Files
2026-04-05 03:08:53 +02:00

309 lines
2.1 MiB
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var r0e=Object.create;var BV=Object.defineProperty;var i0e=Object.getOwnPropertyDescriptor;var o0e=Object.getOwnPropertyNames;var s0e=Object.getPrototypeOf,a0e=Object.prototype.hasOwnProperty;var Al=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var l0e=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of o0e(t))!a0e.call(e,i)&&i!==n&&BV(e,i,{get:()=>t[i],enumerable:!(r=i0e(t,i))||r.enumerable});return e};var L=(e,t,n)=>(n=e!=null?r0e(s0e(e)):{},l0e(t||!e||!e.__esModule?BV(n,"default",{value:e,enumerable:!0}):n,e));var YV=Al(yt=>{"use strict";var nA=Symbol.for("react.transitional.element"),u0e=Symbol.for("react.portal"),c0e=Symbol.for("react.fragment"),d0e=Symbol.for("react.strict_mode"),h0e=Symbol.for("react.profiler"),f0e=Symbol.for("react.consumer"),p0e=Symbol.for("react.context"),m0e=Symbol.for("react.forward_ref"),g0e=Symbol.for("react.suspense"),y0e=Symbol.for("react.memo"),VV=Symbol.for("react.lazy"),v0e=Symbol.for("react.activity"),qV=Symbol.iterator;function b0e(e){return e===null||typeof e!="object"?null:(e=qV&&e[qV]||e["@@iterator"],typeof e=="function"?e:null)}var WV={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},UV=Object.assign,HV={};function Ym(e,t,n){this.props=e,this.context=t,this.refs=HV,this.updater=n||WV}Ym.prototype.isReactComponent={};Ym.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Ym.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function $V(){}$V.prototype=Ym.prototype;function rA(e,t,n){this.props=e,this.context=t,this.refs=HV,this.updater=n||WV}var iA=rA.prototype=new $V;iA.constructor=rA;UV(iA,Ym.prototype);iA.isPureReactComponent=!0;var zV=Array.isArray;function tA(){}var Hn={H:null,A:null,T:null,S:null},KV=Object.prototype.hasOwnProperty;function oA(e,t,n){var r=n.ref;return{$$typeof:nA,type:e,key:t,ref:r!==void 0?r:null,props:n}}function w0e(e,t){return oA(e.type,t,e.props)}function sA(e){return typeof e=="object"&&e!==null&&e.$$typeof===nA}function x0e(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var FV=/\/+/g;function eA(e,t){return typeof e=="object"&&e!==null&&e.key!=null?x0e(""+e.key):t.toString(36)}function S0e(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(tA,tA):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Km(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var s=!1;if(e===null)s=!0;else switch(o){case"bigint":case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case nA:case u0e:s=!0;break;case VV:return s=e._init,Km(s(e._payload),t,n,r,i)}}if(s)return i=i(e),s=r===""?"."+eA(e,0):r,zV(i)?(n="",s!=null&&(n=s.replace(FV,"$&/")+"/"),Km(i,t,n,"",function(u){return u})):i!=null&&(sA(i)&&(i=w0e(i,n+(i.key==null||e&&e.key===i.key?"":(""+i.key).replace(FV,"$&/")+"/")+s)),t.push(i)),1;s=0;var a=r===""?".":r+":";if(zV(e))for(var l=0;l<e.length;l++)r=e[l],o=a+eA(r,l),s+=Km(r,t,n,o,i);else if(l=b0e(e),typeof l=="function")for(e=l.call(e),l=0;!(r=e.next()).done;)r=r.value,o=a+eA(r,l++),s+=Km(r,t,n,o,i);else if(o==="object"){if(typeof e.then=="function")return Km(S0e(e),t,n,r,i);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return s}function WS(e,t,n){if(e==null)return e;var r=[],i=0;return Km(e,r,"","",function(o){return t.call(n,o,i++)}),r}function k0e(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var jV=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},C0e={map:WS,forEach:function(e,t,n){WS(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return WS(e,function(){t++}),t},toArray:function(e){return WS(e,function(t){return t})||[]},only:function(e){if(!sA(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};yt.Activity=v0e;yt.Children=C0e;yt.Component=Ym;yt.Fragment=c0e;yt.Profiler=h0e;yt.PureComponent=rA;yt.StrictMode=d0e;yt.Suspense=g0e;yt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Hn;yt.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Hn.H.useMemoCache(e)}};yt.cache=function(e){return function(){return e.apply(null,arguments)}};yt.cacheSignal=function(){return null};yt.cloneElement=function(e,t,n){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var r=UV({},e.props),i=e.key;if(t!=null)for(o in t.key!==void 0&&(i=""+t.key),t)!KV.call(t,o)||o==="key"||o==="__self"||o==="__source"||o==="ref"&&t.ref===void 0||(r[o]=t[o]);var o=arguments.length-2;if(o===1)r.children=n;else if(1<o){for(var s=Array(o),a=0;a<o;a++)s[a]=arguments[a+2];r.children=s}return oA(e.type,i,r)};yt.createContext=function(e){return e={$$typeof:p0e,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:f0e,_context:e},e};yt.createElement=function(e,t,n){var r,i={},o=null;if(t!=null)for(r in t.key!==void 0&&(o=""+t.key),t)KV.call(t,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(i[r]=t[r]);var s=arguments.length-2;if(s===1)i.children=n;else if(1<s){for(var a=Array(s),l=0;l<s;l++)a[l]=arguments[l+2];i.children=a}if(e&&e.defaultProps)for(r in s=e.defaultProps,s)i[r]===void 0&&(i[r]=s[r]);return oA(e,o,i)};yt.createRef=function(){return{current:null}};yt.forwardRef=function(e){return{$$typeof:m0e,render:e}};yt.isValidElement=sA;yt.lazy=function(e){return{$$typeof:VV,_payload:{_status:-1,_result:e},_init:k0e}};yt.memo=function(e,t){return{$$typeof:y0e,type:e,compare:t===void 0?null:t}};yt.startTransition=function(e){var t=Hn.T,n={};Hn.T=n;try{var r=e(),i=Hn.S;i!==null&&i(n,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(tA,jV)}catch(o){jV(o)}finally{t!==null&&n.types!==null&&(t.types=n.types),Hn.T=t}};yt.unstable_useCacheRefresh=function(){return Hn.H.useCacheRefresh()};yt.use=function(e){return Hn.H.use(e)};yt.useActionState=function(e,t,n){return Hn.H.useActionState(e,t,n)};yt.useCallback=function(e,t){return Hn.H.useCallback(e,t)};yt.useContext=function(e){return Hn.H.useContext(e)};yt.useDebugValue=function(){};yt.useDeferredValue=function(e,t){return Hn.H.useDeferredValue(e,t)};yt.useEffect=function(e,t){return Hn.H.useEffect(e,t)};yt.useEffectEvent=function(e){return Hn.H.useEffectEvent(e)};yt.useId=function(){return Hn.H.useId()};yt.useImperativeHandle=function(e,t,n){return Hn.H.useImperativeHandle(e,t,n)};yt.useInsertionEffect=function(e,t){return Hn.H.useInsertionEffect(e,t)};yt.useLayoutEffect=function(e,t){return Hn.H.useLayoutEffect(e,t)};yt.useMemo=function(e,t){return Hn.H.useMemo(e,t)};yt.useOptimistic=function(e,t){return Hn.H.useOptimistic(e,t)};yt.useReducer=function(e,t,n){return Hn.H.useReducer(e,t,n)};yt.useRef=function(e){return Hn.H.useRef(e)};yt.useState=function(e){return Hn.H.useState(e)};yt.useSyncExternalStore=function(e,t,n){return Hn.H.useSyncExternalStore(e,t,n)};yt.useTransition=function(){return Hn.H.useTransition()};yt.version="19.2.0"});var H=Al((ept,QV)=>{"use strict";QV.exports=YV()});var XV=Al(mo=>{"use strict";var N0e=H();function GV(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function bd(){}var po={d:{f:bd,r:function(){throw Error(GV(522))},D:bd,C:bd,L:bd,m:bd,X:bd,S:bd,M:bd},p:0,findDOMNode:null},M0e=Symbol.for("react.portal");function _0e(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M0e,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}var B0=N0e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function US(e,t){if(e==="font")return"";if(typeof t=="string")return t==="use-credentials"?t:""}mo.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=po;mo.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(GV(299));return _0e(e,t,null,n)};mo.flushSync=function(e){var t=B0.T,n=po.p;try{if(B0.T=null,po.p=2,e)return e()}finally{B0.T=t,po.p=n,po.d.f()}};mo.preconnect=function(e,t){typeof e=="string"&&(t?(t=t.crossOrigin,t=typeof t=="string"?t==="use-credentials"?t:"":void 0):t=null,po.d.C(e,t))};mo.prefetchDNS=function(e){typeof e=="string"&&po.d.D(e)};mo.preinit=function(e,t){if(typeof e=="string"&&t&&typeof t.as=="string"){var n=t.as,r=US(n,t.crossOrigin),i=typeof t.integrity=="string"?t.integrity:void 0,o=typeof t.fetchPriority=="string"?t.fetchPriority:void 0;n==="style"?po.d.S(e,typeof t.precedence=="string"?t.precedence:void 0,{crossOrigin:r,integrity:i,fetchPriority:o}):n==="script"&&po.d.X(e,{crossOrigin:r,integrity:i,fetchPriority:o,nonce:typeof t.nonce=="string"?t.nonce:void 0})}};mo.preinitModule=function(e,t){if(typeof e=="string")if(typeof t=="object"&&t!==null){if(t.as==null||t.as==="script"){var n=US(t.as,t.crossOrigin);po.d.M(e,{crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0})}}else t==null&&po.d.M(e)};mo.preload=function(e,t){if(typeof e=="string"&&typeof t=="object"&&t!==null&&typeof t.as=="string"){var n=t.as,r=US(n,t.crossOrigin);po.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity=="string"?t.integrity:void 0,nonce:typeof t.nonce=="string"?t.nonce:void 0,type:typeof t.type=="string"?t.type:void 0,fetchPriority:typeof t.fetchPriority=="string"?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy=="string"?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet=="string"?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes=="string"?t.imageSizes:void 0,media:typeof t.media=="string"?t.media:void 0})}};mo.preloadModule=function(e,t){if(typeof e=="string")if(t){var n=US(t.as,t.crossOrigin);po.d.m(e,{as:typeof t.as=="string"&&t.as!=="script"?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity=="string"?t.integrity:void 0})}else po.d.m(e)};mo.requestFormReset=function(e){po.d.r(e)};mo.unstable_batchedUpdates=function(e,t){return e(t)};mo.useFormState=function(e,t,n){return B0.H.useFormState(e,t,n)};mo.useFormStatus=function(){return B0.H.useHostTransitionStatus()};mo.version="19.2.0"});var rn=Al((npt,ZV)=>{"use strict";function JV(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(JV)}catch(e){console.error(e)}}JV(),ZV.exports=XV()});var sU=Al(Mk=>{"use strict";var F1e=Symbol.for("react.transitional.element"),j1e=Symbol.for("react.fragment");function oU(e,t,n){var r=null;if(n!==void 0&&(r=""+n),t.key!==void 0&&(r=""+t.key),"key"in t){n={};for(var i in t)i!=="key"&&(n[i]=t[i])}else n=t;return t=n.ref,{$$typeof:F1e,type:e,key:r,ref:t!==void 0?t:null,props:n}}Mk.Fragment=j1e;Mk.jsx=oU;Mk.jsxs=oU});var le=Al((Ngt,aU)=>{"use strict";aU.exports=sU()});var Lpe=Al(ar=>{"use strict";function sF(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,i=e[r];if(0<SO(i,t))e[r]=t,e[n]=i,n=r;else break e}}function Ru(e){return e.length===0?null:e[0]}function CO(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,i=e.length,o=i>>>1;r<o;){var s=2*(r+1)-1,a=e[s],l=s+1,u=e[l];if(0>SO(a,n))l<i&&0>SO(u,a)?(e[r]=u,e[l]=n,r=l):(e[r]=a,e[s]=n,r=s);else if(l<i&&0>SO(u,n))e[r]=u,e[l]=n,r=l;else break e}}return t}function SO(e,t){var n=e.sortIndex-t.sortIndex;return n!==0?n:e.id-t.id}ar.unstable_now=void 0;typeof performance=="object"&&typeof performance.now=="function"?(_pe=performance,ar.unstable_now=function(){return _pe.now()}):(rF=Date,Epe=rF.now(),ar.unstable_now=function(){return rF.now()-Epe});var _pe,rF,Epe,Qc=[],of=[],bdt=1,Da=null,fo=3,aF=!1,q1=!1,z1=!1,lF=!1,Ape=typeof setTimeout=="function"?setTimeout:null,Dpe=typeof clearTimeout=="function"?clearTimeout:null,Ope=typeof setImmediate<"u"?setImmediate:null;function kO(e){for(var t=Ru(of);t!==null;){if(t.callback===null)CO(of);else if(t.startTime<=e)CO(of),t.sortIndex=t.expirationTime,sF(Qc,t);else break;t=Ru(of)}}function uF(e){if(z1=!1,kO(e),!q1)if(Ru(Qc)!==null)q1=!0,Uv||(Uv=!0,Wv());else{var t=Ru(of);t!==null&&cF(uF,t.startTime-e)}}var Uv=!1,F1=-1,Rpe=5,Ipe=-1;function Ppe(){return lF?!0:!(ar.unstable_now()-Ipe<Rpe)}function iF(){if(lF=!1,Uv){var e=ar.unstable_now();Ipe=e;var t=!0;try{e:{q1=!1,z1&&(z1=!1,Dpe(F1),F1=-1),aF=!0;var n=fo;try{t:{for(kO(e),Da=Ru(Qc);Da!==null&&!(Da.expirationTime>e&&Ppe());){var r=Da.callback;if(typeof r=="function"){Da.callback=null,fo=Da.priorityLevel;var i=r(Da.expirationTime<=e);if(e=ar.unstable_now(),typeof i=="function"){Da.callback=i,kO(e),t=!0;break t}Da===Ru(Qc)&&CO(Qc),kO(e)}else CO(Qc);Da=Ru(Qc)}if(Da!==null)t=!0;else{var o=Ru(of);o!==null&&cF(uF,o.startTime-e),t=!1}}break e}finally{Da=null,fo=n,aF=!1}t=void 0}}finally{t?Wv():Uv=!1}}}var Wv;typeof Ope=="function"?Wv=function(){Ope(iF)}:typeof MessageChannel<"u"?(oF=new MessageChannel,Tpe=oF.port2,oF.port1.onmessage=iF,Wv=function(){Tpe.postMessage(null)}):Wv=function(){Ape(iF,0)};var oF,Tpe;function cF(e,t){F1=Ape(function(){e(ar.unstable_now())},t)}ar.unstable_IdlePriority=5;ar.unstable_ImmediatePriority=1;ar.unstable_LowPriority=4;ar.unstable_NormalPriority=3;ar.unstable_Profiling=null;ar.unstable_UserBlockingPriority=2;ar.unstable_cancelCallback=function(e){e.callback=null};ar.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):Rpe=0<e?Math.floor(1e3/e):5};ar.unstable_getCurrentPriorityLevel=function(){return fo};ar.unstable_next=function(e){switch(fo){case 1:case 2:case 3:var t=3;break;default:t=fo}var n=fo;fo=t;try{return e()}finally{fo=n}};ar.unstable_requestPaint=function(){lF=!0};ar.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=fo;fo=e;try{return t()}finally{fo=n}};ar.unstable_scheduleCallback=function(e,t,n){var r=ar.unstable_now();switch(typeof n=="object"&&n!==null?(n=n.delay,n=typeof n=="number"&&0<n?r+n:r):n=r,e){case 1:var i=-1;break;case 2:i=250;break;case 5:i=1073741823;break;case 4:i=1e4;break;default:i=5e3}return i=n+i,e={id:bdt++,callback:t,priorityLevel:e,startTime:n,expirationTime:i,sortIndex:-1},n>r?(e.sortIndex=n,sF(of,e),Ru(Qc)===null&&e===Ru(of)&&(z1?(Dpe(F1),F1=-1):z1=!0,cF(uF,n-r))):(e.sortIndex=i,sF(Qc,e),q1||aF||(q1=!0,Uv||(Uv=!0,Wv()))),e};ar.unstable_shouldYield=Ppe;ar.unstable_wrapCallback=function(e){var t=fo;return function(){var n=fo;fo=t;try{return e.apply(this,arguments)}finally{fo=n}}}});var qpe=Al((ESt,Bpe)=>{"use strict";Bpe.exports=Lpe()});var Gve=Al(QT=>{"use strict";var vi=qpe(),cge=H(),wdt=rn();function re(e){var t="https://react.dev/errors/"+e;if(1<arguments.length){t+="?args[]="+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n])}return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function dge(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function MS(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,(t.flags&4098)!==0&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function hge(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function fge(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function zpe(e){if(MS(e)!==e)throw Error(re(188))}function xdt(e){var t=e.alternate;if(!t){if(t=MS(e),t===null)throw Error(re(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return zpe(i),e;if(o===r)return zpe(i),t;o=o.sibling}throw Error(re(188))}if(n.return!==r.return)n=i,r=o;else{for(var s=!1,a=i.child;a;){if(a===n){s=!0,n=i,r=o;break}if(a===r){s=!0,r=i,n=o;break}a=a.sibling}if(!s){for(a=o.child;a;){if(a===n){s=!0,n=o,r=i;break}if(a===r){s=!0,r=o,n=i;break}a=a.sibling}if(!s)throw Error(re(189))}}if(n.alternate!==r)throw Error(re(190))}if(n.tag!==3)throw Error(re(188));return n.stateNode.current===n?e:t}function pge(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=pge(e),t!==null)return t;e=e.sibling}return null}var Jn=Object.assign,Sdt=Symbol.for("react.element"),NO=Symbol.for("react.transitional.element"),Y1=Symbol.for("react.portal"),Gv=Symbol.for("react.fragment"),mge=Symbol.for("react.strict_mode"),UF=Symbol.for("react.profiler"),gge=Symbol.for("react.consumer"),rd=Symbol.for("react.context"),zj=Symbol.for("react.forward_ref"),HF=Symbol.for("react.suspense"),$F=Symbol.for("react.suspense_list"),Fj=Symbol.for("react.memo"),sf=Symbol.for("react.lazy");Symbol.for("react.scope");var KF=Symbol.for("react.activity");Symbol.for("react.legacy_hidden");Symbol.for("react.tracing_marker");var kdt=Symbol.for("react.memo_cache_sentinel");Symbol.for("react.view_transition");var Fpe=Symbol.iterator;function j1(e){return e===null||typeof e!="object"?null:(e=Fpe&&e[Fpe]||e["@@iterator"],typeof e=="function"?e:null)}var Cdt=Symbol.for("react.client.reference");function YF(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Cdt?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Gv:return"Fragment";case UF:return"Profiler";case mge:return"StrictMode";case HF:return"Suspense";case $F:return"SuspenseList";case KF:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case Y1:return"Portal";case rd:return e.displayName||"Context";case gge:return(e._context.displayName||"Context")+".Consumer";case zj:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Fj:return t=e.displayName||null,t!==null?t:YF(e.type)||"Memo";case sf:t=e._payload,e=e._init;try{return YF(e(t))}catch{}}return null}var Q1=Array.isArray,nt=cge.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ln=wdt.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Om={pending:!1,data:null,method:null,action:null},QF=[],Xv=-1;function qu(e){return{current:e}}function Di(e){0>Xv||(e.current=QF[Xv],QF[Xv]=null,Xv--)}function Wn(e,t){Xv++,QF[Xv]=e.current,e.current=t}var Bu=qu(null),hS=qu(null),yf=qu(null),iT=qu(null);function oT(e,t){switch(Wn(yf,t),Wn(hS,e),Wn(Bu,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kme(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kme(t),e=Lve(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Di(Bu),Wn(Bu,e)}function m0(){Di(Bu),Di(hS),Di(yf)}function GF(e){e.memoizedState!==null&&Wn(iT,e);var t=Bu.current,n=Lve(t,e.type);t!==n&&(Wn(hS,e),Wn(Bu,n))}function sT(e){hS.current===e&&(Di(Bu),Di(hS)),iT.current===e&&(Di(iT),kS._currentValue=Om)}var dF,jpe;function Nm(e){if(dF===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);dF=t&&t[1]||"",jpe=-1<n.stack.indexOf(`
at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
`+dF+e+jpe}var hF=!1;function fF(e,t){if(!e||hF)return"";hF=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var d=function(){throw Error()};if(Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(f){var h=f}Reflect.construct(e,[],d)}else{try{d.call()}catch(f){h=f}e.call(d.prototype)}}else{try{throw Error()}catch(f){h=f}(d=e())&&typeof d.catch=="function"&&d.catch(function(){})}}catch(f){if(f&&h&&typeof f.stack=="string")return[f.stack,h.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,"name");i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=r.DetermineComponentFrameRoot(),s=o[0],a=o[1];if(s&&a){var l=s.split(`
`),u=a.split(`
`);for(i=r=0;r<l.length&&!l[r].includes("DetermineComponentFrameRoot");)r++;for(;i<u.length&&!u[i].includes("DetermineComponentFrameRoot");)i++;if(r===l.length||i===u.length)for(r=l.length-1,i=u.length-1;1<=r&&0<=i&&l[r]!==u[i];)i--;for(;1<=r&&0<=i;r--,i--)if(l[r]!==u[i]){if(r!==1||i!==1)do if(r--,i--,0>i||l[r]!==u[i]){var c=`
`+l[r].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=r&&0<=i);break}}}finally{hF=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Nm(n):""}function Ndt(e,t){switch(e.tag){case 26:case 27:case 5:return Nm(e.type);case 16:return Nm("Lazy");case 13:return e.child!==t&&t!==null?Nm("Suspense Fallback"):Nm("Suspense");case 19:return Nm("SuspenseList");case 0:case 15:return fF(e.type,!1);case 11:return fF(e.type.render,!1);case 1:return fF(e.type,!0);case 31:return Nm("Activity");default:return""}}function Vpe(e){try{var t="",n=null;do t+=Ndt(e,n),n=e,e=e.return;while(e);return t}catch(r){return`
Error generating stack: `+r.message+`
`+r.stack}}var XF=Object.prototype.hasOwnProperty,jj=vi.unstable_scheduleCallback,pF=vi.unstable_cancelCallback,Mdt=vi.unstable_shouldYield,_dt=vi.unstable_requestPaint,Ks=vi.unstable_now,Edt=vi.unstable_getCurrentPriorityLevel,yge=vi.unstable_ImmediatePriority,vge=vi.unstable_UserBlockingPriority,aT=vi.unstable_NormalPriority,Odt=vi.unstable_LowPriority,bge=vi.unstable_IdlePriority,Tdt=vi.log,Adt=vi.unstable_setDisableYieldValue,_S=null,Ys=null;function hf(e){if(typeof Tdt=="function"&&Adt(e),Ys&&typeof Ys.setStrictMode=="function")try{Ys.setStrictMode(_S,e)}catch{}}var Qs=Math.clz32?Math.clz32:Idt,Ddt=Math.log,Rdt=Math.LN2;function Idt(e){return e>>>=0,e===0?32:31-(Ddt(e)/Rdt|0)|0}var MO=256,_O=262144,EO=4194304;function Mm(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function RT(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,o=e.suspendedLanes,s=e.pingedLanes;e=e.warmLanes;var a=r&134217727;return a!==0?(r=a&~o,r!==0?i=Mm(r):(s&=a,s!==0?i=Mm(s):n||(n=a&~e,n!==0&&(i=Mm(n))))):(a=r&~o,a!==0?i=Mm(a):s!==0?i=Mm(s):n||(n=r&~e,n!==0&&(i=Mm(n)))),i===0?0:t!==0&&t!==i&&(t&o)===0&&(o=i&-i,n=t&-t,o>=n||o===32&&(n&4194048)!==0)?t:i}function ES(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Pdt(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function wge(){var e=EO;return EO<<=1,(EO&62914560)===0&&(EO=4194304),e}function mF(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function OS(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ldt(e,t,n,r,i,o){var s=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var a=e.entanglements,l=e.expirationTimes,u=e.hiddenUpdates;for(n=s&~n;0<n;){var c=31-Qs(n),d=1<<c;a[c]=0,l[c]=-1;var h=u[c];if(h!==null)for(u[c]=null,c=0;c<h.length;c++){var f=h[c];f!==null&&(f.lane&=-536870913)}n&=~d}r!==0&&xge(e,r,0),o!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=o&~(s&~t))}function xge(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Qs(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Sge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Qs(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function kge(e,t){var n=t&-t;return n=(n&42)!==0?1:Vj(n),(n&(e.suspendedLanes|t))!==0?0:n}function Vj(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;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:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Wj(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Cge(){var e=ln.p;return e!==0?e:(e=window.event,e===void 0?32:Kve(e.type))}function Wpe(e,t){var n=ln.p;try{return ln.p=e,t()}finally{ln.p=n}}var Tf=Math.random().toString(36).slice(2),$i="__reactFiber$"+Tf,hs="__reactProps$"+Tf,M0="__reactContainer$"+Tf,JF="__reactEvents$"+Tf,Bdt="__reactListeners$"+Tf,qdt="__reactHandles$"+Tf,Upe="__reactResources$"+Tf,TS="__reactMarker$"+Tf;function Uj(e){delete e[$i],delete e[hs],delete e[JF],delete e[Bdt],delete e[qdt]}function Jv(e){var t=e[$i];if(t)return t;for(var n=e.parentNode;n;){if(t=n[M0]||n[$i]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Jme(e);e!==null;){if(n=e[$i])return n;e=Jme(e)}return t}e=n,n=e.parentNode}return null}function _0(e){if(e=e[$i]||e[M0]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function G1(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(re(33))}function l0(e){var t=e[Upe];return t||(t=e[Upe]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function Ai(e){e[TS]=!0}var Nge=new Set,Mge={};function zm(e,t){g0(e,t),g0(e+"Capture",t)}function g0(e,t){for(Mge[e]=t,e=0;e<t.length;e++)Nge.add(t[e])}var zdt=RegExp("^[: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]*$"),Hpe={},$pe={};function Fdt(e){return XF.call($pe,e)?!0:XF.call(Hpe,e)?!1:zdt.test(e)?$pe[e]=!0:(Hpe[e]=!0,!1)}function WO(e,t,n){if(Fdt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var r=t.toLowerCase().slice(0,5);if(r!=="data-"&&r!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function OO(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(t);return}e.setAttribute(t,""+n)}}function Gc(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+r)}}function Ia(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function _ge(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function jdt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var i=r.get,o=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(s){n=""+s,o.call(this,s)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(s){n=""+s},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ZF(e){if(!e._valueTracker){var t=_ge(e)?"checked":"value";e._valueTracker=jdt(e,t,""+e[t])}}function Ege(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=_ge(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function lT(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var Vdt=/[\n"\\]/g;function Ba(e){return e.replace(Vdt,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function ej(e,t,n,r,i,o,s,a){e.name="",s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.type=s:e.removeAttribute("type"),t!=null?s==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Ia(t)):e.value!==""+Ia(t)&&(e.value=""+Ia(t)):s!=="submit"&&s!=="reset"||e.removeAttribute("value"),t!=null?tj(e,s,Ia(t)):n!=null?tj(e,s,Ia(n)):r!=null&&e.removeAttribute("value"),i==null&&o!=null&&(e.defaultChecked=!!o),i!=null&&(e.checked=i&&typeof i!="function"&&typeof i!="symbol"),a!=null&&typeof a!="function"&&typeof a!="symbol"&&typeof a!="boolean"?e.name=""+Ia(a):e.removeAttribute("name")}function Oge(e,t,n,r,i,o,s,a){if(o!=null&&typeof o!="function"&&typeof o!="symbol"&&typeof o!="boolean"&&(e.type=o),t!=null||n!=null){if(!(o!=="submit"&&o!=="reset"||t!=null)){ZF(e);return}n=n!=null?""+Ia(n):"",t=t!=null?""+Ia(t):n,a||t===e.value||(e.value=t),e.defaultValue=t}r=r??i,r=typeof r!="function"&&typeof r!="symbol"&&!!r,e.checked=a?e.checked:!!r,e.defaultChecked=!!r,s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"&&(e.name=s),ZF(e)}function tj(e,t,n){t==="number"&&lT(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function u0(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+Ia(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Tge(e,t,n){if(t!=null&&(t=""+Ia(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Ia(n):""}function Age(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(re(92));if(Q1(r)){if(1<r.length)throw Error(re(93));r=r[0]}n=r}n==null&&(n=""),t=n}n=Ia(t),e.defaultValue=n,r=e.textContent,r===n&&r!==""&&r!==null&&(e.value=r),ZF(e)}function y0(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Wdt=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function Kpe(e,t,n){var r=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?r?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":r?e.setProperty(t,n):typeof n!="number"||n===0||Wdt.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Dge(e,t,n){if(t!=null&&typeof t!="object")throw Error(re(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf("--")===0?e.setProperty(r,""):r==="float"?e.cssFloat="":e[r]="");for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Kpe(e,i,r)}else for(var o in t)t.hasOwnProperty(o)&&Kpe(e,o,t[o])}function Hj(e){if(e.indexOf("-")===-1)return!1;switch(e){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 Udt=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Hdt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function UO(e){return Hdt.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function id(){}var nj=null;function $j(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zv=null,c0=null;function Ype(e){var t=_0(e);if(t&&(e=t.stateNode)){var n=e[hs]||null;e:switch(e=t.stateNode,t.type){case"input":if(ej(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll('input[name="'+Ba(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[hs]||null;if(!i)throw Error(re(90));ej(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Ege(r)}break e;case"textarea":Tge(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&u0(e,!!n.multiple,t,!1)}}}var gF=!1;function Rge(e,t,n){if(gF)return e(t,n);gF=!0;try{var r=e(t);return r}finally{if(gF=!1,(Zv!==null||c0!==null)&&(HT(),Zv&&(t=Zv,e=c0,c0=Zv=null,Ype(t),e)))for(t=0;t<e.length;t++)Ype(e[t])}}function fS(e,t){var n=e.stateNode;if(n===null)return null;var r=n[hs]||null;if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(re(231,t,typeof n));return n}var ud=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),rj=!1;if(ud)try{Hv={},Object.defineProperty(Hv,"passive",{get:function(){rj=!0}}),window.addEventListener("test",Hv,Hv),window.removeEventListener("test",Hv,Hv)}catch{rj=!1}var Hv,ff=null,Kj=null,HO=null;function Ige(){if(HO)return HO;var e,t=Kj,n=t.length,r,i="value"in ff?ff.value:ff.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var s=n-e;for(r=1;r<=s&&t[n-r]===i[o-r];r++);return HO=i.slice(e,1<r?1-r:void 0)}function $O(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function TO(){return!0}function Qpe(){return!1}function fs(e){function t(n,r,i,o,s){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=s,this.currentTarget=null;for(var a in e)e.hasOwnProperty(a)&&(n=e[a],this[a]=n?n(o):o[a]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?TO:Qpe,this.isPropagationStopped=Qpe,this}return Jn(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=TO)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=TO)},persist:function(){},isPersistent:TO}),t}var Fm={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},IT=fs(Fm),AS=Jn({},Fm,{view:0,detail:0}),$dt=fs(AS),yF,vF,V1,PT=Jn({},AS,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Yj,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==V1&&(V1&&e.type==="mousemove"?(yF=e.screenX-V1.screenX,vF=e.screenY-V1.screenY):vF=yF=0,V1=e),yF)},movementY:function(e){return"movementY"in e?e.movementY:vF}}),Gpe=fs(PT),Kdt=Jn({},PT,{dataTransfer:0}),Ydt=fs(Kdt),Qdt=Jn({},AS,{relatedTarget:0}),bF=fs(Qdt),Gdt=Jn({},Fm,{animationName:0,elapsedTime:0,pseudoElement:0}),Xdt=fs(Gdt),Jdt=Jn({},Fm,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Zdt=fs(Jdt),eht=Jn({},Fm,{data:0}),Xpe=fs(eht),tht={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nht={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},rht={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function iht(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rht[e])?!!t[e]:!1}function Yj(){return iht}var oht=Jn({},AS,{key:function(e){if(e.key){var t=tht[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=$O(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?nht[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Yj,charCode:function(e){return e.type==="keypress"?$O(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?$O(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),sht=fs(oht),aht=Jn({},PT,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Jpe=fs(aht),lht=Jn({},AS,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Yj}),uht=fs(lht),cht=Jn({},Fm,{propertyName:0,elapsedTime:0,pseudoElement:0}),dht=fs(cht),hht=Jn({},PT,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),fht=fs(hht),pht=Jn({},Fm,{newState:0,oldState:0}),mht=fs(pht),ght=[9,13,27,32],Qj=ud&&"CompositionEvent"in window,Z1=null;ud&&"documentMode"in document&&(Z1=document.documentMode);var yht=ud&&"TextEvent"in window&&!Z1,Pge=ud&&(!Qj||Z1&&8<Z1&&11>=Z1),Zpe=" ",eme=!1;function Lge(e,t){switch(e){case"keyup":return ght.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Bge(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var e0=!1;function vht(e,t){switch(e){case"compositionend":return Bge(t);case"keypress":return t.which!==32?null:(eme=!0,Zpe);case"textInput":return e=t.data,e===Zpe&&eme?null:e;default:return null}}function bht(e,t){if(e0)return e==="compositionend"||!Qj&&Lge(e,t)?(e=Ige(),HO=Kj=ff=null,e0=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Pge&&t.locale!=="ko"?null:t.data;default:return null}}var wht={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function tme(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!wht[e.type]:t==="textarea"}function qge(e,t,n,r){Zv?c0?c0.push(r):c0=[r]:Zv=r,t=MT(t,"onChange"),0<t.length&&(n=new IT("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var eS=null,pS=null;function xht(e){Rve(e,0)}function LT(e){var t=G1(e);if(Ege(t))return e}function nme(e,t){if(e==="change")return t}var zge=!1;ud&&(ud?(DO="oninput"in document,DO||(wF=document.createElement("div"),wF.setAttribute("oninput","return;"),DO=typeof wF.oninput=="function"),AO=DO):AO=!1,zge=AO&&(!document.documentMode||9<document.documentMode));var AO,DO,wF;function rme(){eS&&(eS.detachEvent("onpropertychange",Fge),pS=eS=null)}function Fge(e){if(e.propertyName==="value"&&LT(pS)){var t=[];qge(t,pS,e,$j(e)),Rge(xht,t)}}function Sht(e,t,n){e==="focusin"?(rme(),eS=t,pS=n,eS.attachEvent("onpropertychange",Fge)):e==="focusout"&&rme()}function kht(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return LT(pS)}function Cht(e,t){if(e==="click")return LT(t)}function Nht(e,t){if(e==="input"||e==="change")return LT(t)}function Mht(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Xs=typeof Object.is=="function"?Object.is:Mht;function mS(e,t){if(Xs(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!XF.call(t,i)||!Xs(e[i],t[i]))return!1}return!0}function ime(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ome(e,t){var n=ime(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ime(n)}}function jge(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?jge(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Vge(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=lT(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=lT(e.document)}return t}function Gj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var _ht=ud&&"documentMode"in document&&11>=document.documentMode,t0=null,ij=null,tS=null,oj=!1;function sme(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;oj||t0==null||t0!==lT(r)||(r=t0,"selectionStart"in r&&Gj(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),tS&&mS(tS,r)||(tS=r,r=MT(ij,"onSelect"),0<r.length&&(t=new IT("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=t0)))}function Cm(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var n0={animationend:Cm("Animation","AnimationEnd"),animationiteration:Cm("Animation","AnimationIteration"),animationstart:Cm("Animation","AnimationStart"),transitionrun:Cm("Transition","TransitionRun"),transitionstart:Cm("Transition","TransitionStart"),transitioncancel:Cm("Transition","TransitionCancel"),transitionend:Cm("Transition","TransitionEnd")},xF={},Wge={};ud&&(Wge=document.createElement("div").style,"AnimationEvent"in window||(delete n0.animationend.animation,delete n0.animationiteration.animation,delete n0.animationstart.animation),"TransitionEvent"in window||delete n0.transitionend.transition);function jm(e){if(xF[e])return xF[e];if(!n0[e])return e;var t=n0[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Wge)return xF[e]=t[n];return e}var Uge=jm("animationend"),Hge=jm("animationiteration"),$ge=jm("animationstart"),Eht=jm("transitionrun"),Oht=jm("transitionstart"),Tht=jm("transitioncancel"),Kge=jm("transitionend"),Yge=new Map,sj="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");sj.push("scrollEnd");function El(e,t){Yge.set(e,t),zm(t,[e])}var uT=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Ra=[],r0=0,Xj=0;function BT(){for(var e=r0,t=Xj=r0=0;t<e;){var n=Ra[t];Ra[t++]=null;var r=Ra[t];Ra[t++]=null;var i=Ra[t];Ra[t++]=null;var o=Ra[t];if(Ra[t++]=null,r!==null&&i!==null){var s=r.pending;s===null?i.next=i:(i.next=s.next,s.next=i),r.pending=i}o!==0&&Qge(n,i,o)}}function qT(e,t,n,r){Ra[r0++]=e,Ra[r0++]=t,Ra[r0++]=n,Ra[r0++]=r,Xj|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Jj(e,t,n,r){return qT(e,t,n,r),cT(e)}function Vm(e,t){return qT(e,null,null,t),cT(e)}function Qge(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,o=e.return;o!==null;)o.childLanes|=n,r=o.alternate,r!==null&&(r.childLanes|=n),o.tag===22&&(e=o.stateNode,e===null||e._visibility&1||(i=!0)),e=o,o=o.return;return e.tag===3?(o=e.stateNode,i&&t!==null&&(i=31-Qs(n),e=o.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),o):null}function cT(e){if(50<cS)throw cS=0,_j=null,Error(re(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var i0={};function Aht(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Hs(e,t,n,r){return new Aht(e,t,n,r)}function Zj(e){return e=e.prototype,!(!e||!e.isReactComponent)}function sd(e,t){var n=e.alternate;return n===null?(n=Hs(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Gge(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function KO(e,t,n,r,i,o){var s=0;if(r=e,typeof e=="function")Zj(e)&&(s=1);else if(typeof e=="string")s=Ift(e,n,Bu.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case KF:return e=Hs(31,n,t,i),e.elementType=KF,e.lanes=o,e;case Gv:return Tm(n.children,i,o,t);case mge:s=8,i|=24;break;case UF:return e=Hs(12,n,t,i|2),e.elementType=UF,e.lanes=o,e;case HF:return e=Hs(13,n,t,i),e.elementType=HF,e.lanes=o,e;case $F:return e=Hs(19,n,t,i),e.elementType=$F,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case rd:s=10;break e;case gge:s=9;break e;case zj:s=11;break e;case Fj:s=14;break e;case sf:s=16,r=null;break e}s=29,n=Error(re(130,e===null?"null":typeof e,"")),r=null}return t=Hs(s,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Tm(e,t,n,r){return e=Hs(7,e,r,t),e.lanes=n,e}function SF(e,t,n){return e=Hs(6,e,null,t),e.lanes=n,e}function Xge(e){var t=Hs(18,null,null,0);return t.stateNode=e,t}function kF(e,t,n){return t=Hs(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ame=new WeakMap;function qa(e,t){if(typeof e=="object"&&e!==null){var n=ame.get(e);return n!==void 0?n:(t={value:e,source:t,stack:Vpe(t)},ame.set(e,t),t)}return{value:e,source:t,stack:Vpe(t)}}var o0=[],s0=0,dT=null,gS=0,Pa=[],La=0,Mf=null,Iu=1,Pu="";function td(e,t){o0[s0++]=gS,o0[s0++]=dT,dT=e,gS=t}function Jge(e,t,n){Pa[La++]=Iu,Pa[La++]=Pu,Pa[La++]=Mf,Mf=e;var r=Iu;e=Pu;var i=32-Qs(r)-1;r&=~(1<<i),n+=1;var o=32-Qs(t)+i;if(30<o){var s=i-i%5;o=(r&(1<<s)-1).toString(32),r>>=s,i-=s,Iu=1<<32-Qs(t)+i|n<<i|r,Pu=o+e}else Iu=1<<o|n<<i|r,Pu=e}function eV(e){e.return!==null&&(td(e,1),Jge(e,1,0))}function tV(e){for(;e===dT;)dT=o0[--s0],o0[s0]=null,gS=o0[--s0],o0[s0]=null;for(;e===Mf;)Mf=Pa[--La],Pa[La]=null,Pu=Pa[--La],Pa[La]=null,Iu=Pa[--La],Pa[La]=null}function Zge(e,t){Pa[La++]=Iu,Pa[La++]=Pu,Pa[La++]=Mf,Iu=t.id,Pu=t.overflow,Mf=e}var Ki=null,Xn=null,Ut=!1,vf=null,za=!1,aj=Error(re(519));function _f(e){var t=Error(re(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw yS(qa(t,e)),aj}function lme(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[$i]=e,t[hs]=r,n){case"dialog":zt("cancel",t),zt("close",t);break;case"iframe":case"object":case"embed":zt("load",t);break;case"video":case"audio":for(n=0;n<xS.length;n++)zt(xS[n],t);break;case"source":zt("error",t);break;case"img":case"image":case"link":zt("error",t),zt("load",t);break;case"details":zt("toggle",t);break;case"input":zt("invalid",t),Oge(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case"select":zt("invalid",t);break;case"textarea":zt("invalid",t),Age(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||r.suppressHydrationWarning===!0||Pve(t.textContent,n)?(r.popover!=null&&(zt("beforetoggle",t),zt("toggle",t)),r.onScroll!=null&&zt("scroll",t),r.onScrollEnd!=null&&zt("scrollend",t),r.onClick!=null&&(t.onclick=id),t=!0):t=!1,t||_f(e,!0)}function ume(e){for(Ki=e.return;Ki;)switch(Ki.tag){case 5:case 31:case 13:za=!1;return;case 27:case 3:za=!0;return;default:Ki=Ki.return}}function $v(e){if(e!==Ki)return!1;if(!Ut)return ume(e),Ut=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||Dj(e.type,e.memoizedProps)),n=!n),n&&Xn&&_f(e),ume(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(re(317));Xn=Xme(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(re(317));Xn=Xme(e)}else t===27?(t=Xn,Af(e.type)?(e=Lj,Lj=null,Xn=e):Xn=t):Xn=Ki?ja(e.stateNode.nextSibling):null;return!0}function Im(){Xn=Ki=null,Ut=!1}function CF(){var e=vf;return e!==null&&(cs===null?cs=e:cs.push.apply(cs,e),vf=null),e}function yS(e){vf===null?vf=[e]:vf.push(e)}var lj=qu(null),Wm=null,od=null;function lf(e,t,n){Wn(lj,t._currentValue),t._currentValue=n}function ad(e){e._currentValue=lj.current,Di(lj)}function uj(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function cj(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var o=i.dependencies;if(o!==null){var s=i.child;o=o.firstContext;e:for(;o!==null;){var a=o;o=i;for(var l=0;l<t.length;l++)if(a.context===t[l]){o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),uj(o.return,n,e),r||(s=null);break e}o=a.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(re(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),uj(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function E0(e,t,n,r){e=null;for(var i=t,o=!1;i!==null;){if(!o){if((i.flags&524288)!==0)o=!0;else if((i.flags&262144)!==0)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(re(387));if(s=s.memoizedProps,s!==null){var a=i.type;Xs(i.pendingProps.value,s.value)||(e!==null?e.push(a):e=[a])}}else if(i===iT.current){if(s=i.alternate,s===null)throw Error(re(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e!==null?e.push(kS):e=[kS])}i=i.return}e!==null&&cj(t,e,n,r),t.flags|=262144}function hT(e){for(e=e.firstContext;e!==null;){if(!Xs(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Pm(e){Wm=e,od=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Yi(e){return eye(Wm,e)}function RO(e,t){return Wm===null&&Pm(e),eye(e,t)}function eye(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},od===null){if(e===null)throw Error(re(308));od=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else od=od.next=t;return n}var Dht=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,r){e.push(r)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},Rht=vi.unstable_scheduleCallback,Iht=vi.unstable_NormalPriority,ni={$$typeof:rd,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function nV(){return{controller:new Dht,data:new Map,refCount:0}}function DS(e){e.refCount--,e.refCount===0&&Rht(Iht,function(){e.controller.abort()})}var nS=null,dj=0,v0=0,d0=null;function Pht(e,t){if(nS===null){var n=nS=[];dj=0,v0=_V(),d0={status:"pending",value:void 0,then:function(r){n.push(r)}}}return dj++,t.then(cme,cme),t}function cme(){if(--dj===0&&nS!==null){d0!==null&&(d0.status="fulfilled");var e=nS;nS=null,v0=0,d0=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Lht(e,t){var n=[],r={status:"pending",value:null,reason:null,then:function(i){n.push(i)}};return e.then(function(){r.status="fulfilled",r.value=t;for(var i=0;i<n.length;i++)(0,n[i])(t)},function(i){for(r.status="rejected",r.reason=i,i=0;i<n.length;i++)(0,n[i])(void 0)}),r}var dme=nt.S;nt.S=function(e,t){pve=Ks(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&Pht(e,t),dme!==null&&dme(e,t)};var Am=qu(null);function rV(){var e=Am.current;return e!==null?e:An.pooledCache}function YO(e,t){t===null?Wn(Am,Am.current):Wn(Am,t.pool)}function tye(){var e=rV();return e===null?null:{parent:ni._currentValue,pool:e}}var O0=Error(re(460)),iV=Error(re(474)),zT=Error(re(542)),fT={then:function(){}};function hme(e){return e=e.status,e==="fulfilled"||e==="rejected"}function nye(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(id,id),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pme(e),e;default:if(typeof t.status=="string")t.then(id,id);else{if(e=An,e!==null&&100<e.shellSuspendCounter)throw Error(re(482));e=t,e.status="pending",e.then(function(r){if(t.status==="pending"){var i=t;i.status="fulfilled",i.value=r}},function(r){if(t.status==="pending"){var i=t;i.status="rejected",i.reason=r}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,pme(e),e}throw Dm=t,O0}}function _m(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Dm=n,O0):n}}var Dm=null;function fme(){if(Dm===null)throw Error(re(459));var e=Dm;return Dm=null,e}function pme(e){if(e===O0||e===zT)throw Error(re(483))}var h0=null,vS=0;function IO(e){var t=vS;return vS+=1,h0===null&&(h0=[]),nye(h0,e,t)}function W1(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function PO(e,t){throw t.$$typeof===Sdt?Error(re(525)):(e=Object.prototype.toString.call(t),Error(re(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function rye(e){function t(y,v){if(e){var b=y.deletions;b===null?(y.deletions=[v],y.flags|=16):b.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y){for(var v=new Map;y!==null;)y.key!==null?v.set(y.key,y):v.set(y.index,y),y=y.sibling;return v}function i(y,v){return y=sd(y,v),y.index=0,y.sibling=null,y}function o(y,v,b){return y.index=b,e?(b=y.alternate,b!==null?(b=b.index,b<v?(y.flags|=67108866,v):b):(y.flags|=67108866,v)):(y.flags|=1048576,v)}function s(y){return e&&y.alternate===null&&(y.flags|=67108866),y}function a(y,v,b,w){return v===null||v.tag!==6?(v=SF(b,y.mode,w),v.return=y,v):(v=i(v,b),v.return=y,v)}function l(y,v,b,w){var x=b.type;return x===Gv?c(y,v,b.props.children,w,b.key):v!==null&&(v.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===sf&&_m(x)===v.type)?(v=i(v,b.props),W1(v,b),v.return=y,v):(v=KO(b.type,b.key,b.props,null,y.mode,w),W1(v,b),v.return=y,v)}function u(y,v,b,w){return v===null||v.tag!==4||v.stateNode.containerInfo!==b.containerInfo||v.stateNode.implementation!==b.implementation?(v=kF(b,y.mode,w),v.return=y,v):(v=i(v,b.children||[]),v.return=y,v)}function c(y,v,b,w,x){return v===null||v.tag!==7?(v=Tm(b,y.mode,w,x),v.return=y,v):(v=i(v,b),v.return=y,v)}function d(y,v,b){if(typeof v=="string"&&v!==""||typeof v=="number"||typeof v=="bigint")return v=SF(""+v,y.mode,b),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case NO:return b=KO(v.type,v.key,v.props,null,y.mode,b),W1(b,v),b.return=y,b;case Y1:return v=kF(v,y.mode,b),v.return=y,v;case sf:return v=_m(v),d(y,v,b)}if(Q1(v)||j1(v))return v=Tm(v,y.mode,b,null),v.return=y,v;if(typeof v.then=="function")return d(y,IO(v),b);if(v.$$typeof===rd)return d(y,RO(y,v),b);PO(y,v)}return null}function h(y,v,b,w){var x=v!==null?v.key:null;if(typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint")return x!==null?null:a(y,v,""+b,w);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case NO:return b.key===x?l(y,v,b,w):null;case Y1:return b.key===x?u(y,v,b,w):null;case sf:return b=_m(b),h(y,v,b,w)}if(Q1(b)||j1(b))return x!==null?null:c(y,v,b,w,null);if(typeof b.then=="function")return h(y,v,IO(b),w);if(b.$$typeof===rd)return h(y,v,RO(y,b),w);PO(y,b)}return null}function f(y,v,b,w,x){if(typeof w=="string"&&w!==""||typeof w=="number"||typeof w=="bigint")return y=y.get(b)||null,a(v,y,""+w,x);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case NO:return y=y.get(w.key===null?b:w.key)||null,l(v,y,w,x);case Y1:return y=y.get(w.key===null?b:w.key)||null,u(v,y,w,x);case sf:return w=_m(w),f(y,v,b,w,x)}if(Q1(w)||j1(w))return y=y.get(b)||null,c(v,y,w,x,null);if(typeof w.then=="function")return f(y,v,b,IO(w),x);if(w.$$typeof===rd)return f(y,v,b,RO(v,w),x);PO(v,w)}return null}function p(y,v,b,w){for(var x=null,S=null,k=v,C=v=0,N=null;k!==null&&C<b.length;C++){k.index>C?(N=k,k=null):N=k.sibling;var E=h(y,k,b[C],w);if(E===null){k===null&&(k=N);break}e&&k&&E.alternate===null&&t(y,k),v=o(E,v,C),S===null?x=E:S.sibling=E,S=E,k=N}if(C===b.length)return n(y,k),Ut&&td(y,C),x;if(k===null){for(;C<b.length;C++)k=d(y,b[C],w),k!==null&&(v=o(k,v,C),S===null?x=k:S.sibling=k,S=k);return Ut&&td(y,C),x}for(k=r(k);C<b.length;C++)N=f(k,y,C,b[C],w),N!==null&&(e&&N.alternate!==null&&k.delete(N.key===null?C:N.key),v=o(N,v,C),S===null?x=N:S.sibling=N,S=N);return e&&k.forEach(function(D){return t(y,D)}),Ut&&td(y,C),x}function m(y,v,b,w){if(b==null)throw Error(re(151));for(var x=null,S=null,k=v,C=v=0,N=null,E=b.next();k!==null&&!E.done;C++,E=b.next()){k.index>C?(N=k,k=null):N=k.sibling;var D=h(y,k,E.value,w);if(D===null){k===null&&(k=N);break}e&&k&&D.alternate===null&&t(y,k),v=o(D,v,C),S===null?x=D:S.sibling=D,S=D,k=N}if(E.done)return n(y,k),Ut&&td(y,C),x;if(k===null){for(;!E.done;C++,E=b.next())E=d(y,E.value,w),E!==null&&(v=o(E,v,C),S===null?x=E:S.sibling=E,S=E);return Ut&&td(y,C),x}for(k=r(k);!E.done;C++,E=b.next())E=f(k,y,C,E.value,w),E!==null&&(e&&E.alternate!==null&&k.delete(E.key===null?C:E.key),v=o(E,v,C),S===null?x=E:S.sibling=E,S=E);return e&&k.forEach(function(q){return t(y,q)}),Ut&&td(y,C),x}function g(y,v,b,w){if(typeof b=="object"&&b!==null&&b.type===Gv&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case NO:e:{for(var x=b.key;v!==null;){if(v.key===x){if(x=b.type,x===Gv){if(v.tag===7){n(y,v.sibling),w=i(v,b.props.children),w.return=y,y=w;break e}}else if(v.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===sf&&_m(x)===v.type){n(y,v.sibling),w=i(v,b.props),W1(w,b),w.return=y,y=w;break e}n(y,v);break}else t(y,v);v=v.sibling}b.type===Gv?(w=Tm(b.props.children,y.mode,w,b.key),w.return=y,y=w):(w=KO(b.type,b.key,b.props,null,y.mode,w),W1(w,b),w.return=y,y=w)}return s(y);case Y1:e:{for(x=b.key;v!==null;){if(v.key===x)if(v.tag===4&&v.stateNode.containerInfo===b.containerInfo&&v.stateNode.implementation===b.implementation){n(y,v.sibling),w=i(v,b.children||[]),w.return=y,y=w;break e}else{n(y,v);break}else t(y,v);v=v.sibling}w=kF(b,y.mode,w),w.return=y,y=w}return s(y);case sf:return b=_m(b),g(y,v,b,w)}if(Q1(b))return p(y,v,b,w);if(j1(b)){if(x=j1(b),typeof x!="function")throw Error(re(150));return b=x.call(b),m(y,v,b,w)}if(typeof b.then=="function")return g(y,v,IO(b),w);if(b.$$typeof===rd)return g(y,v,RO(y,b),w);PO(y,b)}return typeof b=="string"&&b!==""||typeof b=="number"||typeof b=="bigint"?(b=""+b,v!==null&&v.tag===6?(n(y,v.sibling),w=i(v,b),w.return=y,y=w):(n(y,v),w=SF(b,y.mode,w),w.return=y,y=w),s(y)):n(y,v)}return function(y,v,b,w){try{vS=0;var x=g(y,v,b,w);return h0=null,x}catch(k){if(k===O0||k===zT)throw k;var S=Hs(29,k,null,y.mode);return S.lanes=w,S.return=y,S}finally{}}}var Lm=rye(!0),iye=rye(!1),af=!1;function oV(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function hj(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bf(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function wf(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(an&2)!==0){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=cT(e),Qge(e,null,n),t}return qT(e,r,t,n),cT(e)}function rS(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Sge(e,n)}}function NF(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var s={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};o===null?i=o=s:o=o.next=s,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var fj=!1;function iS(){if(fj){var e=d0;if(e!==null)throw e}}function oS(e,t,n,r){fj=!1;var i=e.updateQueue;af=!1;var o=i.firstBaseUpdate,s=i.lastBaseUpdate,a=i.shared.pending;if(a!==null){i.shared.pending=null;var l=a,u=l.next;l.next=null,s===null?o=u:s.next=u,s=l;var c=e.alternate;c!==null&&(c=c.updateQueue,a=c.lastBaseUpdate,a!==s&&(a===null?c.firstBaseUpdate=u:a.next=u,c.lastBaseUpdate=l))}if(o!==null){var d=i.baseState;s=0,c=u=l=null,a=o;do{var h=a.lane&-536870913,f=h!==a.lane;if(f?(Vt&h)===h:(r&h)===h){h!==0&&h===v0&&(fj=!0),c!==null&&(c=c.next={lane:0,tag:a.tag,payload:a.payload,callback:null,next:null});e:{var p=e,m=a;h=t;var g=n;switch(m.tag){case 1:if(p=m.payload,typeof p=="function"){d=p.call(g,d,h);break e}d=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,h=typeof p=="function"?p.call(g,d,h):p,h==null)break e;d=Jn({},d,h);break e;case 2:af=!0}}h=a.callback,h!==null&&(e.flags|=64,f&&(e.flags|=8192),f=i.callbacks,f===null?i.callbacks=[h]:f.push(h))}else f={lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},c===null?(u=c=f,l=d):c=c.next=f,s|=h;if(a=a.next,a===null){if(a=i.shared.pending,a===null)break;f=a,a=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(!0);c===null&&(l=d),i.baseState=l,i.firstBaseUpdate=u,i.lastBaseUpdate=c,o===null&&(i.shared.lanes=0),Of|=s,e.lanes=s,e.memoizedState=d}}function oye(e,t){if(typeof e!="function")throw Error(re(191,e));e.call(t)}function sye(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)oye(n[e],t)}var b0=qu(null),pT=qu(0);function mme(e,t){e=fd,Wn(pT,e),Wn(b0,t),fd=e|t.baseLanes}function pj(){Wn(pT,fd),Wn(b0,b0.current)}function sV(){fd=pT.current,Di(b0),Di(pT)}var Js=qu(null),Fa=null;function uf(e){var t=e.alternate;Wn(Br,Br.current&1),Wn(Js,e),Fa===null&&(t===null||b0.current!==null||t.memoizedState!==null)&&(Fa=e)}function mj(e){Wn(Br,Br.current),Wn(Js,e),Fa===null&&(Fa=e)}function aye(e){e.tag===22?(Wn(Br,Br.current),Wn(Js,e),Fa===null&&(Fa=e)):cf(e)}function cf(){Wn(Br,Br.current),Wn(Js,Js.current)}function Us(e){Di(Js),Fa===e&&(Fa=null),Di(Br)}var Br=qu(0);function mT(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Ij(n)||Pj(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder==="forwards"||t.memoizedProps.revealOrder==="backwards"||t.memoizedProps.revealOrder==="unstable_legacy-backwards"||t.memoizedProps.revealOrder==="together")){if((t.flags&128)!==0)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var cd=0,kt=null,Nn=null,ei=null,gT=!1,f0=!1,Bm=!1,yT=0,bS=0,p0=null,Bht=0;function Mr(){throw Error(re(321))}function aV(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Xs(e[n],t[n]))return!1;return!0}function lV(e,t,n,r,i,o){return cd=o,kt=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,nt.H=e===null||e.memoizedState===null?qye:bV,Bm=!1,o=n(r,i),Bm=!1,f0&&(o=uye(t,n,r,i)),lye(e),o}function lye(e){nt.H=wS;var t=Nn!==null&&Nn.next!==null;if(cd=0,ei=Nn=kt=null,gT=!1,bS=0,p0=null,t)throw Error(re(300));e===null||ri||(e=e.dependencies,e!==null&&hT(e)&&(ri=!0))}function uye(e,t,n,r){kt=e;var i=0;do{if(f0&&(p0=null),bS=0,f0=!1,25<=i)throw Error(re(301));if(i+=1,ei=Nn=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}nt.H=zye,o=t(n,r)}while(f0);return o}function qht(){var e=nt.H,t=e.useState()[0];return t=typeof t.then=="function"?RS(t):t,e=e.useState()[0],(Nn!==null?Nn.memoizedState:null)!==e&&(kt.flags|=1024),t}function uV(){var e=yT!==0;return yT=0,e}function cV(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function dV(e){if(gT){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}gT=!1}cd=0,ei=Nn=kt=null,f0=!1,bS=yT=0,p0=null}function qo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ei===null?kt.memoizedState=ei=e:ei=ei.next=e,ei}function qr(){if(Nn===null){var e=kt.alternate;e=e!==null?e.memoizedState:null}else e=Nn.next;var t=ei===null?kt.memoizedState:ei.next;if(t!==null)ei=t,Nn=e;else{if(e===null)throw kt.alternate===null?Error(re(467)):Error(re(310));Nn=e,e={memoizedState:Nn.memoizedState,baseState:Nn.baseState,baseQueue:Nn.baseQueue,queue:Nn.queue,next:null},ei===null?kt.memoizedState=ei=e:ei=ei.next=e}return ei}function FT(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function RS(e){var t=bS;return bS+=1,p0===null&&(p0=[]),e=nye(p0,e,t),t=kt,(ei===null?t.memoizedState:ei.next)===null&&(t=t.alternate,nt.H=t===null||t.memoizedState===null?qye:bV),e}function jT(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return RS(e);if(e.$$typeof===rd)return Yi(e)}throw Error(re(438,String(e)))}function hV(e){var t=null,n=kt.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=kt.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(i){return i.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=FT(),kt.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=kdt;return t.index++,n}function dd(e,t){return typeof t=="function"?t(e):t}function QO(e){var t=qr();return fV(t,Nn,e)}function fV(e,t,n){var r=e.queue;if(r===null)throw Error(re(311));r.lastRenderedReducer=n;var i=e.baseQueue,o=r.pending;if(o!==null){if(i!==null){var s=i.next;i.next=o.next,o.next=s}t.baseQueue=i=o,r.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var a=s=null,l=null,u=t,c=!1;do{var d=u.lane&-536870913;if(d!==u.lane?(Vt&d)===d:(cd&d)===d){var h=u.revertLane;if(h===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),d===v0&&(c=!0);else if((cd&h)===h){u=u.next,h===v0&&(c=!0);continue}else d={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(a=l=d,s=o):l=l.next=d,kt.lanes|=h,Of|=h;d=u.action,Bm&&n(o,d),o=u.hasEagerState?u.eagerState:n(o,d)}else h={lane:d,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(a=l=h,s=o):l=l.next=h,kt.lanes|=d,Of|=d;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=a,!Xs(o,e.memoizedState)&&(ri=!0,c&&(n=d0,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function MF(e){var t=qr(),n=t.queue;if(n===null)throw Error(re(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do o=e(o,s.action),s=s.next;while(s!==i);Xs(o,t.memoizedState)||(ri=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function cye(e,t,n){var r=kt,i=qr(),o=Ut;if(o){if(n===void 0)throw Error(re(407));n=n()}else n=t();var s=!Xs((Nn||i).memoizedState,n);if(s&&(i.memoizedState=n,ri=!0),i=i.queue,pV(fye.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||ei!==null&&ei.memoizedState.tag&1){if(r.flags|=2048,w0(9,{destroy:void 0},hye.bind(null,r,i,n,t),null),An===null)throw Error(re(349));o||(cd&127)!==0||dye(r,t,n)}return n}function dye(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=kt.updateQueue,t===null?(t=FT(),kt.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function hye(e,t,n,r){t.value=n,t.getSnapshot=r,pye(t)&&mye(e)}function fye(e,t,n){return n(function(){pye(t)&&mye(e)})}function pye(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Xs(e,n)}catch{return!0}}function mye(e){var t=Vm(e,2);t!==null&&ds(t,e,2)}function gj(e){var t=qo();if(typeof e=="function"){var n=e;if(e=n(),Bm){hf(!0);try{n()}finally{hf(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:dd,lastRenderedState:e},t}function gye(e,t,n,r){return e.baseState=n,fV(e,Nn,typeof r=="function"?r:dd)}function zht(e,t,n,r,i){if(WT(e))throw Error(re(485));if(e=t.action,e!==null){var o={payload:i,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(s){o.listeners.push(s)}};nt.T!==null?n(!0):o.isTransition=!1,r(o),n=t.pending,n===null?(o.next=t.pending=o,yye(t,o)):(o.next=n.next,t.pending=n.next=o)}}function yye(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var o=nt.T,s={};nt.T=s;try{var a=n(i,r),l=nt.S;l!==null&&l(s,a),gme(e,t,a)}catch(u){yj(e,t,u)}finally{o!==null&&s.types!==null&&(o.types=s.types),nt.T=o}}else try{o=n(i,r),gme(e,t,o)}catch(u){yj(e,t,u)}}function gme(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(r){yme(e,t,r)},function(r){return yj(e,t,r)}):yme(e,t,n)}function yme(e,t,n){t.status="fulfilled",t.value=n,vye(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,yye(e,n)))}function yj(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status="rejected",t.reason=n,vye(t),t=t.next;while(t!==r)}e.action=null}function vye(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function bye(e,t){return t}function vme(e,t){if(Ut){var n=An.formState;if(n!==null){e:{var r=kt;if(Ut){if(Xn){t:{for(var i=Xn,o=za;i.nodeType!==8;){if(!o){i=null;break t}if(i=ja(i.nextSibling),i===null){i=null;break t}}o=i.data,i=o==="F!"||o==="F"?i:null}if(i){Xn=ja(i.nextSibling),r=i.data==="F!";break e}}_f(r)}r=!1}r&&(t=n[0])}}return n=qo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:bye,lastRenderedState:t},n.queue=r,n=Pye.bind(null,kt,r),r.dispatch=n,r=gj(!1),o=vV.bind(null,kt,!1,r.queue),r=qo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=zht.bind(null,kt,i,o,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function bme(e){var t=qr();return wye(t,Nn,e)}function wye(e,t,n){if(t=fV(e,t,bye)[0],e=QO(dd)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var r=RS(t)}catch(s){throw s===O0?zT:s}else r=t;t=qr();var i=t.queue,o=i.dispatch;return n!==t.memoizedState&&(kt.flags|=2048,w0(9,{destroy:void 0},Fht.bind(null,i,n),null)),[r,o,e]}function Fht(e,t){e.action=t}function wme(e){var t=qr(),n=Nn;if(n!==null)return wye(t,n,e);qr(),t=t.memoizedState,n=qr();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function w0(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=kt.updateQueue,t===null&&(t=FT(),kt.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function xye(){return qr().memoizedState}function GO(e,t,n,r){var i=qo();kt.flags|=e,i.memoizedState=w0(1|t,{destroy:void 0},n,r===void 0?null:r)}function VT(e,t,n,r){var i=qr();r=r===void 0?null:r;var o=i.memoizedState.inst;Nn!==null&&r!==null&&aV(r,Nn.memoizedState.deps)?i.memoizedState=w0(t,o,n,r):(kt.flags|=e,i.memoizedState=w0(1|t,o,n,r))}function xme(e,t){GO(8390656,8,e,t)}function pV(e,t){VT(2048,8,e,t)}function jht(e){kt.flags|=4;var t=kt.updateQueue;if(t===null)t=FT(),kt.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Sye(e){var t=qr().memoizedState;return jht({ref:t,nextImpl:e}),function(){if((an&2)!==0)throw Error(re(440));return t.impl.apply(void 0,arguments)}}function kye(e,t){return VT(4,2,e,t)}function Cye(e,t){return VT(4,4,e,t)}function Nye(e,t){if(typeof t=="function"){e=e();var n=t(e);return function(){typeof n=="function"?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Mye(e,t,n){n=n!=null?n.concat([e]):null,VT(4,4,Nye.bind(null,t,e),n)}function mV(){}function _ye(e,t){var n=qr();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&aV(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Eye(e,t){var n=qr();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&aV(t,r[1]))return r[0];if(r=e(),Bm){hf(!0);try{e()}finally{hf(!1)}}return n.memoizedState=[r,t],r}function gV(e,t,n){return n===void 0||(cd&1073741824)!==0&&(Vt&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=gve(),kt.lanes|=e,Of|=e,n)}function Oye(e,t,n,r){return Xs(n,t)?n:b0.current!==null?(e=gV(e,n,r),Xs(e,t)||(ri=!0),e):(cd&42)===0||(cd&1073741824)!==0&&(Vt&261930)===0?(ri=!0,e.memoizedState=n):(e=gve(),kt.lanes|=e,Of|=e,t)}function Tye(e,t,n,r,i){var o=ln.p;ln.p=o!==0&&8>o?o:8;var s=nt.T,a={};nt.T=a,vV(e,!1,t,n);try{var l=i(),u=nt.S;if(u!==null&&u(a,l),l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=Lht(l,r);sS(e,t,c,Gs(e))}else sS(e,t,r,Gs(e))}catch(d){sS(e,t,{then:function(){},status:"rejected",reason:d},Gs())}finally{ln.p=o,s!==null&&a.types!==null&&(s.types=a.types),nt.T=s}}function Vht(){}function vj(e,t,n,r){if(e.tag!==5)throw Error(re(476));var i=Aye(e).queue;Tye(e,i,t,Om,n===null?Vht:function(){return Dye(e),n(r)})}function Aye(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Om,baseState:Om,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:dd,lastRenderedState:Om},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:dd,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Dye(e){var t=Aye(e);t.next===null&&(t=e.alternate.memoizedState),sS(e,t.next.queue,{},Gs())}function yV(){return Yi(kS)}function Rye(){return qr().memoizedState}function Iye(){return qr().memoizedState}function Wht(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Gs();e=bf(n);var r=wf(t,e,n);r!==null&&(ds(r,t,n),rS(r,t,n)),t={cache:nV()},e.payload=t;return}t=t.return}}function Uht(e,t,n){var r=Gs();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},WT(e)?Lye(t,n):(n=Jj(e,t,n,r),n!==null&&(ds(n,e,r),Bye(n,t,r)))}function Pye(e,t,n){var r=Gs();sS(e,t,n,r)}function sS(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(WT(e))Lye(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var s=t.lastRenderedState,a=o(s,n);if(i.hasEagerState=!0,i.eagerState=a,Xs(a,s))return qT(e,t,i,0),An===null&&BT(),!1}catch{}finally{}if(n=Jj(e,t,i,r),n!==null)return ds(n,e,r),Bye(n,t,r),!0}return!1}function vV(e,t,n,r){if(r={lane:2,revertLane:_V(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},WT(e)){if(t)throw Error(re(479))}else t=Jj(e,n,r,2),t!==null&&ds(t,e,2)}function WT(e){var t=e.alternate;return e===kt||t!==null&&t===kt}function Lye(e,t){f0=gT=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Bye(e,t,n){if((n&4194048)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Sge(e,n)}}var wS={readContext:Yi,use:jT,useCallback:Mr,useContext:Mr,useEffect:Mr,useImperativeHandle:Mr,useLayoutEffect:Mr,useInsertionEffect:Mr,useMemo:Mr,useReducer:Mr,useRef:Mr,useState:Mr,useDebugValue:Mr,useDeferredValue:Mr,useTransition:Mr,useSyncExternalStore:Mr,useId:Mr,useHostTransitionStatus:Mr,useFormState:Mr,useActionState:Mr,useOptimistic:Mr,useMemoCache:Mr,useCacheRefresh:Mr};wS.useEffectEvent=Mr;var qye={readContext:Yi,use:jT,useCallback:function(e,t){return qo().memoizedState=[e,t===void 0?null:t],e},useContext:Yi,useEffect:xme,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,GO(4194308,4,Nye.bind(null,t,e),n)},useLayoutEffect:function(e,t){return GO(4194308,4,e,t)},useInsertionEffect:function(e,t){GO(4,2,e,t)},useMemo:function(e,t){var n=qo();t=t===void 0?null:t;var r=e();if(Bm){hf(!0);try{e()}finally{hf(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=qo();if(n!==void 0){var i=n(t);if(Bm){hf(!0);try{n(t)}finally{hf(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Uht.bind(null,kt,e),[r.memoizedState,e]},useRef:function(e){var t=qo();return e={current:e},t.memoizedState=e},useState:function(e){e=gj(e);var t=e.queue,n=Pye.bind(null,kt,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:mV,useDeferredValue:function(e,t){var n=qo();return gV(n,e,t)},useTransition:function(){var e=gj(!1);return e=Tye.bind(null,kt,e.queue,!0,!1),qo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=kt,i=qo();if(Ut){if(n===void 0)throw Error(re(407));n=n()}else{if(n=t(),An===null)throw Error(re(349));(Vt&127)!==0||dye(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,xme(fye.bind(null,r,o,e),[e]),r.flags|=2048,w0(9,{destroy:void 0},hye.bind(null,r,o,n,t),null),n},useId:function(){var e=qo(),t=An.identifierPrefix;if(Ut){var n=Pu,r=Iu;n=(r&~(1<<32-Qs(r)-1)).toString(32)+n,t="_"+t+"R_"+n,n=yT++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=Bht++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:yV,useFormState:vme,useActionState:vme,useOptimistic:function(e){var t=qo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=vV.bind(null,kt,!0,n),n.dispatch=t,[e,t]},useMemoCache:hV,useCacheRefresh:function(){return qo().memoizedState=Wht.bind(null,kt)},useEffectEvent:function(e){var t=qo(),n={impl:e};return t.memoizedState=n,function(){if((an&2)!==0)throw Error(re(440));return n.impl.apply(void 0,arguments)}}},bV={readContext:Yi,use:jT,useCallback:_ye,useContext:Yi,useEffect:pV,useImperativeHandle:Mye,useInsertionEffect:kye,useLayoutEffect:Cye,useMemo:Eye,useReducer:QO,useRef:xye,useState:function(){return QO(dd)},useDebugValue:mV,useDeferredValue:function(e,t){var n=qr();return Oye(n,Nn.memoizedState,e,t)},useTransition:function(){var e=QO(dd)[0],t=qr().memoizedState;return[typeof e=="boolean"?e:RS(e),t]},useSyncExternalStore:cye,useId:Rye,useHostTransitionStatus:yV,useFormState:bme,useActionState:bme,useOptimistic:function(e,t){var n=qr();return gye(n,Nn,e,t)},useMemoCache:hV,useCacheRefresh:Iye};bV.useEffectEvent=Sye;var zye={readContext:Yi,use:jT,useCallback:_ye,useContext:Yi,useEffect:pV,useImperativeHandle:Mye,useInsertionEffect:kye,useLayoutEffect:Cye,useMemo:Eye,useReducer:MF,useRef:xye,useState:function(){return MF(dd)},useDebugValue:mV,useDeferredValue:function(e,t){var n=qr();return Nn===null?gV(n,e,t):Oye(n,Nn.memoizedState,e,t)},useTransition:function(){var e=MF(dd)[0],t=qr().memoizedState;return[typeof e=="boolean"?e:RS(e),t]},useSyncExternalStore:cye,useId:Rye,useHostTransitionStatus:yV,useFormState:wme,useActionState:wme,useOptimistic:function(e,t){var n=qr();return Nn!==null?gye(n,Nn,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:hV,useCacheRefresh:Iye};zye.useEffectEvent=Sye;function _F(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Jn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var bj={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Gs(),i=bf(r);i.payload=t,n!=null&&(i.callback=n),t=wf(e,i,r),t!==null&&(ds(t,e,r),rS(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Gs(),i=bf(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=wf(e,i,r),t!==null&&(ds(t,e,r),rS(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Gs(),r=bf(n);r.tag=2,t!=null&&(r.callback=t),t=wf(e,r,n),t!==null&&(ds(t,e,n),rS(t,e,n))}};function Sme(e,t,n,r,i,o,s){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,s):t.prototype&&t.prototype.isPureReactComponent?!mS(n,r)||!mS(i,o):!0}function kme(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&bj.enqueueReplaceState(t,t.state,null)}function qm(e,t){var n=t;if("ref"in t){n={};for(var r in t)r!=="ref"&&(n[r]=t[r])}if(e=e.defaultProps){n===t&&(n=Jn({},n));for(var i in e)n[i]===void 0&&(n[i]=e[i])}return n}function Fye(e){uT(e)}function jye(e){console.error(e)}function Vye(e){uT(e)}function vT(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(r){setTimeout(function(){throw r})}}function Cme(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(i){setTimeout(function(){throw i})}}function wj(e,t,n){return n=bf(n),n.tag=3,n.payload={element:null},n.callback=function(){vT(e,t)},n}function Wye(e){return e=bf(e),e.tag=3,e}function Uye(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i=="function"){var o=r.value;e.payload=function(){return i(o)},e.callback=function(){Cme(t,n,r)}}var s=n.stateNode;s!==null&&typeof s.componentDidCatch=="function"&&(e.callback=function(){Cme(t,n,r),typeof i!="function"&&(xf===null?xf=new Set([this]):xf.add(this));var a=r.stack;this.componentDidCatch(r.value,{componentStack:a!==null?a:""})})}function Hht(e,t,n,r,i){if(n.flags|=32768,r!==null&&typeof r=="object"&&typeof r.then=="function"){if(t=n.alternate,t!==null&&E0(t,n,i,!0),n=Js.current,n!==null){switch(n.tag){case 31:case 13:return Fa===null?kT():n.alternate===null&&_r===0&&(_r=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===fT?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),qF(e,r,i)),!1;case 22:return n.flags|=65536,r===fT?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),qF(e,r,i)),!1}throw Error(re(435,n.tag))}return qF(e,r,i),kT(),!1}if(Ut)return t=Js.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==aj&&(e=Error(re(422),{cause:r}),yS(qa(e,n)))):(r!==aj&&(t=Error(re(423),{cause:r}),yS(qa(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=qa(r,n),i=wj(e.stateNode,r,i),NF(e,i),_r!==4&&(_r=2)),!1;var o=Error(re(520),{cause:r});if(o=qa(o,n),uS===null?uS=[o]:uS.push(o),_r!==4&&(_r=2),t===null)return!0;r=qa(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=wj(n.stateNode,r,e),NF(n,e),!1;case 1:if(t=n.type,o=n.stateNode,(n.flags&128)===0&&(typeof t.getDerivedStateFromError=="function"||o!==null&&typeof o.componentDidCatch=="function"&&(xf===null||!xf.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Wye(i),Uye(i,e,n,r),NF(n,i),!1}n=n.return}while(n!==null);return!1}var wV=Error(re(461)),ri=!1;function Hi(e,t,n,r){t.child=e===null?iye(t,null,n,r):Lm(t,e.child,n,r)}function Nme(e,t,n,r,i){n=n.render;var o=t.ref;if("ref"in r){var s={};for(var a in r)a!=="ref"&&(s[a]=r[a])}else s=r;return Pm(t),r=lV(e,t,n,s,o,i),a=uV(),e!==null&&!ri?(cV(e,t,i),hd(e,t,i)):(Ut&&a&&eV(t),t.flags|=1,Hi(e,t,r,i),t.child)}function Mme(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Zj(o)&&o.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=o,Hye(e,t,o,r,i)):(e=KO(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!xV(e,i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:mS,n(s,r)&&e.ref===t.ref)return hd(e,t,i)}return t.flags|=1,e=sd(o,r),e.ref=t.ref,e.return=t,t.child=e}function Hye(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(mS(o,r)&&e.ref===t.ref)if(ri=!1,t.pendingProps=r=o,xV(e,i))(e.flags&131072)!==0&&(ri=!0);else return t.lanes=e.lanes,hd(e,t,i)}return xj(e,t,n,r,i)}function $ye(e,t,n,r){var i=r.children,o=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode==="hidden"){if((t.flags&128)!==0){if(o=o!==null?o.baseLanes|n:n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~o}else r=0,t.child=null;return _me(e,t,o,n,r)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&YO(t,o!==null?o.cachePool:null),o!==null?mme(t,o):pj(),aye(t);else return r=t.lanes=536870912,_me(e,t,o!==null?o.baseLanes|n:n,n,r)}else o!==null?(YO(t,o.cachePool),mme(t,o),cf(t),t.memoizedState=null):(e!==null&&YO(t,null),pj(),cf(t));return Hi(e,t,i,n),t.child}function X1(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function _me(e,t,n,r,i){var o=rV();return o=o===null?null:{parent:ni._currentValue,pool:o},t.memoizedState={baseLanes:n,cachePool:o},e!==null&&YO(t,null),pj(),aye(t),e!==null&&E0(e,t,r,!0),t.childLanes=i,null}function XO(e,t){return t=bT({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Eme(e,t,n){return Lm(t,e.child,null,n),e=XO(t,t.pendingProps),e.flags|=2,Us(t),t.memoizedState=null,e}function $ht(e,t,n){var r=t.pendingProps,i=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(Ut){if(r.mode==="hidden")return e=XO(t,r),t.lanes=536870912,X1(null,e);if(mj(t),(e=Xn)?(e=qve(e,za),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Mf!==null?{id:Iu,overflow:Pu}:null,retryLane:536870912,hydrationErrors:null},n=Xge(e),n.return=t,t.child=n,Ki=t,Xn=null)):e=null,e===null)throw _f(t);return t.lanes=536870912,null}return XO(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(mj(t),i)if(t.flags&256)t.flags&=-257,t=Eme(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(re(558));else if(ri||E0(e,t,n,!1),i=(n&e.childLanes)!==0,ri||i){if(r=An,r!==null&&(s=kge(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Vm(e,s),ds(r,e,s),wV;kT(),t=Eme(e,t,n)}else e=o.treeContext,Xn=ja(s.nextSibling),Ki=t,Ut=!0,vf=null,za=!1,e!==null&&Zge(t,e),t=XO(t,r),t.flags|=4096;return t}return e=sd(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function JO(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!="function"&&typeof n!="object")throw Error(re(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function xj(e,t,n,r,i){return Pm(t),n=lV(e,t,n,r,void 0,i),r=uV(),e!==null&&!ri?(cV(e,t,i),hd(e,t,i)):(Ut&&r&&eV(t),t.flags|=1,Hi(e,t,n,i),t.child)}function Ome(e,t,n,r,i,o){return Pm(t),t.updateQueue=null,n=uye(t,r,n,i),lye(e),r=uV(),e!==null&&!ri?(cV(e,t,o),hd(e,t,o)):(Ut&&r&&eV(t),t.flags|=1,Hi(e,t,n,o),t.child)}function Tme(e,t,n,r,i){if(Pm(t),t.stateNode===null){var o=i0,s=n.contextType;typeof s=="object"&&s!==null&&(o=Yi(s)),o=new n(r,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=bj,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=r,o.state=t.memoizedState,o.refs={},oV(t),s=n.contextType,o.context=typeof s=="object"&&s!==null?Yi(s):i0,o.state=t.memoizedState,s=n.getDerivedStateFromProps,typeof s=="function"&&(_F(t,n,s,r),o.state=t.memoizedState),typeof n.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(s=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),s!==o.state&&bj.enqueueReplaceState(o,o.state,null),oS(t,r,o,i),iS(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!0}else if(e===null){o=t.stateNode;var a=t.memoizedProps,l=qm(n,a);o.props=l;var u=o.context,c=n.contextType;s=i0,typeof c=="object"&&c!==null&&(s=Yi(c));var d=n.getDerivedStateFromProps;c=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function",a=t.pendingProps!==a,c||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a||u!==s)&&kme(t,o,r,s),af=!1;var h=t.memoizedState;o.state=h,oS(t,r,o,i),iS(),u=t.memoizedState,a||h!==u||af?(typeof d=="function"&&(_F(t,n,d,r),u=t.memoizedState),(l=af||Sme(t,n,l,r,h,u,s))?(c||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(t.flags|=4194308)):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=u),o.props=r,o.state=u,o.context=s,r=l):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{o=t.stateNode,hj(e,t),s=t.memoizedProps,c=qm(n,s),o.props=c,d=t.pendingProps,h=o.context,u=n.contextType,l=i0,typeof u=="object"&&u!==null&&(l=Yi(u)),a=n.getDerivedStateFromProps,(u=typeof a=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(s!==d||h!==l)&&kme(t,o,r,l),af=!1,h=t.memoizedState,o.state=h,oS(t,r,o,i),iS();var f=t.memoizedState;s!==d||h!==f||af||e!==null&&e.dependencies!==null&&hT(e.dependencies)?(typeof a=="function"&&(_F(t,n,a,r),f=t.memoizedState),(c=af||Sme(t,n,c,r,h,f,l)||e!==null&&e.dependencies!==null&&hT(e.dependencies))?(u||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,f,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,f,l)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=f),o.props=r,o.state=f,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return o=r,JO(e,t),r=(t.flags&128)!==0,o||r?(o=t.stateNode,n=r&&typeof n.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&r?(t.child=Lm(t,e.child,null,i),t.child=Lm(t,null,n,i)):Hi(e,t,n,i),t.memoizedState=o.state,e=t.child):e=hd(e,t,i),e}function Ame(e,t,n,r){return Im(),t.flags|=256,Hi(e,t,n,r),t.child}var EF={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function OF(e){return{baseLanes:e,cachePool:tye()}}function TF(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=$s),e}function Kye(e,t,n){var r=t.pendingProps,i=!1,o=(t.flags&128)!==0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Br.current&2)!==0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!==0,t.flags&=-33,e===null){if(Ut){if(i?uf(t):cf(t),(e=Xn)?(e=qve(e,za),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Mf!==null?{id:Iu,overflow:Pu}:null,retryLane:536870912,hydrationErrors:null},n=Xge(e),n.return=t,t.child=n,Ki=t,Xn=null)):e=null,e===null)throw _f(t);return Pj(e)?t.lanes=32:t.lanes=536870912,null}var a=r.children;return r=r.fallback,i?(cf(t),i=t.mode,a=bT({mode:"hidden",children:a},i),r=Tm(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=OF(n),r.childLanes=TF(e,s,n),t.memoizedState=EF,X1(null,r)):(uf(t),Sj(t,a))}var l=e.memoizedState;if(l!==null&&(a=l.dehydrated,a!==null)){if(o)t.flags&256?(uf(t),t.flags&=-257,t=AF(e,t,n)):t.memoizedState!==null?(cf(t),t.child=e.child,t.flags|=128,t=null):(cf(t),a=r.fallback,i=t.mode,r=bT({mode:"visible",children:r.children},i),a=Tm(a,i,n,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,Lm(t,e.child,null,n),r=t.child,r.memoizedState=OF(n),r.childLanes=TF(e,s,n),t.memoizedState=EF,t=X1(null,r));else if(uf(t),Pj(a)){if(s=a.nextSibling&&a.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(re(419)),r.stack="",r.digest=s,yS({value:r,source:null,stack:null}),t=AF(e,t,n)}else if(ri||E0(e,t,n,!1),s=(n&e.childLanes)!==0,ri||s){if(s=An,s!==null&&(r=kge(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Vm(e,r),ds(s,e,r),wV;Ij(a)||kT(),t=AF(e,t,n)}else Ij(a)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Xn=ja(a.nextSibling),Ki=t,Ut=!0,vf=null,za=!1,e!==null&&Zge(t,e),t=Sj(t,r.children),t.flags|=4096);return t}return i?(cf(t),a=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=sd(l,{mode:"hidden",children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u!==null?a=sd(u,a):(a=Tm(a,i,n,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,X1(null,r),r=t.child,a=e.child.memoizedState,a===null?a=OF(n):(i=a.cachePool,i!==null?(l=ni._currentValue,i=i.parent!==l?{parent:l,pool:l}:i):i=tye(),a={baseLanes:a.baseLanes|n,cachePool:i}),r.memoizedState=a,r.childLanes=TF(e,s,n),t.memoizedState=EF,X1(e.child,r)):(uf(t),n=e.child,e=n.sibling,n=sd(n,{mode:"visible",children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Sj(e,t){return t=bT({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function bT(e,t){return e=Hs(22,e,null,t),e.lanes=0,e}function AF(e,t,n){return Lm(t,e.child,null,n),e=Sj(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Dme(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),uj(e.return,t,n)}function DF(e,t,n,r,i,o){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:o}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i,s.treeForkCount=o)}function Yye(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;r=r.children;var s=Br.current,a=(s&2)!==0;if(a?(s=s&1|2,t.flags|=128):s&=1,Wn(Br,s),Hi(e,t,r,n),r=Ut?gS:0,!a&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Dme(e,n,t);else if(e.tag===19)Dme(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&mT(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),DF(t,!1,i,n,o,r);break;case"backwards":case"unstable_legacy-backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&mT(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}DF(t,!0,n,null,o,r);break;case"together":DF(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function hd(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Of|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(E0(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(re(153));if(t.child!==null){for(e=t.child,n=sd(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=sd(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xV(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&hT(e)))}function Kht(e,t,n){switch(t.tag){case 3:oT(t,t.stateNode.containerInfo),lf(t,ni,e.memoizedState.cache),Im();break;case 27:case 5:GF(t);break;case 4:oT(t,t.stateNode.containerInfo);break;case 10:lf(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,mj(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated!==null?(uf(t),t.flags|=128,null):(n&t.child.childLanes)!==0?Kye(e,t,n):(uf(t),e=hd(e,t,n),e!==null?e.sibling:null);uf(t);break;case 19:var i=(e.flags&128)!==0;if(r=(n&t.childLanes)!==0,r||(E0(e,t,n,!1),r=(n&t.childLanes)!==0),i){if(r)return Yye(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Wn(Br,Br.current),r)break;return null;case 22:return t.lanes=0,$ye(e,t,n,t.pendingProps);case 24:lf(t,ni,e.memoizedState.cache)}return hd(e,t,n)}function Qye(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ri=!0;else{if(!xV(e,n)&&(t.flags&128)===0)return ri=!1,Kht(e,t,n);ri=(e.flags&131072)!==0}else ri=!1,Ut&&(t.flags&1048576)!==0&&Jge(t,gS,t.index);switch(t.lanes=0,t.tag){case 16:e:{var r=t.pendingProps;if(e=_m(t.elementType),t.type=e,typeof e=="function")Zj(e)?(r=qm(e,r),t.tag=1,t=Tme(null,t,e,r,n)):(t.tag=0,t=xj(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===zj){t.tag=11,t=Nme(null,t,e,r,n);break e}else if(i===Fj){t.tag=14,t=Mme(null,t,e,r,n);break e}}throw t=YF(e)||e,Error(re(306,t,""))}}return t;case 0:return xj(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=qm(r,t.pendingProps),Tme(e,t,r,i,n);case 3:e:{if(oT(t,t.stateNode.containerInfo),e===null)throw Error(re(387));r=t.pendingProps;var o=t.memoizedState;i=o.element,hj(e,t),oS(t,r,null,n);var s=t.memoizedState;if(r=s.cache,lf(t,ni,r),r!==o.cache&&cj(t,[ni],n,!0),iS(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Ame(e,t,r,n);break e}else if(r!==i){i=qa(Error(re(424)),t),yS(i),t=Ame(e,t,r,n);break e}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(Xn=ja(e.firstChild),Ki=t,Ut=!0,vf=null,za=!0,n=iye(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Im(),r===i){t=hd(e,t,n);break e}Hi(e,t,r,n)}t=t.child}return t;case 26:return JO(e,t),e===null?(n=ege(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ut||(n=t.type,e=t.pendingProps,r=_T(yf.current).createElement(n),r[$i]=t,r[hs]=e,Qi(r,n,e),Ai(r),t.stateNode=r):t.memoizedState=ege(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return GF(t),e===null&&Ut&&(r=t.stateNode=zve(t.type,t.pendingProps,yf.current),Ki=t,za=!0,i=Xn,Af(t.type)?(Lj=i,Xn=ja(r.firstChild)):Xn=i),Hi(e,t,t.pendingProps.children,n),JO(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ut&&((i=r=Xn)&&(r=xft(r,t.type,t.pendingProps,za),r!==null?(t.stateNode=r,Ki=t,Xn=ja(r.firstChild),za=!1,i=!0):i=!1),i||_f(t)),GF(t),i=t.type,o=t.pendingProps,s=e!==null?e.memoizedProps:null,r=o.children,Dj(i,o)?r=null:s!==null&&Dj(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=lV(e,t,qht,null,null,n),kS._currentValue=i),JO(e,t),Hi(e,t,r,n),t.child;case 6:return e===null&&Ut&&((e=n=Xn)&&(n=Sft(n,t.pendingProps,za),n!==null?(t.stateNode=n,Ki=t,Xn=null,e=!0):e=!1),e||_f(t)),null;case 13:return Kye(e,t,n);case 4:return oT(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Lm(t,null,r,n):Hi(e,t,r,n),t.child;case 11:return Nme(e,t,t.type,t.pendingProps,n);case 7:return Hi(e,t,t.pendingProps,n),t.child;case 8:return Hi(e,t,t.pendingProps.children,n),t.child;case 12:return Hi(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,lf(t,t.type,r.value),Hi(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,Pm(t),i=Yi(i),r=r(i),t.flags|=1,Hi(e,t,r,n),t.child;case 14:return Mme(e,t,t.type,t.pendingProps,n);case 15:return Hye(e,t,t.type,t.pendingProps,n);case 19:return Yye(e,t,n);case 31:return $ht(e,t,n);case 22:return $ye(e,t,n,t.pendingProps);case 24:return Pm(t),r=Yi(ni),e===null?(i=rV(),i===null&&(i=An,o=nV(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:r,cache:i},oV(t),lf(t,ni,i)):((e.lanes&n)!==0&&(hj(e,t),oS(t,null,null,n),iS()),i=e.memoizedState,o=t.memoizedState,i.parent!==r?(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),lf(t,ni,r)):(r=o.cache,lf(t,ni,r),r!==i.cache&&cj(t,[ni],n,!0))),Hi(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(re(156,t.tag))}function Xc(e){e.flags|=4}function RF(e,t,n,r,i){if((t=(e.mode&32)!==0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(bve())e.flags|=8192;else throw Dm=fT,iV}else e.flags&=-16777217}function Rme(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!Vve(t))if(bve())e.flags|=8192;else throw Dm=fT,iV}function LO(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?wge():536870912,e.lanes|=t,x0|=t)}function U1(e,t){if(!Ut)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Gn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Yht(e,t,n){var r=t.pendingProps;switch(tV(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gn(t),null;case 1:return Gn(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),ad(ni),m0(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&($v(t)?Xc(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,CF())),Gn(t),null;case 26:var i=t.type,o=t.memoizedState;return e===null?(Xc(t),o!==null?(Gn(t),Rme(t,o)):(Gn(t),RF(t,i,null,r,n))):o?o!==e.memoizedState?(Xc(t),Gn(t),Rme(t,o)):(Gn(t),t.flags&=-16777217):(e=e.memoizedProps,e!==r&&Xc(t),Gn(t),RF(t,i,e,r,n)),null;case 27:if(sT(t),n=yf.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xc(t);else{if(!r){if(t.stateNode===null)throw Error(re(166));return Gn(t),null}e=Bu.current,$v(t)?lme(t,e):(e=zve(i,r,n),t.stateNode=e,Xc(t))}return Gn(t),null;case 5:if(sT(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Xc(t);else{if(!r){if(t.stateNode===null)throw Error(re(166));return Gn(t),null}if(o=Bu.current,$v(t))lme(t,o);else{var s=_T(yf.current);switch(o){case 1:o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case 2:o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;default:switch(i){case"svg":o=s.createElementNS("http://www.w3.org/2000/svg",i);break;case"math":o=s.createElementNS("http://www.w3.org/1998/Math/MathML",i);break;case"script":o=s.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild);break;case"select":o=typeof r.is=="string"?s.createElement("select",{is:r.is}):s.createElement("select"),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is=="string"?s.createElement(i,{is:r.is}):s.createElement(i)}}o[$i]=t,o[hs]=r;e:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break e;for(;s.sibling===null;){if(s.return===null||s.return===t)break e;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;e:switch(Qi(o,i,r),i){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}r&&Xc(t)}}return Gn(t),RF(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Xc(t);else{if(typeof r!="string"&&t.stateNode===null)throw Error(re(166));if(e=yf.current,$v(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Ki,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[$i]=t,e=!!(e.nodeValue===n||r!==null&&r.suppressHydrationWarning===!0||Pve(e.nodeValue,n)),e||_f(t,!0)}else e=_T(e).createTextNode(r),e[$i]=t,t.stateNode=e}return Gn(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=$v(t),n!==null){if(e===null){if(!r)throw Error(re(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(re(557));e[$i]=t}else Im(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Gn(t),e=!1}else n=CF(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Us(t),t):(Us(t),null);if((t.flags&128)!==0)throw Error(re(558))}return Gn(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=$v(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(re(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(re(317));i[$i]=t}else Im(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Gn(t),i=!1}else i=CF(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Us(t),t):(Us(t),null)}return Us(t),(t.flags&128)!==0?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),LO(t,t.updateQueue),Gn(t),null);case 4:return m0(),e===null&&EV(t.stateNode.containerInfo),Gn(t),null;case 10:return ad(t.type),Gn(t),null;case 19:if(Di(Br),r=t.memoizedState,r===null)return Gn(t),null;if(i=(t.flags&128)!==0,o=r.rendering,o===null)if(i)U1(r,!1);else{if(_r!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=mT(e),o!==null){for(t.flags|=128,U1(r,!1),e=o.updateQueue,t.updateQueue=e,LO(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Gge(n,e),n=n.sibling;return Wn(Br,Br.current&1|2),Ut&&td(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ks()>xT&&(t.flags|=128,i=!0,U1(r,!1),t.lanes=4194304)}else{if(!i)if(e=mT(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,LO(t,e),U1(r,!0),r.tail===null&&r.tailMode==="hidden"&&!o.alternate&&!Ut)return Gn(t),null}else 2*Ks()-r.renderingStartTime>xT&&n!==536870912&&(t.flags|=128,i=!0,U1(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e!==null?e.sibling=o:t.child=o,r.last=o)}return r.tail!==null?(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ks(),e.sibling=null,n=Br.current,Wn(Br,i?n&1|2:n&1),Ut&&td(t,r.treeForkCount),e):(Gn(t),null);case 22:case 23:return Us(t),sV(),r=t.memoizedState!==null,e!==null?e.memoizedState!==null!==r&&(t.flags|=8192):r&&(t.flags|=8192),r?(n&536870912)!==0&&(t.flags&128)===0&&(Gn(t),t.subtreeFlags&6&&(t.flags|=8192)):Gn(t),n=t.updateQueue,n!==null&&LO(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Di(Am),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ad(ni),Gn(t),null;case 25:return null;case 30:return null}throw Error(re(156,t.tag))}function Qht(e,t){switch(tV(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ad(ni),m0(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return sT(t),null;case 31:if(t.memoizedState!==null){if(Us(t),t.alternate===null)throw Error(re(340));Im()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Us(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(re(340));Im()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Di(Br),null;case 4:return m0(),null;case 10:return ad(t.type),null;case 22:case 23:return Us(t),sV(),e!==null&&Di(Am),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ad(ni),null;case 25:return null;default:return null}}function Gye(e,t){switch(tV(t),t.tag){case 3:ad(ni),m0();break;case 26:case 27:case 5:sT(t);break;case 4:m0();break;case 31:t.memoizedState!==null&&Us(t);break;case 13:Us(t);break;case 19:Di(Br);break;case 10:ad(t.type);break;case 22:case 23:Us(t),sV(),e!==null&&Di(Am);break;case 24:ad(ni)}}function IS(e,t){try{var n=t.updateQueue,r=n!==null?n.lastEffect:null;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var o=n.create,s=n.inst;r=o(),s.destroy=r}n=n.next}while(n!==i)}}catch(a){yn(t,t.return,a)}}function Ef(e,t,n){try{var r=t.updateQueue,i=r!==null?r.lastEffect:null;if(i!==null){var o=i.next;r=o;do{if((r.tag&e)===e){var s=r.inst,a=s.destroy;if(a!==void 0){s.destroy=void 0,i=t;var l=n,u=a;try{u()}catch(c){yn(i,l,c)}}}r=r.next}while(r!==o)}}catch(c){yn(t,t.return,c)}}function Xye(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{sye(t,n)}catch(r){yn(e,e.return,r)}}}function Jye(e,t,n){n.props=qm(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(r){yn(e,t,r)}}function aS(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n=="function"?e.refCleanup=n(r):n.current=r}}catch(i){yn(e,t,i)}}function Lu(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r=="function")try{r()}catch(i){yn(e,t,i)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n=="function")try{n(null)}catch(i){yn(e,t,i)}else n.current=null}function Zye(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&r.focus();break e;case"img":n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(i){yn(e,e.return,i)}}function IF(e,t,n){try{var r=e.stateNode;mft(r,e.type,n,t),r[hs]=t}catch(i){yn(e,e.return,i)}}function eve(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Af(e.type)||e.tag===4}function PF(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||eve(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Af(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function kj(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName==="HTML"?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=id));else if(r!==4&&(r===27&&Af(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(kj(e,t,n),e=e.sibling;e!==null;)kj(e,t,n),e=e.sibling}function wT(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Af(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(wT(e,t,n),e=e.sibling;e!==null;)wT(e,t,n),e=e.sibling}function tve(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Qi(t,r,n),t[$i]=e,t[hs]=n}catch(o){yn(e,e.return,o)}}var nd=!1,ti=!1,LF=!1,Ime=typeof WeakSet=="function"?WeakSet:Set,Ti=null;function Ght(e,t){if(e=e.containerInfo,Tj=AT,e=Vge(e),Gj(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,a=-1,l=-1,u=0,c=0,d=e,h=null;t:for(;;){for(var f;d!==n||i!==0&&d.nodeType!==3||(a=s+i),d!==o||r!==0&&d.nodeType!==3||(l=s+r),d.nodeType===3&&(s+=d.nodeValue.length),(f=d.firstChild)!==null;)h=d,d=f;for(;;){if(d===e)break t;if(h===n&&++u===i&&(a=s),h===o&&++c===r&&(l=s),(f=d.nextSibling)!==null)break;d=h,h=d.parentNode}d=f}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(Aj={focusedElem:e,selectionRange:n},AT=!1,Ti=t;Ti!==null;)if(t=Ti,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ti=e;else for(;Ti!==null;){switch(t=Ti,o=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(n=0;n<e.length;n++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&o!==null){e=void 0,n=t,i=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var p=qm(n.type,i);e=r.getSnapshotBeforeUpdate(p,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(m){yn(n,n.return,m)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)Rj(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Rj(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(re(163))}if(e=t.sibling,e!==null){e.return=t.return,Ti=e;break}Ti=t.return}}function nve(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Zc(e,n),r&4&&IS(5,n);break;case 1:if(Zc(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(s){yn(n,n.return,s)}else{var i=qm(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(s){yn(n,n.return,s)}}r&64&&Xye(n),r&512&&aS(n,n.return);break;case 3:if(Zc(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{sye(e,t)}catch(s){yn(n,n.return,s)}}break;case 27:t===null&&r&4&&tve(n);case 26:case 5:Zc(e,n),t===null&&r&4&&Zye(n),r&512&&aS(n,n.return);break;case 12:Zc(e,n);break;case 31:Zc(e,n),r&4&&ove(e,n);break;case 13:Zc(e,n),r&4&&sve(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=oft.bind(null,n),kft(e,n))));break;case 22:if(r=n.memoizedState!==null||nd,!r){t=t!==null&&t.memoizedState!==null||ti,i=nd;var o=ti;nd=r,(ti=t)&&!o?ed(e,n,(n.subtreeFlags&8772)!==0):Zc(e,n),nd=i,ti=o}break;case 30:break;default:Zc(e,n)}}function rve(e){var t=e.alternate;t!==null&&(e.alternate=null,rve(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Uj(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var lr=null,us=!1;function Jc(e,t,n){for(n=n.child;n!==null;)ive(e,t,n),n=n.sibling}function ive(e,t,n){if(Ys&&typeof Ys.onCommitFiberUnmount=="function")try{Ys.onCommitFiberUnmount(_S,n)}catch{}switch(n.tag){case 26:ti||Lu(n,t),Jc(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:ti||Lu(n,t);var r=lr,i=us;Af(n.type)&&(lr=n.stateNode,us=!1),Jc(e,t,n),dS(n.stateNode),lr=r,us=i;break;case 5:ti||Lu(n,t);case 6:if(r=lr,i=us,lr=null,Jc(e,t,n),lr=r,us=i,lr!==null)if(us)try{(lr.nodeType===9?lr.body:lr.nodeName==="HTML"?lr.ownerDocument.body:lr).removeChild(n.stateNode)}catch(o){yn(n,t,o)}else try{lr.removeChild(n.stateNode)}catch(o){yn(n,t,o)}break;case 18:lr!==null&&(us?(e=lr,Qme(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),N0(e)):Qme(lr,n.stateNode));break;case 4:r=lr,i=us,lr=n.stateNode.containerInfo,us=!0,Jc(e,t,n),lr=r,us=i;break;case 0:case 11:case 14:case 15:Ef(2,n,t),ti||Ef(4,n,t),Jc(e,t,n);break;case 1:ti||(Lu(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"&&Jye(n,t,r)),Jc(e,t,n);break;case 21:Jc(e,t,n);break;case 22:ti=(r=ti)||n.memoizedState!==null,Jc(e,t,n),ti=r;break;default:Jc(e,t,n)}}function ove(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{N0(e)}catch(n){yn(t,t.return,n)}}}function sve(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{N0(e)}catch(n){yn(t,t.return,n)}}function Xht(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Ime),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Ime),t;default:throw Error(re(435,e.tag))}}function BO(e,t){var n=Xht(e);t.forEach(function(r){if(!n.has(r)){n.add(r);var i=sft.bind(null,e,r);r.then(i,i)}})}function as(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],o=e,s=t,a=s;e:for(;a!==null;){switch(a.tag){case 27:if(Af(a.type)){lr=a.stateNode,us=!1;break e}break;case 5:lr=a.stateNode,us=!1;break e;case 3:case 4:lr=a.stateNode.containerInfo,us=!0;break e}a=a.return}if(lr===null)throw Error(re(160));ive(o,s,i),lr=null,us=!1,o=i.alternate,o!==null&&(o.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ave(t,e),t=t.sibling}var _l=null;function ave(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:as(t,e),ls(e),r&4&&(Ef(3,e,e.return),IS(3,e),Ef(5,e,e.return));break;case 1:as(t,e),ls(e),r&512&&(ti||n===null||Lu(n,n.return)),r&64&&nd&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=_l;if(as(t,e),ls(e),r&512&&(ti||n===null||Lu(n,n.return)),r&4){var o=n!==null?n.memoizedState:null;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){e:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(r){case"title":o=i.getElementsByTagName("title")[0],(!o||o[TS]||o[$i]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=i.createElement(r),i.head.insertBefore(o,i.querySelector("head > title"))),Qi(o,r,n),o[$i]=e,Ai(o),r=o;break e;case"link":var s=nge("link","href",i).get(r+(n.href||""));if(s){for(var a=0;a<s.length;a++)if(o=s[a],o.getAttribute("href")===(n.href==null||n.href===""?null:n.href)&&o.getAttribute("rel")===(n.rel==null?null:n.rel)&&o.getAttribute("title")===(n.title==null?null:n.title)&&o.getAttribute("crossorigin")===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(a,1);break t}}o=i.createElement(r),Qi(o,r,n),i.head.appendChild(o);break;case"meta":if(s=nge("meta","content",i).get(r+(n.content||""))){for(a=0;a<s.length;a++)if(o=s[a],o.getAttribute("content")===(n.content==null?null:""+n.content)&&o.getAttribute("name")===(n.name==null?null:n.name)&&o.getAttribute("property")===(n.property==null?null:n.property)&&o.getAttribute("http-equiv")===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute("charset")===(n.charSet==null?null:n.charSet)){s.splice(a,1);break t}}o=i.createElement(r),Qi(o,r,n),i.head.appendChild(o);break;default:throw Error(re(468,r))}o[$i]=e,Ai(o),r=o}e.stateNode=r}else rge(i,e.type,e.stateNode);else e.stateNode=tge(i,r,e.memoizedProps);else o!==r?(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?rge(i,e.type,e.stateNode):tge(i,r,e.memoizedProps)):r===null&&e.stateNode!==null&&IF(e,e.memoizedProps,n.memoizedProps)}break;case 27:as(t,e),ls(e),r&512&&(ti||n===null||Lu(n,n.return)),n!==null&&r&4&&IF(e,e.memoizedProps,n.memoizedProps);break;case 5:if(as(t,e),ls(e),r&512&&(ti||n===null||Lu(n,n.return)),e.flags&32){i=e.stateNode;try{y0(i,"")}catch(p){yn(e,e.return,p)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,IF(e,i,n!==null?n.memoizedProps:i)),r&1024&&(LF=!0);break;case 6:if(as(t,e),ls(e),r&4){if(e.stateNode===null)throw Error(re(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(p){yn(e,e.return,p)}}break;case 3:if(tT=null,i=_l,_l=ET(t.containerInfo),as(t,e),_l=i,ls(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{N0(t.containerInfo)}catch(p){yn(e,e.return,p)}LF&&(LF=!1,lve(e));break;case 4:r=_l,_l=ET(e.stateNode.containerInfo),as(t,e),ls(e),_l=r;break;case 12:as(t,e),ls(e);break;case 31:as(t,e),ls(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,BO(e,r)));break;case 13:as(t,e),ls(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(UT=Ks()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,BO(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=nd,c=ti;if(nd=u||i,ti=c||l,as(t,e),ti=c,nd=u,ls(e),r&8192)e:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||nd||ti||Em(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,i)s=o.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none";else{a=l.stateNode;var d=l.memoizedProps.style,h=d!=null&&d.hasOwnProperty("display")?d.display:null;a.style.display=h==null||typeof h=="boolean"?"":(""+h).trim()}}catch(p){yn(l,l.return,p)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?"":l.memoizedProps}catch(p){yn(l,l.return,p)}}}else if(t.tag===18){if(n===null){l=t;try{var f=l.stateNode;i?Gme(f,!0):Gme(l.stateNode,!1)}catch(p){yn(l,l.return,p)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,BO(e,n))));break;case 19:as(t,e),ls(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,BO(e,r)));break;case 30:break;case 21:break;default:as(t,e),ls(e)}}function ls(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(eve(r)){n=r;break}r=r.return}if(n==null)throw Error(re(160));switch(n.tag){case 27:var i=n.stateNode,o=PF(e);wT(e,o,i);break;case 5:var s=n.stateNode;n.flags&32&&(y0(s,""),n.flags&=-33);var a=PF(e);wT(e,a,s);break;case 3:case 4:var l=n.stateNode.containerInfo,u=PF(e);kj(e,u,l);break;default:throw Error(re(161))}}catch(c){yn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function lve(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;lve(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Zc(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)nve(e,t.alternate,t),t=t.sibling}function Em(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Ef(4,t,t.return),Em(t);break;case 1:Lu(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&Jye(t,t.return,n),Em(t);break;case 27:dS(t.stateNode);case 26:case 5:Lu(t,t.return),Em(t);break;case 22:t.memoizedState===null&&Em(t);break;case 30:Em(t);break;default:Em(t)}e=e.sibling}}function ed(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var r=t.alternate,i=e,o=t,s=o.flags;switch(o.tag){case 0:case 11:case 15:ed(i,o,n),IS(4,o);break;case 1:if(ed(i,o,n),r=o,i=r.stateNode,typeof i.componentDidMount=="function")try{i.componentDidMount()}catch(u){yn(r,r.return,u)}if(r=o,i=r.updateQueue,i!==null){var a=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)oye(l[i],a)}catch(u){yn(r,r.return,u)}}n&&s&64&&Xye(o),aS(o,o.return);break;case 27:tve(o);case 26:case 5:ed(i,o,n),n&&r===null&&s&4&&Zye(o),aS(o,o.return);break;case 12:ed(i,o,n);break;case 31:ed(i,o,n),n&&s&4&&ove(i,o);break;case 13:ed(i,o,n),n&&s&4&&sve(i,o);break;case 22:o.memoizedState===null&&ed(i,o,n),aS(o,o.return);break;case 30:break;default:ed(i,o,n)}t=t.sibling}}function SV(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&DS(n))}function kV(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&DS(e))}function Ml(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)uve(e,t,n,r),t=t.sibling}function uve(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Ml(e,t,n,r),i&2048&&IS(9,t);break;case 1:Ml(e,t,n,r);break;case 3:Ml(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&DS(e)));break;case 12:if(i&2048){Ml(e,t,n,r),e=t.stateNode;try{var o=t.memoizedProps,s=o.id,a=o.onPostCommit;typeof a=="function"&&a(s,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(l){yn(t,t.return,l)}}else Ml(e,t,n,r);break;case 31:Ml(e,t,n,r);break;case 13:Ml(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState!==null?o._visibility&2?Ml(e,t,n,r):lS(e,t):o._visibility&2?Ml(e,t,n,r):(o._visibility|=2,Yv(e,t,n,r,(t.subtreeFlags&10256)!==0||!1)),i&2048&&SV(s,t);break;case 24:Ml(e,t,n,r),i&2048&&kV(t.alternate,t);break;default:Ml(e,t,n,r)}}function Yv(e,t,n,r,i){for(i=i&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var o=e,s=t,a=n,l=r,u=s.flags;switch(s.tag){case 0:case 11:case 15:Yv(o,s,a,l,i),IS(8,s);break;case 23:break;case 22:var c=s.stateNode;s.memoizedState!==null?c._visibility&2?Yv(o,s,a,l,i):lS(o,s):(c._visibility|=2,Yv(o,s,a,l,i)),i&&u&2048&&SV(s.alternate,s);break;case 24:Yv(o,s,a,l,i),i&&u&2048&&kV(s.alternate,s);break;default:Yv(o,s,a,l,i)}t=t.sibling}}function lS(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:lS(n,r),i&2048&&SV(r.alternate,r);break;case 24:lS(n,r),i&2048&&kV(r.alternate,r);break;default:lS(n,r)}t=t.sibling}}var J1=8192;function Kv(e,t,n){if(e.subtreeFlags&J1)for(e=e.child;e!==null;)cve(e,t,n),e=e.sibling}function cve(e,t,n){switch(e.tag){case 26:Kv(e,t,n),e.flags&J1&&e.memoizedState!==null&&Pft(n,_l,e.memoizedState,e.memoizedProps);break;case 5:Kv(e,t,n);break;case 3:case 4:var r=_l;_l=ET(e.stateNode.containerInfo),Kv(e,t,n),_l=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=J1,J1=16777216,Kv(e,t,n),J1=r):Kv(e,t,n));break;default:Kv(e,t,n)}}function dve(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function H1(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Ti=r,fve(r,e)}dve(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)hve(e),e=e.sibling}function hve(e){switch(e.tag){case 0:case 11:case 15:H1(e),e.flags&2048&&Ef(9,e,e.return);break;case 3:H1(e);break;case 12:H1(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,ZO(e)):H1(e);break;default:H1(e)}}function ZO(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Ti=r,fve(r,e)}dve(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Ef(8,t,t.return),ZO(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,ZO(t));break;default:ZO(t)}e=e.sibling}}function fve(e,t){for(;Ti!==null;){var n=Ti;switch(n.tag){case 0:case 11:case 15:Ef(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:DS(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Ti=r;else e:for(n=e;Ti!==null;){r=Ti;var i=r.sibling,o=r.return;if(rve(r),r===n){Ti=null;break e}if(i!==null){i.return=o,Ti=i;break e}Ti=o}}}var Jht={getCacheForType:function(e){var t=Yi(ni),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Yi(ni).controller.signal}},Zht=typeof WeakMap=="function"?WeakMap:Map,an=0,An=null,Ft=null,Vt=0,gn=0,Ws=null,pf=!1,T0=!1,CV=!1,fd=0,_r=0,Of=0,Rm=0,NV=0,$s=0,x0=0,uS=null,cs=null,Cj=!1,UT=0,pve=0,xT=1/0,ST=null,xf=null,yi=0,Sf=null,S0=null,ld=0,Nj=0,Mj=null,mve=null,cS=0,_j=null;function Gs(){return(an&2)!==0&&Vt!==0?Vt&-Vt:nt.T!==null?_V():Cge()}function gve(){if($s===0)if((Vt&536870912)===0||Ut){var e=_O;_O<<=1,(_O&3932160)===0&&(_O=262144),$s=e}else $s=536870912;return e=Js.current,e!==null&&(e.flags|=32),$s}function ds(e,t,n){(e===An&&(gn===2||gn===9)||e.cancelPendingCommit!==null)&&(k0(e,0),mf(e,Vt,$s,!1)),OS(e,n),((an&2)===0||e!==An)&&(e===An&&((an&2)===0&&(Rm|=n),_r===4&&mf(e,Vt,$s,!1)),zu(e))}function yve(e,t,n){if((an&6)!==0)throw Error(re(327));var r=!n&&(t&127)===0&&(t&e.expiredLanes)===0||ES(e,t),i=r?nft(e,t):BF(e,t,!0),o=r;do{if(i===0){T0&&!r&&mf(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!eft(n)){i=BF(e,t,!1),o=!1;continue}if(i===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s!==0?s:s&536870912?536870912:0;if(s!==0){t=s;e:{var a=e;i=uS;var l=a.current.memoizedState.isDehydrated;if(l&&(k0(a,s).flags|=256),s=BF(a,s,!1),s!==2){if(CV&&!l){a.errorRecoveryDisabledLanes|=o,Rm|=o,i=4;break e}o=cs,cs=i,o!==null&&(cs===null?cs=o:cs.push.apply(cs,o))}i=s}if(o=!1,i!==2)continue}}if(i===1){k0(e,0),mf(e,t,0,!0);break}e:{switch(r=e,o=i,o){case 0:case 1:throw Error(re(345));case 4:if((t&4194048)!==t)break;case 6:mf(r,t,$s,!pf);break e;case 2:cs=null;break;case 3:case 5:break;default:throw Error(re(329))}if((t&62914560)===t&&(i=UT+300-Ks(),10<i)){if(mf(r,t,$s,!pf),RT(r,0,!0)!==0)break e;ld=t,r.timeoutHandle=Bve(Pme.bind(null,r,n,cs,ST,Cj,t,$s,Rm,x0,pf,o,"Throttled",-0,0),i);break e}Pme(r,n,cs,ST,Cj,t,$s,Rm,x0,pf,o,null,-0,0)}}break}while(!0);zu(e)}function Pme(e,t,n,r,i,o,s,a,l,u,c,d,h,f){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)===16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:id},cve(t,o,d);var p=(o&62914560)===o?UT-Ks():(o&4194048)===o?pve-Ks():0;if(p=Lft(d,p),p!==null){ld=o,e.cancelPendingCommit=p(Bme.bind(null,e,t,o,n,r,i,s,a,l,c,d,null,h,f)),mf(e,o,s,!u);return}}Bme(e,t,o,n,r,i,s,a,l)}function eft(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],o=i.getSnapshot;i=i.value;try{if(!Xs(o(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function mf(e,t,n,r){t&=~NV,t&=~Rm,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var o=31-Qs(i),s=1<<o;r[o]=-1,i&=~s}n!==0&&xge(e,n,t)}function HT(){return(an&6)===0?(PS(0,!1),!1):!0}function MV(){if(Ft!==null){if(gn===0)var e=Ft.return;else e=Ft,od=Wm=null,dV(e),h0=null,vS=0,e=Ft;for(;e!==null;)Gye(e.alternate,e),e=e.return;Ft=null}}function k0(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,vft(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),ld=0,MV(),An=e,Ft=n=sd(e.current,null),Vt=t,gn=0,Ws=null,pf=!1,T0=ES(e,t),CV=!1,x0=$s=NV=Rm=Of=_r=0,cs=uS=null,Cj=!1,(t&8)!==0&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Qs(r),o=1<<i;t|=e[i],r&=~o}return fd=t,BT(),n}function vve(e,t){kt=null,nt.H=wS,t===O0||t===zT?(t=fme(),gn=3):t===iV?(t=fme(),gn=4):gn=t===wV?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Ws=t,Ft===null&&(_r=1,vT(e,qa(t,e.current)))}function bve(){var e=Js.current;return e===null?!0:(Vt&4194048)===Vt?Fa===null:(Vt&62914560)===Vt||(Vt&536870912)!==0?e===Fa:!1}function wve(){var e=nt.H;return nt.H=wS,e===null?wS:e}function xve(){var e=nt.A;return nt.A=Jht,e}function kT(){_r=4,pf||(Vt&4194048)!==Vt&&Js.current!==null||(T0=!0),(Of&134217727)===0&&(Rm&134217727)===0||An===null||mf(An,Vt,$s,!1)}function BF(e,t,n){var r=an;an|=2;var i=wve(),o=xve();(An!==e||Vt!==t)&&(ST=null,k0(e,t)),t=!1;var s=_r;e:do try{if(gn!==0&&Ft!==null){var a=Ft,l=Ws;switch(gn){case 8:MV(),s=6;break e;case 3:case 2:case 9:case 6:Js.current===null&&(t=!0);var u=gn;if(gn=0,Ws=null,a0(e,a,l,u),n&&T0){s=0;break e}break;default:u=gn,gn=0,Ws=null,a0(e,a,l,u)}}tft(),s=_r;break}catch(c){vve(e,c)}while(!0);return t&&e.shellSuspendCounter++,od=Wm=null,an=r,nt.H=i,nt.A=o,Ft===null&&(An=null,Vt=0,BT()),s}function tft(){for(;Ft!==null;)Sve(Ft)}function nft(e,t){var n=an;an|=2;var r=wve(),i=xve();An!==e||Vt!==t?(ST=null,xT=Ks()+500,k0(e,t)):T0=ES(e,t);e:do try{if(gn!==0&&Ft!==null){t=Ft;var o=Ws;t:switch(gn){case 1:gn=0,Ws=null,a0(e,t,o,1);break;case 2:case 9:if(hme(o)){gn=0,Ws=null,Lme(t);break}t=function(){gn!==2&&gn!==9||An!==e||(gn=7),zu(e)},o.then(t,t);break e;case 3:gn=7;break e;case 4:gn=5;break e;case 7:hme(o)?(gn=0,Ws=null,Lme(t)):(gn=0,Ws=null,a0(e,t,o,7));break;case 5:var s=null;switch(Ft.tag){case 26:s=Ft.memoizedState;case 5:case 27:var a=Ft;if(s?Vve(s):a.stateNode.complete){gn=0,Ws=null;var l=a.sibling;if(l!==null)Ft=l;else{var u=a.return;u!==null?(Ft=u,$T(u)):Ft=null}break t}}gn=0,Ws=null,a0(e,t,o,5);break;case 6:gn=0,Ws=null,a0(e,t,o,6);break;case 8:MV(),_r=6;break e;default:throw Error(re(462))}}rft();break}catch(c){vve(e,c)}while(!0);return od=Wm=null,nt.H=r,nt.A=i,an=n,Ft!==null?0:(An=null,Vt=0,BT(),_r)}function rft(){for(;Ft!==null&&!Mdt();)Sve(Ft)}function Sve(e){var t=Qye(e.alternate,e,fd);e.memoizedProps=e.pendingProps,t===null?$T(e):Ft=t}function Lme(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Ome(n,t,t.pendingProps,t.type,void 0,Vt);break;case 11:t=Ome(n,t,t.pendingProps,t.type.render,t.ref,Vt);break;case 5:dV(t);default:Gye(n,t),t=Ft=Gge(t,fd),t=Qye(n,t,fd)}e.memoizedProps=e.pendingProps,t===null?$T(e):Ft=t}function a0(e,t,n,r){od=Wm=null,dV(t),h0=null,vS=0;var i=t.return;try{if(Hht(e,i,t,n,Vt)){_r=1,vT(e,qa(n,e.current)),Ft=null;return}}catch(o){if(i!==null)throw Ft=i,o;_r=1,vT(e,qa(n,e.current)),Ft=null;return}t.flags&32768?(Ut||r===1?e=!0:T0||(Vt&536870912)!==0?e=!1:(pf=e=!0,(r===2||r===9||r===3||r===6)&&(r=Js.current,r!==null&&r.tag===13&&(r.flags|=16384))),kve(t,e)):$T(t)}function $T(e){var t=e;do{if((t.flags&32768)!==0){kve(t,pf);return}e=t.return;var n=Yht(t.alternate,t,fd);if(n!==null){Ft=n;return}if(t=t.sibling,t!==null){Ft=t;return}Ft=t=e}while(t!==null);_r===0&&(_r=5)}function kve(e,t){do{var n=Qht(e.alternate,e);if(n!==null){n.flags&=32767,Ft=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ft=e;return}Ft=e=n}while(e!==null);_r=6,Ft=null}function Bme(e,t,n,r,i,o,s,a,l){e.cancelPendingCommit=null;do KT();while(yi!==0);if((an&6)!==0)throw Error(re(327));if(t!==null){if(t===e.current)throw Error(re(177));if(o=t.lanes|t.childLanes,o|=Xj,Ldt(e,n,o,s,a,l),e===An&&(Ft=An=null,Vt=0),S0=t,Sf=e,ld=n,Nj=o,Mj=i,mve=r,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,aft(aT,function(){return Eve(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||r){r=nt.T,nt.T=null,i=ln.p,ln.p=2,s=an,an|=4;try{Ght(e,t,n)}finally{an=s,ln.p=i,nt.T=r}}yi=1,Cve(),Nve(),Mve()}}function Cve(){if(yi===1){yi=0;var e=Sf,t=S0,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=nt.T,nt.T=null;var r=ln.p;ln.p=2;var i=an;an|=4;try{ave(t,e);var o=Aj,s=Vge(e.containerInfo),a=o.focusedElem,l=o.selectionRange;if(s!==a&&a&&a.ownerDocument&&jge(a.ownerDocument.documentElement,a)){if(l!==null&&Gj(a)){var u=l.start,c=l.end;if(c===void 0&&(c=u),"selectionStart"in a)a.selectionStart=u,a.selectionEnd=Math.min(c,a.value.length);else{var d=a.ownerDocument||document,h=d&&d.defaultView||window;if(h.getSelection){var f=h.getSelection(),p=a.textContent.length,m=Math.min(l.start,p),g=l.end===void 0?m:Math.min(l.end,p);!f.extend&&m>g&&(s=g,g=m,m=s);var y=ome(a,m),v=ome(a,g);if(y&&v&&(f.rangeCount!==1||f.anchorNode!==y.node||f.anchorOffset!==y.offset||f.focusNode!==v.node||f.focusOffset!==v.offset)){var b=d.createRange();b.setStart(y.node,y.offset),f.removeAllRanges(),m>g?(f.addRange(b),f.extend(v.node,v.offset)):(b.setEnd(v.node,v.offset),f.addRange(b))}}}}for(d=[],f=a;f=f.parentNode;)f.nodeType===1&&d.push({element:f,left:f.scrollLeft,top:f.scrollTop});for(typeof a.focus=="function"&&a.focus(),a=0;a<d.length;a++){var w=d[a];w.element.scrollLeft=w.left,w.element.scrollTop=w.top}}AT=!!Tj,Aj=Tj=null}finally{an=i,ln.p=r,nt.T=n}}e.current=t,yi=2}}function Nve(){if(yi===2){yi=0;var e=Sf,t=S0,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=nt.T,nt.T=null;var r=ln.p;ln.p=2;var i=an;an|=4;try{nve(e,t.alternate,t)}finally{an=i,ln.p=r,nt.T=n}}yi=3}}function Mve(){if(yi===4||yi===3){yi=0,_dt();var e=Sf,t=S0,n=ld,r=mve;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?yi=5:(yi=0,S0=Sf=null,_ve(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(xf=null),Wj(n),t=t.stateNode,Ys&&typeof Ys.onCommitFiberRoot=="function")try{Ys.onCommitFiberRoot(_S,t,void 0,(t.current.flags&128)===128)}catch{}if(r!==null){t=nt.T,i=ln.p,ln.p=2,nt.T=null;try{for(var o=e.onRecoverableError,s=0;s<r.length;s++){var a=r[s];o(a.value,{componentStack:a.stack})}}finally{nt.T=t,ln.p=i}}(ld&3)!==0&&KT(),zu(e),i=e.pendingLanes,(n&261930)!==0&&(i&42)!==0?e===_j?cS++:(cS=0,_j=e):cS=0,PS(0,!1)}}function _ve(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,DS(t)))}function KT(){return Cve(),Nve(),Mve(),Eve()}function Eve(){if(yi!==5)return!1;var e=Sf,t=Nj;Nj=0;var n=Wj(ld),r=nt.T,i=ln.p;try{ln.p=32>n?32:n,nt.T=null,n=Mj,Mj=null;var o=Sf,s=ld;if(yi=0,S0=Sf=null,ld=0,(an&6)!==0)throw Error(re(331));var a=an;if(an|=4,hve(o.current),uve(o,o.current,s,n),an=a,PS(0,!1),Ys&&typeof Ys.onPostCommitFiberRoot=="function")try{Ys.onPostCommitFiberRoot(_S,o)}catch{}return!0}finally{ln.p=i,nt.T=r,_ve(e,t)}}function qme(e,t,n){t=qa(n,t),t=wj(e.stateNode,t,2),e=wf(e,t,2),e!==null&&(OS(e,2),zu(e))}function yn(e,t,n){if(e.tag===3)qme(e,e,n);else for(;t!==null;){if(t.tag===3){qme(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(xf===null||!xf.has(r))){e=qa(n,e),n=Wye(2),r=wf(t,n,2),r!==null&&(Uye(n,r,t,e),OS(r,2),zu(r));break}}t=t.return}}function qF(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Zht;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(CV=!0,i.add(n),e=ift.bind(null,e,t,n),t.then(e,e))}function ift(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,An===e&&(Vt&n)===n&&(_r===4||_r===3&&(Vt&62914560)===Vt&&300>Ks()-UT?(an&2)===0&&k0(e,0):NV|=n,x0===Vt&&(x0=0)),zu(e)}function Ove(e,t){t===0&&(t=wge()),e=Vm(e,t),e!==null&&(OS(e,t),zu(e))}function oft(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ove(e,n)}function sft(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(re(314))}r!==null&&r.delete(t),Ove(e,n)}function aft(e,t){return jj(e,t)}var CT=null,Qv=null,Ej=!1,NT=!1,zF=!1,gf=0;function zu(e){e!==Qv&&e.next===null&&(Qv===null?CT=Qv=e:Qv=Qv.next=e),NT=!0,Ej||(Ej=!0,uft())}function PS(e,t){if(!zF&&NT){zF=!0;do for(var n=!1,r=CT;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var o=0;else{var s=r.suspendedLanes,a=r.pingedLanes;o=(1<<31-Qs(42|e)+1)-1,o&=i&~(s&~a),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(n=!0,zme(r,o))}else o=Vt,o=RT(r,r===An?o:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),(o&3)===0||ES(r,o)||(n=!0,zme(r,o));r=r.next}while(n);zF=!1}}function lft(){Tve()}function Tve(){NT=Ej=!1;var e=0;gf!==0&&yft()&&(e=gf);for(var t=Ks(),n=null,r=CT;r!==null;){var i=r.next,o=Ave(r,t);o===0?(r.next=null,n===null?CT=i:n.next=i,i===null&&(Qv=n)):(n=r,(e!==0||(o&3)!==0)&&(NT=!0)),r=i}yi!==0&&yi!==5||PS(e,!1),gf!==0&&(gf=0)}function Ave(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var s=31-Qs(o),a=1<<s,l=i[s];l===-1?((a&n)===0||(a&r)!==0)&&(i[s]=Pdt(a,t)):l<=t&&(e.expiredLanes|=a),o&=~a}if(t=An,n=Vt,n=RT(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(gn===2||gn===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&pF(r),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||ES(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&pF(r),Wj(n)){case 2:case 8:n=vge;break;case 32:n=aT;break;case 268435456:n=bge;break;default:n=aT}return r=Dve.bind(null,e),n=jj(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&pF(r),e.callbackPriority=2,e.callbackNode=null,2}function Dve(e,t){if(yi!==0&&yi!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(KT()&&e.callbackNode!==n)return null;var r=Vt;return r=RT(e,e===An?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(yve(e,r,t),Ave(e,Ks()),e.callbackNode!=null&&e.callbackNode===n?Dve.bind(null,e):null)}function zme(e,t){if(KT())return null;yve(e,t,!0)}function uft(){bft(function(){(an&6)!==0?jj(yge,lft):Tve()})}function _V(){if(gf===0){var e=v0;e===0&&(e=MO,MO<<=1,(MO&261888)===0&&(MO=256)),gf=e}return gf}function Fme(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:UO(""+e)}function jme(e,t){var n=t.ownerDocument.createElement("input");return n.name=t.name,n.value=t.value,e.id&&n.setAttribute("form",e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function cft(e,t,n,r,i){if(t==="submit"&&n&&n.stateNode===i){var o=Fme((i[hs]||null).action),s=r.submitter;s&&(t=(t=s[hs]||null)?Fme(t.formAction):s.getAttribute("formAction"),t!==null&&(o=t,s=null));var a=new IT("action","action",null,r,i);e.push({event:a,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(gf!==0){var l=s?jme(i,s):new FormData(i);vj(n,{pending:!0,data:l,method:i.method,action:o},null,l)}}else typeof o=="function"&&(a.preventDefault(),l=s?jme(i,s):new FormData(i),vj(n,{pending:!0,data:l,method:i.method,action:o},o,l))},currentTarget:i}]})}}for(qO=0;qO<sj.length;qO++)zO=sj[qO],Vme=zO.toLowerCase(),Wme=zO[0].toUpperCase()+zO.slice(1),El(Vme,"on"+Wme);var zO,Vme,Wme,qO;El(Uge,"onAnimationEnd");El(Hge,"onAnimationIteration");El($ge,"onAnimationStart");El("dblclick","onDoubleClick");El("focusin","onFocus");El("focusout","onBlur");El(Eht,"onTransitionRun");El(Oht,"onTransitionStart");El(Tht,"onTransitionCancel");El(Kge,"onTransitionEnd");g0("onMouseEnter",["mouseout","mouseover"]);g0("onMouseLeave",["mouseout","mouseover"]);g0("onPointerEnter",["pointerout","pointerover"]);g0("onPointerLeave",["pointerout","pointerover"]);zm("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));zm("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));zm("onBeforeInput",["compositionend","keypress","textInput","paste"]);zm("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));zm("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));zm("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xS="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),dft=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(xS));function Rve(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],l=a.instance,u=a.currentTarget;if(a=a.listener,l!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=u;try{o(i)}catch(c){uT(c)}i.currentTarget=null,o=l}else for(s=0;s<r.length;s++){if(a=r[s],l=a.instance,u=a.currentTarget,a=a.listener,l!==o&&i.isPropagationStopped())break e;o=a,i.currentTarget=u;try{o(i)}catch(c){uT(c)}i.currentTarget=null,o=l}}}}function zt(e,t){var n=t[JF];n===void 0&&(n=t[JF]=new Set);var r=e+"__bubble";n.has(r)||(Ive(t,e,2,!1),n.add(r))}function FF(e,t,n){var r=0;t&&(r|=4),Ive(n,e,r,t)}var FO="_reactListening"+Math.random().toString(36).slice(2);function EV(e){if(!e[FO]){e[FO]=!0,Nge.forEach(function(n){n!=="selectionchange"&&(dft.has(n)||FF(n,!1,e),FF(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[FO]||(t[FO]=!0,FF("selectionchange",!1,t))}}function Ive(e,t,n,r){switch(Kve(t)){case 2:var i=zft;break;case 8:i=Fft;break;default:i=DV}n=i.bind(null,t,n,e),i=void 0,!rj||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function jF(e,t,n,r,i){var o=r;if((t&1)===0&&(t&2)===0&&r!==null)e:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var a=r.stateNode.containerInfo;if(a===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;a!==null;){if(s=Jv(a),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=o=s;continue e}a=a.parentNode}}r=r.return}Rge(function(){var u=o,c=$j(n),d=[];e:{var h=Yge.get(e);if(h!==void 0){var f=IT,p=e;switch(e){case"keypress":if($O(n)===0)break e;case"keydown":case"keyup":f=sht;break;case"focusin":p="focus",f=bF;break;case"focusout":p="blur",f=bF;break;case"beforeblur":case"afterblur":f=bF;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":f=Gpe;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":f=Ydt;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":f=uht;break;case Uge:case Hge:case $ge:f=Xdt;break;case Kge:f=dht;break;case"scroll":case"scrollend":f=$dt;break;case"wheel":f=fht;break;case"copy":case"cut":case"paste":f=Zdt;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":f=Jpe;break;case"toggle":case"beforetoggle":f=mht}var m=(t&4)!==0,g=!m&&(e==="scroll"||e==="scrollend"),y=m?h!==null?h+"Capture":null:h;m=[];for(var v=u,b;v!==null;){var w=v;if(b=w.stateNode,w=w.tag,w!==5&&w!==26&&w!==27||b===null||y===null||(w=fS(v,y),w!=null&&m.push(SS(v,w,b))),g)break;v=v.return}0<m.length&&(h=new f(h,p,null,n,c),d.push({event:h,listeners:m}))}}if((t&7)===0){e:{if(h=e==="mouseover"||e==="pointerover",f=e==="mouseout"||e==="pointerout",h&&n!==nj&&(p=n.relatedTarget||n.fromElement)&&(Jv(p)||p[M0]))break e;if((f||h)&&(h=c.window===c?c:(h=c.ownerDocument)?h.defaultView||h.parentWindow:window,f?(p=n.relatedTarget||n.toElement,f=u,p=p?Jv(p):null,p!==null&&(g=MS(p),m=p.tag,p!==g||m!==5&&m!==27&&m!==6)&&(p=null)):(f=null,p=u),f!==p)){if(m=Gpe,w="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(m=Jpe,w="onPointerLeave",y="onPointerEnter",v="pointer"),g=f==null?h:G1(f),b=p==null?h:G1(p),h=new m(w,v+"leave",f,n,c),h.target=g,h.relatedTarget=b,w=null,Jv(c)===u&&(m=new m(y,v+"enter",p,n,c),m.target=b,m.relatedTarget=g,w=m),g=w,f&&p)t:{for(m=hft,y=f,v=p,b=0,w=y;w;w=m(w))b++;w=0;for(var x=v;x;x=m(x))w++;for(;0<b-w;)y=m(y),b--;for(;0<w-b;)v=m(v),w--;for(;b--;){if(y===v||v!==null&&y===v.alternate){m=y;break t}y=m(y),v=m(v)}m=null}else m=null;f!==null&&Ume(d,h,f,m,!1),p!==null&&g!==null&&Ume(d,g,p,m,!0)}}e:{if(h=u?G1(u):window,f=h.nodeName&&h.nodeName.toLowerCase(),f==="select"||f==="input"&&h.type==="file")var S=nme;else if(tme(h))if(zge)S=Nht;else{S=kht;var k=Sht}else f=h.nodeName,!f||f.toLowerCase()!=="input"||h.type!=="checkbox"&&h.type!=="radio"?u&&Hj(u.elementType)&&(S=nme):S=Cht;if(S&&(S=S(e,u))){qge(d,S,n,c);break e}k&&k(e,h,u),e==="focusout"&&u&&h.type==="number"&&u.memoizedProps.value!=null&&tj(h,"number",h.value)}switch(k=u?G1(u):window,e){case"focusin":(tme(k)||k.contentEditable==="true")&&(t0=k,ij=u,tS=null);break;case"focusout":tS=ij=t0=null;break;case"mousedown":oj=!0;break;case"contextmenu":case"mouseup":case"dragend":oj=!1,sme(d,n,c);break;case"selectionchange":if(_ht)break;case"keydown":case"keyup":sme(d,n,c)}var C;if(Qj)e:{switch(e){case"compositionstart":var N="onCompositionStart";break e;case"compositionend":N="onCompositionEnd";break e;case"compositionupdate":N="onCompositionUpdate";break e}N=void 0}else e0?Lge(e,n)&&(N="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(N="onCompositionStart");N&&(Pge&&n.locale!=="ko"&&(e0||N!=="onCompositionStart"?N==="onCompositionEnd"&&e0&&(C=Ige()):(ff=c,Kj="value"in ff?ff.value:ff.textContent,e0=!0)),k=MT(u,N),0<k.length&&(N=new Xpe(N,e,null,n,c),d.push({event:N,listeners:k}),C?N.data=C:(C=Bge(n),C!==null&&(N.data=C)))),(C=yht?vht(e,n):bht(e,n))&&(N=MT(u,"onBeforeInput"),0<N.length&&(k=new Xpe("onBeforeInput","beforeinput",null,n,c),d.push({event:k,listeners:N}),k.data=C)),cft(d,e,u,n,c)}Rve(d,t)})}function SS(e,t,n){return{instance:e,listener:t,currentTarget:n}}function MT(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||o===null||(i=fS(e,n),i!=null&&r.unshift(SS(e,i,o)),i=fS(e,t),i!=null&&r.push(SS(e,i,o))),e.tag===3)return r;e=e.return}return[]}function hft(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Ume(e,t,n,r,i){for(var o=t._reactName,s=[];n!==null&&n!==r;){var a=n,l=a.alternate,u=a.stateNode;if(a=a.tag,l!==null&&l===r)break;a!==5&&a!==26&&a!==27||u===null||(l=u,i?(u=fS(n,o),u!=null&&s.unshift(SS(n,u,l))):i||(u=fS(n,o),u!=null&&s.push(SS(n,u,l)))),n=n.return}s.length!==0&&e.push({event:t,listeners:s})}var fft=/\r\n?/g,pft=/\u0000|\uFFFD/g;function Hme(e){return(typeof e=="string"?e:""+e).replace(fft,`
`).replace(pft,"")}function Pve(e,t){return t=Hme(t),Hme(e)===t}function Cn(e,t,n,r,i,o){switch(n){case"children":typeof r=="string"?t==="body"||t==="textarea"&&r===""||y0(e,r):(typeof r=="number"||typeof r=="bigint")&&t!=="body"&&y0(e,""+r);break;case"className":OO(e,"class",r);break;case"tabIndex":OO(e,"tabindex",r);break;case"dir":case"role":case"viewBox":case"width":case"height":OO(e,n,r);break;case"style":Dge(e,r,o);break;case"data":if(t!=="object"){OO(e,"data",r);break}case"src":case"href":if(r===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(r==null||typeof r=="function"||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=UO(""+r),e.setAttribute(n,r);break;case"action":case"formAction":if(typeof r=="function"){e.setAttribute(n,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof o=="function"&&(n==="formAction"?(t!=="input"&&Cn(e,t,"name",i.name,i,null),Cn(e,t,"formEncType",i.formEncType,i,null),Cn(e,t,"formMethod",i.formMethod,i,null),Cn(e,t,"formTarget",i.formTarget,i,null)):(Cn(e,t,"encType",i.encType,i,null),Cn(e,t,"method",i.method,i,null),Cn(e,t,"target",i.target,i,null)));if(r==null||typeof r=="symbol"||typeof r=="boolean"){e.removeAttribute(n);break}r=UO(""+r),e.setAttribute(n,r);break;case"onClick":r!=null&&(e.onclick=id);break;case"onScroll":r!=null&&zt("scroll",e);break;case"onScrollEnd":r!=null&&zt("scrollend",e);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(re(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(re(60));e.innerHTML=n}}break;case"multiple":e.multiple=r&&typeof r!="function"&&typeof r!="symbol";break;case"muted":e.muted=r&&typeof r!="function"&&typeof r!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(r==null||typeof r=="function"||typeof r=="boolean"||typeof r=="symbol"){e.removeAttribute("xlink:href");break}n=UO(""+r),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",n);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""+r):e.removeAttribute(n);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":r&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":r===!0?e.setAttribute(n,""):r!==!1&&r!=null&&typeof r!="function"&&typeof r!="symbol"?e.setAttribute(n,r):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":r!=null&&typeof r!="function"&&typeof r!="symbol"&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case"rowSpan":case"start":r==null||typeof r=="function"||typeof r=="symbol"||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case"popover":zt("beforetoggle",e),zt("toggle",e),WO(e,"popover",r);break;case"xlinkActuate":Gc(e,"http://www.w3.org/1999/xlink","xlink:actuate",r);break;case"xlinkArcrole":Gc(e,"http://www.w3.org/1999/xlink","xlink:arcrole",r);break;case"xlinkRole":Gc(e,"http://www.w3.org/1999/xlink","xlink:role",r);break;case"xlinkShow":Gc(e,"http://www.w3.org/1999/xlink","xlink:show",r);break;case"xlinkTitle":Gc(e,"http://www.w3.org/1999/xlink","xlink:title",r);break;case"xlinkType":Gc(e,"http://www.w3.org/1999/xlink","xlink:type",r);break;case"xmlBase":Gc(e,"http://www.w3.org/XML/1998/namespace","xml:base",r);break;case"xmlLang":Gc(e,"http://www.w3.org/XML/1998/namespace","xml:lang",r);break;case"xmlSpace":Gc(e,"http://www.w3.org/XML/1998/namespace","xml:space",r);break;case"is":WO(e,"is",r);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=Udt.get(n)||n,WO(e,n,r))}}function Oj(e,t,n,r,i,o){switch(n){case"style":Dge(e,r,o);break;case"dangerouslySetInnerHTML":if(r!=null){if(typeof r!="object"||!("__html"in r))throw Error(re(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(re(60));e.innerHTML=n}}break;case"children":typeof r=="string"?y0(e,r):(typeof r=="number"||typeof r=="bigint")&&y0(e,""+r);break;case"onScroll":r!=null&&zt("scroll",e);break;case"onScrollEnd":r!=null&&zt("scrollend",e);break;case"onClick":r!=null&&(e.onclick=id);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Mge.hasOwnProperty(n))e:{if(n[0]==="o"&&n[1]==="n"&&(i=n.endsWith("Capture"),t=n.slice(2,i?n.length-7:void 0),o=e[hs]||null,o=o!=null?o[n]:null,typeof o=="function"&&e.removeEventListener(t,o,i),typeof r=="function")){typeof o!="function"&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break e}n in e?e[n]=r:r===!0?e.setAttribute(n,""):WO(e,n,r)}}}function Qi(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":zt("error",e),zt("load",e);var r=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case"src":r=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(re(137,t));default:Cn(e,t,o,s,n,null)}}i&&Cn(e,t,"srcSet",n.srcSet,n,null),r&&Cn(e,t,"src",n.src,n,null);return;case"input":zt("invalid",e);var a=o=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var c=n[r];if(c!=null)switch(r){case"name":i=c;break;case"type":s=c;break;case"checked":l=c;break;case"defaultChecked":u=c;break;case"value":o=c;break;case"defaultValue":a=c;break;case"children":case"dangerouslySetInnerHTML":if(c!=null)throw Error(re(137,t));break;default:Cn(e,t,r,c,n,null)}}Oge(e,o,a,l,u,s,i,!1);return;case"select":zt("invalid",e),r=s=o=null;for(i in n)if(n.hasOwnProperty(i)&&(a=n[i],a!=null))switch(i){case"value":o=a;break;case"defaultValue":s=a;break;case"multiple":r=a;default:Cn(e,t,i,a,n,null)}t=o,n=s,e.multiple=!!r,t!=null?u0(e,!!r,t,!1):n!=null&&u0(e,!!r,n,!0);return;case"textarea":zt("invalid",e),o=i=r=null;for(s in n)if(n.hasOwnProperty(s)&&(a=n[s],a!=null))switch(s){case"value":r=a;break;case"defaultValue":i=a;break;case"children":o=a;break;case"dangerouslySetInnerHTML":if(a!=null)throw Error(re(91));break;default:Cn(e,t,s,a,n,null)}Age(e,r,i,o);return;case"option":for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case"selected":e.selected=r&&typeof r!="function"&&typeof r!="symbol";break;default:Cn(e,t,l,r,n,null)}return;case"dialog":zt("beforetoggle",e),zt("toggle",e),zt("cancel",e),zt("close",e);break;case"iframe":case"object":zt("load",e);break;case"video":case"audio":for(r=0;r<xS.length;r++)zt(xS[r],e);break;case"image":zt("error",e),zt("load",e);break;case"details":zt("toggle",e);break;case"embed":case"source":case"link":zt("error",e),zt("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case"children":case"dangerouslySetInnerHTML":throw Error(re(137,t));default:Cn(e,t,u,r,n,null)}return;default:if(Hj(t)){for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!==void 0&&Oj(e,t,c,r,n,void 0));return}}for(a in n)n.hasOwnProperty(a)&&(r=n[a],r!=null&&Cn(e,t,a,r,n,null))}function mft(e,t,n,r){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var i=null,o=null,s=null,a=null,l=null,u=null,c=null;for(f in n){var d=n[f];if(n.hasOwnProperty(f)&&d!=null)switch(f){case"checked":break;case"value":break;case"defaultValue":l=d;default:r.hasOwnProperty(f)||Cn(e,t,f,null,r,d)}}for(var h in r){var f=r[h];if(d=n[h],r.hasOwnProperty(h)&&(f!=null||d!=null))switch(h){case"type":o=f;break;case"name":i=f;break;case"checked":u=f;break;case"defaultChecked":c=f;break;case"value":s=f;break;case"defaultValue":a=f;break;case"children":case"dangerouslySetInnerHTML":if(f!=null)throw Error(re(137,t));break;default:f!==d&&Cn(e,t,h,f,r,d)}}ej(e,s,a,l,u,c,o,i);return;case"select":f=s=a=h=null;for(o in n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case"value":break;case"multiple":f=l;default:r.hasOwnProperty(o)||Cn(e,t,o,null,r,l)}for(i in r)if(o=r[i],l=n[i],r.hasOwnProperty(i)&&(o!=null||l!=null))switch(i){case"value":h=o;break;case"defaultValue":a=o;break;case"multiple":s=o;default:o!==l&&Cn(e,t,i,o,r,l)}t=a,n=s,r=f,h!=null?u0(e,!!n,h,!1):!!r!=!!n&&(t!=null?u0(e,!!n,t,!0):u0(e,!!n,n?[]:"",!1));return;case"textarea":f=h=null;for(a in n)if(i=n[a],n.hasOwnProperty(a)&&i!=null&&!r.hasOwnProperty(a))switch(a){case"value":break;case"children":break;default:Cn(e,t,a,null,r,i)}for(s in r)if(i=r[s],o=n[s],r.hasOwnProperty(s)&&(i!=null||o!=null))switch(s){case"value":h=i;break;case"defaultValue":f=i;break;case"children":break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(re(91));break;default:i!==o&&Cn(e,t,s,i,r,o)}Tge(e,h,f);return;case"option":for(var p in n)if(h=n[p],n.hasOwnProperty(p)&&h!=null&&!r.hasOwnProperty(p))switch(p){case"selected":e.selected=!1;break;default:Cn(e,t,p,null,r,h)}for(l in r)if(h=r[l],f=n[l],r.hasOwnProperty(l)&&h!==f&&(h!=null||f!=null))switch(l){case"selected":e.selected=h&&typeof h!="function"&&typeof h!="symbol";break;default:Cn(e,t,l,h,r,f)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var m in n)h=n[m],n.hasOwnProperty(m)&&h!=null&&!r.hasOwnProperty(m)&&Cn(e,t,m,null,r,h);for(u in r)if(h=r[u],f=n[u],r.hasOwnProperty(u)&&h!==f&&(h!=null||f!=null))switch(u){case"children":case"dangerouslySetInnerHTML":if(h!=null)throw Error(re(137,t));break;default:Cn(e,t,u,h,r,f)}return;default:if(Hj(t)){for(var g in n)h=n[g],n.hasOwnProperty(g)&&h!==void 0&&!r.hasOwnProperty(g)&&Oj(e,t,g,void 0,r,h);for(c in r)h=r[c],f=n[c],!r.hasOwnProperty(c)||h===f||h===void 0&&f===void 0||Oj(e,t,c,h,r,f);return}}for(var y in n)h=n[y],n.hasOwnProperty(y)&&h!=null&&!r.hasOwnProperty(y)&&Cn(e,t,y,null,r,h);for(d in r)h=r[d],f=n[d],!r.hasOwnProperty(d)||h===f||h==null&&f==null||Cn(e,t,d,h,r,f)}function $me(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function gft(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),r=0;r<n.length;r++){var i=n[r],o=i.transferSize,s=i.initiatorType,a=i.duration;if(o&&a&&$me(s)){for(s=0,a=i.responseEnd,r+=1;r<n.length;r++){var l=n[r],u=l.startTime;if(u>a)break;var c=l.transferSize,d=l.initiatorType;c&&$me(d)&&(l=l.responseEnd,s+=c*(l<a?1:(a-u)/(l-u)))}if(--r,t+=8*(o+s)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var Tj=null,Aj=null;function _T(e){return e.nodeType===9?e:e.ownerDocument}function Kme(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Lve(e,t){if(e===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&t==="foreignObject"?0:e}function Dj(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var VF=null;function yft(){var e=window.event;return e&&e.type==="popstate"?e===VF?!1:(VF=e,!0):(VF=null,!1)}var Bve=typeof setTimeout=="function"?setTimeout:void 0,vft=typeof clearTimeout=="function"?clearTimeout:void 0,Yme=typeof Promise=="function"?Promise:void 0,bft=typeof queueMicrotask=="function"?queueMicrotask:typeof Yme<"u"?function(e){return Yme.resolve(null).then(e).catch(wft)}:Bve;function wft(e){setTimeout(function(){throw e})}function Af(e){return e==="head"}function Qme(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"||n==="/&"){if(r===0){e.removeChild(i),N0(t);return}r--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")r++;else if(n==="html")dS(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,dS(n);for(var o=n.firstChild;o;){var s=o.nextSibling,a=o.nodeName;o[TS]||a==="SCRIPT"||a==="STYLE"||a==="LINK"&&o.rel.toLowerCase()==="stylesheet"||n.removeChild(o),o=s}}else n==="body"&&dS(e.ownerDocument.body);n=i}while(n);N0(t)}function Gme(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display="none"):(n.style.display=n._stashedDisplay||"",n.getAttribute("style")===""&&n.removeAttribute("style")):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=""):n.nodeValue=n._stashedText||""),r&&r.nodeType===8)if(n=r.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=r}while(n)}function Rj(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case"HTML":case"HEAD":case"BODY":Rj(n),Uj(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function xft(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(r){if(!e[TS])switch(t){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(o=e.getAttribute("rel"),o==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(o!==i.rel||e.getAttribute("href")!==(i.href==null||i.href===""?null:i.href)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute("title")!==(i.title==null?null:i.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(o=e.getAttribute("src"),(o!==(i.src==null?null:i.src)||e.getAttribute("type")!==(i.type==null?null:i.type)||e.getAttribute("crossorigin")!==(i.crossOrigin==null?null:i.crossOrigin))&&o&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(t==="input"&&e.type==="hidden"){var o=i.name==null?null:""+i.name;if(i.type==="hidden"&&e.getAttribute("name")===o)return e}else return e;if(e=ja(e.nextSibling),e===null)break}return null}function Sft(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=ja(e.nextSibling),e===null))return null;return e}function qve(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=ja(e.nextSibling),e===null))return null;return e}function Ij(e){return e.data==="$?"||e.data==="$~"}function Pj(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function kft(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var r=function(){t(),n.removeEventListener("DOMContentLoaded",r)};n.addEventListener("DOMContentLoaded",r),e._reactRetry=r}}function ja(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return e}var Lj=null;function Xme(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return ja(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function Jme(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"){if(t===0)return e;t--}else n!=="/$"&&n!=="/&"||t++}e=e.previousSibling}return null}function zve(e,t,n){switch(t=_T(n),e){case"html":if(e=t.documentElement,!e)throw Error(re(452));return e;case"head":if(e=t.head,!e)throw Error(re(453));return e;case"body":if(e=t.body,!e)throw Error(re(454));return e;default:throw Error(re(451))}}function dS(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Uj(e)}var Va=new Map,Zme=new Set;function ET(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var pd=ln.d;ln.d={f:Cft,r:Nft,D:Mft,C:_ft,L:Eft,m:Oft,X:Aft,S:Tft,M:Dft};function Cft(){var e=pd.f(),t=HT();return e||t}function Nft(e){var t=_0(e);t!==null&&t.tag===5&&t.type==="form"?Dye(t):pd.r(e)}var A0=typeof document>"u"?null:document;function Fve(e,t,n){var r=A0;if(r&&typeof t=="string"&&t){var i=Ba(t);i='link[rel="'+e+'"][href="'+i+'"]',typeof n=="string"&&(i+='[crossorigin="'+n+'"]'),Zme.has(i)||(Zme.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement("link"),Qi(t,"link",e),Ai(t),r.head.appendChild(t)))}}function Mft(e){pd.D(e),Fve("dns-prefetch",e,null)}function _ft(e,t){pd.C(e,t),Fve("preconnect",e,t)}function Eft(e,t,n){pd.L(e,t,n);var r=A0;if(r&&e&&t){var i='link[rel="preload"][as="'+Ba(t)+'"]';t==="image"&&n&&n.imageSrcSet?(i+='[imagesrcset="'+Ba(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(i+='[imagesizes="'+Ba(n.imageSizes)+'"]')):i+='[href="'+Ba(e)+'"]';var o=i;switch(t){case"style":o=C0(e);break;case"script":o=D0(e)}Va.has(o)||(e=Jn({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),Va.set(o,e),r.querySelector(i)!==null||t==="style"&&r.querySelector(LS(o))||t==="script"&&r.querySelector(BS(o))||(t=r.createElement("link"),Qi(t,"link",e),Ai(t),r.head.appendChild(t)))}}function Oft(e,t){pd.m(e,t);var n=A0;if(n&&e){var r=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+Ba(r)+'"][href="'+Ba(e)+'"]',o=i;switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=D0(e)}if(!Va.has(o)&&(e=Jn({rel:"modulepreload",href:e},t),Va.set(o,e),n.querySelector(i)===null)){switch(r){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(BS(o)))return}r=n.createElement("link"),Qi(r,"link",e),Ai(r),n.head.appendChild(r)}}}function Tft(e,t,n){pd.S(e,t,n);var r=A0;if(r&&e){var i=l0(r).hoistableStyles,o=C0(e);t=t||"default";var s=i.get(o);if(!s){var a={loading:0,preload:null};if(s=r.querySelector(LS(o)))a.loading=5;else{e=Jn({rel:"stylesheet",href:e,"data-precedence":t},n),(n=Va.get(o))&&OV(e,n);var l=s=r.createElement("link");Ai(l),Qi(l,"link",e),l._p=new Promise(function(u,c){l.onload=u,l.onerror=c}),l.addEventListener("load",function(){a.loading|=1}),l.addEventListener("error",function(){a.loading|=2}),a.loading|=4,eT(s,t,r)}s={type:"stylesheet",instance:s,count:1,state:a},i.set(o,s)}}}function Aft(e,t){pd.X(e,t);var n=A0;if(n&&e){var r=l0(n).hoistableScripts,i=D0(e),o=r.get(i);o||(o=n.querySelector(BS(i)),o||(e=Jn({src:e,async:!0},t),(t=Va.get(i))&&TV(e,t),o=n.createElement("script"),Ai(o),Qi(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function Dft(e,t){pd.M(e,t);var n=A0;if(n&&e){var r=l0(n).hoistableScripts,i=D0(e),o=r.get(i);o||(o=n.querySelector(BS(i)),o||(e=Jn({src:e,async:!0,type:"module"},t),(t=Va.get(i))&&TV(e,t),o=n.createElement("script"),Ai(o),Qi(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},r.set(i,o))}}function ege(e,t,n,r){var i=(i=yf.current)?ET(i):null;if(!i)throw Error(re(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=C0(n.href),n=l0(i).hoistableStyles,r=n.get(t),r||(r={type:"style",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=C0(n.href);var o=l0(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(LS(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Va.has(e)||(n={rel:"preload",as:"style",href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Va.set(e,n),o||Rft(i,e,n,s.state))),t&&r===null)throw Error(re(528,""));return s}if(t&&r!==null)throw Error(re(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=D0(n),n=l0(i).hoistableScripts,r=n.get(t),r||(r={type:"script",instance:null,count:0,state:null},n.set(t,r)),r):{type:"void",instance:null,count:0,state:null};default:throw Error(re(444,e))}}function C0(e){return'href="'+Ba(e)+'"'}function LS(e){return'link[rel="stylesheet"]['+e+"]"}function jve(e){return Jn({},e,{"data-precedence":e.precedence,precedence:null})}function Rft(e,t,n,r){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?r.loading=1:(t=e.createElement("link"),r.preload=t,t.addEventListener("load",function(){return r.loading|=1}),t.addEventListener("error",function(){return r.loading|=2}),Qi(t,"link",n),Ai(t),e.head.appendChild(t))}function D0(e){return'[src="'+Ba(e)+'"]'}function BS(e){return"script[async]"+e}function tge(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var r=e.querySelector('style[data-href~="'+Ba(n.href)+'"]');if(r)return t.instance=r,Ai(r),r;var i=Jn({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement("style"),Ai(r),Qi(r,"style",i),eT(r,n.precedence,e),t.instance=r;case"stylesheet":i=C0(n.href);var o=e.querySelector(LS(i));if(o)return t.state.loading|=4,t.instance=o,Ai(o),o;r=jve(n),(i=Va.get(i))&&OV(r,i),o=(e.ownerDocument||e).createElement("link"),Ai(o);var s=o;return s._p=new Promise(function(a,l){s.onload=a,s.onerror=l}),Qi(o,"link",r),t.state.loading|=4,eT(o,n.precedence,e),t.instance=o;case"script":return o=D0(n.src),(i=e.querySelector(BS(o)))?(t.instance=i,Ai(i),i):(r=n,(i=Va.get(o))&&(r=Jn({},n),TV(r,i)),e=e.ownerDocument||e,i=e.createElement("script"),Ai(i),Qi(i,"link",r),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(re(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(r=t.instance,t.state.loading|=4,eT(r,n.precedence,e));return t.instance}function eT(e,t,n){for(var r=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=r.length?r[r.length-1]:null,o=i,s=0;s<r.length;s++){var a=r[s];if(a.dataset.precedence===t)o=a;else if(o!==i)break}o?o.parentNode.insertBefore(e,o.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function OV(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function TV(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var tT=null;function nge(e,t,n){if(tT===null){var r=new Map,i=tT=new Map;i.set(n,r)}else i=tT,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var o=n[i];if(!(o[TS]||o[$i]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var s=o.getAttribute(t)||"";s=e+s;var a=r.get(s);a?a.push(o):r.set(s,[o])}}return r}function rge(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function Ift(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;switch(t.rel){case"stylesheet":return e=t.disabled,typeof t.precedence=="string"&&e==null;default:return!0}case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Vve(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function Pft(e,t,n,r){if(n.type==="stylesheet"&&(typeof r.media!="string"||matchMedia(r.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var i=C0(r.href),o=t.querySelector(LS(i));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=OT.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=o,Ai(o);return}o=t.ownerDocument||t,r=jve(r),(i=Va.get(i))&&OV(r,i),o=o.createElement("link"),Ai(o);var s=o;s._p=new Promise(function(a,l){s.onload=a,s.onerror=l}),Qi(o,"link",r),n.instance=o}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&(n.state.loading&3)===0&&(e.count++,n=OT.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var WF=0;function Lft(e,t){return e.stylesheets&&e.count===0&&nT(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&nT(e,e.stylesheets),e.unsuspend){var o=e.unsuspend;e.unsuspend=null,o()}},6e4+t);0<e.imgBytes&&WF===0&&(WF=62500*gft());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&nT(e,e.stylesheets),e.unsuspend)){var o=e.unsuspend;e.unsuspend=null,o()}},(e.imgBytes>WF?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function OT(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)nT(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var TT=null;function nT(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,TT=new Map,t.forEach(Bft,e),TT=null,OT.call(e))}function Bft(e,t){if(!(t.state.loading&4)){var n=TT.get(e);if(n)var r=n.get(null);else{n=new Map,TT.set(e,n);for(var i=e.querySelectorAll("link[data-precedence],style[data-precedence]"),o=0;o<i.length;o++){var s=i[o];(s.nodeName==="LINK"||s.getAttribute("media")!=="not all")&&(n.set(s.dataset.precedence,s),r=s)}r&&n.set(null,r)}i=t.instance,s=i.getAttribute("data-precedence"),o=n.get(s)||r,o===r&&n.set(null,i),n.set(s,i),this.count++,r=OT.bind(this),i.addEventListener("load",r),i.addEventListener("error",r),o?o.parentNode.insertBefore(i,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var kS={$$typeof:rd,Provider:null,Consumer:null,_currentValue:Om,_currentValue2:Om,_threadCount:0};function qft(e,t,n,r,i,o,s,a,l){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=mF(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mF(0),this.hiddenUpdates=mF(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=o,this.onRecoverableError=s,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=l,this.incompleteTransitions=new Map}function Wve(e,t,n,r,i,o,s,a,l,u,c,d){return e=new qft(e,t,n,s,l,u,c,d,a),t=1,o===!0&&(t|=24),o=Hs(3,null,null,t),e.current=o,o.stateNode=e,t=nV(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:r,isDehydrated:n,cache:t},oV(o),e}function Uve(e){return e?(e=i0,e):i0}function Hve(e,t,n,r,i,o){i=Uve(i),r.context===null?r.context=i:r.pendingContext=i,r=bf(t),r.payload={element:n},o=o===void 0?null:o,o!==null&&(r.callback=o),n=wf(e,r,t),n!==null&&(ds(n,e,t),rS(n,e,t))}function ige(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function AV(e,t){ige(e,t),(e=e.alternate)&&ige(e,t)}function $ve(e){if(e.tag===13||e.tag===31){var t=Vm(e,67108864);t!==null&&ds(t,e,67108864),AV(e,67108864)}}function oge(e){if(e.tag===13||e.tag===31){var t=Gs();t=Vj(t);var n=Vm(e,t);n!==null&&ds(n,e,t),AV(e,t)}}var AT=!0;function zft(e,t,n,r){var i=nt.T;nt.T=null;var o=ln.p;try{ln.p=2,DV(e,t,n,r)}finally{ln.p=o,nt.T=i}}function Fft(e,t,n,r){var i=nt.T;nt.T=null;var o=ln.p;try{ln.p=8,DV(e,t,n,r)}finally{ln.p=o,nt.T=i}}function DV(e,t,n,r){if(AT){var i=Bj(r);if(i===null)jF(e,t,r,DT,n),sge(e,r);else if(Vft(i,e,t,n,r))r.stopPropagation();else if(sge(e,r),t&4&&-1<jft.indexOf(e)){for(;i!==null;){var o=_0(i);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var s=Mm(o.pendingLanes);if(s!==0){var a=o;for(a.pendingLanes|=2,a.entangledLanes|=2;s;){var l=1<<31-Qs(s);a.entanglements[1]|=l,s&=~l}zu(o),(an&6)===0&&(xT=Ks()+500,PS(0,!1))}}break;case 31:case 13:a=Vm(o,2),a!==null&&ds(a,o,2),HT(),AV(o,2)}if(o=Bj(r),o===null&&jF(e,t,r,DT,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else jF(e,t,r,null,n)}}function Bj(e){return e=$j(e),RV(e)}var DT=null;function RV(e){if(DT=null,e=Jv(e),e!==null){var t=MS(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=hge(t),e!==null)return e;e=null}else if(n===31){if(e=fge(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return DT=e,null}function Kve(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Edt()){case yge:return 2;case vge:return 8;case aT:case Odt:return 32;case bge:return 268435456;default:return 32}default:return 32}}var qj=!1,kf=null,Cf=null,Nf=null,CS=new Map,NS=new Map,df=[],jft="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function sge(e,t){switch(e){case"focusin":case"focusout":kf=null;break;case"dragenter":case"dragleave":Cf=null;break;case"mouseover":case"mouseout":Nf=null;break;case"pointerover":case"pointerout":CS.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":NS.delete(t.pointerId)}}function $1(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=_0(t),t!==null&&$ve(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Vft(e,t,n,r,i){switch(t){case"focusin":return kf=$1(kf,e,t,n,r,i),!0;case"dragenter":return Cf=$1(Cf,e,t,n,r,i),!0;case"mouseover":return Nf=$1(Nf,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return CS.set(o,$1(CS.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,NS.set(o,$1(NS.get(o)||null,e,t,n,r,i)),!0}return!1}function Yve(e){var t=Jv(e.target);if(t!==null){var n=MS(t);if(n!==null){if(t=n.tag,t===13){if(t=hge(n),t!==null){e.blockedOn=t,Wpe(e.priority,function(){oge(n)});return}}else if(t===31){if(t=fge(n),t!==null){e.blockedOn=t,Wpe(e.priority,function(){oge(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function rT(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Bj(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);nj=r,n.target.dispatchEvent(r),nj=null}else return t=_0(n),t!==null&&$ve(t),e.blockedOn=n,!1;t.shift()}return!0}function age(e,t,n){rT(e)&&n.delete(t)}function Wft(){qj=!1,kf!==null&&rT(kf)&&(kf=null),Cf!==null&&rT(Cf)&&(Cf=null),Nf!==null&&rT(Nf)&&(Nf=null),CS.forEach(age),NS.forEach(age)}function jO(e,t){e.blockedOn===t&&(e.blockedOn=null,qj||(qj=!0,vi.unstable_scheduleCallback(vi.unstable_NormalPriority,Wft)))}var VO=null;function lge(e){VO!==e&&(VO=e,vi.unstable_scheduleCallback(vi.unstable_NormalPriority,function(){VO===e&&(VO=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!="function"){if(RV(r||n)===null)continue;break}var o=_0(n);o!==null&&(e.splice(t,3),t-=3,vj(o,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function N0(e){function t(l){return jO(l,e)}kf!==null&&jO(kf,e),Cf!==null&&jO(Cf,e),Nf!==null&&jO(Nf,e),CS.forEach(t),NS.forEach(t);for(var n=0;n<df.length;n++){var r=df[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<df.length&&(n=df[0],n.blockedOn===null);)Yve(n),n.blockedOn===null&&df.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],o=n[r+1],s=i[hs]||null;if(typeof o=="function")s||lge(n);else if(s){var a=null;if(o&&o.hasAttribute("formAction")){if(i=o,s=o[hs]||null)a=s.formAction;else if(RV(i)!==null)continue}else a=s.action;typeof a=="function"?n[r+1]=a:(n.splice(r,3),r-=3),lge(n)}}}function Qve(){function e(o){o.canIntercept&&o.info==="react-transition"&&o.intercept({handler:function(){return new Promise(function(s){return i=s})},focusReset:"manual",scroll:"manual"})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var o=navigation.currentEntry;o&&o.url!=null&&navigation.navigate(o.url,{state:o.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var r=!1,i=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),i!==null&&(i(),i=null)}}}function IV(e){this._internalRoot=e}YT.prototype.render=IV.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(re(409));var n=t.current,r=Gs();Hve(n,r,e,t,null,null)};YT.prototype.unmount=IV.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Hve(e.current,2,null,e,null,null),HT(),t[M0]=null}};function YT(e){this._internalRoot=e}YT.prototype.unstable_scheduleHydration=function(e){if(e){var t=Cge();e={blockedOn:null,target:e,priority:t};for(var n=0;n<df.length&&t!==0&&t<df[n].priority;n++);df.splice(n,0,e),n===0&&Yve(e)}};var uge=cge.version;if(uge!=="19.2.0")throw Error(re(527,uge,"19.2.0"));ln.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(re(188)):(e=Object.keys(e).join(","),Error(re(268,e)));return e=xdt(t),e=e!==null?pge(e):null,e=e===null?null:e.stateNode,e};var Uft={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:nt,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&(K1=__REACT_DEVTOOLS_GLOBAL_HOOK__,!K1.isDisabled&&K1.supportsFiber))try{_S=K1.inject(Uft),Ys=K1}catch{}var K1;QT.createRoot=function(e,t){if(!dge(e))throw Error(re(299));var n=!1,r="",i=Fye,o=jye,s=Vye;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Wve(e,1,!1,null,null,n,r,null,i,o,s,Qve),e[M0]=t.current,EV(e),new IV(t)};QT.hydrateRoot=function(e,t,n){if(!dge(e))throw Error(re(299));var r=!1,i="",o=Fye,s=jye,a=Vye,l=null;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(o=n.onUncaughtError),n.onCaughtError!==void 0&&(s=n.onCaughtError),n.onRecoverableError!==void 0&&(a=n.onRecoverableError),n.formState!==void 0&&(l=n.formState)),t=Wve(e,1,!0,t,n??null,r,i,l,o,s,a,Qve),t.context=Uve(null),n=t.current,r=Gs(),r=Vj(r),i=bf(r),i.callback=null,wf(n,i,r),n=r,t.current.lanes=n,OS(t,n),zu(t),e[M0]=t.current,EV(e),new YT(t)};QT.version="19.2.0"});var Zve=Al((TSt,Jve)=>{"use strict";function Xve(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Xve)}catch(e){console.error(e)}}Xve(),Jve.exports=Gve()});var lpt=L(H(),1),upt=L(rn(),1);var rpt=L(H(),1),ipt=L(rn(),1);var aA=new WeakMap;function lA(e){let t=aA.get(e);return t==null?null:(aA.delete(e),t)}function HS(e){let{abortSignal:t,durationMs:n}=e;t&&aA.set(t,n)}function e4(e){if(typeof performance.getEntriesByType!="function")return null;let t=performance.getEntriesByType("resource"),n=E0e(e.requestUrl),r=null,i=Number.POSITIVE_INFINITY;for(let o of t){let s=o;if(s.initiatorType!=="fetch"||!O0e(n,s.name,e.requestUrl)||s.startTime+1<e.requestStartedAt)continue;let a=Math.abs(s.startTime-e.requestStartedAt);a>i||(i=a,r=Math.round(s.duration))}return r}function E0e(e){try{let t=new URL(e);return{origin:t.origin,pathname:t4(t.pathname)}}catch{return null}}function O0e(e,t,n){if(!e)return t===n;try{let r=new URL(t);return r.origin===e.origin&&t4(r.pathname)===e.pathname}catch{return!1}}function t4(e){return e.endsWith("/")&&e.length>1?e.slice(0,-1):e}async function $S(e){let t=e4({requestStartedAt:e.requestStartedAt,requestUrl:e.responseUrl});return t??(await new Promise(r=>{setTimeout(r,0)}),e4({requestStartedAt:e.requestStartedAt,requestUrl:e.responseUrl})??Math.round(performance.now()-e.requestStartedAt))}function uA(e){let{customHeaders:t,customPayload:n,resultDeserializerFn:r,url:i}=e,o=e.fetch||fetch;return{async execute(s,a){try{let l=performance.now(),u=await o(i,{body:JSON.stringify({customPayload:n,procedure:"query",query:s}),headers:{Accept:"application/json","Content-Type":"application/json",...t},method:"POST",signal:a?.abortSignal}),c=await $S({requestStartedAt:l,responseUrl:u.url});if(HS({abortSignal:a?.abortSignal,durationMs:c}),!u.ok){let f;try{f=await u.text()}catch{f="unknown error"}return[new Error(f)]}let[d,h]=await u.json();return d?[Lf(d)]:[null,r?.(h)||h]}catch(l){return[l]}},async executeSequence(s,a){try{let l=performance.now(),u=await o(i,{body:JSON.stringify({customPayload:n,procedure:"sequence",sequence:s}),headers:{Accept:"application/json","Content-Type":"application/json",...t},method:"POST",signal:a?.abortSignal}),c=await $S({requestStartedAt:l,responseUrl:u.url});if(HS({abortSignal:a?.abortSignal,durationMs:c}),!u.ok){let y;try{y=await u.text()}catch{y="unknown error"}return[[new Error(y)]]}let[[d,h],f]=await u.json();if(d)return[[Lf(d)]];let p=r?.(h)||h,[m,g]=f||[];return m?[[null,p],[Lf(m)]]:[[null,p],[null,r?.(g)||g]]}catch(l){return[[l]]}},async executeTransaction(s,a){try{let l=performance.now(),u=await o(i,{body:JSON.stringify({customPayload:n,procedure:"transaction",queries:s}),headers:{Accept:"application/json","Content-Type":"application/json",...t},method:"POST",signal:a?.abortSignal}),c=await $S({requestStartedAt:l,responseUrl:u.url});if(HS({abortSignal:a?.abortSignal,durationMs:c}),!u.ok){let f;try{f=await u.text()}catch{f="unknown error"}return[new Error(f)]}let[d,h]=await u.json();return d?[Lf(d)]:[null,(h??[]).map(f=>r?.(f)||f)]}catch(l){return[l]}},async lintSql(s,a){try{let l=performance.now(),u=await o(i,{body:JSON.stringify({customPayload:n,procedure:"sql-lint",schemaVersion:s.schemaVersion,sql:s.sql}),headers:{Accept:"application/json","Content-Type":"application/json",...t},method:"POST",signal:a?.abortSignal}),c=await $S({requestStartedAt:l,responseUrl:u.url});if(HS({abortSignal:a?.abortSignal,durationMs:c}),!u.ok){let f;try{f=await u.text()}catch{f="unknown error"}return[new Error(f)]}let[d,h]=await u.json();return d?[Lf(d)]:[null,h]}catch(l){return[l]}}}}function Lf(e){let{name:t,message:n}=e;if(e.errors!==void 0){let i=e.errors.map(Lf),o=new AggregateError(i,n);return o.name=e.name,o}let r=new Error(e.message);return e.name=t,r}var T0e=L(H(),1),A0e=L(rn(),1);function Qm(e){if(e==="react")return T0e;if(e==="react-dom")return A0e;throw new Error(`Unknown module ${e}`)}var D0e=Object.create,cA=Object.defineProperty,R0e=Object.getOwnPropertyDescriptor,I0e=Object.getOwnPropertyNames,P0e=Object.getPrototypeOf,L0e=Object.prototype.hasOwnProperty,KS=(e=>typeof Qm<"u"?Qm:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof Qm<"u"?Qm:t)[n]}):e)(function(e){if(typeof Qm<"u")return Qm.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),zr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),YS=(e,t)=>{for(var n in t)cA(e,n,{get:t[n],enumerable:!0})},B0e=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of I0e(t))!L0e.call(e,i)&&i!==n&&cA(e,i,{get:()=>t[i],enumerable:!(r=R0e(t,i))||r.enumerable});return e},Dl=(e,t,n)=>(n=e!=null?D0e(P0e(e)):{},B0e(t||!e||!e.__esModule?cA(n,"default",{value:e,enumerable:!0}):n,e));var Pmt=L(H(),1),Lmt=L(rn(),1);var ymt=L(H(),1),vmt=L(rn(),1);var hpt=L(H(),1),fpt=L(rn(),1);var bk=zr((e,t)=>{"use strict";(function(n,r){typeof e=="object"&&typeof t<"u"?t.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self).dayjs=r()})(e,function(){"use strict";var n=1e3,r=6e4,i=36e5,o="millisecond",s="second",a="minute",l="hour",u="day",c="week",d="month",h="quarter",f="year",p="date",m="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(_){var R=["th","st","nd","rd"],T=_%100;return"["+_+(R[(T-20)%10]||R[T]||R[0])+"]"}},b=function(_,R,T){var B=String(_);return!B||B.length>=R?_:""+Array(R+1-B.length).join(T)+_},w={s:b,z:function(_){var R=-_.utcOffset(),T=Math.abs(R),B=Math.floor(T/60),A=T%60;return(R<=0?"+":"-")+b(B,2,"0")+":"+b(A,2,"0")},m:function _(R,T){if(R.date()<T.date())return-_(T,R);var B=12*(T.year()-R.year())+(T.month()-R.month()),A=R.clone().add(B,d),M=T-A<0,P=R.clone().add(B+(M?-1:1),d);return+(-(B+(T-A)/(M?A-P:P-A))||0)},a:function(_){return _<0?Math.ceil(_)||0:Math.floor(_)},p:function(_){return{M:d,y:f,w:c,d:u,D:p,h:l,m:a,s,ms:o,Q:h}[_]||String(_||"").toLowerCase().replace(/s$/,"")},u:function(_){return _===void 0}},x="en",S={};S[x]=v;var k="$isDayjsObject",C=function(_){return _ instanceof q||!(!_||!_[k])},N=function _(R,T,B){var A;if(!R)return x;if(typeof R=="string"){var M=R.toLowerCase();S[M]&&(A=M),T&&(S[M]=T,A=M);var P=R.split("-");if(!A&&P.length>1)return _(P[0])}else{var F=R.name;S[F]=R,A=F}return!B&&A&&(x=A),A||!B&&x},E=function(_,R){if(C(_))return _.clone();var T=typeof R=="object"?R:{};return T.date=_,T.args=arguments,new q(T)},D=w;D.l=N,D.i=C,D.w=function(_,R){return E(_,{locale:R.$L,utc:R.$u,x:R.$x,$offset:R.$offset})};var q=function(){function _(T){this.$L=N(T.locale,null,!0),this.parse(T),this.$x=this.$x||T.x||{},this[k]=!0}var R=_.prototype;return R.parse=function(T){this.$d=function(B){var A=B.date,M=B.utc;if(A===null)return new Date(NaN);if(D.u(A))return new Date;if(A instanceof Date)return new Date(A);if(typeof A=="string"&&!/Z$/i.test(A)){var P=A.match(g);if(P){var F=P[2]-1||0,I=(P[7]||"0").substring(0,3);return M?new Date(Date.UTC(P[1],F,P[3]||1,P[4]||0,P[5]||0,P[6]||0,I)):new Date(P[1],F,P[3]||1,P[4]||0,P[5]||0,P[6]||0,I)}}return new Date(A)}(T),this.init()},R.init=function(){var T=this.$d;this.$y=T.getFullYear(),this.$M=T.getMonth(),this.$D=T.getDate(),this.$W=T.getDay(),this.$H=T.getHours(),this.$m=T.getMinutes(),this.$s=T.getSeconds(),this.$ms=T.getMilliseconds()},R.$utils=function(){return D},R.isValid=function(){return this.$d.toString()!==m},R.isSame=function(T,B){var A=E(T);return this.startOf(B)<=A&&A<=this.endOf(B)},R.isAfter=function(T,B){return E(T)<this.startOf(B)},R.isBefore=function(T,B){return this.endOf(B)<E(T)},R.$g=function(T,B,A){return D.u(T)?this[B]:this.set(A,T)},R.unix=function(){return Math.floor(this.valueOf()/1e3)},R.valueOf=function(){return this.$d.getTime()},R.startOf=function(T,B){var A=this,M=!!D.u(B)||B,P=D.p(T),F=function(Q,J){var oe=D.w(A.$u?Date.UTC(A.$y,J,Q):new Date(A.$y,J,Q),A);return M?oe:oe.endOf(u)},I=function(Q,J){return D.w(A.toDate()[Q].apply(A.toDate("s"),(M?[0,0,0,0]:[23,59,59,999]).slice(J)),A)},V=this.$W,W=this.$M,j=this.$D,X="set"+(this.$u?"UTC":"");switch(P){case f:return M?F(1,0):F(31,11);case d:return M?F(1,W):F(0,W+1);case c:var $=this.$locale().weekStart||0,K=(V<$?V+7:V)-$;return F(M?j-K:j+(6-K),W);case u:case p:return I(X+"Hours",0);case l:return I(X+"Minutes",1);case a:return I(X+"Seconds",2);case s:return I(X+"Milliseconds",3);default:return this.clone()}},R.endOf=function(T){return this.startOf(T,!1)},R.$set=function(T,B){var A,M=D.p(T),P="set"+(this.$u?"UTC":""),F=(A={},A[u]=P+"Date",A[p]=P+"Date",A[d]=P+"Month",A[f]=P+"FullYear",A[l]=P+"Hours",A[a]=P+"Minutes",A[s]=P+"Seconds",A[o]=P+"Milliseconds",A)[M],I=M===u?this.$D+(B-this.$W):B;if(M===d||M===f){var V=this.clone().set(p,1);V.$d[F](I),V.init(),this.$d=V.set(p,Math.min(this.$D,V.daysInMonth())).$d}else F&&this.$d[F](I);return this.init(),this},R.set=function(T,B){return this.clone().$set(T,B)},R.get=function(T){return this[D.p(T)]()},R.add=function(T,B){var A,M=this;T=Number(T);var P=D.p(B),F=function(W){var j=E(M);return D.w(j.date(j.date()+Math.round(W*T)),M)};if(P===d)return this.set(d,this.$M+T);if(P===f)return this.set(f,this.$y+T);if(P===u)return F(1);if(P===c)return F(7);var I=(A={},A[a]=r,A[l]=i,A[s]=n,A)[P]||1,V=this.$d.getTime()+T*I;return D.w(V,this)},R.subtract=function(T,B){return this.add(-1*T,B)},R.format=function(T){var B=this,A=this.$locale();if(!this.isValid())return A.invalidDate||m;var M=T||"YYYY-MM-DDTHH:mm:ssZ",P=D.z(this),F=this.$H,I=this.$m,V=this.$M,W=A.weekdays,j=A.months,X=A.meridiem,$=function(J,oe,be,Me){return J&&(J[oe]||J(B,M))||be[oe].slice(0,Me)},K=function(J){return D.s(F%12||12,J,"0")},Q=X||function(J,oe,be){var Me=J<12?"AM":"PM";return be?Me.toLowerCase():Me};return M.replace(y,function(J,oe){return oe||function(be){switch(be){case"YY":return String(B.$y).slice(-2);case"YYYY":return D.s(B.$y,4,"0");case"M":return V+1;case"MM":return D.s(V+1,2,"0");case"MMM":return $(A.monthsShort,V,j,3);case"MMMM":return $(j,V);case"D":return B.$D;case"DD":return D.s(B.$D,2,"0");case"d":return String(B.$W);case"dd":return $(A.weekdaysMin,B.$W,W,2);case"ddd":return $(A.weekdaysShort,B.$W,W,3);case"dddd":return W[B.$W];case"H":return String(F);case"HH":return D.s(F,2,"0");case"h":return K(1);case"hh":return K(2);case"a":return Q(F,I,!0);case"A":return Q(F,I,!1);case"m":return String(I);case"mm":return D.s(I,2,"0");case"s":return String(B.$s);case"ss":return D.s(B.$s,2,"0");case"SSS":return D.s(B.$ms,3,"0");case"Z":return P}return null}(J)||P.replace(":","")})},R.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},R.diff=function(T,B,A){var M,P=this,F=D.p(B),I=E(T),V=(I.utcOffset()-this.utcOffset())*r,W=this-I,j=function(){return D.m(P,I)};switch(F){case f:M=j()/12;break;case d:M=j();break;case h:M=j()/3;break;case c:M=(W-V)/6048e5;break;case u:M=(W-V)/864e5;break;case l:M=W/i;break;case a:M=W/r;break;case s:M=W/n;break;default:M=W}return A?M:D.a(M)},R.daysInMonth=function(){return this.endOf(d).$D},R.$locale=function(){return S[this.$L]},R.locale=function(T,B){if(!T)return this.$L;var A=this.clone(),M=N(T,B,!0);return M&&(A.$L=M),A},R.clone=function(){return D.w(this.$d,this)},R.toDate=function(){return new Date(this.valueOf())},R.toJSON=function(){return this.isValid()?this.toISOString():null},R.toISOString=function(){return this.$d.toISOString()},R.toString=function(){return this.$d.toUTCString()},_}(),z=q.prototype;return E.prototype=z,[["$ms",o],["$s",s],["$m",a],["$H",l],["$W",u],["$M",d],["$y",f],["$D",p]].forEach(function(_){z[_[1]]=function(R){return this.$g(R,_[0],_[1])}}),E.extend=function(_,R){return _.$i||(_(R,q,E),_.$i=!0),E},E.locale=N,E.isDayjs=C,E.unix=function(_){return E(1e3*_)},E.en=S[x],E.Ls=S,E.p={},E})}),q0e=zr((e,t)=>{"use strict";(function(n,r){typeof e=="object"&&typeof t<"u"?t.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self).dayjs_plugin_utc=r()})(e,function(){"use strict";var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,s,a){var l=s.prototype;a.utc=function(m){var g={date:m,utc:!0,args:arguments};return new s(g)},l.utc=function(m){var g=a(this.toDate(),{locale:this.$L,utc:!0});return m?g.add(this.utcOffset(),n):g},l.local=function(){return a(this.toDate(),{locale:this.$L,utc:!1})};var u=l.parse;l.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),u.call(this,m)};var c=l.init;l.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else c.call(this)};var d=l.utcOffset;l.utcOffset=function(m,g){var y=this.$utils().u;if(y(m))return this.$u?0:y(this.$offset)?d.call(this):this.$offset;if(typeof m=="string"&&(m=function(x){x===void 0&&(x="");var S=x.match(r);if(!S)return null;var k=(""+S[0]).match(i)||["-",0,0],C=k[0],N=60*+k[1]+ +k[2];return N===0?0:C==="+"?N:-N}(m),m===null))return this;var v=Math.abs(m)<=16?60*m:m;if(v===0)return this.utc(g);var b=this.clone();if(g)return b.$offset=v,b.$u=!1,b;var w=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(b=this.local().add(v+w,n)).$offset=v,b.$x.$localOffset=w,b};var h=l.format;l.format=function(m){var g=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,g)},l.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},l.isUTC=function(){return!!this.$u},l.toISOString=function(){return this.toDate().toISOString()},l.toString=function(){return this.toDate().toUTCString()};var f=l.toDate;l.toDate=function(m){return m==="s"&&this.$offset?a(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():f.call(this)};var p=l.diff;l.diff=function(m,g,y){if(m&&this.$u===m.$u)return p.call(this,m,g,y);var v=this.local(),b=a(m).local();return p.call(v,b,g,y)}}})}),R4=Dl(bk(),1),z0e=Dl(q0e(),1);R4.default.extend(z0e.default);var F0e={};function Ju(e){return F0e[e]??=(0,R4.default)(0).utc().format(e)}var j0e="",eb=0,wk=!1,hg="[]",Yf="{}";function _d(e){return typeof e>"u"||e===void 0}function go(e){return typeof e=="string"}function xk(e){return typeof e=="number"}function hk(e){return typeof e=="boolean"}function AA(e){return e===null}function V0e(e){return e instanceof Date}function DA(e){return typeof e=="bigint"}function Ss(e){return typeof e=="function"}function Ha(e){return typeof e=="object"&&e!==null}function O(e){return Object.freeze(e)}function QS(e){return Qu(e)?e:[e]}function Qu(e){return Array.isArray(e)}function bs(e){return e}var fn=O({is(e){return e.kind==="AlterTableNode"},create(e){return O({kind:"AlterTableNode",table:e})},cloneWithTableProps(e,t){return O({...e,...t})},cloneWithColumnAlteration(e,t){return O({...e,columnAlterations:e.columnAlterations?[...e.columnAlterations,t]:[t]})}}),un=O({is(e){return e.kind==="IdentifierNode"},create(e){return O({kind:"IdentifierNode",name:e})}}),$u=O({is(e){return e.kind==="CreateIndexNode"},create(e){return O({kind:"CreateIndexNode",name:un.create(e)})},cloneWith(e,t){return O({...e,...t})},cloneWithColumns(e,t){return O({...e,columns:[...e.columns||[],...t]})}}),I4=O({is(e){return e.kind==="CreateSchemaNode"},create(e,t){return O({kind:"CreateSchemaNode",schema:un.create(e),...t})},cloneWith(e,t){return O({...e,...t})}}),W0e=["preserve rows","delete rows","drop"],ys=O({is(e){return e.kind==="CreateTableNode"},create(e){return O({kind:"CreateTableNode",table:e,columns:O([])})},cloneWithColumn(e,t){return O({...e,columns:O([...e.columns,t])})},cloneWithConstraint(e,t){return O({...e,constraints:e.constraints?O([...e.constraints,t]):O([t])})},cloneWithFrontModifier(e,t){return O({...e,frontModifiers:e.frontModifiers?O([...e.frontModifiers,t]):O([t])})},cloneWithEndModifier(e,t){return O({...e,endModifiers:e.endModifiers?O([...e.endModifiers,t]):O([t])})},cloneWith(e,t){return O({...e,...t})}}),Gu=O({is(e){return e.kind==="SchemableIdentifierNode"},create(e){return O({kind:"SchemableIdentifierNode",identifier:un.create(e)})},createWithSchema(e,t){return O({kind:"SchemableIdentifierNode",schema:un.create(e),identifier:un.create(t)})}}),$0=O({is(e){return e.kind==="DropIndexNode"},create(e,t){return O({kind:"DropIndexNode",name:Gu.create(e),...t})},cloneWith(e,t){return O({...e,...t})}}),mA=O({is(e){return e.kind==="DropSchemaNode"},create(e,t){return O({kind:"DropSchemaNode",schema:un.create(e),...t})},cloneWith(e,t){return O({...e,...t})}}),gA=O({is(e){return e.kind==="DropTableNode"},create(e,t){return O({kind:"DropTableNode",table:e,...t})},cloneWith(e,t){return O({...e,...t})}}),$a=O({is(e){return e.kind==="AliasNode"},create(e,t){return O({kind:"AliasNode",node:e,alias:t})}}),ta=O({is(e){return e.kind==="TableNode"},create(e){return O({kind:"TableNode",table:Gu.create(e)})},createWithSchema(e,t){return O({kind:"TableNode",table:Gu.createWithSchema(e,t)})}});function vo(e){return Ha(e)&&Ss(e.toOperationNode)}function P4(e){return Ha(e)&&"expressionType"in e&&vo(e)}function U0e(e){return Ha(e)&&"expression"in e&&go(e.alias)&&vo(e)}var Hu=O({is(e){return e.kind==="SelectModifierNode"},create(e,t){return O({kind:"SelectModifierNode",modifier:e,of:t})},createWithExpression(e){return O({kind:"SelectModifierNode",rawModifier:e})}}),Ed=O({is(e){return e.kind==="AndNode"},create(e,t){return O({kind:"AndNode",left:e,right:t})}}),fg=O({is(e){return e.kind==="OrNode"},create(e,t){return O({kind:"OrNode",left:e,right:t})}}),dA=O({is(e){return e.kind==="OnNode"},create(e){return O({kind:"OnNode",on:e})},cloneWithOperation(e,t,n){return O({...e,on:t==="And"?Ed.create(e.on,n):fg.create(e.on,n)})}}),Uf=O({is(e){return e.kind==="JoinNode"},create(e,t){return O({kind:"JoinNode",joinType:e,table:t,on:void 0})},createWithOn(e,t,n){return O({kind:"JoinNode",joinType:e,table:t,on:dA.create(n)})},cloneWithOn(e,t){return O({...e,on:e.on?dA.cloneWithOperation(e.on,"And",t):dA.create(t)})}}),cg=O({is(e){return e.kind==="BinaryOperationNode"},create(e,t,n){return O({kind:"BinaryOperationNode",leftOperand:e,operator:t,rightOperand:n})}}),H0e=["=","==","!=","<>",">",">=","<","<=","in","not in","is","is not","like","not like","match","ilike","not ilike","@>","<@","^@","&&","?","?&","?|","!<","!>","<=>","!~","~","~*","!~*","@@","@@@","!!","<->","regexp","is distinct from","is not distinct from"],$0e=["+","-","*","/","%","^","&","|","#","<<",">>"],L4=["->","->>"],K0e=[...H0e,...$0e,"&&","||"],Y0e=["exists","not exists"],Q0e=["not","-",...Y0e],G0e=[...K0e,...L4,...Q0e,"between","between symmetric"],Od=O({is(e){return e.kind==="OperatorNode"},create(e){return O({kind:"OperatorNode",operator:e})}});function n4(e){return go(e)&&L4.includes(e)}var $n=O({is(e){return e.kind==="ColumnNode"},create(e){return O({kind:"ColumnNode",column:un.create(e)})}}),RA=O({is(e){return e.kind==="SelectAllNode"},create(){return O({kind:"SelectAllNode"})}}),Qf=O({is(e){return e.kind==="ReferenceNode"},create(e,t){return O({kind:"ReferenceNode",table:t,column:e})},createSelectAll(e){return O({kind:"ReferenceNode",table:e,column:RA.create()})}}),X0e=class{#e;get dynamicReference(){return this.#e}get refType(){}constructor(e){this.#e=e}toOperationNode(){return j4(this.#e)}};function B4(e){return Ha(e)&&vo(e)&&go(e.dynamicReference)}var Ku=O({is(e){return e.kind==="OrderByItemNode"},create(e,t){return O({kind:"OrderByItemNode",orderBy:e,direction:t})},cloneWith(e,t){return O({...e,...t})}}),Ar=O({is(e){return e.kind==="RawNode"},create(e,t){return O({kind:"RawNode",sqlFragments:O(e),parameters:O(t)})},createWithSql(e){return Ar.create([e],[])},createWithChild(e){return Ar.create(["",""],[e])},createWithChildren(e){return Ar.create(new Array(e.length+1).fill(""),e)}}),J0e=O({is(e){return e.kind==="CollateNode"},create(e){return O({kind:"CollateNode",collation:un.create(e)})}}),Z0e=class Zm{#e;constructor(t){this.#e=O(t)}desc(){return new Zm({node:Ku.cloneWith(this.#e.node,{direction:Ar.createWithSql("desc")})})}asc(){return new Zm({node:Ku.cloneWith(this.#e.node,{direction:Ar.createWithSql("asc")})})}nullsLast(){return new Zm({node:Ku.cloneWith(this.#e.node,{nulls:"last"})})}nullsFirst(){return new Zm({node:Ku.cloneWith(this.#e.node,{nulls:"first"})})}collate(t){return new Zm({node:Ku.cloneWith(this.#e.node,{collation:J0e.create(t)})})}toOperationNode(){return this.#e.node}},r4=new Set;function pg(e){r4.has(e)||(r4.add(e),console.log(e))}function q4(e){return e==="asc"||e==="desc"}function Hf(e){if(e.length===2)return[hA(e[0],e[1])];if(e.length===1){let[t]=e;return Array.isArray(t)?(pg("orderBy(array) is deprecated, use multiple orderBy calls instead."),t.map(n=>hA(n))):[hA(t)]}throw new Error(`Invalid number of arguments at order by! expected 1-2, received ${e.length}`)}function hA(e,t){let n=ebe(e);if(Ku.is(n)){if(t)throw new Error("Cannot specify direction twice!");return n}return z4(n,t)}function ebe(e){if(ib(e))return Gf(e);if(B4(e))return e.toOperationNode();let[t,n]=e.split(" ");return n?(pg("`orderBy('column asc')` is deprecated. Use `orderBy('column', 'asc')` instead."),z4(Xu(t),n)):Xu(e)}function z4(e,t){if(typeof t=="string"){if(!q4(t))throw new Error(`Invalid order by direction: ${t}`);return Ku.create(e,Ar.createWithSql(t))}if(P4(t))return pg("`orderBy(..., expr)` is deprecated. Use `orderBy(..., 'asc')` or `orderBy(..., (ob) => ...)` instead."),Ku.create(e,t.toOperationNode());let n=Ku.create(e);return t?t(new Z0e({node:n})).toOperationNode():n}var fk=O({is(e){return e.kind==="JSONReferenceNode"},create(e,t){return O({kind:"JSONReferenceNode",reference:e,traversal:t})},cloneWithTraversal(e,t){return O({...e,traversal:t})}}),F4=O({is(e){return e.kind==="JSONOperatorChainNode"},create(e){return O({kind:"JSONOperatorChainNode",operator:e,values:O([])})},cloneWithValue(e,t){return O({...e,values:O([...e.values,t])})}}),K0=O({is(e){return e.kind==="JSONPathNode"},create(e){return O({kind:"JSONPathNode",inOperator:e,pathLegs:O([])})},cloneWithLeg(e,t){return O({...e,pathLegs:O([...e.pathLegs,t])})}});function j4(e){return go(e)?Xu(e):e.toOperationNode()}function X0(e){return Qu(e)?e.map(t=>ws(t)):[ws(e)]}function ws(e){return ib(e)?Gf(e):j4(e)}function tbe(e,t){let n=Xu(e);if(n4(t))return fk.create(n,F4.create(Od.create(t)));let r=t.slice(0,-1);if(n4(r))return fk.create(n,K0.create(Od.create(r)));throw new Error(`Invalid JSON operator: ${t}`)}function Xu(e){if(!e.includes("."))return Qf.create($n.create(e));let t=e.split(".").map(IA);if(t.length===3)return rbe(t);if(t.length===2)return ibe(t);throw new Error(`invalid column reference ${e}`)}function nbe(e){let t=" as ";if(e.includes(t)){let[n,r]=e.split(t).map(IA);return $a.create(Xu(n),un.create(r))}else return Xu(e)}function V4(e){return $n.create(e)}function pk(e){if(e.includes(" ")){let[t,n]=e.split(" ").map(IA);if(!q4(n))throw new Error(`invalid order direction "${n}" next to "${t}"`);return Hf([t,n])[0]}else return V4(e)}function rbe(e){let[t,n,r]=e;return Qf.create($n.create(r),ta.createWithSchema(t,n))}function ibe(e){let[t,n]=e;return Qf.create($n.create(n),ta.create(t))}function IA(e){return e.trim()}var W4=O({is(e){return e.kind==="PrimitiveValueListNode"},create(e){return O({kind:"PrimitiveValueListNode",values:O([...e])})}}),tb=O({is(e){return e.kind==="ValueListNode"},create(e){return O({kind:"ValueListNode",values:O(e)})}}),yo=O({is(e){return e.kind==="ValueNode"},create(e){return O({kind:"ValueNode",value:e})},createImmediate(e){return O({kind:"ValueNode",value:e,immediate:!0})}});function obe(e){return Qu(e)?sbe(e):jr(e)}function jr(e){return ib(e)?Gf(e):yo.create(e)}function PA(e){return xk(e)||hk(e)||AA(e)}function LA(e){if(!PA(e))throw new Error(`unsafe immediate value ${JSON.stringify(e)}`);return yo.createImmediate(e)}function sbe(e){return e.some(ib)?tb.create(e.map(t=>jr(t))):W4.create(e)}var Yu=O({is(e){return e.kind==="ParensNode"},create(e){return O({kind:"ParensNode",node:e})}});function Pi(e){if(e.length===3)return BA(e[0],e[1],e[2]);if(e.length===1)return jr(e[0]);throw new Error(`invalid arguments: ${JSON.stringify(e)}`)}function BA(e,t,n){return abe(t)&&U4(n)?cg.create(ws(e),yA(t),yo.createImmediate(n)):cg.create(ws(e),yA(t),obe(n))}function Bl(e,t,n){return cg.create(ws(e),yA(t),ws(n))}function i4(e,t){return mk(Object.entries(e).filter(([,n])=>!_d(n)).map(([n,r])=>BA(n,U4(r)?"is":"=",r)),t)}function mk(e,t,n=!0){let r=t==="and"?Ed.create:fg.create;if(e.length===0)return cg.create(yo.createImmediate(1),Od.create("="),yo.createImmediate(t==="and"?1:0));let i=o4(e[0]);for(let o=1;o<e.length;++o)i=r(i,o4(e[o]));return e.length>1&&n?Yu.create(i):i}function abe(e){return e==="is"||e==="is not"}function U4(e){return AA(e)||hk(e)}function yA(e){if(go(e)&&G0e.includes(e))return Od.create(e);if(vo(e))return e.toOperationNode();throw new Error(`invalid operator ${JSON.stringify(e)}`)}function o4(e){return vo(e)?e.toOperationNode():e}var dg=O({is(e){return e.kind==="OrderByNode"},create(e){return O({kind:"OrderByNode",items:O([...e])})},cloneWithItems(e,t){return O({...e,items:O([...e.items,...t])})}}),s4=O({is(e){return e.kind==="PartitionByNode"},create(e){return O({kind:"PartitionByNode",items:O(e)})},cloneWithItems(e,t){return O({...e,items:O([...e.items,...t])})}}),vA=O({is(e){return e.kind==="OverNode"},create(){return O({kind:"OverNode"})},cloneWithOrderByItems(e,t){return O({...e,orderBy:e.orderBy?dg.cloneWithItems(e.orderBy,t):dg.create(t)})},cloneWithPartitionByItems(e,t){return O({...e,partitionBy:e.partitionBy?s4.cloneWithItems(e.partitionBy,t):s4.create(t)})}}),gk=O({is(e){return e.kind==="FromNode"},create(e){return O({kind:"FromNode",froms:O(e)})},cloneWithFroms(e,t){return O({...e,froms:O([...e.froms,...t])})}}),a4=O({is(e){return e.kind==="GroupByNode"},create(e){return O({kind:"GroupByNode",items:O(e)})},cloneWithItems(e,t){return O({...e,items:O([...e.items,...t])})}}),l4=O({is(e){return e.kind==="HavingNode"},create(e){return O({kind:"HavingNode",having:e})},cloneWithOperation(e,t,n){return O({...e,having:t==="And"?Ed.create(e.having,n):fg.create(e.having,n)})}}),wi=O({is(e){return e.kind==="InsertQueryNode"},create(e,t,n){return O({kind:"InsertQueryNode",into:e,...t&&{with:t},replace:n})},createWithoutInto(){return O({kind:"InsertQueryNode"})},cloneWith(e,t){return O({...e,...t})}}),H4=O({is(e){return e.kind==="ListNode"},create(e){return O({kind:"ListNode",items:O(e)})}}),ag=O({is(e){return e.kind==="UpdateQueryNode"},create(e,t){return O({kind:"UpdateQueryNode",table:e.length===1?e[0]:H4.create(e),...t&&{with:t}})},createWithoutTable(){return O({kind:"UpdateQueryNode"})},cloneWithFromItems(e,t){return O({...e,from:e.from?gk.cloneWithFroms(e.from,t):gk.create(t)})},cloneWithUpdates(e,t){return O({...e,updates:e.updates?O([...e.updates,...t]):t})},cloneWithLimit(e,t){return O({...e,limit:t})}}),bA=O({is(e){return e.kind==="UsingNode"},create(e){return O({kind:"UsingNode",tables:O(e)})},cloneWithTables(e,t){return O({...e,tables:O([...e.tables,...t])})}}),Y0=O({is(e){return e.kind==="DeleteQueryNode"},create(e,t){return O({kind:"DeleteQueryNode",from:gk.create(e),...t&&{with:t}})},cloneWithOrderByItems:(e,t)=>Ce.cloneWithOrderByItems(e,t),cloneWithoutOrderBy:e=>Ce.cloneWithoutOrderBy(e),cloneWithLimit(e,t){return O({...e,limit:t})},cloneWithoutLimit(e){return O({...e,limit:void 0})},cloneWithUsing(e,t){return O({...e,using:e.using!==void 0?bA.cloneWithTables(e.using,t):bA.create(t)})}}),Fo=O({is(e){return e.kind==="WhereNode"},create(e){return O({kind:"WhereNode",where:e})},cloneWithOperation(e,t,n){return O({...e,where:t==="And"?Ed.create(e.where,n):fg.create(e.where,n)})}}),u4=O({is(e){return e.kind==="ReturningNode"},create(e){return O({kind:"ReturningNode",selections:O(e)})},cloneWithSelections(e,t){return O({...e,selections:e.selections?O([...e.selections,...t]):O(t)})}}),lbe=O({is(e){return e.kind==="ExplainNode"},create(e,t){return O({kind:"ExplainNode",format:e,options:t})}}),$f=O({is(e){return e.kind==="WhenNode"},create(e){return O({kind:"WhenNode",condition:e})},cloneWithResult(e,t){return O({...e,result:t})}}),Ll=O({is(e){return e.kind==="MergeQueryNode"},create(e,t){return O({kind:"MergeQueryNode",into:e,...t&&{with:t}})},cloneWithUsing(e,t){return O({...e,using:t})},cloneWithWhen(e,t){return O({...e,whens:e.whens?O([...e.whens,t]):O([t])})},cloneWithThen(e,t){return O({...e,whens:e.whens?O([...e.whens.slice(0,-1),$f.cloneWithResult(e.whens[e.whens.length-1],t)]):void 0})}}),c4=O({is(e){return e.kind==="OutputNode"},create(e){return O({kind:"OutputNode",selections:O(e)})},cloneWithSelections(e,t){return O({...e,selections:e.selections?O([...e.selections,...t]):O(t)})}}),Ce=O({is(e){return Pn.is(e)||wi.is(e)||ag.is(e)||Y0.is(e)||Ll.is(e)},cloneWithEndModifier(e,t){return O({...e,endModifiers:e.endModifiers?O([...e.endModifiers,t]):O([t])})},cloneWithWhere(e,t){return O({...e,where:e.where?Fo.cloneWithOperation(e.where,"And",t):Fo.create(t)})},cloneWithJoin(e,t){return O({...e,joins:e.joins?O([...e.joins,t]):O([t])})},cloneWithReturning(e,t){return O({...e,returning:e.returning?u4.cloneWithSelections(e.returning,t):u4.create(t)})},cloneWithoutReturning(e){return O({...e,returning:void 0})},cloneWithoutWhere(e){return O({...e,where:void 0})},cloneWithExplain(e,t,n){return O({...e,explain:lbe.create(t,n?.toOperationNode())})},cloneWithTop(e,t){return O({...e,top:t})},cloneWithOutput(e,t){return O({...e,output:e.output?c4.cloneWithSelections(e.output,t):c4.create(t)})},cloneWithOrderByItems(e,t){return O({...e,orderBy:e.orderBy?dg.cloneWithItems(e.orderBy,t):dg.create(t)})},cloneWithoutOrderBy(e){return O({...e,orderBy:void 0})}}),Pn=O({is(e){return e.kind==="SelectQueryNode"},create(e){return O({kind:"SelectQueryNode",...e&&{with:e}})},createFrom(e,t){return O({kind:"SelectQueryNode",from:gk.create(e),...t&&{with:t}})},cloneWithSelections(e,t){return O({...e,selections:e.selections?O([...e.selections,...t]):O(t)})},cloneWithDistinctOn(e,t){return O({...e,distinctOn:e.distinctOn?O([...e.distinctOn,...t]):O(t)})},cloneWithFrontModifier(e,t){return O({...e,frontModifiers:e.frontModifiers?O([...e.frontModifiers,t]):O([t])})},cloneWithOrderByItems:(e,t)=>Ce.cloneWithOrderByItems(e,t),cloneWithGroupByItems(e,t){return O({...e,groupBy:e.groupBy?a4.cloneWithItems(e.groupBy,t):a4.create(t)})},cloneWithLimit(e,t){return O({...e,limit:t})},cloneWithOffset(e,t){return O({...e,offset:t})},cloneWithFetch(e,t){return O({...e,fetch:t})},cloneWithHaving(e,t){return O({...e,having:e.having?l4.cloneWithOperation(e.having,"And",t):l4.create(t)})},cloneWithSetOperations(e,t){return O({...e,setOperations:e.setOperations?O([...e.setOperations,...t]):O([...t])})},cloneWithoutSelections(e){return O({...e,selections:[]})},cloneWithoutLimit(e){return O({...e,limit:void 0})},cloneWithoutOffset(e){return O({...e,offset:void 0})},cloneWithoutOrderBy:e=>Ce.cloneWithoutOrderBy(e),cloneWithoutGroupBy(e){return O({...e,groupBy:void 0})}}),ube=class JS{#e;constructor(t){this.#e=O(t)}on(...t){return new JS({...this.#e,joinNode:Uf.cloneWithOn(this.#e.joinNode,Pi(t))})}onRef(t,n,r){return new JS({...this.#e,joinNode:Uf.cloneWithOn(this.#e.joinNode,Bl(t,n,r))})}onTrue(){return new JS({...this.#e,joinNode:Uf.cloneWithOn(this.#e.joinNode,Ar.createWithSql("true"))})}$call(t){return t(this)}toOperationNode(){return this.#e.joinNode}},cbe=O({is(e){return e.kind==="PartitionByItemNode"},create(e){return O({kind:"PartitionByItemNode",partitionBy:e})}});function dbe(e){return X0(e).map(cbe.create)}var hbe=class ZS{#e;constructor(t){this.#e=O(t)}orderBy(...t){return new ZS({overNode:vA.cloneWithOrderByItems(this.#e.overNode,Hf(t))})}clearOrderBy(){return new ZS({overNode:Ce.cloneWithoutOrderBy(this.#e.overNode)})}partitionBy(t){return new ZS({overNode:vA.cloneWithPartitionByItems(this.#e.overNode,dbe(t))})}$call(t){return t(this)}toOperationNode(){return this.#e.overNode}},Q0=O({is(e){return e.kind==="SelectionNode"},create(e){return O({kind:"SelectionNode",selection:e})},createSelectAll(){return O({kind:"SelectionNode",selection:RA.create()})},createSelectAllFromTable(e){return O({kind:"SelectionNode",selection:Qf.createSelectAll(e)})}});function xs(e){return Ss(e)?xs(e(ks())):Qu(e)?e.map(t=>d4(t)):[d4(e)]}function d4(e){return go(e)?Q0.create(nbe(e)):B4(e)?Q0.create(e.toOperationNode()):Q0.create(rW(e))}function na(e){return e?Array.isArray(e)?e.map(h4):[h4(e)]:[Q0.createSelectAll()]}function h4(e){if(go(e))return Q0.createSelectAllFromTable(xr(e));throw new Error(`invalid value selectAll expression: ${JSON.stringify(e)}`)}var fbe=O({is(e){return e.kind==="ValuesNode"},create(e){return O({kind:"ValuesNode",values:O(e)})}}),pbe=O({is(e){return e.kind==="DefaultInsertValueNode"},create(){return O({kind:"DefaultInsertValueNode"})}});function $4(e){let t=Ss(e)?e(ks()):e,n=Qu(t)?t:O([t]);return mbe(n)}function mbe(e){let t=gbe(e);return[O([...t.keys()].map($n.create)),fbe.create(e.map(n=>ybe(n,t)))]}function gbe(e){let t=new Map;for(let n of e){let r=Object.keys(n);for(let i of r)!t.has(i)&&n[i]!==void 0&&t.set(i,t.size)}return t}function ybe(e,t){let n=Object.keys(e),r=Array.from({length:t.size}),i=!1,o=n.length;for(let s of n){let a=t.get(s);if(_d(a)){o--;continue}let l=e[s];(_d(l)||ib(l))&&(i=!0),r[a]=l}if(o<t.size||i){let s=pbe.create();return tb.create(r.map(a=>_d(a)?s:jr(a)))}return W4.create(r)}var K4=O({is(e){return e.kind==="ColumnUpdateNode"},create(e,t){return O({kind:"ColumnUpdateNode",column:e,value:t})}});function vbe(...e){return e.length===2?[K4.create(ws(e[0]),jr(e[1]))]:qA(e[0])}function qA(e){let t=Ss(e)?e(ks()):e;return Object.entries(t).filter(([n,r])=>r!==void 0).map(([n,r])=>K4.create($n.create(n),jr(r)))}var bbe=O({is(e){return e.kind==="OnDuplicateKeyNode"},create(e){return O({kind:"OnDuplicateKeyNode",updates:e})}}),wbe=class{insertId;numInsertedOrUpdatedRows;constructor(e,t){this.insertId=e,this.numInsertedOrUpdatedRows=t}},nb=class extends Error{node;constructor(e){super("no result"),this.node=e}};function rb(e){return Object.prototype.hasOwnProperty.call(e,"prototype")}var vs=O({is(e){return e.kind==="OnConflictNode"},create(){return O({kind:"OnConflictNode"})},cloneWith(e,t){return O({...e,...t})},cloneWithIndexWhere(e,t){return O({...e,indexWhere:e.indexWhere?Fo.cloneWithOperation(e.indexWhere,"And",t):Fo.create(t)})},cloneWithIndexOrWhere(e,t){return O({...e,indexWhere:e.indexWhere?Fo.cloneWithOperation(e.indexWhere,"Or",t):Fo.create(t)})},cloneWithUpdateWhere(e,t){return O({...e,updateWhere:e.updateWhere?Fo.cloneWithOperation(e.updateWhere,"And",t):Fo.create(t)})},cloneWithUpdateOrWhere(e,t){return O({...e,updateWhere:e.updateWhere?Fo.cloneWithOperation(e.updateWhere,"Or",t):Fo.create(t)})},cloneWithoutIndexWhere(e){return O({...e,indexWhere:void 0})},cloneWithoutUpdateWhere(e){return O({...e,updateWhere:void 0})}}),xbe=class xd{#e;constructor(t){this.#e=O(t)}column(t){let n=$n.create(t);return new xd({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?O([...this.#e.onConflictNode.columns,n]):O([n])})})}columns(t){let n=t.map($n.create);return new xd({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{columns:this.#e.onConflictNode.columns?O([...this.#e.onConflictNode.columns,...n]):O(n)})})}constraint(t){return new xd({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{constraint:un.create(t)})})}expression(t){return new xd({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{indexExpression:t.toOperationNode()})})}where(...t){return new xd({...this.#e,onConflictNode:vs.cloneWithIndexWhere(this.#e.onConflictNode,Pi(t))})}whereRef(t,n,r){return new xd({...this.#e,onConflictNode:vs.cloneWithIndexWhere(this.#e.onConflictNode,Bl(t,n,r))})}clearWhere(){return new xd({...this.#e,onConflictNode:vs.cloneWithoutIndexWhere(this.#e.onConflictNode)})}doNothing(){return new Sbe({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{doNothing:!0})})}doUpdateSet(t){return new kbe({...this.#e,onConflictNode:vs.cloneWith(this.#e.onConflictNode,{updates:qA(t)})})}$call(t){return t(this)}},Sbe=class{#e;constructor(e){this.#e=O(e)}toOperationNode(){return this.#e.onConflictNode}},kbe=class ek{#e;constructor(t){this.#e=O(t)}where(...t){return new ek({...this.#e,onConflictNode:vs.cloneWithUpdateWhere(this.#e.onConflictNode,Pi(t))})}whereRef(t,n,r){return new ek({...this.#e,onConflictNode:vs.cloneWithUpdateWhere(this.#e.onConflictNode,Bl(t,n,r))})}clearWhere(){return new ek({...this.#e,onConflictNode:vs.cloneWithoutUpdateWhere(this.#e.onConflictNode)})}$call(t){return t(this)}toOperationNode(){return this.#e.onConflictNode}},Cbe=O({is(e){return e.kind==="TopNode"},create(e,t){return O({kind:"TopNode",expression:e,modifiers:t})}});function mg(e,t){if(!xk(e)&&!DA(e))throw new Error(`Invalid top expression: ${e}`);if(!_d(t)&&!Nbe(t))throw new Error(`Invalid top modifiers: ${t}`);return Cbe.create(e,t)}function Nbe(e){return e==="percent"||e==="with ties"||e==="percent with ties"}var Gm=O({is(e){return e.kind==="OrActionNode"},create(e){return O({kind:"OrActionNode",action:e})}}),f4=class In{#e;constructor(t){this.#e=O(t)}values(t){let[n,r]=$4(t);return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{columns:n,values:r})})}columns(t){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{columns:O(t.map($n.create))})})}expression(t){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{values:Gf(t)})})}defaultValues(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{defaultValues:!0})})}modifyEnd(t){return new In({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,t.toOperationNode())})}ignore(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("ignore")})})}orIgnore(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("ignore")})})}orAbort(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("abort")})})}orFail(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("fail")})})}orReplace(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("replace")})})}orRollback(){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{orAction:Gm.create("rollback")})})}top(t,n){return new In({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}onConflict(t){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{onConflict:t(new xbe({onConflictNode:vs.create()})).toOperationNode()})})}onDuplicateKeyUpdate(t){return new In({...this.#e,queryNode:wi.cloneWith(this.#e.queryNode,{onDuplicateKey:bbe.create(qA(t))})})}returning(t){return new In({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,xs(t))})}returningAll(){return new In({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,na())})}output(t){return new In({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,xs(t))})}outputAll(t){return new In({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,na(t))})}clearReturning(){return new In({...this.#e,queryNode:Ce.cloneWithoutReturning(this.#e.queryNode)})}$call(t){return t(this)}$if(t,n){return t?n(this):new In({...this.#e})}$castTo(){return new In(this.#e)}$narrowType(){return new In(this.#e)}$assertType(){return new In(this.#e)}withPlugin(t){return new In({...this.#e,executor:this.#e.executor.withPlugin(t)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let t=this.compile(),n=await this.#e.executor.executeQuery(t),{adapter:r}=this.#e.executor,i=t.query;return i.returning&&r.supportsReturning||i.output&&r.supportsOutput?n.rows:[new wbe(n.insertId,n.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[t]=await this.execute();return t}async executeTakeFirstOrThrow(t=nb){let n=await this.executeTakeFirst();if(n===void 0)throw rb(t)?new t(this.toOperationNode()):t(this.toOperationNode());return n}async*stream(t=100){let n=this.compile(),r=this.#e.executor.stream(n,t);for await(let i of r)yield*i.rows}async explain(t,n){return await new In({...this.#e,queryNode:Ce.cloneWithExplain(this.#e.queryNode,t,n)}).execute()}},Mbe=class{numDeletedRows;constructor(e){this.numDeletedRows=e}},zA=O({is(e){return e.kind==="LimitNode"},create(e){return O({kind:"LimitNode",limit:e})}}),_be=class cr{#e;constructor(t){this.#e=O(t)}where(...t){return new cr({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Pi(t))})}whereRef(t,n,r){return new cr({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Bl(t,n,r))})}clearWhere(){return new cr({...this.#e,queryNode:Ce.cloneWithoutWhere(this.#e.queryNode)})}top(t,n){return new cr({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}using(t){return new cr({...this.#e,queryNode:Y0.cloneWithUsing(this.#e.queryNode,ug(t))})}innerJoin(...t){return this.#t("InnerJoin",t)}leftJoin(...t){return this.#t("LeftJoin",t)}rightJoin(...t){return this.#t("RightJoin",t)}fullJoin(...t){return this.#t("FullJoin",t)}#t(t,n){return new cr({...this.#e,queryNode:Ce.cloneWithJoin(this.#e.queryNode,kk(t,n))})}returning(t){return new cr({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,xs(t))})}returningAll(t){return new cr({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,na(t))})}output(t){return new cr({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,xs(t))})}outputAll(t){return new cr({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,na(t))})}clearReturning(){return new cr({...this.#e,queryNode:Ce.cloneWithoutReturning(this.#e.queryNode)})}clearLimit(){return new cr({...this.#e,queryNode:Y0.cloneWithoutLimit(this.#e.queryNode)})}orderBy(...t){return new cr({...this.#e,queryNode:Ce.cloneWithOrderByItems(this.#e.queryNode,Hf(t))})}clearOrderBy(){return new cr({...this.#e,queryNode:Ce.cloneWithoutOrderBy(this.#e.queryNode)})}limit(t){return new cr({...this.#e,queryNode:Y0.cloneWithLimit(this.#e.queryNode,zA.create(jr(t)))})}modifyEnd(t){return new cr({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,t.toOperationNode())})}$call(t){return t(this)}$if(t,n){return t?n(this):new cr({...this.#e})}$castTo(){return new cr(this.#e)}$narrowType(){return new cr(this.#e)}$assertType(){return new cr(this.#e)}withPlugin(t){return new cr({...this.#e,executor:this.#e.executor.withPlugin(t)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let t=this.compile(),n=await this.#e.executor.executeQuery(t),{adapter:r}=this.#e.executor,i=t.query;return i.returning&&r.supportsReturning||i.output&&r.supportsOutput?n.rows:[new Mbe(n.numAffectedRows??BigInt(0))]}async executeTakeFirst(){let[t]=await this.execute();return t}async executeTakeFirstOrThrow(t=nb){let n=await this.executeTakeFirst();if(n===void 0)throw rb(t)?new t(this.toOperationNode()):t(this.toOperationNode());return n}async*stream(t=100){let n=this.compile(),r=this.#e.executor.stream(n,t);for await(let i of r)yield*i.rows}async explain(t,n){return await new cr({...this.#e,queryNode:Ce.cloneWithExplain(this.#e.queryNode,t,n)}).execute()}},Ebe=class{numUpdatedRows;numChangedRows;constructor(e,t){this.numUpdatedRows=e,this.numChangedRows=t}},Y4=class dr{#e;constructor(t){this.#e=O(t)}where(...t){return new dr({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Pi(t))})}whereRef(t,n,r){return new dr({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Bl(t,n,r))})}clearWhere(){return new dr({...this.#e,queryNode:Ce.cloneWithoutWhere(this.#e.queryNode)})}top(t,n){return new dr({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}from(t){return new dr({...this.#e,queryNode:ag.cloneWithFromItems(this.#e.queryNode,ug(t))})}innerJoin(...t){return this.#t("InnerJoin",t)}leftJoin(...t){return this.#t("LeftJoin",t)}rightJoin(...t){return this.#t("RightJoin",t)}fullJoin(...t){return this.#t("FullJoin",t)}#t(t,n){return new dr({...this.#e,queryNode:Ce.cloneWithJoin(this.#e.queryNode,kk(t,n))})}orderBy(...t){return new dr({...this.#e,queryNode:Ce.cloneWithOrderByItems(this.#e.queryNode,Hf(t))})}clearOrderBy(){return new dr({...this.#e,queryNode:Ce.cloneWithoutOrderBy(this.#e.queryNode)})}limit(t){return new dr({...this.#e,queryNode:ag.cloneWithLimit(this.#e.queryNode,zA.create(jr(t)))})}set(...t){return new dr({...this.#e,queryNode:ag.cloneWithUpdates(this.#e.queryNode,vbe(...t))})}returning(t){return new dr({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,xs(t))})}returningAll(t){return new dr({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,na(t))})}output(t){return new dr({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,xs(t))})}outputAll(t){return new dr({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,na(t))})}modifyEnd(t){return new dr({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,t.toOperationNode())})}clearReturning(){return new dr({...this.#e,queryNode:Ce.cloneWithoutReturning(this.#e.queryNode)})}$call(t){return t(this)}$if(t,n){return t?n(this):new dr({...this.#e})}$castTo(){return new dr(this.#e)}$narrowType(){return new dr(this.#e)}$assertType(){return new dr(this.#e)}withPlugin(t){return new dr({...this.#e,executor:this.#e.executor.withPlugin(t)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let t=this.compile(),n=await this.#e.executor.executeQuery(t),{adapter:r}=this.#e.executor,i=t.query;return i.returning&&r.supportsReturning||i.output&&r.supportsOutput?n.rows:[new Ebe(n.numAffectedRows??BigInt(0),n.numChangedRows)]}async executeTakeFirst(){let[t]=await this.execute();return t}async executeTakeFirstOrThrow(t=nb){let n=await this.executeTakeFirst();if(n===void 0)throw rb(t)?new t(this.toOperationNode()):t(this.toOperationNode());return n}async*stream(t=100){let n=this.compile(),r=this.#e.executor.stream(n,t);for await(let i of r)yield*i.rows}async explain(t,n){return await new dr({...this.#e,queryNode:Ce.cloneWithExplain(this.#e.queryNode,t,n)}).execute()}},p4=O({is(e){return e.kind==="CommonTableExpressionNameNode"},create(e,t){return O({kind:"CommonTableExpressionNameNode",table:ta.create(e),columns:t?O(t.map($n.create)):void 0})}}),yk=O({is(e){return e.kind==="CommonTableExpressionNode"},create(e,t){return O({kind:"CommonTableExpressionNode",name:e,expression:t})},cloneWith(e,t){return O({...e,...t})}}),Obe=class wA{#e;constructor(t){this.#e=O(t)}materialized(){return new wA({...this.#e,node:yk.cloneWith(this.#e.node,{materialized:!0})})}notMaterialized(){return new wA({...this.#e,node:yk.cloneWith(this.#e.node,{materialized:!1})})}toOperationNode(){return this.#e.node}};function m4(e,t){let n=t(Wbe()).toOperationNode();return Ss(e)?e(Tbe(n)).toOperationNode():yk.create(Q4(e),n)}function Tbe(e){return t=>new Obe({node:yk.create(Q4(t),e)})}function Q4(e){if(e.includes("(")){let t=e.split(/[\(\)]/),n=t[0],r=t[1].split(",").map(i=>i.trim());return p4.create(n,r)}else return p4.create(e)}var GS=O({is(e){return e.kind==="WithNode"},create(e,t){return O({kind:"WithNode",expressions:O([e]),...t})},cloneWithExpression(e,t){return O({...e,expressions:O([...e.expressions,t])})}}),g4=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];function Abe(e){let t="";for(let n=0;n<e;++n)t+=Dbe();return t}function Dbe(){return g4[~~(Math.random()*g4.length)]}function pn(){return new Rbe}var Rbe=class{#e;get queryId(){return this.#e===void 0&&(this.#e=Abe(8)),this.#e}},FA=class{nodeStack=[];#e=O({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),RenameConstraintNode:this.transformRenameConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),RefreshMaterializedViewNode:this.transformRefreshMaterializedView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this),OrActionNode:this.transformOrAction.bind(this),CollateNode:this.transformCollate.bind(this)});transformNode(e,t){if(!e)return e;this.nodeStack.push(e);let n=this.transformNodeImpl(e,t);return this.nodeStack.pop(),O(n)}transformNodeImpl(e,t){return this.#e[e.kind](e,t)}transformNodeList(e,t){return e&&O(e.map(n=>this.transformNode(n,t)))}transformSelectQuery(e,t){return{kind:"SelectQueryNode",from:this.transformNode(e.from,t),selections:this.transformNodeList(e.selections,t),distinctOn:this.transformNodeList(e.distinctOn,t),joins:this.transformNodeList(e.joins,t),groupBy:this.transformNode(e.groupBy,t),orderBy:this.transformNode(e.orderBy,t),where:this.transformNode(e.where,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),limit:this.transformNode(e.limit,t),offset:this.transformNode(e.offset,t),with:this.transformNode(e.with,t),having:this.transformNode(e.having,t),explain:this.transformNode(e.explain,t),setOperations:this.transformNodeList(e.setOperations,t),fetch:this.transformNode(e.fetch,t),top:this.transformNode(e.top,t)}}transformSelection(e,t){return{kind:"SelectionNode",selection:this.transformNode(e.selection,t)}}transformColumn(e,t){return{kind:"ColumnNode",column:this.transformNode(e.column,t)}}transformAlias(e,t){return{kind:"AliasNode",node:this.transformNode(e.node,t),alias:this.transformNode(e.alias,t)}}transformTable(e,t){return{kind:"TableNode",table:this.transformNode(e.table,t)}}transformFrom(e,t){return{kind:"FromNode",froms:this.transformNodeList(e.froms,t)}}transformReference(e,t){return{kind:"ReferenceNode",column:this.transformNode(e.column,t),table:this.transformNode(e.table,t)}}transformAnd(e,t){return{kind:"AndNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformOr(e,t){return{kind:"OrNode",left:this.transformNode(e.left,t),right:this.transformNode(e.right,t)}}transformValueList(e,t){return{kind:"ValueListNode",values:this.transformNodeList(e.values,t)}}transformParens(e,t){return{kind:"ParensNode",node:this.transformNode(e.node,t)}}transformJoin(e,t){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table,t),on:this.transformNode(e.on,t)}}transformRaw(e,t){return{kind:"RawNode",sqlFragments:O([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters,t)}}transformWhere(e,t){return{kind:"WhereNode",where:this.transformNode(e.where,t)}}transformInsertQuery(e,t){return{kind:"InsertQueryNode",into:this.transformNode(e.into,t),columns:this.transformNodeList(e.columns,t),values:this.transformNode(e.values,t),returning:this.transformNode(e.returning,t),onConflict:this.transformNode(e.onConflict,t),onDuplicateKey:this.transformNode(e.onDuplicateKey,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),ignore:e.ignore,orAction:this.transformNode(e.orAction,t),replace:e.replace,explain:this.transformNode(e.explain,t),defaultValues:e.defaultValues,top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformValues(e,t){return{kind:"ValuesNode",values:this.transformNodeList(e.values,t)}}transformDeleteQuery(e,t){return{kind:"DeleteQueryNode",from:this.transformNode(e.from,t),using:this.transformNode(e.using,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),orderBy:this.transformNode(e.orderBy,t),limit:this.transformNode(e.limit,t),explain:this.transformNode(e.explain,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t)}}transformReturning(e,t){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections,t)}}transformCreateTable(e,t){return{kind:"CreateTableNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),constraints:this.transformNodeList(e.constraints,t),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),selectQuery:this.transformNode(e.selectQuery,t)}}transformColumnDefinition(e,t){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),references:this.transformNode(e.references,t),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo,t),check:this.transformNode(e.check,t),generated:this.transformNode(e.generated,t),frontModifiers:this.transformNodeList(e.frontModifiers,t),endModifiers:this.transformNodeList(e.endModifiers,t),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e,t){return{kind:"AddColumnNode",column:this.transformNode(e.column,t)}}transformDropTable(e,t){return{kind:"DropTableNode",table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e,t){return{kind:"OrderByNode",items:this.transformNodeList(e.items,t)}}transformOrderByItem(e,t){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy,t),direction:this.transformNode(e.direction,t),collation:this.transformNode(e.collation,t),nulls:e.nulls}}transformGroupBy(e,t){return{kind:"GroupByNode",items:this.transformNodeList(e.items,t)}}transformGroupByItem(e,t){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy,t)}}transformUpdateQuery(e,t){return{kind:"UpdateQueryNode",table:this.transformNode(e.table,t),from:this.transformNode(e.from,t),joins:this.transformNodeList(e.joins,t),where:this.transformNode(e.where,t),updates:this.transformNodeList(e.updates,t),returning:this.transformNode(e.returning,t),endModifiers:this.transformNodeList(e.endModifiers,t),with:this.transformNode(e.with,t),explain:this.transformNode(e.explain,t),limit:this.transformNode(e.limit,t),top:this.transformNode(e.top,t),output:this.transformNode(e.output,t),orderBy:this.transformNode(e.orderBy,t)}}transformColumnUpdate(e,t){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column,t),value:this.transformNode(e.value,t)}}transformLimit(e,t){return{kind:"LimitNode",limit:this.transformNode(e.limit,t)}}transformOffset(e,t){return{kind:"OffsetNode",offset:this.transformNode(e.offset,t)}}transformOnConflict(e,t){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns,t),constraint:this.transformNode(e.constraint,t),indexExpression:this.transformNode(e.indexExpression,t),indexWhere:this.transformNode(e.indexWhere,t),updates:this.transformNodeList(e.updates,t),updateWhere:this.transformNode(e.updateWhere,t),doNothing:e.doNothing}}transformOnDuplicateKey(e,t){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates,t)}}transformCreateIndex(e,t){return{kind:"CreateIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists,where:this.transformNode(e.where,t),nullsNotDistinct:e.nullsNotDistinct}}transformList(e,t){return{kind:"ListNode",items:this.transformNodeList(e.items,t)}}transformDropIndex(e,t){return{kind:"DropIndexNode",name:this.transformNode(e.name,t),table:this.transformNode(e.table,t),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e,t){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformUniqueConstraint(e,t){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns,t),name:this.transformNode(e.name,t),nullsNotDistinct:e.nullsNotDistinct,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformForeignKeyConstraint(e,t){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns,t),references:this.transformNode(e.references,t),name:this.transformNode(e.name,t),onDelete:e.onDelete,onUpdate:e.onUpdate,deferrable:e.deferrable,initiallyDeferred:e.initiallyDeferred}}transformSetOperation(e,t){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression,t),all:e.all}}transformReferences(e,t){return{kind:"ReferencesNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e,t){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression,t),name:this.transformNode(e.name,t)}}transformWith(e,t){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions,t),recursive:e.recursive}}transformCommonTableExpression(e,t){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name,t),materialized:e.materialized,expression:this.transformNode(e.expression,t)}}transformCommonTableExpressionName(e,t){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table,t),columns:this.transformNodeList(e.columns,t)}}transformHaving(e,t){return{kind:"HavingNode",having:this.transformNode(e.having,t)}}transformCreateSchema(e,t){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema,t),ifNotExists:e.ifNotExists}}transformDropSchema(e,t){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema,t),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e,t){return{kind:"AlterTableNode",table:this.transformNode(e.table,t),renameTo:this.transformNode(e.renameTo,t),setSchema:this.transformNode(e.setSchema,t),columnAlterations:this.transformNodeList(e.columnAlterations,t),addConstraint:this.transformNode(e.addConstraint,t),dropConstraint:this.transformNode(e.dropConstraint,t),renameConstraint:this.transformNode(e.renameConstraint,t),addIndex:this.transformNode(e.addIndex,t),dropIndex:this.transformNode(e.dropIndex,t)}}transformDropColumn(e,t){return{kind:"DropColumnNode",column:this.transformNode(e.column,t)}}transformRenameColumn(e,t){return{kind:"RenameColumnNode",column:this.transformNode(e.column,t),renameTo:this.transformNode(e.renameTo,t)}}transformAlterColumn(e,t){return{kind:"AlterColumnNode",column:this.transformNode(e.column,t),dataType:this.transformNode(e.dataType,t),dataTypeExpression:this.transformNode(e.dataTypeExpression,t),setDefault:this.transformNode(e.setDefault,t),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e,t){return{kind:"ModifyColumnNode",column:this.transformNode(e.column,t)}}transformAddConstraint(e,t){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint,t)}}transformDropConstraint(e,t){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName,t),ifExists:e.ifExists,modifier:e.modifier}}transformRenameConstraint(e,t){return{kind:"RenameConstraintNode",oldName:this.transformNode(e.oldName,t),newName:this.transformNode(e.newName,t)}}transformCreateView(e,t){return{kind:"CreateViewNode",name:this.transformNode(e.name,t),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns,t),as:this.transformNode(e.as,t)}}transformRefreshMaterializedView(e,t){return{kind:"RefreshMaterializedViewNode",name:this.transformNode(e.name,t),concurrently:e.concurrently,withNoData:e.withNoData}}transformDropView(e,t){return{kind:"DropViewNode",name:this.transformNode(e.name,t),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e,t){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression,t)}}transformDefaultValue(e,t){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue,t)}}transformOn(e,t){return{kind:"OnNode",on:this.transformNode(e.on,t)}}transformSelectModifier(e,t){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier,t),of:this.transformNodeList(e.of,t)}}transformCreateType(e,t){return{kind:"CreateTypeNode",name:this.transformNode(e.name,t),enum:this.transformNode(e.enum,t)}}transformDropType(e,t){return{kind:"DropTypeNode",name:this.transformNode(e.name,t),ifExists:e.ifExists}}transformExplain(e,t){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options,t)}}transformSchemableIdentifier(e,t){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema,t),identifier:this.transformNode(e.identifier,t)}}transformAggregateFunction(e,t){return{kind:"AggregateFunctionNode",func:e.func,aggregated:this.transformNodeList(e.aggregated,t),distinct:e.distinct,orderBy:this.transformNode(e.orderBy,t),withinGroup:this.transformNode(e.withinGroup,t),filter:this.transformNode(e.filter,t),over:this.transformNode(e.over,t)}}transformOver(e,t){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy,t),partitionBy:this.transformNode(e.partitionBy,t)}}transformPartitionBy(e,t){return{kind:"PartitionByNode",items:this.transformNodeList(e.items,t)}}transformPartitionByItem(e,t){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy,t)}}transformBinaryOperation(e,t){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand,t),operator:this.transformNode(e.operator,t),rightOperand:this.transformNode(e.rightOperand,t)}}transformUnaryOperation(e,t){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator,t),operand:this.transformNode(e.operand,t)}}transformUsing(e,t){return{kind:"UsingNode",tables:this.transformNodeList(e.tables,t)}}transformFunction(e,t){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments,t)}}transformCase(e,t){return{kind:"CaseNode",value:this.transformNode(e.value,t),when:this.transformNodeList(e.when,t),else:this.transformNode(e.else,t),isStatement:e.isStatement}}transformWhen(e,t){return{kind:"WhenNode",condition:this.transformNode(e.condition,t),result:this.transformNode(e.result,t)}}transformJSONReference(e,t){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference,t),traversal:this.transformNode(e.traversal,t)}}transformJSONPath(e,t){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator,t),pathLegs:this.transformNodeList(e.pathLegs,t)}}transformJSONPathLeg(e,t){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e,t){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator,t),values:this.transformNodeList(e.values,t)}}transformTuple(e,t){return{kind:"TupleNode",values:this.transformNodeList(e.values,t)}}transformMergeQuery(e,t){return{kind:"MergeQueryNode",into:this.transformNode(e.into,t),using:this.transformNode(e.using,t),whens:this.transformNodeList(e.whens,t),with:this.transformNode(e.with,t),top:this.transformNode(e.top,t),endModifiers:this.transformNodeList(e.endModifiers,t),output:this.transformNode(e.output,t),returning:this.transformNode(e.returning,t)}}transformMatched(e,t){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e,t){return{kind:"AddIndexNode",name:this.transformNode(e.name,t),columns:this.transformNodeList(e.columns,t),unique:e.unique,using:this.transformNode(e.using,t),ifNotExists:e.ifNotExists}}transformCast(e,t){return{kind:"CastNode",expression:this.transformNode(e.expression,t),dataType:this.transformNode(e.dataType,t)}}transformFetch(e,t){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount,t),modifier:e.modifier}}transformTop(e,t){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e,t){return{kind:"OutputNode",selections:this.transformNodeList(e.selections,t)}}transformDataType(e,t){return e}transformSelectAll(e,t){return e}transformIdentifier(e,t){return e}transformValue(e,t){return e}transformPrimitiveValueList(e,t){return e}transformOperator(e,t){return e}transformDefaultInsertValue(e,t){return e}transformOrAction(e,t){return e}transformCollate(e,t){return e}},Ibe=O({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,RefreshMaterializedViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0}),Pbe={json_agg:!0,to_json:!0},Lbe=class extends FA{#e;#t=new Set;#n=new Set;constructor(e){super(),this.#e=e}transformNodeImpl(e,t){if(!this.#i(e))return super.transformNodeImpl(e,t);let n=this.#a(e);for(let o of n)this.#n.add(o);let r=this.#s(e);for(let o of r)this.#t.add(o);let i=super.transformNodeImpl(e,t);for(let o of r)this.#t.delete(o);for(let o of n)this.#n.delete(o);return i}transformSchemableIdentifier(e,t){let n=super.transformSchemableIdentifier(e,t);return n.schema||!this.#t.has(e.identifier.name)?n:{...n,schema:un.create(this.#e)}}transformReferences(e,t){let n=super.transformReferences(e,t);return n.table.table.schema?n:{...n,table:ta.createWithSchema(this.#e,n.table.table.identifier.name)}}transformAggregateFunction(e,t){return{...super.transformAggregateFunction({...e,aggregated:[]},t),aggregated:this.#r(e,t,"aggregated")}}transformFunction(e,t){return{...super.transformFunction({...e,arguments:[]},t),arguments:this.#r(e,t,"arguments")}}transformSelectModifier(e,t){return{...super.transformSelectModifier({...e,of:void 0},t),of:e.of?.map(n=>ta.is(n)&&!n.table.schema?{...n,table:this.transformIdentifier(n.table.identifier,t)}:this.transformNode(n,t))}}#r(e,t,n){return Pbe[e.func]?e[n].map(r=>!ta.is(r)||r.table.schema?this.transformNode(r,t):{...r,table:this.transformIdentifier(r.table.identifier,t)}):this.transformNodeList(e[n],t)}#i(e){return e.kind in Ibe}#s(e){let t=new Set;if("name"in e&&e.name&&Gu.is(e.name)&&this.#l(e.name,t),"from"in e&&e.from)for(let n of e.from.froms)this.#o(n,t);if("into"in e&&e.into&&this.#o(e.into,t),"table"in e&&e.table&&this.#o(e.table,t),"joins"in e&&e.joins)for(let n of e.joins)this.#o(n.table,t);return"using"in e&&e.using&&(Uf.is(e.using)?this.#o(e.using.table,t):this.#o(e.using,t)),t}#a(e){let t=new Set;return"with"in e&&e.with&&this.#u(e.with,t),t}#o(e,t){if(ta.is(e))return this.#l(e.table,t);if($a.is(e)&&ta.is(e.node))return this.#l(e.node.table,t);if(H4.is(e)){for(let n of e.items)this.#o(n,t);return}if(bA.is(e)){for(let n of e.tables)this.#o(n,t);return}}#l(e,t){let n=e.identifier.name;!this.#t.has(n)&&!this.#n.has(n)&&t.add(n)}#u(e,t){for(let n of e.expressions){let r=n.name.table.table.identifier.name;this.#n.has(r)||t.add(r)}}},gg=class{#e;constructor(e){this.#e=new Lbe(e)}transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}async transformResult(e){return e.result}},Bbe=O({is(e){return e.kind==="MatchedNode"},create(e,t=!1){return O({kind:"MatchedNode",not:e,bySource:t})}});function y4(e,t,n){return $f.create(mk([Bbe.create(!e.isMatched,e.bySource),...t&&t.length>0?[t.length===3&&n?Bl(t[0],t[1],t[2]):Pi(t)]:[]],"and",!1))}function G0(e){return go(e)?Ar.create([e],[]):vo(e)?e.toOperationNode():e}var v4=class{#e;#t;#n;constructor(){this.#e=new Promise((e,t)=>{this.#n=t,this.#t=e})}get promise(){return this.#e}resolve=e=>{this.#t&&this.#t(e)};reject=e=>{this.#n&&this.#n(e)}};async function G4(e){let t=new v4,n=new v4;return e.provideConnection(async r=>(t.resolve(r),await n.promise)).catch(r=>t.reject(r)),O({connection:await t.promise,release:n.resolve})}var qbe=O([]),X4=class{#e;constructor(e=qbe){this.#e=e}get plugins(){return this.#e}transformQuery(e,t){for(let n of this.#e){let r=n.transformQuery({node:e,queryId:t});if(r.kind===e.kind)e=r;else throw new Error(["KyselyPlugin.transformQuery must return a node","of the same kind that was given to it.",`The plugin was given a ${e.kind}`,`but it returned a ${r.kind}`].join(" "))}return e}async executeQuery(e){return await this.provideConnection(async t=>{let n=await t.executeQuery(e);return"numUpdatedOrDeletedRows"in n&&pg("kysely:warning: outdated driver/plugin detected! `QueryResult.numUpdatedOrDeletedRows` has been replaced with `QueryResult.numAffectedRows`."),await this.#t(n,e.queryId)})}async*stream(e,t){let{connection:n,release:r}=await G4(this);try{for await(let i of n.streamQuery(e,t))yield await this.#t(i,e.queryId)}finally{r()}}async#t(e,t){for(let n of this.#e)e=await n.transformResult({result:e,queryId:t});return e}},zbe=class V0 extends X4{get adapter(){throw new Error("this query cannot be compiled to SQL")}compileQuery(){throw new Error("this query cannot be compiled to SQL")}provideConnection(){throw new Error("this query cannot be executed")}withConnectionProvider(){throw new Error("this query cannot have a connection provider")}withPlugin(t){return new V0([...this.plugins,t])}withPlugins(t){return new V0([...this.plugins,...t])}withPluginAtFront(t){return new V0([t,...this.plugins])}withoutPlugins(){return new V0([])}},Sk=new zbe,Fbe=class{numChangedRows;constructor(e){this.numChangedRows=e}},jbe=class Bf{#e;constructor(t){this.#e=O(t)}modifyEnd(t){return new Bf({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,t.toOperationNode())})}top(t,n){return new Bf({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}using(...t){return new lg({...this.#e,queryNode:Ll.cloneWithUsing(this.#e.queryNode,kk("Using",t))})}returning(t){return new Bf({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,xs(t))})}returningAll(t){return new Bf({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,na(t))})}output(t){return new Bf({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,xs(t))})}outputAll(t){return new Bf({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,na(t))})}},lg=class Sd{#e;constructor(t){this.#e=O(t)}modifyEnd(t){return new Sd({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,t.toOperationNode())})}top(t,n){return new Sd({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}whenMatched(){return this.#t([])}whenMatchedAnd(...t){return this.#t(t)}whenMatchedAndRef(t,n,r){return this.#t([t,n,r],!0)}#t(t,n){return new b4({...this.#e,queryNode:Ll.cloneWithWhen(this.#e.queryNode,y4({isMatched:!0},t,n))})}whenNotMatched(){return this.#n([])}whenNotMatchedAnd(...t){return this.#n(t)}whenNotMatchedAndRef(t,n,r){return this.#n([t,n,r],!0)}whenNotMatchedBySource(){return this.#n([],!1,!0)}whenNotMatchedBySourceAnd(...t){return this.#n(t,!1,!0)}whenNotMatchedBySourceAndRef(t,n,r){return this.#n([t,n,r],!0,!0)}returning(t){return new Sd({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,xs(t))})}returningAll(t){return new Sd({...this.#e,queryNode:Ce.cloneWithReturning(this.#e.queryNode,na(t))})}output(t){return new Sd({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,xs(t))})}outputAll(t){return new Sd({...this.#e,queryNode:Ce.cloneWithOutput(this.#e.queryNode,na(t))})}#n(t,n=!1,r=!1){let i={...this.#e,queryNode:Ll.cloneWithWhen(this.#e.queryNode,y4({isMatched:!1,bySource:r},t,n))},o=r?b4:Vbe;return new o(i)}$call(t){return t(this)}$if(t,n){return t?n(this):new Sd({...this.#e})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let t=this.compile(),n=await this.#e.executor.executeQuery(t),{adapter:r}=this.#e.executor,i=t.query;return i.returning&&r.supportsReturning||i.output&&r.supportsOutput?n.rows:[new Fbe(n.numAffectedRows)]}async executeTakeFirst(){let[t]=await this.execute();return t}async executeTakeFirstOrThrow(t=nb){let n=await this.executeTakeFirst();if(n===void 0)throw rb(t)?new t(this.toOperationNode()):t(this.toOperationNode());return n}},b4=class{#e;constructor(e){this.#e=O(e)}thenDelete(){return new lg({...this.#e,queryNode:Ll.cloneWithThen(this.#e.queryNode,G0("delete"))})}thenDoNothing(){return new lg({...this.#e,queryNode:Ll.cloneWithThen(this.#e.queryNode,G0("do nothing"))})}thenUpdate(e){return new lg({...this.#e,queryNode:Ll.cloneWithThen(this.#e.queryNode,G0(e(new Y4({queryId:this.#e.queryId,executor:Sk,queryNode:ag.createWithoutTable()}))))})}thenUpdateSet(...e){return this.thenUpdate(t=>t.set(...e))}},Vbe=class{#e;constructor(e){this.#e=O(e)}thenDoNothing(){return new lg({...this.#e,queryNode:Ll.cloneWithThen(this.#e.queryNode,G0("do nothing"))})}thenInsertValues(e){let[t,n]=$4(e);return new lg({...this.#e,queryNode:Ll.cloneWithThen(this.#e.queryNode,G0(wi.cloneWith(wi.createWithoutInto(),{columns:t,values:n})))})}},J4=class eg{#e;constructor(t){this.#e=O(t)}selectFrom(t){return CA({queryId:pn(),executor:this.#e.executor,queryNode:Pn.createFrom(ug(t),this.#e.withNode)})}selectNoFrom(t){return CA({queryId:pn(),executor:this.#e.executor,queryNode:Pn.cloneWithSelections(Pn.create(this.#e.withNode),xs(t))})}insertInto(t){return new f4({queryId:pn(),executor:this.#e.executor,queryNode:wi.create(xr(t),this.#e.withNode)})}replaceInto(t){return new f4({queryId:pn(),executor:this.#e.executor,queryNode:wi.create(xr(t),this.#e.withNode,!0)})}deleteFrom(t){return new _be({queryId:pn(),executor:this.#e.executor,queryNode:Y0.create(ug(t),this.#e.withNode)})}updateTable(t){return new Y4({queryId:pn(),executor:this.#e.executor,queryNode:ag.create(ug(t),this.#e.withNode)})}mergeInto(t){return new jbe({queryId:pn(),executor:this.#e.executor,queryNode:Ll.create(iW(t),this.#e.withNode)})}with(t,n){let r=m4(t,n);return new eg({...this.#e,withNode:this.#e.withNode?GS.cloneWithExpression(this.#e.withNode,r):GS.create(r)})}withRecursive(t,n){let r=m4(t,n);return new eg({...this.#e,withNode:this.#e.withNode?GS.cloneWithExpression(this.#e.withNode,r):GS.create(r,{recursive:!0})})}withPlugin(t){return new eg({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new eg({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new eg({...this.#e,executor:this.#e.executor.withPluginAtFront(new gg(t))})}};function Wbe(){return new J4({executor:Sk})}function Ube(e,t){return new ube({joinNode:Uf.create(e,J0(t))})}function Hbe(){return new hbe({overNode:vA.create()})}function kk(e,t){if(t.length===3)return Kbe(e,t[0],t[1],t[2]);if(t.length===2)return $be(e,t[0],t[1]);if(t.length===1)return Ybe(e,t[0]);throw new Error("not implemented")}function $be(e,t,n){return n(Ube(e,t)).toOperationNode()}function Kbe(e,t,n,r){return Uf.createWithOn(e,J0(t),Bl(n,"=",r))}function Ybe(e,t){return Uf.create(e,J0(t))}var Qbe=O({is(e){return e.kind==="OffsetNode"},create(e){return O({kind:"OffsetNode",offset:e})}}),Gbe=O({is(e){return e.kind==="GroupByItemNode"},create(e){return O({kind:"GroupByItemNode",groupBy:e})}});function Xbe(e){return e=Ss(e)?e(ks()):e,X0(e).map(Gbe.create)}var Z4=O({is(e){return e.kind==="SetOperationNode"},create(e,t,n){return O({kind:"SetOperationNode",operator:e,expression:t,all:n})}});function Xm(e,t,n){return Ss(t)&&(t=t(VA())),Qu(t)||(t=[t]),t.map(r=>Z4.create(e,Gf(r),n))}var wn=class xA{#e;constructor(t){this.#e=t}get expressionType(){}as(t){return new jA(this,t)}or(...t){return new Jbe(fg.create(this.#e,Pi(t)))}and(...t){return new Zbe(Ed.create(this.#e,Pi(t)))}$castTo(){return new xA(this.#e)}$notNull(){return new xA(this.#e)}toOperationNode(){return this.#e}},jA=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return $a.create(this.#e.toOperationNode(),vo(this.#t)?this.#t.toOperationNode():un.create(this.#t))}},Jbe=class SA{#e;constructor(t){this.#e=t}get expressionType(){}as(t){return new jA(this,t)}or(...t){return new SA(fg.create(this.#e,Pi(t)))}$castTo(){return new SA(this.#e)}toOperationNode(){return Yu.create(this.#e)}},Zbe=class kA{#e;constructor(t){this.#e=t}get expressionType(){}as(t){return new jA(this,t)}and(...t){return new kA(Ed.create(this.#e,Pi(t)))}$castTo(){return new kA(this.#e)}toOperationNode(){return Yu.create(this.#e)}},ewe=O({is(e){return e.kind==="FetchNode"},create(e,t){return{kind:"FetchNode",rowCount:yo.create(e),modifier:t}}});function twe(e,t){if(!xk(e)&&!DA(e))throw new Error(`Invalid fetch row count: ${e}`);if(!nwe(t))throw new Error(`Invalid fetch modifier: ${t}`);return ewe.create(e,t)}function nwe(e){return e==="only"||e==="with ties"}var rwe=class wt{#e;constructor(t){this.#e=O(t)}get expressionType(){}get isSelectQueryBuilder(){return!0}where(...t){return new wt({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Pi(t))})}whereRef(t,n,r){return new wt({...this.#e,queryNode:Ce.cloneWithWhere(this.#e.queryNode,Bl(t,n,r))})}having(...t){return new wt({...this.#e,queryNode:Pn.cloneWithHaving(this.#e.queryNode,Pi(t))})}havingRef(t,n,r){return new wt({...this.#e,queryNode:Pn.cloneWithHaving(this.#e.queryNode,Bl(t,n,r))})}select(t){return new wt({...this.#e,queryNode:Pn.cloneWithSelections(this.#e.queryNode,xs(t))})}distinctOn(t){return new wt({...this.#e,queryNode:Pn.cloneWithDistinctOn(this.#e.queryNode,X0(t))})}modifyFront(t){return new wt({...this.#e,queryNode:Pn.cloneWithFrontModifier(this.#e.queryNode,Hu.createWithExpression(t.toOperationNode()))})}modifyEnd(t){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.createWithExpression(t.toOperationNode()))})}distinct(){return new wt({...this.#e,queryNode:Pn.cloneWithFrontModifier(this.#e.queryNode,Hu.create("Distinct"))})}forUpdate(t){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("ForUpdate",t?QS(t).map(xr):void 0))})}forShare(t){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("ForShare",t?QS(t).map(xr):void 0))})}forKeyShare(t){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("ForKeyShare",t?QS(t).map(xr):void 0))})}forNoKeyUpdate(t){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("ForNoKeyUpdate",t?QS(t).map(xr):void 0))})}skipLocked(){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("SkipLocked"))})}noWait(){return new wt({...this.#e,queryNode:Ce.cloneWithEndModifier(this.#e.queryNode,Hu.create("NoWait"))})}selectAll(t){return new wt({...this.#e,queryNode:Pn.cloneWithSelections(this.#e.queryNode,na(t))})}innerJoin(...t){return this.#t("InnerJoin",t)}leftJoin(...t){return this.#t("LeftJoin",t)}rightJoin(...t){return this.#t("RightJoin",t)}fullJoin(...t){return this.#t("FullJoin",t)}crossJoin(...t){return this.#t("CrossJoin",t)}innerJoinLateral(...t){return this.#t("LateralInnerJoin",t)}leftJoinLateral(...t){return this.#t("LateralLeftJoin",t)}crossJoinLateral(...t){return this.#t("LateralCrossJoin",t)}crossApply(...t){return this.#t("CrossApply",t)}outerApply(...t){return this.#t("OuterApply",t)}#t(t,n){return new wt({...this.#e,queryNode:Ce.cloneWithJoin(this.#e.queryNode,kk(t,n))})}orderBy(...t){return new wt({...this.#e,queryNode:Ce.cloneWithOrderByItems(this.#e.queryNode,Hf(t))})}groupBy(t){return new wt({...this.#e,queryNode:Pn.cloneWithGroupByItems(this.#e.queryNode,Xbe(t))})}limit(t){return new wt({...this.#e,queryNode:Pn.cloneWithLimit(this.#e.queryNode,zA.create(jr(t)))})}offset(t){return new wt({...this.#e,queryNode:Pn.cloneWithOffset(this.#e.queryNode,Qbe.create(jr(t)))})}fetch(t,n="only"){return new wt({...this.#e,queryNode:Pn.cloneWithFetch(this.#e.queryNode,twe(t,n))})}top(t,n){return new wt({...this.#e,queryNode:Ce.cloneWithTop(this.#e.queryNode,mg(t,n))})}union(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("union",t,!1))})}unionAll(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("union",t,!0))})}intersect(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("intersect",t,!1))})}intersectAll(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("intersect",t,!0))})}except(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("except",t,!1))})}exceptAll(t){return new wt({...this.#e,queryNode:Pn.cloneWithSetOperations(this.#e.queryNode,Xm("except",t,!0))})}as(t){return new iwe(this,t)}clearSelect(){return new wt({...this.#e,queryNode:Pn.cloneWithoutSelections(this.#e.queryNode)})}clearWhere(){return new wt({...this.#e,queryNode:Ce.cloneWithoutWhere(this.#e.queryNode)})}clearLimit(){return new wt({...this.#e,queryNode:Pn.cloneWithoutLimit(this.#e.queryNode)})}clearOffset(){return new wt({...this.#e,queryNode:Pn.cloneWithoutOffset(this.#e.queryNode)})}clearOrderBy(){return new wt({...this.#e,queryNode:Ce.cloneWithoutOrderBy(this.#e.queryNode)})}clearGroupBy(){return new wt({...this.#e,queryNode:Pn.cloneWithoutGroupBy(this.#e.queryNode)})}$call(t){return t(this)}$if(t,n){return t?n(this):new wt({...this.#e})}$castTo(){return new wt(this.#e)}$narrowType(){return new wt(this.#e)}$assertType(){return new wt(this.#e)}$asTuple(){return new wn(this.toOperationNode())}$asScalar(){return new wn(this.toOperationNode())}withPlugin(t){return new wt({...this.#e,executor:this.#e.executor.withPlugin(t)})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.queryNode,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){let t=this.compile();return(await this.#e.executor.executeQuery(t)).rows}async executeTakeFirst(){let[t]=await this.execute();return t}async executeTakeFirstOrThrow(t=nb){let n=await this.executeTakeFirst();if(n===void 0)throw rb(t)?new t(this.toOperationNode()):t(this.toOperationNode());return n}async*stream(t=100){let n=this.compile(),r=this.#e.executor.stream(n,t);for await(let i of r)yield*i.rows}async explain(t,n){return await new wt({...this.#e,queryNode:Ce.cloneWithExplain(this.#e.queryNode,t,n)}).execute()}};function CA(e){return new rwe(e)}var iwe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}get isAliasedSelectQueryBuilder(){return!0}toOperationNode(){return $a.create(this.#e.toOperationNode(),un.create(this.#t))}},Md=O({is(e){return e.kind==="AggregateFunctionNode"},create(e,t=[]){return O({kind:"AggregateFunctionNode",func:e,aggregated:t})},cloneWithDistinct(e){return O({...e,distinct:!0})},cloneWithOrderBy(e,t,n=!1){let r=n?"withinGroup":"orderBy";return O({...e,[r]:e[r]?dg.cloneWithItems(e[r],t):dg.create(t)})},cloneWithFilter(e,t){return O({...e,filter:e.filter?Fo.cloneWithOperation(e.filter,"And",t):Fo.create(t)})},cloneWithOrFilter(e,t){return O({...e,filter:e.filter?Fo.cloneWithOperation(e.filter,"Or",t):Fo.create(t)})},cloneWithOver(e,t){return O({...e,over:t})}}),w4=O({is(e){return e.kind==="FunctionNode"},create(e,t){return O({kind:"FunctionNode",func:e,arguments:t})}}),fA=class Rl{#e;constructor(t){this.#e=O(t)}get expressionType(){}as(t){return new owe(this,t)}distinct(){return new Rl({...this.#e,aggregateFunctionNode:Md.cloneWithDistinct(this.#e.aggregateFunctionNode)})}orderBy(...t){return new Rl({...this.#e,aggregateFunctionNode:Ce.cloneWithOrderByItems(this.#e.aggregateFunctionNode,Hf(t))})}clearOrderBy(){return new Rl({...this.#e,aggregateFunctionNode:Ce.cloneWithoutOrderBy(this.#e.aggregateFunctionNode)})}withinGroupOrderBy(...t){return new Rl({...this.#e,aggregateFunctionNode:Md.cloneWithOrderBy(this.#e.aggregateFunctionNode,Hf(t),!0)})}filterWhere(...t){return new Rl({...this.#e,aggregateFunctionNode:Md.cloneWithFilter(this.#e.aggregateFunctionNode,Pi(t))})}filterWhereRef(t,n,r){return new Rl({...this.#e,aggregateFunctionNode:Md.cloneWithFilter(this.#e.aggregateFunctionNode,Bl(t,n,r))})}over(t){let n=Hbe();return new Rl({...this.#e,aggregateFunctionNode:Md.cloneWithOver(this.#e.aggregateFunctionNode,(t?t(n):n).toOperationNode())})}$call(t){return t(this)}$castTo(){return new Rl(this.#e)}$notNull(){return new Rl(this.#e)}toOperationNode(){return this.#e.aggregateFunctionNode}},owe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return $a.create(this.#e.toOperationNode(),un.create(this.#t))}};function eW(){let e=(n,r)=>new wn(w4.create(n,X0(r??[]))),t=(n,r)=>new fA({aggregateFunctionNode:Md.create(n,r?X0(r):void 0)});return Object.assign(e,{agg:t,avg(n){return t("avg",[n])},coalesce(...n){return e("coalesce",n)},count(n){return t("count",[n])},countAll(n){return new fA({aggregateFunctionNode:Md.create("count",na(n))})},max(n){return t("max",[n])},min(n){return t("min",[n])},sum(n){return t("sum",[n])},any(n){return e("any",[n])},jsonAgg(n){return new fA({aggregateFunctionNode:Md.create("json_agg",[go(n)?xr(n):n.toOperationNode()])})},toJson(n){return new wn(w4.create("to_json",[go(n)?xr(n):n.toOperationNode()]))}})}var swe=O({is(e){return e.kind==="UnaryOperationNode"},create(e,t){return O({kind:"UnaryOperationNode",operator:e,operand:t})}});function awe(e,t){return swe.create(Od.create(e),ws(t))}var Pl=O({is(e){return e.kind==="CaseNode"},create(e){return O({kind:"CaseNode",value:e})},cloneWithWhen(e,t){return O({...e,when:O(e.when?[...e.when,t]:[t])})},cloneWithThen(e,t){return O({...e,when:e.when?O([...e.when.slice(0,-1),$f.cloneWithResult(e.when[e.when.length-1],t)]):void 0})},cloneWith(e,t){return O({...e,...t})}}),tW=class{#e;constructor(e){this.#e=O(e)}when(...e){return new nW({...this.#e,node:Pl.cloneWithWhen(this.#e.node,$f.create(Pi(e)))})}},nW=class{#e;constructor(e){this.#e=O(e)}then(e){return new lwe({...this.#e,node:Pl.cloneWithThen(this.#e.node,PA(e)?LA(e):jr(e))})}},lwe=class{#e;constructor(e){this.#e=O(e)}when(...e){return new nW({...this.#e,node:Pl.cloneWithWhen(this.#e.node,$f.create(Pi(e)))})}else(e){return new uwe({...this.#e,node:Pl.cloneWith(this.#e.node,{else:PA(e)?LA(e):jr(e)})})}end(){return new wn(Pl.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new wn(Pl.cloneWith(this.#e.node,{isStatement:!0}))}},uwe=class{#e;constructor(e){this.#e=O(e)}end(){return new wn(Pl.cloneWith(this.#e.node,{isStatement:!1}))}endCase(){return new wn(Pl.cloneWith(this.#e.node,{isStatement:!0}))}},x4=O({is(e){return e.kind==="JSONPathLegNode"},create(e,t){return O({kind:"JSONPathLegNode",type:e,value:t})}}),NA=class{#e;constructor(e){this.#e=e}at(e){return this.#t("ArrayLocation",e)}key(e){return this.#t("Member",e)}#t(e,t){return fk.is(this.#e)?new S4(fk.cloneWithTraversal(this.#e,K0.is(this.#e.traversal)?K0.cloneWithLeg(this.#e.traversal,x4.create(e,t)):F4.cloneWithValue(this.#e.traversal,yo.createImmediate(t)))):new S4(K0.cloneWithLeg(this.#e,x4.create(e,t)))}},S4=class MA extends NA{#e;constructor(t){super(t),this.#e=t}get expressionType(){}as(t){return new cwe(this,t)}$castTo(){return new MA(this.#e)}$notNull(){return new MA(this.#e)}toOperationNode(){return this.#e}},cwe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}toOperationNode(){return $a.create(this.#e.toOperationNode(),vo(this.#t)?this.#t.toOperationNode():un.create(this.#t))}},k4=O({is(e){return e.kind==="TupleNode"},create(e){return O({kind:"TupleNode",values:O(e)})}}),dwe=["varchar","char","text","integer","int2","int4","int8","smallint","bigint","boolean","real","double precision","float4","float8","decimal","numeric","binary","bytea","date","datetime","time","timetz","timestamp","timestamptz","serial","bigserial","uuid","json","jsonb","blob","varbinary","int4range","int4multirange","int8range","int8multirange","numrange","nummultirange","tsrange","tsmultirange","tstzrange","tstzmultirange","daterange","datemultirange"],hwe=[/^varchar\(\d+\)$/,/^char\(\d+\)$/,/^decimal\(\d+, \d+\)$/,/^numeric\(\d+, \d+\)$/,/^binary\(\d+\)$/,/^datetime\(\d+\)$/,/^time\(\d+\)$/,/^timetz\(\d+\)$/,/^timestamp\(\d+\)$/,/^timestamptz\(\d+\)$/,/^varbinary\(\d+\)$/],fwe=O({is(e){return e.kind==="DataTypeNode"},create(e){return O({kind:"DataTypeNode",dataType:e})}});function pwe(e){return!!(dwe.includes(e)||hwe.some(t=>t.test(e)))}function Kf(e){if(vo(e))return e.toOperationNode();if(pwe(e))return fwe.create(e);throw new Error(`invalid column data type ${JSON.stringify(e)}`)}var mwe=O({is(e){return e.kind==="CastNode"},create(e,t){return O({kind:"CastNode",expression:e,dataType:t})}});function VA(e=Sk){function t(i,o,s){return new wn(BA(i,o,s))}function n(i,o){return new wn(awe(i,o))}let r=Object.assign(t,{fn:void 0,eb:void 0,selectFrom(i){return CA({queryId:pn(),executor:e,queryNode:Pn.createFrom(ug(i))})},case(i){return new tW({node:Pl.create(_d(i)?void 0:ws(i))})},ref(i,o){return _d(o)?new wn(Xu(i)):new NA(tbe(i,o))},jsonPath(){return new NA(K0.create())},table(i){return new wn(xr(i))},val(i){return new wn(jr(i))},refTuple(...i){return new wn(k4.create(i.map(ws)))},tuple(...i){return new wn(k4.create(i.map(jr)))},lit(i){return new wn(LA(i))},unary:n,not(i){return n("not",i)},exists(i){return n("exists",i)},neg(i){return n("-",i)},between(i,o,s){return new wn(cg.create(ws(i),Od.create("between"),Ed.create(jr(o),jr(s))))},betweenSymmetric(i,o,s){return new wn(cg.create(ws(i),Od.create("between symmetric"),Ed.create(jr(o),jr(s))))},and(i){return Qu(i)?new wn(mk(i,"and")):new wn(i4(i,"and"))},or(i){return Qu(i)?new wn(mk(i,"or")):new wn(i4(i,"or"))},parens(...i){let o=Pi(i);return Yu.is(o)?new wn(o):new wn(Yu.create(o))},cast(i,o){return new wn(mwe.create(ws(i),Kf(o)))},withSchema(i){return VA(e.withPluginAtFront(new gg(i)))}});return r.fn=eW(),r.eb=r,r}function ks(e){return VA()}function Gf(e){if(vo(e))return e.toOperationNode();if(Ss(e))return e(ks()).toOperationNode();throw new Error(`invalid expression: ${JSON.stringify(e)}`)}function rW(e){if(vo(e))return e.toOperationNode();if(Ss(e))return e(ks()).toOperationNode();throw new Error(`invalid aliased expression: ${JSON.stringify(e)}`)}function ib(e){return P4(e)||U0e(e)||Ss(e)}var gwe=class{#e;get table(){return this.#e}constructor(e){this.#e=e}as(e){return new ywe(this.#e,e)}},ywe=class{#e;#t;get table(){return this.#e}get alias(){return this.#t}constructor(e,t){this.#e=e,this.#t=t}toOperationNode(){return $a.create(xr(this.#e),un.create(this.#t))}};function vwe(e){return Ha(e)&&vo(e)&&go(e.table)&&go(e.alias)}function ug(e){return Qu(e)?e.map(t=>J0(t)):[J0(e)]}function J0(e){return go(e)?iW(e):vwe(e)?e.toOperationNode():rW(e)}function iW(e){let t=" as ";if(e.includes(t)){let[n,r]=e.split(t).map(oW);return $a.create(xr(n),un.create(r))}else return xr(e)}function xr(e){if(e.includes(".")){let[t,n]=e.split(".").map(oW);return ta.createWithSchema(t,n)}else return ta.create(e)}function oW(e){return e.trim()}var sW=O({is(e){return e.kind==="AddColumnNode"},create(e){return O({kind:"AddColumnNode",column:e})}}),tr=O({is(e){return e.kind==="ColumnDefinitionNode"},create(e,t){return O({kind:"ColumnDefinitionNode",column:$n.create(e),dataType:t})},cloneWithFrontModifier(e,t){return O({...e,frontModifiers:e.frontModifiers?O([...e.frontModifiers,t]):[t]})},cloneWithEndModifier(e,t){return O({...e,endModifiers:e.endModifiers?O([...e.endModifiers,t]):[t]})},cloneWith(e,t){return O({...e,...t})}}),aW=O({is(e){return e.kind==="DropColumnNode"},create(e){return O({kind:"DropColumnNode",column:$n.create(e)})}}),lW=O({is(e){return e.kind==="RenameColumnNode"},create(e,t){return O({kind:"RenameColumnNode",column:$n.create(e),renameTo:$n.create(t)})}}),WA=O({is(e){return e.kind==="CheckConstraintNode"},create(e,t){return O({kind:"CheckConstraintNode",expression:e,name:t?un.create(t):void 0})}}),bwe=["no action","restrict","cascade","set null","set default"],tk=O({is(e){return e.kind==="ReferencesNode"},create(e,t){return O({kind:"ReferencesNode",table:e,columns:O([...t])})},cloneWithOnDelete(e,t){return O({...e,onDelete:t})},cloneWithOnUpdate(e,t){return O({...e,onUpdate:t})}});function uW(e){return vo(e)?e.toOperationNode():yo.createImmediate(e)}var XS=O({is(e){return e.kind==="GeneratedNode"},create(e){return O({kind:"GeneratedNode",...e})},createWithExpression(e){return O({kind:"GeneratedNode",always:!0,expression:e})},cloneWith(e,t){return O({...e,...t})}}),wwe=O({is(e){return e.kind==="DefaultValueNode"},create(e){return O({kind:"DefaultValueNode",defaultValue:e})}});function vk(e){if(bwe.includes(e))return e;throw new Error(`invalid OnModifyForeignAction ${e}`)}var Z0=class Fr{#e;constructor(t){this.#e=t}autoIncrement(){return new Fr(tr.cloneWith(this.#e,{autoIncrement:!0}))}identity(){return new Fr(tr.cloneWith(this.#e,{identity:!0}))}primaryKey(){return new Fr(tr.cloneWith(this.#e,{primaryKey:!0}))}references(t){let n=Xu(t);if(!n.table||RA.is(n.column))throw new Error(`invalid call references('${t}'). The reference must have format table.column or schema.table.column`);return new Fr(tr.cloneWith(this.#e,{references:tk.create(n.table,[n.column])}))}onDelete(t){if(!this.#e.references)throw new Error("on delete constraint can only be added for foreign keys");return new Fr(tr.cloneWith(this.#e,{references:tk.cloneWithOnDelete(this.#e.references,vk(t))}))}onUpdate(t){if(!this.#e.references)throw new Error("on update constraint can only be added for foreign keys");return new Fr(tr.cloneWith(this.#e,{references:tk.cloneWithOnUpdate(this.#e.references,vk(t))}))}unique(){return new Fr(tr.cloneWith(this.#e,{unique:!0}))}notNull(){return new Fr(tr.cloneWith(this.#e,{notNull:!0}))}unsigned(){return new Fr(tr.cloneWith(this.#e,{unsigned:!0}))}defaultTo(t){return new Fr(tr.cloneWith(this.#e,{defaultTo:wwe.create(uW(t))}))}check(t){return new Fr(tr.cloneWith(this.#e,{check:WA.create(t.toOperationNode())}))}generatedAlwaysAs(t){return new Fr(tr.cloneWith(this.#e,{generated:XS.createWithExpression(t.toOperationNode())}))}generatedAlwaysAsIdentity(){return new Fr(tr.cloneWith(this.#e,{generated:XS.create({identity:!0,always:!0})}))}generatedByDefaultAsIdentity(){return new Fr(tr.cloneWith(this.#e,{generated:XS.create({identity:!0,byDefault:!0})}))}stored(){if(!this.#e.generated)throw new Error("stored() can only be called after generatedAlwaysAs");return new Fr(tr.cloneWith(this.#e,{generated:XS.cloneWith(this.#e.generated,{stored:!0})}))}modifyFront(t){return new Fr(tr.cloneWithFrontModifier(this.#e,t.toOperationNode()))}nullsNotDistinct(){return new Fr(tr.cloneWith(this.#e,{nullsNotDistinct:!0}))}ifNotExists(){return new Fr(tr.cloneWith(this.#e,{ifNotExists:!0}))}modifyEnd(t){return new Fr(tr.cloneWithEndModifier(this.#e,t.toOperationNode()))}$call(t){return t(this)}toOperationNode(){return this.#e}},cW=O({is(e){return e.kind==="ModifyColumnNode"},create(e){return O({kind:"ModifyColumnNode",column:e})}}),Cd=O({is(e){return e.kind==="ForeignKeyConstraintNode"},create(e,t,n,r){return O({kind:"ForeignKeyConstraintNode",columns:e,references:tk.create(t,n),name:r?un.create(r):void 0})},cloneWith(e,t){return O({...e,...t})}}),dW=class qf{#e;constructor(t){this.#e=t}onDelete(t){return new qf(Cd.cloneWith(this.#e,{onDelete:vk(t)}))}onUpdate(t){return new qf(Cd.cloneWith(this.#e,{onUpdate:vk(t)}))}deferrable(){return new qf(Cd.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new qf(Cd.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new qf(Cd.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new qf(Cd.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(t){return t(this)}toOperationNode(){return this.#e}},nk=O({is(e){return e.kind==="AddConstraintNode"},create(e){return O({kind:"AddConstraintNode",constraint:e})}}),Vf=O({is(e){return e.kind==="UniqueConstraintNode"},create(e,t,n){return O({kind:"UniqueConstraintNode",columns:O(e.map($n.create)),name:t?un.create(t):void 0,nullsNotDistinct:n})},cloneWith(e,t){return O({...e,...t})}}),rk=O({is(e){return e.kind==="DropConstraintNode"},create(e){return O({kind:"DropConstraintNode",constraintName:un.create(e)})},cloneWith(e,t){return O({...e,...t})}}),q0=O({is(e){return e.kind==="AlterColumnNode"},create(e,t,n){return O({kind:"AlterColumnNode",column:$n.create(e),[t]:n})}}),hW=class{#e;constructor(e){this.#e=e}setDataType(e){return new z0(q0.create(this.#e,"dataType",Kf(e)))}setDefault(e){return new z0(q0.create(this.#e,"setDefault",uW(e)))}dropDefault(){return new z0(q0.create(this.#e,"dropDefault",!0))}setNotNull(){return new z0(q0.create(this.#e,"setNotNull",!0))}dropNotNull(){return new z0(q0.create(this.#e,"dropNotNull",!0))}$call(e){return e(this)}},z0=class{#e;constructor(e){this.#e=e}toOperationNode(){return this.#e}},Jm=class{#e;constructor(e){this.#e=O(e)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},xwe=class zf{#e;constructor(t){this.#e=O(t)}onDelete(t){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.onDelete(t)})}onUpdate(t){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.onUpdate(t)})}deferrable(){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.deferrable()})}notDeferrable(){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.notDeferrable()})}initiallyDeferred(){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyDeferred()})}initiallyImmediate(){return new zf({...this.#e,constraintBuilder:this.#e.constraintBuilder.initiallyImmediate()})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(fn.cloneWithTableProps(this.#e.node,{addConstraint:nk.create(this.#e.constraintBuilder.toOperationNode())}),this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},C4=class ik{#e;constructor(t){this.#e=O(t)}ifExists(){return new ik({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{dropConstraint:rk.cloneWith(this.#e.node.dropConstraint,{ifExists:!0})})})}cascade(){return new ik({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{dropConstraint:rk.cloneWith(this.#e.node.dropConstraint,{modifier:"cascade"})})})}restrict(){return new ik({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{dropConstraint:rk.cloneWith(this.#e.node.dropConstraint,{modifier:"restrict"})})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},sg=O({is(e){return e.kind==="PrimaryKeyConstraintNode"},create(e,t){return O({kind:"PrimaryKeyConstraintNode",columns:O(e.map($n.create)),name:t?un.create(t):void 0})},cloneWith(e,t){return O({...e,...t})}}),tg=O({is(e){return e.kind==="AddIndexNode"},create(e){return O({kind:"AddIndexNode",name:un.create(e)})},cloneWith(e,t){return O({...e,...t})},cloneWithColumns(e,t){return O({...e,columns:[...e.columns||[],...t]})}}),Swe=class ng{#e;constructor(t){this.#e=O(t)}unique(){return new ng({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.cloneWith(this.#e.node.addIndex,{unique:!0})})})}column(t){return new ng({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.cloneWithColumns(this.#e.node.addIndex,[pk(t)])})})}columns(t){return new ng({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.cloneWithColumns(this.#e.node.addIndex,t.map(pk))})})}expression(t){return new ng({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.cloneWithColumns(this.#e.node.addIndex,[t.toOperationNode()])})})}using(t){return new ng({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.cloneWith(this.#e.node.addIndex,{using:Ar.createWithSql(t)})})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},fW=class rg{#e;constructor(t){this.#e=t}nullsNotDistinct(){return new rg(Vf.cloneWith(this.#e,{nullsNotDistinct:!0}))}deferrable(){return new rg(Vf.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new rg(Vf.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new rg(Vf.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new rg(Vf.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(t){return t(this)}toOperationNode(){return this.#e}},pW=class W0{#e;constructor(t){this.#e=t}deferrable(){return new W0(sg.cloneWith(this.#e,{deferrable:!0}))}notDeferrable(){return new W0(sg.cloneWith(this.#e,{deferrable:!1}))}initiallyDeferred(){return new W0(sg.cloneWith(this.#e,{initiallyDeferred:!0}))}initiallyImmediate(){return new W0(sg.cloneWith(this.#e,{initiallyDeferred:!1}))}$call(t){return t(this)}toOperationNode(){return this.#e}},mW=class{#e;constructor(e){this.#e=e}$call(e){return e(this)}toOperationNode(){return this.#e}},kwe=O({is(e){return e.kind==="RenameConstraintNode"},create(e,t){return O({kind:"RenameConstraintNode",oldName:un.create(e),newName:un.create(t)})}}),Cwe=class{#e;constructor(e){this.#e=O(e)}renameTo(e){return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{renameTo:xr(e)})})}setSchema(e){return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{setSchema:un.create(e)})})}alterColumn(e,t){let n=t(new hW(e));return new F0({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,n.toOperationNode())})}dropColumn(e){return new F0({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,aW.create(e))})}renameColumn(e,t){return new F0({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,lW.create(e,t))})}addColumn(e,t,n=bs){let r=n(new Z0(tr.create(e,Kf(t))));return new F0({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,sW.create(r.toOperationNode()))})}modifyColumn(e,t,n=bs){let r=n(new Z0(tr.create(e,Kf(t))));return new F0({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,cW.create(r.toOperationNode()))})}addUniqueConstraint(e,t,n=bs){let r=n(new fW(Vf.create(t,e)));return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addConstraint:nk.create(r.toOperationNode())})})}addCheckConstraint(e,t,n=bs){let r=n(new mW(WA.create(t.toOperationNode(),e)));return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addConstraint:nk.create(r.toOperationNode())})})}addForeignKeyConstraint(e,t,n,r,i=bs){let o=i(new dW(Cd.create(t.map($n.create),xr(n),r.map($n.create),e)));return new xwe({...this.#e,constraintBuilder:o})}addPrimaryKeyConstraint(e,t,n=bs){let r=n(new pW(sg.create(t,e)));return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addConstraint:nk.create(r.toOperationNode())})})}dropConstraint(e){return new C4({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{dropConstraint:rk.create(e)})})}renameConstraint(e,t){return new C4({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{renameConstraint:kwe.create(e,t)})})}addIndex(e){return new Swe({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{addIndex:tg.create(e)})})}dropIndex(e){return new Jm({...this.#e,node:fn.cloneWithTableProps(this.#e.node,{dropIndex:$0.create(e)})})}$call(e){return e(this)}},F0=class ig{#e;constructor(t){this.#e=O(t)}alterColumn(t,n){let r=n(new hW(t));return new ig({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,r.toOperationNode())})}dropColumn(t){return new ig({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,aW.create(t))})}renameColumn(t,n){return new ig({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,lW.create(t,n))})}addColumn(t,n,r=bs){let i=r(new Z0(tr.create(t,Kf(n))));return new ig({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,sW.create(i.toOperationNode()))})}modifyColumn(t,n,r=bs){let i=r(new Z0(tr.create(t,Kf(n))));return new ig({...this.#e,node:fn.cloneWithColumnAlteration(this.#e.node,cW.create(i.toOperationNode()))})}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},gW=class extends FA{transformPrimitiveValueList(e){return tb.create(e.values.map(yo.createImmediate))}transformValue(e){return yo.createImmediate(e.value)}},Nwe=class Il{#e;constructor(t){this.#e=O(t)}ifNotExists(){return new Il({...this.#e,node:$u.cloneWith(this.#e.node,{ifNotExists:!0})})}unique(){return new Il({...this.#e,node:$u.cloneWith(this.#e.node,{unique:!0})})}nullsNotDistinct(){return new Il({...this.#e,node:$u.cloneWith(this.#e.node,{nullsNotDistinct:!0})})}on(t){return new Il({...this.#e,node:$u.cloneWith(this.#e.node,{table:xr(t)})})}column(t){return new Il({...this.#e,node:$u.cloneWithColumns(this.#e.node,[pk(t)])})}columns(t){return new Il({...this.#e,node:$u.cloneWithColumns(this.#e.node,t.map(pk))})}expression(t){return new Il({...this.#e,node:$u.cloneWithColumns(this.#e.node,[t.toOperationNode()])})}using(t){return new Il({...this.#e,node:$u.cloneWith(this.#e.node,{using:Ar.createWithSql(t)})})}where(...t){let n=new gW;return new Il({...this.#e,node:Ce.cloneWithWhere(this.#e.node,n.transformNode(Pi(t),this.#e.queryId))})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},Mwe=class yW{#e;constructor(t){this.#e=O(t)}ifNotExists(){return new yW({...this.#e,node:I4.cloneWith(this.#e.node,{ifNotExists:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};function _we(e){if(W0e.includes(e))return e;throw new Error(`invalid OnCommitAction ${e}`)}var Ewe=class ea{#e;constructor(t){this.#e=O(t)}temporary(){return new ea({...this.#e,node:ys.cloneWith(this.#e.node,{temporary:!0})})}onCommit(t){return new ea({...this.#e,node:ys.cloneWith(this.#e.node,{onCommit:_we(t)})})}ifNotExists(){return new ea({...this.#e,node:ys.cloneWith(this.#e.node,{ifNotExists:!0})})}addColumn(t,n,r=bs){let i=r(new Z0(tr.create(t,Kf(n))));return new ea({...this.#e,node:ys.cloneWithColumn(this.#e.node,i.toOperationNode())})}addPrimaryKeyConstraint(t,n,r=bs){let i=r(new pW(sg.create(n,t)));return new ea({...this.#e,node:ys.cloneWithConstraint(this.#e.node,i.toOperationNode())})}addUniqueConstraint(t,n,r=bs){let i=r(new fW(Vf.create(n,t)));return new ea({...this.#e,node:ys.cloneWithConstraint(this.#e.node,i.toOperationNode())})}addCheckConstraint(t,n,r=bs){let i=r(new mW(WA.create(n.toOperationNode(),t)));return new ea({...this.#e,node:ys.cloneWithConstraint(this.#e.node,i.toOperationNode())})}addForeignKeyConstraint(t,n,r,i,o=bs){let s=o(new dW(Cd.create(n.map($n.create),xr(r),i.map($n.create),t)));return new ea({...this.#e,node:ys.cloneWithConstraint(this.#e.node,s.toOperationNode())})}modifyFront(t){return new ea({...this.#e,node:ys.cloneWithFrontModifier(this.#e.node,t.toOperationNode())})}modifyEnd(t){return new ea({...this.#e,node:ys.cloneWithEndModifier(this.#e.node,t.toOperationNode())})}as(t){return new ea({...this.#e,node:ys.cloneWith(this.#e.node,{selectQuery:Gf(t)})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},Owe=class ok{#e;constructor(t){this.#e=O(t)}on(t){return new ok({...this.#e,node:$0.cloneWith(this.#e.node,{table:xr(t)})})}ifExists(){return new ok({...this.#e,node:$0.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new ok({...this.#e,node:$0.cloneWith(this.#e.node,{cascade:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},Twe=class _A{#e;constructor(t){this.#e=O(t)}ifExists(){return new _A({...this.#e,node:mA.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new _A({...this.#e,node:mA.cloneWith(this.#e.node,{cascade:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},Awe=class EA{#e;constructor(t){this.#e=O(t)}ifExists(){return new EA({...this.#e,node:gA.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new EA({...this.#e,node:gA.cloneWith(this.#e.node,{cascade:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},Nd=O({is(e){return e.kind==="CreateViewNode"},create(e){return O({kind:"CreateViewNode",name:Gu.create(e)})},cloneWith(e,t){return O({...e,...t})}}),Dwe=class{#e=new gW;transformQuery(e){return this.#e.transformNode(e.node,e.queryId)}transformResult(e){return Promise.resolve(e.result)}},Rwe=class Ff{#e;constructor(t){this.#e=O(t)}temporary(){return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{temporary:!0})})}materialized(){return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{materialized:!0})})}ifNotExists(){return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{ifNotExists:!0})})}orReplace(){return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{orReplace:!0})})}columns(t){return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{columns:t.map(V4)})})}as(t){let n=t.withPlugin(new Dwe).toOperationNode();return new Ff({...this.#e,node:Nd.cloneWith(this.#e.node,{as:n})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},sk=O({is(e){return e.kind==="DropViewNode"},create(e){return O({kind:"DropViewNode",name:Gu.create(e)})},cloneWith(e,t){return O({...e,...t})}}),Iwe=class ak{#e;constructor(t){this.#e=O(t)}materialized(){return new ak({...this.#e,node:sk.cloneWith(this.#e.node,{materialized:!0})})}ifExists(){return new ak({...this.#e,node:sk.cloneWith(this.#e.node,{ifExists:!0})})}cascade(){return new ak({...this.#e,node:sk.cloneWith(this.#e.node,{cascade:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},vW=O({is(e){return e.kind==="CreateTypeNode"},create(e){return O({kind:"CreateTypeNode",name:e})},cloneWithEnum(e,t){return O({...e,enum:tb.create(t.map(yo.createImmediate))})}}),Pwe=class bW{#e;constructor(t){this.#e=O(t)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}asEnum(t){return new bW({...this.#e,node:vW.cloneWithEnum(this.#e.node,t)})}$call(t){return t(this)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},wW=O({is(e){return e.kind==="DropTypeNode"},create(e){return O({kind:"DropTypeNode",name:e})},cloneWith(e,t){return O({...e,...t})}}),Lwe=class xW{#e;constructor(t){this.#e=O(t)}ifExists(){return new xW({...this.#e,node:wW.cloneWith(this.#e.node,{ifExists:!0})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}};function N4(e){if(e.includes(".")){let t=e.split(".").map(Bwe);if(t.length===2)return Gu.createWithSchema(t[0],t[1]);throw new Error(`invalid schemable identifier ${e}`)}else return Gu.create(e)}function Bwe(e){return e.trim()}var lk=O({is(e){return e.kind==="RefreshMaterializedViewNode"},create(e){return O({kind:"RefreshMaterializedViewNode",name:Gu.create(e)})},cloneWith(e,t){return O({...e,...t})}}),qwe=class uk{#e;constructor(t){this.#e=O(t)}concurrently(){return new uk({...this.#e,node:lk.cloneWith(this.#e.node,{concurrently:!0,withNoData:!1})})}withData(){return new uk({...this.#e,node:lk.cloneWith(this.#e.node,{withNoData:!1})})}withNoData(){return new uk({...this.#e,node:lk.cloneWith(this.#e.node,{withNoData:!0,concurrently:!1})})}$call(t){return t(this)}toOperationNode(){return this.#e.executor.transformQuery(this.#e.node,this.#e.queryId)}compile(){return this.#e.executor.compileQuery(this.toOperationNode(),this.#e.queryId)}async execute(){await this.#e.executor.executeQuery(this.compile())}},zwe=class ck{#e;constructor(t){this.#e=t}createTable(t){return new Ewe({queryId:pn(),executor:this.#e,node:ys.create(xr(t))})}dropTable(t){return new Awe({queryId:pn(),executor:this.#e,node:gA.create(xr(t))})}createIndex(t){return new Nwe({queryId:pn(),executor:this.#e,node:$u.create(t)})}dropIndex(t){return new Owe({queryId:pn(),executor:this.#e,node:$0.create(t)})}createSchema(t){return new Mwe({queryId:pn(),executor:this.#e,node:I4.create(t)})}dropSchema(t){return new Twe({queryId:pn(),executor:this.#e,node:mA.create(t)})}alterTable(t){return new Cwe({queryId:pn(),executor:this.#e,node:fn.create(xr(t))})}createView(t){return new Rwe({queryId:pn(),executor:this.#e,node:Nd.create(t)})}refreshMaterializedView(t){return new qwe({queryId:pn(),executor:this.#e,node:lk.create(t)})}dropView(t){return new Iwe({queryId:pn(),executor:this.#e,node:sk.create(t)})}createType(t){return new Pwe({queryId:pn(),executor:this.#e,node:vW.create(N4(t))})}dropType(t){return new Lwe({queryId:pn(),executor:this.#e,node:wW.create(N4(t))})}withPlugin(t){return new ck(this.#e.withPlugin(t))}withoutPlugins(){return new ck(this.#e.withoutPlugins())}withSchema(t){return new ck(this.#e.withPluginAtFront(new gg(t)))}},Fwe=class{ref(e){return new X0e(e)}table(e){return new gwe(e)}},jwe=class{#e;constructor(e){this.#e=e}async provideConnection(e){let t=await this.#e.acquireConnection();try{return await e(t)}finally{await this.#e.releaseConnection(t)}}},Vwe=class og extends X4{#e;#t;#n;constructor(t,n,r,i=[]){super(i),this.#e=t,this.#t=n,this.#n=r}get adapter(){return this.#t}compileQuery(t,n){return this.#e.compileQuery(t,n)}provideConnection(t){return this.#n.provideConnection(t)}withPlugins(t){return new og(this.#e,this.#t,this.#n,[...this.plugins,...t])}withPlugin(t){return new og(this.#e,this.#t,this.#n,[...this.plugins,t])}withPluginAtFront(t){return new og(this.#e,this.#t,this.#n,[t,...this.plugins])}withConnectionProvider(t){return new og(this.#e,this.#t,t,[...this.plugins])}withoutPlugins(){return new og(this.#e,this.#t,this.#n,[])}};function pA(){return typeof performance<"u"&&Ss(performance.now)?performance.now():Date.now()}var Wwe=class{#e;#t;#n;#r;#i;#s=new WeakSet;constructor(e,t){this.#r=!1,this.#e=e,this.#t=t}async init(){if(this.#i)throw new Error("driver has already been destroyed");this.#n||(this.#n=this.#e.init().then(()=>{this.#r=!0}).catch(e=>(this.#n=void 0,Promise.reject(e)))),await this.#n}async acquireConnection(){if(this.#i)throw new Error("driver has already been destroyed");this.#r||await this.init();let e=await this.#e.acquireConnection();return this.#s.has(e)||(this.#a()&&this.#o(e),this.#s.add(e)),e}async releaseConnection(e){await this.#e.releaseConnection(e)}beginTransaction(e,t){return this.#e.beginTransaction(e,t)}commitTransaction(e){return this.#e.commitTransaction(e)}rollbackTransaction(e){return this.#e.rollbackTransaction(e)}savepoint(e,t,n){if(this.#e.savepoint)return this.#e.savepoint(e,t,n);throw new Error("The `savepoint` method is not supported by this driver")}rollbackToSavepoint(e,t,n){if(this.#e.rollbackToSavepoint)return this.#e.rollbackToSavepoint(e,t,n);throw new Error("The `rollbackToSavepoint` method is not supported by this driver")}releaseSavepoint(e,t,n){if(this.#e.releaseSavepoint)return this.#e.releaseSavepoint(e,t,n);throw new Error("The `releaseSavepoint` method is not supported by this driver")}async destroy(){this.#n&&(await this.#n,this.#i||(this.#i=this.#e.destroy().catch(e=>(this.#i=void 0,Promise.reject(e)))),await this.#i)}#a(){return this.#t.isLevelEnabled("query")||this.#t.isLevelEnabled("error")}#o(e){let t=e.executeQuery,n=e.streamQuery,r=this;e.executeQuery=async i=>{let o,s=pA();try{return await t.call(e,i)}catch(a){throw o=a,await r.#l(a,i,s),a}finally{o||await r.#u(i,s)}},e.streamQuery=async function*(i,o){let s,a=pA();try{for await(let l of n.call(e,i,o))yield l}catch(l){throw s=l,await r.#l(l,i,a),l}finally{s||await r.#u(i,a,!0)}}}async#l(e,t,n){await this.#t.error(()=>({level:"error",error:e,query:t,queryDurationMillis:this.#c(n)}))}async#u(e,t,n=!1){await this.#t.query(()=>({level:"query",isStream:n,query:e,queryDurationMillis:this.#c(t)}))}#c(e){return pA()-e}},Uwe=()=>{},UA=class{#e;#t;constructor(e){this.#e=e}async provideConnection(e){for(;this.#t;)await this.#t.catch(Uwe);return this.#t=this.#n(e).finally(()=>{this.#t=void 0}),this.#t}async#n(e){return await e(this.#e)}},Hwe=["read only","read write"],$we=["read uncommitted","read committed","repeatable read","serializable","snapshot"];function SW(e){if(e.accessMode&&!Hwe.includes(e.accessMode))throw new Error(`invalid transaction access mode ${e.accessMode}`);if(e.isolationLevel&&!$we.includes(e.isolationLevel))throw new Error(`invalid transaction isolation level ${e.isolationLevel}`)}var Kwe=["query","error"],mpt=O(Kwe),Ywe=class{#e;#t;constructor(e){Ss(e)?(this.#t=e,this.#e=O({query:!0,error:!0})):(this.#t=Qwe,this.#e=O({query:e.includes("query"),error:e.includes("error")}))}isLevelEnabled(e){return this.#e[e]}async query(e){this.#e.query&&await this.#t(e())}async error(e){this.#e.error&&await this.#t(e())}};function Qwe(e){if(e.level==="query"){let t=`kysely:query:${e.isStream?"stream:":""}`;console.log(`${t} ${e.query.sql}`),console.log(`${t} duration: ${e.queryDurationMillis.toFixed(1)}ms`)}else e.level==="error"&&(e.error instanceof Error?console.error(`kysely:error: ${e.error.stack??e.error.message}`):console.error(`kysely:error: ${JSON.stringify({error:e.error,query:e.query.sql,queryDurationMillis:e.queryDurationMillis})}`))}function Gwe(e){return Ha(e)&&Ss(e.compile)}Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");var HA=class U0 extends J4{#e;constructor(t){let n,r;if(Xwe(t))n={executor:t.executor},r={...t};else{let i=t.dialect,o=i.createDriver(),s=i.createQueryCompiler(),a=i.createAdapter(),l=new Ywe(t.log??[]),u=new Wwe(o,l),c=new jwe(u),d=new Vwe(s,a,c,t.plugins??[]);n={executor:d},r={config:t,executor:d,dialect:i,driver:u}}super(n),this.#e=O(r)}get schema(){return new zwe(this.#e.executor)}get dynamic(){return new Fwe}get introspection(){return this.#e.dialect.createIntrospector(this.withoutPlugins())}case(t){return new tW({node:Pl.create(_d(t)?void 0:Gf(t))})}get fn(){return eW()}transaction(){return new Zwe({...this.#e})}startTransaction(){return new exe({...this.#e})}connection(){return new Jwe({...this.#e})}withPlugin(t){return new U0({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new U0({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new U0({...this.#e,executor:this.#e.executor.withPluginAtFront(new gg(t))})}withTables(){return new U0({...this.#e})}async destroy(){await this.#e.driver.destroy()}get isTransaction(){return!1}getExecutor(){return this.#e.executor}executeQuery(t,n){n!==void 0&&pg("Passing `queryId` in `db.executeQuery` is deprecated and will result in a compile-time error in the future.");let r=Gwe(t)?t.compile():t;return this.getExecutor().executeQuery(r)}async[Symbol.asyncDispose](){await this.destroy()}},kW=class H0 extends HA{#e;constructor(t){super(t),this.#e=t}get isTransaction(){return!0}transaction(){throw new Error("calling the transaction method for a Transaction is not supported")}connection(){throw new Error("calling the connection method for a Transaction is not supported")}async destroy(){throw new Error("calling the destroy method for a Transaction is not supported")}withPlugin(t){return new H0({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new H0({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new H0({...this.#e,executor:this.#e.executor.withPluginAtFront(new gg(t))})}withTables(){return new H0({...this.#e})}};function Xwe(e){return Ha(e)&&Ha(e.config)&&Ha(e.driver)&&Ha(e.executor)&&Ha(e.dialect)}var Jwe=class{#e;constructor(e){this.#e=O(e)}async execute(e){return this.#e.executor.provideConnection(async t=>{let n=this.#e.executor.withConnectionProvider(new UA(t)),r=new HA({...this.#e,executor:n});return await e(r)})}},Zwe=class OA{#e;constructor(t){this.#e=O(t)}setAccessMode(t){return new OA({...this.#e,accessMode:t})}setIsolationLevel(t){return new OA({...this.#e,isolationLevel:t})}async execute(t){let{isolationLevel:n,accessMode:r,...i}=this.#e,o={isolationLevel:n,accessMode:r};return SW(o),this.#e.executor.provideConnection(async s=>{let a=this.#e.executor.withConnectionProvider(new UA(s)),l=new kW({...i,executor:a}),u=!1;try{await this.#e.driver.beginTransaction(s,o),u=!0;let c=await t(l);return await this.#e.driver.commitTransaction(s),c}catch(c){throw u&&await this.#e.driver.rollbackTransaction(s),c}})}},exe=class TA{#e;constructor(t){this.#e=O(t)}setAccessMode(t){return new TA({...this.#e,accessMode:t})}setIsolationLevel(t){return new TA({...this.#e,isolationLevel:t})}async execute(){let{isolationLevel:t,accessMode:n,...r}=this.#e,i={isolationLevel:t,accessMode:n};SW(i);let o=await G4(this.#e.executor);return await this.#e.driver.beginTransaction(o.connection,i),new txe({...r,connection:o,executor:this.#e.executor.withConnectionProvider(new UA(o.connection))})}},txe=class kd extends kW{#e;#t;#n;constructor(t){let n={isCommitted:!1,isRolledBack:!1};t={...t,executor:new nxe(t.executor,n)};let{connection:r,...i}=t;super(i),this.#e=O(t),this.#n=n;let o=pn();this.#t=s=>t.executor.compileQuery(s,o)}get isCommitted(){return this.#n.isCommitted}get isRolledBack(){return this.#n.isRolledBack}commit(){return Wf(this.#n),new j0(async()=>{await this.#e.driver.commitTransaction(this.#e.connection.connection),this.#n.isCommitted=!0,this.#e.connection.release()})}rollback(){return Wf(this.#n),new j0(async()=>{await this.#e.driver.rollbackTransaction(this.#e.connection.connection),this.#n.isRolledBack=!0,this.#e.connection.release()})}savepoint(t){return Wf(this.#n),new j0(async()=>(await this.#e.driver.savepoint?.(this.#e.connection.connection,t,this.#t),new kd({...this.#e})))}rollbackToSavepoint(t){return Wf(this.#n),new j0(async()=>(await this.#e.driver.rollbackToSavepoint?.(this.#e.connection.connection,t,this.#t),new kd({...this.#e})))}releaseSavepoint(t){return Wf(this.#n),new j0(async()=>(await this.#e.driver.releaseSavepoint?.(this.#e.connection.connection,t,this.#t),new kd({...this.#e})))}withPlugin(t){return new kd({...this.#e,executor:this.#e.executor.withPlugin(t)})}withoutPlugins(){return new kd({...this.#e,executor:this.#e.executor.withoutPlugins()})}withSchema(t){return new kd({...this.#e,executor:this.#e.executor.withPluginAtFront(new gg(t))})}withTables(){return new kd({...this.#e})}},j0=class{#e;constructor(e){this.#e=e}async execute(){return await this.#e()}};function Wf(e){if(e.isCommitted)throw new Error("Transaction is already committed");if(e.isRolledBack)throw new Error("Transaction is already rolled back")}var nxe=class jf{#e;#t;constructor(t,n){t instanceof jf?this.#e=t.#e:this.#e=t,this.#t=n}get adapter(){return this.#e.adapter}get plugins(){return this.#e.plugins}transformQuery(t,n){return this.#e.transformQuery(t,n)}compileQuery(t,n){return this.#e.compileQuery(t,n)}provideConnection(t){return this.#e.provideConnection(t)}executeQuery(t){return Wf(this.#t),this.#e.executeQuery(t)}stream(t,n){return Wf(this.#t),this.#e.stream(t,n)}withConnectionProvider(t){return new jf(this.#e.withConnectionProvider(t),this.#t)}withPlugin(t){return new jf(this.#e.withPlugin(t),this.#t)}withPlugins(t){return new jf(this.#e.withPlugins(t),this.#t)}withPluginAtFront(t){return new jf(this.#e.withPluginAtFront(t),this.#t)}withoutPlugins(){return new jf(this.#e.withoutPlugins(),this.#t)}},rxe=class dk{#e;constructor(t){this.#e=O(t)}get expressionType(){}get isRawBuilder(){return!0}as(t){return new ixe(this,t)}$castTo(){return new dk({...this.#e})}$notNull(){return new dk(this.#e)}withPlugin(t){return new dk({...this.#e,plugins:this.#e.plugins!==void 0?O([...this.#e.plugins,t]):O([t])})}toOperationNode(){return this.#n(this.#t())}compile(t){return this.#r(this.#t(t))}async execute(t){let n=this.#t(t);return n.executeQuery(this.#r(n))}#t(t){let n=t!==void 0?t.getExecutor():Sk;return this.#e.plugins!==void 0?n.withPlugins(this.#e.plugins):n}#n(t){return t.transformQuery(this.#e.rawNode,this.#e.queryId)}#r(t){return t.compileQuery(this.#n(t),this.#e.queryId)}};function wd(e){return new rxe(e)}var ixe=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get expression(){return this.#e}get alias(){return this.#t}get rawBuilder(){return this.#e}toOperationNode(){return $a.create(this.#e.toOperationNode(),vo(this.#t)?this.#t.toOperationNode():un.create(this.#t))}},Fe=Object.assign((e,...t)=>wd({queryId:pn(),rawNode:Ar.create(e,t?.map(M4)??[])}),{ref(e){return wd({queryId:pn(),rawNode:Ar.createWithChild(Xu(e))})},val(e){return wd({queryId:pn(),rawNode:Ar.createWithChild(jr(e))})},value(e){return this.val(e)},table(e){return wd({queryId:pn(),rawNode:Ar.createWithChild(xr(e))})},id(...e){let t=new Array(e.length+1).fill(".");return t[0]="",t[t.length-1]="",wd({queryId:pn(),rawNode:Ar.create(t,e.map(un.create))})},lit(e){return wd({queryId:pn(),rawNode:Ar.createWithChild(yo.createImmediate(e))})},literal(e){return this.lit(e)},raw(e){return wd({queryId:pn(),rawNode:Ar.createWithSql(e)})},join(e,t=Fe`, `){let n=new Array(Math.max(2*e.length-1,0)),r=t.toOperationNode();for(let i=0;i<e.length;++i)n[2*i]=M4(e[i]),i!==e.length-1&&(n[2*i+1]=r);return wd({queryId:pn(),rawNode:Ar.createWithChildren(n)})}});function M4(e){return vo(e)?e.toOperationNode():jr(e)}var oxe=class{nodeStack=[];get parentNode(){return this.nodeStack[this.nodeStack.length-2]}#e=O({AliasNode:this.visitAlias.bind(this),ColumnNode:this.visitColumn.bind(this),IdentifierNode:this.visitIdentifier.bind(this),SchemableIdentifierNode:this.visitSchemableIdentifier.bind(this),RawNode:this.visitRaw.bind(this),ReferenceNode:this.visitReference.bind(this),SelectQueryNode:this.visitSelectQuery.bind(this),SelectionNode:this.visitSelection.bind(this),TableNode:this.visitTable.bind(this),FromNode:this.visitFrom.bind(this),SelectAllNode:this.visitSelectAll.bind(this),AndNode:this.visitAnd.bind(this),OrNode:this.visitOr.bind(this),ValueNode:this.visitValue.bind(this),ValueListNode:this.visitValueList.bind(this),PrimitiveValueListNode:this.visitPrimitiveValueList.bind(this),ParensNode:this.visitParens.bind(this),JoinNode:this.visitJoin.bind(this),OperatorNode:this.visitOperator.bind(this),WhereNode:this.visitWhere.bind(this),InsertQueryNode:this.visitInsertQuery.bind(this),DeleteQueryNode:this.visitDeleteQuery.bind(this),ReturningNode:this.visitReturning.bind(this),CreateTableNode:this.visitCreateTable.bind(this),AddColumnNode:this.visitAddColumn.bind(this),ColumnDefinitionNode:this.visitColumnDefinition.bind(this),DropTableNode:this.visitDropTable.bind(this),DataTypeNode:this.visitDataType.bind(this),OrderByNode:this.visitOrderBy.bind(this),OrderByItemNode:this.visitOrderByItem.bind(this),GroupByNode:this.visitGroupBy.bind(this),GroupByItemNode:this.visitGroupByItem.bind(this),UpdateQueryNode:this.visitUpdateQuery.bind(this),ColumnUpdateNode:this.visitColumnUpdate.bind(this),LimitNode:this.visitLimit.bind(this),OffsetNode:this.visitOffset.bind(this),OnConflictNode:this.visitOnConflict.bind(this),OnDuplicateKeyNode:this.visitOnDuplicateKey.bind(this),CreateIndexNode:this.visitCreateIndex.bind(this),DropIndexNode:this.visitDropIndex.bind(this),ListNode:this.visitList.bind(this),PrimaryKeyConstraintNode:this.visitPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.visitUniqueConstraint.bind(this),ReferencesNode:this.visitReferences.bind(this),CheckConstraintNode:this.visitCheckConstraint.bind(this),WithNode:this.visitWith.bind(this),CommonTableExpressionNode:this.visitCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.visitCommonTableExpressionName.bind(this),HavingNode:this.visitHaving.bind(this),CreateSchemaNode:this.visitCreateSchema.bind(this),DropSchemaNode:this.visitDropSchema.bind(this),AlterTableNode:this.visitAlterTable.bind(this),DropColumnNode:this.visitDropColumn.bind(this),RenameColumnNode:this.visitRenameColumn.bind(this),AlterColumnNode:this.visitAlterColumn.bind(this),ModifyColumnNode:this.visitModifyColumn.bind(this),AddConstraintNode:this.visitAddConstraint.bind(this),DropConstraintNode:this.visitDropConstraint.bind(this),RenameConstraintNode:this.visitRenameConstraint.bind(this),ForeignKeyConstraintNode:this.visitForeignKeyConstraint.bind(this),CreateViewNode:this.visitCreateView.bind(this),RefreshMaterializedViewNode:this.visitRefreshMaterializedView.bind(this),DropViewNode:this.visitDropView.bind(this),GeneratedNode:this.visitGenerated.bind(this),DefaultValueNode:this.visitDefaultValue.bind(this),OnNode:this.visitOn.bind(this),ValuesNode:this.visitValues.bind(this),SelectModifierNode:this.visitSelectModifier.bind(this),CreateTypeNode:this.visitCreateType.bind(this),DropTypeNode:this.visitDropType.bind(this),ExplainNode:this.visitExplain.bind(this),DefaultInsertValueNode:this.visitDefaultInsertValue.bind(this),AggregateFunctionNode:this.visitAggregateFunction.bind(this),OverNode:this.visitOver.bind(this),PartitionByNode:this.visitPartitionBy.bind(this),PartitionByItemNode:this.visitPartitionByItem.bind(this),SetOperationNode:this.visitSetOperation.bind(this),BinaryOperationNode:this.visitBinaryOperation.bind(this),UnaryOperationNode:this.visitUnaryOperation.bind(this),UsingNode:this.visitUsing.bind(this),FunctionNode:this.visitFunction.bind(this),CaseNode:this.visitCase.bind(this),WhenNode:this.visitWhen.bind(this),JSONReferenceNode:this.visitJSONReference.bind(this),JSONPathNode:this.visitJSONPath.bind(this),JSONPathLegNode:this.visitJSONPathLeg.bind(this),JSONOperatorChainNode:this.visitJSONOperatorChain.bind(this),TupleNode:this.visitTuple.bind(this),MergeQueryNode:this.visitMergeQuery.bind(this),MatchedNode:this.visitMatched.bind(this),AddIndexNode:this.visitAddIndex.bind(this),CastNode:this.visitCast.bind(this),FetchNode:this.visitFetch.bind(this),TopNode:this.visitTop.bind(this),OutputNode:this.visitOutput.bind(this),OrActionNode:this.visitOrAction.bind(this),CollateNode:this.visitCollate.bind(this)});visitNode=e=>{this.nodeStack.push(e),this.#e[e.kind](e),this.nodeStack.pop()}},sxe=/'/g,$A=class extends oxe{#e="";#t=[];get numParameters(){return this.#t.length}compileQuery(e,t){return this.#e="",this.#t=[],this.nodeStack.splice(0,this.nodeStack.length),this.visitNode(e),O({query:e,queryId:t,sql:this.getSql(),parameters:[...this.#t]})}getSql(){return this.#e}visitSelectQuery(e){let t=this.parentNode!==void 0&&!Yu.is(this.parentNode)&&!wi.is(this.parentNode)&&!ys.is(this.parentNode)&&!Nd.is(this.parentNode)&&!Z4.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("select"),e.distinctOn&&(this.append(" "),this.compileDistinctOn(e.distinctOn)),e.frontModifiers?.length&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.top&&(this.append(" "),this.visitNode(e.top)),e.selections&&(this.append(" "),this.compileList(e.selections)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.groupBy&&(this.append(" "),this.visitNode(e.groupBy)),e.having&&(this.append(" "),this.visitNode(e.having)),e.setOperations&&(this.append(" "),this.compileList(e.setOperations," ")),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.offset&&(this.append(" "),this.visitNode(e.offset)),e.fetch&&(this.append(" "),this.visitNode(e.fetch)),e.endModifiers?.length&&(this.append(" "),this.compileList(this.sortSelectModifiers([...e.endModifiers])," ")),t&&this.append(")")}visitFrom(e){this.append("from "),this.compileList(e.froms)}visitSelection(e){this.visitNode(e.selection)}visitColumn(e){this.visitNode(e.column)}compileDistinctOn(e){this.append("distinct on ("),this.compileList(e),this.append(")")}compileList(e,t=", "){let n=e.length-1;for(let r=0;r<=n;r++)this.visitNode(e[r]),r<n&&this.append(t)}visitWhere(e){this.append("where "),this.visitNode(e.where)}visitHaving(e){this.append("having "),this.visitNode(e.having)}visitInsertQuery(e){let t=this.parentNode!==void 0&&!Yu.is(this.parentNode)&&!Ar.is(this.parentNode)&&!$f.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append(e.replace?"replace":"insert"),e.ignore&&(pg("`InsertQueryNode.ignore` is deprecated. Use `InsertQueryNode.orAction` instead."),this.append(" ignore")),e.orAction&&(this.append(" "),this.visitNode(e.orAction)),e.top&&(this.append(" "),this.visitNode(e.top)),e.into&&(this.append(" into "),this.visitNode(e.into)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.output&&(this.append(" "),this.visitNode(e.output)),e.values&&(this.append(" "),this.visitNode(e.values)),e.defaultValues&&(this.append(" "),this.append("default values")),e.onConflict&&(this.append(" "),this.visitNode(e.onConflict)),e.onDuplicateKey&&(this.append(" "),this.visitNode(e.onDuplicateKey)),e.returning&&(this.append(" "),this.visitNode(e.returning)),t&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitValues(e){this.append("values "),this.compileList(e.values)}visitDeleteQuery(e){let t=this.parentNode!==void 0&&!Yu.is(this.parentNode)&&!Ar.is(this.parentNode);this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("delete "),e.top&&(this.visitNode(e.top),this.append(" ")),this.visitNode(e.from),e.output&&(this.append(" "),this.visitNode(e.output)),e.using&&(this.append(" "),this.visitNode(e.using)),e.joins&&(this.append(" "),this.compileList(e.joins," ")),e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),t&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitReturning(e){this.append("returning "),this.compileList(e.selections)}visitAlias(e){this.visitNode(e.node),this.append(" as "),this.visitNode(e.alias)}visitReference(e){e.table&&(this.visitNode(e.table),this.append(".")),this.visitNode(e.column)}visitSelectAll(e){this.append("*")}visitIdentifier(e){this.append(this.getLeftIdentifierWrapper()),this.compileUnwrappedIdentifier(e),this.append(this.getRightIdentifierWrapper())}compileUnwrappedIdentifier(e){if(!go(e.name))throw new Error("a non-string identifier was passed to compileUnwrappedIdentifier.");this.append(this.sanitizeIdentifier(e.name))}visitAnd(e){this.visitNode(e.left),this.append(" and "),this.visitNode(e.right)}visitOr(e){this.visitNode(e.left),this.append(" or "),this.visitNode(e.right)}visitValue(e){e.immediate?this.appendImmediateValue(e.value):this.appendValue(e.value)}visitValueList(e){this.append("("),this.compileList(e.values),this.append(")")}visitTuple(e){this.append("("),this.compileList(e.values),this.append(")")}visitPrimitiveValueList(e){this.append("(");let{values:t}=e;for(let n=0;n<t.length;++n)this.appendValue(t[n]),n!==t.length-1&&this.append(", ");this.append(")")}visitParens(e){this.append("("),this.visitNode(e.node),this.append(")")}visitJoin(e){this.append(lxe[e.joinType]),this.append(" "),this.visitNode(e.table),e.on&&(this.append(" "),this.visitNode(e.on))}visitOn(e){this.append("on "),this.visitNode(e.on)}visitRaw(e){let{sqlFragments:t,parameters:n}=e;for(let r=0;r<t.length;++r)this.append(t[r]),n.length>r&&this.visitNode(n[r])}visitOperator(e){this.append(e.operator)}visitTable(e){this.visitNode(e.table)}visitSchemableIdentifier(e){e.schema&&(this.visitNode(e.schema),this.append(".")),this.visitNode(e.identifier)}visitCreateTable(e){this.append("create "),e.frontModifiers&&e.frontModifiers.length>0&&(this.compileList(e.frontModifiers," "),this.append(" ")),e.temporary&&this.append("temporary "),this.append("table "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.table),e.selectQuery?(this.append(" as "),this.visitNode(e.selectQuery)):(this.append(" ("),this.compileList([...e.columns,...e.constraints??[]]),this.append(")"),e.onCommit&&(this.append(" on commit "),this.append(e.onCommit)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," ")))}visitColumnDefinition(e){e.ifNotExists&&this.append("if not exists "),this.visitNode(e.column),this.append(" "),this.visitNode(e.dataType),e.unsigned&&this.append(" unsigned"),e.frontModifiers&&e.frontModifiers.length>0&&(this.append(" "),this.compileList(e.frontModifiers," ")),e.generated&&(this.append(" "),this.visitNode(e.generated)),e.identity&&this.append(" identity"),e.defaultTo&&(this.append(" "),this.visitNode(e.defaultTo)),e.notNull&&this.append(" not null"),e.unique&&this.append(" unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.primaryKey&&this.append(" primary key"),e.autoIncrement&&(this.append(" "),this.append(this.getAutoIncrement())),e.references&&(this.append(" "),this.visitNode(e.references)),e.check&&(this.append(" "),this.visitNode(e.check)),e.endModifiers&&e.endModifiers.length>0&&(this.append(" "),this.compileList(e.endModifiers," "))}getAutoIncrement(){return"auto_increment"}visitReferences(e){this.append("references "),this.visitNode(e.table),this.append(" ("),this.compileList(e.columns),this.append(")"),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate))}visitDropTable(e){this.append("drop table "),e.ifExists&&this.append("if exists "),this.visitNode(e.table),e.cascade&&this.append(" cascade")}visitDataType(e){this.append(e.dataType)}visitOrderBy(e){this.append("order by "),this.compileList(e.items)}visitOrderByItem(e){this.visitNode(e.orderBy),e.collation&&(this.append(" "),this.visitNode(e.collation)),e.direction&&(this.append(" "),this.visitNode(e.direction)),e.nulls&&(this.append(" nulls "),this.append(e.nulls))}visitGroupBy(e){this.append("group by "),this.compileList(e.items)}visitGroupByItem(e){this.visitNode(e.groupBy)}visitUpdateQuery(e){let t=this.parentNode!==void 0&&!Yu.is(this.parentNode)&&!Ar.is(this.parentNode)&&!$f.is(this.parentNode);if(this.parentNode===void 0&&e.explain&&(this.visitNode(e.explain),this.append(" ")),t&&this.append("("),e.with&&(this.visitNode(e.with),this.append(" ")),this.append("update "),e.top&&(this.visitNode(e.top),this.append(" ")),e.table&&(this.visitNode(e.table),this.append(" ")),this.append("set "),e.updates&&this.compileList(e.updates),e.output&&(this.append(" "),this.visitNode(e.output)),e.from&&(this.append(" "),this.visitNode(e.from)),e.joins){if(!e.from)throw new Error("Joins in an update query are only supported as a part of a PostgreSQL 'update set from join' query. If you want to create a MySQL 'update join set' query, see https://kysely.dev/docs/examples/update/my-sql-joins");this.append(" "),this.compileList(e.joins," ")}e.where&&(this.append(" "),this.visitNode(e.where)),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),e.limit&&(this.append(" "),this.visitNode(e.limit)),e.returning&&(this.append(" "),this.visitNode(e.returning)),t&&this.append(")"),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitColumnUpdate(e){this.visitNode(e.column),this.append(" = "),this.visitNode(e.value)}visitLimit(e){this.append("limit "),this.visitNode(e.limit)}visitOffset(e){this.append("offset "),this.visitNode(e.offset)}visitOnConflict(e){this.append("on conflict"),e.columns?(this.append(" ("),this.compileList(e.columns),this.append(")")):e.constraint?(this.append(" on constraint "),this.visitNode(e.constraint)):e.indexExpression&&(this.append(" ("),this.visitNode(e.indexExpression),this.append(")")),e.indexWhere&&(this.append(" "),this.visitNode(e.indexWhere)),e.doNothing===!0?this.append(" do nothing"):e.updates&&(this.append(" do update set "),this.compileList(e.updates),e.updateWhere&&(this.append(" "),this.visitNode(e.updateWhere)))}visitOnDuplicateKey(e){this.append("on duplicate key update "),this.compileList(e.updates)}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.using&&(this.append(" using "),this.visitNode(e.using)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.nullsNotDistinct&&this.append(" nulls not distinct"),e.where&&(this.append(" "),this.visitNode(e.where))}visitDropIndex(e){this.append("drop index "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.table&&(this.append(" on "),this.visitNode(e.table)),e.cascade&&this.append(" cascade")}visitCreateSchema(e){this.append("create schema "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.schema)}visitDropSchema(e){this.append("drop schema "),e.ifExists&&this.append("if exists "),this.visitNode(e.schema),e.cascade&&this.append(" cascade")}visitPrimaryKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("primary key ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}buildDeferrable(e){e.deferrable!==void 0&&(e.deferrable?this.append(" deferrable"):this.append(" not deferrable")),e.initiallyDeferred!==void 0&&(e.initiallyDeferred?this.append(" initially deferred"):this.append(" initially immediate"))}visitUniqueConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("unique"),e.nullsNotDistinct&&this.append(" nulls not distinct"),this.append(" ("),this.compileList(e.columns),this.append(")"),this.buildDeferrable(e)}visitCheckConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("check ("),this.visitNode(e.expression),this.append(")")}visitForeignKeyConstraint(e){e.name&&(this.append("constraint "),this.visitNode(e.name),this.append(" ")),this.append("foreign key ("),this.compileList(e.columns),this.append(") "),this.visitNode(e.references),e.onDelete&&(this.append(" on delete "),this.append(e.onDelete)),e.onUpdate&&(this.append(" on update "),this.append(e.onUpdate)),this.buildDeferrable(e)}visitList(e){this.compileList(e.items)}visitWith(e){this.append("with "),e.recursive&&this.append("recursive "),this.compileList(e.expressions)}visitCommonTableExpression(e){this.visitNode(e.name),this.append(" as "),hk(e.materialized)&&(e.materialized||this.append("not "),this.append("materialized ")),this.visitNode(e.expression)}visitCommonTableExpressionName(e){this.visitNode(e.table),e.columns&&(this.append("("),this.compileList(e.columns),this.append(")"))}visitAlterTable(e){this.append("alter table "),this.visitNode(e.table),this.append(" "),e.renameTo&&(this.append("rename to "),this.visitNode(e.renameTo)),e.setSchema&&(this.append("set schema "),this.visitNode(e.setSchema)),e.addConstraint&&this.visitNode(e.addConstraint),e.dropConstraint&&this.visitNode(e.dropConstraint),e.renameConstraint&&this.visitNode(e.renameConstraint),e.columnAlterations&&this.compileColumnAlterations(e.columnAlterations),e.addIndex&&this.visitNode(e.addIndex),e.dropIndex&&this.visitNode(e.dropIndex)}visitAddColumn(e){this.append("add column "),this.visitNode(e.column)}visitRenameColumn(e){this.append("rename column "),this.visitNode(e.column),this.append(" to "),this.visitNode(e.renameTo)}visitDropColumn(e){this.append("drop column "),this.visitNode(e.column)}visitAlterColumn(e){this.append("alter column "),this.visitNode(e.column),this.append(" "),e.dataType&&(this.announcesNewColumnDataType()&&this.append("type "),this.visitNode(e.dataType),e.dataTypeExpression&&(this.append("using "),this.visitNode(e.dataTypeExpression))),e.setDefault&&(this.append("set default "),this.visitNode(e.setDefault)),e.dropDefault&&this.append("drop default"),e.setNotNull&&this.append("set not null"),e.dropNotNull&&this.append("drop not null")}visitModifyColumn(e){this.append("modify column "),this.visitNode(e.column)}visitAddConstraint(e){this.append("add "),this.visitNode(e.constraint)}visitDropConstraint(e){this.append("drop constraint "),e.ifExists&&this.append("if exists "),this.visitNode(e.constraintName),e.modifier==="cascade"?this.append(" cascade"):e.modifier==="restrict"&&this.append(" restrict")}visitRenameConstraint(e){this.append("rename constraint "),this.visitNode(e.oldName),this.append(" to "),this.visitNode(e.newName)}visitSetOperation(e){this.append(e.operator),this.append(" "),e.all&&this.append("all "),this.visitNode(e.expression)}visitCreateView(e){this.append("create "),e.orReplace&&this.append("or replace "),e.materialized&&this.append("materialized "),e.temporary&&this.append("temporary "),this.append("view "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),this.append(" "),e.columns&&(this.append("("),this.compileList(e.columns),this.append(") ")),e.as&&(this.append("as "),this.visitNode(e.as))}visitRefreshMaterializedView(e){this.append("refresh materialized view "),e.concurrently&&this.append("concurrently "),this.visitNode(e.name),e.withNoData?this.append(" with no data"):this.append(" with data")}visitDropView(e){this.append("drop "),e.materialized&&this.append("materialized "),this.append("view "),e.ifExists&&this.append("if exists "),this.visitNode(e.name),e.cascade&&this.append(" cascade")}visitGenerated(e){this.append("generated "),e.always&&this.append("always "),e.byDefault&&this.append("by default "),this.append("as "),e.identity&&this.append("identity"),e.expression&&(this.append("("),this.visitNode(e.expression),this.append(")")),e.stored&&this.append(" stored")}visitDefaultValue(e){this.append("default "),this.visitNode(e.defaultValue)}visitSelectModifier(e){e.rawModifier?this.visitNode(e.rawModifier):this.append(axe[e.modifier]),e.of&&(this.append(" of "),this.compileList(e.of,", "))}visitCreateType(e){this.append("create type "),this.visitNode(e.name),e.enum&&(this.append(" as enum "),this.visitNode(e.enum))}visitDropType(e){this.append("drop type "),e.ifExists&&this.append("if exists "),this.visitNode(e.name)}visitExplain(e){this.append("explain"),(e.options||e.format)&&(this.append(" "),this.append(this.getLeftExplainOptionsWrapper()),e.options&&(this.visitNode(e.options),e.format&&this.append(this.getExplainOptionsDelimiter())),e.format&&(this.append("format"),this.append(this.getExplainOptionAssignment()),this.append(e.format)),this.append(this.getRightExplainOptionsWrapper()))}visitDefaultInsertValue(e){this.append("default")}visitAggregateFunction(e){this.append(e.func),this.append("("),e.distinct&&this.append("distinct "),this.compileList(e.aggregated),e.orderBy&&(this.append(" "),this.visitNode(e.orderBy)),this.append(")"),e.withinGroup&&(this.append(" within group ("),this.visitNode(e.withinGroup),this.append(")")),e.filter&&(this.append(" filter("),this.visitNode(e.filter),this.append(")")),e.over&&(this.append(" "),this.visitNode(e.over))}visitOver(e){this.append("over("),e.partitionBy&&(this.visitNode(e.partitionBy),e.orderBy&&this.append(" ")),e.orderBy&&this.visitNode(e.orderBy),this.append(")")}visitPartitionBy(e){this.append("partition by "),this.compileList(e.items)}visitPartitionByItem(e){this.visitNode(e.partitionBy)}visitBinaryOperation(e){this.visitNode(e.leftOperand),this.append(" "),this.visitNode(e.operator),this.append(" "),this.visitNode(e.rightOperand)}visitUnaryOperation(e){this.visitNode(e.operator),this.isMinusOperator(e.operator)||this.append(" "),this.visitNode(e.operand)}isMinusOperator(e){return Od.is(e)&&e.operator==="-"}visitUsing(e){this.append("using "),this.compileList(e.tables)}visitFunction(e){this.append(e.func),this.append("("),this.compileList(e.arguments),this.append(")")}visitCase(e){this.append("case"),e.value&&(this.append(" "),this.visitNode(e.value)),e.when&&(this.append(" "),this.compileList(e.when," ")),e.else&&(this.append(" else "),this.visitNode(e.else)),this.append(" end"),e.isStatement&&this.append(" case")}visitWhen(e){this.append("when "),this.visitNode(e.condition),e.result&&(this.append(" then "),this.visitNode(e.result))}visitJSONReference(e){this.visitNode(e.reference),this.visitNode(e.traversal)}visitJSONPath(e){e.inOperator&&this.visitNode(e.inOperator),this.append("'$");for(let t of e.pathLegs)this.visitNode(t);this.append("'")}visitJSONPathLeg(e){let t=e.type==="ArrayLocation";this.append(t?"[":"."),this.append(String(e.value)),t&&this.append("]")}visitJSONOperatorChain(e){for(let t=0,n=e.values.length;t<n;t++)t===n-1?this.visitNode(e.operator):this.append("->"),this.visitNode(e.values[t])}visitMergeQuery(e){e.with&&(this.visitNode(e.with),this.append(" ")),this.append("merge "),e.top&&(this.visitNode(e.top),this.append(" ")),this.append("into "),this.visitNode(e.into),e.using&&(this.append(" "),this.visitNode(e.using)),e.whens&&(this.append(" "),this.compileList(e.whens," ")),e.returning&&(this.append(" "),this.visitNode(e.returning)),e.output&&(this.append(" "),this.visitNode(e.output)),e.endModifiers?.length&&(this.append(" "),this.compileList(e.endModifiers," "))}visitMatched(e){e.not&&this.append("not "),this.append("matched"),e.bySource&&this.append(" by source")}visitAddIndex(e){this.append("add "),e.unique&&this.append("unique "),this.append("index "),this.visitNode(e.name),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.using&&(this.append(" using "),this.visitNode(e.using))}visitCast(e){this.append("cast("),this.visitNode(e.expression),this.append(" as "),this.visitNode(e.dataType),this.append(")")}visitFetch(e){this.append("fetch next "),this.visitNode(e.rowCount),this.append(` rows ${e.modifier}`)}visitOutput(e){this.append("output "),this.compileList(e.selections)}visitTop(e){this.append(`top(${e.expression})`),e.modifiers&&this.append(` ${e.modifiers}`)}visitOrAction(e){this.append(e.action)}visitCollate(e){this.append("collate "),this.visitNode(e.collation)}append(e){this.#e+=e}appendValue(e){this.addParameter(e),this.append(this.getCurrentParameterPlaceholder())}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getCurrentParameterPlaceholder(){return"$"+this.numParameters}getLeftExplainOptionsWrapper(){return"("}getExplainOptionAssignment(){return" "}getExplainOptionsDelimiter(){return", "}getRightExplainOptionsWrapper(){return")"}sanitizeIdentifier(e){let t=this.getLeftIdentifierWrapper(),n=this.getRightIdentifierWrapper(),r="";for(let i of e)r+=i,i===t?r+=t:i===n&&(r+=n);return r}sanitizeStringLiteral(e){return e.replace(sxe,"''")}addParameter(e){this.#t.push(e)}appendImmediateValue(e){if(go(e))this.appendStringLiteral(e);else if(xk(e)||hk(e)||DA(e))this.append(e.toString());else if(AA(e))this.append("null");else if(V0e(e))this.appendImmediateValue(e.toISOString());else throw new Error(`invalid immediate value ${e}`)}appendStringLiteral(e){this.append("'"),this.append(this.sanitizeStringLiteral(e)),this.append("'")}sortSelectModifiers(e){return e.sort((t,n)=>t.modifier&&n.modifier?_4[t.modifier]-_4[n.modifier]:1),O(e)}compileColumnAlterations(e){this.compileList(e)}announcesNewColumnDataType(){return!0}},axe=O({ForKeyShare:"for key share",ForNoKeyUpdate:"for no key update",ForUpdate:"for update",ForShare:"for share",NoWait:"nowait",SkipLocked:"skip locked",Distinct:"distinct"}),_4=O({ForKeyShare:1,ForNoKeyUpdate:1,ForUpdate:1,ForShare:1,NoWait:2,SkipLocked:2,Distinct:0}),lxe=O({InnerJoin:"inner join",LeftJoin:"left join",RightJoin:"right join",FullJoin:"full join",CrossJoin:"cross join",LateralInnerJoin:"inner join lateral",LateralLeftJoin:"left join lateral",LateralCrossJoin:"cross join lateral",OuterApply:"outer apply",CrossApply:"cross apply",Using:"using"}),uxe=class{async init(){}async acquireConnection(){return new cxe}async beginTransaction(){}async commitTransaction(){}async rollbackTransaction(){}async releaseConnection(){}async destroy(){}async releaseSavepoint(){}async rollbackToSavepoint(){}async savepoint(){}},cxe=class{async executeQuery(){return{rows:[]}}async*streamQuery(){}},KA=class{get supportsCreateIfNotExists(){return!0}get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}get supportsOutput(){return!1}},dxe=/"/g,CW=class extends $A{visitOrAction(e){this.append("or "),this.append(e.action)}getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return'"'}getRightIdentifierWrapper(){return'"'}getAutoIncrement(){return"autoincrement"}sanitizeIdentifier(e){return e.replace(dxe,'""')}visitDefaultInsertValue(e){this.append("null")}},NW=class extends KA{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!0}async acquireMigrationLock(e,t){}async releaseMigrationLock(e,t){}},hxe=/"/g,MW=class extends $A{sanitizeIdentifier(e){return e.replace(hxe,'""')}},fxe=BigInt("3853314791062309107"),_W=class extends KA{get supportsTransactionalDdl(){return!0}get supportsReturning(){return!0}async acquireMigrationLock(e,t){await Fe`select pg_advisory_xact_lock(${Fe.lit(fxe)})`.execute(e)}async releaseMigrationLock(e,t){}},pxe=/`/g,EW=class extends $A{getCurrentParameterPlaceholder(){return"?"}getLeftExplainOptionsWrapper(){return""}getExplainOptionAssignment(){return"="}getExplainOptionsDelimiter(){return" "}getRightExplainOptionsWrapper(){return""}getLeftIdentifierWrapper(){return"`"}getRightIdentifierWrapper(){return"`"}sanitizeIdentifier(e){return e.replace(pxe,"``")}visitCreateIndex(e){this.append("create "),e.unique&&this.append("unique "),this.append("index "),e.ifNotExists&&this.append("if not exists "),this.visitNode(e.name),e.using&&(this.append(" using "),this.visitNode(e.using)),e.table&&(this.append(" on "),this.visitNode(e.table)),e.columns&&(this.append(" ("),this.compileList(e.columns),this.append(")")),e.where&&(this.append(" "),this.visitNode(e.where))}},E4="ea586330-2c93-47c8-908d-981d9d270f9d",mxe=3600,OW=class extends KA{get supportsTransactionalDdl(){return!1}get supportsReturning(){return!1}async acquireMigrationLock(e,t){await Fe`select get_lock(${Fe.lit(E4)}, ${Fe.lit(mxe)})`.execute(e)}async releaseMigrationLock(e,t){await Fe`select release_lock(${Fe.lit(E4)})`.execute(e)}};function ob(e){return e.trim().replace(/^where\b/i,"").trim().replace(/;+$/u,"").trim()}function TW(e){return e.trim().replace(/;+$/u,"").includes(";")}function yg(e){return new HA({dialect:{createAdapter:()=>new e.Adapter,createDriver:()=>new uxe,createIntrospector:()=>null,createQueryCompiler:()=>new e.QueryCompiler},plugins:[...e.noParameters?[new gxe]:[]]})}var gxe=class{#e=new yxe;transformQuery(e){return this.#e.transformNode(e.node)}transformResult(e){return Promise.resolve(e.result)}},yxe=class extends FA{transformPrimitiveValueList(e){return tb.create(e.values.map(yo.createImmediate))}transformValue(e){return{...super.transformValue(e),immediate:!0}}};function Zu(e){return typeof e=="string"?{parameters:[],sql:e}:e}function hr(e,t){let n=e.compile();return{parameters:n.parameters,sql:n.sql,transformations:t?.transformations}}function Ka(e,t){let n=vxe(e,t);return r=>r.where(i=>i.or(n.map(o=>i.and(o.map(([s,a])=>i(s,a===null?"is":Array.isArray(a)?"in":"=",a))))))}function Ck(e,t){let n={};for(let r of Object.values(t)){let{name:i,pkPosition:o}=r;o!=null&&(n[i]=e[i]??null)}return n}function vxe(e,t){let n=[],r=[],i=ks();for(let a of e){let l=[];for(let u of Object.values(t)){let{name:c,pkPosition:d}=u;if(d==null)continue;let h=d-1;a===e.at(0)&&(n[h]=i.ref(c)),l[h]=YA(a[c]??null,u)}r.push(n.length===1?l.at(0):O4(l))}let o=n.length===1?n.at(0):O4(n),s=r.length===1?r.at(0):r;return[[[o,s]]]}function O4(e){return Fe`(${Fe.join(e,Fe`, `)})`}function ec(e){let{values:t}=e;return()=>Array.isArray(t)?t.map(n=>T4({...e,values:n})):T4({...e,values:t})}function T4(e){let{columns:t,context:n,supportsDefaultKeyword:r,values:i}=e,o=Object.entries(i),s=n==="update"?[]:Object.values(t).filter(a=>a.isRequired);return n==="insert"&&o.length===0&&s.length===0?{[Object.keys(t).at(0)]:r?Fe`default`:null}:o.reduce((a,[l,u])=>({...a,[l]:YA(u,t[l],r)}),s.reduce((a,l)=>{let{datatype:u,fkColumn:c,name:d}=l,{format:h,group:f,isArray:p}=u;return c?a:p||f==="json"?{...a,[d]:Yf}:f==="boolean"?{...a,[d]:wk}:f==="string"?{...a,[d]:j0e}:f==="numeric"?{...a,[d]:eb}:(f==="datetime"||f==="time")&&h?{...a,[d]:Ju(h)}:a},{}))}function YA(e,t,n=!0){let{datatype:r,defaultValue:i,nullable:o}=t,s=ks();return e===null||e===""&&o?s.lit(null):(e===""||e===void 0)&&i!=null?n?Fe`default`:s.lit(null):r.isNative?s.val(e):s.cast(s.val(e),Fe.id(r.schema,r.name))}function Xf(e,t){if(e.length===0)return i=>i.lit(!0);let n=[],r=[];for(let i=0;i<e.length;i++)r.push(wxe(e[i],t)),(i===e.length-1||e[i].after==="or")&&(n.push(r),r=[]);return i=>{let o=n.map(s=>i.and(s.map(a=>a(i))));return i.or(o)}}var bxe=new Set(["ilike","like","not ilike","not like"]);function wxe(e,t){if(e.kind==="ColumnFilter")return n=>{let{column:r,operator:i,value:o}=e,s=t[r];if(bxe.has(i)){let a=typeof o=="string"?o:String(o??"");return n(n.cast(r,"text"),i,a)}return n(s.datatype.group==="raw"?n.cast(r,"text"):r,i,YA(o,s))};if(e.kind==="SqlFilter"){let n=ob(e.sql);return r=>n.length>0?Fe`(${Fe.raw(n)})`:r.lit(!0)}return Xf(e.filters,t)}function QA(e){let t={blockCommentDepth:0,dollarQuoteDelimiter:"",mode:"normal"},n=[],r=0,i=0;for(;i<e.length;){let o=e[i],s=e[i+1];if(t.mode==="single-quote"){if(o==="'"&&s==="'"){i+=2;continue}o==="'"&&(t.mode="normal"),i+=1;continue}if(t.mode==="double-quote"){if(o==='"'&&s==='"'){i+=2;continue}o==='"'&&(t.mode="normal"),i+=1;continue}if(t.mode==="line-comment"){o===`
`&&(t.mode="normal"),i+=1;continue}if(t.mode==="block-comment"){if(o==="/"&&s==="*"){t.blockCommentDepth+=1,i+=2;continue}if(o==="*"&&s==="/"){t.blockCommentDepth-=1,i+=2,t.blockCommentDepth<=0&&(t.blockCommentDepth=0,t.mode="normal");continue}i+=1;continue}if(t.mode==="dollar-quote"){let a=t.dollarQuoteDelimiter;if(a&&e.startsWith(a,i)){t.dollarQuoteDelimiter="",t.mode="normal",i+=a.length;continue}i+=1;continue}if(o==="'"){t.mode="single-quote",i+=1;continue}if(o==='"'){t.mode="double-quote",i+=1;continue}if(o==="-"&&s==="-"){t.mode="line-comment",i+=2;continue}if(o==="/"&&s==="*"){t.mode="block-comment",t.blockCommentDepth=1,i+=2;continue}if(o==="$"){let a=xxe(e,i);if(a){t.mode="dollar-quote",t.dollarQuoteDelimiter=a,i+=a.length;continue}}o===";"&&(A4(e,r,i,n),r=i+1),i+=1}return A4(e,r,e.length,n),n}function AW(e){let{sql:t}=e,n=Sxe(e.cursorIndex,0,t.length),r=QA(t);if(r.length===0)return null;for(let s of r)if(n>=s.from&&n<=s.to)return s;let i=r[0],o=D4(n,i);for(let s of r.slice(1)){let a=D4(n,s);a<o&&(o=a,i=s)}return i}function A4(e,t,n,r){if(n<=t)return;let i=e.slice(t,n),o=i.trim();if(o.length===0)return;let s=i.length-i.trimStart().length,a=i.length-i.trimEnd().length,l=t+s,u=n-a;r.push({from:l,statement:o,to:u})}function D4(e,t){return e<t.from?t.from-e:e>t.to?e-t.to:0}function xxe(e,t){if(e[t]!=="$")return null;let n=t+1;for(;n<e.length;){let r=e[n];if(r==="$"){let i=e.slice(t,n+1);return i==="$$"||/^\$[A-Za-z_][A-Za-z0-9_]*\$$/.test(i)?i:null}if(!/[A-Za-z0-9_]/.test(r))return null;n+=1}return null}function Sxe(e,t,n){return Math.min(n,Math.max(t,e))}function DW(e,t){let n=[];for(let{selection:r}of e.selections??[])if(Qf.is(r)&&$n.is(r.column))n.push(GA(r.column.column.name),XA(t,r.column.column.name));else if($n.is(r))n.push(GA(r.column.name),XA(t,r.column.name));else if($a.is(r)&&un.is(r.alias))n.push(GA(r.alias.name),XA(t,r.alias.name));else throw new Error("can't extract column names from the select query node");return n}function GA(e){return new wn(yo.createImmediate(e))}function XA(e,t){return new wn(Qf.create($n.create(t),ta.create(e)))}var xmt=L(H(),1),Smt=L(rn(),1);function Td(e){let{adapterSource:t,error:n,query:r}=e,i=n;return i.adapterSource=t,i.query=r,[i]}var Cmt=L(H(),1),Nmt=L(rn(),1);var kxe=1024,RW=50*kxe,Cxe=new Set(["delete","insert","select","update","values","with"]);function vg(e){let t=e.trim();if(t.length===0)return{diagnostic:{from:0,message:"Type a SQL statement to lint.",severity:"info",to:0},ok:!1};if(t.length>RW)return{diagnostic:{from:0,message:`SQL lint limit exceeded (${RW} characters).`,severity:"error",to:Math.min(1,t.length)},ok:!1};let n=QA(e);if(n.length===0)return{diagnostic:{from:0,message:"Type a SQL statement to lint.",severity:"info",to:0},ok:!1};for(let r of n){let i=Nxe(r.statement);if(!i||!Cxe.has(i))return{diagnostic:{from:r.from,message:"SQL lint supports SELECT, WITH, VALUES, INSERT, UPDATE, and DELETE statements.",severity:"error",to:Math.min(e.length,r.from+1)},ok:!1}}return{ok:!0,statements:n}}function JA(e){let{error:t,sql:n}=e,r=Math.max(0,e.positionOffset??0),i=IW({sql:n,position:void 0,sqlLength:n.length});if(!(t instanceof Error))return[{from:i.from,message:"SQL lint failed.",severity:"error",source:"postgres",to:i.to}];let o=Mxe(t),s=Exe(t),{from:a,to:l}=IW({message:t.message,position:_xe(t),sql:n,sqlLength:n.length}),u=o==="57014"?"Lint query timed out. Simplify the statement and try again.":t.message;return[{code:o,from:a+r,message:u,severity:s,source:"postgres",to:l+r}]}function Nxe(e){return/^\s*([A-Za-z_]+)/.exec(e)?.[1]?.toLowerCase()??null}function Mxe(e){let t=e;return typeof t.code=="string"?t.code:void 0}function _xe(e){let t=e,{position:n}=t;if(typeof n=="number"&&Number.isFinite(n))return n;if(typeof n=="string"){let r=Number.parseInt(n,10);return Number.isFinite(r)?r:void 0}}function Exe(e){return e.severity==="WARNING"?"warning":"error"}function IW(e){let{message:t,position:n,sql:r,sqlLength:i}=e;if(n==null&&t){let a=Oxe(r,t);if(a)return a}let o=Math.max(i-1,0),s=Math.min(o,Math.max(0,(Number.isFinite(n)?n:1)-1));return i===0?{from:0,to:0}:{from:s,to:Math.max(s+1,s)}}function Oxe(e,t){let n=/"([^"]+)"/.exec(t)?.[1];if(!n)return null;let r=e.toLowerCase(),i=n.toLowerCase(),o=r.indexOf(i);return o<0?null:{from:o,to:Math.min(e.length,o+n.length)}}var Emt=L(H(),1),Omt=L(rn(),1);var Txe="Search timed out after 5 seconds. This kind of search is expensive, and your table might be too large.",Axe=class extends Error{constructor(){super(Txe),this.name="FullTableSearchTimeoutError"}},Dxe=/^[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,Rxe=/^[+-]?(?:\d+|\d*\.\d+)$/,Ixe=/^(\d{4})$/,Pxe=/^(\d{4})-(\d{2})$/,Lxe=/^(\d{4})-(\d{2})-(\d{2})$/,Bxe=/^(\d{4})-(\d{2})-(\d{2})(?:[T ]?([01]\d|2[0-3])(?::([0-5]\d)(?::([0-5]\d)(?:\.(\d{1,3}))?)?)?)(?:[Zz])?$/,qxe=/^([01]\d|2[0-3])(?::([0-5]\d)(?::([0-5]\d)(?:\.(\d{1,6}))?)?)?$/;function bg(){return{activeController:null,latestRequestId:0}}function ab(e){return(e?.trim().length??0)>0}async function wg(e){let{executor:t,options:n,query:r,searchTerm:i,state:o}=e;if(!ab(i))return await t.execute(r,n);let s=new AbortController,a=new AbortController;o.latestRequestId+=1;let l=o.latestRequestId,u=setTimeout(()=>{a.abort()},5e3);o.activeController?.abort(),o.activeController=s;let c=Qxe([n.abortSignal,s.signal,a.signal]);try{let[d,h]=await t.execute(r,{abortSignal:c.signal});return d&&a.signal.aborted?[new Axe]:d?[d]:[null,h]}finally{clearTimeout(u),c.cleanup(),o.latestRequestId===l&&(o.activeController=null)}}function xg(e){let t=e.searchTerm?.trim()??"";if(t.length===0)return{normalizedSearchTerm:t,predicates:[]};let n=Object.values(e.table.columns),r=[],i=Vxe(t),o=Wxe(t),s=Uxe(t),a=Hxe(t),l=Kxe(t);if(t.length>=2){let u=`%${zxe(t)}%`,c=n.filter(d=>Fxe(d)).slice(0,64);for(let d of c)r.push({column:d.name,kind:"text-like",pattern:u})}if(i!==void 0)for(let u of n)u.datatype.group!=="boolean"||u.datatype.isArray||r.push({column:u.name,kind:"boolean-equals",value:i});if(o!==null)for(let u of n)u.datatype.group!=="numeric"||u.datatype.isArray||r.push({column:u.name,kind:"numeric-equals",value:o});if(s!==null)for(let u of n)LW(u)&&r.push({column:u.name,kind:"uuid-equals",value:s});if(a!==null)for(let u of n)u.datatype.group!=="datetime"||u.datatype.isArray||r.push({column:u.name,endExclusive:a.endExclusive,kind:"datetime-day-range",startInclusive:a.startInclusive});if(l!==null)for(let u of n)u.datatype.group!=="time"||u.datatype.isArray||r.push({column:u.name,kind:"time-equals",value:l});return{normalizedSearchTerm:t,predicates:r}}function Sg(e,t){let{dialect:n}=t;return r=>e.predicates.length===0?r.lit(!0):r.or(e.predicates.map(i=>{switch(i.kind){case"text-like":{if(n==="postgres")return r(r.cast(i.column,"text"),"ilike",i.pattern);let o=n==="mysql"?"char":"text";return r(r.fn("lower",[r.cast(i.column,o)]),"like",i.pattern.toLowerCase())}case"numeric-equals":return r(r.cast(i.column,PW(n)),"=",r.cast(r.val(i.value),PW(n)));case"boolean-equals":return r(i.column,"=",i.value);case"uuid-equals":return r(i.column,"=",i.value);case"datetime-day-range":return r.and([r(i.column,">=",i.startInclusive),r(i.column,"<",i.endExclusive)]);case"time-equals":return r(i.column,"=",i.value)}}))}function PW(e){return e==="mysql"?"decimal":"numeric"}function zxe(e){return e.replaceAll("%","\\%").replaceAll("_","\\_")}function Fxe(e){return e.datatype.isArray||jxe(e)?!1:e.datatype.group==="enum"?!0:e.datatype.group!=="string"?!1:!LW(e)}function jxe(e){let t=e.datatype.name.toLowerCase();return t.includes("blob")||t.includes("bytea")||t.includes("binary")}function LW(e){return e.datatype.isArray?!1:e.datatype.name.toLowerCase()==="uuid"}function Vxe(e){let t=e.toLowerCase();if(["true","t","1","yes","y","on"].includes(t))return!0;if(["false","f","0","no","n","off"].includes(t))return!1}function Wxe(e){return Rxe.test(e)?e:null}function Uxe(e){return Dxe.test(e)?e:null}function Hxe(e){let t=$xe(e);if(t)return t;let n=e.match(Ixe);if(n){let c=Number.parseInt(n[1],10),d=sb(c,1,1),h=sb(c+1,1,1);return!d||!h?null:{endExclusive:h.toISOString(),startInclusive:d.toISOString()}}let r=e.match(Pxe);if(r){let c=Number.parseInt(r[1],10),d=Number.parseInt(r[2],10),h=sb(c,d,1),f=d===12?1:d+1,p=d===12?c+1:c,m=sb(p,f,1);return!h||!m?null:{endExclusive:m.toISOString(),startInclusive:h.toISOString()}}let i=e.match(Lxe);if(!i)return null;let o=Number.parseInt(i[1],10),s=Number.parseInt(i[2],10),a=Number.parseInt(i[3],10),l=sb(o,s,a);if(!l)return null;let u=new Date(l);return u.setUTCDate(u.getUTCDate()+1),{endExclusive:u.toISOString(),startInclusive:l.toISOString()}}function $xe(e){let t=e.match(Bxe);if(!t)return null;let n=Number.parseInt(t[1],10),r=Number.parseInt(t[2],10),i=Number.parseInt(t[3],10),o=Number.parseInt(t[4],10),s=Number.parseInt(t[5]??"00",10),a=Number.parseInt(t[6]??"00",10),l=t[7]?Number.parseInt(t[7].padEnd(3,"0"),10):0,u=Yxe({day:i,hour:o,milliseconds:l,minute:s,month:r,second:a,year:n});if(!u)return null;let c=new Date(u);return t[7]!=null?c.setUTCMilliseconds(c.getUTCMilliseconds()+1):t[6]!=null?c.setUTCSeconds(c.getUTCSeconds()+1):t[5]!=null?c.setUTCMinutes(c.getUTCMinutes()+1):c.setUTCHours(c.getUTCHours()+1),{endExclusive:c.toISOString(),startInclusive:u.toISOString()}}function Kxe(e){let t=e.match(qxe);if(!t)return null;let n=t[1],r=t[2]??"00",i=t[3]??"00",o=t[4];return o?`${n}:${r}:${i}.${o}`:`${n}:${r}:${i}`}function sb(e,t,n){let r=new Date(Date.UTC(e,t-1,n));return Number.isNaN(r.getTime())||r.getUTCFullYear()!==e||r.getUTCMonth()!==t-1||r.getUTCDate()!==n?null:r}function Yxe(e){let{day:t,hour:n,milliseconds:r,minute:i,month:o,second:s,year:a}=e,l=new Date(Date.UTC(a,o-1,t,n,i,s,r));return Number.isNaN(l.getTime())||l.getUTCFullYear()!==a||l.getUTCMonth()!==o-1||l.getUTCDate()!==t||l.getUTCHours()!==n||l.getUTCMinutes()!==i||l.getUTCSeconds()!==s||l.getUTCMilliseconds()!==r?null:l}function Qxe(e){let t=new AbortController,n=[],r=i=>{t.signal.aborted||t.abort(i.reason)};for(let i of e){if(!i)continue;if(i.aborted){r(i);continue}let o=()=>r(i);i.addEventListener("abort",o),n.push({listener:o,signal:i})}return{cleanup(){for(let{listener:i,signal:o}of n)o.removeEventListener("abort",i)},signal:t.signal}}var Dmt=L(H(),1),Rmt=L(rn(),1);function tc(e){let{defaultSchema:t,dialect:n,introspection:r}=e,i=Gxe(r),o=Xxe(i);return{defaultSchema:t,dialect:n,namespace:i,version:o}}function Gxe(e){let t={};for(let[n,r]of Object.entries(e.schemas)){let i={};for(let[o,s]of Object.entries(r.tables))i[o]=Object.keys(s.columns).sort((a,l)=>a.localeCompare(l));t[n]=i}return t}function Xxe(e){let t=[],n=Object.keys(e).sort((r,i)=>r.localeCompare(i));for(let r of n){let i=e[r]??{},o=Object.keys(i).sort((s,a)=>s.localeCompare(a));for(let s of o){let a=[...i[s]??[]].sort((l,u)=>l.localeCompare(u));t.push(`${r}.${s}:${a.join(",")}`)}}return`schema-${Jxe(t.join("|")).toString(36)}`}function Jxe(e){let t=5381;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);t=t*33^r}return t>>>0}var Zxe={bigint:{group:"numeric"},binary:{group:"string"},bit:{group:"raw"},blob:{group:"string"},char:{group:"string"},"char binary":{group:"string"},date:{format:"YYYY-MM-DD",group:"datetime"},datetime:{format:"YYYY-MM-DD HH:mm:ss.SSS",group:"datetime"},dec:{group:"numeric"},decimal:{group:"numeric"},double:{group:"numeric"},"double precision":{group:"numeric"},enum:{group:"enum"},fixed:{group:"numeric"},float:{group:"numeric"},geometry:{group:"raw"},geometrycollection:{group:"raw"},int:{group:"numeric"},integer:{group:"numeric"},json:{group:"json"},linestring:{group:"raw"},long:{group:"string"},"long varchar":{group:"string"},longblob:{group:"string"},longtext:{group:"string"},longvarbinary:{group:"string"},longvarchar:{group:"string"},mediumblob:{group:"string"},mediumint:{group:"numeric"},mediumtext:{group:"string"},multilinestring:{group:"raw"},multipoint:{group:"raw"},multipolygon:{group:"raw"},numeric:{group:"numeric"},point:{group:"raw"},polygon:{group:"raw"},real:{group:"numeric"},set:{group:"raw"},smallint:{group:"numeric"},text:{group:"string"},time:{format:"HH:mm:ss.SSS",group:"time"},timestamp:{format:"YYYY-MM-DD HH:mm:ss.SSS",group:"datetime"},tinyblob:{group:"string"},tinyint:{group:"numeric"},tinytext:{group:"string"},varbinary:{group:"string"},varchar:{group:"string"},"varchar binary":{group:"string"},vector:{group:"raw"},year:{format:"YYYY",group:"numeric"}};function nc(e){return yg({...e,Adapter:OW,QueryCompiler:EW})}function e1e(e,t){let{rows:n,table:{columns:r,name:i}}=e,o=nc(t);return hr(o.deleteFrom(i).$call(Ka(n,r)).$castTo())}function ZA(e,t){let{rows:n,table:{columns:r,name:i}}=e,o=nc(t);return hr(o.insertInto(i).values(ec({columns:r,context:"insert",supportsDefaultKeyword:!0,values:n})).$castTo())}function BW(e,t){let{criteria:n,table:{columns:r,name:i}}=e,o=nc(t);return hr(o.selectFrom(i).$call(Ka(n,r)).select(Object.keys(r)).select(VW().as("__ps_inserted_at__")))}function qW(e,t){let{changes:n,row:r,table:{columns:i,name:o}}=e,s=nc(t);return hr(s.selectFrom(o).$call(Ka([{...r,...n}],i)).select(Object.keys(i)).select(VW().as("__ps_updated_at__")))}function t1e(e,t){let{filter:n={after:"and",filters:[],kind:"FilterGroup"},fullTableSearchTerm:r,pageIndex:i,pageSize:o,sortOrder:s,table:{columns:a,name:l}}=e,u=nc(t),c=Xf(n.filters,a),d=xg({searchTerm:r,table:e.table}),h=d.predicates.length>0?v=>v.and([c(v),Sg(d,{dialect:"mysql"})(v)]):c,f="__ps_agg__",p="__ps_count__",m=ab(r),g=Fe`/*+ MAX_EXECUTION_TIME(${Fe.lit(5e3)}) SET_VAR(lock_wait_timeout=${Fe.lit(1)}) */`,y=u.selectFrom(l).where(h).select(v=>{let b=v.cast(v.fn.coalesce(v.fn.countAll(),Fe.lit(0)),"char");return m?Fe`${g} ${b}`.as(p):b.as(p)});return hr(u.with(f,()=>y).selectFrom(l).innerJoin(f,v=>v.onTrue()).where(h).select(m?Fe`${g} ${Fe.ref(`${f}.${p}`)}`.as(p):`${f}.${p}`).select(Object.keys(a)).$call(v=>s.reduce((b,w)=>b.orderBy(w.column,w.direction),v)).limit(o).offset(Fe.lit(BigInt(i)*BigInt(o))))}function zW(e,t){let{changes:n,row:r,table:{columns:i,name:o,schema:s}}=e,a=nc(t);return hr(a.withSchema(s).updateTable(o).set(ec({columns:i,context:"update",supportsDefaultKeyword:!0,values:n})).$call(Ka([r],i)).$castTo())}function VW(){return Fe`cast(unix_timestamp(now(3)) * 1000 as unsigned)`}function n1e(e){return Fe`json_object(${Fe.join(Object.keys(e).flatMap(t=>[Fe.lit(t),e[t]]))})`}function r1e(e){let t=Fe`database()`,n=nc(e).selectFrom("information_schema.columns as c").leftJoin("information_schema.KEY_COLUMN_USAGE as kcu",r=>r.on("kcu.TABLE_SCHEMA","=",t).onRef("kcu.TABLE_NAME","=","c.TABLE_NAME").onRef("kcu.COLUMN_NAME","=","c.COLUMN_NAME").on("kcu.POSITION_IN_UNIQUE_CONSTRAINT","is not",null)).leftJoin("information_schema.KEY_COLUMN_USAGE as pk_kcu",r=>r.on("pk_kcu.TABLE_SCHEMA","=",t).onRef("pk_kcu.TABLE_NAME","=","c.TABLE_NAME").onRef("pk_kcu.COLUMN_NAME","=","c.COLUMN_NAME").on("pk_kcu.CONSTRAINT_NAME","=","PRIMARY")).where("c.TABLE_SCHEMA","=",t).select(["c.COLUMN_DEFAULT as default","c.COLUMN_NAME as name","c.COLUMN_TYPE as datatype","c.ORDINAL_POSITION as position","c.TABLE_NAME","kcu.REFERENCED_TABLE_NAME as fk_table","kcu.REFERENCED_COLUMN_NAME as fk_column","pk_kcu.ORDINAL_POSITION as pk"]).select(r=>[r("c.EXTRA","=","auto_increment").as("autoincrement"),r("c.EXTRA","in",["on update CURRENT_TIMESTAMP","STORED GENERATED","VIRTUAL GENERATED"]).as("computed"),r("c.IS_NULLABLE","=","YES").as("nullable")]);return hr(nc(e).with("cols",()=>n).selectFrom("information_schema.tables as t").innerJoin("cols as c",r=>r.onRef("c.TABLE_NAME","=","t.TABLE_NAME")).where("t.TABLE_SCHEMA","=",t).where("t.TABLE_TYPE","in",["BASE TABLE","VIEW"]).groupBy([t,"t.TABLE_NAME","t.TABLE_TYPE"]).select([t.as("schema"),"t.TABLE_NAME as name","t.TABLE_TYPE as type"]).$narrowType().select(r=>r.fn("json_arrayagg",[n1e({autoincrement:r.ref("c.autoincrement"),computed:r.ref("c.computed"),datatype:r.ref("c.datatype"),default:r.ref("c.default"),fk_column:r.ref("c.fk_column"),fk_table:r.ref("c.fk_table"),name:r.ref("c.name"),position:r.ref("c.position"),pk:r.ref("c.pk"),nullable:r.ref("c.nullable")})]).as("columns")).orderBy("t.TABLE_SCHEMA").orderBy("t.TABLE_NAME").orderBy("t.TABLE_TYPE"))}function i1e(e){let t=nc(e),n=Fe`@@session.time_zone`;return hr(t.selectNoFrom(t.case().when(n,"=","SYSTEM").then(Fe`@@system_time_zone`).else(n).end().as("timezone")).$narrowType())}function FW(e){let{error:t,sql:n}=e,r=Math.max(0,e.positionOffset??0),i=l1e(n.length);if(!(t instanceof Error))return[{from:i.from+r,message:"SQL lint failed.",severity:"error",source:"mysql",to:i.to+r}];let o=s1e(t),s=u1e(n,t.message)??i;return[{code:o,from:s.from+r,message:a1e({code:o,message:t.message}),severity:"error",source:"mysql",to:s.to+r}]}async function o1e(e,t,n){let r=vg(t.sql);if(!r.ok)return[null,{diagnostics:[r.diagnostic],schemaVersion:t.schemaVersion}];let i=[];for(let o of r.statements)try{let s=Zu(`EXPLAIN ${o.statement}`),[a]=await e.execute(s,n);if(!a)continue;i.push(...FW({error:a,positionOffset:o.from,sql:o.statement}))}catch(s){i.push(...FW({error:s,positionOffset:o.from,sql:o.statement}))}return[null,{diagnostics:i,schemaVersion:t.schemaVersion}]}function s1e(e){let t=e;return typeof t.code=="string"?t.code:void 0}function a1e(e){let{code:t,message:n}=e;return t==="ER_QUERY_TIMEOUT"||t==="ER_QUERY_INTERRUPTED"||n.toLowerCase().includes("maximum statement execution time exceeded")?"Lint query timed out. Simplify the statement and try again.":n}function l1e(e){return e<=0?{from:0,to:0}:{from:0,to:1}}function u1e(e,t){let n=new Set,r=/'([^']+)'/.exec(t);r?.[1]&&n.add(r[1]);let i=/`([^`]+)`/.exec(t);i?.[1]&&n.add(i[1]);let o=/"([^"]+)"/.exec(t);o?.[1]&&n.add(o[1]);let s=/table\s+'([^']+)'\s+doesn't exist/i.exec(t);s?.[1]&&n.add(s[1]);let a=e.toLowerCase();for(let l of n){let u=l.toLowerCase(),c=a.indexOf(u);if(c>=0)return{from:c,to:Math.min(e.length,c+l.length)};let d=u.split(".").at(-1);if(!d)continue;let h=a.indexOf(d);if(h>=0)return{from:h,to:Math.min(e.length,h+d.length)}}return null}function WW(e){let{executor:t,...n}=e,r=bg(),i=typeof t.lintSql=="function",o=l=>Td({...l,adapterSource:"mysql"});async function s(l,u){let c=l.map(f=>zW(f,n)),d=l.map(f=>qW(f,n)),h=c.flatMap((f,p)=>[f,d[p]]);try{if(typeof t.executeTransaction=="function"){let[p,m]=await t.executeTransaction(h,u);if(p)return o({error:p,query:c[0]});let g=[];for(let y=0;y<l.length;y+=1){let v=m[y*2+1],[b]=v??[];if(!b)return o({error:new Error("Updated row not found"),query:c[y]});g.push(b)}return[null,{rows:g,queries:c}]}let f=[];for(let p=0;p<l.length;p+=1){let[[m],g]=await t.executeSequence([c[p],d[p]],u);if(m)return o({error:m,query:c[p]});let[y,v]=g;if(y)return o({error:y,query:c[p]});let[b]=v;if(!b)return o({error:new Error("Updated row not found"),query:c[p]});f.push(b)}return[null,{rows:f,queries:c}]}catch(f){return o({error:f})}}async function a(l){try{let u=r1e(e),c=i1e(e),[[d,h],[f,p]]=await Promise.all([t.execute(u,l),t.execute(c,l)]);if(d)return o({error:d,query:u});let m=f?"UTC":p[0]?.timezone??"UTC";return[null,c1e({query:u,tables:h,timezone:m})]}catch(u){return o({error:u})}}return{capabilities:{fullTableSearch:!0,sqlDialect:"mysql",sqlEditorAutocomplete:!0,sqlEditorLint:!0},async delete(l,u){try{let c=e1e(l,n),[d]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{...l,query:c}]}catch(c){return o({error:c})}},async insert(l,u){try{let{rows:c,table:d}=l,{columns:h}=d,f=Object.values(h).find(w=>w.isAutoincrement),p=c.map(w=>Ck(w,h)),m=p.some(w=>{let x=Object.values(w);return x.length===0||x.some(S=>S==null)});if(!f&&m)return o({error:new Error("Cannot proceed with the insertion, some rows cannot be refetched after insertion."),query:ZA(l,n)});if(!m){let w=ZA(l,n),x=BW({criteria:p,table:d},n),S=[w,x],[[k],C]=await t.executeSequence(S,u),N=Nk(S);if(k)return o({error:k,query:N});let[E,D]=C;return E?o({error:new Error("Failed to refetch inserted rows - please refresh.",{cause:E}),query:N}):[null,{rows:D,query:N}]}let g=await Promise.all(c.map(async w=>{let x=ZA({rows:[w],table:d},n),[S,k]=await t.execute(x,u);if(S)return o({error:S,query:x});let{name:C}=f,N=w[C]||k[0]?.insertId;if(!N)return o({error:new Error("Could not determine value for autoincrement column to refetch inserted row."),query:x});let E=BW({criteria:[{[C]:N}],table:{...d,columns:Object.values(h).reduce((R,T)=>{let{name:B}=T;return R[B]={...T,pkPosition:B===C?1:null},R},{})}},n),[D,q]=await t.execute(E,u),z=Nk([x,E]);if(D)return console.error("Error refetching inserted row:",D),o({error:new Error("Failed to refetch inserted row - please refresh.",{cause:D}),query:z});let[_]=q;return _?[null,{row:_,query:z}]:o({error:new Error("Refetch query returned no results for inserted row."),query:z})})),y=[],v=null,b=[];for(let w=0;w<g.length;w++){let[x,S]=g[w];x?(b.push([w,x]),x.query&&(v=v?Nk([v,x.query]):x.query)):(y.push(S.row),S.query&&(v=v?Nk([v,S.query]):S.query))}return b.length>0?o({error:new AggregateError(b.map(([,w])=>w),`Row${b.length>1?"s":""} ${b.map(([w])=>w).join(", ")} could not be inserted or refetched.`),query:v}):[null,{rows:y,query:v}]}catch(c){return o({error:c})}},async introspect(l){return await a(l)},async sqlSchema(l,u){let[c,d]=await a(u);return c?[c]:[null,tc({defaultSchema:void 0,dialect:"mysql",introspection:d})]},async sqlLint(l,u){if(i&&typeof t.lintSql=="function")try{let[c,d]=await t.lintSql(l,u);if(!c)return[null,d];if(!jW(c))return o({error:c});i=!1}catch(c){if(!jW(c))return o({error:c});i=!1}return await o1e(t,l,u)},async raw(l,u){try{let c=Zu(l.sql),[d,h]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{query:c,rowCount:h.length,rows:h}]}catch(c){return o({error:c})}},async query(l,u){try{let c=t1e(l,n),[d,h]=await wg({executor:t,options:u,query:c,searchTerm:l.fullTableSearchTerm,state:r});return d?o({error:d,query:c}):[null,{filteredRowCount:h[0]?.__ps_count__||"0",rows:h,query:c}]}catch(c){return o({error:c})}},async update(l,u){try{let c=zW(l,n),d=qW(l,n),[[h],f]=await t.executeSequence([c,d],u);if(h)return o({error:h,query:c});let[p,m]=f;if(p)return o({error:p,query:c});let[g]=m;return g?[null,{row:g,query:c}]:o({error:new Error("Updated row not found"),query:c})}catch(c){return o({error:c})}},async updateMany(l,u){return await s(l.updates,u)}}}function jW(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("invalid procedure")||t.includes("unexpected server error")||t.includes("internal server error")||t.includes("bad gateway")||t.includes("service unavailable")||t.includes("not supported")||t.includes("method not allowed")}function c1e(e){let{query:t,tables:n,timezone:r}=e;return n.reduce((i,o)=>{let{schemas:s}=i,{columns:a,name:l,schema:u}=o,c=a.sort((d,h)=>d.position-h.position).reduce((d,h)=>{let{datatype:f,default:p,name:m}=h,g=f.indexOf("("),y=(g>-1?f.substring(0,g):f).trim().toLowerCase(),v=!!h.autoincrement,b=!!h.computed,w=!!h.nullable;return{...d,[m]:{datatype:{...Zxe[y]||{group:"raw"},isArray:!1,isNative:!0,name:y,options:y==="enum"?f.slice(6,-2).split("','"):[],schema:u},defaultValue:p,fkColumn:h.fk_column,fkSchema:u,fkTable:h.fk_table,isAutoincrement:v,isComputed:b,isRequired:!w&&!v&&!b&&p==null,name:m,nullable:w,pkPosition:h.pk,schema:u,table:l}}},{});return s[u]===void 0&&(s[u]={name:u,tables:{}}),s[u].tables[l]={columns:c,name:l,schema:u},i},{filterOperators:d1e,query:t,schemas:{},timezone:r})}var d1e=["=","!=",">",">=","<","<=","is","is not","like","not like"];function Nk(e){let[t,n]=e;return{parameters:t.parameters.concat(n.parameters),sql:`${t.sql};
${n.sql}`}}var agt=L(H(),1),lgt=L(rn(),1);var Hmt=L(H(),1),$mt=L(rn(),1);var h1e={bool:{group:"boolean"},boolean:{group:"boolean"},bytea:{group:"string"},char:{group:"string"},citext:{group:"string"},date:{format:"YYYY-MM-DD",group:"datetime"},interval:{group:"string"},name:{group:"string"},varchar:{group:"string"},text:{group:"string"},time:{format:"HH:mm:ss.SSS",group:"time"},timestamp:{format:"YYYY-MM-DD HH:mm:ss.SSS",group:"datetime"},timestamptz:{format:"YYYY-MM-DD HH:mm:ss.SSSZZ",group:"datetime"},"timestamp without time zone":{format:"YYYY-MM-DD HH:mm:ss.SSS",group:"datetime"},"timestamp with time zone":{format:"YYYY-MM-DD HH:mm:ss.SSSZZ",group:"datetime"},timetz:{format:"HH:mm:ss.SSSZZ",group:"time"},"time without time zone":{format:"HH:mm:ss.SSS",group:"time"},"time with time zone":{format:"HH:mm:ss.SSSZZ",group:"time"},uuid:{format:"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",group:"raw"},int2:{group:"numeric"},int4:{group:"numeric"},int8:{group:"numeric"},smallint:{group:"numeric"},integer:{group:"numeric"},bigint:{group:"numeric"},decimal:{group:"numeric"},numeric:{group:"numeric"},real:{group:"numeric"},float4:{group:"numeric"},float8:{group:"numeric"},"double precision":{group:"numeric"},json:{group:"json"},jsonb:{group:"json"}};function kg(e){return yg({...e,Adapter:_W,QueryCompiler:MW})}function $W(e){let t=xg(e),n=t.normalizedSearchTerm;if(n.length<2)return t;let r=new Set(t.predicates.flatMap(a=>a.kind==="text-like"?[a.column]:[])),i=64-r.size;if(i<=0)return t;let o=`%${f1e(n)}%`,s=[];for(let a of Object.values(e.table.columns))if(!r.has(a.name)&&(s.push({column:a.name,kind:"text-like",pattern:o}),s.length>=i))break;return s.length===0?t:{...t,predicates:[...t.predicates,...s]}}function f1e(e){return e.replaceAll("%","\\%").replaceAll("_","\\_")}function KW(e,t){let{rows:n,table:{columns:r,name:i,schema:o}}=e,s=kg(t);return hr(s.withSchema(o).insertInto(i).values(ec({columns:r,context:"insert",supportsDefaultKeyword:!0,values:n})).returning(Object.keys(r)).returning(tD().as("__ps_inserted_at__")))}function YW(e,t){let{filter:n={after:"and",filters:[],kind:"FilterGroup"},fullTableSearchTerm:r,pageIndex:i,pageSize:o,sortOrder:s,table:{columns:a,name:l,schema:u}}=e,c=kg(t),d=Xf(n.filters,a),h=$W({searchTerm:r,table:e.table}),f=h.predicates.length>0?v=>v.and([d(v),Sg(h,{dialect:"postgres"})(v)]):d,p="__ps_agg__",m="__ps_count__",g="__ps_search_guardrails__";if(ab(r))return hr(c.with(g,v=>v.selectNoFrom(b=>[b.fn("set_config",[Fe.lit("statement_timeout"),Fe.lit("5000ms"),Fe.lit(!0)]).as("__ps_statement_timeout__"),b.fn("set_config",[Fe.lit("lock_timeout"),Fe.lit("100ms"),Fe.lit(!0)]).as("__ps_lock_timeout__")])).with(p,v=>v.withSchema(u).selectFrom(l).innerJoin(Fe.table(g).as(g),b=>b.onTrue()).where(f).select(b=>b.cast(b.fn.coalesce(b.fn.countAll(),Fe.lit(0)),"text").as(m))).withSchema(u).selectFrom(l).innerJoin(g,v=>v.onTrue()).innerJoin(p,v=>v.onTrue()).where(f).select(`${p}.${m}`).select(Object.keys(a)).$call(v=>s.reduce((b,w)=>{let x=a[w.column];return x?.datatype.group==="numeric"&&!x.datatype.isArray?b.orderBy(Fe`cast(${Fe.ref(w.column)} as numeric)`,w.direction):b.orderBy(w.column,w.direction)},v)).limit(o).offset(Fe.lit(BigInt(i)*BigInt(o))));let y=c.withSchema(u).selectFrom(l).where(f).select(v=>v.cast(v.fn.coalesce(v.fn.countAll(),Fe.lit(0)),"text").as(m));return hr(c.with(p,()=>y).withSchema(u).selectFrom(l).innerJoin(p,v=>v.onTrue()).where(f).select(`${p}.${m}`).select(Object.keys(a)).$call(v=>s.reduce((b,w)=>{let x=a[w.column];return x?.datatype.group==="numeric"&&!x.datatype.isArray?b.orderBy(Fe`cast(${Fe.ref(w.column)} as numeric)`,w.direction):b.orderBy(w.column,w.direction)},v)).limit(o).offset(Fe.lit(BigInt(i)*BigInt(o))))}function eD(e,t){let{changes:n,row:r,table:{columns:i,name:o,schema:s}}=e,a=kg(t);return hr(a.withSchema(s).updateTable(o).set(ec({columns:i,context:"update",supportsDefaultKeyword:!0,values:n})).$call(Ka([r],i)).returning(Object.keys(i)).returning(tD().as("__ps_updated_at__")))}function QW(e,t){let{rows:n,table:{columns:r,name:i,schema:o}}=e,s=kg(t);return hr(s.withSchema(o).deleteFrom(i).$call(Ka(n,r)).returning(Object.keys(r)).returning(tD().as("__ps_deleted_at__")))}function tD(){let e=ks();return e.cast(e.fn("floor",[e(e.fn("extract",[Fe`epoch from now()`]),"*",1e3)]),"text")}function p1e(e){return Fe`(select coalesce(json_agg(agg), '[]') from ${e} as agg)`}var m1e="r",g1e="v",y1e=[m1e,g1e];function GW(e){return hr(kg(e).selectFrom("pg_catalog.pg_class as cls").innerJoin("pg_catalog.pg_namespace as ns","cls.relnamespace","ns.oid").$call(v1e).where("cls.relkind","in",y1e).select(t=>["ns.nspname as schema","cls.relname as name",p1e(t.selectFrom("pg_catalog.pg_attribute as att").innerJoin("pg_catalog.pg_type as typ","typ.oid","att.atttypid").innerJoin("pg_catalog.pg_namespace as tns","tns.oid","typ.typnamespace").leftJoin("pg_catalog.pg_constraint as pk_con",n=>n.on("pk_con.contype","=","p").onRef("pk_con.conrelid","=","cls.oid").on(r=>r("att.attnum","=",r.fn.any("pk_con.conkey")))).leftJoin("pg_catalog.pg_constraint as fk_con",n=>n.on("fk_con.contype","=","f").onRef("fk_con.conrelid","=","cls.oid").on(r=>r("att.attnum","=",r.fn.any("fk_con.conkey")))).leftJoin("pg_catalog.pg_class as fk_cls","fk_cls.oid","fk_con.confrelid").leftJoin("pg_catalog.pg_namespace as fk_ns","fk_ns.oid","fk_cls.relnamespace").leftJoin("pg_catalog.pg_attribute as fk_att",n=>n.onRef("fk_att.attrelid","=","fk_cls.oid").on(r=>r("fk_att.attnum","=",r.fn.any("fk_con.confkey")))).leftJoin("pg_catalog.pg_attrdef as def",n=>n.onRef("def.adrelid","=","att.attrelid").onRef("def.adnum","=","att.attnum")).whereRef("att.attrelid","=","cls.oid").where("att.attnum",">=",0).where("att.attisdropped","!=",!0).select(["att.attname as name","fk_att.attname as fk_column","fk_cls.relname as fk_table","fk_ns.nspname as fk_schema","tns.nspname as datatype_schema","typ.typname as datatype"]).select(n=>[n("att.attidentity","!=","").or(n("def.adbin","is not",null).and(n.fn("pg_get_expr",["def.adbin","def.adrelid"]),"like","nextval(%")).$castTo().as("autoinc"),n("att.attgenerated","!=","").$castTo().as("computed"),n.fn("pg_get_expr",["def.adbin","def.adrelid"]).as("default"),n("att.attnotnull","!=",!0).$castTo().as("nullable"),n.fn.coalesce(n.selectFrom("pg_catalog.pg_enum as enm").whereRef("enm.enumtypid","=","typ.oid").select(r=>r.fn.jsonAgg(r.ref("enm.enumlabel")).as("o")),Fe`'[]'`).as("options"),n.fn("array_position",["pk_con.conkey","att.attnum"]).as("pk")])).as("columns")]))}function XW(){let e=kg();return hr(e.selectNoFrom(e.fn("current_setting",[Fe.lit("timezone")]).as("timezone")))}function v1e(e){return e.where("ns.nspname","!~","^pg_").where("ns.nspname","!=","information_schema")}function nD(e){let{executor:t,...n}=e,r=bg(),i=typeof t.lintSql=="function",o=l=>Td({...l,adapterSource:"postgresql"});async function s(l,u){let c=l.map(d=>eD(d,n));try{if(typeof t.executeTransaction=="function"){let[h,f]=await t.executeTransaction(c,u);if(h)return o({error:h,query:c[0]});let p=[];for(let[m,g]of f.entries()){let[y]=g;if(!y)return o({error:new Error("Update failed"),query:c[m]});p.push(y)}return[null,{rows:p,queries:c}]}let d=[];for(let[h,f]of c.entries()){let[p,m]=await t.execute(f,u);if(p)return o({error:p,query:f});let[g]=m;if(!g)return o({error:new Error("Update failed"),query:c[h]});d.push(g)}return[null,{rows:d,queries:c}]}catch(d){return o({error:d})}}async function a(l){try{let u=GW(n),c=XW(),[[d,h],[f,p]]=await Promise.all([t.execute(u,l),t.execute(c,l)]);if(d)return o({error:d,query:u});let m=f?"UTC":p[0]?.timezone??"UTC";return[null,x1e({query:u,tables:h,timezone:m})]}catch(u){return o({error:u})}}return{defaultSchema:"public",capabilities:{fullTableSearch:!0,sqlDialect:"postgresql",sqlEditorAutocomplete:!0,sqlEditorLint:!0},async introspect(l){return await a(l)},async query(l,u){try{let c=YW(l,n),[d,h]=await wg({executor:t,options:u,query:c,searchTerm:l.fullTableSearchTerm,state:r});return d?o({error:d,query:c}):[null,{filteredRowCount:h[0]?.__ps_count__||"0",rows:h,query:c}]}catch(c){return o({error:c})}},async raw(l,u){return await w1e(t,l,u)},async sqlSchema(l,u){let[c,d]=await a(u);return c?[c]:[null,tc({defaultSchema:"public",dialect:"postgresql",introspection:d})]},async sqlLint(l,u){if(i&&typeof t.lintSql=="function")try{let[c,d]=await t.lintSql(l,u);if(!c)return[null,d];if(!UW(c))return o({error:c});HW(c)&&(i=!1)}catch(c){if(!UW(c))return o({error:c});HW(c)&&(i=!1)}return await b1e(t,l,u)},async insert(l,u){try{let c=KW(l,n),[d,h]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{rows:h,query:c}]}catch(c){return o({error:c})}},async update(l,u){try{let c=eD(l,n),[d,h]=await t.execute(c,u);if(d)return o({error:d,query:c});let[f]=h;return f?[null,{row:f,query:c}]:o({error:new Error("Update failed"),query:c})}catch(c){return o({error:c})}},async updateMany(l,u){return await s(l.updates,u)},async delete(l,u){try{let c=QW(l,n),[d]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{...l,query:c}]}catch(c){return o({error:c})}}}}function UW(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("invalid procedure")||t.includes("unexpected server error")||t.includes("internal server error")||t.includes("bad gateway")||t.includes("service unavailable")||t.includes("not supported")||t.includes("method not allowed")}function HW(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("invalid procedure")||t.includes("unexpected server error")||t.includes("internal server error")||t.includes("not supported")||t.includes("method not allowed")}async function b1e(e,t,n){let r=vg(t.sql);if(!r.ok)return[null,{diagnostics:[r.diagnostic],schemaVersion:t.schemaVersion}];let i=[];for(let o of r.statements)try{let s=Zu(`EXPLAIN ${o.statement}`),[a]=await e.execute(s,n);if(!a)continue;i.push(...JA({error:a,positionOffset:o.from,sql:o.statement}))}catch(s){i.push(...JA({error:s,positionOffset:o.from,sql:o.statement}))}return[null,{diagnostics:i,schemaVersion:t.schemaVersion}]}async function w1e(e,t,n){try{let r=Zu(t.sql),[i,o]=await e.execute(r,n);return i?Td({adapterSource:"postgresql",error:i,query:r}):[null,{query:r,rowCount:o.length,rows:o}]}catch(r){return Td({adapterSource:"postgresql",error:r})}}function x1e(e){let{query:t,tables:n,timezone:r}=e;return n.reduce((i,o)=>{let{schemas:s}=i,{columns:a,name:l,schema:u}=o,c=a.reduce((d,h)=>{let{autoinc:f,computed:p,datatype:m,datatype_schema:g,default:y,name:v,options:b,nullable:w}=h,x=m.startsWith("_"),S=x?m.slice(1):m;return{...d,[v]:{datatype:{...h1e[S]||{group:b.length>0?"enum":"raw"},isArray:x,isNative:g==="pg_catalog",name:x?`${S}[]`:S,options:b,schema:g},defaultValue:y,fkColumn:h.fk_column,fkSchema:h.fk_schema,fkTable:h.fk_table,isAutoincrement:f,isComputed:p,isRequired:!w&&!f&&!p&&y==null,name:v,nullable:w,pkPosition:h.pk,schema:u,table:l}}},{});return s[u]===void 0&&(s[u]={name:u,tables:{}}),s[u].tables[l]={columns:c,name:l,schema:u},i},{filterOperators:S1e,query:t,schemas:{public:{name:"public",tables:{}}},timezone:r})}var S1e=["=","!=",">",">=","<","<=","is","is not","like","not like","ilike","not ilike"];var dgt=L(H(),1),hgt=L(rn(),1);var k1e={BLOB:{group:"raw"},INTEGER:{group:"numeric"},NULL:{group:"raw"},NUMERIC:{group:"numeric"},REAL:{group:"numeric"},TEXT:{group:"string"}};function C1e(e){if(!e)return"BLOB";let t=e.toUpperCase();return t.includes("INT")?"INTEGER":t.includes("TEXT")||t.includes("CHAR")||t.includes("CLOB")?"TEXT":t.includes("BLOB")?"BLOB":t.includes("REAL")||t.includes("FLOA")||t.includes("DOUB")?"REAL":"NUMERIC"}function ub(e){return yg({...e,Adapter:NW,QueryCompiler:CW})}function N1e(e,t){let{filter:n={after:"and",filters:[],kind:"FilterGroup"},fullTableSearchTerm:r,pageIndex:i,pageSize:o,sortOrder:s,table:{columns:a,name:l}}=e,u=ub(t),c=Xf(n.filters,a),d=xg({searchTerm:r,table:e.table}),h=d.predicates.length>0?g=>g.and([c(g),Sg(d,{dialect:"sqlite"})(g)]):c,f="__ps_agg__",p="__ps_count__",m=u.selectFrom(l).where(h).select(g=>g.cast(g.fn.coalesce(g.fn.countAll(),Fe.lit(0)),"text").as(p));return hr(u.with(f,()=>m).selectFrom(l).innerJoin(f,g=>g.onTrue()).where(h).select(`${f}.${p}`).select(Object.keys(a)).$call(g=>s.reduce((y,v)=>y.orderBy(v.column,v.direction),g)).limit(o).offset(Fe.lit(BigInt(i)*BigInt(o))))}function M1e(e,t){let{rows:n,table:{columns:r,name:i}}=e,o=ub(t);return hr(o.deleteFrom(i).$call(Ka(n,r)).returning(Object.keys(r)).returning(iD().as("__ps_deleted_at__")))}function _1e(e,t){let{table:{columns:n,name:r},rows:i}=e,o=ub(t);return hr(o.insertInto(r).values(ec({columns:n,context:"insert",supportsDefaultKeyword:!1,values:i})).returning(Object.keys(n)).returning(iD().as("__ps_inserted_at__")))}function JW(e,t){let{changes:n,row:r,table:{columns:i,name:o}}=e,s=ub(t);return hr(s.updateTable(o).set(ec({columns:i,context:"update",supportsDefaultKeyword:!1,values:n})).$call(Ka([r],i)).returning(Object.keys(i)).returning(iD().as("__ps_updated_at__")))}function iD(){let e=ks();return e.cast(e.cast(Fe`(julianday('now') - 2440587.5) * 86400000.0`,"integer"),"text")}function E1e(e){return Fe`(select coalesce(json_group_array(json_object(${Fe.join(O1e(e.toOperationNode(),"agg"))})), '[]') from ${e} as agg)`}function O1e(e,t){try{return DW(e,t)}catch{throw new Error("SQLite jsonArrayFrom and jsonObjectFrom functions can only handle explicit selections due to limitations of the json_object function. selectAll() is not allowed in the subquery.")}}function T1e(e){return hr(ub(e).selectFrom(ks().fn("pragma_table_list",[]).as("tl")).leftJoin("sqlite_schema as ss",t=>t.onRef("ss.type","=","tl.type").onRef("ss.name","=","tl.name")).where("tl.type","in",["table","view"]).where("tl.schema","=","main").where("tl.name","not like","sqlite_%").select(["tl.name","ss.sql"]).$narrowType().select(t=>[E1e(t.selectFrom(t.fn("pragma_table_xinfo",["tl.name"]).as("txi")).leftJoin(t.fn("pragma_foreign_key_list",["tl.name"]).as("fkl"),"fkl.from","txi.name").where("txi.hidden","!=",1).select(["txi.dflt_value as default","txi.name","txi.pk","txi.type as datatype","fkl.table as fk_table","fkl.to as fk_column"]).select(n=>[n("txi.hidden","in",[2,3]).as("computed"),n("txi.notnull","=",0).as("nullable")])).as("columns")]),{transformations:{columns:"json-parse"}})}function ZW(e){let{error:t,sql:n}=e,r=Math.max(0,e.positionOffset??0),i=I1e(n.length);if(!(t instanceof Error))return[{from:i.from+r,message:"SQL lint failed.",severity:"error",source:"sqlite",to:i.to+r}];let o=D1e(t),s=P1e(n,t.message)??i;return[{code:o,from:s.from+r,message:R1e(t.message),severity:"error",source:"sqlite",to:s.to+r}]}async function A1e(e,t,n){let r=vg(t.sql);if(!r.ok)return[null,{diagnostics:[r.diagnostic],schemaVersion:t.schemaVersion}];let i=[];for(let o of r.statements)try{let s=Zu(`EXPLAIN ${o.statement}`),[a]=await e.execute(s,n);if(!a)continue;i.push(...ZW({error:a,positionOffset:o.from,sql:o.statement}))}catch(s){i.push(...ZW({error:s,positionOffset:o.from,sql:o.statement}))}return[null,{diagnostics:i,schemaVersion:t.schemaVersion}]}function D1e(e){let t=e;return typeof t.code=="string"?t.code:void 0}function R1e(e){return e.toLowerCase().includes("interrupted")?"Lint query timed out. Simplify the statement and try again.":e}function I1e(e){return e<=0?{from:0,to:0}:{from:0,to:1}}function P1e(e,t){let n=/near\s+["'`]([^"'`]+)["'`]/i.exec(t);if(n?.[1])return rD(e,n[1]);let r=/no such table:\s*([^\s]+)/i.exec(t);if(r?.[1])return rD(e,r[1]);let i=/no such column:\s*([^\s]+)/i.exec(t);return i?.[1]?rD(e,i[1]):null}function rD(e,t){let n=t.trim().replace(/^['"`]|['"`]$/g,"");if(n.length===0)return null;let r=e.toLowerCase(),i=n.toLowerCase(),o=r.indexOf(i);if(o>=0)return{from:o,to:Math.min(e.length,o+n.length)};let s=i.split(".").at(-1);if(!s)return null;let a=r.indexOf(s);return a<0?null:{from:a,to:Math.min(e.length,a+s.length)}}var lb="main",L1e=["=","!=",">",">=","<","<=","is","is not","like","not like"];function tU(e){let{executor:t,...n}=e,r=bg(),i=typeof t.lintSql=="function",o=l=>Td({...l,adapterSource:"sqlite"});async function s(l,u){let c=l.map(d=>JW(d,n));try{if(typeof t.executeTransaction=="function"){let[h,f]=await t.executeTransaction(c,u);if(h)return o({error:h,query:c[0]});let p=[];for(let[m,g]of f.entries()){let[y]=g;if(!y)return o({error:new Error("Update failed"),query:c[m]});p.push(y)}return[null,{rows:p,queries:c}]}let d=[];for(let[h,f]of c.entries()){let[p,m]=await t.execute(f,u);if(p)return o({error:p,query:f});let[g]=m;if(!g)return o({error:new Error("Update failed"),query:c[h]});d.push(g)}return[null,{rows:d,queries:c}]}catch(d){return o({error:d})}}async function a(l){try{let u=T1e(e),[c,d]=await t.execute(u,l);return c?o({error:c,query:u}):[null,q1e({query:u,tables:d})]}catch(u){return o({error:u})}}return{defaultSchema:lb,capabilities:{fullTableSearch:!0,sqlDialect:"sqlite",sqlEditorAutocomplete:!0,sqlEditorLint:!0},async delete(l,u){try{let c=M1e(l,n),[d]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{...l,query:c}]}catch(c){return o({error:c})}},async insert(l,u){try{let c=_1e(l,n),[d,h]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{rows:h,query:c}]}catch(c){return o({error:c})}},async introspect(l){return await a(l)},async sqlSchema(l,u){let[c,d]=await a(u);return c?[c]:[null,tc({defaultSchema:lb,dialect:"sqlite",introspection:d})]},async sqlLint(l,u){if(i&&typeof t.lintSql=="function")try{let[c,d]=await t.lintSql(l,u);if(!c)return[null,d];if(!eU(c))return o({error:c});i=!1}catch(c){if(!eU(c))return o({error:c});i=!1}return await A1e(t,l,u)},async query(l,u){try{let c=N1e(l,n),[d,h]=await wg({executor:t,options:u,query:c,searchTerm:l.fullTableSearchTerm,state:r});return d?o({error:d,query:c}):[null,{filteredRowCount:h[0]?.__ps_count__||"0",rows:h,query:c}]}catch(c){return o({error:c})}},async raw(l,u){try{let c=Zu(l.sql),[d,h]=await t.execute(c,u);return d?o({error:d,query:c}):[null,{query:c,rowCount:h.length,rows:h}]}catch(c){return o({error:c})}},async update(l,u){try{let c=JW(l,n),[d,h]=await t.execute(c,u);if(d)return o({error:d,query:c});let[f]=h;return f?[null,{row:f,query:c}]:o({error:new Error("Update failed"),query:c})}catch(c){return o({error:c})}},async updateMany(l,u){return await s(l.updates,u)}}}function eU(e){if(!(e instanceof Error))return!1;let t=e.message.toLowerCase();return t.includes("invalid procedure")||t.includes("not supported")||t.includes("method not allowed")}var B1e=/WITHOUT\s+ROWID/i;function q1e(e){let{tables:t,query:n}=e;return{filterOperators:L1e,query:n,schemas:t.reduce((r,i)=>{let{columns:o,name:s,sql:a}=i,l=0,u=o.reduce((c,d,h)=>{let{datatype:f,default:p,fk_column:m,name:g,pk:y}=d;l=Math.max(l,y);let v=C1e(f),b=f.toUpperCase()==="INTEGER"&&y===1&&l===1&&!o.slice(h+1).some(function(S){return S.pk>1})&&!B1e.test(a),w=!!d.computed,x=!!d.nullable&&!b;return c[g]={datatype:{...k1e[v],affinity:v,isArray:!1,isNative:!0,name:f,options:[],schema:lb},defaultValue:p,fkColumn:m,fkSchema:m?lb:null,fkTable:d.fk_table,isAutoincrement:b,isComputed:w,isRequired:!x&&!b&&!w&&p==null,name:g,nullable:x,pkPosition:y>0?y:null,schema:lb,table:s},c},{});return r.main.tables[s]={columns:u,name:s,schema:"main"},r},{main:{tables:{},name:"main"}}),timezone:"UTC"}}var Ygt=L(H(),1),Qgt=L(rn(),1);var wgt=L(H(),1),xgt=L(rn(),1);var nU="__PRISMA_STUDIO_AI_OUTPUT_LIMIT__:",z1e=["cancelled","not-configured","output-limit-exceeded","request-failed"],cb=class extends Error{code;constructor(e){super(e.message),this.name="StudioLlmError",this.code=e.code}};function rU(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.ok===!0?typeof t.text=="string":t.ok===!1&&typeof t.message=="string"&&typeof t.code=="string"&&z1e.includes(t.code)}function iU(e){if(e instanceof cb&&e.code==="output-limit-exceeded")return e.message.trim();let t=e instanceof Error?e.message:typeof e=="string"?e:null;return t?.startsWith(nU)?t.slice(nU.length).trim():null}var nx=L(le(),1),ul=L(H(),1),hG=L(H(),1),fG=L(H(),1),D_=L(H(),1),BI=L(le(),1),gG=L(H(),1),rx=L(H(),1),yG=L(H(),1),vG=L(le(),1),L_=L(H(),1),Ac=L(H(),1),VX=L(H(),1),WX=L(H(),1),jh=L(H(),1),B_=L(H(),1),$X=L(H(),1),q_=L(le(),1),vv=L(H(),1),GX=L(H(),1),F_=L(H(),1),bv=L(H(),1),XX=L(H(),1),ZX=L(H(),1),sP=L(H(),1),Up=L(H(),1),Co=L(H(),1),nJ=L(H(),1),oJ=L(H(),1),uJ=L(le(),1),ux=L(H(),1),xv=L(H(),1),bJ=L(le(),1),j_=L(H(),1),V_=L(H(),1),ryt=L(le(),1),SJ=L(H(),1),Vh=L(H(),1),W_=L(H(),1),Dc=L(H(),1),Rc=L(H(),1),$p=L(H(),1),aa=L(H(),1),tn=L(H(),1),XJ=L(rn(),1),ve=L(H(),1),JJ=L(rn(),1),rZ=L(le(),1),Ic=L(H(),1),Uh=L(H(),1),Gp=L(H(),1),ji=L(H(),1),gZ=L(le(),1),Lc=L(H(),1),px=L(H(),1),As=L(H(),1),Cp=L(le(),1),G_=L(H(),1),mx=L(H(),1),Qt=L(H(),1),jn=L(H(),1),GZ=L(H(),1),Na=L(H(),1),Rz=L(le(),1),Iz=L(H(),1),XZ=L(H(),1),Ma=L(H(),1),Syt=L(H(),1),vr=L(H(),1),JZ=L(H(),1),ZZ=L(rn(),1),pi=L(H(),1),Jy=L(le(),1),nee=L(le(),1),_v=L(H(),1),iee=L(H(),1),Pz=L(le(),1),Oa=L(H(),1),aee=L(le(),1),J_=L(H(),1),uee=L(rn(),1),cee=L(le(),1),Zo=L(H(),1),dee=L(H(),1),hee=L(H(),1),eE=L(H(),1),so=L(H(),1),pee=L(H(),1),tE=L(H(),1),mee=L(H(),1),Qn=L(H(),1),Tv=L(H(),1),vee=L(H(),1),Sn=L(le(),1),Ee=L(H(),1),Vee=L(H(),1),kyt=L(rn(),1),Yr=L(H(),1),HP=L(le(),1),$ee=L(le(),1),Uc=L(H(),1),l1=L(H(),1),Xo=L(le(),1),Ro=L(le(),1),xl=L(H(),1),uE=L(H(),1),ate=L(H(),1),em=L(le(),1),pte=L(H(),1),YP=L(le(),1),ka=L(H(),1),Ci=L(H(),1),Gd=L(H(),1),zN=L(le(),1),Myt=L(H(),1),Eyt=L(le(),1),dE=L(H(),1),Tyt=L(le(),1),bh=L(le(),1);var vU=L(H(),1);var Mgt=!!(typeof window<"u"&&window.document&&window.document.createElement);function lU(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e?.(i),n===!1||!i.defaultPrevented)return t?.(i)}}var ra=L(H(),1);var uU=L(H(),1),cU=globalThis?.document?uU.useLayoutEffect:()=>{};var _k=L(H(),1);var V1e=ra[" useInsertionEffect ".trim().toString()]||cU;function dU({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,o,s]=W1e({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{let c=ra.useRef(e!==void 0);ra.useEffect(()=>{let d=c.current;d!==a&&console.warn(`${r} is changing from ${d?"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.`),c.current=a},[a,r])}let u=ra.useCallback(c=>{if(a){let d=U1e(c)?c(e):c;d!==e&&s.current?.(d)}else o(c)},[a,e,o,s]);return[l,u]}function W1e({defaultProp:e,onChange:t}){let[n,r]=ra.useState(e),i=ra.useRef(n),o=ra.useRef(t);return V1e(()=>{o.current=t},[t]),ra.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}function U1e(e){return typeof e=="function"}var Tgt=Symbol("RADIX:SYNC_STATE");var mU=L(H(),1),X1e=L(rn(),1);var oi=L(H(),1);var H1e=L(H(),1);function hU(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function fU(...e){return t=>{let n=!1,r=e.map(i=>{let o=hU(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){let o=r[i];typeof o=="function"?o():hU(e[i],null)}}}}var Ek=L(le(),1);function pU(e){let t=$1e(e),n=oi.forwardRef((r,i)=>{let{children:o,...s}=r,a=oi.Children.toArray(o),l=a.find(Y1e);if(l){let u=l.props.children,c=a.map(d=>d===l?oi.Children.count(u)>1?oi.Children.only(null):oi.isValidElement(u)?u.props.children:null:d);return(0,Ek.jsx)(t,{...s,ref:i,children:oi.isValidElement(u)?oi.cloneElement(u,void 0,c):null})}return(0,Ek.jsx)(t,{...s,ref:i,children:o})});return n.displayName=`${e}.Slot`,n}function $1e(e){let t=oi.forwardRef((n,r)=>{let{children:i,...o}=n;if(oi.isValidElement(i)){let s=G1e(i),a=Q1e(o,i.props);return i.type!==oi.Fragment&&(a.ref=r?fU(r,s):s),oi.cloneElement(i,a)}return oi.Children.count(i)>1?oi.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var K1e=Symbol("radix.slottable");function Y1e(e){return oi.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===K1e}function Q1e(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...a)=>{let l=o(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function G1e(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gU=L(le(),1),J1e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yU=J1e.reduce((e,t)=>{let n=pU(`Primitive.${t}`),r=mU.forwardRef((i,o)=>{let{asChild:s,...a}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,gU.jsx)(l,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});var bU=L(le(),1),wU="Toggle",Ok=vU.forwardRef((e,t)=>{let{pressed:n,defaultPressed:r,onPressedChange:i,...o}=e,[s,a]=dU({prop:n,onChange:i,defaultProp:r??!1,caller:wU});return(0,bU.jsx)(yU.button,{type:"button","aria-pressed":s,"data-state":s?"on":"off","data-disabled":e.disabled?"":void 0,...o,ref:t,onClick:lU(e.onClick,()=>{e.disabled||a(!s)})})});Ok.displayName=wU;var oD=Ok;var To=L(le(),1),pm=L(H(),1);var Tte=L(H(),1),Ate=L(le(),1),zM=L(le(),1),Wt=L(le(),1),Fte=L(H(),1),jte=L(le(),1),$o=L(le(),1),Bc=L(H(),1),Vte=L(H(),1),Wte=L(le(),1),Se=L(H(),1),e5=L(rn(),1),es=L(H(),1),$r=L(H(),1),ene=L(H(),1),tne=L(rn(),1),rne=L(H(),1),tL=L(le(),1),wh=L(le(),1),pne=L(H(),1),mne=L(le(),1),Ze=L(le(),1),Gh=L(H(),1),nr=L(le(),1),rre=L(le(),1),Xe=L(le(),1),bc=L(le(),1),CE=L(H(),1),ire=L(le(),1),mm=L(H(),1),gm=L(le(),1),Xt=L(le(),1),Pp=L(le(),1),cre=L(H(),1),Mo=L(H(),1),U=L(H(),1),dre=L(H(),1),Byt=L(rn(),1),hi=L(H(),1),dn=L(H(),1),ma=L(H(),1),jyt=L(H(),1),Uyt=L(rn(),1),xt=L(H(),1),Kr=L(le(),1),Zie=L(H(),1),$N=L(le(),1),Tt=L(le(),1),Wr=L(le(),1),Zh=L(H(),1),Qo=L(H(),1),Gle=L(le(),1),Ge=L(H(),1),$B=L(rn(),1),Hc=L(H(),1),ku=L(le(),1),JE=L(H(),1),rue=L(H(),1),Bv=L(H(),1),Tn=L(H(),1),je=L(H(),1),lt=L(le(),1),br=L(le(),1),$c=L(H(),1),Qr=L(le(),1),fh=L(le(),1),cM=L(le(),1),ah=L(le(),1),yce=L(H(),1),ph=L(le(),1),kh=L(le(),1),li=L(le(),1),ne=L(H(),1),Op=L(rn(),1),Pr=L(H(),1),wm=L(H(),1),Lr=L(H(),1),tq=L(H(),1),pe=L(H(),1),aq=L(le(),1),cm=L(H(),1),gi=L(H(),1),Oi=L(le(),1),Kc=L(H(),1),Gr=L(le(),1),Dde=L(H(),1),Rde=L(le(),1),Lde=L(H(),1),Bde=L(le(),1),en=L(le(),1),vt=L(le(),1),dq=L(le(),1),Yn=L(le(),1),wo=L(le(),1),bl=L(H(),1);function fb(e){return e+.5|0}var Ad=(e,t,n)=>Math.max(Math.min(e,n),t);function db(e){return Ad(fb(e*2.55),0,255)}function Dd(e){return Ad(fb(e*255),0,255)}function rc(e){return Ad(fb(e/2.55)/100,0,1)}function xU(e){return Ad(fb(e*100),0,100)}var ia={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},aD=[..."0123456789ABCDEF"],eSe=e=>aD[e&15],tSe=e=>aD[(e&240)>>4]+aD[e&15],Tk=e=>(e&240)>>4===(e&15),nSe=e=>Tk(e.r)&&Tk(e.g)&&Tk(e.b)&&Tk(e.a);function rSe(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&ia[e[1]]*17,g:255&ia[e[2]]*17,b:255&ia[e[3]]*17,a:t===5?ia[e[4]]*17:255}:(t===7||t===9)&&(n={r:ia[e[1]]<<4|ia[e[2]],g:ia[e[3]]<<4|ia[e[4]],b:ia[e[5]]<<4|ia[e[6]],a:t===9?ia[e[7]]<<4|ia[e[8]]:255})),n}var iSe=(e,t)=>e<255?t(e):"";function oSe(e){var t=nSe(e)?eSe:tSe;return e?"#"+t(e.r)+t(e.g)+t(e.b)+iSe(e.a,t):void 0}var sSe=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function NU(e,t,n){let r=t*Math.min(n,1-n),i=(o,s=(o+e/30)%12)=>n-r*Math.max(Math.min(s-3,9-s,1),-1);return[i(0),i(8),i(4)]}function aSe(e,t,n){let r=(i,o=(i+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[r(5),r(3),r(1)]}function lSe(e,t,n){let r=NU(e,1,.5),i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)r[i]*=1-t-n,r[i]+=t;return r}function uSe(e,t,n,r,i){return e===i?(t-n)/r+(t<n?6:0):t===i?(n-e)/r+2:(e-t)/r+4}function lD(e){let n=e.r/255,r=e.g/255,i=e.b/255,o=Math.max(n,r,i),s=Math.min(n,r,i),a=(o+s)/2,l,u,c;return o!==s&&(c=o-s,u=a>.5?c/(2-o-s):c/(o+s),l=uSe(n,r,i,c,o),l=l*60+.5),[l|0,u||0,a]}function uD(e,t,n,r){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,r)).map(Dd)}function cD(e,t,n){return uD(NU,e,t,n)}function cSe(e,t,n){return uD(lSe,e,t,n)}function dSe(e,t,n){return uD(aSe,e,t,n)}function MU(e){return(e%360+360)%360}function hSe(e){let t=sSe.exec(e),n=255,r;if(!t)return;t[5]!==r&&(n=t[6]?db(+t[5]):Dd(+t[5]));let i=MU(+t[2]),o=+t[3]/100,s=+t[4]/100;return t[1]==="hwb"?r=cSe(i,o,s):t[1]==="hsv"?r=dSe(i,o,s):r=cD(i,o,s),{r:r[0],g:r[1],b:r[2],a:n}}function fSe(e,t){var n=lD(e);n[0]=MU(n[0]+t),n=cD(n),e.r=n[0],e.g=n[1],e.b=n[2]}function pSe(e){if(!e)return;let t=lD(e),n=t[0],r=xU(t[1]),i=xU(t[2]);return e.a<255?`hsla(${n}, ${r}%, ${i}%, ${rc(e.a)})`:`hsl(${n}, ${r}%, ${i}%)`}var SU={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},kU={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function mSe(){let e={},t=Object.keys(kU),n=Object.keys(SU),r,i,o,s,a;for(r=0;r<t.length;r++){for(s=a=t[r],i=0;i<n.length;i++)o=n[i],a=a.replace(o,SU[o]);o=parseInt(kU[s],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}var Ak;function gSe(e){Ak||(Ak=mSe(),Ak.transparent=[0,0,0,0]);let t=Ak[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}var ySe=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function vSe(e){let t=ySe.exec(e),n=255,r,i,o;if(t){if(t[7]!==r){let s=+t[7];n=t[8]?db(s):Ad(s*255,0,255)}return r=+t[1],i=+t[3],o=+t[5],r=255&(t[2]?db(r):Ad(r,0,255)),i=255&(t[4]?db(i):Ad(i,0,255)),o=255&(t[6]?db(o):Ad(o,0,255)),{r,g:i,b:o,a:n}}}function bSe(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${rc(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}var sD=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,Cg=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function wSe(e,t,n){let r=Cg(rc(e.r)),i=Cg(rc(e.g)),o=Cg(rc(e.b));return{r:Dd(sD(r+n*(Cg(rc(t.r))-r))),g:Dd(sD(i+n*(Cg(rc(t.g))-i))),b:Dd(sD(o+n*(Cg(rc(t.b))-o))),a:e.a+n*(t.a-e.a)}}function Dk(e,t,n){if(e){let r=lD(e);r[t]=Math.max(0,Math.min(r[t]+r[t]*n,t===0?360:1)),r=cD(r),e.r=r[0],e.g=r[1],e.b=r[2]}}function _U(e,t){return e&&Object.assign(t||{},e)}function CU(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=Dd(e[3]))):(t=_U(e,{r:0,g:0,b:0,a:1}),t.a=Dd(t.a)),t}function xSe(e){return e.charAt(0)==="r"?vSe(e):hSe(e)}var hb=class e{constructor(t){if(t instanceof e)return t;let n=typeof t,r;n==="object"?r=CU(t):n==="string"&&(r=rSe(t)||gSe(t)||xSe(t)),this._rgb=r,this._valid=!!r}get valid(){return this._valid}get rgb(){var t=_U(this._rgb);return t&&(t.a=rc(t.a)),t}set rgb(t){this._rgb=CU(t)}rgbString(){return this._valid?bSe(this._rgb):void 0}hexString(){return this._valid?oSe(this._rgb):void 0}hslString(){return this._valid?pSe(this._rgb):void 0}mix(t,n){if(t){let r=this.rgb,i=t.rgb,o,s=n===o?.5:n,a=2*s-1,l=r.a-i.a,u=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-u,r.r=255&u*r.r+o*i.r+.5,r.g=255&u*r.g+o*i.g+.5,r.b=255&u*r.b+o*i.b+.5,r.a=s*r.a+(1-s)*i.a,this.rgb=r}return this}interpolate(t,n){return t&&(this._rgb=wSe(this._rgb,t._rgb,n)),this}clone(){return new e(this.rgb)}alpha(t){return this._rgb.a=Dd(t),this}clearer(t){let n=this._rgb;return n.a*=1-t,this}greyscale(){let t=this._rgb,n=fb(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){let n=this._rgb;return n.a*=1+t,this}negate(){let t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return Dk(this._rgb,2,t),this}darken(t){return Dk(this._rgb,2,-t),this}saturate(t){return Dk(this._rgb,1,t),this}desaturate(t){return Dk(this._rgb,1,-t),this}rotate(t){return fSe(this._rgb,t),this}};function Fl(){}var qU=(()=>{let e=0;return()=>e++})();function Rt(e){return e==null}function Ln(e){if(Array.isArray&&Array.isArray(e))return!0;let t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function Bt(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function fr(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function jo(e,t){return fr(e)?e:t}function ht(e,t){return typeof e>"u"?t:e}var zU=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,pD=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function Mn(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function cn(e,t,n,r){let i,o,s;if(Ln(e))if(o=e.length,r)for(i=o-1;i>=0;i--)t.call(n,e[i],i);else for(i=0;i<o;i++)t.call(n,e[i],i);else if(Bt(e))for(s=Object.keys(e),o=s.length,i=0;i<o;i++)t.call(n,e[s[i]],s[i])}function gb(e,t){let n,r,i,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,r=e.length;n<r;++n)if(i=e[n],o=t[n],i.datasetIndex!==o.datasetIndex||i.index!==o.index)return!1;return!0}function Lk(e){if(Ln(e))return e.map(Lk);if(Bt(e)){let t=Object.create(null),n=Object.keys(e),r=n.length,i=0;for(;i<r;++i)t[n[i]]=Lk(e[n[i]]);return t}return e}function FU(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function SSe(e,t,n,r){if(!FU(e))return;let i=t[e],o=n[e];Bt(i)&&Bt(o)?Mg(i,o,r):t[e]=Lk(o)}function Mg(e,t,n){let r=Ln(t)?t:[t],i=r.length;if(!Bt(e))return e;n=n||{};let o=n.merger||SSe,s;for(let a=0;a<i;++a){if(s=r[a],!Bt(s))continue;let l=Object.keys(s);for(let u=0,c=l.length;u<c;++u)o(l[u],e,s,n)}return e}function Eg(e,t){return Mg(e,t,{merger:kSe})}function kSe(e,t,n){if(!FU(e))return;let r=t[e],i=n[e];Bt(r)&&Bt(i)?Eg(r,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Lk(i))}var EU={"":e=>e,x:e=>e.x,y:e=>e.y};function CSe(e){let t=e.split("."),n=[],r="";for(let i of t)r+=i,r.endsWith("\\")?r=r.slice(0,-1)+".":(n.push(r),r="");return n}function NSe(e){let t=CSe(e);return n=>{for(let r of t){if(r==="")break;n=n&&n[r]}return n}}function sc(e,t){return(EU[t]||(EU[t]=NSe(t)))(e)}function Fk(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Og=e=>typeof e<"u",ic=e=>typeof e=="function",mD=(e,t)=>{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0};function jU(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}var Gt=Math.PI,Bn=2*Gt,MSe=Bn+Gt,Bk=Number.POSITIVE_INFINITY,_Se=Gt/180,Sr=Gt/2,Jf=Gt/4,OU=Gt*2/3,oc=Math.log10,Ya=Math.sign;function Tg(e,t,n){return Math.abs(e-t)<n}function gD(e){let t=Math.round(e);e=Tg(e,t,e/1e3)?t:e;let n=Math.pow(10,Math.floor(oc(e))),r=e/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}function VU(e){let t=[],n=Math.sqrt(e),r;for(r=1;r<n;r++)e%r===0&&(t.push(r),t.push(e/r));return n===(n|0)&&t.push(n),t.sort((i,o)=>i-o).pop(),t}function ESe(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function tp(e){return!ESe(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function WU(e,t){let n=Math.round(e);return n-t<=e&&n+t>=e}function yD(e,t,n){let r,i,o;for(r=0,i=e.length;r<i;r++)o=e[r][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function oa(e){return e*(Gt/180)}function jk(e){return e*(180/Gt)}function vD(e){if(!fr(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function bD(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),o=Math.atan2(r,n);return o<-.5*Gt&&(o+=Bn),{angle:o,distance:i}}function qk(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function OSe(e,t){return(e-t+MSe)%Bn-Gt}function Li(e){return(e%Bn+Bn)%Bn}function Ag(e,t,n,r){let i=Li(e),o=Li(t),s=Li(n),a=Li(o-i),l=Li(s-i),u=Li(i-o),c=Li(i-s);return i===o||i===s||r&&o===s||a>l&&u<c}function si(e,t,n){return Math.max(t,Math.min(n,e))}function UU(e){return si(e,-32768,32767)}function jl(e,t,n,r=1e-6){return e>=Math.min(t,n)-r&&e<=Math.max(t,n)+r}function Vk(e,t,n){n=n||(s=>e[s]<t);let r=e.length-1,i=0,o;for(;r-i>1;)o=i+r>>1,n(o)?i=o:r=o;return{lo:i,hi:r}}var ql=(e,t,n,r)=>Vk(e,n,r?i=>{let o=e[i][t];return o<n||o===n&&e[i+1][t]===n}:i=>e[i][t]<n),HU=(e,t,n)=>Vk(e,n,r=>e[r][t]>=n);function $U(e,t,n){let r=0,i=e.length;for(;r<i&&e[r]<t;)r++;for(;i>r&&e[i-1]>n;)i--;return r>0||i<e.length?e.slice(r,i):e}var KU=["push","pop","shift","splice","unshift"];function YU(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),KU.forEach(n=>{let r="_onData"+Fk(n),i=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){let s=i.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[r]=="function"&&a[r](...o)}),s}})})}function wD(e,t){let n=e._chartjs;if(!n)return;let r=n.listeners,i=r.indexOf(t);i!==-1&&r.splice(i,1),!(r.length>0)&&(KU.forEach(o=>{delete e[o]}),delete e._chartjs)}function xD(e){let t=new Set(e);return t.size===e.length?e:Array.from(t)}var SD=function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame}();function kD(e,t){let n=[],r=!1;return function(...i){n=i,r||(r=!0,SD.call(window,()=>{r=!1,e.apply(t,n)}))}}function QU(e,t){let n;return function(...r){return t?(clearTimeout(n),n=setTimeout(e,t,r)):e.apply(this,r),t}}var Wk=e=>e==="start"?"left":e==="end"?"right":"center",Bi=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,GU=(e,t,n,r)=>e===(r?"left":"right")?n:e==="center"?(t+n)/2:t;function CD(e,t,n){let r=t.length,i=0,o=r;if(e._sorted){let{iScale:s,vScale:a,_parsed:l}=e,u=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,c=s.axis,{min:d,max:h,minDefined:f,maxDefined:p}=s.getUserBounds();if(f){if(i=Math.min(ql(l,c,d).lo,n?r:ql(t,c,s.getPixelForValue(d)).lo),u){let m=l.slice(0,i+1).reverse().findIndex(g=>!Rt(g[a.axis]));i-=Math.max(0,m)}i=si(i,0,r-1)}if(p){let m=Math.max(ql(l,s.axis,h,!0).hi+1,n?0:ql(t,c,s.getPixelForValue(h),!0).hi+1);if(u){let g=l.slice(m-1).findIndex(y=>!Rt(y[a.axis]));m+=Math.max(0,g)}o=si(m,i,r)-i}else o=r-i}return{start:i,count:o}}function ND(e){let{xScale:t,yScale:n,_scaleRanges:r}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!r)return e._scaleRanges=i,!0;let o=r.xmin!==t.min||r.xmax!==t.max||r.ymin!==n.min||r.ymax!==n.max;return Object.assign(r,i),o}var Rk=e=>e===0||e===1,TU=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*Bn/n)),AU=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*Bn/n)+1,Ng={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Sr)+1,easeOutSine:e=>Math.sin(e*Sr),easeInOutSine:e=>-.5*(Math.cos(Gt*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>Rk(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>Rk(e)?e:TU(e,.075,.3),easeOutElastic:e=>Rk(e)?e:AU(e,.075,.3),easeInOutElastic(e){return Rk(e)?e:e<.5?.5*TU(e*2,.1125,.45):.5+.5*AU(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-Ng.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?Ng.easeInBounce(e*2)*.5:Ng.easeOutBounce(e*2-1)*.5+.5};function MD(e){if(e&&typeof e=="object"){let t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function _D(e){return MD(e)?e:new hb(e)}function dD(e){return MD(e)?e:new hb(e).saturate(.5).darken(.1).hexString()}var TSe=["x","y","borderWidth","radius","tension"],ASe=["color","borderColor","backgroundColor"];function DSe(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:ASe},numbers:{type:"number",properties:TSe}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function RSe(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}var DU=new Map;function ISe(e,t){t=t||{};let n=e+JSON.stringify(t),r=DU.get(n);return r||(r=new Intl.NumberFormat(e,t),DU.set(n,r)),r}function Dg(e,t,n){return ISe(t,n).format(e)}var XU={values(e){return Ln(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";let r=this.chart.options.locale,i,o=e;if(n.length>1){let u=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(u<1e-4||u>1e15)&&(i="scientific"),o=PSe(e,n)}let s=oc(Math.abs(o)),a=isNaN(s)?1:Math.max(Math.min(-1*Math.floor(s),20),0),l={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),Dg(e,r,l)},logarithmic(e,t,n){if(e===0)return"0";let r=n[t].significand||e/Math.pow(10,Math.floor(oc(e)));return[1,2,3,5,10,15].includes(r)||t>.8*n.length?XU.numeric.call(this,e,t,n):""}};function PSe(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var yb={formatters:XU};function LSe(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:yb.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}var Pd=Object.create(null),Uk=Object.create(null);function pb(e,t){if(!t)return e;let n=t.split(".");for(let r=0,i=n.length;r<i;++r){let o=n[r];e=e[o]||(e[o]=Object.create(null))}return e}function hD(e,t,n){return typeof t=="string"?Mg(pb(e,t),n):Mg(pb(e,""),t)}var fD=class{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=r=>r.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(r,i)=>dD(i.backgroundColor),this.hoverBorderColor=(r,i)=>dD(i.borderColor),this.hoverColor=(r,i)=>dD(i.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return hD(this,t,n)}get(t){return pb(this,t)}describe(t,n){return hD(Uk,t,n)}override(t,n){return hD(Pd,t,n)}route(t,n,r,i){let o=pb(this,t),s=pb(this,r),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){let l=this[a],u=s[i];return Bt(l)?Object.assign({},u,l):ht(l,u)},set(l){this[a]=l}}})}apply(t){t.forEach(n=>n(this))}},Kn=new fD({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[DSe,RSe,LSe]);function BSe(e){return!e||Rt(e.size)||Rt(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function mb(e,t,n,r,i){let o=t[i];return o||(o=t[i]=e.measureText(i).width,n.push(i)),o>r&&(r=o),r}function JU(e,t,n,r){r=r||{};let i=r.data=r.data||{},o=r.garbageCollect=r.garbageCollect||[];r.font!==t&&(i=r.data={},o=r.garbageCollect=[],r.font=t),e.save(),e.font=t;let s=0,a=n.length,l,u,c,d,h;for(l=0;l<a;l++)if(d=n[l],d!=null&&!Ln(d))s=mb(e,i,o,s,d);else if(Ln(d))for(u=0,c=d.length;u<c;u++)h=d[u],h!=null&&!Ln(h)&&(s=mb(e,i,o,s,h));e.restore();let f=o.length/2;if(f>n.length){for(l=0;l<f;l++)delete i[o[l]];o.splice(0,f)}return s}function Ld(e,t,n){let r=e.currentDevicePixelRatio,i=n!==0?Math.max(n/2,.5):0;return Math.round((t-i)*r)/r+i}function ED(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function Hk(e,t,n,r){OD(e,t,n,r,null)}function OD(e,t,n,r,i){let o,s,a,l,u,c,d,h,f=t.pointStyle,p=t.rotation,m=t.radius,g=(p||0)*_Se;if(f&&typeof f=="object"&&(o=f.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,r),e.rotate(g),e.drawImage(f,-f.width/2,-f.height/2,f.width,f.height),e.restore();return}if(!(isNaN(m)||m<=0)){switch(e.beginPath(),f){default:i?e.ellipse(n,r,i/2,m,0,0,Bn):e.arc(n,r,m,0,Bn),e.closePath();break;case"triangle":c=i?i/2:m,e.moveTo(n+Math.sin(g)*c,r-Math.cos(g)*m),g+=OU,e.lineTo(n+Math.sin(g)*c,r-Math.cos(g)*m),g+=OU,e.lineTo(n+Math.sin(g)*c,r-Math.cos(g)*m),e.closePath();break;case"rectRounded":u=m*.516,l=m-u,s=Math.cos(g+Jf)*l,d=Math.cos(g+Jf)*(i?i/2-u:l),a=Math.sin(g+Jf)*l,h=Math.sin(g+Jf)*(i?i/2-u:l),e.arc(n-d,r-a,u,g-Gt,g-Sr),e.arc(n+h,r-s,u,g-Sr,g),e.arc(n+d,r+a,u,g,g+Sr),e.arc(n-h,r+s,u,g+Sr,g+Gt),e.closePath();break;case"rect":if(!p){l=Math.SQRT1_2*m,c=i?i/2:l,e.rect(n-c,r-l,2*c,2*l);break}g+=Jf;case"rectRot":d=Math.cos(g)*(i?i/2:m),s=Math.cos(g)*m,a=Math.sin(g)*m,h=Math.sin(g)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+h,r-s),e.lineTo(n+d,r+a),e.lineTo(n-h,r+s),e.closePath();break;case"crossRot":g+=Jf;case"cross":d=Math.cos(g)*(i?i/2:m),s=Math.cos(g)*m,a=Math.sin(g)*m,h=Math.sin(g)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+h,r-s),e.lineTo(n-h,r+s);break;case"star":d=Math.cos(g)*(i?i/2:m),s=Math.cos(g)*m,a=Math.sin(g)*m,h=Math.sin(g)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+h,r-s),e.lineTo(n-h,r+s),g+=Jf,d=Math.cos(g)*(i?i/2:m),s=Math.cos(g)*m,a=Math.sin(g)*m,h=Math.sin(g)*(i?i/2:m),e.moveTo(n-d,r-a),e.lineTo(n+d,r+a),e.moveTo(n+h,r-s),e.lineTo(n-h,r+s);break;case"line":s=i?i/2:Math.cos(g)*m,a=Math.sin(g)*m,e.moveTo(n-s,r-a),e.lineTo(n+s,r+a);break;case"dash":e.moveTo(n,r),e.lineTo(n+Math.cos(g)*(i?i/2:m),r+Math.sin(g)*m);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function zl(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function vb(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function bb(e){e.restore()}function ZU(e,t,n,r,i){if(!t)return e.lineTo(n.x,n.y);if(i==="middle"){let o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else i==="after"!=!!r?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function e6(e,t,n,r){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(r?t.cp1x:t.cp2x,r?t.cp1y:t.cp2y,r?n.cp2x:n.cp1x,r?n.cp2y:n.cp1y,n.x,n.y)}function qSe(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),Rt(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function zSe(e,t,n,r,i){if(i.strikethrough||i.underline){let o=e.measureText(r),s=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,u=n+o.actualBoundingBoxDescent,c=i.strikethrough?(l+u)/2:u;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(s,c),e.lineTo(a,c),e.stroke()}}function FSe(e,t){let n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Bd(e,t,n,r,i,o={}){let s=Ln(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="",l,u;for(e.save(),e.font=i.string,qSe(e,o),l=0;l<s.length;++l)u=s[l],o.backdrop&&FSe(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),Rt(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(u,n,r,o.maxWidth)),e.fillText(u,n,r,o.maxWidth),zSe(e,n,r,u,o),r+=Number(i.lineHeight);e.restore()}function Rg(e,t){let{x:n,y:r,w:i,h:o,radius:s}=t;e.arc(n+s.topLeft,r+s.topLeft,s.topLeft,1.5*Gt,Gt,!0),e.lineTo(n,r+o-s.bottomLeft),e.arc(n+s.bottomLeft,r+o-s.bottomLeft,s.bottomLeft,Gt,Sr,!0),e.lineTo(n+i-s.bottomRight,r+o),e.arc(n+i-s.bottomRight,r+o-s.bottomRight,s.bottomRight,Sr,0,!0),e.lineTo(n+i,r+s.topRight),e.arc(n+i-s.topRight,r+s.topRight,s.topRight,0,-Sr,!0),e.lineTo(n+s.topLeft,r)}var jSe=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,VSe=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function WSe(e,t){let n=(""+e).match(jSe);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}var USe=e=>+e||0;function $k(e,t){let n={},r=Bt(t),i=r?Object.keys(t):t,o=Bt(e)?r?s=>ht(e[s],e[t[s]]):s=>e[s]:()=>e;for(let s of i)n[s]=USe(o(s));return n}function TD(e){return $k(e,{top:"y",right:"x",bottom:"y",left:"x"})}function qd(e){return $k(e,["topLeft","topRight","bottomLeft","bottomRight"])}function qi(e){let t=TD(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function Vr(e,t){e=e||{},t=t||Kn.font;let n=ht(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let r=ht(e.style,t.style);r&&!(""+r).match(VSe)&&(console.warn('Invalid font style specified: "'+r+'"'),r=void 0);let i={family:ht(e.family,t.family),lineHeight:WSe(ht(e.lineHeight,t.lineHeight),n),size:n,style:r,weight:ht(e.weight,t.weight),string:""};return i.string=BSe(i),i}function Ig(e,t,n,r){let i=!0,o,s,a;for(o=0,s=e.length;o<s;++o)if(a=e[o],a!==void 0&&(t!==void 0&&typeof a=="function"&&(a=a(t),i=!1),n!==void 0&&Ln(a)&&(a=a[n%a.length],i=!1),a!==void 0))return r&&!i&&(r.cacheable=!1),a}function t6(e,t,n){let{min:r,max:i}=e,o=pD(t,(i-r)/2),s=(a,l)=>n&&a===0?0:a+l;return{min:s(r,-Math.abs(o)),max:s(i,o)}}function ac(e,t){return Object.assign(Object.create(e),t)}function Kk(e,t=[""],n,r,i=()=>e[0]){let o=n||e;typeof r>"u"&&(r=i6("_fallback",e));let s={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:r,_getTarget:i,override:a=>Kk([a,...e],t,o,r)};return new Proxy(s,{deleteProperty(a,l){return delete a[l],delete a._keys,delete e[0][l],!0},get(a,l){return n6(a,l,()=>JSe(l,t,e,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,l){return IU(a).includes(l)},ownKeys(a){return IU(a)},set(a,l,u){let c=a._storage||(a._storage=i());return a[l]=c[l]=u,delete a._keys,!0}})}function ep(e,t,n,r){let i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:AD(e,r),setContext:o=>ep(e,o,n,r),override:o=>ep(e.override(o),t,n,r)};return new Proxy(i,{deleteProperty(o,s){return delete o[s],delete e[s],!0},get(o,s,a){return n6(o,s,()=>$Se(o,s,a))},getOwnPropertyDescriptor(o,s){return o._descriptors.allKeys?Reflect.has(e,s)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,s)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,s){return Reflect.has(e,s)},ownKeys(){return Reflect.ownKeys(e)},set(o,s,a){return e[s]=a,delete o[s],!0}})}function AD(e,t={scriptable:!0,indexable:!0}){let{_scriptable:n=t.scriptable,_indexable:r=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:r,isScriptable:ic(n)?n:()=>n,isIndexable:ic(r)?r:()=>r}}var HSe=(e,t)=>e?e+Fk(t):t,DD=(e,t)=>Bt(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function n6(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];let r=n();return e[t]=r,r}function $Se(e,t,n){let{_proxy:r,_context:i,_subProxy:o,_descriptors:s}=e,a=r[t];return ic(a)&&s.isScriptable(t)&&(a=KSe(t,a,e,n)),Ln(a)&&a.length&&(a=YSe(t,a,e,s.isIndexable)),DD(t,a)&&(a=ep(a,i,o&&o[t],s)),a}function KSe(e,t,n,r){let{_proxy:i,_context:o,_subProxy:s,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let l=t(o,s||r);return a.delete(e),DD(e,l)&&(l=RD(i._scopes,i,e,l)),l}function YSe(e,t,n,r){let{_proxy:i,_context:o,_subProxy:s,_descriptors:a}=n;if(typeof o.index<"u"&&r(e))return t[o.index%t.length];if(Bt(t[0])){let l=t,u=i._scopes.filter(c=>c!==l);t=[];for(let c of l){let d=RD(u,i,e,c);t.push(ep(d,o,s&&s[e],a))}}return t}function r6(e,t,n){return ic(e)?e(t,n):e}var QSe=(e,t)=>e===!0?t:typeof e=="string"?sc(t,e):void 0;function GSe(e,t,n,r,i){for(let o of t){let s=QSe(n,o);if(s){e.add(s);let a=r6(s._fallback,n,i);if(typeof a<"u"&&a!==n&&a!==r)return a}else if(s===!1&&typeof r<"u"&&n!==r)return null}return!1}function RD(e,t,n,r){let i=t._rootScopes,o=r6(t._fallback,n,r),s=[...e,...i],a=new Set;a.add(r);let l=RU(a,s,n,o||n,r);return l===null||typeof o<"u"&&o!==n&&(l=RU(a,s,o,l,r),l===null)?!1:Kk(Array.from(a),[""],i,o,()=>XSe(t,n,r))}function RU(e,t,n,r,i){for(;n;)n=GSe(e,t,n,r,i);return n}function XSe(e,t,n){let r=e._getTarget();t in r||(r[t]={});let i=r[t];return Ln(i)&&Bt(n)?n:i||{}}function JSe(e,t,n,r){let i;for(let o of t)if(i=i6(HSe(o,e),n),typeof i<"u")return DD(e,i)?RD(n,r,e,i):i}function i6(e,t){for(let n of t){if(!n)continue;let r=n[e];if(typeof r<"u")return r}}function IU(e){let t=e._keys;return t||(t=e._keys=ZSe(e._scopes)),t}function ZSe(e){let t=new Set;for(let n of e)for(let r of Object.keys(n).filter(i=>!i.startsWith("_")))t.add(r);return Array.from(t)}function ID(e,t,n,r){let{iScale:i}=e,{key:o="r"}=this._parsing,s=new Array(r),a,l,u,c;for(a=0,l=r;a<l;++a)u=a+n,c=t[u],s[a]={r:i.parse(sc(c,o),u)};return s}var eke=Number.EPSILON||1e-14,_g=(e,t)=>t<e.length&&!e[t].skip&&e[t],o6=e=>e==="x"?"y":"x";function tke(e,t,n,r){let i=e.skip?t:e,o=t,s=n.skip?t:n,a=qk(o,i),l=qk(s,o),u=a/(a+l),c=l/(a+l);u=isNaN(u)?0:u,c=isNaN(c)?0:c;let d=r*u,h=r*c;return{previous:{x:o.x-d*(s.x-i.x),y:o.y-d*(s.y-i.y)},next:{x:o.x+h*(s.x-i.x),y:o.y+h*(s.y-i.y)}}}function nke(e,t,n){let r=e.length,i,o,s,a,l,u=_g(e,0);for(let c=0;c<r-1;++c)if(l=u,u=_g(e,c+1),!(!l||!u)){if(Tg(t[c],0,eke)){n[c]=n[c+1]=0;continue}i=n[c]/t[c],o=n[c+1]/t[c],a=Math.pow(i,2)+Math.pow(o,2),!(a<=9)&&(s=3/Math.sqrt(a),n[c]=i*s*t[c],n[c+1]=o*s*t[c])}}function rke(e,t,n="x"){let r=o6(n),i=e.length,o,s,a,l=_g(e,0);for(let u=0;u<i;++u){if(s=a,a=l,l=_g(e,u+1),!a)continue;let c=a[n],d=a[r];s&&(o=(c-s[n])/3,a[`cp1${n}`]=c-o,a[`cp1${r}`]=d-o*t[u]),l&&(o=(l[n]-c)/3,a[`cp2${n}`]=c+o,a[`cp2${r}`]=d+o*t[u])}}function ike(e,t="x"){let n=o6(t),r=e.length,i=Array(r).fill(0),o=Array(r),s,a,l,u=_g(e,0);for(s=0;s<r;++s)if(a=l,l=u,u=_g(e,s+1),!!l){if(u){let c=u[t]-l[t];i[s]=c!==0?(u[n]-l[n])/c:0}o[s]=a?u?Ya(i[s-1])!==Ya(i[s])?0:(i[s-1]+i[s])/2:i[s-1]:i[s]}nke(e,i,o),rke(e,o,t)}function Ik(e,t,n){return Math.max(Math.min(e,n),t)}function oke(e,t){let n,r,i,o,s,a=zl(e[0],t);for(n=0,r=e.length;n<r;++n)s=o,o=a,a=n<r-1&&zl(e[n+1],t),o&&(i=e[n],s&&(i.cp1x=Ik(i.cp1x,t.left,t.right),i.cp1y=Ik(i.cp1y,t.top,t.bottom)),a&&(i.cp2x=Ik(i.cp2x,t.left,t.right),i.cp2y=Ik(i.cp2y,t.top,t.bottom)))}function s6(e,t,n,r,i){let o,s,a,l;if(t.spanGaps&&(e=e.filter(u=>!u.skip)),t.cubicInterpolationMode==="monotone")ike(e,i);else{let u=r?e[e.length-1]:e[0];for(o=0,s=e.length;o<s;++o)a=e[o],l=tke(u,a,e[Math.min(o+1,s-(r?0:1))%s],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,u=a}t.capBezierPoints&&oke(e,n)}function Yk(){return typeof window<"u"&&typeof document<"u"}function Qk(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function zk(e,t,n){let r;return typeof e=="string"?(r=parseInt(e,10),e.indexOf("%")!==-1&&(r=r/100*t.parentNode[n])):r=e,r}var Gk=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function ske(e,t){return Gk(e).getPropertyValue(t)}var ake=["top","right","bottom","left"];function Zf(e,t,n){let r={};n=n?"-"+n:"";for(let i=0;i<4;i++){let o=ake[i];r[o]=parseFloat(e[t+"-"+o+n])||0}return r.width=r.left+r.right,r.height=r.top+r.bottom,r}var lke=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function uke(e,t){let n=e.touches,r=n&&n.length?n[0]:e,{offsetX:i,offsetY:o}=r,s=!1,a,l;if(lke(i,o,e.target))a=i,l=o;else{let u=t.getBoundingClientRect();a=r.clientX-u.left,l=r.clientY-u.top,s=!0}return{x:a,y:l,box:s}}function zd(e,t){if("native"in e)return e;let{canvas:n,currentDevicePixelRatio:r}=t,i=Gk(n),o=i.boxSizing==="border-box",s=Zf(i,"padding"),a=Zf(i,"border","width"),{x:l,y:u,box:c}=uke(e,n),d=s.left+(c&&a.left),h=s.top+(c&&a.top),{width:f,height:p}=t;return o&&(f-=s.width+a.width,p-=s.height+a.height),{x:Math.round((l-d)/f*n.width/r),y:Math.round((u-h)/p*n.height/r)}}function cke(e,t,n){let r,i;if(t===void 0||n===void 0){let o=e&&Qk(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{let s=o.getBoundingClientRect(),a=Gk(o),l=Zf(a,"border","width"),u=Zf(a,"padding");t=s.width-u.width-l.width,n=s.height-u.height-l.height,r=zk(a.maxWidth,o,"clientWidth"),i=zk(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:r||Bk,maxHeight:i||Bk}}var Id=e=>Math.round(e*10)/10;function a6(e,t,n,r){let i=Gk(e),o=Zf(i,"margin"),s=zk(i.maxWidth,e,"clientWidth")||Bk,a=zk(i.maxHeight,e,"clientHeight")||Bk,l=cke(e,t,n),{width:u,height:c}=l;if(i.boxSizing==="content-box"){let h=Zf(i,"border","width"),f=Zf(i,"padding");u-=f.width+h.width,c-=f.height+h.height}return u=Math.max(0,u-o.width),c=Math.max(0,r?u/r:c-o.height),u=Id(Math.min(u,s,l.maxWidth)),c=Id(Math.min(c,a,l.maxHeight)),u&&!c&&(c=Id(u/2)),(t!==void 0||n!==void 0)&&r&&l.height&&c>l.height&&(c=l.height,u=Id(Math.floor(c*r))),{width:u,height:c}}function PD(e,t,n){let r=t||1,i=Id(e.height*r),o=Id(e.width*r);e.height=Id(e.height),e.width=Id(e.width);let s=e.canvas;return s.style&&(n||!s.style.height&&!s.style.width)&&(s.style.height=`${e.height}px`,s.style.width=`${e.width}px`),e.currentDevicePixelRatio!==r||s.height!==i||s.width!==o?(e.currentDevicePixelRatio=r,s.height=i,s.width=o,e.ctx.setTransform(r,0,0,r,0,0),!0):!1}var l6=function(){let e=!1;try{let t={get passive(){return e=!0,!1}};Yk()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e}();function LD(e,t){let n=ske(e,t),r=n&&n.match(/^(\d+)(\.\d+)?px$/);return r?+r[1]:void 0}function Rd(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function u6(e,t,n,r){return{x:e.x+n*(t.x-e.x),y:r==="middle"?n<.5?e.y:t.y:r==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function c6(e,t,n,r){let i={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},s=Rd(e,i,n),a=Rd(i,o,n),l=Rd(o,t,n),u=Rd(s,a,n),c=Rd(a,l,n);return Rd(u,c,n)}var dke=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,r){return n-r},leftForLtr(n,r){return n-r}}},hke=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function np(e,t,n){return e?dke(t,n):hke()}function BD(e,t){let n,r;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,r=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=r)}function qD(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function d6(e){return e==="angle"?{between:Ag,compare:OSe,normalize:Li}:{between:jl,compare:(t,n)=>t-n,normalize:t=>t}}function PU({start:e,end:t,count:n,loop:r,style:i}){return{start:e%n,end:t%n,loop:r&&(t-e+1)%n===0,style:i}}function fke(e,t,n){let{property:r,start:i,end:o}=n,{between:s,normalize:a}=d6(r),l=t.length,{start:u,end:c,loop:d}=e,h,f;if(d){for(u+=l,c+=l,h=0,f=l;h<f&&s(a(t[u%l][r]),i,o);++h)u--,c--;u%=l,c%=l}return c<u&&(c+=l),{start:u,end:c,loop:d,style:e.style}}function zD(e,t,n){if(!n)return[e];let{property:r,start:i,end:o}=n,s=t.length,{compare:a,between:l,normalize:u}=d6(r),{start:c,end:d,loop:h,style:f}=fke(e,t,n),p=[],m=!1,g=null,y,v,b,w=()=>l(i,b,y)&&a(i,b)!==0,x=()=>a(o,y)===0||l(o,b,y),S=()=>m||w(),k=()=>!m||x();for(let C=c,N=c;C<=d;++C)v=t[C%s],!v.skip&&(y=u(v[r]),y!==b&&(m=l(y,i,o),g===null&&S()&&(g=a(y,i)===0?C:N),g!==null&&k()&&(p.push(PU({start:g,end:C,loop:h,count:s,style:f})),g=null),N=C,b=y));return g!==null&&p.push(PU({start:g,end:d,loop:h,count:s,style:f})),p}function FD(e,t){let n=[],r=e.segments;for(let i=0;i<r.length;i++){let o=zD(r[i],e.points,t);o.length&&n.push(...o)}return n}function pke(e,t,n,r){let i=0,o=t-1;if(n&&!r)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(o+=i);o>i&&e[o%t].skip;)o--;return o%=t,{start:i,end:o}}function mke(e,t,n,r){let i=e.length,o=[],s=t,a=e[t],l;for(l=t+1;l<=n;++l){let u=e[l%i];u.skip||u.stop?a.skip||(r=!1,o.push({start:t%i,end:(l-1)%i,loop:r}),t=s=u.stop?l:null):(s=l,a.skip&&(t=l)),a=u}return s!==null&&o.push({start:t%i,end:s%i,loop:r}),o}function h6(e,t){let n=e.points,r=e.options.spanGaps,i=n.length;if(!i)return[];let o=!!e._loop,{start:s,end:a}=pke(n,i,o,r);if(r===!0)return LU(e,[{start:s,end:a,loop:o}],n,t);let l=a<s?a+i:a,u=!!e._fullLoop&&s===0&&a===i-1;return LU(e,mke(n,s,l,u),n,t)}function LU(e,t,n,r){return!r||!r.setContext||!n?t:gke(e,t,n,r)}function gke(e,t,n,r){let i=e._chart.getContext(),o=BU(e.options),{_datasetIndex:s,options:{spanGaps:a}}=e,l=n.length,u=[],c=o,d=t[0].start,h=d;function f(p,m,g,y){let v=a?-1:1;if(p!==m){for(p+=l;n[p%l].skip;)p-=v;for(;n[m%l].skip;)m+=v;p%l!==m%l&&(u.push({start:p%l,end:m%l,loop:g,style:y}),c=y,d=m%l)}}for(let p of t){d=a?d:p.start;let m=n[d%l],g;for(h=d+1;h<=p.end;h++){let y=n[h%l];g=BU(r.setContext(ac(i,{type:"segment",p0:m,p1:y,p0DataIndex:(h-1)%l,p1DataIndex:h%l,datasetIndex:s}))),yke(g,c)&&f(d,h-1,p.loop,c),m=y,c=g}d<h-1&&f(d,h-1,p.loop,c)}return u}function BU(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function yke(e,t){if(!t)return!1;let n=[],r=function(i,o){return MD(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,r)!==JSON.stringify(t,r)}function Pk(e,t,n){return e.options.clip?e[n]:t[n]}function vke(e,t){let{xScale:n,yScale:r}=e;return n&&r?{left:Pk(n,t,"left"),right:Pk(n,t,"right"),top:Pk(r,t,"top"),bottom:Pk(r,t,"bottom")}:t}function jD(e,t){let n=t._clip;if(n.disabled)return!1;let r=vke(t,e.chartArea);return{left:n.left===!1?0:r.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:r.right+(n.right===!0?0:n.right),top:n.top===!1?0:r.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:r.bottom+(n.bottom===!0?0:n.bottom)}}var ZD=class{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,r,i){let o=n.listeners[i],s=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:s,currentStep:Math.min(r-n.start,s)}))}_refresh(){this._request||(this._running=!0,this._request=SD.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((r,i)=>{if(!r.running||!r.items.length)return;let o=r.items,s=o.length-1,a=!1,l;for(;s>=0;--s)l=o[s],l._active?(l._total>r.duration&&(r.duration=l._total),l.tick(t),a=!0):(o[s]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,r,t,"progress")),o.length||(r.running=!1,this._notify(i,r,t,"complete"),r.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){let n=this._charts,r=n.get(t);return r||(r={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,r)),r}listen(t,n,r){this._getAnims(t).listeners[n].push(r)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){let n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((r,i)=>Math.max(r,i._duration),0),this._refresh())}running(t){if(!this._running)return!1;let n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){let n=this._charts.get(t);if(!n||!n.items.length)return;let r=n.items,i=r.length-1;for(;i>=0;--i)r[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}},lc=new ZD,f6="transparent",bke={boolean(e,t,n){return n>.5?t:e},color(e,t,n){let r=_D(e||f6),i=r.valid&&_D(t||f6);return i&&i.valid?i.mix(r,n).hexString():t},number(e,t,n){return e+(t-e)*n}},e2=class{constructor(t,n,r,i){let o=n[r];i=Ig([t.to,i,o,t.from]);let s=Ig([t.from,o,i]);this._active=!0,this._fn=t.fn||bke[t.type||typeof s],this._easing=Ng[t.easing]||Ng.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=r,this._from=s,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,r){if(this._active){this._notify(!1);let i=this._target[this._prop],o=r-this._start,s=this._duration-o;this._start=r,this._duration=Math.floor(Math.max(s,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=Ig([t.to,n,i,t.from]),this._from=Ig([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){let n=t-this._start,r=this._duration,i=this._prop,o=this._from,s=this._loop,a=this._to,l;if(this._active=o!==a&&(s||n<r),!this._active){this._target[i]=a,this._notify(!0);return}if(n<0){this._target[i]=o;return}l=n/r%2,l=s&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[i]=this._fn(o,a,l)}wait(){let t=this._promises||(this._promises=[]);return new Promise((n,r)=>{t.push({res:n,rej:r})})}_notify(t){let n=t?"res":"rej",r=this._promises||[];for(let i=0;i<r.length;i++)r[i][n]()}},oC=class{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!Bt(t))return;let n=Object.keys(Kn.animation),r=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{let o=t[i];if(!Bt(o))return;let s={};for(let a of n)s[a]=o[a];(Ln(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!r.has(a))&&r.set(a,s)})})}_animateOptions(t,n){let r=n.options,i=xke(t,r);if(!i)return[];let o=this._createAnimations(i,r);return r.$shared&&wke(t.options.$animations,r).then(()=>{t.options=r},()=>{}),o}_createAnimations(t,n){let r=this._properties,i=[],o=t.$animations||(t.$animations={}),s=Object.keys(n),a=Date.now(),l;for(l=s.length-1;l>=0;--l){let u=s[l];if(u.charAt(0)==="$")continue;if(u==="options"){i.push(...this._animateOptions(t,n));continue}let c=n[u],d=o[u],h=r.get(u);if(d)if(h&&d.active()){d.update(h,c,a);continue}else d.cancel();if(!h||!h.duration){t[u]=c;continue}o[u]=d=new e2(h,t,u,c),i.push(d)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}let r=this._createAnimations(t,n);if(r.length)return lc.add(this._chart,r),!0}};function wke(e,t){let n=[],r=Object.keys(t);for(let i=0;i<r.length;i++){let o=e[r[i]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function xke(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function p6(e,t){let n=e&&e.options||{},r=n.reverse,i=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:r?o:i,end:r?i:o}}function Ske(e,t,n){if(n===!1)return!1;let r=p6(e,n),i=p6(t,n);return{top:i.end,right:r.end,bottom:i.start,left:r.start}}function kke(e){let t,n,r,i;return Bt(e)?(t=e.top,n=e.right,r=e.bottom,i=e.left):t=n=r=i=e,{top:t,right:n,bottom:r,left:i,disabled:e===!1}}function hH(e,t){let n=[],r=e._getSortedDatasetMetas(t),i,o;for(i=0,o=r.length;i<o;++i)n.push(r[i].index);return n}function m6(e,t,n,r={}){let i=e.keys,o=r.mode==="single",s,a,l,u;if(t===null)return;let c=!1;for(s=0,a=i.length;s<a;++s){if(l=+i[s],l===n){if(c=!0,r.all)continue;break}u=e.values[l],fr(u)&&(o||t===0||Ya(t)===Ya(u))&&(t+=u)}return!c&&!r.all?0:t}function Cke(e,t){let{iScale:n,vScale:r}=t,i=n.axis==="x"?"x":"y",o=r.axis==="x"?"x":"y",s=Object.keys(e),a=new Array(s.length),l,u,c;for(l=0,u=s.length;l<u;++l)c=s[l],a[l]={[i]:c,[o]:e[c]};return a}function VD(e,t){let n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Nke(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function Mke(e){let{min:t,max:n,minDefined:r,maxDefined:i}=e.getUserBounds();return{min:r?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function _ke(e,t,n){let r=e[t]||(e[t]={});return r[n]||(r[n]={})}function g6(e,t,n,r){for(let i of t.getMatchingVisibleMetas(r).reverse()){let o=e[i.index];if(n&&o>0||!n&&o<0)return i.index}return null}function y6(e,t){let{chart:n,_cachedMeta:r}=e,i=n._stacks||(n._stacks={}),{iScale:o,vScale:s,index:a}=r,l=o.axis,u=s.axis,c=Nke(o,s,r),d=t.length,h;for(let f=0;f<d;++f){let p=t[f],{[l]:m,[u]:g}=p,y=p._stacks||(p._stacks={});h=y[u]=_ke(i,c,m),h[a]=g,h._top=g6(h,s,!0,r.type),h._bottom=g6(h,s,!1,r.type);let v=h._visualValues||(h._visualValues={});v[a]=g}}function WD(e,t){let n=e.scales;return Object.keys(n).filter(r=>n[r].axis===t).shift()}function Eke(e,t){return ac(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function Oke(e,t,n){return ac(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function wb(e,t){let n=e.controller.index,r=e.vScale&&e.vScale.axis;if(r){t=t||e._parsed;for(let i of t){let o=i._stacks;if(!o||o[r]===void 0||o[r][n]===void 0)return;delete o[r][n],o[r]._visualValues!==void 0&&o[r]._visualValues[n]!==void 0&&delete o[r]._visualValues[n]}}}var UD=e=>e==="reset"||e==="none",v6=(e,t)=>t?e:Object.assign({},e),Tke=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:hH(n,!0),values:null},Ul=class{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){let t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=VD(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&wb(this._cachedMeta),this.index=t}linkScales(){let t=this.chart,n=this._cachedMeta,r=this.getDataset(),i=(d,h,f,p)=>d==="x"?h:d==="r"?p:f,o=n.xAxisID=ht(r.xAxisID,WD(t,"x")),s=n.yAxisID=ht(r.yAxisID,WD(t,"y")),a=n.rAxisID=ht(r.rAxisID,WD(t,"r")),l=n.indexAxis,u=n.iAxisID=i(l,o,s,a),c=n.vAxisID=i(l,s,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(s),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(u),n.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){let n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){let t=this._cachedMeta;this._data&&wD(this._data,this),t._stacked&&wb(t)}_dataCheck(){let t=this.getDataset(),n=t.data||(t.data=[]),r=this._data;if(Bt(n)){let i=this._cachedMeta;this._data=Cke(n,i)}else if(r!==n){if(r){wD(r,this);let i=this._cachedMeta;wb(i),i._parsed=[]}n&&Object.isExtensible(n)&&YU(n,this),this._syncList=[],this._data=n}}addElements(){let t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){let n=this._cachedMeta,r=this.getDataset(),i=!1;this._dataCheck();let o=n._stacked;n._stacked=VD(n.vScale,n),n.stack!==r.stack&&(i=!0,wb(n),n.stack=r.stack),this._resyncElements(t),(i||o!==n._stacked)&&(y6(this,n._parsed),n._stacked=VD(n.vScale,n))}configure(){let t=this.chart.config,n=t.datasetScopeKeys(this._type),r=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(r,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){let{_cachedMeta:r,_data:i}=this,{iScale:o,_stacked:s}=r,a=o.axis,l=t===0&&n===i.length?!0:r._sorted,u=t>0&&r._parsed[t-1],c,d,h;if(this._parsing===!1)r._parsed=i,r._sorted=!0,h=i;else{Ln(i[t])?h=this.parseArrayData(r,i,t,n):Bt(i[t])?h=this.parseObjectData(r,i,t,n):h=this.parsePrimitiveData(r,i,t,n);let f=()=>d[a]===null||u&&d[a]<u[a];for(c=0;c<n;++c)r._parsed[c+t]=d=h[c],l&&(f()&&(l=!1),u=d);r._sorted=l}s&&y6(this,h)}parsePrimitiveData(t,n,r,i){let{iScale:o,vScale:s}=t,a=o.axis,l=s.axis,u=o.getLabels(),c=o===s,d=new Array(i),h,f,p;for(h=0,f=i;h<f;++h)p=h+r,d[h]={[a]:c||o.parse(u[p],p),[l]:s.parse(n[p],p)};return d}parseArrayData(t,n,r,i){let{xScale:o,yScale:s}=t,a=new Array(i),l,u,c,d;for(l=0,u=i;l<u;++l)c=l+r,d=n[c],a[l]={x:o.parse(d[0],c),y:s.parse(d[1],c)};return a}parseObjectData(t,n,r,i){let{xScale:o,yScale:s}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,u=new Array(i),c,d,h,f;for(c=0,d=i;c<d;++c)h=c+r,f=n[h],u[c]={x:o.parse(sc(f,a),h),y:s.parse(sc(f,l),h)};return u}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,r){let i=this.chart,o=this._cachedMeta,s=n[t.axis],a={keys:hH(i,!0),values:n._stacks[t.axis]._visualValues};return m6(a,s,o.index,{mode:r})}updateRangeFromParsed(t,n,r,i){let o=r[n.axis],s=o===null?NaN:o,a=i&&r._stacks[n.axis];i&&a&&(i.values=a,s=m6(i,o,this._cachedMeta.index)),t.min=Math.min(t.min,s),t.max=Math.max(t.max,s)}getMinMax(t,n){let r=this._cachedMeta,i=r._parsed,o=r._sorted&&t===r.iScale,s=i.length,a=this._getOtherScale(t),l=Tke(n,r,this.chart),u={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:c,max:d}=Mke(a),h,f;function p(){f=i[h];let m=f[a.axis];return!fr(f[t.axis])||c>m||d<m}for(h=0;h<s&&!(!p()&&(this.updateRangeFromParsed(u,t,f,l),o));++h);if(o){for(h=s-1;h>=0;--h)if(!p()){this.updateRangeFromParsed(u,t,f,l);break}}return u}getAllParsedValues(t){let n=this._cachedMeta._parsed,r=[],i,o,s;for(i=0,o=n.length;i<o;++i)s=n[i][t.axis],fr(s)&&r.push(s);return r}getMaxOverflow(){return!1}getLabelAndValue(t){let n=this._cachedMeta,r=n.iScale,i=n.vScale,o=this.getParsed(t);return{label:r?""+r.getLabelForValue(o[r.axis]):"",value:i?""+i.getLabelForValue(o[i.axis]):""}}_update(t){let n=this._cachedMeta;this.update(t||"default"),n._clip=kke(ht(this.options.clip,Ske(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){let t=this._ctx,n=this.chart,r=this._cachedMeta,i=r.data||[],o=n.chartArea,s=[],a=this._drawStart||0,l=this._drawCount||i.length-a,u=this.options.drawActiveElementsOnTop,c;for(r.dataset&&r.dataset.draw(t,o,a,l),c=a;c<a+l;++c){let d=i[c];d.hidden||(d.active&&u?s.push(d):d.draw(t,o))}for(c=0;c<s.length;++c)s[c].draw(t,o)}getStyle(t,n){let r=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(r):this.resolveDataElementOptions(t||0,r)}getContext(t,n,r){let i=this.getDataset(),o;if(t>=0&&t<this._cachedMeta.data.length){let s=this._cachedMeta.data[t];o=s.$context||(s.$context=Oke(this.getContext(),t,s)),o.parsed=this.getParsed(t),o.raw=i.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=Eke(this.chart.getContext(),this.index)),o.dataset=i,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=r,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",r){let i=n==="active",o=this._cachedDataOpts,s=t+"-"+n,a=o[s],l=this.enableOptionSharing&&Og(r);if(a)return v6(a,l);let u=this.chart.config,c=u.datasetElementScopeKeys(this._type,t),d=i?[`${t}Hover`,"hover",t,""]:[t,""],h=u.getOptionScopes(this.getDataset(),c),f=Object.keys(Kn.elements[t]),p=()=>this.getContext(r,i,n),m=u.resolveNamedOptions(h,f,p,d);return m.$shared&&(m.$shared=l,o[s]=Object.freeze(v6(m,l))),m}_resolveAnimations(t,n,r){let i=this.chart,o=this._cachedDataOpts,s=`animation-${n}`,a=o[s];if(a)return a;let l;if(i.options.animation!==!1){let c=this.chart.config,d=c.datasetAnimationScopeKeys(this._type,n),h=c.getOptionScopes(this.getDataset(),d);l=c.createResolver(h,this.getContext(t,r,n))}let u=new oC(i,l&&l.animations);return l&&l._cacheable&&(o[s]=Object.freeze(u)),u}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||UD(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){let r=this.resolveDataElementOptions(t,n),i=this._sharedOptions,o=this.getSharedOptions(r),s=this.includeOptions(n,o)||o!==i;return this.updateSharedOptions(o,n,r),{sharedOptions:o,includeOptions:s}}updateElement(t,n,r,i){UD(i)?Object.assign(t,r):this._resolveAnimations(n,i).update(t,r)}updateSharedOptions(t,n,r){t&&!UD(n)&&this._resolveAnimations(void 0,n).update(t,r)}_setStyle(t,n,r,i){t.active=i;let o=this.getStyle(n,i);this._resolveAnimations(n,r,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,r){this._setStyle(t,r,"active",!1)}setHoverStyle(t,n,r){this._setStyle(t,r,"active",!0)}_removeDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){let t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){let n=this._data,r=this._cachedMeta.data;for(let[a,l,u]of this._syncList)this[a](l,u);this._syncList=[];let i=r.length,o=n.length,s=Math.min(o,i);s&&this.parse(0,s),o>i?this._insertElements(i,o-i,t):o<i&&this._removeElements(o,i-o)}_insertElements(t,n,r=!0){let i=this._cachedMeta,o=i.data,s=t+n,a,l=u=>{for(u.length+=n,a=u.length-1;a>=s;a--)u[a]=u[a-n]};for(l(o),a=t;a<s;++a)o[a]=new this.dataElementType;this._parsing&&l(i._parsed),this.parse(t,n),r&&this.updateElements(o,t,n,"reset")}updateElements(t,n,r,i){}_removeElements(t,n){let r=this._cachedMeta;if(this._parsing){let i=r._parsed.splice(t,n);r._stacked&&wb(r,i)}r.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{let[n,r,i]=t;this[n](r,i)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){let t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);let r=arguments.length-2;r&&this._sync(["_insertElements",t,r])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}};function Ake(e,t){if(!e._cache.$bar){let n=e.getMatchingVisibleMetas(t),r=[];for(let i=0,o=n.length;i<o;i++)r=r.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=xD(r.sort((i,o)=>i-o))}return e._cache.$bar}function Dke(e){let t=e.iScale,n=Ake(t,e.type),r=t._length,i,o,s,a,l=()=>{s===32767||s===-32768||(Og(a)&&(r=Math.min(r,Math.abs(s-a)||r)),a=s)};for(i=0,o=n.length;i<o;++i)s=t.getPixelForValue(n[i]),l();for(a=void 0,i=0,o=t.ticks.length;i<o;++i)s=t.getPixelForTick(i),l();return r}function Rke(e,t,n,r){let i=n.barThickness,o,s;return Rt(i)?(o=t.min*n.categoryPercentage,s=n.barPercentage):(o=i*r,s=1),{chunk:o/r,ratio:s,start:t.pixels[e]-o/2}}function Ike(e,t,n,r){let i=t.pixels,o=i[e],s=e>0?i[e-1]:null,a=e<i.length-1?i[e+1]:null,l=n.categoryPercentage;s===null&&(s=o-(a===null?t.end-t.start:a-o)),a===null&&(a=o+o-s);let u=o-(o-Math.min(s,a))/2*l;return{chunk:Math.abs(a-s)/2*l/r,ratio:n.barPercentage,start:u}}function Pke(e,t,n,r){let i=n.parse(e[0],r),o=n.parse(e[1],r),s=Math.min(i,o),a=Math.max(i,o),l=s,u=a;Math.abs(s)>Math.abs(a)&&(l=a,u=s),t[n.axis]=u,t._custom={barStart:l,barEnd:u,start:i,end:o,min:s,max:a}}function fH(e,t,n,r){return Ln(e)?Pke(e,t,n,r):t[n.axis]=n.parse(e,r),t}function b6(e,t,n,r){let i=e.iScale,o=e.vScale,s=i.getLabels(),a=i===o,l=[],u,c,d,h;for(u=n,c=n+r;u<c;++u)h=t[u],d={},d[i.axis]=a||i.parse(s[u],u),l.push(fH(h,d,o,u));return l}function HD(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function Lke(e,t,n){return e!==0?Ya(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function Bke(e){let t,n,r,i,o;return e.horizontal?(t=e.base>e.x,n="left",r="right"):(t=e.base<e.y,n="bottom",r="top"),t?(i="end",o="start"):(i="start",o="end"),{start:n,end:r,reverse:t,top:i,bottom:o}}function qke(e,t,n,r){let i=t.borderSkipped,o={};if(!i){e.borderSkipped=o;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}let{start:s,end:a,reverse:l,top:u,bottom:c}=Bke(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===r?i=u:(n._bottom||0)===r?i=c:(o[w6(c,s,a,l)]=!0,i=u)),o[w6(i,s,a,l)]=!0,e.borderSkipped=o}function w6(e,t,n,r){return r?(e=zke(e,t,n),e=x6(e,n,t)):e=x6(e,t,n),e}function zke(e,t,n){return e===t?n:e===n?t:e}function x6(e,t,n){return e==="start"?t:e==="end"?n:e}function Fke(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}var t2=class extends Ul{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,n,r,i){return b6(t,n,r,i)}parseArrayData(t,n,r,i){return b6(t,n,r,i)}parseObjectData(t,n,r,i){let{iScale:o,vScale:s}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,u=o.axis==="x"?a:l,c=s.axis==="x"?a:l,d=[],h,f,p,m;for(h=r,f=r+i;h<f;++h)m=n[h],p={},p[o.axis]=o.parse(sc(m,u),h),d.push(fH(sc(m,c),p,s,h));return d}updateRangeFromParsed(t,n,r,i){super.updateRangeFromParsed(t,n,r,i);let o=r._custom;o&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,o.min),t.max=Math.max(t.max,o.max))}getMaxOverflow(){return 0}getLabelAndValue(t){let n=this._cachedMeta,{iScale:r,vScale:i}=n,o=this.getParsed(t),s=o._custom,a=HD(s)?"["+s.start+", "+s.end+"]":""+i.getLabelForValue(o[i.axis]);return{label:""+r.getLabelForValue(o[r.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();let t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){let n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,r,i){let o=i==="reset",{index:s,_cachedMeta:{vScale:a}}=this,l=a.getBasePixel(),u=a.isHorizontal(),c=this._getRuler(),{sharedOptions:d,includeOptions:h}=this._getSharedOptions(n,i);for(let f=n;f<n+r;f++){let p=this.getParsed(f),m=o||Rt(p[a.axis])?{base:l,head:l}:this._calculateBarValuePixels(f),g=this._calculateBarIndexPixels(f,c),y=(p._stacks||{})[a.axis],v={horizontal:u,base:m.base,enableBorderRadius:!y||HD(p._custom)||s===y._top||s===y._bottom,x:u?m.head:g.center,y:u?g.center:m.head,height:u?g.size:Math.abs(m.size),width:u?Math.abs(m.size):g.size};h&&(v.options=d||this.resolveDataElementOptions(f,t[f].active?"active":i));let b=v.options||t[f].options;qke(v,b,y,s),Fke(v,b,c.ratio),this.updateElement(t[f],f,v,i)}}_getStacks(t,n){let{iScale:r}=this._cachedMeta,i=r.getMatchingVisibleMetas(this._type).filter(c=>c.controller.options.grouped),o=r.options.stacked,s=[],a=this._cachedMeta.controller.getParsed(n),l=a&&a[r.axis],u=c=>{let d=c._parsed.find(f=>f[r.axis]===l),h=d&&d[c.vScale.axis];if(Rt(h)||isNaN(h))return!0};for(let c of i)if(!(n!==void 0&&u(c))&&((o===!1||s.indexOf(c.stack)===-1||o===void 0&&c.stack===void 0)&&s.push(c.stack),c.index===t))break;return s.length||s.push(void 0),s}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){let t=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(t).filter(r=>t[r].axis===n).shift()}_getAxis(){let t={},n=this.getFirstScaleIdForIndexAxis();for(let r of this.chart.data.datasets)t[ht(this.chart.options.indexAxis==="x"?r.xAxisID:r.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,r){let i=this._getStacks(t,r),o=n!==void 0?i.indexOf(n):-1;return o===-1?i.length-1:o}_getRuler(){let t=this.options,n=this._cachedMeta,r=n.iScale,i=[],o,s;for(o=0,s=n.data.length;o<s;++o)i.push(r.getPixelForValue(this.getParsed(o)[r.axis],o));let a=t.barThickness;return{min:a||Dke(n),pixels:i,start:r._startPixel,end:r._endPixel,stackCount:this._getStackCount(),scale:r,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){let{_cachedMeta:{vScale:n,_stacked:r,index:i},options:{base:o,minBarLength:s}}=this,a=o||0,l=this.getParsed(t),u=l._custom,c=HD(u),d=l[n.axis],h=0,f=r?this.applyStack(n,l,r):d,p,m;f!==d&&(h=f-d,f=d),c&&(d=u.barStart,f=u.barEnd-u.barStart,d!==0&&Ya(d)!==Ya(u.barEnd)&&(h=0),h+=d);let g=!Rt(o)&&!c?o:h,y=n.getPixelForValue(g);if(this.chart.getDataVisibility(t)?p=n.getPixelForValue(h+f):p=y,m=p-y,Math.abs(m)<s){m=Lke(m,n,a)*s,d===a&&(y-=m/2);let v=n.getPixelForDecimal(0),b=n.getPixelForDecimal(1),w=Math.min(v,b),x=Math.max(v,b);y=Math.max(Math.min(y,x),w),p=y+m,r&&!c&&(l._stacks[n.axis]._visualValues[i]=n.getValueForPixel(p)-n.getValueForPixel(y))}if(y===n.getPixelForValue(a)){let v=Ya(m)*n.getLineWidthForValue(a)/2;y+=v,m-=v}return{size:m,base:y,head:p,center:p+m/2}}_calculateBarIndexPixels(t,n){let r=n.scale,i=this.options,o=i.skipNull,s=ht(i.maxBarThickness,1/0),a,l,u=this._getAxisCount();if(n.grouped){let c=o?this._getStackCount(t):n.stackCount,d=i.barThickness==="flex"?Ike(t,n,i,c*u):Rke(t,n,i,c*u),h=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,f=this._getAxis().indexOf(ht(h,this.getFirstScaleIdForIndexAxis())),p=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0)+f;a=d.start+d.chunk*p+d.chunk/2,l=Math.min(s,d.chunk*d.ratio)}else a=r.getPixelForValue(this.getParsed(t)[r.axis],t),l=Math.min(s,n.min*n.ratio);return{base:a-l/2,head:a+l/2,center:a,size:l}}draw(){let t=this._cachedMeta,n=t.vScale,r=t.data,i=r.length,o=0;for(;o<i;++o)this.getParsed(o)[n.axis]!==null&&!r[o].hidden&&r[o].draw(this._ctx)}},n2=class extends Ul{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,r,i){let o=super.parsePrimitiveData(t,n,r,i);for(let s=0;s<o.length;s++)o[s]._custom=this.resolveDataElementOptions(s+r).radius;return o}parseArrayData(t,n,r,i){let o=super.parseArrayData(t,n,r,i);for(let s=0;s<o.length;s++){let a=n[r+s];o[s]._custom=ht(a[2],this.resolveDataElementOptions(s+r).radius)}return o}parseObjectData(t,n,r,i){let o=super.parseObjectData(t,n,r,i);for(let s=0;s<o.length;s++){let a=n[r+s];o[s]._custom=ht(a&&a.r&&+a.r,this.resolveDataElementOptions(s+r).radius)}return o}getMaxOverflow(){let t=this._cachedMeta.data,n=0;for(let r=t.length-1;r>=0;--r)n=Math.max(n,t[r].size(this.resolveDataElementOptions(r))/2);return n>0&&n}getLabelAndValue(t){let n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:o}=n,s=this.getParsed(t),a=i.getLabelForValue(s.x),l=o.getLabelForValue(s.y),u=s._custom;return{label:r[t]||"",value:"("+a+", "+l+(u?", "+u:"")+")"}}update(t){let n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,r,i){let o=i==="reset",{iScale:s,vScale:a}=this._cachedMeta,{sharedOptions:l,includeOptions:u}=this._getSharedOptions(n,i),c=s.axis,d=a.axis;for(let h=n;h<n+r;h++){let f=t[h],p=!o&&this.getParsed(h),m={},g=m[c]=o?s.getPixelForDecimal(.5):s.getPixelForValue(p[c]),y=m[d]=o?a.getBasePixel():a.getPixelForValue(p[d]);m.skip=isNaN(g)||isNaN(y),u&&(m.options=l||this.resolveDataElementOptions(h,f.active?"active":i),o&&(m.options.radius=0)),this.updateElement(f,h,m,i)}}resolveDataElementOptions(t,n){let r=this.getParsed(t),i=super.resolveDataElementOptions(t,n);i.$shared&&(i=Object.assign({},i,{$shared:!1}));let o=i.radius;return n!=="active"&&(i.radius=0),i.radius+=ht(r&&r._custom,o),i}};function jke(e,t,n){let r=1,i=1,o=0,s=0;if(t<Bn){let a=e,l=a+t,u=Math.cos(a),c=Math.sin(a),d=Math.cos(l),h=Math.sin(l),f=(b,w,x)=>Ag(b,a,l,!0)?1:Math.max(w,w*n,x,x*n),p=(b,w,x)=>Ag(b,a,l,!0)?-1:Math.min(w,w*n,x,x*n),m=f(0,u,d),g=f(Sr,c,h),y=p(Gt,u,d),v=p(Gt+Sr,c,h);r=(m-y)/2,i=(g-v)/2,o=-(m+y)/2,s=-(g+v)/2}return{ratioX:r,ratioY:i,offsetX:o,offsetY:s}}var _b=class extends Ul{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let n=t.data,{labels:{pointStyle:r,textAlign:i,color:o,useBorderRadius:s,borderRadius:a}}=t.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((l,u)=>{let d=t.getDatasetMeta(0).controller.getStyle(u);return{text:l,fillStyle:d.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(u),lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:d.borderWidth,strokeStyle:d.borderColor,textAlign:i,pointStyle:r,borderRadius:s&&(a||d.borderRadius),index:u}}):[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}}};constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){let r=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=r;else{let o=l=>+r[l];if(Bt(r[t])){let{key:l="value"}=this._parsing;o=u=>+sc(r[u],l)}let s,a;for(s=t,a=t+n;s<a;++s)i._parsed[s]=o(s)}}_getRotation(){return oa(this.options.rotation-90)}_getCircumference(){return oa(this.options.circumference)}_getRotationExtents(){let t=Bn,n=-Bn;for(let r=0;r<this.chart.data.datasets.length;++r)if(this.chart.isDatasetVisible(r)&&this.chart.getDatasetMeta(r).type===this._type){let i=this.chart.getDatasetMeta(r).controller,o=i._getRotation(),s=i._getCircumference();t=Math.min(t,o),n=Math.max(n,o+s)}return{rotation:t,circumference:n-t}}update(t){let n=this.chart,{chartArea:r}=n,i=this._cachedMeta,o=i.data,s=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(r.width,r.height)-s)/2,0),l=Math.min(zU(this.options.cutout,a),1),u=this._getRingWeight(this.index),{circumference:c,rotation:d}=this._getRotationExtents(),{ratioX:h,ratioY:f,offsetX:p,offsetY:m}=jke(d,c,l),g=(r.width-s)/h,y=(r.height-s)/f,v=Math.max(Math.min(g,y)/2,0),b=pD(this.options.radius,v),w=Math.max(b*l,0),x=(b-w)/this._getVisibleDatasetWeightTotal();this.offsetX=p*b,this.offsetY=m*b,i.total=this.calculateTotal(),this.outerRadius=b-x*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-x*u,0),this.updateElements(o,0,o.length,t)}_circumference(t,n){let r=this.options,i=this._cachedMeta,o=this._getCircumference();return n&&r.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*o/Bn)}updateElements(t,n,r,i){let o=i==="reset",s=this.chart,a=s.chartArea,u=s.options.animation,c=(a.left+a.right)/2,d=(a.top+a.bottom)/2,h=o&&u.animateScale,f=h?0:this.innerRadius,p=h?0:this.outerRadius,{sharedOptions:m,includeOptions:g}=this._getSharedOptions(n,i),y=this._getRotation(),v;for(v=0;v<n;++v)y+=this._circumference(v,o);for(v=n;v<n+r;++v){let b=this._circumference(v,o),w=t[v],x={x:c+this.offsetX,y:d+this.offsetY,startAngle:y,endAngle:y+b,circumference:b,outerRadius:p,innerRadius:f};g&&(x.options=m||this.resolveDataElementOptions(v,w.active?"active":i)),y+=b,this.updateElement(w,v,x,i)}}calculateTotal(){let t=this._cachedMeta,n=t.data,r=0,i;for(i=0;i<n.length;i++){let o=t._parsed[i];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(r+=Math.abs(o))}return r}calculateCircumference(t){let n=this._cachedMeta.total;return n>0&&!isNaN(t)?Bn*(Math.abs(t)/n):0}getLabelAndValue(t){let n=this._cachedMeta,r=this.chart,i=r.data.labels||[],o=Dg(n._parsed[t],r.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let n=0,r=this.chart,i,o,s,a,l;if(!t){for(i=0,o=r.data.datasets.length;i<o;++i)if(r.isDatasetVisible(i)){s=r.getDatasetMeta(i),t=s.data,a=s.controller;break}}if(!t)return 0;for(i=0,o=t.length;i<o;++i)l=a.resolveDataElementOptions(i),l.borderAlign!=="inner"&&(n=Math.max(n,l.borderWidth||0,l.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let r=0,i=t.length;r<i;++r){let o=this.resolveDataElementOptions(r);n=Math.max(n,o.offset||0,o.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let r=0;r<t;++r)this.chart.isDatasetVisible(r)&&(n+=this._getRingWeight(r));return n}_getRingWeight(t){return Math.max(ht(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}},r2=class extends Ul{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){let n=this._cachedMeta,{dataset:r,data:i=[],_dataset:o}=n,s=this.chart._animationsDisabled,{start:a,count:l}=CD(n,i,s);this._drawStart=a,this._drawCount=l,ND(n)&&(a=0,l=i.length),r._chart=this.chart,r._datasetIndex=this.index,r._decimated=!!o._decimated,r.points=i;let u=this.resolveDatasetElementOptions(t);this.options.showLine||(u.borderWidth=0),u.segment=this.options.segment,this.updateElement(r,void 0,{animated:!s,options:u},t),this.updateElements(i,a,l,t)}updateElements(t,n,r,i){let o=i==="reset",{iScale:s,vScale:a,_stacked:l,_dataset:u}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(n,i),h=s.axis,f=a.axis,{spanGaps:p,segment:m}=this.options,g=tp(p)?p:Number.POSITIVE_INFINITY,y=this.chart._animationsDisabled||o||i==="none",v=n+r,b=t.length,w=n>0&&this.getParsed(n-1);for(let x=0;x<b;++x){let S=t[x],k=y?S:{};if(x<n||x>=v){k.skip=!0;continue}let C=this.getParsed(x),N=Rt(C[f]),E=k[h]=s.getPixelForValue(C[h],x),D=k[f]=o||N?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,C,l):C[f],x);k.skip=isNaN(E)||isNaN(D)||N,k.stop=x>0&&Math.abs(C[h]-w[h])>g,m&&(k.parsed=C,k.raw=u.data[x]),d&&(k.options=c||this.resolveDataElementOptions(x,S.active?"active":i)),y||this.updateElement(S,x,k,i),w=C}}getMaxOverflow(){let t=this._cachedMeta,n=t.dataset,r=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return r;let o=i[0].size(this.resolveDataElementOptions(0)),s=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(r,o,s)/2}draw(){let t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}},sC=class extends Ul{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){let n=t.data;if(n.labels.length&&n.datasets.length){let{labels:{pointStyle:r,color:i}}=t.legend.options;return n.labels.map((o,s)=>{let l=t.getDatasetMeta(0).controller.getStyle(s);return{text:o,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:i,lineWidth:l.borderWidth,pointStyle:r,hidden:!t.getDataVisibility(s),index:s}})}return[]}},onClick(t,n,r){r.chart.toggleDataVisibility(n.index),r.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){let n=this._cachedMeta,r=this.chart,i=r.data.labels||[],o=Dg(n._parsed[t].r,r.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,n,r,i){return ID.bind(this)(t,n,r,i)}update(t){let n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,t)}getMinMax(){let t=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((r,i)=>{let o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(o<n.min&&(n.min=o),o>n.max&&(n.max=o))}),n}_updateRadius(){let t=this.chart,n=t.chartArea,r=t.options,i=Math.min(n.right-n.left,n.bottom-n.top),o=Math.max(i/2,0),s=Math.max(r.cutoutPercentage?o/100*r.cutoutPercentage:1,0),a=(o-s)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,r,i){let o=i==="reset",s=this.chart,l=s.options.animation,u=this._cachedMeta.rScale,c=u.xCenter,d=u.yCenter,h=u.getIndexAngle(0)-.5*Gt,f=h,p,m=360/this.countVisibleElements();for(p=0;p<n;++p)f+=this._computeAngle(p,i,m);for(p=n;p<n+r;p++){let g=t[p],y=f,v=f+this._computeAngle(p,i,m),b=s.getDataVisibility(p)?u.getDistanceFromCenterForValue(this.getParsed(p).r):0;f=v,o&&(l.animateScale&&(b=0),l.animateRotate&&(y=v=h));let w={x:c,y:d,innerRadius:0,outerRadius:b,startAngle:y,endAngle:v,options:this.resolveDataElementOptions(p,g.active?"active":i)};this.updateElement(g,p,w,i)}}countVisibleElements(){let t=this._cachedMeta,n=0;return t.data.forEach((r,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&n++}),n}_computeAngle(t,n,r){return this.chart.getDataVisibility(t)?oa(this.resolveDataElementOptions(t,n).angle||r):0}},i2=class extends _b{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}},o2=class extends Ul{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){let n=this._cachedMeta.vScale,r=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(r[n.axis])}}parseObjectData(t,n,r,i){return ID.bind(this)(t,n,r,i)}update(t){let n=this._cachedMeta,r=n.dataset,i=n.data||[],o=n.iScale.getLabels();if(r.points=i,t!=="resize"){let s=this.resolveDatasetElementOptions(t);this.options.showLine||(s.borderWidth=0);let a={_loop:!0,_fullLoop:o.length===i.length,options:s};this.updateElement(r,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,n,r,i){let o=this._cachedMeta.rScale,s=i==="reset";for(let a=n;a<n+r;a++){let l=t[a],u=this.resolveDataElementOptions(a,l.active?"active":i),c=o.getPointPositionForValue(a,this.getParsed(a).r),d=s?o.xCenter:c.x,h=s?o.yCenter:c.y,f={x:d,y:h,angle:c.angle,skip:isNaN(d)||isNaN(h),options:u};this.updateElement(l,a,f,i)}}},s2=class extends Ul{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){let n=this._cachedMeta,r=this.chart.data.labels||[],{xScale:i,yScale:o}=n,s=this.getParsed(t),a=i.getLabelForValue(s.x),l=o.getLabelForValue(s.y);return{label:r[t]||"",value:"("+a+", "+l+")"}}update(t){let n=this._cachedMeta,{data:r=[]}=n,i=this.chart._animationsDisabled,{start:o,count:s}=CD(n,r,i);if(this._drawStart=o,this._drawCount=s,ND(n)&&(o=0,s=r.length),this.options.showLine){this.datasetElementType||this.addElements();let{dataset:a,_dataset:l}=n;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!l._decimated,a.points=r;let u=this.resolveDatasetElementOptions(t);u.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:u},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(r,o,s,t)}addElements(){let{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,r,i){let o=i==="reset",{iScale:s,vScale:a,_stacked:l,_dataset:u}=this._cachedMeta,c=this.resolveDataElementOptions(n,i),d=this.getSharedOptions(c),h=this.includeOptions(i,d),f=s.axis,p=a.axis,{spanGaps:m,segment:g}=this.options,y=tp(m)?m:Number.POSITIVE_INFINITY,v=this.chart._animationsDisabled||o||i==="none",b=n>0&&this.getParsed(n-1);for(let w=n;w<n+r;++w){let x=t[w],S=this.getParsed(w),k=v?x:{},C=Rt(S[p]),N=k[f]=s.getPixelForValue(S[f],w),E=k[p]=o||C?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,S,l):S[p],w);k.skip=isNaN(N)||isNaN(E)||C,k.stop=w>0&&Math.abs(S[f]-b[f])>y,g&&(k.parsed=S,k.raw=u.data[w]),h&&(k.options=d||this.resolveDataElementOptions(w,x.active?"active":i)),v||this.updateElement(x,w,k,i),b=S}this.updateSharedOptions(d,i,c)}getMaxOverflow(){let t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let a=0;for(let l=n.length-1;l>=0;--l)a=Math.max(a,n[l].size(this.resolveDataElementOptions(l))/2);return a>0&&a}let r=t.dataset,i=r.options&&r.options.borderWidth||0;if(!n.length)return i;let o=n[0].size(this.resolveDataElementOptions(0)),s=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,o,s)/2}},Vke=Object.freeze({__proto__:null,BarController:t2,BubbleController:n2,DoughnutController:_b,LineController:r2,PieController:i2,PolarAreaController:sC,RadarController:o2,ScatterController:s2});function rp(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}var a2=class e{static override(t){Object.assign(e.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return rp()}parse(){return rp()}format(){return rp()}add(){return rp()}diff(){return rp()}startOf(){return rp()}endOf(){return rp()}},Wke={_date:a2};function Uke(e,t,n,r){let{controller:i,data:o,_sorted:s}=e,a=i._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&s&&o.length){let u=a._reversePixels?HU:ql;if(r){if(i._sharedOptions){let c=o[0],d=typeof c.getRange=="function"&&c.getRange(t);if(d){let h=u(o,t,n-d),f=u(o,t,n+d);return{lo:h.lo,hi:f.hi}}}}else{let c=u(o,t,n);if(l){let{vScale:d}=i._cachedMeta,{_parsed:h}=e,f=h.slice(0,c.lo+1).reverse().findIndex(m=>!Rt(m[d.axis]));c.lo-=Math.max(0,f);let p=h.slice(c.hi).findIndex(m=>!Rt(m[d.axis]));c.hi+=Math.max(0,p)}return c}}return{lo:0,hi:o.length-1}}function Db(e,t,n,r,i){let o=e.getSortedVisibleDatasetMetas(),s=n[t];for(let a=0,l=o.length;a<l;++a){let{index:u,data:c}=o[a],{lo:d,hi:h}=Uke(o[a],t,s,i);for(let f=d;f<=h;++f){let p=c[f];p.skip||r(p,u,f)}}}function Hke(e){let t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(r,i){let o=t?Math.abs(r.x-i.x):0,s=n?Math.abs(r.y-i.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(s,2))}}function $D(e,t,n,r,i){let o=[];return!i&&!e.isPointInArea(t)||Db(e,n,t,function(a,l,u){!i&&!zl(a,e.chartArea,0)||a.inRange(t.x,t.y,r)&&o.push({element:a,datasetIndex:l,index:u})},!0),o}function $ke(e,t,n,r){let i=[];function o(s,a,l){let{startAngle:u,endAngle:c}=s.getProps(["startAngle","endAngle"],r),{angle:d}=bD(s,{x:t.x,y:t.y});Ag(d,u,c)&&i.push({element:s,datasetIndex:a,index:l})}return Db(e,n,t,o),i}function Kke(e,t,n,r,i,o){let s=[],a=Hke(n),l=Number.POSITIVE_INFINITY;function u(c,d,h){let f=c.inRange(t.x,t.y,i);if(r&&!f)return;let p=c.getCenterPoint(i);if(!(!!o||e.isPointInArea(p))&&!f)return;let g=a(t,p);g<l?(s=[{element:c,datasetIndex:d,index:h}],l=g):g===l&&s.push({element:c,datasetIndex:d,index:h})}return Db(e,n,t,u),s}function KD(e,t,n,r,i,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!r?$ke(e,t,n,i):Kke(e,t,n,r,i,o)}function S6(e,t,n,r,i){let o=[],s=n==="x"?"inXRange":"inYRange",a=!1;return Db(e,n,t,(l,u,c)=>{l[s]&&l[s](t[n],i)&&(o.push({element:l,datasetIndex:u,index:c}),a=a||l.inRange(t.x,t.y,i))}),r&&!a?[]:o}var Yke={evaluateInteractionItems:Db,modes:{index(e,t,n,r){let i=zd(t,e),o=n.axis||"x",s=n.includeInvisible||!1,a=n.intersect?$D(e,i,o,r,s):KD(e,i,o,!1,r,s),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(u=>{let c=a[0].index,d=u.data[c];d&&!d.skip&&l.push({element:d,datasetIndex:u.index,index:c})}),l):[]},dataset(e,t,n,r){let i=zd(t,e),o=n.axis||"xy",s=n.includeInvisible||!1,a=n.intersect?$D(e,i,o,r,s):KD(e,i,o,!1,r,s);if(a.length>0){let l=a[0].datasetIndex,u=e.getDatasetMeta(l).data;a=[];for(let c=0;c<u.length;++c)a.push({element:u[c],datasetIndex:l,index:c})}return a},point(e,t,n,r){let i=zd(t,e),o=n.axis||"xy",s=n.includeInvisible||!1;return $D(e,i,o,r,s)},nearest(e,t,n,r){let i=zd(t,e),o=n.axis||"xy",s=n.includeInvisible||!1;return KD(e,i,o,n.intersect,r,s)},x(e,t,n,r){let i=zd(t,e);return S6(e,i,"x",n.intersect,r)},y(e,t,n,r){let i=zd(t,e);return S6(e,i,"y",n.intersect,r)}}},pH=["left","top","right","bottom"];function xb(e,t){return e.filter(n=>n.pos===t)}function k6(e,t){return e.filter(n=>pH.indexOf(n.pos)===-1&&n.box.axis===t)}function Sb(e,t){return e.sort((n,r)=>{let i=t?r:n,o=t?n:r;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function Qke(e){let t=[],n,r,i,o,s,a;for(n=0,r=(e||[]).length;n<r;++n)i=e[n],{position:o,options:{stack:s,stackWeight:a=1}}=i,t.push({index:n,box:i,pos:o,horizontal:i.isHorizontal(),weight:i.weight,stack:s&&o+s,stackWeight:a});return t}function Gke(e){let t={};for(let n of e){let{stack:r,pos:i,stackWeight:o}=n;if(!r||!pH.includes(i))continue;let s=t[r]||(t[r]={count:0,placed:0,weight:0,size:0});s.count++,s.weight+=o}return t}function Xke(e,t){let n=Gke(e),{vBoxMaxWidth:r,hBoxMaxHeight:i}=t,o,s,a;for(o=0,s=e.length;o<s;++o){a=e[o];let{fullSize:l}=a.box,u=n[a.stack],c=u&&a.stackWeight/u.weight;a.horizontal?(a.width=c?c*r:l&&t.availableWidth,a.height=i):(a.width=r,a.height=c?c*i:l&&t.availableHeight)}return n}function Jke(e){let t=Qke(e),n=Sb(t.filter(u=>u.box.fullSize),!0),r=Sb(xb(t,"left"),!0),i=Sb(xb(t,"right")),o=Sb(xb(t,"top"),!0),s=Sb(xb(t,"bottom")),a=k6(t,"x"),l=k6(t,"y");return{fullSize:n,leftAndTop:r.concat(o),rightAndBottom:i.concat(l).concat(s).concat(a),chartArea:xb(t,"chartArea"),vertical:r.concat(i).concat(l),horizontal:o.concat(s).concat(a)}}function C6(e,t,n,r){return Math.max(e[n],t[n])+Math.max(e[r],t[r])}function mH(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Zke(e,t,n,r){let{pos:i,box:o}=n,s=e.maxPadding;if(!Bt(i)){n.size&&(e[i]-=n.size);let d=r[n.stack]||{size:0,count:1};d.size=Math.max(d.size,n.horizontal?o.height:o.width),n.size=d.size/d.count,e[i]+=n.size}o.getPadding&&mH(s,o.getPadding());let a=Math.max(0,t.outerWidth-C6(s,e,"left","right")),l=Math.max(0,t.outerHeight-C6(s,e,"top","bottom")),u=a!==e.w,c=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:u,other:c}:{same:c,other:u}}function eCe(e){let t=e.maxPadding;function n(r){let i=Math.max(t[r]-e[r],0);return e[r]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function tCe(e,t){let n=t.maxPadding;function r(i){let o={left:0,top:0,right:0,bottom:0};return i.forEach(s=>{o[s]=Math.max(t[s],n[s])}),o}return r(e?["left","right"]:["top","bottom"])}function Nb(e,t,n,r){let i=[],o,s,a,l,u,c;for(o=0,s=e.length,u=0;o<s;++o){a=e[o],l=a.box,l.update(a.width||t.w,a.height||t.h,tCe(a.horizontal,t));let{same:d,other:h}=Zke(t,n,a,r);u|=d&&i.length,c=c||h,l.fullSize||i.push(a)}return u&&Nb(i,t,n,r)||c}function Xk(e,t,n,r,i){e.top=n,e.left=t,e.right=t+r,e.bottom=n+i,e.width=r,e.height=i}function N6(e,t,n,r){let i=n.padding,{x:o,y:s}=t;for(let a of e){let l=a.box,u=r[a.stack]||{count:1,placed:0,weight:1},c=a.stackWeight/u.weight||1;if(a.horizontal){let d=t.w*c,h=u.size||l.height;Og(u.start)&&(s=u.start),l.fullSize?Xk(l,i.left,s,n.outerWidth-i.right-i.left,h):Xk(l,t.left+u.placed,s,d,h),u.start=s,u.placed+=d,s=l.bottom}else{let d=t.h*c,h=u.size||l.width;Og(u.start)&&(o=u.start),l.fullSize?Xk(l,o,i.top,h,n.outerHeight-i.bottom-i.top):Xk(l,o,t.top+u.placed,h,d),u.start=o,u.placed+=d,o=l.right}}t.x=o,t.y=s}var Xi={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){let n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,r){if(!e)return;let i=qi(e.options.layout.padding),o=Math.max(t-i.width,0),s=Math.max(n-i.height,0),a=Jke(e.boxes),l=a.vertical,u=a.horizontal;cn(e.boxes,m=>{typeof m.beforeLayout=="function"&&m.beforeLayout()});let c=l.reduce((m,g)=>g.box.options&&g.box.options.display===!1?m:m+1,0)||1,d=Object.freeze({outerWidth:t,outerHeight:n,padding:i,availableWidth:o,availableHeight:s,vBoxMaxWidth:o/2/c,hBoxMaxHeight:s/2}),h=Object.assign({},i);mH(h,qi(r));let f=Object.assign({maxPadding:h,w:o,h:s,x:i.left,y:i.top},i),p=Xke(l.concat(u),d);Nb(a.fullSize,f,d,p),Nb(l,f,d,p),Nb(u,f,d,p)&&Nb(l,f,d,p),eCe(f),N6(a.leftAndTop,f,d,p),f.x+=f.w,f.y+=f.h,N6(a.rightAndBottom,f,d,p),e.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},cn(a.chartArea,m=>{let g=m.box;Object.assign(g,e.chartArea),g.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}},aC=class{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,r){}removeEventListener(t,n,r){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,r,i){return n=Math.max(0,n||t.width),r=r||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):r)}}isAttached(t){return!0}updateConfig(t){}},l2=class extends aC{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}},rC="$chartjs",nCe={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},M6=e=>e===null||e==="";function rCe(e,t){let n=e.style,r=e.getAttribute("height"),i=e.getAttribute("width");if(e[rC]={initial:{height:r,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",M6(i)){let o=LD(e,"width");o!==void 0&&(e.width=o)}if(M6(r))if(e.style.height==="")e.height=e.width/(t||2);else{let o=LD(e,"height");o!==void 0&&(e.height=o)}return e}var gH=l6?{passive:!0}:!1;function iCe(e,t,n){e&&e.addEventListener(t,n,gH)}function oCe(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,gH)}function sCe(e,t){let n=nCe[e.type]||e.type,{x:r,y:i}=zd(e,t);return{type:n,chart:t,native:e,x:r!==void 0?r:null,y:i!==void 0?i:null}}function lC(e,t){for(let n of e)if(n===t||n.contains(t))return!0}function aCe(e,t,n){let r=e.canvas,i=new MutationObserver(o=>{let s=!1;for(let a of o)s=s||lC(a.addedNodes,r),s=s&&!lC(a.removedNodes,r);s&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function lCe(e,t,n){let r=e.canvas,i=new MutationObserver(o=>{let s=!1;for(let a of o)s=s||lC(a.removedNodes,r),s=s&&!lC(a.addedNodes,r);s&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}var Eb=new Map,_6=0;function yH(){let e=window.devicePixelRatio;e!==_6&&(_6=e,Eb.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function uCe(e,t){Eb.size||window.addEventListener("resize",yH),Eb.set(e,t)}function cCe(e){Eb.delete(e),Eb.size||window.removeEventListener("resize",yH)}function dCe(e,t,n){let r=e.canvas,i=r&&Qk(r);if(!i)return;let o=kD((a,l)=>{let u=i.clientWidth;n(a,l),u<i.clientWidth&&n()},window),s=new ResizeObserver(a=>{let l=a[0],u=l.contentRect.width,c=l.contentRect.height;u===0&&c===0||o(u,c)});return s.observe(i),uCe(e,o),s}function YD(e,t,n){n&&n.disconnect(),t==="resize"&&cCe(e)}function hCe(e,t,n){let r=e.canvas,i=kD(o=>{e.ctx!==null&&n(sCe(o,e))},e);return iCe(r,t,i),i}var u2=class extends aC{acquireContext(t,n){let r=t&&t.getContext&&t.getContext("2d");return r&&r.canvas===t?(rCe(t,n),r):null}releaseContext(t){let n=t.canvas;if(!n[rC])return!1;let r=n[rC].initial;["height","width"].forEach(o=>{let s=r[o];Rt(s)?n.removeAttribute(o):n.setAttribute(o,s)});let i=r.style||{};return Object.keys(i).forEach(o=>{n.style[o]=i[o]}),n.width=n.width,delete n[rC],!0}addEventListener(t,n,r){this.removeEventListener(t,n);let i=t.$proxies||(t.$proxies={}),s={attach:aCe,detach:lCe,resize:dCe}[n]||hCe;i[n]=s(t,n,r)}removeEventListener(t,n){let r=t.$proxies||(t.$proxies={}),i=r[n];if(!i)return;({attach:YD,detach:YD,resize:YD}[n]||oCe)(t,n,i),r[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,r,i){return a6(t,n,r,i)}isAttached(t){let n=t&&Qk(t);return!!(n&&n.isConnected)}};function fCe(e){return!Yk()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?l2:u2}var Qa=class{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){let{x:n,y:r}=this.getProps(["x","y"],t);return{x:n,y:r}}hasValue(){return tp(this.x)&&tp(this.y)}getProps(t,n){let r=this.$animations;if(!n||!r)return this;let i={};return t.forEach(o=>{i[o]=r[o]&&r[o].active()?r[o]._to:this[o]}),i}};function pCe(e,t){let n=e.options.ticks,r=mCe(e),i=Math.min(n.maxTicksLimit||r,r),o=n.major.enabled?yCe(t):[],s=o.length,a=o[0],l=o[s-1],u=[];if(s>i)return vCe(t,u,o,s/i),u;let c=gCe(o,t,i);if(s>0){let d,h,f=s>1?Math.round((l-a)/(s-1)):null;for(Jk(t,u,c,Rt(f)?0:a-f,a),d=0,h=s-1;d<h;d++)Jk(t,u,c,o[d],o[d+1]);return Jk(t,u,c,l,Rt(f)?t.length:l+f),u}return Jk(t,u,c),u}function mCe(e){let t=e.options.offset,n=e._tickSize(),r=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(r,i))}function gCe(e,t,n){let r=bCe(e),i=t.length/n;if(!r)return Math.max(i,1);let o=VU(r);for(let s=0,a=o.length-1;s<a;s++){let l=o[s];if(l>i)return l}return Math.max(i,1)}function yCe(e){let t=[],n,r;for(n=0,r=e.length;n<r;n++)e[n].major&&t.push(n);return t}function vCe(e,t,n,r){let i=0,o=n[0],s;for(r=Math.ceil(r),s=0;s<e.length;s++)s===o&&(t.push(e[s]),i++,o=n[i*r])}function Jk(e,t,n,r,i){let o=ht(r,0),s=Math.min(ht(i,e.length),e.length),a=0,l,u,c;for(n=Math.ceil(n),i&&(l=i-r,n=l/Math.floor(l/n)),c=o;c<0;)a++,c=Math.round(o+a*n);for(u=Math.max(o,0);u<s;u++)u===c&&(t.push(e[u]),a++,c=Math.round(o+a*n))}function bCe(e){let t=e.length,n,r;if(t<2)return!1;for(r=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==r)return!1;return r}var wCe=e=>e==="left"?"right":e==="right"?"left":e,E6=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,O6=(e,t)=>Math.min(t||e,e);function T6(e,t){let n=[],r=e.length/t,i=e.length,o=0;for(;o<i;o+=r)n.push(e[Math.floor(o)]);return n}function xCe(e,t,n){let r=e.ticks.length,i=Math.min(t,r-1),o=e._startPixel,s=e._endPixel,a=1e-6,l=e.getPixelForTick(i),u;if(!(n&&(r===1?u=Math.max(l-o,s-l):t===0?u=(e.getPixelForTick(1)-l)/2:u=(l-e.getPixelForTick(i-1))/2,l+=i<t?u:-u,l<o-a||l>s+a)))return l}function SCe(e,t){cn(e,n=>{let r=n.gc,i=r.length/2,o;if(i>t){for(o=0;o<i;++o)delete n.data[r[o]];r.splice(0,i)}})}function kb(e){return e.drawTicks?e.tickLength:0}function A6(e,t){if(!e.display)return 0;let n=Vr(e.font,t),r=qi(e.padding);return(Ln(e.text)?e.text.length:1)*n.lineHeight+r.height}function kCe(e,t){return ac(e,{scale:t,type:"scale"})}function CCe(e,t,n){return ac(e,{tick:n,index:t,type:"tick"})}function NCe(e,t,n){let r=Wk(e);return(n&&t!=="right"||!n&&t==="right")&&(r=wCe(r)),r}function MCe(e,t,n,r){let{top:i,left:o,bottom:s,right:a,chart:l}=e,{chartArea:u,scales:c}=l,d=0,h,f,p,m=s-i,g=a-o;if(e.isHorizontal()){if(f=Bi(r,o,a),Bt(n)){let y=Object.keys(n)[0],v=n[y];p=c[y].getPixelForValue(v)+m-t}else n==="center"?p=(u.bottom+u.top)/2+m-t:p=E6(e,n,t);h=a-o}else{if(Bt(n)){let y=Object.keys(n)[0],v=n[y];f=c[y].getPixelForValue(v)-g+t}else n==="center"?f=(u.left+u.right)/2-g+t:f=E6(e,n,t);p=Bi(r,s,i),d=n==="left"?-Sr:Sr}return{titleX:f,titleY:p,maxWidth:h,rotation:d}}var op=class e extends Qa{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:r,_suggestedMax:i}=this;return t=jo(t,Number.POSITIVE_INFINITY),n=jo(n,Number.NEGATIVE_INFINITY),r=jo(r,Number.POSITIVE_INFINITY),i=jo(i,Number.NEGATIVE_INFINITY),{min:jo(t,r),max:jo(n,i),minDefined:fr(t),maxDefined:fr(n)}}getMinMax(t){let{min:n,max:r,minDefined:i,maxDefined:o}=this.getUserBounds(),s;if(i&&o)return{min:n,max:r};let a=this.getMatchingVisibleMetas();for(let l=0,u=a.length;l<u;++l)s=a[l].controller.getMinMax(this,t),i||(n=Math.min(n,s.min)),o||(r=Math.max(r,s.max));return n=o&&n>r?r:n,r=i&&n>r?n:r,{min:jo(n,jo(r,n)),max:jo(r,jo(n,r))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){let t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Mn(this.options.beforeUpdate,[this])}update(t,n,r){let{beginAtZero:i,grace:o,ticks:s}=this.options,a=s.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=r=Object.assign({left:0,right:0,top:0,bottom:0},r),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+r.left+r.right:this.height+r.top+r.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=t6(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();let l=a<this.ticks.length;this._convertTicksToLabels(l?T6(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),s.display&&(s.autoSkip||s.source==="auto")&&(this.ticks=pCe(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,r;this.isHorizontal()?(n=this.left,r=this.right):(n=this.top,r=this.bottom,t=!t),this._startPixel=n,this._endPixel=r,this._reversePixels=t,this._length=r-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){Mn(this.options.afterUpdate,[this])}beforeSetDimensions(){Mn(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){Mn(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),Mn(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){Mn(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){let n=this.options.ticks,r,i,o;for(r=0,i=t.length;r<i;r++)o=t[r],o.label=Mn(n.callback,[o.value,r,t],this)}afterTickToLabelConversion(){Mn(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){Mn(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){let t=this.options,n=t.ticks,r=O6(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,o=n.maxRotation,s=i,a,l,u;if(!this._isVisible()||!n.display||i>=o||r<=1||!this.isHorizontal()){this.labelRotation=i;return}let c=this._getLabelSizes(),d=c.widest.width,h=c.highest.height,f=si(this.chart.width-d,0,this.maxWidth);a=t.offset?this.maxWidth/r:f/(r-1),d+6>a&&(a=f/(r-(t.offset?.5:1)),l=this.maxHeight-kb(t.grid)-n.padding-A6(t.title,this.chart.options.font),u=Math.sqrt(d*d+h*h),s=jk(Math.min(Math.asin(si((c.highest.height+6)/a,-1,1)),Math.asin(si(l/u,-1,1))-Math.asin(si(h/u,-1,1)))),s=Math.max(i,Math.min(o,s))),this.labelRotation=s}afterCalculateLabelRotation(){Mn(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Mn(this.options.beforeFit,[this])}fit(){let t={width:0,height:0},{chart:n,options:{ticks:r,title:i,grid:o}}=this,s=this._isVisible(),a=this.isHorizontal();if(s){let l=A6(i,n.options.font);if(a?(t.width=this.maxWidth,t.height=kb(o)+l):(t.height=this.maxHeight,t.width=kb(o)+l),r.display&&this.ticks.length){let{first:u,last:c,widest:d,highest:h}=this._getLabelSizes(),f=r.padding*2,p=oa(this.labelRotation),m=Math.cos(p),g=Math.sin(p);if(a){let y=r.mirror?0:g*d.width+m*h.height;t.height=Math.min(this.maxHeight,t.height+y+f)}else{let y=r.mirror?0:m*d.width+g*h.height;t.width=Math.min(this.maxWidth,t.width+y+f)}this._calculatePadding(u,c,g,m)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,r,i){let{ticks:{align:o,padding:s},position:a}=this.options,l=this.labelRotation!==0,u=a!=="top"&&this.axis==="x";if(this.isHorizontal()){let c=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1),h=0,f=0;l?u?(h=i*t.width,f=r*n.height):(h=r*t.height,f=i*n.width):o==="start"?f=n.width:o==="end"?h=t.width:o!=="inner"&&(h=t.width/2,f=n.width/2),this.paddingLeft=Math.max((h-c+s)*this.width/(this.width-c),0),this.paddingRight=Math.max((f-d+s)*this.width/(this.width-d),0)}else{let c=n.height/2,d=t.height/2;o==="start"?(c=0,d=t.height):o==="end"&&(c=n.height,d=0),this.paddingTop=c+s,this.paddingBottom=d+s}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Mn(this.options.afterFit,[this])}isHorizontal(){let{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,r;for(n=0,r=t.length;n<r;n++)Rt(t[n].label)&&(t.splice(n,1),r--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){let n=this.options.ticks.sampleSize,r=this.ticks;n<r.length&&(r=T6(r,n)),this._labelSizes=t=this._computeLabelSizes(r,r.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,r){let{ctx:i,_longestTextCache:o}=this,s=[],a=[],l=Math.floor(n/O6(n,r)),u=0,c=0,d,h,f,p,m,g,y,v,b,w,x;for(d=0;d<n;d+=l){if(p=t[d].label,m=this._resolveTickFontOptions(d),i.font=g=m.string,y=o[g]=o[g]||{data:{},gc:[]},v=m.lineHeight,b=w=0,!Rt(p)&&!Ln(p))b=mb(i,y.data,y.gc,b,p),w=v;else if(Ln(p))for(h=0,f=p.length;h<f;++h)x=p[h],!Rt(x)&&!Ln(x)&&(b=mb(i,y.data,y.gc,b,x),w+=v);s.push(b),a.push(w),u=Math.max(b,u),c=Math.max(w,c)}SCe(o,n);let S=s.indexOf(u),k=a.indexOf(c),C=N=>({width:s[N]||0,height:a[N]||0});return{first:C(0),last:C(n-1),widest:C(S),highest:C(k),widths:s,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){let n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);let n=this._startPixel+t*this._length;return UU(this._alignToPixels?Ld(this.chart,n,0):n)}getDecimalForPixel(t){let n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){let{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){let n=this.ticks||[];if(t>=0&&t<n.length){let r=n[t];return r.$context||(r.$context=CCe(this.getContext(),t,r))}return this.$context||(this.$context=kCe(this.chart.getContext(),this))}_tickSize(){let t=this.options.ticks,n=oa(this.labelRotation),r=Math.abs(Math.cos(n)),i=Math.abs(Math.sin(n)),o=this._getLabelSizes(),s=t.autoSkipPadding||0,a=o?o.widest.width+s:0,l=o?o.highest.height+s:0;return this.isHorizontal()?l*r>a*i?a/r:l/i:l*i<a*r?l/r:a/i}_isVisible(){let t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){let n=this.axis,r=this.chart,i=this.options,{grid:o,position:s,border:a}=i,l=o.offset,u=this.isHorizontal(),d=this.ticks.length+(l?1:0),h=kb(o),f=[],p=a.setContext(this.getContext()),m=p.display?p.width:0,g=m/2,y=function(T){return Ld(r,T,m)},v,b,w,x,S,k,C,N,E,D,q,z;if(s==="top")v=y(this.bottom),k=this.bottom-h,N=v-g,D=y(t.top)+g,z=t.bottom;else if(s==="bottom")v=y(this.top),D=t.top,z=y(t.bottom)-g,k=v+g,N=this.top+h;else if(s==="left")v=y(this.right),S=this.right-h,C=v-g,E=y(t.left)+g,q=t.right;else if(s==="right")v=y(this.left),E=t.left,q=y(t.right)-g,S=v+g,C=this.left+h;else if(n==="x"){if(s==="center")v=y((t.top+t.bottom)/2+.5);else if(Bt(s)){let T=Object.keys(s)[0],B=s[T];v=y(this.chart.scales[T].getPixelForValue(B))}D=t.top,z=t.bottom,k=v+g,N=k+h}else if(n==="y"){if(s==="center")v=y((t.left+t.right)/2);else if(Bt(s)){let T=Object.keys(s)[0],B=s[T];v=y(this.chart.scales[T].getPixelForValue(B))}S=v-g,C=S-h,E=t.left,q=t.right}let _=ht(i.ticks.maxTicksLimit,d),R=Math.max(1,Math.ceil(d/_));for(b=0;b<d;b+=R){let T=this.getContext(b),B=o.setContext(T),A=a.setContext(T),M=B.lineWidth,P=B.color,F=A.dash||[],I=A.dashOffset,V=B.tickWidth,W=B.tickColor,j=B.tickBorderDash||[],X=B.tickBorderDashOffset;w=xCe(this,b,l),w!==void 0&&(x=Ld(r,w,M),u?S=C=E=q=x:k=N=D=z=x,f.push({tx1:S,ty1:k,tx2:C,ty2:N,x1:E,y1:D,x2:q,y2:z,width:M,color:P,borderDash:F,borderDashOffset:I,tickWidth:V,tickColor:W,tickBorderDash:j,tickBorderDashOffset:X}))}return this._ticksLength=d,this._borderValue=v,f}_computeLabelItems(t){let n=this.axis,r=this.options,{position:i,ticks:o}=r,s=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:u,padding:c,mirror:d}=o,h=kb(r.grid),f=h+c,p=d?-c:f,m=-oa(this.labelRotation),g=[],y,v,b,w,x,S,k,C,N,E,D,q,z="middle";if(i==="top")S=this.bottom-p,k=this._getXAxisLabelAlignment();else if(i==="bottom")S=this.top+p,k=this._getXAxisLabelAlignment();else if(i==="left"){let R=this._getYAxisLabelAlignment(h);k=R.textAlign,x=R.x}else if(i==="right"){let R=this._getYAxisLabelAlignment(h);k=R.textAlign,x=R.x}else if(n==="x"){if(i==="center")S=(t.top+t.bottom)/2+f;else if(Bt(i)){let R=Object.keys(i)[0],T=i[R];S=this.chart.scales[R].getPixelForValue(T)+f}k=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")x=(t.left+t.right)/2-f;else if(Bt(i)){let R=Object.keys(i)[0],T=i[R];x=this.chart.scales[R].getPixelForValue(T)}k=this._getYAxisLabelAlignment(h).textAlign}n==="y"&&(l==="start"?z="top":l==="end"&&(z="bottom"));let _=this._getLabelSizes();for(y=0,v=a.length;y<v;++y){b=a[y],w=b.label;let R=o.setContext(this.getContext(y));C=this.getPixelForTick(y)+o.labelOffset,N=this._resolveTickFontOptions(y),E=N.lineHeight,D=Ln(w)?w.length:1;let T=D/2,B=R.color,A=R.textStrokeColor,M=R.textStrokeWidth,P=k;s?(x=C,k==="inner"&&(y===v-1?P=this.options.reverse?"left":"right":y===0?P=this.options.reverse?"right":"left":P="center"),i==="top"?u==="near"||m!==0?q=-D*E+E/2:u==="center"?q=-_.highest.height/2-T*E+E:q=-_.highest.height+E/2:u==="near"||m!==0?q=E/2:u==="center"?q=_.highest.height/2-T*E:q=_.highest.height-D*E,d&&(q*=-1),m!==0&&!R.showLabelBackdrop&&(x+=E/2*Math.sin(m))):(S=C,q=(1-D)*E/2);let F;if(R.showLabelBackdrop){let I=qi(R.backdropPadding),V=_.heights[y],W=_.widths[y],j=q-I.top,X=0-I.left;switch(z){case"middle":j-=V/2;break;case"bottom":j-=V;break}switch(k){case"center":X-=W/2;break;case"right":X-=W;break;case"inner":y===v-1?X-=W:y>0&&(X-=W/2);break}F={left:X,top:j,width:W+I.width,height:V+I.height,color:R.backdropColor}}g.push({label:w,font:N,textOffset:q,options:{rotation:m,color:B,strokeColor:A,strokeWidth:M,textAlign:P,textBaseline:z,translation:[x,S],backdrop:F}})}return g}_getXAxisLabelAlignment(){let{position:t,ticks:n}=this.options;if(-oa(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){let{position:n,ticks:{crossAlign:r,mirror:i,padding:o}}=this.options,s=this._getLabelSizes(),a=t+o,l=s.widest.width,u,c;return n==="left"?i?(c=this.right+o,r==="near"?u="left":r==="center"?(u="center",c+=l/2):(u="right",c+=l)):(c=this.right-a,r==="near"?u="right":r==="center"?(u="center",c-=l/2):(u="left",c=this.left)):n==="right"?i?(c=this.left+o,r==="near"?u="right":r==="center"?(u="center",c-=l/2):(u="left",c-=l)):(c=this.left+a,r==="near"?u="left":r==="center"?(u="center",c+=l/2):(u="right",c=this.right)):u="right",{textAlign:u,x:c}}_computeLabelArea(){if(this.options.ticks.mirror)return;let t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){let{ctx:t,options:{backgroundColor:n},left:r,top:i,width:o,height:s}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(r,i,o,s),t.restore())}getLineWidthForValue(t){let n=this.options.grid;if(!this._isVisible()||!n.display)return 0;let i=this.ticks.findIndex(o=>o.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){let n=this.options.grid,r=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t)),o,s,a=(l,u,c)=>{!c.width||!c.color||(r.save(),r.lineWidth=c.width,r.strokeStyle=c.color,r.setLineDash(c.borderDash||[]),r.lineDashOffset=c.borderDashOffset,r.beginPath(),r.moveTo(l.x,l.y),r.lineTo(u.x,u.y),r.stroke(),r.restore())};if(n.display)for(o=0,s=i.length;o<s;++o){let l=i[o];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){let{chart:t,ctx:n,options:{border:r,grid:i}}=this,o=r.setContext(this.getContext()),s=r.display?o.width:0;if(!s)return;let a=i.setContext(this.getContext(0)).lineWidth,l=this._borderValue,u,c,d,h;this.isHorizontal()?(u=Ld(t,this.left,s)-s/2,c=Ld(t,this.right,a)+a/2,d=h=l):(d=Ld(t,this.top,s)-s/2,h=Ld(t,this.bottom,a)+a/2,u=c=l),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(u,d),n.lineTo(c,h),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;let r=this.ctx,i=this._computeLabelArea();i&&vb(r,i);let o=this.getLabelItems(t);for(let s of o){let a=s.options,l=s.font,u=s.label,c=s.textOffset;Bd(r,u,0,c,l,a)}i&&bb(r)}drawTitle(){let{ctx:t,options:{position:n,title:r,reverse:i}}=this;if(!r.display)return;let o=Vr(r.font),s=qi(r.padding),a=r.align,l=o.lineHeight/2;n==="bottom"||n==="center"||Bt(n)?(l+=s.bottom,Ln(r.text)&&(l+=o.lineHeight*(r.text.length-1))):l+=s.top;let{titleX:u,titleY:c,maxWidth:d,rotation:h}=MCe(this,l,n,a);Bd(t,r.text,0,0,o,{color:r.color,maxWidth:d,rotation:h,textAlign:NCe(a,n,i),textBaseline:"middle",translation:[u,c]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){let t=this.options,n=t.ticks&&t.ticks.z||0,r=ht(t.grid&&t.grid.z,-1),i=ht(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==e.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:r,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){let n=this.chart.getSortedVisibleDatasetMetas(),r=this.axis+"AxisID",i=[],o,s;for(o=0,s=n.length;o<s;++o){let a=n[o];a[r]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){let n=this.options.ticks.setContext(this.getContext(t));return Vr(n.font)}_maxDigits(){let t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}},Lg=class{constructor(t,n,r){this.type=t,this.scope=n,this.override=r,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){let n=Object.getPrototypeOf(t),r;OCe(n)&&(r=this.register(n));let i=this.items,o=t.id,s=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in i||(i[o]=t,_Ce(t,s,r),this.override&&Kn.override(t.id,t.overrides)),s}get(t){return this.items[t]}unregister(t){let n=this.items,r=t.id,i=this.scope;r in n&&delete n[r],i&&r in Kn[i]&&(delete Kn[i][r],this.override&&delete Pd[r])}};function _Ce(e,t,n){let r=Mg(Object.create(null),[n?Kn.get(n):{},Kn.get(t),e.defaults]);Kn.set(t,r),e.defaultRoutes&&ECe(t,e.defaultRoutes),e.descriptors&&Kn.describe(t,e.descriptors)}function ECe(e,t){Object.keys(t).forEach(n=>{let r=n.split("."),i=r.pop(),o=[e].concat(r).join("."),s=t[n].split("."),a=s.pop(),l=s.join(".");Kn.route(o,i,l,a)})}function OCe(e){return"id"in e&&"defaults"in e}var c2=class{constructor(){this.controllers=new Lg(Ul,"datasets",!0),this.elements=new Lg(Qa,"elements"),this.plugins=new Lg(Object,"plugins"),this.scales=new Lg(op,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,r){[...n].forEach(i=>{let o=r||this._getRegistryForType(i);r||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):cn(i,s=>{let a=r||this._getRegistryForType(s);this._exec(t,a,s)})})}_exec(t,n,r){let i=Fk(t);Mn(r["before"+i],[],r),n[t](r),Mn(r["after"+i],[],r)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){let r=this._typedRegistries[n];if(r.isForType(t))return r}return this.plugins}_get(t,n,r){let i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+r+".");return i}},Wl=new c2,d2=class{constructor(){this._init=void 0}notify(t,n,r,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;let o=i?this._descriptors(t).filter(i):this._descriptors(t),s=this._notify(o,t,n,r);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),s}_notify(t,n,r,i){i=i||{};for(let o of t){let s=o.plugin,a=s[r],l=[n,i,o.options];if(Mn(a,l,s)===!1&&i.cancelable)return!1}return!0}invalidate(){Rt(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;let n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){let r=t&&t.config,i=ht(r.options&&r.options.plugins,{}),o=TCe(r);return i===!1&&!n?[]:DCe(t,o,i,n)}_notifyStateChanges(t){let n=this._oldCache||[],r=this._cache,i=(o,s)=>o.filter(a=>!s.some(l=>a.plugin.id===l.plugin.id));this._notify(i(n,r),t,"stop"),this._notify(i(r,n),t,"start")}};function TCe(e){let t={},n=[],r=Object.keys(Wl.plugins.items);for(let o=0;o<r.length;o++)n.push(Wl.getPlugin(r[o]));let i=e.plugins||[];for(let o=0;o<i.length;o++){let s=i[o];n.indexOf(s)===-1&&(n.push(s),t[s.id]=!0)}return{plugins:n,localIds:t}}function ACe(e,t){return!t&&e===!1?null:e===!0?{}:e}function DCe(e,{plugins:t,localIds:n},r,i){let o=[],s=e.getContext();for(let a of t){let l=a.id,u=ACe(r[l],i);u!==null&&o.push({plugin:a,options:RCe(e.config,{plugin:a,local:n[l]},u,s)})}return o}function RCe(e,{plugin:t,local:n},r,i){let o=e.pluginScopeKeys(t),s=e.getOptionScopes(r,o);return n&&t.defaults&&s.push(t.defaults),e.createResolver(s,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function h2(e,t){let n=Kn.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function ICe(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function PCe(e,t){return e===t?"_index_":"_value_"}function D6(e){if(e==="x"||e==="y"||e==="r")return e}function LCe(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function f2(e,...t){if(D6(e))return e;for(let n of t){let r=n.axis||LCe(n.position)||e.length>1&&D6(e[0].toLowerCase());if(r)return r}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function R6(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function BCe(e,t){if(t.data&&t.data.datasets){let n=t.data.datasets.filter(r=>r.xAxisID===e||r.yAxisID===e);if(n.length)return R6(e,"x",n[0])||R6(e,"y",n[0])}return{}}function qCe(e,t){let n=Pd[e.type]||{scales:{}},r=t.scales||{},i=h2(e.type,t),o=Object.create(null);return Object.keys(r).forEach(s=>{let a=r[s];if(!Bt(a))return console.error(`Invalid scale configuration for scale: ${s}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${s}`);let l=f2(s,a,BCe(s,e),Kn.scales[a.type]),u=PCe(l,i),c=n.scales||{};o[s]=Eg(Object.create(null),[{axis:l},a,c[l],c[u]])}),e.data.datasets.forEach(s=>{let a=s.type||e.type,l=s.indexAxis||h2(a,t),c=(Pd[a]||{}).scales||{};Object.keys(c).forEach(d=>{let h=ICe(d,l),f=s[h+"AxisID"]||h;o[f]=o[f]||Object.create(null),Eg(o[f],[{axis:h},r[f],c[d]])})}),Object.keys(o).forEach(s=>{let a=o[s];Eg(a,[Kn.scales[a.type],Kn.scale])}),o}function vH(e){let t=e.options||(e.options={});t.plugins=ht(t.plugins,{}),t.scales=qCe(e,t)}function bH(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function zCe(e){return e=e||{},e.data=bH(e.data),vH(e),e}var I6=new Map,wH=new Set;function Zk(e,t){let n=I6.get(e);return n||(n=t(),I6.set(e,n),wH.add(n)),n}var Cb=(e,t,n)=>{let r=sc(t,n);r!==void 0&&e.add(r)},p2=class{constructor(t){this._config=zCe(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=bH(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){let t=this._config;this.clearCache(),vH(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Zk(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return Zk(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return Zk(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){let n=t.id,r=this.type;return Zk(`${r}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){let r=this._scopeCache,i=r.get(t);return(!i||n)&&(i=new Map,r.set(t,i)),i}getOptionScopes(t,n,r){let{options:i,type:o}=this,s=this._cachedScopes(t,r),a=s.get(n);if(a)return a;let l=new Set;n.forEach(c=>{t&&(l.add(t),c.forEach(d=>Cb(l,t,d))),c.forEach(d=>Cb(l,i,d)),c.forEach(d=>Cb(l,Pd[o]||{},d)),c.forEach(d=>Cb(l,Kn,d)),c.forEach(d=>Cb(l,Uk,d))});let u=Array.from(l);return u.length===0&&u.push(Object.create(null)),wH.has(n)&&s.set(n,u),u}chartOptionScopes(){let{options:t,type:n}=this;return[t,Pd[n]||{},Kn.datasets[n]||{},{type:n},Kn,Uk]}resolveNamedOptions(t,n,r,i=[""]){let o={$shared:!0},{resolver:s,subPrefixes:a}=P6(this._resolverCache,t,i),l=s;if(jCe(s,n)){o.$shared=!1,r=ic(r)?r():r;let u=this.createResolver(t,r,a);l=ep(s,r,u)}for(let u of n)o[u]=l[u];return o}createResolver(t,n,r=[""],i){let{resolver:o}=P6(this._resolverCache,t,r);return Bt(n)?ep(o,n,void 0,i):o}};function P6(e,t,n){let r=e.get(t);r||(r=new Map,e.set(t,r));let i=n.join(),o=r.get(i);return o||(o={resolver:Kk(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},r.set(i,o)),o}var FCe=e=>Bt(e)&&Object.getOwnPropertyNames(e).some(t=>ic(e[t]));function jCe(e,t){let{isScriptable:n,isIndexable:r}=AD(e);for(let i of t){let o=n(i),s=r(i),a=(s||o)&&e[i];if(o&&(ic(a)||FCe(a))||s&&Ln(a))return!0}return!1}var VCe="4.5.1",WCe=["top","bottom","left","right","chartArea"];function L6(e,t){return e==="top"||e==="bottom"||WCe.indexOf(e)===-1&&t==="x"}function B6(e,t){return function(n,r){return n[e]===r[e]?n[t]-r[t]:n[e]-r[e]}}function q6(e){let t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),Mn(n&&n.onComplete,[e],t)}function UCe(e){let t=e.chart,n=t.options.animation;Mn(n&&n.onProgress,[e],t)}function xH(e){return Yk()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}var iC={},z6=e=>{let t=xH(e);return Object.values(iC).filter(n=>n.canvas===t).pop()};function HCe(e,t,n){let r=Object.keys(e);for(let i of r){let o=+i;if(o>=t){let s=e[i];delete e[i],(n>0||o>t)&&(e[o+n]=s)}}}function $Ce(e,t,n,r){return!n||e.type==="mouseout"?null:r?t:e}var jd=class{static defaults=Kn;static instances=iC;static overrides=Pd;static registry=Wl;static version=VCe;static getChart=z6;static register(...t){Wl.add(...t),F6()}static unregister(...t){Wl.remove(...t),F6()}constructor(t,n){let r=this.config=new p2(n),i=xH(t),o=z6(i);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");let s=r.createResolver(r.chartOptionScopes(),this.getContext());this.platform=new(r.platform||fCe(i)),this.platform.updateConfig(r);let a=this.platform.acquireContext(i,s.aspectRatio),l=a&&a.canvas,u=l&&l.height,c=l&&l.width;if(this.id=qU(),this.ctx=a,this.canvas=l,this.width=c,this.height=u,this._options=s,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new d2,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=QU(d=>this.update(d),s.resizeDelay||0),this._dataChanges=[],iC[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}lc.listen(this,"complete",q6),lc.listen(this,"progress",UCe),this._initialize(),this.attached&&this.update()}get aspectRatio(){let{options:{aspectRatio:t,maintainAspectRatio:n},width:r,height:i,_aspectRatio:o}=this;return Rt(t)?n&&o?o:i?r/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return Wl}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():PD(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return ED(this.canvas,this.ctx),this}stop(){return lc.stop(this),this}resize(t,n){lc.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){let r=this.options,i=this.canvas,o=r.maintainAspectRatio&&this.aspectRatio,s=this.platform.getMaximumSize(i,t,n,o),a=r.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=s.width,this.height=s.height,this._aspectRatio=this.aspectRatio,PD(this,a,!0)&&(this.notifyPlugins("resize",{size:s}),Mn(r.onResize,[this,s],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){let n=this.options.scales||{};cn(n,(r,i)=>{r.id=i})}buildOrUpdateScales(){let t=this.options,n=t.scales,r=this.scales,i=Object.keys(r).reduce((s,a)=>(s[a]=!1,s),{}),o=[];n&&(o=o.concat(Object.keys(n).map(s=>{let a=n[s],l=f2(s,a),u=l==="r",c=l==="x";return{options:a,dposition:u?"chartArea":c?"bottom":"left",dtype:u?"radialLinear":c?"category":"linear"}}))),cn(o,s=>{let a=s.options,l=a.id,u=f2(l,a),c=ht(a.type,s.dtype);(a.position===void 0||L6(a.position,u)!==L6(s.dposition))&&(a.position=s.dposition),i[l]=!0;let d=null;if(l in r&&r[l].type===c)d=r[l];else{let h=Wl.getScale(c);d=new h({id:l,type:c,ctx:this.ctx,chart:this}),r[d.id]=d}d.init(a,t)}),cn(i,(s,a)=>{s||delete r[a]}),cn(r,s=>{Xi.configure(this,s,s.options),Xi.addBox(this,s)})}_updateMetasets(){let t=this._metasets,n=this.data.datasets.length,r=t.length;if(t.sort((i,o)=>i.index-o.index),r>n){for(let i=n;i<r;++i)this._destroyDatasetMeta(i);t.splice(n,r-n)}this._sortedMetasets=t.slice(0).sort(B6("order","index"))}_removeUnreferencedMetasets(){let{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((r,i)=>{n.filter(o=>o===r._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){let t=[],n=this.data.datasets,r,i;for(this._removeUnreferencedMetasets(),r=0,i=n.length;r<i;r++){let o=n[r],s=this.getDatasetMeta(r),a=o.type||this.config.type;if(s.type&&s.type!==a&&(this._destroyDatasetMeta(r),s=this.getDatasetMeta(r)),s.type=a,s.indexAxis=o.indexAxis||h2(a,this.options),s.order=o.order||0,s.index=r,s.label=""+o.label,s.visible=this.isDatasetVisible(r),s.controller)s.controller.updateIndex(r),s.controller.linkScales();else{let l=Wl.getController(a),{datasetElementType:u,dataElementType:c}=Kn.datasets[a];Object.assign(l,{dataElementType:Wl.getElement(c),datasetElementType:u&&Wl.getElement(u)}),s.controller=new l(this,r),t.push(s.controller)}}return this._updateMetasets(),t}_resetElements(){cn(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){let n=this.config;n.update();let r=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!r.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;let o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let s=0;for(let u=0,c=this.data.datasets.length;u<c;u++){let{controller:d}=this.getDatasetMeta(u),h=!i&&o.indexOf(d)===-1;d.buildOrUpdateElements(h),s=Math.max(+d.getMaxOverflow(),s)}s=this._minPadding=r.layout.autoPadding?s:0,this._updateLayout(s),i||cn(o,u=>{u.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(B6("z","_idx"));let{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){cn(this.scales,t=>{Xi.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){let t=this.options,n=new Set(Object.keys(this._listeners)),r=new Set(t.events);(!mD(n,r)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){let{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(let{method:r,start:i,count:o}of n){let s=r==="_removeElements"?-o:o;HCe(t,i,s)}}_getUniformDataChanges(){let t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];let n=this.data.datasets.length,r=o=>new Set(t.filter(s=>s[0]===o).map((s,a)=>a+","+s.splice(1).join(","))),i=r(0);for(let o=1;o<n;o++)if(!mD(i,r(o)))return;return Array.from(i).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Xi.update(this,this.width,this.height,t);let n=this.chartArea,r=n.width<=0||n.height<=0;this._layers=[],cn(this.boxes,i=>{r&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,r=this.data.datasets.length;n<r;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,r=this.data.datasets.length;n<r;++n)this._updateDataset(n,ic(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){let r=this.getDatasetMeta(t),i={meta:r,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(r.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(lc.has(this)?this.attached&&!lc.running(this)&&lc.start(this):(this.draw(),q6({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){let{width:r,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(r,i)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;let n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){let n=this._sortedMetasets,r=[],i,o;for(i=0,o=n.length;i<o;++i){let s=n[i];(!t||s.visible)&&r.push(s)}return r}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;let t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){let n=this.ctx,r={meta:t,index:t.index,cancelable:!0},i=jD(this,t);this.notifyPlugins("beforeDatasetDraw",r)!==!1&&(i&&vb(n,i),t.controller.draw(),i&&bb(n),r.cancelable=!1,this.notifyPlugins("afterDatasetDraw",r))}isPointInArea(t){return zl(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,r,i){let o=Yke.modes[n];return typeof o=="function"?o(this,t,r,i):[]}getDatasetMeta(t){let n=this.data.datasets[t],r=this._metasets,i=r.filter(o=>o&&o._dataset===n).pop();return i||(i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},r.push(i)),i}getContext(){return this.$context||(this.$context=ac(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){let n=this.data.datasets[t];if(!n)return!1;let r=this.getDatasetMeta(t);return typeof r.hidden=="boolean"?!r.hidden:!n.hidden}setDatasetVisibility(t,n){let r=this.getDatasetMeta(t);r.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,r){let i=r?"show":"hide",o=this.getDatasetMeta(t),s=o.controller._resolveAnimations(void 0,i);Og(n)?(o.data[n].hidden=!r,this.update()):(this.setDatasetVisibility(t,r),s.update(o,{visible:r}),this.update(a=>a.datasetIndex===t?i:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){let n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),lc.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");let{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),ED(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete iC[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){let t=this._listeners,n=this.platform,r=(o,s)=>{n.addEventListener(this,o,s),t[o]=s},i=(o,s,a)=>{o.offsetX=s,o.offsetY=a,this._eventHandler(o)};cn(this.options.events,o=>r(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});let t=this._responsiveListeners,n=this.platform,r=(l,u)=>{n.addEventListener(this,l,u),t[l]=u},i=(l,u)=>{t[l]&&(n.removeEventListener(this,l,u),delete t[l])},o=(l,u)=>{this.canvas&&this.resize(l,u)},s,a=()=>{i("attach",a),this.attached=!0,this.resize(),r("resize",o),r("detach",s)};s=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),r("attach",a)},n.isAttached(this.canvas)?a():s()}unbindEvents(){cn(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},cn(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,r){let i=r?"set":"remove",o,s,a,l;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){s=t[a];let u=s&&this.getDatasetMeta(s.datasetIndex).controller;u&&u[i+"HoverStyle"](s.element,s.datasetIndex,s.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){let n=this._active||[],r=t.map(({datasetIndex:o,index:s})=>{let a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[s],index:s}});!gb(r,n)&&(this._active=r,this._lastEvent=null,this._updateHoverStyles(r,n))}notifyPlugins(t,n,r){return this._plugins.notify(this,t,n,r)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,r){let i=this.options.hover,o=(l,u)=>l.filter(c=>!u.some(d=>c.datasetIndex===d.datasetIndex&&c.index===d.index)),s=o(n,t),a=r?t:o(t,n);s.length&&this.updateHoverStyle(s,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,n){let r={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=s=>(s.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",r,i)===!1)return;let o=this._handleEvent(t,n,r.inChartArea);return r.cancelable=!1,this.notifyPlugins("afterEvent",r,i),(o||r.changed)&&this.render(),this}_handleEvent(t,n,r){let{_active:i=[],options:o}=this,s=n,a=this._getActiveElements(t,i,r,s),l=jU(t),u=$Ce(t,this._lastEvent,r,l);r&&(this._lastEvent=null,Mn(o.onHover,[t,a,this],this),l&&Mn(o.onClick,[t,a,this],this));let c=!gb(a,i);return(c||n)&&(this._active=a,this._updateHoverStyles(a,i,n)),this._lastEvent=u,c}_getActiveElements(t,n,r,i){if(t.type==="mouseout")return[];if(!r)return n;let o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}};function F6(){return cn(jd.instances,e=>e._plugins.invalidate())}function KCe(e,t,n){let{startAngle:r,x:i,y:o,outerRadius:s,innerRadius:a,options:l}=t,{borderWidth:u,borderJoinStyle:c}=l,d=Math.min(u/s,Li(r-n));if(e.beginPath(),e.arc(i,o,s-u/2,r+d/2,n-d/2),a>0){let h=Math.min(u/a,Li(r-n));e.arc(i,o,a+u/2,n-h/2,r+h/2,!0)}else{let h=Math.min(u/2,s*Li(r-n));if(c==="round")e.arc(i,o,h,n-Gt/2,r+Gt/2,!0);else if(c==="bevel"){let f=2*h*h,p=-f*Math.cos(n+Gt/2)+i,m=-f*Math.sin(n+Gt/2)+o,g=f*Math.cos(r+Gt/2)+i,y=f*Math.sin(r+Gt/2)+o;e.lineTo(p,m),e.lineTo(g,y)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}function YCe(e,t,n){let{startAngle:r,pixelMargin:i,x:o,y:s,outerRadius:a,innerRadius:l}=t,u=i/a;e.beginPath(),e.arc(o,s,a,r-u,n+u),l>i?(u=i/l,e.arc(o,s,l,n+u,r-u,!0)):e.arc(o,s,i,n+Sr,r-Sr),e.closePath(),e.clip()}function QCe(e){return $k(e,["outerStart","outerEnd","innerStart","innerEnd"])}function GCe(e,t,n,r){let i=QCe(e.options.borderRadius),o=(n-t)/2,s=Math.min(o,r*t/2),a=l=>{let u=(n-Math.min(o,l))*r/2;return si(l,0,Math.min(o,u))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:si(i.innerStart,0,s),innerEnd:si(i.innerEnd,0,s)}}function Pg(e,t,n,r){return{x:n+e*Math.cos(t),y:r+e*Math.sin(t)}}function uC(e,t,n,r,i,o){let{x:s,y:a,startAngle:l,pixelMargin:u,innerRadius:c}=t,d=Math.max(t.outerRadius+r+n-u,0),h=c>0?c+r+n+u:0,f=0,p=i-l;if(r){let R=c>0?c-r:0,T=d>0?d-r:0,B=(R+T)/2,A=B!==0?p*B/(B+r):p;f=(p-A)/2}let m=Math.max(.001,p*d-n/Gt)/d,g=(p-m)/2,y=l+g+f,v=i-g-f,{outerStart:b,outerEnd:w,innerStart:x,innerEnd:S}=GCe(t,h,d,v-y),k=d-b,C=d-w,N=y+b/k,E=v-w/C,D=h+x,q=h+S,z=y+x/D,_=v-S/q;if(e.beginPath(),o){let R=(N+E)/2;if(e.arc(s,a,d,N,R),e.arc(s,a,d,R,E),w>0){let M=Pg(C,E,s,a);e.arc(M.x,M.y,w,E,v+Sr)}let T=Pg(q,v,s,a);if(e.lineTo(T.x,T.y),S>0){let M=Pg(q,_,s,a);e.arc(M.x,M.y,S,v+Sr,_+Math.PI)}let B=(v-S/h+(y+x/h))/2;if(e.arc(s,a,h,v-S/h,B,!0),e.arc(s,a,h,B,y+x/h,!0),x>0){let M=Pg(D,z,s,a);e.arc(M.x,M.y,x,z+Math.PI,y-Sr)}let A=Pg(k,y,s,a);if(e.lineTo(A.x,A.y),b>0){let M=Pg(k,N,s,a);e.arc(M.x,M.y,b,y-Sr,N)}}else{e.moveTo(s,a);let R=Math.cos(N)*d+s,T=Math.sin(N)*d+a;e.lineTo(R,T);let B=Math.cos(E)*d+s,A=Math.sin(E)*d+a;e.lineTo(B,A)}e.closePath()}function XCe(e,t,n,r,i){let{fullCircles:o,startAngle:s,circumference:a}=t,l=t.endAngle;if(o){uC(e,t,n,r,l,i);for(let u=0;u<o;++u)e.fill();isNaN(a)||(l=s+(a%Bn||Bn))}return uC(e,t,n,r,l,i),e.fill(),l}function JCe(e,t,n,r,i){let{fullCircles:o,startAngle:s,circumference:a,options:l}=t,{borderWidth:u,borderJoinStyle:c,borderDash:d,borderDashOffset:h,borderRadius:f}=l,p=l.borderAlign==="inner";if(!u)return;e.setLineDash(d||[]),e.lineDashOffset=h,p?(e.lineWidth=u*2,e.lineJoin=c||"round"):(e.lineWidth=u,e.lineJoin=c||"bevel");let m=t.endAngle;if(o){uC(e,t,n,r,m,i);for(let g=0;g<o;++g)e.stroke();isNaN(a)||(m=s+(a%Bn||Bn))}p&&YCe(e,t,m),l.selfJoin&&m-s>=Gt&&f===0&&c!=="miter"&&KCe(e,t,m),o||(uC(e,t,n,r,m,i),e.stroke())}var m2=class extends Qa{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,n,r){let i=this.getProps(["x","y"],r),{angle:o,distance:s}=bD(i,{x:t,y:n}),{startAngle:a,endAngle:l,innerRadius:u,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],r),h=(this.options.spacing+this.options.borderWidth)/2,f=ht(d,l-a),p=Ag(o,a,l)&&a!==l,m=f>=Bn||p,g=jl(s,u+h,c+h);return m&&g}getCenterPoint(t){let{x:n,y:r,startAngle:i,endAngle:o,innerRadius:s,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:l,spacing:u}=this.options,c=(i+o)/2,d=(s+a+u+l)/2;return{x:n+Math.cos(c)*d,y:r+Math.sin(c)*d}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){let{options:n,circumference:r}=this,i=(n.offset||0)/4,o=(n.spacing||0)/2,s=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=r>Bn?Math.floor(r/Bn):0,r===0||this.innerRadius<0||this.outerRadius<0)return;t.save();let a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*i,Math.sin(a)*i);let l=1-Math.sin(Math.min(Gt,r||0)),u=i*l;t.fillStyle=n.backgroundColor,t.strokeStyle=n.borderColor,XCe(t,this,u,o,s),JCe(t,this,u,o,s),t.restore()}};function SH(e,t,n=t){e.lineCap=ht(n.borderCapStyle,t.borderCapStyle),e.setLineDash(ht(n.borderDash,t.borderDash)),e.lineDashOffset=ht(n.borderDashOffset,t.borderDashOffset),e.lineJoin=ht(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=ht(n.borderWidth,t.borderWidth),e.strokeStyle=ht(n.borderColor,t.borderColor)}function ZCe(e,t,n){e.lineTo(n.x,n.y)}function eNe(e){return e.stepped?ZU:e.tension||e.cubicInterpolationMode==="monotone"?e6:ZCe}function kH(e,t,n={}){let r=e.length,{start:i=0,end:o=r-1}=n,{start:s,end:a}=t,l=Math.max(i,s),u=Math.min(o,a),c=i<s&&o<s||i>a&&o>a;return{count:r,start:l,loop:t.loop,ilen:u<l&&!c?r+u-l:u-l}}function tNe(e,t,n,r){let{points:i,options:o}=t,{count:s,start:a,loop:l,ilen:u}=kH(i,n,r),c=eNe(o),{move:d=!0,reverse:h}=r||{},f,p,m;for(f=0;f<=u;++f)p=i[(a+(h?u-f:f))%s],!p.skip&&(d?(e.moveTo(p.x,p.y),d=!1):c(e,m,p,h,o.stepped),m=p);return l&&(p=i[(a+(h?u:0))%s],c(e,m,p,h,o.stepped)),!!l}function nNe(e,t,n,r){let i=t.points,{count:o,start:s,ilen:a}=kH(i,n,r),{move:l=!0,reverse:u}=r||{},c=0,d=0,h,f,p,m,g,y,v=w=>(s+(u?a-w:w))%o,b=()=>{m!==g&&(e.lineTo(c,g),e.lineTo(c,m),e.lineTo(c,y))};for(l&&(f=i[v(0)],e.moveTo(f.x,f.y)),h=0;h<=a;++h){if(f=i[v(h)],f.skip)continue;let w=f.x,x=f.y,S=w|0;S===p?(x<m?m=x:x>g&&(g=x),c=(d*c+w)/++d):(b(),e.lineTo(w,x),p=S,d=0,m=g=x),y=x}b()}function g2(e){let t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?nNe:tNe}function rNe(e){return e.stepped?u6:e.tension||e.cubicInterpolationMode==="monotone"?c6:Rd}function iNe(e,t,n,r){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,r)&&i.closePath()),SH(e,t.options),e.stroke(i)}function oNe(e,t,n,r){let{segments:i,options:o}=t,s=g2(t);for(let a of i)SH(e,o,a.style),e.beginPath(),s(e,t,a,{start:n,end:n+r-1})&&e.closePath(),e.stroke()}var sNe=typeof Path2D=="function";function aNe(e,t,n,r){sNe&&!t.options.segment?iNe(e,t,n,r):oNe(e,t,n,r)}var Bg=class extends Qa{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){let r=this.options;if((r.tension||r.cubicInterpolationMode==="monotone")&&!r.stepped&&!this._pointsUpdated){let i=r.spanGaps?this._loop:this._fullLoop;s6(this._points,r,t,i,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=h6(this,this.options.segment))}first(){let t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){let t=this.segments,n=this.points,r=t.length;return r&&n[t[r-1].end]}interpolate(t,n){let r=this.options,i=t[n],o=this.points,s=FD(this,{property:n,start:i,end:i});if(!s.length)return;let a=[],l=rNe(r),u,c;for(u=0,c=s.length;u<c;++u){let{start:d,end:h}=s[u],f=o[d],p=o[h];if(f===p){a.push(f);continue}let m=Math.abs((i-f[n])/(p[n]-f[n])),g=l(f,p,m,r.stepped);g[n]=t[n],a.push(g)}return a.length===1?a[0]:a}pathSegment(t,n,r){return g2(this)(t,this,n,r)}path(t,n,r){let i=this.segments,o=g2(this),s=this._loop;n=n||0,r=r||this.points.length-n;for(let a of i)s&=o(t,this,a,{start:n,end:n+r-1});return!!s}draw(t,n,r,i){let o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),aNe(t,this,r,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}};function j6(e,t,n,r){let i=e.options,{[n]:o}=e.getProps([n],r);return Math.abs(t-o)<i.radius+i.hitRadius}var y2=class extends Qa{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,r){let i=this.options,{x:o,y:s}=this.getProps(["x","y"],r);return Math.pow(t-o,2)+Math.pow(n-s,2)<Math.pow(i.hitRadius+i.radius,2)}inXRange(t,n){return j6(this,t,"x",n)}inYRange(t,n){return j6(this,t,"y",n)}getCenterPoint(t){let{x:n,y:r}=this.getProps(["x","y"],t);return{x:n,y:r}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);let r=n&&t.borderWidth||0;return(n+r)*2}draw(t,n){let r=this.options;this.skip||r.radius<.1||!zl(this,n,this.size(r)/2)||(t.strokeStyle=r.borderColor,t.lineWidth=r.borderWidth,t.fillStyle=r.backgroundColor,Hk(t,r,this.x,this.y))}getRange(){let t=this.options||{};return t.radius+t.hitRadius}};function CH(e,t){let{x:n,y:r,base:i,width:o,height:s}=e.getProps(["x","y","base","width","height"],t),a,l,u,c,d;return e.horizontal?(d=s/2,a=Math.min(n,i),l=Math.max(n,i),u=r-d,c=r+d):(d=o/2,a=n-d,l=n+d,u=Math.min(r,i),c=Math.max(r,i)),{left:a,top:u,right:l,bottom:c}}function Fd(e,t,n,r){return e?0:si(t,n,r)}function lNe(e,t,n){let r=e.options.borderWidth,i=e.borderSkipped,o=TD(r);return{t:Fd(i.top,o.top,0,n),r:Fd(i.right,o.right,0,t),b:Fd(i.bottom,o.bottom,0,n),l:Fd(i.left,o.left,0,t)}}function uNe(e,t,n){let{enableBorderRadius:r}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,o=qd(i),s=Math.min(t,n),a=e.borderSkipped,l=r||Bt(i);return{topLeft:Fd(!l||a.top||a.left,o.topLeft,0,s),topRight:Fd(!l||a.top||a.right,o.topRight,0,s),bottomLeft:Fd(!l||a.bottom||a.left,o.bottomLeft,0,s),bottomRight:Fd(!l||a.bottom||a.right,o.bottomRight,0,s)}}function cNe(e){let t=CH(e),n=t.right-t.left,r=t.bottom-t.top,i=lNe(e,n/2,r/2),o=uNe(e,n/2,r/2);return{outer:{x:t.left,y:t.top,w:n,h:r,radius:o},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:r-i.t-i.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,o.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(i.b,i.r))}}}}function QD(e,t,n,r){let i=t===null,o=n===null,a=e&&!(i&&o)&&CH(e,r);return a&&(i||jl(t,a.left,a.right))&&(o||jl(n,a.top,a.bottom))}function dNe(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function hNe(e,t){e.rect(t.x,t.y,t.w,t.h)}function GD(e,t,n={}){let r=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,o=(e.x+e.w!==n.x+n.w?t:0)-r,s=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+r,y:e.y+i,w:e.w+o,h:e.h+s,radius:e.radius}}var v2=class extends Qa{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){let{inflateAmount:n,options:{borderColor:r,backgroundColor:i}}=this,{inner:o,outer:s}=cNe(this),a=dNe(s.radius)?Rg:hNe;t.save(),(s.w!==o.w||s.h!==o.h)&&(t.beginPath(),a(t,GD(s,n,o)),t.clip(),a(t,GD(o,-n,s)),t.fillStyle=r,t.fill("evenodd")),t.beginPath(),a(t,GD(o,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,r){return QD(this,t,n,r)}inXRange(t,n){return QD(this,t,null,n)}inYRange(t,n){return QD(this,null,t,n)}getCenterPoint(t){let{x:n,y:r,base:i,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(n+i)/2:n,y:o?r:(r+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}},fNe=Object.freeze({__proto__:null,ArcElement:m2,BarElement:v2,LineElement:Bg,PointElement:y2}),b2=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],V6=b2.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function NH(e){return b2[e%b2.length]}function MH(e){return V6[e%V6.length]}function pNe(e,t){return e.borderColor=NH(t),e.backgroundColor=MH(t),++t}function mNe(e,t){return e.backgroundColor=e.data.map(()=>NH(t++)),t}function gNe(e,t){return e.backgroundColor=e.data.map(()=>MH(t++)),t}function yNe(e){let t=0;return(n,r)=>{let i=e.getDatasetMeta(r).controller;i instanceof _b?t=mNe(n,t):i instanceof sC?t=gNe(n,t):i&&(t=pNe(n,t))}}function W6(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function vNe(e){return e&&(e.borderColor||e.backgroundColor)}function bNe(){return Kn.borderColor!=="rgba(0,0,0,0.1)"||Kn.backgroundColor!=="rgba(0,0,0,0.1)"}var _2={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;let{data:{datasets:r},options:i}=e.config,{elements:o}=i,s=W6(r)||vNe(i)||o&&W6(o)||bNe();if(!n.forceOverride&&s)return;let a=yNe(e);r.forEach(a)}};function wNe(e,t,n,r,i){let o=i.samples||r;if(o>=n)return e.slice(t,t+n);let s=[],a=(n-2)/(o-2),l=0,u=t+n-1,c=t,d,h,f,p,m;for(s[l++]=e[c],d=0;d<o-2;d++){let g=0,y=0,v,b=Math.floor((d+1)*a)+1+t,w=Math.min(Math.floor((d+2)*a)+1,n)+t,x=w-b;for(v=b;v<w;v++)g+=e[v].x,y+=e[v].y;g/=x,y/=x;let S=Math.floor(d*a)+1+t,k=Math.min(Math.floor((d+1)*a)+1,n)+t,{x:C,y:N}=e[c];for(f=p=-1,v=S;v<k;v++)p=.5*Math.abs((C-g)*(e[v].y-N)-(C-e[v].x)*(y-N)),p>f&&(f=p,h=e[v],m=v);s[l++]=h,c=m}return s[l++]=e[u],s}function xNe(e,t,n,r){let i=0,o=0,s,a,l,u,c,d,h,f,p,m,g=[],y=t+n-1,v=e[t].x,w=e[y].x-v;for(s=t;s<t+n;++s){a=e[s],l=(a.x-v)/w*r,u=a.y;let x=l|0;if(x===c)u<p?(p=u,d=s):u>m&&(m=u,h=s),i=(o*i+a.x)/++o;else{let S=s-1;if(!Rt(d)&&!Rt(h)){let k=Math.min(d,h),C=Math.max(d,h);k!==f&&k!==S&&g.push({...e[k],x:i}),C!==f&&C!==S&&g.push({...e[C],x:i})}s>0&&S!==f&&g.push(e[S]),g.push(a),c=x,o=0,p=m=u,d=h=f=s}}return g}function _H(e){if(e._decimated){let t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function U6(e){e.data.datasets.forEach(t=>{_H(t)})}function SNe(e,t){let n=t.length,r=0,i,{iScale:o}=e,{min:s,max:a,minDefined:l,maxDefined:u}=o.getUserBounds();return l&&(r=si(ql(t,o.axis,s).lo,0,n-1)),u?i=si(ql(t,o.axis,a).hi+1,r,n)-r:i=n-r,{start:r,count:i}}var kNe={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){U6(e);return}let r=e.width;e.data.datasets.forEach((i,o)=>{let{_data:s,indexAxis:a}=i,l=e.getDatasetMeta(o),u=s||i.data;if(Ig([a,e.options.indexAxis])==="y"||!l.controller.supportsDecimation)return;let c=e.scales[l.xAxisID];if(c.type!=="linear"&&c.type!=="time"||e.options.parsing)return;let{start:d,count:h}=SNe(l,u),f=n.threshold||4*r;if(h<=f){_H(i);return}Rt(s)&&(i._data=u,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(m){this._data=m}}));let p;switch(n.algorithm){case"lttb":p=wNe(u,d,h,r,n);break;case"min-max":p=xNe(u,d,h,r);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}i._decimated=p})},destroy(e){U6(e)}};function CNe(e,t,n){let r=e.segments,i=e.points,o=t.points,s=[];for(let a of r){let{start:l,end:u}=a;u=fC(l,u,i);let c=w2(n,i[l],i[u],a.loop);if(!t.segments){s.push({source:a,target:c,start:i[l],end:i[u]});continue}let d=FD(t,c);for(let h of d){let f=w2(n,o[h.start],o[h.end],h.loop),p=zD(a,i,f);for(let m of p)s.push({source:m,target:h,start:{[n]:H6(c,f,"start",Math.max)},end:{[n]:H6(c,f,"end",Math.min)}})}}return s}function w2(e,t,n,r){if(r)return;let i=t[e],o=n[e];return e==="angle"&&(i=Li(i),o=Li(o)),{property:e,start:i,end:o}}function NNe(e,t){let{x:n=null,y:r=null}=e||{},i=t.points,o=[];return t.segments.forEach(({start:s,end:a})=>{a=fC(s,a,i);let l=i[s],u=i[a];r!==null?(o.push({x:l.x,y:r}),o.push({x:u.x,y:r})):n!==null&&(o.push({x:n,y:l.y}),o.push({x:n,y:u.y}))}),o}function fC(e,t,n){for(;t>e;t--){let r=n[t];if(!isNaN(r.x)&&!isNaN(r.y))break}return t}function H6(e,t,n,r){return e&&t?r(e[n],t[n]):e?e[n]:t?t[n]:0}function EH(e,t){let n=[],r=!1;return Ln(e)?(r=!0,n=e):n=NNe(e,t),n.length?new Bg({points:n,options:{tension:0},_loop:r,_fullLoop:r}):null}function $6(e){return e&&e.fill!==!1}function MNe(e,t,n){let i=e[t].fill,o=[t],s;if(!n)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!fr(i))return i;if(s=e[i],!s)return!1;if(s.visible)return i;o.push(i),i=s.fill}return!1}function _Ne(e,t,n){let r=ANe(e);if(Bt(r))return isNaN(r.value)?!1:r;let i=parseFloat(r);return fr(i)&&Math.floor(i)===i?ENe(r[0],t,i,n):["origin","start","end","stack","shape"].indexOf(r)>=0&&r}function ENe(e,t,n,r){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=r?!1:n}function ONe(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:Bt(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function TNe(e,t,n){let r;return e==="start"?r=n:e==="end"?r=t.options.reverse?t.min:t.max:Bt(e)?r=e.value:r=t.getBaseValue(),r}function ANe(e){let t=e.options,n=t.fill,r=ht(n&&n.target,n);return r===void 0&&(r=!!t.backgroundColor),r===!1||r===null?!1:r===!0?"origin":r}function DNe(e){let{scale:t,index:n,line:r}=e,i=[],o=r.segments,s=r.points,a=RNe(t,n);a.push(EH({x:null,y:t.bottom},r));for(let l=0;l<o.length;l++){let u=o[l];for(let c=u.start;c<=u.end;c++)INe(i,s[c],a)}return new Bg({points:i,options:{}})}function RNe(e,t){let n=[],r=e.getMatchingVisibleMetas("line");for(let i=0;i<r.length;i++){let o=r[i];if(o.index===t)break;o.hidden||n.unshift(o.dataset)}return n}function INe(e,t,n){let r=[];for(let i=0;i<n.length;i++){let o=n[i],{first:s,last:a,point:l}=PNe(o,t,"x");if(!(!l||s&&a)){if(s)r.unshift(l);else if(e.push(l),!a)break}}e.push(...r)}function PNe(e,t,n){let r=e.interpolate(t,n);if(!r)return{};let i=r[n],o=e.segments,s=e.points,a=!1,l=!1;for(let u=0;u<o.length;u++){let c=o[u],d=s[c.start][n],h=s[c.end][n];if(jl(i,d,h)){a=i===d,l=i===h;break}}return{first:a,last:l,point:r}}var cC=class{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,r){let{x:i,y:o,radius:s}=this;return n=n||{start:0,end:Bn},t.arc(i,o,s,n.end,n.start,!0),!r.bounds}interpolate(t){let{x:n,y:r,radius:i}=this,o=t.angle;return{x:n+Math.cos(o)*i,y:r+Math.sin(o)*i,angle:o}}};function LNe(e){let{chart:t,fill:n,line:r}=e;if(fr(n))return BNe(t,n);if(n==="stack")return DNe(e);if(n==="shape")return!0;let i=qNe(e);return i instanceof cC?i:EH(i,r)}function BNe(e,t){let n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function qNe(e){return(e.scale||{}).getPointPositionForValue?FNe(e):zNe(e)}function zNe(e){let{scale:t={},fill:n}=e,r=ONe(n,t);if(fr(r)){let i=t.isHorizontal();return{x:i?r:null,y:i?null:r}}return null}function FNe(e){let{scale:t,fill:n}=e,r=t.options,i=t.getLabels().length,o=r.reverse?t.max:t.min,s=TNe(n,t,o),a=[];if(r.grid.circular){let l=t.getPointPositionForValue(0,o);return new cC({x:l.x,y:l.y,radius:t.getDistanceFromCenterForValue(s)})}for(let l=0;l<i;++l)a.push(t.getPointPositionForValue(l,s));return a}function XD(e,t,n){let r=LNe(t),{chart:i,index:o,line:s,scale:a,axis:l}=t,u=s.options,c=u.fill,d=u.backgroundColor,{above:h=d,below:f=d}=c||{},p=i.getDatasetMeta(o),m=jD(i,p);r&&s.points.length&&(vb(e,n),jNe(e,{line:s,target:r,above:h,below:f,area:n,scale:a,axis:l,clip:m}),bb(e))}function jNe(e,t){let{line:n,target:r,above:i,below:o,area:s,scale:a,clip:l}=t,u=n._loop?"angle":t.axis;e.save();let c=o;o!==i&&(u==="x"?(K6(e,r,s.top),JD(e,{line:n,target:r,color:i,scale:a,property:u,clip:l}),e.restore(),e.save(),K6(e,r,s.bottom)):u==="y"&&(Y6(e,r,s.left),JD(e,{line:n,target:r,color:o,scale:a,property:u,clip:l}),e.restore(),e.save(),Y6(e,r,s.right),c=i)),JD(e,{line:n,target:r,color:c,scale:a,property:u,clip:l}),e.restore()}function K6(e,t,n){let{segments:r,points:i}=t,o=!0,s=!1;e.beginPath();for(let a of r){let{start:l,end:u}=a,c=i[l],d=i[fC(l,u,i)];o?(e.moveTo(c.x,c.y),o=!1):(e.lineTo(c.x,n),e.lineTo(c.x,c.y)),s=!!t.pathSegment(e,a,{move:s}),s?e.closePath():e.lineTo(d.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Y6(e,t,n){let{segments:r,points:i}=t,o=!0,s=!1;e.beginPath();for(let a of r){let{start:l,end:u}=a,c=i[l],d=i[fC(l,u,i)];o?(e.moveTo(c.x,c.y),o=!1):(e.lineTo(n,c.y),e.lineTo(c.x,c.y)),s=!!t.pathSegment(e,a,{move:s}),s?e.closePath():e.lineTo(n,d.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function JD(e,t){let{line:n,target:r,property:i,color:o,scale:s,clip:a}=t,l=CNe(n,r,i);for(let{source:u,target:c,start:d,end:h}of l){let{style:{backgroundColor:f=o}={}}=u,p=r!==!0;e.save(),e.fillStyle=f,VNe(e,s,a,p&&w2(i,d,h)),e.beginPath();let m=!!n.pathSegment(e,u),g;if(p){m?e.closePath():Q6(e,r,h,i);let y=!!r.pathSegment(e,c,{move:m,reverse:!0});g=m&&y,g||Q6(e,r,d,i)}e.closePath(),e.fill(g?"evenodd":"nonzero"),e.restore()}}function VNe(e,t,n,r){let i=t.chart.chartArea,{property:o,start:s,end:a}=r||{};if(o==="x"||o==="y"){let l,u,c,d;o==="x"?(l=s,u=i.top,c=a,d=i.bottom):(l=i.left,u=s,c=i.right,d=a),e.beginPath(),n&&(l=Math.max(l,n.left),c=Math.min(c,n.right),u=Math.max(u,n.top),d=Math.min(d,n.bottom)),e.rect(l,u,c-l,d-u),e.clip()}}function Q6(e,t,n,r){let i=t.interpolate(n,r);i&&e.lineTo(i.x,i.y)}var WNe={id:"filler",afterDatasetsUpdate(e,t,n){let r=(e.data.datasets||[]).length,i=[],o,s,a,l;for(s=0;s<r;++s)o=e.getDatasetMeta(s),a=o.dataset,l=null,a&&a.options&&a instanceof Bg&&(l={visible:e.isDatasetVisible(s),index:s,fill:_Ne(a,s,r),chart:e,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=l,i.push(l);for(s=0;s<r;++s)l=i[s],!(!l||l.fill===!1)&&(l.fill=MNe(i,s,n.propagate))},beforeDraw(e,t,n){let r=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),o=e.chartArea;for(let s=i.length-1;s>=0;--s){let a=i[s].$filler;a&&(a.line.updateControlPoints(o,a.axis),r&&a.fill&&XD(e.ctx,a,o))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;let r=e.getSortedVisibleDatasetMetas();for(let i=r.length-1;i>=0;--i){let o=r[i].$filler;$6(o)&&XD(e.ctx,o,e.chartArea)}},beforeDatasetDraw(e,t,n){let r=t.meta.$filler;!$6(r)||n.drawTime!=="beforeDatasetDraw"||XD(e.ctx,r,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}},G6=(e,t)=>{let{boxHeight:n=t,boxWidth:r=t}=e;return e.usePointStyle&&(n=Math.min(n,t),r=e.pointStyleWidth||Math.min(r,t)),{boxWidth:r,boxHeight:n,itemHeight:Math.max(t,n)}},UNe=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index,dC=class extends Qa{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,r){this.maxWidth=t,this.maxHeight=n,this._margins=r,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){let t=this.options.labels||{},n=Mn(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(r=>t.filter(r,this.chart.data))),t.sort&&(n=n.sort((r,i)=>t.sort(r,i,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){let{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}let r=t.labels,i=Vr(r.font),o=i.size,s=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=G6(r,o),u,c;n.font=i.string,this.isHorizontal()?(u=this.maxWidth,c=this._fitRows(s,o,a,l)+10):(c=this.maxHeight,u=this._fitCols(s,i,a,l)+10),this.width=Math.min(u,t.maxWidth||this.maxWidth),this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,n,r,i){let{ctx:o,maxWidth:s,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],u=this.lineWidths=[0],c=i+a,d=t;o.textAlign="left",o.textBaseline="middle";let h=-1,f=-c;return this.legendItems.forEach((p,m)=>{let g=r+n/2+o.measureText(p.text).width;(m===0||u[u.length-1]+g+2*a>s)&&(d+=c,u[u.length-(m>0?0:1)]=0,f+=c,h++),l[m]={left:0,top:f,row:h,width:g,height:i},u[u.length-1]+=g+a}),d}_fitCols(t,n,r,i){let{ctx:o,maxHeight:s,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],u=this.columnSizes=[],c=s-t,d=a,h=0,f=0,p=0,m=0;return this.legendItems.forEach((g,y)=>{let{itemWidth:v,itemHeight:b}=HNe(r,n,o,g,i);y>0&&f+b+2*a>c&&(d+=h+a,u.push({width:h,height:f}),p+=h+a,m++,h=f=0),l[y]={left:p,top:f,col:m,width:v,height:b},h=Math.max(h,v),f+=b+a}),d+=h,u.push({width:h,height:f}),d}adjustHitBoxes(){if(!this.options.display)return;let t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:r,labels:{padding:i},rtl:o}}=this,s=np(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=Bi(r,this.left+i,this.right-this.lineWidths[a]);for(let u of n)a!==u.row&&(a=u.row,l=Bi(r,this.left+i,this.right-this.lineWidths[a])),u.top+=this.top+t+i,u.left=s.leftForLtr(s.x(l),u.width),l+=u.width+i}else{let a=0,l=Bi(r,this.top+t+i,this.bottom-this.columnSizes[a].height);for(let u of n)u.col!==a&&(a=u.col,l=Bi(r,this.top+t+i,this.bottom-this.columnSizes[a].height)),u.top=l,u.left+=this.left+i,u.left=s.leftForLtr(s.x(u.left),u.width),l+=u.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){let t=this.ctx;vb(t,this),this._draw(),bb(t)}}_draw(){let{options:t,columnSizes:n,lineWidths:r,ctx:i}=this,{align:o,labels:s}=t,a=Kn.color,l=np(t.rtl,this.left,this.width),u=Vr(s.font),{padding:c}=s,d=u.size,h=d/2,f;this.drawTitle(),i.textAlign=l.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=u.string;let{boxWidth:p,boxHeight:m,itemHeight:g}=G6(s,d),y=function(S,k,C){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;i.save();let N=ht(C.lineWidth,1);if(i.fillStyle=ht(C.fillStyle,a),i.lineCap=ht(C.lineCap,"butt"),i.lineDashOffset=ht(C.lineDashOffset,0),i.lineJoin=ht(C.lineJoin,"miter"),i.lineWidth=N,i.strokeStyle=ht(C.strokeStyle,a),i.setLineDash(ht(C.lineDash,[])),s.usePointStyle){let E={radius:m*Math.SQRT2/2,pointStyle:C.pointStyle,rotation:C.rotation,borderWidth:N},D=l.xPlus(S,p/2),q=k+h;OD(i,E,D,q,s.pointStyleWidth&&p)}else{let E=k+Math.max((d-m)/2,0),D=l.leftForLtr(S,p),q=qd(C.borderRadius);i.beginPath(),Object.values(q).some(z=>z!==0)?Rg(i,{x:D,y:E,w:p,h:m,radius:q}):i.rect(D,E,p,m),i.fill(),N!==0&&i.stroke()}i.restore()},v=function(S,k,C){Bd(i,C.text,S,k+g/2,u,{strikethrough:C.hidden,textAlign:l.textAlign(C.textAlign)})},b=this.isHorizontal(),w=this._computeTitleHeight();b?f={x:Bi(o,this.left+c,this.right-r[0]),y:this.top+c+w,line:0}:f={x:this.left+c,y:Bi(o,this.top+w+c,this.bottom-n[0].height),line:0},BD(this.ctx,t.textDirection);let x=g+c;this.legendItems.forEach((S,k)=>{i.strokeStyle=S.fontColor,i.fillStyle=S.fontColor;let C=i.measureText(S.text).width,N=l.textAlign(S.textAlign||(S.textAlign=s.textAlign)),E=p+h+C,D=f.x,q=f.y;l.setWidth(this.width),b?k>0&&D+E+c>this.right&&(q=f.y+=x,f.line++,D=f.x=Bi(o,this.left+c,this.right-r[f.line])):k>0&&q+x>this.bottom&&(D=f.x=D+n[f.line].width+c,f.line++,q=f.y=Bi(o,this.top+w+c,this.bottom-n[f.line].height));let z=l.x(D);if(y(z,q,S),D=GU(N,D+p+h,b?D+E:this.right,t.rtl),v(l.x(D),q,S),b)f.x+=E+c;else if(typeof S.text!="string"){let _=u.lineHeight;f.y+=OH(S,_)+c}else f.y+=x}),qD(this.ctx,t.textDirection)}drawTitle(){let t=this.options,n=t.title,r=Vr(n.font),i=qi(n.padding);if(!n.display)return;let o=np(t.rtl,this.left,this.width),s=this.ctx,a=n.position,l=r.size/2,u=i.top+l,c,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+u,d=Bi(t.align,d,this.right-h);else{let p=this.columnSizes.reduce((m,g)=>Math.max(m,g.height),0);c=u+Bi(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}let f=Bi(a,d,d+h);s.textAlign=o.textAlign(Wk(a)),s.textBaseline="middle",s.strokeStyle=n.color,s.fillStyle=n.color,s.font=r.string,Bd(s,n.text,f,c,r)}_computeTitleHeight(){let t=this.options.title,n=Vr(t.font),r=qi(t.padding);return t.display?n.lineHeight+r.height:0}_getLegendItemAt(t,n){let r,i,o;if(jl(t,this.left,this.right)&&jl(n,this.top,this.bottom)){for(o=this.legendHitBoxes,r=0;r<o.length;++r)if(i=o[r],jl(t,i.left,i.left+i.width)&&jl(n,i.top,i.top+i.height))return this.legendItems[r]}return null}handleEvent(t){let n=this.options;if(!YNe(t.type,n))return;let r=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){let i=this._hoveredItem,o=UNe(i,r);i&&!o&&Mn(n.onLeave,[t,i,this],this),this._hoveredItem=r,r&&!o&&Mn(n.onHover,[t,r,this],this)}else r&&Mn(n.onClick,[t,r,this],this)}};function HNe(e,t,n,r,i){let o=$Ne(r,e,t,n),s=KNe(i,r,t.lineHeight);return{itemWidth:o,itemHeight:s}}function $Ne(e,t,n,r){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((o,s)=>o.length>s.length?o:s)),t+n.size/2+r.measureText(i).width}function KNe(e,t,n){let r=e;return typeof t.text!="string"&&(r=OH(t,n)),r}function OH(e,t){let n=e.text?e.text.length:0;return t*n}function YNe(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var QNe={id:"legend",_element:dC,start(e,t,n){let r=e.legend=new dC({ctx:e.ctx,options:n,chart:e});Xi.configure(e,r,n),Xi.addBox(e,r)},stop(e){Xi.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){let r=e.legend;Xi.configure(e,r,n),r.options=n},afterUpdate(e){let t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){let r=t.datasetIndex,i=n.chart;i.isDatasetVisible(r)?(i.hide(r),t.hidden=!0):(i.show(r),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){let t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:r,textAlign:i,color:o,useBorderRadius:s,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{let u=l.controller.getStyle(n?0:void 0),c=qi(u.borderWidth);return{text:t[l.index].label,fillStyle:u.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:u.borderCapStyle,lineDash:u.borderDash,lineDashOffset:u.borderDashOffset,lineJoin:u.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:u.borderColor,pointStyle:r||u.pointStyle,rotation:u.rotation,textAlign:i||u.textAlign,borderRadius:s&&(a||u.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}},Ob=class extends Qa{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){let r=this.options;if(this.left=0,this.top=0,!r.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;let i=Ln(r.text)?r.text.length:1;this._padding=qi(r.padding);let o=i*Vr(r.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){let t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){let{top:n,left:r,bottom:i,right:o,options:s}=this,a=s.align,l=0,u,c,d;return this.isHorizontal()?(c=Bi(a,r,o),d=n+t,u=o-r):(s.position==="left"?(c=r+t,d=Bi(a,i,n),l=Gt*-.5):(c=o-t,d=Bi(a,n,i),l=Gt*.5),u=i-n),{titleX:c,titleY:d,maxWidth:u,rotation:l}}draw(){let t=this.ctx,n=this.options;if(!n.display)return;let r=Vr(n.font),o=r.lineHeight/2+this._padding.top,{titleX:s,titleY:a,maxWidth:l,rotation:u}=this._drawArgs(o);Bd(t,n.text,0,0,r,{color:n.color,maxWidth:l,rotation:u,textAlign:Wk(n.align),textBaseline:"middle",translation:[s,a]})}};function GNe(e,t){let n=new Ob({ctx:e.ctx,options:t,chart:e});Xi.configure(e,n,t),Xi.addBox(e,n),e.titleBlock=n}var XNe={id:"title",_element:Ob,start(e,t,n){GNe(e,n)},stop(e){let t=e.titleBlock;Xi.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){let r=e.titleBlock;Xi.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},eC=new WeakMap,JNe={id:"subtitle",start(e,t,n){let r=new Ob({ctx:e.ctx,options:n,chart:e});Xi.configure(e,r,n),Xi.addBox(e,r),eC.set(e,r)},stop(e){Xi.removeBox(e,eC.get(e)),eC.delete(e)},beforeUpdate(e,t,n){let r=eC.get(e);Xi.configure(e,r,n),r.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}},Mb={average(e){if(!e.length)return!1;let t,n,r=new Set,i=0,o=0;for(t=0,n=e.length;t<n;++t){let a=e[t].element;if(a&&a.hasValue()){let l=a.tooltipPosition();r.add(l.x),i+=l.y,++o}}return o===0||r.size===0?!1:{x:[...r].reduce((a,l)=>a+l)/r.size,y:i/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,r=t.y,i=Number.POSITIVE_INFINITY,o,s,a;for(o=0,s=e.length;o<s;++o){let l=e[o].element;if(l&&l.hasValue()){let u=l.getCenterPoint(),c=qk(t,u);c<i&&(i=c,a=l)}}if(a){let l=a.tooltipPosition();n=l.x,r=l.y}return{x:n,y:r}}};function Vl(e,t){return t&&(Ln(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function uc(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
`)>-1?e.split(`
`):e}function ZNe(e,t){let{element:n,datasetIndex:r,index:i}=t,o=e.getDatasetMeta(r).controller,{label:s,value:a}=o.getLabelAndValue(i);return{chart:e,label:s,parsed:o.getParsed(i),raw:e.data.datasets[r].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:r,element:n}}function X6(e,t){let n=e.chart.ctx,{body:r,footer:i,title:o}=e,{boxWidth:s,boxHeight:a}=t,l=Vr(t.bodyFont),u=Vr(t.titleFont),c=Vr(t.footerFont),d=o.length,h=i.length,f=r.length,p=qi(t.padding),m=p.height,g=0,y=r.reduce((w,x)=>w+x.before.length+x.lines.length+x.after.length,0);if(y+=e.beforeBody.length+e.afterBody.length,d&&(m+=d*u.lineHeight+(d-1)*t.titleSpacing+t.titleMarginBottom),y){let w=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;m+=f*w+(y-f)*l.lineHeight+(y-1)*t.bodySpacing}h&&(m+=t.footerMarginTop+h*c.lineHeight+(h-1)*t.footerSpacing);let v=0,b=function(w){g=Math.max(g,n.measureText(w).width+v)};return n.save(),n.font=u.string,cn(e.title,b),n.font=l.string,cn(e.beforeBody.concat(e.afterBody),b),v=t.displayColors?s+2+t.boxPadding:0,cn(r,w=>{cn(w.before,b),cn(w.lines,b),cn(w.after,b)}),v=0,n.font=c.string,cn(e.footer,b),n.restore(),g+=p.width,{width:g,height:m}}function eMe(e,t){let{y:n,height:r}=t;return n<r/2?"top":n>e.height-r/2?"bottom":"center"}function tMe(e,t,n,r){let{x:i,width:o}=r,s=n.caretSize+n.caretPadding;if(e==="left"&&i+o+s>t.width||e==="right"&&i-o-s<0)return!0}function nMe(e,t,n,r){let{x:i,width:o}=n,{width:s,chartArea:{left:a,right:l}}=e,u="center";return r==="center"?u=i<=(a+l)/2?"left":"right":i<=o/2?u="left":i>=s-o/2&&(u="right"),tMe(u,e,t,n)&&(u="center"),u}function J6(e,t,n){let r=n.yAlign||t.yAlign||eMe(e,n);return{xAlign:n.xAlign||t.xAlign||nMe(e,t,n,r),yAlign:r}}function rMe(e,t){let{x:n,width:r}=e;return t==="right"?n-=r:t==="center"&&(n-=r/2),n}function iMe(e,t,n){let{y:r,height:i}=e;return t==="top"?r+=n:t==="bottom"?r-=i+n:r-=i/2,r}function Z6(e,t,n,r){let{caretSize:i,caretPadding:o,cornerRadius:s}=e,{xAlign:a,yAlign:l}=n,u=i+o,{topLeft:c,topRight:d,bottomLeft:h,bottomRight:f}=qd(s),p=rMe(t,a),m=iMe(t,l,u);return l==="center"?a==="left"?p+=u:a==="right"&&(p-=u):a==="left"?p-=Math.max(c,h)+i:a==="right"&&(p+=Math.max(d,f)+i),{x:si(p,0,r.width-t.width),y:si(m,0,r.height-t.height)}}function tC(e,t,n){let r=qi(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-r.right:e.x+r.left}function eH(e){return Vl([],uc(e))}function oMe(e,t,n){return ac(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function tH(e,t){let n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}var TH={beforeTitle:Fl,title(e){if(e.length>0){let t=e[0],n=t.chart.data.labels,r=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(r>0&&t.dataIndex<r)return n[t.dataIndex]}return""},afterTitle:Fl,beforeBody:Fl,beforeLabel:Fl,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");let n=e.formattedValue;return Rt(n)||(t+=n),t},labelColor(e){let n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){let n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:Fl,afterBody:Fl,beforeFooter:Fl,footer:Fl,afterFooter:Fl};function Vo(e,t,n,r){let i=e[t].call(n,r);return typeof i>"u"?TH[t].call(n,r):i}var hC=class extends Qa{static positioners=Mb;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){let t=this._cachedAnimations;if(t)return t;let n=this.chart,r=this.options.setContext(this.getContext()),i=r.enabled&&n.options.animation&&r.animations,o=new oC(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=oMe(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){let{callbacks:r}=n,i=Vo(r,"beforeTitle",this,t),o=Vo(r,"title",this,t),s=Vo(r,"afterTitle",this,t),a=[];return a=Vl(a,uc(i)),a=Vl(a,uc(o)),a=Vl(a,uc(s)),a}getBeforeBody(t,n){return eH(Vo(n.callbacks,"beforeBody",this,t))}getBody(t,n){let{callbacks:r}=n,i=[];return cn(t,o=>{let s={before:[],lines:[],after:[]},a=tH(r,o);Vl(s.before,uc(Vo(a,"beforeLabel",this,o))),Vl(s.lines,Vo(a,"label",this,o)),Vl(s.after,uc(Vo(a,"afterLabel",this,o))),i.push(s)}),i}getAfterBody(t,n){return eH(Vo(n.callbacks,"afterBody",this,t))}getFooter(t,n){let{callbacks:r}=n,i=Vo(r,"beforeFooter",this,t),o=Vo(r,"footer",this,t),s=Vo(r,"afterFooter",this,t),a=[];return a=Vl(a,uc(i)),a=Vl(a,uc(o)),a=Vl(a,uc(s)),a}_createItems(t){let n=this._active,r=this.chart.data,i=[],o=[],s=[],a=[],l,u;for(l=0,u=n.length;l<u;++l)a.push(ZNe(this.chart,n[l]));return t.filter&&(a=a.filter((c,d,h)=>t.filter(c,d,h,r))),t.itemSort&&(a=a.sort((c,d)=>t.itemSort(c,d,r))),cn(a,c=>{let d=tH(t.callbacks,c);i.push(Vo(d,"labelColor",this,c)),o.push(Vo(d,"labelPointStyle",this,c)),s.push(Vo(d,"labelTextColor",this,c))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=s,this.dataPoints=a,a}update(t,n){let r=this.options.setContext(this.getContext()),i=this._active,o,s=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{let a=Mb[r.position].call(this,i,this._eventPosition);s=this._createItems(r),this.title=this.getTitle(s,r),this.beforeBody=this.getBeforeBody(s,r),this.body=this.getBody(s,r),this.afterBody=this.getAfterBody(s,r),this.footer=this.getFooter(s,r);let l=this._size=X6(this,r),u=Object.assign({},a,l),c=J6(this.chart,r,u),d=Z6(r,u,c,this.chart);this.xAlign=c.xAlign,this.yAlign=c.yAlign,o={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=s,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&r.external&&r.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,r,i){let o=this.getCaretPosition(t,r,i);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,r){let{xAlign:i,yAlign:o}=this,{caretSize:s,cornerRadius:a}=r,{topLeft:l,topRight:u,bottomLeft:c,bottomRight:d}=qd(a),{x:h,y:f}=t,{width:p,height:m}=n,g,y,v,b,w,x;return o==="center"?(w=f+m/2,i==="left"?(g=h,y=g-s,b=w+s,x=w-s):(g=h+p,y=g+s,b=w-s,x=w+s),v=g):(i==="left"?y=h+Math.max(l,c)+s:i==="right"?y=h+p-Math.max(u,d)-s:y=this.caretX,o==="top"?(b=f,w=b-s,g=y-s,v=y+s):(b=f+m,w=b+s,g=y+s,v=y-s),x=b),{x1:g,x2:y,x3:v,y1:b,y2:w,y3:x}}drawTitle(t,n,r){let i=this.title,o=i.length,s,a,l;if(o){let u=np(r.rtl,this.x,this.width);for(t.x=tC(this,r.titleAlign,r),n.textAlign=u.textAlign(r.titleAlign),n.textBaseline="middle",s=Vr(r.titleFont),a=r.titleSpacing,n.fillStyle=r.titleColor,n.font=s.string,l=0;l<o;++l)n.fillText(i[l],u.x(t.x),t.y+s.lineHeight/2),t.y+=s.lineHeight+a,l+1===o&&(t.y+=r.titleMarginBottom-a)}}_drawColorBox(t,n,r,i,o){let s=this.labelColors[r],a=this.labelPointStyles[r],{boxHeight:l,boxWidth:u}=o,c=Vr(o.bodyFont),d=tC(this,"left",o),h=i.x(d),f=l<c.lineHeight?(c.lineHeight-l)/2:0,p=n.y+f;if(o.usePointStyle){let m={radius:Math.min(u,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},g=i.leftForLtr(h,u)+u/2,y=p+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,Hk(t,m,g,y),t.strokeStyle=s.borderColor,t.fillStyle=s.backgroundColor,Hk(t,m,g,y)}else{t.lineWidth=Bt(s.borderWidth)?Math.max(...Object.values(s.borderWidth)):s.borderWidth||1,t.strokeStyle=s.borderColor,t.setLineDash(s.borderDash||[]),t.lineDashOffset=s.borderDashOffset||0;let m=i.leftForLtr(h,u),g=i.leftForLtr(i.xPlus(h,1),u-2),y=qd(s.borderRadius);Object.values(y).some(v=>v!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Rg(t,{x:m,y:p,w:u,h:l,radius:y}),t.fill(),t.stroke(),t.fillStyle=s.backgroundColor,t.beginPath(),Rg(t,{x:g,y:p+1,w:u-2,h:l-2,radius:y}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(m,p,u,l),t.strokeRect(m,p,u,l),t.fillStyle=s.backgroundColor,t.fillRect(g,p+1,u-2,l-2))}t.fillStyle=this.labelTextColors[r]}drawBody(t,n,r){let{body:i}=this,{bodySpacing:o,bodyAlign:s,displayColors:a,boxHeight:l,boxWidth:u,boxPadding:c}=r,d=Vr(r.bodyFont),h=d.lineHeight,f=0,p=np(r.rtl,this.x,this.width),m=function(C){n.fillText(C,p.x(t.x+f),t.y+h/2),t.y+=h+o},g=p.textAlign(s),y,v,b,w,x,S,k;for(n.textAlign=s,n.textBaseline="middle",n.font=d.string,t.x=tC(this,g,r),n.fillStyle=r.bodyColor,cn(this.beforeBody,m),f=a&&g!=="right"?s==="center"?u/2+c:u+2+c:0,w=0,S=i.length;w<S;++w){for(y=i[w],v=this.labelTextColors[w],n.fillStyle=v,cn(y.before,m),b=y.lines,a&&b.length&&(this._drawColorBox(n,t,w,p,r),h=Math.max(d.lineHeight,l)),x=0,k=b.length;x<k;++x)m(b[x]),h=d.lineHeight;cn(y.after,m)}f=0,h=d.lineHeight,cn(this.afterBody,m),t.y-=o}drawFooter(t,n,r){let i=this.footer,o=i.length,s,a;if(o){let l=np(r.rtl,this.x,this.width);for(t.x=tC(this,r.footerAlign,r),t.y+=r.footerMarginTop,n.textAlign=l.textAlign(r.footerAlign),n.textBaseline="middle",s=Vr(r.footerFont),n.fillStyle=r.footerColor,n.font=s.string,a=0;a<o;++a)n.fillText(i[a],l.x(t.x),t.y+s.lineHeight/2),t.y+=s.lineHeight+r.footerSpacing}}drawBackground(t,n,r,i){let{xAlign:o,yAlign:s}=this,{x:a,y:l}=t,{width:u,height:c}=r,{topLeft:d,topRight:h,bottomLeft:f,bottomRight:p}=qd(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+d,l),s==="top"&&this.drawCaret(t,n,r,i),n.lineTo(a+u-h,l),n.quadraticCurveTo(a+u,l,a+u,l+h),s==="center"&&o==="right"&&this.drawCaret(t,n,r,i),n.lineTo(a+u,l+c-p),n.quadraticCurveTo(a+u,l+c,a+u-p,l+c),s==="bottom"&&this.drawCaret(t,n,r,i),n.lineTo(a+f,l+c),n.quadraticCurveTo(a,l+c,a,l+c-f),s==="center"&&o==="left"&&this.drawCaret(t,n,r,i),n.lineTo(a,l+d),n.quadraticCurveTo(a,l,a+d,l),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){let n=this.chart,r=this.$animations,i=r&&r.x,o=r&&r.y;if(i||o){let s=Mb[t.position].call(this,this._active,this._eventPosition);if(!s)return;let a=this._size=X6(this,t),l=Object.assign({},s,this._size),u=J6(n,t,l),c=Z6(t,l,u,n);(i._to!==c.x||o._to!==c.y)&&(this.xAlign=u.xAlign,this.yAlign=u.yAlign,this.width=a.width,this.height=a.height,this.caretX=s.x,this.caretY=s.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(t){let n=this.options.setContext(this.getContext()),r=this.opacity;if(!r)return;this._updateAnimationTarget(n);let i={width:this.width,height:this.height},o={x:this.x,y:this.y};r=Math.abs(r)<.001?0:r;let s=qi(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=r,this.drawBackground(o,t,i,n),BD(t,n.textDirection),o.y+=s.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),qD(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){let r=this._active,i=t.map(({datasetIndex:a,index:l})=>{let u=this.chart.getDatasetMeta(a);if(!u)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:u.data[l],index:l}}),o=!gb(r,i),s=this._positionChanged(i,n);(o||s)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,r=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;let i=this.options,o=this._active||[],s=this._getActiveElements(t,o,n,r),a=this._positionChanged(s,t),l=n||!gb(s,o)||a;return l&&(this._active=s,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,r,i){let o=this.options;if(t.type==="mouseout")return[];if(!i)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);let s=this.chart.getElementsAtEventForMode(t,o.mode,o,r);return o.reverse&&s.reverse(),s}_positionChanged(t,n){let{caretX:r,caretY:i,options:o}=this,s=Mb[o.position].call(this,t,n);return s!==!1&&(r!==s.x||i!==s.y)}},sMe={id:"tooltip",_element:hC,positioners:Mb,afterInit(e,t,n){n&&(e.tooltip=new hC({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){let t=e.tooltip;if(t&&t._willRender()){let n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){let n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:TH},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},aMe=Object.freeze({__proto__:null,Colors:_2,Decimation:kNe,Filler:WNe,Legend:QNe,SubTitle:JNe,Title:XNe,Tooltip:sMe}),lMe=(e,t,n,r)=>(typeof t=="string"?(n=e.push(t)-1,r.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function uMe(e,t,n,r){let i=e.indexOf(t);if(i===-1)return lMe(e,t,n,r);let o=e.lastIndexOf(t);return i!==o?n:i}var cMe=(e,t)=>e===null?null:si(Math.round(e),0,t);function nH(e){let t=this.getLabels();return e>=0&&e<t.length?t[e]:e}var x2=class extends op{static id="category";static defaults={ticks:{callback:nH}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){let n=this._addedLabels;if(n.length){let r=this.getLabels();for(let{index:i,label:o}of n)r[i]===o&&r.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(Rt(t))return null;let r=this.getLabels();return n=isFinite(n)&&r[n]===t?n:uMe(r,t,ht(n,t),this._addedLabels),cMe(n,r.length-1)}determineDataLimits(){let{minDefined:t,maxDefined:n}=this.getUserBounds(),{min:r,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(r=0),n||(i=this.getLabels().length-1)),this.min=r,this.max=i}buildTicks(){let t=this.min,n=this.max,r=this.options.offset,i=[],o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(r?0:1),1),this._startValue=this.min-(r?.5:0);for(let s=t;s<=n;s++)i.push({value:s});return i}getLabelForValue(t){return nH.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){let n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}};function dMe(e,t){let n=[],{bounds:i,step:o,min:s,max:a,precision:l,count:u,maxTicks:c,maxDigits:d,includeBounds:h}=e,f=o||1,p=c-1,{min:m,max:g}=t,y=!Rt(s),v=!Rt(a),b=!Rt(u),w=(g-m)/(d+1),x=gD((g-m)/p/f)*f,S,k,C,N;if(x<1e-14&&!y&&!v)return[{value:m},{value:g}];N=Math.ceil(g/x)-Math.floor(m/x),N>p&&(x=gD(N*x/p/f)*f),Rt(l)||(S=Math.pow(10,l),x=Math.ceil(x*S)/S),i==="ticks"?(k=Math.floor(m/x)*x,C=Math.ceil(g/x)*x):(k=m,C=g),y&&v&&o&&WU((a-s)/o,x/1e3)?(N=Math.round(Math.min((a-s)/x,c)),x=(a-s)/N,k=s,C=a):b?(k=y?s:k,C=v?a:C,N=u-1,x=(C-k)/N):(N=(C-k)/x,Tg(N,Math.round(N),x/1e3)?N=Math.round(N):N=Math.ceil(N));let E=Math.max(vD(x),vD(k));S=Math.pow(10,Rt(l)?E:l),k=Math.round(k*S)/S,C=Math.round(C*S)/S;let D=0;for(y&&(h&&k!==s?(n.push({value:s}),k<s&&D++,Tg(Math.round((k+D*x)*S)/S,s,rH(s,w,e))&&D++):k<s&&D++);D<N;++D){let q=Math.round((k+D*x)*S)/S;if(v&&q>a)break;n.push({value:q})}return v&&h&&C!==a?n.length&&Tg(n[n.length-1].value,a,rH(a,w,e))?n[n.length-1].value=a:n.push({value:a}):(!v||C===a)&&n.push({value:C}),n}function rH(e,t,{horizontal:n,minRotation:r}){let i=oa(r),o=(n?Math.sin(i):Math.cos(i))||.001,s=.75*t*(""+e).length;return Math.min(t/o,s)}var qg=class extends op{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return Rt(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){let{beginAtZero:t}=this.options,{minDefined:n,maxDefined:r}=this.getUserBounds(),{min:i,max:o}=this,s=l=>i=n?i:l,a=l=>o=r?o:l;if(t){let l=Ya(i),u=Ya(o);l<0&&u<0?a(0):l>0&&u>0&&s(0)}if(i===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||s(i-l)}this.min=i,this.max=o}getTickLimit(){let t=this.options.ticks,{maxTicksLimit:n,stepSize:r}=t,i;return r?(i=Math.ceil(this.max/r)-Math.floor(this.min/r)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${r} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){let t=this.options,n=t.ticks,r=this.getTickLimit();r=Math.max(2,r);let i={maxTicks:r,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,s=dMe(i,o);return t.bounds==="ticks"&&yD(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}configure(){let t=this.ticks,n=this.min,r=this.max;if(super.configure(),this.options.offset&&t.length){let i=(r-n)/Math.max(t.length-1,1)/2;n-=i,r+=i}this._startValue=n,this._endValue=r,this._valueRange=r-n}getLabelForValue(t){return Dg(t,this.chart.options.locale,this.options.ticks.format)}},S2=class extends qg{static id="linear";static defaults={ticks:{callback:yb.formatters.numeric}};determineDataLimits(){let{min:t,max:n}=this.getMinMax(!0);this.min=fr(t)?t:0,this.max=fr(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){let t=this.isHorizontal(),n=t?this.width:this.height,r=oa(this.options.ticks.minRotation),i=(t?Math.sin(r):Math.cos(r))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}},Tb=e=>Math.floor(oc(e)),ip=(e,t)=>Math.pow(10,Tb(e)+t);function iH(e){return e/Math.pow(10,Tb(e))===1}function oH(e,t,n){let r=Math.pow(10,n),i=Math.floor(e/r);return Math.ceil(t/r)-i}function hMe(e,t){let n=t-e,r=Tb(n);for(;oH(e,t,r)>10;)r++;for(;oH(e,t,r)<10;)r--;return Math.min(r,Tb(e))}function fMe(e,{min:t,max:n}){t=jo(e.min,t);let r=[],i=Tb(t),o=hMe(t,n),s=o<0?Math.pow(10,Math.abs(o)):1,a=Math.pow(10,o),l=i>o?Math.pow(10,i):0,u=Math.round((t-l)*s)/s,c=Math.floor((t-l)/a/10)*a*10,d=Math.floor((u-c)/Math.pow(10,o)),h=jo(e.min,Math.round((l+c+d*Math.pow(10,o))*s)/s);for(;h<n;)r.push({value:h,major:iH(h),significand:d}),d>=10?d=d<15?15:20:d++,d>=20&&(o++,d=2,s=o>=0?1:s),h=Math.round((l+c+d*Math.pow(10,o))*s)/s;let f=jo(e.max,h);return r.push({value:f,major:iH(f),significand:d}),r}var k2=class extends op{static id="logarithmic";static defaults={ticks:{callback:yb.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){let r=qg.prototype.parse.apply(this,[t,n]);if(r===0){this._zero=!0;return}return fr(r)&&r>0?r:null}determineDataLimits(){let{min:t,max:n}=this.getMinMax(!0);this.min=fr(t)?Math.max(0,t):null,this.max=fr(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!fr(this._userMin)&&(this.min=t===ip(this.min,0)?ip(this.min,-1):ip(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){let{minDefined:t,maxDefined:n}=this.getUserBounds(),r=this.min,i=this.max,o=a=>r=t?r:a,s=a=>i=n?i:a;r===i&&(r<=0?(o(1),s(10)):(o(ip(r,-1)),s(ip(i,1)))),r<=0&&o(ip(i,-1)),i<=0&&s(ip(r,1)),this.min=r,this.max=i}buildTicks(){let t=this.options,n={min:this._userMin,max:this._userMax},r=fMe(n,this);return t.bounds==="ticks"&&yD(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}getLabelForValue(t){return t===void 0?"0":Dg(t,this.chart.options.locale,this.options.ticks.format)}configure(){let t=this.min;super.configure(),this._startValue=oc(t),this._valueRange=oc(this.max)-oc(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(oc(t)-this._startValue)/this._valueRange)}getValueForPixel(t){let n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}};function C2(e){let t=e.ticks;if(t.display&&e.display){let n=qi(t.backdropPadding);return ht(t.font&&t.font.size,Kn.font.size)+n.height}return 0}function pMe(e,t,n){return n=Ln(n)?n:[n],{w:JU(e,t.string,n),h:n.length*t.lineHeight}}function sH(e,t,n,r,i){return e===r||e===i?{start:t-n/2,end:t+n/2}:e<r||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function mMe(e){let t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),r=[],i=[],o=e._pointLabels.length,s=e.options.pointLabels,a=s.centerPointLabels?Gt/o:0;for(let l=0;l<o;l++){let u=s.setContext(e.getPointLabelContext(l));i[l]=u.padding;let c=e.getPointPosition(l,e.drawingArea+i[l],a),d=Vr(u.font),h=pMe(e.ctx,d,e._pointLabels[l]);r[l]=h;let f=Li(e.getIndexAngle(l)+a),p=Math.round(jk(f)),m=sH(p,c.x,h.w,0,180),g=sH(p,c.y,h.h,90,270);gMe(n,t,f,m,g)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=bMe(e,r,i)}function gMe(e,t,n,r,i){let o=Math.abs(Math.sin(n)),s=Math.abs(Math.cos(n)),a=0,l=0;r.start<t.l?(a=(t.l-r.start)/o,e.l=Math.min(e.l,t.l-a)):r.end>t.r&&(a=(r.end-t.r)/o,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(l=(t.t-i.start)/s,e.t=Math.min(e.t,t.t-l)):i.end>t.b&&(l=(i.end-t.b)/s,e.b=Math.max(e.b,t.b+l))}function yMe(e,t,n){let r=e.drawingArea,{extra:i,additionalAngle:o,padding:s,size:a}=n,l=e.getPointPosition(t,r+i+s,o),u=Math.round(jk(Li(l.angle+Sr))),c=SMe(l.y,a.h,u),d=wMe(u),h=xMe(l.x,a.w,d);return{visible:!0,x:l.x,y:c,textAlign:d,left:h,top:c,right:h+a.w,bottom:c+a.h}}function vMe(e,t){if(!t)return!0;let{left:n,top:r,right:i,bottom:o}=e;return!(zl({x:n,y:r},t)||zl({x:n,y:o},t)||zl({x:i,y:r},t)||zl({x:i,y:o},t))}function bMe(e,t,n){let r=[],i=e._pointLabels.length,o=e.options,{centerPointLabels:s,display:a}=o.pointLabels,l={extra:C2(o)/2,additionalAngle:s?Gt/i:0},u;for(let c=0;c<i;c++){l.padding=n[c],l.size=t[c];let d=yMe(e,c,l);r.push(d),a==="auto"&&(d.visible=vMe(d,u),d.visible&&(u=d))}return r}function wMe(e){return e===0||e===180?"center":e<180?"left":"right"}function xMe(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function SMe(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function kMe(e,t,n){let{left:r,top:i,right:o,bottom:s}=n,{backdropColor:a}=t;if(!Rt(a)){let l=qd(t.borderRadius),u=qi(t.backdropPadding);e.fillStyle=a;let c=r-u.left,d=i-u.top,h=o-r+u.width,f=s-i+u.height;Object.values(l).some(p=>p!==0)?(e.beginPath(),Rg(e,{x:c,y:d,w:h,h:f,radius:l}),e.fill()):e.fillRect(c,d,h,f)}}function CMe(e,t){let{ctx:n,options:{pointLabels:r}}=e;for(let i=t-1;i>=0;i--){let o=e._pointLabelItems[i];if(!o.visible)continue;let s=r.setContext(e.getPointLabelContext(i));kMe(n,s,o);let a=Vr(s.font),{x:l,y:u,textAlign:c}=o;Bd(n,e._pointLabels[i],l,u+a.lineHeight/2,a,{color:s.color,textAlign:c,textBaseline:"middle"})}}function AH(e,t,n,r){let{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,Bn);else{let o=e.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let s=1;s<r;s++)o=e.getPointPosition(s,t),i.lineTo(o.x,o.y)}}function NMe(e,t,n,r,i){let o=e.ctx,s=t.circular,{color:a,lineWidth:l}=t;!s&&!r||!a||!l||n<0||(o.save(),o.strokeStyle=a,o.lineWidth=l,o.setLineDash(i.dash||[]),o.lineDashOffset=i.dashOffset,o.beginPath(),AH(e,n,s,r),o.closePath(),o.stroke(),o.restore())}function MMe(e,t,n){return ac(e,{label:n,index:t,type:"pointLabel"})}var N2=class extends qg{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:yb.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){let t=this._padding=qi(C2(this.options)/2),n=this.width=this.maxWidth-t.width,r=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+r/2+t.top),this.drawingArea=Math.floor(Math.min(n,r)/2)}determineDataLimits(){let{min:t,max:n}=this.getMinMax(!1);this.min=fr(t)&&!isNaN(t)?t:0,this.max=fr(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/C2(this.options))}generateTickLabels(t){qg.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,r)=>{let i=Mn(this.options.pointLabels.callback,[n,r],this);return i||i===0?i:""}).filter((n,r)=>this.chart.getDataVisibility(r))}fit(){let t=this.options;t.display&&t.pointLabels.display?mMe(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,r,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((r-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,r,i))}getIndexAngle(t){let n=Bn/(this._pointLabels.length||1),r=this.options.startAngle||0;return Li(t*n+oa(r))}getDistanceFromCenterForValue(t){if(Rt(t))return NaN;let n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(Rt(t))return NaN;let n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){let n=this._pointLabels||[];if(t>=0&&t<n.length){let r=n[t];return MMe(this.getContext(),t,r)}}getPointPosition(t,n,r=0){let i=this.getIndexAngle(t)-Sr+r;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){let{left:n,top:r,right:i,bottom:o}=this._pointLabelItems[t];return{left:n,top:r,right:i,bottom:o}}drawBackground(){let{backgroundColor:t,grid:{circular:n}}=this.options;if(t){let r=this.ctx;r.save(),r.beginPath(),AH(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),r.closePath(),r.fillStyle=t,r.fill(),r.restore()}}drawGrid(){let t=this.ctx,n=this.options,{angleLines:r,grid:i,border:o}=n,s=this._pointLabels.length,a,l,u;if(n.pointLabels.display&&CMe(this,s),i.display&&this.ticks.forEach((c,d)=>{if(d!==0||d===0&&this.min<0){l=this.getDistanceFromCenterForValue(c.value);let h=this.getContext(d),f=i.setContext(h),p=o.setContext(h);NMe(this,f,l,s,p)}}),r.display){for(t.save(),a=s-1;a>=0;a--){let c=r.setContext(this.getPointLabelContext(a)),{color:d,lineWidth:h}=c;!h||!d||(t.lineWidth=h,t.strokeStyle=d,t.setLineDash(c.borderDash),t.lineDashOffset=c.borderDashOffset,l=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),u=this.getPointPosition(a,l),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(u.x,u.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){let t=this.ctx,n=this.options,r=n.ticks;if(!r.display)return;let i=this.getIndexAngle(0),o,s;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,l)=>{if(l===0&&this.min>=0&&!n.reverse)return;let u=r.setContext(this.getContext(l)),c=Vr(u.font);if(o=this.getDistanceFromCenterForValue(this.ticks[l].value),u.showLabelBackdrop){t.font=c.string,s=t.measureText(a.label).width,t.fillStyle=u.backdropColor;let d=qi(u.backdropPadding);t.fillRect(-s/2-d.left,-o-c.size/2-d.top,s+d.width,c.size+d.height)}Bd(t,a.label,0,-o,c,{color:u.color,strokeColor:u.textStrokeColor,strokeWidth:u.textStrokeWidth})}),t.restore()}drawTitle(){}},pC={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},Wo=Object.keys(pC);function aH(e,t){return e-t}function lH(e,t){if(Rt(t))return null;let n=e._adapter,{parser:r,round:i,isoWeekday:o}=e._parseOpts,s=t;return typeof r=="function"&&(s=r(s)),fr(s)||(s=typeof r=="string"?n.parse(s,r):n.parse(s)),s===null?null:(i&&(s=i==="week"&&(tp(o)||o===!0)?n.startOf(s,"isoWeek",o):n.startOf(s,i)),+s)}function uH(e,t,n,r){let i=Wo.length;for(let o=Wo.indexOf(e);o<i-1;++o){let s=pC[Wo[o]],a=s.steps?s.steps:Number.MAX_SAFE_INTEGER;if(s.common&&Math.ceil((n-t)/(a*s.size))<=r)return Wo[o]}return Wo[i-1]}function _Me(e,t,n,r,i){for(let o=Wo.length-1;o>=Wo.indexOf(n);o--){let s=Wo[o];if(pC[s].common&&e._adapter.diff(i,r,s)>=t-1)return s}return Wo[n?Wo.indexOf(n):0]}function EMe(e){for(let t=Wo.indexOf(e)+1,n=Wo.length;t<n;++t)if(pC[Wo[t]].common)return Wo[t]}function cH(e,t,n){if(!n)e[t]=!0;else if(n.length){let{lo:r,hi:i}=Vk(n,t),o=n[r]>=t?n[r]:n[i];e[o]=!0}}function OMe(e,t,n,r){let i=e._adapter,o=+i.startOf(t[0].value,r),s=t[t.length-1].value,a,l;for(a=o;a<=s;a=+i.add(a,1,r))l=n[a],l>=0&&(t[l].major=!0);return t}function dH(e,t,n){let r=[],i={},o=t.length,s,a;for(s=0;s<o;++s)a=t[s],i[a]=s,r.push({value:a,major:!1});return o===0||!n?r:OMe(e,r,i,n)}var Ab=class extends op{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){let r=t.time||(t.time={}),i=this._adapter=new Wke._date(t.adapters.date);i.init(n),Eg(r.displayFormats,i.formats()),this._parseOpts={parser:r.parser,round:r.round,isoWeekday:r.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:lH(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){let t=this.options,n=this._adapter,r=t.time.unit||"day",{min:i,max:o,minDefined:s,maxDefined:a}=this.getUserBounds();function l(u){!s&&!isNaN(u.min)&&(i=Math.min(i,u.min)),!a&&!isNaN(u.max)&&(o=Math.max(o,u.max))}(!s||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),i=fr(i)&&!isNaN(i)?i:+n.startOf(Date.now(),r),o=fr(o)&&!isNaN(o)?o:+n.endOf(Date.now(),r)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){let t=this.getLabelTimestamps(),n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],r=t[t.length-1]),{min:n,max:r}}buildTicks(){let t=this.options,n=t.time,r=t.ticks,i=r.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);let o=this.min,s=this.max,a=$U(i,o,s);return this._unit=n.unit||(r.autoSkip?uH(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):_Me(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!r.major.enabled||this._unit==="year"?void 0:EMe(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),dH(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,r=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?r=o:r=(o-this.getDecimalForValue(t[t.length-2]))/2);let s=t.length<3?.5:.25;n=si(n,0,s),r=si(r,0,s),this._offsets={start:n,end:r,factor:1/(n+1+r)}}_generate(){let t=this._adapter,n=this.min,r=this.max,i=this.options,o=i.time,s=o.unit||uH(o.minUnit,n,r,this._getLabelCapacity(n)),a=ht(i.ticks.stepSize,1),l=s==="week"?o.isoWeekday:!1,u=tp(l)||l===!0,c={},d=n,h,f;if(u&&(d=+t.startOf(d,"isoWeek",l)),d=+t.startOf(d,u?"day":s),t.diff(r,n,s)>1e5*a)throw new Error(n+" and "+r+" are too far apart with stepSize of "+a+" "+s);let p=i.ticks.source==="data"&&this.getDataTimestamps();for(h=d,f=0;h<r;h=+t.add(h,a,s),f++)cH(c,h,p);return(h===r||i.bounds==="ticks"||f===1)&&cH(c,h,p),Object.keys(c).sort(aH).map(m=>+m)}getLabelForValue(t){let n=this._adapter,r=this.options.time;return r.tooltipFormat?n.format(t,r.tooltipFormat):n.format(t,r.displayFormats.datetime)}format(t,n){let i=this.options.time.displayFormats,o=this._unit,s=n||i[o];return this._adapter.format(t,s)}_tickFormatFunction(t,n,r,i){let o=this.options,s=o.ticks.callback;if(s)return Mn(s,[t,n,r],this);let a=o.time.displayFormats,l=this._unit,u=this._majorUnit,c=l&&a[l],d=u&&a[u],h=r[n],f=u&&d&&h&&h.major;return this._adapter.format(t,i||(f?d:c))}generateTickLabels(t){let n,r,i;for(n=0,r=t.length;n<r;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){let n=this._offsets,r=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+r)*n.factor)}getValueForPixel(t){let n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+r*(this.max-this.min)}_getLabelSize(t){let n=this.options.ticks,r=this.ctx.measureText(t).width,i=oa(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(i),s=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:r*o+a*s,h:r*s+a*o}}_getLabelCapacity(t){let n=this.options.time,r=n.displayFormats,i=r[n.unit]||r.millisecond,o=this._tickFormatFunction(t,0,dH(this,[t],this._majorUnit),i),s=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/s.w:this.height/s.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,r;if(t.length)return t;let i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,r=i.length;n<r;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){let t=this._cache.labels||[],n,r;if(t.length)return t;let i=this.getLabels();for(n=0,r=i.length;n<r;++n)t.push(lH(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return xD(t.sort(aH))}};function nC(e,t,n){let r=0,i=e.length-1,o,s,a,l;n?(t>=e[r].pos&&t<=e[i].pos&&({lo:r,hi:i}=ql(e,"pos",t)),{pos:o,time:a}=e[r],{pos:s,time:l}=e[i]):(t>=e[r].time&&t<=e[i].time&&({lo:r,hi:i}=ql(e,"time",t)),{time:o,pos:a}=e[r],{time:s,pos:l}=e[i]);let u=s-o;return u?a+(l-a)*(t-o)/u:a}var M2=class extends Ab{static id="timeseries";static defaults=Ab.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){let t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=nC(n,this.min),this._tableRange=nC(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){let{min:n,max:r}=this,i=[],o=[],s,a,l,u,c;for(s=0,a=t.length;s<a;++s)u=t[s],u>=n&&u<=r&&i.push(u);if(i.length<2)return[{time:n,pos:0},{time:r,pos:1}];for(s=0,a=i.length;s<a;++s)c=i[s+1],l=i[s-1],u=i[s],Math.round((c+l)/2)!==u&&o.push({time:u,pos:s/(a-1)});return o}_generate(){let t=this.min,n=this.max,r=super.getDataTimestamps();return(!r.includes(t)||!r.length)&&r.splice(0,0,t),(!r.includes(n)||r.length===1)&&r.push(n),r.sort((i,o)=>i-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;let n=this.getDataTimestamps(),r=this.getLabelTimestamps();return n.length&&r.length?t=this.normalize(n.concat(r)):t=n.length?n:r,t=this._cache.all=t,t}getDecimalForValue(t){return(nC(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){let n=this._offsets,r=this.getDecimalForPixel(t)/n.factor-n.end;return nC(this._table,r*this._tableRange+this._minPos,!0)}},TMe=Object.freeze({__proto__:null,CategoryScale:x2,LinearScale:S2,LogarithmicScale:k2,RadialLinearScale:N2,TimeScale:Ab,TimeSeriesScale:M2}),DH=[Vke,fNe,aMe,TMe];jd.register(...DH);var fq=L(le(),1),Et=L(le(),1),Ne=L(H(),1),Xde=L(rn(),1),zs=L(H(),1),Do=L(le(),1),xm=L(H(),1),Io=L(le(),1),yc=L(H(),1),Rs=L(H(),1),jv=L(H(),1),Nhe=L(H(),1),dO=L(H(),1),gu=L(H(),1),tx=L(le(),1),Ehe=L(H(),1),sr=L(H(),1),Xr=L(le(),1),ir=L(H(),1),jp=L(le(),1),ru=L(le(),1),Po=L(H(),1),Ls=L(le(),1),Zhe=L(H(),1),Wy=L(le(),1),ha=L(le(),1),Vp=L(le(),1),hv=L(H(),1),vfe=L(H(),1),bfe=L(H(),1),ay=L(H(),1),wfe=L(H(),1),pM=L(H(),1),ly=L(H(),1),xfe=L(H(),1),Sfe=L(H(),1),kfe=L(H(),1),Cfe=L(H(),1),Nfe=L(H(),1),Mfe=L(H(),1),_fe=L(H(),1),yO=L(H(),1),kc=L(H(),1),Ofe=L(H(),1),Tfe=L(H(),1),Afe=L(H(),1),Dfe=L(H(),1),Rfe=L(H(),1),Ife=L(H(),1),Pfe=L(H(),1),bq=L(H(),1),Lfe=L(H(),1),Bfe=L(H(),1),qfe=L(H(),1),zfe=L(H(),1),at=L(H(),1),Uy=L(H(),1),bO=L(H(),1),tpe=L(H(),1),wq=L(H(),1),rpe=L(le(),1),pr=L(le(),1),Es=L(le(),1),ope=L(H(),1),Hy=L(le(),1),Wp=L(le(),1),Yx=L(le(),1),spe=L(H(),1),gh=L(le(),1),Jd=L(le(),1),ut=L(H(),1),lpe=L(H(),1),mM=L(le(),1),fe=L(le(),1),wpe=L(H(),1),xpe=L(rn(),1),to=L(le(),1),Is=L(H(),1),qe=L(le(),1),Cpe=L(le(),1),ci=L(le(),1);var uG=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.rfcBase32=e.uuid25Base36=e.flickrBase58=e.cookieBase90=void 0,e.cookieBase90="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&'()*+-./:<=>?@[]^_`{|}~",e.flickrBase58="123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",e.uuid25Base36="0123456789abcdefghijklmnopqrstuvwxyz",e.rfcBase32="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",e.default={cookieBase90:e.cookieBase90,flickrBase58:e.flickrBase58,rfcBase32:e.rfcBase32,uuid25Base36:e.uuid25Base36}}),AMe=zr((e,t)=>{"use strict";function n(r,i){if(!r||!i||!r.length||!i.length)throw new Error("Bad alphabet");this.srcAlphabet=r,this.dstAlphabet=i}n.prototype.convert=function(r){var i,o,s,a={},l=this.srcAlphabet.length,u=this.dstAlphabet.length,c=r.length,d=typeof r=="string"?"":[];if(!this.isValid(r))throw new Error('Number "'+r+'" contains of non-alphabetic digits ('+this.srcAlphabet+")");if(this.srcAlphabet===this.dstAlphabet)return r;for(i=0;i<c;i++)a[i]=this.srcAlphabet.indexOf(r[i]);do{for(o=0,s=0,i=0;i<c;i++)o=o*l+a[i],o>=u?(a[s++]=parseInt(o/u,10),o=o%u):s>0&&(a[s++]=0);c=s,d=this.dstAlphabet.slice(o,o+1).concat(d)}while(s!==0);return d},n.prototype.isValid=function(r){for(var i=0;i<r.length;++i)if(this.srcAlphabet.indexOf(r[i])===-1)return!1;return!0},t.exports=n}),DMe=zr((e,t)=>{"use strict";var n=AMe();function r(i,o){var s=new n(i,o);return function(a){return s.convert(a)}}r.BIN="01",r.OCT="01234567",r.DEC="0123456789",r.HEX="0123456789abcdef",t.exports=r}),RMe=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0});var t=uG();e.default={consistentLength:!0,alphabet:t.flickrBase58,uuid:()=>globalThis.crypto?.randomUUID()}}),IMe=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.checkForDuplicates=e.calculateMaxLength=void 0;var t=r=>Math.ceil(128/Math.log2(r));e.calculateMaxLength=t;var n=r=>{let i=new Set(r);return r.length!==i.size};e.checkForDuplicates=n}),cG=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.shortenUUID=e.restoreUUID=void 0;var t=(r,i)=>r.hexFromAlphabet(i).padStart(32,"0").match(/(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})/)?.slice(1).join("-");e.restoreUUID=t;var n=(r,i)=>{let o=r.hexToAlphabet(i.toLowerCase().replace(/-/g,""));return r.consistentLength?o.padStart(r.maxLength,r.paddingCharacter):o};e.shortenUUID=n}),PMe=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isSubset=e.REGEX=void 0,e.validateUUID=n;var t=cG();e.REGEX=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function n(o){return typeof o=="string"&&e.REGEX.test(o)}var r=(o,s)=>{let a=new Set(o);return s.split("").every(l=>a.has(l))};e.isSubset=r;var i=o=>(s,a=!1)=>{if(!s||typeof s!="string")return!1;let l=o.consistentLength?s.length===o.maxLength:s.length<=o.maxLength,u=(0,e.isSubset)(o.alphabet,s);return l&&u&&(a?n((0,t.restoreUUID)(o,s)):!0)};e.default=i}),dG=zr(e=>{"use strict";var t=e&&e.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(e,"__esModule",{value:!0}),e.createTranslator=void 0;var n=t(DMe()),r=t(RMe()),i=IMe(),o=t(PMe()),s=cG(),a=(c={})=>{let d={...r.default,...c};if((0,i.checkForDuplicates)(d.alphabet))throw new Error("Alphabet contains duplicate characters.");let h={...d,maxLength:(0,i.calculateMaxLength)(d.alphabet.length),paddingCharacter:d.alphabet[0],hexFromAlphabet:(0,n.default)(d.alphabet,n.default.HEX),hexToAlphabet:(0,n.default)(n.default.HEX,d.alphabet)},f={alphabet:h.alphabet,fromUUID:p=>(0,s.shortenUUID)(h,p),generate:()=>(0,s.shortenUUID)(h,h.uuid()),maxLength:h.maxLength,toUUID:p=>(0,s.restoreUUID)(h,p),uuid:h.uuid,validate:(0,o.default)(h)};return Object.freeze(f),f},l=(c,d={})=>a({...d,alphabet:c}),u=(c,d)=>typeof c=="string"?l(c,d):a(c);e.createTranslator=u}),LMe=zr(e=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.generate=void 0;var t=dG(),n,r=()=>(n===void 0&&(n=(0,t.createTranslator)()),n.generate());e.generate=r}),BMe=zr(e=>{"use strict";var t=e&&e.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};Object.defineProperty(e,"__esModule",{value:!0}),e.generate=e.createTranslator=e.constants=void 0;var n=uG();Object.defineProperty(e,"constants",{enumerable:!0,get:function(){return t(n).default}});var r=dG();Object.defineProperty(e,"createTranslator",{enumerable:!0,get:function(){return r.createTranslator}});var i=LMe();Object.defineProperty(e,"generate",{enumerable:!0,get:function(){return i.generate}})}),qMe=zr(e=>{"use strict";(function(){function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}function n(p,m){d||o.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=m();if(!h){var y=m();s(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),h=!0)}y=a({inst:{value:g,getSnapshot:m}});var v=y[0].inst,b=y[1];return u(function(){v.value=g,v.getSnapshot=m,r(v)&&b({inst:v})},[p,g,m]),l(function(){return r(v)&&b({inst:v}),p(function(){r(v)&&b({inst:v})})},[p]),c(g),g}function r(p){var m=p.getSnapshot;p=p.value;try{var g=m();return!s(p,g)}catch{return!0}}function i(p,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=KS("react"),s=typeof Object.is=="function"?Object.is:t,a=o.useState,l=o.useEffect,u=o.useLayoutEffect,c=o.useDebugValue,d=!1,h=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?i:n;e.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()}),zMe=zr((e,t)=>{"use strict";t.exports=qMe()}),FMe=zr(e=>{"use strict";(function(){function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=KS("react"),r=zMe(),i=typeof Object.is=="function"?Object.is:t,o=r.useSyncExternalStore,s=n.useRef,a=n.useEffect,l=n.useMemo,u=n.useDebugValue;e.useSyncExternalStoreWithSelector=function(c,d,h,f,p){var m=s(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=l(function(){function v(k){if(!b){if(b=!0,w=k,k=f(k),p!==void 0&&g.hasValue){var C=g.value;if(p(C,k))return x=C}return x=k}if(C=x,i(w,k))return C;var N=f(k);return p!==void 0&&p(C,N)?(w=k,C):(w=k,x=N)}var b=!1,w,x,S=h===void 0?null:h;return[function(){return v(d())},S===null?void 0:function(){return v(S())}]},[d,h,f,p]);var y=o(c,m[0],m[1]);return a(function(){g.hasValue=!0,g.value=y},[y]),u(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()}),jMe=zr((e,t)=>{"use strict";t.exports=FMe()}),VMe=zr((e,t)=>{"use strict";(function(n,r){typeof e=="object"&&typeof t<"u"?t.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self).dayjs_plugin_localeData=r()})(e,function(){"use strict";return function(n,r,i){var o=r.prototype,s=function(d){return d&&(d.indexOf?d:d.s)},a=function(d,h,f,p,m){var g=d.name?d:d.$locale(),y=s(g[h]),v=s(g[f]),b=y||v.map(function(x){return x.slice(0,p)});if(!m)return b;var w=g.weekStart;return b.map(function(x,S){return b[(S+(w||0))%7]})},l=function(){return i.Ls[i.locale()]},u=function(d,h){return d.formats[h]||function(f){return f.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(p,m,g){return m||g.slice(1)})}(d.formats[h.toUpperCase()])},c=function(){var d=this;return{months:function(h){return h?h.format("MMMM"):a(d,"months")},monthsShort:function(h){return h?h.format("MMM"):a(d,"monthsShort","months",3)},firstDayOfWeek:function(){return d.$locale().weekStart||0},weekdays:function(h){return h?h.format("dddd"):a(d,"weekdays")},weekdaysMin:function(h){return h?h.format("dd"):a(d,"weekdaysMin","weekdays",2)},weekdaysShort:function(h){return h?h.format("ddd"):a(d,"weekdaysShort","weekdays",3)},longDateFormat:function(h){return u(d.$locale(),h)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return c.bind(this)()},i.localeData=function(){var d=l();return{firstDayOfWeek:function(){return d.weekStart||0},weekdays:function(){return i.weekdays()},weekdaysShort:function(){return i.weekdaysShort()},weekdaysMin:function(){return i.weekdaysMin()},months:function(){return i.months()},monthsShort:function(){return i.monthsShort()},longDateFormat:function(h){return u(d,h)},meridiem:d.meridiem,ordinal:d.ordinal}},i.months=function(){return a(l(),"months")},i.monthsShort=function(){return a(l(),"monthsShort","months",3)},i.weekdays=function(d){return a(l(),"weekdays",null,null,d)},i.weekdaysShort=function(d){return a(l(),"weekdaysShort","weekdays",3,d)},i.weekdaysMin=function(d){return a(l(),"weekdaysMin","weekdays",2,d)}}})}),WMe=zr((e,t)=>{"use strict";(function(n,r){typeof e=="object"&&typeof t<"u"?t.exports=r():typeof define=="function"&&define.amd?define(r):(n=typeof globalThis<"u"?globalThis:n||self).dayjs_plugin_localizedFormat=r()})(e,function(){"use strict";var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,i,o){var s=i.prototype,a=s.format;o.en.formats=n,s.format=function(l){l===void 0&&(l="YYYY-MM-DDTHH:mm:ssZ");var u=this.$locale().formats,c=function(d,h){return d.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(f,p,m){var g=m&&m.toUpperCase();return p||h[m]||n[m]||h[g].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(y,v,b){return v||b.slice(1)})})}(l,u===void 0?{}:u);return a.call(this,c)}}})}),xq=(0,hG.createContext)({});function Sq(e){let t=(0,fG.useRef)(null);return t.current===null&&(t.current=e()),t.current}var pG=typeof window<"u",mG=pG?D_.useLayoutEffect:D_.useEffect,R_=(0,yG.createContext)(null);function kq(e,t){e.indexOf(t)===-1&&e.push(t)}function gM(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var yu=(e,t,n)=>n>t?t:n<e?e:n;function qI(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var pv=()=>{},Oc=()=>{};typeof process<"u"&&(pv=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(qI(t,n))},Oc=(e,t,n)=>{if(!e)throw new Error(qI(t,n))});var Tc={},bG=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function wG(e){return typeof e=="object"&&e!==null}var xG=e=>/^0[^.\s]+$/u.test(e);function Cq(e){let t;return()=>(t===void 0&&(t=e()),t)}var xa=e=>e,UMe=(e,t)=>n=>t(e(n)),Qx=(...e)=>e.reduce(UMe),ix=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Nq=class{constructor(){this.subscriptions=[]}add(e){return kq(this.subscriptions,e),()=>gM(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let o=this.subscriptions[i];o&&o(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},Sa=e=>e*1e3,ya=e=>e/1e3;function SG(e,t){return t?e*(1e3/t):0}var RH=new Set;function Mq(e,t,n){e||RH.has(t)||(console.warn(qI(t,n)),RH.add(t))}var kG=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,HMe=1e-7,$Me=12;function KMe(e,t,n,r,i){let o,s,a=0;do s=t+(n-t)/2,o=kG(s,r,i)-e,o>0?n=s:t=s;while(Math.abs(o)>HMe&&++a<$Me);return s}function Gx(e,t,n,r){if(e===t&&n===r)return xa;let i=o=>KMe(o,0,1,e,n);return o=>o===0||o===1?o:kG(i(o),t,r)}var CG=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,NG=e=>t=>1-e(1-t),MG=Gx(.33,1.53,.69,.99),_q=NG(MG),_G=CG(_q),EG=e=>(e*=2)<1?.5*_q(e):.5*(2-Math.pow(2,-10*(e-1))),Eq=e=>1-Math.sin(Math.acos(e)),OG=NG(Eq),TG=CG(Eq),YMe=Gx(.42,0,1,1),QMe=Gx(0,0,.58,1),AG=Gx(.42,0,.58,1),GMe=e=>Array.isArray(e)&&typeof e[0]!="number",DG=e=>Array.isArray(e)&&typeof e[0]=="number",IH={linear:xa,easeIn:YMe,easeInOut:AG,easeOut:QMe,circIn:Eq,circInOut:TG,circOut:OG,backIn:_q,backInOut:_G,backOut:MG,anticipate:EG},XMe=e=>typeof e=="string",PH=e=>{if(DG(e)){Oc(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");let[t,n,r,i]=e;return Gx(t,n,r,i)}else if(XMe(e))return Oc(IH[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),IH[e];return e},mC=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"],iu={value:null,addProjectionMetrics:null};function JMe(e,t){let n=new Set,r=new Set,i=!1,o=!1,s=new WeakSet,a={delta:0,timestamp:0,isProcessing:!1},l=0;function u(d){s.has(d)&&(c.schedule(d),e()),l++,d(a)}let c={schedule:(d,h=!1,f=!1)=>{let p=f&&i?n:r;return h&&s.add(d),p.has(d)||p.add(d),d},cancel:d=>{r.delete(d),s.delete(d)},process:d=>{if(a=d,i){o=!0;return}i=!0,[n,r]=[r,n],n.forEach(u),t&&iu.value&&iu.value.frameloop[t].push(l),l=0,n.clear(),i=!1,o&&(o=!1,c.process(d))}};return c}var ZMe=40;function RG(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,s=mC.reduce((y,v)=>(y[v]=JMe(o,t?v:void 0),y),{}),{setup:a,read:l,resolveKeyframes:u,preUpdate:c,update:d,preRender:h,render:f,postRender:p}=s,m=()=>{let y=Tc.useManualTiming?i.timestamp:performance.now();n=!1,Tc.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(y-i.timestamp,ZMe),1)),i.timestamp=y,i.isProcessing=!0,a.process(i),l.process(i),u.process(i),c.process(i),d.process(i),h.process(i),f.process(i),p.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(m))},g=()=>{n=!0,r=!0,i.isProcessing||e(m)};return{schedule:mC.reduce((y,v)=>{let b=s[v];return y[v]=(w,x=!1,S=!1)=>(n||g(),b.schedule(w,x,S)),y},{}),cancel:y=>{for(let v=0;v<mC.length;v++)s[mC[v]].cancel(y)},state:i,steps:s}}var{schedule:Fn,cancel:Nh,state:zi,steps:E2}=RG(typeof requestAnimationFrame<"u"?requestAnimationFrame:xa,!0),CN;function e_e(){CN=void 0}var Eo={now:()=>(CN===void 0&&Eo.set(zi.isProcessing||Tc.useManualTiming?zi.timestamp:performance.now()),CN),set:e=>{CN=e,queueMicrotask(e_e)}},Dp={layout:0,mainThread:0,waapi:0},IG=e=>t=>typeof t=="string"&&t.startsWith(e),PG=IG("--"),t_e=IG("var(--"),Oq=e=>t_e(e)?n_e.test(e.split("/*")[0].trim()):!1,n_e=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function LH(e){return typeof e!="string"?!1:e.split("/*")[0].includes("var(--")}var mv={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},ox={...mv,transform:e=>yu(0,1,e)},gC={...mv,default:1},Tw=e=>Math.round(e*1e5)/1e5,Tq=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function r_e(e){return e==null}var i_e=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Aq=(e,t)=>n=>!!(typeof n=="string"&&i_e.test(n)&&n.startsWith(e)||t&&!r_e(n)&&Object.prototype.hasOwnProperty.call(n,t)),LG=(e,t,n)=>r=>{if(typeof r!="string")return r;let[i,o,s,a]=r.match(Tq);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(s),alpha:a!==void 0?parseFloat(a):1}},o_e=e=>yu(0,255,e),O2={...mv,transform:e=>Math.round(o_e(e))},wp={test:Aq("rgb","red"),parse:LG("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+O2.transform(e)+", "+O2.transform(t)+", "+O2.transform(n)+", "+Tw(ox.transform(r))+")"};function s_e(e){let t="",n="",r="",i="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var zI={test:Aq("#"),parse:s_e,transform:wp.transform},Xx=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Yd=Xx("deg"),hu=Xx("%"),Pe=Xx("px"),a_e=Xx("vh"),l_e=Xx("vw"),BH={...hu,parse:e=>hu.parse(e)/100,transform:e=>hu.transform(e*100)},dy={test:Aq("hsl","hue"),parse:LG("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+hu.transform(Tw(t))+", "+hu.transform(Tw(n))+", "+Tw(ox.transform(r))+")"},Ur={test:e=>wp.test(e)||zI.test(e)||dy.test(e),parse:e=>wp.test(e)?wp.parse(e):dy.test(e)?dy.parse(e):zI.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?wp.transform(e):dy.transform(e),getAnimatableNone:e=>{let t=Ur.parse(e);return t.alpha=0,Ur.transform(t)}},u_e=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function c_e(e){return isNaN(e)&&typeof e=="string"&&(e.match(Tq)?.length||0)+(e.match(u_e)?.length||0)>0}var BG="number",qG="color",d_e="var",h_e="var(",qH="${}",f_e=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function sx(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],o=0,s=t.replace(f_e,a=>(Ur.test(a)?(r.color.push(o),i.push(qG),n.push(Ur.parse(a))):a.startsWith(h_e)?(r.var.push(o),i.push(d_e),n.push(a)):(r.number.push(o),i.push(BG),n.push(parseFloat(a))),++o,qH)).split(qH);return{values:n,split:s,indexes:r,types:i}}function zG(e){return sx(e).values}function FG(e){let{split:t,types:n}=sx(e),r=t.length;return i=>{let o="";for(let s=0;s<r;s++)if(o+=t[s],i[s]!==void 0){let a=n[s];a===BG?o+=Tw(i[s]):a===qG?o+=Ur.transform(i[s]):o+=i[s]}return o}}var p_e=e=>typeof e=="number"?0:Ur.test(e)?Ur.getAnimatableNone(e):e;function m_e(e){let t=zG(e);return FG(e)(t.map(p_e))}var Mh={test:c_e,parse:zG,createTransformer:FG,getAnimatableNone:m_e};function T2(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function g_e({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,s=0;if(!t)i=o=s=n;else{let a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=T2(l,a,e+1/3),o=T2(l,a,e),s=T2(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(s*255),alpha:r}}function yM(e,t){return n=>n>0?t:e}var yr=(e,t,n)=>e+(t-e)*n,A2=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},y_e=[zI,wp,dy],v_e=e=>y_e.find(t=>t.test(e));function zH(e){let t=v_e(e);if(pv(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,"color-not-animatable"),!t)return!1;let n=t.parse(e);return t===dy&&(n=g_e(n)),n}var FH=(e,t)=>{let n=zH(e),r=zH(t);if(!n||!r)return yM(e,t);let i={...n};return o=>(i.red=A2(n.red,r.red,o),i.green=A2(n.green,r.green,o),i.blue=A2(n.blue,r.blue,o),i.alpha=yr(n.alpha,r.alpha,o),wp.transform(i))},FI=new Set(["none","hidden"]);function b_e(e,t){return FI.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function w_e(e,t){return n=>yr(e,t,n)}function Dq(e){return typeof e=="number"?w_e:typeof e=="string"?Oq(e)?yM:Ur.test(e)?FH:k_e:Array.isArray(e)?jG:typeof e=="object"?Ur.test(e)?FH:x_e:yM}function jG(e,t){let n=[...e],r=n.length,i=e.map((o,s)=>Dq(o)(o,t[s]));return o=>{for(let s=0;s<r;s++)n[s]=i[s](o);return n}}function x_e(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Dq(e[i])(e[i],t[i]));return i=>{for(let o in r)n[o]=r[o](i);return n}}function S_e(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let o=t.types[i],s=e.indexes[o][r[o]],a=e.values[s]??0;n[i]=a,r[o]++}return n}var k_e=(e,t)=>{let n=Mh.createTransformer(t),r=sx(e),i=sx(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?FI.has(e)&&!i.values.length||FI.has(t)&&!r.values.length?b_e(e,t):Qx(jG(S_e(r,i),i.values),n):(pv(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,"complex-values-different"),yM(e,t))};function VG(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?yr(e,t,n):Dq(e)(e,t)}var C_e=e=>{let t=({timestamp:n})=>e(n);return{start:(n=!0)=>Fn.update(t,n),stop:()=>Nh(t),now:()=>zi.isProcessing?zi.timestamp:Eo.now()}},WG=(e,t,n=10)=>{let r="",i=Math.max(Math.round(t/n),2);for(let o=0;o<i;o++)r+=Math.round(e(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`};function Rq(e){let t=0,n=50,r=e.next(t);for(;!r.done&&t<2e4;)t+=n,r=e.next(t);return t>=2e4?1/0:t}function N_e(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Rq(r),2e4);return{type:"keyframes",ease:o=>r.next(i*o).value/t,duration:ya(i)}}var M_e=5;function UG(e,t,n){let r=Math.max(t-M_e,0);return SG(n-e(r),t-r)}var mr={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},D2=.001;function __e({duration:e=mr.duration,bounce:t=mr.bounce,velocity:n=mr.velocity,mass:r=mr.mass}){let i,o;pv(e<=Sa(mr.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let s=1-t;s=yu(mr.minDamping,mr.maxDamping,s),e=yu(mr.minDuration,mr.maxDuration,ya(e)),s<1?(i=u=>{let c=u*s,d=c*e,h=c-n,f=jI(u,s),p=Math.exp(-d);return D2-h/f*p},o=u=>{let c=u*s*e,d=c*n+n,h=Math.pow(s,2)*Math.pow(u,2)*e,f=Math.exp(-c),p=jI(Math.pow(u,2),s);return(-i(u)+D2>0?-1:1)*((d-h)*f)/p}):(i=u=>{let c=Math.exp(-u*e),d=(u-n)*e+1;return-D2+c*d},o=u=>{let c=Math.exp(-u*e),d=(n-u)*(e*e);return c*d});let a=5/e,l=O_e(i,o,a);if(e=Sa(e),isNaN(l))return{stiffness:mr.stiffness,damping:mr.damping,duration:e};{let u=Math.pow(l,2)*r;return{stiffness:u,damping:s*2*Math.sqrt(r*u),duration:e}}}var E_e=12;function O_e(e,t,n){let r=n;for(let i=1;i<E_e;i++)r=r-e(r)/t(r);return r}function jI(e,t){return e*Math.sqrt(1-t*t)}var T_e=["duration","bounce"],A_e=["stiffness","damping","mass"];function jH(e,t){return t.some(n=>e[n]!==void 0)}function D_e(e){let t={velocity:mr.velocity,stiffness:mr.stiffness,damping:mr.damping,mass:mr.mass,isResolvedFromDuration:!1,...e};if(!jH(e,A_e)&&jH(e,T_e))if(e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*yu(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:mr.mass,stiffness:i,damping:o}}else{let n=__e(e);t={...t,...n,mass:mr.mass},t.isResolvedFromDuration=!0}return t}function vM(e=mr.visualDuration,t=mr.bounce){let n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e,{restSpeed:r,restDelta:i}=n,o=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:u,mass:c,duration:d,velocity:h,isResolvedFromDuration:f}=D_e({...n,velocity:-ya(n.velocity||0)}),p=h||0,m=u/(2*Math.sqrt(l*c)),g=s-o,y=ya(Math.sqrt(l/c)),v=Math.abs(g)<5;r||(r=v?mr.restSpeed.granular:mr.restSpeed.default),i||(i=v?mr.restDelta.granular:mr.restDelta.default);let b;if(m<1){let x=jI(y,m);b=S=>{let k=Math.exp(-m*y*S);return s-k*((p+m*y*g)/x*Math.sin(x*S)+g*Math.cos(x*S))}}else if(m===1)b=x=>s-Math.exp(-y*x)*(g+(p+y*g)*x);else{let x=y*Math.sqrt(m*m-1);b=S=>{let k=Math.exp(-m*y*S),C=Math.min(x*S,300);return s-k*((p+m*y*g)*Math.sinh(C)+x*g*Math.cosh(C))/x}}let w={calculatedDuration:f&&d||null,next:x=>{let S=b(x);if(f)a.done=x>=d;else{let k=x===0?p:0;m<1&&(k=x===0?Sa(p):UG(b,x,S));let C=Math.abs(k)<=r,N=Math.abs(s-S)<=i;a.done=C&&N}return a.value=a.done?s:S,a},toString:()=>{let x=Math.min(Rq(w),2e4),S=WG(k=>w.next(x*k).value,x,30);return x+"ms "+S},toTransition:()=>{}};return w}vM.applyToOptions=e=>{let t=N_e(e,100,vM);return e.ease=t.ease,e.duration=Sa(t.duration),e.type="keyframes",e};function VI({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:s,min:a,max:l,restDelta:u=.5,restSpeed:c}){let d=e[0],h={done:!1,value:d},f=C=>a!==void 0&&C<a||l!==void 0&&C>l,p=C=>a===void 0?l:l===void 0||Math.abs(a-C)<Math.abs(l-C)?a:l,m=n*t,g=d+m,y=s===void 0?g:s(g);y!==g&&(m=y-d);let v=C=>-m*Math.exp(-C/r),b=C=>y+v(C),w=C=>{let N=v(C),E=b(C);h.done=Math.abs(N)<=u,h.value=h.done?y:E},x,S,k=C=>{f(h.value)&&(x=C,S=vM({keyframes:[h.value,p(h.value)],velocity:UG(b,C,h.value),damping:i,stiffness:o,restDelta:u,restSpeed:c}))};return k(0),{calculatedDuration:null,next:C=>{let N=!1;return!S&&x===void 0&&(N=!0,w(C),k(C)),x!==void 0&&C>=x?S.next(C-x):(!N&&w(C),h)}}}function R_e(e,t,n){let r=[],i=n||Tc.mix||VG,o=e.length-1;for(let s=0;s<o;s++){let a=i(e[s],e[s+1]);if(t){let l=Array.isArray(t)?t[s]||xa:t;a=Qx(l,a)}r.push(a)}return r}function I_e(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let o=e.length;if(Oc(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];let s=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());let a=R_e(t,r,i),l=a.length,u=c=>{if(s&&c<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(c<e[d+1]);d++);let h=ix(e[d],e[d+1],c);return a[d](h)};return n?c=>u(yu(e[0],e[o-1],c)):u}function P_e(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=ix(0,t,r);e.push(yr(n,1,i))}}function L_e(e){let t=[0];return P_e(t,e.length-1),t}function B_e(e,t){return e.map(n=>n*t)}function q_e(e,t){return e.map(()=>t||AG).splice(0,e.length-1)}function hy({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){let i=GMe(r)?r.map(PH):PH(r),o={done:!1,value:t[0]},s=B_e(n&&n.length===t.length?n:L_e(t),e),a=I_e(s,t,{ease:Array.isArray(i)?i:q_e(t,i)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}var z_e=e=>e!==null;function Iq(e,{repeat:t,repeatType:n="loop"},r,i=1){let o=e.filter(z_e),s=i<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!s||r===void 0?o[s]:r}var F_e={decay:VI,inertia:VI,tween:hy,keyframes:hy,spring:vM};function HG(e){typeof e.type=="string"&&(e.type=F_e[e.type])}var Pq=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},j_e=e=>e/100,Lq=class extends Pq{constructor(e){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{let{motionValue:t}=this.options;t&&t.updatedAt!==Eo.now()&&this.tick(Eo.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),this.options.onStop?.())},Dp.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;HG(e);let{type:t=hy,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:o=0}=e,{keyframes:s}=e,a=t||hy;a!==hy&&Oc(s.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${s}`,"spring-two-frames"),a!==hy&&typeof s[0]!="number"&&(this.mixKeyframes=Qx(j_e,VG(s[0],s[1])),s=[0,100]);let l=a({...e,keyframes:s});i==="mirror"&&(this.mirroredGenerator=a({...e,keyframes:[...s].reverse(),velocity:-o})),l.calculatedDuration===null&&(l.calculatedDuration=Rq(l));let{calculatedDuration:u}=l;this.calculatedDuration=u,this.resolvedDuration=u+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=l}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=t}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:o,resolvedDuration:s,calculatedDuration:a}=this;if(this.startTime===null)return n.next(0);let{delay:l=0,keyframes:u,repeat:c,repeatType:d,repeatDelay:h,type:f,onUpdate:p,finalKeyframe:m}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-l*(this.playbackSpeed>=0?1:-1),y=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,b=n;if(c){let k=Math.min(this.currentTime,r)/s,C=Math.floor(k),N=k%1;!N&&k>=1&&(N=1),N===1&&C--,C=Math.min(C,c+1),C%2&&(d==="reverse"?(N=1-N,h&&(N-=h/s)):d==="mirror"&&(b=o)),v=yu(0,1,N)*s}let w=y?{done:!1,value:u[0]}:b.next(v);i&&(w.value=i(w.value));let{done:x}=w;!y&&a!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&x);return S&&f!==VI&&(w.value=Iq(u,this.options,m,this.speed)),p&&p(w.value),S&&this.finish(),w}then(e,t){return this.finished.then(e,t)}get duration(){return ya(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ya(e)}get time(){return ya(this.currentTime)}set time(e){e=Sa(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?.start(!1)}get speed(){return this.playbackSpeed}set speed(e){this.updateTime(Eo.now());let t=this.playbackSpeed!==e;this.playbackSpeed=e,t&&(this.time=ya(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=C_e,startTime:t}=this.options;this.driver||(this.driver=e(r=>this.tick(r))),this.options.onPlay?.();let n=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=n):this.holdTime!==null?this.startTime=n-this.holdTime:this.startTime||(this.startTime=t??n),this.state==="finished"&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state="running",this.driver.start()}pause(){this.state="paused",this.updateTime(Eo.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state="finished",this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null,Dp.mainThread--}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),this.driver?.stop(),e.observe(this)}};function V_e(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var xp=e=>e*180/Math.PI,WI=e=>{let t=xp(Math.atan2(e[1],e[0]));return UI(t)},W_e={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:WI,rotateZ:WI,skewX:e=>xp(Math.atan(e[1])),skewY:e=>xp(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},UI=e=>(e=e%360,e<0&&(e+=360),e),VH=WI,WH=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),UH=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),U_e={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:WH,scaleY:UH,scale:e=>(WH(e)+UH(e))/2,rotateX:e=>UI(xp(Math.atan2(e[6],e[5]))),rotateY:e=>UI(xp(Math.atan2(-e[2],e[0]))),rotateZ:VH,rotate:VH,skewX:e=>xp(Math.atan(e[4])),skewY:e=>xp(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function HI(e){return e.includes("scale")?1:0}function $I(e,t){if(!e||e==="none")return HI(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=U_e,i=n;else{let a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=W_e,i=a}if(!i)return HI(t);let o=r[t],s=i[1].split(",").map($_e);return typeof o=="function"?o(s):s[o]}var H_e=(e,t)=>{let{transform:n="none"}=getComputedStyle(e);return $I(n,t)};function $_e(e){return parseFloat(e.trim())}var gv=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],yv=new Set(gv),HH=e=>e===mv||e===Pe,K_e=new Set(["x","y","z"]),Y_e=gv.filter(e=>!K_e.has(e));function Q_e(e){let t=[];return Y_e.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}var uh={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>$I(t,"x"),y:(e,{transform:t})=>$I(t,"y")};uh.translateX=uh.x;uh.translateY=uh.y;var Rp=new Set,KI=!1,YI=!1,QI=!1;function $G(){if(YI){let e=Array.from(Rp).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{let i=Q_e(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();let i=n.get(r);i&&i.forEach(([o,s])=>{r.getValue(o)?.set(s)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}YI=!1,KI=!1,Rp.forEach(e=>e.complete(QI)),Rp.clear()}function KG(){Rp.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(YI=!0)})}function G_e(){QI=!0,KG(),$G(),QI=!1}var Bq=class{constructor(e,t,n,r,i,o=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=o}scheduleResolve(){this.state="scheduled",this.isAsync?(Rp.add(this),KI||(KI=!0,Fn.read(KG),Fn.resolveKeyframes($G))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),o=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let s=n.readValue(t,o);s!=null&&(e[0]=s)}e[0]===void 0&&(e[0]=o),r&&i===void 0&&r.set(e[0])}V_e(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Rp.delete(this)}cancel(){this.state==="scheduled"&&(Rp.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}},X_e=e=>e.startsWith("--");function J_e(e,t,n){X_e(t)?e.style.setProperty(t,n):e.style[t]=n}var Z_e=Cq(()=>window.ScrollTimeline!==void 0),eEe={};function tEe(e,t){let n=Cq(e);return()=>eEe[t]??n()}var YG=tEe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),nw=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,$H={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:nw([0,.65,.55,1]),circOut:nw([.55,0,1,.45]),backIn:nw([.31,.01,.66,-.59]),backOut:nw([.33,1.53,.69,.99])};function QG(e,t){if(e)return typeof e=="function"?YG()?WG(e,t):"ease-out":DG(e)?nw(e):Array.isArray(e)?e.map(n=>QG(n,t)||$H.easeOut):$H[e]}function nEe(e,t,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:s="loop",ease:a="easeOut",times:l}={},u=void 0){let c={[t]:n};l&&(c.offset=l);let d=QG(a,i);Array.isArray(d)&&(c.easing=d),iu.value&&Dp.waapi++;let h={delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:s==="reverse"?"alternate":"normal"};u&&(h.pseudoElement=u);let f=e.animate(c,h);return iu.value&&f.finished.finally(()=>{Dp.waapi--}),f}function GG(e){return typeof e=="function"&&"applyToOptions"in e}function rEe({type:e,...t}){return GG(e)&&YG()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}var XG=class extends Pq{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:o=!1,finalKeyframe:s,onComplete:a}=e;this.isPseudoElement=!!i,this.allowFlatten=o,this.options=e,Oc(typeof e.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");let l=rEe(e);this.animation=nEe(t,n,r,l,i),l.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let u=Iq(r,this.options,s,this.speed);this.updateMotionValue?this.updateMotionValue(u):J_e(t,n,u),this.animation.cancel()}a?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e==="idle"||e==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ya(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ya(e)}get time(){return ya(Number(this.animation.currentTime)||0)}set time(e){this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Sa(e)}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,observe:t}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:"linear"}),this.animation.onfinish=null,e&&Z_e()?(this.animation.timeline=e,xa):t(this)}},JG={anticipate:EG,backInOut:_G,circInOut:TG};function iEe(e){return e in JG}function oEe(e){typeof e.ease=="string"&&iEe(e.ease)&&(e.ease=JG[e.ease])}var R2=10,sEe=class extends XG{constructor(e){oEe(e),HG(e),super(e),e.startTime!==void 0&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...o}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let s=new Lq({...o,autoplay:!1}),a=Math.max(R2,Eo.now()-this.startTime),l=yu(0,R2,a-R2);t.setWithVelocity(s.sample(Math.max(0,a-l)).value,s.sample(a).value,l),s.stop()}},KH=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Mh.test(e)||e==="0")&&!e.startsWith("url("));function aEe(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function lEe(e,t,n,r){let i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;let o=e[e.length-1],s=KH(i,t),a=KH(o,t);return pv(s===a,`You are trying to animate ${t} from "${i}" to "${o}". "${s?o:i}" is not an animatable value.`,"value-not-animatable"),!s||!a?!1:aEe(e)||(n==="spring"||GG(n))&&r}function GI(e){e.duration=0,e.type="keyframes"}var uEe=new Set(["opacity","clipPath","filter","transform"]),cEe=Cq(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function dEe(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:o,type:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:a,transformTemplate:l}=t.owner.getProps();return cEe()&&n&&uEe.has(n)&&(n!=="transform"||!l)&&!a&&!r&&i!=="mirror"&&o!==0&&s!=="inertia"}var hEe=40,fEe=class extends Pq{constructor({autoplay:e=!0,delay:t=0,type:n="keyframes",repeat:r=0,repeatDelay:i=0,repeatType:o="loop",keyframes:s,name:a,motionValue:l,element:u,...c}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Eo.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:o,name:a,motionValue:l,element:u,...c},h=u?.KeyframeResolver||Bq;this.keyframeResolver=new h(s,(f,p,m)=>this.onKeyframesResolved(f,p,d,!m),a,l,u),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:o,velocity:s,delay:a,isHandoff:l,onUpdate:u}=n;this.resolvedAt=Eo.now(),lEe(e,i,o,s)||((Tc.instantAnimations||!a)&&u?.(Iq(e,n,t)),e[0]=e[e.length-1],GI(n),n.repeat=0);let c={startTime:r?this.resolvedAt?this.resolvedAt-this.createdAt>hEe?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},d=!l&&dEe(c),h=c.motionValue?.owner?.current,f=d?new sEe({...c,element:h}):new Lq(c);f.finished.then(()=>{this.notifyFinished()}).catch(xa),this.pendingTimeline&&(this.stopTimeline=f.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=f}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),G_e()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function ZG(e,t,n,r=0,i=1){let o=Array.from(e).sort((l,u)=>l.sortNodePosition(u)).indexOf(t),s=e.size,a=(s-1)*r;return typeof n=="function"?n(o,s):i===1?o*r:a-o*r}var pEe=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function mEe(e){let t=pEe.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var gEe=4;function eX(e,t,n=1){Oc(n<=gEe,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");let[r,i]=mEe(e);if(!r)return;let o=window.getComputedStyle(t).getPropertyValue(r);if(o){let s=o.trim();return bG(s)?parseFloat(s):s}return Oq(i)?eX(i,t,n+1):i}var yEe={type:"spring",stiffness:500,damping:25,restSpeed:10},vEe=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),bEe={type:"keyframes",duration:.8},wEe={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},xEe=(e,{keyframes:t})=>t.length>2?bEe:yv.has(e)?e.startsWith("scale")?vEe(t[1]):yEe:wEe,SEe=e=>e!==null;function kEe(e,{repeat:t,repeatType:n="loop"},r){let i=e.filter(SEe),o=t&&n!=="loop"&&t%2===1?0:i.length-1;return!o||r===void 0?i[o]:r}function tX(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function qq(e,t){let n=e?.[t]??e?.default??e;return n!==e?tX(n,e):n}function CEe({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:o,repeatType:s,repeatDelay:a,from:l,elapsed:u,...c}){return!!Object.keys(c).length}var zq=(e,t,n,r={},i,o)=>s=>{let a=qq(r,e)||{},l=a.delay||r.delay||0,{elapsed:u=0}=r;u=u-Sa(l);let c={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-u,onUpdate:h=>{t.set(h),a.onUpdate&&a.onUpdate(h)},onComplete:()=>{s(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:i};CEe(a)||Object.assign(c,xEe(e,c)),c.duration&&(c.duration=Sa(c.duration)),c.repeatDelay&&(c.repeatDelay=Sa(c.repeatDelay)),c.from!==void 0&&(c.keyframes[0]=c.from);let d=!1;if((c.type===!1||c.duration===0&&!c.repeatDelay)&&(GI(c),c.delay===0&&(d=!0)),(Tc.instantAnimations||Tc.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,GI(c),c.delay=0),c.allowFlatten=!a.type&&!a.ease,d&&!o&&t.get()!==void 0){let h=kEe(c.keyframes,a);if(h!==void 0){Fn.update(()=>{c.onUpdate(h),c.onComplete()});return}}return a.isSync?new Lq(c):new fEe(c)};function YH(e){let t=[{},{}];return e?.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function Fq(e,t,n,r){if(typeof t=="function"){let[i,o]=YH(r);t=t(n!==void 0?n:e.custom,i,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){let[i,o]=YH(r);t=t(n!==void 0?n:e.custom,i,o)}return t}function My(e,t,n){let r=e.getProps();return Fq(r,t,n!==void 0?n:r.custom,e)}var nX=new Set(["width","height","top","left","right","bottom",...gv]),QH=30,NEe=e=>!isNaN(parseFloat(e)),GH={current:void 0},MEe=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{let r=Eo.now();if(this.updatedAt!==r&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(n),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let i of this.dependents)i.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Eo.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=NEe(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return Mq(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",e)}on(e,t){this.events[e]||(this.events[e]=new Nq);let n=this.events[e].add(t);return e==="change"?()=>{n(),Fn.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||(this.dependents=new Set),this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return GH.current&&GH.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Eo.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>QH)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,QH);return SG(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function $y(e,t){return new MEe(e,t)}var XI=e=>Array.isArray(e);function _Ee(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,$y(n))}function EEe(e){return XI(e)?e[e.length-1]||0:e}function OEe(e,t){let n=My(e,t),{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(let s in o){let a=EEe(o[s]);_Ee(e,s,a)}}var io=e=>!!(e&&e.getVelocity);function TEe(e){return!!(io(e)&&e.add)}function JI(e,t){let n=e.getValue("willChange");if(TEe(n))return n.add(t);if(!n&&Tc.WillChange){let r=new Tc.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function jq(e){return e.replace(/([A-Z])/g,t=>`-${t.toLowerCase()}`)}var AEe="framerAppearId",rX="data-"+jq(AEe);function iX(e){return e.props[rX]}function DEe({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function oX(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o,transitionEnd:s,...a}=t,l=e.getDefaultTransition();o=o?tX(o,l):l;let u=o?.reduceMotion;r&&(o=r);let c=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let h in a){let f=e.getValue(h,e.latestValues[h]??null),p=a[h];if(p===void 0||d&&DEe(d,h))continue;let m={delay:n,...qq(o||{},h)},g=f.get();if(g!==void 0&&!f.isAnimating&&!Array.isArray(p)&&p===g&&!m.velocity)continue;let y=!1;if(window.MotionHandoffAnimation){let w=iX(e);if(w){let x=window.MotionHandoffAnimation(w,h,Fn);x!==null&&(m.startTime=x,y=!0)}}JI(e,h);let v=u??e.shouldReduceMotion;f.start(zq(h,f,p,v&&nX.has(h)?{type:!1}:m,e,y));let b=f.animation;b&&c.push(b)}if(s){let h=()=>Fn.update(()=>{s&&OEe(e,s)});c.length?Promise.all(c).then(h):h()}return c}function ZI(e,t,n={}){let r=My(e,t,n.type==="exit"?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let o=r?()=>Promise.all(oX(e,r,n)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(l=0)=>{let{delayChildren:u=0,staggerChildren:c,staggerDirection:d}=i;return REe(e,t,l,u,c,d,n)}:()=>Promise.resolve(),{when:a}=i;if(a){let[l,u]=a==="beforeChildren"?[o,s]:[s,o];return l().then(()=>u())}else return Promise.all([o(),s(n.delay)])}function REe(e,t,n=0,r=0,i=0,o=1,s){let a=[];for(let l of e.variantChildren)l.notify("AnimationStart",t),a.push(ZI(l,t,{...s,delay:n+(typeof r=="function"?0:r)+ZG(e.variantChildren,l,r,i,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function IEe(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){let i=t.map(o=>ZI(e,o,n));r=Promise.all(i)}else if(typeof t=="string")r=ZI(e,t,n);else{let i=typeof t=="function"?My(e,t,n.custom):t;r=Promise.all(oX(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}var PEe={test:e=>e==="auto",parse:e=>e},sX=e=>t=>t.test(e),aX=[mv,Pe,hu,Yd,l_e,a_e,PEe],XH=e=>aX.find(sX(e));function LEe(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||xG(e):!0}var BEe=new Set(["brightness","contrast","saturate","opacity"]);function qEe(e){let[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;let[r]=n.match(Tq)||[];if(!r)return e;let i=n.replace(r,""),o=BEe.has(t)?1:0;return r!==n&&(o*=100),t+"("+o+i+")"}var zEe=/\b([a-z-]*)\(.*?\)/gu,eP={...Mh,getAnimatableNone:e=>{let t=e.match(zEe);return t?t.map(qEe).join(" "):e}},JH={...mv,transform:Math.round},FEe={rotate:Yd,rotateX:Yd,rotateY:Yd,rotateZ:Yd,scale:gC,scaleX:gC,scaleY:gC,scaleZ:gC,skew:Yd,skewX:Yd,skewY:Yd,distance:Pe,translateX:Pe,translateY:Pe,translateZ:Pe,x:Pe,y:Pe,z:Pe,perspective:Pe,transformPerspective:Pe,opacity:ox,originX:BH,originY:BH,originZ:Pe},Vq={borderWidth:Pe,borderTopWidth:Pe,borderRightWidth:Pe,borderBottomWidth:Pe,borderLeftWidth:Pe,borderRadius:Pe,borderTopLeftRadius:Pe,borderTopRightRadius:Pe,borderBottomRightRadius:Pe,borderBottomLeftRadius:Pe,width:Pe,maxWidth:Pe,height:Pe,maxHeight:Pe,top:Pe,right:Pe,bottom:Pe,left:Pe,inset:Pe,insetBlock:Pe,insetBlockStart:Pe,insetBlockEnd:Pe,insetInline:Pe,insetInlineStart:Pe,insetInlineEnd:Pe,padding:Pe,paddingTop:Pe,paddingRight:Pe,paddingBottom:Pe,paddingLeft:Pe,paddingBlock:Pe,paddingBlockStart:Pe,paddingBlockEnd:Pe,paddingInline:Pe,paddingInlineStart:Pe,paddingInlineEnd:Pe,margin:Pe,marginTop:Pe,marginRight:Pe,marginBottom:Pe,marginLeft:Pe,marginBlock:Pe,marginBlockStart:Pe,marginBlockEnd:Pe,marginInline:Pe,marginInlineStart:Pe,marginInlineEnd:Pe,fontSize:Pe,backgroundPositionX:Pe,backgroundPositionY:Pe,...FEe,zIndex:JH,fillOpacity:ox,strokeOpacity:ox,numOctaves:JH},jEe={...Vq,color:Ur,backgroundColor:Ur,outlineColor:Ur,fill:Ur,stroke:Ur,borderColor:Ur,borderTopColor:Ur,borderRightColor:Ur,borderBottomColor:Ur,borderLeftColor:Ur,filter:eP,WebkitFilter:eP},lX=e=>jEe[e];function uX(e,t){let n=lX(e);return n!==eP&&(n=Mh),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var VEe=new Set(["auto","none","0"]);function WEe(e,t,n){let r=0,i;for(;r<e.length&&!i;){let o=e[r];typeof o=="string"&&!VEe.has(o)&&sx(o).values.length&&(i=e[r]),r++}if(i&&n)for(let o of t)e[o]=uX(n,i)}var UEe=class extends Bq{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let u=0;u<e.length;u++){let c=e[u];if(typeof c=="string"&&(c=c.trim(),Oq(c))){let d=eX(c,t.current);d!==void 0&&(e[u]=d),u===e.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!nX.has(n)||e.length!==2)return;let[r,i]=e,o=XH(r),s=XH(i),a=LH(r),l=LH(i);if(a!==l&&uh[n]){this.needsMeasurement=!0;return}if(o!==s)if(HH(o)&&HH(s))for(let u=0;u<e.length;u++){let c=e[u];typeof c=="string"&&(e[u]=parseFloat(c))}else uh[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let r=0;r<e.length;r++)(e[r]===null||LEe(e[r]))&&n.push(r);n.length&&WEe(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=uh[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,o=n[i];n[i]=uh[t](e.measureViewportBox(),window.getComputedStyle(e.current)),o!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=o),this.removedTransforms?.length&&this.removedTransforms.forEach(([s,a])=>{e.getValue(s).set(a)}),this.resolveNoneKeyframes()}},HEe=new Set(["opacity","clipPath","filter","transform"]);function cX(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(r=>r!=null)}var dX=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function tP(e){return wG(e)&&"offsetHeight"in e}var{schedule:Wq,cancel:tyt}=RG(queueMicrotask,!1),el={x:!1,y:!1};function hX(){return el.x||el.y}function $Ee(e){return e==="x"||e==="y"?el[e]?null:(el[e]=!0,()=>{el[e]=!1}):el.x||el.y?null:(el.x=el.y=!0,()=>{el.x=el.y=!1})}function fX(e,t){let n=cX(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function KEe(e){return!(e.pointerType==="touch"||hX())}function YEe(e,t,n={}){let[r,i,o]=fX(e,n);return r.forEach(s=>{let a=!1,l=!1,u,c=()=>{s.removeEventListener("pointerleave",p)},d=g=>{u&&(u(g),u=void 0),c()},h=g=>{a=!1,window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h),l&&(l=!1,d(g))},f=()=>{a=!0,window.addEventListener("pointerup",h,i),window.addEventListener("pointercancel",h,i)},p=g=>{if(g.pointerType!=="touch"){if(a){l=!0;return}d(g)}},m=g=>{if(!KEe(g))return;l=!1;let y=t(s,g);typeof y=="function"&&(u=y,s.addEventListener("pointerleave",p,i))};s.addEventListener("pointerenter",m,i),s.addEventListener("pointerdown",f,i)}),o}var pX=(e,t)=>t?e===t?!0:pX(e,t.parentElement):!1,Uq=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,QEe=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function GEe(e){return QEe.has(e.tagName)||e.isContentEditable===!0}var XEe=new Set(["INPUT","SELECT","TEXTAREA"]);function JEe(e){return XEe.has(e.tagName)||e.isContentEditable===!0}var NN=new WeakSet;function ZH(e){return t=>{t.key==="Enter"&&e(t)}}function I2(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}var ZEe=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ZH(()=>{if(NN.has(n))return;I2(n,"down");let i=ZH(()=>{I2(n,"up")}),o=()=>I2(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function e$(e){return Uq(e)&&!hX()}var t$=new WeakSet;function eOe(e,t,n={}){let[r,i,o]=fX(e,n),s=a=>{let l=a.currentTarget;if(!e$(a)||t$.has(a))return;NN.add(l),n.stopPropagation&&t$.add(a);let u=t(l,a),c=(f,p)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",h),NN.has(l)&&NN.delete(l),e$(f)&&typeof u=="function"&&u(f,{success:p})},d=f=>{c(f,l===window||l===document||n.useGlobalTarget||pX(l,f.target))},h=f=>{c(f,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",h,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",s,i),tP(a)&&(a.addEventListener("focus",l=>ZEe(l,i)),!GEe(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function Hq(e){return wG(e)&&"ownerSVGElement"in e}var MN=new WeakMap,_N,mX=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+"Size"]:Hq(r)&&"getBBox"in r?r.getBBox()[t]:r[n],tOe=mX("inline","width","offsetWidth"),nOe=mX("block","height","offsetHeight");function rOe({target:e,borderBoxSize:t}){MN.get(e)?.forEach(n=>{n(e,{get width(){return tOe(e,t)},get height(){return nOe(e,t)}})})}function iOe(e){e.forEach(rOe)}function oOe(){typeof ResizeObserver>"u"||(_N=new ResizeObserver(iOe))}function sOe(e,t){_N||oOe();let n=cX(e);return n.forEach(r=>{let i=MN.get(r);i||(i=new Set,MN.set(r,i)),i.add(t),_N?.observe(r)}),()=>{n.forEach(r=>{let i=MN.get(r);i?.delete(t),i?.size||_N?.unobserve(r)})}}var EN=new Set,fy;function aOe(){fy=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};EN.forEach(t=>t(e))},window.addEventListener("resize",fy)}function lOe(e){return EN.add(e),fy||aOe(),()=>{EN.delete(e),!EN.size&&typeof fy=="function"&&(window.removeEventListener("resize",fy),fy=void 0)}}function n$(e,t){return typeof e=="function"?lOe(e):sOe(e,t)}function uOe(e){return Hq(e)&&e.tagName==="svg"}var cOe=[...aX,Ur,Mh],dOe=e=>cOe.find(sX(e)),r$=()=>({translate:0,scale:1,origin:0,originPoint:0}),py=()=>({x:r$(),y:r$()}),i$=()=>({min:0,max:0}),ui=()=>({x:i$(),y:i$()}),hOe=new WeakMap;function I_(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function ax(e){return typeof e=="string"||Array.isArray(e)}var $q=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Kq=["initial",...$q];function P_(e){return I_(e.animate)||Kq.some(t=>ax(e[t]))}function gX(e){return!!(P_(e)||e.variants)}function fOe(e,t,n){for(let r in t){let i=t[r],o=n[r];if(io(i))e.addValue(r,i);else if(io(o))e.addValue(r,$y(i,{owner:e}));else if(o!==i)if(e.hasValue(r)){let s=e.getValue(r);s.liveStyle===!0?s.jump(i):s.hasAnimated||s.set(i)}else{let s=e.getStaticValue(r);e.addValue(r,$y(s!==void 0?s:i,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var nP={current:null},yX={current:!1},pOe=typeof window<"u";function mOe(){if(yX.current=!0,!!pOe)if(window.matchMedia){let e=window.matchMedia("(prefers-reduced-motion)"),t=()=>nP.current=e.matches;e.addEventListener("change",t),t()}else nP.current=!1}var o$=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"],bM={};function vX(e){bM=e}function gOe(){return bM}var yOe=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:o,visualState:s},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Bq,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let h=Eo.now();this.renderScheduledAt<h&&(this.renderScheduledAt=h,Fn.render(this.render,!1,!0))};let{latestValues:l,renderState:u}=s;this.latestValues=l,this.baseTarget={...l},this.initialValues=t.initial?{...l}:{},this.renderState=u,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=P_(t),this.isVariantNode=gX(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:c,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let h in d){let f=d[h];l[h]!==void 0&&io(f)&&f.set(l[h])}}mount(e){if(this.hasBeenMounted)for(let t in this.initialValues)this.values.get(t)?.jump(this.initialValues[t]),this.latestValues[t]=this.initialValues[t];this.current=e,hOe.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((t,n)=>this.bindToMotionValue(n,t)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(yX.current||mOe(),this.shouldReduceMotion=nP.current),Mq(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Nh(this.notifyUpdate),Nh(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&HEe.has(e)&&this.current instanceof HTMLElement){let{factory:o,keyframes:s,times:a,ease:l,duration:u}=t.accelerate,c=new XG({element:this.current,name:e,keyframes:s,times:a,ease:l,duration:Sa(u)}),d=o(c);this.valueSubscriptions.set(e,()=>{d(),c.cancel()});return}let n=yv.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on("change",o=>{this.latestValues[e]=o,this.props.onUpdate&&Fn.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<"u"&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e="animation";for(e in bM){let t=bM[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let i=this.features[e];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ui()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let n=0;n<o$.length;n++){let r=o$[n];this.propEventSubscriptions[r]&&(this.propEventSubscriptions[r](),delete this.propEventSubscriptions[r]);let i="on"+r,o=e[i];o&&(this.propEventSubscriptions[r]=this.on(r,o))}this.prevMotionValues=fOe(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=$y(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n=="string"&&(bG(n)||xG(n))?n=parseFloat(n):!dOe(n)&&Mh.test(t)&&(n=uX(e,t)),this.setBaseTarget(e,io(n)?n.get():n)),io(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t=="string"||typeof t=="object"){let i=Fq(this.props,t,this.presenceContext?.custom);i&&(n=i[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!io(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new Nq),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Wq.render(this.render)}},bX=class extends yOe{constructor(){super(...arguments),this.KeyframeResolver=UEe}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;io(e)&&(this.childSubscription=e.on("change",t=>{this.current&&(this.current.textContent=`${t}`)}))}},Fh=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function wX({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function vOe({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function bOe(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function P2(e){return e===void 0||e===1}function rP({scale:e,scaleX:t,scaleY:n}){return!P2(e)||!P2(t)||!P2(n)}function dp(e){return rP(e)||xX(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function xX(e){return s$(e.x)||s$(e.y)}function s$(e){return e&&e!=="0%"}function wM(e,t,n){let r=e-n,i=t*r;return n+i}function a$(e,t,n,r,i){return i!==void 0&&(e=wM(e,i,r)),wM(e,n,r)+t}function iP(e,t=0,n=1,r,i){e.min=a$(e.min,t,n,r,i),e.max=a$(e.max,t,n,r,i)}function SX(e,{x:t,y:n}){iP(e.x,t.translate,t.scale,t.originPoint),iP(e.y,n.translate,n.scale,n.originPoint)}var l$=.999999999999,u$=1.0000000000001;function wOe(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let o,s;for(let a=0;a<i;a++){o=n[a],s=o.projectionDelta;let{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&gy(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),s&&(t.x*=s.x.scale,t.y*=s.y.scale,SX(e,s)),r&&dp(o.latestValues)&&gy(e,o.latestValues))}t.x<u$&&t.x>l$&&(t.x=1),t.y<u$&&t.y>l$&&(t.y=1)}function my(e,t){e.min=e.min+t,e.max=e.max+t}function c$(e,t,n,r,i=.5){let o=yr(e.min,e.max,i);iP(e,t,n,o,r)}function gy(e,t){c$(e.x,t.x,t.scaleX,t.scale,t.originX),c$(e.y,t.y,t.scaleY,t.scale,t.originY)}function kX(e,t){return wX(bOe(e.getBoundingClientRect(),t))}function xOe(e,t,n){let r=kX(e,n),{scroll:i}=t;return i&&(my(r.x,i.offset.x),my(r.y,i.offset.y)),r}var SOe={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},kOe=gv.length;function COe(e,t,n){let r="",i=!0;for(let o=0;o<kOe;o++){let s=gv[o],a=e[s];if(a===void 0)continue;let l=!0;if(typeof a=="number")l=a===(s.startsWith("scale")?1:0);else{let u=parseFloat(a);l=s.startsWith("scale")?u===1:u===0}if(!l||n){let u=dX(a,Vq[s]);if(!l){i=!1;let c=SOe[s]||s;r+=`${c}(${u}) `}n&&(t[s]=u)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function Yq(e,t,n){let{style:r,vars:i,transformOrigin:o}=e,s=!1,a=!1;for(let l in t){let u=t[l];if(yv.has(l)){s=!0;continue}else if(PG(l)){i[l]=u;continue}else{let c=dX(u,Vq[l]);l.startsWith("origin")?(a=!0,o[l]=c):r[l]=c}}if(t.transform||(s||n?r.transform=COe(t,e.transform,n):r.transform&&(r.transform="none")),a){let{originX:l="50%",originY:u="50%",originZ:c=0}=o;r.transformOrigin=`${l} ${u} ${c}`}}function CX(e,{style:t,vars:n},r,i){let o=e.style,s;for(s in t)o[s]=t[s];i?.applyProjectionStyles(o,r);for(s in n)o.setProperty(s,n[s])}function d$(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Rb={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(Pe.test(e))e=parseFloat(e);else return e;let n=d$(e,t.target.x),r=d$(e,t.target.y);return`${n}% ${r}%`}},NOe={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Mh.parse(e);if(i.length>5)return r;let o=Mh.createTransformer(e),s=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+s]/=a,i[1+s]/=l;let u=yr(a,l,.5);return typeof i[2+s]=="number"&&(i[2+s]/=u),typeof i[3+s]=="number"&&(i[3+s]/=u),o(i)}},oP={borderRadius:{...Rb,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Rb,borderTopRightRadius:Rb,borderBottomLeftRadius:Rb,borderBottomRightRadius:Rb,boxShadow:NOe};function NX(e,{layout:t,layoutId:n}){return yv.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!oP[e]||e==="opacity")}function Qq(e,t,n){let r=e.style,i=t?.style,o={};if(!r)return o;for(let s in r)(io(r[s])||i&&io(i[s])||NX(s,e)||n?.getValue(s)?.liveStyle!==void 0)&&(o[s]=r[s]);return o}function MOe(e){return window.getComputedStyle(e)}var _Oe=class extends bX{constructor(){super(...arguments),this.type="html",this.renderInstance=CX}readValueFromInstance(e,t){if(yv.has(t))return this.projection?.isProjecting?HI(t):H_e(e,t);{let n=MOe(e),r=(PG(t)?n.getPropertyValue(t):n[t])||0;return typeof r=="string"?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return kX(e,t)}build(e,t,n){Yq(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Qq(e,t,n)}},EOe={offset:"stroke-dashoffset",array:"stroke-dasharray"},OOe={offset:"strokeDashoffset",array:"strokeDasharray"};function TOe(e,t,n=1,r=0,i=!0){e.pathLength=1;let o=i?EOe:OOe;e[o.offset]=`${-r}`,e[o.array]=`${t} ${n}`}var AOe=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function MX(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:s=0,...a},l,u,c){if(Yq(e,a,u),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:h}=e;d.transform&&(h.transform=d.transform,delete d.transform),(h.transform||d.transformOrigin)&&(h.transformOrigin=d.transformOrigin??"50% 50%",delete d.transformOrigin),h.transform&&(h.transformBox=c?.transformBox??"fill-box",delete d.transformBox);for(let f of AOe)d[f]!==void 0&&(h[f]=d[f],delete d[f]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&TOe(d,i,o,s,!1)}var _X=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]),EX=e=>typeof e=="string"&&e.toLowerCase()==="svg";function DOe(e,t,n,r){CX(e,t,void 0,r);for(let i in t.attrs)e.setAttribute(_X.has(i)?i:jq(i),t.attrs[i])}function OX(e,t,n){let r=Qq(e,t,n);for(let i in e)if(io(e[i])||io(t[i])){let o=gv.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=e[i]}return r}var ROe=class extends bX{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=ui}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(yv.has(t)){let n=lX(t);return n&&n.default||0}return t=_X.has(t)?t:jq(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return OX(e,t,n)}build(e,t,n){MX(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){DOe(e,t,n,r)}mount(e){this.isSVGTag=EX(e.tagName),super.mount(e)}},IOe=Kq.length;function TX(e){if(!e)return;if(!e.isControllingVariants){let n=e.parent?TX(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}let t={};for(let n=0;n<IOe;n++){let r=Kq[n],i=e.props[r];(ax(i)||i===!1)&&(t[r]=i)}return t}function AX(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var POe=[...$q].reverse(),LOe=$q.length;function BOe(e){return t=>Promise.all(t.map(({animation:n,options:r})=>IEe(e,n,r)))}function qOe(e){let t=BOe(e),n=h$(),r=!0,i=l=>(u,c)=>{let d=My(e,c,l==="exit"?e.presenceContext?.custom:void 0);if(d){let{transition:h,transitionEnd:f,...p}=d;u={...u,...p,...f}}return u};function o(l){t=l(e)}function s(l){let{props:u}=e,c=TX(e.parent)||{},d=[],h=new Set,f={},p=1/0;for(let g=0;g<LOe;g++){let y=POe[g],v=n[y],b=u[y]!==void 0?u[y]:c[y],w=ax(b),x=y===l?v.isActive:null;x===!1&&(p=g);let S=b===c[y]&&b!==u[y]&&w;if(S&&r&&e.manuallyAnimateOnMount&&(S=!1),v.protectedKeys={...f},!v.isActive&&x===null||!b&&!v.prevProp||I_(b)||typeof b=="boolean")continue;if(y==="exit"&&v.isActive&&x!==!0){v.prevResolvedValues&&(f={...f,...v.prevResolvedValues});continue}let k=zOe(v.prevProp,b),C=k||y===l&&v.isActive&&!S&&w||g>p&&w,N=!1,E=Array.isArray(b)?b:[b],D=E.reduce(i(y),{});x===!1&&(D={});let{prevResolvedValues:q={}}=v,z={...q,...D},_=T=>{C=!0,h.has(T)&&(N=!0,h.delete(T)),v.needsAnimating[T]=!0;let B=e.getValue(T);B&&(B.liveStyle=!1)};for(let T in z){let B=D[T],A=q[T];if(f.hasOwnProperty(T))continue;let M=!1;XI(B)&&XI(A)?M=!AX(B,A):M=B!==A,M?B!=null?_(T):h.add(T):B!==void 0&&h.has(T)?_(T):v.protectedKeys[T]=!0}v.prevProp=b,v.prevResolvedValues=D,v.isActive&&(f={...f,...D}),r&&e.blockInitialAnimation&&(C=!1);let R=S&&k;C&&(!R||N)&&d.push(...E.map(T=>{let B={type:y};if(typeof T=="string"&&r&&!R&&e.manuallyAnimateOnMount&&e.parent){let{parent:A}=e,M=My(A,T);if(A.enteringChildren&&M){let{delayChildren:P}=M.transition||{};B.delay=ZG(A.enteringChildren,e,P)}}return{animation:T,options:B}}))}if(h.size){let g={};if(typeof u.initial!="boolean"){let y=My(e,Array.isArray(u.initial)?u.initial[0]:u.initial);y&&y.transition&&(g.transition=y.transition)}h.forEach(y=>{let v=e.getBaseTarget(y),b=e.getValue(y);b&&(b.liveStyle=!0),g[y]=v??null}),d.push({animation:g})}let m=!!d.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(m=!1),r=!1,m?t(d):Promise.resolve()}function a(l,u){if(n[l].isActive===u)return Promise.resolve();e.variantChildren?.forEach(d=>d.animationState?.setActive(l,u)),n[l].isActive=u;let c=s(l);for(let d in n)n[d].protectedKeys={};return c}return{animateChanges:s,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=h$()}}}function zOe(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!AX(t,e):!1}function sp(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function h$(){return{animate:sp(!0),whileInView:sp(),whileHover:sp(),whileTap:sp(),whileDrag:sp(),whileFocus:sp(),exit:sp()}}function f$(e,t){e.min=t.min,e.max=t.max}function Ga(e,t){f$(e.x,t.x),f$(e.y,t.y)}function p$(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var DX=1e-4,FOe=1-DX,jOe=1+DX,RX=.01,VOe=0-RX,WOe=0+RX;function Oo(e){return e.max-e.min}function UOe(e,t,n){return Math.abs(e-t)<=n}function m$(e,t,n,r=.5){e.origin=r,e.originPoint=yr(t.min,t.max,e.origin),e.scale=Oo(n)/Oo(t),e.translate=yr(n.min,n.max,e.origin)-e.originPoint,(e.scale>=FOe&&e.scale<=jOe||isNaN(e.scale))&&(e.scale=1),(e.translate>=VOe&&e.translate<=WOe||isNaN(e.translate))&&(e.translate=0)}function Aw(e,t,n,r){m$(e.x,t.x,n.x,r?r.originX:void 0),m$(e.y,t.y,n.y,r?r.originY:void 0)}function g$(e,t,n){e.min=n.min+t.min,e.max=e.min+Oo(t)}function HOe(e,t,n){g$(e.x,t.x,n.x),g$(e.y,t.y,n.y)}function y$(e,t,n){e.min=t.min-n.min,e.max=e.min+Oo(t)}function xM(e,t,n){y$(e.x,t.x,n.x),y$(e.y,t.y,n.y)}function v$(e,t,n,r,i){return e-=t,e=wM(e,1/n,r),i!==void 0&&(e=wM(e,1/i,r)),e}function $Oe(e,t=0,n=1,r=.5,i,o=e,s=e){if(hu.test(t)&&(t=parseFloat(t),t=yr(s.min,s.max,t/100)-s.min),typeof t!="number")return;let a=yr(o.min,o.max,r);e===o&&(a-=t),e.min=v$(e.min,t,n,a,i),e.max=v$(e.max,t,n,a,i)}function b$(e,t,[n,r,i],o,s){$Oe(e,t[n],t[r],t[i],t.scale,o,s)}var KOe=["x","scaleX","originX"],YOe=["y","scaleY","originY"];function w$(e,t,n,r){b$(e.x,t,KOe,n?n.x:void 0,r?r.x:void 0),b$(e.y,t,YOe,n?n.y:void 0,r?r.y:void 0)}function x$(e){return e.translate===0&&e.scale===1}function IX(e){return x$(e.x)&&x$(e.y)}function S$(e,t){return e.min===t.min&&e.max===t.max}function QOe(e,t){return S$(e.x,t.x)&&S$(e.y,t.y)}function k$(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function PX(e,t){return k$(e.x,t.x)&&k$(e.y,t.y)}function C$(e){return Oo(e.x)/Oo(e.y)}function N$(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Jl(e){return[e("x"),e("y")]}function GOe(e,t,n){let r="",i=e.x.translate/t.x,o=e.y.translate/t.y,s=n?.z||0;if((i||o||s)&&(r=`translate3d(${i}px, ${o}px, ${s}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:u,rotate:c,rotateX:d,rotateY:h,skewX:f,skewY:p}=n;u&&(r=`perspective(${u}px) ${r}`),c&&(r+=`rotate(${c}deg) `),d&&(r+=`rotateX(${d}deg) `),h&&(r+=`rotateY(${h}deg) `),f&&(r+=`skewX(${f}deg) `),p&&(r+=`skewY(${p}deg) `)}let a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}var LX=["TopLeft","TopRight","BottomLeft","BottomRight"],XOe=LX.length,M$=e=>typeof e=="string"?parseFloat(e):e,_$=e=>typeof e=="number"||Pe.test(e);function JOe(e,t,n,r,i,o){i?(e.opacity=yr(0,n.opacity??1,ZOe(r)),e.opacityExit=yr(t.opacity??1,0,eTe(r))):o&&(e.opacity=yr(t.opacity??1,n.opacity??1,r));for(let s=0;s<XOe;s++){let a=`border${LX[s]}Radius`,l=E$(t,a),u=E$(n,a);l===void 0&&u===void 0||(l||(l=0),u||(u=0),l===0||u===0||_$(l)===_$(u)?(e[a]=Math.max(yr(M$(l),M$(u),r),0),(hu.test(u)||hu.test(l))&&(e[a]+="%")):e[a]=u)}(t.rotate||n.rotate)&&(e.rotate=yr(t.rotate||0,n.rotate||0,r))}function E$(e,t){return e[t]!==void 0?e[t]:e.borderRadius}var ZOe=BX(0,.5,OG),eTe=BX(.5,.95,xa);function BX(e,t,n){return r=>r<e?0:r>t?1:n(ix(e,t,r))}function tTe(e,t,n){let r=io(e)?e:$y(e);return r.start(zq("",r,t,n)),r.animation}function lx(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var nTe=(e,t)=>e.depth-t.depth,rTe=class{constructor(){this.children=[],this.isDirty=!1}add(e){kq(this.children,e),this.isDirty=!0}remove(e){gM(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(nTe),this.isDirty=!1,this.children.forEach(e)}};function iTe(e,t){let n=Eo.now(),r=({timestamp:i})=>{let o=i-n;o>=t&&(Nh(r),e(o-t))};return Fn.setup(r,!0),()=>Nh(r)}function ON(e){return io(e)?e.get():e}var oTe=class{constructor(){this.members=[]}add(e){kq(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;r&&r.isConnected===!1&&n.isPresent!==!1&&!n.snapshot&&gM(this.members,n)}e.scheduleRender()}remove(e){if(gM(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let t=this.members[this.members.length-1];t&&this.promote(t)}}relegate(e){let t=this.members.findIndex(r=>e===r);if(t===0)return!1;let n;for(let r=t;r>=0;r--){let i=this.members[r],o=i.instance;if(i.isPresent!==!1&&(!o||o.isConnected!==!1)){n=i;break}}return n?(this.promote(n),!0):!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.instance&&n.scheduleRender(),e.scheduleRender();let r=n.options.layoutDependency,i=e.options.layoutDependency;if(!(r!==void 0&&i!==void 0&&r===i)){let s=n.instance;s&&s.isConnected===!1&&!n.snapshot||(e.resumeFrom=n,t&&(e.resumeFrom.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root&&e.root.isUpdating&&(e.isLayoutDirty=!0))}let{crossfade:o}=e.options;o===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{let{options:t,resumingFrom:n}=e;t.onExitComplete&&t.onExitComplete(),n&&n.options.onExitComplete&&n.options.onExitComplete()})}scheduleRender(){this.members.forEach(e=>{e.instance&&e.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}},TN={hasAnimatedSinceResize:!0,hasEverUpdated:!1},hp={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},L2=["","X","Y","Z"],sTe=1e3,aTe=0;function B2(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function qX(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=iX(t);if(window.MotionHasOptimisedAnimation(n,"transform")){let{layout:i,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",Fn,!(i||o))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&qX(r)}function zX({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(o={},s=t?.()){this.id=aTe++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,iu.value&&(hp.nodes=hp.calculatedTargetDeltas=hp.calculatedProjections=0),this.nodes.forEach(cTe),this.nodes.forEach(pTe),this.nodes.forEach(mTe),this.nodes.forEach(dTe),iu.addProjectionMetrics&&iu.addProjectionMetrics(hp)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=s?s.root||s:this,this.path=s?[...s.path,s]:[],this.parent=s,this.depth=s?s.depth+1:0;for(let a=0;a<this.path.length;a++)this.path[a].shouldResetTransform=!0;this.root===this&&(this.nodes=new rTe)}addEventListener(o,s){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new Nq),this.eventHandlers.get(o).add(s)}notifyListeners(o,...s){let a=this.eventHandlers.get(o);a&&a.notify(...s)}hasListeners(o){return this.eventHandlers.has(o)}mount(o){if(this.instance)return;this.isSVG=Hq(o)&&!uOe(o),this.instance=o;let{layoutId:s,layout:a,visualElement:l}=this.options;if(l&&!l.current&&l.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(a||s)&&(this.isLayoutDirty=!0),e){let u,c=0,d=()=>this.root.updateBlockedByResize=!1;Fn.read(()=>{c=window.innerWidth}),e(o,()=>{let h=window.innerWidth;h!==c&&(c=h,this.root.updateBlockedByResize=!0,u&&u(),u=iTe(d,250),TN.hasAnimatedSinceResize&&(TN.hasAnimatedSinceResize=!1,this.nodes.forEach(A$)))})}s&&this.root.registerSharedNode(s,this),this.options.animate!==!1&&l&&(s||a)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:c,hasRelativeLayoutChanged:d,layout:h})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let f=this.options.transition||l.getDefaultTransition()||wTe,{onLayoutAnimationStart:p,onLayoutAnimationComplete:m}=l.getProps(),g=!this.targetLayout||!PX(this.targetLayout,h),y=!c&&d;if(this.options.layoutRoot||this.resumeFrom||y||c&&(g||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let v={...qq(f,"layout"),onPlay:p,onComplete:m};(l.shouldReduceMotion||this.options.layoutRoot)&&(v.delay=0,v.type=!1),this.startAnimation(v),this.setAnimationOrigin(u,y)}else c||A$(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=h})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Nh(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(gTe),this.animationId++)}getTransformTemplate(){let{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&qX(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){let c=this.path[u];c.shouldResetTransform=!0,c.updateScroll("snapshot"),c.options.layoutRoot&&c.willUpdate(!1)}let{layoutId:s,layout:a}=this.options;if(s===void 0&&!a)return;let l=this.getTransformTemplate();this.prevTransformTemplateValue=l?l(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(O$);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(T$);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(fTe),this.nodes.forEach(lTe),this.nodes.forEach(uTe)):this.nodes.forEach(T$),this.clearAllSnapshots();let o=Eo.now();zi.delta=yu(0,1e3/60,o-zi.timestamp),zi.timestamp=o,zi.isProcessing=!0,E2.update.process(zi),E2.preRender.process(zi),E2.render.process(zi),zi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Wq.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(hTe),this.sharedNodes.forEach(yTe)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Fn.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Fn.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Oo(this.snapshot.measuredBox.x)&&!Oo(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let a=0;a<this.path.length;a++)this.path[a].updateScroll();let o=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected=ui(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);let{visualElement:s}=this.options;s&&s.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let s=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(s=!1),s&&this.instance){let a=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:a,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:a}}}resetTransform(){if(!i)return;let o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,s=this.projectionDelta&&!IX(this.projectionDelta),a=this.getTransformTemplate(),l=a?a(this.latestValues,""):void 0,u=l!==this.prevTransformTemplateValue;o&&this.instance&&(s||dp(this.latestValues)||u)&&(i(this.instance,l),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){let s=this.measurePageBox(),a=this.removeElementScroll(s);return o&&(a=this.removeTransform(a)),xTe(a),{animationId:this.root.animationId,measuredBox:s,layoutBox:a,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:o}=this.options;if(!o)return ui();let s=o.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(STe))){let{scroll:a}=this.root;a&&(my(s.x,a.offset.x),my(s.y,a.offset.y))}return s}removeElementScroll(o){let s=ui();if(Ga(s,o),this.scroll?.wasRoot)return s;for(let a=0;a<this.path.length;a++){let l=this.path[a],{scroll:u,options:c}=l;l!==this.root&&u&&c.layoutScroll&&(u.wasRoot&&Ga(s,o),my(s.x,u.offset.x),my(s.y,u.offset.y))}return s}applyTransform(o,s=!1){let a=ui();Ga(a,o);for(let l=0;l<this.path.length;l++){let u=this.path[l];!s&&u.options.layoutScroll&&u.scroll&&u!==u.root&&gy(a,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),dp(u.latestValues)&&gy(a,u.latestValues)}return dp(this.latestValues)&&gy(a,this.latestValues),a}removeTransform(o){let s=ui();Ga(s,o);for(let a=0;a<this.path.length;a++){let l=this.path[a];if(!l.instance||!dp(l.latestValues))continue;rP(l.latestValues)&&l.updateSnapshot();let u=ui(),c=l.measurePageBox();Ga(u,c),w$(s,l.latestValues,l.snapshot?l.snapshot.layoutBox:void 0,u)}return dp(this.latestValues)&&w$(s,this.latestValues),s}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==zi.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){let s=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=s.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=s.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=s.isSharedProjectionDirty);let a=!!this.resumingFrom||this!==s;if(!(o||a&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:l,layoutId:u}=this.options;if(!this.layout||!(l||u))return;this.resolvedRelativeTargetAt=zi.timestamp;let c=this.getClosestProjectingParent();c&&this.linkedParentVersion!==c.layoutVersion&&!c.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(c&&c.layout?this.createRelativeTarget(c,this.layout.layoutBox,c.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=ui(),this.targetWithTransforms=ui()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),HOe(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ga(this.target,this.layout.layoutBox),SX(this.target,this.targetDelta)):Ga(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,c&&!!c.resumingFrom==!!this.resumingFrom&&!c.options.layoutScroll&&c.target&&this.animationProgress!==1?this.createRelativeTarget(c,this.target,c.target):this.relativeParent=this.relativeTarget=void 0),iu.value&&hp.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||rP(this.parent.latestValues)||xX(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(o,s,a){this.relativeParent=o,this.linkedParentVersion=o.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ui(),this.relativeTargetOrigin=ui(),xM(this.relativeTargetOrigin,s,a),Ga(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let o=this.getLead(),s=!!this.resumingFrom||this!==o,a=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(a=!1),s&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(a=!1),this.resolvedRelativeTargetAt===zi.timestamp&&(a=!1),a)return;let{layout:l,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(l||u))return;Ga(this.layoutCorrected,this.layout.layoutBox);let c=this.treeScale.x,d=this.treeScale.y;wOe(this.layoutCorrected,this.treeScale,this.path,s),o.layout&&!o.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(o.target=o.layout.layoutBox,o.targetWithTransforms=ui());let{target:h}=o;if(!h){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(p$(this.prevProjectionDelta.x,this.projectionDelta.x),p$(this.prevProjectionDelta.y,this.projectionDelta.y)),Aw(this.projectionDelta,this.layoutCorrected,h,this.latestValues),(this.treeScale.x!==c||this.treeScale.y!==d||!N$(this.projectionDelta.x,this.prevProjectionDelta.x)||!N$(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",h)),iu.value&&hp.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){if(this.options.visualElement?.scheduleRender(),o){let s=this.getStack();s&&s.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=py(),this.projectionDelta=py(),this.projectionDeltaWithTransform=py()}setAnimationOrigin(o,s=!1){let a=this.snapshot,l=a?a.latestValues:{},u={...this.latestValues},c=py();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!s;let d=ui(),h=a?a.source:void 0,f=this.layout?this.layout.source:void 0,p=h!==f,m=this.getStack(),g=!m||m.members.length<=1,y=!!(p&&!g&&this.options.crossfade===!0&&!this.path.some(bTe));this.animationProgress=0;let v;this.mixTargetDelta=b=>{let w=b/1e3;D$(c.x,o.x,w),D$(c.y,o.y,w),this.setTargetDelta(c),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xM(d,this.layout.layoutBox,this.relativeParent.layout.layoutBox),vTe(this.relativeTarget,this.relativeTargetOrigin,d,w),v&&QOe(this.relativeTarget,v)&&(this.isProjectionDirty=!1),v||(v=ui()),Ga(v,this.relativeTarget)),p&&(this.animationValues=u,JOe(u,l,this.latestValues,w,y,g)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=w},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&(Nh(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Fn.update(()=>{TN.hasAnimatedSinceResize=!0,Dp.layout++,this.motionValue||(this.motionValue=$y(0)),this.currentAnimation=tTe(this.motionValue,[0,1e3],{...o,velocity:0,isSync:!0,onUpdate:s=>{this.mixTargetDelta(s),o.onUpdate&&o.onUpdate(s)},onStop:()=>{Dp.layout--},onComplete:()=>{Dp.layout--,o.onComplete&&o.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(sTe),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let o=this.getLead(),{targetWithTransforms:s,target:a,layout:l,latestValues:u}=o;if(!(!s||!a||!l)){if(this!==o&&this.layout&&l&&FX(this.options.animationType,this.layout.layoutBox,l.layoutBox)){a=this.target||ui();let c=Oo(this.layout.layoutBox.x);a.x.min=o.target.x.min,a.x.max=a.x.min+c;let d=Oo(this.layout.layoutBox.y);a.y.min=o.target.y.min,a.y.max=a.y.min+d}Ga(s,a),gy(s,u),Aw(this.projectionDeltaWithTransform,this.layoutCorrected,s,u)}}registerSharedNode(o,s){this.sharedNodes.has(o)||this.sharedNodes.set(o,new oTe),this.sharedNodes.get(o).add(s);let a=s.options.initialPromotionConfig;s.promote({transition:a?a.transition:void 0,preserveFollowOpacity:a&&a.shouldPreserveFollowOpacity?a.shouldPreserveFollowOpacity(s):void 0})}isLead(){let o=this.getStack();return o?o.lead===this:!0}getLead(){let{layoutId:o}=this.options;return o?this.getStack()?.lead||this:this}getPrevLead(){let{layoutId:o}=this.options;return o?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:s,preserveFollowOpacity:a}={}){let l=this.getStack();l&&l.promote(this,a),o&&(this.projectionDelta=void 0,this.needsReset=!0),s&&this.setOptions({transition:s})}relegate(){let o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){let{visualElement:o}=this.options;if(!o)return;let s=!1,{latestValues:a}=o;if((a.z||a.rotate||a.rotateX||a.rotateY||a.rotateZ||a.skewX||a.skewY)&&(s=!0),!s)return;let l={};a.z&&B2("z",o,l,this.animationValues);for(let u=0;u<L2.length;u++)B2(`rotate${L2[u]}`,o,l,this.animationValues),B2(`skew${L2[u]}`,o,l,this.animationValues);o.render();for(let u in l)o.setStaticValue(u,l[u]),this.animationValues&&(this.animationValues[u]=l[u]);o.scheduleRender()}applyProjectionStyles(o,s){if(!this.instance||this.isSVG)return;if(!this.isVisible){o.visibility="hidden";return}let a=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,o.visibility="",o.opacity="",o.pointerEvents=ON(s?.pointerEvents)||"",o.transform=a?a(this.latestValues,""):"none";return}let l=this.getLead();if(!this.projectionDelta||!this.layout||!l.target){this.options.layoutId&&(o.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,o.pointerEvents=ON(s?.pointerEvents)||""),this.hasProjected&&!dp(this.latestValues)&&(o.transform=a?a({},""):"none",this.hasProjected=!1);return}o.visibility="";let u=l.animationValues||l.latestValues;this.applyTransformsToTarget();let c=GOe(this.projectionDeltaWithTransform,this.treeScale,u);a&&(c=a(u,c)),o.transform=c;let{x:d,y:h}=this.projectionDelta;o.transformOrigin=`${d.origin*100}% ${h.origin*100}% 0`,l.animationValues?o.opacity=l===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:o.opacity=l===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(let f in oP){if(u[f]===void 0)continue;let{correct:p,applyTo:m,isCSSVariable:g}=oP[f],y=c==="none"?u[f]:p(u[f],l);if(m){let v=m.length;for(let b=0;b<v;b++)o[m[b]]=y}else g?this.options.visualElement.renderState.vars[f]=y:o[f]=y}this.options.layoutId&&(o.pointerEvents=l===this?ON(s?.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>o.currentAnimation?.stop()),this.root.nodes.forEach(O$),this.root.sharedNodes.clear()}}}function lTe(e){e.updateLayout()}function uTe(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,o=t.source!==e.layout.source;i==="size"?Jl(c=>{let d=o?t.measuredBox[c]:t.layoutBox[c],h=Oo(d);d.min=n[c].min,d.max=d.min+h}):FX(i,t.layoutBox,n)&&Jl(c=>{let d=o?t.measuredBox[c]:t.layoutBox[c],h=Oo(n[c]);d.max=d.min+h,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[c].max=e.relativeTarget[c].min+h)});let s=py();Aw(s,n,t.layoutBox);let a=py();o?Aw(a,e.applyTransform(r,!0),t.measuredBox):Aw(a,n,t.layoutBox);let l=!IX(s),u=!1;if(!e.resumeFrom){let c=e.getClosestProjectingParent();if(c&&!c.resumeFrom){let{snapshot:d,layout:h}=c;if(d&&h){let f=ui();xM(f,t.layoutBox,d.layoutBox);let p=ui();xM(p,n,h.layoutBox),PX(f,p)||(u=!0),c.options.layoutRoot&&(e.relativeTarget=p,e.relativeTargetOrigin=f,e.relativeParent=c)}}}e.notifyListeners("didUpdate",{layout:n,snapshot:t,delta:a,layoutDelta:s,hasLayoutChanged:l,hasRelativeLayoutChanged:u})}else if(e.isLead()){let{onExitComplete:n}=e.options;n&&n()}e.options.transition=void 0}function cTe(e){iu.value&&hp.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function dTe(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function hTe(e){e.clearSnapshot()}function O$(e){e.clearMeasurements()}function T$(e){e.isLayoutDirty=!1}function fTe(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function A$(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function pTe(e){e.resolveTargetDelta()}function mTe(e){e.calcProjection()}function gTe(e){e.resetSkewAndRotation()}function yTe(e){e.removeLeadSnapshot()}function D$(e,t,n){e.translate=yr(t.translate,0,n),e.scale=yr(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function R$(e,t,n,r){e.min=yr(t.min,n.min,r),e.max=yr(t.max,n.max,r)}function vTe(e,t,n,r){R$(e.x,t.x,n.x,r),R$(e.y,t.y,n.y,r)}function bTe(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var wTe={duration:.45,ease:[.4,0,.1,1]},I$=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),P$=I$("applewebkit/")&&!I$("chrome/")?Math.round:xa;function L$(e){e.min=P$(e.min),e.max=P$(e.max)}function xTe(e){L$(e.x),L$(e.y)}function FX(e,t,n){return e==="position"||e==="preserve-aspect"&&!UOe(C$(t),C$(n),.2)}function STe(e){return e!==e.root&&e.scroll?.wasRoot}var kTe=zX({attachResizeListener:(e,t)=>lx(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),q2={current:void 0},jX=zX({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!q2.current){let e=new kTe({});e.mount(window),e.setOptions({layoutScroll:!0}),q2.current=e}return q2.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),Gq=(0,VX.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});function B$(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function CTe(...e){return t=>{let n=!1,r=e.map(i=>{let o=B$(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){let o=r[i];typeof o=="function"?o():B$(e[i],null)}}}}function NTe(...e){return WX.useCallback(CTe(...e),e)}var MTe=class extends L_.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let n=t.offsetParent,r=tP(n)&&n.offsetWidth||0,i=tP(n)&&n.offsetHeight||0,o=this.props.sizeRef.current;o.height=t.offsetHeight||0,o.width=t.offsetWidth||0,o.top=t.offsetTop,o.left=t.offsetLeft,o.right=r-o.width-o.left,o.bottom=i-o.height-o.top}return null}componentDidUpdate(){}render(){return this.props.children}};function _Te({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:o}){let s=(0,Ac.useId)(),a=(0,Ac.useRef)(null),l=(0,Ac.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:u}=(0,Ac.useContext)(Gq),c=e.props?.ref??e?.ref,d=NTe(a,c);return(0,Ac.useInsertionEffect)(()=>{let{width:h,height:f,top:p,left:m,right:g,bottom:y}=l.current;if(t||o===!1||!a.current||!h||!f)return;let v=n==="left"?`left: ${m}`:`right: ${g}`,b=r==="bottom"?`bottom: ${y}`:`top: ${p}`;a.current.dataset.motionPopId=s;let w=document.createElement("style");u&&(w.nonce=u);let x=i??document.head;return x.appendChild(w),w.sheet&&w.sheet.insertRule(`
[data-motion-pop-id="${s}"] {
position: absolute !important;
width: ${h}px !important;
height: ${f}px !important;
${v}px !important;
${b}px !important;
}
`),()=>{x.contains(w)&&x.removeChild(w)}},[t]),(0,vG.jsx)(MTe,{isPresent:t,childRef:a,sizeRef:l,pop:o,children:o===!1?e:L_.cloneElement(e,{ref:d})})}var ETe=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:o,mode:s,anchorX:a,anchorY:l,root:u})=>{let c=Sq(OTe),d=(0,rx.useId)(),h=!0,f=(0,rx.useMemo)(()=>(h=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:p=>{c.set(p,!0);for(let m of c.values())if(!m)return;r&&r()},register:p=>(c.set(p,!1),()=>c.delete(p))}),[n,c,r]);return o&&h&&(f={...f}),(0,rx.useMemo)(()=>{c.forEach((p,m)=>c.set(m,!1))},[n]),gG.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),e=(0,BI.jsx)(_Te,{pop:s==="popLayout",isPresent:n,anchorX:a,anchorY:l,root:u,children:e}),(0,BI.jsx)(R_.Provider,{value:f,children:e})};function OTe(){return new Map}function UX(e=!0){let t=(0,jh.useContext)(R_);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,o=(0,jh.useId)();(0,jh.useEffect)(()=>{if(e)return i(o)},[e]);let s=(0,jh.useCallback)(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,s]:[!0]}var yC=e=>e.key||"";function q$(e){let t=[];return B_.Children.forEach(e,n=>{(0,B_.isValidElement)(n)&&t.push(n)}),t}var HX=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:o="sync",propagate:s=!1,anchorX:a="left",anchorY:l="top",root:u})=>{let[c,d]=UX(s),h=(0,ul.useMemo)(()=>q$(e),[e]),f=s&&!c?[]:h.map(yC),p=(0,ul.useRef)(!0),m=(0,ul.useRef)(h),g=Sq(()=>new Map),y=(0,ul.useRef)(new Set),[v,b]=(0,ul.useState)(h),[w,x]=(0,ul.useState)(h);mG(()=>{p.current=!1,m.current=h;for(let C=0;C<w.length;C++){let N=yC(w[C]);f.includes(N)?(g.delete(N),y.current.delete(N)):g.get(N)!==!0&&g.set(N,!1)}},[w,f.length,f.join("-")]);let S=[];if(h!==v){let C=[...h];for(let N=0;N<w.length;N++){let E=w[N],D=yC(E);f.includes(D)||(C.splice(N,0,E),S.push(E))}return o==="wait"&&S.length&&(C=S),x(q$(C)),b(h),null}o==="wait"&&w.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);let{forceRender:k}=(0,ul.useContext)(xq);return(0,nx.jsx)(nx.Fragment,{children:w.map(C=>{let N=yC(C),E=s&&!c?!1:h===w||f.includes(N),D=()=>{if(y.current.has(N))return;if(y.current.add(N),g.has(N))g.set(N,!0);else return;let q=!0;g.forEach(z=>{z||(q=!1)}),q&&(k?.(),x(m.current),s&&d?.(),r&&r())};return(0,nx.jsx)(ETe,{isPresent:E,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:u,onExitComplete:E?void 0:D,anchorX:a,anchorY:l,children:C},N)})})},KX=(0,$X.createContext)({strict:!1}),z$={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},F$=!1;function TTe(){if(F$)return;let e={};for(let t in z$)e[t]={isEnabled:n=>z$[t].some(r=>!!n[r])};vX(e),F$=!0}function YX(){return TTe(),gOe()}function ATe(e){let t=YX();for(let n in e)t[n]={...t[n],...e[n]};vX(t)}var DTe=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","propagate","ignoreStrict","viewport"]);function SM(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||DTe.has(e)}var QX=e=>!SM(e);function RTe(e){typeof e=="function"&&(QX=t=>t.startsWith("on")?!SM(t):e(t))}try{RTe(KS("@emotion/is-prop-valid").default)}catch{}function ITe(e,t,n){let r={};for(let i in e)i==="values"&&typeof e.values=="object"||(QX(i)||n===!0&&SM(i)||!t&&!SM(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}var z_=(0,GX.createContext)({});function PTe(e,t){if(P_(e)){let{initial:n,animate:r}=e;return{initial:n===!1||ax(n)?n:void 0,animate:ax(r)?r:void 0}}return e.inherit!==!1?t:{}}function LTe(e){let{initial:t,animate:n}=PTe(e,(0,F_.useContext)(z_));return(0,F_.useMemo)(()=>({initial:t,animate:n}),[j$(t),j$(n)])}function j$(e){return Array.isArray(e)?e.join(" "):e}var Xq=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function JX(e,t,n){for(let r in t)!io(t[r])&&!NX(r,n)&&(e[r]=t[r])}function BTe({transformTemplate:e},t){return(0,XX.useMemo)(()=>{let n=Xq();return Yq(n,t,e),Object.assign({},n.vars,n.style)},[t])}function qTe(e,t){let n=e.style||{},r={};return JX(r,n,e),Object.assign(r,BTe(e,t)),r}function zTe(e,t){let n={},r=qTe(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var eJ=()=>({...Xq(),attrs:{}});function FTe(e,t,n,r){let i=(0,ZX.useMemo)(()=>{let o=eJ();return MX(o,t,EX(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){let o={};JX(o,e.style,e),i.style={...o,...i.style}}return i}var jTe=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Jq(e){return typeof e!="string"||e.includes("-")?!1:!!(jTe.indexOf(e)>-1||/[A-Z]/u.test(e))}function VTe(e,t,n,{latestValues:r},i,o=!1,s){let a=(s??Jq(e)?FTe:zTe)(t,r,i,e),l=ITe(t,typeof e=="string",o),u=e!==bv.Fragment?{...l,...a,ref:n}:{},{children:c}=t,d=(0,bv.useMemo)(()=>io(c)?c.get():c,[c]);return(0,bv.createElement)(e,{...u,children:d})}function WTe({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:UTe(n,r,i,e),renderState:t()}}function UTe(e,t,n,r){let i={},o=r(e,{});for(let h in o)i[h]=ON(o[h]);let{initial:s,animate:a}=e,l=P_(e),u=gX(e);t&&u&&!l&&e.inherit!==!1&&(s===void 0&&(s=t.initial),a===void 0&&(a=t.animate));let c=n?n.initial===!1:!1;c=c||s===!1;let d=c?a:s;if(d&&typeof d!="boolean"&&!I_(d)){let h=Array.isArray(d)?d:[d];for(let f=0;f<h.length;f++){let p=Fq(e,h[f]);if(p){let{transitionEnd:m,transition:g,...y}=p;for(let v in y){let b=y[v];if(Array.isArray(b)){let w=c?b.length-1:0;b=b[w]}b!==null&&(i[v]=b)}for(let v in m)i[v]=m[v]}}}return i}var tJ=e=>(t,n)=>{let r=(0,sP.useContext)(z_),i=(0,sP.useContext)(R_),o=()=>WTe(e,t,r,i);return n?o():Sq(o)},HTe=tJ({scrapeMotionValuesFromProps:Qq,createRenderState:Xq}),$Te=tJ({scrapeMotionValuesFromProps:OX,createRenderState:eJ}),KTe=Symbol.for("motionComponentSymbol");function YTe(e,t,n){let r=(0,Up.useRef)(n);(0,Up.useInsertionEffect)(()=>{r.current=n});let i=(0,Up.useRef)(null);return(0,Up.useCallback)(o=>{o&&e.onMount?.(o),t&&(o?t.mount(o):t.unmount());let s=r.current;if(typeof s=="function")if(o){let a=s(o);typeof a=="function"&&(i.current=a)}else i.current?(i.current(),i.current=null):s(o);else s&&(s.current=o)},[t])}var rJ=(0,nJ.createContext)({});function Xg(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function QTe(e,t,n,r,i,o){let{visualElement:s}=(0,Co.useContext)(z_),a=(0,Co.useContext)(KX),l=(0,Co.useContext)(R_),u=(0,Co.useContext)(Gq),c=u.reducedMotion,d=u.skipAnimations,h=(0,Co.useRef)(null),f=(0,Co.useRef)(!1);r=r||a.renderer,!h.current&&r&&(h.current=r(e,{visualState:t,parent:s,props:n,presenceContext:l,blockInitialAnimation:l?l.initial===!1:!1,reducedMotionConfig:c,skipAnimations:d,isSVG:o}),f.current&&h.current&&(h.current.manuallyAnimateOnMount=!0));let p=h.current,m=(0,Co.useContext)(rJ);p&&!p.projection&&i&&(p.type==="html"||p.type==="svg")&&GTe(h.current,n,i,m);let g=(0,Co.useRef)(!1);(0,Co.useInsertionEffect)(()=>{p&&g.current&&p.update(n,l)});let y=n[rX],v=(0,Co.useRef)(!!y&&!window.MotionHandoffIsComplete?.(y)&&window.MotionHasOptimisedAnimation?.(y));return mG(()=>{f.current=!0,p&&(g.current=!0,window.MotionIsMounted=!0,p.updateFeatures(),p.scheduleRenderMicrotask(),v.current&&p.animationState&&p.animationState.animateChanges())}),(0,Co.useEffect)(()=>{p&&(!v.current&&p.animationState&&p.animationState.animateChanges(),v.current&&(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(y)}),v.current=!1),p.enteringChildren=void 0)}),p}function GTe(e,t,n,r){let{layoutId:i,layout:o,drag:s,dragConstraints:a,layoutScroll:l,layoutRoot:u,layoutCrossfade:c}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:iJ(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!s||a&&Xg(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:c,layoutScroll:l,layoutRoot:u})}function iJ(e){if(e)return e.options.allowProjection!==!1?e.projection:iJ(e.parent)}function z2(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&ATe(r);let o=n?n==="svg":Jq(e),s=o?$Te:HTe;function a(u,c){let d,h={...(0,vv.useContext)(Gq),...u,layoutId:XTe(u)},{isStatic:f}=h,p=LTe(u),m=s(u,f);if(!f&&pG){JTe(h,r);let g=ZTe(h);d=g.MeasureLayout,p.visualElement=QTe(e,m,h,i,g.ProjectionNode,o)}return(0,q_.jsxs)(z_.Provider,{value:p,children:[d&&p.visualElement?(0,q_.jsx)(d,{visualElement:p.visualElement,...h}):null,VTe(e,u,YTe(m,p.visualElement,c),m,f,t,o)]})}a.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;let l=(0,vv.forwardRef)(a);return l[KTe]=e,l}function XTe({layoutId:e}){let t=(0,vv.useContext)(xq).id;return t&&e!==void 0?t+"-"+e:e}function JTe(e,t){let n=(0,vv.useContext)(KX).strict;if(t&&n){let r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?pv(!1,r,"lazy-strict-mode"):Oc(!1,r,"lazy-strict-mode")}}function ZTe(e){let t=YX(),{drag:n,layout:r}=t;if(!n&&!r)return{};let i={...n,...r};return{MeasureLayout:n?.isEnabled(e)||r?.isEnabled(e)?i.MeasureLayout:void 0,ProjectionNode:i.ProjectionNode}}function eAe(e,t){if(typeof Proxy>"u")return z2;let n=new Map,r=(o,s)=>z2(o,s,e,t),i=(o,s)=>(Mq(!1,"motion() is deprecated. Use motion.create() instead."),r(o,s));return new Proxy(i,{get:(o,s)=>s==="create"?r:(n.has(s)||n.set(s,z2(s,void 0,e,t)),n.get(s))})}var tAe=(e,t)=>t.isSVG??Jq(e)?new ROe(t):new _Oe(t,{allowProjection:e!==oJ.Fragment}),nAe=class extends Fh{constructor(e){super(e),e.animationState||(e.animationState=qOe(e))}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();I_(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},rAe=0,iAe=class extends Fh{constructor(){super(...arguments),this.id=rAe++}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;let r=this.node.animationState.setActive("exit",!e);t&&!e&&r.then(()=>{t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}},oAe={animation:{Feature:nAe},exit:{Feature:iAe}};function Jx(e){return{point:{x:e.pageX,y:e.pageY}}}var sAe=e=>t=>Uq(t)&&e(t,Jx(t));function Dw(e,t,n,r){return lx(e,t,sAe(n),r)}var sJ=({current:e})=>e?e.ownerDocument.defaultView:null,V$=(e,t)=>Math.abs(e-t);function aAe(e,t){let n=V$(e.x,t.x),r=V$(e.y,t.y);return Math.sqrt(n**2+r**2)}var W$=new Set(["auto","scroll"]),aJ=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:o=3,element:s}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=h=>{this.handleScroll(h.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let h=j2(this.lastMoveEventInfo,this.history),f=this.startEvent!==null,p=aAe(h.offset,{x:0,y:0})>=this.distanceThreshold;if(!f&&!p)return;let{point:m}=h,{timestamp:g}=zi;this.history.push({...m,timestamp:g});let{onStart:y,onMove:v}=this.handlers;f||(y&&y(this.lastMoveEvent,h),this.startEvent=this.lastMoveEvent),v&&v(this.lastMoveEvent,h)},this.handlePointerMove=(h,f)=>{this.lastMoveEvent=h,this.lastMoveEventInfo=F2(f,this.transformPagePoint),Fn.update(this.updatePoint,!0)},this.handlePointerUp=(h,f)=>{this.end();let{onEnd:p,onSessionEnd:m,resumeAnimation:g}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&g&&g(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let y=j2(h.type==="pointercancel"?this.lastMoveEventInfo:F2(f,this.transformPagePoint),this.history);this.startEvent&&p&&p(h,y),m&&m(h,y)},!Uq(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=o,this.contextWindow=r||window;let a=Jx(e),l=F2(a,this.transformPagePoint),{point:u}=l,{timestamp:c}=zi;this.history=[{...u,timestamp:c}];let{onSessionStart:d}=t;d&&d(e,j2(l,this.history)),this.removeListeners=Qx(Dw(this.contextWindow,"pointermove",this.handlePointerMove),Dw(this.contextWindow,"pointerup",this.handlePointerUp),Dw(this.contextWindow,"pointercancel",this.handlePointerUp)),s&&this.startScrollTracking(s)}startScrollTracking(e){let t=e.parentElement;for(;t;){let n=getComputedStyle(t);(W$.has(n.overflowX)||W$.has(n.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener("scroll",this.onElementScroll,{capture:!0,passive:!0}),window.addEventListener("scroll",this.onWindowScroll,{passive:!0}),this.removeScrollListeners=()=>{window.removeEventListener("scroll",this.onElementScroll,{capture:!0}),window.removeEventListener("scroll",this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Fn.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Nh(this.updatePoint)}};function F2(e,t){return t?{point:t(e.point)}:e}function U$(e,t){return{x:e.x-t.x,y:e.y-t.y}}function j2({point:e},t){return{point:e,delta:U$(e,lJ(t)),offset:U$(e,lAe(t)),velocity:uAe(t,.1)}}function lAe(e){return e[0]}function lJ(e){return e[e.length-1]}function uAe(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=lJ(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Sa(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Sa(t)*2&&(r=e[1]);let o=ya(i.timestamp-r.timestamp);if(o===0)return{x:0,y:0};let s={x:(i.x-r.x)/o,y:(i.y-r.y)/o};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function cAe(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?yr(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?yr(n,e,r.max):Math.min(e,n)),e}function H$(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function dAe(e,{top:t,left:n,bottom:r,right:i}){return{x:H$(e.x,n,i),y:H$(e.y,t,r)}}function $$(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function hAe(e,t){return{x:$$(e.x,t.x),y:$$(e.y,t.y)}}function fAe(e,t){let n=.5,r=Oo(e),i=Oo(t);return i>r?n=ix(t.min,t.max-r,e.min):r>i&&(n=ix(e.min,e.max-i,t.min)),yu(0,1,n)}function pAe(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var aP=.35;function mAe(e=aP){return e===!1?e=0:e===!0&&(e=aP),{x:K$(e,"left","right"),y:K$(e,"top","bottom")}}function K$(e,t,n){return{min:Y$(e,t),max:Y$(e,n)}}function Y$(e,t){return typeof e=="number"?e:e[t]||0}var gAe=new WeakMap,yAe=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ui(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=c=>{t&&this.snapToCursor(Jx(c).point),this.stopAnimation()},o=(c,d)=>{let{drag:h,dragPropagation:f,onDragStart:p}=this.getProps();if(h&&!f&&(this.openDragLock&&this.openDragLock(),this.openDragLock=$Ee(h),!this.openDragLock))return;this.latestPointerEvent=c,this.latestPanInfo=d,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Jl(g=>{let y=this.getAxisMotionValue(g).get()||0;if(hu.test(y)){let{projection:v}=this.visualElement;if(v&&v.layout){let b=v.layout.layoutBox[g];b&&(y=Oo(b)*(parseFloat(y)/100))}}this.originPoint[g]=y}),p&&Fn.update(()=>p(c,d),!1,!0),JI(this.visualElement,"transform");let{animationState:m}=this.visualElement;m&&m.setActive("whileDrag",!0)},s=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d;let{dragPropagation:h,dragDirectionLock:f,onDirectionLock:p,onDrag:m}=this.getProps();if(!h&&!this.openDragLock)return;let{offset:g}=d;if(f&&this.currentDirection===null){this.currentDirection=bAe(g),this.currentDirection!==null&&p&&p(this.currentDirection);return}this.updateAxis("x",d.point,g),this.updateAxis("y",d.point,g),this.visualElement.render(),m&&Fn.update(()=>m(c,d),!1,!0)},a=(c,d)=>{this.latestPointerEvent=c,this.latestPanInfo=d,this.stop(c,d),this.latestPointerEvent=null,this.latestPanInfo=null},l=()=>{let{dragSnapToOrigin:c}=this.getProps();(c||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:u}=this.getProps();this.panSession=new aJ(e,{onSessionStart:i,onStart:o,onMove:s,onSessionEnd:a,resumeAnimation:l},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:n,contextWindow:sJ(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:o}=r;this.startAnimation(o);let{onDragEnd:s}=this.getProps();s&&Fn.postRender(()=>s(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive("whileDrag",!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!vC(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),o=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(o=cAe(o,this.constraints[e],this.elastic[e])),i.set(o)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Xg(e)?this.constraints||(this.constraints=this.resolveRefConstraints()):e&&n?this.constraints=dAe(n.layoutBox,e):this.constraints=!1,this.elastic=mAe(t),r!==this.constraints&&!Xg(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Jl(i=>{this.constraints!==!1&&this.getAxisMotionValue(i)&&(this.constraints[i]=pAe(n.layoutBox[i],this.constraints[i]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Xg(e))return!1;let n=e.current;Oc(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=xOe(n,r.root,this.visualElement.getTransformPagePoint()),o=hAe(r.layout.layoutBox,i);if(t){let s=t(vOe(o));this.hasMutatedConstraints=!!s,s&&(o=wX(s))}return o}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:s}=this.getProps(),a=this.constraints||{},l=Jl(u=>{if(!vC(u,t,this.currentDirection))return;let c=a&&a[u]||{};o&&(c={min:0,max:0});let d=r?200:1e6,h=r?40:1e7,f={type:"inertia",velocity:n?e[u]:0,bounceStiffness:d,bounceDamping:h,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(u,f)});return Promise.all(l).then(s)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return JI(this.visualElement,e),n.start(zq(e,n,0,t,this.visualElement,!1))}stopAnimation(){Jl(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){Jl(t=>{let{drag:n}=this.getProps();if(!vC(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:o,max:s}=r.layout.layoutBox[t],a=i.get()||0;i.set(e[t]-yr(o,s,.5)+a)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Xg(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Jl(o=>{let s=this.getAxisMotionValue(o);if(s&&this.constraints!==!1){let a=s.get();r[o]=fAe({min:a,max:a},this.constraints[o])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Jl(o=>{if(!vC(o,e,null))return;let s=this.getAxisMotionValue(o),{min:a,max:l}=this.constraints[o];s.set(yr(a,l,r[o]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;gAe.set(this.visualElement,this);let e=this.visualElement.current,t=Dw(e,"pointerdown",l=>{let{drag:u,dragListener:c=!0}=this.getProps(),d=l.target,h=d!==e&&JEe(d);u&&c&&!h&&this.start(l)}),n,r=()=>{let{dragConstraints:l}=this.getProps();Xg(l)&&l.current&&(this.constraints=this.resolveRefConstraints(),n||(n=vAe(e,l.current,()=>this.scalePositionWithinConstraints())))},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Fn.read(r);let s=lx(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:u})=>{this.isDragging&&u&&(Jl(c=>{let d=this.getAxisMotionValue(c);d&&(this.originPoint[c]+=l[c].translate,d.set(d.get()+l[c].translate))}),this.visualElement.render())});return()=>{s(),t(),o(),a&&a(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:o=aP,dragMomentum:s=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:o,dragMomentum:s}}};function Q$(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function vAe(e,t,n){let r=n$(e,Q$(n)),i=n$(t,Q$(n));return()=>{r(),i()}}function vC(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function bAe(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}var wAe=class extends Fh{constructor(e){super(e),this.removeGroupControls=xa,this.removeListeners=xa,this.controls=new yAe(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||xa}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},V2=e=>(t,n)=>{e&&Fn.update(()=>e(t,n),!1,!0)},xAe=class extends Fh{constructor(){super(...arguments),this.removePointerDownListener=xa}onPointerDown(e){this.session=new aJ(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:sJ(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:V2(e),onStart:V2(t),onMove:V2(n),onEnd:(i,o)=>{delete this.session,r&&Fn.postRender(()=>r(i,o))}}}mount(){this.removePointerDownListener=Dw(this.node.current,"pointerdown",e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},W2=!1,SAe=class extends ux.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),W2&&i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),TN.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:o}=n;return o&&(o.isPresent=i,e.layoutDependency!==t&&o.setOptions({...o.options,layoutDependency:t}),W2=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?o.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?o.promote():o.relegate()||Fn.postRender(()=>{let s=o.getStack();(!s||!s.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){let{projection:e}=this.props.visualElement;e&&(e.root.didUpdate(),Wq.postRender(()=>{!e.currentAnimation&&e.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;W2=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function cJ(e){let[t,n]=UX(),r=(0,ux.useContext)(xq);return(0,uJ.jsx)(SAe,{...e,layoutGroup:r,switchLayoutGroup:(0,ux.useContext)(rJ),isPresent:t,safeToRemove:n})}var kAe={pan:{Feature:xAe},drag:{Feature:wAe,ProjectionNode:jX,MeasureLayout:cJ}};function G$(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");let i="onHover"+n,o=r[i];o&&Fn.postRender(()=>o(t,Jx(t)))}var CAe=class extends Fh{mount(){let{current:e}=this.node;e&&(this.unmount=YEe(e,(t,n)=>(G$(this.node,n,"Start"),r=>G$(this.node,r,"End"))))}unmount(){}},NAe=class extends Fh{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(":focus-visible")}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Qx(lx(this.node.current,"focus",()=>this.onFocus()),lx(this.node.current,"blur",()=>this.onBlur()))}unmount(){}};function X$(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");let i="onTap"+(n==="End"?"":n),o=r[i];o&&Fn.postRender(()=>o(t,Jx(t)))}var MAe=class extends Fh{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=eOe(e,(r,i)=>(X$(this.node,i,"Start"),(o,{success:s})=>X$(this.node,o,s?"End":"Cancel")),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},lP=new WeakMap,U2=new WeakMap,_Ae=e=>{let t=lP.get(e.target);t&&t(e)},EAe=e=>{e.forEach(_Ae)};function OAe({root:e,...t}){let n=e||document;U2.has(n)||U2.set(n,{});let r=U2.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(EAe,{root:e,...t})),r[i]}function TAe(e,t,n){let r=OAe(t);return lP.set(e,n),r.observe(e),()=>{lP.delete(e),r.unobserve(e)}}var AAe={some:0,all:1},DAe=class extends Fh{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r="some",once:i}=e,o={root:t?t.current:void 0,rootMargin:n,threshold:typeof r=="number"?r:AAe[r]},s=a=>{let{isIntersecting:l}=a;if(this.isInView===l||(this.isInView=l,i&&!l&&this.hasEnteredView))return;l&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",l);let{onViewportEnter:u,onViewportLeave:c}=this.node.getProps(),d=l?u:c;d&&d(a)};return TAe(this.node.current,o,s)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;let{props:e,prevProps:t}=this.node;["amount","margin","root"].some(RAe(e,t))&&this.startObserver()}unmount(){}};function RAe({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var IAe={inView:{Feature:DAe},tap:{Feature:MAe},focus:{Feature:NAe},hover:{Feature:CAe}},PAe={layout:{ProjectionNode:jX,MeasureLayout:cJ}},LAe={...oAe,...IAe,...kAe,...PAe},uP=eAe(LAe,tAe),wv=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},BAe={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},qAe=class{#e=BAe;#t=!1;setTimeoutProvider(e){this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,this.#t=!1}setTimeout(e,t){return this.#t=!0,this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#t=!0,this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},Sp=new qAe;function zAe(e){setTimeout(e,0)}var Hp=typeof window>"u"||"Deno"in globalThis;function xo(){}function FAe(e,t){return typeof e=="function"?e(t):e}function cP(e){return typeof e=="number"&&e>=0&&e!==1/0}function dJ(e,t){return Math.max(e+(t||0)-Date.now(),0)}function yh(e,t){return typeof e=="function"?e(t):e}function la(e,t){return typeof e=="function"?e(t):e}function J$(e,t){let{type:n="all",exact:r,fetchStatus:i,predicate:o,queryKey:s,stale:a}=e;if(s){if(r){if(t.queryHash!==Zq(s,t.options))return!1}else if(!cx(t.queryKey,s))return!1}if(n!=="all"){let l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||o&&!o(t))}function Z$(e,t){let{exact:n,status:r,predicate:i,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(il(t.options.mutationKey)!==il(o))return!1}else if(!cx(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Zq(e,t){return(t?.queryKeyHashFn||il)(e)}function il(e){return JSON.stringify(e,(t,n)=>dP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function cx(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>cx(e[n],t[n])):!1}var jAe=Object.prototype.hasOwnProperty;function kM(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=e8(e)&&e8(t);if(!r&&!(dP(e)&&dP(t)))return t;let i=(r?e:Object.keys(e)).length,o=r?t:Object.keys(t),s=o.length,a=r?new Array(s):{},l=0;for(let u=0;u<s;u++){let c=r?u:o[u],d=e[c],h=t[c];if(d===h){a[c]=d,(r?u<i:jAe.call(e,c))&&l++;continue}if(d===null||h===null||typeof d!="object"||typeof h!="object"){a[c]=h;continue}let f=kM(d,h,n+1);a[c]=f,f===d&&l++}return i===s&&l===i?e:a}function CM(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function e8(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function dP(e){if(!t8(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!t8(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function t8(e){return Object.prototype.toString.call(e)==="[object Object]"}function VAe(e){return new Promise(t=>{Sp.setTimeout(t,e)})}function hP(e,t,n){if(typeof n.structuralSharing=="function")return n.structuralSharing(e,t);if(n.structuralSharing!==!1){try{return kM(e,t)}catch(r){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${n.queryHash}]: ${r}`),r}return kM(e,t)}return t}function WAe(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function UAe(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var NM=Symbol();function hJ(e,t){return e.queryFn===NM&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===NM?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function ez(e,t){return typeof e=="function"?e(...t):!!e}function HAe(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var $Ae=class extends wv{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!Hp&&window.addEventListener){let t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},tz=new $Ae;function fP(){let e,t,n=new Promise((i,o)=>{e=i,t=o});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var KAe=zAe;function YAe(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=KAe,o=a=>{t?e.push(a):i(()=>{n(a)})},s=()=>{let a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||s()}return l},batchCalls:a=>(...l)=>{o(()=>{a(...l)})},schedule:o,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var Rr=YAe(),QAe=class extends wv{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!Hp&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",n,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}},MM=new QAe;function GAe(e){return Math.min(1e3*2**e,3e4)}function fJ(e){return(e??"online")==="online"?MM.isOnline():!0}var pP=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function pJ(e){let t=!1,n=0,r,i=fP(),o=()=>i.status!=="pending",s=m=>{if(!o()){let g=new pP(m);h(g),e.onCancel?.(g)}},a=()=>{t=!0},l=()=>{t=!1},u=()=>tz.isFocused()&&(e.networkMode==="always"||MM.isOnline())&&e.canRun(),c=()=>fJ(e.networkMode)&&e.canRun(),d=m=>{o()||(r?.(),i.resolve(m))},h=m=>{o()||(r?.(),i.reject(m))},f=()=>new Promise(m=>{r=g=>{(o()||u())&&m(g)},e.onPause?.()}).then(()=>{r=void 0,o()||e.onContinue?.()}),p=()=>{if(o())return;let m,g=n===0?e.initialPromise:void 0;try{m=g??e.fn()}catch(y){m=Promise.reject(y)}Promise.resolve(m).then(d).catch(y=>{if(o())return;let v=e.retry??(Hp?0:3),b=e.retryDelay??GAe,w=typeof b=="function"?b(n,y):b,x=v===!0||typeof v=="number"&&n<v||typeof v=="function"&&v(n,y);if(t||!x){h(y);return}n++,e.onFail?.(n,y),VAe(w).then(()=>u()?void 0:f()).then(()=>{t?h(y):p()})})};return{promise:i,status:()=>i.status,cancel:s,continue:()=>(r?.(),i),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?p():f().then(p),i)}}var mJ=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),cP(this.gcTime)&&(this.#e=Sp.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Hp?1/0:300*1e3))}clearGcTimeout(){this.#e&&(Sp.clearTimeout(this.#e),this.#e=void 0)}},XAe=class extends mJ{#e;#t;#n;#r;#i;#s;#a;constructor(e){super(),this.#a=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=r8(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let t=r8(this.options);t.data!==void 0&&(this.setState(n8(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(e,t){let n=hP(this.state.data,e,this.options);return this.#o({data:n,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#o({type:"setState",state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(xo).catch(xo):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>la(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===NM||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>yh(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:!dJ(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#a?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#o({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#i?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let s=this.observers.find(a=>a.options.queryFn);s&&this.setOptions(s.options)}Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']");let n=new AbortController,r=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,n.signal)})},i=()=>{let s=hJ(this.options,t),a=(()=>{let l={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(l),l})();return this.#a=!1,this.options.persister?this.options.persister(s,a,this):s(a)},o=(()=>{let s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(s),s})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#o({type:"fetch",meta:o.fetchOptions?.meta}),this.#i=pJ({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:s=>{s instanceof pP&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),n.abort()},onFail:(s,a)=>{this.#o({type:"failed",failureCount:s,error:a})},onPause:()=>{this.#o({type:"pause"})},onContinue:()=>{this.#o({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{let s=await this.#i.start();if(s===void 0)throw console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#n.config.onSuccess?.(s,this),this.#n.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof pP){if(s.silent)return this.#i.promise;if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#o({type:"error",error:s}),this.#n.config.onError?.(s,this),this.#n.config.onSettled?.(this.state.data,s,this),s}finally{this.scheduleGc()}}#o(e){let t=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,...gJ(n.data,this.options),fetchMeta:e.meta??null};case"success":let r={...n,...n8(e.data,e.dataUpdatedAt),dataUpdateCount:n.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?r:void 0,r;case"error":let i=e.error;return{...n,error:i,errorUpdateCount:n.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:n.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...n,isInvalidated:!0};case"setState":return{...n,...e.state}}};this.state=t(this.state),Rr.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:e})})}};function gJ(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:fJ(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function n8(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function r8(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var yJ=class extends wv{constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.#a=fP(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#s;#a;#o;#l;#u;#c;#h;#f;#d;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),i8(this.#t,this.options)?this.#p():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return mP(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return mP(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#w(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof la(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#S(),this.#t.setOptions(this.options),t._defaulted&&!CM(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});let r=this.hasListeners();r&&o8(this.#t,n,this.options,t)&&this.#p(),this.updateResult(),r&&(this.#t!==n||la(this.options.enabled,this.#t)!==la(t.enabled,this.#t)||yh(this.options.staleTime,this.#t)!==yh(t.staleTime,this.#t))&&this.#g();let i=this.#y();r&&(this.#t!==n||la(this.options.enabled,this.#t)!==la(t.enabled,this.#t)||i!==this.#d)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return ZAe(this,n)&&(this.#r=n,this.#s=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(n,r)=>(this.trackProp(r),t?.(r),r==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(n,r))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#p({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#p(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(xo)),t}#g(){this.#w();let e=yh(this.options.staleTime,this.#t);if(Hp||this.#r.isStale||!cP(e))return;let t=dJ(this.#r.dataUpdatedAt,e)+1;this.#h=Sp.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#d=e,!(Hp||la(this.options.enabled,this.#t)===!1||!cP(this.#d)||this.#d===0)&&(this.#f=Sp.setInterval(()=>{(this.options.refetchIntervalInBackground||tz.isFocused())&&this.#p()},this.#d))}#b(){this.#g(),this.#v(this.#y())}#w(){this.#h&&(Sp.clearTimeout(this.#h),this.#h=void 0)}#x(){this.#f&&(Sp.clearInterval(this.#f),this.#f=void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,o=this.#i,s=this.#s,a=e!==n?e.state:this.#n,{state:l}=e,u={...l},c=!1,d;if(t._optimisticResults){let S=this.hasListeners(),k=!S&&i8(e,t),C=S&&o8(e,n,t,r);(k||C)&&(u={...u,...gJ(l.data,e.options)}),t._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:h,errorUpdatedAt:f,status:p}=u;d=u.data;let m=!1;if(t.placeholderData!==void 0&&d===void 0&&p==="pending"){let S;i?.isPlaceholderData&&t.placeholderData===s?.placeholderData?(S=i.data,m=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#c?.state.data,this.#c):t.placeholderData,S!==void 0&&(p="success",d=hP(i?.data,S,t),c=!0)}if(t.select&&d!==void 0&&!m)if(i&&d===o?.data&&t.select===this.#l)d=this.#u;else try{this.#l=t.select,d=t.select(d),d=hP(i?.data,d,t),this.#u=d,this.#o=null}catch(S){this.#o=S}this.#o&&(h=this.#o,d=this.#u,f=Date.now(),p="error");let g=u.fetchStatus==="fetching",y=p==="pending",v=p==="error",b=y&&g,w=d!==void 0,x={status:p,fetchStatus:u.fetchStatus,isPending:y,isSuccess:p==="success",isError:v,isInitialLoading:b,isLoading:b,data:d,dataUpdatedAt:u.dataUpdatedAt,error:h,errorUpdatedAt:f,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>a.dataUpdateCount||u.errorUpdateCount>a.errorUpdateCount,isFetching:g,isRefetching:g&&!y,isLoadingError:v&&!w,isPaused:u.fetchStatus==="paused",isPlaceholderData:c,isRefetchError:v&&w,isStale:nz(e,t),refetch:this.refetch,promise:this.#a,isEnabled:la(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let S=x.data!==void 0,k=x.status==="error"&&!S,C=D=>{k?D.reject(x.error):S&&D.resolve(x.data)},N=()=>{let D=this.#a=x.promise=fP();C(D)},E=this.#a;switch(E.status){case"pending":e.queryHash===n.queryHash&&C(E);break;case"fulfilled":(k||x.data!==E.value)&&N();break;case"rejected":(!k||x.error!==E.reason)&&N();break}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#s=this.options,this.#i.data!==void 0&&(this.#c=this.#t),CM(t,e))return;this.#r=t;let n=()=>{if(!e)return!0;let{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#m.size)return!0;let o=new Set(i??this.#m);return this.options.throwOnError&&o.add("error"),Object.keys(this.#r).some(s=>{let a=s;return this.#r[a]!==e[a]&&o.has(a)})};this.#k({listeners:n()})}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#k(e){Rr.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function JAe(e,t){return la(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function i8(e,t){return JAe(e,t)||e.state.data!==void 0&&mP(e,t,t.refetchOnMount)}function mP(e,t,n){if(la(t.enabled,e)!==!1&&yh(t.staleTime,e)!=="static"){let r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&nz(e,t)}return!1}function o8(e,t,n,r){return(e!==t||la(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&nz(e,n)}function nz(e,t){return la(t.enabled,e)!==!1&&e.isStaleByTime(yh(t.staleTime,e))}function ZAe(e,t){return!CM(e.getCurrentResult(),t)}function s8(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,o=t.state.data?.pages||[],s=t.state.data?.pageParams||[],a={pages:[],pageParams:[]},l=0,u=async()=>{let c=!1,d=p=>{HAe(p,()=>t.signal,()=>c=!0)},h=hJ(t.options,t.fetchOptions),f=async(p,m,g)=>{if(c)return Promise.reject();if(m==null&&p.pages.length)return Promise.resolve(p);let y=(()=>{let x={client:t.client,queryKey:t.queryKey,pageParam:m,direction:g?"backward":"forward",meta:t.options.meta};return d(x),x})(),v=await h(y),{maxPages:b}=t.options,w=g?UAe:WAe;return{pages:w(p.pages,v,b),pageParams:w(p.pageParams,m,b)}};if(i&&o.length){let p=i==="backward",m=p?eDe:a8,g={pages:o,pageParams:s},y=m(r,g);a=await f(g,y,p)}else{let p=e??o.length;do{let m=l===0?s[0]??r.initialPageParam:a8(r,a);if(l>0&&m==null)break;a=await f(a,m),l++}while(l<p)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):t.fetchFn=u}}}function a8(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function eDe(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var tDe=class extends mJ{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||vJ(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:"continue"})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=pJ({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(new Error("No mutationFn found")),onFail:(o,s)=>{this.#i({type:"failed",failureCount:o,error:s})},onPause:()=>{this.#i({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status==="pending",i=!this.#r.canStart();try{if(r)t();else{this.#i({type:"pending",variables:e,isPaused:i}),await this.#n.config.onMutate?.(e,this,n);let s=await this.options.onMutate?.(e,n);s!==this.state.context&&this.#i({type:"pending",context:s,variables:e,isPaused:i})}let o=await this.#r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:"success",data:o}),o}catch(o){try{await this.#n.config.onError?.(o,e,this.state.context,this,n)}catch(s){Promise.reject(s)}try{await this.options.onError?.(o,e,this.state.context,n)}catch(s){Promise.reject(s)}try{await this.#n.config.onSettled?.(void 0,o,this.state.variables,this.state.context,this,n)}catch(s){Promise.reject(s)}try{await this.options.onSettled?.(void 0,o,e,this.state.context,n)}catch(s){Promise.reject(s)}throw this.#i({type:"error",error:o}),o}finally{this.#n.runNext(this)}}#i(e){let t=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=t(this.state),Rr.batch(()=>{this.#t.forEach(n=>{n.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:"updated",action:e})})}};function vJ(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var nDe=class extends wv{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new tDe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=bC(e);if(typeof t=="string"){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){let t=bC(e);if(typeof t=="string"){let n=this.#t.get(t);if(n)if(n.length>1){let r=n.indexOf(e);r!==-1&&n.splice(r,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=bC(e);if(typeof t=="string"){let n=this.#t.get(t)?.find(r=>r.state.status==="pending");return!n||n===e}else return!0}runNext(e){let t=bC(e);return typeof t=="string"?this.#t.get(t)?.find(n=>n!==e&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Rr.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(n=>Z$(t,n))}findAll(e={}){return this.getAll().filter(t=>Z$(e,t))}notify(e){Rr.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(t=>t.state.isPaused);return Rr.batch(()=>Promise.all(e.map(t=>t.continue().catch(xo))))}};function bC(e){return e.options.scope?.id}var rDe=class extends wv{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),CM(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&il(t.mutationKey)!==il(this.options.mutationKey)?this.reset():this.#n?.state.status==="pending"&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#s(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#s()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??vJ();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#s(e){Rr.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type==="success"){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(i){Promise.reject(i)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(i){Promise.reject(i)}}else if(e?.type==="error"){try{this.#r.onError?.(e.error,t,n,r)}catch(i){Promise.reject(i)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(i){Promise.reject(i)}}}this.listeners.forEach(t=>{t(this.#t)})})}},iDe=class extends wv{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Zq(r,t),o=this.get(i);return o||(o=new XAe({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(o)),o}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){Rr.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(n=>J$(t,n))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(n=>J$(e,n)):t}notify(e){Rr.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Rr.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Rr.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},oDe=class{#e;#t;#n;#r;#i;#s;#a;#o;constructor(e={}){this.#e=e.queryCache||new iDe,this.#t=e.mutationCache||new nDe,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=tz.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#o=MM.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#a?.(),this.#a=void 0,this.#o?.(),this.#o=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(yh(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:n})=>{let r=n.data;return[t,r]})}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,o=FAe(t,i);if(o!==void 0)return this.#e.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(e,t,n){return Rr.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Rr.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){let n=this.#e;return Rr.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Rr.batch(()=>this.#e.findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(xo).catch(xo)}invalidateQueries(e,t={}){return Rr.batch(()=>(this.#e.findAll(e).forEach(n=>{n.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Rr.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let o=i.fetch(void 0,n);return n.throwOnError||(o=o.catch(xo)),i.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(r).then(xo)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(yh(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(xo).catch(xo)}fetchInfiniteQuery(e){return e.behavior=s8(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(xo).catch(xo)}ensureInfiniteQueryData(e){return e.behavior=s8(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return MM.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(il(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(r=>{cx(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(il(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(r=>{cx(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Zq(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===NM&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},wJ=xv.createContext(void 0),Zx=e=>{let t=xv.useContext(wJ);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},sDe=({client:e,children:t})=>(xv.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,bJ.jsx)(wJ.Provider,{value:e,children:t})),xJ=j_.createContext(!1),aDe=()=>j_.useContext(xJ),nyt=xJ.Provider;function lDe(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var uDe=V_.createContext(lDe()),cDe=()=>V_.useContext(uDe),dDe=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError=="function"?ez(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},hDe=e=>{SJ.useEffect(()=>{e.clearReset()},[e])},fDe=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||ez(n,[e.error,r])),pDe=e=>{if(e.suspense){let t=r=>r==="static"?r:Math.max(r??1e3,1e3),n=e.staleTime;e.staleTime=typeof n=="function"?(...r)=>t(n(...r)):t(n),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},mDe=(e,t)=>e.isLoading&&e.isFetching&&!t,gDe=(e,t)=>e?.suspense&&t.isPending,l8=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function yDe(e,t,n){if(typeof e!="object"||Array.isArray(e))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let r=aDe(),i=cDe(),o=Zx(n),s=o.defaultQueryOptions(e);o.getDefaultOptions().queries?._experimental_beforeQuery?.(s);let a=o.getQueryCache().get(s.queryHash);s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`),s._optimisticResults=r?"isRestoring":"optimistic",pDe(s),dDe(s,i,a),hDe(i);let l=!o.getQueryCache().get(s.queryHash),[u]=Vh.useState(()=>new t(o,s)),c=u.getOptimisticResult(s),d=!r&&e.subscribed!==!1;if(Vh.useSyncExternalStore(Vh.useCallback(h=>{let f=d?u.subscribe(Rr.batchCalls(h)):xo;return u.updateResult(),f},[u,d]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),Vh.useEffect(()=>{u.setOptions(s)},[s,u]),gDe(s,c))throw l8(s,u,i);if(fDe({result:c,errorResetBoundary:i,throwOnError:s.throwOnError,query:a,suspense:s.suspense}))throw c.error;return o.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!Hp&&mDe(c,r)&&(l?l8(s,u,i):a?.promise)?.catch(xo).finally(()=>{u.updateResult()}),s.notifyOnChangeProps?c:u.trackResult(c)}function vDe(e,t){return yDe(e,yJ,t)}function bDe(e,t){let n=Zx(t),r=n.getQueryCache();return W_.useSyncExternalStore(W_.useCallback(i=>r.subscribe(Rr.batchCalls(i)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}function kJ(e,t){let n=Zx(t);return wDe({filters:{...e,status:"pending"}},n).length}function u8(e,t){return e.findAll(t.filters).map(n=>t.select?t.select(n):n.state)}function wDe(e={},t){let n=Zx(t).getMutationCache(),r=Dc.useRef(e),i=Dc.useRef(null);return i.current===null&&(i.current=u8(n,e)),Dc.useEffect(()=>{r.current=e}),Dc.useSyncExternalStore(Dc.useCallback(o=>n.subscribe(()=>{let s=kM(i.current,u8(n,r.current));i.current!==s&&(i.current=s,Rr.schedule(o))}),[n]),()=>i.current,()=>i.current)}function rz(e,t){let n=Zx(t),[r]=Rc.useState(()=>new rDe(n,e));Rc.useEffect(()=>{r.setOptions(e)},[r,e]);let i=Rc.useSyncExternalStore(Rc.useCallback(s=>r.subscribe(Rr.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=Rc.useCallback((s,a)=>{r.mutate(s,a).catch(xo)},[r]);if(i.error&&ez(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:o,mutateAsync:i.mutate}}var Sv=class{},Ky=class extends Sv{constructor(e,t){super(),this.collection=e,this.alias=t,this.type="collectionRef"}},fa=class extends Sv{constructor(e,t){super(),this.query=e,this.alias=t,this.type="queryRef"}},oo=class extends Sv{constructor(e){super(),this.path=e,this.type="ref"}},Go=class extends Sv{constructor(e){super(),this.value=e,this.type="val"}},Fs=class extends Sv{constructor(e,t){super(),this.name=e,this.args=t,this.type="func"}},CJ=class extends Sv{constructor(e,t){super(),this.name=e,this.args=t,this.type="agg"}};function Yy(e){return e instanceof CJ||e instanceof Fs||e instanceof oo||e instanceof Go}function iz(e){return typeof e=="object"&&"expression"in e?e.expression:e}function c8(e){return typeof e=="object"&&"expression"in e?e.expression:e}function d8(e){return typeof e=="object"&&"expression"in e&&e.residual===!0}function xDe(e){return{expression:e,residual:!0}}function SDe(e,t){if(e.from.alias===t)return e.from;for(let n of e.join||[])if(n.from.alias===t)return n.from}function dx(e,t,n){if(t.path.length!==0){if(t.path.length===1){let r=t.path[0];if(e.select){let i=e.select[r];if(i&&i.type==="ref")return dx(e,i,n)}return{collection:n,path:[r]}}if(t.path.length>1){let[r,...i]=t.path,o=SDe(e,r);return o?o.type==="queryRef"?dx(o.query,new oo(i),n):{collection:o.collection,path:i}:void 0}}}var rs=class extends Error{constructor(e){super(e),this.name="TanStackDBError"}},h8=class extends rs{constructor(e,t,n){let r=`${e==="insert"?"Insert":"Update"} validation failed: ${t.map(i=>`
- ${i.message} - path: ${i.path}`).join("")}`;super(n||r),this.name="SchemaValidationError",this.type=e,this.issues=t}},e1=class extends rs{constructor(e){super(e),this.name="CollectionConfigurationError"}},kDe=class extends e1{constructor(){super("Collection requires a config")}},CDe=class extends e1{constructor(){super("Collection requires a sync config")}},NDe=class extends e1{constructor(){super("Schema must implement the standard-schema interface")}},f8=class extends e1{constructor(){super("Schema validation must be synchronous")}},t1=class extends rs{constructor(e){super(e),this.name="CollectionStateError"}},MDe=class extends t1{constructor(e,t){super(`Cannot perform ${e} on collection "${t}" - collection is in error state. Try calling cleanup() and restarting the collection.`)}},_De=class extends t1{constructor(e,t,n){super(`Invalid collection status transition from "${e}" to "${t}" for collection "${n}"`)}},EDe=class extends t1{constructor(){super("Collection is in error state")}},ODe=class extends t1{constructor(){super("Active subscribers count is negative - this should never happen")}},Cu=class extends rs{constructor(e){super(e),this.name="CollectionOperationError"}},TDe=class extends Cu{constructor(e){super(`An object was created without a defined key: ${JSON.stringify(e)}`)}},ADe=class extends Cu{constructor(e,t){let n=e===null?"null":typeof e;super(`getKey returned an invalid key type. Expected string or number, but got ${n}: ${JSON.stringify(e)}. Item: ${JSON.stringify(t)}`)}},DDe=class extends Cu{constructor(e){super(`Cannot insert document with ID "${e}" because it already exists in the collection`)}},RDe=class extends Cu{constructor(e,t,n){let r=`Cannot insert document with key "${e}" from sync because it already exists in the collection "${t}"`;n?.hasCustomGetKey&&n.hasDistinct?super(`${r}. This collection uses a custom getKey with .distinct(). The .distinct() operator deduplicates by the ENTIRE selected object (standard SQL behavior), but your custom getKey extracts only a subset of fields. This causes multiple distinct rows (with different values in non-key fields) to receive the same key. To fix this, either: (1) ensure your SELECT only includes fields that uniquely identify each row, (2) use .groupBy() with min()/max() aggregates to select one value per group, or (3) remove the custom getKey to use the default key behavior.`):n?.hasCustomGetKey&&n.hasJoins?super(`${r}. This collection uses a custom getKey with joined queries. Joined queries can produce multiple rows with the same key when relationships are not 1:1. Consider: (1) using a composite key in your getKey function (e.g., \`\${item.key1}-\${item.key2}\`), (2) ensuring your join produces unique rows per key, or (3) removing the custom getKey to use the default composite key behavior.`):super(r)}},IDe=class extends Cu{constructor(){super("The first argument to update is missing")}},PDe=class extends Cu{constructor(){super("No keys were passed to update")}},LDe=class extends Cu{constructor(e){super(`The key "${e}" was passed to update but an object for this key was not found in the collection`)}},BDe=class extends Cu{constructor(e,t){super(`Updating the key of an item is not allowed. Original key: "${e}", Attempted new key: "${t}". Please delete the old item and create a new one if a key change is necessary.`)}},qDe=class extends Cu{constructor(){super("No keys were passed to delete")}},zDe=class extends Cu{constructor(e){super(`Collection.delete was called with key '${e}' but there is no item in the collection with this key`)}},oz=class extends rs{constructor(e){super(e),this.name="MissingHandlerError"}},FDe=class extends oz{constructor(){super("Collection.insert called directly (not within an explicit transaction) but no 'onInsert' handler is configured.")}},jDe=class extends oz{constructor(){super("Collection.update called directly (not within an explicit transaction) but no 'onUpdate' handler is configured.")}},VDe=class extends oz{constructor(){super("Collection.delete called directly (not within an explicit transaction) but no 'onDelete' handler is configured.")}},Wh=class extends rs{constructor(e){super(e),this.name="TransactionError"}},WDe=class extends Wh{constructor(){super("mutationFn is required when creating a transaction")}},UDe=class extends Wh{constructor(){super("You can no longer call .mutate() as the transaction is no longer pending")}},HDe=class extends Wh{constructor(){super("You can no longer call .rollback() as the transaction is already completed")}},$De=class extends Wh{constructor(){super("You can no longer call .commit() as the transaction is no longer pending")}},p8=class extends Wh{constructor(){super("No pending sync transaction to write to")}},m8=class extends Wh{constructor(){super("The pending sync transaction is already committed, you can't still write to it.")}},KDe=class extends Wh{constructor(){super("No pending sync transaction to commit")}},YDe=class extends Wh{constructor(){super("The pending sync transaction is already committed, you can't commit it again.")}},dm=class extends rs{constructor(e){super(e),this.name="QueryBuilderError"}},QDe=class extends dm{constructor(e){super(`Only one source is allowed in the ${e}`)}},GDe=class extends dm{constructor(e){super(`A sub query passed to a ${e} must have a from clause itself`)}},XDe=class extends dm{constructor(e){super(`Invalid source for live query: The value provided for alias "${e}" is not a Collection or subquery. Live queries only accept Collection instances or subqueries. Please ensure you're passing a valid Collection or QueryBuilder, not a plain array or other data type.`)}},wC=class extends dm{constructor(e,t){super(`Invalid source for ${e}: Expected an object with a single key-value pair like { alias: collection }. For example: .from({ todos: todosCollection }). Got: ${t}`)}},JDe=class extends dm{constructor(){super("Join condition must be an equality expression")}},ZDe=class extends dm{constructor(){super("Query must have a from clause")}},g8=class extends dm{constructor(e){super(`Invalid where() expression: Expected a query expression, but received a ${e}. This usually happens when using JavaScript's comparison operators (===, !==, <, >, etc.) directly. Instead, use the query builder functions:
\u274C .where(({ user }) => user.id === 'abc')
\u2705 .where(({ user }) => eq(user.id, 'abc'))
Available comparison functions: eq, gt, gte, lt, lte, and, or, not, like, ilike, isNull, isUndefined`)}},js=class extends rs{constructor(e){super(e),this.name="QueryCompilationError"}},e2e=class extends js{constructor(){super("DISTINCT requires a SELECT clause.")}},t2e=class extends js{constructor(){super("HAVING clause requires GROUP BY clause")}},n2e=class extends js{constructor(){super("LIMIT and OFFSET require an ORDER BY clause to ensure deterministic results")}},NJ=class extends js{constructor(e,t,n){let r=t?`alias "${e}" (collection "${t}")`:`collection "${e}"`,i=n?.length?`. Available keys: ${n.join(", ")}`:"";super(`Input for ${r} not found in inputs map${i}`)}},r2e=class extends js{constructor(e,t){super(`Subquery uses alias "${e}" which is already used in the parent query. Each alias must be unique across parent and subquery contexts. Parent query aliases: ${t.join(", ")}. Please rename "${e}" in either the parent query or subquery to avoid conflicts.`)}},i2e=class extends js{constructor(e){super(`Unsupported FROM type: ${e}`)}},o2e=class extends js{constructor(e){super(`Unknown expression type: ${e}`)}},s2e=class extends js{constructor(){super("Reference path cannot be empty")}},a2e=class extends js{constructor(e){super(`Unknown function: ${e}`)}},y8=class extends js{constructor(e){super(`Collection "${e}" not found during compilation of join`)}},hm=class extends rs{constructor(e){super(e),this.name="JoinError"}},l2e=class extends hm{constructor(e){super(`Unsupported join type: ${e}`)}},u2e=class extends hm{constructor(e){super(`Invalid join condition: both expressions refer to the same source "${e}"`)}},c2e=class extends hm{constructor(){super("Invalid join condition: expressions must reference source aliases")}},d2e=class extends hm{constructor(e){super(`Invalid join condition: left expression refers to an unavailable source "${e}"`)}},h2e=class extends hm{constructor(e){super(`Invalid join condition: right expression does not refer to the joined source "${e}"`)}},f2e=class extends hm{constructor(){super("Invalid join condition")}},p2e=class extends hm{constructor(e){super(`Unsupported join source type: ${e}`)}},U_=class extends rs{constructor(e){super(e),this.name="GroupByError"}},m2e=class extends U_{constructor(e){super(`Non-aggregate expression '${e}' in SELECT must also appear in GROUP BY clause`)}},g2e=class extends U_{constructor(e){super(`Unsupported aggregate function: ${e}`)}},y2e=class extends U_{constructor(e){super(`Aggregate function in HAVING clause must also be in SELECT clause: ${e}`)}},v2e=class extends U_{constructor(e){super(`Unknown expression type in HAVING clause: ${e}`)}},MJ=class extends rs{constructor(e){super(e),this.name="StorageError"}},b2e=class extends MJ{constructor(e,t){super(`Cannot ${e} item because it cannot be JSON serialized: ${t}`)}},sz=class extends MJ{constructor(e){super(e),this.name="LocalStorageCollectionError"}},w2e=class extends sz{constructor(){super("[LocalStorageCollection] storageKey must be provided.")}},x2e=class extends sz{constructor(e,t){super(`[LocalStorageCollection] Invalid data format in storage key "${e}" for key "${t}".`)}},S2e=class extends sz{constructor(e){super(`[LocalStorageCollection] Invalid data format in storage key "${e}". Expected object format.`)}},v8=class extends rs{constructor(e,t){let n=t instanceof Error?t.message:String(t);super(`Collection "${e}" sync cleanup function threw an error: ${n}`),this.name="SyncCleanupError"}},k2e=class extends rs{constructor(e){super(e),this.name="QueryOptimizerError"}},C2e=class extends k2e{constructor(){super("Cannot combine empty expression list")}},N2e=class extends js{constructor(e,t,n,r){super(`Internal error: subscription for alias '${e}' (remapped from '${t}', collection '${n}') is missing in join pipeline. Available aliases: ${r.join(", ")}. This indicates a bug in alias tracking.`)}},M2e=class extends js{constructor(e){super(`Internal error: compiler returned aliases without inputs: ${e.join(", ")}. This indicates a bug in query compilation. Please report this issue.`)}},_2e=class extends js{constructor(){super("setWindow() can only be called on collections with an ORDER BY clause. Add .orderBy() to your query to enable window movement.")}},H2=new WeakMap,E2e=1;function b8(e){if(H2.has(e))return H2.get(e);let t=E2e++;return H2.set(e,t),t}var az=(e,t,n)=>{let{nulls:r}=n;if(e==null&&t==null)return 0;if(e==null)return r==="first"?-1:1;if(t==null)return r==="first"?1:-1;if(typeof e=="string"&&typeof t=="string"&&n.stringSort==="locale")return e.localeCompare(t,n.locale,n.localeOptions);if(Array.isArray(e)&&Array.isArray(t)){for(let s=0;s<Math.min(e.length,t.length);s++){let a=az(e[s],t[s],n);if(a!==0)return a}return e.length-t.length}if(e instanceof Date&&t instanceof Date)return e.getTime()-t.getTime();let i=typeof e=="object",o=typeof t=="object";if(i||o){if(i&&o){let s=b8(e),a=b8(t);return s-a}if(i)return 1;if(o)return-1}return e<t?-1:e>t?1:0},O2e=(e,t,n)=>az(t,e,{...n,nulls:n.nulls==="first"?"last":"first"});function _M(e){return(t,n)=>e.direction==="asc"?az(t,n,e):O2e(t,n,e)}var gP=_M({direction:"asc",nulls:"first",stringSort:"locale"});function T2e(e,t){if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}var A2e=128,_J="__TS_DB_BTREE_UNDEFINED_VALUE__";function kp(e){return e instanceof Date?e.getTime():(typeof Buffer<"u"&&e instanceof Buffer||e instanceof Uint8Array)&&e.byteLength<=A2e?`__u8__${Array.from(e).join(",")}`:e}function Vd(e){return e===void 0?_J:kp(e)}function Ib(e){if(e!==_J)return e}function D2e(e,t){if(e===t)return!0;let n=typeof Buffer<"u"&&e instanceof Buffer||e instanceof Uint8Array,r=typeof Buffer<"u"&&t instanceof Buffer||t instanceof Uint8Array;return n&&r?T2e(e,t):!1}function xi(e){return e==null}function _y(e){return e===!0}function ro(e,t=!1){return uz(e,t)}function lz(e){return uz(e,!0)}function uz(e,t){switch(e.type){case"val":{let n=e.value;return()=>n}case"ref":return t?I2e(e):R2e(e);case"func":return P2e(e,t);default:throw new o2e(e.type)}}function R2e(e){let[t,...n]=e.path;if(!t)throw new s2e;if(t==="$selected"){if(n.length===0)return i=>i.$selected;if(n.length===1){let i=n[0];return o=>o.$selected?.[i]}else return i=>{let o=i.$selected;if(o===void 0)return;let s=o;for(let a of n){if(s==null)return s;s=s[a]}return s}}let r=t;if(n.length===0)return i=>i[r];if(n.length===1){let i=n[0];return o=>o[r]?.[i]}else return i=>{let o=i[r];if(o===void 0)return;let s=o;for(let a of n){if(s==null)return s;s=s[a]}return s}}function I2e(e){let t=e.path;return n=>{let r=n;for(let i of t){if(r==null)return r;r=r[i]}return r}}function P2e(e,t){let n=e.args.map(r=>uz(r,t));switch(e.name){case"eq":{let r=n[0],i=n[1];return o=>{let s=kp(r(o)),a=kp(i(o));return xi(s)||xi(a)?null:D2e(s,a)}}case"gt":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:s>a}}case"gte":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:s>=a}}case"lt":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:s<a}}case"lte":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:s<=a}}case"and":return r=>{let i=!1;for(let o of n){let s=o(r);if(s===!1)return!1;xi(s)&&(i=!0)}return i?null:!0};case"or":return r=>{let i=!1;for(let o of n){let s=o(r);if(s===!0)return!0;xi(s)&&(i=!0)}return i?null:!1};case"not":{let r=n[0];return i=>{let o=r(i);return xi(o)?null:!o}}case"in":{let r=n[0],i=n[1];return o=>{let s=kp(r(o)),a=i(o);return xi(s)?null:Array.isArray(a)?a.some(l=>kp(l)===s):!1}}case"like":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:w8(s,a,!1)}}case"ilike":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return xi(s)||xi(a)?null:w8(s,a,!0)}}case"upper":{let r=n[0];return i=>{let o=r(i);return typeof o=="string"?o.toUpperCase():o}}case"lower":{let r=n[0];return i=>{let o=r(i);return typeof o=="string"?o.toLowerCase():o}}case"length":{let r=n[0];return i=>{let o=r(i);return typeof o=="string"||Array.isArray(o)?o.length:0}}case"concat":return r=>n.map(i=>{let o=i(r);try{return String(o??"")}catch{try{return JSON.stringify(o)||""}catch{return"[object]"}}}).join("");case"coalesce":return r=>{for(let i of n){let o=i(r);if(o!=null)return o}return null};case"add":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return(s??0)+(a??0)}}case"subtract":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return(s??0)-(a??0)}}case"multiply":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o);return(s??0)*(a??0)}}case"divide":{let r=n[0],i=n[1];return o=>{let s=r(o),a=i(o)??0;return a!==0?(s??0)/a:null}}case"isUndefined":{let r=n[0];return i=>r(i)===void 0}case"isNull":{let r=n[0];return i=>r(i)===null}default:throw new a2e(e.name)}}function w8(e,t,n){if(typeof e!="string"||typeof t!="string")return!1;let r=n?e.toLowerCase():e,i=(n?t.toLowerCase():t).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return i=i.replace(/%/g,".*"),i=i.replace(/_/g,"."),new RegExp(`^${i}$`,"s").test(r)}function ol(e,t){return AN(e,t,new Map)}function AN(e,t,n){if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t)return!1;if(e instanceof Date)return t instanceof Date?e.getTime()===t.getTime():!1;if(t instanceof Date)return!1;if(e instanceof RegExp)return t instanceof RegExp?e.source===t.source&&e.flags===t.flags:!1;if(t instanceof RegExp)return!1;if(e instanceof Map){if(!(t instanceof Map)||e.size!==t.size)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let r=Array.from(e.entries()).every(([i,o])=>t.has(i)&&AN(o,t.get(i),n));return n.delete(e),r}if(t instanceof Map)return!1;if(e instanceof Set){if(!(t instanceof Set)||e.size!==t.size)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let r=Array.from(e),i=Array.from(t);if(r.every(s=>typeof s!="object"))return n.delete(e),r.every(s=>t.has(s));let o=r.length===i.length;return n.delete(e),o}if(t instanceof Set)return!1;if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)&&!(e instanceof DataView)&&!(t instanceof DataView)){let r=e,i=t;if(r.length!==i.length)return!1;for(let o=0;o<r.length;o++)if(r[o]!==i[o])return!1;return!0}if(ArrayBuffer.isView(t)&&!(t instanceof DataView)&&!ArrayBuffer.isView(e))return!1;if(Rw(e)&&Rw(t)){let r=yP(e),i=yP(t);return r!==i?!1:typeof e.equals=="function"?e.equals(t):e.toString()===t.toString()}if(Rw(t))return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;if(n.has(e))return n.get(e)===t;n.set(e,t);let r=e.every((i,o)=>AN(i,t[o],n));return n.delete(e),r}if(Array.isArray(t))return!1;if(typeof e=="object"){if(n.has(e))return n.get(e)===t;n.set(e,t);let r=Object.keys(e),i=Object.keys(t);if(r.length!==i.length)return n.delete(e),!1;let o=r.every(s=>s in t&&AN(e[s],t[s],n));return n.delete(e),o}return!1}var L2e=["Temporal.Duration","Temporal.Instant","Temporal.PlainDate","Temporal.PlainDateTime","Temporal.PlainMonthDay","Temporal.PlainTime","Temporal.PlainYearMonth","Temporal.ZonedDateTime"];function yP(e){return e[Symbol.toStringTag]}function Rw(e){let t=yP(e);return typeof t=="string"&&L2e.includes(t)}var cz={direction:"asc",nulls:"first",stringSort:"locale"},B2e=class{constructor(e){this.originalIndex=e}lookup(e,t){let n=e==="gt"?"lt":e==="gte"?"lte":e==="lt"?"gt":e==="lte"?"gte":e;return this.originalIndex.lookup(n,t)}rangeQuery(e={}){return this.originalIndex.rangeQueryReversed(e)}rangeQueryReversed(e={}){return this.originalIndex.rangeQuery(e)}take(e,t,n){return this.originalIndex.takeReversed(e,t,n)}takeFromStart(e,t){return this.originalIndex.takeReversedFromEnd(e,t)}takeReversed(e,t,n){return this.originalIndex.take(e,t,n)}takeReversedFromEnd(e,t){return this.originalIndex.takeFromStart(e,t)}get orderedEntriesArray(){return this.originalIndex.orderedEntriesArrayReversed}get orderedEntriesArrayReversed(){return this.originalIndex.orderedEntriesArray}supports(e){return this.originalIndex.supports(e)}matchesField(e){return this.originalIndex.matchesField(e)}matchesCompareOptions(e){return this.originalIndex.matchesCompareOptions(e)}matchesDirection(e){return this.originalIndex.matchesDirection(e)}getStats(){return this.originalIndex.getStats()}add(e,t){this.originalIndex.add(e,t)}remove(e,t){this.originalIndex.remove(e,t)}update(e,t,n){this.originalIndex.update(e,t,n)}build(e){this.originalIndex.build(e)}clear(){this.originalIndex.clear()}get keyCount(){return this.originalIndex.keyCount}equalityLookup(e){return this.originalIndex.equalityLookup(e)}inArrayLookup(e){return this.originalIndex.inArrayLookup(e)}get indexedKeysSet(){return this.originalIndex.indexedKeysSet}get valueMapData(){return this.originalIndex.valueMapData}};function n1(e,t,n){let r=n??{...cz,...e.compareOptions};for(let i of e.indexes.values())if(i.matchesField(t)&&i.matchesCompareOptions(r))return i.matchesDirection(r.direction)?i:new B2e(i)}function q2e(e){if(e.length===0)return new Set;if(e.length===1)return new Set(e[0]);let t=new Set(e[0]);for(let n=1;n<e.length;n++){let r=new Set;for(let i of t)e[n].has(i)&&r.add(i);t=r}return t}function z2e(e){let t=new Set;for(let n of e)for(let r of n)t.add(r);return t}function F2e(e,t){return dz(e,t)}function dz(e,t){if(e.type==="func")switch(e.name){case"eq":case"gt":case"gte":case"lt":case"lte":return V2e(e,t);case"and":return W2e(e,t);case"or":return U2e(e,t);case"in":return H2e(e,t)}return{canOptimize:!1,matchingKeys:new Set}}function j2e(e,t){if(e.type!=="func"||e.args.length<2)return{canOptimize:!1,matchingKeys:new Set};let n=new Map;for(let r of e.args)if(r.type==="func"&&["gt","gte","lt","lte"].includes(r.name)){let i=r;if(i.args.length===2){let o=i.args[0],s=i.args[1],a=null,l=null,u=i.name;if(o.type==="ref"&&s.type==="val")a=o,l=s;else if(o.type==="val"&&s.type==="ref")switch(a=s,l=o,u){case"gt":u="lt";break;case"gte":u="lte";break;case"lt":u="gt";break;case"lte":u="gte";break}if(a&&l){let c=a.path.join("."),d=l.value;n.has(c)||n.set(c,[]),n.get(c).push({operation:u,value:d})}}}for(let[r,i]of n)if(i.length>=2){let o=r.split("."),s=n1(t,o);if(s&&s.supports("gt")&&s.supports("lt")){let a,l,u=!0,c=!0;for(let{operation:d,value:h}of i)switch(d){case"gt":(a===void 0||h>a)&&(a=h,u=!1);break;case"gte":(a===void 0||h>a)&&(a=h,u=!0);break;case"lt":(l===void 0||h<l)&&(l=h,c=!1);break;case"lte":(l===void 0||h<l)&&(l=h,c=!0);break}return{canOptimize:!0,matchingKeys:s.rangeQuery({from:a,to:l,fromInclusive:u,toInclusive:c})}}}return{canOptimize:!1,matchingKeys:new Set}}function V2e(e,t){if(e.type!=="func"||e.args.length!==2)return{canOptimize:!1,matchingKeys:new Set};let n=e.args[0],r=e.args[1],i=null,o=null,s=e.name;if(n.type==="ref"&&r.type==="val")i=n,o=r;else if(n.type==="val"&&r.type==="ref")switch(i=r,o=n,s){case"gt":s="lt";break;case"gte":s="lte";break;case"lt":s="gt";break;case"lte":s="gte";break}if(i&&o){let a=i.path,l=n1(t,a);if(l){let u=o.value,c=s;return l.supports(c)?{canOptimize:!0,matchingKeys:l.lookup(c,u)}:{canOptimize:!1,matchingKeys:new Set}}}return{canOptimize:!1,matchingKeys:new Set}}function W2e(e,t){if(e.type!=="func"||e.args.length<2)return{canOptimize:!1,matchingKeys:new Set};let n=j2e(e,t);if(n.canOptimize)return n;let r=[];for(let i of e.args){let o=dz(i,t);o.canOptimize&&r.push(o)}if(r.length>0){let i=r.map(o=>o.matchingKeys);return{canOptimize:!0,matchingKeys:q2e(i)}}return{canOptimize:!1,matchingKeys:new Set}}function U2e(e,t){if(e.type!=="func"||e.args.length<2)return{canOptimize:!1,matchingKeys:new Set};let n=[];for(let r of e.args){let i=dz(r,t);i.canOptimize&&n.push(i)}if(n.length>0){let r=n.map(i=>i.matchingKeys);return{canOptimize:!0,matchingKeys:z2e(r)}}return{canOptimize:!1,matchingKeys:new Set}}function H2e(e,t){if(e.type!=="func"||e.args.length!==2)return{canOptimize:!1,matchingKeys:new Set};let n=e.args[0],r=e.args[1];if(n.type==="ref"&&r.type==="val"&&Array.isArray(r.value)){let i=n.path,o=r.value,s=n1(t,i);if(s){if(s.supports("in"))return{canOptimize:!0,matchingKeys:s.lookup("in",o)};if(s.supports("eq")){let a=new Set;for(let l of o){let u=s.lookup("eq",l);for(let c of u)a.add(c)}return{canOptimize:!0,matchingKeys:a}}}}return{canOptimize:!1,matchingKeys:new Set}}var $2e=class extends Map{constructor(e,t){super(t),this.defaultValue=e}get(e){return this.has(e)?super.get(e):this.defaultValue()}update(e,t){let n=this.get(e),r=t(n);return this.set(e,r),r}},$2=3e4;function K2(e,t){if(t.length<=$2)e.push(...t);else for(let n=0;n<t.length;n+=$2){let r=t.slice(n,n+$2);e.push(...r)}}function K2e(e,t,n){let r=0,i=e.length;for(;r<i;){let o=Math.floor((r+i)/2),s=n(e[o],t);if(s<0)r=o+1;else if(s>0)i=o;else return o}return r}var Y2e=class{constructor(){this.objectIds=new WeakMap,this.nextId=0}getId(e){if(typeof e!="object"||e===null){let t=String(e),n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);n=(n<<5)-n+i,n=n&n}return n}return this.objectIds.has(e)||this.objectIds.set(e,this.nextId++),this.objectIds.get(e)}getStringId(e){return e===null?"null":e===void 0?"undefined":typeof e!="object"?`str_${String(e)}`:`obj_${this.getId(e)}`}},Y2=new Y2e;function Q2e(e,t){let[n,r]=e,[i,o]=t,s=[...xC(n,Math.min(r,i)),...xC(Math.max(n,o),r)],a=[...xC(i,Math.min(o,n)),...xC(Math.max(i,r),o)];return{onlyInA:s,onlyInB:a}}function xC(e,t){let n=[];for(let r=e;r<t;r++)n.push(r);return n}function EM(e,t){return typeof e==typeof t?e<t?-1:e>t?1:0:typeof e=="string"?-1:1}function hz(e){return JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n instanceof Date?n.toISOString():n)}var G2e=Wi(),X2e=Wi(),J2e=Wi(),Z2e=Wi(),eRe=Wi();function Wi(){return Math.random()*(2**31-1)>>>0}var EJ=new ArrayBuffer(8),tRe=new DataView(EJ),Wd=new Uint8Array(EJ),H_=class{constructor(){this.hash=G2e,this.length=0,this.carry=0,this.carryBytes=0}_mix(e){e=Math.imul(e,3432918353),e=e<<15|e>>>17,e=Math.imul(e,461845907),this.hash^=e,this.hash=this.hash<<13|this.hash>>>19,this.hash=Math.imul(this.hash,5)+3864292196}writeByte(e){this.carry|=(e&255)<<8*this.carryBytes,this.carryBytes++,this.length++,this.carryBytes===4&&(this._mix(this.carry>>>0),this.carry=0,this.carryBytes=0)}update(e){switch(typeof e){case"symbol":{this.update(eRe);let t=e.description;if(!t)return;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);this.writeByte(r&255),this.writeByte(r>>>8&255)}return}case"string":this.update(X2e);for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);this.writeByte(n&255),this.writeByte(n>>>8&255)}return;case"number":tRe.setFloat64(0,e,!0),this.writeByte(Wd[0]),this.writeByte(Wd[1]),this.writeByte(Wd[2]),this.writeByte(Wd[3]),this.writeByte(Wd[4]),this.writeByte(Wd[5]),this.writeByte(Wd[6]),this.writeByte(Wd[7]);return;case"bigint":{let t=e;for(t<0n?(t=-t,this.update(Z2e)):this.update(J2e);t>0n;)this.writeByte(Number(t&0xffn)),t>>=8n;e===0n&&this.writeByte(0);return}default:throw new TypeError(`Unsupported input type: ${typeof e}`)}}digest(){if(this.carryBytes>0){let e=this.carry>>>0;e=Math.imul(e,3432918353),e=e<<15|e>>>17,e=Math.imul(e,461845907),this.hash^=e}return this.hash^=this.length,this.hash^=this.hash>>>16,this.hash=Math.imul(this.hash,2246822507),this.hash^=this.hash>>>13,this.hash=Math.imul(this.hash,3266489909),this.hash^=this.hash>>>16,this.hash>>>0}},nRe=Wi(),rRe=Wi(),iRe=Wi(),oRe=Wi(),sRe=Wi(),aRe=Wi(),lRe=Wi(),uRe=Wi(),cRe=Wi(),dRe=Wi(),hRe=Wi(),fRe=Wi(),pRe=128,hx=new WeakMap;function ko(e){let t=new H_;return OJ(t,e),t.digest()}function mRe(e){let t=hx.get(e);if(t!==void 0)return t;let n;if(e instanceof Date)n=gRe(e);else if(typeof Buffer<"u"&&e instanceof Buffer||e instanceof Uint8Array)if(e.byteLength<=pRe)n=yRe(e);else return vP(e);else{if(e instanceof File)return vP(e);{let r=e,i=uRe;e instanceof Array&&(i=cRe),e instanceof Map&&(i=dRe,r=[...e.entries()]),e instanceof Set&&(i=hRe,r=[...e.entries()]),n=vRe(r,i)}}return hx.set(e,n),n}function gRe(e){let t=new H_;return t.update(lRe),t.update(e.getTime()),t.digest()}function yRe(e){let t=new H_;t.update(fRe),t.update(e.byteLength);for(let n=0;n<e.byteLength;n++)t.writeByte(e[n]);return t.digest()}function vRe(e,t){let n=new H_;n.update(t);let r=Object.keys(e);r.sort(wRe);for(let i of r)n.update(sRe),n.update(i),OJ(n,e[i]);return n.digest()}function OJ(e,t){if(t===null){e.update(iRe);return}switch(typeof t){case"undefined":e.update(oRe);return;case"boolean":e.update(t?nRe:rRe);return;case"number":e.update(isNaN(t)?NaN:t===0?0:t);return;case"bigint":case"string":case"symbol":e.update(t);return;case"object":e.update(bRe(t));return;case"function":e.update(vP(t));return;default:console.warn(`Ignored input during hashing because it is of type ${typeof t} which is not supported`)}}function bRe(e){let t=hx.get(e);return t===void 0&&(t=mRe(e)),t}var x8=1;function vP(e){let t=hx.get(e);return t===void 0&&(t=x8^aRe,x8++,hx.set(e,t)),t}function wRe(e,t){return e.localeCompare(t)}var vu=class hc{#e;constructor(t=[]){this.#e=t}toString(t=!1){return`MultiSet(${JSON.stringify(this.#e,null,t?2:void 0)})`}toJSON(){return JSON.stringify(Array.from(this.getInner()))}static fromJSON(t){return new hc(JSON.parse(t))}map(t){return new hc(this.#e.map(([n,r])=>[t(n),r]))}filter(t){return new hc(this.#e.filter(([n,r])=>t(n)))}negate(){return new hc(this.#e.map(([t,n])=>[t,-n]))}concat(t){let n=[];return K2(n,this.#e),K2(n,t.getInner()),new hc(n)}consolidate(){if(this.#e.length>0){let t=this.#e[0]?.[0];if(Array.isArray(t)&&t.length===2)return this.#t()}return this.#n()}#t(){let t=new Map,n=new Map,r=o=>{if(o.length!==2)throw new Error("Expected tuple of length 2");let[s,a]=o;return`${Y2.getStringId(s)}|${Y2.getStringId(a)}`};for(let[o,s]of this.#e){if(!Array.isArray(o)||o.length!==2)return this.#n();let[a,l]=o;if(typeof a!="string"&&typeof a!="number")return this.#n();let u;Array.isArray(l)&&l.length===2?u=r(l):u=Y2.getStringId(l);let c=a+"|"+u;t.set(c,(t.get(c)||0)+s),n.has(c)||n.set(c,o)}let i=[];for(let[o,s]of t)s!==0&&i.push([n.get(o),s]);return new hc(i)}#n(){let t=new $2e(()=>0),n=new Map,r=!1,i=!1,o=!1;for(let[l,u]of this.#e)if(typeof l=="string")r=!0;else if(typeof l=="number")i=!0;else{o=!0;break}let s=o||r&&i;for(let[l,u]of this.#e){let c=s?ko(l):l;s&&!n.has(c)&&n.set(c,l),t.update(c,d=>d+u)}let a=[];for(let[l,u]of t.entries())if(u!==0){let c=s?n.get(l):l;a.push([c,u])}return new hc(a)}extend(t){let n=t instanceof hc?t.getInner():t;K2(this.#e,n)}add(t,n){n!==0&&this.#e.push([t,n])}getInner(){return this.#e}},xRe=class{#e;constructor(e){this.#e=e}drain(){let e=[...this.#e].reverse();return this.#e.length=0,e}isEmpty(){return this.#e.length===0}},Nu=class{#e=[];sendData(e){e instanceof vu||(e=new vu(e));for(let t of this.#e)t.unshift(e)}newReader(){let e=[];return this.#e.push(e),new xRe(e)}},TJ=class{constructor(e,t,n){this.id=e,this.inputs=t,this.output=n}hasPendingWork(){return this.inputs.some(e=>!e.isEmpty())}},kv=class extends TJ{constructor(e,t,n){super(e,[t],n),this.id=e}inputMessages(){return this.inputs[0].drain()}},SRe=class extends TJ{constructor(e,t,n,r){super(e,[t,n],r),this.id=e}inputAMessages(){return this.inputs[0].drain()}inputBMessages(){return this.inputs[1].drain()}},fz=class extends kv{run(){for(let e of this.inputMessages())this.output.sendData(this.inner(e))}},kRe=class{#e=[];#t=0;#n=!1;constructor(){}#r(){if(this.#n)throw new Error("Graph already finalized")}getNextOperatorId(){return this.#r(),this.#t++}newInput(){this.#r();let e=new Nu;return new CRe(this,e)}addOperator(e){this.#r(),this.#e.push(e)}finalize(){this.#r(),this.#n=!0}step(){if(!this.#n)throw new Error("Graph not finalized");for(let e of this.#e)e.run()}pendingWork(){return this.#e.some(e=>e.hasPendingWork())}run(){for(;this.pendingWork();)this.step()}},Mu=class{#e;#t;constructor(e,t){this.#e=e,this.#t=t}connectReader(){return this.#t.newReader()}get writer(){return this.#t}get graph(){return this.#e}pipe(...e){return e.reduce((t,n)=>n(t),this)}},CRe=class extends Mu{sendData(e){this.writer.sendData(e)}},NRe=class extends fz{#e;constructor(e,t,n,r){super(e,t,n),this.#e=r}inner(e){return e.map(this.#e)}};function No(e){return t=>{let n=new Mu(t.graph,new Nu),r=new NRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}var rw=Symbol("NO_PREFIX"),S8=class extends Map{addValue(e,t){if(t===0)return this.size===0;let n=Iw(e),r=this.get(n);if(DN(r)){let[i,o]=r;if(Iw(i)!==n)throw new Error("Mismatching prefixes, this should never happen");if(i===e||ko(i)===ko(e)){let s=o+t;s===0?this.delete(n):this.set(n,[e,s])}else{let s=new iw;s.set(ko(i),r),s.set(ko(e),[e,t]),this.set(n,s)}}else r===void 0?this.set(n,[e,t]):r.addValue(e,t)&&this.delete(n);return this.size===0}},iw=class extends Map{addValue(e,t){if(t===0)return this.size===0;let n=ko(e),r=this.get(n);if(r){let[,i]=r,o=i+t;o===0?this.delete(n):this.set(n,[e,o])}else this.set(n,[e,t]);return this.size===0}},yy=class AJ{#e;#t=new Map;constructor(){this.#e=new Map}static fromMultiSets(t){let n=new AJ;for(let r of t)for(let[i,o]of r.getInner()){let[s,a]=i;n.addValue(s,[a,o])}return n}toString(t=!1){return`Index(${JSON.stringify([...this.entries()],void 0,t?2:void 0)})`}get size(){return this.#e.size}has(t){return this.#e.has(t)}hasPresence(t){return(this.#t.get(t)||0)!==0}getConsolidatedMultiplicity(t){return this.#t.get(t)||0}getPresenceKeys(){return this.#t.keys()}get(t){return[...this.getIterator(t)]}*getIterator(t){let n=this.#e.get(t);if(DN(n))yield n;else{if(n===void 0)return;if(n instanceof iw)for(let r of n.values())yield r;else for(let r of n.values())if(DN(r))yield r;else for(let i of r.values())yield i}}*entries(){for(let t of this.#e.keys())for(let n of this.getIterator(t))yield[t,n]}*entriesIterators(){for(let t of this.#e.keys())yield[t,this.getIterator(t)]}addValue(t,n){let[r,i]=n;if(i===0)return;let o=(this.#t.get(t)||0)+i;o===0?this.#t.delete(t):this.#t.set(t,o);let s=this.#e.get(t);if(s===void 0){this.#e.set(t,n);return}if(DN(s)){this.#n(t,s,r,i);return}if(s instanceof iw){let a=Iw(r);if(a!==rw){let l=new S8;l.set(rw,s),l.set(a,n),this.#e.set(t,l)}else s.addValue(r,i)&&this.#e.delete(t)}else s.addValue(r,i)&&this.#e.delete(t)}#n(t,n,r,i){let[o,s]=n;if(o===r){let u=s+i;u===0?this.#e.delete(t):this.#e.set(t,[r,u]);return}let a=Iw(r),l=Iw(o);if(l===a&&(o===r||ko(o)===ko(r))){let u=s+i;u===0?this.#e.delete(t):this.#e.set(t,[r,u]);return}if(l===rw&&a===rw){let u=new iw;u.set(ko(o),n),u.set(ko(r),[r,i]),this.#e.set(t,u)}else{let u=new S8;if(l===a){let c=new iw;c.set(ko(o),n),c.set(ko(r),[r,i]),u.set(l,c)}else u.set(l,n),u.set(a,[r,i]);this.#e.set(t,u)}}append(t){for(let[n,r]of t.entries())this.addValue(n,r)}join(t){let n=[];if(this.size<=t.size)for(let[r,i]of this.entriesIterators()){if(!t.has(r))continue;let o=t.get(r);for(let[s,a]of i)for(let[l,u]of o)a!==0&&u!==0&&n.push([[r,[s,l]],a*u])}else for(let[r,i]of t.entriesIterators()){if(!this.has(r))continue;let o=this.get(r);for(let[s,a]of i)for(let[l,u]of o)u!==0&&a!==0&&n.push([[r,[l,s]],u*a])}return new vu(n)}};function Iw(e){return Array.isArray(e)&&(typeof e[0]=="string"||typeof e[0]=="number"||typeof e[0]=="bigint")?e[0]:rw}function DN(e){return Array.isArray(e)}var MRe=class extends kv{#e=new yy;#t=new yy;#n;constructor(e,t,n,r){super(e,t,n),this.#n=r}run(){let e=new Set;for(let n of this.inputMessages())for(let[r,i]of n.getInner()){let[o,s]=r;this.#e.addValue(o,[s,i]),e.add(o)}let t=[];for(let n of e){let r=this.#e.get(n),i=this.#t.get(n),o=this.#n(r),s=new Map,a=new Map;for(let[l,u]of o){let c=s.get(l)??0;s.set(l,c+u)}for(let[l,u]of i){let c=a.get(l)??0;a.set(l,c+u)}for(let[l,u]of a)s.has(l)||(t.push([[n,l],-u]),this.#t.addValue(n,[l,-u]));for(let[l,u]of s)a.has(l)||u!==0&&(t.push([[n,l],u]),this.#t.addValue(n,[l,u]));for(let[l,u]of s){let c=a.get(l);if(c!==void 0){let d=u-c;d!==0&&(t.push([[n,l],d]),this.#t.addValue(n,[l,d]))}}}t.length>0&&this.output.sendData(new vu(t))}};function _Re(e){return t=>{let n=new Mu(t.graph,new Nu),r=new MRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}function k8(e){return"pipe"in e}function C8(e,t={}){let n=Object.fromEntries(Object.entries(t).filter(([r,i])=>!k8(i)));return Object.fromEntries(Object.entries(t).filter(([r,i])=>k8(i))),r=>{let i="__original_key__";return r.pipe(No(o=>{let s=e(o),a=hz(s),l={};l[i]=s;for(let[u,c]of Object.entries(n))l[u]=c.preMap(o);return[a,l]})).pipe(_Re(o=>{let s=0;for(let[u,c]of o)s+=c;if(s<=0)return[];let a={},l=o[0]?.[0]?.[i];a[i]=l;for(let[u,c]of Object.entries(n)){let d=o.map(([h,f])=>[h[u],f]);a[u]=c.reduce(d)}return[[a,1]]})).pipe(No(([o,s])=>{let a=s[i],l={};Object.assign(l,a);for(let[u,c]of Object.entries(n))c.postMap?l[u]=c.postMap(s[u]):l[u]=s[u];return[o,l]}))}}function ERe(e=t=>t){return{preMap:t=>e(t),reduce:t=>{let n=0;for(let[r,i]of t)n+=r*i;return n}}}function ORe(e=t=>t){return{preMap:t=>e(t)==null?0:1,reduce:t=>{let n=0;for(let[r,i]of t)n+=r*i;return n}}}function TRe(e=t=>t){return{preMap:t=>({sum:e(t),count:0}),reduce:t=>{let n=0,r=0;for(let[i,o]of t)n+=i.sum*o,r+=o;return{sum:n,count:r}},postMap:t=>t.sum/t.count}}function ARe(e){let t=e??(n=>n);return{preMap:n=>t(n),reduce:n=>{let r;for(let[i,o]of n)(!r||i&&i<r)&&(r=i);return r}}}function DRe(e){let t=e??(n=>n);return{preMap:n=>t(n),reduce:n=>{let r;for(let[i,o]of n)(!r||i&&i>r)&&(r=i);return r}}}function RRe(e=t=>t){return{preMap:t=>[e(t)],reduce:t=>{let n=[];for(let[r,i]of t)for(let o of r)for(let s=0;s<i;s++)n.push(o);return n.length===0?[]:(n.sort((r,i)=>r-i),n)},postMap:t=>{if(t.length===0)return 0;let n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}}}function IRe(e=t=>t){return{preMap:t=>{let n=e(t),r=new Map;return r.set(n,1),r},reduce:t=>{let n=new Map;for(let[r,i]of t)for(let[o,s]of r.entries()){let a=n.get(o)||0;n.set(o,a+s*i)}return n},postMap:t=>{if(t.size===0)return 0;let n=0,r=0;for(let[i,o]of t.entries())o>r&&(r=o,n=i);return n}}}var PRe={sum:ERe,count:ORe,avg:TRe,min:ARe,max:DRe,median:RRe,mode:IRe},LRe=class extends fz{#e;constructor(e,t,n,r){super(e,t,n),this.#e=r}inner(e){return this.#e(e),e}};function BRe(e){return t=>{let n=new Mu(t.graph,new Nu),r=new LRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}var qRe=class extends fz{#e;constructor(e,t,n,r){super(e,t,n),this.#e=r}inner(e){return e.filter(this.#e)}};function ch(e){return t=>{let n=new Mu(t.graph,new Nu),r=new qRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}var zRe=class extends kv{#e;constructor(e,t,n,r){super(e,t,n),this.#e=r}run(){for(let e of this.inputMessages())this.#e(e),this.output.sendData(e)}};function FRe(e){return t=>{let n=new Mu(t.graph,new Nu),r=new zRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}var jRe=class extends kv{run(){let e=this.inputMessages();if(e.length===0)return;let t=new vu;for(let r of e)t.extend(r);let n=t.consolidate();n.getInner().length>0&&this.output.sendData(n)}};function VRe(){return e=>{let t=new Mu(e.graph,new Nu),n=new jRe(e.graph.getNextOperatorId(),e.connectReader(),t.writer);return e.graph.addOperator(n),t}}var WRe=class extends SRe{#e=new yy;#t=new yy;#n;constructor(e,t,n,r,i="inner"){super(e,t,n,r),this.#n=i}run(){let e=yy.fromMultiSets(this.inputAMessages()),t=yy.fromMultiSets(this.inputBMessages());if(e.size===0&&t.size===0)return;let n=new vu;this.#n!=="anti"&&this.emitInnerResults(e,t,n),(this.#n==="left"||this.#n==="full"||this.#n==="anti")&&this.emitLeftOuterResults(e,t,n),(this.#n==="right"||this.#n==="full")&&this.emitRightOuterResults(e,t,n),this.#e.append(e),this.#t.append(t),n.getInner().length>0&&this.output.sendData(n)}emitInnerResults(e,t,n){e.size>0&&n.extend(e.join(this.#t)),t.size>0&&n.extend(this.#e.join(t)),e.size>0&&t.size>0&&n.extend(e.join(t))}emitLeftOuterResults(e,t,n){if(e.size>0)for(let[r,i]of e.entriesIterators()){let o=this.#t.getConsolidatedMultiplicity(r),s=t.getConsolidatedMultiplicity(r);if(o+s===0)for(let[a,l]of i)l!==0&&n.add([r,[a,null]],l)}if(t.size>0)for(let r of t.getPresenceKeys()){let i=this.#t.getConsolidatedMultiplicity(r),o=t.getConsolidatedMultiplicity(r);if(o===0)continue;let s=i+o;if(i===0==(s===0))continue;let a=i===0;for(let[l,u]of this.#e.getIterator(r))u!==0&&n.add([r,[l,null]],a?-u:+u)}}emitRightOuterResults(e,t,n){if(t.size>0)for(let[r,i]of t.entriesIterators()){let o=this.#e.getConsolidatedMultiplicity(r),s=e.getConsolidatedMultiplicity(r);if(o+s===0)for(let[a,l]of i)l!==0&&n.add([r,[null,a]],l)}if(e.size>0)for(let r of e.getPresenceKeys()){let i=this.#e.getConsolidatedMultiplicity(r),o=e.getConsolidatedMultiplicity(r);if(o===0)continue;let s=i+o;if(i===0==(s===0))continue;let a=i===0;for(let[l,u]of this.#t.getIterator(r))u!==0&&n.add([r,[null,l]],a?-u:+u)}}};function URe(e,t="inner"){return n=>{if(n.graph!==e.graph)throw new Error("Cannot join streams from different graphs");let r=new Mu(n.graph,new Nu),i=new WRe(n.graph.getNextOperatorId(),n.connectReader(),e.connectReader(),r.writer,t);return n.graph.addOperator(i),r}}var HRe=class extends kv{#e;#t;constructor(e,t,n,r=i=>i){super(e,t,n),this.#e=r,this.#t=new Map}run(){let e=new Map;for(let n of this.inputMessages())for(let[r,i]of n.getInner()){let o=ko(this.#e(r)),s=(e.get(o)?.[0]??this.#t.get(o)??0)+i;e.set(o,[s,r])}let t=[];for(let[n,[r,i]]of e.entries()){let o=this.#t.get(n)??0;r===0?this.#t.delete(n):this.#t.set(n,r),o<=0&&r>0?t.push([[ko(this.#e(i)),i[1]],1]):o>0&&r<=0&&t.push([[ko(this.#e(i)),i[1]],-1])}t.length>0&&this.output.sendData(new vu(t))}};function $Re(e=t=>t){return t=>{let n=new Mu(t.graph,new Nu),r=new HRe(t.graph.getNextOperatorId(),t.connectReader(),n.writer,e);return t.graph.addOperator(r),n}}var KRe="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function vy(e,t,n){let r=n[0];if(t!=null&&e>=t)throw new Error(e+" >= "+t);if(e.slice(-1)===r||t&&t.slice(-1)===r)throw new Error("trailing zero");if(t){let s=0;for(;(e[s]||r)===t[s];)s++;if(s>0)return t.slice(0,s)+vy(e.slice(s),t.slice(s),n)}let i=e?n.indexOf(e[0]):0,o=t!=null?n.indexOf(t[0]):n.length;if(o-i>1){let s=Math.round(.5*(i+o));return n[s]}else return t&&t.length>1?t.slice(0,1):n[i]+vy(e.slice(1),null,n)}function DJ(e){if(e.length!==RJ(e[0]))throw new Error("invalid integer part of order key: "+e)}function RJ(e){if(e>="a"&&e<="z")return e.charCodeAt(0)-97+2;if(e>="A"&&e<="Z")return 90-e.charCodeAt(0)+2;throw new Error("invalid order key head: "+e)}function ow(e){let t=RJ(e[0]);if(t>e.length)throw new Error("invalid order key: "+e);return e.slice(0,t)}function N8(e,t){if(e==="A"+t[0].repeat(26))throw new Error("invalid order key: "+e);let n=ow(e);if(e.slice(n.length).slice(-1)===t[0])throw new Error("invalid order key: "+e)}function M8(e,t){DJ(e);let[n,...r]=e.split(""),i=!0;for(let o=r.length-1;i&&o>=0;o--){let s=t.indexOf(r[o])+1;s===t.length?r[o]=t[0]:(r[o]=t[s],i=!1)}if(i){if(n==="Z")return"a"+t[0];if(n==="z")return null;let o=String.fromCharCode(n.charCodeAt(0)+1);return o>"a"?r.push(t[0]):r.pop(),o+r.join("")}else return n+r.join("")}function YRe(e,t){DJ(e);let[n,...r]=e.split(""),i=!0;for(let o=r.length-1;i&&o>=0;o--){let s=t.indexOf(r[o])-1;s===-1?r[o]=t.slice(-1):(r[o]=t[s],i=!1)}if(i){if(n==="a")return"Z"+t.slice(-1);if(n==="A")return null;let o=String.fromCharCode(n.charCodeAt(0)-1);return o<"Z"?r.push(t.slice(-1)):r.pop(),o+r.join("")}else return n+r.join("")}function QRe(e,t,n=KRe){if(e!=null&&N8(e,n),t!=null&&N8(t,n),e!=null&&t!=null&&e>=t)throw new Error(e+" >= "+t);if(e==null){if(t==null)return"a"+n[0];let l=ow(t),u=t.slice(l.length);if(l==="A"+n[0].repeat(26))return l+vy("",u,n);if(l<t)return l;let c=YRe(l,n);if(c==null)throw new Error("cannot decrement any more");return c}if(t==null){let l=ow(e),u=e.slice(l.length);return M8(l,n)??l+vy(u,null,n)}let r=ow(e),i=e.slice(r.length),o=ow(t),s=t.slice(o.length);if(r===o)return r+vy(i,s,n);let a=M8(r,n);if(a==null)throw new Error("cannot increment any more");return a<t?a:r+vy(i,null,n)}function _8(e,t){return[e,t]}function E8(e){return e[0]}function O8(e){return e[1]}function GRe(e){return([t,n],[r,i])=>{let o=e(n,i);return o!==0?o:EM(t,r)}}var IJ=class{#e=[];#t;#n;#r;constructor(e,t,n){this.#n=e,this.#r=e+t,this.#t=n}get size(){let e=this.#n,t=this.#r-this.#n,n=this.#e.length-e;return Math.max(0,Math.min(t,n))}move({offset:e,limit:t}){let n=this.#n,r=this.#r-this.#n,i=[this.#n,this.#r===1/0?this.#n+this.size:this.#r];this.#n=e??n,this.#r=this.#n+(t??r);let o=[this.#n,this.#r===1/0?Math.max(this.#n+this.size,i[1]):this.#r],{onlyInA:s,onlyInB:a}=Q2e(i,o),l=[];a.forEach(c=>{let d=this.#e[c];d&&l.push(d)});let u=[];return s.forEach(c=>{let d=this.#e[c];d&&u.push(d)}),{moveIns:l,moveOuts:u,changes:s.length+a.length>0}}insert(e){let t={moveIn:null,moveOut:null},n=this.#i(e),r=n===0?null:O8(this.#e[n-1]),i=n===this.#e.length?null:O8(this.#e[n]),o=QRe(r,i),s=_8(e,o);if(this.#e.splice(n,0,s),n<this.#r){let a=Math.max(n,this.#n);a<this.#e.length&&(t.moveIn=this.#e[a],this.#r<this.#e.length&&(t.moveOut=this.#e[this.#r]))}return t}delete(e){let t={moveIn:null,moveOut:null},n=this.#i(e),[r]=this.#e.splice(n,1);if(n<this.#r){if(t.moveOut=r,n<this.#n){let o=this.#n-1;o<this.#e.length?t.moveOut=this.#e[o]:t.moveOut=null}let i=this.#r-1;i<this.#e.length&&(t.moveIn=this.#e[i])}return t}#i(e){return K2e(this.#e,_8(e,""),(t,n)=>this.#t(E8(t),E8(n)))}},XRe=class{#e=new Map;#t;constructor(e){this.#t=e}get size(){return this.#t.size}get isEmpty(){return this.#e.size===0&&this.#t.size===0}processElement(e,t,n){let{oldMultiplicity:r,newMultiplicity:i}=this.#n(e,n);return r<=0&&i>0?this.#t.insert([e,t]):r>0&&i<=0?this.#t.delete([e,t]):{moveIn:null,moveOut:null}}move(e){if(!(this.#t instanceof IJ))throw new Error("Cannot move B+-tree implementation of TopK with fractional index");return this.#t.move(e)}#n(e,t){if(t===0){let i=this.#e.get(e)??0;return{oldMultiplicity:i,newMultiplicity:i}}let n=this.#e.get(e)??0,r=n+t;return r===0?this.#e.delete(e):this.#e.set(e,r),{oldMultiplicity:n,newMultiplicity:r}}};function T8(e,t){if(e){let[[n,r],i]=e;t.push([[n,[r,i]],1])}}function A8(e,t){if(e){let[[n,r],i]=e;t.push([[n,[r,i]],-1])}}var JRe=class extends kv{#e;constructor(e,t,n,r,i){super(e,t,n);let o=i.limit??1/0,s=i.offset??0,a=this.createTopK(s,o,GRe(r));this.#e=new XRe(a),i.setSizeCallback?.(()=>this.#e.size),i.setWindowFn?.(this.moveTopK.bind(this))}createTopK(e,t,n){return new IJ(e,t,n)}moveTopK({offset:e,limit:t}){let n=[],r=this.#e.move({offset:e,limit:t});r.moveIns.forEach(i=>T8(i,n)),r.moveOuts.forEach(i=>A8(i,n)),r.changes&&this.output.sendData(new vu(n))}run(){let e=[];for(let t of this.inputMessages())for(let[n,r]of t.getInner()){let[i,o]=n;this.processElement(i,o,r,e)}e.length>0&&this.output.sendData(new vu(e))}processElement(e,t,n,r){let i=this.#e.processElement(e,t,n);T8(i.moveIn,r),A8(i.moveOut,r)}};function ZRe(e,t){let n=t||{};return r=>{let i=new Mu(r.graph,new Nu),o=new JRe(r.graph.getNextOperatorId(),r.connectReader(),i.writer,e,n);return r.graph.addOperator(o),i}}function eIe(e,t,n){let r=n?.limit??1/0,i=n?.offset??0,o=n?.setSizeCallback,s=n?.setWindowFn,a=n?.comparator??((l,u)=>l===u?0:l<u?-1:1);return l=>l.pipe(e((u,c)=>a(t(u),t(c)),{limit:r,offset:i,setSizeCallback:o,setWindowFn:s}),VRe())}function tIe(e,t){return eIe(ZRe,e,t)}var nIe=class{constructor(e,t,n){this._root=Q2,this._size=0,this._maxNodeSize=n>=4?Math.min(n,256):32,this._compare=e,t&&this.setPairs(t)}get size(){return this._size}get length(){return this._size}get isEmpty(){return this._size===0}clear(){this._root=Q2,this._size=0}get(e,t){return this._root.get(e,t,this)}set(e,t,n){this._root.isShared&&(this._root=this._root.clone());let r=this._root.set(e,t,n,this);return r===!0||r===!1?r:(this._root=new rIe([this._root,r]),!0)}has(e){return this.forRange(e,e,!0,void 0)!==0}delete(e){return this.editRange(e,e,!0,oIe)!==0}get maxNodeSize(){return this._maxNodeSize}minKey(){return this._root.minKey()}maxKey(){return this._root.maxKey()}keysArray(){let e=[];return this._root.forRange(this.minKey(),this.maxKey(),!0,!1,this,0,(t,n)=>{e.push(t)}),e}nextHigherPair(e,t){return t=t||[],e===void 0?this._root.minPair(t):this._root.getPairOrNextHigher(e,this._compare,!1,t)}nextHigherKey(e){let t=this.nextHigherPair(e,D8);return t&&t[0]}nextLowerPair(e,t){return t=t||[],e===void 0?this._root.maxPair(t):this._root.getPairOrNextLower(e,this._compare,!1,t)}nextLowerKey(e){let t=this.nextLowerPair(e,D8);return t&&t[0]}setPairs(e,t){let n=0;for(let r of e)this.set(r[0],r[1],t)&&n++;return n}forRange(e,t,n,r,i){let o=this._root.forRange(e,t,n,!1,this,i||0,r);return typeof o=="number"?o:o.break}editRange(e,t,n,r,i){let o=this._root;o.isShared&&(this._root=o=o.clone());try{let s=o.forRange(e,t,n,!0,this,i||0,r);return typeof s=="number"?s:s.break}finally{let s;for(;o.keys.length<=1&&!o.isLeaf;)s||=o.isShared,this._root=o=o.keys.length===0?Q2:o.children[0];s&&(o.isShared=!0)}}},PJ=class bP{get isLeaf(){return this.children===void 0}constructor(t=[],n){this.keys=t,this.values=n||Ji,this.isShared=void 0}maxKey(){return this.keys[this.keys.length-1]}indexOf(t,n,r){let i=this.keys,o=0,s=i.length,a=s>>1;for(;o<s;){let l=r(i[a],t);if(l<0)o=a+1;else if(l>0)s=a;else{if(l===0)return a;if(t===t)return i.length;throw new Error("BTree: NaN was used as a key")}a=o+s>>1}return a^n}minKey(){return this.keys[0]}minPair(t){if(this.keys.length!==0)return t[0]=this.keys[0],t[1]=this.values[0],t}maxPair(t){if(this.keys.length===0)return;let n=this.keys.length-1;return t[0]=this.keys[n],t[1]=this.values[n],t}clone(){let t=this.values;return new bP(this.keys.slice(0),t===Ji?t:t.slice(0))}get(t,n,r){let i=this.indexOf(t,-1,r._compare);return i<0?n:this.values[i]}getPairOrNextLower(t,n,r,i){let o=this.indexOf(t,-1,n),s=o<0?~o-1:r?o:o-1;if(s>=0)return i[0]=this.keys[s],i[1]=this.values[s],i}getPairOrNextHigher(t,n,r,i){let o=this.indexOf(t,-1,n),s=o<0?~o:r?o:o+1,a=this.keys;if(s<a.length)return i[0]=a[s],i[1]=this.values[s],i}set(t,n,r,i){let o=this.indexOf(t,-1,i._compare);if(o<0){if(o=~o,i._size++,this.keys.length<i._maxNodeSize)return this.insertInLeaf(o,t,n,i);{let s=this.splitOffRightSide(),a=this;return o>this.keys.length&&(o-=this.keys.length,a=s),a.insertInLeaf(o,t,n,i),s}}else return r!==!1&&(n!==void 0&&this.reifyValues(),this.keys[o]=t,this.values[o]=n),!1}reifyValues(){return this.values===Ji?this.values=this.values.slice(0,this.keys.length):this.values}insertInLeaf(t,n,r,i){if(this.keys.splice(t,0,n),this.values===Ji){for(;Ji.length<i._maxNodeSize;)Ji.push(void 0);if(r===void 0)return!0;this.values=Ji.slice(0,this.keys.length-1)}return this.values.splice(t,0,r),!0}takeFromRight(t){let n=this.values;t.values===Ji?n!==Ji&&n.push(void 0):(n=this.reifyValues(),n.push(t.values.shift())),this.keys.push(t.keys.shift())}takeFromLeft(t){let n=this.values;t.values===Ji?n!==Ji&&n.unshift(void 0):(n=this.reifyValues(),n.unshift(t.values.pop())),this.keys.unshift(t.keys.pop())}splitOffRightSide(){let t=this.keys.length>>1,n=this.keys.splice(t),r=this.values===Ji?Ji:this.values.splice(t);return new bP(n,r)}forRange(t,n,r,i,o,s,a){let l=o._compare,u,c;if(n===t){if(!r||(c=(u=this.indexOf(t,-1,l))+1,u<0))return s}else u=this.indexOf(t,0,l),c=this.indexOf(n,-1,l),c<0?c=~c:r===!0&&c++;let d=this.keys,h=this.values;if(a!==void 0)for(let f=u;f<c;f++){let p=d[f],m=a(p,h[f],s++);if(m!==void 0){if(i===!0){if(p!==d[f]||this.isShared===!0)throw new Error("BTree illegally changed or cloned in editRange");m.delete?(this.keys.splice(f,1),this.values!==Ji&&this.values.splice(f,1),o._size--,f--,c--):m.hasOwnProperty("value")&&(h[f]=m.value)}if(m.break!==void 0)return m}}else s+=c-u;return s}mergeSibling(t,n){if(this.keys.push.apply(this.keys,t.keys),this.values===Ji){if(t.values===Ji)return;this.values=this.values.slice(0,this.keys.length)}this.values.push.apply(this.values,t.reifyValues())}},rIe=class LJ extends PJ{constructor(t,n){if(!n){n=[];for(let r=0;r<t.length;r++)n[r]=t[r].maxKey()}super(n),this.children=t}minKey(){return this.children[0].minKey()}minPair(t){return this.children[0].minPair(t)}maxPair(t){return this.children[this.children.length-1].maxPair(t)}get(t,n,r){let i=this.indexOf(t,0,r._compare),o=this.children;return i<o.length?o[i].get(t,n,r):void 0}getPairOrNextLower(t,n,r,i){let o=this.indexOf(t,0,n),s=this.children;if(o>=s.length)return this.maxPair(i);let a=s[o].getPairOrNextLower(t,n,r,i);return a===void 0&&o>0?s[o-1].maxPair(i):a}getPairOrNextHigher(t,n,r,i){let o=this.indexOf(t,0,n),s=this.children,a=s.length;if(o>=a)return;let l=s[o].getPairOrNextHigher(t,n,r,i);return l===void 0&&o<a-1?s[o+1].minPair(i):l}set(t,n,r,i){let o=this.children,s=i._maxNodeSize,a=i._compare,l=Math.min(this.indexOf(t,0,a),o.length-1),u=o[l];if(u.isShared&&(o[l]=u=u.clone()),u.keys.length>=s){let d;l>0&&(d=o[l-1]).keys.length<s&&a(u.keys[0],t)<0?(d.isShared&&(o[l-1]=d=d.clone()),d.takeFromRight(u),this.keys[l-1]=d.maxKey()):(d=o[l+1])!==void 0&&d.keys.length<s&&a(u.maxKey(),t)<0&&(d.isShared&&(o[l+1]=d=d.clone()),d.takeFromLeft(u),this.keys[l]=o[l].maxKey())}let c=u.set(t,n,r,i);if(c===!1)return!1;if(this.keys[l]=u.maxKey(),c===!0)return!0;if(this.keys.length<s)return this.insert(l+1,c),!0;{let d=this.splitOffRightSide(),h=this;return a(c.maxKey(),this.maxKey())>0&&(h=d,l-=this.keys.length),h.insert(l+1,c),d}}insert(t,n){this.children.splice(t,0,n),this.keys.splice(t,0,n.maxKey())}splitOffRightSide(){let t=this.children.length>>1;return new LJ(this.children.splice(t),this.keys.splice(t))}takeFromRight(t){this.keys.push(t.keys.shift()),this.children.push(t.children.shift())}takeFromLeft(t){this.keys.unshift(t.keys.pop()),this.children.unshift(t.children.pop())}forRange(t,n,r,i,o,s,a){let l=o._compare,u=this.keys,c=this.children,d=this.indexOf(t,0,l),h=d,f=Math.min(n===t?d:this.indexOf(n,0,l),u.length-1);if(i){if(h<=f)try{for(;h<=f;h++){c[h].isShared&&(c[h]=c[h].clone());let p=c[h].forRange(t,n,r,i,o,s,a);if(u[h]=c[h].maxKey(),typeof p!="number")return p;s=p}}finally{let p=o._maxNodeSize>>1;for(d>0&&d--,h=f;h>=d;h--)c[h].keys.length<=p&&(c[h].keys.length!==0?this.tryMerge(h,o._maxNodeSize):(u.splice(h,1),c.splice(h,1)));c.length!==0&&c[0].keys.length===0&&sIe(!1,"emptiness bug")}}else for(;h<=f;h++){let p=c[h].forRange(t,n,r,i,o,s,a);if(typeof p!="number")return p;s=p}return s}tryMerge(t,n){let r=this.children;return t>=0&&t+1<r.length&&r[t].keys.length+r[t+1].keys.length<=n?(r[t].isShared&&(r[t]=r[t].clone()),r[t].mergeSibling(r[t+1],n),r.splice(t+1,1),this.keys.splice(t+1,1),this.keys[t]=r[t].maxKey(),!0):!1}mergeSibling(t,n){let r=this.keys.length;this.keys.push.apply(this.keys,t.keys);let i=t.children;if(this.children.push.apply(this.children,i),t.isShared&&!this.isShared)for(let o of i)o.isShared=!0;this.tryMerge(r-1,n)}},Ji=[],iIe={delete:!0},oIe=()=>iIe,Q2=function(){let e=new PJ;return e.isShared=!0,e}(),D8=[];function sIe(e,...t){throw t.unshift("B+ tree"),new Error(t.join(" "))}function BJ(){let e=new Map;function t(n){let r=n.join(".");if(e.has(r))return e.get(r);let i=new Proxy({},{get(o,s,a){if(s==="__refProxy")return!0;if(s==="__path")return n;if(s==="__type")return;if(typeof s=="symbol")return Reflect.get(o,s,a);let l=[...n,String(s)];return t(l)},has(o,s){return s==="__refProxy"||s==="__path"||s==="__type"?!0:Reflect.has(o,s)},ownKeys(o){return Reflect.ownKeys(o)},getOwnPropertyDescriptor(o,s){return s==="__refProxy"||s==="__path"||s==="__type"?{enumerable:!1,configurable:!0}:Reflect.getOwnPropertyDescriptor(o,s)}});return e.set(r,i),i}return t([])}function fp(e){let t=new Map,n=0;function r(i){let o=i.join(".");if(t.has(o))return t.get(o);let s=new Proxy({},{get(a,l,u){if(l==="__refProxy")return!0;if(l==="__path")return i;if(l==="__type")return;if(typeof l=="symbol")return Reflect.get(a,l,u);let c=[...i,String(l)];return r(c)},has(a,l){return l==="__refProxy"||l==="__path"||l==="__type"?!0:Reflect.has(a,l)},ownKeys(a){let l=++n,u=`__SPREAD_SENTINEL__${i.join(".")}__${l}`;return Object.prototype.hasOwnProperty.call(a,u)||Object.defineProperty(a,u,{enumerable:!0,configurable:!0,value:!0}),Reflect.ownKeys(a)},getOwnPropertyDescriptor(a,l){return l==="__refProxy"||l==="__path"||l==="__type"?{enumerable:!1,configurable:!0}:Reflect.getOwnPropertyDescriptor(a,l)}});return t.set(o,s),s}return new Proxy({},{get(i,o,s){if(o==="__refProxy")return!0;if(o==="__path")return[];if(o==="__type")return;if(typeof o=="symbol")return Reflect.get(i,o,s);let a=String(o);if(e.includes(a))return r([a])},has(i,o){return o==="__refProxy"||o==="__path"||o==="__type"||typeof o=="string"&&e.includes(o)?!0:Reflect.has(i,o)},ownKeys(i){return[...e,"__refProxy","__path","__type"]},getOwnPropertyDescriptor(i,o){if(o==="__refProxy"||o==="__path"||o==="__type")return{enumerable:!1,configurable:!0};if(typeof o=="string"&&e.includes(o))return{enumerable:!0,configurable:!0}}})}function R8(e){let t=fp(e),n=new Map;function r(o){let s=o.join(".");if(n.has(s))return n.get(s);let a=new Proxy({},{get(l,u,c){if(u==="__refProxy")return!0;if(u==="__path")return["$selected",...o];if(u==="__type")return;if(typeof u=="symbol")return Reflect.get(l,u,c);let d=[...o,String(u)];return r(d)},has(l,u){return u==="__refProxy"||u==="__path"||u==="__type"?!0:Reflect.has(l,u)},ownKeys(l){return Reflect.ownKeys(l)},getOwnPropertyDescriptor(l,u){return u==="__refProxy"||u==="__path"||u==="__type"?{enumerable:!1,configurable:!0}:Reflect.getOwnPropertyDescriptor(l,u)}});return n.set(s,a),a}let i=r([]);return new Proxy(t,{get(o,s,a){return s==="$selected"?i:Reflect.get(o,s,a)},has(o,s){return s==="$selected"?!0:Reflect.has(o,s)},ownKeys(o){return[...Reflect.ownKeys(o),"$selected"]},getOwnPropertyDescriptor(o,s){return s==="$selected"?{enumerable:!0,configurable:!0,value:i}:Reflect.getOwnPropertyDescriptor(o,s)}})}function Ir(e){return wP(e)?new oo(e.__path):e&&typeof e=="object"&&"type"in e&&(e.type==="func"||e.type==="ref"||e.type==="val"||e.type==="agg")?e:new Go(e)}function wP(e){return e&&typeof e=="object"&&e.__refProxy===!0}function Qy(e,t){return new Fs("eq",[Ir(e),Ir(t)])}function I8(e,t){return new Fs("gt",[Ir(e),Ir(t)])}function aIe(e,t){return new Fs("gte",[Ir(e),Ir(t)])}function xP(e,t){return new Fs("lt",[Ir(e),Ir(t)])}function SP(e,t,...n){let r=[e,t,...n];return new Fs("and",r.map(i=>Ir(i)))}function lIe(e,t,...n){let r=[e,t,...n];return new Fs("or",r.map(i=>Ir(i)))}function uIe(e,t){return new Fs("in",[Ir(e),Ir(t)])}var cIe=class{constructor(e,t,n,r){this.lookupCount=0,this.totalLookupTime=0,this.lastUpdated=new Date,this.id=e,this.expression=t,this.compareOptions=cz,this.name=n,this.initialize(r)}supports(e){return this.supportedOperations.has(e)}matchesField(e){return this.expression.type==="ref"&&this.expression.path.length===e.length&&this.expression.path.every((t,n)=>t===e[n])}matchesCompareOptions(e){let t={...this.compareOptions,direction:void 0},n={...e,direction:void 0};return ol(t,n)}matchesDirection(e){return this.compareOptions.direction===e}getStats(){return{entryCount:this.keyCount,lookupCount:this.lookupCount,averageLookupTime:this.lookupCount>0?this.totalLookupTime/this.lookupCount:0,lastUpdated:this.lastUpdated}}evaluateIndexExpression(e){return lz(this.expression)(e)}trackLookup(e){let t=performance.now()-e;this.lookupCount++,this.totalLookupTime+=t}updateTimestamp(){this.lastUpdated=new Date}},kP=class extends cIe{constructor(e,t,n,r){super(e,t,n,r),this.supportedOperations=new Set(["eq","gt","gte","lt","lte","in"]),this.valueMap=new Map,this.indexedKeys=new Set,this.compareFn=gP;let i=r?.compareFn??gP;this.compareFn=(o,s)=>i(Ib(o),Ib(s)),r?.compareOptions&&(this.compareOptions=r.compareOptions),this.orderedEntries=new nIe(this.compareFn)}initialize(e){}add(e,t){let n;try{n=this.evaluateIndexExpression(t)}catch(i){throw new Error(`Failed to evaluate index expression for key ${e}: ${i}`)}let r=Vd(n);if(this.valueMap.has(r))this.valueMap.get(r).add(e);else{let i=new Set([e]);this.valueMap.set(r,i),this.orderedEntries.set(r,void 0)}this.indexedKeys.add(e),this.updateTimestamp()}remove(e,t){let n;try{n=this.evaluateIndexExpression(t)}catch(i){console.warn(`Failed to evaluate index expression for key ${e} during removal:`,i);return}let r=Vd(n);if(this.valueMap.has(r)){let i=this.valueMap.get(r);i.delete(e),i.size===0&&(this.valueMap.delete(r),this.orderedEntries.delete(r))}this.indexedKeys.delete(e),this.updateTimestamp()}update(e,t,n){this.remove(e,t),this.add(e,n)}build(e){this.clear();for(let[t,n]of e)this.add(t,n)}clear(){this.orderedEntries.clear(),this.valueMap.clear(),this.indexedKeys.clear(),this.updateTimestamp()}lookup(e,t){let n=performance.now(),r;switch(e){case"eq":r=this.equalityLookup(t);break;case"gt":r=this.rangeQuery({from:t,fromInclusive:!1});break;case"gte":r=this.rangeQuery({from:t,fromInclusive:!0});break;case"lt":r=this.rangeQuery({to:t,toInclusive:!1});break;case"lte":r=this.rangeQuery({to:t,toInclusive:!0});break;case"in":r=this.inArrayLookup(t);break;default:throw new Error(`Operation ${e} not supported by BTreeIndex`)}return this.trackLookup(n),r}get keyCount(){return this.indexedKeys.size}equalityLookup(e){let t=Vd(e);return new Set(this.valueMap.get(t)??[])}rangeQuery(e={}){let{from:t,to:n,fromInclusive:r=!0,toInclusive:i=!0}=e,o=new Set,s="from"in e,a="to"in e,l=s?Vd(t):this.orderedEntries.minKey(),u=a?Vd(n):this.orderedEntries.maxKey();return this.orderedEntries.forRange(l,u,i,(c,d)=>{if(!r&&this.compareFn(c,t)===0)return;let h=this.valueMap.get(c);h&&h.forEach(f=>o.add(f))}),o}rangeQueryReversed(e={}){let{from:t,to:n,fromInclusive:r=!0,toInclusive:i=!0}=e,o="from"in e,s="to"in e;return this.rangeQuery({from:s?n:this.orderedEntries.maxKey(),to:o?t:this.orderedEntries.minKey(),fromInclusive:i,toInclusive:r})}takeInternal(e,t,n,r,i=!1){let o=new Set,s=[],a,l=n;for(;(a=t(l))!==void 0&&s.length<e;){l=a[0];let u=this.valueMap.get(l);if(u&&u.size>0){let c=Array.from(u).sort(EM);i&&c.reverse();for(let d of c){if(s.length>=e)break;!o.has(d)&&(r?.(d)??!0)&&(s.push(d),o.add(d))}}}return s}take(e,t,n){let r=o=>this.orderedEntries.nextHigherPair(o),i=Vd(t);return this.takeInternal(e,r,i,n)}takeFromStart(e,t){let n=r=>this.orderedEntries.nextHigherPair(r);return this.takeInternal(e,n,void 0,t)}takeReversed(e,t,n){let r=o=>this.orderedEntries.nextLowerPair(o),i=Vd(t);return this.takeInternal(e,r,i,n,!0)}takeReversedFromEnd(e,t){let n=r=>this.orderedEntries.nextLowerPair(r);return this.takeInternal(e,n,void 0,t,!0)}inArrayLookup(e){let t=new Set;for(let n of e){let r=Vd(n),i=this.valueMap.get(r);i&&i.forEach(o=>t.add(o))}return t}get indexedKeysSet(){return this.indexedKeys}get orderedEntriesArray(){return this.orderedEntries.keysArray().map(e=>[Ib(e),this.valueMap.get(e)??new Set])}get orderedEntriesArrayReversed(){return this.takeReversedFromEnd(this.orderedEntries.size).map(e=>[Ib(e),this.valueMap.get(e)??new Set])}get valueMapData(){let e=new Map;for(let[t,n]of this.valueMap)e.set(Ib(t),n);return e}};function qJ(e){return e.config.autoIndex==="eager"}function $_(e,t,n,r,i){if(!qJ(n))return;let o=r??{...cz,...n.compareOptions};if(!Array.from(n.indexes.values()).find(s=>s.matchesField(t)&&s.matchesCompareOptions(o)))try{n.createIndex(s=>{let a=s;for(let l of t)a=a[l];return a},{name:`auto:${t.join(".")}`,indexType:kP,options:i?{compareFn:i,compareOptions:o}:{}})}catch(s){console.warn(`${n.id?`[${n.id}] `:""}Failed to create auto-index for field path "${t.join(".")}":`,s)}}function dIe(e,t){if(!qJ(t))return;let n=hIe(e);for(let{fieldName:r,fieldPath:i}of n)$_(r,i,t)}function hIe(e){let t=[];function n(r){if(r.type!=="func")return;let i=r;if(i.name==="and"){for(let a of i.args)n(a);return}if(!["eq","gt","gte","lt","lte","in"].includes(i.name)||i.args.length<1||i.args[0].type!=="ref")return;let o=i.args[0].path;if(o.length===0)return;let s=o.join("_");t.push({fieldName:s,fieldPath:o})}return n(e),t}var{sum:fIe,count:pIe,avg:mIe,min:gIe,max:yIe}=PRe;function vIe(e,t){let n=new Map,r=[...e];if(!t)return{selectToGroupByIndex:n,groupByExpressions:r};for(let[i,o]of Object.entries(t)){if(o.type==="agg"||Gy(o))continue;let s=r.findIndex(a=>OM(o,a));if(s===-1)throw new m2e(i);n.set(i,s)}return{selectToGroupByIndex:n,groupByExpressions:r}}function P8(e,t,n,r,i){if(t.length===0){let d={},h={},f={value:0};if(r){for(let[m,g]of Object.entries(r))if(g.type==="agg")d[m]=SC(g);else if(Gy(g)){let{transformed:y,extracted:v}=CP(g,f);for(let[b,w]of Object.entries(v))d[b]=SC(w);h[m]=ro(y)}}let p=()=>({__singleGroup:!0});if(e=e.pipe(C8(p,d)),e=e.pipe(No(([,m])=>{let g={...m.$selected||{}};if(r){for(let[y,v]of Object.entries(r))v.type==="agg"&&(g[y]=m[y]);L8(g,m,h)}return["single_group",{...m,$selected:g}]})),n&&n.length>0)for(let m of n){let g=c8(m),y=TM(g,r||{},"$selected"),v=ro(y);e=e.pipe(ch(([,b])=>{let w={$selected:b.$selected};return _y(v(w))}))}if(i&&i.length>0)for(let m of i)e=e.pipe(ch(([,g])=>{let y={$selected:g.$selected};return _y(m(y))}));return e}let o=vIe(t,r),s=t.map(d=>ro(d)),a=([,d])=>{let h={...d};delete h.$selected;let f={};for(let p=0;p<t.length;p++){let m=s[p],g=m(h);f[`__key_${p}`]=g}return f},l={},u={},c={value:0};if(r){for(let[d,h]of Object.entries(r))if(h.type==="agg")l[d]=SC(h);else if(Gy(h)){let{transformed:f,extracted:p}=CP(h,c);for(let[m,g]of Object.entries(p))l[m]=SC(g);u[d]=ro(f)}}if(e=e.pipe(C8(a,l)),e=e.pipe(No(([,d])=>{let h=d.$selected||{},f={};if(r){for(let[m,g]of Object.entries(r))if(g.type==="agg")f[m]=d[m];else if(!u[m]){let y=o.selectToGroupByIndex.get(m);y!==void 0?f[m]=d[`__key_${y}`]:f[m]=h[m]}L8(f,d,u)}else for(let m=0;m<t.length;m++)f[`__key_${m}`]=d[`__key_${m}`];let p;if(t.length===1)p=d.__key_0;else{let m=[];for(let g=0;g<t.length;g++)m.push(d[`__key_${g}`]);p=hz(m)}return[p,{...d,$selected:f}]})),n&&n.length>0)for(let d of n){let h=c8(d),f=TM(h,r||{}),p=ro(f);e=e.pipe(ch(([,m])=>{let g={$selected:m.$selected};return p(g)}))}if(i&&i.length>0)for(let d of i)e=e.pipe(ch(([,h])=>{let f={$selected:h.$selected};return _y(d(f))}));return e}function OM(e,t){if(!e||!t||e.type!==t.type)return!1;switch(e.type){case"ref":return!e.path||!t.path||e.path.length!==t.path.length?!1:e.path.every((n,r)=>n===t.path[r]);case"val":return e.value===t.value;case"func":return e.name===t.name&&e.args?.length===t.args?.length&&(e.args||[]).every((n,r)=>OM(n,t.args[r]));case"agg":return e.name===t.name&&e.args?.length===t.args?.length&&(e.args||[]).every((n,r)=>OM(n,t.args[r]));default:return!1}}function SC(e){let t=ro(e.args[0]),n=([,o])=>{let s=t(o);return typeof s=="number"?s:s!=null?Number(s):0},r=([,o])=>{let s=t(o);return typeof s=="number"||typeof s=="string"||typeof s=="bigint"||s instanceof Date?s:s!=null?Number(s):0},i=([,o])=>t(o);switch(e.name.toLowerCase()){case"sum":return fIe(n);case"count":return pIe(i);case"avg":return mIe(n);case"min":return gIe(r);case"max":return yIe(r);default:throw new g2e(e.name)}}function TM(e,t,n="$selected"){switch(e.type){case"agg":{let r=e;for(let[i,o]of Object.entries(t))if(o.type==="agg"&&bIe(r,o))return new oo([n,i]);throw new y2e(r.name)}case"func":{let r=e,i=r.args.map(o=>TM(o,t));return new Fs(r.name,i)}case"ref":return e;case"val":return e;default:throw new v2e(e.type)}}function L8(e,t,n){for(let r of Object.keys(t))r.startsWith("__agg_")&&(e[r]=t[r]);for(let[r,i]of Object.entries(n))e[r]=i({$selected:e});for(let r of Object.keys(e))r.startsWith("__agg_")&&delete e[r]}function Gy(e){return Yy(e)?e.type==="agg"?!0:e.type==="func"?e.args.some(t=>Gy(t)):!1:!1}function CP(e,t){if(e.type==="agg"){let n=`__agg_${t.value++}`;return{transformed:new oo(["$selected",n]),extracted:{[n]:e}}}if(e.type==="func"){let n={},r=e.args.map(i=>{let o=CP(i,t);return Object.assign(n,o.extracted),o.transformed});return{transformed:new Fs(e.name,r),extracted:n}}return{transformed:e,extracted:{}}}function bIe(e,t){return e.name===t.name&&e.args.length===t.args.length&&e.args.every((n,r)=>OM(n,t.args[r]))}function wIe(e,t,n,r,i,o,s,a,l){let u=n.map(p=>{let m=TM(p.expression,r,"$selected");return{compiledExpression:ro(m),compareOptions:NP(p,i)}}),c=p=>{let m=p;return n.length>1?u.map(g=>g.compiledExpression(m)):n.length===1?u[0].compiledExpression(m):null},d=(p,m)=>{if(n.length>1){let g=p,y=m;for(let v=0;v<n.length;v++){let b=u[v],w=_M(b.compareOptions)(g[v],y[v]);if(w!==0)return w}return g.length-y.length}if(n.length===1){let g=u[0];return _M(g.compareOptions)(p,m)}return gP(p,m)},h,f;if(a){let p,m,g,y=e.from.alias,v=n[0],b=v.expression;if(b.type==="ref"){let w=dx(e,b,i);if(w){m=w.collection;let x=w.path[0],S=NP(v,m);x&&$_(x,w.path,m,S,d),g=ro(new oo(w.path),!0),p=n1(m,w.path,S),p?.supports("gt")||(p=void 0),y=b.path.length>1?String(b.path[0]):e.from.alias}}if(g){let w=n.every(S=>S.expression.type==="ref")?n.map(S=>{let k=S.expression,C=dx(e,k,i);return ro(C?new oo(C.path):S.expression,!0)}):void 0;f={alias:y,offset:l??0,limit:a,comparator:(S,k)=>{if(n.length===1){let C=S&&g(S),N=k&&g(k);return d(C,N)}if(w){let C=N=>N&&w.map(E=>E(N));return d(C(S),C(k))}return 0},valueExtractorForRawRow:S=>{if(n.length===1)return g(S);if(w)return w.map(k=>k(S))},firstColumnValueExtractor:g,index:p,orderBy:n};let x=m?.id??i.id;o[x]=f,p&&(h=S=>{o[x].dataNeeded=()=>{let k=S();return Math.max(0,f.limit-k)}})}}return t.pipe(tIe(c,{limit:a,offset:l,comparator:d,setSizeCallback:h,setWindowFn:p=>{s(m=>{p(m),f&&(f.offset=m.offset??f.offset,f.limit=m.limit??f.limit)})}}))}function NP(e,t){return e.compareOptions.stringSort!==void 0?e.compareOptions:{...t.compareOptions,direction:e.compareOptions.direction,nulls:e.compareOptions.nulls}}function xIe(e,t={}){let n=r=>{let i=[];for(let[o,s]of e.entries())(r?.(s)??!0)&&i.push({type:"insert",key:o,value:s});return i};if(t.limit!==void 0&&!t.orderBy)throw new Error("limit cannot be used without orderBy");if(t.orderBy){let r=t.where?Pw(t.where):void 0,i=kIe(e,t.orderBy,t.limit,r,t.optimizedOnly);if(i===void 0)return;let o=[];for(let s of i){let a=e.get(s);a!==void 0&&o.push({type:"insert",key:s,value:a})}return o}if(!t.where)return n();try{let r=t.where,i=F2e(r,e);if(i.canOptimize){let o=[];for(let s of i.matchingKeys){let a=e.get(s);a!==void 0&&o.push({type:"insert",key:s,value:a})}return o}else{if(t.optimizedOnly)return;let o=Pw(r);return n(o)}}catch(r){console.warn(`${e.id?`[${e.id}] `:""}Error processing where clause, falling back to full scan:`,r);let i=Pw(t.where);return t.optimizedOnly?void 0:n(i)}}function Pw(e){let t=lz(e);return n=>{try{let r=t(n);return _y(r)}catch{return!1}}}function SIe(e,t){let n=Pw(t.whereExpression);return r=>{let i=[];for(let o of r)if(o.type==="insert")n(o.value)&&i.push(o);else if(o.type==="update"){let s=n(o.value),a=o.previousValue?n(o.previousValue):!1;s&&a?i.push(o):s&&!a?i.push({...o,type:"insert"}):!s&&a&&i.push({...o,type:"delete",value:o.previousValue})}else n(o.value)&&i.push(o);(i.length>0||r.length===0)&&e(i)}}function kIe(e,t,n,r,i){if(t.length===1){let l=t[0],u=l.expression;if(u.type==="ref"){let c=u.path,d=NP(l,e);$_(c[0],c,e,d);let h=n1(e,c,d);if(h&&h.supports("gt")){let f=p=>{let m=e.get(p);return m===void 0?!1:r?.(m)??!0};return h.takeFromStart(n??h.keyCount,f)}}}if(i)return;let o=[];for(let[l,u]of e.entries())(r?.(u)??!0)&&o.push({key:l,value:u});let s=(l,u)=>{for(let c of t){let d=_M(c.compareOptions),h=B8(l.value,c.expression),f=B8(u.value,c.expression),p=d(h,f);if(p!==0)return p}return 0};o.sort(s);let a=o.map(l=>l.key);return n!==void 0?a.slice(0,n):a}function B8(e,t){if(t.type==="ref"){let n=t,r=e;for(let i of n.path)r=r?.[i];return r}else return t.type==="val"?t.value:lz(t)(e)}var q8=class{constructor(e){this.map=new Map,this.sortedKeys=[],this.comparator=e}indexOf(e,t){let n=0,r=this.sortedKeys.length;if(!this.comparator){for(;n<r;){let i=Math.floor((n+r)/2),o=this.sortedKeys[i],s=EM(e,o);if(s<0)r=i;else if(s>0)n=i+1;else return i}return n}for(;n<r;){let i=Math.floor((n+r)/2),o=this.sortedKeys[i],s=this.map.get(o),a=this.comparator(t,s);if(a<0)r=i;else if(a>0)n=i+1;else{let l=EM(e,o);if(l<0)r=i;else if(l>0)n=i+1;else return i}}return n}set(e,t){if(this.map.has(e)){let r=this.map.get(e),i=this.indexOf(e,r);this.sortedKeys.splice(i,1)}let n=this.indexOf(e,t);return this.sortedKeys.splice(n,0,e),this.map.set(e,t),this}get(e){return this.map.get(e)}delete(e){if(this.map.has(e)){let t=this.map.get(e),n=this.indexOf(e,t);return this.sortedKeys.splice(n,1),this.map.delete(e)}return!1}has(e){return this.map.has(e)}clear(){this.map.clear(),this.sortedKeys=[]}get size(){return this.map.size}*[Symbol.iterator](){for(let e of this.sortedKeys)yield[e,this.map.get(e)]}entries(){return this[Symbol.iterator]()}keys(){return this.sortedKeys[Symbol.iterator]()}values(){return function*(){for(let e of this.sortedKeys)yield this.map.get(e)}.call(this)}forEach(e){for(let t of this.sortedKeys)e(this.map.get(t),t,this.map)}},CIe=class{constructor(e){this.pendingSyncedTransactions=[],this.syncedMetadata=new Map,this.optimisticUpserts=new Map,this.optimisticDeletes=new Set,this.size=0,this.syncedKeys=new Set,this.preSyncVisibleState=new Map,this.recentlySyncedKeys=new Set,this.hasReceivedFirstCommit=!1,this.isCommittingSyncTransactions=!1,this.commitPendingTransactions=()=>{let t=!1;for(let s of this.transactions.values())if(s.state==="persisting"){t=!0;break}let{committedSyncedTransactions:n,uncommittedSyncedTransactions:r,hasTruncateSync:i,hasImmediateSync:o}=this.pendingSyncedTransactions.reduce((s,a)=>(a.committed?(s.committedSyncedTransactions.push(a),a.truncate&&(s.hasTruncateSync=!0),a.immediate&&(s.hasImmediateSync=!0)):s.uncommittedSyncedTransactions.push(a),s),{committedSyncedTransactions:[],uncommittedSyncedTransactions:[],hasTruncateSync:!1,hasImmediateSync:!1});if(!t||i||o){this.isCommittingSyncTransactions=!0;let s=i?n.find(h=>h.truncate)?.optimisticSnapshot:null,a=new Set;for(let h of n)for(let f of h.operations)a.add(f.key);let l=this.preSyncVisibleState;if(l.size===0){l=new Map;for(let h of a){let f=this.get(h);f!==void 0&&l.set(h,f)}}let u=[],c=this.config.sync.rowUpdateMode||"partial";for(let h of n){if(h.truncate){let f=new Set([...this.syncedData.keys(),...s?.upserts.keys()||[]]);for(let p of f){if(s?.deletes.has(p))continue;let m=s?.upserts.get(p)||this.syncedData.get(p);m!==void 0&&u.push({type:"delete",key:p,value:m})}this.syncedData.clear(),this.syncedMetadata.clear(),this.syncedKeys.clear();for(let p of a)l.delete(p);this._events.emit("truncate",{type:"truncate",collection:this.collection})}for(let f of h.operations){let p=f.key;switch(this.syncedKeys.add(p),f.type){case"insert":this.syncedMetadata.set(p,f.metadata);break;case"update":this.syncedMetadata.set(p,Object.assign({},this.syncedMetadata.get(p),f.metadata));break;case"delete":this.syncedMetadata.delete(p);break}switch(f.type){case"insert":this.syncedData.set(p,f.value);break;case"update":{if(c==="partial"){let m=Object.assign({},this.syncedData.get(p),f.value);this.syncedData.set(p,m)}else this.syncedData.set(p,f.value);break}case"delete":this.syncedData.delete(p);break}}}if(i){let h=new Set;for(let m of n)for(let g of m.operations)(g.type==="insert"||g.type==="update")&&h.add(g.key);let f=new Map(s.upserts),p=new Set(s.deletes);for(let[m,g]of f)if(!p.has(m))if(h.has(m)){let y=!1;for(let v=u.length-1;v>=0;v--){let b=u[v];if(b.key===m&&b.type==="insert"){b.value=g,y=!0;break}}y||u.push({type:"insert",key:m,value:g})}else u.push({type:"insert",key:m,value:g});if(u.length>0&&p.size>0){let m=[];for(let g of u)g.type==="insert"&&p.has(g.key)||m.push(g);u.length=0,u.push(...m)}this.lifecycle.status!=="ready"&&this.lifecycle.markReady()}if(this.optimisticUpserts.clear(),this.optimisticDeletes.clear(),this.isCommittingSyncTransactions=!1,i&&s){for(let[h,f]of s.upserts)this.optimisticUpserts.set(h,f);for(let h of s.deletes)this.optimisticDeletes.add(h)}for(let h of this.transactions.values())if(!["completed","failed"].includes(h.state)){for(let f of h.mutations)if(this.isThisCollection(f.collection)&&f.optimistic)switch(f.type){case"insert":case"update":this.optimisticUpserts.set(f.key,f.modified),this.optimisticDeletes.delete(f.key);break;case"delete":this.optimisticUpserts.delete(f.key),this.optimisticDeletes.add(f.key);break}}let d=new Map;for(let h of this.transactions.values())if(h.state==="completed")for(let f of h.mutations)f.optimistic&&this.isThisCollection(f.collection)&&a.has(f.key)&&d.set(f.key,{type:f.type,value:f.modified});for(let h of a){let f=l.get(h),p=this.get(h),m=d.get(h),g=!1;m&&(m.type==="delete"&&f!==void 0&&p===void 0&&ol(m.value,f)||p!==void 0&&ol(m.value,p))&&(g=!0),g||(f===void 0&&p!==void 0?u.push({type:"insert",key:h,value:p}):f!==void 0&&p===void 0?u.push({type:"delete",key:h,value:f}):f!==void 0&&p!==void 0&&!ol(f,p)&&u.push({type:"update",key:h,value:p,previousValue:f}))}this.size=this.calculateSize(),u.length>0&&this.indexes.updateIndexes(u),this.changes.emitEvents(u,!0),this.pendingSyncedTransactions=r,this.preSyncVisibleState.clear(),Promise.resolve().then(()=>{this.recentlySyncedKeys.clear()}),this.hasReceivedFirstCommit||(this.hasReceivedFirstCommit=!0)}},this.config=e,this.transactions=new q8((t,n)=>t.compareCreatedAt(n)),this.syncedData=new q8(e.compare)}setDeps(e){this.collection=e.collection,this.lifecycle=e.lifecycle,this.changes=e.changes,this.indexes=e.indexes,this._events=e.events}get(e){let{optimisticDeletes:t,optimisticUpserts:n,syncedData:r}=this;if(!t.has(e))return n.has(e)?n.get(e):r.get(e)}has(e){let{optimisticDeletes:t,optimisticUpserts:n,syncedData:r}=this;return t.has(e)?!1:n.has(e)?!0:r.has(e)}*keys(){let{syncedData:e,optimisticDeletes:t,optimisticUpserts:n}=this;for(let r of e.keys())t.has(r)||(yield r);for(let r of n.keys())!e.has(r)&&!t.has(r)&&(yield r)}*values(){for(let e of this.keys()){let t=this.get(e);t!==void 0&&(yield t)}}*entries(){for(let e of this.keys()){let t=this.get(e);t!==void 0&&(yield[e,t])}}*[Symbol.iterator](){for(let[e,t]of this.entries())yield[e,t]}forEach(e){let t=0;for(let[n,r]of this.entries())e(r,n,t++)}map(e){let t=[],n=0;for(let[r,i]of this.entries())t.push(e(i,r,n++));return t}isThisCollection(e){return e===this.collection}recomputeOptimisticState(e=!1){if(this.isCommittingSyncTransactions&&!e)return;let t=new Map(this.optimisticUpserts),n=new Set(this.optimisticDeletes);this.optimisticUpserts.clear(),this.optimisticDeletes.clear();let r=[];for(let s of this.transactions.values())["completed","failed"].includes(s.state)||r.push(s);for(let s of r)for(let a of s.mutations)if(this.isThisCollection(a.collection)&&a.optimistic)switch(a.type){case"insert":case"update":this.optimisticUpserts.set(a.key,a.modified),this.optimisticDeletes.delete(a.key);break;case"delete":this.optimisticUpserts.delete(a.key),this.optimisticDeletes.add(a.key);break}this.size=this.calculateSize();let i=[];this.collectOptimisticChanges(t,n,i);let o=i.filter(s=>!!(!this.recentlySyncedKeys.has(s.key)||e));if(this.pendingSyncedTransactions.length>0&&!e){let s=new Set;for(let l of this.pendingSyncedTransactions)for(let u of l.operations)s.add(u.key);let a=o.filter(l=>!(l.type==="delete"&&s.has(l.key)&&!r.some(u=>u.mutations.some(c=>this.isThisCollection(c.collection)&&c.key===l.key))));a.length>0&&this.indexes.updateIndexes(a),this.changes.emitEvents(a,e)}else o.length>0&&this.indexes.updateIndexes(o),this.changes.emitEvents(o,e)}calculateSize(){let e=this.syncedData.size,t=Array.from(this.optimisticDeletes).filter(r=>this.syncedData.has(r)&&!this.optimisticUpserts.has(r)).length,n=Array.from(this.optimisticUpserts.keys()).filter(r=>!this.syncedData.has(r)).length;return e-t+n}collectOptimisticChanges(e,t,n){let r=new Set([...e.keys(),...this.optimisticUpserts.keys(),...t,...this.optimisticDeletes]);for(let i of r){let o=this.get(i),s=this.getPreviousValue(i,e,t);s!==void 0&&o===void 0?n.push({type:"delete",key:i,value:s}):s===void 0&&o!==void 0?n.push({type:"insert",key:i,value:o}):s!==void 0&&o!==void 0&&s!==o&&n.push({type:"update",key:i,value:o,previousValue:s})}}getPreviousValue(e,t,n){if(!n.has(e))return t.has(e)?t.get(e):this.syncedData.get(e)}scheduleTransactionCleanup(e){if(e.state==="completed"){this.transactions.delete(e.id);return}e.isPersisted.promise.then(()=>{this.transactions.delete(e.id)}).catch(()=>{})}capturePreSyncVisibleState(){if(this.pendingSyncedTransactions.length===0)return;let e=new Set;for(let t of this.pendingSyncedTransactions)for(let n of t.operations)e.add(n.key);for(let t of e)this.recentlySyncedKeys.add(t);for(let t of e)if(!this.preSyncVisibleState.has(t)){let n=this.get(t);n!==void 0&&this.preSyncVisibleState.set(t,n)}}onTransactionStateChange(){this.changes.shouldBatchEvents=this.pendingSyncedTransactions.length>0,this.capturePreSyncVisibleState(),this.recomputeOptimisticState(!1)}cleanup(){this.syncedData.clear(),this.syncedMetadata.clear(),this.optimisticUpserts.clear(),this.optimisticDeletes.clear(),this.size=0,this.pendingSyncedTransactions=[],this.syncedKeys.clear(),this.hasReceivedFirstCommit=!1}},zJ=class{constructor(){this.listeners=new Map}on(e,t){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(t),()=>{this.listeners.get(e)?.delete(t)}}once(e,t){let n=this.on(e,r=>{t(r),n()});return n}off(e,t){this.listeners.get(e)?.delete(t)}waitFor(e,t){return new Promise((n,r)=>{let i,o=this.on(e,s=>{i&&(clearTimeout(i),i=void 0),n(s),o()});t&&(i=setTimeout(()=>{i=void 0,o(),r(new Error(`Timeout waiting for event ${String(e)}`))},t))})}emitInner(e,t){this.listeners.get(e)?.forEach(n=>{try{n(t)}catch(r){queueMicrotask(()=>{throw r})}})}clearListeners(){this.listeners.clear()}};function NIe(e,t){if(t.length===0||e.length===0)return;if(e.length===1){let{expression:r,compareOptions:i}=e[0];return(i.direction==="asc"?I8:xP)(r,new Go(t[0]))}let n=[];for(let r=0;r<e.length&&r<t.length;r++){let i=e[r],o=t[r],s=[];for(let l=0;l<r;l++){let u=e[l],c=t[l];s.push(Qy(u.expression,new Go(c)))}let a=(i.compareOptions.direction==="asc"?I8:xP)(i.expression,new Go(o));if(s.length===0)n.push(a);else{let l=[...s,a];n.push(l.reduce((u,c)=>SP(u,c)))}}return n.length===1?n[0]:n.reduce((r,i)=>lIe(r,i))}var MIe=class extends zJ{constructor(e,t,n){super(),this.collection=e,this.callback=t,this.options=n,this.loadedInitialState=!1,this.skipFiltering=!1,this.snapshotSent=!1,this.loadedSubsets=[],this.sentKeys=new Set,this.limitedSnapshotRowCount=0,this._status="ready",this.pendingLoadSubsetPromises=new Set,this.isBufferingForTruncate=!1,this.truncateBuffer=[],this.pendingTruncateRefetches=new Set,n.onUnsubscribe&&this.on("unsubscribed",i=>n.onUnsubscribe(i)),n.whereExpression&&dIe(n.whereExpression,this.collection);let r=i=>{t(i),this.trackSentKeys(i)};this.callback=r,this.filteredCallback=n.whereExpression?SIe(this.callback,n):this.callback,this.truncateCleanup=this.collection.on("truncate",()=>{this.handleTruncate()})}get status(){return this._status}handleTruncate(){let e=[...this.loadedSubsets],t=this.collection._sync.syncLoadSubsetFn!==null;if(e.length===0||!t){this.snapshotSent=!1,this.loadedInitialState=!1,this.limitedSnapshotRowCount=0,this.lastSentKey=void 0,this.loadedSubsets=[];return}this.isBufferingForTruncate=!0,this.truncateBuffer=[],this.pendingTruncateRefetches.clear(),this.snapshotSent=!1,this.loadedInitialState=!1,this.limitedSnapshotRowCount=0,this.lastSentKey=void 0,this.loadedSubsets=[],queueMicrotask(()=>{if(this.isBufferingForTruncate){for(let n of e){let r=this.collection._sync.loadSubset(n);this.loadedSubsets.push(n),this.trackLoadSubsetPromise(r),r instanceof Promise&&(this.pendingTruncateRefetches.add(r),r.catch(()=>{}).finally(()=>{this.pendingTruncateRefetches.delete(r),this.checkTruncateRefetchComplete()}))}this.pendingTruncateRefetches.size===0&&this.flushTruncateBuffer()}})}checkTruncateRefetchComplete(){this.pendingTruncateRefetches.size===0&&this.isBufferingForTruncate&&this.flushTruncateBuffer()}flushTruncateBuffer(){this.isBufferingForTruncate=!1;let e=this.truncateBuffer.flat();e.length>0&&this.filteredCallback(e),this.truncateBuffer=[]}setOrderByIndex(e){this.orderByIndex=e}setStatus(e){if(this._status===e)return;let t=this._status;this._status=e,this.emitInner("status:change",{type:"status:change",subscription:this,previousStatus:t,status:e});let n=`status:${e}`;this.emitInner(n,{type:n,subscription:this,previousStatus:t,status:e})}trackLoadSubsetPromise(e){e instanceof Promise&&(this.pendingLoadSubsetPromises.add(e),this.setStatus("loadingSubset"),e.finally(()=>{this.pendingLoadSubsetPromises.delete(e),this.pendingLoadSubsetPromises.size===0&&this.setStatus("ready")}))}hasLoadedInitialState(){return this.loadedInitialState}hasSentAtLeastOneSnapshot(){return this.snapshotSent}emitEvents(e){let t=this.filterAndFlipChanges(e);this.isBufferingForTruncate?t.length>0&&this.truncateBuffer.push(t):this.filteredCallback(t)}requestSnapshot(e){if(this.loadedInitialState)return!1;let t={where:this.options.whereExpression,optimizedOnly:e?.optimizedOnly??!1};if(e){if("where"in e){let s=e.where;if(t.where){let a=t.where,l=SP(a,s);t.where=l}else t.where=s}}else this.loadedInitialState=!0;let n={where:t.where,subscription:this,orderBy:e?.orderBy,limit:e?.limit},r=this.collection._sync.loadSubset(n);e?.onLoadSubsetResult?.(r),this.loadedSubsets.push(n),(e?.trackLoadSubsetPromise??!0)&&this.trackLoadSubsetPromise(r);let i=this.collection.currentStateAsChanges(t);if(i===void 0)return!1;let o=i.filter(s=>!this.sentKeys.has(s.key));for(let s of o)this.sentKeys.add(s.key);return this.snapshotSent=!0,this.callback(o),!0}requestLimitedSnapshot({orderBy:e,limit:t,minValues:n,offset:r,trackLoadSubsetPromise:i=!0,onLoadSubsetResult:o}){if(!t)throw new Error("limit is required");if(!this.orderByIndex)throw new Error("Ordered snapshot was requested but no index was found. You have to call setOrderByIndex before requesting an ordered snapshot.");let s=n!==void 0&&n.length>0,a=n?.[0],l=this.orderByIndex,u=this.options.whereExpression,c=u?Pw(u):void 0,d=k=>{if(k!==void 0&&this.sentKeys.has(k))return!1;let C=this.collection.get(k);return C===void 0?!1:c?.(C)??!0},h=a,f=[],p=[];if(s){let{expression:k}=e[0],C=this.collection.currentStateAsChanges({where:Qy(k,new Go(a))});if(C){let N=C.map(D=>D.key).filter(D=>!this.sentKeys.has(D)&&d(D));p.push(...N);let E=l.take(t-p.length,a,d);p.push(...E)}else p=l.take(t,a,d)}else p=l.takeFromStart(t,d);let m=()=>Math.max(t-f.length,0),g=()=>p.length===0,y=e[0].expression,v=y.type==="ref"?ro(new oo(y.path),!0):null;for(;m()>0&&!g();){let k=new Set;for(let C of p){let N=this.collection.get(C);f.push({type:"insert",key:C,value:N}),h=v?v(N):N,k.add(C)}p=l.take(m(),h,d)}let b=this.limitedSnapshotRowCount;for(let k of f)this.sentKeys.add(k.key);this.callback(f),this.limitedSnapshotRowCount+=f.length,f.length>0&&(this.lastSentKey=f[f.length-1].key);let w;if(n!==void 0&&n.length>0){let k=NIe(e,n);if(k){let{expression:C}=e[0],N=n[0],E;if(N instanceof Date){let D=new Date(N.getTime()+1);E=SP(aIe(C,new Go(N)),xP(C,new Go(D)))}else E=Qy(C,new Go(N));w={whereFrom:k,whereCurrent:E,lastKey:this.lastSentKey}}}let x={where:u,limit:t,orderBy:e,cursor:w,offset:r??b,subscription:this},S=this.collection._sync.loadSubset(x);o?.(S),this.loadedSubsets.push(x),i&&this.trackLoadSubsetPromise(S)}filterAndFlipChanges(e){if(this.loadedInitialState||this.skipFiltering)return e;let t=this.isBufferingForTruncate,n=[];for(let r of e){let i=r;if(this.sentKeys.has(r.key)){if(r.type==="insert")continue;r.type==="delete"&&this.sentKeys.delete(r.key)}else{if(r.type==="update")i={...r,type:"insert",previousValue:void 0};else if(r.type==="delete"&&!t)continue;this.sentKeys.add(r.key)}n.push(i)}return n}trackSentKeys(e){if(!(this.loadedInitialState||this.skipFiltering)){for(let t of e)t.type==="delete"?this.sentKeys.delete(t.key):this.sentKeys.add(t.key);this.orderByIndex&&(this.limitedSnapshotRowCount=Math.max(this.limitedSnapshotRowCount,this.sentKeys.size))}}markAllStateAsSeen(){this.skipFiltering=!0}unsubscribe(){this.truncateCleanup?.(),this.truncateCleanup=void 0,this.isBufferingForTruncate=!1,this.truncateBuffer=[],this.pendingTruncateRefetches.clear();for(let e of this.loadedSubsets)this.collection._sync.unloadSubset(e);this.loadedSubsets=[],this.emitInner("unsubscribed",{type:"unsubscribed",subscription:this}),this.clearListeners()}},_Ie=class{constructor(){this.activeSubscribersCount=0,this.changeSubscriptions=new Set,this.batchedEvents=[],this.shouldBatchEvents=!1}setDeps(e){this.lifecycle=e.lifecycle,this.sync=e.sync,this.events=e.events,this.collection=e.collection}emitEmptyReadyEvent(){for(let e of this.changeSubscriptions)e.emitEvents([])}emitEvents(e,t=!1){if(this.shouldBatchEvents&&!t){this.batchedEvents.push(...e);return}let n=e;if(t&&(this.batchedEvents.length>0&&(n=[...this.batchedEvents,...e]),this.batchedEvents=[],this.shouldBatchEvents=!1),n.length!==0)for(let r of this.changeSubscriptions)r.emitEvents(n)}subscribeChanges(e,t={}){if(this.addSubscriber(),t.where&&t.whereExpression)throw new Error("Cannot specify both 'where' and 'whereExpression' options. Use one or the other.");let{where:n,...r}=t,i=r.whereExpression;if(n){let s=BJ(),a=n(s);i=Ir(a)}let o=new MIe(this.collection,e,{...r,whereExpression:i,onUnsubscribe:()=>{this.removeSubscriber(),this.changeSubscriptions.delete(o)}});return t.onStatusChange&&o.on("status:change",t.onStatusChange),t.includeInitialState?o.requestSnapshot({trackLoadSubsetPromise:!1,orderBy:t.orderBy,limit:t.limit,onLoadSubsetResult:t.onLoadSubsetResult}):t.includeInitialState===!1&&o.markAllStateAsSeen(),this.changeSubscriptions.add(o),o}addSubscriber(){let e=this.activeSubscribersCount;this.activeSubscribersCount++,this.lifecycle.cancelGCTimer(),(this.lifecycle.status==="cleaned-up"||this.lifecycle.status==="idle")&&this.sync.startSync(),this.events.emitSubscribersChange(this.activeSubscribersCount,e)}removeSubscriber(){let e=this.activeSubscribersCount;if(this.activeSubscribersCount--,this.activeSubscribersCount===0)this.lifecycle.startGCTimer();else if(this.activeSubscribersCount<0)throw new ODe;this.events.emitSubscribersChange(this.activeSubscribersCount,e)}cleanup(){this.batchedEvents=[],this.shouldBatchEvents=!1}},EIe=e=>setTimeout(()=>{e({didTimeout:!0,timeRemaining:()=>50})},0),OIe=e=>{clearTimeout(e)},TIe=typeof window<"u"&&"requestIdleCallback"in window?(e,t)=>window.requestIdleCallback(e,t):(e,t)=>EIe(e),G2=typeof window<"u"&&"cancelIdleCallback"in window?e=>window.cancelIdleCallback(e):OIe,AIe=class{constructor(e,t){this.status="idle",this.hasBeenReady=!1,this.hasReceivedFirstCommit=!1,this.onFirstReadyCallbacks=[],this.gcTimeoutId=null,this.idleCallbackId=null,this.config=e,this.id=t}setDeps(e){this.indexes=e.indexes,this.events=e.events,this.changes=e.changes,this.sync=e.sync,this.state=e.state}validateStatusTransition(e,t){if(e!==t&&!{idle:["loading","error","cleaned-up"],loading:["ready","error","cleaned-up"],ready:["cleaned-up","error"],error:["cleaned-up","idle"],"cleaned-up":["loading","error"]}[e].includes(t))throw new _De(e,t,this.id)}setStatus(e,t=!1){if(e==="ready"&&!t)throw new t1(`You can't directly call "setStatus('ready'). You must use markReady instead.`);this.validateStatusTransition(this.status,e);let n=this.status;this.status=e,e==="ready"&&!this.indexes.isIndexesResolved&&this.indexes.resolveAllIndexes().catch(r=>{console.warn(`${this.config.id?`[${this.config.id}] `:""}Failed to resolve indexes:`,r)}),this.events.emitStatusChange(e,n)}validateCollectionUsable(e){switch(this.status){case"error":throw new MDe(e,this.id);case"cleaned-up":this.sync.startSync();break}}markReady(){if(this.validateStatusTransition(this.status,"ready"),this.status==="loading"){if(this.setStatus("ready",!0),!this.hasBeenReady){this.hasBeenReady=!0,this.hasReceivedFirstCommit||(this.hasReceivedFirstCommit=!0);let e=[...this.onFirstReadyCallbacks];this.onFirstReadyCallbacks=[],e.forEach(t=>t())}this.changes.changeSubscriptions.size>0&&this.changes.emitEmptyReadyEvent()}}startGCTimer(){this.gcTimeoutId&&clearTimeout(this.gcTimeoutId);let e=this.config.gcTime??3e5;e<=0||!Number.isFinite(e)||(this.gcTimeoutId=setTimeout(()=>{this.changes.activeSubscribersCount===0&&this.scheduleIdleCleanup()},e))}cancelGCTimer(){this.gcTimeoutId&&(clearTimeout(this.gcTimeoutId),this.gcTimeoutId=null),this.idleCallbackId!==null&&(G2(this.idleCallbackId),this.idleCallbackId=null)}scheduleIdleCleanup(){this.idleCallbackId!==null&&G2(this.idleCallbackId),this.idleCallbackId=TIe(e=>{this.changes.activeSubscribersCount===0?this.performCleanup(e)&&(this.idleCallbackId=null):this.idleCallbackId=null},{timeout:1e3})}performCleanup(e){if(!e||e.timeRemaining()>0||e.didTimeout){this.sync.cleanup(),this.state.cleanup(),this.changes.cleanup(),this.indexes.cleanup(),this.gcTimeoutId&&(clearTimeout(this.gcTimeoutId),this.gcTimeoutId=null),this.hasBeenReady=!1;let t=[...this.onFirstReadyCallbacks];return this.onFirstReadyCallbacks=[],t.forEach(n=>{try{n()}catch(r){console.error(`${this.config.id?`[${this.config.id}] `:""}Error in onFirstReady callback during cleanup:`,r)}}),this.setStatus("cleaned-up"),this.events.cleanup(),!0}else return this.scheduleIdleCleanup(),!1}onFirstReady(e){if(this.hasBeenReady){e();return}this.onFirstReadyCallbacks.push(e)}cleanup(){this.idleCallbackId!==null&&(G2(this.idleCallbackId),this.idleCallbackId=null),this.performCleanup()}},pz=Symbol("liveQueryInternal"),DIe=class{constructor(e,t){this.preloadPromise=null,this.syncCleanupFn=null,this.syncLoadSubsetFn=null,this.syncUnloadSubsetFn=null,this.pendingLoadSubsetPromises=new Set,this.config=e,this.id=t,this.syncMode=e.syncMode??"eager"}setDeps(e){this.collection=e.collection,this.state=e.state,this.lifecycle=e.lifecycle,this._events=e.events}startSync(){if(!(this.lifecycle.status!=="idle"&&this.lifecycle.status!=="cleaned-up")){this.lifecycle.setStatus("loading");try{let e=RIe(this.config.sync.sync({collection:this.collection,begin:t=>{this.state.pendingSyncedTransactions.push({committed:!1,operations:[],deletedKeys:new Set,immediate:t?.immediate})},write:t=>{let n=this.state.pendingSyncedTransactions[this.state.pendingSyncedTransactions.length-1];if(!n)throw new p8;if(n.committed)throw new m8;let r;"key"in t?r=t.key:r=this.config.getKey(t.value);let i=t.type;if(t.type==="insert"){let s=this.state.syncedData.has(r),a=n.deletedKeys.has(r),l=n.truncate===!0;if(s&&!a&&!l){let u=this.state.syncedData.get(r);if(u!==void 0&&ol(u,t.value))i="update";else{let c=this.config.utils[pz];throw new RDe(r,this.id,{hasCustomGetKey:c?.hasCustomGetKey??!1,hasJoins:c?.hasJoins??!1,hasDistinct:c?.hasDistinct??!1})}}}let o={...t,type:i,key:r};n.operations.push(o),i==="delete"&&n.deletedKeys.add(r)},commit:()=>{let t=this.state.pendingSyncedTransactions[this.state.pendingSyncedTransactions.length-1];if(!t)throw new KDe;if(t.committed)throw new YDe;t.committed=!0,this.state.commitPendingTransactions()},markReady:()=>{this.lifecycle.markReady()},truncate:()=>{let t=this.state.pendingSyncedTransactions[this.state.pendingSyncedTransactions.length-1];if(!t)throw new p8;if(t.committed)throw new m8;t.operations=[],t.deletedKeys.clear(),t.truncate=!0,t.optimisticSnapshot={upserts:new Map(this.state.optimisticUpserts),deletes:new Set(this.state.optimisticDeletes)}}}));if(this.syncCleanupFn=e?.cleanup??null,this.syncLoadSubsetFn=e?.loadSubset??null,this.syncUnloadSubsetFn=e?.unloadSubset??null,this.syncMode==="on-demand"&&!this.syncLoadSubsetFn)throw new e1(`Collection "${this.id}" is configured with syncMode "on-demand" but the sync function did not return a loadSubset handler. Either provide a loadSubset handler or use syncMode "eager".`)}catch(e){throw this.lifecycle.setStatus("error"),e}}}preload(){return this.preloadPromise?this.preloadPromise:(this.syncMode==="on-demand"&&console.warn(`${this.id?`[${this.id}] `:""}Calling .preload() on a collection with syncMode "on-demand" is a no-op. In on-demand mode, data is only loaded when queries request it. Instead, create a live query and call .preload() on that to load the specific data you need. See https://tanstack.com/blog/tanstack-db-0.5-query-driven-sync for more details.`),this.preloadPromise=new Promise((e,t)=>{if(this.lifecycle.status==="ready"){e();return}if(this.lifecycle.status==="error"){t(new EDe);return}if(this.lifecycle.onFirstReady(()=>{e()}),this.lifecycle.status==="idle"||this.lifecycle.status==="cleaned-up")try{this.startSync()}catch(n){t(n);return}}),this.preloadPromise)}get isLoadingSubset(){return this.pendingLoadSubsetPromises.size>0}trackLoadPromise(e){let t=!this.isLoadingSubset;this.pendingLoadSubsetPromises.add(e),t&&this._events.emit("loadingSubset:change",{type:"loadingSubset:change",collection:this.collection,isLoadingSubset:!0,previousIsLoadingSubset:!1,loadingSubsetTransition:"start"}),e.finally(()=>{let n=this.pendingLoadSubsetPromises.size===1&&this.pendingLoadSubsetPromises.has(e);this.pendingLoadSubsetPromises.delete(e),n&&this._events.emit("loadingSubset:change",{type:"loadingSubset:change",collection:this.collection,isLoadingSubset:!1,previousIsLoadingSubset:!0,loadingSubsetTransition:"end"})})}loadSubset(e){if(this.syncMode==="eager")return!0;if(this.syncLoadSubsetFn){let t=this.syncLoadSubsetFn(e);if(t instanceof Promise)return this.trackLoadPromise(t),t}return!0}unloadSubset(e){this.syncUnloadSubsetFn&&this.syncUnloadSubsetFn(e)}cleanup(){try{this.syncCleanupFn&&(this.syncCleanupFn(),this.syncCleanupFn=null)}catch(e){queueMicrotask(()=>{if(e instanceof Error){let t=new v8(this.id,e);throw t.cause=e,t.stack=e.stack,t}else throw new v8(this.id,e)})}this.preloadPromise=null}};function RIe(e){if(typeof e=="function")return{cleanup:e};if(typeof e=="object")return e}function FJ(e){return typeof e=="function"&&e.prototype!==void 0&&e.prototype.constructor===e}async function IIe(e){return FJ(e)?e:await e()}var PIe=class{constructor(e,t,n,r,i,o){this.id=e,this.expression=t,this.name=n,this.resolver=r,this.options=i,this.collectionEntries=o,this.indexPromise=null,this.resolvedIndex=null,FJ(this.resolver)&&(this.resolvedIndex=new this.resolver(this.id,this.expression,this.name,this.options),this.collectionEntries&&this.resolvedIndex.build(this.collectionEntries))}async resolve(){return this.resolvedIndex?this.resolvedIndex:(this.indexPromise||(this.indexPromise=this.createIndex()),this.resolvedIndex=await this.indexPromise,this.resolvedIndex)}isResolved(){return this.resolvedIndex!==null}getResolved(){if(!this.resolvedIndex)throw new Error(`Index ${this.id} has not been resolved yet. Ensure collection is synced.`);return this.resolvedIndex}getId(){return this.id}getName(){return this.name}getExpression(){return this.expression}async createIndex(){let e=await IIe(this.resolver);return new e(this.id,this.expression,this.name,this.options)}},LIe=class{constructor(e,t){this.indexId=e,this.lazyIndex=t}get index(){return this.lazyIndex.getResolved()}get isReady(){return this.lazyIndex.isResolved()}async whenReady(){return await this.lazyIndex.resolve()}get id(){return this.indexId}get name(){return this.isReady?this.index.name:this.lazyIndex.getName()}get expression(){return this.lazyIndex.getExpression()}supports(e){return this.index.supports(e)}getStats(){return this.index.getStats()}matchesField(e){let t=this.expression;return t.type==="ref"&&t.path.length===e.length&&t.path.every((n,r)=>n===e[r])}get keyCount(){return this.index.keyCount}get indexedKeysSet(){return this.index.indexedKeysSet}get orderedEntriesArray(){return this.index.orderedEntriesArray}get valueMapData(){return this.index.valueMapData}equalityLookup(e){return this.index.equalityLookup?.(e)??new Set}rangeQuery(e){return this.index.rangeQuery?.(e)??new Set}inArrayLookup(e){return this.index.inArrayLookup?.(e)??new Set}_getLazyWrapper(){return this.lazyIndex}},BIe=class{constructor(){this.lazyIndexes=new Map,this.resolvedIndexes=new Map,this.isIndexesResolved=!1,this.indexCounter=0}setDeps(e){this.state=e.state,this.lifecycle=e.lifecycle}createIndex(e,t={}){this.lifecycle.validateCollectionUsable("createIndex");let n=++this.indexCounter,r=BJ(),i=e(r),o=Ir(i),s=t.indexType??kP,a=new PIe(n,o,t.name,s,t.options,this.state.entries());if(this.lazyIndexes.set(n,a),s===kP)try{let l=a.getResolved();this.resolvedIndexes.set(n,l)}catch(l){console.warn("Failed to resolve BTreeIndex:",l)}else if(typeof s=="function"&&s.prototype)try{let l=a.getResolved();this.resolvedIndexes.set(n,l)}catch{this.resolveSingleIndex(n,a).catch(l=>{console.warn("Failed to resolve single index:",l)})}else this.isIndexesResolved&&this.resolveSingleIndex(n,a).catch(l=>{console.warn("Failed to resolve single index:",l)});return new LIe(n,a)}async resolveAllIndexes(){if(this.isIndexesResolved)return;let e=Array.from(this.lazyIndexes.entries()).map(async([t,n])=>{let r=await n.resolve();return r.build(this.state.entries()),this.resolvedIndexes.set(t,r),{indexId:t,resolvedIndex:r}});await Promise.all(e),this.isIndexesResolved=!0}async resolveSingleIndex(e,t){let n=await t.resolve();return n.build(this.state.entries()),this.resolvedIndexes.set(e,n),n}get indexes(){return this.resolvedIndexes}updateIndexes(e){for(let t of this.resolvedIndexes.values())for(let n of e)switch(n.type){case"insert":t.add(n.key,n.value);break;case"update":n.previousValue?t.update(n.key,n.previousValue,n.value):t.add(n.key,n.value);break;case"delete":t.remove(n.key,n.value);break}}cleanup(){this.lazyIndexes.clear(),this.resolvedIndexes.clear()}},qIe=new Set(["find","findLast","findIndex","findLastIndex","filter","map","flatMap","forEach","some","every","reduce","reduceRight"]),zIe=new Set(["pop","push","shift","unshift","splice","sort","reverse","fill","copyWithin"]),FIe=new Set(["set","delete","clear","add"]),jIe=new Set(["entries","keys","values","forEach"]);function mz(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)&&!Rw(e)}function VIe(e,t,n,r){if(qIe.has(e))return function(...i){let o=i[0];if(typeof o!="function")return t.apply(n.copy_,i);let s=(u,c)=>{if(mz(u)){let d={tracker:n,prop:String(c)},{proxy:h}=r(u,d);return h}return u},a=function(u,c,d){let h=s(u,c);return o.call(this,h,c,d)};if(e==="reduce"||e==="reduceRight"){let u=function(c,d,h,f){let p=s(d,h);return o.call(this,c,p,h,f)};return t.apply(n.copy_,[u,...i.slice(1)])}let l=t.apply(n.copy_,[a,...i.slice(1)]);if((e==="find"||e==="findLast")&&l&&typeof l=="object"){let u=n.copy_.indexOf(l);if(u!==-1)return s(l,u)}return e==="filter"&&Array.isArray(l)?l.map(u=>{let c=n.copy_.indexOf(u);return c!==-1?s(u,c):u}):l}}function WIe(e,t){return function(){let n=e.copy_,r=0;return{next(){if(r>=n.length)return{done:!0,value:void 0};let i=n[r],o=i;if(mz(i)){let s={tracker:e,prop:String(r)},{proxy:a}=t(i,s);o=a}return r++,{done:!1,value:o}},[Symbol.iterator](){return this}}}}function z8(e,t,n){return function(...r){let i=e.apply(t.copy_,r);return n(t),i}}function UIe(e,t,n,r,i,o,s){if(jIe.has(e)||t===Symbol.iterator)return function(...a){let l=n.apply(i.copy_,a);if(e==="forEach"){let u=a[0];if(typeof u=="function"){let c=function(d,h,f){let p=u.call(this,d,h,f);return s(i),p};return n.apply(r,[c,...a.slice(1)])}}if(e==="entries"||e==="values"||e===Symbol.iterator.toString()||t===Symbol.iterator){let u=l,c=new Map;if(e==="values"&&r instanceof Map)for(let[h,f]of i.copy_.entries())c.set(f,h);let d=new Map;if(r instanceof Set)for(let h of i.copy_.values())d.set(h,h);return{next(){let h=u.next();if(!h.done&&h.value&&typeof h.value=="object"){if(e==="entries"&&Array.isArray(h.value)&&h.value.length===2){if(h.value[1]&&typeof h.value[1]=="object"){let f=h.value[0],p={tracker:i,prop:f,updateMap:g=>{i.copy_ instanceof Map&&i.copy_.set(f,g)}},{proxy:m}=o(h.value[1],p);h.value[1]=m}}else if(e==="values"||e===Symbol.iterator.toString()||t===Symbol.iterator)if(e==="values"&&r instanceof Map){let f=c.get(h.value);if(f!==void 0){let p={tracker:i,prop:f,updateMap:g=>{i.copy_ instanceof Map&&i.copy_.set(f,g)}},{proxy:m}=o(h.value,p);h.value=m}}else if(r instanceof Set){let f=h.value,p={tracker:i,prop:f,updateSet:g=>{i.copy_ instanceof Set&&(i.copy_.delete(f),i.copy_.add(g),d.set(f,g))}},{proxy:m}=o(h.value,p);h.value=m}else{let f=Symbol("iterator-value"),{proxy:p}=o(h.value,{tracker:i,prop:f});h.value=p}}return h},[Symbol.iterator](){return this}}}return l}}function jt(...e){let t=typeof window<"u"&&typeof localStorage<"u";t&&localStorage.getItem("DEBUG")==="true"?console.log("[proxy]",...e):!t&&typeof process<"u"&&process.env.DEBUG==="true"&&console.log("[proxy]",...e)}function vc(e,t=new WeakMap){if(e==null||typeof e!="object")return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){let i=[];return t.set(e,i),e.forEach((o,s)=>{i[s]=vc(o,t)}),i}if(ArrayBuffer.isView(e)&&!(e instanceof DataView)){let i=Object.getPrototypeOf(e).constructor,o=new i(e.length);t.set(e,o);for(let s=0;s<e.length;s++)o[s]=e[s];return o}if(e instanceof Map){let i=new Map;return t.set(e,i),e.forEach((o,s)=>{i.set(s,vc(o,t))}),i}if(e instanceof Set){let i=new Set;return t.set(e,i),e.forEach(o=>{i.add(vc(o,t))}),i}if(Rw(e))return e;let n={};t.set(e,n);for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=vc(e[i],t));let r=Object.getOwnPropertySymbols(e);for(let i of r)n[i]=vc(e[i],t);return n}var F8=0;function HIe(){return F8+=1,F8}function gz(e,t){let n=new Map;function r(c,d){if(jt("Object ID:",c.constructor.name),n.has(c))return n.get(c);{let h=gz(c,d);return n.set(c,h),h}}let i=new Map,o={copy_:vc(e),originalObject:vc(e),proxyCount:HIe(),modified:!1,assigned_:{},parent:t,target:e};jt("createChangeProxy called for target",e,o.proxyCount);function s(c){c.modified||(c.modified=!0),c.parent&&(jt("propagating change to parent"),"updateMap"in c.parent?c.parent.updateMap(c.copy_):"updateSet"in c.parent?c.parent.updateSet(c.copy_):(c.parent.tracker.copy_[c.parent.prop]=c.copy_,c.parent.tracker.assigned_[c.parent.prop]=!0),s(c.parent.tracker))}function a(c){if(jt("checkIfReverted called with assigned keys:",Object.keys(c.assigned_)),Object.keys(c.assigned_).length===0&&Object.getOwnPropertySymbols(c.assigned_).length===0)return jt("No assigned properties, returning true"),!0;for(let h in c.assigned_)if(c.assigned_[h]===!0){let f=c.copy_[h],p=c.originalObject[h];if(jt(`Checking property ${String(h)}, current:`,f,"original:",p),!ol(f,p))return jt(`Property ${String(h)} is different, returning false`),!1}else if(c.assigned_[h]===!1)return jt(`Property ${String(h)} was deleted, returning false`),!1;let d=Object.getOwnPropertySymbols(c.assigned_);for(let h of d)if(c.assigned_[h]===!0){let f=c.copy_[h],p=c.originalObject[h];if(!ol(f,p))return jt("Symbol property is different, returning false"),!1}else if(c.assigned_[h]===!1)return jt("Symbol property was deleted, returning false"),!1;return jt("All properties match original values, returning true"),!0}function l(c,d){jt("checkParentStatus called for child prop:",d);let h=a(c);jt("Parent checkIfReverted returned:",h),h&&(jt("Parent is fully reverted, clearing tracking"),c.modified=!1,c.assigned_={},c.parent&&(jt("Continuing up the parent chain"),l(c.parent.tracker,c.parent.prop)))}function u(c){if(jt("createObjectProxy",c),i.has(c))return jt("proxyCache found match"),i.get(c);let d=new Proxy(c,{get(h,f){jt("get",h,f);let p=o.copy_[f]??o.originalObject[f],m=o.originalObject[f];if(jt("value (at top of proxy get)",p),Object.getOwnPropertyDescriptor(h,f)?.get)return p;if(typeof p=="function"){if(Array.isArray(h)){let g=f.toString();if(zIe.has(g))return z8(p,o,s);let y=VIe(g,p,o,r);if(y)return y;if(f===Symbol.iterator)return WIe(o,r)}if(h instanceof Map||h instanceof Set){let g=f.toString();if(FIe.has(g))return z8(p,o,s);let y=UIe(g,f,p,h,o,r,s);if(y)return y}return p.bind(h)}if(mz(p)){let g={tracker:o,prop:String(f)},{proxy:y}=r(m,g);return i.set(p,y),y}return p},set(h,f,p){let m=o.copy_[f];if(jt(`set called for property ${String(f)}, current:`,m,"new:",p),ol(m,p))jt("Value unchanged, not tracking");else{let g=o.originalObject[f],y=ol(p,g);if(jt("value:",p,"original:",g,"isRevertToOriginal:",y),y){jt(`Reverting property ${String(f)} to original value`),delete o.assigned_[f.toString()],jt(`Updating copy with original value for ${String(f)}`),o.copy_[f]=vc(g),jt("Checking if all properties reverted");let v=a(o);jt("All reverted:",v),v?(jt("All properties reverted, clearing tracking"),o.modified=!1,o.assigned_={},t&&(jt("Updating parent for property:",t.prop),l(t.tracker,t.prop))):(jt("Some properties still changed, keeping modified flag"),o.modified=!0)}else jt(`Setting new value for property ${String(f)}`),o.copy_[f]=p,o.assigned_[f.toString()]=!0,jt("Marking object and ancestors as modified",o),s(o)}return!0},defineProperty(h,f,p){let m=Reflect.defineProperty(h,f,p);return m&&"value"in p&&(o.copy_[f]=vc(p.value),o.assigned_[f.toString()]=!0,s(o)),m},getOwnPropertyDescriptor(h,f){return Reflect.getOwnPropertyDescriptor(h,f)},preventExtensions(h){return Reflect.preventExtensions(h)},isExtensible(h){return Reflect.isExtensible(h)},deleteProperty(h,f){jt("deleteProperty",h,f);let p=typeof f=="symbol"?f.toString():f;if(p in h){let m=p in o.originalObject,g=Reflect.deleteProperty(h,f);return g&&(m?(o.assigned_[p]=!1,s(o)):(delete o.assigned_[p],Object.keys(o.assigned_).length===0&&Object.getOwnPropertySymbols(o.assigned_).length===0?o.modified=!1:o.modified=!0)),g}return!0}});return i.set(c,d),d}return{proxy:u(o.copy_),getChanges:()=>{if(jt("getChanges called, modified:",o.modified),jt(o),!o.modified)return jt("Object not modified, returning empty object"),{};if(typeof o.copy_!="object"||Array.isArray(o.copy_)||Object.keys(o.assigned_).length===0)return o.copy_;let c={};for(let d in o.copy_)o.assigned_[d]===!0&&d in o.copy_&&(c[d]=o.copy_[d]);return jt("Returning copy:",c),c}}}function $Ie(e){let t=e.map(n=>gz(n));return{proxies:t.map(n=>n.proxy),getChanges:()=>t.map(n=>n.getChanges())}}function KIe(e,t){let{proxy:n,getChanges:r}=gz(e);return t(n),r()}function YIe(e,t){let{proxies:n,getChanges:r}=$Ie(e);return t(n),r()}function QIe(){let e,t,n=!0;return{promise:new Promise((r,i)=>{e=o=>{n=!1,r(o)},t=o=>{n=!1,i(o)}}),resolve:e,reject:t,isPending:()=>n}}function GIe(e){return typeof e=="object"&&e!==null&&typeof e.hasPendingGraphRun=="function"}var XIe=class{constructor(){this.contexts=new Map,this.clearListeners=new Set}getOrCreateContext(e){let t=this.contexts.get(e);return t||(t={queue:[],jobs:new Map,dependencies:new Map,completed:new Set},this.contexts.set(e,t)),t}schedule({contextId:e,jobId:t,dependencies:n,run:r}){if(typeof e>"u"){r();return}let i=this.getOrCreateContext(e);if(i.jobs.has(t)||i.queue.push(t),i.jobs.set(t,r),n){let o=new Set(n);o.delete(t),i.dependencies.set(t,o)}else i.dependencies.has(t)||i.dependencies.set(t,new Set);i.completed.delete(t)}flush(e){let t=this.contexts.get(e);if(!t)return;let{queue:n,jobs:r,dependencies:i,completed:o}=t;for(;n.length>0;){let s=!1,a=n.length;for(let l=0;l<a;l++){let u=n.shift(),c=r.get(u);if(!c){i.delete(u),o.delete(u);continue}let d=i.get(u),h=!d;if(d){h=!0;for(let f of d){if(f===u)continue;let p=GIe(f)&&f.hasPendingGraphRun(e);if(r.has(f)&&!o.has(f)||!r.has(f)&&p){h=!1;break}}}h?(r.delete(u),i.delete(u),c(),o.add(u),s=!0):n.push(u)}if(!s)throw new Error(`Scheduler detected unresolved dependencies for context ${String(e)}.`)}this.contexts.delete(e)}flushAll(){for(let e of Array.from(this.contexts.keys()))this.flush(e)}clear(e){this.contexts.delete(e),this.clearListeners.forEach(t=>t(e))}onClear(e){return this.clearListeners.add(e),()=>this.clearListeners.delete(e)}hasPendingJobs(e){let t=this.contexts.get(e);return!!t&&t.jobs.size>0}clearJob(e,t){let n=this.contexts.get(e);n&&(n.jobs.delete(t),n.dependencies.delete(t),n.completed.delete(t),n.queue=n.queue.filter(r=>r!==t),n.jobs.size===0&&this.contexts.delete(e))}},AM=new XIe,DM=[],fx=[],JIe=0;function ZIe(e,t){switch(`${e.type}-${t.type}`){case"insert-update":return{...e,type:"insert",original:{},modified:t.modified,changes:{...e.changes,...t.changes},key:e.key,globalKey:e.globalKey,metadata:t.metadata??e.metadata,syncMetadata:{...e.syncMetadata,...t.syncMetadata},mutationId:t.mutationId,updatedAt:t.updatedAt};case"insert-delete":return null;case"update-delete":return t;case"update-update":return{...t,original:e.original,changes:{...e.changes,...t.changes},metadata:t.metadata??e.metadata,syncMetadata:{...e.syncMetadata,...t.syncMetadata}};case"delete-delete":case"insert-insert":return t;default:{let n=`${e.type}-${t.type}`;throw new Error(`Unhandled mutation combination: ${n}`)}}}function kC(e){let t=new rPe(e);return DM.push(t),t}function RN(){if(fx.length>0)return fx.slice(-1)[0]}function ePe(e){AM.clear(e.id),fx.push(e)}function tPe(e){try{AM.flush(e.id)}finally{fx=fx.filter(t=>t.id!==e.id)}}function nPe(e){let t=DM.findIndex(n=>n.id===e.id);t!==-1&&DM.splice(t,1)}var rPe=class{constructor(e){if(typeof e.mutationFn>"u")throw new WDe;this.id=e.id??crypto.randomUUID(),this.mutationFn=e.mutationFn,this.state="pending",this.mutations=[],this.isPersisted=QIe(),this.autoCommit=e.autoCommit??!0,this.createdAt=new Date,this.sequenceNumber=JIe++,this.metadata=e.metadata??{}}setState(e){this.state=e,(e==="completed"||e==="failed")&&nPe(this)}mutate(e){if(this.state!=="pending")throw new UDe;ePe(this);try{e()}finally{tPe(this)}return this.autoCommit&&this.commit().catch(()=>{}),this}applyMutations(e){for(let t of e){let n=this.mutations.findIndex(r=>r.globalKey===t.globalKey);if(n>=0){let r=this.mutations[n],i=ZIe(r,t);i===null?this.mutations.splice(n,1):this.mutations[n]=i}else this.mutations.push(t)}}rollback(e){let t=e?.isSecondaryRollback??!1;if(this.state==="completed")throw new HDe;if(this.setState("failed"),!t){let n=new Set;this.mutations.forEach(r=>n.add(r.globalKey));for(let r of DM)r.state==="pending"&&r.mutations.some(i=>n.has(i.globalKey))&&r.rollback({isSecondaryRollback:!0})}return this.isPersisted.reject(this.error?.error),this.touchCollection(),this}touchCollection(){let e=new Set;for(let t of this.mutations)e.has(t.collection.id)||(t.collection._state.onTransactionStateChange(),t.collection._state.pendingSyncedTransactions.length>0&&t.collection._state.commitPendingTransactions(),e.add(t.collection.id))}async commit(){if(this.state!=="pending")throw new $De;if(this.setState("persisting"),this.mutations.length===0)return this.setState("completed"),this.isPersisted.resolve(this),this;try{await this.mutationFn({transaction:this}),this.setState("completed"),this.touchCollection(),this.isPersisted.resolve(this)}catch(e){let t=e instanceof Error?e:new Error(String(e));throw this.error={message:t.message,error:t},this.rollback(),t}return this}compareCreatedAt(e){let t=this.createdAt.getTime()-e.createdAt.getTime();return t!==0?t:this.sequenceNumber-e.sequenceNumber}},iPe=class{constructor(e,t){this.insert=(n,r)=>{this.lifecycle.validateCollectionUsable("insert");let i=this.state,o=RN();if(!o&&!this.config.onInsert)throw new FDe;let s=Array.isArray(n)?n:[n],a=[],l=new Set;if(s.forEach(u=>{let c=this.validateData(u,"insert"),d=this.config.getKey(c);if(this.state.has(d)||l.has(d))throw new DDe(d);l.add(d);let h=this.generateGlobalKey(d,u),f={mutationId:crypto.randomUUID(),original:{},modified:c,changes:Object.fromEntries(Object.keys(u).map(p=>[p,c[p]])),globalKey:h,key:d,metadata:r?.metadata,syncMetadata:this.config.sync.getSyncMetadata?.()||{},optimistic:r?.optimistic??!0,type:"insert",createdAt:new Date,updatedAt:new Date,collection:this.collection};a.push(f)}),o)return o.applyMutations(a),i.transactions.set(o.id,o),i.scheduleTransactionCleanup(o),i.recomputeOptimisticState(!0),o;{let u=kC({mutationFn:async c=>await this.config.onInsert({transaction:c.transaction,collection:this.collection})});return u.applyMutations(a),u.commit().catch(()=>{}),i.transactions.set(u.id,u),i.scheduleTransactionCleanup(u),i.recomputeOptimisticState(!0),u}},this.delete=(n,r)=>{let i=this.state;this.lifecycle.validateCollectionUsable("delete");let o=RN();if(!o&&!this.config.onDelete)throw new VDe;if(Array.isArray(n)&&n.length===0)throw new qDe;let s=Array.isArray(n)?n:[n],a=[];for(let u of s){if(!this.state.has(u))throw new zDe(u);let c=this.generateGlobalKey(u,this.state.get(u)),d={mutationId:crypto.randomUUID(),original:this.state.get(u),modified:this.state.get(u),changes:this.state.get(u),globalKey:c,key:u,metadata:r?.metadata,syncMetadata:i.syncedMetadata.get(u)||{},optimistic:r?.optimistic??!0,type:"delete",createdAt:new Date,updatedAt:new Date,collection:this.collection};a.push(d)}if(o)return o.applyMutations(a),i.transactions.set(o.id,o),i.scheduleTransactionCleanup(o),i.recomputeOptimisticState(!0),o;let l=kC({autoCommit:!0,mutationFn:async u=>this.config.onDelete({transaction:u.transaction,collection:this.collection})});return l.applyMutations(a),l.commit().catch(()=>{}),i.transactions.set(l.id,l),i.scheduleTransactionCleanup(l),i.recomputeOptimisticState(!0),l},this.id=t,this.config=e}setDeps(e){this.lifecycle=e.lifecycle,this.state=e.state,this.collection=e.collection}ensureStandardSchema(e){if(e&&"~standard"in e)return e;throw new NDe}validateData(e,t,n){if(!this.config.schema)return e;let r=this.ensureStandardSchema(this.config.schema);if(t==="update"&&n){let o=this.state.get(n);if(o&&e&&typeof e=="object"&&typeof o=="object"){let s=Object.assign({},o,e),a=r["~standard"].validate(s);if(a instanceof Promise)throw new f8;if("issues"in a&&a.issues){let c=a.issues.map(d=>({message:d.message,path:d.path?.map(h=>String(h))}));throw new h8(t,c)}let l=a.value,u=Object.keys(e);return Object.fromEntries(u.map(c=>[c,l[c]]))}}let i=r["~standard"].validate(e);if(i instanceof Promise)throw new f8;if("issues"in i&&i.issues){let o=i.issues.map(s=>({message:s.message,path:s.path?.map(a=>String(a))}));throw new h8(t,o)}return i.value}generateGlobalKey(e,t){if(typeof e!="string"&&typeof e!="number")throw typeof e>"u"?new TDe(t):new ADe(e,t);return`KEY::${this.id}/${e}`}update(e,t,n){if(typeof e>"u")throw new IDe;let r=this.state;this.lifecycle.validateCollectionUsable("update");let i=RN();if(!i&&!this.config.onUpdate)throw new jDe;let o=Array.isArray(e),s=o?e:[e];if(o&&s.length===0)throw new PDe;let a=typeof t=="function"?t:n,l=typeof t=="function"?{}:t,u=s.map(f=>{let p=this.state.get(f);if(!p)throw new LDe(f);return p}),c;o?c=YIe(u,a):c=[KIe(u[0],a)];let d=s.map((f,p)=>{let m=c[p];if(!m||Object.keys(m).length===0)return null;let g=u[p],y=this.validateData(m,"update",f),v=Object.assign({},g,y),b=this.config.getKey(g),w=this.config.getKey(v);if(b!==w)throw new BDe(b,w);let x=this.generateGlobalKey(w,v);return{mutationId:crypto.randomUUID(),original:g,modified:v,changes:Object.fromEntries(Object.keys(m).map(S=>[S,v[S]])),globalKey:x,key:f,metadata:l.metadata,syncMetadata:r.syncedMetadata.get(f)||{},optimistic:l.optimistic??!0,type:"update",createdAt:new Date,updatedAt:new Date,collection:this.collection}}).filter(Boolean);if(d.length===0){let f=kC({mutationFn:async()=>{}});return f.commit().catch(()=>{}),r.scheduleTransactionCleanup(f),f}if(i)return i.applyMutations(d),r.transactions.set(i.id,i),r.scheduleTransactionCleanup(i),r.recomputeOptimisticState(!0),i;let h=kC({mutationFn:async f=>this.config.onUpdate({transaction:f.transaction,collection:this.collection})});return h.applyMutations(d),h.commit().catch(()=>{}),r.transactions.set(h.id,h),r.scheduleTransactionCleanup(h),r.recomputeOptimisticState(!0),h}},oPe=class extends zJ{constructor(){super()}setDeps(e){this.collection=e.collection}emit(e,t){this.emitInner(e,t)}emitStatusChange(e,t){this.emit("status:change",{type:"status:change",collection:this.collection,previousStatus:t,status:e});let n=`status:${e}`;this.emit(n,{type:n,collection:this.collection,previousStatus:t,status:e})}emitSubscribersChange(e,t){this.emit("subscribers:change",{type:"subscribers:change",collection:this.collection,previousSubscriberCount:t,subscriberCount:e})}cleanup(){this.clearListeners()}};function tu(e){let t=new yz(e);return e.utils?t.utils=e.utils:t.utils={},t}var yz=class{constructor(e){if(this.utils={},this.insert=(t,n)=>this._mutations.insert(t,n),this.delete=(t,n)=>this._mutations.delete(t,n),!e)throw new kDe;if(!e.sync)throw new CDe;e.id?this.id=e.id:this.id=crypto.randomUUID(),this.config={...e,autoIndex:e.autoIndex??"eager"},this._changes=new _Ie,this._events=new oPe,this._indexes=new BIe,this._lifecycle=new AIe(e,this.id),this._mutations=new iPe(e,this.id),this._state=new CIe(e),this._sync=new DIe(e,this.id),this.comparisonOpts=sPe(e),this._changes.setDeps({collection:this,lifecycle:this._lifecycle,sync:this._sync,events:this._events}),this._events.setDeps({collection:this}),this._indexes.setDeps({state:this._state,lifecycle:this._lifecycle}),this._lifecycle.setDeps({changes:this._changes,events:this._events,indexes:this._indexes,state:this._state,sync:this._sync}),this._mutations.setDeps({collection:this,lifecycle:this._lifecycle,state:this._state}),this._state.setDeps({collection:this,lifecycle:this._lifecycle,changes:this._changes,indexes:this._indexes,events:this._events}),this._sync.setDeps({collection:this,state:this._state,lifecycle:this._lifecycle,events:this._events}),e.startSync===!0&&this._sync.startSync()}get status(){return this._lifecycle.status}get subscriberCount(){return this._changes.activeSubscribersCount}onFirstReady(e){return this._lifecycle.onFirstReady(e)}isReady(){return this._lifecycle.status==="ready"}get isLoadingSubset(){return this._sync.isLoadingSubset}startSyncImmediate(){this._sync.startSync()}preload(){return this._sync.preload()}get(e){return this._state.get(e)}has(e){return this._state.has(e)}get size(){return this._state.size}*keys(){yield*this._state.keys()}*values(){yield*this._state.values()}*entries(){yield*this._state.entries()}*[Symbol.iterator](){yield*this._state[Symbol.iterator]()}forEach(e){return this._state.forEach(e)}map(e){return this._state.map(e)}getKeyFromItem(e){return this.config.getKey(e)}createIndex(e,t={}){return this._indexes.createIndex(e,t)}get indexes(){return this._indexes.indexes}validateData(e,t,n){return this._mutations.validateData(e,t,n)}get compareOptions(){return{...this.comparisonOpts}}update(e,t,n){return this._mutations.update(e,t,n)}get state(){let e=new Map;for(let[t,n]of this.entries())e.set(t,n);return e}stateWhenReady(){return this.size>0||this.isReady()?Promise.resolve(this.state):this.preload().then(()=>this.state)}get toArray(){return Array.from(this.values())}toArrayWhenReady(){return this.size>0||this.isReady()?Promise.resolve(this.toArray):this.preload().then(()=>this.toArray)}currentStateAsChanges(e={}){return xIe(this,e)}subscribeChanges(e,t={}){return this._changes.subscribeChanges(e,t)}on(e,t){return this._events.on(e,t)}once(e,t){return this._events.once(e,t)}off(e,t){this._events.off(e,t)}waitFor(e,t){return this._events.waitFor(e,t)}async cleanup(){return this._lifecycle.cleanup(),Promise.resolve()}};function sPe(e){if(e.defaultStringCollation){let t=e.defaultStringCollation;return{stringSort:t.stringSort??"locale",locale:t.stringSort==="locale"?t.locale:void 0,localeOptions:t.stringSort==="locale"?t.localeOptions:void 0}}else return{stringSort:"locale"}}function Jg(e){let{initialData:t,onInsert:n,onUpdate:r,onDelete:i,id:o,...s}=e,a=o??crypto.randomUUID(),l=aPe(t),u=async f=>{let p;return n&&(p=await n(f)??{}),l.confirmOperationsSync(f.transaction.mutations),p},c=async f=>{let p;return r&&(p=await r(f)??{}),l.confirmOperationsSync(f.transaction.mutations),p},d=async f=>{let p;return i&&(p=await i(f)??{}),l.confirmOperationsSync(f.transaction.mutations),p},h=f=>{let p=f.mutations.filter(m=>m.collection.id===a);p.length!==0&&l.confirmOperationsSync(p)};return{...s,id:a,sync:l.sync,onInsert:u,onUpdate:c,onDelete:d,utils:{acceptMutations:h},startSync:!0,gcTime:0}}function aPe(e){let t=null,n=null,r=null,i=null;return{sync:{sync:o=>{let{begin:s,write:a,commit:l,markReady:u}=o;return t=s,n=a,r=l,i=o.collection,e&&e.length>0&&(s(),e.forEach(c=>{a({type:"insert",value:c})}),l()),u(),()=>{}},getSyncMetadata:()=>({})},confirmOperationsSync:o=>{!t||!n||!r||(t(),o.forEach(s=>{n&&n({type:s.type,value:s.modified})}),r())},collection:i}}function by(e,t,n){try{e.stringify(t)}catch(r){throw new b2e(n,r instanceof Error?r.message:String(r))}}function X2(){return crypto.randomUUID()}function lPe(e){return typeof e=="number"?`n:${e}`:`s:${e}`}function uPe(e){return e.startsWith("n:")?Number(e.slice(2)):e.startsWith("s:")?e.slice(2):e}function cPe(){let e=new Map;return{getItem(t){return e.get(t)??null},setItem(t,n){e.set(t,n)},removeItem(t){e.delete(t)}}}function dPe(){return{addEventListener:()=>{},removeEventListener:()=>{}}}function j8(e){if(!e.storageKey)throw new w2e;let t=e.storage||(typeof window<"u"?window.localStorage:null)||cPe(),n=e.storageEventApi||(typeof window<"u"?window:null)||dPe(),r=e.parser||JSON,i=new Map,o=hPe(e.storageKey,t,n,r,e.getKey,i),s=x=>{try{let S={};x.forEach((C,N)=>{S[lPe(N)]=C});let k=r.stringify(S);t.setItem(e.storageKey,k)}catch(S){throw console.error(`[LocalStorageCollection] Error saving data to storage key "${e.storageKey}":`,S),S}},a=()=>{t.removeItem(e.storageKey)},l=()=>{let x=t.getItem(e.storageKey);return x?new Blob([x]).size:0},u=async x=>{x.transaction.mutations.forEach(k=>{by(r,k.modified,"insert")});let S={};return e.onInsert&&(S=await e.onInsert(x)??{}),x.transaction.mutations.forEach(k=>{let C={versionKey:X2(),data:k.modified};i.set(k.key,C)}),s(i),o.confirmOperationsSync(x.transaction.mutations),S},c=async x=>{x.transaction.mutations.forEach(k=>{by(r,k.modified,"update")});let S={};return e.onUpdate&&(S=await e.onUpdate(x)??{}),x.transaction.mutations.forEach(k=>{let C={versionKey:X2(),data:k.modified};i.set(k.key,C)}),s(i),o.confirmOperationsSync(x.transaction.mutations),S},d=async x=>{let S={};return e.onDelete&&(S=await e.onDelete(x)??{}),x.transaction.mutations.forEach(k=>{i.delete(k.key)}),s(i),o.confirmOperationsSync(x.transaction.mutations),S},{storageKey:h,storage:f,storageEventApi:p,onInsert:m,onUpdate:g,onDelete:y,id:v,...b}=e,w=v??`local-collection:${e.storageKey}`;return{...b,id:w,sync:o,onInsert:u,onUpdate:c,onDelete:d,utils:{clearStorage:a,getStorageSize:l,acceptMutations:x=>{let S=x.mutations.filter(k=>o.collection&&k.collection===o.collection?!0:k.collection.id===w);if(S.length!==0){for(let k of S)switch(k.type){case"insert":case"update":by(r,k.modified,k.type);break;case"delete":by(r,k.original,k.type);break}for(let k of S)switch(k.type){case"insert":case"update":{let C={versionKey:X2(),data:k.modified};i.set(k.key,C);break}case"delete":{i.delete(k.key);break}}s(i),o.confirmOperationsSync(S)}}}}}function V8(e,t,n){try{let r=t.getItem(e);if(!r)return new Map;let i=n.parse(r),o=new Map;if(typeof i=="object"&&i!==null&&!Array.isArray(i))Object.entries(i).forEach(([s,a])=>{if(a&&typeof a=="object"&&"versionKey"in a&&"data"in a){let l=a,u=uPe(s);o.set(u,l)}else throw new x2e(e,s)});else throw new S2e(e);return o}catch(r){return console.warn(`[LocalStorageCollection] Error loading data from storage key "${e}":`,r),new Map}}function hPe(e,t,n,r,i,o){let s=null,a=null,l=(c,d)=>{let h=[];return c.forEach((f,p)=>{let m=d.get(p);m?f.versionKey!==m.versionKey&&h.push({type:"update",key:p,value:m.data}):h.push({type:"delete",key:p,value:f.data})}),d.forEach((f,p)=>{c.has(p)||h.push({type:"insert",key:p,value:f.data})}),h},u=()=>{if(!s)return;let{begin:c,write:d,commit:h}=s,f=V8(e,t,r),p=l(o,f);p.length>0&&(c(),p.forEach(({type:m,value:g})=>{g&&(by(r,g,m),d({type:m,value:g}))}),h(),o.clear(),f.forEach((m,g)=>{o.set(g,m)}))};return{sync:c=>{let{begin:d,write:h,commit:f,markReady:p}=c;s=c,a=c.collection;let m=V8(e,t,r);m.size>0&&(d(),m.forEach(y=>{by(r,y.data,"load"),h({type:"insert",value:y.data})}),f()),o.clear(),m.forEach((y,v)=>{o.set(v,y)}),p();let g=y=>{y.key!==e||y.storageArea!==t||u()};n.addEventListener("storage",g)},getSyncMetadata:()=>({storageKey:e,storageType:t===(typeof window<"u"?window.localStorage:null)?"localStorage":"custom"}),manualTrigger:u,collection:a,confirmOperationsSync:c=>{if(!s)return;let{begin:d,write:h,commit:f}=s;d(),c.forEach(p=>{h({type:p.type,value:p.type==="delete"?p.original:p.modified})}),f()}}}var MP=class eo{constructor(t={}){this.query={},this.query={...t}}_createRefForSource(t,n){let r;try{r=Object.keys(t)}catch{let a=t===null?"null":"undefined";throw new wC(n,a)}if(Array.isArray(t))throw new wC(n,"array");if(r.length!==1)throw r.length===0?new wC(n,"empty object"):r.every(a=>!isNaN(Number(a)))?new wC(n,"string"):new QDe(n);let i=r[0],o=t[i],s;if(o instanceof yz)s=new Ky(o,i);else if(o instanceof eo){let a=o._getQuery();if(!a.from)throw new GDe(n);s=new fa(a,i)}else throw new XDe(i);return[i,s]}from(t){let[,n]=this._createRefForSource(t,"from clause");return new eo({...this.query,from:n})}join(t,n,r="left"){let[i,o]=this._createRefForSource(t,"join clause"),s=[...this._getCurrentAliases(),i],a=fp(s),l=n(a),u,c;if(l.type==="func"&&l.name==="eq"&&l.args.length===2)u=l.args[0],c=l.args[1];else throw new JDe;let d={from:o,type:r,left:u,right:c},h=this.query.join||[];return new eo({...this.query,join:[...h,d]})}leftJoin(t,n){return this.join(t,n,"left")}rightJoin(t,n){return this.join(t,n,"right")}innerJoin(t,n){return this.join(t,n,"inner")}fullJoin(t,n){return this.join(t,n,"full")}where(t){let n=this._getCurrentAliases(),r=fp(n),i=t(r),o=wP(i)?Ir(i):i;if(!Yy(o))throw new g8(W8(o));let s=this.query.where||[];return new eo({...this.query,where:[...s,o]})}having(t){let n=this._getCurrentAliases(),r=this.query.select||this.query.fnSelect?R8(n):fp(n),i=t(r),o=wP(i)?Ir(i):i;if(!Yy(o))throw new g8(W8(o));let s=this.query.having||[];return new eo({...this.query,having:[...s,o]})}select(t){let n=this._getCurrentAliases(),r=fp(n),i=t(r),o=jJ(i);return new eo({...this.query,select:o,fnSelect:void 0})}orderBy(t,n="asc"){let r=this._getCurrentAliases(),i=this.query.select||this.query.fnSelect?R8(r):fp(r),o=t(i),s=typeof n=="string"?{direction:n,nulls:"first"}:{direction:n.direction??"asc",nulls:n.nulls??"first",stringSort:n.stringSort,locale:n.stringSort==="locale"?n.locale:void 0,localeOptions:n.stringSort==="locale"?n.localeOptions:void 0},a=c=>({expression:Ir(c),compareOptions:s}),l=Array.isArray(o)?o.map(c=>a(c)):[a(o)],u=this.query.orderBy||[];return new eo({...this.query,orderBy:[...u,...l]})}groupBy(t){let n=this._getCurrentAliases(),r=fp(n),i=t(r),o=Array.isArray(i)?i.map(a=>Ir(a)):[Ir(i)],s=this.query.groupBy||[];return new eo({...this.query,groupBy:[...s,...o]})}limit(t){return new eo({...this.query,limit:t})}offset(t){return new eo({...this.query,offset:t})}distinct(){return new eo({...this.query,distinct:!0})}findOne(){return new eo({...this.query,singleResult:!0})}_getCurrentAliases(){let t=[];if(this.query.from&&t.push(this.query.from.alias),this.query.join)for(let n of this.query.join)t.push(n.from.alias);return t}get fn(){let t=this;return{select(n){return new eo({...t.query,select:void 0,fnSelect:n})},where(n){return new eo({...t.query,fnWhere:[...t.query.fnWhere||[],n]})},having(n){return new eo({...t.query,fnHaving:[...t.query.fnHaving||[],n]})}}}_getQuery(){if(!this.query.from)throw new ZDe;return this.query}};function W8(e){return e===null?"null":e===void 0?"undefined":typeof e=="object"?"object":typeof e}function fPe(e){return e===void 0?Ir(null):e instanceof CJ||e instanceof Fs||e instanceof oo||e instanceof Go?e:Ir(e)}function pPe(e){return e!==null&&typeof e=="object"&&!Yy(e)&&!e.__refProxy}function jJ(e){if(!pPe(e))return fPe(e);let t={};for(let[n,r]of Object.entries(e)){if(typeof n=="string"&&n.startsWith("__SPREAD_SENTINEL__")){t[n]=r;continue}t[n]=jJ(r)}return t}function mPe(e){let t=e(new MP);return VJ(t)}function VJ(e){return e._getQuery()}function gPe(e){let t=yPe(e),n=e,r,i=0,o=10;for(;i<o&&!ol(n,r);)r=n,n=_P(n),i++;return{optimizedQuery:UJ(n),sourceWhereClauses:t}}function yPe(e){let t=new Map;if(!e.where||e.where.length===0)return t;let n=OP(e.where).map(o=>HJ(o)),r=$J(n),i=WJ(e);for(let[o,s]of r.singleSource)vPe(e,o)&&!i.has(o)&&t.set(o,s);return t}function vPe(e,t){if(e.from.alias===t)return e.from.type==="collectionRef";if(e.join){for(let n of e.join)if(n.from.alias===t)return n.from.type==="collectionRef"}return!1}function WJ(e){let t=new Set;if(e.join){let n=e.from.alias;for(let r of e.join){let i=r.from.alias;(r.type==="left"||r.type==="full")&&t.add(i),(r.type==="right"||r.type==="full")&&t.add(n)}}return t}function _P(e){let t={...e,from:e.from.type==="queryRef"?new fa(_P(e.from.query),e.from.alias):e.from,join:e.join?.map(n=>({...n,from:n.from.type==="queryRef"?new fa(_P(n.from.query),n.from.alias):n.from}))};return bPe(t)}function bPe(e){if(!e.where||e.where.length===0)return e;if(!e.join||e.join.length===0){if(e.where.length>1){let s=OP(e.where),a=RM(s);return{...e,where:[a]}}return e}let t=e.where.filter(s=>!d8(s)),n=OP(t).map(s=>HJ(s)),r=$J(n),i=xPe(e,r),o=e.where.filter(s=>d8(s));return o.length>0&&(i.where=[...i.where||[],...o]),i}function UJ(e){return{...e,from:EP(e.from),join:e.join?.map(t=>({...t,from:EP(t.from)}))}}function EP(e){if(e.type==="collectionRef")return e;let t=UJ(e.query);if(wPe(t)){let n=EP(t.from);return n.type==="collectionRef"?new Ky(n.collection,e.alias):new fa(n.query,e.alias)}return new fa(t,e.alias)}function wPe(e){return(!e.where||e.where.length===0)&&!e.select&&(!e.groupBy||e.groupBy.length===0)&&(!e.having||e.having.length===0)&&(!e.orderBy||e.orderBy.length===0)&&(!e.join||e.join.length===0)&&e.limit===void 0&&e.offset===void 0&&!e.fnSelect&&(!e.fnWhere||e.fnWhere.length===0)&&(!e.fnHaving||e.fnHaving.length===0)}function OP(e){let t=[];for(let n of e){let r=iz(n);t.push(...vz(r))}return t}function vz(e){if(e.type==="func"&&e.name==="and"){let t=[];for(let n of e.args)t.push(...vz(n));return t}else return[e]}function HJ(e){let t=new Set,n=!1;function r(i){switch(i.type){case"ref":if(i.path&&i.path.length>0){let o=i.path[0];o&&(t.add(o),i.path.length===1&&(n=!0))}break;case"func":i.args&&i.args.forEach(r);break;case"val":break;case"agg":i.args&&i.args.forEach(r);break}}return r(e),{expression:e,touchedSources:t,hasNamespaceOnlyRef:n}}function $J(e){let t=new Map,n=[];for(let o of e)if(o.touchedSources.size===1&&!o.hasNamespaceOnlyRef){let s=Array.from(o.touchedSources)[0];t.has(s)||t.set(s,[]),t.get(s).push(o.expression)}else(o.touchedSources.size>1||o.hasNamespaceOnlyRef)&&n.push(o.expression);let r=new Map;for(let[o,s]of t)r.set(o,RM(s));let i=n.length>0?RM(n):void 0;return{singleSource:r,multiSource:i}}function xPe(e,t){let n=new Set,r=WJ(e),i=new Map;for(let[c,d]of t.singleSource)r.has(c)||i.set(c,d);let o=U8(e.from,i,n),s=e.join?e.join.map(c=>({...c,from:U8(c.from,i,n)})):void 0,a=[];t.multiSource&&a.push(t.multiSource);let l=r.size>0;for(let[c,d]of t.singleSource)n.has(c)?l&&a.push(xDe(d)):a.push(d);let u=a.length>1?[RM(a.flatMap(c=>vz(iz(c))))]:a;return{select:e.select,groupBy:e.groupBy?[...e.groupBy]:void 0,having:e.having?[...e.having]:void 0,orderBy:e.orderBy?[...e.orderBy]:void 0,limit:e.limit,offset:e.offset,distinct:e.distinct,fnSelect:e.fnSelect,fnWhere:e.fnWhere?[...e.fnWhere]:void 0,fnHaving:e.fnHaving?[...e.fnHaving]:void 0,from:o,join:s,where:u.length>0?u:[]}}function wy(e){return{from:e.from.type==="collectionRef"?new Ky(e.from.collection,e.from.alias):new fa(wy(e.from.query),e.from.alias),select:e.select,join:e.join?e.join.map(t=>({type:t.type,left:t.left,right:t.right,from:t.from.type==="collectionRef"?new Ky(t.from.collection,t.from.alias):new fa(wy(t.from.query),t.from.alias)})):void 0,where:e.where?[...e.where]:void 0,groupBy:e.groupBy?[...e.groupBy]:void 0,having:e.having?[...e.having]:void 0,orderBy:e.orderBy?[...e.orderBy]:void 0,limit:e.limit,offset:e.offset,fnSelect:e.fnSelect,fnWhere:e.fnWhere?[...e.fnWhere]:void 0,fnHaving:e.fnHaving?[...e.fnHaving]:void 0}}function U8(e,t,n){let r=t.get(e.alias);if(!r)return e.type==="collectionRef"?new Ky(e.collection,e.alias):new fa(wy(e.query),e.alias);if(e.type==="collectionRef"){let s={from:new Ky(e.collection,e.alias),where:[r]};return n.add(e.alias),new fa(s,e.alias)}if(!_Pe(e.query,r,e.alias))return new fa(wy(e.query),e.alias);if(OPe(e.query,r,e.alias))return new fa(wy(e.query),e.alias);let i=e.query.where||[],o={...wy(e.query),where:[...i,r]};return n.add(e.alias),new fa(o,e.alias)}function SPe(e,t,n){return e.select?KJ(e.select)||EPe(e.select,t,n):!1}function kPe(e){return e.groupBy&&e.groupBy.length>0}function CPe(e){return e.having&&e.having.length>0}function NPe(e){return e.orderBy&&e.orderBy.length>0&&(e.limit!==void 0||e.offset!==void 0)}function MPe(e){return e.fnSelect||e.fnWhere&&e.fnWhere.length>0||e.fnHaving&&e.fnHaving.length>0}function _Pe(e,t,n){return!(SPe(e,t,n)||kPe(e)||CPe(e)||NPe(e)||MPe(e))}function KJ(e){for(let t of Object.values(e))if(typeof t=="object"){let n=t;if(n.type==="agg"||!("type"in n)&&KJ(n))return!0}return!1}function bz(e){let t=[];if(e==null||typeof e!="object")return t;switch(e.type){case"ref":t.push(e);break;case"func":case"agg":for(let n of e.args??[])t.push(...bz(n));break}return t}function EPe(e,t,n){let r=new Set;for(let[o,s]of Object.entries(e))o.startsWith("__SPREAD_SENTINEL__")||s instanceof oo||r.add(o);let i=bz(t);for(let o of i){let s=o.path;if(!Array.isArray(s)||s.length<2)continue;let a=s[0],l=s[1];if(a===n&&r.has(l))return!0}return!1}function OPe(e,t,n){let r=bz(t);if(r.every(o=>o.path[0]!==n))return!1;if(e.fnSelect)return!0;let i=e.select;if(!i)return!1;for(let o of r){let s=o.path;if(s.length<2||s[0]!==n)continue;let a=i[s[1]];if(!a)continue;if(!(a instanceof oo)||a.path.length<2)return!0;let[l,u]=a.path;if(l!==n&&l!==e.from.alias||u!==s[1])return!0}return!1}function RM(e){if(e.length===0)throw new C2e;return e.length===1?e[0]:new Fs("and",e)}function TPe(e,t,n,r,i,o,s,a,l,u,c,d,h,f,p,m,g,y,v){let b=e;for(let w of t)b=APe(b,w,n,r,i,o,s,a,l,u,c,d,h,f,p,m,g,y,v);return b}function APe(e,t,n,r,i,o,s,a,l,u,c,d,h,f,p,m,g,y,v){let b=t.from.type==="collectionRef",{alias:w,input:x,collectionId:S}=RPe(t.from,o,l,u,c,d,h,f,s,a,m,g,y,v);n[w]=x,b&&(g[w]=S);let k=l[r],C=l[S];if(!k)throw new y8(r);if(!C)throw new y8(S);let{activeSource:N,lazySource:E}=PPe(t.type,k,C),D=Object.keys(n),{mainExpr:q,joinedExpr:z}=DPe(t.left,t.right,D,w),_=ro(q),R=ro(z),T=e.pipe(No(([A,M])=>[kp(_(M)),[A,M]])),B=x.pipe(No(([A,M])=>{let P={[w]:M};return[kp(R(P)),[A,P]]}));if(!["inner","left","right","full"].includes(t.type))throw new l2e(t.type);if(N){let A=N==="main"?t.from:p.from,M=A.type==="queryRef"&&(A.query.limit||A.query.offset),P=q.type==="func"||z.type==="func";if(!M&&!P){let F=N==="main"?w:i;d.add(F);let I=N==="main"?T:B,V=dx(p,N==="main"?z:q,E),W=V.collection,j=V.path[0];j&&$_(j,V.path,W);let X=I.pipe(BRe($=>{let K=y[F]||F,Q=u[K];if(!Q)throw new N2e(K,F,E.id,Object.keys(u));if(Q.hasLoadedInitialState())return;let J=$.getInner().map(([[be]])=>be),oe=new oo(V.path);Q.requestSnapshot({where:uIe(oe,J),optimizedOnly:!0})||Q.requestSnapshot()}));N==="main"?T=X:B=X}}return T.pipe(URe(B,t.type),IPe(t.type))}function DPe(e,t,n,r){let i=n.filter(a=>a!==r),o=TP(e),s=TP(t);if(o&&i.includes(o)&&s===r)return{mainExpr:e,joinedExpr:t};if(o===r&&s&&i.includes(s))return{mainExpr:t,joinedExpr:e};throw!o||!s?new c2e:o===s?new u2e(o):i.includes(o)?s!==r?new h2e(r):new f2e:new d2e(o)}function TP(e){switch(e.type){case"ref":return e.path[0]||null;case"func":{let t=new Set;for(let n of e.args){let r=TP(n);r&&t.add(r)}return t.size===1?Array.from(t)[0]:null}default:return null}}function RPe(e,t,n,r,i,o,s,a,l,u,c,d,h,f){switch(e.type){case"collectionRef":{let p=t[e.alias];if(!p)throw new NJ(e.alias,e.collection.id,Object.keys(t));return d[e.alias]=e.collection.id,{alias:e.alias,input:p,collectionId:e.collection.id}}case"queryRef":{let p=u.get(e.query)||e.query,m=c(p,t,n,r,i,o,s,a,l,u);Object.assign(d,m.aliasToCollectionId),Object.assign(h,m.aliasRemapping);let g=u.has(e.query),y=e.query.from.alias;if(!(!g&&e.alias===y))for(let[w,x]of m.sourceWhereClauses)f.set(w,x);let v=Object.keys(m.aliasToCollectionId).find(w=>m.aliasToCollectionId[w]===m.collectionId);v&&v!==e.alias&&(h[e.alias]=v);let b=m.pipeline.pipe(No(w=>{let[x,[S,k]]=w;return[x,S]}));return{alias:e.alias,input:b,collectionId:m.collectionId}}default:throw new p2e(e.type)}}function IPe(e){return function(t){return t.pipe(ch(n=>{let[r,[i,o]]=n,s=i?.[1],a=o?.[1];return e==="inner"?!!(s&&a):e==="left"?!!s:e==="right"?!!a:!0}),No(n=>{let[r,[i,o]]=n,s=i?.[0],a=i?.[1],l=o?.[0],u=o?.[1],c={};return a&&Object.assign(c,a),u&&Object.assign(c,u),[`[${s},${l}]`,c]}))}}function PPe(e,t,n){switch(e){case"left":return{activeSource:"main",lazySource:n};case"right":return{activeSource:"joined",lazySource:t};case"inner":return t.size<n.size?{activeSource:"main",lazySource:n}:{activeSource:"joined",lazySource:t};default:return{activeSource:void 0,lazySource:void 0}}}function AP(e){return e instanceof Go?e.value:e}function LPe(e,t,n){let r=e.source(t);if(r&&typeof r=="object"){let i=n,o=e.targetPath;if(o.length===0)for(let[s,a]of Object.entries(r))n[s]=AP(a);else for(let s=0;s<o.length;s++){let a=o[s];if(s===o.length-1){let l=i[a]??={};if(typeof l=="object")for(let[u,c]of Object.entries(r))l[u]=AP(c)}else{let l=i[a];(l==null||typeof l!="object")&&(i[a]={}),i=i[a]}}}}function BPe(e,t,n){let r=e.alias.split(".");if(r.length===1)n[e.alias]=e.compiled(t);else{let i=n;for(let o=0;o<r.length-1;o++){let s=r[o],a=i[s];(a==null||typeof a!="object")&&(i[s]={}),i=i[s]}i[r[r.length-1]]=AP(e.compiled(t))}}function qPe([e,t],n){let r={};for(let i of n)i.kind==="merge"?LPe(i,t,r):BPe(i,t,r);return[e,{...t,$selected:r}]}function zPe(e,t,n){let r=[];return YJ([],t,r),e.pipe(No(i=>qPe(i,r)))}function FPe(e){return e.type==="agg"}function jPe(e){return e&&typeof e=="object"&&!Yy(e)}function YJ(e,t,n){for(let[r,i]of Object.entries(t)){if(r.startsWith("__SPREAD_SENTINEL__")){let s=r.slice(19),a=s.lastIndexOf("__"),l=a>=0?s.slice(0,a):s,u=i&&typeof i=="object"&&"type"in i&&i.type==="ref";if(l.includes(".")||u){let c=[...e],d=u?i:new oo(l.split(".")),h=ro(d);n.push({kind:"merge",targetPath:c,source:h})}else{let c=l,d=[...e];n.push({kind:"merge",targetPath:d,source:h=>h[c]})}continue}let o=i;if(jPe(o)){YJ([...e,r],o,n);continue}if(FPe(o)||Gy(o))n.push({kind:"field",alias:[...e,r].join("."),compiled:()=>null});else{if(o===void 0||!Yy(o)){n.push({kind:"field",alias:[...e,r].join("."),compiled:()=>o});continue}if(o instanceof Go){let s=o.value;n.push({kind:"field",alias:[...e,r].join("."),compiled:()=>s})}else n.push({kind:"field",alias:[...e,r].join("."),compiled:ro(o)})}}}function wz(e,t,n,r,i,o,s,a,l=new WeakMap,u=new WeakMap){let c=l.get(e);if(c)return c;DP(e);let{optimizedQuery:d,sourceWhereClauses:h}=gPe(e);u.set(d,e),IP(d,e,u);let f={...t},p={},m={},g={},{alias:y,input:v,collectionId:b}=WPe(d.from,f,n,r,i,o,s,a,l,u,p,m,h);g[y]=v;let w=v.pipe(No(([k,C])=>[k,{[y]:C}]));if(d.join&&d.join.length>0&&(w=TPe(w,d.join,g,b,y,f,l,u,n,r,i,o,s,a,e,wz,p,m,h)),d.where&&d.where.length>0)for(let k of d.where){let C=iz(k),N=ro(C);w=w.pipe(ch(([E,D])=>_y(N(D))))}if(d.fnWhere&&d.fnWhere.length>0)for(let k of d.fnWhere)w=w.pipe(ch(([C,N])=>_y(k(N))));if(d.distinct&&!d.fnSelect&&!d.select)throw new e2e;if(d.fnSelect?w=w.pipe(No(([k,C])=>{let N=d.fnSelect(C);return[k,{...C,$selected:N}]})):d.select?w=zPe(w,d.select):w=w.pipe(No(([k,C])=>{let N=!d.join&&!d.groupBy?C[y]:C;return[k,{...C,$selected:N}]})),d.groupBy&&d.groupBy.length>0?w=P8(w,d.groupBy,d.having,d.select,d.fnHaving):d.select&&Object.values(d.select).some(k=>k.type==="agg"||Gy(k))&&(w=P8(w,[],d.having,d.select,d.fnHaving)),d.having&&(!d.groupBy||d.groupBy.length===0)&&!(d.select&&Object.values(d.select).some(k=>k.type==="agg")))throw new t2e;if(d.fnHaving&&d.fnHaving.length>0&&(!d.groupBy||d.groupBy.length===0))for(let k of d.fnHaving)w=w.pipe(ch(([C,N])=>k(N)));if(d.distinct&&(w=w.pipe($Re(([k,C])=>C.$selected))),d.orderBy&&d.orderBy.length>0){let k=wIe(e,w,d.orderBy,d.select||{},n[b],s,a,d.limit,d.offset).pipe(No(([N,[E,D]])=>{let q=E.$selected,z=RP(q);return[N,[z,D]]})),C={collectionId:b,pipeline:k,sourceWhereClauses:h,aliasToCollectionId:p,aliasRemapping:m};return l.set(e,C),C}else if(d.limit!==void 0||d.offset!==void 0)throw new n2e;let x=w.pipe(No(([k,C])=>{let N=C.$selected,E=RP(N);return[k,[E,void 0]]})),S={collectionId:b,pipeline:x,sourceWhereClauses:h,aliasToCollectionId:p,aliasRemapping:m};return l.set(e,S),S}function VPe(e){let t=new Set;if(e.from.type==="collectionRef"&&t.add(e.from.alias),e.join)for(let n of e.join)n.from.type==="collectionRef"&&t.add(n.from.alias);return t}function DP(e,t=new Set){let n=VPe(e);for(let i of n)if(t.has(i))throw new r2e(i,Array.from(t));let r=new Set([...t,...n]);if(e.from.type==="queryRef"&&DP(e.from.query,r),e.join)for(let i of e.join)i.from.type==="queryRef"&&DP(i.from.query,r)}function WPe(e,t,n,r,i,o,s,a,l,u,c,d,h){switch(e.type){case"collectionRef":{let f=t[e.alias];if(!f)throw new NJ(e.alias,e.collection.id,Object.keys(t));return c[e.alias]=e.collection.id,{alias:e.alias,input:f,collectionId:e.collection.id}}case"queryRef":{let f=u.get(e.query)||e.query,p=wz(f,t,n,r,i,o,s,a,l,u);Object.assign(c,p.aliasToCollectionId),Object.assign(d,p.aliasRemapping);let m=u.has(e.query),g=e.query.from.alias;if(!(!m&&e.alias===g))for(let[b,w]of p.sourceWhereClauses)h.set(b,w);let y=Object.keys(p.aliasToCollectionId).find(b=>p.aliasToCollectionId[b]===p.collectionId);y&&y!==e.alias&&(d[e.alias]=y);let v=p.pipeline.pipe(No(b=>{let[w,[x,S]]=b,k=RP(x);return[w,k]}));return{alias:e.alias,input:v,collectionId:p.collectionId}}default:throw new i2e(e.type)}}function UPe(e){return e instanceof Go||e&&typeof e=="object"&&"type"in e&&e.type==="val"}function RP(e){return UPe(e)?e.value:e}function IP(e,t,n){if(e.from.type==="queryRef"&&t.from.type==="queryRef"&&(n.set(e.from.query,t.from.query),IP(e.from.query,t.from.query,n)),e.join&&t.join)for(let r=0;r<e.join.length&&r<t.join.length;r++){let i=e.join[r],o=t.join[r];i.from.type==="queryRef"&&o.from.type==="queryRef"&&(n.set(i.from.query,o.from.query),IP(i.from.query,o.from.query,n))}}function xz(e,t){let n=e.type;if(n==="val")return new Go(e.value);if(n==="ref"){let r=e.path;if(Array.isArray(r)){if(r[0]===t&&r.length>1)return new oo(r.slice(1));if(r.length===1&&r[0]!==void 0)return new oo([r[0]])}return new oo(Array.isArray(r)?r:[String(r)])}else{let r=[];for(let i of e.args){let o=xz(i,t);r.push(o)}return new Fs(e.name,r)}}function J2(e,t){return e.map(n=>{let r=xz(n.expression,t);return{...n,expression:r}})}var H8=Symbol.for("@tanstack/db.collection-config-builder"),HPe=class{constructor(e,t,n,r){this.alias=e,this.collectionId=t,this.collection=n,this.collectionConfigBuilder=r,this.biggest=void 0,this.subscriptionLoadingPromises=new Map,this.sentToD2Keys=new Set}subscribe(){let e=this.getWhereClauseForAlias();if(e){let t=xz(e,this.alias);return this.subscribeToChanges(t)}return this.subscribeToChanges()}subscribeToChanges(e){let t=this.getOrderByInfo(),n=s=>{s instanceof Promise&&this.collectionConfigBuilder.liveQueryCollection._sync.trackLoadPromise(s)},r=s=>{let a=s.subscription;if(s.status==="loadingSubset")this.ensureLoadingPromise(a);else{let l=this.subscriptionLoadingPromises.get(a);l&&(this.subscriptionLoadingPromises.delete(a),l.resolve())}},i;if(t)i=this.subscribeToOrderedChanges(e,t,r,n);else{let s=!this.collectionConfigBuilder.isLazyAlias(this.alias);i=this.subscribeToMatchingChanges(e,s,r)}i.status==="loadingSubset"&&this.ensureLoadingPromise(i);let o=()=>{let s=this.subscriptionLoadingPromises.get(i);s&&(this.subscriptionLoadingPromises.delete(i),s.resolve()),i.unsubscribe()};return this.collectionConfigBuilder.currentSyncState.unsubscribeCallbacks.add(o),i}sendChangesToPipeline(e,t){let n=Array.isArray(e)?e:[...e],r=[];for(let s of n){if(s.type==="insert"){if(this.sentToD2Keys.has(s.key))continue;this.sentToD2Keys.add(s.key)}else s.type==="delete"&&this.sentToD2Keys.delete(s.key);r.push(s)}let i=this.collectionConfigBuilder.currentSyncState.inputs[this.alias],o=$Pe(i,r,this.collection.config.getKey)>0?t:void 0;this.collectionConfigBuilder.scheduleGraphRun(o,{alias:this.alias})}subscribeToMatchingChanges(e,t,n){let r=f=>{this.sendChangesToPipeline(f)},{orderBy:i,limit:o,offset:s}=this.collectionConfigBuilder.query,a=o!==void 0&&s!==void 0?o+s:o,l=i?J2(i,this.alias):void 0,u=l?.every(f=>{let p=f.expression;if(p.type!=="ref")return!1;let m=p.path;return Array.isArray(m)&&m.length===1})??!1,c=u?l:void 0,d=u?a:void 0,h=t?f=>{f instanceof Promise&&this.collectionConfigBuilder.liveQueryCollection._sync.trackLoadPromise(f)}:void 0;return this.collection.subscribeChanges(r,{...t&&{includeInitialState:t},whereExpression:e,onStatusChange:n,orderBy:c,limit:d,onLoadSubsetResult:h})}subscribeToOrderedChanges(e,t,n,r){let{orderBy:i,offset:o,limit:s,index:a}=t,l=p=>{p instanceof Promise&&(this.pendingOrderedLoadPromise=p,p.finally(()=>{this.pendingOrderedLoadPromise===p&&(this.pendingOrderedLoadPromise=void 0)})),r(p)};this.orderedLoadSubsetResult=l;let u={},c=p=>{let m=Array.isArray(p)?p:[...p];this.trackSentValues(m,t.comparator);let g=KPe(m);this.sendChangesToPipelineWithTracking(g,u.current)},d=this.collection.subscribeChanges(c,{whereExpression:e,onStatusChange:n});u.current=d;let h=this.collection.on("truncate",()=>{this.biggest=void 0,this.lastLoadRequestKey=void 0,this.pendingOrderedLoadPromise=void 0,this.sentToD2Keys.clear()});d.on("unsubscribed",()=>{h()});let f=J2(i,this.alias);return a?(d.setOrderByIndex(a),d.requestLimitedSnapshot({limit:o+s,orderBy:f,trackLoadSubsetPromise:!1,onLoadSubsetResult:l})):d.requestSnapshot({orderBy:f,limit:o+s,trackLoadSubsetPromise:!1,onLoadSubsetResult:l}),d}loadMoreIfNeeded(e){let t=this.getOrderByInfo();if(!t)return!0;let{dataNeeded:n}=t;if(!n||this.pendingOrderedLoadPromise)return!0;let r=n();return r>0&&this.loadNextItems(r,e),!0}sendChangesToPipelineWithTracking(e,t){if(!this.getOrderByInfo()){this.sendChangesToPipeline(e);return}let n=t;n[H8]??=this.loadMoreIfNeeded.bind(this,t),this.sendChangesToPipeline(e,n[H8])}loadNextItems(e,t){let n=this.getOrderByInfo();if(!n)return;let{orderBy:r,valueExtractorForRawRow:i,offset:o}=n,s=this.biggest,a=s?i(s):void 0,l;a!==void 0&&(l=Array.isArray(a)?a:[a]);let u=this.getLoadRequestKey({minValues:l,offset:o,limit:e});if(this.lastLoadRequestKey===u)return;let c=J2(r,this.alias);t.requestLimitedSnapshot({orderBy:c,limit:e,minValues:l,trackLoadSubsetPromise:!1,onLoadSubsetResult:this.orderedLoadSubsetResult}),this.lastLoadRequestKey=u}getWhereClauseForAlias(){let e=this.collectionConfigBuilder.sourceWhereClausesCache;if(e)return e.get(this.alias)}getOrderByInfo(){let e=this.collectionConfigBuilder.optimizableOrderByCollections[this.collectionId];if(e&&e.alias===this.alias)return e}trackSentValues(e,t){for(let n of e){if(n.type==="delete")continue;let r=!this.sentToD2Keys.has(n.key);this.biggest?t(this.biggest,n.value)<0?(this.biggest=n.value,this.lastLoadRequestKey=void 0):r&&(this.lastLoadRequestKey=void 0):(this.biggest=n.value,this.lastLoadRequestKey=void 0)}}ensureLoadingPromise(e){if(this.subscriptionLoadingPromises.has(e))return;let t,n=new Promise(r=>{t=r});this.subscriptionLoadingPromises.set(e,{resolve:t}),this.collectionConfigBuilder.liveQueryCollection._sync.trackLoadPromise(n)}getLoadRequestKey(e){return hz({minValues:e.minValues??null,offset:e.offset,limit:e.limit})}};function $Pe(e,t,n){let r=[];for(let i of t){let o=n(i.value);i.type==="insert"?r.push([[o,i.value],1]):i.type==="update"?(r.push([[o,i.previousValue],-1]),r.push([[o,i.value],1])):r.push([[o,i.value],-1])}return r.length!==0&&e.sendData(new vu(r)),r.length}function*KPe(e){for(let t of e)t.type==="update"?(yield{type:"delete",key:t.key,value:t.previousValue},yield{type:"insert",key:t.key,value:t.value}):yield t}var QJ=new WeakMap;function YPe(e){return e.utils?.[pz]?.getBuilder?.()}function QPe(e,t){QJ.set(e,t)}function GPe(e){return QJ.get(e)}var XPe=0,JPe=class{constructor(e){this.config=e,this.compiledAliasToCollectionId={},this.resultKeys=new WeakMap,this.orderByIndices=new WeakMap,this.isGraphRunning=!1,this.runCount=0,this.isInErrorState=!1,this.aliasDependencies={},this.builderDependencies=new Set,this.pendingGraphRuns=new Map,this.subscriptions={},this.lazySourcesCallbacks={},this.lazySources=new Set,this.optimizableOrderByCollections={},this.id=e.id||`live-query-${++XPe}`,this.query=ZPe(e),this.collections=tLe(this.query);let t=nLe(this.query);this.collectionByAlias={};for(let[n,r]of t.entries()){let i=this.collections[n];if(i)for(let o of r)this.collectionByAlias[o]=i}this.query.orderBy&&this.query.orderBy.length>0&&(this.compare=eLe(this.orderByIndices)),this.compareOptions=this.config.defaultStringCollation??GJ(this.query).compareOptions,this.compileBasePipeline()}hasJoins(e){return!!(e.join&&e.join.length>0||e.from.type==="queryRef"&&this.hasJoins(e.from.query))}getConfig(){return{id:this.id,getKey:this.config.getKey||(e=>this.resultKeys.get(e)),sync:this.getSyncConfig(),compare:this.compare,defaultStringCollation:this.compareOptions,gcTime:this.config.gcTime||5e3,schema:this.config.schema,onInsert:this.config.onInsert,onUpdate:this.config.onUpdate,onDelete:this.config.onDelete,startSync:this.config.startSync,singleResult:this.query.singleResult,utils:{getRunCount:this.getRunCount.bind(this),setWindow:this.setWindow.bind(this),getWindow:this.getWindow.bind(this),[pz]:{getBuilder:()=>this,hasCustomGetKey:!!this.config.getKey,hasJoins:this.hasJoins(this.query),hasDistinct:!!this.query.distinct}}}}setWindow(e){if(!this.windowFn)throw new _2e;return this.currentWindow=e,this.windowFn(e),this.maybeRunGraphFn?.(),this.liveQueryCollection?.isLoadingSubset?new Promise(t=>{let n=this.liveQueryCollection.on("loadingSubset:change",r=>{r.isLoadingSubset||(n(),t())})}):!0}getWindow(){if(!(!this.windowFn||!this.currentWindow))return{offset:this.currentWindow.offset??0,limit:this.currentWindow.limit??0}}getCollectionIdForAlias(e){let t=this.compiledAliasToCollectionId[e];if(t)return t;let n=this.collectionByAlias[e];if(n)return n.id;throw new Error(`Unknown source alias "${e}"`)}isLazyAlias(e){return this.lazySources.has(e)}maybeRunGraph(e){if(!this.isGraphRunning){if(!this.currentSyncConfig||!this.currentSyncState)throw new Error("maybeRunGraph called without active sync session. This should not happen.");this.isGraphRunning=!0;try{let{begin:t,commit:n}=this.currentSyncConfig,r=this.currentSyncState;if(this.isInErrorState)return;if(r.subscribedToAllCollections){let i=!1;for(;r.graph.pendingWork();)r.graph.run(),r.flushPendingChanges?.(),e?.(),i=!0;i||e?.(),r.messagesCount===0&&(t(),n()),this.updateLiveQueryStatus(this.currentSyncConfig)}}finally{this.isGraphRunning=!1}}}scheduleGraphRun(e,t){let n=t?.contextId??RN()?.id,r=t?.jobId??this,i=(()=>{if(t?.dependencies)return t.dependencies;let a=new Set(this.builderDependencies);if(t?.alias){let l=this.aliasDependencies[t.alias];if(l)for(let u of l)a.add(u)}return a.delete(this),Array.from(a)})();if(n)for(let a of i)typeof a.scheduleGraphRun=="function"&&a.scheduleGraphRun(void 0,{contextId:n});if(!this.currentSyncConfig||!this.currentSyncState)throw new Error("scheduleGraphRun called without active sync session. This should not happen.");let o=n?this.pendingGraphRuns.get(n):void 0;o||(o={loadCallbacks:new Set},n&&this.pendingGraphRuns.set(n,o)),e&&o.loadCallbacks.add(e);let s=n?void 0:o;AM.schedule({contextId:n,jobId:r,dependencies:i,run:()=>this.executeGraphRun(n,s)})}clearPendingGraphRun(e){this.pendingGraphRuns.delete(e)}hasPendingGraphRun(e){return this.pendingGraphRuns.has(e)}executeGraphRun(e,t){let n=t??(e?this.pendingGraphRuns.get(e):void 0);if(e&&this.pendingGraphRuns.delete(e),!n||!this.currentSyncConfig||!this.currentSyncState)return;this.incrementRunCount();let r=()=>{let i=!0,o;if(n.loadCallbacks.forEach(s=>{try{i=s()&&i}catch(a){i=!1,o??=a}}),o)throw o;return i};this.maybeRunGraph(r)}getSyncConfig(){return{rowUpdateMode:"full",sync:this.syncFn.bind(this)}}incrementRunCount(){this.runCount++}getRunCount(){return this.runCount}syncFn(e){this.liveQueryCollection=e.collection,this.currentSyncConfig=e;let t={messagesCount:0,subscribedToAllCollections:!1,unsubscribeCallbacks:new Set},n=this.extendPipelineWithChangeProcessing(e,t);this.currentSyncState=n,this.unsubscribeFromSchedulerClears=AM.onClear(o=>{this.clearPendingGraphRun(o)});let r=e.collection.on("loadingSubset:change",o=>{o.isLoadingSubset||this.updateLiveQueryStatus(e)});t.unsubscribeCallbacks.add(r);let i=this.subscribeToAllCollections(e,n);return this.maybeRunGraphFn=()=>this.scheduleGraphRun(i),this.scheduleGraphRun(i),()=>{t.unsubscribeCallbacks.forEach(o=>o()),this.currentSyncConfig=void 0,this.currentSyncState=void 0,this.pendingGraphRuns.clear(),this.graphCache=void 0,this.inputsCache=void 0,this.pipelineCache=void 0,this.sourceWhereClausesCache=void 0,this.lazySources.clear(),this.optimizableOrderByCollections={},this.lazySourcesCallbacks={},Object.keys(this.subscriptions).forEach(o=>delete this.subscriptions[o]),this.compiledAliasToCollectionId={},this.unsubscribeFromSchedulerClears?.(),this.unsubscribeFromSchedulerClears=void 0}}compileBasePipeline(){this.graphCache=new kRe,this.inputsCache=Object.fromEntries(Object.keys(this.collectionByAlias).map(n=>[n,this.graphCache.newInput()]));let e=wz(this.query,this.inputsCache,this.collections,this.subscriptions,this.lazySourcesCallbacks,this.lazySources,this.optimizableOrderByCollections,n=>{this.windowFn=n});this.pipelineCache=e.pipeline,this.sourceWhereClausesCache=e.sourceWhereClauses,this.compiledAliasToCollectionId=e.aliasToCollectionId;let t=Object.keys(this.compiledAliasToCollectionId).filter(n=>!Object.hasOwn(this.inputsCache,n));if(t.length>0)throw new M2e(t)}maybeCompileBasePipeline(){return(!this.graphCache||!this.inputsCache||!this.pipelineCache)&&this.compileBasePipeline(),{graph:this.graphCache,inputs:this.inputsCache,pipeline:this.pipelineCache}}extendPipelineWithChangeProcessing(e,t){let{begin:n,commit:r}=e,{graph:i,inputs:o,pipeline:s}=this.maybeCompileBasePipeline(),a=new Map;return s.pipe(FRe(l=>{let u=l.getInner();t.messagesCount+=u.length,u.reduce(rLe,a)})),t.flushPendingChanges=()=>{if(a.size===0)return;let l=a;if(this.config.getKey){let u=new Map;for(let[,c]of a){let d=this.config.getKey(c.value),h=u.get(d);h?(h.inserts+=c.inserts,h.deletes+=c.deletes,c.inserts>0&&(h.value=c.value,c.orderByIndex!==void 0&&(h.orderByIndex=c.orderByIndex))):u.set(d,{...c})}l=u}n(),l.forEach(this.applyChanges.bind(this,e)),r(),a=new Map},i.finalize(),t.graph=i,t.inputs=o,t.pipeline=s,t}applyChanges(e,t,n){let{write:r,collection:i}=e,{deletes:o,inserts:s,value:a,orderByIndex:l}=t;if(this.resultKeys.set(a,n),l!==void 0&&this.orderByIndices.set(a,l),s&&o===0)r({value:a,type:"insert"});else if(s>o||s===o&&i.has(i.getKeyFromItem(a)))r({value:a,type:"update"});else if(o>0)r({value:a,type:"delete"});else throw new Error(`Could not apply changes: ${JSON.stringify(t)}. This should never happen.`)}handleSourceStatusChange(e,t,n){let{status:r}=n;if(r==="error"){this.transitionToError(`Source collection '${t}' entered error state`);return}if(r==="cleaned-up"){this.transitionToError(`Source collection '${t}' was manually cleaned up while live query '${this.id}' depends on it. Live queries prevent automatic GC, so this was likely a manual cleanup() call.`);return}this.updateLiveQueryStatus(e)}updateLiveQueryStatus(e){let{markReady:t}=e;if(this.isInErrorState)return;let n=this.currentSyncState?.subscribedToAllCollections,r=this.allCollectionsReady(),i=this.liveQueryCollection?.isLoadingSubset;n&&r&&!i&&t()}transitionToError(e){this.isInErrorState=!0,console.error(`[Live Query Error] ${e}`),this.liveQueryCollection?._lifecycle.setStatus("error")}allCollectionsReady(){return Object.values(this.collections).every(e=>e.isReady())}subscribeToAllCollections(e,t){let n=Object.entries(this.compiledAliasToCollectionId);if(n.length===0)throw new Error(`Compiler returned no alias metadata for query '${this.id}'. This should not happen; please report.`);let r=n.map(([o,s])=>{let a=this.collectionByAlias[o]??this.collections[s],l=GPe(a);l&&l!==this?(this.aliasDependencies[o]=[l],this.builderDependencies.add(l)):this.aliasDependencies[o]=[];let u=new HPe(o,s,a,this),c=a.on("status:change",h=>{this.handleSourceStatusChange(e,s,h)});t.unsubscribeCallbacks.add(c);let d=u.subscribe();return this.subscriptions[o]=d,u.loadMoreIfNeeded.bind(u,d)}),i=()=>(r.map(o=>o()),!0);return t.subscribedToAllCollections=!0,i}};function ZPe(e){return typeof e.query=="function"?mPe(e.query):VJ(e.query)}function eLe(e){return(t,n)=>{let r=e.get(t),i=e.get(n);return r&&i?r<i?-1:r>i?1:0:0}}function tLe(e){let t={};function n(i){i.type==="collectionRef"?t[i.collection.id]=i.collection:i.type==="queryRef"&&r(i.query)}function r(i){if(i.from&&n(i.from),i.join&&Array.isArray(i.join))for(let o of i.join)o.from&&n(o.from)}return r(e),t}function GJ(e){let t=e.from;if(t.type==="collectionRef")return t.collection;if(t.type==="queryRef")return GJ(t.query);throw new Error(`Failed to extract collection. Invalid FROM clause: ${JSON.stringify(e)}`)}function nLe(e){let t=new Map;function n(i){if(i)if(i.type==="collectionRef"){let{id:o}=i.collection,s=t.get(o);s?s.add(i.alias):t.set(o,new Set([i.alias]))}else i.type==="queryRef"&&r(i.query)}function r(i){if(i&&(n(i.from),i.join))for(let o of i.join)n(o.from)}return r(e),t}function rLe(e,[[t,n],r]){let[i,o]=n,s=e.get(t)||{deletes:0,inserts:0,value:i,orderByIndex:o};return r<0?s.deletes+=Math.abs(r):r>0&&(s.inserts+=r,s.value=i,o!==void 0&&(s.orderByIndex=o)),e.set(t,s),e}function $8(e){return new JPe(e).getConfig()}function Z2(e){if(typeof e=="function"){let t=$8({query:e});return K8(t)}else{let t=e,n=$8(t);return t.utils&&(n.utils={...n.utils,...t.utils}),K8(n)}}function K8(e){let t=tu(e),n=YPe(e);return n&&QPe(t,n),t}var eR=1;function Xy(e,t=[]){let n=e&&typeof e=="object"&&typeof e.subscribeChanges=="function"&&typeof e.startSyncImmediate=="function"&&typeof e.id=="string",r=(0,aa.useRef)(null),i=(0,aa.useRef)(null),o=(0,aa.useRef)(null),s=(0,aa.useRef)(0),a=(0,aa.useRef)(null),l=!r.current||n&&o.current!==e||!n&&(i.current===null||i.current.length!==t.length||i.current.some((p,m)=>p!==t[m]));if(l)if(n)e.config?.syncMode==="on-demand"&&console.warn(`[useLiveQuery] Warning: Passing a collection with syncMode "on-demand" directly to useLiveQuery will not load any data. In on-demand mode, data is only loaded when queries with predicates request it.
Instead, use a query builder function:
const { data } = useLiveQuery((q) => q.from({ c: myCollection }).select(({ c }) => c))
Or switch to syncMode "eager" if you want all data to sync automatically.`),e.startSyncImmediate(),r.current=e,o.current=e;else if(typeof e=="function"){let p=new MP,m=e(p);if(m==null)r.current=null;else if(m instanceof yz)m.startSyncImmediate(),r.current=m;else if(m instanceof MP)r.current=Z2({query:e,startSync:!0,gcTime:eR});else if(m&&typeof m=="object")r.current=Z2({startSync:!0,gcTime:eR,...m});else throw new Error(`useLiveQuery callback must return a QueryBuilder, LiveQueryCollectionConfig, Collection, undefined, or null. Got: ${typeof m}`);i.current=[...t]}else r.current=Z2({startSync:!0,gcTime:eR,...e}),i.current=[...t];l&&(s.current=0,a.current=null);let u=(0,aa.useRef)(null);(!u.current||l)&&(u.current=p=>{if(!r.current)return()=>{};let m=r.current.subscribeChanges(()=>{s.current+=1,p()});return r.current.status==="ready"&&(s.current+=1,p()),()=>{m.unsubscribe()}});let c=(0,aa.useRef)(null);(!c.current||l)&&(c.current=()=>{let p=s.current,m=r.current;return(!a.current||a.current.version!==p||a.current.collection!==m)&&(a.current={collection:m,version:p}),a.current});let d=(0,aa.useSyncExternalStore)(u.current,c.current),h=(0,aa.useRef)(null),f=(0,aa.useRef)(null);if(!h.current||h.current.version!==d.version||h.current.collection!==d.collection){if(!d.collection)f.current={state:void 0,data:void 0,collection:void 0,status:"disabled",isLoading:!1,isReady:!0,isIdle:!1,isError:!1,isCleanedUp:!1,isEnabled:!1};else{let p=Array.from(d.collection.entries()),m=d.collection.config.singleResult,g=null,y=null;f.current={get state(){return g||(g=new Map(p)),g},get data(){return y||(y=p.map(([,v])=>v)),m?y[0]:y},collection:d.collection,status:d.collection.status,isLoading:d.collection.status==="loading",isReady:d.collection.status==="ready",isIdle:d.collection.status==="idle",isError:d.collection.status==="error",isCleanedUp:d.collection.status==="cleaned-up",isEnabled:!0}}h.current=d}return f.current}function iLe(e){if(!e||typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}var oLe=e=>{switch(e){case"success":return lLe;case"info":return cLe;case"warning":return uLe;case"error":return dLe;default:return null}},sLe=Array(12).fill(0),aLe=({visible:e,className:t})=>ve.default.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ve.default.createElement("div",{className:"sonner-spinner"},sLe.map((n,r)=>ve.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),lLe=ve.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.default.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"})),uLe=ve.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ve.default.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"})),cLe=ve.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.default.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"})),dLe=ve.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ve.default.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"})),hLe=ve.default.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"},ve.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),fLe=()=>{let[e,t]=ve.default.useState(document.hidden);return ve.default.useEffect(()=>{let n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e},PP=1,pLe=class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:n,...r}=e,i=typeof e?.id=="number"||((t=e.id)==null?void 0:t.length)>0?e.id:PP++,o=this.toasts.find(a=>a.id===i),s=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),o?this.toasts=this.toasts.map(a=>a.id===i?(this.publish({...a,...e,id:i,title:n}),{...a,...e,id:i,dismissible:s,title:n}):a):this.addToast({title:n,...r,dismissible:s,id:i}),i},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(t=>{this.subscribers.forEach(n=>n({id:t.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:"loading",message:t.loading,description:typeof t.description!="function"?t.description:void 0}));let r=Promise.resolve(e instanceof Function?e():e),i=n!==void 0,o,s=r.then(async l=>{if(o=["resolve",l],ve.default.isValidElement(l))i=!1,this.create({id:n,type:"default",message:l});else if(gLe(l)&&!l.ok){i=!1;let u=typeof t.error=="function"?await t.error(`HTTP error! status: ${l.status}`):t.error,c=typeof t.description=="function"?await t.description(`HTTP error! status: ${l.status}`):t.description,d=typeof u=="object"&&!ve.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"error",description:c,...d})}else if(l instanceof Error){i=!1;let u=typeof t.error=="function"?await t.error(l):t.error,c=typeof t.description=="function"?await t.description(l):t.description,d=typeof u=="object"&&!ve.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"error",description:c,...d})}else if(t.success!==void 0){i=!1;let u=typeof t.success=="function"?await t.success(l):t.success,c=typeof t.description=="function"?await t.description(l):t.description,d=typeof u=="object"&&!ve.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"success",description:c,...d})}}).catch(async l=>{if(o=["reject",l],t.error!==void 0){i=!1;let u=typeof t.error=="function"?await t.error(l):t.error,c=typeof t.description=="function"?await t.description(l):t.description,d=typeof u=="object"&&!ve.default.isValidElement(u)?u:{message:u};this.create({id:n,type:"error",description:c,...d})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally==null||t.finally.call(t)}),a=()=>new Promise((l,u)=>s.then(()=>o[0]==="reject"?u(o[1]):l(o[1])).catch(u));return typeof n!="string"&&typeof n!="number"?{unwrap:a}:Object.assign(n,{unwrap:a})},this.custom=(e,t)=>{let n=t?.id||PP++;return this.create({jsx:e(n),id:n,...t}),n},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},Uo=new pLe,mLe=(e,t)=>{let n=t?.id||PP++;return Uo.addToast({title:e,...t,id:n}),n},gLe=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",yLe=mLe,vLe=()=>Uo.toasts,bLe=()=>Uo.getActiveToasts(),Ey=Object.assign(yLe,{success:Uo.success,info:Uo.info,warning:Uo.warning,error:Uo.error,custom:Uo.custom,message:Uo.message,promise:Uo.promise,dismiss:Uo.dismiss,loading:Uo.loading},{getHistory:vLe,getToasts:bLe});iLe("[data-sonner-toaster][dir=ltr],html[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%)}[data-sonner-toaster][dir=rtl],html[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%)}[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:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[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);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[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 rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [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)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [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;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [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);background:var(--normal-bg);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-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[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}[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}[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,0)) translateX(var(--swipe-amount-x,0));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{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{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{from{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-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--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-sonner-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-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-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, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--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-sonner-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-sonner-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]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[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]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[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]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[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]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[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:first-child{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)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{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 CC(e){return e.label!==void 0}var wLe=3,xLe="24px",SLe="16px",Y8=4e3,kLe=356,CLe=14,NLe=45,MLe=200;function Hl(...e){return e.filter(Boolean).join(" ")}function _Le(e){let[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}var ELe=e=>{var t,n,r,i,o,s,a,l,u;let{invert:c,toast:d,unstyled:h,interacting:f,setHeights:p,visibleToasts:m,heights:g,index:y,toasts:v,expanded:b,removeToast:w,defaultRichColors:x,closeButton:S,style:k,cancelButtonStyle:C,actionButtonStyle:N,className:E="",descriptionClassName:D="",duration:q,position:z,gap:_,expandByDefault:R,classNames:T,icons:B,closeButtonAriaLabel:A="Close toast"}=e,[M,P]=ve.default.useState(null),[F,I]=ve.default.useState(null),[V,W]=ve.default.useState(!1),[j,X]=ve.default.useState(!1),[$,K]=ve.default.useState(!1),[Q,J]=ve.default.useState(!1),[oe,be]=ve.default.useState(!1),[Me,Je]=ve.default.useState(0),[Ve,Ct]=ve.default.useState(0),He=ve.default.useRef(d.duration||q||Y8),de=ve.default.useRef(null),ie=ve.default.useRef(null),ze=y===0,Le=y+1<=m,Oe=d.type,rt=d.dismissible!==!1,Ht=d.className||"",$t=d.descriptionClassName||"",dt=ve.default.useMemo(()=>g.findIndex(ce=>ce.toastId===d.id)||0,[g,d.id]),et=ve.default.useMemo(()=>{var ce;return(ce=d.closeButton)!=null?ce:S},[d.closeButton,S]),pt=ve.default.useMemo(()=>d.duration||q||Y8,[d.duration,q]),nn=ve.default.useRef(0),Dt=ve.default.useRef(0),Ot=ve.default.useRef(0),Kt=ve.default.useRef(null),[Er,Dn]=z.split("-"),Zn=ve.default.useMemo(()=>g.reduce((ce,$e,it)=>it>=dt?ce:ce+$e.height,0),[g,dt]),Un=fLe(),he=d.invert||c,Ae=Oe==="loading";Dt.current=ve.default.useMemo(()=>dt*_+Zn,[dt,Zn]),ve.default.useEffect(()=>{He.current=pt},[pt]),ve.default.useEffect(()=>{W(!0)},[]),ve.default.useEffect(()=>{let ce=ie.current;if(ce){let $e=ce.getBoundingClientRect().height;return Ct($e),p(it=>[{toastId:d.id,height:$e,position:d.position},...it]),()=>p(it=>it.filter(Jt=>Jt.toastId!==d.id))}},[p,d.id]),ve.default.useLayoutEffect(()=>{if(!V)return;let ce=ie.current,$e=ce.style.height;ce.style.height="auto";let it=ce.getBoundingClientRect().height;ce.style.height=$e,Ct(it),p(Jt=>Jt.find(Nt=>Nt.toastId===d.id)?Jt.map(Nt=>Nt.toastId===d.id?{...Nt,height:it}:Nt):[{toastId:d.id,height:it,position:d.position},...Jt])},[V,d.title,d.description,p,d.id,d.jsx,d.action,d.cancel]);let ge=ve.default.useCallback(()=>{X(!0),Je(Dt.current),p(ce=>ce.filter($e=>$e.toastId!==d.id)),setTimeout(()=>{w(d)},MLe)},[d,w,p,Dt]);ve.default.useEffect(()=>{if(d.promise&&Oe==="loading"||d.duration===1/0||d.type==="loading")return;let ce;return b||f||Un?(()=>{if(Ot.current<nn.current){let $e=new Date().getTime()-nn.current;He.current=He.current-$e}Ot.current=new Date().getTime()})():He.current!==1/0&&(nn.current=new Date().getTime(),ce=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),ge()},He.current)),()=>clearTimeout(ce)},[b,f,d,Oe,Un,ge]),ve.default.useEffect(()=>{d.delete&&(ge(),d.onDismiss==null||d.onDismiss.call(d,d))},[ge,d.delete]);function Be(){var ce;if(B?.loading){var $e;return ve.default.createElement("div",{className:Hl(T?.loader,d==null||($e=d.classNames)==null?void 0:$e.loader,"sonner-loader"),"data-visible":Oe==="loading"},B.loading)}return ve.default.createElement(aLe,{className:Hl(T?.loader,d==null||(ce=d.classNames)==null?void 0:ce.loader),visible:Oe==="loading"})}let ye=d.icon||B?.[Oe]||oLe(Oe);var De,gt;return ve.default.createElement("li",{tabIndex:0,ref:ie,className:Hl(E,Ht,T?.toast,d==null||(t=d.classNames)==null?void 0:t.toast,T?.default,T?.[Oe],d==null||(n=d.classNames)==null?void 0:n[Oe]),"data-sonner-toast":"","data-rich-colors":(De=d.richColors)!=null?De:x,"data-styled":!(d.jsx||d.unstyled||h),"data-mounted":V,"data-promise":!!d.promise,"data-swiped":oe,"data-removed":j,"data-visible":Le,"data-y-position":Er,"data-x-position":Dn,"data-index":y,"data-front":ze,"data-swiping":$,"data-dismissible":rt,"data-type":Oe,"data-invert":he,"data-swipe-out":Q,"data-swipe-direction":F,"data-expanded":!!(b||R&&V),"data-testid":d.testId,style:{"--index":y,"--toasts-before":y,"--z-index":v.length-y,"--offset":`${j?Me:Dt.current}px`,"--initial-height":R?"auto":`${Ve}px`,...k,...d.style},onDragEnd:()=>{K(!1),P(null),Kt.current=null},onPointerDown:ce=>{ce.button!==2&&(Ae||!rt||(de.current=new Date,Je(Dt.current),ce.target.setPointerCapture(ce.pointerId),ce.target.tagName!=="BUTTON"&&(K(!0),Kt.current={x:ce.clientX,y:ce.clientY})))},onPointerUp:()=>{var ce,$e,it;if(Q||!rt)return;Kt.current=null;let Jt=Number(((ce=ie.current)==null?void 0:ce.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nt=Number((($e=ie.current)==null?void 0:$e.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),tt=new Date().getTime()-((it=de.current)==null?void 0:it.getTime()),vn=M==="x"?Jt:Nt,Yt=Math.abs(vn)/tt;if(Math.abs(vn)>=NLe||Yt>.11){Je(Dt.current),d.onDismiss==null||d.onDismiss.call(d,d),I(M==="x"?Jt>0?"right":"left":Nt>0?"down":"up"),ge(),J(!0);return}else{var Mt,bt;(Mt=ie.current)==null||Mt.style.setProperty("--swipe-amount-x","0px"),(bt=ie.current)==null||bt.style.setProperty("--swipe-amount-y","0px")}be(!1),K(!1),P(null)},onPointerMove:ce=>{var $e,it,Jt;if(!Kt.current||!rt||(($e=window.getSelection())==null?void 0:$e.toString().length)>0)return;let Nt=ce.clientY-Kt.current.y,tt=ce.clientX-Kt.current.x;var vn;let Yt=(vn=e.swipeDirections)!=null?vn:_Le(z);!M&&(Math.abs(tt)>1||Math.abs(Nt)>1)&&P(Math.abs(tt)>Math.abs(Nt)?"x":"y");let Mt={x:0,y:0},bt=Rn=>1/(1.5+Math.abs(Rn)/20);if(M==="y"){if(Yt.includes("top")||Yt.includes("bottom"))if(Yt.includes("top")&&Nt<0||Yt.includes("bottom")&&Nt>0)Mt.y=Nt;else{let Rn=Nt*bt(Nt);Mt.y=Math.abs(Rn)<Math.abs(Nt)?Rn:Nt}}else if(M==="x"&&(Yt.includes("left")||Yt.includes("right")))if(Yt.includes("left")&&tt<0||Yt.includes("right")&&tt>0)Mt.x=tt;else{let Rn=tt*bt(tt);Mt.x=Math.abs(Rn)<Math.abs(tt)?Rn:tt}(Math.abs(Mt.x)>0||Math.abs(Mt.y)>0)&&be(!0),(it=ie.current)==null||it.style.setProperty("--swipe-amount-x",`${Mt.x}px`),(Jt=ie.current)==null||Jt.style.setProperty("--swipe-amount-y",`${Mt.y}px`)}},et&&!d.jsx&&Oe!=="loading"?ve.default.createElement("button",{"aria-label":A,"data-disabled":Ae,"data-close-button":!0,onClick:Ae||!rt?()=>{}:()=>{ge(),d.onDismiss==null||d.onDismiss.call(d,d)},className:Hl(T?.closeButton,d==null||(r=d.classNames)==null?void 0:r.closeButton)},(gt=B?.close)!=null?gt:hLe):null,(Oe||d.icon||d.promise)&&d.icon!==null&&(B?.[Oe]!==null||d.icon)?ve.default.createElement("div",{"data-icon":"",className:Hl(T?.icon,d==null||(i=d.classNames)==null?void 0:i.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||Be():null,d.type!=="loading"?ye:null):null,ve.default.createElement("div",{"data-content":"",className:Hl(T?.content,d==null||(o=d.classNames)==null?void 0:o.content)},ve.default.createElement("div",{"data-title":"",className:Hl(T?.title,d==null||(s=d.classNames)==null?void 0:s.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?ve.default.createElement("div",{"data-description":"",className:Hl(D,$t,T?.description,d==null||(a=d.classNames)==null?void 0:a.description)},typeof d.description=="function"?d.description():d.description):null),ve.default.isValidElement(d.cancel)?d.cancel:d.cancel&&CC(d.cancel)?ve.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||C,onClick:ce=>{CC(d.cancel)&&rt&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,ce),ge())},className:Hl(T?.cancelButton,d==null||(l=d.classNames)==null?void 0:l.cancelButton)},d.cancel.label):null,ve.default.isValidElement(d.action)?d.action:d.action&&CC(d.action)?ve.default.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||N,onClick:ce=>{CC(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,ce),!ce.defaultPrevented&&ge())},className:Hl(T?.actionButton,d==null||(u=d.classNames)==null?void 0:u.actionButton)},d.action.label):null)};function Q8(){if(typeof window>"u"||typeof document>"u")return"ltr";let e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function OLe(e,t){let n={};return[e,t].forEach((r,i)=>{let o=i===1,s=o?"--mobile-offset":"--offset",a=o?SLe:xLe;function l(u){["top","right","bottom","left"].forEach(c=>{n[`${s}-${c}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${s}-${u}`]=a:n[`${s}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):l(a)}),n}var TLe=ve.default.forwardRef(function(e,t){let{id:n,invert:r,position:i="bottom-right",hotkey:o=["altKey","KeyT"],expand:s,closeButton:a,className:l,offset:u,mobileOffset:c,theme:d="light",richColors:h,duration:f,style:p,visibleToasts:m=wLe,toastOptions:g,dir:y=Q8(),gap:v=CLe,icons:b,containerAriaLabel:w="Notifications"}=e,[x,S]=ve.default.useState([]),k=ve.default.useMemo(()=>n?x.filter(I=>I.toasterId===n):x.filter(I=>!I.toasterId),[x,n]),C=ve.default.useMemo(()=>Array.from(new Set([i].concat(k.filter(I=>I.position).map(I=>I.position)))),[k,i]),[N,E]=ve.default.useState([]),[D,q]=ve.default.useState(!1),[z,_]=ve.default.useState(!1),[R,T]=ve.default.useState(d!=="system"?d:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),B=ve.default.useRef(null),A=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=ve.default.useRef(null),P=ve.default.useRef(!1),F=ve.default.useCallback(I=>{S(V=>{var W;return(W=V.find(j=>j.id===I.id))!=null&&W.delete||Uo.dismiss(I.id),V.filter(({id:j})=>j!==I.id)})},[]);return ve.default.useEffect(()=>Uo.subscribe(I=>{if(I.dismiss){requestAnimationFrame(()=>{S(V=>V.map(W=>W.id===I.id?{...W,delete:!0}:W))});return}setTimeout(()=>{JJ.default.flushSync(()=>{S(V=>{let W=V.findIndex(j=>j.id===I.id);return W!==-1?[...V.slice(0,W),{...V[W],...I},...V.slice(W+1)]:[I,...V]})})})}),[x]),ve.default.useEffect(()=>{if(d!=="system"){T(d);return}if(d==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?T("dark"):T("light")),typeof window>"u")return;let I=window.matchMedia("(prefers-color-scheme: dark)");try{I.addEventListener("change",({matches:V})=>{T(V?"dark":"light")})}catch{I.addListener(({matches:V})=>{try{T(V?"dark":"light")}catch(W){console.error(W)}})}},[d]),ve.default.useEffect(()=>{x.length<=1&&q(!1)},[x]),ve.default.useEffect(()=>{let I=V=>{var W;if(o.every(X=>V[X]||V.code===X)){var j;q(!0),(j=B.current)==null||j.focus()}V.code==="Escape"&&(document.activeElement===B.current||(W=B.current)!=null&&W.contains(document.activeElement))&&q(!1)};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[o]),ve.default.useEffect(()=>{if(B.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,P.current=!1)}},[B.current]),ve.default.createElement("section",{ref:t,"aria-label":`${w} ${A}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},C.map((I,V)=>{var W;let[j,X]=I.split("-");return k.length?ve.default.createElement("ol",{key:I,dir:y==="auto"?Q8():y,tabIndex:-1,ref:B,className:l,"data-sonner-toaster":!0,"data-sonner-theme":R,"data-y-position":j,"data-x-position":X,style:{"--front-toast-height":`${((W=N[0])==null?void 0:W.height)||0}px`,"--width":`${kLe}px`,"--gap":`${v}px`,...p,...OLe(u,c)},onBlur:$=>{P.current&&!$.currentTarget.contains($.relatedTarget)&&(P.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:$=>{$.target instanceof HTMLElement&&$.target.dataset.dismissible==="false"||P.current||(P.current=!0,M.current=$.relatedTarget)},onMouseEnter:()=>q(!0),onMouseMove:()=>q(!0),onMouseLeave:()=>{z||q(!1)},onDragEnd:()=>q(!1),onPointerDown:$=>{$.target instanceof HTMLElement&&$.target.dataset.dismissible==="false"||_(!0)},onPointerUp:()=>_(!1)},k.filter($=>!$.position&&V===0||$.position===I).map(($,K)=>{var Q,J;return ve.default.createElement(ELe,{key:$.id,icons:b,index:K,toast:$,defaultRichColors:h,duration:(Q=g?.duration)!=null?Q:f,className:g?.className,descriptionClassName:g?.descriptionClassName,invert:r,visibleToasts:m,closeButton:(J=g?.closeButton)!=null?J:a,interacting:z,position:I,style:g?.style,unstyled:g?.unstyled,classNames:g?.classNames,cancelButtonStyle:g?.cancelButtonStyle,actionButtonStyle:g?.actionButtonStyle,closeButtonAriaLabel:g?.closeButtonAriaLabel,removeToast:F,toasts:k.filter(oe=>oe.position==$.position),heights:N.filter(oe=>oe.position==$.position),setHeights:E,expandByDefault:s,gap:v,expanded:D,swipeDirections:e.swipeDirections})})):null}))}),IN=Object.create(null),Pb=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?IN:globalThis),vh=new Proxy(IN,{get(e,t){return Pb()[t]??IN[t]},has(e,t){let n=Pb();return t in n||t in IN},set(e,t,n){let r=Pb(!0);return r[t]=n,!0},deleteProperty(e,t){if(!t)return!1;let n=Pb(!0);return delete n[t],!0},ownKeys(){let e=Pb(!0);return Object.keys(e)}}),ALe=typeof process<"u"&&process.env&&"true"||"",DLe=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:!0}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:!0}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:!0}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:!1}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:!1}],["VERCEL","VERCEL_ENV",{ci:!1}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:!1}],["CODESANDBOX","CODESANDBOX_HOST",{ci:!1}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:!0}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:!0}]];function RLe(){if(globalThis.process?.env)for(let e of DLe){let t=e[1]||e[0];if(globalThis.process?.env[t])return{name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:!1}:{name:"",ci:!1}}var ZJ=RLe(),ILe=ZJ.name;function Kp(e){return e?e!=="false":!1}var K_=globalThis.process?.platform||"",Y_=Kp(vh.CI)||ZJ.ci!==!1,eZ=Kp(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY),r1=typeof window<"u",oyt=Kp(vh.DEBUG),PLe=ALe==="test"||Kp(vh.TEST),syt=Kp(vh.MINIMAL)||Y_||PLe||!eZ,LLe=/^win/i.test(K_),ayt=/^linux/i.test(K_),lyt=/^darwin/i.test(K_),uyt=!Kp(vh.NO_COLOR)&&(Kp(vh.FORCE_COLOR)||(eZ||LLe)&&vh.TERM!=="dumb"||Y_),tZ=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null,cyt=Number(tZ?.split(".")[0])||null,BLe=globalThis.process||Object.create(null),G8={versions:{}},nZ=new Proxy(BLe,{get(e,t){if(t==="env")return vh;if(t in e)return e[t];if(t in G8)return G8[t]}}),qLe=globalThis.process?.release?.name==="node",zLe=!!globalThis.Bun||!!globalThis.process?.versions?.bun,FLe=!!globalThis.Deno,jLe=!!globalThis.fastly,VLe=!!globalThis.Netlify,WLe=!!globalThis.EdgeRuntime,ULe=globalThis.navigator?.userAgent==="Cloudflare-Workers",HLe=[[VLe,"netlify"],[WLe,"edge-light"],[ULe,"workerd"],[jLe,"fastly"],[FLe,"deno"],[zLe,"bun"],[qLe,"node"]];function $Le(){let e=HLe.find(t=>t[0]);if(e)return{name:e[1]}}var KLe=$Le(),dyt=KLe?.name||"";function YLe(e=new Date){return`${QLe(e)}T${GLe(e)}${XLe(e)}`}function QLe(e){return[e.getFullYear(),Ip(e.getMonth()+1),Ip(e.getDate())].join("-")}function GLe(e){return[Ip(e.getHours()),Ip(e.getMinutes()),Ip(e.getSeconds())].join(":")}function XLe(e){let t=e.getTimezoneOffset();if(!t)return"Z";let n=Math.abs(t),r=Math.floor(n/60),i=n%60;return`${t>0?"-":"+"}${Ip(r)}:${Ip(i)}`}function Ip(e){return String(e).padStart(2,"0")}var JLe="https://checkpoint.prisma.io/v1",ZLe="check/:product";async function eBe(e){let t=new URL(ZLe,e.baseURL||JLe);t.pathname=t.pathname.replace(":product",e.product);let{additionalData:n}=e;t.search=new URLSearchParams([...Object.entries({arch:e.architecture||nZ.arch||"unknown",check_if_update_available:`${e.skipUpdateCheck!==!0}`,ci:`${Y_}`,ci_name:ILe,cli_install_type:e.cliInstallType||"",cli_path_hash:e.cliPathHash||"",client_event_id:e.eventId||"",command:e.command||"",information:typeof n=="string"?n:n?JSON.stringify(n):"",local_timestamp:YLe(e.timestamp),node_version:tZ||"0.0.0",os:e.platform||K_||"unknown",previous_client_event_id:e.previousEventId||"",project_hash:e.projectHash||"",signature:e.signature,version:e.version}),...tR("schema_generators_providers",e.ormGeneratorProviders),...tR("schema_preview_features",e.ormPreviewFeatures),...tR("schema_providers",[e.ormDatasourceProvider])]).toString(),e.debug&&console.debug("Sending request to:",t.toString());let r=await fetch(t,{headers:{Accept:"application/json","User-Agent":"prisma/js-checkpoint"},method:"GET"});if(!r.ok)throw new Error(`checkpoint response error: ${r.status} ${r.statusText}`);return await r.json()}function tR(e,t){return t?.filter(Boolean).map(n=>[e,n])||[]}var tBe=({...e})=>(0,rZ.jsx)(TLe,{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"}},...e}),iZ=new Set(["like","not like","ilike","not ilike"]);function Sz(e,t,n){let r=e?.datatype.group;if(r===void 0)return"";if(t==="is"||t==="is not")return n.toLowerCase()==="null"?null:n;if(e?.datatype.isArray&&t!=null&&!iZ.has(t))try{let i=JSON.parse(n);return Array.isArray(i)?i:n}catch{return n}if(r==="boolean")return n==="true";if(r==="datetime"||r==="enum"||r==="raw"||r==="string"||r==="time")return n;if(r==="json")try{return JSON.parse(n)}catch{return n}return r==="numeric"?n===""?null:Number(n):n}function oZ(e,t,n){let r=e?.datatype.group;if(t&&(t==="is"||t==="is not"))return n===null?"null":String(n);if(r===void 0||n==null)return"";if(e?.datatype.isArray&&t!=null&&!iZ.has(t))try{return JSON.stringify(n)}catch{return String(n)}if(r==="boolean"||r==="datetime"||r==="enum"||r==="numeric"||r==="raw"||r==="string"||r==="time")return String(n);if(r==="json"){if(n==="")return"";try{return JSON.stringify(n)}catch{return String(n)}}return String(n)}var nBe=Dl(BMe(),1),NC="0123456789abcdef",X8=class sw{constructor(t){this.bytes=t}static ofInner(t){if(t.length!==16)throw new TypeError("not 128-bit length");return new sw(t)}static fromFieldsV7(t,n,r,i){if(!Number.isInteger(t)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||t<0||n<0||r<0||i<0||t>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");let o=new Uint8Array(16);return o[0]=t/2**40,o[1]=t/2**32,o[2]=t/2**24,o[3]=t/2**16,o[4]=t/2**8,o[5]=t,o[6]=112|n>>>8,o[7]=n,o[8]=128|r>>>24,o[9]=r>>>16,o[10]=r>>>8,o[11]=r,o[12]=i>>>24,o[13]=i>>>16,o[14]=i>>>8,o[15]=i,new sw(o)}static parse(t){var n,r,i,o;let s;switch(t.length){case 32:s=(n=/^[0-9a-f]{32}$/i.exec(t))===null||n===void 0?void 0:n[0];break;case 36:s=(r=/^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))===null||r===void 0?void 0:r.slice(1,6).join("");break;case 38:s=(i=/^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t))===null||i===void 0?void 0:i.slice(1,6).join("");break;case 45:s=(o=/^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t))===null||o===void 0?void 0:o.slice(1,6).join("");break;default:break}if(s){let a=new Uint8Array(16);for(let l=0;l<16;l+=4){let u=parseInt(s.substring(2*l,2*l+8),16);a[l+0]=u>>>24,a[l+1]=u>>>16,a[l+2]=u>>>8,a[l+3]=u}return new sw(a)}else throw new SyntaxError("could not parse UUID string")}toString(){let t="";for(let n=0;n<this.bytes.length;n++)t+=NC.charAt(this.bytes[n]>>>4),t+=NC.charAt(this.bytes[n]&15),(n===3||n===5||n===7||n===9)&&(t+="-");return t}toHex(){let t="";for(let n=0;n<this.bytes.length;n++)t+=NC.charAt(this.bytes[n]>>>4),t+=NC.charAt(this.bytes[n]&15);return t}toJSON(){return this.toString()}getVariant(){let t=this.bytes[8]>>>4;if(t<0)throw new Error("unreachable");if(t<=7)return this.bytes.every(n=>n===0)?"NIL":"VAR_0";if(t<=11)return"VAR_10";if(t<=13)return"VAR_110";if(t<=15)return this.bytes.every(n=>n===255)?"MAX":"VAR_RESERVED";throw new Error("unreachable")}getVersion(){return this.getVariant()==="VAR_10"?this.bytes[6]>>>4:void 0}clone(){return new sw(this.bytes.slice(0))}equals(t){return this.compareTo(t)===0}compareTo(t){for(let n=0;n<16;n++){let r=this.bytes[n]-t.bytes[n];if(r!==0)return Math.sign(r)}return 0}},rBe=class{constructor(e){this.timestamp_biased=0,this.counter=0,this.random=e??iBe()}generate(){return this.generateOrResetCore(Date.now(),1e4)}generateOrAbort(){return this.generateOrAbortCore(Date.now(),1e4)}generateOrResetCore(e,t){let n=this.generateOrAbortCore(e,t);return n===void 0&&(this.timestamp_biased=0,n=this.generateOrAbortCore(e,t)),n}generateOrAbortCore(e,t){if(!Number.isInteger(e)||e<0||e>0xffffffffffff)throw new RangeError("`unixTsMs` must be a 48-bit unsigned integer");if(t<0||t>0xffffffffffff)throw new RangeError("`rollbackAllowance` out of reasonable range");if(e++,e>this.timestamp_biased)this.timestamp_biased=e,this.resetCounter();else if(e+t>=this.timestamp_biased)this.counter++,this.counter>4398046511103&&(this.timestamp_biased++,this.resetCounter());else return;return X8.fromFieldsV7(this.timestamp_biased-1,Math.trunc(this.counter/2**30),this.counter&2**30-1,this.random.nextUint32())}resetCounter(){this.counter=this.random.nextUint32()*1024+(this.random.nextUint32()&1023)}generateV4(){let e=new Uint8Array(Uint32Array.of(this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32(),this.random.nextUint32()).buffer);return e[6]=64|e[6]>>>4,e[8]=128|e[8]>>>2,X8.ofInner(e)}},iBe=()=>{if(typeof crypto<"u"&&typeof crypto.getRandomValues<"u")return new oBe;if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");return{nextUint32:()=>Math.trunc(Math.random()*65536)*65536+Math.trunc(Math.random()*65536)}},oBe=class{constructor(){this.buffer=new Uint32Array(8),this.cursor=65535}nextUint32(){return this.cursor>=this.buffer.length&&(crypto.getRandomValues(this.buffer),this.cursor=0),this.buffer[this.cursor++]}},J8,sBe=()=>aBe().toString(),aBe=()=>(J8||(J8=new rBe)).generate(),Pc=nBe.default.createTranslator({uuid:sBe}),lBe=new Set(["=","!=",">",">=","<","<=","is","is not","like","not like","ilike","not ilike"]);function sZ(){return{kind:"FilterGroup",filters:[],after:"and",id:Pc.generate()}}var aZ=sZ();function lZ(e){return JSON.parse(JSON.stringify(e))}function uBe(e){return JSON.parse(JSON.stringify(e))}function uZ(e){return{after:"and",column:e,draftValue:"",id:Pc.generate(),kind:"ColumnFilter",operator:"",value:""}}function cZ(e=""){return{after:"and",id:Pc.generate(),kind:"SqlFilter",sql:e}}function nu(e){return lBe.has(e)}function dZ(e,t){return{...e,filters:e.filters.flatMap(n=>{if(n.kind==="ColumnFilter"){if(!n.column.trim()||!nu(n.operator)||t&&Yp(n,t))return[];let{aiSource:i,draftValue:o,...s}=n;return[{...s,operator:n.operator}]}if(n.kind==="SqlFilter"){if(Yp(n,t??{}))return[];let{aiSource:i,lint:o,...s}=n;return[s]}let r=dZ(n,t);return r.filters.length===0?[]:[r]})}}function kz(e){let t=0;for(let n of e.filters){if(n.kind==="ColumnFilter"){n.column.trim()&&t++;continue}if(n.kind==="SqlFilter"){t++;continue}t+=kz(n)}return t}var cBe=new Set([">",">=","<","<="]),dBe=new Set(["=","!="]),hZ=new Set(["ilike","like","not ilike","not like"]),hBe=/^[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i;function Cz(e,t){let n=["=","!=","is","is not"],r=e.datatype.isArray?CBe(e)?[...n,"like","not like","ilike","not ilike"]:n:kBe(Nz(e));if(!t||t.length===0)return r;let i=new Set(t);return r.filter(o=>i.has(o))}function fBe(e,t){return Cz(e).includes(t)}function Yp(e,t){if(e.kind==="SqlFilter")return ob(e.sql).length===0?{code:"missing-sql",message:"Enter a SQL WHERE clause before saving this filter."}:TW(e.sql)?{code:"invalid-sql-fragment",message:"SQL filters must be a single WHERE clause fragment without embedded semicolons."}:null;if(e.kind==="FilterGroup")return null;if(!e.column.trim()||!t[e.column])return{code:"unknown-column",message:"This filter references a column that is no longer available."};if(!nu(e.operator))return{code:"missing-operator",message:"Choose an operator before saving this filter."};let n=t[e.column],r=gBe(e,n),i=r.trim();if(e.operator==="is"||e.operator==="is not")return i.toLowerCase()==="null"||e.value===null?null:{code:"null-check-only",message:`"${e.operator}" only supports null checks. Use value "null".`};if(!fBe(n,e.operator))return NBe(n,e.operator);if(n.datatype.isArray)return hZ.has(e.operator)||bBe(i)?null:{code:"invalid-array",message:"Array filters must use a valid JSON array value."};switch(Nz(n)){case"binary":return null;case"boolean":return yBe(i)?null:{code:"invalid-boolean",message:'Boolean filters must use "true" or "false".'};case"datetime":return vBe(i)?null:{code:"invalid-datetime",message:"Date/time filters must use a valid date or timestamp."};case"enum":return dBe.has(e.operator)&&n.datatype.options.length>0&&!n.datatype.options.includes(r)?{code:"invalid-enum",message:`Value must be one of: ${n.datatype.options.join(", ")}.`}:null;case"json":return wBe(i)?null:{code:"invalid-json",message:"JSON filters must use valid JSON."};case"numeric":return xBe(i)?null:{code:"invalid-number",message:"Numeric filters must use a valid number."};case"text":return null;case"time":return SBe(i)?null:{code:"invalid-time",message:"Time filters must use a valid time value."};case"unknown":return null;case"uuid":return TBe(i)?null:{code:"invalid-uuid",message:"UUID filters must use a valid UUID value."}}}function pBe(e,t){return Yp(e,t)||(e.kind==="SqlFilter"&&e.lint?.status==="invalid"?e.lint.issue:null)}function PN(e,t){let n=t.trim();return n.length===0?e:{...e,filters:e.filters.map(r=>r.kind==="FilterGroup"?PN(r,n):{...r,aiSource:{query:n}})}}function mBe(e){let{currentFilter:t,previousFilter:n}=e;if(!n)return t;let r=new Map;function i(s){for(let a of s.filters){if(a.kind==="FilterGroup"){i(a);continue}a.aiSource&&r.set(a.id,a.aiSource)}}function o(s){return{...s,filters:s.filters.map(a=>{if(a.kind==="FilterGroup")return o(a);let l=r.get(a.id);return l?{...a,aiSource:l}:a})}}return i(n),r.size===0?t:o(t)}function gBe(e,t){return typeof e.draftValue=="string"?e.draftValue:nu(e.operator)?oZ(t,e.operator,e.value):""}function yBe(e){let t=e.toLowerCase();return t==="true"||t==="false"}function vBe(e){return e.length===0?!1:!Number.isNaN(Date.parse(e))}function bBe(e){if(e.length===0)return!1;try{return Array.isArray(JSON.parse(e))}catch{return!1}}function wBe(e){if(e.length===0)return!1;try{return JSON.parse(e),!0}catch{return!1}}function xBe(e){if(e.length===0)return!1;let t=Number(e);return Number.isFinite(t)}function SBe(e){return e.length===0?!1:/^(?:[01]\d|2[0-3]):[0-5]\d(?::[0-5]\d(?:\.\d{1,6})?)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)?$/.test(e)}function kBe(e){switch(e){case"datetime":case"numeric":case"time":return["=","!=",">",">=","<","<=","is","is not"];case"enum":case"text":return["=","!=","is","is not","like","not like","ilike","not ilike"];case"binary":case"boolean":case"json":case"unknown":case"uuid":return["=","!=","is","is not"]}}function Nz(e){if(OBe(e))return"uuid";if(_Be(e))return"binary";if(e.datatype.group==="raw")return EBe(e)?"text":"unknown";switch(e.datatype.group){case"boolean":return"boolean";case"datetime":return"datetime";case"enum":return"enum";case"json":return"json";case"numeric":return"numeric";case"string":return"text";case"time":return"time"}}function CBe(e){return["enum","text"].includes(Nz(MBe(e)))}function NBe(e,t){return hZ.has(t)?{code:"invalid-operator-for-type",message:e.datatype.isArray?`"${t}" is only available for text-like scalar columns and text-like arrays.`:`"${t}" is only available for text and enum columns.`}:cBe.has(t)?{code:"invalid-operator-for-type",message:`"${t}" is only available for numeric, date/time, and time columns.`}:{code:"invalid-operator-for-type",message:`Operator "${t}" is not supported for this column type.`}}function MBe(e){return{...e,datatype:{...e.datatype,isArray:!1}}}function _Be(e){let t=Mz(e);return t.includes("blob")||t.includes("bytea")||t.includes("binary")}function EBe(e){let t=Mz(e),n=e.datatype.affinity?.toLowerCase()??"";return t.includes("char")||t.includes("clob")||t.includes("string")||t.includes("text")||t.includes("varchar")||n==="text"}function OBe(e){return Mz(e)==="uuid"}function Mz(e){return e.datatype.name.toLowerCase()}function TBe(e){return e.length===0?!1:hBe.test(e)}var _z=RBe();function Dr(e,...t){if(!_z)return;let n=DBe(e,...t);performance.mark(n);try{console.log(e,...t)}catch{console.log(n)}}function ABe(e,...t){_z&&console.warn(e,...t)}function DBe(e,...t){return e.replace(/%[sfdO]/g,n=>{let r=t.shift();return n==="%O"&&r?JSON.stringify(r).replace(/"([^"]+)":/g,"$1:"):String(r)})}function RBe(){try{let e="nuqs-localStorage-test";if(typeof localStorage>"u")return!1;localStorage.setItem(e,e);let t=localStorage.getItem(e)===e;return localStorage.removeItem(e),t&&(localStorage.getItem("debug")||"").includes("nuqs")}catch{return!1}}var IBe={303:"Multiple adapter contexts detected. This might happen in monorepos.",404:"nuqs requires an adapter to work with your framework.",409:"Multiple versions of the library are loaded. This may lead to unexpected behavior. Currently using `%s`, but `%s` (via the %s adapter) was about to load on top.",414:"Max safe URL length exceeded. Some browsers may not be able to accept this URL. Consider limiting the amount of state stored in the URL.",422:"Invalid options combination: `limitUrlUpdates: debounce` should be used in SSR scenarios, with `shallow: false`",429:"URL update rate-limited by the browser. Consider increasing `throttleMs` for key(s) `%s`. %O",500:"Empty search params cache. Search params can't be accessed in Layouts.",501:"Search params cache already populated. Have you called `parse` twice?"};function i1(e){return`[nuqs] ${IBe[e]}
See https://nuqs.dev/NUQS-${e}`}var Qp=(0,Uh.createContext)({useAdapter(){throw new Error(i1(404))}});Qp.displayName="NuqsAdapterContext";_z&&typeof window<"u"&&(window.__NuqsAdapterContext&&window.__NuqsAdapterContext!==Qp&&console.error(i1(303)),window.__NuqsAdapterContext=Qp);function PBe(e){return({children:t,defaultOptions:n,processUrlSearchParams:r,...i})=>(0,Uh.createElement)(Qp.Provider,{...i,value:{useAdapter:e,defaultOptions:n,processUrlSearchParams:r}},t)}function LBe(e){let t=(0,Uh.useContext)(Qp);if(!("useAdapter"in t))throw new Error(i1(404));return t.useAdapter(e)}var BBe=()=>(0,Uh.useContext)(Qp).defaultOptions,qBe=()=>(0,Uh.useContext)(Qp).processUrlSearchParams;function zBe(){if(typeof window>"u"||!window.GestureEvent)return 50;try{let e=navigator.userAgent?.match(/version\/([\d\.]+) safari/i);return parseFloat(e[1])>=17?120:320}catch{return 320}}function FBe(e){return{method:"throttle",timeMs:e}}var Lw=FBe(zBe());function jBe(e){return e===null||Array.isArray(e)&&e.length===0}function VBe(e,t,n){if(typeof e=="string")n.set(t,e);else{n.delete(t);for(let r of e)n.append(t,r);n.has(t)||n.set(t,"")}return n}function fZ(){let e=new Map;return{on(t,n){let r=e.get(t)||[];return r.push(n),e.set(t,r),()=>this.off(t,n)},off(t,n){let r=e.get(t);r&&e.set(t,r.filter(i=>i!==n))},emit(t,n){e.get(t)?.forEach(r=>r(n))}}}function LP(e,t,n){function r(){e(),n.removeEventListener("abort",o)}let i=setTimeout(r,t);function o(){clearTimeout(i),n.removeEventListener("abort",o)}n.addEventListener("abort",o)}function BP(){let e=Promise;if(Promise.hasOwnProperty("withResolvers"))return Promise.withResolvers();let t=()=>{},n=()=>{};return{promise:new e((r,i)=>{t=r,n=i}),resolve:t,reject:n}}function WBe(e,t){let n=t;for(let r=e.length-1;r>=0;r--){let i=e[r];if(!i)continue;let o=n;n=()=>i(o)}n()}function qP(){return new URLSearchParams(location.search)}var pZ=class{updateMap=new Map;options={history:"replace",scroll:!1,shallow:!0};timeMs=Lw.timeMs;transitions=new Set;resolvers=null;controller=null;lastFlushedAt=0;resetQueueOnNextPush=!1;push({key:e,query:t,options:n},r=Lw.timeMs){this.resetQueueOnNextPush&&(this.reset(),this.resetQueueOnNextPush=!1),Dr("[nuqs gtq] Enqueueing %s=%s %O",e,t,n),this.updateMap.set(e,t),n.history==="push"&&(this.options.history="push"),n.scroll&&(this.options.scroll=!0),n.shallow===!1&&(this.options.shallow=!1),n.startTransition&&this.transitions.add(n.startTransition),(!Number.isFinite(this.timeMs)||r>this.timeMs)&&(this.timeMs=r)}getQueuedQuery(e){return this.updateMap.get(e)}getPendingPromise({getSearchParamsSnapshot:e=qP}){return this.resolvers?.promise??Promise.resolve(e())}flush({getSearchParamsSnapshot:e=qP,rateLimitFactor:t=1,...n},r){if(this.controller??=new AbortController,!Number.isFinite(this.timeMs))return Dr("[nuqs gtq] Skipping flush due to throttleMs=Infinity"),Promise.resolve(e());if(this.resolvers)return this.resolvers.promise;this.resolvers=BP();let i=()=>{this.lastFlushedAt=performance.now();let[o,s]=this.applyPendingUpdates({...n,autoResetQueueOnUpdate:n.autoResetQueueOnUpdate??!0,getSearchParamsSnapshot:e},r);s===null?(this.resolvers.resolve(o),this.resetQueueOnNextPush=!0):this.resolvers.reject(o),this.resolvers=null};return LP(()=>{let o=performance.now()-this.lastFlushedAt,s=this.timeMs,a=t*Math.max(0,s-o);Dr("[nuqs gtq] Scheduling flush in %f ms. Throttled at %f ms (x%f)",a,s,t),a===0?i():LP(i,a,this.controller.signal)},0,this.controller.signal),this.resolvers.promise}abort(){return this.controller?.abort(),this.controller=new AbortController,this.resolvers?.resolve(new URLSearchParams),this.resolvers=null,this.reset()}reset(){let e=Array.from(this.updateMap.keys());return Dr("[nuqs gtq] Resetting queue %s",JSON.stringify(Object.fromEntries(this.updateMap))),this.updateMap.clear(),this.transitions.clear(),this.options={history:"replace",scroll:!1,shallow:!0},this.timeMs=Lw.timeMs,e}applyPendingUpdates(e,t){let{updateUrl:n,getSearchParamsSnapshot:r}=e,i=r();if(Dr("[nuqs gtq] Applying %d pending update(s) on top of %s",this.updateMap.size,i.toString()),this.updateMap.size===0)return[i,null];let o=Array.from(this.updateMap.entries()),s={...this.options},a=Array.from(this.transitions);e.autoResetQueueOnUpdate&&this.reset(),Dr("[nuqs gtq] Flushing queue %O with options %O",o,s);for(let[l,u]of o)u===null?i.delete(l):i=VBe(u,l,i);t&&(i=t(i));try{return WBe(a,()=>{n(i,s)}),[i,null]}catch(l){return console.error(i1(429),o.map(([u])=>u).join(),l),[i,l]}}},LN=new pZ;function UBe(e,t,n){let r=(0,Gp.useCallback)(()=>{let o=Object.fromEntries(e.map(s=>[s,n(s)]));return[JSON.stringify(o),o]},[e.join(","),n]),i=(0,Gp.useRef)(null);return i.current===null&&(i.current=r()),(0,Gp.useSyncExternalStore)((0,Gp.useCallback)(o=>{let s=e.map(a=>t(a,o));return()=>s.forEach(a=>a())},[e.join(","),t]),()=>{let[o,s]=r();return i.current[0]===o?i.current[1]:(i.current=[o,s],s)},()=>i.current[1])}var HBe=class{callback;resolvers=BP();controller=new AbortController;queuedValue=void 0;constructor(e){this.callback=e}abort(){this.controller.abort(),this.queuedValue=void 0}push(e,t){return this.queuedValue=e,this.controller.abort(),this.controller=new AbortController,LP(()=>{let n=this.resolvers;try{Dr("[nuqs dq] Flushing debounce queue",e);let r=this.callback(e);Dr("[nuqs dq] Reset debounce queue %O",this.queuedValue),this.queuedValue=void 0,this.resolvers=BP(),r.then(i=>n.resolve(i)).catch(i=>n.reject(i))}catch(r){this.queuedValue=void 0,n.reject(r)}},t,this.controller.signal),this.resolvers.promise}},$Be=class{throttleQueue;queues=new Map;queuedQuerySync=fZ();constructor(e=new pZ){this.throttleQueue=e}useQueuedQueries(e){return UBe(e,(t,n)=>this.queuedQuerySync.on(t,n),t=>this.getQueuedQuery(t))}push(e,t,n,r){if(!Number.isFinite(t)){let s=n.getSearchParamsSnapshot??qP;return Promise.resolve(s())}let i=e.key;if(!this.queues.has(i)){Dr("[nuqs dqc] Creating debounce queue for `%s`",i);let s=new HBe(a=>(this.throttleQueue.push(a),this.throttleQueue.flush(n,r).finally(()=>{this.queues.get(a.key)?.queuedValue===void 0&&(Dr("[nuqs dqc] Cleaning up empty queue for `%s`",a.key),this.queues.delete(a.key)),this.queuedQuerySync.emit(a.key)})));this.queues.set(i,s)}Dr("[nuqs dqc] Enqueueing debounce update %O",e);let o=this.queues.get(i).push(e,t);return this.queuedQuerySync.emit(i),o}abort(e){let t=this.queues.get(e);return t?(Dr("[nuqs dqc] Aborting debounce queue %s=%s",e,t.queuedValue?.query),this.queues.delete(e),t.abort(),this.queuedQuerySync.emit(e),n=>(n.then(t.resolvers.resolve,t.resolvers.reject),n)):n=>n}abortAll(){for(let[e,t]of this.queues.entries())Dr("[nuqs dqc] Aborting debounce queue %s=%s",e,t.queuedValue?.query),t.abort(),t.resolvers.resolve(new URLSearchParams),this.queuedQuerySync.emit(e);this.queues.clear()}getQueuedQuery(e){let t=this.queues.get(e)?.queuedValue?.query;return t!==void 0?t:this.throttleQueue.getQueuedQuery(e)}},nR=new $Be(LN);function KBe(e,t){return e===t?!0:e===null||t===null||typeof e=="string"||typeof t=="string"||e.length!==t.length?!1:e.every((n,r)=>n===t[r])}function mZ(e,t,n){try{return e(t)}catch(r){return ABe("[nuqs] Error while parsing value `%s`: %O"+(n?" (for key `%s`)":""),t,r,n),null}}function Vc(e){function t(n){if(typeof n>"u")return null;let r="";if(Array.isArray(n)){if(n[0]===void 0)return null;r=n[0]}return typeof n=="string"&&(r=n),mZ(e.parse,r)}return{type:"single",eq:(n,r)=>n===r,...e,parseServerSide:t,withDefault(n){return{...this,defaultValue:n,parseServerSide(r){return t(r)??n}}},withOptions(n){return{...this,...n}}}}var hyt=Vc({parse:e=>e,serialize:String}),fyt=Vc({parse:e=>{let t=parseInt(e);return t==t?t:null},serialize:e=>""+Math.round(e)}),pyt=Vc({parse:e=>{let t=parseInt(e);return t==t?t-1:null},serialize:e=>""+Math.round(e+1)}),myt=Vc({parse:e=>{let t=parseInt(e,16);return t==t?t:null},serialize:e=>{let t=Math.round(e).toString(16);return(t.length&1?"0":"")+t}}),gyt=Vc({parse:e=>{let t=parseFloat(e);return t==t?t:null},serialize:String}),yyt=Vc({parse:e=>e.toLowerCase()==="true",serialize:String});function Ez(e,t){return e.valueOf()===t.valueOf()}var vyt=Vc({parse:e=>{let t=parseInt(e);return t==t?new Date(t):null},serialize:e=>""+e.valueOf(),eq:Ez}),byt=Vc({parse:e=>{let t=new Date(e);return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString(),eq:Ez}),wyt=Vc({parse:e=>{let t=new Date(e.slice(0,10));return t.valueOf()==t.valueOf()?t:null},serialize:e=>e.toISOString().slice(0,10),eq:Ez}),rR=fZ(),YBe={};function QBe(e,t={}){let n=(0,ji.useId)(),r=BBe(),i=qBe(),{history:o="replace",scroll:s=r?.scroll??!1,shallow:a=r?.shallow??!0,throttleMs:l=Lw.timeMs,limitUrlUpdates:u=r?.limitUrlUpdates,clearOnDefault:c=r?.clearOnDefault??!0,startTransition:d,urlKeys:h=YBe}=t,f=Object.keys(e).join(","),p=(0,ji.useMemo)(()=>Object.fromEntries(Object.keys(e).map(C=>[C,h[C]??C])),[f,JSON.stringify(h)]),m=LBe(Object.values(p)),g=m.searchParams,y=(0,ji.useRef)({}),v=(0,ji.useMemo)(()=>Object.fromEntries(Object.keys(e).map(C=>[C,e[C].defaultValue??null])),[Object.values(e).map(({defaultValue:C})=>C).join(",")]),b=nR.useQueuedQueries(Object.values(p)),[w,x]=(0,ji.useState)(()=>iR(e,h,g??new URLSearchParams,b).state),S=(0,ji.useRef)(w);if(Dr("[nuq+ %s `%s`] render - state: %O, iSP: %s",n,f,w,g),Object.keys(y.current).join("&")!==Object.values(p).join("&")){let{state:C,hasChanged:N}=iR(e,h,g,b,y.current,S.current);N&&(Dr("[nuq+ %s `%s`] State changed: %O",n,f,{state:C,initialSearchParams:g,queuedQueries:b,queryRef:y.current,stateRef:S.current}),S.current=C,x(C)),y.current=Object.fromEntries(Object.entries(p).map(([E,D])=>[D,e[E]?.type==="multi"?g?.getAll(D):g?.get(D)??null]))}(0,ji.useEffect)(()=>{let{state:C,hasChanged:N}=iR(e,h,g,b,y.current,S.current);N&&(Dr("[nuq+ %s `%s`] State changed: %O",n,f,{state:C,initialSearchParams:g,queuedQueries:b,queryRef:y.current,stateRef:S.current}),S.current=C,x(C))},[Object.values(p).map(C=>`${C}=${g?.getAll(C)}`).join("&"),JSON.stringify(b)]),(0,ji.useEffect)(()=>{let C=Object.keys(e).reduce((N,E)=>(N[E]=({state:D,query:q})=>{x(z=>{let{defaultValue:_}=e[E],R=p[E],T=D??_??null,B=z[E]??_??null;return Object.is(B,T)?(Dr("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). no change, skipping, resolved: %O",n,f,R,D,_,S.current),z):(S.current={...S.current,[E]:T},y.current[R]=q,Dr("[nuq+ %s `%s`] Cross-hook key sync %s: %O (default: %O). updateInternalState, resolved: %O",n,f,R,D,_,S.current),S.current)})},N),{});for(let N of Object.keys(e)){let E=p[N];Dr("[nuq+ %s `%s`] Subscribing to sync for `%s`",n,E,f),rR.on(E,C[N])}return()=>{for(let N of Object.keys(e)){let E=p[N];Dr("[nuq+ %s `%s`] Unsubscribing to sync for `%s`",n,E,f),rR.off(E,C[N])}}},[f,p]);let k=(0,ji.useCallback)((C,N={})=>{let E=Object.fromEntries(Object.keys(e).map(B=>[B,null])),D=typeof C=="function"?C(Z8(S.current,v))??E:C??E;Dr("[nuq+ %s `%s`] setState: %O",n,f,D);let q,z=0,_=!1,R=[];for(let[B,A]of Object.entries(D)){let M=e[B],P=p[B];if(!M||A===void 0)continue;(N.clearOnDefault??M.clearOnDefault??c)&&A!==null&&M.defaultValue!==void 0&&(M.eq??((V,W)=>V===W))(A,M.defaultValue)&&(A=null);let F=A===null?null:(M.serialize??String)(A);rR.emit(P,{state:A,query:F});let I={key:P,query:F,options:{history:N.history??M.history??o,shallow:N.shallow??M.shallow??a,scroll:N.scroll??M.scroll??s,startTransition:N.startTransition??M.startTransition??d}};if(N?.limitUrlUpdates?.method==="debounce"||u?.method==="debounce"||M.limitUrlUpdates?.method==="debounce"){I.options.shallow===!0&&console.warn(i1(422));let V=N?.limitUrlUpdates?.timeMs??u?.timeMs??M.limitUrlUpdates?.timeMs??Lw.timeMs,W=nR.push(I,V,m,i);z<V&&(q=W,z=V)}else{let V=N?.limitUrlUpdates?.timeMs??M?.limitUrlUpdates?.timeMs??u?.timeMs??N.throttleMs??M.throttleMs??l;R.push(nR.abort(P)),LN.push(I,V),_=!0}}let T=R.reduce((B,A)=>A(B),_?LN.flush(m,i):LN.getPendingPromise(m));return q??T},[f,o,a,s,l,u?.method,u?.timeMs,d,p,m.updateUrl,m.getSearchParamsSnapshot,m.rateLimitFactor,i,v]);return[(0,ji.useMemo)(()=>Z8(w,v),[w,v]),k]}function iR(e,t,n,r,i,o){let s=!1,a=Object.entries(e).reduce((l,[u,c])=>{let d=t?.[u]??u,h=r[d],f=c.type==="multi"?[]:null,p=h===void 0?(c.type==="multi"?n?.getAll(d):n?.get(d))??f:h;return i&&o&&KBe(i[d]??f,p)?(l[u]=o[u]??null,l):(s=!0,l[u]=(jBe(p)?null:mZ(c.parse,p,d))??null,i&&(i[d]=p),l)},{});if(!s){let l=Object.keys(e),u=Object.keys(o??{});s=l.length!==u.length||l.some(c=>!u.includes(c))}return{state:a,hasChanged:s}}function Z8(e,t){return Object.fromEntries(Object.keys(e).map(n=>[n,e[n]??t[n]??null]))}function GBe(e,t={}){let{parse:n,type:r,serialize:i,eq:o,defaultValue:s,...a}=t,[{[e]:l},u]=QBe({[e]:{parse:n??(c=>c),type:r,serialize:i,eq:o,defaultValue:s}},a);return[l,(0,ji.useCallback)((c,d={})=>u(h=>({[e]:typeof c=="function"?c(h[e]):c}),d),[e,u])]}function $l(e,t){return GBe(e,t)}function yZ(e){return`#${Object.entries(e).map(([t,n])=>{let r=t.endsWith("Param")?t.slice(0,-5):t;return`${encodeURIComponent(r)}=${encodeURIComponent(n)}`}).join("&")}`}function XBe(e){let{adapter:t,introspection:n}=e,{schemas:r}=n,{defaultSchema:i}=t,o=i??Object.keys(r)[0]??"public",s=Object.keys(r[o]?.tables??{})[0]??"",a=JSON.stringify(aZ);return{schema:o,table:s,filter:a,pageIndex:"0",pageSize:"25",search:"",searchScope:"table",view:"table"}}function JBe(e){let t=[];for(let[n,r]of Object.entries(e.schemas))for(let i of Object.keys(r.tables))t.push({id:`${n}.${i}`,schema:n,table:i,qualifiedName:`${n}.${i}`});return t}function ZBe(){let{adapter:e,navigationTableNamesCollection:t}=is(),{data:n,isFetching:r}=Hh(),{schemas:i}=n,o=(0,Ic.useMemo)(()=>XBe({adapter:e,introspection:n}),[e,n]);(0,Ic.useEffect)(()=>{let R=JBe(n),T=new Map(R.map(A=>[A.id,A])),B=Array.from(t.toArray).map(A=>A.id).filter(A=>!T.has(A));B.length>0&&t.delete(B);for(let A of R){let M=t.get(A.id);if(!M){t.insert(A);continue}M.schema===A.schema&&M.table===A.table&&M.qualifiedName===A.qualifiedName||t.update(A.id,P=>{P.schema=A.schema,P.table=A.table,P.qualifiedName=A.qualifiedName})}},[n,t]);let[s,a]=$l("filter",{defaultValue:o.filter}),[l,u]=$l("pageIndex",{defaultValue:o.pageIndex}),[c,d]=$l("pageSize",{defaultValue:o.pageSize}),[h,f]=$l("pin"),[p,m]=$l("schema",{defaultValue:o.schema}),[g,y]=$l("search",{defaultValue:o.search}),[v,b]=$l("searchScope",{defaultValue:o.searchScope}),[w,x]=$l("sort"),[S,k]=$l("table",{defaultValue:o.table}),[C,N]=$l("view",{defaultValue:o.view}),E=p&&i[p]?p:o.schema,D=E?i[E]:void 0,q=D?D.tables:void 0,z=S&&q?.[S]?S:Object.keys(q??{})[0],_=q&&z?q[z]:void 0;return{metadata:(0,Ic.useMemo)(()=>({activeSchema:D,activeTables:q,activeTable:_,isFetching:r}),[D,q,_,r]),createUrl:yZ,filterParam:s,pageIndexParam:l,pageSizeParam:c,pinParam:h,schemaParam:p,searchParam:g,searchScopeParam:v,sortParam:w,tableParam:S,viewParam:C,setFilterParam:a,setPageIndexParam:u,setPageSizeParam:d,setPinParam:f,setSchemaParam:m,setSearchParam:y,setSearchScopeParam:b,setSortParam:x,setTableParam:k,setViewParam:N}}var vZ=(0,Ic.createContext)(void 0);function eqe({children:e}){let t=ZBe();return(0,gZ.jsx)(vZ.Provider,{value:t,children:e})}function lo(){let e=(0,Ic.useContext)(vZ);if(e===void 0)throw new Error("useNavigationContext must be used within a NavigationContextProvider");return e}function tqe(e){try{let t={light:{},dark:{}},n=e.replace(/@layer\s+base\s*\{|\}$/g,"").trim(),r=n.match(/:root\s*\{([^}]+)\}/),i=n.match(/\.dark\s*\{([^}]+)\}/);return r&&r[1]&&(t.light=e9(r[1])),i&&i[1]&&(t.dark=e9(i[1])),Object.keys(t.light).length===0&&Object.keys(t.dark).length===0?null:t}catch{return null}}function e9(e){let t={},n=/--([\w-]+):\s*([^;]+);?/g,r;for(;(r=n.exec(e))!==null;){let[,i,o]=r;i&&o&&(t[`--${i}`]=o.trim())}return t}function nqe(){return typeof document>"u"?[]:Array.from(document.querySelectorAll(".ps"))}function rqe(e){let{currentThemeVariables:t,isDarkMode:n,removedThemeVariableNames:r}=e,i=nqe();for(let o of i){o.classList.toggle("dark",n);for(let s of r)o.style.removeProperty(s);if(t)for(let[s,a]of Object.entries(t))o.style.setProperty(s,a)}}var iqe=typeof window>"u"?Lc.useEffect:Lc.useLayoutEffect;function oqe(e,t){let n=(0,Lc.useRef)([]),r=(0,Lc.useMemo)(()=>e?typeof e=="string"?tqe(e):e:null,[e]),i=(0,Lc.useMemo)(()=>r?r[t?"dark":"light"]||{}:null,[r,t]);return iqe(()=>{if(typeof document>"u"||!document.body)return;let o=()=>{let a=Object.keys(i??{}),l=n.current.filter(u=>!a.includes(u));rqe({currentThemeVariables:i,isDarkMode:t??!1,removedThemeVariableNames:l}),n.current=a};o();let s=new MutationObserver(()=>{o()});return s.observe(document.body,{childList:!0,subtree:!0}),()=>{s.disconnect()}},[i,t]),{parsedTheme:r,currentThemeVariables:i,hasCustomTheme:!!r}}var zP=120,t9=Symbol("prisma.studio.tanstack_db_mutation_guard.instrumented");function sqe(e){if(typeof e!="object"||e==null)return!1;let t=e;return typeof t.insert=="function"&&typeof t.update=="function"&&typeof t.delete=="function"}function aqe(e){let{maxMutationsPerTick:t,mutationCount:n,triggeredBy:r}=e;return[`[TanStack DB] Mutation burst detected: ${n} mutations in one event-loop tick`,`(threshold: ${t}).`,`Triggered by ${r.collectionName}.${r.method}().`,"This often indicates render-driven write loops.","Keep transient input state local and avoid collection writes on every keystroke."].join(" ")}function lqe(e){return[...e.entries()].sort((t,n)=>n[1]-t[1]).slice(0,5).map(([t,n])=>({collectionName:t,count:n}))}function uqe(e={}){let t=e.enabled??!1,n=e.maxMutationsPerTick??zP,r=e.mode??"warn",i=e.onViolation,o=0,s=!1,a=!1,l=new Map;function u(){o=0,l.clear(),a=!1,s=!1}function c(){s||(s=!0,setTimeout(u,0))}function d(h){if(!t||(c(),o+=1,l.set(h.collectionName,(l.get(h.collectionName)??0)+1),o<=n||a))return;a=!0;let f={collectionBreakdown:lqe(l),maxMutationsPerTick:n,message:aqe({maxMutationsPerTick:n,mutationCount:o,triggeredBy:h}),mutationCount:o,triggeredBy:h};if(i?.(f),r==="throw")throw new Error(f.message);console.warn(f.message,{collectionBreakdown:f.collectionBreakdown,maxMutationsPerTick:f.maxMutationsPerTick,mutationCount:f.mutationCount,triggeredBy:f.triggeredBy})}return{recordMutation:d}}function bZ(){return r1&&window.__PRISMA_STUDIO_STRICT_TANSTACK_DB__===!0}function cqe(){return bZ()}function dqe(){return bZ()?"throw":"warn"}function hqe(){if(!r1)return zP;let e=window.__PRISMA_STUDIO_TANSTACK_DB_MAX_MUTATIONS_PER_TICK__;return Number.isInteger(e)&&e>0?e:zP}var fqe=uqe({maxMutationsPerTick:hqe(),mode:dqe()});function fc(e,t){if(!sqe(e)||!t.guard&&!cqe())return e;let n=e;if(n[t9])return e;let r=t.guard??fqe,{collectionName:i}=t,o=n.insert.bind(n),s=n.update.bind(n),a=n.delete.bind(n);return n.insert=(...l)=>(r.recordMutation({collectionName:i,method:"insert"}),o(...l)),n.update=(...l)=>(r.recordMutation({collectionName:i,method:"update"}),s(...l)),n.delete=(...l)=>(r.recordMutation({collectionName:i,method:"delete"}),a(...l)),n[t9]=!0,e}var pqe=fc(tu(Jg({id:"fallback-ui-local-state",getKey(e){return e.id},initialData:[]})),{collectionName:"fallback-ui-local-state"});function sa(e){return typeof e!="object"||e==null?e:structuredClone(e)}function oR(e,t){return typeof t=="function"?t(e):t}function Q_(e){let t=(0,As.useRef)(null);return t.current||(t.current=`${e}:${Pc.generate()}`),t.current}function En(e,t,n={}){let{cleanupOnUnmount:r=!1}=n,[i,o]=(0,As.useState)(()=>sa(t)),s=(0,As.useRef)(e),a=MZ()?.uiLocalStateCollection??pqe,{data:l}=Xy(f=>{if(!(r||!e))return f.from({item:a}).where(({item:p})=>Qy(p.id,e)).select(({item:p})=>({id:p.id,value:p.value})).findOne()},[r,e,a]);(0,As.useEffect)(()=>{if(r){if(s.current!==e){s.current=e,o(sa(t));return}o(f=>Object.is(f,t)?f:sa(t))}},[r,t,e]);let u=(0,As.useCallback)(f=>{o(p=>sa(oR(p,f)))},[]),c=(0,As.useCallback)(()=>{o(sa(t))},[t]);(0,As.useEffect)(()=>{r||e&&(a.has(e)||a.insert({id:e,value:sa(t)}))},[r,t,e,a]);let d=(0,As.useCallback)(f=>{if(r){u(f);return}if(e){if(!a.get(e)){a.insert({id:e,value:sa(oR(sa(t),f))});return}a.update(e,p=>{let m=p.value;p.value=sa(oR(m,f))})}},[r,t,e,u,a]),h=(0,As.useCallback)(()=>{if(r){c();return}if(e){if(!a.has(e)){a.insert({id:e,value:sa(t)});return}a.update(e,f=>{f.value=sa(t)})}},[r,t,e,c,a]);return[r?i:l?.value??sa(t),d,h]}var mqe="nuqs-hash";function gqe(e,t){let n;return(...r)=>{n&&clearTimeout(n),n=setTimeout(()=>e(...r),t)}}function yqe(){let e=typeof window<"u"?window.location.hash.slice(1):"",[t,n]=En(mqe,e),r=s=>{n(s)};(0,px.useEffect)(()=>{t!==e&&r(e)},[e,t]);function i(s,{history:a}){let{pathname:l,search:u}=window.location,c=s.toString(),d=`${l}${u}#${c}`;a==="push"?window.history.pushState(null,"",d):window.history.replaceState(null,"",d),r(c)}function o(){if(typeof window>"u")return new URLSearchParams;let s=window.location.hash.slice(1);return new URLSearchParams(s)}return(0,px.useEffect)(()=>{let s=gqe(()=>{r(window.location.hash.slice(1))},50);return window.addEventListener("hashchange",s),()=>window.removeEventListener("hashchange",s)},[]),{searchParams:(0,px.useMemo)(()=>new URLSearchParams(t),[t]),updateUrl:i,getSearchParamsSnapshot:o}}var vqe=PBe(yqe),pp="studio-ui-state",bqe="prisma-studio-ui-state-v1",wqe="studio-sql-editor-state",xqe="prisma-studio-sql-editor-state-v1",wZ=25,Sqe="(prefers-color-scheme: dark)",kqe="(prefers-reduced-motion: reduce)";function Cqe(){return nZ.env.CHECKPOINT_DISABLE?.trim()==="1"}function xZ(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}function SZ(){return typeof window>"u"||typeof window.matchMedia!="function"?null:window.matchMedia(Sqe)}function xy(){return SZ()?.matches??xZ()}function Nqe(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(kqe).matches}function Mqe(){if(typeof document>"u"||Nqe())return;let e=document,t=e.startViewTransition;if(typeof t=="function")return t.bind(e)}function kZ(e,t){return e==="dark"||e==="light"||e==="system"?e:typeof t=="boolean"?t?"dark":"light":"system"}function _qe(e){return typeof e=="object"&&e!==null&&"cleanup"in e}function FP(){return{id:pp,isNavigationOpen:!0,isDarkMode:xy(),themeMode:"system",tablePageSize:wZ,isInfiniteScrollEnabled:!1}}function CZ(e){return typeof e=="number"&&Number.isInteger(e)&&Number.isSafeInteger(e)&&e>0?e:wZ}function Eqe(e){let t=FP(),n=kZ(e?.themeMode,e?.isDarkMode),r=n==="system"?xy():n==="dark";return{...t,...e,isDarkMode:r,themeMode:n,tablePageSize:CZ(e?.tablePageSize),isInfiniteScrollEnabled:e?.isInfiniteScrollEnabled??!1}}var NZ=(0,tn.createContext)(void 0);function Oqe(e){let{children:t,onEvent:n,adapter:r,llm:i,theme:o}=e,s=(0,tn.useRef)(new oDe),a=(0,tn.useRef)(Pc.generate()),l=(0,tn.useRef)(new Map),u=(0,tn.useRef)(xy()),c=(0,tn.useRef)(fc(tu(j8({id:pp,storageKey:bqe,getKey(j){return j.id}})),{collectionName:"studio-ui-state"})),d=(0,tn.useRef)(fc(tu(Jg({id:"studio-operation-events",getKey(j){return j.eventId},initialData:[]})),{collectionName:"studio-operation-events"})),h=(0,tn.useRef)(fc(tu(Jg({id:"studio-table-ui-state",getKey(j){return j.id},initialData:[]})),{collectionName:"studio-table-ui-state"})),f=(0,tn.useRef)(fc(tu(Jg({id:"studio-table-query-meta",getKey(j){return j.id},initialData:[]})),{collectionName:"studio-table-query-meta"})),p=(0,tn.useRef)(fc(tu(Jg({id:"studio-local-ui-state",getKey(j){return j.id},initialData:[]})),{collectionName:"studio-local-ui-state"})),m=(0,tn.useRef)(fc(tu(j8({id:wqe,storageKey:xqe,getKey(j){return j.id}})),{collectionName:"studio-sql-editor-state"})),g=(0,tn.useRef)(fc(tu(Jg({id:"studio-navigation-table-names",getKey(j){return j.id},initialData:[]})),{collectionName:"studio-navigation-table-names"})),y=s.current,v=c.current,b=d.current,w=h.current,x=f.current,S=p.current,k=m.current,C=g.current,{data:N=[]}=Xy(v),{data:E=[]}=Xy(b),D=Eqe(N.find(j=>j.id===pp)),q=(0,tn.useMemo)(()=>[...E].sort((j,X)=>new Date(j.timestamp).getTime()-new Date(X.timestamp).getTime()),[E]),z=(0,tn.useCallback)(j=>{if(!v.get(pp)){let X=FP();j(X),v.insert(X);return}v.update(pp,j)},[v]),_=(0,tn.useCallback)((j,X)=>{let $=l.current.get(j);if($!=null)return $;let K=fc(X(),{collectionName:`rows:${j}`});return l.current.set(j,K),K},[]),R=(0,tn.useCallback)(()=>{for(let j of l.current.values())_qe(j)&&typeof j.cleanup=="function"&&j.cleanup().catch(X=>{console.error("Failed to cleanup cached rows collection",X)});l.current.clear()},[]);(0,tn.useEffect)(()=>{v.has(pp)||v.insert(FP())},[v]),(0,tn.useEffect)(()=>{R(),y.resetQueries({exact:!1,queryKey:[]})},[r,R,y]),(0,tn.useEffect)(()=>{if(typeof document>"u")return;let j=SZ(),X=()=>{let K=xy(),Q=v.get(pp);if(!Q){u.current=K;return}if(kZ(Q.themeMode,Q.isDarkMode)!=="system"){u.current=K;return}if(Q.isDarkMode===K){u.current=K;return}z(J=>{J.isDarkMode=K,J.themeMode="system"}),u.current=K};if(X(),j){let K=()=>{u.current!==xy()&&X()};return typeof j.addEventListener=="function"?(j.addEventListener("change",K),()=>{j.removeEventListener("change",K)}):(j.addListener(K),()=>{j.removeListener(K)})}let $=new MutationObserver(K=>{for(let Q of K)if(Q.type==="attributes"&&Q.attributeName==="class"){if(u.current===xZ())continue;X();break}});return $.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>$.disconnect()},[v,z]);let{hasCustomTheme:T}=oqe(o,D.isDarkMode),B=(0,tn.useCallback)(j=>{let{name:X,payload:$}=j;if(X==="studio_operation_error"){if($.error.name==="AbortError")return;Ey.error(`"${$.operation}" operation failed`,{action:{label:"Console",onClick:()=>{window.location.hash=yZ({viewParam:"console"})}}})}let K=Pc.generate(),Q=new Date().toISOString(),J={...j,eventId:K,timestamp:Q};if(J.name==="studio_operation_success"||J.name==="studio_operation_error"){b.insert(J);let oe=b.size-100;if(oe>0){let be=[...b.toArray].sort((Me,Je)=>new Date(Me.timestamp).getTime()-new Date(Je.timestamp).getTime()).slice(0,oe).map(Me=>Me.eventId);be.length>0&&b.delete(be)}}n?.(J),X==="studio_launched"&&r1&&!Y_&&!Cqe()&&!Tqe()&&!Dqe()&&eBe({additionalData:{eventPayload:$,variant:"free"},command:X,eventId:K,product:"prisma-studio-embedded",signature:a.current,skipUpdateCheck:!0,timestamp:new Date(Q),version:"0.27.3"}).catch(oe=>{console.error(oe)})},[n,b]),A=(0,tn.useCallback)(()=>{z(j=>{j.isNavigationOpen=!j.isNavigationOpen})},[z]),M=(0,tn.useCallback)(j=>{let X=()=>{(0,XJ.flushSync)(()=>{z(K=>{K.themeMode=j,K.isDarkMode=j==="system"?xy():j==="dark"})})},$=Mqe();if(typeof $=="function"){$(()=>{X()});return}X()},[z]),P=(0,tn.useCallback)(j=>{let X=CZ(j);z($=>{$.tablePageSize=X})},[z]),F=(0,tn.useCallback)(j=>{z(X=>{X.isInfiniteScrollEnabled=j})},[z]),I=(0,tn.useCallback)(async j=>{if(typeof i=="function"){let X=await i(j);if(!rU(X))throw new cb({code:"request-failed",message:"Studio llm() returned an invalid response shape."});if(X.ok)return X.text;throw new cb({code:X.code,message:X.message})}throw new cb({code:"not-configured",message:"Studio AI is not configured."})},[i]),V=typeof i=="function",W=typeof i=="function";return(0,Cp.jsxs)(sDe,{client:y,children:[(0,Cp.jsx)(tBe,{}),(0,Cp.jsx)(NZ.Provider,{value:{adapter:r,llm:i,hasAiFilter:V,hasAiSql:W,requestLlm:I,onEvent:B,operationEvents:q,isNavigationOpen:D.isNavigationOpen,toggleNavigation:A,isDarkMode:D.isDarkMode,themeMode:D.themeMode,setThemeMode:M,tablePageSize:D.tablePageSize,setTablePageSize:P,isInfiniteScrollEnabled:D.isInfiniteScrollEnabled,setInfiniteScrollEnabled:F,hasCustomTheme:T,queryClient:y,tableUiStateCollection:w,tableQueryMetaCollection:x,uiLocalStateCollection:S,sqlEditorStateCollection:k,navigationTableNamesCollection:C,getOrCreateRowsCollection:_},children:(0,Cp.jsx)(vqe,{children:(0,Cp.jsx)(eqe,{children:t})})})]})}function MZ(){return(0,tn.useContext)(NZ)}function is(){let e=MZ();if(!e)throw new Error("`useStudio` must be used within a `StudioContext.Provider`");return e}function Tqe(){return Aqe()&&"__PVCE__"in window&&window.__PVCE__===!0}function Aqe(){return r1&&"acquireVsCodeApi"in window&&typeof window.acquireVsCodeApi=="function"}function Dqe(){if(!r1)return!1;let{hostname:e}=window.location;return"__PDPCP__"in window&&window.__PDPCP__===!0||e.includes("console.prisma.io")||e.includes("datacdn.workers.dev")}function Rqe(e){return{schemas:{[e||"db"]:{name:e||"db",tables:{}}},timezone:"UTC",filterOperators:[],query:{parameters:[],sql:""}}}function Iqe(e){if(!e?.sql)return null;let t=e.sql.slice(0,120);return e.sql.length>120?`${t}...`:t}function Hh(){let{adapter:e,onEvent:t}=is(),n=(0,$p.useRef)(!1);(0,$p.useEffect)(()=>{n.current=!1},[e]);let r=vDe({queryKey:["introspection"],queryFn:async({signal:a})=>{let[l,u]=await e.introspect({abortSignal:a});if(l)throw t({name:"studio_operation_error",payload:{operation:"introspect",query:l.query,error:l}}),l;if(t({name:"studio_operation_success",payload:{operation:"introspect",query:u.query,error:void 0}}),!n.current){let c=Object.values(u.schemas).reduce((d,h)=>d+Object.keys(h.tables).length,0);t({name:"studio_launched",payload:{tableCount:c}}),n.current=!0}return u},refetchOnReconnect:!1,refetchOnWindowFocus:!1,retry:!1,retryOnMount:!1,staleTime:1/0}),i=(0,$p.useMemo)(()=>Rqe(e.defaultSchema),[e.defaultSchema]),o=r.data!=null,s=(0,$p.useMemo)(()=>r.error?{adapterSource:r.error.adapterSource??e.capabilities?.sqlDialect??e.defaultSchema??"unknown",message:r.error.message,operation:"introspect",query:r.error.query,queryPreview:Iqe(r.error.query)}:null,[e.capabilities?.sqlDialect,e.defaultSchema,r.error]);return{...r,data:r.data??i,errorState:s,hasResolvedIntrospection:o,isUsingLastKnownGoodData:r.isError&&r.data!=null,isUsingPlaceholderData:r.data==null}}function _Z(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=_Z(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function EZ(){for(var e,t,n=0,r="",i=arguments.length;n<i;n++)(e=arguments[n])&&(t=_Z(e))&&(r&&(r+=" "),r+=t);return r}var Pqe=(e,t)=>{let n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Lqe=(e,t)=>({classGroupId:e,validator:t}),OZ=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),n9=[],Bqe="arbitrary..",qqe=e=>{let t=Fqe(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return zqe(i);let o=i.split("-"),s=o[0]===""&&o.length>1?1:0;return TZ(o,s,t)},getConflictingClassGroupIds:(i,o)=>{if(o){let s=r[i],a=n[i];return s?a?Pqe(a,s):s:a||n9}return n[i]||n9}}},TZ=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let l=TZ(e,t+1,i);if(l)return l}let o=n.validators;if(o===null)return;let s=t===0?e.join("-"):e.slice(t).join("-"),a=o.length;for(let l=0;l<a;l++){let u=o[l];if(u.validator(s))return u.classGroupId}},zqe=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?Bqe+r:void 0})(),Fqe=e=>{let{theme:t,classGroups:n}=e;return jqe(n,t)},jqe=(e,t)=>{let n=OZ();for(let r in e){let i=e[r];Oz(i,n,r,t)}return n},Oz=(e,t,n,r)=>{let i=e.length;for(let o=0;o<i;o++){let s=e[o];Vqe(s,t,n,r)}},Vqe=(e,t,n,r)=>{if(typeof e=="string"){Wqe(e,t,n);return}if(typeof e=="function"){Uqe(e,t,n,r);return}Hqe(e,t,n,r)},Wqe=(e,t,n)=>{let r=e===""?t:AZ(t,e);r.classGroupId=n},Uqe=(e,t,n,r)=>{if($qe(e)){Oz(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Lqe(n,e))},Hqe=(e,t,n,r)=>{let i=Object.entries(e),o=i.length;for(let s=0;s<o;s++){let[a,l]=i[s];Oz(l,AZ(t,a),n,r)}},AZ=(e,t)=>{let n=e,r=t.split("-"),i=r.length;for(let o=0;o<i;o++){let s=r[o],a=n.nextPart.get(s);a||(a=OZ(),n.nextPart.set(s,a)),n=a}return n},$qe=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Kqe=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(o,s)=>{n[o]=s,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(o){let s=n[o];if(s!==void 0)return s;if((s=r[o])!==void 0)return i(o,s),s},set(o,s){o in n?n[o]=s:i(o,s)}}},Yqe=[],r9=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Qqe=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=i=>{let o=[],s=0,a=0,l=0,u,c=i.length;for(let m=0;m<c;m++){let g=i[m];if(s===0&&a===0){if(g===":"){o.push(i.slice(l,m)),l=m+1;continue}if(g==="/"){u=m;continue}}g==="["?s++:g==="]"?s--:g==="("?a++:g===")"&&a--}let d=o.length===0?i:i.slice(l),h=d,f=!1;d.endsWith("!")?(h=d.slice(0,-1),f=!0):d.startsWith("!")&&(h=d.slice(1),f=!0);let p=u&&u>l?u-l:void 0;return r9(o,f,h,p)};if(t){let i=t+":",o=r;r=s=>s.startsWith(i)?o(s.slice(i.length)):r9(Yqe,!1,s,void 0,!0)}if(n){let i=r;r=o=>n({className:o,parseClassName:i})}return r},Gqe=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{let r=[],i=[];for(let o=0;o<n.length;o++){let s=n[o],a=s[0]==="[",l=t.has(s);a||l?(i.length>0&&(i.sort(),r.push(...i),i=[]),r.push(s)):i.push(s)}return i.length>0&&(i.sort(),r.push(...i)),r}},Xqe=e=>({cache:Kqe(e.cacheSize),parseClassName:Qqe(e),sortModifiers:Gqe(e),...qqe(e)}),Jqe=/\s+/,Zqe=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o}=t,s=[],a=e.trim().split(Jqe),l="";for(let u=a.length-1;u>=0;u-=1){let c=a[u],{isExternal:d,modifiers:h,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(c);if(d){l=c+(l.length>0?" "+l:l);continue}let g=!!m,y=r(g?p.substring(0,m):p);if(!y){if(!g){l=c+(l.length>0?" "+l:l);continue}if(y=r(p),!y){l=c+(l.length>0?" "+l:l);continue}g=!1}let v=h.length===0?"":h.length===1?h[0]:o(h).join(":"),b=f?v+"!":v,w=b+y;if(s.indexOf(w)>-1)continue;s.push(w);let x=i(y,g);for(let S=0;S<x.length;++S){let k=x[S];s.push(b+k)}l=c+(l.length>0?" "+l:l)}return l},eze=(...e)=>{let t=0,n,r,i="";for(;t<e.length;)(n=e[t++])&&(r=DZ(n))&&(i&&(i+=" "),i+=r);return i},DZ=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=DZ(e[r]))&&(n&&(n+=" "),n+=t);return n},i9=(e,...t)=>{let n,r,i,o,s=l=>{let u=t.reduce((c,d)=>d(c),e());return n=Xqe(u),r=n.cache.get,i=n.cache.set,o=a,a(l)},a=l=>{let u=r(l);if(u)return u;let c=Zqe(l,n);return i(l,c),c};return o=s,(...l)=>o(eze(...l))},tze=[],ai=e=>{let t=n=>n[e]||tze;return t.isThemeGetter=!0,t},RZ=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,IZ=/^\((?:(\w[\w-]*):)?(.+)\)$/i,nze=/^\d+\/\d+$/,rze=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ize=/\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$/,oze=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,sze=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,aze=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,zg=e=>nze.test(e),At=e=>!!e&&!Number.isNaN(Number(e)),Ud=e=>!!e&&Number.isInteger(Number(e)),sR=e=>e.endsWith("%")&&At(e.slice(0,-1)),cc=e=>rze.test(e),lze=()=>!0,uze=e=>ize.test(e)&&!oze.test(e),PZ=()=>!1,cze=e=>sze.test(e),dze=e=>aze.test(e),hze=e=>!Re(e)&&!Ie(e),fze=e=>Cv(e,qZ,PZ),Re=e=>RZ.test(e),ap=e=>Cv(e,zZ,uze),aR=e=>Cv(e,vze,At),o9=e=>Cv(e,LZ,PZ),pze=e=>Cv(e,BZ,dze),MC=e=>Cv(e,FZ,cze),Ie=e=>IZ.test(e),Lb=e=>Nv(e,zZ),mze=e=>Nv(e,bze),s9=e=>Nv(e,LZ),gze=e=>Nv(e,qZ),yze=e=>Nv(e,BZ),_C=e=>Nv(e,FZ,!0),Cv=(e,t,n)=>{let r=RZ.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Nv=(e,t,n=!1)=>{let r=IZ.exec(e);return r?r[1]?t(r[1]):n:!1},LZ=e=>e==="position"||e==="percentage",BZ=e=>e==="image"||e==="url",qZ=e=>e==="length"||e==="size"||e==="bg-size",zZ=e=>e==="length",vze=e=>e==="number",bze=e=>e==="family-name",FZ=e=>e==="shadow",a9=()=>{let e=ai("color"),t=ai("font"),n=ai("text"),r=ai("font-weight"),i=ai("tracking"),o=ai("leading"),s=ai("breakpoint"),a=ai("container"),l=ai("spacing"),u=ai("radius"),c=ai("shadow"),d=ai("inset-shadow"),h=ai("text-shadow"),f=ai("drop-shadow"),p=ai("blur"),m=ai("perspective"),g=ai("aspect"),y=ai("ease"),v=ai("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],x=()=>[...w(),Ie,Re],S=()=>["auto","hidden","clip","visible","scroll"],k=()=>["auto","contain","none"],C=()=>[Ie,Re,l],N=()=>[zg,"full","auto",...C()],E=()=>[Ud,"none","subgrid",Ie,Re],D=()=>["auto",{span:["full",Ud,Ie,Re]},Ud,Ie,Re],q=()=>[Ud,"auto",Ie,Re],z=()=>["auto","min","max","fr",Ie,Re],_=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],R=()=>["start","end","center","stretch","center-safe","end-safe"],T=()=>["auto",...C()],B=()=>[zg,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],A=()=>[e,Ie,Re],M=()=>[...w(),s9,o9,{position:[Ie,Re]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],F=()=>["auto","cover","contain",gze,fze,{size:[Ie,Re]}],I=()=>[sR,Lb,ap],V=()=>["","none","full",u,Ie,Re],W=()=>["",At,Lb,ap],j=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[At,sR,s9,o9],K=()=>["","none",p,Ie,Re],Q=()=>["none",At,Ie,Re],J=()=>["none",At,Ie,Re],oe=()=>[At,Ie,Re],be=()=>[zg,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[cc],breakpoint:[cc],color:[lze],container:[cc],"drop-shadow":[cc],ease:["in","out","in-out"],font:[hze],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[cc],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[cc],shadow:[cc],spacing:["px",At],text:[cc],"text-shadow":[cc],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",zg,Re,Ie,g]}],container:["container"],columns:[{columns:[At,Re,Ie,a]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"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"],sr:["sr-only","not-sr-only"],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:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:k()}],"overscroll-x":[{"overscroll-x":k()}],"overscroll-y":[{"overscroll-y":k()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{start:N()}],end:[{end:N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[Ud,"auto",Ie,Re]}],basis:[{basis:[zg,"full","auto",a,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[At,zg,"auto","initial","none",Re]}],grow:[{grow:["",At,Ie,Re]}],shrink:[{shrink:["",At,Ie,Re]}],order:[{order:[Ud,"first","last","none",Ie,Re]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":q()}],"col-end":[{"col-end":q()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":q()}],"row-end":[{"row-end":q()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":z()}],"auto-rows":[{"auto-rows":z()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[..._(),"normal"]}],"justify-items":[{"justify-items":[...R(),"normal"]}],"justify-self":[{"justify-self":["auto",...R()]}],"align-content":[{content:["normal",..._()]}],"align-items":[{items:[...R(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...R(),{baseline:["","last"]}]}],"place-content":[{"place-content":_()}],"place-items":[{"place-items":[...R(),"baseline"]}],"place-self":[{"place-self":["auto",...R()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:T()}],mx:[{mx:T()}],my:[{my:T()}],ms:[{ms:T()}],me:[{me:T()}],mt:[{mt:T()}],mr:[{mr:T()}],mb:[{mb:T()}],ml:[{ml:T()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:B()}],w:[{w:[a,"screen",...B()]}],"min-w":[{"min-w":[a,"screen","none",...B()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...B()]}],h:[{h:["screen","lh",...B()]}],"min-h":[{"min-h":["screen","lh","none",...B()]}],"max-h":[{"max-h":["screen","lh",...B()]}],"font-size":[{text:["base",n,Lb,ap]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Ie,aR]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",sR,Re]}],"font-family":[{font:[mze,Re,t]}],"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:[i,Ie,Re]}],"line-clamp":[{"line-clamp":[At,"none",Ie,aR]}],leading:[{leading:[o,...C()]}],"list-image":[{"list-image":["none",Ie,Re]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ie,Re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...j(),"wavy"]}],"text-decoration-thickness":[{decoration:[At,"from-font","auto",Ie,ap]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[At,"auto",Ie,Re]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ie,Re]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ie,Re]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:M()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:F()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Ud,Ie,Re],radial:["",Ie,Re],conic:[Ud,Ie,Re]},yze,pze]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:I()}],"gradient-via-pos":[{via:I()}],"gradient-to-pos":[{to:I()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:W()}],"border-w-x":[{"border-x":W()}],"border-w-y":[{"border-y":W()}],"border-w-s":[{"border-s":W()}],"border-w-e":[{"border-e":W()}],"border-w-t":[{"border-t":W()}],"border-w-r":[{"border-r":W()}],"border-w-b":[{"border-b":W()}],"border-w-l":[{"border-l":W()}],"divide-x":[{"divide-x":W()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":W()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...j(),"hidden","none"]}],"divide-style":[{divide:[...j(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...j(),"none","hidden"]}],"outline-offset":[{"outline-offset":[At,Ie,Re]}],"outline-w":[{outline:["",At,Lb,ap]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",c,_C,MC]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",d,_C,MC]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:W()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[At,ap]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":W()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",h,_C,MC]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[At,Ie,Re]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[At]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[Ie,Re]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":w()}],"mask-image-conic-pos":[{"mask-conic":[At]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:M()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:F()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ie,Re]}],filter:[{filter:["","none",Ie,Re]}],blur:[{blur:K()}],brightness:[{brightness:[At,Ie,Re]}],contrast:[{contrast:[At,Ie,Re]}],"drop-shadow":[{"drop-shadow":["","none",f,_C,MC]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",At,Ie,Re]}],"hue-rotate":[{"hue-rotate":[At,Ie,Re]}],invert:[{invert:["",At,Ie,Re]}],saturate:[{saturate:[At,Ie,Re]}],sepia:[{sepia:["",At,Ie,Re]}],"backdrop-filter":[{"backdrop-filter":["","none",Ie,Re]}],"backdrop-blur":[{"backdrop-blur":K()}],"backdrop-brightness":[{"backdrop-brightness":[At,Ie,Re]}],"backdrop-contrast":[{"backdrop-contrast":[At,Ie,Re]}],"backdrop-grayscale":[{"backdrop-grayscale":["",At,Ie,Re]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[At,Ie,Re]}],"backdrop-invert":[{"backdrop-invert":["",At,Ie,Re]}],"backdrop-opacity":[{"backdrop-opacity":[At,Ie,Re]}],"backdrop-saturate":[{"backdrop-saturate":[At,Ie,Re]}],"backdrop-sepia":[{"backdrop-sepia":["",At,Ie,Re]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ie,Re]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[At,"initial",Ie,Re]}],ease:[{ease:["linear","initial",y,Ie,Re]}],delay:[{delay:[At,Ie,Re]}],animate:[{animate:["none",v,Ie,Re]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,Ie,Re]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:Q()}],"rotate-x":[{"rotate-x":Q()}],"rotate-y":[{"rotate-y":Q()}],"rotate-z":[{"rotate-z":Q()}],scale:[{scale:J()}],"scale-x":[{"scale-x":J()}],"scale-y":[{"scale-y":J()}],"scale-z":[{"scale-z":J()}],"scale-3d":["scale-3d"],skew:[{skew:oe()}],"skew-x":[{"skew-x":oe()}],"skew-y":[{"skew-y":oe()}],transform:[{transform:[Ie,Re,"","none","gpu","cpu"]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],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",Ie,Re]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",Ie,Re]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[At,Lb,ap,aR]}],stroke:[{stroke:["none",...A()]}],"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-x","border-w-y","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-x","border-color-y","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"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},wze=(e,{cacheSize:t,prefix:n,experimentalParseClassName:r,extend:i={},override:o={}})=>(aw(e,"cacheSize",t),aw(e,"prefix",n),aw(e,"experimentalParseClassName",r),EC(e.theme,o.theme),EC(e.classGroups,o.classGroups),EC(e.conflictingClassGroups,o.conflictingClassGroups),EC(e.conflictingClassGroupModifiers,o.conflictingClassGroupModifiers),aw(e,"orderSensitiveModifiers",o.orderSensitiveModifiers),OC(e.theme,i.theme),OC(e.classGroups,i.classGroups),OC(e.conflictingClassGroups,i.conflictingClassGroups),OC(e.conflictingClassGroupModifiers,i.conflictingClassGroupModifiers),jZ(e,i,"orderSensitiveModifiers"),e),aw=(e,t,n)=>{n!==void 0&&(e[t]=n)},EC=(e,t)=>{if(t)for(let n in t)aw(e,n,t[n])},OC=(e,t)=>{if(t)for(let n in t)jZ(e,t,n)},jZ=(e,t,n)=>{let r=t[n];r!==void 0&&(e[n]=e[n]?e[n].concat(r):r)},xze=(e,...t)=>typeof e=="function"?i9(a9,e,...t):i9(()=>wze(a9(),e),...t),Sze=xze({});function G(...e){return Sze(EZ(e))}var kze=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Cze=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),l9=e=>{let t=Cze(e);return t.charAt(0).toUpperCase()+t.slice(1)},VZ=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),Nze=e=>{for(let t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0},Mze={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"},_ze=(0,mx.forwardRef)(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:o,iconNode:s,...a},l)=>(0,mx.createElement)("svg",{ref:l,...Mze,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:VZ("lucide",i),...!o&&!Nze(a)&&{"aria-hidden":"true"},...a},[...s.map(([u,c])=>(0,mx.createElement)(u,c)),...Array.isArray(o)?o:[o]])),ct=(e,t)=>{let n=(0,G_.forwardRef)(({className:r,...i},o)=>(0,G_.createElement)(_ze,{ref:o,iconNode:t,className:VZ(`lucide-${kze(l9(e))}`,`lucide-${e}`,r),...i}));return n.displayName=l9(e),n},Eze=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Oze=ct("arrow-down",Eze),Tze=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Aze=ct("arrow-right",Tze),Dze=[["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}],["path",{d:"M17 10V4h-2",key:"zcsr5x"}],["path",{d:"M15 10h4",key:"id2lce"}],["rect",{x:"15",y:"14",width:"4",height:"6",ry:"2",key:"33xykx"}]],Rze=ct("arrow-up-1-0",Dze),Ize=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Pze=ct("arrow-up",Ize),Lze=[["path",{d:"M12 6v12",key:"1vza4d"}],["path",{d:"M17.196 9 6.804 15",key:"1ah31z"}],["path",{d:"m6.804 9 10.392 6",key:"1b6pxd"}]],Bze=ct("asterisk",Lze),qze=[["rect",{width:"7",height:"13",x:"3",y:"8",rx:"1",key:"1fjrkv"}],["path",{d:"m15 2-3 3-3-3",key:"1uh6eb"}],["rect",{width:"7",height:"13",x:"14",y:"8",rx:"1",key:"w3fjg8"}]],zze=ct("between-vertical-start",qze),Fze=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]],jze=ct("calculator",Fze),Vze=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],fm=ct("check",Vze),Wze=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Mv=ct("chevron-down",Wze),Uze=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],WZ=ct("chevron-left",Uze),Hze=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],o1=ct("chevron-right",Hze),$ze=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Kze=ct("chevron-up",$ze),Yze=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],Qze=ct("chevrons-left",Yze),Gze=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Xze=ct("chevrons-right",Gze),Jze=[["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"}]],Tz=ct("circle-alert",Jze),Zze=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],e5e=ct("circle-check-big",Zze),t5e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],UZ=ct("circle",t5e),n5e=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],HZ=ct("code-xml",n5e),r5e=[["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"}]],$Z=ct("copy",r5e),i5e=[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]],o5e=ct("corner-down-left",i5e),s5e=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Az=ct("database",s5e),a5e=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],l5e=ct("file-code-corner",a5e),u5e=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],IM=ct("funnel",u5e),c5e=[["path",{d:"M7 2h10",key:"nczekb"}],["path",{d:"M5 6h14",key:"u2x4p"}],["rect",{width:"18",height:"12",x:"3",y:"10",rx:"2",key:"l0tzu3"}]],d5e=ct("gallery-vertical-end",c5e),h5e=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],u9=ct("key-round",h5e),f5e=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],PM=ct("key",f5e),p5e=[["path",{d:"M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z",key:"1pdavp"}],["path",{d:"M20.054 15.987H3.946",key:"14rxg9"}]],m5e=ct("laptop",p5e),g5e=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],jP=ct("loader-circle",g5e),y5e=[["path",{d:"M5 12h14",key:"1ays0h"}]],KZ=ct("minus",y5e),v5e=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],b5e=ct("moon",v5e),w5e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],x5e=ct("panel-left-close",w5e),S5e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],k5e=ct("panel-left-open",S5e),C5e=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],N5e=ct("pin",C5e),M5e=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],_5e=ct("play",M5e),E5e=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],O5e=ct("plus",E5e),T5e=[["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"}]],Dz=ct("refresh-cw",T5e),A5e=[["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"}]],D5e=ct("save",A5e),R5e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_h=ct("search",R5e),I5e=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],c9=ct("sparkles",I5e),P5e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"m12 16 4-4-4-4",key:"1i9zcv"}]],L5e=ct("square-arrow-right",P5e),B5e=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],q5e=ct("square",B5e),z5e=[["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"}]],F5e=ct("sun",z5e),j5e=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],YZ=ct("table-2",j5e),V5e=[["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"}]],W5e=ct("triangle-alert",V5e),U5e=[["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"}]],H5e=ct("undo-2",U5e),$5e=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],X_=ct("x",$5e),d9=1,K5e=.9,Y5e=.8,Q5e=.17,lR=.1,uR=.999,G5e=.9999,X5e=.99,J5e=/[\\\/_+.#"@\[\(\{&]/,Z5e=/[\\\/_+.#"@\[\(\{&]/g,e3e=/[\s-]/,QZ=/[\s-]/g;function VP(e,t,n,r,i,o,s){if(o===t.length)return i===e.length?d9:X5e;var a=`${i},${o}`;if(s[a]!==void 0)return s[a];for(var l=r.charAt(o),u=n.indexOf(l,i),c=0,d,h,f,p;u>=0;)d=VP(e,t,n,r,u+1,o+1,s),d>c&&(u===i?d*=d9:J5e.test(e.charAt(u-1))?(d*=Y5e,f=e.slice(i,u-1).match(Z5e),f&&i>0&&(d*=Math.pow(uR,f.length))):e3e.test(e.charAt(u-1))?(d*=K5e,p=e.slice(i,u-1).match(QZ),p&&i>0&&(d*=Math.pow(uR,p.length))):(d*=Q5e,i>0&&(d*=Math.pow(uR,u-i))),e.charAt(u)!==t.charAt(o)&&(d*=G5e)),(d<lR&&n.charAt(u-1)===r.charAt(o+1)||r.charAt(o+1)===r.charAt(o)&&n.charAt(u-1)!==r.charAt(o))&&(h=VP(e,t,n,r,u+1,o+2,s),h*lR>d&&(d=h*lR)),d>c&&(c=d),u=n.indexOf(l,u+1);return s[a]=c,c}function h9(e){return e.toLowerCase().replace(QZ," ")}function t3e(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,VP(e,t,h9(e),h9(t),0,0,{})}var xyt=!!(typeof window<"u"&&window.document&&window.document.createElement);function xe(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function f9(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function bu(...e){return t=>{let n=!1,r=e.map(i=>{let o=f9(i,t);return!n&&typeof o=="function"&&(n=!0),o});if(n)return()=>{for(let i=0;i<r.length;i++){let o=r[i];typeof o=="function"?o():f9(e[i],null)}}}}function qt(...e){return GZ.useCallback(bu(...e),e)}function n3e(e,t){let n=Na.createContext(t),r=o=>{let{children:s,...a}=o,l=Na.useMemo(()=>a,Object.values(a));return(0,Rz.jsx)(n.Provider,{value:l,children:s})};r.displayName=e+"Provider";function i(o){let s=Na.useContext(n);if(s)return s;if(t!==void 0)return t;throw new Error(`\`${o}\` must be used within \`${e}\``)}return[r,i]}function os(e,t=[]){let n=[];function r(o,s){let a=Na.createContext(s),l=n.length;n=[...n,s];let u=d=>{let{scope:h,children:f,...p}=d,m=h?.[e]?.[l]||a,g=Na.useMemo(()=>p,Object.values(p));return(0,Rz.jsx)(m.Provider,{value:g,children:f})};u.displayName=o+"Provider";function c(d,h){let f=h?.[e]?.[l]||a,p=Na.useContext(f);if(p)return p;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${o}\``)}return[u,c]}let i=()=>{let o=n.map(s=>Na.createContext(s));return function(s){let a=s?.[e]||o;return Na.useMemo(()=>({[`__scope${e}`]:{...s,[e]:a}}),[s,a])}};return i.scopeName=e,[r,r3e(i,...t)]}function r3e(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(i){let o=r.reduce((s,{useScope:a,scopeName:l})=>{let u=a(i)[`__scope${l}`];return{...s,...u}},{});return Na.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var ao=globalThis?.document?XZ.useLayoutEffect:()=>{},i3e=Iz[" useId ".trim().toString()]||(()=>{}),o3e=0;function fi(e){let[t,n]=Iz.useState(i3e());return ao(()=>{e||n(r=>r??String(o3e++))},[e]),e||(t?`radix-${t}`:"")}var s3e=Ma[" useInsertionEffect ".trim().toString()]||ao;function _a({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,o,s]=a3e({defaultProp:t,onChange:n}),a=e!==void 0,l=a?e:i;{let c=Ma.useRef(e!==void 0);Ma.useEffect(()=>{let d=c.current;d!==a&&console.warn(`${r} is changing from ${d?"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.`),c.current=a},[a,r])}let u=Ma.useCallback(c=>{if(a){let d=l3e(c)?c(e):c;d!==e&&s.current?.(d)}else o(c)},[a,e,o,s]);return[l,u]}function a3e({defaultProp:e,onChange:t}){let[n,r]=Ma.useState(e),i=Ma.useRef(n),o=Ma.useRef(t);return s3e(()=>{o.current=t},[t]),Ma.useEffect(()=>{i.current!==n&&(o.current?.(n),i.current=n)},[n,i]),[n,r,o]}function l3e(e){return typeof e=="function"}function Xp(e){let t=u3e(e),n=pi.forwardRef((r,i)=>{let{children:o,...s}=r,a=pi.Children.toArray(o),l=a.find(c3e);if(l){let u=l.props.children,c=a.map(d=>d===l?pi.Children.count(u)>1?pi.Children.only(null):pi.isValidElement(u)?u.props.children:null:d);return(0,Jy.jsx)(t,{...s,ref:i,children:pi.isValidElement(u)?pi.cloneElement(u,void 0,c):null})}return(0,Jy.jsx)(t,{...s,ref:i,children:o})});return n.displayName=`${e}.Slot`,n}function u3e(e){let t=pi.forwardRef((n,r)=>{let{children:i,...o}=n;if(pi.isValidElement(i)){let s=h3e(i),a=d3e(o,i.props);return i.type!==pi.Fragment&&(a.ref=r?bu(r,s):s),pi.cloneElement(i,a)}return pi.Children.count(i)>1?pi.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var eee=Symbol("radix.slottable");function tee(e){let t=({children:n})=>(0,Jy.jsx)(Jy.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=eee,t}function c3e(e){return pi.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===eee}function d3e(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...s)=>{let a=o(...s);return i(...s),a}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function h3e(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var f3e=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ft=f3e.reduce((e,t)=>{let n=Xp(`Primitive.${t}`),r=JZ.forwardRef((i,o)=>{let{asChild:s,...a}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,nee.jsx)(l,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ree(e,t){e&&ZZ.flushSync(()=>e.dispatchEvent(t))}function Ea(e){let t=_v.useRef(e);return _v.useEffect(()=>{t.current=e}),_v.useMemo(()=>(...n)=>t.current?.(...n),[])}function p3e(e,t=globalThis?.document){let n=Ea(e);iee.useEffect(()=>{let r=i=>{i.key==="Escape"&&n(i)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var m3e="DismissableLayer",WP="dismissableLayer.update",g3e="dismissableLayer.pointerDownOutside",y3e="dismissableLayer.focusOutside",p9,oee=vr.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ev=vr.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:o,onInteractOutside:s,onDismiss:a,...l}=e,u=vr.useContext(oee),[c,d]=vr.useState(null),h=c?.ownerDocument??globalThis?.document,[,f]=vr.useState({}),p=qt(t,k=>d(k)),m=Array.from(u.layers),[g]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=m.indexOf(g),v=c?m.indexOf(c):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,w=v>=y,x=w3e(k=>{let C=k.target,N=[...u.branches].some(E=>E.contains(C));!w||N||(i?.(k),s?.(k),k.defaultPrevented||a?.())},h),S=x3e(k=>{let C=k.target;[...u.branches].some(N=>N.contains(C))||(o?.(k),s?.(k),k.defaultPrevented||a?.())},h);return p3e(k=>{v===u.layers.size-1&&(r?.(k),!k.defaultPrevented&&a&&(k.preventDefault(),a()))},h),vr.useEffect(()=>{if(c)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(p9=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),m9(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=p9)}},[c,h,n,u]),vr.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),m9())},[c,u]),vr.useEffect(()=>{let k=()=>f({});return document.addEventListener(WP,k),()=>document.removeEventListener(WP,k)},[]),(0,Pz.jsx)(ft.div,{...l,ref:p,style:{pointerEvents:b?w?"auto":"none":void 0,...e.style},onFocusCapture:xe(e.onFocusCapture,S.onFocusCapture),onBlurCapture:xe(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:xe(e.onPointerDownCapture,x.onPointerDownCapture)})});Ev.displayName=m3e;var v3e="DismissableLayerBranch",b3e=vr.forwardRef((e,t)=>{let n=vr.useContext(oee),r=vr.useRef(null),i=qt(t,r);return vr.useEffect(()=>{let o=r.current;if(o)return n.branches.add(o),()=>{n.branches.delete(o)}},[n.branches]),(0,Pz.jsx)(ft.div,{...e,ref:i})});b3e.displayName=v3e;function w3e(e,t=globalThis?.document){let n=Ea(e),r=vr.useRef(!1),i=vr.useRef(()=>{});return vr.useEffect(()=>{let o=a=>{if(a.target&&!r.current){let u=function(){see(g3e,n,c,{discrete:!0})};var l=u;let c={originalEvent:a};a.pointerType==="touch"?(t.removeEventListener("click",i.current),i.current=u,t.addEventListener("click",i.current,{once:!0})):u()}else t.removeEventListener("click",i.current);r.current=!1},s=window.setTimeout(()=>{t.addEventListener("pointerdown",o)},0);return()=>{window.clearTimeout(s),t.removeEventListener("pointerdown",o),t.removeEventListener("click",i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function x3e(e,t=globalThis?.document){let n=Ea(e),r=vr.useRef(!1);return vr.useEffect(()=>{let i=o=>{o.target&&!r.current&&see(y3e,n,{originalEvent:o},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function m9(){let e=new CustomEvent(WP);document.dispatchEvent(e)}function see(e,t,n,{discrete:r}){let i=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?ree(i,o):i.dispatchEvent(o)}var cR="focusScope.autoFocusOnMount",dR="focusScope.autoFocusOnUnmount",g9={bubbles:!1,cancelable:!0},S3e="FocusScope",s1=Oa.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:o,...s}=e,[a,l]=Oa.useState(null),u=Ea(i),c=Ea(o),d=Oa.useRef(null),h=qt(t,m=>l(m)),f=Oa.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;Oa.useEffect(()=>{if(r){let v=function(S){if(f.paused||!a)return;let k=S.target;a.contains(k)?d.current=k:Qd(d.current,{select:!0})},b=function(S){if(f.paused||!a)return;let k=S.relatedTarget;k!==null&&(a.contains(k)||Qd(d.current,{select:!0}))},w=function(S){if(document.activeElement===document.body)for(let k of S)k.removedNodes.length>0&&Qd(a)};var m=v,g=b,y=w;document.addEventListener("focusin",v),document.addEventListener("focusout",b);let x=new MutationObserver(w);return a&&x.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",b),x.disconnect()}}},[r,a,f.paused]),Oa.useEffect(()=>{if(a){v9.add(f);let m=document.activeElement;if(!a.contains(m)){let g=new CustomEvent(cR,g9);a.addEventListener(cR,u),a.dispatchEvent(g),g.defaultPrevented||(k3e(E3e(lee(a)),{select:!0}),document.activeElement===m&&Qd(a))}return()=>{a.removeEventListener(cR,u),setTimeout(()=>{let g=new CustomEvent(dR,g9);a.addEventListener(dR,c),a.dispatchEvent(g),g.defaultPrevented||Qd(m??document.body,{select:!0}),a.removeEventListener(dR,c),v9.remove(f)},0)}}},[a,u,c,f]);let p=Oa.useCallback(m=>{if(!n&&!r||f.paused)return;let g=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,y=document.activeElement;if(g&&y){let v=m.currentTarget,[b,w]=C3e(v);b&&w?!m.shiftKey&&y===w?(m.preventDefault(),n&&Qd(b,{select:!0})):m.shiftKey&&y===b&&(m.preventDefault(),n&&Qd(w,{select:!0})):y===v&&m.preventDefault()}},[n,r,f.paused]);return(0,aee.jsx)(ft.div,{tabIndex:-1,...s,ref:h,onKeyDown:p})});s1.displayName=S3e;function k3e(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Qd(r,{select:t}),document.activeElement!==n)return}function C3e(e){let t=lee(e),n=y9(t,e),r=y9(t.reverse(),e);return[n,r]}function lee(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{let i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function y9(e,t){for(let n of e)if(!N3e(n,{upTo:t}))return n}function N3e(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function M3e(e){return e instanceof HTMLInputElement&&"select"in e}function Qd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&M3e(e)&&t&&e.select()}}var v9=_3e();function _3e(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=b9(e,t),e.unshift(t)},remove(t){e=b9(e,t),e[0]?.resume()}}}function b9(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function E3e(e){return e.filter(t=>t.tagName!=="A")}var O3e="Portal",Ov=J_.forwardRef((e,t)=>{let{container:n,...r}=e,[i,o]=J_.useState(!1);ao(()=>o(!0),[]);let s=n||i&&globalThis?.document?.body;return s?uee.default.createPortal((0,cee.jsx)(ft.div,{...r,ref:t}),s):null});Ov.displayName=O3e;function T3e(e,t){return dee.useReducer((n,r)=>t[n][r]??n,e)}var Vs=e=>{let{present:t,children:n}=e,r=A3e(t),i=typeof n=="function"?n({present:r.isPresent}):Zo.Children.only(n),o=qt(r.ref,D3e(i));return typeof n=="function"||r.isPresent?Zo.cloneElement(i,{ref:o}):null};Vs.displayName="Presence";function A3e(e){let[t,n]=Zo.useState(),r=Zo.useRef(null),i=Zo.useRef(e),o=Zo.useRef("none"),s=e?"mounted":"unmounted",[a,l]=T3e(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return Zo.useEffect(()=>{let u=TC(r.current);o.current=a==="mounted"?u:"none"},[a]),ao(()=>{let u=r.current,c=i.current;if(c!==e){let d=o.current,h=TC(u);e?l("MOUNT"):h==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&d!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,l]),ao(()=>{if(t){let u,c=t.ownerDocument.defaultView??window,d=f=>{let p=TC(r.current).includes(CSS.escape(f.animationName));if(f.target===t&&p&&(l("ANIMATION_END"),!i.current)){let m=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},h=f=>{f.target===t&&(o.current=TC(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:Zo.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function TC(e){return e?.animationName||"none"}function D3e(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var hR=0;function Z_(){hee.useEffect(()=>{let e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??w9()),document.body.insertAdjacentElement("beforeend",e[1]??w9()),hR++,()=>{hR===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),hR--}},[])}function w9(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var ou=function(){return ou=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},ou.apply(this,arguments)};function fee(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function R3e(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,o;r<i;r++)(o||!(r in t))&&(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}var BN="right-scroll-bar-position",qN="width-before-scroll-bar",I3e="with-scroll-bars-hidden",P3e="--removed-body-scroll-bar-size";function fR(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function L3e(e,t){var n=(0,pee.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var B3e=typeof window<"u"?tE.useLayoutEffect:tE.useEffect,x9=new WeakMap;function q3e(e,t){var n=L3e(t||null,function(r){return e.forEach(function(i){return fR(i,r)})});return B3e(function(){var r=x9.get(n);if(r){var i=new Set(r),o=new Set(e),s=n.current;i.forEach(function(a){o.has(a)||fR(a,null)}),o.forEach(function(a){i.has(a)||fR(a,s)})}x9.set(n,e)},[e]),n}function z3e(e){return e}function F3e(e,t){t===void 0&&(t=z3e);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(o){var s=t(o,r);return n.push(s),function(){n=n.filter(function(a){return a!==s})}},assignSyncMedium:function(o){for(r=!0;n.length;){var s=n;n=[],s.forEach(o)}n={push:function(a){return o(a)},filter:function(){return n}}},assignMedium:function(o){r=!0;var s=[];if(n.length){var a=n;n=[],a.forEach(o),s=n}var l=function(){var c=s;s=[],c.forEach(o)},u=function(){return Promise.resolve().then(l)};u(),n={push:function(c){s.push(c),u()},filter:function(c){return s=s.filter(c),n}}}};return i}function j3e(e){e===void 0&&(e={});var t=F3e(null);return t.options=ou({async:!0,ssr:!1},e),t}var gee=function(e){var t=e.sideCar,n=fee(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return mee.createElement(r,ou({},n))};gee.isSideCarExport=!0;function V3e(e,t){return e.useMedium(t),gee}var yee=j3e(),pR=function(){},nE=so.forwardRef(function(e,t){var n=so.useRef(null),r=so.useState({onScrollCapture:pR,onWheelCapture:pR,onTouchMoveCapture:pR}),i=r[0],o=r[1],s=e.forwardProps,a=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,h=e.sideCar,f=e.noRelative,p=e.noIsolation,m=e.inert,g=e.allowPinchZoom,y=e.as,v=y===void 0?"div":y,b=e.gapMode,w=fee(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),x=h,S=q3e([n,t]),k=ou(ou({},w),i);return so.createElement(so.Fragment,null,c&&so.createElement(x,{sideCar:yee,removeScrollBar:u,shards:d,noRelative:f,noIsolation:p,inert:m,setCallbacks:o,allowPinchZoom:!!g,lockRef:n,gapMode:b}),s?so.cloneElement(so.Children.only(a),ou(ou({},k),{ref:S})):so.createElement(v,ou({},k,{className:l,ref:S}),a))});nE.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};nE.classNames={fullWidth:qN,zeroRight:BN};var S9,W3e=function(){if(S9)return S9;if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function U3e(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=W3e();return t&&e.setAttribute("nonce",t),e}function H3e(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $3e(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var K3e=function(){var e=0,t=null;return{add:function(n){e==0&&(t=U3e())&&(H3e(t,n),$3e(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Y3e=function(){var e=K3e();return function(t,n){vee.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},bee=function(){var e=Y3e(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},Q3e={left:0,top:0,right:0,gap:0},mR=function(e){return parseInt(e||"",10)||0},G3e=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[mR(n),mR(r),mR(i)]},X3e=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Q3e;var t=G3e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},J3e=bee(),Oy="data-scroll-locked",Z3e=function(e,t,n,r){var i=e.left,o=e.top,s=e.right,a=e.gap;return n===void 0&&(n="margin"),`
.`.concat(I3e,` {
overflow: hidden `).concat(r,`;
padding-right: `).concat(a,"px ").concat(r,`;
}
body[`).concat(Oy,`] {
overflow: hidden `).concat(r,`;
overscroll-behavior: contain;
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
padding-left: `.concat(i,`px;
padding-top: `).concat(o,`px;
padding-right: `).concat(s,`px;
margin-left:0;
margin-top:0;
margin-right: `).concat(a,"px ").concat(r,`;
`),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
}
.`).concat(BN,` {
right: `).concat(a,"px ").concat(r,`;
}
.`).concat(qN,` {
margin-right: `).concat(a,"px ").concat(r,`;
}
.`).concat(BN," .").concat(BN,` {
right: 0 `).concat(r,`;
}
.`).concat(qN," .").concat(qN,` {
margin-right: 0 `).concat(r,`;
}
body[`).concat(Oy,`] {
`).concat(P3e,": ").concat(a,`px;
}
`)},k9=function(){var e=parseInt(document.body.getAttribute(Oy)||"0",10);return isFinite(e)?e:0},eFe=function(){Tv.useEffect(function(){return document.body.setAttribute(Oy,(k9()+1).toString()),function(){var e=k9()-1;e<=0?document.body.removeAttribute(Oy):document.body.setAttribute(Oy,e.toString())}},[])},tFe=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;eFe();var o=Tv.useMemo(function(){return X3e(i)},[i]);return Tv.createElement(J3e,{styles:Z3e(o,!t,i,n?"":"!important")})},UP=!1;if(typeof window<"u")try{Bb=Object.defineProperty({},"passive",{get:function(){return UP=!0,!0}}),window.addEventListener("test",Bb,Bb),window.removeEventListener("test",Bb,Bb)}catch{UP=!1}var Bb,Fg=UP?{passive:!1}:!1,nFe=function(e){return e.tagName==="TEXTAREA"},wee=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!nFe(e)&&n[t]==="visible")},rFe=function(e){return wee(e,"overflowY")},iFe=function(e){return wee(e,"overflowX")},C9=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=xee(e,r);if(i){var o=See(e,r),s=o[1],a=o[2];if(s>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},oFe=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},sFe=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},xee=function(e,t){return e==="v"?rFe(t):iFe(t)},See=function(e,t){return e==="v"?oFe(t):sFe(t)},aFe=function(e,t){return e==="h"&&t==="rtl"?-1:1},lFe=function(e,t,n,r,i){var o=aFe(e,window.getComputedStyle(t).direction),s=o*r,a=n.target,l=t.contains(a),u=!1,c=s>0,d=0,h=0;do{if(!a)break;var f=See(e,a),p=f[0],m=f[1],g=f[2],y=m-g-o*p;(p||y)&&xee(e,a)&&(d+=y,h+=p);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(c&&(i&&Math.abs(d)<1||!i&&s>d)||!c&&(i&&Math.abs(h)<1||!i&&-s>h))&&(u=!0),u},AC=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},N9=function(e){return[e.deltaX,e.deltaY]},M9=function(e){return e&&"current"in e?e.current:e},uFe=function(e,t){return e[0]===t[0]&&e[1]===t[1]},cFe=function(e){return`
.block-interactivity-`.concat(e,` {pointer-events: none;}
.allow-interactivity-`).concat(e,` {pointer-events: all;}
`)},dFe=0,jg=[];function hFe(e){var t=Qn.useRef([]),n=Qn.useRef([0,0]),r=Qn.useRef(),i=Qn.useState(dFe++)[0],o=Qn.useState(bee)[0],s=Qn.useRef(e);Qn.useEffect(function(){s.current=e},[e]),Qn.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var m=R3e([e.lockRef.current],(e.shards||[]).map(M9),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=Qn.useCallback(function(m,g){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!s.current.allowPinchZoom;var y=AC(m),v=n.current,b="deltaX"in m?m.deltaX:v[0]-y[0],w="deltaY"in m?m.deltaY:v[1]-y[1],x,S=m.target,k=Math.abs(b)>Math.abs(w)?"h":"v";if("touches"in m&&k==="h"&&S.type==="range")return!1;var C=window.getSelection(),N=C&&C.anchorNode,E=N?N===S||N.contains(S):!1;if(E)return!1;var D=C9(k,S);if(!D)return!0;if(D?x=k:(x=k==="v"?"h":"v",D=C9(k,S)),!D)return!1;if(!r.current&&"changedTouches"in m&&(b||w)&&(r.current=x),!x)return!0;var q=r.current||x;return lFe(q,g,m,q==="h"?b:w,!0)},[]),l=Qn.useCallback(function(m){var g=m;if(!(!jg.length||jg[jg.length-1]!==o)){var y="deltaY"in g?N9(g):AC(g),v=t.current.filter(function(x){return x.name===g.type&&(x.target===g.target||g.target===x.shadowParent)&&uFe(x.delta,y)})[0];if(v&&v.should){g.cancelable&&g.preventDefault();return}if(!v){var b=(s.current.shards||[]).map(M9).filter(Boolean).filter(function(x){return x.contains(g.target)}),w=b.length>0?a(g,b[0]):!s.current.noIsolation;w&&g.cancelable&&g.preventDefault()}}},[]),u=Qn.useCallback(function(m,g,y,v){var b={name:m,delta:g,target:y,should:v,shadowParent:fFe(y)};t.current.push(b),setTimeout(function(){t.current=t.current.filter(function(w){return w!==b})},1)},[]),c=Qn.useCallback(function(m){n.current=AC(m),r.current=void 0},[]),d=Qn.useCallback(function(m){u(m.type,N9(m),m.target,a(m,e.lockRef.current))},[]),h=Qn.useCallback(function(m){u(m.type,AC(m),m.target,a(m,e.lockRef.current))},[]);Qn.useEffect(function(){return jg.push(o),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:h}),document.addEventListener("wheel",l,Fg),document.addEventListener("touchmove",l,Fg),document.addEventListener("touchstart",c,Fg),function(){jg=jg.filter(function(m){return m!==o}),document.removeEventListener("wheel",l,Fg),document.removeEventListener("touchmove",l,Fg),document.removeEventListener("touchstart",c,Fg)}},[]);var f=e.removeScrollBar,p=e.inert;return Qn.createElement(Qn.Fragment,null,p?Qn.createElement(o,{styles:cFe(i)}):null,f?Qn.createElement(tFe,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function fFe(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var pFe=V3e(yee,hFe),kee=eE.forwardRef(function(e,t){return eE.createElement(nE,ou({},e,{ref:t,sideCar:pFe}))});kee.classNames=nE.classNames;var rE=kee,mFe=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Vg=new WeakMap,DC=new WeakMap,RC={},gR=0,Cee=function(e){return e&&(e.host||Cee(e.parentNode))},gFe=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Cee(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},yFe=function(e,t,n,r){var i=gFe(t,Array.isArray(e)?e:[e]);RC[n]||(RC[n]=new WeakMap);var o=RC[n],s=[],a=new Set,l=new Set(i),u=function(d){!d||a.has(d)||(a.add(d),u(d.parentNode))};i.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(h){if(a.has(h))c(h);else try{var f=h.getAttribute(r),p=f!==null&&f!=="false",m=(Vg.get(h)||0)+1,g=(o.get(h)||0)+1;Vg.set(h,m),o.set(h,g),s.push(h),m===1&&p&&DC.set(h,!0),g===1&&h.setAttribute(n,"true"),p||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return c(t),a.clear(),gR++,function(){s.forEach(function(d){var h=Vg.get(d)-1,f=o.get(d)-1;Vg.set(d,h),o.set(d,f),h||(DC.has(d)||d.removeAttribute(r),DC.delete(d)),f||d.removeAttribute(n)}),gR--,gR||(Vg=new WeakMap,Vg=new WeakMap,DC=new WeakMap,RC={})}},iE=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=t||mFe(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),yFe(r,i,n,"aria-hidden")):function(){return null}},oE="Dialog",[Nee,Mee]=os(oE),[vFe,wl]=Nee(oE),_ee=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!0}=e,a=jn.useRef(null),l=jn.useRef(null),[u,c]=_a({prop:r,defaultProp:i??!1,onChange:o,caller:oE});return(0,Sn.jsx)(vFe,{scope:t,triggerRef:a,contentRef:l,contentId:fi(),titleId:fi(),descriptionId:fi(),open:u,onOpenChange:c,onOpenToggle:jn.useCallback(()=>c(d=>!d),[c]),modal:s,children:n})};_ee.displayName=oE;var Eee="DialogTrigger",Oee=jn.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wl(Eee,n),o=qt(t,i.triggerRef);return(0,Sn.jsx)(ft.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":qz(i.open),...r,ref:o,onClick:xe(e.onClick,i.onOpenToggle)})});Oee.displayName=Eee;var Lz="DialogPortal",[bFe,Tee]=Nee(Lz,{forceMount:void 0}),Aee=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,o=wl(Lz,t);return(0,Sn.jsx)(bFe,{scope:t,forceMount:n,children:jn.Children.map(r,s=>(0,Sn.jsx)(Vs,{present:n||o.open,children:(0,Sn.jsx)(Ov,{asChild:!0,container:i,children:s})}))})};Aee.displayName=Lz;var LM="DialogOverlay",Dee=jn.forwardRef((e,t)=>{let n=Tee(LM,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=wl(LM,e.__scopeDialog);return o.modal?(0,Sn.jsx)(Vs,{present:r||o.open,children:(0,Sn.jsx)(xFe,{...i,ref:t})}):null});Dee.displayName=LM;var wFe=Xp("DialogOverlay.RemoveScroll"),xFe=jn.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wl(LM,n);return(0,Sn.jsx)(rE,{as:wFe,allowPinchZoom:!0,shards:[i.contentRef],children:(0,Sn.jsx)(ft.div,{"data-state":qz(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Jp="DialogContent",Ree=jn.forwardRef((e,t)=>{let n=Tee(Jp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,o=wl(Jp,e.__scopeDialog);return(0,Sn.jsx)(Vs,{present:r||o.open,children:o.modal?(0,Sn.jsx)(SFe,{...i,ref:t}):(0,Sn.jsx)(kFe,{...i,ref:t})})});Ree.displayName=Jp;var SFe=jn.forwardRef((e,t)=>{let n=wl(Jp,e.__scopeDialog),r=jn.useRef(null),i=qt(t,n.contentRef,r);return jn.useEffect(()=>{let o=r.current;if(o)return iE(o)},[]),(0,Sn.jsx)(Iee,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,o=>{o.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,o=>{let s=o.detail.originalEvent,a=s.button===0&&s.ctrlKey===!0;(s.button===2||a)&&o.preventDefault()}),onFocusOutside:xe(e.onFocusOutside,o=>o.preventDefault())})}),kFe=jn.forwardRef((e,t)=>{let n=wl(Jp,e.__scopeDialog),r=jn.useRef(!1),i=jn.useRef(!1);return(0,Sn.jsx)(Iee,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));let s=o.target;n.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),Iee=jn.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,...s}=e,a=wl(Jp,n),l=jn.useRef(null),u=qt(t,l);return Z_(),(0,Sn.jsxs)(Sn.Fragment,{children:[(0,Sn.jsx)(s1,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,Sn.jsx)(Ev,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":qz(a.open),...s,ref:u,onDismiss:()=>a.onOpenChange(!1)})}),(0,Sn.jsxs)(Sn.Fragment,{children:[(0,Sn.jsx)(NFe,{titleId:a.titleId}),(0,Sn.jsx)(_Fe,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Bz="DialogTitle",Pee=jn.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wl(Bz,n);return(0,Sn.jsx)(ft.h2,{id:i.titleId,...r,ref:t})});Pee.displayName=Bz;var Lee="DialogDescription",Bee=jn.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wl(Lee,n);return(0,Sn.jsx)(ft.p,{id:i.descriptionId,...r,ref:t})});Bee.displayName=Lee;var qee="DialogClose",zee=jn.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=wl(qee,n);return(0,Sn.jsx)(ft.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>i.onOpenChange(!1))})});zee.displayName=qee;function qz(e){return e?"open":"closed"}var Fee="DialogTitleWarning",[CFe,jee]=n3e(Fee,{contentName:Jp,titleName:Bz,docsSlug:"dialog"}),NFe=({titleId:e})=>{let t=jee(Fee),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return jn.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},MFe="DialogDescriptionWarning",_Fe=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${jee(MFe).contentName}}.`;return jn.useEffect(()=>{let r=e.current?.getAttribute("aria-describedby");t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},zz=_ee,EFe=Oee,Fz=Aee,sE=Dee,aE=Ree,jz=Pee,Vz=Bee,Wz=zee,OFe=Symbol.for("react.lazy"),BM=Yr[" use ".trim().toString()];function TFe(e){return typeof e=="object"&&e!==null&&"then"in e}function Wee(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===OFe&&"_payload"in e&&TFe(e._payload)}function Uee(e){let t=AFe(e),n=Yr.forwardRef((r,i)=>{let{children:o,...s}=r;Wee(o)&&typeof BM=="function"&&(o=BM(o._payload));let a=Yr.Children.toArray(o),l=a.find(RFe);if(l){let u=l.props.children,c=a.map(d=>d===l?Yr.Children.count(u)>1?Yr.Children.only(null):Yr.isValidElement(u)?u.props.children:null:d);return(0,HP.jsx)(t,{...s,ref:i,children:Yr.isValidElement(u)?Yr.cloneElement(u,void 0,c):null})}return(0,HP.jsx)(t,{...s,ref:i,children:o})});return n.displayName=`${e}.Slot`,n}var Hee=Uee("Slot");function AFe(e){let t=Yr.forwardRef((n,r)=>{let{children:i,...o}=n;if(Wee(i)&&typeof BM=="function"&&(i=BM(i._payload)),Yr.isValidElement(i)){let s=PFe(i),a=IFe(o,i.props);return i.type!==Yr.Fragment&&(a.ref=r?bu(r,s):s),Yr.cloneElement(i,a)}return Yr.Children.count(i)>1?Yr.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var DFe=Symbol("radix.slottable");function RFe(e){return Yr.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===DFe}function IFe(e,t){let n={...t};for(let r in t){let i=e[r],o=t[r];/^on[A-Z]/.test(r)?i&&o?n[r]=(...s)=>{let a=o(...s);return i(...s),a}:i&&(n[r]=i):r==="style"?n[r]={...i,...o}:r==="className"&&(n[r]=[i,o].filter(Boolean).join(" "))}return{...e,...n}}function PFe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var LFe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Wc=LFe.reduce((e,t)=>{let n=Uee(`Primitive.${t}`),r=Vee.forwardRef((i,o)=>{let{asChild:s,...a}=i,l=s?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),(0,$ee.jsx)(l,{...a,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),qb='[cmdk-group=""]',yR='[cmdk-group-items=""]',BFe='[cmdk-group-heading=""]',Kee='[cmdk-item=""]',_9=`${Kee}:not([aria-disabled="true"])`,$P="cmdk-item-select",Zg="data-value",qFe=(e,t,n)=>t3e(e,t,n),Yee=Ee.createContext(void 0),a1=()=>Ee.useContext(Yee),Qee=Ee.createContext(void 0),Uz=()=>Ee.useContext(Qee),Gee=Ee.createContext(void 0),Xee=Ee.forwardRef((e,t)=>{let n=ey(()=>{var I,V;return{search:"",value:(V=(I=e.value)!=null?I:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=ey(()=>new Set),i=ey(()=>new Map),o=ey(()=>new Map),s=ey(()=>new Set),a=Jee(e),{label:l,children:u,value:c,onValueChange:d,filter:h,shouldFilter:f,loop:p,disablePointerSelection:m=!1,vimBindings:g=!0,...y}=e,v=fi(),b=fi(),w=fi(),x=Ee.useRef(null),S=QFe();Zp(()=>{if(c!==void 0){let I=c.trim();n.current.value=I,k.emit()}},[c]),Zp(()=>{S(6,z)},[]);let k=Ee.useMemo(()=>({subscribe:I=>(s.current.add(I),()=>s.current.delete(I)),snapshot:()=>n.current,setState:(I,V,W)=>{var j,X,$,K;if(!Object.is(n.current[I],V)){if(n.current[I]=V,I==="search")q(),E(),S(1,D);else if(I==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Q=document.getElementById(w);Q?Q.focus():(j=document.getElementById(v))==null||j.focus()}if(S(7,()=>{var Q;n.current.selectedItemId=(Q=_())==null?void 0:Q.id,k.emit()}),W||S(5,z),((X=a.current)==null?void 0:X.value)!==void 0){let Q=V??"";(K=($=a.current).onValueChange)==null||K.call($,Q);return}}k.emit()}},emit:()=>{s.current.forEach(I=>I())}}),[]),C=Ee.useMemo(()=>({value:(I,V,W)=>{var j;V!==((j=o.current.get(I))==null?void 0:j.value)&&(o.current.set(I,{value:V,keywords:W}),n.current.filtered.items.set(I,N(V,W)),S(2,()=>{E(),k.emit()}))},item:(I,V)=>(r.current.add(I),V&&(i.current.has(V)?i.current.get(V).add(I):i.current.set(V,new Set([I]))),S(3,()=>{q(),E(),n.current.value||D(),k.emit()}),()=>{o.current.delete(I),r.current.delete(I),n.current.filtered.items.delete(I);let W=_();S(4,()=>{q(),W?.getAttribute("id")===I&&D(),k.emit()})}),group:I=>(i.current.has(I)||i.current.set(I,new Set),()=>{o.current.delete(I),i.current.delete(I)}),filter:()=>a.current.shouldFilter,label:l||e["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:w,labelId:b,listInnerRef:x}),[]);function N(I,V){var W,j;let X=(j=(W=a.current)==null?void 0:W.filter)!=null?j:qFe;return I?X(I,n.current.search,V):0}function E(){if(!n.current.search||a.current.shouldFilter===!1)return;let I=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(j=>{let X=i.current.get(j),$=0;X.forEach(K=>{let Q=I.get(K);$=Math.max(Q,$)}),V.push([j,$])});let W=x.current;R().sort((j,X)=>{var $,K;let Q=j.getAttribute("id"),J=X.getAttribute("id");return(($=I.get(J))!=null?$:0)-((K=I.get(Q))!=null?K:0)}).forEach(j=>{let X=j.closest(yR);X?X.appendChild(j.parentElement===X?j:j.closest(`${yR} > *`)):W.appendChild(j.parentElement===W?j:j.closest(`${yR} > *`))}),V.sort((j,X)=>X[1]-j[1]).forEach(j=>{var X;let $=(X=x.current)==null?void 0:X.querySelector(`${qb}[${Zg}="${encodeURIComponent(j[0])}"]`);$?.parentElement.appendChild($)})}function D(){let I=R().find(W=>W.getAttribute("aria-disabled")!=="true"),V=I?.getAttribute(Zg);k.setState("value",V||void 0)}function q(){var I,V,W,j;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let X=0;for(let $ of r.current){let K=(V=(I=o.current.get($))==null?void 0:I.value)!=null?V:"",Q=(j=(W=o.current.get($))==null?void 0:W.keywords)!=null?j:[],J=N(K,Q);n.current.filtered.items.set($,J),J>0&&X++}for(let[$,K]of i.current)for(let Q of K)if(n.current.filtered.items.get(Q)>0){n.current.filtered.groups.add($);break}n.current.filtered.count=X}function z(){var I,V,W;let j=_();j&&(((I=j.parentElement)==null?void 0:I.firstChild)===j&&((W=(V=j.closest(qb))==null?void 0:V.querySelector(BFe))==null||W.scrollIntoView({block:"nearest"})),j.scrollIntoView({block:"nearest"}))}function _(){var I;return(I=x.current)==null?void 0:I.querySelector(`${Kee}[aria-selected="true"]`)}function R(){var I;return Array.from(((I=x.current)==null?void 0:I.querySelectorAll(_9))||[])}function T(I){let V=R()[I];V&&k.setState("value",V.getAttribute(Zg))}function B(I){var V;let W=_(),j=R(),X=j.findIndex(K=>K===W),$=j[X+I];(V=a.current)!=null&&V.loop&&($=X+I<0?j[j.length-1]:X+I===j.length?j[0]:j[X+I]),$&&k.setState("value",$.getAttribute(Zg))}function A(I){let V=_(),W=V?.closest(qb),j;for(;W&&!j;)W=I>0?KFe(W,qb):YFe(W,qb),j=W?.querySelector(_9);j?k.setState("value",j.getAttribute(Zg)):B(I)}let M=()=>T(R().length-1),P=I=>{I.preventDefault(),I.metaKey?M():I.altKey?A(1):B(1)},F=I=>{I.preventDefault(),I.metaKey?T(0):I.altKey?A(-1):B(-1)};return Ee.createElement(Wc.div,{ref:t,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:I=>{var V;(V=y.onKeyDown)==null||V.call(y,I);let W=I.nativeEvent.isComposing||I.keyCode===229;if(!(I.defaultPrevented||W))switch(I.key){case"n":case"j":{g&&I.ctrlKey&&P(I);break}case"ArrowDown":{P(I);break}case"p":case"k":{g&&I.ctrlKey&&F(I);break}case"ArrowUp":{F(I);break}case"Home":{I.preventDefault(),T(0);break}case"End":{I.preventDefault(),M();break}case"Enter":{I.preventDefault();let j=_();if(j){let X=new Event($P);j.dispatchEvent(X)}}}}},Ee.createElement("label",{"cmdk-label":"",htmlFor:C.inputId,id:C.labelId,style:XFe},l),lE(e,I=>Ee.createElement(Qee.Provider,{value:k},Ee.createElement(Yee.Provider,{value:C},I))))}),zFe=Ee.forwardRef((e,t)=>{var n,r;let i=fi(),o=Ee.useRef(null),s=Ee.useContext(Gee),a=a1(),l=Jee(e),u=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:s?.forceMount;Zp(()=>{if(!u)return a.item(i,s?.id)},[u]);let c=Zee(i,o,[e.value,e.children,o],e.keywords),d=Uz(),h=Eh(S=>S.value&&S.value===c.current),f=Eh(S=>u||a.filter()===!1?!0:S.search?S.filtered.items.get(i)>0:!0);Ee.useEffect(()=>{let S=o.current;if(!(!S||e.disabled))return S.addEventListener($P,p),()=>S.removeEventListener($P,p)},[f,e.onSelect,e.disabled]);function p(){var S,k;m(),(k=(S=l.current).onSelect)==null||k.call(S,c.current)}function m(){d.setState("value",c.current,!0)}if(!f)return null;let{disabled:g,value:y,onSelect:v,forceMount:b,keywords:w,...x}=e;return Ee.createElement(Wc.div,{ref:bu(o,t),...x,id:i,"cmdk-item":"",role:"option","aria-disabled":!!g,"aria-selected":!!h,"data-disabled":!!g,"data-selected":!!h,onPointerMove:g||a.getDisablePointerSelection()?void 0:m,onClick:g?void 0:p},e.children)}),FFe=Ee.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...o}=e,s=fi(),a=Ee.useRef(null),l=Ee.useRef(null),u=fi(),c=a1(),d=Eh(f=>i||c.filter()===!1?!0:f.search?f.filtered.groups.has(s):!0);Zp(()=>c.group(s),[]),Zee(s,a,[e.value,e.heading,l]);let h=Ee.useMemo(()=>({id:s,forceMount:i}),[i]);return Ee.createElement(Wc.div,{ref:bu(a,t),...o,"cmdk-group":"",role:"presentation",hidden:d?void 0:!0},n&&Ee.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:u},n),lE(e,f=>Ee.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?u:void 0},Ee.createElement(Gee.Provider,{value:h},f))))}),jFe=Ee.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Ee.useRef(null),o=Eh(s=>!s.search);return!n&&!o?null:Ee.createElement(Wc.div,{ref:bu(i,t),...r,"cmdk-separator":"",role:"separator"})}),VFe=Ee.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,o=Uz(),s=Eh(u=>u.search),a=Eh(u=>u.selectedItemId),l=a1();return Ee.useEffect(()=>{e.value!=null&&o.setState("search",e.value)},[e.value]),Ee.createElement(Wc.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:i?e.value:s,onChange:u=>{i||o.setState("search",u.target.value),n?.(u.target.value)}})}),WFe=Ee.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,o=Ee.useRef(null),s=Ee.useRef(null),a=Eh(u=>u.selectedItemId),l=a1();return Ee.useEffect(()=>{if(s.current&&o.current){let u=s.current,c=o.current,d,h=new ResizeObserver(()=>{d=requestAnimationFrame(()=>{let f=u.offsetHeight;c.style.setProperty("--cmdk-list-height",f.toFixed(1)+"px")})});return h.observe(u),()=>{cancelAnimationFrame(d),h.unobserve(u)}}},[]),Ee.createElement(Wc.div,{ref:bu(o,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},lE(e,u=>Ee.createElement("div",{ref:bu(s,l.listInnerRef),"cmdk-list-sizer":""},u)))}),UFe=Ee.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:o,container:s,...a}=e;return Ee.createElement(zz,{open:n,onOpenChange:r},Ee.createElement(Fz,{container:s},Ee.createElement(sE,{"cmdk-overlay":"",className:i}),Ee.createElement(aE,{"aria-label":e.label,"cmdk-dialog":"",className:o},Ee.createElement(Xee,{ref:t,...a}))))}),HFe=Ee.forwardRef((e,t)=>Eh(n=>n.filtered.count===0)?Ee.createElement(Wc.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),$Fe=Ee.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...o}=e;return Ee.createElement(Wc.div,{ref:t,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},lE(e,s=>Ee.createElement("div",{"aria-hidden":!0},s)))}),ss=Object.assign(Xee,{List:WFe,Item:zFe,Input:VFe,Group:FFe,Separator:jFe,Dialog:UFe,Empty:HFe,Loading:$Fe});function KFe(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function YFe(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Jee(e){let t=Ee.useRef(e);return Zp(()=>{t.current=e}),t}var Zp=typeof window>"u"?Ee.useEffect:Ee.useLayoutEffect;function ey(e){let t=Ee.useRef();return t.current===void 0&&(t.current=e()),t}function Eh(e){let t=Uz(),n=()=>e(t.snapshot());return Ee.useSyncExternalStore(t.subscribe,n,n)}function Zee(e,t,n,r=[]){let i=Ee.useRef(),o=a1();return Zp(()=>{var s;let a=(()=>{var u;for(let c of n){if(typeof c=="string")return c.trim();if(typeof c=="object"&&"current"in c)return c.current?(u=c.current.textContent)==null?void 0:u.trim():i.current}})(),l=r.map(u=>u.trim());o.value(e,a,l),(s=t.current)==null||s.setAttribute(Zg,a),i.current=a}),i}var QFe=()=>{let[e,t]=Ee.useState(),n=ey(()=>new Map);return Zp(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,i)=>{n.current.set(r,i),t({})}};function GFe(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function lE({asChild:e,children:t},n){return e&&Ee.isValidElement(t)?Ee.cloneElement(GFe(t),{ref:t.ref},n(t.props.children)):n(t)}var XFe={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"},ete=zz,JFe=Fz,tte=l1.forwardRef(({className:e,...t},n)=>(0,Xo.jsx)(sE,{ref:n,className:G("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",e),...t}));tte.displayName=sE.displayName;var Hz=l1.forwardRef(({className:e,children:t,container:n,showCloseButton:r=!0,...i},o)=>(0,Xo.jsx)(JFe,{container:n??void 0,children:(0,Xo.jsxs)("div",{className:"ps",children:[(0,Xo.jsx)(tte,{}),(0,Xo.jsxs)(aE,{ref:o,className:G("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background 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%] sm:rounded-lg",e),...i,children:[t,r?(0,Xo.jsxs)(Wz,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,Xo.jsx)(X_,{className:"size-4"}),(0,Xo.jsx)("span",{className:"sr-only",children:"Close"})]}):null]})]})}));Hz.displayName=aE.displayName;var ZFe=({className:e,...t})=>(0,Xo.jsx)("div",{className:G("flex flex-col gap-1.5 text-center sm:text-left",e),...t});ZFe.displayName="DialogHeader";var eje=({className:e,...t})=>(0,Xo.jsx)("div",{className:G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t});eje.displayName="DialogFooter";var nte=l1.forwardRef(({className:e,...t},n)=>(0,Xo.jsx)(jz,{ref:n,className:G("text-lg font-semibold leading-none tracking-tight",e),...t}));nte.displayName=jz.displayName;var rte=l1.forwardRef(({className:e,...t},n)=>(0,Xo.jsx)(Vz,{ref:n,className:G("text-sm text-muted-foreground",e),...t}));rte.displayName=Vz.displayName;var $z=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss,{ref:n,className:G("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));$z.displayName=ss.displayName;var tje=({children:e,...t})=>(0,Ro.jsx)(ete,{...t,children:(0,Ro.jsx)(Hz,{className:"overflow-hidden p-0",showCloseButton:!1,children:(0,Ro.jsx)($z,{children:e})})});tje.displayName="CommandDialog";var ite=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsxs)("div",{className:"flex items-center gap-3 border-b border-border bg-muted/20 px-4 py-3.5",children:[(0,Ro.jsx)(_h,{className:"size-4 shrink-0 text-muted-foreground/75"}),(0,Ro.jsx)(ss.Input,{ref:n,className:G("flex h-9 w-full rounded-md bg-transparent px-0 font-sans text-[15px] font-medium leading-6 outline-none placeholder:text-muted-foreground/75 disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));ite.displayName=ss.Input.displayName;var ote=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss.List,{ref:n,className:G("max-h-[min(68vh,26rem)] overflow-y-auto overflow-x-hidden px-2 pb-2 pt-1",e),...t}));ote.displayName=ss.List.displayName;var ste=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss.Empty,{ref:n,className:G("px-4 py-6 text-sm text-muted-foreground",e),...t}));ste.displayName=ss.Empty.displayName;var KP=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss.Group,{ref:n,className:G("overflow-hidden px-1.5 pb-1.5 pt-1 text-foreground [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:pt-2.5 [&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:tracking-[0.16em] [&_[cmdk-group-heading]]:text-muted-foreground/70 [&_[cmdk-group-heading]]:uppercase",e),...t}));KP.displayName=ss.Group.displayName;var nje=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss.Separator,{ref:n,className:G("-mx-1 h-px bg-border",e),...t}));nje.displayName=ss.Separator.displayName;var Kz=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)(ss.Item,{ref:n,className:G("group relative flex min-h-9 cursor-default items-center gap-2.5 rounded-xl px-3 py-2 font-sans text-left text-[13px] font-medium outline-none select-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-secondary/90 data-[selected=true]:ring-1 data-[selected=true]:ring-border/60 data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",e),...t}));Kz.displayName=ss.Item.displayName;var rje=Uc.forwardRef(({className:e,...t},n)=>(0,Ro.jsx)("span",{ref:n,className:G("ml-auto text-xs tracking-widest text-muted-foreground",e),...t}));rje.displayName="CommandShortcut";function Yz(e){let t=uE.useRef({value:e,previous:e});return uE.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function Qz(e){let[t,n]=ate.useState(void 0);return ao(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;let o=i[0],s,a;if("borderBoxSize"in o){let l=o.borderBoxSize,u=Array.isArray(l)?l[0]:l;s=u.inlineSize,a=u.blockSize}else s=e.offsetWidth,a=e.offsetHeight;n({width:s,height:a})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var cE="Switch",[ije,Nyt]=os(cE),[oje,sje]=ije(cE),lte=xl.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l="on",onCheckedChange:u,form:c,...d}=e,[h,f]=xl.useState(null),p=qt(t,b=>f(b)),m=xl.useRef(!1),g=h?c||!!h.closest("form"):!0,[y,v]=_a({prop:i,defaultProp:o??!1,onChange:u,caller:cE});return(0,em.jsxs)(oje,{scope:n,checked:y,disabled:a,children:[(0,em.jsx)(ft.button,{type:"button",role:"switch","aria-checked":y,"aria-required":s,"data-state":hte(y),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:p,onClick:xe(e.onClick,b=>{v(w=>!w),g&&(m.current=b.isPropagationStopped(),m.current||b.stopPropagation())})}),g&&(0,em.jsx)(dte,{control:h,bubbles:!m.current,name:r,value:l,checked:y,required:s,disabled:a,form:c,style:{transform:"translateX(-100%)"}})]})});lte.displayName=cE;var ute="SwitchThumb",cte=xl.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=sje(ute,n);return(0,em.jsx)(ft.span,{"data-state":hte(i.checked),"data-disabled":i.disabled?"":void 0,...r,ref:t})});cte.displayName=ute;var aje="SwitchBubbleInput",dte=xl.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},o)=>{let s=xl.useRef(null),a=qt(s,o),l=Yz(n),u=Qz(t);return xl.useEffect(()=>{let c=s.current;if(!c)return;let d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"checked").set;if(l!==n&&h){let f=new Event("click",{bubbles:r});h.call(c,n),c.dispatchEvent(f)}},[l,n,r]),(0,em.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:a,style:{...i.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});dte.displayName=aje;function hte(e){return e?"checked":"unchecked"}var fte=lte,lje=cte,Gz=pte.forwardRef(({className:e,...t},n)=>(0,YP.jsx)(fte,{className:G("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors 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 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:n,children:(0,YP.jsx)(lje,{className:G("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));Gz.displayName=fte.displayName;function Xz(e){let t=e+"CollectionProvider",[n,r]=os(t),[i,o]=n(t,{collectionRef:{current:null},itemMap:new Map}),s=m=>{let{scope:g,children:y}=m,v=Gd.default.useRef(null),b=Gd.default.useRef(new Map).current;return(0,zN.jsx)(i,{scope:g,itemMap:b,collectionRef:v,children:y})};s.displayName=t;let a=e+"CollectionSlot",l=Xp(a),u=Gd.default.forwardRef((m,g)=>{let{scope:y,children:v}=m,b=o(a,y),w=qt(g,b.collectionRef);return(0,zN.jsx)(l,{ref:w,children:v})});u.displayName=a;let c=e+"CollectionItemSlot",d="data-radix-collection-item",h=Xp(c),f=Gd.default.forwardRef((m,g)=>{let{scope:y,children:v,...b}=m,w=Gd.default.useRef(null),x=qt(g,w),S=o(c,y);return Gd.default.useEffect(()=>(S.itemMap.set(w,{ref:w,...b}),()=>{S.itemMap.delete(w)})),(0,zN.jsx)(h,{[d]:"",ref:x,children:v})});f.displayName=c;function p(m){let g=o(e+"CollectionConsumer",m);return Gd.default.useCallback(()=>{let y=g.collectionRef.current;if(!y)return[];let v=Array.from(y.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((b,w)=>v.indexOf(b.ref.current)-v.indexOf(w.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:s,Slot:u,ItemSlot:f},p,r]}var uje=dE.createContext(void 0);function hE(e){let t=dE.useContext(uje);return e||t||"ltr"}var vR="rovingFocusGroup.onEntryFocus",cje={bubbles:!1,cancelable:!0},u1="RovingFocusGroup",[QP,mte,dje]=Xz(u1),[hje,fE]=os(u1,[dje]),[fje,pje]=hje(u1),gte=Ci.forwardRef((e,t)=>(0,bh.jsx)(QP.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,bh.jsx)(QP.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,bh.jsx)(mje,{...e,ref:t})})}));gte.displayName=u1;var mje=Ci.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:o,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,preventScrollOnEntryFocus:c=!1,...d}=e,h=Ci.useRef(null),f=qt(t,h),p=hE(o),[m,g]=_a({prop:s,defaultProp:a??null,onChange:l,caller:u1}),[y,v]=Ci.useState(!1),b=Ea(u),w=mte(n),x=Ci.useRef(!1),[S,k]=Ci.useState(0);return Ci.useEffect(()=>{let C=h.current;if(C)return C.addEventListener(vR,b),()=>C.removeEventListener(vR,b)},[b]),(0,bh.jsx)(fje,{scope:n,orientation:r,dir:p,loop:i,currentTabStopId:m,onItemFocus:Ci.useCallback(C=>g(C),[g]),onItemShiftTab:Ci.useCallback(()=>v(!0),[]),onFocusableItemAdd:Ci.useCallback(()=>k(C=>C+1),[]),onFocusableItemRemove:Ci.useCallback(()=>k(C=>C-1),[]),children:(0,bh.jsx)(ft.div,{tabIndex:y||S===0?-1:0,"data-orientation":r,...d,ref:f,style:{outline:"none",...e.style},onMouseDown:xe(e.onMouseDown,()=>{x.current=!0}),onFocus:xe(e.onFocus,C=>{let N=!x.current;if(C.target===C.currentTarget&&N&&!y){let E=new CustomEvent(vR,cje);if(C.currentTarget.dispatchEvent(E),!E.defaultPrevented){let D=w().filter(R=>R.focusable),q=D.find(R=>R.active),z=D.find(R=>R.id===m),_=[q,z,...D].filter(Boolean).map(R=>R.ref.current);bte(_,c)}}x.current=!1}),onBlur:xe(e.onBlur,()=>v(!1))})})}),yte="RovingFocusGroupItem",vte=Ci.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...a}=e,l=fi(),u=o||l,c=pje(yte,n),d=c.currentTabStopId===u,h=mte(n),{onFocusableItemAdd:f,onFocusableItemRemove:p,currentTabStopId:m}=c;return Ci.useEffect(()=>{if(r)return f(),()=>p()},[r,f,p]),(0,bh.jsx)(QP.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,bh.jsx)(ft.span,{tabIndex:d?0:-1,"data-orientation":c.orientation,...a,ref:t,onMouseDown:xe(e.onMouseDown,g=>{r?c.onItemFocus(u):g.preventDefault()}),onFocus:xe(e.onFocus,()=>c.onItemFocus(u)),onKeyDown:xe(e.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){c.onItemShiftTab();return}if(g.target!==g.currentTarget)return;let y=vje(g,c.orientation,c.dir);if(y!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let v=h().filter(b=>b.focusable).map(b=>b.ref.current);if(y==="last")v.reverse();else if(y==="prev"||y==="next"){y==="prev"&&v.reverse();let b=v.indexOf(g.currentTarget);v=c.loop?bje(v,b+1):v.slice(b+1)}setTimeout(()=>bte(v))}}),children:typeof s=="function"?s({isCurrentTabStop:d,hasTabStop:m!=null}):s})})});vte.displayName=yte;var gje={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function yje(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function vje(e,t,n){let r=yje(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return gje[r]}function bte(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function bje(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var wte=gte,xte=vte,$h="ToggleGroup",[Ste,Ryt]=os($h,[fE]),kte=fE(),Jz=ka.default.forwardRef((e,t)=>{let{type:n,...r}=e;if(n==="single")return(0,To.jsx)(wje,{...r,ref:t});if(n==="multiple")return(0,To.jsx)(xje,{...r,ref:t});throw new Error(`Missing prop \`type\` expected on \`${$h}\``)});Jz.displayName=$h;var[Cte,Nte]=Ste($h),wje=ka.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s,a]=_a({prop:n,defaultProp:r??"",onChange:i,caller:$h});return(0,To.jsx)(Cte,{scope:e.__scopeToggleGroup,type:"single",value:ka.default.useMemo(()=>s?[s]:[],[s]),onItemActivate:a,onItemDeactivate:ka.default.useCallback(()=>a(""),[a]),children:(0,To.jsx)(Mte,{...o,ref:t})})}),xje=ka.default.forwardRef((e,t)=>{let{value:n,defaultValue:r,onValueChange:i=()=>{},...o}=e,[s,a]=_a({prop:n,defaultProp:r??[],onChange:i,caller:$h}),l=ka.default.useCallback(c=>a((d=[])=>[...d,c]),[a]),u=ka.default.useCallback(c=>a((d=[])=>d.filter(h=>h!==c)),[a]);return(0,To.jsx)(Cte,{scope:e.__scopeToggleGroup,type:"multiple",value:s,onItemActivate:l,onItemDeactivate:u,children:(0,To.jsx)(Mte,{...o,ref:t})})});Jz.displayName=$h;var[Sje,kje]=Ste($h),Mte=ka.default.forwardRef((e,t)=>{let{__scopeToggleGroup:n,disabled:r=!1,rovingFocus:i=!0,orientation:o,dir:s,loop:a=!0,...l}=e,u=kte(n),c=hE(s),d={role:"group",dir:c,...l};return(0,To.jsx)(Sje,{scope:n,rovingFocus:i,disabled:r,children:i?(0,To.jsx)(wte,{asChild:!0,...u,orientation:o,dir:c,loop:a,children:(0,To.jsx)(ft.div,{...d,ref:t})}):(0,To.jsx)(ft.div,{...d,ref:t})})}),qM="ToggleGroupItem",_te=ka.default.forwardRef((e,t)=>{let n=Nte(qM,e.__scopeToggleGroup),r=kje(qM,e.__scopeToggleGroup),i=kte(e.__scopeToggleGroup),o=n.value.includes(e.value),s=r.disabled||e.disabled,a={...e,pressed:o,disabled:s},l=ka.default.useRef(null);return r.rovingFocus?(0,To.jsx)(xte,{asChild:!0,...i,focusable:!s,active:o,ref:l,children:(0,To.jsx)(E9,{...a,ref:t})}):(0,To.jsx)(E9,{...a,ref:t})});_te.displayName=qM;var E9=ka.default.forwardRef((e,t)=>{let{__scopeToggleGroup:n,value:r,...i}=e,o=Nte(qM,n),s={role:"radio","aria-checked":e.pressed,"aria-pressed":void 0},a=o.type==="single"?s:void 0;return(0,To.jsx)(Ok,{...a,...i,ref:t,onPressedChange:l=>{l?o.onItemActivate(r):o.onItemDeactivate(r)}})}),Ete=Jz,Ote=_te,O9=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,T9=EZ,pE=(e,t)=>n=>{var r;if(t?.variants==null)return T9(e,n?.class,n?.className);let{variants:i,defaultVariants:o}=t,s=Object.keys(i).map(u=>{let c=n?.[u],d=o?.[u];if(c===null)return null;let h=O9(c)||O9(d);return i[u][h]}),a=n&&Object.entries(n).reduce((u,c)=>{let[d,h]=c;return h===void 0||(u[d]=h),u},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((u,c)=>{let{class:d,className:h,...f}=c;return Object.entries(f).every(p=>{let[m,g]=p;return Array.isArray(g)?g.includes({...o,...a}[m]):{...o,...a}[m]===g})?[...u,d,h]:u},[]);return T9(e,s,l,n?.class,n?.className)},Dte=pE("inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent shadow-sm hover:bg-accent hover:text-accent-foreground"},size:{default:"h-9 min-w-9 px-2",sm:"h-8 min-w-8 px-1.5",lg:"h-10 min-w-10 px-2.5"}},defaultVariants:{variant:"default",size:"default"}}),Cje=Tte.forwardRef(({className:e,variant:t,size:n,...r},i)=>(0,Ate.jsx)(oD,{ref:i,className:G(Dte({variant:t,size:n,className:e})),...r}));Cje.displayName=oD.displayName;var Rte=pm.createContext({size:"default",variant:"default"}),Ite=pm.forwardRef(({className:e,variant:t,size:n,children:r,...i},o)=>(0,zM.jsx)(Ete,{ref:o,className:G("flex items-center justify-center gap-1",e),...i,children:(0,zM.jsx)(Rte.Provider,{value:{variant:t,size:n},children:r})}));Ite.displayName=Ete.displayName;var GP=pm.forwardRef(({className:e,children:t,variant:n,size:r,...i},o)=>{let s=pm.useContext(Rte);return(0,zM.jsx)(Ote,{ref:o,className:G(Dte({variant:s.variant||n,size:s.size||r}),e),...i,children:t})});GP.displayName=Ote.displayName;function Pte(e){let{navigationTableNamesCollection:t}=is(),n=e.schema,r=e.searchTerm.trim(),i=r.toLowerCase(),{data:o=[]}=Xy(s=>{if(!n)return;let a=s.from({table:t}).where(({table:l})=>Qy(l.schema,n));return(i.length===0?a:a.fn.where(({table:l})=>l.table.toLowerCase().includes(i))).orderBy(({table:l})=>l.table).fn.select(l=>l.table)},[t,n,i]);return{tables:o,isSearchActive:r.length>0}}var Lte="navigation:table-search",Bte="navigation:table-grid-focus-request",Nje="studio:command-palette",qte=(0,Qt.createContext)(void 0),zte=(0,Qt.createContext)(void 0);function Mje(e){return e.trim().toLowerCase()}function IC(e){let t=Mje(e.query);return t.length===0?!0:[e.label,...e.keywords??[]].join(" ").toLowerCase().includes(t)}function _je(e,t){return typeof e=="function"?e(t):e}function Eje(e,t){return typeof e=="function"?e(t):!!e}function Oje(e){return e[e.length-1]?.actions??[]}function A9(e){let{children:t,disabled:n=!1,icon:r,keywords:i,label:o,onSelect:s,value:a}=e;return(0,Wt.jsxs)(Kz,{disabled:n,keywords:i,onSelect:s,value:a,className:G("justify-between gap-3",n?"text-muted-foreground/55":"text-foreground hover:bg-secondary/85"),children:[(0,Wt.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5",children:[(0,Wt.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-lg border border-border/70 bg-background text-muted-foreground",children:(0,Wt.jsx)(r,{className:"size-3.5"})}),(0,Wt.jsx)("span",{className:"truncate",children:o})]}),(0,Wt.jsx)("span",{className:"flex shrink-0 items-center",children:t})]})}function Tje(){let e=(0,Qt.useContext)(qte);if(!e)throw new Error("useCommandPaletteContext must be used within StudioCommandPaletteProvider");return e}function Aje(){let e=(0,Qt.useContext)(zte);if(!e)throw new Error("useCommandPaletteStateContext must be used within StudioCommandPaletteProvider");return e}function Dje(e){let{registerContextActions:t,unregisterContextActions:n}=Tje(),r=(0,Qt.useId)();(0,Qt.useEffect)(()=>(t(r,e),()=>{n(r)}),[e,t,r,n])}function Rje(e){let{children:t}=e,[n,r]=En(Nje,{isOpen:!1}),[i,o]=(0,Qt.useState)([]),s=(0,Qt.useMemo)(()=>Oje(i),[i]),a=(0,Qt.useCallback)(h=>{r(f=>({...f,isOpen:h}))},[r]),l=(0,Qt.useCallback)((h,f)=>{o(p=>{let m=p.filter(g=>g.id!==h);return m.push({actions:f,id:h}),m})},[]),u=(0,Qt.useCallback)(h=>{o(f=>f.filter(p=>p.id!==h))},[]),c=(0,Qt.useMemo)(()=>({registerContextActions:l,unregisterContextActions:u}),[l,u]),d=(0,Qt.useMemo)(()=>({isOpen:n.isOpen,setIsOpen:a,viewActions:s}),[n.isOpen,a,s]);return(0,Qt.useEffect)(()=>{function h(f){f.key.toLowerCase()!=="k"||!(f.metaKey||f.ctrlKey)||f.altKey||(f.preventDefault(),a(!0))}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[a]),(0,Wt.jsx)(qte.Provider,{value:c,children:(0,Wt.jsxs)(zte.Provider,{value:d,children:[t,(0,Wt.jsx)(Ije,{})]})})}function Ije(){let{isDarkMode:e,isNavigationOpen:t,setThemeMode:n,themeMode:r,toggleNavigation:i}=is(),{createUrl:o,schemaParam:s}=lo(),{isOpen:a,setIsOpen:l,viewActions:u}=Aje(),[c,d]=(0,Qt.useState)(""),[,h]=En(Lte,{isOpen:!1,term:""}),f=(0,Qt.useRef)(null),p=(0,Qt.useRef)(null),{tables:m}=Pte({schema:s,searchTerm:c}),g=(0,Qt.useMemo)(()=>u.filter(P=>P.shouldShow?.(c)??!0).map(P=>{let F=_je(P.label,c);return{disabled:Eje(P.disabled,c),icon:P.icon,id:P.id,keywords:P.keywords,label:F,onSelect:P.onSelect,section:"context"}}).filter(P=>IC({label:P.label,keywords:P.keywords,query:c})),[c,u]),y=(0,Qt.useMemo)(()=>m.slice(0,3).map(P=>({disabled:!1,icon:Az,id:`table:${P.id}`,keywords:[P.qualifiedName,P.schema,"table"],label:P.table,onSelect:()=>{window.location.hash=o({schemaParam:P.schema,tableParam:P.table,viewParam:"table"})},section:"tables"})),[o,m]),v=Math.max(m.length-y.length,0),b=(0,Qt.useMemo)(()=>v===0?null:{disabled:!1,icon:_h,id:"tables:more",keywords:["filter tables","more tables","browse tables"],label:`${v} more...`,onSelect:P=>{t||i(),h({isOpen:!0,term:P.trim()})},section:"tables"},[t,v,h,i]),w=(0,Qt.useMemo)(()=>b?[...y,b]:y,[b,y]),x=r==="system"?"":r,S=r==="system",k=IC({label:"Match system theme",keywords:["appearance","follow system","match system","system","system theme","theme"],query:c}),C=IC({label:"Studio theme",keywords:["appearance","dark","dark mode","light","light mode","theme"],query:c}),N=k||C,E=(0,Qt.useCallback)(P=>{if(P){n("system");return}n(e?"dark":"light")},[e,n]),D=(0,Qt.useCallback)(P=>{(P==="dark"||P==="light")&&n(P)},[n]),q=(0,Qt.useCallback)(()=>{n(e?"light":"dark")},[e,n]),z=(0,Qt.useMemo)(()=>[{disabled:!1,icon:d5e,id:"view:schema",keywords:["visualizer","schema","diagram"],label:"Visualizer",onSelect:()=>{window.location.hash=o({viewParam:"schema"})},section:"views"},{disabled:!1,icon:zze,id:"view:console",keywords:["console","events","operations"],label:"Console",onSelect:()=>{window.location.hash=o({viewParam:"console"})},section:"views"},{disabled:!1,icon:l5e,id:"view:sql",keywords:["sql","query","editor"],label:"SQL",onSelect:()=>{window.location.hash=o({viewParam:"sql"})},section:"views"}].filter(P=>IC({label:P.label,keywords:P.keywords,query:c})),[o,c]);(0,Qt.useEffect)(()=>{if(!a){d("");return}f.current?.focus(),f.current?.select()},[a]);function _(){l(!1)}function R(P){if(P.disabled)return;let F=c;d(""),_(),Promise.resolve(P.onSelect(F))}function T(P){let{items:F,label:I}=P;return F.length===0?null:(0,Wt.jsx)(KP,{heading:I,children:F.map(V=>{let W=V.icon;return(0,Wt.jsxs)(Kz,{disabled:V.disabled,keywords:V.keywords,onSelect:()=>R(V),value:V.id,className:G(V.disabled?"text-muted-foreground/55":"text-foreground hover:bg-secondary/85"),children:[(0,Wt.jsx)("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-lg border border-border/70 bg-background text-muted-foreground transition-colors group-data-[selected=true]:border-border group-data-[selected=true]:bg-card",children:(0,Wt.jsx)(W,{className:"size-3.5"})}),(0,Wt.jsx)("span",{className:"min-w-0 truncate",children:V.label})]},V.id)})})}function B(){return N?(0,Wt.jsxs)(KP,{heading:"Appearance",children:[k?(0,Wt.jsx)(A9,{icon:m5e,keywords:["appearance","follow system","match system","system","system theme","theme"],label:"Match system theme",onSelect:()=>E(!S),value:"appearance:system-theme",children:(0,Wt.jsx)(Gz,{"aria-label":"Match system theme",checked:S,onClick:P=>{P.stopPropagation()},onCheckedChange:E,onMouseDown:P=>{P.preventDefault(),P.stopPropagation()}})}):null,C?(0,Wt.jsx)(A9,{disabled:S,icon:e?b5e:F5e,keywords:["appearance","dark","dark mode","light","light mode","theme"],label:"Studio theme",onSelect:q,value:"appearance:studio-theme",children:(0,Wt.jsxs)(Ite,{"aria-label":"Studio theme",className:"gap-1 rounded-lg bg-muted/60 p-1",type:"single",value:x,onValueChange:D,children:[(0,Wt.jsx)(GP,{"aria-label":"Light mode",className:"min-w-13 border-0 bg-transparent px-2.5 py-1 text-xs shadow-none hover:bg-background/80 hover:text-foreground data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm",disabled:S,onClick:P=>{P.stopPropagation()},onMouseDown:P=>{P.preventDefault(),P.stopPropagation()},size:"sm",value:"light",variant:"default",children:"Light"}),(0,Wt.jsx)(GP,{"aria-label":"Dark mode",className:"min-w-13 border-0 bg-transparent px-2.5 py-1 text-xs shadow-none hover:bg-background/80 hover:text-foreground data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm",disabled:S,onClick:P=>{P.stopPropagation()},onMouseDown:P=>{P.preventDefault(),P.stopPropagation()},size:"sm",value:"dark",variant:"default",children:"Dark"})]})}):null]}):null}let A=p.current?.closest(".ps"),M=A instanceof HTMLElement?A:typeof document>"u"?null:document.body;return(0,Wt.jsxs)(Wt.Fragment,{children:[(0,Wt.jsx)("span",{ref:p,"aria-hidden":"true",className:"hidden"}),(0,Wt.jsx)(ete,{open:a,onOpenChange:l,children:(0,Wt.jsxs)(Hz,{container:M,className:"w-[min(38rem,calc(100vw-2rem))] max-w-none overflow-hidden rounded-xl border border-border bg-background p-0 font-sans shadow-[0_16px_36px_rgba(15,23,42,0.12)]",onOpenAutoFocus:P=>{P.preventDefault(),f.current?.focus(),f.current?.select()},showCloseButton:!1,children:[(0,Wt.jsx)(nte,{className:"sr-only",children:"Command palette"}),(0,Wt.jsx)(rte,{className:"sr-only",children:"Search commands, tables, and Studio views."}),(0,Wt.jsxs)($z,{className:"font-sans",shouldFilter:!1,children:[(0,Wt.jsx)(ite,{"aria-label":"Search commands",className:"border-0 shadow-none focus-visible:ring-0",onValueChange:d,placeholder:"Search commands",ref:f,value:c}),(0,Wt.jsxs)(ote,{className:"px-1 py-1",children:[T({items:g,label:"Suggested"}),T({items:w,label:"Tables"}),B(),T({items:z,label:"Navigation"}),N?null:(0,Wt.jsx)(ste,{children:"No matching commands."})]})]})]})})]})}var Zz=pE("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background text-foreground shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",xs:"h-6 rounded-md px-2 text-xs",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),zn=Fte.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},o)=>(0,jte.jsx)(r?Hee:"button",{className:G(Zz({variant:t,size:n,className:e})),ref:o,...i}));zn.displayName="Button";function XP(e){let{className:t,compact:n=!1,description:r,isRetrying:i,message:o,onRetry:s,queryPreview:a,source:l,title:u,variant:c="error"}=e;return(0,$o.jsx)("div",{className:G("rounded-md border text-foreground",n?"px-3 py-2 text-xs":"px-4 py-4 text-sm shadow-sm",c==="error"?"border-red-500/30 bg-red-500/10":"border-amber-500/30 bg-amber-500/10",t),children:(0,$o.jsxs)("div",{className:G("gap-3",n?"flex items-start justify-between":"flex flex-col"),children:[(0,$o.jsxs)("div",{className:"min-w-0",children:[(0,$o.jsxs)("div",{className:"flex items-center gap-2 font-medium",children:[(0,$o.jsx)(Tz,{size:14}),(0,$o.jsx)("span",{children:u})]}),(0,$o.jsx)("p",{className:"mt-1 text-foreground/80",children:r}),o?(0,$o.jsx)("p",{className:"mt-2 text-foreground/70",children:o}):null,(0,$o.jsxs)("p",{className:"mt-2 text-foreground/60",children:["Source: ",l]}),a?(0,$o.jsx)("code",{className:G("mt-2 block rounded-sm border border-border/60 bg-background/60 p-2 font-mono text-[11px] text-foreground/70",n?"truncate":"whitespace-pre-wrap break-all"),children:a}):null]}),(0,$o.jsxs)(zn,{className:G(n?"shrink-0":"self-start"),onClick:s,size:"sm",type:"button",variant:"outline",children:[(0,$o.jsx)(Dz,{className:G("mr-1 size-3",i&&"animate-spin")}),"Retry"]})]})})}var Pje='data:image/svg+xml,<svg%0A width="58"%0A height="72"%0A viewBox="0 0 58 72"%0A fill="none"%0A xmlns="http://www.w3.org/2000/svg"%0A>%0A <path%0A fill-rule="evenodd"%0A clip-rule="evenodd"%0A d="M0.522473 45.0933C-0.184191 46.246 -0.173254 47.7004 0.550665 48.8423L13.6534 69.5114C14.5038 70.8529 16.1429 71.4646 17.6642 71.0082L55.4756 59.6648C57.539 59.0457 58.5772 56.7439 57.6753 54.7874L33.3684 2.06007C32.183 -0.511323 28.6095 -0.722394 27.1296 1.69157L0.522473 45.0933ZM32.7225 14.1141C32.2059 12.9187 30.4565 13.1028 30.2001 14.3796L20.842 60.9749C20.6447 61.9574 21.5646 62.7964 22.5248 62.5098L48.6494 54.7114C49.4119 54.4838 49.8047 53.6415 49.4891 52.9111L32.7225 14.1141Z"%0A fill="white"%0A />%0A</svg>%0A',Lje='data:image/svg+xml, <svg width="12" height="14" viewBox="0 0 12 14" fill="none" xmlns="http://www.w3.org/2000/svg">%0A <path%0A fill-rule="evenodd"%0A clip-rule="evenodd"%0A d="M0.396923 8.8719C0.25789 9.09869 0.260041 9.38484 0.402469 9.60951L2.98037 13.6761C3.14768 13.94 3.47018 14.0603 3.76949 13.9705L11.2087 11.7388C11.6147 11.617 11.8189 11.1641 11.6415 10.7792L6.8592 0.405309C6.62598 -0.100601 5.92291 -0.142128 5.63176 0.332808L0.396923 8.8719ZM6.73214 2.77688C6.6305 2.54169 6.2863 2.57792 6.23585 2.82912L4.3947 11.9965C4.35588 12.1898 4.53686 12.3549 4.72578 12.2985L9.86568 10.7642C10.0157 10.7194 10.093 10.5537 10.0309 10.41L6.73214 2.77688Z"%0A fill="currentColor"%0A />%0A </svg>',Fi=Vte.forwardRef(({className:e,type:t,...n},r)=>(0,Wte.jsx)("input",{type:t,className:G("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm leading-5 font-normal text-foreground shadow-sm transition-colors 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-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),ref:r,...n}));Fi.displayName="Input";function D9(e,[t,n]){return Math.min(n,Math.max(t,e))}var Bje=["top","right","bottom","left"],Oh=Math.min,Ts=Math.max,FM=Math.round,PC=Math.floor,fu=e=>({x:e,y:e}),qje={left:"right",right:"left",bottom:"top",top:"bottom"},zje={start:"end",end:"start"};function JP(e,t,n){return Ts(e,Oh(t,n))}function qc(e,t){return typeof e=="function"?e(t):e}function zc(e){return e.split("-")[0]}function Av(e){return e.split("-")[1]}function t5(e){return e==="x"?"y":"x"}function n5(e){return e==="y"?"height":"width"}var Fje=new Set(["top","bottom"]);function lu(e){return Fje.has(zc(e))?"y":"x"}function r5(e){return t5(lu(e))}function jje(e,t,n){n===void 0&&(n=!1);let r=Av(e),i=r5(e),o=n5(i),s=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(s=jM(s)),[s,jM(s)]}function Vje(e){let t=jM(e);return[ZP(e),t,ZP(t)]}function ZP(e){return e.replace(/start|end/g,t=>zje[t])}var R9=["left","right"],I9=["right","left"],Wje=["top","bottom"],Uje=["bottom","top"];function Hje(e,t,n){switch(e){case"top":case"bottom":return n?t?I9:R9:t?R9:I9;case"left":case"right":return t?Wje:Uje;default:return[]}}function $je(e,t,n,r){let i=Av(e),o=Hje(zc(e),n==="start",r);return i&&(o=o.map(s=>s+"-"+i),t&&(o=o.concat(o.map(ZP)))),o}function jM(e){return e.replace(/left|right|bottom|top/g,t=>qje[t])}function Kje(e){return{top:0,right:0,bottom:0,left:0,...e}}function Ute(e){return typeof e!="number"?Kje(e):{top:e,right:e,bottom:e,left:e}}function VM(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function P9(e,t,n){let{reference:r,floating:i}=e,o=lu(t),s=r5(t),a=n5(s),l=zc(t),u=o==="y",c=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2,f;switch(l){case"top":f={x:c,y:r.y-i.height};break;case"bottom":f={x:c,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-i.width,y:d};break;default:f={x:r.x,y:r.y}}switch(Av(t)){case"start":f[s]-=h*(n&&u?-1:1);break;case"end":f[s]+=h*(n&&u?-1:1);break}return f}async function Yje(e,t){var n;t===void 0&&(t={});let{x:r,y:i,platform:o,rects:s,elements:a,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=qc(t,e),p=Ute(f),m=a[h?d==="floating"?"reference":"floating":d],g=VM(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(m)))==null||n?m:m.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(a.floating)),boundary:u,rootBoundary:c,strategy:l})),y=d==="floating"?{x:r,y:i,width:s.floating.width,height:s.floating.height}:s.reference,v=await(o.getOffsetParent==null?void 0:o.getOffsetParent(a.floating)),b=await(o.isElement==null?void 0:o.isElement(v))?await(o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},w=VM(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:y,offsetParent:v,strategy:l}):y);return{top:(g.top-w.top+p.top)/b.y,bottom:(w.bottom-g.bottom+p.bottom)/b.y,left:(g.left-w.left+p.left)/b.x,right:(w.right-g.right+p.right)/b.x}}var Qje=async(e,t,n)=>{let{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:s}=n,a=o.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(t)),u=await s.getElementRects({reference:e,floating:t,strategy:i}),{x:c,y:d}=P9(u,r,l),h=r,f={},p=0;for(let g=0;g<a.length;g++){var m;let{name:y,fn:v}=a[g],{x:b,y:w,data:x,reset:S}=await v({x:c,y:d,initialPlacement:r,placement:h,strategy:i,middlewareData:f,rects:u,platform:{...s,detectOverflow:(m=s.detectOverflow)!=null?m:Yje},elements:{reference:e,floating:t}});c=b??c,d=w??d,f={...f,[y]:{...f[y],...x}},S&&p<=50&&(p++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(u=S.rects===!0?await s.getElementRects({reference:e,floating:t,strategy:i}):S.rects),{x:c,y:d}=P9(u,h,l)),g=-1)}return{x:c,y:d,placement:h,strategy:i,middlewareData:f}},Gje=e=>({name:"arrow",options:e,async fn(t){let{x:n,y:r,placement:i,rects:o,platform:s,elements:a,middlewareData:l}=t,{element:u,padding:c=0}=qc(e,t)||{};if(u==null)return{};let d=Ute(c),h={x:n,y:r},f=r5(i),p=n5(f),m=await s.getDimensions(u),g=f==="y",y=g?"top":"left",v=g?"bottom":"right",b=g?"clientHeight":"clientWidth",w=o.reference[p]+o.reference[f]-h[f]-o.floating[p],x=h[f]-o.reference[f],S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(u)),k=S?S[b]:0;(!k||!await(s.isElement==null?void 0:s.isElement(S)))&&(k=a.floating[b]||o.floating[p]);let C=w/2-x/2,N=k/2-m[p]/2-1,E=Oh(d[y],N),D=Oh(d[v],N),q=E,z=k-m[p]-D,_=k/2-m[p]/2+C,R=JP(q,_,z),T=!l.arrow&&Av(i)!=null&&_!==R&&o.reference[p]/2-(_<q?E:D)-m[p]/2<0,B=T?_<q?_-q:_-z:0;return{[f]:h[f]+B,data:{[f]:R,centerOffset:_-R-B,...T&&{alignmentOffset:B}},reset:T}}}),Xje=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;let{placement:i,middlewareData:o,rects:s,initialPlacement:a,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=qc(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};let y=zc(i),v=lu(a),b=zc(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(u.floating)),x=h||(b||!m?[jM(a)]:Vje(a)),S=p!=="none";!h&&S&&x.push(...$je(a,m,p,w));let k=[a,...x],C=await l.detectOverflow(t,g),N=[],E=((r=o.flip)==null?void 0:r.overflows)||[];if(c&&N.push(C[y]),d){let _=jje(i,s,w);N.push(C[_[0]],C[_[1]])}if(E=[...E,{placement:i,overflows:N}],!N.every(_=>_<=0)){var D,q;let _=(((D=o.flip)==null?void 0:D.index)||0)+1,R=k[_];if(R&&(!(d==="alignment"&&v!==lu(R))||E.every(B=>lu(B.placement)===v?B.overflows[0]>0:!0)))return{data:{index:_,overflows:E},reset:{placement:R}};let T=(q=E.filter(B=>B.overflows[0]<=0).sort((B,A)=>B.overflows[1]-A.overflows[1])[0])==null?void 0:q.placement;if(!T)switch(f){case"bestFit":{var z;let B=(z=E.filter(A=>{if(S){let M=lu(A.placement);return M===v||M==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(M=>M>0).reduce((M,P)=>M+P,0)]).sort((A,M)=>A[1]-M[1])[0])==null?void 0:z[0];B&&(T=B);break}case"initialPlacement":T=a;break}if(i!==T)return{reset:{placement:T}}}return{}}}};function L9(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function B9(e){return Bje.some(t=>e[t]>=0)}var Jje=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i="referenceHidden",...o}=qc(e,t);switch(i){case"referenceHidden":{let s=await r.detectOverflow(t,{...o,elementContext:"reference"}),a=L9(s,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:B9(a)}}}case"escaped":{let s=await r.detectOverflow(t,{...o,altBoundary:!0}),a=L9(s,n.floating);return{data:{escapedOffsets:a,escaped:B9(a)}}}default:return{}}}}},Hte=new Set(["left","top"]);async function Zje(e,t){let{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),s=zc(n),a=Av(n),l=lu(n)==="y",u=Hte.has(s)?-1:1,c=o&&l?-1:1,d=qc(t,e),{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof p=="number"&&(f=a==="end"?p*-1:p),l?{x:f*c,y:h*u}:{x:h*u,y:f*c}}var eVe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;let{x:i,y:o,placement:s,middlewareData:a}=t,l=await Zje(t,e);return s===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:o+l.y,data:{...l,placement:s}}}}},tVe=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){let{x:n,y:r,placement:i,platform:o}=t,{mainAxis:s=!0,crossAxis:a=!1,limiter:l={fn:y=>{let{x:v,y:b}=y;return{x:v,y:b}}},...u}=qc(e,t),c={x:n,y:r},d=await o.detectOverflow(t,u),h=lu(zc(i)),f=t5(h),p=c[f],m=c[h];if(s){let y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",b=p+d[y],w=p-d[v];p=JP(b,p,w)}if(a){let y=h==="y"?"top":"left",v=h==="y"?"bottom":"right",b=m+d[y],w=m-d[v];m=JP(b,m,w)}let g=l.fn({...t,[f]:p,[h]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[f]:s,[h]:a}}}}}},nVe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:o,middlewareData:s}=t,{offset:a=0,mainAxis:l=!0,crossAxis:u=!0}=qc(e,t),c={x:n,y:r},d=lu(i),h=t5(d),f=c[h],p=c[d],m=qc(a,t),g=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){let b=h==="y"?"height":"width",w=o.reference[h]-o.floating[b]+g.mainAxis,x=o.reference[h]+o.reference[b]-g.mainAxis;f<w?f=w:f>x&&(f=x)}if(u){var y,v;let b=h==="y"?"width":"height",w=Hte.has(zc(i)),x=o.reference[d]-o.floating[b]+(w&&((y=s.offset)==null?void 0:y[d])||0)+(w?0:g.crossAxis),S=o.reference[d]+o.reference[b]+(w?0:((v=s.offset)==null?void 0:v[d])||0)-(w?g.crossAxis:0);p<x?p=x:p>S&&(p=S)}return{[h]:f,[d]:p}}}},rVe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;let{placement:i,rects:o,platform:s,elements:a}=t,{apply:l=()=>{},...u}=qc(e,t),c=await s.detectOverflow(t,u),d=zc(i),h=Av(i),f=lu(i)==="y",{width:p,height:m}=o.floating,g,y;d==="top"||d==="bottom"?(g=d,y=h===(await(s.isRTL==null?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(y=d,g=h==="end"?"top":"bottom");let v=m-c.top-c.bottom,b=p-c.left-c.right,w=Oh(m-c[g],v),x=Oh(p-c[y],b),S=!t.middlewareData.shift,k=w,C=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(C=b),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=v),S&&!h){let E=Ts(c.left,0),D=Ts(c.right,0),q=Ts(c.top,0),z=Ts(c.bottom,0);f?C=p-2*(E!==0||D!==0?E+D:Ts(c.left,c.right)):k=m-2*(q!==0||z!==0?q+z:Ts(c.top,c.bottom))}await l({...t,availableWidth:C,availableHeight:k});let N=await s.getDimensions(a.floating);return p!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function mE(){return typeof window<"u"}function Dv(e){return $te(e)?(e.nodeName||"").toLowerCase():"#document"}function Ps(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function _u(e){var t;return(t=($te(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $te(e){return mE()?e instanceof Node||e instanceof Ps(e).Node:!1}function fl(e){return mE()?e instanceof Element||e instanceof Ps(e).Element:!1}function wu(e){return mE()?e instanceof HTMLElement||e instanceof Ps(e).HTMLElement:!1}function q9(e){return!mE()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ps(e).ShadowRoot}var iVe=new Set(["inline","contents"]);function c1(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=pl(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&!iVe.has(i)}var oVe=new Set(["table","td","th"]);function sVe(e){return oVe.has(Dv(e))}var aVe=[":popover-open",":modal"];function gE(e){return aVe.some(t=>{try{return e.matches(t)}catch{return!1}})}var lVe=["transform","translate","scale","rotate","perspective"],uVe=["transform","translate","scale","rotate","perspective","filter"],cVe=["paint","layout","strict","content"];function i5(e){let t=o5(),n=fl(e)?pl(e):e;return lVe.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!t&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!t&&(n.filter?n.filter!=="none":!1)||uVe.some(r=>(n.willChange||"").includes(r))||cVe.some(r=>(n.contain||"").includes(r))}function dVe(e){let t=Th(e);for(;wu(t)&&!Zy(t);){if(i5(t))return t;if(gE(t))return null;t=Th(t)}return null}function o5(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}var hVe=new Set(["html","body","#document"]);function Zy(e){return hVe.has(Dv(e))}function pl(e){return Ps(e).getComputedStyle(e)}function yE(e){return fl(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Th(e){if(Dv(e)==="html")return e;let t=e.assignedSlot||e.parentNode||q9(e)&&e.host||_u(e);return q9(t)?t.host:t}function Kte(e){let t=Th(e);return Zy(t)?e.ownerDocument?e.ownerDocument.body:e.body:wu(t)&&c1(t)?t:Kte(t)}function gx(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);let i=Kte(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),s=Ps(i);if(o){let a=eL(s);return t.concat(s,s.visualViewport||[],c1(i)?i:[],a&&n?gx(a):[])}return t.concat(i,gx(i,[],n))}function eL(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yte(e){let t=pl(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=wu(e),o=i?e.offsetWidth:n,s=i?e.offsetHeight:r,a=FM(n)!==o||FM(r)!==s;return a&&(n=o,r=s),{width:n,height:r,$:a}}function s5(e){return fl(e)?e:e.contextElement}function Ty(e){let t=s5(e);if(!wu(t))return fu(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:o}=Yte(t),s=(o?FM(n.width):n.width)/r,a=(o?FM(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!a||!Number.isFinite(a))&&(a=1),{x:s,y:a}}var fVe=fu(0);function Qte(e){let t=Ps(e);return!o5()||!t.visualViewport?fVe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function pVe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Ps(e)?!1:t}function tm(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),o=s5(e),s=fu(1);t&&(r?fl(r)&&(s=Ty(r)):s=Ty(e));let a=pVe(o,n,r)?Qte(o):fu(0),l=(i.left+a.x)/s.x,u=(i.top+a.y)/s.y,c=i.width/s.x,d=i.height/s.y;if(o){let h=Ps(o),f=r&&fl(r)?Ps(r):r,p=h,m=eL(p);for(;m&&r&&f!==p;){let g=Ty(m),y=m.getBoundingClientRect(),v=pl(m),b=y.left+(m.clientLeft+parseFloat(v.paddingLeft))*g.x,w=y.top+(m.clientTop+parseFloat(v.paddingTop))*g.y;l*=g.x,u*=g.y,c*=g.x,d*=g.y,l+=b,u+=w,p=Ps(m),m=eL(p)}}return VM({width:c,height:d,x:l,y:u})}function vE(e,t){let n=yE(e).scrollLeft;return t?t.left+n:tm(_u(e)).left+n}function Gte(e,t){let n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-vE(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function mVe(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,o=i==="fixed",s=_u(r),a=t?gE(t.floating):!1;if(r===s||a&&o)return n;let l={scrollLeft:0,scrollTop:0},u=fu(1),c=fu(0),d=wu(r);if((d||!d&&!o)&&((Dv(r)!=="body"||c1(s))&&(l=yE(r)),wu(r))){let f=tm(r);u=Ty(r),c.x=f.x+r.clientLeft,c.y=f.y+r.clientTop}let h=s&&!d&&!o?Gte(s,l):fu(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-l.scrollLeft*u.x+c.x+h.x,y:n.y*u.y-l.scrollTop*u.y+c.y+h.y}}function gVe(e){return Array.from(e.getClientRects())}function yVe(e){let t=_u(e),n=yE(e),r=e.ownerDocument.body,i=Ts(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ts(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),s=-n.scrollLeft+vE(e),a=-n.scrollTop;return pl(r).direction==="rtl"&&(s+=Ts(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:s,y:a}}var z9=25;function vVe(e,t){let n=Ps(e),r=_u(e),i=n.visualViewport,o=r.clientWidth,s=r.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;let c=o5();(!c||c&&t==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}let u=vE(r);if(u<=0){let c=r.ownerDocument,d=c.body,h=getComputedStyle(d),f=c.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-f);p<=z9&&(o-=p)}else u<=z9&&(o+=u);return{width:o,height:s,x:a,y:l}}var bVe=new Set(["absolute","fixed"]);function wVe(e,t){let n=tm(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=wu(e)?Ty(e):fu(1),s=e.clientWidth*o.x,a=e.clientHeight*o.y,l=i*o.x,u=r*o.y;return{width:s,height:a,x:l,y:u}}function F9(e,t,n){let r;if(t==="viewport")r=vVe(e,n);else if(t==="document")r=yVe(_u(e));else if(fl(t))r=wVe(t,n);else{let i=Qte(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return VM(r)}function Xte(e,t){let n=Th(e);return n===t||!fl(n)||Zy(n)?!1:pl(n).position==="fixed"||Xte(n,t)}function xVe(e,t){let n=t.get(e);if(n)return n;let r=gx(e,[],!1).filter(a=>fl(a)&&Dv(a)!=="body"),i=null,o=pl(e).position==="fixed",s=o?Th(e):e;for(;fl(s)&&!Zy(s);){let a=pl(s),l=i5(s);!l&&a.position==="fixed"&&(i=null),(o?!l&&!i:!l&&a.position==="static"&&i&&bVe.has(i.position)||c1(s)&&!l&&Xte(e,s))?r=r.filter(u=>u!==s):i=a,s=Th(s)}return t.set(e,r),r}function SVe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,o=[...n==="clippingAncestors"?gE(t)?[]:xVe(t,this._c):[].concat(n),r],s=o[0],a=o.reduce((l,u)=>{let c=F9(t,u,i);return l.top=Ts(c.top,l.top),l.right=Oh(c.right,l.right),l.bottom=Oh(c.bottom,l.bottom),l.left=Ts(c.left,l.left),l},F9(t,s,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function kVe(e){let{width:t,height:n}=Yte(e);return{width:t,height:n}}function CVe(e,t,n){let r=wu(t),i=_u(t),o=n==="fixed",s=tm(e,!0,o,t),a={scrollLeft:0,scrollTop:0},l=fu(0);function u(){l.x=vE(i)}if(r||!r&&!o)if((Dv(t)!=="body"||c1(i))&&(a=yE(t)),r){let f=tm(t,!0,o,t);l.x=f.x+t.clientLeft,l.y=f.y+t.clientTop}else i&&u();o&&!r&&i&&u();let c=i&&!r&&!o?Gte(i,a):fu(0),d=s.left+a.scrollLeft-l.x-c.x,h=s.top+a.scrollTop-l.y-c.y;return{x:d,y:h,width:s.width,height:s.height}}function bR(e){return pl(e).position==="static"}function j9(e,t){if(!wu(e)||pl(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return _u(e)===n&&(n=n.ownerDocument.body),n}function Jte(e,t){let n=Ps(e);if(gE(e))return n;if(!wu(e)){let i=Th(e);for(;i&&!Zy(i);){if(fl(i)&&!bR(i))return i;i=Th(i)}return n}let r=j9(e,t);for(;r&&sVe(r)&&bR(r);)r=j9(r,t);return r&&Zy(r)&&bR(r)&&!i5(r)?n:r||dVe(e)||n}var NVe=async function(e){let t=this.getOffsetParent||Jte,n=this.getDimensions,r=await n(e.floating);return{reference:CVe(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function MVe(e){return pl(e).direction==="rtl"}var _Ve={convertOffsetParentRelativeRectToViewportRelativeRect:mVe,getDocumentElement:_u,getClippingRect:SVe,getOffsetParent:Jte,getElementRects:NVe,getClientRects:gVe,getDimensions:kVe,getScale:Ty,isElement:fl,isRTL:MVe};function Zte(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function EVe(e,t){let n=null,r,i=_u(e);function o(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function s(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),o();let u=e.getBoundingClientRect(),{left:c,top:d,width:h,height:f}=u;if(a||t(),!h||!f)return;let p=PC(d),m=PC(i.clientWidth-(c+h)),g=PC(i.clientHeight-(d+f)),y=PC(c),v={rootMargin:-p+"px "+-m+"px "+-g+"px "+-y+"px",threshold:Ts(0,Oh(1,l))||1},b=!0;function w(x){let S=x[0].intersectionRatio;if(S!==l){if(!b)return s();S?s(!1,S):r=setTimeout(()=>{s(!1,1e-7)},1e3)}S===1&&!Zte(u,e.getBoundingClientRect())&&s(),b=!1}try{n=new IntersectionObserver(w,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(w,v)}n.observe(e)}return s(!0),o}function OVe(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,u=s5(e),c=i||o?[...u?gx(u):[],...gx(t)]:[];c.forEach(y=>{i&&y.addEventListener("scroll",n,{passive:!0}),o&&y.addEventListener("resize",n)});let d=u&&a?EVe(u,n):null,h=-1,f=null;s&&(f=new ResizeObserver(y=>{let[v]=y;v&&v.target===u&&f&&(f.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var b;(b=f)==null||b.observe(t)})),n()}),u&&!l&&f.observe(u),f.observe(t));let p,m=l?tm(e):null;l&&g();function g(){let y=tm(e);m&&!Zte(m,y)&&n(),m=y,p=requestAnimationFrame(g)}return n(),()=>{var y;c.forEach(v=>{i&&v.removeEventListener("scroll",n),o&&v.removeEventListener("resize",n)}),d?.(),(y=f)==null||y.disconnect(),f=null,l&&cancelAnimationFrame(p)}}var TVe=eVe,AVe=tVe,DVe=Xje,RVe=rVe,IVe=Jje,V9=Gje,PVe=nVe,LVe=(e,t,n)=>{let r=new Map,i={platform:_Ve,...n},o={...i.platform,_c:r};return Qje(e,t,{...i,platform:o})},BVe=typeof document<"u",qVe=function(){},FN=BVe?ene.useLayoutEffect:qVe;function WM(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!WM(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!WM(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function nne(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function W9(e,t){let n=nne(e);return Math.round(t*n)/n}function wR(e){let t=$r.useRef(e);return FN(()=>{t.current=e}),t}function zVe(e){e===void 0&&(e={});let{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:s}={},transform:a=!0,whileElementsMounted:l,open:u}=e,[c,d]=$r.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,f]=$r.useState(r);WM(h,r)||f(r);let[p,m]=$r.useState(null),[g,y]=$r.useState(null),v=$r.useCallback(A=>{A!==S.current&&(S.current=A,m(A))},[]),b=$r.useCallback(A=>{A!==k.current&&(k.current=A,y(A))},[]),w=o||p,x=s||g,S=$r.useRef(null),k=$r.useRef(null),C=$r.useRef(c),N=l!=null,E=wR(l),D=wR(i),q=wR(u),z=$r.useCallback(()=>{if(!S.current||!k.current)return;let A={placement:t,strategy:n,middleware:h};D.current&&(A.platform=D.current),LVe(S.current,k.current,A).then(M=>{let P={...M,isPositioned:q.current!==!1};_.current&&!WM(C.current,P)&&(C.current=P,tne.flushSync(()=>{d(P)}))})},[h,t,n,D,q]);FN(()=>{u===!1&&C.current.isPositioned&&(C.current.isPositioned=!1,d(A=>({...A,isPositioned:!1})))},[u]);let _=$r.useRef(!1);FN(()=>(_.current=!0,()=>{_.current=!1}),[]),FN(()=>{if(w&&(S.current=w),x&&(k.current=x),w&&x){if(E.current)return E.current(w,x,z);z()}},[w,x,z,E,N]);let R=$r.useMemo(()=>({reference:S,floating:k,setReference:v,setFloating:b}),[v,b]),T=$r.useMemo(()=>({reference:w,floating:x}),[w,x]),B=$r.useMemo(()=>{let A={position:n,left:0,top:0};if(!T.floating)return A;let M=W9(T.floating,c.x),P=W9(T.floating,c.y);return a?{...A,transform:"translate("+M+"px, "+P+"px)",...nne(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:M,top:P}},[n,a,T.floating,c.x,c.y]);return $r.useMemo(()=>({...c,update:z,refs:R,elements:T,floatingStyles:B}),[c,z,R,T,B])}var FVe=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){let{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?V9({element:r.current,padding:i}).fn(n):{}:r?V9({element:r,padding:i}).fn(n):{}}}},jVe=(e,t)=>({...TVe(e),options:[e,t]}),VVe=(e,t)=>({...AVe(e),options:[e,t]}),WVe=(e,t)=>({...PVe(e),options:[e,t]}),UVe=(e,t)=>({...DVe(e),options:[e,t]}),HVe=(e,t)=>({...RVe(e),options:[e,t]}),$Ve=(e,t)=>({...IVe(e),options:[e,t]}),KVe=(e,t)=>({...FVe(e),options:[e,t]}),YVe="Arrow",ine=rne.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...o}=e;return(0,tL.jsx)(ft.svg,{...o,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:(0,tL.jsx)("polygon",{points:"0,0 30,0 15,10"})})});ine.displayName=YVe;var QVe=ine,a5="Popper",[one,Kh]=os(a5),[GVe,sne]=one(a5),ane=e=>{let{__scopePopper:t,children:n}=e,[r,i]=es.useState(null);return(0,wh.jsx)(GVe,{scope:t,anchor:r,onAnchorChange:i,children:n})};ane.displayName=a5;var lne="PopperAnchor",une=es.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,o=sne(lne,n),s=es.useRef(null),a=qt(t,s),l=es.useRef(null);return es.useEffect(()=>{let u=l.current;l.current=r?.current||s.current,u!==l.current&&o.onAnchorChange(l.current)}),r?null:(0,wh.jsx)(ft.div,{...i,ref:a})});une.displayName=lne;var l5="PopperContent",[XVe,JVe]=one(l5),cne=es.forwardRef((e,t)=>{let{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:o="center",alignOffset:s=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:f="optimized",onPlaced:p,...m}=e,g=sne(l5,n),[y,v]=es.useState(null),b=qt(t,$=>v($)),[w,x]=es.useState(null),S=Qz(w),k=S?.width??0,C=S?.height??0,N=r+(o!=="center"?"-"+o:""),E=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},D=Array.isArray(u)?u:[u],q=D.length>0,z={padding:E,boundary:D.filter(e4e),altBoundary:q},{refs:_,floatingStyles:R,placement:T,isPositioned:B,middlewareData:A}=zVe({strategy:"fixed",placement:N,whileElementsMounted:(...$)=>OVe(...$,{animationFrame:f==="always"}),elements:{reference:g.anchor},middleware:[jVe({mainAxis:i+C,alignmentAxis:s}),l&&VVe({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?WVe():void 0,...z}),l&&UVe({...z}),HVe({...z,apply:({elements:$,rects:K,availableWidth:Q,availableHeight:J})=>{let{width:oe,height:be}=K.reference,Me=$.floating.style;Me.setProperty("--radix-popper-available-width",`${Q}px`),Me.setProperty("--radix-popper-available-height",`${J}px`),Me.setProperty("--radix-popper-anchor-width",`${oe}px`),Me.setProperty("--radix-popper-anchor-height",`${be}px`)}}),w&&KVe({element:w,padding:a}),t4e({arrowWidth:k,arrowHeight:C}),h&&$Ve({strategy:"referenceHidden",...z})]}),[M,P]=fne(T),F=Ea(p);ao(()=>{B&&F?.()},[B,F]);let I=A.arrow?.x,V=A.arrow?.y,W=A.arrow?.centerOffset!==0,[j,X]=es.useState();return ao(()=>{y&&X(window.getComputedStyle(y).zIndex)},[y]),(0,wh.jsx)("div",{ref:_.setFloating,"data-radix-popper-content-wrapper":"",style:{...R,transform:B?R.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:j,"--radix-popper-transform-origin":[A.transformOrigin?.x,A.transformOrigin?.y].join(" "),...A.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:(0,wh.jsx)(XVe,{scope:n,placedSide:M,onArrowChange:x,arrowX:I,arrowY:V,shouldHideArrow:W,children:(0,wh.jsx)(ft.div,{"data-side":M,"data-align":P,...m,ref:b,style:{...m.style,animation:B?void 0:"none"}})})})});cne.displayName=l5;var dne="PopperArrow",ZVe={top:"bottom",right:"left",bottom:"top",left:"right"},hne=es.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=JVe(dne,n),o=ZVe[i.placedSide];return(0,wh.jsx)("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:(0,wh.jsx)(QVe,{...r,ref:t,style:{...r.style,display:"block"}})})});hne.displayName=dne;function e4e(e){return e!==null}var t4e=e=>({name:"transformOrigin",options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,o=i.arrow?.centerOffset!==0,s=o?0:e.arrowWidth,a=o?0:e.arrowHeight,[l,u]=fne(n),c={start:"0%",center:"50%",end:"100%"}[u],d=(i.arrow?.x??0)+s/2,h=(i.arrow?.y??0)+a/2,f="",p="";return l==="bottom"?(f=o?c:`${d}px`,p=`${-a}px`):l==="top"?(f=o?c:`${d}px`,p=`${r.floating.height+a}px`):l==="right"?(f=`${-a}px`,p=o?c:`${h}px`):l==="left"&&(f=`${r.floating.width+a}px`,p=o?c:`${h}px`),{data:{x:f,y:p}}}});function fne(e){let[t,n="center"]=e.split("-");return[t,n]}var d1=ane,h1=une,bE=cne,wE=hne,gne=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"}),n4e="VisuallyHidden",yne=pne.forwardRef((e,t)=>(0,mne.jsx)(ft.span,{...e,ref:t,style:{...gne,...e.style}}));yne.displayName=n4e;var r4e=yne,i4e=[" ","Enter","ArrowUp","ArrowDown"],o4e=[" ","Enter"],nm="Select",[xE,SE,s4e]=Xz(nm),[Rv,Iyt]=os(nm,[s4e,Kh]),kE=Kh(),[a4e,Yh]=Rv(nm),[l4e,u4e]=Rv(nm),vne=e=>{let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:o,value:s,defaultValue:a,onValueChange:l,dir:u,name:c,autoComplete:d,disabled:h,required:f,form:p}=e,m=kE(t),[g,y]=Se.useState(null),[v,b]=Se.useState(null),[w,x]=Se.useState(!1),S=hE(u),[k,C]=_a({prop:r,defaultProp:i??!1,onChange:o,caller:nm}),[N,E]=_a({prop:s,defaultProp:a,onChange:l,caller:nm}),D=Se.useRef(null),q=g?p||!!g.closest("form"):!0,[z,_]=Se.useState(new Set),R=Array.from(z).map(T=>T.props.value).join(";");return(0,Ze.jsx)(d1,{...m,children:(0,Ze.jsxs)(a4e,{required:f,scope:t,trigger:g,onTriggerChange:y,valueNode:v,onValueNodeChange:b,valueNodeHasChildren:w,onValueNodeHasChildrenChange:x,contentId:fi(),value:N,onValueChange:E,open:k,onOpenChange:C,dir:S,triggerPointerDownPosRef:D,disabled:h,children:[(0,Ze.jsx)(xE.Provider,{scope:t,children:(0,Ze.jsx)(l4e,{scope:e.__scopeSelect,onNativeOptionAdd:Se.useCallback(T=>{_(B=>new Set(B).add(T))},[]),onNativeOptionRemove:Se.useCallback(T=>{_(B=>{let A=new Set(B);return A.delete(T),A})},[]),children:n})}),q?(0,Ze.jsxs)(Vne,{"aria-hidden":!0,required:f,tabIndex:-1,name:c,autoComplete:d,value:N,onChange:T=>E(T.target.value),disabled:h,form:p,children:[N===void 0?(0,Ze.jsx)("option",{value:""}):null,Array.from(z)]},R):null]})})};vne.displayName=nm;var bne="SelectTrigger",wne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,disabled:r=!1,...i}=e,o=kE(n),s=Yh(bne,n),a=s.disabled||r,l=qt(t,s.onTriggerChange),u=SE(n),c=Se.useRef("touch"),[d,h,f]=Une(m=>{let g=u().filter(b=>!b.disabled),y=g.find(b=>b.value===s.value),v=Hne(g,m,y);v!==void 0&&s.onValueChange(v.value)}),p=m=>{a||(s.onOpenChange(!0),f()),m&&(s.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return(0,Ze.jsx)(h1,{asChild:!0,...o,children:(0,Ze.jsx)(ft.button,{type:"button",role:"combobox","aria-controls":s.contentId,"aria-expanded":s.open,"aria-required":s.required,"aria-autocomplete":"none",dir:s.dir,"data-state":s.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":Wne(s.value)?"":void 0,...i,ref:l,onClick:xe(i.onClick,m=>{m.currentTarget.focus(),c.current!=="mouse"&&p(m)}),onPointerDown:xe(i.onPointerDown,m=>{c.current=m.pointerType;let g=m.target;g.hasPointerCapture(m.pointerId)&&g.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(p(m),m.preventDefault())}),onKeyDown:xe(i.onKeyDown,m=>{let g=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&h(m.key),!(g&&m.key===" ")&&i4e.includes(m.key)&&(p(),m.preventDefault())})})})});wne.displayName=bne;var xne="SelectValue",Sne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,children:o,placeholder:s="",...a}=e,l=Yh(xne,n),{onValueNodeHasChildrenChange:u}=l,c=o!==void 0,d=qt(t,l.onValueNodeChange);return ao(()=>{u(c)},[u,c]),(0,Ze.jsx)(ft.span,{...a,ref:d,style:{pointerEvents:"none"},children:Wne(l.value)?(0,Ze.jsx)(Ze.Fragment,{children:s}):o})});Sne.displayName=xne;var c4e="SelectIcon",kne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,children:r,...i}=e;return(0,Ze.jsx)(ft.span,{"aria-hidden":!0,...i,ref:t,children:r||"\u25BC"})});kne.displayName=c4e;var d4e="SelectPortal",Cne=e=>(0,Ze.jsx)(Ov,{asChild:!0,...e});Cne.displayName=d4e;var rm="SelectContent",Nne=Se.forwardRef((e,t)=>{let n=Yh(rm,e.__scopeSelect),[r,i]=Se.useState();if(ao(()=>{i(new DocumentFragment)},[]),!n.open){let o=r;return o?e5.createPortal((0,Ze.jsx)(Mne,{scope:e.__scopeSelect,children:(0,Ze.jsx)(xE.Slot,{scope:e.__scopeSelect,children:(0,Ze.jsx)("div",{children:e.children})})}),o):null}return(0,Ze.jsx)(_ne,{...e,ref:t})});Nne.displayName=rm;var tl=10,[Mne,Qh]=Rv(rm),h4e="SelectContentImpl",f4e=Xp("SelectContent.RemoveScroll"),_ne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:s,side:a,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:h,collisionPadding:f,sticky:p,hideWhenDetached:m,avoidCollisions:g,...y}=e,v=Yh(rm,n),[b,w]=Se.useState(null),[x,S]=Se.useState(null),k=qt(t,$=>w($)),[C,N]=Se.useState(null),[E,D]=Se.useState(null),q=SE(n),[z,_]=Se.useState(!1),R=Se.useRef(!1);Se.useEffect(()=>{if(b)return iE(b)},[b]),Z_();let T=Se.useCallback($=>{let[K,...Q]=q().map(be=>be.ref.current),[J]=Q.slice(-1),oe=document.activeElement;for(let be of $)if(be===oe||(be?.scrollIntoView({block:"nearest"}),be===K&&x&&(x.scrollTop=0),be===J&&x&&(x.scrollTop=x.scrollHeight),be?.focus(),document.activeElement!==oe))return},[q,x]),B=Se.useCallback(()=>T([C,b]),[T,C,b]);Se.useEffect(()=>{z&&B()},[z,B]);let{onOpenChange:A,triggerPointerDownPosRef:M}=v;Se.useEffect(()=>{if(b){let $={x:0,y:0},K=J=>{$={x:Math.abs(Math.round(J.pageX)-(M.current?.x??0)),y:Math.abs(Math.round(J.pageY)-(M.current?.y??0))}},Q=J=>{$.x<=10&&$.y<=10?J.preventDefault():b.contains(J.target)||A(!1),document.removeEventListener("pointermove",K),M.current=null};return M.current!==null&&(document.addEventListener("pointermove",K),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",K),document.removeEventListener("pointerup",Q,{capture:!0})}}},[b,A,M]),Se.useEffect(()=>{let $=()=>A(!1);return window.addEventListener("blur",$),window.addEventListener("resize",$),()=>{window.removeEventListener("blur",$),window.removeEventListener("resize",$)}},[A]);let[P,F]=Une($=>{let K=q().filter(oe=>!oe.disabled),Q=K.find(oe=>oe.ref.current===document.activeElement),J=Hne(K,$,Q);J&&setTimeout(()=>J.ref.current.focus())}),I=Se.useCallback(($,K,Q)=>{let J=!R.current&&!Q;(v.value!==void 0&&v.value===K||J)&&(N($),J&&(R.current=!0))},[v.value]),V=Se.useCallback(()=>b?.focus(),[b]),W=Se.useCallback(($,K,Q)=>{let J=!R.current&&!Q;(v.value!==void 0&&v.value===K||J)&&D($)},[v.value]),j=r==="popper"?nL:Ene,X=j===nL?{side:a,sideOffset:l,align:u,alignOffset:c,arrowPadding:d,collisionBoundary:h,collisionPadding:f,sticky:p,hideWhenDetached:m,avoidCollisions:g}:{};return(0,Ze.jsx)(Mne,{scope:n,content:b,viewport:x,onViewportChange:S,itemRefCallback:I,selectedItem:C,onItemLeave:V,itemTextRefCallback:W,focusSelectedItem:B,selectedItemText:E,position:r,isPositioned:z,searchRef:P,children:(0,Ze.jsx)(rE,{as:f4e,allowPinchZoom:!0,children:(0,Ze.jsx)(s1,{asChild:!0,trapped:v.open,onMountAutoFocus:$=>{$.preventDefault()},onUnmountAutoFocus:xe(i,$=>{v.trigger?.focus({preventScroll:!0}),$.preventDefault()}),children:(0,Ze.jsx)(Ev,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:$=>$.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,Ze.jsx)(j,{role:"listbox",id:v.contentId,"data-state":v.open?"open":"closed",dir:v.dir,onContextMenu:$=>$.preventDefault(),...y,...X,onPlaced:()=>_(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:xe(y.onKeyDown,$=>{let K=$.ctrlKey||$.altKey||$.metaKey;if($.key==="Tab"&&$.preventDefault(),!K&&$.key.length===1&&F($.key),["ArrowUp","ArrowDown","Home","End"].includes($.key)){let Q=q().filter(J=>!J.disabled).map(J=>J.ref.current);if(["ArrowUp","End"].includes($.key)&&(Q=Q.slice().reverse()),["ArrowUp","ArrowDown"].includes($.key)){let J=$.target,oe=Q.indexOf(J);Q=Q.slice(oe+1)}setTimeout(()=>T(Q)),$.preventDefault()}})})})})})})});_ne.displayName=h4e;var p4e="SelectItemAlignedPosition",Ene=Se.forwardRef((e,t)=>{let{__scopeSelect:n,onPlaced:r,...i}=e,o=Yh(rm,n),s=Qh(rm,n),[a,l]=Se.useState(null),[u,c]=Se.useState(null),d=qt(t,k=>c(k)),h=SE(n),f=Se.useRef(!1),p=Se.useRef(!0),{viewport:m,selectedItem:g,selectedItemText:y,focusSelectedItem:v}=s,b=Se.useCallback(()=>{if(o.trigger&&o.valueNode&&a&&u&&m&&g&&y){let k=o.trigger.getBoundingClientRect(),C=u.getBoundingClientRect(),N=o.valueNode.getBoundingClientRect(),E=y.getBoundingClientRect();if(o.dir!=="rtl"){let J=E.left-C.left,oe=N.left-J,be=k.left-oe,Me=k.width+be,Je=Math.max(Me,C.width),Ve=window.innerWidth-tl,Ct=D9(oe,[tl,Math.max(tl,Ve-Je)]);a.style.minWidth=Me+"px",a.style.left=Ct+"px"}else{let J=C.right-E.right,oe=window.innerWidth-N.right-J,be=window.innerWidth-k.right-oe,Me=k.width+be,Je=Math.max(Me,C.width),Ve=window.innerWidth-tl,Ct=D9(oe,[tl,Math.max(tl,Ve-Je)]);a.style.minWidth=Me+"px",a.style.right=Ct+"px"}let D=h(),q=window.innerHeight-tl*2,z=m.scrollHeight,_=window.getComputedStyle(u),R=parseInt(_.borderTopWidth,10),T=parseInt(_.paddingTop,10),B=parseInt(_.borderBottomWidth,10),A=parseInt(_.paddingBottom,10),M=R+T+z+A+B,P=Math.min(g.offsetHeight*5,M),F=window.getComputedStyle(m),I=parseInt(F.paddingTop,10),V=parseInt(F.paddingBottom,10),W=k.top+k.height/2-tl,j=q-W,X=g.offsetHeight/2,$=g.offsetTop+X,K=R+T+$,Q=M-K;if(K<=W){let J=D.length>0&&g===D[D.length-1].ref.current;a.style.bottom="0px";let oe=u.clientHeight-m.offsetTop-m.offsetHeight,be=Math.max(j,X+(J?V:0)+oe+B),Me=K+be;a.style.height=Me+"px"}else{let J=D.length>0&&g===D[0].ref.current;a.style.top="0px";let oe=Math.max(W,R+m.offsetTop+(J?I:0)+X)+Q;a.style.height=oe+"px",m.scrollTop=K-W+m.offsetTop}a.style.margin=`${tl}px 0`,a.style.minHeight=P+"px",a.style.maxHeight=q+"px",r?.(),requestAnimationFrame(()=>f.current=!0)}},[h,o.trigger,o.valueNode,a,u,m,g,y,o.dir,r]);ao(()=>b(),[b]);let[w,x]=Se.useState();ao(()=>{u&&x(window.getComputedStyle(u).zIndex)},[u]);let S=Se.useCallback(k=>{k&&p.current===!0&&(b(),v?.(),p.current=!1)},[b,v]);return(0,Ze.jsx)(g4e,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:f,onScrollButtonChange:S,children:(0,Ze.jsx)("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:w},children:(0,Ze.jsx)(ft.div,{...i,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});Ene.displayName=p4e;var m4e="SelectPopperPosition",nL=Se.forwardRef((e,t)=>{let{__scopeSelect:n,align:r="start",collisionPadding:i=tl,...o}=e,s=kE(n);return(0,Ze.jsx)(bE,{...s,...o,ref:t,align:r,collisionPadding:i,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)"}})});nL.displayName=m4e;var[g4e,u5]=Rv(rm,{}),rL="SelectViewport",One=Se.forwardRef((e,t)=>{let{__scopeSelect:n,nonce:r,...i}=e,o=Qh(rL,n),s=u5(rL,n),a=qt(t,o.onViewportChange),l=Se.useRef(0);return(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,Ze.jsx)(xE.Slot,{scope:n,children:(0,Ze.jsx)(ft.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:xe(i.onScroll,u=>{let c=u.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:h}=s;if(h?.current&&d){let f=Math.abs(l.current-c.scrollTop);if(f>0){let p=window.innerHeight-tl*2,m=parseFloat(d.style.minHeight),g=parseFloat(d.style.height),y=Math.max(m,g);if(y<p){let v=y+f,b=Math.min(p,v),w=v-b;d.style.height=b+"px",d.style.bottom==="0px"&&(c.scrollTop=w>0?w:0,d.style.justifyContent="flex-end")}}}l.current=c.scrollTop})})})]})});One.displayName=rL;var Tne="SelectGroup",[y4e,v4e]=Rv(Tne),b4e=Se.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=fi();return(0,Ze.jsx)(y4e,{scope:n,id:i,children:(0,Ze.jsx)(ft.div,{role:"group","aria-labelledby":i,...r,ref:t})})});b4e.displayName=Tne;var Ane="SelectLabel",Dne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=v4e(Ane,n);return(0,Ze.jsx)(ft.div,{id:i.id,...r,ref:t})});Dne.displayName=Ane;var UM="SelectItem",[w4e,Rne]=Rv(UM),Ine=Se.forwardRef((e,t)=>{let{__scopeSelect:n,value:r,disabled:i=!1,textValue:o,...s}=e,a=Yh(UM,n),l=Qh(UM,n),u=a.value===r,[c,d]=Se.useState(o??""),[h,f]=Se.useState(!1),p=qt(t,v=>l.itemRefCallback?.(v,r,i)),m=fi(),g=Se.useRef("touch"),y=()=>{i||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return(0,Ze.jsx)(w4e,{scope:n,value:r,disabled:i,textId:m,isSelected:u,onItemTextChange:Se.useCallback(v=>{d(b=>b||(v?.textContent??"").trim())},[]),children:(0,Ze.jsx)(xE.ItemSlot,{scope:n,value:r,disabled:i,textValue:c,children:(0,Ze.jsx)(ft.div,{role:"option","aria-labelledby":m,"data-highlighted":h?"":void 0,"aria-selected":u&&h,"data-state":u?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...s,ref:p,onFocus:xe(s.onFocus,()=>f(!0)),onBlur:xe(s.onBlur,()=>f(!1)),onClick:xe(s.onClick,()=>{g.current!=="mouse"&&y()}),onPointerUp:xe(s.onPointerUp,()=>{g.current==="mouse"&&y()}),onPointerDown:xe(s.onPointerDown,v=>{g.current=v.pointerType}),onPointerMove:xe(s.onPointerMove,v=>{g.current=v.pointerType,i?l.onItemLeave?.():g.current==="mouse"&&v.currentTarget.focus({preventScroll:!0})}),onPointerLeave:xe(s.onPointerLeave,v=>{v.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:xe(s.onKeyDown,v=>{l.searchRef?.current!==""&&v.key===" "||(o4e.includes(v.key)&&y(),v.key===" "&&v.preventDefault())})})})})});Ine.displayName=UM;var lw="SelectItemText",Pne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,className:r,style:i,...o}=e,s=Yh(lw,n),a=Qh(lw,n),l=Rne(lw,n),u=u4e(lw,n),[c,d]=Se.useState(null),h=qt(t,y=>d(y),l.onItemTextChange,y=>a.itemTextRefCallback?.(y,l.value,l.disabled)),f=c?.textContent,p=Se.useMemo(()=>(0,Ze.jsx)("option",{value:l.value,disabled:l.disabled,children:f},l.value),[l.disabled,l.value,f]),{onNativeOptionAdd:m,onNativeOptionRemove:g}=u;return ao(()=>(m(p),()=>g(p)),[m,g,p]),(0,Ze.jsxs)(Ze.Fragment,{children:[(0,Ze.jsx)(ft.span,{id:l.textId,...o,ref:h}),l.isSelected&&s.valueNode&&!s.valueNodeHasChildren?e5.createPortal(o.children,s.valueNode):null]})});Pne.displayName=lw;var Lne="SelectItemIndicator",Bne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return Rne(Lne,n).isSelected?(0,Ze.jsx)(ft.span,{"aria-hidden":!0,...r,ref:t}):null});Bne.displayName=Lne;var iL="SelectScrollUpButton",qne=Se.forwardRef((e,t)=>{let n=Qh(iL,e.__scopeSelect),r=u5(iL,e.__scopeSelect),[i,o]=Se.useState(!1),s=qt(t,r.onScrollButtonChange);return ao(()=>{if(n.viewport&&n.isPositioned){let l=function(){let c=u.scrollTop>0;o(c)};var a=l;let u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?(0,Ze.jsx)(Fne,{...e,ref:s,onAutoScroll:()=>{let{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});qne.displayName=iL;var oL="SelectScrollDownButton",zne=Se.forwardRef((e,t)=>{let n=Qh(oL,e.__scopeSelect),r=u5(oL,e.__scopeSelect),[i,o]=Se.useState(!1),s=qt(t,r.onScrollButtonChange);return ao(()=>{if(n.viewport&&n.isPositioned){let l=function(){let c=u.scrollHeight-u.clientHeight,d=Math.ceil(u.scrollTop)<c;o(d)};var a=l;let u=n.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[n.viewport,n.isPositioned]),i?(0,Ze.jsx)(Fne,{...e,ref:s,onAutoScroll:()=>{let{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});zne.displayName=oL;var Fne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,onAutoScroll:r,...i}=e,o=Qh("SelectScrollButton",n),s=Se.useRef(null),a=SE(n),l=Se.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return Se.useEffect(()=>()=>l(),[l]),ao(()=>{a().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),(0,Ze.jsx)(ft.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:xe(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:xe(i.onPointerMove,()=>{o.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:xe(i.onPointerLeave,()=>{l()})})}),x4e="SelectSeparator",jne=Se.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e;return(0,Ze.jsx)(ft.div,{"aria-hidden":!0,...r,ref:t})});jne.displayName=x4e;var sL="SelectArrow",S4e=Se.forwardRef((e,t)=>{let{__scopeSelect:n,...r}=e,i=kE(n),o=Yh(sL,n),s=Qh(sL,n);return o.open&&s.position==="popper"?(0,Ze.jsx)(wE,{...i,...r,ref:t}):null});S4e.displayName=sL;var k4e="SelectBubbleInput",Vne=Se.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{let i=Se.useRef(null),o=qt(r,i),s=Yz(t);return Se.useEffect(()=>{let a=i.current;if(!a)return;let l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(s!==t&&u){let c=new Event("change",{bubbles:!0});u.call(a,t),a.dispatchEvent(c)}},[s,t]),(0,Ze.jsx)(ft.select,{...n,style:{...gne,...n.style},ref:o,defaultValue:t})});Vne.displayName=k4e;function Wne(e){return e===""||e===void 0}function Une(e){let t=Ea(e),n=Se.useRef(""),r=Se.useRef(0),i=Se.useCallback(s=>{let a=n.current+s;t(a),function l(u){n.current=u,window.clearTimeout(r.current),u!==""&&(r.current=window.setTimeout(()=>l(""),1e3))}(a)},[t]),o=Se.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return Se.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,o]}function Hne(e,t,n){let r=t.length>1&&Array.from(t).every(a=>a===t[0])?t[0]:t,i=n?e.indexOf(n):-1,o=C4e(e,Math.max(i,0));r.length===1&&(o=o.filter(a=>a!==n));let s=o.find(a=>a.textValue.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}function C4e(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var N4e=vne,$ne=wne,M4e=Sne,_4e=kne,E4e=Cne,Kne=Nne,O4e=One,Yne=Dne,Qne=Ine,T4e=Pne,A4e=Bne,Gne=qne,Xne=zne,Jne=jne,Zne=N4e,ere=M4e,c5=Gh.forwardRef(({className:e,children:t,label:n,...r},i)=>(0,nr.jsxs)($ne,{ref:i,className:G("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...r,children:[(0,nr.jsxs)("div",{className:"flex items-center gap-1",children:[n&&(0,nr.jsxs)("span",{className:"text-muted-foreground",children:[n,":"]}),t]}),(0,nr.jsx)(_4e,{className:"flex shrink-0 items-center justify-center opacity-50",children:(0,nr.jsx)(Mv,{className:"h-4 w-4"})})]}));c5.displayName=$ne.displayName;var tre=Gh.forwardRef(({className:e,...t},n)=>(0,nr.jsx)(Gne,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:(0,nr.jsx)(Kze,{className:"h-4 w-4"})}));tre.displayName=Gne.displayName;var nre=Gh.forwardRef(({className:e,...t},n)=>(0,nr.jsx)(Xne,{ref:n,className:G("flex cursor-default items-center justify-center py-1",e),...t,children:(0,nr.jsx)(Mv,{className:"h-4 w-4"})}));nre.displayName=Xne.displayName;var d5=Gh.forwardRef(({className:e,children:t,position:n="popper",...r},i)=>(0,nr.jsx)(E4e,{children:(0,nr.jsx)("div",{className:"ps",children:(0,nr.jsxs)(Kne,{ref:i,className:G("relative z-50 max-h-(--radix-select-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-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 origin-(--radix-select-content-transform-origin)",n==="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",e),position:n,...r,children:[(0,nr.jsx)(tre,{}),(0,nr.jsx)(O4e,{className:G("p-1",n==="popper"&&"h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)"),children:t}),(0,nr.jsx)(nre,{})]})})}));d5.displayName=Kne.displayName;var D4e=Gh.forwardRef(({className:e,...t},n)=>(0,nr.jsx)(Yne,{ref:n,className:G("px-2 py-1.5 text-sm font-semibold",e),...t}));D4e.displayName=Yne.displayName;var Bw=Gh.forwardRef(({className:e,children:t,...n},r)=>(0,nr.jsxs)(Qne,{ref:r,className:G("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),...n,children:[(0,nr.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,nr.jsx)(A4e,{children:(0,nr.jsx)(fm,{className:"h-4 w-4"})})}),(0,nr.jsx)(T4e,{children:t})]}));Bw.displayName=Qne.displayName;var R4e=Gh.forwardRef(({className:e,...t},n)=>(0,nr.jsx)(Jne,{ref:n,className:G("-mx-1 my-1 h-px bg-muted",e),...t}));R4e.displayName=Jne.displayName;function jN({className:e,...t}){return(0,rre.jsx)("div",{className:G("animate-pulse rounded-md bg-foreground/10",e),...t})}function Ho({className:e}){let{metadata:t,createUrl:n,viewParam:r,schemaParam:i}=lo(),{isDarkMode:o}=is(),{isFetching:s,activeTable:a}=t,{errorState:l,hasResolvedIntrospection:u,isRefetching:c,refetch:d}=Hh(),[h,f]=En(Lte,{isOpen:!1,term:""}),[,p]=En(Bte,{requestId:0,tableId:null}),[m,g]=(0,Bc.useState)(-1),y=(0,Bc.useRef)(null),{tables:v,isSearchActive:b}=Pte({schema:i,searchTerm:h.term}),w=(0,Bc.useMemo)(()=>v.map(A=>A.id).join("|"),[v]),x=a?`${a.schema}.${a.name}`:null,S=s&&!u,k=l!=null&&!u,C=l!=null&&u,N=o?Pje:Lje;(0,Bc.useEffect)(()=>{h.isOpen&&(y.current?.focus(),y.current?.select())},[h.isOpen]),(0,Bc.useEffect)(()=>{if(!h.isOpen){g(-1);return}let A=w.length>0?w.split("|"):[],M=r==="table"&&x?A.indexOf(x):-1;g(M>=0?M:A.length>0?0:-1)},[x,w,h.isOpen,h.term,r]);function E(){f(A=>({...A,isOpen:!0}))}function D(){y.current?.blur(),f({isOpen:!1,term:""})}function q(A){f(M=>({...M,term:A}))}function z(A){window.location.hash=n({schemaParam:A.schema,tableParam:A.table,viewParam:"table"})}function _(A){p(M=>({requestId:M.requestId+1,tableId:`${A.schema}.${A.table}`}))}function R(A){_(A),D(),z(A)}function T(A){if(A.key==="Escape"){A.preventDefault(),D();return}if(v.length!==0){if(A.key==="ArrowDown"){A.preventDefault(),g(M=>M<0?0:Math.min(M+1,v.length-1));return}if(A.key==="ArrowUp"){A.preventDefault(),g(M=>M<0?v.length-1:Math.max(M-1,0));return}if(A.key==="Enter"&&m>=0){A.preventDefault();let M=v[m];if(!M)return;R({schema:M.schema,table:M.table})}}}let B=G("flex flex-col w-48 overflow-y-auto min-h-full h-0 text-card-foreground shadow-xs rounded-lg",e);return(0,Xe.jsxs)("div",{className:B,children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-2 pt-4 pb-0.5 px-4",children:[(0,Xe.jsx)("img",{src:N,alt:"Prisma Logo",className:"h-6 w-auto"}),(0,Xe.jsx)("span",{className:"text-lg font-medium font-sans",children:"Prisma Studio"})]}),(0,Xe.jsx)(Ho.SchemaSelector,{}),(0,Xe.jsxs)(Ho.Block,{label:"Studio",children:[(0,Xe.jsx)(Ho.Item,{asChild:!0,isActive:r==="schema",className:"py-1 font-mono text-xs text-foreground/60 hover:text-foreground transition-all cursor-pointer data-[active=true]:bg-accent data-[active=true]:foreground data-[active=true]:text-foreground",children:(0,Xe.jsx)("a",{href:n({viewParam:"schema"}),className:"w-full",children:"Visualizer"})}),(0,Xe.jsx)(Ho.Item,{asChild:!0,isActive:r==="console",className:"py-1 font-mono text-xs text-foreground/60 hover:text-foreground transition-all cursor-pointer data-[active=true]:bg-accent data-[active=true]:foreground data-[active=true]:text-foreground",children:(0,Xe.jsx)("a",{href:n({viewParam:"console"}),className:"w-full",children:"Console"})}),(0,Xe.jsx)(Ho.Item,{asChild:!0,isActive:r==="sql",className:"py-1 font-mono text-xs text-foreground/60 hover:text-foreground transition-all cursor-pointer data-[active=true]:bg-accent data-[active=true]:foreground data-[active=true]:text-foreground",children:(0,Xe.jsx)("a",{href:n({viewParam:"sql"}),className:"w-full",children:"SQL"})})]}),(0,Xe.jsx)(Ho.TablesBlock,{isSearchOpen:h.isOpen,onOpenSearch:E,onCloseSearch:D,onSearchKeyDown:T,searchInputRef:y,searchTerm:h.term,setSearchTerm:q,children:k?(0,Xe.jsx)(XP,{className:"mx-2 mb-2",compact:!0,description:"Retry to reload schema and table metadata.",isRetrying:c,message:l.message,onRetry:()=>{d()},queryPreview:l.queryPreview,source:l.adapterSource,title:"Schema metadata unavailable"}):(0,Xe.jsxs)(Xe.Fragment,{children:[C&&(0,Xe.jsx)(XP,{className:"mx-2 mb-2",compact:!0,description:"Studio is showing the last successful schema snapshot.",isRetrying:c,message:l.message,onRetry:()=>{d()},queryPreview:l.queryPreview,source:l.adapterSource,title:"Schema refresh failed",variant:"warning"}),S?Array(4).fill(null).map((A,M)=>(0,Xe.jsx)(Ho.Item,{wrapChildrenInSpan:!1,children:(0,Xe.jsx)(jN,{className:"h-3 w-full"})},M)):v.length>0?v.map((A,M)=>{let P=h.isOpen&&M===m,F=a?.schema===A.schema&&a?.name===A.table&&r==="table";return(0,Xe.jsx)(Ho.Item,{asChild:!0,"data-search-highlighted":P?"true":"false",isActive:h.isOpen?P:F,className:"py-1 font-mono text-xs text-foreground/60 hover:text-foreground transition-all cursor-pointer data-[active=true]:bg-accent data-[active=true]:foreground data-[active=true]:text-foreground",onMouseEnter:()=>{h.isOpen&&g(M)},children:(0,Xe.jsx)("a",{href:n({tableParam:A.table,schemaParam:A.schema,viewParam:"table"}),className:"w-full",onClick:I=>{I.button!==0||I.altKey||I.ctrlKey||I.metaKey||I.shiftKey||(I.preventDefault(),R({schema:A.schema,table:A.table}))},children:A.table})},A.id)}):(0,Xe.jsx)(Ho.Item,{children:b?"No matching tables":"No tables found"})]})})]})}var I4e=({className:e,label:t,children:n,...r})=>(0,Xe.jsxs)("div",{className:e,...r,children:[(0,Xe.jsxs)("div",{className:"flex items-center gap-1 pt-4 pb-2 px-4 sticky top-0 backdrop-blur-sm",children:[(0,Xe.jsx)(YZ,{size:16,className:"text-muted-foreground/60"}),(0,Xe.jsx)("h2",{className:"text-sm font-medium",children:t})]}),(0,Xe.jsx)("nav",{"aria-label":t,className:"flex flex-col gap-px pb-3 p-2",children:n})]}),P4e=({className:e,children:t,isSearchOpen:n,onCloseSearch:r,onOpenSearch:i,onSearchKeyDown:o,searchInputRef:s,searchTerm:a,setSearchTerm:l,...u})=>(0,Xe.jsxs)("div",{className:G("group/tables relative",e),"data-search-open":n?"true":"false",...u,children:[(0,Xe.jsxs)("div",{className:"relative flex items-center gap-1 pt-4 pb-2 px-4 sticky top-0 backdrop-blur-sm min-h-10",children:[(0,Xe.jsxs)("div",{className:G("flex items-center gap-1 transition-opacity duration-200",n&&"opacity-0 pointer-events-none"),children:[(0,Xe.jsx)(YZ,{size:16,className:"text-muted-foreground/60"}),(0,Xe.jsx)("h2",{className:"text-sm font-medium",children:"Tables"})]}),(0,Xe.jsx)("button",{"aria-label":"Search tables",className:G("ml-auto h-6 w-6 rounded-sm flex items-center justify-center text-muted-foreground/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring transition-opacity duration-200",n?"opacity-0 pointer-events-none":"opacity-0 group-hover/tables:opacity-100 focus:opacity-100 focus-visible:opacity-100"),onClick:i,type:"button",children:(0,Xe.jsx)(_h,{size:14})}),(0,Xe.jsx)("div",{"data-table-search-input-wrapper":!0,className:G("absolute right-4 top-1/2 -translate-y-1/2 origin-right transition-[opacity,transform] duration-200 ease-out will-change-transform w-[calc(100%-2rem)]",n?"opacity-100 scale-x-100":"opacity-0 scale-x-0 pointer-events-none"),children:(0,Xe.jsx)(Fi,{"aria-label":"Search tables",className:"h-9 w-full bg-background shadow-none",onChange:c=>{l(c.currentTarget.value)},onKeyDown:o,onBlur:c=>{c.currentTarget.value.trim().length>0||r()},placeholder:"Search tables...",ref:s,value:a})})]}),(0,Xe.jsx)("nav",{"aria-label":"Tables",className:"flex flex-col gap-px pb-3 p-2",children:t})]}),L4e=({className:e,asChild:t=!1,isActive:n,size:r,children:i,wrapChildrenInSpan:o=!0,...s})=>(0,Xe.jsx)(t?Hee:"button",{"data-sidebar":"menu-button","data-size":r,"data-active":n,className:G("py-1.5 px-2 text-sm font-medium rounded-md flex gap-2 items-center border border-transparent bg-transparent",e),...s,children:o?(0,Xe.jsx)("span",{className:"truncate",children:i}):(0,Xe.jsx)(Xe.Fragment,{children:i})}),B4e=()=>{let{data:e,hasResolvedIntrospection:t,isFetching:n}=Hh(),{schemaParam:r,setSchemaParam:i,setTableParam:o}=lo(),s=Object.keys(e.schemas||{});return(0,Xe.jsx)("div",{className:"flex items-center gap-1 pt-4 pb-2 px-4 sticky top-0 backdrop-blur-sm",children:(0,Xe.jsxs)(Zne,{value:r,onValueChange:a=>{let l=e.schemas[a??""],u=Object.keys(l?.tables??{})[0]??null;i(a),o(u)},children:[(0,Xe.jsx)(c5,{className:"text-xs",label:"Schema",children:(0,Xe.jsx)(ere,{placeholder:"Select schema"})}),(0,Xe.jsx)(d5,{children:n&&!t?(0,Xe.jsx)(Bw,{value:"loading",children:"Loading schemas..."}):s.length>0?s.map(a=>(0,Xe.jsx)(Bw,{value:a,className:"text-xs",children:a},a)):(0,Xe.jsx)(Bw,{value:"no-schemas",children:"No schemas found"})})]})})};Ho.Block=I4e;Ho.Item=L4e;Ho.SchemaSelector=B4e;Ho.TablesBlock=P4e;function f1(e){let{toggleNavigation:t,isNavigationOpen:n}=is();return(0,bc.jsx)("div",{className:G("bg-studio-header-background flex w-full rounded-t-lg border-b border-border bg-card p-2 py-3",e.className),children:(0,bc.jsxs)("div",{className:"flex w-full items-center gap-3",children:[(0,bc.jsxs)("div",{className:"flex min-w-0 grow items-center gap-2",children:[(0,bc.jsx)(zn,{"aria-label":n?"Close navigation":"Open navigation",variant:"outline",size:"icon",onClick:t,children:n?(0,bc.jsx)(x5e,{"data-icon":"inline-start"}):(0,bc.jsx)(k5e,{"data-icon":"inline-start"})}),e.children]}),e.endContent!=null?(0,bc.jsx)("div",{"data-testid":"studio-header-end-controls",className:"flex shrink-0 items-center gap-2 pl-2",children:e.endContent}):null]})})}var ore=pE("inline-flex items-center rounded-md 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-red-400/50 bg-red-400/30 text-foreground dark:text-white hover:bg-red-400/80",success:"border-green-500/50 bg-green-500/30 text-foreground dark:text-white hover:bg-green-500/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function q4e({className:e,variant:t,...n}){return(0,ire.jsx)("div",{className:G(ore({variant:t}),e),...n})}var sre=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("rounded-xl border bg-card text-card-foreground shadow",e),...t}));sre.displayName="Card";var are=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("flex flex-col gap-1.5 p-6",e),...t}));are.displayName="CardHeader";var lre=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("font-semibold leading-none tracking-tight",e),...t}));lre.displayName="CardTitle";var z4e=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("text-sm text-muted-foreground",e),...t}));z4e.displayName="CardDescription";var ure=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("p-6 pt-0",e),...t}));ure.displayName="CardContent";var F4e=mm.forwardRef(({className:e,...t},n)=>(0,gm.jsx)("div",{ref:n,className:G("flex items-center p-6 pt-0",e),...t}));F4e.displayName="CardFooter";var j4e=e=>new Date(e).toLocaleTimeString(),V4e=e=>{if(!e||!e.sql)return"No query";let t=e.sql.substring(0,100);return e.sql.length>100?`${t}...`:t};function W4e({event:e}){let[t,n]=En(`operation-event:${e.eventId}:query-expanded`,!1,{cleanupOnUnmount:!0}),r=e.name==="studio_operation_error";return(0,Xt.jsx)("div",{className:"flex flex-col gap-2",children:(0,Xt.jsxs)(sre,{className:G("w-full rounded-sm border-ring/20 overflow-clip shadow-none"),children:[(0,Xt.jsx)(are,{className:G("p-3 font-normal",r?"border-red-500/60 bg-red-500/10":"border-green-500/60 bg-green-500/10"),children:(0,Xt.jsxs)(lre,{className:"flex items-center justify-between font-mono text-xs",children:[(0,Xt.jsxs)("div",{className:"flex items-center gap-2",children:[r?(0,Xt.jsx)(Tz,{size:16,className:"text-red-500"}):(0,Xt.jsx)(e5e,{size:16,className:"text-green-500"}),(0,Xt.jsxs)("span",{className:"",children:[e.payload.operation,", ",j4e(e.timestamp)]})]}),(0,Xt.jsx)(q4e,{variant:r?"destructive":"success",className:"font-normal text-xs",children:e.name==="studio_operation_success"?"Success":"Error"})]})}),(0,Xt.jsxs)(ure,{className:"flex flex-col gap-3 p-3",children:[e.payload.query&&(0,Xt.jsxs)("div",{"data-response-type":"query",className:"flex flex-col gap-2",children:[(0,Xt.jsxs)("div",{className:"flex items-center justify-between relative",children:[(0,Xt.jsxs)("button",{type:"button",onClick:()=>n(!t),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground","aria-expanded":t,children:[t?(0,Xt.jsx)(Mv,{size:12}):(0,Xt.jsx)(o1,{size:12}),"SQL Query"]}),(0,Xt.jsx)(zn,{"aria-label":"Copy SQL query",variant:"outline",size:"icon",className:"size-6",onClick:()=>{navigator.clipboard.writeText(e.payload.query?.sql||""),Ey.success("Query copied to clipboard")},children:(0,Xt.jsx)($Z,{"data-icon":"inline-start"})})]}),(0,Xt.jsx)("div",{className:G("p-3 bg-secondary/50 border border-border rounded-sm text-xs font-mono overflow-x-auto",t?"block whitespace-pre-wrap max-h-64 overflow-y-auto":"max-h-10 overflow-hidden"),children:t?e.payload.query.sql:V4e(e.payload.query)}),(0,Xt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,Xt.jsx)("span",{className:"text-xs text-muted-foreground",children:"Parameters"}),(0,Xt.jsx)("div",{className:"p-3 bg-secondary/50 border border-border rounded-sm text-xs font-mono overflow-x-auto",children:JSON.stringify(e.payload.query.parameters||[],null,2)})]})]}),r&&e.payload.error&&(0,Xt.jsxs)("div",{"data-response-type":"error",className:"flex flex-col gap-2",children:[(0,Xt.jsx)("div",{className:"flex items-center justify-between relative",children:(0,Xt.jsxs)("span",{className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground",children:[(0,Xt.jsx)(W5e,{size:12}),"Error Details"]})}),e.payload.error.adapterSource?(0,Xt.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,Xt.jsx)("span",{className:"text-xs text-muted-foreground",children:"Adapter"}),(0,Xt.jsx)("div",{className:"p-3 bg-secondary/50 border border-border rounded-sm text-xs font-mono overflow-x-auto",children:e.payload.error.adapterSource})]}):null,(0,Xt.jsx)("div",{className:"p-3 bg-secondary/50 border border-red-400/20 rounded-sm text-xs font-mono overflow-x-auto",children:(0,Xt.jsx)("pre",{className:"text-xs text-red-400 whitespace-pre-wrap font-mono",children:e.payload.error instanceof AggregateError?e.payload.error.errors.map((i,o)=>(0,Xt.jsx)("div",{children:i.message},o)):e.payload.error.message})})]})]})]})})}function U4e(e){let{operationEvents:t}=is(),n=(0,CE.useRef)(null);return(0,CE.useEffect)(()=>{n.current&&(n.current.scrollTop=n.current.scrollHeight)},[t]),(0,Pp.jsxs)("div",{className:"flex flex-col h-full overflow-hidden",children:[(0,Pp.jsx)(f1,{}),(0,Pp.jsxs)("div",{ref:n,className:"flex flex-col grow p-4 overflow-y-auto gap-2 bg-background/50",children:[t.length===0&&(0,Pp.jsx)("div",{className:"flex justify-center items-center h-full text-muted-foreground",children:"No operation events yet."}),t.map(r=>(0,Pp.jsx)(W4e,{event:r},r.eventId))]})]})}var U9={name:"No Tables Found",fields:[{name:"message",type:"info",isRequired:!0}]};function H4e(){let{data:e,isFetching:t}=Hh(),{metadata:{activeSchema:n}}=lo();return(0,cre.useMemo)(()=>{if(t||!e||!n)return{tables:[U9],relationships:[]};let r=e.schemas[n.name];if(!r||Object.keys(r.tables).length===0)return{tables:[U9],relationships:[]};let i=[],o={};Object.values(r.tables).forEach(a=>{let l=[];Object.values(a.columns).forEach(c=>{let d={name:c.name,type:c.datatype.name,isPrimary:c.pkPosition!=null,isRequired:!c.nullable,isNullable:c.nullable,isForeignKey:!!c.fkTable};c.fkTable&&c.fkColumn&&(d.foreignKeyTo={table:c.fkTable,column:c.fkColumn}),l.push(d)});let u={name:a.name,fields:l};i.push(u),o[a.name]=u});let s=[];return i.forEach(a=>{let l=r.tables[a.name];l&&Object.values(l.columns).forEach(u=>{if(u.fkTable&&u.fkColumn){let c=u.pkPosition!=null;s.push({from:u.fkTable,to:a.name,type:c?"1:1":"1:n"})}})}),{tables:i,relationships:s}},[e,t,n])}function Ui(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Ui(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var $4e=Dl(jMe(),1),H9=e=>{let t,n=new Set,r=(a,l)=>{let u=typeof a=="function"?a(t):a;if(!Object.is(u,t)){let c=t;t=l??(typeof u!="object"||u===null)?u:Object.assign({},t,u),n.forEach(d=>d(t,c))}},i=()=>t,o={setState:r,getState:i,getInitialState:()=>s,subscribe:a=>(n.add(a),()=>n.delete(a)),destroy:()=>{(import.meta.env?import.meta.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},s=t=e(r,i,o);return o},K4e=e=>e?H9(e):H9,{useDebugValue:Y4e}=dre.default,{useSyncExternalStoreWithSelector:Q4e}=$4e.default,G4e=e=>e;function hre(e,t=G4e,n){let r=Q4e(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Y4e(r),r}var $9=(e,t)=>{let n=K4e(e),r=(i,o=t)=>hre(n,i,o);return Object.assign(r,n),r},X4e=(e,t)=>e?$9(e,t):$9;function _i(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let r of e)if(!t.has(r))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var J4e={value:()=>{}};function fre(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new VN(n)}function VN(e){this._=e}function Z4e(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}VN.prototype=fre.prototype={constructor:VN,on:function(e,t){var n=this._,r=Z4e(e+"",n),i,o=-1,s=r.length;if(arguments.length<2){for(;++o<s;)if((i=(e=r[o]).type)&&(i=eWe(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<s;)if(i=(e=r[o]).type)n[i]=K9(n[i],e.name,t);else if(t==null)for(i in n)n[i]=K9(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new VN(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function eWe(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function K9(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=J4e,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var h5=fre,aL="http://www.w3.org/1999/xhtml",Y9={svg:"http://www.w3.org/2000/svg",xhtml:aL,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function NE(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Y9.hasOwnProperty(t)?{space:Y9[t],local:e}:e}function tWe(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===aL&&t.documentElement.namespaceURI===aL?t.createElement(e):t.createElementNS(n,e)}}function nWe(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function pre(e){var t=NE(e);return(t.local?nWe:tWe)(t)}function rWe(){}function f5(e){return e==null?rWe:function(){return this.querySelector(e)}}function iWe(e){typeof e!="function"&&(e=f5(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=new Array(s),l,u,c=0;c<s;++c)(l=o[c])&&(u=e.call(l,l.__data__,c,o))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Bs(r,this._parents)}function oWe(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function sWe(){return[]}function mre(e){return e==null?sWe:function(){return this.querySelectorAll(e)}}function aWe(e){return function(){return oWe(e.apply(this,arguments))}}function lWe(e){typeof e=="function"?e=aWe(e):e=mre(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var s=t[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&(r.push(e.call(l,l.__data__,u,s)),i.push(l));return new Bs(r,i)}function gre(e){return function(){return this.matches(e)}}function yre(e){return function(t){return t.matches(e)}}var uWe=Array.prototype.find;function cWe(e){return function(){return uWe.call(this.children,e)}}function dWe(){return this.firstElementChild}function hWe(e){return this.select(e==null?dWe:cWe(typeof e=="function"?e:yre(e)))}var fWe=Array.prototype.filter;function pWe(){return Array.from(this.children)}function mWe(e){return function(){return fWe.call(this.children,e)}}function gWe(e){return this.selectAll(e==null?pWe:mWe(typeof e=="function"?e:yre(e)))}function yWe(e){typeof e!="function"&&(e=gre(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,u=0;u<s;++u)(l=o[u])&&e.call(l,l.__data__,u,o)&&a.push(l);return new Bs(r,this._parents)}function vre(e){return new Array(e.length)}function vWe(){return new Bs(this._enter||this._groups.map(vre),this._parents)}function HM(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}HM.prototype={constructor:HM,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function bWe(e){return function(){return e}}function wWe(e,t,n,r,i,o){for(var s=0,a,l=t.length,u=o.length;s<u;++s)(a=t[s])?(a.__data__=o[s],r[s]=a):n[s]=new HM(e,o[s]);for(;s<l;++s)(a=t[s])&&(i[s]=a)}function xWe(e,t,n,r,i,o,s){var a,l,u=new Map,c=t.length,d=o.length,h=new Array(c),f;for(a=0;a<c;++a)(l=t[a])&&(h[a]=f=s.call(l,l.__data__,a,t)+"",u.has(f)?i[a]=l:u.set(f,l));for(a=0;a<d;++a)f=s.call(e,o[a],a,o)+"",(l=u.get(f))?(r[a]=l,l.__data__=o[a],u.delete(f)):n[a]=new HM(e,o[a]);for(a=0;a<c;++a)(l=t[a])&&u.get(h[a])===l&&(i[a]=l)}function SWe(e){return e.__data__}function kWe(e,t){if(!arguments.length)return Array.from(this,SWe);var n=t?xWe:wWe,r=this._parents,i=this._groups;typeof e!="function"&&(e=bWe(e));for(var o=i.length,s=new Array(o),a=new Array(o),l=new Array(o),u=0;u<o;++u){var c=r[u],d=i[u],h=d.length,f=CWe(e.call(c,c&&c.__data__,u,r)),p=f.length,m=a[u]=new Array(p),g=s[u]=new Array(p),y=l[u]=new Array(h);n(c,d,m,g,y,f,t);for(var v=0,b=0,w,x;v<p;++v)if(w=m[v]){for(v>=b&&(b=v+1);!(x=g[b])&&++b<p;);w._next=x||null}}return s=new Bs(s,r),s._enter=a,s._exit=l,s}function CWe(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function NWe(){return new Bs(this._exit||this._groups.map(vre),this._parents)}function MWe(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function _We(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,s=Math.min(i,o),a=new Array(i),l=0;l<s;++l)for(var u=n[l],c=r[l],d=u.length,h=a[l]=new Array(d),f,p=0;p<d;++p)(f=u[p]||c[p])&&(h[p]=f);for(;l<i;++l)a[l]=n[l];return new Bs(a,this._parents)}function EWe(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],s;--i>=0;)(s=r[i])&&(o&&s.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(s,o),o=s);return this}function OWe(e){e||(e=TWe);function t(d,h){return d&&h?e(d.__data__,h.__data__):!d-!h}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var s=n[o],a=s.length,l=i[o]=new Array(a),u,c=0;c<a;++c)(u=s[c])&&(l[c]=u);l.sort(t)}return new Bs(i,this._parents).order()}function TWe(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function AWe(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function DWe(){return Array.from(this)}function RWe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var s=r[i];if(s)return s}return null}function IWe(){let e=0;for(let t of this)++e;return e}function PWe(){return!this.node()}function LWe(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,s=i.length,a;o<s;++o)(a=i[o])&&e.call(a,a.__data__,o,i);return this}function BWe(e){return function(){this.removeAttribute(e)}}function qWe(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zWe(e,t){return function(){this.setAttribute(e,t)}}function FWe(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function jWe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function VWe(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function WWe(e,t){var n=NE(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?qWe:BWe:typeof t=="function"?n.local?VWe:jWe:n.local?FWe:zWe)(n,t))}function bre(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function UWe(e){return function(){this.style.removeProperty(e)}}function HWe(e,t,n){return function(){this.style.setProperty(e,t,n)}}function $We(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function KWe(e,t,n){return arguments.length>1?this.each((t==null?UWe:typeof t=="function"?$We:HWe)(e,t,n??"")):ev(this.node(),e)}function ev(e,t){return e.style.getPropertyValue(t)||bre(e).getComputedStyle(e,null).getPropertyValue(t)}function YWe(e){return function(){delete this[e]}}function QWe(e,t){return function(){this[e]=t}}function GWe(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function XWe(e,t){return arguments.length>1?this.each((t==null?YWe:typeof t=="function"?GWe:QWe)(e,t)):this.node()[e]}function wre(e){return e.trim().split(/^|\s+/)}function p5(e){return e.classList||new xre(e)}function xre(e){this._node=e,this._names=wre(e.getAttribute("class")||"")}xre.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Sre(e,t){for(var n=p5(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function kre(e,t){for(var n=p5(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function JWe(e){return function(){Sre(this,e)}}function ZWe(e){return function(){kre(this,e)}}function eUe(e,t){return function(){(t.apply(this,arguments)?Sre:kre)(this,e)}}function tUe(e,t){var n=wre(e+"");if(arguments.length<2){for(var r=p5(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?eUe:t?JWe:ZWe)(n,t))}function nUe(){this.textContent=""}function rUe(e){return function(){this.textContent=e}}function iUe(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function oUe(e){return arguments.length?this.each(e==null?nUe:(typeof e=="function"?iUe:rUe)(e)):this.node().textContent}function sUe(){this.innerHTML=""}function aUe(e){return function(){this.innerHTML=e}}function lUe(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function uUe(e){return arguments.length?this.each(e==null?sUe:(typeof e=="function"?lUe:aUe)(e)):this.node().innerHTML}function cUe(){this.nextSibling&&this.parentNode.appendChild(this)}function dUe(){return this.each(cUe)}function hUe(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fUe(){return this.each(hUe)}function pUe(e){var t=typeof e=="function"?e:pre(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function mUe(){return null}function gUe(e,t){var n=typeof e=="function"?e:pre(e),r=t==null?mUe:typeof t=="function"?t:f5(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function yUe(){var e=this.parentNode;e&&e.removeChild(this)}function vUe(){return this.each(yUe)}function bUe(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wUe(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function xUe(e){return this.select(e?wUe:bUe)}function SUe(e){return arguments.length?this.property("__data__",e):this.node().__data__}function kUe(e){return function(t){e.call(this,t,this.__data__)}}function CUe(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function NUe(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function MUe(e,t,n){return function(){var r=this.__on,i,o=kUe(t);if(r){for(var s=0,a=r.length;s<a;++s)if((i=r[s]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function _Ue(e,t,n){var r=CUe(e+""),i,o=r.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(i=0,c=a[l];i<o;++i)if((s=r[i]).type===c.type&&s.name===c.name)return c.value}return}for(a=t?MUe:NUe,i=0;i<o;++i)this.each(a(r[i],t,n));return this}function Cre(e,t,n){var r=bre(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function EUe(e,t){return function(){return Cre(this,e,t)}}function OUe(e,t){return function(){return Cre(this,e,t.apply(this,arguments))}}function TUe(e,t){return this.each((typeof t=="function"?OUe:EUe)(e,t))}function*AUe(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,s;i<o;++i)(s=r[i])&&(yield s)}var Nre=[null];function Bs(e,t){this._groups=e,this._parents=t}function Mre(){return new Bs([[document.documentElement]],Nre)}function DUe(){return this}Bs.prototype=Mre.prototype={constructor:Bs,select:iWe,selectAll:lWe,selectChild:hWe,selectChildren:gWe,filter:yWe,data:kWe,enter:vWe,exit:NWe,join:MWe,merge:_We,selection:DUe,order:EWe,sort:OWe,call:AWe,nodes:DWe,node:RWe,size:IWe,empty:PWe,each:LWe,attr:WWe,style:KWe,property:XWe,classed:tUe,text:oUe,html:uUe,raise:dUe,lower:fUe,append:pUe,insert:gUe,remove:vUe,clone:xUe,datum:SUe,on:_Ue,dispatch:TUe,[Symbol.iterator]:AUe};var p1=Mre;function pa(e){return typeof e=="string"?new Bs([[document.querySelector(e)]],[document.documentElement]):new Bs([[e]],Nre)}function RUe(e){let t;for(;t=e.sourceEvent;)e=t;return e}function nl(e,t){if(e=RUe(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var IUe={passive:!1},yx={capture:!0,passive:!1};function xR(e){e.stopImmediatePropagation()}function Ay(e){e.preventDefault(),e.stopImmediatePropagation()}function _re(e){var t=e.document.documentElement,n=pa(e).on("dragstart.drag",Ay,yx);"onselectstart"in t?n.on("selectstart.drag",Ay,yx):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Ere(e,t){var n=e.document.documentElement,r=pa(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ay,yx),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var LC=e=>()=>e;function lL(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:s,y:a,dx:l,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}lL.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function PUe(e){return!e.ctrlKey&&!e.button}function LUe(){return this.parentNode}function BUe(e,t){return t??{x:e.x,y:e.y}}function qUe(){return navigator.maxTouchPoints||"ontouchstart"in this}function zUe(){var e=PUe,t=LUe,n=BUe,r=qUe,i={},o=h5("start","drag","end"),s=0,a,l,u,c,d=0;function h(w){w.on("mousedown.drag",f).filter(r).on("touchstart.drag",g).on("touchmove.drag",y,IUe).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(w,x){if(!(c||!e.call(this,w,x))){var S=b(this,t.call(this,w,x),w,x,"mouse");S&&(pa(w.view).on("mousemove.drag",p,yx).on("mouseup.drag",m,yx),_re(w.view),xR(w),u=!1,a=w.clientX,l=w.clientY,S("start",w))}}function p(w){if(Ay(w),!u){var x=w.clientX-a,S=w.clientY-l;u=x*x+S*S>d}i.mouse("drag",w)}function m(w){pa(w.view).on("mousemove.drag mouseup.drag",null),Ere(w.view,u),Ay(w),i.mouse("end",w)}function g(w,x){if(e.call(this,w,x)){var S=w.changedTouches,k=t.call(this,w,x),C=S.length,N,E;for(N=0;N<C;++N)(E=b(this,k,w,x,S[N].identifier,S[N]))&&(xR(w),E("start",w,S[N]))}}function y(w){var x=w.changedTouches,S=x.length,k,C;for(k=0;k<S;++k)(C=i[x[k].identifier])&&(Ay(w),C("drag",w,x[k]))}function v(w){var x=w.changedTouches,S=x.length,k,C;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),k=0;k<S;++k)(C=i[x[k].identifier])&&(xR(w),C("end",w,x[k]))}function b(w,x,S,k,C,N){var E=o.copy(),D=nl(N||S,x),q,z,_;if((_=n.call(w,new lL("beforestart",{sourceEvent:S,target:h,identifier:C,active:s,x:D[0],y:D[1],dx:0,dy:0,dispatch:E}),k))!=null)return q=_.x-D[0]||0,z=_.y-D[1]||0,function R(T,B,A){var M=D,P;switch(T){case"start":i[C]=R,P=s++;break;case"end":delete i[C],--s;case"drag":D=nl(A||B,x),P=s;break}E.call(T,w,new lL(T,{sourceEvent:B,subject:_,target:h,identifier:C,active:P,x:D[0]+q,y:D[1]+z,dx:D[0]-M[0],dy:D[1]-M[1],dispatch:E}),k)}}return h.filter=function(w){return arguments.length?(e=typeof w=="function"?w:LC(!!w),h):e},h.container=function(w){return arguments.length?(t=typeof w=="function"?w:LC(w),h):t},h.subject=function(w){return arguments.length?(n=typeof w=="function"?w:LC(w),h):n},h.touchable=function(w){return arguments.length?(r=typeof w=="function"?w:LC(!!w),h):r},h.on=function(){var w=o.on.apply(o,arguments);return w===o?h:w},h.clickDistance=function(w){return arguments.length?(d=(w=+w)*w,h):Math.sqrt(d)},h}function m5(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Ore(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function m1(){}var vx=.7,$M=1/vx,Dy="\\s*([+-]?\\d+)\\s*",bx="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",pu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",FUe=/^#([0-9a-f]{3,8})$/,jUe=new RegExp(`^rgb\\(${Dy},${Dy},${Dy}\\)$`),VUe=new RegExp(`^rgb\\(${pu},${pu},${pu}\\)$`),WUe=new RegExp(`^rgba\\(${Dy},${Dy},${Dy},${bx}\\)$`),UUe=new RegExp(`^rgba\\(${pu},${pu},${pu},${bx}\\)$`),HUe=new RegExp(`^hsl\\(${bx},${pu},${pu}\\)$`),$Ue=new RegExp(`^hsla\\(${bx},${pu},${pu},${bx}\\)$`),Q9={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};m5(m1,wx,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:G9,formatHex:G9,formatHex8:KUe,formatHsl:YUe,formatRgb:X9,toString:X9});function G9(){return this.rgb().formatHex()}function KUe(){return this.rgb().formatHex8()}function YUe(){return Tre(this).formatHsl()}function X9(){return this.rgb().formatRgb()}function wx(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=FUe.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?J9(t):n===3?new Jo(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?BC(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?BC(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=jUe.exec(e))?new Jo(t[1],t[2],t[3],1):(t=VUe.exec(e))?new Jo(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=WUe.exec(e))?BC(t[1],t[2],t[3],t[4]):(t=UUe.exec(e))?BC(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=HUe.exec(e))?tK(t[1],t[2]/100,t[3]/100,1):(t=$Ue.exec(e))?tK(t[1],t[2]/100,t[3]/100,t[4]):Q9.hasOwnProperty(e)?J9(Q9[e]):e==="transparent"?new Jo(NaN,NaN,NaN,0):null}function J9(e){return new Jo(e>>16&255,e>>8&255,e&255,1)}function BC(e,t,n,r){return r<=0&&(e=t=n=NaN),new Jo(e,t,n,r)}function QUe(e){return e instanceof m1||(e=wx(e)),e?(e=e.rgb(),new Jo(e.r,e.g,e.b,e.opacity)):new Jo}function KM(e,t,n,r){return arguments.length===1?QUe(e):new Jo(e,t,n,r??1)}function Jo(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}m5(Jo,KM,Ore(m1,{brighter(e){return e=e==null?$M:Math.pow($M,e),new Jo(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vx:Math.pow(vx,e),new Jo(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Jo(Lp(this.r),Lp(this.g),Lp(this.b),YM(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Z9,formatHex:Z9,formatHex8:GUe,formatRgb:eK,toString:eK}));function Z9(){return`#${Np(this.r)}${Np(this.g)}${Np(this.b)}`}function GUe(){return`#${Np(this.r)}${Np(this.g)}${Np(this.b)}${Np((isNaN(this.opacity)?1:this.opacity)*255)}`}function eK(){let e=YM(this.opacity);return`${e===1?"rgb(":"rgba("}${Lp(this.r)}, ${Lp(this.g)}, ${Lp(this.b)}${e===1?")":`, ${e})`}`}function YM(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Lp(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Np(e){return e=Lp(e),(e<16?"0":"")+e.toString(16)}function tK(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new rl(e,t,n,r)}function Tre(e){if(e instanceof rl)return new rl(e.h,e.s,e.l,e.opacity);if(e instanceof m1||(e=wx(e)),!e)return new rl;if(e instanceof rl)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),s=NaN,a=o-i,l=(o+i)/2;return a?(t===o?s=(n-r)/a+(n<r)*6:n===o?s=(r-t)/a+2:s=(t-n)/a+4,a/=l<.5?o+i:2-o-i,s*=60):a=l>0&&l<1?0:s,new rl(s,a,l,e.opacity)}function XUe(e,t,n,r){return arguments.length===1?Tre(e):new rl(e,t,n,r??1)}function rl(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}m5(rl,XUe,Ore(m1,{brighter(e){return e=e==null?$M:Math.pow($M,e),new rl(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vx:Math.pow(vx,e),new rl(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Jo(SR(e>=240?e-240:e+120,i,r),SR(e,i,r),SR(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new rl(nK(this.h),qC(this.s),qC(this.l),YM(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=YM(this.opacity);return`${e===1?"hsl(":"hsla("}${nK(this.h)}, ${qC(this.s)*100}%, ${qC(this.l)*100}%${e===1?")":`, ${e})`}`}}));function nK(e){return e=(e||0)%360,e<0?e+360:e}function qC(e){return Math.max(0,Math.min(1,e||0))}function SR(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}function Are(e,t,n,r,i){var o=e*e,s=o*e;return((1-3*e+3*o-s)*t+(4-6*o+3*s)*n+(1+3*e+3*o-3*s)*r+s*i)/6}function JUe(e){var t=e.length-1;return function(n){var r=n<=0?n=0:n>=1?(n=1,t-1):Math.floor(n*t),i=e[r],o=e[r+1],s=r>0?e[r-1]:2*i-o,a=r<t-1?e[r+2]:2*o-i;return Are((n-r/t)*t,s,i,o,a)}}function ZUe(e){var t=e.length;return function(n){var r=Math.floor(((n%=1)<0?++n:n)*t),i=e[(r+t-1)%t],o=e[r%t],s=e[(r+1)%t],a=e[(r+2)%t];return Are((n-r/t)*t,i,o,s,a)}}var Dre=e=>()=>e;function e6e(e,t){return function(n){return e+n*t}}function t6e(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function n6e(e){return(e=+e)==1?Rre:function(t,n){return n-t?t6e(t,n,e):Dre(isNaN(t)?n:t)}}function Rre(e,t){var n=t-e;return n?e6e(e,n):Dre(isNaN(e)?t:e)}var rK=function e(t){var n=n6e(t);function r(i,o){var s=n((i=KM(i)).r,(o=KM(o)).r),a=n(i.g,o.g),l=n(i.b,o.b),u=Rre(i.opacity,o.opacity);return function(c){return i.r=s(c),i.g=a(c),i.b=l(c),i.opacity=u(c),i+""}}return r.gamma=e,r}(1);function Ire(e){return function(t){var n=t.length,r=new Array(n),i=new Array(n),o=new Array(n),s,a;for(s=0;s<n;++s)a=KM(t[s]),r[s]=a.r||0,i[s]=a.g||0,o[s]=a.b||0;return r=e(r),i=e(i),o=e(o),a.opacity=1,function(l){return a.r=r(l),a.g=i(l),a.b=o(l),a+""}}}var Pyt=Ire(JUe),Lyt=Ire(ZUe);function Zd(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var uL=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,kR=new RegExp(uL.source,"g");function r6e(e){return function(){return e}}function i6e(e){return function(t){return e(t)+""}}function o6e(e,t){var n=uL.lastIndex=kR.lastIndex=0,r,i,o,s=-1,a=[],l=[];for(e=e+"",t=t+"";(r=uL.exec(e))&&(i=kR.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),a[s]?a[s]+=o:a[++s]=o),(r=r[0])===(i=i[0])?a[s]?a[s]+=i:a[++s]=i:(a[++s]=null,l.push({i:s,x:Zd(r,i)})),n=kR.lastIndex;return n<t.length&&(o=t.slice(n),a[s]?a[s]+=o:a[++s]=o),a.length<2?l[0]?i6e(l[0].x):r6e(t):(t=l.length,function(u){for(var c=0,d;c<t;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var iK=180/Math.PI,cL={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pre(e,t,n,r,i,o){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*r)&&(n-=e*l,r-=t*l),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,l/=a),e*r<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*iK,skewX:Math.atan(l)*iK,scaleX:s,scaleY:a}}var zC;function s6e(e){let t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?cL:Pre(t.a,t.b,t.c,t.d,t.e,t.f)}function a6e(e){return e==null?cL:(zC||(zC=document.createElementNS("http://www.w3.org/2000/svg","g")),zC.setAttribute("transform",e),(e=zC.transform.baseVal.consolidate())?(e=e.matrix,Pre(e.a,e.b,e.c,e.d,e.e,e.f)):cL)}function Lre(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function o(u,c,d,h,f,p){if(u!==d||c!==h){var m=f.push("translate(",null,t,null,n);p.push({i:m-4,x:Zd(u,d)},{i:m-2,x:Zd(c,h)})}else(d||h)&&f.push("translate("+d+t+h+n)}function s(u,c,d,h){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),h.push({i:d.push(i(d)+"rotate(",null,r)-2,x:Zd(u,c)})):c&&d.push(i(d)+"rotate("+c+r)}function a(u,c,d,h){u!==c?h.push({i:d.push(i(d)+"skewX(",null,r)-2,x:Zd(u,c)}):c&&d.push(i(d)+"skewX("+c+r)}function l(u,c,d,h,f,p){if(u!==d||c!==h){var m=f.push(i(f)+"scale(",null,",",null,")");p.push({i:m-4,x:Zd(u,d)},{i:m-2,x:Zd(c,h)})}else(d!==1||h!==1)&&f.push(i(f)+"scale("+d+","+h+")")}return function(u,c){var d=[],h=[];return u=e(u),c=e(c),o(u.translateX,u.translateY,c.translateX,c.translateY,d,h),s(u.rotate,c.rotate,d,h),a(u.skewX,c.skewX,d,h),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,h),u=c=null,function(f){for(var p=-1,m=h.length,g;++p<m;)d[(g=h[p]).i]=g.x(f);return d.join("")}}}var l6e=Lre(s6e,"px, ","px)","deg)"),u6e=Lre(a6e,", ",")",")"),c6e=1e-12;function oK(e){return((e=Math.exp(e))+1/e)/2}function d6e(e){return((e=Math.exp(e))-1/e)/2}function h6e(e){return((e=Math.exp(2*e))-1)/(e+1)}var f6e=function e(t,n,r){function i(o,s){var a=o[0],l=o[1],u=o[2],c=s[0],d=s[1],h=s[2],f=c-a,p=d-l,m=f*f+p*p,g,y;if(m<c6e)y=Math.log(h/u)/t,g=function(k){return[a+k*f,l+k*p,u*Math.exp(t*k*y)]};else{var v=Math.sqrt(m),b=(h*h-u*u+r*m)/(2*u*n*v),w=(h*h-u*u-r*m)/(2*h*n*v),x=Math.log(Math.sqrt(b*b+1)-b),S=Math.log(Math.sqrt(w*w+1)-w);y=(S-x)/t,g=function(k){var C=k*y,N=oK(x),E=u/(n*v)*(N*h6e(t*C+x)-d6e(x));return[a+E*f,l+E*p,u*N/oK(t*C+x)]}}return g.duration=y*1e3*t/Math.SQRT2,g}return i.rho=function(o){var s=Math.max(.001,+o),a=s*s,l=a*a;return e(s,a,l)},i}(Math.SQRT2,2,4),tv=0,uw=0,zb=0,Bre=1e3,QM,cw,GM=0,im=0,ME=0,xx=typeof performance=="object"&&performance.now?performance:Date,qre=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function g5(){return im||(qre(p6e),im=xx.now()+ME)}function p6e(){im=0}function XM(){this._call=this._time=this._next=null}XM.prototype=zre.prototype={constructor:XM,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?g5():+n)+(t==null?0:+t),!this._next&&cw!==this&&(cw?cw._next=this:QM=this,cw=this),this._call=e,this._time=n,dL()},stop:function(){this._call&&(this._call=null,this._time=1/0,dL())}};function zre(e,t,n){var r=new XM;return r.restart(e,t,n),r}function m6e(){g5(),++tv;for(var e=QM,t;e;)(t=im-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tv}function sK(){im=(GM=xx.now())+ME,tv=uw=0;try{m6e()}finally{tv=0,y6e(),im=0}}function g6e(){var e=xx.now(),t=e-GM;t>Bre&&(ME-=t,GM=e)}function y6e(){for(var e,t=QM,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:QM=n);cw=e,dL(r)}function dL(e){if(!tv){uw&&(uw=clearTimeout(uw));var t=e-im;t>24?(e<1/0&&(uw=setTimeout(sK,e-xx.now()-ME)),zb&&(zb=clearInterval(zb))):(zb||(GM=xx.now(),zb=setInterval(g6e,Bre)),tv=1,qre(sK))}}function aK(e,t,n){var r=new XM;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var v6e=h5("start","end","cancel","interrupt"),b6e=[],Fre=0,lK=1,hL=2,WN=3,uK=4,fL=5,UN=6;function _E(e,t,n,r,i,o){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;w6e(e,n,{name:t,index:r,group:i,on:v6e,tween:b6e,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Fre})}function y5(e,t){var n=Sl(e,t);if(n.state>Fre)throw new Error("too late; already scheduled");return n}function Eu(e,t){var n=Sl(e,t);if(n.state>WN)throw new Error("too late; already running");return n}function Sl(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function w6e(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=zre(o,0,n.time);function o(u){n.state=lK,n.timer.restart(s,n.delay,n.time),n.delay<=u&&s(u-n.delay)}function s(u){var c,d,h,f;if(n.state!==lK)return l();for(c in r)if(f=r[c],f.name===n.name){if(f.state===WN)return aK(s);f.state===uK?(f.state=UN,f.timer.stop(),f.on.call("interrupt",e,e.__data__,f.index,f.group),delete r[c]):+c<t&&(f.state=UN,f.timer.stop(),f.on.call("cancel",e,e.__data__,f.index,f.group),delete r[c])}if(aK(function(){n.state===WN&&(n.state=uK,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=hL,n.on.call("start",e,e.__data__,n.index,n.group),n.state===hL){for(n.state=WN,i=new Array(h=n.tween.length),c=0,d=-1;c<h;++c)(f=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(i[++d]=f);i.length=d+1}}function a(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(l),n.state=fL,1),d=-1,h=i.length;++d<h;)i[d].call(e,c);n.state===fL&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=UN,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function HN(e,t){var n=e.__transition,r,i,o=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){o=!1;continue}i=r.state>hL&&r.state<fL,r.state=UN,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}o&&delete e.__transition}}function x6e(e){return this.each(function(){HN(this,e)})}function S6e(e,t){var n,r;return function(){var i=Eu(this,e),o=i.tween;if(o!==n){r=n=o;for(var s=0,a=r.length;s<a;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}i.tween=r}}function k6e(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Eu(this,e),s=o.tween;if(s!==r){i=(r=s).slice();for(var a={name:t,value:n},l=0,u=i.length;l<u;++l)if(i[l].name===t){i[l]=a;break}l===u&&i.push(a)}o.tween=i}}function C6e(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Sl(this.node(),n).tween,i=0,o=r.length,s;i<o;++i)if((s=r[i]).name===e)return s.value;return null}return this.each((t==null?S6e:k6e)(n,e,t))}function v5(e,t,n){var r=e._id;return e.each(function(){var i=Eu(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Sl(i,r).value[t]}}function jre(e,t){var n;return(typeof t=="number"?Zd:t instanceof wx?rK:(n=wx(t))?(t=n,rK):o6e)(e,t)}function N6e(e){return function(){this.removeAttribute(e)}}function M6e(e){return function(){this.removeAttributeNS(e.space,e.local)}}function _6e(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttribute(e);return s===i?null:s===r?o:o=t(r=s,n)}}function E6e(e,t,n){var r,i=n+"",o;return function(){var s=this.getAttributeNS(e.space,e.local);return s===i?null:s===r?o:o=t(r=s,n)}}function O6e(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function T6e(e,t,n){var r,i,o;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a)))}}function A6e(e,t){var n=NE(e),r=n==="transform"?u6e:jre;return this.attrTween(e,typeof t=="function"?(n.local?T6e:O6e)(n,r,v5(this,"attr."+e,t)):t==null?(n.local?M6e:N6e)(n):(n.local?E6e:_6e)(n,r,t))}function D6e(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function R6e(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function I6e(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&R6e(e,o)),n}return i._value=t,i}function P6e(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&D6e(e,o)),n}return i._value=t,i}function L6e(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=NE(e);return this.tween(n,(r.local?I6e:P6e)(r,t))}function B6e(e,t){return function(){y5(this,e).delay=+t.apply(this,arguments)}}function q6e(e,t){return t=+t,function(){y5(this,e).delay=t}}function z6e(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?B6e:q6e)(t,e)):Sl(this.node(),t).delay}function F6e(e,t){return function(){Eu(this,e).duration=+t.apply(this,arguments)}}function j6e(e,t){return t=+t,function(){Eu(this,e).duration=t}}function V6e(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?F6e:j6e)(t,e)):Sl(this.node(),t).duration}function W6e(e,t){if(typeof t!="function")throw new Error;return function(){Eu(this,e).ease=t}}function U6e(e){var t=this._id;return arguments.length?this.each(W6e(t,e)):Sl(this.node(),t).ease}function H6e(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Eu(this,e).ease=n}}function $6e(e){if(typeof e!="function")throw new Error;return this.each(H6e(this._id,e))}function K6e(e){typeof e!="function"&&(e=gre(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],s=o.length,a=r[i]=[],l,u=0;u<s;++u)(l=o[u])&&e.call(l,l.__data__,u,o)&&a.push(l);return new Fc(r,this._parents,this._name,this._id)}function Y6e(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),s=new Array(r),a=0;a<o;++a)for(var l=t[a],u=n[a],c=l.length,d=s[a]=new Array(c),h,f=0;f<c;++f)(h=l[f]||u[f])&&(d[f]=h);for(;a<r;++a)s[a]=t[a];return new Fc(s,this._parents,this._name,this._id)}function Q6e(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function G6e(e,t,n){var r,i,o=Q6e(t)?y5:Eu;return function(){var s=o(this,e),a=s.on;a!==r&&(i=(r=a).copy()).on(t,n),s.on=i}}function X6e(e,t){var n=this._id;return arguments.length<2?Sl(this.node(),n).on.on(e):this.each(G6e(n,e,t))}function J6e(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Z6e(){return this.on("end.remove",J6e(this._id))}function eHe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=f5(e));for(var r=this._groups,i=r.length,o=new Array(i),s=0;s<i;++s)for(var a=r[s],l=a.length,u=o[s]=new Array(l),c,d,h=0;h<l;++h)(c=a[h])&&(d=e.call(c,c.__data__,h,a))&&("__data__"in c&&(d.__data__=c.__data__),u[h]=d,_E(u[h],t,n,h,u,Sl(c,n)));return new Fc(o,this._parents,t,n)}function tHe(e){var t=this._name,n=this._id;typeof e!="function"&&(e=mre(e));for(var r=this._groups,i=r.length,o=[],s=[],a=0;a<i;++a)for(var l=r[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var h=e.call(c,c.__data__,d,l),f,p=Sl(c,n),m=0,g=h.length;m<g;++m)(f=h[m])&&_E(f,t,n,m,h,p);o.push(h),s.push(c)}return new Fc(o,s,t,n)}var nHe=p1.prototype.constructor;function rHe(){return new nHe(this._groups,this._parents)}function iHe(e,t){var n,r,i;return function(){var o=ev(this,e),s=(this.style.removeProperty(e),ev(this,e));return o===s?null:o===n&&s===r?i:i=t(n=o,r=s)}}function Vre(e){return function(){this.style.removeProperty(e)}}function oHe(e,t,n){var r,i=n+"",o;return function(){var s=ev(this,e);return s===i?null:s===r?o:o=t(r=s,n)}}function sHe(e,t,n){var r,i,o;return function(){var s=ev(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),ev(this,e))),s===l?null:s===r&&l===i?o:(i=l,o=t(r=s,a))}}function aHe(e,t){var n,r,i,o="style."+t,s="end."+o,a;return function(){var l=Eu(this,e),u=l.on,c=l.value[o]==null?a||(a=Vre(t)):void 0;(u!==n||i!==c)&&(r=(n=u).copy()).on(s,i=c),l.on=r}}function lHe(e,t,n){var r=(e+="")=="transform"?l6e:jre;return t==null?this.styleTween(e,iHe(e,r)).on("end.style."+e,Vre(e)):typeof t=="function"?this.styleTween(e,sHe(e,r,v5(this,"style."+e,t))).each(aHe(this._id,e)):this.styleTween(e,oHe(e,r,t),n).on("end.style."+e,null)}function uHe(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function cHe(e,t,n){var r,i;function o(){var s=t.apply(this,arguments);return s!==i&&(r=(i=s)&&uHe(e,s,n)),r}return o._value=t,o}function dHe(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,cHe(e,t,n??""))}function hHe(e){return function(){this.textContent=e}}function fHe(e){return function(){var t=e(this);this.textContent=t??""}}function pHe(e){return this.tween("text",typeof e=="function"?fHe(v5(this,"text",e)):hHe(e==null?"":e+""))}function mHe(e){return function(t){this.textContent=e.call(this,t)}}function gHe(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&mHe(i)),t}return r._value=e,r}function yHe(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,gHe(e))}function vHe(){for(var e=this._name,t=this._id,n=Wre(),r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,u=0;u<a;++u)if(l=s[u]){var c=Sl(l,t);_E(l,e,n,u,s,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Fc(r,this._parents,e,n)}function bHe(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,s){var a={value:s},l={value:function(){--i===0&&o()}};n.each(function(){var u=Eu(this,r),c=u.on;c!==e&&(t=(e=c).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),u.on=t}),i===0&&o()})}var wHe=0;function Fc(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function xHe(e){return p1().transition(e)}function Wre(){return++wHe}var dc=p1.prototype;Fc.prototype=xHe.prototype={constructor:Fc,select:eHe,selectAll:tHe,selectChild:dc.selectChild,selectChildren:dc.selectChildren,filter:K6e,merge:Y6e,selection:rHe,transition:vHe,call:dc.call,nodes:dc.nodes,node:dc.node,size:dc.size,empty:dc.empty,each:dc.each,on:X6e,attr:A6e,attrTween:L6e,style:lHe,styleTween:dHe,text:pHe,textTween:yHe,remove:Z6e,tween:C6e,delay:z6e,duration:V6e,ease:U6e,easeVarying:$6e,end:bHe,[Symbol.iterator]:dc[Symbol.iterator]};function SHe(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var kHe={time:null,delay:0,duration:250,ease:SHe};function CHe(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function NHe(e){var t,n;e instanceof Fc?(t=e._id,e=e._name):(t=Wre(),(n=kHe).time=g5(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var s=r[o],a=s.length,l,u=0;u<a;++u)(l=s[u])&&_E(l,e,t,u,s,n||CHe(l,t));return new Fc(r,this._parents,e,t)}p1.prototype.interrupt=x6e;p1.prototype.transition=NHe;var FC=e=>()=>e;function MHe(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Cc(e,t,n){this.k=e,this.x=t,this.y=n}Cc.prototype={constructor:Cc,scale:function(e){return e===1?this:new Cc(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Cc(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var mu=new Cc(1,0,0);_He.prototype=Cc.prototype;function _He(e){for(;!e.__zoom;)if(!(e=e.parentNode))return mu;return e.__zoom}function CR(e){e.stopImmediatePropagation()}function Fb(e){e.preventDefault(),e.stopImmediatePropagation()}function EHe(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function OHe(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function cK(){return this.__zoom||mu}function THe(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function AHe(){return navigator.maxTouchPoints||"ontouchstart"in this}function DHe(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s))}function Ure(){var e=EHe,t=OHe,n=DHe,r=THe,i=AHe,o=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=f6e,u=h5("start","zoom","end"),c,d,h,f=500,p=150,m=0,g=10;function y(_){_.property("__zoom",cK).on("wheel.zoom",C,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",E).filter(i).on("touchstart.zoom",D).on("touchmove.zoom",q).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,R,T,B){var A=_.selection?_.selection():_;A.property("__zoom",cK),_!==A?x(_,R,T,B):A.interrupt().each(function(){S(this,arguments).event(B).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},y.scaleBy=function(_,R,T,B){y.scaleTo(_,function(){var A=this.__zoom.k,M=typeof R=="function"?R.apply(this,arguments):R;return A*M},T,B)},y.scaleTo=function(_,R,T,B){y.transform(_,function(){var A=t.apply(this,arguments),M=this.__zoom,P=T==null?w(A):typeof T=="function"?T.apply(this,arguments):T,F=M.invert(P),I=typeof R=="function"?R.apply(this,arguments):R;return n(b(v(M,I),P,F),A,s)},T,B)},y.translateBy=function(_,R,T,B){y.transform(_,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof T=="function"?T.apply(this,arguments):T),t.apply(this,arguments),s)},null,B)},y.translateTo=function(_,R,T,B,A){y.transform(_,function(){var M=t.apply(this,arguments),P=this.__zoom,F=B==null?w(M):typeof B=="function"?B.apply(this,arguments):B;return n(mu.translate(F[0],F[1]).scale(P.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof T=="function"?-T.apply(this,arguments):-T),M,s)},B,A)};function v(_,R){return R=Math.max(o[0],Math.min(o[1],R)),R===_.k?_:new Cc(R,_.x,_.y)}function b(_,R,T){var B=R[0]-T[0]*_.k,A=R[1]-T[1]*_.k;return B===_.x&&A===_.y?_:new Cc(_.k,B,A)}function w(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function x(_,R,T,B){_.on("start.zoom",function(){S(this,arguments).event(B).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(B).end()}).tween("zoom",function(){var A=this,M=arguments,P=S(A,M).event(B),F=t.apply(A,M),I=T==null?w(F):typeof T=="function"?T.apply(A,M):T,V=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),W=A.__zoom,j=typeof R=="function"?R.apply(A,M):R,X=l(W.invert(I).concat(V/W.k),j.invert(I).concat(V/j.k));return function($){if($===1)$=j;else{var K=X($),Q=V/K[2];$=new Cc(Q,I[0]-K[0]*Q,I[1]-K[1]*Q)}P.zoom(null,$)}})}function S(_,R,T){return!T&&_.__zooming||new k(_,R)}function k(_,R){this.that=_,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,R),this.taps=0}k.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,R){return this.mouse&&_!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var R=pa(this.that).datum();u.call(_,this.that,new MHe(_,{sourceEvent:this.sourceEvent,target:y,type:_,transform:this.that.__zoom,dispatch:u}),R)}};function C(_,...R){if(!e.apply(this,arguments))return;var T=S(this,R).event(_),B=this.__zoom,A=Math.max(o[0],Math.min(o[1],B.k*Math.pow(2,r.apply(this,arguments)))),M=nl(_);if(T.wheel)(T.mouse[0][0]!==M[0]||T.mouse[0][1]!==M[1])&&(T.mouse[1]=B.invert(T.mouse[0]=M)),clearTimeout(T.wheel);else{if(B.k===A)return;T.mouse=[M,B.invert(M)],HN(this),T.start()}Fb(_),T.wheel=setTimeout(P,p),T.zoom("mouse",n(b(v(B,A),T.mouse[0],T.mouse[1]),T.extent,s));function P(){T.wheel=null,T.end()}}function N(_,...R){if(h||!e.apply(this,arguments))return;var T=_.currentTarget,B=S(this,R,!0).event(_),A=pa(_.view).on("mousemove.zoom",I,!0).on("mouseup.zoom",V,!0),M=nl(_,T),P=_.clientX,F=_.clientY;_re(_.view),CR(_),B.mouse=[M,this.__zoom.invert(M)],HN(this),B.start();function I(W){if(Fb(W),!B.moved){var j=W.clientX-P,X=W.clientY-F;B.moved=j*j+X*X>m}B.event(W).zoom("mouse",n(b(B.that.__zoom,B.mouse[0]=nl(W,T),B.mouse[1]),B.extent,s))}function V(W){A.on("mousemove.zoom mouseup.zoom",null),Ere(W.view,B.moved),Fb(W),B.event(W).end()}}function E(_,...R){if(e.apply(this,arguments)){var T=this.__zoom,B=nl(_.changedTouches?_.changedTouches[0]:_,this),A=T.invert(B),M=T.k*(_.shiftKey?.5:2),P=n(b(v(T,M),B,A),t.apply(this,R),s);Fb(_),a>0?pa(this).transition().duration(a).call(x,P,B,_):pa(this).call(y.transform,P,B,_)}}function D(_,...R){if(e.apply(this,arguments)){var T=_.touches,B=T.length,A=S(this,R,_.changedTouches.length===B).event(_),M,P,F,I;for(CR(_),P=0;P<B;++P)F=T[P],I=nl(F,this),I=[I,this.__zoom.invert(I),F.identifier],A.touch0?!A.touch1&&A.touch0[2]!==I[2]&&(A.touch1=I,A.taps=0):(A.touch0=I,M=!0,A.taps=1+!!c);c&&(c=clearTimeout(c)),M&&(A.taps<2&&(d=I[0],c=setTimeout(function(){c=null},f)),HN(this),A.start())}}function q(_,...R){if(this.__zooming){var T=S(this,R).event(_),B=_.changedTouches,A=B.length,M,P,F,I;for(Fb(_),M=0;M<A;++M)P=B[M],F=nl(P,this),T.touch0&&T.touch0[2]===P.identifier?T.touch0[0]=F:T.touch1&&T.touch1[2]===P.identifier&&(T.touch1[0]=F);if(P=T.that.__zoom,T.touch1){var V=T.touch0[0],W=T.touch0[1],j=T.touch1[0],X=T.touch1[1],$=($=j[0]-V[0])*$+($=j[1]-V[1])*$,K=(K=X[0]-W[0])*K+(K=X[1]-W[1])*K;P=v(P,Math.sqrt($/K)),F=[(V[0]+j[0])/2,(V[1]+j[1])/2],I=[(W[0]+X[0])/2,(W[1]+X[1])/2]}else if(T.touch0)F=T.touch0[0],I=T.touch0[1];else return;T.zoom("touch",n(b(P,F,I),T.extent,s))}}function z(_,...R){if(this.__zooming){var T=S(this,R).event(_),B=_.changedTouches,A=B.length,M,P;for(CR(_),h&&clearTimeout(h),h=setTimeout(function(){h=null},f),M=0;M<A;++M)P=B[M],T.touch0&&T.touch0[2]===P.identifier?delete T.touch0:T.touch1&&T.touch1[2]===P.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(P=nl(P,this),Math.hypot(d[0]-P[0],d[1]-P[1])<g)){var F=pa(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:FC(+_),y):r},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:FC(!!_),y):e},y.touchable=function(_){return arguments.length?(i=typeof _=="function"?_:FC(!!_),y):i},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:FC([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(o[0]=+_[0],o[1]=+_[1],y):[o[0],o[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(l=_,y):l},y.on=function(){var _=u.on.apply(u,arguments);return _===u?y:_},y.clickDistance=function(_){return arguments.length?(m=(_=+_)*_,y):Math.sqrt(m)},y.tapDistance=function(_){return arguments.length?(g=+_,y):g},y}var EE=(0,U.createContext)(null),RHe=EE.Provider,xu={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},Hre=xu.error001();function Vn(e,t){let n=(0,U.useContext)(EE);if(n===null)throw new Error(Hre);return hre(n,e,t)}var mi=()=>{let e=(0,U.useContext)(EE);if(e===null)throw new Error(Hre);return(0,U.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},IHe=e=>e.userSelectionActive?"none":"all";function b5({position:e,children:t,className:n,style:r,...i}){let o=Vn(IHe),s=`${e}`.split("-");return U.default.createElement("div",{className:Ui(["react-flow__panel",n,...s]),style:{...r,pointerEvents:o},...i},t)}function PHe({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:U.default.createElement(b5,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},U.default.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var LHe=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:o={},labelBgPadding:s=[2,4],labelBgBorderRadius:a=2,children:l,className:u,...c})=>{let d=(0,U.useRef)(null),[h,f]=(0,U.useState)({x:0,y:0,width:0,height:0}),p=Ui(["react-flow__edge-textwrapper",u]);return(0,U.useEffect)(()=>{if(d.current){let m=d.current.getBBox();f({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:U.default.createElement("g",{transform:`translate(${e-h.width/2} ${t-h.height/2})`,className:p,visibility:h.width?"visible":"hidden",...c},i&&U.default.createElement("rect",{width:h.width+2*s[0],x:-s[0],y:-s[1],height:h.height+2*s[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),U.default.createElement("text",{className:"react-flow__edge-text",y:h.height/2,dy:"0.3em",ref:d,style:r},n),l)},BHe=(0,U.memo)(LHe),w5=e=>({width:e.offsetWidth,height:e.offsetHeight}),nv=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),x5=(e={x:0,y:0},t)=>({x:nv(e.x,t[0][0],t[1][0]),y:nv(e.y,t[0][1],t[1][1])}),dK=(e,t,n)=>e<t?nv(Math.abs(e-t),1,50)/50:e>n?-nv(Math.abs(e-n),1,50)/50:0,$re=(e,t)=>{let n=dK(e.x,35,t.width-35)*20,r=dK(e.y,35,t.height-35)*20;return[n,r]},Kre=e=>e.getRootNode?.()||window?.document,Yre=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Sx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Qre=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),hK=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),qHe=(e,t)=>Qre(Yre(Sx(e),Sx(t))),pL=(e,t)=>{let n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},zHe=e=>va(e.width)&&va(e.height)&&va(e.x)&&va(e.y),va=e=>!isNaN(e)&&isFinite(e),Cr=Symbol.for("internals"),Gre=["Enter"," ","Escape"],Xre=(e,t)=>{},FHe=e=>"nativeEvent"in e;function mL(e){let t=(FHe(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(t?.nodeName)||t?.hasAttribute("contenteditable")||!!t?.closest(".nokey")}var Jre=e=>"clientX"in e,xh=(e,t)=>{let n=Jre(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},JM=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,g1=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:h,interactionWidth:f=20})=>U.default.createElement(U.default.Fragment,null,U.default.createElement("path",{id:e,style:c,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:h}),f&&U.default.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),i&&va(n)&&va(r)?U.default.createElement(BHe,{x:n,y:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u}):null);g1.displayName="BaseEdge";function jb(e,t,n){return n===void 0?n:r=>{let i=t().edges.find(o=>o.id===e);i&&n(r,{...i})}}function Zre({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,o=n<e?n+i:n-i,s=Math.abs(r-t)/2,a=r<t?r+s:r-s;return[o,a,i,s]}function eie({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:s,targetControlY:a}){let l=e*.125+i*.375+s*.375+n*.125,u=t*.125+o*.375+a*.375+r*.125,c=Math.abs(l-e),d=Math.abs(u-t);return[l,u,c,d]}var om;(function(e){e.Strict="strict",e.Loose="loose"})(om||(om={}));var Mp;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Mp||(Mp={}));var kx;(function(e){e.Partial="partial",e.Full="full"})(kx||(kx={}));var wc;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(wc||(wc={}));var ZM;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ZM||(ZM={}));var Ue;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ue||(Ue={}));function fK({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Ue.Left||e===Ue.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function tie({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:i,targetPosition:o=Ue.Top}){let[s,a]=fK({pos:n,x1:e,y1:t,x2:r,y2:i}),[l,u]=fK({pos:o,x1:r,y1:i,x2:e,y2:t}),[c,d,h,f]=eie({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:a,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${a} ${l},${u} ${r},${i}`,c,d,h,f]}var S5=(0,U.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Ue.Bottom,targetPosition:o=Ue.Top,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:p,interactionWidth:m})=>{let[g,y,v]=tie({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o});return U.default.createElement(g1,{path:g,labelX:y,labelY:v,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:p,interactionWidth:m})});S5.displayName="SimpleBezierEdge";var pK={[Ue.Left]:{x:-1,y:0},[Ue.Right]:{x:1,y:0},[Ue.Top]:{x:0,y:-1},[Ue.Bottom]:{x:0,y:1}},jHe=({source:e,sourcePosition:t=Ue.Bottom,target:n})=>t===Ue.Left||t===Ue.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},mK=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function VHe({source:e,sourcePosition:t=Ue.Bottom,target:n,targetPosition:r=Ue.Top,center:i,offset:o}){let s=pK[t],a=pK[r],l={x:e.x+s.x*o,y:e.y+s.y*o},u={x:n.x+a.x*o,y:n.y+a.y*o},c=jHe({source:l,sourcePosition:t,target:u}),d=c.x!==0?"x":"y",h=c[d],f=[],p,m,g={x:0,y:0},y={x:0,y:0},[v,b,w,x]=Zre({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[d]*a[d]===-1){p=i.x??v,m=i.y??b;let S=[{x:p,y:l.y},{x:p,y:u.y}],k=[{x:l.x,y:m},{x:u.x,y:m}];s[d]===h?f=d==="x"?S:k:f=d==="x"?k:S}else{let S=[{x:l.x,y:u.y}],k=[{x:u.x,y:l.y}];if(d==="x"?f=s.x===h?k:S:f=s.y===h?S:k,t===r){let q=Math.abs(e[d]-n[d]);if(q<=o){let z=Math.min(o-1,o-q);s[d]===h?g[d]=(l[d]>e[d]?-1:1)*z:y[d]=(u[d]>n[d]?-1:1)*z}}if(t!==r){let q=d==="x"?"y":"x",z=s[d]===a[q],_=l[q]>u[q],R=l[q]<u[q];(s[d]===1&&(!z&&_||z&&R)||s[d]!==1&&(!z&&R||z&&_))&&(f=d==="x"?S:k)}let C={x:l.x+g.x,y:l.y+g.y},N={x:u.x+y.x,y:u.y+y.y},E=Math.max(Math.abs(C.x-f[0].x),Math.abs(N.x-f[0].x)),D=Math.max(Math.abs(C.y-f[0].y),Math.abs(N.y-f[0].y));E>=D?(p=(C.x+N.x)/2,m=f[0].y):(p=f[0].x,m=(C.y+N.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...f,{x:u.x+y.x,y:u.y+y.y},n],p,m,w,x]}function WHe(e,t,n,r){let i=Math.min(mK(e,t)/2,mK(t,n)/2,r),{x:o,y:s}=t;if(e.x===o&&o===n.x||e.y===s&&s===n.y)return`L${o} ${s}`;if(e.y===s){let u=e.x<n.x?-1:1,c=e.y<n.y?1:-1;return`L ${o+i*u},${s}Q ${o},${s} ${o},${s+i*c}`}let a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${o},${s+i*l}Q ${o},${s} ${o+i*a},${s}`}function gL({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:i,targetPosition:o=Ue.Top,borderRadius:s=5,centerX:a,centerY:l,offset:u=20}){let[c,d,h,f,p]=VHe({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:a,y:l},offset:u});return[c.reduce((m,g,y)=>{let v="";return y>0&&y<c.length-1?v=WHe(c[y-1],g,c[y+1],s):v=`${y===0?"M":"L"}${g.x} ${g.y}`,m+=v,m},""),d,h,f,p]}var OE=(0,U.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,style:c,sourcePosition:d=Ue.Bottom,targetPosition:h=Ue.Top,markerEnd:f,markerStart:p,pathOptions:m,interactionWidth:g})=>{let[y,v,b]=gL({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:h,borderRadius:m?.borderRadius,offset:m?.offset});return U.default.createElement(g1,{path:y,labelX:v,labelY:b,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,style:c,markerEnd:f,markerStart:p,interactionWidth:g})});OE.displayName="SmoothStepEdge";var k5=(0,U.memo)(e=>U.default.createElement(OE,{...e,pathOptions:(0,U.useMemo)(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));k5.displayName="StepEdge";function UHe({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,o,s,a]=Zre({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,s,a]}var C5=(0,U.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:h,interactionWidth:f})=>{let[p,m,g]=UHe({sourceX:e,sourceY:t,targetX:n,targetY:r});return U.default.createElement(g1,{path:p,labelX:m,labelY:g,label:i,labelStyle:o,labelShowBg:s,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,style:c,markerEnd:d,markerStart:h,interactionWidth:f})});C5.displayName="StraightEdge";function jC(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function gK({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Ue.Left:return[t-jC(t-r,o),n];case Ue.Right:return[t+jC(r-t,o),n];case Ue.Top:return[t,n-jC(n-i,o)];case Ue.Bottom:return[t,n+jC(i-n,o)]}}function nie({sourceX:e,sourceY:t,sourcePosition:n=Ue.Bottom,targetX:r,targetY:i,targetPosition:o=Ue.Top,curvature:s=.25}){let[a,l]=gK({pos:n,x1:e,y1:t,x2:r,y2:i,c:s}),[u,c]=gK({pos:o,x1:r,y1:i,x2:e,y2:t,c:s}),[d,h,f,p]=eie({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:u,targetControlY:c});return[`M${e},${t} C${a},${l} ${u},${c} ${r},${i}`,d,h,f,p]}var e_=(0,U.memo)(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Ue.Bottom,targetPosition:o=Ue.Top,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:p,pathOptions:m,interactionWidth:g})=>{let[y,v,b]=nie({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o,curvature:m?.curvature});return U.default.createElement(g1,{path:y,labelX:v,labelY:b,label:s,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:p,interactionWidth:g})});e_.displayName="BezierEdge";var N5=(0,U.createContext)(null),HHe=N5.Provider;N5.Consumer;var $He=()=>(0,U.useContext)(N5),KHe=e=>"id"in e&&"source"in e&&"target"in e,YHe=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,yL=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(n=>`${n}=${e[n]}`).join("&")}`,QHe=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),rie=(e,t)=>{if(!e.source||!e.target)return Xre("006",xu.error006()),t;let n;return KHe(e)?n={...e}:n={...e,id:YHe(e)},QHe(n,t)?t:t.concat(n)},vL=({x:e,y:t},[n,r,i],o,[s,a])=>{let l={x:(e-n)/i,y:(t-r)/i};return o?{x:s*Math.round(l.x/s),y:a*Math.round(l.y/a)}:l},iie=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),Bp=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};let n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},TE=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=e.reduce((r,i)=>{let{x:o,y:s}=Bp(i,t).positionAbsolute;return Yre(r,Sx({x:o,y:s,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Qre(n)},oie=(e,t,[n,r,i]=[0,0,1],o=!1,s=!1,a=[0,0])=>{let l={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},u=[];return e.forEach(c=>{let{width:d,height:h,selectable:f=!0,hidden:p=!1}=c;if(s&&!f||p)return!1;let{positionAbsolute:m}=Bp(c,a),g={x:m.x,y:m.y,width:d||0,height:h||0},y=pL(l,g),v=typeof d>"u"||typeof h>"u"||d===null||h===null,b=o&&y>0,w=(d||0)*(h||0);(v||b||y>=w||c.dragging)&&u.push(c)}),u},sie=(e,t)=>{let n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},aie=(e,t,n,r,i,o=.1)=>{let s=t/(e.width*(1+o)),a=n/(e.height*(1+o)),l=Math.min(s,a),u=nv(l,r,i),c=e.x+e.width/2,d=e.y+e.height/2,h=t/2-c*u,f=n/2-d*u;return{x:h,y:f,zoom:u}},mp=(e,t=0)=>e.transition().duration(t);function yK(e,t,n,r){return(t[n]||[]).reduce((i,o)=>(`${e.id}-${o.id}-${n}`!==r&&i.push({id:o.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+o.x+o.width/2,y:(e.positionAbsolute?.y??0)+o.y+o.height/2}),i),[])}function GHe(e,t,n,r,i,o){let{x:s,y:a}=xh(e),l=t.elementsFromPoint(s,a).find(f=>f.classList.contains("react-flow__handle"));if(l){let f=l.getAttribute("data-nodeid");if(f){let p=M5(void 0,l),m=l.getAttribute("data-handleid"),g=o({nodeId:f,id:m,type:p});if(g){let y=i.find(v=>v.nodeId===f&&v.type===p&&v.id===m);return{handle:{id:m,type:p,nodeId:f,x:y?.x||n.x,y:y?.y||n.y},validHandleResult:g}}}}let u=[],c=1/0;if(i.forEach(f=>{let p=Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2);if(p<=r){let m=o(f);p<=c&&(p<c?u=[{handle:f,validHandleResult:m}]:p===c&&u.push({handle:f,validHandleResult:m}),c=p)}}),!u.length)return{handle:null,validHandleResult:lie()};if(u.length===1)return u[0];let d=u.some(({validHandleResult:f})=>f.isValid),h=u.some(({handle:f})=>f.type==="target");return u.find(({handle:f,validHandleResult:p})=>h?f.type==="target":d?p.isValid:!0)||u[0]}var XHe={source:null,target:null,sourceHandle:null,targetHandle:null},lie=()=>({handleDomNode:null,isValid:!1,connection:XHe,endHandle:null});function uie(e,t,n,r,i,o,s){let a=i==="target",l=s.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),u={...lie(),handleDomNode:l};if(l){let c=M5(void 0,l),d=l.getAttribute("data-nodeid"),h=l.getAttribute("data-handleid"),f=l.classList.contains("connectable"),p=l.classList.contains("connectableend"),m={source:a?d:n,sourceHandle:a?h:r,target:a?n:d,targetHandle:a?r:h};u.connection=m,f&&p&&(t===om.Strict?a&&c==="source"||!a&&c==="target":d!==n||h!==r)&&(u.endHandle={nodeId:d,handleId:h,type:c},u.isValid=o(m))}return u}function JHe({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,o)=>{if(o[Cr]){let{handleBounds:s}=o[Cr],a=[],l=[];s&&(a=yK(o,s,"source",`${t}-${n}-${r}`),l=yK(o,s,"target",`${t}-${n}-${r}`)),i.push(...a,...l)}return i},[])}function M5(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function NR(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function ZHe(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function cie({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:o,setState:s,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:u}){let c=Kre(e.target),{connectionMode:d,domNode:h,autoPanOnConnect:f,connectionRadius:p,onConnectStart:m,panBy:g,getNodes:y,cancelConnection:v}=o(),b=0,w,{x,y:S}=xh(e),k=c?.elementFromPoint(x,S),C=M5(l,k),N=h?.getBoundingClientRect();if(!N||!C)return;let E,D=xh(e,N),q=!1,z=null,_=!1,R=null,T=JHe({nodes:y(),nodeId:n,handleId:t,handleType:C}),B=()=>{if(!f)return;let[P,F]=$re(D,N);g({x:P,y:F}),b=requestAnimationFrame(B)};s({connectionPosition:D,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:C,connectionStartHandle:{nodeId:n,handleId:t,type:C},connectionEndHandle:null}),m?.(e,{nodeId:n,handleId:t,handleType:C});function A(P){let{transform:F}=o();D=xh(P,N);let{handle:I,validHandleResult:V}=GHe(P,c,vL(D,F,!1,[1,1]),p,T,W=>uie(W,d,n,t,i?"target":"source",a,c));if(w=I,q||(B(),q=!0),R=V.handleDomNode,z=V.connection,_=V.isValid,s({connectionPosition:w&&_?iie({x:w.x,y:w.y},F):D,connectionStatus:ZHe(!!w,_),connectionEndHandle:V.endHandle}),!w&&!_&&!R)return NR(E);z.source!==z.target&&R&&(NR(E),E=R,R.classList.add("connecting","react-flow__handle-connecting"),R.classList.toggle("valid",_),R.classList.toggle("react-flow__handle-valid",_))}function M(P){(w||R)&&z&&_&&r?.(z),o().onConnectEnd?.(P),l&&u?.(P),NR(E),v(),cancelAnimationFrame(b),q=!1,_=!1,z=null,R=null,c.removeEventListener("mousemove",A),c.removeEventListener("mouseup",M),c.removeEventListener("touchmove",A),c.removeEventListener("touchend",M)}c.addEventListener("mousemove",A),c.addEventListener("mouseup",M),c.addEventListener("touchmove",A),c.addEventListener("touchend",M)}var vK=()=>!0,e$e=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),t$e=(e,t,n)=>r=>{let{connectionStartHandle:i,connectionEndHandle:o,connectionClickStartHandle:s}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||o?.nodeId===e&&o?.handleId===t&&o?.type===n,clickConnecting:s?.nodeId===e&&s?.handleId===t&&s?.type===n}},die=(0,U.forwardRef)(({type:e="source",position:t=Ue.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:s,onConnect:a,children:l,className:u,onMouseDown:c,onTouchStart:d,...h},f)=>{let p=s||null,m=e==="target",g=mi(),y=$He(),{connectOnClick:v,noPanClassName:b}=Vn(e$e,_i),{connecting:w,clickConnecting:x}=Vn(t$e(y,p,e),_i);y||g.getState().onError?.("010",xu.error010());let S=N=>{let{defaultEdgeOptions:E,onConnect:D,hasDefaultEdges:q}=g.getState(),z={...E,...N};if(q){let{edges:_,setEdges:R}=g.getState();R(rie(z,_))}D?.(z),a?.(z)},k=N=>{if(!y)return;let E=Jre(N);i&&(E&&N.button===0||!E)&&cie({event:N,handleId:p,nodeId:y,onConnect:S,isTarget:m,getState:g.getState,setState:g.setState,isValidConnection:n||g.getState().isValidConnection||vK}),E?c?.(N):d?.(N)},C=N=>{let{onClickConnectStart:E,onClickConnectEnd:D,connectionClickStartHandle:q,connectionMode:z,isValidConnection:_}=g.getState();if(!y||!q&&!i)return;if(!q){E?.(N,{nodeId:y,handleId:p,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:y,type:e,handleId:p}});return}let R=Kre(N.target),T=n||_||vK,{connection:B,isValid:A}=uie({nodeId:y,id:p,type:e},z,q.nodeId,q.handleId||null,q.type,T,R);A&&S(B),D?.(N),g.setState({connectionClickStartHandle:null})};return U.default.createElement("div",{"data-handleid":p,"data-nodeid":y,"data-handlepos":t,"data-id":`${y}-${p}-${e}`,className:Ui(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",b,u,{source:!m,target:m,connectable:r,connectablestart:i,connectableend:o,connecting:x,connectionindicator:r&&(i&&!w||o&&w)}]),onMouseDown:k,onTouchStart:k,onClick:v?C:void 0,ref:f,...h},l)});die.displayName="Handle";var rv=(0,U.memo)(die),hie=({data:e,isConnectable:t,targetPosition:n=Ue.Top,sourcePosition:r=Ue.Bottom})=>U.default.createElement(U.default.Fragment,null,U.default.createElement(rv,{type:"target",position:n,isConnectable:t}),e?.label,U.default.createElement(rv,{type:"source",position:r,isConnectable:t}));hie.displayName="DefaultNode";var bL=(0,U.memo)(hie),fie=({data:e,isConnectable:t,sourcePosition:n=Ue.Bottom})=>U.default.createElement(U.default.Fragment,null,e?.label,U.default.createElement(rv,{type:"source",position:n,isConnectable:t}));fie.displayName="InputNode";var pie=(0,U.memo)(fie),mie=({data:e,isConnectable:t,targetPosition:n=Ue.Top})=>U.default.createElement(U.default.Fragment,null,U.default.createElement(rv,{type:"target",position:n,isConnectable:t}),e?.label);mie.displayName="OutputNode";var gie=(0,U.memo)(mie),_5=()=>null;_5.displayName="GroupNode";var n$e=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),VC=e=>e.id;function r$e(e,t){return _i(e.selectedNodes.map(VC),t.selectedNodes.map(VC))&&_i(e.selectedEdges.map(VC),t.selectedEdges.map(VC))}var yie=(0,U.memo)(({onSelectionChange:e})=>{let t=mi(),{selectedNodes:n,selectedEdges:r}=Vn(n$e,r$e);return(0,U.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(o=>o(i))},[n,r,e]),null});yie.displayName="SelectionListener";var i$e=e=>!!e.onSelectionChange;function o$e({onSelectionChange:e}){let t=Vn(i$e);return e||t?U.default.createElement(yie,{onSelectionChange:e}):null}var s$e=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Wg(e,t){(0,U.useEffect)(()=>{typeof e<"u"&&t(e)},[e])}function It(e,t,n){(0,U.useEffect)(()=>{typeof t<"u"&&n({[e]:t})},[t])}var a$e=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:o,onConnectEnd:s,onClickConnectStart:a,onClickConnectEnd:l,nodesDraggable:u,nodesConnectable:c,nodesFocusable:d,edgesFocusable:h,edgesUpdatable:f,elevateNodesOnSelect:p,minZoom:m,maxZoom:g,nodeExtent:y,onNodesChange:v,onEdgesChange:b,elementsSelectable:w,connectionMode:x,snapGrid:S,snapToGrid:k,translateExtent:C,connectOnClick:N,defaultEdgeOptions:E,fitView:D,fitViewOptions:q,onNodesDelete:z,onEdgesDelete:_,onNodeDrag:R,onNodeDragStart:T,onNodeDragStop:B,onSelectionDrag:A,onSelectionDragStart:M,onSelectionDragStop:P,noPanClassName:F,nodeOrigin:I,rfId:V,autoPanOnConnect:W,autoPanOnNodeDrag:j,onError:X,connectionRadius:$,isValidConnection:K,nodeDragThreshold:Q})=>{let{setNodes:J,setEdges:oe,setDefaultNodesAndEdges:be,setMinZoom:Me,setMaxZoom:Je,setTranslateExtent:Ve,setNodeExtent:Ct,reset:He}=Vn(s$e,_i),de=mi();return(0,U.useEffect)(()=>{let ie=r?.map(ze=>({...ze,...E}));return be(n,ie),()=>{He()}},[]),It("defaultEdgeOptions",E,de.setState),It("connectionMode",x,de.setState),It("onConnect",i,de.setState),It("onConnectStart",o,de.setState),It("onConnectEnd",s,de.setState),It("onClickConnectStart",a,de.setState),It("onClickConnectEnd",l,de.setState),It("nodesDraggable",u,de.setState),It("nodesConnectable",c,de.setState),It("nodesFocusable",d,de.setState),It("edgesFocusable",h,de.setState),It("edgesUpdatable",f,de.setState),It("elementsSelectable",w,de.setState),It("elevateNodesOnSelect",p,de.setState),It("snapToGrid",k,de.setState),It("snapGrid",S,de.setState),It("onNodesChange",v,de.setState),It("onEdgesChange",b,de.setState),It("connectOnClick",N,de.setState),It("fitViewOnInit",D,de.setState),It("fitViewOnInitOptions",q,de.setState),It("onNodesDelete",z,de.setState),It("onEdgesDelete",_,de.setState),It("onNodeDrag",R,de.setState),It("onNodeDragStart",T,de.setState),It("onNodeDragStop",B,de.setState),It("onSelectionDrag",A,de.setState),It("onSelectionDragStart",M,de.setState),It("onSelectionDragStop",P,de.setState),It("noPanClassName",F,de.setState),It("nodeOrigin",I,de.setState),It("rfId",V,de.setState),It("autoPanOnConnect",W,de.setState),It("autoPanOnNodeDrag",j,de.setState),It("onError",X,de.setState),It("connectionRadius",$,de.setState),It("isValidConnection",K,de.setState),It("nodeDragThreshold",Q,de.setState),Wg(e,J),Wg(t,oe),Wg(m,Me),Wg(g,Je),Wg(C,Ve),Wg(y,Ct),null},bK={display:"none"},l$e={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vie="react-flow__node-desc",bie="react-flow__edge-desc",u$e="react-flow__aria-live",c$e=e=>e.ariaLiveMessage;function d$e({rfId:e}){let t=Vn(c$e);return U.default.createElement("div",{id:`${u$e}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:l$e},t)}function h$e({rfId:e,disableKeyboardA11y:t}){return U.default.createElement(U.default.Fragment,null,U.default.createElement("div",{id:`${vie}-${e}`,style:bK},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),U.default.createElement("div",{id:`${bie}-${e}`,style:bK},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&U.default.createElement(d$e,{rfId:e}))}var Cx=(e=null,t={actInsideInputWithModifier:!0})=>{let[n,r]=(0,U.useState)(!1),i=(0,U.useRef)(!1),o=(0,U.useRef)(new Set([])),[s,a]=(0,U.useMemo)(()=>{if(e!==null){let l=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.split("+")),u=l.reduce((c,d)=>c.concat(...d),[]);return[l,u]}return[[],[]]},[e]);return(0,U.useEffect)(()=>{let l=typeof document<"u"?document:null,u=t?.target||l;if(e!==null){let c=f=>{if(i.current=f.ctrlKey||f.metaKey||f.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&mL(f))return!1;let p=xK(f.code,a);o.current.add(f[p]),wK(s,o.current,!1)&&(f.preventDefault(),r(!0))},d=f=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&mL(f))return!1;let p=xK(f.code,a);wK(s,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(f[p]),f.key==="Meta"&&o.current.clear(),i.current=!1},h=()=>{o.current.clear(),r(!1)};return u?.addEventListener("keydown",c),u?.addEventListener("keyup",d),window.addEventListener("blur",h),()=>{u?.removeEventListener("keydown",c),u?.removeEventListener("keyup",d),window.removeEventListener("blur",h)}}},[e,r]),n};function wK(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function xK(e,t){return t.includes(e)?"code":"key"}function wie(e,t,n,r){let i=e.parentNode||e.parentId;if(!i)return n;let o=t.get(i),s=Bp(o,r);return wie(o,t,{x:(n.x??0)+s.x,y:(n.y??0)+s.y,z:(o[Cr]?.z??0)>(n.z??0)?o[Cr]?.z??0:n.z??0},r)}function xie(e,t,n){e.forEach(r=>{let i=r.parentNode||r.parentId;if(i&&!e.has(i))throw new Error(`Parent node ${i} not found`);if(i||n?.[r.id]){let{x:o,y:s,z:a}=wie(r,e,{...r.position,z:r[Cr]?.z??0},t);r.positionAbsolute={x:o,y:s},r[Cr].z=a,n?.[r.id]&&(r[Cr].isParent=!0)}})}function MR(e,t,n,r){let i=new Map,o={},s=r?1e3:0;return e.forEach(a=>{let l=(va(a.zIndex)?a.zIndex:0)+(a.selected?s:0),u=t.get(a.id),c={...a,positionAbsolute:{x:a.position.x,y:a.position.y}},d=a.parentNode||a.parentId;d&&(o[d]=!0);let h=u?.type&&u?.type!==a.type;Object.defineProperty(c,Cr,{enumerable:!1,value:{handleBounds:h?void 0:u?.[Cr]?.handleBounds,z:l}}),i.set(a.id,c)}),xie(i,n,o),i}function Sie(e,t={}){let{getNodes:n,width:r,height:i,minZoom:o,maxZoom:s,d3Zoom:a,d3Selection:l,fitViewOnInitDone:u,fitViewOnInit:c,nodeOrigin:d}=e(),h=t.initial&&!u&&c;if(a&&l&&(h||!t.initial)){let f=n().filter(m=>{let g=t.includeHiddenNodes?m.width&&m.height:!m.hidden;return t.nodes?.length?g&&t.nodes.some(y=>y.id===m.id):g}),p=f.every(m=>m.width&&m.height);if(f.length>0&&p){let m=TE(f,d),{x:g,y,zoom:v}=aie(m,r,i,t.minZoom??o,t.maxZoom??s,t.padding??.1),b=mu.translate(g,y).scale(v);return typeof t.duration=="number"&&t.duration>0?a.transform(mp(l,t.duration),b):a.transform(l,b),!0}}return!1}function f$e(e,t){return e.forEach(n=>{let r=t.get(n.id);r&&t.set(r.id,{...r,[Cr]:r[Cr],selected:n.selected})}),new Map(t)}function p$e(e,t){return t.map(n=>{let r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function WC({changedNodes:e,changedEdges:t,get:n,set:r}){let{nodeInternals:i,edges:o,onNodesChange:s,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:u}=n();e?.length&&(l&&r({nodeInternals:f$e(e,i)}),s?.(e)),t?.length&&(u&&r({edges:p$e(t,o)}),a?.(t))}var Ug=()=>{},m$e={zoomIn:Ug,zoomOut:Ug,zoomTo:Ug,getZoom:()=>1,setViewport:Ug,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ug,fitBounds:Ug,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},g$e=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),y$e=()=>{let e=mi(),{d3Zoom:t,d3Selection:n}=Vn(g$e,_i);return(0,U.useMemo)(()=>n&&t?{zoomIn:r=>t.scaleBy(mp(n,r?.duration),1.2),zoomOut:r=>t.scaleBy(mp(n,r?.duration),1/1.2),zoomTo:(r,i)=>t.scaleTo(mp(n,i?.duration),r),getZoom:()=>e.getState().transform[2],setViewport:(r,i)=>{let[o,s,a]=e.getState().transform,l=mu.translate(r.x??o,r.y??s).scale(r.zoom??a);t.transform(mp(n,i?.duration),l)},getViewport:()=>{let[r,i,o]=e.getState().transform;return{x:r,y:i,zoom:o}},fitView:r=>Sie(e.getState,r),setCenter:(r,i,o)=>{let{width:s,height:a,maxZoom:l}=e.getState(),u=typeof o?.zoom<"u"?o.zoom:l,c=s/2-r*u,d=a/2-i*u,h=mu.translate(c,d).scale(u);t.transform(mp(n,o?.duration),h)},fitBounds:(r,i)=>{let{width:o,height:s,minZoom:a,maxZoom:l}=e.getState(),{x:u,y:c,zoom:d}=aie(r,o,s,a,l,i?.padding??.1),h=mu.translate(u,c).scale(d);t.transform(mp(n,i?.duration),h)},project:r=>{let{transform:i,snapToGrid:o,snapGrid:s}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),vL(r,i,o,s)},screenToFlowPosition:r=>{let{transform:i,snapToGrid:o,snapGrid:s,domNode:a}=e.getState();if(!a)return r;let{x:l,y:u}=a.getBoundingClientRect(),c={x:r.x-l,y:r.y-u};return vL(c,i,o,s)},flowToScreenPosition:r=>{let{transform:i,domNode:o}=e.getState();if(!o)return r;let{x:s,y:a}=o.getBoundingClientRect(),l=iie(r,i);return{x:l.x+s,y:l.y+a}},viewportInitialized:!0}:m$e,[t,n])};function E5(){let e=y$e(),t=mi(),n=(0,U.useCallback)(()=>t.getState().getNodes().map(m=>({...m})),[]),r=(0,U.useCallback)(m=>t.getState().nodeInternals.get(m),[]),i=(0,U.useCallback)(()=>{let{edges:m=[]}=t.getState();return m.map(g=>({...g}))},[]),o=(0,U.useCallback)(m=>{let{edges:g=[]}=t.getState();return g.find(y=>y.id===m)},[]),s=(0,U.useCallback)(m=>{let{getNodes:g,setNodes:y,hasDefaultNodes:v,onNodesChange:b}=t.getState(),w=g(),x=typeof m=="function"?m(w):m;if(v)y(x);else if(b){let S=x.length===0?w.map(k=>({type:"remove",id:k.id})):x.map(k=>({item:k,type:"reset"}));b(S)}},[]),a=(0,U.useCallback)(m=>{let{edges:g=[],setEdges:y,hasDefaultEdges:v,onEdgesChange:b}=t.getState(),w=typeof m=="function"?m(g):m;if(v)y(w);else if(b){let x=w.length===0?g.map(S=>({type:"remove",id:S.id})):w.map(S=>({item:S,type:"reset"}));b(x)}},[]),l=(0,U.useCallback)(m=>{let g=Array.isArray(m)?m:[m],{getNodes:y,setNodes:v,hasDefaultNodes:b,onNodesChange:w}=t.getState();if(b){let x=[...y(),...g];v(x)}else if(w){let x=g.map(S=>({item:S,type:"add"}));w(x)}},[]),u=(0,U.useCallback)(m=>{let g=Array.isArray(m)?m:[m],{edges:y=[],setEdges:v,hasDefaultEdges:b,onEdgesChange:w}=t.getState();if(b)v([...y,...g]);else if(w){let x=g.map(S=>({item:S,type:"add"}));w(x)}},[]),c=(0,U.useCallback)(()=>{let{getNodes:m,edges:g=[],transform:y}=t.getState(),[v,b,w]=y;return{nodes:m().map(x=>({...x})),edges:g.map(x=>({...x})),viewport:{x:v,y:b,zoom:w}}},[]),d=(0,U.useCallback)(({nodes:m,edges:g})=>{let{nodeInternals:y,getNodes:v,edges:b,hasDefaultNodes:w,hasDefaultEdges:x,onNodesDelete:S,onEdgesDelete:k,onNodesChange:C,onEdgesChange:N}=t.getState(),E=(m||[]).map(R=>R.id),D=(g||[]).map(R=>R.id),q=v().reduce((R,T)=>{let B=T.parentNode||T.parentId,A=!E.includes(T.id)&&B&&R.find(M=>M.id===B);return(typeof T.deletable!="boolean"||T.deletable)&&(E.includes(T.id)||A)&&R.push(T),R},[]),z=b.filter(R=>typeof R.deletable=="boolean"?R.deletable:!0),_=z.filter(R=>D.includes(R.id));if(q||_){let R=sie(q,z),T=[..._,...R],B=T.reduce((A,M)=>(A.includes(M.id)||A.push(M.id),A),[]);if((x||w)&&(x&&t.setState({edges:b.filter(A=>!B.includes(A.id))}),w&&(q.forEach(A=>{y.delete(A.id)}),t.setState({nodeInternals:new Map(y)}))),B.length>0&&(k?.(T),N&&N(B.map(A=>({id:A,type:"remove"})))),q.length>0&&(S?.(q),C)){let A=q.map(M=>({id:M.id,type:"remove"}));C(A)}}},[]),h=(0,U.useCallback)(m=>{let g=zHe(m),y=g?null:t.getState().nodeInternals.get(m.id);return!g&&!y?[null,null,g]:[g?m:hK(y),y,g]},[]),f=(0,U.useCallback)((m,g=!0,y)=>{let[v,b,w]=h(m);return v?(y||t.getState().getNodes()).filter(x=>{if(!w&&(x.id===b.id||!x.positionAbsolute))return!1;let S=hK(x),k=pL(S,v);return g&&k>0||k>=v.width*v.height}):[]},[]),p=(0,U.useCallback)((m,g,y=!0)=>{let[v]=h(m);if(!v)return!1;let b=pL(v,g);return y&&b>0||b>=v.width*v.height},[]);return(0,U.useMemo)(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:o,setNodes:s,setEdges:a,addNodes:l,addEdges:u,toObject:c,deleteElements:d,getIntersectingNodes:f,isNodeIntersecting:p}),[e,n,r,i,o,s,a,l,u,c,d,f,p])}var v$e={actInsideInputWithModifier:!1},b$e=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{let n=mi(),{deleteElements:r}=E5(),i=Cx(e,v$e),o=Cx(t);(0,U.useEffect)(()=>{if(i){let{edges:s,getNodes:a}=n.getState(),l=a().filter(c=>c.selected),u=s.filter(c=>c.selected);r({nodes:l,edges:u}),n.setState({nodesSelectionActive:!1})}},[i]),(0,U.useEffect)(()=>{n.setState({multiSelectionActive:o})},[o])};function w$e(e){let t=mi();(0,U.useEffect)(()=>{let n,r=()=>{if(!e.current)return;let i=w5(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",xu.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}var O5={position:"absolute",width:"100%",height:"100%",top:0,left:0},x$e=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,UC=e=>({x:e.x,y:e.y,zoom:e.k}),Hg=(e,t)=>e.target.closest(`.${t}`),SK=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kK=e=>{let t=e.ctrlKey&&JM()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},S$e=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),k$e=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:o=!0,panOnScroll:s=!1,panOnScrollSpeed:a=.5,panOnScrollMode:l=Mp.Free,zoomOnDoubleClick:u=!0,elementsSelectable:c,panOnDrag:d=!0,defaultViewport:h,translateExtent:f,minZoom:p,maxZoom:m,zoomActivationKeyCode:g,preventScrolling:y=!0,children:v,noWheelClassName:b,noPanClassName:w})=>{let x=(0,U.useRef)(),S=mi(),k=(0,U.useRef)(!1),C=(0,U.useRef)(!1),N=(0,U.useRef)(null),E=(0,U.useRef)({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:q,d3ZoomHandler:z,userSelectionActive:_}=Vn(S$e,_i),R=Cx(g),T=(0,U.useRef)(0),B=(0,U.useRef)(!1),A=(0,U.useRef)();return w$e(N),(0,U.useEffect)(()=>{if(N.current){let M=N.current.getBoundingClientRect(),P=Ure().scaleExtent([p,m]).translateExtent(f),F=pa(N.current).call(P),I=mu.translate(h.x,h.y).scale(nv(h.zoom,p,m)),V=[[0,0],[M.width,M.height]],W=P.constrain()(I,V,f);P.transform(F,W),P.wheelDelta(kK),S.setState({d3Zoom:P,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:N.current.closest(".react-flow")})}},[]),(0,U.useEffect)(()=>{q&&D&&(s&&!R&&!_?q.on("wheel.zoom",M=>{if(Hg(M,b))return!1;M.preventDefault(),M.stopImmediatePropagation();let P=q.property("__zoom").k||1;if(M.ctrlKey&&o){let K=nl(M),Q=kK(M),J=P*Math.pow(2,Q);D.scaleTo(q,J,K,M);return}let F=M.deltaMode===1?20:1,I=l===Mp.Vertical?0:M.deltaX*F,V=l===Mp.Horizontal?0:M.deltaY*F;!JM()&&M.shiftKey&&l!==Mp.Vertical&&(I=M.deltaY*F,V=0),D.translateBy(q,-(I/P)*a,-(V/P)*a,{internal:!0});let W=UC(q.property("__zoom")),{onViewportChangeStart:j,onViewportChange:X,onViewportChangeEnd:$}=S.getState();clearTimeout(A.current),B.current||(B.current=!0,t?.(M,W),j?.(W)),B.current&&(e?.(M,W),X?.(W),A.current=setTimeout(()=>{n?.(M,W),$?.(W),B.current=!1},150))},{passive:!1}):typeof z<"u"&&q.on("wheel.zoom",function(M,P){if(!y&&M.type==="wheel"&&!M.ctrlKey||Hg(M,b))return null;M.preventDefault(),z.call(this,M,P)},{passive:!1}))},[_,s,l,q,D,z,R,o,y,b,t,e,n]),(0,U.useEffect)(()=>{D&&D.on("start",M=>{if(!M.sourceEvent||M.sourceEvent.internal)return null;T.current=M.sourceEvent?.button;let{onViewportChangeStart:P}=S.getState(),F=UC(M.transform);k.current=!0,E.current=F,M.sourceEvent?.type==="mousedown"&&S.setState({paneDragging:!0}),P?.(F),t?.(M.sourceEvent,F)})},[D,t]),(0,U.useEffect)(()=>{D&&(_&&!k.current?D.on("zoom",null):_||D.on("zoom",M=>{let{onViewportChange:P}=S.getState();if(S.setState({transform:[M.transform.x,M.transform.y,M.transform.k]}),C.current=!!(r&&SK(d,T.current??0)),(e||P)&&!M.sourceEvent?.internal){let F=UC(M.transform);P?.(F),e?.(M.sourceEvent,F)}}))},[_,D,e,d,r]),(0,U.useEffect)(()=>{D&&D.on("end",M=>{if(!M.sourceEvent||M.sourceEvent.internal)return null;let{onViewportChangeEnd:P}=S.getState();if(k.current=!1,S.setState({paneDragging:!1}),r&&SK(d,T.current??0)&&!C.current&&r(M.sourceEvent),C.current=!1,(n||P)&&x$e(E.current,M.transform)){let F=UC(M.transform);E.current=F,clearTimeout(x.current),x.current=setTimeout(()=>{P?.(F),n?.(M.sourceEvent,F)},s?150:0)}})},[D,s,d,n,r]),(0,U.useEffect)(()=>{D&&D.filter(M=>{let P=R||i,F=o&&M.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&M.button===1&&M.type==="mousedown"&&(Hg(M,"react-flow__node")||Hg(M,"react-flow__edge")))return!0;if(!d&&!P&&!s&&!u&&!o||_||!u&&M.type==="dblclick"||Hg(M,b)&&M.type==="wheel"||Hg(M,w)&&(M.type!=="wheel"||s&&M.type==="wheel"&&!R)||!o&&M.ctrlKey&&M.type==="wheel"||!P&&!s&&!F&&M.type==="wheel"||!d&&(M.type==="mousedown"||M.type==="touchstart")||Array.isArray(d)&&!d.includes(M.button)&&M.type==="mousedown")return!1;let I=Array.isArray(d)&&d.includes(M.button)||!M.button||M.button<=1;return(!M.ctrlKey||M.type==="wheel")&&I})},[_,D,i,o,s,u,d,c,R]),U.default.createElement("div",{className:"react-flow__renderer",ref:N,style:O5},v)},C$e=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function N$e(){let{userSelectionActive:e,userSelectionRect:t}=Vn(C$e,_i);return e&&t?U.default.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function CK(e,t){let n=t.parentNode||t.parentId,r=e.find(i=>i.id===n);if(r){let i=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(i>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),o>0&&(r.style.height+=o),t.position.x<0){let s=Math.abs(t.position.x);r.position.x=r.position.x-s,r.style.width+=s,t.position.x=0}if(t.position.y<0){let s=Math.abs(t.position.y);r.position.y=r.position.y-s,r.style.height+=s,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function kie(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);let n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{let o=e.filter(a=>a.id===i.id);if(o.length===0)return r.push(i),r;let s={...i};for(let a of o)if(a)switch(a.type){case"select":{s.selected=a.selected;break}case"position":{typeof a.position<"u"&&(s.position=a.position),typeof a.positionAbsolute<"u"&&(s.positionAbsolute=a.positionAbsolute),typeof a.dragging<"u"&&(s.dragging=a.dragging),s.expandParent&&CK(r,s);break}case"dimensions":{typeof a.dimensions<"u"&&(s.width=a.dimensions.width,s.height=a.dimensions.height),typeof a.updateStyle<"u"&&(s.style={...s.style||{},...a.dimensions}),typeof a.resizing=="boolean"&&(s.resizing=a.resizing),s.expandParent&&CK(r,s);break}case"remove":return r}return r.push(s),r},n)}function T5(e,t){return kie(e,t)}function Cie(e,t){return kie(e,t)}var eh=(e,t)=>({id:e,type:"select",selected:t});function Sy(e,t){return e.reduce((n,r)=>{let i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(eh(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(eh(r.id,!1))),n},[])}var _R=(e,t)=>n=>{n.target===t.current&&e?.(n)},M$e=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),Nie=(0,U.memo)(({isSelecting:e,selectionMode:t=kx.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:o,onPaneContextMenu:s,onPaneScroll:a,onPaneMouseEnter:l,onPaneMouseMove:u,onPaneMouseLeave:c,children:d})=>{let h=(0,U.useRef)(null),f=mi(),p=(0,U.useRef)(0),m=(0,U.useRef)(0),g=(0,U.useRef)(),{userSelectionActive:y,elementsSelectable:v,dragging:b}=Vn(M$e,_i),w=()=>{f.setState({userSelectionActive:!1,userSelectionRect:null}),p.current=0,m.current=0},x=z=>{o?.(z),f.getState().resetSelectedElements(),f.setState({nodesSelectionActive:!1})},S=z=>{if(Array.isArray(n)&&n?.includes(2)){z.preventDefault();return}s?.(z)},k=a?z=>a(z):void 0,C=z=>{let{resetSelectedElements:_,domNode:R}=f.getState();if(g.current=R?.getBoundingClientRect(),!v||!e||z.button!==0||z.target!==h.current||!g.current)return;let{x:T,y:B}=xh(z,g.current);_(),f.setState({userSelectionRect:{width:0,height:0,startX:T,startY:B,x:T,y:B}}),r?.(z)},N=z=>{let{userSelectionRect:_,nodeInternals:R,edges:T,transform:B,onNodesChange:A,onEdgesChange:M,nodeOrigin:P,getNodes:F}=f.getState();if(!e||!g.current||!_)return;f.setState({userSelectionActive:!0,nodesSelectionActive:!1});let I=xh(z,g.current),V=_.startX??0,W=_.startY??0,j={..._,x:I.x<V?I.x:V,y:I.y<W?I.y:W,width:Math.abs(I.x-V),height:Math.abs(I.y-W)},X=F(),$=oie(R,j,B,t===kx.Partial,!0,P),K=sie($,T).map(J=>J.id),Q=$.map(J=>J.id);if(p.current!==Q.length){p.current=Q.length;let J=Sy(X,Q);J.length&&A?.(J)}if(m.current!==K.length){m.current=K.length;let J=Sy(T,K);J.length&&M?.(J)}f.setState({userSelectionRect:j})},E=z=>{if(z.button!==0)return;let{userSelectionRect:_}=f.getState();!y&&_&&z.target===h.current&&x?.(z),f.setState({nodesSelectionActive:p.current>0}),w(),i?.(z)},D=z=>{y&&(f.setState({nodesSelectionActive:p.current>0}),i?.(z)),w()},q=v&&(e||y);return U.default.createElement("div",{className:Ui(["react-flow__pane",{dragging:b,selection:e}]),onClick:q?void 0:_R(x,h),onContextMenu:_R(S,h),onWheel:_R(k,h),onMouseEnter:q?void 0:l,onMouseDown:q?C:void 0,onMouseMove:q?N:u,onMouseUp:q?E:void 0,onMouseLeave:q?D:c,ref:h,style:O5},d,U.default.createElement(N$e,null))});Nie.displayName="Pane";function Mie(e,t){let n=e.parentNode||e.parentId;if(!n)return!1;let r=t.get(n);return r?r.selected?!0:Mie(r,t):!1}function NK(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function _$e(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!Mie(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}))}function E$e(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function _ie(e,t,n,r,i=[0,0],o){let s=E$e(e,e.extent||r),a=s,l=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(l&&e.width&&e.height){let d=n.get(l),{x:h,y:f}=Bp(d,i).positionAbsolute;a=d&&va(h)&&va(f)&&va(d.width)&&va(d.height)?[[h+e.width*i[0],f+e.height*i[1]],[h+d.width-e.width+e.width*i[0],f+d.height-e.height+e.height*i[1]]]:a}else o?.("005",xu.error005()),a=s;else if(e.extent&&l&&e.extent!=="parent"){let d=n.get(l),{x:h,y:f}=Bp(d,i).positionAbsolute;a=[[e.extent[0][0]+h,e.extent[0][1]+f],[e.extent[1][0]+h,e.extent[1][1]+f]]}let u={x:0,y:0};if(l){let d=n.get(l);u=Bp(d,i).positionAbsolute}let c=a&&a!=="parent"?x5(t,a):t;return{position:{x:c.x-u.x,y:c.y-u.y},positionAbsolute:c}}function ER({nodeId:e,dragItems:t,nodeInternals:n}){let r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}var MK=(e,t,n,r)=>{let i=t.querySelectorAll(e);if(!i||!i.length)return null;let o=Array.from(i),s=t.getBoundingClientRect(),a={x:s.width*r[0],y:s.height*r[1]};return o.map(l=>{let u=l.getBoundingClientRect();return{id:l.getAttribute("data-handleid"),position:l.getAttribute("data-handlepos"),x:(u.left-s.left-a.x)/n,y:(u.top-s.top-a.y)/n,...w5(l)}})};function Vb(e,t,n){return n===void 0?n:r=>{let i=t().nodeInternals.get(e);i&&n(r,{...i})}}function wL({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:s,nodeInternals:a,onError:l}=t.getState(),u=a.get(e);if(!u){l?.("012",xu.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&s)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function O$e(){let e=mi();return(0,U.useCallback)(({sourceEvent:t})=>{let{transform:n,snapGrid:r,snapToGrid:i}=e.getState(),o=t.touches?t.touches[0].clientX:t.clientX,s=t.touches?t.touches[0].clientY:t.clientY,a={x:(o-n[0])/n[2],y:(s-n[1])/n[2]};return{xSnapped:i?r[0]*Math.round(a.x/r[0]):a.x,ySnapped:i?r[1]*Math.round(a.y/r[1]):a.y,...a}},[])}function OR(e){return(t,n,r)=>e?.(t,r)}function Eie({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,selectNodesOnDrag:s}){let a=mi(),[l,u]=(0,U.useState)(!1),c=(0,U.useRef)([]),d=(0,U.useRef)({x:null,y:null}),h=(0,U.useRef)(0),f=(0,U.useRef)(null),p=(0,U.useRef)({x:0,y:0}),m=(0,U.useRef)(null),g=(0,U.useRef)(!1),y=(0,U.useRef)(!1),v=(0,U.useRef)(!1),b=O$e();return(0,U.useEffect)(()=>{if(e?.current){let w=pa(e.current),x=({x:C,y:N})=>{let{nodeInternals:E,onNodeDrag:D,onSelectionDrag:q,updateNodePositions:z,nodeExtent:_,snapGrid:R,snapToGrid:T,nodeOrigin:B,onError:A}=a.getState();d.current={x:C,y:N};let M=!1,P={x:0,y:0,x2:0,y2:0};if(c.current.length>1&&_){let I=TE(c.current,B);P=Sx(I)}if(c.current=c.current.map(I=>{let V={x:C-I.distance.x,y:N-I.distance.y};T&&(V.x=R[0]*Math.round(V.x/R[0]),V.y=R[1]*Math.round(V.y/R[1]));let W=[[_[0][0],_[0][1]],[_[1][0],_[1][1]]];c.current.length>1&&_&&!I.extent&&(W[0][0]=I.positionAbsolute.x-P.x+_[0][0],W[1][0]=I.positionAbsolute.x+(I.width??0)-P.x2+_[1][0],W[0][1]=I.positionAbsolute.y-P.y+_[0][1],W[1][1]=I.positionAbsolute.y+(I.height??0)-P.y2+_[1][1]);let j=_ie(I,V,E,W,B,A);return M=M||I.position.x!==j.position.x||I.position.y!==j.position.y,I.position=j.position,I.positionAbsolute=j.positionAbsolute,I}),!M)return;z(c.current,!0,!0),u(!0);let F=i?D:OR(q);if(F&&m.current){let[I,V]=ER({nodeId:i,dragItems:c.current,nodeInternals:E});F(m.current,I,V)}},S=()=>{if(!f.current)return;let[C,N]=$re(p.current,f.current);if(C!==0||N!==0){let{transform:E,panBy:D}=a.getState();d.current.x=(d.current.x??0)-C/E[2],d.current.y=(d.current.y??0)-N/E[2],D({x:C,y:N})&&x(d.current)}h.current=requestAnimationFrame(S)},k=C=>{let{nodeInternals:N,multiSelectionActive:E,nodesDraggable:D,unselectNodesAndEdges:q,onNodeDragStart:z,onSelectionDragStart:_}=a.getState();y.current=!0;let R=i?z:OR(_);(!s||!o)&&!E&&i&&(N.get(i)?.selected||q()),i&&o&&s&&wL({id:i,store:a,nodeRef:e});let T=b(C);if(d.current=T,c.current=_$e(N,D,T,i),R&&c.current){let[B,A]=ER({nodeId:i,dragItems:c.current,nodeInternals:N});R(C.sourceEvent,B,A)}};if(t)w.on(".drag",null);else{let C=zUe().on("start",N=>{let{domNode:E,nodeDragThreshold:D}=a.getState();D===0&&k(N),v.current=!1;let q=b(N);d.current=q,f.current=E?.getBoundingClientRect()||null,p.current=xh(N.sourceEvent,f.current)}).on("drag",N=>{let E=b(N),{autoPanOnNodeDrag:D,nodeDragThreshold:q}=a.getState();if(N.sourceEvent.type==="touchmove"&&N.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!g.current&&y.current&&D&&(g.current=!0,S()),!y.current){let z=E.xSnapped-(d?.current?.x??0),_=E.ySnapped-(d?.current?.y??0);Math.sqrt(z*z+_*_)>q&&k(N)}(d.current.x!==E.xSnapped||d.current.y!==E.ySnapped)&&c.current&&y.current&&(m.current=N.sourceEvent,p.current=xh(N.sourceEvent,f.current),x(E))}}).on("end",N=>{if(!(!y.current||v.current)&&(u(!1),g.current=!1,y.current=!1,cancelAnimationFrame(h.current),c.current)){let{updateNodePositions:E,nodeInternals:D,onNodeDragStop:q,onSelectionDragStop:z}=a.getState(),_=i?q:OR(z);if(E(c.current,!1,!1),_){let[R,T]=ER({nodeId:i,dragItems:c.current,nodeInternals:D});_(N.sourceEvent,R,T)}}}).filter(N=>{let E=N.target;return!N.button&&(!n||!NK(E,`.${n}`,e))&&(!r||NK(E,r,e))});return w.call(C),()=>{w.on(".drag",null)}}}},[e,t,n,r,o,a,i,s,b]),l}function Oie(){let e=mi();return(0,U.useCallback)(t=>{let{nodeInternals:n,nodeExtent:r,updateNodePositions:i,getNodes:o,snapToGrid:s,snapGrid:a,onError:l,nodesDraggable:u}=e.getState(),c=o().filter(y=>y.selected&&(y.draggable||u&&typeof y.draggable>"u")),d=s?a[0]:5,h=s?a[1]:5,f=t.isShiftPressed?4:1,p=t.x*d*f,m=t.y*h*f,g=c.map(y=>{if(y.positionAbsolute){let v={x:y.positionAbsolute.x+p,y:y.positionAbsolute.y+m};s&&(v.x=a[0]*Math.round(v.x/a[0]),v.y=a[1]*Math.round(v.y/a[1]));let{positionAbsolute:b,position:w}=_ie(y,v,n,r,void 0,l);y.position=w,y.positionAbsolute=b}return y});i(g,!0,!1)},[])}var Ry={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Wb=e=>{let t=({id:n,type:r,data:i,xPos:o,yPos:s,xPosOrigin:a,yPosOrigin:l,selected:u,onClick:c,onMouseEnter:d,onMouseMove:h,onMouseLeave:f,onContextMenu:p,onDoubleClick:m,style:g,className:y,isDraggable:v,isSelectable:b,isConnectable:w,isFocusable:x,selectNodesOnDrag:S,sourcePosition:k,targetPosition:C,hidden:N,resizeObserver:E,dragHandle:D,zIndex:q,isParent:z,noDragClassName:_,noPanClassName:R,initialized:T,disableKeyboardA11y:B,ariaLabel:A,rfId:M,hasHandleBounds:P})=>{let F=mi(),I=(0,U.useRef)(null),V=(0,U.useRef)(null),W=(0,U.useRef)(k),j=(0,U.useRef)(C),X=(0,U.useRef)(r),$=b||v||c||d||h||f,K=Oie(),Q=Vb(n,F.getState,d),J=Vb(n,F.getState,h),oe=Vb(n,F.getState,f),be=Vb(n,F.getState,p),Me=Vb(n,F.getState,m),Je=He=>{let{nodeDragThreshold:de}=F.getState();if(b&&(!S||!v||de>0)&&wL({id:n,store:F,nodeRef:I}),c){let ie=F.getState().nodeInternals.get(n);ie&&c(He,{...ie})}},Ve=He=>{if(!mL(He)&&!B)if(Gre.includes(He.key)&&b){let de=He.key==="Escape";wL({id:n,store:F,unselect:de,nodeRef:I})}else v&&u&&Object.prototype.hasOwnProperty.call(Ry,He.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${He.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~s}`}),K({x:Ry[He.key].x,y:Ry[He.key].y,isShiftPressed:He.shiftKey}))};(0,U.useEffect)(()=>()=>{V.current&&(E?.unobserve(V.current),V.current=null)},[]),(0,U.useEffect)(()=>{if(I.current&&!N){let He=I.current;(!T||!P||V.current!==He)&&(V.current&&E?.unobserve(V.current),E?.observe(He),V.current=He)}},[N,T,P]),(0,U.useEffect)(()=>{let He=X.current!==r,de=W.current!==k,ie=j.current!==C;I.current&&(He||de||ie)&&(He&&(X.current=r),de&&(W.current=k),ie&&(j.current=C),F.getState().updateNodeDimensions([{id:n,nodeElement:I.current,forceUpdate:!0}]))},[n,r,k,C]);let Ct=Eie({nodeRef:I,disabled:N||!v,noDragClassName:_,handleSelector:D,nodeId:n,isSelectable:b,selectNodesOnDrag:S});return N?null:U.default.createElement("div",{className:Ui(["react-flow__node",`react-flow__node-${r}`,{[R]:v},y,{selected:u,selectable:b,parent:z,dragging:Ct}]),ref:I,style:{zIndex:q,transform:`translate(${a}px,${l}px)`,pointerEvents:$?"all":"none",visibility:T?"visible":"hidden",...g},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:Q,onMouseMove:J,onMouseLeave:oe,onContextMenu:be,onClick:Je,onDoubleClick:Me,onKeyDown:x?Ve:void 0,tabIndex:x?0:void 0,role:x?"button":void 0,"aria-describedby":B?void 0:`${vie}-${M}`,"aria-label":A},U.default.createElement(HHe,{value:n},U.default.createElement(e,{id:n,data:i,type:r,xPos:o,yPos:s,selected:u,isConnectable:w,sourcePosition:k,targetPosition:C,dragging:Ct,dragHandle:D,zIndex:q})))};return t.displayName="NodeWrapper",(0,U.memo)(t)},T$e=e=>{let t=e.getNodes().filter(n=>n.selected);return{...TE(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function A$e({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=mi(),{width:i,height:o,x:s,y:a,transformString:l,userSelectionActive:u}=Vn(T$e,_i),c=Oie(),d=(0,U.useRef)(null);if((0,U.useEffect)(()=>{n||d.current?.focus({preventScroll:!0})},[n]),Eie({nodeRef:d}),u||!i||!o)return null;let h=e?p=>{let m=r.getState().getNodes().filter(g=>g.selected);e(p,m)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(Ry,p.key)&&c({x:Ry[p.key].x,y:Ry[p.key].y,isShiftPressed:p.shiftKey})};return U.default.createElement("div",{className:Ui(["react-flow__nodesselection","react-flow__container",t]),style:{transform:l}},U.default.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:h,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:i,height:o,top:a,left:s}}))}var D$e=(0,U.memo)(A$e),R$e=e=>e.nodesSelectionActive,Tie=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:s,deleteKeyCode:a,onMove:l,onMoveStart:u,onMoveEnd:c,selectionKeyCode:d,selectionOnDrag:h,selectionMode:f,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:y,zoomActivationKeyCode:v,elementsSelectable:b,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:S,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:N,panOnDrag:E,defaultViewport:D,translateExtent:q,minZoom:z,maxZoom:_,preventScrolling:R,onSelectionContextMenu:T,noWheelClassName:B,noPanClassName:A,disableKeyboardA11y:M})=>{let P=Vn(R$e),F=Cx(d),I=Cx(y),V=I||E,W=I||S,j=F||h&&V!==!0;return b$e({deleteKeyCode:a,multiSelectionKeyCode:g}),U.default.createElement(k$e,{onMove:l,onMoveStart:u,onMoveEnd:c,onPaneContextMenu:o,elementsSelectable:b,zoomOnScroll:w,zoomOnPinch:x,panOnScroll:W,panOnScrollSpeed:k,panOnScrollMode:C,zoomOnDoubleClick:N,panOnDrag:!F&&V,defaultViewport:D,translateExtent:q,minZoom:z,maxZoom:_,zoomActivationKeyCode:v,preventScrolling:R,noWheelClassName:B,noPanClassName:A},U.default.createElement(Nie,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:s,panOnDrag:V,isSelecting:!!j,selectionMode:f},e,P&&U.default.createElement(D$e,{onSelectionContextMenu:T,noPanClassName:A,disableKeyboardA11y:M})))};Tie.displayName="FlowRenderer";var I$e=(0,U.memo)(Tie);function P$e(e){return Vn((0,U.useCallback)(t=>e?oie(t.nodeInternals,{x:0,y:0,width:t.width,height:t.height},t.transform,!0):t.getNodes(),[e]))}function L$e(e){let t={input:Wb(e.input||pie),default:Wb(e.default||bL),output:Wb(e.output||gie),group:Wb(e.group||_5)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,o)=>(i[o]=Wb(e[o]||bL),i),n);return{...t,...r}}var B$e=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},q$e=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Aie=e=>{let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:o,onError:s}=Vn(q$e,_i),a=P$e(e.onlyRenderVisibleElements),l=(0,U.useRef)(),u=(0,U.useMemo)(()=>{if(typeof ResizeObserver>"u")return null;let c=new ResizeObserver(d=>{let h=d.map(f=>({id:f.target.getAttribute("data-id"),nodeElement:f.target,forceUpdate:!0}));o(h)});return l.current=c,c},[]);return(0,U.useEffect)(()=>()=>{l?.current?.disconnect()},[]),U.default.createElement("div",{className:"react-flow__nodes",style:O5},a.map(c=>{let d=c.type||"default";e.nodeTypes[d]||(s?.("003",xu.error003(d)),d="default");let h=e.nodeTypes[d]||e.nodeTypes.default,f=!!(c.draggable||t&&typeof c.draggable>"u"),p=!!(c.selectable||i&&typeof c.selectable>"u"),m=!!(c.connectable||n&&typeof c.connectable>"u"),g=!!(c.focusable||r&&typeof c.focusable>"u"),y=e.nodeExtent?x5(c.positionAbsolute,e.nodeExtent):c.positionAbsolute,v=y?.x??0,b=y?.y??0,w=B$e({x:v,y:b,width:c.width??0,height:c.height??0,origin:e.nodeOrigin});return U.default.createElement(h,{key:c.id,id:c.id,className:c.className,style:c.style,type:d,data:c.data,sourcePosition:c.sourcePosition||Ue.Bottom,targetPosition:c.targetPosition||Ue.Top,hidden:c.hidden,xPos:v,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!c.selected,isDraggable:f,isSelectable:p,isConnectable:m,isFocusable:g,resizeObserver:u,dragHandle:c.dragHandle,zIndex:c[Cr]?.z??0,isParent:!!c[Cr]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!c.width&&!!c.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:c.ariaLabel,hasHandleBounds:!!c[Cr]?.handleBounds})}))};Aie.displayName="NodeRenderer";var z$e=(0,U.memo)(Aie),F$e=(e,t,n)=>n===Ue.Left?e-t:n===Ue.Right?e+t:e,j$e=(e,t,n)=>n===Ue.Top?e-t:n===Ue.Bottom?e+t:e,_K="react-flow__edgeupdater",EK=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:s,type:a})=>U.default.createElement("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:s,className:Ui([_K,`${_K}-${a}`]),cx:F$e(t,r,e),cy:j$e(n,r,e),r,stroke:"transparent",fill:"transparent"}),V$e=()=>!0,$g=e=>{let t=({id:n,className:r,type:i,data:o,onClick:s,onEdgeDoubleClick:a,selected:l,animated:u,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,style:g,source:y,target:v,sourceX:b,sourceY:w,targetX:x,targetY:S,sourcePosition:k,targetPosition:C,elementsSelectable:N,hidden:E,sourceHandleId:D,targetHandleId:q,onContextMenu:z,onMouseEnter:_,onMouseMove:R,onMouseLeave:T,reconnectRadius:B,onReconnect:A,onReconnectStart:M,onReconnectEnd:P,markerEnd:F,markerStart:I,rfId:V,ariaLabel:W,isFocusable:j,isReconnectable:X,pathOptions:$,interactionWidth:K,disableKeyboardA11y:Q})=>{let J=(0,U.useRef)(null),[oe,be]=(0,U.useState)(!1),[Me,Je]=(0,U.useState)(!1),Ve=mi(),Ct=(0,U.useMemo)(()=>`url('#${yL(I,V)}')`,[I,V]),He=(0,U.useMemo)(()=>`url('#${yL(F,V)}')`,[F,V]);if(E)return null;let de=Ot=>{let{edges:Kt,addSelectedEdges:Er,unselectNodesAndEdges:Dn,multiSelectionActive:Zn}=Ve.getState(),Un=Kt.find(he=>he.id===n);Un&&(N&&(Ve.setState({nodesSelectionActive:!1}),Un.selected&&Zn?(Dn({nodes:[],edges:[Un]}),J.current?.blur()):Er([n])),s&&s(Ot,Un))},ie=jb(n,Ve.getState,a),ze=jb(n,Ve.getState,z),Le=jb(n,Ve.getState,_),Oe=jb(n,Ve.getState,R),rt=jb(n,Ve.getState,T),Ht=(Ot,Kt)=>{if(Ot.button!==0)return;let{edges:Er,isValidConnection:Dn}=Ve.getState(),Zn=Kt?v:y,Un=(Kt?q:D)||null,he=Kt?"target":"source",Ae=Dn||V$e,ge=Kt,Be=Er.find(De=>De.id===n);Je(!0),M?.(Ot,Be,he);let ye=De=>{Je(!1),P?.(De,Be,he)};cie({event:Ot,handleId:Un,nodeId:Zn,onConnect:De=>A?.(Be,De),isTarget:ge,getState:Ve.getState,setState:Ve.setState,isValidConnection:Ae,edgeUpdaterType:he,onReconnectEnd:ye})},$t=Ot=>Ht(Ot,!0),dt=Ot=>Ht(Ot,!1),et=()=>be(!0),pt=()=>be(!1),nn=!N&&!s,Dt=Ot=>{if(!Q&&Gre.includes(Ot.key)&&N){let{unselectNodesAndEdges:Kt,addSelectedEdges:Er,edges:Dn}=Ve.getState();Ot.key==="Escape"?(J.current?.blur(),Kt({edges:[Dn.find(Zn=>Zn.id===n)]})):Er([n])}};return U.default.createElement("g",{className:Ui(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:l,animated:u,inactive:nn,updating:oe}]),onClick:de,onDoubleClick:ie,onContextMenu:ze,onMouseEnter:Le,onMouseMove:Oe,onMouseLeave:rt,onKeyDown:j?Dt:void 0,tabIndex:j?0:void 0,role:j?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${y} to ${v}`,"aria-describedby":j?`${bie}-${V}`:void 0,ref:J},!Me&&U.default.createElement(e,{id:n,source:y,target:v,selected:l,animated:u,label:c,labelStyle:d,labelShowBg:h,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:m,data:o,style:g,sourceX:b,sourceY:w,targetX:x,targetY:S,sourcePosition:k,targetPosition:C,sourceHandleId:D,targetHandleId:q,markerStart:Ct,markerEnd:He,pathOptions:$,interactionWidth:K}),X&&U.default.createElement(U.default.Fragment,null,(X==="source"||X===!0)&&U.default.createElement(EK,{position:k,centerX:b,centerY:w,radius:B,onMouseDown:$t,onMouseEnter:et,onMouseOut:pt,type:"source"}),(X==="target"||X===!0)&&U.default.createElement(EK,{position:C,centerX:x,centerY:S,radius:B,onMouseDown:dt,onMouseEnter:et,onMouseOut:pt,type:"target"})))};return t.displayName="EdgeWrapper",(0,U.memo)(t)};function W$e(e){let t={default:$g(e.default||e_),straight:$g(e.bezier||C5),step:$g(e.step||k5),smoothstep:$g(e.step||OE),simplebezier:$g(e.simplebezier||S5)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,o)=>(i[o]=$g(e[o]||e_),i),n);return{...t,...r}}function OK(e,t,n=null){let r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,o=n?.width||t.width,s=n?.height||t.height;switch(e){case Ue.Top:return{x:r+o/2,y:i};case Ue.Right:return{x:r+o,y:i+s/2};case Ue.Bottom:return{x:r+o/2,y:i+s};case Ue.Left:return{x:r,y:i+s/2}}}function TK(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}var U$e=(e,t,n,r,i,o)=>{let s=OK(n,e,t),a=OK(o,r,i);return{sourceX:s.x,sourceY:s.y,targetX:a.x,targetY:a.y}};function H$e({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:o,width:s,height:a,transform:l}){let u={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+o)};u.x===u.x2&&(u.x2+=1),u.y===u.y2&&(u.y2+=1);let c=Sx({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:s/l[2],height:a/l[2]}),d=Math.max(0,Math.min(c.x2,u.x2)-Math.max(c.x,u.x)),h=Math.max(0,Math.min(c.y2,u.y2)-Math.max(c.y,u.y));return Math.ceil(d*h)>0}function AK(e){let t=e?.[Cr]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}var $$e=[{level:0,isMaxLevel:!0,edges:[]}];function K$e(e,t,n=!1){let r=-1,i=e.reduce((s,a)=>{let l=va(a.zIndex),u=l?a.zIndex:0;if(n){let c=t.get(a.target),d=t.get(a.source),h=a.selected||c?.selected||d?.selected,f=Math.max(d?.[Cr]?.z||0,c?.[Cr]?.z||0,1e3);u=(l?a.zIndex:0)+(h?f:0)}return s[u]?s[u].push(a):s[u]=[a],r=u>r?u:r,s},{}),o=Object.entries(i).map(([s,a])=>{let l=+s;return{edges:a,level:l,isMaxLevel:l===r}});return o.length===0?$$e:o}function Y$e(e,t,n){let r=Vn((0,U.useCallback)(i=>e?i.edges.filter(o=>{let s=t.get(o.source),a=t.get(o.target);return s?.width&&s?.height&&a?.width&&a?.height&&H$e({sourcePos:s.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:s.width,sourceHeight:s.height,targetWidth:a.width,targetHeight:a.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return K$e(r,t,n)}var Q$e=({color:e="none",strokeWidth:t=1})=>U.default.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),G$e=({color:e="none",strokeWidth:t=1})=>U.default.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),DK={[ZM.Arrow]:Q$e,[ZM.ArrowClosed]:G$e};function X$e(e){let t=mi();return(0,U.useMemo)(()=>Object.prototype.hasOwnProperty.call(DK,e)?DK[e]:(t.getState().onError?.("009",xu.error009(e)),null),[e])}var J$e=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:s,orient:a="auto-start-reverse"})=>{let l=X$e(t);return l?U.default.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0"},U.default.createElement(l,{color:n,strokeWidth:s})):null},Z$e=({defaultColor:e,rfId:t})=>n=>{let r=[];return n.edges.reduce((i,o)=>([o.markerStart,o.markerEnd].forEach(s=>{if(s&&typeof s=="object"){let a=yL(s,t);r.includes(a)||(i.push({id:a,color:s.color||e,...s}),r.push(a))}}),i),[]).sort((i,o)=>i.id.localeCompare(o.id))},Die=({defaultColor:e,rfId:t})=>{let n=Vn((0,U.useCallback)(Z$e({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((o,s)=>o.id!==i[s].id)));return U.default.createElement("defs",null,n.map(r=>U.default.createElement(J$e,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Die.displayName="MarkerDefinitions";var e8e=(0,U.memo)(Die),t8e=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Rie=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:o,onEdgeContextMenu:s,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:c,onEdgeDoubleClick:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,reconnectRadius:m,children:g,disableKeyboardA11y:y})=>{let{edgesFocusable:v,edgesUpdatable:b,elementsSelectable:w,width:x,height:S,connectionMode:k,nodeInternals:C,onError:N}=Vn(t8e,_i),E=Y$e(t,C,n);return x?U.default.createElement(U.default.Fragment,null,E.map(({level:D,edges:q,isMaxLevel:z})=>U.default.createElement("svg",{key:D,style:{zIndex:D},width:x,height:S,className:"react-flow__edges react-flow__container"},z&&U.default.createElement(e8e,{defaultColor:e,rfId:r}),U.default.createElement("g",null,q.map(_=>{let[R,T,B]=AK(C.get(_.source)),[A,M,P]=AK(C.get(_.target));if(!B||!P)return null;let F=_.type||"default";i[F]||(N?.("011",xu.error011(F)),F="default");let I=i[F]||i.default,V=k===om.Strict?M.target:(M.target??[]).concat(M.source??[]),W=TK(T.source,_.sourceHandle),j=TK(V,_.targetHandle),X=W?.position||Ue.Bottom,$=j?.position||Ue.Top,K=!!(_.focusable||v&&typeof _.focusable>"u"),Q=_.reconnectable||_.updatable,J=typeof h<"u"&&(Q||b&&typeof Q>"u");if(!W||!j)return N?.("008",xu.error008(W,_)),null;let{sourceX:oe,sourceY:be,targetX:Me,targetY:Je}=U$e(R,W,X,A,j,$);return U.default.createElement(I,{key:_.id,id:_.id,className:Ui([_.className,o]),type:F,data:_.data,selected:!!_.selected,animated:!!_.animated,hidden:!!_.hidden,label:_.label,labelStyle:_.labelStyle,labelShowBg:_.labelShowBg,labelBgStyle:_.labelBgStyle,labelBgPadding:_.labelBgPadding,labelBgBorderRadius:_.labelBgBorderRadius,style:_.style,source:_.source,target:_.target,sourceHandleId:_.sourceHandle,targetHandleId:_.targetHandle,markerEnd:_.markerEnd,markerStart:_.markerStart,sourceX:oe,sourceY:be,targetX:Me,targetY:Je,sourcePosition:X,targetPosition:$,elementsSelectable:w,onContextMenu:s,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,onClick:c,onEdgeDoubleClick:d,onReconnect:h,onReconnectStart:f,onReconnectEnd:p,reconnectRadius:m,rfId:r,ariaLabel:_.ariaLabel,isFocusable:K,isReconnectable:J,pathOptions:"pathOptions"in _?_.pathOptions:void 0,interactionWidth:_.interactionWidth,disableKeyboardA11y:y})})))),g):null};Rie.displayName="EdgeRenderer";var n8e=(0,U.memo)(Rie),r8e=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function i8e({children:e}){let t=Vn(r8e);return U.default.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function o8e(e){let t=E5(),n=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var s8e={[Ue.Left]:Ue.Right,[Ue.Right]:Ue.Left,[Ue.Top]:Ue.Bottom,[Ue.Bottom]:Ue.Top},Iie=({nodeId:e,handleType:t,style:n,type:r=wc.Bezier,CustomComponent:i,connectionStatus:o})=>{let{fromNode:s,handleId:a,toX:l,toY:u,connectionMode:c}=Vn((0,U.useCallback)(S=>({fromNode:S.nodeInternals.get(e),handleId:S.connectionHandleId,toX:(S.connectionPosition.x-S.transform[0])/S.transform[2],toY:(S.connectionPosition.y-S.transform[1])/S.transform[2],connectionMode:S.connectionMode}),[e]),_i),d=s?.[Cr]?.handleBounds,h=d?.[t];if(c===om.Loose&&(h=h||d?.[t==="source"?"target":"source"]),!s||!h)return null;let f=a?h.find(S=>S.id===a):h[0],p=f?f.x+f.width/2:(s.width??0)/2,m=f?f.y+f.height/2:s.height??0,g=(s.positionAbsolute?.x??0)+p,y=(s.positionAbsolute?.y??0)+m,v=f?.position,b=v?s8e[v]:null;if(!v||!b)return null;if(i)return U.default.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:s,fromHandle:f,fromX:g,fromY:y,toX:l,toY:u,fromPosition:v,toPosition:b,connectionStatus:o});let w="",x={sourceX:g,sourceY:y,sourcePosition:v,targetX:l,targetY:u,targetPosition:b};return r===wc.Bezier?[w]=nie(x):r===wc.Step?[w]=gL({...x,borderRadius:0}):r===wc.SmoothStep?[w]=gL(x):r===wc.SimpleBezier?[w]=tie(x):w=`M${g},${y} ${l},${u}`,U.default.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};Iie.displayName="ConnectionLine";var a8e=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function l8e({containerStyle:e,style:t,type:n,component:r}){let{nodeId:i,handleType:o,nodesConnectable:s,width:a,height:l,connectionStatus:u}=Vn(a8e,_i);return i&&o&&a&&s?U.default.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},U.default.createElement("g",{className:Ui(["react-flow__connection",u])},U.default.createElement(Iie,{nodeId:i,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:u}))):null}function RK(e,t){let n=(0,U.useRef)(null),r=mi();return(0,U.useMemo)(()=>t(e),[e])}var Pie=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:o,onNodeClick:s,onEdgeClick:a,onNodeDoubleClick:l,onEdgeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:m,onSelectionEnd:g,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:w,selectionKeyCode:x,selectionOnDrag:S,selectionMode:k,multiSelectionKeyCode:C,panActivationKeyCode:N,zoomActivationKeyCode:E,deleteKeyCode:D,onlyRenderVisibleElements:q,elementsSelectable:z,selectNodesOnDrag:_,defaultViewport:R,translateExtent:T,minZoom:B,maxZoom:A,preventScrolling:M,defaultMarkerColor:P,zoomOnScroll:F,zoomOnPinch:I,panOnScroll:V,panOnScrollSpeed:W,panOnScrollMode:j,zoomOnDoubleClick:X,panOnDrag:$,onPaneClick:K,onPaneMouseEnter:Q,onPaneMouseMove:J,onPaneMouseLeave:oe,onPaneScroll:be,onPaneContextMenu:Me,onEdgeContextMenu:Je,onEdgeMouseEnter:Ve,onEdgeMouseMove:Ct,onEdgeMouseLeave:He,onReconnect:de,onReconnectStart:ie,onReconnectEnd:ze,reconnectRadius:Le,noDragClassName:Oe,noWheelClassName:rt,noPanClassName:Ht,elevateEdgesOnSelect:$t,disableKeyboardA11y:dt,nodeOrigin:et,nodeExtent:pt,rfId:nn})=>{let Dt=RK(e,L$e),Ot=RK(t,W$e);return o8e(o),U.default.createElement(I$e,{onPaneClick:K,onPaneMouseEnter:Q,onPaneMouseMove:J,onPaneMouseLeave:oe,onPaneContextMenu:Me,onPaneScroll:be,deleteKeyCode:D,selectionKeyCode:x,selectionOnDrag:S,selectionMode:k,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:C,panActivationKeyCode:N,zoomActivationKeyCode:E,elementsSelectable:z,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:F,zoomOnPinch:I,zoomOnDoubleClick:X,panOnScroll:V,panOnScrollSpeed:W,panOnScrollMode:j,panOnDrag:$,defaultViewport:R,translateExtent:T,minZoom:B,maxZoom:A,onSelectionContextMenu:p,preventScrolling:M,noDragClassName:Oe,noWheelClassName:rt,noPanClassName:Ht,disableKeyboardA11y:dt},U.default.createElement(i8e,null,U.default.createElement(n8e,{edgeTypes:Ot,onEdgeClick:a,onEdgeDoubleClick:u,onlyRenderVisibleElements:q,onEdgeContextMenu:Je,onEdgeMouseEnter:Ve,onEdgeMouseMove:Ct,onEdgeMouseLeave:He,onReconnect:de,onReconnectStart:ie,onReconnectEnd:ze,reconnectRadius:Le,defaultMarkerColor:P,noPanClassName:Ht,elevateEdgesOnSelect:!!$t,disableKeyboardA11y:dt,rfId:nn},U.default.createElement(l8e,{style:v,type:y,component:b,containerStyle:w})),U.default.createElement("div",{className:"react-flow__edgelabel-renderer"}),U.default.createElement(z$e,{nodeTypes:Dt,onNodeClick:s,onNodeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:h,onNodeContextMenu:f,selectNodesOnDrag:_,onlyRenderVisibleElements:q,noPanClassName:Ht,noDragClassName:Oe,disableKeyboardA11y:dt,nodeOrigin:et,nodeExtent:pt,rfId:nn})))};Pie.displayName="GraphView";var u8e=(0,U.memo)(Pie),xL=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Hd={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:xL,nodeExtent:xL,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:om.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:Xre,isValidConnection:void 0},c8e=()=>X4e((e,t)=>({...Hd,setNodes:n=>{let{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:o}=t();e({nodeInternals:MR(n,r,i,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{let{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{let i=typeof n<"u",o=typeof r<"u",s=i?MR(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:s,edges:o?r:[],hasDefaultNodes:i,hasDefaultEdges:o})},updateNodeDimensions:n=>{let{onNodesChange:r,nodeInternals:i,fitViewOnInit:o,fitViewOnInitDone:s,fitViewOnInitOptions:a,domNode:l,nodeOrigin:u}=t(),c=l?.querySelector(".react-flow__viewport");if(!c)return;let d=window.getComputedStyle(c),{m22:h}=new window.DOMMatrixReadOnly(d.transform),f=n.reduce((m,g)=>{let y=i.get(g.id);if(y?.hidden)i.set(y.id,{...y,[Cr]:{...y[Cr],handleBounds:void 0}});else if(y){let v=w5(g.nodeElement);v.width&&v.height&&(y.width!==v.width||y.height!==v.height||g.forceUpdate)&&(i.set(y.id,{...y,[Cr]:{...y[Cr],handleBounds:{source:MK(".source",g.nodeElement,h,u),target:MK(".target",g.nodeElement,h,u)}},...v}),m.push({id:y.id,type:"dimensions",dimensions:v}))}return m},[]);xie(i,u);let p=s||o&&!s&&Sie(t,{initial:!0,...a});e({nodeInternals:new Map(i),fitViewOnInitDone:p}),f?.length>0&&r?.(f)},updateNodePositions:(n,r=!0,i=!1)=>{let{triggerNodeChanges:o}=t(),s=n.map(a=>{let l={id:a.id,type:"position",dragging:i};return r&&(l.positionAbsolute=a.positionAbsolute,l.position=a.position),l});o(s)},triggerNodeChanges:n=>{let{onNodesChange:r,nodeInternals:i,hasDefaultNodes:o,nodeOrigin:s,getNodes:a,elevateNodesOnSelect:l}=t();if(n?.length){if(o){let u=T5(n,a()),c=MR(u,i,s,l);e({nodeInternals:c})}r?.(n)}},addSelectedNodes:n=>{let{multiSelectionActive:r,edges:i,getNodes:o}=t(),s,a=null;r?s=n.map(l=>eh(l,!0)):(s=Sy(o(),n),a=Sy(i,[])),WC({changedNodes:s,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{let{multiSelectionActive:r,edges:i,getNodes:o}=t(),s,a=null;r?s=n.map(l=>eh(l,!0)):(s=Sy(i,n),a=Sy(o(),[])),WC({changedNodes:a,changedEdges:s,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{let{edges:i,getNodes:o}=t(),s=n||o(),a=r||i,l=s.map(c=>(c.selected=!1,eh(c.id,!1))),u=a.map(c=>eh(c.id,!1));WC({changedNodes:l,changedEdges:u,get:t,set:e})},setMinZoom:n=>{let{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{let{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{let{edges:n,getNodes:r}=t(),i=r().filter(s=>s.selected).map(s=>eh(s.id,!1)),o=n.filter(s=>s.selected).map(s=>eh(s.id,!1));WC({changedNodes:i,changedEdges:o,get:t,set:e})},setNodeExtent:n=>{let{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=x5(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{let{transform:r,width:i,height:o,d3Zoom:s,d3Selection:a,translateExtent:l}=t();if(!s||!a||!n.x&&!n.y)return!1;let u=mu.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),c=[[0,0],[i,o]],d=s?.constrain()(u,c,l);return s.transform(a,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:Hd.connectionNodeId,connectionHandleId:Hd.connectionHandleId,connectionHandleType:Hd.connectionHandleType,connectionStatus:Hd.connectionStatus,connectionStartHandle:Hd.connectionStartHandle,connectionEndHandle:Hd.connectionEndHandle}),reset:()=>e({...Hd})}),Object.is),Lie=({children:e})=>{let t=(0,U.useRef)(null);return t.current||(t.current=c8e()),U.default.createElement(RHe,{value:t.current},e)};Lie.displayName="ReactFlowProvider";var Bie=({children:e})=>(0,U.useContext)(EE)?U.default.createElement(U.default.Fragment,null,e):U.default.createElement(Lie,null,e);Bie.displayName="ReactFlowWrapper";var d8e={input:pie,default:bL,output:gie,group:_5},h8e={default:e_,straight:C5,step:k5,smoothstep:OE,simplebezier:S5},f8e=[0,0],p8e=[15,15],m8e={x:0,y:0,zoom:1},g8e={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},qie=(0,U.forwardRef)(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o=d8e,edgeTypes:s=h8e,onNodeClick:a,onEdgeClick:l,onInit:u,onMove:c,onMoveStart:d,onMoveEnd:h,onConnect:f,onConnectStart:p,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:y,onNodeMouseEnter:v,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:k,onNodeDrag:C,onNodeDragStop:N,onNodesDelete:E,onEdgesDelete:D,onSelectionChange:q,onSelectionDragStart:z,onSelectionDrag:_,onSelectionDragStop:R,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:A,connectionMode:M=om.Strict,connectionLineType:P=wc.Bezier,connectionLineStyle:F,connectionLineComponent:I,connectionLineContainerStyle:V,deleteKeyCode:W="Backspace",selectionKeyCode:j="Shift",selectionOnDrag:X=!1,selectionMode:$=kx.Full,panActivationKeyCode:K="Space",multiSelectionKeyCode:Q=JM()?"Meta":"Control",zoomActivationKeyCode:J=JM()?"Meta":"Control",snapToGrid:oe=!1,snapGrid:be=p8e,onlyRenderVisibleElements:Me=!1,selectNodesOnDrag:Je=!0,nodesDraggable:Ve,nodesConnectable:Ct,nodesFocusable:He,nodeOrigin:de=f8e,edgesFocusable:ie,edgesUpdatable:ze,elementsSelectable:Le,defaultViewport:Oe=m8e,minZoom:rt=.5,maxZoom:Ht=2,translateExtent:$t=xL,preventScrolling:dt=!0,nodeExtent:et,defaultMarkerColor:pt="#b1b1b7",zoomOnScroll:nn=!0,zoomOnPinch:Dt=!0,panOnScroll:Ot=!1,panOnScrollSpeed:Kt=.5,panOnScrollMode:Er=Mp.Free,zoomOnDoubleClick:Dn=!0,panOnDrag:Zn=!0,onPaneClick:Un,onPaneMouseEnter:he,onPaneMouseMove:Ae,onPaneMouseLeave:ge,onPaneScroll:Be,onPaneContextMenu:ye,children:De,onEdgeContextMenu:gt,onEdgeDoubleClick:ce,onEdgeMouseEnter:$e,onEdgeMouseMove:it,onEdgeMouseLeave:Jt,onEdgeUpdate:Nt,onEdgeUpdateStart:tt,onEdgeUpdateEnd:vn,onReconnect:Yt,onReconnectStart:Mt,onReconnectEnd:bt,reconnectRadius:Rn=10,edgeUpdaterRadius:ps=10,onNodesChange:md,onEdgesChange:Fu,noDragClassName:gd="nodrag",noWheelClassName:Or="nowheel",noPanClassName:Df="nopan",fitView:wr=!1,fitViewOptions:ms,connectOnClick:ju=!0,attributionPosition:Tr,proOptions:Wa,defaultEdgeOptions:Vu,elevateNodesOnSelect:yd=!0,elevateEdgesOnSelect:Wu=!1,disableKeyboardA11y:Zs=!1,autoPanOnConnect:Ua=!0,autoPanOnNodeDrag:gs=!0,connectionRadius:zo=20,isValidConnection:er,onError:Gi,style:ur,id:Ri,nodeDragThreshold:Um,...Uu},bi)=>{let Ol=Ri||"1";return U.default.createElement("div",{...Uu,style:{...ur,...g8e},ref:bi,className:Ui(["react-flow",i]),"data-testid":"rf__wrapper",id:Ri},U.default.createElement(Bie,null,U.default.createElement(u8e,{onInit:u,onMove:c,onMoveStart:d,onMoveEnd:h,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:v,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:o,edgeTypes:s,connectionLineType:P,connectionLineStyle:F,connectionLineComponent:I,connectionLineContainerStyle:V,selectionKeyCode:j,selectionOnDrag:X,selectionMode:$,deleteKeyCode:W,multiSelectionKeyCode:Q,panActivationKeyCode:K,zoomActivationKeyCode:J,onlyRenderVisibleElements:Me,selectNodesOnDrag:Je,defaultViewport:Oe,translateExtent:$t,minZoom:rt,maxZoom:Ht,preventScrolling:dt,zoomOnScroll:nn,zoomOnPinch:Dt,zoomOnDoubleClick:Dn,panOnScroll:Ot,panOnScrollSpeed:Kt,panOnScrollMode:Er,panOnDrag:Zn,onPaneClick:Un,onPaneMouseEnter:he,onPaneMouseMove:Ae,onPaneMouseLeave:ge,onPaneScroll:Be,onPaneContextMenu:ye,onSelectionContextMenu:T,onSelectionStart:B,onSelectionEnd:A,onEdgeContextMenu:gt,onEdgeDoubleClick:ce,onEdgeMouseEnter:$e,onEdgeMouseMove:it,onEdgeMouseLeave:Jt,onReconnect:Yt??Nt,onReconnectStart:Mt??tt,onReconnectEnd:bt??vn,reconnectRadius:Rn??ps,defaultMarkerColor:pt,noDragClassName:gd,noWheelClassName:Or,noPanClassName:Df,elevateEdgesOnSelect:Wu,rfId:Ol,disableKeyboardA11y:Zs,nodeOrigin:de,nodeExtent:et}),U.default.createElement(a$e,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:p,onConnectEnd:m,onClickConnectStart:g,onClickConnectEnd:y,nodesDraggable:Ve,nodesConnectable:Ct,nodesFocusable:He,edgesFocusable:ie,edgesUpdatable:ze,elementsSelectable:Le,elevateNodesOnSelect:yd,minZoom:rt,maxZoom:Ht,nodeExtent:et,onNodesChange:md,onEdgesChange:Fu,snapToGrid:oe,snapGrid:be,connectionMode:M,translateExtent:$t,connectOnClick:ju,defaultEdgeOptions:Vu,fitView:wr,fitViewOptions:ms,onNodesDelete:E,onEdgesDelete:D,onNodeDragStart:k,onNodeDrag:C,onNodeDragStop:N,onSelectionDrag:_,onSelectionDragStart:z,onSelectionDragStop:R,noPanClassName:Df,nodeOrigin:de,rfId:Ol,autoPanOnConnect:Ua,autoPanOnNodeDrag:gs,onError:Gi,connectionRadius:zo,isValidConnection:er,nodeDragThreshold:Um}),U.default.createElement(o$e,{onSelectionChange:q}),De,U.default.createElement(PHe,{proOptions:Wa,position:Tr}),U.default.createElement(h$e,{rfId:Ol,disableKeyboardA11y:Zs})))});qie.displayName="ReactFlow";function zie(e){return t=>{let[n,r]=(0,U.useState)(t),i=(0,U.useCallback)(o=>r(s=>e(o,s)),[]);return[n,r,i]}}var zyt=zie(T5),Fyt=zie(Cie),Fie=({id:e,x:t,y:n,width:r,height:i,style:o,color:s,strokeColor:a,strokeWidth:l,className:u,borderRadius:c,shapeRendering:d,onClick:h,selected:f})=>{let{background:p,backgroundColor:m}=o||{},g=s||p||m;return hi.default.createElement("rect",{className:Ui(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:c,ry:c,width:r,height:i,fill:g,stroke:a,strokeWidth:l,shapeRendering:d,onClick:h?y=>h(y,e):void 0})};Fie.displayName="MiniMapNode";var y8e=(0,hi.memo)(Fie),v8e=e=>e.nodeOrigin,b8e=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),TR=e=>e instanceof Function?e:()=>e;function w8e({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:o=y8e,onClick:s}){let a=Vn(b8e,_i),l=Vn(v8e),u=TR(t),c=TR(e),d=TR(n),h=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return hi.default.createElement(hi.default.Fragment,null,a.map(f=>{let{x:p,y:m}=Bp(f,l).positionAbsolute;return hi.default.createElement(o,{key:f.id,x:p,y:m,width:f.width,height:f.height,style:f.style,selected:f.selected,className:d(f),color:u(f),borderRadius:r,strokeColor:c(f),strokeWidth:i,shapeRendering:h,onClick:s,id:f.id})}))}var x8e=(0,hi.memo)(w8e),S8e=200,k8e=150,C8e=e=>{let t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?qHe(TE(t,e.nodeOrigin),n):n,rfId:e.rfId}},N8e="react-flow__minimap-desc";function jie({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:s=2,nodeComponent:a,maskColor:l="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:c=1,position:d="bottom-right",onClick:h,onNodeClick:f,pannable:p=!1,zoomable:m=!1,ariaLabel:g="React Flow mini map",inversePan:y=!1,zoomStep:v=10,offsetScale:b=5}){let w=mi(),x=(0,hi.useRef)(null),{boundingRect:S,viewBB:k,rfId:C}=Vn(C8e,_i),N=e?.width??S8e,E=e?.height??k8e,D=S.width/N,q=S.height/E,z=Math.max(D,q),_=z*N,R=z*E,T=b*z,B=S.x-(_-S.width)/2-T,A=S.y-(R-S.height)/2-T,M=_+T*2,P=R+T*2,F=`${N8e}-${C}`,I=(0,hi.useRef)(0);I.current=z,(0,hi.useEffect)(()=>{if(x.current){let j=pa(x.current),X=Q=>{let{transform:J,d3Selection:oe,d3Zoom:be}=w.getState();if(Q.sourceEvent.type!=="wheel"||!oe||!be)return;let Me=-Q.sourceEvent.deltaY*(Q.sourceEvent.deltaMode===1?.05:Q.sourceEvent.deltaMode?1:.002)*v,Je=J[2]*Math.pow(2,Me);be.scaleTo(oe,Je)},$=Q=>{let{transform:J,d3Selection:oe,d3Zoom:be,translateExtent:Me,width:Je,height:Ve}=w.getState();if(Q.sourceEvent.type!=="mousemove"||!oe||!be)return;let Ct=I.current*Math.max(1,J[2])*(y?-1:1),He={x:J[0]-Q.sourceEvent.movementX*Ct,y:J[1]-Q.sourceEvent.movementY*Ct},de=[[0,0],[Je,Ve]],ie=mu.translate(He.x,He.y).scale(J[2]),ze=be.constrain()(ie,de,Me);be.transform(oe,ze)},K=Ure().on("zoom",p?$:null).on("zoom.wheel",m?X:null);return j.call(K),()=>{j.on("zoom",null)}}},[p,m,y,v]);let V=h?j=>{let X=nl(j);h(j,{x:X[0],y:X[1]})}:void 0,W=f?(j,X)=>{let $=w.getState().nodeInternals.get(X);f(j,$)}:void 0;return hi.default.createElement(b5,{position:d,style:e,className:Ui(["react-flow__minimap",t]),"data-testid":"rf__minimap"},hi.default.createElement("svg",{width:N,height:E,viewBox:`${B} ${A} ${M} ${P}`,role:"img","aria-labelledby":F,ref:x,onClick:V},g&&hi.default.createElement("title",{id:F},g),hi.default.createElement(x8e,{onClick:W,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:s,nodeComponent:a}),hi.default.createElement("path",{className:"react-flow__minimap-mask",d:`M${B-T},${A-T}h${M+T*2}v${P+T*2}h${-M-T*2}z
M${k.x},${k.y}h${k.width}v${k.height}h${-k.width}z`,fill:l,fillRule:"evenodd",stroke:u,strokeWidth:c,pointerEvents:"none"})))}jie.displayName="MiniMap";var M8e=(0,hi.memo)(jie);function _8e(){return dn.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},dn.default.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function E8e(){return dn.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},dn.default.createElement("path",{d:"M0 0h32v4.2H0z"}))}function O8e(){return dn.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},dn.default.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function T8e(){return dn.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},dn.default.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function A8e(){return dn.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},dn.default.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}var dw=({children:e,className:t,...n})=>dn.default.createElement("button",{type:"button",className:Ui(["react-flow__controls-button",t]),...n},e);dw.displayName="ControlButton";var D8e=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Vie=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:s,onFitView:a,onInteractiveChange:l,className:u,children:c,position:d="bottom-left"})=>{let h=mi(),[f,p]=(0,dn.useState)(!1),{isInteractive:m,minZoomReached:g,maxZoomReached:y}=Vn(D8e,_i),{zoomIn:v,zoomOut:b,fitView:w}=E5();if((0,dn.useEffect)(()=>{p(!0)},[]),!f)return null;let x=()=>{v(),o?.()},S=()=>{b(),s?.()},k=()=>{w(i),a?.()},C=()=>{h.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),l?.(!m)};return dn.default.createElement(b5,{className:Ui(["react-flow__controls",u]),position:d,style:e,"data-testid":"rf__controls"},t&&dn.default.createElement(dn.default.Fragment,null,dn.default.createElement(dw,{onClick:x,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y},dn.default.createElement(_8e,null)),dn.default.createElement(dw,{onClick:S,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:g},dn.default.createElement(E8e,null))),n&&dn.default.createElement(dw,{className:"react-flow__controls-fitview",onClick:k,title:"fit view","aria-label":"fit view"},dn.default.createElement(O8e,null)),r&&dn.default.createElement(dw,{className:"react-flow__controls-interactive",onClick:C,title:"toggle interactivity","aria-label":"toggle interactivity"},m?dn.default.createElement(A8e,null):dn.default.createElement(T8e,null)),c)};Vie.displayName="Controls";var R8e=(0,dn.memo)(Vie),cl;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(cl||(cl={}));function I8e({color:e,dimensions:t,lineWidth:n}){return ma.default.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function P8e({color:e,radius:t}){return ma.default.createElement("circle",{cx:t,cy:t,r:t,fill:e})}var L8e={[cl.Dots]:"#91919a",[cl.Lines]:"#eee",[cl.Cross]:"#e2e2e2"},B8e={[cl.Dots]:1,[cl.Lines]:1,[cl.Cross]:6},q8e=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Wie({id:e,variant:t=cl.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=2,color:s,style:a,className:l}){let u=(0,ma.useRef)(null),{transform:c,patternId:d}=Vn(q8e,_i),h=s||L8e[t],f=r||B8e[t],p=t===cl.Dots,m=t===cl.Cross,g=Array.isArray(n)?n:[n,n],y=[g[0]*c[2]||1,g[1]*c[2]||1],v=f*c[2],b=m?[v,v]:y,w=p?[v/o,v/o]:[b[0]/o,b[1]/o];return ma.default.createElement("svg",{className:Ui(["react-flow__background",l]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:u,"data-testid":"rf__background"},ma.default.createElement("pattern",{id:d+e,x:c[0]%y[0],y:c[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},p?ma.default.createElement(P8e,{color:h,radius:v/o}):ma.default.createElement(I8e,{dimensions:b,color:h,lineWidth:i})),ma.default.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}Wie.displayName="Background";var z8e=(0,ma.memo)(Wie),[AE,$yt]=os("Tooltip",[Kh]),DE=Kh(),Uie="TooltipProvider",F8e=700,SL="tooltip.open",[j8e,A5]=AE(Uie),Hie=e=>{let{__scopeTooltip:t,delayDuration:n=F8e,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:o}=e,s=xt.useRef(!0),a=xt.useRef(!1),l=xt.useRef(0);return xt.useEffect(()=>{let u=l.current;return()=>window.clearTimeout(u)},[]),(0,Kr.jsx)(j8e,{scope:t,isOpenDelayedRef:s,delayDuration:n,onOpen:xt.useCallback(()=>{window.clearTimeout(l.current),s.current=!1},[]),onClose:xt.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>s.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:xt.useCallback(u=>{a.current=u},[]),disableHoverableContent:i,children:o})};Hie.displayName=Uie;var Nx="Tooltip",[V8e,y1]=AE(Nx),$ie=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:o,disableHoverableContent:s,delayDuration:a}=e,l=A5(Nx,e.__scopeTooltip),u=DE(t),[c,d]=xt.useState(null),h=fi(),f=xt.useRef(0),p=s??l.disableHoverableContent,m=a??l.delayDuration,g=xt.useRef(!1),[y,v]=_a({prop:r,defaultProp:i??!1,onChange:k=>{k?(l.onOpen(),document.dispatchEvent(new CustomEvent(SL))):l.onClose(),o?.(k)},caller:Nx}),b=xt.useMemo(()=>y?g.current?"delayed-open":"instant-open":"closed",[y]),w=xt.useCallback(()=>{window.clearTimeout(f.current),f.current=0,g.current=!1,v(!0)},[v]),x=xt.useCallback(()=>{window.clearTimeout(f.current),f.current=0,v(!1)},[v]),S=xt.useCallback(()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>{g.current=!0,v(!0),f.current=0},m)},[m,v]);return xt.useEffect(()=>()=>{f.current&&(window.clearTimeout(f.current),f.current=0)},[]),(0,Kr.jsx)(d1,{...u,children:(0,Kr.jsx)(V8e,{scope:t,contentId:h,open:y,stateAttribute:b,trigger:c,onTriggerChange:d,onTriggerEnter:xt.useCallback(()=>{l.isOpenDelayedRef.current?S():w()},[l.isOpenDelayedRef,S,w]),onTriggerLeave:xt.useCallback(()=>{p?x():(window.clearTimeout(f.current),f.current=0)},[x,p]),onOpen:w,onClose:x,disableHoverableContent:p,children:n})})};$ie.displayName=Nx;var kL="TooltipTrigger",Kie=xt.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=y1(kL,n),o=A5(kL,n),s=DE(n),a=xt.useRef(null),l=qt(t,a,i.onTriggerChange),u=xt.useRef(!1),c=xt.useRef(!1),d=xt.useCallback(()=>u.current=!1,[]);return xt.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),(0,Kr.jsx)(h1,{asChild:!0,...s,children:(0,Kr.jsx)(ft.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:xe(e.onPointerMove,h=>{h.pointerType!=="touch"&&!c.current&&!o.isPointerInTransitRef.current&&(i.onTriggerEnter(),c.current=!0)}),onPointerLeave:xe(e.onPointerLeave,()=>{i.onTriggerLeave(),c.current=!1}),onPointerDown:xe(e.onPointerDown,()=>{i.open&&i.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:xe(e.onFocus,()=>{u.current||i.onOpen()}),onBlur:xe(e.onBlur,i.onClose),onClick:xe(e.onClick,i.onClose)})})});Kie.displayName=kL;var D5="TooltipPortal",[W8e,U8e]=AE(D5,{forceMount:void 0}),Yie=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,o=y1(D5,t);return(0,Kr.jsx)(W8e,{scope:t,forceMount:n,children:(0,Kr.jsx)(Vs,{present:n||o.open,children:(0,Kr.jsx)(Ov,{asChild:!0,container:i,children:r})})})};Yie.displayName=D5;var iv="TooltipContent",Qie=xt.forwardRef((e,t)=>{let n=U8e(iv,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...o}=e,s=y1(iv,e.__scopeTooltip);return(0,Kr.jsx)(Vs,{present:r||s.open,children:s.disableHoverableContent?(0,Kr.jsx)(Gie,{side:i,...o,ref:t}):(0,Kr.jsx)(H8e,{side:i,...o,ref:t})})}),H8e=xt.forwardRef((e,t)=>{let n=y1(iv,e.__scopeTooltip),r=A5(iv,e.__scopeTooltip),i=xt.useRef(null),o=qt(t,i),[s,a]=xt.useState(null),{trigger:l,onClose:u}=n,c=i.current,{onPointerInTransitChange:d}=r,h=xt.useCallback(()=>{a(null),d(!1)},[d]),f=xt.useCallback((p,m)=>{let g=p.currentTarget,y={x:p.clientX,y:p.clientY},v=G8e(y,g.getBoundingClientRect()),b=X8e(y,v),w=J8e(m.getBoundingClientRect()),x=e9e([...b,...w]);a(x),d(!0)},[d]);return xt.useEffect(()=>()=>h(),[h]),xt.useEffect(()=>{if(l&&c){let p=g=>f(g,c),m=g=>f(g,l);return l.addEventListener("pointerleave",p),c.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",p),c.removeEventListener("pointerleave",m)}}},[l,c,f,h]),xt.useEffect(()=>{if(s){let p=m=>{let g=m.target,y={x:m.clientX,y:m.clientY},v=l?.contains(g)||c?.contains(g),b=!Z8e(y,s);v?h():b&&(h(),u())};return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[l,c,s,u,h]),(0,Kr.jsx)(Gie,{...e,ref:o})}),[$8e,K8e]=AE(Nx,{isInside:!1}),Y8e=tee("TooltipContent"),Gie=xt.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:o,onPointerDownOutside:s,...a}=e,l=y1(iv,n),u=DE(n),{onClose:c}=l;return xt.useEffect(()=>(document.addEventListener(SL,c),()=>document.removeEventListener(SL,c)),[c]),xt.useEffect(()=>{if(l.trigger){let d=h=>{h.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),(0,Kr.jsx)(Ev,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:(0,Kr.jsxs)(bE,{"data-state":l.stateAttribute,...u,...a,ref:t,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:[(0,Kr.jsx)(Y8e,{children:r}),(0,Kr.jsx)($8e,{scope:n,isInside:!0,children:(0,Kr.jsx)(r4e,{id:l.contentId,role:"tooltip",children:i||r})})]})})});Qie.displayName=iv;var Xie="TooltipArrow",Q8e=xt.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=DE(n);return K8e(Xie,n).isInside?null:(0,Kr.jsx)(wE,{...i,...r,ref:t})});Q8e.displayName=Xie;function G8e(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),o=Math.abs(t.left-e.x);switch(Math.min(n,r,i,o)){case o:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function X8e(e,t,n=5){let r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function J8e(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Z8e(e,t){let{x:n,y:r}=e,i=!1;for(let o=0,s=t.length-1;o<t.length;s=o++){let a=t[o],l=t[s],u=a.x,c=a.y,d=l.x,h=l.y;c>r!=h>r&&n<(d-u)*(r-c)/(h-c)+u&&(i=!i)}return i}function e9e(e){let t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),t9e(t)}function t9e(e){if(e.length<=1)return e.slice();let t=[];for(let r=0;r<e.length;r++){let i=e[r];for(;t.length>=2;){let o=t[t.length-1],s=t[t.length-2];if((o.x-s.x)*(i.y-s.y)>=(o.y-s.y)*(i.x-s.x))t.pop();else break}t.push(i)}t.pop();let n=[];for(let r=e.length-1;r>=0;r--){let i=e[r];for(;n.length>=2;){let o=n[n.length-1],s=n[n.length-2];if((o.x-s.x)*(i.y-s.y)>=(o.y-s.y)*(i.x-s.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var n9e=Hie,r9e=$ie,i9e=Kie,o9e=Yie,Jie=Qie,RE=n9e,IE=r9e,PE=i9e,v1=Zie.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,$N.jsx)(o9e,{children:(0,$N.jsx)("div",{className:"ps",children:(0,$N.jsx)(Jie,{ref:r,sideOffset:t,className:G("z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground 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 origin-(--radix-tooltip-content-transform-origin)",e),...n})})}));v1.displayName=Jie.displayName;var HC=({iconElement:e,tooltipText:t,className:n})=>(0,Tt.jsxs)(IE,{children:[(0,Tt.jsx)(PE,{asChild:!0,children:(0,Tt.jsx)("span",{className:n,children:e})}),(0,Tt.jsx)(v1,{children:t})]}),eoe=(0,Mo.memo)(({data:e})=>{let{metadata:{activeSchema:t},createUrl:n}=lo(),r=e.label==="No Tables Found",i=o=>{let s=[];if(r&&o.type==="info")return s.push((0,Tt.jsx)(HC,{iconElement:(0,Tt.jsx)(Tz,{size:16}),tooltipText:"Informational message"},"info")),s;if(o.isPrimary?s.push((0,Tt.jsx)(HC,{iconElement:(0,Tt.jsx)(PM,{className:"size-3 text-primary"}),tooltipText:"Primary Key",className:"flex size-5 items-center justify-center rounded-full bg-muted p-0.5 text-muted-foreground"},"pk")):o.isNullable&&s.push((0,Tt.jsx)(HC,{iconElement:(0,Tt.jsx)("span",{className:"inline-flex size-4 items-center justify-center text-center text-muted-foreground",children:"?"}),tooltipText:"Nullable",className:"flex size-5 items-center justify-center rounded-full bg-muted p-0.5 text-muted-foreground"},"nullable")),o.isForeignKey){let a=o.foreignKeyTo?`Foreign Key to ${o.foreignKeyTo.table}.${o.foreignKeyTo.column}`:"Foreign Key";s.push((0,Tt.jsx)(HC,{iconElement:(0,Tt.jsx)(PM,{className:"size-3"}),tooltipText:a,className:"flex size-5 items-center justify-center rounded-full bg-primary p-0.5 text-primary-foreground"},"fk"))}return s};return(0,Tt.jsx)(RE,{delayDuration:300,children:(0,Tt.jsxs)("div",{className:G("min-w-[250px] shadow-xl rounded-md border border-border bg-card",r&&"border-orange-400"),children:[(0,Tt.jsx)(rv,{type:"target",position:Ue.Top,style:{opacity:0}}),(0,Tt.jsxs)("div",{className:G("px-4 py-3 border-b border-border flex justify-between items-center text-foreground",r&&"bg-orange-100 dark:bg-orange-950 text-orange-700 dark:text-orange-300"),children:[(0,Tt.jsx)("div",{className:"font-semibold",children:e.label}),!r&&(0,Tt.jsx)(zn,{asChild:!0,variant:"ghost",size:"icon",className:"size-7",children:(0,Tt.jsx)("a",{"aria-label":`Open table ${e.label}`,href:n({tableParam:e.label,schemaParam:t?.name,viewParam:"table"}),rel:"noopener noreferrer",title:`Open table ${e.label}`,onClick:o=>o.stopPropagation(),children:(0,Tt.jsx)(L5e,{"data-icon":"inline-start"})})})]}),(0,Tt.jsx)("div",{className:"px-4 py-2",children:r?(0,Tt.jsxs)("div",{className:"flex items-center gap-2 py-8 text-sm text-muted-foreground",children:[i({name:"message",type:"info",isNullable:!1,isPrimary:!1,isForeignKey:!1}).map((o,s)=>(0,Tt.jsx)("div",{children:o},s)),(0,Tt.jsx)("span",{className:"flex-1",children:"No database tables found. Connect to a database to see your schema."})]}):e.fields.map((o,s)=>(0,Tt.jsxs)("div",{className:G("flex items-center gap-2 py-2 text-sm text-foreground",o.isPrimary&&"text-primary"),children:[(0,Tt.jsx)("div",{className:"flex items-center gap-1 min-w-[calc(1.25rem*2+0.25rem)]",children:i(o).map((a,l)=>(0,Tt.jsx)("div",{children:a},l))}),(0,Tt.jsx)("span",{className:"flex-1 truncate max-w-44",children:o.name}),(0,Tt.jsx)("span",{className:"text-xs text-muted-foreground font-mono truncate",children:o.type})]},s))}),(0,Tt.jsx)(rv,{type:"source",position:Ue.Bottom,style:{opacity:0}})]})})});eoe.displayName="TableNode";var s9e={tableNode:eoe};function IK(e,t){if(e.length<=3)return e.map((o,s)=>({id:o.name,type:"tableNode",data:{label:o.name,fields:o.fields},position:{x:350*s,y:50}}));let n=350,r=300,i=Math.ceil(Math.sqrt(e.length));return e.map((o,s)=>{let a=s%i,l=Math.floor(s/i);return{id:o.name,type:"tableNode",data:{label:o.name,fields:o.fields},position:{x:a*n,y:l*r}}})}function a9e({tables:e,relationships:t}){let n=(0,Mo.useMemo)(()=>new Set(e.map(g=>g.name)),[e]),r=(0,Mo.useMemo)(()=>t.filter(g=>n.has(g.from)&&n.has(g.to)),[t,n]),i=(0,Mo.useMemo)(()=>IK(e,r),[e,r]),o=(0,Mo.useMemo)(()=>r.map((g,y)=>({id:`e${y}`,source:g.from,target:g.to,animated:!0,label:g.type,type:"smoothstep",style:{stroke:"var(--primary)",strokeWidth:1,strokeDasharray:"5 5"},labelStyle:{fill:"var(--primary)",fontSize:12}})),[r]),s=(0,Mo.useMemo)(()=>e.map(g=>g.name).sort().join("|")||"__empty__",[e]),[a,l]=En(`schema-visualizer:${s}:nodes`,i,{cleanupOnUnmount:!0}),[u,c]=En(`schema-visualizer:${s}:edges`,o,{cleanupOnUnmount:!0});(0,Mo.useEffect)(()=>{l(IK(e,r))},[e,r,l]),(0,Mo.useEffect)(()=>{c(r.map((g,y)=>({id:`e${y}`,source:g.from,target:g.to,animated:!0,label:g.type,type:"smoothstep",style:{stroke:"var(--primary)",strokeWidth:1,strokeDasharray:"5 5"},labelStyle:{fontSize:12}})))},[r,c]);let d=(0,Mo.useCallback)(g=>c(y=>rie(g,y)),[c]),h=(0,Mo.useCallback)(g=>l(y=>T5(g,y)),[l]),f=(0,Mo.useCallback)(g=>c(y=>Cie(g,y)),[c]),p=G("shadow-sm","[&_button]:border [&_button]:border-input [&_button]:bg-background [&_button]:shadow-sm hover:[&_button]:bg-accent hover:[&_button]:text-accent-foreground","[&_button_>_svg]:fill-foreground"),m=G("bg-muted/70 backdrop-blur-sm","[&_svg_>_rect]:fill-muted-foreground/80","[&_svg_>_path]:fill-background [&_svg_>_path]:opacity-50");return(0,Tt.jsx)(Tt.Fragment,{children:(0,Tt.jsx)("div",{className:"w-full h-full bg-card",children:(0,Tt.jsxs)(qie,{nodes:a,edges:u,onNodesChange:h,onEdgesChange:f,onConnect:d,connectionLineType:wc.SmoothStep,nodeTypes:s9e,fitView:!0,fitViewOptions:{padding:.2},children:[(0,Tt.jsx)(z8e,{className:"bg-muted",gap:16}),(0,Tt.jsx)(R8e,{showInteractive:!1,className:p}),(0,Tt.jsx)(M8e,{pannable:!0,className:m})]})})})}function l9e(e){let{tables:t,relationships:n}=H4e();return(0,Wr.jsxs)(Wr.Fragment,{children:[(0,Wr.jsxs)(f1,{children:[(0,Wr.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wr.jsx)("span",{className:"flex size-5 items-center justify-center rounded-full bg-muted p-0.5 text-muted-foreground",children:(0,Wr.jsx)(PM,{className:"size-3 text-primary"})}),(0,Wr.jsx)("p",{className:"text-xs text-muted-foreground",children:"Primary Key"})]}),(0,Wr.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wr.jsx)("span",{className:"flex size-5 items-center justify-center rounded-full bg-muted p-0.5 text-muted-foreground",children:(0,Wr.jsx)("span",{className:"inline-flex size-3 items-center justify-center text-center leading-none",children:"?"})}),(0,Wr.jsx)("p",{className:"text-xs text-muted-foreground",children:"Nullable"})]}),(0,Wr.jsxs)("div",{className:"flex items-center gap-2",children:[(0,Wr.jsx)("span",{className:"flex size-5 items-center justify-center rounded-full bg-primary p-0.5 text-primary-foreground",children:(0,Wr.jsx)(PM,{className:"size-3"})}),(0,Wr.jsx)("p",{className:"text-xs text-muted-foreground",children:"Foreign Key"})]})]}),(0,Wr.jsx)("div",{className:"w-full h-full",children:(0,Wr.jsx)(a9e,{tables:t,relationships:n})})]})}var u9e=0,AR=class{constructor(e,t){this.from=e,this.to=t}},Pt=class{constructor(e={}){this.id=u9e++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Ta.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Pt.closedBy=new Pt({deserialize:e=>e.split(" ")});Pt.openedBy=new Pt({deserialize:e=>e.split(" ")});Pt.group=new Pt({deserialize:e=>e.split(" ")});Pt.isolate=new Pt({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});Pt.contextHash=new Pt({perNode:!0});Pt.lookAhead=new Pt({perNode:!0});Pt.mounted=new Pt({perNode:!0});var qw=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Pt.mounted.id]}},c9e=Object.create(null),Ta=class toe{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):c9e,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new toe(t.name||"",n,t.id,r);if(t.props){for(let o of t.props)if(Array.isArray(o)||(o=o(i)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[o[0].id]=o[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(Pt.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(Pt.group),o=-1;o<(i?i.length:0);o++){let s=n[o<0?r.name:i[o]];if(s)return s}}}};Ta.none=new Ta("",Object.create(null),0,8);var d9e=class noe{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let o of t){let s=o(r);if(s){i||(i=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in i&&(a=l.combine(i[l.id],a)),i[l.id]=a}}n.push(i?new Ta(r.name,i,r.id,r.flags):r)}return new noe(n)}},$C=new WeakMap,PK=new WeakMap,kr;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays",e[e.EnterBracketed=16]="EnterBracketed"})(kr||(kr={}));var Ni=class CL{constructor(t,n,r,i,o){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let t=qw.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new _L(this.topNode,t)}cursorAt(t,n=0,r=0){let i=$C.get(this)||this.topNode,o=new _L(i);return o.moveTo(t,n),$C.set(this,o._tree),o}get topNode(){return new Ah(this,0,0,null)}resolve(t,n=0){let r=Mx($C.get(this)||this.topNode,t,n,!1);return $C.set(this,r),r}resolveInner(t,n=0){let r=Mx(PK.get(this)||this.topNode,t,n,!0);return PK.set(this,r),r}resolveStack(t,n=0){return m9e(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:o=this.length}=t,s=t.mode||0,a=(s&kr.IncludeAnonymous)>0;for(let l=this.cursor(s|kr.IncludeAnonymous);;){let u=!1;if(l.from<=o&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;u=!0}for(;u&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;u=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:I5(Ta.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new CL(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new CL(Ta.none,n,r,i)))}static build(t){return g9e(t)}};Ni.empty=new Ni(Ta.none,[],[],0);var h9e=class roe{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new roe(this.buffer,this.index)}},ov=class ioe{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return Ta.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],o=i.name;if(/\W/.test(o)&&!i.isError&&(o=JSON.stringify(o)),t+=4,r==t)return o;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return o+"("+s.join(",")+")"}findChild(t,n,r,i,o){let{buffer:s}=this,a=-1;for(let l=t;l!=n&&!(ooe(o,i,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(t,n,r){let i=this.buffer,o=new Uint16Array(n-t),s=0;for(let a=t,l=0;a<n;){o[l++]=i[a++],o[l++]=i[a++]-r;let u=o[l++]=i[a++]-r;o[l++]=i[a++]-t,s=Math.max(s,u)}return new ioe(o,s,this.set)}};function ooe(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function Mx(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let s=!r&&e instanceof Ah&&e.index<0?null:e.parent;if(!s)return e;e=s}let o=r?0:kr.IgnoreOverlays;if(r)for(let s=e,a=s.parent;a;s=a,a=s.parent)s instanceof Ah&&s.index<0&&((i=a.enter(t,n,o))===null||i===void 0?void 0:i.from)!=s.from&&(e=a);for(;;){let s=e.enter(t,n,o);if(!s)return e;e=s}}var soe=class{cursor(e=0){return new _L(this,e)}getChild(e,t=null,n=null){let r=LK(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return LK(this,e,t,n)}resolve(e,t=0){return Mx(this,e,t,!1)}resolveInner(e,t=0){return Mx(this,e,t,!0)}matchContext(e){return NL(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(n=t,t=r.prevSibling):t=r}return n}get node(){return this}get next(){return this.parent}},Ah=class KN extends soe{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,u=n>0?a.length:-1;t!=u;t+=n){let c=a[t],d=l[t]+s.from,h;if(!(!(o&kr.EnterBracketed&&c instanceof Ni&&(h=qw.get(c))&&!h.overlay&&h.bracketed&&r>=d&&r<=d+c.length)&&!ooe(i,r,d,d+c.length))){if(c instanceof ov){if(o&kr.ExcludeBuffers)continue;let f=c.findChild(0,c.buffer.length,n,r-d,i);if(f>-1)return new ML(new f9e(s,c,t,d),null,f)}else if(o&kr.IncludeAnonymous||!c.type.isAnonymous||R5(c)){let f;if(!(o&kr.IgnoreMounts)&&(f=qw.get(c))&&!f.overlay)return new KN(f.tree,d,t,s);let p=new KN(c,d,t,s);return o&kr.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,o)}}}if(o&kr.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?t=s.index+n:t=n<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}prop(t){return this._tree.prop(t)}enter(t,n,r=0){let i;if(!(r&kr.IgnoreOverlays)&&(i=qw.get(this._tree))&&i.overlay){let o=t-this.from,s=r&kr.EnterBracketed&&i.bracketed;for(let{from:a,to:l}of i.overlay)if((n>0||s?a<=o:a<o)&&(n<0||s?l>=o:l>o))return new KN(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function LK(e,t,n,r){let i=e.cursor(),o=[];if(!i.firstChild())return o;if(n!=null){for(let s=!1;!s;)if(s=i.type.is(n),!i.nextSibling())return o}for(;;){if(r!=null&&i.type.is(r))return o;if(i.type.is(t)&&o.push(i.node),!i.nextSibling())return r==null?o:[]}}function NL(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var f9e=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},ML=class hw extends soe{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return o<0?null:new hw(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}prop(t){return this.type.prop(t)}enter(t,n,r=0){if(r&kr.ExcludeBuffers)return null;let{buffer:i}=this.context,o=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return o<0?null:new hw(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new hw(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new hw(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,o=r.buffer[this.index+3];if(o>i){let s=r.buffer[this.index+1];t.push(r.slice(i,o,s)),n.push(0)}return new Ni(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function aoe(e){if(!e.length)return null;let t=0,n=e[0];for(let o=1;o<e.length;o++){let s=e[o];(s.from>n.from||s.to<n.to)&&(n=s,t=o)}let r=n instanceof Ah&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new p9e(i,n)}var p9e=class{constructor(e,t){this.heads=e,this.node=t}get next(){return aoe(this.heads)}};function m9e(e,t,n){let r=e.resolveInner(t,n),i=null;for(let o=r instanceof Ah?r:r.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(i||(i=[r])).push(s.resolve(t,n)),o=s}else{let s=qw.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let a=new Ah(s.tree,s.overlay[0].from+o.from,-1,o);(i||(i=[r])).push(Mx(a,t,n,!1))}}return i?aoe(i):r}var _L=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~kr.EnterBracketed,e instanceof Ah)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof Ah?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&kr.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&kr.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&kr.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let r=n<0?0:this.stack[n]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(r)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(r.buffer.buffer[i+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,o=e<0?-1:n._tree.children.length;i!=o;i+=e){let s=n._tree.children[i];if(this.mode&kr.IncludeAnonymous||s instanceof ov||!s.type.isAnonymous||R5(s))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)e:for(let r=this.index,i=this.stack.length;i>=0;){for(let o=e;o;o=o._parent)if(o.index==r){if(r==this.index)return o;t=o,n=i+1;break e}r=this.stack[--i]}for(let r=n;r<this.stack.length;r++)t=new ML(this.buffer,t,this.stack[r]);return this.bufferNode=new ML(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return NL(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return NL(this._tree,e,r);let o=n[t.buffer[this.stack[i]]];if(!o.isAnonymous){if(e[r]&&e[r]!=o.name)return!1;r--}}return!0}};function R5(e){return e.children.some(t=>t instanceof ov||!t.type.isAnonymous||R5(t))}function g9e(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=1024,reused:o=[],minRepeatType:s=r.types.length}=e,a=Array.isArray(n)?new h9e(n,n.length):n,l=r.types,u=0,c=0;function d(x,S,k,C,N,E){let{id:D,start:q,end:z,size:_}=a,R=c,T=u;if(_<0)if(a.next(),_==-1){let F=o[D];k.push(F),C.push(q-x);return}else if(_==-3){u=D;return}else if(_==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${_}`);let B=l[D],A,M,P=q-x;if(z-q<=i&&(M=g(a.pos-S,N))){let F=new Uint16Array(M.size-M.skip),I=a.pos-M.size,V=F.length;for(;a.pos>I;)V=y(M.start,F,V);A=new ov(F,z-M.start,r),P=M.start-x}else{let F=a.pos-_;a.next();let I=[],V=[],W=D>=s?D:-1,j=0,X=z;for(;a.pos>F;)W>=0&&a.id==W&&a.size>=0?(a.end<=X-i&&(p(I,V,q,j,a.end,X,W,R,T),j=I.length,X=a.end),a.next()):E>2500?h(q,F,I,V):d(q,F,I,V,W,E+1);if(W>=0&&j>0&&j<I.length&&p(I,V,q,j,q,X,W,R,T),I.reverse(),V.reverse(),W>-1&&j>0){let $=f(B,T);A=I5(B,I,V,0,I.length,0,z-q,$,$)}else A=m(B,I,V,z-q,R-z,T)}k.push(A),C.push(P)}function h(x,S,k,C){let N=[],E=0,D=-1;for(;a.pos>S;){let{id:q,start:z,end:_,size:R}=a;if(R>4)a.next();else{if(D>-1&&z<D)break;D<0&&(D=_-i),N.push(q,z,_),E++,a.next()}}if(E){let q=new Uint16Array(E*4),z=N[N.length-2];for(let _=N.length-3,R=0;_>=0;_-=3)q[R++]=N[_],q[R++]=N[_+1]-z,q[R++]=N[_+2]-z,q[R++]=R;k.push(new ov(q,N[2]-z,r)),C.push(z-x)}}function f(x,S){return(k,C,N)=>{let E=0,D=k.length-1,q,z;if(D>=0&&(q=k[D])instanceof Ni){if(!D&&q.type==x&&q.length==N)return q;(z=q.prop(Pt.lookAhead))&&(E=C[D]+q.length+z)}return m(x,k,C,N,E,S)}}function p(x,S,k,C,N,E,D,q,z){let _=[],R=[];for(;x.length>C;)_.push(x.pop()),R.push(S.pop()+k-N);x.push(m(r.types[D],_,R,E-N,q-E,z)),S.push(N-k)}function m(x,S,k,C,N,E,D){if(E){let q=[Pt.contextHash,E];D=D?[q].concat(D):[q]}if(N>25){let q=[Pt.lookAhead,N];D=D?[q].concat(D):[q]}return new Ni(x,S,k,C,D)}function g(x,S){let k=a.fork(),C=0,N=0,E=0,D=k.end-i,q={size:0,start:0,skip:0};e:for(let z=k.pos-x;k.pos>z;){let _=k.size;if(k.id==S&&_>=0){q.size=C,q.start=N,q.skip=E,E+=4,C+=4,k.next();continue}let R=k.pos-_;if(_<0||R<z||k.start<D)break;let T=k.id>=s?4:0,B=k.start;for(k.next();k.pos>R;){if(k.size<0)if(k.size==-3||k.size==-4)T+=4;else break e;else k.id>=s&&(T+=4);k.next()}N=B,C+=_,E+=T}return(S<0||C==x)&&(q.size=C,q.start=N,q.skip=E),q.size>4?q:void 0}function y(x,S,k){let{id:C,start:N,end:E,size:D}=a;if(a.next(),D>=0&&C<s){let q=k;if(D>4){let z=a.pos-(D-4);for(;a.pos>z;)k=y(x,S,k)}S[--k]=q,S[--k]=E-x,S[--k]=N-x,S[--k]=C}else D==-3?u=C:D==-4&&(c=C);return k}let v=[],b=[];for(;a.pos>0;)d(e.start||0,e.bufferStart||0,v,b,-1,0);let w=(t=e.length)!==null&&t!==void 0?t:v.length?b[0]+v[0].length:0;return new Ni(l[e.topID],v.reverse(),b.reverse(),w)}var BK=new WeakMap;function YN(e,t){if(!e.isAnonymous||t instanceof ov||t.type!=e)return 1;let n=BK.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof Ni)){n=1;break}n+=YN(e,r)}BK.set(t,n)}return n}function I5(e,t,n,r,i,o,s,a,l){let u=0;for(let p=r;p<i;p++)u+=YN(e,t[p]);let c=Math.ceil(u*1.5/8),d=[],h=[];function f(p,m,g,y,v){for(let b=g;b<y;){let w=b,x=m[b],S=YN(e,p[b]);for(b++;b<y;b++){let k=YN(e,p[b]);if(S+k>=c)break;S+=k}if(b==w+1){if(S>c){let k=p[w];f(k.children,k.positions,0,k.children.length,m[w]+v);continue}d.push(p[w])}else{let k=m[b-1]+p[b-1].length-x;d.push(I5(e,p,m,w,b,x,k,null,l))}h.push(x+v-o)}}return f(t,n,r,i,0),(a||l)(d,h,s)}var QN=class EL{constructor(t,n,r,i,o=!1,s=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new EL(0,t.length,t,0,!1,r)];for(let o of n)o.to>t.length&&i.push(o);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],o=1,s=t.length?t[0]:null;for(let a=0,l=0,u=0;;a++){let c=a<n.length?n[a]:null,d=c?c.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let h=s;if(l>=h.from||d<=h.to||u){let f=Math.max(h.from,l)-u,p=Math.min(h.to,d)-u;h=f>=p?null:new EL(f,p,h.tree,h.offset+u,a>0,!!c)}if(h&&i.push(h),s.to>d)break;s=o<t.length?t[o++]:null}if(!c)break;l=c.toA,u=c.toA-c.toB}return i}},loe=class{startParse(e,t,n){return typeof e=="string"&&(e=new y9e(e)),n=n?n.length?n.map(r=>new AR(r.from,r.to)):[new AR(0,0)]:[new AR(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let i=r.advance();if(i)return i}}},y9e=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}},Kyt=new Pt({perNode:!0}),OL=[],uoe=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?uoe:OL).push(n=n+e[t])})();function v9e(e){if(e<768)return!1;for(let t=0,n=OL.length;;){let r=t+n>>1;if(e<OL[r])n=r;else if(e>=uoe[r])t=r+1;else return!0;if(t==n)return!1}}function qK(e){return e>=127462&&e<=127487}var zK=8205;function b9e(e,t,n=!0,r=!0){return(n?coe:w9e)(e,t,r)}function coe(e,t,n){if(t==e.length)return t;t&&doe(e.charCodeAt(t))&&hoe(e.charCodeAt(t-1))&&t--;let r=DR(e,t);for(t+=FK(r);t<e.length;){let i=DR(e,t);if(r==zK||i==zK||n&&v9e(i))t+=FK(i),r=i;else if(qK(i)){let o=0,s=t-2;for(;s>=0&&qK(DR(e,s));)o++,s-=2;if(o%2==0)break;t+=2}else break}return t}function w9e(e,t,n){for(;t>0;){let r=coe(e,t-2,n);if(r<t)return r;t--}return 0}function DR(e,t){let n=e.charCodeAt(t);if(!hoe(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return doe(r)?(n-55296<<10)+(r-56320)+65536:n}function doe(e){return e>=56320&&e<57344}function hoe(e){return e>=55296&&e<56320}function FK(e){return e<65536?1:2}var sn=class foe{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=sv(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),GN.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=sv(this,t,n);let r=[];return this.decompose(t,n,r,0),GN.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new zw(this),o=new zw(t);for(let s=n,a=n;;){if(i.next(s),o.next(s),s=0,i.lineBreak!=o.lineBreak||i.done!=o.done||i.value!=o.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(t=1){return new zw(this,t)}iterRange(t,n=this.length){return new poe(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new moe(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?foe.empty:t.length<=32?new sl(t):GN.from(sl.split(t,[]))}},sl=class Gl extends sn{constructor(t,n=x9e(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let o=0;;o++){let s=this.text[o],a=i+s.length;if((n?r:a)>=t)return new S9e(i,a,r,s);i=a+1,r++}}decompose(t,n,r,i){let o=t<=0&&n>=this.length?this:new Gl(jK(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let s=r.pop(),a=XN(o.text,s.text.slice(),0,o.length);if(a.length<=32)r.push(new Gl(a,s.length+o.length));else{let l=a.length>>1;r.push(new Gl(a.slice(0,l)),new Gl(a.slice(l)))}}else r.push(o)}replace(t,n,r){if(!(r instanceof Gl))return super.replace(t,n,r);[t,n]=sv(this,t,n);let i=XN(this.text,XN(r.text,jK(this.text,0,t)),n),o=this.length+r.length-(n-t);return i.length<=32?new Gl(i,o):GN.from(Gl.split(i,[]),o)}sliceString(t,n=this.length,r=`
`){[t,n]=sv(this,t,n);let i="";for(let o=0,s=0;o<=n&&s<this.text.length;s++){let a=this.text[s],l=o+a.length;o>t&&s&&(i+=r),t<l&&n>o&&(i+=a.slice(Math.max(0,t-o),n-o)),o=l+1}return i}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let o of t)r.push(o),i+=o.length+1,r.length==32&&(n.push(new Gl(r,i)),r=[],i=-1);return i>-1&&n.push(new Gl(r,i)),n}},GN=class ty extends sn{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,i){for(let o=0;;o++){let s=this.children[o],a=i+s.length,l=r+s.lines-1;if((n?l:a)>=t)return s.lineInner(t,n,r,i);i=a+1,r=l+1}}decompose(t,n,r,i){for(let o=0,s=0;s<=n&&o<this.children.length;o++){let a=this.children[o],l=s+a.length;if(t<=l&&n>=s){let u=i&((s<=t?1:0)|(l>=n?2:0));s>=t&&l<=n&&!u?r.push(a):a.decompose(t-s,n-s,r,u)}s=l+1}}replace(t,n,r){if([t,n]=sv(this,t,n),r.lines<this.lines)for(let i=0,o=0;i<this.children.length;i++){let s=this.children[i],a=o+s.length;if(t>=o&&n<=a){let l=s.replace(t-o,n-o,r),u=this.lines-s.lines+l.lines;if(l.lines<u>>4&&l.lines>u>>6){let c=this.children.slice();return c[i]=l,new ty(c,this.length-(n-t)+r.length)}return super.replace(o,a,l)}o=a+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
`){[t,n]=sv(this,t,n);let i="";for(let o=0,s=0;o<this.children.length&&s<=n;o++){let a=this.children[o],l=s+a.length;s>t&&o&&(i+=r),t<l&&n>s&&(i+=a.sliceString(t-s,n-s,r)),s=l+1}return i}flatten(t){for(let n of this.children)n.flatten(t)}scanIdentical(t,n){if(!(t instanceof ty))return 0;let r=0,[i,o,s,a]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,o+=n){if(i==s||o==a)return r;let l=this.children[i],u=t.children[o];if(l!=u)return r+l.scanIdentical(u,n);r+=l.length+1}}static from(t,n=t.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let f of t)r+=f.lines;if(r<32){let f=[];for(let p of t)p.flatten(f);return new sl(f,n)}let i=Math.max(32,r>>5),o=i<<1,s=i>>1,a=[],l=0,u=-1,c=[];function d(f){let p;if(f.lines>o&&f instanceof ty)for(let m of f.children)d(m);else f.lines>s&&(l>s||!l)?(h(),a.push(f)):f instanceof sl&&l&&(p=c[c.length-1])instanceof sl&&f.lines+p.lines<=32?(l+=f.lines,u+=f.length+1,c[c.length-1]=new sl(p.text.concat(f.text),p.length+1+f.length)):(l+f.lines>i&&h(),l+=f.lines,u+=f.length+1,c.push(f))}function h(){l!=0&&(a.push(c.length==1?c[0]:ty.from(c,u)),u=-1,l=c.length=0)}for(let f of t)d(f);return h(),a.length==1?a[0]:new ty(a,n)}};sn.empty=new sl([""],0);function x9e(e){let t=-1;for(let n of e)t+=n.length+1;return t}function XN(e,t,n=0,r=1e9){for(let i=0,o=0,s=!0;o<e.length&&i<=r;o++){let a=e[o],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),s?(t[t.length-1]+=a,s=!1):t.push(a)),i=l+1}return t}function jK(e,t,n){return XN(e,[""],t,n)}var zw=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof sl?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],o=i>>1,s=r instanceof sl?r.text.length:r.children.length;if(o==(t>0?s:0)){if(n==0)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
`,this;e--}else if(r instanceof sl){let a=r.text[o+(t<0?-1:0)];if(this.offsets[n]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=r.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof sl?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},poe=class{constructor(e,t,n){this.value="",this.done=!1,this.cursor=new zw(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}},moe=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value="",this.afterBreak=!1):t?(this.done=!0,this.value=""):n?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<"u"&&(sn.prototype[Symbol.iterator]=function(){return this.iter()},zw.prototype[Symbol.iterator]=poe.prototype[Symbol.iterator]=moe.prototype[Symbol.iterator]=function(){return this});var S9e=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function sv(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function Mi(e,t,n=!0,r=!0){return b9e(e,t,n,r)}function k9e(e){return e>=56320&&e<57344}function C9e(e){return e>=55296&&e<56320}function Ko(e,t){let n=e.charCodeAt(t);if(!C9e(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return k9e(r)?(n-55296<<10)+(r-56320)+65536:n}function P5(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function su(e){return e<65536?1:2}var TL=/\r\n?|\n/,_o=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(_o||(_o={})),Iy=class JN{constructor(t){this.sections=t}get length(){let t=0;for(let n=0;n<this.sections.length;n+=2)t+=this.sections[n];return t}get newLength(){let t=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];t+=r<0?this.sections[n]:r}return t}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(t){for(let n=0,r=0,i=0;n<this.sections.length;){let o=this.sections[n++],s=this.sections[n++];s<0?(t(r,i,o),i+=o):i+=s,r+=o}}iterChangedRanges(t,n=!1){AL(this,t,n)}get invertedDesc(){let t=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?t.push(r,i):t.push(i,r)}return new JN(t)}composeDesc(t){return this.empty?t:t.empty?this:goe(this,t)}mapDesc(t,n=!1){return t.empty?this:DL(this,t,n)}mapPos(t,n=-1,r=_o.Simple){let i=0,o=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],u=i+a;if(l<0){if(u>t)return o+(t-i);o+=a}else{if(r!=_o.Simple&&u>=t&&(r==_o.TrackDel&&i<t&&u>t||r==_o.TrackBefore&&i<t||r==_o.TrackAfter&&u>t))return null;if(u>t||u==t&&n<0&&!a)return t==i||n<0?o:o+l;o+=l}i=u}if(t>i)throw new RangeError(`Position ${t} is out of range for changeset of length ${i}`);return o}touchesRange(t,n=t){for(let r=0,i=0;r<this.sections.length&&i<=n;){let o=this.sections[r++],s=this.sections[r++],a=i+o;if(s>=0&&i<=n&&a>=t)return i<t&&a>n?"cover":!0;i=a}return!1}toString(){let t="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];t+=(t?" ":"")+r+(i>=0?":"+i:"")}return t}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new JN(t)}static create(t){return new JN(t)}},ml=class Xd extends Iy{constructor(t,n){super(t),this.inserted=n}apply(t){if(this.length!=t.length)throw new RangeError("Applying change set to a document with the wrong length");return AL(this,(n,r,i,o,s)=>t=t.replace(i,i+(r-n),s),!1),t}mapDesc(t,n=!1){return DL(this,t,n,!0)}invert(t){let n=this.sections.slice(),r=[];for(let i=0,o=0;i<n.length;i+=2){let s=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=s;let l=i>>1;for(;r.length<l;)r.push(sn.empty);r.push(s?t.slice(o,o+s):sn.empty)}o+=s}return new Xd(n,r)}compose(t){return this.empty?t:t.empty?this:goe(this,t,!0)}map(t,n=!1){return t.empty?this:DL(this,t,n,!0)}iterChanges(t,n=!1){AL(this,t,n)}get desc(){return Iy.create(this.sections)}filter(t){let n=[],r=[],i=[],o=new _x(this);e:for(let s=0,a=0;;){let l=s==t.length?1e9:t[s++];for(;a<l||a==l&&o.len==0;){if(o.done)break e;let c=Math.min(o.len,l-a);no(i,c,-1);let d=o.ins==-1?-1:o.off==0?o.ins:0;no(n,c,d),d>0&&dh(r,n,o.text),o.forward(c),a+=c}let u=t[s++];for(;a<u;){if(o.done)break e;let c=Math.min(o.len,u-a);no(n,c,-1),no(i,c,o.ins==-1?-1:o.off==0?o.ins:0),o.forward(c),a+=c}}return{changes:new Xd(n,r),filtered:Iy.create(i)}}toJSON(){let t=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?t.push(r):i==0?t.push([r]):t.push([r].concat(this.inserted[n>>1].toJSON()))}return t}static of(t,n,r){let i=[],o=[],s=0,a=null;function l(c=!1){if(!c&&!i.length)return;s<n&&no(i,n-s,-1);let d=new Xd(i,o);a=a?a.compose(d.map(a)):d,i=[],o=[],s=0}function u(c){if(Array.isArray(c))for(let d of c)u(d);else if(c instanceof Xd){if(c.length!=n)throw new RangeError(`Mismatched change set length (got ${c.length}, expected ${n})`);l(),a=a?a.compose(c.map(a)):c}else{let{from:d,to:h=d,insert:f}=c;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let p=f?typeof f=="string"?sn.of(f.split(r||TL)):f:sn.empty,m=p.length;if(d==h&&m==0)return;d<s&&l(),d>s&&no(i,d-s,-1),no(i,h-d,m),dh(o,i,p),s=h}}return u(t),l(!a),a}static empty(t){return new Xd(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<t.length;i++){let o=t[i];if(typeof o=="number")n.push(o,-1);else{if(!Array.isArray(o)||typeof o[0]!="number"||o.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(o.length==1)n.push(o[0],0);else{for(;r.length<i;)r.push(sn.empty);r[i]=sn.of(o.slice(1)),n.push(o[0],r[i].length)}}}return new Xd(n,r)}static createSet(t,n){return new Xd(t,n)}};function no(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function dh(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(sn.empty);e.push(n)}}function AL(e,t,n){let r=e.inserted;for(let i=0,o=0,s=0;s<e.sections.length;){let a=e.sections[s++],l=e.sections[s++];if(l<0)i+=a,o+=a;else{let u=i,c=o,d=sn.empty;for(;u+=a,c+=l,l&&r&&(d=d.append(r[s-2>>1])),!(n||s==e.sections.length||e.sections[s+1]<0);)a=e.sections[s++],l=e.sections[s++];t(i,u,o,c,d),i=u,o=c}}}function DL(e,t,n,r=!1){let i=[],o=r?[]:null,s=new _x(e),a=new _x(t);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let u=Math.min(s.len,a.len);no(i,u,-1),s.forward(u),a.forward(u)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!n))){let u=a.len;for(no(i,a.ins,-1);u;){let c=Math.min(s.len,u);s.ins>=0&&l<s.i&&s.len<=c&&(no(i,0,s.ins),o&&dh(o,i,s.text),l=s.i),s.forward(c),u-=c}a.next()}else if(s.ins>=0){let u=0,c=s.len;for(;c;)if(a.ins==-1){let d=Math.min(c,a.len);u+=d,c-=d,a.forward(d)}else if(a.ins==0&&a.len<c)c-=a.len,a.next();else break;no(i,u,l<s.i?s.ins:0),o&&l<s.i&&dh(o,i,s.text),l=s.i,s.forward(s.len-c)}else{if(s.done&&a.done)return o?ml.createSet(i,o):Iy.create(i);throw new Error("Mismatched change set lengths")}}}function goe(e,t,n=!1){let r=[],i=n?[]:null,o=new _x(e),s=new _x(t);for(let a=!1;;){if(o.done&&s.done)return i?ml.createSet(r,i):Iy.create(r);if(o.ins==0)no(r,o.len,0,a),o.next();else if(s.len==0&&!s.done)no(r,0,s.ins,a),i&&dh(i,r,s.text),s.next();else{if(o.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(o.len2,s.len),u=r.length;if(o.ins==-1){let c=s.ins==-1?-1:s.off?0:s.ins;no(r,l,c,a),i&&c&&dh(i,r,s.text)}else s.ins==-1?(no(r,o.off?0:o.len,l,a),i&&dh(i,r,o.textBit(l))):(no(r,o.off?0:o.len,s.off?0:s.ins,a),i&&!s.off&&dh(i,r,s.text));a=(o.ins>l||s.ins>=0&&s.len>l)&&(a||r.length>u),o.forward2(l),s.forward(l)}}}}var _x=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?sn.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?sn.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},KC=class RL{constructor(t,n,r){this.from=t,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let t=this.flags&7;return t==7?null:t}get goalColumn(){let t=this.flags>>6;return t==16777215?void 0:t}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new RL(r,i,this.flags)}extend(t,n=t){if(t<=this.anchor&&n>=this.anchor)return ae.range(t,n);let r=Math.abs(t-this.anchor)>Math.abs(n-this.anchor)?t:n;return ae.range(this.anchor,r)}eq(t,n=!1){return this.anchor==t.anchor&&this.head==t.head&&this.goalColumn==t.goalColumn&&(!n||!this.empty||this.assoc==t.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(t){if(!t||typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ae.range(t.anchor,t.head)}static create(t,n,r){return new RL(t,n,r)}},ae=class Ms{constructor(t,n){this.ranges=t,this.mainIndex=n}map(t,n=-1){return t.empty?this:Ms.create(this.ranges.map(r=>r.map(t,n)),this.mainIndex)}eq(t,n=!1){if(this.ranges.length!=t.ranges.length||this.mainIndex!=t.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(t.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new Ms([this.main],0)}addRange(t,n=!0){return Ms.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,Ms.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(t=>t.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!="number"||t.main>=t.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ms(t.ranges.map(n=>KC.fromJSON(n)),t.main)}static single(t,n=t){return new Ms([Ms.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<t.length;i++){let o=t[i];if(o.empty?o.from<=r:o.from<r)return Ms.normalized(t.slice(),n);r=o.to}return new Ms(t,n)}static cursor(t,n=0,r,i){return KC.create(t,t,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(t,n,r,i){let o=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<t?KC.create(n,t,48|o):KC.create(t,n,(n>t?8:0)|o)}static normalized(t,n=0){let r=t[n];t.sort((i,o)=>i.from-o.from),n=t.indexOf(r);for(let i=1;i<t.length;i++){let o=t[i],s=t[i-1];if(o.empty?o.from<=s.to:o.from<s.to){let a=s.from,l=Math.max(o.to,s.to);i<=n&&n--,t.splice(--i,2,o.anchor>o.head?Ms.range(l,a):Ms.range(a,l))}}return new Ms(t,n)}};function yoe(e,t){for(let n of e.ranges)if(n.to>t)throw new RangeError("Selection points outside of document")}var L5=0,Te=class voe{constructor(t,n,r,i,o){this.combine=t,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=L5++,this.default=t([]),this.extensions=typeof o=="function"?o(this):o}get reader(){return this}static define(t={}){return new voe(t.combine||(n=>n),t.compareInput||((n,r)=>n===r),t.compare||(t.combine?(n,r)=>n===r:B5),!!t.static,t.enables)}of(t){return new ZN([],this,0,t)}compute(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ZN(t,this,1,n)}computeN(t,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new ZN(t,this,2,n)}from(t,n){return n||(n=r=>r),this.compute([t],r=>n(r.field(t)))}};function B5(e,t){return e==t||e.length==t.length&&e.every((n,r)=>n===t[r])}var ZN=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=L5++}dynamicSlot(e){var t;let n=this.value,r=this.facet.compareInput,i=this.id,o=e[i]>>1,s=this.type==2,a=!1,l=!1,u=[];for(let c of this.dependencies)c=="doc"?a=!0:c=="selection"?l=!0:(((t=e[c.id])!==null&&t!==void 0?t:1)&1)==0&&u.push(e[c.id]);return{create(c){return c.values[o]=n(c),1},update(c,d){if(a&&d.docChanged||l&&(d.docChanged||d.selection)||IL(c,u)){let h=n(c);if(s?!VK(h,c.values[o],r):!r(h,c.values[o]))return c.values[o]=h,1}return 0},reconfigure:(c,d)=>{let h,f=d.config.address[i];if(f!=null){let p=t_(d,f);if(this.dependencies.every(m=>m instanceof Te?d.facet(m)===c.facet(m):m instanceof uo?d.field(m,!1)==c.field(m,!1):!0)||(s?VK(h=n(c),p,r):r(h=n(c),p)))return c.values[o]=p,0}else h=n(c);return c.values[o]=h,1}}}};function VK(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function IL(e,t){let n=!1;for(let r of t)Fw(e,r)&1&&(n=!0);return n}function N9e(e,t,n){let r=n.map(l=>e[l.id]),i=n.map(l=>l.type),o=r.filter(l=>!(l&1)),s=e[t.id]>>1;function a(l){let u=[];for(let c=0;c<r.length;c++){let d=t_(l,r[c]);if(i[c]==2)for(let h of d)u.push(h);else u.push(d)}return t.combine(u)}return{create(l){for(let u of r)Fw(l,u);return l.values[s]=a(l),1},update(l,u){if(!IL(l,o))return 0;let c=a(l);return t.compare(c,l.values[s])?0:(l.values[s]=c,1)},reconfigure(l,u){let c=IL(l,r),d=u.config.facets[t.id],h=u.facet(t);if(d&&!c&&B5(n,d))return l.values[s]=h,0;let f=a(l);return t.compare(f,h)?(l.values[s]=h,0):(l.values[s]=f,1)}}}var YC=Te.define({static:!0}),uo=class boe{constructor(t,n,r,i,o){this.id=t,this.createF=n,this.updateF=r,this.compareF=i,this.spec=o,this.provides=void 0}static define(t){let n=new boe(L5++,t.create,t.update,t.compare||((r,i)=>r===i),t);return t.provide&&(n.provides=t.provide(n)),n}create(t){return(t.facet(YC).find(r=>r.field==this)?.create||this.createF)(t)}slot(t){let n=t[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let o=r.values[n],s=this.updateF(o,i);return this.compareF(o,s)?0:(r.values[n]=s,1)},reconfigure:(r,i)=>{let o=r.facet(YC),s=i.facet(YC),a;return(a=o.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(r.values[n]=a.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(t){return[this,YC.of({field:this,create:t})]}get extension(){return this}},bp={lowest:4,low:3,default:2,high:1,highest:0};function Ub(e){return t=>new woe(t,e)}var Xh={highest:Ub(bp.highest),high:Ub(bp.high),default:Ub(bp.default),low:Ub(bp.low),lowest:Ub(bp.lowest)},woe=class{constructor(e,t){this.inner=e,this.prec=t}},xoe=class Soe{of(t){return new PL(this,t)}reconfigure(t){return Soe.reconfigure.of({compartment:this,extension:t})}get(t){return t.config.compartments.get(this)}},PL=class{constructor(e,t){this.compartment=e,this.inner=t}},WK=class koe{constructor(t,n,r,i,o,s){for(this.base=t,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=o,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(t){let n=this.address[t.id];return n==null?t.default:this.staticValues[n>>1]}static resolve(t,n,r){let i=[],o=Object.create(null),s=new Map;for(let h of M9e(t,n,s))h instanceof uo?i.push(h):(o[h.facet.id]||(o[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],u=[];for(let h of i)a[h.id]=u.length<<1,u.push(f=>h.slot(f));let c=r?.config.facets;for(let h in o){let f=o[h],p=f[0].facet,m=c&&c[h]||[];if(f.every(g=>g.type==0))if(a[p.id]=l.length<<1|1,B5(m,f))l.push(r.facet(p));else{let g=p.combine(f.map(y=>y.value));l.push(r&&p.compare(g,r.facet(p))?r.facet(p):g)}else{for(let g of f)g.type==0?(a[g.id]=l.length<<1|1,l.push(g.value)):(a[g.id]=u.length<<1,u.push(y=>g.dynamicSlot(y)));a[p.id]=u.length<<1,u.push(g=>N9e(g,p,f))}}let d=u.map(h=>h(a));return new koe(t,s,d,a,l,o)}};function M9e(e,t,n){let r=[[],[],[],[],[]],i=new Map;function o(s,a){let l=i.get(s);if(l!=null){if(l<=a)return;let u=r[l].indexOf(s);u>-1&&r[l].splice(u,1),s instanceof PL&&n.delete(s.compartment)}if(i.set(s,a),Array.isArray(s))for(let u of s)o(u,a);else if(s instanceof PL){if(n.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=t.get(s.compartment)||s.inner;n.set(s.compartment,u),o(u,a)}else if(s instanceof woe)o(s.inner,s.prec);else if(s instanceof uo)r[a].push(s),s.provides&&o(s.provides,a);else if(s instanceof ZN)r[a].push(s),s.facet.extensions&&o(s.facet.extensions,bp.default);else{let u=s.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);o(u,a)}}return o(e,bp.default),r.reduce((s,a)=>s.concat(a))}function Fw(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function t_(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Coe=Te.define(),LL=Te.define({combine:e=>e.some(t=>t),static:!0}),Noe=Te.define({combine:e=>e.length?e[0]:void 0,static:!0}),Moe=Te.define(),_oe=Te.define(),Eoe=Te.define(),Ooe=Te.define({combine:e=>e.length?e[0]:!1}),Ou=class{constructor(e,t){this.type=e,this.value=t}static define(){return new _9e}},_9e=class{of(e){return new Ou(this,e)}},E9e=class{constructor(e){this.map=e}of(e){return new St(this,e)}},St=class Toe{constructor(t,n){this.type=t,this.value=n}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new Toe(this.type,n)}is(t){return this.type==t}static define(t={}){return new E9e(t.map||(n=>n))}static mapEffects(t,n){if(!t.length)return t;let r=[];for(let i of t){let o=i.map(n);o&&r.push(o)}return r}};St.reconfigure=St.define();St.appendConfig=St.define();var ts=class fw{constructor(t,n,r,i,o,s){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=o,this.scrollIntoView=s,this._doc=null,this._state=null,r&&yoe(r,n.newLength),o.some(a=>a.type==fw.time)||(this.annotations=o.concat(fw.time.of(Date.now())))}static create(t,n,r,i,o,s){return new fw(t,n,r,i,o,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(t){for(let n of this.annotations)if(n.type==t)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(fw.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]=="."))}};ts.time=Ou.define();ts.userEvent=Ou.define();ts.addToHistory=Ou.define();ts.remote=Ou.define();function O9e(e,t){let n=[];for(let r=0,i=0;;){let o,s;if(r<e.length&&(i==t.length||t[i]>=e[r]))o=e[r++],s=e[r++];else if(i<t.length)o=t[i++],s=t[i++];else return n;!n.length||n[n.length-1]<o?n.push(o,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function Aoe(e,t,n){var r;let i,o,s;return n?(i=t.changes,o=ml.empty(t.changes.length),s=e.changes.compose(t.changes)):(i=t.changes.map(e.changes),o=e.changes.mapDesc(t.changes,!0),s=e.changes.compose(i)),{changes:s,selection:t.selection?t.selection.map(o):(r=e.selection)===null||r===void 0?void 0:r.map(i),effects:St.mapEffects(e.effects,i).concat(St.mapEffects(t.effects,o)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function BL(e,t,n){let r=t.selection,i=Py(t.annotations);return t.userEvent&&(i=i.concat(ts.userEvent.of(t.userEvent))),{changes:t.changes instanceof ml?t.changes:ml.of(t.changes||[],n,e.facet(Noe)),selection:r&&(r instanceof ae?r:ae.single(r.anchor,r.head)),effects:Py(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function Doe(e,t,n){let r=BL(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let o=1;o<t.length;o++){t[o].filter===!1&&(n=!1);let s=!!t[o].sequential;r=Aoe(r,BL(e,t[o],s?r.changes.newLength:e.doc.length),s)}let i=ts.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return A9e(n?T9e(i):i)}function T9e(e){let t=e.startState,n=!0;for(let i of t.facet(Moe)){let o=i(e);if(o===!1){n=!1;break}Array.isArray(o)&&(n=n===!0?o:O9e(n,o))}if(n!==!0){let i,o;if(n===!1)o=e.changes.invertedDesc,i=ml.empty(t.doc.length);else{let s=e.changes.filter(n);i=s.changes,o=s.filtered.mapDesc(s.changes).invertedDesc}e=ts.create(t,i,e.selection&&e.selection.map(o),St.mapEffects(e.effects,o),e.annotations,e.scrollIntoView)}let r=t.facet(_oe);for(let i=r.length-1;i>=0;i--){let o=r[i](e);o instanceof ts?e=o:Array.isArray(o)&&o.length==1&&o[0]instanceof ts?e=o[0]:e=Doe(t,Py(o),!1)}return e}function A9e(e){let t=e.startState,n=t.facet(Eoe),r=e;for(let i=n.length-1;i>=0;i--){let o=n[i](e);o&&Object.keys(o).length&&(r=Aoe(r,BL(t,o,e.changes.newLength),!0))}return r==e?e:ts.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var D9e=[];function Py(e){return e==null?D9e:Array.isArray(e)?e:[e]}var rr=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(rr||(rr={})),R9e=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,qL;try{qL=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function I9e(e){if(qL)return qL.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>"\x80"&&(n.toUpperCase()!=n.toLowerCase()||R9e.test(n)))return!0}return!1}function P9e(e){return t=>{if(!/\S/.test(t))return rr.Space;if(I9e(t))return rr.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return rr.Word;return rr.Other}}var or=class Ja{constructor(t,n,r,i,o,s){this.config=t,this.doc=n,this.selection=r,this.values=i,this.status=t.statusTemplate.slice(),this.computeSlot=o,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Fw(this,a<<1);this.computeSlot=null}field(t,n=!0){let r=this.config.address[t.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return Fw(this,r),t_(this,r)}update(...t){return Doe(this,t,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let a of t.effects)a.is(xoe.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,u)=>i.set(u,l)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(St.reconfigure)?(n=null,r=a.value):a.is(St.appendConfig)&&(n=null,r=Py(r).concat(a.value));let o;n?o=t.startState.values.slice():(n=WK.resolve(r,i,this),o=new Ja(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,l)=>l.reconfigure(a,this),null).values);let s=t.startState.facet(LL)?t.newSelection:t.newSelection.asSingle();new Ja(n,t.newDoc,s,o,(a,l)=>l.update(a,t),t)}replaceSelection(t){return typeof t=="string"&&(t=this.toText(t)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:t},range:ae.cursor(n.from+t.length)}))}changeByRange(t){let n=this.selection,r=t(n.ranges[0]),i=this.changes(r.changes),o=[r.range],s=Py(r.effects);for(let a=1;a<n.ranges.length;a++){let l=t(n.ranges[a]),u=this.changes(l.changes),c=u.map(i);for(let h=0;h<a;h++)o[h]=o[h].map(c);let d=i.mapDesc(u,!0);o.push(l.range.map(d)),i=i.compose(c),s=St.mapEffects(s,c).concat(St.mapEffects(Py(l.effects),d))}return{changes:i,selection:ae.create(o,n.mainIndex),effects:s}}changes(t=[]){return t instanceof ml?t:ml.of(t,this.doc.length,this.facet(Ja.lineSeparator))}toText(t){return sn.of(t.split(this.facet(Ja.lineSeparator)||TL))}sliceDoc(t=0,n=this.doc.length){return this.doc.sliceString(t,n,this.lineBreak)}facet(t){let n=this.config.address[t.id];return n==null?t.default:(Fw(this,n),t_(this,n))}toJSON(t){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(t)for(let r in t){let i=t[r];i instanceof uo&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(t[r]),this))}return n}static fromJSON(t,n={},r){if(!t||typeof t.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let o in r)if(Object.prototype.hasOwnProperty.call(t,o)){let s=r[o],a=t[o];i.push(s.init(l=>s.spec.fromJSON(a,l)))}}return Ja.create({doc:t.doc,selection:ae.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=WK.resolve(t.extensions||[],new Map),r=t.doc instanceof sn?t.doc:sn.of((t.doc||"").split(n.staticFacet(Ja.lineSeparator)||TL)),i=t.selection?t.selection instanceof ae?t.selection:ae.single(t.selection.anchor,t.selection.head):ae.single(0);return yoe(i,r.length),n.staticFacet(LL)||(i=i.asSingle()),new Ja(n,r,i,n.dynamicSlots.map(()=>null),(o,s)=>s.create(o),null)}get tabSize(){return this.facet(Ja.tabSize)}get lineBreak(){return this.facet(Ja.lineSeparator)||`
`}get readOnly(){return this.facet(Ooe)}phrase(t,...n){for(let r of this.facet(Ja.phrases))if(Object.prototype.hasOwnProperty.call(r,t)){t=r[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let o=+(i||1);return!o||o>n.length?r:n[o-1]})),t}languageDataAt(t,n,r=-1){let i=[];for(let o of this.facet(Coe))for(let s of o(this,n,r))Object.prototype.hasOwnProperty.call(s,t)&&i.push(s[t]);return i}charCategorizer(t){let n=this.languageDataAt("wordChars",t);return P9e(n.length?n[0]:"")}wordAt(t){let{text:n,from:r,length:i}=this.doc.lineAt(t),o=this.charCategorizer(t),s=t-r,a=t-r;for(;s>0;){let l=Mi(n,s,!1);if(o(n.slice(l,s))!=rr.Word)break;s=l}for(;a<i;){let l=Mi(n,a);if(o(n.slice(a,l))!=rr.Word)break;a=l}return s==a?null:ae.range(s+r,a+r)}};or.allowMultipleSelections=LL;or.tabSize=Te.define({combine:e=>e.length?e[0]:4});or.lineSeparator=Noe;or.readOnly=Ooe;or.phrases=Te.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(i=>e[i]==t[i])}});or.languageData=Coe;or.changeFilter=Moe;or.transactionFilter=_oe;or.transactionExtender=Eoe;xoe.reconfigure=St.define();function kl(e,t,n={}){let r={};for(let i of e)for(let o of Object.keys(i)){let s=i[o],a=r[o];if(a===void 0)r[o]=s;else if(!(a===s||s===void 0))if(Object.hasOwnProperty.call(n,o))r[o]=n[o](a,s);else throw new Error("Config merge conflict for field "+o)}for(let i in t)r[i]===void 0&&(r[i]=t[i]);return r}var Dh=class{eq(e){return this==e}range(e,t=e){return zL.create(e,t,this)}};Dh.prototype.startSide=Dh.prototype.endSide=0;Dh.prototype.point=!1;Dh.prototype.mapMode=_o.TrackDel;function q5(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var zL=class Roe{constructor(t,n,r){this.from=t,this.to=n,this.value=r}static create(t,n,r){return new Roe(t,n,r)}};function FL(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var L9e=class Ioe{constructor(t,n,r,i){this.from=t,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(t,n,r,i=0){let o=r?this.to:this.from;for(let s=i,a=o.length;;){if(s==a)return s;let l=s+a>>1,u=o[l]-t||(r?this.value[l].endSide:this.value[l].startSide)-n;if(l==s)return u>=0?s:a;u>=0?a=l:s=l+1}}between(t,n,r,i){for(let o=this.findIndex(n,-1e9,!0),s=this.findIndex(r,1e9,!1,o);o<s;o++)if(i(this.from[o]+t,this.to[o]+t,this.value[o])===!1)return!1}map(t,n){let r=[],i=[],o=[],s=-1,a=-1;for(let l=0;l<this.value.length;l++){let u=this.value[l],c=this.from[l]+t,d=this.to[l]+t,h,f;if(c==d){let p=n.mapPos(c,u.startSide,u.mapMode);if(p==null||(h=f=p,u.startSide!=u.endSide&&(f=n.mapPos(c,u.endSide),f<h)))continue}else if(h=n.mapPos(c,u.startSide),f=n.mapPos(d,u.endSide),h>f||h==f&&u.startSide>0&&u.endSide<=0)continue;(f-h||u.endSide-u.startSide)<0||(s<0&&(s=h),u.point&&(a=Math.max(a,f-h)),r.push(u),i.push(h-s),o.push(f-s))}return{mapped:r.length?new Ioe(i,o,r,a):null,pos:s}}},hn=class pc{constructor(t,n,r,i){this.chunkPos=t,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(t,n,r,i){return new pc(t,n,r,i)}get length(){let t=this.chunk.length-1;return t<0?0:Math.max(this.chunkEnd(t),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let t=this.nextLayer.size;for(let n of this.chunk)t+=n.value.length;return t}chunkEnd(t){return this.chunkPos[t]+this.chunk[t].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:o=this.length}=t,s=t.filter;if(n.length==0&&!s)return this;if(r&&(n=n.slice().sort(FL)),this.isEmpty)return n.length?pc.of(n):this;let a=new Loe(this,null,-1).goto(0),l=0,u=[],c=new sm;for(;a.value||l<n.length;)if(l<n.length&&(a.from-n[l].from||a.startSide-n[l].value.startSide)>=0){let d=n[l++];c.addInner(d.from,d.to,d.value)||u.push(d)}else a.rangeIndex==1&&a.chunkIndex<this.chunk.length&&(l==n.length||this.chunkEnd(a.chunkIndex)<n[l].from)&&(!s||i>this.chunkEnd(a.chunkIndex)||o<this.chunkPos[a.chunkIndex])&&c.addChunk(this.chunkPos[a.chunkIndex],this.chunk[a.chunkIndex])?a.nextChunk():((!s||i>a.to||o<a.from||s(a.from,a.to,a.value))&&(c.addInner(a.from,a.to,a.value)||u.push(zL.create(a.from,a.to,a.value))),a.next());return c.finishInner(this.nextLayer.isEmpty&&!u.length?pc.empty:this.nextLayer.update({add:u,filter:s,filterFrom:i,filterTo:o}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1;for(let s=0;s<this.chunk.length;s++){let a=this.chunkPos[s],l=this.chunk[s],u=t.touchesRange(a,a+l.length);if(u===!1)i=Math.max(i,l.maxPoint),n.push(l),r.push(t.mapPos(a));else if(u===!0){let{mapped:c,pos:d}=l.map(a,t);c&&(i=Math.max(i,c.maxPoint),n.push(c),r.push(d))}}let o=this.nextLayer.map(t);return n.length==0?o:new pc(r,n,o||pc.empty,i)}between(t,n,r){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let o=this.chunkPos[i],s=this.chunk[i];if(n>=o&&t<=o+s.length&&s.between(o,t-o,n-o,r)===!1)return}this.nextLayer.between(t,n,r)}}iter(t=0){return jL.from([this]).goto(t)}get isEmpty(){return this.nextLayer==this}static iter(t,n=0){return jL.from(t).goto(n)}static compare(t,n,r,i,o=-1){let s=t.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=o),a=n.filter(d=>d.maxPoint>0||!d.isEmpty&&d.maxPoint>=o),l=UK(s,a,r),u=new Hb(s,l,o),c=new Hb(a,l,o);r.iterGaps((d,h,f)=>HK(u,d,c,h,f,i)),r.empty&&r.length==0&&HK(u,0,c,0,0,i)}static eq(t,n,r=0,i){i==null&&(i=999999999);let o=t.filter(c=>!c.isEmpty&&n.indexOf(c)<0),s=n.filter(c=>!c.isEmpty&&t.indexOf(c)<0);if(o.length!=s.length)return!1;if(!o.length)return!0;let a=UK(o,s),l=new Hb(o,a,0).goto(r),u=new Hb(s,a,0).goto(r);for(;;){if(l.to!=u.to||!VL(l.active,u.active)||l.point&&(!u.point||!q5(l.point,u.point)))return!1;if(l.to>i)return!0;l.next(),u.next()}}static spans(t,n,r,i,o=-1){let s=new Hb(t,null,o).goto(n),a=n,l=s.openStart;for(;;){let u=Math.min(s.to,r);if(s.point){let c=s.activeForPoint(s.to),d=s.pointFrom<n?c.length+1:s.point.startSide<0?c.length:Math.min(c.length,l);i.point(a,u,s.point,c,d,s.pointRank),l=Math.min(s.openEnd(u),c.length)}else u>a&&(i.span(a,u,s.active,l),l=s.openEnd(u));if(s.to>r)return l+(s.point&&s.to>r?1:0);a=s.to,s.next()}}static of(t,n=!1){let r=new sm;for(let i of t instanceof zL?[t]:n?B9e(t):t)r.add(i.from,i.to,i.value);return r.finish()}static join(t){if(!t.length)return pc.empty;let n=t[t.length-1];for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=pc.empty;i=i.nextLayer)n=new pc(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};hn.empty=new hn([],[],null,-1);function B9e(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(FL(t,r)>0)return e.slice().sort(FL);t=r}return e}hn.empty.nextLayer=hn.empty;var sm=class Poe{finishChunk(t){this.chunks.push(new L9e(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,t&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(t,n,r){this.addInner(t,n,r)||(this.nextLayer||(this.nextLayer=new Poe)).add(t,n,r)}addInner(t,n,r){let i=t-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(t-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=t),this.from.push(t-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=t,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-t)),!0)}addChunk(t,n){if((t-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(t);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+t,this.lastTo=n.to[r]+t,!0}finish(){return this.finishInner(hn.empty)}finishInner(t){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return t;let n=hn.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(t):t,this.setMaxPoint);return this.from=null,n}};function UK(e,t,n){let r=new Map;for(let o of e)for(let s=0;s<o.chunk.length;s++)o.chunk[s].maxPoint<=0&&r.set(o.chunk[s],o.chunkPos[s]);let i=new Set;for(let o of t)for(let s=0;s<o.chunk.length;s++){let a=r.get(o.chunk[s]);a!=null&&(n?n.mapPos(a):a)==o.chunkPos[s]&&!n?.touchesRange(a,a+o.chunk[s].length)&&i.add(o.chunk[s])}return i}var Loe=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let r=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(r)||this.layer.chunkEnd(this.chunkIndex)<e||r.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},jL=class Boe{constructor(t){this.heap=t}static from(t,n=null,r=-1){let i=[];for(let o=0;o<t.length;o++)for(let s=t[o];!s.isEmpty;s=s.nextLayer)s.maxPoint>=r&&i.push(new Loe(s,n,r,o));return i.length==1?i[0]:new Boe(i)}get startSide(){return this.value?this.value.startSide:0}goto(t,n=-1e9){for(let r of this.heap)r.goto(t,n);for(let r=this.heap.length>>1;r>=0;r--)RR(this.heap,r);return this.next(),this}forward(t,n){for(let r of this.heap)r.forward(t,n);for(let r=this.heap.length>>1;r>=0;r--)RR(this.heap,r);(this.to-t||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let t=this.heap[0];this.from=t.from,this.to=t.to,this.value=t.value,this.rank=t.rank,t.value&&t.next(),RR(this.heap,0)}}};function RR(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var Hb=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=jL.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){QC(this.active,e),QC(this.activeTo,e),QC(this.activeRank,e),this.minActive=$K(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;GC(this.active,t,n),GC(this.activeTo,t,r),GC(this.activeRank,t,i),e&&GC(e,t,this.cursor.from),this.minActive=$K(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&QC(n,r)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let i=this.cursor.value;if(!i.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=i,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=i.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let r=n.length-1;r>=0&&n[r]<e;r--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function HK(e,t,n,r,i,o){e.goto(t),n.goto(r);let s=r+i,a=r,l=r-t,u=!!o.boundChange;for(let c=!1;;){let d=e.to+l-n.to,h=d||e.endSide-n.endSide,f=h<0?e.to+l:n.to,p=Math.min(f,s);if(e.point||n.point?(e.point&&n.point&&q5(e.point,n.point)&&VL(e.activeForPoint(e.to),n.activeForPoint(n.to))||o.comparePoint(a,p,e.point,n.point),c=!1):(c&&o.boundChange(a),p>a&&!VL(e.active,n.active)&&o.compareRange(a,p,e.active,n.active),u&&p<s&&(d||e.openEnd(f)!=n.openEnd(f))&&(c=!0)),f>s)break;a=f,h<=0&&e.next(),h>=0&&n.next()}}function VL(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!q5(e[n],t[n]))return!1;return!0}function QC(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function GC(e,t,n){for(let r=e.length-1;r>=t;r--)e[r+1]=e[r];e[t]=n}function $K(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function Iv(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=Mi(e,i));return r}function WL(e,t,n,r){for(let i=0,o=0;;){if(o>=t)return i;if(i==e.length)break;o+=e.charCodeAt(i)==9?n-o%n:1,i=Mi(e,i)}return r===!0?-1:e.length}var KK=typeof Symbol>"u"?"__\u037C":Symbol.for("\u037C"),UL=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),YK=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{},Rh=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function i(o,s,a,l){let u=[],c=/^@(\w+)\b/.exec(o[0]),d=c&&c[1]=="keyframes";if(c&&s==null)return a.push(o[0]+";");for(let h in s){let f=s[h];if(/&/.test(h))i(h.split(/,\s*/).map(p=>o.map(m=>p.replace(/&/,m))).reduce((p,m)=>p.concat(m)),f,a);else if(f&&typeof f=="object"){if(!c)throw new RangeError("The value of a property ("+h+") should be a primitive value.");i(r(h),f,u,d)}else f!=null&&u.push(h.replace(/_.*/,"").replace(/[A-Z]/g,p=>"-"+p.toLowerCase())+": "+f+";")}(u.length||d)&&a.push((n&&!c&&!l?o.map(n):o).join(", ")+" {"+u.join(" ")+"}")}for(let o in e)i(r(o),e[o],this.rules)}getRules(){return this.rules.join(`
`)}static newName(){let e=YK[KK]||1;return YK[KK]=e+1,"\u037C"+e.toString(36)}static mount(e,t,n){let r=e[UL],i=n&&n.nonce;r?i&&r.setNonce(i):r=new q9e(e,i),r.mount(Array.isArray(t)?t:[t],e)}},QK=new Map,q9e=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let i=QK.get(n);if(i)return e[UL]=i;this.sheet=new r.CSSStyleSheet,QK.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[UL]=this}mount(e,t){let n=this.sheet,r=0,i=0;for(let o=0;o<e.length;o++){let s=e[o],a=this.modules.indexOf(s);if(a<i&&a>-1&&(this.modules.splice(a,1),i--,a=-1),a==-1){if(this.modules.splice(i++,0,s),n)for(let l=0;l<s.rules.length;l++)n.insertRule(s.rules[l],r++)}else{for(;i<a;)r+=this.modules[i++].rules.length;r+=s.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let o="";for(let a=0;a<this.modules.length;a++)o+=this.modules[a].getRules()+`
`;this.styleTag.textContent=o;let s=t.head||t;this.styleTag.parentNode!=s&&s.insertBefore(this.styleTag,s.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}},Ih={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:"'"},Ex={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},z9e=typeof navigator<"u"&&/Mac/.test(navigator.platform),F9e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Hr=0;Hr<10;Hr++)Ih[48+Hr]=Ih[96+Hr]=String(Hr);var Hr;for(Hr=1;Hr<=24;Hr++)Ih[Hr+111]="F"+Hr;var Hr;for(Hr=65;Hr<=90;Hr++)Ih[Hr]=String.fromCharCode(Hr+32),Ex[Hr]=String.fromCharCode(Hr);var Hr;for(XC in Ih)Ex.hasOwnProperty(XC)||(Ex[XC]=Ih[XC]);var XC;function j9e(e){var t=z9e&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||F9e&&e.shiftKey&&e.key&&e.key.length==1||e.key=="Unidentified",n=!t&&e.key||(e.shiftKey?Ex:Ih)[e.keyCode]||e.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function xn(){var e=arguments[0];typeof e=="string"&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)qoe(e,arguments[t]);return e}function qoe(e,t){if(typeof t=="string")e.appendChild(document.createTextNode(t));else if(t!=null)if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)qoe(e,t[n]);else throw new RangeError("Unsupported child node: "+t)}var So=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},HL=typeof document<"u"?document:{documentElement:{style:{}}},$L=/Edge\/(\d+)/.exec(So.userAgent),zoe=/MSIE \d/.test(So.userAgent),KL=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(So.userAgent),LE=!!(zoe||KL||$L),GK=!LE&&/gecko\/(\d+)/i.test(So.userAgent),IR=!LE&&/Chrome\/(\d+)/.exec(So.userAgent),XK="webkitFontSmoothing"in HL.documentElement.style,YL=!LE&&/Apple Computer/.test(So.vendor),JK=YL&&(/Mobile\/\w+/.test(So.userAgent)||So.maxTouchPoints>2),_e={mac:JK||/Mac/.test(So.platform),windows:/Win/.test(So.platform),linux:/Linux|X11/.test(So.platform),ie:LE,ie_version:zoe?HL.documentMode||6:KL?+KL[1]:$L?+$L[1]:0,gecko:GK,gecko_version:GK?+(/Firefox\/(\d+)/.exec(So.userAgent)||[0,0])[1]:0,chrome:!!IR,chrome_version:IR?+IR[1]:0,ios:JK,android:/Android\b/.test(So.userAgent),webkit:XK,webkit_version:XK?+(/\bAppleWebKit\/(\d+)/.exec(So.userAgent)||[0,0])[1]:0,safari:YL,safari_version:YL?+(/\bVersion\/(\d+(\.\d+)?)/.exec(So.userAgent)||[0,0])[1]:0,tabSize:HL.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function z5(e,t){for(let n in e)n=="class"&&t.class?t.class+=" "+e.class:n=="style"&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}var n_=Object.create(null);function F5(e,t,n){if(e==t)return!0;e||(e=n_),t||(t=n_);let r=Object.keys(e),i=Object.keys(t);if(r.length-(n&&r.indexOf(n)>-1?1:0)!=i.length-(n&&i.indexOf(n)>-1?1:0))return!1;for(let o of r)if(o!=n&&(i.indexOf(o)==-1||e[o]!==t[o]))return!1;return!0}function V9e(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]==null&&e.removeAttribute(r)}for(let n in t){let r=t[n];n=="style"?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function ZK(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i=="style"?e.style.cssText="":e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i=="style"?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function W9e(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var Tu=class{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},Vi=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(Vi||(Vi={})),Qe=class extends Dh{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new j5(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new Ox(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:o}=Woe(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(o?t?2e8:1:-6e8)+1}return new Ox(e,n,r,t,e.widget||null,!0)}static line(e){return new V5(e)}static set(e,t=!1){return hn.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};Qe.none=hn.empty;var j5=class Foe extends Qe{constructor(t){let{start:n,end:r}=Woe(t);super(n?-1:5e8,r?1:-6e8,null,t),this.tagName=t.tagName||"span",this.attrs=t.class&&t.attributes?z5(t.attributes,{class:t.class}):t.class?{class:t.class}:t.attributes||n_}eq(t){return this==t||t instanceof Foe&&this.tagName==t.tagName&&F5(this.attrs,t.attrs)}range(t,n=t){if(t>=n)throw new RangeError("Mark decorations may not be empty");return super.range(t,n)}};j5.prototype.point=!1;var V5=class joe extends Qe{constructor(t){super(-2e8,-2e8,null,t)}eq(t){return t instanceof joe&&this.spec.class==t.spec.class&&F5(this.spec.attributes,t.spec.attributes)}range(t,n=t){if(n!=t)throw new RangeError("Line decoration ranges must be zero-length");return super.range(t,n)}};V5.prototype.mapMode=_o.TrackBefore;V5.prototype.point=!0;var Ox=class Voe extends Qe{constructor(t,n,r,i,o,s){super(n,r,o,t),this.block=i,this.isReplace=s,this.mapMode=i?n<=0?_o.TrackBefore:_o.TrackAfter:_o.TrackDel}get type(){return this.startSide!=this.endSide?Vi.WidgetRange:this.startSide<=0?Vi.WidgetBefore:Vi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof Voe&&U9e(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(t,n=t){if(this.isReplace&&(t>n||t==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=t)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(t,n)}};Ox.prototype.point=!0;function Woe(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n==null&&(n=e.inclusive),r==null&&(r=e.inclusive),{start:n??t,end:r??t}}function U9e(e,t){return e==t||!!(e&&t&&e.compare(t))}function Ly(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var e7=class QL extends Dh{constructor(t,n){super(),this.tagName=t,this.attributes=n}eq(t){return t==this||t instanceof QL&&this.tagName==t.tagName&&F5(this.attributes,t.attributes)}static create(t){return new QL(t.tagName,t.attributes||n_)}static set(t,n=!1){return hn.of(t,n)}};e7.prototype.startSide=e7.prototype.endSide=-1;function Tx(e){let t;return e.nodeType==11?t=e.getSelection?e:e.ownerDocument:t=e,t.getSelection()}function GL(e,t){return t?e==t||e.contains(t.nodeType!=1?t.parentNode:t):!1}function jw(e,t){if(!t.anchorNode)return!1;try{return GL(e,t.anchorNode)}catch{return!1}}function Vw(e){return e.nodeType==3?Dx(e,0,e.nodeValue.length).getClientRects():e.nodeType==1?e.getClientRects():[]}function Ww(e,t,n,r){return n?t7(e,t,n,r,-1)||t7(e,t,n,r,1):!1}function Ph(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function r_(e){return e.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function t7(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:jc(e))){if(e.nodeName=="DIV")return!1;let o=e.parentNode;if(!o||o.nodeType!=1)return!1;t=Ph(e)+(i<0?0:1),e=o}else if(e.nodeType==1){if(e=e.childNodes[t+(i<0?-1:0)],e.nodeType==1&&e.contentEditable=="false")return!1;t=i<0?jc(e):0}else return!1}}function jc(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Ax(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function H9e(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Uoe(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function $9e(e,t,n,r,i,o,s,a){let l=e.ownerDocument,u=l.defaultView||window;for(let c=e,d=!1;c&&!d;)if(c.nodeType==1){let h,f=c==l.body,p=1,m=1;if(f)h=H9e(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let v=c.getBoundingClientRect();({scaleX:p,scaleY:m}=Uoe(c,v)),h={left:v.left,right:v.left+c.clientWidth*p,top:v.top,bottom:v.top+c.clientHeight*m}}let g=0,y=0;if(i=="nearest")t.top<h.top?(y=t.top-(h.top+s),n>0&&t.bottom>h.bottom+y&&(y=t.bottom-h.bottom+s)):t.bottom>h.bottom&&(y=t.bottom-h.bottom+s,n<0&&t.top-y<h.top&&(y=t.top-(h.top+s)));else{let v=t.bottom-t.top,b=h.bottom-h.top;y=(i=="center"&&v<=b?t.top+v/2-b/2:i=="start"||i=="center"&&n<0?t.top-s:t.bottom-b+s)-h.top}if(r=="nearest"?t.left<h.left?(g=t.left-(h.left+o),n>0&&t.right>h.right+g&&(g=t.right-h.right+o)):t.right>h.right&&(g=t.right-h.right+o,n<0&&t.left<h.left+g&&(g=t.left-(h.left+o))):g=(r=="center"?t.left+(t.right-t.left)/2-(h.right-h.left)/2:r=="start"==a?t.left-o:t.right-(h.right-h.left)+o)-h.left,g||y)if(f)u.scrollBy(g,y);else{let v=0,b=0;if(y){let w=c.scrollTop;c.scrollTop+=y/m,b=(c.scrollTop-w)*m}if(g){let w=c.scrollLeft;c.scrollLeft+=g/p,v=(c.scrollLeft-w)*p}t={left:t.left-v,top:t.top-b,right:t.right-v,bottom:t.bottom-b},v&&Math.abs(v-g)<1&&(r="nearest"),b&&Math.abs(b-y)<1&&(i="nearest")}if(f)break;(t.top<h.top||t.bottom>h.bottom||t.left<h.left||t.right>h.right)&&(t={left:Math.max(t.left,h.left),right:Math.min(t.right,h.right),top:Math.max(t.top,h.top),bottom:Math.min(t.bottom,h.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function Hoe(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let o=e.parentNode;o&&!(o==n.body||(!t||r)&&i);)if(o.nodeType==1)!i&&o.scrollHeight>o.clientHeight&&(i=o),t&&!r&&o.scrollWidth>o.clientWidth&&(r=o),o=o.assignedSlot||o.parentNode;else if(o.nodeType==11)o=o.host;else break;return{x:r,y:i}}var K9e=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?jc(t):0),n,Math.min(e.focusOffset,n?jc(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}},gp=null;_e.safari&&_e.safari_version>=26&&(gp=!1);function $oe(e){if(e.setActive)return e.setActive();if(gp)return e.focus(gp);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(gp==null?{get preventScroll(){return gp={preventScroll:!0},!0}}:void 0),!gp){gp=!1;for(let n=0;n<t.length;){let r=t[n++],i=t[n++],o=t[n++];r.scrollTop!=i&&(r.scrollTop=i),r.scrollLeft!=o&&(r.scrollLeft=o)}}}var n7;function Dx(e,t,n=t){let r=n7||(n7=document.createRange());return r.setEnd(e,n),r.setStart(e,t),r}function By(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let o=new KeyboardEvent("keydown",i);o.synthetic=!0,e.dispatchEvent(o);let s=new KeyboardEvent("keyup",i);return s.synthetic=!0,e.dispatchEvent(s),o.defaultPrevented||s.defaultPrevented}function Y9e(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Q9e(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,jc(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=jc(n))}else{if(n==e)return!0;r=Ph(n),n=n.parentNode}}function Koe(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Yoe(e,t){for(let n=e,r=t;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=jc(n)}else if(n.parentNode&&!r_(n))r=Ph(n),n=n.parentNode;else return null}}function Qoe(e,t){for(let n=e,r=t;;){if(n.nodeType==3&&r<n.nodeValue.length)return{node:n,offset:r};if(n.nodeType==1&&r<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!r_(n))r=Ph(n)+1,n=n.parentNode;else return null}}var hh=class XL{constructor(t,n,r=!0){this.node=t,this.offset=n,this.precise=r}static before(t,n){return new XL(t.parentNode,Ph(t),n)}static after(t,n){return new XL(t.parentNode,Ph(t)+1,n)}},On=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(On||(On={})),am=On.LTR,W5=On.RTL;function Goe(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<+e[n]);return t}var G9e=Goe("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),X9e=Goe("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),JL=Object.create(null),Kl=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);JL[t]=n,JL[n]=-t}function Xoe(e){return e<=247?G9e[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?X9e[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var J9e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,uu=class{get dir(){return this.level%2?W5:am}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let o=0;o<e.length;o++){let s=e[o];if(s.from<=t&&s.to>=t){if(s.level==n)return o;(i<0||(r!=0?r<0?s.from<t:s.to>t:e[i].level>s.level))&&(i=o)}}if(i<0)throw new RangeError("Index out of range");return i}};function Joe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!Joe(r.inner,i.inner))return!1}return!0}var _n=[];function Z9e(e,t,n,r,i){for(let o=0;o<=r.length;o++){let s=o?r[o-1].to:t,a=o<r.length?r[o].from:n,l=o?256:i;for(let u=s,c=l,d=l;u<a;u++){let h=Xoe(e.charCodeAt(u));h==512?h=c:h==8&&d==4&&(h=16),_n[u]=h==4?2:h,h&7&&(d=h),c=h}for(let u=s,c=l,d=l;u<a;u++){let h=_n[u];if(h==128)u<a-1&&c==_n[u+1]&&c&24?h=_n[u]=c:_n[u]=256;else if(h==64){let f=u+1;for(;f<a&&_n[f]==64;)f++;let p=u&&c==8||f<n&&_n[f]==8?d==1?1:8:256;for(let m=u;m<f;m++)_n[m]=p;u=f-1}else h==8&&d==1&&(_n[u]=1);c=h,h&7&&(d=h)}}}function eKe(e,t,n,r,i){let o=i==1?2:1;for(let s=0,a=0,l=0;s<=r.length;s++){let u=s?r[s-1].to:t,c=s<r.length?r[s].from:n;for(let d=u,h,f,p;d<c;d++)if(f=JL[h=e.charCodeAt(d)])if(f<0){for(let m=a-3;m>=0;m-=3)if(Kl[m+1]==-f){let g=Kl[m+2],y=g&2?i:g&4?g&1?o:i:0;y&&(_n[d]=_n[Kl[m]]=y),a=m;break}}else{if(Kl.length==189)break;Kl[a++]=d,Kl[a++]=h,Kl[a++]=l}else if((p=_n[d])==2||p==1){let m=p==i;l=m?0:1;for(let g=a-3;g>=0;g-=3){let y=Kl[g+2];if(y&2)break;if(m)Kl[g+2]|=2;else{if(y&4)break;Kl[g+2]|=4}}}}}function tKe(e,t,n,r){for(let i=0,o=r;i<=n.length;i++){let s=i?n[i-1].to:e,a=i<n.length?n[i].from:t;for(let l=s;l<a;){let u=_n[l];if(u==256){let c=l+1;for(;;)if(c==a){if(i==n.length)break;c=n[i++].to,a=i<n.length?n[i].from:t}else if(_n[c]==256)c++;else break;let d=o==1,h=(c<t?_n[c]:r)==1,f=d==h?d?1:2:r;for(let p=c,m=i,g=m?n[m-1].to:e;p>l;)p==g&&(p=n[--m].from,g=m?n[m-1].to:e),_n[--p]=f;l=c}else o=u,l++}}}function ZL(e,t,n,r,i,o,s){let a=r%2?2:1;if(r%2==i%2)for(let l=t,u=0;l<n;){let c=!0,d=!1;if(u==o.length||l<o[u].from){let m=_n[l];m!=a&&(c=!1,d=m==16)}let h=!c&&a==1?[]:null,f=c?r:r+1,p=l;e:for(;;)if(u<o.length&&p==o[u].from){if(d)break e;let m=o[u];if(!c)for(let g=m.to,y=u+1;;){if(g==n)break e;if(y<o.length&&o[y].from==g)g=o[y++].to;else{if(_n[g]==a)break e;break}}if(u++,h)h.push(m);else{m.from>l&&s.push(new uu(l,m.from,f));let g=m.direction==am!=!(f%2);eB(e,g?r+1:r,i,m.inner,m.from,m.to,s),l=m.to}p=m.to}else{if(p==n||(c?_n[p]!=a:_n[p]==a))break;p++}h?ZL(e,l,p,r+1,i,h,s):l<p&&s.push(new uu(l,p,f)),l=p}else for(let l=n,u=o.length;l>t;){let c=!0,d=!1;if(!u||l>o[u-1].to){let m=_n[l-1];m!=a&&(c=!1,d=m==16)}let h=!c&&a==1?[]:null,f=c?r:r+1,p=l;e:for(;;)if(u&&p==o[u-1].to){if(d)break e;let m=o[--u];if(!c)for(let g=m.from,y=u;;){if(g==t)break e;if(y&&o[y-1].to==g)g=o[--y].from;else{if(_n[g-1]==a)break e;break}}if(h)h.push(m);else{m.to<l&&s.push(new uu(m.to,l,f));let g=m.direction==am!=!(f%2);eB(e,g?r+1:r,i,m.inner,m.from,m.to,s),l=m.from}p=m.from}else{if(p==t||(c?_n[p-1]!=a:_n[p-1]==a))break;p--}h?ZL(e,p,l,r+1,i,h,s):p<l&&s.push(new uu(p,l,f)),l=p}}function eB(e,t,n,r,i,o,s){let a=t%2?2:1;Z9e(e,i,o,r,a),eKe(e,i,o,r,a),tKe(i,o,r,a),ZL(e,i,o,t,n,r,s)}function nKe(e,t,n){if(!e)return[new uu(0,0,t==W5?1:0)];if(t==am&&!n.length&&!J9e.test(e))return Zoe(e.length);if(n.length)for(;e.length>_n.length;)_n[_n.length]=256;let r=[],i=t==am?0:1;return eB(e,i,i,n,0,e.length,r),r}function Zoe(e){return[new uu(0,e,0)]}var ese="";function rKe(e,t,n,r,i){var o;let s=r.head-e.from,a=uu.find(t,s,(o=r.bidiLevel)!==null&&o!==void 0?o:-1,r.assoc),l=t[a],u=l.side(i,n);if(s==u){let h=a+=i?1:-1;if(h<0||h>=t.length)return null;l=t[a=h],s=l.side(!i,n),u=l.side(i,n)}let c=Mi(e.text,s,l.forward(i,n));(c<l.from||c>l.to)&&(c=u),ese=e.text.slice(Math.min(s,c),Math.max(s,c));let d=a==(i?t.length-1:0)?null:t[a+(i?1:-1)];return d&&c==u&&d.level+(i?0:1)<l.level?ae.cursor(d.side(!i,n)+e.from,d.forward(i,n)?1:-1,d.level):ae.cursor(c+e.from,l.forward(i,n)?-1:1,l.level)}function iKe(e,t,n){for(let r=t;r<n;r++){let i=Xoe(e.charCodeAt(r));if(i==1)return am;if(i==2||i==4)return W5}return am}var tse=Te.define(),nse=Te.define(),rse=Te.define(),ise=Te.define(),tB=Te.define(),ose=Te.define(),sse=Te.define(),U5=Te.define(),H5=Te.define(),ase=Te.define({combine:e=>e.some(t=>t)}),lse=Te.define({combine:e=>e.some(t=>t)}),use=Te.define(),PR=class nB{constructor(t,n="nearest",r="nearest",i=5,o=5,s=!1){this.range=t,this.y=n,this.x=r,this.yMargin=i,this.xMargin=o,this.isSnapshot=s}map(t){return t.empty?this:new nB(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new nB(ae.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},JC=St.define({map:(e,t)=>e.map(t)}),cse=St.define();function Ao(e,t,n){let r=e.facet(ise);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}var xc=Te.define({combine:e=>e.length?e[0]:!0}),oKe=0,ky=Te.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),Jr=class rB{constructor(t,n,r,i,o){this.id=t,this.create=n,this.domEventHandlers=r,this.domEventObservers=i,this.baseExtensions=o(this),this.extension=this.baseExtensions.concat(ky.of({plugin:this,arg:void 0}))}of(t){return this.baseExtensions.concat(ky.of({plugin:this,arg:t}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:o,decorations:s}=n||{};return new rB(oKe++,t,r,i,a=>{let l=[];return s&&l.push(BE.of(u=>{let c=u.plugin(a);return c?s(c):Qe.none})),o&&l.push(o(a)),l})}static fromClass(t,n){return rB.define((r,i)=>new t(r,i),n)}},LR=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(n){if(Ao(t.state,n,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Ao(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(n){Ao(e.state,n,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}},dse=Te.define(),$5=Te.define(),BE=Te.define(),hse=Te.define(),K5=Te.define(),b1=Te.define(),fse=Te.define();function r7(e,t){let n=e.state.facet(fse);if(!n.length)return n;let r=n.map(o=>o instanceof Function?o(e):o),i=[];return hn.spans(r,t.from,t.to,{point(){},span(o,s,a,l){let u=o-t.from,c=s-t.from,d=i;for(let h=a.length-1;h>=0;h--,l--){let f=a[h].spec.bidiIsolate,p;if(f==null&&(f=iKe(t.text,u,c)),l>0&&d.length&&(p=d[d.length-1]).to==u&&p.direction==f)p.to=c,d=p.inner;else{let m={from:u,to:c,direction:f,inner:[]};d.push(m),d=m.inner}}}}),i}var pse=Te.define();function Y5(e){let t=0,n=0,r=0,i=0;for(let o of e.state.facet(pse)){let s=o(e);s&&(s.left!=null&&(t=Math.max(t,s.left)),s.right!=null&&(n=Math.max(n,s.right)),s.top!=null&&(r=Math.max(r,s.top)),s.bottom!=null&&(i=Math.max(i,s.bottom)))}return{left:t,right:n,top:r,bottom:i}}var pw=Te.define(),Nc=class iB{constructor(t,n,r,i){this.fromA=t,this.toA=n,this.fromB=r,this.toB=i}join(t){return new iB(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(t){let n=t.length,r=this;for(;n>0;n--){let i=t[n-1];if(!(i.fromA>r.toA)){if(i.toA<r.fromA)break;r=r.join(i),t.splice(n-1,1)}}return t.splice(n,0,r),t}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,o=0,s=0;;){let a=i<t.length?t[i].fromB:1e9,l=o<n.length?n[o]:1e9,u=Math.min(a,l);if(u==1e9)break;let c=u+s,d=u,h=c;for(;;)if(o<n.length&&n[o]<=d){let f=n[o+1];o+=2,d=Math.max(d,f);for(let p=i;p<t.length&&t[p].fromB<=d;p++)s=t[p].toA-t[p].toB;h=Math.max(h,f+s)}else if(i<t.length&&t[i].fromB<=d){let f=t[i++];d=Math.max(d,f.toB),h=Math.max(h,f.toA),s=f.toA-f.toB}else break;r.push(new iB(c,h,u,d))}return r}},i7=class mse{constructor(t,n,r){this.view=t,this.state=n,this.transactions=r,this.flags=0,this.startState=t.state,this.changes=ml.empty(this.startState.doc.length);for(let o of r)this.changes=this.changes.compose(o.changes);let i=[];this.changes.iterChangedRanges((o,s,a,l)=>i.push(new Nc(o,s,a,l))),this.changedRanges=i}static create(t,n,r){return new mse(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(t=>t.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},sKe=[],Nr=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return sKe}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let t=this.domAttrs;t&&V9e(this.dom,t)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let r of this.children){if(r==e)return n;n+=r.length+r.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t){return null}domPosFor(e,t){let n=Ph(this.dom),r=this.length?e>0:t>0;return new hh(this.parent.dom,n+(r?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof zE)return e;return null}static get(e){return e.cmTile}},qE=class extends Nr{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,o=0;for(let s of this.children){if(s.sync(e),o+=s.length+s.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=s.dom&&(i.written=!0),s.dom.parentNode==t)for(;r&&r!=s.dom;)r=o7(r);else t.insertBefore(s.dom,r);n=s.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=o7(r);this.length=o}};function o7(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var zE=class extends qE{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=Nr.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let o=n.children[r++];if(o instanceof qp)t.push(r),n=o,r=0;else{let s=i+o.length,a=e(o,i);if(a!==void 0)return a;i=s+o.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,o=-1;if(this.blockTiles((s,a)=>{let l=a+s.length;if(e>=a&&e<=l){if(s.isWidget()&&t>=-1&&t<=1){if(s.flags&32)return!0;s.flags&16&&(n=void 0)}(a<e||e==l&&(t<-1?s.length:s.covers(1)))&&(!n||!s.isWidget()&&n.isWidget())&&(n=s,r=e-a),(l>e||e==a&&(t>1?s.length:s.covers(-1)))&&(!i||!s.isWidget()&&i.isWidget())&&(i=s,o=e-a)}}),!n&&!i)throw new Error("No tile at position "+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:o}}},qp=class gse extends qE{constructor(t,n){super(t),this.wrapper=n}isBlock(){return!0}covers(t){return this.children.length?t<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new gse(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},i_=class yse extends qE{constructor(t,n){super(t),this.attrs=n}isLine(){return!0}static start(t,n,r){let i=new yse(n||document.createElement("div"),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(t,n,r){let i=null,o=-1,s=null,a=-1;function l(c,d){for(let h=0,f=0;h<c.children.length&&f<=d;h++){let p=c.children[h],m=f+p.length;m>=d&&(p.isComposite()?l(p,d-f):(!s||s.isHidden&&(n>0||r&&lKe(s,p)))&&(m>d||p.flags&32)?(s=p,a=d-f):(f<d||p.flags&16&&!p.isHidden)&&(i=p,o=d-f)),f=m}}l(this,t);let u=(n<0?i:s)||i||s;return u?{tile:u,offset:u==i?o:a}:null}coordsIn(t,n){let r=this.resolveInline(t,n,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),n):aKe(this)}domIn(t,n){let r=this.resolveInline(t,n);if(r){let{tile:i,offset:o}=r;if(this.dom.contains(i.dom))return i.isText()?new hh(i.dom,Math.min(i.dom.nodeValue.length,o)):i.domPosFor(o,i.flags&16?1:i.flags&32?-1:n);let s=r.tile.parent,a=!1;for(let l of s.children){if(a)return new hh(l.dom,0);l==r.tile&&(a=!0)}}return new hh(this.dom,0)}};function aKe(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Vw(t);return n[n.length-1]||null}function lKe(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var ga=class vse extends qE{constructor(t,n){super(t),this.mark=n}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new vse(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},mw=class bse extends Nr{constructor(t,n){super(t,n.length),this.text=n}sync(t){this.flags&2||(super.sync(t),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(t,n){let r=this.dom.nodeValue.length;t>r&&(t=r);let i=t,o=t,s=0;t==0&&n<0||t==r&&n>=0?_e.chrome||_e.gecko||(t?(i--,s=1):o<r&&(o++,s=-1)):n<0?i--:o<r&&o++;let a=Dx(this.dom,i,o).getClientRects();if(!a.length)return null;let l=a[(s?s<0:n>=0)?0:a.length-1];return _e.safari&&!s&&l.width==0&&(l=Array.prototype.find.call(a,u=>u.width)||l),s?Ax(l,s<0):l||null}static of(t,n){let r=new bse(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},Rx=class wse extends Nr{constructor(t,n,r,i){super(t,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(t){return this.flags&48?!1:(this.flags&(t<0?64:128))>0}coordsIn(t,n){return this.coordsInWidget(t,n,!1)}coordsInWidget(t,n,r){let i=this.widget.coordsAt(this.dom,t,n);if(i)return i;if(r)return Ax(this.dom.getBoundingClientRect(),this.length?t==0:n<=0);{let o=this.dom.getClientRects(),s=null;if(!o.length)return null;let a=this.flags&16?!0:this.flags&32?!1:t>0;for(let l=a?o.length-1:0;s=o[l],!(t>0?l==0:l==o.length-1||s.top<s.bottom);l+=a?-1:1);return Ax(s,!a)}}get overrideDOMText(){if(!this.length)return sn.empty;let{root:t}=this;if(!t)return sn.empty;let n=this.posAtStart;return t.view.state.doc.slice(n,n+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,o){return o||(o=t.toDOM(n),t.editable||(o.contentEditable="false")),new wse(o,r,t,i)}},o_=class extends Nr{constructor(e){let t=document.createElement("img");t.className="cm-widgetBuffer",t.setAttribute("aria-hidden","true"),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return sn.empty}coordsIn(e){return this.dom.getBoundingClientRect()}},uKe=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:o,parents:s}=this;for(;e||t>0;)if(r.isComposite())if(o){if(!e)break;n&&n.break(),e--,o=!1}else if(i==r.children.length){if(!e&&!s.length)break;n&&n.leave(r),o=!!r.breakAfter,{tile:r,index:i}=s.pop(),i++}else{let a=r.children[i],l=a.breakAfter;(t>0?a.length<=e:a.length<e)&&(!n||n.skip(a,0,a.length)!==!1||!a.isComposite)?(o=!!l,i++,e-=a.length):(s.push({tile:r,index:i}),r=a,i=0,n&&a.isComposite()&&n.enter(a))}else if(i==r.length)o=!!r.breakAfter,{tile:r,index:i}=s.pop(),i++;else if(e){let a=Math.min(e,r.length-i);n&&n.skip(r,i,i+a),e-=a,i+=a}else break;return this.tile=r,this.index=i,this.beforeBreak=o,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},cKe=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},dKe=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){var i;this.flushBuffer();let o=this.ensureMarks(t,n),s=o.lastChild;if(s&&s.isText()&&!(s.flags&8)&&s.length+e.length<512){this.cache.reused.set(s,2);let a=o.children[o.children.length-1]=new mw(s.dom,s.text+e);a.parent=o}else o.append(r||mw.of(e,(i=this.cache.find(mw))===null||i===void 0?void 0:i.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?BR(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let s=t.marks.length-1;s>=0;s--){let a=t.marks[s],l=r.lastChild;if(l instanceof ga&&l.mark.eq(a.mark))l.dom!=a.dom&&l.setDOM(BR(a.dom)),r=l;else{if(this.cache.reused.get(a)){let c=Nr.get(a.dom);c&&c.setDOM(BR(a.dom))}let u=ga.of(a.mark,a.dom);r.append(u),r=u}this.cache.reused.set(a,2)}let i=Nr.get(e.text);i&&this.cache.reused.set(i,2);let o=new mw(e.text,e.text.nodeValue);o.flags|=8,r.append(o)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){var n;e||(e=xse);let r=i_.start(e,t||((n=this.cache.find(i_))===null||n===void 0?void 0:n.dom),!!t);this.getBlockPos().append(this.lastBlock=this.curLine=r)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){var n;let r=this.curLine;for(let i=e.length-1;i>=0;i--){let o=e[i],s;if(t>0&&(s=r.lastChild)&&s instanceof ga&&s.mark.eq(o))r=s,t--;else{let a=ga.of(o,(n=this.cache.find(ga,l=>l.mark.eq(o)))===null||n===void 0?void 0:n.dom);r.append(a),r=a,t=0}}return r}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!s7(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(_e.ios&&s7(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(qR,0,32)||new Rx(qR.toDOM(),0,qR,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=new cKe(e.from,e.to,e.value,e.rank),n=this.wrappers.length;for(;n>0&&(this.wrappers[n-1].rank-t.rank||this.wrappers[n-1].to-t.to)<0;)n--;this.wrappers.splice(n,0,t)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let t=this.root;for(let n of this.wrappers){let r=t.lastChild;if(n.from<this.pos&&r instanceof qp&&r.wrapper.eq(n.wrapper))t=r;else{let i=qp.of(n.wrapper,(e=this.cache.find(qp,o=>o.wrapper.eq(n.wrapper)))===null||e===void 0?void 0:e.dom);t.append(i),t=i}}return t}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(o_,void 0,1);return n&&(n.flags=t),n||new o_(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},hKe=class{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:r,lineBreak:i,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=r;let s=this.textOff=Math.min(e,r.length);return i?null:r.slice(0,s)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},s_=[Rx,i_,mw,ga,o_,qp,zE];for(let e=0;e<s_.length;e++)s_[e].bucket=e;var fKe=class{constructor(e){this.view=e,this.buckets=s_.map(()=>[]),this.index=s_.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],o=this.index[r];for(let s=i.length-1;s>=0;s--){let a=(s+o)%i.length,l=i[a];if((!t||t(l))&&!this.reused.has(l))return i.splice(a,1),a<o&&this.index[r]--,this.reused.set(l,n),l}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,o=0;;i++){if(i==r.length){if(o)return null;o=1,i=0}let s=r[i];if(!this.reused.has(s)&&(o==0?s.widget.compare(e):s.widget.constructor==e.constructor&&e.updateDOM(s.dom,this.view)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,s.widget==e&&s.length==t&&(s.flags&497)==n?(this.reused.set(s,1),s):(this.reused.set(s,2),new Rx(s.dom,t,e,s.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},pKe=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new fKe(e),this.text=new hKe(e.state.doc),this.builder=new dKe(this.cache,new zE(e,e.contentDOM),hn.iter(n)),this.cache.reused.set(t,2),this.old=new uKe(t),this.reuseWalker={skip:(o,s,a)=>{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,o=0;;){let s=o<e.length?e[o++]:null,a=s?s.fromA:this.old.root.length;if(a>r){let l=a-r;this.preserve(l,!o,!s),r=a,i+=l}if(!s)break;t&&s.fromA<=t.range.fromA&&s.toA>=t.range.toA?(this.forward(s.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,s.toA),this.emit(t.range.toB,s.toB)):(this.forward(s.fromA,s.toA),this.emit(i,s.toB)),i=s.toB,r=s.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=yKe(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(o,s,a)=>{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-s);else{let l=a>0||s<o.length?Rx.of(o.widget,this.view,a-s,o.flags&496,this.cache.maybeReuse(o)):this.cache.reuse(o);l.flags&256?(l.flags&=-2,this.builder.addBlockWidget(l)):(this.builder.ensureLine(null),this.builder.addInlineWidget(l,r,i),i=r.length)}else if(o.isText())this.builder.ensureLine(null),!s&&a==o.length&&!this.cache.reused.has(o)?this.builder.addText(o.text,r,i,this.cache.reuse(o)):(this.cache.add(o),this.builder.addText(o.text.slice(s,a),r,i)),i=r.length;else if(o.isLine())o.flags&=-2,this.cache.reused.set(o,1),this.builder.addLine(o);else if(o instanceof o_)this.cache.add(o);else if(o instanceof ga)this.builder.ensureLine(null),this.builder.addMark(o,r,i),this.cache.reused.set(o,1),i=r.length;else return!1;this.openWidget=!1},enter:o=>{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof ga&&r.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?r.length&&(r.length=i=0):o instanceof ga&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=0,o=hn.spans(this.decorations,e,t,{point:(s,a,l,u,c,d)=>{if(l instanceof Ox){if(this.disallowBlockEffectsFor[d]){if(l.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(s).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(i=u.length,c>u.length)r.continueWidget(a-s);else{let h=l.widget||(l.block?av.block:av.inline),f=mKe(l),p=this.cache.findWidget(h,a-s,f)||Rx.of(h,this.view,a-s,f);l.block?(l.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(p)):(r.ensureLine(n),r.addInlineWidget(p,u,c))}n=null}else n=gKe(n,l);a>s&&this.text.skip(a-s)},span:(s,a,l,u)=>{for(let c=s;c<a;){let d=this.text.next(Math.min(512,a-c));d==null?(r.addLineStartIfNotCovered(n),r.addBreak(),c++):(r.ensureLine(n),r.addText(d,l,c==s?u:l.length),c+=d.length),n=null}}});r.addLineStartIfNotCovered(n),this.openWidget=o>i,this.openMarks=o}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let i=Nr.get(r);if(r==this.view.contentDOM)break;i instanceof ga?t.push(i):i?.isLine()?n=i:i instanceof qp||(r.nodeName=="DIV"&&!n&&r!=this.view.contentDOM?n=new i_(r,xse):n||t.push(ga.of(new j5({tagName:r.nodeName.toLowerCase(),attributes:W9e(r)}),r)))}return{line:n,marks:t}}};function s7(e,t){let n=r=>{for(let i of r.children)if((t?i.isText():i.length)||n(i))return!0;return!1};return n(e)}function mKe(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var xse={class:"cm-line"};function gKe(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||(e={class:"cm-line"}),n&&z5(n,e),r&&(e.class+=" "+r)),e}function yKe(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof ga&&t.push(r.mark)}return t}function BR(e){let t=Nr.get(e);return t&&t.setDOM(e.cloneNode()),e}var av=class extends Tu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};av.inline=new av("span");av.block=new av("div");var qR=new class extends Tu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}},a7=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Qe.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new zE(e,e.contentDOM),this.updateInner([new Nc(0,0,0,e.state.doc.length)],null)}update(e){var t;let n=e.changedRanges;this.minWidth>0&&n.length&&(n.every(({fromA:u,toA:c})=>c<this.minWidthFrom||u>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let r=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((t=this.domChanged)===null||t===void 0)&&t.newSel?r=this.domChanged.newSel.head:!MKe(e.changes,this.hasComposition)&&!e.selectionSet&&(r=e.state.selection.main.head));let i=r>-1?bKe(this.view,e.changes,r):null;if(this.domChanged=null,this.hasComposition){let{from:u,to:c}=this.hasComposition;n=new Nc(u,c,e.changes.mapPos(u,-1),e.changes.mapPos(c,1)).addToSet(n.slice())}this.hasComposition=i?{from:i.range.fromB,to:i.range.toB}:null,(_e.ie||_e.chrome)&&!i&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,s=this.blockWrappers;this.updateDeco();let a=SKe(o,this.decorations,e.changes);a.length&&(n=Nc.extendWithRanges(n,a));let l=CKe(s,this.blockWrappers,e.changes);return l.length&&(n=Nc.extendWithRanges(n,l)),i&&!n.some(u=>u.fromA<=i.range.fromA&&u.toA>=i.range.toA)&&(n=i.range.addToSet(n.slice())),this.tile.flags&2&&n.length==0?!1:(this.updateInner(n,i),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let o=this.tile,s=new pKe(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&Nr.get(t.text)&&s.cache.reused.set(Nr.get(t.text),2),this.tile=s.run(e,t),oB(o,s.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let i=_e.chrome||_e.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(i),i&&(i.written||n.selectionRange.focusNode!=i.node||!this.tile.dom.contains(i.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let i of this.tile.children)i.isWidget()&&i.widget instanceof zR&&r.push(i.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let n of t.effects)n.is(cse)&&(this.editContextFormatting=n.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,o=!i&&!(this.view.state.facet(xc)||n.tabIndex>-1)&&jw(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||o))return;let s=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,l,u;if(a.empty?u=l=this.inlineDOMNearPos(a.anchor,a.assoc||1):(u=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),l=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),_e.gecko&&a.empty&&!this.hasComposition&&vKe(l)){let d=document.createTextNode("");this.view.observer.ignore(()=>l.node.insertBefore(d,l.node.childNodes[l.offset]||null)),l=u=new hh(d,0),s=!0}let c=this.view.observer.selectionRange;(s||!c.focusNode||(!Ww(l.node,l.offset,c.anchorNode,c.anchorOffset)||!Ww(u.node,u.offset,c.focusNode,c.focusOffset))&&!this.suppressWidgetCursorChange(c,a))&&(this.view.observer.ignore(()=>{_e.android&&_e.chrome&&n.contains(c.focusNode)&&NKe(c.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let d=Tx(this.view.root);if(d)if(a.empty){if(_e.gecko){let h=wKe(l.node,l.offset);if(h&&h!=3){let f=(h==1?Yoe:Qoe)(l.node,l.offset);f&&(l=new hh(f.node,f.offset))}}d.collapse(l.node,l.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(l.node,l.offset);try{d.extend(u.node,u.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([l,u]=[u,l]),h.setEnd(u.node,u.offset),h.setStart(l.node,l.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(l,u)),this.impreciseAnchor=l.precise?null:new hh(c.anchorNode,c.anchorOffset),this.impreciseHead=u.precise?null:new hh(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Ww(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Tx(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let o=this.lineAt(t.head,t.assoc);if(!o)return;let s=o.posAtStart;if(t.head==s||t.head==s+o.length)return;let a=this.coordsAt(t.head,-1),l=this.coordsAt(t.head,1);if(!a||!l||a.bottom>l.top)return;let u=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(u.node,u.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let o=jc(e)==0?0:t==0?-1:1;for(;;){let s=e.parentNode;if(s==n.dom)break;o==0&&s.firstChild!=s.lastChild&&(e==s.firstChild?o=-1:o=1),e=s}o<0?i=e:i=e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!Nr.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let o=0,s=r;;o++){let a=n.children[o];if(a.dom==i)return s;s+=a.length+a.breakAfter}}else return n.isText()?e==n.dom?r+t:r+(t?n.length:0):r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(e,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,o,s=-1,a=!1;return this.tile.blockTiles((l,u)=>{if(l.isWidget()){if(l.flags&32&&u>=e)return!0;l.flags&16&&(i=!0)}else{let c=u+l.length;if(u<=e&&(n=l,r=e-u,i=c<e),c>=e&&!o&&(o=l,s=e-u,a=u>e),u>e&&o)return!0}}),!n&&!o?this.domAtPos(e,t):(i&&o?n=null:a&&n&&(o=null),n&&t<0||!o?n.domIn(r,t):o.domIn(s,t))}coordsAt(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.widget instanceof zR?null:n.coordsInWidget(r,t,!0):n.coordsIn(r,t)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(i,o){if(i.isComposite())for(let s of i.children){if(s.length>=o){let a=r(s,o);if(a)return a}if(o-=s.length,o<0)break}else if(i.isText()&&o<i.length){let s=Mi(i.text,o);if(s==o)return null;let a=Dx(i.dom,o,s).getClientRects();for(let l=0;l<a.length;l++){let u=a[l];if(l==a.length-1||u.top<u.bottom&&u.left<u.right)return u}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,o=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,s=-1,a=this.view.textDirection==On.LTR,l=0,u=(c,d,h)=>{for(let f=0;f<c.children.length&&!(d>r);f++){let p=c.children[f],m=d+p.length,g=p.dom.getBoundingClientRect(),{height:y}=g;if(h&&!f&&(l+=g.top-h.top),p instanceof qp)m>n&&u(p,d,g);else if(d>=n&&(l>0&&t.push(-l),t.push(y+l),l=0,o)){let v=p.dom.lastChild,b=v?Vw(v):[];if(b.length){let w=b[b.length-1],x=a?w.right-g.left:g.right-w.left;x>s&&(s=x,this.minWidth=i,this.minWidthFrom=d,this.minWidthTo=m)}}h&&f==c.children.length-1&&(l+=h.bottom-g.bottom),d=m+p.breakAfter}};return u(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction=="rtl"?On.RTL:On.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let s=0,a;for(let l of o.children){if(!l.isText()||/[^ -~]/.test(l.text))return;let u=Vw(l.dom);if(u.length!=1)return;s+=u[0].width,a=u[0].height}if(s)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:s/o.length,textHeight:a}}});if(e)return e;let t=document.createElement("div"),n,r,i;return t.className="cm-line",t.style.width="99999px",t.style.position="absolute",t.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let o=Vw(t.firstChild)[0];n=t.getBoundingClientRect().height,r=o&&o.width?o.width/27:7,i=o&&o.height?o.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],o=i?i.from-1:this.view.state.doc.length;if(o>n){let s=(t.lineBlockAt(o).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(Qe.replace({widget:new zR(s),block:!0,inclusive:!0,isBlockGap:!0}).range(n,o))}if(!i)break;n=i.to+1}return Qe.set(e)}updateDeco(){let e=1,t=this.view.state.facet(BE).map(i=>(this.dynamicDecorationMap[e++]=typeof i=="function")?i(this.view):i),n=!1,r=this.view.state.facet(K5).map((i,o)=>{let s=typeof i=="function";return s&&(n=!0),s?i(this.view):i});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(hn.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(hse).map(i=>typeof i=="function"?i(this.view):i)}scrollIntoView(e){if(e.isSnapshot){let l=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=l.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let l of this.view.state.facet(use))try{if(l(this.view,e.range,e))return!0}catch(u){Ao(this.view.state,u,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Y5(this.view),o={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:s,offsetHeight:a}=this.view.scrollDOM;if($9e(this.view.scrollDOM,o,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,s),-s),Math.max(Math.min(e.yMargin,a),-a),this.view.textDirection==On.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.pageYOffset+window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.pageYOffset+window.visualViewport.offsetTop)){let l=this.view.docView.lineAt(t.head,1);l&&l.dom.scrollIntoView({block:"nearest"})}}lineHasWidget(e){let t=n=>n.isWidget()||n.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){oB(this.tile)}};function oB(e,t){let n=t?.get(e);if(n!=1){n==null&&e.destroy();for(let r of e.children)oB(r,t)}}function vKe(e){return e.node.nodeType==1&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable=="false")&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable=="false")}function Sse(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Yoe(n.focusNode,n.focusOffset),i=Qoe(n.focusNode,n.focusOffset),o=r||i;if(i&&r&&i.node!=r.node){let a=Nr.get(i.node);if(!a||a.isText()&&a.text!=i.node.nodeValue)o=i;else if(e.docView.lastCompositionAfterCursor){let l=Nr.get(r.node);!l||l.isText()&&l.text!=r.node.nodeValue||(o=i)}}if(e.docView.lastCompositionAfterCursor=o!=r,!o)return null;let s=t-o.offset;return{from:s,to:s+o.node.nodeValue.length,node:o.node}}function bKe(e,t,n){let r=Sse(e,n);if(!r)return null;let{node:i,from:o,to:s}=r,a=i.nodeValue;if(/[\n\r]/.test(a)||e.state.doc.sliceString(r.from,r.to)!=a)return null;let l=t.invertedDesc;return{range:new Nc(l.mapPos(o),l.mapPos(s),o,s),text:i}}function wKe(e,t){return e.nodeType!=1?0:(t&&e.childNodes[t-1].contentEditable=="false"?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable=="false"?2:0)}var xKe=class{constructor(){this.changes=[]}compareRange(e,t){Ly(e,t,this.changes)}comparePoint(e,t){Ly(e,t,this.changes)}boundChange(e){Ly(e,e,this.changes)}};function SKe(e,t,n){let r=new xKe;return hn.compare(e,t,n,r),r.changes}var kKe=class{constructor(){this.changes=[]}compareRange(e,t){Ly(e,t,this.changes)}comparePoint(){}boundChange(e){Ly(e,e,this.changes)}};function CKe(e,t,n){let r=new kKe;return hn.compare(e,t,n,r),r.changes}function NKe(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(n.nodeType==1&&n.contentEditable=="false")return!0;return!1}function MKe(e,t){let n=!1;return t&&e.iterChangedRanges((r,i)=>{r<t.to&&i>t.from&&(n=!0)}),n}var zR=class extends Tu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function _Ke(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),o=t-i.from;if(i.length==0)return ae.cursor(t);o==0?n=1:o==i.length&&(n=-1);let s=o,a=o;n<0?s=Mi(i.text,o,!1):a=Mi(i.text,o);let l=r(i.text.slice(s,a));for(;s>0;){let u=Mi(i.text,s,!1);if(r(i.text.slice(u,s))!=l)break;s=u}for(;a<i.length;){let u=Mi(i.text,a);if(r(i.text.slice(a,u))!=l)break;a=u}return ae.range(s+i.from,a+i.from)}function EKe(e,t,n,r,i){let o=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let a=e.viewState.heightOracle.textHeight,l=Math.floor((i-n.top-(e.defaultLineHeight-a)*.5)/a);o+=l*e.viewState.heightOracle.lineLength}let s=e.state.sliceDoc(n.from,n.to);return n.from+WL(s,o,e.state.tabSize)}function sB(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let i;for(let o of r.type){if(o.from>t)break;if(!(o.to<t)){if(o.from<t&&o.to>t)return o;(!i||o.type==Vi.Text&&(i.type!=o.type||(n<0?o.from<t:o.to>t)))&&(i=o)}}return i||r}return r}function OKe(e,t,n,r){let i=sB(e,t.head,t.assoc||-1),o=!r||i.type!=Vi.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(o){let s=e.dom.getBoundingClientRect(),a=e.textDirectionAt(i.from),l=e.posAtCoords({x:n==(a==On.LTR)?s.right-1:s.left+1,y:(o.top+o.bottom)/2});if(l!=null)return ae.cursor(l,n?-1:1)}return ae.cursor(n?i.to:i.from,n?-1:1)}function l7(e,t,n,r){let i=e.state.doc.lineAt(t.head),o=e.bidiSpans(i),s=e.textDirectionAt(i.from);for(let a=t,l=null;;){let u=rKe(i,o,s,a,n),c=ese;if(!u){if(i.number==(n?e.state.doc.lines:1))return a;c=`
`,i=e.state.doc.line(i.number+(n?1:-1)),o=e.bidiSpans(i),u=e.visualLineSide(i,!n)}if(l){if(!l(c))return a}else{if(!r)return u;l=r(c)}a=u}}function TKe(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return o=>{let s=r(o);return i==rr.Space&&(i=s),i==s}}function AKe(e,t,n,r){let i=t.head,o=n?1:-1;if(i==(n?e.state.doc.length:0))return ae.cursor(i,t.assoc);let s=t.goalColumn,a,l=e.contentDOM.getBoundingClientRect(),u=e.coordsAtPos(i,(t.empty?t.assoc:0)||(n?1:-1)),c=e.documentTop;if(u)s==null&&(s=u.left-l.left),a=o<0?u.top:u.bottom;else{let p=e.viewState.lineBlockAt(i);s==null&&(s=Math.min(l.right-l.left,e.defaultCharacterWidth*(i-p.from))),a=(o<0?p.top:p.bottom)+c}let d=l.left+s,h=r??e.viewState.heightOracle.textHeight>>1,f=aB(e,{x:d,y:a+h*o},!1,o);return ae.cursor(f.pos,f.assoc,void 0,s)}function Uw(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(o,s,a)=>{if(t>o&&t<s){let l=r||n||(t-o<s-t?-1:1);t=l<0?o:s,r=l}});if(!r)return t}}function kse(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],o=null;if(i.empty){let s=Uw(e,i.from,0);s!=i.from&&(o=ae.cursor(s,-1))}else{let s=Uw(e,i.from,-1),a=Uw(e,i.to,1);(s!=i.from||a!=i.to)&&(o=ae.range(i.from==i.anchor?s:a,i.from==i.head?s:a))}o&&(n||(n=t.ranges.slice()),n[r]=o)}return n?ae.create(n,t.mainIndex):t}function FR(e,t,n){let r=Uw(e.state.facet(b1).map(i=>i(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:ae.cursor(r,r<n.from?1:-1)}var au=class{constructor(e,t){this.pos=e,this.assoc=t}};function aB(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),o=i.top+e.viewState.paddingTop,{x:s,y:a}=t,l=a-o,u;for(;;){if(l<0)return new au(0,1);if(l>e.viewState.docHeight)return new au(e.state.doc.length,-1);if(u=e.elementAtHeight(l),r==null)break;if(u.type==Vi.Text){if(r<0?u.to<e.viewport.from:u.from>e.viewport.to)break;let h=e.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(h&&(r<0?h.top<=l+o:h.bottom>=l+o))break}let d=e.viewState.heightOracle.textHeight/2;l=r>0?u.bottom+d:u.top-d}if(e.viewport.from>=u.to||e.viewport.to<=u.from){if(n)return null;if(u.type==Vi.Text){let d=EKe(e,i,u,s,a);return new au(d,d==u.from?1:-1)}}if(u.type!=Vi.Text)return l<(u.top+u.bottom)/2?new au(u.from,1):new au(u.to,-1);let c=e.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=e.docView.lineAt(u.from,-2)),new DKe(e,s,a,e.textDirectionAt(u.from)).scanTile(c,u.from)}var DKe=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[uu.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[uu.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t){let n=0,r=e.length-1,i=new Set,o=this.bidiIn(e[0],e[r]),s,a,l=-1,u=1e9,c;e:for(;n<r;){let h=r-n,f=n+r>>1;t:if(i.has(f)){let m=n+Math.floor(Math.random()*h);for(let g=0;g<h;g++){if(!i.has(m)){f=m;break t}m++,m==r&&(m=n)}break e}i.add(f);let p=t(f);if(p)for(let m=0;m<p.length;m++){let g=p[m],y=0;if(g.bottom<this.y)(!s||s.bottom<g.bottom)&&(s=g),y=1;else if(g.top>this.y)(!a||a.top>g.top)&&(a=g),y=-1;else{let v=g.left>this.x?this.x-g.left:g.right<this.x?this.x-g.right:0,b=Math.abs(v);b<u&&(l=f,u=b,c=g),v&&(y=v<0==(this.baseDir==On.LTR)?-1:1)}y==-1&&(!o||this.baseDirAt(e[f],1))?r=f:y==1&&(!o||this.baseDirAt(e[f+1],-1))&&(n=f+1)}}if(!c){let h=s&&(!a||this.y-s.bottom<a.top-this.y)?s:a;return this.y=(h.top+h.bottom)/2,this.scan(e,t)}let d=(o?this.dirAt(e[l],1):this.baseDir)==On.LTR;return{i:l,after:this.x>(c.left+c.right)/2==d}}scanText(e,t){let n=[];for(let i=0;i<e.length;i=Mi(e.text,i))n.push(t+i);n.push(t+e.length);let r=this.scan(n,i=>{let o=n[i]-t,s=n[i+1]-t;return Dx(e.dom,o,s).getClientRects()});return r.after?new au(n[r.i+1],-1):new au(n[r.i],1)}scanTile(e,t){if(!e.length)return new au(t,1);if(e.children.length==1){let s=e.children[0];if(s.isText())return this.scanText(s,t);if(s.isComposite())return this.scanTile(s,t)}let n=[t];for(let s=0,a=t;s<e.children.length;s++)n.push(a+=e.children[s].length);let r=this.scan(n,s=>{let a=e.children[s];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Dx(a.dom,0,a.length)).getClientRects()}),i=e.children[r.i],o=n[r.i];return i.isText()?this.scanText(i,o):i.isComposite()?this.scanTile(i,o):r.after?new au(n[r.i+1],-1):new au(o,1)}},ny="\uFFFF",RKe=class{constructor(e,t){this.points=e,this.view=t,this.text="",this.lineSeparator=t.state.facet(or.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ny}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let i=this.text.length;this.readNode(r);let o=Nr.get(r),s=r.nextSibling;if(s==t){o?.breakAfter&&!s&&n!=this.view.contentDOM&&this.lineBreak();break}let a=Nr.get(s);(o&&a?o.breakAfter:(o?o.breakAfter:r_(r))||r_(s)&&(r.nodeName!="BR"||o?.isWidget())&&this.text.length>i)&&!PKe(s,t)&&this.lineBreak(),r=s}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,o=1,s;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),o=this.lineSeparator.length):(s=r.exec(t))&&(i=s.index,o=s[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);n=i+o}}readNode(e){let t=Nr.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let r=n.iter();!r.next().done;)r.lineBreak?this.lineBreak():this.append(r.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(e.nodeType==3?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(IKe(e,n.node,n.offset)?t:0))}};function IKe(e,t,n){for(;;){if(!t||n<jc(t))return!1;if(t==e)return!0;n=Ph(t)+1,t=t.parentNode}}function PKe(e,t){let n;for(;!(e==t||!e);e=e.nextSibling){let r=Nr.get(e);if(!r?.isWidget())return!1;r&&(n||(n=[])).push(r)}if(n){for(let r of n)if(r.overrideDOMText?.length)return!1}return!0}var u7=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},LKe=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=Cse(e.docView.tile,t,n,0))){let s=i||o?[]:qKe(e),a=new RKe(s,e);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=zKe(s,this.bounds.from)}else{let s=e.observer.selectionRange,a=i&&i.node==s.focusNode&&i.offset==s.focusOffset||!GL(e.contentDOM,s.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(s.focusNode,s.focusOffset),l=o&&o.node==s.anchorNode&&o.offset==s.anchorOffset||!GL(e.contentDOM,s.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(s.anchorNode,s.anchorOffset),u=e.viewport;if((_e.ios||_e.chrome)&&e.state.selection.main.empty&&a!=l&&(u.from>0||u.to<e.state.doc.length)){let c=Math.min(a,l),d=Math.max(a,l),h=u.from-c,f=u.to-d;(h==0||h==1||c==0)&&(f==0||f==-1||d==e.state.doc.length)&&(a=0,l=e.state.doc.length)}e.inputState.composing>-1&&e.state.selection.ranges.length>1?this.newSel=e.state.selection.replaceRange(ae.range(l,a)):this.newSel=ae.single(l,a)}}};function Cse(e,t,n,r){if(e.isComposite()){let i=-1,o=-1,s=-1,a=-1;for(let l=0,u=r,c=r;l<e.children.length;l++){let d=e.children[l],h=u+d.length;if(u<t&&h>n)return Cse(d,t,n,u);if(h>=t&&i==-1&&(i=l,o=u),u>n&&d.dom.parentNode==e.dom){s=l,a=c;break}c=h,u=h+d.breakAfter}return{from:o,to:a<0?r+e.length:a,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:s<e.children.length&&s>=0?e.children[s].dom:null}}else return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function Nse(e,t){let n,{newSel:r}=t,{state:i}=e,o=i.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:a,to:l}=t.bounds,u=o.from,c=null;(s===8||_e.android&&t.text.length<l-a)&&(u=o.to,c="end");let d=i.doc.sliceString(a,l,ny),h,f;!o.empty&&o.from>=a&&o.to<=l&&(t.typeOver||d!=t.text)&&d.slice(0,o.from-a)==t.text.slice(0,o.from-a)&&d.slice(o.to-a)==t.text.slice(h=t.text.length-(d.length-(o.to-a)))?n={from:o.from,to:o.to,insert:sn.of(t.text.slice(o.from-a,h).split(ny))}:(f=Mse(d,t.text,u-a,c))&&(_e.chrome&&s==13&&f.toB==f.from+2&&t.text.slice(f.from,f.toB)==ny+ny&&f.toB--,n={from:a+f.from,to:a+f.toA,insert:sn.of(t.text.slice(f.from,f.toB).split(ny))})}else r&&(!e.hasFocus&&i.facet(xc)||a_(r,o))&&(r=null);if(!n&&!r)return!1;if((_e.mac||_e.android)&&n&&n.from==n.to&&n.from==o.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:sn.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(o.from).to<o.to&&e.docView.lineHasWidget(o.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:o.from,to:o.to,insert:i.toText(e.inputState.insertingText)}:_e.chrome&&n&&n.from==n.to&&n.from==o.head&&n.insert.toString()==`
`&&e.lineWrapping&&(r&&(r=ae.single(r.main.anchor-1,r.main.head-1)),n={from:o.from,to:o.to,insert:sn.of([" "])}),n)return Q5(e,n,r,s);if(r&&!a_(r,o)){let a=!1,l="select";return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin=="select"&&(a=!0),l=e.inputState.lastSelectionOrigin,l=="select.pointer"&&(r=kse(i.facet(b1).map(u=>u(e)),r))),e.dispatch({selection:r,scrollIntoView:a,userEvent:l}),!0}else return!1}function Q5(e,t,n,r=-1){if(_e.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(_e.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==" ")&&t.insert.length==1&&t.insert.lines==2&&By(e.contentDOM,"Enter",13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&By(e.contentDOM,"Backspace",8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&By(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let s,a=()=>s||(s=BKe(e,t,n));return e.state.facet(ose).some(l=>l(e,t.from,t.to,o,a))||e.dispatch(a()),!0}function BKe(e,t,n){let r,i=e.state,o=i.selection.main,s=-1;if(t.from==t.to&&t.from<o.from||t.from>o.to){let l=t.from<o.from?-1:1,u=l<0?o.from:o.to,c=Uw(i.facet(b1).map(d=>d(e)),u,l);t.from==c&&(s=c)}if(s>-1)r={changes:t,selection:ae.cursor(t.from+t.insert.length,-1)};else if(t.from>=o.from&&t.to<=o.to&&t.to-t.from>=(o.to-o.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let l=o.from<t.from?i.sliceDoc(o.from,t.from):"",u=o.to>t.to?i.sliceDoc(t.to,o.to):"";r=i.replaceSelection(e.state.toText(l+t.insert.sliceString(0,void 0,e.state.lineBreak)+u))}else{let l=i.changes(t),u=n&&n.main.to<=l.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=o.to+10&&t.to>=o.to-10){let c=e.state.sliceDoc(t.from,t.to),d,h=n&&Sse(e,n.main.head);if(h){let p=t.insert.length-(t.to-t.from);d={from:h.from,to:h.to-p}}else d=e.state.doc.lineAt(o.head);let f=o.to-t.to;r=i.changeByRange(p=>{if(p.from==o.from&&p.to==o.to)return{changes:l,range:u||p.map(l)};let m=p.to-f,g=m-c.length;if(e.state.sliceDoc(g,m)!=c||m>=d.from&&g<=d.to)return{range:p};let y=i.changes({from:g,to:m,insert:t.insert}),v=p.to-o.to;return{changes:y,range:u?ae.range(Math.max(0,u.anchor+v),Math.max(0,u.head+v)):p.map(y)}})}else r={changes:l,selection:u&&i.selection.replaceRange(u)}}let a="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,a+=".compose",e.inputState.compositionFirstChange&&(a+=".start",e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:a,scrollIntoView:!0})}function Mse(e,t,n,r){let i=Math.min(e.length,t.length),o=0;for(;o<i&&e.charCodeAt(o)==t.charCodeAt(o);)o++;if(o==i&&e.length==t.length)return null;let s=e.length,a=t.length;for(;s>0&&a>0&&e.charCodeAt(s-1)==t.charCodeAt(a-1);)s--,a--;if(r=="end"){let l=Math.max(0,o-Math.min(s,a));n-=s+l-o}if(s<o&&e.length<t.length){let l=n<=o&&n>=s?o-n:0;o-=l,a=o+(a-s),s=o}else if(a<o){let l=n<=o&&n>=a?o-n:0;o-=l,s=o+(s-a),a=o}return{from:o,toA:s,toB:a}}function qKe(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}=e.observer.selectionRange;return n&&(t.push(new u7(n,r)),(i!=n||o!=r)&&t.push(new u7(i,o))),t}function zKe(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n>-1&&r>-1?ae.single(n+t,r+t):null}function a_(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var FKe=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,_e.safari&&e.contentDOM.addEventListener("input",()=>null),_e.gecko&&t7e(e.contentDOM.ownerDocument)}handleEvent(e){!YKe(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let r of n.observers)r(this.view,t);for(let r of n.handlers){if(t.defaultPrevented)break;if(r(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=jKe(e),n=this.handlers,r=this.view.contentDOM;for(let i in t)if(i!="scroll"){let o=!t[i].handlers.length,s=n[i];s&&o!=!s.handlers.length&&(r.removeEventListener(i,this.handleEvent),s=null),s||r.addEventListener(i,this.handleEvent,{passive:o})}for(let i in n)i!="scroll"&&!t[i]&&r.removeEventListener(i,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Ese.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),_e.android&&_e.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;let t;return _e.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=_se.find(n=>n.keyCode==e.keyCode))&&!e.ctrlKey||VKe.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(e.keyCode!=229&&this.view.observer.forceFlush(),!1)}flushIOSKey(e){let t=this.pendingIOSKey;return!t||t.key=="Enter"&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,By(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:_e.safari&&!_e.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function c7(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(i){Ao(n.state,i)}}}function jKe(e){let t=Object.create(null);function n(r){return t[r]||(t[r]={observers:[],handlers:[]})}for(let r of e){let i=r.spec,o=i&&i.plugin.domEventHandlers,s=i&&i.plugin.domEventObservers;if(o)for(let a in o){let l=o[a];l&&n(a).handlers.push(c7(r.value,l))}if(s)for(let a in s){let l=s[a];l&&n(a).observers.push(c7(r.value,l))}}for(let r in gl)n(r).handlers.push(gl[r]);for(let r in ns)n(r).observers.push(ns[r]);return t}var _se=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],VKe="dthko",Ese=[16,17,18,20,91,92,224,225],ZC=6;function eN(e){return Math.max(0,e)*.7+8}function WKe(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var UKe=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Hoe(e.contentDOM),this.atoms=e.state.facet(b1).map(o=>o(e));let i=e.contentDOM.ownerDocument;i.addEventListener("mousemove",this.move=this.move.bind(this)),i.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(or.allowMultipleSelections)&&HKe(e,t),this.dragging=KKe(e,t)&&Ase(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&WKe(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,o=this.view.win.innerWidth,s=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:s}=this.scrollParents.y.getBoundingClientRect());let a=Y5(this.view);e.clientX-a.left<=r+ZC?t=-eN(r-e.clientX):e.clientX+a.right>=o-ZC&&(t=eN(e.clientX-o)),e.clientY-a.top<=i+ZC?n=-eN(i-e.clientY):e.clientY+a.bottom>=s-ZC&&(n=eN(e.clientY-s)),this.setScrollSpeed(t,n)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=kse(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(t=>t.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function HKe(e,t){let n=e.state.facet(tse);return n.length?n[0](t):_e.mac?t.metaKey:t.ctrlKey}function $Ke(e,t){let n=e.state.facet(nse);return n.length?n[0](t):_e.mac?!t.altKey:!t.ctrlKey}function KKe(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Tx(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let o=0;o<i.length;o++){let s=i[o];if(s.left<=t.clientX&&s.right>=t.clientX&&s.top<=t.clientY&&s.bottom>=t.clientY)return!0}return!1}function YKe(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Nr.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var gl=Object.create(null),ns=Object.create(null),Ose=_e.ie&&_e.ie_version<15||_e.ios&&_e.webkit_version<604;function QKe(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{e.focus(),n.remove(),Tse(e,n.value)},50)}function FE(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Tse(e,t){t=FE(e.state,U5,t);let{state:n}=e,r,i=1,o=n.toText(t),s=o.lines==n.selection.ranges.length;if(lB!=null&&n.selection.ranges.every(a=>a.empty)&&lB==o.toString()){let a=-1;r=n.changeByRange(l=>{let u=n.doc.lineAt(l.from);if(u.from==a)return{range:l};a=u.from;let c=n.toText((s?o.line(i++).text:t)+n.lineBreak);return{changes:{from:u.from,insert:c},range:ae.cursor(l.from+c.length)}})}else s?r=n.changeByRange(a=>{let l=o.line(i++);return{changes:{from:a.from,to:a.to,insert:l.text},range:ae.cursor(a.from+l.length)}}):r=n.replaceSelection(o);e.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}ns.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft};ns.wheel=ns.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()};gl.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1);ns.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")};ns.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")};gl.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(rse))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=XKe(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new UKe(e,t,n,r)),r&&e.observer.ignore(()=>{$oe(e.contentDOM);let o=e.root.activeElement;o&&!o.contains(e.contentDOM)&&o.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin("select.pointer");return!1};function d7(e,t,n,r){if(r==1)return ae.cursor(t,n);if(r==2)return _Ke(e.state,t,n);{let i=e.docView.lineAt(t,n),o=e.state.doc.lineAt(i?i.posAtEnd:t),s=i?i.posAtStart:o.from,a=i?i.posAtEnd:o.to;return a<e.state.doc.length&&a==o.to&&a++,ae.range(s,a)}}var GKe=_e.ie&&_e.ie_version<=11,h7=null,f7=0,p7=0;function Ase(e){if(!GKe)return e.detail;let t=h7,n=p7;return h7=e,p7=Date.now(),f7=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(f7+1)%3:1}function XKe(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Ase(t),i=e.state.selection;return{update(o){o.docChanged&&(n.pos=o.changes.mapPos(n.pos),i=i.map(o.changes))},get(o,s,a){let l=e.posAndSideAtCoords({x:o.clientX,y:o.clientY},!1),u,c=d7(e,l.pos,l.assoc,r);if(n.pos!=l.pos&&!s){let d=d7(e,n.pos,n.assoc,r),h=Math.min(d.from,c.from),f=Math.max(d.to,c.to);c=h<c.from?ae.range(h,f):ae.range(f,h)}return s?i.replaceRange(i.main.extend(c.from,c.to)):a&&r==1&&i.ranges.length>1&&(u=JKe(i,l.pos))?u:a?i.addRange(c):ae.create([c])}}}function JKe(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return ae.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n?1:0))}return null}gl.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.tile.nearest(t.target);if(i&&i.isWidget()){let o=i.posAtStart,s=o+i.length;(o>=n.to||s<=n.from)&&(n=ae.range(o,s))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",FE(e.state,H5,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1};gl.dragend=e=>(e.inputState.draggedContent=null,!1);function m7(e,t,n,r){if(n=FE(e.state,U5,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,s=r&&o&&$Ke(e,t)?{from:o.from,to:o.to}:null,a={from:i,insert:n},l=e.state.changes(s?[s,a]:a);e.focus(),e.dispatch({changes:l,selection:{anchor:l.mapPos(i,-1),head:l.mapPos(i,1)},userEvent:s?"move.drop":"input.drop"}),e.inputState.draggedContent=null}gl.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,o=()=>{++i==n.length&&m7(e,t,r.filter(s=>s!=null).join(e.state.lineBreak),!1)};for(let s=0;s<n.length;s++){let a=new FileReader;a.onerror=o,a.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(a.result)||(r[s]=a.result),o()},a.readAsText(n[s])}return!0}else{let r=t.dataTransfer.getData("Text");if(r)return m7(e,t,r,!0),!0}return!1};gl.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Ose?null:t.clipboardData;return n?(Tse(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QKe(e),!1)};function ZKe(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function e7e(e){let t=[],n=[],r=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let i=-1;for(let{from:o}of e.selection.ranges){let s=e.doc.lineAt(o);s.number>i&&(t.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),i=s.number}r=!0}return{text:FE(e,H5,t.join(e.lineBreak)),ranges:n,linewise:r}}var lB=null;gl.copy=gl.cut=(e,t)=>{if(!jw(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=e7e(e.state);if(!n&&!i)return!1;lB=i?n:null,t.type=="cut"&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let o=Ose?null:t.clipboardData;return o?(o.clearData(),o.setData("text/plain",n),!0):(ZKe(e,n),!1)};var Dse=Ou.define();function Rse(e,t){let n=[];for(let r of e.facet(sse)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Dse.of(!0)}):null}function Ise(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Rse(e.state,t);n?e.dispatch(n):e.update([])}},10)}ns.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Ise(e)};ns.blur=e=>{e.observer.clearSelectionRange(),Ise(e)};ns.compositionstart=ns.compositionupdate=e=>{e.observer.editContext||(e.inputState.compositionFirstChange==null&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))};ns.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,_e.chrome&&_e.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))};ns.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()};gl.beforeinput=(e,t)=>{var n,r;if((t.inputType=="insertText"||t.inputType=="insertCompositionText")&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType=="insertReplacementText"&&e.observer.editContext){let o=(n=t.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),s=t.getTargetRanges();if(o&&s.length){let a=s[0],l=e.posAtDOM(a.startContainer,a.startOffset),u=e.posAtDOM(a.endContainer,a.endOffset);return Q5(e,{from:l,to:u,insert:e.state.toText(o)},null),!0}}let i;if(_e.chrome&&_e.android&&(i=_se.find(o=>o.inputType==t.inputType))&&(e.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let o=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var s;(((s=window.visualViewport)===null||s===void 0?void 0:s.height)||0)>o+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return _e.ios&&t.inputType=="deleteContentForward"&&e.observer.flushSoon(),_e.safari&&t.inputType=="insertText"&&e.inputState.composing>=0&&setTimeout(()=>ns.compositionend(e,t),20),!1};var g7=new Set;function t7e(e){g7.has(e)||(g7.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}var y7=["pre-wrap","normal","pre-line","break-spaces"],lv=!1;function v7(){lv=!1}var n7e=class{constructor(e){this.lineWrapping=e,this.doc=sn.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return y7.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,o){let s=y7.indexOf(e)>-1,a=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=s||Math.abs(n-this.charWidth)>.1;if(this.lineWrapping=s,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,a){this.heightSamples={};for(let l=0;l<o.length;l++){let u=o[l];u<0?l++:this.heightSamples[Math.floor(u*10)]=!0}}return a}},r7e=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},Sc=class Pse{constructor(t,n,r,i,o){this.from=t,this.length=n,this.top=r,this.height=i,this._content=o}get type(){return typeof this._content=="number"?Vi.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof Ox?this._content.widget:null}get widgetLineBreaks(){return typeof this._content=="number"?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new Pse(this.from,this.length+t.length,this.top,this.height+t.height,n)}},qn=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(qn||(qn={})),eM=.001,dl=class tM{constructor(t,n,r=2){this.length=t,this.height=n,this.flags=r}get outdated(){return(this.flags&2)>0}set outdated(t){this.flags=(t?2:0)|this.flags&-3}setHeight(t){this.height!=t&&(Math.abs(this.height-t)>eM&&(lv=!0),this.height=t)}replace(t,n,r){return tM.of(r)}decomposeLeft(t,n){n.push(this)}decomposeRight(t,n){n.push(this)}applyChanges(t,n,r,i){let o=this,s=r.doc;for(let a=i.length-1;a>=0;a--){let{fromA:l,toA:u,fromB:c,toB:d}=i[a],h=o.lineAt(l,qn.ByPosNoHeight,r.setDoc(n),0,0),f=h.to>=u?h:o.lineAt(u,qn.ByPosNoHeight,r,0,0);for(d+=f.to-u,u=f.to;a>0&&h.from<=i[a-1].toA;)l=i[a-1].fromA,c=i[a-1].fromB,a--,l<h.from&&(h=o.lineAt(l,qn.ByPosNoHeight,r,0,0));c+=h.from-l,l=h.from;let p=a7e.build(r.setDoc(s),t,c,d);o=l_(o,o.replace(l,u,p))}return o.updateHeight(r,0)}static empty(){return new Zl(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,o=0;for(;;)if(n==r)if(i>o*2){let a=t[n-1];a.break?t.splice(--n,1,a.left,null,a.right):t.splice(--n,1,a.left,a.right),r+=1+a.break,i-=a.size}else if(o>i*2){let a=t[r];a.break?t.splice(r,1,a.left,null,a.right):t.splice(r,1,a.left,a.right),r+=2+a.break,o-=a.size}else break;else if(i<o){let a=t[n++];a&&(i+=a.size)}else{let a=t[--r];a&&(o+=a.size)}let s=0;return t[n-1]==null?(s=1,n--):t[n]==null&&(s=1,r++),new o7e(tM.of(t.slice(0,n)),s,tM.of(t.slice(r)))}};function l_(e,t){return e==t?e:(e.constructor!=t.constructor&&(lv=!0),t)}dl.prototype.size=1;var i7e=Qe.replace({}),Lse=class extends dl{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new Sc(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new Sc(r,0,n,this.spaceAbove,i7e):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let o=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(o):o}forEachLine(e,t,n,r,i,o){e<=i+this.length&&t>=i&&o(this.lineAt(0,qn.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},Zl=class uB extends Lse{constructor(t,n,r){super(t,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(t,n){return new Sc(n,this.length,t+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof uB||i instanceof qy&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof qy?i=new uB(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):dl.of(r)}updateHeight(t,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,t.heightForLine(this.length-this.collapsed))+this.breaks*t.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}},qy=class Za extends dl{constructor(t){super(t,0)}heightMetrics(t,n){let r=t.doc.lineAt(n).number,i=t.doc.lineAt(n+this.length).number,o=i-r+1,s,a=0;if(t.lineWrapping){let l=Math.min(this.height,t.lineHeight*o);s=l/o,this.length>o+1&&(a=(this.height-l)/(this.length-o-1))}else s=this.height/o;return{firstLine:r,lastLine:i,perLine:s,perChar:a}}blockAt(t,n,r,i){let{firstLine:o,lastLine:s,perLine:a,perChar:l}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(t<n.lineHeight?0:Math.round(Math.max(0,Math.min(1,(t-r)/this.height))*this.length)),c=n.doc.lineAt(u),d=a+c.length*l,h=Math.max(r,t-d/2);return new Sc(c.from,c.length,h,d,0)}else{let u=Math.max(0,Math.min(s-o,Math.floor((t-r)/a))),{from:c,length:d}=n.doc.line(o+u);return new Sc(c,d,r+a*u,a,0)}}lineAt(t,n,r,i,o){if(n==qn.ByHeight)return this.blockAt(t,r,i,o);if(n==qn.ByPosNoHeight){let{from:f,to:p}=r.doc.lineAt(t);return new Sc(f,p-f,0,0,0)}let{firstLine:s,perLine:a,perChar:l}=this.heightMetrics(r,o),u=r.doc.lineAt(t),c=a+u.length*l,d=u.number-s,h=i+a*d+l*(u.from-o-d);return new Sc(u.from,u.length,Math.max(i,Math.min(h,i+this.height-c)),c,0)}forEachLine(t,n,r,i,o,s){t=Math.max(t,o),n=Math.min(n,o+this.length);let{firstLine:a,perLine:l,perChar:u}=this.heightMetrics(r,o);for(let c=t,d=i;c<=n;){let h=r.doc.lineAt(c);if(c==t){let p=h.number-a;d+=l*p+u*(t-o-p)}let f=l+u*h.length;s(new Sc(h.from,h.length,d,f,0)),d+=f,c=h.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let o=r[r.length-1];o instanceof Za?r[r.length-1]=new Za(o.length+i):r.push(null,new Za(i-1))}if(t>0){let o=r[0];o instanceof Za?r[0]=new Za(t+o.length):r.unshift(new Za(t-1),null)}return dl.of(r)}decomposeLeft(t,n){n.push(new Za(t-1),null)}decomposeRight(t,n){n.push(null,new Za(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let o=n+this.length;if(i&&i.from<=n+this.length&&i.more){let s=[],a=Math.max(n,i.from),l=-1;for(i.from>n&&s.push(new Za(i.from-n-1).updateHeight(t,n));a<=o&&i.more;){let c=t.doc.lineAt(a).length;s.length&&s.push(null);let d=i.heights[i.index++],h=0;d<0&&(h=-d,d=i.heights[i.index++]),l==-1?l=d:Math.abs(d-l)>=eM&&(l=-2);let f=new Zl(c,d,h);f.outdated=!1,s.push(f),a+=c+1}a<=o&&s.push(null,new Za(o-a).updateHeight(t,a));let u=dl.of(s);return(l<0||Math.abs(u.height-this.height)>=eM||Math.abs(l-this.heightMetrics(t,n).perLine)>=eM)&&(lv=!0),l_(this,u)}else(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}},o7e=class extends dl{constructor(e,t,n){super(e.length+t+n.length,e.height+n.height,t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let o=r+this.left.height,s=i+this.left.length+this.break,a=t==qn.ByHeight?e<o:e<s,l=a?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,o,s);if(this.break||(a?l.to<s:l.from>s))return l;let u=t==qn.ByPosNoHeight?qn.ByPosNoHeight:qn.ByPos;return a?l.join(this.right.lineAt(s,u,n,o,s)):this.left.lineAt(s,u,n,r,i).join(l)}forEachLine(e,t,n,r,i,o){let s=r+this.left.height,a=i+this.left.length+this.break;if(this.break)e<a&&this.left.forEachLine(e,t,n,r,i,o),t>=a&&this.right.forEachLine(e,t,n,s,a,o);else{let l=this.lineAt(a,qn.ByPos,n,r,i);e<l.from&&this.left.forEachLine(e,l.from-1,n,r,i,o),l.to>=e&&l.from<=t&&o(l),t>l.to&&this.right.forEachLine(l.to+1,t,n,s,a,o)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let o=i.length;for(let s of n)i.push(s);if(e>0&&b7(i,o-1),t<this.length){let s=i.length;this.decomposeRight(t,i),b7(i,s)}return dl.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?dl.of(this.break?[e,null,t]:[e,t]):(this.left=l_(this.left,e),this.right=l_(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:o}=this,s=t+i.length+this.break,a=null;return r&&r.from<=t+i.length&&r.more?a=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=s+o.length&&r.more?a=o=o.updateHeight(e,s,n,r):o.updateHeight(e,s,n),a?this.balanced(i,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}};function b7(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof qy&&(r=e[t+1])instanceof qy&&e.splice(t-1,3,new qy(n.length+1+r.length))}var s7e=5,a7e=class Bse{constructor(t,n){this.pos=t,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=t}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(t,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof Zl?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zl(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(t,n,r){if(t<n||r.heightRelevant){let i=r.widget?r.widget.estimatedHeight:0,o=r.widget?r.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=n-t;r.block?this.addBlock(new Lse(s,i,r)):(s||o||i>=s7e)&&this.addLineDeco(i,o,s)}else n>t&&this.span(t,n);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:t,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=t,this.lineEnd=n,this.writtenTo<t&&((this.writtenTo<t-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,t-1)),this.nodes.push(null)),this.pos>t&&this.nodes.push(new Zl(this.pos-t,-1,0)),this.writtenTo=this.pos}blankContent(t,n){let r=new qy(n-t);return this.oracle.doc.lineAt(t).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let t=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(t instanceof Zl)return t;let n=new Zl(0,-1,0);return this.nodes.push(n),n}addBlock(t){this.enterLine();let n=t.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(t),this.writtenTo=this.pos=this.pos+t.length,n&&n.endSide>0&&(this.covering=t)}addLineDeco(t,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,t),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(t){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zl)&&!this.isCovered?this.nodes.push(new Zl(0,-1,0)):(this.writtenTo<this.pos||n==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let r=t;for(let i of this.nodes)i instanceof Zl&&i.updateHeight(this.oracle,r),r+=i?i.length:1;return this.nodes}static build(t,n,r,i){let o=new Bse(r,t);return hn.spans(n,r,i,o,0),o.finish(r)}};function l7e(e,t,n){let r=new u7e;return hn.compare(e,t,n,r,0),r.changes}var u7e=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&Ly(e,t,this.changes,5)}};function c7e(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,o=Math.max(0,n.left),s=Math.min(i.innerWidth,n.right),a=Math.max(0,n.top),l=Math.min(i.innerHeight,n.bottom);for(let u=e.parentNode;u&&u!=r.body;)if(u.nodeType==1){let c=u,d=window.getComputedStyle(c);if((c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth)&&d.overflow!="visible"){let h=c.getBoundingClientRect();o=Math.max(o,h.left),s=Math.min(s,h.right),a=Math.max(a,h.top),l=Math.min(u==e.parentNode?i.innerHeight:l,h.bottom)}u=d.position=="absolute"||d.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:o-n.left,right:Math.max(o,s)-n.left,top:a-(n.top+t),bottom:Math.max(a,l)-(n.top+t)}}function d7e(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function h7e(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var jR=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return Qe.replace({widget:new f7e(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},f7e=class extends Tu{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}},w7=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=x7,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=On.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet($5).some(r=>typeof r!="function"&&r.class=="cm-lineWrapping");this.heightOracle=new n7e(n),this.stateDeco=S7(t),this.heightMap=dl.empty().applyChanges(this.stateDeco,sn.empty,this.heightOracle.setDoc(t.doc),[new Nc(0,0,0,t.doc.length)]);for(let r=0;r<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());r++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Qe.set(this.lineGaps.map(r=>r.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:i,to:o})=>r>=i&&r<=o)){let{from:i,to:o}=this.lineBlockAt(r);e.push(new tN(i,o))}}return this.viewports=e.sort((n,r)=>n.from-r.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?x7:new g7e(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(gw(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=S7(this.state);let r=e.changedRanges,i=Nc.extendWithRanges(r,l7e(n,this.stateDeco,e?e.changes:ml.empty(this.state.doc.length))),o=this.heightMap.height,s=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);v7(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=o||lv)&&(e.flags|=2),s?(this.scrollAnchorPos=e.changes.mapPos(s.from,-1),this.scrollAnchorHeight=s.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<a.from||t.range.head>a.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let l=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(l||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(lse)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction=="rtl"?On.RTL:On.LTR;let o=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent==="refresh",s=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=s.height;this.contentDOMHeight=s.height,this.mustMeasureContent=!1;let l=0,u=0;if(s.width&&s.height){let{scaleX:w,scaleY:x}=Uoe(t,s);(w>.005&&Math.abs(this.scaleX-w)>.005||x>.005&&Math.abs(this.scaleY-x)>.005)&&(this.scaleX=w,this.scaleY=x,l|=16,o=a=!0)}let c=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=c||this.paddingBottom!=d)&&(this.paddingTop=c,this.paddingBottom=d,l|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,l|=16);let h=Hoe(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let f=this.getScrollOffset();this.scrollOffset!=f&&(this.scrollAnchorHeight=-1,this.scrollOffset=f),this.scrolledToBottom=Koe(this.scrollParent||e.win);let p=(this.printing?h7e:c7e)(t,this.paddingTop),m=p.top-this.pixelViewport.top,g=p.bottom-this.pixelViewport.bottom;this.pixelViewport=p;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!d7e(e.dom))return 0;let v=s.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=s.width,this.editorHeight=e.scrollDOM.clientHeight,l|=16),a){let w=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(w)&&(o=!0),o||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:x,charWidth:S,textHeight:k}=e.docView.measureTextSize();o=x>0&&r.refresh(i,x,S,k,Math.max(5,v/S),w),o&&(e.docView.minWidth=0,l|=16)}m>0&&g>0?u=Math.max(m,g):m<0&&g<0&&(u=Math.min(m,g)),v7();for(let x of this.viewports){let S=x.from==this.viewport.from?w:e.docView.measureVisibleLineHeights(x);this.heightMap=(o?dl.empty().applyChanges(this.stateDeco,sn.empty,this.heightOracle,[new Nc(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,o,new r7e(x.from,S))}lv&&(l|=2)}let b=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return b&&(l&2&&(l|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),l|=this.updateForViewport()),(l&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),l|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),l}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:o,visibleBottom:s}=this,a=new tN(r.lineAt(o-n*1e3,qn.ByHeight,i,0,0).from,r.lineAt(s+(1-n)*1e3,qn.ByHeight,i,0,0).to);if(t){let{head:l}=t.range;if(l<a.from||l>a.to){let u=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),c=r.lineAt(l,qn.ByPos,i,0,0),d;t.y=="center"?d=(c.top+c.bottom)/2-u/2:t.y=="start"||t.y=="nearest"&&l<a.from?d=c.top:d=c.bottom-u,a=new tN(r.lineAt(d-1e3/2,qn.ByHeight,i,0,0).from,r.lineAt(d+u+1e3/2,qn.ByHeight,i,0,0).to)}}return a}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new tN(this.heightMap.lineAt(n,qn.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,qn.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,qn.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,qn.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:s}=this;return(e==0||r<=o-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=s+Math.max(10,Math.min(n,250)))&&r>o-2*1e3&&i<s+2*1e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new jR(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,o=r<<1;if(this.defaultTextDirection!=On.LTR&&!n)return[];let s=[],a=(u,c,d,h)=>{if(c-u<i)return;let f=this.state.selection.main,p=[f.from];f.empty||p.push(f.to);for(let g of p)if(g>u&&g<c){a(u,g-10,d,h),a(g+10,c,d,h);return}let m=m7e(e,g=>g.from>=d.from&&g.to<=d.to&&Math.abs(g.from-u)<i&&Math.abs(g.to-c)<i&&!p.some(y=>g.from<y&&g.to>y));if(!m){if(c<d.to&&t&&n&&t.visibleRanges.some(v=>v.from<=c&&v.to>=c)){let v=t.moveToLineBoundary(ae.cursor(c),!1,!0).head;v>u&&(c=v)}let g=this.gapSize(d,u,c,h),y=n||g<2e6?g:2e6;m=new jR(u,c,g,y)}s.push(m)},l=u=>{if(u.length<o||u.type!=Vi.Text)return;let c=p7e(u.from,u.to,this.stateDeco);if(c.total<o)return;let d=this.scrollTarget?this.scrollTarget.range.head:null,h,f;if(n){let p=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,m,g;if(d!=null){let y=rN(c,d),v=((this.visibleBottom-this.visibleTop)/2+p)/u.height;m=y-v,g=y+v}else m=(this.visibleTop-u.top-p)/u.height,g=(this.visibleBottom-u.top+p)/u.height;h=nN(c,m),f=nN(c,g)}else{let p=c.total*this.heightOracle.charWidth,m=r*this.heightOracle.charWidth,g=0;if(p>2e6)for(let x of e)x.from>=u.from&&x.from<u.to&&x.size!=x.displaySize&&x.from*this.heightOracle.charWidth+g<this.pixelViewport.left&&(g=x.size-x.displaySize);let y=this.pixelViewport.left+g,v=this.pixelViewport.right+g,b,w;if(d!=null){let x=rN(c,d),S=((v-y)/2+m)/p;b=x-S,w=x+S}else b=(y-m)/p,w=(v+m)/p;h=nN(c,b),f=nN(c,w)}h>u.from&&a(u.from,h,u,c),f<u.to&&a(f,u.to,u,c)};for(let u of this.viewportLines)Array.isArray(u.type)?u.type.forEach(l):l(u);return s}gapSize(e,t,n,r){let i=rN(r,n)-rN(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){jR.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=Qe.set(e.map(t=>t.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];hn.spans(t,this.viewport.from,this.viewport.to,{span(i,o){n.push({from:i,to:o})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let i=0;i<n.length&&!(r&8);i++){let o=this.visibleRanges[i],s=n[i];(o.from!=s.from||o.to!=s.to)&&(r|=4,e&&e.mapPos(o.from,-1)==s.from&&e.mapPos(o.to,1)==s.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||gw(this.heightMap.lineAt(e,qn.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||gw(this.heightMap.lineAt(this.scaler.fromDOM(e),qn.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return gw(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},tN=class{constructor(e,t){this.from=e,this.to=t}};function p7e(e,t,n){let r=[],i=e,o=0;return hn.spans(n,e,t,{span(){},point(s,a){s>i&&(r.push({from:i,to:s}),o+=s-i),i=a}},20),i<t&&(r.push({from:i,to:t}),o+=t-i),{total:o,ranges:r}}function nN({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let i=0;;i++){let{from:o,to:s}=t[i],a=s-o;if(r<=a)return o+r;r-=a}}function rN(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function m7e(e,t){for(let n of e)if(t(n))return n}var x7={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function S7(e){let t=e.facet(BE).filter(r=>typeof r!="function"),n=e.facet(K5).filter(r=>typeof r!="function");return n.length&&t.push(hn.join(n)),t}var g7e=class qse{constructor(t,n,r){let i=0,o=0,s=0;this.viewports=r.map(({from:a,to:l})=>{let u=n.lineAt(a,qn.ByPos,t,0,0).top,c=n.lineAt(l,qn.ByPos,t,0,0).bottom;return i+=c-u,{from:a,to:l,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let a of this.viewports)a.domTop=s+(a.top-o)*this.scale,s=a.domBottom=a.domTop+(a.bottom-a.top),o=a.bottom}toDOM(t){for(let n=0,r=0,i=0;;n++){let o=n<this.viewports.length?this.viewports[n]:null;if(!o||t<o.top)return i+(t-r)*this.scale;if(t<=o.bottom)return o.domTop+(t-o.top);r=o.bottom,i=o.domBottom}}fromDOM(t){for(let n=0,r=0,i=0;;n++){let o=n<this.viewports.length?this.viewports[n]:null;if(!o||t<o.domTop)return r+(t-i)/this.scale;if(t<=o.domBottom)return o.top+(t-o.domTop);r=o.bottom,i=o.domBottom}}eq(t){return t instanceof qse?this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((n,r)=>n.from==t.viewports[r].from&&n.to==t.viewports[r].to):!1}};function gw(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new Sc(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(i=>gw(i,t)):e._content)}var iN=Te.define({combine:e=>e.join(" ")}),cB=Te.define({combine:e=>e.indexOf(!0)>-1}),dB=Rh.newName(),zse=Rh.newName(),Fse=Rh.newName(),jse={"&light":"."+zse,"&dark":"."+Fse};function hB(e,t,n){return new Rh(t,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return e;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):e+" "+r}})}var y7e=hB("."+dB,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},jse),v7e={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},VR=_e.ie&&_e.ie_version<=11,b7e=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new K9e,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let n of t)this.queue.push(n);(_e.ie&&_e.ie_version<=11||_e.ios&&e.composing)&&t.some(n=>n.type=="childList"&&n.removedNodes.length||n.type=="characterData"&&n.oldValue.length>n.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&_e.android&&e.constructor.EDIT_CONTEXT!==!1&&!(_e.chrome&&_e.chrome_version<126)&&(this.editContext=new x7e(e),e.state.facet(xc)&&(e.contentDOM.editContext=this.editContext.editContext)),VR&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(xc)?n.root.activeElement!=this.dom:!jw(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);if(i&&i.isWidget()&&i.widget.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(_e.ie&&_e.ie_version<=11||_e.android&&_e.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Ww(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Tx(e.root);if(!t)return!1;let n=_e.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&w7e(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=jw(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&Q9e(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(n.nodeType==1)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let n of this.scrollTargets)n.removeEventListener("scroll",this.onScroll);for(let n of this.scrollTargets=t)n.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,v7e),VR&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),VR&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let r=()=>{let i=this.delayedAndroidKey;i&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=i.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&i.force&&By(this.dom,i.key,i.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(r)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(!((n=this.delayedAndroidKey)===null||n===void 0)&&n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let o=this.readMutation(i);o&&(o.typeOver&&(r=!0),t==-1?{from:t,to:n}=o:(t=Math.min(o.from,t),n=Math.max(o.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&jw(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new LKe(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,r=Nse(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!a_(this.view.state.selection,t.newSel.main))&&this.view.update([]),r}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type=="attributes"),e.type=="childList"){let n=k7(t,e.previousSibling||e.target.previousSibling,-1),r=k7(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(xc)!=e.state.facet(xc)&&(e.view.contentDOM.editContext=e.state.facet(xc)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(n=this.resizeScroll)===null||n===void 0||n.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function k7(e,t,n){for(;t;){let r=Nr.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i!=e.dom?i:n>0?t.nextSibling:t.previousSibling}return null}function C7(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,o=t.endOffset,s=e.docView.domAtPos(e.state.selection.main.anchor,1);return Ww(s.node,s.offset,i,o)&&([n,r,i,o]=[i,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:o}}function w7e(e,t){if(t.getComposedRanges){let i=t.getComposedRanges(e.root)[0];if(i)return C7(e,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",r,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",r,!0),n?C7(e,n):null}var x7e=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:o}=r,s=this.toEditorPos(n.updateRangeStart),a=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:s,drifted:!1});let l=a-s>n.text.length;s==this.from&&i<this.from?s=i:a==this.to&&i>this.to&&(a=i);let u=Mse(e.state.sliceDoc(s,a),n.text,(l?r.from:r.to)-s,l?"end":null);if(!u){let d=ae.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));a_(d,r)||e.dispatch({selection:d,userEvent:"select"});return}let c={from:u.from+s,to:u.toA+s,insert:sn.of(n.text.slice(u.from,u.toB).split(`
`))};if((_e.mac||_e.android)&&c.from==o-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:a,insert:sn.of([n.text.replace("."," ")])}),this.pendingContextChange=c,!e.state.readOnly){let d=this.to-this.from+(c.to-c.from+c.insert.length);Q5(e,c,ae.single(this.toEditorPos(n.selectionStart,d),this.toEditorPos(n.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),c.from<c.to&&!c.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let o=this.toEditorPos(n.rangeStart),s=this.toEditorPos(n.rangeEnd);o<s;o++){let a=e.coordsForChar(o);i=a&&new DOMRect(a.left,a.top,a.right-a.left,a.bottom-a.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=n=>{let r=[];for(let i of n.getTextFormats()){let o=i.underlineStyle,s=i.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(s)){let a=this.toEditorPos(i.rangeStart),l=this.toEditorPos(i.rangeEnd);if(a<l){let u=`text-decoration: underline ${/^[a-z]/.test(o)?o+" ":o=="Dashed"?"dashed ":o=="Squiggle"?"wavy ":""}${/thin/i.test(s)?1:2}px`;r.push(Qe.mark({attributes:{style:u}}).range(a,l))}}}e.dispatch({effects:cse.of(Qe.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let r=Tx(n.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,o,s,a,l)=>{if(n)return;let u=l.length-(o-i);if(r&&o>=r.to)if(r.from==i&&r.to==o&&r.insert.eq(l)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(i+=t,o+=t,o<=this.from)this.from+=u,this.to+=u;else if(i<this.to){if(i<this.from||o>this.to||this.to-this.from+l.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(o),l.toString()),this.to+=u}t+=u}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},ke=class fB{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(t={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),t.parent&&t.parent.appendChild(this.dom);let{dispatch:r}=t;this.dispatchTransactions=t.dispatchTransactions||r&&(i=>i.forEach(o=>r(o,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=t.root||Y9e(t.parent)||document,this.viewState=new w7(this,t.state||or.create(t)),t.scrollTo&&t.scrollTo.is(JC)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ky).map(i=>new LR(i));for(let i of this.plugins)i.update(this);this.observer=new b7e(this),this.inputState=new FKe(this),this.inputState.ensureHandlers(this.plugins),this.docView=new a7(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...t){let n=t.length==1&&t[0]instanceof ts?t:t.length==1&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(n,this)}update(t){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,o=this.state;for(let h of t){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;t.some(h=>h.annotation(Dse))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=Rse(o,s),l||(a=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(c=null)):this.observer.clear(),o.facet(or.phrases)!=this.state.facet(or.phrases))return this.setState(o);i=i7.create(this,o,t),i.flags|=a;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let h of t){if(d&&(d=d.map(h.changes)),h.scrollIntoView){let{main:f}=h.state.selection;d=new PR(f.empty?f:ae.cursor(f.head,f.head>f.anchor?-1:1))}for(let f of h.effects)f.is(JC)&&(d=f.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=M7.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(pw)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(iN)!=i.state.facet(iN)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let h of this.state.facet(tB))try{h(i)}catch(f){Ao(this.state,f,"update listener")}(l||c)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),c&&!Nse(this,c)&&u.force&&By(this.contentDOM,u.key,u.keyCode)})}setState(t){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=t;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new w7(this,t),this.plugins=t.facet(ky).map(r=>new LR(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new a7(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(t){let n=t.startState.facet(ky),r=t.state.facet(ky);if(n!=r){let i=[];for(let o of r){let s=n.indexOf(o);if(s<0)i.push(new LR(o));else{let a=this.plugins[s];a.mustUpdate=t,i.push(a)}}for(let o of this.plugins)o.mustUpdate!=t&&o.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=t;for(let i=0;i<this.plugins.length;i++)this.plugins[i].update(this);n!=r&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let t of this.plugins){let n=t.value;if(n&&n.docViewUpdate)try{n.docViewUpdate(this)}catch(r){Ao(this.state,r,"doc view update listener")}}}measure(t=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,t&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(Koe(r||this.win))o=-1,s=this.viewState.heightMap.height;else{let f=this.viewState.scrollAnchorAt(i);o=f.from,s=f.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];l&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(f=>{try{return f.read(this)}catch(p){return Ao(this.state,p),N7}}),d=i7.create(this,this.state,[]),h=!1;d.flags|=l,n?n.flags|=l:n=d,this.updateState=2,d.empty||(this.updatePlugins(d),this.inputState.update(d),this.updateAttrs(),h=this.docView.update(d),h&&this.docViewUpdate());for(let f=0;f<u.length;f++)if(c[f]!=N7)try{let p=u[f];p.write&&p.write(c[f],this)}catch(p){Ao(this.state,p)}if(h&&this.docView.updateSelection(!0),!d.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let f=((o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-s)/this.scaleY;if((f>1||f<-1)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+f,r?r.scrollTop+=f:this.win.scrollBy(0,f),s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let a of this.state.facet(tB))a(n)}get themeClasses(){return dB+" "+(this.state.facet(cB)?Fse:zse)+" "+this.state.facet(iN)}updateAttrs(){let t=_7(this,dse,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(xc)?"true":"false",class:"cm-content",style:`${_e.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),_7(this,$5,n);let r=this.observer.ignore(()=>{let i=ZK(this.contentDOM,this.contentAttrs,n),o=ZK(this.dom,this.editorAttrs,t);return i||o});return this.editorAttrs=t,this.contentAttrs=n,r}showAnnouncements(t){let n=!0;for(let r of t)for(let i of r.effects)if(i.is(fB.announce)){n&&(this.announceDOM.textContent=""),n=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(pw);let t=this.state.facet(fB.cspNonce);Rh.mount(this.root,this.styleModules.concat(y7e).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(t){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),t){if(this.measureRequests.indexOf(t)>-1)return;if(t.key!=null){for(let n=0;n<this.measureRequests.length;n++)if(this.measureRequests[n].key===t.key){this.measureRequests[n]=t;return}}this.measureRequests.push(t)}}plugin(t){let n=this.pluginMap.get(t);return(n===void 0||n&&n.plugin!=t)&&this.pluginMap.set(t,n=this.plugins.find(r=>r.plugin==t)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(t){return this.readMeasured(),this.viewState.elementAtHeight(t)}lineBlockAtHeight(t){return this.readMeasured(),this.viewState.lineBlockAtHeight(t)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(t){return this.viewState.lineBlockAt(t)}get contentHeight(){return this.viewState.contentHeight}moveByChar(t,n,r){return FR(this,t,l7(this,t,n,r))}moveByGroup(t,n){return FR(this,t,l7(this,t,n,r=>TKe(this,t.head,r)))}visualLineSide(t,n){let r=this.bidiSpans(t),i=this.textDirectionAt(t.from),o=r[n?r.length-1:0];return ae.cursor(o.side(n,i)+t.from,o.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return OKe(this,t,n,r)}moveVertically(t,n,r){return FR(this,t,AKe(this,t,n,r))}domAtPos(t,n=1){return this.docView.domAtPos(t,n)}posAtDOM(t,n=0){return this.docView.posFromDOM(t,n)}posAtCoords(t,n=!0){this.readMeasured();let r=aB(this,t,n);return r&&r.pos}posAndSideAtCoords(t,n=!0){return this.readMeasured(),aB(this,t,n)}coordsAtPos(t,n=1){this.readMeasured();let r=this.docView.coordsAt(t,n);if(!r||r.left==r.right)return r;let i=this.state.doc.lineAt(t),o=this.bidiSpans(i),s=o[uu.find(o,t-i.from,-1,n)];return Ax(r,s.dir==On.LTR==n>0)}coordsForChar(t){return this.readMeasured(),this.docView.coordsForChar(t)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(t){return!this.state.facet(ase)||t<this.viewport.from||t>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(t))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(t){if(t.length>S7e)return Zoe(t.length);let n=this.textDirectionAt(t.from),r;for(let o of this.bidiCache)if(o.from==t.from&&o.dir==n&&(o.fresh||Joe(o.isolates,r=r7(this,t))))return o.order;r||(r=r7(this,t));let i=nKe(t.text,n,r);return this.bidiCache.push(new M7(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||_e.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{$oe(this.contentDOM),this.docView.updateSelection()})}setRoot(t){this._root!=t&&(this._root=t,this.observer.setWindow((t.nodeType==9?t:t.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let t of this.plugins)t.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(t,n={}){return JC.of(new PR(typeof t=="number"?ae.cursor(t):t,n.y,n.x,n.yMargin,n.xMargin))}scrollSnapshot(){let{scrollTop:t,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(t);return JC.of(new PR(ae.cursor(r.from),"start","start",r.top-t,n,!0))}setTabFocusMode(t){t==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof t=="boolean"?this.inputState.tabFocusMode=t?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+t)}static domEventHandlers(t){return Jr.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Jr.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=Rh.newName(),i=[iN.of(r),pw.of(hB(`.${r}`,t))];return n&&n.dark&&i.push(cB.of(!0)),i}static baseTheme(t){return Xh.lowest(pw.of(hB("."+dB,t,jse)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content");return((n=(r&&Nr.get(r)||Nr.get(t))?.root)===null||n===void 0?void 0:n.view)||null}};ke.styleModule=pw;ke.inputHandler=ose;ke.clipboardInputFilter=U5;ke.clipboardOutputFilter=H5;ke.scrollHandler=use;ke.focusChangeEffect=sse;ke.perLineTextDirection=ase;ke.exceptionSink=ise;ke.updateListener=tB;ke.editable=xc;ke.mouseSelectionStyle=rse;ke.dragMovesSelection=nse;ke.clickAddsSelectionRange=tse;ke.decorations=BE;ke.blockWrappers=hse;ke.outerDecorations=K5;ke.atomicRanges=b1;ke.bidiIsolatedRanges=fse;ke.scrollMargins=pse;ke.darkTheme=cB;ke.cspNonce=Te.define({combine:e=>e.length?e[0]:""});ke.contentAttributes=$5;ke.editorAttributes=dse;ke.lineWrapping=ke.contentAttributes.of({class:"cm-lineWrapping"});ke.announce=St.define();var S7e=4096,N7={},M7=class Vse{constructor(t,n,r,i,o,s){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=o,this.order=s}static update(t,n){if(n.empty&&!t.some(o=>o.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:On.LTR;for(let o=Math.max(0,t.length-10);o<t.length;o++){let s=t[o];s.dir==i&&!n.touchesRange(s.from,s.to)&&r.push(new Vse(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return r}};function _7(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let o=r[i],s=typeof o=="function"?o(e):o;s&&z5(s,n)}return n}var k7e=_e.mac?"mac":_e.windows?"win":_e.linux?"linux":"key";function C7e(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r=="Space"&&(r=" ");let i,o,s,a;for(let l=0;l<n.length-1;++l){let u=n[l];if(/^(cmd|meta|m)$/i.test(u))a=!0;else if(/^a(lt)?$/i.test(u))i=!0;else if(/^(c|ctrl|control)$/i.test(u))o=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))t=="mac"?a=!0:o=!0;else throw new Error("Unrecognized modifier name: "+u)}return i&&(r="Alt-"+r),o&&(r="Ctrl-"+r),a&&(r="Meta-"+r),s&&(r="Shift-"+r),r}function oN(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n!==!1&&t.shiftKey&&(e="Shift-"+e),e}var N7e=Xh.default(ke.domEventHandlers({keydown(e,t){return Use(Wse(t.state),e,t,"editor")}})),w1=Te.define({enables:N7e}),E7=new WeakMap;function Wse(e){let t=e.facet(w1),n=E7.get(t);return n||E7.set(t,n=E7e(t.reduce((r,i)=>r.concat(i),[]))),n}function M7e(e,t,n){return Use(Wse(e.state),t,e,n)}var sh=null,_7e=4e3;function E7e(e,t=k7e){let n=Object.create(null),r=Object.create(null),i=(s,a)=>{let l=r[s];if(l==null)r[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,u,c)=>{var d,h;let f=n[s]||(n[s]=Object.create(null)),p=a.split(/ (?!$)/).map(y=>C7e(y,t));for(let y=1;y<p.length;y++){let v=p.slice(0,y).join(" ");i(v,!0),f[v]||(f[v]={preventDefault:!0,stopPropagation:!1,run:[b=>{let w=sh={view:b,prefix:v,scope:s};return setTimeout(()=>{sh==w&&(sh=null)},_7e),!0}]})}let m=p.join(" ");i(m,!1);let g=f[m]||(f[m]={preventDefault:!1,stopPropagation:!1,run:((h=(d=f._any)===null||d===void 0?void 0:d.run)===null||h===void 0?void 0:h.slice())||[]});l&&g.run.push(l),u&&(g.preventDefault=!0),c&&(g.stopPropagation=!0)};for(let s of e){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let u of a){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:d}=s;for(let h in c)c[h].run.push(f=>d(f,pB))}let l=s[t]||s.key;if(l)for(let u of a)o(u,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(u,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return n}var pB=null;function Use(e,t,n,r){pB=t;let i=j9e(t),o=Ko(i,0),s=su(o)==i.length&&i!=" ",a="",l=!1,u=!1,c=!1;sh&&sh.view==n&&sh.scope==r&&(a=sh.prefix+" ",Ese.indexOf(t.keyCode)<0&&(u=!0,sh=null));let d=new Set,h=g=>{if(g){for(let y of g.run)if(!d.has(y)&&(d.add(y),y(n)))return g.stopPropagation&&(c=!0),!0;g.preventDefault&&(g.stopPropagation&&(c=!0),u=!0)}return!1},f=e[r],p,m;return f&&(h(f[a+oN(i,t,!s)])?l=!0:s&&(t.altKey||t.metaKey||t.ctrlKey)&&!(_e.windows&&t.ctrlKey&&t.altKey)&&!(_e.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Ih[t.keyCode])&&p!=i?(h(f[a+oN(p,t,!0)])||t.shiftKey&&(m=Ex[t.keyCode])!=i&&m!=p&&h(f[a+oN(m,t,!1)]))&&(l=!0):s&&t.shiftKey&&h(f[a+oN(i,t,!0)])&&(l=!0),!l&&h(f._any)&&(l=!0)),u&&(l=!0),l&&c&&t.stopPropagation(),pB=null,l}var G5=class Hse{constructor(t,n,r,i,o){this.className=t,this.left=n,this.top=r,this.width=i,this.height=o}draw(){let t=document.createElement("div");return t.className=this.className,this.adjust(t),t}update(t,n){return n.className!=this.className?!1:(this.adjust(t),!0)}adjust(t){t.style.left=this.left+"px",t.style.top=this.top+"px",this.width!=null&&(t.style.width=this.width+"px"),t.style.height=this.height+"px"}eq(t){return this.left==t.left&&this.top==t.top&&this.width==t.width&&this.height==t.height&&this.className==t.className}static forRange(t,n,r){if(r.empty){let i=t.coordsAtPos(r.head,r.assoc||1);if(!i)return[];let o=$se(t);return[new Hse(n,i.left-o.left,i.top-o.top,null,i.bottom-i.top)]}else return O7e(t,n,r)}};function $se(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==On.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function O7(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let o=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,a=e.posAtCoords({x:o.left+1,y:s}),l=e.posAtCoords({x:o.right-1,y:s});return a==null||l==null?r:{from:Math.max(r.from,Math.min(a,l)),to:Math.min(r.to,Math.max(a,l))}}function O7e(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let r=Math.max(n.from,e.viewport.from),i=Math.min(n.to,e.viewport.to),o=e.textDirection==On.LTR,s=e.contentDOM,a=s.getBoundingClientRect(),l=$se(e),u=s.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),d=a.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),h=a.right-(c?parseInt(c.paddingRight):0),f=sB(e,r,1),p=sB(e,i,-1),m=f.type==Vi.Text?f:null,g=p.type==Vi.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=O7(e,r,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=O7(e,i,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return v(b(n.from,n.to,m));{let x=m?b(n.from,null,m):w(f,!1),S=g?b(null,n.to,g):w(p,!0),k=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&x.bottom+e.defaultLineHeight/2<S.top?k.push(y(d,x.bottom,h,S.top)):x.bottom<S.top&&e.elementAtHeight((x.bottom+S.top)/2).type==Vi.Text&&(x.bottom=S.top=(x.bottom+S.top)/2),v(x).concat(k).concat(v(S))}function y(x,S,k,C){return new G5(t,x-l.left,S-l.top,Math.max(0,k-x),C-S)}function v({top:x,bottom:S,horizontal:k}){let C=[];for(let N=0;N<k.length;N+=2)C.push(y(k[N],x,k[N+1],S));return C}function b(x,S,k){let C=1e9,N=-1e9,E=[];function D(_,R,T,B,A){let M=e.coordsAtPos(_,_==k.to?-2:2),P=e.coordsAtPos(T,T==k.from?2:-2);!M||!P||(C=Math.min(M.top,P.top,C),N=Math.max(M.bottom,P.bottom,N),A==On.LTR?E.push(o&&R?d:M.left,o&&B?h:P.right):E.push(!o&&B?d:P.left,!o&&R?h:M.right))}let q=x??k.from,z=S??k.to;for(let _ of e.visibleRanges)if(_.to>q&&_.from<z)for(let R=Math.max(_.from,q),T=Math.min(_.to,z);;){let B=e.state.doc.lineAt(R);for(let A of e.bidiSpans(B)){let M=A.from+B.from,P=A.to+B.from;if(M>=T)break;P>R&&D(Math.max(M,R),x==null&&M<=q,Math.min(P,T),S==null&&P>=z,A.dir)}if(R=B.to+1,R>=T)break}return E.length==0&&D(q,x==null,z,S==null,e.textDirection),{top:C,bottom:N,horizontal:E}}function w(x,S){let k=a.top+(S?x.top:x.bottom);return{top:k,bottom:k,horizontal:[]}}}function T7e(e,t){return e.constructor==t.constructor&&e.eq(t)}var A7e=class{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(nM)!=e.state.facet(nM)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(nM);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform=`scale(${1/e}, ${1/t})`)}draw(e){if(e.length!=this.drawn.length||e.some((t,n)=>!T7e(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let r of e)r.update&&t&&r.constructor&&this.drawn[n].constructor&&r.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(r.draw(),t);for(;t;){let r=t.nextSibling;t.remove(),t=r}this.drawn=e,_e.safari&&_e.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}},nM=Te.define();function Kse(e){return[Jr.define(t=>new A7e(t,e)),nM.of(e)]}var Ix=Te.define({combine(e){return kl(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function D7e(e={}){return[Ix.of(e),R7e,I7e,P7e,lse.of(!0)]}function Yse(e){return e.startState.facet(Ix)!=e.state.facet(Ix)}var R7e=Kse({above:!0,markers(e){let{state:t}=e,n=t.facet(Ix),r=[];for(let i of t.selection.ranges){let o=i==t.selection.main;if(i.empty||n.drawRangeCursor){let s=o?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",a=i.empty?i:ae.cursor(i.head,i.head>i.anchor?-1:1);for(let l of G5.forRange(e,s,a))r.push(l)}}return r},update(e,t){e.transactions.some(r=>r.selection)&&(t.style.animationName=t.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Yse(e);return n&&T7(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){T7(t.state,e)},class:"cm-cursorLayer"});function T7(e,t){t.style.animationDuration=e.facet(Ix).cursorBlinkRate+"ms"}var I7e=Kse({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:G5.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||Yse(e)},class:"cm-selectionLayer"}),P7e=Xh.highest(ke.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),Qse=St.define({map(e,t){return e==null?null:t.mapPos(e)}}),yw=uo.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(Qse)?r.value:n,e)}}),L7e=Jr.fromClass(class{constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(e){var t;let n=e.state.field(yw);n==null?this.cursor!=null&&((t=this.cursor)===null||t===void 0||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(yw)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(yw),n=t!=null&&e.coordsAtPos(t);if(!n)return null;let r=e.scrollDOM.getBoundingClientRect();return{left:n.left-r.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-r.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(yw)!=e&&this.view.dispatch({effects:Qse.of(e)})}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){(e.target==this.view.contentDOM||!this.view.contentDOM.contains(e.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function B7e(){return[yw,L7e]}function A7(e,t,n,r,i){t.lastIndex=0;for(let o=e.iterRange(n,r),s=n,a;!o.next().done;s+=o.value.length)if(!o.lineBreak)for(;a=t.exec(o.value);)i(s+a.index,a)}function q7e(e,t){let n=e.visibleRanges;if(n.length==1&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let r=[];for(let{from:i,to:o}of n)i=Math.max(e.state.doc.lineAt(i).from,i-t),o=Math.min(e.state.doc.lineAt(o).to,o+t),r.length&&r[r.length-1].to>=i?r[r.length-1].to=o:r.push({from:i,to:o});return r}var z7e=class{constructor(e){let{regexp:t,decoration:n,decorate:r,boundary:i,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,r)this.addMatch=(s,a,l,u)=>r(u,l,l+s[0].length,s,a);else if(typeof n=="function")this.addMatch=(s,a,l,u)=>{let c=n(s,a,l);c&&u(l,l+s[0].length,c)};else if(n)this.addMatch=(s,a,l,u)=>u(l,l+s[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=i,this.maxLength=o}createDeco(e){let t=new sm,n=t.add.bind(t);for(let{from:r,to:i}of q7e(e,this.maxLength))A7(e.state.doc,this.regexp,r,i,(o,s)=>this.addMatch(s,e,o,n));return t.finish()}updateDeco(e,t){let n=1e9,r=-1;return e.docChanged&&e.changes.iterChanges((i,o,s,a)=>{a>=e.view.viewport.from&&s<=e.view.viewport.to&&(n=Math.min(s,n),r=Math.max(a,r))}),e.viewportMoved||r-n>1e3?this.createDeco(e.view):r>-1?this.updateRange(e.view,t.map(e.changes),n,r):t}updateRange(e,t,n,r){for(let i of e.visibleRanges){let o=Math.max(i.from,n),s=Math.min(i.to,r);if(s>=o){let a=e.state.doc.lineAt(o),l=a.to<s?e.state.doc.lineAt(s):a,u=Math.max(i.from,a.from),c=Math.min(i.to,l.to);if(this.boundary){for(;o>a.from;o--)if(this.boundary.test(a.text[o-1-a.from])){u=o;break}for(;s<l.to;s++)if(this.boundary.test(l.text[s-l.from])){c=s;break}}let d=[],h,f=(p,m,g)=>d.push(g.range(p,m));if(a==l)for(this.regexp.lastIndex=u-a.from;(h=this.regexp.exec(a.text))&&h.index<c-a.from;)this.addMatch(h,e,h.index+a.from,f);else A7(e.state.doc,this.regexp,u,c,(p,m)=>this.addMatch(m,e,p,f));t=t.update({filterFrom:u,filterTo:c,filter:(p,m)=>p<u||m>c,add:d})}}return t}},mB=/x/.unicode!=null?"gu":"g",F7e=new RegExp(`[\0-\b
-\x7F-\x9F\xAD\u061C\u200B\u200E\u200F\u2028\u2029\u202D\u202E\u2066\u2067\u2069\uFEFF\uFFF9-\uFFFC]`,mB),j7e={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},WR=null;function V7e(){var e;if(WR==null&&typeof document<"u"&&document.body){let t=document.body.style;WR=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return WR||!1}var rM=Te.define({combine(e){let t=kl(e,{render:null,specialChars:F7e,addSpecialChars:null});return(t.replaceTabs=!V7e())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,mB)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,mB)),t}});function W7e(e={}){return[rM.of(e),U7e()]}var D7=null;function U7e(){return D7||(D7=Jr.fromClass(class{constructor(e){this.view=e,this.decorations=Qe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(rM)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new z7e({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,o=Ko(t[0],0);if(o==9){let s=i.lineAt(r),a=n.state.tabSize,l=Iv(s.text,a,r-s.from);return Qe.replace({widget:new Y7e((a-l%a)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[o]||(this.decorationCache[o]=Qe.replace({widget:new K7e(e,o)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(rM);e.startState.facet(rM)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}))}var H7e="\u2022";function $7e(e){return e>=32?H7e:e==10?"\u2424":String.fromCharCode(9216+e)}var K7e=class extends Tu{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=$7e(this.code),n=e.state.phrase("Control character")+" "+(j7e[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,n,t);if(r)return r;let i=document.createElement("span");return i.textContent=t,i.title=n,i.setAttribute("aria-label",n),i.className="cm-specialChar",i}ignoreEvent(){return!1}},Y7e=class extends Tu{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}};function Q7e(){return X7e}var G7e=Qe.line({class:"cm-activeLine"}),X7e=Jr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let r of e.state.selection.ranges){let i=e.lineBlockAt(r.head);i.from>t&&(n.push(G7e.range(i.from)),t=i.from)}return Qe.set(n)}},{decorations:e=>e.decorations}),J7e=class extends Tu{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?Vw(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Ax(t[0],n.direction!="rtl"),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function Z7e(e){let t=Jr.fromClass(class{constructor(n){this.view=n,this.placeholder=e?Qe.set([Qe.widget({widget:new J7e(e),side:1}).range(0)]):Qe.none}get decorations(){return this.view.state.doc.length?Qe.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,ke.contentAttributes.of({"aria-placeholder":e})]:t}var gB=2e3;function eYe(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),o=[];if(t.off>gB||n.off>gB||t.col<0||n.col<0){let s=Math.min(t.off,n.off),a=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let u=e.doc.line(l);u.length<=a&&o.push(ae.range(u.from+s,u.to+a))}}else{let s=Math.min(t.col,n.col),a=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let u=e.doc.line(l),c=WL(u.text,s,e.tabSize,!0);if(c<0)o.push(ae.cursor(u.to));else{let d=WL(u.text,a,e.tabSize);o.push(ae.range(u.from+c,u.from+d))}}}return o}function tYe(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function R7(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1),r=e.state.doc.lineAt(n),i=n-r.from,o=i>gB?-1:i==r.length?tYe(e,t.clientX):Iv(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:o,off:i}}function nYe(e,t){let n=R7(e,t),r=e.state.selection;return n?{update(i){if(i.docChanged){let o=i.changes.mapPos(i.startState.doc.line(n.line).from),s=i.state.doc.lineAt(o);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},r=r.map(i.changes)}},get(i,o,s){let a=R7(e,i);if(!a)return r;let l=eYe(e.state,n,a);return l.length?s?ae.create(l.concat(r.ranges)):ae.create(l):r}}:null}function rYe(e){let t=e?.eventFilter||(n=>n.altKey&&n.button==0);return ke.mouseSelectionStyle.of((n,r)=>t(r)?nYe(n,r):null)}var iYe={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},oYe={style:"cursor: crosshair"};function sYe(e={}){let[t,n]=iYe[e.key||"Alt"],r=Jr.fromClass(class{constructor(i){this.view=i,this.isDown=!1}set(i){this.isDown!=i&&(this.isDown=i,this.view.update([]))}},{eventObservers:{keydown(i){this.set(i.keyCode==t||n(i))},keyup(i){(i.keyCode==t||!n(i))&&this.set(!1)},mousemove(i){this.set(n(i))}}});return[r,ke.contentAttributes.of(i=>{var o;return!((o=i.plugin(r))===null||o===void 0)&&o.isDown?oYe:null})]}var sN="-10000px",Gse=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(o=>o);let i=null;this.tooltipViews=this.tooltips.map(o=>i=n(o,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(a=>a);if(r===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],s=t?[]:null;for(let a=0;a<i.length;a++){let l=i[a],u=-1;if(l){for(let c=0;c<this.tooltips.length;c++){let d=this.tooltips[c];d&&d.create==l.create&&(u=c)}if(u<0)o[a]=this.createTooltipView(l,a?o[a-1]:null),s&&(s[a]=!!l.above);else{let c=o[a]=this.tooltipViews[u];s&&(s[a]=t[u]),c.update&&c.update(e)}}}for(let a of this.tooltipViews)o.indexOf(a)<0&&(this.removeTooltipView(a),(n=a.destroy)===null||n===void 0||n.call(a));return t&&(s.forEach((a,l)=>t[l]=a),t.length=s.length),this.input=r,this.tooltips=i,this.tooltipViews=o,!0}};function aYe(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}var UR=Te.define({combine:e=>{var t,n,r;return{position:_e.ios?"absolute":((t=e.find(i=>i.position))===null||t===void 0?void 0:t.position)||"fixed",parent:((n=e.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=e.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||aYe}}}),I7=new WeakMap,X5=Jr.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(UR);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Gse(e,jE,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(UR);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add("cm-tooltip"),e.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=sN,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(e=r.destroy)===null||e===void 0||e.call(r);this.parent&&this.container.remove(),(t=this.resizeObserver)===null||t===void 0||t.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(_e.safari){let s=o.getBoundingClientRect();n=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}else n=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(e=o.width/this.parent.offsetWidth,t=o.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=Y5(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(UR).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:o}=e,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],u=this.manager.tooltipViews[a],{dom:c}=u,d=e.pos[a],h=e.size[a];if(!d||l.clip!==!1&&(d.bottom<=Math.max(n.top,r.top)||d.top>=Math.min(n.bottom,r.bottom)||d.right<Math.max(n.left,r.left)-.1||d.left>Math.min(n.right,r.right)+.1)){c.style.top=sN;continue}let f=l.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=f?7:0,m=h.right-h.left,g=(t=I7.get(u))!==null&&t!==void 0?t:h.bottom-h.top,y=u.offset||uYe,v=this.view.textDirection==On.LTR,b=h.width>r.right-r.left?v?r.left:r.right-h.width:v?Math.max(r.left,Math.min(d.left-(f?14:0)+y.x,r.right-m)):Math.min(Math.max(r.left,d.left-m+(f?14:0)-y.x),r.right-m),w=this.above[a];!l.strictSide&&(w?d.top-g-p-y.y<r.top:d.bottom+g+p+y.y>r.bottom)&&w==r.bottom-d.bottom>d.top-r.top&&(w=this.above[a]=!w);let x=(w?d.top-r.top:r.bottom-d.bottom)-p;if(x<g&&u.resize!==!1){if(x<this.view.defaultLineHeight){c.style.top=sN;continue}I7.set(u,g),c.style.height=(g=x)/o+"px"}else c.style.height&&(c.style.height="");let S=w?d.top-g-p-y.y:d.bottom+p+y.y,k=b+m;if(u.overlap!==!0)for(let C of s)C.left<k&&C.right>b&&C.top<S+g&&C.bottom>S&&(S=w?C.top-g-2-p:C.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-e.parent.top)/o+"px",P7(c,(b-e.parent.left)/i)):(c.style.top=S/o+"px",P7(c,b/i)),f){let C=d.left+(v?y.x:-y.x)-(b+14-7);f.style.left=C/i+"px"}u.overlap!==!0&&s.push({left:b,top:S,right:k,bottom:S+g}),c.classList.toggle("cm-tooltip-above",w),c.classList.toggle("cm-tooltip-below",!w),u.positioned&&u.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=sN}},{eventObservers:{scroll(){this.maybeMeasure()}}});function P7(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}var lYe=ke.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),uYe={x:0,y:0},jE=Te.define({enables:[X5,lYe]}),u_=Te.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])}),Xse=class Jse{static create(t){return new Jse(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gse(t,u_,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(t,n){let r=t.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(t){for(let n of this.manager.tooltipViews)n.mount&&n.mount(t);this.mounted=!0}positioned(t){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(t)}update(t){this.manager.update(t)}destroy(){var t;for(let n of this.manager.tooltipViews)(t=n.destroy)===null||t===void 0||t.call(n)}passProp(t){let n;for(let r of this.manager.tooltipViews){let i=r[t];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},cYe=jE.compute([u_],e=>{let t=e.facet(u_);return t.length===0?null:{pos:Math.min(...t.map(n=>n.pos)),end:Math.max(...t.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Xse.create,above:t[0].above,arrow:t.some(n=>n.arrow)}}),dYe=class{constructor(e,t,n,r,i){this.view=e,this.source=t,this.field=n,this.setHover=r,this.hoverTime=i,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.tile.nearest(t.target);if(!n)return;let r,i=1;if(n.isWidget())r=n.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let s=e.coordsAtPos(r);if(!s||t.y<s.top||t.y>s.bottom||t.x<s.left-e.defaultCharacterWidth||t.x>s.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(u=>u.from<=r&&u.to>=r),l=a&&a.dir==On.RTL?-1:1;i=t.x<s.left?-l:l}let o=this.source(e,r,i);if(o?.then){let s=this.pending={pos:r};o.then(a=>{this.pending==s&&(this.pending=null,a&&!(Array.isArray(a)&&!a.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(a)?a:[a])}))},a=>Ao(e.state,a,"hover tooltip"))}else o&&!(Array.isArray(o)&&!o.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(o)?o:[o])})}get tooltip(){let e=this.view.plugin(X5),t=e?e.manager.tooltips.findIndex(n=>n.create==Xse.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:i}=this;if(r.length&&i&&!hYe(i.dom,e)||this.pending){let{pos:o}=r[0]||this.pending,s=(n=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:o;(o==s?this.view.posAtCoords(this.lastMove)!=o:!fYe(this.view,o,s,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},aN=4;function hYe(e,t){let{left:n,right:r,top:i,bottom:o}=e.getBoundingClientRect(),s;if(s=e.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();i=Math.min(a.top,i),o=Math.max(a.bottom,o)}return t.clientX>=n-aN&&t.clientX<=r+aN&&t.clientY>=i-aN&&t.clientY<=o+aN}function fYe(e,t,n,r,i,o){let s=e.scrollDOM.getBoundingClientRect(),a=e.documentTop+e.documentPadding.top+e.contentHeight;if(s.left>r||s.right<r||s.top>i||Math.min(s.bottom,a)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function pYe(e,t={}){let n=St.define(),r=uo.define({create(){return[]},update(i,o){if(i.length&&(t.hideOnChange&&(o.docChanged||o.selection)?i=[]:t.hideOn&&(i=i.filter(s=>!t.hideOn(o,s))),o.docChanged)){let s=[];for(let a of i){let l=o.changes.mapPos(a.pos,-1,_o.TrackDel);if(l!=null){let u=Object.assign(Object.create(null),a);u.pos=l,u.end!=null&&(u.end=o.changes.mapPos(u.end)),s.push(u)}}i=s}for(let s of o.effects)s.is(n)&&(i=s.value),s.is(mYe)&&(i=[]);return i},provide:i=>u_.from(i)});return{active:r,extension:[r,Jr.define(i=>new dYe(i,e,r,n,t.hoverTime||300)),cYe]}}function Zse(e,t){let n=e.plugin(X5);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var mYe=St.define(),L7=Te.define({combine(e){let t,n;for(let r of e)t=t||r.topContainer,n=n||r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function J5(e,t){let n=e.plugin(eae),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var eae=Jr.fromClass(class{constructor(e){this.input=e.state.facet(Px),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(L7);this.top=new lN(e,!0,t.topContainer),this.bottom=new lN(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(e){let t=e.state.facet(L7);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new lN(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new lN(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Px);if(n!=this.input){let r=n.filter(l=>l),i=[],o=[],s=[],a=[];for(let l of r){let u=this.specs.indexOf(l),c;u<0?(c=l(e.view),a.push(c)):(c=this.panels[u],c.update&&c.update(e)),i.push(c),(c.top?o:s).push(c)}this.specs=r,this.panels=i,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let r of this.panels)r.update&&r.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>ke.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),lN=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=B7(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=B7(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function B7(e){let t=e.nextSibling;return e.remove(),t}var Px=Te.define({enables:eae});function gYe(e,t){let n,r=new Promise(s=>n=s),i=s=>yYe(s,t,n);e.state.field(HR,!1)?e.dispatch({effects:tae.of(i)}):e.dispatch({effects:St.appendConfig.of(HR.init(()=>[i]))});let o=nae.of(i);return{close:o,result:r.then(s=>((e.win.queueMicrotask||(a=>e.win.setTimeout(a,10)))(()=>{e.state.field(HR).indexOf(i)>-1&&e.dispatch({effects:o})}),s))}}var HR=uo.define({create(){return[]},update(e,t){for(let n of t.effects)n.is(tae)?e=[n.value].concat(e):n.is(nae)&&(e=e.filter(r=>r!=n.value));return e},provide:e=>Px.computeN([e],t=>t.field(e))}),tae=St.define(),nae=St.define();function yYe(e,t,n){let r=t.content?t.content(e,()=>s(null)):null;if(!r){if(r=xn("form"),t.input){let a=xn("input",t.input);/^(text|password|number|email|tel|url)$/.test(a.type)&&a.classList.add("cm-textfield"),a.name||(a.name="input"),r.appendChild(xn("label",(t.label||"")+": ",a))}else r.appendChild(document.createTextNode(t.label||""));r.appendChild(document.createTextNode(" ")),r.appendChild(xn("button",{class:"cm-button",type:"submit"},t.submitLabel||"OK"))}let i=r.nodeName=="FORM"?[r]:r.querySelectorAll("form");for(let a=0;a<i.length;a++){let l=i[a];l.addEventListener("keydown",u=>{u.keyCode==27?(u.preventDefault(),s(null)):u.keyCode==13&&(u.preventDefault(),s(l))}),l.addEventListener("submit",u=>{u.preventDefault(),s(l)})}let o=xn("div",r,xn("button",{onclick:()=>s(null),"aria-label":e.state.phrase("close"),class:"cm-dialog-close",type:"button"},["\xD7"]));t.class&&(o.className=t.class),o.classList.add("cm-dialog");function s(a){o.contains(o.ownerDocument.activeElement)&&e.focus(),n(a)}return{dom:o,top:t.top,mount:()=>{if(t.focus){let a;typeof t.focus=="string"?a=r.querySelector(t.focus):a=r.querySelector("input")||r.querySelector("button"),a&&"select"in a?a.select():a&&"focus"in a&&a.focus()}}}}var Su=class extends Dh{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Su.prototype.elementClass="";Su.prototype.toDOM=void 0;Su.prototype.mapMode=_o.TrackBefore;Su.prototype.startSide=Su.prototype.endSide=-1;Su.prototype.point=!0;var iM=Te.define(),vYe=Te.define(),bYe={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>hn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},Hw=Te.define();function rae(e){return[iae(),Hw.of({...bYe,...e})]}var yB=Te.define({combine:e=>e.some(t=>t)});function iae(e){let t=[wYe];return e&&e.fixed===!1&&t.push(yB.of(!0)),t}var wYe=Jr.fromClass(class{constructor(e){this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(Hw).map(t=>new z7(e,t)),this.fixed=!e.state.facet(yB);for(let t of this.gutters)t.config.side=="after"?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,r=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(e.geometryChanged){let t=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=t,this.domAfter&&(this.domAfter.style.minHeight=t)}this.view.state.facet(yB)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=hn.iter(this.view.state.facet(iM),this.view.viewport.from),r=[],i=this.gutters.map(o=>new xYe(o,this.view.viewport,-this.view.documentPadding.top));for(let o of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(o.type)){let s=!0;for(let a of o.type)if(a.type==Vi.Text&&s){vB(n,r,a.from);for(let l of i)l.line(this.view,a,r);s=!1}else if(a.widget)for(let l of i)l.widget(this.view,a)}else if(o.type==Vi.Text){vB(n,r,o.from);for(let s of i)s.line(this.view,o,r)}else if(o.widget)for(let s of i)s.widget(this.view,o);for(let o of i)o.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(Hw),n=e.state.facet(Hw),r=e.docChanged||e.heightChanged||e.viewportChanged||!hn.eq(e.startState.facet(iM),e.state.facet(iM),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let i of this.gutters)i.update(e)&&(r=!0);else{r=!0;let i=[];for(let o of n){let s=t.indexOf(o);s<0?i.push(new z7(this.view,o)):(this.gutters[s].update(e),i.push(this.gutters[s]))}for(let o of this.gutters)o.dom.remove(),i.indexOf(o)<0&&o.destroy();for(let o of i)o.config.side=="after"?this.getDOMAfter().appendChild(o.dom):this.dom.appendChild(o.dom);this.gutters=i}return r}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:e=>ke.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*t.scaleX,i=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==On.LTR?{left:r,right:i}:{right:r,left:i}})});function q7(e){return Array.isArray(e)?e:[e]}function vB(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}var xYe=class{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=hn.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:r}=this,i=(t.top-this.height)/e.scaleY,o=t.height/e.scaleY;if(this.i==r.elements.length){let s=new oae(e,o,i,n);r.elements.push(s),r.dom.appendChild(s.dom)}else r.elements[this.i].update(e,o,i,n);this.height=t.bottom,this.i++}line(e,t,n){let r=[];vB(this.cursor,r,t.from),n.length&&(r=r.concat(n));let i=this.gutter.config.lineMarker(e,t,r);i&&r.unshift(i);let o=this.gutter;r.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,r)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),r=n?[n]:null;for(let i of e.state.facet(vYe)){let o=i(e,t.widget,t);o&&(r||(r=[])).push(o)}r&&this.addElement(e,t,r)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}},z7=class{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,r=>{let i=r.target,o;if(i!=this.dom&&this.dom.contains(i)){for(;i.parentNode!=this.dom;)i=i.parentNode;let a=i.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=r.clientY;let s=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[n](e,s,r)&&r.preventDefault()});this.markers=q7(t.markers(e)),t.initialSpacer&&(this.spacer=new oae(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=q7(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let r=this.config.updateSpacer(this.spacer.markers[0],e);r!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[r])}let n=e.view.viewport;return!hn.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}},oae=class{constructor(e,t,n,r){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,r)}update(e,t,n,r){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),SYe(this.markers,r)||this.setMarkers(e,r)}setMarkers(e,t){let n="cm-gutterElement",r=this.dom.firstChild;for(let i=0,o=0;;){let s=o,a=i<t.length?t[i++]:null,l=!1;if(a){let u=a.elementClass;u&&(n+=" "+u);for(let c=o;c<this.markers.length;c++)if(this.markers[c].compare(a)){s=c,l=!0;break}}else s=this.markers.length;for(;o<s;){let u=this.markers[o++];if(u.toDOM){u.destroy(r);let c=r.nextSibling;r.remove(),r=c}}if(!a)break;a.toDOM&&(l?r=r.nextSibling:this.dom.insertBefore(a.toDOM(e),r)),l&&o++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}};function SYe(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}var kYe=Te.define(),CYe=Te.define(),Cy=Te.define({combine(e){return kl(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let o=r[i],s=n[i];r[i]=o?(a,l,u)=>o(a,l,u)||s(a,l,u):s}return r}})}}),$R=class extends Su{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}};function KR(e,t){return e.state.facet(Cy).formatNumber(t,e.state)}var NYe=Hw.compute([Cy],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(kYe)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new $R(KR(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(CYe)){let o=i(t,n,r);if(o)return o}return null},lineMarkerChange:t=>t.startState.facet(Cy)!=t.state.facet(Cy),initialSpacer(t){return new $R(KR(t,F7(t.state.doc.lines)))},updateSpacer(t,n){let r=KR(n.view,F7(n.view.state.doc.lines));return r==t.number?t:new $R(r)},domEventHandlers:e.facet(Cy).domEventHandlers,side:"before"}));function MYe(e={}){return[Cy.of(e),iae(),NYe]}function F7(e){let t=9;for(;t<e;)t=t*10+9;return t}var _Ye=new class extends Su{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},EYe=iM.compute(["selection"],e=>{let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.head).from;i>n&&(n=i,t.push(_Ye.range(i)))}return hn.of(t)});function OYe(){return EYe}var TYe=0,mc=class bB{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=TYe++}toString(){let{name:t}=this;for(let n of this.modified)n.name&&(t=`${n.name}(${t})`);return t}static define(t,n){let r=typeof t=="string"?t:"?";if(t instanceof bB&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new bB(r,[],null,[]);if(i.set.push(i),n)for(let o of n.set)i.set.push(o);return i}static defineModifier(t){let n=new j7(t);return r=>r.modified.indexOf(n)>-1?r:j7.get(r.base||r,r.modified.concat(n).sort((i,o)=>i.id-o.id))}},AYe=0,j7=class sae{constructor(t){this.name=t,this.instances=[],this.id=AYe++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(a=>a.base==t&&DYe(n,a.modified));if(r)return r;let i=[],o=new mc(t.name,i,t,n);for(let a of n)a.instances.push(o);let s=RYe(n);for(let a of t.set)if(!a.modified.length)for(let l of s)i.push(sae.get(a,l));return o}};function DYe(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function RYe(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((n,r)=>r.length-n.length)}function aae(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let o=[],s=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let f=i[d++];if(d==i.length&&f=="!"){s=0;break}if(f!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=o.length-1,u=o[l];if(!u)throw new RangeError("Invalid path: "+i);let c=new Lx(r,s,l>0?o.slice(0,l):null);t[u]=c.sort(t[u])}}return lae.add(t)}var lae=new Pt({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth>=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let o=new Lx(i.tags,i.mode,i.context);n?n.next=o:r=o,n=o}return r}}),Lx=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Lx.empty=new Lx([],2,null);function uae(e,t){let n=Object.create(null);for(let o of e)if(!Array.isArray(o.tag))n[o.tag.id]=o.class;else for(let s of o.tag)n[s.id]=o.class;let{scope:r,all:i=null}=t||{};return{style:o=>{let s=i;for(let a of o)for(let l of a.set){let u=n[l.id];if(u){s=s?s+" "+u:u;break}}return s},scope:r}}function IYe(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function PYe(e,t,n,r=0,i=e.length){let o=new LYe(r,Array.isArray(t)?t:[t],n);o.highlightRange(e.cursor(),r,i,"",o.highlighters),o.flush(i)}var LYe=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:o,from:s,to:a}=e;if(s>=n||a<=t)return;o.isTop&&(i=this.highlighters.filter(h=>!h.scope||h.scope(o)));let l=r,u=BYe(e)||Lx.empty,c=IYe(i,u.tags);if(c&&(l&&(l+=" "),l+=c,u.mode==1&&(r+=(r?" ":"")+c)),this.startSpan(Math.max(t,s),l),u.opaque)return;let d=e.tree&&e.tree.prop(Pt.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+s,1),f=this.highlighters.filter(m=>!m.scope||m.scope(d.tree.type)),p=e.firstChild();for(let m=0,g=s;;m++){let y=m<d.overlay.length?d.overlay[m]:null,v=y?y.from+s:a,b=Math.max(t,g),w=Math.min(n,v);if(b<w&&p)for(;e.from<w&&(this.highlightRange(e,b,w,r,i),this.startSpan(Math.min(w,e.to),l),!(e.to>=v||!e.nextSibling())););if(!y||v>n)break;g=y.to+s,g>t&&(this.highlightRange(h.cursor(),Math.max(t,y.from+s),Math.min(n,g),"",f),this.startSpan(Math.min(n,g),l))}p&&e.parent()}else if(e.firstChild()){d&&(r="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),l)}while(e.nextSibling());e.parent()}}};function BYe(e){let t=e.type.prop(lae);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var we=mc.define,uN=we(),th=we(),V7=we(th),W7=we(th),nh=we(),cN=we(nh),YR=we(nh),Xl=we(),lp=we(Xl),Yl=we(),Ql=we(),wB=we(),$b=we(wB),dN=we(),ee={comment:uN,lineComment:we(uN),blockComment:we(uN),docComment:we(uN),name:th,variableName:we(th),typeName:V7,tagName:we(V7),propertyName:W7,attributeName:we(W7),className:we(th),labelName:we(th),namespace:we(th),macroName:we(th),literal:nh,string:cN,docString:we(cN),character:we(cN),attributeValue:we(cN),number:YR,integer:we(YR),float:we(YR),bool:we(nh),regexp:we(nh),escape:we(nh),color:we(nh),url:we(nh),keyword:Yl,self:we(Yl),null:we(Yl),atom:we(Yl),unit:we(Yl),modifier:we(Yl),operatorKeyword:we(Yl),controlKeyword:we(Yl),definitionKeyword:we(Yl),moduleKeyword:we(Yl),operator:Ql,derefOperator:we(Ql),arithmeticOperator:we(Ql),logicOperator:we(Ql),bitwiseOperator:we(Ql),compareOperator:we(Ql),updateOperator:we(Ql),definitionOperator:we(Ql),typeOperator:we(Ql),controlOperator:we(Ql),punctuation:wB,separator:we(wB),bracket:$b,angleBracket:we($b),squareBracket:we($b),paren:we($b),brace:we($b),content:Xl,heading:lp,heading1:we(lp),heading2:we(lp),heading3:we(lp),heading4:we(lp),heading5:we(lp),heading6:we(lp),contentSeparator:we(Xl),list:we(Xl),quote:we(Xl),emphasis:we(Xl),strong:we(Xl),link:we(Xl),monospace:we(Xl),strikethrough:we(Xl),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:dN,documentMeta:we(dN),annotation:we(dN),processingInstruction:we(dN),definition:mc.defineModifier("definition"),constant:mc.defineModifier("constant"),function:mc.defineModifier("function"),standard:mc.defineModifier("standard"),local:mc.defineModifier("local"),special:mc.defineModifier("special")};for(let e in ee){let t=ee[e];t instanceof mc&&(t.name=e)}var Yyt=uae([{tag:ee.link,class:"tok-link"},{tag:ee.heading,class:"tok-heading"},{tag:ee.emphasis,class:"tok-emphasis"},{tag:ee.strong,class:"tok-strong"},{tag:ee.keyword,class:"tok-keyword"},{tag:ee.atom,class:"tok-atom"},{tag:ee.bool,class:"tok-bool"},{tag:ee.url,class:"tok-url"},{tag:ee.labelName,class:"tok-labelName"},{tag:ee.inserted,class:"tok-inserted"},{tag:ee.deleted,class:"tok-deleted"},{tag:ee.literal,class:"tok-literal"},{tag:ee.string,class:"tok-string"},{tag:ee.number,class:"tok-number"},{tag:[ee.regexp,ee.escape,ee.special(ee.string)],class:"tok-string2"},{tag:ee.variableName,class:"tok-variableName"},{tag:ee.local(ee.variableName),class:"tok-variableName tok-local"},{tag:ee.definition(ee.variableName),class:"tok-variableName tok-definition"},{tag:ee.special(ee.variableName),class:"tok-variableName2"},{tag:ee.definition(ee.propertyName),class:"tok-propertyName tok-definition"},{tag:ee.typeName,class:"tok-typeName"},{tag:ee.namespace,class:"tok-namespace"},{tag:ee.className,class:"tok-className"},{tag:ee.macroName,class:"tok-macroName"},{tag:ee.propertyName,class:"tok-propertyName"},{tag:ee.operator,class:"tok-operator"},{tag:ee.comment,class:"tok-comment"},{tag:ee.meta,class:"tok-meta"},{tag:ee.invalid,class:"tok-invalid"},{tag:ee.punctuation,class:"tok-punctuation"}]),QR,Ny=new Pt;function qYe(e){return Te.define({combine:e?t=>t.concat(e):void 0})}var zYe=new Pt,al=class{constructor(e,t,n=[],r=""){this.data=e,this.name=r,or.prototype.hasOwnProperty("tree")||Object.defineProperty(or.prototype,"tree",{get(){return Ei(this)}}),this.parser=t,this.extension=[Lh.of(this),or.languageData.of((i,o,s)=>{let a=U7(i,o,s),l=a.type.prop(Ny);if(!l)return[];let u=i.facet(l),c=a.type.prop(zYe);if(c){let d=a.resolve(o-a.from,s);for(let h of c)if(h.test(d,i)){let f=i.facet(h.facet);return h.type=="replace"?f:f.concat(u)}}return u})].concat(n)}isActiveAt(e,t,n=-1){return U7(e,t,n).type.prop(Ny)==this.data}findRegions(e){let t=e.facet(Lh);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(i,o)=>{if(i.prop(Ny)==this.data){n.push({from:o,to:o+i.length});return}let s=i.prop(Pt.mounted);if(s){if(s.tree.prop(Ny)==this.data){if(s.overlay)for(let a of s.overlay)n.push({from:a.from+o,to:a.to+o});else n.push({from:o,to:o+i.length});return}else if(s.overlay){let a=n.length;if(r(s.tree,s.overlay[0].from+o),n.length>a)return}}for(let a=0;a<i.children.length;a++){let l=i.children[a];l instanceof Ni&&r(l,i.positions[a]+o)}};return r(Ei(e),0),n}get allowsNesting(){return!0}};al.setState=St.define();function U7(e,t,n){let r=e.facet(Lh),i=Ei(e).topNode;if(!r||r.allowsNesting)for(let o=i;o;o=o.enter(t,n,kr.ExcludeBuffers|kr.EnterBracketed))o.type.isTop&&(i=o);return i}var FYe=class xB extends al{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=qYe(t.languageData);return new xB(n,t.parser.configure({props:[Ny.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new xB(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function Ei(e){let t=e.field(al.state,!1);return t?t.tree:Ni.empty}var jYe=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},Kb=null,VYe=class SB{constructor(t,n,r=[],i,o,s,a,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new SB(t,n,[],Ni.empty,0,r,[],null)}startParse(){return this.parser.startParse(new jYe(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Ni.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof t=="number"){let i=Date.now()+t;t=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n<this.state.doc.length&&this.parse.stopAt(n);;){let i=this.parse.advance();if(i)if(this.fragments=this.withoutTempSkipped(QN.addTree(i,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(r=this.parse.stoppedAt)!==null&&r!==void 0?r:this.state.doc.length,this.tree=i,this.parse=null,this.treeLen<(n??this.state.doc.length))this.parse=this.startParse();else return!0;if(t())return!1}})}takeTree(){let t,n;this.parse&&(t=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&this.parse.stopAt(t),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=t,this.tree=n,this.fragments=this.withoutTempSkipped(QN.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Kb;Kb=this;try{return t()}finally{Kb=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=H7(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!t.empty){let l=[];if(t.iterChangedRanges((u,c,d,h)=>l.push({fromA:u,toA:c,fromB:d,toB:h})),r=QN.applyChanges(r,l),i=Ni.empty,o=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){a=[];for(let u of this.skipped){let c=t.mapPos(u.from,1),d=t.mapPos(u.to,-1);c<d&&a.push({from:c,to:d})}}}return new SB(this.parser,n,r,i,o,s,a,this.scheduleOn)}updateViewport(t){if(this.viewport.from==t.from&&this.viewport.to==t.to)return!1;this.viewport=t;let n=this.skipped.length;for(let r=0;r<this.skipped.length;r++){let{from:i,to:o}=this.skipped[r];i<t.to&&o>t.from&&(this.fragments=H7(this.fragments,i,o),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(t,n){this.skipped.push({from:t,to:n})}static getSkippingParser(t){return new class extends loe{createParse(n,r,i){let o=i[0].from,s=i[i.length-1].to;return{parsedPos:o,advance(){let a=Kb;if(a){for(let l of i)a.tempSkipped.push(l);t&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,t]):t)}return this.parsedPos=s,new Ni(Ta.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(t){t=Math.min(t,this.state.doc.length);let n=this.fragments;return this.treeLen>=t&&n.length&&n[0].from==0&&n[0].to>=t}static get(){return Kb}};function H7(e,t,n){return QN.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var kB=class CB{constructor(t){this.context=t,this.tree=t.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new CB(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=VYe.create(t.facet(Lh).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new CB(r)}};al.state=uo.define({create:kB.init,update(e,t){for(let n of t.effects)if(n.is(al.setState))return n.value;return t.startState.facet(Lh)!=t.state.facet(Lh)?kB.init(t.state):e.apply(t)}});var cae=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(cae=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var GR=typeof navigator<"u"&&!((QR=navigator.scheduling)===null||QR===void 0)&&QR.isInputPending?()=>navigator.scheduling.isInputPending():null,WYe=Jr.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(al.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(al.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=cae(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(al.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,e&&!GR?Math.max(25,e.timeRemaining()-5):1e9),s=i.context.treeLen<r&&n.doc.length>r+1e3,a=i.context.work(()=>GR&&GR()||Date.now()>o,r+(s?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:al.setState.of(new kB(i.context))})),this.chunkBudget>0&&!(a&&!s)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Ao(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Lh=Te.define({combine(e){return e.length?e[0]:null},enables:e=>[al.state,WYe,ke.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),UYe=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},HYe=Te.define(),VE=Te.define({combine:e=>{if(!e.length)return" ";let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(n=>n!=t[0]))throw new Error("Invalid indent unit: "+JSON.stringify(e[0]));return t}});function c_(e){let t=e.facet(VE);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Bx(e,t){let n="",r=e.tabSize,i=e.facet(VE)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let o=0;o<t;o++)n+=i;return n}function Z5(e,t){e instanceof or&&(e=new WE(e));for(let r of e.state.facet(HYe)){let i=r(e,t);if(i!==void 0)return i}let n=Ei(e.state);return n.length>=t?$Ye(e,n,t):null}var WE=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=c_(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),o=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return o>-1&&(i+=o-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Iv(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let o=i(r);if(o>-1)return o}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},dae=new Pt;function $Ye(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let o=[];for(let s=i;s&&!(s.from<r.node.from||s.to>r.node.to||s.from==r.node.from&&s.type==r.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)r={node:o[s],next:r}}return hae(r,e,n)}function hae(e,t,n){for(let r=e;r;r=r.next){let i=YYe(r.node);if(i)return i(GYe.create(t,n,r))}return 0}function KYe(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function YYe(e){let t=e.type.prop(dae);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Pt.closedBy))){let i=e.lastChild,o=i&&r.indexOf(i.name)>-1;return s=>ZYe(s,!0,1,void 0,o&&!KYe(s)?i.from:void 0)}return e.parent==null?QYe:null}function QYe(){return 0}var GYe=class fae extends WE{constructor(t,n,r){super(t.state,t.options),this.base=t,this.pos=n,this.context=r}get node(){return this.context.node}static create(t,n,r){return new fae(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(t){let n=this.state.doc.lineAt(t.from);for(;;){let r=t.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(XYe(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return hae(this.context.next,this.base,this.pos)}};function XYe(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function JYe(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,o=e.state.doc.lineAt(n.from),s=i==null||i<=o.from?o.to:Math.min(o.to,i);for(let a=n.to;;){let l=t.childAfter(a);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let u=/^ */.exec(o.text.slice(n.to-o.from))[0].length;return{from:n.from,to:n.to+u}}a=l.to}}function ZYe(e,t,n,r,i){let o=e.textAfter,s=o.match(/^\s*/)[0].length,a=r&&o.slice(s,s+r.length)==r||i==e.pos+s,l=t?JYe(e):null;return l?a?e.column(l.from):e.column(l.to):e.baseIndent+(a?0:e.unit*n)}function eQe({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var tQe=200;function nQe(){return or.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:r}=e.newSelection.main,i=n.lineAt(r);if(r>i.from+tQe)return e;let o=n.sliceString(i.from,r);if(!t.some(u=>u.test(o)))return e;let{state:s}=e,a=-1,l=[];for(let{head:u}of s.selection.ranges){let c=s.doc.lineAt(u);if(c.from==a)continue;a=c.from;let d=Z5(s,c.from);if(d==null)continue;let h=/^\s*/.exec(c.text)[0],f=Bx(s,d);h!=f&&l.push({from:c.from,to:c.from+h.length,insert:f})}return l.length?[e,{changes:l,sequential:!0}]:e})}var rQe=Te.define(),pae=new Pt;function iQe(e,t,n){let r=Ei(e);if(r.length<n)return null;let i=r.resolveStack(n,1),o=null;for(let s=i;s;s=s.next){let a=s.node;if(a.to<=n||a.from>n)continue;if(o&&a.from<t)break;let l=a.type.prop(pae);if(l&&(a.to<r.length-50||r.length==e.doc.length||!oQe(a))){let u=l(a,e);u&&u.from<=n&&u.from>=t&&u.to>n&&(o=u)}}return o}function oQe(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function d_(e,t,n){for(let r of e.facet(rQe)){let i=r(e,t,n);if(i)return i}return iQe(e,t,n)}function mae(e,t){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);return n>=r?void 0:{from:n,to:r}}var UE=St.define({map:mae}),x1=St.define({map:mae});function gae(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(r=>r.from<=n&&r.to>=n)||t.push(e.lineBlockAt(n));return t}var lm=uo.define({create(){return Qe.none},update(e,t){t.isUserEvent("delete")&&t.changes.iterChangedRanges((n,r)=>e=$7(e,n,r)),e=e.map(t.changes);for(let n of t.effects)if(n.is(UE)&&!sQe(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(e3),i=r?Qe.replace({widget:new fQe(r(t.state,n.value))}):K7;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(x1)&&(e=e.update({filter:(r,i)=>n.value.from!=r||n.value.to!=i,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=$7(e,t.selection.main.head)),e},provide:e=>ke.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(r,i)=>{n.push(r,i)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw new RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let r=e[n++],i=e[n++];if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid JSON for fold state");t.push(K7.range(r,i))}return Qe.set(t,!0)}});function $7(e,t,n=t){let r=!1;return e.between(t,n,(i,o)=>{i<n&&o>t&&(r=!0)}),r?e.update({filterFrom:t,filterTo:n,filter:(i,o)=>i>=n||o<=t}):e}function h_(e,t,n){var r;let i=null;return(r=e.field(lm,!1))===null||r===void 0||r.between(t,n,(o,s)=>{(!i||i.from>o)&&(i={from:o,to:s})}),i}function sQe(e,t,n){let r=!1;return e.between(t,t,(i,o)=>{i==t&&o==n&&(r=!0)}),r}function yae(e,t){return e.field(lm,!1)?t:t.concat(St.appendConfig.of(bae()))}var aQe=e=>{for(let t of gae(e)){let n=d_(e.state,t.from,t.to);if(n)return e.dispatch({effects:yae(e.state,[UE.of(n),vae(e,n)])}),!0}return!1},lQe=e=>{if(!e.state.field(lm,!1))return!1;let t=[];for(let n of gae(e)){let r=h_(e.state,n.from,n.to);r&&t.push(x1.of(r),vae(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function vae(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return ke.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}var uQe=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),o=d_(t,i.from,i.to);o&&n.push(UE.of(o)),r=(o?e.lineBlockAt(o.to):i).to+1}return n.length&&e.dispatch({effects:yae(e.state,n)}),!!n.length},cQe=e=>{let t=e.state.field(lm,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(x1.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},dQe=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:aQe},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:lQe},{key:"Ctrl-Alt-[",run:uQe},{key:"Ctrl-Alt-]",run:cQe}],hQe={placeholderDOM:null,preparePlaceholder:null,placeholderText:"\u2026"},e3=Te.define({combine(e){return kl(e,hQe)}});function bae(e){let t=[lm,gQe];return e&&t.push(e3.of(e)),t}function wae(e,t){let{state:n}=e,r=n.facet(e3),i=s=>{let a=e.lineBlockAt(e.posAtDOM(s.target)),l=h_(e.state,a.from,a.to);l&&e.dispatch({effects:x1.of(l)}),s.preventDefault()};if(r.placeholderDOM)return r.placeholderDOM(e,i,t);let o=document.createElement("span");return o.textContent=r.placeholderText,o.setAttribute("aria-label",n.phrase("folded code")),o.title=n.phrase("unfold"),o.className="cm-foldPlaceholder",o.onclick=i,o}var K7=Qe.replace({widget:new class extends Tu{toDOM(e){return wae(e,null)}}}),fQe=class extends Tu{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return wae(e,this.value)}},pQe={openText:"\u2304",closedText:"\u203A",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1},XR=class extends Su{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}};function mQe(e={}){let t={...pQe,...e},n=new XR(t,!0),r=new XR(t,!1),i=Jr.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(Lh)!=s.state.facet(Lh)||s.startState.field(lm,!1)!=s.state.field(lm,!1)||Ei(s.startState)!=Ei(s.state)||t.foldingChanged(s))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let a=new sm;for(let l of s.viewportLineBlocks){let u=h_(s.state,l.from,l.to)?r:d_(s.state,l.from,l.to)?n:null;u&&a.add(l.from,l.from,u)}return a.finish()}}),{domEventHandlers:o}=t;return[i,rae({class:"cm-foldGutter",markers(s){var a;return((a=s.plugin(i))===null||a===void 0?void 0:a.markers)||hn.empty},initialSpacer(){return new XR(t,!1)},domEventHandlers:{...o,click:(s,a,l)=>{if(o.click&&o.click(s,a,l))return!0;let u=h_(s.state,a.from,a.to);if(u)return s.dispatch({effects:x1.of(u)}),!0;let c=d_(s.state,a.from,a.to);return c?(s.dispatch({effects:UE.of(c)}),!0):!1}}}),bae()]}var gQe=ke.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}}),t3=class xae{constructor(t,n){this.specs=t;let r;function i(a){let l=Rh.newName();return(r||(r=Object.create(null)))["."+l]=a,l}let o=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,s=n.scope;this.scope=s instanceof al?a=>a.prop(Ny)==s.data:s?a=>a==s:void 0,this.style=uae(t.map(a=>({tag:a.tag,class:a.class||i(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=r?new Rh(r):null,this.themeType=n.themeType}static define(t,n){return new xae(t,n||{})}},NB=Te.define(),Sae=Te.define({combine(e){return e.length?[e[0]]:null}});function JR(e){let t=e.facet(NB);return t.length?t:e.facet(Sae)}function kae(e,t){let n=[vQe],r;return e instanceof t3&&(e.module&&n.push(ke.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Sae.of(e)):r?n.push(NB.computeN([ke.darkTheme],i=>i.facet(ke.darkTheme)==(r=="dark")?[e]:[])):n.push(NB.of(e)),n}var yQe=class{constructor(e){this.markCache=Object.create(null),this.tree=Ei(e.state),this.decorations=this.buildDeco(e,JR(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=Ei(e.state),n=JR(e.state),r=n!=JR(e.startState),{viewport:i}=e.view,o=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&o>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return Qe.none;let n=new sm;for(let{from:r,to:i}of e.visibleRanges)PYe(this.tree,t,(o,s,a)=>{n.add(o,s,this.markCache[a]||(this.markCache[a]=Qe.mark({class:a})))},r,i);return n.finish()}},vQe=Xh.high(Jr.fromClass(yQe,{decorations:e=>e.decorations})),bQe=t3.define([{tag:ee.meta,color:"#404740"},{tag:ee.link,textDecoration:"underline"},{tag:ee.heading,textDecoration:"underline",fontWeight:"bold"},{tag:ee.emphasis,fontStyle:"italic"},{tag:ee.strong,fontWeight:"bold"},{tag:ee.strikethrough,textDecoration:"line-through"},{tag:ee.keyword,color:"#708"},{tag:[ee.atom,ee.bool,ee.url,ee.contentSeparator,ee.labelName],color:"#219"},{tag:[ee.literal,ee.inserted],color:"#164"},{tag:[ee.string,ee.deleted],color:"#a11"},{tag:[ee.regexp,ee.escape,ee.special(ee.string)],color:"#e40"},{tag:ee.definition(ee.variableName),color:"#00f"},{tag:ee.local(ee.variableName),color:"#30a"},{tag:[ee.typeName,ee.namespace],color:"#085"},{tag:ee.className,color:"#167"},{tag:[ee.special(ee.variableName),ee.macroName],color:"#256"},{tag:ee.definition(ee.propertyName),color:"#00c"},{tag:ee.comment,color:"#940"},{tag:ee.invalid,color:"#f00"}]),wQe=ke.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Cae=1e4,Nae="()[]{}",Mae=Te.define({combine(e){return kl(e,{afterCursor:!0,brackets:Nae,maxScanDistance:Cae,renderMatch:kQe})}}),xQe=Qe.mark({class:"cm-matchingBracket"}),SQe=Qe.mark({class:"cm-nonmatchingBracket"});function kQe(e){let t=[],n=e.matched?xQe:SQe;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}function Y7(e){let t=[],n=e.facet(Mae);for(let r of e.selection.ranges){if(!r.empty)continue;let i=cu(e,r.head,-1,n)||r.head>0&&cu(e,r.head-1,1,n)||n.afterCursor&&(cu(e,r.head,1,n)||r.head<e.doc.length&&cu(e,r.head+1,-1,n));i&&(t=t.concat(n.renderMatch(i,e)))}return Qe.set(t,!0)}var CQe=Jr.fromClass(class{constructor(e){this.paused=!1,this.decorations=Y7(e.state)}update(e){(e.docChanged||e.selectionSet||this.paused)&&(e.view.composing?(this.decorations=this.decorations.map(e.changes),this.paused=!0):(this.decorations=Y7(e.state),this.paused=!1))}},{decorations:e=>e.decorations}),NQe=[CQe,wQe];function MQe(e={}){return[Mae.of(e),NQe]}var _Qe=new Pt;function MB(e,t,n){let r=e.prop(t<0?Pt.openedBy:Pt.closedBy);if(r)return r;if(e.name.length==1){let i=n.indexOf(e.name);if(i>-1&&i%2==(t<0?1:0))return[n[i+t]]}return null}function _B(e){let t=e.type.prop(_Qe);return t?t(e.node):e}function cu(e,t,n,r={}){let i=r.maxScanDistance||Cae,o=r.brackets||Nae,s=Ei(e),a=s.resolveInner(t,n);for(let l=a;l;l=l.parent){let u=MB(l.type,n,o);if(u&&l.from<l.to){let c=_B(l);if(c&&(n>0?t>=c.from&&t<c.to:t>c.from&&t<=c.to))return EQe(e,t,n,l,c,u,o)}}return OQe(e,t,n,s,a.type,i,o)}function EQe(e,t,n,r,i,o,s){let a=r.parent,l={from:i.from,to:i.to},u=0,c=a?.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&o.indexOf(c.type.name)>-1&&c.from<c.to){let d=_B(c);return{start:l,end:d?{from:d.from,to:d.to}:void 0,matched:!0}}else if(MB(c.type,n,s))u++;else if(MB(c.type,-n,s)){if(u==0){let d=_B(c);return{start:l,end:d&&d.from<d.to?{from:d.from,to:d.to}:void 0,matched:!1}}u--}}while(n<0?c.prevSibling():c.nextSibling());return{start:l,matched:!1}}function OQe(e,t,n,r,i,o,s){let a=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(a);if(l<0||l%2==0!=n>0)return null;let u={from:n<0?t-1:t,to:n>0?t+1:t},c=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let h=0;!c.next().done&&h<=o;){let f=c.value;n<0&&(h+=f.length);let p=t+h*n;for(let m=n>0?0:f.length-1,g=n>0?f.length:-1;m!=g;m+=n){let y=s.indexOf(f[m]);if(!(y<0||r.resolveInner(p+m,1).type!=i))if(y%2==0==n>0)d++;else{if(d==1)return{start:u,end:{from:p+m,to:p+m+1},matched:y>>1==l>>1};d--}}n>0&&(h+=f.length)}return c.done?{start:u,matched:!1}:null}var TQe=Object.create(null),Q7=[Ta.none],G7=[],X7=Object.create(null),AQe=Object.create(null);for(let[e,t]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])AQe[e]=DQe(TQe,t);function ZR(e,t){G7.indexOf(e)>-1||(G7.push(e),console.warn(t))}function DQe(e,t){let n=[];for(let a of t.split(" ")){let l=[];for(let u of a.split(".")){let c=e[u]||ee[u];c?typeof c=="function"?l.length?l=l.map(c):ZR(u,`Modifier ${u} used at start of tag`):l.length?ZR(u,`Tag ${u} used as modifier`):l=Array.isArray(c)?c:[c]:ZR(u,`Unknown highlighting tag ${u}`)}for(let u of l)n.push(u)}if(!n.length)return 0;let r=t.replace(/ /g,"_"),i=r+" "+n.map(a=>a.id),o=X7[i];if(o)return o.id;let s=X7[i]=Ta.define({id:Q7.length,name:r,props:[aae({[r]:n})]});return Q7.push(s),s.id}var Qyt={rtl:Qe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:On.RTL}),ltr:Qe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:On.LTR}),auto:Qe.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})},RQe=class EB{constructor(t,n,r,i,o,s,a,l,u,c=0,d){this.p=t,this.stack=n,this.state=r,this.reducePos=i,this.pos=o,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=u,this.lookAhead=c,this.parent=d}toString(){return`[${this.stack.filter((t,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(t,n,r=0){let i=t.parser.context;return new EB(t,[],n,r,r,0,[],0,i?new J7(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(t,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=t}reduce(t){var n;let r=t>>19,i=t&65535,{parser:o}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=o.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(o.getGoto(this.state,i,!0),this.reducePos),i<o.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(t&262144?6:0),u=l?this.stack[l-2]:this.p.ranges[0].from,c=this.reducePos-u;c>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSize<c&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=u,this.p.lastBigReductionSize=c));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(i<o.minRepeatTerm||t&131072){let f=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,u,f,h+4,!0)}if(t&262144)this.state=this.stack[l];else{let f=this.stack[l-3];this.state=o.getGoto(f,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,u)}storeNode(t,n,r,i=4,o=!1){if(t==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==r)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=r;return}}}if(!o||this.pos==r)this.buffer.push(t,n,r,i);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,i>4&&(i-=4)}this.buffer[s]=t,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=i}}shift(t,n,r,i){if(t&131072)this.pushState(t&65535,this.pos);else if((t&262144)==0){let o=t,{parser:s}=this.p;this.pos=i;let a=s.stateFlag(o,1);!a&&(i>r||n<=s.maxNode)&&(this.reducePos=i),this.pushState(o,a?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,i,4)}else this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4)}apply(t,n,r,i){t&65536?this.reduce(t):this.shift(t,n,r,i)}useNode(t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=t)&&(this.p.reused.push(t),r++);let i=this.pos;this.reducePos=this.pos=i+t.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,t,this,this.p.stream.reset(this.pos-t.length)))}split(){let t=this,n=t.buffer.length;for(;n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new EB(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(t,n){let r=t<=this.p.parser.maxNode;r&&this.storeNode(t,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(t){for(let n=new IQe(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,t);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(t){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let o=0,s;o<n.length;o+=2)(s=n[o+1])!=this.state&&this.p.parser.hasAction(s,t)&&i.push(n[o],s);if(this.stack.length<120)for(let o=0;i.length<8&&o<n.length;o+=2){let s=n[o+1];i.some((a,l)=>l&1&&a==s)||i.push(n[o],s)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let o=n[i+1];if(o==this.state)continue;let s=this.split();s.pushState(o,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[i],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:t}=this.p,n=t.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!t.validAction(this.state,n)){let r=n>>19,i=n&65535,o=this.stack.length-r*3;if(o<0||t.getGoto(this.stack[o],i,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:t}=this.p,n=[],r=(i,o)=>{if(!n.includes(i))return n.push(i),t.allActions(i,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-o;if(a>1){let l=s&65535,u=this.stack.length-a*3;if(u>=0&&t.getGoto(this.stack[u],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,o+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:t}=this.p;return t.data[t.stateSlot(this.state,1)]==65535&&!t.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(t){if(this.state!=t.state||this.stack.length!=t.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=t.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(t){return this.p.parser.dialect.flags[t]}shiftContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,t,this,this.p.stream.reset(n)))}reduceContext(t,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,t,this,this.p.stream.reset(n)))}emitContext(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let t=this.buffer.length-1;(t<0||this.buffer[t]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(t){if(t!=this.curContext.context){let n=new J7(this.curContext.tracker,t);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(t){return t<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=t,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},J7=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},IQe=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},PQe=class OB{constructor(t,n,r){this.stack=t,this.pos=n,this.index=r,this.buffer=t.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new OB(t,n,n-t.bufferBase)}maybeNext(){let t=this.stack.parent;t!=null&&(this.index=this.stack.bufferBase-t.bufferBase,this.stack=t,this.buffer=t.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new OB(this.stack,this.pos,this.index)}};function vw(e,t=Uint16Array){if(typeof e!="string")return e;let n=null;for(let r=0,i=0;r<e.length;){let o=0;for(;;){let s=e.charCodeAt(r++),a=!1;if(s==126){o=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}n?n[i++]=o:n=new t(o)}return n}var oM=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},Z7=new oM,LQe=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=Z7,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;i<n.from;){if(!r)return null;let o=this.ranges[--r];i-=n.from-o.to,n=o}for(;t<0?i>n.to:i>=n.to;){if(r==this.ranges.length-1)return null;let o=this.ranges[++r];i+=o.from-n.to,n=o}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t<this.chunk.length)n=this.pos+e,r=this.chunk.charCodeAt(t);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(n=i,n>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let o=this.rangeIndex,s=this.range;for(;s.to<=n;)s=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>s.to&&(this.chunk2=this.chunk2.slice(0,s.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=Z7,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},zy=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;_ae(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};zy.prototype.contextual=zy.prototype.fallback=zy.prototype.extend=!1;var BQe=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e=="string"?vw(e):e}token(e,t){let n=e.pos,r=0;for(;;){let i=e.next<0,o=e.resolveOffset(1,1);if(_ae(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(i||r++,o==null)break;e.reset(o,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};BQe.prototype.contextual=zy.prototype.fallback=zy.prototype.extend=!1;var qQe=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function _ae(e,t,n,r,i,o){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&e[s])!=0;){let u=e[s+1];for(let f=s+3;f<u;f+=2)if((e[f+1]&a)>0){let p=e[f];if(l.allows(p)&&(t.token.value==-1||t.token.value==p||zQe(p,t.token.value,i,o))){t.acceptToken(p);break}}let c=t.next,d=0,h=e[s+2];if(t.next<0&&h>d&&e[u+h*3-3]==65535){s=e[u+h*3-1];continue e}for(;d<h;){let f=d+h>>1,p=u+f+(f<<1),m=e[p],g=e[p+1]||65536;if(c<m)h=f;else if(c>=g)d=f+1;else{s=e[p+2],t.advance();continue e}}break}}function eY(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function zQe(e,t,n,r){let i=eY(n,r,t);return i<0||eY(n,r,e)<i}var Cs=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG),eI=null;function tY(e,t,n){let r=e.cursor(kr.IncludeAnonymous);for(r.moveTo(t);;)if(!(n<0?r.childBefore(t):r.childAfter(t)))for(;;){if((n<0?r.to<t:r.from>t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var FQe=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?tY(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?tY(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],r=this.index[t];if(r==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=n.children[r],o=this.start[t]+n.positions[r];if(o>e)return this.nextStart=o,null;if(i instanceof Ni){if(o==e){if(o<this.safeFrom)return null;let s=o+i.length;if(s<=this.safeTo){let a=i.prop(Pt.lookAhead);if(!a||s+a<this.fragment.to)return i}}this.index[t]++,o+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+i.length}}},jQe=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new oM)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,o=r.stateSlot(e.state,3),s=e.curContext?e.curContext.hash:0,a=0;for(let l=0;l<i.length;l++){if((1<<l&o)==0)continue;let u=i[l],c=this.tokens[l];if(!(n&&!u.fallback)&&((u.contextual||c.start!=e.pos||c.mask!=o||c.context!=s)&&(this.updateCachedToken(c,u,e),c.mask=o,c.context=s),c.lookAhead>c.end+25&&(a=Math.max(c.lookAhead,a)),c.value!=0)){let d=t;if(c.extended>-1&&(t=this.addActions(e,c.extended,c.end,t)),t=this.addActions(e,c.value,c.end,t),!u.extend&&(n=c,t>d))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!n&&e.pos==this.stream.end&&(n=new oM,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new oM,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:i}=n.p;for(let o=0;o<i.specialized.length;o++)if(i.specialized[o]==e.value){let s=i.specializers[o](this.stream.read(e.start,e.end),n);if(s>=0&&n.p.parser.dialect.allows(s>>1)){(s&1)==0?e.value=s>>1:e.extended=s>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let i=0;i<r;i+=3)if(this.actions[i]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=n,r}addActions(e,t,n,r){let{state:i}=e,{parser:o}=e.p,{data:s}=o;for(let a=0;a<2;a++)for(let l=o.stateSlot(i,a?2:1);;l+=3){if(s[l]==65535)if(s[l+1]==1)l=gc(s,l+2);else{r==0&&s[l+1]==2&&(r=this.putAction(gc(s,l+2),t,n,r));break}s[l]==t&&(r=this.putAction(gc(s,l+1),t,n,r))}return r}},VQe=class{constructor(e,t,n,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new LQe(t,r),this.tokens=new jQe(e,this.stream),this.topTerm=e.top[1];let{from:i}=r[0];this.stacks=[RQe.start(this,e.top[0],i)],this.fragments=n.length&&this.stream.end-i>e.bufferLength*4?new FQe(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let s=e[o];for(;;){if(this.tokens.mainToken=null,s.pos>t)n.push(s);else{if(this.advanceStack(s,n,e))continue;{r||(r=[],i=[]),r.push(s);let a=this.tokens.getMainToken(s);i.push(a.value,a.end)}}break}}if(!n.length){let o=r&&HQe(r);if(o)return Cs&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Cs&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let o=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(o)return Cs&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(n.length>o)for(n.sort((s,a)=>a.score-s.score);n.length>o;)n.pop();n.some(s=>s.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let o=0;o<n.length-1;o++){let s=n[o];for(let a=o+1;a<n.length;a++){let l=n[a];if(s.sameState(l)||s.buffer.length>500&&l.buffer.length>500)if((s.score-l.score||s.buffer.length-l.buffer.length)>0)n.splice(a--,1);else{n.splice(o--,1);continue e}}}n.length>12&&(n.sort((o,s)=>s.score-o.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let o=1;o<n.length;o++)n[o].pos<this.minStackPos&&(this.minStackPos=n[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,o=Cs?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let l=e.curContext&&e.curContext.tracker.strict,u=l?e.curContext.hash:0;for(let c=this.fragments.nodeAt(r);c;){let d=this.parser.nodeSet.types[c.type.id]==c.type?i.getGoto(e.state,c.type.id):-1;if(d>-1&&c.length&&(!l||(c.prop(Pt.contextHash)||0)==u))return e.useNode(c,d),Cs&&console.log(o+this.stackID(e)+` (via reuse of ${i.getName(c.type.id)})`),!0;if(!(c instanceof Ni)||c.children.length==0||c.positions[0]>0)break;let h=c.children[0];if(h instanceof Ni&&c.positions[0]==0)c=h;else break}}let s=i.stateSlot(e.state,4);if(s>0)return e.reduce(s),Cs&&console.log(o+this.stackID(e)+` (via always-reduce ${i.getName(s&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let l=0;l<a.length;){let u=a[l++],c=a[l++],d=a[l++],h=l==a.length||!n,f=h?e:e.split(),p=this.tokens.mainToken;if(f.apply(u,c,p?p.start:f.pos,d),Cs&&console.log(o+this.stackID(f)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(c)} @ ${r}${f==e?"":", split"})`),h)return!0;f.pos>r?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return nY(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let o=0;o<e.length;o++){let s=e[o],a=t[o<<1],l=t[(o<<1)+1],u=Cs?this.stackID(s)+" -> ":"";if(s.deadEnd&&(i||(i=!0,s.restart(),Cs&&console.log(u+this.stackID(s)+" (restarted)"),this.advanceFully(s,n))))continue;let c=s.split(),d=u;for(let h=0;h<10&&c.forceReduce()&&(Cs&&console.log(d+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,n));h++)Cs&&(d=this.stackID(c)+" -> ");for(let h of s.recoverByInsert(a))Cs&&console.log(u+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,n);this.stream.end>s.pos?(l==s.pos&&(l++,a=0),s.recoverByDelete(a,l),Cs&&console.log(u+this.stackID(s)+` (via recover-delete ${this.parser.getName(a)})`),nY(s,n)):(!r||r.score<c.score)&&(r=c)}return r}stackToTree(e){return e.close(),Ni.build({buffer:PQe.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(eI||(eI=new WeakMap)).get(e);return t||eI.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function nY(e,t){for(let n=0;n<t.length;n++){let r=t[n];if(r.pos==e.pos&&r.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}var WQe=class{constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}allows(e){return!this.disabled||this.disabled[e]==0}},UQe=class TB extends loe{constructor(t){if(super(),this.wrappers=[],t.version!=14)throw new RangeError(`Parser version (${t.version}) doesn't match runtime version (14)`);let n=t.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<t.repeatNodeCount;a++)n.push("");let r=Object.keys(t.topRules).map(a=>t.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function o(a,l,u){i[a].push([l,l.deserialize(String(u))])}if(t.nodeProps)for(let a of t.nodeProps){let l=a[0];typeof l=="string"&&(l=Pt[l]);for(let u=1;u<a.length;){let c=a[u++];if(c>=0)o(c,l,a[u++]);else{let d=a[u+-c];for(let h=-c;h>0;h--)o(a[u++],l,d);u++}}}this.nodeSet=new d9e(n.map((a,l)=>Ta.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:t.skippedNodes&&t.skippedNodes.indexOf(l)>-1}))),t.propSources&&(this.nodeSet=this.nodeSet.extend(...t.propSources)),this.strict=!1,this.bufferLength=1024;let s=vw(t.tokenData);this.context=t.context,this.specializerSpecs=t.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(rY),this.states=vw(t.states,Uint32Array),this.data=vw(t.stateData),this.goto=vw(t.goto),this.maxTerm=t.maxTerm,this.tokenizers=t.tokenizers.map(a=>typeof a=="number"?new zy(s,a):a),this.topRules=t.topRules,this.dialects=t.dialects||{},this.dynamicPrecedences=t.dynamicPrecedences||null,this.tokenPrecTable=t.tokenPrec,this.termNames=t.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(t,n,r){let i=new VQe(this,t,n,r);for(let o of this.wrappers)i=o(i,t,n,r);return i}getGoto(t,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let o=i[n+1];;){let s=i[o++],a=s&1,l=i[o++];if(a&&r)return l;for(let u=o+(s>>1);o<u;o++)if(i[o]==t)return l;if(a)return-1}}hasAction(t,n){let r=this.data;for(let i=0;i<2;i++)for(let o=this.stateSlot(t,i?2:1),s;;o+=3){if((s=r[o])==65535)if(r[o+1]==1)s=r[o=gc(r,o+2)];else{if(r[o+1]==2)return gc(r,o+2);break}if(s==n||s==0)return gc(r,o+1)}return 0}stateSlot(t,n){return this.states[t*6+n]}stateFlag(t,n){return(this.stateSlot(t,0)&n)>0}validAction(t,n){return!!this.allActions(t,r=>r==n?!0:null)}allActions(t,n){let r=this.stateSlot(t,4),i=r?n(r):void 0;for(let o=this.stateSlot(t,1);i==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=gc(this.data,o+2);else break;i=n(gc(this.data,o+1))}return i}nextStates(t){let n=[];for(let r=this.stateSlot(t,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=gc(this.data,r+2);else break;if((this.data[r+2]&1)==0){let i=this.data[r+1];n.some((o,s)=>s&1&&o==i)||n.push(this.data[r],i)}}return n}configure(t){let n=Object.assign(Object.create(TB.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let r=this.topRules[t.top];if(!r)throw new RangeError(`Invalid top rule name ${t.top}`);n.top=r}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=t.tokenizers.find(o=>o.from==r);return i?i.to:r})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let o=t.specializers.find(a=>a.from==r.external);if(!o)return r;let s=Object.assign(Object.assign({},r),{external:o.to});return n.specializers[i]=rY(s),s})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(t){return this.termNames?this.termNames[t]:String(t<=this.maxNode&&this.nodeSet.types[t].name||t)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(t){let n=this.dynamicPrecedences;return n==null?0:n[t]||0}parseDialect(t){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(t)for(let o of t.split(" ")){let s=n.indexOf(o);s>=0&&(r[s]=!0)}let i=null;for(let o=0;o<n.length;o++)if(!r[o])for(let s=this.dialects[n[o]],a;(a=this.data[s++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new WQe(t,r,i)}static deserialize(t){return new TB(t)}};function gc(e,t){return e[t]|e[t+1]<<16}function HQe(e){let t=null;for(let n of e){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}function rY(e){if(e.external){let t=e.extend?1:0;return(n,r)=>e.external(n,r)<<1|t}return e.get}var Eae=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=Ei(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Tae(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function iY(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),`[${n?"\\w":""}${t.replace(/[^\w\s]/g,"\\$&")}]`}function $Qe(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let o=1;o<i.length;o++)n[i[o]]=!0}let r=iY(t)+iY(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function Oae(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:$Qe(t);return i=>{let o=i.matchBefore(r);return o||i.explicit?{from:o?o.from:i.pos,options:t,validFor:n}:null}}function KQe(e,t){return n=>{for(let r=Ei(n.state).resolveInner(n.pos,-1);r;r=r.parent){if(e.indexOf(r.name)>-1)return null;if(r.type.isTop)break}return t(n)}}var oY=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function zp(e){return e.selection.main.from}function Tae(e,t){var n;let{source:r}=e,i=t&&r[0]!="^",o=r[r.length-1]!="$";return!i&&!o?e:new RegExp(`${i?"^":""}(?:${r})${o?"$":""}`,(n=e.flags)!==null&&n!==void 0?n:e.ignoreCase?"i":"")}var Aae=Ou.define();function YQe(e,t,n,r){let{main:i}=e.selection,o=n-i.from,s=r-i.from;return{...e.changeByRange(a=>{if(a!=i&&n!=r&&e.sliceDoc(a.from+o,a.from+s)!=e.sliceDoc(n,r))return{range:a};let l=e.toText(t);return{changes:{from:a.from+o,to:r==i.from?a.to:a.from+s,insert:l},range:ae.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var sY=new WeakMap;function QQe(e){if(!Array.isArray(e))return e;let t=sY.get(e);return t||sY.set(e,t=Oae(e)),t}var f_=St.define(),qx=St.define(),GQe=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=Ko(e,t),r=su(n);this.chars.push(n);let i=e.slice(t,t+r),o=i.toUpperCase();this.folded.push(Ko(o==i?i.toLowerCase():o,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:o}=this;if(t.length==1){let y=Ko(e,0),v=su(y),b=v==e.length?0:-100;if(y!=t[0])if(y==n[0])b+=-200;else return null;return this.ret(b,[0,v])}let s=e.indexOf(this.pattern);if(s==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=t.length,l=0;if(s<0){for(let y=0,v=Math.min(e.length,200);y<v&&l<a;){let b=Ko(e,y);(b==t[l]||b==n[l])&&(r[l++]=y),y+=su(b)}if(l<a)return null}let u=0,c=0,d=!1,h=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let y=0,v=Math.min(e.length,200),b=0;y<v&&c<a;){let w=Ko(e,y);s<0&&(u<a&&w==t[u]&&(i[u++]=y),h<a&&(w==t[h]||w==n[h]?(h==0&&(f=y),p=y+1,h++):h=0));let x,S=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(x=P5(w))!=x.toLowerCase()?1:x!=x.toUpperCase()?2:0;(!y||S==1&&m||b==0&&S!=0)&&(t[c]==w||n[c]==w&&(d=!0)?o[c++]=y:o.length&&(g=!1)),b=S,y+=su(w)}return c==a&&o[0]==0&&g?this.result(-100+(d?-200:0),o,e):h==a&&f==0?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):s>-1?this.ret(-700-e.length,[s,s+this.pattern.length]):h==a?this.ret(-900-e.length,[f,p]):c==a?this.result(-100+(d?-200:0)+-700+(g?0:-1100),o,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let o of t){let s=o+(this.astral?su(Ko(n,o)):1);i&&r[i-1]==o?r[i-1]=s:(r[i++]=o,r[i++]=s)}return this.ret(e-n.length,r)}},XQe=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},ki=Te.define({combine(e){return kl(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:JQe,filterStrict:!1,compareCompletions:(t,n)=>(t.sortText||t.label).localeCompare(n.sortText||n.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(t,n)=>t&&n,closeOnBlur:(t,n)=>t&&n,icons:(t,n)=>t&&n,tooltipClass:(t,n)=>r=>aY(t(r),n(r)),optionClass:(t,n)=>r=>aY(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function aY(e,t){return e?t?e+" "+t:e:t}function JQe(e,t,n,r,i,o){let s=e.textDirection==On.RTL,a=s,l=!1,u="top",c,d,h=t.left-i.left,f=i.right-t.right,p=r.right-r.left,m=r.bottom-r.top;if(a&&h<Math.min(p,f)?a=!1:!a&&f<Math.min(p,h)&&(a=!0),p<=(a?h:f))c=Math.max(i.top,Math.min(n.top,i.bottom-m))-t.top,d=Math.min(400,a?h:f);else{l=!0,d=Math.min(400,(s?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=m||v>t.top?c=n.bottom-t.top:(u="bottom",c=t.bottom-n.top)}let g=(t.bottom-t.top)/o.offsetHeight,y=(t.right-t.left)/o.offsetWidth;return{style:`${u}: ${c/g}px; max-width: ${d/y}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}var n3=St.define();function ZQe(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(n){let r=document.createElement("div");return r.classList.add("cm-completionIcon"),n.type&&r.classList.add(...n.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),r.setAttribute("aria-hidden","true"),r},position:20}),t.push({render(n,r,i,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=n.displayLabel||n.label,l=0;for(let u=0;u<o.length;){let c=o[u++],d=o[u++];c>l&&s.appendChild(document.createTextNode(a.slice(l,c)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(c,d))),h.className="cm-completionMatchedText",l=d}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(n){if(!n.detail)return null;let r=document.createElement("span");return r.className="cm-completionDetail",r.textContent=n.detail,r},position:80}),t.sort((n,r)=>n.position-r.position).map(n=>n.render)}function tI(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let i=Math.floor(t/n);return{from:i*n,to:(i+1)*n}}let r=Math.floor((e-t)/n);return{from:e-(r+1)*n,to:e-r*n}}var eGe=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:i,selected:o}=r.open,s=e.state.facet(ki);this.optionContent=ZQe(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=tI(i.length,o,s.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:l}=e.state.field(t).open;for(let u=a.target,c;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(c=/-(\d+)$/.exec(u.id))&&+c[1]<l.length){this.applyCompletion(e,l[+c[1]]),a.preventDefault();return}if(a.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&a.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&a.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:n3.of(u)}),a.preventDefault())}}),this.dom.addEventListener("focusout",a=>{let l=e.state.field(this.stateField,!1);l&&l.tooltip&&e.state.facet(ki).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:qx.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=r){let{options:i,selected:o,disabled:s}=n.open;(!r.open||r.open.options!=i)&&(this.range=tI(i.length,o,e.state.facet(ki).maxRenderedOptions),this.showOptions(i,n.id)),this.updateSel(),s!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!s)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=tI(t.options.length,t.selected,this.view.state.facet(ki).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let o=typeof i=="string"?document.createTextNode(i):i(r);if(!o)return;"then"in o?o.then(s=>{s&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(s,r)}).catch(s=>Ao(this.view.state,s,"completion info")):(this.addInfoPane(o,r),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:i}=e;n.appendChild(r),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!="LI"||!n.id?r--:r==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&nGe(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let o=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:o.clientWidth,bottom:o.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(ki).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){let r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",o=>{o.target==r&&o.preventDefault()});let i=null;for(let o=n.from;o<n.to;o++){let{completion:s,match:a}=e[o],{section:l}=s;if(l){let d=typeof l=="string"?l:l.name;if(d!=i&&(o>n.from||n.from==0))if(i=d,typeof l!="string"&&l.header)r.appendChild(l.header(l));else{let h=r.appendChild(document.createElement("completion-section"));h.textContent=d}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+o,u.setAttribute("role","option");let c=this.optionClass(s);c&&(u.className=c);for(let d of this.optionContent){let h=d(s,this.view.state,this.view,a);h&&u.appendChild(h)}}return n.from&&r.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function tGe(e,t){return n=>new eGe(n,e,t)}function nGe(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function lY(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function rGe(e,t){let n=[],r=null,i=null,o=c=>{n.push(c);let{section:d}=c.completion;if(d){r||(r=[]);let h=typeof d=="string"?d:d.name;r.some(f=>f.name==h)||r.push(typeof d=="string"?{name:h}:d)}},s=t.facet(ki);for(let c of e)if(c.hasResult()){let d=c.result.getMatch;if(c.result.filter===!1)for(let h of c.result.options)o(new oY(h,c.source,d?d(h):[],1e9-n.length));else{let h=t.sliceDoc(c.from,c.to),f,p=s.filterStrict?new XQe(h):new GQe(h);for(let m of c.result.options)if(f=p.match(m.label)){let g=m.displayLabel?d?d(m,f.matched):[]:f.matched,y=f.score+(m.boost||0);if(o(new oY(m,c.source,g,y)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:v}=m.section;i||(i=Object.create(null)),i[v]=Math.max(y,i[v]||-1e9)}}}}if(r){let c=Object.create(null),d=0,h=(f,p)=>(f.rank==="dynamic"&&p.rank==="dynamic"?i[p.name]-i[f.name]:0)||(typeof f.rank=="number"?f.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(f.name<p.name?-1:1);for(let f of r.sort(h))d-=1e5,c[f.name]=d;for(let f of n){let{section:p}=f.completion;p&&(f.score+=c[typeof p=="string"?p:p.name])}}let a=[],l=null,u=s.compareCompletions;for(let c of n.sort((d,h)=>h.score-d.score||u(d.completion,h.completion))){let d=c.completion;!l||l.label!=d.label||l.detail!=d.detail||l.type!=null&&d.type!=null&&l.type!=d.type||l.apply!=d.apply||l.boost!=d.boost?a.push(c):lY(c.completion)>lY(l)&&(a[a.length-1]=c),l=c.completion}return a}var iGe=class bw{constructor(t,n,r,i,o,s){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=o,this.disabled=s}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new bw(this.options,uY(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,o,s){if(i&&!s&&t.some(u=>u.isPending))return i.setDisabled();let a=rGe(t,n);if(!a.length)return i&&t.some(u=>u.isPending)?i.setDisabled():null;let l=n.facet(ki).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let u=i.options[i.selected].completion;for(let c=0;c<a.length;c++)if(a[c].completion==u){l=c;break}}return new bw(a,uY(r,l),{pos:t.reduce((u,c)=>c.hasResult()?Math.min(u,c.from):u,1e8),create:dGe,above:o.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new bw(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new bw(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},oGe=class AB{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new AB(uGe,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(ki),i=(r.override||n.languageDataAt("autocomplete",zp(n)).map(QQe)).map(a=>(this.active.find(l=>l.source==a)||new _p(a,this.active.some(l=>l.state!=0)?1:0)).update(t,r));i.length==this.active.length&&i.every((a,l)=>a==this.active[l])&&(i=this.active);let o=this.open,s=t.effects.some(a=>a.is(r3));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||i.some(a=>a.hasResult()&&t.changes.touchesRange(a.from,a.to))||!sGe(i,this.active)||s?o=iGe.build(i,n,this.id,o,r,s):o&&o.disabled&&!i.some(a=>a.isPending)&&(o=null),!o&&i.every(a=>!a.isPending)&&i.some(a=>a.hasResult())&&(i=i.map(a=>a.hasResult()?new _p(a.source,0):a));for(let a of t.effects)a.is(n3)&&(o=o&&o.setSelected(a.value,this.id));return i==this.active&&o==this.open?this:new AB(i,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?aGe:lGe}};function sGe(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,o=r==t.length;if(i||o)return i==o;if(e[n++].result!=t[r++].result)return!1}}var aGe={"aria-autocomplete":"list"},lGe={};function uY(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}var uGe=[];function Dae(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(Aae);if(r&&t.activateOnCompletion(r))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:e.docChanged?16:0}var _p=class ww{constructor(t,n,r=!1){this.source=t,this.state=n,this.explicit=r}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=Dae(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new ww(i.source,0)),r&4&&i.state==0&&(i=new ww(this.source,1)),i=i.updateFor(t,r);for(let o of t.effects)if(o.is(f_))i=new ww(i.source,1,o.value);else if(o.is(qx))i=new ww(i.source,0);else if(o.is(r3))for(let s of o.value)s.source==i.source&&(i=s);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(zp(t.state))}},Rae=class sM extends _p{constructor(t,n,r,i,o,s){super(t,3,n),this.limit=r,this.result=i,this.from=o,this.to=s}hasResult(){return!0}updateFor(t,n){var r;if(!(n&3))return this.map(t.changes);let i=this.result;i.map&&!t.changes.empty&&(i=i.map(i,t.changes));let o=t.changes.mapPos(this.from),s=t.changes.mapPos(this.to,1),a=zp(t.state);if(a>s||!i||n&2&&(zp(t.startState)==this.from||a<this.limit))return new _p(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return cGe(i.validFor,t.state,o,s)?new sM(this.source,this.explicit,l,i,o,s):i.update&&(i=i.update(i,o,s,new Eae(t.state,a,!1)))?new sM(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:zp(t.state)):new _p(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new sM(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new _p(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}};function cGe(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Tae(e,!0).test(i)}var r3=St.define({map(e,t){return e.map(n=>n.map(t))}}),Yo=uo.define({create(){return oGe.start()},update(e,t){return e.update(t)},provide:e=>[jE.from(e,t=>t.tooltip),ke.contentAttributes.from(e,t=>t.attrs)]});function i3(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(Yo).active.find(i=>i.source==t.source);return r instanceof Rae?(typeof n=="string"?e.dispatch({...YQe(e.state,n,r.from,r.to),annotations:Aae.of(t.completion)}):n(e,t.completion,r.from,r.to),!0):!1}var dGe=tGe(Yo,i3);function hN(e,t="option"){return n=>{let r=n.state.field(Yo,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(ki).interactionDelay)return!1;let i=1,o;t=="page"&&(o=Zse(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,a=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:s-1;return a<0?a=t=="page"?0:s-1:a>=s&&(a=t=="page"?s-1:0),n.dispatch({effects:n3.of(a)}),!0}}var hGe=e=>{let t=e.state.field(Yo,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(ki).interactionDelay?!1:i3(e,t.open.options[t.open.selected])},nI=e=>e.state.field(Yo,!1)?(e.dispatch({effects:f_.of(!0)}),!0):!1,fGe=e=>{let t=e.state.field(Yo,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:qx.of(null)}),!0)},pGe=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},mGe=50,gGe=1e3,yGe=Jr.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(Yo).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Yo),n=e.state.facet(ki);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Yo)==t)return;let r=e.transactions.some(o=>{let s=Dae(o,n);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(r||s.context.abortOnDocChange&&e.docChanged||s.updates.length+e.transactions.length>mGe&&Date.now()-s.time>gGe){for(let a of s.context.abortListeners)try{a()}catch(l){Ao(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(o=>o.effects.some(s=>s.is(f_)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let o of e.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(Yo);for(let n of t.active)n.isPending&&!this.running.some(r=>r.active.source==n.source)&&this.startQuery(n);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=zp(t),r=new Eae(t,n,e.explicit,this.view),i=new pGe(e,r);this.running.push(i),Promise.resolve(e.source(r)).then(o=>{i.context.aborted||(i.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:qx.of(null)}),Ao(this.view.state,o)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(ki).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(ki),r=this.view.state.field(Yo);for(let i=0;i<this.running.length;i++){let o=this.running[i];if(o.done===void 0)continue;if(this.running.splice(i--,1),o.done){let a=zp(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),u=new Rae(o.active.source,o.active.explicit,l,o.done,o.done.from,(e=o.done.to)!==null&&e!==void 0?e:a);for(let c of o.updates)u=u.update(c,n);if(u.hasResult()){t.push(u);continue}}let s=r.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new _p(o.active.source,0);for(let l of o.updates)a=a.update(l,n);a.isPending||t.push(a)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:r3.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Yo,!1);if(t&&t.tooltip&&this.view.state.facet(ki).closeOnBlur){let n=t.open&&Zse(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:qx.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:f_.of(!1)}),20),this.composing=0}}}),vGe=typeof navigator=="object"&&/Win/.test(navigator.platform),bGe=Xh.highest(ke.domEventHandlers({keydown(e,t){let n=t.state.field(Yo,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(vGe&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(s=>s.source==r.source),o=r.completion.commitCharacters||i.result.commitCharacters;return o&&o.indexOf(e.key)>-1&&i3(t,r),!1}})),wGe=ke.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),zx={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ep=St.define({map(e,t){return t.mapPos(e,-1,_o.TrackAfter)??void 0}}),o3=new class extends Dh{};o3.startSide=1;o3.endSide=-1;var Iae=uo.define({create(){return hn.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:r=>r>=n.from&&r<=n.to})}for(let n of t.effects)n.is(Ep)&&(e=e.update({add:[o3.range(n.value,n.value+1)]}));return e}});function xGe(){return[kGe,Iae]}var rI="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function Pae(e){for(let t=0;t<rI.length;t+=2)if(rI.charCodeAt(t)==e)return rI.charAt(t+1);return P5(e<128?e:e+1)}function Lae(e,t){return e.languageDataAt("closeBrackets",t)[0]||zx}var SGe=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),kGe=ke.inputHandler.of((e,t,n,r)=>{if((SGe?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&su(Ko(r,0))==1||t!=i.from||n!=i.to)return!1;let o=MGe(e.state,r);return o?(e.dispatch(o),!0):!1}),CGe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Lae(e,e.selection.main.head).brackets||zx.brackets,r=null,i=e.changeByRange(o=>{if(o.empty){let s=_Ge(e.doc,o.head);for(let a of n)if(a==s&&HE(e.doc,o.head)==Pae(Ko(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:ae.cursor(o.head-a.length)}}return{range:r=o}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:"delete.backward"})),!r},NGe=[{key:"Backspace",run:CGe}];function MGe(e,t){let n=Lae(e,e.selection.main.head),r=n.brackets||zx.brackets;for(let i of r){let o=Pae(Ko(i,0));if(t==i)return o==i?TGe(e,i,r.indexOf(i+i+i)>-1,n):EGe(e,i,o,n.before||zx.before);if(t==o&&Bae(e,e.selection.main.from))return OGe(e,i,o)}return null}function Bae(e,t){let n=!1;return e.field(Iae).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function HE(e,t){let n=e.sliceString(t,t+2);return n.slice(0,su(Ko(n,0)))}function _Ge(e,t){let n=e.sliceString(t-2,t);return su(Ko(n,0))==n.length?n:n.slice(1)}function EGe(e,t,n,r){let i=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:Ep.of(s.to+t.length),range:ae.range(s.anchor+t.length,s.head+t.length)};let a=HE(e.doc,s.head);return!a||/\s/.test(a)||r.indexOf(a)>-1?{changes:{insert:t+n,from:s.head},effects:Ep.of(s.head+t.length),range:ae.cursor(s.head+t.length)}:{range:i=s}});return i?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function OGe(e,t,n){let r=null,i=e.changeByRange(o=>o.empty&&HE(e.doc,o.head)==n?{changes:{from:o.head,to:o.head+n.length,insert:n},range:ae.cursor(o.head+n.length)}:r={range:o});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function TGe(e,t,n,r){let i=r.stringPrefixes||zx.stringPrefixes,o=null,s=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:t,from:a.to}],effects:Ep.of(a.to+t.length),range:ae.range(a.anchor+t.length,a.head+t.length)};let l=a.head,u=HE(e.doc,l),c;if(u==t){if(cY(e,l))return{changes:{insert:t+t,from:l},effects:Ep.of(l+t.length),range:ae.cursor(l+t.length)};if(Bae(e,l)){let d=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+d.length,insert:d},range:ae.cursor(l+d.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(c=dY(e,l-2*t.length,i))>-1&&cY(e,c))return{changes:{insert:t+t+t+t,from:l},effects:Ep.of(l+t.length),range:ae.cursor(l+t.length)};if(e.charCategorizer(l)(u)!=rr.Word&&dY(e,l,i)>-1&&!AGe(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Ep.of(l+t.length),range:ae.cursor(l+t.length)}}return{range:o=a}});return o?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function cY(e,t){let n=Ei(e).resolveInner(t+1);return n.parent&&n.from==t}function AGe(e,t,n,r){let i=Ei(e).resolveInner(t,-1),o=r.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+o)),l=a.indexOf(n);if(!l||l>-1&&r.indexOf(a.slice(0,l))>-1){let c=i.firstChild;for(;c&&c.from==i.from&&c.to-c.from>n.length+l;){if(e.sliceDoc(c.to-n.length,c.to)==n)return!1;c=c.firstChild}return!0}let u=i.to==t&&i.parent;if(!u)break;i=u}return!1}function dY(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=rr.Word)return t;for(let i of n){let o=t-i.length;if(e.sliceDoc(o,t)==i&&r(e.sliceDoc(o-1,o))!=rr.Word)return o}return-1}function DGe(e={}){return[bGe,Yo,ki.of(e),yGe,RGe,wGe]}var qae=[{key:"Ctrl-Space",run:nI},{mac:"Alt-`",run:nI},{mac:"Alt-i",run:nI},{key:"Escape",run:fGe},{key:"ArrowDown",run:hN(!0)},{key:"ArrowUp",run:hN(!1)},{key:"PageDown",run:hN(!0,"page")},{key:"PageUp",run:hN(!1,"page")},{key:"Enter",run:hGe}],RGe=Xh.highest(w1.computeN([ki],e=>e.facet(ki).defaultKeymap?[qae]:[])),IGe=36,hY=1,PGe=2,Kg=3,iI=4,LGe=5,BGe=6,qGe=7,zGe=8,FGe=9,jGe=10,VGe=11,WGe=12,UGe=13,HGe=14,$Ge=15,KGe=16,YGe=17,fY=18,QGe=19,zae=20,Fae=21,pY=22,GGe=23,XGe=24;function DB(e){return e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57}function JGe(e){return e>=48&&e<=57||e>=97&&e<=102||e>=65&&e<=70}function yp(e,t,n){for(let r=!1;;){if(e.next<0)return;if(e.next==t&&!r){e.advance();return}r=n&&!r&&e.next==92,e.advance()}}function ZGe(e,t){e:for(;;){if(e.next<0)return;if(e.next==36){e.advance();for(let n=0;n<t.length;n++){if(e.next!=t.charCodeAt(n))continue e;e.advance()}if(e.next==36){e.advance();return}}else e.advance()}}function eXe(e,t){let n="[{<(".indexOf(String.fromCharCode(t)),r=n<0?t:"]}>)".charCodeAt(n);for(;;){if(e.next<0)return;if(e.next==r&&e.peek(1)==39){e.advance(2);return}e.advance()}}function RB(e,t){for(;!(e.next!=95&&!DB(e.next));)t!=null&&(t+=String.fromCharCode(e.next)),e.advance();return t}function tXe(e){if(e.next==39||e.next==34||e.next==96){let t=e.next;e.advance(),yp(e,t,!1)}else RB(e)}function mY(e,t){for(;e.next==48||e.next==49;)e.advance();t&&e.next==t&&e.advance()}function gY(e,t){for(;;){if(e.next==46){if(t)break;t=!0}else if(e.next<48||e.next>57)break;e.advance()}if(e.next==69||e.next==101)for(e.advance(),(e.next==43||e.next==45)&&e.advance();e.next>=48&&e.next<=57;)e.advance()}function yY(e){for(;!(e.next<0||e.next==10);)e.advance()}function up(e,t){for(let n=0;n<t.length;n++)if(t.charCodeAt(n)==e)return!0;return!1}var oI=` \r
`;function jae(e,t,n){let r=Object.create(null);r.true=r.false=LGe,r.null=r.unknown=BGe;for(let i of e.split(" "))i&&(r[i]=zae);for(let i of t.split(" "))i&&(r[i]=Fae);for(let i of(n||"").split(" "))i&&(r[i]=XGe);return r}var ym="array binary bit boolean char character clob date decimal double float int integer interval large national nchar nclob numeric object precision real smallint time timestamp varchar varying ",vm="absolute action add after all allocate alter and any are as asc assertion at authorization before begin between both breadth by call cascade cascaded case cast catalog check close collate collation column commit condition connect connection constraint constraints constructor continue corresponding count create cross cube current current_date current_default_transform_group current_transform_group_for_type current_path current_role current_time current_timestamp current_user cursor cycle data day deallocate declare default deferrable deferred delete depth deref desc describe descriptor deterministic diagnostics disconnect distinct do domain drop dynamic each else elseif end end-exec equals escape except exception exec execute exists exit external fetch first for foreign found from free full function general get global go goto grant group grouping handle having hold hour identity if immediate in indicator initially inner inout input insert intersect into is isolation join key language last lateral leading leave left level like limit local localtime localtimestamp locator loop map match method minute modifies module month names natural nesting new next no none not of old on only open option or order ordinality out outer output overlaps pad parameter partial path prepare preserve primary prior privileges procedure public read reads recursive redo ref references referencing relative release repeat resignal restrict result return returns revoke right role rollback rollup routine row rows savepoint schema scroll search second section select session session_user set sets signal similar size some space specific specifictype sql sqlexception sqlstate sqlwarning start state static system_user table temporary then timezone_hour timezone_minute to trailing transaction translation treat trigger under undo union unique unnest until update usage user using value values view when whenever where while with without work write year zone ",IB={backslashEscapes:!1,hashComments:!1,spaceAfterDashes:!1,slashComments:!1,doubleQuotedStrings:!1,doubleDollarQuotedStrings:!1,unquotedBitLiterals:!1,treatBitsAsBytes:!1,charSetCasts:!1,plsqlQuotingMechanism:!1,operatorChars:"*+-%<>!=&|~^/",specialVar:"?",identifierQuotes:'"',caseInsensitiveIdentifiers:!1,words:jae(vm,ym)};function nXe(e,t,n,r){let i={};for(let o in IB)i[o]=(e.hasOwnProperty(o)?e:IB)[o];return t&&(i.words=jae(t,n||"",r)),i}function Vae(e){return new qQe(t=>{var n;let{next:r}=t;if(t.advance(),up(r,oI)){for(;up(t.next,oI);)t.advance();t.acceptToken(IGe)}else if(r==36&&e.doubleDollarQuotedStrings){let i=RB(t,"");t.next==36&&(t.advance(),ZGe(t,i),t.acceptToken(Kg))}else if(r==39||r==34&&e.doubleQuotedStrings)yp(t,r,e.backslashEscapes),t.acceptToken(Kg);else if(r==35&&e.hashComments||r==47&&t.next==47&&e.slashComments)yY(t),t.acceptToken(hY);else if(r==45&&t.next==45&&(!e.spaceAfterDashes||t.peek(1)==32))yY(t),t.acceptToken(hY);else if(r==47&&t.next==42){t.advance();for(let i=1;;){let o=t.next;if(t.next<0)break;if(t.advance(),o==42&&t.next==47){if(i--,t.advance(),!i)break}else o==47&&t.next==42&&(i++,t.advance())}t.acceptToken(PGe)}else if((r==101||r==69)&&t.next==39)t.advance(),yp(t,39,!0),t.acceptToken(Kg);else if((r==110||r==78)&&t.next==39&&e.charSetCasts)t.advance(),yp(t,39,e.backslashEscapes),t.acceptToken(Kg);else if(r==95&&e.charSetCasts)for(let i=0;;i++){if(t.next==39&&i>1){t.advance(),yp(t,39,e.backslashEscapes),t.acceptToken(Kg);break}if(!DB(t.next))break;t.advance()}else if(e.plsqlQuotingMechanism&&(r==113||r==81)&&t.next==39&&t.peek(1)>0&&!up(t.peek(1),oI)){let i=t.peek(1);t.advance(2),eXe(t,i),t.acceptToken(Kg)}else if(up(r,e.identifierQuotes)){let i=r==91?93:r;yp(t,i,!1),t.acceptToken(QGe)}else if(r==40)t.acceptToken(qGe);else if(r==41)t.acceptToken(zGe);else if(r==123)t.acceptToken(FGe);else if(r==125)t.acceptToken(jGe);else if(r==91)t.acceptToken(VGe);else if(r==93)t.acceptToken(WGe);else if(r==59)t.acceptToken(UGe);else if(e.unquotedBitLiterals&&r==48&&t.next==98)t.advance(),mY(t),t.acceptToken(pY);else if((r==98||r==66)&&(t.next==39||t.next==34)){let i=t.next;t.advance(),e.treatBitsAsBytes?(yp(t,i,e.backslashEscapes),t.acceptToken(GGe)):(mY(t,i),t.acceptToken(pY))}else if(r==48&&(t.next==120||t.next==88)||(r==120||r==88)&&t.next==39){let i=t.next==39;for(t.advance();JGe(t.next);)t.advance();i&&t.next==39&&t.advance(),t.acceptToken(iI)}else if(r==46&&t.next>=48&&t.next<=57)gY(t,!0),t.acceptToken(iI);else if(r==46)t.acceptToken(HGe);else if(r>=48&&r<=57)gY(t,!1),t.acceptToken(iI);else if(up(r,e.operatorChars)){for(;up(t.next,e.operatorChars);)t.advance();t.acceptToken($Ge)}else if(up(r,e.specialVar))t.next==r&&t.advance(),tXe(t),t.acceptToken(YGe);else if(r==58||r==44)t.acceptToken(KGe);else if(DB(r)){let i=RB(t,String.fromCharCode(r));t.acceptToken(t.next==46||t.peek(-i.length-1)==46?fY:(n=e.words[i.toLowerCase()])!==null&&n!==void 0?n:fY)}})}var Wae=Vae(IB),rXe=UQe.deserialize({version:14,states:"%vQ]QQOOO#wQRO'#DSO$OQQO'#CwO%eQQO'#CxO%lQQO'#CyO%sQQO'#CzOOQQ'#DS'#DSOOQQ'#C}'#C}O'UQRO'#C{OOQQ'#Cv'#CvOOQQ'#C|'#C|Q]QQOOQOQQOOO'`QQO'#DOO(xQRO,59cO)PQQO,59cO)UQQO'#DSOOQQ,59d,59dO)cQQO,59dOOQQ,59e,59eO)jQQO,59eOOQQ,59f,59fO)qQQO,59fOOQQ-E6{-E6{OOQQ,59b,59bOOQQ-E6z-E6zOOQQ,59j,59jOOQQ-E6|-E6|O+VQRO1G.}O+^QQO,59cOOQQ1G/O1G/OOOQQ1G/P1G/POOQQ1G/Q1G/QP+kQQO'#C}O+rQQO1G.}O)PQQO,59cO,PQQO'#Cw",stateData:",[~OtOSPOSQOS~ORUOSUOTUOUUOVROXSOZTO]XO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O^]ORvXSvXTvXUvXVvXXvXZvX]vX_vX`vXavXbvXcvXdvXevXfvXgvXhvX~OsvX~P!jOa_Ob_Oc_O~ORUOSUOTUOUUOVROXSOZTO^tO_UO`UOa`Ob`Oc`OdUOeUOfUOgUOhUO~OWaO~P$ZOYcO~P$ZO[eO~P$ZORUOSUOTUOUUOVROXSOZTO^QO_UO`UOaPObPOcPOdUOeUOfUOgUOhUO~O]hOsoX~P%zOajObjOcjO~O^]ORkaSkaTkaUkaVkaXkaZka]ka_ka`kaakabkackadkaekafkagkahka~Oska~P'kO^]O~OWvXYvX[vX~P!jOWnO~P$ZOYoO~P$ZO[pO~P$ZO^]ORkiSkiTkiUkiVkiXkiZki]ki_ki`kiakibkickidkiekifkigkihki~Oski~P)xOWkaYka[ka~P'kO]hO~P$ZOWkiYki[ki~P)xOasObsOcsO~O",goto:"#hwPPPPPPPPPPPPPPPPPPPPPPPPPPx||||!Y!^!d!xPPP#[TYOZeUORSTWZbdfqT[OZQZORiZSWOZQbRQdSQfTZgWbdfqQ^PWk^lmrQl_Qm`RrseVORSTWZbdfq",nodeNames:"\u26A0 LineComment BlockComment String Number Bool Null ( ) { } [ ] ; . Operator Punctuation SpecialVar Identifier QuotedIdentifier Keyword Type Bits Bytes Builtin Script Statement CompositeIdentifier Parens Braces Brackets Statement",maxTerm:38,nodeProps:[["isolate",-4,1,2,3,19,""]],skippedNodes:[0,1,2],repeatNodeCount:3,tokenData:"RORO",tokenizers:[0,Wae],topRules:{Script:[0,25]},tokenPrec:0});function PB(e){let t=e.cursor().moveTo(e.from,-1);for(;/Comment/.test(t.name);)t.moveTo(t.from,-1);return t.node}function Fx(e,t){let n=e.sliceString(t.from,t.to),r=/^([`'"\[])(.*)([`'"\]])$/.exec(n);return r?r[2]:n}function p_(e){return e&&(e.name=="Identifier"||e.name=="QuotedIdentifier")}function iXe(e,t){if(t.name=="CompositeIdentifier"){let n=[];for(let r=t.firstChild;r;r=r.nextSibling)p_(r)&&n.push(Fx(e,r));return n}return[Fx(e,t)]}function vY(e,t){for(let n=[];;){if(!t||t.name!=".")return n;let r=PB(t);if(!p_(r))return n;n.unshift(Fx(e,r)),t=PB(r)}}function oXe(e,t){let n=Ei(e).resolveInner(t,-1),r=aXe(e.doc,n);return n.name=="Identifier"||n.name=="QuotedIdentifier"||n.name=="Keyword"?{from:n.from,quoted:n.name=="QuotedIdentifier"?e.doc.sliceString(n.from,n.from+1):null,parents:vY(e.doc,PB(n)),aliases:r}:n.name=="."?{from:t,quoted:null,parents:vY(e.doc,n),aliases:r}:{from:t,quoted:null,parents:[],empty:!0,aliases:r}}var sXe=new Set("where group having order union intersect except all distinct limit offset fetch for".split(" "));function aXe(e,t){let n;for(let i=t;!n;i=i.parent){if(!i)return null;i.name=="Statement"&&(n=i)}let r=null;for(let i=n.firstChild,o=!1,s=null;i;i=i.nextSibling){let a=i.name=="Keyword"?e.sliceString(i.from,i.to).toLowerCase():null,l=null;if(!o)o=a=="from";else if(a=="as"&&s&&p_(i.nextSibling))l=Fx(e,i.nextSibling);else{if(a&&sXe.has(a))break;s&&p_(i)&&(l=Fx(e,i))}l&&(r||(r=Object.create(null)),r[l]=iXe(e,s)),s=/Identifier$/.test(i.name)?i:null}return r}function lXe(e,t,n){return n.map(r=>({...r,label:r.label[0]==e?r.label:e+r.label+t,apply:void 0}))}var uXe=/^\w*$/,cXe=/^[`'"\[]?\w*[`'"\]]?$/;function bY(e){return e.self&&typeof e.self.label=="string"}var dXe=class Uae{constructor(t,n){this.idQuote=t,this.idCaseInsensitive=n,this.list=[],this.children=void 0}child(t){let n=this.children||(this.children=Object.create(null));return n[t]||(t&&!this.list.some(i=>i.label==t)&&this.list.push(wY(t,"type",this.idQuote,this.idCaseInsensitive)),n[t]=new Uae(this.idQuote,this.idCaseInsensitive))}maybeChild(t){return this.children?this.children[t]:null}addCompletion(t){let n=this.list.findIndex(r=>r.label==t.label);n>-1?this.list[n]=t:this.list.push(t)}addCompletions(t){for(let n of t)this.addCompletion(typeof n=="string"?wY(n,"property",this.idQuote,this.idCaseInsensitive):n)}addNamespace(t){Array.isArray(t)?this.addCompletions(t):bY(t)?this.addNamespace(t.children):this.addNamespaceObject(t)}addNamespaceObject(t){for(let n of Object.keys(t)){let r=t[n],i=null,o=n.replace(/\\?\./g,a=>a=="."?"\0":a).split("\0"),s=this;bY(r)&&(i=r.self,r=r.children);for(let a=0;a<o.length;a++)i&&a==o.length-1&&s.addCompletion(i),s=s.child(o[a].replace(/\\\./g,"."));s.addNamespace(r)}}};function wY(e,t,n,r){return new RegExp("^[a-z_][a-z_\\d]*$",r?"i":"").test(e)?{label:e,type:t}:{label:e,type:t,apply:n+e+Hae(n)}}function Hae(e){return e==="["?"]":e}function hXe(e,t,n,r,i,o){var s;let a=((s=o?.spec.identifierQuotes)===null||s===void 0?void 0:s[0])||'"',l=new dXe(a,!!o?.spec.caseInsensitiveIdentifiers),u=i?l.child(i):null;return l.addNamespace(e),t&&(u||l).addCompletions(t),n&&l.addCompletions(n),u&&l.addCompletions(u.list),r&&l.addCompletions((u||l).child(r).list),c=>{let{parents:d,from:h,quoted:f,empty:p,aliases:m}=oXe(c.state,c.pos);if(p&&!c.explicit)return null;m&&d.length==1&&(d=m[d[0]]||d);let g=l;for(let v of d){for(;!g.children||!g.children[v];)if(g==l&&u)g=u;else if(g==u&&r)g=g.child(r);else return null;let b=g.maybeChild(v);if(!b)return null;g=b}let y=g.list;if(g==l&&m&&(y=y.concat(Object.keys(m).map(v=>({label:v,type:"constant"})))),f){let v=f[0],b=Hae(v),w=c.state.sliceDoc(c.pos,c.pos+1)==b;return{from:h,to:w?c.pos+1:void 0,options:lXe(v,b,y),validFor:cXe}}else return{from:h,options:y,validFor:uXe}}}function fXe(e){return e==Fae?"type":e==zae?"keyword":"variable"}function pXe(e,t,n){let r=Object.keys(e).map(i=>n(t?i.toUpperCase():i,fXe(e[i])));return KQe(["QuotedIdentifier","String","LineComment","BlockComment","."],Oae(r))}var mXe=rXe.configure({props:[dae.add({Statement:eQe()}),pae.add({Statement(e,t){return{from:Math.min(e.from+100,t.doc.lineAt(e.from).to),to:e.to}},BlockComment(e){return{from:e.from+2,to:e.to-2}}}),aae({Keyword:ee.keyword,Type:ee.typeName,Builtin:ee.standard(ee.name),Bits:ee.number,Bytes:ee.string,Bool:ee.bool,Null:ee.null,Number:ee.number,String:ee.string,Identifier:ee.name,QuotedIdentifier:ee.special(ee.string),SpecialVar:ee.special(ee.name),LineComment:ee.lineComment,BlockComment:ee.blockComment,Operator:ee.operator,"Semi Punctuation":ee.punctuation,"( )":ee.paren,"{ }":ee.brace,"[ ]":ee.squareBracket})]}),Jh=class LB{constructor(t,n,r){this.dialect=t,this.language=n,this.spec=r}get extension(){return this.language.extension}configureLanguage(t,n){return new LB(this.dialect,this.language.configure(t,n),this.spec)}static define(t){let n=nXe(t,t.keywords,t.types,t.builtin),r=FYe.define({name:"sql",parser:mXe.configure({tokenizers:[{from:Wae,to:Vae(n)}]}),languageData:{commentTokens:{line:"--",block:{open:"/*",close:"*/"}},closeBrackets:{brackets:["(","[","{","'",'"',"`"]}}});return new LB(n,r,t)}};function gXe(e,t){return{label:e,type:t,boost:-1}}function yXe(e,t=!1,n){return pXe(e.dialect.words,t,n||gXe)}function vXe(e){return e.schema?hXe(e.schema,e.tables,e.schemas,e.defaultTable,e.defaultSchema,e.dialect||s3):()=>null}function bXe(e){return e.schema?(e.dialect||s3).language.data.of({autocomplete:vXe(e)}):[]}function wXe(e={}){let t=e.dialect||s3;return new UYe(t.language,[bXe(e),t.language.data.of({autocomplete:yXe(t,e.upperCaseKeywords,e.keywordCompletion)})])}var s3=Jh.define({}),xXe=Jh.define({charSetCasts:!0,doubleDollarQuotedStrings:!0,operatorChars:"+-*/<>=~!@#%^&|`?",specialVar:"",keywords:vm+"abort abs absent access according ada admin aggregate alias also always analyse analyze array_agg array_max_cardinality asensitive assert assignment asymmetric atomic attach attribute attributes avg backward base64 begin_frame begin_partition bernoulli bit_length blocked bom cache called cardinality catalog_name ceil ceiling chain char_length character_length character_set_catalog character_set_name character_set_schema characteristics characters checkpoint class class_origin cluster coalesce cobol collation_catalog collation_name collation_schema collect column_name columns command_function command_function_code comment comments committed concurrently condition_number configuration conflict connection_name constant constraint_catalog constraint_name constraint_schema contains content control conversion convert copy corr cost covar_pop covar_samp csv cume_dist current_catalog current_row current_schema cursor_name database datalink datatype datetime_interval_code datetime_interval_precision db debug defaults defined definer degree delimiter delimiters dense_rank depends derived detach detail dictionary disable discard dispatch dlnewcopy dlpreviouscopy dlurlcomplete dlurlcompleteonly dlurlcompletewrite dlurlpath dlurlpathonly dlurlpathwrite dlurlscheme dlurlserver dlvalue document dump dynamic_function dynamic_function_code element elsif empty enable encoding encrypted end_frame end_partition endexec enforced enum errcode error event every exclude excluding exclusive exp explain expression extension extract family file filter final first_value flag floor following force foreach fortran forward frame_row freeze fs functions fusion generated granted greatest groups handler header hex hierarchy hint id ignore ilike immediately immutable implementation implicit import include including increment indent index indexes info inherit inherits inline insensitive instance instantiable instead integrity intersection invoker isnull key_member key_type label lag last_value lead leakproof least length library like_regex link listen ln load location lock locked log logged lower mapping matched materialized max max_cardinality maxvalue member merge message message_length message_octet_length message_text min minvalue mod mode more move multiset mumps name namespace nfc nfd nfkc nfkd nil normalize normalized nothing notice notify notnull nowait nth_value ntile nullable nullif nulls number occurrences_regex octet_length octets off offset oids operator options ordering others over overlay overriding owned owner parallel parameter_mode parameter_name parameter_ordinal_position parameter_specific_catalog parameter_specific_name parameter_specific_schema parser partition pascal passing passthrough password percent percent_rank percentile_cont percentile_disc perform period permission pg_context pg_datatype_name pg_exception_context pg_exception_detail pg_exception_hint placing plans pli policy portion position position_regex power precedes preceding prepared print_strict_params procedural procedures program publication query quote raise range rank reassign recheck recovery refresh regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy regr_syy reindex rename repeatable replace replica requiring reset respect restart restore result_oid returned_cardinality returned_length returned_octet_length returned_sqlstate returning reverse routine_catalog routine_name routine_schema routines row_count row_number rowtype rule scale schema_name schemas scope scope_catalog scope_name scope_schema security selective self sensitive sequence sequences serializable server server_name setof share show simple skip slice snapshot source specific_name sqlcode sqlerror sqrt stable stacked standalone statement statistics stddev_pop stddev_samp stdin stdout storage strict strip structure style subclass_origin submultiset subscription substring substring_regex succeeds sum symmetric sysid system system_time table_name tables tablesample tablespace temp template ties token top_level_count transaction_active transactions_committed transactions_rolled_back transform transforms translate translate_regex trigger_catalog trigger_name trigger_schema trim trim_array truncate trusted type types uescape unbounded uncommitted unencrypted unlink unlisten unlogged unnamed untyped upper uri use_column use_variable user_defined_type_catalog user_defined_type_code user_defined_type_name user_defined_type_schema vacuum valid validate validator value_of var_pop var_samp varbinary variable_conflict variadic verbose version versioning views volatile warning whitespace width_bucket window within wrapper xmlagg xmlattributes xmlbinary xmlcast xmlcomment xmlconcat xmldeclaration xmldocument xmlelement xmlexists xmlforest xmliterate xmlnamespaces xmlparse xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltext xmlvalidate yes",types:ym+"bigint int8 bigserial serial8 varbit bool box bytea cidr circle precision float8 inet int4 json jsonb line lseg macaddr macaddr8 money numeric pg_lsn point polygon float4 int2 smallserial serial2 serial serial4 text timetz timestamptz tsquery tsvector txid_snapshot uuid xml"}),$ae="accessible algorithm analyze asensitive authors auto_increment autocommit avg avg_row_length binlog btree cache catalog_name chain change changed checkpoint checksum class_origin client_statistics coalesce code collations columns comment committed completion concurrent consistent contains contributors convert database databases day_hour day_microsecond day_minute day_second delay_key_write delayed delimiter des_key_file dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile enable enclosed ends engine engines enum errors escaped even event events every explain extended fast field fields flush force found_rows fulltext grants handler hash high_priority hosts hour_microsecond hour_minute hour_second ignore ignore_server_ids import index index_statistics infile innodb insensitive insert_method install invoker iterate keys kill linear lines list load lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modify mutex mysql_errno no_write_to_binlog offline offset one online optimize optionally outfile pack_keys parser partition partitions password phase plugin plugins prev processlist profile profiles purge query quick range read_write rebuild recover regexp relaylog remove rename reorganize repair repeatable replace require resume rlike row_format rtree schedule schema_name schemas second_microsecond security sensitive separator serializable server share show slave slow snapshot soname spatial sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result ssl starting starts std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace terminated triggers truncate uncommitted uninstall unlock upgrade use use_frm user_resources user_statistics utc_date utc_time utc_timestamp variables views warnings xa xor year_month zerofill",Kae=ym+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int1 int2 int3 int4 int8 float4 float8 varbinary varcharacter precision datetime unsigned signed",Yae="charset clear edit ego help nopager notee nowarning pager print prompt quit rehash source status system tee",SXe=Jh.define({operatorChars:"*+-%<>!=&|^",charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:"@?",identifierQuotes:"`",keywords:vm+"group_concat "+$ae,types:Kae,builtin:Yae}),Gyt=Jh.define({operatorChars:"*+-%<>!=&|^",charSetCasts:!0,doubleQuotedStrings:!0,unquotedBitLiterals:!0,hashComments:!0,spaceAfterDashes:!0,specialVar:"@?",identifierQuotes:"`",keywords:vm+"always generated groupby_concat hard persistent shutdown soft virtual "+$ae,types:Kae,builtin:Yae}),kXe="approx_count_distinct approx_percentile_cont approx_percentile_disc avg checksum_agg count count_big grouping grouping_id max min product stdev stdevp sum var varp ai_generate_embeddings ai_generate_chunks cume_dist first_value lag last_value lead percentile_cont percentile_disc percent_rank left_shift right_shift bit_count get_bit set_bit collationproperty tertiary_weights @@datefirst @@dbts @@langid @@language @@lock_timeout @@max_connections @@max_precision @@nestlevel @@options @@remserver @@servername @@servicename @@spid @@textsize @@version cast convert parse try_cast try_convert try_parse asymkey_id asymkeyproperty certproperty cert_id crypt_gen_random decryptbyasymkey decryptbycert decryptbykey decryptbykeyautoasymkey decryptbykeyautocert decryptbypassphrase encryptbyasymkey encryptbycert encryptbykey encryptbypassphrase hashbytes is_objectsigned key_guid key_id key_name signbyasymkey signbycert symkeyproperty verifysignedbycert verifysignedbyasymkey @@cursor_rows @@fetch_status cursor_status datalength ident_current ident_incr ident_seed identity sql_variant_property @@datefirst current_timestamp current_timezone current_timezone_id date_bucket dateadd datediff datediff_big datefromparts datename datepart datetime2fromparts datetimefromparts datetimeoffsetfromparts datetrunc day eomonth getdate getutcdate isdate month smalldatetimefromparts switchoffset sysdatetime sysdatetimeoffset sysutcdatetime timefromparts todatetimeoffset year edit_distance edit_distance_similarity jaro_winkler_distance jaro_winkler_similarity edge_id_from_parts graph_id_from_edge_id graph_id_from_node_id node_id_from_parts object_id_from_edge_id object_id_from_node_id json isjson json_array json_contains json_modify json_object json_path_exists json_query json_value regexp_like regexp_replace regexp_substr regexp_instr regexp_count regexp_matches regexp_split_to_table abs acos asin atan atn2 ceiling cos cot degrees exp floor log log10 pi power radians rand round sign sin sqrt square tan choose greatest iif least @@procid app_name applock_mode applock_test assemblyproperty col_length col_name columnproperty databasepropertyex db_id db_name file_id file_idex file_name filegroup_id filegroup_name filegroupproperty fileproperty filepropertyex fulltextcatalogproperty fulltextserviceproperty index_col indexkey_property indexproperty next value for object_definition object_id object_name object_schema_name objectproperty objectpropertyex original_db_name parsename schema_id schema_name scope_identity serverproperty stats_date type_id type_name typeproperty dense_rank ntile rank row_number publishingservername certenclosed certprivatekey current_user database_principal_id has_dbaccess has_perms_by_name is_member is_rolemember is_srvrolemember loginproperty original_login permissions pwdencrypt pwdcompare session_user sessionproperty suser_id suser_name suser_sid suser_sname system_user user user_id user_name ascii char charindex concat concat_ws difference format left len lower ltrim nchar patindex quotename replace replicate reverse right rtrim soundex space str string_agg string_escape stuff substring translate trim unicode upper $partition @@error @@identity @@pack_received @@rowcount @@trancount binary_checksum checksum compress connectionproperty context_info current_request_id current_transaction_id decompress error_line error_message error_number error_procedure error_severity error_state formatmessage get_filestream_transaction_context getansinull host_id host_name isnull isnumeric min_active_rowversion newid newsequentialid rowcount_big session_context xact_state @@connections @@cpu_busy @@idle @@io_busy @@pack_sent @@packet_errors @@timeticks @@total_errors @@total_read @@total_write textptr textvalid columns_updated eventdata trigger_nestlevel vector_distance vectorproperty vector_search generate_series opendatasource openjson openquery openrowset openxml predict string_split coalesce nullif apply catch filter force include keep keepfixed modify optimize parameterization parameters partition recompile sequence set",Xyt=Jh.define({keywords:vm+"add external procedure all fetch public alter file raiserror and fillfactor read any for readtext as foreign reconfigure asc freetext references authorization freetexttable replication backup from restore begin full restrict between function return break goto revert browse grant revoke bulk group right by having rollback cascade holdlock rowcount case identity rowguidcol check identity_insert rule checkpoint identitycol save close if schema clustered in securityaudit coalesce index select collate inner semantickeyphrasetable column insert semanticsimilaritydetailstable commit intersect semanticsimilaritytable compute into session_user constraint is set contains join setuser containstable key shutdown continue kill some convert left statistics create like system_user cross lineno table current load tablesample current_date merge textsize current_time national then current_timestamp nocheck to current_user nonclustered top cursor not tran database null transaction dbcc nullif trigger deallocate of truncate declare off try_convert default offsets tsequal delete on union deny open unique desc opendatasource unpivot disk openquery update distinct openrowset updatetext distributed openxml use double option user drop or values dump order varying else outer view end over waitfor errlvl percent when escape pivot where except plan while exec precision with execute primary within group exists print writetext exit proc noexpand index forceseek forcescan holdlock nolock nowait paglock readcommitted readcommittedlock readpast readuncommitted repeatableread rowlock serializable snapshot spatial_window_max_cells tablock tablockx updlock xlock keepidentity keepdefaults ignore_constraints ignore_triggers",types:ym+"smalldatetime datetimeoffset datetime2 datetime bigint smallint smallmoney tinyint money real text nvarchar ntext varbinary image hierarchyid uniqueidentifier sql_variant xml",builtin:kXe,operatorChars:"*+-%<>!=^&|/",specialVar:"@",identifierQuotes:'"['}),CXe=Jh.define({keywords:vm+"abort analyze attach autoincrement conflict database detach exclusive fail glob ignore index indexed instead isnull notnull offset plan pragma query raise regexp reindex rename replace temp vacuum virtual",types:ym+"bool blob long longblob longtext medium mediumblob mediumint mediumtext tinyblob tinyint tinytext text bigint int2 int8 unsigned signed real",builtin:"auth backup bail changes clone databases dbinfo dump echo eqp explain fullschema headers help import imposter indexes iotrace lint load log mode nullvalue once print prompt quit restore save scanstats separator shell show stats system tables testcase timeout timer trace vfsinfo vfslist vfsname width",operatorChars:"*+-%<>!=&|/~",identifierQuotes:'`"',specialVar:"@:?$"}),Jyt=Jh.define({keywords:"add all allow alter and any apply as asc authorize batch begin by clustering columnfamily compact consistency count create custom delete desc distinct drop each_quorum exists filtering from grant if in index insert into key keyspace keyspaces level limit local_one local_quorum modify nan norecursive nosuperuser not of on one order password permission permissions primary quorum rename revoke schema select set storage superuser table three to token truncate ttl two type unlogged update use user users using values where with writetime infinity NaN",types:ym+"ascii bigint blob counter frozen inet list map static text timeuuid tuple uuid varint",slashComments:!0}),Zyt=Jh.define({keywords:vm+"abort accept access add all alter and any arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body by case cast char_base check close cluster clusters colauth column comment commit compress connected constant constraint crash create current currval cursor data_base database dba deallocate debugoff debugon declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry exception exception_init exchange exclusive exists external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base of off offline on online only option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw rebuild record ref references refresh rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work",builtin:"appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define echo editfile embedded feedback flagger flush heading headsep instance linesize lno loboffset logsource longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar repfooter repheader serveroutput shiftinout show showmode spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout timing trimout trimspool ttitle underline verify version wrap",types:ym+"ascii bfile bfilename bigserial bit blob dec long number nvarchar nvarchar2 serial smallint string text uid varchar2 xml",operatorChars:"*/+-%<>!=~",doubleQuotedStrings:!0,charSetCasts:!0,plsqlQuotingMechanism:!0}),xY=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},Yb=class Qae{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let i=r.facet(du).markerFilter;i&&(t=i(t,r));let o=t.slice().sort((f,p)=>f.from-p.from||f.to-p.to),s=new sm,a=[],l=0,u=r.doc.iter(),c=0,d=r.doc.length;for(let f=0;;){let p=f==o.length?null:o[f];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((b,w)=>Math.min(b,w.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>d)break;g=p.to,a.push(p),f++}for(;f<o.length;){let b=o[f];if(b.from==m&&(b.to>b.from||b.to==m))a.push(b),f++,g=Math.min(b.to,g);else{g=Math.min(b.from,g);break}}g=Math.min(g,d);let y=!1;if(a.some(b=>b.from==m&&(b.to==g||g==d))&&(y=m==g,!y&&g-m<10)){let b=m-(c+u.value.length);b>0&&(u.next(b),c=m);for(let w=m;;){if(w>=g){y=!0;break}if(!u.lineBreak&&c+u.value.length>w)break;w=c+u.value.length,c+=u.value.length,u.next()}}let v=rle(a);if(y)s.add(m,m,Qe.widget({widget:new IXe(v),diagnostics:a.slice()}));else{let b=a.reduce((w,x)=>x.markClass?w+" "+x.markClass:w,"");s.add(m,g,Qe.mark({class:"cm-lintRange cm-lintRange-"+v+b,diagnostics:a.slice(),inclusiveEnd:a.some(w=>w.to>g)}))}if(l=g,l==d)break;for(let b=0;b<a.length;b++)a[b].to<=l&&a.splice(b--,1)}let h=s.finish();return new Qae(h,n,Bh(h))}};function Bh(e,t=null,n=0){let r=null;return e.between(n,1e9,(i,o,{spec:s})=>{if(!(t&&s.diagnostics.indexOf(t)<0))if(!r)r=new xY(i,o,t||s.diagnostics[0]);else{if(s.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new xY(r.from,o,r.diagnostic)}}),r}function Gae(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(du).hideOn(e,n,r);if(i!=null)return i;let o=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(s=>s.is($E))||e.changes.touchesRange(o.from,Math.max(o.to,r)))}function Xae(e,t){return e.field(Ds,!1)?t:t.concat(St.appendConfig.of(sle))}function NXe(e,t){return{effects:Xae(e,[$E.of(t)])}}var $E=St.define(),a3=St.define(),Jae=St.define(),Ds=uo.define({create(){return new Yb(Qe.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let o=t.changes.mapPos(e.selected.from,1);r=Bh(n,e.selected.diagnostic,o)||Bh(n,null,o)}!n.size&&i&&t.state.facet(du).autoPanel&&(i=null),e=new Yb(n,i,r)}for(let n of t.effects)if(n.is($E)){let r=t.state.facet(du).autoPanel?n.value.length?BB.open:null:e.panel;e=Yb.init(n.value,r,t.state)}else n.is(a3)?e=new Yb(e.diagnostics,n.value?BB.open:null,e.selected):n.is(Jae)&&(e=new Yb(e.diagnostics,e.panel,n.value));return e},provide:e=>[Px.from(e,t=>t.panel),ke.decorations.from(e,t=>t.diagnostics)]}),MXe=Qe.mark({class:"cm-lintRange cm-lintRange-active"});function _Xe(e,t,n){let{diagnostics:r}=e.state.field(Ds),i,o=-1,s=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(l,u,{spec:c})=>{if(t>=l&&t<=u&&(l==u||(t>l||n>0)&&(t<u||n<0)))return i=c.diagnostics,o=l,s=u,!1});let a=e.state.facet(du).tooltipFilter;return i&&a&&(i=a(i,e.state)),i?{pos:o,end:s,above:e.state.doc.lineAt(o).to<s,create(){return{dom:Zae(e,i)}}}:null}function Zae(e,t){return xn("ul",{class:"cm-tooltip-lint"},t.map(n=>tle(e,n,!1)))}var EXe=e=>{let t=e.state.field(Ds,!1);(!t||!t.panel)&&e.dispatch({effects:Xae(e.state,[a3.of(!0)])});let n=J5(e,BB.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},SY=e=>{let t=e.state.field(Ds,!1);return!t||!t.panel?!1:(e.dispatch({effects:a3.of(!1)}),!0)},OXe=e=>{let t=e.state.field(Ds,!1);if(!t)return!1;let n=e.state.selection.main,r=Bh(t.diagnostics,null,n.to+1);return!r&&(r=Bh(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},TXe=[{key:"Mod-Shift-m",run:EXe,preventDefault:!0},{key:"F8",run:OXe}],AXe=Jr.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(du);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(e<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-e);else{this.set=!1;let{state:t}=this.view,{sources:n}=t.facet(du);n.length&&DXe(n.map(r=>Promise.resolve(r(this.view))),r=>{this.view.state.doc==t.doc&&this.view.dispatch(NXe(this.view.state,r.reduce((i,o)=>i.concat(o))))},r=>{Ao(this.view.state,r)})}}update(e){let t=e.state.facet(du);(e.docChanged||t!=e.startState.facet(du)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function DXe(e,t,n){let r=[],i=-1;for(let o of e)o.then(s=>{r.push(s),clearTimeout(i),r.length==e.length?t(r):i=setTimeout(()=>t(r),200)},n)}var du=Te.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...kl(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:kY,tooltipFilter:kY,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,i,o)=>t(r,i,o)||n(r,i,o):t:n,autoPanel:(t,n)=>t||n})}}});function kY(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function RXe(e,t={}){return[du.of({source:e,config:t}),AXe,sle]}function ele(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let i=n[r];if(/[a-zA-Z]/.test(i)&&!t.some(o=>o.toLowerCase()==i.toLowerCase())){t.push(i);continue e}}t.push("")}return t}function tle(e,t,n){var r;let i=n?ele(t.actions):[];return xn("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},xn("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((o,s)=>{let a=!1,l=f=>{if(f.preventDefault(),a)return;a=!0;let p=Bh(e.state.field(Ds).diagnostics,t);p&&o.apply(e,p.from,p.to)},{name:u}=o,c=i[s]?u.indexOf(i[s]):-1,d=c<0?u:[u.slice(0,c),xn("u",u.slice(c,c+1)),u.slice(c+1)],h=o.markClass?" "+o.markClass:"";return xn("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[s]})"`}.`},d)}),t.source&&xn("div",{class:"cm-diagnosticSource"},t.source))}var IXe=class extends Tu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return xn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},CY=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=tle(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},BB=class nle{constructor(t){this.view=t,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)SY(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=ele(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==i.keyCode){let l=Bh(this.view.state.field(Ds).diagnostics,o);l&&o.actions[a].apply(t,l.from,l.to)}}else return;i.preventDefault()}},r=i=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(i.target)&&this.moveSelection(o)};this.list=xn("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=xn("div",{class:"cm-panel-lint"},this.list,xn("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>SY(this.view)},"\xD7")),this.update()}get selectedIndex(){let t=this.view.state.field(Ds).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(Ds),r=0,i=!1,o=null,s=new Set;for(t.between(0,this.view.state.doc.length,(a,l,{spec:u})=>{for(let c of u.diagnostics){if(s.has(c))continue;s.add(c);let d=-1,h;for(let f=r;f<this.items.length;f++)if(this.items[f].diagnostic==c){d=f;break}d<0?(h=new CY(this.view,c),this.items.splice(r,0,h),i=!0):(h=this.items[d],d>r&&(this.items.splice(r,d-r),i=!0)),n&&h.diagnostic==n.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();this.items.length==0&&(this.items.push(new CY(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let u=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/u:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(Ds),r=Bh(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Jae.of(r)})}static open(t){return new nle(t)}};function aM(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function fN(e){return aM(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var PXe=ke.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:fN("#d11")},".cm-lintRange-warning":{backgroundImage:fN("orange")},".cm-lintRange-info":{backgroundImage:fN("#999")},".cm-lintRange-hint":{backgroundImage:fN("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function LXe(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function rle(e){let t="hint",n=1;for(let r of e){let i=LXe(r.severity);i>n&&(n=i,t=r.severity)}return t}var ile=class extends Su{constructor(e){super(),this.diagnostics=e,this.severity=rle(e)}toDOM(e){let t=document.createElement("div");t.className="cm-lint-marker cm-lint-marker-"+this.severity;let n=this.diagnostics,r=e.state.facet(KE).tooltipFilter;return r&&(n=r(n,e.state)),n.length&&(t.onmouseover=()=>qXe(e,t,n)),t}};function BXe(e,t){let n=r=>{let i=t.getBoundingClientRect();if(!(r.clientX>i.left-10&&r.clientX<i.right+10&&r.clientY>i.top-10&&r.clientY<i.bottom+10)){for(let o=r.target;o;o=o.parentNode)if(o.nodeType==1&&o.classList.contains("cm-tooltip-lint"))return;window.removeEventListener("mousemove",n),e.state.field(ole)&&e.dispatch({effects:l3.of(null)})}};window.addEventListener("mousemove",n)}function qXe(e,t,n){function r(){let s=e.elementAtHeight(t.getBoundingClientRect().top+5-e.documentTop);e.coordsAtPos(s.from)&&e.dispatch({effects:l3.of({pos:s.from,above:!1,clip:!1,create(){return{dom:Zae(e,n),getCoords:()=>t.getBoundingClientRect()}}})}),t.onmouseout=t.onmousemove=null,BXe(e,t)}let{hoverTime:i}=e.state.facet(KE),o=setTimeout(r,i);t.onmouseout=()=>{clearTimeout(o),t.onmouseout=t.onmousemove=null},t.onmousemove=()=>{clearTimeout(o),o=setTimeout(r,i)}}function zXe(e,t){let n=Object.create(null);for(let i of t){let o=e.lineAt(i.from);(n[o.from]||(n[o.from]=[])).push(i)}let r=[];for(let i in n)r.push(new ile(n[i]).range(+i));return hn.of(r,!0)}var FXe=rae({class:"cm-gutter-lint",markers:e=>e.state.field(qB),widgetMarker:(e,t,n)=>{let r=[];return e.state.field(qB).between(n.from,n.to,(i,o,s)=>{i>n.from&&i<n.to&&r.push(...s.diagnostics)}),r.length?new ile(r):null}}),qB=uo.define({create(){return hn.empty},update(e,t){e=e.map(t.changes);let n=t.state.facet(KE).markerFilter;for(let r of t.effects)if(r.is($E)){let i=r.value;n&&(i=n(i||[],t.state)),e=zXe(t.state.doc,i.slice(0))}return e}}),l3=St.define(),ole=uo.define({create(){return null},update(e,t){return e&&t.docChanged&&(e=Gae(t,e)?null:{...e,pos:t.changes.mapPos(e.pos)}),t.effects.reduce((n,r)=>r.is(l3)?r.value:n,e)},provide:e=>jE.from(e)}),jXe=ke.baseTheme({".cm-gutter-lint":{width:"1.4em","& .cm-gutterElement":{padding:".2em"}},".cm-lint-marker":{width:"1em",height:"1em"},".cm-lint-marker-info":{content:aM('<path fill="#aaf" stroke="#77e" stroke-width="6" stroke-linejoin="round" d="M5 5L35 5L35 35L5 35Z"/>')},".cm-lint-marker-warning":{content:aM('<path fill="#fe8" stroke="#fd7" stroke-width="6" stroke-linejoin="round" d="M20 6L37 35L3 35Z"/>')},".cm-lint-marker-error":{content:aM('<circle cx="20" cy="20" r="15" fill="#f87" stroke="#f43" stroke-width="6"/>')}}),sle=[Ds,ke.decorations.compute([Ds],e=>{let{selected:t,panel:n}=e.field(Ds);return!t||!n||t.from==t.to?Qe.none:Qe.set([MXe.range(t.from,t.to)])}),pYe(_Xe,{hideOn:Gae}),PXe],KE=Te.define({combine(e){return kl(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})}});function VXe(e={}){return[KE.of(e),qB,FXe,jXe,ole]}function zB(){return zB=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},zB.apply(null,arguments)}function WXe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var UXe=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=c3(e.state,n.from);return r.line?HXe(e):r.block?KXe(e):!1};function u3(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var HXe=u3(GXe,0),$Xe=u3(ale,0),KXe=u3((e,t)=>ale(e,t,QXe(t)),0);function c3(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}var Qb=50;function YXe(e,{open:t,close:n},r,i){let o=e.sliceDoc(r-Qb,r),s=e.sliceDoc(i,i+Qb),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,u=o.length-a;if(o.slice(u-t.length,u)==t&&s.slice(l,l+n.length)==n)return{open:{pos:r-a,margin:a&&1},close:{pos:i+l,margin:l&&1}};let c,d;i-r<=2*Qb?c=d=e.sliceDoc(r,i):(c=e.sliceDoc(r,r+Qb),d=e.sliceDoc(i-Qb,i));let h=/^\s*/.exec(c)[0].length,f=/\s*$/.exec(d)[0].length,p=d.length-f-n.length;return c.slice(h,h+t.length)==t&&d.slice(p,p+n.length)==n?{open:{pos:r+h+t.length,margin:/\s/.test(c.charAt(h+t.length))?1:0},close:{pos:i-f-n.length,margin:/\s/.test(d.charAt(p-1))?1:0}}:null}function QXe(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let o=t.length-1;o>=0&&t[o].to>r.from?t[o].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function ale(e,t,n=t.selection.ranges){let r=n.map(o=>c3(t,o.from).block);if(!r.every(o=>o))return null;let i=n.map((o,s)=>YXe(t,r[s],o.from,o.to));if(e!=2&&!i.every(o=>o))return{changes:t.changes(n.map((o,s)=>i[s]?[]:[{from:o.from,insert:r[s].open+" "},{from:o.to,insert:" "+r[s].close}]))};if(e!=1&&i.some(o=>o)){let o=[];for(let s=0,a;s<i.length;s++)if(a=i[s]){let l=r[s],{open:u,close:c}=a;o.push({from:u.pos-l.open.length,to:u.pos+u.margin},{from:c.pos-c.margin,to:c.pos+l.close.length})}return{changes:o}}return null}function GXe(e,t,n=t.selection.ranges){let r=[],i=-1;e:for(let{from:o,to:s}of n){let a=r.length,l=1e9,u;for(let c=o;c<=s;){let d=t.doc.lineAt(c);if(u==null&&(u=c3(t,d.from).line,!u))continue e;if(d.from>i&&(o==s||s>d.from)){i=d.from;let h=/^\s*/.exec(d.text)[0].length,f=h==d.length,p=d.text.slice(h,h+u.length)==u?h:-1;h<d.text.length&&h<l&&(l=h),r.push({line:d,comment:p,token:u,indent:h,empty:f,single:!1})}c=d.to+1}if(l<1e9)for(let c=a;c<r.length;c++)r[c].indent<r[c].line.text.length&&(r[c].indent=l);r.length==a+1&&(r[a].single=!0)}if(e!=2&&r.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:u,empty:c,single:d}of r)(d||!c)&&o.push({from:a.from+u,insert:l+" "});let s=t.changes(o);return{changes:s,selection:t.selection.map(s,1)}}else if(e!=1&&r.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of r)if(a>=0){let u=s.from+a,c=u+l.length;s.text[c-s.from]==" "&&c++,o.push({from:u,to:c})}return{changes:o}}return null}var FB=Ou.define(),XXe=Ou.define(),JXe=Te.define(),lle=Te.define({combine(e){return kl(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,i)=>t(r,i)||n(r,i)})}}),ule=uo.define({create(){return $w.empty},update(e,t){let n=t.state.facet(lle),r=t.annotation(FB);if(r){let l=Mc.fromTransaction(t,r.selection),u=r.side,c=u==0?e.undone:e.done;return l?c=m_(c,c.length,n.minDepth,l):c=hle(c,t.startState.selection),new $w(u==0?r.rest:c,u==0?c:r.rest)}let i=t.annotation(XXe);if((i=="full"||i=="before")&&(e=e.isolate()),t.annotation(ts.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let o=Mc.fromTransaction(t),s=t.annotation(ts.time),a=t.annotation(ts.userEvent);return o?e=e.addChanges(o,s,a,n,t):t.selection&&(e=e.addSelection(t.startState.selection,s,a,n.newGroupDelay)),(i=="full"||i=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new $w(e.done.map(Mc.fromJSON),e.undone.map(Mc.fromJSON))}});function ZXe(e={}){return[ule,lle.of(e),ke.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?cle:t.inputType=="historyRedo"?jB:null;return r?(t.preventDefault(),r(n)):!1}})]}function YE(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(ule,!1);if(!i)return!1;let o=i.pop(e,n,t);return o?(r(o),!0):!1}}var cle=YE(0,!1),jB=YE(1,!1),eJe=YE(0,!0),tJe=YE(1,!0),Mc=class xw{constructor(t,n,r,i,o){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=o}setSelAfter(t){return new xw(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(t){return new xw(t.changes&&ml.fromJSON(t.changes),[],t.mapped&&Iy.fromJSON(t.mapped),t.startSelection&&ae.fromJSON(t.startSelection),t.selectionsAfter.map(ae.fromJSON))}static fromTransaction(t,n){let r=ba;for(let i of t.startState.facet(JXe)){let o=i(t);o.length&&(r=r.concat(o))}return!r.length&&t.changes.empty?null:new xw(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,ba)}static selection(t){return new xw(void 0,ba,void 0,void 0,t)}};function m_(e,t,n,r){let i=t+1>n+20?t-n-1:0,o=e.slice(i,t);return o.push(r),o}function nJe(e,t){let n=[],r=!1;return e.iterChangedRanges((i,o)=>n.push(i,o)),t.iterChangedRanges((i,o,s,a)=>{for(let l=0;l<n.length;){let u=n[l++],c=n[l++];a>=u&&s<=c&&(r=!0)}}),r}function rJe(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function dle(e,t){return e.length?t.length?e.concat(t):e:t}var ba=[],iJe=200;function hle(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-iJe));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),m_(e,e.length-1,1e9,n.setSelAfter(r)))}else return[Mc.selection([t])]}function oJe(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function sI(e,t){if(!e.length)return e;let n=e.length,r=ba;for(;n;){let i=sJe(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let o=e.slice(0,n);return o[n-1]=i,o}else t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Mc.selection(r)]:ba}function sJe(e,t,n){let r=dle(e.selectionsAfter.length?e.selectionsAfter.map(a=>a.map(t)):ba,n);if(!e.changes)return Mc.selection(r);let i=e.changes.map(t),o=t.mapDesc(e.changes,!0),s=e.mapped?e.mapped.composeDesc(o):o;return new Mc(i,St.mapEffects(e.effects,t),s,e.startSelection.map(o),r)}var aJe=/^(input\.type|delete)($|\.)/,$w=class Sw{constructor(t,n,r=0,i=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new Sw(this.done,this.undone):this}addChanges(t,n,r,i,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&t.changes&&(!r||aJe.test(r))&&(!a.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(o,nJe(a.changes,t.changes))||r=="input.type.compose")?s=m_(s,s.length-1,i.minDepth,new Mc(t.changes.compose(a.changes),dle(St.mapEffects(t.effects,a.changes),a.effects),a.mapped,a.startSelection,ba)):s=m_(s,s.length,i.minDepth,t),new Sw(s,ba,n,r)}addSelection(t,n,r,i){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:ba;return o.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&rJe(o[o.length-1],t)?this:new Sw(hle(this.done,t),this.undone,n,r)}addMapping(t){return new Sw(sI(this.done,t),sI(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let i=t==0?this.done:this.undone;if(i.length==0)return null;let o=i[i.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):n.selection);if(r&&o.selectionsAfter.length)return n.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:FB.of({side:t,rest:oJe(i),selection:s}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=i.length==1?ba:i.slice(0,i.length-1);return o.mapped&&(a=sI(a,o.mapped)),n.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:FB.of({side:t,rest:a,selection:s}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}};$w.empty=new $w(ba,ba);var lJe=[{key:"Mod-z",run:cle,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:jB,preventDefault:!0},{linux:"Ctrl-Shift-z",run:jB,preventDefault:!0},{key:"Mod-u",run:eJe,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:tJe,preventDefault:!0}];function Pv(e,t){return ae.create(e.ranges.map(t),e.mainIndex)}function Cl(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function Nl({state:e,dispatch:t},n){let r=Pv(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Cl(e,r)),!0)}function QE(e,t){return ae.cursor(t?e.to:e.from)}function fle(e,t){return Nl(e,n=>n.empty?e.moveByChar(n,t):QE(n,t))}function co(e){return e.textDirectionAt(e.state.selection.main.head)==On.LTR}var ple=e=>fle(e,!co(e)),mle=e=>fle(e,co(e));function gle(e,t){return Nl(e,n=>n.empty?e.moveByGroup(n,t):QE(n,t))}var uJe=e=>gle(e,!co(e)),cJe=e=>gle(e,co(e)),evt=typeof Intl<"u"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function dJe(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function GE(e,t,n){let r=Ei(e).resolveInner(t.head),i=n?Pt.closedBy:Pt.openedBy;for(let l=t.head;;){let u=n?r.childAfter(l):r.childBefore(l);if(!u)break;dJe(e,u,i)?r=u:l=n?u.to:u.from}let o=r.type.prop(i),s,a;return o&&(s=n?cu(e,r.from,1):cu(e,r.to,-1))&&s.matched?a=n?s.end.to:s.end.from:a=n?r.to:r.from,ae.cursor(a,n?-1:1)}var hJe=e=>Nl(e,t=>GE(e.state,t,!co(e))),fJe=e=>Nl(e,t=>GE(e.state,t,co(e)));function yle(e,t){return Nl(e,n=>{if(!n.empty)return QE(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}var vle=e=>yle(e,!1),ble=e=>yle(e,!0);function wle(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let o of e.state.facet(ke.scrollMargins)){let s=o(e);s?.top&&(n=Math.max(s?.top,n)),s?.bottom&&(r=Math.max(s?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function xle(e,t){let n=wle(e),{state:r}=e,i=Pv(r.selection,s=>s.empty?e.moveVertically(s,t,n.height):QE(s,t));if(i.eq(r.selection))return!1;let o;if(n.selfScroll){let s=e.coordsAtPos(r.selection.main.head),a=e.scrollDOM.getBoundingClientRect(),l=a.top+n.marginTop,u=a.bottom-n.marginBottom;s&&s.top>l&&s.bottom<u&&(o=ke.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-l}))}return e.dispatch(Cl(r,i),{effects:o}),!0}var NY=e=>xle(e,!1),VB=e=>xle(e,!0);function ef(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let o=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;o&&t.head!=r.from+o&&(i=ae.cursor(r.from+o))}return i}var pJe=e=>Nl(e,t=>ef(e,t,!0)),mJe=e=>Nl(e,t=>ef(e,t,!1)),gJe=e=>Nl(e,t=>ef(e,t,!co(e))),yJe=e=>Nl(e,t=>ef(e,t,co(e))),vJe=e=>Nl(e,t=>ae.cursor(e.lineBlockAt(t.head).from,1)),bJe=e=>Nl(e,t=>ae.cursor(e.lineBlockAt(t.head).to,-1));function wJe(e,t,n){let r=!1,i=Pv(e.selection,o=>{let s=cu(e,o.head,-1)||cu(e,o.head,1)||o.head>0&&cu(e,o.head-1,1)||o.head<e.doc.length&&cu(e,o.head+1,-1);if(!s||!s.end)return o;r=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return n?ae.range(o.anchor,a):ae.cursor(a)});return r?(t(Cl(e,i)),!0):!1}var xJe=({state:e,dispatch:t})=>wJe(e,t,!1);function Aa(e,t){let n=Pv(e.state.selection,r=>{let i=t(r);return ae.range(r.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return n.eq(e.state.selection)?!1:(e.dispatch(Cl(e.state,n)),!0)}function Sle(e,t){return Aa(e,n=>e.moveByChar(n,t))}var kle=e=>Sle(e,!co(e)),Cle=e=>Sle(e,co(e));function Nle(e,t){return Aa(e,n=>e.moveByGroup(n,t))}var SJe=e=>Nle(e,!co(e)),kJe=e=>Nle(e,co(e)),CJe=e=>Aa(e,t=>GE(e.state,t,!co(e))),NJe=e=>Aa(e,t=>GE(e.state,t,co(e)));function Mle(e,t){return Aa(e,n=>e.moveVertically(n,t))}var _le=e=>Mle(e,!1),Ele=e=>Mle(e,!0);function Ole(e,t){return Aa(e,n=>e.moveVertically(n,t,wle(e).height))}var MY=e=>Ole(e,!1),_Y=e=>Ole(e,!0),MJe=e=>Aa(e,t=>ef(e,t,!0)),_Je=e=>Aa(e,t=>ef(e,t,!1)),EJe=e=>Aa(e,t=>ef(e,t,!co(e))),OJe=e=>Aa(e,t=>ef(e,t,co(e))),TJe=e=>Aa(e,t=>ae.cursor(e.lineBlockAt(t.head).from)),AJe=e=>Aa(e,t=>ae.cursor(e.lineBlockAt(t.head).to)),EY=({state:e,dispatch:t})=>(t(Cl(e,{anchor:0})),!0),OY=({state:e,dispatch:t})=>(t(Cl(e,{anchor:e.doc.length})),!0),TY=({state:e,dispatch:t})=>(t(Cl(e,{anchor:e.selection.main.anchor,head:0})),!0),AY=({state:e,dispatch:t})=>(t(Cl(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),DJe=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),RJe=({state:e,dispatch:t})=>{let n=XE(e).map(({from:r,to:i})=>ae.range(r,Math.min(i+1,e.doc.length)));return t(e.update({selection:ae.create(n),userEvent:"select"})),!0},IJe=({state:e,dispatch:t})=>{let n=Pv(e.selection,r=>{let i=Ei(e),o=i.resolveStack(r.from,1);if(r.empty){let s=i.resolveStack(r.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<r.from&&a.to>=r.to||a.to>r.to&&a.from<=r.from)&&s.next)return ae.range(a.to,a.from)}return r});return n.eq(e.selection)?!1:(t(Cl(e,n)),!0)};function Tle(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let o of n.selection.ranges){let s=n.doc.lineAt(o.head);if(t?s.to<e.state.doc.length:s.from>0)for(let a=o;;){let l=e.moveVertically(a,t);if(l.head<s.from||l.head>s.to){i.some(u=>u.head==l.head)||i.push(l);break}else{if(l.head==a.head)break;a=l}}}return i.length==r.ranges.length?!1:(e.dispatch(Cl(n,ae.create(i,i.length-1))),!0)}var PJe=e=>Tle(e,!1),LJe=e=>Tle(e,!0),BJe=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=ae.create([n.main]):n.main.empty||(r=ae.create([ae.cursor(n.main.head)])),r?(t(Cl(e,r)),!0):!1};function S1(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,i=r.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=t(o);l<s?(n="delete.backward",l=pN(e,l,!1)):l>s&&(n="delete.forward",l=pN(e,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=pN(e,s,!1),a=pN(e,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:ae.cursor(s,s<o.head?-1:1)}});return i.changes.empty?!1:(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?ke.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function pN(e,t,n){if(e instanceof ke)for(let r of e.state.facet(ke.atomicRanges).map(i=>i(e)))r.between(t,t,(i,o)=>{i<t&&o>t&&(t=n?o:i)});return t}var Ale=(e,t,n)=>S1(e,r=>{let i=r.from,{state:o}=e,s=o.doc.lineAt(i),a,l;if(n&&!t&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,i-s.from))){if(a[a.length-1]==" ")return i-1;let u=Iv(a,o.tabSize),c=u%c_(o)||c_(o);for(let d=0;d<c&&a[a.length-1-d]==" ";d++)i--;l=i}else l=Mi(s.text,i-s.from,t,t)+s.from,l==i&&s.number!=(t?o.doc.lines:1)?l+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,i-s.from))&&(l=Mi(s.text,l-s.from,!1,!1)+s.from);return l}),WB=e=>Ale(e,!1,!0),Dle=e=>Ale(e,!0,!1),Rle=(e,t)=>S1(e,n=>{let r=n.head,{state:i}=e,o=i.doc.lineAt(r),s=i.charCategorizer(r);for(let a=null;;){if(r==(t?o.to:o.from)){r==n.head&&o.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let l=Mi(o.text,r-o.from,t)+o.from,u=o.text.slice(Math.min(r,l)-o.from,Math.max(r,l)-o.from),c=s(u);if(a!=null&&c!=a)break;(u!=" "||r!=n.head)&&(a=c),r=l}return r}),Ile=e=>Rle(e,!1),qJe=e=>Rle(e,!0),zJe=e=>S1(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),FJe=e=>S1(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),jJe=e=>S1(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),VJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:sn.of(["",""])},range:ae.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},WJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let i=r.from,o=e.doc.lineAt(i),s=i==o.from?i-1:Mi(o.text,i-o.from,!1)+o.from,a=i==o.to?i+1:Mi(o.text,i-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:e.doc.slice(i,a).append(e.doc.slice(s,i))},range:ae.cursor(a)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function XE(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),o=e.doc.lineAt(r.to);if(!r.empty&&r.to==o.from&&(o=e.doc.lineAt(r.to-1)),n>=i.number){let s=t[t.length-1];s.to=o.to,s.ranges.push(r)}else t.push({from:i.from,to:o.to,ranges:[r]});n=o.number+1}return t}function Ple(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let o of XE(e)){if(n?o.to==e.doc.length:o.from==0)continue;let s=e.doc.lineAt(n?o.to+1:o.from-1),a=s.length+1;if(n){r.push({from:o.to,to:s.to},{from:o.from,insert:s.text+e.lineBreak});for(let l of o.ranges)i.push(ae.range(Math.min(e.doc.length,l.anchor+a),Math.min(e.doc.length,l.head+a)))}else{r.push({from:s.from,to:o.from},{from:o.to,insert:e.lineBreak+s.text});for(let l of o.ranges)i.push(ae.range(l.anchor-a,l.head-a))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:ae.create(i,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}var UJe=({state:e,dispatch:t})=>Ple(e,t,!1),HJe=({state:e,dispatch:t})=>Ple(e,t,!0);function Lle(e,t,n){if(e.readOnly)return!1;let r=[];for(let o of XE(e))n?r.push({from:o.from,insert:e.doc.slice(o.from,o.to)+e.lineBreak}):r.push({from:o.to,insert:e.lineBreak+e.doc.slice(o.from,o.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var $Je=({state:e,dispatch:t})=>Lle(e,t,!1),KJe=({state:e,dispatch:t})=>Lle(e,t,!0),YJe=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(XE(t).map(({from:i,to:o})=>(i>0?i--:o<t.doc.length&&o++,{from:i,to:o}))),r=Pv(t.selection,i=>{let o;if(e.lineWrapping){let s=e.lineBlockAt(i.head),a=e.coordsAtPos(i.head,i.assoc||1);a&&(o=s.bottom+e.documentTop-a.bottom+e.defaultLineHeight/2)}return e.moveVertically(i,!0,o)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function QJe(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=Ei(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),o;return r&&i&&r.to<=t&&i.from>=t&&(o=r.type.prop(Pt.closedBy))&&o.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var DY=Ble(!1),GJe=Ble(!0);function Ble(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(i=>{let{from:o,to:s}=i,a=t.doc.lineAt(o),l=!e&&o==s&&QJe(t,o);e&&(o=s=(s<=a.to?a:t.doc.lineAt(s)).to);let u=new WE(t,{simulateBreak:o,simulateDoubleBreak:!!l}),c=Z5(u,o);for(c==null&&(c=Iv(/^\s*/.exec(t.doc.lineAt(o).text)[0],t.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let d=["",Bx(t,c)];return l&&d.push(Bx(t,u.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:sn.of(d)},range:ae.cursor(o+1+d[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function d3(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let s=r.from;s<=r.to;){let a=e.doc.lineAt(s);a.number>n&&(r.empty||r.to>a.from)&&(t(a,i,r),n=a.number),s=a.to+1}let o=e.changes(i);return{changes:i,range:ae.range(o.mapPos(r.anchor,1),o.mapPos(r.head,1))}})}var XJe=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new WE(e,{overrideIndentation:o=>n[o]??-1}),i=d3(e,(o,s,a)=>{let l=Z5(r,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let u=/^\s*/.exec(o.text)[0],c=Bx(e,l);(u!=c||a.from<o.from+u.length)&&(n[o.from]=l,s.push({from:o.from,to:o.from+u.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:"indent"})),!0},qle=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(d3(e,(n,r)=>{r.push({from:n.from,insert:e.facet(VE)})}),{userEvent:"input.indent"})),!0),zle=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(d3(e,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let o=Iv(i,e.tabSize),s=0,a=Bx(e,Math.max(0,o-c_(e)));for(;s<i.length&&s<a.length&&i.charCodeAt(s)==a.charCodeAt(s);)s++;r.push({from:n.from+s,to:n.from+i.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),JJe=e=>(e.setTabFocusMode(),!0),ZJe=[{key:"Ctrl-b",run:ple,shift:kle,preventDefault:!0},{key:"Ctrl-f",run:mle,shift:Cle},{key:"Ctrl-p",run:vle,shift:_le},{key:"Ctrl-n",run:ble,shift:Ele},{key:"Ctrl-a",run:vJe,shift:TJe},{key:"Ctrl-e",run:bJe,shift:AJe},{key:"Ctrl-d",run:Dle},{key:"Ctrl-h",run:WB},{key:"Ctrl-k",run:zJe},{key:"Ctrl-Alt-h",run:Ile},{key:"Ctrl-o",run:VJe},{key:"Ctrl-t",run:WJe},{key:"Ctrl-v",run:VB}],eZe=[{key:"ArrowLeft",run:ple,shift:kle,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:uJe,shift:SJe,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:gJe,shift:EJe,preventDefault:!0},{key:"ArrowRight",run:mle,shift:Cle,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:cJe,shift:kJe,preventDefault:!0},{mac:"Cmd-ArrowRight",run:yJe,shift:OJe,preventDefault:!0},{key:"ArrowUp",run:vle,shift:_le,preventDefault:!0},{mac:"Cmd-ArrowUp",run:EY,shift:TY},{mac:"Ctrl-ArrowUp",run:NY,shift:MY},{key:"ArrowDown",run:ble,shift:Ele,preventDefault:!0},{mac:"Cmd-ArrowDown",run:OY,shift:AY},{mac:"Ctrl-ArrowDown",run:VB,shift:_Y},{key:"PageUp",run:NY,shift:MY},{key:"PageDown",run:VB,shift:_Y},{key:"Home",run:mJe,shift:_Je,preventDefault:!0},{key:"Mod-Home",run:EY,shift:TY},{key:"End",run:pJe,shift:MJe,preventDefault:!0},{key:"Mod-End",run:OY,shift:AY},{key:"Enter",run:DY,shift:DY},{key:"Mod-a",run:DJe},{key:"Backspace",run:WB,shift:WB,preventDefault:!0},{key:"Delete",run:Dle,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Ile,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:qJe,preventDefault:!0},{mac:"Mod-Backspace",run:FJe,preventDefault:!0},{mac:"Mod-Delete",run:jJe,preventDefault:!0}].concat(ZJe.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),tZe=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:hJe,shift:CJe},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:fJe,shift:NJe},{key:"Alt-ArrowUp",run:UJe},{key:"Shift-Alt-ArrowUp",run:$Je},{key:"Alt-ArrowDown",run:HJe},{key:"Shift-Alt-ArrowDown",run:KJe},{key:"Mod-Alt-ArrowUp",run:PJe},{key:"Mod-Alt-ArrowDown",run:LJe},{key:"Escape",run:BJe},{key:"Mod-Enter",run:GJe},{key:"Alt-l",mac:"Ctrl-l",run:RJe},{key:"Mod-i",run:IJe,preventDefault:!0},{key:"Mod-[",run:zle},{key:"Mod-]",run:qle},{key:"Mod-Alt-\\",run:XJe},{key:"Shift-Mod-k",run:YJe},{key:"Shift-Mod-\\",run:xJe},{key:"Mod-/",run:UXe},{key:"Alt-A",run:$Xe},{key:"Ctrl-m",mac:"Shift-Alt-m",run:JJe}].concat(eZe),nZe={key:"Tab",run:qle,shift:zle},RY=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e,uv=class{constructor(e,t,n=0,r=e.length,i,o){this.test=o,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?s=>i(RY(s)):RY,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Ko(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=P5(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=su(e);let r=this.normalize(t);if(r.length)for(let i=0,o=n;;i++){let s=r.charCodeAt(i),a=this.match(s,o,this.bufferPos+this.bufferStart);if(i==r.length-1){if(a)return this.value=a,this;break}o==n&&i<t.length&&t.charCodeAt(i)==s&&o++}}}match(e,t,n){let r=null;for(let i=0;i<this.matches.length;i+=2){let o=this.matches[i],s=!1;this.query.charCodeAt(o)==e&&(o==this.query.length-1?r={from:this.matches[i+1],to:n}:(this.matches[i]++,s=!0)),s||(this.matches.splice(i,2),i-=2)}return this.query.charCodeAt(0)==e&&(this.query.length==1?r={from:t,to:n}:this.matches.push(1,t)),r&&this.test&&!this.test(r.from,r.to,this.buffer,this.bufferStart)&&(r=null),r}};typeof Symbol<"u"&&(uv.prototype[Symbol.iterator]=function(){return this});var Fle={from:-1,to:-1,match:/.*/.exec("")},h3="gm"+(/x/.unicode==null?"":"u"),jle=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine="",this.done=!1,this.value=Fle,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new Vle(e,t,n,r,i);this.re=new RegExp(t,h3+(n?.ignoreCase?"i":"")),this.test=n?.test,this.iter=e.iter();let o=e.lineAt(r);this.curLineStart=o.from,this.matchPos=g_(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=g_(this.text,r+(n==r?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},aI=new WeakMap,IY=class lM{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let i=aI.get(t);if(!i||i.from>=r||i.to<=n){let a=new lM(n,t.sliceString(n,r));return aI.set(t,a),a}if(i.from==n&&i.to==r)return i;let{text:o,from:s}=i;return s>n&&(o=t.sliceString(n,s)+o,s=n),i.to<r&&(o+=t.sliceString(i.to,r)),aI.set(t,new lM(s,o)),new lM(n,o.slice(n-s,r-s))}},Vle=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Fle,this.matchPos=g_(e,r),this.re=new RegExp(t,h3+(n?.ignoreCase?"i":"")),this.test=n?.test,this.flat=IY.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,r=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,match:t},this.matchPos=g_(this.text,r+(n==r?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=IY.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<"u"&&(jle.prototype[Symbol.iterator]=Vle.prototype[Symbol.iterator]=function(){return this});function rZe(e){try{return new RegExp(e,h3),!0}catch{return!1}}function g_(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var iZe=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:i}=gYe(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return i.then(o=>{let s=o&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(o.elements.line.value);if(!s){e.dispatch({effects:r});return}let a=t.doc.lineAt(t.selection.main.head),[,l,u,c,d]=s,h=c?+c.slice(1):0,f=u?+u:a.number;if(u&&d){let g=f/100;l&&(g=g*(l=="-"?-1:1)+a.number/t.doc.lines),f=Math.round(t.doc.lines*g)}else u&&l&&(f=f*(l=="-"?-1:1)+a.number);let p=t.doc.line(Math.max(1,Math.min(t.doc.lines,f))),m=ae.cursor(p.from+Math.max(0,Math.min(h,p.length)));e.dispatch({effects:[r,ke.scrollIntoView(m.from,{y:"center"})],selection:m})}),!0},oZe={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Wle=Te.define({combine(e){return kl(e,oZe,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function sZe(e){let t=[dZe,cZe];return e&&t.push(Wle.of(e)),t}var aZe=Qe.mark({class:"cm-selectionMatch"}),lZe=Qe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function PY(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=rr.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=rr.Word)}function uZe(e,t,n,r){return e(t.sliceDoc(n,n+1))==rr.Word&&e(t.sliceDoc(r-1,r))==rr.Word}var cZe=Jr.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Wle),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Qe.none;let i=r.main,o,s=null;if(i.empty){if(!t.highlightWordAroundCursor)return Qe.none;let l=n.wordAt(i.head);if(!l)return Qe.none;s=n.charCategorizer(i.head),o=n.sliceDoc(l.from,l.to)}else{let l=i.to-i.from;if(l<t.minSelectionLength||l>200)return Qe.none;if(t.wholeWords){if(o=n.sliceDoc(i.from,i.to),s=n.charCategorizer(i.head),!(PY(s,n,i.from,i.to)&&uZe(s,n,i.from,i.to)))return Qe.none}else if(o=n.sliceDoc(i.from,i.to),!o)return Qe.none}let a=[];for(let l of e.visibleRanges){let u=new uv(n.doc,o,l.from,l.to);for(;!u.next().done;){let{from:c,to:d}=u.value;if((!s||PY(s,n,c,d))&&(i.empty&&c<=i.from&&d>=i.to?a.push(lZe.range(c,d)):(c>=i.to||d<=i.from)&&a.push(aZe.range(c,d)),a.length>t.maxMatches))return Qe.none}}return Qe.set(a)}},{decorations:e=>e.decorations}),dZe=ke.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),hZe=({state:e,dispatch:t})=>{let{selection:n}=e,r=ae.create(n.ranges.map(i=>e.wordAt(i.head)||ae.cursor(i.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function fZe(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),o=i&&i.from==n.from&&i.to==n.to;for(let s=!1,a=new uv(e.doc,t,r[r.length-1].to);;)if(a.next(),a.done){if(s)return null;a=new uv(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),s=!0}else{if(s&&r.some(l=>l.from==a.value.from))continue;if(o){let l=e.wordAt(a.value.from);if(!l||l.from!=a.value.from||l.to!=a.value.to)continue}return a.value}}var pZe=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(o=>o.from===o.to))return hZe({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(o=>e.sliceDoc(o.from,o.to)!=r))return!1;let i=fZe(e,r);return i?(t(e.update({selection:e.selection.addRange(ae.range(i.from,i.to),!1),effects:ke.scrollIntoView(i.to)})),!0):!1},Lv=Te.define({combine(e){return kl(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new EZe(t),scrollToMatch:t=>ke.scrollIntoView(t)})}}),Ule=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||rZe(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?`
`:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new wZe(this):new yZe(this)}getCursor(e,t=0,n){let r=e.doc?e:or.create({doc:e});return n==null&&(n=r.doc.length),this.regexp?iy(this,r,t,n):ry(this,r,t,n)}},Hle=class{constructor(e){this.spec=e}};function mZe(e,t,n){return(r,i,o,s)=>{if(n&&!n(r,i,o,s))return!1;let a=r>=s&&i<=s+o.length?o.slice(r-s,i-s):t.doc.sliceString(r,i);return e(a,t,r,i)}}function ry(e,t,n,r){let i;return e.wholeWord&&(i=gZe(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=mZe(e.test,t,i)),new uv(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:o=>o.toLowerCase(),i)}function gZe(e,t){return(n,r,i,o)=>((o>n||o+i.length<r)&&(o=Math.max(0,n-2),i=e.sliceString(o,Math.min(e.length,r+2))),(t(y_(i,n-o))!=rr.Word||t(v_(i,n-o))!=rr.Word)&&(t(v_(i,r-o))!=rr.Word||t(y_(i,r-o))!=rr.Word))}var yZe=class extends Hle{constructor(e){super(e)}nextMatch(e,t,n){let r=ry(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let i=Math.min(e.doc.length,t+this.spec.unquoted.length);r=ry(this.spec,e,0,i).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let i=Math.max(t,r-1e4-this.spec.unquoted.length),o=ry(this.spec,e,i,r),s=null;for(;!o.nextOverlapping().done;)s=o.value;if(s)return s;if(i==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||(r=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=ry(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=ry(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function vZe(e,t,n){return(r,i,o)=>(!n||n(r,i,o))&&e(o[0],t,r,i)}function iy(e,t,n,r){let i;return e.wholeWord&&(i=bZe(t.charCategorizer(t.selection.main.head))),e.test&&(i=vZe(e.test,t,i)),new jle(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function y_(e,t){return e.slice(Mi(e,t,!1),t)}function v_(e,t){return e.slice(t,Mi(e,t))}function bZe(e){return(t,n,r)=>!r[0].length||(e(y_(r.input,r.index))!=rr.Word||e(v_(r.input,r.index))!=rr.Word)&&(e(v_(r.input,r.index+r[0].length))!=rr.Word||e(y_(r.input,r.index+r[0].length))!=rr.Word)}var wZe=class extends Hle{nextMatch(e,t,n){let r=iy(this.spec,e,n,e.doc.length).next();return r.done&&(r=iy(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),o=iy(this.spec,e,i,n),s=null;for(;!o.next().done;)s=o.value;if(s&&(i==t||s.from>i+10))return s;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let r=n.length;r>0;r--){let i=+n.slice(0,r);if(i>0&&i<e.match.length)return e.match[i]+n.slice(r)}return t})}matchAll(e,t){let n=iy(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=iy(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},jx=St.define(),f3=St.define(),Sh=uo.define({create(e){return new lI(UB(e).create(),null)},update(e,t){for(let n of t.effects)n.is(jx)?e=new lI(n.value.create(),e.panel):n.is(f3)&&(e=new lI(e.query,n.value?p3:null));return e},provide:e=>Px.from(e,t=>t.panel)}),lI=class{constructor(e,t){this.query=e,this.panel=t}},xZe=Qe.mark({class:"cm-searchMatch"}),SZe=Qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),kZe=Jr.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Sh))}update(e){let t=e.state.field(Sh);(t!=e.startState.field(Sh)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Qe.none;let{view:n}=this,r=new sm;for(let i=0,o=n.visibleRanges,s=o.length;i<s;i++){let{from:a,to:l}=o[i];for(;i<s-1&&l>o[i+1].from-500;)l=o[++i].to;e.highlight(n.state,a,l,(u,c)=>{let d=n.state.selection.ranges.some(h=>h.from==u&&h.to==c);r.add(u,c,d?SZe:xZe)})}return r.finish()}},{decorations:e=>e.decorations});function k1(e){return t=>{let n=t.state.field(Sh,!1);return n&&n.query.spec.valid?e(t,n):Yle(t)}}var b_=k1((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=ae.single(r.from,r.to),o=e.state.facet(Lv);return e.dispatch({selection:i,effects:[m3(e,r),o.scrollToMatch(i.main,e)],userEvent:"select.search"}),Kle(e),!0}),w_=k1((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let o=ae.single(i.from,i.to),s=e.state.facet(Lv);return e.dispatch({selection:o,effects:[m3(e,i),s.scrollToMatch(o.main,e)],userEvent:"select.search"}),Kle(e),!0}),CZe=k1((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:ae.create(n.map(r=>ae.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),NZe=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,o=[],s=0;for(let a=new uv(e.doc,e.sliceDoc(r,i));!a.next().done;){if(o.length>1e3)return!1;a.value.from==r&&(s=o.length),o.push(ae.range(a.value.from,a.value.to))}return t(e.update({selection:ae.create(o,s),userEvent:"select.search.matches"})),!0},LY=k1((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let o=t.nextMatch(n,r,r);if(!o)return!1;let s=o,a=[],l,u,c=[];s.from==r&&s.to==i&&(u=n.toText(t.getReplacement(s)),a.push({from:s.from,to:s.to,insert:u}),s=t.nextMatch(n,s.from,s.to),c.push(ke.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+".")));let d=e.state.changes(a);return s&&(l=ae.single(s.from,s.to).map(d),c.push(m3(e,s)),c.push(n.facet(Lv).scrollToMatch(l.main,e))),e.dispatch({changes:d,selection:l,effects:c,userEvent:"input.replace"}),!0}),MZe=k1((e,{query:t})=>{if(e.state.readOnly)return!1;let n=t.matchAll(e.state,1e9).map(i=>{let{from:o,to:s}=i;return{from:o,to:s,insert:t.getReplacement(i)}});if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:ke.announce.of(r),userEvent:"input.replace.all"}),!0});function p3(e){return e.state.facet(Lv).createPanel(e)}function UB(e,t){var n,r,i,o,s;let a=e.selection.main,l=a.empty||a.to>a.from+100?"":e.sliceDoc(a.from,a.to);if(t&&!l)return t;let u=e.facet(Lv);return new Ule({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?l:l.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(i=t?.literal)!==null&&i!==void 0?i:u.literal,regexp:(o=t?.regexp)!==null&&o!==void 0?o:u.regexp,wholeWord:(s=t?.wholeWord)!==null&&s!==void 0?s:u.wholeWord})}function $le(e){let t=J5(e,p3);return t&&t.dom.querySelector("[main-field]")}function Kle(e){let t=$le(e);t&&t==e.root.activeElement&&t.select()}var Yle=e=>{let t=e.state.field(Sh,!1);if(t&&t.panel){let n=$le(e);if(n&&n!=e.root.activeElement){let r=UB(e.state,t.query.spec);r.valid&&e.dispatch({effects:jx.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[f3.of(!0),t?jx.of(UB(e.state,t.query.spec)):St.appendConfig.of(TZe)]});return!0},Qle=e=>{let t=e.state.field(Sh,!1);if(!t||!t.panel)return!1;let n=J5(e,p3);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:f3.of(!1)}),!0},_Ze=[{key:"Mod-f",run:Yle,scope:"editor search-panel"},{key:"F3",run:b_,shift:w_,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:b_,shift:w_,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Qle,scope:"editor search-panel"},{key:"Mod-Shift-l",run:NZe},{key:"Mod-Alt-g",run:iZe},{key:"Mod-d",run:pZe,preventDefault:!0}],EZe=class{constructor(e){this.view=e;let t=this.query=e.state.field(Sh).query.spec;this.commit=this.commit.bind(this),this.searchField=xn("input",{value:t.search,placeholder:Ns(e,"Find"),"aria-label":Ns(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=xn("input",{value:t.replace,placeholder:Ns(e,"Replace"),"aria-label":Ns(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=xn("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=xn("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=xn("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(r,i,o){return xn("button",{class:"cm-button",name:r,onclick:i,type:"button"},o)}this.dom=xn("div",{onkeydown:r=>this.keydown(r),class:"cm-search"},[this.searchField,n("next",()=>b_(e),[Ns(e,"next")]),n("prev",()=>w_(e),[Ns(e,"previous")]),n("select",()=>CZe(e),[Ns(e,"all")]),xn("label",null,[this.caseField,Ns(e,"match case")]),xn("label",null,[this.reField,Ns(e,"regexp")]),xn("label",null,[this.wordField,Ns(e,"by word")]),...e.state.readOnly?[]:[xn("br"),this.replaceField,n("replace",()=>LY(e),[Ns(e,"replace")]),n("replaceAll",()=>MZe(e),[Ns(e,"replace all")])],xn("button",{name:"close",onclick:()=>Qle(e),"aria-label":Ns(e,"close"),type:"button"},["\xD7"])])}commit(){let e=new Ule({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:jx.of(e)}))}keydown(e){M7e(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?w_:b_)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),LY(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(jx)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Lv).top}};function Ns(e,t){return e.state.phrase(t)}var mN=30,gN=/[\s\.,:;?!]/;function m3(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,o=Math.max(r.from,t-mN),s=Math.min(i,n+mN),a=e.state.sliceDoc(o,s);if(o!=r.from){for(let l=0;l<mN;l++)if(!gN.test(a[l+1])&&gN.test(a[l])){a=a.slice(l);break}}if(s!=i){for(let l=a.length-1;l>a.length-mN;l--)if(!gN.test(a[l-1])&&gN.test(a[l])){a=a.slice(0,l);break}}return ke.announce.of(`${e.state.phrase("current match")}. ${a} ${e.state.phrase("on line")} ${r.number}.`)}var OZe=ke.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),TZe=[Sh,Xh.low(kZe),OZe],BY=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(NGe)),e.defaultKeymap!==!1&&(n=n.concat(tZe)),e.searchKeymap!==!1&&(n=n.concat(_Ze)),e.historyKeymap!==!1&&(n=n.concat(lJe)),e.foldKeymap!==!1&&(n=n.concat(dQe)),e.completionKeymap!==!1&&(n=n.concat(qae)),e.lintKeymap!==!1&&(n=n.concat(TXe));var r=[];return e.lineNumbers!==!1&&r.push(MYe()),e.highlightActiveLineGutter!==!1&&r.push(OYe()),e.highlightSpecialChars!==!1&&r.push(W7e()),e.history!==!1&&r.push(ZXe()),e.foldGutter!==!1&&r.push(mQe()),e.drawSelection!==!1&&r.push(D7e()),e.dropCursor!==!1&&r.push(B7e()),e.allowMultipleSelections!==!1&&r.push(or.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(nQe()),e.syntaxHighlighting!==!1&&r.push(kae(bQe,{fallback:!0})),e.bracketMatching!==!1&&r.push(MQe()),e.closeBrackets!==!1&&r.push(xGe()),e.autocompletion!==!1&&r.push(DGe()),e.rectangularSelection!==!1&&r.push(rYe()),t!==!1&&r.push(sYe()),e.highlightActiveLine!==!1&&r.push(Q7e()),e.highlightSelectionMatches!==!1&&r.push(sZe()),e.tabSize&&typeof e.tabSize=="number"&&r.push(VE.of(" ".repeat(e.tabSize))),r.concat([w1.of(n.flat())]).filter(Boolean)},AZe="#e5c07b",qY="#e06c75",DZe="#56b6c2",RZe="#ffffff",uM="#abb2bf",HB="#7d8799",IZe="#61afef",PZe="#98c379",zY="#d19a66",LZe="#c678dd",BZe="#21252b",FY="#2c313a",jY="#282c34",uI="#353a42",qZe="#3E4451",VY="#528bff",zZe=ke.theme({"&":{color:uM,backgroundColor:jY},".cm-content":{caretColor:VY},".cm-cursor, .cm-dropCursor":{borderLeftColor:VY},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:qZe},".cm-panels":{backgroundColor:BZe,color:uM},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:jY,color:HB,border:"none"},".cm-activeLineGutter":{backgroundColor:FY},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:uI},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:uI,borderBottomColor:uI},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:FY,color:uM}}},{dark:!0}),FZe=t3.define([{tag:ee.keyword,color:LZe},{tag:[ee.name,ee.deleted,ee.character,ee.propertyName,ee.macroName],color:qY},{tag:[ee.function(ee.variableName),ee.labelName],color:IZe},{tag:[ee.color,ee.constant(ee.name),ee.standard(ee.name)],color:zY},{tag:[ee.definition(ee.name),ee.separator],color:uM},{tag:[ee.typeName,ee.className,ee.number,ee.changed,ee.annotation,ee.modifier,ee.self,ee.namespace],color:AZe},{tag:[ee.operator,ee.operatorKeyword,ee.url,ee.escape,ee.regexp,ee.link,ee.special(ee.string)],color:DZe},{tag:[ee.meta,ee.comment],color:HB},{tag:ee.strong,fontWeight:"bold"},{tag:ee.emphasis,fontStyle:"italic"},{tag:ee.strikethrough,textDecoration:"line-through"},{tag:ee.link,color:HB,textDecoration:"underline"},{tag:ee.heading,fontWeight:"bold",color:qY},{tag:[ee.atom,ee.bool,ee.special(ee.variableName)],color:zY},{tag:[ee.processingInstruction,ee.string,ee.inserted],color:PZe},{tag:ee.invalid,color:RZe}]),jZe=[zZe,kae(FZe)],VZe=ke.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),WZe=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i="light",placeholder:o="",basicSetup:s=!0}=e,a=[];switch(t&&a.unshift(w1.of([nZe])),s&&(typeof s=="boolean"?a.unshift(BY()):a.unshift(BY(s))),o&&a.unshift(Z7e(o)),i){case"light":a.push(VZe);break;case"dark":a.push(jZe);break;case"none":break;default:a.push(i);break}return n===!1&&a.push(ke.editable.of(!1)),r&&a.push(or.readOnly.of(!0)),[...a]},UZe=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)}),HZe=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},WY=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},cI=null,$Ze=()=>typeof window>"u"?new WY:(cI||(cI=new WY),cI),UY=Ou.define(),KZe=200,YZe=[];function QZe(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:o,onUpdate:s,extensions:a=YZe,autoFocus:l,theme:u="light",height:c=null,minHeight:d=null,maxHeight:h=null,width:f=null,minWidth:p=null,maxWidth:m=null,placeholder:g="",editable:y=!0,readOnly:v=!1,indentWithTab:b=!0,basicSetup:w=!0,root:x,initialState:S}=e,[k,C]=(0,Qo.useState)(),[N,E]=(0,Qo.useState)(),[D,q]=(0,Qo.useState)(),z=(0,Qo.useState)(()=>({current:null}))[0],_=(0,Qo.useState)(()=>({current:null}))[0],R=ke.theme({"&":{height:c,minHeight:d,maxHeight:h,width:f,minWidth:p,maxWidth:m},"& .cm-scroller":{height:"100% !important"}}),T=ke.updateListener.of(M=>{if(M.docChanged&&typeof r=="function"&&!M.transactions.some(I=>I.annotation(UY))){z.current?z.current.reset():(z.current=new HZe(()=>{if(_.current){var I=_.current;_.current=null,I()}z.current=null},KZe),$Ze().add(z.current));var P=M.state.doc,F=P.toString();r(F,M)}i&&i(UZe(M))}),B=WZe({theme:u,editable:y,readOnly:v,placeholder:g,indentWithTab:b,basicSetup:w}),A=[T,R,...B];return s&&typeof s=="function"&&A.push(ke.updateListener.of(s)),A=A.concat(a),(0,Qo.useLayoutEffect)(()=>{if(k&&!D){var M={doc:t,selection:n,extensions:A},P=S?or.fromJSON(S.json,M,S.fields):or.create(M);if(q(P),!N){var F=new ke({state:P,parent:k,root:x});E(F),o&&o(F,P)}}return()=>{N&&(q(void 0),E(void 0))}},[k,D]),(0,Qo.useEffect)(()=>{e.container&&C(e.container)},[e.container]),(0,Qo.useEffect)(()=>()=>{N&&(N.destroy(),E(void 0)),z.current&&(z.current.cancel(),z.current=null)},[N]),(0,Qo.useEffect)(()=>{l&&N&&N.focus()},[l,N]),(0,Qo.useEffect)(()=>{N&&N.dispatch({effects:St.reconfigure.of(A)})},[u,a,c,d,h,f,p,m,g,y,v,b,w,r,s]),(0,Qo.useEffect)(()=>{if(t!==void 0){var M=N?N.state.doc.toString():"";if(N&&t!==M){var P=z.current&&!z.current.isDone,F=()=>{N&&t!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:t||""},annotations:[UY.of(!0)]})};P?_.current=F:F()}}},[t,N]),{state:D,setState:q,view:N,setView:E,container:k,setContainer:C}}var GZe=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Xle=(0,Zh.forwardRef)((e,t)=>{var{className:n,value:r="",selection:i,extensions:o=[],onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:u,autoFocus:c,theme:d="light",height:h,minHeight:f,maxHeight:p,width:m,minWidth:g,maxWidth:y,basicSetup:v,placeholder:b,indentWithTab:w,editable:x,readOnly:S,root:k,initialState:C}=e,N=WXe(e,GZe),E=(0,Zh.useRef)(null),{state:D,view:q,container:z,setContainer:_}=QZe({root:k,value:r,autoFocus:c,theme:d,height:h,minHeight:f,maxHeight:p,width:m,minWidth:g,maxWidth:y,basicSetup:v,placeholder:b,indentWithTab:w,editable:x,readOnly:S,selection:i,onChange:s,onStatistics:a,onCreateEditor:l,onUpdate:u,extensions:o,initialState:C});(0,Zh.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:q}),[E,z,D,q]);var R=(0,Zh.useCallback)(B=>{E.current=B,_(B)},[_]);if(typeof r!="string")throw new Error("value must be typeof string but got "+typeof r);var T=typeof d=="string"?"cm-theme-"+d:"cm-theme";return(0,Gle.jsx)("div",zB({ref:R,className:""+T+(n?" "+n:"")},N))});Xle.displayName="CodeMirror";var XZe=Xle,Jle=Hc.forwardRef(({className:e,containerProps:t,...n},r)=>{let{className:i,...o}=t??{};return(0,ku.jsx)("div",{className:G("relative w-full overflow-auto flex items-start h-full",i),...o,children:(0,ku.jsx)("table",{ref:r,className:G("w-full caption-bottom text-sm",e),...n})})});Jle.displayName="Table";var Zle=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("thead",{ref:n,className:G(e),...t}));Zle.displayName="TableHeader";var eue=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("tbody",{ref:n,className:G("[&_tr:last-child]:border-0",e),...t}));eue.displayName="TableBody";var JZe=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("tfoot",{ref:n,className:G("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",e),...t}));JZe.displayName="TableFooter";var Fy=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("tr",{ref:n,className:G("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",e),...t}));Fy.displayName="TableRow";var um=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("th",{ref:n,className:G("h-10 px-2 text-left align-middle font-medium text-muted-foreground",e),...t}));um.displayName="TableHead";var Kw=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("td",{ref:n,className:G("align-middle",e),...t}));Kw.displayName="TableCell";var ZZe=Hc.forwardRef(({className:e,...t},n)=>(0,ku.jsx)("caption",{ref:n,className:G("mt-4 text-sm text-muted-foreground",e),...t}));ZZe.displayName="TableCaption";function tue(e){if(!e)return[];let t=new Set,n=[];for(let r of e.split(",")){let i=r.trim();i.length===0||t.has(i)||(t.add(i),n.push(i))}return n}function eet(e){let t=tue(e.join(","));return t.length>0?t.join(","):null}function nue(){let{pinParam:e,setPinParam:t}=lo(),n=(0,JE.useMemo)(()=>tue(e),[e]),r=(0,JE.useCallback)(i=>{let o=eet(i);(e??null)!==o&&t(o)},[e,t]);return{pinnedColumnIds:n,setPinnedColumnIds:r}}var KB=["Enter"," "],tet=["ArrowDown","PageUp","Home"],iue=["ArrowUp","PageDown","End"],net=[...tet,...iue],ret={ltr:[...KB,"ArrowRight"],rtl:[...KB,"ArrowLeft"]},iet={ltr:["ArrowLeft"],rtl:["ArrowRight"]},C1="Menu",[Vx,oet,set]=Xz(C1),[bm,ZE]=os(C1,[set,Kh,fE]),N1=Kh(),oue=fE(),[sue,tf]=bm(C1),[aet,M1]=bm(C1),aue=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:o,modal:s=!0}=e,a=N1(t),[l,u]=je.useState(null),c=je.useRef(!1),d=Ea(o),h=hE(i);return je.useEffect(()=>{let f=()=>{c.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},p=()=>c.current=!1;return document.addEventListener("keydown",f,{capture:!0}),()=>{document.removeEventListener("keydown",f,{capture:!0}),document.removeEventListener("pointerdown",p,{capture:!0}),document.removeEventListener("pointermove",p,{capture:!0})}},[]),(0,lt.jsx)(d1,{...a,children:(0,lt.jsx)(sue,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:u,children:(0,lt.jsx)(aet,{scope:t,onClose:je.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:c,dir:h,modal:s,children:r})})})};aue.displayName=C1;var uet="MenuAnchor",g3=je.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=N1(n);return(0,lt.jsx)(h1,{...i,...r,ref:t})});g3.displayName=uet;var y3="MenuPortal",[cet,lue]=bm(y3,{forceMount:void 0}),uue=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,o=tf(y3,t);return(0,lt.jsx)(cet,{scope:t,forceMount:n,children:(0,lt.jsx)(Vs,{present:n||o.open,children:(0,lt.jsx)(Ov,{asChild:!0,container:i,children:r})})})};uue.displayName=y3;var Ca="MenuContent",[det,v3]=bm(Ca),cue=je.forwardRef((e,t)=>{let n=lue(Ca,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=tf(Ca,e.__scopeMenu),s=M1(Ca,e.__scopeMenu);return(0,lt.jsx)(Vx.Provider,{scope:e.__scopeMenu,children:(0,lt.jsx)(Vs,{present:r||o.open,children:(0,lt.jsx)(Vx.Slot,{scope:e.__scopeMenu,children:s.modal?(0,lt.jsx)(het,{...i,ref:t}):(0,lt.jsx)(fet,{...i,ref:t})})})})}),het=je.forwardRef((e,t)=>{let n=tf(Ca,e.__scopeMenu),r=je.useRef(null),i=qt(t,r);return je.useEffect(()=>{let o=r.current;if(o)return iE(o)},[]),(0,lt.jsx)(b3,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:xe(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),fet=je.forwardRef((e,t)=>{let n=tf(Ca,e.__scopeMenu);return(0,lt.jsx)(b3,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),pet=Xp("MenuContent.ScrollLock"),b3=je.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:h,onDismiss:f,disableOutsideScroll:p,...m}=e,g=tf(Ca,n),y=M1(Ca,n),v=N1(n),b=oue(n),w=oet(n),[x,S]=je.useState(null),k=je.useRef(null),C=qt(t,k,g.onContentChange),N=je.useRef(0),E=je.useRef(""),D=je.useRef(0),q=je.useRef(null),z=je.useRef("right"),_=je.useRef(0),R=p?rE:je.Fragment,T=p?{as:pet,allowPinchZoom:!0}:void 0,B=M=>{let P=E.current+M,F=w().filter($=>!$.disabled),I=document.activeElement,V=F.find($=>$.ref.current===I)?.textValue,W=F.map($=>$.textValue),j=_et(W,P,V),X=F.find($=>$.textValue===j)?.ref.current;(function $(K){E.current=K,window.clearTimeout(N.current),K!==""&&(N.current=window.setTimeout(()=>$(""),1e3))})(P),X&&setTimeout(()=>X.focus())};je.useEffect(()=>()=>window.clearTimeout(N.current),[]),Z_();let A=je.useCallback(M=>z.current===q.current?.side&&Oet(M,q.current?.area),[]);return(0,lt.jsx)(det,{scope:n,searchRef:E,onItemEnter:je.useCallback(M=>{A(M)&&M.preventDefault()},[A]),onItemLeave:je.useCallback(M=>{A(M)||(k.current?.focus(),S(null))},[A]),onTriggerLeave:je.useCallback(M=>{A(M)&&M.preventDefault()},[A]),pointerGraceTimerRef:D,onPointerGraceIntentChange:je.useCallback(M=>{q.current=M},[]),children:(0,lt.jsx)(R,{...T,children:(0,lt.jsx)(s1,{asChild:!0,trapped:i,onMountAutoFocus:xe(o,M=>{M.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:s,children:(0,lt.jsx)(Ev,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:u,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:h,onDismiss:f,children:(0,lt.jsx)(wte,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:xe(l,M=>{y.isUsingKeyboardRef.current||M.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,lt.jsx)(bE,{role:"menu","aria-orientation":"vertical","data-state":_ue(g.open),"data-radix-menu-content":"",dir:y.dir,...v,...m,ref:C,style:{outline:"none",...m.style},onKeyDown:xe(m.onKeyDown,M=>{let P=M.target.closest("[data-radix-menu-content]")===M.currentTarget,F=M.ctrlKey||M.altKey||M.metaKey,I=M.key.length===1;P&&(M.key==="Tab"&&M.preventDefault(),!F&&I&&B(M.key));let V=k.current;if(M.target!==V||!net.includes(M.key))return;M.preventDefault();let W=w().filter(j=>!j.disabled).map(j=>j.ref.current);iue.includes(M.key)&&W.reverse(),Net(W)}),onBlur:xe(e.onBlur,M=>{M.currentTarget.contains(M.target)||(window.clearTimeout(N.current),E.current="")}),onPointerMove:xe(e.onPointerMove,Wx(M=>{let P=M.target,F=_.current!==M.clientX;if(M.currentTarget.contains(P)&&F){let I=M.clientX>_.current?"right":"left";z.current=I,_.current=M.clientX}}))})})})})})})});cue.displayName=Ca;var met="MenuGroup",w3=je.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,lt.jsx)(ft.div,{role:"group",...r,ref:t})});w3.displayName=met;var get="MenuLabel",due=je.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,lt.jsx)(ft.div,{...r,ref:t})});due.displayName=get;var x_="MenuItem",HY="menu.itemSelect",eO=je.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,o=je.useRef(null),s=M1(x_,e.__scopeMenu),a=v3(x_,e.__scopeMenu),l=qt(t,o),u=je.useRef(!1),c=()=>{let d=o.current;if(!n&&d){let h=new CustomEvent(HY,{bubbles:!0,cancelable:!0});d.addEventListener(HY,f=>r?.(f),{once:!0}),ree(d,h),h.defaultPrevented?u.current=!1:s.onClose()}};return(0,lt.jsx)(hue,{...i,ref:l,disabled:n,onClick:xe(e.onClick,c),onPointerDown:d=>{e.onPointerDown?.(d),u.current=!0},onPointerUp:xe(e.onPointerUp,d=>{u.current||d.currentTarget?.click()}),onKeyDown:xe(e.onKeyDown,d=>{let h=a.searchRef.current!=="";n||h&&d.key===" "||KB.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});eO.displayName=x_;var hue=je.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=v3(x_,n),a=oue(n),l=je.useRef(null),u=qt(t,l),[c,d]=je.useState(!1),[h,f]=je.useState("");return je.useEffect(()=>{let p=l.current;p&&f((p.textContent??"").trim())},[o.children]),(0,lt.jsx)(Vx.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,lt.jsx)(xte,{asChild:!0,...a,focusable:!r,children:(0,lt.jsx)(ft.div,{role:"menuitem","data-highlighted":c?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...o,ref:u,onPointerMove:xe(e.onPointerMove,Wx(p=>{r?s.onItemLeave(p):(s.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:xe(e.onPointerLeave,Wx(p=>s.onItemLeave(p))),onFocus:xe(e.onFocus,()=>d(!0)),onBlur:xe(e.onBlur,()=>d(!1))})})})}),yet="MenuCheckboxItem",fue=je.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,lt.jsx)(vue,{scope:e.__scopeMenu,checked:n,children:(0,lt.jsx)(eO,{role:"menuitemcheckbox","aria-checked":S_(n)?"mixed":n,...i,ref:t,"data-state":k3(n),onSelect:xe(i.onSelect,()=>r?.(S_(n)?!0:!n),{checkForDefaultPrevented:!1})})})});fue.displayName=yet;var pue="MenuRadioGroup",[vet,bet]=bm(pue,{value:void 0,onValueChange:()=>{}}),mue=je.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,o=Ea(r);return(0,lt.jsx)(vet,{scope:e.__scopeMenu,value:n,onValueChange:o,children:(0,lt.jsx)(w3,{...i,ref:t})})});mue.displayName=pue;var gue="MenuRadioItem",yue=je.forwardRef((e,t)=>{let{value:n,...r}=e,i=bet(gue,e.__scopeMenu),o=n===i.value;return(0,lt.jsx)(vue,{scope:e.__scopeMenu,checked:o,children:(0,lt.jsx)(eO,{role:"menuitemradio","aria-checked":o,...r,ref:t,"data-state":k3(o),onSelect:xe(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});yue.displayName=gue;var x3="MenuItemIndicator",[vue,wet]=bm(x3,{checked:!1}),bue=je.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=wet(x3,n);return(0,lt.jsx)(Vs,{present:r||S_(o.checked)||o.checked===!0,children:(0,lt.jsx)(ft.span,{...i,ref:t,"data-state":k3(o.checked)})})});bue.displayName=x3;var xet="MenuSeparator",wue=je.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,lt.jsx)(ft.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});wue.displayName=xet;var ket="MenuArrow",xue=je.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=N1(n);return(0,lt.jsx)(wE,{...i,...r,ref:t})});xue.displayName=ket;var S3="MenuSub",[Cet,Sue]=bm(S3),kue=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,o=tf(S3,t),s=N1(t),[a,l]=je.useState(null),[u,c]=je.useState(null),d=Ea(i);return je.useEffect(()=>(o.open===!1&&d(!1),()=>d(!1)),[o.open,d]),(0,lt.jsx)(d1,{...s,children:(0,lt.jsx)(sue,{scope:t,open:r,onOpenChange:d,content:u,onContentChange:c,children:(0,lt.jsx)(Cet,{scope:t,contentId:fi(),triggerId:fi(),trigger:a,onTriggerChange:l,children:n})})})};kue.displayName=S3;var kw="MenuSubTrigger",Cue=je.forwardRef((e,t)=>{let n=tf(kw,e.__scopeMenu),r=M1(kw,e.__scopeMenu),i=Sue(kw,e.__scopeMenu),o=v3(kw,e.__scopeMenu),s=je.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=o,u={__scopeMenu:e.__scopeMenu},c=je.useCallback(()=>{s.current&&window.clearTimeout(s.current),s.current=null},[]);return je.useEffect(()=>c,[c]),je.useEffect(()=>{let d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),(0,lt.jsx)(g3,{asChild:!0,...u,children:(0,lt.jsx)(hue,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":_ue(n.open),...e,ref:bu(t,i.onTriggerChange),onClick:d=>{e.onClick?.(d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:xe(e.onPointerMove,Wx(d=>{o.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!s.current&&(o.onPointerGraceIntentChange(null),s.current=window.setTimeout(()=>{n.onOpenChange(!0),c()},100))})),onPointerLeave:xe(e.onPointerLeave,Wx(d=>{c();let h=n.content?.getBoundingClientRect();if(h){let f=n.content?.dataset.side,p=f==="right",m=p?-5:5,g=h[p?"left":"right"],y=h[p?"right":"left"];o.onPointerGraceIntentChange({area:[{x:d.clientX+m,y:d.clientY},{x:g,y:h.top},{x:y,y:h.top},{x:y,y:h.bottom},{x:g,y:h.bottom}],side:f}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(d),d.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:xe(e.onKeyDown,d=>{let h=o.searchRef.current!=="";e.disabled||h&&d.key===" "||ret[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});Cue.displayName=kw;var Nue="MenuSubContent",Mue=je.forwardRef((e,t)=>{let n=lue(Ca,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,o=tf(Ca,e.__scopeMenu),s=M1(Ca,e.__scopeMenu),a=Sue(Nue,e.__scopeMenu),l=je.useRef(null),u=qt(t,l);return(0,lt.jsx)(Vx.Provider,{scope:e.__scopeMenu,children:(0,lt.jsx)(Vs,{present:r||o.open,children:(0,lt.jsx)(Vx.Slot,{scope:e.__scopeMenu,children:(0,lt.jsx)(b3,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:u,align:"start",side:s.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:c=>{s.isUsingKeyboardRef.current&&l.current?.focus(),c.preventDefault()},onCloseAutoFocus:c=>c.preventDefault(),onFocusOutside:xe(e.onFocusOutside,c=>{c.target!==a.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:xe(e.onEscapeKeyDown,c=>{s.onClose(),c.preventDefault()}),onKeyDown:xe(e.onKeyDown,c=>{let d=c.currentTarget.contains(c.target),h=iet[s.dir].includes(c.key);d&&h&&(o.onOpenChange(!1),a.trigger?.focus(),c.preventDefault())})})})})})});Mue.displayName=Nue;function _ue(e){return e?"open":"closed"}function S_(e){return e==="indeterminate"}function k3(e){return S_(e)?"indeterminate":e?"checked":"unchecked"}function Net(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Met(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function _et(e,t,n){let r=t.length>1&&Array.from(t).every(a=>a===t[0])?t[0]:t,i=n?e.indexOf(n):-1,o=Met(e,Math.max(i,0));r.length===1&&(o=o.filter(a=>a!==n));let s=o.find(a=>a.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}function Eet(e,t){let{x:n,y:r}=e,i=!1;for(let o=0,s=t.length-1;o<t.length;s=o++){let a=t[o],l=t[s],u=a.x,c=a.y,d=l.x,h=l.y;c>r!=h>r&&n<(d-u)*(r-c)/(h-c)+u&&(i=!i)}return i}function Oet(e,t){if(!t)return!1;let n={x:e.clientX,y:e.clientY};return Eet(n,t)}function Wx(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Eue=aue,Oue=g3,Tue=uue,Aue=cue,Due=w3,Rue=due,Iue=eO,Pue=fue,Lue=mue,Bue=yue,que=bue,zue=wue,Fue=xue,Tet=kue,jue=Cue,Vue=Mue,C3="ContextMenu",[Aet,tvt]=os(C3,[ZE]),ho=ZE(),[Det,Wue]=Aet(C3),Uue=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,dir:i,modal:o=!0}=e,[s,a]=Tn.useState(!1),l=ho(t),u=Ea(r),c=Tn.useCallback(d=>{a(d),u(d)},[u]);return(0,br.jsx)(Det,{scope:t,open:s,onOpenChange:c,modal:o,children:(0,br.jsx)(Eue,{...l,dir:i,open:s,onOpenChange:c,modal:o,children:n})})};Uue.displayName=C3;var Hue="ContextMenuTrigger",$ue=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,disabled:r=!1,...i}=e,o=Wue(Hue,n),s=ho(n),a=Tn.useRef({x:0,y:0}),l=Tn.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),u=Tn.useRef(0),c=Tn.useCallback(()=>window.clearTimeout(u.current),[]),d=h=>{a.current={x:h.clientX,y:h.clientY},o.onOpenChange(!0)};return Tn.useEffect(()=>c,[c]),Tn.useEffect(()=>{r&&c()},[r,c]),(0,br.jsxs)(br.Fragment,{children:[(0,br.jsx)(Oue,{...s,virtualRef:l}),(0,br.jsx)(ft.span,{"data-state":o.open?"open":"closed","data-disabled":r?"":void 0,...i,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:xe(e.onContextMenu,h=>{c(),d(h),h.preventDefault()}),onPointerDown:r?e.onPointerDown:xe(e.onPointerDown,yN(h=>{c(),u.current=window.setTimeout(()=>d(h),700)})),onPointerMove:r?e.onPointerMove:xe(e.onPointerMove,yN(c)),onPointerCancel:r?e.onPointerCancel:xe(e.onPointerCancel,yN(c)),onPointerUp:r?e.onPointerUp:xe(e.onPointerUp,yN(c))})]})});$ue.displayName=Hue;var Ret="ContextMenuPortal",Kue=e=>{let{__scopeContextMenu:t,...n}=e,r=ho(t);return(0,br.jsx)(Tue,{...r,...n})};Kue.displayName=Ret;var Yue="ContextMenuContent",Que=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=Wue(Yue,n),o=ho(n),s=Tn.useRef(!1);return(0,br.jsx)(Aue,{...o,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:a=>{e.onCloseAutoFocus?.(a),!a.defaultPrevented&&s.current&&a.preventDefault(),s.current=!1},onInteractOutside:a=>{e.onInteractOutside?.(a),!a.defaultPrevented&&!i.modal&&(s.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Que.displayName=Yue;var Iet="ContextMenuGroup",Pet=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Due,{...i,...r,ref:t})});Pet.displayName=Iet;var Let="ContextMenuLabel",Gue=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Rue,{...i,...r,ref:t})});Gue.displayName=Let;var Bet="ContextMenuItem",Xue=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Iue,{...i,...r,ref:t})});Xue.displayName=Bet;var qet="ContextMenuCheckboxItem",Jue=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Pue,{...i,...r,ref:t})});Jue.displayName=qet;var zet="ContextMenuRadioGroup",Fet=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Lue,{...i,...r,ref:t})});Fet.displayName=zet;var jet="ContextMenuRadioItem",Zue=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Bue,{...i,...r,ref:t})});Zue.displayName=jet;var Vet="ContextMenuItemIndicator",ece=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(que,{...i,...r,ref:t})});ece.displayName=Vet;var Wet="ContextMenuSeparator",tce=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(zue,{...i,...r,ref:t})});tce.displayName=Wet;var Uet="ContextMenuArrow",Het=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Fue,{...i,...r,ref:t})});Het.displayName=Uet;var nce="ContextMenuSub",$et=e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,defaultOpen:o}=e,s=ho(t),[a,l]=_a({prop:i,defaultProp:o??!1,onChange:r,caller:nce});return(0,br.jsx)(Tet,{...s,open:a,onOpenChange:l,children:n})};$et.displayName=nce;var Ket="ContextMenuSubTrigger",rce=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(jue,{...i,...r,ref:t})});rce.displayName=Ket;var Yet="ContextMenuSubContent",ice=Tn.forwardRef((e,t)=>{let{__scopeContextMenu:n,...r}=e,i=ho(n);return(0,br.jsx)(Vue,{...i,...r,ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});ice.displayName=Yet;function yN(e){return t=>t.pointerType!=="mouse"?e(t):void 0}var Qet=Uue,Get=$ue,Xet=Kue,oce=Que,sce=Gue,ace=Xue,lce=Jue,uce=Zue,cce=ece,dce=tce,hce=rce,fce=ice,pce=Qet,mce=Get,Jet=$c.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Qr.jsxs)(hce,{ref:i,className:G("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",t&&"pl-8",e),...r,children:[n,(0,Qr.jsx)(o1,{className:"ml-auto h-4 w-4"})]}));Jet.displayName=hce.displayName;var Zet=$c.forwardRef(({className:e,...t},n)=>(0,Qr.jsx)(fce,{ref:n,className:G("z-50 min-w-32 overflow-hidden rounded-md border border-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 origin-(--radix-context-menu-content-transform-origin)",e),...t}));Zet.displayName=fce.displayName;var N3=$c.forwardRef(({className:e,...t},n)=>(0,Qr.jsx)(Xet,{children:(0,Qr.jsx)("div",{className:"ps",children:(0,Qr.jsx)(oce,{ref:n,className:G("z-50 max-h-(--radix-context-menu-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-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 origin-(--radix-context-menu-content-transform-origin)",e),...t})})}));N3.displayName=oce.displayName;var M3=$c.forwardRef(({className:e,inset:t,...n},r)=>(0,Qr.jsx)(ace,{ref:r,className:G("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",t&&"pl-8",e),...n}));M3.displayName=ace.displayName;var ett=$c.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Qr.jsxs)(lce,{ref:i,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),checked:n,...r,children:[(0,Qr.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Qr.jsx)(cce,{children:(0,Qr.jsx)(fm,{className:"h-4 w-4"})})}),t]}));ett.displayName=lce.displayName;var ttt=$c.forwardRef(({className:e,children:t,...n},r)=>(0,Qr.jsxs)(uce,{ref:r,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),...n,children:[(0,Qr.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Qr.jsx)(cce,{children:(0,Qr.jsx)(UZ,{className:"h-4 w-4 fill-current"})})}),t]}));ttt.displayName=uce.displayName;var ntt=$c.forwardRef(({className:e,inset:t,...n},r)=>(0,Qr.jsx)(sce,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold text-foreground",t&&"pl-8",e),...n}));ntt.displayName=sce.displayName;var rtt=$c.forwardRef(({className:e,...t},n)=>(0,Qr.jsx)(dce,{ref:n,className:G("-mx-1 my-1 h-px bg-border",e),...t}));rtt.displayName=dce.displayName;var itt=({className:e,...t})=>(0,Qr.jsx)("span",{className:G("ml-auto text-xs tracking-widest text-muted-foreground",e),...t});itt.displayName="ContextMenuShortcut";var gce="studioSuppressCellOpenUntil";function k_(e=250){typeof document>"u"||!document.body||(document.body.dataset[gce]=String(Date.now()+e))}function Yw(){if(typeof document>"u"||!document.body)return!1;let e=Number(document.body.dataset[gce]??"0");return Number.isFinite(e)&&e>Date.now()}function ott(e){let{children:t,copyText:n}=e,r=(0,Bv.useRef)(null),i=(0,Bv.useCallback)(()=>{k_();let o=(typeof n=="function"?n():n)??(stt(r.current)||YB(t));o!=null&&navigator.clipboard.writeText(o).catch(s=>{console.error("Failed to copy to clipboard:",s)})},[t,n]);return(0,fh.jsxs)(pce,{children:[(0,fh.jsx)(mce,{className:"block w-full h-full",children:(0,fh.jsx)("div",{"data-studio-context-menu-trigger":!0,ref:r,children:t})}),(0,fh.jsx)(N3,{children:(0,fh.jsxs)(M3,{onPointerDown:()=>k_(),onSelect:()=>i(),className:"flex items-center gap-2",children:[(0,fh.jsx)($Z,{size:12}),"Copy"]})})]})}function stt(e){return e?.innerText?.trim()??""}function YB(e){if(typeof e=="string"||typeof e=="number"||typeof e=="boolean")return String(e);if(e==null)return"";if((0,Bv.isValidElement)(e)){let t=e.props;return e.type&&typeof e.type=="function"&&e.type.name==="RevealText"?t.text||"":e.type&&typeof e.type=="function"&&e.type.name==="NullValue"?"NULL":t.children?YB(t.children):""}return Array.isArray(e)?e.map(YB).join(""):""}var att=G("relative z-10 block h-(--studio-cell-height) w-full px-(--studio-cell-spacing)","truncate text-xs font-mono text-foreground","leading-(--studio-cell-height)","group-data-[select=true]:p-0"),QB=G("ps-staged-cell relative z-0","before:pointer-events-none before:absolute before:inset-0 before:z-0 before:bg-staged-cell-background before:content-['']","after:pointer-events-none after:absolute after:inset-0 after:z-20 after:border after:border-amber-300 after:content-['']"),Qw=G("relative z-0","before:pointer-events-none before:absolute before:inset-0 before:z-20 before:border before:border-sky-300 before:content-['']"),GB=G("ps-staged-cell relative z-0","before:pointer-events-none before:absolute before:inset-0 before:z-0 before:bg-staged-cell-background before:content-['']","after:pointer-events-none after:absolute after:inset-0 after:z-20 after:border after:border-sky-300 after:content-['']"),wa=(0,rue.forwardRef)((e,t)=>{let{children:n,className:r,contentClassName:i,contextMenuCopyText:o,style:s,withContextMenu:a=!0,...l}=e,u=a?(0,cM.jsx)(ott,{copyText:o,children:n}):n;return(0,cM.jsx)(Kw,{...l,className:G("p-0 border-r border-b border-table-border group","cursor-pointer",r),ref:t,style:s,children:(0,cM.jsx)("div",{"data-studio-cell-content":!0,className:G(att,i),children:u})})});wa.displayName="Cell";function ltt(e,t,n){let r=i=>e(i,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function _3(e,t,n){let r=e.length-t.length;if(r===0)return e(...t);if(r===1)return ltt(e,t,n);throw Error("Wrong number of arguments")}function $Y(...e){return _3(utt,e)}var utt=(e,t)=>e.length>=t;function ctt(...e){return _3(_1,e)}function _1(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e))return dtt(e,t);if(e instanceof Map)return htt(e,t);if(e instanceof Set)return ftt(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!_1(r,t[n]))return!1;return!0}function dtt(e,t){if(e.length!==t.length)return!1;for(let[n,r]of e.entries())if(!_1(r,t[n]))return!1;return!0}function htt(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(!t.has(n)||!_1(r,t.get(n)))return!1;return!0}function ftt(e,t){if(e.size!==t.size)return!1;let n=[...t];for(let r of e){let i=!1;for(let[o,s]of n.entries())if(_1(r,s)){i=!0,n.splice(o,1);break}if(!i)return!1}return!0}function XB(e){return typeof e=="object"&&!!e}function ptt(...e){return _3(mtt,e)}function mtt(e,t){if(!$Y(t,1))return{...e};if(!$Y(t,2)){let{[t[0]]:r,...i}=e;return i}let n={...e};for(let r of t)delete n[r];return n}function gtt(e){return(0,ah.jsx)(RE,{delayDuration:120,children:(0,ah.jsxs)(IE,{children:[(0,ah.jsx)(PE,{children:(0,ah.jsx)("span",{className:"italic text-muted-foreground select-none",children:"(default value)"})}),(0,ah.jsx)(v1,{side:"bottom",className:"text-xs",children:(0,ah.jsx)("span",{children:String(e.defaultValue)})})]})})}var ytt=/^(\d{4}-\d{2}-\d{2})([Tt ]?)([01]\d|2[0-3])((?::[0-5]\d(?::[0-5]\d(?:\.\d{1,6})?)?)?)([Zz]?)$/;function vtt(e,t){let n=t?.trim()??"";if(n.length===0||e.length===0)return[{isMatch:!1,text:e}];let r=KY(e,n);if(r.length>0)return YY(e,r);let i=btt(n);for(let o of i){let s=KY(e,o);if(s.length>0)return YY(e,s)}return[{isMatch:!1,text:e}]}function KY(e,t){let n=e.toLowerCase(),r=t.toLowerCase(),i=[],o=0,s=n.indexOf(r,o);for(;s!==-1;){let a=s+t.length;i.push({end:a,start:s}),o=a,s=n.indexOf(r,o)}return i}function YY(e,t){if(t.length===0)return[{isMatch:!1,text:e}];let n=[],r=0;for(let i of t)i.start>r&&n.push({isMatch:!1,text:e.slice(r,i.start)}),n.push({isMatch:!0,text:e.slice(i.start,i.end)}),r=i.end;return r<e.length&&n.push({isMatch:!1,text:e.slice(r)}),n}function btt(e){let t=e.match(ytt);if(!t)return[];let[,n,r,i,o,s]=t,a=r===""?["T"," "]:r===" "?["T",""]:[" ",""],l=s===""?[""]:[s,""],u=new Set,c=[];for(let d of a)for(let h of l){let f=`${n}${d}${i}${o}${h}`;if(f.toLowerCase()===e.toLowerCase())continue;let p=f.toLowerCase();u.has(p)||(u.add(p),c.push(f))}return c}function oy(e){let{searchTerm:t,text:n}=e,r=vtt(n,t);return r.length===1&&!r[0]?.isMatch?(0,ph.jsx)(ph.Fragment,{children:n}):(0,ph.jsx)(ph.Fragment,{children:r.map((i,o)=>{let s=`${i.text}:${o}`;return i.isMatch?(0,ph.jsx)("mark",{className:"rounded-sm bg-yellow-200/80 text-current dark:bg-yellow-300/60","data-search-match":"true",children:i.text},s):(0,ph.jsx)(yce.Fragment,{children:i.text},s)})})}function wtt(e){let{searchTerm:t,value:n}=e,r=n.trimStart(),i=n.trim(),o=r?n.length-n.trimEnd().length:0;return(0,kh.jsxs)(kh.Fragment,{children:[(0,kh.jsx)("span",{className:"text-muted-foreground select-none",children:"\xB7".repeat(n.length-r.length)}),(0,kh.jsx)(oy,{searchTerm:t,text:i}),(0,kh.jsx)("span",{className:"text-muted-foreground select-none",children:"\xB7".repeat(o)})]})}function C_(e){let{cell:t,column:n,searchTerm:r}=e,{datatype:i,defaultValue:o,fkColumn:s,nullable:a}=n,{format:l,group:u,isArray:c}=i,d=t.getValue();return d===void 0?o!=null?(0,li.jsx)(gtt,{defaultValue:o}):a?(0,li.jsx)(QY,{}):s?null:c?(0,li.jsx)("span",{className:"text-muted-foreground",children:hg}):u==="string"?(0,li.jsx)(GY,{}):u==="numeric"?(0,li.jsx)("span",{className:"text-muted-foreground",children:eb}):(u==="datetime"||u==="time")&&l?(0,li.jsx)("span",{className:"text-muted-foreground",children:Ju(l)}):u==="boolean"?(0,li.jsx)("span",{className:"text-muted-foreground",children:String(wk)}):u==="json"?(0,li.jsx)("span",{className:"text-muted-foreground",children:Yf}):null:d===null?(0,li.jsx)(QY,{}):c&&d===Yf?(0,li.jsx)(oy,{searchTerm:r,text:hg}):c||u==="json"?(0,li.jsx)(oy,{searchTerm:r,text:XB(d)?JSON.stringify(d,null,2):String(d)}):u==="string"?d===""?(0,li.jsx)(GY,{}):(0,li.jsx)(wtt,{searchTerm:r,value:String(d)}):u==="boolean"?(0,li.jsx)(oy,{searchTerm:r,text:String(!!d)}):u==="raw"?(0,li.jsx)(oy,{searchTerm:r,text:XB(d)?JSON.stringify(d,null,2):String(d)}):(0,li.jsx)(oy,{searchTerm:r,text:String(d)})}function QY(){return(0,li.jsx)("code",{className:"text-muted-foreground/60",children:"NULL"})}function GY(){return(0,li.jsx)("span",{className:"italic text-muted-foreground select-none",children:"(empty string)"})}function xtt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,Pr.useMemo)(()=>r=>{t.forEach(i=>i(r))},t)}var tO=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function qv(e){let t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function E3(e){return"nodeType"in e}function Lo(e){var t,n;return e?qv(e)?e:E3(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function O3(e){let{Document:t}=Lo(e);return e instanceof t}function E1(e){return qv(e)?!1:e instanceof Lo(e).HTMLElement}function vce(e){return e instanceof Lo(e).SVGElement}function zv(e){return e?qv(e)?e.document:E3(e)?O3(e)?e:E1(e)||vce(e)?e.ownerDocument:document:document:document}var yl=tO?Pr.useLayoutEffect:Pr.useEffect;function nO(e){let t=(0,Pr.useRef)(e);return yl(()=>{t.current=e}),(0,Pr.useCallback)(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return t.current==null?void 0:t.current(...r)},[])}function Stt(){let e=(0,Pr.useRef)(null),t=(0,Pr.useCallback)((r,i)=>{e.current=setInterval(r,i)},[]),n=(0,Pr.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function Ux(e,t){t===void 0&&(t=[e]);let n=(0,Pr.useRef)(e);return yl(()=>{n.current!==e&&(n.current=e)},t),n}function O1(e,t){let n=(0,Pr.useRef)();return(0,Pr.useMemo)(()=>{let r=e(n.current);return n.current=r,r},[...t])}function N_(e){let t=nO(e),n=(0,Pr.useRef)(null),r=(0,Pr.useCallback)(i=>{i!==n.current&&t?.(i,n.current),n.current=i},[]);return[n,r]}function M_(e){let t=(0,Pr.useRef)();return(0,Pr.useEffect)(()=>{t.current=e},[e]),t.current}var dI={};function T1(e,t){return(0,Pr.useMemo)(()=>{if(t)return t;let n=dI[e]==null?0:dI[e]+1;return dI[e]=n,e+"-"+n},[e,t])}function bce(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((o,s)=>{let a=Object.entries(s);for(let[l,u]of a){let c=o[l];c!=null&&(o[l]=c+e*u)}return o},{...t})}}var jy=bce(1),__=bce(-1);function ktt(e){return"clientX"in e&&"clientY"in e}function rO(e){if(!e)return!1;let{KeyboardEvent:t}=Lo(e.target);return t&&e instanceof t}function Ctt(e){if(!e)return!1;let{TouchEvent:t}=Lo(e.target);return t&&e instanceof t}function E_(e){if(Ctt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return ktt(e)?{x:e.clientX,y:e.clientY}:null}var qh=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[qh.Translate.toString(e),qh.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),XY="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Ntt(e){return e.matches(XY)?e:e.querySelector(XY)}var Mtt={display:"none"};function _tt(e){let{id:t,value:n}=e;return wm.default.createElement("div",{id:t,style:Mtt},n)}function Ett(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e,i={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 wm.default.createElement("div",{id:t,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function Ott(){let[e,t]=(0,wm.useState)("");return{announce:(0,wm.useCallback)(n=>{n!=null&&t(n)},[]),announcement:e}}var wce=(0,ne.createContext)(null);function Ttt(e){let t=(0,ne.useContext)(wce);(0,ne.useEffect)(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function Att(){let[e]=(0,ne.useState)(()=>new Set),t=(0,ne.useCallback)(n=>(e.add(n),()=>e.delete(n)),[e]);return[(0,ne.useCallback)(n=>{let{type:r,event:i}=n;e.forEach(o=>{var s;return(s=o[r])==null?void 0:s.call(o,i)})},[e]),t]}var Dtt={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.
`},Rtt={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Itt(e){let{announcements:t=Rtt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Dtt}=e,{announce:o,announcement:s}=Ott(),a=T1("DndLiveRegion"),[l,u]=(0,ne.useState)(!1);if((0,ne.useEffect)(()=>{u(!0)},[]),Ttt((0,ne.useMemo)(()=>({onDragStart(d){let{active:h}=d;o(t.onDragStart({active:h}))},onDragMove(d){let{active:h,over:f}=d;t.onDragMove&&o(t.onDragMove({active:h,over:f}))},onDragOver(d){let{active:h,over:f}=d;o(t.onDragOver({active:h,over:f}))},onDragEnd(d){let{active:h,over:f}=d;o(t.onDragEnd({active:h,over:f}))},onDragCancel(d){let{active:h,over:f}=d;o(t.onDragCancel({active:h,over:f}))}}),[o,t])),!l)return null;let c=ne.default.createElement(ne.default.Fragment,null,ne.default.createElement(_tt,{id:r,value:i.draggable}),ne.default.createElement(Ett,{id:a,announcement:s}));return n?(0,Op.createPortal)(c,n):c}var di;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(di||(di={}));function O_(){}function Ptt(e,t){return(0,ne.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Ltt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,ne.useMemo)(()=>[...t].filter(r=>r!=null),[...t])}var vl=Object.freeze({x:0,y:0});function Btt(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function qtt(e,t){let n=E_(e);if(!n)return"0 0";let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function ztt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ftt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function jtt(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function JY(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var Vtt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=JY(t,t.left,t.top),o=[];for(let s of r){let{id:a}=s,l=n.get(a);if(l){let u=Btt(JY(l),i);o.push({id:a,data:{droppableContainer:s,value:u}})}}return o.sort(ztt)};function Wtt(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),s=i-r,a=o-n;if(r<i&&n<o){let l=t.width*t.height,u=e.width*e.height,c=s*a,d=c/(l+u-c);return Number(d.toFixed(4))}return 0}var Utt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let o of r){let{id:s}=o,a=n.get(s);if(a){let l=Wtt(a,t);l>0&&i.push({id:s,data:{droppableContainer:o,value:l}})}}return i.sort(Ftt)};function Htt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function xce(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:vl}function $tt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((o,s)=>({...o,top:o.top+e*s.y,bottom:o.bottom+e*s.y,left:o.left+e*s.x,right:o.right+e*s.x}),{...t})}}var Ktt=$tt(1);function Sce(e){if(e.startsWith("matrix3d(")){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Ytt(e,t,n){let r=Sce(t);if(!r)return e;let{scaleX:i,scaleY:o,x:s,y:a}=r,l=e.left-s-(1-i)*parseFloat(n),u=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),c=i?e.width/i:e.width,d=o?e.height/o:e.height;return{width:c,height:d,top:u,right:l+c,bottom:u+d,left:l}}var Qtt={ignoreTransform:!1};function Fv(e,t){t===void 0&&(t=Qtt);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:u,transformOrigin:c}=Lo(e).getComputedStyle(e);u&&(n=Ytt(n,u,c))}let{top:r,left:i,width:o,height:s,bottom:a,right:l}=n;return{top:r,left:i,width:o,height:s,bottom:a,right:l}}function ZY(e){return Fv(e,{ignoreTransform:!0})}function Gtt(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Xtt(e,t){return t===void 0&&(t=Lo(e).getComputedStyle(e)),t.position==="fixed"}function Jtt(e,t){t===void 0&&(t=Lo(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(r=>{let i=t[r];return typeof i=="string"?n.test(i):!1})}function T3(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(O3(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!E1(i)||vce(i)||n.includes(i))return n;let o=Lo(e).getComputedStyle(i);return i!==e&&Jtt(i,o)&&n.push(i),Xtt(i,o)?n:r(i.parentNode)}return e?r(e):n}function kce(e){let[t]=T3(e,1);return t??null}function hI(e){return!tO||!e?null:qv(e)?e:E3(e)?O3(e)||e===zv(e).scrollingElement?window:E1(e)?e:null:null}function Cce(e){return qv(e)?e.scrollX:e.scrollLeft}function Nce(e){return qv(e)?e.scrollY:e.scrollTop}function JB(e){return{x:Cce(e),y:Nce(e)}}var Si;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Si||(Si={}));function Mce(e){return!tO||!e?!1:e===document.scrollingElement}function _ce(e){let t={x:0,y:0},n=Mce(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},i=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:i,isLeft:o,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}var Ztt={x:.2,y:.2};function ent(e,t,n,r,i){let{top:o,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=Ztt);let{isTop:u,isBottom:c,isLeft:d,isRight:h}=_ce(e),f={x:0,y:0},p={x:0,y:0},m={height:t.height*i.y,width:t.width*i.x};return!u&&o<=t.top+m.height?(f.y=Si.Backward,p.y=r*Math.abs((t.top+m.height-o)/m.height)):!c&&l>=t.bottom-m.height&&(f.y=Si.Forward,p.y=r*Math.abs((t.bottom-m.height-l)/m.height)),!h&&a>=t.right-m.width?(f.x=Si.Forward,p.x=r*Math.abs((t.right-m.width-a)/m.width)):!d&&s<=t.left+m.width&&(f.x=Si.Backward,p.x=r*Math.abs((t.left+m.width-s)/m.width)),{direction:f,speed:p}}function tnt(e){if(e===document.scrollingElement){let{innerWidth:o,innerHeight:s}=window;return{top:0,left:0,right:o,bottom:s,width:o,height:s}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Ece(e){return e.reduce((t,n)=>jy(t,JB(n)),vl)}function nnt(e){return e.reduce((t,n)=>t+Cce(n),0)}function rnt(e){return e.reduce((t,n)=>t+Nce(n),0)}function Oce(e,t){if(t===void 0&&(t=Fv),!e)return;let{top:n,left:r,bottom:i,right:o}=t(e);kce(e)&&(i<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}var int=[["x",["left","right"],nnt],["y",["top","bottom"],rnt]],A3=class{constructor(e,t){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;let n=T3(t),r=Ece(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[i,o,s]of int)for(let a of o)Object.defineProperty(this,a,{get:()=>{let l=s(n),u=r[i]-l;return this.rect[a]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Gw=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(t=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...t)})},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function ont(e){let{EventTarget:t}=Lo(e);return e instanceof t?e:zv(e)}function fI(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var ua;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ua||(ua={}));function eQ(e){e.preventDefault()}function snt(e){e.stopPropagation()}var on;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(on||(on={}));var Tce={start:[on.Space,on.Enter],cancel:[on.Esc],end:[on.Space,on.Enter,on.Tab]},ant=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case on.Right:return{...n,x:n.x+25};case on.Left:return{...n,x:n.x-25};case on.Down:return{...n,y:n.y+25};case on.Up:return{...n,y:n.y-25}}},Ace=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Gw(zv(t)),this.windowListeners=new Gw(Lo(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ua.Resize,this.handleCancel),this.windowListeners.add(ua.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ua.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Oce(n),t(vl)}handleKeyDown(e){if(rO(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Tce,coordinateGetter:o=ant,scrollBehavior:s="smooth"}=r,{code:a}=e;if(i.end.includes(a)){this.handleEnd(e);return}if(i.cancel.includes(a)){this.handleCancel(e);return}let{collisionRect:l}=n.current,u=l?{x:l.left,y:l.top}:vl;this.referenceCoordinates||(this.referenceCoordinates=u);let c=o(e,{active:t,context:n.current,currentCoordinates:u});if(c){let d=__(c,u),h={x:0,y:0},{scrollableAncestors:f}=n.current;for(let p of f){let m=e.code,{isTop:g,isRight:y,isLeft:v,isBottom:b,maxScroll:w,minScroll:x}=_ce(p),S=tnt(p),k={x:Math.min(m===on.Right?S.right-S.width/2:S.right,Math.max(m===on.Right?S.left:S.left+S.width/2,c.x)),y:Math.min(m===on.Down?S.bottom-S.height/2:S.bottom,Math.max(m===on.Down?S.top:S.top+S.height/2,c.y))},C=m===on.Right&&!y||m===on.Left&&!v,N=m===on.Down&&!b||m===on.Up&&!g;if(C&&k.x!==c.x){let E=p.scrollLeft+d.x,D=m===on.Right&&E<=w.x||m===on.Left&&E>=x.x;if(D&&!d.y){p.scrollTo({left:E,behavior:s});return}D?h.x=p.scrollLeft-E:h.x=m===on.Right?p.scrollLeft-w.x:p.scrollLeft-x.x,h.x&&p.scrollBy({left:-h.x,behavior:s});break}else if(N&&k.y!==c.y){let E=p.scrollTop+d.y,D=m===on.Down&&E<=w.y||m===on.Up&&E>=x.y;if(D&&!d.x){p.scrollTo({top:E,behavior:s});return}D?h.y=p.scrollTop-E:h.y=m===on.Down?p.scrollTop-w.y:p.scrollTop-x.y,h.y&&p.scrollBy({top:-h.y,behavior:s});break}}this.handleMove(e,jy(__(c,this.referenceCoordinates),h))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Ace.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=Tce,onActivation:i}=t,{active:o}=n,{code:s}=e.nativeEvent;if(r.start.includes(s)){let a=o.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function tQ(e){return!!(e&&"distance"in e)}function nQ(e){return!!(e&&"delay"in e)}var D3=class{constructor(e,t,n){var r;n===void 0&&(n=ont(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=t;let{event:i}=e,{target:o}=i;this.props=e,this.events=t,this.document=zv(o),this.documentListeners=new Gw(this.document),this.listeners=new Gw(n),this.windowListeners=new Gw(Lo(o)),this.initialCoordinates=(r=E_(i))!=null?r:vl,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(){let{events:e,props:{options:{activationConstraint:t,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(ua.Resize,this.handleCancel),this.windowListeners.add(ua.DragStart,eQ),this.windowListeners.add(ua.VisibilityChange,this.handleCancel),this.windowListeners.add(ua.ContextMenu,eQ),this.documentListeners.add(ua.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(nQ(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(tQ(t)){this.handlePending(t);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,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ua.Click,snt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ua.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;let{activated:n,initialCoordinates:r,props:i}=this,{onMove:o,options:{activationConstraint:s}}=i;if(!r)return;let a=(t=E_(e))!=null?t:vl,l=__(r,a);if(!n&&s){if(tQ(s)){if(s.tolerance!=null&&fI(l,s.tolerance))return this.handleCancel();if(fI(l,s.distance))return this.handleStart()}if(nQ(s)&&fI(l,s.tolerance))return this.handleCancel();this.handlePending(s,l);return}e.cancelable&&e.preventDefault(),o(a)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===on.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},lnt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}},Dce=class extends D3{constructor(e){let{event:t}=e,n=zv(t.target);super(e,lnt,n)}};Dce.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var unt={move:{name:"mousemove"},end:{name:"mouseup"}},ZB;(function(e){e[e.RightClick=2]="RightClick"})(ZB||(ZB={}));var Rce=class extends D3{constructor(e){super(e,unt,zv(e.event.target))}};Rce.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ZB.RightClick?!1:(r?.({event:n}),!0)}}];var pI={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}},cnt=class extends D3{constructor(e){super(e,pI)}static setup(){return window.addEventListener(pI.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(pI.move.name,e)};function e(){}}};cnt.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Xw;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Xw||(Xw={}));var T_;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(T_||(T_={}));function dnt(e){let{acceleration:t,activator:n=Xw.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:s=5,order:a=T_.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:c,delta:d,threshold:h}=e,f=fnt({delta:d,disabled:!o}),[p,m]=Stt(),g=(0,ne.useRef)({x:0,y:0}),y=(0,ne.useRef)({x:0,y:0}),v=(0,ne.useMemo)(()=>{switch(n){case Xw.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Xw.DraggableRect:return i}},[n,i,l]),b=(0,ne.useRef)(null),w=(0,ne.useCallback)(()=>{let S=b.current;if(!S)return;let k=g.current.x*y.current.x,C=g.current.y*y.current.y;S.scrollBy(k,C)},[]),x=(0,ne.useMemo)(()=>a===T_.TreeOrder?[...u].reverse():u,[a,u]);(0,ne.useEffect)(()=>{if(!o||!u.length||!v){m();return}for(let S of x){if(r?.(S)===!1)continue;let k=u.indexOf(S),C=c[k];if(!C)continue;let{direction:N,speed:E}=ent(S,C,v,t,h);for(let D of["x","y"])f[D][N[D]]||(E[D]=0,N[D]=0);if(E.x>0||E.y>0){m(),b.current=S,p(w,s),g.current=E,y.current=N;return}}g.current={x:0,y:0},y.current={x:0,y:0},m()},[t,w,r,m,o,s,JSON.stringify(v),JSON.stringify(f),p,u,x,c,JSON.stringify(h)])}var hnt={x:{[Si.Backward]:!1,[Si.Forward]:!1},y:{[Si.Backward]:!1,[Si.Forward]:!1}};function fnt(e){let{delta:t,disabled:n}=e,r=M_(t);return O1(i=>{if(n||!r||!i)return hnt;let o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Si.Backward]:i.x[Si.Backward]||o.x===-1,[Si.Forward]:i.x[Si.Forward]||o.x===1},y:{[Si.Backward]:i.y[Si.Backward]||o.y===-1,[Si.Forward]:i.y[Si.Forward]||o.y===1}}},[n,t,r])}function pnt(e,t){let n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return O1(i=>{var o;return t==null?null:(o=r??i)!=null?o:null},[r,t])}function mnt(e,t){return(0,ne.useMemo)(()=>e.reduce((n,r)=>{let{sensor:i}=r,o=i.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...o]},[]),[e,t])}var Hx;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Hx||(Hx={}));var eq;(function(e){e.Optimized="optimized"})(eq||(eq={}));var rQ=new Map;function gnt(e,t){let{dragging:n,dependencies:r,config:i}=t,[o,s]=(0,ne.useState)(null),{frequency:a,measure:l,strategy:u}=i,c=(0,ne.useRef)(e),d=g(),h=Ux(d),f=(0,ne.useCallback)(function(y){y===void 0&&(y=[]),!h.current&&s(v=>v===null?y:v.concat(y.filter(b=>!v.includes(b))))},[h]),p=(0,ne.useRef)(null),m=O1(y=>{if(d&&!n)return rQ;if(!y||y===rQ||c.current!==e||o!=null){let v=new Map;for(let b of e){if(!b)continue;if(o&&o.length>0&&!o.includes(b.id)&&b.rect.current){v.set(b.id,b.rect.current);continue}let w=b.node.current,x=w?new A3(l(w),w):null;b.rect.current=x,x&&v.set(b.id,x)}return v}return y},[e,o,n,d,l]);return(0,ne.useEffect)(()=>{c.current=e},[e]),(0,ne.useEffect)(()=>{d||f()},[n,d]),(0,ne.useEffect)(()=>{o&&o.length>0&&s(null)},[JSON.stringify(o)]),(0,ne.useEffect)(()=>{d||typeof a!="number"||p.current!==null||(p.current=setTimeout(()=>{f(),p.current=null},a))},[a,d,f,...r]),{droppableRects:m,measureDroppableContainers:f,measuringScheduled:o!=null};function g(){switch(u){case Hx.Always:return!1;case Hx.BeforeDragging:return n;default:return!n}}}function R3(e,t){return O1(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function ynt(e,t){return R3(e,t)}function vnt(e){let{callback:t,disabled:n}=e,r=nO(t),i=(0,ne.useMemo)(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;let{MutationObserver:o}=window;return new o(r)},[r,n]);return(0,ne.useEffect)(()=>()=>i?.disconnect(),[i]),i}function iO(e){let{callback:t,disabled:n}=e,r=nO(t),i=(0,ne.useMemo)(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;let{ResizeObserver:o}=window;return new o(r)},[n]);return(0,ne.useEffect)(()=>()=>i?.disconnect(),[i]),i}function bnt(e){return new A3(Fv(e),e)}function iQ(e,t,n){t===void 0&&(t=bnt);let[r,i]=(0,ne.useState)(null);function o(){i(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??n)!=null?u:null}let c=t(e);return JSON.stringify(l)===JSON.stringify(c)?l:c})}let s=vnt({callback(l){if(e)for(let u of l){let{type:c,target:d}=u;if(c==="childList"&&d instanceof HTMLElement&&d.contains(e)){o();break}}}}),a=iO({callback:o});return yl(()=>{o(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function wnt(e){let t=R3(e);return xce(e,t)}var oQ=[];function xnt(e){let t=(0,ne.useRef)(e),n=O1(r=>e?r&&r!==oQ&&e&&t.current&&e.parentNode===t.current.parentNode?r:T3(e):oQ,[e]);return(0,ne.useEffect)(()=>{t.current=e},[e]),n}function Snt(e){let[t,n]=(0,ne.useState)(null),r=(0,ne.useRef)(e),i=(0,ne.useCallback)(o=>{let s=hI(o.target);s&&n(a=>a?(a.set(s,JB(s)),new Map(a)):null)},[]);return(0,ne.useEffect)(()=>{let o=r.current;if(e!==o){s(o);let a=e.map(l=>{let u=hI(l);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,JB(u)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(o)};function s(a){a.forEach(l=>{hI(l)?.removeEventListener("scroll",i)})}},[i,e]),(0,ne.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((o,s)=>jy(o,s),vl):Ece(e):vl,[e,t])}function sQ(e,t){t===void 0&&(t=[]);let n=(0,ne.useRef)(null);return(0,ne.useEffect)(()=>{n.current=null},t),(0,ne.useEffect)(()=>{let r=e!==vl;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?__(e,n.current):vl}function knt(e){(0,ne.useEffect)(()=>{if(!tO)return;let t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(let n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Cnt(e,t){return(0,ne.useMemo)(()=>e.reduce((n,r)=>{let{eventName:i,handler:o}=r;return n[i]=s=>{o(s,t)},n},{}),[e,t])}function Ice(e){return(0,ne.useMemo)(()=>e?Gtt(e):null,[e])}var aQ=[];function Nnt(e,t){t===void 0&&(t=Fv);let[n]=e,r=Ice(n?Lo(n):null),[i,o]=(0,ne.useState)(aQ);function s(){o(()=>e.length?e.map(l=>Mce(l)?r:new A3(t(l),l)):aQ)}let a=iO({callback:s});return yl(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),i}function Pce(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return E1(t)?t:e}function Mnt(e){let{measure:t}=e,[n,r]=(0,ne.useState)(null),i=(0,ne.useCallback)(u=>{for(let{target:c}of u)if(E1(c)){r(d=>{let h=t(c);return d?{...d,width:h.width,height:h.height}:h});break}},[t]),o=iO({callback:i}),s=(0,ne.useCallback)(u=>{let c=Pce(u);o?.disconnect(),c&&o?.observe(c),r(c?t(c):null)},[t,o]),[a,l]=N_(s);return(0,ne.useMemo)(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}var _nt=[{sensor:Dce,options:{}},{sensor:Ace,options:{}}],Ent={current:{}},dM={draggable:{measure:ZY},droppable:{measure:ZY,strategy:Hx.WhileDragging,frequency:eq.Optimized},dragOverlay:{measure:Fv}},Jw=class extends Map{get(e){var t;return e!=null&&(t=super.get(e))!=null?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,n;return(t=(n=this.get(e))==null?void 0:n.node.current)!=null?t:void 0}},Ont={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Jw,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:O_},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:dM,measureDroppableContainers:O_,windowRect:null,measuringScheduled:!1},Lce={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:O_,draggableNodes:new Map,over:null,measureDroppableContainers:O_},A1=(0,ne.createContext)(Lce),Bce=(0,ne.createContext)(Ont);function Tnt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Jw}}}function Ant(e,t){switch(t.type){case di.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case di.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case di.DragEnd:case di.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case di.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Jw(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case di.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;let s=new Jw(e.droppable.containers);return s.set(n,{...o,disabled:i}),{...e,droppable:{...e.droppable,containers:s}}}case di.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let o=new Jw(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function Dnt(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,ne.useContext)(A1),o=M_(r),s=M_(n?.id);return(0,ne.useEffect)(()=>{if(!t&&!r&&o&&s!=null){if(!rO(o)||document.activeElement===o.target)return;let a=i.get(s);if(!a)return;let{activatorNode:l,node:u}=a;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(let c of[l.current,u.current]){if(!c)continue;let d=Ntt(c);if(d){d.focus();break}}})}},[r,t,i,s,o]),null}function qce(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((i,o)=>o({transform:i,...r}),n):n}function Rnt(e){return(0,ne.useMemo)(()=>({draggable:{...dM.draggable,...e?.draggable},droppable:{...dM.droppable,...e?.droppable},dragOverlay:{...dM.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Int(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,o=(0,ne.useRef)(!1),{x:s,y:a}=typeof i=="boolean"?{x:i,y:i}:i;yl(()=>{if(!s&&!a||!t){o.current=!1;return}if(o.current||!r)return;let l=t?.node.current;if(!l||l.isConnected===!1)return;let u=n(l),c=xce(u,r);if(s||(c.x=0),a||(c.y=0),o.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){let d=kce(l);d&&d.scrollBy({top:c.y,left:c.x})}},[t,s,a,r,n])}var oO=(0,ne.createContext)({...vl,scaleX:1,scaleY:1}),rh;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(rh||(rh={}));var Pnt=(0,ne.memo)(function(e){var t,n,r,i;let{id:o,accessibility:s,autoScroll:a=!0,children:l,sensors:u=_nt,collisionDetection:c=Utt,measuring:d,modifiers:h,...f}=e,p=(0,ne.useReducer)(Ant,void 0,Tnt),[m,g]=p,[y,v]=Att(),[b,w]=(0,ne.useState)(rh.Uninitialized),x=b===rh.Initialized,{draggable:{active:S,nodes:k,translate:C},droppable:{containers:N}}=m,E=S!=null?k.get(S):null,D=(0,ne.useRef)({initial:null,translated:null}),q=(0,ne.useMemo)(()=>{var ye;return S!=null?{id:S,data:(ye=E?.data)!=null?ye:Ent,rect:D}:null},[S,E]),z=(0,ne.useRef)(null),[_,R]=(0,ne.useState)(null),[T,B]=(0,ne.useState)(null),A=Ux(f,Object.values(f)),M=T1("DndDescribedBy",o),P=(0,ne.useMemo)(()=>N.getEnabled(),[N]),F=Rnt(d),{droppableRects:I,measureDroppableContainers:V,measuringScheduled:W}=gnt(P,{dragging:x,dependencies:[C.x,C.y],config:F.droppable}),j=pnt(k,S),X=(0,ne.useMemo)(()=>T?E_(T):null,[T]),$=Be(),K=ynt(j,F.draggable.measure);Int({activeNode:S!=null?k.get(S):null,config:$.layoutShiftCompensation,initialRect:K,measure:F.draggable.measure});let Q=iQ(j,F.draggable.measure,K),J=iQ(j?j.parentElement:null),oe=(0,ne.useRef)({activatorEvent:null,active:null,activeNode:j,collisionRect:null,collisions:null,droppableRects:I,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),be=N.getNodeFor((t=oe.current.over)==null?void 0:t.id),Me=Mnt({measure:F.dragOverlay.measure}),Je=(n=Me.nodeRef.current)!=null?n:j,Ve=x?(r=Me.rect)!=null?r:Q:null,Ct=!!(Me.nodeRef.current&&Me.rect),He=wnt(Ct?null:Q),de=Ice(Je?Lo(Je):null),ie=xnt(x?be??j:null),ze=Nnt(ie),Le=qce(h,{transform:{x:C.x-He.x,y:C.y-He.y,scaleX:1,scaleY:1},activatorEvent:T,active:q,activeNodeRect:Q,containerNodeRect:J,draggingNodeRect:Ve,over:oe.current.over,overlayNodeRect:Me.rect,scrollableAncestors:ie,scrollableAncestorRects:ze,windowRect:de}),Oe=X?jy(X,C):null,rt=Snt(ie),Ht=sQ(rt),$t=sQ(rt,[Q]),dt=jy(Le,Ht),et=Ve?Ktt(Ve,Le):null,pt=q&&et?c({active:q,collisionRect:et,droppableRects:I,droppableContainers:P,pointerCoordinates:Oe}):null,nn=jtt(pt,"id"),[Dt,Ot]=(0,ne.useState)(null),Kt=Ct?Le:jy(Le,$t),Er=Htt(Kt,(i=Dt?.rect)!=null?i:null,Q),Dn=(0,ne.useRef)(null),Zn=(0,ne.useCallback)((ye,De)=>{let{sensor:gt,options:ce}=De;if(z.current==null)return;let $e=k.get(z.current);if(!$e)return;let it=ye.nativeEvent,Jt=new gt({active:z.current,activeNode:$e,event:it,options:ce,context:oe,onAbort(tt){if(!k.get(tt))return;let{onDragAbort:vn}=A.current,Yt={id:tt};vn?.(Yt),y({type:"onDragAbort",event:Yt})},onPending(tt,vn,Yt,Mt){if(!k.get(tt))return;let{onDragPending:bt}=A.current,Rn={id:tt,constraint:vn,initialCoordinates:Yt,offset:Mt};bt?.(Rn),y({type:"onDragPending",event:Rn})},onStart(tt){let vn=z.current;if(vn==null)return;let Yt=k.get(vn);if(!Yt)return;let{onDragStart:Mt}=A.current,bt={activatorEvent:it,active:{id:vn,data:Yt.data,rect:D}};(0,Op.unstable_batchedUpdates)(()=>{Mt?.(bt),w(rh.Initializing),g({type:di.DragStart,initialCoordinates:tt,active:vn}),y({type:"onDragStart",event:bt}),R(Dn.current),B(it)})},onMove(tt){g({type:di.DragMove,coordinates:tt})},onEnd:Nt(di.DragEnd),onCancel:Nt(di.DragCancel)});Dn.current=Jt;function Nt(tt){return async function(){let{active:vn,collisions:Yt,over:Mt,scrollAdjustedTranslate:bt}=oe.current,Rn=null;if(vn&&bt){let{cancelDrop:ps}=A.current;Rn={activatorEvent:it,active:vn,collisions:Yt,delta:bt,over:Mt},tt===di.DragEnd&&typeof ps=="function"&&await Promise.resolve(ps(Rn))&&(tt=di.DragCancel)}z.current=null,(0,Op.unstable_batchedUpdates)(()=>{g({type:tt}),w(rh.Uninitialized),Ot(null),R(null),B(null),Dn.current=null;let ps=tt===di.DragEnd?"onDragEnd":"onDragCancel";if(Rn){let md=A.current[ps];md?.(Rn),y({type:ps,event:Rn})}})}}},[k]),Un=(0,ne.useCallback)((ye,De)=>(gt,ce)=>{let $e=gt.nativeEvent,it=k.get(ce);if(z.current!==null||!it||$e.dndKit||$e.defaultPrevented)return;let Jt={active:it};ye(gt,De.options,Jt)===!0&&($e.dndKit={capturedBy:De.sensor},z.current=ce,Zn(gt,De))},[k,Zn]),he=mnt(u,Un);knt(u),yl(()=>{Q&&b===rh.Initializing&&w(rh.Initialized)},[Q,b]),(0,ne.useEffect)(()=>{let{onDragMove:ye}=A.current,{active:De,activatorEvent:gt,collisions:ce,over:$e}=oe.current;if(!De||!gt)return;let it={active:De,activatorEvent:gt,collisions:ce,delta:{x:dt.x,y:dt.y},over:$e};(0,Op.unstable_batchedUpdates)(()=>{ye?.(it),y({type:"onDragMove",event:it})})},[dt.x,dt.y]),(0,ne.useEffect)(()=>{let{active:ye,activatorEvent:De,collisions:gt,droppableContainers:ce,scrollAdjustedTranslate:$e}=oe.current;if(!ye||z.current==null||!De||!$e)return;let{onDragOver:it}=A.current,Jt=ce.get(nn),Nt=Jt&&Jt.rect.current?{id:Jt.id,rect:Jt.rect.current,data:Jt.data,disabled:Jt.disabled}:null,tt={active:ye,activatorEvent:De,collisions:gt,delta:{x:$e.x,y:$e.y},over:Nt};(0,Op.unstable_batchedUpdates)(()=>{Ot(Nt),it?.(tt),y({type:"onDragOver",event:tt})})},[nn]),yl(()=>{oe.current={activatorEvent:T,active:q,activeNode:j,collisionRect:et,collisions:pt,droppableRects:I,draggableNodes:k,draggingNode:Je,draggingNodeRect:Ve,droppableContainers:N,over:Dt,scrollableAncestors:ie,scrollAdjustedTranslate:dt},D.current={initial:Ve,translated:et}},[q,j,pt,et,k,Je,Ve,I,N,Dt,ie,dt]),dnt({...$,delta:C,draggingRect:et,pointerCoordinates:Oe,scrollableAncestors:ie,scrollableAncestorRects:ze});let Ae=(0,ne.useMemo)(()=>({active:q,activeNode:j,activeNodeRect:Q,activatorEvent:T,collisions:pt,containerNodeRect:J,dragOverlay:Me,draggableNodes:k,droppableContainers:N,droppableRects:I,over:Dt,measureDroppableContainers:V,scrollableAncestors:ie,scrollableAncestorRects:ze,measuringConfiguration:F,measuringScheduled:W,windowRect:de}),[q,j,Q,T,pt,J,Me,k,N,I,Dt,V,ie,ze,F,W,de]),ge=(0,ne.useMemo)(()=>({activatorEvent:T,activators:he,active:q,activeNodeRect:Q,ariaDescribedById:{draggable:M},dispatch:g,draggableNodes:k,over:Dt,measureDroppableContainers:V}),[T,he,q,Q,g,M,k,Dt,V]);return ne.default.createElement(wce.Provider,{value:v},ne.default.createElement(A1.Provider,{value:ge},ne.default.createElement(Bce.Provider,{value:Ae},ne.default.createElement(oO.Provider,{value:Er},l)),ne.default.createElement(Dnt,{disabled:s?.restoreFocus===!1})),ne.default.createElement(Itt,{...s,hiddenTextDescribedById:M}));function Be(){let ye=_?.autoScrollEnabled===!1,De=typeof a=="object"?a.enabled===!1:a===!1,gt=x&&!ye&&!De;return typeof a=="object"?{...a,enabled:gt}:{enabled:gt}}}),Lnt=(0,ne.createContext)(null),lQ="button",Bnt="Draggable";function qnt(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,o=T1(Bnt),{activators:s,activatorEvent:a,active:l,activeNodeRect:u,ariaDescribedById:c,draggableNodes:d,over:h}=(0,ne.useContext)(A1),{role:f=lQ,roleDescription:p="draggable",tabIndex:m=0}=i??{},g=l?.id===t,y=(0,ne.useContext)(g?oO:Lnt),[v,b]=N_(),[w,x]=N_(),S=Cnt(s,t),k=Ux(n);yl(()=>(d.set(t,{id:t,key:o,node:v,activatorNode:w,data:k}),()=>{let N=d.get(t);N&&N.key===o&&d.delete(t)}),[d,t]);let C=(0,ne.useMemo)(()=>({role:f,tabIndex:m,"aria-disabled":r,"aria-pressed":g&&f===lQ?!0:void 0,"aria-roledescription":p,"aria-describedby":c.draggable}),[r,f,m,g,p,c.draggable]);return{active:l,activatorEvent:a,activeNodeRect:u,attributes:C,isDragging:g,listeners:r?void 0:S,node:v,over:h,setNodeRef:b,setActivatorNodeRef:x,transform:y}}function zce(){return(0,ne.useContext)(Bce)}var znt="Droppable",Fnt={timeout:25};function jnt(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,o=T1(znt),{active:s,dispatch:a,over:l,measureDroppableContainers:u}=(0,ne.useContext)(A1),c=(0,ne.useRef)({disabled:n}),d=(0,ne.useRef)(!1),h=(0,ne.useRef)(null),f=(0,ne.useRef)(null),{disabled:p,updateMeasurementsFor:m,timeout:g}={...Fnt,...i},y=Ux(m??r),v=(0,ne.useCallback)(()=>{if(!d.current){d.current=!0;return}f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),f.current=null},g)},[g]),b=iO({callback:v,disabled:p||!s}),w=(0,ne.useCallback)((C,N)=>{b&&(N&&(b.unobserve(N),d.current=!1),C&&b.observe(C))},[b]),[x,S]=N_(w),k=Ux(t);return(0,ne.useEffect)(()=>{!b||!x.current||(b.disconnect(),d.current=!1,b.observe(x.current))},[x,b]),(0,ne.useEffect)(()=>(a({type:di.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:h,data:k}}),()=>a({type:di.UnregisterDroppable,key:o,id:r})),[r]),(0,ne.useEffect)(()=>{n!==c.current.disabled&&(a({type:di.SetDroppableDisabled,id:r,key:o,disabled:n}),c.current.disabled=n)},[r,o,n,a]),{active:s,rect:h,isOver:l?.id===r,node:x,over:l,setNodeRef:S}}function Vnt(e){let{animation:t,children:n}=e,[r,i]=(0,ne.useState)(null),[o,s]=(0,ne.useState)(null),a=M_(n);return!n&&!r&&a&&i(a),yl(()=>{if(!o)return;let l=r?.key,u=r?.props.id;if(l==null||u==null){i(null);return}Promise.resolve(t(u,o)).then(()=>{i(null)})},[t,r,o]),ne.default.createElement(ne.default.Fragment,null,n,r?(0,ne.cloneElement)(r,{ref:s}):null)}var Wnt={x:0,y:0,scaleX:1,scaleY:1};function Unt(e){let{children:t}=e;return ne.default.createElement(A1.Provider,{value:Lce},ne.default.createElement(oO.Provider,{value:Wnt},t))}var Hnt={position:"fixed",touchAction:"none"},$nt=e=>rO(e)?"transform 250ms ease":void 0,Knt=(0,ne.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:o,className:s,rect:a,style:l,transform:u,transition:c=$nt}=e;if(!a)return null;let d=i?u:{...u,scaleX:1,scaleY:1},h={...Hnt,width:a.width,height:a.height,top:a.top,left:a.left,transform:qh.Transform.toString(d),transformOrigin:i&&r?qtt(r,a):void 0,transition:typeof c=="function"?c(r):c,...l};return ne.default.createElement(n,{className:s,style:h,ref:t},o)}),Ynt=e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:o,className:s}=e;if(o!=null&&o.active)for(let[a,l]of Object.entries(o.active))l!==void 0&&(i[a]=n.node.style.getPropertyValue(a),n.node.style.setProperty(a,l));if(o!=null&&o.dragOverlay)for(let[a,l]of Object.entries(o.dragOverlay))l!==void 0&&r.node.style.setProperty(a,l);return s!=null&&s.active&&n.node.classList.add(s.active),s!=null&&s.dragOverlay&&r.node.classList.add(s.dragOverlay),function(){for(let[a,l]of Object.entries(i))n.node.style.setProperty(a,l);s!=null&&s.active&&n.node.classList.remove(s.active)}},Qnt=e=>{let{transform:{initial:t,final:n}}=e;return[{transform:qh.Transform.toString(t)},{transform:qh.Transform.toString(n)}]},Gnt={duration:250,easing:"ease",keyframes:Qnt,sideEffects:Ynt({styles:{active:{opacity:"0"}}})};function Xnt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return nO((o,s)=>{if(t===null)return;let a=n.get(o);if(!a)return;let l=a.node.current;if(!l)return;let u=Pce(s);if(!u)return;let{transform:c}=Lo(s).getComputedStyle(s),d=Sce(c);if(!d)return;let h=typeof t=="function"?t:Jnt(t);return Oce(l,i.draggable.measure),h({active:{id:o,data:a.data,node:l,rect:i.draggable.measure(l)},draggableNodes:n,dragOverlay:{node:s,rect:i.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:i,transform:d})})}function Jnt(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...Gnt,...e};return o=>{let{active:s,dragOverlay:a,transform:l,...u}=o;if(!t)return;let c={x:a.rect.left-s.rect.left,y:a.rect.top-s.rect.top},d={scaleX:l.scaleX!==1?s.rect.width*l.scaleX/a.rect.width:1,scaleY:l.scaleY!==1?s.rect.height*l.scaleY/a.rect.height:1},h={x:l.x-c.x,y:l.y-c.y,...d},f=i({...u,active:s,dragOverlay:a,transform:{initial:l,final:h}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let g=r?.({active:s,dragOverlay:a,...u}),y=a.node.animate(f,{duration:t,easing:n,fill:"forwards"});return new Promise(v=>{y.onfinish=()=>{g?.(),v()}})}}var uQ=0;function Znt(e){return(0,ne.useMemo)(()=>{if(e!=null)return uQ++,uQ},[e])}var ert=ne.default.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:o,modifiers:s,wrapperElement:a="div",className:l,zIndex:u=999}=e,{activatorEvent:c,active:d,activeNodeRect:h,containerNodeRect:f,draggableNodes:p,droppableContainers:m,dragOverlay:g,over:y,measuringConfiguration:v,scrollableAncestors:b,scrollableAncestorRects:w,windowRect:x}=zce(),S=(0,ne.useContext)(oO),k=Znt(d?.id),C=qce(s,{activatorEvent:c,active:d,activeNodeRect:h,containerNodeRect:f,draggingNodeRect:g.rect,over:y,overlayNodeRect:g.rect,scrollableAncestors:b,scrollableAncestorRects:w,transform:S,windowRect:x}),N=R3(h),E=Xnt({config:r,draggableNodes:p,droppableContainers:m,measuringConfiguration:v}),D=N?g.setRef:void 0;return ne.default.createElement(Unt,null,ne.default.createElement(Vnt,{animation:E},d&&k?ne.default.createElement(Knt,{key:k,id:d.id,ref:D,as:a,activatorEvent:c,adjustScale:t,className:l,transition:o,rect:N,style:{zIndex:u,...i},transform:C},n):null))});function Zw(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function trt(e,t){return e.reduce((n,r,i)=>{let o=t.get(r);return o&&(n[i]=o),n},Array(e.length))}function vN(e){return e!==null&&e>=0}function nrt(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function rrt(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}var bN={scaleX:1,scaleY:1},mI=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:i,overIndex:o,index:s}=e,a=(t=n[i])!=null?t:r;if(!a)return null;let l=irt(n,s,i);if(s===i){let u=n[o];return u?{x:i<o?u.left+u.width-(a.left+a.width):u.left-a.left,y:0,...bN}:null}return s>i&&s<=o?{x:-a.width-l,y:0,...bN}:s<i&&s>=o?{x:a.width+l,y:0,...bN}:{x:0,y:0,...bN}};function irt(e,t,n){let r=e[t],i=e[t-1],o=e[t+1];return!r||!i&&!o?0:n<t?i?r.left-(i.left+i.width):o.left-(r.left+r.width):o?o.left-(r.left+r.width):r.left-(i.left+i.width)}var Fce=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,o=Zw(t,r,n),s=t[i],a=o[i];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},jce="Sortable",Vce=Lr.default.createContext({activeIndex:-1,containerId:jce,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Fce,disabled:{draggable:!1,droppable:!1}});function gI(e){let{children:t,id:n,items:r,strategy:i=Fce,disabled:o=!1}=e,{active:s,dragOverlay:a,droppableRects:l,over:u,measureDroppableContainers:c}=zce(),d=T1(jce,n),h=a.rect!==null,f=(0,Lr.useMemo)(()=>r.map(S=>typeof S=="object"&&"id"in S?S.id:S),[r]),p=s!=null,m=s?f.indexOf(s.id):-1,g=u?f.indexOf(u.id):-1,y=(0,Lr.useRef)(f),v=!nrt(f,y.current),b=g!==-1&&m===-1||v,w=rrt(o);yl(()=>{v&&p&&c(f)},[v,f,p,c]),(0,Lr.useEffect)(()=>{y.current=f},[f]);let x=(0,Lr.useMemo)(()=>({activeIndex:m,containerId:d,disabled:w,disableTransforms:b,items:f,overIndex:g,useDragOverlay:h,sortedRects:trt(f,l),strategy:i}),[m,d,w.draggable,w.droppable,b,f,g,l,h,i]);return Lr.default.createElement(Vce.Provider,{value:x},t)}var ort=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return Zw(n,r,i).indexOf(t)},srt=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:o,newIndex:s,previousItems:a,previousContainerId:l,transition:u}=e;return!u||!r||a!==o&&i===s?!1:n?!0:s!==i&&t===l},art={duration:200,easing:"ease"},Wce="transform",lrt=qh.Transition.toString({property:Wce,duration:0,easing:"linear"}),urt={roleDescription:"sortable"};function crt(e){let{disabled:t,index:n,node:r,rect:i}=e,[o,s]=(0,Lr.useState)(null),a=(0,Lr.useRef)(n);return yl(()=>{if(!t&&n!==a.current&&r.current){let l=i.current;if(l){let u=Fv(r.current,{ignoreTransform:!0}),c={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(c.x||c.y)&&s(c)}}n!==a.current&&(a.current=n)},[t,n,r,i]),(0,Lr.useEffect)(()=>{o&&s(null)},[o]),o}function drt(e){let{animateLayoutChanges:t=srt,attributes:n,disabled:r,data:i,getNewIndex:o=ort,id:s,strategy:a,resizeObserverConfig:l,transition:u=art}=e,{items:c,containerId:d,activeIndex:h,disabled:f,disableTransforms:p,sortedRects:m,overIndex:g,useDragOverlay:y,strategy:v}=(0,Lr.useContext)(Vce),b=hrt(r,f),w=c.indexOf(s),x=(0,Lr.useMemo)(()=>({sortable:{containerId:d,index:w,items:c},...i}),[d,i,w,c]),S=(0,Lr.useMemo)(()=>c.slice(c.indexOf(s)),[c,s]),{rect:k,node:C,isOver:N,setNodeRef:E}=jnt({id:s,data:x,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...l}}),{active:D,activatorEvent:q,activeNodeRect:z,attributes:_,setNodeRef:R,listeners:T,isDragging:B,over:A,setActivatorNodeRef:M,transform:P}=qnt({id:s,data:x,attributes:{...urt,...n},disabled:b.draggable}),F=xtt(E,R),I=!!D,V=I&&!p&&vN(h)&&vN(g),W=!y&&B,j=W&&V?P:null,X=V?j??(a??v)({rects:m,activeNodeRect:z,activeIndex:h,overIndex:g,index:w}):null,$=vN(h)&&vN(g)?o({id:s,items:c,activeIndex:h,overIndex:g}):w,K=D?.id,Q=(0,Lr.useRef)({activeId:K,items:c,newIndex:$,containerId:d}),J=c!==Q.current.items,oe=t({active:D,containerId:d,isDragging:B,isSorting:I,id:s,index:w,items:c,newIndex:Q.current.newIndex,previousItems:Q.current.items,previousContainerId:Q.current.containerId,transition:u,wasDragging:Q.current.activeId!=null}),be=crt({disabled:!oe,index:w,node:C,rect:k});return(0,Lr.useEffect)(()=>{I&&Q.current.newIndex!==$&&(Q.current.newIndex=$),d!==Q.current.containerId&&(Q.current.containerId=d),c!==Q.current.items&&(Q.current.items=c)},[I,$,d,c]),(0,Lr.useEffect)(()=>{if(K===Q.current.activeId)return;if(K!=null&&Q.current.activeId==null){Q.current.activeId=K;return}let Je=setTimeout(()=>{Q.current.activeId=K},50);return()=>clearTimeout(Je)},[K]),{active:D,activeIndex:h,attributes:_,data:x,rect:k,index:w,newIndex:$,items:c,isOver:N,isSorting:I,isDragging:B,listeners:T,node:C,overIndex:g,over:A,setNodeRef:F,setActivatorNodeRef:M,setDroppableNodeRef:E,setDraggableNodeRef:R,transform:be??X,transition:Me()};function Me(){if(be||J&&Q.current.newIndex===w)return lrt;if(!(W&&!rO(q)||!u)&&(I||oe))return qh.Transition.toString({...u,property:Wce})}}function hrt(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}var nvt=[on.Down,on.Right,on.Up,on.Left];function mh(e,t){return typeof e=="function"?e(t):e}function qs(e,t){return n=>{t.setState(r=>({...r,[e]:mh(n,r[e])}))}}function sO(e){return e instanceof Function}function frt(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function prt(e,t){let n=[],r=i=>{i.forEach(o=>{n.push(o);let s=t(o);s!=null&&s.length&&r(s)})};return r(e),n}function ot(e,t,n){let r=[],i;return o=>{let s;n.key&&n.debug&&(s=Date.now());let a=e(o);if(!(a.length!==r.length||a.some((u,c)=>r[c]!==u)))return i;r=a;let l;if(n.key&&n.debug&&(l=Date.now()),i=t(...a),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){let u=Math.round((Date.now()-s)*100)/100,c=Math.round((Date.now()-l)*100)/100,d=c/16,h=(f,p)=>{for(f=String(f);f.length<p;)f=" "+f;return f};console.info(`%c\u23F1 ${h(c,5)} /${h(u,5)} ms`,`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(0,Math.min(120-120*d,120))}deg 100% 31%);`,n?.key)}return i}}function st(e,t,n,r){return{debug:()=>{var i;return(i=e?.debugAll)!=null?i:e[t]},key:!1,onChange:r}}function mrt(e,t,n,r){let i=()=>{var s;return(s=o.getValue())!=null?s:e.options.renderFallbackValue},o={id:`${t.id}_${n.id}`,row:t,column:n,getValue:()=>t.getValue(r),renderValue:i,getContext:ot(()=>[e,n,t,o],(s,a,l,u)=>({table:s,column:a,row:l,cell:u,getValue:u.getValue,renderValue:u.renderValue}),st(e.options,"debugCells","cell.getContext"))};return e._features.forEach(s=>{s.createCell==null||s.createCell(o,n,t,e)},{}),o}function grt(e,t,n,r){var i,o;let s={...e._getDefaultColumnDef(),...t},a=s.accessorKey,l=(i=(o=s.id)!=null?o:a?typeof String.prototype.replaceAll=="function"?a.replaceAll(".","_"):a.replace(/\./g,"_"):void 0)!=null?i:typeof s.header=="string"?s.header:void 0,u;if(s.accessorFn?u=s.accessorFn:a&&(a.includes(".")?u=d=>{let h=d;for(let p of a.split(".")){var f;h=(f=h)==null?void 0:f[p],h===void 0&&console.warn(`"${p}" in deeply nested key "${a}" returned undefined.`)}return h}:u=d=>d[s.accessorKey]),!l)throw new Error(s.accessorFn?"Columns require an id when using an accessorFn":"Columns require an id when using a non-string header");let c={id:`${String(l)}`,accessorFn:u,parent:r,depth:n,columnDef:s,columns:[],getFlatColumns:ot(()=>[!0],()=>{var d;return[c,...(d=c.columns)==null?void 0:d.flatMap(h=>h.getFlatColumns())]},st(e.options,"debugColumns","column.getFlatColumns")),getLeafColumns:ot(()=>[e._getOrderColumnsFn()],d=>{var h;if((h=c.columns)!=null&&h.length){let f=c.columns.flatMap(p=>p.getLeafColumns());return d(f)}return[c]},st(e.options,"debugColumns","column.getLeafColumns"))};for(let d of e._features)d.createColumn==null||d.createColumn(c,e);return c}var Zi="debugHeaders";function cQ(e,t,n){var r;let i={id:(r=n.id)!=null?r:t.id,column:t,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{let o=[],s=a=>{a.subHeaders&&a.subHeaders.length&&a.subHeaders.map(s),o.push(a)};return s(i),o},getContext:()=>({table:e,header:i,column:t})};return e._features.forEach(o=>{o.createHeader==null||o.createHeader(i,e)}),i}var yrt={createTable:e=>{e.getHeaderGroups=ot(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>{var o,s;let a=(o=r?.map(c=>n.find(d=>d.id===c)).filter(Boolean))!=null?o:[],l=(s=i?.map(c=>n.find(d=>d.id===c)).filter(Boolean))!=null?s:[],u=n.filter(c=>!(r!=null&&r.includes(c.id))&&!(i!=null&&i.includes(c.id)));return wN(t,[...a,...u,...l],e)},st(e.options,Zi,"getHeaderGroups")),e.getCenterHeaderGroups=ot(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r,i)=>(n=n.filter(o=>!(r!=null&&r.includes(o.id))&&!(i!=null&&i.includes(o.id))),wN(t,n,e,"center")),st(e.options,Zi,"getCenterHeaderGroups")),e.getLeftHeaderGroups=ot(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.left],(t,n,r)=>{var i;let o=(i=r?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?i:[];return wN(t,o,e,"left")},st(e.options,Zi,"getLeftHeaderGroups")),e.getRightHeaderGroups=ot(()=>[e.getAllColumns(),e.getVisibleLeafColumns(),e.getState().columnPinning.right],(t,n,r)=>{var i;let o=(i=r?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?i:[];return wN(t,o,e,"right")},st(e.options,Zi,"getRightHeaderGroups")),e.getFooterGroups=ot(()=>[e.getHeaderGroups()],t=>[...t].reverse(),st(e.options,Zi,"getFooterGroups")),e.getLeftFooterGroups=ot(()=>[e.getLeftHeaderGroups()],t=>[...t].reverse(),st(e.options,Zi,"getLeftFooterGroups")),e.getCenterFooterGroups=ot(()=>[e.getCenterHeaderGroups()],t=>[...t].reverse(),st(e.options,Zi,"getCenterFooterGroups")),e.getRightFooterGroups=ot(()=>[e.getRightHeaderGroups()],t=>[...t].reverse(),st(e.options,Zi,"getRightFooterGroups")),e.getFlatHeaders=ot(()=>[e.getHeaderGroups()],t=>t.map(n=>n.headers).flat(),st(e.options,Zi,"getFlatHeaders")),e.getLeftFlatHeaders=ot(()=>[e.getLeftHeaderGroups()],t=>t.map(n=>n.headers).flat(),st(e.options,Zi,"getLeftFlatHeaders")),e.getCenterFlatHeaders=ot(()=>[e.getCenterHeaderGroups()],t=>t.map(n=>n.headers).flat(),st(e.options,Zi,"getCenterFlatHeaders")),e.getRightFlatHeaders=ot(()=>[e.getRightHeaderGroups()],t=>t.map(n=>n.headers).flat(),st(e.options,Zi,"getRightFlatHeaders")),e.getCenterLeafHeaders=ot(()=>[e.getCenterFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),st(e.options,Zi,"getCenterLeafHeaders")),e.getLeftLeafHeaders=ot(()=>[e.getLeftFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),st(e.options,Zi,"getLeftLeafHeaders")),e.getRightLeafHeaders=ot(()=>[e.getRightFlatHeaders()],t=>t.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),st(e.options,Zi,"getRightLeafHeaders")),e.getLeafHeaders=ot(()=>[e.getLeftHeaderGroups(),e.getCenterHeaderGroups(),e.getRightHeaderGroups()],(t,n,r)=>{var i,o,s,a,l,u;return[...(i=(o=t[0])==null?void 0:o.headers)!=null?i:[],...(s=(a=n[0])==null?void 0:a.headers)!=null?s:[],...(l=(u=r[0])==null?void 0:u.headers)!=null?l:[]].map(c=>c.getLeafHeaders()).flat()},st(e.options,Zi,"getLeafHeaders"))}};function wN(e,t,n,r){var i,o;let s=0,a=function(h,f){f===void 0&&(f=1),s=Math.max(s,f),h.filter(p=>p.getIsVisible()).forEach(p=>{var m;(m=p.columns)!=null&&m.length&&a(p.columns,f+1)},0)};a(e);let l=[],u=(h,f)=>{let p={depth:f,id:[r,`${f}`].filter(Boolean).join("_"),headers:[]},m=[];h.forEach(g=>{let y=[...m].reverse()[0],v=g.column.depth===p.depth,b,w=!1;if(v&&g.column.parent?b=g.column.parent:(b=g.column,w=!0),y&&y?.column===b)y.subHeaders.push(g);else{let x=cQ(n,b,{id:[r,f,b.id,g?.id].filter(Boolean).join("_"),isPlaceholder:w,placeholderId:w?`${m.filter(S=>S.column===b).length}`:void 0,depth:f,index:m.length});x.subHeaders.push(g),m.push(x)}p.headers.push(g),g.headerGroup=p}),l.push(p),f>0&&u(m,f-1)},c=t.map((h,f)=>cQ(n,h,{depth:s,index:f}));u(c,s-1),l.reverse();let d=h=>h.filter(f=>f.column.getIsVisible()).map(f=>{let p=0,m=0,g=[0];f.subHeaders&&f.subHeaders.length?(g=[],d(f.subHeaders).forEach(v=>{let{colSpan:b,rowSpan:w}=v;p+=b,g.push(w)})):p=1;let y=Math.min(...g);return m=m+y,f.colSpan=p,f.rowSpan=m,{colSpan:p,rowSpan:m}});return d((i=(o=l[0])==null?void 0:o.headers)!=null?i:[]),l}var vrt=(e,t,n,r,i,o,s)=>{let a={id:t,index:r,original:n,depth:i,parentId:s,_valuesCache:{},_uniqueValuesCache:{},getValue:l=>{if(a._valuesCache.hasOwnProperty(l))return a._valuesCache[l];let u=e.getColumn(l);if(u!=null&&u.accessorFn)return a._valuesCache[l]=u.accessorFn(a.original,r),a._valuesCache[l]},getUniqueValues:l=>{if(a._uniqueValuesCache.hasOwnProperty(l))return a._uniqueValuesCache[l];let u=e.getColumn(l);if(u!=null&&u.accessorFn)return u.columnDef.getUniqueValues?(a._uniqueValuesCache[l]=u.columnDef.getUniqueValues(a.original,r),a._uniqueValuesCache[l]):(a._uniqueValuesCache[l]=[a.getValue(l)],a._uniqueValuesCache[l])},renderValue:l=>{var u;return(u=a.getValue(l))!=null?u:e.options.renderFallbackValue},subRows:o??[],getLeafRows:()=>prt(a.subRows,l=>l.subRows),getParentRow:()=>a.parentId?e.getRow(a.parentId,!0):void 0,getParentRows:()=>{let l=[],u=a;for(;;){let c=u.getParentRow();if(!c)break;l.push(c),u=c}return l.reverse()},getAllCells:ot(()=>[e.getAllLeafColumns()],l=>l.map(u=>mrt(e,a,u,u.id)),st(e.options,"debugRows","getAllCells")),_getAllCellsByColumnId:ot(()=>[a.getAllCells()],l=>l.reduce((u,c)=>(u[c.column.id]=c,u),{}),st(e.options,"debugRows","getAllCellsByColumnId"))};for(let l=0;l<e._features.length;l++){let u=e._features[l];u==null||u.createRow==null||u.createRow(a,e)}return a},brt={createColumn:(e,t)=>{e._getFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,e.id),e.getFacetedRowModel=()=>e._getFacetedRowModel?e._getFacetedRowModel():t.getPreFilteredRowModel(),e._getFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,e.id),e.getFacetedUniqueValues=()=>e._getFacetedUniqueValues?e._getFacetedUniqueValues():new Map,e._getFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,e.id),e.getFacetedMinMaxValues=()=>{if(e._getFacetedMinMaxValues)return e._getFacetedMinMaxValues()}}},Uce=(e,t,n)=>{var r,i;let o=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=e.getValue(t))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(o))};Uce.autoRemove=e=>hl(e);var Hce=(e,t,n)=>{var r;return!!(!((r=e.getValue(t))==null||(r=r.toString())==null)&&r.includes(n))};Hce.autoRemove=e=>hl(e);var $ce=(e,t,n)=>{var r;return((r=e.getValue(t))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};$ce.autoRemove=e=>hl(e);var Kce=(e,t,n)=>{var r;return(r=e.getValue(t))==null?void 0:r.includes(n)};Kce.autoRemove=e=>hl(e);var Yce=(e,t,n)=>!n.some(r=>{var i;return!((i=e.getValue(t))!=null&&i.includes(r))});Yce.autoRemove=e=>hl(e)||!(e!=null&&e.length);var Qce=(e,t,n)=>n.some(r=>{var i;return(i=e.getValue(t))==null?void 0:i.includes(r)});Qce.autoRemove=e=>hl(e)||!(e!=null&&e.length);var Gce=(e,t,n)=>e.getValue(t)===n;Gce.autoRemove=e=>hl(e);var Xce=(e,t,n)=>e.getValue(t)==n;Xce.autoRemove=e=>hl(e);var I3=(e,t,n)=>{let[r,i]=n,o=e.getValue(t);return o>=r&&o<=i};I3.resolveFilterValue=e=>{let[t,n]=e,r=typeof t!="number"?parseFloat(t):t,i=typeof n!="number"?parseFloat(n):n,o=t===null||Number.isNaN(r)?-1/0:r,s=n===null||Number.isNaN(i)?1/0:i;if(o>s){let a=o;o=s,s=a}return[o,s]};I3.autoRemove=e=>hl(e)||hl(e[0])&&hl(e[1]);var ih={includesString:Uce,includesStringSensitive:Hce,equalsString:$ce,arrIncludes:Kce,arrIncludesAll:Yce,arrIncludesSome:Qce,equals:Gce,weakEquals:Xce,inNumberRange:I3};function hl(e){return e==null||e===""}var wrt={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:e=>({columnFilters:[],...e}),getDefaultOptions:e=>({onColumnFiltersChange:qs("columnFilters",e),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(e,t)=>{e.getAutoFilterFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=n?.getValue(e.id);return typeof r=="string"?ih.includesString:typeof r=="number"?ih.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?ih.equals:Array.isArray(r)?ih.arrIncludes:ih.weakEquals},e.getFilterFn=()=>{var n,r;return sO(e.columnDef.filterFn)?e.columnDef.filterFn:e.columnDef.filterFn==="auto"?e.getAutoFilterFn():(n=(r=t.options.filterFns)==null?void 0:r[e.columnDef.filterFn])!=null?n:ih[e.columnDef.filterFn]},e.getCanFilter=()=>{var n,r,i;return((n=e.columnDef.enableColumnFilter)!=null?n:!0)&&((r=t.options.enableColumnFilters)!=null?r:!0)&&((i=t.options.enableFilters)!=null?i:!0)&&!!e.accessorFn},e.getIsFiltered=()=>e.getFilterIndex()>-1,e.getFilterValue=()=>{var n;return(n=t.getState().columnFilters)==null||(n=n.find(r=>r.id===e.id))==null?void 0:n.value},e.getFilterIndex=()=>{var n,r;return(n=(r=t.getState().columnFilters)==null?void 0:r.findIndex(i=>i.id===e.id))!=null?n:-1},e.setFilterValue=n=>{t.setColumnFilters(r=>{let i=e.getFilterFn(),o=r?.find(c=>c.id===e.id),s=mh(n,o?o.value:void 0);if(dQ(i,s,e)){var a;return(a=r?.filter(c=>c.id!==e.id))!=null?a:[]}let l={id:e.id,value:s};if(o){var u;return(u=r?.map(c=>c.id===e.id?l:c))!=null?u:[]}return r!=null&&r.length?[...r,l]:[l]})}},createRow:(e,t)=>{e.columnFilters={},e.columnFiltersMeta={}},createTable:e=>{e.setColumnFilters=t=>{let n=e.getAllLeafColumns(),r=i=>{var o;return(o=mh(t,i))==null?void 0:o.filter(s=>{let a=n.find(l=>l.id===s.id);if(a){let l=a.getFilterFn();if(dQ(l,s.value,a))return!1}return!0})};e.options.onColumnFiltersChange==null||e.options.onColumnFiltersChange(r)},e.resetColumnFilters=t=>{var n,r;e.setColumnFilters(t?[]:(n=(r=e.initialState)==null?void 0:r.columnFilters)!=null?n:[])},e.getPreFilteredRowModel=()=>e.getCoreRowModel(),e.getFilteredRowModel=()=>(!e._getFilteredRowModel&&e.options.getFilteredRowModel&&(e._getFilteredRowModel=e.options.getFilteredRowModel(e)),e.options.manualFiltering||!e._getFilteredRowModel?e.getPreFilteredRowModel():e._getFilteredRowModel())}};function dQ(e,t,n){return(e&&e.autoRemove?e.autoRemove(t,n):!1)||typeof t>"u"||typeof t=="string"&&!t}var xrt=(e,t,n)=>n.reduce((r,i)=>{let o=i.getValue(e);return r+(typeof o=="number"?o:0)},0),Srt=(e,t,n)=>{let r;return n.forEach(i=>{let o=i.getValue(e);o!=null&&(r>o||r===void 0&&o>=o)&&(r=o)}),r},krt=(e,t,n)=>{let r;return n.forEach(i=>{let o=i.getValue(e);o!=null&&(r<o||r===void 0&&o>=o)&&(r=o)}),r},Crt=(e,t,n)=>{let r,i;return n.forEach(o=>{let s=o.getValue(e);s!=null&&(r===void 0?s>=s&&(r=i=s):(r>s&&(r=s),i<s&&(i=s)))}),[r,i]},Nrt=(e,t)=>{let n=0,r=0;if(t.forEach(i=>{let o=i.getValue(e);o!=null&&(o=+o)>=o&&(++n,r+=o)}),n)return r/n},Mrt=(e,t)=>{if(!t.length)return;let n=t.map(o=>o.getValue(e));if(!frt(n))return;if(n.length===1)return n[0];let r=Math.floor(n.length/2),i=n.sort((o,s)=>o-s);return n.length%2!==0?i[r]:(i[r-1]+i[r])/2},_rt=(e,t)=>Array.from(new Set(t.map(n=>n.getValue(e))).values()),Ert=(e,t)=>new Set(t.map(n=>n.getValue(e))).size,Ort=(e,t)=>t.length,yI={sum:xrt,min:Srt,max:krt,extent:Crt,mean:Nrt,median:Mrt,unique:_rt,uniqueCount:Ert,count:Ort},Trt={getDefaultColumnDef:()=>({aggregatedCell:e=>{var t,n;return(t=(n=e.getValue())==null||n.toString==null?void 0:n.toString())!=null?t:null},aggregationFn:"auto"}),getInitialState:e=>({grouping:[],...e}),getDefaultOptions:e=>({onGroupingChange:qs("grouping",e),groupedColumnMode:"reorder"}),createColumn:(e,t)=>{e.toggleGrouping=()=>{t.setGrouping(n=>n!=null&&n.includes(e.id)?n.filter(r=>r!==e.id):[...n??[],e.id])},e.getCanGroup=()=>{var n,r;return((n=e.columnDef.enableGrouping)!=null?n:!0)&&((r=t.options.enableGrouping)!=null?r:!0)&&(!!e.accessorFn||!!e.columnDef.getGroupingValue)},e.getIsGrouped=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.includes(e.id)},e.getGroupedIndex=()=>{var n;return(n=t.getState().grouping)==null?void 0:n.indexOf(e.id)},e.getToggleGroupingHandler=()=>{let n=e.getCanGroup();return()=>{n&&e.toggleGrouping()}},e.getAutoAggregationFn=()=>{let n=t.getCoreRowModel().flatRows[0],r=n?.getValue(e.id);if(typeof r=="number")return yI.sum;if(Object.prototype.toString.call(r)==="[object Date]")return yI.extent},e.getAggregationFn=()=>{var n,r;if(!e)throw new Error;return sO(e.columnDef.aggregationFn)?e.columnDef.aggregationFn:e.columnDef.aggregationFn==="auto"?e.getAutoAggregationFn():(n=(r=t.options.aggregationFns)==null?void 0:r[e.columnDef.aggregationFn])!=null?n:yI[e.columnDef.aggregationFn]}},createTable:e=>{e.setGrouping=t=>e.options.onGroupingChange==null?void 0:e.options.onGroupingChange(t),e.resetGrouping=t=>{var n,r;e.setGrouping(t?[]:(n=(r=e.initialState)==null?void 0:r.grouping)!=null?n:[])},e.getPreGroupedRowModel=()=>e.getFilteredRowModel(),e.getGroupedRowModel=()=>(!e._getGroupedRowModel&&e.options.getGroupedRowModel&&(e._getGroupedRowModel=e.options.getGroupedRowModel(e)),e.options.manualGrouping||!e._getGroupedRowModel?e.getPreGroupedRowModel():e._getGroupedRowModel())},createRow:(e,t)=>{e.getIsGrouped=()=>!!e.groupingColumnId,e.getGroupingValue=n=>{if(e._groupingValuesCache.hasOwnProperty(n))return e._groupingValuesCache[n];let r=t.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(e._groupingValuesCache[n]=r.columnDef.getGroupingValue(e.original),e._groupingValuesCache[n]):e.getValue(n)},e._groupingValuesCache={}},createCell:(e,t,n,r)=>{e.getIsGrouped=()=>t.getIsGrouped()&&t.id===n.groupingColumnId,e.getIsPlaceholder=()=>!e.getIsGrouped()&&t.getIsGrouped(),e.getIsAggregated=()=>{var i;return!e.getIsGrouped()&&!e.getIsPlaceholder()&&!!((i=n.subRows)!=null&&i.length)}}};function Art(e,t,n){if(!(t!=null&&t.length)||!n)return e;let r=e.filter(i=>!t.includes(i.id));return n==="remove"?r:[...t.map(i=>e.find(o=>o.id===i)).filter(Boolean),...r]}var Drt={getInitialState:e=>({columnOrder:[],...e}),getDefaultOptions:e=>({onColumnOrderChange:qs("columnOrder",e)}),createColumn:(e,t)=>{e.getIndex=ot(n=>[ex(t,n)],n=>n.findIndex(r=>r.id===e.id),st(t.options,"debugColumns","getIndex")),e.getIsFirstColumn=n=>{var r;return((r=ex(t,n)[0])==null?void 0:r.id)===e.id},e.getIsLastColumn=n=>{var r;let i=ex(t,n);return((r=i[i.length-1])==null?void 0:r.id)===e.id}},createTable:e=>{e.setColumnOrder=t=>e.options.onColumnOrderChange==null?void 0:e.options.onColumnOrderChange(t),e.resetColumnOrder=t=>{var n;e.setColumnOrder(t?[]:(n=e.initialState.columnOrder)!=null?n:[])},e._getOrderColumnsFn=ot(()=>[e.getState().columnOrder,e.getState().grouping,e.options.groupedColumnMode],(t,n,r)=>i=>{let o=[];if(!(t!=null&&t.length))o=i;else{let s=[...t],a=[...i];for(;a.length&&s.length;){let l=s.shift(),u=a.findIndex(c=>c.id===l);u>-1&&o.push(a.splice(u,1)[0])}o=[...o,...a]}return Art(o,n,r)},st(e.options,"debugTable","_getOrderColumnsFn"))}},vI=()=>({left:[],right:[]}),Rrt={getInitialState:e=>({columnPinning:vI(),...e}),getDefaultOptions:e=>({onColumnPinningChange:qs("columnPinning",e)}),createColumn:(e,t)=>{e.pin=n=>{let r=e.getLeafColumns().map(i=>i.id).filter(Boolean);t.setColumnPinning(i=>{var o,s;if(n==="right"){var a,l;return{left:((a=i?.left)!=null?a:[]).filter(d=>!(r!=null&&r.includes(d))),right:[...((l=i?.right)!=null?l:[]).filter(d=>!(r!=null&&r.includes(d))),...r]}}if(n==="left"){var u,c;return{left:[...((u=i?.left)!=null?u:[]).filter(d=>!(r!=null&&r.includes(d))),...r],right:((c=i?.right)!=null?c:[]).filter(d=>!(r!=null&&r.includes(d)))}}return{left:((o=i?.left)!=null?o:[]).filter(d=>!(r!=null&&r.includes(d))),right:((s=i?.right)!=null?s:[]).filter(d=>!(r!=null&&r.includes(d)))}})},e.getCanPin=()=>e.getLeafColumns().some(n=>{var r,i,o;return((r=n.columnDef.enablePinning)!=null?r:!0)&&((i=(o=t.options.enableColumnPinning)!=null?o:t.options.enablePinning)!=null?i:!0)}),e.getIsPinned=()=>{let n=e.getLeafColumns().map(a=>a.id),{left:r,right:i}=t.getState().columnPinning,o=n.some(a=>r?.includes(a)),s=n.some(a=>i?.includes(a));return o?"left":s?"right":!1},e.getPinnedIndex=()=>{var n,r;let i=e.getIsPinned();return i?(n=(r=t.getState().columnPinning)==null||(r=r[i])==null?void 0:r.indexOf(e.id))!=null?n:-1:0}},createRow:(e,t)=>{e.getCenterVisibleCells=ot(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left,t.getState().columnPinning.right],(n,r,i)=>{let o=[...r??[],...i??[]];return n.filter(s=>!o.includes(s.column.id))},st(t.options,"debugRows","getCenterVisibleCells")),e.getLeftVisibleCells=ot(()=>[e._getAllVisibleCells(),t.getState().columnPinning.left],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"left"})),st(t.options,"debugRows","getLeftVisibleCells")),e.getRightVisibleCells=ot(()=>[e._getAllVisibleCells(),t.getState().columnPinning.right],(n,r)=>(r??[]).map(i=>n.find(o=>o.column.id===i)).filter(Boolean).map(i=>({...i,position:"right"})),st(t.options,"debugRows","getRightVisibleCells"))},createTable:e=>{e.setColumnPinning=t=>e.options.onColumnPinningChange==null?void 0:e.options.onColumnPinningChange(t),e.resetColumnPinning=t=>{var n,r;return e.setColumnPinning(t?vI():(n=(r=e.initialState)==null?void 0:r.columnPinning)!=null?n:vI())},e.getIsSomeColumnsPinned=t=>{var n;let r=e.getState().columnPinning;if(!t){var i,o;return!!((i=r.left)!=null&&i.length||(o=r.right)!=null&&o.length)}return!!((n=r[t])!=null&&n.length)},e.getLeftLeafColumns=ot(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left],(t,n)=>(n??[]).map(r=>t.find(i=>i.id===r)).filter(Boolean),st(e.options,"debugColumns","getLeftLeafColumns")),e.getRightLeafColumns=ot(()=>[e.getAllLeafColumns(),e.getState().columnPinning.right],(t,n)=>(n??[]).map(r=>t.find(i=>i.id===r)).filter(Boolean),st(e.options,"debugColumns","getRightLeafColumns")),e.getCenterLeafColumns=ot(()=>[e.getAllLeafColumns(),e.getState().columnPinning.left,e.getState().columnPinning.right],(t,n,r)=>{let i=[...n??[],...r??[]];return t.filter(o=>!i.includes(o.id))},st(e.options,"debugColumns","getCenterLeafColumns"))}};function Irt(e){return e||(typeof document<"u"?document:null)}var xN={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},bI=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),Prt={getDefaultColumnDef:()=>xN,getInitialState:e=>({columnSizing:{},columnSizingInfo:bI(),...e}),getDefaultOptions:e=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:qs("columnSizing",e),onColumnSizingInfoChange:qs("columnSizingInfo",e)}),createColumn:(e,t)=>{e.getSize=()=>{var n,r,i;let o=t.getState().columnSizing[e.id];return Math.min(Math.max((n=e.columnDef.minSize)!=null?n:xN.minSize,(r=o??e.columnDef.size)!=null?r:xN.size),(i=e.columnDef.maxSize)!=null?i:xN.maxSize)},e.getStart=ot(n=>[n,ex(t,n),t.getState().columnSizing],(n,r)=>r.slice(0,e.getIndex(n)).reduce((i,o)=>i+o.getSize(),0),st(t.options,"debugColumns","getStart")),e.getAfter=ot(n=>[n,ex(t,n),t.getState().columnSizing],(n,r)=>r.slice(e.getIndex(n)+1).reduce((i,o)=>i+o.getSize(),0),st(t.options,"debugColumns","getAfter")),e.resetSize=()=>{t.setColumnSizing(n=>{let{[e.id]:r,...i}=n;return i})},e.getCanResize=()=>{var n,r;return((n=e.columnDef.enableResizing)!=null?n:!0)&&((r=t.options.enableColumnResizing)!=null?r:!0)},e.getIsResizing=()=>t.getState().columnSizingInfo.isResizingColumn===e.id},createHeader:(e,t)=>{e.getSize=()=>{let n=0,r=i=>{if(i.subHeaders.length)i.subHeaders.forEach(r);else{var o;n+=(o=i.column.getSize())!=null?o:0}};return r(e),n},e.getStart=()=>{if(e.index>0){let n=e.headerGroup.headers[e.index-1];return n.getStart()+n.getSize()}return 0},e.getResizeHandler=n=>{let r=t.getColumn(e.column.id),i=r?.getCanResize();return o=>{if(!r||!i||(o.persist==null||o.persist(),wI(o)&&o.touches&&o.touches.length>1))return;let s=e.getSize(),a=e?e.getLeafHeaders().map(y=>[y.column.id,y.column.getSize()]):[[r.id,r.getSize()]],l=wI(o)?Math.round(o.touches[0].clientX):o.clientX,u={},c=(y,v)=>{typeof v=="number"&&(t.setColumnSizingInfo(b=>{var w,x;let S=t.options.columnResizeDirection==="rtl"?-1:1,k=(v-((w=b?.startOffset)!=null?w:0))*S,C=Math.max(k/((x=b?.startSize)!=null?x:0),-.999999);return b.columnSizingStart.forEach(N=>{let[E,D]=N;u[E]=Math.round(Math.max(D+D*C,0)*100)/100}),{...b,deltaOffset:k,deltaPercentage:C}}),(t.options.columnResizeMode==="onChange"||y==="end")&&t.setColumnSizing(b=>({...b,...u})))},d=y=>c("move",y),h=y=>{c("end",y),t.setColumnSizingInfo(v=>({...v,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},f=Irt(n),p={moveHandler:y=>d(y.clientX),upHandler:y=>{f?.removeEventListener("mousemove",p.moveHandler),f?.removeEventListener("mouseup",p.upHandler),h(y.clientX)}},m={moveHandler:y=>(y.cancelable&&(y.preventDefault(),y.stopPropagation()),d(y.touches[0].clientX),!1),upHandler:y=>{var v;f?.removeEventListener("touchmove",m.moveHandler),f?.removeEventListener("touchend",m.upHandler),y.cancelable&&(y.preventDefault(),y.stopPropagation()),h((v=y.touches[0])==null?void 0:v.clientX)}},g=Lrt()?{passive:!1}:!1;wI(o)?(f?.addEventListener("touchmove",m.moveHandler,g),f?.addEventListener("touchend",m.upHandler,g)):(f?.addEventListener("mousemove",p.moveHandler,g),f?.addEventListener("mouseup",p.upHandler,g)),t.setColumnSizingInfo(y=>({...y,startOffset:l,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:r.id}))}}},createTable:e=>{e.setColumnSizing=t=>e.options.onColumnSizingChange==null?void 0:e.options.onColumnSizingChange(t),e.setColumnSizingInfo=t=>e.options.onColumnSizingInfoChange==null?void 0:e.options.onColumnSizingInfoChange(t),e.resetColumnSizing=t=>{var n;e.setColumnSizing(t?{}:(n=e.initialState.columnSizing)!=null?n:{})},e.resetHeaderSizeInfo=t=>{var n;e.setColumnSizingInfo(t?bI():(n=e.initialState.columnSizingInfo)!=null?n:bI())},e.getTotalSize=()=>{var t,n;return(t=(n=e.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?t:0},e.getLeftTotalSize=()=>{var t,n;return(t=(n=e.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?t:0},e.getCenterTotalSize=()=>{var t,n;return(t=(n=e.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?t:0},e.getRightTotalSize=()=>{var t,n;return(t=(n=e.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?t:0}}},SN=null;function Lrt(){if(typeof SN=="boolean")return SN;let e=!1;try{let t={get passive(){return e=!0,!1}},n=()=>{};window.addEventListener("test",n,t),window.removeEventListener("test",n)}catch{e=!1}return SN=e,SN}function wI(e){return e.type==="touchstart"}var Brt={getInitialState:e=>({columnVisibility:{},...e}),getDefaultOptions:e=>({onColumnVisibilityChange:qs("columnVisibility",e)}),createColumn:(e,t)=>{e.toggleVisibility=n=>{e.getCanHide()&&t.setColumnVisibility(r=>({...r,[e.id]:n??!e.getIsVisible()}))},e.getIsVisible=()=>{var n,r;let i=e.columns;return(n=i.length?i.some(o=>o.getIsVisible()):(r=t.getState().columnVisibility)==null?void 0:r[e.id])!=null?n:!0},e.getCanHide=()=>{var n,r;return((n=e.columnDef.enableHiding)!=null?n:!0)&&((r=t.options.enableHiding)!=null?r:!0)},e.getToggleVisibilityHandler=()=>n=>{e.toggleVisibility==null||e.toggleVisibility(n.target.checked)}},createRow:(e,t)=>{e._getAllVisibleCells=ot(()=>[e.getAllCells(),t.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),st(t.options,"debugRows","_getAllVisibleCells")),e.getVisibleCells=ot(()=>[e.getLeftVisibleCells(),e.getCenterVisibleCells(),e.getRightVisibleCells()],(n,r,i)=>[...n,...r,...i],st(t.options,"debugRows","getVisibleCells"))},createTable:e=>{let t=(n,r)=>ot(()=>[r(),r().filter(i=>i.getIsVisible()).map(i=>i.id).join("_")],i=>i.filter(o=>o.getIsVisible==null?void 0:o.getIsVisible()),st(e.options,"debugColumns",n));e.getVisibleFlatColumns=t("getVisibleFlatColumns",()=>e.getAllFlatColumns()),e.getVisibleLeafColumns=t("getVisibleLeafColumns",()=>e.getAllLeafColumns()),e.getLeftVisibleLeafColumns=t("getLeftVisibleLeafColumns",()=>e.getLeftLeafColumns()),e.getRightVisibleLeafColumns=t("getRightVisibleLeafColumns",()=>e.getRightLeafColumns()),e.getCenterVisibleLeafColumns=t("getCenterVisibleLeafColumns",()=>e.getCenterLeafColumns()),e.setColumnVisibility=n=>e.options.onColumnVisibilityChange==null?void 0:e.options.onColumnVisibilityChange(n),e.resetColumnVisibility=n=>{var r;e.setColumnVisibility(n?{}:(r=e.initialState.columnVisibility)!=null?r:{})},e.toggleAllColumnsVisible=n=>{var r;n=(r=n)!=null?r:!e.getIsAllColumnsVisible(),e.setColumnVisibility(e.getAllLeafColumns().reduce((i,o)=>({...i,[o.id]:n||!(o.getCanHide!=null&&o.getCanHide())}),{}))},e.getIsAllColumnsVisible=()=>!e.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),e.getIsSomeColumnsVisible=()=>e.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),e.getToggleAllColumnsVisibilityHandler=()=>n=>{var r;e.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}};function ex(e,t){return t?t==="center"?e.getCenterVisibleLeafColumns():t==="left"?e.getLeftVisibleLeafColumns():e.getRightVisibleLeafColumns():e.getVisibleLeafColumns()}var qrt={createTable:e=>{e._getGlobalFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,"__global__"),e.getGlobalFacetedRowModel=()=>e.options.manualFiltering||!e._getGlobalFacetedRowModel?e.getPreFilteredRowModel():e._getGlobalFacetedRowModel(),e._getGlobalFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,"__global__"),e.getGlobalFacetedUniqueValues=()=>e._getGlobalFacetedUniqueValues?e._getGlobalFacetedUniqueValues():new Map,e._getGlobalFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,"__global__"),e.getGlobalFacetedMinMaxValues=()=>{if(e._getGlobalFacetedMinMaxValues)return e._getGlobalFacetedMinMaxValues()}}},zrt={getInitialState:e=>({globalFilter:void 0,...e}),getDefaultOptions:e=>({onGlobalFilterChange:qs("globalFilter",e),globalFilterFn:"auto",getColumnCanGlobalFilter:t=>{var n;let r=(n=e.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[t.id])==null?void 0:n.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(e,t)=>{e.getCanGlobalFilter=()=>{var n,r,i,o;return((n=e.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=t.options.enableGlobalFilter)!=null?r:!0)&&((i=t.options.enableFilters)!=null?i:!0)&&((o=t.options.getColumnCanGlobalFilter==null?void 0:t.options.getColumnCanGlobalFilter(e))!=null?o:!0)&&!!e.accessorFn}},createTable:e=>{e.getGlobalAutoFilterFn=()=>ih.includesString,e.getGlobalFilterFn=()=>{var t,n;let{globalFilterFn:r}=e.options;return sO(r)?r:r==="auto"?e.getGlobalAutoFilterFn():(t=(n=e.options.filterFns)==null?void 0:n[r])!=null?t:ih[r]},e.setGlobalFilter=t=>{e.options.onGlobalFilterChange==null||e.options.onGlobalFilterChange(t)},e.resetGlobalFilter=t=>{e.setGlobalFilter(t?void 0:e.initialState.globalFilter)}}},Frt={getInitialState:e=>({expanded:{},...e}),getDefaultOptions:e=>({onExpandedChange:qs("expanded",e),paginateExpandedRows:!0}),createTable:e=>{let t=!1,n=!1;e._autoResetExpanded=()=>{var r,i;if(!t){e._queue(()=>{t=!0});return}if((r=(i=e.options.autoResetAll)!=null?i:e.options.autoResetExpanded)!=null?r:!e.options.manualExpanding){if(n)return;n=!0,e._queue(()=>{e.resetExpanded(),n=!1})}},e.setExpanded=r=>e.options.onExpandedChange==null?void 0:e.options.onExpandedChange(r),e.toggleAllRowsExpanded=r=>{r??!e.getIsAllRowsExpanded()?e.setExpanded(!0):e.setExpanded({})},e.resetExpanded=r=>{var i,o;e.setExpanded(r?{}:(i=(o=e.initialState)==null?void 0:o.expanded)!=null?i:{})},e.getCanSomeRowsExpand=()=>e.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),e.getToggleAllRowsExpandedHandler=()=>r=>{r.persist==null||r.persist(),e.toggleAllRowsExpanded()},e.getIsSomeRowsExpanded=()=>{let r=e.getState().expanded;return r===!0||Object.values(r).some(Boolean)},e.getIsAllRowsExpanded=()=>{let r=e.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||e.getRowModel().flatRows.some(i=>!i.getIsExpanded()))},e.getExpandedDepth=()=>{let r=0;return(e.getState().expanded===!0?Object.keys(e.getRowModel().rowsById):Object.keys(e.getState().expanded)).forEach(i=>{let o=i.split(".");r=Math.max(r,o.length)}),r},e.getPreExpandedRowModel=()=>e.getSortedRowModel(),e.getExpandedRowModel=()=>(!e._getExpandedRowModel&&e.options.getExpandedRowModel&&(e._getExpandedRowModel=e.options.getExpandedRowModel(e)),e.options.manualExpanding||!e._getExpandedRowModel?e.getPreExpandedRowModel():e._getExpandedRowModel())},createRow:(e,t)=>{e.toggleExpanded=n=>{t.setExpanded(r=>{var i;let o=r===!0?!0:!!(r!=null&&r[e.id]),s={};if(r===!0?Object.keys(t.getRowModel().rowsById).forEach(a=>{s[a]=!0}):s=r,n=(i=n)!=null?i:!o,!o&&n)return{...s,[e.id]:!0};if(o&&!n){let{[e.id]:a,...l}=s;return l}return r})},e.getIsExpanded=()=>{var n;let r=t.getState().expanded;return!!((n=t.options.getIsRowExpanded==null?void 0:t.options.getIsRowExpanded(e))!=null?n:r===!0||r?.[e.id])},e.getCanExpand=()=>{var n,r,i;return(n=t.options.getRowCanExpand==null?void 0:t.options.getRowCanExpand(e))!=null?n:((r=t.options.enableExpanding)!=null?r:!0)&&!!((i=e.subRows)!=null&&i.length)},e.getIsAllParentsExpanded=()=>{let n=!0,r=e;for(;n&&r.parentId;)r=t.getRow(r.parentId,!0),n=r.getIsExpanded();return n},e.getToggleExpandedHandler=()=>{let n=e.getCanExpand();return()=>{n&&e.toggleExpanded()}}}},nq=0,rq=10,xI=()=>({pageIndex:nq,pageSize:rq}),jrt={getInitialState:e=>({...e,pagination:{...xI(),...e?.pagination}}),getDefaultOptions:e=>({onPaginationChange:qs("pagination",e)}),createTable:e=>{let t=!1,n=!1;e._autoResetPageIndex=()=>{var r,i;if(!t){e._queue(()=>{t=!0});return}if((r=(i=e.options.autoResetAll)!=null?i:e.options.autoResetPageIndex)!=null?r:!e.options.manualPagination){if(n)return;n=!0,e._queue(()=>{e.resetPageIndex(),n=!1})}},e.setPagination=r=>{let i=o=>mh(r,o);return e.options.onPaginationChange==null?void 0:e.options.onPaginationChange(i)},e.resetPagination=r=>{var i;e.setPagination(r?xI():(i=e.initialState.pagination)!=null?i:xI())},e.setPageIndex=r=>{e.setPagination(i=>{let o=mh(r,i.pageIndex),s=typeof e.options.pageCount>"u"||e.options.pageCount===-1?Number.MAX_SAFE_INTEGER:e.options.pageCount-1;return o=Math.max(0,Math.min(o,s)),{...i,pageIndex:o}})},e.resetPageIndex=r=>{var i,o;e.setPageIndex(r?nq:(i=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageIndex)!=null?i:nq)},e.resetPageSize=r=>{var i,o;e.setPageSize(r?rq:(i=(o=e.initialState)==null||(o=o.pagination)==null?void 0:o.pageSize)!=null?i:rq)},e.setPageSize=r=>{e.setPagination(i=>{let o=Math.max(1,mh(r,i.pageSize)),s=i.pageSize*i.pageIndex,a=Math.floor(s/o);return{...i,pageIndex:a,pageSize:o}})},e.setPageCount=r=>e.setPagination(i=>{var o;let s=mh(r,(o=e.options.pageCount)!=null?o:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...i,pageCount:s}}),e.getPageOptions=ot(()=>[e.getPageCount()],r=>{let i=[];return r&&r>0&&(i=[...new Array(r)].fill(null).map((o,s)=>s)),i},st(e.options,"debugTable","getPageOptions")),e.getCanPreviousPage=()=>e.getState().pagination.pageIndex>0,e.getCanNextPage=()=>{let{pageIndex:r}=e.getState().pagination,i=e.getPageCount();return i===-1?!0:i===0?!1:r<i-1},e.previousPage=()=>e.setPageIndex(r=>r-1),e.nextPage=()=>e.setPageIndex(r=>r+1),e.firstPage=()=>e.setPageIndex(0),e.lastPage=()=>e.setPageIndex(e.getPageCount()-1),e.getPrePaginationRowModel=()=>e.getExpandedRowModel(),e.getPaginationRowModel=()=>(!e._getPaginationRowModel&&e.options.getPaginationRowModel&&(e._getPaginationRowModel=e.options.getPaginationRowModel(e)),e.options.manualPagination||!e._getPaginationRowModel?e.getPrePaginationRowModel():e._getPaginationRowModel()),e.getPageCount=()=>{var r;return(r=e.options.pageCount)!=null?r:Math.ceil(e.getRowCount()/e.getState().pagination.pageSize)},e.getRowCount=()=>{var r;return(r=e.options.rowCount)!=null?r:e.getPrePaginationRowModel().rows.length}}},SI=()=>({top:[],bottom:[]}),Vrt={getInitialState:e=>({rowPinning:SI(),...e}),getDefaultOptions:e=>({onRowPinningChange:qs("rowPinning",e)}),createRow:(e,t)=>{e.pin=(n,r,i)=>{let o=r?e.getLeafRows().map(l=>{let{id:u}=l;return u}):[],s=i?e.getParentRows().map(l=>{let{id:u}=l;return u}):[],a=new Set([...s,e.id,...o]);t.setRowPinning(l=>{var u,c;if(n==="bottom"){var d,h;return{top:((d=l?.top)!=null?d:[]).filter(m=>!(a!=null&&a.has(m))),bottom:[...((h=l?.bottom)!=null?h:[]).filter(m=>!(a!=null&&a.has(m))),...Array.from(a)]}}if(n==="top"){var f,p;return{top:[...((f=l?.top)!=null?f:[]).filter(m=>!(a!=null&&a.has(m))),...Array.from(a)],bottom:((p=l?.bottom)!=null?p:[]).filter(m=>!(a!=null&&a.has(m)))}}return{top:((u=l?.top)!=null?u:[]).filter(m=>!(a!=null&&a.has(m))),bottom:((c=l?.bottom)!=null?c:[]).filter(m=>!(a!=null&&a.has(m)))}})},e.getCanPin=()=>{var n;let{enableRowPinning:r,enablePinning:i}=t.options;return typeof r=="function"?r(e):(n=r??i)!=null?n:!0},e.getIsPinned=()=>{let n=[e.id],{top:r,bottom:i}=t.getState().rowPinning,o=n.some(a=>r?.includes(a)),s=n.some(a=>i?.includes(a));return o?"top":s?"bottom":!1},e.getPinnedIndex=()=>{var n,r;let i=e.getIsPinned();return i&&(r=((n=i==="top"?t.getTopRows():t.getBottomRows())==null?void 0:n.map(s=>{let{id:a}=s;return a}))?.indexOf(e.id))!=null?r:-1}},createTable:e=>{e.setRowPinning=t=>e.options.onRowPinningChange==null?void 0:e.options.onRowPinningChange(t),e.resetRowPinning=t=>{var n,r;return e.setRowPinning(t?SI():(n=(r=e.initialState)==null?void 0:r.rowPinning)!=null?n:SI())},e.getIsSomeRowsPinned=t=>{var n;let r=e.getState().rowPinning;if(!t){var i,o;return!!((i=r.top)!=null&&i.length||(o=r.bottom)!=null&&o.length)}return!!((n=r[t])!=null&&n.length)},e._getPinnedRows=(t,n,r)=>{var i;return((i=e.options.keepPinnedRows)==null||i?(n??[]).map(o=>{let s=e.getRow(o,!0);return s.getIsAllParentsExpanded()?s:null}):(n??[]).map(o=>t.find(s=>s.id===o))).filter(Boolean).map(o=>({...o,position:r}))},e.getTopRows=ot(()=>[e.getRowModel().rows,e.getState().rowPinning.top],(t,n)=>e._getPinnedRows(t,n,"top"),st(e.options,"debugRows","getTopRows")),e.getBottomRows=ot(()=>[e.getRowModel().rows,e.getState().rowPinning.bottom],(t,n)=>e._getPinnedRows(t,n,"bottom"),st(e.options,"debugRows","getBottomRows")),e.getCenterRows=ot(()=>[e.getRowModel().rows,e.getState().rowPinning.top,e.getState().rowPinning.bottom],(t,n,r)=>{let i=new Set([...n??[],...r??[]]);return t.filter(o=>!i.has(o.id))},st(e.options,"debugRows","getCenterRows"))}},Wrt={getInitialState:e=>({rowSelection:{},...e}),getDefaultOptions:e=>({onRowSelectionChange:qs("rowSelection",e),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:e=>{e.setRowSelection=t=>e.options.onRowSelectionChange==null?void 0:e.options.onRowSelectionChange(t),e.resetRowSelection=t=>{var n;return e.setRowSelection(t?{}:(n=e.initialState.rowSelection)!=null?n:{})},e.toggleAllRowsSelected=t=>{e.setRowSelection(n=>{t=typeof t<"u"?t:!e.getIsAllRowsSelected();let r={...n},i=e.getPreGroupedRowModel().flatRows;return t?i.forEach(o=>{o.getCanSelect()&&(r[o.id]=!0)}):i.forEach(o=>{delete r[o.id]}),r})},e.toggleAllPageRowsSelected=t=>e.setRowSelection(n=>{let r=typeof t<"u"?t:!e.getIsAllPageRowsSelected(),i={...n};return e.getRowModel().rows.forEach(o=>{iq(i,o.id,r,!0,e)}),i}),e.getPreSelectedRowModel=()=>e.getCoreRowModel(),e.getSelectedRowModel=ot(()=>[e.getState().rowSelection,e.getCoreRowModel()],(t,n)=>Object.keys(t).length?kI(e,n):{rows:[],flatRows:[],rowsById:{}},st(e.options,"debugTable","getSelectedRowModel")),e.getFilteredSelectedRowModel=ot(()=>[e.getState().rowSelection,e.getFilteredRowModel()],(t,n)=>Object.keys(t).length?kI(e,n):{rows:[],flatRows:[],rowsById:{}},st(e.options,"debugTable","getFilteredSelectedRowModel")),e.getGroupedSelectedRowModel=ot(()=>[e.getState().rowSelection,e.getSortedRowModel()],(t,n)=>Object.keys(t).length?kI(e,n):{rows:[],flatRows:[],rowsById:{}},st(e.options,"debugTable","getGroupedSelectedRowModel")),e.getIsAllRowsSelected=()=>{let t=e.getFilteredRowModel().flatRows,{rowSelection:n}=e.getState(),r=!!(t.length&&Object.keys(n).length);return r&&t.some(i=>i.getCanSelect()&&!n[i.id])&&(r=!1),r},e.getIsAllPageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows.filter(i=>i.getCanSelect()),{rowSelection:n}=e.getState(),r=!!t.length;return r&&t.some(i=>!n[i.id])&&(r=!1),r},e.getIsSomeRowsSelected=()=>{var t;let n=Object.keys((t=e.getState().rowSelection)!=null?t:{}).length;return n>0&&n<e.getFilteredRowModel().flatRows.length},e.getIsSomePageRowsSelected=()=>{let t=e.getPaginationRowModel().flatRows;return e.getIsAllPageRowsSelected()?!1:t.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},e.getToggleAllRowsSelectedHandler=()=>t=>{e.toggleAllRowsSelected(t.target.checked)},e.getToggleAllPageRowsSelectedHandler=()=>t=>{e.toggleAllPageRowsSelected(t.target.checked)}},createRow:(e,t)=>{e.toggleSelected=(n,r)=>{let i=e.getIsSelected();t.setRowSelection(o=>{var s;if(n=typeof n<"u"?n:!i,e.getCanSelect()&&i===n)return o;let a={...o};return iq(a,e.id,n,(s=r?.selectChildren)!=null?s:!0,t),a})},e.getIsSelected=()=>{let{rowSelection:n}=t.getState();return P3(e,n)},e.getIsSomeSelected=()=>{let{rowSelection:n}=t.getState();return oq(e,n)==="some"},e.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=t.getState();return oq(e,n)==="all"},e.getCanSelect=()=>{var n;return typeof t.options.enableRowSelection=="function"?t.options.enableRowSelection(e):(n=t.options.enableRowSelection)!=null?n:!0},e.getCanSelectSubRows=()=>{var n;return typeof t.options.enableSubRowSelection=="function"?t.options.enableSubRowSelection(e):(n=t.options.enableSubRowSelection)!=null?n:!0},e.getCanMultiSelect=()=>{var n;return typeof t.options.enableMultiRowSelection=="function"?t.options.enableMultiRowSelection(e):(n=t.options.enableMultiRowSelection)!=null?n:!0},e.getToggleSelectedHandler=()=>{let n=e.getCanSelect();return r=>{var i;n&&e.toggleSelected((i=r.target)==null?void 0:i.checked)}}}},iq=(e,t,n,r,i)=>{var o;let s=i.getRow(t,!0);n?(s.getCanMultiSelect()||Object.keys(e).forEach(a=>delete e[a]),s.getCanSelect()&&(e[t]=!0)):delete e[t],r&&(o=s.subRows)!=null&&o.length&&s.getCanSelectSubRows()&&s.subRows.forEach(a=>iq(e,a.id,n,r,i))};function kI(e,t){let n=e.getState().rowSelection,r=[],i={},o=function(s,a){return s.map(l=>{var u;let c=P3(l,n);if(c&&(r.push(l),i[l.id]=l),(u=l.subRows)!=null&&u.length&&(l={...l,subRows:o(l.subRows)}),c)return l}).filter(Boolean)};return{rows:o(t.rows),flatRows:r,rowsById:i}}function P3(e,t){var n;return(n=t[e.id])!=null?n:!1}function oq(e,t,n){var r;if(!((r=e.subRows)!=null&&r.length))return!1;let i=!0,o=!1;return e.subRows.forEach(s=>{if(!(o&&!i)&&(s.getCanSelect()&&(P3(s,t)?o=!0:i=!1),s.subRows&&s.subRows.length)){let a=oq(s,t);a==="all"?o=!0:(a==="some"&&(o=!0),i=!1)}}),i?"all":o?"some":!1}var sq=/([0-9]+)/gm,Urt=(e,t,n)=>Jce(zh(e.getValue(n)).toLowerCase(),zh(t.getValue(n)).toLowerCase()),Hrt=(e,t,n)=>Jce(zh(e.getValue(n)),zh(t.getValue(n))),$rt=(e,t,n)=>L3(zh(e.getValue(n)).toLowerCase(),zh(t.getValue(n)).toLowerCase()),Krt=(e,t,n)=>L3(zh(e.getValue(n)),zh(t.getValue(n))),Yrt=(e,t,n)=>{let r=e.getValue(n),i=t.getValue(n);return r>i?1:r<i?-1:0},Qrt=(e,t,n)=>L3(e.getValue(n),t.getValue(n));function L3(e,t){return e===t?0:e>t?1:-1}function zh(e){return typeof e=="number"?isNaN(e)||e===1/0||e===-1/0?"":String(e):typeof e=="string"?e:""}function Jce(e,t){let n=e.split(sq).filter(Boolean),r=t.split(sq).filter(Boolean);for(;n.length&&r.length;){let i=n.shift(),o=r.shift(),s=parseInt(i,10),a=parseInt(o,10),l=[s,a].sort();if(isNaN(l[0])){if(i>o)return 1;if(o>i)return-1;continue}if(isNaN(l[1]))return isNaN(s)?-1:1;if(s>a)return 1;if(a>s)return-1}return n.length-r.length}var Gb={alphanumeric:Urt,alphanumericCaseSensitive:Hrt,text:$rt,textCaseSensitive:Krt,datetime:Yrt,basic:Qrt},Grt={getInitialState:e=>({sorting:[],...e}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:e=>({onSortingChange:qs("sorting",e),isMultiSortEvent:t=>t.shiftKey}),createColumn:(e,t)=>{e.getAutoSortingFn=()=>{let n=t.getFilteredRowModel().flatRows.slice(10),r=!1;for(let i of n){let o=i?.getValue(e.id);if(Object.prototype.toString.call(o)==="[object Date]")return Gb.datetime;if(typeof o=="string"&&(r=!0,o.split(sq).length>1))return Gb.alphanumeric}return r?Gb.text:Gb.basic},e.getAutoSortDir=()=>typeof t.getFilteredRowModel().flatRows[0]?.getValue(e.id)=="string"?"asc":"desc",e.getSortingFn=()=>{var n,r;if(!e)throw new Error;return sO(e.columnDef.sortingFn)?e.columnDef.sortingFn:e.columnDef.sortingFn==="auto"?e.getAutoSortingFn():(n=(r=t.options.sortingFns)==null?void 0:r[e.columnDef.sortingFn])!=null?n:Gb[e.columnDef.sortingFn]},e.toggleSorting=(n,r)=>{let i=e.getNextSortingOrder(),o=typeof n<"u"&&n!==null;t.setSorting(s=>{let a=s?.find(f=>f.id===e.id),l=s?.findIndex(f=>f.id===e.id),u=[],c,d=o?n:i==="desc";if(s!=null&&s.length&&e.getCanMultiSort()&&r?a?c="toggle":c="add":s!=null&&s.length&&l!==s.length-1?c="replace":a?c="toggle":c="replace",c==="toggle"&&(o||i||(c="remove")),c==="add"){var h;u=[...s,{id:e.id,desc:d}],u.splice(0,u.length-((h=t.options.maxMultiSortColCount)!=null?h:Number.MAX_SAFE_INTEGER))}else c==="toggle"?u=s.map(f=>f.id===e.id?{...f,desc:d}:f):c==="remove"?u=s.filter(f=>f.id!==e.id):u=[{id:e.id,desc:d}];return u})},e.getFirstSortDir=()=>{var n,r;return((n=(r=e.columnDef.sortDescFirst)!=null?r:t.options.sortDescFirst)!=null?n:e.getAutoSortDir()==="desc")?"desc":"asc"},e.getNextSortingOrder=n=>{var r,i;let o=e.getFirstSortDir(),s=e.getIsSorted();return s?s!==o&&((r=t.options.enableSortingRemoval)==null||r)&&(!(n&&(i=t.options.enableMultiRemove)!=null)||i)?!1:s==="desc"?"asc":"desc":o},e.getCanSort=()=>{var n,r;return((n=e.columnDef.enableSorting)!=null?n:!0)&&((r=t.options.enableSorting)!=null?r:!0)&&!!e.accessorFn},e.getCanMultiSort=()=>{var n,r;return(n=(r=e.columnDef.enableMultiSort)!=null?r:t.options.enableMultiSort)!=null?n:!!e.accessorFn},e.getIsSorted=()=>{var n;let r=(n=t.getState().sorting)==null?void 0:n.find(i=>i.id===e.id);return r?r.desc?"desc":"asc":!1},e.getSortIndex=()=>{var n,r;return(n=(r=t.getState().sorting)==null?void 0:r.findIndex(i=>i.id===e.id))!=null?n:-1},e.clearSorting=()=>{t.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==e.id):[])},e.getToggleSortingHandler=()=>{let n=e.getCanSort();return r=>{n&&(r.persist==null||r.persist(),e.toggleSorting==null||e.toggleSorting(void 0,e.getCanMultiSort()?t.options.isMultiSortEvent==null?void 0:t.options.isMultiSortEvent(r):!1))}}},createTable:e=>{e.setSorting=t=>e.options.onSortingChange==null?void 0:e.options.onSortingChange(t),e.resetSorting=t=>{var n,r;e.setSorting(t?[]:(n=(r=e.initialState)==null?void 0:r.sorting)!=null?n:[])},e.getPreSortedRowModel=()=>e.getGroupedRowModel(),e.getSortedRowModel=()=>(!e._getSortedRowModel&&e.options.getSortedRowModel&&(e._getSortedRowModel=e.options.getSortedRowModel(e)),e.options.manualSorting||!e._getSortedRowModel?e.getPreSortedRowModel():e._getSortedRowModel())}},Xrt=[yrt,Brt,Drt,Rrt,brt,wrt,qrt,zrt,Grt,Trt,Frt,jrt,Vrt,Wrt,Prt];function Jrt(e){var t,n;(e.debugAll||e.debugTable)&&console.info("Creating Table Instance...");let r=[...Xrt,...(t=e._features)!=null?t:[]],i={_features:r},o=i._features.reduce((d,h)=>Object.assign(d,h.getDefaultOptions==null?void 0:h.getDefaultOptions(i)),{}),s=d=>i.options.mergeOptions?i.options.mergeOptions(o,d):{...o,...d},a={...(n=e.initialState)!=null?n:{}};i._features.forEach(d=>{var h;a=(h=d.getInitialState==null?void 0:d.getInitialState(a))!=null?h:a});let l=[],u=!1,c={_features:r,options:{...o,...e},initialState:a,_queue:d=>{l.push(d),u||(u=!0,Promise.resolve().then(()=>{for(;l.length;)l.shift()();u=!1}).catch(h=>setTimeout(()=>{throw h})))},reset:()=>{i.setState(i.initialState)},setOptions:d=>{let h=mh(d,i.options);i.options=s(h)},getState:()=>i.options.state,setState:d=>{i.options.onStateChange==null||i.options.onStateChange(d)},_getRowId:(d,h,f)=>{var p;return(p=i.options.getRowId==null?void 0:i.options.getRowId(d,h,f))!=null?p:`${f?[f.id,h].join("."):h}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(d,h)=>{let f=(h?i.getPrePaginationRowModel():i.getRowModel()).rowsById[d];if(!f&&(f=i.getCoreRowModel().rowsById[d],!f))throw new Error(`getRow could not find row with ID: ${d}`);return f},_getDefaultColumnDef:ot(()=>[i.options.defaultColumn],d=>{var h;return d=(h=d)!=null?h:{},{header:f=>{let p=f.header.column.columnDef;return p.accessorKey?p.accessorKey:p.accessorFn?p.id:null},cell:f=>{var p,m;return(p=(m=f.renderValue())==null||m.toString==null?void 0:m.toString())!=null?p:null},...i._features.reduce((f,p)=>Object.assign(f,p.getDefaultColumnDef==null?void 0:p.getDefaultColumnDef()),{}),...d}},st(e,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:()=>i.options.columns,getAllColumns:ot(()=>[i._getColumnDefs()],d=>{let h=function(f,p,m){return m===void 0&&(m=0),f.map(g=>{let y=grt(i,g,m,p),v=g;return y.columns=v.columns?h(v.columns,y,m+1):[],y})};return h(d)},st(e,"debugColumns","getAllColumns")),getAllFlatColumns:ot(()=>[i.getAllColumns()],d=>d.flatMap(h=>h.getFlatColumns()),st(e,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:ot(()=>[i.getAllFlatColumns()],d=>d.reduce((h,f)=>(h[f.id]=f,h),{}),st(e,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:ot(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(d,h)=>{let f=d.flatMap(p=>p.getLeafColumns());return h(f)},st(e,"debugColumns","getAllLeafColumns")),getColumn:d=>{let h=i._getAllFlatColumnsById()[d];return h||console.error(`[Table] Column with id '${d}' does not exist.`),h}};Object.assign(i,c);for(let d=0;d<i._features.length;d++){let h=i._features[d];h==null||h.createTable==null||h.createTable(i)}return i}function Zrt(){return e=>ot(()=>[e.options.data],t=>{let n={rows:[],flatRows:[],rowsById:{}},r=function(i,o,s){o===void 0&&(o=0);let a=[];for(let u=0;u<i.length;u++){let c=vrt(e,e._getRowId(i[u],u,s),i[u],u,o,void 0,s?.id);if(n.flatRows.push(c),n.rowsById[c.id]=c,a.push(c),e.options.getSubRows){var l;c.originalSubRows=e.options.getSubRows(i[u],u),(l=c.originalSubRows)!=null&&l.length&&(c.subRows=r(c.originalSubRows,o+1,c))}}return a};return n.rows=r(t),n},st(e.options,"debugTable","getRowModel",()=>e._autoResetPageIndex()))}function Zce(e){let t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=tq.useState(()=>({current:Jrt(t)})),[r,i]=tq.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...r,...e.state},onStateChange:s=>{i(s),e.onStateChange==null||e.onStateChange(s)}})),n.current}function eit(e){let{end:t,start:n}=e;return{rowStart:Math.min(n.rowIndex,t.rowIndex),rowEnd:Math.max(n.rowIndex,t.rowIndex),columnStart:Math.min(n.columnIndex,t.columnIndex),columnEnd:Math.max(n.columnIndex,t.columnIndex)}}function hQ(e){let{columnIndex:t,range:n,rowIndex:r}=e;return r>=n.rowStart&&r<=n.rowEnd&&t>=n.columnStart&&t<=n.columnEnd}function tit(e){let t=e.replace(/\r/g,"");if(t==="")return[];let n=t.split(`
`);return n[n.length-1]===""&&n.pop(),n.map(r=>r.split(" "))}function CI(e){let{columnIds:t,range:n,rows:r}=e,i=[];for(let o=n.rowStart;o<=n.rowEnd;o++){let s=r[o];if(!s)continue;let a=[];for(let l=n.columnStart;l<=n.columnEnd;l++){let u=t[l];u&&a.push(rit(s[u]))}i.push(a.join(" "))}return i.join(`
`)}function nit(e){let{columnIds:t,matrix:n,range:r,rowCount:i}=e;if(n.length===0)return[];let o=n.length,s=Math.max(1,...n.map(f=>Math.max(1,f.length))),a=r.rowEnd-r.rowStart+1,l=r.columnEnd-r.columnStart+1,u=o===1&&s===1,c=u?a:o,d=u?l:s,h=[];for(let f=0;f<c;f++){let p=r.rowStart+f;if(!(p<0||p>=i))for(let m=0;m<d;m++){let g=r.columnStart+m,y=t[g];if(!y||e.canWrite&&!e.canWrite({columnId:y,rowIndex:p}))continue;let v=n[u?0:f]??[],b=v[u?0:m]??v[0]??"";h.push({columnId:y,rowIndex:p,value:b})}}return h}function rit(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}function iit(e){return Math.min(400,Math.max(50,e))}function ede(e){let t=!1,n={};for(let[r,i]of Object.entries(e)){let o=iit(i);n[r]=o,t||=o!==i}return t?n:e}function oit(e,t){let n=typeof t=="function"?t(e):t;return ede(n)}function sit(e){let{columnWidths:t,minColumnCount:n,overscanPx:r,scrollLeft:i,viewportWidth:o}=e,s=t.length;if(s===0)return{enabled:!1,startIndex:0,endIndex:-1,hiddenStartCount:0,hiddenEndCount:0,hiddenStartWidth:0,hiddenEndWidth:0};let a=Number.isFinite(o)?o:0,l=Number.isFinite(i)?Math.max(0,i):0,u=Number.isFinite(r)?Math.max(0,r):0;if(a<=0||s<n)return fQ(t);let c=new Array(s),d=new Array(s),h=0;for(let x=0;x<s;x++){let S=ait(t[x]);c[x]=h,h+=S,d[x]=h}let f=Math.max(0,l-u),p=Math.max(f,l+a+u),m=0;for(;m<s&&d[m]<=f;)m++;m>=s&&(m=s-1);let g=m;for(;g<s-1&&c[g+1]<p;)g++;if(m===0&&g===s-1)return fQ(t);let y=m,v=Math.max(0,s-1-g),b=c[m]??0,w=h-(d[g]??h);return{enabled:!0,startIndex:m,endIndex:g,hiddenStartCount:y,hiddenEndCount:v,hiddenStartWidth:b,hiddenEndWidth:w}}function fQ(e){return{enabled:!1,startIndex:0,endIndex:e.length-1,hiddenStartCount:0,hiddenEndCount:0,hiddenStartWidth:0,hiddenEndWidth:0}}function ait(e){return typeof e!="number"||!Number.isFinite(e)?0:Math.max(0,e)}function lit({className:e}){return(0,aq.jsx)("div",{"data-loading-bar":!0,className:G("h-[2px] w-full overflow-hidden bg-table-border z-50",e),children:(0,aq.jsx)("div",{className:"animate-indeterminate h-full w-1/3 rounded-r-full bg-primary"})})}var aO="DropdownMenu",[uit,rvt]=os(aO,[ZE]),Bo=ZE(),[cit,tde]=uit(aO),nde=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:o,onOpenChange:s,modal:a=!0}=e,l=Bo(t),u=gi.useRef(null),[c,d]=_a({prop:i,defaultProp:o??!1,onChange:s,caller:aO});return(0,Oi.jsx)(cit,{scope:t,triggerId:fi(),triggerRef:u,contentId:fi(),open:c,onOpenChange:d,onOpenToggle:gi.useCallback(()=>d(h=>!h),[d]),modal:a,children:(0,Oi.jsx)(Eue,{...l,open:c,onOpenChange:d,dir:r,modal:a,children:n})})};nde.displayName=aO;var rde="DropdownMenuTrigger",ide=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=tde(rde,n),s=Bo(n);return(0,Oi.jsx)(Oue,{asChild:!0,...s,children:(0,Oi.jsx)(ft.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":r?"":void 0,disabled:r,...i,ref:bu(t,o.triggerRef),onPointerDown:xe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(o.onOpenToggle(),o.open||a.preventDefault())}),onKeyDown:xe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&o.onOpenToggle(),a.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});ide.displayName=rde;var dit="DropdownMenuPortal",ode=e=>{let{__scopeDropdownMenu:t,...n}=e,r=Bo(t);return(0,Oi.jsx)(Tue,{...r,...n})};ode.displayName=dit;var sde="DropdownMenuContent",ade=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=tde(sde,n),o=Bo(n),s=gi.useRef(!1);return(0,Oi.jsx)(Aue,{id:i.contentId,"aria-labelledby":i.triggerId,...o,...r,ref:t,onCloseAutoFocus:xe(e.onCloseAutoFocus,a=>{s.current||i.triggerRef.current?.focus(),s.current=!1,a.preventDefault()}),onInteractOutside:xe(e.onInteractOutside,a=>{let l=a.detail.originalEvent,u=l.button===0&&l.ctrlKey===!0,c=l.button===2||u;(!i.modal||c)&&(s.current=!0)}),style:{...e.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)"}})});ade.displayName=sde;var hit="DropdownMenuGroup",fit=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Due,{...i,...r,ref:t})});fit.displayName=hit;var pit="DropdownMenuLabel",lde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Rue,{...i,...r,ref:t})});lde.displayName=pit;var mit="DropdownMenuItem",ude=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Iue,{...i,...r,ref:t})});ude.displayName=mit;var git="DropdownMenuCheckboxItem",cde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Pue,{...i,...r,ref:t})});cde.displayName=git;var yit="DropdownMenuRadioGroup",dde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Lue,{...i,...r,ref:t})});dde.displayName=yit;var vit="DropdownMenuRadioItem",hde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Bue,{...i,...r,ref:t})});hde.displayName=vit;var bit="DropdownMenuItemIndicator",fde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(que,{...i,...r,ref:t})});fde.displayName=bit;var wit="DropdownMenuSeparator",pde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(zue,{...i,...r,ref:t})});pde.displayName=wit;var xit="DropdownMenuArrow",Sit=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Fue,{...i,...r,ref:t})});Sit.displayName=xit;var kit="DropdownMenuSubTrigger",mde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(jue,{...i,...r,ref:t})});mde.displayName=kit;var Cit="DropdownMenuSubContent",gde=gi.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Bo(n);return(0,Oi.jsx)(Vue,{...i,...r,ref:t,style:{...e.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)"}})});gde.displayName=Cit;var Nit=nde,Mit=ide,_it=ode,yde=ade,vde=lde,bde=ude,wde=cde,Eit=dde,xde=hde,Sde=fde,kde=pde,Cde=mde,Nde=gde,Mde=Nit,_de=Mit,Oit=Eit,Tit=Kc.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,Gr.jsxs)(Cde,{ref:i,className:G("flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",t&&"pl-8",e),...r,children:[n,(0,Gr.jsx)(o1,{className:"ml-auto"})]}));Tit.displayName=Cde.displayName;var Ait=Kc.forwardRef(({className:e,...t},n)=>(0,Gr.jsx)(Nde,{ref:n,className:G("z-50 min-w-32 overflow-hidden rounded-md border border-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 origin-(--radix-dropdown-menu-content-transform-origin)",e),...t}));Ait.displayName=Nde.displayName;var B3=Kc.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,Gr.jsx)(_it,{children:(0,Gr.jsx)("div",{className:"ps",children:(0,Gr.jsx)(yde,{ref:r,sideOffset:t,className:G("z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-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 origin-(--radix-dropdown-menu-content-transform-origin)",e),...n})})}));B3.displayName=yde.displayName;var Ede=Kc.forwardRef(({className:e,inset:t,...n},r)=>(0,Gr.jsx)(bde,{ref:r,className:G("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",t&&"pl-8",e),...n}));Ede.displayName=bde.displayName;var Ode=Kc.forwardRef(({className:e,children:t,checked:n,...r},i)=>(0,Gr.jsxs)(wde,{ref:i,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),checked:n,...r,children:[(0,Gr.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Gr.jsx)(Sde,{children:(0,Gr.jsx)(fm,{className:"h-4 w-4"})})}),t]}));Ode.displayName=wde.displayName;var Tde=Kc.forwardRef(({className:e,children:t,...n},r)=>(0,Gr.jsxs)(xde,{ref:r,className:G("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",e),...n,children:[(0,Gr.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,Gr.jsx)(Sde,{children:(0,Gr.jsx)(UZ,{className:"h-2 w-2 fill-current"})})}),t]}));Tde.displayName=xde.displayName;var Dit=Kc.forwardRef(({className:e,inset:t,...n},r)=>(0,Gr.jsx)(vde,{ref:r,className:G("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));Dit.displayName=vde.displayName;var Ade=Kc.forwardRef(({className:e,...t},n)=>(0,Gr.jsx)(kde,{ref:n,className:G("-mx-1 my-1 h-px bg-muted",e),...t}));Ade.displayName=kde.displayName;var Rit=({className:e,...t})=>(0,Gr.jsx)("span",{className:G("ml-auto text-xs tracking-widest opacity-60",e),...t});Rit.displayName="DropdownMenuShortcut";var Iit="Label",Ide=Dde.forwardRef((e,t)=>(0,Rde.jsx)(Wc.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));Ide.displayName=Iit;var Pde=Ide,Pit=pE("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),lO=Lde.forwardRef(({className:e,...t},n)=>(0,Bde.jsx)(Pde,{ref:n,className:G(Pit(),e),...t}));lO.displayName=Pde.displayName;var Lit=[10,25,50,100,500];function Bit(e){let{controlsDisabled:t=!1,infiniteScrollEnabled:n=!1,onBlockedInteraction:r,onInfiniteScrollEnabledChange:i,table:o,variant:s="basic"}=e,{pageIndex:a,pageSize:l}=o.getState().pagination,u=o.getPageCount(),[c,d]=(0,cm.useState)(String(a+1)),[h,f]=(0,cm.useState)(!1),p=(0,cm.useId)(),m=Math.max(String(Math.max(u,1)).length,c.trim().length||1),g=t,y=n&&!g;(0,cm.useEffect)(()=>{d(String(a+1))},[a]);function v(){r?.()}function b(k){g&&(k.preventDefault(),v())}function w(k){g&&(v(),k.currentTarget.blur())}function x(k,C){k.key==="Enter"&&(k.preventDefault(),C(k.currentTarget.value))}function S(k=c){if(g||y)return;let C=pQ(k);if(C==null){d(String(a+1));return}let N=Math.max(u,1),E=Math.min(Math.max(C,1),N);o.setPageIndex(E-1),d(String(E))}return(0,en.jsx)("div",{className:"rounded-b-lg overflow-visible sticky bottom-0 left-0 border-t-0 w-full z-20 p-0",children:(0,en.jsx)("div",{className:"flex items-center justify-between gap-2 py-3 px-2 border-t border-table-border backdrop-blur-sm bg-background/90",children:s==="basic"?(0,en.jsxs)("div",{className:"flex items-center gap-2",children:[(0,en.jsx)(zn,{variant:"outline",size:"sm","aria-disabled":g||!o.getCanPreviousPage()||void 0,className:t?"opacity-70":void 0,onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanPreviousPage()&&o.previousPage()},children:"Previous"}),(0,en.jsx)(zn,{variant:"outline",size:"sm","aria-disabled":g||!o.getCanNextPage()||void 0,className:t?"opacity-70":void 0,onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanNextPage()&&o.nextPage()},children:"Next"})]}):(0,en.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,en.jsxs)("div",{"aria-label":"Pagination",className:"inline-flex items-stretch overflow-hidden rounded-md border border-input bg-background shadow-sm",role:"group",children:[(0,en.jsx)(zn,{"aria-label":"Go to first page",variant:"outline",size:"icon",disabled:y||!o.getCanPreviousPage(),"aria-disabled":g||!o.getCanPreviousPage()||void 0,className:G("h-9 w-9 rounded-none border-0 border-r border-input shadow-none",t?"opacity-70":void 0),onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanPreviousPage()&&o.setPageIndex(0)},children:(0,en.jsx)(Qze,{"data-icon":"inline-start"})}),(0,en.jsx)(zn,{"aria-label":"Go to previous page",variant:"outline",size:"icon",disabled:y||!o.getCanPreviousPage(),"aria-disabled":g||!o.getCanPreviousPage()||void 0,className:G("h-9 w-9 rounded-none border-0 border-r border-input shadow-none",t?"opacity-70":void 0),onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanPreviousPage()&&o.previousPage()},children:(0,en.jsx)(WZ,{"data-icon":"inline-start"})}),(0,en.jsxs)("div",{className:"flex items-center gap-2 border-r border-input px-3 font-sans text-xs font-medium text-foreground tabular-nums",children:[(0,en.jsx)(Fi,{"aria-disabled":g||void 0,"aria-label":"Page number",inputMode:"numeric",pattern:"[0-9]*",type:"text",value:c,className:G("h-9 w-auto min-w-0 rounded-none border-0 px-1 text-right font-sans text-xs text-foreground tabular-nums shadow-none focus-visible:ring-0",(g||y)&&"opacity-70"),style:{width:`${m+1}ch`},readOnly:g||y,onMouseDown:b,onClick:()=>{g&&v()},onBlur:k=>S(k.currentTarget.value),onChange:k=>d(k.target.value),onInput:k=>d(k.target.value),onFocus:w,onKeyDown:k=>x(k,S)}),(0,en.jsx)("span",{className:"shrink-0",children:"of"}),(0,en.jsx)("span",{className:"shrink-0",children:u})]}),(0,en.jsxs)(Mde,{open:h&&!y,onOpenChange:k=>{if(g){k&&v(),f(!1);return}if(y){f(!1);return}f(k)},children:[(0,en.jsx)(_de,{asChild:!0,children:(0,en.jsxs)(zn,{"aria-disabled":g||void 0,"aria-label":"Rows per page",variant:"outline",size:"sm",disabled:y,className:G("h-9 rounded-none border-0 border-r border-input px-3 shadow-none font-sans text-xs font-medium","justify-between gap-2 whitespace-nowrap",t?"opacity-70":void 0),onMouseDown:b,onClick:k=>{g&&(k.preventDefault(),v())},children:[(0,en.jsxs)("span",{children:[l," rows per page"]}),(0,en.jsx)(Mv,{"data-icon":"inline-end"})]})}),(0,en.jsx)(B3,{align:"start",className:"min-w-[11rem] font-sans",children:(0,en.jsx)(Oit,{value:String(l),onValueChange:k=>{let C=pQ(k);C!=null&&o.setPageSize(C)},children:Lit.map(k=>(0,en.jsxs)(Tde,{value:String(k),className:"font-sans text-xs",children:[k," rows per page"]},k))})})]}),(0,en.jsx)(zn,{"aria-label":"Go to next page",variant:"outline",size:"icon",disabled:y||!o.getCanNextPage(),"aria-disabled":g||!o.getCanNextPage()||void 0,className:G("h-9 w-9 rounded-none border-0 border-r border-input shadow-none",t?"opacity-70":void 0),onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanNextPage()&&o.nextPage()},children:(0,en.jsx)(o1,{"data-icon":"inline-start"})}),(0,en.jsx)(zn,{"aria-label":"Go to last page",variant:"outline",size:"icon",disabled:y||!o.getCanNextPage(),"aria-disabled":g||!o.getCanNextPage()||void 0,className:G("h-9 w-9 rounded-none border-0 shadow-none",t?"opacity-70":void 0),onMouseDown:b,onClick:()=>{if(g){v();return}y||o.getCanNextPage()&&o.setPageIndex(u-1)},children:(0,en.jsx)(Xze,{"data-icon":"inline-start"})})]}),(0,en.jsxs)("div",{className:G(Zz({size:"default",variant:"outline"}),"h-9 gap-3 px-3 font-sans text-xs shadow-sm",g&&"opacity-70"),children:[(0,en.jsx)(Gz,{id:p,"aria-label":"Infinite scroll",checked:n,onMouseDown:b,onCheckedChange:k=>{if(g){v();return}i?.(k===!0)}}),(0,en.jsx)(lO,{className:"cursor-pointer font-sans text-xs font-medium",htmlFor:p,onMouseDown:b,children:"infinite scroll"})]})]})})})}function pQ(e){let t=e.trim();if(!/^\d+$/.test(t))return null;let n=Number(t);return!Number.isInteger(n)||!Number.isSafeInteger(n)||n<=0?null:n}function lq(e,t){let n=e.getIsPinned(),r=n==="left",i=n==="right",o=t==="header"&&(r||i),s=t==="cell"&&(r||i),a=t==="header"?"z-10":void 0,l=t==="cell"?s?"group-hover:!bg-muted":"group-hover:bg-muted":void 0,u=t==="cell"&&!n?"relative z-0":void 0,c=s?e.id==="__ps_select"?"z-30":"z-20":void 0,d=o?e.id==="__ps_select"?"z-40":"z-30":void 0;return{className:G(l,t==="cell"&&n&&"group-odd:!bg-table-cell-odd group-even:!bg-table-cell-even",t==="header"&&"select-none touch-none sticky top-0 bg-table-head","group border-r border-b border-table-border","overflow-hidden whitespace-nowrap text-ellipsis","data-[pinning-animating=from]:transition-none data-[pinning-animating=true]:transition-transform data-[pinning-animating=true]:duration-[1000ms] data-[pinning-animating=true]:ease-out data-[pinning-animating=true]:will-change-transform motion-reduce:transition-none",a,u,n&&"sticky",d,c,e.id==="__ps_select"&&"p-0"),style:{minWidth:`${e.getSize()}px`,transform:"translate3d(var(--ps-pinning-translate-x, 0px), var(--ps-pinning-translate-y, 0px), 0)",width:`${e.getSize()}px`,left:r?`${e.getStart("left")}px`:void 0,right:i?`${e.getAfter("right")}px`:void 0}}}function qit(e){let{columnIds:t,rowCount:n}=e,r=t[0];return!r||n<=0?null:{columnId:r,rowIndex:0}}function qde(e){let{columnIds:t,focusedCell:n,rowCount:r}=e;if(r<=0||t.length===0)return null;if(!n)return qit(e);let i=t.includes(n.columnId)?n.columnId:t[0];return i?{columnId:i,rowIndex:Cw(n.rowIndex,0,r-1)}:null}function zit(e){let t=qde(e);if(!t)return null;let n=e.columnIds.indexOf(t.columnId);if(n===-1)return t;switch(e.direction){case"up":return{...t,rowIndex:Cw(t.rowIndex-1,0,e.rowCount-1)};case"down":return{...t,rowIndex:Cw(t.rowIndex+1,0,e.rowCount-1)};case"left":return{...t,columnId:e.columnIds[Cw(n-1,0,e.columnIds.length-1)]};case"right":return{...t,columnId:e.columnIds[Cw(n+1,0,e.columnIds.length-1)]}}}function Fit(e){let{columnIds:t,columnWidths:n,currentScrollLeft:r,focusedColumnId:i,viewportWidth:o}=e,s=Math.max(0,r),a=Math.max(0,o),l=t.indexOf(i);if(l===-1||a<=0)return s;let u=0;for(let p=0;p<l;p+=1)u+=Math.max(0,n[p]??0);let c=Math.max(0,n[l]??0),d=u+c,h=s,f=h+a;return u<h?u:d>f?Math.max(0,d-a):s}function uq(e,t){return e===t?!0:!e||!t?!1:e.columnId===t.columnId&&e.rowIndex===t.rowIndex}function Cw(e,t,n){return Math.min(Math.max(e,t),n)}var Tp={mode:"none"};function jit(e){throw new Error(`Unhandled selection event: ${JSON.stringify(e)}`)}function Vit(e){return Array.from(new Set(e.filter(t=>typeof t=="string").map(t=>t.trim()).filter(t=>t.length>0)))}function A_(e){return{rowIndex:e.rowIndex,columnId:e.columnId,columnIndex:e.columnIndex}}function mQ(e){return e.mode==="none"?Tp:e.mode==="row"?{mode:"row",rowIds:[...e.rowIds]}:{mode:"cell",start:A_(e.start),end:A_(e.end)}}function oh(e,t){switch(t.type){case"cell.select":return{mode:"cell",start:A_(t.start),end:A_(t.end)};case"cell.clear":return e.mode==="cell"?Tp:mQ(e);case"row.select":{let n=Vit(t.rowIds);return n.length===0?Tp:{mode:"row",rowIds:n}}case"row.clear":return e.mode==="row"?Tp:mQ(e);case"escape":case"reset":return Tp;default:return jit(t)}}function zde(e){return e.mode!=="cell"?null:eit({start:e.start,end:e.end})}function Fde(e){return e.mode==="cell"?e.start:null}function Wit(e){return e.mode==="cell"?e.end:null}function Uit(e){return e.mode!=="none"}function gQ(e){return Object.entries(e).filter(([,t])=>t===!0).map(([t])=>t).sort()}var ca="__ps_select",Hit=16,$it=320,Kit=[],yQ={left:[ca],right:[]},vQ={},Yit=1e3,Qit={block:"nearest",inline:"nearest"},bQ=120,Git=360;function jde(e){let t=e.dataset.gridHeaderColumnId;if(t)return`header:${t}`;let n=e.dataset.gridRowIndex,r=e.dataset.gridColumnId;return n!=null&&r?`cell:${n}:${r}`:null}function Xit(e){return!Number.isFinite(e)||e<=0?bQ:Math.max(bQ,Math.min(Git,Math.round(e*.25)))}function wQ(e){let t=new Map;return e.querySelectorAll("th[data-grid-header-column-id], td[data-grid-row-index][data-grid-column-id]").forEach(n=>{let r=jde(n);if(!r)return;let i=n.getBoundingClientRect();t.set(r,{left:i.left,top:i.top})}),t}function Jit(e){return Vde(e).join("|")}function Vde(e){return e.map(t=>typeof t.id=="string"&&t.id.length>0?t.id:"accessorKey"in t&&typeof t.accessorKey=="string"&&t.accessorKey.length>0?t.accessorKey:"").filter(t=>t.length>0)}function Wde(e,t){let n=new Set(t),r=new Set,i=[];for(let o of e)o===ca||!n.has(o)||r.has(o)||(r.add(o),i.push(o));return i}function cq(e){return{left:[ca,...e],right:[]}}function lh(e){return(e.left??[]).filter(t=>t!==ca)}function Fp(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function kN(e,t){return Fp(e.left??[],t.left??[])&&Fp(e.right??[],t.right??[])}function xQ(e){let{columnOrder:t,pinnedColumnIds:n}=e,r=new Set(n);return[...t.filter(i=>r.has(i)?(r.delete(i),!0):!1),...Array.from(r)]}function cv(e,t){return(t.left??[]).includes(e)?"left":(t.right??[]).includes(e)?"right":"center"}function Zit(e){let{activeId:t,columnOrder:n,columnPinning:r,overId:i}=e;if(t===i)return{didReorder:!1,nextColumnOrder:n,nextColumnPinning:r};let o=n.indexOf(t),s=n.indexOf(i);if(o<0||s<0||o===s)return{didReorder:!1,nextColumnOrder:n,nextColumnPinning:r};let a=cv(t,r),l=cv(i,r);if(a!==l)return{didReorder:!1,nextColumnOrder:n,nextColumnPinning:r};let u=Zw(n,o,s);if(a==="left"){let c=lh(r),d=c.indexOf(t),h=c.indexOf(i);if(d<0||h<0)return{didReorder:!1,nextColumnOrder:n,nextColumnPinning:r};let f=Zw(c,d,h);return{didReorder:!Fp(f,c),nextColumnOrder:u,nextColumnPinning:{left:[ca,...f],right:r.right??[]}}}if(a==="right"){let c=r.right??[],d=c.indexOf(t),h=c.indexOf(i);if(d<0||h<0)return{didReorder:!1,nextColumnOrder:n,nextColumnPinning:r};let f=Zw(c,d,h);return{didReorder:!Fp(f,c),nextColumnOrder:u,nextColumnPinning:{left:r.left??[],right:f}}}return{didReorder:!0,nextColumnOrder:u,nextColumnPinning:r}}function eot(e){let{activeId:t,columnPinning:n,overId:r}=e;if(!r)return null;let i=cv(t,n),o=cv(r,n);return i===o?r:null}function SQ(e){let{activeId:t,columnPinning:n,lastCompatibleOverId:r,overId:i}=e,o=eot({activeId:t,columnPinning:n,overId:i});return o?{compatibleOverId:o,nextLastCompatibleOverId:o,resolvedDropTargetId:o}:i?{compatibleOverId:null,nextLastCompatibleOverId:null,resolvedDropTargetId:null}:{compatibleOverId:null,nextLastCompatibleOverId:r,resolvedDropTargetId:r}}function tot(e){let{activeId:t,columnOrder:n,columnPinning:r,deltaX:i}=e;if(Math.abs(i)<8)return null;let o=cv(t,r),s=[];o==="left"?s=xQ({columnOrder:n,pinnedColumnIds:lh(r)}):o==="right"?s=xQ({columnOrder:n,pinnedColumnIds:r.right??[]}):s=n.filter(u=>cv(u,r)==="center");let a=s.indexOf(t);if(a<0||s.length<2)return null;let l=i>0?Math.min(s.length-1,a+1):Math.max(0,a-1);return l===a?null:s[l]??null}function kQ(e,t){return cq(Wde(lh(e),t))}function Ude(e){let{pinnedColumnIds:t,focusScrollContainerKey:n,focusRowIndexOffset:r=0,focusedCell:i,selectionScopeKey:o,columnDefs:s,getBeforeHeaderRows:a,getBeforeRows:l,isFetching:u,isProcessing:c,onFocusedCellChange:d,areRowsInViewActionsLocked:h=!1,hasMoreInfiniteRows:f=!1,infiniteScrollEnabled:p=!1,onBlockedRowsInViewAction:m,onInfiniteScrollEnabledChange:g,onLoadMoreRows:y,onPinnedColumnIdsChange:v,onPaginationChange:b,onPasteSelection:w,onRowSelectionChange:x,onSortingChange:S,pageCount:k,paginationState:C,rows:N,rowSelectionState:E,sortingState:D,canWriteToCell:q}=e,z=o??"__default__",[_,R]=En(`datagrid:${z}:column-order`,Kit),[T,B]=En(`datagrid:${z}:column-pinning`,yQ),[A,M]=En(`datagrid:${z}:column-sizing`,vQ),P=(0,pe.useMemo)(()=>ede(A),[A]),[F,I]=En(`datagrid:${z}:selection-state`,Tp),V=Fde(F),W=Wit(F),j=zde(F),X=(0,pe.useMemo)(()=>gQ(E),[E]),$=X.join("|"),K=(0,pe.useRef)(null),Q=(0,pe.useRef)(null),J=(0,pe.useRef)(null),oe=(0,pe.useRef)(!1),be=(0,pe.useRef)(o),Me=(0,pe.useMemo)(()=>CQ(D),[D]),Je=(0,pe.useMemo)(()=>Jit(s),[s]),Ve=(0,pe.useRef)([]),Ct=(0,pe.useRef)("");Ct.current!==Je&&(Ct.current=Je,Ve.current=Vde(s));let He=Ve.current,de=(0,pe.useMemo)(()=>He.filter(Y=>Y!==ca),[He]),ie=(0,pe.useMemo)(()=>Wde(t??[],de),[t,de]),ze=ie.join("|"),Le=(0,pe.useMemo)(()=>t==null?yQ:cq(ie),[ie,t]),Oe=u||c;(0,pe.useEffect)(()=>{R(He),B(Le),M(vQ)},[Je,Le,He,R,B,M]),(0,pe.useEffect)(()=>{if(t==null)return;let Y=cq(ie);kN(T,Y)||B(Y),v&&!Fp(t,ie)&&v(ie)},[T,v,ie,ze,t,B]),(0,pe.useEffect)(()=>{P!==A&&M(P)},[A,P,M]);let rt=(0,pe.useRef)(null),Ht=(0,pe.useRef)(null),$t=(0,pe.useRef)(null),dt=(0,pe.useRef)(null),[et,pt]=(0,pe.useState)(null),nn=(0,pe.useCallback)(()=>{$t.current!=null&&(window.cancelAnimationFrame($t.current),$t.current=null),dt.current!=null&&(window.clearTimeout(dt.current),dt.current=null),pt(null)},[]),Dt=(0,pe.useCallback)(()=>{let Y=rt.current;Y&&(nn(),Ht.current=wQ(Y))},[nn]),Ot=(0,pe.useCallback)(Y=>{B(Z=>{let se=typeof Y=="function"?Y(Z):Y,ue=kQ(se,de);return v&&!Fp(lh(Z),lh(ue))&&v(lh(ue)),kN(Z,ue)||Dt(),kN(Z,ue)?Z:ue})},[v,Dt,B,de]),Kt=(0,pe.useCallback)(Y=>{let Z=rt.current;if(!Z)return{metrics:null,width:200};let se=Z.querySelectorAll("th[data-grid-header-id]"),ue=Array.from(se).find(Ye=>Ye.dataset.gridHeaderId===Y);if(!ue)return{metrics:null,width:200};let Ke=ue.getBoundingClientRect();return{metrics:{bottom:Ke.bottom,centerY:Ke.top+Ke.height/2,top:Ke.top},width:Ke.width}},[]),Er=(0,pe.useCallback)(({active:Y})=>{let Z=String(Y.id);tt.current=null,Yt.current={x:0,y:0};let se=Kt(Z);vn.current=se.metrics,it({columnId:Z,width:se.width}),Nt(!1)},[Kt]),Dn=(0,pe.useCallback)(({delta:Y})=>{Yt.current=Y},[]),Zn=(0,pe.useCallback)(()=>{let Y=vn.current;if(!Y)return!1;let Z=Y.centerY+Yt.current.y;return Z<Y.top-4||Z>Y.bottom+4},[]),Un=(0,pe.useCallback)(({active:Y,over:Z})=>{let se=String(Y.id),ue=SQ({activeId:se,columnPinning:T,lastCompatibleOverId:tt.current,overId:Z?String(Z.id):null}),Ke=!!(ue.compatibleOverId&&ue.compatibleOverId!==se);if(Nt(Ye=>Ye===Ke?Ye:Ke),ue.compatibleOverId&&ue.compatibleOverId!==se){tt.current=ue.compatibleOverId;return}if(Z&&!ue.compatibleOverId){if(Zn())return;tt.current=null}},[T,Zn]),he=(0,pe.useCallback)(({active:Y,over:Z,delta:se})=>{let ue=String(Y.id),Ke=SQ({activeId:ue,columnPinning:T,lastCompatibleOverId:tt.current,overId:Z?String(Z.id):null}),Ye=Ke.resolvedDropTargetId,mt=!!(Z&&!Ke.compatibleOverId);if((!Ye||Ye===ue)&&!mt&&(Ye=tot({activeId:ue,columnOrder:_,columnPinning:T,deltaX:se.x})),tt.current=null,vn.current=null,Yt.current={x:0,y:0},it(null),Nt(!0),!Ye)return;let Zt=Zit({activeId:ue,columnOrder:_,columnPinning:T,overId:Ye});if(!Zt.didReorder)return;Dt(),R(Zt.nextColumnOrder);let Lt=kQ(Zt.nextColumnPinning,de),vd=lh(T),If=lh(Lt);v&&!Fp(vd,If)&&v(If),kN(T,Lt)||B(Lt)},[_,T,v,Dt,R,B,de]),Ae=(0,pe.useCallback)(()=>{tt.current=null,vn.current=null,Yt.current={x:0,y:0},it(null),Nt(!0)},[]),ge=Ptt(Rce,{activationConstraint:{distance:10}}),Be=Ltt(ge),[ye,De]=(0,pe.useState)({scrollLeft:0,width:0}),[gt,ce]=(0,pe.useState)(null),[$e,it]=(0,pe.useState)(null),[Jt,Nt]=(0,pe.useState)(!0),tt=(0,pe.useRef)(null),vn=(0,pe.useRef)(null),Yt=(0,pe.useRef)({x:0,y:0}),Mt=(0,pe.useRef)(null);(0,pe.useLayoutEffect)(()=>{let Y=Ht.current,Z=rt.current;if(!Y||!Z)return;Ht.current=null;let se=wQ(Z),ue={};if(Z.querySelectorAll("th[data-grid-header-column-id], td[data-grid-row-index][data-grid-column-id]").forEach(Ke=>{let Ye=jde(Ke);if(!Ye)return;let mt=Y.get(Ye),Zt=se.get(Ye);if(!mt||!Zt)return;let Lt=mt.left-Zt.left,vd=mt.top-Zt.top;Math.abs(Lt)<1&&Math.abs(vd)<1||(ue[Ye]={x:Lt,y:vd})}),Object.keys(ue).length!==0)return pt({deltas:ue,phase:"from"}),$t.current=window.requestAnimationFrame(()=>{$t.current=window.requestAnimationFrame(()=>{pt(Ke=>Ke&&{...Ke,phase:"true"}),$t.current=null})}),dt.current=window.setTimeout(()=>{nn()},Yit+40),()=>{nn()}},[nn,_,T]);let bt=Zce({columnResizeMode:"onChange",columns:s,data:N,defaultColumn:{size:200,minSize:50,maxSize:400},enableColumnPinning:!0,enableColumnResizing:!0,enableRowSelection:!0,enableSorting:!!(S&&D),getCoreRowModel:Zrt(),getRowId:({__ps_rowid:Y})=>Y,manualPagination:!0,manualSorting:!0,meta:{isColumnReorderPreviewEnabled:Jt},onColumnOrderChange:R,onColumnPinningChange:Ot,onColumnSizingChange:Y=>M(Z=>oit(Z,Y)),onPaginationChange:b,onRowSelectionChange:x,onSortingChange:Y=>S?.(Z=>(typeof Y=="function"&&(Y=Y(CQ(Z))),not(Y))),pageCount:k,state:{columnOrder:_,columnPinning:T,columnSizing:P,pagination:C,rowSelection:E,sorting:Me}}),Rn=bt.getCenterVisibleLeafColumns(),ps=bt.getLeftVisibleLeafColumns().reduce((Y,Z)=>Y+Z.getSize(),0),md=bt.getRightVisibleLeafColumns().reduce((Y,Z)=>Y+Z.getSize(),0),Fu=Math.max(0,ye.width-ps-md),gd=Math.max(0,ye.scrollLeft-ps),Or=sit({columnWidths:Rn.map(Y=>Y.getSize()),minColumnCount:Hit,overscanPx:$it,scrollLeft:gd,viewportWidth:Fu}),Df=bt.getVisibleLeafColumns(),wr=(0,pe.useMemo)(()=>Df.map(Y=>Y.id).filter(Y=>Y!==ca),[Df]),ms=(0,pe.useMemo)(()=>new Map(wr.map((Y,Z)=>[Y,Z])),[wr]),ju=wr.join("|"),Tr=X.length>0,Wa=wr.length-1;function Vu(Y){return Or.enabled?Y.slice(Or.startIndex,Or.endIndex+1):Y}let yd=(0,pe.useCallback)((Y,Z)=>CI({columnIds:wr,range:{rowStart:Y,rowEnd:Y,columnStart:Z,columnEnd:Z},rows:N}),[N,wr]),Wu=(0,pe.useCallback)(()=>!j||N.length===0?"":CI({columnIds:wr,range:j,rows:N}),[N,wr,j]),Zs=(0,pe.useCallback)(Y=>N.length===0||wr.length===0||Wa<0?"":CI({columnIds:wr,range:{rowStart:Y,rowEnd:Y,columnStart:0,columnEnd:Wa},rows:N}),[Wa,N,wr]),Ua=(0,pe.useCallback)(()=>!Tr||N.length===0||wr.length===0||Wa<0?"":bt.getRowModel().rows.filter(Y=>Y.getIsSelected()).map(Y=>Zs(Y.index)).filter(Y=>Y.length>0).join(`
`),[Zs,Tr,Wa,N.length,wr.length,bt]),gs=(0,pe.useCallback)((Y,Z)=>{I(se=>oh(se,{type:"cell.select",start:Y,end:Z}))},[I]),zo=(0,pe.useCallback)(()=>{I(Y=>oh(Y,{type:"cell.clear"})),Q.current=null},[I]);(0,pe.useEffect)(()=>{K.current=V},[V]),(0,pe.useEffect)(()=>{I(Y=>oh(Y,{type:"row.select",rowIds:X}))},[X,$,I]),(0,pe.useEffect)(()=>{let Y=Z=>{oe.current=!1,J.current=null;let se=Q.current;if(Q.current=null,!se||se.cellSelectionMode)return;let ue=document.elementFromPoint(Z.clientX,Z.clientY),Ke=ue instanceof Element?ue.closest("td[data-grid-row-index][data-grid-column-id]"):null,Ye=Number(Ke?.dataset.gridRowIndex),mt=Ke?.dataset.gridColumnId,Zt=mt!=null?ms.get(mt):void 0,Lt=Number.isInteger(Ye)&&mt!=null&&Zt!=null?{rowIndex:Ye,columnId:mt,columnIndex:Zt}:null;if(Lt&&!NQ(se.anchor,Lt)){Yg(),gs(se.base,Lt);return}NI()};return window.addEventListener("mouseup",Y),()=>{window.removeEventListener("mouseup",Y)}},[ms,gs]),(0,pe.useEffect)(()=>{if(!(j!==null&&N.length>0)&&!Tr)return;let Y=se=>{if(Xb(document.activeElement)||Xb(se.target)||NI())return;let ue=Tr?Ua():Wu();ue&&(se.preventDefault(),se.clipboardData?.setData("text/plain",ue))},Z=se=>{if(!w||!j||Xb(document.activeElement)||Xb(se.target)||NI())return;let ue=se.clipboardData?.getData("text/plain");if(!ue)return;let Ke=tit(ue),Ye=nit({canWrite:({columnId:mt,rowIndex:Zt})=>{let Lt=N[Zt];return Lt?q?q({columnId:mt,row:Lt}):!0:!1},columnIds:wr,matrix:Ke,range:j,rowCount:N.length});Ye.length!==0&&(se.preventDefault(),Promise.resolve(w(Ye)).catch(mt=>{console.error("Failed to paste selection:",mt)}))};return window.addEventListener("copy",Y),window.addEventListener("paste",Z),()=>{window.removeEventListener("copy",Y),window.removeEventListener("paste",Z)}},[q,Wu,Ua,Tr,w,N,wr,j]);let er=(0,pe.useCallback)(Y=>{let Z=typeof Y=="function"?Y(E):Y;x(Z),I(se=>oh(se,{type:"row.select",rowIds:gQ(Z)}))},[x,E,I]),Gi=(0,pe.useCallback)(()=>{J.current=null,oe.current=!1},[]),ur=(0,pe.useCallback)(()=>{I(Y=>oh(Y,{type:"reset"})),Q.current=null,Gi()},[Gi,I]),Ri=(0,pe.useCallback)(()=>{er({}),Gi()},[Gi,er]),Um=(0,pe.useCallback)(()=>{I(Y=>oh(Y,{type:"escape"})),Q.current=null,Gi(),Tr&&x({})},[Tr,x,Gi,I]),Uu=(0,pe.useCallback)(Y=>{let{drag:Z,rowId:se,rowIndex:ue}=Y;Yg(),zo(),oe.current=Z,J.current=ue,er({[se]:!0})},[zo,er]);(0,pe.useEffect)(()=>{be.current!==o&&(be.current=o,ur(),Tr&&er({}))},[Tr,ur,o,er]),(0,pe.useEffect)(()=>{if(!Uit(F)&&!Tr)return;let Y=Z=>{if(Xb(document.activeElement))return;if(Z.key==="Escape"){Um(),Z.preventDefault();return}if(!Z.shiftKey||!V||!W)return;let{columnDelta:se,rowDelta:ue}=rot(Z.key);if(se===0&&ue===0)return;Z.preventDefault();let Ke=MQ(W.rowIndex+ue,0,Math.max(0,N.length-1)),Ye=MQ(W.columnIndex+se,0,Math.max(0,wr.length-1)),mt=wr[Ye];mt&&(d?.({columnId:mt,rowIndex:Ke+r}),gs(V,{rowIndex:Ke,columnId:mt,columnIndex:Ye}))};return window.addEventListener("keydown",Y),()=>{window.removeEventListener("keydown",Y)}},[Um,r,Tr,d,F,N.length,wr,W,j,V,gs]),(0,pe.useEffect)(()=>{ur()},[C.pageIndex,C.pageSize,ur,ju]),(0,pe.useEffect)(()=>{if(n==null)return;let Y=rt.current?.parentElement;Y instanceof HTMLDivElement&&Y.focus({preventScroll:!0})},[n]),(0,pe.useEffect)(()=>{if(!i){Mt.current=null;return}if(uq(Mt.current,i))return;let Y=rt.current?.parentElement;if(!(Y instanceof HTMLDivElement))return;let Z=bt.getColumn(i.columnId);if(!Z)return;let se=null;if(Z.getIsPinned()===!1&&Fu>0){let Ke=bt.getCenterVisibleLeafColumns(),Ye=Math.max(0,Y.scrollLeft),mt=Fit({columnIds:Ke.map(Zt=>Zt.id),columnWidths:Ke.map(Zt=>Zt.getSize()),currentScrollLeft:Ye,focusedColumnId:i.columnId,viewportWidth:Fu});se=Math.max(0,mt),Math.abs(se-Y.scrollLeft)>=1&&(Y.scrollLeft=se,Y.dispatchEvent(new Event("scroll")))}let ue=Array.from(Y.querySelectorAll(`td[data-grid-visual-row-index="${i.rowIndex}"][data-grid-column-id]`)).find(Ke=>Ke.dataset.gridColumnId===i.columnId);ue&&(ue.scrollIntoView(Qit),se!=null&&Math.abs(se-Y.scrollLeft)>=1&&(Y.scrollLeft=se,Y.dispatchEvent(new Event("scroll"))),Mt.current=i)},[ye.scrollLeft,Fu,i,ps,md,bt]),(0,pe.useEffect)(()=>{let Y=rt.current?.parentElement;if(!Y)return;let Z=null,se=()=>{Z=null;let Ye=Y.scrollLeft,mt=Y.clientWidth;De(Zt=>Zt.scrollLeft===Ye&&Zt.width===mt?Zt:{scrollLeft:Ye,width:mt})},ue=()=>{if(Z===null){if(typeof window.requestAnimationFrame!="function"){se();return}Z=window.requestAnimationFrame(se)}};ue(),Y.addEventListener("scroll",ue,{passive:!0}),window.addEventListener("resize",ue);let Ke=null;return typeof ResizeObserver<"u"&&(Ke=new ResizeObserver(ue),Ke.observe(Y)),()=>{Z!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(Z),Y.removeEventListener("scroll",ue),window.removeEventListener("resize",ue),Ke?.disconnect()}},[Je]),(0,pe.useEffect)(()=>{let Y=rt.current?.parentElement;if(!Y||!p||!f)return;let Z=()=>{if(u||c)return;let se=Xit(Y.clientHeight);Y.scrollHeight-(Y.scrollTop+Y.clientHeight)>se||y?.()};return Y.addEventListener("scroll",Z,{passive:!0}),Z(),()=>{Y.removeEventListener("scroll",Z)}},[f,p,u,c,y]);let bi=(0,pe.useCallback)((Y,Z)=>{let se=ms.get(Z);return se==null?null:{columnId:Z,columnIndex:se,rowIndex:Y}},[ms]),Ol=(0,pe.useCallback)((Y,Z)=>{let se=Math.min(Y,Z),ue=Math.max(Y,Z),Ke={},Ye=bt.getRowModel().rows;for(let mt=se;mt<=ue;mt++){let Zt=Ye[mt];Zt&&(Ke[Zt.id]=!0)}er(Ke)},[er,bt]),R0=(0,pe.useCallback)(()=>{let Y={};for(let Z of bt.getRowModel().rows)Y[Z.id]=!0;Yg(),ur(),er(Y)},[ur,er,bt]),qS=(0,pe.useCallback)(Y=>{if(Y.button!==0||Yw())return;Y.preventDefault(),Y.stopPropagation();let Z=bt.getRowModel().rows;if(Z.length>0&&Z.every(se=>E[se.id]===!0)){Ri();return}R0()},[Ri,E,R0,bt]),GT=(0,pe.useCallback)((Y,Z,se)=>{let ue=Y.button===0,Ke=Y.button===2;if(!(!ue&&!Ke)&&!Yw()){if(Ke){if(Y.stopPropagation(),zo(),E[se]===!0){oe.current=!1,J.current=Z;return}Uu({rowId:se,rowIndex:Z,drag:!1});return}if(ue&&Y.preventDefault(),Y.stopPropagation(),Y.shiftKey){Yg(),zo();let Ye={...E};Ye[se]===!0?delete Ye[se]:Ye[se]=!0,er(Ye),oe.current=!1,J.current=Z;return}Uu({rowId:se,rowIndex:Z,drag:ue})}},[zo,E,Uu,er]),Rf=(0,pe.useCallback)(Y=>{if(!oe.current)return;let Z=J.current;Z!=null&&Ol(Z,Y)},[Ol]),I0=(0,pe.useCallback)((Y,Z,se)=>{if(Y.stopPropagation(),zo(),E[se]===!0){oe.current=!1,J.current=Z;return}Uu({rowId:se,rowIndex:Z,drag:!1})},[zo,E,Uu]);function XT(Y,Z,se){if(Y.button!==0||Yw())return;Tr&&Ri();let ue=bi(Z,se);if(ue){if(Y.shiftKey&&K.current){Yg(),gs(K.current,ue),Q.current={anchor:ue,base:K.current,cellSelectionMode:!0};return}Q.current={anchor:ue,base:ue,cellSelectionMode:!1}}}let P0=(0,pe.useCallback)((Y,Z)=>{let se=Q.current;if(!se)return;let ue=bi(Y,Z);if(ue){if(!se.cellSelectionMode){if(NQ(se.anchor,ue))return;se.cellSelectionMode=!0,Yg(),gs(se.base,ue);return}gs(se.base,ue)}},[gs,bi]),zS=(0,pe.useCallback)(Y=>{if(!(Y instanceof Element))return null;let Z=Y.closest("td[data-grid-row-index][data-grid-column-id]");if(!Z)return null;let se=Number(Z.dataset.gridRowIndex),ue=Z.dataset.gridColumnId;return!Number.isInteger(se)||!ue?null:bi(se,ue)},[bi]);function FS(Y,Z){P0(Y,Z)}(0,pe.useEffect)(()=>{let Y=Z=>{if((Z.buttons&1)!==1||!Q.current&&!oe.current)return;let se=document.elementFromPoint(Z.clientX,Z.clientY),ue=zS(se);ue&&(oe.current&&Rf(ue.rowIndex),Q.current&&P0(ue.rowIndex,ue.columnId))};return window.addEventListener("mousemove",Y),()=>{window.removeEventListener("mousemove",Y)}},[Rf,zS,P0]);function Hm(Y){if(typeof Y.column.columnDef.header!="function")return null;let Z=lq(Y.column,"header"),se=et?.deltas[`header:${Y.column.id}`],ue={...Z.style,...se?{"--ps-pinning-translate-x":et.phase==="from"?`${se.x}px`:"0px","--ps-pinning-translate-y":et.phase==="from"?`${se.y}px`:"0px"}:null},Ke=Y.column.columnDef.header(Y.getContext());return(0,vt.jsx)(Ke,{...Z,className:G(Z.className,Y.column.id===ca&&"cursor-pointer"),"data-pinning-animating":se?et.phase:void 0,"data-grid-header-id":Y.id,"data-grid-header-column-id":Y.column.id,style:ue,onMouseDown:Ye=>{Y.column.id===ca&&qS(Ye)}},Y.id)}function $m(Y){let{cell:Z,row:se,rowIndex:ue}=Y;if(typeof Z.column.columnDef.cell!="function")return null;let Ke=Z.column.columnDef.cell(Z.getContext()),Ye=lq(Z.column,"cell"),mt=et?.deltas[`cell:${ue}:${Z.column.id}`],Zt={...Ye.style,...mt?{"--ps-pinning-translate-x":et.phase==="from"?`${mt.x}px`:"0px","--ps-pinning-translate-y":et.phase==="from"?`${mt.y}px`:"0px"}:null},Lt=Z.column.id===ca,vd=se.getIsSelected(),If=ms.get(Z.column.id),te=ue+r,me=j!=null&&If!=null&&hQ({columnIndex:If,range:j,rowIndex:ue}),_t=i?.rowIndex===te&&i.columnId===Z.column.id;return(0,vt.jsx)(Ke,{...Ye,className:G(Ye.className,Lt&&"group-odd:bg-table-cell-odd group-even:bg-table-cell-even",vd&&"group-odd:!bg-table-row-selected-odd group-even:!bg-table-row-selected-even",me&&"!bg-primary/15 ring-1 ring-inset ring-primary/30",_t&&"relative z-0 before:pointer-events-none before:absolute before:inset-0 before:border before:border-sky-300 before:content-['']"),"data-grid-column-id":Z.column.id,"data-grid-row-index":ue,"data-grid-visual-row-index":te,"data-grid-cell-context-target":"true","data-pinning-animating":mt?et.phase:void 0,"data-focused":_t||void 0,"data-row-select-cell":Lt||void 0,"data-selected":me||void 0,style:Zt,withContextMenu:!1,onMouseDown:bn=>(Lt||d?.({columnId:Z.column.id,rowIndex:te}),Lt?GT(bn,ue,se.id):XT(bn,ue,Z.column.id)),onMouseEnter:()=>Lt?Rf(ue):FS(ue,Z.column.id),onContextMenu:bn=>{Lt&&I0(bn,ue,se.id)},onClick:bn=>{Lt||bn.shiftKey||me||zo()}},Z.id)}let jS=(0,pe.useCallback)(()=>{if(!gt)return"";let{columnId:Y,rowIndex:Z}=gt,se=bt.getRowModel().rows[Z];if(!se)return"";let ue=Y===ca,Ke=se.getIsSelected(),Ye=ms.get(Y),mt=j!=null&&Ye!=null&&hQ({columnIndex:Ye,range:j,rowIndex:Z});if(ue)return Tr&&Ke?Ua():Zs(Z);if(Tr&&Ke)return Ua();if(mt){let Zt=Wu();if(Zt)return Zt}return Ye==null?"":yd(Z,Ye)},[ms,gt,Zs,Wu,Ua,yd,Tr,j,bt]),JT=(0,pe.useCallback)(Y=>{let Z=(Y.target instanceof Element?Y.target:null)?.closest("td[data-grid-row-index][data-grid-column-id][data-grid-cell-context-target='true']");if(!Z){ce(null);return}let se=Number(Z.dataset.gridRowIndex),ue=Z.dataset.gridColumnId;if(!Number.isInteger(se)||!ue){ce(null);return}ce({columnId:ue,rowIndex:se})},[]),VS=(0,pe.useCallback)(()=>{k_();let Y=jS();!Y&&Y!==""||navigator.clipboard.writeText(Y).catch(Z=>{console.error("Failed to copy to clipboard:",Z)})},[jS]);return(0,vt.jsx)(vt.Fragment,{children:(0,vt.jsxs)("div",{"data-studio":"content",className:"flex-1 w-0 h-0 min-h-0 min-w-full flex flex-col relative bg-background/50",children:[(0,vt.jsx)("div",{children:Oe&&(0,vt.jsx)(lit,{className:"absolute -top-px left-0 right-0"})}),(0,vt.jsxs)(pce,{children:[(0,vt.jsx)(mce,{asChild:!0,children:(0,vt.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",onContextMenuCapture:JT,children:(0,vt.jsxs)(Pnt,{collisionDetection:Vtt,sensors:Be,onDragCancel:Ae,onDragEnd:he,onDragMove:Dn,onDragOver:Un,onDragStart:Er,children:[(0,vt.jsxs)(Jle,{containerProps:{"aria-label":"Table grid",className:"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/25","data-grid-scroll-container":"true",style:{containerType:"inline-size"},tabIndex:0},ref:rt,className:"table-fixed border-separate border-spacing-0 box-border w-auto bg-background/50",children:[(0,vt.jsxs)(Zle,{children:[a?.(bt),bt.getHeaderGroups().map(Y=>{let Z=Y.headers.filter(Lt=>Lt.column.getIsPinned()==="left"),se=Y.headers.filter(Lt=>Lt.column.getIsPinned()===!1),ue=Y.headers.filter(Lt=>Lt.column.getIsPinned()==="right"),Ke=Vu(se),Ye=Z.filter(Lt=>Lt.column.id!==ca).map(Lt=>Lt.id),mt=Ke.map(Lt=>Lt.id),Zt=ue.map(Lt=>Lt.id);return(0,vt.jsxs)(Fy,{children:[(0,vt.jsx)(gI,{items:Ye,strategy:mI,children:Z.map(Hm)}),Or.hiddenStartWidth>0&&se.length>0&&(0,vt.jsx)(um,{"aria-hidden":"true",className:"p-0 border-r border-b border-table-border bg-table-head pointer-events-none",style:{minWidth:`${Or.hiddenStartWidth}px`,width:`${Or.hiddenStartWidth}px`}},`${Y.id}-virtual-start`),(0,vt.jsx)(gI,{items:mt,strategy:mI,children:Ke.map(Hm)}),Or.hiddenEndWidth>0&&se.length>0&&(0,vt.jsx)(um,{"aria-hidden":"true",className:"p-0 border-r border-b border-table-border bg-table-head pointer-events-none",style:{minWidth:`${Or.hiddenEndWidth}px`,width:`${Or.hiddenEndWidth}px`}},`${Y.id}-virtual-end`),(0,vt.jsx)(gI,{items:Zt,strategy:mI,children:ue.map(Hm)})]},Y.id)})]}),(0,vt.jsxs)(eue,{children:[l?.(bt),bt.getRowModel().rows?.length?bt.getRowModel().rows.map((Y,Z)=>{let se=Y.getLeftVisibleCells(),ue=Y.getCenterVisibleCells(),Ke=Y.getRightVisibleCells(),Ye=Vu(ue);return(0,vt.jsxs)(Fy,{"data-row-selected":Y.getIsSelected()||void 0,className:G("bg-table-row group","odd:bg-table-cell-odd even:bg-table-cell-even/50"),children:[se.map(mt=>$m({cell:mt,row:Y,rowIndex:Z})),Or.hiddenStartWidth>0&&ue.length>0&&(0,vt.jsx)(Kw,{"aria-hidden":"true",className:"relative z-0 p-0 border-r border-b border-table-border pointer-events-none group-odd:!bg-table-cell-odd group-even:!bg-table-cell-even",style:{minWidth:`${Or.hiddenStartWidth}px`,width:`${Or.hiddenStartWidth}px`}},`${Y.id}-virtual-start`),Ye.map(mt=>$m({cell:mt,row:Y,rowIndex:Z})),Or.hiddenEndWidth>0&&ue.length>0&&(0,vt.jsx)(Kw,{"aria-hidden":"true",className:"relative z-0 p-0 border-r border-b border-table-border pointer-events-none group-odd:!bg-table-cell-odd group-even:!bg-table-cell-even",style:{minWidth:`${Or.hiddenEndWidth}px`,width:`${Or.hiddenEndWidth}px`}},`${Y.id}-virtual-end`),Ke.map(mt=>$m({cell:mt,row:Y,rowIndex:Z}))]},Y.id)}):(0,vt.jsx)(Fy,{children:(0,vt.jsx)(Kw,{colSpan:s.length,className:"h-24 text-left p-(--studio-cell-spacing)",children:u&&(0,vt.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,vt.jsx)(jN,{className:"h-4 w-full"}),(0,vt.jsx)(jN,{className:"h-4 w-4/5"}),(0,vt.jsx)(jN,{className:"h-4 w-2/3"})]})})})]})]}),(0,vt.jsx)(ert,{dropAnimation:null,children:$e?(0,vt.jsx)("div",{className:"pointer-events-none flex h-10 items-center border border-table-border bg-background px-2 font-mono text-xs text-foreground/90 shadow-md",style:{minWidth:`${$e.width}px`,width:`${$e.width}px`},children:(0,vt.jsx)("span",{className:"truncate",children:$e.columnId})}):null})]})})}),(0,vt.jsx)(N3,{children:(0,vt.jsx)(M3,{disabled:gt===null,onPointerDown:()=>k_(),onSelect:Y=>{if(gt===null){Y.preventDefault();return}VS()},children:"Copy"})})]}),k==null?null:(0,vt.jsx)(Bit,{controlsDisabled:h,infiniteScrollEnabled:p,onBlockedInteraction:m,onInfiniteScrollEnabledChange:g,table:bt,variant:"numeric"}),(0,vt.jsx)(HX,{mode:"wait",children:bt.getRowModel().rows?.length===0&&!u&&!c&&(0,vt.jsx)(uP.div,{className:"flex items-center justify-center absolute -inset-0 pointer-events-none",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},children:(0,vt.jsxs)("div",{className:"flex flex-col gap-1 text-center",children:[(0,vt.jsx)("div",{className:"text-sm text-muted-foreground",children:"No results found"}),(0,vt.jsx)("div",{className:"text-xs text-muted-foreground",children:"It doesn't look like you have any data in this table."})]})})})]})})}function CQ(e){return e?.map(t=>({id:t.column,desc:t.direction==="desc"}))||[]}function not(e){return e.map(t=>({column:t.id,direction:t.desc?"desc":"asc"}))}function Xb(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function NI(){let e=window.getSelection();return!e||e.rangeCount===0||e.isCollapsed?!1:e.toString().trim().length>0}function Yg(){let e=window.getSelection();!e||e.rangeCount===0||e.removeAllRanges()}function NQ(e,t){return e.rowIndex===t.rowIndex&&e.columnIndex===t.columnIndex}function rot(e){switch(e){case"ArrowUp":return{rowDelta:-1,columnDelta:0};case"ArrowDown":return{rowDelta:1,columnDelta:0};case"ArrowLeft":return{rowDelta:0,columnDelta:-1};case"ArrowRight":return{rowDelta:0,columnDelta:1};default:return{rowDelta:0,columnDelta:0}}}function MQ(e,t,n){return Math.min(Math.max(e,t),n)}var hq=e=>{let{children:t,className:n,header:r,style:i,table:o,...s}=e,{attributes:a,listeners:l,transform:u,transition:c,setNodeRef:d,isDragging:h}=drt({id:r.id}),f=!!o.options.meta?.isColumnReorderPreviewEnabled,p=!h&&!f,m=p?void 0:qh.Translate.toString(u),g={...i,cursor:"grab",touchAction:"none",transform:[i?.transform,m].filter(Boolean).join(" ")||void 0,transition:p?void 0:c},y=G(n,"p-0",h&&"z-50! opacity-0");return(0,dq.jsx)(um,{ref:d,...s,...a,...l,style:g,className:y,children:(0,dq.jsx)("div",{className:"h-full min-w-0 w-full",children:t})})};function Jb(e){let{children:t,tooltip:n}=e;return(0,Yn.jsx)(RE,{delayDuration:120,children:(0,Yn.jsxs)(IE,{children:[(0,Yn.jsx)(PE,{asChild:!0,children:(0,Yn.jsx)("span",{className:"inline-flex shrink-0 items-center justify-center",children:t})}),(0,Yn.jsx)(v1,{side:"bottom",className:"text-xs",children:n})]})})}function iot({column:e}){let{datatype:t,fkColumn:n,fkSchema:r,fkTable:i,isAutoincrement:o,isComputed:s,isRequired:a,name:l,pkPosition:u}=e;return(0,Yn.jsxs)("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[u!=null&&(0,Yn.jsx)(Jb,{tooltip:(0,Yn.jsx)("span",{children:"Primary key"}),children:(0,Yn.jsx)(u9,{size:12,className:"text-amber-500"})}),n!=null&&(0,Yn.jsx)(Jb,{tooltip:(0,Yn.jsxs)("span",{children:["Foreign key - references"," ",[r,i,n].filter(Boolean).join(".")]}),children:(0,Yn.jsx)(u9,{size:12,className:"text-primary"})}),o&&(0,Yn.jsx)(Jb,{tooltip:(0,Yn.jsx)("span",{children:"Auto-increment"}),children:(0,Yn.jsx)(Rze,{size:12,className:"text-muted-foreground"})}),s&&(0,Yn.jsx)(Jb,{tooltip:(0,Yn.jsx)("span",{children:"Computed"}),children:(0,Yn.jsx)(jze,{size:12,className:"text-muted-foreground"})}),a&&(0,Yn.jsx)(Jb,{tooltip:(0,Yn.jsx)("span",{children:"Required - not nullable, computed, auto-incrementing, and has no default value"}),children:(0,Yn.jsx)(Bze,{size:12,className:"text-destructive"})}),(0,Yn.jsx)("span",{className:"min-w-0 truncate font-medium",children:l}),(0,Yn.jsx)("span",{className:"min-w-0 truncate lowercase text-muted-foreground/70",children:t.affinity||t.name})]})}function Hde(e){let{column:t,header:n,className:r,isSortDisabled:i=!1,onBlockedSortInteraction:o}=e,s=n.column.getIsPinned()!==!1,a=n.column.getIsSorted(),l=a!==!1,u=s||l,c=u?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto focus-within:opacity-100 focus-within:pointer-events-auto",d=a==="asc",h=a==="desc";function f(){n.column.pin(s?!1:"left")}function p(){if(i){o?.();return}if(n.column.getCanSort()){if(a===!1){n.column.toggleSorting(!1);return}if(a==="asc"){n.column.toggleSorting(!0);return}n.column.clearSorting()}}function m(g){g.stopPropagation(),i&&(g.preventDefault(),o?.())}return(0,wo.jsxs)("div",{className:G("group relative flex h-full w-full items-center justify-between min-w-0 px-2",r),children:[(0,wo.jsx)("div",{className:"flex items-center justify-between w-full min-w-0 pr-2",children:(0,wo.jsx)("div",{className:"flex items-center gap-2 overflow-hidden text-ellipsis font-mono text-xs",children:n.isPlaceholder?null:(0,wo.jsx)("span",{className:"flex min-w-0",children:(0,wo.jsx)("span",{className:"min-w-0 overflow-hidden text-ellipsis text-foreground/90",children:(0,wo.jsx)(iot,{column:t})})})})}),(0,wo.jsxs)("span",{"data-testid":"column-header-controls","data-active":u||void 0,className:G("absolute right-1 top-1/2 -translate-y-1/2 z-10 inline-flex items-center gap-0.5 rounded-full border border-table-border bg-background/95 px-1 py-0.5 shadow-sm transition-opacity duration-150",c),children:[n.column.getCanPin()&&n.column.id!=="__ps_select"&&(0,wo.jsx)("button",{type:"button","aria-label":s?"Unpin column":"Pin column",onClick:g=>{g.stopPropagation(),f()},onMouseDown:g=>g.stopPropagation(),className:G("flex h-5 w-5 items-center justify-center rounded-full transition-colors",s?"text-foreground":"text-muted-foreground/70 hover:text-foreground"),children:(0,wo.jsx)(N5e,{size:12})}),n.column.getCanSort()&&(0,wo.jsx)("button",{type:"button","aria-disabled":i||void 0,"aria-label":d?"Sort descending":h?"Clear sorting":"Sort ascending",onClick:g=>{g.stopPropagation(),p()},onMouseDown:m,className:G("flex h-5 w-5 items-center justify-center rounded-full transition-colors",i&&"opacity-60",l?"text-foreground":"text-muted-foreground/70 hover:text-foreground"),children:h?(0,wo.jsx)(Oze,{size:12}):(0,wo.jsx)(Pze,{size:12})})]}),n.column.getCanResize()&&(0,wo.jsx)("button",{type:"button",tabIndex:0,onMouseDown:g=>{g.stopPropagation(),n.getResizeHandler()(g)},onTouchStart:g=>{g.stopPropagation(),n.getResizeHandler()(g)},onClick:g=>g.stopPropagation(),onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),n.getResizeHandler()(g))},className:G("absolute inset-y-0 -right-2 z-20 block w-4 cursor-col-resize before:absolute before:inset-y-0 before:left-2 before:w-px before:bg-transparent hover:before:bg-table-border focus-visible:outline-none focus-visible:before:bg-table-border"),"aria-label":"Resize column"})]})}function oot(e){return e==="mysql"?SXe:e==="sqlite"?CXe:xXe}function sot(e){let t={},n=Object.keys(e).sort((r,i)=>r.localeCompare(i));for(let r of n){let i=e[r]??{},o={},s=Object.keys(i).sort((a,l)=>a.localeCompare(l));for(let a of s)o[a]=[...i[a]??[]].sort((l,u)=>l.localeCompare(u));t[r]=o}return t}function aot(e){let{runSql:t}=e;return[{key:"Mod-Enter",run:()=>(t(),!0)}]}function $de(e){let t=e.trim(),n=/^```(?:json)?\s*([\s\S]*?)\s*```$/i.exec(t);return n?.[1]?n[1].trim():t}async function Kde(e){let{requestAiText:t,buildRetryPrompt:n,createRetryIssueFromError:r,invalidResponseMessage:i,maxCorrectionRetries:o=1,parseResponse:s,prompt:a}=e,l="",u=a;for(let c=0;c<=o;c+=1){try{l=await t(u)}catch(h){let f=iU(h);if(!f)throw h;let p=r?.({error:h,message:f,responseText:f})??null;if(!p)throw new Error(f);if(c>=o)throw new Error(p.message);l=f,u=n({correctionCount:c+1,issues:[p],responseText:l});continue}let d=s(l);if(d.issues.length===0&&d.value!==null)return{correctionCount:c,didRetry:c>0,responseText:l,value:d.value};if(c>=o)throw new Error(d.issues[0]?.message??i);u=n({correctionCount:c+1,issues:d.issues,responseText:l})}throw new Error(i)}var lot=12,uot=20;function cot(e){let{activeSchema:t,dialect:n,introspection:r,maxColumnsPerTable:i=lot,maxTables:o=uot}=e,s=[],a=fot(e.activeSchema,r);for(let l of a){for(let u of Object.values(l.tables))if(s.push({columns:Object.values(u.columns).slice(0,i).map(c=>({datatype:c.datatype.name,name:c.name})),name:u.name,schema:u.schema}),s.length>=o)break;if(s.length>=o)break}return{activeSchema:t,dialect:n,tables:s,timeZone:r.timezone}}function Yde(e){let{context:t,now:n=new Date,request:r}=e,i=yot(t.dialect),o=t.timeZone??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",s=t.tables.flatMap(a=>[`- ${a.schema}.${a.name}`,...a.columns.map(l=>` - ${l.name}: ${l.datatype}`)]);return["You convert a user's natural-language request into a single SQL statement for Prisma Studio.",`Database engine: ${i}`,`SQL dialect identifier: ${t.dialect}`,`Active schema: ${t.activeSchema}`,`Current local date and time: ${bot(n,o)} (timezone: ${o})`,`Current UTC date and time: ${n.toISOString()}`,"Available tables and columns:",...s,"Return JSON only. Do not add markdown fences or commentary.",'Return this exact top-level shape: {"sql":"...","rationale":"...","shouldGenerateVisualization":true}',"Rules:","- Use only the listed schemas, tables, and columns.","- Return exactly one SQL statement.","- Prefer a read-only SELECT query unless the user explicitly requests a write or schema change.","- If the query returns rows instead of a count or aggregate, include a reasonable LIMIT of 100 or less unless the user explicitly requests another limit.",`- Use only functions, operators, and casts supported by ${i}.`,"- Use dialect-appropriate SQL syntax.","- Decide whether the resulting dataset would make an interesting chart.",'- Set "shouldGenerateVisualization" to true only when the expected result is meaningfully visualizable as a simple chart such as a bar, line, pie, scatter, or time-series view.','- Set "shouldGenerateVisualization" to false for results that are mostly free-form text, unstructured JSON, single values, or otherwise better inspected as a table.',...vot(t.dialect).map(a=>`- ${a}`),"- Never invent tables or columns that are not listed above.",`User request: ${r}`].join(`
`)}function dot(e){let{context:t,issues:n,now:r,previousSql:i,queryErrorMessage:o,request:s,responseText:a}=e;return[Yde({context:t,now:r,request:s}),i?`Previous SQL statement: ${i}`:null,o?`Database error from that SQL: ${o}`:null,"Your previous response was invalid.",`Original user request: ${s}`,`Previous response: ${a}`,"Problems to fix:",...n.map(l=>`- ${l.message}`),"Return corrected JSON only. Do not add markdown fences or commentary."].filter(l=>l!==null).join(`
`)}async function hot(e){let{activeSchema:t,requestAiSqlGeneration:n,dialect:r,introspection:i,maxColumnsPerTable:o,maxTables:s,now:a,request:l}=e,u=l.trim();if(u.length===0)throw new Error("Please enter a SQL generation request first.");let c=cot({activeSchema:t,dialect:r,introspection:i,maxColumnsPerTable:o,maxTables:s});return mot({requestAiSqlGeneration:n,buildRetryPrompt:({issues:d,responseText:h})=>dot({context:c,issues:d,now:a,request:u,responseText:h}),prompt:Yde({context:c,now:a,request:u})})}function fot(e,t){let n=Object.values(t.schemas),r=n.find(i=>i.name===e);return r?[r,...n.filter(i=>i.name!==e)]:n}function pot(e){let t=null,n=$de(e);try{t=JSON.parse(n)}catch(i){return{issues:[{code:"invalid-json",message:i instanceof Error?`AI response was not valid JSON: ${i.message}`:"AI response was not valid JSON.",responseText:e}],value:null}}if(t==null||typeof t!="object"||Array.isArray(t))return{issues:[{code:"invalid-response-shape",message:"AI response must be a JSON object.",responseText:e}],value:null};if(typeof t.sql!="string")return{issues:[{code:"missing-sql",message:'AI response must include a non-empty "sql" string.',responseText:e}],value:null};let r=t.sql.trim();return r.length===0?{issues:[{code:"missing-sql",message:'AI response must include a non-empty "sql" string.',responseText:e}],value:null}:{issues:[],value:{rationale:typeof t.rationale=="string"&&t.rationale.trim().length>0?t.rationale.trim():null,shouldGenerateVisualization:got(t.shouldGenerateVisualization),sql:r}}}async function mot(e){let{requestAiSqlGeneration:t,buildRetryPrompt:n,prompt:r}=e,i=await Kde({requestAiText:t,buildRetryPrompt:({issues:o,responseText:s})=>n({issues:o,responseText:s}),createRetryIssueFromError:({message:o,responseText:s})=>({code:"provider-output-limit",message:`AI response hit the provider output limit before finishing: ${o}`,responseText:s}),invalidResponseMessage:"AI response did not include valid SQL.",maxCorrectionRetries:1,parseResponse:pot,prompt:r});return{didRetry:i.didRetry,rationale:i.value.rationale,responseText:i.responseText,shouldGenerateVisualization:i.value.shouldGenerateVisualization,sql:i.value.sql}}function got(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="yes"||t==="y")return!0;if(t==="false"||t==="no"||t==="n")return!1}return!1}function yot(e){switch(e){case"mysql":return"MySQL";case"sqlite":return"SQLite";default:return"PostgreSQL"}}function vot(e){switch(e){case"mysql":return["Do not use PostgreSQL-only syntax like ILIKE or ::type casts."];case"sqlite":return["Do not use PostgreSQL schemas, PostgreSQL casts, or MySQL-only functions."];default:return["Do not use SQLite-only functions such as TYPEOF() or MySQL-only functions such as JSON_TYPE()."]}}function bot(e,t){return new Intl.DateTimeFormat("en-US",{dateStyle:"full",timeStyle:"long",timeZone:t}).format(e)}var wot=2,q3=["bar","bubble","doughnut","line","pie","polarArea","radar","scatter"];jd.register(_2);function Qde(e){let{aiQueryRequest:t,databaseEngine:n,querySql:r,rows:i}=e;return["Generate an appropriate chart for the following data using the Chart.js library. Use no external libraries.",`Database engine: ${n}`,`SQL: ${r}`,t?`AI query request: ${t}`:null,`Row count: ${i.length}`,"Full result rows JSON:",JSON.stringify(i),"Return JSON only. Do not add markdown fences or commentary.",'Return this exact top-level shape: {"config":{"type":"bar","data":{"labels":["A"],"datasets":[{"label":"Series","data":[1]}]},"options":{}}}',`Supported chart types: ${q3.join(", ")}`,"The config must be valid for new Chart(canvas, config).","Do not include functions, callbacks, plugins, dates, Maps, Sets, or references to external libraries.","Use plain JSON values only."].filter(o=>o!==null).join(`
`)}function xot(e){let{aiQueryRequest:t,databaseEngine:n,issues:r,querySql:i,responseText:o,rows:s}=e;return[Qde({aiQueryRequest:t,databaseEngine:n,querySql:i,rows:s}),"Your previous response was invalid.",`Previous response: ${o}`,"Problems to fix:",...r.map(a=>`- ${a.message}`),"Return corrected JSON only. Do not add markdown fences or commentary."].join(`
`)}async function Sot(e){let{requestAiVisualization:t,aiQueryRequest:n,databaseEngine:r,maxCorrectionRetries:i=wot,querySql:o,rows:s}=e,a=await Kde({requestAiText:t,buildRetryPrompt:({issues:l,responseText:u})=>xot({aiQueryRequest:n,databaseEngine:r,issues:l,querySql:o,responseText:u,rows:s}),createRetryIssueFromError:({message:l,responseText:u})=>({code:"provider-output-limit",message:`AI visualization response hit the provider output limit before finishing: ${l}`,responseText:u}),invalidResponseMessage:"AI visualization response did not contain a valid Chart.js config.",maxCorrectionRetries:i,parseResponse:Cot,prompt:Qde({aiQueryRequest:n,databaseEngine:r,querySql:o,rows:s})});return{config:a.value,didRetry:a.didRetry,responseText:a.responseText}}function kot(e,t){return new jd(e,{...t,options:{maintainAspectRatio:!1,...t.options}})}function Cot(e){let t=null,n=$de(e);try{t=JSON.parse(n)}catch(i){return{issues:[{code:"invalid-json",message:i instanceof Error?`AI visualization response was not valid JSON: ${i.message}`:"AI visualization response was not valid JSON.",responseText:e}],value:null}}let r=t?.config;return!r||typeof r!="object"||Array.isArray(r)?{issues:[{code:"invalid-config",message:'AI visualization response must include a "config" object.',responseText:e}],value:null}:Not(r.type)?!r.data||typeof r.data!="object"||Array.isArray(r.data)||!Array.isArray(r.data.datasets)?{issues:[{code:"invalid-data",message:'Chart config must include "data.datasets" as an array.',responseText:e}],value:null}:r.options!==void 0&&(typeof r.options!="object"||r.options===null||Array.isArray(r.options))?{issues:[{code:"invalid-options",message:'Chart config "options" must be a JSON object when present.',responseText:e}],value:null}:{issues:[],value:r}:{issues:[{code:"invalid-chart-type",message:`Chart type must be one of: ${q3.join(", ")}.`,responseText:e}],value:null}}function Not(e){return typeof e=="string"&&q3.includes(e)}function Mot(e){let{requestAiVisualization:t,aiQueryRequest:n,autoGenerate:r,databaseEngine:i,querySql:o,resetKey:s,rows:a}=e,l=(0,bl.useRef)(0),[u,c]=(0,bl.useState)({status:"idle"}),d=typeof t=="function"&&typeof o=="string",h=(0,bl.useCallback)(async()=>{if(!t||!o)return;let p=l.current+1;l.current=p,c({status:"loading"});try{let m=await Sot({requestAiVisualization:t,aiQueryRequest:n,databaseEngine:i,querySql:o,rows:a});if(l.current!==p)return;c({config:m.config,status:"ready"})}catch(m){if(l.current!==p)return;c({message:m instanceof Error?m.message:"AI visualization generation failed.",status:"error"})}},[n,i,o,t,a]),f=(0,bl.useCallback)(()=>{u.status==="idle"&&h()},[h,u.status]);return(0,bl.useEffect)(()=>{if(l.current+=1,!d){c(p=>p.status==="idle"?p:{status:"idle"});return}if(r){h();return}c(p=>p.status==="idle"?p:{status:"idle"})},[r,d,o,s,h]),{canGenerate:d,generateVisualization:f,state:u}}function _ot(e){let{className:t,config:n}=e,r=(0,bl.useRef)(null);return(0,bl.useEffect)(()=>{if(!r.current)return;let i=kot(r.current,n);return()=>{i.destroy()}},[n]),(0,fq.jsx)("div",{className:G("h-72 mx-auto w-[clamp(300px,calc(100cqw-2rem),1200px)] min-w-[300px] max-w-[1200px]",t),"data-testid":"sql-result-visualization-chart",children:(0,fq.jsx)("canvas",{ref:r})})}function Eot(e){let{lintSql:t,schemaVersion:n}=e,r={abortController:null,requestId:0};return{dispose(){r.abortController?.abort(),r.abortController=null},source:async i=>{let o=i.state.doc.toString();if(o.trim().length===0)return r.abortController?.abort(),r.abortController=null,[];r.abortController?.abort();let s=new AbortController;r.abortController=s;let a=r.requestId+1;r.requestId=a;let[l,u]=await t({schemaVersion:n,sql:o},{abortSignal:s.signal});return s.signal.aborted||r.requestId!==a?[]:l?[{from:0,message:l.message,severity:"warning",source:"studio",to:Math.min(1,o.length)}]:u.diagnostics.map(c=>Oot(c,o.length))}}}function Oot(e,t){if(t<=0)return{...e,from:0,to:0};let n=Math.max(t-1,0),r=_Q(e.from,0,n),i=_Q(Math.max(e.to,r+1),r+1,t);return{...e,from:r,to:i}}function _Q(e,t,n){return Math.min(n,Math.max(t,e))}var Tot="select * from ",Aot="Generate SQL with AI ...",Dot=20,hM="sql-editor:draft",fM="sql-editor:ai-prompt-history",Rot="prisma-studio-sql-editor-state-v1",Iot=250,Pot="sql:view:grid",Lot="__sql_result__",EQ="__sql_result__",Bot=[],OQ={pageIndex:0,pageSize:25},qot={id:"__ps_select",accessorKey:"__ps_select",enablePinning:!0,enableResizing:!1,enableSorting:!1,size:35,minSize:35,header({table:e}){return t=>(0,Et.jsx)(um,{...t,"aria-label":"Row selection spacer"})},cell({row:e}){return t=>(0,Et.jsx)(wa,{"data-select":"true",...t})}},zot=(0,Ge.memo)(function(e){let{isRunning:t,paginationState:n,pinnedColumnIds:r,result:i,rowSelectionState:o,setPaginationState:s,setPinnedColumnIds:a,setRowSelectionState:l,visualizationState:u}=e,c=(0,Ge.useMemo)(()=>i.rows,[i]),d=(0,Ge.useMemo)(()=>c.map((m,g)=>({...m,__ps_rowid:`sql-row-${g}`})),[c]),h=(0,Ge.useMemo)(()=>{let m=[],g=new Set;for(let y of c)for(let v of Object.keys(y))g.has(v)||(g.add(v),m.push(v));return m},[c]),f=(0,Ge.useMemo)(()=>{let m={};for(let g of h){let y=jot(c,g);m[g]=Wot(g,y)}return m},[h,c]),p=(0,Ge.useMemo)(()=>[...h.map(m=>{let g=f[m];return{accessorKey:m,enableSorting:!1,header({table:y,header:v}){return b=>(0,Et.jsx)(hq,{table:y,header:v,...b,children:(0,Et.jsx)(Hde,{header:v,column:g})})},id:m,meta:g,cell({cell:y}){return v=>(0,Et.jsx)(wa,{...v,withContextMenu:!1,children:C_({cell:y,column:g})})}}}),qot],[f,h]);return(0,Et.jsx)(Ude,{columnDefs:p,getBeforeHeaderRows:u.status==="ready"?m=>(0,Et.jsx)(Fy,{"data-testid":"sql-result-visualization-row",children:(0,Et.jsx)(um,{className:"h-auto p-0 align-top",colSpan:Math.max(m.getAllLeafColumns().length,1),children:(0,Et.jsx)("div",{className:"sticky left-0 box-border w-[100cqw] overflow-hidden border-b border-border bg-white px-4 pt-4 pb-5","data-testid":"sql-result-visualization-band",children:(0,Et.jsx)(_ot,{config:u.config})})})}):void 0,isFetching:t,isProcessing:!1,onPinnedColumnIdsChange:a,onPaginationChange:s,onRowSelectionChange:l,pageCount:void 0,paginationState:n,pinnedColumnIds:r,rowSelectionState:o,rows:d,selectionScopeKey:Pot})});function Fot(e){let{adapter:t,hasAiSql:n,isDarkMode:r,onEvent:i,requestLlm:o,sqlEditorStateCollection:s}=is(),{data:a}=Hh(),{schemaParam:l}=lo(),{pinnedColumnIds:u,setPinnedColumnIds:c}=nue(),d=Yot({sqlEditorStateCollection:s}),h=Qot({sqlEditorStateCollection:s}),f=(0,Ge.useRef)(null),p=(0,Ge.useRef)(null),m=(0,Ge.useRef)(null),g=(0,Ge.useRef)(()=>{}),y=(0,Ge.useRef)(d),[v,b]=(0,Ge.useState)(()=>d??Tot),w=(0,Ge.useRef)(!1),x=(0,Ge.useRef)(v),[S,k]=(0,Ge.useState)(!1),[C,N]=(0,Ge.useState)(""),[E,D]=(0,Ge.useState)(h),[q,z]=(0,Ge.useState)(null),[_,R]=(0,Ge.useState)(null),[T,B]=(0,Ge.useState)(null),[A,M]=(0,Ge.useState)(!1),[P,F]=(0,Ge.useState)(null),[I,V]=(0,Ge.useState)(null),[W,j]=(0,Ge.useState)(null),[X,$]=(0,Ge.useState)(0),[K,Q]=(0,Ge.useState)({}),[J,oe]=(0,Ge.useState)(OQ),be=(0,Ge.useRef)(E),Me=(0,Ge.useCallback)(he=>{if(y.current===he)return;let Ae=s.get(hM);if(!Ae){s.insert({id:hM,queryText:he}),y.current=he;return}if(Ae.queryText===he){y.current=he;return}s.update(hM,ge=>{ge.queryText=he}),y.current=he},[s]),Je=(0,Ge.useCallback)(he=>{let Ae=Got(be.current,he);if(!(Ae.length===be.current.length&&Ae.every((ge,Be)=>ge===be.current[Be]))){if(D(Ae),!s.get(fM)){s.insert({aiPromptHistory:Ae,id:fM});return}s.update(fM,ge=>{ge.aiPromptHistory=Ae})}},[s]),Ve=C.length===0&&q!=null?E[q]??null:null,Ct=(0,Ge.useCallback)(()=>{if(!Ve)return!1;(0,$B.flushSync)(()=>{N(Ve),z(null)});let he=m.current;if(he){let Ae=Ve.length;he.setSelectionRange(Ae,Ae)}return!0},[Ve]),He=(0,Ge.useCallback)(he=>{C.length>0||E.length===0||z(Ae=>Ae==null?he==="older"?0:E.length-1:he==="older"?(Ae+1)%E.length:(Ae-1+E.length)%E.length)},[C.length,E]);(0,Ge.useEffect)(()=>{x.current=v},[v]),(0,Ge.useEffect)(()=>{be.current=E},[E]),(0,Ge.useEffect)(()=>{if(!w.current||y.current===v)return;let he=window.setTimeout(()=>{Me(v)},Iot);return()=>{window.clearTimeout(he)}},[v,Me]),(0,Ge.useEffect)(()=>()=>{let he=p.current?.state.doc.toString()??x.current,Ae=he!==x.current;!w.current&&!Ae||Me(he)},[Me]);let de=(0,Ge.useMemo)(()=>tc({defaultSchema:t.defaultSchema,dialect:t.capabilities?.sqlDialect??"postgresql",introspection:a}),[t.capabilities?.sqlDialect,t.defaultSchema,a]),ie=(0,Ge.useMemo)(()=>sot(de.namespace),[de.namespace]),ze=(0,Ge.useMemo)(()=>oot(de.dialect),[de.dialect]),Le=(0,Ge.useMemo)(()=>wXe({defaultSchema:de.defaultSchema,dialect:ze,schema:ie}),[ze,ie,de.defaultSchema]),Oe=(0,Ge.useMemo)(()=>!t.capabilities?.sqlEditorLint||!$ot(t)?null:Eot({lintSql:(he,Ae)=>t.sqlLint(he,Ae),schemaVersion:de.version}),[t,de.version]);(0,Ge.useEffect)(()=>()=>{Oe?.dispose()},[Oe]);let rt=(0,Ge.useMemo)(()=>Oe?[VXe(),RXe(Oe.source,{delay:500})]:[],[Oe]),Ht=(0,Ge.useMemo)(()=>[Le,ke.lineWrapping,Xh.highest(w1.of(aot({runSql:()=>{g.current()}}))),...rt],[Le,rt]),$t=(0,Ge.useMemo)(()=>Kot(t.capabilities?.sqlDialect??"postgresql"),[t.capabilities?.sqlDialect]),dt=(0,Ge.useCallback)(async he=>await o({prompt:he,task:"sql-generation"}),[o]),et=(0,Ge.useCallback)(async he=>await o({prompt:he,task:"sql-visualization"}),[o]),pt=Mot({requestAiVisualization:n?et:void 0,aiQueryRequest:W?.aiQueryRequest??null,autoGenerate:W?.shouldAutoGenerateVisualization??!1,databaseEngine:$t,querySql:W?.querySql??null,resetKey:X,rows:W?.rows??Bot});async function nn(he){let Ae=he.sql.trim();if(Ae.length===0||S)return null;let ge=performance.now(),Be=new AbortController;f.current=Be,k(!0),V(null),$(ce=>ce+1);let[ye,De]=await t.raw({sql:Ae},{abortSignal:Be.signal}),gt=lA(Be.signal)??Math.round(performance.now()-ge);return f.current=null,k(!1),{aiQueryRequest:he.aiQueryRequest??null,durationMs:gt,error:ye??null,rawResult:De??null,shouldAutoGenerateVisualization:he.shouldAutoGenerateVisualization??!1}}function Dt(he,Ae){let{durationMs:ge,error:Be,rawResult:ye,shouldAutoGenerateVisualization:De}=he,{aiQueryRequest:gt}=he,ce=Ae?.reportEvents??!0;if(Be){let $e=Be.name==="AbortError",it=$e?"Query cancelled.":Be.message;V(it),$e||j(null),!$e&&ce&&i({name:"studio_operation_error",payload:{operation:"raw-query",query:Be.query,error:Be}});return}ye&&(j({aiQueryRequest:gt,durationMs:ge,querySql:ye.query.sql,rowCount:ye.rowCount,rows:ye.rows,shouldAutoGenerateVisualization:De}),Q({}),oe(OQ),V(null),ce&&i({name:"studio_operation_success",payload:{error:void 0,operation:"raw-query",query:ye.query}}))}async function Ot(he){let Ae=he?.sqlOverride??v,ge=Vot({pendingAiSqlExecution:P,sql:Ae}),Be=await nn({aiQueryRequest:ge.aiQueryRequest,shouldAutoGenerateVisualization:ge.shouldAutoGenerateVisualization,sql:Ae});Be&&Dt(Be)}function Kt(){let he=p.current,Ae=v.trim();return!he||Ae.length===0?Ae:AW({cursorIndex:he.state.selection.main.head,sql:v})?.statement??Ae}g.current=()=>{Ot({sqlOverride:Kt()})};function Er(){let he=f.current;he&&he.abort()}async function Dn(){if(!n||A)return;if(!a){R("Schema metadata is still loading. Try again in a moment.");return}let he=C.trim();if(he.length!==0){Je(he),z(null),M(!0),R(null),B(null),V(null),F(null),j(null);try{let Ae=await hot({activeSchema:l??t.defaultSchema??"public",requestAiSqlGeneration:dt,dialect:t.capabilities?.sqlDialect??"postgresql",introspection:a,request:he});(0,$B.flushSync)(()=>{w.current=!0,x.current=Ae.sql,b(Ae.sql),B(Ae.rationale),F({aiQueryRequest:he,shouldAutoGenerateVisualization:Ae.shouldGenerateVisualization,sql:Ae.sql})}),Zn(Ae.sql)}catch(Ae){R(Ae instanceof Error?Ae.message:"AI SQL generation failed.")}finally{M(!1)}}}function Zn(he){let Ae=p.current;if(!Ae)return;let ge=he.length;Ae.dispatch({selection:{anchor:ge,head:ge}}),Ae.focus()}let Un=(0,Et.jsxs)(zn,{onClick:()=>{if(S){Er();return}Ot({sqlOverride:Kt()})},disabled:!S&&v.trim().length===0,size:"sm",variant:S?"outline":"default",children:[S?(0,Et.jsx)(q5e,{className:"size-4"}):(0,Et.jsx)(_5e,{className:"size-4"}),S?"Cancel":"Run SQL"]});return(0,Et.jsxs)("div",{className:"flex flex-1 min-h-0 flex-col h-full overflow-hidden",children:[(0,Et.jsx)(f1,{endContent:Un,children:n?(0,Et.jsxs)("div",{className:"flex min-w-0 grow items-center gap-2",children:[(0,Et.jsx)(Fi,{"aria-label":"Generate SQL with AI",className:"min-w-0 grow",disabled:A,onMouseDown:()=>{Ct()},onChange:he=>{z(null),N(he.currentTarget.value)},onKeyDown:he=>{if(he.key==="ArrowUp"||he.key==="ArrowDown"){C.length===0&&E.length>0&&(he.preventDefault(),He(he.key==="ArrowUp"?"older":"newer"));return}if(Ve){if(Xot(he.key))return;if(Ct()&&he.key==="Enter"){he.preventDefault();return}}he.key==="Enter"&&(he.preventDefault(),Dn())},placeholder:Ve??Aot,ref:m,value:C}),(0,Et.jsxs)(zn,{disabled:C.trim().length===0||A,onClick:()=>{Dn()},size:"sm",variant:"outline",children:[A?(0,Et.jsx)(jP,{className:"size-4 animate-spin"}):(0,Et.jsx)(c9,{className:"size-4"}),"Generate SQL"]})]}):null}),(0,Et.jsxs)("div",{className:"flex flex-col gap-3 p-3 border-b border-border bg-background",children:[(0,Et.jsx)("div",{className:"rounded-md border border-border overflow-hidden bg-background",children:(0,Et.jsx)(XZe,{"aria-label":"SQL editor",basicSetup:{foldGutter:!1},className:["[&_.cm-editor]:!border-0 [&_.cm-editor]:font-mono","[&_.cm-gutters]:border-r [&_.cm-gutters]:border-border [&_.cm-gutters]:bg-muted/30","[&_.cm-line]:text-[15px] [&_.cm-scroller]:font-mono"].join(" "),extensions:Ht,minHeight:"128px",onCreateEditor:he=>{p.current=he;let Ae=he.state.doc.length;he.dispatch({selection:{anchor:Ae,head:Ae}}),he.focus()},onChange:he=>{w.current=!0,x.current=he,b(he)},placeholder:"Write SQL...",theme:r?"dark":"light",value:v})}),_?(0,Et.jsxs)("div",{className:"text-sm text-destructive",children:[(0,Et.jsx)("strong",{children:"AI SQL generation error:"})," ",_]}):null,T?(0,Et.jsxs)("div",{className:"text-xs text-muted-foreground",children:[(0,Et.jsx)("strong",{children:"AI rationale:"})," ",T]}):null,I?(0,Et.jsxs)("div",{className:"text-sm text-destructive",children:[(0,Et.jsx)("strong",{children:"Query error:"})," ",I]}):null,W?(0,Et.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs text-muted-foreground","data-testid":"sql-result-summary",children:[(0,Et.jsxs)("div",{children:[W.rowCount," row(s) returned in ",W.durationMs,"ms"]}),n?(0,Et.jsxs)("div",{className:"flex min-w-0 items-center justify-end",children:[pt.state.status==="idle"&&pt.canGenerate?(0,Et.jsxs)(zn,{className:"h-auto rounded-none px-0 py-0 text-xs text-muted-foreground shadow-none hover:bg-transparent hover:text-foreground","data-testid":"sql-result-visualization-action",onClick:pt.generateVisualization,size:"sm",variant:"ghost",children:[(0,Et.jsx)(c9,{"data-icon":"inline-start"}),"Visualize data with AI"]}):null,pt.state.status==="loading"?(0,Et.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground","data-testid":"sql-result-visualization-action",children:[(0,Et.jsx)(jP,{className:"size-4 animate-spin"}),"Generating graph..."]}):null,pt.state.status==="error"?(0,Et.jsx)("div",{className:"max-w-[32rem] text-right text-xs text-destructive","data-testid":"sql-result-visualization-action",children:pt.state.message}):null]}):null]}):null]}),(0,Et.jsx)("div",{"data-testid":"sql-result-grid-container",className:"grow min-h-0 flex flex-col",children:W==null?null:(0,Et.jsx)(zot,{isRunning:S,paginationState:J,pinnedColumnIds:u,result:W,rowSelectionState:K,setPaginationState:oe,setPinnedColumnIds:c,setRowSelectionState:Q,visualizationState:pt.state})})]})}function jot(e,t){for(let n of e){let r=n[t];if(r!=null)return r}}function Vot(e){let{pendingAiSqlExecution:t}=e,n=TQ(e.sql);return!t||n.length===0?{aiQueryRequest:null,shouldAutoGenerateVisualization:!1}:TQ(t.sql)!==n?{aiQueryRequest:null,shouldAutoGenerateVisualization:!1}:{aiQueryRequest:t.aiQueryRequest,shouldAutoGenerateVisualization:t.shouldAutoGenerateVisualization}}function TQ(e){return e.trim().replace(/;+$/,"")}function Wot(e,t){let n=Array.isArray(t),r=Uot(t),i=Hot(t);return{datatype:{affinity:i,format:void 0,group:r,isArray:n,isNative:!1,name:i,options:[],schema:EQ},defaultValue:null,fkColumn:null,fkSchema:null,fkTable:null,isAutoincrement:!1,isComputed:!1,isRequired:!1,name:e,nullable:!0,pkPosition:null,schema:EQ,table:Lot}}function Uot(e){if(Array.isArray(e))return"json";if(e instanceof Date)return"datetime";switch(typeof e){case"bigint":case"number":return"numeric";case"boolean":return"boolean";case"string":return"string";case"object":return"json";default:return"raw"}}function Hot(e){if(Array.isArray(e))return"array";if(e instanceof Date)return"timestamp";switch(typeof e){case"bigint":return"bigint";case"number":return"numeric";case"boolean":return"boolean";case"string":return"text";case"object":return"json";case"undefined":return"unknown";default:return"raw"}}function $ot(e){return typeof e.sqlLint=="function"}function Kot(e){switch(e){case"mysql":return"MySQL";case"sqlite":return"SQLite";default:return"PostgreSQL"}}function Yot(e){let t=Gde({rowId:hM,sqlEditorStateCollection:e.sqlEditorStateCollection})?.queryText;return typeof t=="string"?t:null}function Qot(e){let t=Gde({rowId:fM,sqlEditorStateCollection:e.sqlEditorStateCollection});return pq(t?.aiPromptHistory)}function Gde(e){let{rowId:t,sqlEditorStateCollection:n}=e,r=n.get(t);if(r!=null)return r;if(typeof window>"u")return null;let i=window.localStorage.getItem(Rot);if(!i)return null;try{let o=JSON.parse(i);if(typeof o!="object"||o==null||Array.isArray(o))return null;let s=o[`s:${t}`];if(typeof s!="object"||s==null)return null;let a=s.data;return typeof a!="object"||a==null?null:a}catch{return null}}function pq(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(typeof r!="string")continue;let i=r.trim();if(!(i.length===0||n.has(i))&&(n.add(i),t.push(i),t.length>=Dot))break}return t}function Got(e,t){let n=t.trim();return n.length===0?pq(e):pq([n,...e])}function Xot(e){return e==="Alt"||e==="CapsLock"||e==="Control"||e==="Meta"||e==="Shift"}var Jde="AlertDialog",[Jot,ovt]=os(Jde,[Mee]),Yc=Mee(),Zde=e=>{let{__scopeAlertDialog:t,...n}=e,r=Yc(t);return(0,Do.jsx)(zz,{...r,...n,modal:!0})};Zde.displayName=Jde;var Zot="AlertDialogTrigger",est=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Yc(n);return(0,Do.jsx)(EFe,{...i,...r,ref:t})});est.displayName=Zot;var tst="AlertDialogPortal",ehe=e=>{let{__scopeAlertDialog:t,...n}=e,r=Yc(t);return(0,Do.jsx)(Fz,{...r,...n})};ehe.displayName=tst;var nst="AlertDialogOverlay",the=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Yc(n);return(0,Do.jsx)(sE,{...i,...r,ref:t})});the.displayName=nst;var Vy="AlertDialogContent",[rst,ist]=Jot(Vy),ost=tee("AlertDialogContent"),nhe=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,o=Yc(n),s=zs.useRef(null),a=qt(t,s),l=zs.useRef(null);return(0,Do.jsx)(CFe,{contentName:Vy,titleName:rhe,docsSlug:"alert-dialog",children:(0,Do.jsx)(rst,{scope:n,cancelRef:l,children:(0,Do.jsxs)(aE,{role:"alertdialog",...o,...i,ref:a,onOpenAutoFocus:xe(i.onOpenAutoFocus,u=>{u.preventDefault(),l.current?.focus({preventScroll:!0})}),onPointerDownOutside:u=>u.preventDefault(),onInteractOutside:u=>u.preventDefault(),children:[(0,Do.jsx)(ost,{children:r}),(0,Do.jsx)(ast,{contentRef:s})]})})})});nhe.displayName=Vy;var rhe="AlertDialogTitle",ihe=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Yc(n);return(0,Do.jsx)(jz,{...i,...r,ref:t})});ihe.displayName=rhe;var ohe="AlertDialogDescription",she=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Yc(n);return(0,Do.jsx)(Vz,{...i,...r,ref:t})});she.displayName=ohe;var sst="AlertDialogAction",ahe=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Yc(n);return(0,Do.jsx)(Wz,{...i,...r,ref:t})});ahe.displayName=sst;var lhe="AlertDialogCancel",uhe=zs.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=ist(lhe,n),o=Yc(n),s=qt(t,i);return(0,Do.jsx)(Wz,{...o,...r,ref:s})});uhe.displayName=lhe;var ast=({contentRef:e})=>{let t=`\`${Vy}\` requires a description for the component to be accessible for screen reader users.
You can add a description to the \`${Vy}\` by passing a \`${ohe}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Vy}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return zs.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},lst=Zde,ust=ehe,che=the,dhe=nhe,hhe=ahe,fhe=uhe,phe=ihe,mhe=she,cst=lst,dst=ust,ghe=xm.forwardRef(({className:e,...t},n)=>(0,Io.jsx)(che,{ref:n,className:G("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",e),...t}));ghe.displayName=che.displayName;var yhe=xm.forwardRef(({className:e,...t},n)=>(0,Io.jsx)(dst,{children:(0,Io.jsxs)("div",{className:"ps",children:[(0,Io.jsx)(ghe,{}),(0,Io.jsx)(dhe,{ref:n,className:G("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-border bg-card p-6 text-card-foreground shadow-2xl ring-1 ring-border/50 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%] sm:rounded-lg",e),...t})]})}));yhe.displayName=dhe.displayName;var vhe=({className:e,...t})=>(0,Io.jsx)("div",{className:G("flex flex-col gap-1.5 text-center sm:text-left",e),...t});vhe.displayName="AlertDialogHeader";var bhe=({className:e,...t})=>(0,Io.jsx)("div",{className:G("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t});bhe.displayName="AlertDialogFooter";var whe=xm.forwardRef(({className:e,...t},n)=>(0,Io.jsx)(phe,{ref:n,className:G("text-lg font-semibold leading-none tracking-tight",e),...t}));whe.displayName=phe.displayName;var xhe=xm.forwardRef(({className:e,...t},n)=>(0,Io.jsx)(mhe,{ref:n,className:G("text-sm text-muted-foreground",e),...t}));xhe.displayName=mhe.displayName;var She=xm.forwardRef(({className:e,size:t,variant:n,...r},i)=>(0,Io.jsx)(zn,{asChild:!0,size:t,variant:n,children:(0,Io.jsx)(hhe,{ref:i,className:G("focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background",e),...r})}));She.displayName=hhe.displayName;var khe=xm.forwardRef(({className:e,size:t,variant:n="outline",...r},i)=>(0,Io.jsx)(zn,{asChild:!0,size:t,variant:n,children:(0,Io.jsx)(fhe,{ref:i,className:G("focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background",e),...r})}));khe.displayName=fhe.displayName;var nf=class extends rs{constructor(e){super(e),this.name="QueryCollectionError"}},hst=class extends nf{constructor(){super("[QueryCollection] queryKey must be provided."),this.name="QueryKeyRequiredError"}},fst=class extends nf{constructor(){super("[QueryCollection] queryFn must be provided."),this.name="QueryFnRequiredError"}},pst=class extends nf{constructor(){super("[QueryCollection] queryClient must be provided."),this.name="QueryClientRequiredError"}},mst=class extends nf{constructor(){super("[QueryCollection] getKey must be provided."),this.name="GetKeyRequiredError"}},gst=class extends nf{constructor(){super("Collection must be in 'ready' state for manual sync operations. Sync not initialized yet."),this.name="SyncNotInitializedError"}},yst=class extends nf{constructor(e){super(`Duplicate key '${e}' found within batch operations`),this.name="DuplicateKeyInBatchError"}},vst=class extends nf{constructor(e){super(`Update operation: Item with key '${e}' does not exist`),this.name="UpdateOperationItemNotFoundError"}},bst=class extends nf{constructor(e){super(`Delete operation: Item with key '${e}' does not exist`),this.name="DeleteOperationItemNotFoundError"}},cp=new WeakMap;function wst(e,t){let n=Array.isArray(e)?e:[e],r=[];for(let i of n)if(i.type==="delete"){let o=Array.isArray(i.key)?i.key:[i.key];for(let s of o)r.push({type:"delete",key:s})}else{let o=Array.isArray(i.data)?i.data:[i.data];for(let s of o){let a;if(i.type==="update")a=t.getKey(s);else{let l=t.collection.validateData(s,i.type==="upsert"?"insert":i.type);a=t.getKey(l)}r.push({type:i.type,key:a,data:s})}}return r}function xst(e,t){let n=new Set;for(let r of e){if(n.has(r.key))throw new yst(r.key);if(n.add(r.key),r.type==="update"){if(!t.collection._state.syncedData.has(r.key))throw new vst(r.key)}else if(r.type==="delete"&&!t.collection._state.syncedData.has(r.key))throw new bst(r.key)}}function Zb(e,t){let n=wst(e,t);xst(n,t),t.begin({immediate:!0});for(let i of n)switch(i.type){case"insert":{let o=t.collection.validateData(i.data,"insert");t.write({type:"insert",value:o});break}case"update":{let o={...t.collection._state.syncedData.get(i.key),...i.data},s=t.collection.validateData(o,"update",i.key);t.write({type:"update",value:s});break}case"delete":{let o=t.collection._state.syncedData.get(i.key);t.write({type:"delete",value:o});break}case"upsert":{let o=t.collection._state.syncedData.has(i.key),s=t.collection.validateData(i.data,o?"update":"insert",i.key);o?t.write({type:"update",value:s}):t.write({type:"insert",value:s});break}}t.commit();let r=Array.from(t.collection._state.syncedData.values());t.updateCacheData?t.updateCacheData(r):t.queryClient.setQueryData(t.queryKey,r)}function Sst(e){function t(){let n=e();if(!n)throw new gst;return n}return{writeInsert(n){let r={type:"insert",data:n},i=t(),o=cp.get(i);if(o?.isActive){o.operations.push(r);return}Zb(r,i)},writeUpdate(n){let r={type:"update",data:n},i=t(),o=cp.get(i);if(o?.isActive){o.operations.push(r);return}Zb(r,i)},writeDelete(n){let r={type:"delete",key:n},i=t(),o=cp.get(i);if(o?.isActive){o.operations.push(r);return}Zb(r,i)},writeUpsert(n){let r={type:"upsert",data:n},i=t(),o=cp.get(i);if(o?.isActive){o.operations.push(r);return}Zb(r,i)},writeBatch(n){let r=t();if(cp.get(r)?.isActive)throw new Error("Cannot nest writeBatch calls. Complete the current batch before starting a new one.");let i={operations:[],isActive:!0};cp.set(r,i);try{let o=n();if(o&&typeof o=="object"&&"then"in o&&typeof o.then=="function")throw new Error("writeBatch does not support async callbacks. The callback must be synchronous.");i.operations.length>0&&Zb(i.operations,r)}finally{i.isActive=!1,cp.delete(r)}}}}function kst(e){if(!e)return;let t={};return e.where&&(t.where=mq(e.where)),e.orderBy?.length&&(t.orderBy=e.orderBy.map(n=>{let r={expression:mq(n.expression),direction:n.compareOptions.direction,nulls:n.compareOptions.nulls,stringSort:n.compareOptions.stringSort};return n.compareOptions.stringSort==="locale"?{...r,locale:n.compareOptions.locale,localeOptions:n.compareOptions.localeOptions}:r})),e.limit!==void 0&&(t.limit=e.limit),e.offset!==void 0&&(t.offset=e.offset),Object.keys(t).length===0?void 0:JSON.stringify(t)}function mq(e){if(!e)return null;switch(e.type){case"val":return{type:"val",value:gq(e.value)};case"ref":return{type:"ref",path:[...e.path]};case"func":return{type:"func",name:e.name,args:e.args.map(t=>mq(t))};default:return null}}function gq(e){if(e===void 0)return{__type:"undefined"};if(typeof e=="number"){if(Number.isNaN(e))return{__type:"nan"};if(e===Number.POSITIVE_INFINITY)return{__type:"infinity",sign:1};if(e===Number.NEGATIVE_INFINITY)return{__type:"infinity",sign:-1}}return e===null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"?e:e instanceof Date?{__type:"date",value:e.toJSON()}:Array.isArray(e)?e.map(t=>gq(t)):typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,gq(n)])):e}var Cst=class{constructor(e,t,n){this.state=e,this.refetchFn=t,this.refetch=t,this.writeInsert=n.writeInsert,this.writeUpdate=n.writeUpdate,this.writeDelete=n.writeDelete,this.writeUpsert=n.writeUpsert,this.writeBatch=n.writeBatch}async clearError(){this.state.lastError=void 0,this.state.errorCount=0,this.state.lastErrorUpdatedAt=0,await this.refetchFn({throwOnError:!0})}get lastError(){return this.state.lastError}get isError(){return!!this.state.lastError}get errorCount(){return this.state.errorCount}get isFetching(){return Array.from(this.state.observers.values()).some(e=>e.getCurrentResult().isFetching)}get isRefetching(){return Array.from(this.state.observers.values()).some(e=>e.getCurrentResult().isRefetching)}get isLoading(){return Array.from(this.state.observers.values()).some(e=>e.getCurrentResult().isLoading)}get dataUpdatedAt(){return Math.max(0,...Array.from(this.state.observers.values()).map(e=>e.getCurrentResult().dataUpdatedAt))}get fetchStatus(){return Array.from(this.state.observers.values()).map(e=>e.getCurrentResult().fetchStatus)}};function Nst(e){let{queryKey:t,queryFn:n,select:r,queryClient:i,enabled:o,refetchInterval:s,retry:a,retryDelay:l,staleTime:u,getKey:c,onInsert:d,onUpdate:h,onDelete:f,meta:p,...m}=e,g=m.syncMode??"eager";if(!t)throw new hst;if(!n)throw new fst;if(!i)throw new pst;if(!c)throw new mst;let y={lastError:void 0,errorCount:0,lastErrorUpdatedAt:0,observers:new Map},v=new Map,b=new Map,w=new Map,x=new Map,S=new Map,k=(P,F)=>{let I=w.get(P)||new Set;I.add(F),w.set(P,I);let V=b.get(F)||new Set;V.add(P),b.set(F,V)},C=(P,F)=>{let I=w.get(P)||new Set;I.delete(F),w.set(P,I);let V=b.get(F)||new Set;return V.delete(P),b.set(F,V),I.size===0},N=P=>{let{begin:F,write:I,commit:V,markReady:W,collection:j}=P,X=!1,$=ie=>{if(typeof t=="function")return t(ie);if(g==="on-demand"){let ze=kst(ie);return ze!==void 0?[...t,ze]:t}else return t},K=(ie={},ze=n)=>{let Le=$(ie),Oe=il(Le),rt={...p,loadSubsetOptions:ie};if(y.observers.has(Oe)){S.set(Oe,(S.get(Oe)||0)+1);let et=y.observers.get(Oe),pt=et.getCurrentResult();return pt.isSuccess?!0:pt.isError?Promise.reject(pt.error):i.getQueryData(Le)!==void 0?!0:new Promise((nn,Dt)=>{let Ot=et.subscribe(Kt=>{queueMicrotask(()=>{Kt.isSuccess?(Ot(),nn()):Kt.isError&&(Ot(),Dt(Kt.error))})})})}let Ht={queryKey:Le,queryFn:ze,meta:rt,structuralSharing:!0,notifyOnChangeProps:"all",...o!==void 0&&{enabled:o},...s!==void 0&&{refetchInterval:s},...a!==void 0&&{retry:a},...l!==void 0&&{retryDelay:l},...u!==void 0&&{staleTime:u}},$t=new yJ(i,Ht);if(v.set(Oe,Le),y.observers.set(Oe,$t),S.set(Oe,(S.get(Oe)||0)+1),i.getQueryData(Le)!==void 0)return(X||j.subscriberCount>0)&&oe($t,Oe),!0;let dt=new Promise((et,pt)=>{let nn=$t.subscribe(Dt=>{queueMicrotask(()=>{Dt.isSuccess?(nn(),et()):Dt.isError&&(nn(),pt(Dt.error))})})});return(X||j.subscriberCount>0)&&oe($t,Oe),dt},Q=ie=>{let ze=il(ie);return Le=>{if(Le.isSuccess){y.lastError=void 0,y.errorCount=0;let Oe=Le.data,rt=r?r(Oe):Oe;if(!Array.isArray(rt)||rt.some(dt=>typeof dt!="object")){let dt=r?`@tanstack/query-db-collection: select() must return an array of objects. Got: ${typeof rt} for queryKey ${JSON.stringify(ie)}`:`@tanstack/query-db-collection: queryFn must return an array of objects. Got: ${typeof rt} for queryKey ${JSON.stringify(ie)}`;console.error(dt);return}let Ht=new Map(j._state.syncedData.entries()),$t=new Map;rt.forEach(dt=>{let et=c(dt);$t.set(et,dt)}),F(),Ht.forEach((dt,et)=>{let pt=$t.get(et);pt?ol(dt,pt)||I({type:"update",value:pt}):C(et,ze)&&I({type:"delete",value:dt})}),$t.forEach((dt,et)=>{k(et,ze),Ht.has(et)||I({type:"insert",value:dt})}),V(),W()}else Le.isError&&((Le.errorUpdatedAt!==y.lastErrorUpdatedAt||Le.error!==y.lastError)&&(y.lastError=Le.error,y.errorCount++,y.lastErrorUpdatedAt=Le.errorUpdatedAt),console.error(`[QueryCollection] Error observing query ${String(ie)}:`,Le.error),W())}},J=ie=>x.has(ie),oe=(ie,ze)=>{if(!J(ze)){let Le=v.get(ze),Oe=Q(Le),rt=ie.subscribe(Oe);x.set(ze,rt);let Ht=ie.getCurrentResult();(Ht.isSuccess||Ht.isError)&&Oe(Ht)}},be=()=>{y.observers.forEach(oe)},Me=()=>{x.forEach(ie=>{ie()}),x.clear()};X=!0;let Je=j.on("subscribers:change",({subscriberCount:ie})=>{ie>0?be():ie===0&&Me()});if(g==="eager"){let ie=K({});ie instanceof Promise&&ie.catch(()=>{})}else W();be(),y.observers.forEach((ie,ze)=>{let Le=v.get(ze);Q(Le)(ie.getCurrentResult())});let Ve=ie=>{x.get(ie)?.(),x.delete(ie);let ze=b.get(ie)??new Set,Le=[];ze.forEach(Oe=>{let rt=w.get(Oe);rt&&(rt.delete(ie),rt.size===0&&(w.delete(Oe),j.has(Oe)&&Le.push(j.get(Oe))))}),Le.length>0&&(F(),Le.forEach(Oe=>{I({type:"delete",value:Oe})}),V()),y.observers.delete(ie),b.delete(ie),v.delete(ie),S.delete(ie)},Ct=ie=>{let ze=S.get(ie)||0,Le=y.observers.get(ie);if(ze<=0&&(x.get(ie)?.(),x.delete(ie)),Le?.hasListeners()??!1){S.set(ie,0);return}ze>0&&console.warn(`[cleanupQueryIfIdle] Invariant violation: refcount=${ze} but no listeners. Cleaning up to prevent leak.`,{hashedQueryKey:ie}),Ve(ie)},He=ie=>{Ve(ie)},de=i.getQueryCache().subscribe(ie=>{let ze=ie.query.queryHash;ie.type==="removed"&&v.has(ze)&&Ct(ze)});return{loadSubset:g==="eager"?void 0:K,unloadSubset:g==="eager"?void 0:ie=>{let ze=$(ie),Le=il(ze),Oe=(S.get(Le)||0)-1;Oe<=0?(S.set(Le,0),Ct(Le)):S.set(Le,Oe)},cleanup:async()=>{Je(),Me();let ie=[...v.values()],ze=[...y.observers.keys()];for(let Le of ze)He(Le);de(),await Promise.all(ie.map(async Le=>{await i.cancelQueries({queryKey:Le,exact:!0}),i.removeQueries({queryKey:Le,exact:!0})}))}}},E=async P=>{let F=[...v.values()].map(I=>y.observers.get(il(I)).refetch({throwOnError:P?.throwOnError}));return Promise.all(F)},D=(P,F)=>{r?i.setQueryData(P,I=>{if(!I||typeof I!="object")return I;if(Array.isArray(I))return F;let V=r(I);if(Array.isArray(V)){for(let W of Object.keys(I))if(I[W]===V)return{...I,[W]:F}}if(Array.isArray(I.data))return{...I,data:F};if(Array.isArray(I.items))return{...I,items:F};if(Array.isArray(I.results))return{...I,results:F};for(let W of Object.keys(I))if(Array.isArray(I[W]))return{...I,[W]:F};return I}):i.setQueryData(P,F)},q=P=>{let F=Array.from(v.values());if(F.length>0)for(let I of F)D(I,P);else{let I=typeof t=="function"?t({}):t;D(I,P)}},z=null,_=P=>{let{begin:F,write:I,commit:V,collection:W}=P,j=typeof t=="function"?t({}):t;return z={collection:W,queryClient:i,queryKey:j,getKey:c,begin:F,write:I,commit:V,updateCacheData:q},N(P)},R=Sst(()=>z),T=d?async P=>{let F=await d(P)??{};return F.refetch!==!1&&await E(),F}:void 0,B=h?async P=>{let F=await h(P)??{};return F.refetch!==!1&&await E(),F}:void 0,A=f?async P=>{let F=await f(P)??{};return F.refetch!==!1&&await E(),F}:void 0,M=new Cst(y,E,R);return{...m,getKey:c,syncMode:g,sync:{sync:_},onInsert:T,onUpdate:B,onDelete:A,utils:M}}function Mst(e,t){let n={filter:Ck(e,t.columns),table:`${t.schema}.${t.name}`};return JSON.stringify(n)}function AQ(e){let{row:t,table:n,orderIndex:r}=e;return{...t,__ps_rowid:Mst(t,n),...r==null?{}:{__ps_order:r}}}function z3(e,t){let{row:n,rows:r}=e;return n!==void 0?{...e,row:AQ({row:n,table:t})}:r!==void 0?{...e,rows:r.map((i,o)=>AQ({row:i,table:t,orderIndex:o}))}:e}function DQ(e){let{activeTable:t,rows:n,writeUpdate:r}=e;for(let i of n)r(z3({row:i},t).row)}function _st(e,t){let n=typeof e.__ps_order=="number"?e.__ps_order:1/0,r=typeof t.__ps_order=="number"?t.__ps_order:1/0;if(n!==r)return n-r;let i=String(e.__ps_rowid??""),o=String(t.__ps_rowid??"");return i.localeCompare(o)}function Che(e){return e.map(t=>`${t.column}:${t.direction}`).join(",")}function F3(e){return JSON.stringify(e)}function Est(e,t){if(!e)return"";let{filter:n,fullTableSearchTerm:r,pageIndex:i,pageSize:o,sortOrder:s}=t;return[e.schema,e.name,String(i),String(o),Che(s),F3(n),r??""].join("::")}function Ost(e,t){return e?[e.schema,e.name,F3(t.filter),t.fullTableSearchTerm??""].join("::"):""}function Tst(e,t,n){let r=n.get(e);if(!r){n.insert({id:e,filteredRowCount:t});return}r.filteredRowCount!==t&&n.update(e,i=>{i.filteredRowCount=t})}function uO(e){let{filter:t,fullTableSearchTerm:n,pageIndex:r,pageSize:i,sortOrder:o}=e,s=is(),{adapter:a,onEvent:l,queryClient:u,tableQueryMetaCollection:c}=s,{metadata:{activeTable:d}}=lo(),h=(0,yc.useMemo)(()=>Che(o),[o]),f=(0,yc.useMemo)(()=>`${F3(t)}::${n??""}`,[t,n]),p=(0,yc.useMemo)(()=>Est(d,{fullTableSearchTerm:n,pageIndex:r,pageSize:i,sortOrder:o,filter:t}),[d,t,n,r,i,o]),m=(0,yc.useMemo)(()=>Ost(d,{filter:t,fullTableSearchTerm:n}),[d,t,n]),g=(0,yc.useMemo)(()=>d?["schema",d.schema,"table",d.name,"query","sortOrder",h||"natural","pageIndex",r,"pageSize",i,"filter",f]:null,[d,f,r,i,h]),y=(0,yc.useMemo)(()=>!d||!p?null:s.getOrCreateRowsCollection(p,()=>tu(Nst({compare:_st,gcTime:0,id:`rows:${p}`,getKey(k){return String(k.__ps_rowid)},onDelete:async({transaction:k})=>{let C=k.mutations.map(D=>D.original);if(C.length===0)return;let[N,E]=await a.delete({rows:C,table:d},{});if(N)throw l({name:"studio_operation_error",payload:{operation:"delete",query:N.query,error:N}}),N;l({name:"studio_operation_success",payload:{operation:"delete",query:E.query,error:void 0}})},onUpdate:async({collection:k,transaction:C})=>{if(C.mutations.length>1&&typeof a.updateMany=="function"){let[N,E]=await a.updateMany({table:d,updates:C.mutations.map(D=>({changes:D.changes,row:D.original,table:d}))},{});if(N)throw l({name:"studio_operation_error",payload:{operation:"update",query:N.query,error:N}}),N;for(let D of E.queries)l({name:"studio_operation_success",payload:{operation:"update",query:D,error:void 0}});DQ({activeTable:d,writeUpdate:k.utils.writeUpdate,rows:E.rows});return}for(let N of C.mutations){let[E,D]=await a.update({changes:N.changes,row:N.original,table:d},{});if(E)throw l({name:"studio_operation_error",payload:{operation:"update",query:E.query,error:E}}),E;l({name:"studio_operation_success",payload:{operation:"update",query:D.query,error:void 0}}),DQ({activeTable:d,writeUpdate:k.utils.writeUpdate,rows:[D.row]})}},queryClient:u,queryFn:async({signal:k})=>{let[C,N]=await a.query({pageIndex:r,pageSize:i,sortOrder:o,table:d,filter:t,fullTableSearchTerm:n},{abortSignal:k});if(C)throw l({name:"studio_operation_error",payload:{operation:"query",query:C.query,error:C}}),C;return l({name:"studio_operation_success",payload:{operation:"query",query:N.query,error:void 0}}),Tst(m,N.filteredRowCount,c),z3(N,d).rows},queryKey:()=>["schema",d.schema,"table",d.name,"query","sortOrder",h||"natural","pageIndex",r,"pageSize",i,"filter",f],retry:!1,staleTime:1/0}))),[d,a,t,f,n,l,r,i,u,m,p,h,o,s,c]),{data:v=[],isLoading:b}=Xy(k=>{if(y)return k.from({row:y}).orderBy(({row:C})=>C.__ps_order,{direction:"asc",nulls:"last"}).orderBy(({row:C})=>C.__ps_rowid).fn.select(C=>C.row)},[y]),w=bDe(g?{queryKey:g,exact:!0}:void 0,u),x=c.get(m)?.filteredRowCount??1/0,S=(0,yc.useCallback)(async()=>{y&&await y.utils.refetch({throwOnError:!0})},[y]);return{activeTable:d,collection:y,rows:v,filteredRowCount:x,isFetching:b||w>0,refetch:S,queryScopeKey:p}}function MI(e,t){return{id:e,editingFilter:uBe(t?.editingFilter??lZ(sZ())),rowSelectionState:{...t?.rowSelectionState??{}},stagedRows:[...t?.stagedRows??[]],stagedUpdates:[...t?.stagedUpdates??[]]}}function Ast(e){return e?`${e.schema}.${e.name}`:""}function j3(e){let{tableUiStateCollection:t}=is(),{metadata:{activeTable:n}}=lo(),r=(0,jv.useMemo)(()=>Ast(n),[n]),{data:i}=Xy(a=>{if(r)return a.from({item:t}).where(({item:l})=>Qy(l.id,r)).select(({item:l})=>({id:l.id,editingFilter:l.editingFilter,rowSelectionState:l.rowSelectionState,stagedRows:l.stagedRows,stagedUpdates:l.stagedUpdates})).findOne()},[r,t]);(0,jv.useEffect)(()=>{!r||t.has(r)||t.insert(MI(r,e))},[e,r,t]);let o=!r||i?i:MI(r,e),s=(0,jv.useCallback)(a=>{if(r){if(!t.has(r)){let l=MI(r,e);a(l),t.insert(l);return}t.update(r,a)}},[e,r,t]);return{scopeKey:r,tableUiState:o,updateTableUiState:s}}function Dst(e){try{return JSON.parse(e)}catch(t){return console.error("Failed to parse filter param",t),aZ}}function cO(e){let{filterParam:t,setFilterParam:n}=lo(),r=(0,Rs.useMemo)(()=>Dst(t),[t]),i=(0,Rs.useMemo)(()=>JSON.stringify(r),[r]),o=(0,Rs.useMemo)(()=>lZ(r),[r]),s=(0,Rs.useCallback)(g=>{n(JSON.stringify(g))},[n]),{scopeKey:a,tableUiState:l,updateTableUiState:u}=j3({editingFilter:o}),c=l?.editingFilter??o,d=`${a}:${i}`,h=(0,Rs.useRef)(d),f=(0,Rs.useCallback)(g=>{u(y=>{y.editingFilter=g})},[u]),p=(0,Rs.useCallback)((g=c)=>{s(dZ(g,e))},[e,c,s]);(0,Rs.useEffect)(()=>{h.current!==d&&(h.current=d,f(mBe({currentFilter:o,previousFilter:c})))},[d,c,o,f]);let m=(0,Rs.useMemo)(()=>kz(c),[c]);return{appliedFilter:r,setAppliedFilter:s,editingFilter:c,setEditingFilter:f,applyEditingFilter:p,totalEditingFilters:m}}function D1(){let{pageIndexParam:e,setPageIndexParam:t,setPageSizeParam:n}=lo(),{isInfiniteScrollEnabled:r,setInfiniteScrollEnabled:i,setTablePageSize:o,tablePageSize:s}=is(),a=Number.isSafeInteger(Number(e))?Math.max(0,Number(e)):0,l=(0,Nhe.useCallback)(u=>{let c={pageIndex:a,pageSize:s};if(typeof u=="function"){let d=u(c);t(d.pageIndex+""),n(d.pageSize+""),o(d.pageSize)}else t(u.pageIndex+""),n(u.pageSize+""),o(u.pageSize)},[a,t,n,o,s]);return{isInfiniteScrollEnabled:r,paginationState:{pageIndex:a,pageSize:s},setInfiniteScrollEnabled:i,setPaginationState:l}}function hO(){let{metadata:{activeTable:e},pageIndexParam:t,setPageIndexParam:n,sortParam:r,setSortParam:i}=lo(),o=l=>{if(!l)return[];try{return l.split(",").map(u=>{let[c,d]=u.split(":");return!c||!d||!["asc","desc"].includes(d)?null:{column:c,direction:d}}).filter(Boolean)}catch(u){return console.error("Failed to parse sorting parameter:",u),[]}},s=(0,dO.useMemo)(()=>{let l=o(r);return l.length>0?l:Rst(e)},[e,r]),a=(0,dO.useCallback)(l=>{let u=typeof l=="function"?l(s):l,c=u.length>0?u.map(d=>`${d.column}:${d.direction}`).join(","):null;(async()=>(await i(c),t!=="0"&&await n("0")))()},[t,n,i,s]);return{sortingState:s,setSortingState:a}}function Rst(e){return e?Object.values(e.columns).filter(t=>t.pkPosition!=null).sort((t,n)=>{let r=t.pkPosition??Number.POSITIVE_INFINITY,i=n.pkPosition??Number.POSITIVE_INFINITY;return r-i}).map(t=>({column:t.name,direction:"asc"})):[]}function Ist(){let{adapter:e,onEvent:t}=is(),{paginationState:n}=D1(),{sortingState:r}=hO(),{appliedFilter:i}=cO(),{activeTable:o,refetch:s}=uO({pageIndex:n.pageIndex,pageSize:n.pageSize,sortOrder:r,filter:i}),{schema:a=null,name:l=null}=o??{};return rz({mutationKey:["schema",a,"table",l,"insert"],async mutationFn(u){if(!o)throw new Error("Active table is not available");let[c,d]=await e.insert({rows:u,table:o},{});if(c)throw t({name:"studio_operation_error",payload:{operation:"insert",query:c.query,error:c}}),c;return t({name:"studio_operation_success",payload:{operation:"insert",query:d.query,error:void 0}}),z3(d,o)},async onSuccess(){await s()},retry:!1})}function Pst(e){let{filter:t,pageIndex:n,pageSize:r,sortOrder:i}=e,{metadata:{activeTable:o}}=lo(),s=Lst({activeTable:o,searchScope:e.searchScope??"table",searchTerm:e.searchTerm??""}),a=uO({filter:t,fullTableSearchTerm:s,pageIndex:n,pageSize:r,sortOrder:i});return{data:a.activeTable?{filteredRowCount:a.filteredRowCount,rows:a.rows}:void 0,isFetching:a.isFetching,refetch:a.refetch}}function Lst(e){let{activeTable:t,searchScope:n}=e,r=e.searchTerm.trim();if(!(n!=="row"||r.length===0||t==null))return r}function Bst(){let{paginationState:e}=D1(),{sortingState:t}=hO(),{appliedFilter:n}=cO(),{activeTable:r,collection:i}=uO({pageIndex:e.pageIndex,pageSize:e.pageSize,sortOrder:t,filter:n}),o=["schema",r?.schema??null,"table",r?.name??null];return rz({mutationFn:async s=>{if(!i||!r||s.updates.length===0)throw new Error("Active table collection is not available");let a=s.updates.map(l=>String(l.row.__ps_rowid??""));if(a.some(l=>l.length===0))throw new Error("Active table collection is not available");return await i.update(a,l=>{l.forEach((u,c)=>{Object.assign(u,s.updates[c]?.changes??{})})}).isPersisted.promise,{rows:a.map(l=>i.get(l))}},mutationKey:[...o,"update-many"],retry:!1})}function Mhe(){return kJ({predicate({options:{mutationKey:e}}){return e?.[4]==="insert"}})}function qst(){let{paginationState:e}=D1(),{sortingState:t}=hO(),{appliedFilter:n}=cO(),{activeTable:r,collection:i,refetch:o}=uO({pageIndex:e.pageIndex,pageSize:e.pageSize,sortOrder:t,filter:n}),{schema:s=null,name:a=null}=r??{};return rz({mutationKey:["schema",s,"table",a,"delete"],async mutationFn(l){if(!i||!r)throw new Error("Active table collection is not available");let u=l.map(c=>String(c.__ps_rowid??"")).filter(c=>c.length>0);return u.length===0?{rows:[]}:(await i.delete(u).isPersisted.promise,await o(),{rows:l})},retry:!1})}function zst(e){let{paginationState:t}=D1(),{mutate:n}=qst(),{scopeKey:r,tableUiState:i,updateTableUiState:o}=j3(),s=(0,gu.useMemo)(()=>i?.rowSelectionState??{},[i?.rowSelectionState]),a=Object.keys(s).length!==0,l=(0,gu.useRef)(r),u=(0,gu.useRef)(t.pageIndex),c=(0,gu.useRef)(t.pageSize);(0,gu.useEffect)(()=>{let f=l.current!==r,p=u.current!==t.pageIndex,m=c.current!==t.pageSize;l.current=r,u.current=t.pageIndex,c.current=t.pageSize,!(!r||!f&&!p&&!m||Object.keys(s).length===0)&&o(g=>{g.rowSelectionState={}})},[t.pageIndex,t.pageSize,s,r,o]);let d=(0,gu.useCallback)(f=>{o(p=>{let m=p.rowSelectionState??{};p.rowSelectionState=typeof f=="function"?f(m):f})},[o]);function h(){let f=e?.rows.filter(p=>s[p.__ps_rowid]);n(f??[],{onSuccess(){d({})}})}return{deleteSelection:h,setRowSelectionState:d,rowSelectionState:s,isSelecting:a}}function _he(e){let{cell:t,column:n,createUrl:r,introspection:i}=e,{fkSchema:o,fkTable:s,fkColumn:a}=n;return(0,tx.jsx)(V3,{createUrl:r,filterColumn:a,filterValue:t.getValue(),introspection:i,targetSchema:o,targetTable:s})}function V3(e){let{createUrl:t,filterColumn:n,filterValue:r,introspection:i,targetSchema:o,targetTable:s}=e;if(o==null||s==null||n==null)return null;let a=i.schemas[o]?.tables[s];return!a||r==null?null:(0,tx.jsx)(zn,{"aria-label":`Open ${a.name}`,className:"shrink-0",onMouseDown:l=>l.stopPropagation(),size:"xs",variant:"outline",onClick:l=>l.stopPropagation(),asChild:!0,children:(0,tx.jsx)("a",{href:t({schemaParam:o,tableParam:a.name,filterParam:JSON.stringify({kind:"FilterGroup",id:Pc.generate(),after:"and",filters:[{kind:"ColumnFilter",id:Pc.generate(),column:n,operator:"=",value:r,after:"and"}]})}),children:(0,tx.jsx)(Aze,{size:12})})})}var fO="Popover",[Ohe,svt]=os(fO,[Kh]),R1=Kh(),[Fst,rf]=Ohe(fO),The=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:o,modal:s=!1}=e,a=R1(t),l=sr.useRef(null),[u,c]=sr.useState(!1),[d,h]=_a({prop:r,defaultProp:i??!1,onChange:o,caller:fO});return(0,Xr.jsx)(d1,{...a,children:(0,Xr.jsx)(Fst,{scope:t,contentId:fi(),triggerRef:l,open:d,onOpenChange:h,onOpenToggle:sr.useCallback(()=>h(f=>!f),[h]),hasCustomAnchor:u,onCustomAnchorAdd:sr.useCallback(()=>c(!0),[]),onCustomAnchorRemove:sr.useCallback(()=>c(!1),[]),modal:s,children:n})})};The.displayName=fO;var Ahe="PopoverAnchor",jst=sr.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rf(Ahe,n),o=R1(n),{onCustomAnchorAdd:s,onCustomAnchorRemove:a}=i;return sr.useEffect(()=>(s(),()=>a()),[s,a]),(0,Xr.jsx)(h1,{...o,...r,ref:t})});jst.displayName=Ahe;var Dhe="PopoverTrigger",Rhe=sr.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rf(Dhe,n),o=R1(n),s=qt(t,i.triggerRef),a=(0,Xr.jsx)(ft.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":qhe(i.open),...r,ref:s,onClick:xe(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?a:(0,Xr.jsx)(h1,{asChild:!0,...o,children:a})});Rhe.displayName=Dhe;var W3="PopoverPortal",[Vst,Wst]=Ohe(W3,{forceMount:void 0}),Ihe=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,o=rf(W3,t);return(0,Xr.jsx)(Vst,{scope:t,forceMount:n,children:(0,Xr.jsx)(Vs,{present:n||o.open,children:(0,Xr.jsx)(Ov,{asChild:!0,container:i,children:r})})})};Ihe.displayName=W3;var dv="PopoverContent",Phe=sr.forwardRef((e,t)=>{let n=Wst(dv,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,o=rf(dv,e.__scopePopover);return(0,Xr.jsx)(Vs,{present:r||o.open,children:o.modal?(0,Xr.jsx)(Hst,{...i,ref:t}):(0,Xr.jsx)($st,{...i,ref:t})})});Phe.displayName=dv;var Ust=Xp("PopoverContent.RemoveScroll"),Hst=sr.forwardRef((e,t)=>{let n=rf(dv,e.__scopePopover),r=sr.useRef(null),i=qt(t,r),o=sr.useRef(!1);return sr.useEffect(()=>{let s=r.current;if(s)return iE(s)},[]),(0,Xr.jsx)(rE,{as:Ust,allowPinchZoom:!0,children:(0,Xr.jsx)(Lhe,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xe(e.onCloseAutoFocus,s=>{s.preventDefault(),o.current||n.triggerRef.current?.focus()}),onPointerDownOutside:xe(e.onPointerDownOutside,s=>{let a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,u=a.button===2||l;o.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:xe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1})})})}),$st=sr.forwardRef((e,t)=>{let n=rf(dv,e.__scopePopover),r=sr.useRef(!1),i=sr.useRef(!1);return(0,Xr.jsx)(Lhe,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{e.onCloseAutoFocus?.(o),o.defaultPrevented||(r.current||n.triggerRef.current?.focus(),o.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:o=>{e.onInteractOutside?.(o),o.defaultPrevented||(r.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));let s=o.target;n.triggerRef.current?.contains(s)&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})}),Lhe=sr.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,h=rf(dv,n),f=R1(n);return Z_(),(0,Xr.jsx)(s1,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:o,children:(0,Xr.jsx)(Ev,{asChild:!0,disableOutsidePointerEvents:s,onInteractOutside:c,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>h.onOpenChange(!1),children:(0,Xr.jsx)(bE,{"data-state":qhe(h.open),role:"dialog",id:h.contentId,...f,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),Bhe="PopoverClose",Kst=sr.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=rf(Bhe,n);return(0,Xr.jsx)(ft.button,{type:"button",...r,ref:t,onClick:xe(e.onClick,()=>i.onOpenChange(!1))})});Kst.displayName=Bhe;var Yst="PopoverArrow",Qst=sr.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=R1(n);return(0,Xr.jsx)(wE,{...i,...r,ref:t})});Qst.displayName=Yst;function qhe(e){return e?"open":"closed"}var zhe=The,Fhe=Rhe,jhe=Ihe,pO=Phe,mO=(0,ir.createContext)(null),Vhe=({children:e,onOpenChange:t,open:n,...r})=>{let[i,o]=(0,ir.useState)(!1),s=(0,ir.useRef)(null),a=n!==void 0,l=a?n:i,u=(0,ir.useCallback)(h=>{a||o(h),t?.(h)},[a,t]),c=(0,ir.useCallback)(h=>{s.current=h},[]),d=(0,ir.useCallback)(()=>{s.current?.()},[]);return(0,jp.jsx)(mO.Provider,{value:{commitInteractOutside:d,open:l,registerInteractOutsideAction:c,setOpen:u},children:(0,jp.jsx)(zhe,{open:l,onOpenChange:u,...r,children:e})})};Vhe.displayName="PopoverCell";var Whe=(0,ir.forwardRef)(({children:e,onDoubleClick:t,className:n,...r},i)=>{let o=(0,ir.useContext)(mO),{onClick:s,...a}=r;return(0,jp.jsx)(Fhe,{className:G("w-full h-full cursor-pointer",n),onClick:l=>{if(s?.(l),!l.defaultPrevented){if(RQ(l)){l.preventDefault(),l.stopPropagation();return}o?.setOpen(!0)}},onDoubleClick:l=>{if(t?.(l),!l.defaultPrevented){if(RQ(l)){l.preventDefault(),l.stopPropagation();return}o?.setOpen(!0)}},ref:l=>{typeof i=="function"?i(l):i&&(i.current=l)},...a,children:e})});Whe.displayName="PopoverCellTrigger";var Uhe=(0,ir.forwardRef)(({className:e,align:t="center",onInteractOutside:n,sideOffset:r=4,...i},o)=>{let s=(0,ir.useContext)(mO);return(0,jp.jsx)(jhe,{children:(0,jp.jsx)("div",{className:"ps",children:(0,jp.jsx)(pO,{...i,align:t,className:G("flex flex-col gap-2 z-50 border border-border bg-popover text-popover-foreground shadow-md outline-none",e),"data-studio-cell-editor":"true",onCloseAutoFocus:a=>{a.preventDefault()},onInteractOutside:a=>{n?.(a),!a.defaultPrevented&&s?.commitInteractOutside()},onEscapeKeyDown:a=>a.preventDefault(),ref:o,sideOffset:r})})})});Uhe.displayName=pO.displayName;function RQ(e){return!!(e.button!==0||Yw())}function Sm(e){let{onCancel:t,onNavigate:n,onSave:r}=e,i=(0,ir.useContext)(mO),o=(0,ir.useRef)(r);o.current=r;let s=(0,ir.useCallback)(()=>{o.current?.()},[]);(0,ir.useEffect)(()=>{if(i)return i.registerInteractOutsideAction(s),()=>{i.registerInteractOutsideAction(null)}},[s,i]);let a=(0,ir.useCallback)(()=>{r?.(),IQ(),i?.setOpen(!1)},[i,r]),l=(0,ir.useCallback)(()=>{t?.(),IQ(),i?.setOpen(!1)},[i,t]),u=(0,ir.useCallback)(c=>{if((c.key==="Enter"||c.key==="Return")&&!c.shiftKey){c.preventDefault(),c.stopPropagation(),a();return}if(c.key==="Escape"){c.preventDefault(),c.stopPropagation(),l();return}if(c.key==="Tab"){if(!n)return;c.preventDefault(),c.stopPropagation(),a(),n("tab");return}if(!c.metaKey&&!c.ctrlKey||!n)return;let d=c.key==="ArrowLeft"?"left":c.key==="ArrowRight"?"right":c.key==="ArrowUp"?"up":c.key==="ArrowDown"?"down":null;d&&(c.preventDefault(),c.stopPropagation(),a(),n(d))},[l,a,n]);return{handleCancel:l,handleKeyDown:u,handleSave:a}}function IQ(){document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}function Hhe(e){let{cellComponent:t,containerProps:n,inputComponent:r,isEditorOpen:i,linkComponent:o,onRequestClose:s,onRequestOpen:a}=e,[l,u]=(0,Ehe.useState)(!1),c=i!==void 0,d=c?i:l;function h(){c||u(!0),a?.()}function f(){c||u(!1),s?.()}let p=(0,ru.jsxs)("div",{className:"flex flex-row w-full gap-2 justify-between items-center",children:[(0,ru.jsx)("div",{children:t}),o]});return d?(0,ru.jsxs)(Vhe,{open:d,onOpenChange:m=>!m&&f(),children:[(0,ru.jsx)(Whe,{asChild:!0,children:(0,ru.jsx)(wa,{...n,withContextMenu:!1,children:p})}),(0,ru.jsx)(Uhe,{align:"start",alignOffset:-1,className:G("p-0 z-30 gap-0 border-muted-foreground/50","w-[calc(var(--radix-popover-trigger-width)+1px)] max-w-72 min-w-max"),sideOffset:-40,children:(0,ru.jsx)("div",{className:"bg-secondary/70",children:r})})]}):(0,ru.jsx)(wa,{...n,onClick:PQ(n?.onClick,h),onDoubleClick:PQ(n?.onDoubleClick,h),withContextMenu:!1,children:p})}function PQ(e,t){return n=>{if(e?.(n),!n.defaultPrevented){if(Gst(n)){n.preventDefault(),n.stopPropagation();return}t()}}}function Gst(e){return e.button!==0?!0:Yw()}var gO="Checkbox",[Xst,avt]=os(gO),[Jst,U3]=Xst(gO);function Zst(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:o,form:s,name:a,onCheckedChange:l,required:u,value:c="on",internal_do_not_use_render:d}=e,[h,f]=_a({prop:n,defaultProp:i??!1,onChange:l,caller:gO}),[p,m]=Po.useState(null),[g,y]=Po.useState(null),v=Po.useRef(!1),b=p?!!s||!!p.closest("form"):!0,w={checked:h,disabled:o,setChecked:f,control:p,setControl:m,name:a,form:s,value:c,hasConsumerStoppedPropagationRef:v,required:u,defaultChecked:Ch(i)?!1:i,isFormControl:b,bubbleInput:g,setBubbleInput:y};return(0,Ls.jsx)(Jst,{scope:t,...w,children:eat(d)?d(w):r})}var $he="CheckboxTrigger",Khe=Po.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i)=>{let{control:o,value:s,disabled:a,checked:l,required:u,setControl:c,setChecked:d,hasConsumerStoppedPropagationRef:h,isFormControl:f,bubbleInput:p}=U3($he,e),m=qt(i,c),g=Po.useRef(l);return Po.useEffect(()=>{let y=o?.form;if(y){let v=()=>d(g.current);return y.addEventListener("reset",v),()=>y.removeEventListener("reset",v)}},[o,d]),(0,Ls.jsx)(ft.button,{type:"button",role:"checkbox","aria-checked":Ch(l)?"mixed":l,"aria-required":u,"data-state":Jhe(l),"data-disabled":a?"":void 0,disabled:a,value:s,...r,ref:m,onKeyDown:xe(t,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:xe(n,y=>{d(v=>Ch(v)?!0:!v),p&&f&&(h.current=y.isPropagationStopped(),h.current||y.stopPropagation())})})});Khe.displayName=$he;var H3=Po.forwardRef((e,t)=>{let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:o,required:s,disabled:a,value:l,onCheckedChange:u,form:c,...d}=e;return(0,Ls.jsx)(Zst,{__scopeCheckbox:n,checked:i,defaultChecked:o,disabled:a,required:s,onCheckedChange:u,name:r,form:c,value:l,internal_do_not_use_render:({isFormControl:h})=>(0,Ls.jsxs)(Ls.Fragment,{children:[(0,Ls.jsx)(Khe,{...d,ref:t,__scopeCheckbox:n}),h&&(0,Ls.jsx)(Xhe,{__scopeCheckbox:n})]})})});H3.displayName=gO;var Yhe="CheckboxIndicator",Qhe=Po.forwardRef((e,t)=>{let{__scopeCheckbox:n,forceMount:r,...i}=e,o=U3(Yhe,n);return(0,Ls.jsx)(Vs,{present:r||Ch(o.checked)||o.checked===!0,children:(0,Ls.jsx)(ft.span,{"data-state":Jhe(o.checked),"data-disabled":o.disabled?"":void 0,...i,ref:t,style:{pointerEvents:"none",...e.style}})})});Qhe.displayName=Yhe;var Ghe="CheckboxBubbleInput",Xhe=Po.forwardRef(({__scopeCheckbox:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:o,defaultChecked:s,required:a,disabled:l,name:u,value:c,form:d,bubbleInput:h,setBubbleInput:f}=U3(Ghe,e),p=qt(n,f),m=Yz(o),g=Qz(r);Po.useEffect(()=>{let v=h;if(!v)return;let b=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(b,"checked").set,x=!i.current;if(m!==o&&w){let S=new Event("click",{bubbles:x});v.indeterminate=Ch(o),w.call(v,Ch(o)?!1:o),v.dispatchEvent(S)}},[h,m,o,i]);let y=Po.useRef(Ch(o)?!1:o);return(0,Ls.jsx)(ft.input,{type:"checkbox","aria-hidden":!0,defaultChecked:s??y.current,required:a,disabled:l,name:u,value:c,form:d,...t,tabIndex:-1,ref:p,style:{...t.style,...g,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Xhe.displayName=Ghe;function eat(e){return typeof e=="function"}function Ch(e){return e==="indeterminate"}function Jhe(e){return Ch(e)?"indeterminate":e?"checked":"unchecked"}var efe=Zhe.forwardRef(({className:e,...t},n)=>{let{checked:r}=t;return(0,Wy.jsx)(H3,{ref:n,className:G("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:(0,Wy.jsxs)(Qhe,{className:G("flex items-center justify-center text-current"),children:[r==="indeterminate"?(0,Wy.jsx)(KZ,{className:"h-4 w-4"}):null,r===!0?(0,Wy.jsx)(fm,{className:"h-4 w-4"}):null]})})});efe.displayName=H3.displayName;function km(e){let{children:t,disabled:n,onCancel:r,onSave:i,saveText:o,showSave:s=!0}=e;return(0,ha.jsx)("div",{className:"flex flex-row gap-1 border-t border-table-border text-xs p-2",children:(0,ha.jsx)("div",{className:"flex flex-col gap-1 w-full",children:(0,ha.jsxs)("div",{className:"grid grid-cols-2 gap-1 items-start justify-between",children:[(0,ha.jsxs)("div",{className:"flex flex-col gap-1",children:[s&&(0,ha.jsxs)("button",{"aria-disabled":n,className:"flex flex-row gap-1 items-center cursor-pointer shrink-0",disabled:n,onClick:()=>i?.(),children:[(0,ha.jsx)("kbd",{className:"inline-flex justify-center items-center h-6 w-6 rounded-md bg-muted text-muted-foreground",children:(0,ha.jsx)(o5e,{size:12,strokeWidth:2})})," ",o||"Save changes"]}),(0,ha.jsxs)("button",{className:"flex flex-row gap-1 items-center cursor-pointer shrink-0",onClick:()=>r?.(),children:[(0,ha.jsx)("kbd",{className:"inline-flex justify-center items-center h-6 w-6 rounded-md bg-muted text-muted-foreground text-[8px] leading-none font-semibold",children:"Esc"})," ","Cancel changes"]})]}),(0,ha.jsx)("div",{className:"flex flex-col gap-1 items-end",children:t})]})})})}function tat(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{defaultValue:l,fkColumn:u,isRequired:c}=t,d=n==="insert"&&l!=null?void 0:null,h=a==null?c&&!u?wk:"indeterminate":!!a,f=Q_("boolean-input"),[p,m]=En(f,h,{cleanupOnUnmount:!0}),{handleCancel:g,handleKeyDown:y,handleSave:v}=Sm({onNavigate:r,onSave:()=>p===h?!1:(i(p==="indeterminate"?d:p),!0)});return(0,Vp.jsxs)("div",{onKeyDown:y,children:[(0,Vp.jsxs)("div",{className:"flex flex-row items-center h-(--studio-cell-height) gap-4 py-0 px-2",children:[(0,Vp.jsx)(efe,{"aria-checked":p==="indeterminate"?"mixed":p,"aria-disabled":o,checked:p,disabled:o,id:"boolean-input",onCheckedChange:()=>m(b=>!c&&b===!0?"indeterminate":!b)}),(0,Vp.jsx)(lO,{htmlFor:"boolean-input",children:p==="indeterminate"?d===null?"NULL":"(default value)":String(p)})]}),(0,Vp.jsx)(km,{disabled:o,onCancel:g,onSave:v,showSave:s})]})}var bo=Dl(bk(),1),nat=Dl(VMe(),1);function rat(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}var iat={},Nw={};function Ap(e,t){try{let n=(iat[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return n in Nw?Nw[n]:LQ(n,n.split(":"))}catch{if(e in Nw)return Nw[e];let n=e?.match(oat);return n?LQ(e,n.slice(1)):NaN}}var oat=/([+-]\d\d):?(\d\d)?/;function LQ(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=+(t[2]||0)/60;return Nw[e]=n*60+r>0?n*60+r+i:n*60-r-i}var Mw=class _w extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Ap(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),tfe(this,NaN),yq(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new _w(...n,t):new _w(Date.now(),t)}withTimeZone(t){return new _w(+this,t)}getTimezoneOffset(){let t=-Ap(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),yq(this),+this}[Symbol.for("constructDateFrom")](t){return new _w(+new Date(t),this.timeZone)}},BQ=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!BQ.test(e))return;let t=e.replace(BQ,"$1UTC");Mw.prototype[t]&&(e.startsWith("get")?Mw.prototype[e]=function(){return this.internal[t]()}:(Mw.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),sat(this),+this},Mw.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),yq(this),+this}))});function yq(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Ap(e.timeZone,e)*60))}function sat(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),tfe(e)}function tfe(e){let t=Ap(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),o=-new Date(+r).getTimezoneOffset(),s=i-o,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();s&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+s);let l=i-n;l&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+l);let u=new Date(+e);u.setUTCSeconds(0);let c=i>0?u.getSeconds():(u.getSeconds()-60)%60,d=Math.round(-(Ap(e.timeZone,e)*60))%60;(d||c)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+d),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+d+c));let h=Ap(e.timeZone,e),f=h>0?Math.floor(h):Math.ceil(h),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,g=p-l;if(m&&g){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+g);let y=Ap(e.timeZone,e),v=y>0?Math.floor(y):Math.ceil(y),b=f-v;b&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+b),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+b))}}var da=class Ew extends Mw{static tz(t,...n){return n.length?new Ew(...n,t):new Ew(Date.now(),t)}toISOString(){let[t,n,r]=this.tzComponents(),i=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+i}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[t,n,r,i]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${r} ${n} ${i}`}toTimeString(){let t=this.internal.toUTCString().split(" ")[4],[n,r,i]=this.tzComponents();return`${t} GMT${n}${r}${i} (${rat(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){let t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),i=String(Math.abs(t)%60).padStart(2,"0");return[n,r,i]}withTimeZone(t){return new Ew(+this,t)}[Symbol.for("constructDateFrom")](t){return new Ew(+new Date(t),this.timeZone)}},aat=Math.pow(10,8)*24*60*60*1e3,lvt=-aat,nfe=6048e5,lat=864e5,uat=3600,rfe=uat*24,uvt=rfe*7,cat=rfe*365.2425,dat=cat/12,cvt=dat*3,qQ=Symbol.for("constructDateFrom");function Zr(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&qQ in e?e[qQ](t):e instanceof Date?new e.constructor(t):new Date(t)}function kn(e,t){return Zr(t||e,e)}function ife(e,t,n){let r=kn(e,n?.in);return isNaN(t)?Zr(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function ofe(e,t,n){let r=kn(e,n?.in);if(isNaN(t))return Zr(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),o=Zr(n?.in||e,r.getTime());o.setMonth(r.getMonth()+t+1,0);let s=o.getDate();return i>=s?o:(r.setFullYear(o.getFullYear(),o.getMonth(),i),r)}var hat={};function I1(){return hat}function fv(e,t){let n=I1(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=kn(e,t?.in),o=i.getDay(),s=(o<r?7:0)+o-r;return i.setDate(i.getDate()-s),i.setHours(0,0,0,0),i}function $x(e,t){return fv(e,{...t,weekStartsOn:1})}function sfe(e,t){let n=kn(e,t?.in),r=n.getFullYear(),i=Zr(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let o=$x(i),s=Zr(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);let a=$x(s);return n.getTime()>=o.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function zQ(e){let t=kn(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function Vv(e,...t){let n=Zr.bind(null,e||t.find(r=>typeof r=="object"));return t.map(n)}function Kx(e,t){let n=kn(e,t?.in);return n.setHours(0,0,0,0),n}function $3(e,t,n){let[r,i]=Vv(n?.in,e,t),o=Kx(r),s=Kx(i),a=+o-zQ(o),l=+s-zQ(s);return Math.round((a-l)/lat)}function fat(e,t){let n=sfe(e,t),r=Zr(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),$x(r)}function pat(e,t,n){return ife(e,t*7,n)}function mat(e,t,n){return ofe(e,t*12,n)}function gat(e,t){let n,r=t?.in;return e.forEach(i=>{!r&&typeof i=="object"&&(r=Zr.bind(null,i));let o=kn(i,r);(!n||n<o||isNaN(+o))&&(n=o)}),Zr(r,n||NaN)}function yat(e,t){let n,r=t?.in;return e.forEach(i=>{!r&&typeof i=="object"&&(r=Zr.bind(null,i));let o=kn(i,r);(!n||n>o||isNaN(+o))&&(n=o)}),Zr(r,n||NaN)}function vat(e,t,n){let[r,i]=Vv(n?.in,e,t);return+Kx(r)==+Kx(i)}function afe(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function bat(e){return!(!afe(e)&&typeof e!="number"||isNaN(+kn(e)))}function lfe(e,t,n){let[r,i]=Vv(n?.in,e,t),o=r.getFullYear()-i.getFullYear(),s=r.getMonth()-i.getMonth();return o*12+s}function wat(e,t){let n=kn(e,t?.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function ufe(e,t){let[n,r]=Vv(e,t.start,t.end);return{start:n,end:r}}function xat(e,t){let{start:n,end:r}=ufe(t?.in,e),i=+n>+r,o=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setDate(1);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,i=!i);let l=[];for(;+s<=o;)l.push(Zr(n,s)),s.setMonth(s.getMonth()+a);return i?l.reverse():l}function Sat(e,t){let n=kn(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function kat(e,t){let n=kn(e,t?.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function cfe(e,t){let n=kn(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Cat(e,t){let{start:n,end:r}=ufe(t?.in,e),i=+n>+r,o=i?+n:+r,s=i?r:n;s.setHours(0,0,0,0),s.setMonth(0,1);let a=t?.step??1;if(!a)return[];a<0&&(a=-a,i=!i);let l=[];for(;+s<=o;)l.push(Zr(n,s)),s.setFullYear(s.getFullYear()+a);return i?l.reverse():l}function dfe(e,t){let n=I1(),r=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,i=kn(e,t?.in),o=i.getDay(),s=(o<r?-7:0)+6-(o-r);return i.setDate(i.getDate()+s),i.setHours(23,59,59,999),i}function Nat(e,t){return dfe(e,{...t,weekStartsOn:1})}var Mat={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},_at=(e,t,n)=>{let r,i=Mat[e];return typeof i=="string"?r=i:t===1?r=i.one:r=i.other.replace("{{count}}",t.toString()),n?.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function _I(e){return(t={})=>{let n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}var Eat={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Oat={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Tat={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Aat={date:_I({formats:Eat,defaultWidth:"full"}),time:_I({formats:Oat,defaultWidth:"full"}),dateTime:_I({formats:Tat,defaultWidth:"full"})},Dat={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Rat=(e,t,n,r)=>Dat[e];function ew(e){return(t,n)=>{let r=n?.context?String(n.context):"standalone",i;if(r==="formatting"&&e.formattingValues){let s=e.defaultFormattingWidth||e.defaultWidth,a=n?.width?String(n.width):s;i=e.formattingValues[a]||e.formattingValues[s]}else{let s=e.defaultWidth,a=n?.width?String(n.width):e.defaultWidth;i=e.values[a]||e.values[s]}let o=e.argumentCallback?e.argumentCallback(t):t;return i[o]}}var Iat={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Pat={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Lat={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"]},Bat={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"]},qat={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"}},zat={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"}},Fat=(e,t)=>{let n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},jat={ordinalNumber:Fat,era:ew({values:Iat,defaultWidth:"wide"}),quarter:ew({values:Pat,defaultWidth:"wide",argumentCallback:e=>e-1}),month:ew({values:Lat,defaultWidth:"wide"}),day:ew({values:Bat,defaultWidth:"wide"}),dayPeriod:ew({values:qat,defaultWidth:"wide",formattingValues:zat,defaultFormattingWidth:"wide"})};function tw(e){return(t,n={})=>{let r=n.width,i=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],o=t.match(i);if(!o)return null;let s=o[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],l=Array.isArray(a)?Wat(a,d=>d.test(s)):Vat(a,d=>d.test(s)),u;u=e.valueCallback?e.valueCallback(l):l,u=n.valueCallback?n.valueCallback(u):u;let c=t.slice(s.length);return{value:u,rest:c}}}function Vat(e,t){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function Wat(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function Uat(e){return(t,n={})=>{let r=t.match(e.matchPattern);if(!r)return null;let i=r[0],o=t.match(e.parsePattern);if(!o)return null;let s=e.valueCallback?e.valueCallback(o[0]):o[0];s=n.valueCallback?n.valueCallback(s):s;let a=t.slice(i.length);return{value:s,rest:a}}}var Hat=/^(\d+)(th|st|nd|rd)?/i,$at=/\d+/i,Kat={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},Yat={any:[/^b/i,/^(a|c)/i]},Qat={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Gat={any:[/1/i,/2/i,/3/i,/4/i]},Xat={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},Jat={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]},Zat={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},elt={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]},tlt={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},nlt={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}},rlt={ordinalNumber:Uat({matchPattern:Hat,parsePattern:$at,valueCallback:e=>parseInt(e,10)}),era:tw({matchPatterns:Kat,defaultMatchWidth:"wide",parsePatterns:Yat,defaultParseWidth:"any"}),quarter:tw({matchPatterns:Qat,defaultMatchWidth:"wide",parsePatterns:Gat,defaultParseWidth:"any",valueCallback:e=>e+1}),month:tw({matchPatterns:Xat,defaultMatchWidth:"wide",parsePatterns:Jat,defaultParseWidth:"any"}),day:tw({matchPatterns:Zat,defaultMatchWidth:"wide",parsePatterns:elt,defaultParseWidth:"any"}),dayPeriod:tw({matchPatterns:tlt,defaultMatchWidth:"any",parsePatterns:nlt,defaultParseWidth:"any"})},sy={code:"en-US",formatDistance:_at,formatLong:Aat,formatRelative:Rat,localize:jat,match:rlt,options:{weekStartsOn:0,firstWeekContainsDate:1}};function ilt(e,t){let n=kn(e,t?.in);return $3(n,cfe(n))+1}function K3(e,t){let n=kn(e,t?.in),r=+$x(n)-+fat(n);return Math.round(r/nfe)+1}function hfe(e,t){let n=kn(e,t?.in),r=n.getFullYear(),i=I1(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??i.firstWeekContainsDate??i.locale?.options?.firstWeekContainsDate??1,s=Zr(t?.in||e,0);s.setFullYear(r+1,0,o),s.setHours(0,0,0,0);let a=fv(s,t),l=Zr(t?.in||e,0);l.setFullYear(r,0,o),l.setHours(0,0,0,0);let u=fv(l,t);return+n>=+a?r+1:+n>=+u?r:r-1}function olt(e,t){let n=I1(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,i=hfe(e,t),o=Zr(t?.in||e,0);return o.setFullYear(i,0,r),o.setHours(0,0,0,0),fv(o,t)}function Y3(e,t){let n=kn(e,t?.in),r=+fv(n,t)-+olt(n,t);return Math.round(r/nfe)+1}function mn(e,t){let n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}var $d={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return mn(t==="yy"?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t==="M"?String(n+1):mn(n+1,2)},d(e,t){return mn(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];default:return n==="am"?"a.m.":"p.m."}},h(e,t){return mn(e.getHours()%12||12,t.length)},H(e,t){return mn(e.getHours(),t.length)},m(e,t){return mn(e.getMinutes(),t.length)},s(e,t){return mn(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds(),i=Math.trunc(r*Math.pow(10,n-3));return mn(i,t.length)}},Qg={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},FQ={G:function(e,t,n){let r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){let r=e.getFullYear(),i=r>0?r:1-r;return n.ordinalNumber(i,{unit:"year"})}return $d.y(e,t)},Y:function(e,t,n,r){let i=hfe(e,r),o=i>0?i:1-i;if(t==="YY"){let s=o%100;return mn(s,2)}return t==="Yo"?n.ordinalNumber(o,{unit:"year"}):mn(o,t.length)},R:function(e,t){let n=sfe(e);return mn(n,t.length)},u:function(e,t){let n=e.getFullYear();return mn(n,t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return mn(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return mn(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){let r=e.getMonth();switch(t){case"M":case"MM":return $d.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){let r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return mn(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){let i=Y3(e,r);return t==="wo"?n.ordinalNumber(i,{unit:"week"}):mn(i,t.length)},I:function(e,t,n){let r=K3(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):mn(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):$d.d(e,t)},D:function(e,t,n){let r=ilt(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):mn(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){let i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(o);case"ee":return mn(o,2);case"eo":return n.ordinalNumber(o,{unit:"day"});case"eee":return n.day(i,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(i,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(i,{width:"short",context:"formatting"});default:return n.day(i,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){let i=e.getDay(),o=(i-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(o);case"cc":return mn(o,t.length);case"co":return n.ordinalNumber(o,{unit:"day"});case"ccc":return n.day(i,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(i,{width:"narrow",context:"standalone"});case"cccccc":return n.day(i,{width:"short",context:"standalone"});default:return n.day(i,{width:"wide",context:"standalone"})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case"i":return String(i);case"ii":return mn(i,t.length);case"io":return n.ordinalNumber(i,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){let r=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(r,{width:"narrow",context:"formatting"});default:return n.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(e,t,n){let r=e.getHours(),i;switch(r===12?i=Qg.noon:r===0?i=Qg.midnight:i=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},B:function(e,t,n){let r=e.getHours(),i;switch(r>=17?i=Qg.evening:r>=12?i=Qg.afternoon:r>=4?i=Qg.morning:i=Qg.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(i,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(i,{width:"narrow",context:"formatting"});default:return n.dayPeriod(i,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return $d.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):$d.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):mn(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):mn(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):$d.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):$d.s(e,t)},S:function(e,t){return $d.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return VQ(r);case"XXXX":case"XX":return vp(r);default:return vp(r,":")}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"x":return VQ(r);case"xxxx":case"xx":return vp(r);default:return vp(r,":")}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+jQ(r,":");default:return"GMT"+vp(r,":")}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+jQ(r,":");default:return"GMT"+vp(r,":")}},t:function(e,t,n){let r=Math.trunc(+e/1e3);return mn(r,t.length)},T:function(e,t,n){return mn(+e,t.length)}};function jQ(e,t=""){let n=e>0?"-":"+",r=Math.abs(e),i=Math.trunc(r/60),o=r%60;return o===0?n+String(i):n+String(i)+t+mn(o,2)}function VQ(e,t){return e%60===0?(e>0?"-":"+")+mn(Math.abs(e)/60,2):vp(e,t)}function vp(e,t=""){let n=e>0?"-":"+",r=Math.abs(e),i=mn(Math.trunc(r/60),2),o=mn(r%60,2);return n+i+t+o}var WQ=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});default:return t.date({width:"full"})}},ffe=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});default:return t.time({width:"full"})}},slt=(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return WQ(e,t);let o;switch(r){case"P":o=t.dateTime({width:"short"});break;case"PP":o=t.dateTime({width:"medium"});break;case"PPP":o=t.dateTime({width:"long"});break;default:o=t.dateTime({width:"full"});break}return o.replace("{{date}}",WQ(r,t)).replace("{{time}}",ffe(i,t))},alt={p:ffe,P:slt},llt=/^D+$/,ult=/^Y+$/,clt=["D","DD","YY","YYYY"];function dlt(e){return llt.test(e)}function hlt(e){return ult.test(e)}function flt(e,t,n){let r=plt(e,t,n);if(console.warn(r),clt.includes(e))throw new RangeError(r)}function plt(e,t,n){let r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var mlt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,glt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ylt=/^'([^]*?)'?$/,vlt=/''/g,blt=/[a-zA-Z]/;function Ow(e,t,n){let r=I1(),i=n?.locale??r.locale??sy,o=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,s=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,a=kn(e,n?.in);if(!bat(a))throw new RangeError("Invalid time value");let l=t.match(glt).map(c=>{let d=c[0];if(d==="p"||d==="P"){let h=alt[d];return h(c,i.formatLong)}return c}).join("").match(mlt).map(c=>{if(c==="''")return{isToken:!1,value:"'"};let d=c[0];if(d==="'")return{isToken:!1,value:wlt(c)};if(FQ[d])return{isToken:!0,value:c};if(d.match(blt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+d+"`");return{isToken:!1,value:c}});i.localize.preprocessor&&(l=i.localize.preprocessor(a,l));let u={firstWeekContainsDate:o,weekStartsOn:s,locale:i};return l.map(c=>{if(!c.isToken)return c.value;let d=c.value;(!n?.useAdditionalWeekYearTokens&&hlt(d)||!n?.useAdditionalDayOfYearTokens&&dlt(d))&&flt(d,t,String(e));let h=FQ[d[0]];return h(a,d,i.localize,u)}).join("")}function wlt(e){let t=e.match(ylt);return t?t[1].replace(vlt,"'"):e}function xlt(e,t){let n=kn(e,t?.in),r=n.getFullYear(),i=n.getMonth(),o=Zr(n,0);return o.setFullYear(r,i+1,0),o.setHours(0,0,0,0),o.getDate()}function Slt(e,t){return kn(e,t?.in).getMonth()}function klt(e,t){return kn(e,t?.in).getFullYear()}function Clt(e,t){return+kn(e)>+kn(t)}function Nlt(e,t){return+kn(e)<+kn(t)}function Mlt(e,t,n){let[r,i]=Vv(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function _lt(e,t,n){let[r,i]=Vv(n?.in,e,t);return r.getFullYear()===i.getFullYear()}function Elt(e,t,n){let r=kn(e,n?.in),i=r.getFullYear(),o=r.getDate(),s=Zr(n?.in||e,0);s.setFullYear(i,t,15),s.setHours(0,0,0,0);let a=xlt(s);return r.setMonth(t,Math.min(o,a)),r}function Olt(e,t,n){let r=kn(e,n?.in);return isNaN(+r)?Zr(n?.in||e,NaN):(r.setFullYear(t),r)}function Tlt(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),o=t.addDays(i,34);return t.getMonth(e)===t.getMonth(o)?5:4}function pfe(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function Alt(e,t){let n=pfe(e,t),r=Tlt(e,t);return t.addDays(n,r*7-1)}var mfe={...sy,labels:{labelDayButton:(e,t,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,a)=>Ow(s,a,{locale:sy,...n});let o=i(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o},labelMonthDropdown:"Choose the Month",labelNext:"Go to the Next Month",labelPrevious:"Go to the Previous Month",labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:"Choose the Year",labelGrid:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,o)=>Ow(i,o,{locale:sy,...t}),r(e,"LLLL yyyy")},labelGridcell:(e,t,n,r)=>{let i;r&&typeof r.format=="function"?i=r.format.bind(r):i=(s,a)=>Ow(s,a,{locale:sy,...n});let o=i(e,"PPPP");return t?.today&&(o=`Today, ${o}`),o},labelNav:"Navigation bar",labelWeekNumberHeader:"Week Number",labelWeekday:(e,t,n)=>{let r;return n&&typeof n.format=="function"?r=n.format.bind(n):r=(i,o)=>Ow(i,o,{locale:sy,...t}),r(e,"cccc")}}},Au=class vq{constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?da.tz(this.options.timeZone):new this.Date,this.newDate=(r,i,o)=>this.overrides?.newDate?this.overrides.newDate(r,i,o):this.options.timeZone?new da(r,i,o,this.options.timeZone):new Date(r,i,o),this.addDays=(r,i)=>this.overrides?.addDays?this.overrides.addDays(r,i):ife(r,i),this.addMonths=(r,i)=>this.overrides?.addMonths?this.overrides.addMonths(r,i):ofe(r,i),this.addWeeks=(r,i)=>this.overrides?.addWeeks?this.overrides.addWeeks(r,i):pat(r,i),this.addYears=(r,i)=>this.overrides?.addYears?this.overrides.addYears(r,i):mat(r,i),this.differenceInCalendarDays=(r,i)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,i):$3(r,i),this.differenceInCalendarMonths=(r,i)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,i):lfe(r,i),this.eachMonthOfInterval=r=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):xat(r),this.eachYearOfInterval=r=>{let i=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(r):Cat(r),o=new Set(i.map(a=>this.getYear(a)));if(o.size===i.length)return i;let s=[];return o.forEach(a=>{s.push(new Date(a,0,1))}),s},this.endOfBroadcastWeek=r=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):Alt(r,this),this.endOfISOWeek=r=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(r):Nat(r),this.endOfMonth=r=>this.overrides?.endOfMonth?this.overrides.endOfMonth(r):wat(r),this.endOfWeek=(r,i)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(r,i):dfe(r,this.options),this.endOfYear=r=>this.overrides?.endOfYear?this.overrides.endOfYear(r):kat(r),this.format=(r,i,o)=>{let s=this.overrides?.format?this.overrides.format(r,i,this.options):Ow(r,i,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(s):s},this.getISOWeek=r=>this.overrides?.getISOWeek?this.overrides.getISOWeek(r):K3(r),this.getMonth=(r,i)=>this.overrides?.getMonth?this.overrides.getMonth(r,this.options):Slt(r,this.options),this.getYear=(r,i)=>this.overrides?.getYear?this.overrides.getYear(r,this.options):klt(r,this.options),this.getWeek=(r,i)=>this.overrides?.getWeek?this.overrides.getWeek(r,this.options):Y3(r,this.options),this.isAfter=(r,i)=>this.overrides?.isAfter?this.overrides.isAfter(r,i):Clt(r,i),this.isBefore=(r,i)=>this.overrides?.isBefore?this.overrides.isBefore(r,i):Nlt(r,i),this.isDate=r=>this.overrides?.isDate?this.overrides.isDate(r):afe(r),this.isSameDay=(r,i)=>this.overrides?.isSameDay?this.overrides.isSameDay(r,i):vat(r,i),this.isSameMonth=(r,i)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(r,i):Mlt(r,i),this.isSameYear=(r,i)=>this.overrides?.isSameYear?this.overrides.isSameYear(r,i):_lt(r,i),this.max=r=>this.overrides?.max?this.overrides.max(r):gat(r),this.min=r=>this.overrides?.min?this.overrides.min(r):yat(r),this.setMonth=(r,i)=>this.overrides?.setMonth?this.overrides.setMonth(r,i):Elt(r,i),this.setYear=(r,i)=>this.overrides?.setYear?this.overrides.setYear(r,i):Olt(r,i),this.startOfBroadcastWeek=(r,i)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):pfe(r,this),this.startOfDay=r=>this.overrides?.startOfDay?this.overrides.startOfDay(r):Kx(r),this.startOfISOWeek=r=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(r):$x(r),this.startOfMonth=r=>this.overrides?.startOfMonth?this.overrides.startOfMonth(r):Sat(r),this.startOfWeek=(r,i)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(r,this.options):fv(r,this.options),this.startOfYear=r=>this.overrides?.startOfYear?this.overrides.startOfYear(r):cfe(r),this.options={locale:mfe,...t},this.overrides=n}getDigitMap(){let{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let i=0;i<10;i++)r[i.toString()]=n.format(i);return r}replaceDigits(t){let n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&vq.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,o=n?.code;if(o&&vq.yearFirstLocales.has(o))try{return new Intl.DateTimeFormat(o,{month:"long",year:"numeric",timeZone:r,numberingSystem:i}).format(t)}catch{}let s=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,s)}};Au.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);var Du=new Au,gfe=class{constructor(e,t,n=Du){this.date=e,this.displayMonth=t,this.outside=!!(t&&!n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,"yyyy-MM-dd"),this.displayMonthId=n.format(t,"yyyy-MM"),this.dateMonthId=n.format(e,"yyyy-MM")}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},Dlt=class{constructor(e,t){this.date=e,this.weeks=t}},Rlt=class{constructor(e,t){this.days=t,this.weekNumber=e}},yfe={};YS(yfe,{Button:()=>Ilt,CaptionLabel:()=>Plt,Chevron:()=>Llt,Day:()=>Blt,DayButton:()=>qlt,Dropdown:()=>zlt,DropdownNav:()=>Flt,Footer:()=>jlt,Month:()=>Vlt,MonthCaption:()=>Wlt,MonthGrid:()=>Ult,Months:()=>Hlt,MonthsDropdown:()=>$lt,Nav:()=>Klt,NextMonthButton:()=>Ylt,Option:()=>Qlt,PreviousMonthButton:()=>Glt,Root:()=>Xlt,Select:()=>Jlt,Week:()=>Zlt,WeekNumber:()=>nut,WeekNumberHeader:()=>rut,Weekday:()=>eut,Weekdays:()=>tut,Weeks:()=>iut,YearsDropdown:()=>out});function Ilt(e){return vfe.default.createElement("button",{...e})}function Plt(e){return bfe.default.createElement("span",{...e})}function Llt(e){let{size:t=24,orientation:n="left",className:r}=e;return ay.default.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&ay.default.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&ay.default.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&ay.default.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&ay.default.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Blt(e){let{day:t,modifiers:n,...r}=e;return wfe.default.createElement("td",{...r})}function qlt(e){let{day:t,modifiers:n,...r}=e,i=pM.default.useRef(null);return pM.default.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),pM.default.createElement("button",{ref:i,...r})}var We;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(We||(We={}));var gr;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(gr||(gr={}));var ll;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(ll||(ll={}));var Os;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(Os||(Os={}));function zlt(e){let{options:t,className:n,components:r,classNames:i,...o}=e,s=[i[We.Dropdown],n].join(" "),a=t?.find(({value:l})=>l===o.value);return ly.default.createElement("span",{"data-disabled":o.disabled,className:i[We.DropdownRoot]},ly.default.createElement(r.Select,{className:s,...o},t?.map(({value:l,label:u,disabled:c})=>ly.default.createElement(r.Option,{key:l,value:l,disabled:c},u))),ly.default.createElement("span",{className:i[We.CaptionLabel],"aria-hidden":!0},a?.label,ly.default.createElement(r.Chevron,{orientation:"down",size:18,className:i[We.Chevron]})))}function Flt(e){return xfe.default.createElement("div",{...e})}function jlt(e){return Sfe.default.createElement("div",{...e})}function Vlt(e){let{calendarMonth:t,displayIndex:n,...r}=e;return kfe.default.createElement("div",{...r},e.children)}function Wlt(e){let{calendarMonth:t,displayIndex:n,...r}=e;return Cfe.default.createElement("div",{...r})}function Ult(e){return Nfe.default.createElement("table",{...e})}function Hlt(e){return Mfe.default.createElement("div",{...e})}var Efe=(0,yO.createContext)(void 0);function P1(){let e=(0,yO.useContext)(Efe);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function $lt(e){let{components:t}=P1();return _fe.default.createElement(t.Dropdown,{...e})}function Klt(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...o}=e,{components:s,classNames:a,labels:{labelPrevious:l,labelNext:u}}=P1(),c=(0,kc.useCallback)(h=>{i&&n?.(h)},[i,n]),d=(0,kc.useCallback)(h=>{r&&t?.(h)},[r,t]);return kc.default.createElement("nav",{...o},kc.default.createElement(s.PreviousMonthButton,{type:"button",className:a[We.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":l(r),onClick:d},kc.default.createElement(s.Chevron,{disabled:r?void 0:!0,className:a[We.Chevron],orientation:"left"})),kc.default.createElement(s.NextMonthButton,{type:"button",className:a[We.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":i?void 0:!0,"aria-label":u(i),onClick:c},kc.default.createElement(s.Chevron,{disabled:i?void 0:!0,orientation:"right",className:a[We.Chevron]})))}function Ylt(e){let{components:t}=P1();return Ofe.default.createElement(t.Button,{...e})}function Qlt(e){return Tfe.default.createElement("option",{...e})}function Glt(e){let{components:t}=P1();return Afe.default.createElement(t.Button,{...e})}function Xlt(e){let{rootRef:t,...n}=e;return Dfe.default.createElement("div",{...n,ref:t})}function Jlt(e){return Rfe.default.createElement("select",{...e})}function Zlt(e){let{week:t,...n}=e;return Ife.default.createElement("tr",{...n})}function eut(e){return Pfe.default.createElement("th",{...e})}function tut(e){return bq.default.createElement("thead",{"aria-hidden":!0},bq.default.createElement("tr",{...e}))}function nut(e){let{week:t,...n}=e;return Lfe.default.createElement("th",{...n})}function rut(e){return Bfe.default.createElement("th",{...e})}function iut(e){return qfe.default.createElement("tbody",{...e})}function out(e){let{components:t}=P1();return zfe.default.createElement(t.Dropdown,{...e})}function _c(e,t,n=!1,r=Du){let{from:i,to:o}=e,{differenceInCalendarDays:s,isSameDay:a}=r;return i&&o?(s(o,i)<0&&([i,o]=[o,i]),s(t,i)>=(n?1:0)&&s(o,t)>=(n?1:0)):!n&&o?a(o,t):!n&&i?a(i,t):!1}function Q3(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function vO(e){return!!(e&&typeof e=="object"&&"from"in e)}function G3(e){return!!(e&&typeof e=="object"&&"after"in e)}function X3(e){return!!(e&&typeof e=="object"&&"before"in e)}function Ffe(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function jfe(e,t){return Array.isArray(e)&&e.every(t.isDate)}function Ec(e,t,n=Du){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:o,isAfter:s}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return i(e,a);if(jfe(a,n))return a.some(l=>i(e,l));if(vO(a))return _c(a,e,!1,n);if(Ffe(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(Q3(a)){let l=o(a.before,e),u=o(a.after,e),c=l>0,d=u<0;return s(a.before,a.after)?d&&c:c||d}return G3(a)?o(e,a.after)>0:X3(a)?o(a.before,e)>0:typeof a=="function"?a(e):!1})}function sut(e,t,n,r,i){let{disabled:o,hidden:s,modifiers:a,showOutsideDays:l,broadcastCalendar:u,today:c=i.today()}=t,{isSameDay:d,isSameMonth:h,startOfMonth:f,isBefore:p,endOfMonth:m,isAfter:g}=i,y=n&&f(n),v=r&&m(r),b={[gr.focused]:[],[gr.outside]:[],[gr.disabled]:[],[gr.hidden]:[],[gr.today]:[]},w={};for(let x of e){let{date:S,displayMonth:k}=x,C=!!(k&&!h(S,k)),N=!!(y&&p(S,y)),E=!!(v&&g(S,v)),D=!!(o&&Ec(S,o,i)),q=!!(s&&Ec(S,s,i))||N||E||!u&&!l&&C||u&&l===!1&&C,z=d(S,c);C&&b.outside.push(x),D&&b.disabled.push(x),q&&b.hidden.push(x),z&&b.today.push(x),a&&Object.keys(a).forEach(_=>{let R=a?.[_];R&&Ec(S,R,i)&&(w[_]?w[_].push(x):w[_]=[x])})}return x=>{let S={[gr.focused]:!1,[gr.disabled]:!1,[gr.hidden]:!1,[gr.outside]:!1,[gr.today]:!1},k={};for(let C in b){let N=b[C];S[C]=N.some(E=>E===x)}for(let C in w)k[C]=w[C].some(N=>N===x);return{...S,...k}}}function aut(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[i])=>(n[i]?r.push(n[i]):t[gr[i]]?r.push(t[gr[i]]):t[ll[i]]&&r.push(t[ll[i]]),r),[t[We.Day]])}function lut(e){return{...yfe,...e}}function uut(e){let t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function cut(){let e={};for(let t in We)e[We[t]]=`rdp-${We[t]}`;for(let t in gr)e[gr[t]]=`rdp-${gr[t]}`;for(let t in ll)e[ll[t]]=`rdp-${ll[t]}`;for(let t in Os)e[Os[t]]=`rdp-${Os[t]}`;return e}var Vfe={};YS(Vfe,{formatCaption:()=>Wfe,formatDay:()=>hut,formatMonthCaption:()=>dut,formatMonthDropdown:()=>fut,formatWeekNumber:()=>mut,formatWeekNumberHeader:()=>gut,formatWeekdayName:()=>put,formatYearCaption:()=>yut,formatYearDropdown:()=>Ufe});function Wfe(e,t,n){return(n??new Au(t)).formatMonthYear(e)}var dut=Wfe;function hut(e,t,n){return(n??new Au(t)).format(e,"d")}function fut(e,t=Du){return t.format(e,"LLLL")}function put(e,t,n){return(n??new Au(t)).format(e,"cccccc")}function mut(e,t=Du){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function gut(){return""}function Ufe(e,t=Du){return t.format(e,"yyyy")}var yut=Ufe;function vut(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...Vfe,...e}}var Hfe={};YS(Hfe,{labelCaption:()=>wut,labelDay:()=>but,labelDayButton:()=>J3,labelGrid:()=>Z3,labelGridcell:()=>$fe,labelMonthDropdown:()=>Kfe,labelNav:()=>Yfe,labelNext:()=>Qfe,labelPrevious:()=>Gfe,labelWeekNumber:()=>Jfe,labelWeekNumberHeader:()=>Zfe,labelWeekday:()=>Xfe,labelYearDropdown:()=>epe});function J3(e,t,n,r){let i=(r??new Au(n)).format(e,"PPPP");return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}var but=J3;function Z3(e,t,n){return(n??new Au(t)).formatMonthYear(e)}var wut=Z3;function $fe(e,t,n,r){let i=(r??new Au(n)).format(e,"PPPP");return t?.today&&(i=`Today, ${i}`),i}function Kfe(e){return"Choose the Month"}function Yfe(){return""}var xut="Go to the Next Month";function Qfe(e,t){return xut}function Gfe(e){return"Go to the Previous Month"}function Xfe(e,t,n){return(n??new Au(t)).format(e,"cccc")}function Jfe(e,t){return`Week ${e}`}function Zfe(e){return"Week Number"}function epe(e){return"Choose the Year"}var Xa=(e,t,n)=>t||(n?typeof n=="function"?n:(...r)=>n:e);function Sut(e,t){let n=t.locale?.labels??{};return{...Hfe,...e??{},labelDayButton:Xa(J3,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:Xa(Kfe,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:Xa(Qfe,e?.labelNext,n.labelNext),labelPrevious:Xa(Gfe,e?.labelPrevious,n.labelPrevious),labelWeekNumber:Xa(Jfe,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:Xa(epe,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:Xa(Z3,e?.labelGrid,n.labelGrid),labelGridcell:Xa($fe,e?.labelGridcell,n.labelGridcell),labelNav:Xa(Yfe,e?.labelNav,n.labelNav),labelWeekNumberHeader:Xa(Zfe,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:Xa(Xfe,e?.labelWeekday,n.labelWeekday)}}function kut(e,t,n,r,i){let{startOfMonth:o,startOfYear:s,endOfYear:a,eachMonthOfInterval:l,getMonth:u}=i;return l({start:s(e),end:a(e)}).map(c=>{let d=r.formatMonthDropdown(c,i),h=u(c),f=t&&c<o(t)||n&&c>o(n)||!1;return{value:h,label:d,disabled:f}})}function Cut(e,t={},n={}){let r={...t?.[We.Day]};return Object.entries(e).filter(([,i])=>i===!0).forEach(([i])=>{r={...r,...n?.[i]}}),r}function Nut(e,t,n,r){let i=r??e.today(),o=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),s=[];for(let a=0;a<7;a++){let l=e.addDays(o,a);s.push(l)}return s}function Mut(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:o,endOfYear:s,eachYearOfInterval:a,getYear:l}=r,u=o(e),c=s(t),d=a({start:u,end:c});return i&&d.reverse(),d.map(h=>{let f=n.formatYearDropdown(h,r);return{value:l(h),label:f,disabled:!1}})}function _ut(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,o=a=>{let l=typeof a=="number"||typeof a=="string"?new Date(a):a;return new da(l.getFullYear(),l.getMonth(),l.getDate(),12,0,0,e)},s=a=>{let l=o(a);return new Date(l.getFullYear(),l.getMonth(),l.getDate(),0,0,0,0)};return{today:()=>o(da.tz(e)),newDate:(a,l,u)=>new da(a,l,u,12,0,0,e),startOfDay:a=>o(a),startOfWeek:(a,l)=>{let u=o(a),c=l?.weekStartsOn??i,d=(u.getDay()-c+7)%7;return u.setDate(u.getDate()-d),u},startOfISOWeek:a=>{let l=o(a),u=(l.getDay()-1+7)%7;return l.setDate(l.getDate()-u),l},startOfMonth:a=>{let l=o(a);return l.setDate(1),l},startOfYear:a=>{let l=o(a);return l.setMonth(0,1),l},endOfWeek:(a,l)=>{let u=o(a),c=(((l?.weekStartsOn??i)+6)%7-u.getDay()+7)%7;return u.setDate(u.getDate()+c),u},endOfISOWeek:a=>{let l=o(a),u=(7-l.getDay())%7;return l.setDate(l.getDate()+u),l},endOfMonth:a=>{let l=o(a);return l.setMonth(l.getMonth()+1,0),l},endOfYear:a=>{let l=o(a);return l.setMonth(11,31),l},eachMonthOfInterval:a=>{let l=o(a.start),u=o(a.end),c=[],d=new da(l.getFullYear(),l.getMonth(),1,12,0,0,e),h=u.getFullYear()*12+u.getMonth();for(;d.getFullYear()*12+d.getMonth()<=h;)c.push(new da(d,e)),d.setMonth(d.getMonth()+1,1);return c},addDays:(a,l)=>{let u=o(a);return u.setDate(u.getDate()+l),u},addWeeks:(a,l)=>{let u=o(a);return u.setDate(u.getDate()+l*7),u},addMonths:(a,l)=>{let u=o(a);return u.setMonth(u.getMonth()+l),u},addYears:(a,l)=>{let u=o(a);return u.setFullYear(u.getFullYear()+l),u},eachYearOfInterval:a=>{let l=o(a.start),u=o(a.end),c=[],d=new da(l.getFullYear(),0,1,12,0,0,e);for(;d.getFullYear()<=u.getFullYear();)c.push(new da(d,e)),d.setFullYear(d.getFullYear()+1,0,1);return c},getWeek:(a,l)=>{let u=s(a);return Y3(u,{weekStartsOn:l?.weekStartsOn??i,firstWeekContainsDate:l?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:a=>{let l=s(a);return K3(l)},differenceInCalendarDays:(a,l)=>{let u=s(a),c=s(l);return $3(u,c)},differenceInCalendarMonths:(a,l)=>{let u=s(a),c=s(l);return lfe(u,c)}}}var L1=e=>e instanceof HTMLElement?e:null,EI=e=>[...e.querySelectorAll("[data-animated-month]")??[]],Eut=e=>L1(e.querySelector("[data-animated-month]")),OI=e=>L1(e.querySelector("[data-animated-caption]")),TI=e=>L1(e.querySelector("[data-animated-weeks]")),Out=e=>L1(e.querySelector("[data-animated-nav]")),Tut=e=>L1(e.querySelector("[data-animated-weekdays]"));function Aut(e,t,{classNames:n,months:r,focused:i,dateLib:o}){let s=(0,Uy.useRef)(null),a=(0,Uy.useRef)(r),l=(0,Uy.useRef)(!1);(0,Uy.useLayoutEffect)(()=>{let u=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;let c=o.isSameMonth(r[0].date,u[0].date),d=o.isAfter(r[0].date,u[0].date),h=d?n[Os.caption_after_enter]:n[Os.caption_before_enter],f=d?n[Os.weeks_after_enter]:n[Os.weeks_before_enter],p=s.current,m=e.current.cloneNode(!0);if(m instanceof HTMLElement?(EI(m).forEach(v=>{if(!(v instanceof HTMLElement))return;let b=Eut(v);b&&v.contains(b)&&v.removeChild(b);let w=OI(v);w&&w.classList.remove(h);let x=TI(v);x&&x.classList.remove(f)}),s.current=m):s.current=null,l.current||c||i)return;let g=p instanceof HTMLElement?EI(p):[],y=EI(e.current);if(y?.every(v=>v instanceof HTMLElement)&&g&&g.every(v=>v instanceof HTMLElement)){l.current=!0;let v=[];e.current.style.isolation="isolate";let b=Out(e.current);b&&(b.style.zIndex="1"),y.forEach((w,x)=>{let S=g[x];if(!S)return;w.style.position="relative",w.style.overflow="hidden";let k=OI(w);k&&k.classList.add(h);let C=TI(w);C&&C.classList.add(f);let N=()=>{l.current=!1,e.current&&(e.current.style.isolation=""),b&&(b.style.zIndex=""),k&&k.classList.remove(h),C&&C.classList.remove(f),w.style.position="",w.style.overflow="",w.contains(S)&&w.removeChild(S)};v.push(N),S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");let E=Tut(S);E&&(E.style.opacity="0");let D=OI(S);D&&(D.classList.add(d?n[Os.caption_before_exit]:n[Os.caption_after_exit]),D.addEventListener("animationend",N));let q=TI(S);q&&q.classList.add(d?n[Os.weeks_before_exit]:n[Os.weeks_after_exit]),w.insertBefore(S,w.firstChild)})}})}function Dut(e,t,n,r){let i=e[0],o=e[e.length-1],{ISOWeek:s,fixedWeeks:a,broadcastCalendar:l}=n??{},{addDays:u,differenceInCalendarDays:c,differenceInCalendarMonths:d,endOfBroadcastWeek:h,endOfISOWeek:f,endOfMonth:p,endOfWeek:m,isAfter:g,startOfBroadcastWeek:y,startOfISOWeek:v,startOfWeek:b}=r,w=l?y(i,r):s?v(i):b(i),x=l?h(o):s?f(p(o)):m(p(o)),S=t&&(l?h(t):s?f(t):m(t)),k=S&&g(x,S)?S:x,C=c(k,w),N=d(o,i)+1,E=[];for(let q=0;q<=C;q++){let z=u(w,q);E.push(z)}let D=(l?35:42)*N;if(a&&E.length<D){let q=D-E.length;for(let z=0;z<q;z++){let _=u(E[E.length-1],1);E.push(_)}}return E}function Rut(e){let t=[];return e.reduce((n,r)=>{let i=r.weeks.reduce((o,s)=>o.concat(s.days.slice()),t.slice());return n.concat(i.slice())},t.slice())}function Iut(e,t,n,r){let{numberOfMonths:i=1}=n,o=[];for(let s=0;s<i;s++){let a=r.addMonths(e,s);if(t&&a>t)break;o.push(a)}return o}function UQ(e,t,n,r){let{month:i,defaultMonth:o,today:s=r.today(),numberOfMonths:a=1}=e,l=i||o||s,{differenceInCalendarMonths:u,addMonths:c,startOfMonth:d}=r;if(n&&u(n,l)<a-1){let h=-1*(a-1);l=c(n,h)}return t&&u(l,t)<0&&(l=t),d(l)}function Put(e,t,n,r){let{addDays:i,endOfBroadcastWeek:o,endOfISOWeek:s,endOfMonth:a,endOfWeek:l,getISOWeek:u,getWeek:c,startOfBroadcastWeek:d,startOfISOWeek:h,startOfWeek:f}=r,p=e.reduce((m,g)=>{let y=n.broadcastCalendar?d(g,r):n.ISOWeek?h(g):f(g),v=n.broadcastCalendar?o(g):n.ISOWeek?s(a(g)):l(a(g)),b=t.filter(k=>k>=y&&k<=v),w=n.broadcastCalendar?35:42;if(n.fixedWeeks&&b.length<w){let k=t.filter(C=>{let N=w-b.length;return C>v&&C<=i(v,N)});b.push(...k)}let x=b.reduce((k,C)=>{let N=n.ISOWeek?u(C):c(C),E=k.find(q=>q.weekNumber===N),D=new gfe(C,g,r);return E?E.days.push(D):k.push(new Rlt(N,[D])),k},[]),S=new Dlt(g,x);return m.push(S),m},[]);return n.reverseMonths?p.reverse():p}function Lut(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:o,startOfMonth:s,endOfMonth:a,addYears:l,endOfYear:u,newDate:c,today:d}=t,{fromYear:h,toYear:f,fromMonth:p,toMonth:m}=e;!n&&p&&(n=p),!n&&h&&(n=t.newDate(h,0,1)),!r&&m&&(r=m),!r&&f&&(r=c(f,11,31));let g=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=s(n):h?n=c(h,0,1):!n&&g&&(n=i(l(e.today??d(),-100))),r?r=a(r):f?r=c(f,11,31):!r&&g&&(r=u(e.today??d())),[n&&o(n),r&&o(r)]}function But(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:o=1}=n,{startOfMonth:s,addMonths:a,differenceInCalendarMonths:l}=r,u=i?o:1,c=s(e);if(!t||!(l(t,e)<o))return a(c,u)}function qut(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:o}=n,{startOfMonth:s,addMonths:a,differenceInCalendarMonths:l}=r,u=i?o??1:1,c=s(e);if(!t||!(l(c,t)<=0))return a(c,-u)}function zut(e){let t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function wO(e,t){let[n,r]=(0,tpe.useState)(e);return[t===void 0?n:t,r]}function Fut(e,t){let[n,r]=Lut(e,t),{startOfMonth:i,endOfMonth:o}=t,s=UQ(e,n,r,t),[a,l]=wO(s,e.month?s:void 0);(0,bO.useEffect)(()=>{let v=UQ(e,n,r,t);l(v)},[e.timeZone]);let{months:u,weeks:c,days:d,previousMonth:h,nextMonth:f}=(0,bO.useMemo)(()=>{let v=Iut(a,r,{numberOfMonths:e.numberOfMonths},t),b=Dut(v,e.endMonth?o(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),w=Put(v,b,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),x=zut(w),S=Rut(w),k=qut(a,n,e,t),C=But(a,r,e,t);return{months:w,weeks:x,days:S,previousMonth:k,nextMonth:C}},[t,a.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:p,onMonthChange:m}=e,g=v=>c.some(b=>b.days.some(w=>w.isEqualTo(v))),y=v=>{if(p)return;let b=i(v);n&&b<i(n)&&(b=i(n)),r&&b>i(r)&&(b=i(r)),l(b),m?.(b)};return{months:u,weeks:c,days:d,navStart:n,navEnd:r,previousMonth:h,nextMonth:f,goToMonth:y,goToDay:v=>{g(v)||y(v.date)}}}var eu;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(eu||(eu={}));function HQ(e){return!e[gr.disabled]&&!e[gr.hidden]&&!e[gr.outside]}function jut(e,t,n,r){let i,o=-1;for(let s of e){let a=t(s);HQ(a)&&(a[gr.focused]&&o<eu.FocusedModifier?(i=s,o=eu.FocusedModifier):r?.isEqualTo(s)&&o<eu.LastFocused?(i=s,o=eu.LastFocused):n(s.date)&&o<eu.Selected?(i=s,o=eu.Selected):a[gr.today]&&o<eu.Today&&(i=s,o=eu.Today))}return i||(i=e.find(s=>HQ(t(s)))),i}function Vut(e,t,n,r,i,o,s){let{ISOWeek:a,broadcastCalendar:l}=o,{addDays:u,addMonths:c,addWeeks:d,addYears:h,endOfBroadcastWeek:f,endOfISOWeek:p,endOfWeek:m,max:g,min:y,startOfBroadcastWeek:v,startOfISOWeek:b,startOfWeek:w}=s,x={day:u,week:d,month:c,year:h,startOfWeek:S=>l?v(S,s):a?b(S):w(S),endOfWeek:S=>l?f(S):a?p(S):m(S)}[e](n,t==="after"?1:-1);return t==="before"&&r?x=g([r,x]):t==="after"&&i&&(x=y([i,x])),x}function npe(e,t,n,r,i,o,s,a=0){if(a>365)return;let l=Vut(e,t,n.date,r,i,o,s),u=!!(o.disabled&&Ec(l,o.disabled,s)),c=!!(o.hidden&&Ec(l,o.hidden,s)),d=l,h=new gfe(l,d,s);return!u&&!c?h:npe(e,t,h,r,i,o,s,a+1)}function Wut(e,t,n,r,i){let{autoFocus:o}=e,[s,a]=(0,wq.useState)(),l=jut(t.days,n,r||(()=>!1),s),[u,c]=(0,wq.useState)(o?l:void 0);return{isFocusTarget:d=>!!l?.isEqualTo(d),setFocused:c,focused:u,blur:()=>{a(u),c(void 0)},moveFocus:(d,h)=>{if(!u)return;let f=npe(d,h,u,t.navStart,t.navEnd,e,i);f&&(e.disableNavigation&&!t.days.some(p=>p.isEqualTo(f))||(t.goToDay(f),c(f)))}}}function Uut(e,t){let{selected:n,required:r,onSelect:i}=e,[o,s]=wO(n,i?n:void 0),a=i?n:o,{isSameDay:l}=t,u=h=>a?.some(f=>l(f,h))??!1,{min:c,max:d}=e;return{selected:a,select:(h,f,p)=>{let m=[...a??[]];if(u(h)){if(a?.length===c||r&&a?.length===1)return;m=a?.filter(g=>!l(g,h))}else a?.length===d?m=[h]:m=[...m,h];return i||s(m),i?.(m,h,f,p),m},isSelected:u}}function Hut(e,t,n=0,r=0,i=!1,o=Du){let{from:s,to:a}=t||{},{isSameDay:l,isAfter:u,isBefore:c}=o,d;if(!s&&!a)d={from:e,to:n>0?void 0:e};else if(s&&!a)l(s,e)?n===0?d={from:s,to:e}:i?d={from:s,to:void 0}:d=void 0:c(e,s)?d={from:e,to:s}:d={from:s,to:e};else if(s&&a)if(l(s,e)&&l(a,e))i?d={from:s,to:a}:d=void 0;else if(l(s,e))d={from:s,to:n>0?void 0:e};else if(l(a,e))d={from:e,to:n>0?void 0:e};else if(c(e,s))d={from:e,to:a};else if(u(e,s))d={from:s,to:e};else if(u(e,a))d={from:s,to:e};else throw new Error("Invalid range");if(d?.from&&d?.to){let h=o.differenceInCalendarDays(d.to,d.from);r>0&&h>r?d={from:e,to:void 0}:n>1&&h<n&&(d={from:e,to:void 0})}return d}function $ut(e,t,n=Du){let r=Array.isArray(t)?t:[t],i=e.from,o=n.differenceInCalendarDays(e.to,e.from),s=Math.min(o,6);for(let a=0;a<=s;a++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function $Q(e,t,n=Du){return _c(e,t.from,!1,n)||_c(e,t.to,!1,n)||_c(t,e.from,!1,n)||_c(t,e.to,!1,n)}function Kut(e,t,n=Du){let r=Array.isArray(t)?t:[t];if(r.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?_c(e,o,!1,n):jfe(o,n)?o.some(s=>_c(e,s,!1,n)):vO(o)?o.from&&o.to?$Q(e,{from:o.from,to:o.to},n):!1:Ffe(o)?$ut(e,o.dayOfWeek,n):Q3(o)?n.isAfter(o.before,o.after)?$Q(e,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):Ec(e.from,o,n)||Ec(e.to,o,n):G3(o)||X3(o)?Ec(e.from,o,n)||Ec(e.to,o,n):!1))return!0;let i=r.filter(o=>typeof o=="function");if(i.length){let o=e.from,s=n.differenceInCalendarDays(e.to,e.from);for(let a=0;a<=s;a++){if(i.some(l=>l(o)))return!0;o=n.addDays(o,1)}}return!1}function Yut(e,t){let{disabled:n,excludeDisabled:r,selected:i,required:o,onSelect:s}=e,[a,l]=wO(i,s?i:void 0),u=s?i:a;return{selected:u,select:(c,d,h)=>{let{min:f,max:p}=e,m=c?Hut(c,u,f,p,o,t):void 0;return r&&n&&m?.from&&m.to&&Kut({from:m.from,to:m.to},n,t)&&(m.from=c,m.to=void 0),s||l(m),s?.(m,c,d,h),m},isSelected:c=>u&&_c(u,c,!1,t)}}function Qut(e,t){let{selected:n,required:r,onSelect:i}=e,[o,s]=wO(n,i?n:void 0),a=i?n:o,{isSameDay:l}=t;return{selected:a,select:(u,c,d)=>{let h=u;return!r&&a&&a&&l(u,a)&&(h=void 0),i||s(h),i?.(h,u,c,d),h},isSelected:u=>a?l(a,u):!1}}function Gut(e,t){let n=Qut(e,t),r=Uut(e,t),i=Yut(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return i;default:return}}function _s(e,t){return e instanceof da&&e.timeZone===t?e:new da(e,t)}function Gg(e,t,n){if(!n)return _s(e,t);let r=_s(e,t),i=new da(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function KQ(e,t,n){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?Gg(e,t,n):Array.isArray(e)?e.map(r=>r instanceof Date?Gg(r,t,n):r):vO(e)?{...e,from:e.from?_s(e.from,t):e.from,to:e.to?_s(e.to,t):e.to}:Q3(e)?{before:Gg(e.before,t,n),after:Gg(e.after,t,n)}:G3(e)?{after:Gg(e.after,t,n)}:X3(e)?{before:Gg(e.before,t,n)}:e}function AI(e,t,n){return e&&(Array.isArray(e)?e.map(r=>KQ(r,t,n)):KQ(e,t,n))}function Xut(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=_s(t.today,n)),t.month&&(t.month=_s(t.month,n)),t.defaultMonth&&(t.defaultMonth=_s(t.defaultMonth,n)),t.startMonth&&(t.startMonth=_s(t.startMonth,n)),t.endMonth&&(t.endMonth=_s(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=_s(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(ge=>_s(ge,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?_s(t.selected.from,n):t.selected.from,to:t.selected.to?_s(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=AI(t.disabled,n)),t.hidden!==void 0&&(t.hidden=AI(t.hidden,n)),t.modifiers)){let ge={};Object.keys(t.modifiers).forEach(Be=>{ge[Be]=AI(t.modifiers?.[Be],n)}),t.modifiers=ge}let{components:r,formatters:i,labels:o,dateLib:s,locale:a,classNames:l}=(0,at.useMemo)(()=>{let ge={...mfe,...t.locale},Be=t.broadcastCalendar?1:t.weekStartsOn,ye=t.noonSafe&&t.timeZone?_ut(t.timeZone,{weekStartsOn:Be,locale:ge}):void 0,De=t.dateLib&&ye?{...ye,...t.dateLib}:t.dateLib??ye,gt=new Au({locale:ge,weekStartsOn:Be,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},De);return{dateLib:gt,components:lut(t.components),formatters:vut(t.formatters),labels:Sut(t.labels,gt.options),locale:ge,classNames:{...cut(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:s.today()});let{captionLayout:u,mode:c,navLayout:d,numberOfMonths:h=1,onDayBlur:f,onDayClick:p,onDayFocus:m,onDayKeyDown:g,onDayMouseEnter:y,onDayMouseLeave:v,onNextClick:b,onPrevClick:w,showWeekNumber:x,styles:S}=t,{formatCaption:k,formatDay:C,formatMonthDropdown:N,formatWeekNumber:E,formatWeekNumberHeader:D,formatWeekdayName:q,formatYearDropdown:z}=i,_=Fut(t,s),{days:R,months:T,navStart:B,navEnd:A,previousMonth:M,nextMonth:P,goToMonth:F}=_,I=sut(R,t,B,A,s),{isSelected:V,select:W,selected:j}=Gut(t,s)??{},{blur:X,focused:$,isFocusTarget:K,moveFocus:Q,setFocused:J}=Wut(t,_,I,V??(()=>!1),s),{labelDayButton:oe,labelGridcell:be,labelGrid:Me,labelMonthDropdown:Je,labelNav:Ve,labelPrevious:Ct,labelNext:He,labelWeekday:de,labelWeekNumber:ie,labelWeekNumberHeader:ze,labelYearDropdown:Le}=o,Oe=(0,at.useMemo)(()=>Nut(s,t.ISOWeek,t.broadcastCalendar,t.today),[s,t.ISOWeek,t.broadcastCalendar,t.today]),rt=c!==void 0||p!==void 0,Ht=(0,at.useCallback)(()=>{M&&(F(M),w?.(M))},[M,F,w]),$t=(0,at.useCallback)(()=>{P&&(F(P),b?.(P))},[F,P,b]),dt=(0,at.useCallback)((ge,Be)=>ye=>{ye.preventDefault(),ye.stopPropagation(),J(ge),!Be.disabled&&(W?.(ge.date,Be,ye),p?.(ge.date,Be,ye))},[W,p,J]),et=(0,at.useCallback)((ge,Be)=>ye=>{J(ge),m?.(ge.date,Be,ye)},[m,J]),pt=(0,at.useCallback)((ge,Be)=>ye=>{X(),f?.(ge.date,Be,ye)},[X,f]),nn=(0,at.useCallback)((ge,Be)=>ye=>{let De={ArrowLeft:[ye.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[ye.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[ye.shiftKey?"year":"week","after"],ArrowUp:[ye.shiftKey?"year":"week","before"],PageUp:[ye.shiftKey?"year":"month","before"],PageDown:[ye.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(De[ye.key]){ye.preventDefault(),ye.stopPropagation();let[gt,ce]=De[ye.key];Q(gt,ce)}g?.(ge.date,Be,ye)},[Q,g,t.dir]),Dt=(0,at.useCallback)((ge,Be)=>ye=>{y?.(ge.date,Be,ye)},[y]),Ot=(0,at.useCallback)((ge,Be)=>ye=>{v?.(ge.date,Be,ye)},[v]),Kt=(0,at.useCallback)(ge=>Be=>{let ye=Number(Be.target.value),De=s.setMonth(s.startOfMonth(ge),ye);F(De)},[s,F]),Er=(0,at.useCallback)(ge=>Be=>{let ye=Number(Be.target.value),De=s.setYear(s.startOfMonth(ge),ye);F(De)},[s,F]),{className:Dn,style:Zn}=(0,at.useMemo)(()=>({className:[l[We.Root],t.className].filter(Boolean).join(" "),style:{...S?.[We.Root],...t.style}}),[l,t.className,t.style,S]),Un=uut(t),he=(0,at.useRef)(null);Aut(he,!!t.animate,{classNames:l,months:T,focused:$,dateLib:s});let Ae={dayPickerProps:t,selected:j,select:W,isSelected:V,months:T,nextMonth:P,previousMonth:M,goToMonth:F,getModifiers:I,components:r,classNames:l,styles:S,labels:o,formatters:i};return at.default.createElement(Efe.Provider,{value:Ae},at.default.createElement(r.Root,{rootRef:t.animate?he:void 0,className:Dn,style:Zn,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...Un},at.default.createElement(r.Months,{className:l[We.Months],style:S?.[We.Months]},!t.hideNavigation&&!d&&at.default.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[We.Nav],style:S?.[We.Nav],"aria-label":Ve(),onPreviousClick:Ht,onNextClick:$t,previousMonth:M,nextMonth:P}),T.map((ge,Be)=>at.default.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:l[We.Month],style:S?.[We.Month],key:Be,displayIndex:Be,calendarMonth:ge},d==="around"&&!t.hideNavigation&&Be===0&&at.default.createElement(r.PreviousMonthButton,{type:"button",className:l[We.PreviousMonthButton],tabIndex:M?void 0:-1,"aria-disabled":M?void 0:!0,"aria-label":Ct(M),onClick:Ht,"data-animated-button":t.animate?"true":void 0},at.default.createElement(r.Chevron,{disabled:M?void 0:!0,className:l[We.Chevron],orientation:t.dir==="rtl"?"right":"left"})),at.default.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:l[We.MonthCaption],style:S?.[We.MonthCaption],calendarMonth:ge,displayIndex:Be},u?.startsWith("dropdown")?at.default.createElement(r.DropdownNav,{className:l[We.Dropdowns],style:S?.[We.Dropdowns]},(()=>{let ye=u==="dropdown"||u==="dropdown-months"?at.default.createElement(r.MonthsDropdown,{key:"month",className:l[We.MonthsDropdown],"aria-label":Je(),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:Kt(ge.date),options:kut(ge.date,B,A,i,s),style:S?.[We.Dropdown],value:s.getMonth(ge.date)}):at.default.createElement("span",{key:"month"},N(ge.date,s)),De=u==="dropdown"||u==="dropdown-years"?at.default.createElement(r.YearsDropdown,{key:"year",className:l[We.YearsDropdown],"aria-label":Le(s.options),classNames:l,components:r,disabled:!!t.disableNavigation,onChange:Er(ge.date),options:Mut(B,A,i,s,!!t.reverseYears),style:S?.[We.Dropdown],value:s.getYear(ge.date)}):at.default.createElement("span",{key:"year"},z(ge.date,s));return s.getMonthYearOrder()==="year-first"?[De,ye]:[ye,De]})(),at.default.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},k(ge.date,s.options,s))):at.default.createElement(r.CaptionLabel,{className:l[We.CaptionLabel],role:"status","aria-live":"polite"},k(ge.date,s.options,s))),d==="around"&&!t.hideNavigation&&Be===h-1&&at.default.createElement(r.NextMonthButton,{type:"button",className:l[We.NextMonthButton],tabIndex:P?void 0:-1,"aria-disabled":P?void 0:!0,"aria-label":He(P),onClick:$t,"data-animated-button":t.animate?"true":void 0},at.default.createElement(r.Chevron,{disabled:P?void 0:!0,className:l[We.Chevron],orientation:t.dir==="rtl"?"left":"right"})),Be===h-1&&d==="after"&&!t.hideNavigation&&at.default.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:l[We.Nav],style:S?.[We.Nav],"aria-label":Ve(),onPreviousClick:Ht,onNextClick:$t,previousMonth:M,nextMonth:P}),at.default.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":c==="multiple"||c==="range","aria-label":Me(ge.date,s.options,s)||void 0,className:l[We.MonthGrid],style:S?.[We.MonthGrid]},!t.hideWeekdays&&at.default.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:l[We.Weekdays],style:S?.[We.Weekdays]},x&&at.default.createElement(r.WeekNumberHeader,{"aria-label":ze(s.options),className:l[We.WeekNumberHeader],style:S?.[We.WeekNumberHeader],scope:"col"},D()),Oe.map(ye=>at.default.createElement(r.Weekday,{"aria-label":de(ye,s.options,s),className:l[We.Weekday],key:String(ye),style:S?.[We.Weekday],scope:"col"},q(ye,s.options,s)))),at.default.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:l[We.Weeks],style:S?.[We.Weeks]},ge.weeks.map(ye=>at.default.createElement(r.Week,{className:l[We.Week],key:ye.weekNumber,style:S?.[We.Week],week:ye},x&&at.default.createElement(r.WeekNumber,{week:ye,style:S?.[We.WeekNumber],"aria-label":ie(ye.weekNumber,{locale:a}),className:l[We.WeekNumber],scope:"row",role:"rowheader"},E(ye.weekNumber,s)),ye.days.map(De=>{let{date:gt}=De,ce=I(De);if(ce[gr.focused]=!ce.hidden&&!!$?.isEqualTo(De),ce[ll.selected]=V?.(gt)||ce.selected,vO(j)){let{from:Nt,to:tt}=j;ce[ll.range_start]=!!(Nt&&tt&&s.isSameDay(gt,Nt)),ce[ll.range_end]=!!(Nt&&tt&&s.isSameDay(gt,tt)),ce[ll.range_middle]=_c(j,gt,!0,s)}let $e=Cut(ce,S,t.modifiersStyles),it=aut(ce,l,t.modifiersClassNames),Jt=!rt&&!ce.hidden?be(gt,ce,s.options,s):void 0;return at.default.createElement(r.Day,{key:`${De.isoDate}_${De.displayMonthId}`,day:De,modifiers:ce,className:it.join(" "),style:$e,role:"gridcell","aria-selected":ce.selected||void 0,"aria-label":Jt,"data-day":De.isoDate,"data-month":De.outside?De.dateMonthId:void 0,"data-selected":ce.selected||void 0,"data-disabled":ce.disabled||void 0,"data-hidden":ce.hidden||void 0,"data-outside":De.outside||void 0,"data-focused":ce.focused||void 0,"data-today":ce.today||void 0},!ce.hidden&&rt?at.default.createElement(r.DayButton,{className:l[We.DayButton],style:S?.[We.DayButton],type:"button",day:De,modifiers:ce,disabled:!ce.focused&&ce.disabled||void 0,"aria-disabled":ce.focused&&ce.disabled||void 0,tabIndex:K(De)?0:-1,"aria-label":oe(gt,ce,s.options,s),onClick:dt(De,ce),onBlur:pt(De,ce),onFocus:et(De,ce),onKeyDown:nn(De,ce),onMouseEnter:Dt(De,ce),onMouseLeave:Ot(De,ce)},C(gt,s.options,s)):!ce.hidden&&C(De.date,s.options,s))})))))))),t.footer&&at.default.createElement(r.Footer,{className:l[We.Footer],style:S?.[We.Footer],role:"status","aria-live":"polite"},t.footer)))}function ipe({className:e,classNames:t,showOutsideDays:n=!0,hideNavigation:r,...i}){let o=G("relative flex flex-col gap-4 sm:flex-row",i.monthsClassName),s=G("hidden",i.monthCaptionClassName),a=G("flex items-center justify-center gap-2 w-full",r?"w-full":"hidden",i.dropdownsClassName),l=G("pt-3 text-xs",i.footerClassName),u=G("flex",i.weekdaysClassName),c=G("w-9 text-xs font-normal text-muted-foreground",i.weekdayClassName),d=G("truncate text-xs font-medium",i.captionLabelClassName),h=G("mx-auto mt-4",i.monthGridClassName),f=G("mt-0 flex w-max items-start",i.weekClassName),p=G("flex size-9 flex-1 items-center justify-center p-0 text-xs",i.dayClassName),m=G(Zz({variant:"ghost"}),"size-8 rounded-md p-0 font-normal text-xs transition-none aria-selected:opacity-100",i.dayButtonClassName),g="bg-accent [&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground",y=G(g,"rounded-s-md",i.rangeStartClassName),v=G(g,"rounded-e-md",i.rangeEndClassName),b=G("bg-accent text-foreground! [&>button]:bg-transparent [&>button]:text-foreground! [&>button]:hover:bg-transparent [&>button]:hover:text-foreground!",i.rangeMiddleClassName),w=G("[&>button]:bg-primary [&>button]:text-primary-foreground [&>button]:hover:bg-primary [&>button]:hover:text-primary-foreground","[&[aria-selected]>button]:bg-primary [&[aria-selected]>button]:text-primary-foreground",i.selectedClassName),x=G("[&>button]:font-bold [&>button]:text-accent-foreground",i.todayClassName),S=G("text-muted-foreground opacity-50 aria-selected:text-muted-foreground aria-selected:opacity-30",i.outsideClassName),k=G("text-muted-foreground opacity-50",i.disabledClassName),C=G("invisible flex-1",i.hiddenClassName);return(0,rpe.jsx)(Xut,{mode:"single",captionLayout:"label",hideNavigation:!0,showOutsideDays:n,className:G("p-0 text-xs",e),classNames:{caption_label:d,day:p,day_button:m,dropdowns:a,footer:l,month:i.monthClassName,month_caption:s,month_grid:h,months:o,week:f,weekday:c,weekdays:u,range_end:v,range_middle:b,range_start:y,disabled:k,hidden:C,outside:S,today:x,selected:w,nav:"hidden",...t},...i})}ipe.displayName="Calendar";function B1(e){let{initialValue:t,stateKey:n}=e,r=Q_("studio-input"),i=n??r,[o,s]=En(i,t??"",{cleanupOnUnmount:!0});return{handleOnChange:a=>{s(a.target.value)},value:o,setValue:s}}bo.default.extend(nat.default);var Jut=bo.default.months(),DI=new Date(0),RI=new Date(864e13);function Zut(e=new Date){let t=-e.getTimezoneOffset(),n=t>=0?"+":"-",r=Math.abs(t),i=String(Math.floor(r/60)).padStart(2,"0"),o=String(r%60).padStart(2,"0");return`UTC${n}${i}:${o}`}function ect(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{datatype:l,defaultValue:u,fkColumn:c,isRequired:d}=t,{format:h,group:f}=l;if(!h)throw new Error("DateInput requires a format in the datatype.");let p=a==null?d&&!c?Ju(h):"":String(a),m=n==="insert"&&u!=null?void 0:d&&!c?Ju(h):null,g=(0,hv.useMemo)(()=>{let K=(0,bo.default)(p);return K.isValid()?K.toDate():new Date},[p]),y=Q_("date-input"),[v,b]=En(`${y}:selected-date`,g,{cleanupOnUnmount:!0}),[w,x]=En(`${y}:current-month`,g,{cleanupOnUnmount:!0}),[S,k]=En(`${y}:hour`,(0,bo.default)(g).format("HH"),{cleanupOnUnmount:!0}),[C,N]=En(`${y}:minute`,(0,bo.default)(g).format("mm"),{cleanupOnUnmount:!0}),[E,D]=En(`${y}:second`,(0,bo.default)(g).format("ss"),{cleanupOnUnmount:!0}),{handleOnChange:q,setValue:z,value:_}=B1({initialValue:p,stateKey:`${y}:input`}),R=f==="time"||h.includes(":"),T=(0,hv.useMemo)(()=>Zut(),[]),B=K=>{q(K);try{let Q=(0,bo.default)(K.target.value);if(!Q.isValid())return;let J=Q.toDate();b(J),x(J),R&&(k(Q.format("HH")),N(Q.format("mm")),D(Q.format("ss")))}catch{}},A=K=>{if(!K)return;let Q=(0,bo.default)(K);if(R){let oe=(0,bo.default)(v??new Date);Q=Q.hour(oe.hour()).minute(oe.minute()).second(oe.second()).millisecond(oe.millisecond()),v==null&&(k(oe.format("HH")),N(oe.format("mm")),D(oe.format("ss")))}let J=Q.toDate();b(J),x(J),z(Q.format(h))},{handleCancel:M,handleKeyDown:P,handleSave:F}=Sm({onNavigate:r,onSave:()=>{let K=!_&&d&&!c?Ju(h):(0,bo.default)(_).format(h),Q=(0,bo.default)(p).format(h);return K!==Q?(i(_||m),!0):!1}}),I=w.getMonth().toString(),[V,W]=En(`${y}:year`,w.getFullYear().toString(),{cleanupOnUnmount:!0}),j=K=>{let Q=(0,bo.default)(v);v&&(K.hour!==void 0||K.minute!==void 0||K.second!==void 0)&&K.year===void 0&&K.month===void 0&&K.day===void 0?Q=(0,bo.default)(v):!v&&(K.hour!==void 0||K.minute!==void 0||K.second!==void 0)&&(Q=(0,bo.default)(w));let J=Q.set("year",K.year??Q.year()).set("month",K.month??Q.month()).set("date",K.day??Q.date()).set("hour",K.hour??(R?Q.hour():0)).set("minute",K.minute??(R?Q.minute():0)).set("second",K.second??(R?Q.second():0));b(J.toDate()),(K.year!==void 0||K.month!==void 0)&&x(J.toDate()),z(J.format(h)),K.year!==void 0&&W(String(K.year)),R&&(K.hour!==void 0&&k(String(K.hour).padStart(2,"0")),K.minute!==void 0&&N(String(K.minute).padStart(2,"0")),K.second!==void 0&&D(String(K.second).padStart(2,"0")))},X=K=>{let Q=K.target.value;W(Q);let J=Number(Q);J>=DI.getFullYear()&&J<=RI.getFullYear()&&j({year:J})},$=(K,Q)=>{let J=parseInt(Q);if(isNaN(J))return;let oe=K==="hour"?J:parseInt(S),be=K==="minute"?J:parseInt(C),Me=K==="second"?J:parseInt(E);K==="hour"&&k(Q.padStart(2,"0")),K==="minute"&&N(Q.padStart(2,"0")),K==="second"&&D(Q.padStart(2,"0"));let Je=K==="hour"&&Q.length>=1&&J>=0&&J<=23,Ve=K==="minute"&&Q.length>=1&&J>=0&&J<=59,Ct=K==="second"&&Q.length>=1&&J>=0&&J<=59;(K==="hour"&&Je||K==="minute"&&Ve||K==="second"&&Ct)&&j({hour:oe,minute:be,second:Me})};return(0,hv.useEffect)(()=>{if(!v)return;let K=(0,bo.default)(v);W(K.year().toString()),R&&(k(K.format("HH")),N(K.format("mm")),D(K.format("ss")))},[R,v]),(0,hv.useEffect)(()=>{!w||v||W(w.getFullYear().toString())},[w,v]),(0,pr.jsxs)("div",{onKeyDown:P,children:[(0,pr.jsx)("div",{className:"flex items-center pr-(--studio-cell-spacing)",children:(0,pr.jsx)(Fi,{"aria-required":d,className:"cell-input-leading border-none shadow-none focus-visible:ring-0 resize-none px-(--studio-cell-spacing)",onChange:B,placeholder:h,required:d,type:"text",value:_})}),(0,pr.jsxs)("div",{className:"flex flex-col gap-0 p-2 border-t border-table-border",children:[(0,pr.jsxs)("div",{className:"flex items-center justify-between mb-1 gap-2",children:[(0,pr.jsxs)(Zne,{onValueChange:K=>j({month:parseInt(K)}),value:I,children:[(0,pr.jsx)(c5,{className:"text-xs data-[state=open]:border-primary shadow-none",children:(0,pr.jsx)(ere,{placeholder:"Month"})}),(0,pr.jsx)(d5,{children:Jut.map((K,Q)=>(0,pr.jsx)(Bw,{value:String(Q),children:K},Q))})]}),(0,pr.jsx)(Fi,{className:"text-xs w-20 text-right shadow-none",max:RI.getFullYear(),min:DI.getFullYear(),onChange:X,placeholder:"YYYY",type:"number",value:V})]}),(0,pr.jsx)(ipe,{captionLayout:"dropdown",className:"w-full",disabled:o,endMonth:RI,mode:"single",month:w,onMonthChange:x,onSelect:A,selected:v,startMonth:DI}),R&&(0,pr.jsxs)("div",{className:"mt-1",children:[(0,pr.jsxs)("div",{className:"flex items-center justify-start gap-1",children:[(0,pr.jsx)(Fi,{className:"text-xs w-16 text-right shadow-none",type:"number",value:S,onChange:K=>$("hour",K.target.value),placeholder:"HH",min:0,max:23,maxLength:2,disabled:o}),(0,pr.jsx)("span",{className:"text-xs text-muted-foreground",children:":"}),(0,pr.jsx)(Fi,{className:"text-xs w-16 text-right shadow-none",type:"number",value:C,onChange:K=>$("minute",K.target.value),placeholder:"mm",min:0,max:59,maxLength:2,disabled:o}),(0,pr.jsx)("span",{className:"text-xs text-muted-foreground",children:":"}),(0,pr.jsx)(Fi,{className:"text-xs w-16 text-right shadow-none ",type:"number",value:E,onChange:K=>$("second",K.target.value),placeholder:"ss",min:0,max:59,maxLength:2,disabled:o})]}),(0,pr.jsxs)("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Editing in local time (",T,")"]})]})]}),(0,pr.jsx)(km,{disabled:o,onCancel:M,onSave:F,saveText:_?void 0:`Set to ${m===null?"NULL":m===void 0?"default value":"Date(0)"}`,showSave:s})]})}function tct(e){let{column:t,context:n,onNavigate:r,onSubmit:i,options:o,readonly:s,showSaveAction:a,value:l}=e,{defaultValue:u,nullable:c}=t,d=Q_("enum-input"),[h,f]=En(d,l==null?l:String(l),{cleanupOnUnmount:!0}),{handleSave:p,handleCancel:m,handleKeyDown:g}=Sm({onNavigate:r,onSave:()=>h!==l?(i(h),!0):!1}),y=v=>G(ore({variant:v===h?"default":"outline"}),"focus:ring-accent-foreground focus:ring-offset-background focus:ring-offset-1");return(0,Es.jsxs)("div",{onKeyDown:g,children:[(0,Es.jsx)("div",{className:"flex items-center gap-2 h-(--studio-cell-height) px-2 py-0 w-full text-sm text-muted-foreground",children:h===null?(0,Es.jsx)("span",{className:"italic",children:"(NULL)"}):h===void 0?(0,Es.jsx)("span",{className:"italic",children:"(default value)"}):h}),(0,Es.jsxs)("div",{className:"flex flex-row flex-wrap gap-2 p-2 min-w-(--radix-popover-trigger-width) max-w-[300px] w-full border-t border-table-border overflow-y-scroll max-h-32",children:[c?(0,Es.jsx)("button",{className:y(null),disabled:s,onClick:()=>f(null),children:(0,Es.jsx)("span",{className:"italic",children:"(NULL)"})},"__PS_NULL__"):null,n==="insert"&&u!=null?(0,Es.jsx)("button",{className:y(void 0),disabled:s,onClick:()=>f(void 0),children:(0,Es.jsx)("span",{className:"italic",children:"(default value)"})},"__PS_DEFAULT_VALUE__"):null,o.map(v=>(0,Es.jsx)("button",{className:y(v),disabled:s,onClick:()=>f(v),children:v},v))]}),(0,Es.jsx)(km,{disabled:s,onCancel:m,onSave:p,showSave:a})]})}function nct(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{datatype:l,defaultValue:u,fkColumn:c,isRequired:d,nullable:h}=t,{isArray:f}=l,p=(0,ope.useMemo)(()=>a==null?n==="insert"&&d&&!c?f?hg:Yf:"":JSON.stringify(a,null,2),[n,c,f,d,a]),m=n==="insert"&&u!=null?void 0:h?null:f?hg:Yf,{handleOnChange:g,value:y}=B1({initialValue:p}),{handleSave:v,handleCancel:b,handleKeyDown:w}=Sm({onNavigate:r,onSave:()=>(!y&&d&&!c?f?hg:Yf:y)!==p?(i(y?JSON.parse(y):m&&(f?[]:{})),!0):!1});return(0,Hy.jsxs)("div",{onKeyDown:w,children:[(0,Hy.jsx)("div",{className:"flex flex-row items-center gap-4 py-0",children:(0,Hy.jsx)("textarea",{"aria-disabled":o,"aria-required":d,className:"cell-input-base appearance-none w-full border-none outline-none shadow-none bg-transparent focus-visible:ring-0 resize px-(--studio-cell-spacing)",disabled:o,lang:"en_EN",onChange:g,required:d,rows:5,value:y})}),(0,Hy.jsx)(km,{disabled:o,onCancel:b,onSave:v,saveText:y?void 0:m===null?"Set null":m===void 0?"Set default":`Set '${m}'`,showSave:s})]})}function rct(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{defaultValue:l,fkColumn:u,isRequired:c}=t,d=a==null?c&&!u?String(eb):"":String(a),h=n==="insert"&&l!=null?void 0:c&&!u?0:null,{setValue:f,value:p}=B1({initialValue:d}),{handleSave:m,handleCancel:g,handleKeyDown:y}=Sm({onNavigate:r,onSave:()=>(!p&&c&&!u?String(eb):p)!==d?(i(p===""?h:Number(p)),!0):!1});return(0,Wp.jsxs)("div",{onKeyDown:y,children:[(0,Wp.jsxs)("div",{className:"flex flex-row items-center h-(--studio-cell-height) gap-4 py-0",children:[(0,Wp.jsx)(lO,{htmlFor:"numeric-input",className:"sr-only",children:"Numeric"}),(0,Wp.jsx)("input",{"aria-required":c,className:"cell-input-leading appearance-none w-full border-none outline-none shadow-none bg-transparent focus-visible:ring-0 resize-none px-(--studio-cell-spacing)",disabled:o,inputMode:"numeric",lang:"en_EN",onChange:v=>f(v.target.value),pattern:"\\d*",required:c,step:"any",type:"text",value:p})]}),(0,Wp.jsx)(km,{disabled:o,onCancel:g,onSave:m,saveText:p===""?`Set to ${h===null?"NULL":h===void 0?"default value":h}`:void 0,showSave:s})]})}function ict(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{defaultValue:l,isRequired:u,nullable:c}=t,d=a==null?"":String(a),h=n==="insert"&&l!=null?void 0:c?null:"",{handleOnChange:f,value:p}=B1({initialValue:d}),{handleSave:m,handleCancel:g,handleKeyDown:y}=Sm({onNavigate:r,onSave:()=>p!==d?(i(p||h),!0):!1});return(0,Yx.jsxs)("div",{onKeyDown:y,children:[(0,Yx.jsx)(Fi,{"aria-required":u,className:"cell-input-leading border-none shadow-none focus-visible:ring-0 resize-none px-(--studio-cell-spacing)",disabled:o,onChange:f,required:u,type:"text",value:p}),(0,Yx.jsx)(km,{disabled:o,onCancel:g,onSave:m,saveText:p?void 0:`Set to ${h===null?"NULL":h===void 0?"default value":h===""?"empty string":h}`,showSave:s})]})}var eF=Dl(bk(),1),oct=Dl(WMe(),1);eF.default.extend(oct.default);function sct(e){let{column:t,context:n,onNavigate:r,onSubmit:i,readonly:o,showSaveAction:s,value:a}=e,{datatype:l,fkColumn:u,isRequired:c}=t,{format:d}=l;if(!d)throw new Error("TimeInput requires a format in the datatype.");let h=a==null?c&&!u?Ju(d):"":String(a),f=n==="insert"&&t.defaultValue!=null?void 0:c&&!u?Ju(d):null,{handleOnChange:p,value:m}=B1({initialValue:h}),g=(0,spe.useMemo)(()=>{try{if(!m.includes(":"))return m;let w=/[+-]\d{2}(:\d{2})?$/.test(m),x=(0,eF.default)(`2000-01-01 ${m}`);if(x.isValid())return x.format("h:mm A")+(w?` (${x.format("Z")})`:"");let S=/(\d{1,2}):(\d{2}):(\d{2})(?:\.\d+)?([+-]\d{2}(?::\d{2})?)?/,k=m.match(S);if(k){let C=parseInt(k[1]||"12",10),N=k[2]||"00",E=k[4]||"",D=C>=12?"PM":"AM";return`${C%12===0?12:C%12}:${N} ${D}${E?` (${E})`:""}`}return m}catch{return m}},[m]),{handleCancel:y,handleKeyDown:v,handleSave:b}=Sm({onNavigate:r,onSave:()=>{let w=!m&&c&&!u?Ju(d):YQ(m,d),x=YQ(h,d);return w!==x?(i(m||f),!0):!1}});return(0,gh.jsxs)("div",{onKeyDown:v,children:[(0,gh.jsx)(Fi,{"aria-required":c,className:"cell-input-leading border-none shadow-none focus-visible:ring-0 resize-none px-(--studio-cell-spacing)",onChange:p,placeholder:d,required:c,type:"text",value:m}),m&&m!==g?(0,gh.jsxs)("div",{className:"flex flex-col gap-1 p-2 border-t border-table-border",children:[(0,gh.jsx)("div",{className:"text-xs text-muted-foreground",children:"Formatted value"}),(0,gh.jsx)("div",{className:"text-xs font-mono text-foreground",children:g})]}):null,(0,gh.jsx)(km,{disabled:o,onCancel:y,onSave:b,saveText:m?void 0:`Set to ${f===null?"NULL":f===void 0?"default value":f}`,showSave:s})]})}function YQ(e,t){return(0,eF.default)(`${new Date(0).toDateString()} ${e}`).format(t)}function ape(e){let{cell:t,column:n,context:r,onNavigate:i,onSubmit:o,showSaveAction:s}=e,{datatype:a,isAutoincrement:l,isComputed:u,nullable:c}=n,{format:d,group:h,isArray:f,options:p}=a,m=e.readonly||l||u,g=t.getValue();return f||h==="json"?(0,Jd.jsx)(nct,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:g}):h==="datetime"&&d?(0,Jd.jsx)(ect,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:g}):h==="time"&&d?(0,Jd.jsx)(sct,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:g}):h==="boolean"?(0,Jd.jsx)(tat,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:g}):h==="enum"&&(c||p?.length>0)?(0,Jd.jsx)(tct,{column:n,context:r,onNavigate:i,onSubmit:o,options:p,readonly:m,showSaveAction:s,value:g}):h==="numeric"?(0,Jd.jsx)(rct,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:g}):(0,Jd.jsx)(ict,{column:n,context:r,onNavigate:i,onSubmit:o,readonly:m,showSaveAction:s,value:XB(g)?JSON.stringify(g):g})}var uy="Search rows",cy="Filter with AI",act=[uy,cy];function Kd(e){let{label:t,query:n}=e,r=n.trim();if(r.length===0)return{kind:"focus",payload:""};let i=t.toLowerCase(),o=r.toLowerCase();if(act.some(s=>s.toLowerCase().startsWith(o)))return{kind:"focus",payload:""};if(o.startsWith(`${i} `)){let s=r.slice(t.length).trim();return{kind:s.length>0?"execute":"focus",payload:s}}return{kind:"execute",payload:r}}function lct(e){let{canGoToNextPage:t,canGoToPreviousPage:n,hasAiFilter:r,hasStagedChanges:i,isInsertingDisabled:o,onDiscardStagedChanges:s,onFocusFilterWithAi:a,onFocusSearch:l,onGoToNextPage:u,onGoToPreviousPage:c,onInsertRow:d,onRefresh:h,onRunFilterWithAi:f,onRunSearch:p,onSaveStagedChanges:m,saveStagedChangesLabel:g}=e;return[{disabled:i,id:"table.search.focus",icon:_h,keywords:["search","rows"],label:uy,onSelect:()=>l(),shouldShow:y=>Kd({label:uy,query:y}).kind==="focus"},{disabled:i,id:"table.search.execute",icon:_h,keywords:["search","rows"],label:y=>`Search rows: ${Kd({label:uy,query:y}).payload}`,onSelect:y=>p(Kd({label:uy,query:y}).payload),shouldShow:y=>Kd({label:uy,query:y}).kind==="execute"},{disabled:i,id:"table.filter-with-ai.focus",icon:IM,keywords:["filter","ai","llm","natural language"],label:cy,onSelect:()=>a(),shouldShow:y=>r&&Kd({label:cy,query:y}).kind==="focus"},{disabled:i,id:"table.filter-with-ai.execute",icon:IM,keywords:["filter","ai","llm","natural language"],label:y=>`Filter with AI: ${Kd({label:cy,query:y}).payload}`,onSelect:y=>f(Kd({label:cy,query:y}).payload),shouldShow:y=>r&&Kd({label:cy,query:y}).kind==="execute"},...i?[{id:"table.save-staged-changes",icon:D5e,keywords:["save","rows","staged","commit","write to db"],label:g,onSelect:()=>m()},{id:"table.discard-staged-changes",icon:H5e,keywords:["discard","edits","staged","cancel"],label:"Discard edits",onSelect:()=>s()}]:[],{disabled:o,id:"table.insert-row",icon:O5e,keywords:["insert","new row","create row"],label:"Insert row",onSelect:()=>d()},{id:"table.refresh",icon:Dz,keywords:["refresh","reload"],label:"Refresh table",onSelect:()=>h()},{disabled:i||!t,id:"table.next-page",icon:o1,keywords:["next","page","pagination"],label:"Next page",onSelect:()=>u()},{disabled:i||!n,id:"table.previous-page",icon:WZ,keywords:["previous","page","pagination","back"],label:"Previous page",onSelect:()=>c()}]}function uct(e){let{introspection:t,table:n}=e;if(!t||!n)return[];let r=Object.values(t.schemas).flatMap(s=>Object.values(s.tables).flatMap(a=>Object.values(a.columns).flatMap(l=>!l.fkColumn||!l.fkTable||l.fkSchema!=null&&l.fkSchema!==n.schema||l.fkTable!==n.name?[]:l.fkColumn in n.columns?{currentColumnName:l.fkColumn,sourceColumn:l.name,sourceSchema:a.schema,sourceTable:a.name}:[]))),i=new Map,o=new Map;return r.forEach(s=>{let a=`${s.sourceSchema}.${s.sourceTable}`;i.set(a,(i.get(a)??0)+1),o.set(s.sourceTable,(o.get(s.sourceTable)??0)+1)}),r.map(s=>{let a=`${s.sourceSchema}.${s.sourceTable}`,l=(o.get(s.sourceTable)??0)>1,u=(i.get(a)??0)>1,c=s.sourceTable;return(l||u)&&(c=`${s.sourceTable}_${s.sourceColumn}`),{...s,kind:"back-relation",name:c}}).sort((s,a)=>s.name.localeCompare(a.name))}function cct(e){return typeof e=="object"&&e!=null&&"kind"in e&&e.kind==="back-relation"&&"name"in e&&typeof e.name=="string"&&"currentColumnName"in e&&typeof e.currentColumnName=="string"&&"sourceColumn"in e&&typeof e.sourceColumn=="string"&&"sourceSchema"in e&&typeof e.sourceSchema=="string"&&"sourceTable"in e&&typeof e.sourceTable=="string"}function dct(e){let{hasMoreInfiniteRows:t,isInfiniteScrollEnabled:n,loadedInfinitePageCount:r,loadedRowCount:i,pendingRowTarget:o}=e;return!n||!t||o!=null&&i<o?null:25*(r+1)}var upe=zhe,cpe=Fhe,tF=lpe.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},i)=>(0,mM.jsx)(jhe,{children:(0,mM.jsx)("div",{className:"ps",children:(0,mM.jsx)(pO,{ref:i,align:t,sideOffset:n,className:G("z-50 w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 origin-(--radix-popover-content-transform-origin)",e),...r})})}));tF.displayName=pO.displayName;function QQ(e){let{dialect:t,table:n,whereClause:r}=e,i=ob(r);return`select * from ${fct(t,n)} where (${i})`}function hct(e){let{lintedSql:t,result:n,whereClause:r}=e,[i,o]=n;if(i)return i.message;let s=o.diagnostics[0];return s?pct({diagnosticFrom:s.from,lintedSql:t,message:s.message,whereClause:r}):null}function fct(e,t){let n=GQ(e,t.name);return t.schema?`${GQ(e,t.schema)}.${n}`:n}function GQ(e,t){return e==="mysql"?`\`${t.replaceAll("`","``")}\``:`"${t.replaceAll('"','""')}"`}function pct(e){let{diagnosticFrom:t,lintedSql:n,message:r,whereClause:i}=e;if(!mct(r))return r;let o=gct({diagnosticFrom:t,lintedSql:n,whereClause:i});return o?`${r}. Near: ${o}`:r}function mct(e){return/end of input|unexpected end|unterminated/i.test(e)}function gct(e){let{diagnosticFrom:t,lintedSql:n,whereClause:r}=e,i=ob(r);if(i.length===0)return null;let o=`(${i})`,s=n.lastIndexOf(o),a=s>=0?s+1:-1,l=a>=0?dpe(t-a,0,i.length):i.length,u=yct(i,l);return u?`WHERE ${u}`:null}function yct(e,t){if(e.length===0)return null;if(e.length<=32)return e;let n=dpe(t,0,e.length),r=Math.max(0,Math.min(n-16,e.length-32)),i=Math.min(e.length,r+32),o=r>0?"\u2026":"",s=i<e.length?"\u2026":"";return`${o}${e.slice(r,i)}${s}`}function dpe(e,t,n){return Math.min(n,Math.max(t,e))}var hpe=["=","!=",">",">=","<","<=","is","is not","like","not like","ilike","not ilike"];function fpe(e){let{filterOperators:t,now:n=new Date,request:r,table:i,timeZone:o}=e,s=t&&t.length>0?t:hpe,a=o??Intl.DateTimeFormat().resolvedOptions().timeZone??"UTC",l=Object.values(i.columns).map(u=>`- ${u.name}: ${u.datatype.name} (group: ${u.datatype.group}; supported operators: ${Cz(u,s).join(", ")})`);return["You convert a user's natural-language table filtering request into Prisma Studio filter JSON.",`Table: ${i.schema}.${i.name}`,"Columns:",...l,`Allowed operators: ${s.join(", ")}`,`Current local date and time: ${kct(n,a)} (timezone: ${a})`,`Current UTC date and time: ${n.toISOString()}`,"Return JSON only. Do not add markdown fences or commentary.",'Return this exact top-level shape: {"filters":[...]}','Each filter item must be either {"kind":"column","column":"column_name","operator":"=","value":"value"} or {"kind":"sql","sql":"raw SQL WHERE clause"}.',"Rules:","- Use only the listed columns.","- Use only the allowed operators.","- Return one or more filters.",'- Prefer kind "column" filters whenever possible.',`- Use kind "sql" only as a fallback when the user's request cannot be fully expressed with the predefined column filters above.`,'- Do not use kind "sql" as a shortcut for a request that can already be represented with the listed columns and operators.','- Operators "is" and "is not" are only valid for null checks and MUST use value null.',"- Comparison operators >, >=, <, and <= are only valid for numeric, date/time, and time columns.","- Text-search operators like, not like, ilike, and not ilike are only valid for text-like columns, enum columns, and text-like arrays.","- Boolean filters must use true or false.","- UUID filters must use valid UUID values.","- JSON filters must use valid JSON values, and array equality filters must use valid JSON arrays.","- SQL filters must be a single SQL WHERE clause fragment. A leading WHERE keyword is allowed but not required.","- Prefer ilike for case-insensitive text matching when the user implies partial text search.","- Resolve relative date phrases like today, yesterday, this month, and last year against the current timestamp above.",`User request: ${r}`].join(`
`)}function vct(e){let{issues:t,request:n,responseText:r,...i}=e,o=t.length>0?t.map(s=>{let a=s.filterIndex!=null?`- Filter ${s.filterIndex+1}`:"- Response",l=[s.column?`column=${s.column}`:null,s.operator?`operator=${s.operator}`:null,s.value!==void 0?`value=${s.value}`:null].filter(Boolean);return l.length>0?`${a} (${l.join(", ")}): ${s.message}`:`${a}: ${s.message}`}):["- The response was invalid. Return corrected filter JSON."];return[fpe({...i,request:n}),"Your previous response was invalid.",`Original user request: ${n}`,`Previous response: ${r}`,"Problems to fix:",...o,"Return corrected JSON only. Do not add markdown fences or commentary."].join(`
`)}async function bct(e){let{aiFilter:t,filterOperators:n,now:r,request:i,table:o,timeZone:s}=e,a=await t(fpe({filterOperators:n,now:r,request:i,table:o,timeZone:s})),l=XQ({filterOperators:n,responseText:a,table:o});if(l.issues.length===0)return{...l,filterGroup:PN(l.filterGroup,i),didRetry:!1,responseText:a};let u=await t(vct({filterOperators:n,issues:l.issues,now:r,request:i,responseText:a,table:o,timeZone:s})),c=XQ({filterOperators:n,responseText:u,table:o});return c.filterGroup.filters.length===0&&l.filterGroup.filters.length>0?{...l,filterGroup:PN(l.filterGroup,i),didRetry:!0,responseText:u}:{...c,filterGroup:PN(c.filterGroup,i),didRetry:!0,responseText:u}}function XQ(e){let{filterOperators:t,responseText:n,table:r}=e,i=wct(),o=new Set(t&&t.length>0?t:hpe),s=xct(n);if("issues"in s)return{filterGroup:i,issues:s.issues.map(l=>({...l,responseText:n}))};let a=[];for(let[l,u]of(s.filters??[]).entries()){if(u.kind==="sql"||u.kind===void 0&&typeof u.sql=="string"&&!Object.hasOwn(u,"column")){if(typeof u.sql!="string"){a.push({code:"invalid-response-shape",filterIndex:l,message:'SQL filters must include a string "sql" value.',responseText:n});continue}let p=cZ(u.sql),m=Yp(p,r.columns);m&&a.push({code:"invalid-filter-syntax",filterIndex:l,message:m.message,responseText:n,syntaxIssue:m,value:u.sql}),i.filters.push(p);continue}if(u.kind!==void 0&&u.kind!=="column"){a.push({code:"invalid-response-shape",filterIndex:l,message:'Filter kind must be "column" or "sql".',responseText:n});continue}if(typeof u.column!="string"||!r.columns[u.column]){a.push({code:"invalid-column",filterIndex:l,message:"Use one of the listed columns.",responseText:n,value:u.value===void 0?void 0:II(u.value)});continue}if(typeof u.operator!="string"||!nu(u.operator)||!o.has(u.operator)){a.push({code:"invalid-operator",column:u.column,filterIndex:l,message:"Use one of the allowed operators.",operator:typeof u.operator=="string"?u.operator:void 0,responseText:n,value:u.value===void 0?void 0:II(u.value)});continue}if(!Object.hasOwn(u,"value")){a.push({code:"missing-value",column:u.column,filterIndex:l,message:"Every filter must include a value.",operator:u.operator,responseText:n});continue}let c=r.columns[u.column],d=II(u.value),h=uZ(u.column);h.draftValue=d,h.operator=u.operator,h.value=Sz(c,u.operator,d);let f=Yp(h,r.columns);f&&a.push({code:"invalid-filter-syntax",column:u.column,filterIndex:l,message:f.message,operator:u.operator,responseText:n,syntaxIssue:f,value:d}),i.filters.push(h)}return i.filters.length===0&&a.push({code:"missing-filters",message:"AI response did not contain any valid filters.",responseText:n}),{filterGroup:i,issues:a}}function wct(){return{after:"and",filters:[],id:Pc.generate(),kind:"FilterGroup"}}function xct(e){let t=Sct(e.trim()),n;try{n=JSON.parse(t)}catch(r){return{issues:[{code:"invalid-json",message:r instanceof Error?`AI response was not valid JSON: ${r.message}`:"AI response was not valid JSON."}]}}return typeof n!="object"||n==null||Array.isArray(n)?{issues:[{code:"invalid-response-shape",message:"AI response must be a JSON object."}]}:"filters"in n&&(n.filters==null||!Array.isArray(n.filters))?{issues:[{code:"invalid-response-shape",message:'AI response must include a "filters" array.'}]}:n}function Sct(e){let t=e.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i),n=t?t[1].trim():e,r=n.indexOf("{"),i=n.lastIndexOf("}");return r>=0&&i>r?n.slice(r,i+1):n}function II(e){if(e===void 0)return"";if(e===null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function kct(e,t){let n=new Intl.DateTimeFormat("en-CA",{day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",month:"2-digit",second:"2-digit",timeZone:t,year:"numeric"}).formatToParts(e),r=Object.fromEntries(n.filter(i=>i.type!=="literal").map(i=>[i.type,i.value]));return`${r.year}-${r.month}-${r.day} ${r.hour}:${r.minute}:${r.second}`}async function ppe(e){let{aiFilter:t,applyEditingFilter:n,filterOperators:r,request:i,setEditingFilter:o,table:s}=e,a=i.trim();if(a.length===0)throw new Error("Please enter a filter request first.");let l=await bct({aiFilter:t,filterOperators:r,request:a,table:s}),u=l.filterGroup;if(u.filters.length===0)throw new Error(l.issues[0]?.message??"AI response did not contain any valid filters.");return o(u),n(u),u}var Cct=["=","!=",">",">=","<","<=","is","is not","like","not like","ilike","not ilike"],Nct=[{category:"Comparison",label:"Equal",value:"="},{category:"Comparison",label:"Not equal",value:"!="},{category:"Comparison",label:"Greater than",value:">"},{category:"Comparison",label:"Greater than or equal",value:">="},{category:"Comparison",label:"Less than",value:"<"},{category:"Comparison",label:"Less than or equal",value:"<="},{category:"Text Search",label:"Like",value:"like"},{category:"Text Search",label:"Not like",value:"not like"},{category:"Text Search",label:"Ilike",value:"ilike"},{category:"Text Search",label:"Not ilike",value:"not ilike"},{category:"Null Checks",label:"Is",value:"is"},{category:"Null Checks",label:"Is not",value:"is not"}];function JQ(e){return e.datatype.name}var mpe="SQL WHERE clause",gpe="Raw SQL";function ZQ(e){let t=e.trim().toLowerCase();return t.length===0?!0:[mpe,gpe,"sql","where"].join(" ").toLowerCase().includes(t)}function Mct(e){let{aiSourceQuery:t,issueMessage:n}=e,r=t?.trim();return!n&&!r?null:n?{isWarning:!0,primaryMessage:n,secondaryMessage:r}:{isWarning:!1,primaryMessage:r}}function ype(e){let{pillContent:t}=e,n=Mct(e);if(!n)return t;let{isWarning:r,primaryMessage:i,secondaryMessage:o}=n;return(0,fe.jsx)(RE,{delayDuration:120,children:(0,fe.jsxs)(IE,{children:[(0,fe.jsx)(PE,{asChild:!0,children:t}),(0,fe.jsx)(v1,{side:"bottom",className:G("max-w-[260px] px-2.5 py-1.5 text-xs shadow-sm",r?"border border-amber-300 bg-amber-100 text-amber-950":"border border-emerald-300 bg-emerald-100 text-emerald-950"),children:(0,fe.jsxs)("div",{className:"space-y-1",children:[(0,fe.jsx)("div",{children:i}),r&&o?(0,fe.jsx)("div",{className:"border-t border-amber-300/80 pt-1 text-[11px] text-amber-900/85",children:o}):null]})})]})})}function _ct(e){let{aiFilter:t,aiFocusRequestKey:n=0,applyEditingFilter:r,disabled:i=!1,editingFilter:o,filterOperators:s,onBlockedInteraction:a,setEditingFilter:l,table:u,totalEditingFilters:c}=e,[d,h]=(0,ut.useState)(!1),[f,p]=(0,ut.useState)(""),[m,g]=(0,ut.useState)(""),[y,v]=(0,ut.useState)(!1),[b,w]=(0,ut.useState)(!1),x=typeof t=="function",S=(0,ut.useRef)(null),k=(0,ut.useRef)(null),C=(0,ut.useMemo)(()=>Object.values(u.columns),[u.columns]),N=(0,ut.useMemo)(()=>{let M=f.trim().toLowerCase();return M.length===0?C:C.filter(P=>{let F=JQ(P);return P.name.toLowerCase().includes(M)||F.toLowerCase().includes(M)})},[C,f]);(0,ut.useEffect)(()=>{d&&(S.current?.focus(),S.current?.select())},[d]),(0,ut.useEffect)(()=>{!x||n===0||i||(v(!0),requestAnimationFrame(()=>{k.current?.focus(),k.current?.select()}))},[n,i,x]),(0,ut.useEffect)(()=>{i&&(h(!1),v(!1))},[i]);function E(){a?.()}function D(M){i&&(M.preventDefault(),M.stopPropagation(),E())}function q(M){if(i&&M){E();return}h(M)}function z(M){let P={...o,filters:[...o.filters,uZ(M)]};l(P),p(""),h(!1)}function _(){let M={...o,filters:[...o.filters,cZ()]};l(M),p(""),h(!1)}let R=y||m.trim().length>0||b,T=m.trim().length>0&&!b&&x,B=(0,fe.jsx)(cpe,{asChild:!0,children:(0,fe.jsxs)("button",{"aria-disabled":i||void 0,"aria-expanded":d,"aria-label":"Add filter",type:"button",className:G("flex h-9 shrink-0 items-center gap-1.5 bg-transparent px-3 text-sm text-foreground transition-colors focus-visible:outline-none",i&&"opacity-70",x?"border-r border-border/70 hover:bg-accent/50":"rounded-md border border-input shadow-sm hover:bg-accent",!x&&c>0&&"border-primary ring-1 ring-primary/15"),onClick:M=>{i&&(M.preventDefault(),M.stopPropagation(),E())},onMouseDown:D,children:[(0,fe.jsx)(IM,{className:"size-4"}),(0,fe.jsx)(Mv,{"data-testid":"table-filter-menu-chevron",className:"size-3.5 text-muted-foreground"})]})});async function A(){if(!t||i)return;let M=m.trim();if(!(M.length===0||b)){w(!0);try{await ppe({aiFilter:t,applyEditingFilter:r,filterOperators:s,request:M,setEditingFilter:l,table:u}),g(""),v(!1)}catch(P){Ey.error("AI filtering failed.",{description:P instanceof Error?P.message:String(P)})}finally{w(!1)}}}return(0,fe.jsx)("div",{"data-testid":"table-ai-filter-control",className:G("flex min-w-0 items-center",x&&R&&"flex-1"),children:(0,fe.jsxs)(upe,{open:d,onOpenChange:q,children:[x?(0,fe.jsxs)("div",{"data-testid":"table-filter-combo-shell",className:G("flex min-w-0 items-center overflow-hidden rounded-md border bg-background shadow-sm transition-[border-color,box-shadow,width,flex-basis] duration-150 ease-out",i&&"opacity-70",R?"flex-1":"w-[252px]",c>0||d?"border-primary ring-1 ring-primary/15":"border-input","focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/15"),children:[B,(0,fe.jsxs)("div",{className:G("flex min-w-0 items-center self-stretch",R?"flex-1":"w-[196px]"),children:[(0,fe.jsx)(Fi,{"aria-disabled":i||void 0,"aria-label":"Filter with AI",className:"h-9 min-w-0 flex-1 border-0 rounded-none bg-transparent px-3 py-0 text-sm shadow-none focus-visible:ring-0",onBlur:()=>{i||m.trim().length===0&&!b&&v(!1)},onChange:M=>{if(i){E();return}g(M.currentTarget.value)},onClick:()=>{i&&E()},onMouseDown:D,onFocus:()=>{if(i){k.current?.blur(),E();return}v(!0)},onKeyDown:M=>{if(i){E(),M.preventDefault();return}M.key==="Enter"&&(M.preventDefault(),A()),M.key==="Escape"&&m.trim().length===0&&!b&&(v(!1),k.current?.blur())},placeholder:"Filter with AI ...",ref:k,readOnly:i,value:m}),b?(0,fe.jsx)(jP,{className:"mr-3 size-3.5 shrink-0 animate-spin text-muted-foreground"}):T?(0,fe.jsx)("button",{"aria-label":"Apply AI filter",className:"mr-2.5 flex size-6 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-accent hover:text-foreground",onClick:()=>{A()},type:"button",children:(0,fe.jsx)(fm,{className:"size-3.5"})}):null]})]}):B,(0,fe.jsxs)(tF,{align:"start",side:"bottom",className:"w-[320px] max-w-[calc(100vw-2rem)] overflow-hidden p-0 font-sans",children:[(0,fe.jsx)("div",{className:"border-b border-border px-3 py-2",children:(0,fe.jsxs)("div",{className:"relative",children:[(0,fe.jsx)(_h,{className:"absolute left-0 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,fe.jsx)(Fi,{"aria-label":"Select column to filter",className:"h-8 border-0 pl-6 pr-0 text-sm shadow-none focus-visible:ring-0",onChange:M=>{p(M.currentTarget.value)},placeholder:"Select column to filter...",ref:S,value:f})]})}),(0,fe.jsx)("div",{className:"max-h-[280px] overflow-y-auto p-1.5",children:N.length===0&&!ZQ(f)?(0,fe.jsx)("div",{className:"px-2.5 py-4 text-xs text-muted-foreground",children:"No columns match this search."}):(0,fe.jsxs)(fe.Fragment,{children:[ZQ(f)?(0,fe.jsxs)("button",{type:"button",className:"mb-1 flex w-full items-center justify-between rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",onClick:_,children:[(0,fe.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5",children:[(0,fe.jsx)(HZ,{className:"size-3.5 text-muted-foreground"}),(0,fe.jsx)("span",{className:"truncate text-sm font-medium",children:mpe})]}),(0,fe.jsx)("span",{className:"truncate pl-3 text-xs text-muted-foreground",children:gpe})]}):null,N.map(M=>(0,fe.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>z(M.name),children:[(0,fe.jsxs)("span",{className:"flex min-w-0 items-center gap-2.5",children:[(0,fe.jsx)(Az,{className:"size-3.5 text-muted-foreground"}),(0,fe.jsx)("span",{className:"truncate text-sm font-medium",children:M.name})]}),(0,fe.jsx)("span",{className:"truncate pl-3 text-xs text-muted-foreground",children:JQ(M)})]},M.name))]})})]})]})})}function Ect(e){let{applyEditingFilter:t,disabled:n=!1,editingFilter:r,filterOperators:i,onBlockedInteraction:o,setEditingFilter:s,sqlFilterLint:a,table:l}=e;if(r.filters.length===0)return null;function u(f,p){let m={...r,filters:r.filters.map((g,y)=>y===f?p:g)};s(m)}function c(f){let p={...r,filters:r.filters.filter((m,g)=>g!==f)};s(p),t(p)}function d(f){!n||!eG(f.target)||(f.preventDefault(),f.stopPropagation(),o?.())}function h(f){!n||f.key==="Tab"||!eG(f.target)||(f.preventDefault(),f.stopPropagation(),o?.())}return(0,fe.jsx)("div",{"aria-disabled":n||void 0,"data-testid":"table-filter-row",className:"shrink-0 border-b border-table-border bg-table-head px-2 pt-1 pb-3",onClickCapture:d,onKeyDownCapture:h,onMouseDownCapture:d,children:(0,fe.jsx)("div",{"data-testid":"table-filter-pill-list",className:"flex flex-wrap items-center gap-1.5",children:r.filters.map((f,p)=>f.kind==="ColumnFilter"?(0,fe.jsx)(Oct,{applyEditingFilter:t,availableOperators:i,filter:f,onRemove:()=>c(p),onUpdate:m=>u(p,m),table:l},f.id):f.kind==="SqlFilter"?(0,fe.jsx)(Tct,{applyEditingFilter:t,filter:f,onRemove:()=>c(p),onUpdate:m=>u(p,m),sqlFilterLint:a,table:l},f.id):(0,fe.jsx)(Act,{filterGroup:f,onRemove:()=>c(p)},f.id))})})}function eG(e){return e instanceof Element&&e.closest("button, input, textarea, [role='button'], [role='combobox']")!=null}function Oct(e){let{applyEditingFilter:t,availableOperators:n,filter:r,onRemove:i,onUpdate:o,table:s}=e,[a,l]=(0,ut.useState)(r.operator===""),[u,c]=(0,ut.useState)(r.operator===""),[d,h]=(0,ut.useState)(!1),[f,p]=(0,ut.useState)(""),m=(0,ut.useRef)(null),g=(0,ut.useRef)(null),y=(0,ut.useRef)(null),v=(0,ut.useRef)(!1),b=(0,ut.useRef)(null),w=r.operator==="",x=s.columns[r.column],S=Yp(r,s.columns),k=a?null:S,C=typeof r.draftValue=="string"?r.draftValue:nu(r.operator)&&x?oZ(x,r.operator,r.value):"",N=C.length>0?C:"Empty",E=n&&n.length>0?n:Cct,D=(0,ut.useMemo)(()=>{let M=new Set(x?Cz(x,E):E),P=f.trim().toLowerCase();return Nct.filter(F=>M.has(F.value)?P.length===0?!0:F.label.toLowerCase().includes(P)||F.value.toLowerCase().includes(P):!1)},[x,f,E]);(0,ut.useEffect)(()=>{w&&l(!0)},[w]),(0,ut.useEffect)(()=>{!w&&!d||(m.current?.focus(),m.current?.select())},[d,w]);function q(){requestAnimationFrame(()=>{b.current?.focus(),b.current?.select()})}let z=(0,ut.useCallback)(()=>{nu(r.operator)&&(t(),c(!1),l(!1),h(!1))},[t,r.operator]),_=(0,ut.useCallback)(()=>{if(v.current=!1,u){i();return}nu(r.operator)&&t(),l(!1),h(!1)},[t,r.operator,u,i]);(0,ut.useEffect)(()=>{if(!a)return;function M(F){let I=F.target;I instanceof Node&&(y.current?.contains(I)||g.current?.contains(I)||_())}function P(F){F.key==="Escape"&&(F.preventDefault(),_())}return document.addEventListener("mousedown",M),document.addEventListener("keydown",P),()=>{document.removeEventListener("mousedown",M),document.removeEventListener("keydown",P)}},[_,a]);function R(M){!x||!nu(r.operator)||o({...r,draftValue:M.currentTarget.value,value:Sz(x,r.operator,M.currentTarget.value)})}function T(M){M.key==="Enter"&&(M.preventDefault(),z())}function B(M){v.current=!0,o({...r,operator:M}),p(""),l(!0),h(!1)}let A=(0,fe.jsxs)("div",{ref:y,"aria-invalid":k?!0:void 0,className:G("inline-flex max-w-full items-stretch overflow-hidden rounded-full border bg-background text-xs leading-none text-foreground font-sans shadow-sm",k?"border-amber-400 ring-1 ring-amber-300/80":"border-table-border"),"data-filter-ai-query":r.aiSource?.query,"data-filter-origin":r.aiSource?"ai":"manual","data-filter-syntax-state":k?"invalid":"valid","data-filter-syntax-message":k?.message,children:[(0,fe.jsxs)("div",{className:"flex h-6 min-h-0 min-w-0 items-center gap-1.5 border-r border-table-border px-2 py-0 text-foreground",children:[(0,fe.jsx)(Az,{className:G("size-3.5 shrink-0",k?"text-amber-500":"text-primary")}),(0,fe.jsx)("span",{className:"truncate font-semibold leading-none",children:r.column})]}),(0,fe.jsxs)(upe,{open:w||d,onOpenChange:M=>{w||h(M)},children:[(0,fe.jsx)(cpe,{asChild:!0,children:(0,fe.jsx)("button",{type:"button","aria-label":`Choose operator for ${r.column}`,className:"flex h-6 min-h-0 min-w-10 appearance-none items-center justify-center rounded-none border-0 border-r border-table-border bg-transparent px-2 py-0 text-[11px] leading-none font-sans font-medium text-foreground/80 shadow-none transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>{l(!0),h(!0)},children:r.operator||"Select operator..."})}),(0,fe.jsxs)(tF,{align:"start",className:"w-[320px] max-w-[calc(100vw-2rem)] overflow-hidden p-0 font-sans",ref:g,onCloseAutoFocus:M=>{v.current&&(M.preventDefault(),v.current=!1,q())},onOpenAutoFocus:M=>{M.preventDefault()},children:[(0,fe.jsx)("div",{className:"border-b border-border px-3 py-2",children:(0,fe.jsxs)("div",{className:"relative",children:[(0,fe.jsx)(_h,{className:"absolute left-0 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),(0,fe.jsx)(Fi,{"aria-label":"Select operator",className:"h-8 border-0 pl-6 pr-0 text-sm shadow-none focus-visible:ring-0",onChange:M=>{p(M.currentTarget.value)},placeholder:"Select operator...",ref:m,value:f})]})}),(0,fe.jsx)("div",{className:"max-h-[320px] overflow-y-auto p-1.5",children:D.length===0?(0,fe.jsx)("div",{className:"px-2.5 py-4 text-xs text-muted-foreground",children:"No operators match this search."}):["Comparison","Text Search","Null Checks"].map(M=>{let P=D.filter(F=>F.category===M);return P.length===0?null:(0,fe.jsxs)("div",{className:"pb-1.5 last:pb-0",children:[(0,fe.jsx)("div",{className:"px-2.5 py-1.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-muted-foreground",children:M}),P.map(F=>(0,fe.jsxs)("button",{type:"button",className:"flex w-full items-center justify-between rounded-lg px-2.5 py-2 text-left transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>B(F.value),children:[(0,fe.jsx)("span",{className:"text-sm font-medium",children:F.label}),(0,fe.jsx)("span",{className:"text-xs text-muted-foreground",children:F.value.toUpperCase()})]},F.value))]},M)})})]})]}),(0,fe.jsx)("div",{className:"min-w-16 border-r border-table-border",children:a?(0,fe.jsx)(Fi,{"aria-label":`Filter value for ${r.column}`,className:"h-6 min-h-0 rounded-none border-0 bg-transparent px-2 py-0 text-xs leading-none text-foreground font-sans font-normal shadow-none focus-visible:ring-0",disabled:!nu(r.operator),onChange:R,onKeyDown:T,placeholder:"Empty",ref:b,value:C}):(0,fe.jsx)("button",{type:"button",className:"flex h-6 min-h-0 w-full min-w-0 appearance-none items-center rounded-none border-0 bg-transparent px-2 py-0 text-left text-xs leading-none text-foreground font-sans shadow-none transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>{l(!0),q()},children:(0,fe.jsx)("span",{className:"truncate",children:N})})}),(0,fe.jsx)("button",{type:"button","aria-label":a?"Apply filter":"Remove filter",className:G("flex h-6 min-h-0 w-7 appearance-none items-center justify-center rounded-none border-0 bg-transparent px-1 py-0 leading-none font-sans shadow-none transition-colors",a?"text-foreground hover:bg-accent":"text-foreground hover:bg-destructive/10 hover:text-destructive"),disabled:a&&!nu(r.operator),onClick:()=>{if(a){z();return}i()},children:a?(0,fe.jsx)(fm,{className:"size-3.5"}):(0,fe.jsx)(X_,{className:"size-3.5"})})]});return ype({aiSourceQuery:r.aiSource?.query,issueMessage:k?.message,pillContent:A})}function Tct(e){let{applyEditingFilter:t,filter:n,onRemove:r,onUpdate:i,sqlFilterLint:o,table:s}=e,[a,l]=(0,ut.useState)(n.sql.trim().length===0),[u,c]=(0,ut.useState)(n.sql.trim().length===0),d=(0,ut.useRef)(null),h=(0,ut.useRef)({abortController:null,requestId:0}),f=(0,ut.useRef)(n),p=(0,ut.useRef)(null),m=Yp(n,s.columns),g=a?null:pBe(n,s.columns),y=n.sql.trim().length>0?n.sql:"Empty",v=(0,ut.useMemo)(()=>!o||m?null:[o.schemaVersion??"",QQ({dialect:o.dialect,table:s,whereClause:n.sql})].join("::"),[n.sql,o,m,s]);function b(){requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})}let w=(0,ut.useCallback)(()=>{t(),c(!1),l(!1)},[t]),x=(0,ut.useCallback)(()=>{if(u){r();return}t(),l(!1)},[t,u,r]);(0,ut.useEffect)(()=>{f.current=n},[n]),(0,ut.useEffect)(()=>{a&&b()},[a]),(0,ut.useEffect)(()=>{if(!a)return;function k(N){let E=N.target;E instanceof Node&&(d.current?.contains(E)||x())}function C(N){N.key==="Escape"&&(N.preventDefault(),x())}return document.addEventListener("mousedown",k),document.addEventListener("keydown",C),()=>{document.removeEventListener("mousedown",k),document.removeEventListener("keydown",C)}},[x,a]),(0,ut.useEffect)(()=>{if(!o||a||m||!v){h.current.abortController?.abort(),h.current.abortController=null;return}if(n.lint?.requestKey===v&&(n.lint.status==="invalid"||n.lint.status==="pending"||n.lint.status==="valid"))return;h.current.abortController?.abort();let k=new AbortController,C=h.current.requestId+1;h.current.abortController=k,h.current.requestId=C,i(tG(n,{issue:null,requestKey:v,status:"pending"}));let N=QQ({dialect:o.dialect,table:s,whereClause:n.sql});o.lintSql({schemaVersion:o.schemaVersion,sql:N},{abortSignal:k.signal}).then(E=>{if(k.signal.aborted||h.current.requestId!==C)return;h.current.abortController===k&&(h.current.abortController=null);let D=hct({lintedSql:N,result:E,whereClause:n.sql}),q=tG(f.current,{issue:D?{code:"sql-lint-error",message:D}:null,requestKey:v,status:D?"invalid":"valid"});i(q)})},[t,n,a,i,o,v,m,s]),(0,ut.useEffect)(()=>{let k=h.current;return()=>{let C=k.abortController;C?.abort(),k.abortController===C&&(k.abortController=null)}},[]);let S=(0,fe.jsxs)("div",{ref:d,"aria-invalid":g?!0:void 0,className:G("inline-flex max-w-full items-stretch overflow-hidden rounded-full border bg-background text-xs leading-none text-foreground font-sans shadow-sm",g?"border-amber-400 ring-1 ring-amber-300/80":"border-table-border"),"data-filter-ai-query":n.aiSource?.query,"data-filter-origin":n.aiSource?"ai":"manual","data-filter-syntax-state":g?"invalid":"valid","data-filter-syntax-message":g?.message,children:[(0,fe.jsxs)("div",{className:"flex h-6 min-h-0 items-center gap-1.5 border-r border-table-border px-2 py-0",children:[(0,fe.jsx)(HZ,{className:G("size-3.5 shrink-0",g?"text-amber-500":"text-primary")}),(0,fe.jsx)("span",{className:"font-semibold leading-none",children:"SQL"})]}),(0,fe.jsx)("div",{className:"min-w-28 border-r border-table-border",children:a?(0,fe.jsx)(Fi,{"aria-label":"SQL WHERE clause",className:"h-6 min-h-0 rounded-none border-0 bg-transparent px-2 py-0 text-xs leading-none text-foreground font-sans font-normal shadow-none focus-visible:ring-0",onChange:k=>{i(vpe({...n,sql:k.currentTarget.value}))},onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),w())},placeholder:"WHERE clause",ref:p,value:n.sql}):(0,fe.jsx)("button",{type:"button",className:"flex h-6 min-h-0 w-full min-w-0 appearance-none items-center rounded-none border-0 bg-transparent px-2 py-0 text-left text-xs leading-none text-foreground font-sans shadow-none transition-colors hover:bg-accent hover:text-accent-foreground",onClick:()=>{l(!0),b()},children:(0,fe.jsx)("span",{className:"truncate",children:y})})}),(0,fe.jsx)("button",{type:"button","aria-label":a?"Apply SQL filter":"Remove SQL filter",className:G("flex h-6 min-h-0 w-7 appearance-none items-center justify-center rounded-none border-0 bg-transparent px-1 py-0 leading-none font-sans shadow-none transition-colors",a?"text-foreground hover:bg-accent":"text-foreground hover:bg-destructive/10 hover:text-destructive"),onClick:()=>{if(a){w();return}r()},children:a?(0,fe.jsx)(fm,{className:"size-3.5"}):(0,fe.jsx)(X_,{className:"size-3.5"})})]});return ype({aiSourceQuery:n.aiSource?.query,issueMessage:g?.message,pillContent:S})}function vpe(e){let{lint:t,...n}=e;return n}function tG(e,t){return{...vpe(e),lint:t}}function Act(e){let{filterGroup:t,onRemove:n}=e,r=kz(t);return(0,fe.jsxs)("div",{className:"inline-flex items-center gap-1.5 rounded-full border border-dashed border-table-border bg-background/95 px-2 py-1 text-xs text-foreground shadow-sm",children:[(0,fe.jsx)(IM,{className:"size-3.5 text-muted-foreground"}),(0,fe.jsx)("span",{className:"font-medium",children:"Grouped filter"}),(0,fe.jsxs)("span",{className:"text-muted-foreground",children:[r," condition",r===1?"":"s"]}),(0,fe.jsx)("button",{type:"button","aria-label":"Remove grouped filter",className:"text-muted-foreground transition-colors hover:text-destructive",onClick:n,children:(0,fe.jsx)(X_,{className:"size-3.5"})})]})}function Dct(e){let{columnIds:t,range:n,rows:r}=e,i=[],o=[];for(let s=n.columnStart;s<=n.columnEnd;s++){let a=t[s];a&&i.push(a)}if(i.length===0)return{columnIds:[],rows:[]};for(let s=n.rowStart;s<=n.rowEnd;s++){let a=r[s];a&&o.push(i.map(l=>bpe(a[l])))}return{columnIds:i,rows:o}}function Rct(e){let{columnIds:t,rowSelectionState:n,rows:r}=e;if(t.length===0)return{columnIds:[],rows:[]};let i=r.filter(o=>{let s=o.__ps_rowid;return typeof s=="string"&&n[s]===!0}).map(o=>t.map(s=>bpe(o[s])));return{columnIds:[...t],rows:i}}function Ict(e){let{format:t,includeColumnHeader:n,table:r}=e;return r.columnIds.length===0?"":t==="csv"?Bct({includeColumnHeader:n,table:r}):zct({includeColumnHeader:n,table:r})}function Pct(e){let t=e.format==="csv"?"csv":"md";return`${e.schema}-${e.table}-selection.${t}`}function Lct(e){let{content:t,filename:n,format:r}=e,i=new Blob([t],{type:r==="csv"?"text/csv;charset=utf-8":"text/markdown;charset=utf-8"}),o=URL.createObjectURL(i),s=document.createElement("a");s.href=o,s.download=n,s.rel="noopener",s.style.display="none",document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}function Bct(e){let{includeColumnHeader:t,table:n}=e,r=[];t&&r.push(nG(n.columnIds));for(let i of n.rows)r.push(nG(i));return r.join(`
`)}function nG(e){return e.map(qct).join(",")}function qct(e){return/[",\n\r]/.test(e)?`"${e.replaceAll('"','""')}"`:e}function zct(e){let{includeColumnHeader:t,table:n}=e,r=[];t&&(r.push(rG(n.columnIds)),r.push(`| ${n.columnIds.map(()=>"---").join(" | ")} |`));for(let i of n.rows)r.push(rG(i));return r.join(`
`)}function rG(e){return`| ${e.map(Fct).join(" | ")} |`}function Fct(e){return e.replaceAll("\\","\\\\").replaceAll("|","\\|").replaceAll(`\r
`,"<br />").replaceAll(`
`,"<br />").replaceAll("\r","<br />")}function bpe(e){if(e==null)return"";if(typeof e=="object")try{return JSON.stringify(e)}catch{return String(e)}return String(e)}var jct="__ps_draft_id";function Vct(e){let{activeEditorCellKey:t,focusedCell:n,onFocusedCellChange:r,onEditorNavigate:i,setActiveEditorCellKey:o,table:s,stagedRows:a,setStagedRows:l}=e,u=!!Mhe(),{createUrl:c}=lo(),{data:d}=Hh();function h(y,v){l(b=>{let w=[...b];return w[y]={...w[y],...v},w})}function f(y){l(v=>[...v.slice(0,y),...v.slice(y+1)])}let p=(0,wpe.useCallback)(y=>{(0,xpe.flushSync)(()=>{o(v=>v===y.editorCellKey?null:v),r({columnId:y.columnId,rowIndex:y.rowIndex})})},[r,o]),m=Object.values(s.options.columns).map(y=>({...y,cell({cell:v}){return b=>{let{rowIndex:w,...x}=b;if(y.id==="__ps_select")return(0,to.jsx)(wa,{className:"hover:bg-transparent","data-select":"true",...x,children:(0,to.jsx)(zn,{className:"peer shrink-0 border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring bg-background w-full h-full rounded-none border-none",disabled:u,onClick:()=>f(w),variant:null,size:"icon",children:(0,to.jsx)("span",{className:"flex items-center justify-center text-current",children:(0,to.jsx)(KZ,{className:"opacity-10",size:14})})})});let S=String(y.id??""),k=n?.rowIndex===w&&n.columnId===S;if(cct(y.meta))return(0,to.jsx)(wa,{...x,className:G(x.className,k?GB:QB),"data-focused":k||void 0,"data-grid-column-id":S,"data-grid-visual-row-index":w,withContextMenu:!1,children:(0,to.jsx)("div",{className:"flex w-full items-center justify-end",children:(0,to.jsx)(V3,{createUrl:c,filterColumn:y.meta.sourceColumn,filterValue:(a[w]??{})[y.meta.currentColumnName],introspection:d,targetSchema:y.meta.sourceSchema,targetTable:y.meta.sourceTable})})});let C=y.meta;if(C.isAutoincrement)return(0,to.jsx)(wa,{className:G("italic text-muted-foreground select-none",k&&Qw),"data-focused":k||void 0,"data-grid-column-id":S,"data-grid-visual-row-index":w,onMouseDown:()=>r({columnId:S,rowIndex:w}),children:"(auto-increment)"});if(C.isComputed)return(0,to.jsx)(wa,{className:G("italic text-muted-foreground select-none",k&&Qw),"data-focused":k||void 0,"data-grid-column-id":S,"data-grid-visual-row-index":w,onMouseDown:()=>r({columnId:S,rowIndex:w}),children:"(computed)"});let N=Wct(iG(a[w]??{},w),S);return(0,to.jsx)(Hhe,{cellComponent:C_({cell:v,column:C}),containerProps:{...x,"data-focused":k||void 0,"data-grid-column-id":S,"data-grid-visual-row-index":w,className:G(x.className,k?GB:QB),onMouseDown(E){x.onMouseDown?.(E),!E.defaultPrevented&&r({columnId:S,rowIndex:w})}},inputComponent:ape({cell:v,column:C,context:"insert",onNavigate(E){i({columnId:S,direction:E,rowKey:iG(a[w]??{},w),rowKind:"insert"})},onSubmit(E){h(w,{[y.id]:E}),p({columnId:S,editorCellKey:N,rowIndex:w})},readonly:u,showSaveAction:!1}),isEditorOpen:t===N,linkComponent:_he({cell:v,column:C,createUrl:c,introspection:d}),onRequestClose:()=>p({columnId:S,editorCellKey:N,rowIndex:w}),onRequestOpen:()=>{r({columnId:S,rowIndex:w}),o(N)}})}}})),g=Zce({...s.options,columns:m,enableSorting:!1,onPaginationChange:void 0,onSortingChange:void 0,data:a,state:ptt(s.options.state,["pagination","sorting"])});return(0,to.jsx)(to.Fragment,{children:g.getRowModel().rows.map((y,v)=>(0,to.jsx)(Fy,{children:y.getVisibleCells().map((b,w)=>{if(typeof b.column.columnDef.cell=="function"){let x=b.column.columnDef.cell(b.getContext());return(0,to.jsx)(x,{...lq(b.column,"cell"),rowIndex:v},w)}return null})},v))})}function Wct(e,t){return`insert:${e}:${t}`}function iG(e,t){let n=e[jct];return typeof n=="string"&&n.length>0?n:`draft-${t}`}function Uct(e){let{scopeKey:t,searchTerm:n,setPageIndexParam:r,setSearchParam:i,supportsFullTableSearch:o}=e,[s,a]=En(o?`table-row-search:${t}`:void 0,{isOpen:n.length>0}),[l,u]=(0,Is.useState)(n),c=(0,Is.useRef)(null),d=o&&s.isOpen;(0,Is.useEffect)(()=>{u(n)},[n]),(0,Is.useEffect)(()=>{if(!o){a({isOpen:!1});return}n.length>0&&a({isOpen:!0})},[n,a,o]),(0,Is.useEffect)(()=>{d&&(c.current?.focus(),c.current?.select())},[d]),(0,Is.useEffect)(()=>{if(!o||l===n)return;let m=setTimeout(()=>{i(l),r("0")},350);return()=>clearTimeout(m)},[l,n,r,i,o]);let h=(0,Is.useCallback)(()=>{c.current?.blur(),a({isOpen:!1}),u(""),i(""),r("0")},[r,a,i]),f=(0,Is.useCallback)(()=>{a({isOpen:!0})},[a]),p=(0,Is.useCallback)(m=>{let g=m.trim();a({isOpen:!0}),u(g),i(g),r("0"),requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()})},[r,a,i]);return{closeRowSearch:h,isRowSearchOpen:d,openRowSearch:f,rowSearchInputRef:c,runRowSearch:p,searchInput:l,setSearchInput:u}}var Hct=50;function $ct(e){let t=!!kJ(),{adapter:n,hasAiFilter:r,requestLlm:i}=is(),{metadata:{activeTable:o},createUrl:s,searchParam:a,setPageIndexParam:l,setSearchParam:u}=lo(),c=n.capabilities?.fullTableSearch===!0,d=o?`${o.schema}.${o.name}`:void 0,{pinnedColumnIds:h,setPinnedColumnIds:f}=nue(),p=a??"",m=c?p:"",{sortingState:g,setSortingState:y}=hO(),{isInfiniteScrollEnabled:v,paginationState:b,setInfiniteScrollEnabled:w,setPaginationState:x}=D1(),[S,k]=(0,Ne.useState)(1),{appliedFilter:C,editingFilter:N,setEditingFilter:E,applyEditingFilter:D,totalEditingFilters:q}=cO(o?.columns),z=(0,Ne.useMemo)(()=>lG({activeRowSearchTerm:m,filter:C,pageSize:v?25:b.pageSize,selectionScopeKey:d,sortingState:g}),[m,C,v,b.pageSize,d,g]),{data:_,refetch:R}=Hh(),T=(0,Ne.useMemo)(()=>tc({defaultSchema:n.defaultSchema,dialect:n.capabilities?.sqlDialect??"postgresql",introspection:_}),[n.capabilities?.sqlDialect,n.defaultSchema,_]),B=(0,Ne.useMemo)(()=>!n.capabilities?.sqlEditorLint||!hdt(n)?null:{dialect:T.dialect,lintSql:(te,me)=>n.sqlLint(te,me),schemaVersion:T.version},[n,T.dialect,T.version]),{data:A,isFetching:M,refetch:P}=Pst({pageIndex:v?0:b.pageIndex,pageSize:v?25*S:b.pageSize,sortOrder:g,filter:C,searchScope:c?"row":"table",searchTerm:m}),[F,I]=(0,Ne.useState)(null),V=(0,Ne.useMemo)(()=>v&&M&&(A==null||A.rows.length===0)&&F?.key===z?F.data:A,[A,z,M,v,F]);(0,Ne.useEffect)(()=>{if(!v||!A){F!=null&&I(null);return}M&&A.rows.length===0||I(te=>te?.key===z&&te.data.filteredRowCount===A.filteredRowCount&&te.data.rows===A.rows?te:{data:A,key:z})},[A,z,M,v,F]);let{deleteSelection:W,isSelecting:j,rowSelectionState:X,setRowSelectionState:$}=zst(V),{tableUiState:K,updateTableUiState:Q}=j3({editingFilter:N}),[J]=En(Bte,{requestId:0,tableId:null}),[oe,be]=En(d?`datagrid:${d}:selection-state`:void 0,Tp),[Me,Je]=En(d?`datagrid:${d}:focused-cell`:void 0,null),[Ve]=En(d?`datagrid:${d}:column-order`:void 0,[]),[Ct]=En(d?`datagrid:${d}:column-pinning`:void 0,{left:["__ps_select"],right:[]}),He=Uct({scopeKey:d??"",searchTerm:p,setPageIndexParam:l,setSearchParam:u,supportsFullTableSearch:c}),de=(0,Ne.useMemo)(()=>V?.rows??[],[V?.rows]),ie=(0,Ne.useMemo)(()=>K?.stagedRows??[],[K?.stagedRows]),ze=(0,Ne.useMemo)(()=>K?.stagedUpdates??[],[K?.stagedUpdates]),[Le,Oe]=(0,Ne.useState)(null),[rt,Ht]=(0,Ne.useState)(0),[$t,dt]=(0,Ne.useState)(0),[et,pt]=(0,Ne.useState)(!1),[nn,Dt]=(0,Ne.useState)(!0),[Ot,Kt]=(0,Ne.useState)(0),[Er,Dn]=(0,Ne.useState)(!1),[Zn,Un]=(0,Ne.useState)(!1),[he,Ae]=(0,Ne.useState)(!1),ge=Object.values(X).filter(Boolean).length,Be=zde(oe),ye=Be!=null||ge>0,De=Kct(ge),gt=Yct(ge),ce=idt(adt({stagedRows:ie,stagedUpdates:ze})),$e=(0,Ne.useRef)(null),it=(0,Ne.useRef)(!1),Jt=(0,Ne.useRef)(z),Nt=(0,Ne.useCallback)(te=>{Q(me=>{let _t=me.stagedRows??[];me.stagedRows=typeof te=="function"?te(_t):te})},[Q]),tt=(0,Ne.useCallback)(te=>{Q(me=>{let _t=me.stagedUpdates??[];me.stagedUpdates=typeof te=="function"?te(_t):te})},[Q]),vn=(0,Ne.useMemo)(()=>new Map(ze.map(te=>[te.rowId,te])),[ze]),Yt=(0,Ne.useMemo)(()=>de.map(te=>{let me=String(te.__ps_rowid??""),_t=vn.get(me);return _t?{...te,..._t.changes}:te}),[de,vn]),Mt=ie.length>0||ze.length>0,bt=ze.length,Rn=ie.length+bt,ps=odt(Rn),md=Ot===0?null:Ot%2===0?"motion-safe:animate-[ps-discard-wiggle-b_420ms_ease-in-out]":"motion-safe:animate-[ps-discard-wiggle-a_420ms_ease-in-out]",Fu=Ot===0?null:Ot%2===0?"ps-discard-wiggle-b":"ps-discard-wiggle-a";(0,Ne.useEffect)(()=>{Oe(null)},[o?.name,o?.schema,b.pageIndex,b.pageSize]),(0,Ne.useEffect)(()=>{Jt.current!==z&&(Jt.current=z,$e.current=null,it.current=!1,k(1))},[z]),(0,Ne.useEffect)(()=>{v||($e.current=null,it.current=!1,k(1))},[v]),(0,Ne.useEffect)(()=>{ge===0&&he&&Ae(!1)},[he,ge]),(0,Ne.useEffect)(()=>{Mt||(Er&&Dn(!1),Zn&&Un(!1),Ot!==0&&Kt(0))},[Ot,Mt,Zn,Er]),(0,Ne.useEffect)(()=>{!ye&&et&&pt(!1)},[ye,et]);let gd=!Object.values(o?.columns??{}).some(te=>te.pkPosition!=null),Or=Mhe(),Df=Ist(),wr=Bst(),ms=pdt(V?.filteredRowCount??1/0,b.pageSize),ju=v&&mdt(V?.filteredRowCount??1/0,de.length),Tr=b.pageIndex>0,Wa=ms!=null&&b.pageIndex<ms-1;(0,Ne.useLayoutEffect)(()=>{let te=$e.current;if(te==null){it.current=!1;return}if(M){it.current=!0;return}(de.length>=te||!ju||it.current)&&($e.current=null,it.current=!1)},[ju,M,de.length]);let Vu=o?`${o.schema}.${o.name}`:null,yd=(0,Ne.useMemo)(()=>uct({introspection:_,table:o}),[o,_]),Wu=(0,Ne.useMemo)(()=>tdt({backRelationColumns:yd,columns:o?.columns}),[o?.columns,yd]),Zs=(0,Ne.useMemo)(()=>Wu,[Wu]),Ua=(0,Ne.useMemo)(()=>oG({columnOrder:Ve,columnPinning:Ct,defaultColumnIds:Zs}),[Zs,Ve,Ct]),gs=(0,Ne.useMemo)(()=>{let te=Yt;return Be?Dct({columnIds:Ua,range:Be,rows:te}):ge>0?Rct({columnIds:Ua,rowSelectionState:X,rows:te}):null},[Be,Yt,X,ge,Ua]),zo=(0,Ne.useMemo)(()=>Jct(o?.columns,gd),[o?.columns,gd]),er=(0,Ne.useMemo)(()=>oG({columnOrder:Ve,columnPinning:Ct,defaultColumnIds:Zs}),[Zs,Ve,Ct]),Gi=(0,Ne.useMemo)(()=>Zct({displayRows:Yt,persistedRows:de,stagedRows:ie}),[Yt,de,ie]),ur=(0,Ne.useMemo)(()=>qde({columnIds:er,focusedCell:Me,rowCount:Gi.length}),[Gi.length,er,Me]),Ri=(0,Ne.useCallback)(()=>{Mt&&Kt(te=>te+1)},[Mt]),Um=(0,Ne.useCallback)(te=>{if(Mt){Ri();return}Jt.current=lG({activeRowSearchTerm:m,filter:C,pageSize:te?25:b.pageSize,selectionScopeKey:d,sortingState:g}),$e.current=null,it.current=!1,k(1),w(te),te&&b.pageIndex!==0&&l("0")},[m,C,Mt,b.pageIndex,b.pageSize,d,w,l,g,Ri]),Uu=(0,Ne.useCallback)(()=>{let te=dct({hasMoreInfiniteRows:ju,isInfiniteScrollEnabled:v,loadedInfinitePageCount:S,loadedRowCount:de.length,pendingRowTarget:$e.current});te!=null&&($e.current=null,it.current=!1,$e.current=te,k(me=>me+1))},[ju,v,S,de.length]),bi=(0,Ne.useCallback)(te=>{cdt(te)&&(uq(Me,te)||Je(te))},[Me,Je]);(0,Ne.useEffect)(()=>{uq(Me,ur)||Je(ur)},[Me,ur,Je]);let Ol=(0,Ne.useCallback)(async te=>await i({prompt:te,task:"table-filter"}),[i]),R0=(0,Ne.useCallback)(async te=>{if(!(!r||!o))try{await ppe({aiFilter:Ol,applyEditingFilter:D,filterOperators:_.filterOperators,request:te,setEditingFilter:E,table:o})}catch(me){Ey.error("AI filtering failed.",{description:me instanceof Error?me.message:String(me)})}},[o,D,r,_.filterOperators,Ol,E]),qS=(0,Ne.useCallback)(()=>{Ht(te=>te+1)},[]);function GT(){if(!Mt)return;let te=()=>{Oe(null),Ey.success(sdt(Rn))},me=()=>{if(ze.length===0){te();return}wr.mutate({updates:ze.map(({changes:_t,row:bn})=>({changes:_t,row:bn}))},{onSuccess(){tt([]),te()}})};if(ie.length===0){me();return}Df.mutate(Xct(ie),{onSuccess(){Nt([]),me()}})}let Rf=(0,Ne.useCallback)(async()=>{await R(),await P()},[P,R]),I0=(0,Ne.useCallback)(()=>{Nt(te=>[...te,Qct()]),bi(er[0]?{columnId:er[0],rowIndex:0}:null)},[er,bi,Nt]);function XT(){Oe(null),Nt([]),tt([])}function P0(){XT(),Un(!1)}function zS(){W(),Ae(!1)}function FS(te){return gs?Ict({table:gs,format:te,includeColumnHeader:nn}):""}function Hm(te){let me=FS(te);pt(!1),!(!me||typeof navigator.clipboard?.writeText!="function")&&navigator.clipboard.writeText(me).catch(_t=>{console.error("Failed to copy selection export:",_t)})}function $m(te){if(!o)return;let me=FS(te);pt(!1),me&&Lct({content:me,filename:Pct({format:te,schema:o.schema,table:o.name}),format:te})}let jS=(0,Ne.useMemo)(()=>lct({canGoToNextPage:Wa,canGoToPreviousPage:Tr,hasAiFilter:r,hasStagedChanges:Mt,isInsertingDisabled:Or>0,onDiscardStagedChanges:()=>Un(!0),onFocusFilterWithAi:qS,onFocusSearch:He.openRowSearch,onGoToNextPage(){if(Mt){Ri();return}Wa&&x(te=>({...te,pageIndex:te.pageIndex+1}))},onGoToPreviousPage(){if(Mt){Ri();return}Tr&&x(te=>({...te,pageIndex:te.pageIndex-1}))},onInsertRow:I0,onRefresh:()=>{Rf()},onRunFilterWithAi:R0,onRunSearch:He.runRowSearch,onSaveStagedChanges:()=>Dn(!0),saveStagedChangesLabel:sG(Rn)}),[Wa,Tr,qS,R0,r,Mt,Or,I0,Rf,He.openRowSearch,He.runRowSearch,Rn,x,Ri]);Dje(jS);function JT(te,me,_t){let bn=String(_t.__ps_rowid??"");bn&&tt(ii=>kpe(ii,{columnName:me.name,row:_t,rowId:bn,value:te}))}function VS(te){let me=edt({columnId:te.columnId,direction:te.direction,editableColumnIds:zo,rowKey:te.rowKey,rowKind:te.rowKind,rows:Gi});Oe(me?PI({columnId:me.columnId,rowKey:me.rowKey,rowKind:me.rowKind}):null)}let Y=(0,Ne.useCallback)(te=>{(0,Xde.flushSync)(()=>{bi({columnId:te.columnId,rowIndex:te.rowIndex}),Oe(me=>me===te.editorCellKey?null:me)})},[bi]),Z=(0,Ne.useCallback)(te=>{if(!te||!zo.includes(te.columnId))return;let me=Gi[te.rowIndex];me&&Oe(PI({columnId:te.columnId,rowKey:me.rowKey,rowKind:me.rowKind}))},[zo,Gi]),se=(0,Ne.useRef)(null),ue=(0,Ne.useRef)(0),Ke=(0,Ne.useRef)(null);(0,Ne.useEffect)(()=>{if(!Vu||J.tableId!==Vu)return;let te=`${Vu}:${J.requestId}`;Ke.current!==te&&(Ke.current=te,dt(me=>me+1))},[Vu,J.requestId,J.tableId]),(0,Ne.useLayoutEffect)(()=>{se.current&&!Le&&(document.querySelector('[data-grid-scroll-container="true"]')?.focus({preventScroll:!0}),dt(te=>te+1)),se.current=Le},[Le]),(0,Ne.useEffect)(()=>{let te=me=>{if(Le||udt(document.activeElement)||document.querySelector('[role="dialog"]:not([data-studio-cell-editor="true"])')||me.altKey||me.ctrlKey||me.metaKey||!ur)return;if(me.key==="Enter"){me.preventDefault(),Z(ur);return}let _t=ldt(me.key);if(!_t)return;let bn=Date.now();if(me.repeat&&bn-ue.current<Hct){me.preventDefault();return}let ii=zit({columnIds:er,direction:_t,focusedCell:ur,rowCount:Gi.length});if(ii){if(me.preventDefault(),ue.current=bn,me.shiftKey){let Ii=Fde(oe)??aG({columnIds:er,focusedCell:ur,stagedRowCount:ie.length}),Tl=aG({columnIds:er,focusedCell:ii,stagedRowCount:ie.length});Ii&&Tl&&($({}),be(Pf=>oh(Pf,{type:"cell.select",end:Tl,start:Ii}))),bi(ii);return}$({}),be(Ii=>oh(Ii,{type:"reset"})),bi(ii)}};return window.addEventListener("keydown",te),()=>{window.removeEventListener("keydown",te)}},[Le,Gi.length,er,oe,bi,Z,ur,be,$,ie.length]);function Ye(te){if(!o)return!1;let{columnId:me}=te,_t=o.columns[me];return _t?Spe(_t,gd):!1}function mt(te){if(!o||te.length===0)return;let me=new Map;for(let _t of te){let bn=de[_t.rowIndex];if(!bn)continue;let ii=o.columns[_t.columnId];if(!ii||!Ye({columnId:ii.name,row:bn}))continue;let Ii=String(bn.__ps_rowid),Tl=me.get(Ii),Pf=Sz(ii,"=",_t.value);if(!Tl){me.set(Ii,{row:bn,changes:{[ii.name]:Pf}});continue}Tl.changes[ii.name]=Pf}me.size!==0&&(tt(_t=>rdt(_t,[...me.values()])),Ey.success(`Bulk paste staged for ${me.size} row${me.size===1?"":"s"}`))}let Zt=Object.values(o?.columns??{}).sort(nF).map(te=>({id:te.name,accessorKey:te.name,meta:te,header({table:me,header:_t}){return bn=>(0,qe.jsx)(hq,{table:me,header:_t,...bn,children:(0,qe.jsx)(Hde,{header:_t,column:te,isSortDisabled:Mt,onBlockedSortInteraction:Ri})})},cell({cell:me}){return _t=>{let bn=de[me.row.index]??me.row.original,ii=String(bn.__ps_rowid??""),Ii=ie.length+me.row.index,Tl=PI({columnId:te.name,rowKey:ii,rowKind:"persisted"}),Pf=Le===Tl,PV=vn.get(ii),LV=!!(PV&&Object.prototype.hasOwnProperty.call(PV.changes,te.name)),L0=ur?.rowIndex===Ii&&ur.columnId===te.name;return te.isAutoincrement||te.isComputed?(0,qe.jsx)(wa,{..._t,className:G(_t.className,L0&&Qw),"data-focused":L0||void 0,"data-grid-visual-row-index":Ii,withContextMenu:!1,children:C_({cell:me,column:te,searchTerm:m})}):(0,qe.jsx)(Hhe,{cellComponent:C_({cell:me,column:te,searchTerm:m}),containerProps:{..._t,"data-focused":L0||void 0,"data-grid-visual-row-index":Ii,className:G(_t.className,L0&&LV?GB:L0?Qw:LV?QB:void 0)},inputComponent:Pf?ape({cell:me,column:te,context:"edit",onNavigate(ZT){VS({columnId:te.name,direction:ZT,rowKey:ii,rowKind:"persisted"})},onSubmit(ZT){JT(ZT,te,bn),Y({columnId:te.name,editorCellKey:Tl,rowIndex:Ii})},readonly:gd,showSaveAction:!1}):null,isEditorOpen:Pf,linkComponent:_he({cell:me,column:te,createUrl:s,introspection:_}),onRequestClose:()=>Y({columnId:te.name,editorCellKey:Tl,rowIndex:Ii}),onRequestOpen:()=>{bi({columnId:te.name,rowIndex:Ii}),Oe(Tl)}})}}})),Lt=yd.map(te=>({accessorFn:()=>null,enableSorting:!1,id:te.name,meta:te,header({table:me,header:_t}){return bn=>(0,qe.jsx)(hq,{table:me,header:_t,...bn,children:(0,qe.jsx)(ndt,{name:te.name})})},cell({cell:me}){return _t=>{let bn=de[me.row.index]??me.row.original,ii=ie.length+me.row.index,Ii=ur?.rowIndex===ii&&ur.columnId===te.name;return(0,qe.jsx)(wa,{..._t,className:G(_t.className,Ii&&Qw),"data-focused":Ii||void 0,"data-grid-visual-row-index":ii,withContextMenu:!1,children:(0,qe.jsx)("div",{className:"flex h-full w-full items-center justify-end",children:(0,qe.jsx)(V3,{createUrl:s,filterColumn:te.sourceColumn,filterValue:bn[te.currentColumnName],introspection:_,targetSchema:te.sourceSchema,targetTable:te.sourceTable})})})}}})),vd=[{id:"__ps_select",accessorKey:"__ps_select",enablePinning:!0,enableResizing:!1,enableSorting:!1,size:35,minSize:35,header({table:te}){return me=>(0,qe.jsx)(um,{...me,"aria-label":"Row selection spacer"})},cell({row:te}){return me=>(0,qe.jsx)(wa,{"data-select":"true",...me})}}],If=[...Zt,...vd,...Lt];return o?(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsxs)(f1,{className:N.filters.length>0?"border-b-0 pb-2":void 0,endContent:(0,qe.jsx)(zn,{"aria-label":"Refresh table",variant:"outline",size:"icon",onClick:()=>{Rf()},disabled:M,children:(0,qe.jsx)(Dz,{"data-icon":"inline-start",className:G(M&&"animate-spin")})}),children:[(0,qe.jsx)("div",{className:"flex min-w-0 items-center gap-2",children:(0,qe.jsx)(fdt,{disabled:Mt,onBlockedInteraction:Ri,rowSearch:He,supportsFullTableSearch:c})}),(0,qe.jsx)(_ct,{aiFilter:r?Ol:void 0,aiFocusRequestKey:rt,applyEditingFilter:D,disabled:Mt,editingFilter:N,filterOperators:_.filterOperators,onBlockedInteraction:Ri,setEditingFilter:E,table:o,totalEditingFilters:q}),(0,qe.jsx)(zn,{variant:"outline",className:"h-9 px-5",onClick:I0,disabled:Or>0,children:"Insert row"}),ye&&(0,qe.jsxs)(Mde,{open:et,onOpenChange:te=>{pt(te),te&&Dt(!0)},children:[(0,qe.jsx)(_de,{asChild:!0,children:(0,qe.jsxs)(zn,{"aria-expanded":et,"aria-label":"Copy selection as",variant:"outline",className:G("h-9 shrink-0 gap-1.5 px-3 font-sans",et&&"bg-accent text-accent-foreground"),children:[(0,qe.jsx)("span",{children:"copy as"}),(0,qe.jsx)(Mv,{className:"size-3.5 text-muted-foreground"})]})}),(0,qe.jsxs)(B3,{align:"start",side:"bottom",className:"w-[220px] max-w-[calc(100vw-2rem)] overflow-hidden p-1 font-sans",children:[(0,qe.jsx)(Ode,{checked:nn,className:"rounded-lg font-sans text-sm font-medium",onCheckedChange:te=>Dt(te===!0),onSelect:te=>{te.preventDefault()},children:"include column header"}),(0,qe.jsx)(Ade,{}),(0,qe.jsx)("div",{className:"p-0.5",children:[{action:()=>Hm("markdown"),label:"copy markdown"},{action:()=>Hm("csv"),label:"copy csv"},{action:()=>$m("markdown"),label:"save markdown"},{action:()=>$m("csv"),label:"save csv"}].map(te=>(0,qe.jsx)(Ede,{className:"rounded-lg font-sans text-sm font-medium",onSelect:te.action,children:te.label},te.label))})]})]}),Mt&&(0,qe.jsxs)(qe.Fragment,{children:[(0,qe.jsx)(zn,{className:"h-9 border border-emerald-300 bg-emerald-100 px-5 font-sans text-emerald-950 hover:bg-emerald-200",onClick:()=>Dn(!0),children:sG(Rn)}),(0,qe.jsx)(zn,{"data-wiggle-animation":Fu?`${Fu}-${Ot}`:void 0,variant:"outline",className:G("h-9 border-amber-300 bg-amber-100 px-4 font-sans text-amber-950 hover:border-amber-400 hover:bg-amber-200 motion-safe:origin-center motion-safe:will-change-transform",md),onClick:()=>Un(!0),children:"Discard edits"})]}),j&&ge>0&&(0,qe.jsx)(zn,{variant:"secondary",size:"sm",onClick:()=>Ae(!0),children:De})]}),(0,qe.jsx)(Ect,{applyEditingFilter:D,disabled:Mt,editingFilter:N,filterOperators:_.filterOperators,onBlockedInteraction:Ri,setEditingFilter:E,sqlFilterLint:B,table:o}),(0,qe.jsx)(Ude,{areRowsInViewActionsLocked:Mt,canWriteToCell:Ye,columnDefs:If,focusScrollContainerKey:$t||void 0,focusRowIndexOffset:ie.length,focusedCell:ur,getBeforeRows:te=>(0,qe.jsx)(Vct,{activeEditorCellKey:Le,focusedCell:ur,onEditorNavigate:VS,onFocusedCellChange:bi,setActiveEditorCellKey:Oe,setStagedRows:Nt,stagedRows:ie,table:te}),hasMoreInfiniteRows:ju,infiniteScrollEnabled:v,isFetching:M,isProcessing:t,onFocusedCellChange:bi,onBlockedRowsInViewAction:Ri,onInfiniteScrollEnabledChange:Um,onLoadMoreRows:Uu,onPinnedColumnIdsChange:f,onPaginationChange:x,onPasteSelection:mt,onRowSelectionChange:$,onSortingChange:y,pageCount:ms,paginationState:b,pinnedColumnIds:h,rows:Yt,rowSelectionState:X,selectionScopeKey:d,sortingState:g}),(0,qe.jsx)(LI,{onOpenChange:Ae,onPrimaryAction:zS,open:he,primaryLabel:"delete",primaryVariant:"destructive",prompt:gt,secondaryLabel:"keep",title:"Confirm row deletion"}),(0,qe.jsx)(LI,{onOpenChange:Dn,onPrimaryAction:()=>{Dn(!1),GT()},open:Er,primaryLabel:"yes, write to db",prompt:ps,secondaryLabel:"no, keep editing",title:"Confirm staged row save"}),(0,qe.jsx)(LI,{onOpenChange:Un,onPrimaryAction:P0,open:Zn,primaryLabel:"yes, discard",primaryVariant:"destructive",prompt:ce,secondaryLabel:"no, keep editing",title:"Confirm staged edit discard"})]}):null}function Kct(e){return`Delete ${e} ${e===1?"row":"rows"}`}function Yct(e){return`Do you want to delete ${e} ${e===1?"row":"rows"}?`}function oG(e){let{columnOrder:t,columnPinning:n,defaultColumnIds:r}=e,i=new Set(r),o=[...t.filter(l=>i.has(l)),...r.filter(l=>!t.includes(l))],s=(n.left??[]).filter(l=>l!=="__ps_select"&&i.has(l)),a=new Set;return[...s,...o].filter(l=>a.has(l)?!1:(a.add(l),!0))}var xO="__ps_draft_id";function PI(e){return`${e.rowKind}:${e.rowKey}:${e.columnId}`}function Qct(){return{[xO]:crypto.randomUUID()}}function Gct(e,t){let n=e[xO];return typeof n=="string"&&n.length>0?n:`draft-${t}`}function Xct(e){return e.map(t=>{let{[xO]:n,...r}=t;return r})}function Jct(e,t){return Object.values(e??{}).filter(n=>Spe(n,t)).sort(nF).map(n=>n.name)}function Zct(e){let{displayRows:t,persistedRows:n,stagedRows:r}=e;return[...r.map((i,o)=>({row:i,rowKey:Gct(i,o),rowKind:"insert"})),...t.map((i,o)=>({row:i,rowKey:String(n[o]?.__ps_rowid??i.__ps_rowid??""),rowKind:"persisted"}))]}function edt(e){let{columnId:t,direction:n,editableColumnIds:r,rowKey:i,rowKind:o,rows:s}=e,a=s.findIndex(c=>c.rowKey===i&&c.rowKind===o),l=r.indexOf(t);if(a===-1||l===-1)return null;if(n==="tab"){let c=l+1;if(c<r.length)return{columnId:r[c],rowKey:i,rowKind:o};let d=s[a+1];return d?{columnId:r[0],rowKey:d.rowKey,rowKind:d.rowKind}:null}if(n==="left"||n==="right"){let c=r[l+(n==="left"?-1:1)];return c?{columnId:c,rowKey:i,rowKind:o}:null}let u=s[a+(n==="up"?-1:1)];return u?{columnId:t,rowKey:u.rowKey,rowKind:u.rowKind}:null}function Spe(e,t){return!t&&!e.isAutoincrement&&!e.isComputed}function nF(e,t){let n=e.pkPosition||1/0,r=t.pkPosition||1/0,i=n-r;return Number.isFinite(i)?i||e.name.localeCompare(t.name):Number.isNaN(i)?e.name.localeCompare(t.name):i}function tdt(e){let{backRelationColumns:t,columns:n}=e;return[...Object.values(n??{}).sort(nF).map(r=>r.name),...t.map(r=>r.name)]}function ndt(e){let{name:t}=e;return(0,qe.jsx)("div",{className:"flex h-full min-w-0 items-center px-2",children:(0,qe.jsx)("span",{className:"min-w-0 truncate font-mono text-xs text-foreground/90",children:t})})}function kpe(e,t){let{columnName:n,row:r,rowId:i,value:o}=t,s=[...e],a=s.findIndex(h=>h.rowId===i),l=s[a],u=l?.row??r,c={...l?.changes??{}};if(ctt(u[n],o)?delete c[n]:c[n]=o,Object.keys(c).length===0)return a!==-1&&s.splice(a,1),s;let d={changes:c,row:u,rowId:i};return a===-1?(s.push(d),s):(s[a]=d,s)}function rdt(e,t){let n=e;for(let r of t){let i=String(r.row.__ps_rowid??"");if(i)for(let[o,s]of Object.entries(r.changes))n=kpe(n,{columnName:o,row:r.row,rowId:i,value:s})}return n}function sG(e){return`Save ${e} ${e===1?"row":"rows"}`}function idt(e){return`Discard edits to ${e} ${e===1?"cell":"cells"}?`}function odt(e){return`Commit ${e} updated ${e===1?"row":"rows"} to the database?`}function sdt(e){return`${e===1?"Row":"Rows"} saved successfully`}function adt(e){let{stagedRows:t,stagedUpdates:n}=e,r=t.reduce((o,s)=>{let a=Object.keys(s).filter(l=>l!==xO).length;return o+Math.max(a,1)},0),i=n.reduce((o,s)=>o+Object.keys(s.changes).length,0);return r+i}function ldt(e){switch(e){case"ArrowUp":return"up";case"ArrowDown":return"down";case"ArrowLeft":return"left";case"ArrowRight":return"right";default:return null}}function udt(e){if(!(e instanceof HTMLElement)||!e.isConnected)return!1;let t=e.tagName.toLowerCase();return t==="input"||t==="textarea"||t==="select"?!0:e.isContentEditable}function aG(e){let{columnIds:t,focusedCell:n,stagedRowCount:r}=e;if(!n||n.rowIndex<r)return null;let i=t.indexOf(n.columnId);return i===-1?null:{columnId:n.columnId,columnIndex:i,rowIndex:n.rowIndex-r}}function cdt(e){return e==null?!0:typeof e!="object"?!1:"columnId"in e&&typeof e.columnId=="string"&&"rowIndex"in e&&Number.isInteger(e.rowIndex)}function ddt(e){let{event:t,onPrimaryAction:n,onSecondaryAction:r,primaryRef:i,secondaryRef:o}=e;if(t.key!=="ArrowLeft"&&t.key!=="ArrowRight"&&t.key!=="ArrowUp"&&t.key!=="ArrowDown"&&t.key!=="Enter")return;let s=document.activeElement===o.current?"secondary":"primary";if(t.key==="Enter"){if(t.preventDefault(),s==="primary"){n();return}r();return}if(t.preventDefault(),t.key==="ArrowLeft"||t.key==="ArrowUp"){i.current?.focus();return}o.current?.focus()}function LI(e){let{onOpenChange:t,onPrimaryAction:n,open:r,primaryClassName:i,primaryLabel:o,primaryVariant:s="default",prompt:a,secondaryLabel:l,title:u}=e,c=(0,Ne.useRef)(null),d=(0,Ne.useRef)(null),h=(0,Ne.useCallback)(()=>{t(!1)},[t]);return(0,qe.jsx)(cst,{open:r,onOpenChange:t,children:(0,qe.jsxs)(yhe,{className:"max-w-[280px] gap-2.5 p-3 font-sans",onKeyDown:f=>ddt({event:f,onPrimaryAction:n,onSecondaryAction:h,primaryRef:c,secondaryRef:d}),onOpenAutoFocus:f=>{f.preventDefault(),c.current?.focus()},children:[(0,qe.jsxs)(vhe,{className:"gap-0 text-left",children:[(0,qe.jsx)(whe,{className:"sr-only",children:u}),(0,qe.jsx)(xhe,{className:"font-sans text-[13px] leading-5 text-foreground",children:a})]}),(0,qe.jsxs)(bhe,{className:"flex-row justify-end gap-1.5",children:[(0,qe.jsx)(She,{ref:c,size:"sm",variant:s,className:i,onClick:n,children:o}),(0,qe.jsx)(khe,{ref:d,size:"sm",variant:"secondary",onClick:h,children:l})]})]})})}function hdt(e){return typeof e.sqlLint=="function"}function fdt(e){let{disabled:t=!1,onBlockedInteraction:n,rowSearch:r,supportsFullTableSearch:i}=e,{closeRowSearch:o,isRowSearchOpen:s,openRowSearch:a,rowSearchInputRef:l,searchInput:u,setSearchInput:c}=r;(0,Ne.useEffect)(()=>{t&&o()},[o,t]);function d(){n?.()}function h(f){t&&(f.preventDefault(),d())}return i?(0,qe.jsxs)("div",{className:G("relative h-9 transition-[width] duration-200 ease-out",s?"w-56":"w-9"),"data-row-search-open":s?"true":"false",children:[(0,qe.jsx)(zn,{"aria-disabled":t||void 0,"aria-label":"Global search",variant:"outline",size:"icon",className:G("absolute right-0 top-0 min-w-9 w-auto px-2 transition-opacity duration-200",t&&"opacity-70",s&&"opacity-0 pointer-events-none"),onMouseDown:h,onClick:()=>{if(t){d();return}a()},children:(0,qe.jsx)(_h,{})}),(0,qe.jsx)("div",{"data-row-search-input-wrapper":!0,className:G("absolute right-0 top-1/2 -translate-y-1/2 origin-right transition-[opacity,transform] duration-200 ease-out will-change-transform w-56 z-10",s?"opacity-100 scale-x-100":"opacity-0 scale-x-0 pointer-events-none"),children:(0,qe.jsx)(Fi,{"aria-disabled":t||void 0,"aria-label":"Global search",className:G("h-9 w-full bg-background shadow-none",t&&"opacity-70"),onMouseDown:h,onBlur:f=>{t||f.currentTarget.value.trim().length>0||o()},onChange:f=>{if(t){d();return}c(f.currentTarget.value)},onClick:()=>{t&&d()},onFocus:f=>{t&&(d(),f.currentTarget.blur())},onKeyDown:f=>{if(t){d(),f.preventDefault();return}f.key==="Escape"&&(f.preventDefault(),o())},placeholder:"Global search",ref:l,readOnly:t,value:u})})]}):null}function pdt(e,t){if(e===1/0)return;let n=Number((BigInt(e)+BigInt(t)-BigInt(1))/BigInt(t));return Number.isSafeInteger(n)?n:Number.MAX_SAFE_INTEGER}function lG(e){let{activeRowSearchTerm:t,filter:n,pageSize:r,selectionScopeKey:i,sortingState:o}=e;return JSON.stringify({activeRowSearchTerm:t,filter:n,pageSize:r,sortingState:o,table:i??""})}function mdt(e,t){return e===1/0?!0:BigInt(e)>BigInt(t)}function Npe(e){return(0,Cpe.jsx)("div",{children:"This view was incorrectly loaded, please report this bug."})}function Mpe(e){let{adapter:t,llm:n,onEvent:r,theme:i}=e;return t?(0,ci.jsx)(Oqe,{adapter:t,llm:n,onEvent:r,theme:i,children:(0,ci.jsx)(ydt,{})}):(console.error("No adapter provided to Studio component"),(0,ci.jsx)("div",{children:"Error: No adapter provided"}))}var gdt={schema:l9e,table:$ct,console:U4e,sql:Fot,default:Npe};function ydt(){let{isNavigationOpen:e}=is(),{metadata:{activeTable:t},viewParam:n}=lo(),{errorState:r,hasResolvedIntrospection:i,isRefetching:o,refetch:s}=Hh(),a=G("flex flex-col w-full h-full font-sans"),l=gdt[n??"default"]??Npe,u=n==="table"&&t==null&&r!=null&&!i;return(0,ci.jsx)("div",{className:"ps",style:{width:"100%",height:"100%"},children:(0,ci.jsx)(Rje,{children:(0,ci.jsx)("div",{className:a,children:(0,ci.jsxs)("div",{className:"flex gap-0 bg-background relative min-h-full rounded-lg",children:[(0,ci.jsx)(HX,{mode:"wait",children:e&&(0,ci.jsx)(uP.div,{initial:{width:0,opacity:0},animate:{width:"auto",opacity:1},exit:{width:0,opacity:0},transition:{duration:.14},children:(0,ci.jsx)(Ho,{})})}),(0,ci.jsx)(uP.div,{className:"flex w-full bg-secondary flex-col p-px rounded-lg self-start h-full min-h-full max-h-full overflow-clip",transition:{duration:.14},children:u?(0,ci.jsx)(vdt,{errorState:r,isRetrying:o,onRetry:()=>{s()}}):(0,ci.jsx)(l,{})})]})})})})}function vdt(e){let{errorState:t,isRetrying:n,onRetry:r}=e;return(0,ci.jsxs)("div",{className:"flex h-full min-h-0 flex-col bg-background",children:[(0,ci.jsx)(f1,{}),(0,ci.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,ci.jsx)(XP,{className:"w-full max-w-2xl",description:"Studio could not load schema and table metadata. Retry after checking database permissions or connectivity.",isRetrying:n,message:t.message,onRetry:r,queryPreview:t.queryPreview,source:t.adapterSource,title:"Could not load schema metadata"})})]})}var t0e=L(H()),n0e=L(Zve());var Hft=["mysql","postgres","sqlite"];function e0e(e){return typeof e=="string"&&Hft.includes(e)}var $ft={mysql:WW,postgres:nD,sqlite:tU};function Kft(){let e=window.__STUDIO_CONFIG__;if(e&&e0e(e.adapter))return{adapter:e.adapter};throw new Error("Invalid Prisma Studio frontend config.")}function Yft(){let e=document.getElementById("root");if(e instanceof HTMLElement)return e;throw new Error("Prisma Studio root element was not found.")}var Qft=$ft[Kft().adapter],Gft=Qft({executor:uA({url:"/bff"})}),Xft=e=>{fetch("/telemetry",{body:JSON.stringify(e),method:"POST"}).catch(()=>{})};window.__PVCE__=!0;(0,n0e.createRoot)(Yft()).render((0,t0e.createElement)(Mpe,{adapter:Gft,onEvent:Xft}));
/*! Bundled license information:
react/cjs/react.production.js:
(**
* @license React
* react.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.
*)
react-dom/cjs/react-dom.production.js:
(**
* @license React
* react-dom.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.
*)
react/cjs/react-jsx-runtime.production.js:
(**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
scheduler/cjs/scheduler.production.js:
(**
* @license React
* scheduler.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
react-dom/cjs/react-dom-client.production.js:
(**
* @license React
* react-dom-client.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
@kurkle/color/dist/color.esm.js:
(*!
* @kurkle/color v0.3.4
* https://github.com/kurkle/color#readme
* (c) 2024 Jukka Kurkela
* Released under the MIT License
*)
chart.js/dist/chunks/helpers.dataset.js:
chart.js/dist/chart.js:
(*!
* Chart.js v4.5.1
* https://www.chartjs.org
* (c) 2025 Chart.js Contributors
* Released under the MIT License
*)
@prisma/studio-core/dist/ui/index.js:
(*! Bundled license information:
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
(**
* @license React
* use-sync-external-store-shim.development.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.
*)
use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
(**
* @license React
* use-sync-external-store-shim/with-selector.development.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.
*)
uuidv7/dist/index.js:
(**
* uuidv7: A JavaScript implementation of UUID version 7
*
* Copyright 2021-2025 LiosK
*
* @license Apache-2.0
* @packageDocumentation
*)
lucide-react/dist/esm/shared/src/utils.js:
lucide-react/dist/esm/defaultAttributes.js:
lucide-react/dist/esm/Icon.js:
lucide-react/dist/esm/createLucideIcon.js:
lucide-react/dist/esm/icons/arrow-down.js:
lucide-react/dist/esm/icons/arrow-right.js:
lucide-react/dist/esm/icons/arrow-up-1-0.js:
lucide-react/dist/esm/icons/arrow-up.js:
lucide-react/dist/esm/icons/asterisk.js:
lucide-react/dist/esm/icons/between-vertical-start.js:
lucide-react/dist/esm/icons/calculator.js:
lucide-react/dist/esm/icons/check.js:
lucide-react/dist/esm/icons/chevron-down.js:
lucide-react/dist/esm/icons/chevron-left.js:
lucide-react/dist/esm/icons/chevron-right.js:
lucide-react/dist/esm/icons/chevron-up.js:
lucide-react/dist/esm/icons/chevrons-left.js:
lucide-react/dist/esm/icons/chevrons-right.js:
lucide-react/dist/esm/icons/circle-alert.js:
lucide-react/dist/esm/icons/circle-check-big.js:
lucide-react/dist/esm/icons/circle.js:
lucide-react/dist/esm/icons/code-xml.js:
lucide-react/dist/esm/icons/copy.js:
lucide-react/dist/esm/icons/corner-down-left.js:
lucide-react/dist/esm/icons/database.js:
lucide-react/dist/esm/icons/file-code-corner.js:
lucide-react/dist/esm/icons/funnel.js:
lucide-react/dist/esm/icons/gallery-vertical-end.js:
lucide-react/dist/esm/icons/key-round.js:
lucide-react/dist/esm/icons/key.js:
lucide-react/dist/esm/icons/laptop.js:
lucide-react/dist/esm/icons/loader-circle.js:
lucide-react/dist/esm/icons/minus.js:
lucide-react/dist/esm/icons/moon.js:
lucide-react/dist/esm/icons/panel-left-close.js:
lucide-react/dist/esm/icons/panel-left-open.js:
lucide-react/dist/esm/icons/pin.js:
lucide-react/dist/esm/icons/play.js:
lucide-react/dist/esm/icons/plus.js:
lucide-react/dist/esm/icons/refresh-cw.js:
lucide-react/dist/esm/icons/save.js:
lucide-react/dist/esm/icons/search.js:
lucide-react/dist/esm/icons/sparkles.js:
lucide-react/dist/esm/icons/square-arrow-right.js:
lucide-react/dist/esm/icons/square.js:
lucide-react/dist/esm/icons/sun.js:
lucide-react/dist/esm/icons/table-2.js:
lucide-react/dist/esm/icons/triangle-alert.js:
lucide-react/dist/esm/icons/undo-2.js:
lucide-react/dist/esm/icons/x.js:
lucide-react/dist/esm/lucide-react.js:
(**
* @license lucide-react v0.562.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*)
@tanstack/table-core/build/lib/index.mjs:
(**
* table-core
*
* Copyright (c) TanStack
*
* 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
*)
@tanstack/react-table/build/lib/index.mjs:
(**
* react-table
*
* Copyright (c) TanStack
*
* 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
*)
*)
*/