(function(){const l=document.createElement("link").relList;if(l&&l.supports&&l.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))T(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const N of u.addedNodes)N.tagName==="LINK"&&N.rel==="modulepreload"&&T(N)}).observe(document,{childList:!0,subtree:!0});function E(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function T(c){if(c.ep)return;c.ep=!0;const u=E(c);fetch(c.href,u)}})();function Lc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var HT={exports:{}},gl={};/**
 * @license React
 * react-jsx-runtime.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var IA;function TI(){if(IA)return gl;IA=1;var r=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function E(T,c,u){var N=null;if(u!==void 0&&(N=""+u),c.key!==void 0&&(N=""+c.key),"key"in c){u={};for(var L in c)L!=="key"&&(u[L]=c[L])}else u=c;return c=u.ref,{$$typeof:r,type:T,key:N,ref:c!==void 0?c:null,props:u}}return gl.Fragment=l,gl.jsx=E,gl.jsxs=E,gl}var hA;function cI(){return hA||(hA=1,HT.exports=TI()),HT.exports}var a=cI(),FT={exports:{}},ke={};/**
 * @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.
 */var fA;function SI(){if(fA)return ke;fA=1;var r=Symbol.for("react.transitional.element"),l=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),N=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),R=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),d=Symbol.for("react.activity"),_=Symbol.iterator;function C(p){return p===null||typeof p!="object"?null:(p=_&&p[_]||p["@@iterator"],typeof p=="function"?p:null)}var f={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},m=Object.assign,j={};function W(p,H,ne){this.props=p,this.context=H,this.refs=j,this.updater=ne||f}W.prototype.isReactComponent={},W.prototype.setState=function(p,H){if(typeof p!="object"&&typeof p!="function"&&p!=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,p,H,"setState")},W.prototype.forceUpdate=function(p){this.updater.enqueueForceUpdate(this,p,"forceUpdate")};function P(){}P.prototype=W.prototype;function Z(p,H,ne){this.props=p,this.context=H,this.refs=j,this.updater=ne||f}var v=Z.prototype=new P;v.constructor=Z,m(v,W.prototype),v.isPureReactComponent=!0;var M=Array.isArray;function Te(){}var B={H:null,A:null,T:null,S:null},se=Object.prototype.hasOwnProperty;function w(p,H,ne){var ae=ne.ref;return{$$typeof:r,type:p,key:H,ref:ae!==void 0?ae:null,props:ne}}function $(p,H){return w(p.type,H,p.props)}function J(p){return typeof p=="object"&&p!==null&&p.$$typeof===r}function Ce(p){var H={"=":"=0",":":"=2"};return"$"+p.replace(/[=:]/g,function(ne){return H[ne]})}var Ie=/\/+/g;function ve(p,H){return typeof p=="object"&&p!==null&&p.key!=null?Ce(""+p.key):H.toString(36)}function z(p){switch(p.status){case"fulfilled":return p.value;case"rejected":throw p.reason;default:switch(typeof p.status=="string"?p.then(Te,Te):(p.status="pending",p.then(function(H){p.status==="pending"&&(p.status="fulfilled",p.value=H)},function(H){p.status==="pending"&&(p.status="rejected",p.reason=H)})),p.status){case"fulfilled":return p.value;case"rejected":throw p.reason}}throw p}function D(p,H,ne,ae,F){var te=typeof p;(te==="undefined"||te==="boolean")&&(p=null);var Y=!1;if(p===null)Y=!0;else switch(te){case"bigint":case"string":case"number":Y=!0;break;case"object":switch(p.$$typeof){case r:case l:Y=!0;break;case O:return Y=p._init,D(Y(p._payload),H,ne,ae,F)}}if(Y)return F=F(p),Y=ae===""?"."+ve(p,0):ae,M(F)?(ne="",Y!=null&&(ne=Y.replace(Ie,"$&/")+"/"),D(F,H,ne,"",function(xe){return xe})):F!=null&&(J(F)&&(F=$(F,ne+(F.key==null||p&&p.key===F.key?"":(""+F.key).replace(Ie,"$&/")+"/")+Y)),H.push(F)),1;Y=0;var le=ae===""?".":ae+":";if(M(p))for(var he=0;he<p.length;he++)ae=p[he],te=le+ve(ae,he),Y+=D(ae,H,ne,te,F);else if(he=C(p),typeof he=="function")for(p=he.call(p),he=0;!(ae=p.next()).done;)ae=ae.value,te=le+ve(ae,he++),Y+=D(ae,H,ne,te,F);else if(te==="object"){if(typeof p.then=="function")return D(z(p),H,ne,ae,F);throw H=String(p),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(p).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.")}return Y}function oe(p,H,ne){if(p==null)return p;var ae=[],F=0;return D(p,ae,"","",function(te){return H.call(ne,te,F++)}),ae}function Oe(p){if(p._status===-1){var H=p._result;H=H(),H.then(function(ne){(p._status===0||p._status===-1)&&(p._status=1,p._result=ne)},function(ne){(p._status===0||p._status===-1)&&(p._status=2,p._result=ne)}),p._status===-1&&(p._status=0,p._result=H)}if(p._status===1)return p._result.default;throw p._result}var x=typeof reportError=="function"?reportError:function(p){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var H=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof p=="object"&&p!==null&&typeof p.message=="string"?String(p.message):String(p),error:p});if(!window.dispatchEvent(H))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",p);return}console.error(p)},y={map:oe,forEach:function(p,H,ne){oe(p,function(){H.apply(this,arguments)},ne)},count:function(p){var H=0;return oe(p,function(){H++}),H},toArray:function(p){return oe(p,function(H){return H})||[]},only:function(p){if(!J(p))throw Error("React.Children.only expected to receive a single React element child.");return p}};return ke.Activity=d,ke.Children=y,ke.Component=W,ke.Fragment=E,ke.Profiler=c,ke.PureComponent=Z,ke.StrictMode=T,ke.Suspense=I,ke.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,ke.__COMPILER_RUNTIME={__proto__:null,c:function(p){return B.H.useMemoCache(p)}},ke.cache=function(p){return function(){return p.apply(null,arguments)}},ke.cacheSignal=function(){return null},ke.cloneElement=function(p,H,ne){if(p==null)throw Error("The argument must be a React element, but you passed "+p+".");var ae=m({},p.props),F=p.key;if(H!=null)for(te in H.key!==void 0&&(F=""+H.key),H)!se.call(H,te)||te==="key"||te==="__self"||te==="__source"||te==="ref"&&H.ref===void 0||(ae[te]=H[te]);var te=arguments.length-2;if(te===1)ae.children=ne;else if(1<te){for(var Y=Array(te),le=0;le<te;le++)Y[le]=arguments[le+2];ae.children=Y}return w(p.type,F,ae)},ke.createContext=function(p){return p={$$typeof:N,_currentValue:p,_currentValue2:p,_threadCount:0,Provider:null,Consumer:null},p.Provider=p,p.Consumer={$$typeof:u,_context:p},p},ke.createElement=function(p,H,ne){var ae,F={},te=null;if(H!=null)for(ae in H.key!==void 0&&(te=""+H.key),H)se.call(H,ae)&&ae!=="key"&&ae!=="__self"&&ae!=="__source"&&(F[ae]=H[ae]);var Y=arguments.length-2;if(Y===1)F.children=ne;else if(1<Y){for(var le=Array(Y),he=0;he<Y;he++)le[he]=arguments[he+2];F.children=le}if(p&&p.defaultProps)for(ae in Y=p.defaultProps,Y)F[ae]===void 0&&(F[ae]=Y[ae]);return w(p,te,F)},ke.createRef=function(){return{current:null}},ke.forwardRef=function(p){return{$$typeof:L,render:p}},ke.isValidElement=J,ke.lazy=function(p){return{$$typeof:O,_payload:{_status:-1,_result:p},_init:Oe}},ke.memo=function(p,H){return{$$typeof:R,type:p,compare:H===void 0?null:H}},ke.startTransition=function(p){var H=B.T,ne={};B.T=ne;try{var ae=p(),F=B.S;F!==null&&F(ne,ae),typeof ae=="object"&&ae!==null&&typeof ae.then=="function"&&ae.then(Te,x)}catch(te){x(te)}finally{H!==null&&ne.types!==null&&(H.types=ne.types),B.T=H}},ke.unstable_useCacheRefresh=function(){return B.H.useCacheRefresh()},ke.use=function(p){return B.H.use(p)},ke.useActionState=function(p,H,ne){return B.H.useActionState(p,H,ne)},ke.useCallback=function(p,H){return B.H.useCallback(p,H)},ke.useContext=function(p){return B.H.useContext(p)},ke.useDebugValue=function(){},ke.useDeferredValue=function(p,H){return B.H.useDeferredValue(p,H)},ke.useEffect=function(p,H){return B.H.useEffect(p,H)},ke.useEffectEvent=function(p){return B.H.useEffectEvent(p)},ke.useId=function(){return B.H.useId()},ke.useImperativeHandle=function(p,H,ne){return B.H.useImperativeHandle(p,H,ne)},ke.useInsertionEffect=function(p,H){return B.H.useInsertionEffect(p,H)},ke.useLayoutEffect=function(p,H){return B.H.useLayoutEffect(p,H)},ke.useMemo=function(p,H){return B.H.useMemo(p,H)},ke.useOptimistic=function(p,H){return B.H.useOptimistic(p,H)},ke.useReducer=function(p,H,ne){return B.H.useReducer(p,H,ne)},ke.useRef=function(p){return B.H.useRef(p)},ke.useState=function(p){return B.H.useState(p)},ke.useSyncExternalStore=function(p,H,ne){return B.H.useSyncExternalStore(p,H,ne)},ke.useTransition=function(){return B.H.useTransition()},ke.version="19.2.4",ke}var CA;function _c(){return CA||(CA=1,FT.exports=SI()),FT.exports}var A=_c();const aa=Lc(A);var YT={exports:{}},Ml={},jT={exports:{}},VT={};/**
 * @license React
 * scheduler.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var pA;function RI(){return pA||(pA=1,(function(r){function l(D,oe){var Oe=D.length;D.push(oe);e:for(;0<Oe;){var x=Oe-1>>>1,y=D[x];if(0<c(y,oe))D[x]=oe,D[Oe]=y,Oe=x;else break e}}function E(D){return D.length===0?null:D[0]}function T(D){if(D.length===0)return null;var oe=D[0],Oe=D.pop();if(Oe!==oe){D[0]=Oe;e:for(var x=0,y=D.length,p=y>>>1;x<p;){var H=2*(x+1)-1,ne=D[H],ae=H+1,F=D[ae];if(0>c(ne,Oe))ae<y&&0>c(F,ne)?(D[x]=F,D[ae]=Oe,x=ae):(D[x]=ne,D[H]=Oe,x=H);else if(ae<y&&0>c(F,Oe))D[x]=F,D[ae]=Oe,x=ae;else break e}}return oe}function c(D,oe){var Oe=D.sortIndex-oe.sortIndex;return Oe!==0?Oe:D.id-oe.id}if(r.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;r.unstable_now=function(){return u.now()}}else{var N=Date,L=N.now();r.unstable_now=function(){return N.now()-L}}var I=[],R=[],O=1,d=null,_=3,C=!1,f=!1,m=!1,j=!1,W=typeof setTimeout=="function"?setTimeout:null,P=typeof clearTimeout=="function"?clearTimeout:null,Z=typeof setImmediate<"u"?setImmediate:null;function v(D){for(var oe=E(R);oe!==null;){if(oe.callback===null)T(R);else if(oe.startTime<=D)T(R),oe.sortIndex=oe.expirationTime,l(I,oe);else break;oe=E(R)}}function M(D){if(m=!1,v(D),!f)if(E(I)!==null)f=!0,Te||(Te=!0,Ce());else{var oe=E(R);oe!==null&&z(M,oe.startTime-D)}}var Te=!1,B=-1,se=5,w=-1;function $(){return j?!0:!(r.unstable_now()-w<se)}function J(){if(j=!1,Te){var D=r.unstable_now();w=D;var oe=!0;try{e:{f=!1,m&&(m=!1,P(B),B=-1),C=!0;var Oe=_;try{t:{for(v(D),d=E(I);d!==null&&!(d.expirationTime>D&&$());){var x=d.callback;if(typeof x=="function"){d.callback=null,_=d.priorityLevel;var y=x(d.expirationTime<=D);if(D=r.unstable_now(),typeof y=="function"){d.callback=y,v(D),oe=!0;break t}d===E(I)&&T(I),v(D)}else T(I);d=E(I)}if(d!==null)oe=!0;else{var p=E(R);p!==null&&z(M,p.startTime-D),oe=!1}}break e}finally{d=null,_=Oe,C=!1}oe=void 0}}finally{oe?Ce():Te=!1}}}var Ce;if(typeof Z=="function")Ce=function(){Z(J)};else if(typeof MessageChannel<"u"){var Ie=new MessageChannel,ve=Ie.port2;Ie.port1.onmessage=J,Ce=function(){ve.postMessage(null)}}else Ce=function(){W(J,0)};function z(D,oe){B=W(function(){D(r.unstable_now())},oe)}r.unstable_IdlePriority=5,r.unstable_ImmediatePriority=1,r.unstable_LowPriority=4,r.unstable_NormalPriority=3,r.unstable_Profiling=null,r.unstable_UserBlockingPriority=2,r.unstable_cancelCallback=function(D){D.callback=null},r.unstable_forceFrameRate=function(D){0>D||125<D?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):se=0<D?Math.floor(1e3/D):5},r.unstable_getCurrentPriorityLevel=function(){return _},r.unstable_next=function(D){switch(_){case 1:case 2:case 3:var oe=3;break;default:oe=_}var Oe=_;_=oe;try{return D()}finally{_=Oe}},r.unstable_requestPaint=function(){j=!0},r.unstable_runWithPriority=function(D,oe){switch(D){case 1:case 2:case 3:case 4:case 5:break;default:D=3}var Oe=_;_=D;try{return oe()}finally{_=Oe}},r.unstable_scheduleCallback=function(D,oe,Oe){var x=r.unstable_now();switch(typeof Oe=="object"&&Oe!==null?(Oe=Oe.delay,Oe=typeof Oe=="number"&&0<Oe?x+Oe:x):Oe=x,D){case 1:var y=-1;break;case 2:y=250;break;case 5:y=1073741823;break;case 4:y=1e4;break;default:y=5e3}return y=Oe+y,D={id:O++,callback:oe,priorityLevel:D,startTime:Oe,expirationTime:y,sortIndex:-1},Oe>x?(D.sortIndex=Oe,l(R,D),E(I)===null&&D===E(R)&&(m?(P(B),B=-1):m=!0,z(M,Oe-x))):(D.sortIndex=y,l(I,D),f||C||(f=!0,Te||(Te=!0,Ce()))),D},r.unstable_shouldYield=$,r.unstable_wrapCallback=function(D){var oe=_;return function(){var Oe=_;_=oe;try{return D.apply(this,arguments)}finally{_=Oe}}}})(VT)),VT}var LA;function uI(){return LA||(LA=1,jT.exports=RI()),jT.exports}var wT={exports:{}},Sn={};/**
 * @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.
 */var _A;function AI(){if(_A)return Sn;_A=1;var r=_c();function l(I){var R="https://react.dev/errors/"+I;if(1<arguments.length){R+="?args[]="+encodeURIComponent(arguments[1]);for(var O=2;O<arguments.length;O++)R+="&args[]="+encodeURIComponent(arguments[O])}return"Minified React error #"+I+"; visit "+R+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function E(){}var T={d:{f:E,r:function(){throw Error(l(522))},D:E,C:E,L:E,m:E,X:E,S:E,M:E},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(I,R,O){var d=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:d==null?null:""+d,children:I,containerInfo:R,implementation:O}}var N=r.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function L(I,R){if(I==="font")return"";if(typeof R=="string")return R==="use-credentials"?R:""}return Sn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,Sn.createPortal=function(I,R){var O=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!R||R.nodeType!==1&&R.nodeType!==9&&R.nodeType!==11)throw Error(l(299));return u(I,R,null,O)},Sn.flushSync=function(I){var R=N.T,O=T.p;try{if(N.T=null,T.p=2,I)return I()}finally{N.T=R,T.p=O,T.d.f()}},Sn.preconnect=function(I,R){typeof I=="string"&&(R?(R=R.crossOrigin,R=typeof R=="string"?R==="use-credentials"?R:"":void 0):R=null,T.d.C(I,R))},Sn.prefetchDNS=function(I){typeof I=="string"&&T.d.D(I)},Sn.preinit=function(I,R){if(typeof I=="string"&&R&&typeof R.as=="string"){var O=R.as,d=L(O,R.crossOrigin),_=typeof R.integrity=="string"?R.integrity:void 0,C=typeof R.fetchPriority=="string"?R.fetchPriority:void 0;O==="style"?T.d.S(I,typeof R.precedence=="string"?R.precedence:void 0,{crossOrigin:d,integrity:_,fetchPriority:C}):O==="script"&&T.d.X(I,{crossOrigin:d,integrity:_,fetchPriority:C,nonce:typeof R.nonce=="string"?R.nonce:void 0})}},Sn.preinitModule=function(I,R){if(typeof I=="string")if(typeof R=="object"&&R!==null){if(R.as==null||R.as==="script"){var O=L(R.as,R.crossOrigin);T.d.M(I,{crossOrigin:O,integrity:typeof R.integrity=="string"?R.integrity:void 0,nonce:typeof R.nonce=="string"?R.nonce:void 0})}}else R==null&&T.d.M(I)},Sn.preload=function(I,R){if(typeof I=="string"&&typeof R=="object"&&R!==null&&typeof R.as=="string"){var O=R.as,d=L(O,R.crossOrigin);T.d.L(I,O,{crossOrigin:d,integrity:typeof R.integrity=="string"?R.integrity:void 0,nonce:typeof R.nonce=="string"?R.nonce:void 0,type:typeof R.type=="string"?R.type:void 0,fetchPriority:typeof R.fetchPriority=="string"?R.fetchPriority:void 0,referrerPolicy:typeof R.referrerPolicy=="string"?R.referrerPolicy:void 0,imageSrcSet:typeof R.imageSrcSet=="string"?R.imageSrcSet:void 0,imageSizes:typeof R.imageSizes=="string"?R.imageSizes:void 0,media:typeof R.media=="string"?R.media:void 0})}},Sn.preloadModule=function(I,R){if(typeof I=="string")if(R){var O=L(R.as,R.crossOrigin);T.d.m(I,{as:typeof R.as=="string"&&R.as!=="script"?R.as:void 0,crossOrigin:O,integrity:typeof R.integrity=="string"?R.integrity:void 0})}else T.d.m(I)},Sn.requestFormReset=function(I){T.d.r(I)},Sn.unstable_batchedUpdates=function(I,R){return I(R)},Sn.useFormState=function(I,R,O){return N.H.useFormState(I,R,O)},Sn.useFormStatus=function(){return N.H.useHostTransitionStatus()},Sn.version="19.2.4",Sn}var mA;function md(){if(mA)return wT.exports;mA=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(l){console.error(l)}}return r(),wT.exports=AI(),wT.exports}/**
 * @license React
 * react-dom-client.production.js
 *
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var vA;function dI(){if(vA)return Ml;vA=1;var r=uI(),l=_c(),E=md();function T(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 c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(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 N(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 L(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 I(e){if(u(e)!==e)throw Error(T(188))}function R(e){var t=e.alternate;if(!t){if(t=u(e),t===null)throw Error(T(188));return t!==e?null:e}for(var n=e,s=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(s=i.return,s!==null){n=s;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return I(i),e;if(o===s)return I(i),t;o=o.sibling}throw Error(T(188))}if(n.return!==s.return)n=i,s=o;else{for(var S=!1,h=i.child;h;){if(h===n){S=!0,n=i,s=o;break}if(h===s){S=!0,s=i,n=o;break}h=h.sibling}if(!S){for(h=o.child;h;){if(h===n){S=!0,n=o,s=i;break}if(h===s){S=!0,s=o,n=i;break}h=h.sibling}if(!S)throw Error(T(189))}}if(n.alternate!==s)throw Error(T(190))}if(n.tag!==3)throw Error(T(188));return n.stateNode.current===n?e:t}function O(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=O(e),t!==null)return t;e=e.sibling}return null}var d=Object.assign,_=Symbol.for("react.element"),C=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),W=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),Te=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),se=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),J=Symbol.iterator;function Ce(e){return e===null||typeof e!="object"?null:(e=J&&e[J]||e["@@iterator"],typeof e=="function"?e:null)}var Ie=Symbol.for("react.client.reference");function ve(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ie?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case m:return"Fragment";case W:return"Profiler";case j:return"StrictMode";case M:return"Suspense";case Te:return"SuspenseList";case w:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case f:return"Portal";case Z:return e.displayName||"Context";case P:return(e._context.displayName||"Context")+".Consumer";case v:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case B:return t=e.displayName||null,t!==null?t:ve(e.type)||"Memo";case se:t=e._payload,e=e._init;try{return ve(e(t))}catch{}}return null}var z=Array.isArray,D=l.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=E.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Oe={pending:!1,data:null,method:null,action:null},x=[],y=-1;function p(e){return{current:e}}function H(e){0>y||(e.current=x[y],x[y]=null,y--)}function ne(e,t){y++,x[y]=e.current,e.current=t}var ae=p(null),F=p(null),te=p(null),Y=p(null);function le(e,t){switch(ne(te,t),ne(F,e),ne(ae,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vu(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vu(t),e=wu(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}H(ae),ne(ae,e)}function he(){H(ae),H(F),H(te)}function xe(e){e.memoizedState!==null&&ne(Y,e);var t=ae.current,n=wu(t,e.type);t!==n&&(ne(F,e),ne(ae,n))}function ye(e){F.current===e&&(H(ae),H(F)),Y.current===e&&(H(Y),vl._currentValue=Oe)}var _e,me;function Ne(e){if(_e===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||"",me=-1<n.stack.indexOf(`
    at`)?" (<anonymous>)":-1<n.stack.indexOf("@")?"@unknown:0:0":""}return`
`+_e+e+me}var b=!1;function K(e,t){if(!e||b)return"";b=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(t){var de=function(){throw Error()};if(Object.defineProperty(de.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(de,[])}catch(re){var ee=re}Reflect.construct(e,[],de)}else{try{de.call()}catch(re){ee=re}e.call(de.prototype)}}else{try{throw Error()}catch(re){ee=re}(de=e())&&typeof de.catch=="function"&&de.catch(function(){})}}catch(re){if(re&&ee&&typeof re.stack=="string")return[re.stack,ee.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var i=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");i&&i.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var o=s.DetermineComponentFrameRoot(),S=o[0],h=o[1];if(S&&h){var g=S.split(`
`),q=h.split(`
`);for(i=s=0;s<g.length&&!g[s].includes("DetermineComponentFrameRoot");)s++;for(;i<q.length&&!q[i].includes("DetermineComponentFrameRoot");)i++;if(s===g.length||i===q.length)for(s=g.length-1,i=q.length-1;1<=s&&0<=i&&g[s]!==q[i];)i--;for(;1<=s&&0<=i;s--,i--)if(g[s]!==q[i]){if(s!==1||i!==1)do if(s--,i--,0>i||g[s]!==q[i]){var ie=`
`+g[s].replace(" at new "," at ");return e.displayName&&ie.includes("<anonymous>")&&(ie=ie.replace("<anonymous>",e.displayName)),ie}while(1<=s&&0<=i);break}}}finally{b=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:"")?Ne(n):""}function Le(e,t){switch(e.tag){case 26:case 27:case 5:return Ne(e.type);case 16:return Ne("Lazy");case 13:return e.child!==t&&t!==null?Ne("Suspense Fallback"):Ne("Suspense");case 19:return Ne("SuspenseList");case 0:case 15:return K(e.type,!1);case 11:return K(e.type.render,!1);case 1:return K(e.type,!0);case 31:return Ne("Activity");default:return""}}function Ge(e){try{var t="",n=null;do t+=Le(e,n),n=e,e=e.return;while(e);return t}catch(s){return`
Error generating stack: `+s.message+`
`+s.stack}}var De=Object.prototype.hasOwnProperty,ze=r.unstable_scheduleCallback,Xe=r.unstable_cancelCallback,et=r.unstable_shouldYield,Xt=r.unstable_requestPaint,st=r.unstable_now,Gt=r.unstable_getCurrentPriorityLevel,Bt=r.unstable_ImmediatePriority,Ht=r.unstable_UserBlockingPriority,Pt=r.unstable_NormalPriority,mn=r.unstable_LowPriority,vn=r.unstable_IdlePriority,dr=r.log,Ha=r.unstable_setDisableYieldValue,Jn=null,qt=null;function an(e){if(typeof dr=="function"&&Ha(e),qt&&typeof qt.setStrictMode=="function")try{qt.setStrictMode(Jn,e)}catch{}}var Kt=Math.clz32?Math.clz32:zr,sa=Math.log,Kr=Math.LN2;function zr(e){return e>>>=0,e===0?32:31-(sa(e)/Kr|0)|0}var qn=256,Qt=262144,X=4194304;function Pe(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 Ke(e,t,n){var s=e.pendingLanes;if(s===0)return 0;var i=0,o=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var h=s&134217727;return h!==0?(s=h&~o,s!==0?i=Pe(s):(S&=h,S!==0?i=Pe(S):n||(n=h&~e,n!==0&&(i=Pe(n))))):(h=s&~o,h!==0?i=Pe(h):S!==0?i=Pe(S):n||(n=s&~e,n!==0&&(i=Pe(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 zt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Fa(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 kr(){var e=X;return X<<=1,(X&62914560)===0&&(X=4194304),e}function rn(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Hn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Do(e,t,n,s,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 h=e.entanglements,g=e.expirationTimes,q=e.hiddenUpdates;for(n=S&~n;0<n;){var ie=31-Kt(n),de=1<<ie;h[ie]=0,g[ie]=-1;var ee=q[ie];if(ee!==null)for(q[ie]=null,ie=0;ie<ee.length;ie++){var re=ee[ie];re!==null&&(re.lane&=-536870913)}n&=~de}s!==0&&Kl(e,s,0),o!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=o&~(S&~t))}function Kl(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var s=31-Kt(t);e.entangledLanes|=t,e.entanglements[s]=e.entanglements[s]|1073741824|n&261930}function zl(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var s=31-Kt(n),i=1<<s;i&t|e[s]&t&&(e[s]|=t),n&=~i}}function $r(e,t){var n=t&-t;return n=(n&42)!==0?1:Or(n),(n&(e.suspendedLanes|t))!==0?0:n}function Or(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 js(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function kl(){var e=oe.p;return e!==0?e:(e=window.event,e===void 0?32:SA(e.type))}function $l(e,t){var n=oe.p;try{return oe.p=e,t()}finally{oe.p=n}}var un=Math.random().toString(36).slice(2),kt="__reactFiber$"+un,cn="__reactProps$"+un,Ya="__reactContainer$"+un,Vs="__reactEvents$"+un,ws="__reactListeners$"+un,yo="__reactHandles$"+un,Jl="__reactResources$"+un,Nr="__reactMarker$"+un;function ce(e){delete e[kt],delete e[cn],delete e[Vs],delete e[ws],delete e[yo]}function Fe(e){var t=e[kt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ya]||n[kt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ju(e);e!==null;){if(n=e[kt])return n;e=Ju(e)}return t}e=n,n=e.parentNode}return null}function We(e){if(e=e[kt]||e[Ya]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ft(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(T(33))}function Tt(e){var t=e[Jl];return t||(t=e[Jl]={hoistableStyles:new Map,hoistableScripts:new Map}),t}function yt(e){e[Nr]=!0}var ua=new Set,Aa={};function la(e,t){ja(e,t),ja(e+"Capture",t)}function ja(e,t){for(Aa[e]=t,e=0;e<t.length;e++)ua.add(t[e])}var tO=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]*$"),gc={},Mc={};function nO(e){return De.call(Mc,e)?!0:De.call(gc,e)?!1:tO.test(e)?Mc[e]=!0:(gc[e]=!0,!1)}function ql(e,t,n){if(nO(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case"undefined":case"function":case"symbol":e.removeAttribute(t);return;case"boolean":var s=t.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(t);return}}e.setAttribute(t,""+n)}}function Ql(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 da(e,t,n,s){if(s===null)e.removeAttribute(n);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttributeNS(t,n,""+s)}}function Fn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Pc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function aO(e,t,n){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var i=s.get,o=s.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:s.enumerable}),{getValue:function(){return n},setValue:function(S){n=""+S},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function go(e){if(!e._valueTracker){var t=Pc(e)?"checked":"value";e._valueTracker=aO(e,t,""+e[t])}}function Uc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),s="";return e&&(s=Pc(e)?e.checked?"true":"false":e.value),e=s,e!==n?(t.setValue(e),!0):!1}function Zl(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 rO=/[\n"\\]/g;function Yn(e){return e.replace(rO,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Mo(e,t,n,s,i,o,S,h){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=""+Fn(t)):e.value!==""+Fn(t)&&(e.value=""+Fn(t)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),t!=null?Po(e,S,Fn(t)):n!=null?Po(e,S,Fn(n)):s!=null&&e.removeAttribute("value"),i==null&&o!=null&&(e.defaultChecked=!!o),i!=null&&(e.checked=i&&typeof i!="function"&&typeof i!="symbol"),h!=null&&typeof h!="function"&&typeof h!="symbol"&&typeof h!="boolean"?e.name=""+Fn(h):e.removeAttribute("name")}function bc(e,t,n,s,i,o,S,h){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)){go(e);return}n=n!=null?""+Fn(n):"",t=t!=null?""+Fn(t):n,h||t===e.value||(e.value=t),e.defaultValue=t}s=s??i,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=h?e.checked:!!s,e.defaultChecked=!!s,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),go(e)}function Po(e,t,n){t==="number"&&Zl(e.ownerDocument)===e||e.defaultValue===""+n||(e.defaultValue=""+n)}function Jr(e,t,n,s){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&&s&&(e[n].defaultSelected=!0)}else{for(n=""+Fn(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,s&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gc(e,t,n){if(t!=null&&(t=""+Fn(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n!=null?""+Fn(n):""}function Bc(e,t,n,s){if(t==null){if(s!=null){if(n!=null)throw Error(T(92));if(z(s)){if(1<s.length)throw Error(T(93));s=s[0]}n=s}n==null&&(n=""),t=n}n=Fn(t),e.defaultValue=n,s=e.textContent,s===n&&s!==""&&s!==null&&(e.value=s),go(e)}function qr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var sO=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 Hc(e,t,n){var s=t.indexOf("--")===0;n==null||typeof n=="boolean"||n===""?s?e.setProperty(t,""):t==="float"?e.cssFloat="":e[t]="":s?e.setProperty(t,n):typeof n!="number"||n===0||sO.has(t)?t==="float"?e.cssFloat=n:e[t]=(""+n).trim():e[t]=n+"px"}function Fc(e,t,n){if(t!=null&&typeof t!="object")throw Error(T(62));if(e=e.style,n!=null){for(var s in n)!n.hasOwnProperty(s)||t!=null&&t.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var i in t)s=t[i],t.hasOwnProperty(i)&&n[i]!==s&&Hc(e,i,s)}else for(var o in t)t.hasOwnProperty(o)&&Hc(e,o,t[o])}function Uo(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 lO=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"]]),iO=/^[\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 ei(e){return iO.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Oa(){}var bo=null;function Go(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Qr=null,Zr=null;function Yc(e){var t=We(e);if(t&&(e=t.stateNode)){var n=e[cn]||null;e:switch(e=t.stateNode,t.type){case"input":if(Mo(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="'+Yn(""+t)+'"][type="radio"]'),t=0;t<n.length;t++){var s=n[t];if(s!==e&&s.form===e.form){var i=s[cn]||null;if(!i)throw Error(T(90));Mo(s,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)s=n[t],s.form===e.form&&Uc(s)}break e;case"textarea":Gc(e,n.value,n.defaultValue);break e;case"select":t=n.value,t!=null&&Jr(e,!!n.multiple,t,!1)}}}var Bo=!1;function jc(e,t,n){if(Bo)return e(t,n);Bo=!0;try{var s=e(t);return s}finally{if(Bo=!1,(Qr!==null||Zr!==null)&&(ji(),Qr&&(t=Qr,e=Zr,Zr=Qr=null,Yc(t),e)))for(t=0;t<e.length;t++)Yc(e[t])}}function Ws(e,t){var n=e.stateNode;if(n===null)return null;var s=n[cn]||null;if(s===null)return null;n=s[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":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(T(231,t,typeof n));return n}var Na=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ho=!1;if(Na)try{var Xs={};Object.defineProperty(Xs,"passive",{get:function(){Ho=!0}}),window.addEventListener("test",Xs,Xs),window.removeEventListener("test",Xs,Xs)}catch{Ho=!1}var Va=null,Fo=null,ti=null;function Vc(){if(ti)return ti;var e,t=Fo,n=t.length,s,i="value"in Va?Va.value:Va.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var S=n-e;for(s=1;s<=S&&t[n-s]===i[o-s];s++);return ti=i.slice(e,1<s?1-s:void 0)}function ni(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 ai(){return!0}function wc(){return!1}function In(e){function t(n,s,i,o,S){this._reactName=n,this._targetInst=i,this.type=s,this.nativeEvent=o,this.target=S,this.currentTarget=null;for(var h in e)e.hasOwnProperty(h)&&(n=e[h],this[h]=n?n(o):o[h]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?ai:wc,this.isPropagationStopped=wc,this}return d(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=ai)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=ai)},persist:function(){},isPersistent:ai}),t}var Ir={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ri=In(Ir),Ks=d({},Ir,{view:0,detail:0}),oO=In(Ks),Yo,jo,zs,si=d({},Ks,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wo,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!==zs&&(zs&&e.type==="mousemove"?(Yo=e.screenX-zs.screenX,jo=e.screenY-zs.screenY):jo=Yo=0,zs=e),Yo)},movementY:function(e){return"movementY"in e?e.movementY:jo}}),Wc=In(si),EO=d({},si,{dataTransfer:0}),TO=In(EO),cO=d({},Ks,{relatedTarget:0}),Vo=In(cO),SO=d({},Ir,{animationName:0,elapsedTime:0,pseudoElement:0}),RO=In(SO),uO=d({},Ir,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),AO=In(uO),dO=d({},Ir,{data:0}),Xc=In(dO),OO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},NO={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"},IO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function hO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=IO[e])?!!t[e]:!1}function wo(){return hO}var fO=d({},Ks,{key:function(e){if(e.key){var t=OO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=ni(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?NO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wo,charCode:function(e){return e.type==="keypress"?ni(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ni(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),CO=In(fO),pO=d({},si,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Kc=In(pO),LO=d({},Ks,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wo}),_O=In(LO),mO=d({},Ir,{propertyName:0,elapsedTime:0,pseudoElement:0}),vO=In(mO),xO=d({},si,{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}),DO=In(xO),yO=d({},Ir,{newState:0,oldState:0}),gO=In(yO),MO=[9,13,27,32],Wo=Na&&"CompositionEvent"in window,ks=null;Na&&"documentMode"in document&&(ks=document.documentMode);var PO=Na&&"TextEvent"in window&&!ks,zc=Na&&(!Wo||ks&&8<ks&&11>=ks),kc=" ",$c=!1;function Jc(e,t){switch(e){case"keyup":return MO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var es=!1;function UO(e,t){switch(e){case"compositionend":return qc(t);case"keypress":return t.which!==32?null:($c=!0,kc);case"textInput":return e=t.data,e===kc&&$c?null:e;default:return null}}function bO(e,t){if(es)return e==="compositionend"||!Wo&&Jc(e,t)?(e=Vc(),ti=Fo=Va=null,es=!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 zc&&t.locale!=="ko"?null:t.data;default:return null}}var GO={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 Qc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!GO[e.type]:t==="textarea"}function Zc(e,t,n,s){Qr?Zr?Zr.push(s):Zr=[s]:Qr=s,t=ki(t,"onChange"),0<t.length&&(n=new ri("onChange","change",null,n,s),e.push({event:n,listeners:t}))}var $s=null,Js=null;function BO(e){Gu(e,0)}function li(e){var t=ft(e);if(Uc(t))return e}function eS(e,t){if(e==="change")return t}var tS=!1;if(Na){var Xo;if(Na){var Ko="oninput"in document;if(!Ko){var nS=document.createElement("div");nS.setAttribute("oninput","return;"),Ko=typeof nS.oninput=="function"}Xo=Ko}else Xo=!1;tS=Xo&&(!document.documentMode||9<document.documentMode)}function aS(){$s&&($s.detachEvent("onpropertychange",rS),Js=$s=null)}function rS(e){if(e.propertyName==="value"&&li(Js)){var t=[];Zc(t,Js,e,Go(e)),jc(BO,t)}}function HO(e,t,n){e==="focusin"?(aS(),$s=t,Js=n,$s.attachEvent("onpropertychange",rS)):e==="focusout"&&aS()}function FO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return li(Js)}function YO(e,t){if(e==="click")return li(t)}function jO(e,t){if(e==="input"||e==="change")return li(t)}function VO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var xn=typeof Object.is=="function"?Object.is:VO;function qs(e,t){if(xn(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(s=0;s<n.length;s++){var i=n[s];if(!De.call(t,i)||!xn(e[i],t[i]))return!1}return!0}function sS(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function lS(e,t){var n=sS(e);e=0;for(var s;n;){if(n.nodeType===3){if(s=e+n.textContent.length,e<=t&&s>=t)return{node:n,offset:t-e};e=s}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=sS(n)}}function iS(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?iS(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function oS(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Zl(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=Zl(e.document)}return t}function zo(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 wO=Na&&"documentMode"in document&&11>=document.documentMode,ts=null,ko=null,Qs=null,$o=!1;function ES(e,t,n){var s=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;$o||ts==null||ts!==Zl(s)||(s=ts,"selectionStart"in s&&zo(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),Qs&&qs(Qs,s)||(Qs=s,s=ki(ko,"onSelect"),0<s.length&&(t=new ri("onSelect","select",null,t,n),e.push({event:t,listeners:s}),t.target=ts)))}function hr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var ns={animationend:hr("Animation","AnimationEnd"),animationiteration:hr("Animation","AnimationIteration"),animationstart:hr("Animation","AnimationStart"),transitionrun:hr("Transition","TransitionRun"),transitionstart:hr("Transition","TransitionStart"),transitioncancel:hr("Transition","TransitionCancel"),transitionend:hr("Transition","TransitionEnd")},Jo={},TS={};Na&&(TS=document.createElement("div").style,"AnimationEvent"in window||(delete ns.animationend.animation,delete ns.animationiteration.animation,delete ns.animationstart.animation),"TransitionEvent"in window||delete ns.transitionend.transition);function fr(e){if(Jo[e])return Jo[e];if(!ns[e])return e;var t=ns[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in TS)return Jo[e]=t[n];return e}var cS=fr("animationend"),SS=fr("animationiteration"),RS=fr("animationstart"),WO=fr("transitionrun"),XO=fr("transitionstart"),KO=fr("transitioncancel"),uS=fr("transitionend"),AS=new Map,qo="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(" ");qo.push("scrollEnd");function Qn(e,t){AS.set(e,t),la(t,[e])}var ii=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)},jn=[],as=0,Qo=0;function oi(){for(var e=as,t=Qo=as=0;t<e;){var n=jn[t];jn[t++]=null;var s=jn[t];jn[t++]=null;var i=jn[t];jn[t++]=null;var o=jn[t];if(jn[t++]=null,s!==null&&i!==null){var S=s.pending;S===null?i.next=i:(i.next=S.next,S.next=i),s.pending=i}o!==0&&dS(n,i,o)}}function Ei(e,t,n,s){jn[as++]=e,jn[as++]=t,jn[as++]=n,jn[as++]=s,Qo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Zo(e,t,n,s){return Ei(e,t,n,s),Ti(e)}function Cr(e,t){return Ei(e,null,null,t),Ti(e)}function dS(e,t,n){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n);for(var i=!1,o=e.return;o!==null;)o.childLanes|=n,s=o.alternate,s!==null&&(s.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-Kt(n),e=o.hiddenUpdates,s=e[i],s===null?e[i]=[t]:s.push(t),t.lane=n|536870912),o):null}function Ti(e){if(50<hl)throw hl=0,oT=null,Error(T(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var rs={};function zO(e,t,n,s){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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Dn(e,t,n,s){return new zO(e,t,n,s)}function eE(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ia(e,t){var n=e.alternate;return n===null?(n=Dn(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 OS(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 ci(e,t,n,s,i,o){var S=0;if(s=e,typeof e=="function")eE(e)&&(S=1);else if(typeof e=="string")S=QN(e,n,ae.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case w:return e=Dn(31,n,t,i),e.elementType=w,e.lanes=o,e;case m:return pr(n.children,i,o,t);case j:S=8,i|=24;break;case W:return e=Dn(12,n,t,i|2),e.elementType=W,e.lanes=o,e;case M:return e=Dn(13,n,t,i),e.elementType=M,e.lanes=o,e;case Te:return e=Dn(19,n,t,i),e.elementType=Te,e.lanes=o,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Z:S=10;break e;case P:S=9;break e;case v:S=11;break e;case B:S=14;break e;case se:S=16,s=null;break e}S=29,n=Error(T(130,e===null?"null":typeof e,"")),s=null}return t=Dn(S,n,t,i),t.elementType=e,t.type=s,t.lanes=o,t}function pr(e,t,n,s){return e=Dn(7,e,s,t),e.lanes=n,e}function tE(e,t,n){return e=Dn(6,e,null,t),e.lanes=n,e}function NS(e){var t=Dn(18,null,null,0);return t.stateNode=e,t}function nE(e,t,n){return t=Dn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var IS=new WeakMap;function Vn(e,t){if(typeof e=="object"&&e!==null){var n=IS.get(e);return n!==void 0?n:(t={value:e,source:t,stack:Ge(t)},IS.set(e,t),t)}return{value:e,source:t,stack:Ge(t)}}var ss=[],ls=0,Si=null,Zs=0,wn=[],Wn=0,wa=null,ia=1,oa="";function ha(e,t){ss[ls++]=Zs,ss[ls++]=Si,Si=e,Zs=t}function hS(e,t,n){wn[Wn++]=ia,wn[Wn++]=oa,wn[Wn++]=wa,wa=e;var s=ia;e=oa;var i=32-Kt(s)-1;s&=~(1<<i),n+=1;var o=32-Kt(t)+i;if(30<o){var S=i-i%5;o=(s&(1<<S)-1).toString(32),s>>=S,i-=S,ia=1<<32-Kt(t)+i|n<<i|s,oa=o+e}else ia=1<<o|n<<i|s,oa=e}function aE(e){e.return!==null&&(ha(e,1),hS(e,1,0))}function rE(e){for(;e===Si;)Si=ss[--ls],ss[ls]=null,Zs=ss[--ls],ss[ls]=null;for(;e===wa;)wa=wn[--Wn],wn[Wn]=null,oa=wn[--Wn],wn[Wn]=null,ia=wn[--Wn],wn[Wn]=null}function fS(e,t){wn[Wn++]=ia,wn[Wn++]=oa,wn[Wn++]=wa,ia=t.id,oa=t.overflow,wa=e}var sn=null,_t=null,ot=!1,Wa=null,Xn=!1,sE=Error(T(519));function Xa(e){var t=Error(T(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw el(Vn(t,e)),sE}function CS(e){var t=e.stateNode,n=e.type,s=e.memoizedProps;switch(t[kt]=e,t[cn]=s,n){case"dialog":nt("cancel",t),nt("close",t);break;case"iframe":case"object":case"embed":nt("load",t);break;case"video":case"audio":for(n=0;n<Cl.length;n++)nt(Cl[n],t);break;case"source":nt("error",t);break;case"img":case"image":case"link":nt("error",t),nt("load",t);break;case"details":nt("toggle",t);break;case"input":nt("invalid",t),bc(t,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":nt("invalid",t);break;case"textarea":nt("invalid",t),Bc(t,s.value,s.defaultValue,s.children)}n=s.children,typeof n!="string"&&typeof n!="number"&&typeof n!="bigint"||t.textContent===""+n||s.suppressHydrationWarning===!0||Yu(t.textContent,n)?(s.popover!=null&&(nt("beforetoggle",t),nt("toggle",t)),s.onScroll!=null&&nt("scroll",t),s.onScrollEnd!=null&&nt("scrollend",t),s.onClick!=null&&(t.onclick=Oa),t=!0):t=!1,t||Xa(e,!0)}function pS(e){for(sn=e.return;sn;)switch(sn.tag){case 5:case 31:case 13:Xn=!1;return;case 27:case 3:Xn=!0;return;default:sn=sn.return}}function is(e){if(e!==sn)return!1;if(!ot)return pS(e),ot=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!=="form"&&n!=="button")||pT(e.type,e.memoizedProps)),n=!n),n&&_t&&Xa(e),pS(e),t===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(T(317));_t=$u(e)}else if(t===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(T(317));_t=$u(e)}else t===27?(t=_t,sr(e.type)?(e=xT,xT=null,_t=e):_t=t):_t=sn?zn(e.stateNode.nextSibling):null;return!0}function Lr(){_t=sn=null,ot=!1}function lE(){var e=Wa;return e!==null&&(pn===null?pn=e:pn.push.apply(pn,e),Wa=null),e}function el(e){Wa===null?Wa=[e]:Wa.push(e)}var iE=p(null),_r=null,fa=null;function Ka(e,t,n){ne(iE,t._currentValue),t._currentValue=n}function Ca(e){e._currentValue=iE.current,H(iE)}function oE(e,t,n){for(;e!==null;){var s=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,s!==null&&(s.childLanes|=t)):s!==null&&(s.childLanes&t)!==t&&(s.childLanes|=t),e===n)break;e=e.return}}function EE(e,t,n,s){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 h=o;o=i;for(var g=0;g<t.length;g++)if(h.context===t[g]){o.lanes|=n,h=o.alternate,h!==null&&(h.lanes|=n),oE(o.return,n,e),s||(S=null);break e}o=h.next}}else if(i.tag===18){if(S=i.return,S===null)throw Error(T(341));S.lanes|=n,o=S.alternate,o!==null&&(o.lanes|=n),oE(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 os(e,t,n,s){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(T(387));if(S=S.memoizedProps,S!==null){var h=i.type;xn(i.pendingProps.value,S.value)||(e!==null?e.push(h):e=[h])}}else if(i===Y.current){if(S=i.alternate,S===null)throw Error(T(387));S.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e!==null?e.push(vl):e=[vl])}i=i.return}e!==null&&EE(t,e,n,s),t.flags|=262144}function Ri(e){for(e=e.firstContext;e!==null;){if(!xn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function mr(e){_r=e,fa=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ln(e){return LS(_r,e)}function ui(e,t){return _r===null&&mr(e),LS(e,t)}function LS(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},fa===null){if(e===null)throw Error(T(308));fa=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else fa=fa.next=t;return n}var kO=typeof AbortController<"u"?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(n,s){e.push(s)}};this.abort=function(){t.aborted=!0,e.forEach(function(n){return n()})}},$O=r.unstable_scheduleCallback,JO=r.unstable_NormalPriority,jt={$$typeof:Z,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function TE(){return{controller:new kO,data:new Map,refCount:0}}function tl(e){e.refCount--,e.refCount===0&&$O(JO,function(){e.controller.abort()})}var nl=null,cE=0,Es=0,Ts=null;function qO(e,t){if(nl===null){var n=nl=[];cE=0,Es=uT(),Ts={status:"pending",value:void 0,then:function(s){n.push(s)}}}return cE++,t.then(_S,_S),t}function _S(){if(--cE===0&&nl!==null){Ts!==null&&(Ts.status="fulfilled");var e=nl;nl=null,Es=0,Ts=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function QO(e,t){var n=[],s={status:"pending",value:null,reason:null,then:function(i){n.push(i)}};return e.then(function(){s.status="fulfilled",s.value=t;for(var i=0;i<n.length;i++)(0,n[i])(t)},function(i){for(s.status="rejected",s.reason=i,i=0;i<n.length;i++)(0,n[i])(void 0)}),s}var mS=D.S;D.S=function(e,t){Tu=st(),typeof t=="object"&&t!==null&&typeof t.then=="function"&&qO(e,t),mS!==null&&mS(e,t)};var vr=p(null);function SE(){var e=vr.current;return e!==null?e:Ct.pooledCache}function Ai(e,t){t===null?ne(vr,vr.current):ne(vr,t.pool)}function vS(){var e=SE();return e===null?null:{parent:jt._currentValue,pool:e}}var cs=Error(T(460)),RE=Error(T(474)),di=Error(T(542)),Oi={then:function(){}};function xS(e){return e=e.status,e==="fulfilled"||e==="rejected"}function DS(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Oa,Oa),t=n),t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,gS(e),e;default:if(typeof t.status=="string")t.then(Oa,Oa);else{if(e=Ct,e!==null&&100<e.shellSuspendCounter)throw Error(T(482));e=t,e.status="pending",e.then(function(s){if(t.status==="pending"){var i=t;i.status="fulfilled",i.value=s}},function(s){if(t.status==="pending"){var i=t;i.status="rejected",i.reason=s}})}switch(t.status){case"fulfilled":return t.value;case"rejected":throw e=t.reason,gS(e),e}throw Dr=t,cs}}function xr(e){try{var t=e._init;return t(e._payload)}catch(n){throw n!==null&&typeof n=="object"&&typeof n.then=="function"?(Dr=n,cs):n}}var Dr=null;function yS(){if(Dr===null)throw Error(T(459));var e=Dr;return Dr=null,e}function gS(e){if(e===cs||e===di)throw Error(T(483))}var Ss=null,al=0;function Ni(e){var t=al;return al+=1,Ss===null&&(Ss=[]),DS(Ss,e,t)}function rl(e,t){t=t.props.ref,e.ref=t!==void 0?t:null}function Ii(e,t){throw t.$$typeof===_?Error(T(525)):(e=Object.prototype.toString.call(t),Error(T(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)))}function MS(e){function t(V,G){if(e){var k=V.deletions;k===null?(V.deletions=[G],V.flags|=16):k.push(G)}}function n(V,G){if(!e)return null;for(;G!==null;)t(V,G),G=G.sibling;return null}function s(V){for(var G=new Map;V!==null;)V.key!==null?G.set(V.key,V):G.set(V.index,V),V=V.sibling;return G}function i(V,G){return V=Ia(V,G),V.index=0,V.sibling=null,V}function o(V,G,k){return V.index=k,e?(k=V.alternate,k!==null?(k=k.index,k<G?(V.flags|=67108866,G):k):(V.flags|=67108866,G)):(V.flags|=1048576,G)}function S(V){return e&&V.alternate===null&&(V.flags|=67108866),V}function h(V,G,k,Re){return G===null||G.tag!==6?(G=tE(k,V.mode,Re),G.return=V,G):(G=i(G,k),G.return=V,G)}function g(V,G,k,Re){var Ye=k.type;return Ye===m?ie(V,G,k.props.children,Re,k.key):G!==null&&(G.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===se&&xr(Ye)===G.type)?(G=i(G,k.props),rl(G,k),G.return=V,G):(G=ci(k.type,k.key,k.props,null,V.mode,Re),rl(G,k),G.return=V,G)}function q(V,G,k,Re){return G===null||G.tag!==4||G.stateNode.containerInfo!==k.containerInfo||G.stateNode.implementation!==k.implementation?(G=nE(k,V.mode,Re),G.return=V,G):(G=i(G,k.children||[]),G.return=V,G)}function ie(V,G,k,Re,Ye){return G===null||G.tag!==7?(G=pr(k,V.mode,Re,Ye),G.return=V,G):(G=i(G,k),G.return=V,G)}function de(V,G,k){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=tE(""+G,V.mode,k),G.return=V,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case C:return k=ci(G.type,G.key,G.props,null,V.mode,k),rl(k,G),k.return=V,k;case f:return G=nE(G,V.mode,k),G.return=V,G;case se:return G=xr(G),de(V,G,k)}if(z(G)||Ce(G))return G=pr(G,V.mode,k,null),G.return=V,G;if(typeof G.then=="function")return de(V,Ni(G),k);if(G.$$typeof===Z)return de(V,ui(V,G),k);Ii(V,G)}return null}function ee(V,G,k,Re){var Ye=G!==null?G.key:null;if(typeof k=="string"&&k!==""||typeof k=="number"||typeof k=="bigint")return Ye!==null?null:h(V,G,""+k,Re);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case C:return k.key===Ye?g(V,G,k,Re):null;case f:return k.key===Ye?q(V,G,k,Re):null;case se:return k=xr(k),ee(V,G,k,Re)}if(z(k)||Ce(k))return Ye!==null?null:ie(V,G,k,Re,null);if(typeof k.then=="function")return ee(V,G,Ni(k),Re);if(k.$$typeof===Z)return ee(V,G,ui(V,k),Re);Ii(V,k)}return null}function re(V,G,k,Re,Ye){if(typeof Re=="string"&&Re!==""||typeof Re=="number"||typeof Re=="bigint")return V=V.get(k)||null,h(G,V,""+Re,Ye);if(typeof Re=="object"&&Re!==null){switch(Re.$$typeof){case C:return V=V.get(Re.key===null?k:Re.key)||null,g(G,V,Re,Ye);case f:return V=V.get(Re.key===null?k:Re.key)||null,q(G,V,Re,Ye);case se:return Re=xr(Re),re(V,G,k,Re,Ye)}if(z(Re)||Ce(Re))return V=V.get(k)||null,ie(G,V,Re,Ye,null);if(typeof Re.then=="function")return re(V,G,k,Ni(Re),Ye);if(Re.$$typeof===Z)return re(V,G,k,ui(G,Re),Ye);Ii(G,Re)}return null}function Ue(V,G,k,Re){for(var Ye=null,ct=null,Be=G,Je=G=0,it=null;Be!==null&&Je<k.length;Je++){Be.index>Je?(it=Be,Be=null):it=Be.sibling;var St=ee(V,Be,k[Je],Re);if(St===null){Be===null&&(Be=it);break}e&&Be&&St.alternate===null&&t(V,Be),G=o(St,G,Je),ct===null?Ye=St:ct.sibling=St,ct=St,Be=it}if(Je===k.length)return n(V,Be),ot&&ha(V,Je),Ye;if(Be===null){for(;Je<k.length;Je++)Be=de(V,k[Je],Re),Be!==null&&(G=o(Be,G,Je),ct===null?Ye=Be:ct.sibling=Be,ct=Be);return ot&&ha(V,Je),Ye}for(Be=s(Be);Je<k.length;Je++)it=re(Be,V,Je,k[Je],Re),it!==null&&(e&&it.alternate!==null&&Be.delete(it.key===null?Je:it.key),G=o(it,G,Je),ct===null?Ye=it:ct.sibling=it,ct=it);return e&&Be.forEach(function(Tr){return t(V,Tr)}),ot&&ha(V,Je),Ye}function je(V,G,k,Re){if(k==null)throw Error(T(151));for(var Ye=null,ct=null,Be=G,Je=G=0,it=null,St=k.next();Be!==null&&!St.done;Je++,St=k.next()){Be.index>Je?(it=Be,Be=null):it=Be.sibling;var Tr=ee(V,Be,St.value,Re);if(Tr===null){Be===null&&(Be=it);break}e&&Be&&Tr.alternate===null&&t(V,Be),G=o(Tr,G,Je),ct===null?Ye=Tr:ct.sibling=Tr,ct=Tr,Be=it}if(St.done)return n(V,Be),ot&&ha(V,Je),Ye;if(Be===null){for(;!St.done;Je++,St=k.next())St=de(V,St.value,Re),St!==null&&(G=o(St,G,Je),ct===null?Ye=St:ct.sibling=St,ct=St);return ot&&ha(V,Je),Ye}for(Be=s(Be);!St.done;Je++,St=k.next())St=re(Be,V,Je,St.value,Re),St!==null&&(e&&St.alternate!==null&&Be.delete(St.key===null?Je:St.key),G=o(St,G,Je),ct===null?Ye=St:ct.sibling=St,ct=St);return e&&Be.forEach(function(EI){return t(V,EI)}),ot&&ha(V,Je),Ye}function It(V,G,k,Re){if(typeof k=="object"&&k!==null&&k.type===m&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case C:e:{for(var Ye=k.key;G!==null;){if(G.key===Ye){if(Ye=k.type,Ye===m){if(G.tag===7){n(V,G.sibling),Re=i(G,k.props.children),Re.return=V,V=Re;break e}}else if(G.elementType===Ye||typeof Ye=="object"&&Ye!==null&&Ye.$$typeof===se&&xr(Ye)===G.type){n(V,G.sibling),Re=i(G,k.props),rl(Re,k),Re.return=V,V=Re;break e}n(V,G);break}else t(V,G);G=G.sibling}k.type===m?(Re=pr(k.props.children,V.mode,Re,k.key),Re.return=V,V=Re):(Re=ci(k.type,k.key,k.props,null,V.mode,Re),rl(Re,k),Re.return=V,V=Re)}return S(V);case f:e:{for(Ye=k.key;G!==null;){if(G.key===Ye)if(G.tag===4&&G.stateNode.containerInfo===k.containerInfo&&G.stateNode.implementation===k.implementation){n(V,G.sibling),Re=i(G,k.children||[]),Re.return=V,V=Re;break e}else{n(V,G);break}else t(V,G);G=G.sibling}Re=nE(k,V.mode,Re),Re.return=V,V=Re}return S(V);case se:return k=xr(k),It(V,G,k,Re)}if(z(k))return Ue(V,G,k,Re);if(Ce(k)){if(Ye=Ce(k),typeof Ye!="function")throw Error(T(150));return k=Ye.call(k),je(V,G,k,Re)}if(typeof k.then=="function")return It(V,G,Ni(k),Re);if(k.$$typeof===Z)return It(V,G,ui(V,k),Re);Ii(V,k)}return typeof k=="string"&&k!==""||typeof k=="number"||typeof k=="bigint"?(k=""+k,G!==null&&G.tag===6?(n(V,G.sibling),Re=i(G,k),Re.return=V,V=Re):(n(V,G),Re=tE(k,V.mode,Re),Re.return=V,V=Re),S(V)):n(V,G)}return function(V,G,k,Re){try{al=0;var Ye=It(V,G,k,Re);return Ss=null,Ye}catch(Be){if(Be===cs||Be===di)throw Be;var ct=Dn(29,Be,null,V.mode);return ct.lanes=Re,ct.return=V,ct}finally{}}}var yr=MS(!0),PS=MS(!1),za=!1;function uE(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function AE(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 ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function $a(e,t,n){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(Rt&2)!==0){var i=s.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),s.pending=t,t=Ti(e),dS(e,null,n),t}return Ei(e,s,t,n),Ti(e)}function sl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194048)!==0)){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,zl(e,n)}}function dE(e,t){var n=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,n===s)){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:s.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:s.shared,callbacks:s.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var OE=!1;function ll(){if(OE){var e=Ts;if(e!==null)throw e}}function il(e,t,n,s){OE=!1;var i=e.updateQueue;za=!1;var o=i.firstBaseUpdate,S=i.lastBaseUpdate,h=i.shared.pending;if(h!==null){i.shared.pending=null;var g=h,q=g.next;g.next=null,S===null?o=q:S.next=q,S=g;var ie=e.alternate;ie!==null&&(ie=ie.updateQueue,h=ie.lastBaseUpdate,h!==S&&(h===null?ie.firstBaseUpdate=q:h.next=q,ie.lastBaseUpdate=g))}if(o!==null){var de=i.baseState;S=0,ie=q=g=null,h=o;do{var ee=h.lane&-536870913,re=ee!==h.lane;if(re?(lt&ee)===ee:(s&ee)===ee){ee!==0&&ee===Es&&(OE=!0),ie!==null&&(ie=ie.next={lane:0,tag:h.tag,payload:h.payload,callback:null,next:null});e:{var Ue=e,je=h;ee=t;var It=n;switch(je.tag){case 1:if(Ue=je.payload,typeof Ue=="function"){de=Ue.call(It,de,ee);break e}de=Ue;break e;case 3:Ue.flags=Ue.flags&-65537|128;case 0:if(Ue=je.payload,ee=typeof Ue=="function"?Ue.call(It,de,ee):Ue,ee==null)break e;de=d({},de,ee);break e;case 2:za=!0}}ee=h.callback,ee!==null&&(e.flags|=64,re&&(e.flags|=8192),re=i.callbacks,re===null?i.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:h.tag,payload:h.payload,callback:h.callback,next:null},ie===null?(q=ie=re,g=de):ie=ie.next=re,S|=ee;if(h=h.next,h===null){if(h=i.shared.pending,h===null)break;re=h,h=re.next,re.next=null,i.lastBaseUpdate=re,i.shared.pending=null}}while(!0);ie===null&&(g=de),i.baseState=g,i.firstBaseUpdate=q,i.lastBaseUpdate=ie,o===null&&(i.shared.lanes=0),er|=S,e.lanes=S,e.memoizedState=de}}function US(e,t){if(typeof e!="function")throw Error(T(191,e));e.call(t)}function bS(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)US(n[e],t)}var Rs=p(null),hi=p(0);function GS(e,t){e=ga,ne(hi,e),ne(Rs,t),ga=e|t.baseLanes}function NE(){ne(hi,ga),ne(Rs,Rs.current)}function IE(){ga=hi.current,H(Rs),H(hi)}var yn=p(null),Kn=null;function Ja(e){var t=e.alternate;ne(Ft,Ft.current&1),ne(yn,e),Kn===null&&(t===null||Rs.current!==null||t.memoizedState!==null)&&(Kn=e)}function hE(e){ne(Ft,Ft.current),ne(yn,e),Kn===null&&(Kn=e)}function BS(e){e.tag===22?(ne(Ft,Ft.current),ne(yn,e),Kn===null&&(Kn=e)):qa()}function qa(){ne(Ft,Ft.current),ne(yn,yn.current)}function gn(e){H(yn),Kn===e&&(Kn=null),H(Ft)}var Ft=p(0);function fi(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||mT(n)||vT(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 pa=0,$e=null,Ot=null,Vt=null,Ci=!1,us=!1,gr=!1,pi=0,ol=0,As=null,ZO=0;function Ut(){throw Error(T(321))}function fE(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!xn(e[n],t[n]))return!1;return!0}function CE(e,t,n,s,i,o){return pa=o,$e=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,D.H=e===null||e.memoizedState===null?fR:BE,gr=!1,o=n(s,i),gr=!1,us&&(o=FS(t,n,s,i)),HS(e),o}function HS(e){D.H=cl;var t=Ot!==null&&Ot.next!==null;if(pa=0,Vt=Ot=$e=null,Ci=!1,ol=0,As=null,t)throw Error(T(300));e===null||wt||(e=e.dependencies,e!==null&&Ri(e)&&(wt=!0))}function FS(e,t,n,s){$e=e;var i=0;do{if(us&&(As=null),ol=0,us=!1,25<=i)throw Error(T(301));if(i+=1,Vt=Ot=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}D.H=CR,o=t(n,s)}while(us);return o}function eN(){var e=D.H,t=e.useState()[0];return t=typeof t.then=="function"?El(t):t,e=e.useState()[0],(Ot!==null?Ot.memoizedState:null)!==e&&($e.flags|=1024),t}function pE(){var e=pi!==0;return pi=0,e}function LE(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function _E(e){if(Ci){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Ci=!1}pa=0,Vt=Ot=$e=null,us=!1,ol=pi=0,As=null}function An(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Vt===null?$e.memoizedState=Vt=e:Vt=Vt.next=e,Vt}function Yt(){if(Ot===null){var e=$e.alternate;e=e!==null?e.memoizedState:null}else e=Ot.next;var t=Vt===null?$e.memoizedState:Vt.next;if(t!==null)Vt=t,Ot=e;else{if(e===null)throw $e.alternate===null?Error(T(467)):Error(T(310));Ot=e,e={memoizedState:Ot.memoizedState,baseState:Ot.baseState,baseQueue:Ot.baseQueue,queue:Ot.queue,next:null},Vt===null?$e.memoizedState=Vt=e:Vt=Vt.next=e}return Vt}function Li(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function El(e){var t=ol;return ol+=1,As===null&&(As=[]),e=DS(As,e,t),t=$e,(Vt===null?t.memoizedState:Vt.next)===null&&(t=t.alternate,D.H=t===null||t.memoizedState===null?fR:BE),e}function _i(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return El(e);if(e.$$typeof===Z)return ln(e)}throw Error(T(438,String(e)))}function mE(e){var t=null,n=$e.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var s=$e.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(t={data:s.data.map(function(i){return i.slice()}),index:0})))}if(t==null&&(t={data:[],index:0}),n===null&&(n=Li(),$e.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),s=0;s<e;s++)n[s]=$;return t.index++,n}function La(e,t){return typeof t=="function"?t(e):t}function mi(e){var t=Yt();return vE(t,Ot,e)}function vE(e,t,n){var s=e.queue;if(s===null)throw Error(T(311));s.lastRenderedReducer=n;var i=e.baseQueue,o=s.pending;if(o!==null){if(i!==null){var S=i.next;i.next=o.next,o.next=S}t.baseQueue=i=o,s.pending=null}if(o=e.baseState,i===null)e.memoizedState=o;else{t=i.next;var h=S=null,g=null,q=t,ie=!1;do{var de=q.lane&-536870913;if(de!==q.lane?(lt&de)===de:(pa&de)===de){var ee=q.revertLane;if(ee===0)g!==null&&(g=g.next={lane:0,revertLane:0,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null}),de===Es&&(ie=!0);else if((pa&ee)===ee){q=q.next,ee===Es&&(ie=!0);continue}else de={lane:0,revertLane:q.revertLane,gesture:null,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},g===null?(h=g=de,S=o):g=g.next=de,$e.lanes|=ee,er|=ee;de=q.action,gr&&n(o,de),o=q.hasEagerState?q.eagerState:n(o,de)}else ee={lane:de,revertLane:q.revertLane,gesture:q.gesture,action:q.action,hasEagerState:q.hasEagerState,eagerState:q.eagerState,next:null},g===null?(h=g=ee,S=o):g=g.next=ee,$e.lanes|=de,er|=de;q=q.next}while(q!==null&&q!==t);if(g===null?S=o:g.next=h,!xn(o,e.memoizedState)&&(wt=!0,ie&&(n=Ts,n!==null)))throw n;e.memoizedState=o,e.baseState=S,e.baseQueue=g,s.lastRenderedState=o}return i===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function xE(e){var t=Yt(),n=t.queue;if(n===null)throw Error(T(311));n.lastRenderedReducer=e;var s=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);xn(o,t.memoizedState)||(wt=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,s]}function YS(e,t,n){var s=$e,i=Yt(),o=ot;if(o){if(n===void 0)throw Error(T(407));n=n()}else n=t();var S=!xn((Ot||i).memoizedState,n);if(S&&(i.memoizedState=n,wt=!0),i=i.queue,gE(wS.bind(null,s,i,e),[e]),i.getSnapshot!==t||S||Vt!==null&&Vt.memoizedState.tag&1){if(s.flags|=2048,ds(9,{destroy:void 0},VS.bind(null,s,i,n,t),null),Ct===null)throw Error(T(349));o||(pa&127)!==0||jS(s,t,n)}return n}function jS(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$e.updateQueue,t===null?(t=Li(),$e.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function VS(e,t,n,s){t.value=n,t.getSnapshot=s,WS(t)&&XS(e)}function wS(e,t,n){return n(function(){WS(t)&&XS(e)})}function WS(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!xn(e,n)}catch{return!0}}function XS(e){var t=Cr(e,2);t!==null&&Ln(t,e,2)}function DE(e){var t=An();if(typeof e=="function"){var n=e;if(e=n(),gr){an(!0);try{n()}finally{an(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:e},t}function KS(e,t,n,s){return e.baseState=n,vE(e,Ot,typeof s=="function"?s:La)}function tN(e,t,n,s,i){if(Di(e))throw Error(T(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)}};D.T!==null?n(!0):o.isTransition=!1,s(o),n=t.pending,n===null?(o.next=t.pending=o,zS(t,o)):(o.next=n.next,t.pending=n.next=o)}}function zS(e,t){var n=t.action,s=t.payload,i=e.state;if(t.isTransition){var o=D.T,S={};D.T=S;try{var h=n(i,s),g=D.S;g!==null&&g(S,h),kS(e,t,h)}catch(q){yE(e,t,q)}finally{o!==null&&S.types!==null&&(o.types=S.types),D.T=o}}else try{o=n(i,s),kS(e,t,o)}catch(q){yE(e,t,q)}}function kS(e,t,n){n!==null&&typeof n=="object"&&typeof n.then=="function"?n.then(function(s){$S(e,t,s)},function(s){return yE(e,t,s)}):$S(e,t,n)}function $S(e,t,n){t.status="fulfilled",t.value=n,JS(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,zS(e,n)))}function yE(e,t,n){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do t.status="rejected",t.reason=n,JS(t),t=t.next;while(t!==s)}e.action=null}function JS(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function qS(e,t){return t}function QS(e,t){if(ot){var n=Ct.formState;if(n!==null){e:{var s=$e;if(ot){if(_t){t:{for(var i=_t,o=Xn;i.nodeType!==8;){if(!o){i=null;break t}if(i=zn(i.nextSibling),i===null){i=null;break t}}o=i.data,i=o==="F!"||o==="F"?i:null}if(i){_t=zn(i.nextSibling),s=i.data==="F!";break e}}Xa(s)}s=!1}s&&(t=n[0])}}return n=An(),n.memoizedState=n.baseState=t,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qS,lastRenderedState:t},n.queue=s,n=NR.bind(null,$e,s),s.dispatch=n,s=DE(!1),o=GE.bind(null,$e,!1,s.queue),s=An(),i={state:t,dispatch:null,action:e,pending:null},s.queue=i,n=tN.bind(null,$e,i,o,n),i.dispatch=n,s.memoizedState=e,[t,n,!1]}function ZS(e){var t=Yt();return eR(t,Ot,e)}function eR(e,t,n){if(t=vE(e,t,qS)[0],e=mi(La)[0],typeof t=="object"&&t!==null&&typeof t.then=="function")try{var s=El(t)}catch(S){throw S===cs?di:S}else s=t;t=Yt();var i=t.queue,o=i.dispatch;return n!==t.memoizedState&&($e.flags|=2048,ds(9,{destroy:void 0},nN.bind(null,i,n),null)),[s,o,e]}function nN(e,t){e.action=t}function tR(e){var t=Yt(),n=Ot;if(n!==null)return eR(t,n,e);Yt(),t=t.memoizedState,n=Yt();var s=n.queue.dispatch;return n.memoizedState=e,[t,s,!1]}function ds(e,t,n,s){return e={tag:e,create:n,deps:s,inst:t,next:null},t=$e.updateQueue,t===null&&(t=Li(),$e.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(s=n.next,n.next=e,e.next=s,t.lastEffect=e),e}function nR(){return Yt().memoizedState}function vi(e,t,n,s){var i=An();$e.flags|=e,i.memoizedState=ds(1|t,{destroy:void 0},n,s===void 0?null:s)}function xi(e,t,n,s){var i=Yt();s=s===void 0?null:s;var o=i.memoizedState.inst;Ot!==null&&s!==null&&fE(s,Ot.memoizedState.deps)?i.memoizedState=ds(t,o,n,s):($e.flags|=e,i.memoizedState=ds(1|t,o,n,s))}function aR(e,t){vi(8390656,8,e,t)}function gE(e,t){xi(2048,8,e,t)}function aN(e){$e.flags|=4;var t=$e.updateQueue;if(t===null)t=Li(),$e.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function rR(e){var t=Yt().memoizedState;return aN({ref:t,nextImpl:e}),function(){if((Rt&2)!==0)throw Error(T(440));return t.impl.apply(void 0,arguments)}}function sR(e,t){return xi(4,2,e,t)}function lR(e,t){return xi(4,4,e,t)}function iR(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 oR(e,t,n){n=n!=null?n.concat([e]):null,xi(4,4,iR.bind(null,t,e),n)}function ME(){}function ER(e,t){var n=Yt();t=t===void 0?null:t;var s=n.memoizedState;return t!==null&&fE(t,s[1])?s[0]:(n.memoizedState=[e,t],e)}function TR(e,t){var n=Yt();t=t===void 0?null:t;var s=n.memoizedState;if(t!==null&&fE(t,s[1]))return s[0];if(s=e(),gr){an(!0);try{e()}finally{an(!1)}}return n.memoizedState=[s,t],s}function PE(e,t,n){return n===void 0||(pa&1073741824)!==0&&(lt&261930)===0?e.memoizedState=t:(e.memoizedState=n,e=Su(),$e.lanes|=e,er|=e,n)}function cR(e,t,n,s){return xn(n,t)?n:Rs.current!==null?(e=PE(e,n,s),xn(e,t)||(wt=!0),e):(pa&42)===0||(pa&1073741824)!==0&&(lt&261930)===0?(wt=!0,e.memoizedState=n):(e=Su(),$e.lanes|=e,er|=e,t)}function SR(e,t,n,s,i){var o=oe.p;oe.p=o!==0&&8>o?o:8;var S=D.T,h={};D.T=h,GE(e,!1,t,n);try{var g=i(),q=D.S;if(q!==null&&q(h,g),g!==null&&typeof g=="object"&&typeof g.then=="function"){var ie=QO(g,s);Tl(e,t,ie,Un(e))}else Tl(e,t,s,Un(e))}catch(de){Tl(e,t,{then:function(){},status:"rejected",reason:de},Un())}finally{oe.p=o,S!==null&&h.types!==null&&(S.types=h.types),D.T=S}}function rN(){}function UE(e,t,n,s){if(e.tag!==5)throw Error(T(476));var i=RR(e).queue;SR(e,i,t,Oe,n===null?rN:function(){return uR(e),n(s)})}function RR(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Oe,baseState:Oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:Oe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:La,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function uR(e){var t=RR(e);t.next===null&&(t=e.alternate.memoizedState),Tl(e,t.next.queue,{},Un())}function bE(){return ln(vl)}function AR(){return Yt().memoizedState}function dR(){return Yt().memoizedState}function sN(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Un();e=ka(n);var s=$a(t,e,n);s!==null&&(Ln(s,t,n),sl(s,t,n)),t={cache:TE()},e.payload=t;return}t=t.return}}function lN(e,t,n){var s=Un();n={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Di(e)?IR(t,n):(n=Zo(e,t,n,s),n!==null&&(Ln(n,e,s),hR(n,t,s)))}function NR(e,t,n){var s=Un();Tl(e,t,n,s)}function Tl(e,t,n,s){var i={lane:s,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Di(e))IR(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,h=o(S,n);if(i.hasEagerState=!0,i.eagerState=h,xn(h,S))return Ei(e,t,i,0),Ct===null&&oi(),!1}catch{}finally{}if(n=Zo(e,t,i,s),n!==null)return Ln(n,e,s),hR(n,t,s),!0}return!1}function GE(e,t,n,s){if(s={lane:2,revertLane:uT(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},Di(e)){if(t)throw Error(T(479))}else t=Zo(e,n,s,2),t!==null&&Ln(t,e,2)}function Di(e){var t=e.alternate;return e===$e||t!==null&&t===$e}function IR(e,t){us=Ci=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hR(e,t,n){if((n&4194048)!==0){var s=t.lanes;s&=e.pendingLanes,n|=s,t.lanes=n,zl(e,n)}}var cl={readContext:ln,use:_i,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};cl.useEffectEvent=Ut;var fR={readContext:ln,use:_i,useCallback:function(e,t){return An().memoizedState=[e,t===void 0?null:t],e},useContext:ln,useEffect:aR,useImperativeHandle:function(e,t,n){n=n!=null?n.concat([e]):null,vi(4194308,4,iR.bind(null,t,e),n)},useLayoutEffect:function(e,t){return vi(4194308,4,e,t)},useInsertionEffect:function(e,t){vi(4,2,e,t)},useMemo:function(e,t){var n=An();t=t===void 0?null:t;var s=e();if(gr){an(!0);try{e()}finally{an(!1)}}return n.memoizedState=[s,t],s},useReducer:function(e,t,n){var s=An();if(n!==void 0){var i=n(t);if(gr){an(!0);try{n(t)}finally{an(!1)}}}else i=t;return s.memoizedState=s.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},s.queue=e,e=e.dispatch=lN.bind(null,$e,e),[s.memoizedState,e]},useRef:function(e){var t=An();return e={current:e},t.memoizedState=e},useState:function(e){e=DE(e);var t=e.queue,n=NR.bind(null,$e,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ME,useDeferredValue:function(e,t){var n=An();return PE(n,e,t)},useTransition:function(){var e=DE(!1);return e=SR.bind(null,$e,e.queue,!0,!1),An().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var s=$e,i=An();if(ot){if(n===void 0)throw Error(T(407));n=n()}else{if(n=t(),Ct===null)throw Error(T(349));(lt&127)!==0||jS(s,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,aR(wS.bind(null,s,o,e),[e]),s.flags|=2048,ds(9,{destroy:void 0},VS.bind(null,s,o,n,t),null),n},useId:function(){var e=An(),t=Ct.identifierPrefix;if(ot){var n=oa,s=ia;n=(s&~(1<<32-Kt(s)-1)).toString(32)+n,t="_"+t+"R_"+n,n=pi++,0<n&&(t+="H"+n.toString(32)),t+="_"}else n=ZO++,t="_"+t+"r_"+n.toString(32)+"_";return e.memoizedState=t},useHostTransitionStatus:bE,useFormState:QS,useActionState:QS,useOptimistic:function(e){var t=An();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=GE.bind(null,$e,!0,n),n.dispatch=t,[e,t]},useMemoCache:mE,useCacheRefresh:function(){return An().memoizedState=sN.bind(null,$e)},useEffectEvent:function(e){var t=An(),n={impl:e};return t.memoizedState=n,function(){if((Rt&2)!==0)throw Error(T(440));return n.impl.apply(void 0,arguments)}}},BE={readContext:ln,use:_i,useCallback:ER,useContext:ln,useEffect:gE,useImperativeHandle:oR,useInsertionEffect:sR,useLayoutEffect:lR,useMemo:TR,useReducer:mi,useRef:nR,useState:function(){return mi(La)},useDebugValue:ME,useDeferredValue:function(e,t){var n=Yt();return cR(n,Ot.memoizedState,e,t)},useTransition:function(){var e=mi(La)[0],t=Yt().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:YS,useId:AR,useHostTransitionStatus:bE,useFormState:ZS,useActionState:ZS,useOptimistic:function(e,t){var n=Yt();return KS(n,Ot,e,t)},useMemoCache:mE,useCacheRefresh:dR};BE.useEffectEvent=rR;var CR={readContext:ln,use:_i,useCallback:ER,useContext:ln,useEffect:gE,useImperativeHandle:oR,useInsertionEffect:sR,useLayoutEffect:lR,useMemo:TR,useReducer:xE,useRef:nR,useState:function(){return xE(La)},useDebugValue:ME,useDeferredValue:function(e,t){var n=Yt();return Ot===null?PE(n,e,t):cR(n,Ot.memoizedState,e,t)},useTransition:function(){var e=xE(La)[0],t=Yt().memoizedState;return[typeof e=="boolean"?e:El(e),t]},useSyncExternalStore:YS,useId:AR,useHostTransitionStatus:bE,useFormState:tR,useActionState:tR,useOptimistic:function(e,t){var n=Yt();return Ot!==null?KS(n,Ot,e,t):(n.baseState=e,[e,n.queue.dispatch])},useMemoCache:mE,useCacheRefresh:dR};CR.useEffectEvent=rR;function HE(e,t,n,s){t=e.memoizedState,n=n(s,t),n=n==null?t:d({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var FE={enqueueSetState:function(e,t,n){e=e._reactInternals;var s=Un(),i=ka(s);i.payload=t,n!=null&&(i.callback=n),t=$a(e,i,s),t!==null&&(Ln(t,e,s),sl(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var s=Un(),i=ka(s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=$a(e,i,s),t!==null&&(Ln(t,e,s),sl(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Un(),s=ka(n);s.tag=2,t!=null&&(s.callback=t),t=$a(e,s,n),t!==null&&(Ln(t,e,n),sl(t,e,n))}};function pR(e,t,n,s,i,o,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,o,S):t.prototype&&t.prototype.isPureReactComponent?!qs(n,s)||!qs(i,o):!0}function LR(e,t,n,s){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,s),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,s),t.state!==e&&FE.enqueueReplaceState(t,t.state,null)}function Mr(e,t){var n=t;if("ref"in t){n={};for(var s in t)s!=="ref"&&(n[s]=t[s])}if(e=e.defaultProps){n===t&&(n=d({},n));for(var i in e)n[i]===void 0&&(n[i]=e[i])}return n}function _R(e){ii(e)}function mR(e){console.error(e)}function vR(e){ii(e)}function yi(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(s){setTimeout(function(){throw s})}}function xR(e,t,n){try{var s=e.onCaughtError;s(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(i){setTimeout(function(){throw i})}}function YE(e,t,n){return n=ka(n),n.tag=3,n.payload={element:null},n.callback=function(){yi(e,t)},n}function DR(e){return e=ka(e),e.tag=3,e}function yR(e,t,n,s){var i=n.type.getDerivedStateFromError;if(typeof i=="function"){var o=s.value;e.payload=function(){return i(o)},e.callback=function(){xR(t,n,s)}}var S=n.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){xR(t,n,s),typeof i!="function"&&(tr===null?tr=new Set([this]):tr.add(this));var h=s.stack;this.componentDidCatch(s.value,{componentStack:h!==null?h:""})})}function iN(e,t,n,s,i){if(n.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(t=n.alternate,t!==null&&os(t,n,i,!0),n=yn.current,n!==null){switch(n.tag){case 31:case 13:return Kn===null?Vi():n.alternate===null&&bt===0&&(bt=3),n.flags&=-257,n.flags|=65536,n.lanes=i,s===Oi?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([s]):t.add(s),cT(e,s,i)),!1;case 22:return n.flags|=65536,s===Oi?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([s])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([s]):n.add(s)),cT(e,s,i)),!1}throw Error(T(435,n.tag))}return cT(e,s,i),Vi(),!1}if(ot)return t=yn.current,t!==null?((t.flags&65536)===0&&(t.flags|=256),t.flags|=65536,t.lanes=i,s!==sE&&(e=Error(T(422),{cause:s}),el(Vn(e,n)))):(s!==sE&&(t=Error(T(423),{cause:s}),el(Vn(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,s=Vn(s,n),i=YE(e.stateNode,s,i),dE(e,i),bt!==4&&(bt=2)),!1;var o=Error(T(520),{cause:s});if(o=Vn(o,n),Il===null?Il=[o]:Il.push(o),bt!==4&&(bt=2),t===null)return!0;s=Vn(s,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=YE(n.stateNode,s,e),dE(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"&&(tr===null||!tr.has(o))))return n.flags|=65536,i&=-i,n.lanes|=i,i=DR(i),yR(i,e,n,s),dE(n,i),!1}n=n.return}while(n!==null);return!1}var jE=Error(T(461)),wt=!1;function on(e,t,n,s){t.child=e===null?PS(t,null,n,s):yr(t,e.child,n,s)}function gR(e,t,n,s,i){n=n.render;var o=t.ref;if("ref"in s){var S={};for(var h in s)h!=="ref"&&(S[h]=s[h])}else S=s;return mr(t),s=CE(e,t,n,S,o,i),h=pE(),e!==null&&!wt?(LE(e,t,i),_a(e,t,i)):(ot&&h&&aE(t),t.flags|=1,on(e,t,s,i),t.child)}function MR(e,t,n,s,i){if(e===null){var o=n.type;return typeof o=="function"&&!eE(o)&&o.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=o,PR(e,t,o,s,i)):(e=ci(n.type,null,s,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!$E(e,i)){var S=o.memoizedProps;if(n=n.compare,n=n!==null?n:qs,n(S,s)&&e.ref===t.ref)return _a(e,t,i)}return t.flags|=1,e=Ia(o,s),e.ref=t.ref,e.return=t,t.child=e}function PR(e,t,n,s,i){if(e!==null){var o=e.memoizedProps;if(qs(o,s)&&e.ref===t.ref)if(wt=!1,t.pendingProps=s=o,$E(e,i))(e.flags&131072)!==0&&(wt=!0);else return t.lanes=e.lanes,_a(e,t,i)}return VE(e,t,n,s,i)}function UR(e,t,n,s){var i=s.children,o=e!==null?e.memoizedState:null;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((t.flags&128)!==0){if(o=o!==null?o.baseLanes|n:n,e!==null){for(s=t.child=e.child,i=0;s!==null;)i=i|s.lanes|s.childLanes,s=s.sibling;s=i&~o}else s=0,t.child=null;return bR(e,t,o,n,s)}if((n&536870912)!==0)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ai(t,o!==null?o.cachePool:null),o!==null?GS(t,o):NE(),BS(t);else return s=t.lanes=536870912,bR(e,t,o!==null?o.baseLanes|n:n,n,s)}else o!==null?(Ai(t,o.cachePool),GS(t,o),qa(),t.memoizedState=null):(e!==null&&Ai(t,null),NE(),qa());return on(e,t,i,n),t.child}function Sl(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function bR(e,t,n,s,i){var o=SE();return o=o===null?null:{parent:jt._currentValue,pool:o},t.memoizedState={baseLanes:n,cachePool:o},e!==null&&Ai(t,null),NE(),BS(t),e!==null&&os(e,t,s,!0),t.childLanes=i,null}function gi(e,t){return t=Pi({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function GR(e,t,n){return yr(t,e.child,null,n),e=gi(t,t.pendingProps),e.flags|=2,gn(t),t.memoizedState=null,e}function oN(e,t,n){var s=t.pendingProps,i=(t.flags&128)!==0;if(t.flags&=-129,e===null){if(ot){if(s.mode==="hidden")return e=gi(t,s),t.lanes=536870912,Sl(null,e);if(hE(t),(e=_t)?(e=ku(e,Xn),e=e!==null&&e.data==="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wa!==null?{id:ia,overflow:oa}:null,retryLane:536870912,hydrationErrors:null},n=NS(e),n.return=t,t.child=n,sn=t,_t=null)):e=null,e===null)throw Xa(t);return t.lanes=536870912,null}return gi(t,s)}var o=e.memoizedState;if(o!==null){var S=o.dehydrated;if(hE(t),i)if(t.flags&256)t.flags&=-257,t=GR(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(T(558));else if(wt||os(e,t,n,!1),i=(n&e.childLanes)!==0,wt||i){if(s=Ct,s!==null&&(S=$r(s,n),S!==0&&S!==o.retryLane))throw o.retryLane=S,Cr(e,S),Ln(s,e,S),jE;Vi(),t=GR(e,t,n)}else e=o.treeContext,_t=zn(S.nextSibling),sn=t,ot=!0,Wa=null,Xn=!1,e!==null&&fS(t,e),t=gi(t,s),t.flags|=4096;return t}return e=Ia(e.child,{mode:s.mode,children:s.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Mi(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(T(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function VE(e,t,n,s,i){return mr(t),n=CE(e,t,n,s,void 0,i),s=pE(),e!==null&&!wt?(LE(e,t,i),_a(e,t,i)):(ot&&s&&aE(t),t.flags|=1,on(e,t,n,i),t.child)}function BR(e,t,n,s,i,o){return mr(t),t.updateQueue=null,n=FS(t,s,n,i),HS(e),s=pE(),e!==null&&!wt?(LE(e,t,o),_a(e,t,o)):(ot&&s&&aE(t),t.flags|=1,on(e,t,n,o),t.child)}function HR(e,t,n,s,i){if(mr(t),t.stateNode===null){var o=rs,S=n.contextType;typeof S=="object"&&S!==null&&(o=ln(S)),o=new n(s,o),t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,o.updater=FE,t.stateNode=o,o._reactInternals=t,o=t.stateNode,o.props=s,o.state=t.memoizedState,o.refs={},uE(t),S=n.contextType,o.context=typeof S=="object"&&S!==null?ln(S):rs,o.state=t.memoizedState,S=n.getDerivedStateFromProps,typeof S=="function"&&(HE(t,n,S,s),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&&FE.enqueueReplaceState(o,o.state,null),il(t,s,o,i),ll(),o.state=t.memoizedState),typeof o.componentDidMount=="function"&&(t.flags|=4194308),s=!0}else if(e===null){o=t.stateNode;var h=t.memoizedProps,g=Mr(n,h);o.props=g;var q=o.context,ie=n.contextType;S=rs,typeof ie=="object"&&ie!==null&&(S=ln(ie));var de=n.getDerivedStateFromProps;ie=typeof de=="function"||typeof o.getSnapshotBeforeUpdate=="function",h=t.pendingProps!==h,ie||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(h||q!==S)&&LR(t,o,s,S),za=!1;var ee=t.memoizedState;o.state=ee,il(t,s,o,i),ll(),q=t.memoizedState,h||ee!==q||za?(typeof de=="function"&&(HE(t,n,de,s),q=t.memoizedState),(g=za||pR(t,n,g,s,ee,q,S))?(ie||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=s,t.memoizedState=q),o.props=s,o.state=q,o.context=S,s=g):(typeof o.componentDidMount=="function"&&(t.flags|=4194308),s=!1)}else{o=t.stateNode,AE(e,t),S=t.memoizedProps,ie=Mr(n,S),o.props=ie,de=t.pendingProps,ee=o.context,q=n.contextType,g=rs,typeof q=="object"&&q!==null&&(g=ln(q)),h=n.getDerivedStateFromProps,(q=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(S!==de||ee!==g)&&LR(t,o,s,g),za=!1,ee=t.memoizedState,o.state=ee,il(t,s,o,i),ll();var re=t.memoizedState;S!==de||ee!==re||za||e!==null&&e.dependencies!==null&&Ri(e.dependencies)?(typeof h=="function"&&(HE(t,n,h,s),re=t.memoizedState),(ie=za||pR(t,n,ie,s,ee,re,g)||e!==null&&e.dependencies!==null&&Ri(e.dependencies))?(q||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(s,re,g),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(s,re,g)),typeof o.componentDidUpdate=="function"&&(t.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof o.componentDidUpdate!="function"||S===e.memoizedProps&&ee===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ee===e.memoizedState||(t.flags|=1024),t.memoizedProps=s,t.memoizedState=re),o.props=s,o.state=re,o.context=g,s=ie):(typeof o.componentDidUpdate!="function"||S===e.memoizedProps&&ee===e.memoizedState||(t.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&ee===e.memoizedState||(t.flags|=1024),s=!1)}return o=s,Mi(e,t),s=(t.flags&128)!==0,o||s?(o=t.stateNode,n=s&&typeof n.getDerivedStateFromError!="function"?null:o.render(),t.flags|=1,e!==null&&s?(t.child=yr(t,e.child,null,i),t.child=yr(t,null,n,i)):on(e,t,n,i),t.memoizedState=o.state,e=t.child):e=_a(e,t,i),e}function FR(e,t,n,s){return Lr(),t.flags|=256,on(e,t,n,s),t.child}var wE={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function WE(e){return{baseLanes:e,cachePool:vS()}}function XE(e,t,n){return e=e!==null?e.childLanes&~n:0,t&&(e|=Pn),e}function YR(e,t,n){var s=t.pendingProps,i=!1,o=(t.flags&128)!==0,S;if((S=o)||(S=e!==null&&e.memoizedState===null?!1:(Ft.current&2)!==0),S&&(i=!0,t.flags&=-129),S=(t.flags&32)!==0,t.flags&=-33,e===null){if(ot){if(i?Ja(t):qa(),(e=_t)?(e=ku(e,Xn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:wa!==null?{id:ia,overflow:oa}:null,retryLane:536870912,hydrationErrors:null},n=NS(e),n.return=t,t.child=n,sn=t,_t=null)):e=null,e===null)throw Xa(t);return vT(e)?t.lanes=32:t.lanes=536870912,null}var h=s.children;return s=s.fallback,i?(qa(),i=t.mode,h=Pi({mode:"hidden",children:h},i),s=pr(s,i,n,null),h.return=t,s.return=t,h.sibling=s,t.child=h,s=t.child,s.memoizedState=WE(n),s.childLanes=XE(e,S,n),t.memoizedState=wE,Sl(null,s)):(Ja(t),KE(t,h))}var g=e.memoizedState;if(g!==null&&(h=g.dehydrated,h!==null)){if(o)t.flags&256?(Ja(t),t.flags&=-257,t=zE(e,t,n)):t.memoizedState!==null?(qa(),t.child=e.child,t.flags|=128,t=null):(qa(),h=s.fallback,i=t.mode,s=Pi({mode:"visible",children:s.children},i),h=pr(h,i,n,null),h.flags|=2,s.return=t,h.return=t,s.sibling=h,t.child=s,yr(t,e.child,null,n),s=t.child,s.memoizedState=WE(n),s.childLanes=XE(e,S,n),t.memoizedState=wE,t=Sl(null,s));else if(Ja(t),vT(h)){if(S=h.nextSibling&&h.nextSibling.dataset,S)var q=S.dgst;S=q,s=Error(T(419)),s.stack="",s.digest=S,el({value:s,source:null,stack:null}),t=zE(e,t,n)}else if(wt||os(e,t,n,!1),S=(n&e.childLanes)!==0,wt||S){if(S=Ct,S!==null&&(s=$r(S,n),s!==0&&s!==g.retryLane))throw g.retryLane=s,Cr(e,s),Ln(S,e,s),jE;mT(h)||Vi(),t=zE(e,t,n)}else mT(h)?(t.flags|=192,t.child=e.child,t=null):(e=g.treeContext,_t=zn(h.nextSibling),sn=t,ot=!0,Wa=null,Xn=!1,e!==null&&fS(t,e),t=KE(t,s.children),t.flags|=4096);return t}return i?(qa(),h=s.fallback,i=t.mode,g=e.child,q=g.sibling,s=Ia(g,{mode:"hidden",children:s.children}),s.subtreeFlags=g.subtreeFlags&65011712,q!==null?h=Ia(q,h):(h=pr(h,i,n,null),h.flags|=2),h.return=t,s.return=t,s.sibling=h,t.child=s,Sl(null,s),s=t.child,h=e.child.memoizedState,h===null?h=WE(n):(i=h.cachePool,i!==null?(g=jt._currentValue,i=i.parent!==g?{parent:g,pool:g}:i):i=vS(),h={baseLanes:h.baseLanes|n,cachePool:i}),s.memoizedState=h,s.childLanes=XE(e,S,n),t.memoizedState=wE,Sl(e.child,s)):(Ja(t),n=e.child,e=n.sibling,n=Ia(n,{mode:"visible",children:s.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 KE(e,t){return t=Pi({mode:"visible",children:t},e.mode),t.return=e,e.child=t}function Pi(e,t){return e=Dn(22,e,null,t),e.lanes=0,e}function zE(e,t,n){return yr(t,e.child,null,n),e=KE(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function jR(e,t,n){e.lanes|=t;var s=e.alternate;s!==null&&(s.lanes|=t),oE(e.return,t,n)}function kE(e,t,n,s,i,o){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:s,tail:n,tailMode:i,treeForkCount:o}:(S.isBackwards=t,S.rendering=null,S.renderingStartTime=0,S.last=s,S.tail=n,S.tailMode=i,S.treeForkCount=o)}function VR(e,t,n){var s=t.pendingProps,i=s.revealOrder,o=s.tail;s=s.children;var S=Ft.current,h=(S&2)!==0;if(h?(S=S&1|2,t.flags|=128):S&=1,ne(Ft,S),on(e,t,s,n),s=ot?Zs:0,!h&&e!==null&&(e.flags&128)!==0)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&jR(e,n,t);else if(e.tag===19)jR(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&&fi(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),kE(t,!1,i,n,o,s);break;case"backwards":case"unstable_legacy-backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&fi(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}kE(t,!0,n,null,o,s);break;case"together":kE(t,!1,null,null,void 0,s);break;default:t.memoizedState=null}return t.child}function _a(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),er|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(os(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(T(153));if(t.child!==null){for(e=t.child,n=Ia(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Ia(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function $E(e,t){return(e.lanes&t)!==0?!0:(e=e.dependencies,!!(e!==null&&Ri(e)))}function EN(e,t,n){switch(t.tag){case 3:le(t,t.stateNode.containerInfo),Ka(t,jt,e.memoizedState.cache),Lr();break;case 27:case 5:xe(t);break;case 4:le(t,t.stateNode.containerInfo);break;case 10:Ka(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,hE(t),null;break;case 13:var s=t.memoizedState;if(s!==null)return s.dehydrated!==null?(Ja(t),t.flags|=128,null):(n&t.child.childLanes)!==0?YR(e,t,n):(Ja(t),e=_a(e,t,n),e!==null?e.sibling:null);Ja(t);break;case 19:var i=(e.flags&128)!==0;if(s=(n&t.childLanes)!==0,s||(os(e,t,n,!1),s=(n&t.childLanes)!==0),i){if(s)return VR(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ne(Ft,Ft.current),s)break;return null;case 22:return t.lanes=0,UR(e,t,n,t.pendingProps);case 24:Ka(t,jt,e.memoizedState.cache)}return _a(e,t,n)}function wR(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)wt=!0;else{if(!$E(e,n)&&(t.flags&128)===0)return wt=!1,EN(e,t,n);wt=(e.flags&131072)!==0}else wt=!1,ot&&(t.flags&1048576)!==0&&hS(t,Zs,t.index);switch(t.lanes=0,t.tag){case 16:e:{var s=t.pendingProps;if(e=xr(t.elementType),t.type=e,typeof e=="function")eE(e)?(s=Mr(e,s),t.tag=1,t=HR(null,t,e,s,n)):(t.tag=0,t=VE(null,t,e,s,n));else{if(e!=null){var i=e.$$typeof;if(i===v){t.tag=11,t=gR(null,t,e,s,n);break e}else if(i===B){t.tag=14,t=MR(null,t,e,s,n);break e}}throw t=ve(e)||e,Error(T(306,t,""))}}return t;case 0:return VE(e,t,t.type,t.pendingProps,n);case 1:return s=t.type,i=Mr(s,t.pendingProps),HR(e,t,s,i,n);case 3:e:{if(le(t,t.stateNode.containerInfo),e===null)throw Error(T(387));s=t.pendingProps;var o=t.memoizedState;i=o.element,AE(e,t),il(t,s,null,n);var S=t.memoizedState;if(s=S.cache,Ka(t,jt,s),s!==o.cache&&EE(t,[jt],n,!0),ll(),s=S.element,o.isDehydrated)if(o={element:s,isDehydrated:!1,cache:S.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=FR(e,t,s,n);break e}else if(s!==i){i=Vn(Error(T(424)),t),el(i),t=FR(e,t,s,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(_t=zn(e.firstChild),sn=t,ot=!0,Wa=null,Xn=!0,n=PS(t,null,s,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Lr(),s===i){t=_a(e,t,n);break e}on(e,t,s,n)}t=t.child}return t;case 26:return Mi(e,t),e===null?(n=eA(t.type,null,t.pendingProps,null))?t.memoizedState=n:ot||(n=t.type,e=t.pendingProps,s=$i(te.current).createElement(n),s[kt]=t,s[cn]=e,En(s,n,e),yt(s),t.stateNode=s):t.memoizedState=eA(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return xe(t),e===null&&ot&&(s=t.stateNode=qu(t.type,t.pendingProps,te.current),sn=t,Xn=!0,i=_t,sr(t.type)?(xT=i,_t=zn(s.firstChild)):_t=i),on(e,t,t.pendingProps.children,n),Mi(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ot&&((i=s=_t)&&(s=FN(s,t.type,t.pendingProps,Xn),s!==null?(t.stateNode=s,sn=t,_t=zn(s.firstChild),Xn=!1,i=!0):i=!1),i||Xa(t)),xe(t),i=t.type,o=t.pendingProps,S=e!==null?e.memoizedProps:null,s=o.children,pT(i,o)?s=null:S!==null&&pT(i,S)&&(t.flags|=32),t.memoizedState!==null&&(i=CE(e,t,eN,null,null,n),vl._currentValue=i),Mi(e,t),on(e,t,s,n),t.child;case 6:return e===null&&ot&&((e=n=_t)&&(n=YN(n,t.pendingProps,Xn),n!==null?(t.stateNode=n,sn=t,_t=null,e=!0):e=!1),e||Xa(t)),null;case 13:return YR(e,t,n);case 4:return le(t,t.stateNode.containerInfo),s=t.pendingProps,e===null?t.child=yr(t,null,s,n):on(e,t,s,n),t.child;case 11:return gR(e,t,t.type,t.pendingProps,n);case 7:return on(e,t,t.pendingProps,n),t.child;case 8:return on(e,t,t.pendingProps.children,n),t.child;case 12:return on(e,t,t.pendingProps.children,n),t.child;case 10:return s=t.pendingProps,Ka(t,t.type,s.value),on(e,t,s.children,n),t.child;case 9:return i=t.type._context,s=t.pendingProps.children,mr(t),i=ln(i),s=s(i),t.flags|=1,on(e,t,s,n),t.child;case 14:return MR(e,t,t.type,t.pendingProps,n);case 15:return PR(e,t,t.type,t.pendingProps,n);case 19:return VR(e,t,n);case 31:return oN(e,t,n);case 22:return UR(e,t,n,t.pendingProps);case 24:return mr(t),s=ln(jt),e===null?(i=SE(),i===null&&(i=Ct,o=TE(),i.pooledCache=o,o.refCount++,o!==null&&(i.pooledCacheLanes|=n),i=o),t.memoizedState={parent:s,cache:i},uE(t),Ka(t,jt,i)):((e.lanes&n)!==0&&(AE(e,t),il(t,null,null,n),ll()),i=e.memoizedState,o=t.memoizedState,i.parent!==s?(i={parent:s,cache:s},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Ka(t,jt,s)):(s=o.cache,Ka(t,jt,s),s!==i.cache&&EE(t,[jt],n,!0))),on(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(T(156,t.tag))}function ma(e){e.flags|=4}function JE(e,t,n,s,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(du())e.flags|=8192;else throw Dr=Oi,RE}else e.flags&=-16777217}function WR(e,t){if(t.type!=="stylesheet"||(t.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!sA(t))if(du())e.flags|=8192;else throw Dr=Oi,RE}function Ui(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag!==22?kr():536870912,e.lanes|=t,hs|=t)}function Rl(e,t){if(!ot)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 s=null;n!==null;)n.alternate!==null&&(s=n),n=n.sibling;s===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function mt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,s=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,s|=i.subtreeFlags&65011712,s|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,s|=i.subtreeFlags,s|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=s,e.childLanes=n,t}function TN(e,t,n){var s=t.pendingProps;switch(rE(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mt(t),null;case 1:return mt(t),null;case 3:return n=t.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),t.memoizedState.cache!==s&&(t.flags|=2048),Ca(jt),he(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(is(t)?ma(t):e===null||e.memoizedState.isDehydrated&&(t.flags&256)===0||(t.flags|=1024,lE())),mt(t),null;case 26:var i=t.type,o=t.memoizedState;return e===null?(ma(t),o!==null?(mt(t),WR(t,o)):(mt(t),JE(t,i,null,s,n))):o?o!==e.memoizedState?(ma(t),mt(t),WR(t,o)):(mt(t),t.flags&=-16777217):(e=e.memoizedProps,e!==s&&ma(t),mt(t),JE(t,i,e,s,n)),null;case 27:if(ye(t),n=te.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&ma(t);else{if(!s){if(t.stateNode===null)throw Error(T(166));return mt(t),null}e=ae.current,is(t)?CS(t):(e=qu(i,s,n),t.stateNode=e,ma(t))}return mt(t),null;case 5:if(ye(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==s&&ma(t);else{if(!s){if(t.stateNode===null)throw Error(T(166));return mt(t),null}if(o=ae.current,is(t))CS(t);else{var S=$i(te.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 s.is=="string"?S.createElement("select",{is:s.is}):S.createElement("select"),s.multiple?o.multiple=!0:s.size&&(o.size=s.size);break;default:o=typeof s.is=="string"?S.createElement(i,{is:s.is}):S.createElement(i)}}o[kt]=t,o[cn]=s;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(En(o,i,s),i){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&ma(t)}}return mt(t),JE(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==s&&ma(t);else{if(typeof s!="string"&&t.stateNode===null)throw Error(T(166));if(e=te.current,is(t)){if(e=t.stateNode,n=t.memoizedProps,s=null,i=sn,i!==null)switch(i.tag){case 27:case 5:s=i.memoizedProps}e[kt]=t,e=!!(e.nodeValue===n||s!==null&&s.suppressHydrationWarning===!0||Yu(e.nodeValue,n)),e||Xa(t,!0)}else e=$i(e).createTextNode(s),e[kt]=t,t.stateNode=e}return mt(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(s=is(t),n!==null){if(e===null){if(!s)throw Error(T(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(T(557));e[kt]=t}else Lr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;mt(t),e=!1}else n=lE(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(gn(t),t):(gn(t),null);if((t.flags&128)!==0)throw Error(T(558))}return mt(t),null;case 13:if(s=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=is(t),s!==null&&s.dehydrated!==null){if(e===null){if(!i)throw Error(T(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(T(317));i[kt]=t}else Lr(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;mt(t),i=!1}else i=lE(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(gn(t),t):(gn(t),null)}return gn(t),(t.flags&128)!==0?(t.lanes=n,t):(n=s!==null,e=e!==null&&e.memoizedState!==null,n&&(s=t.child,i=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(i=s.alternate.memoizedState.cachePool.pool),o=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(o=s.memoizedState.cachePool.pool),o!==i&&(s.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ui(t,t.updateQueue),mt(t),null);case 4:return he(),e===null&&NT(t.stateNode.containerInfo),mt(t),null;case 10:return Ca(t.type),mt(t),null;case 19:if(H(Ft),s=t.memoizedState,s===null)return mt(t),null;if(i=(t.flags&128)!==0,o=s.rendering,o===null)if(i)Rl(s,!1);else{if(bt!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(o=fi(e),o!==null){for(t.flags|=128,Rl(s,!1),e=o.updateQueue,t.updateQueue=e,Ui(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)OS(n,e),n=n.sibling;return ne(Ft,Ft.current&1|2),ot&&ha(t,s.treeForkCount),t.child}e=e.sibling}s.tail!==null&&st()>Fi&&(t.flags|=128,i=!0,Rl(s,!1),t.lanes=4194304)}else{if(!i)if(e=fi(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Ui(t,e),Rl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!ot)return mt(t),null}else 2*st()-s.renderingStartTime>Fi&&n!==536870912&&(t.flags|=128,i=!0,Rl(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(e=s.last,e!==null?e.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=st(),e.sibling=null,n=Ft.current,ne(Ft,i?n&1|2:n&1),ot&&ha(t,s.treeForkCount),e):(mt(t),null);case 22:case 23:return gn(t),IE(),s=t.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(t.flags|=8192):s&&(t.flags|=8192),s?(n&536870912)!==0&&(t.flags&128)===0&&(mt(t),t.subtreeFlags&6&&(t.flags|=8192)):mt(t),n=t.updateQueue,n!==null&&Ui(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),s=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),s!==n&&(t.flags|=2048),e!==null&&H(vr),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(jt),mt(t),null;case 25:return null;case 30:return null}throw Error(T(156,t.tag))}function cN(e,t){switch(rE(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ca(jt),he(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ye(t),null;case 31:if(t.memoizedState!==null){if(gn(t),t.alternate===null)throw Error(T(340));Lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(gn(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(T(340));Lr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return H(Ft),null;case 4:return he(),null;case 10:return Ca(t.type),null;case 22:case 23:return gn(t),IE(),e!==null&&H(vr),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ca(jt),null;case 25:return null;default:return null}}function XR(e,t){switch(rE(t),t.tag){case 3:Ca(jt),he();break;case 26:case 27:case 5:ye(t);break;case 4:he();break;case 31:t.memoizedState!==null&&gn(t);break;case 13:gn(t);break;case 19:H(Ft);break;case 10:Ca(t.type);break;case 22:case 23:gn(t),IE(),e!==null&&H(vr);break;case 24:Ca(jt)}}function ul(e,t){try{var n=t.updateQueue,s=n!==null?n.lastEffect:null;if(s!==null){var i=s.next;n=i;do{if((n.tag&e)===e){s=void 0;var o=n.create,S=n.inst;s=o(),S.destroy=s}n=n.next}while(n!==i)}}catch(h){dt(t,t.return,h)}}function Qa(e,t,n){try{var s=t.updateQueue,i=s!==null?s.lastEffect:null;if(i!==null){var o=i.next;s=o;do{if((s.tag&e)===e){var S=s.inst,h=S.destroy;if(h!==void 0){S.destroy=void 0,i=t;var g=n,q=h;try{q()}catch(ie){dt(i,g,ie)}}}s=s.next}while(s!==o)}}catch(ie){dt(t,t.return,ie)}}function KR(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{bS(t,n)}catch(s){dt(e,e.return,s)}}}function zR(e,t,n){n.props=Mr(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(s){dt(e,t,s)}}function Al(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof n=="function"?e.refCleanup=n(s):n.current=s}}catch(i){dt(e,t,i)}}function Ea(e,t){var n=e.ref,s=e.refCleanup;if(n!==null)if(typeof s=="function")try{s()}catch(i){dt(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){dt(e,t,i)}else n.current=null}function kR(e){var t=e.type,n=e.memoizedProps,s=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":n.autoFocus&&s.focus();break e;case"img":n.src?s.src=n.src:n.srcSet&&(s.srcset=n.srcSet)}}catch(i){dt(e,e.return,i)}}function qE(e,t,n){try{var s=e.stateNode;PN(s,e.type,n,t),s[cn]=t}catch(i){dt(e,e.return,i)}}function $R(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&sr(e.type)||e.tag===4}function QE(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||$R(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&&sr(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 ZE(e,t,n){var s=e.tag;if(s===5||s===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=Oa));else if(s!==4&&(s===27&&sr(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(ZE(e,t,n),e=e.sibling;e!==null;)ZE(e,t,n),e=e.sibling}function bi(e,t,n){var s=e.tag;if(s===5||s===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(s!==4&&(s===27&&sr(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(bi(e,t,n),e=e.sibling;e!==null;)bi(e,t,n),e=e.sibling}function JR(e){var t=e.stateNode,n=e.memoizedProps;try{for(var s=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);En(t,s,n),t[kt]=e,t[cn]=n}catch(o){dt(e,e.return,o)}}var va=!1,Wt=!1,eT=!1,qR=typeof WeakSet=="function"?WeakSet:Set,Zt=null;function SN(e,t){if(e=e.containerInfo,fT=no,e=oS(e),zo(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var s=n.getSelection&&n.getSelection();if(s&&s.rangeCount!==0){n=s.anchorNode;var i=s.anchorOffset,o=s.focusNode;s=s.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var S=0,h=-1,g=-1,q=0,ie=0,de=e,ee=null;t:for(;;){for(var re;de!==n||i!==0&&de.nodeType!==3||(h=S+i),de!==o||s!==0&&de.nodeType!==3||(g=S+s),de.nodeType===3&&(S+=de.nodeValue.length),(re=de.firstChild)!==null;)ee=de,de=re;for(;;){if(de===e)break t;if(ee===n&&++q===i&&(h=S),ee===o&&++ie===s&&(g=S),(re=de.nextSibling)!==null)break;de=ee,ee=de.parentNode}de=re}n=h===-1||g===-1?null:{start:h,end:g}}else n=null}n=n||{start:0,end:0}}else n=null;for(CT={focusedElem:e,selectionRange:n},no=!1,Zt=t;Zt!==null;)if(t=Zt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Zt=e;else for(;Zt!==null;){switch(t=Zt,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,s=n.stateNode;try{var Ue=Mr(n.type,i);e=s.getSnapshotBeforeUpdate(Ue,o),s.__reactInternalSnapshotBeforeUpdate=e}catch(je){dt(n,n.return,je)}}break;case 3:if((e&1024)!==0){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)_T(e);else if(n===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":_T(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(T(163))}if(e=t.sibling,e!==null){e.return=t.return,Zt=e;break}Zt=t.return}}function QR(e,t,n){var s=n.flags;switch(n.tag){case 0:case 11:case 15:Da(e,n),s&4&&ul(5,n);break;case 1:if(Da(e,n),s&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(S){dt(n,n.return,S)}else{var i=Mr(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(S){dt(n,n.return,S)}}s&64&&KR(n),s&512&&Al(n,n.return);break;case 3:if(Da(e,n),s&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{bS(e,t)}catch(S){dt(n,n.return,S)}}break;case 27:t===null&&s&4&&JR(n);case 26:case 5:Da(e,n),t===null&&s&4&&kR(n),s&512&&Al(n,n.return);break;case 12:Da(e,n);break;case 31:Da(e,n),s&4&&tu(e,n);break;case 13:Da(e,n),s&4&&nu(e,n),s&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=fN.bind(null,n),jN(e,n))));break;case 22:if(s=n.memoizedState!==null||va,!s){t=t!==null&&t.memoizedState!==null||Wt,i=va;var o=Wt;va=s,(Wt=t)&&!o?ya(e,n,(n.subtreeFlags&8772)!==0):Da(e,n),va=i,Wt=o}break;case 30:break;default:Da(e,n)}}function ZR(e){var t=e.alternate;t!==null&&(e.alternate=null,ZR(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ce(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 gt=null,hn=!1;function xa(e,t,n){for(n=n.child;n!==null;)eu(e,t,n),n=n.sibling}function eu(e,t,n){if(qt&&typeof qt.onCommitFiberUnmount=="function")try{qt.onCommitFiberUnmount(Jn,n)}catch{}switch(n.tag){case 26:Wt||Ea(n,t),xa(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:Wt||Ea(n,t);var s=gt,i=hn;sr(n.type)&&(gt=n.stateNode,hn=!1),xa(e,t,n),Ll(n.stateNode),gt=s,hn=i;break;case 5:Wt||Ea(n,t);case 6:if(s=gt,i=hn,gt=null,xa(e,t,n),gt=s,hn=i,gt!==null)if(hn)try{(gt.nodeType===9?gt.body:gt.nodeName==="HTML"?gt.ownerDocument.body:gt).removeChild(n.stateNode)}catch(o){dt(n,t,o)}else try{gt.removeChild(n.stateNode)}catch(o){dt(n,t,o)}break;case 18:gt!==null&&(hn?(e=gt,Ku(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,n.stateNode),xs(e)):Ku(gt,n.stateNode));break;case 4:s=gt,i=hn,gt=n.stateNode.containerInfo,hn=!0,xa(e,t,n),gt=s,hn=i;break;case 0:case 11:case 14:case 15:Qa(2,n,t),Wt||Qa(4,n,t),xa(e,t,n);break;case 1:Wt||(Ea(n,t),s=n.stateNode,typeof s.componentWillUnmount=="function"&&zR(n,t,s)),xa(e,t,n);break;case 21:xa(e,t,n);break;case 22:Wt=(s=Wt)||n.memoizedState!==null,xa(e,t,n),Wt=s;break;default:xa(e,t,n)}}function tu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{xs(e)}catch(n){dt(t,t.return,n)}}}function nu(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{xs(e)}catch(n){dt(t,t.return,n)}}function RN(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new qR),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new qR),t;default:throw Error(T(435,e.tag))}}function Gi(e,t){var n=RN(e);t.forEach(function(s){if(!n.has(s)){n.add(s);var i=CN.bind(null,e,s);s.then(i,i)}})}function fn(e,t){var n=t.deletions;if(n!==null)for(var s=0;s<n.length;s++){var i=n[s],o=e,S=t,h=S;e:for(;h!==null;){switch(h.tag){case 27:if(sr(h.type)){gt=h.stateNode,hn=!1;break e}break;case 5:gt=h.stateNode,hn=!1;break e;case 3:case 4:gt=h.stateNode.containerInfo,hn=!0;break e}h=h.return}if(gt===null)throw Error(T(160));eu(o,S,i),gt=null,hn=!1,o=i.alternate,o!==null&&(o.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)au(t,e),t=t.sibling}var Zn=null;function au(e,t){var n=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fn(t,e),Cn(e),s&4&&(Qa(3,e,e.return),ul(3,e),Qa(5,e,e.return));break;case 1:fn(t,e),Cn(e),s&512&&(Wt||n===null||Ea(n,n.return)),s&64&&va&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?s:n.concat(s))));break;case 26:var i=Zn;if(fn(t,e),Cn(e),s&512&&(Wt||n===null||Ea(n,n.return)),s&4){var o=n!==null?n.memoizedState:null;if(s=e.memoizedState,n===null)if(s===null)if(e.stateNode===null){e:{s=e.type,n=e.memoizedProps,i=i.ownerDocument||i;t:switch(s){case"title":o=i.getElementsByTagName("title")[0],(!o||o[Nr]||o[kt]||o.namespaceURI==="http://www.w3.org/2000/svg"||o.hasAttribute("itemprop"))&&(o=i.createElement(s),i.head.insertBefore(o,i.querySelector("head > title"))),En(o,s,n),o[kt]=e,yt(o),s=o;break e;case"link":var S=aA("link","href",i).get(s+(n.href||""));if(S){for(var h=0;h<S.length;h++)if(o=S[h],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(h,1);break t}}o=i.createElement(s),En(o,s,n),i.head.appendChild(o);break;case"meta":if(S=aA("meta","content",i).get(s+(n.content||""))){for(h=0;h<S.length;h++)if(o=S[h],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(h,1);break t}}o=i.createElement(s),En(o,s,n),i.head.appendChild(o);break;default:throw Error(T(468,s))}o[kt]=e,yt(o),s=o}e.stateNode=s}else rA(i,e.type,e.stateNode);else e.stateNode=nA(i,s,e.memoizedProps);else o!==s?(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,s===null?rA(i,e.type,e.stateNode):nA(i,s,e.memoizedProps)):s===null&&e.stateNode!==null&&qE(e,e.memoizedProps,n.memoizedProps)}break;case 27:fn(t,e),Cn(e),s&512&&(Wt||n===null||Ea(n,n.return)),n!==null&&s&4&&qE(e,e.memoizedProps,n.memoizedProps);break;case 5:if(fn(t,e),Cn(e),s&512&&(Wt||n===null||Ea(n,n.return)),e.flags&32){i=e.stateNode;try{qr(i,"")}catch(Ue){dt(e,e.return,Ue)}}s&4&&e.stateNode!=null&&(i=e.memoizedProps,qE(e,i,n!==null?n.memoizedProps:i)),s&1024&&(eT=!0);break;case 6:if(fn(t,e),Cn(e),s&4){if(e.stateNode===null)throw Error(T(162));s=e.memoizedProps,n=e.stateNode;try{n.nodeValue=s}catch(Ue){dt(e,e.return,Ue)}}break;case 3:if(Qi=null,i=Zn,Zn=Ji(t.containerInfo),fn(t,e),Zn=i,Cn(e),s&4&&n!==null&&n.memoizedState.isDehydrated)try{xs(t.containerInfo)}catch(Ue){dt(e,e.return,Ue)}eT&&(eT=!1,ru(e));break;case 4:s=Zn,Zn=Ji(e.stateNode.containerInfo),fn(t,e),Cn(e),Zn=s;break;case 12:fn(t,e),Cn(e);break;case 31:fn(t,e),Cn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,Gi(e,s)));break;case 13:fn(t,e),Cn(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Hi=st()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,Gi(e,s)));break;case 22:i=e.memoizedState!==null;var g=n!==null&&n.memoizedState!==null,q=va,ie=Wt;if(va=q||i,Wt=ie||g,fn(t,e),Wt=ie,va=q,Cn(e),s&8192)e:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||g||va||Wt||Pr(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){g=n=t;try{if(o=g.stateNode,i)S=o.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{h=g.stateNode;var de=g.memoizedProps.style,ee=de!=null&&de.hasOwnProperty("display")?de.display:null;h.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(Ue){dt(g,g.return,Ue)}}}else if(t.tag===6){if(n===null){g=t;try{g.stateNode.nodeValue=i?"":g.memoizedProps}catch(Ue){dt(g,g.return,Ue)}}}else if(t.tag===18){if(n===null){g=t;try{var re=g.stateNode;i?zu(re,!0):zu(g.stateNode,!1)}catch(Ue){dt(g,g.return,Ue)}}}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}s&4&&(s=e.updateQueue,s!==null&&(n=s.retryQueue,n!==null&&(s.retryQueue=null,Gi(e,n))));break;case 19:fn(t,e),Cn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,Gi(e,s)));break;case 30:break;case 21:break;default:fn(t,e),Cn(e)}}function Cn(e){var t=e.flags;if(t&2){try{for(var n,s=e.return;s!==null;){if($R(s)){n=s;break}s=s.return}if(n==null)throw Error(T(160));switch(n.tag){case 27:var i=n.stateNode,o=QE(e);bi(e,o,i);break;case 5:var S=n.stateNode;n.flags&32&&(qr(S,""),n.flags&=-33);var h=QE(e);bi(e,h,S);break;case 3:case 4:var g=n.stateNode.containerInfo,q=QE(e);ZE(e,q,g);break;default:throw Error(T(161))}}catch(ie){dt(e,e.return,ie)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function ru(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;ru(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Da(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)QR(e,t.alternate,t),t=t.sibling}function Pr(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Qa(4,t,t.return),Pr(t);break;case 1:Ea(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount=="function"&&zR(t,t.return,n),Pr(t);break;case 27:Ll(t.stateNode);case 26:case 5:Ea(t,t.return),Pr(t);break;case 22:t.memoizedState===null&&Pr(t);break;case 30:Pr(t);break;default:Pr(t)}e=e.sibling}}function ya(e,t,n){for(n=n&&(t.subtreeFlags&8772)!==0,t=t.child;t!==null;){var s=t.alternate,i=e,o=t,S=o.flags;switch(o.tag){case 0:case 11:case 15:ya(i,o,n),ul(4,o);break;case 1:if(ya(i,o,n),s=o,i=s.stateNode,typeof i.componentDidMount=="function")try{i.componentDidMount()}catch(q){dt(s,s.return,q)}if(s=o,i=s.updateQueue,i!==null){var h=s.stateNode;try{var g=i.shared.hiddenCallbacks;if(g!==null)for(i.shared.hiddenCallbacks=null,i=0;i<g.length;i++)US(g[i],h)}catch(q){dt(s,s.return,q)}}n&&S&64&&KR(o),Al(o,o.return);break;case 27:JR(o);case 26:case 5:ya(i,o,n),n&&s===null&&S&4&&kR(o),Al(o,o.return);break;case 12:ya(i,o,n);break;case 31:ya(i,o,n),n&&S&4&&tu(i,o);break;case 13:ya(i,o,n),n&&S&4&&nu(i,o);break;case 22:o.memoizedState===null&&ya(i,o,n),Al(o,o.return);break;case 30:break;default:ya(i,o,n)}t=t.sibling}}function tT(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&&tl(n))}function nT(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&tl(e))}function ea(e,t,n,s){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)su(e,t,n,s),t=t.sibling}function su(e,t,n,s){var i=t.flags;switch(t.tag){case 0:case 11:case 15:ea(e,t,n,s),i&2048&&ul(9,t);break;case 1:ea(e,t,n,s);break;case 3:ea(e,t,n,s),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&tl(e)));break;case 12:if(i&2048){ea(e,t,n,s),e=t.stateNode;try{var o=t.memoizedProps,S=o.id,h=o.onPostCommit;typeof h=="function"&&h(S,t.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(g){dt(t,t.return,g)}}else ea(e,t,n,s);break;case 31:ea(e,t,n,s);break;case 13:ea(e,t,n,s);break;case 23:break;case 22:o=t.stateNode,S=t.alternate,t.memoizedState!==null?o._visibility&2?ea(e,t,n,s):dl(e,t):o._visibility&2?ea(e,t,n,s):(o._visibility|=2,Os(e,t,n,s,(t.subtreeFlags&10256)!==0||!1)),i&2048&&tT(S,t);break;case 24:ea(e,t,n,s),i&2048&&nT(t.alternate,t);break;default:ea(e,t,n,s)}}function Os(e,t,n,s,i){for(i=i&&((t.subtreeFlags&10256)!==0||!1),t=t.child;t!==null;){var o=e,S=t,h=n,g=s,q=S.flags;switch(S.tag){case 0:case 11:case 15:Os(o,S,h,g,i),ul(8,S);break;case 23:break;case 22:var ie=S.stateNode;S.memoizedState!==null?ie._visibility&2?Os(o,S,h,g,i):dl(o,S):(ie._visibility|=2,Os(o,S,h,g,i)),i&&q&2048&&tT(S.alternate,S);break;case 24:Os(o,S,h,g,i),i&&q&2048&&nT(S.alternate,S);break;default:Os(o,S,h,g,i)}t=t.sibling}}function dl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,s=t,i=s.flags;switch(s.tag){case 22:dl(n,s),i&2048&&tT(s.alternate,s);break;case 24:dl(n,s),i&2048&&nT(s.alternate,s);break;default:dl(n,s)}t=t.sibling}}var Ol=8192;function Ns(e,t,n){if(e.subtreeFlags&Ol)for(e=e.child;e!==null;)lu(e,t,n),e=e.sibling}function lu(e,t,n){switch(e.tag){case 26:Ns(e,t,n),e.flags&Ol&&e.memoizedState!==null&&ZN(n,Zn,e.memoizedState,e.memoizedProps);break;case 5:Ns(e,t,n);break;case 3:case 4:var s=Zn;Zn=Ji(e.stateNode.containerInfo),Ns(e,t,n),Zn=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=Ol,Ol=16777216,Ns(e,t,n),Ol=s):Ns(e,t,n));break;default:Ns(e,t,n)}}function iu(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 Nl(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];Zt=s,Eu(s,e)}iu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)ou(e),e=e.sibling}function ou(e){switch(e.tag){case 0:case 11:case 15:Nl(e),e.flags&2048&&Qa(9,e,e.return);break;case 3:Nl(e);break;case 12:Nl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Bi(e)):Nl(e);break;default:Nl(e)}}function Bi(e){var t=e.deletions;if((e.flags&16)!==0){if(t!==null)for(var n=0;n<t.length;n++){var s=t[n];Zt=s,Eu(s,e)}iu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Qa(8,t,t.return),Bi(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Bi(t));break;default:Bi(t)}e=e.sibling}}function Eu(e,t){for(;Zt!==null;){var n=Zt;switch(n.tag){case 0:case 11:case 15:Qa(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var s=n.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:tl(n.memoizedState.cache)}if(s=n.child,s!==null)s.return=n,Zt=s;else e:for(n=e;Zt!==null;){s=Zt;var i=s.sibling,o=s.return;if(ZR(s),s===n){Zt=null;break e}if(i!==null){i.return=o,Zt=i;break e}Zt=o}}}var uN={getCacheForType:function(e){var t=ln(jt),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ln(jt).controller.signal}},AN=typeof WeakMap=="function"?WeakMap:Map,Rt=0,Ct=null,tt=null,lt=0,At=0,Mn=null,Za=!1,Is=!1,aT=!1,ga=0,bt=0,er=0,Ur=0,rT=0,Pn=0,hs=0,Il=null,pn=null,sT=!1,Hi=0,Tu=0,Fi=1/0,Yi=null,tr=null,$t=0,nr=null,fs=null,Ma=0,lT=0,iT=null,cu=null,hl=0,oT=null;function Un(){return(Rt&2)!==0&&lt!==0?lt&-lt:D.T!==null?uT():kl()}function Su(){if(Pn===0)if((lt&536870912)===0||ot){var e=Qt;Qt<<=1,(Qt&3932160)===0&&(Qt=262144),Pn=e}else Pn=536870912;return e=yn.current,e!==null&&(e.flags|=32),Pn}function Ln(e,t,n){(e===Ct&&(At===2||At===9)||e.cancelPendingCommit!==null)&&(Cs(e,0),ar(e,lt,Pn,!1)),Hn(e,n),((Rt&2)===0||e!==Ct)&&(e===Ct&&((Rt&2)===0&&(Ur|=n),bt===4&&ar(e,lt,Pn,!1)),Ta(e))}function Ru(e,t,n){if((Rt&6)!==0)throw Error(T(327));var s=!n&&(t&127)===0&&(t&e.expiredLanes)===0||zt(e,t),i=s?NN(e,t):TT(e,t,!0),o=s;do{if(i===0){Is&&!s&&ar(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!dN(n)){i=TT(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 h=e;i=Il;var g=h.current.memoizedState.isDehydrated;if(g&&(Cs(h,S).flags|=256),S=TT(h,S,!1),S!==2){if(aT&&!g){h.errorRecoveryDisabledLanes|=o,Ur|=o,i=4;break e}o=pn,pn=i,o!==null&&(pn===null?pn=o:pn.push.apply(pn,o))}i=S}if(o=!1,i!==2)continue}}if(i===1){Cs(e,0),ar(e,t,0,!0);break}e:{switch(s=e,o=i,o){case 0:case 1:throw Error(T(345));case 4:if((t&4194048)!==t)break;case 6:ar(s,t,Pn,!Za);break e;case 2:pn=null;break;case 3:case 5:break;default:throw Error(T(329))}if((t&62914560)===t&&(i=Hi+300-st(),10<i)){if(ar(s,t,Pn,!Za),Ke(s,0,!0)!==0)break e;Ma=t,s.timeoutHandle=Wu(uu.bind(null,s,n,pn,Yi,sT,t,Pn,Ur,hs,Za,o,"Throttled",-0,0),i);break e}uu(s,n,pn,Yi,sT,t,Pn,Ur,hs,Za,o,null,-0,0)}}break}while(!0);Ta(e)}function uu(e,t,n,s,i,o,S,h,g,q,ie,de,ee,re){if(e.timeoutHandle=-1,de=t.subtreeFlags,de&8192||(de&16785408)===16785408){de={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Oa},lu(t,o,de);var Ue=(o&62914560)===o?Hi-st():(o&4194048)===o?Tu-st():0;if(Ue=eI(de,Ue),Ue!==null){Ma=o,e.cancelPendingCommit=Ue(Cu.bind(null,e,t,o,n,s,i,S,h,g,ie,de,null,ee,re)),ar(e,o,S,!q);return}}Cu(e,t,o,n,s,i,S,h,g)}function dN(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 s=0;s<n.length;s++){var i=n[s],o=i.getSnapshot;i=i.value;try{if(!xn(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 ar(e,t,n,s){t&=~rT,t&=~Ur,e.suspendedLanes|=t,e.pingedLanes&=~t,s&&(e.warmLanes|=t),s=e.expirationTimes;for(var i=t;0<i;){var o=31-Kt(i),S=1<<o;s[o]=-1,i&=~S}n!==0&&Kl(e,n,t)}function ji(){return(Rt&6)===0?(fl(0),!1):!0}function ET(){if(tt!==null){if(At===0)var e=tt.return;else e=tt,fa=_r=null,_E(e),Ss=null,al=0,e=tt;for(;e!==null;)XR(e.alternate,e),e=e.return;tt=null}}function Cs(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,GN(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ma=0,ET(),Ct=e,tt=n=Ia(e.current,null),lt=t,At=0,Mn=null,Za=!1,Is=zt(e,t),aT=!1,hs=Pn=rT=Ur=er=bt=0,pn=Il=null,sT=!1,(t&8)!==0&&(t|=t&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=t;0<s;){var i=31-Kt(s),o=1<<i;t|=e[i],s&=~o}return ga=t,oi(),n}function Au(e,t){$e=null,D.H=cl,t===cs||t===di?(t=yS(),At=3):t===RE?(t=yS(),At=4):At=t===jE?8:t!==null&&typeof t=="object"&&typeof t.then=="function"?6:1,Mn=t,tt===null&&(bt=1,yi(e,Vn(t,e.current)))}function du(){var e=yn.current;return e===null?!0:(lt&4194048)===lt?Kn===null:(lt&62914560)===lt||(lt&536870912)!==0?e===Kn:!1}function Ou(){var e=D.H;return D.H=cl,e===null?cl:e}function Nu(){var e=D.A;return D.A=uN,e}function Vi(){bt=4,Za||(lt&4194048)!==lt&&yn.current!==null||(Is=!0),(er&134217727)===0&&(Ur&134217727)===0||Ct===null||ar(Ct,lt,Pn,!1)}function TT(e,t,n){var s=Rt;Rt|=2;var i=Ou(),o=Nu();(Ct!==e||lt!==t)&&(Yi=null,Cs(e,t)),t=!1;var S=bt;e:do try{if(At!==0&&tt!==null){var h=tt,g=Mn;switch(At){case 8:ET(),S=6;break e;case 3:case 2:case 9:case 6:yn.current===null&&(t=!0);var q=At;if(At=0,Mn=null,ps(e,h,g,q),n&&Is){S=0;break e}break;default:q=At,At=0,Mn=null,ps(e,h,g,q)}}ON(),S=bt;break}catch(ie){Au(e,ie)}while(!0);return t&&e.shellSuspendCounter++,fa=_r=null,Rt=s,D.H=i,D.A=o,tt===null&&(Ct=null,lt=0,oi()),S}function ON(){for(;tt!==null;)Iu(tt)}function NN(e,t){var n=Rt;Rt|=2;var s=Ou(),i=Nu();Ct!==e||lt!==t?(Yi=null,Fi=st()+500,Cs(e,t)):Is=zt(e,t);e:do try{if(At!==0&&tt!==null){t=tt;var o=Mn;t:switch(At){case 1:At=0,Mn=null,ps(e,t,o,1);break;case 2:case 9:if(xS(o)){At=0,Mn=null,hu(t);break}t=function(){At!==2&&At!==9||Ct!==e||(At=7),Ta(e)},o.then(t,t);break e;case 3:At=7;break e;case 4:At=5;break e;case 7:xS(o)?(At=0,Mn=null,hu(t)):(At=0,Mn=null,ps(e,t,o,7));break;case 5:var S=null;switch(tt.tag){case 26:S=tt.memoizedState;case 5:case 27:var h=tt;if(S?sA(S):h.stateNode.complete){At=0,Mn=null;var g=h.sibling;if(g!==null)tt=g;else{var q=h.return;q!==null?(tt=q,wi(q)):tt=null}break t}}At=0,Mn=null,ps(e,t,o,5);break;case 6:At=0,Mn=null,ps(e,t,o,6);break;case 8:ET(),bt=6;break e;default:throw Error(T(462))}}IN();break}catch(ie){Au(e,ie)}while(!0);return fa=_r=null,D.H=s,D.A=i,Rt=n,tt!==null?0:(Ct=null,lt=0,oi(),bt)}function IN(){for(;tt!==null&&!et();)Iu(tt)}function Iu(e){var t=wR(e.alternate,e,ga);e.memoizedProps=e.pendingProps,t===null?wi(e):tt=t}function hu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=BR(n,t,t.pendingProps,t.type,void 0,lt);break;case 11:t=BR(n,t,t.pendingProps,t.type.render,t.ref,lt);break;case 5:_E(t);default:XR(n,t),t=tt=OS(t,ga),t=wR(n,t,ga)}e.memoizedProps=e.pendingProps,t===null?wi(e):tt=t}function ps(e,t,n,s){fa=_r=null,_E(t),Ss=null,al=0;var i=t.return;try{if(iN(e,i,t,n,lt)){bt=1,yi(e,Vn(n,e.current)),tt=null;return}}catch(o){if(i!==null)throw tt=i,o;bt=1,yi(e,Vn(n,e.current)),tt=null;return}t.flags&32768?(ot||s===1?e=!0:Is||(lt&536870912)!==0?e=!1:(Za=e=!0,(s===2||s===9||s===3||s===6)&&(s=yn.current,s!==null&&s.tag===13&&(s.flags|=16384))),fu(t,e)):wi(t)}function wi(e){var t=e;do{if((t.flags&32768)!==0){fu(t,Za);return}e=t.return;var n=TN(t.alternate,t,ga);if(n!==null){tt=n;return}if(t=t.sibling,t!==null){tt=t;return}tt=t=e}while(t!==null);bt===0&&(bt=5)}function fu(e,t){do{var n=cN(e.alternate,e);if(n!==null){n.flags&=32767,tt=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){tt=e;return}tt=e=n}while(e!==null);bt=6,tt=null}function Cu(e,t,n,s,i,o,S,h,g){e.cancelPendingCommit=null;do Wi();while($t!==0);if((Rt&6)!==0)throw Error(T(327));if(t!==null){if(t===e.current)throw Error(T(177));if(o=t.lanes|t.childLanes,o|=Qo,Do(e,n,o,S,h,g),e===Ct&&(tt=Ct=null,lt=0),fs=t,nr=e,Ma=n,lT=o,iT=i,cu=s,(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,pN(Pt,function(){return vu(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(t.flags&13878)!==0,(t.subtreeFlags&13878)!==0||s){s=D.T,D.T=null,i=oe.p,oe.p=2,S=Rt,Rt|=4;try{SN(e,t,n)}finally{Rt=S,oe.p=i,D.T=s}}$t=1,pu(),Lu(),_u()}}function pu(){if($t===1){$t=0;var e=nr,t=fs,n=(t.flags&13878)!==0;if((t.subtreeFlags&13878)!==0||n){n=D.T,D.T=null;var s=oe.p;oe.p=2;var i=Rt;Rt|=4;try{au(t,e);var o=CT,S=oS(e.containerInfo),h=o.focusedElem,g=o.selectionRange;if(S!==h&&h&&h.ownerDocument&&iS(h.ownerDocument.documentElement,h)){if(g!==null&&zo(h)){var q=g.start,ie=g.end;if(ie===void 0&&(ie=q),"selectionStart"in h)h.selectionStart=q,h.selectionEnd=Math.min(ie,h.value.length);else{var de=h.ownerDocument||document,ee=de&&de.defaultView||window;if(ee.getSelection){var re=ee.getSelection(),Ue=h.textContent.length,je=Math.min(g.start,Ue),It=g.end===void 0?je:Math.min(g.end,Ue);!re.extend&&je>It&&(S=It,It=je,je=S);var V=lS(h,je),G=lS(h,It);if(V&&G&&(re.rangeCount!==1||re.anchorNode!==V.node||re.anchorOffset!==V.offset||re.focusNode!==G.node||re.focusOffset!==G.offset)){var k=de.createRange();k.setStart(V.node,V.offset),re.removeAllRanges(),je>It?(re.addRange(k),re.extend(G.node,G.offset)):(k.setEnd(G.node,G.offset),re.addRange(k))}}}}for(de=[],re=h;re=re.parentNode;)re.nodeType===1&&de.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<de.length;h++){var Re=de[h];Re.element.scrollLeft=Re.left,Re.element.scrollTop=Re.top}}no=!!fT,CT=fT=null}finally{Rt=i,oe.p=s,D.T=n}}e.current=t,$t=2}}function Lu(){if($t===2){$t=0;var e=nr,t=fs,n=(t.flags&8772)!==0;if((t.subtreeFlags&8772)!==0||n){n=D.T,D.T=null;var s=oe.p;oe.p=2;var i=Rt;Rt|=4;try{QR(e,t.alternate,t)}finally{Rt=i,oe.p=s,D.T=n}}$t=3}}function _u(){if($t===4||$t===3){$t=0,Xt();var e=nr,t=fs,n=Ma,s=cu;(t.subtreeFlags&10256)!==0||(t.flags&10256)!==0?$t=5:($t=0,fs=nr=null,mu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(tr=null),js(n),t=t.stateNode,qt&&typeof qt.onCommitFiberRoot=="function")try{qt.onCommitFiberRoot(Jn,t,void 0,(t.current.flags&128)===128)}catch{}if(s!==null){t=D.T,i=oe.p,oe.p=2,D.T=null;try{for(var o=e.onRecoverableError,S=0;S<s.length;S++){var h=s[S];o(h.value,{componentStack:h.stack})}}finally{D.T=t,oe.p=i}}(Ma&3)!==0&&Wi(),Ta(e),i=e.pendingLanes,(n&261930)!==0&&(i&42)!==0?e===oT?hl++:(hl=0,oT=e):hl=0,fl(0)}}function mu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,tl(t)))}function Wi(){return pu(),Lu(),_u(),vu()}function vu(){if($t!==5)return!1;var e=nr,t=lT;lT=0;var n=js(Ma),s=D.T,i=oe.p;try{oe.p=32>n?32:n,D.T=null,n=iT,iT=null;var o=nr,S=Ma;if($t=0,fs=nr=null,Ma=0,(Rt&6)!==0)throw Error(T(331));var h=Rt;if(Rt|=4,ou(o.current),su(o,o.current,S,n),Rt=h,fl(0,!1),qt&&typeof qt.onPostCommitFiberRoot=="function")try{qt.onPostCommitFiberRoot(Jn,o)}catch{}return!0}finally{oe.p=i,D.T=s,mu(e,t)}}function xu(e,t,n){t=Vn(n,t),t=YE(e.stateNode,t,2),e=$a(e,t,2),e!==null&&(Hn(e,2),Ta(e))}function dt(e,t,n){if(e.tag===3)xu(e,e,n);else for(;t!==null;){if(t.tag===3){xu(t,e,n);break}else if(t.tag===1){var s=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(tr===null||!tr.has(s))){e=Vn(n,e),n=DR(2),s=$a(t,n,2),s!==null&&(yR(n,s,t,e),Hn(s,2),Ta(s));break}}t=t.return}}function cT(e,t,n){var s=e.pingCache;if(s===null){s=e.pingCache=new AN;var i=new Set;s.set(t,i)}else i=s.get(t),i===void 0&&(i=new Set,s.set(t,i));i.has(n)||(aT=!0,i.add(n),e=hN.bind(null,e,t,n),t.then(e,e))}function hN(e,t,n){var s=e.pingCache;s!==null&&s.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Ct===e&&(lt&n)===n&&(bt===4||bt===3&&(lt&62914560)===lt&&300>st()-Hi?(Rt&2)===0&&Cs(e,0):rT|=n,hs===lt&&(hs=0)),Ta(e)}function Du(e,t){t===0&&(t=kr()),e=Cr(e,t),e!==null&&(Hn(e,t),Ta(e))}function fN(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Du(e,n)}function CN(e,t){var n=0;switch(e.tag){case 31:case 13:var s=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(T(314))}s!==null&&s.delete(t),Du(e,n)}function pN(e,t){return ze(e,t)}var Xi=null,Ls=null,ST=!1,Ki=!1,RT=!1,rr=0;function Ta(e){e!==Ls&&e.next===null&&(Ls===null?Xi=Ls=e:Ls=Ls.next=e),Ki=!0,ST||(ST=!0,_N())}function fl(e,t){if(!RT&&Ki){RT=!0;do for(var n=!1,s=Xi;s!==null;){if(e!==0){var i=s.pendingLanes;if(i===0)var o=0;else{var S=s.suspendedLanes,h=s.pingedLanes;o=(1<<31-Kt(42|e)+1)-1,o&=i&~(S&~h),o=o&201326741?o&201326741|1:o?o|2:0}o!==0&&(n=!0,Pu(s,o))}else o=lt,o=Ke(s,s===Ct?o:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(o&3)===0||zt(s,o)||(n=!0,Pu(s,o));s=s.next}while(n);RT=!1}}function LN(){yu()}function yu(){Ki=ST=!1;var e=0;rr!==0&&bN()&&(e=rr);for(var t=st(),n=null,s=Xi;s!==null;){var i=s.next,o=gu(s,t);o===0?(s.next=null,n===null?Xi=i:n.next=i,i===null&&(Ls=n)):(n=s,(e!==0||(o&3)!==0)&&(Ki=!0)),s=i}$t!==0&&$t!==5||fl(e),rr!==0&&(rr=0)}function gu(e,t){for(var n=e.suspendedLanes,s=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes&-62914561;0<o;){var S=31-Kt(o),h=1<<S,g=i[S];g===-1?((h&n)===0||(h&s)!==0)&&(i[S]=Fa(h,t)):g<=t&&(e.expiredLanes|=h),o&=~h}if(t=Ct,n=lt,n=Ke(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,n===0||e===t&&(At===2||At===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&Xe(s),e.callbackNode=null,e.callbackPriority=0;if((n&3)===0||zt(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(s!==null&&Xe(s),js(n)){case 2:case 8:n=Ht;break;case 32:n=Pt;break;case 268435456:n=vn;break;default:n=Pt}return s=Mu.bind(null,e),n=ze(n,s),e.callbackPriority=t,e.callbackNode=n,t}return s!==null&&s!==null&&Xe(s),e.callbackPriority=2,e.callbackNode=null,2}function Mu(e,t){if($t!==0&&$t!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Wi()&&e.callbackNode!==n)return null;var s=lt;return s=Ke(e,e===Ct?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(Ru(e,s,t),gu(e,st()),e.callbackNode!=null&&e.callbackNode===n?Mu.bind(null,e):null)}function Pu(e,t){if(Wi())return null;Ru(e,t,!0)}function _N(){BN(function(){(Rt&6)!==0?ze(Bt,LN):yu()})}function uT(){if(rr===0){var e=Es;e===0&&(e=qn,qn<<=1,(qn&261888)===0&&(qn=256)),rr=e}return rr}function Uu(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:ei(""+e)}function bu(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 mN(e,t,n,s,i){if(t==="submit"&&n&&n.stateNode===i){var o=Uu((i[cn]||null).action),S=s.submitter;S&&(t=(t=S[cn]||null)?Uu(t.formAction):S.getAttribute("formAction"),t!==null&&(o=t,S=null));var h=new ri("action","action",null,s,i);e.push({event:h,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(rr!==0){var g=S?bu(i,S):new FormData(i);UE(n,{pending:!0,data:g,method:i.method,action:o},null,g)}}else typeof o=="function"&&(h.preventDefault(),g=S?bu(i,S):new FormData(i),UE(n,{pending:!0,data:g,method:i.method,action:o},o,g))},currentTarget:i}]})}}for(var AT=0;AT<qo.length;AT++){var dT=qo[AT],vN=dT.toLowerCase(),xN=dT[0].toUpperCase()+dT.slice(1);Qn(vN,"on"+xN)}Qn(cS,"onAnimationEnd"),Qn(SS,"onAnimationIteration"),Qn(RS,"onAnimationStart"),Qn("dblclick","onDoubleClick"),Qn("focusin","onFocus"),Qn("focusout","onBlur"),Qn(WO,"onTransitionRun"),Qn(XO,"onTransitionStart"),Qn(KO,"onTransitionCancel"),Qn(uS,"onTransitionEnd"),ja("onMouseEnter",["mouseout","mouseover"]),ja("onMouseLeave",["mouseout","mouseover"]),ja("onPointerEnter",["pointerout","pointerover"]),ja("onPointerLeave",["pointerout","pointerover"]),la("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),la("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),la("onBeforeInput",["compositionend","keypress","textInput","paste"]),la("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),la("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),la("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Cl="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(" "),DN=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Cl));function Gu(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var s=e[n],i=s.event;s=s.listeners;e:{var o=void 0;if(t)for(var S=s.length-1;0<=S;S--){var h=s[S],g=h.instance,q=h.currentTarget;if(h=h.listener,g!==o&&i.isPropagationStopped())break e;o=h,i.currentTarget=q;try{o(i)}catch(ie){ii(ie)}i.currentTarget=null,o=g}else for(S=0;S<s.length;S++){if(h=s[S],g=h.instance,q=h.currentTarget,h=h.listener,g!==o&&i.isPropagationStopped())break e;o=h,i.currentTarget=q;try{o(i)}catch(ie){ii(ie)}i.currentTarget=null,o=g}}}}function nt(e,t){var n=t[Vs];n===void 0&&(n=t[Vs]=new Set);var s=e+"__bubble";n.has(s)||(Bu(t,e,2,!1),n.add(s))}function OT(e,t,n){var s=0;t&&(s|=4),Bu(n,e,s,t)}var zi="_reactListening"+Math.random().toString(36).slice(2);function NT(e){if(!e[zi]){e[zi]=!0,ua.forEach(function(n){n!=="selectionchange"&&(DN.has(n)||OT(n,!1,e),OT(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[zi]||(t[zi]=!0,OT("selectionchange",!1,t))}}function Bu(e,t,n,s){switch(SA(t)){case 2:var i=aI;break;case 8:i=rI;break;default:i=PT}n=i.bind(null,t,n,e),i=void 0,!Ho||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),s?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 IT(e,t,n,s,i){var o=s;if((t&1)===0&&(t&2)===0&&s!==null)e:for(;;){if(s===null)return;var S=s.tag;if(S===3||S===4){var h=s.stateNode.containerInfo;if(h===i)break;if(S===4)for(S=s.return;S!==null;){var g=S.tag;if((g===3||g===4)&&S.stateNode.containerInfo===i)return;S=S.return}for(;h!==null;){if(S=Fe(h),S===null)return;if(g=S.tag,g===5||g===6||g===26||g===27){s=o=S;continue e}h=h.parentNode}}s=s.return}jc(function(){var q=o,ie=Go(n),de=[];e:{var ee=AS.get(e);if(ee!==void 0){var re=ri,Ue=e;switch(e){case"keypress":if(ni(n)===0)break e;case"keydown":case"keyup":re=CO;break;case"focusin":Ue="focus",re=Vo;break;case"focusout":Ue="blur",re=Vo;break;case"beforeblur":case"afterblur":re=Vo;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":re=Wc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=TO;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=_O;break;case cS:case SS:case RS:re=RO;break;case uS:re=vO;break;case"scroll":case"scrollend":re=oO;break;case"wheel":re=DO;break;case"copy":case"cut":case"paste":re=AO;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=Kc;break;case"toggle":case"beforetoggle":re=gO}var je=(t&4)!==0,It=!je&&(e==="scroll"||e==="scrollend"),V=je?ee!==null?ee+"Capture":null:ee;je=[];for(var G=q,k;G!==null;){var Re=G;if(k=Re.stateNode,Re=Re.tag,Re!==5&&Re!==26&&Re!==27||k===null||V===null||(Re=Ws(G,V),Re!=null&&je.push(pl(G,Re,k))),It)break;G=G.return}0<je.length&&(ee=new re(ee,Ue,null,n,ie),de.push({event:ee,listeners:je}))}}if((t&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ee&&n!==bo&&(Ue=n.relatedTarget||n.fromElement)&&(Fe(Ue)||Ue[Ya]))break e;if((re||ee)&&(ee=ie.window===ie?ie:(ee=ie.ownerDocument)?ee.defaultView||ee.parentWindow:window,re?(Ue=n.relatedTarget||n.toElement,re=q,Ue=Ue?Fe(Ue):null,Ue!==null&&(It=u(Ue),je=Ue.tag,Ue!==It||je!==5&&je!==27&&je!==6)&&(Ue=null)):(re=null,Ue=q),re!==Ue)){if(je=Wc,Re="onMouseLeave",V="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(je=Kc,Re="onPointerLeave",V="onPointerEnter",G="pointer"),It=re==null?ee:ft(re),k=Ue==null?ee:ft(Ue),ee=new je(Re,G+"leave",re,n,ie),ee.target=It,ee.relatedTarget=k,Re=null,Fe(ie)===q&&(je=new je(V,G+"enter",Ue,n,ie),je.target=k,je.relatedTarget=It,Re=je),It=Re,re&&Ue)t:{for(je=yN,V=re,G=Ue,k=0,Re=V;Re;Re=je(Re))k++;Re=0;for(var Ye=G;Ye;Ye=je(Ye))Re++;for(;0<k-Re;)V=je(V),k--;for(;0<Re-k;)G=je(G),Re--;for(;k--;){if(V===G||G!==null&&V===G.alternate){je=V;break t}V=je(V),G=je(G)}je=null}else je=null;re!==null&&Hu(de,ee,re,je,!1),Ue!==null&&It!==null&&Hu(de,It,Ue,je,!0)}}e:{if(ee=q?ft(q):window,re=ee.nodeName&&ee.nodeName.toLowerCase(),re==="select"||re==="input"&&ee.type==="file")var ct=eS;else if(Qc(ee))if(tS)ct=jO;else{ct=FO;var Be=HO}else re=ee.nodeName,!re||re.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?q&&Uo(q.elementType)&&(ct=eS):ct=YO;if(ct&&(ct=ct(e,q))){Zc(de,ct,n,ie);break e}Be&&Be(e,ee,q),e==="focusout"&&q&&ee.type==="number"&&q.memoizedProps.value!=null&&Po(ee,"number",ee.value)}switch(Be=q?ft(q):window,e){case"focusin":(Qc(Be)||Be.contentEditable==="true")&&(ts=Be,ko=q,Qs=null);break;case"focusout":Qs=ko=ts=null;break;case"mousedown":$o=!0;break;case"contextmenu":case"mouseup":case"dragend":$o=!1,ES(de,n,ie);break;case"selectionchange":if(wO)break;case"keydown":case"keyup":ES(de,n,ie)}var Je;if(Wo)e:{switch(e){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else es?Jc(e,n)&&(it="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(it="onCompositionStart");it&&(zc&&n.locale!=="ko"&&(es||it!=="onCompositionStart"?it==="onCompositionEnd"&&es&&(Je=Vc()):(Va=ie,Fo="value"in Va?Va.value:Va.textContent,es=!0)),Be=ki(q,it),0<Be.length&&(it=new Xc(it,e,null,n,ie),de.push({event:it,listeners:Be}),Je?it.data=Je:(Je=qc(n),Je!==null&&(it.data=Je)))),(Je=PO?UO(e,n):bO(e,n))&&(it=ki(q,"onBeforeInput"),0<it.length&&(Be=new Xc("onBeforeInput","beforeinput",null,n,ie),de.push({event:Be,listeners:it}),Be.data=Je)),mN(de,e,q,n,ie)}Gu(de,t)})}function pl(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ki(e,t){for(var n=t+"Capture",s=[];e!==null;){var i=e,o=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||o===null||(i=Ws(e,n),i!=null&&s.unshift(pl(e,i,o)),i=Ws(e,t),i!=null&&s.push(pl(e,i,o))),e.tag===3)return s;e=e.return}return[]}function yN(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Hu(e,t,n,s,i){for(var o=t._reactName,S=[];n!==null&&n!==s;){var h=n,g=h.alternate,q=h.stateNode;if(h=h.tag,g!==null&&g===s)break;h!==5&&h!==26&&h!==27||q===null||(g=q,i?(q=Ws(n,o),q!=null&&S.unshift(pl(n,q,g))):i||(q=Ws(n,o),q!=null&&S.push(pl(n,q,g)))),n=n.return}S.length!==0&&e.push({event:t,listeners:S})}var gN=/\r\n?/g,MN=/\u0000|\uFFFD/g;function Fu(e){return(typeof e=="string"?e:""+e).replace(gN,`
`).replace(MN,"")}function Yu(e,t){return t=Fu(t),Fu(e)===t}function Nt(e,t,n,s,i,o){switch(n){case"children":typeof s=="string"?t==="body"||t==="textarea"&&s===""||qr(e,s):(typeof s=="number"||typeof s=="bigint")&&t!=="body"&&qr(e,""+s);break;case"className":Ql(e,"class",s);break;case"tabIndex":Ql(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":Ql(e,n,s);break;case"style":Fc(e,s,o);break;case"data":if(t!=="object"){Ql(e,"data",s);break}case"src":case"href":if(s===""&&(t!=="a"||n!=="href")){e.removeAttribute(n);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=ei(""+s),e.setAttribute(n,s);break;case"action":case"formAction":if(typeof s=="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"&&Nt(e,t,"name",i.name,i,null),Nt(e,t,"formEncType",i.formEncType,i,null),Nt(e,t,"formMethod",i.formMethod,i,null),Nt(e,t,"formTarget",i.formTarget,i,null)):(Nt(e,t,"encType",i.encType,i,null),Nt(e,t,"method",i.method,i,null),Nt(e,t,"target",i.target,i,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(n);break}s=ei(""+s),e.setAttribute(n,s);break;case"onClick":s!=null&&(e.onclick=Oa);break;case"onScroll":s!=null&&nt("scroll",e);break;case"onScrollEnd":s!=null&&nt("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(T(61));if(n=s.__html,n!=null){if(i.children!=null)throw Error(T(60));e.innerHTML=n}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}n=ei(""+s),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":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""+s):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":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,""):e.removeAttribute(n);break;case"capture":case"download":s===!0?e.setAttribute(n,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(n,s):e.removeAttribute(n);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(n,s):e.removeAttribute(n);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(n):e.setAttribute(n,s);break;case"popover":nt("beforetoggle",e),nt("toggle",e),ql(e,"popover",s);break;case"xlinkActuate":da(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":da(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":da(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":da(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":da(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":da(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":da(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":da(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":da(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":ql(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<n.length)||n[0]!=="o"&&n[0]!=="O"||n[1]!=="n"&&n[1]!=="N")&&(n=lO.get(n)||n,ql(e,n,s))}}function hT(e,t,n,s,i,o){switch(n){case"style":Fc(e,s,o);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(T(61));if(n=s.__html,n!=null){if(i.children!=null)throw Error(T(60));e.innerHTML=n}}break;case"children":typeof s=="string"?qr(e,s):(typeof s=="number"||typeof s=="bigint")&&qr(e,""+s);break;case"onScroll":s!=null&&nt("scroll",e);break;case"onScrollEnd":s!=null&&nt("scrollend",e);break;case"onClick":s!=null&&(e.onclick=Oa);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Aa.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[cn]||null,o=o!=null?o[n]:null,typeof o=="function"&&e.removeEventListener(t,o,i),typeof s=="function")){typeof o!="function"&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,s,i);break e}n in e?e[n]=s:s===!0?e.setAttribute(n,""):ql(e,n,s)}}}function En(e,t,n){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":nt("error",e),nt("load",e);var s=!1,i=!1,o;for(o in n)if(n.hasOwnProperty(o)){var S=n[o];if(S!=null)switch(o){case"src":s=!0;break;case"srcSet":i=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(T(137,t));default:Nt(e,t,o,S,n,null)}}i&&Nt(e,t,"srcSet",n.srcSet,n,null),s&&Nt(e,t,"src",n.src,n,null);return;case"input":nt("invalid",e);var h=o=S=i=null,g=null,q=null;for(s in n)if(n.hasOwnProperty(s)){var ie=n[s];if(ie!=null)switch(s){case"name":i=ie;break;case"type":S=ie;break;case"checked":g=ie;break;case"defaultChecked":q=ie;break;case"value":o=ie;break;case"defaultValue":h=ie;break;case"children":case"dangerouslySetInnerHTML":if(ie!=null)throw Error(T(137,t));break;default:Nt(e,t,s,ie,n,null)}}bc(e,o,h,g,q,S,i,!1);return;case"select":nt("invalid",e),s=S=o=null;for(i in n)if(n.hasOwnProperty(i)&&(h=n[i],h!=null))switch(i){case"value":o=h;break;case"defaultValue":S=h;break;case"multiple":s=h;default:Nt(e,t,i,h,n,null)}t=o,n=S,e.multiple=!!s,t!=null?Jr(e,!!s,t,!1):n!=null&&Jr(e,!!s,n,!0);return;case"textarea":nt("invalid",e),o=i=s=null;for(S in n)if(n.hasOwnProperty(S)&&(h=n[S],h!=null))switch(S){case"value":s=h;break;case"defaultValue":i=h;break;case"children":o=h;break;case"dangerouslySetInnerHTML":if(h!=null)throw Error(T(91));break;default:Nt(e,t,S,h,n,null)}Bc(e,s,i,o);return;case"option":for(g in n)if(n.hasOwnProperty(g)&&(s=n[g],s!=null))switch(g){case"selected":e.selected=s&&typeof s!="function"&&typeof s!="symbol";break;default:Nt(e,t,g,s,n,null)}return;case"dialog":nt("beforetoggle",e),nt("toggle",e),nt("cancel",e),nt("close",e);break;case"iframe":case"object":nt("load",e);break;case"video":case"audio":for(s=0;s<Cl.length;s++)nt(Cl[s],e);break;case"image":nt("error",e),nt("load",e);break;case"details":nt("toggle",e);break;case"embed":case"source":case"link":nt("error",e),nt("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(q in n)if(n.hasOwnProperty(q)&&(s=n[q],s!=null))switch(q){case"children":case"dangerouslySetInnerHTML":throw Error(T(137,t));default:Nt(e,t,q,s,n,null)}return;default:if(Uo(t)){for(ie in n)n.hasOwnProperty(ie)&&(s=n[ie],s!==void 0&&hT(e,t,ie,s,n,void 0));return}}for(h in n)n.hasOwnProperty(h)&&(s=n[h],s!=null&&Nt(e,t,h,s,n,null))}function PN(e,t,n,s){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,h=null,g=null,q=null,ie=null;for(re in n){var de=n[re];if(n.hasOwnProperty(re)&&de!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":g=de;default:s.hasOwnProperty(re)||Nt(e,t,re,null,s,de)}}for(var ee in s){var re=s[ee];if(de=n[ee],s.hasOwnProperty(ee)&&(re!=null||de!=null))switch(ee){case"type":o=re;break;case"name":i=re;break;case"checked":q=re;break;case"defaultChecked":ie=re;break;case"value":S=re;break;case"defaultValue":h=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(T(137,t));break;default:re!==de&&Nt(e,t,ee,re,s,de)}}Mo(e,S,h,g,q,ie,o,i);return;case"select":re=S=h=ee=null;for(o in n)if(g=n[o],n.hasOwnProperty(o)&&g!=null)switch(o){case"value":break;case"multiple":re=g;default:s.hasOwnProperty(o)||Nt(e,t,o,null,s,g)}for(i in s)if(o=s[i],g=n[i],s.hasOwnProperty(i)&&(o!=null||g!=null))switch(i){case"value":ee=o;break;case"defaultValue":h=o;break;case"multiple":S=o;default:o!==g&&Nt(e,t,i,o,s,g)}t=h,n=S,s=re,ee!=null?Jr(e,!!n,ee,!1):!!s!=!!n&&(t!=null?Jr(e,!!n,t,!0):Jr(e,!!n,n?[]:"",!1));return;case"textarea":re=ee=null;for(h in n)if(i=n[h],n.hasOwnProperty(h)&&i!=null&&!s.hasOwnProperty(h))switch(h){case"value":break;case"children":break;default:Nt(e,t,h,null,s,i)}for(S in s)if(i=s[S],o=n[S],s.hasOwnProperty(S)&&(i!=null||o!=null))switch(S){case"value":ee=i;break;case"defaultValue":re=i;break;case"children":break;case"dangerouslySetInnerHTML":if(i!=null)throw Error(T(91));break;default:i!==o&&Nt(e,t,S,i,s,o)}Gc(e,ee,re);return;case"option":for(var Ue in n)if(ee=n[Ue],n.hasOwnProperty(Ue)&&ee!=null&&!s.hasOwnProperty(Ue))switch(Ue){case"selected":e.selected=!1;break;default:Nt(e,t,Ue,null,s,ee)}for(g in s)if(ee=s[g],re=n[g],s.hasOwnProperty(g)&&ee!==re&&(ee!=null||re!=null))switch(g){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:Nt(e,t,g,ee,s,re)}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 je in n)ee=n[je],n.hasOwnProperty(je)&&ee!=null&&!s.hasOwnProperty(je)&&Nt(e,t,je,null,s,ee);for(q in s)if(ee=s[q],re=n[q],s.hasOwnProperty(q)&&ee!==re&&(ee!=null||re!=null))switch(q){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(T(137,t));break;default:Nt(e,t,q,ee,s,re)}return;default:if(Uo(t)){for(var It in n)ee=n[It],n.hasOwnProperty(It)&&ee!==void 0&&!s.hasOwnProperty(It)&&hT(e,t,It,void 0,s,ee);for(ie in s)ee=s[ie],re=n[ie],!s.hasOwnProperty(ie)||ee===re||ee===void 0&&re===void 0||hT(e,t,ie,ee,s,re);return}}for(var V in n)ee=n[V],n.hasOwnProperty(V)&&ee!=null&&!s.hasOwnProperty(V)&&Nt(e,t,V,null,s,ee);for(de in s)ee=s[de],re=n[de],!s.hasOwnProperty(de)||ee===re||ee==null&&re==null||Nt(e,t,de,ee,s,re)}function ju(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function UN(){if(typeof performance.getEntriesByType=="function"){for(var e=0,t=0,n=performance.getEntriesByType("resource"),s=0;s<n.length;s++){var i=n[s],o=i.transferSize,S=i.initiatorType,h=i.duration;if(o&&h&&ju(S)){for(S=0,h=i.responseEnd,s+=1;s<n.length;s++){var g=n[s],q=g.startTime;if(q>h)break;var ie=g.transferSize,de=g.initiatorType;ie&&ju(de)&&(g=g.responseEnd,S+=ie*(g<h?1:(h-q)/(g-q)))}if(--s,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 fT=null,CT=null;function $i(e){return e.nodeType===9?e:e.ownerDocument}function Vu(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 wu(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 pT(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 LT=null;function bN(){var e=window.event;return e&&e.type==="popstate"?e===LT?!1:(LT=e,!0):(LT=null,!1)}var Wu=typeof setTimeout=="function"?setTimeout:void 0,GN=typeof clearTimeout=="function"?clearTimeout:void 0,Xu=typeof Promise=="function"?Promise:void 0,BN=typeof queueMicrotask=="function"?queueMicrotask:typeof Xu<"u"?function(e){return Xu.resolve(null).then(e).catch(HN)}:Wu;function HN(e){setTimeout(function(){throw e})}function sr(e){return e==="head"}function Ku(e,t){var n=t,s=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"||n==="/&"){if(s===0){e.removeChild(i),xs(t);return}s--}else if(n==="$"||n==="$?"||n==="$~"||n==="$!"||n==="&")s++;else if(n==="html")Ll(e.ownerDocument.documentElement);else if(n==="head"){n=e.ownerDocument.head,Ll(n);for(var o=n.firstChild;o;){var S=o.nextSibling,h=o.nodeName;o[Nr]||h==="SCRIPT"||h==="STYLE"||h==="LINK"&&o.rel.toLowerCase()==="stylesheet"||n.removeChild(o),o=S}}else n==="body"&&Ll(e.ownerDocument.body);n=i}while(n);xs(t)}function zu(e,t){var n=e;e=0;do{var s=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||""),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(e===0)break;e--}else n!=="$"&&n!=="$?"&&n!=="$~"&&n!=="$!"||e++;n=s}while(n)}function _T(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":_T(n),ce(n);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(n.rel.toLowerCase()==="stylesheet")continue}e.removeChild(n)}}function FN(e,t,n,s){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[Nr])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=zn(e.nextSibling),e===null)break}return null}function YN(e,t,n){if(t==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=zn(e.nextSibling),e===null))return null;return e}function ku(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!t||(e=zn(e.nextSibling),e===null))return null;return e}function mT(e){return e.data==="$?"||e.data==="$~"}function vT(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function jN(e,t){var n=e.ownerDocument;if(e.data==="$~")e._reactRetry=t;else if(e.data!=="$?"||n.readyState!=="loading")t();else{var s=function(){t(),n.removeEventListener("DOMContentLoaded",s)};n.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function zn(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 xT=null;function $u(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"||n==="/&"){if(t===0)return zn(e.nextSibling);t--}else n!=="$"&&n!=="$!"&&n!=="$?"&&n!=="$~"&&n!=="&"||t++}e=e.nextSibling}return null}function Ju(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 qu(e,t,n){switch(t=$i(n),e){case"html":if(e=t.documentElement,!e)throw Error(T(452));return e;case"head":if(e=t.head,!e)throw Error(T(453));return e;case"body":if(e=t.body,!e)throw Error(T(454));return e;default:throw Error(T(451))}}function Ll(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ce(e)}var kn=new Map,Qu=new Set;function Ji(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pa=oe.d;oe.d={f:VN,r:wN,D:WN,C:XN,L:KN,m:zN,X:$N,S:kN,M:JN};function VN(){var e=Pa.f(),t=ji();return e||t}function wN(e){var t=We(e);t!==null&&t.tag===5&&t.type==="form"?uR(t):Pa.r(e)}var _s=typeof document>"u"?null:document;function Zu(e,t,n){var s=_s;if(s&&typeof t=="string"&&t){var i=Yn(t);i='link[rel="'+e+'"][href="'+i+'"]',typeof n=="string"&&(i+='[crossorigin="'+n+'"]'),Qu.has(i)||(Qu.add(i),e={rel:e,crossOrigin:n,href:t},s.querySelector(i)===null&&(t=s.createElement("link"),En(t,"link",e),yt(t),s.head.appendChild(t)))}}function WN(e){Pa.D(e),Zu("dns-prefetch",e,null)}function XN(e,t){Pa.C(e,t),Zu("preconnect",e,t)}function KN(e,t,n){Pa.L(e,t,n);var s=_s;if(s&&e&&t){var i='link[rel="preload"][as="'+Yn(t)+'"]';t==="image"&&n&&n.imageSrcSet?(i+='[imagesrcset="'+Yn(n.imageSrcSet)+'"]',typeof n.imageSizes=="string"&&(i+='[imagesizes="'+Yn(n.imageSizes)+'"]')):i+='[href="'+Yn(e)+'"]';var o=i;switch(t){case"style":o=ms(e);break;case"script":o=vs(e)}kn.has(o)||(e=d({rel:"preload",href:t==="image"&&n&&n.imageSrcSet?void 0:e,as:t},n),kn.set(o,e),s.querySelector(i)!==null||t==="style"&&s.querySelector(_l(o))||t==="script"&&s.querySelector(ml(o))||(t=s.createElement("link"),En(t,"link",e),yt(t),s.head.appendChild(t)))}}function zN(e,t){Pa.m(e,t);var n=_s;if(n&&e){var s=t&&typeof t.as=="string"?t.as:"script",i='link[rel="modulepreload"][as="'+Yn(s)+'"][href="'+Yn(e)+'"]',o=i;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":o=vs(e)}if(!kn.has(o)&&(e=d({rel:"modulepreload",href:e},t),kn.set(o,e),n.querySelector(i)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(n.querySelector(ml(o)))return}s=n.createElement("link"),En(s,"link",e),yt(s),n.head.appendChild(s)}}}function kN(e,t,n){Pa.S(e,t,n);var s=_s;if(s&&e){var i=Tt(s).hoistableStyles,o=ms(e);t=t||"default";var S=i.get(o);if(!S){var h={loading:0,preload:null};if(S=s.querySelector(_l(o)))h.loading=5;else{e=d({rel:"stylesheet",href:e,"data-precedence":t},n),(n=kn.get(o))&&DT(e,n);var g=S=s.createElement("link");yt(g),En(g,"link",e),g._p=new Promise(function(q,ie){g.onload=q,g.onerror=ie}),g.addEventListener("load",function(){h.loading|=1}),g.addEventListener("error",function(){h.loading|=2}),h.loading|=4,qi(S,t,s)}S={type:"stylesheet",instance:S,count:1,state:h},i.set(o,S)}}}function $N(e,t){Pa.X(e,t);var n=_s;if(n&&e){var s=Tt(n).hoistableScripts,i=vs(e),o=s.get(i);o||(o=n.querySelector(ml(i)),o||(e=d({src:e,async:!0},t),(t=kn.get(i))&&yT(e,t),o=n.createElement("script"),yt(o),En(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},s.set(i,o))}}function JN(e,t){Pa.M(e,t);var n=_s;if(n&&e){var s=Tt(n).hoistableScripts,i=vs(e),o=s.get(i);o||(o=n.querySelector(ml(i)),o||(e=d({src:e,async:!0,type:"module"},t),(t=kn.get(i))&&yT(e,t),o=n.createElement("script"),yt(o),En(o,"link",e),n.head.appendChild(o)),o={type:"script",instance:o,count:1,state:null},s.set(i,o))}}function eA(e,t,n,s){var i=(i=te.current)?Ji(i):null;if(!i)throw Error(T(446));switch(e){case"meta":case"title":return null;case"style":return typeof n.precedence=="string"&&typeof n.href=="string"?(t=ms(n.href),n=Tt(i).hoistableStyles,s=n.get(t),s||(s={type:"style",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(n.rel==="stylesheet"&&typeof n.href=="string"&&typeof n.precedence=="string"){e=ms(n.href);var o=Tt(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(_l(e)))&&!o._p&&(S.instance=o,S.state.loading=5),kn.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},kn.set(e,n),o||qN(i,e,n,S.state))),t&&s===null)throw Error(T(528,""));return S}if(t&&s!==null)throw Error(T(529,""));return null;case"script":return t=n.async,n=n.src,typeof n=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=vs(n),n=Tt(i).hoistableScripts,s=n.get(t),s||(s={type:"script",instance:null,count:0,state:null},n.set(t,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(T(444,e))}}function ms(e){return'href="'+Yn(e)+'"'}function _l(e){return'link[rel="stylesheet"]['+e+"]"}function tA(e){return d({},e,{"data-precedence":e.precedence,precedence:null})}function qN(e,t,n,s){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?s.loading=1:(t=e.createElement("link"),s.preload=t,t.addEventListener("load",function(){return s.loading|=1}),t.addEventListener("error",function(){return s.loading|=2}),En(t,"link",n),yt(t),e.head.appendChild(t))}function vs(e){return'[src="'+Yn(e)+'"]'}function ml(e){return"script[async]"+e}function nA(e,t,n){if(t.count++,t.instance===null)switch(t.type){case"style":var s=e.querySelector('style[data-href~="'+Yn(n.href)+'"]');if(s)return t.instance=s,yt(s),s;var i=d({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),yt(s),En(s,"style",i),qi(s,n.precedence,e),t.instance=s;case"stylesheet":i=ms(n.href);var o=e.querySelector(_l(i));if(o)return t.state.loading|=4,t.instance=o,yt(o),o;s=tA(n),(i=kn.get(i))&&DT(s,i),o=(e.ownerDocument||e).createElement("link"),yt(o);var S=o;return S._p=new Promise(function(h,g){S.onload=h,S.onerror=g}),En(o,"link",s),t.state.loading|=4,qi(o,n.precedence,e),t.instance=o;case"script":return o=vs(n.src),(i=e.querySelector(ml(o)))?(t.instance=i,yt(i),i):(s=n,(i=kn.get(o))&&(s=d({},n),yT(s,i)),e=e.ownerDocument||e,i=e.createElement("script"),yt(i),En(i,"link",s),e.head.appendChild(i),t.instance=i);case"void":return null;default:throw Error(T(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(s=t.instance,t.state.loading|=4,qi(s,n.precedence,e));return t.instance}function qi(e,t,n){for(var s=n.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),i=s.length?s[s.length-1]:null,o=i,S=0;S<s.length;S++){var h=s[S];if(h.dataset.precedence===t)o=h;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 DT(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.title==null&&(e.title=t.title)}function yT(e,t){e.crossOrigin==null&&(e.crossOrigin=t.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=t.referrerPolicy),e.integrity==null&&(e.integrity=t.integrity)}var Qi=null;function aA(e,t,n){if(Qi===null){var s=new Map,i=Qi=new Map;i.set(n,s)}else i=Qi,s=i.get(n),s||(s=new Map,i.set(n,s));if(s.has(e))return s;for(s.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var o=n[i];if(!(o[Nr]||o[kt]||e==="link"&&o.getAttribute("rel")==="stylesheet")&&o.namespaceURI!=="http://www.w3.org/2000/svg"){var S=o.getAttribute(t)||"";S=e+S;var h=s.get(S);h?h.push(o):s.set(S,[o])}}return s}function rA(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t==="title"?e.querySelector("head > title"):null)}function QN(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 sA(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function ZN(e,t,n,s){if(n.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(n.state.loading&4)===0){if(n.instance===null){var i=ms(s.href),o=t.querySelector(_l(i));if(o){t=o._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=Zi.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=o,yt(o);return}o=t.ownerDocument||t,s=tA(s),(i=kn.get(i))&&DT(s,i),o=o.createElement("link"),yt(o);var S=o;S._p=new Promise(function(h,g){S.onload=h,S.onerror=g}),En(o,"link",s),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=Zi.bind(e),t.addEventListener("load",n),t.addEventListener("error",n))}}var gT=0;function eI(e,t){return e.stylesheets&&e.count===0&&to(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var s=setTimeout(function(){if(e.stylesheets&&to(e,e.stylesheets),e.unsuspend){var o=e.unsuspend;e.unsuspend=null,o()}},6e4+t);0<e.imgBytes&&gT===0&&(gT=62500*UN());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&to(e,e.stylesheets),e.unsuspend)){var o=e.unsuspend;e.unsuspend=null,o()}},(e.imgBytes>gT?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(i)}}:null}function Zi(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)to(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var eo=null;function to(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,eo=new Map,t.forEach(tI,e),eo=null,Zi.call(e))}function tI(e,t){if(!(t.state.loading&4)){var n=eo.get(e);if(n)var s=n.get(null);else{n=new Map,eo.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),s=S)}s&&n.set(null,s)}i=t.instance,S=i.getAttribute("data-precedence"),o=n.get(S)||s,o===s&&n.set(null,i),n.set(S,i),this.count++,s=Zi.bind(this),i.addEventListener("load",s),i.addEventListener("error",s),o?o.parentNode.insertBefore(i,o.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var vl={$$typeof:Z,Provider:null,Consumer:null,_currentValue:Oe,_currentValue2:Oe,_threadCount:0};function nI(e,t,n,s,i,o,S,h,g){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=rn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rn(0),this.hiddenUpdates=rn(null),this.identifierPrefix=s,this.onUncaughtError=i,this.onCaughtError=o,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=g,this.incompleteTransitions=new Map}function lA(e,t,n,s,i,o,S,h,g,q,ie,de){return e=new nI(e,t,n,S,g,q,ie,de,h),t=1,o===!0&&(t|=24),o=Dn(3,null,null,t),e.current=o,o.stateNode=e,t=TE(),t.refCount++,e.pooledCache=t,t.refCount++,o.memoizedState={element:s,isDehydrated:n,cache:t},uE(o),e}function iA(e){return e?(e=rs,e):rs}function oA(e,t,n,s,i,o){i=iA(i),s.context===null?s.context=i:s.pendingContext=i,s=ka(t),s.payload={element:n},o=o===void 0?null:o,o!==null&&(s.callback=o),n=$a(e,s,t),n!==null&&(Ln(n,e,t),sl(n,e,t))}function EA(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function MT(e,t){EA(e,t),(e=e.alternate)&&EA(e,t)}function TA(e){if(e.tag===13||e.tag===31){var t=Cr(e,67108864);t!==null&&Ln(t,e,67108864),MT(e,67108864)}}function cA(e){if(e.tag===13||e.tag===31){var t=Un();t=Or(t);var n=Cr(e,t);n!==null&&Ln(n,e,t),MT(e,t)}}var no=!0;function aI(e,t,n,s){var i=D.T;D.T=null;var o=oe.p;try{oe.p=2,PT(e,t,n,s)}finally{oe.p=o,D.T=i}}function rI(e,t,n,s){var i=D.T;D.T=null;var o=oe.p;try{oe.p=8,PT(e,t,n,s)}finally{oe.p=o,D.T=i}}function PT(e,t,n,s){if(no){var i=UT(s);if(i===null)IT(e,t,s,ao,n),RA(e,s);else if(lI(i,e,t,n,s))s.stopPropagation();else if(RA(e,s),t&4&&-1<sI.indexOf(e)){for(;i!==null;){var o=We(i);if(o!==null)switch(o.tag){case 3:if(o=o.stateNode,o.current.memoizedState.isDehydrated){var S=Pe(o.pendingLanes);if(S!==0){var h=o;for(h.pendingLanes|=2,h.entangledLanes|=2;S;){var g=1<<31-Kt(S);h.entanglements[1]|=g,S&=~g}Ta(o),(Rt&6)===0&&(Fi=st()+500,fl(0))}}break;case 31:case 13:h=Cr(o,2),h!==null&&Ln(h,o,2),ji(),MT(o,2)}if(o=UT(s),o===null&&IT(e,t,s,ao,n),o===i)break;i=o}i!==null&&s.stopPropagation()}else IT(e,t,s,null,n)}}function UT(e){return e=Go(e),bT(e)}var ao=null;function bT(e){if(ao=null,e=Fe(e),e!==null){var t=u(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=N(t),e!==null)return e;e=null}else if(n===31){if(e=L(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 ao=e,null}function SA(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(Gt()){case Bt:return 2;case Ht:return 8;case Pt:case mn:return 32;case vn:return 268435456;default:return 32}default:return 32}}var GT=!1,lr=null,ir=null,or=null,xl=new Map,Dl=new Map,Er=[],sI="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 RA(e,t){switch(e){case"focusin":case"focusout":lr=null;break;case"dragenter":case"dragleave":ir=null;break;case"mouseover":case"mouseout":or=null;break;case"pointerover":case"pointerout":xl.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Dl.delete(t.pointerId)}}function yl(e,t,n,s,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:s,nativeEvent:o,targetContainers:[i]},t!==null&&(t=We(t),t!==null&&TA(t)),e):(e.eventSystemFlags|=s,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function lI(e,t,n,s,i){switch(t){case"focusin":return lr=yl(lr,e,t,n,s,i),!0;case"dragenter":return ir=yl(ir,e,t,n,s,i),!0;case"mouseover":return or=yl(or,e,t,n,s,i),!0;case"pointerover":var o=i.pointerId;return xl.set(o,yl(xl.get(o)||null,e,t,n,s,i)),!0;case"gotpointercapture":return o=i.pointerId,Dl.set(o,yl(Dl.get(o)||null,e,t,n,s,i)),!0}return!1}function uA(e){var t=Fe(e.target);if(t!==null){var n=u(t);if(n!==null){if(t=n.tag,t===13){if(t=N(n),t!==null){e.blockedOn=t,$l(e.priority,function(){cA(n)});return}}else if(t===31){if(t=L(n),t!==null){e.blockedOn=t,$l(e.priority,function(){cA(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 ro(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=UT(e.nativeEvent);if(n===null){n=e.nativeEvent;var s=new n.constructor(n.type,n);bo=s,n.target.dispatchEvent(s),bo=null}else return t=We(n),t!==null&&TA(t),e.blockedOn=n,!1;t.shift()}return!0}function AA(e,t,n){ro(e)&&n.delete(t)}function iI(){GT=!1,lr!==null&&ro(lr)&&(lr=null),ir!==null&&ro(ir)&&(ir=null),or!==null&&ro(or)&&(or=null),xl.forEach(AA),Dl.forEach(AA)}function so(e,t){e.blockedOn===t&&(e.blockedOn=null,GT||(GT=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,iI)))}var lo=null;function dA(e){lo!==e&&(lo=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){lo===e&&(lo=null);for(var t=0;t<e.length;t+=3){var n=e[t],s=e[t+1],i=e[t+2];if(typeof s!="function"){if(bT(s||n)===null)continue;break}var o=We(n);o!==null&&(e.splice(t,3),t-=3,UE(o,{pending:!0,data:i,method:n.method,action:s},s,i))}}))}function xs(e){function t(g){return so(g,e)}lr!==null&&so(lr,e),ir!==null&&so(ir,e),or!==null&&so(or,e),xl.forEach(t),Dl.forEach(t);for(var n=0;n<Er.length;n++){var s=Er[n];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Er.length&&(n=Er[0],n.blockedOn===null);)uA(n),n.blockedOn===null&&Er.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(s=0;s<n.length;s+=3){var i=n[s],o=n[s+1],S=i[cn]||null;if(typeof o=="function")S||dA(n);else if(S){var h=null;if(o&&o.hasAttribute("formAction")){if(i=o,S=o[cn]||null)h=S.formAction;else if(bT(i)!==null)continue}else h=S.action;typeof h=="function"?n[s+1]=h:(n.splice(s,3),s-=3),dA(n)}}}function OA(){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),s||setTimeout(n,20)}function n(){if(!s&&!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 s=!1,i=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(n,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),i!==null&&(i(),i=null)}}}function BT(e){this._internalRoot=e}io.prototype.render=BT.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(T(409));var n=t.current,s=Un();oA(n,s,e,t,null,null)},io.prototype.unmount=BT.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;oA(e.current,2,null,e,null,null),ji(),t[Ya]=null}};function io(e){this._internalRoot=e}io.prototype.unstable_scheduleHydration=function(e){if(e){var t=kl();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Er.length&&t!==0&&t<Er[n].priority;n++);Er.splice(n,0,e),n===0&&uA(e)}};var NA=l.version;if(NA!=="19.2.4")throw Error(T(527,NA,"19.2.4"));oe.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(T(188)):(e=Object.keys(e).join(","),Error(T(268,e)));return e=R(t),e=e!==null?O(e):null,e=e===null?null:e.stateNode,e};var oI={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var oo=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!oo.isDisabled&&oo.supportsFiber)try{Jn=oo.inject(oI),qt=oo}catch{}}return Ml.createRoot=function(e,t){if(!c(e))throw Error(T(299));var n=!1,s="",i=_R,o=mR,S=vR;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(s=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(o=t.onCaughtError),t.onRecoverableError!==void 0&&(S=t.onRecoverableError)),t=lA(e,1,!1,null,null,n,s,null,i,o,S,OA),e[Ya]=t.current,NT(e),new BT(t)},Ml.hydrateRoot=function(e,t,n){if(!c(e))throw Error(T(299));var s=!1,i="",o=_R,S=mR,h=vR,g=null;return n!=null&&(n.unstable_strictMode===!0&&(s=!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&&(h=n.onRecoverableError),n.formState!==void 0&&(g=n.formState)),t=lA(e,1,!0,t,n??null,s,i,g,o,S,h,OA),t.context=iA(null),n=t.current,s=Un(),s=Or(s),i=ka(s),i.callback=null,$a(n,i,s),n=s,t.current.lanes=n,Hn(t,n),Ta(t),e[Ya]=t.current,NT(e),new io(t)},Ml.version="19.2.4",Ml}var xA;function OI(){if(xA)return YT.exports;xA=1;function r(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(r)}catch(l){console.error(l)}}return r(),YT.exports=dI(),YT.exports}var NI=OI();const II=Lc(NI);md();const hc="/api";let Ba=localStorage.getItem("dp_token")||null;async function fe(r,l={}){const E={"Content-Type":"application/json",...l.headers||{}};Ba&&(E.Authorization=`Bearer ${Ba}`);const T=await fetch(`${hc}${r}`,{...l,headers:E});if(T.status===401)throw Ba=null,localStorage.removeItem("dp_token"),window.dispatchEvent(new Event("dp_auth_required")),new Error("Authentication required");if(!T.ok){const c=await T.text();throw new Error(c||T.statusText)}return T.json()}const Ee={setToken:r=>{Ba=r,r?localStorage.setItem("dp_token",r):localStorage.removeItem("dp_token")},getToken:()=>Ba,getAuthStatus:()=>fe("/auth/status"),login:(r,l)=>fe("/auth/login",{method:"POST",body:JSON.stringify({username:r,password:l})}),setup:(r,l,E)=>fe("/auth/setup",{method:"POST",body:JSON.stringify({username:r,password:l,display_name:E})}),getMe:()=>fe("/auth/me"),listUsers:()=>fe("/users"),createUser:(r,l,E,T)=>fe("/users",{method:"POST",body:JSON.stringify({username:r,password:l,role:E,display_name:T})}),updateUser:(r,l)=>fe(`/users/${r}`,{method:"PUT",body:JSON.stringify(l)}),deleteUser:r=>fe(`/users/${r}`,{method:"DELETE"}),listSecrets:()=>fe("/secrets"),setSecret:(r,l)=>fe("/secrets",{method:"POST",body:JSON.stringify({key:r,value:l})}),deleteSecret:r=>fe(`/secrets/${r}`,{method:"DELETE"}),listFiles:()=>fe("/files"),readFile:r=>fe(`/files/${r}`),saveFile:(r,l)=>fe(`/files/${r}`,{method:"PUT",body:JSON.stringify({content:l})}),deleteFile:(r,l=!1)=>fe(`/files/${r}${l?"?drop_object=true":""}`,{method:"DELETE"}),moveFile:(r,l)=>fe(`/files/${r}/move`,{method:"POST",body:JSON.stringify({destination:l})}),listModels:()=>fe("/models"),runTransform:(r=null,l=!1)=>fe("/transform",{method:"POST",body:JSON.stringify({targets:r,force:l})}),runScript:r=>fe("/run",{method:"POST",body:JSON.stringify({script_path:r})}),listStreams:()=>fe("/streams"),runStream:(r,l=!1)=>fe(`/stream/${r}?force=${l}`,{method:"POST"}),cancelStream:()=>fe("/stream/cancel",{method:"POST"}),runStreamSSE:(r,l=!1,E)=>{const T=new AbortController,c=`${hc}/stream/${r}/events?force=${l}`,u={};return Ba&&(u.Authorization=`Bearer ${Ba}`),fetch(c,{signal:T.signal,headers:u}).then(async N=>{var O;if(!N.ok){const d=await N.text();E("error",{message:d||N.statusText});return}const L=(O=N.body)==null?void 0:O.getReader();if(!L)return;const I=new TextDecoder;let R="";for(;;){const{done:d,value:_}=await L.read();if(d)break;R+=I.decode(_,{stream:!0});const C=R.split(`
`);R=C.pop()||"";let f="";for(const m of C)if(m.startsWith("event: "))f=m.slice(7).trim();else if(m.startsWith("data: ")&&f){try{const j=JSON.parse(m.slice(6));E(f,j)}catch{}f=""}}}).catch(N=>{N.name!=="AbortError"&&E("error",{message:String(N)})}),{abort:()=>T.abort()}},runQuery:r=>fe("/query",{method:"POST",body:JSON.stringify({sql:r})}),explainQuery:r=>fe("/query/explain",{method:"POST",body:JSON.stringify({sql:r})}),profileQuery:r=>fe("/query/profile",{method:"POST",body:JSON.stringify({sql:r})}),getSlowQueries:(r=50)=>fe("/metrics/slow-queries?limit="+r),listTables:(r=null)=>fe(`/tables${r?`?schema=${r}`:""}`),describeTable:(r,l)=>fe(`/tables/${r}/${l}`),sampleTable:(r,l,E=100)=>fe(`/tables/${r}/${l}/sample?limit=${E}`),getHistory:(r=50)=>fe(`/history?limit=${r}`),runLint:(r=!1)=>fe(`/lint?fix=${r}`,{method:"POST"}),lintFile:(r,l=!1,E=null)=>fe("/lint/file",{method:"POST",body:JSON.stringify({path:r,fix:l,content:E})}),getLintConfig:()=>fe("/lint/config"),saveLintConfig:r=>fe("/lint/config",{method:"PUT",body:JSON.stringify({content:r})}),deleteLintConfig:()=>fe("/lint/config",{method:"DELETE"}),getDAG:()=>fe("/dag"),getDocs:()=>fe("/docs/markdown"),getStructuredDocs:()=>fe("/docs/structured"),getOverview:()=>fe("/overview"),getConnectorHealth:()=>fe("/connectors/health"),getScheduler:()=>fe("/scheduler"),listNotebooks:()=>fe("/notebooks"),getNotebook:r=>fe(`/notebooks/open/${r}`),saveNotebook:(r,l)=>fe(`/notebooks/save/${r}`,{method:"POST",body:JSON.stringify({notebook:l})}),createNotebook:(r,l="")=>fe(`/notebooks/create/${r}?title=${encodeURIComponent(l)}`,{method:"POST"}),runNotebook:r=>fe(`/notebooks/run/${r}`,{method:"POST"}),runCell:(r,l,{reset:E=!1,cell_type:T="code"}={})=>fe(`/notebooks/run-cell/${r}`,{method:"POST",body:JSON.stringify({source:l,cell_type:T,reset:E})}),previewFile:(r,l,E)=>fe("/import/preview-file",{method:"POST",body:JSON.stringify({file_path:r,target_schema:l,target_table:E})}),importFile:(r,l,E)=>fe("/import/file",{method:"POST",body:JSON.stringify({file_path:r,target_schema:l,target_table:E})}),testConnection:(r,l)=>fe("/import/test-connection",{method:"POST",body:JSON.stringify({connection_type:r,params:l})}),importFromConnection:(r,l,E,T,c)=>fe("/import/from-connection",{method:"POST",body:JSON.stringify({connection_type:r,params:l,source_table:E,target_schema:T,target_table:c})}),listAvailableConnectors:()=>fe("/connectors/available"),listConfiguredConnectors:()=>fe("/connectors"),testConnector:(r,l)=>fe("/connectors/test",{method:"POST",body:JSON.stringify({connector_type:r,config:l})}),discoverConnector:(r,l)=>fe("/connectors/discover",{method:"POST",body:JSON.stringify({connector_type:r,config:l})}),setupConnector:(r,l,E,T,c,u)=>fe("/connectors/setup",{method:"POST",body:JSON.stringify({connector_type:r,connection_name:l,config:E,tables:T,target_schema:c,schedule:u})}),regenerateConnector:(r,l)=>fe(`/connectors/regenerate/${r}`,{method:"POST",body:JSON.stringify(l||{})}),syncConnector:r=>fe(`/connectors/sync/${r}`,{method:"POST"}),removeConnector:r=>fe(`/connectors/${r}`,{method:"DELETE"}),runDiff:(r=null,l=null,E=!1)=>fe("/diff",{method:"POST",body:JSON.stringify({targets:r,target_schema:l,full:E})}),getGitStatus:()=>fe("/git/status"),uploadFile:async r=>{const l=new FormData;l.append("file",r);const E={};Ba&&(E.Authorization=`Bearer ${Ba}`);const T=await fetch(`${hc}/upload`,{method:"POST",body:l,headers:E});if(!T.ok)throw new Error(await T.text());return T.json()},getEnvironment:()=>fe("/environment"),switchEnvironment:r=>fe(`/environment/${r}`,{method:"PUT"}),listSeeds:()=>fe("/seeds"),runSeeds:(r=!1,l="seeds")=>fe("/seeds",{method:"POST",body:JSON.stringify({force:r,schema_name:l})}),listSources:()=>fe("/sources"),checkSourceFreshness:()=>fe("/sources/freshness"),listExposures:()=>fe("/exposures"),getAutocomplete:()=>fe("/autocomplete"),getFullDAG:()=>fe("/dag/full"),getModelNotebookView:r=>fe(`/models/${r}/notebook-view`),createModel:(r,l="bronze",E="table",T="")=>fe("/models/create",{method:"POST",body:JSON.stringify({name:r,schema_name:l,materialized:E,sql:T})}),runCheck:()=>fe("/check",{method:"POST"}),runContracts:()=>fe("/contracts/run",{method:"POST"}),getLineage:r=>fe(`/lineage/${r}`),getAllLineage:()=>fe("/lineage"),getAlertHistory:(r=50)=>fe(`/alerts?limit=${r}`),testAlert:(r,l)=>fe("/alerts/test",{method:"POST",body:JSON.stringify({channel:r,...l})}),getCDCStatus:()=>fe("/cdc"),resetCDCWatermark:r=>fe(`/cdc/${encodeURIComponent(r)}/reset`,{method:"POST"}),listMaskingPolicies:()=>fe("/masking/policies"),createMaskingPolicy:r=>fe("/masking/policies",{method:"POST",body:JSON.stringify(r)}),updateMaskingPolicy:(r,l)=>fe(`/masking/policies/${r}`,{method:"PUT",body:JSON.stringify(l)}),deleteMaskingPolicy:r=>fe(`/masking/policies/${r}`,{method:"DELETE"}),getFreshness:(r=24)=>fe(`/freshness?max_hours=${r}`),getProfiles:()=>fe("/profiles"),getAssertions:(r=100)=>fe(`/assertions?limit=${r}`),getContracts:()=>fe("/contracts"),getContractHistory:()=>fe("/contracts/history"),getImpactAnalysis:(r,l)=>{const E=l?`?column=${encodeURIComponent(l)}`:"";return fe(`/impact/${encodeURIComponent(r)}${E}`)},listWikiPages:()=>fe("/wiki"),getWikiPage:r=>fe(`/wiki/${encodeURIComponent(r)}`),getRewindRuns:(r=100)=>fe(`/rewind/runs?limit=${r}`),getRewindSnapshots:(r=5e3)=>fe(`/rewind/snapshots?limit=${r}`),getRunSnapshots:r=>fe(`/rewind/snapshots/${r}`),getSnapshotSample:(r,l,E=100)=>fe(`/rewind/sample/${r}/${l}?limit=${E}`),restoreSnapshot:(r,l,E=!0)=>fe("/rewind/restore",{method:"POST",body:JSON.stringify({run_id:r,model_name:l,cascade:E})}),getDownstreamModels:r=>fe(`/rewind/downstream/${r}`),runRewindGC:()=>fe("/rewind/gc",{method:"POST"}),runSentinelCheck:()=>fe("/sentinel/check",{method:"POST"}),getSentinelDiffs:(r=50)=>fe(`/sentinel/diffs?limit=${r}`),getSentinelImpacts:r=>fe(`/sentinel/impacts/${r}`),getSentinelHistory:(r,l=20)=>fe(`/sentinel/history/${r}?limit=${l}`),getSentinelSources:()=>fe("/sentinel/sources"),applySentinelFix:(r,l,E)=>fe("/sentinel/apply-fix",{method:"POST",body:JSON.stringify({model_path:r,old_name:l,new_name:E})}),resolveSentinelImpact:(r,l)=>fe("/sentinel/resolve",{method:"POST",body:JSON.stringify({diff_id:r,model_name:l})})};function vd({node:r,depth:l,onSelect:E,activeFile:T,onNewFile:c,onDeleteFile:u,onMoveFile:N}){var v;const[L,I]=A.useState(l<2),[R,O]=A.useState(!1),[d,_]=A.useState(""),[C,f]=A.useState(!1),[m,j]=A.useState(!1),W=T===r.path;if(r.type==="dir")return a.jsxs("div",{children:[a.jsxs("div",{"data-havn-file":"",style:{...$n.item,paddingLeft:8+l*16,background:m?"color-mix(in srgb, var(--havn-accent) 12%, transparent)":"transparent"},onClick:()=>I(!L),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),onDragOver:M=>{M.preventDefault(),M.stopPropagation(),j(!0)},onDragLeave:M=>{M.stopPropagation(),j(!1)},onDrop:M=>{M.preventDefault(),M.stopPropagation(),j(!1);const Te=M.dataTransfer.getData("text/plain");if(Te&&N){const B=Te.split("/").pop(),se=`${r.path}/${B}`;se!==Te&&N(Te,se)}},children:[a.jsx("span",{style:{...$n.icon,transform:L?"rotate(0deg)":"rotate(-90deg)"},children:"▾"}),a.jsx("span",{style:$n.dirName,children:r.name}),C&&a.jsx("button",{onClick:M=>{M.stopPropagation(),I(!0),O(!0),_("")},style:$n.addBtn,title:`New file in ${r.name}/`,children:"+"})]}),L&&R&&a.jsx("div",{style:{...$n.newFileRow,paddingLeft:24+l*16},children:a.jsx("input",{value:d,onChange:M=>_(M.target.value),placeholder:"filename.sql",style:$n.newFileInput,autoFocus:!0,onKeyDown:M=>{M.key==="Enter"&&d.trim()&&(c(`${r.path}/${d.trim()}`),O(!1),_("")),M.key==="Escape"&&(O(!1),_(""))},onBlur:()=>{O(!1),_("")}})}),L&&((v=r.children)==null?void 0:v.map(M=>a.jsx(vd,{node:M,depth:l+1,onSelect:E,activeFile:T,onNewFile:c,onDeleteFile:u,onMoveFile:N},M.path)))]});const P=r.name.split(".").pop(),Z=P==="sql"?"var(--havn-accent)":P==="py"?"var(--havn-green)":"var(--havn-text-secondary)";return a.jsxs("div",{"data-havn-file":"",draggable:!0,onDragStart:M=>{M.dataTransfer.setData("text/plain",r.path),M.dataTransfer.effectAllowed="move"},style:{...$n.item,paddingLeft:8+l*16,background:W?"var(--havn-bg-secondary)":"transparent",borderLeft:W?"2px solid var(--havn-accent)":"2px solid transparent"},onClick:()=>E(r.path),onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[a.jsx("span",{style:{...$n.dot,background:Z}}),a.jsx("span",{style:W?$n.activeFileName:$n.fileName,children:r.name}),C&&u&&a.jsx("button",{onClick:M=>{M.stopPropagation(),u(r.path)},style:$n.deleteBtn,title:`Delete ${r.name}`,children:"×"})]})}function hI({files:r,onSelect:l,activeFile:E,onNewFile:T,onDeleteFile:c,onMoveFile:u}){return a.jsxs("div",{children:[r.length===0&&a.jsx("div",{style:$n.empty,children:"No files found"}),r.map(N=>a.jsx(vd,{node:N,depth:0,onSelect:l,activeFile:E,onNewFile:T,onDeleteFile:c,onMoveFile:u},N.path))]})}const $n={item:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",cursor:"pointer",fontSize:"13px",whiteSpace:"nowrap",margin:"0 4px",borderRadius:"3px"},icon:{fontSize:"10px",color:"var(--havn-text-secondary)",width:"10px",display:"inline-block",transition:"transform 0.12s ease"},dirName:{color:"var(--havn-text)",fontWeight:500,fontFamily:"var(--havn-font-mono)"},addBtn:{marginLeft:"auto",width:"18px",height:"18px",background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"14px",lineHeight:"18px",textAlign:"center",padding:0,flexShrink:0},newFileRow:{display:"flex",padding:"2px 8px 4px",margin:"0 4px"},newFileInput:{flex:1,padding:"3px 6px",background:"var(--havn-bg)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",outline:"none"},fileName:{color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"12px"},activeFileName:{color:"var(--havn-accent)",fontWeight:500,fontFamily:"var(--havn-font-mono)",fontSize:"12px"},dot:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},deleteBtn:{marginLeft:"auto",width:"18px",height:"18px",background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"14px",lineHeight:"18px",textAlign:"center",padding:0,flexShrink:0},empty:{padding:"12px",color:"var(--havn-text-dim)",fontSize:"12px",textAlign:"center"}};function DA(r,l){(l==null||l>r.length)&&(l=r.length);for(var E=0,T=Array(l);E<l;E++)T[E]=r[E];return T}function fI(r){if(Array.isArray(r))return r}function CI(r,l,E){return(l=DI(l))in r?Object.defineProperty(r,l,{value:E,enumerable:!0,configurable:!0,writable:!0}):r[l]=E,r}function pI(r,l){var E=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(E!=null){var T,c,u,N,L=[],I=!0,R=!1;try{if(u=(E=E.call(r)).next,l!==0)for(;!(I=(T=u.call(E)).done)&&(L.push(T.value),L.length!==l);I=!0);}catch(O){R=!0,c=O}finally{try{if(!I&&E.return!=null&&(N=E.return(),Object(N)!==N))return}finally{if(R)throw c}}return L}}function LI(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function yA(r,l){var E=Object.keys(r);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(r);l&&(T=T.filter(function(c){return Object.getOwnPropertyDescriptor(r,c).enumerable})),E.push.apply(E,T)}return E}function gA(r){for(var l=1;l<arguments.length;l++){var E=arguments[l]!=null?arguments[l]:{};l%2?yA(Object(E),!0).forEach(function(T){CI(r,T,E[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(E)):yA(Object(E)).forEach(function(T){Object.defineProperty(r,T,Object.getOwnPropertyDescriptor(E,T))})}return r}function _I(r,l){if(r==null)return{};var E,T,c=mI(r,l);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(r);for(T=0;T<u.length;T++)E=u[T],l.indexOf(E)===-1&&{}.propertyIsEnumerable.call(r,E)&&(c[E]=r[E])}return c}function mI(r,l){if(r==null)return{};var E={};for(var T in r)if({}.hasOwnProperty.call(r,T)){if(l.indexOf(T)!==-1)continue;E[T]=r[T]}return E}function vI(r,l){return fI(r)||pI(r,l)||yI(r,l)||LI()}function xI(r,l){if(typeof r!="object"||!r)return r;var E=r[Symbol.toPrimitive];if(E!==void 0){var T=E.call(r,l);if(typeof T!="object")return T;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(r)}function DI(r){var l=xI(r,"string");return typeof l=="symbol"?l:l+""}function yI(r,l){if(r){if(typeof r=="string")return DA(r,l);var E={}.toString.call(r).slice(8,-1);return E==="Object"&&r.constructor&&(E=r.constructor.name),E==="Map"||E==="Set"?Array.from(r):E==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(E)?DA(r,l):void 0}}function gI(r,l,E){return l in r?Object.defineProperty(r,l,{value:E,enumerable:!0,configurable:!0,writable:!0}):r[l]=E,r}function MA(r,l){var E=Object.keys(r);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(r);l&&(T=T.filter(function(c){return Object.getOwnPropertyDescriptor(r,c).enumerable})),E.push.apply(E,T)}return E}function PA(r){for(var l=1;l<arguments.length;l++){var E=arguments[l]!=null?arguments[l]:{};l%2?MA(Object(E),!0).forEach(function(T){gI(r,T,E[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(E)):MA(Object(E)).forEach(function(T){Object.defineProperty(r,T,Object.getOwnPropertyDescriptor(E,T))})}return r}function MI(){for(var r=arguments.length,l=new Array(r),E=0;E<r;E++)l[E]=arguments[E];return function(T){return l.reduceRight(function(c,u){return u(c)},T)}}function Bl(r){return function l(){for(var E=this,T=arguments.length,c=new Array(T),u=0;u<T;u++)c[u]=arguments[u];return c.length>=r.length?r.apply(this,c):function(){for(var N=arguments.length,L=new Array(N),I=0;I<N;I++)L[I]=arguments[I];return l.apply(E,[].concat(c,L))}}}function Co(r){return{}.toString.call(r).includes("Object")}function PI(r){return!Object.keys(r).length}function jl(r){return typeof r=="function"}function UI(r,l){return Object.prototype.hasOwnProperty.call(r,l)}function bI(r,l){return Co(l)||Sr("changeType"),Object.keys(l).some(function(E){return!UI(r,E)})&&Sr("changeField"),l}function GI(r){jl(r)||Sr("selectorType")}function BI(r){jl(r)||Co(r)||Sr("handlerType"),Co(r)&&Object.values(r).some(function(l){return!jl(l)})&&Sr("handlersType")}function HI(r){r||Sr("initialIsRequired"),Co(r)||Sr("initialType"),PI(r)&&Sr("initialContent")}function FI(r,l){throw new Error(r[l]||r.default)}var YI={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},Sr=Bl(FI)(YI),Eo={changes:bI,selector:GI,handler:BI,initial:HI};function jI(r){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Eo.initial(r),Eo.handler(l);var E={current:r},T=Bl(WI)(E,l),c=Bl(wI)(E),u=Bl(Eo.changes)(r),N=Bl(VI)(E);function L(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(O){return O};return Eo.selector(R),R(E.current)}function I(R){MI(T,c,u,N)(R)}return[L,I]}function VI(r,l){return jl(l)?l(r.current):l}function wI(r,l){return r.current=PA(PA({},r.current),l),l}function WI(r,l,E){return jl(l)?l(r.current):Object.keys(E).forEach(function(T){var c;return(c=l[T])===null||c===void 0?void 0:c.call(l,r.current[T])}),E}var XI={create:jI},KI={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function zI(r){return function l(){for(var E=this,T=arguments.length,c=new Array(T),u=0;u<T;u++)c[u]=arguments[u];return c.length>=r.length?r.apply(this,c):function(){for(var N=arguments.length,L=new Array(N),I=0;I<N;I++)L[I]=arguments[I];return l.apply(E,[].concat(c,L))}}}function kI(r){return{}.toString.call(r).includes("Object")}function $I(r){return r||UA("configIsRequired"),kI(r)||UA("configType"),r.urls?(JI(),{paths:{vs:r.urls.monacoBase}}):r}function JI(){console.warn(xd.deprecation)}function qI(r,l){throw new Error(r[l]||r.default)}var xd={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
    You are using deprecated way of configuration.

    Instead of using
      monaco.config({ urls: { monacoBase: '...' } })
    use
      monaco.config({ paths: { vs: '...' } })

    For more please check the link https://github.com/suren-atoyan/monaco-loader#config
  `},UA=zI(qI)(xd),QI={config:$I},ZI=function(){for(var l=arguments.length,E=new Array(l),T=0;T<l;T++)E[T]=arguments[T];return function(c){return E.reduceRight(function(u,N){return N(u)},c)}};function Dd(r,l){return Object.keys(l).forEach(function(E){l[E]instanceof Object&&r[E]&&Object.assign(l[E],Dd(r[E],l[E]))}),gA(gA({},r),l)}var eh={type:"cancelation",msg:"operation is manually canceled"};function WT(r){var l=!1,E=new Promise(function(T,c){r.then(function(u){return l?c(eh):T(u)}),r.catch(c)});return E.cancel=function(){return l=!0},E}var th=["monaco"],nh=XI.create({config:KI,isInitialized:!1,resolve:null,reject:null,monaco:null}),yd=vI(nh,2),Xl=yd[0],Lo=yd[1];function ah(r){var l=QI.config(r),E=l.monaco,T=_I(l,th);Lo(function(c){return{config:Dd(c.config,T),monaco:E}})}function rh(){var r=Xl(function(l){var E=l.monaco,T=l.isInitialized,c=l.resolve;return{monaco:E,isInitialized:T,resolve:c}});if(!r.isInitialized){if(Lo({isInitialized:!0}),r.monaco)return r.resolve(r.monaco),WT(XT);if(window.monaco&&window.monaco.editor)return gd(window.monaco),r.resolve(window.monaco),WT(XT);ZI(sh,ih)(oh)}return WT(XT)}function sh(r){return document.body.appendChild(r)}function lh(r){var l=document.createElement("script");return r&&(l.src=r),l}function ih(r){var l=Xl(function(T){var c=T.config,u=T.reject;return{config:c,reject:u}}),E=lh("".concat(l.config.paths.vs,"/loader.js"));return E.onload=function(){return r()},E.onerror=l.reject,E}function oh(){var r=Xl(function(E){var T=E.config,c=E.resolve,u=E.reject;return{config:T,resolve:c,reject:u}}),l=window.require;l.config(r.config),l(["vs/editor/editor.main"],function(E){var T=E.m||E;gd(T),r.resolve(T)},function(E){r.reject(E)})}function gd(r){Xl().monaco||Lo({monaco:r})}function Eh(){return Xl(function(r){var l=r.monaco;return l})}var XT=new Promise(function(r,l){return Lo({resolve:r,reject:l})}),mc={config:ah,init:rh,__getMonacoInstance:Eh},Th={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},KT=Th,ch={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Sh=ch;function Rh({children:r}){return aa.createElement("div",{style:Sh.container},r)}var uh=Rh,Ah=uh;function dh({width:r,height:l,isEditorReady:E,loading:T,_ref:c,className:u,wrapperProps:N}){return aa.createElement("section",{style:{...KT.wrapper,width:r,height:l},...N},!E&&aa.createElement(Ah,null,T),aa.createElement("div",{ref:c,style:{...KT.fullWidth,...!E&&KT.hide},className:u}))}var Oh=dh,Md=A.memo(Oh);function Nh(r){A.useEffect(r,[])}var Pd=Nh;function Ih(r,l,E=!0){let T=A.useRef(!0);A.useEffect(T.current||!E?()=>{T.current=!1}:r,l)}var Bn=Ih;function Fl(){}function Us(r,l,E,T){return hh(r,T)||fh(r,l,E,T)}function hh(r,l){return r.editor.getModel(Ud(r,l))}function fh(r,l,E,T){return r.editor.createModel(l,E,T?Ud(r,T):void 0)}function Ud(r,l){return r.Uri.parse(l)}function Ch({original:r,modified:l,language:E,originalLanguage:T,modifiedLanguage:c,originalModelPath:u,modifiedModelPath:N,keepCurrentOriginalModel:L=!1,keepCurrentModifiedModel:I=!1,theme:R="light",loading:O="Loading...",options:d={},height:_="100%",width:C="100%",className:f,wrapperProps:m={},beforeMount:j=Fl,onMount:W=Fl}){let[P,Z]=A.useState(!1),[v,M]=A.useState(!0),Te=A.useRef(null),B=A.useRef(null),se=A.useRef(null),w=A.useRef(W),$=A.useRef(j),J=A.useRef(!1);Pd(()=>{let z=mc.init();return z.then(D=>(B.current=D)&&M(!1)).catch(D=>(D==null?void 0:D.type)!=="cancelation"&&console.error("Monaco initialization: error:",D)),()=>Te.current?ve():z.cancel()}),Bn(()=>{if(Te.current&&B.current){let z=Te.current.getOriginalEditor(),D=Us(B.current,r||"",T||E||"text",u||"");D!==z.getModel()&&z.setModel(D)}},[u],P),Bn(()=>{if(Te.current&&B.current){let z=Te.current.getModifiedEditor(),D=Us(B.current,l||"",c||E||"text",N||"");D!==z.getModel()&&z.setModel(D)}},[N],P),Bn(()=>{let z=Te.current.getModifiedEditor();z.getOption(B.current.editor.EditorOption.readOnly)?z.setValue(l||""):l!==z.getValue()&&(z.executeEdits("",[{range:z.getModel().getFullModelRange(),text:l||"",forceMoveMarkers:!0}]),z.pushUndoStop())},[l],P),Bn(()=>{var z,D;(D=(z=Te.current)==null?void 0:z.getModel())==null||D.original.setValue(r||"")},[r],P),Bn(()=>{let{original:z,modified:D}=Te.current.getModel();B.current.editor.setModelLanguage(z,T||E||"text"),B.current.editor.setModelLanguage(D,c||E||"text")},[E,T,c],P),Bn(()=>{var z;(z=B.current)==null||z.editor.setTheme(R)},[R],P),Bn(()=>{var z;(z=Te.current)==null||z.updateOptions(d)},[d],P);let Ce=A.useCallback(()=>{var oe;if(!B.current)return;$.current(B.current);let z=Us(B.current,r||"",T||E||"text",u||""),D=Us(B.current,l||"",c||E||"text",N||"");(oe=Te.current)==null||oe.setModel({original:z,modified:D})},[E,l,c,r,T,u,N]),Ie=A.useCallback(()=>{var z;!J.current&&se.current&&(Te.current=B.current.editor.createDiffEditor(se.current,{automaticLayout:!0,...d}),Ce(),(z=B.current)==null||z.editor.setTheme(R),Z(!0),J.current=!0)},[d,R,Ce]);A.useEffect(()=>{P&&w.current(Te.current,B.current)},[P]),A.useEffect(()=>{!v&&!P&&Ie()},[v,P,Ie]);function ve(){var D,oe,Oe,x;let z=(D=Te.current)==null?void 0:D.getModel();L||((oe=z==null?void 0:z.original)==null||oe.dispose()),I||((Oe=z==null?void 0:z.modified)==null||Oe.dispose()),(x=Te.current)==null||x.dispose()}return aa.createElement(Md,{width:C,height:_,isEditorReady:P,loading:O,_ref:se,className:f,wrapperProps:m})}var ph=Ch;A.memo(ph);function Lh(r){let l=A.useRef();return A.useEffect(()=>{l.current=r},[r]),l.current}var _h=Lh,To=new Map;function mh({defaultValue:r,defaultLanguage:l,defaultPath:E,value:T,language:c,path:u,theme:N="light",line:L,loading:I="Loading...",options:R={},overrideServices:O={},saveViewState:d=!0,keepCurrentModel:_=!1,width:C="100%",height:f="100%",className:m,wrapperProps:j={},beforeMount:W=Fl,onMount:P=Fl,onChange:Z,onValidate:v=Fl}){let[M,Te]=A.useState(!1),[B,se]=A.useState(!0),w=A.useRef(null),$=A.useRef(null),J=A.useRef(null),Ce=A.useRef(P),Ie=A.useRef(W),ve=A.useRef(),z=A.useRef(T),D=_h(u),oe=A.useRef(!1),Oe=A.useRef(!1);Pd(()=>{let p=mc.init();return p.then(H=>(w.current=H)&&se(!1)).catch(H=>(H==null?void 0:H.type)!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>$.current?y():p.cancel()}),Bn(()=>{var H,ne,ae,F;let p=Us(w.current,r||T||"",l||c||"",u||E||"");p!==((H=$.current)==null?void 0:H.getModel())&&(d&&To.set(D,(ne=$.current)==null?void 0:ne.saveViewState()),(ae=$.current)==null||ae.setModel(p),d&&((F=$.current)==null||F.restoreViewState(To.get(u))))},[u],M),Bn(()=>{var p;(p=$.current)==null||p.updateOptions(R)},[R],M),Bn(()=>{!$.current||T===void 0||($.current.getOption(w.current.editor.EditorOption.readOnly)?$.current.setValue(T):T!==$.current.getValue()&&(Oe.current=!0,$.current.executeEdits("",[{range:$.current.getModel().getFullModelRange(),text:T,forceMoveMarkers:!0}]),$.current.pushUndoStop(),Oe.current=!1))},[T],M),Bn(()=>{var H,ne;let p=(H=$.current)==null?void 0:H.getModel();p&&c&&((ne=w.current)==null||ne.editor.setModelLanguage(p,c))},[c],M),Bn(()=>{var p;L!==void 0&&((p=$.current)==null||p.revealLine(L))},[L],M),Bn(()=>{var p;(p=w.current)==null||p.editor.setTheme(N)},[N],M);let x=A.useCallback(()=>{var p;if(!(!J.current||!w.current)&&!oe.current){Ie.current(w.current);let H=u||E,ne=Us(w.current,T||r||"",l||c||"",H||"");$.current=(p=w.current)==null?void 0:p.editor.create(J.current,{model:ne,automaticLayout:!0,...R},O),d&&$.current.restoreViewState(To.get(H)),w.current.editor.setTheme(N),L!==void 0&&$.current.revealLine(L),Te(!0),oe.current=!0}},[r,l,E,T,c,u,R,O,d,N,L]);A.useEffect(()=>{M&&Ce.current($.current,w.current)},[M]),A.useEffect(()=>{!B&&!M&&x()},[B,M,x]),z.current=T,A.useEffect(()=>{var p,H;M&&Z&&((p=ve.current)==null||p.dispose(),ve.current=(H=$.current)==null?void 0:H.onDidChangeModelContent(ne=>{Oe.current||Z($.current.getValue(),ne)}))},[M,Z]),A.useEffect(()=>{if(M){let p=w.current.editor.onDidChangeMarkers(H=>{var ae;let ne=(ae=$.current.getModel())==null?void 0:ae.uri;if(ne&&H.find(F=>F.path===ne.path)){let F=w.current.editor.getModelMarkers({resource:ne});v==null||v(F)}});return()=>{p==null||p.dispose()}}return()=>{}},[M,v]);function y(){var p,H;(p=ve.current)==null||p.dispose(),_?d&&To.set(u,$.current.saveViewState()):(H=$.current.getModel())==null||H.dispose(),$.current.dispose()}return aa.createElement(Md,{width:C,height:f,isEditorReady:M,loading:I,_ref:J,className:m,wrapperProps:j})}var vh=mh,xh=A.memo(vh),Dh=xh;const Vl={"havn-dark":{name:"havn Dark",description:"Harbour Teal on deep ocean",dark:!0,vars:{"--havn-bg":"#0B0E14","--havn-bg-secondary":"#121620","--havn-bg-tertiary":"#080A0F","--havn-border":"#1C2233","--havn-border-light":"#263044","--havn-text":"#D0D6E0","--havn-text-secondary":"#6B7A90","--havn-text-dim":"#3A4560","--havn-accent":"#3ECFB4","--havn-green":"#34D399","--havn-green-border":"#3ECFB4","--havn-red":"#F87171","--havn-yellow":"#FBBF24","--havn-purple":"#7C8CF5","--havn-radius":"6px","--havn-radius-lg":"10px","--havn-btn-bg":"#1C2233","--havn-btn-border":"#263044"}},"havn-light":{name:"havn Light",description:"Harbour Teal on Nordic grey",dark:!1,vars:{"--havn-bg":"#F4F6F8","--havn-bg-secondary":"#E8ECF0","--havn-bg-tertiary":"#FFFFFF","--havn-border":"#D0D7DF","--havn-border-light":"#BCC5D0","--havn-text":"#0B0E14","--havn-text-secondary":"#5A6878","--havn-text-dim":"#94A0B0","--havn-accent":"#2BA88E","--havn-green":"#22A06B","--havn-green-border":"#2BA88E","--havn-red":"#DC2626","--havn-yellow":"#B45309","--havn-purple":"#5B6AD0","--havn-radius":"6px","--havn-radius-lg":"10px","--havn-btn-bg":"#E8ECF0","--havn-btn-border":"#D0D7DF"}},"midnight-terminal":{name:"Midnight Terminal",description:"Green-on-black terminal aesthetic",dark:!0,vars:{"--havn-bg":"#0c0e14","--havn-bg-secondary":"#11131a","--havn-bg-tertiary":"#0a0c11","--havn-border":"#1a1e2e","--havn-border-light":"#252a3a","--havn-text":"#c8cdd8","--havn-text-secondary":"#636b80","--havn-text-dim":"#3a4058","--havn-accent":"#6ee7b7","--havn-green":"#34d399","--havn-green-border":"#4ade80","--havn-red":"#fb7185","--havn-yellow":"#fbbf24","--havn-purple":"#a78bfa","--havn-radius":"4px","--havn-radius-lg":"6px","--havn-btn-bg":"#1a1e2e","--havn-btn-border":"#252a3a"}},"paper-light":{name:"Paper Light",description:"Warm editorial light theme",dark:!1,vars:{"--havn-bg":"#faf8f5","--havn-bg-secondary":"#f0ece6","--havn-bg-tertiary":"#fff","--havn-border":"#ddd7cc","--havn-border-light":"#ccc5b8","--havn-text":"#2c2418","--havn-text-secondary":"#8a7e6e","--havn-text-dim":"#b8ad9c","--havn-accent":"#c45d3e","--havn-green":"#558b44","--havn-green-border":"#6aa858","--havn-red":"#c44040","--havn-yellow":"#b08825","--havn-purple":"#7c5ab8","--havn-radius":"2px","--havn-radius-lg":"4px","--havn-btn-bg":"#ebe5dc","--havn-btn-border":"#ddd7cc"}},electric:{name:"Electric",description:"Modern indigo-accented dark theme",dark:!0,vars:{"--havn-bg":"#09090b","--havn-bg-secondary":"#121216","--havn-bg-tertiary":"#0d0d10","--havn-border":"#1f1f2e","--havn-border-light":"#2a2a3e","--havn-text":"#e4e4f0","--havn-text-secondary":"#6b6b8a","--havn-text-dim":"#3d3d55","--havn-accent":"#818cf8","--havn-green":"#4ade80","--havn-green-border":"#5eead4","--havn-red":"#f87171","--havn-yellow":"#facc15","--havn-purple":"#c084fc","--havn-radius":"8px","--havn-radius-lg":"12px","--havn-btn-bg":"#1f1f2e","--havn-btn-border":"#2a2a3e"}},"nordic-frost":{name:"Nordic Frost",description:"Cool professional slate-blue light theme",dark:!1,vars:{"--havn-bg":"#e8ecf1","--havn-bg-secondary":"#dce2e9","--havn-bg-tertiary":"#f2f4f7","--havn-border":"#c4cdd8","--havn-border-light":"#b4bfcc","--havn-text":"#1e2a3a","--havn-text-secondary":"#5a6a7e","--havn-text-dim":"#94a3b8","--havn-accent":"#2563eb","--havn-green":"#16a34a","--havn-green-border":"#22c55e","--havn-red":"#dc2626","--havn-yellow":"#ca8a04","--havn-purple":"#7c3aed","--havn-radius":"6px","--havn-radius-lg":"10px","--havn-btn-bg":"#dce2e9","--havn-btn-border":"#c4cdd8"}},ember:{name:"Ember",description:"Warm dark theme with amber highlights",dark:!0,vars:{"--havn-bg":"#140e0a","--havn-bg-secondary":"#1c1410","--havn-bg-tertiary":"#110c08","--havn-border":"#2e2218","--havn-border-light":"#3d2e20","--havn-text":"#e8ddd0","--havn-text-secondary":"#8a7560","--havn-text-dim":"#4e3d2e","--havn-accent":"#f59e0b","--havn-green":"#84cc16","--havn-green-border":"#a3e635","--havn-red":"#ef4444","--havn-yellow":"#eab308","--havn-purple":"#d97706","--havn-radius":"3px","--havn-radius-lg":"5px","--havn-btn-bg":"#2e2218","--havn-btn-border":"#3d2e20"}},corporate:{name:"Corporate",description:"Deliberately vanilla, muted blue, zero personality",dark:!1,vars:{"--havn-bg":"#f5f5f5","--havn-bg-secondary":"#eaeaea","--havn-bg-tertiary":"#fff","--havn-border":"#d4d4d4","--havn-border-light":"#c0c0c0","--havn-text":"#333","--havn-text-secondary":"#777","--havn-text-dim":"#aaa","--havn-accent":"#4a7cbc","--havn-green":"#5a9a5a","--havn-green-border":"#6ab06a","--havn-red":"#c05050","--havn-yellow":"#b09030","--havn-purple":"#7868a8","--havn-radius":"4px","--havn-radius-lg":"6px","--havn-btn-bg":"#e0e0e0","--havn-btn-border":"#d4d4d4"}}},wl={"outfit-jetbrains":{name:"Outfit + JetBrains Mono",description:"Clean geometric sans with technical mono",vars:{"--havn-font":"'Outfit', -apple-system, BlinkMacSystemFont, sans-serif","--havn-font-mono":"'JetBrains Mono', monospace"}},"ibm-plex":{name:"IBM Plex Sans + Plex Mono",description:"Neutral humanist with matched mono",vars:{"--havn-font":"'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif","--havn-font-mono":"'IBM Plex Mono', 'Fira Code', monospace"}},"sora-fira":{name:"Sora + Fira Code",description:"Geometric display with ligature-rich mono",vars:{"--havn-font":"'Sora', -apple-system, BlinkMacSystemFont, sans-serif","--havn-font-mono":"'Fira Code', monospace"}},"manrope-jetbrains":{name:"Manrope + JetBrains Mono",description:"Friendly rounded sans with technical mono",vars:{"--havn-font":"'Manrope', -apple-system, BlinkMacSystemFont, sans-serif","--havn-font-mono":"'JetBrains Mono', monospace"}},"dm-sans-space":{name:"DM Sans + Space Mono",description:"Compact geometric with retro-flavored mono",vars:{"--havn-font":"'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif","--havn-font-mono":"'Space Mono', monospace"}},"crimson-jetbrains":{name:"Crimson Pro + JetBrains Mono",description:"Editorial serif with technical mono",vars:{"--havn-font":"'Crimson Pro', 'Source Serif 4', Georgia, serif","--havn-font-mono":"'JetBrains Mono', 'Fira Code', monospace"}},system:{name:"System Default",description:"Native OS fonts for maximum performance",vars:{"--havn-font":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif","--havn-font-mono":"Consolas, 'Courier New', monospace"}}},Wl="havn-dark",_o="outfit-jetbrains";function yh(r,l){const E=Vl[r]||Vl[Wl],T=wl[l]||wl[_o];return{name:E.name,description:E.description,dark:E.dark,vars:{...E.vars,...T.vars}}}const bA=Object.fromEntries(Object.entries(Vl).map(([r,l])=>[r,{...l,vars:{...l.vars,...wl[_o].vars}}])),gh=Wl;function Mh(r){return bA[r]||bA[gh]}function Ph(){return Object.keys(Vl)}function Uh(){return Object.keys(wl)}const bd=A.createContext({colorThemeId:Wl,fontThemeId:_o,setColorThemeId:()=>{},setFontThemeId:()=>{},themeId:Wl,setThemeId:()=>{}});function Gd(){return A.useContext(bd)}function bh(r,l){const E=yh(r,l),T=document.documentElement;for(const[c,u]of Object.entries(E.vars))T.style.setProperty(c,u);T.style.setProperty("color-scheme",E.dark?"dark":"light")}function Gh({children:r}){const[l,E]=A.useState(()=>{const N=localStorage.getItem("dp_theme");return localStorage.getItem("havn_color_theme")||N||Wl}),[T,c]=A.useState(()=>localStorage.getItem("havn_font_theme")||_o);A.useEffect(()=>{bh(l,T),localStorage.setItem("havn_color_theme",l),localStorage.setItem("havn_font_theme",T)},[l,T]);const u=E;return a.jsx(bd.Provider,{value:{colorThemeId:l,fontThemeId:T,setColorThemeId:E,setFontThemeId:c,themeId:l,setThemeId:u},children:r})}const Hs=new Map;let Ds=null,GA=0;async function Bh(){const r=Date.now();if(Ds&&r-GA<3e4)return Ds;try{Ds=await Ee.listTables(),GA=r}catch{Ds=Ds||[]}return Ds}async function BA(r,l){const E=`${r}.${l}`;let T=Hs.get(E);if(T!==void 0)return T;try{T=await Ee.describeTable(r,l),Hs.set(E,T)}catch{Hs.set(E,null),T=null}return T}let HA=!1;mc.init().then(r=>{if(HA)return;HA=!0;const l=/\b(?:FROM|JOIN|INNER\s+JOIN|LEFT\s+(?:OUTER\s+)?JOIN|RIGHT\s+(?:OUTER\s+)?JOIN|FULL\s+(?:OUTER\s+)?JOIN|CROSS\s+JOIN|INTO|UPDATE|TABLE)\s+(\w*)$/i,E=/\b(?:SELECT|WHERE|AND|OR|ON|USING|GROUP\s+BY|ORDER\s+BY|HAVING|SET|WHEN|THEN|ELSE|CASE|BETWEEN|AS|DISTINCT|NOT|IN|IS|LIKE|ILIKE|LIMIT|OFFSET)\s+(\w*)$/i,T=/,\s*(\w*)$/,c=/\b(\w+)\.\s*(\w*)$/;function u(N){const L=[],I=/\b(?:FROM|JOIN)\s+(\w+)\.(\w+)(?:\s+(?:AS\s+)?(\w+))?/gi;let R;for(;(R=I.exec(N))!==null;){const O=R[1],d=R[2],_=R[3]||null;L.push({schema:O,table:d,alias:_})}return L}r.languages.registerCompletionItemProvider("sql",{triggerCharacters:["."," ",","],provideCompletionItems:async(N,L)=>{const I=N.getValue(),R=N.getOffsetAt(L),O=I.substring(0,R),d=await Bh(),_=O.match(c);if(_){const m=_[1].toLowerCase(),j=(_[2]||"").toLowerCase();if(d.some(v=>v.schema.toLowerCase()===m)){const v=[];for(const M of d)M.schema.toLowerCase()===m&&M.name.toLowerCase().startsWith(j)&&v.push({label:`${M.schema}.${M.name}`,kind:r.languages.CompletionItemKind.Struct,insertText:M.name,detail:M.type||"table",range:{startLineNumber:L.lineNumber,startColumn:L.column-j.length,endLineNumber:L.lineNumber,endColumn:L.column}});return{suggestions:v}}const Z=u(I).find(v=>v.alias&&v.alias.toLowerCase()===m||!v.alias&&v.table.toLowerCase()===m);if(Z){const v=await BA(Z.schema,Z.table);if(v&&v.columns)return{suggestions:v.columns.filter(M=>M.name.toLowerCase().startsWith(j)).map(M=>({label:M.name,kind:r.languages.CompletionItemKind.Field,insertText:M.name,detail:`${Z.schema}.${Z.table} — ${M.type}`,range:{startLineNumber:L.lineNumber,startColumn:L.column-j.length,endLineNumber:L.lineNumber,endColumn:L.column}}))}}return{suggestions:[]}}const C=O.match(l);if(C){const m=(C[1]||"").toLowerCase(),j=[];for(const W of d){const P=`${W.schema}.${W.name}`;(W.schema.toLowerCase().startsWith(m)||W.name.toLowerCase().startsWith(m)||P.toLowerCase().startsWith(m))&&j.push({label:P,kind:r.languages.CompletionItemKind.Struct,insertText:P,detail:W.type||"table",range:{startLineNumber:L.lineNumber,startColumn:L.column-m.length,endLineNumber:L.lineNumber,endColumn:L.column}})}return{suggestions:j}}const f=O.match(E)||O.match(T);if(f){const m=(f[1]||"").toLowerCase(),j=u(I);if(j.length===0)return{suggestions:[]};const W=[];for(const v of j){const M=await BA(v.schema,v.table);if(M&&M.columns)for(const Te of M.columns)W.push({...Te,source:`${v.schema}.${v.table}`})}const P=new Map;for(const v of W){const M=v.name.toLowerCase();P.has(M)?P.get(M).ambiguous=!0:P.set(M,{...v,ambiguous:!1})}const Z=[];for(const[,v]of P)v.name.toLowerCase().startsWith(m)&&Z.push({label:v.name,kind:r.languages.CompletionItemKind.Field,insertText:v.name,detail:`${v.type} — ${v.source}`,range:{startLineNumber:L.lineNumber,startColumn:L.column-m.length,endLineNumber:L.lineNumber,endColumn:L.column}});return{suggestions:Z}}return{suggestions:[]}}}),r.languages.registerHoverProvider("sql",{provideHover:async(N,L)=>{const I=N.getLineContent(L.lineNumber),R=N.getWordAtPosition(L);if(!R)return null;let O=null,d=null;const C=I.substring(0,R.startColumn-1).match(/(\w+)\.\s*$/);if(C&&(O=C[1],d=R.word),!O){const P=I.substring(R.endColumn-1).match(/^\s*\.(\w+)/);P&&(O=R.word,d=P[1])}if(!O||!d)return null;const f=`${O}.${d}`;let m=Hs.get(f);if(m===void 0)try{m=await Ee.describeTable(O,d),Hs.set(f,m)}catch{Hs.set(f,null),m=null}if(!m||!m.columns||m.columns.length===0)return{range:new r.Range(L.lineNumber,R.startColumn,L.lineNumber,R.endColumn),contents:[{value:`*${O}.${d}* — table not found in warehouse`}]};const j=[`**${O}.${d}** — ${m.columns.length} columns`,""];for(const W of m.columns)j.push(`- \`${W.name}\` *${W.type}*`);return{range:new r.Range(L.lineNumber,R.startColumn,L.lineNumber,R.endColumn),contents:[{value:j.join(`
`)}]}}})});function Hh({content:r,language:l,onChange:E,activeFile:T,onMount:c,goToLine:u,onFormat:N,onPreview:L}){const{themeId:I}=Gd(),O=Mh(I).dark?"vs-dark":"vs",d=A.useRef(null),_=A.useRef(N);_.current=N;const C=A.useRef(L);C.current=L;function f(m,j){d.current=m,c&&c(m),m.addAction({id:"havn-format-sql",label:"Format SQL (havn lint --fix)",keybindings:[j.KeyMod.CtrlCmd|j.KeyMod.Shift|j.KeyCode.KeyF],precondition:null,keybindingContext:null,run:()=>{_.current&&_.current()}}),m.addAction({id:"havn-preview-sql",label:"Preview SQL results",keybindings:[j.KeyMod.CtrlCmd|j.KeyCode.Enter],precondition:null,keybindingContext:null,run:()=>{C.current&&C.current()}})}return A.useEffect(()=>{if(!u||!d.current)return;const{line:m,col:j}=u;d.current.revealLineInCenter(m),d.current.setPosition({lineNumber:m,column:j||1}),d.current.focus()},[u]),T?a.jsx(Dh,{height:"100%",language:l,value:r,onChange:m=>E(m||""),theme:O,onMount:(m,j)=>f(m,j),options:{minimap:{enabled:!1},hover:{above:!1},fontSize:13,lineNumbers:"on",renderLineHighlight:"all",scrollBeyondLastLine:!1,wordWrap:"on",padding:{top:8},tabSize:4,insertSpaces:!0,smoothScrolling:!0,cursorBlinking:"smooth",cursorSmoothCaretAnimation:"on",fontFamily:"var(--havn-font-mono)",quickSuggestions:!0,suggestOnTriggerCharacters:!0}}):a.jsxs("div",{style:br.empty,children:[a.jsx("div",{style:br.emptyIcon,children:a.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--havn-text-dim)",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),a.jsx("polyline",{points:"14,2 14,8 20,8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),a.jsx("polyline",{points:"10,9 9,9 8,9"})]})}),a.jsx("p",{style:br.emptyText,children:"Select a file to edit"}),a.jsxs("p",{style:br.emptyHint,children:["SQL files in ",a.jsx("code",{style:br.code,children:"transform/"})," are transformation models.",a.jsx("br",{}),"Python files in ",a.jsx("code",{style:br.code,children:"ingest/"})," and ",a.jsx("code",{style:br.code,children:"export/"})," are data scripts."]})]})}const br={empty:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--havn-text-secondary)",gap:"8px"},emptyIcon:{marginBottom:"4px",opacity:.6},emptyText:{fontSize:"16px",marginBottom:"4px",fontWeight:500},emptyHint:{fontSize:"13px",textAlign:"center",lineHeight:"1.7",color:"var(--havn-text-dim)"},code:{background:"var(--havn-btn-bg)",padding:"1px 5px",borderRadius:"3px",fontSize:"12px",fontFamily:"var(--havn-font-mono)"}},Fh=/^([\w./\\-]+\.\w+):(\d+):(\d+)/,Yh=/^([\w/\\-]+\.[\w./\\-]+): /;function jh(r,l,E){if(!E)return a.jsx("span",{style:l,children:r});const T=r.match(Fh);if(T){const[R,O,d,_]=T,C=parseInt(d,10),f=parseInt(_,10),m=r.slice(R.length);return a.jsxs("span",{style:l,children:[a.jsx("span",{style:bn.fileLink,onClick:()=>E(O,C,f),onMouseEnter:j=>{j.currentTarget.style.color="var(--havn-accent)",j.currentTarget.style.textDecoration="underline"},onMouseLeave:j=>{j.currentTarget.style.color="",j.currentTarget.style.textDecoration=""},title:`Open ${O} at line ${C}`,children:R}),m]})}const c=r.match(Yh);if(c){const R=c[1],O=r.slice(R.length);return a.jsxs("span",{style:l,children:[a.jsx("span",{style:bn.fileLink,onClick:()=>E(R,1,1),onMouseEnter:d=>{d.currentTarget.style.color="var(--havn-accent)",d.currentTarget.style.textDecoration="underline"},onMouseLeave:d=>{d.currentTarget.style.color="",d.currentTarget.style.textDecoration=""},title:`Open ${R}`,children:R}),O]})}const u=/([\w-]+[/\\][\w./\\-]+\.\w+)/g,N=[];let L=0,I;for(;(I=u.exec(r))!==null;)I.index>L&&N.push({text:r.slice(L,I.index)}),N.push({text:I[1],isLink:!0}),L=I.index+I[0].length;return N.length>0?(L<r.length&&N.push({text:r.slice(L)}),a.jsx("span",{style:l,children:N.map((R,O)=>R.isLink?a.jsx("span",{style:bn.fileLink,onClick:()=>E(R.text,1,1),onMouseEnter:d=>{d.currentTarget.style.color="var(--havn-accent)",d.currentTarget.style.textDecoration="underline"},onMouseLeave:d=>{d.currentTarget.style.color="",d.currentTarget.style.textDecoration=""},title:`Open ${R.text}`,children:R.text},O):R.text)})):a.jsx("span",{style:l,children:r})}function Vh({output:r,onClear:l,height:E=180,onOpenFile:T}){const c=A.useRef(null);return A.useEffect(()=>{var u;(u=c.current)==null||u.scrollIntoView({behavior:"smooth"})},[r]),a.jsxs("div",{style:{...bn.container,height:E},children:[a.jsxs("div",{style:bn.header,children:[a.jsx("span",{style:bn.headerTitle,children:"Output"}),a.jsx("span",{style:bn.count,children:r.length>0?`${r.length} entries`:""}),a.jsx("button",{onClick:l,style:bn.clearBtn,children:"Clear"})]}),a.jsxs("div",{style:bn.log,children:[r.length===0&&a.jsx("div",{style:bn.placeholder,children:"Run a script or transform to see output here."}),r.map((u,N)=>a.jsxs("div",{style:bn.entry,children:[a.jsx("span",{style:bn.ts,children:u.ts}),a.jsx("span",{style:{...bn.indicator,background:u.type==="error"?"var(--havn-red)":u.type==="warn"?"var(--havn-yellow)":(u.type==="success","var(--havn-accent)")}}),jh(u.message,FA[u.type]||FA.info,T)]},N)),a.jsx("div",{ref:c})]})]})}const FA={info:{color:"var(--havn-text)"},success:{color:"var(--havn-accent)"},error:{color:"var(--havn-red)"},warn:{color:"var(--havn-yellow)"},log:{color:"var(--havn-text-secondary)"}},bn={container:{borderTop:"1px solid var(--havn-border)",display:"flex",flexDirection:"column",background:"var(--havn-bg-tertiary)"},header:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 12px",fontSize:"12px",fontWeight:"600",color:"var(--havn-text-secondary)",borderBottom:"1px solid var(--havn-border)"},headerTitle:{fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},count:{fontSize:"10px",color:"var(--havn-text-dim)",flex:1},clearBtn:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px"},log:{flex:1,overflow:"auto",padding:"4px 12px",fontFamily:"var(--havn-font-mono)",fontSize:"12px",lineHeight:"1.7"},placeholder:{color:"var(--havn-text-dim)",fontStyle:"italic",padding:"8px 0",fontSize:"12px"},entry:{display:"flex",gap:"8px",alignItems:"baseline"},ts:{color:"var(--havn-text-dim)",flexShrink:0,fontSize:"11px"},indicator:{width:"4px",height:"4px",borderRadius:"50%",flexShrink:0,marginTop:"2px"},fileLink:{cursor:"pointer",transition:"color 0.15s"}},Q=r=>r.flatMap(wh),wh=r=>No(Xh(r)).map(Wh),Wh=r=>r.replace(/ +/g," ").trim(),Xh=r=>({type:"mandatory_block",items:vc(r,0)[0]}),vc=(r,l,E)=>{const T=[];for(;r[l];){const[c,u]=Kh(r,l);if(T.push(c),l=u,r[l]==="|")l++;else if(r[l]==="}"||r[l]==="]"){if(E!==r[l])throw new Error(`Unbalanced parenthesis in: ${r}`);return l++,[T,l]}else if(l===r.length){if(E)throw new Error(`Unbalanced parenthesis in: ${r}`);return[T,l]}else throw new Error(`Unexpected "${r[l]}"`)}return[T,l]},Kh=(r,l)=>{const E=[];for(;;){const[T,c]=zh(r,l);if(T)E.push(T),l=c;else break}return E.length===1?[E[0],l]:[{type:"concatenation",items:E},l]},zh=(r,l)=>{if(r[l]==="{")return kh(r,l+1);if(r[l]==="[")return $h(r,l+1);{let E="";for(;r[l]&&/[A-Za-z0-9_ ]/.test(r[l]);)E+=r[l],l++;return[E,l]}},kh=(r,l)=>{const[E,T]=vc(r,l,"}");return[{type:"mandatory_block",items:E},T]},$h=(r,l)=>{const[E,T]=vc(r,l,"]");return[{type:"optional_block",items:E},T]},No=r=>{if(typeof r=="string")return[r];if(r.type==="concatenation")return r.items.map(No).reduce(Jh,[""]);if(r.type==="mandatory_block")return r.items.flatMap(No);if(r.type==="optional_block")return["",...r.items.flatMap(No)];throw new Error(`Unknown node type: ${r}`)},Jh=(r,l)=>{const E=[];for(const T of r)for(const c of l)E.push(T+c);return E};var Ae;(function(r){r.QUOTED_IDENTIFIER="QUOTED_IDENTIFIER",r.IDENTIFIER="IDENTIFIER",r.STRING="STRING",r.VARIABLE="VARIABLE",r.RESERVED_DATA_TYPE="RESERVED_DATA_TYPE",r.RESERVED_PARAMETERIZED_DATA_TYPE="RESERVED_PARAMETERIZED_DATA_TYPE",r.RESERVED_KEYWORD="RESERVED_KEYWORD",r.RESERVED_FUNCTION_NAME="RESERVED_FUNCTION_NAME",r.RESERVED_KEYWORD_PHRASE="RESERVED_KEYWORD_PHRASE",r.RESERVED_DATA_TYPE_PHRASE="RESERVED_DATA_TYPE_PHRASE",r.RESERVED_SET_OPERATION="RESERVED_SET_OPERATION",r.RESERVED_CLAUSE="RESERVED_CLAUSE",r.RESERVED_SELECT="RESERVED_SELECT",r.RESERVED_JOIN="RESERVED_JOIN",r.ARRAY_IDENTIFIER="ARRAY_IDENTIFIER",r.ARRAY_KEYWORD="ARRAY_KEYWORD",r.CASE="CASE",r.END="END",r.WHEN="WHEN",r.ELSE="ELSE",r.THEN="THEN",r.LIMIT="LIMIT",r.BETWEEN="BETWEEN",r.AND="AND",r.OR="OR",r.XOR="XOR",r.OPERATOR="OPERATOR",r.COMMA="COMMA",r.ASTERISK="ASTERISK",r.PROPERTY_ACCESS_OPERATOR="PROPERTY_ACCESS_OPERATOR",r.OPEN_PAREN="OPEN_PAREN",r.CLOSE_PAREN="CLOSE_PAREN",r.LINE_COMMENT="LINE_COMMENT",r.BLOCK_COMMENT="BLOCK_COMMENT",r.DISABLE_COMMENT="DISABLE_COMMENT",r.NUMBER="NUMBER",r.NAMED_PARAMETER="NAMED_PARAMETER",r.QUOTED_PARAMETER="QUOTED_PARAMETER",r.NUMBERED_PARAMETER="NUMBERED_PARAMETER",r.POSITIONAL_PARAMETER="POSITIONAL_PARAMETER",r.CUSTOM_PARAMETER="CUSTOM_PARAMETER",r.DELIMITER="DELIMITER",r.EOF="EOF"})(Ae=Ae||(Ae={}));const Bd=r=>({type:Ae.EOF,raw:"«EOF»",text:"«EOF»",start:r}),Rr=Bd(1/0),ys=r=>l=>l.type===r.type&&l.text===r.text,ur={ARRAY:ys({text:"ARRAY",type:Ae.RESERVED_DATA_TYPE}),BY:ys({text:"BY",type:Ae.RESERVED_KEYWORD}),SET:ys({text:"SET",type:Ae.RESERVED_CLAUSE}),STRUCT:ys({text:"STRUCT",type:Ae.RESERVED_DATA_TYPE}),WINDOW:ys({text:"WINDOW",type:Ae.RESERVED_CLAUSE}),VALUES:ys({text:"VALUES",type:Ae.RESERVED_CLAUSE})},Hd=r=>r===Ae.RESERVED_DATA_TYPE||r===Ae.RESERVED_KEYWORD||r===Ae.RESERVED_FUNCTION_NAME||r===Ae.RESERVED_KEYWORD_PHRASE||r===Ae.RESERVED_DATA_TYPE_PHRASE||r===Ae.RESERVED_CLAUSE||r===Ae.RESERVED_SELECT||r===Ae.RESERVED_SET_OPERATION||r===Ae.RESERVED_JOIN||r===Ae.ARRAY_KEYWORD||r===Ae.CASE||r===Ae.END||r===Ae.WHEN||r===Ae.ELSE||r===Ae.THEN||r===Ae.LIMIT||r===Ae.BETWEEN||r===Ae.AND||r===Ae.OR||r===Ae.XOR,qh=r=>r===Ae.AND||r===Ae.OR||r===Ae.XOR,Qh=["KEYS.NEW_KEYSET","KEYS.ADD_KEY_FROM_RAW_BYTES","AEAD.DECRYPT_BYTES","AEAD.DECRYPT_STRING","AEAD.ENCRYPT","KEYS.KEYSET_CHAIN","KEYS.KEYSET_FROM_JSON","KEYS.KEYSET_TO_JSON","KEYS.ROTATE_KEYSET","KEYS.KEYSET_LENGTH","ANY_VALUE","ARRAY_AGG","AVG","CORR","COUNT","COUNTIF","COVAR_POP","COVAR_SAMP","MAX","MIN","ST_CLUSTERDBSCAN","STDDEV_POP","STDDEV_SAMP","STRING_AGG","SUM","VAR_POP","VAR_SAMP","ANY_VALUE","ARRAY_AGG","ARRAY_CONCAT_AGG","AVG","BIT_AND","BIT_OR","BIT_XOR","COUNT","COUNTIF","LOGICAL_AND","LOGICAL_OR","MAX","MIN","STRING_AGG","SUM","APPROX_COUNT_DISTINCT","APPROX_QUANTILES","APPROX_TOP_COUNT","APPROX_TOP_SUM","ARRAY_CONCAT","ARRAY_LENGTH","ARRAY_TO_STRING","GENERATE_ARRAY","GENERATE_DATE_ARRAY","GENERATE_TIMESTAMP_ARRAY","ARRAY_REVERSE","OFFSET","SAFE_OFFSET","ORDINAL","SAFE_ORDINAL","BIT_COUNT","PARSE_BIGNUMERIC","PARSE_NUMERIC","SAFE_CAST","CURRENT_DATE","EXTRACT","DATE","DATE_ADD","DATE_SUB","DATE_DIFF","DATE_TRUNC","DATE_FROM_UNIX_DATE","FORMAT_DATE","LAST_DAY","PARSE_DATE","UNIX_DATE","CURRENT_DATETIME","DATETIME","EXTRACT","DATETIME_ADD","DATETIME_SUB","DATETIME_DIFF","DATETIME_TRUNC","FORMAT_DATETIME","LAST_DAY","PARSE_DATETIME","ERROR","EXTERNAL_QUERY","S2_CELLIDFROMPOINT","S2_COVERINGCELLIDS","ST_ANGLE","ST_AREA","ST_ASBINARY","ST_ASGEOJSON","ST_ASTEXT","ST_AZIMUTH","ST_BOUNDARY","ST_BOUNDINGBOX","ST_BUFFER","ST_BUFFERWITHTOLERANCE","ST_CENTROID","ST_CENTROID_AGG","ST_CLOSESTPOINT","ST_CLUSTERDBSCAN","ST_CONTAINS","ST_CONVEXHULL","ST_COVEREDBY","ST_COVERS","ST_DIFFERENCE","ST_DIMENSION","ST_DISJOINT","ST_DISTANCE","ST_DUMP","ST_DWITHIN","ST_ENDPOINT","ST_EQUALS","ST_EXTENT","ST_EXTERIORRING","ST_GEOGFROM","ST_GEOGFROMGEOJSON","ST_GEOGFROMTEXT","ST_GEOGFROMWKB","ST_GEOGPOINT","ST_GEOGPOINTFROMGEOHASH","ST_GEOHASH","ST_GEOMETRYTYPE","ST_INTERIORRINGS","ST_INTERSECTION","ST_INTERSECTS","ST_INTERSECTSBOX","ST_ISCOLLECTION","ST_ISEMPTY","ST_LENGTH","ST_MAKELINE","ST_MAKEPOLYGON","ST_MAKEPOLYGONORIENTED","ST_MAXDISTANCE","ST_NPOINTS","ST_NUMGEOMETRIES","ST_NUMPOINTS","ST_PERIMETER","ST_POINTN","ST_SIMPLIFY","ST_SNAPTOGRID","ST_STARTPOINT","ST_TOUCHES","ST_UNION","ST_UNION_AGG","ST_WITHIN","ST_X","ST_Y","FARM_FINGERPRINT","MD5","SHA1","SHA256","SHA512","HLL_COUNT.INIT","HLL_COUNT.MERGE","HLL_COUNT.MERGE_PARTIAL","HLL_COUNT.EXTRACT","MAKE_INTERVAL","EXTRACT","JUSTIFY_DAYS","JUSTIFY_HOURS","JUSTIFY_INTERVAL","JSON_EXTRACT","JSON_QUERY","JSON_EXTRACT_SCALAR","JSON_VALUE","JSON_EXTRACT_ARRAY","JSON_QUERY_ARRAY","JSON_EXTRACT_STRING_ARRAY","JSON_VALUE_ARRAY","TO_JSON_STRING","ABS","SIGN","IS_INF","IS_NAN","IEEE_DIVIDE","RAND","SQRT","POW","POWER","EXP","LN","LOG","LOG10","GREATEST","LEAST","DIV","SAFE_DIVIDE","SAFE_MULTIPLY","SAFE_NEGATE","SAFE_ADD","SAFE_SUBTRACT","MOD","ROUND","TRUNC","CEIL","CEILING","FLOOR","COS","COSH","ACOS","ACOSH","SIN","SINH","ASIN","ASINH","TAN","TANH","ATAN","ATANH","ATAN2","RANGE_BUCKET","FIRST_VALUE","LAST_VALUE","NTH_VALUE","LEAD","LAG","PERCENTILE_CONT","PERCENTILE_DISC","NET.IP_FROM_STRING","NET.SAFE_IP_FROM_STRING","NET.IP_TO_STRING","NET.IP_NET_MASK","NET.IP_TRUNC","NET.IPV4_FROM_INT64","NET.IPV4_TO_INT64","NET.HOST","NET.PUBLIC_SUFFIX","NET.REG_DOMAIN","RANK","DENSE_RANK","PERCENT_RANK","CUME_DIST","NTILE","ROW_NUMBER","SESSION_USER","CORR","COVAR_POP","COVAR_SAMP","STDDEV_POP","STDDEV_SAMP","STDDEV","VAR_POP","VAR_SAMP","VARIANCE","ASCII","BYTE_LENGTH","CHAR_LENGTH","CHARACTER_LENGTH","CHR","CODE_POINTS_TO_BYTES","CODE_POINTS_TO_STRING","CONCAT","CONTAINS_SUBSTR","ENDS_WITH","FORMAT","FROM_BASE32","FROM_BASE64","FROM_HEX","INITCAP","INSTR","LEFT","LENGTH","LPAD","LOWER","LTRIM","NORMALIZE","NORMALIZE_AND_CASEFOLD","OCTET_LENGTH","REGEXP_CONTAINS","REGEXP_EXTRACT","REGEXP_EXTRACT_ALL","REGEXP_INSTR","REGEXP_REPLACE","REGEXP_SUBSTR","REPLACE","REPEAT","REVERSE","RIGHT","RPAD","RTRIM","SAFE_CONVERT_BYTES_TO_STRING","SOUNDEX","SPLIT","STARTS_WITH","STRPOS","SUBSTR","SUBSTRING","TO_BASE32","TO_BASE64","TO_CODE_POINTS","TO_HEX","TRANSLATE","TRIM","UNICODE","UPPER","CURRENT_TIME","TIME","EXTRACT","TIME_ADD","TIME_SUB","TIME_DIFF","TIME_TRUNC","FORMAT_TIME","PARSE_TIME","CURRENT_TIMESTAMP","EXTRACT","STRING","TIMESTAMP","TIMESTAMP_ADD","TIMESTAMP_SUB","TIMESTAMP_DIFF","TIMESTAMP_TRUNC","FORMAT_TIMESTAMP","PARSE_TIMESTAMP","TIMESTAMP_SECONDS","TIMESTAMP_MILLIS","TIMESTAMP_MICROS","UNIX_SECONDS","UNIX_MILLIS","UNIX_MICROS","GENERATE_UUID","COALESCE","IF","IFNULL","NULLIF","AVG","BIT_AND","BIT_OR","BIT_XOR","CORR","COUNT","COVAR_POP","COVAR_SAMP","EXACT_COUNT_DISTINCT","FIRST","GROUP_CONCAT","GROUP_CONCAT_UNQUOTED","LAST","MAX","MIN","NEST","NTH","QUANTILES","STDDEV","STDDEV_POP","STDDEV_SAMP","SUM","TOP","UNIQUE","VARIANCE","VAR_POP","VAR_SAMP","BIT_COUNT","BOOLEAN","BYTES","CAST","FLOAT","HEX_STRING","INTEGER","STRING","COALESCE","GREATEST","IFNULL","IS_INF","IS_NAN","IS_EXPLICITLY_DEFINED","LEAST","NVL","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATE","DATE_ADD","DATEDIFF","DAY","DAYOFWEEK","DAYOFYEAR","FORMAT_UTC_USEC","HOUR","MINUTE","MONTH","MSEC_TO_TIMESTAMP","NOW","PARSE_UTC_USEC","QUARTER","SEC_TO_TIMESTAMP","SECOND","STRFTIME_UTC_USEC","TIME","TIMESTAMP","TIMESTAMP_TO_MSEC","TIMESTAMP_TO_SEC","TIMESTAMP_TO_USEC","USEC_TO_TIMESTAMP","UTC_USEC_TO_DAY","UTC_USEC_TO_HOUR","UTC_USEC_TO_MONTH","UTC_USEC_TO_WEEK","UTC_USEC_TO_YEAR","WEEK","YEAR","FORMAT_IP","PARSE_IP","FORMAT_PACKED_IP","PARSE_PACKED_IP","JSON_EXTRACT","JSON_EXTRACT_SCALAR","ABS","ACOS","ACOSH","ASIN","ASINH","ATAN","ATANH","ATAN2","CEIL","COS","COSH","DEGREES","EXP","FLOOR","LN","LOG","LOG2","LOG10","PI","POW","RADIANS","RAND","ROUND","SIN","SINH","SQRT","TAN","TANH","REGEXP_MATCH","REGEXP_EXTRACT","REGEXP_REPLACE","CONCAT","INSTR","LEFT","LENGTH","LOWER","LPAD","LTRIM","REPLACE","RIGHT","RPAD","RTRIM","SPLIT","SUBSTR","UPPER","TABLE_DATE_RANGE","TABLE_DATE_RANGE_STRICT","TABLE_QUERY","HOST","DOMAIN","TLD","AVG","COUNT","MAX","MIN","STDDEV","SUM","CUME_DIST","DENSE_RANK","FIRST_VALUE","LAG","LAST_VALUE","LEAD","NTH_VALUE","NTILE","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","RANK","RATIO_TO_REPORT","ROW_NUMBER","CURRENT_USER","EVERY","FROM_BASE64","HASH","FARM_FINGERPRINT","IF","POSITION","SHA1","SOME","TO_BASE64","BQ.JOBS.CANCEL","BQ.REFRESH_MATERIALIZED_VIEW","OPTIONS","PIVOT","UNPIVOT"],Zh=["ALL","AND","ANY","AS","ASC","ASSERT_ROWS_MODIFIED","AT","BETWEEN","BY","CASE","CAST","COLLATE","CONTAINS","CREATE","CROSS","CUBE","CURRENT","DEFAULT","DEFINE","DESC","DISTINCT","ELSE","END","ENUM","ESCAPE","EXCEPT","EXCLUDE","EXISTS","EXTRACT","FALSE","FETCH","FOLLOWING","FOR","FROM","FULL","GROUP","GROUPING","GROUPS","HASH","HAVING","IF","IGNORE","IN","INNER","INTERSECT","INTO","IS","JOIN","LATERAL","LEFT","LIMIT","LOOKUP","MERGE","NATURAL","NEW","NO","NOT","NULL","NULLS","OF","ON","OR","ORDER","OUTER","OVER","PARTITION","PRECEDING","PROTO","RANGE","RECURSIVE","RESPECT","RIGHT","ROLLUP","ROWS","SELECT","SET","SOME","TABLE","TABLESAMPLE","THEN","TO","TREAT","TRUE","UNBOUNDED","UNION","UNNEST","USING","WHEN","WHERE","WINDOW","WITH","WITHIN","SAFE","LIKE","COPY","CLONE","IN","OUT","INOUT","RETURNS","LANGUAGE","CASCADE","RESTRICT","DETERMINISTIC"],ef=["ARRAY","BOOL","BYTES","DATE","DATETIME","GEOGRAPHY","INTERVAL","INT64","INT","SMALLINT","INTEGER","BIGINT","TINYINT","BYTEINT","NUMERIC","DECIMAL","BIGNUMERIC","BIGDECIMAL","FLOAT64","STRING","STRUCT","TIME","TIMEZONE"],tf=Q(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]),nf=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","QUALIFY","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","OMIT RECORD IF","INSERT [INTO]","VALUES","SET","MERGE [INTO]","WHEN [NOT] MATCHED [BY SOURCE | BY TARGET] [THEN]","UPDATE SET","CLUSTER BY","FOR SYSTEM_TIME AS OF","WITH CONNECTION","WITH PARTITION COLUMNS","REMOTE WITH CONNECTION"]),YA=Q(["CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"]),zT=Q(["CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]","UPDATE","DELETE [FROM]","DROP [SNAPSHOT | EXTERNAL] TABLE [IF EXISTS]","ALTER TABLE [IF EXISTS]","ADD COLUMN [IF NOT EXISTS]","DROP COLUMN [IF EXISTS]","RENAME TO","ALTER COLUMN [IF EXISTS]","SET DEFAULT COLLATE","SET OPTIONS","DROP NOT NULL","SET DATA TYPE","ALTER SCHEMA [IF EXISTS]","ALTER [MATERIALIZED] VIEW [IF EXISTS]","ALTER BI_CAPACITY","TRUNCATE TABLE","CREATE SCHEMA [IF NOT EXISTS]","DEFAULT COLLATE","CREATE [OR REPLACE] [TEMP|TEMPORARY|TABLE] FUNCTION [IF NOT EXISTS]","CREATE [OR REPLACE] PROCEDURE [IF NOT EXISTS]","CREATE [OR REPLACE] ROW ACCESS POLICY [IF NOT EXISTS]","GRANT TO","FILTER USING","CREATE CAPACITY","AS JSON","CREATE RESERVATION","CREATE ASSIGNMENT","CREATE SEARCH INDEX [IF NOT EXISTS]","DROP SCHEMA [IF EXISTS]","DROP [MATERIALIZED] VIEW [IF EXISTS]","DROP [TABLE] FUNCTION [IF EXISTS]","DROP PROCEDURE [IF EXISTS]","DROP ROW ACCESS POLICY","DROP ALL ROW ACCESS POLICIES","DROP CAPACITY [IF EXISTS]","DROP RESERVATION [IF EXISTS]","DROP ASSIGNMENT [IF EXISTS]","DROP SEARCH INDEX [IF EXISTS]","DROP [IF EXISTS]","GRANT","REVOKE","DECLARE","EXECUTE IMMEDIATE","LOOP","END LOOP","REPEAT","END REPEAT","WHILE","END WHILE","BREAK","LEAVE","CONTINUE","ITERATE","FOR","END FOR","BEGIN","BEGIN TRANSACTION","COMMIT TRANSACTION","ROLLBACK TRANSACTION","RAISE","RETURN","CALL","ASSERT","EXPORT DATA"]),af=Q(["UNION {ALL | DISTINCT}","EXCEPT DISTINCT","INTERSECT DISTINCT"]),rf=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN"]),sf=Q(["TABLESAMPLE SYSTEM","ANY TYPE","ALL COLUMNS","NOT DETERMINISTIC","{ROWS | RANGE} BETWEEN","IS [NOT] DISTINCT FROM"]),lf=Q([]),of={name:"bigquery",tokenizerOptions:{reservedSelect:tf,reservedClauses:[...nf,...zT,...YA],reservedSetOperations:af,reservedJoins:rf,reservedKeywordPhrases:sf,reservedDataTypePhrases:lf,reservedKeywords:Zh,reservedDataTypes:ef,reservedFunctionNames:Qh,extraParens:["[]"],stringTypes:[{quote:'""".."""',prefixes:["R","B","RB","BR"]},{quote:"'''..'''",prefixes:["R","B","RB","BR"]},'""-bs',"''-bs",{quote:'""-raw',prefixes:["R","B","RB","BR"],requirePrefix:!0},{quote:"''-raw",prefixes:["R","B","RB","BR"],requirePrefix:!0}],identTypes:["``"],identChars:{dashes:!0},paramTypes:{positional:!0,named:["@"],quoted:["@"]},variableTypes:[{regex:String.raw`@@\w+`}],lineCommentTypes:["--","#"],operators:["&","|","^","~",">>","<<","||","=>"],postProcess:Ef},formatOptions:{onelineClauses:[...YA,...zT],tabularOnelineClauses:zT}};function Ef(r){return Tf(cf(r))}function Tf(r){let l=Rr;return r.map(E=>E.text==="OFFSET"&&l.text==="["?(l=E,Object.assign(Object.assign({},E),{type:Ae.RESERVED_FUNCTION_NAME})):(l=E,E))}function cf(r){var l;const E=[];for(let T=0;T<r.length;T++){const c=r[T];if((ur.ARRAY(c)||ur.STRUCT(c))&&((l=r[T+1])===null||l===void 0?void 0:l.text)==="<"){const u=Sf(r,T+1),N=r.slice(T,u+1);E.push({type:Ae.IDENTIFIER,raw:N.map(jA("raw")).join(""),text:N.map(jA("text")).join(""),start:c.start}),T=u}else E.push(c)}return E}const jA=r=>l=>l.type===Ae.IDENTIFIER||l.type===Ae.COMMA?l[r]+" ":l[r];function Sf(r,l){let E=0;for(let T=l;T<r.length;T++){const c=r[T];if(c.text==="<"?E++:c.text===">"?E--:c.text===">>"&&(E-=2),E===0)return T}return r.length-1}const Rf=["BIT_AND","BIT_OR","BIT_XOR","BLAKE3","CAST","CHARACTER_LENGTH","CHAR_LENGTH","COVAR_POP","COVAR_SAMP","CRC32","CRC32IEEE","CRC64","DATE","DATE_DIFF","DATE_FORMAT","DATE_TRUNC","DAY","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","FORMAT_BYTES","FQDN","FROM_BASE64","FROM_DAYS","FROM_UNIXTIME","HOUR","INET6_ATON","INET6_NTOA","INET_ATON","INET_NTOA","IPv4CIDRToRange","IPv4NumToString","IPv4NumToStringClassC","IPv4StringToNum","IPv4StringToNumOrDefault","IPv4StringToNumOrNull","IPv4ToIPv6","IPv6CIDRToRange","IPv6NumToString","IPv6StringToNum","IPv6StringToNumOrDefault","IPv6StringToNumOrNull","JSONAllPaths","JSONAllPathsWithTypes","JSONArrayLength","JSONDynamicPaths","JSONDynamicPathsWithTypes","JSONExtract","JSONExtractArrayRaw","JSONExtractArrayRawCaseInsensitive","JSONExtractBool","JSONExtractBoolCaseInsensitive","JSONExtractCaseInsensitive","JSONExtractFloat","JSONExtractFloatCaseInsensitive","JSONExtractInt","JSONExtractIntCaseInsensitive","JSONExtractKeys","JSONExtractKeysAndValues","JSONExtractKeysAndValuesCaseInsensitive","JSONExtractKeysAndValuesRaw","JSONExtractKeysAndValuesRawCaseInsensitive","JSONExtractKeysCaseInsensitive","JSONExtractRaw","JSONExtractRawCaseInsensitive","JSONExtractString","JSONExtractStringCaseInsensitive","JSONExtractUInt","JSONExtractUIntCaseInsensitive","JSONHas","JSONKey","JSONLength","JSONMergePatch","JSONSharedDataPaths","JSONSharedDataPathsWithTypes","JSONType","JSON_ARRAY_LENGTH","JSON_EXISTS","JSON_QUERY","JSON_VALUE","L1Distance","L1Norm","L1Normalize","L2Distance","L2Norm","L2Normalize","L2SquaredDistance","L2SquaredNorm","LAST_DAY","LinfDistance","LinfNorm","LinfNormalize","LpDistance","LpNorm","LpNormalize","MACNumToString","MACStringToNum","MACStringToOUI","MAP_FROM_ARRAYS","MD4","MD5","MILLISECOND","MINUTE","MONTH","OCTET_LENGTH","QUARTER","REGEXP_EXTRACT","REGEXP_MATCHES","REGEXP_REPLACE","RIPEMD160","SCHEMA","SECOND","SHA1","SHA224","SHA256","SHA384","SHA512","SHA512_256","STD","STDDEV_POP","STDDEV_SAMP","ST_LineFromWKB","ST_MLineFromWKB","ST_MPolyFromWKB","ST_PointFromWKB","ST_PolyFromWKB","SUBSTRING_INDEX","SVG","TIMESTAMP_DIFF","TO_BASE64","TO_DAYS","TO_UNIXTIME","ULIDStringToDateTime","URLHash","URLHierarchy","URLPathHierarchy","UTCTimestamp","UTC_timestamp","UUIDNumToString","UUIDStringToNum","UUIDToNum","UUIDv7ToDateTime","VAR_POP","VAR_SAMP","YEAR","YYYYMMDDToDate","YYYYMMDDToDate32","YYYYMMDDhhmmssToDateTime","YYYYMMDDhhmmssToDateTime64","_CAST","__actionName","__bitBoolMaskAnd","__bitBoolMaskOr","__bitSwapLastTwo","__bitWrapperFunc","__getScalar","__patchPartitionID","__scalarSubqueryResult","abs","accurateCast","accurateCastOrDefault","accurateCastOrNull","acos","acosh","addDate","addDays","addHours","addInterval","addMicroseconds","addMilliseconds","addMinutes","addMonths","addNanoseconds","addQuarters","addSeconds","addTupleOfIntervals","addWeeks","addYears","addressToLine","addressToLineWithInlines","addressToSymbol","aes_decrypt_mysql","aes_encrypt_mysql","age","aggThrow","alphaTokens","analysisOfVariance","anova","any","anyHeavy","anyLast","anyLastRespectNulls","anyLast_respect_nulls","anyRespectNulls","anyValueRespectNulls","any_respect_nulls","any_value","any_value_respect_nulls","appendTrailingCharIfAbsent","approx_top_count","approx_top_k","approx_top_sum","argMax","argMin","array","arrayAUC","arrayAUCPR","arrayAll","arrayAvg","arrayCompact","arrayConcat","arrayCount","arrayCumSum","arrayCumSumNonNegative","arrayDifference","arrayDistinct","arrayDotProduct","arrayElement","arrayElementOrNull","arrayEnumerate","arrayEnumerateDense","arrayEnumerateDenseRanked","arrayEnumerateUniq","arrayEnumerateUniqRanked","arrayExists","arrayFill","arrayFilter","arrayFirst","arrayFirstIndex","arrayFirstOrNull","arrayFlatten","arrayFold","arrayIntersect","arrayJaccardIndex","arrayJoin","arrayLast","arrayLastIndex","arrayLastOrNull","arrayLevenshteinDistance","arrayLevenshteinDistanceWeighted","arrayMap","arrayMax","arrayMin","arrayNormalizedGini","arrayPRAUC","arrayPartialReverseSort","arrayPartialShuffle","arrayPartialSort","arrayPopBack","arrayPopFront","arrayProduct","arrayPushBack","arrayPushFront","arrayROCAUC","arrayRandomSample","arrayReduce","arrayReduceInRanges","arrayResize","arrayReverse","arrayReverseFill","arrayReverseSort","arrayReverseSplit","arrayRotateLeft","arrayRotateRight","arrayShiftLeft","arrayShiftRight","arrayShingles","arrayShuffle","arraySimilarity","arraySlice","arraySort","arraySplit","arrayStringConcat","arraySum","arraySymmetricDifference","arrayUnion","arrayUniq","arrayWithConstant","arrayZip","arrayZipUnaligned","array_agg","array_concat_agg","ascii","asin","asinh","assumeNotNull","atan","atan2","atanh","authenticatedUser","avg","avgWeighted","bar","base32Decode","base32Encode","base58Decode","base58Encode","base64Decode","base64Encode","base64URLDecode","base64URLEncode","basename","bech32Decode","bech32Encode","bin","bitAnd","bitCount","bitHammingDistance","bitNot","bitOr","bitPositionsToArray","bitRotateLeft","bitRotateRight","bitShiftLeft","bitShiftRight","bitSlice","bitTest","bitTestAll","bitTestAny","bitXor","bitmapAnd","bitmapAndCardinality","bitmapAndnot","bitmapAndnotCardinality","bitmapBuild","bitmapCardinality","bitmapContains","bitmapHasAll","bitmapHasAny","bitmapMax","bitmapMin","bitmapOr","bitmapOrCardinality","bitmapSubsetInRange","bitmapSubsetLimit","bitmapToArray","bitmapTransform","bitmapXor","bitmapXorCardinality","bitmaskToArray","bitmaskToList","blockNumber","blockSerializedSize","blockSize","boundingRatio","buildId","byteHammingDistance","byteSize","byteSlice","byteSwap","caseWithExpr","caseWithExpression","caseWithoutExpr","caseWithoutExpression","catboostEvaluate","categoricalInformationValue","cbrt","ceil","ceiling","changeDay","changeHour","changeMinute","changeMonth","changeSecond","changeYear","char","cityHash64","clamp","coalesce","colorOKLCHToSRGB","colorSRGBToOKLCH","compareSubstrings","concat","concatAssumeInjective","concatWithSeparator","concatWithSeparatorAssumeInjective","concat_ws","connectionId","connection_id","contingency","convertCharset","corr","corrMatrix","corrStable","cos","cosh","cosineDistance","count","countDigits","countEqual","countMatches","countMatchesCaseInsensitive","countSubstrings","countSubstringsCaseInsensitive","countSubstringsCaseInsensitiveUTF8","covarPop","covarPopMatrix","covarPopStable","covarSamp","covarSampMatrix","covarSampStable","cramersV","cramersVBiasCorrected","curdate","currentDatabase","currentProfiles","currentQueryID","currentRoles","currentSchemas","currentUser","current_database","current_date","current_query_id","current_schemas","current_timestamp","current_user","cutFragment","cutIPv6","cutQueryString","cutQueryStringAndFragment","cutToFirstSignificantSubdomain","cutToFirstSignificantSubdomainCustom","cutToFirstSignificantSubdomainCustomRFC","cutToFirstSignificantSubdomainCustomWithWWW","cutToFirstSignificantSubdomainCustomWithWWWRFC","cutToFirstSignificantSubdomainRFC","cutToFirstSignificantSubdomainWithWWW","cutToFirstSignificantSubdomainWithWWWRFC","cutURLParameter","cutWWW","damerauLevenshteinDistance","dateDiff","dateName","dateTime64ToSnowflake","dateTime64ToSnowflakeID","dateTimeToSnowflake","dateTimeToSnowflakeID","dateTimeToUUIDv7","dateTrunc","date_bin","date_diff","decodeHTMLComponent","decodeURLComponent","decodeURLFormComponent","decodeXMLComponent","decrypt","defaultProfiles","defaultRoles","defaultValueOfArgumentType","defaultValueOfTypeName","degrees","deltaSum","deltaSumTimestamp","demangle","denseRank","dense_rank","detectCharset","detectLanguage","detectLanguageMixed","detectLanguageUnknown","detectProgrammingLanguage","detectTonality","dictGet","dictGetAll","dictGetChildren","dictGetDate","dictGetDateOrDefault","dictGetDateTime","dictGetDateTimeOrDefault","dictGetDescendants","dictGetFloat32","dictGetFloat32OrDefault","dictGetFloat64","dictGetFloat64OrDefault","dictGetHierarchy","dictGetIPv4","dictGetIPv4OrDefault","dictGetIPv6","dictGetIPv6OrDefault","dictGetInt16","dictGetInt16OrDefault","dictGetInt32","dictGetInt32OrDefault","dictGetInt64","dictGetInt64OrDefault","dictGetInt8","dictGetInt8OrDefault","dictGetOrDefault","dictGetOrNull","dictGetString","dictGetStringOrDefault","dictGetUInt16","dictGetUInt16OrDefault","dictGetUInt32","dictGetUInt32OrDefault","dictGetUInt64","dictGetUInt64OrDefault","dictGetUInt8","dictGetUInt8OrDefault","dictGetUUID","dictGetUUIDOrDefault","dictHas","dictIsIn","displayName","distanceL1","distanceL2","distanceL2Squared","distanceLinf","distanceLp","distinctDynamicTypes","distinctJSONPaths","distinctJSONPathsAndTypes","divide","divideDecimal","divideOrNull","domain","domainRFC","domainWithoutWWW","domainWithoutWWWRFC","dotProduct","dumpColumnStructure","dynamicElement","dynamicType","e","editDistance","editDistanceUTF8","empty","emptyArrayDate","emptyArrayDateTime","emptyArrayFloat32","emptyArrayFloat64","emptyArrayInt16","emptyArrayInt32","emptyArrayInt64","emptyArrayInt8","emptyArrayString","emptyArrayToSingle","emptyArrayUInt16","emptyArrayUInt32","emptyArrayUInt64","emptyArrayUInt8","enabledProfiles","enabledRoles","encodeURLComponent","encodeURLFormComponent","encodeXMLComponent","encrypt","endsWith","endsWithUTF8","entropy","equals","erf","erfc","errorCodeToName","estimateCompressionRatio","evalMLMethod","exp","exp10","exp2","exponentialMovingAverage","exponentialTimeDecayedAvg","exponentialTimeDecayedCount","exponentialTimeDecayedMax","exponentialTimeDecayedSum","extract","extractAll","extractAllGroups","extractAllGroupsHorizontal","extractAllGroupsVertical","extractGroups","extractKeyValuePairs","extractKeyValuePairsWithEscaping","extractTextFromHTML","extractURLParameter","extractURLParameterNames","extractURLParameters","factorial","farmFingerprint64","farmHash64","file","filesystemAvailable","filesystemCapacity","filesystemUnreserved","finalizeAggregation","financialInternalRateOfReturn","financialInternalRateOfReturnExtended","financialNetPresentValue","financialNetPresentValueExtended","firstLine","firstSignificantSubdomain","firstSignificantSubdomainCustom","firstSignificantSubdomainCustomRFC","firstSignificantSubdomainRFC","firstValueRespectNulls","first_value","first_value_respect_nulls","flameGraph","flatten","flattenTuple","floor","formatDateTime","formatDateTimeInJodaSyntax","formatQuery","formatQueryOrNull","formatQuerySingleLine","formatQuerySingleLineOrNull","formatReadableDecimalSize","formatReadableQuantity","formatReadableSize","formatReadableTimeDelta","formatRow","formatRowNoNewline","fragment","fromDaysSinceYearZero","fromDaysSinceYearZero32","fromModifiedJulianDay","fromModifiedJulianDayOrNull","fromUTCTimestamp","fromUnixTimestamp","fromUnixTimestamp64Micro","fromUnixTimestamp64Milli","fromUnixTimestamp64Nano","fromUnixTimestamp64Second","fromUnixTimestampInJodaSyntax","from_utc_timestamp","fullHostName","fuzzBits","gccMurmurHash","gcd","generateRandomStructure","generateSerialID","generateSnowflakeID","generateULID","generateUUIDv4","generateUUIDv7","geoDistance","geoToH3","geoToS2","geohashDecode","geohashEncode","geohashesInBox","getClientHTTPHeader","getMacro","getMaxTableNameLengthForDatabase","getMergeTreeSetting","getOSKernelVersion","getServerPort","getServerSetting","getSetting","getSettingOrDefault","getSizeOfEnumType","getSubcolumn","getTypeSerializationStreams","globalIn","globalInIgnoreSet","globalNotIn","globalNotInIgnoreSet","globalNotNullIn","globalNotNullInIgnoreSet","globalNullIn","globalNullInIgnoreSet","globalVariable","greatCircleAngle","greatCircleDistance","greater","greaterOrEquals","greatest","groupArray","groupArrayInsertAt","groupArrayIntersect","groupArrayLast","groupArrayMovingAvg","groupArrayMovingSum","groupArraySample","groupArraySorted","groupBitAnd","groupBitOr","groupBitXor","groupBitmap","groupBitmapAnd","groupBitmapOr","groupBitmapXor","groupConcat","groupNumericIndexedVector","groupUniqArray","group_concat","h3CellAreaM2","h3CellAreaRads2","h3Distance","h3EdgeAngle","h3EdgeLengthKm","h3EdgeLengthM","h3ExactEdgeLengthKm","h3ExactEdgeLengthM","h3ExactEdgeLengthRads","h3GetBaseCell","h3GetDestinationIndexFromUnidirectionalEdge","h3GetFaces","h3GetIndexesFromUnidirectionalEdge","h3GetOriginIndexFromUnidirectionalEdge","h3GetPentagonIndexes","h3GetRes0Indexes","h3GetResolution","h3GetUnidirectionalEdge","h3GetUnidirectionalEdgeBoundary","h3GetUnidirectionalEdgesFromHexagon","h3HexAreaKm2","h3HexAreaM2","h3HexRing","h3IndexesAreNeighbors","h3IsPentagon","h3IsResClassIII","h3IsValid","h3Line","h3NumHexagons","h3PointDistKm","h3PointDistM","h3PointDistRads","h3ToCenterChild","h3ToChildren","h3ToGeo","h3ToGeoBoundary","h3ToParent","h3ToString","h3UnidirectionalEdgeIsValid","h3kRing","halfMD5","has","hasAll","hasAny","hasColumnInTable","hasSubsequence","hasSubsequenceCaseInsensitive","hasSubsequenceCaseInsensitiveUTF8","hasSubsequenceUTF8","hasSubstr","hasThreadFuzzer","hasToken","hasTokenCaseInsensitive","hasTokenCaseInsensitiveOrNull","hasTokenOrNull","hex","hilbertDecode","hilbertEncode","histogram","hiveHash","hop","hopEnd","hopStart","hostName","hostname","hypot","icebergBucket","icebergHash","icebergTruncate","identity","idnaDecode","idnaEncode","if","ifNotFinite","ifNull","ignore","inIgnoreSet","indexHint","indexOf","indexOfAssumeSorted","initcap","initcapUTF8","initialQueryID","initialQueryStartTime","initial_query_id","initial_query_start_time","initializeAggregation","instr","intDiv","intDivOrNull","intDivOrZero","intExp10","intExp2","intHash32","intHash64","intervalLengthSum","isConstant","isDecimalOverflow","isDynamicElementInSharedData","isFinite","isIPAddressInRange","isIPv4String","isIPv6String","isInfinite","isMergeTreePartCoveredBy","isNaN","isNotDistinctFrom","isNotNull","isNull","isNullable","isValidJSON","isValidUTF8","isZeroOrNull","jaroSimilarity","jaroWinklerSimilarity","javaHash","javaHashUTF16LE","joinGet","joinGetOrNull","jsonMergePatch","jumpConsistentHash","kafkaMurmurHash","keccak256","kolmogorovSmirnovTest","kostikConsistentHash","kql_array_sort_asc","kql_array_sort_desc","kurtPop","kurtSamp","lag","lagInFrame","largestTriangleThreeBuckets","lastValueRespectNulls","last_value","last_value_respect_nulls","lcase","lcm","lead","leadInFrame","least","left","leftPad","leftPadUTF8","leftUTF8","lemmatize","length","lengthUTF8","less","lessOrEquals","levenshteinDistance","levenshteinDistanceUTF8","lgamma","ln","locate","log","log10","log1p","log2","logTrace","lowCardinalityIndices","lowCardinalityKeys","lower","lowerUTF8","lpad","ltrim","lttb","makeDate","makeDate32","makeDateTime","makeDateTime64","mannWhitneyUTest","map","mapAdd","mapAll","mapApply","mapConcat","mapContains","mapContainsKey","mapContainsKeyLike","mapContainsValue","mapContainsValueLike","mapExists","mapExtractKeyLike","mapExtractValueLike","mapFilter","mapFromArrays","mapFromString","mapKeys","mapPartialReverseSort","mapPartialSort","mapPopulateSeries","mapReverseSort","mapSort","mapSubtract","mapUpdate","mapValues","match","materialize","max","max2","maxIntersections","maxIntersectionsPosition","maxMappedArrays","meanZTest","median","medianBFloat16","medianBFloat16Weighted","medianDD","medianDeterministic","medianExact","medianExactHigh","medianExactLow","medianExactWeighted","medianExactWeightedInterpolated","medianGK","medianInterpolatedWeighted","medianTDigest","medianTDigestWeighted","medianTiming","medianTimingWeighted","mergeTreePartInfo","metroHash64","mid","min","min2","minMappedArrays","minSampleSizeContinous","minSampleSizeContinuous","minSampleSizeConversion","minus","mismatches","mod","modOrNull","modulo","moduloLegacy","moduloOrNull","moduloOrZero","monthName","mortonDecode","mortonEncode","multiFuzzyMatchAllIndices","multiFuzzyMatchAny","multiFuzzyMatchAnyIndex","multiIf","multiMatchAllIndices","multiMatchAny","multiMatchAnyIndex","multiSearchAllPositions","multiSearchAllPositionsCaseInsensitive","multiSearchAllPositionsCaseInsensitiveUTF8","multiSearchAllPositionsUTF8","multiSearchAny","multiSearchAnyCaseInsensitive","multiSearchAnyCaseInsensitiveUTF8","multiSearchAnyUTF8","multiSearchFirstIndex","multiSearchFirstIndexCaseInsensitive","multiSearchFirstIndexCaseInsensitiveUTF8","multiSearchFirstIndexUTF8","multiSearchFirstPosition","multiSearchFirstPositionCaseInsensitive","multiSearchFirstPositionCaseInsensitiveUTF8","multiSearchFirstPositionUTF8","multiply","multiplyDecimal","murmurHash2_32","murmurHash2_64","murmurHash3_128","murmurHash3_32","murmurHash3_64","negate","neighbor","nested","netloc","ngramDistance","ngramDistanceCaseInsensitive","ngramDistanceCaseInsensitiveUTF8","ngramDistanceUTF8","ngramMinHash","ngramMinHashArg","ngramMinHashArgCaseInsensitive","ngramMinHashArgCaseInsensitiveUTF8","ngramMinHashArgUTF8","ngramMinHashCaseInsensitive","ngramMinHashCaseInsensitiveUTF8","ngramMinHashUTF8","ngramSearch","ngramSearchCaseInsensitive","ngramSearchCaseInsensitiveUTF8","ngramSearchUTF8","ngramSimHash","ngramSimHashCaseInsensitive","ngramSimHashCaseInsensitiveUTF8","ngramSimHashUTF8","ngrams","nonNegativeDerivative","normL1","normL2","normL2Squared","normLinf","normLp","normalizeL1","normalizeL2","normalizeLinf","normalizeLp","normalizeQuery","normalizeQueryKeepNames","normalizeUTF8NFC","normalizeUTF8NFD","normalizeUTF8NFKC","normalizeUTF8NFKD","normalizedQueryHash","normalizedQueryHashKeepNames","notEmpty","notEquals","notILike","notIn","notInIgnoreSet","notLike","notNullIn","notNullInIgnoreSet","nothing","nothingNull","nothingUInt64","now","now64","nowInBlock","nowInBlock64","nth_value","ntile","nullIf","nullIn","nullInIgnoreSet","numbers","numericIndexedVectorAllValueSum","numericIndexedVectorBuild","numericIndexedVectorCardinality","numericIndexedVectorGetValue","numericIndexedVectorPointwiseAdd","numericIndexedVectorPointwiseDivide","numericIndexedVectorPointwiseEqual","numericIndexedVectorPointwiseGreater","numericIndexedVectorPointwiseGreaterEqual","numericIndexedVectorPointwiseLess","numericIndexedVectorPointwiseLessEqual","numericIndexedVectorPointwiseMultiply","numericIndexedVectorPointwiseNotEqual","numericIndexedVectorPointwiseSubtract","numericIndexedVectorShortDebugString","numericIndexedVectorToMap","overlay","overlayUTF8","parseDateTime","parseDateTime32BestEffort","parseDateTime32BestEffortOrNull","parseDateTime32BestEffortOrZero","parseDateTime64","parseDateTime64BestEffort","parseDateTime64BestEffortOrNull","parseDateTime64BestEffortOrZero","parseDateTime64BestEffortUS","parseDateTime64BestEffortUSOrNull","parseDateTime64BestEffortUSOrZero","parseDateTime64InJodaSyntax","parseDateTime64InJodaSyntaxOrNull","parseDateTime64InJodaSyntaxOrZero","parseDateTime64OrNull","parseDateTime64OrZero","parseDateTimeBestEffort","parseDateTimeBestEffortOrNull","parseDateTimeBestEffortOrZero","parseDateTimeBestEffortUS","parseDateTimeBestEffortUSOrNull","parseDateTimeBestEffortUSOrZero","parseDateTimeInJodaSyntax","parseDateTimeInJodaSyntaxOrNull","parseDateTimeInJodaSyntaxOrZero","parseDateTimeOrNull","parseDateTimeOrZero","parseReadableSize","parseReadableSizeOrNull","parseReadableSizeOrZero","parseTimeDelta","partitionID","partitionId","path","pathFull","percentRank","percent_rank","pi","plus","pmod","pmodOrNull","pointInEllipses","pointInPolygon","polygonAreaCartesian","polygonAreaSpherical","polygonConvexHullCartesian","polygonPerimeterCartesian","polygonPerimeterSpherical","polygonsDistanceCartesian","polygonsDistanceSpherical","polygonsEqualsCartesian","polygonsIntersectCartesian","polygonsIntersectSpherical","polygonsIntersectionCartesian","polygonsIntersectionSpherical","polygonsSymDifferenceCartesian","polygonsSymDifferenceSpherical","polygonsUnionCartesian","polygonsUnionSpherical","polygonsWithinCartesian","polygonsWithinSpherical","port","portRFC","position","positionCaseInsensitive","positionCaseInsensitiveUTF8","positionUTF8","positiveModulo","positiveModuloOrNull","positive_modulo","positive_modulo_or_null","pow","power","printf","proportionsZTest","protocol","punycodeDecode","punycodeEncode","quantile","quantileBFloat16","quantileBFloat16Weighted","quantileDD","quantileDeterministic","quantileExact","quantileExactExclusive","quantileExactHigh","quantileExactInclusive","quantileExactLow","quantileExactWeighted","quantileExactWeightedInterpolated","quantileGK","quantileInterpolatedWeighted","quantileTDigest","quantileTDigestWeighted","quantileTiming","quantileTimingWeighted","quantiles","quantilesBFloat16","quantilesBFloat16Weighted","quantilesDD","quantilesDeterministic","quantilesExact","quantilesExactExclusive","quantilesExactHigh","quantilesExactInclusive","quantilesExactLow","quantilesExactWeighted","quantilesExactWeightedInterpolated","quantilesGK","quantilesInterpolatedWeighted","quantilesTDigest","quantilesTDigestWeighted","quantilesTiming","quantilesTimingWeighted","queryID","queryString","queryStringAndFragment","query_id","radians","rand","rand32","rand64","randBernoulli","randBinomial","randCanonical","randChiSquared","randConstant","randExponential","randFisherF","randLogNormal","randNegativeBinomial","randNormal","randPoisson","randStudentT","randUniform","randomFixedString","randomPrintableASCII","randomString","randomStringUTF8","rank","rankCorr","readWKBLineString","readWKBMultiLineString","readWKBMultiPolygon","readWKBPoint","readWKBPolygon","readWKTLineString","readWKTMultiLineString","readWKTMultiPolygon","readWKTPoint","readWKTPolygon","readWKTRing","regexpExtract","regexpQuoteMeta","regionHierarchy","regionIn","regionToArea","regionToCity","regionToContinent","regionToCountry","regionToDistrict","regionToName","regionToPopulation","regionToTopContinent","reinterpret","reinterpretAsDate","reinterpretAsDateTime","reinterpretAsFixedString","reinterpretAsFloat32","reinterpretAsFloat64","reinterpretAsInt128","reinterpretAsInt16","reinterpretAsInt256","reinterpretAsInt32","reinterpretAsInt64","reinterpretAsInt8","reinterpretAsString","reinterpretAsUInt128","reinterpretAsUInt16","reinterpretAsUInt256","reinterpretAsUInt32","reinterpretAsUInt64","reinterpretAsUInt8","reinterpretAsUUID","repeat","replace","replaceAll","replaceOne","replaceRegexpAll","replaceRegexpOne","replicate","retention","reverse","reverseUTF8","revision","right","rightPad","rightPadUTF8","rightUTF8","round","roundAge","roundBankers","roundDown","roundDuration","roundToExp2","rowNumberInAllBlocks","rowNumberInBlock","row_number","rpad","rtrim","runningAccumulate","runningConcurrency","runningDifference","runningDifferenceStartingWithFirstValue","s2CapContains","s2CapUnion","s2CellsIntersect","s2GetNeighbors","s2RectAdd","s2RectContains","s2RectIntersection","s2RectUnion","s2ToGeo","scalarProduct","searchAll","searchAny","sequenceCount","sequenceMatch","sequenceMatchEvents","sequenceNextNode","seriesDecomposeSTL","seriesOutliersDetectTukey","seriesPeriodDetectFFT","serverTimeZone","serverTimezone","serverUUID","shardCount","shardNum","showCertificate","sigmoid","sign","simpleJSONExtractBool","simpleJSONExtractFloat","simpleJSONExtractInt","simpleJSONExtractRaw","simpleJSONExtractString","simpleJSONExtractUInt","simpleJSONHas","simpleLinearRegression","sin","singleValueOrNull","sinh","sipHash128","sipHash128Keyed","sipHash128Reference","sipHash128ReferenceKeyed","sipHash64","sipHash64Keyed","skewPop","skewSamp","sleep","sleepEachRow","snowflakeIDToDateTime","snowflakeIDToDateTime64","snowflakeToDateTime","snowflakeToDateTime64","soundex","space","sparkBar","sparkbar","sparseGrams","sparseGramsHashes","sparseGramsHashesUTF8","sparseGramsUTF8","splitByAlpha","splitByChar","splitByNonAlpha","splitByRegexp","splitByString","splitByWhitespace","sqid","sqidDecode","sqidEncode","sqrt","startsWith","startsWithUTF8","stddevPop","stddevPopStable","stddevSamp","stddevSampStable","stem","stochasticLinearRegression","stochasticLogisticRegression","str_to_date","str_to_map","stringBytesEntropy","stringBytesUniq","stringJaccardIndex","stringJaccardIndexUTF8","stringToH3","structureToCapnProtoSchema","structureToProtobufSchema","studentTTest","subBitmap","subDate","substr","substring","substringIndex","substringIndexUTF8","substringUTF8","subtractDays","subtractHours","subtractInterval","subtractMicroseconds","subtractMilliseconds","subtractMinutes","subtractMonths","subtractNanoseconds","subtractQuarters","subtractSeconds","subtractTupleOfIntervals","subtractWeeks","subtractYears","sum","sumCount","sumKahan","sumMapFiltered","sumMapFilteredWithOverflow","sumMapWithOverflow","sumMappedArrays","sumWithOverflow","svg","synonyms","tan","tanh","tcpPort","tgamma","theilsU","throwIf","tid","timeDiff","timeSeriesDeltaToGrid","timeSeriesDerivToGrid","timeSeriesFromGrid","timeSeriesGroupArray","timeSeriesIdToTags","timeSeriesIdToTagsGroup","timeSeriesIdeltaToGrid","timeSeriesInstantDeltaToGrid","timeSeriesInstantRateToGrid","timeSeriesIrateToGrid","timeSeriesLastToGrid","timeSeriesLastTwoSamples","timeSeriesPredictLinearToGrid","timeSeriesRange","timeSeriesRateToGrid","timeSeriesResampleToGridWithStaleness","timeSeriesStoreTags","timeSeriesTagsGroupToTags","timeSlot","timeSlots","timeZone","timeZoneOf","timeZoneOffset","time_bucket","timestamp","timestampDiff","timestamp_diff","timezone","timezoneOf","timezoneOffset","toBFloat16","toBFloat16OrNull","toBFloat16OrZero","toBool","toColumnTypeName","toDate","toDate32","toDate32OrDefault","toDate32OrNull","toDate32OrZero","toDateOrDefault","toDateOrNull","toDateOrZero","toDateTime","toDateTime32","toDateTime64","toDateTime64OrDefault","toDateTime64OrNull","toDateTime64OrZero","toDateTimeOrDefault","toDateTimeOrNull","toDateTimeOrZero","toDayOfMonth","toDayOfWeek","toDayOfYear","toDaysSinceYearZero","toDecimal128","toDecimal128OrDefault","toDecimal128OrNull","toDecimal128OrZero","toDecimal256","toDecimal256OrDefault","toDecimal256OrNull","toDecimal256OrZero","toDecimal32","toDecimal32OrDefault","toDecimal32OrNull","toDecimal32OrZero","toDecimal64","toDecimal64OrDefault","toDecimal64OrNull","toDecimal64OrZero","toDecimalString","toFixedString","toFloat32","toFloat32OrDefault","toFloat32OrNull","toFloat32OrZero","toFloat64","toFloat64OrDefault","toFloat64OrNull","toFloat64OrZero","toHour","toIPv4","toIPv4OrDefault","toIPv4OrNull","toIPv4OrZero","toIPv6","toIPv6OrDefault","toIPv6OrNull","toIPv6OrZero","toISOWeek","toISOYear","toInt128","toInt128OrDefault","toInt128OrNull","toInt128OrZero","toInt16","toInt16OrDefault","toInt16OrNull","toInt16OrZero","toInt256","toInt256OrDefault","toInt256OrNull","toInt256OrZero","toInt32","toInt32OrDefault","toInt32OrNull","toInt32OrZero","toInt64","toInt64OrDefault","toInt64OrNull","toInt64OrZero","toInt8","toInt8OrDefault","toInt8OrNull","toInt8OrZero","toInterval","toIntervalDay","toIntervalHour","toIntervalMicrosecond","toIntervalMillisecond","toIntervalMinute","toIntervalMonth","toIntervalNanosecond","toIntervalQuarter","toIntervalSecond","toIntervalWeek","toIntervalYear","toJSONString","toLastDayOfMonth","toLastDayOfWeek","toLowCardinality","toMillisecond","toMinute","toModifiedJulianDay","toModifiedJulianDayOrNull","toMonday","toMonth","toMonthNumSinceEpoch","toNullable","toQuarter","toRelativeDayNum","toRelativeHourNum","toRelativeMinuteNum","toRelativeMonthNum","toRelativeQuarterNum","toRelativeSecondNum","toRelativeWeekNum","toRelativeYearNum","toSecond","toStartOfDay","toStartOfFifteenMinutes","toStartOfFiveMinute","toStartOfFiveMinutes","toStartOfHour","toStartOfISOYear","toStartOfInterval","toStartOfMicrosecond","toStartOfMillisecond","toStartOfMinute","toStartOfMonth","toStartOfNanosecond","toStartOfQuarter","toStartOfSecond","toStartOfTenMinutes","toStartOfWeek","toStartOfYear","toString","toStringCutToZero","toTime","toTime64","toTime64OrNull","toTime64OrZero","toTimeOrNull","toTimeOrZero","toTimeWithFixedDate","toTimeZone","toTimezone","toTypeName","toUInt128","toUInt128OrDefault","toUInt128OrNull","toUInt128OrZero","toUInt16","toUInt16OrDefault","toUInt16OrNull","toUInt16OrZero","toUInt256","toUInt256OrDefault","toUInt256OrNull","toUInt256OrZero","toUInt32","toUInt32OrDefault","toUInt32OrNull","toUInt32OrZero","toUInt64","toUInt64OrDefault","toUInt64OrNull","toUInt64OrZero","toUInt8","toUInt8OrDefault","toUInt8OrNull","toUInt8OrZero","toUTCTimestamp","toUUID","toUUIDOrDefault","toUUIDOrNull","toUUIDOrZero","toUnixTimestamp","toUnixTimestamp64Micro","toUnixTimestamp64Milli","toUnixTimestamp64Nano","toUnixTimestamp64Second","toValidUTF8","toWeek","toYYYYMM","toYYYYMMDD","toYYYYMMDDhhmmss","toYear","toYearNumSinceEpoch","toYearWeek","to_utc_timestamp","today","tokens","topK","topKWeighted","topLevelDomain","topLevelDomainRFC","transactionID","transactionLatestSnapshot","transactionOldestSnapshot","transform","translate","translateUTF8","trim","trimBoth","trimLeft","trimRight","trunc","tryBase32Decode","tryBase58Decode","tryBase64Decode","tryBase64URLDecode","tryDecrypt","tryIdnaEncode","tryPunycodeDecode","tumble","tumbleEnd","tumbleStart","tuple","tupleConcat","tupleDivide","tupleDivideByNumber","tupleElement","tupleHammingDistance","tupleIntDiv","tupleIntDivByNumber","tupleIntDivOrZero","tupleIntDivOrZeroByNumber","tupleMinus","tupleModulo","tupleModuloByNumber","tupleMultiply","tupleMultiplyByNumber","tupleNames","tupleNegate","tuplePlus","tupleToNameValuePairs","ucase","unbin","unhex","uniq","uniqCombined","uniqCombined64","uniqExact","uniqHLL12","uniqTheta","uniqThetaIntersect","uniqThetaNot","uniqThetaUnion","uniqUpTo","upper","upperUTF8","uptime","user","validateNestedArraySizes","varPop","varPopStable","varSamp","varSampStable","variantElement","variantType","vectorDifference","vectorSum","version","visibleWidth","visitParamExtractBool","visitParamExtractFloat","visitParamExtractInt","visitParamExtractRaw","visitParamExtractString","visitParamExtractUInt","visitParamHas","week","welchTTest","widthBucket","width_bucket","windowFunnel","windowID","wkb","wkt","wordShingleMinHash","wordShingleMinHashArg","wordShingleMinHashArgCaseInsensitive","wordShingleMinHashArgCaseInsensitiveUTF8","wordShingleMinHashArgUTF8","wordShingleMinHashCaseInsensitive","wordShingleMinHashCaseInsensitiveUTF8","wordShingleMinHashUTF8","wordShingleSimHash","wordShingleSimHashCaseInsensitive","wordShingleSimHashCaseInsensitiveUTF8","wordShingleSimHashUTF8","wyHash64","xor","xxHash32","xxHash64","xxh3","yandexConsistentHash","yearweek","yesterday","zookeeperSessionUptime","MergeTree","ReplacingMergeTree","SummingMergeTree","AggregatingMergeTree","CollapsingMergeTree","VersionedCollapsingMergeTree","GraphiteMergeTree","CoalescingMergeTree","Atomic","Shared","Lazy","Replicated","PostgreSQL","MySQL","SQLite","MaterializedPostgreSQL","DataLakeCatalog"],uf=["ACCESS","ACTION","ADD","ADMIN","AFTER","ALGORITHM","ALIAS","ALL","ALLOWED_LATENESS","ALTER","AND","ANTI","APPEND","APPLY","AS","ASC","ASCENDING","ASOF","ASSUME","AST","ASYNC","ATTACH","AUTO_INCREMENT","AZURE","BACKUP","BAGEXPANSION","BASE_BACKUP","BCRYPT_HASH","BCRYPT_PASSWORD","BEGIN","BETWEEN","BIDIRECTIONAL","BOTH","BY","CACHE","CACHES","CASCADE","CASE","CHANGE","CHANGEABLE_IN_READONLY","CHANGED","CHARACTER","CHECK","CLEANUP","CLEAR","CLUSTER","CLUSTERS","CLUSTER_HOST_IDS","CN","CODEC","COLLATE","COLLECTION","COLUMN","COLUMNS","COMMENT","COMMIT","COMPRESSION","CONST","CONSTRAINT","CREATE","CROSS","CUBE","CURRENT","D","DATA","DATABASE","DATABASES","DAYS","DD","DDL","DEDUPLICATE","DEFAULT","DEFINER","DELAY","DELETE","DELETED","DEPENDS","DESC","DESCENDING","DESCRIBE","DETACH","DETACHED","DICTIONARIES","DICTIONARY","DISK","DISTINCT","DIV","DOUBLE_SHA1_HASH","DOUBLE_SHA1_PASSWORD","DROP","ELSE","ENABLED","END","ENFORCED","ENGINE","ENGINES","EPHEMERAL","ESTIMATE","EVENT","EVENTS","EVERY","EXCEPT","EXCHANGE","EXISTS","EXPLAIN","EXPRESSION","EXTENDED","EXTERNAL","FAKE","FALSE","FETCH","FIELDS","FILESYSTEM","FILL","FILTER","FINAL","FIRST","FOLLOWING","FOR","FOREIGN","FORMAT","FREEZE","FROM","FULL","FULLTEXT","FUNCTION","FUNCTIONS","GLOBAL","GRANT","GRANTEES","GRANTS","GRANULARITY","GROUP","GROUPING","GROUPS","H","HASH","HAVING","HDFS","HH","HIERARCHICAL","HOST","HOURS","HTTP","IDENTIFIED","ILIKE","IN","INDEX","INDEXES","INDICES","INFILE","INHERIT","INJECTIVE","INNER","INSERT","INTERPOLATE","INTERSECT","INTERVAL","INTO","INVISIBLE","INVOKER","IP","IS","IS_OBJECT_ID","JOIN","JWT","KERBEROS","KEY","KEYED","KEYS","KILL","KIND","LARGE","LAST","LAYOUT","LDAP","LEADING","LEVEL","LIFETIME","LIGHTWEIGHT","LIKE","LIMIT","LIMITS","LINEAR","LIST","LIVE","LOCAL","M","MASK","MATERIALIZED","MCS","MEMORY","MERGES","METRICS","MI","MICROSECOND","MICROSECONDS","MILLISECONDS","MINUTES","MM","MODIFY","MONTHS","MOVE","MS","MUTATION","N","NAME","NAMED","NANOSECOND","NANOSECONDS","NEXT","NO","NONE","NOT","NO_PASSWORD","NS","NULL","NULLS","OBJECT","OFFSET","ON","ONLY","OPTIMIZE","OPTION","OR","ORDER","OUTER","OUTFILE","OVER","OVERRIDABLE","OVERRIDE","PART","PARTIAL","PARTITION","PARTITIONS","PART_MOVE_TO_SHARD","PASTE","PERIODIC","PERMANENTLY","PERMISSIVE","PERSISTENT","PIPELINE","PLAINTEXT_PASSWORD","PLAN","POLICY","POPULATE","PRECEDING","PRECISION","PREWHERE","PRIMARY","PRIVILEGES","PROCESSLIST","PROFILE","PROJECTION","PROTOBUF","PULL","Q","QQ","QUALIFY","QUARTERS","QUERY","QUOTA","RANDOMIZE","RANDOMIZED","RANGE","READONLY","REALM","RECOMPRESS","RECURSIVE","REFERENCES","REFRESH","REGEXP","REMOVE","RENAME","RESET","RESPECT","RESTORE","RESTRICT","RESTRICTIVE","RESUME","REVOKE","ROLE","ROLES","ROLLBACK","ROLLUP","ROW","ROWS","S","S3","SALT","SAMPLE","SAN","SCHEME","SECONDS","SECURITY","SELECT","SEMI","SEQUENTIAL","SERVER","SET","SETS","SETTING","SETTINGS","SHA256_HASH","SHA256_PASSWORD","SHARD","SHOW","SIGNED","SIMPLE","SNAPSHOT","SOURCE","SPATIAL","SQL","SQL_TSI_DAY","SQL_TSI_HOUR","SQL_TSI_MICROSECOND","SQL_TSI_MILLISECOND","SQL_TSI_MINUTE","SQL_TSI_MONTH","SQL_TSI_NANOSECOND","SQL_TSI_QUARTER","SQL_TSI_SECOND","SQL_TSI_WEEK","SQL_TSI_YEAR","SS","SSH_KEY","SSL_CERTIFICATE","STALENESS","START","STATISTICS","STDOUT","STEP","STORAGE","STRICT","STRICTLY_ASCENDING","SUBPARTITION","SUBPARTITIONS","SUSPEND","SYNC","SYNTAX","SYSTEM","TABLE","TABLES","TAGS","TEMPORARY","TEST","THAN","THEN","TIES","TIME","TO","TOP","TOTALS","TRACKING","TRAILING","TRANSACTION","TREE","TRIGGER","TRUE","TRUNCATE","TTL","TYPE","TYPEOF","UNBOUNDED","UNDROP","UNFREEZE","UNION","UNIQUE","UNSET","UNSIGNED","UNTIL","UPDATE","URL","USE","USING","UUID","VALID","VALUES","VARYING","VIEW","VISIBLE","VOLUME","WATCH","WATERMARK","WEEKS","WHEN","WHERE","WINDOW","WITH","WITH_ITEMINDEX","WK","WRITABLE","WW","YEARS","YY","YYYY","ZKPATH"],Af=["AGGREGATEFUNCTION","ARRAY","BFLOAT16","BIGINT","BIGINT SIGNED","BIGINT UNSIGNED","BINARY","BINARY LARGE OBJECT","BINARY VARYING","BIT","BLOB","BYTE","BYTEA","BOOL","CHAR","CHAR LARGE OBJECT","CHAR VARYING","CHARACTER","CHARACTER LARGE OBJECT","CHARACTER VARYING","CLOB","DEC","DOUBLE","DOUBLE PRECISION","DATE","DATE32","DATETIME","DATETIME32","DATETIME64","DECIMAL","DECIMAL128","DECIMAL256","DECIMAL32","DECIMAL64","DYNAMIC","ENUM","ENUM","ENUM16","ENUM8","FIXED","FLOAT","FIXEDSTRING","FLOAT32","FLOAT64","GEOMETRY","INET4","INET6","INT","INT SIGNED","INT UNSIGNED","INT1","INT1 SIGNED","INT1 UNSIGNED","INTEGER","INTEGER SIGNED","INTEGER UNSIGNED","IPV4","IPV6","INT128","INT16","INT256","INT32","INT64","INT8","INTERVALDAY","INTERVALHOUR","INTERVALMICROSECOND","INTERVALMILLISECOND","INTERVALMINUTE","INTERVALMONTH","INTERVALNANOSECOND","INTERVALQUARTER","INTERVALSECOND","INTERVALWEEK","INTERVALYEAR","JSON","LONGBLOB","LONGTEXT","LINESTRING","LOWCARDINALITY","MEDIUMBLOB","MEDIUMINT","MEDIUMINT SIGNED","MEDIUMINT UNSIGNED","MEDIUMTEXT","MAP","MULTILINESTRING","MULTIPOLYGON","NATIONAL CHAR","NATIONAL CHAR VARYING","NATIONAL CHARACTER","NATIONAL CHARACTER LARGE OBJECT","NATIONAL CHARACTER VARYING","NCHAR","NCHAR LARGE OBJECT","NCHAR VARYING","NUMERIC","NVARCHAR","NESTED","NOTHING","NULLABLE","OBJECT","POINT","POLYGON","REAL","RING","SET","SIGNED","SINGLE","SMALLINT","SMALLINT SIGNED","SMALLINT UNSIGNED","SIMPLEAGGREGATEFUNCTION","STRING","TEXT","TIMESTAMP","TINYBLOB","TINYINT","TINYINT SIGNED","TINYINT UNSIGNED","TINYTEXT","TIME","TIME64","TUPLE","UINT128","UINT16","UINT256","UINT32","UINT64","UINT8","UNSIGNED","UUID","VARBINARY","VARCHAR","VARCHAR2","VARIANT","YEAR","BOOL","BOOLEAN"],df=Q(["SELECT [DISTINCT]","MODIFY QUERY SELECT [DISTINCT]"]),Of=Q(["SET","WITH","FROM","SAMPLE","PREWHERE","WHERE","GROUP BY","HAVING","QUALIFY","ORDER BY","LIMIT","SETTINGS","INTO OUTFILE","FORMAT","WINDOW","PARTITION BY","INSERT INTO","VALUES","DEPENDS ON","MOVE {USER | ROLE | QUOTA | SETTINGS PROFILE | ROW POLICY}","GRANT","REVOKE","CHECK GRANT","SET [DEFAULT] ROLE [NONE | ALL | ALL EXCEPT]","DEDUPLICATE BY","MODIFY STATISTICS","TYPE","ALTER USER [IF EXISTS]","ALTER [ROW] POLICY [IF EXISTS]","DROP {USER | ROLE | QUOTA | PROFILE | SETTINGS PROFILE | ROW POLICY | POLICY} [IF EXISTS]"]),VA=Q(["CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"]),kT=Q(["ALL EXCEPT","ON CLUSTER","UPDATE","SYSTEM RELOAD {DICTIONARIES | DICTIONARY | FUNCTIONS | FUNCTION | ASYNCHRONOUS METRICS}","SYSTEM DROP {DNS CACHE | MARK CACHE | ICEBERG METADATA CACHE | TEXT INDEX DICTIONARY CACHE | TEXT INDEX HEADER CACHE | TEXT INDEX POSTINGS CACHE | REPLICA | DATABASE REPLICA | UNCOMPRESSED CACHE | COMPILED EXPRESSION CACHE | QUERY CONDITION CACHE | QUERY CACHE | FORMAT SCHEMA CACHE | FILESYSTEM CACHE}","SYSTEM FLUSH LOGS","SYSTEM RELOAD {CONFIG | USERS}","SYSTEM SHUTDOWN","SYSTEM KILL","SYSTEM FLUSH DISTRIBUTED","SYSTEM START DISTRIBUTED SENDS","SYSTEM {STOP | START} {LISTEN | MERGES | TTL MERGES | MOVES | FETCHES | REPLICATED SENDS | REPLICATION QUEUES | PULLING REPLICATION LOG}","SYSTEM {SYNC | RESTART | RESTORE} REPLICA","SYSTEM {SYNC | RESTORE} DATABASE REPLICA","SYSTEM RESTART REPLICAS","SYSTEM UNFREEZE","SYSTEM WAIT LOADING PARTS","SYSTEM {LOAD | UNLOAD} PRIMARY KEY","SYSTEM {STOP | START} [REPLICATED] VIEW","SYSTEM {STOP | START} VIEWS","SYSTEM {REFRESH | CANCEL | WAIT} VIEW","WITH NAME","SHOW [CREATE] {TABLE | TEMPORARY TABLE | DICTIONARY | VIEW | DATABASE}","SHOW DATABASES [[NOT] {LIKE | ILIKE}]","SHOW [FULL] [TEMPORARY] TABLES [FROM | IN]","SHOW [EXTENDED] [FULL] COLUMNS {FROM | IN}","ATTACH {TABLE | DICTIONARY | DATABASE} [IF NOT EXISTS]","DETACH {TABLE | DICTIONARY | DATABASE} [IF EXISTS]","PERMANENTLY","SYNC","DROP {DICTIONARY | DATABASE | PROFILE | VIEW | FUNCTION | NAMED COLLECTION} [IF EXISTS]","DROP [TEMPORARY] TABLE [IF EXISTS] [IF EMPTY]","RENAME TO","EXISTS [TEMPORARY] {TABLE | DICTIONARY | DATABASE}","KILL QUERY","OPTIMIZE TABLE","RENAME {TABLE | DICTIONARY | DATABASE}","EXCHANGE {TABLES | DICTIONARIES}","TRUNCATE TABLE [IF EXISTS]","EXECUTE AS","USE","TO","UNDROP TABLE","CREATE {DATABASE | NAMED COLLECTION} [IF NOT EXISTS]","CREATE [OR REPLACE] {VIEW | DICTIONARY} [IF NOT EXISTS]","CREATE MATERIALIZED VIEW [IF NOT EXISTS]","CREATE FUNCTION","CREATE {USER | ROLE | QUOTA | SETTINGS PROFILE} [IF NOT EXISTS | OR REPLACE]","CREATE [ROW] POLICY [IF NOT EXISTS | OR REPLACE]","REPLACE [TEMPORARY] TABLE [IF NOT EXISTS]","ALTER {ROLE | QUOTA | SETTINGS PROFILE} [IF EXISTS]","ALTER [TEMPORARY] TABLE","ALTER NAMED COLLECTION [IF EXISTS]","GRANTEES","NOT IDENTIFIED","RESET AUTHENTICATION METHODS TO NEW","{IDENTIFIED | ADD IDENTIFIED} [WITH | BY]","[ADD | DROP] HOST {LOCAL | NAME | REGEXP | IP | LIKE}","VALID UNTIL","DROP [ALL] {PROFILES | SETTINGS}","{ADD | MODIFY} SETTINGS","ADD PROFILES","APPLY DELETED MASK","IN PARTITION","{ADD | DROP | RENAME | CLEAR | COMMENT | MODIFY | ALTER | MATERIALIZE} COLUMN","{DETACH | DROP | ATTACH | FETCH | MOVE} {PART | PARTITION}","DROP DETACHED {PART | PARTITION}","{FORGET | REPLACE} PARTITION","CLEAR COLUMN","{FREEZE | UNFREEZE} [PARTITION]","CLEAR INDEX","TO {DISK | VOLUME}","[DELETE | REWRITE PARTS] IN PARTITION","{MODIFY | RESET} SETTING","DELETE WHERE","MODIFY ORDER BY","{MODIFY | REMOVE} SAMPLE BY","{ADD | MATERIALIZE | CLEAR} INDEX [IF NOT EXISTS]","DROP INDEX [IF EXISTS]","GRANULARITY","AFTER","FIRST","ADD CONSTRAINT [IF NOT EXISTS]","DROP CONSTRAINT [IF EXISTS]","MODIFY TTL","REMOVE TTL","ADD STATISTICS [IF NOT EXISTS]","{DROP | CLEAR} STATISTICS [IF EXISTS]","MATERIALIZE STATISTICS [ALL | IF EXISTS]","KEYED BY","NOT KEYED","FOR [RANDOMIZED] INTERVAL","AS {PERMISSIVE | RESTRICTIVE}","FOR SELECT","ADD PROJECTION [IF NOT EXISTS]","{DROP | MATERIALIZE | CLEAR} PROJECTION [IF EXISTS]","REFRESH {EVERY | AFTER}","RANDOMIZE FOR","APPEND","APPEND TO","DELETE FROM","EXPLAIN [AST | SYNTAX | QUERY TREE | PLAN | PIPELINE | ESTIMATE | TABLE OVERRIDE]","GRANT ON CLUSTER","GRANT CURRENT GRANTS","WITH GRANT OPTION","REVOKE ON CLUSTER","ADMIN OPTION FOR","CHECK TABLE","PARTITION ID","{DESC | DESCRIBE} TABLE"]),Nf=Q(["UNION [ALL | DISTINCT]","PARALLEL WITH"]),If=Q(["[GLOBAL] [INNER|LEFT|RIGHT|FULL|CROSS] [OUTER|SEMI|ANTI|ANY|ALL|ASOF] JOIN","[LEFT] ARRAY JOIN"]),hf=Q(["{ROWS | RANGE} BETWEEN","ALTER MATERIALIZE STATISTICS"]),ff={name:"clickhouse",tokenizerOptions:{reservedSelect:df,reservedClauses:[...Of,...VA,...kT],reservedSetOperations:Nf,reservedJoins:If,reservedKeywordPhrases:hf,reservedKeywords:uf,reservedDataTypes:Af,reservedFunctionNames:Rf,extraParens:["[]","{}"],lineCommentTypes:["#","--"],nestedBlockComments:!1,underscoresInNumbers:!0,stringTypes:["$$","''-qq-bs"],identTypes:['""-qq-bs',"``"],paramTypes:{custom:[{regex:String.raw`\{[^:']+:[^}]+\}`,key:r=>{const l=/\{([^:]+):/.exec(r);return l?l[1].trim():r}}]},operators:["%","||","?",":","==","<=>","->"],postProcess:Cf},formatOptions:{onelineClauses:[...VA,...kT],tabularOnelineClauses:kT}};function Cf(r){return r.map((l,E)=>{const T=r[E+1]||Rr,c=r[E-1]||Rr;return l.type===Ae.RESERVED_SELECT&&(T.type===Ae.COMMA||c.type===Ae.RESERVED_CLAUSE||c.type===Ae.COMMA)?Object.assign(Object.assign({},l),{type:Ae.RESERVED_KEYWORD}):ur.SET(l)&&T.type===Ae.OPEN_PAREN?Object.assign(Object.assign({},l),{type:Ae.RESERVED_FUNCTION_NAME}):l})}const pf=["ARRAY_AGG","AVG","CORRELATION","COUNT","COUNT_BIG","COVARIANCE","COVARIANCE_SAMP","CUME_DIST","GROUPING","LISTAGG","MAX","MEDIAN","MIN","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_ICPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","STDDEV","STDDEV_SAMP","SUM","VARIANCE","VARIANCE_SAMP","XMLAGG","XMLGROUP","ABS","ABSVAL","ACOS","ADD_DAYS","ADD_HOURS","ADD_MINUTES","ADD_MONTHS","ADD_SECONDS","ADD_YEARS","AGE","ARRAY_DELETE","ARRAY_FIRST","ARRAY_LAST","ARRAY_NEXT","ARRAY_PRIOR","ASCII","ASCII_STR","ASIN","ATAN","ATAN2","ATANH","BITAND","BITANDNOT","BITOR","BITXOR","BITNOT","BPCHAR","BSON_TO_JSON","BTRIM","CARDINALITY","CEILING","CEIL","CHARACTER_LENGTH","CHR","COALESCE","COLLATION_KEY","COLLATION_KEY_BIT","COMPARE_DECFLOAT","CONCAT","COS","COSH","COT","CURSOR_ROWCOUNT","DATAPARTITIONNUM","DATE_PART","DATE_TRUNC","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFWEEK_ISO","DAYOFYEAR","DAYS","DAYS_BETWEEN","DAYS_TO_END_OF_MONTH","DBPARTITIONNUM","DECFLOAT","DECFLOAT_FORMAT","DECODE","DECRYPT_BIN","DECRYPT_CHAR","DEGREES","DEREF","DIFFERENCE","DIGITS","DOUBLE_PRECISION","EMPTY_BLOB","EMPTY_CLOB","EMPTY_DBCLOB","EMPTY_NCLOB","ENCRYPT","EVENT_MON_STATE","EXP","EXTRACT","FIRST_DAY","FLOOR","FROM_UTC_TIMESTAMP","GENERATE_UNIQUE","GETHINT","GREATEST","HASH","HASH4","HASH8","HASHEDVALUE","HEX","HEXTORAW","HOUR","HOURS_BETWEEN","IDENTITY_VAL_LOCAL","IFNULL","INITCAP","INSERT","INSTR","INSTR2","INSTR4","INSTRB","INTNAND","INTNOR","INTNXOR","INTNNOT","ISNULL","JSON_ARRAY","JSON_OBJECT","JSON_QUERY","JSON_TO_BSON","JSON_VALUE","JULIAN_DAY","LAST_DAY","LCASE","LEAST","LEFT","LENGTH","LENGTH2","LENGTH4","LENGTHB","LN","LOCATE","LOCATE_IN_STRING","LOG10","LONG_VARCHAR","LONG_VARGRAPHIC","LOWER","LPAD","LTRIM","MAX","MAX_CARDINALITY","MICROSECOND","MIDNIGHT_SECONDS","MIN","MINUTE","MINUTES_BETWEEN","MOD","MONTH","MONTHNAME","MONTHS_BETWEEN","MULTIPLY_ALT","NEXT_DAY","NEXT_MONTH","NEXT_QUARTER","NEXT_WEEK","NEXT_YEAR","NORMALIZE_DECFLOAT","NOW","NULLIF","NVL","NVL2","OCTET_LENGTH","OVERLAY","PARAMETER","POSITION","POSSTR","POW","POWER","QUANTIZE","QUARTER","QUOTE_IDENT","QUOTE_LITERAL","RADIANS","RAISE_ERROR","RAND","RANDOM","RAWTOHEX","REC2XML","REGEXP_COUNT","REGEXP_EXTRACT","REGEXP_INSTR","REGEXP_LIKE","REGEXP_MATCH_COUNT","REGEXP_REPLACE","REGEXP_SUBSTR","REPEAT","REPLACE","RID","RID_BIT","RIGHT","ROUND","ROUND_TIMESTAMP","RPAD","RTRIM","SECLABEL","SECLABEL_BY_NAME","SECLABEL_TO_CHAR","SECOND","SECONDS_BETWEEN","SIGN","SIN","SINH","SOUNDEX","SPACE","SQRT","STRIP","STRLEFT","STRPOS","STRRIGHT","SUBSTR","SUBSTR2","SUBSTR4","SUBSTRB","SUBSTRING","TABLE_NAME","TABLE_SCHEMA","TAN","TANH","THIS_MONTH","THIS_QUARTER","THIS_WEEK","THIS_YEAR","TIMESTAMP_FORMAT","TIMESTAMP_ISO","TIMESTAMPDIFF","TIMEZONE","TO_CHAR","TO_CLOB","TO_DATE","TO_HEX","TO_MULTI_BYTE","TO_NCHAR","TO_NCLOB","TO_NUMBER","TO_SINGLE_BYTE","TO_TIMESTAMP","TO_UTC_TIMESTAMP","TOTALORDER","TRANSLATE","TRIM","TRIM_ARRAY","TRUNC_TIMESTAMP","TRUNCATE","TRUNC","TYPE_ID","TYPE_NAME","TYPE_SCHEMA","UCASE","UNICODE_STR","UPPER","VALUE","VARCHAR_BIT_FORMAT","VARCHAR_FORMAT","VARCHAR_FORMAT_BIT","VERIFY_GROUP_FOR_USER","VERIFY_ROLE_FOR_USER","VERIFY_TRUSTED_CONTEXT_ROLE_FOR_USER","WEEK","WEEK_ISO","WEEKS_BETWEEN","WIDTH_BUCKET","XMLATTRIBUTES","XMLCOMMENT","XMLCONCAT","XMLDOCUMENT","XMLELEMENT","XMLFOREST","XMLNAMESPACES","XMLPARSE","XMLPI","XMLQUERY","XMLROW","XMLSERIALIZE","XMLTEXT","XMLVALIDATE","XMLXSROBJECTID","XSLTRANSFORM","YEAR","YEARS_BETWEEN","YMD_BETWEEN","BASE_TABLE","JSON_TABLE","UNNEST","XMLTABLE","RANK","DENSE_RANK","NTILE","LAG","LEAD","ROW_NUMBER","FIRST_VALUE","LAST_VALUE","NTH_VALUE","RATIO_TO_REPORT","CAST"],Lf=["ACTIVATE","ADD","AFTER","ALIAS","ALL","ALLOCATE","ALLOW","ALTER","AND","ANY","AS","ASENSITIVE","ASSOCIATE","ASUTIME","AT","ATTRIBUTES","AUDIT","AUTHORIZATION","AUX","AUXILIARY","BEFORE","BEGIN","BETWEEN","BINARY","BUFFERPOOL","BY","CACHE","CALL","CALLED","CAPTURE","CARDINALITY","CASCADED","CASE","CAST","CHECK","CLONE","CLOSE","CLUSTER","COLLECTION","COLLID","COLUMN","COMMENT","COMMIT","CONCAT","CONDITION","CONNECT","CONNECTION","CONSTRAINT","CONTAINS","CONTINUE","COUNT","COUNT_BIG","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_LC_CTYPE","CURRENT_PATH","CURRENT_SCHEMA","CURRENT_SERVER","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","CURRENT_USER","CURSOR","CYCLE","DATA","DATABASE","DATAPARTITIONNAME","DATAPARTITIONNUM","DAY","DAYS","DB2GENERAL","DB2GENRL","DB2SQL","DBINFO","DBPARTITIONNAME","DBPARTITIONNUM","DEALLOCATE","DECLARE","DEFAULT","DEFAULTS","DEFINITION","DELETE","DENSERANK","DENSE_RANK","DESCRIBE","DESCRIPTOR","DETERMINISTIC","DIAGNOSTICS","DISABLE","DISALLOW","DISCONNECT","DISTINCT","DO","DOCUMENT","DROP","DSSIZE","DYNAMIC","EACH","EDITPROC","ELSE","ELSEIF","ENABLE","ENCODING","ENCRYPTION","END","END-EXEC","ENDING","ERASE","ESCAPE","EVERY","EXCEPT","EXCEPTION","EXCLUDING","EXCLUSIVE","EXECUTE","EXISTS","EXIT","EXPLAIN","EXTENDED","EXTERNAL","EXTRACT","FENCED","FETCH","FIELDPROC","FILE","FINAL","FIRST1","FOR","FOREIGN","FREE","FROM","FULL","FUNCTION","GENERAL","GENERATED","GET","GLOBAL","GO","GOTO","GRANT","GRAPHIC","GROUP","HANDLER","HASH","HASHED_VALUE","HAVING","HINT","HOLD","HOUR","HOURS","IDENTITY","IF","IMMEDIATE","IMPORT","IN","INCLUDING","INCLUSIVE","INCREMENT","INDEX","INDICATOR","INDICATORS","INF","INFINITY","INHERIT","INNER","INOUT","INSENSITIVE","INSERT","INTEGRITY","INTERSECT","INTO","IS","ISNULL","ISOBID","ISOLATION","ITERATE","JAR","JAVA","JOIN","KEEP","KEY","LABEL","LANGUAGE","LAST3","LATERAL","LC_CTYPE","LEAVE","LEFT","LIKE","LIMIT","LINKTYPE","LOCAL","LOCALDATE","LOCALE","LOCALTIME","LOCALTIMESTAMP","LOCATOR","LOCATORS","LOCK","LOCKMAX","LOCKSIZE","LOOP","MAINTAINED","MATERIALIZED","MAXVALUE","MICROSECOND","MICROSECONDS","MINUTE","MINUTES","MINVALUE","MODE","MODIFIES","MONTH","MONTHS","NAN","NEW","NEW_TABLE","NEXTVAL","NO","NOCACHE","NOCYCLE","NODENAME","NODENUMBER","NOMAXVALUE","NOMINVALUE","NONE","NOORDER","NORMALIZED","NOT2","NOTNULL","NULL","NULLS","NUMPARTS","OBID","OF","OFF","OFFSET","OLD","OLD_TABLE","ON","OPEN","OPTIMIZATION","OPTIMIZE","OPTION","OR","ORDER","OUT","OUTER","OVER","OVERRIDING","PACKAGE","PADDED","PAGESIZE","PARAMETER","PART","PARTITION","PARTITIONED","PARTITIONING","PARTITIONS","PASSWORD","PATH","PERCENT","PIECESIZE","PLAN","POSITION","PRECISION","PREPARE","PREVVAL","PRIMARY","PRIQTY","PRIVILEGES","PROCEDURE","PROGRAM","PSID","PUBLIC","QUERY","QUERYNO","RANGE","RANK","READ","READS","RECOVERY","REFERENCES","REFERENCING","REFRESH","RELEASE","RENAME","REPEAT","RESET","RESIGNAL","RESTART","RESTRICT","RESULT","RESULT_SET_LOCATOR","RETURN","RETURNS","REVOKE","RIGHT","ROLE","ROLLBACK","ROUND_CEILING","ROUND_DOWN","ROUND_FLOOR","ROUND_HALF_DOWN","ROUND_HALF_EVEN","ROUND_HALF_UP","ROUND_UP","ROUTINE","ROW","ROWNUMBER","ROWS","ROWSET","ROW_NUMBER","RRN","RUN","SAVEPOINT","SCHEMA","SCRATCHPAD","SCROLL","SEARCH","SECOND","SECONDS","SECQTY","SECURITY","SELECT","SENSITIVE","SEQUENCE","SESSION","SESSION_USER","SET","SIGNAL","SIMPLE","SNAN","SOME","SOURCE","SPECIFIC","SQL","SQLID","STACKED","STANDARD","START","STARTING","STATEMENT","STATIC","STATMENT","STAY","STOGROUP","STORES","STYLE","SUBSTRING","SUMMARY","SYNONYM","SYSFUN","SYSIBM","SYSPROC","SYSTEM","SYSTEM_USER","TABLE","TABLESPACE","THEN","TO","TRANSACTION","TRIGGER","TRIM","TRUNCATE","TYPE","UNDO","UNION","UNIQUE","UNTIL","UPDATE","USAGE","USER","USING","VALIDPROC","VALUE","VALUES","VARIABLE","VARIANT","VCAT","VERSION","VIEW","VOLATILE","VOLUMES","WHEN","WHENEVER","WHERE","WHILE","WITH","WITHOUT","WLM","WRITE","XMLELEMENT","XMLEXISTS","XMLNAMESPACES","YEAR","YEARS"],_f=["ARRAY","BIGINT","BINARY","BLOB","BOOLEAN","CCSID","CHAR","CHARACTER","CLOB","DATE","DATETIME","DBCLOB","DEC","DECIMAL","DOUBLE","DOUBLE PRECISION","FLOAT","FLOAT4","FLOAT8","GRAPHIC","INT","INT2","INT4","INT8","INTEGER","INTERVAL","LONG VARCHAR","LONG VARGRAPHIC","NCHAR","NCHR","NCLOB","NVARCHAR","NUMERIC","SMALLINT","REAL","TIME","TIMESTAMP","VARBINARY","VARCHAR","VARGRAPHIC"],mf=Q(["SELECT [ALL | DISTINCT]"]),vf=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER BY [INPUT SEQUENCE]","LIMIT","OFFSET","FETCH NEXT","FOR UPDATE [OF]","FOR {READ | FETCH} ONLY","FOR {RR | CS | UR | RS} [USE AND KEEP {SHARE | UPDATE | EXCLUSIVE} LOCKS]","WAIT FOR OUTCOME","SKIP LOCKED DATA","INTO","INSERT INTO","VALUES","SET","MERGE INTO","WHEN [NOT] MATCHED [THEN]","UPDATE SET","INSERT"]),wA=Q(["CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"]),$T=Q(["CREATE [OR REPLACE] VIEW","UPDATE","WHERE CURRENT OF","WITH {RR | RS | CS | UR}","DELETE FROM","DROP TABLE [IF EXISTS]","ALTER TABLE","ADD [COLUMN]","DROP [COLUMN]","RENAME COLUMN","ALTER [COLUMN]","SET DATA TYPE","SET NOT NULL","DROP {DEFAULT | GENERATED | NOT NULL}","TRUNCATE [TABLE]","ALLOCATE","ALTER AUDIT POLICY","ALTER BUFFERPOOL","ALTER DATABASE PARTITION GROUP","ALTER DATABASE","ALTER EVENT MONITOR","ALTER FUNCTION","ALTER HISTOGRAM TEMPLATE","ALTER INDEX","ALTER MASK","ALTER METHOD","ALTER MODULE","ALTER NICKNAME","ALTER PACKAGE","ALTER PERMISSION","ALTER PROCEDURE","ALTER SCHEMA","ALTER SECURITY LABEL COMPONENT","ALTER SECURITY POLICY","ALTER SEQUENCE","ALTER SERVER","ALTER SERVICE CLASS","ALTER STOGROUP","ALTER TABLESPACE","ALTER THRESHOLD","ALTER TRIGGER","ALTER TRUSTED CONTEXT","ALTER TYPE","ALTER USAGE LIST","ALTER USER MAPPING","ALTER VIEW","ALTER WORK ACTION SET","ALTER WORK CLASS SET","ALTER WORKLOAD","ALTER WRAPPER","ALTER XSROBJECT","ALTER STOGROUP","ALTER TABLESPACE","ALTER TRIGGER","ALTER TRUSTED CONTEXT","ALTER VIEW","ASSOCIATE [RESULT SET] {LOCATOR | LOCATORS}","AUDIT","BEGIN DECLARE SECTION","CALL","CLOSE","COMMENT ON","COMMIT [WORK]","CONNECT","CREATE [OR REPLACE] [PUBLIC] ALIAS","CREATE AUDIT POLICY","CREATE BUFFERPOOL","CREATE DATABASE PARTITION GROUP","CREATE EVENT MONITOR","CREATE [OR REPLACE] FUNCTION","CREATE FUNCTION MAPPING","CREATE HISTOGRAM TEMPLATE","CREATE [UNIQUE] INDEX","CREATE INDEX EXTENSION","CREATE [OR REPLACE] MASK","CREATE [SPECIFIC] METHOD","CREATE [OR REPLACE] MODULE","CREATE [OR REPLACE] NICKNAME","CREATE [OR REPLACE] PERMISSION","CREATE [OR REPLACE] PROCEDURE","CREATE ROLE","CREATE SCHEMA","CREATE SECURITY LABEL [COMPONENT]","CREATE SECURITY POLICY","CREATE [OR REPLACE] SEQUENCE","CREATE SERVICE CLASS","CREATE SERVER","CREATE STOGROUP","CREATE SYNONYM","CREATE [LARGE | REGULAR | {SYSTEM | USER} TEMPORARY] TABLESPACE","CREATE THRESHOLD","CREATE {TRANSFORM | TRANSFORMS} FOR","CREATE [OR REPLACE] TRIGGER","CREATE TRUSTED CONTEXT","CREATE [OR REPLACE] TYPE","CREATE TYPE MAPPING","CREATE USAGE LIST","CREATE USER MAPPING FOR","CREATE [OR REPLACE] VARIABLE","CREATE WORK ACTION SET","CREATE WORK CLASS SET","CREATE WORKLOAD","CREATE WRAPPER","DECLARE","DECLARE GLOBAL TEMPORARY TABLE","DESCRIBE [INPUT | OUTPUT]","DISCONNECT","DROP [PUBLIC] ALIAS","DROP AUDIT POLICY","DROP BUFFERPOOL","DROP DATABASE PARTITION GROUP","DROP EVENT MONITOR","DROP [SPECIFIC] FUNCTION","DROP FUNCTION MAPPING","DROP HISTOGRAM TEMPLATE","DROP INDEX [EXTENSION]","DROP MASK","DROP [SPECIFIC] METHOD","DROP MODULE","DROP NICKNAME","DROP PACKAGE","DROP PERMISSION","DROP [SPECIFIC] PROCEDURE","DROP ROLE","DROP SCHEMA","DROP SECURITY LABEL [COMPONENT]","DROP SECURITY POLICY","DROP SEQUENCE","DROP SERVER","DROP SERVICE CLASS","DROP STOGROUP","DROP TABLE HIERARCHY","DROP {TABLESPACE | TABLESPACES}","DROP {TRANSFORM | TRANSFORMS}","DROP THRESHOLD","DROP TRIGGER","DROP TRUSTED CONTEXT","DROP TYPE [MAPPING]","DROP USAGE LIST","DROP USER MAPPING FOR","DROP VARIABLE","DROP VIEW [HIERARCHY]","DROP WORK {ACTION | CLASS} SET","DROP WORKLOAD","DROP WRAPPER","DROP XSROBJECT","END DECLARE SECTION","EXECUTE [IMMEDIATE]","EXPLAIN {PLAN [SECTION] | ALL}","FETCH [FROM]","FLUSH {BUFFERPOOL | BUFFERPOOLS} ALL","FLUSH EVENT MONITOR","FLUSH FEDERATED CACHE","FLUSH OPTIMIZATION PROFILE CACHE","FLUSH PACKAGE CACHE [DYNAMIC]","FLUSH AUTHENTICATION CACHE [FOR ALL]","FREE LOCATOR","GET DIAGNOSTICS","GOTO","GRANT","INCLUDE","ITERATE","LEAVE","LOCK TABLE","LOOP","OPEN","PIPE","PREPARE","REFRESH TABLE","RELEASE","RELEASE [TO] SAVEPOINT","RENAME [TABLE | INDEX | STOGROUP | TABLESPACE]","REPEAT","RESIGNAL","RETURN","REVOKE","ROLLBACK [WORK] [TO SAVEPOINT]","SAVEPOINT","SET COMPILATION ENVIRONMENT","SET CONNECTION","SET CURRENT","SET ENCRYPTION PASSWORD","SET EVENT MONITOR STATE","SET INTEGRITY","SET PASSTHRU","SET PATH","SET ROLE","SET SCHEMA","SET SERVER OPTION","SET {SESSION AUTHORIZATION | SESSION_USER}","SET USAGE LIST","SIGNAL","TRANSFER OWNERSHIP OF","WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}","WHILE"]),xf=Q(["UNION [ALL]","EXCEPT [ALL]","INTERSECT [ALL]"]),Df=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN"]),yf=Q(["ON DELETE","ON UPDATE","SET NULL","{ROWS | RANGE} BETWEEN"]),gf=Q([]),Mf={name:"db2",tokenizerOptions:{reservedSelect:mf,reservedClauses:[...vf,...wA,...$T],reservedSetOperations:xf,reservedJoins:Df,reservedKeywordPhrases:yf,reservedDataTypePhrases:gf,reservedKeywords:Lf,reservedDataTypes:_f,reservedFunctionNames:pf,extraParens:["[]"],stringTypes:[{quote:"''-qq",prefixes:["G","N","U&"]},{quote:"''-raw",prefixes:["X","BX","GX","UX"],requirePrefix:!0}],identTypes:['""-qq'],identChars:{first:"@#$",rest:"@#$"},paramTypes:{positional:!0,named:[":"]},paramChars:{first:"@#$",rest:"@#$"},operators:["**","%","|","&","^","~","¬=","¬>","¬<","!>","!<","^=","^>","^<","||","->","=>"]},formatOptions:{onelineClauses:[...wA,...$T],tabularOnelineClauses:$T}},Pf=["ARRAY_AGG","AVG","CORR","CORRELATION","COUNT","COUNT_BIG","COVAR_POP","COVARIANCE","COVAR","COVAR_SAMP","COVARIANCE_SAMP","EVERY","GROUPING","JSON_ARRAYAGG","JSON_OBJECTAGG","LISTAGG","MAX","MEDIAN","MIN","PERCENTILE_CONT","PERCENTILE_DISC","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","SOME","STDDEV_POP","STDDEV","STDDEV_SAMP","SUM","VAR_POP","VARIANCE","VAR","VAR_SAMP","VARIANCE_SAMP","XMLAGG","XMLGROUP","ABS","ABSVAL","ACOS","ADD_DAYS","ADD_HOURS","ADD_MINUTES","ADD_MONTHS","ADD_SECONDS","ADD_YEARS","ANTILOG","ARRAY_MAX_CARDINALITY","ARRAY_TRIM","ASCII","ASIN","ATAN","ATAN2","ATANH","BASE64_DECODE","BASE64_ENCODE","BIT_LENGTH","BITAND","BITANDNOT","BITNOT","BITOR","BITXOR","BSON_TO_JSON","CARDINALITY","CEIL","CEILING","CHAR_LENGTH","CHARACTER_LENGTH","CHR","COALESCE","COMPARE_DECFLOAT","CONCAT","CONTAINS","COS","COSH","COT","CURDATE","CURTIME","DATABASE","DATAPARTITIONNAME","DATAPARTITIONNUM","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK_ISO","DAYOFWEEK","DAYOFYEAR","DAYS","DBPARTITIONNAME","DBPARTITIONNUM","DECFLOAT_FORMAT","DECFLOAT_SORTKEY","DECRYPT_BINARY","DECRYPT_BIT","DECRYPT_CHAR","DECRYPT_DB","DEGREES","DIFFERENCE","DIGITS","DLCOMMENT","DLLINKTYPE","DLURLCOMPLETE","DLURLPATH","DLURLPATHONLY","DLURLSCHEME","DLURLSERVER","DLVALUE","DOUBLE_PRECISION","DOUBLE","ENCRPYT","ENCRYPT_AES","ENCRYPT_AES256","ENCRYPT_RC2","ENCRYPT_TDES","EXP","EXTRACT","FIRST_DAY","FLOOR","GENERATE_UNIQUE","GET_BLOB_FROM_FILE","GET_CLOB_FROM_FILE","GET_DBCLOB_FROM_FILE","GET_XML_FILE","GETHINT","GREATEST","HASH_MD5","HASH_ROW","HASH_SHA1","HASH_SHA256","HASH_SHA512","HASH_VALUES","HASHED_VALUE","HEX","HEXTORAW","HOUR","HTML_ENTITY_DECODE","HTML_ENTITY_ENCODE","HTTP_DELETE_BLOB","HTTP_DELETE","HTTP_GET_BLOB","HTTP_GET","HTTP_PATCH_BLOB","HTTP_PATCH","HTTP_POST_BLOB","HTTP_POST","HTTP_PUT_BLOB","HTTP_PUT","IDENTITY_VAL_LOCAL","IFNULL","INSERT","INSTR","INTERPRET","ISFALSE","ISNOTFALSE","ISNOTTRUE","ISTRUE","JSON_ARRAY","JSON_OBJECT","JSON_QUERY","JSON_TO_BSON","JSON_UPDATE","JSON_VALUE","JULIAN_DAY","LAND","LAST_DAY","LCASE","LEAST","LEFT","LENGTH","LN","LNOT","LOCATE_IN_STRING","LOCATE","LOG10","LOR","LOWER","LPAD","LTRIM","MAX_CARDINALITY","MAX","MICROSECOND","MIDNIGHT_SECONDS","MIN","MINUTE","MOD","MONTH","MONTHNAME","MONTHS_BETWEEN","MQREAD","MQREADCLOB","MQRECEIVE","MQRECEIVECLOB","MQSEND","MULTIPLY_ALT","NEXT_DAY","NORMALIZE_DECFLOAT","NOW","NULLIF","NVL","OCTET_LENGTH","OVERLAY","PI","POSITION","POSSTR","POW","POWER","QUANTIZE","QUARTER","RADIANS","RAISE_ERROR","RANDOM","RAND","REGEXP_COUNT","REGEXP_INSTR","REGEXP_REPLACE","REGEXP_SUBSTR","REPEAT","REPLACE","RID","RIGHT","ROUND_TIMESTAMP","ROUND","RPAD","RRN","RTRIM","SCORE","SECOND","SIGN","SIN","SINH","SOUNDEX","SPACE","SQRT","STRIP","STRLEFT","STRPOS","STRRIGHT","SUBSTR","SUBSTRING","TABLE_NAME","TABLE_SCHEMA","TAN","TANH","TIMESTAMP_FORMAT","TIMESTAMP_ISO","TIMESTAMPDIFF_BIG","TIMESTAMPDIFF","TO_CHAR","TO_CLOB","TO_DATE","TO_NUMBER","TO_TIMESTAMP","TOTALORDER","TRANSLATE","TRIM_ARRAY","TRIM","TRUNC_TIMESTAMP","TRUNC","TRUNCATE","UCASE","UPPER","URL_DECODE","URL_ENCODE","VALUE","VARBINARY_FORMAT","VARCHAR_BIT_FORMAT","VARCHAR_FORMAT_BINARY","VARCHAR_FORMAT","VERIFY_GROUP_FOR_USER","WEEK_ISO","WEEK","WRAP","XMLATTRIBUTES","XMLCOMMENT","XMLCONCAT","XMLDOCUMENT","XMLELEMENT","XMLFOREST","XMLNAMESPACES","XMLPARSE","XMLPI","XMLROW","XMLSERIALIZE","XMLTEXT","XMLVALIDATE","XOR","XSLTRANSFORM","YEAR","ZONED","BASE_TABLE","HTTP_DELETE_BLOB_VERBOSE","HTTP_DELETE_VERBOSE","HTTP_GET_BLOB_VERBOSE","HTTP_GET_VERBOSE","HTTP_PATCH_BLOB_VERBOSE","HTTP_PATCH_VERBOSE","HTTP_POST_BLOB_VERBOSE","HTTP_POST_VERBOSE","HTTP_PUT_BLOB_VERBOSE","HTTP_PUT_VERBOSE","JSON_TABLE","MQREADALL","MQREADALLCLOB","MQRECEIVEALL","MQRECEIVEALLCLOB","XMLTABLE","UNPACK","CUME_DIST","DENSE_RANK","FIRST_VALUE","LAG","LAST_VALUE","LEAD","NTH_VALUE","NTILE","PERCENT_RANK","RANK","RATIO_TO_REPORT","ROW_NUMBER","CAST"],Uf=["ABSENT","ACCORDING","ACCTNG","ACTION","ACTIVATE","ADD","ALIAS","ALL","ALLOCATE","ALLOW","ALTER","AND","ANY","APPEND","APPLNAME","ARRAY","ARRAY_AGG","ARRAY_TRIM","AS","ASC","ASENSITIVE","ASSOCIATE","ATOMIC","ATTACH","ATTRIBUTES","AUTHORIZATION","AUTONOMOUS","BEFORE","BEGIN","BETWEEN","BIND","BSON","BUFFERPOOL","BY","CACHE","CALL","CALLED","CARDINALITY","CASE","CAST","CHECK","CL","CLOSE","CLUSTER","COLLECT","COLLECTION","COLUMN","COMMENT","COMMIT","COMPACT","COMPARISONS","COMPRESS","CONCAT","CONCURRENT","CONDITION","CONNECT","CONNECT_BY_ROOT","CONNECTION","CONSTANT","CONSTRAINT","CONTAINS","CONTENT","CONTINUE","COPY","COUNT","COUNT_BIG","CREATE","CREATEIN","CROSS","CUBE","CUME_DIST","CURRENT","CURRENT_DATE","CURRENT_PATH","CURRENT_SCHEMA","CURRENT_SERVER","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","CURRENT_USER","CURSOR","CYCLE","DATABASE","DATAPARTITIONNAME","DATAPARTITIONNUM","DAY","DAYS","DB2GENERAL","DB2GENRL","DB2SQL","DBINFO","DBPARTITIONNAME","DBPARTITIONNUM","DEACTIVATE","DEALLOCATE","DECLARE","DEFAULT","DEFAULTS","DEFER","DEFINE","DEFINITION","DELETE","DELETING","DENSE_RANK","DENSERANK","DESC","DESCRIBE","DESCRIPTOR","DETACH","DETERMINISTIC","DIAGNOSTICS","DISABLE","DISALLOW","DISCONNECT","DISTINCT","DO","DOCUMENT","DROP","DYNAMIC","EACH","ELSE","ELSEIF","EMPTY","ENABLE","ENCODING","ENCRYPTION","END","END-EXEC","ENDING","ENFORCED","ERROR","ESCAPE","EVERY","EXCEPT","EXCEPTION","EXCLUDING","EXCLUSIVE","EXECUTE","EXISTS","EXIT","EXTEND","EXTERNAL","EXTRACT","FALSE","FENCED","FETCH","FIELDPROC","FILE","FINAL","FIRST_VALUE","FOR","FOREIGN","FORMAT","FREE","FREEPAGE","FROM","FULL","FUNCTION","GBPCACHE","GENERAL","GENERATED","GET","GLOBAL","GO","GOTO","GRANT","GROUP","HANDLER","HASH","HASH_ROW","HASHED_VALUE","HAVING","HINT","HOLD","HOUR","HOURS","IDENTITY","IF","IGNORE","IMMEDIATE","IMPLICITLY","IN","INCLUDE","INCLUDING","INCLUSIVE","INCREMENT","INDEX","INDEXBP","INDICATOR","INF","INFINITY","INHERIT","INLINE","INNER","INOUT","INSENSITIVE","INSERT","INSERTING","INTEGRITY","INTERPRET","INTERSECT","INTO","IS","ISNULL","ISOLATION","ITERATE","JAVA","JOIN","JSON","JSON_ARRAY","JSON_ARRAYAGG","JSON_EXISTS","JSON_OBJECT","JSON_OBJECTAGG","JSON_QUERY","JSON_TABLE","JSON_VALUE","KEEP","KEY","KEYS","LABEL","LAG","LANGUAGE","LAST_VALUE","LATERAL","LEAD","LEAVE","LEFT","LEVEL2","LIKE","LIMIT","LINKTYPE","LISTAGG","LOCAL","LOCALDATE","LOCALTIME","LOCALTIMESTAMP","LOCATION","LOCATOR","LOCK","LOCKSIZE","LOG","LOGGED","LOOP","MAINTAINED","MASK","MATCHED","MATERIALIZED","MAXVALUE","MERGE","MICROSECOND","MICROSECONDS","MINPCTUSED","MINUTE","MINUTES","MINVALUE","MIRROR","MIXED","MODE","MODIFIES","MONTH","MONTHS","NAMESPACE","NAN","NATIONAL","NCHAR","NCLOB","NESTED","NEW","NEW_TABLE","NEXTVAL","NO","NOCACHE","NOCYCLE","NODENAME","NODENUMBER","NOMAXVALUE","NOMINVALUE","NONE","NOORDER","NORMALIZED","NOT","NOTNULL","NTH_VALUE","NTILE","NULL","NULLS","NVARCHAR","OBID","OBJECT","OF","OFF","OFFSET","OLD","OLD_TABLE","OMIT","ON","ONLY","OPEN","OPTIMIZE","OPTION","OR","ORDER","ORDINALITY","ORGANIZE","OUT","OUTER","OVER","OVERLAY","OVERRIDING","PACKAGE","PADDED","PAGE","PAGESIZE","PARAMETER","PART","PARTITION","PARTITIONED","PARTITIONING","PARTITIONS","PASSING","PASSWORD","PATH","PCTFREE","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","PERIOD","PERMISSION","PIECESIZE","PIPE","PLAN","POSITION","PREPARE","PREVVAL","PRIMARY","PRIOR","PRIQTY","PRIVILEGES","PROCEDURE","PROGRAM","PROGRAMID","QUERY","RANGE","RANK","RATIO_TO_REPORT","RCDFMT","READ","READS","RECOVERY","REFERENCES","REFERENCING","REFRESH","REGEXP_LIKE","RELEASE","RENAME","REPEAT","RESET","RESIGNAL","RESTART","RESULT","RESULT_SET_LOCATOR","RETURN","RETURNING","RETURNS","REVOKE","RID","RIGHT","ROLLBACK","ROLLUP","ROUTINE","ROW","ROW_NUMBER","ROWNUMBER","ROWS","RRN","RUN","SAVEPOINT","SBCS","SCALAR","SCHEMA","SCRATCHPAD","SCROLL","SEARCH","SECOND","SECONDS","SECQTY","SECURED","SELECT","SENSITIVE","SEQUENCE","SESSION","SESSION_USER","SET","SIGNAL","SIMPLE","SKIP","SNAN","SOME","SOURCE","SPECIFIC","SQL","SQLID","SQLIND_DEFAULT","SQLIND_UNASSIGNED","STACKED","START","STARTING","STATEMENT","STATIC","STOGROUP","SUBSTRING","SUMMARY","SYNONYM","SYSTEM_TIME","SYSTEM_USER","TABLE","TABLESPACE","TABLESPACES","TAG","THEN","THREADSAFE","TO","TRANSACTION","TRANSFER","TRIGGER","TRIM","TRIM_ARRAY","TRUE","TRUNCATE","TRY_CAST","TYPE","UNDO","UNION","UNIQUE","UNIT","UNKNOWN","UNNEST","UNTIL","UPDATE","UPDATING","URI","USAGE","USE","USER","USERID","USING","VALUE","VALUES","VARIABLE","VARIANT","VCAT","VERSION","VERSIONING","VIEW","VOLATILE","WAIT","WHEN","WHENEVER","WHERE","WHILE","WITH","WITHIN","WITHOUT","WRAPPED","WRAPPER","WRITE","WRKSTNNAME","XMLAGG","XMLATTRIBUTES","XMLCAST","XMLCOMMENT","XMLCONCAT","XMLDOCUMENT","XMLELEMENT","XMLFOREST","XMLGROUP","XMLNAMESPACES","XMLPARSE","XMLPI","XMLROW","XMLSERIALIZE","XMLTABLE","XMLTEXT","XMLVALIDATE","XSLTRANSFORM","XSROBJECT","YEAR","YEARS","YES","ZONE"],bf=["ARRAY","BIGINT","BINARY","BIT","BLOB","BOOLEAN","CCSID","CHAR","CHARACTER","CLOB","DATA","DATALINK","DATE","DBCLOB","DECFLOAT","DECIMAL","DEC","DOUBLE","DOUBLE PRECISION","FLOAT","GRAPHIC","INT","INTEGER","LONG","NUMERIC","REAL","ROWID","SMALLINT","TIME","TIMESTAMP","VARBINARY","VARCHAR","VARGRAPHIC","XML"],Gf=Q(["SELECT [ALL | DISTINCT]"]),Bf=Q(["WITH [RECURSIVE]","INTO","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER [SIBLINGS] BY [INPUT SEQUENCE]","LIMIT","OFFSET","FETCH {FIRST | NEXT}","FOR UPDATE [OF]","FOR READ ONLY","OPTIMIZE FOR","INSERT INTO","VALUES","SET","MERGE INTO","WHEN [NOT] MATCHED [THEN]","UPDATE SET","DELETE","INSERT","FOR SYSTEM NAME"]),WA=Q(["CREATE [OR REPLACE] TABLE"]),JT=Q(["CREATE [OR REPLACE] [RECURSIVE] VIEW","UPDATE","WHERE CURRENT OF","WITH {NC | RR | RS | CS | UR}","DELETE FROM","DROP TABLE","ALTER TABLE","ADD [COLUMN]","ALTER [COLUMN]","DROP [COLUMN]","SET DATA TYPE","SET {GENERATED ALWAYS | GENERATED BY DEFAULT}","SET NOT NULL","SET {NOT HIDDEN | IMPLICITLY HIDDEN}","SET FIELDPROC","DROP {DEFAULT | NOT NULL | GENERATED | IDENTITY | ROW CHANGE TIMESTAMP | FIELDPROC}","TRUNCATE [TABLE]","SET [CURRENT] SCHEMA","SET CURRENT_SCHEMA","ALLOCATE CURSOR","ALLOCATE [SQL] DESCRIPTOR [LOCAL | GLOBAL] SQL","ALTER [SPECIFIC] {FUNCTION | PROCEDURE}","ALTER {MASK | PERMISSION | SEQUENCE | TRIGGER}","ASSOCIATE [RESULT SET] {LOCATOR | LOCATORS}","BEGIN DECLARE SECTION","CALL","CLOSE","COMMENT ON {ALIAS | COLUMN | CONSTRAINT | INDEX | MASK | PACKAGE | PARAMETER | PERMISSION | SEQUENCE | TABLE | TRIGGER | VARIABLE | XSROBJECT}","COMMENT ON [SPECIFIC] {FUNCTION | PROCEDURE | ROUTINE}","COMMENT ON PARAMETER SPECIFIC {FUNCTION | PROCEDURE | ROUTINE}","COMMENT ON [TABLE FUNCTION] RETURN COLUMN","COMMENT ON [TABLE FUNCTION] RETURN COLUMN SPECIFIC [PROCEDURE | ROUTINE]","COMMIT [WORK] [HOLD]","CONNECT [TO | RESET] USER","CREATE [OR REPLACE] {ALIAS | FUNCTION | MASK | PERMISSION | PROCEDURE | SEQUENCE | TRIGGER | VARIABLE}","CREATE [ENCODED VECTOR] INDEX","CREATE UNIQUE [WHERE NOT NULL] INDEX","CREATE SCHEMA","CREATE TYPE","DEALLOCATE [SQL] DESCRIPTOR [LOCAL | GLOBAL]","DECLARE CURSOR","DECLARE GLOBAL TEMPORARY TABLE","DECLARE","DESCRIBE CURSOR","DESCRIBE INPUT","DESCRIBE [OUTPUT]","DESCRIBE {PROCEDURE | ROUTINE}","DESCRIBE TABLE","DISCONNECT ALL [SQL]","DISCONNECT [CURRENT]","DROP {ALIAS | INDEX | MASK | PACKAGE | PERMISSION | SCHEMA | SEQUENCE | TABLE | TYPE | VARIABLE | XSROBJECT} [IF EXISTS]","DROP [SPECIFIC] {FUNCTION | PROCEDURE | ROUTINE} [IF EXISTS]","END DECLARE SECTION","EXECUTE [IMMEDIATE]","FREE LOCATOR","GET [SQL] DESCRIPTOR [LOCAL | GLOBAL]","GET [CURRENT | STACKED] DIAGNOSTICS","GRANT {ALL [PRIVILEGES] | ALTER | EXECUTE} ON {FUNCTION | PROCEDURE | ROUTINE | PACKAGE | SCHEMA | SEQUENCE | TABLE | TYPE | VARIABLE | XSROBJECT}","HOLD LOCATOR","INCLUDE","LABEL ON {ALIAS | COLUMN | CONSTRAINT | INDEX | MASK | PACKAGE | PERMISSION | SEQUENCE | TABLE | TRIGGER | VARIABLE | XSROBJECT}","LABEL ON [SPECIFIC] {FUNCTION | PROCEDURE | ROUTINE}","LOCK TABLE","OPEN","PREPARE","REFRESH TABLE","RELEASE","RELEASE [TO] SAVEPOINT","RENAME [TABLE | INDEX] TO","REVOKE {ALL [PRIVILEGES] | ALTER | EXECUTE} ON {FUNCTION | PROCEDURE | ROUTINE | PACKAGE | SCHEMA | SEQUENCE | TABLE | TYPE | VARIABLE | XSROBJECT}","ROLLBACK [WORK] [HOLD | TO SAVEPOINT]","SAVEPOINT","SET CONNECTION","SET CURRENT {DEBUG MODE | DECFLOAT ROUNDING MODE | DEGREE | IMPLICIT XMLPARSE OPTION | TEMPORAL SYSTEM_TIME}","SET [SQL] DESCRIPTOR [LOCAL | GLOBAL]","SET ENCRYPTION PASSWORD","SET OPTION","SET {[CURRENT [FUNCTION]] PATH | CURRENT_PATH}","SET RESULT SETS [WITH RETURN [TO CALLER | TO CLIENT]]","SET SESSION AUTHORIZATION","SET SESSION_USER","SET TRANSACTION","SIGNAL SQLSTATE [VALUE]","TAG","TRANSFER OWNERSHIP OF","WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"]),Hf=Q(["UNION [ALL]","EXCEPT [ALL]","INTERSECT [ALL]"]),Ff=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","[LEFT | RIGHT] EXCEPTION JOIN","{INNER | CROSS} JOIN"]),Yf=Q(["ON DELETE","ON UPDATE","SET NULL","{ROWS | RANGE} BETWEEN"]),jf=Q([]),Vf={name:"db2i",tokenizerOptions:{reservedSelect:Gf,reservedClauses:[...Bf,...WA,...JT],reservedSetOperations:Hf,reservedJoins:Ff,reservedKeywordPhrases:Yf,reservedDataTypePhrases:jf,reservedKeywords:Uf,reservedDataTypes:bf,reservedFunctionNames:Pf,nestedBlockComments:!0,extraParens:["[]"],stringTypes:[{quote:"''-qq",prefixes:["G","N"]},{quote:"''-raw",prefixes:["X","BX","GX","UX"],requirePrefix:!0}],identTypes:['""-qq'],identChars:{first:"@#$",rest:"@#$"},paramTypes:{positional:!0,named:[":"]},paramChars:{first:"@#$",rest:"@#$"},operators:["**","¬=","¬>","¬<","!>","!<","||","=>"]},formatOptions:{onelineClauses:[...WA,...JT],tabularOnelineClauses:JT}},wf=["ABS","ACOS","ADD","ADD_PARQUET_KEY","AGE","AGGREGATE","ALIAS","ALL_PROFILING_OUTPUT","ANY_VALUE","APPLY","APPROX_COUNT_DISTINCT","APPROX_QUANTILE","ARBITRARY","ARGMAX","ARGMIN","ARG_MAX","ARG_MAX_NULL","ARG_MIN","ARG_MIN_NULL","ARRAY_AGG","ARRAY_AGGR","ARRAY_AGGREGATE","ARRAY_APPEND","ARRAY_APPLY","ARRAY_CAT","ARRAY_CONCAT","ARRAY_CONTAINS","ARRAY_COSINE_SIMILARITY","ARRAY_CROSS_PRODUCT","ARRAY_DISTANCE","ARRAY_DISTINCT","ARRAY_DOT_PRODUCT","ARRAY_EXTRACT","ARRAY_FILTER","ARRAY_GRADE_UP","ARRAY_HAS","ARRAY_HAS_ALL","ARRAY_HAS_ANY","ARRAY_INDEXOF","ARRAY_INNER_PRODUCT","ARRAY_INTERSECT","ARRAY_LENGTH","ARRAY_POP_BACK","ARRAY_POP_FRONT","ARRAY_POSITION","ARRAY_PREPEND","ARRAY_PUSH_BACK","ARRAY_PUSH_FRONT","ARRAY_REDUCE","ARRAY_RESIZE","ARRAY_REVERSE","ARRAY_REVERSE_SORT","ARRAY_SELECT","ARRAY_SLICE","ARRAY_SORT","ARRAY_TO_JSON","ARRAY_TO_STRING","ARRAY_TRANSFORM","ARRAY_UNIQUE","ARRAY_VALUE","ARRAY_WHERE","ARRAY_ZIP","ARROW_SCAN","ARROW_SCAN_DUMB","ASCII","ASIN","ATAN","ATAN2","AVG","BASE64","BIN","BITSTRING","BITSTRING_AGG","BIT_AND","BIT_COUNT","BIT_LENGTH","BIT_OR","BIT_POSITION","BIT_XOR","BOOL_AND","BOOL_OR","CARDINALITY","CBRT","CEIL","CEILING","CENTURY","CHECKPOINT","CHR","COLLATIONS","COL_DESCRIPTION","COMBINE","CONCAT","CONCAT_WS","CONSTANT_OR_NULL","CONTAINS","COPY_DATABASE","CORR","COS","COT","COUNT","COUNT_IF","COUNT_STAR","COVAR_POP","COVAR_SAMP","CREATE_SORT_KEY","CURRENT_CATALOG","CURRENT_DATABASE","CURRENT_DATE","CURRENT_LOCALTIME","CURRENT_LOCALTIMESTAMP","CURRENT_QUERY","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_SCHEMAS","CURRENT_SETTING","CURRENT_USER","CURRVAL","DAMERAU_LEVENSHTEIN","DATABASE_LIST","DATABASE_SIZE","DATEDIFF","DATEPART","DATESUB","DATETRUNC","DATE_ADD","DATE_DIFF","DATE_PART","DATE_SUB","DATE_TRUNC","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","DECADE","DECODE","DEGREES","DISABLE_CHECKPOINT_ON_SHUTDOWN","DISABLE_OBJECT_CACHE","DISABLE_OPTIMIZER","DISABLE_PRINT_PROGRESS_BAR","DISABLE_PROFILE","DISABLE_PROFILING","DISABLE_PROGRESS_BAR","DISABLE_VERIFICATION","DISABLE_VERIFY_EXTERNAL","DISABLE_VERIFY_FETCH_ROW","DISABLE_VERIFY_PARALLELISM","DISABLE_VERIFY_SERIALIZER","DIVIDE","DUCKDB_COLUMNS","DUCKDB_CONSTRAINTS","DUCKDB_DATABASES","DUCKDB_DEPENDENCIES","DUCKDB_EXTENSIONS","DUCKDB_FUNCTIONS","DUCKDB_INDEXES","DUCKDB_KEYWORDS","DUCKDB_MEMORY","DUCKDB_OPTIMIZERS","DUCKDB_SCHEMAS","DUCKDB_SECRETS","DUCKDB_SEQUENCES","DUCKDB_SETTINGS","DUCKDB_TABLES","DUCKDB_TEMPORARY_FILES","DUCKDB_TYPES","DUCKDB_VIEWS","EDIT","EDITDIST3","ELEMENT_AT","ENABLE_CHECKPOINT_ON_SHUTDOWN","ENABLE_OBJECT_CACHE","ENABLE_OPTIMIZER","ENABLE_PRINT_PROGRESS_BAR","ENABLE_PROFILE","ENABLE_PROFILING","ENABLE_PROGRESS_BAR","ENABLE_VERIFICATION","ENCODE","ENDS_WITH","ENTROPY","ENUM_CODE","ENUM_FIRST","ENUM_LAST","ENUM_RANGE","ENUM_RANGE_BOUNDARY","EPOCH","EPOCH_MS","EPOCH_NS","EPOCH_US","ERA","ERROR","EVEN","EXP","FACTORIAL","FAVG","FDIV","FILTER","FINALIZE","FIRST","FLATTEN","FLOOR","FMOD","FORCE_CHECKPOINT","FORMAT","FORMATREADABLEDECIMALSIZE","FORMATREADABLESIZE","FORMAT_BYTES","FORMAT_PG_TYPE","FORMAT_TYPE","FROM_BASE64","FROM_BINARY","FROM_HEX","FROM_JSON","FROM_JSON_STRICT","FSUM","FUNCTIONS","GAMMA","GCD","GENERATE_SERIES","GENERATE_SUBSCRIPTS","GEN_RANDOM_UUID","GEOMEAN","GEOMETRIC_MEAN","GETENV","GET_BIT","GET_BLOCK_SIZE","GET_CURRENT_TIME","GET_CURRENT_TIMESTAMP","GLOB","GRADE_UP","GREATEST","GREATEST_COMMON_DIVISOR","GROUP_CONCAT","HAMMING","HASH","HAS_ANY_COLUMN_PRIVILEGE","HAS_COLUMN_PRIVILEGE","HAS_DATABASE_PRIVILEGE","HAS_FOREIGN_DATA_WRAPPER_PRIVILEGE","HAS_FUNCTION_PRIVILEGE","HAS_LANGUAGE_PRIVILEGE","HAS_SCHEMA_PRIVILEGE","HAS_SEQUENCE_PRIVILEGE","HAS_SERVER_PRIVILEGE","HAS_TABLESPACE_PRIVILEGE","HAS_TABLE_PRIVILEGE","HEX","HISTOGRAM","HOUR","ICU_CALENDAR_NAMES","ICU_SORT_KEY","ILIKE_ESCAPE","IMPORT_DATABASE","INDEX_SCAN","INET_CLIENT_ADDR","INET_CLIENT_PORT","INET_SERVER_ADDR","INET_SERVER_PORT","INSTR","IN_SEARCH_PATH","ISFINITE","ISINF","ISNAN","ISODOW","ISOYEAR","JACCARD","JARO_SIMILARITY","JARO_WINKLER_SIMILARITY","JSON_ARRAY","JSON_ARRAY_LENGTH","JSON_CONTAINS","JSON_DESERIALIZE_SQL","JSON_EXECUTE_SERIALIZED_SQL","JSON_EXTRACT","JSON_EXTRACT_PATH","JSON_EXTRACT_PATH_TEXT","JSON_EXTRACT_STRING","JSON_GROUP_ARRAY","JSON_GROUP_OBJECT","JSON_GROUP_STRUCTURE","JSON_KEYS","JSON_MERGE_PATCH","JSON_OBJECT","JSON_QUOTE","JSON_SERIALIZE_PLAN","JSON_SERIALIZE_SQL","JSON_STRUCTURE","JSON_TRANSFORM","JSON_TRANSFORM_STRICT","JSON_TYPE","JSON_VALID","JULIAN","KAHAN_SUM","KURTOSIS","KURTOSIS_POP","LAST","LAST_DAY","LCASE","LCM","LEAST","LEAST_COMMON_MULTIPLE","LEFT","LEFT_GRAPHEME","LEN","LENGTH","LENGTH_GRAPHEME","LEVENSHTEIN","LGAMMA","LIKE_ESCAPE","LIST","LISTAGG","LIST_AGGR","LIST_AGGREGATE","LIST_ANY_VALUE","LIST_APPEND","LIST_APPLY","LIST_APPROX_COUNT_DISTINCT","LIST_AVG","LIST_BIT_AND","LIST_BIT_OR","LIST_BIT_XOR","LIST_BOOL_AND","LIST_BOOL_OR","LIST_CAT","LIST_CONCAT","LIST_CONTAINS","LIST_COSINE_SIMILARITY","LIST_COUNT","LIST_DISTANCE","LIST_DISTINCT","LIST_DOT_PRODUCT","LIST_ELEMENT","LIST_ENTROPY","LIST_EXTRACT","LIST_FILTER","LIST_FIRST","LIST_GRADE_UP","LIST_HAS","LIST_HAS_ALL","LIST_HAS_ANY","LIST_HISTOGRAM","LIST_INDEXOF","LIST_INNER_PRODUCT","LIST_INTERSECT","LIST_KURTOSIS","LIST_KURTOSIS_POP","LIST_LAST","LIST_MAD","LIST_MAX","LIST_MEDIAN","LIST_MIN","LIST_MODE","LIST_PACK","LIST_POSITION","LIST_PREPEND","LIST_PRODUCT","LIST_REDUCE","LIST_RESIZE","LIST_REVERSE","LIST_REVERSE_SORT","LIST_SELECT","LIST_SEM","LIST_SKEWNESS","LIST_SLICE","LIST_SORT","LIST_STDDEV_POP","LIST_STDDEV_SAMP","LIST_STRING_AGG","LIST_SUM","LIST_TRANSFORM","LIST_UNIQUE","LIST_VALUE","LIST_VAR_POP","LIST_VAR_SAMP","LIST_WHERE","LIST_ZIP","LN","LOG","LOG10","LOG2","LOWER","LPAD","LSMODE","LTRIM","MAD","MAKE_DATE","MAKE_TIME","MAKE_TIMESTAMP","MAKE_TIMESTAMPTZ","MAP","MAP_CONCAT","MAP_ENTRIES","MAP_EXTRACT","MAP_FROM_ENTRIES","MAP_KEYS","MAP_VALUES","MAX","MAX_BY","MD5","MD5_NUMBER","MD5_NUMBER_LOWER","MD5_NUMBER_UPPER","MEAN","MEDIAN","METADATA_INFO","MICROSECOND","MILLENNIUM","MILLISECOND","MIN","MINUTE","MIN_BY","MISMATCHES","MOD","MODE","MONTH","MONTHNAME","MULTIPLY","NEXTAFTER","NEXTVAL","NFC_NORMALIZE","NOT_ILIKE_ESCAPE","NOT_LIKE_ESCAPE","NOW","NULLIF","OBJ_DESCRIPTION","OCTET_LENGTH","ORD","PARQUET_FILE_METADATA","PARQUET_KV_METADATA","PARQUET_METADATA","PARQUET_SCAN","PARQUET_SCHEMA","PARSE_DIRNAME","PARSE_DIRPATH","PARSE_FILENAME","PARSE_PATH","PG_COLLATION_IS_VISIBLE","PG_CONF_LOAD_TIME","PG_CONVERSION_IS_VISIBLE","PG_FUNCTION_IS_VISIBLE","PG_GET_CONSTRAINTDEF","PG_GET_EXPR","PG_GET_VIEWDEF","PG_HAS_ROLE","PG_IS_OTHER_TEMP_SCHEMA","PG_MY_TEMP_SCHEMA","PG_OPCLASS_IS_VISIBLE","PG_OPERATOR_IS_VISIBLE","PG_OPFAMILY_IS_VISIBLE","PG_POSTMASTER_START_TIME","PG_SIZE_PRETTY","PG_TABLE_IS_VISIBLE","PG_TIMEZONE_NAMES","PG_TS_CONFIG_IS_VISIBLE","PG_TS_DICT_IS_VISIBLE","PG_TS_PARSER_IS_VISIBLE","PG_TS_TEMPLATE_IS_VISIBLE","PG_TYPEOF","PG_TYPE_IS_VISIBLE","PI","PLATFORM","POSITION","POW","POWER","PRAGMA_COLLATIONS","PRAGMA_DATABASE_SIZE","PRAGMA_METADATA_INFO","PRAGMA_PLATFORM","PRAGMA_SHOW","PRAGMA_STORAGE_INFO","PRAGMA_TABLE_INFO","PRAGMA_USER_AGENT","PRAGMA_VERSION","PREFIX","PRINTF","PRODUCT","QUANTILE","QUANTILE_CONT","QUANTILE_DISC","QUARTER","RADIANS","RANDOM","RANGE","READFILE","READ_BLOB","READ_CSV","READ_CSV_AUTO","READ_JSON","READ_JSON_AUTO","READ_JSON_OBJECTS","READ_JSON_OBJECTS_AUTO","READ_NDJSON","READ_NDJSON_AUTO","READ_NDJSON_OBJECTS","READ_PARQUET","READ_TEXT","REDUCE","REGEXP_ESCAPE","REGEXP_EXTRACT","REGEXP_EXTRACT_ALL","REGEXP_FULL_MATCH","REGEXP_MATCHES","REGEXP_REPLACE","REGEXP_SPLIT_TO_ARRAY","REGEXP_SPLIT_TO_TABLE","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","REPEAT","REPEAT_ROW","REPLACE","RESERVOIR_QUANTILE","REVERSE","RIGHT","RIGHT_GRAPHEME","ROUND","ROUNDBANKERS","ROUND_EVEN","ROW","ROW_TO_JSON","RPAD","RTRIM","SECOND","SEM","SEQ_SCAN","SESSION_USER","SETSEED","SET_BIT","SHA256","SHA3","SHELL_ADD_SCHEMA","SHELL_ESCAPE_CRNL","SHELL_IDQUOTE","SHELL_MODULE_SCHEMA","SHELL_PUTSNL","SHOBJ_DESCRIPTION","SHOW","SHOW_DATABASES","SHOW_TABLES","SHOW_TABLES_EXPANDED","SIGN","SIGNBIT","SIN","SKEWNESS","SNIFF_CSV","SPLIT","SPLIT_PART","SQL_AUTO_COMPLETE","SQRT","STARTS_WITH","STATS","STDDEV","STDDEV_POP","STDDEV_SAMP","STORAGE_INFO","STRFTIME","STRING_AGG","STRING_SPLIT","STRING_SPLIT_REGEX","STRING_TO_ARRAY","STRIP_ACCENTS","STRLEN","STRPOS","STRPTIME","STRUCT_EXTRACT","STRUCT_INSERT","STRUCT_PACK","STR_SPLIT","STR_SPLIT_REGEX","SUBSTR","SUBSTRING","SUBSTRING_GRAPHEME","SUBTRACT","SUFFIX","SUM","SUMKAHAN","SUMMARY","SUM_NO_OVERFLOW","TABLE_INFO","TAN","TEST_ALL_TYPES","TEST_VECTOR_TYPES","TIMEZONE","TIMEZONE_HOUR","TIMEZONE_MINUTE","TIME_BUCKET","TODAY","TO_BASE","TO_BASE64","TO_BINARY","TO_CENTURIES","TO_DAYS","TO_DECADES","TO_HEX","TO_HOURS","TO_JSON","TO_MICROSECONDS","TO_MILLENNIA","TO_MILLISECONDS","TO_MINUTES","TO_MONTHS","TO_SECONDS","TO_TIMESTAMP","TO_WEEKS","TO_YEARS","TRANSACTION_TIMESTAMP","TRANSLATE","TRIM","TRUNC","TRY_STRPTIME","TXID_CURRENT","TYPEOF","UCASE","UNBIN","UNHEX","UNICODE","UNION_EXTRACT","UNION_TAG","UNION_VALUE","UNNEST","UNPIVOT_LIST","UPPER","USER","USER_AGENT","UUID","VARIANCE","VAR_POP","VAR_SAMP","VECTOR_TYPE","VERIFY_EXTERNAL","VERIFY_FETCH_ROW","VERIFY_PARALLELISM","VERIFY_SERIALIZER","VERSION","WEEK","WEEKDAY","WEEKOFYEAR","WHICH_SECRET","WRITEFILE","XOR","YEAR","YEARWEEK","CAST","COALESCE","RANK","ROW_NUMBER"],Wf=["ALL","ANALYSE","ANALYZE","AND","ANY","AS","ASC","ATTACH","ASYMMETRIC","BOTH","CASE","CAST","CHECK","COLLATE","COLUMN","CONSTRAINT","CREATE","DEFAULT","DEFERRABLE","DESC","DESCRIBE","DETACH","DISTINCT","DO","ELSE","END","EXCEPT","FALSE","FETCH","FOR","FOREIGN","FROM","GRANT","GROUP","HAVING","IN","INITIALLY","INTERSECT","INTO","IS","LATERAL","LEADING","LIMIT","NOT","NULL","OFFSET","ON","ONLY","OR","ORDER","PIVOT","PIVOT_LONGER","PIVOT_WIDER","PLACING","PRIMARY","REFERENCES","RETURNING","SELECT","SHOW","SOME","SUMMARIZE","SYMMETRIC","TABLE","THEN","TO","TRAILING","TRUE","UNION","UNIQUE","UNPIVOT","USING","VARIADIC","WHEN","WHERE","WINDOW","WITH"],Xf=["ARRAY","BIGINT","BINARY","BIT","BITSTRING","BLOB","BOOL","BOOLEAN","BPCHAR","BYTEA","CHAR","DATE","DATETIME","DEC","DECIMAL","DOUBLE","ENUM","FLOAT","FLOAT4","FLOAT8","GUID","HUGEINT","INET","INT","INT1","INT128","INT16","INT2","INT32","INT4","INT64","INT8","INTEGER","INTEGRAL","INTERVAL","JSON","LIST","LOGICAL","LONG","MAP","NUMERIC","NVARCHAR","OID","REAL","ROW","SHORT","SIGNED","SMALLINT","STRING","STRUCT","TEXT","TIME","TIMESTAMP_MS","TIMESTAMP_NS","TIMESTAMP_S","TIMESTAMP_US","TIMESTAMP","TIMESTAMPTZ","TIMETZ","TINYINT","UBIGINT","UHUGEINT","UINT128","UINT16","UINT32","UINT64","UINT8","UINTEGER","UNION","USMALLINT","UTINYINT","UUID","VARBINARY","VARCHAR"],Kf=Q(["SELECT [ALL | DISTINCT]"]),zf=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY [ALL]","HAVING","WINDOW","PARTITION BY","ORDER BY [ALL]","LIMIT","OFFSET","USING SAMPLE","QUALIFY","INSERT [OR REPLACE] INTO","VALUES","DEFAULT VALUES","SET","RETURNING"]),XA=Q(["CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]),qT=Q(["UPDATE","ON CONFLICT","DELETE FROM","DROP TABLE [IF EXISTS]","TRUNCATE","ALTER TABLE","ADD [COLUMN] [IF NOT EXISTS]","ADD PRIMARY KEY","DROP [COLUMN] [IF EXISTS]","ALTER [COLUMN]","RENAME [COLUMN]","RENAME TO","SET [DATA] TYPE","{SET | DROP} DEFAULT","{SET | DROP} NOT NULL","CREATE [OR REPLACE] [TEMPORARY | TEMP] {MACRO | FUNCTION}","DROP MACRO [TABLE] [IF EXISTS]","DROP FUNCTION [IF EXISTS]","CREATE [UNIQUE] INDEX [IF NOT EXISTS]","DROP INDEX [IF EXISTS]","CREATE [OR REPLACE] SCHEMA [IF NOT EXISTS]","DROP SCHEMA [IF EXISTS]","CREATE [OR REPLACE] [PERSISTENT | TEMPORARY] SECRET [IF NOT EXISTS]","DROP [PERSISTENT | TEMPORARY] SECRET [IF EXISTS]","CREATE [OR REPLACE] [TEMPORARY | TEMP] SEQUENCE","DROP SEQUENCE [IF EXISTS]","CREATE [OR REPLACE] [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]","DROP VIEW [IF EXISTS]","ALTER VIEW","CREATE TYPE","DROP TYPE [IF EXISTS]","ANALYZE","ATTACH [DATABASE] [IF NOT EXISTS]","DETACH [DATABASE] [IF EXISTS]","CALL","[FORCE] CHECKPOINT","COMMENT ON [TABLE | COLUMN | VIEW | INDEX | SEQUENCE | TYPE | MACRO | MACRO TABLE]","COPY [FROM DATABASE]","DESCRIBE","EXPORT DATABASE","IMPORT DATABASE","INSTALL","LOAD","PIVOT","PIVOT_WIDER","UNPIVOT","EXPLAIN [ANALYZE]","SET {LOCAL | SESSION | GLOBAL}","RESET [LOCAL | SESSION | GLOBAL]","{SET | RESET} VARIABLE","SUMMARIZE","BEGIN TRANSACTION","ROLLBACK","COMMIT","ABORT","USE","VACUUM [ANALYZE]","PREPARE","EXECUTE","DEALLOCATE [PREPARE]"]),kf=Q(["UNION [ALL | BY NAME]","EXCEPT [ALL]","INTERSECT [ALL]"]),$f=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","{NATURAL | ASOF} [INNER] JOIN","{NATURAL | ASOF} {LEFT | RIGHT | FULL} [OUTER] JOIN","POSITIONAL JOIN","ANTI JOIN","SEMI JOIN"]),Jf=Q(["{ROWS | RANGE | GROUPS} BETWEEN","SIMILAR TO","IS [NOT] DISTINCT FROM"]),qf=Q(["TIMESTAMP WITH TIME ZONE"]),Qf={name:"duckdb",tokenizerOptions:{reservedSelect:Kf,reservedClauses:[...zf,...XA,...qT],reservedSetOperations:kf,reservedJoins:$f,reservedKeywordPhrases:Jf,reservedDataTypePhrases:qf,supportsXor:!0,reservedKeywords:Wf,reservedDataTypes:Xf,reservedFunctionNames:wf,nestedBlockComments:!0,extraParens:["[]","{}"],underscoresInNumbers:!0,stringTypes:["$$","''-qq",{quote:"''-qq-bs",prefixes:["E"],requirePrefix:!0},{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:['""-qq'],identChars:{rest:"$"},paramTypes:{positional:!0,numbered:["$"],quoted:["$"]},operators:["//","%","**","^","!","&","|","~","<<",">>","::","==","->","->>",":",":=","=>","~~","!~~","~~*","!~~*","~~~","~","!~","~*","!~*","^@","||",">>=","<<="]},formatOptions:{alwaysDenseOperators:["::"],onelineClauses:[...XA,...qT],tabularOnelineClauses:qT}},Zf=["ABS","ACOS","ASIN","ATAN","BIN","BROUND","CBRT","CEIL","CEILING","CONV","COS","DEGREES","EXP","FACTORIAL","FLOOR","GREATEST","HEX","LEAST","LN","LOG","LOG10","LOG2","NEGATIVE","PI","PMOD","POSITIVE","POW","POWER","RADIANS","RAND","ROUND","SHIFTLEFT","SHIFTRIGHT","SHIFTRIGHTUNSIGNED","SIGN","SIN","SQRT","TAN","UNHEX","WIDTH_BUCKET","ARRAY_CONTAINS","MAP_KEYS","MAP_VALUES","SIZE","SORT_ARRAY","BINARY","CAST","ADD_MONTHS","DATE","DATE_ADD","DATE_FORMAT","DATE_SUB","DATEDIFF","DAY","DAYNAME","DAYOFMONTH","DAYOFYEAR","EXTRACT","FROM_UNIXTIME","FROM_UTC_TIMESTAMP","HOUR","LAST_DAY","MINUTE","MONTH","MONTHS_BETWEEN","NEXT_DAY","QUARTER","SECOND","TIMESTAMP","TO_DATE","TO_UTC_TIMESTAMP","TRUNC","UNIX_TIMESTAMP","WEEKOFYEAR","YEAR","ASSERT_TRUE","COALESCE","IF","ISNOTNULL","ISNULL","NULLIF","NVL","ASCII","BASE64","CHARACTER_LENGTH","CHR","CONCAT","CONCAT_WS","CONTEXT_NGRAMS","DECODE","ELT","ENCODE","FIELD","FIND_IN_SET","FORMAT_NUMBER","GET_JSON_OBJECT","IN_FILE","INITCAP","INSTR","LCASE","LENGTH","LEVENSHTEIN","LOCATE","LOWER","LPAD","LTRIM","NGRAMS","OCTET_LENGTH","PARSE_URL","PRINTF","QUOTE","REGEXP_EXTRACT","REGEXP_REPLACE","REPEAT","REVERSE","RPAD","RTRIM","SENTENCES","SOUNDEX","SPACE","SPLIT","STR_TO_MAP","SUBSTR","SUBSTRING","TRANSLATE","TRIM","UCASE","UNBASE64","UPPER","MASK","MASK_FIRST_N","MASK_HASH","MASK_LAST_N","MASK_SHOW_FIRST_N","MASK_SHOW_LAST_N","AES_DECRYPT","AES_ENCRYPT","CRC32","CURRENT_DATABASE","CURRENT_USER","HASH","JAVA_METHOD","LOGGED_IN_USER","MD5","REFLECT","SHA","SHA1","SHA2","SURROGATE_KEY","VERSION","AVG","COLLECT_LIST","COLLECT_SET","CORR","COUNT","COVAR_POP","COVAR_SAMP","HISTOGRAM_NUMERIC","MAX","MIN","NTILE","PERCENTILE","PERCENTILE_APPROX","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","STDDEV_POP","STDDEV_SAMP","SUM","VAR_POP","VAR_SAMP","VARIANCE","EXPLODE","INLINE","JSON_TUPLE","PARSE_URL_TUPLE","POSEXPLODE","STACK","LEAD","LAG","FIRST_VALUE","LAST_VALUE","RANK","ROW_NUMBER","DENSE_RANK","CUME_DIST","PERCENT_RANK","NTILE"],eC=["ADD","ADMIN","AFTER","ANALYZE","ARCHIVE","ASC","BEFORE","BUCKET","BUCKETS","CASCADE","CHANGE","CLUSTER","CLUSTERED","CLUSTERSTATUS","COLLECTION","COLUMNS","COMMENT","COMPACT","COMPACTIONS","COMPUTE","CONCATENATE","CONTINUE","DATA","DATABASES","DATETIME","DAY","DBPROPERTIES","DEFERRED","DEFINED","DELIMITED","DEPENDENCY","DESC","DIRECTORIES","DIRECTORY","DISABLE","DISTRIBUTE","ELEM_TYPE","ENABLE","ESCAPED","EXCLUSIVE","EXPLAIN","EXPORT","FIELDS","FILE","FILEFORMAT","FIRST","FORMAT","FORMATTED","FUNCTIONS","HOLD_DDLTIME","HOUR","IDXPROPERTIES","IGNORE","INDEX","INDEXES","INPATH","INPUTDRIVER","INPUTFORMAT","ITEMS","JAR","KEYS","KEY_TYPE","LIMIT","LINES","LOAD","LOCATION","LOCK","LOCKS","LOGICAL","LONG","MAPJOIN","MATERIALIZED","METADATA","MINUS","MINUTE","MONTH","MSCK","NOSCAN","NO_DROP","OFFLINE","OPTION","OUTPUTDRIVER","OUTPUTFORMAT","OVERWRITE","OWNER","PARTITIONED","PARTITIONS","PLUS","PRETTY","PRINCIPALS","PROTECTION","PURGE","READ","READONLY","REBUILD","RECORDREADER","RECORDWRITER","RELOAD","RENAME","REPAIR","REPLACE","REPLICATION","RESTRICT","REWRITE","ROLE","ROLES","SCHEMA","SCHEMAS","SECOND","SEMI","SERDE","SERDEPROPERTIES","SERVER","SETS","SHARED","SHOW","SHOW_DATABASE","SKEWED","SORT","SORTED","SSL","STATISTICS","STORED","STREAMTABLE","STRING","TABLES","TBLPROPERTIES","TEMPORARY","TERMINATED","TINYINT","TOUCH","TRANSACTIONS","UNARCHIVE","UNDO","UNIONTYPE","UNLOCK","UNSET","UNSIGNED","URI","USE","UTC","UTCTIMESTAMP","VALUE_TYPE","VIEW","WHILE","YEAR","AUTOCOMMIT","ISOLATION","LEVEL","OFFSET","SNAPSHOT","TRANSACTION","WORK","WRITE","ABORT","KEY","LAST","NORELY","NOVALIDATE","NULLS","RELY","VALIDATE","DETAIL","DOW","EXPRESSION","OPERATOR","QUARTER","SUMMARY","VECTORIZATION","WEEK","YEARS","MONTHS","WEEKS","DAYS","HOURS","MINUTES","SECONDS","TIMESTAMPTZ","ZONE","ALL","ALTER","AND","AS","AUTHORIZATION","BETWEEN","BOTH","BY","CASE","CAST","COLUMN","CONF","CREATE","CROSS","CUBE","CURRENT","CURRENT_DATE","CURRENT_TIMESTAMP","CURSOR","DATABASE","DELETE","DESCRIBE","DISTINCT","DROP","ELSE","END","EXCHANGE","EXISTS","EXTENDED","EXTERNAL","FALSE","FETCH","FOLLOWING","FOR","FROM","FULL","FUNCTION","GRANT","GROUP","GROUPING","HAVING","IF","IMPORT","IN","INNER","INSERT","INTERSECT","INTO","IS","JOIN","LATERAL","LEFT","LESS","LIKE","LOCAL","MACRO","MORE","NONE","NOT","NULL","OF","ON","OR","ORDER","OUT","OUTER","OVER","PARTIALSCAN","PARTITION","PERCENT","PRECEDING","PRESERVE","PROCEDURE","RANGE","READS","REDUCE","REVOKE","RIGHT","ROLLUP","ROW","ROWS","SELECT","SET","TABLE","TABLESAMPLE","THEN","TO","TRANSFORM","TRIGGER","TRUE","TRUNCATE","UNBOUNDED","UNION","UNIQUEJOIN","UPDATE","USER","USING","UTC_TMESTAMP","VALUES","WHEN","WHERE","WINDOW","WITH","COMMIT","ONLY","REGEXP","RLIKE","ROLLBACK","START","CACHE","CONSTRAINT","FOREIGN","PRIMARY","REFERENCES","DAYOFWEEK","EXTRACT","FLOOR","VIEWS","TIME","SYNC","TEXTFILE","SEQUENCEFILE","ORC","CSV","TSV","PARQUET","AVRO","RCFILE","JSONFILE","INPUTFORMAT","OUTPUTFORMAT"],tC=["ARRAY","BIGINT","BINARY","BOOLEAN","CHAR","DATE","DECIMAL","DOUBLE","FLOAT","INT","INTEGER","INTERVAL","MAP","NUMERIC","PRECISION","SMALLINT","STRUCT","TIMESTAMP","VARCHAR"],nC=Q(["SELECT [ALL | DISTINCT]"]),aC=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","SORT BY","CLUSTER BY","DISTRIBUTE BY","LIMIT","INSERT INTO [TABLE]","VALUES","SET","MERGE INTO","WHEN [NOT] MATCHED [THEN]","UPDATE SET","INSERT [VALUES]","INSERT OVERWRITE [LOCAL] DIRECTORY","LOAD DATA [LOCAL] INPATH","[OVERWRITE] INTO TABLE"]),KA=Q(["CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"]),QT=Q(["CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]","UPDATE","DELETE FROM","DROP TABLE [IF EXISTS]","ALTER TABLE","RENAME TO","TRUNCATE [TABLE]","ALTER","CREATE","USE","DESCRIBE","DROP","FETCH","SHOW","STORED AS","STORED BY","ROW FORMAT"]),rC=Q(["UNION [ALL | DISTINCT]"]),sC=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","LEFT SEMI JOIN"]),lC=Q(["{ROWS | RANGE} BETWEEN"]),iC=Q([]),oC={name:"hive",tokenizerOptions:{reservedSelect:nC,reservedClauses:[...aC,...KA,...QT],reservedSetOperations:rC,reservedJoins:sC,reservedKeywordPhrases:lC,reservedDataTypePhrases:iC,reservedKeywords:eC,reservedDataTypes:tC,reservedFunctionNames:Zf,extraParens:["[]"],stringTypes:['""-bs',"''-bs"],identTypes:["``"],variableTypes:[{quote:"{}",prefixes:["$"],requirePrefix:!0}],operators:["%","~","^","|","&","<=>","==","!","||"]},formatOptions:{onelineClauses:[...KA,...QT],tabularOnelineClauses:QT}};function mo(r){return r.map((l,E)=>{const T=r[E+1]||Rr;if(ur.SET(l)&&T.text==="(")return Object.assign(Object.assign({},l),{type:Ae.RESERVED_FUNCTION_NAME});const c=r[E-1]||Rr;return ur.VALUES(l)&&c.text==="="?Object.assign(Object.assign({},l),{type:Ae.RESERVED_FUNCTION_NAME}):l})}const EC=["ACCESSIBLE","ADD","ALL","ALTER","ANALYZE","AND","AS","ASC","ASENSITIVE","BEFORE","BETWEEN","BOTH","BY","CALL","CASCADE","CASE","CHANGE","CHECK","COLLATE","COLUMN","CONDITION","CONSTRAINT","CONTINUE","CONVERT","CREATE","CROSS","CURRENT_DATE","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DECLARE","DEFAULT","DELAYED","DELETE","DELETE_DOMAIN_ID","DESC","DESCRIBE","DETERMINISTIC","DISTINCT","DISTINCTROW","DIV","DO_DOMAIN_IDS","DROP","DUAL","EACH","ELSE","ELSEIF","ENCLOSED","ESCAPED","EXCEPT","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FOR","FORCE","FOREIGN","FROM","FULLTEXT","GENERAL","GRANT","GROUP","HAVING","HIGH_PRIORITY","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IF","IGNORE","IGNORE_DOMAIN_IDS","IGNORE_SERVER_IDS","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","INTERSECT","INTERVAL","INTO","IS","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINES","LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LOOP","LOW_PRIORITY","MASTER_HEARTBEAT_PERIOD","MASTER_SSL_VERIFY_SERVER_CERT","MATCH","MAXVALUE","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATURAL","NOT","NO_WRITE_TO_BINLOG","NULL","OFFSET","ON","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PAGE_CHECKSUM","PARSE_VCOL_EXPR","PARTITION","POSITION","PRIMARY","PROCEDURE","PURGE","RANGE","READ","READS","READ_WRITE","RECURSIVE","REF_SYSTEM_ID","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE","REQUIRE","RESIGNAL","RESTRICT","RETURN","RETURNING","REVOKE","RIGHT","RLIKE","ROW_NUMBER","ROWS","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SENSITIVE","SEPARATOR","SET","SHOW","SIGNAL","SLOW","SPATIAL","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STATS_AUTO_RECALC","STATS_PERSISTENT","STATS_SAMPLE_PAGES","STRAIGHT_JOIN","TABLE","TERMINATED","THEN","TO","TRAILING","TRIGGER","TRUE","UNDO","UNION","UNIQUE","UNLOCK","UNSIGNED","UPDATE","USAGE","USE","USING","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","VALUES","WHEN","WHERE","WHILE","WINDOW","WITH","WRITE","XOR","YEAR_MONTH","ZEROFILL"],TC=["BIGINT","BINARY","BIT","BLOB","CHAR BYTE","CHAR","CHARACTER","DATETIME","DEC","DECIMAL","DOUBLE PRECISION","DOUBLE","ENUM","FIXED","FLOAT","FLOAT4","FLOAT8","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","LONG","LONGBLOB","LONGTEXT","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","NATIONAL CHAR","NATIONAL VARCHAR","NUMERIC","PRECISION","REAL","SMALLINT","TEXT","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","VARBINARY","VARCHAR","VARCHARACTER","VARYING","YEAR"],cC=["ADDDATE","ADD_MONTHS","BIT_AND","BIT_OR","BIT_XOR","CAST","COUNT","CUME_DIST","CURDATE","CURTIME","DATE_ADD","DATE_SUB","DATE_FORMAT","DECODE","DENSE_RANK","EXTRACT","FIRST_VALUE","GROUP_CONCAT","JSON_ARRAYAGG","JSON_OBJECTAGG","LAG","LEAD","MAX","MEDIAN","MID","MIN","NOW","NTH_VALUE","NTILE","POSITION","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","RANK","ROW_NUMBER","SESSION_USER","STD","STDDEV","STDDEV_POP","STDDEV_SAMP","SUBDATE","SUBSTR","SUBSTRING","SUM","SYSTEM_USER","TRIM","TRIM_ORACLE","VARIANCE","VAR_POP","VAR_SAMP","ABS","ACOS","ADDTIME","AES_DECRYPT","AES_ENCRYPT","ASIN","ATAN","ATAN2","BENCHMARK","BIN","BINLOG_GTID_POS","BIT_COUNT","BIT_LENGTH","CEIL","CEILING","CHARACTER_LENGTH","CHAR_LENGTH","CHR","COERCIBILITY","COLUMN_CHECK","COLUMN_EXISTS","COLUMN_LIST","COLUMN_JSON","COMPRESS","CONCAT","CONCAT_OPERATOR_ORACLE","CONCAT_WS","CONNECTION_ID","CONV","CONVERT_TZ","COS","COT","CRC32","DATEDIFF","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","DEGREES","DECODE_HISTOGRAM","DECODE_ORACLE","DES_DECRYPT","DES_ENCRYPT","ELT","ENCODE","ENCRYPT","EXP","EXPORT_SET","EXTRACTVALUE","FIELD","FIND_IN_SET","FLOOR","FORMAT","FOUND_ROWS","FROM_BASE64","FROM_DAYS","FROM_UNIXTIME","GET_LOCK","GREATEST","HEX","IFNULL","INSTR","ISNULL","IS_FREE_LOCK","IS_USED_LOCK","JSON_ARRAY","JSON_ARRAY_APPEND","JSON_ARRAY_INSERT","JSON_COMPACT","JSON_CONTAINS","JSON_CONTAINS_PATH","JSON_DEPTH","JSON_DETAILED","JSON_EXISTS","JSON_EXTRACT","JSON_INSERT","JSON_KEYS","JSON_LENGTH","JSON_LOOSE","JSON_MERGE","JSON_MERGE_PATCH","JSON_MERGE_PRESERVE","JSON_QUERY","JSON_QUOTE","JSON_OBJECT","JSON_REMOVE","JSON_REPLACE","JSON_SET","JSON_SEARCH","JSON_TYPE","JSON_UNQUOTE","JSON_VALID","JSON_VALUE","LAST_DAY","LAST_INSERT_ID","LCASE","LEAST","LENGTH","LENGTHB","LN","LOAD_FILE","LOCATE","LOG","LOG10","LOG2","LOWER","LPAD","LPAD_ORACLE","LTRIM","LTRIM_ORACLE","MAKEDATE","MAKETIME","MAKE_SET","MASTER_GTID_WAIT","MASTER_POS_WAIT","MD5","MONTHNAME","NAME_CONST","NVL","NVL2","OCT","OCTET_LENGTH","ORD","PERIOD_ADD","PERIOD_DIFF","PI","POW","POWER","QUOTE","REGEXP_INSTR","REGEXP_REPLACE","REGEXP_SUBSTR","RADIANS","RAND","RELEASE_ALL_LOCKS","RELEASE_LOCK","REPLACE_ORACLE","REVERSE","ROUND","RPAD","RPAD_ORACLE","RTRIM","RTRIM_ORACLE","SEC_TO_TIME","SHA","SHA1","SHA2","SIGN","SIN","SLEEP","SOUNDEX","SPACE","SQRT","STRCMP","STR_TO_DATE","SUBSTR_ORACLE","SUBSTRING_INDEX","SUBTIME","SYS_GUID","TAN","TIMEDIFF","TIME_FORMAT","TIME_TO_SEC","TO_BASE64","TO_CHAR","TO_DAYS","TO_SECONDS","UCASE","UNCOMPRESS","UNCOMPRESSED_LENGTH","UNHEX","UNIX_TIMESTAMP","UPDATEXML","UPPER","UUID","UUID_SHORT","VERSION","WEEKDAY","WEEKOFYEAR","WSREP_LAST_WRITTEN_GTID","WSREP_LAST_SEEN_GTID","WSREP_SYNC_WAIT_UPTO_GTID","YEARWEEK","COALESCE","NULLIF"],SC=Q(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),RC=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER BY","LIMIT","OFFSET","FETCH {FIRST | NEXT}","INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO]","REPLACE [LOW_PRIORITY | DELAYED] [INTO]","VALUES","ON DUPLICATE KEY UPDATE","SET","RETURNING"]),zA=Q(["CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"]),ZT=Q(["CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]","UPDATE [LOW_PRIORITY] [IGNORE]","DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM","DROP [TEMPORARY] TABLE [IF EXISTS]","ALTER [ONLINE] [IGNORE] TABLE [IF EXISTS]","ADD [COLUMN] [IF NOT EXISTS]","{CHANGE | MODIFY} [COLUMN] [IF EXISTS]","DROP [COLUMN] [IF EXISTS]","RENAME [TO]","RENAME COLUMN","ALTER [COLUMN]","{SET | DROP} DEFAULT","SET {VISIBLE | INVISIBLE}","TRUNCATE [TABLE]","ALTER DATABASE","ALTER DATABASE COMMENT","ALTER EVENT","ALTER FUNCTION","ALTER PROCEDURE","ALTER SCHEMA","ALTER SCHEMA COMMENT","ALTER SEQUENCE","ALTER SERVER","ALTER USER","ALTER VIEW","ANALYZE","ANALYZE TABLE","BACKUP LOCK","BACKUP STAGE","BACKUP UNLOCK","BEGIN","BINLOG","CACHE INDEX","CALL","CHANGE MASTER TO","CHECK TABLE","CHECK VIEW","CHECKSUM TABLE","COMMIT","CREATE AGGREGATE FUNCTION","CREATE DATABASE","CREATE EVENT","CREATE FUNCTION","CREATE INDEX","CREATE PROCEDURE","CREATE ROLE","CREATE SEQUENCE","CREATE SERVER","CREATE SPATIAL INDEX","CREATE TRIGGER","CREATE UNIQUE INDEX","CREATE USER","DEALLOCATE PREPARE","DESCRIBE","DROP DATABASE","DROP EVENT","DROP FUNCTION","DROP INDEX","DROP PREPARE","DROP PROCEDURE","DROP ROLE","DROP SEQUENCE","DROP SERVER","DROP TRIGGER","DROP USER","DROP VIEW","EXECUTE","EXPLAIN","FLUSH","GET DIAGNOSTICS","GET DIAGNOSTICS CONDITION","GRANT","HANDLER","HELP","INSTALL PLUGIN","INSTALL SONAME","KILL","LOAD DATA INFILE","LOAD INDEX INTO CACHE","LOAD XML INFILE","LOCK TABLE","OPTIMIZE TABLE","PREPARE","PURGE BINARY LOGS","PURGE MASTER LOGS","RELEASE SAVEPOINT","RENAME TABLE","RENAME USER","REPAIR TABLE","REPAIR VIEW","RESET MASTER","RESET QUERY CACHE","RESET REPLICA","RESET SLAVE","RESIGNAL","REVOKE","ROLLBACK","SAVEPOINT","SET CHARACTER SET","SET DEFAULT ROLE","SET GLOBAL TRANSACTION","SET NAMES","SET PASSWORD","SET ROLE","SET STATEMENT","SET TRANSACTION","SHOW","SHOW ALL REPLICAS STATUS","SHOW ALL SLAVES STATUS","SHOW AUTHORS","SHOW BINARY LOGS","SHOW BINLOG EVENTS","SHOW BINLOG STATUS","SHOW CHARACTER SET","SHOW CLIENT_STATISTICS","SHOW COLLATION","SHOW COLUMNS","SHOW CONTRIBUTORS","SHOW CREATE DATABASE","SHOW CREATE EVENT","SHOW CREATE FUNCTION","SHOW CREATE PACKAGE","SHOW CREATE PACKAGE BODY","SHOW CREATE PROCEDURE","SHOW CREATE SEQUENCE","SHOW CREATE TABLE","SHOW CREATE TRIGGER","SHOW CREATE USER","SHOW CREATE VIEW","SHOW DATABASES","SHOW ENGINE","SHOW ENGINE INNODB STATUS","SHOW ENGINES","SHOW ERRORS","SHOW EVENTS","SHOW EXPLAIN","SHOW FUNCTION CODE","SHOW FUNCTION STATUS","SHOW GRANTS","SHOW INDEX","SHOW INDEXES","SHOW INDEX_STATISTICS","SHOW KEYS","SHOW LOCALES","SHOW MASTER LOGS","SHOW MASTER STATUS","SHOW OPEN TABLES","SHOW PACKAGE BODY CODE","SHOW PACKAGE BODY STATUS","SHOW PACKAGE STATUS","SHOW PLUGINS","SHOW PLUGINS SONAME","SHOW PRIVILEGES","SHOW PROCEDURE CODE","SHOW PROCEDURE STATUS","SHOW PROCESSLIST","SHOW PROFILE","SHOW PROFILES","SHOW QUERY_RESPONSE_TIME","SHOW RELAYLOG EVENTS","SHOW REPLICA","SHOW REPLICA HOSTS","SHOW REPLICA STATUS","SHOW SCHEMAS","SHOW SLAVE","SHOW SLAVE HOSTS","SHOW SLAVE STATUS","SHOW STATUS","SHOW STORAGE ENGINES","SHOW TABLE STATUS","SHOW TABLES","SHOW TRIGGERS","SHOW USER_STATISTICS","SHOW VARIABLES","SHOW WARNINGS","SHOW WSREP_MEMBERSHIP","SHOW WSREP_STATUS","SHUTDOWN","SIGNAL","START ALL REPLICAS","START ALL SLAVES","START REPLICA","START SLAVE","START TRANSACTION","STOP ALL REPLICAS","STOP ALL SLAVES","STOP REPLICA","STOP SLAVE","UNINSTALL PLUGIN","UNINSTALL SONAME","UNLOCK TABLE","USE","XA BEGIN","XA COMMIT","XA END","XA PREPARE","XA RECOVER","XA ROLLBACK","XA START"]),uC=Q(["UNION [ALL | DISTINCT]","EXCEPT [ALL | DISTINCT]","INTERSECT [ALL | DISTINCT]","MINUS [ALL | DISTINCT]"]),AC=Q(["JOIN","{LEFT | RIGHT} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL JOIN","NATURAL {LEFT | RIGHT} [OUTER] JOIN","STRAIGHT_JOIN"]),dC=Q(["ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]","CHARACTER SET","{ROWS | RANGE} BETWEEN","IDENTIFIED BY"]),OC=Q([]),NC={name:"mariadb",tokenizerOptions:{reservedSelect:SC,reservedClauses:[...RC,...zA,...ZT],reservedSetOperations:uC,reservedJoins:AC,reservedKeywordPhrases:dC,reservedDataTypePhrases:OC,supportsXor:!0,reservedKeywords:EC,reservedDataTypes:TC,reservedFunctionNames:cC,stringTypes:['""-qq-bs',"''-qq-bs",{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:["``"],identChars:{first:"$",rest:"$",allowFirstCharNumber:!0},variableTypes:[{regex:"@@?[A-Za-z0-9_.$]+"},{quote:'""-qq-bs',prefixes:["@"],requirePrefix:!0},{quote:"''-qq-bs",prefixes:["@"],requirePrefix:!0},{quote:"``",prefixes:["@"],requirePrefix:!0}],paramTypes:{positional:!0},lineCommentTypes:["--","#"],operators:["%",":=","&","|","^","~","<<",">>","<=>","&&","||","!","*.*"],postProcess:mo},formatOptions:{onelineClauses:[...zA,...ZT],tabularOnelineClauses:ZT}},IC=["ACCESSIBLE","ADD","ALL","ALTER","ANALYZE","AND","AS","ASC","ASENSITIVE","BEFORE","BETWEEN","BOTH","BY","CALL","CASCADE","CASE","CHANGE","CHECK","COLLATE","COLUMN","CONDITION","CONSTRAINT","CONTINUE","CONVERT","CREATE","CROSS","CUBE","CUME_DIST","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DECLARE","DEFAULT","DELAYED","DELETE","DENSE_RANK","DESC","DESCRIBE","DETERMINISTIC","DISTINCT","DISTINCTROW","DIV","DROP","DUAL","EACH","ELSE","ELSEIF","EMPTY","ENCLOSED","ESCAPED","EXCEPT","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FIRST_VALUE","FOR","FORCE","FOREIGN","FROM","FULLTEXT","FUNCTION","GENERATED","GET","GRANT","GROUP","GROUPING","GROUPS","HAVING","HIGH_PRIORITY","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IF","IGNORE","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","IN","INTERSECT","INTERVAL","INTO","IO_AFTER_GTIDS","IO_BEFORE_GTIDS","IS","ITERATE","JOIN","JSON_TABLE","KEY","KEYS","KILL","LAG","LAST_VALUE","LATERAL","LEAD","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINES","LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LONG","LOOP","LOW_PRIORITY","MASTER_BIND","MASTER_SSL_VERIFY_SERVER_CERT","MATCH","MAXVALUE","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATURAL","NOT","NO_WRITE_TO_BINLOG","NTH_VALUE","NTILE","NULL","OF","ON","OPTIMIZE","OPTIMIZER_COSTS","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PARTITION","PERCENT_RANK","PRIMARY","PROCEDURE","PURGE","RANGE","RANK","READ","READS","READ_WRITE","RECURSIVE","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE","REQUIRE","RESIGNAL","RESTRICT","RETURN","REVOKE","RIGHT","RLIKE","ROW","ROWS","ROW_NUMBER","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SENSITIVE","SEPARATOR","SET","SHOW","SIGNAL","SPATIAL","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STORED","STRAIGHT_JOIN","SYSTEM","TABLE","TERMINATED","THEN","TO","TRAILING","TRIGGER","TRUE","UNDO","UNION","UNIQUE","UNLOCK","UNSIGNED","UPDATE","USAGE","USE","USING","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","VALUES","VIRTUAL","WHEN","WHERE","WHILE","WINDOW","WITH","WRITE","XOR","YEAR_MONTH","ZEROFILL"],hC=["BIGINT","BINARY","BIT","BLOB","BOOL","BOOLEAN","CHAR","CHARACTER","DATE","DATETIME","DEC","DECIMAL","DOUBLE PRECISION","DOUBLE","ENUM","FIXED","FLOAT","FLOAT4","FLOAT8","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","LONGBLOB","LONGTEXT","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","NATIONAL CHAR","NATIONAL VARCHAR","NUMERIC","PRECISION","REAL","SMALLINT","TEXT","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","VARBINARY","VARCHAR","VARCHARACTER","VARYING","YEAR"],fC=["ABS","ACOS","ADDDATE","ADDTIME","AES_DECRYPT","AES_ENCRYPT","ANY_VALUE","ASCII","ASIN","ATAN","ATAN2","AVG","BENCHMARK","BIN","BIN_TO_UUID","BINARY","BIT_AND","BIT_COUNT","BIT_LENGTH","BIT_OR","BIT_XOR","CAN_ACCESS_COLUMN","CAN_ACCESS_DATABASE","CAN_ACCESS_TABLE","CAN_ACCESS_USER","CAN_ACCESS_VIEW","CAST","CEIL","CEILING","CHAR","CHAR_LENGTH","CHARACTER_LENGTH","CHARSET","COALESCE","COERCIBILITY","COLLATION","COMPRESS","CONCAT","CONCAT_WS","CONNECTION_ID","CONV","CONVERT","CONVERT_TZ","COS","COT","COUNT","CRC32","CUME_DIST","CURDATE","CURRENT_DATE","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURTIME","DATABASE","DATE","DATE_ADD","DATE_FORMAT","DATE_SUB","DATEDIFF","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","DEFAULT","DEGREES","DENSE_RANK","DIV","ELT","EXP","EXPORT_SET","EXTRACT","EXTRACTVALUE","FIELD","FIND_IN_SET","FIRST_VALUE","FLOOR","FORMAT","FORMAT_BYTES","FORMAT_PICO_TIME","FOUND_ROWS","FROM_BASE64","FROM_DAYS","FROM_UNIXTIME","GEOMCOLLECTION","GEOMETRYCOLLECTION","GET_DD_COLUMN_PRIVILEGES","GET_DD_CREATE_OPTIONS","GET_DD_INDEX_SUB_PART_LENGTH","GET_FORMAT","GET_LOCK","GREATEST","GROUP_CONCAT","GROUPING","GTID_SUBSET","GTID_SUBTRACT","HEX","HOUR","ICU_VERSION","IF","IFNULL","INET_ATON","INET_NTOA","INET6_ATON","INET6_NTOA","INSERT","INSTR","INTERNAL_AUTO_INCREMENT","INTERNAL_AVG_ROW_LENGTH","INTERNAL_CHECK_TIME","INTERNAL_CHECKSUM","INTERNAL_DATA_FREE","INTERNAL_DATA_LENGTH","INTERNAL_DD_CHAR_LENGTH","INTERNAL_GET_COMMENT_OR_ERROR","INTERNAL_GET_ENABLED_ROLE_JSON","INTERNAL_GET_HOSTNAME","INTERNAL_GET_USERNAME","INTERNAL_GET_VIEW_WARNING_OR_ERROR","INTERNAL_INDEX_COLUMN_CARDINALITY","INTERNAL_INDEX_LENGTH","INTERNAL_IS_ENABLED_ROLE","INTERNAL_IS_MANDATORY_ROLE","INTERNAL_KEYS_DISABLED","INTERNAL_MAX_DATA_LENGTH","INTERNAL_TABLE_ROWS","INTERNAL_UPDATE_TIME","INTERVAL","IS","IS_FREE_LOCK","IS_IPV4","IS_IPV4_COMPAT","IS_IPV4_MAPPED","IS_IPV6","IS NOT","IS NOT NULL","IS NULL","IS_USED_LOCK","IS_UUID","ISNULL","JSON_ARRAY","JSON_ARRAY_APPEND","JSON_ARRAY_INSERT","JSON_ARRAYAGG","JSON_CONTAINS","JSON_CONTAINS_PATH","JSON_DEPTH","JSON_EXTRACT","JSON_INSERT","JSON_KEYS","JSON_LENGTH","JSON_MERGE","JSON_MERGE_PATCH","JSON_MERGE_PRESERVE","JSON_OBJECT","JSON_OBJECTAGG","JSON_OVERLAPS","JSON_PRETTY","JSON_QUOTE","JSON_REMOVE","JSON_REPLACE","JSON_SCHEMA_VALID","JSON_SCHEMA_VALIDATION_REPORT","JSON_SEARCH","JSON_SET","JSON_STORAGE_FREE","JSON_STORAGE_SIZE","JSON_TABLE","JSON_TYPE","JSON_UNQUOTE","JSON_VALID","JSON_VALUE","LAG","LAST_DAY","LAST_INSERT_ID","LAST_VALUE","LCASE","LEAD","LEAST","LEFT","LENGTH","LIKE","LINESTRING","LN","LOAD_FILE","LOCALTIME","LOCALTIMESTAMP","LOCATE","LOG","LOG10","LOG2","LOWER","LPAD","LTRIM","MAKE_SET","MAKEDATE","MAKETIME","MASTER_POS_WAIT","MATCH","MAX","MBRCONTAINS","MBRCOVEREDBY","MBRCOVERS","MBRDISJOINT","MBREQUALS","MBRINTERSECTS","MBROVERLAPS","MBRTOUCHES","MBRWITHIN","MD5","MICROSECOND","MID","MIN","MINUTE","MOD","MONTH","MONTHNAME","MULTILINESTRING","MULTIPOINT","MULTIPOLYGON","NAME_CONST","NOW","NTH_VALUE","NTILE","NULLIF","OCT","OCTET_LENGTH","ORD","PERCENT_RANK","PERIOD_ADD","PERIOD_DIFF","PI","POINT","POLYGON","POSITION","POW","POWER","PS_CURRENT_THREAD_ID","PS_THREAD_ID","QUARTER","QUOTE","RADIANS","RAND","RANDOM_BYTES","RANK","REGEXP","REGEXP_INSTR","REGEXP_LIKE","REGEXP_REPLACE","REGEXP_SUBSTR","RELEASE_ALL_LOCKS","RELEASE_LOCK","REPEAT","REPLACE","REVERSE","RIGHT","RLIKE","ROLES_GRAPHML","ROUND","ROW_COUNT","ROW_NUMBER","RPAD","RTRIM","SCHEMA","SEC_TO_TIME","SECOND","SESSION_USER","SHA1","SHA2","SIGN","SIN","SLEEP","SOUNDEX","SOUNDS LIKE","SOURCE_POS_WAIT","SPACE","SQRT","ST_AREA","ST_ASBINARY","ST_ASGEOJSON","ST_ASTEXT","ST_BUFFER","ST_BUFFER_STRATEGY","ST_CENTROID","ST_COLLECT","ST_CONTAINS","ST_CONVEXHULL","ST_CROSSES","ST_DIFFERENCE","ST_DIMENSION","ST_DISJOINT","ST_DISTANCE","ST_DISTANCE_SPHERE","ST_ENDPOINT","ST_ENVELOPE","ST_EQUALS","ST_EXTERIORRING","ST_FRECHETDISTANCE","ST_GEOHASH","ST_GEOMCOLLFROMTEXT","ST_GEOMCOLLFROMWKB","ST_GEOMETRYN","ST_GEOMETRYTYPE","ST_GEOMFROMGEOJSON","ST_GEOMFROMTEXT","ST_GEOMFROMWKB","ST_HAUSDORFFDISTANCE","ST_INTERIORRINGN","ST_INTERSECTION","ST_INTERSECTS","ST_ISCLOSED","ST_ISEMPTY","ST_ISSIMPLE","ST_ISVALID","ST_LATFROMGEOHASH","ST_LATITUDE","ST_LENGTH","ST_LINEFROMTEXT","ST_LINEFROMWKB","ST_LINEINTERPOLATEPOINT","ST_LINEINTERPOLATEPOINTS","ST_LONGFROMGEOHASH","ST_LONGITUDE","ST_MAKEENVELOPE","ST_MLINEFROMTEXT","ST_MLINEFROMWKB","ST_MPOINTFROMTEXT","ST_MPOINTFROMWKB","ST_MPOLYFROMTEXT","ST_MPOLYFROMWKB","ST_NUMGEOMETRIES","ST_NUMINTERIORRING","ST_NUMPOINTS","ST_OVERLAPS","ST_POINTATDISTANCE","ST_POINTFROMGEOHASH","ST_POINTFROMTEXT","ST_POINTFROMWKB","ST_POINTN","ST_POLYFROMTEXT","ST_POLYFROMWKB","ST_SIMPLIFY","ST_SRID","ST_STARTPOINT","ST_SWAPXY","ST_SYMDIFFERENCE","ST_TOUCHES","ST_TRANSFORM","ST_UNION","ST_VALIDATE","ST_WITHIN","ST_X","ST_Y","STATEMENT_DIGEST","STATEMENT_DIGEST_TEXT","STD","STDDEV","STDDEV_POP","STDDEV_SAMP","STR_TO_DATE","STRCMP","SUBDATE","SUBSTR","SUBSTRING","SUBSTRING_INDEX","SUBTIME","SUM","SYSDATE","SYSTEM_USER","TAN","TIME","TIME_FORMAT","TIME_TO_SEC","TIMEDIFF","TIMESTAMP","TIMESTAMPADD","TIMESTAMPDIFF","TO_BASE64","TO_DAYS","TO_SECONDS","TRIM","TRUNCATE","UCASE","UNCOMPRESS","UNCOMPRESSED_LENGTH","UNHEX","UNIX_TIMESTAMP","UPDATEXML","UPPER","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","UUID","UUID_SHORT","UUID_TO_BIN","VALIDATE_PASSWORD_STRENGTH","VALUES","VAR_POP","VAR_SAMP","VARIANCE","VERSION","WAIT_FOR_EXECUTED_GTID_SET","WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS","WEEK","WEEKDAY","WEEKOFYEAR","WEIGHT_STRING","YEAR","YEARWEEK"],CC=Q(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),pC=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO]","REPLACE [LOW_PRIORITY | DELAYED] [INTO]","VALUES","ON DUPLICATE KEY UPDATE","SET"]),kA=Q(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]),ec=Q(["CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]","UPDATE [LOW_PRIORITY] [IGNORE]","DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM","DROP [TEMPORARY] TABLE [IF EXISTS]","ALTER TABLE","ADD [COLUMN]","{CHANGE | MODIFY} [COLUMN]","DROP [COLUMN]","RENAME [TO | AS]","RENAME COLUMN","ALTER [COLUMN]","{SET | DROP} DEFAULT","TRUNCATE [TABLE]","ALTER DATABASE","ALTER EVENT","ALTER FUNCTION","ALTER INSTANCE","ALTER LOGFILE GROUP","ALTER PROCEDURE","ALTER RESOURCE GROUP","ALTER SERVER","ALTER TABLESPACE","ALTER USER","ALTER VIEW","ANALYZE TABLE","BINLOG","CACHE INDEX","CALL","CHANGE MASTER TO","CHANGE REPLICATION FILTER","CHANGE REPLICATION SOURCE TO","CHECK TABLE","CHECKSUM TABLE","CLONE","COMMIT","CREATE DATABASE","CREATE EVENT","CREATE FUNCTION","CREATE FUNCTION","CREATE INDEX","CREATE LOGFILE GROUP","CREATE PROCEDURE","CREATE RESOURCE GROUP","CREATE ROLE","CREATE SERVER","CREATE SPATIAL REFERENCE SYSTEM","CREATE TABLESPACE","CREATE TRIGGER","CREATE USER","DEALLOCATE PREPARE","DESCRIBE","DROP DATABASE","DROP EVENT","DROP FUNCTION","DROP FUNCTION","DROP INDEX","DROP LOGFILE GROUP","DROP PROCEDURE","DROP RESOURCE GROUP","DROP ROLE","DROP SERVER","DROP SPATIAL REFERENCE SYSTEM","DROP TABLESPACE","DROP TRIGGER","DROP USER","DROP VIEW","EXECUTE","EXPLAIN","FLUSH","GRANT","HANDLER","HELP","IMPORT TABLE","INSTALL COMPONENT","INSTALL PLUGIN","KILL","LOAD DATA","LOAD INDEX INTO CACHE","LOAD XML","LOCK INSTANCE FOR BACKUP","LOCK TABLES","MASTER_POS_WAIT","OPTIMIZE TABLE","PREPARE","PURGE BINARY LOGS","RELEASE SAVEPOINT","RENAME TABLE","RENAME USER","REPAIR TABLE","RESET","RESET MASTER","RESET PERSIST","RESET REPLICA","RESET SLAVE","RESTART","REVOKE","ROLLBACK","ROLLBACK TO SAVEPOINT","SAVEPOINT","SET CHARACTER SET","SET DEFAULT ROLE","SET NAMES","SET PASSWORD","SET RESOURCE GROUP","SET ROLE","SET TRANSACTION","SHOW","SHOW BINARY LOGS","SHOW BINLOG EVENTS","SHOW CHARACTER SET","SHOW COLLATION","SHOW COLUMNS","SHOW CREATE DATABASE","SHOW CREATE EVENT","SHOW CREATE FUNCTION","SHOW CREATE PROCEDURE","SHOW CREATE TABLE","SHOW CREATE TRIGGER","SHOW CREATE USER","SHOW CREATE VIEW","SHOW DATABASES","SHOW ENGINE","SHOW ENGINES","SHOW ERRORS","SHOW EVENTS","SHOW FUNCTION CODE","SHOW FUNCTION STATUS","SHOW GRANTS","SHOW INDEX","SHOW MASTER STATUS","SHOW OPEN TABLES","SHOW PLUGINS","SHOW PRIVILEGES","SHOW PROCEDURE CODE","SHOW PROCEDURE STATUS","SHOW PROCESSLIST","SHOW PROFILE","SHOW PROFILES","SHOW RELAYLOG EVENTS","SHOW REPLICA STATUS","SHOW REPLICAS","SHOW SLAVE","SHOW SLAVE HOSTS","SHOW STATUS","SHOW TABLE STATUS","SHOW TABLES","SHOW TRIGGERS","SHOW VARIABLES","SHOW WARNINGS","SHUTDOWN","SOURCE_POS_WAIT","START GROUP_REPLICATION","START REPLICA","START SLAVE","START TRANSACTION","STOP GROUP_REPLICATION","STOP REPLICA","STOP SLAVE","TABLE","UNINSTALL COMPONENT","UNINSTALL PLUGIN","UNLOCK INSTANCE","UNLOCK TABLES","USE","XA","ITERATE","LEAVE","LOOP","REPEAT","RETURN","WHILE"]),LC=Q(["UNION [ALL | DISTINCT]"]),_C=Q(["JOIN","{LEFT | RIGHT} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT} [OUTER] JOIN","STRAIGHT_JOIN"]),mC=Q(["ON {UPDATE | DELETE} [SET NULL]","CHARACTER SET","{ROWS | RANGE} BETWEEN","IDENTIFIED BY"]),vC=Q([]),xC={name:"mysql",tokenizerOptions:{reservedSelect:CC,reservedClauses:[...pC,...kA,...ec],reservedSetOperations:LC,reservedJoins:_C,reservedKeywordPhrases:mC,reservedDataTypePhrases:vC,supportsXor:!0,reservedKeywords:IC,reservedDataTypes:hC,reservedFunctionNames:fC,stringTypes:['""-qq-bs',{quote:"''-qq-bs",prefixes:["N"]},{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:["``"],identChars:{first:"$",rest:"$",allowFirstCharNumber:!0},variableTypes:[{regex:"@@?[A-Za-z0-9_.$]+"},{quote:'""-qq-bs',prefixes:["@"],requirePrefix:!0},{quote:"''-qq-bs",prefixes:["@"],requirePrefix:!0},{quote:"``",prefixes:["@"],requirePrefix:!0}],paramTypes:{positional:!0},lineCommentTypes:["--","#"],operators:["%",":=","&","|","^","~","<<",">>","<=>","->","->>","&&","||","!","*.*"],postProcess:mo},formatOptions:{onelineClauses:[...kA,...ec],tabularOnelineClauses:ec}},DC=["ADD","ALL","ALTER","ANALYZE","AND","ARRAY","AS","ASC","BETWEEN","BOTH","BY","CALL","CASCADE","CASE","CHANGE","CHECK","COLLATE","COLUMN","CONSTRAINT","CONTINUE","CONVERT","CREATE","CROSS","CURRENT_DATE","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DEFAULT","DELAYED","DELETE","DESC","DESCRIBE","DISTINCT","DISTINCTROW","DIV","DOUBLE","DROP","DUAL","ELSE","ELSEIF","ENCLOSED","ESCAPED","EXCEPT","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FOR","FORCE","FOREIGN","FROM","FULLTEXT","GENERATED","GRANT","GROUP","GROUPS","HAVING","HIGH_PRIORITY","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IF","IGNORE","ILIKE","IN","INDEX","INFILE","INNER","INOUT","INSERT","INTERSECT","INTERVAL","INTO","IS","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINES","LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LONG","LOW_PRIORITY","MATCH","MAXVALUE","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","NATURAL","NOT","NO_WRITE_TO_BINLOG","NULL","OF","ON","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PARTITION","PRIMARY","PROCEDURE","RANGE","READ","RECURSIVE","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE","REQUIRE","RESTRICT","REVOKE","RIGHT","RLIKE","ROW","ROWS","SECOND_MICROSECOND","SELECT","SET","SHOW","SPATIAL","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STATS_EXTENDED","STORED","STRAIGHT_JOIN","TABLE","TABLESAMPLE","TERMINATED","THEN","TO","TRAILING","TRIGGER","TRUE","TiDB_CURRENT_TSO","UNION","UNIQUE","UNLOCK","UNSIGNED","UNTIL","UPDATE","USAGE","USE","USING","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","VALUES","VIRTUAL","WHEN","WHERE","WHILE","WINDOW","WITH","WRITE","XOR","YEAR_MONTH","ZEROFILL"],yC=["BIGINT","BINARY","BIT","BLOB","BOOL","BOOLEAN","CHAR","CHARACTER","DATE","DATETIME","DEC","DECIMAL","DOUBLE PRECISION","DOUBLE","ENUM","FIXED","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","LONGBLOB","LONGTEXT","MEDIUMBLOB","MEDIUMINT","MIDDLEINT","NATIONAL CHAR","NATIONAL VARCHAR","NUMERIC","PRECISION","SMALLINT","TEXT","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","VARBINARY","VARCHAR","VARCHARACTER","VARYING","YEAR"],gC=["ABS","ACOS","ADDDATE","ADDTIME","AES_DECRYPT","AES_ENCRYPT","ANY_VALUE","ASCII","ASIN","ATAN","ATAN2","AVG","BENCHMARK","BIN","BIN_TO_UUID","BIT_AND","BIT_COUNT","BIT_LENGTH","BIT_OR","BIT_XOR","BITAND","BITNEG","BITOR","BITXOR","CASE","CAST","CEIL","CEILING","CHAR_FUNC","CHAR_LENGTH","CHARACTER_LENGTH","CHARSET","COALESCE","COERCIBILITY","COLLATION","COMPRESS","CONCAT","CONCAT_WS","CONNECTION_ID","CONV","CONVERT","CONVERT_TZ","COS","COT","COUNT","CRC32","CUME_DIST","CURDATE","CURRENT_DATE","CURRENT_RESOURCE_GROUP","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURTIME","DATABASE","DATE","DATE_ADD","DATE_FORMAT","DATE_SUB","DATEDIFF","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","DECODE","DEFAULT_FUNC","DEGREES","DENSE_RANK","DES_DECRYPT","DES_ENCRYPT","DIV","ELT","ENCODE","ENCRYPT","EQ","EXP","EXPORT_SET","EXTRACT","FIELD","FIND_IN_SET","FIRST_VALUE","FLOOR","FORMAT","FORMAT_BYTES","FORMAT_NANO_TIME","FOUND_ROWS","FROM_BASE64","FROM_DAYS","FROM_UNIXTIME","GE","GET_FORMAT","GET_LOCK","GETPARAM","GREATEST","GROUP_CONCAT","GROUPING","GT","HEX","HOUR","IF","IFNULL","ILIKE","INET6_ATON","INET6_NTOA","INET_ATON","INET_NTOA","INSERT_FUNC","INSTR","INTDIV","INTERVAL","IS_FREE_LOCK","IS_IPV4","IS_IPV4_COMPAT","IS_IPV4_MAPPED","IS_IPV6","IS_USED_LOCK","IS_UUID","ISFALSE","ISNULL","ISTRUE","JSON_ARRAY","JSON_ARRAYAGG","JSON_ARRAY_APPEND","JSON_ARRAY_INSERT","JSON_CONTAINS","JSON_CONTAINS_PATH","JSON_DEPTH","JSON_EXTRACT","JSON_INSERT","JSON_KEYS","JSON_LENGTH","JSON_MEMBEROF","JSON_MERGE","JSON_MERGE_PATCH","JSON_MERGE_PRESERVE","JSON_OBJECT","JSON_OBJECTAGG","JSON_OVERLAPS","JSON_PRETTY","JSON_QUOTE","JSON_REMOVE","JSON_REPLACE","JSON_SEARCH","JSON_SET","JSON_STORAGE_FREE","JSON_STORAGE_SIZE","JSON_TYPE","JSON_UNQUOTE","JSON_VALID","LAG","LAST_DAY","LAST_INSERT_ID","LAST_VALUE","LASTVAL","LCASE","LE","LEAD","LEAST","LEFT","LEFTSHIFT","LENGTH","LIKE","LN","LOAD_FILE","LOCALTIME","LOCALTIMESTAMP","LOCATE","LOG","LOG10","LOG2","LOWER","LPAD","LT","LTRIM","MAKE_SET","MAKEDATE","MAKETIME","MASTER_POS_WAIT","MAX","MD5","MICROSECOND","MID","MIN","MINUS","MINUTE","MOD","MONTH","MONTHNAME","MUL","NAME_CONST","NE","NEXTVAL","NOT","NOW","NTH_VALUE","NTILE","NULLEQ","OCT","OCTET_LENGTH","OLD_PASSWORD","ORD","PASSWORD_FUNC","PERCENT_RANK","PERIOD_ADD","PERIOD_DIFF","PI","PLUS","POSITION","POW","POWER","QUARTER","QUOTE","RADIANS","RAND","RANDOM_BYTES","RANK","REGEXP","REGEXP_INSTR","REGEXP_LIKE","REGEXP_REPLACE","REGEXP_SUBSTR","RELEASE_ALL_LOCKS","RELEASE_LOCK","REPEAT","REPLACE","REVERSE","RIGHT","RIGHTSHIFT","ROUND","ROW_COUNT","ROW_NUMBER","RPAD","RTRIM","SCHEMA","SEC_TO_TIME","SECOND","SESSION_USER","SETVAL","SETVAR","SHA","SHA1","SHA2","SIGN","SIN","SLEEP","SM3","SPACE","SQRT","STD","STDDEV","STDDEV_POP","STDDEV_SAMP","STR_TO_DATE","STRCMP","SUBDATE","SUBSTR","SUBSTRING","SUBSTRING_INDEX","SUBTIME","SUM","SYSDATE","SYSTEM_USER","TAN","TIDB_BOUNDED_STALENESS","TIDB_CURRENT_TSO","TIDB_DECODE_BINARY_PLAN","TIDB_DECODE_KEY","TIDB_DECODE_PLAN","TIDB_DECODE_SQL_DIGESTS","TIDB_ENCODE_SQL_DIGEST","TIDB_IS_DDL_OWNER","TIDB_PARSE_TSO","TIDB_PARSE_TSO_LOGICAL","TIDB_ROW_CHECKSUM","TIDB_SHARD","TIDB_VERSION","TIME","TIME_FORMAT","TIME_TO_SEC","TIMEDIFF","TIMESTAMP","TIMESTAMPADD","TIMESTAMPDIFF","TO_BASE64","TO_DAYS","TO_SECONDS","TRANSLATE","TRIM","TRUNCATE","UCASE","UNARYMINUS","UNCOMPRESS","UNCOMPRESSED_LENGTH","UNHEX","UNIX_TIMESTAMP","UPPER","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","UUID","UUID_SHORT","UUID_TO_BIN","VALIDATE_PASSWORD_STRENGTH","VAR_POP","VAR_SAMP","VARIANCE","VERSION","VITESS_HASH","WEEK","WEEKDAY","WEEKOFYEAR","WEIGHT_STRING","YEAR","YEARWEEK"],MC=Q(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),PC=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [INTO]","REPLACE [LOW_PRIORITY | DELAYED] [INTO]","VALUES","ON DUPLICATE KEY UPDATE","SET"]),$A=Q(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]),tc=Q(["CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]","UPDATE [LOW_PRIORITY] [IGNORE]","DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM","DROP [TEMPORARY] TABLE [IF EXISTS]","ALTER TABLE","ADD [COLUMN]","{CHANGE | MODIFY} [COLUMN]","DROP [COLUMN]","RENAME [TO | AS]","RENAME COLUMN","ALTER [COLUMN]","{SET | DROP} DEFAULT","TRUNCATE [TABLE]","ALTER DATABASE","ALTER INSTANCE","ALTER RESOURCE GROUP","ALTER SEQUENCE","ALTER USER","ALTER VIEW","ANALYZE TABLE","CHECK TABLE","CHECKSUM TABLE","COMMIT","CREATE DATABASE","CREATE INDEX","CREATE RESOURCE GROUP","CREATE ROLE","CREATE SEQUENCE","CREATE USER","DEALLOCATE PREPARE","DESCRIBE","DROP DATABASE","DROP INDEX","DROP RESOURCE GROUP","DROP ROLE","DROP TABLESPACE","DROP USER","DROP VIEW","EXPLAIN","FLUSH","GRANT","IMPORT TABLE","INSTALL COMPONENT","INSTALL PLUGIN","KILL","LOAD DATA","LOCK INSTANCE FOR BACKUP","LOCK TABLES","OPTIMIZE TABLE","PREPARE","RELEASE SAVEPOINT","RENAME TABLE","RENAME USER","REPAIR TABLE","RESET","REVOKE","ROLLBACK","ROLLBACK TO SAVEPOINT","SAVEPOINT","SET CHARACTER SET","SET DEFAULT ROLE","SET NAMES","SET PASSWORD","SET RESOURCE GROUP","SET ROLE","SET TRANSACTION","SHOW","SHOW BINARY LOGS","SHOW BINLOG EVENTS","SHOW CHARACTER SET","SHOW COLLATION","SHOW COLUMNS","SHOW CREATE DATABASE","SHOW CREATE TABLE","SHOW CREATE USER","SHOW CREATE VIEW","SHOW DATABASES","SHOW ENGINE","SHOW ENGINES","SHOW ERRORS","SHOW EVENTS","SHOW GRANTS","SHOW INDEX","SHOW MASTER STATUS","SHOW OPEN TABLES","SHOW PLUGINS","SHOW PRIVILEGES","SHOW PROCESSLIST","SHOW PROFILE","SHOW PROFILES","SHOW STATUS","SHOW TABLE STATUS","SHOW TABLES","SHOW TRIGGERS","SHOW VARIABLES","SHOW WARNINGS","TABLE","UNINSTALL COMPONENT","UNINSTALL PLUGIN","UNLOCK INSTANCE","UNLOCK TABLES","USE"]),UC=Q(["UNION [ALL | DISTINCT]"]),bC=Q(["JOIN","{LEFT | RIGHT} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT} [OUTER] JOIN","STRAIGHT_JOIN"]),GC=Q(["ON {UPDATE | DELETE} [SET NULL]","CHARACTER SET","{ROWS | RANGE} BETWEEN","IDENTIFIED BY"]),BC=Q([]),HC={name:"tidb",tokenizerOptions:{reservedSelect:MC,reservedClauses:[...PC,...$A,...tc],reservedSetOperations:UC,reservedJoins:bC,reservedKeywordPhrases:GC,reservedDataTypePhrases:BC,supportsXor:!0,reservedKeywords:DC,reservedDataTypes:yC,reservedFunctionNames:gC,stringTypes:['""-qq-bs',{quote:"''-qq-bs",prefixes:["N"]},{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:["``"],identChars:{first:"$",rest:"$",allowFirstCharNumber:!0},variableTypes:[{regex:"@@?[A-Za-z0-9_.$]+"},{quote:'""-qq-bs',prefixes:["@"],requirePrefix:!0},{quote:"''-qq-bs",prefixes:["@"],requirePrefix:!0},{quote:"``",prefixes:["@"],requirePrefix:!0}],paramTypes:{positional:!0},lineCommentTypes:["--","#"],operators:["%",":=","&","|","^","~","<<",">>","<=>","->","->>","&&","||","!","*.*"],postProcess:mo},formatOptions:{onelineClauses:[...$A,...tc],tabularOnelineClauses:tc}},FC=["ABORT","ABS","ACOS","ADVISOR","ARRAY_AGG","ARRAY_AGG","ARRAY_APPEND","ARRAY_AVG","ARRAY_BINARY_SEARCH","ARRAY_CONCAT","ARRAY_CONTAINS","ARRAY_COUNT","ARRAY_DISTINCT","ARRAY_EXCEPT","ARRAY_FLATTEN","ARRAY_IFNULL","ARRAY_INSERT","ARRAY_INTERSECT","ARRAY_LENGTH","ARRAY_MAX","ARRAY_MIN","ARRAY_MOVE","ARRAY_POSITION","ARRAY_PREPEND","ARRAY_PUT","ARRAY_RANGE","ARRAY_REMOVE","ARRAY_REPEAT","ARRAY_REPLACE","ARRAY_REVERSE","ARRAY_SORT","ARRAY_STAR","ARRAY_SUM","ARRAY_SYMDIFF","ARRAY_SYMDIFF1","ARRAY_SYMDIFFN","ARRAY_UNION","ASIN","ATAN","ATAN2","AVG","BASE64","BASE64_DECODE","BASE64_ENCODE","BITAND ","BITCLEAR ","BITNOT ","BITOR ","BITSET ","BITSHIFT ","BITTEST ","BITXOR ","CEIL","CLOCK_LOCAL","CLOCK_MILLIS","CLOCK_STR","CLOCK_TZ","CLOCK_UTC","COALESCE","CONCAT","CONCAT2","CONTAINS","CONTAINS_TOKEN","CONTAINS_TOKEN_LIKE","CONTAINS_TOKEN_REGEXP","COS","COUNT","COUNT","COUNTN","CUME_DIST","CURL","DATE_ADD_MILLIS","DATE_ADD_STR","DATE_DIFF_MILLIS","DATE_DIFF_STR","DATE_FORMAT_STR","DATE_PART_MILLIS","DATE_PART_STR","DATE_RANGE_MILLIS","DATE_RANGE_STR","DATE_TRUNC_MILLIS","DATE_TRUNC_STR","DECODE","DECODE_JSON","DEGREES","DENSE_RANK","DURATION_TO_STR","ENCODED_SIZE","ENCODE_JSON","EXP","FIRST_VALUE","FLOOR","GREATEST","HAS_TOKEN","IFINF","IFMISSING","IFMISSINGORNULL","IFNAN","IFNANORINF","IFNULL","INITCAP","ISARRAY","ISATOM","ISBITSET","ISBOOLEAN","ISNUMBER","ISOBJECT","ISSTRING","LAG","LAST_VALUE","LEAD","LEAST","LENGTH","LN","LOG","LOWER","LTRIM","MAX","MEAN","MEDIAN","META","MILLIS","MILLIS_TO_LOCAL","MILLIS_TO_STR","MILLIS_TO_TZ","MILLIS_TO_UTC","MILLIS_TO_ZONE_NAME","MIN","MISSINGIF","NANIF","NEGINFIF","NOW_LOCAL","NOW_MILLIS","NOW_STR","NOW_TZ","NOW_UTC","NTH_VALUE","NTILE","NULLIF","NVL","NVL2","OBJECT_ADD","OBJECT_CONCAT","OBJECT_INNER_PAIRS","OBJECT_INNER_VALUES","OBJECT_LENGTH","OBJECT_NAMES","OBJECT_PAIRS","OBJECT_PUT","OBJECT_REMOVE","OBJECT_RENAME","OBJECT_REPLACE","OBJECT_UNWRAP","OBJECT_VALUES","PAIRS","PERCENT_RANK","PI","POLY_LENGTH","POSINFIF","POSITION","POWER","RADIANS","RANDOM","RANK","RATIO_TO_REPORT","REGEXP_CONTAINS","REGEXP_LIKE","REGEXP_MATCHES","REGEXP_POSITION","REGEXP_REPLACE","REGEXP_SPLIT","REGEX_CONTAINS","REGEX_LIKE","REGEX_MATCHES","REGEX_POSITION","REGEX_REPLACE","REGEX_SPLIT","REPEAT","REPLACE","REVERSE","ROUND","ROW_NUMBER","RTRIM","SEARCH","SEARCH_META","SEARCH_SCORE","SIGN","SIN","SPLIT","SQRT","STDDEV","STDDEV_POP","STDDEV_SAMP","STR_TO_DURATION","STR_TO_MILLIS","STR_TO_TZ","STR_TO_UTC","STR_TO_ZONE_NAME","SUBSTR","SUFFIXES","SUM","TAN","TITLE","TOARRAY","TOATOM","TOBOOLEAN","TOKENS","TOKENS","TONUMBER","TOOBJECT","TOSTRING","TRIM","TRUNC","UPPER","UUID","VARIANCE","VARIANCE_POP","VARIANCE_SAMP","VAR_POP","VAR_SAMP","WEEKDAY_MILLIS","WEEKDAY_STR","CAST"],YC=["ADVISE","ALL","ALTER","ANALYZE","AND","ANY","ARRAY","AS","ASC","AT","BEGIN","BETWEEN","BINARY","BOOLEAN","BREAK","BUCKET","BUILD","BY","CALL","CASE","CAST","CLUSTER","COLLATE","COLLECTION","COMMIT","COMMITTED","CONNECT","CONTINUE","CORRELATED","COVER","CREATE","CURRENT","DATABASE","DATASET","DATASTORE","DECLARE","DECREMENT","DELETE","DERIVED","DESC","DESCRIBE","DISTINCT","DO","DROP","EACH","ELEMENT","ELSE","END","EVERY","EXCEPT","EXCLUDE","EXECUTE","EXISTS","EXPLAIN","FALSE","FETCH","FILTER","FIRST","FLATTEN","FLUSH","FOLLOWING","FOR","FORCE","FROM","FTS","FUNCTION","GOLANG","GRANT","GROUP","GROUPS","GSI","HASH","HAVING","IF","IGNORE","ILIKE","IN","INCLUDE","INCREMENT","INDEX","INFER","INLINE","INNER","INSERT","INTERSECT","INTO","IS","ISOLATION","JAVASCRIPT","JOIN","KEY","KEYS","KEYSPACE","KNOWN","LANGUAGE","LAST","LEFT","LET","LETTING","LEVEL","LIKE","LIMIT","LSM","MAP","MAPPING","MATCHED","MATERIALIZED","MERGE","MINUS","MISSING","NAMESPACE","NEST","NL","NO","NOT","NTH_VALUE","NULL","NULLS","NUMBER","OBJECT","OFFSET","ON","OPTION","OPTIONS","OR","ORDER","OTHERS","OUTER","OVER","PARSE","PARTITION","PASSWORD","PATH","POOL","PRECEDING","PREPARE","PRIMARY","PRIVATE","PRIVILEGE","PROBE","PROCEDURE","PUBLIC","RANGE","RAW","REALM","REDUCE","RENAME","RESPECT","RETURN","RETURNING","REVOKE","RIGHT","ROLE","ROLLBACK","ROW","ROWS","SATISFIES","SAVEPOINT","SCHEMA","SCOPE","SELECT","SELF","SEMI","SET","SHOW","SOME","START","STATISTICS","STRING","SYSTEM","THEN","TIES","TO","TRAN","TRANSACTION","TRIGGER","TRUE","TRUNCATE","UNBOUNDED","UNDER","UNION","UNIQUE","UNKNOWN","UNNEST","UNSET","UPDATE","UPSERT","USE","USER","USING","VALIDATE","VALUE","VALUED","VALUES","VIA","VIEW","WHEN","WHERE","WHILE","WINDOW","WITH","WITHIN","WORK","XOR"],jC=[],VC=Q(["SELECT [ALL | DISTINCT]"]),wC=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT INTO","VALUES","SET","MERGE INTO","WHEN [NOT] MATCHED THEN","UPDATE SET","INSERT","NEST","UNNEST","RETURNING"]),JA=Q(["UPDATE","DELETE FROM","SET SCHEMA","ADVISE","ALTER INDEX","BEGIN TRANSACTION","BUILD INDEX","COMMIT TRANSACTION","CREATE COLLECTION","CREATE FUNCTION","CREATE INDEX","CREATE PRIMARY INDEX","CREATE SCOPE","DROP COLLECTION","DROP FUNCTION","DROP INDEX","DROP PRIMARY INDEX","DROP SCOPE","EXECUTE","EXECUTE FUNCTION","EXPLAIN","GRANT","INFER","PREPARE","REVOKE","ROLLBACK TRANSACTION","SAVEPOINT","SET TRANSACTION","UPDATE STATISTICS","UPSERT","LET","SET CURRENT SCHEMA","SHOW","USE [PRIMARY] KEYS"]),WC=Q(["UNION [ALL]","EXCEPT [ALL]","INTERSECT [ALL]"]),XC=Q(["JOIN","{LEFT | RIGHT} [OUTER] JOIN","INNER JOIN"]),KC=Q(["{ROWS | RANGE | GROUPS} BETWEEN"]),zC=Q([]),kC={name:"n1ql",tokenizerOptions:{reservedSelect:VC,reservedClauses:[...wC,...JA],reservedSetOperations:WC,reservedJoins:XC,reservedKeywordPhrases:KC,reservedDataTypePhrases:zC,supportsXor:!0,reservedKeywords:YC,reservedDataTypes:jC,reservedFunctionNames:FC,stringTypes:['""-bs',"''-bs"],identTypes:["``"],extraParens:["[]","{}"],paramTypes:{positional:!0,numbered:["$"],named:["$"]},lineCommentTypes:["#","--"],operators:["%","==",":","||"]},formatOptions:{onelineClauses:JA}},$C=["ADD","AGENT","AGGREGATE","ALL","ALTER","AND","ANY","ARROW","AS","ASC","AT","ATTRIBUTE","AUTHID","AVG","BEGIN","BETWEEN","BLOCK","BODY","BOTH","BOUND","BULK","BY","BYTE","CALL","CALLING","CASCADE","CASE","CHARSET","CHARSETFORM","CHARSETID","CHECK","CLOSE","CLUSTER","CLUSTERS","COLAUTH","COLLECT","COLUMNS","COMMENT","COMMIT","COMMITTED","COMPILED","COMPRESS","CONNECT","CONSTANT","CONSTRUCTOR","CONTEXT","CONVERT","COUNT","CRASH","CREATE","CURRENT","CURSOR","CUSTOMDATUM","DANGLING","DATA","DAY","DECLARE","DEFAULT","DEFINE","DELETE","DESC","DETERMINISTIC","DISTINCT","DROP","DURATION","ELEMENT","ELSE","ELSIF","EMPTY","END","ESCAPE","EXCEPT","EXCEPTION","EXCEPTIONS","EXCLUSIVE","EXECUTE","EXISTS","EXIT","EXTERNAL","FETCH","FINAL","FIXED","FOR","FORALL","FORCE","FORM","FROM","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HASH","HAVING","HEAP","HIDDEN","HOUR","IDENTIFIED","IF","IMMEDIATE","IN","INCLUDING","INDEX","INDEXES","INDICATOR","INDICES","INFINITE","INSERT","INSTANTIABLE","INTERFACE","INTERSECT","INTERVAL","INTO","INVALIDATE","IS","ISOLATION","JAVA","LANGUAGE","LARGE","LEADING","LENGTH","LEVEL","LIBRARY","LIKE","LIKE2","LIKE4","LIKEC","LIMIT","LIMITED","LOCAL","LOCK","LOOP","MAP","MAX","MAXLEN","MEMBER","MERGE","MIN","MINUS","MINUTE","MOD","MODE","MODIFY","MONTH","MULTISET","NAME","NAN","NATIONAL","NATIVE","NEW","NOCOMPRESS","NOCOPY","NOT","NOWAIT","NULL","OBJECT","OCICOLL","OCIDATE","OCIDATETIME","OCIDURATION","OCIINTERVAL","OCILOBLOCATOR","OCINUMBER","OCIRAW","OCIREF","OCIREFCURSOR","OCIROWID","OCISTRING","OCITYPE","OF","ON","ONLY","OPAQUE","OPEN","OPERATOR","OPTION","OR","ORACLE","ORADATA","ORDER","OVERLAPS","ORGANIZATION","ORLANY","ORLVARY","OTHERS","OUT","OVERRIDING","PACKAGE","PARALLEL_ENABLE","PARAMETER","PARAMETERS","PARTITION","PASCAL","PIPE","PIPELINED","PRAGMA","PRIOR","PRIVATE","PROCEDURE","PUBLIC","RAISE","RANGE","READ","RECORD","REF","REFERENCE","REM","REMAINDER","RENAME","RESOURCE","RESULT","RETURN","RETURNING","REVERSE","REVOKE","ROLLBACK","ROW","SAMPLE","SAVE","SAVEPOINT","SB1","SB2","SB4","SECOND","SEGMENT","SELECT","SELF","SEPARATE","SEQUENCE","SERIALIZABLE","SET","SHARE","SHORT","SIZE","SIZE_T","SOME","SPARSE","SQL","SQLCODE","SQLDATA","SQLNAME","SQLSTATE","STANDARD","START","STATIC","STDDEV","STORED","STRING","STRUCT","STYLE","SUBMULTISET","SUBPARTITION","SUBSTITUTABLE","SUBTYPE","SUM","SYNONYM","TABAUTH","TABLE","TDO","THE","THEN","TIME","TIMEZONE_ABBR","TIMEZONE_HOUR","TIMEZONE_MINUTE","TIMEZONE_REGION","TO","TRAILING","TRANSAC","TRANSACTIONAL","TRUSTED","TYPE","UB1","UB2","UB4","UNDER","UNION","UNIQUE","UNSIGNED","UNTRUSTED","UPDATE","USE","USING","VALIST","VALUE","VALUES","VARIABLE","VARIANCE","VARRAY","VIEW","VIEWS","VOID","WHEN","WHERE","WHILE","WITH","WORK","WRAPPED","WRITE","YEAR","ZONE"],JC=["ARRAY","BFILE_BASE","BINARY","BLOB_BASE","CHAR VARYING","CHAR_BASE","CHAR","CHARACTER VARYING","CHARACTER","CLOB_BASE","DATE_BASE","DATE","DECIMAL","DOUBLE","FLOAT","INT","INTERVAL DAY","INTERVAL YEAR","LONG","NATIONAL CHAR VARYING","NATIONAL CHAR","NATIONAL CHARACTER VARYING","NATIONAL CHARACTER","NCHAR VARYING","NCHAR","NCHAR","NUMBER_BASE","NUMBER","NUMBERIC","NVARCHAR","PRECISION","RAW","TIMESTAMP","UROWID","VARCHAR","VARCHAR2"],qC=["ABS","ACOS","ASIN","ATAN","ATAN2","BITAND","CEIL","COS","COSH","EXP","FLOOR","LN","LOG","MOD","NANVL","POWER","REMAINDER","ROUND","SIGN","SIN","SINH","SQRT","TAN","TANH","TRUNC","WIDTH_BUCKET","CHR","CONCAT","INITCAP","LOWER","LPAD","LTRIM","NLS_INITCAP","NLS_LOWER","NLSSORT","NLS_UPPER","REGEXP_REPLACE","REGEXP_SUBSTR","REPLACE","RPAD","RTRIM","SOUNDEX","SUBSTR","TRANSLATE","TREAT","TRIM","UPPER","NLS_CHARSET_DECL_LEN","NLS_CHARSET_ID","NLS_CHARSET_NAME","ASCII","INSTR","LENGTH","REGEXP_INSTR","ADD_MONTHS","CURRENT_DATE","CURRENT_TIMESTAMP","DBTIMEZONE","EXTRACT","FROM_TZ","LAST_DAY","LOCALTIMESTAMP","MONTHS_BETWEEN","NEW_TIME","NEXT_DAY","NUMTODSINTERVAL","NUMTOYMINTERVAL","ROUND","SESSIONTIMEZONE","SYS_EXTRACT_UTC","SYSDATE","SYSTIMESTAMP","TO_CHAR","TO_TIMESTAMP","TO_TIMESTAMP_TZ","TO_DSINTERVAL","TO_YMINTERVAL","TRUNC","TZ_OFFSET","GREATEST","LEAST","ASCIISTR","BIN_TO_NUM","CAST","CHARTOROWID","COMPOSE","CONVERT","DECOMPOSE","HEXTORAW","NUMTODSINTERVAL","NUMTOYMINTERVAL","RAWTOHEX","RAWTONHEX","ROWIDTOCHAR","ROWIDTONCHAR","SCN_TO_TIMESTAMP","TIMESTAMP_TO_SCN","TO_BINARY_DOUBLE","TO_BINARY_FLOAT","TO_CHAR","TO_CLOB","TO_DATE","TO_DSINTERVAL","TO_LOB","TO_MULTI_BYTE","TO_NCHAR","TO_NCLOB","TO_NUMBER","TO_DSINTERVAL","TO_SINGLE_BYTE","TO_TIMESTAMP","TO_TIMESTAMP_TZ","TO_YMINTERVAL","TO_YMINTERVAL","TRANSLATE","UNISTR","BFILENAME","EMPTY_BLOB,","EMPTY_CLOB","CARDINALITY","COLLECT","POWERMULTISET","POWERMULTISET_BY_CARDINALITY","SET","SYS_CONNECT_BY_PATH","CLUSTER_ID","CLUSTER_PROBABILITY","CLUSTER_SET","FEATURE_ID","FEATURE_SET","FEATURE_VALUE","PREDICTION","PREDICTION_COST","PREDICTION_DETAILS","PREDICTION_PROBABILITY","PREDICTION_SET","APPENDCHILDXML","DELETEXML","DEPTH","EXTRACT","EXISTSNODE","EXTRACTVALUE","INSERTCHILDXML","INSERTXMLBEFORE","PATH","SYS_DBURIGEN","SYS_XMLAGG","SYS_XMLGEN","UPDATEXML","XMLAGG","XMLCDATA","XMLCOLATTVAL","XMLCOMMENT","XMLCONCAT","XMLFOREST","XMLPARSE","XMLPI","XMLQUERY","XMLROOT","XMLSEQUENCE","XMLSERIALIZE","XMLTABLE","XMLTRANSFORM","DECODE","DUMP","ORA_HASH","VSIZE","COALESCE","LNNVL","NULLIF","NVL","NVL2","SYS_CONTEXT","SYS_GUID","SYS_TYPEID","UID","USER","USERENV","AVG","COLLECT","CORR","CORR_S","CORR_K","COUNT","COVAR_POP","COVAR_SAMP","CUME_DIST","DENSE_RANK","FIRST","GROUP_ID","GROUPING","GROUPING_ID","LAST","MAX","MEDIAN","MIN","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","RANK","REGR_SLOPE","REGR_INTERCEPT","REGR_COUNT","REGR_R2","REGR_AVGX","REGR_AVGY","REGR_SXX","REGR_SYY","REGR_SXY","STATS_BINOMIAL_TEST","STATS_CROSSTAB","STATS_F_TEST","STATS_KS_TEST","STATS_MODE","STATS_MW_TEST","STATS_ONE_WAY_ANOVA","STATS_T_TEST_ONE","STATS_T_TEST_PAIRED","STATS_T_TEST_INDEP","STATS_T_TEST_INDEPU","STATS_WSR_TEST","STDDEV","STDDEV_POP","STDDEV_SAMP","SUM","VAR_POP","VAR_SAMP","VARIANCE","FIRST_VALUE","LAG","LAST_VALUE","LEAD","NTILE","RATIO_TO_REPORT","ROW_NUMBER","DEREF","MAKE_REF","REF","REFTOHEX","VALUE","CV","ITERATION_NUMBER","PRESENTNNV","PRESENTV","PREVIOUS"],QC=Q(["SELECT [ALL | DISTINCT | UNIQUE]"]),ZC=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER [SIBLINGS] BY","OFFSET","FETCH {FIRST | NEXT}","FOR UPDATE [OF]","INSERT [INTO | ALL INTO]","VALUES","SET","MERGE [INTO]","WHEN [NOT] MATCHED [THEN]","UPDATE SET","RETURNING"]),qA=Q(["CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"]),nc=Q(["CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW","CREATE MATERIALIZED VIEW","UPDATE [ONLY]","DELETE FROM [ONLY]","DROP TABLE","ALTER TABLE","ADD","DROP {COLUMN | UNUSED COLUMNS | COLUMNS CONTINUE}","MODIFY","RENAME TO","RENAME COLUMN","TRUNCATE TABLE","SET SCHEMA","BEGIN","CONNECT BY","DECLARE","EXCEPT","EXCEPTION","LOOP","START WITH"]),ep=Q(["UNION [ALL]","MINUS","INTERSECT"]),tp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN","{CROSS | OUTER} APPLY"]),np=Q(["ON {UPDATE | DELETE} [SET NULL]","ON COMMIT","{ROWS | RANGE} BETWEEN"]),ap=Q([]),rp={name:"plsql",tokenizerOptions:{reservedSelect:QC,reservedClauses:[...ZC,...qA,...nc],reservedSetOperations:ep,reservedJoins:tp,reservedKeywordPhrases:np,reservedDataTypePhrases:ap,supportsXor:!0,reservedKeywords:$C,reservedDataTypes:JC,reservedFunctionNames:qC,stringTypes:[{quote:"''-qq",prefixes:["N"]},{quote:"q''",prefixes:["N"]}],identTypes:['""-qq'],identChars:{rest:"$#"},variableTypes:[{regex:"&{1,2}[A-Za-z][A-Za-z0-9_$#]*"}],paramTypes:{numbered:[":"],named:[":"]},operators:["**",":=","%","~=","^=",">>","<<","=>","@","||"],postProcess:sp},formatOptions:{alwaysDenseOperators:["@"],onelineClauses:[...qA,...nc],tabularOnelineClauses:nc}};function sp(r){let l=Rr;return r.map(E=>ur.SET(E)&&ur.BY(l)?Object.assign(Object.assign({},E),{type:Ae.RESERVED_KEYWORD}):(Hd(E.type)&&(l=E),E))}const lp=["ABS","ACOS","ACOSD","ACOSH","ASIN","ASIND","ASINH","ATAN","ATAN2","ATAN2D","ATAND","ATANH","CBRT","CEIL","CEILING","COS","COSD","COSH","COT","COTD","DEGREES","DIV","EXP","FACTORIAL","FLOOR","GCD","LCM","LN","LOG","LOG10","MIN_SCALE","MOD","PI","POWER","RADIANS","RANDOM","ROUND","SCALE","SETSEED","SIGN","SIN","SIND","SINH","SQRT","TAN","TAND","TANH","TRIM_SCALE","TRUNC","WIDTH_BUCKET","ABS","ASCII","BIT_LENGTH","BTRIM","CHARACTER_LENGTH","CHAR_LENGTH","CHR","CONCAT","CONCAT_WS","FORMAT","INITCAP","LEFT","LENGTH","LOWER","LPAD","LTRIM","MD5","NORMALIZE","OCTET_LENGTH","OVERLAY","PARSE_IDENT","PG_CLIENT_ENCODING","POSITION","QUOTE_IDENT","QUOTE_LITERAL","QUOTE_NULLABLE","REGEXP_MATCH","REGEXP_MATCHES","REGEXP_REPLACE","REGEXP_SPLIT_TO_ARRAY","REGEXP_SPLIT_TO_TABLE","REPEAT","REPLACE","REVERSE","RIGHT","RPAD","RTRIM","SPLIT_PART","SPRINTF","STARTS_WITH","STRING_AGG","STRING_TO_ARRAY","STRING_TO_TABLE","STRPOS","SUBSTR","SUBSTRING","TO_ASCII","TO_HEX","TRANSLATE","TRIM","UNISTR","UPPER","BIT_COUNT","BIT_LENGTH","BTRIM","CONVERT","CONVERT_FROM","CONVERT_TO","DECODE","ENCODE","GET_BIT","GET_BYTE","LENGTH","LTRIM","MD5","OCTET_LENGTH","OVERLAY","POSITION","RTRIM","SET_BIT","SET_BYTE","SHA224","SHA256","SHA384","SHA512","STRING_AGG","SUBSTR","SUBSTRING","TRIM","BIT_COUNT","BIT_LENGTH","GET_BIT","LENGTH","OCTET_LENGTH","OVERLAY","POSITION","SET_BIT","SUBSTRING","REGEXP_MATCH","REGEXP_MATCHES","REGEXP_REPLACE","REGEXP_SPLIT_TO_ARRAY","REGEXP_SPLIT_TO_TABLE","TO_CHAR","TO_DATE","TO_NUMBER","TO_TIMESTAMP","CLOCK_TIMESTAMP","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATE_BIN","DATE_PART","DATE_TRUNC","EXTRACT","ISFINITE","JUSTIFY_DAYS","JUSTIFY_HOURS","JUSTIFY_INTERVAL","LOCALTIME","LOCALTIMESTAMP","MAKE_DATE","MAKE_INTERVAL","MAKE_TIME","MAKE_TIMESTAMP","MAKE_TIMESTAMPTZ","NOW","PG_SLEEP","PG_SLEEP_FOR","PG_SLEEP_UNTIL","STATEMENT_TIMESTAMP","TIMEOFDAY","TO_TIMESTAMP","TRANSACTION_TIMESTAMP","ENUM_FIRST","ENUM_LAST","ENUM_RANGE","AREA","BOUND_BOX","BOX","CENTER","CIRCLE","DIAGONAL","DIAMETER","HEIGHT","ISCLOSED","ISOPEN","LENGTH","LINE","LSEG","NPOINTS","PATH","PCLOSE","POINT","POLYGON","POPEN","RADIUS","SLOPE","WIDTH","ABBREV","BROADCAST","FAMILY","HOST","HOSTMASK","INET_MERGE","INET_SAME_FAMILY","MACADDR8_SET7BIT","MASKLEN","NETMASK","NETWORK","SET_MASKLEN","TRUNC","ARRAY_TO_TSVECTOR","GET_CURRENT_TS_CONFIG","JSONB_TO_TSVECTOR","JSON_TO_TSVECTOR","LENGTH","NUMNODE","PHRASETO_TSQUERY","PLAINTO_TSQUERY","QUERYTREE","SETWEIGHT","STRIP","TO_TSQUERY","TO_TSVECTOR","TSQUERY_PHRASE","TSVECTOR_TO_ARRAY","TS_DEBUG","TS_DELETE","TS_FILTER","TS_HEADLINE","TS_LEXIZE","TS_PARSE","TS_RANK","TS_RANK_CD","TS_REWRITE","TS_STAT","TS_TOKEN_TYPE","WEBSEARCH_TO_TSQUERY","GEN_RANDOM_UUID","UUIDV4","UUIDV7","UUID_EXTRACT_TIMESTAMP","UUID_EXTRACT_VERSION","CURSOR_TO_XML","CURSOR_TO_XMLSCHEMA","DATABASE_TO_XML","DATABASE_TO_XMLSCHEMA","DATABASE_TO_XML_AND_XMLSCHEMA","NEXTVAL","QUERY_TO_XML","QUERY_TO_XMLSCHEMA","QUERY_TO_XML_AND_XMLSCHEMA","SCHEMA_TO_XML","SCHEMA_TO_XMLSCHEMA","SCHEMA_TO_XML_AND_XMLSCHEMA","STRING","TABLE_TO_XML","TABLE_TO_XMLSCHEMA","TABLE_TO_XML_AND_XMLSCHEMA","XMLAGG","XMLCOMMENT","XMLCONCAT","XMLELEMENT","XMLEXISTS","XMLFOREST","XMLPARSE","XMLPI","XMLROOT","XMLSERIALIZE","XMLTABLE","XML_IS_WELL_FORMED","XML_IS_WELL_FORMED_CONTENT","XML_IS_WELL_FORMED_DOCUMENT","XPATH","XPATH_EXISTS","ARRAY_TO_JSON","JSONB_AGG","JSONB_ARRAY_ELEMENTS","JSONB_ARRAY_ELEMENTS_TEXT","JSONB_ARRAY_LENGTH","JSONB_BUILD_ARRAY","JSONB_BUILD_OBJECT","JSONB_EACH","JSONB_EACH_TEXT","JSONB_EXTRACT_PATH","JSONB_EXTRACT_PATH_TEXT","JSONB_INSERT","JSONB_OBJECT","JSONB_OBJECT_AGG","JSONB_OBJECT_KEYS","JSONB_PATH_EXISTS","JSONB_PATH_EXISTS_TZ","JSONB_PATH_MATCH","JSONB_PATH_MATCH_TZ","JSONB_PATH_QUERY","JSONB_PATH_QUERY_ARRAY","JSONB_PATH_QUERY_ARRAY_TZ","JSONB_PATH_QUERY_FIRST","JSONB_PATH_QUERY_FIRST_TZ","JSONB_PATH_QUERY_TZ","JSONB_POPULATE_RECORD","JSONB_POPULATE_RECORDSET","JSONB_PRETTY","JSONB_SET","JSONB_SET_LAX","JSONB_STRIP_NULLS","JSONB_TO_RECORD","JSONB_TO_RECORDSET","JSONB_TYPEOF","JSON_AGG","JSON_ARRAY_ELEMENTS","JSON_ARRAY_ELEMENTS_TEXT","JSON_ARRAY_LENGTH","JSON_BUILD_ARRAY","JSON_BUILD_OBJECT","JSON_EACH","JSON_EACH_TEXT","JSON_EXTRACT_PATH","JSON_EXTRACT_PATH_TEXT","JSON_OBJECT","JSON_OBJECT_AGG","JSON_OBJECT_KEYS","JSON_POPULATE_RECORD","JSON_POPULATE_RECORDSET","JSON_STRIP_NULLS","JSON_TO_RECORD","JSON_TO_RECORDSET","JSON_TYPEOF","ROW_TO_JSON","TO_JSON","TO_JSONB","TO_TIMESTAMP","CURRVAL","LASTVAL","NEXTVAL","SETVAL","COALESCE","GREATEST","LEAST","NULLIF","ARRAY_AGG","ARRAY_APPEND","ARRAY_CAT","ARRAY_DIMS","ARRAY_FILL","ARRAY_LENGTH","ARRAY_LOWER","ARRAY_NDIMS","ARRAY_POSITION","ARRAY_POSITIONS","ARRAY_PREPEND","ARRAY_REMOVE","ARRAY_REPLACE","ARRAY_TO_STRING","ARRAY_UPPER","CARDINALITY","STRING_TO_ARRAY","TRIM_ARRAY","UNNEST","ISEMPTY","LOWER","LOWER_INC","LOWER_INF","MULTIRANGE","RANGE_MERGE","UPPER","UPPER_INC","UPPER_INF","ARRAY_AGG","AVG","BIT_AND","BIT_OR","BIT_XOR","BOOL_AND","BOOL_OR","COALESCE","CORR","COUNT","COVAR_POP","COVAR_SAMP","CUME_DIST","DENSE_RANK","EVERY","GROUPING","JSONB_AGG","JSONB_OBJECT_AGG","JSON_AGG","JSON_OBJECT_AGG","MAX","MIN","MODE","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","RANGE_AGG","RANGE_INTERSECT_AGG","RANK","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","STDDEV","STDDEV_POP","STDDEV_SAMP","STRING_AGG","SUM","TO_JSON","TO_JSONB","VARIANCE","VAR_POP","VAR_SAMP","XMLAGG","CUME_DIST","DENSE_RANK","FIRST_VALUE","LAG","LAST_VALUE","LEAD","NTH_VALUE","NTILE","PERCENT_RANK","RANK","ROW_NUMBER","GENERATE_SERIES","GENERATE_SUBSCRIPTS","ACLDEFAULT","ACLEXPLODE","COL_DESCRIPTION","CURRENT_CATALOG","CURRENT_DATABASE","CURRENT_QUERY","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_SCHEMAS","CURRENT_USER","FORMAT_TYPE","HAS_ANY_COLUMN_PRIVILEGE","HAS_COLUMN_PRIVILEGE","HAS_DATABASE_PRIVILEGE","HAS_FOREIGN_DATA_WRAPPER_PRIVILEGE","HAS_FUNCTION_PRIVILEGE","HAS_LANGUAGE_PRIVILEGE","HAS_SCHEMA_PRIVILEGE","HAS_SEQUENCE_PRIVILEGE","HAS_SERVER_PRIVILEGE","HAS_TABLESPACE_PRIVILEGE","HAS_TABLE_PRIVILEGE","HAS_TYPE_PRIVILEGE","INET_CLIENT_ADDR","INET_CLIENT_PORT","INET_SERVER_ADDR","INET_SERVER_PORT","MAKEACLITEM","OBJ_DESCRIPTION","PG_BACKEND_PID","PG_BLOCKING_PIDS","PG_COLLATION_IS_VISIBLE","PG_CONF_LOAD_TIME","PG_CONTROL_CHECKPOINT","PG_CONTROL_INIT","PG_CONTROL_SYSTEM","PG_CONVERSION_IS_VISIBLE","PG_CURRENT_LOGFILE","PG_CURRENT_SNAPSHOT","PG_CURRENT_XACT_ID","PG_CURRENT_XACT_ID_IF_ASSIGNED","PG_DESCRIBE_OBJECT","PG_FUNCTION_IS_VISIBLE","PG_GET_CATALOG_FOREIGN_KEYS","PG_GET_CONSTRAINTDEF","PG_GET_EXPR","PG_GET_FUNCTIONDEF","PG_GET_FUNCTION_ARGUMENTS","PG_GET_FUNCTION_IDENTITY_ARGUMENTS","PG_GET_FUNCTION_RESULT","PG_GET_INDEXDEF","PG_GET_KEYWORDS","PG_GET_OBJECT_ADDRESS","PG_GET_OWNED_SEQUENCE","PG_GET_RULEDEF","PG_GET_SERIAL_SEQUENCE","PG_GET_STATISTICSOBJDEF","PG_GET_TRIGGERDEF","PG_GET_USERBYID","PG_GET_VIEWDEF","PG_HAS_ROLE","PG_IDENTIFY_OBJECT","PG_IDENTIFY_OBJECT_AS_ADDRESS","PG_INDEXAM_HAS_PROPERTY","PG_INDEX_COLUMN_HAS_PROPERTY","PG_INDEX_HAS_PROPERTY","PG_IS_OTHER_TEMP_SCHEMA","PG_JIT_AVAILABLE","PG_LAST_COMMITTED_XACT","PG_LISTENING_CHANNELS","PG_MY_TEMP_SCHEMA","PG_NOTIFICATION_QUEUE_USAGE","PG_OPCLASS_IS_VISIBLE","PG_OPERATOR_IS_VISIBLE","PG_OPFAMILY_IS_VISIBLE","PG_OPTIONS_TO_TABLE","PG_POSTMASTER_START_TIME","PG_SAFE_SNAPSHOT_BLOCKING_PIDS","PG_SNAPSHOT_XIP","PG_SNAPSHOT_XMAX","PG_SNAPSHOT_XMIN","PG_STATISTICS_OBJ_IS_VISIBLE","PG_TABLESPACE_DATABASES","PG_TABLESPACE_LOCATION","PG_TABLE_IS_VISIBLE","PG_TRIGGER_DEPTH","PG_TS_CONFIG_IS_VISIBLE","PG_TS_DICT_IS_VISIBLE","PG_TS_PARSER_IS_VISIBLE","PG_TS_TEMPLATE_IS_VISIBLE","PG_TYPEOF","PG_TYPE_IS_VISIBLE","PG_VISIBLE_IN_SNAPSHOT","PG_XACT_COMMIT_TIMESTAMP","PG_XACT_COMMIT_TIMESTAMP_ORIGIN","PG_XACT_STATUS","PQSERVERVERSION","ROW_SECURITY_ACTIVE","SESSION_USER","SHOBJ_DESCRIPTION","TO_REGCLASS","TO_REGCOLLATION","TO_REGNAMESPACE","TO_REGOPER","TO_REGOPERATOR","TO_REGPROC","TO_REGPROCEDURE","TO_REGROLE","TO_REGTYPE","TXID_CURRENT","TXID_CURRENT_IF_ASSIGNED","TXID_CURRENT_SNAPSHOT","TXID_SNAPSHOT_XIP","TXID_SNAPSHOT_XMAX","TXID_SNAPSHOT_XMIN","TXID_STATUS","TXID_VISIBLE_IN_SNAPSHOT","USER","VERSION","BRIN_DESUMMARIZE_RANGE","BRIN_SUMMARIZE_NEW_VALUES","BRIN_SUMMARIZE_RANGE","CONVERT_FROM","CURRENT_SETTING","GIN_CLEAN_PENDING_LIST","PG_ADVISORY_LOCK","PG_ADVISORY_LOCK_SHARED","PG_ADVISORY_UNLOCK","PG_ADVISORY_UNLOCK_ALL","PG_ADVISORY_UNLOCK_SHARED","PG_ADVISORY_XACT_LOCK","PG_ADVISORY_XACT_LOCK_SHARED","PG_BACKUP_START_TIME","PG_CANCEL_BACKEND","PG_COLLATION_ACTUAL_VERSION","PG_COLUMN_COMPRESSION","PG_COLUMN_SIZE","PG_COPY_LOGICAL_REPLICATION_SLOT","PG_COPY_PHYSICAL_REPLICATION_SLOT","PG_CREATE_LOGICAL_REPLICATION_SLOT","PG_CREATE_PHYSICAL_REPLICATION_SLOT","PG_CREATE_RESTORE_POINT","PG_CURRENT_WAL_FLUSH_LSN","PG_CURRENT_WAL_INSERT_LSN","PG_CURRENT_WAL_LSN","PG_DATABASE_SIZE","PG_DROP_REPLICATION_SLOT","PG_EXPORT_SNAPSHOT","PG_FILENODE_RELATION","PG_GET_WAL_REPLAY_PAUSE_STATE","PG_IMPORT_SYSTEM_COLLATIONS","PG_INDEXES_SIZE","PG_IS_IN_BACKUP","PG_IS_IN_RECOVERY","PG_IS_WAL_REPLAY_PAUSED","PG_LAST_WAL_RECEIVE_LSN","PG_LAST_WAL_REPLAY_LSN","PG_LAST_XACT_REPLAY_TIMESTAMP","PG_LOGICAL_EMIT_MESSAGE","PG_LOGICAL_SLOT_GET_BINARY_CHANGES","PG_LOGICAL_SLOT_GET_CHANGES","PG_LOGICAL_SLOT_PEEK_BINARY_CHANGES","PG_LOGICAL_SLOT_PEEK_CHANGES","PG_LOG_BACKEND_MEMORY_CONTEXTS","PG_LS_ARCHIVE_STATUSDIR","PG_LS_DIR","PG_LS_LOGDIR","PG_LS_TMPDIR","PG_LS_WALDIR","PG_PARTITION_ANCESTORS","PG_PARTITION_ROOT","PG_PARTITION_TREE","PG_PROMOTE","PG_READ_BINARY_FILE","PG_READ_FILE","PG_RELATION_FILENODE","PG_RELATION_FILEPATH","PG_RELATION_SIZE","PG_RELOAD_CONF","PG_REPLICATION_ORIGIN_ADVANCE","PG_REPLICATION_ORIGIN_CREATE","PG_REPLICATION_ORIGIN_DROP","PG_REPLICATION_ORIGIN_OID","PG_REPLICATION_ORIGIN_PROGRESS","PG_REPLICATION_ORIGIN_SESSION_IS_SETUP","PG_REPLICATION_ORIGIN_SESSION_PROGRESS","PG_REPLICATION_ORIGIN_SESSION_RESET","PG_REPLICATION_ORIGIN_SESSION_SETUP","PG_REPLICATION_ORIGIN_XACT_RESET","PG_REPLICATION_ORIGIN_XACT_SETUP","PG_REPLICATION_SLOT_ADVANCE","PG_ROTATE_LOGFILE","PG_SIZE_BYTES","PG_SIZE_PRETTY","PG_START_BACKUP","PG_STAT_FILE","PG_STOP_BACKUP","PG_SWITCH_WAL","PG_TABLESPACE_SIZE","PG_TABLE_SIZE","PG_TERMINATE_BACKEND","PG_TOTAL_RELATION_SIZE","PG_TRY_ADVISORY_LOCK","PG_TRY_ADVISORY_LOCK_SHARED","PG_TRY_ADVISORY_XACT_LOCK","PG_TRY_ADVISORY_XACT_LOCK_SHARED","PG_WALFILE_NAME","PG_WALFILE_NAME_OFFSET","PG_WAL_LSN_DIFF","PG_WAL_REPLAY_PAUSE","PG_WAL_REPLAY_RESUME","SET_CONFIG","SUPPRESS_REDUNDANT_UPDATES_TRIGGER","TSVECTOR_UPDATE_TRIGGER","TSVECTOR_UPDATE_TRIGGER_COLUMN","PG_EVENT_TRIGGER_DDL_COMMANDS","PG_EVENT_TRIGGER_DROPPED_OBJECTS","PG_EVENT_TRIGGER_TABLE_REWRITE_OID","PG_EVENT_TRIGGER_TABLE_REWRITE_REASON","PG_GET_OBJECT_ADDRESS","PG_MCV_LIST_ITEMS","CAST"],ip=["ALL","ANALYSE","ANALYZE","AND","ANY","AS","ASC","ASYMMETRIC","AUTHORIZATION","BETWEEN","BINARY","BOTH","CASE","CAST","CHECK","COLLATE","COLLATION","COLUMN","CONCURRENTLY","CONSTRAINT","CREATE","CROSS","CURRENT_CATALOG","CURRENT_DATE","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","DAY","DEFAULT","DEFERRABLE","DESC","DISTINCT","DO","ELSE","END","EXCEPT","EXISTS","FALSE","FETCH","FILTER","FOR","FOREIGN","FREEZE","FROM","FULL","GRANT","GROUP","HAVING","HOUR","ILIKE","IN","INITIALLY","INNER","INOUT","INTERSECT","INTO","IS","ISNULL","JOIN","LATERAL","LEADING","LEFT","LIKE","LIMIT","LOCALTIME","LOCALTIMESTAMP","MINUTE","MONTH","NATURAL","NOT","NOTNULL","NULL","NULLIF","OFFSET","ON","ONLY","OR","ORDER","OUT","OUTER","OVER","OVERLAPS","PLACING","PRIMARY","REFERENCES","RETURNING","RIGHT","ROW","SECOND","SELECT","SESSION_USER","SIMILAR","SOME","SYMMETRIC","TABLE","TABLESAMPLE","THEN","TO","TRAILING","TRUE","UNION","UNIQUE","USER","USING","VALUES","VARIADIC","VERBOSE","WHEN","WHERE","WINDOW","WITH","WITHIN","WITHOUT","YEAR"],op=["ARRAY","BIGINT","BIT","BIT VARYING","BOOL","BOOLEAN","CHAR","CHARACTER","CHARACTER VARYING","DECIMAL","DEC","DOUBLE","ENUM","FLOAT","INT","INTEGER","INTERVAL","NCHAR","NUMERIC","JSON","JSONB","PRECISION","REAL","SMALLINT","TEXT","TIME","TIMESTAMP","TIMESTAMPTZ","UUID","VARCHAR","XML","ZONE"],Ep=Q(["SELECT [ALL | DISTINCT]"]),Tp=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY [ALL | DISTINCT]","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","FETCH {FIRST | NEXT}","FOR {UPDATE | NO KEY UPDATE | SHARE | KEY SHARE} [OF]","INSERT INTO","VALUES","DEFAULT VALUES","SET","RETURNING"]),QA=Q(["CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"]),ac=Q(["CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW","CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]","UPDATE [ONLY]","WHERE CURRENT OF","ON CONFLICT","DELETE FROM [ONLY]","DROP TABLE [IF EXISTS]","ALTER TABLE [IF EXISTS] [ONLY]","ALTER TABLE ALL IN TABLESPACE","RENAME [COLUMN]","RENAME TO","ADD [COLUMN] [IF NOT EXISTS]","DROP [COLUMN] [IF EXISTS]","ALTER [COLUMN]","SET DATA TYPE","{SET | DROP} DEFAULT","{SET | DROP} NOT NULL","TRUNCATE [TABLE] [ONLY]","SET SCHEMA","AFTER","ABORT","ALTER AGGREGATE","ALTER COLLATION","ALTER CONVERSION","ALTER DATABASE","ALTER DEFAULT PRIVILEGES","ALTER DOMAIN","ALTER EVENT TRIGGER","ALTER EXTENSION","ALTER FOREIGN DATA WRAPPER","ALTER FOREIGN TABLE","ALTER FUNCTION","ALTER GROUP","ALTER INDEX","ALTER LANGUAGE","ALTER LARGE OBJECT","ALTER MATERIALIZED VIEW","ALTER OPERATOR","ALTER OPERATOR CLASS","ALTER OPERATOR FAMILY","ALTER POLICY","ALTER PROCEDURE","ALTER PUBLICATION","ALTER ROLE","ALTER ROUTINE","ALTER RULE","ALTER SCHEMA","ALTER SEQUENCE","ALTER SERVER","ALTER STATISTICS","ALTER SUBSCRIPTION","ALTER SYSTEM","ALTER TABLESPACE","ALTER TEXT SEARCH CONFIGURATION","ALTER TEXT SEARCH DICTIONARY","ALTER TEXT SEARCH PARSER","ALTER TEXT SEARCH TEMPLATE","ALTER TRIGGER","ALTER TYPE","ALTER USER","ALTER USER MAPPING","ALTER VIEW","ANALYZE","BEGIN","CALL","CHECKPOINT","CLOSE","CLUSTER","COMMENT ON","COMMIT","COMMIT PREPARED","COPY","CREATE ACCESS METHOD","CREATE [OR REPLACE] AGGREGATE","CREATE CAST","CREATE COLLATION","CREATE [DEFAULT] CONVERSION","CREATE DATABASE","CREATE DOMAIN","CREATE EVENT TRIGGER","CREATE EXTENSION","CREATE FOREIGN DATA WRAPPER","CREATE FOREIGN TABLE","CREATE [OR REPLACE] FUNCTION","CREATE GROUP","CREATE [UNIQUE] INDEX","CREATE [OR REPLACE] [TRUSTED] [PROCEDURAL] LANGUAGE","CREATE OPERATOR","CREATE OPERATOR CLASS","CREATE OPERATOR FAMILY","CREATE POLICY","CREATE [OR REPLACE] PROCEDURE","CREATE PUBLICATION","CREATE ROLE","CREATE [OR REPLACE] RULE","CREATE SCHEMA [AUTHORIZATION]","CREATE [TEMPORARY | TEMP | UNLOGGED] SEQUENCE","CREATE SERVER","CREATE STATISTICS","CREATE SUBSCRIPTION","CREATE TABLESPACE","CREATE TEXT SEARCH CONFIGURATION","CREATE TEXT SEARCH DICTIONARY","CREATE TEXT SEARCH PARSER","CREATE TEXT SEARCH TEMPLATE","CREATE [OR REPLACE] TRANSFORM","CREATE [OR REPLACE] [CONSTRAINT] TRIGGER","CREATE TYPE","CREATE USER","CREATE USER MAPPING","DEALLOCATE","DECLARE","DISCARD","DROP ACCESS METHOD","DROP AGGREGATE","DROP CAST","DROP COLLATION","DROP CONVERSION","DROP DATABASE","DROP DOMAIN","DROP EVENT TRIGGER","DROP EXTENSION","DROP FOREIGN DATA WRAPPER","DROP FOREIGN TABLE","DROP FUNCTION","DROP GROUP","DROP IDENTITY","DROP INDEX","DROP LANGUAGE","DROP MATERIALIZED VIEW [IF EXISTS]","DROP OPERATOR","DROP OPERATOR CLASS","DROP OPERATOR FAMILY","DROP OWNED","DROP POLICY","DROP PROCEDURE","DROP PUBLICATION","DROP ROLE","DROP ROUTINE","DROP RULE","DROP SCHEMA","DROP SEQUENCE","DROP SERVER","DROP STATISTICS","DROP SUBSCRIPTION","DROP TABLESPACE","DROP TEXT SEARCH CONFIGURATION","DROP TEXT SEARCH DICTIONARY","DROP TEXT SEARCH PARSER","DROP TEXT SEARCH TEMPLATE","DROP TRANSFORM","DROP TRIGGER","DROP TYPE","DROP USER","DROP USER MAPPING","DROP VIEW","EXECUTE","EXPLAIN","FETCH","GRANT","IMPORT FOREIGN SCHEMA","LISTEN","LOAD","LOCK","MOVE","NOTIFY","OVERRIDING SYSTEM VALUE","PREPARE","PREPARE TRANSACTION","REASSIGN OWNED","REFRESH MATERIALIZED VIEW","REINDEX","RELEASE SAVEPOINT","RESET [ALL|ROLE|SESSION AUTHORIZATION]","REVOKE","ROLLBACK","ROLLBACK PREPARED","ROLLBACK TO SAVEPOINT","SAVEPOINT","SECURITY LABEL","SELECT INTO","SET CONSTRAINTS","SET ROLE","SET SESSION AUTHORIZATION","SET TRANSACTION","SHOW","START TRANSACTION","UNLISTEN","VACUUM"]),cp=Q(["UNION [ALL | DISTINCT]","EXCEPT [ALL | DISTINCT]","INTERSECT [ALL | DISTINCT]"]),Sp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"]),Rp=Q(["PRIMARY KEY","GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY","ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]","DO {NOTHING | UPDATE}","AS MATERIALIZED","{ROWS | RANGE | GROUPS} BETWEEN","IS [NOT] DISTINCT FROM","NULLS {FIRST | LAST}","WITH ORDINALITY"]),up=Q(["[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"]),Ap={name:"postgresql",tokenizerOptions:{reservedSelect:Ep,reservedClauses:[...Tp,...QA,...ac],reservedSetOperations:cp,reservedJoins:Sp,reservedKeywordPhrases:Rp,reservedDataTypePhrases:up,reservedKeywords:ip,reservedDataTypes:op,reservedFunctionNames:lp,nestedBlockComments:!0,extraParens:["[]"],underscoresInNumbers:!0,stringTypes:["$$",{quote:"''-qq",prefixes:["U&"]},{quote:"''-qq-bs",prefixes:["E"],requirePrefix:!0},{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:[{quote:'""-qq',prefixes:["U&"]}],identChars:{rest:"$"},paramTypes:{numbered:["$"]},operators:["%","^","|/","||/","@",":=","&","|","#","~","<<",">>","~>~","~<~","~>=~","~<=~","@-@","@@","##","<->","&&","&<","&>","<<|","&<|","|>>","|&>","<^","^>","?#","?-","?|","?-|","?||","@>","<@","~=","?","@?","?&","->","->>","#>","#>>","#-","=>",">>=","<<=","~~","~~*","!~~","!~~*","~","~*","!~","!~*","-|-","||","@@@","!!","^@","<%","%>","<<%","%>>","<<->","<->>","<<<->","<->>>","::",":","<#>","<=>","<+>","<~>","<%>"],operatorKeyword:!0},formatOptions:{alwaysDenseOperators:["::",":"],onelineClauses:[...QA,...ac],tabularOnelineClauses:ac}},dp=["ANY_VALUE","APPROXIMATE PERCENTILE_DISC","AVG","COUNT","LISTAGG","MAX","MEDIAN","MIN","PERCENTILE_CONT","STDDEV_SAMP","STDDEV_POP","SUM","VAR_SAMP","VAR_POP","array_concat","array_flatten","get_array_length","split_to_array","subarray","BIT_AND","BIT_OR","BOOL_AND","BOOL_OR","COALESCE","DECODE","GREATEST","LEAST","NVL","NVL2","NULLIF","ADD_MONTHS","AT TIME ZONE","CONVERT_TIMEZONE","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATE_CMP","DATE_CMP_TIMESTAMP","DATE_CMP_TIMESTAMPTZ","DATE_PART_YEAR","DATEADD","DATEDIFF","DATE_PART","DATE_TRUNC","EXTRACT","GETDATE","INTERVAL_CMP","LAST_DAY","MONTHS_BETWEEN","NEXT_DAY","SYSDATE","TIMEOFDAY","TIMESTAMP_CMP","TIMESTAMP_CMP_DATE","TIMESTAMP_CMP_TIMESTAMPTZ","TIMESTAMPTZ_CMP","TIMESTAMPTZ_CMP_DATE","TIMESTAMPTZ_CMP_TIMESTAMP","TIMEZONE","TO_TIMESTAMP","TRUNC","AddBBox","DropBBox","GeometryType","ST_AddPoint","ST_Angle","ST_Area","ST_AsBinary","ST_AsEWKB","ST_AsEWKT","ST_AsGeoJSON","ST_AsText","ST_Azimuth","ST_Boundary","ST_Collect","ST_Contains","ST_ContainsProperly","ST_ConvexHull","ST_CoveredBy","ST_Covers","ST_Crosses","ST_Dimension","ST_Disjoint","ST_Distance","ST_DistanceSphere","ST_DWithin","ST_EndPoint","ST_Envelope","ST_Equals","ST_ExteriorRing","ST_Force2D","ST_Force3D","ST_Force3DM","ST_Force3DZ","ST_Force4D","ST_GeometryN","ST_GeometryType","ST_GeomFromEWKB","ST_GeomFromEWKT","ST_GeomFromText","ST_GeomFromWKB","ST_InteriorRingN","ST_Intersects","ST_IsPolygonCCW","ST_IsPolygonCW","ST_IsClosed","ST_IsCollection","ST_IsEmpty","ST_IsSimple","ST_IsValid","ST_Length","ST_LengthSphere","ST_Length2D","ST_LineFromMultiPoint","ST_LineInterpolatePoint","ST_M","ST_MakeEnvelope","ST_MakeLine","ST_MakePoint","ST_MakePolygon","ST_MemSize","ST_MMax","ST_MMin","ST_Multi","ST_NDims","ST_NPoints","ST_NRings","ST_NumGeometries","ST_NumInteriorRings","ST_NumPoints","ST_Perimeter","ST_Perimeter2D","ST_Point","ST_PointN","ST_Points","ST_Polygon","ST_RemovePoint","ST_Reverse","ST_SetPoint","ST_SetSRID","ST_Simplify","ST_SRID","ST_StartPoint","ST_Touches","ST_Within","ST_X","ST_XMax","ST_XMin","ST_Y","ST_YMax","ST_YMin","ST_Z","ST_ZMax","ST_ZMin","SupportsBBox","CHECKSUM","FUNC_SHA1","FNV_HASH","MD5","SHA","SHA1","SHA2","HLL","HLL_CREATE_SKETCH","HLL_CARDINALITY","HLL_COMBINE","IS_VALID_JSON","IS_VALID_JSON_ARRAY","JSON_ARRAY_LENGTH","JSON_EXTRACT_ARRAY_ELEMENT_TEXT","JSON_EXTRACT_PATH_TEXT","JSON_PARSE","JSON_SERIALIZE","ABS","ACOS","ASIN","ATAN","ATAN2","CBRT","CEILING","CEIL","COS","COT","DEGREES","DEXP","DLOG1","DLOG10","EXP","FLOOR","LN","LOG","MOD","PI","POWER","RADIANS","RANDOM","ROUND","SIN","SIGN","SQRT","TAN","TO_HEX","TRUNC","EXPLAIN_MODEL","ASCII","BPCHARCMP","BTRIM","BTTEXT_PATTERN_CMP","CHAR_LENGTH","CHARACTER_LENGTH","CHARINDEX","CHR","COLLATE","CONCAT","CRC32","DIFFERENCE","INITCAP","LEFT","RIGHT","LEN","LENGTH","LOWER","LPAD","RPAD","LTRIM","OCTETINDEX","OCTET_LENGTH","POSITION","QUOTE_IDENT","QUOTE_LITERAL","REGEXP_COUNT","REGEXP_INSTR","REGEXP_REPLACE","REGEXP_SUBSTR","REPEAT","REPLACE","REPLICATE","REVERSE","RTRIM","SOUNDEX","SPLIT_PART","STRPOS","STRTOL","SUBSTRING","TEXTLEN","TRANSLATE","TRIM","UPPER","decimal_precision","decimal_scale","is_array","is_bigint","is_boolean","is_char","is_decimal","is_float","is_integer","is_object","is_scalar","is_smallint","is_varchar","json_typeof","AVG","COUNT","CUME_DIST","DENSE_RANK","FIRST_VALUE","LAST_VALUE","LAG","LEAD","LISTAGG","MAX","MEDIAN","MIN","NTH_VALUE","NTILE","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","RANK","RATIO_TO_REPORT","ROW_NUMBER","STDDEV_SAMP","STDDEV_POP","SUM","VAR_SAMP","VAR_POP","CAST","CONVERT","TO_CHAR","TO_DATE","TO_NUMBER","TEXT_TO_INT_ALT","TEXT_TO_NUMERIC_ALT","CHANGE_QUERY_PRIORITY","CHANGE_SESSION_PRIORITY","CHANGE_USER_PRIORITY","CURRENT_SETTING","PG_CANCEL_BACKEND","PG_TERMINATE_BACKEND","REBOOT_CLUSTER","SET_CONFIG","CURRENT_AWS_ACCOUNT","CURRENT_DATABASE","CURRENT_NAMESPACE","CURRENT_SCHEMA","CURRENT_SCHEMAS","CURRENT_USER","CURRENT_USER_ID","HAS_ASSUMEROLE_PRIVILEGE","HAS_DATABASE_PRIVILEGE","HAS_SCHEMA_PRIVILEGE","HAS_TABLE_PRIVILEGE","PG_BACKEND_PID","PG_GET_COLS","PG_GET_GRANTEE_BY_IAM_ROLE","PG_GET_IAM_ROLE_BY_USER","PG_GET_LATE_BINDING_VIEW_COLS","PG_LAST_COPY_COUNT","PG_LAST_COPY_ID","PG_LAST_UNLOAD_ID","PG_LAST_QUERY_ID","PG_LAST_UNLOAD_COUNT","SESSION_USER","SLICE_NUM","USER","VERSION"],Op=["AES128","AES256","ALL","ALLOWOVERWRITE","ANY","AS","ASC","AUTHORIZATION","BACKUP","BETWEEN","BINARY","BOTH","CHECK","COLUMN","CONSTRAINT","CREATE","CROSS","DEFAULT","DEFERRABLE","DEFLATE","DEFRAG","DESC","DISABLE","DISTINCT","DO","ENABLE","ENCODE","ENCRYPT","ENCRYPTION","EXPLICIT","FALSE","FOR","FOREIGN","FREEZE","FROM","FULL","GLOBALDICT256","GLOBALDICT64K","GROUP","IDENTITY","IGNORE","ILIKE","IN","INITIALLY","INNER","INTO","IS","ISNULL","LANGUAGE","LEADING","LIKE","LIMIT","LOCALTIME","LOCALTIMESTAMP","LUN","LUNS","MINUS","NATURAL","NEW","NOT","NOTNULL","NULL","NULLS","OFF","OFFLINE","OFFSET","OID","OLD","ON","ONLY","OPEN","ORDER","OUTER","OVERLAPS","PARALLEL","PARTITION","PERCENT","PERMISSIONS","PLACING","PRIMARY","RECOVER","REFERENCES","REJECTLOG","RESORT","RESPECT","RESTORE","SIMILAR","SNAPSHOT","SOME","SYSTEM","TABLE","TAG","TDES","THEN","TIMESTAMP","TO","TOP","TRAILING","TRUE","UNIQUE","USING","VERBOSE","WALLET","WITHOUT","ACCEPTANYDATE","ACCEPTINVCHARS","BLANKSASNULL","DATEFORMAT","EMPTYASNULL","ENCODING","ESCAPE","EXPLICIT_IDS","FILLRECORD","IGNOREBLANKLINES","IGNOREHEADER","REMOVEQUOTES","ROUNDEC","TIMEFORMAT","TRIMBLANKS","TRUNCATECOLUMNS","COMPROWS","COMPUPDATE","MAXERROR","NOLOAD","STATUPDATE","FORMAT","CSV","DELIMITER","FIXEDWIDTH","SHAPEFILE","AVRO","JSON","PARQUET","ORC","ACCESS_KEY_ID","CREDENTIALS","ENCRYPTED","IAM_ROLE","MASTER_SYMMETRIC_KEY","SECRET_ACCESS_KEY","SESSION_TOKEN","BZIP2","GZIP","LZOP","ZSTD","MANIFEST","READRATIO","REGION","SSH","RAW","AZ64","BYTEDICT","DELTA","DELTA32K","LZO","MOSTLY8","MOSTLY16","MOSTLY32","RUNLENGTH","TEXT255","TEXT32K","CATALOG_ROLE","SECRET_ARN","EXTERNAL","AUTO","EVEN","KEY","PREDICATE","COMPRESSION"],Np=["ARRAY","BIGINT","BPCHAR","CHAR","CHARACTER VARYING","CHARACTER","DECIMAL","INT","INT2","INT4","INT8","INTEGER","NCHAR","NUMERIC","NVARCHAR","SMALLINT","TEXT","VARBYTE","VARCHAR"],Ip=Q(["SELECT [ALL | DISTINCT]"]),hp=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","QUALIFY","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT INTO","VALUES","SET"]),ZA=Q(["CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"]),rc=Q(["CREATE [OR REPLACE | MATERIALIZED] VIEW","UPDATE","DELETE [FROM]","DROP TABLE [IF EXISTS]","ALTER TABLE","ALTER TABLE APPEND","ADD [COLUMN]","DROP [COLUMN]","RENAME TO","RENAME COLUMN","ALTER COLUMN","TYPE","ENCODE","TRUNCATE [TABLE]","ABORT","ALTER DATABASE","ALTER DATASHARE","ALTER DEFAULT PRIVILEGES","ALTER GROUP","ALTER MATERIALIZED VIEW","ALTER PROCEDURE","ALTER SCHEMA","ALTER USER","ANALYSE","ANALYZE","ANALYSE COMPRESSION","ANALYZE COMPRESSION","BEGIN","CALL","CANCEL","CLOSE","COMMIT","COPY","CREATE DATABASE","CREATE DATASHARE","CREATE EXTERNAL FUNCTION","CREATE EXTERNAL SCHEMA","CREATE EXTERNAL TABLE","CREATE FUNCTION","CREATE GROUP","CREATE LIBRARY","CREATE MODEL","CREATE PROCEDURE","CREATE SCHEMA","CREATE USER","DEALLOCATE","DECLARE","DESC DATASHARE","DROP DATABASE","DROP DATASHARE","DROP FUNCTION","DROP GROUP","DROP LIBRARY","DROP MODEL","DROP MATERIALIZED VIEW","DROP PROCEDURE","DROP SCHEMA","DROP USER","DROP VIEW","DROP","EXECUTE","EXPLAIN","FETCH","GRANT","LOCK","PREPARE","REFRESH MATERIALIZED VIEW","RESET","REVOKE","ROLLBACK","SELECT INTO","SET SESSION AUTHORIZATION","SET SESSION CHARACTERISTICS","SHOW","SHOW EXTERNAL TABLE","SHOW MODEL","SHOW DATASHARES","SHOW PROCEDURE","SHOW TABLE","SHOW VIEW","START TRANSACTION","UNLOAD","VACUUM"]),fp=Q(["UNION [ALL]","EXCEPT","INTERSECT","MINUS"]),Cp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"]),pp=Q(["NULL AS","DATA CATALOG","HIVE METASTORE","{ROWS | RANGE} BETWEEN"]),Lp=Q([]),_p={name:"redshift",tokenizerOptions:{reservedSelect:Ip,reservedClauses:[...hp,...ZA,...rc],reservedSetOperations:fp,reservedJoins:Cp,reservedKeywordPhrases:pp,reservedDataTypePhrases:Lp,reservedKeywords:Op,reservedDataTypes:Np,reservedFunctionNames:dp,extraParens:["[]"],stringTypes:["''-qq"],identTypes:['""-qq'],identChars:{first:"#"},paramTypes:{numbered:["$"]},operators:["^","%","@","|/","||/","&","|","~","<<",">>","||","::"]},formatOptions:{alwaysDenseOperators:["::"],onelineClauses:[...ZA,...rc],tabularOnelineClauses:rc}},mp=["ADD","AFTER","ALL","ALTER","ANALYZE","AND","ANTI","ANY","ARCHIVE","AS","ASC","AT","AUTHORIZATION","BETWEEN","BOTH","BUCKET","BUCKETS","BY","CACHE","CASCADE","CAST","CHANGE","CHECK","CLEAR","CLUSTER","CLUSTERED","CODEGEN","COLLATE","COLLECTION","COLUMN","COLUMNS","COMMENT","COMMIT","COMPACT","COMPACTIONS","COMPUTE","CONCATENATE","CONSTRAINT","COST","CREATE","CROSS","CUBE","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","DATA","DATABASE","DATABASES","DAY","DBPROPERTIES","DEFINED","DELETE","DELIMITED","DESC","DESCRIBE","DFS","DIRECTORIES","DIRECTORY","DISTINCT","DISTRIBUTE","DIV","DROP","ESCAPE","ESCAPED","EXCEPT","EXCHANGE","EXISTS","EXPORT","EXTENDED","EXTERNAL","EXTRACT","FALSE","FETCH","FIELDS","FILTER","FILEFORMAT","FIRST","FIRST_VALUE","FOLLOWING","FOR","FOREIGN","FORMAT","FORMATTED","FULL","FUNCTION","FUNCTIONS","GLOBAL","GRANT","GROUP","GROUPING","HOUR","IF","IGNORE","IMPORT","IN","INDEX","INDEXES","INNER","INPATH","INPUTFORMAT","INTERSECT","INTO","IS","ITEMS","KEYS","LAST","LAST_VALUE","LATERAL","LAZY","LEADING","LEFT","LIKE","LINES","LIST","LOCAL","LOCATION","LOCK","LOCKS","LOGICAL","MACRO","MATCHED","MERGE","MINUTE","MONTH","MSCK","NAMESPACE","NAMESPACES","NATURAL","NO","NOT","NULL","NULLS","OF","ONLY","OPTION","OPTIONS","OR","ORDER","OUT","OUTER","OUTPUTFORMAT","OVER","OVERLAPS","OVERLAY","OVERWRITE","OWNER","PARTITION","PARTITIONED","PARTITIONS","PERCENT","PLACING","POSITION","PRECEDING","PRIMARY","PRINCIPALS","PROPERTIES","PURGE","QUERY","RANGE","RECORDREADER","RECORDWRITER","RECOVER","REDUCE","REFERENCES","RENAME","REPAIR","REPLACE","RESPECT","RESTRICT","REVOKE","RIGHT","RLIKE","ROLE","ROLES","ROLLBACK","ROLLUP","ROW","ROWS","SCHEMA","SECOND","SELECT","SEMI","SEPARATED","SERDE","SERDEPROPERTIES","SESSION_USER","SETS","SHOW","SKEWED","SOME","SORT","SORTED","START","STATISTICS","STORED","STRATIFY","SUBSTR","SUBSTRING","TABLE","TABLES","TBLPROPERTIES","TEMPORARY","TERMINATED","THEN","TO","TOUCH","TRAILING","TRANSACTION","TRANSACTIONS","TRIM","TRUE","TRUNCATE","UNARCHIVE","UNBOUNDED","UNCACHE","UNIQUE","UNKNOWN","UNLOCK","UNSET","USE","USER","USING","VIEW","WINDOW","YEAR","ANALYSE","ARRAY_ZIP","COALESCE","CONTAINS","CONVERT","DAYS","DAY_HOUR","DAY_MINUTE","DAY_SECOND","DECODE","DEFAULT","DISTINCTROW","ENCODE","EXPLODE","EXPLODE_OUTER","FIXED","GREATEST","GROUP_CONCAT","HOURS","HOUR_MINUTE","HOUR_SECOND","IFNULL","LEAST","LEVEL","MINUTE_SECOND","NULLIF","OFFSET","ON","OPTIMIZE","REGEXP","SEPARATOR","SIZE","TYPE","TYPES","UNSIGNED","VARIABLES","YEAR_MONTH"],vp=["ARRAY","BIGINT","BINARY","BOOLEAN","BYTE","CHAR","DATE","DEC","DECIMAL","DOUBLE","FLOAT","INT","INTEGER","INTERVAL","LONG","MAP","NUMERIC","REAL","SHORT","SMALLINT","STRING","STRUCT","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP","TINYINT","VARCHAR"],xp=["APPROX_COUNT_DISTINCT","APPROX_PERCENTILE","AVG","BIT_AND","BIT_OR","BIT_XOR","BOOL_AND","BOOL_OR","COLLECT_LIST","COLLECT_SET","CORR","COUNT","COUNT","COUNT","COUNT_IF","COUNT_MIN_SKETCH","COVAR_POP","COVAR_SAMP","EVERY","FIRST","FIRST_VALUE","GROUPING","GROUPING_ID","KURTOSIS","LAST","LAST_VALUE","MAX","MAX_BY","MEAN","MIN","MIN_BY","PERCENTILE","PERCENTILE","PERCENTILE_APPROX","SKEWNESS","STD","STDDEV","STDDEV_POP","STDDEV_SAMP","SUM","VAR_POP","VAR_SAMP","VARIANCE","CUME_DIST","DENSE_RANK","LAG","LEAD","NTH_VALUE","NTILE","PERCENT_RANK","RANK","ROW_NUMBER","ARRAY","ARRAY_CONTAINS","ARRAY_DISTINCT","ARRAY_EXCEPT","ARRAY_INTERSECT","ARRAY_JOIN","ARRAY_MAX","ARRAY_MIN","ARRAY_POSITION","ARRAY_REMOVE","ARRAY_REPEAT","ARRAY_UNION","ARRAYS_OVERLAP","ARRAYS_ZIP","FLATTEN","SEQUENCE","SHUFFLE","SLICE","SORT_ARRAY","ELEMENT_AT","ELEMENT_AT","MAP_CONCAT","MAP_ENTRIES","MAP_FROM_ARRAYS","MAP_FROM_ENTRIES","MAP_KEYS","MAP_VALUES","STR_TO_MAP","ADD_MONTHS","CURRENT_DATE","CURRENT_DATE","CURRENT_TIMESTAMP","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","DATE_ADD","DATE_FORMAT","DATE_FROM_UNIX_DATE","DATE_PART","DATE_SUB","DATE_TRUNC","DATEDIFF","DAY","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","EXTRACT","FROM_UNIXTIME","FROM_UTC_TIMESTAMP","HOUR","LAST_DAY","MAKE_DATE","MAKE_DT_INTERVAL","MAKE_INTERVAL","MAKE_TIMESTAMP","MAKE_YM_INTERVAL","MINUTE","MONTH","MONTHS_BETWEEN","NEXT_DAY","NOW","QUARTER","SECOND","SESSION_WINDOW","TIMESTAMP_MICROS","TIMESTAMP_MILLIS","TIMESTAMP_SECONDS","TO_DATE","TO_TIMESTAMP","TO_UNIX_TIMESTAMP","TO_UTC_TIMESTAMP","TRUNC","UNIX_DATE","UNIX_MICROS","UNIX_MILLIS","UNIX_SECONDS","UNIX_TIMESTAMP","WEEKDAY","WEEKOFYEAR","WINDOW","YEAR","FROM_JSON","GET_JSON_OBJECT","JSON_ARRAY_LENGTH","JSON_OBJECT_KEYS","JSON_TUPLE","SCHEMA_OF_JSON","TO_JSON","ABS","ACOS","ACOSH","AGGREGATE","ARRAY_SORT","ASCII","ASIN","ASINH","ASSERT_TRUE","ATAN","ATAN2","ATANH","BASE64","BIN","BIT_COUNT","BIT_GET","BIT_LENGTH","BROUND","BTRIM","CARDINALITY","CBRT","CEIL","CEILING","CHAR_LENGTH","CHARACTER_LENGTH","CHR","CONCAT","CONCAT_WS","CONV","COS","COSH","COT","CRC32","CURRENT_CATALOG","CURRENT_DATABASE","CURRENT_USER","DEGREES","ELT","EXP","EXPM1","FACTORIAL","FIND_IN_SET","FLOOR","FORALL","FORMAT_NUMBER","FORMAT_STRING","FROM_CSV","GETBIT","HASH","HEX","HYPOT","INITCAP","INLINE","INLINE_OUTER","INPUT_FILE_BLOCK_LENGTH","INPUT_FILE_BLOCK_START","INPUT_FILE_NAME","INSTR","ISNAN","ISNOTNULL","ISNULL","JAVA_METHOD","LCASE","LEFT","LENGTH","LEVENSHTEIN","LN","LOCATE","LOG","LOG10","LOG1P","LOG2","LOWER","LPAD","LTRIM","MAP_FILTER","MAP_ZIP_WITH","MD5","MOD","MONOTONICALLY_INCREASING_ID","NAMED_STRUCT","NANVL","NEGATIVE","NVL","NVL2","OCTET_LENGTH","OVERLAY","PARSE_URL","PI","PMOD","POSEXPLODE","POSEXPLODE_OUTER","POSITION","POSITIVE","POW","POWER","PRINTF","RADIANS","RAISE_ERROR","RAND","RANDN","RANDOM","REFLECT","REGEXP_EXTRACT","REGEXP_EXTRACT_ALL","REGEXP_LIKE","REGEXP_REPLACE","REPEAT","REPLACE","REVERSE","RIGHT","RINT","ROUND","RPAD","RTRIM","SCHEMA_OF_CSV","SENTENCES","SHA","SHA1","SHA2","SHIFTLEFT","SHIFTRIGHT","SHIFTRIGHTUNSIGNED","SIGN","SIGNUM","SIN","SINH","SOUNDEX","SPACE","SPARK_PARTITION_ID","SPLIT","SQRT","STACK","SUBSTR","SUBSTRING","SUBSTRING_INDEX","TAN","TANH","TO_CSV","TRANSFORM_KEYS","TRANSFORM_VALUES","TRANSLATE","TRIM","TRY_ADD","TRY_DIVIDE","TYPEOF","UCASE","UNBASE64","UNHEX","UPPER","UUID","VERSION","WIDTH_BUCKET","XPATH","XPATH_BOOLEAN","XPATH_DOUBLE","XPATH_FLOAT","XPATH_INT","XPATH_LONG","XPATH_NUMBER","XPATH_SHORT","XPATH_STRING","XXHASH64","ZIP_WITH","CAST","COALESCE","NULLIF"],Dp=Q(["SELECT [ALL | DISTINCT]"]),yp=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","SORT BY","CLUSTER BY","DISTRIBUTE BY","LIMIT","INSERT [INTO | OVERWRITE] [TABLE]","VALUES","INSERT OVERWRITE [LOCAL] DIRECTORY","LOAD DATA [LOCAL] INPATH","[OVERWRITE] INTO TABLE"]),ed=Q(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]),sc=Q(["CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]","DROP TABLE [IF EXISTS]","ALTER TABLE","ADD COLUMNS","DROP {COLUMN | COLUMNS}","RENAME TO","RENAME COLUMN","ALTER COLUMN","TRUNCATE TABLE","LATERAL VIEW","ALTER DATABASE","ALTER VIEW","CREATE DATABASE","CREATE FUNCTION","DROP DATABASE","DROP FUNCTION","DROP VIEW","REPAIR TABLE","USE DATABASE","TABLESAMPLE","PIVOT","TRANSFORM","EXPLAIN","ADD FILE","ADD JAR","ANALYZE TABLE","CACHE TABLE","CLEAR CACHE","DESCRIBE DATABASE","DESCRIBE FUNCTION","DESCRIBE QUERY","DESCRIBE TABLE","LIST FILE","LIST JAR","REFRESH","REFRESH TABLE","REFRESH FUNCTION","RESET","SHOW COLUMNS","SHOW CREATE TABLE","SHOW DATABASES","SHOW FUNCTIONS","SHOW PARTITIONS","SHOW TABLE EXTENDED","SHOW TABLES","SHOW TBLPROPERTIES","SHOW VIEWS","UNCACHE TABLE"]),gp=Q(["UNION [ALL | DISTINCT]","EXCEPT [ALL | DISTINCT]","INTERSECT [ALL | DISTINCT]"]),Mp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN","[LEFT] {ANTI | SEMI} JOIN","NATURAL [LEFT] {ANTI | SEMI} JOIN"]),Pp=Q(["ON DELETE","ON UPDATE","CURRENT ROW","{ROWS | RANGE} BETWEEN"]),Up=Q([]),bp={name:"spark",tokenizerOptions:{reservedSelect:Dp,reservedClauses:[...yp,...ed,...sc],reservedSetOperations:gp,reservedJoins:Mp,reservedKeywordPhrases:Pp,reservedDataTypePhrases:Up,supportsXor:!0,reservedKeywords:mp,reservedDataTypes:vp,reservedFunctionNames:xp,extraParens:["[]"],stringTypes:["''-bs",'""-bs',{quote:"''-raw",prefixes:["R","X"],requirePrefix:!0},{quote:'""-raw',prefixes:["R","X"],requirePrefix:!0}],identTypes:["``"],identChars:{allowFirstCharNumber:!0},variableTypes:[{quote:"{}",prefixes:["$"],requirePrefix:!0}],operators:["%","~","^","|","&","<=>","==","!","||","->"],postProcess:Gp},formatOptions:{onelineClauses:[...ed,...sc],tabularOnelineClauses:sc}};function Gp(r){return r.map((l,E)=>{const T=r[E-1]||Rr,c=r[E+1]||Rr;return ur.WINDOW(l)&&c.type===Ae.OPEN_PAREN?Object.assign(Object.assign({},l),{type:Ae.RESERVED_FUNCTION_NAME}):l.text==="ITEMS"&&l.type===Ae.RESERVED_KEYWORD&&!(T.text==="COLLECTION"&&c.text==="TERMINATED")?Object.assign(Object.assign({},l),{type:Ae.IDENTIFIER,text:l.raw}):l})}const Bp=["ABS","CHANGES","CHAR","COALESCE","FORMAT","GLOB","HEX","IFNULL","IIF","INSTR","LAST_INSERT_ROWID","LENGTH","LIKE","LIKELIHOOD","LIKELY","LOAD_EXTENSION","LOWER","LTRIM","NULLIF","PRINTF","QUOTE","RANDOM","RANDOMBLOB","REPLACE","ROUND","RTRIM","SIGN","SOUNDEX","SQLITE_COMPILEOPTION_GET","SQLITE_COMPILEOPTION_USED","SQLITE_OFFSET","SQLITE_SOURCE_ID","SQLITE_VERSION","SUBSTR","SUBSTRING","TOTAL_CHANGES","TRIM","TYPEOF","UNICODE","UNLIKELY","UPPER","ZEROBLOB","AVG","COUNT","GROUP_CONCAT","MAX","MIN","SUM","TOTAL","DATE","TIME","DATETIME","JULIANDAY","UNIXEPOCH","STRFTIME","row_number","rank","dense_rank","percent_rank","cume_dist","ntile","lag","lead","first_value","last_value","nth_value","ACOS","ACOSH","ASIN","ASINH","ATAN","ATAN2","ATANH","CEIL","CEILING","COS","COSH","DEGREES","EXP","FLOOR","LN","LOG","LOG","LOG10","LOG2","MOD","PI","POW","POWER","RADIANS","SIN","SINH","SQRT","TAN","TANH","TRUNC","JSON","JSON_ARRAY","JSON_ARRAY_LENGTH","JSON_ARRAY_LENGTH","JSON_EXTRACT","JSON_INSERT","JSON_OBJECT","JSON_PATCH","JSON_REMOVE","JSON_REPLACE","JSON_SET","JSON_TYPE","JSON_TYPE","JSON_VALID","JSON_QUOTE","JSON_GROUP_ARRAY","JSON_GROUP_OBJECT","JSON_EACH","JSON_TREE","CAST"],Hp=["ABORT","ACTION","ADD","AFTER","ALL","ALTER","AND","ARE","ALWAYS","ANALYZE","AS","ASC","ATTACH","AUTOINCREMENT","BEFORE","BEGIN","BETWEEN","BY","CASCADE","CASE","CAST","CHECK","COLLATE","COLUMN","COMMIT","CONFLICT","CONSTRAINT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATABASE","DEFAULT","DEFERRABLE","DEFERRED","DELETE","DESC","DETACH","DISTINCT","DO","DROP","EACH","ELSE","END","ESCAPE","EXCEPT","EXCLUDE","EXCLUSIVE","EXISTS","EXPLAIN","FAIL","FILTER","FIRST","FOLLOWING","FOR","FOREIGN","FROM","FULL","GENERATED","GLOB","GROUP","HAVING","IF","IGNORE","IMMEDIATE","IN","INDEX","INDEXED","INITIALLY","INNER","INSERT","INSTEAD","INTERSECT","INTO","IS","ISNULL","JOIN","KEY","LAST","LEFT","LIKE","LIMIT","MATCH","MATERIALIZED","NATURAL","NO","NOT","NOTHING","NOTNULL","NULL","NULLS","OF","OFFSET","ON","ONLY","OPEN","OR","ORDER","OTHERS","OUTER","OVER","PARTITION","PLAN","PRAGMA","PRECEDING","PRIMARY","QUERY","RAISE","RANGE","RECURSIVE","REFERENCES","REGEXP","REINDEX","RELEASE","RENAME","REPLACE","RESTRICT","RETURNING","RIGHT","ROLLBACK","ROW","ROWS","SAVEPOINT","SELECT","SET","TABLE","TEMP","TEMPORARY","THEN","TIES","TO","TRANSACTION","TRIGGER","UNBOUNDED","UNION","UNIQUE","UPDATE","USING","VACUUM","VALUES","VIEW","VIRTUAL","WHEN","WHERE","WINDOW","WITH","WITHOUT"],Fp=["ANY","ARRAY","BLOB","CHARACTER","DECIMAL","INT","INTEGER","NATIVE CHARACTER","NCHAR","NUMERIC","NVARCHAR","REAL","TEXT","VARCHAR","VARYING CHARACTER"],Yp=Q(["SELECT [ALL | DISTINCT]"]),jp=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT [OR ABORT | OR FAIL | OR IGNORE | OR REPLACE | OR ROLLBACK] INTO","REPLACE INTO","VALUES","SET","RETURNING"]),td=Q(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]),lc=Q(["CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]","UPDATE [OR ABORT | OR FAIL | OR IGNORE | OR REPLACE | OR ROLLBACK]","ON CONFLICT","DELETE FROM","DROP TABLE [IF EXISTS]","ALTER TABLE","ADD [COLUMN]","DROP [COLUMN]","RENAME [COLUMN]","RENAME TO","SET SCHEMA"]),Vp=Q(["UNION [ALL]","EXCEPT","INTERSECT"]),wp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"]),Wp=Q(["ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]","{ROWS | RANGE | GROUPS} BETWEEN","DO UPDATE"]),Xp=Q([]),Kp={name:"sqlite",tokenizerOptions:{reservedSelect:Yp,reservedClauses:[...jp,...td,...lc],reservedSetOperations:Vp,reservedJoins:wp,reservedKeywordPhrases:Wp,reservedDataTypePhrases:Xp,reservedKeywords:Hp,reservedDataTypes:Fp,reservedFunctionNames:Bp,stringTypes:["''-qq",{quote:"''-raw",prefixes:["X"],requirePrefix:!0}],identTypes:['""-qq',"``","[]"],paramTypes:{positional:!0,numbered:["?"],named:[":","@","$"]},operators:["%","~","&","|","<<",">>","==","->","->>","||"]},formatOptions:{onelineClauses:[...td,...lc],tabularOnelineClauses:lc}},zp=["GROUPING","RANK","DENSE_RANK","PERCENT_RANK","CUME_DIST","ROW_NUMBER","POSITION","OCCURRENCES_REGEX","POSITION_REGEX","EXTRACT","CHAR_LENGTH","CHARACTER_LENGTH","OCTET_LENGTH","CARDINALITY","ABS","MOD","LN","EXP","POWER","SQRT","FLOOR","CEIL","CEILING","WIDTH_BUCKET","SUBSTRING","SUBSTRING_REGEX","UPPER","LOWER","CONVERT","TRANSLATE","TRANSLATE_REGEX","TRIM","OVERLAY","NORMALIZE","SPECIFICTYPE","CURRENT_DATE","CURRENT_TIME","LOCALTIME","CURRENT_TIMESTAMP","LOCALTIMESTAMP","COUNT","AVG","MAX","MIN","SUM","STDDEV_POP","STDDEV_SAMP","VAR_SAMP","VAR_POP","COLLECT","FUSION","INTERSECTION","COVAR_POP","COVAR_SAMP","CORR","REGR_SLOPE","REGR_INTERCEPT","REGR_COUNT","REGR_R2","REGR_AVGX","REGR_AVGY","REGR_SXX","REGR_SYY","REGR_SXY","PERCENTILE_CONT","PERCENTILE_DISC","CAST","COALESCE","NULLIF","ROUND","SIN","COS","TAN","ASIN","ACOS","ATAN"],kp=["ALL","ALLOCATE","ALTER","ANY","ARE","AS","ASC","ASENSITIVE","ASYMMETRIC","AT","ATOMIC","AUTHORIZATION","BEGIN","BETWEEN","BOTH","BY","CALL","CALLED","CASCADED","CAST","CHECK","CLOSE","COALESCE","COLLATE","COLUMN","COMMIT","CONDITION","CONNECT","CONSTRAINT","CORRESPONDING","CREATE","CROSS","CUBE","CURRENT","CURRENT_CATALOG","CURRENT_DEFAULT_TRANSFORM_GROUP","CURRENT_PATH","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_TRANSFORM_GROUP_FOR_TYPE","CURRENT_USER","CURSOR","CYCLE","DEALLOCATE","DAY","DECLARE","DEFAULT","DELETE","DEREF","DESC","DESCRIBE","DETERMINISTIC","DISCONNECT","DISTINCT","DROP","DYNAMIC","EACH","ELEMENT","END-EXEC","ESCAPE","EVERY","EXCEPT","EXEC","EXECUTE","EXISTS","EXTERNAL","FALSE","FETCH","FILTER","FOR","FOREIGN","FREE","FROM","FULL","FUNCTION","GET","GLOBAL","GRANT","GROUP","HAVING","HOLD","HOUR","IDENTITY","IN","INDICATOR","INNER","INOUT","INSENSITIVE","INSERT","INTERSECT","INTO","IS","LANGUAGE","LARGE","LATERAL","LEADING","LEFT","LIKE","LIKE_REGEX","LOCAL","MATCH","MEMBER","MERGE","METHOD","MINUTE","MODIFIES","MODULE","MONTH","NATURAL","NEW","NO","NONE","NOT","NULL","NULLIF","OF","OLD","ON","ONLY","OPEN","ORDER","OUT","OUTER","OVER","OVERLAPS","PARAMETER","PARTITION","PRECISION","PREPARE","PRIMARY","PROCEDURE","RANGE","READS","REAL","RECURSIVE","REF","REFERENCES","REFERENCING","RELEASE","RESULT","RETURN","RETURNS","REVOKE","RIGHT","ROLLBACK","ROLLUP","ROW","ROWS","SAVEPOINT","SCOPE","SCROLL","SEARCH","SECOND","SELECT","SENSITIVE","SESSION_USER","SET","SIMILAR","SOME","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","START","STATIC","SUBMULTISET","SYMMETRIC","SYSTEM","SYSTEM_USER","TABLE","TABLESAMPLE","THEN","TIMEZONE_HOUR","TIMEZONE_MINUTE","TO","TRAILING","TRANSLATION","TREAT","TRIGGER","TRUE","UESCAPE","UNION","UNIQUE","UNKNOWN","UNNEST","UPDATE","USER","USING","VALUE","VALUES","WHENEVER","WINDOW","WITHIN","WITHOUT","YEAR"],$p=["ARRAY","BIGINT","BINARY LARGE OBJECT","BINARY VARYING","BINARY","BLOB","BOOLEAN","CHAR LARGE OBJECT","CHAR VARYING","CHAR","CHARACTER LARGE OBJECT","CHARACTER VARYING","CHARACTER","CLOB","DATE","DEC","DECIMAL","DOUBLE","FLOAT","INT","INTEGER","INTERVAL","MULTISET","NATIONAL CHAR VARYING","NATIONAL CHAR","NATIONAL CHARACTER LARGE OBJECT","NATIONAL CHARACTER VARYING","NATIONAL CHARACTER","NCHAR LARGE OBJECT","NCHAR VARYING","NCHAR","NCLOB","NUMERIC","SMALLINT","TIME","TIMESTAMP","VARBINARY","VARCHAR"],Jp=Q(["SELECT [ALL | DISTINCT]"]),qp=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY [ALL | DISTINCT]","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","FETCH {FIRST | NEXT}","INSERT INTO","VALUES","SET"]),nd=Q(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]),ic=Q(["CREATE [RECURSIVE] VIEW","UPDATE","WHERE CURRENT OF","DELETE FROM","DROP TABLE","ALTER TABLE","ADD COLUMN","DROP [COLUMN]","RENAME COLUMN","RENAME TO","ALTER [COLUMN]","{SET | DROP} DEFAULT","ADD SCOPE","DROP SCOPE {CASCADE | RESTRICT}","RESTART WITH","TRUNCATE TABLE","SET SCHEMA"]),Qp=Q(["UNION [ALL | DISTINCT]","EXCEPT [ALL | DISTINCT]","INTERSECT [ALL | DISTINCT]"]),Zp=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"]),eL=Q(["ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]","{ROWS | RANGE} BETWEEN"]),tL=Q([]),nL={name:"sql",tokenizerOptions:{reservedSelect:Jp,reservedClauses:[...qp,...nd,...ic],reservedSetOperations:Qp,reservedJoins:Zp,reservedKeywordPhrases:eL,reservedDataTypePhrases:tL,reservedKeywords:kp,reservedDataTypes:$p,reservedFunctionNames:zp,stringTypes:[{quote:"''-qq-bs",prefixes:["N","U&"]},{quote:"''-raw",prefixes:["X"],requirePrefix:!0}],identTypes:['""-qq',"``"],paramTypes:{positional:!0},operators:["||"]},formatOptions:{onelineClauses:[...nd,...ic],tabularOnelineClauses:ic}},aL=["ABS","ACOS","ALL_MATCH","ANY_MATCH","APPROX_DISTINCT","APPROX_MOST_FREQUENT","APPROX_PERCENTILE","APPROX_SET","ARBITRARY","ARRAYS_OVERLAP","ARRAY_AGG","ARRAY_DISTINCT","ARRAY_EXCEPT","ARRAY_INTERSECT","ARRAY_JOIN","ARRAY_MAX","ARRAY_MIN","ARRAY_POSITION","ARRAY_REMOVE","ARRAY_SORT","ARRAY_UNION","ASIN","ATAN","ATAN2","AT_TIMEZONE","AVG","BAR","BETA_CDF","BING_TILE","BING_TILES_AROUND","BING_TILE_AT","BING_TILE_COORDINATES","BING_TILE_POLYGON","BING_TILE_QUADKEY","BING_TILE_ZOOM_LEVEL","BITWISE_AND","BITWISE_AND_AGG","BITWISE_LEFT_SHIFT","BITWISE_NOT","BITWISE_OR","BITWISE_OR_AGG","BITWISE_RIGHT_SHIFT","BITWISE_RIGHT_SHIFT_ARITHMETIC","BITWISE_XOR","BIT_COUNT","BOOL_AND","BOOL_OR","CARDINALITY","CAST","CBRT","CEIL","CEILING","CHAR2HEXINT","CHECKSUM","CHR","CLASSIFY","COALESCE","CODEPOINT","COLOR","COMBINATIONS","CONCAT","CONCAT_WS","CONTAINS","CONTAINS_SEQUENCE","CONVEX_HULL_AGG","CORR","COS","COSH","COSINE_SIMILARITY","COUNT","COUNT_IF","COVAR_POP","COVAR_SAMP","CRC32","CUME_DIST","CURRENT_CATALOG","CURRENT_DATE","CURRENT_GROUPS","CURRENT_SCHEMA","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TIMEZONE","CURRENT_USER","DATE","DATE_ADD","DATE_DIFF","DATE_FORMAT","DATE_PARSE","DATE_TRUNC","DAY","DAY_OF_MONTH","DAY_OF_WEEK","DAY_OF_YEAR","DEGREES","DENSE_RANK","DOW","DOY","E","ELEMENT_AT","EMPTY_APPROX_SET","EVALUATE_CLASSIFIER_PREDICTIONS","EVERY","EXP","EXTRACT","FEATURES","FILTER","FIRST_VALUE","FLATTEN","FLOOR","FORMAT","FORMAT_DATETIME","FORMAT_NUMBER","FROM_BASE","FROM_BASE32","FROM_BASE64","FROM_BASE64URL","FROM_BIG_ENDIAN_32","FROM_BIG_ENDIAN_64","FROM_ENCODED_POLYLINE","FROM_GEOJSON_GEOMETRY","FROM_HEX","FROM_IEEE754_32","FROM_IEEE754_64","FROM_ISO8601_DATE","FROM_ISO8601_TIMESTAMP","FROM_ISO8601_TIMESTAMP_NANOS","FROM_UNIXTIME","FROM_UNIXTIME_NANOS","FROM_UTF8","GEOMETRIC_MEAN","GEOMETRY_FROM_HADOOP_SHAPE","GEOMETRY_INVALID_REASON","GEOMETRY_NEAREST_POINTS","GEOMETRY_TO_BING_TILES","GEOMETRY_UNION","GEOMETRY_UNION_AGG","GREATEST","GREAT_CIRCLE_DISTANCE","HAMMING_DISTANCE","HASH_COUNTS","HISTOGRAM","HMAC_MD5","HMAC_SHA1","HMAC_SHA256","HMAC_SHA512","HOUR","HUMAN_READABLE_SECONDS","IF","INDEX","INFINITY","INTERSECTION_CARDINALITY","INVERSE_BETA_CDF","INVERSE_NORMAL_CDF","IS_FINITE","IS_INFINITE","IS_JSON_SCALAR","IS_NAN","JACCARD_INDEX","JSON_ARRAY_CONTAINS","JSON_ARRAY_GET","JSON_ARRAY_LENGTH","JSON_EXISTS","JSON_EXTRACT","JSON_EXTRACT_SCALAR","JSON_FORMAT","JSON_PARSE","JSON_QUERY","JSON_SIZE","JSON_VALUE","KURTOSIS","LAG","LAST_DAY_OF_MONTH","LAST_VALUE","LEAD","LEARN_CLASSIFIER","LEARN_LIBSVM_CLASSIFIER","LEARN_LIBSVM_REGRESSOR","LEARN_REGRESSOR","LEAST","LENGTH","LEVENSHTEIN_DISTANCE","LINE_INTERPOLATE_POINT","LINE_INTERPOLATE_POINTS","LINE_LOCATE_POINT","LISTAGG","LN","LOCALTIME","LOCALTIMESTAMP","LOG","LOG10","LOG2","LOWER","LPAD","LTRIM","LUHN_CHECK","MAKE_SET_DIGEST","MAP","MAP_AGG","MAP_CONCAT","MAP_ENTRIES","MAP_FILTER","MAP_FROM_ENTRIES","MAP_KEYS","MAP_UNION","MAP_VALUES","MAP_ZIP_WITH","MAX","MAX_BY","MD5","MERGE","MERGE_SET_DIGEST","MILLISECOND","MIN","MINUTE","MIN_BY","MOD","MONTH","MULTIMAP_AGG","MULTIMAP_FROM_ENTRIES","MURMUR3","NAN","NGRAMS","NONE_MATCH","NORMALIZE","NORMAL_CDF","NOW","NTH_VALUE","NTILE","NULLIF","NUMERIC_HISTOGRAM","OBJECTID","OBJECTID_TIMESTAMP","PARSE_DATA_SIZE","PARSE_DATETIME","PARSE_DURATION","PERCENT_RANK","PI","POSITION","POW","POWER","QDIGEST_AGG","QUARTER","RADIANS","RAND","RANDOM","RANK","REDUCE","REDUCE_AGG","REGEXP_COUNT","REGEXP_EXTRACT","REGEXP_EXTRACT_ALL","REGEXP_LIKE","REGEXP_POSITION","REGEXP_REPLACE","REGEXP_SPLIT","REGRESS","REGR_INTERCEPT","REGR_SLOPE","RENDER","REPEAT","REPLACE","REVERSE","RGB","ROUND","ROW_NUMBER","RPAD","RTRIM","SECOND","SEQUENCE","SHA1","SHA256","SHA512","SHUFFLE","SIGN","SIMPLIFY_GEOMETRY","SIN","SKEWNESS","SLICE","SOUNDEX","SPATIAL_PARTITIONING","SPATIAL_PARTITIONS","SPLIT","SPLIT_PART","SPLIT_TO_MAP","SPLIT_TO_MULTIMAP","SPOOKY_HASH_V2_32","SPOOKY_HASH_V2_64","SQRT","STARTS_WITH","STDDEV","STDDEV_POP","STDDEV_SAMP","STRPOS","ST_AREA","ST_ASBINARY","ST_ASTEXT","ST_BOUNDARY","ST_BUFFER","ST_CENTROID","ST_CONTAINS","ST_CONVEXHULL","ST_COORDDIM","ST_CROSSES","ST_DIFFERENCE","ST_DIMENSION","ST_DISJOINT","ST_DISTANCE","ST_ENDPOINT","ST_ENVELOPE","ST_ENVELOPEASPTS","ST_EQUALS","ST_EXTERIORRING","ST_GEOMETRIES","ST_GEOMETRYFROMTEXT","ST_GEOMETRYN","ST_GEOMETRYTYPE","ST_GEOMFROMBINARY","ST_INTERIORRINGN","ST_INTERIORRINGS","ST_INTERSECTION","ST_INTERSECTS","ST_ISCLOSED","ST_ISEMPTY","ST_ISRING","ST_ISSIMPLE","ST_ISVALID","ST_LENGTH","ST_LINEFROMTEXT","ST_LINESTRING","ST_MULTIPOINT","ST_NUMGEOMETRIES","ST_NUMINTERIORRING","ST_NUMPOINTS","ST_OVERLAPS","ST_POINT","ST_POINTN","ST_POINTS","ST_POLYGON","ST_RELATE","ST_STARTPOINT","ST_SYMDIFFERENCE","ST_TOUCHES","ST_UNION","ST_WITHIN","ST_X","ST_XMAX","ST_XMIN","ST_Y","ST_YMAX","ST_YMIN","SUBSTR","SUBSTRING","SUM","TAN","TANH","TDIGEST_AGG","TIMESTAMP_OBJECTID","TIMEZONE_HOUR","TIMEZONE_MINUTE","TO_BASE","TO_BASE32","TO_BASE64","TO_BASE64URL","TO_BIG_ENDIAN_32","TO_BIG_ENDIAN_64","TO_CHAR","TO_DATE","TO_ENCODED_POLYLINE","TO_GEOJSON_GEOMETRY","TO_GEOMETRY","TO_HEX","TO_IEEE754_32","TO_IEEE754_64","TO_ISO8601","TO_MILLISECONDS","TO_SPHERICAL_GEOGRAPHY","TO_TIMESTAMP","TO_UNIXTIME","TO_UTF8","TRANSFORM","TRANSFORM_KEYS","TRANSFORM_VALUES","TRANSLATE","TRIM","TRIM_ARRAY","TRUNCATE","TRY","TRY_CAST","TYPEOF","UPPER","URL_DECODE","URL_ENCODE","URL_EXTRACT_FRAGMENT","URL_EXTRACT_HOST","URL_EXTRACT_PARAMETER","URL_EXTRACT_PATH","URL_EXTRACT_PORT","URL_EXTRACT_PROTOCOL","URL_EXTRACT_QUERY","UUID","VALUES_AT_QUANTILES","VALUE_AT_QUANTILE","VARIANCE","VAR_POP","VAR_SAMP","VERSION","WEEK","WEEK_OF_YEAR","WIDTH_BUCKET","WILSON_INTERVAL_LOWER","WILSON_INTERVAL_UPPER","WITH_TIMEZONE","WORD_STEM","XXHASH64","YEAR","YEAR_OF_WEEK","YOW","ZIP","ZIP_WITH","CLASSIFIER","FIRST","LAST","MATCH_NUMBER","NEXT","PERMUTE","PREV"],rL=["ABSENT","ADD","ADMIN","AFTER","ALL","ALTER","ANALYZE","AND","ANY","AS","ASC","AT","AUTHORIZATION","BERNOULLI","BETWEEN","BOTH","BY","CALL","CASCADE","CASE","CATALOGS","COLUMN","COLUMNS","COMMENT","COMMIT","COMMITTED","CONDITIONAL","CONSTRAINT","COPARTITION","CREATE","CROSS","CUBE","CURRENT","CURRENT_PATH","CURRENT_ROLE","DATA","DEALLOCATE","DEFAULT","DEFINE","DEFINER","DELETE","DENY","DESC","DESCRIBE","DESCRIPTOR","DISTINCT","DISTRIBUTED","DOUBLE","DROP","ELSE","EMPTY","ENCODING","END","ERROR","ESCAPE","EXCEPT","EXCLUDING","EXECUTE","EXISTS","EXPLAIN","FALSE","FETCH","FINAL","FIRST","FOLLOWING","FOR","FROM","FULL","FUNCTIONS","GRANT","GRANTED","GRANTS","GRAPHVIZ","GROUP","GROUPING","GROUPS","HAVING","IGNORE","IN","INCLUDING","INITIAL","INNER","INPUT","INSERT","INTERSECT","INTERVAL","INTO","INVOKER","IO","IS","ISOLATION","JOIN","JSON","JSON_ARRAY","JSON_OBJECT","KEEP","KEY","KEYS","LAST","LATERAL","LEADING","LEFT","LEVEL","LIKE","LIMIT","LOCAL","LOGICAL","MATCH","MATCHED","MATCHES","MATCH_RECOGNIZE","MATERIALIZED","MEASURES","NATURAL","NEXT","NFC","NFD","NFKC","NFKD","NO","NONE","NOT","NULL","NULLS","OBJECT","OF","OFFSET","OMIT","ON","ONE","ONLY","OPTION","OR","ORDER","ORDINALITY","OUTER","OUTPUT","OVER","OVERFLOW","PARTITION","PARTITIONS","PASSING","PAST","PATH","PATTERN","PER","PERMUTE","PRECEDING","PRECISION","PREPARE","PRIVILEGES","PROPERTIES","PRUNE","QUOTES","RANGE","READ","RECURSIVE","REFRESH","RENAME","REPEATABLE","RESET","RESPECT","RESTRICT","RETURNING","REVOKE","RIGHT","ROLE","ROLES","ROLLBACK","ROLLUP","ROW","ROWS","RUNNING","SCALAR","SCHEMA","SCHEMAS","SECURITY","SEEK","SELECT","SERIALIZABLE","SESSION","SET","SETS","SHOW","SKIP","SOME","START","STATS","STRING","SUBSET","SYSTEM","TABLE","TABLES","TABLESAMPLE","TEXT","THEN","TIES","TIME","TIMESTAMP","TO","TRAILING","TRANSACTION","TRUE","TYPE","UESCAPE","UNBOUNDED","UNCOMMITTED","UNCONDITIONAL","UNION","UNIQUE","UNKNOWN","UNMATCHED","UNNEST","UPDATE","USE","USER","USING","UTF16","UTF32","UTF8","VALIDATE","VALUE","VALUES","VERBOSE","VIEW","WHEN","WHERE","WINDOW","WITH","WITHIN","WITHOUT","WORK","WRAPPER","WRITE","ZONE"],sL=["BIGINT","INT","INTEGER","SMALLINT","TINYINT","BOOLEAN","DATE","DECIMAL","REAL","DOUBLE","HYPERLOGLOG","QDIGEST","TDIGEST","P4HYPERLOGLOG","INTERVAL","TIMESTAMP","TIME","VARBINARY","VARCHAR","CHAR","ROW","ARRAY","MAP","JSON","JSON2016","IPADDRESS","GEOMETRY","UUID","SETDIGEST","JONIREGEXP","RE2JREGEXP","LIKEPATTERN","COLOR","CODEPOINTS","FUNCTION","JSONPATH"],lL=Q(["SELECT [ALL | DISTINCT]"]),iL=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY [ALL | DISTINCT]","HAVING","WINDOW","PARTITION BY","ORDER BY","LIMIT","OFFSET","FETCH {FIRST | NEXT}","INSERT INTO","VALUES","SET","MATCH_RECOGNIZE","MEASURES","ONE ROW PER MATCH","ALL ROWS PER MATCH","AFTER MATCH","PATTERN","SUBSET","DEFINE"]),ad=Q(["CREATE TABLE [IF NOT EXISTS]"]),oc=Q(["CREATE [OR REPLACE] [MATERIALIZED] VIEW","UPDATE","DELETE FROM","DROP TABLE [IF EXISTS]","ALTER TABLE [IF EXISTS]","ADD COLUMN [IF NOT EXISTS]","DROP COLUMN [IF EXISTS]","RENAME COLUMN [IF EXISTS]","RENAME TO","SET AUTHORIZATION [USER | ROLE]","SET PROPERTIES","EXECUTE","TRUNCATE TABLE","ALTER SCHEMA","ALTER MATERIALIZED VIEW","ALTER VIEW","CREATE SCHEMA","CREATE ROLE","DROP SCHEMA","DROP MATERIALIZED VIEW","DROP VIEW","DROP ROLE","EXPLAIN","ANALYZE","EXPLAIN ANALYZE","EXPLAIN ANALYZE VERBOSE","USE","DESCRIBE INPUT","DESCRIBE OUTPUT","REFRESH MATERIALIZED VIEW","RESET SESSION","SET SESSION","SET PATH","SET TIME ZONE","SHOW GRANTS","SHOW CREATE TABLE","SHOW CREATE SCHEMA","SHOW CREATE VIEW","SHOW CREATE MATERIALIZED VIEW","SHOW TABLES","SHOW SCHEMAS","SHOW CATALOGS","SHOW COLUMNS","SHOW STATS FOR","SHOW ROLES","SHOW CURRENT ROLES","SHOW ROLE GRANTS","SHOW FUNCTIONS","SHOW SESSION"]),oL=Q(["UNION [ALL | DISTINCT] [CORRESPONDING]","EXCEPT [ALL | DISTINCT] [CORRESPONDING]","INTERSECT [ALL | DISTINCT] [CORRESPONDING]"]),EL=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL [INNER] JOIN","NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"]),TL=Q(["{ROWS | RANGE | GROUPS} BETWEEN","IS [NOT] DISTINCT FROM"]),cL=Q([]),SL={name:"trino",tokenizerOptions:{reservedSelect:lL,reservedClauses:[...iL,...ad,...oc],reservedSetOperations:oL,reservedJoins:EL,reservedKeywordPhrases:TL,reservedDataTypePhrases:cL,reservedKeywords:rL,reservedDataTypes:sL,reservedFunctionNames:aL,extraParens:["[]","{}"],stringTypes:[{quote:"''-qq",prefixes:["U&"]},{quote:"''-raw",prefixes:["X"],requirePrefix:!0}],identTypes:['""-qq'],paramTypes:{positional:!0},operators:["%","->","=>",":","||","|","^","$"]},formatOptions:{onelineClauses:[...ad,...oc],tabularOnelineClauses:oc}},RL=["APPROX_COUNT_DISTINCT","AVG","CHECKSUM_AGG","COUNT","COUNT_BIG","GROUPING","GROUPING_ID","MAX","MIN","STDEV","STDEVP","SUM","VAR","VARP","CUME_DIST","FIRST_VALUE","LAG","LAST_VALUE","LEAD","PERCENTILE_CONT","PERCENTILE_DISC","PERCENT_RANK","Collation - COLLATIONPROPERTY","Collation - TERTIARY_WEIGHTS","@@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","DATEADD","DATEDIFF","DATEDIFF_BIG","DATEFROMPARTS","DATENAME","DATEPART","DATETIME2FROMPARTS","DATETIMEFROMPARTS","DATETIMEOFFSETFROMPARTS","DAY","EOMONTH","GETDATE","GETUTCDATE","ISDATE","MONTH","SMALLDATETIMEFROMPARTS","SWITCHOFFSET","SYSDATETIME","SYSDATETIMEOFFSET","SYSUTCDATETIME","TIMEFROMPARTS","TODATETIMEOFFSET","YEAR","JSON","ISJSON","JSON_VALUE","JSON_QUERY","JSON_MODIFY","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","CERTENCODED","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","CHARINDEX","CONCAT","CONCAT_WS","DIFFERENCE","FORMAT","LEFT","LEN","LOWER","LTRIM","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","UPDATE","COALESCE","NULLIF"],uL=["ADD","ALL","ALTER","AND","ANY","AS","ASC","AUTHORIZATION","BACKUP","BEGIN","BETWEEN","BREAK","BROWSE","BULK","BY","CASCADE","CHECK","CHECKPOINT","CLOSE","CLUSTERED","COALESCE","COLLATE","COLUMN","COMMIT","COMPUTE","CONSTRAINT","CONTAINS","CONTAINSTABLE","CONTINUE","CONVERT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DBCC","DEALLOCATE","DECLARE","DEFAULT","DELETE","DENY","DESC","DISK","DISTINCT","DISTRIBUTED","DROP","DUMP","ERRLVL","ESCAPE","EXEC","EXECUTE","EXISTS","EXIT","EXTERNAL","FETCH","FILE","FILLFACTOR","FOR","FOREIGN","FREETEXT","FREETEXTTABLE","FROM","FULL","FUNCTION","GOTO","GRANT","GROUP","HAVING","HOLDLOCK","IDENTITY","IDENTITYCOL","IDENTITY_INSERT","IF","IN","INDEX","INNER","INSERT","INTERSECT","INTO","IS","JOIN","KEY","KILL","LEFT","LIKE","LINENO","LOAD","MERGE","NOCHECK","NONCLUSTERED","NOT","NULL","NULLIF","OF","OFF","OFFSETS","ON","OPEN","OPENDATASOURCE","OPENQUERY","OPENROWSET","OPENXML","OPTION","OR","ORDER","OUTER","OVER","PERCENT","PIVOT","PLAN","PRIMARY","PRINT","PROC","PROCEDURE","PUBLIC","RAISERROR","READ","READTEXT","RECONFIGURE","REFERENCES","REPLICATION","RESTORE","RESTRICT","RETURN","REVERT","REVOKE","RIGHT","ROLLBACK","ROWCOUNT","ROWGUIDCOL","RULE","SAVE","SCHEMA","SECURITYAUDIT","SELECT","SEMANTICKEYPHRASETABLE","SEMANTICSIMILARITYDETAILSTABLE","SEMANTICSIMILARITYTABLE","SESSION_USER","SET","SETUSER","SHUTDOWN","SOME","STATISTICS","SYSTEM_USER","TABLE","TABLESAMPLE","TEXTSIZE","THEN","TO","TOP","TRAN","TRANSACTION","TRIGGER","TRUNCATE","TRY_CONVERT","TSEQUAL","UNION","UNIQUE","UNPIVOT","UPDATE","UPDATETEXT","USE","USER","VALUES","VIEW","WAITFOR","WHERE","WHILE","WITH","WITHIN GROUP","WRITETEXT","$ACTION"],AL=["BINARY","BIT","CHAR","CHAR","CHARACTER","DATE","DATETIME2","DATETIMEOFFSET","DEC","DECIMAL","DOUBLE","FLOAT","INT","INTEGER","NATIONAL","NCHAR","NUMERIC","NVARCHAR","PRECISION","REAL","SMALLINT","TIME","TIMESTAMP","VARBINARY","VARCHAR"],dL=Q(["SELECT [ALL | DISTINCT]"]),OL=Q(["WITH","INTO","FROM","WHERE","GROUP BY","HAVING","WINDOW","PARTITION BY","ORDER BY","OFFSET","FETCH {FIRST | NEXT}","FOR {BROWSE | XML | JSON}","OPTION","INSERT [INTO]","VALUES","SET","MERGE [INTO]","WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]","UPDATE SET"]),rd=Q(["CREATE TABLE"]),Ec=Q(["CREATE [OR ALTER] [MATERIALIZED] VIEW","UPDATE","WHERE CURRENT OF","DELETE [FROM]","DROP TABLE [IF EXISTS]","ALTER TABLE","ADD","DROP COLUMN [IF EXISTS]","ALTER COLUMN","TRUNCATE TABLE","CREATE [UNIQUE] [CLUSTERED] INDEX","CREATE DATABASE","ALTER DATABASE","DROP DATABASE [IF EXISTS]","CREATE [OR ALTER] [PARTITION] {FUNCTION | PROCEDURE | PROC}","ALTER [PARTITION] {FUNCTION | PROCEDURE | PROC}","DROP [PARTITION] {FUNCTION | PROCEDURE | PROC} [IF EXISTS]","GO","USE","ADD SENSITIVITY CLASSIFICATION","ADD SIGNATURE","AGGREGATE","ANSI_DEFAULTS","ANSI_NULLS","ANSI_NULL_DFLT_OFF","ANSI_NULL_DFLT_ON","ANSI_PADDING","ANSI_WARNINGS","APPLICATION ROLE","ARITHABORT","ARITHIGNORE","ASSEMBLY","ASYMMETRIC KEY","AUTHORIZATION","AVAILABILITY GROUP","BACKUP","BACKUP CERTIFICATE","BACKUP MASTER KEY","BACKUP SERVICE MASTER KEY","BEGIN CONVERSATION TIMER","BEGIN DIALOG CONVERSATION","BROKER PRIORITY","BULK INSERT","CERTIFICATE","CLOSE MASTER KEY","CLOSE SYMMETRIC KEY","COLUMN ENCRYPTION KEY","COLUMN MASTER KEY","COLUMNSTORE INDEX","CONCAT_NULL_YIELDS_NULL","CONTEXT_INFO","CONTRACT","CREDENTIAL","CRYPTOGRAPHIC PROVIDER","CURSOR_CLOSE_ON_COMMIT","DATABASE","DATABASE AUDIT SPECIFICATION","DATABASE ENCRYPTION KEY","DATABASE HADR","DATABASE SCOPED CONFIGURATION","DATABASE SCOPED CREDENTIAL","DATABASE SET","DATEFIRST","DATEFORMAT","DEADLOCK_PRIORITY","DENY","DENY XML","DISABLE TRIGGER","ENABLE TRIGGER","END CONVERSATION","ENDPOINT","EVENT NOTIFICATION","EVENT SESSION","EXECUTE AS","EXTERNAL DATA SOURCE","EXTERNAL FILE FORMAT","EXTERNAL LANGUAGE","EXTERNAL LIBRARY","EXTERNAL RESOURCE POOL","EXTERNAL TABLE","FIPS_FLAGGER","FMTONLY","FORCEPLAN","FULLTEXT CATALOG","FULLTEXT INDEX","FULLTEXT STOPLIST","GET CONVERSATION GROUP","GET_TRANSMISSION_STATUS","GRANT","GRANT XML","IDENTITY_INSERT","IMPLICIT_TRANSACTIONS","INDEX","LANGUAGE","LOCK_TIMEOUT","LOGIN","MASTER KEY","MESSAGE TYPE","MOVE CONVERSATION","NOCOUNT","NOEXEC","NUMERIC_ROUNDABORT","OFFSETS","OPEN MASTER KEY","OPEN SYMMETRIC KEY","PARSEONLY","PARTITION SCHEME","QUERY_GOVERNOR_COST_LIMIT","QUEUE","QUOTED_IDENTIFIER","RECEIVE","REMOTE SERVICE BINDING","REMOTE_PROC_TRANSACTIONS","RESOURCE GOVERNOR","RESOURCE POOL","RESTORE","RESTORE FILELISTONLY","RESTORE HEADERONLY","RESTORE LABELONLY","RESTORE MASTER KEY","RESTORE REWINDONLY","RESTORE SERVICE MASTER KEY","RESTORE VERIFYONLY","REVERT","REVOKE","REVOKE XML","ROLE","ROUTE","ROWCOUNT","RULE","SCHEMA","SEARCH PROPERTY LIST","SECURITY POLICY","SELECTIVE XML INDEX","SEND","SENSITIVITY CLASSIFICATION","SEQUENCE","SERVER AUDIT","SERVER AUDIT SPECIFICATION","SERVER CONFIGURATION","SERVER ROLE","SERVICE","SERVICE MASTER KEY","SETUSER","SHOWPLAN_ALL","SHOWPLAN_TEXT","SHOWPLAN_XML","SIGNATURE","SPATIAL INDEX","STATISTICS","STATISTICS IO","STATISTICS PROFILE","STATISTICS TIME","STATISTICS XML","SYMMETRIC KEY","SYNONYM","TABLE","TABLE IDENTITY","TEXTSIZE","TRANSACTION ISOLATION LEVEL","TRIGGER","TYPE","UPDATE STATISTICS","USER","WORKLOAD GROUP","XACT_ABORT","XML INDEX","XML SCHEMA COLLECTION"]),NL=Q(["UNION [ALL]","EXCEPT","INTERSECT"]),IL=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","{CROSS | OUTER} APPLY"]),hL=Q(["ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]","{ROWS | RANGE} BETWEEN"]),fL=Q([]),CL={name:"transactsql",tokenizerOptions:{reservedSelect:dL,reservedClauses:[...OL,...rd,...Ec],reservedSetOperations:NL,reservedJoins:IL,reservedKeywordPhrases:hL,reservedDataTypePhrases:fL,reservedKeywords:uL,reservedDataTypes:AL,reservedFunctionNames:RL,nestedBlockComments:!0,stringTypes:[{quote:"''-qq",prefixes:["N"]},"{}"],identTypes:['""-qq',"[]"],identChars:{first:"#@",rest:"#@$"},paramTypes:{named:["@"],quoted:["@"]},operators:["%","&","|","^","~","!<","!>","+=","-=","*=","/=","%=","|=","&=","^=","::",":"],propertyAccessOperators:[".."]},formatOptions:{alwaysDenseOperators:["::"],onelineClauses:[...rd,...Ec],tabularOnelineClauses:Ec}},pL=["ADD","ALL","ALTER","ANALYZE","AND","AS","ASC","ASENSITIVE","BEFORE","BETWEEN","_BINARY","BOTH","BY","CALL","CASCADE","CASE","CHANGE","CHECK","COLLATE","COLUMN","CONDITION","CONSTRAINT","CONTINUE","CONVERT","CREATE","CROSS","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DECLARE","DEFAULT","DELAYED","DELETE","DESC","DESCRIBE","DETERMINISTIC","DISTINCT","DISTINCTROW","DIV","DROP","DUAL","EACH","ELSE","ELSEIF","ENCLOSED","ESCAPED","EXCEPT","EXISTS","EXIT","EXPLAIN","EXTRA_JOIN","FALSE","FETCH","FOR","FORCE","FORCE_COMPILED_MODE","FORCE_INTERPRETER_MODE","FOREIGN","FROM","FULL","FULLTEXT","GRANT","GROUP","HAVING","HEARTBEAT_NO_LOGGING","HIGH_PRIORITY","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IF","IGNORE","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","IN","_INTERNAL_DYNAMIC_TYPECAST","INTERSECT","INTERVAL","INTO","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINES","LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LOOP","LOW_PRIORITY","MATCH","MAXVALUE","MINUS","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATURAL","NO_QUERY_REWRITE","NOT","NO_WRITE_TO_BINLOG","NO_QUERY_REWRITE","NULL","ON","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PRIMARY","PROCEDURE","PURGE","RANGE","READ","READS","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE","REQUIRE","RESTRICT","RETURN","REVOKE","RIGHT","RIGHT_ANTI_JOIN","RIGHT_SEMI_JOIN","RIGHT_STRAIGHT_JOIN","RLIKE","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SEMI_JOIN","SENSITIVE","SEPARATOR","SET","SHOW","SIGNAL","SPATIAL","SPECIFIC","SQL","SQL_BIG_RESULT","SQL_BUFFER_RESULT","SQL_CACHE","SQL_CALC_FOUND_ROWS","SQLEXCEPTION","SQL_NO_CACHE","SQL_NO_LOGGING","SQL_SMALL_RESULT","SQLSTATE","SQLWARNING","STRAIGHT_JOIN","TABLE","TERMINATED","THEN","TO","TRAILING","TRIGGER","TRUE","UNBOUNDED","UNDO","UNION","UNIQUE","UNLOCK","UPDATE","USAGE","USE","USING","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","_UTF8","VALUES","WHEN","WHERE","WHILE","WINDOW","WITH","WITHIN","WRITE","XOR","YEAR_MONTH","ZEROFILL"],LL=["BIGINT","BINARY","BIT","BLOB","CHAR","CHARACTER","DATETIME","DEC","DECIMAL","DOUBLE PRECISION","DOUBLE","ENUM","FIXED","FLOAT","FLOAT4","FLOAT8","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","LONG","LONGBLOB","LONGTEXT","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","NATIONAL CHAR","NATIONAL VARCHAR","NUMERIC","PRECISION","REAL","SMALLINT","TEXT","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","UNSIGNED","VARBINARY","VARCHAR","VARCHARACTER","YEAR"],_L=["ABS","ACOS","ADDDATE","ADDTIME","AES_DECRYPT","AES_ENCRYPT","ANY_VALUE","APPROX_COUNT_DISTINCT","APPROX_COUNT_DISTINCT_ACCUMULATE","APPROX_COUNT_DISTINCT_COMBINE","APPROX_COUNT_DISTINCT_ESTIMATE","APPROX_GEOGRAPHY_INTERSECTS","APPROX_PERCENTILE","ASCII","ASIN","ATAN","ATAN2","AVG","BIN","BINARY","BIT_AND","BIT_COUNT","BIT_OR","BIT_XOR","CAST","CEIL","CEILING","CHAR","CHARACTER_LENGTH","CHAR_LENGTH","CHARSET","COALESCE","COERCIBILITY","COLLATION","COLLECT","CONCAT","CONCAT_WS","CONNECTION_ID","CONV","CONVERT","CONVERT_TZ","COS","COT","COUNT","CUME_DIST","CURDATE","CURRENT_DATE","CURRENT_ROLE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURTIME","DATABASE","DATE","DATE_ADD","DATEDIFF","DATE_FORMAT","DATE_SUB","DATE_TRUNC","DAY","DAYNAME","DAYOFMONTH","DAYOFWEEK","DAYOFYEAR","DECODE","DEFAULT","DEGREES","DENSE_RANK","DIV","DOT_PRODUCT","ELT","EUCLIDEAN_DISTANCE","EXP","EXTRACT","FIELD","FIRST","FIRST_VALUE","FLOOR","FORMAT","FOUND_ROWS","FROM_BASE64","FROM_DAYS","FROM_UNIXTIME","GEOGRAPHY_AREA","GEOGRAPHY_CONTAINS","GEOGRAPHY_DISTANCE","GEOGRAPHY_INTERSECTS","GEOGRAPHY_LATITUDE","GEOGRAPHY_LENGTH","GEOGRAPHY_LONGITUDE","GEOGRAPHY_POINT","GEOGRAPHY_WITHIN_DISTANCE","GEOMETRY_AREA","GEOMETRY_CONTAINS","GEOMETRY_DISTANCE","GEOMETRY_FILTER","GEOMETRY_INTERSECTS","GEOMETRY_LENGTH","GEOMETRY_POINT","GEOMETRY_WITHIN_DISTANCE","GEOMETRY_X","GEOMETRY_Y","GREATEST","GROUPING","GROUP_CONCAT","HEX","HIGHLIGHT","HOUR","ICU_VERSION","IF","IFNULL","INET_ATON","INET_NTOA","INET6_ATON","INET6_NTOA","INITCAP","INSERT","INSTR","INTERVAL","IS","IS NULL","JSON_AGG","JSON_ARRAY_CONTAINS_DOUBLE","JSON_ARRAY_CONTAINS_JSON","JSON_ARRAY_CONTAINS_STRING","JSON_ARRAY_PUSH_DOUBLE","JSON_ARRAY_PUSH_JSON","JSON_ARRAY_PUSH_STRING","JSON_DELETE_KEY","JSON_EXTRACT_DOUBLE","JSON_EXTRACT_JSON","JSON_EXTRACT_STRING","JSON_EXTRACT_BIGINT","JSON_GET_TYPE","JSON_LENGTH","JSON_SET_DOUBLE","JSON_SET_JSON","JSON_SET_STRING","JSON_SPLICE_DOUBLE","JSON_SPLICE_JSON","JSON_SPLICE_STRING","LAG","LAST_DAY","LAST_VALUE","LCASE","LEAD","LEAST","LEFT","LENGTH","LIKE","LN","LOCALTIME","LOCALTIMESTAMP","LOCATE","LOG","LOG10","LOG2","LPAD","LTRIM","MATCH","MAX","MD5","MEDIAN","MICROSECOND","MIN","MINUTE","MOD","MONTH","MONTHNAME","MONTHS_BETWEEN","NOT","NOW","NTH_VALUE","NTILE","NULLIF","OCTET_LENGTH","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","PI","PIVOT","POSITION","POW","POWER","QUARTER","QUOTE","RADIANS","RAND","RANK","REGEXP","REPEAT","REPLACE","REVERSE","RIGHT","RLIKE","ROUND","ROW_COUNT","ROW_NUMBER","RPAD","RTRIM","SCALAR","SCHEMA","SEC_TO_TIME","SHA1","SHA2","SIGMOID","SIGN","SIN","SLEEP","SPLIT","SOUNDEX","SOUNDS LIKE","SOURCE_POS_WAIT","SPACE","SQRT","STDDEV","STDDEV_POP","STDDEV_SAMP","STR_TO_DATE","SUBDATE","SUBSTR","SUBSTRING","SUBSTRING_INDEX","SUM","SYS_GUID","TAN","TIME","TIMEDIFF","TIME_BUCKET","TIME_FORMAT","TIMESTAMP","TIMESTAMPADD","TIMESTAMPDIFF","TIME_TO_SEC","TO_BASE64","TO_CHAR","TO_DAYS","TO_JSON","TO_NUMBER","TO_SECONDS","TO_TIMESTAMP","TRIM","TRUNC","TRUNCATE","UCASE","UNHEX","UNIX_TIMESTAMP","UPDATEXML","UPPER","UTC_DATE","UTC_TIME","UTC_TIMESTAMP","UUID","VALUES","VARIANCE","VAR_POP","VAR_SAMP","VECTOR_SUB","VERSION","WEEK","WEEKDAY","WEEKOFYEAR","YEAR"],mL=Q(["SELECT [ALL | DISTINCT | DISTINCTROW]"]),vL=Q(["WITH","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER BY","LIMIT","OFFSET","INSERT [IGNORE] [INTO]","VALUES","REPLACE [INTO]","ON DUPLICATE KEY UPDATE","SET","CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]","CREATE [OR REPLACE] [EXTERNAL] FUNCTION"]),sd=Q(["CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"]),Tc=Q(["CREATE VIEW","UPDATE","DELETE [FROM]","DROP [TEMPORARY] TABLE [IF EXISTS]","ALTER [ONLINE] TABLE","ADD [COLUMN]","ADD [UNIQUE] {INDEX | KEY}","DROP [COLUMN]","MODIFY [COLUMN]","CHANGE","RENAME [TO | AS]","TRUNCATE [TABLE]","ADD AGGREGATOR","ADD LEAF","AGGREGATOR SET AS MASTER","ALTER DATABASE","ALTER PIPELINE","ALTER RESOURCE POOL","ALTER USER","ALTER VIEW","ANALYZE TABLE","ATTACH DATABASE","ATTACH LEAF","ATTACH LEAF ALL","BACKUP DATABASE","BINLOG","BOOTSTRAP AGGREGATOR","CACHE INDEX","CALL","CHANGE","CHANGE MASTER TO","CHANGE REPLICATION FILTER","CHANGE REPLICATION SOURCE TO","CHECK BLOB CHECKSUM","CHECK TABLE","CHECKSUM TABLE","CLEAR ORPHAN DATABASES","CLONE","COMMIT","CREATE DATABASE","CREATE GROUP","CREATE INDEX","CREATE LINK","CREATE MILESTONE","CREATE PIPELINE","CREATE RESOURCE POOL","CREATE ROLE","CREATE USER","DEALLOCATE PREPARE","DESCRIBE","DETACH DATABASE","DETACH PIPELINE","DROP DATABASE","DROP FUNCTION","DROP INDEX","DROP LINK","DROP PIPELINE","DROP PROCEDURE","DROP RESOURCE POOL","DROP ROLE","DROP USER","DROP VIEW","EXECUTE","EXPLAIN","FLUSH","FORCE","GRANT","HANDLER","HELP","KILL CONNECTION","KILLALL QUERIES","LOAD DATA","LOAD INDEX INTO CACHE","LOAD XML","LOCK INSTANCE FOR BACKUP","LOCK TABLES","MASTER_POS_WAIT","OPTIMIZE TABLE","PREPARE","PURGE BINARY LOGS","REBALANCE PARTITIONS","RELEASE SAVEPOINT","REMOVE AGGREGATOR","REMOVE LEAF","REPAIR TABLE","REPLACE","REPLICATE DATABASE","RESET","RESET MASTER","RESET PERSIST","RESET REPLICA","RESET SLAVE","RESTART","RESTORE DATABASE","RESTORE REDUNDANCY","REVOKE","ROLLBACK","ROLLBACK TO SAVEPOINT","SAVEPOINT","SET CHARACTER SET","SET DEFAULT ROLE","SET NAMES","SET PASSWORD","SET RESOURCE GROUP","SET ROLE","SET TRANSACTION","SHOW","SHOW CHARACTER SET","SHOW COLLATION","SHOW COLUMNS","SHOW CREATE DATABASE","SHOW CREATE FUNCTION","SHOW CREATE PIPELINE","SHOW CREATE PROCEDURE","SHOW CREATE TABLE","SHOW CREATE USER","SHOW CREATE VIEW","SHOW DATABASES","SHOW ENGINE","SHOW ENGINES","SHOW ERRORS","SHOW FUNCTION CODE","SHOW FUNCTION STATUS","SHOW GRANTS","SHOW INDEX","SHOW MASTER STATUS","SHOW OPEN TABLES","SHOW PLUGINS","SHOW PRIVILEGES","SHOW PROCEDURE CODE","SHOW PROCEDURE STATUS","SHOW PROCESSLIST","SHOW PROFILE","SHOW PROFILES","SHOW RELAYLOG EVENTS","SHOW REPLICA STATUS","SHOW REPLICAS","SHOW SLAVE","SHOW SLAVE HOSTS","SHOW STATUS","SHOW TABLE STATUS","SHOW TABLES","SHOW VARIABLES","SHOW WARNINGS","SHUTDOWN","SNAPSHOT DATABASE","SOURCE_POS_WAIT","START GROUP_REPLICATION","START PIPELINE","START REPLICA","START SLAVE","START TRANSACTION","STOP GROUP_REPLICATION","STOP PIPELINE","STOP REPLICA","STOP REPLICATING","STOP SLAVE","TEST PIPELINE","UNLOCK INSTANCE","UNLOCK TABLES","USE","XA","ITERATE","LEAVE","LOOP","REPEAT","RETURN","WHILE"]),xL=Q(["UNION [ALL | DISTINCT]","EXCEPT","INTERSECT","MINUS"]),DL=Q(["JOIN","{LEFT | RIGHT | FULL} [OUTER] JOIN","{INNER | CROSS} JOIN","NATURAL {LEFT | RIGHT} [OUTER] JOIN","STRAIGHT_JOIN"]),yL=Q(["ON DELETE","ON UPDATE","CHARACTER SET","{ROWS | RANGE} BETWEEN","IDENTIFIED BY"]),gL=Q([]),ML={name:"singlestoredb",tokenizerOptions:{reservedSelect:mL,reservedClauses:[...vL,...sd,...Tc],reservedSetOperations:xL,reservedJoins:DL,reservedKeywordPhrases:yL,reservedDataTypePhrases:gL,reservedKeywords:pL,reservedDataTypes:LL,reservedFunctionNames:_L,stringTypes:['""-qq-bs',"''-qq-bs",{quote:"''-raw",prefixes:["B","X"],requirePrefix:!0}],identTypes:["``"],identChars:{first:"$",rest:"$",allowFirstCharNumber:!0},variableTypes:[{regex:"@@?[A-Za-z0-9_$]+"},{quote:"``",prefixes:["@"],requirePrefix:!0}],lineCommentTypes:["--","#"],operators:[":=","&","|","^","~","<<",">>","<=>","&&","||","::","::$","::%",":>","!:>","*.*"],postProcess:mo},formatOptions:{alwaysDenseOperators:["::","::$","::%"],onelineClauses:[...sd,...Tc],tabularOnelineClauses:Tc}},PL=["ABS","ACOS","ACOSH","ADD_MONTHS","ALL_USER_NAMES","ANY_VALUE","APPROX_COUNT_DISTINCT","APPROX_PERCENTILE","APPROX_PERCENTILE_ACCUMULATE","APPROX_PERCENTILE_COMBINE","APPROX_PERCENTILE_ESTIMATE","APPROX_TOP_K","APPROX_TOP_K_ACCUMULATE","APPROX_TOP_K_COMBINE","APPROX_TOP_K_ESTIMATE","APPROXIMATE_JACCARD_INDEX","APPROXIMATE_SIMILARITY","ARRAY_AGG","ARRAY_APPEND","ARRAY_CAT","ARRAY_COMPACT","ARRAY_CONSTRUCT","ARRAY_CONSTRUCT_COMPACT","ARRAY_CONTAINS","ARRAY_INSERT","ARRAY_INTERSECTION","ARRAY_POSITION","ARRAY_PREPEND","ARRAY_SIZE","ARRAY_SLICE","ARRAY_TO_STRING","ARRAY_UNION_AGG","ARRAY_UNIQUE_AGG","ARRAYS_OVERLAP","AS_ARRAY","AS_BINARY","AS_BOOLEAN","AS_CHAR","AS_VARCHAR","AS_DATE","AS_DECIMAL","AS_NUMBER","AS_DOUBLE","AS_REAL","AS_INTEGER","AS_OBJECT","AS_TIME","AS_TIMESTAMP_LTZ","AS_TIMESTAMP_NTZ","AS_TIMESTAMP_TZ","ASCII","ASIN","ASINH","ATAN","ATAN2","ATANH","AUTO_REFRESH_REGISTRATION_HISTORY","AUTOMATIC_CLUSTERING_HISTORY","AVG","BASE64_DECODE_BINARY","BASE64_DECODE_STRING","BASE64_ENCODE","BIT_LENGTH","BITAND","BITAND_AGG","BITMAP_BIT_POSITION","BITMAP_BUCKET_NUMBER","BITMAP_CONSTRUCT_AGG","BITMAP_COUNT","BITMAP_OR_AGG","BITNOT","BITOR","BITOR_AGG","BITSHIFTLEFT","BITSHIFTRIGHT","BITXOR","BITXOR_AGG","BOOLAND","BOOLAND_AGG","BOOLNOT","BOOLOR","BOOLOR_AGG","BOOLXOR","BOOLXOR_AGG","BUILD_SCOPED_FILE_URL","BUILD_STAGE_FILE_URL","CASE","CAST","CBRT","CEIL","CHARINDEX","CHECK_JSON","CHECK_XML","CHR","CHAR","COALESCE","COLLATE","COLLATION","COMPLETE_TASK_GRAPHS","COMPRESS","CONCAT","CONCAT_WS","CONDITIONAL_CHANGE_EVENT","CONDITIONAL_TRUE_EVENT","CONTAINS","CONVERT_TIMEZONE","COPY_HISTORY","CORR","COS","COSH","COT","COUNT","COUNT_IF","COVAR_POP","COVAR_SAMP","CUME_DIST","CURRENT_ACCOUNT","CURRENT_AVAILABLE_ROLES","CURRENT_CLIENT","CURRENT_DATABASE","CURRENT_DATE","CURRENT_IP_ADDRESS","CURRENT_REGION","CURRENT_ROLE","CURRENT_SCHEMA","CURRENT_SCHEMAS","CURRENT_SECONDARY_ROLES","CURRENT_SESSION","CURRENT_STATEMENT","CURRENT_TASK_GRAPHS","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_TRANSACTION","CURRENT_USER","CURRENT_VERSION","CURRENT_WAREHOUSE","DATA_TRANSFER_HISTORY","DATABASE_REFRESH_HISTORY","DATABASE_REFRESH_PROGRESS","DATABASE_REFRESH_PROGRESS_BY_JOB","DATABASE_STORAGE_USAGE_HISTORY","DATE_FROM_PARTS","DATE_PART","DATE_TRUNC","DATEADD","DATEDIFF","DAYNAME","DECODE","DECOMPRESS_BINARY","DECOMPRESS_STRING","DECRYPT","DECRYPT_RAW","DEGREES","DENSE_RANK","DIV0","EDITDISTANCE","ENCRYPT","ENCRYPT_RAW","ENDSWITH","EQUAL_NULL","EXP","EXPLAIN_JSON","EXTERNAL_FUNCTIONS_HISTORY","EXTERNAL_TABLE_FILES","EXTERNAL_TABLE_FILE_REGISTRATION_HISTORY","EXTRACT","EXTRACT_SEMANTIC_CATEGORIES","FACTORIAL","FILTER","FIRST_VALUE","FLATTEN","FLOOR","GENERATE_COLUMN_DESCRIPTION","GENERATOR","GET","GET_ABSOLUTE_PATH","GET_DDL","GET_IGNORE_CASE","GET_OBJECT_REFERENCES","GET_PATH","GET_PRESIGNED_URL","GET_RELATIVE_PATH","GET_STAGE_LOCATION","GETBIT","GREATEST","GREATEST_IGNORE_NULLS","GROUPING","GROUPING_ID","HASH","HASH_AGG","HAVERSINE","HEX_DECODE_BINARY","HEX_DECODE_STRING","HEX_ENCODE","HLL","HLL_ACCUMULATE","HLL_COMBINE","HLL_ESTIMATE","HLL_EXPORT","HLL_IMPORT","HOUR","MINUTE","SECOND","IDENTIFIER","IFF","IFNULL","ILIKE","ILIKE ANY","INFER_SCHEMA","INITCAP","INSERT","INVOKER_ROLE","INVOKER_SHARE","IS_ARRAY","IS_BINARY","IS_BOOLEAN","IS_CHAR","IS_VARCHAR","IS_DATE","IS_DATE_VALUE","IS_DECIMAL","IS_DOUBLE","IS_REAL","IS_GRANTED_TO_INVOKER_ROLE","IS_INTEGER","IS_NULL_VALUE","IS_OBJECT","IS_ROLE_IN_SESSION","IS_TIME","IS_TIMESTAMP_LTZ","IS_TIMESTAMP_NTZ","IS_TIMESTAMP_TZ","JAROWINKLER_SIMILARITY","JSON_EXTRACT_PATH_TEXT","KURTOSIS","LAG","LAST_DAY","LAST_QUERY_ID","LAST_TRANSACTION","LAST_VALUE","LEAD","LEAST","LEFT","LENGTH","LEN","LIKE","LIKE ALL","LIKE ANY","LISTAGG","LN","LOCALTIME","LOCALTIMESTAMP","LOG","LOGIN_HISTORY","LOGIN_HISTORY_BY_USER","LOWER","LPAD","LTRIM","MATERIALIZED_VIEW_REFRESH_HISTORY","MD5","MD5_HEX","MD5_BINARY","MD5_NUMBER — Obsoleted","MD5_NUMBER_LOWER64","MD5_NUMBER_UPPER64","MEDIAN","MIN","MAX","MINHASH","MINHASH_COMBINE","MOD","MODE","MONTHNAME","MONTHS_BETWEEN","NEXT_DAY","NORMAL","NTH_VALUE","NTILE","NULLIF","NULLIFZERO","NVL","NVL2","OBJECT_AGG","OBJECT_CONSTRUCT","OBJECT_CONSTRUCT_KEEP_NULL","OBJECT_DELETE","OBJECT_INSERT","OBJECT_KEYS","OBJECT_PICK","OCTET_LENGTH","PARSE_IP","PARSE_JSON","PARSE_URL","PARSE_XML","PERCENT_RANK","PERCENTILE_CONT","PERCENTILE_DISC","PI","PIPE_USAGE_HISTORY","POLICY_CONTEXT","POLICY_REFERENCES","POSITION","POW","POWER","PREVIOUS_DAY","QUERY_ACCELERATION_HISTORY","QUERY_HISTORY","QUERY_HISTORY_BY_SESSION","QUERY_HISTORY_BY_USER","QUERY_HISTORY_BY_WAREHOUSE","RADIANS","RANDOM","RANDSTR","RANK","RATIO_TO_REPORT","REGEXP","REGEXP_COUNT","REGEXP_INSTR","REGEXP_LIKE","REGEXP_REPLACE","REGEXP_SUBSTR","REGEXP_SUBSTR_ALL","REGR_AVGX","REGR_AVGY","REGR_COUNT","REGR_INTERCEPT","REGR_R2","REGR_SLOPE","REGR_SXX","REGR_SXY","REGR_SYY","REGR_VALX","REGR_VALY","REPEAT","REPLACE","REPLICATION_GROUP_REFRESH_HISTORY","REPLICATION_GROUP_REFRESH_PROGRESS","REPLICATION_GROUP_REFRESH_PROGRESS_BY_JOB","REPLICATION_GROUP_USAGE_HISTORY","REPLICATION_USAGE_HISTORY","REST_EVENT_HISTORY","RESULT_SCAN","REVERSE","RIGHT","RLIKE","ROUND","ROW_NUMBER","RPAD","RTRIM","RTRIMMED_LENGTH","SEARCH_OPTIMIZATION_HISTORY","SEQ1","SEQ2","SEQ4","SEQ8","SERVERLESS_TASK_HISTORY","SHA1","SHA1_HEX","SHA1_BINARY","SHA2","SHA2_HEX","SHA2_BINARY","SIGN","SIN","SINH","SKEW","SOUNDEX","SPACE","SPLIT","SPLIT_PART","SPLIT_TO_TABLE","SQRT","SQUARE","ST_AREA","ST_ASEWKB","ST_ASEWKT","ST_ASGEOJSON","ST_ASWKB","ST_ASBINARY","ST_ASWKT","ST_ASTEXT","ST_AZIMUTH","ST_CENTROID","ST_COLLECT","ST_CONTAINS","ST_COVEREDBY","ST_COVERS","ST_DIFFERENCE","ST_DIMENSION","ST_DISJOINT","ST_DISTANCE","ST_DWITHIN","ST_ENDPOINT","ST_ENVELOPE","ST_GEOGFROMGEOHASH","ST_GEOGPOINTFROMGEOHASH","ST_GEOGRAPHYFROMWKB","ST_GEOGRAPHYFROMWKT","ST_GEOHASH","ST_GEOMETRYFROMWKB","ST_GEOMETRYFROMWKT","ST_HAUSDORFFDISTANCE","ST_INTERSECTION","ST_INTERSECTS","ST_LENGTH","ST_MAKEGEOMPOINT","ST_GEOM_POINT","ST_MAKELINE","ST_MAKEPOINT","ST_POINT","ST_MAKEPOLYGON","ST_POLYGON","ST_NPOINTS","ST_NUMPOINTS","ST_PERIMETER","ST_POINTN","ST_SETSRID","ST_SIMPLIFY","ST_SRID","ST_STARTPOINT","ST_SYMDIFFERENCE","ST_UNION","ST_WITHIN","ST_X","ST_XMAX","ST_XMIN","ST_Y","ST_YMAX","ST_YMIN","STAGE_DIRECTORY_FILE_REGISTRATION_HISTORY","STAGE_STORAGE_USAGE_HISTORY","STARTSWITH","STDDEV","STDDEV_POP","STDDEV_SAMP","STRIP_NULL_VALUE","STRTOK","STRTOK_SPLIT_TO_TABLE","STRTOK_TO_ARRAY","SUBSTR","SUBSTRING","SUM","SYSDATE","SYSTEM$ABORT_SESSION","SYSTEM$ABORT_TRANSACTION","SYSTEM$AUTHORIZE_PRIVATELINK","SYSTEM$AUTHORIZE_STAGE_PRIVATELINK_ACCESS","SYSTEM$BEHAVIOR_CHANGE_BUNDLE_STATUS","SYSTEM$CANCEL_ALL_QUERIES","SYSTEM$CANCEL_QUERY","SYSTEM$CLUSTERING_DEPTH","SYSTEM$CLUSTERING_INFORMATION","SYSTEM$CLUSTERING_RATIO ","SYSTEM$CURRENT_USER_TASK_NAME","SYSTEM$DATABASE_REFRESH_HISTORY ","SYSTEM$DATABASE_REFRESH_PROGRESS","SYSTEM$DATABASE_REFRESH_PROGRESS_BY_JOB ","SYSTEM$DISABLE_BEHAVIOR_CHANGE_BUNDLE","SYSTEM$DISABLE_DATABASE_REPLICATION","SYSTEM$ENABLE_BEHAVIOR_CHANGE_BUNDLE","SYSTEM$ESTIMATE_QUERY_ACCELERATION","SYSTEM$ESTIMATE_SEARCH_OPTIMIZATION_COSTS","SYSTEM$EXPLAIN_JSON_TO_TEXT","SYSTEM$EXPLAIN_PLAN_JSON","SYSTEM$EXTERNAL_TABLE_PIPE_STATUS","SYSTEM$GENERATE_SAML_CSR","SYSTEM$GENERATE_SCIM_ACCESS_TOKEN","SYSTEM$GET_AWS_SNS_IAM_POLICY","SYSTEM$GET_PREDECESSOR_RETURN_VALUE","SYSTEM$GET_PRIVATELINK","SYSTEM$GET_PRIVATELINK_AUTHORIZED_ENDPOINTS","SYSTEM$GET_PRIVATELINK_CONFIG","SYSTEM$GET_SNOWFLAKE_PLATFORM_INFO","SYSTEM$GET_TAG","SYSTEM$GET_TAG_ALLOWED_VALUES","SYSTEM$GET_TAG_ON_CURRENT_COLUMN","SYSTEM$GET_TAG_ON_CURRENT_TABLE","SYSTEM$GLOBAL_ACCOUNT_SET_PARAMETER","SYSTEM$LAST_CHANGE_COMMIT_TIME","SYSTEM$LINK_ACCOUNT_OBJECTS_BY_NAME","SYSTEM$MIGRATE_SAML_IDP_REGISTRATION","SYSTEM$PIPE_FORCE_RESUME","SYSTEM$PIPE_STATUS","SYSTEM$REVOKE_PRIVATELINK","SYSTEM$REVOKE_STAGE_PRIVATELINK_ACCESS","SYSTEM$SET_RETURN_VALUE","SYSTEM$SHOW_OAUTH_CLIENT_SECRETS","SYSTEM$STREAM_GET_TABLE_TIMESTAMP","SYSTEM$STREAM_HAS_DATA","SYSTEM$TASK_DEPENDENTS_ENABLE","SYSTEM$TYPEOF","SYSTEM$USER_TASK_CANCEL_ONGOING_EXECUTIONS","SYSTEM$VERIFY_EXTERNAL_OAUTH_TOKEN","SYSTEM$WAIT","SYSTEM$WHITELIST","SYSTEM$WHITELIST_PRIVATELINK","TAG_REFERENCES","TAG_REFERENCES_ALL_COLUMNS","TAG_REFERENCES_WITH_LINEAGE","TAN","TANH","TASK_DEPENDENTS","TASK_HISTORY","TIME_FROM_PARTS","TIME_SLICE","TIMEADD","TIMEDIFF","TIMESTAMP_FROM_PARTS","TIMESTAMPADD","TIMESTAMPDIFF","TO_ARRAY","TO_BINARY","TO_BOOLEAN","TO_CHAR","TO_VARCHAR","TO_DATE","DATE","TO_DECIMAL","TO_NUMBER","TO_NUMERIC","TO_DOUBLE","TO_GEOGRAPHY","TO_GEOMETRY","TO_JSON","TO_OBJECT","TO_TIME","TIME","TO_TIMESTAMP","TO_TIMESTAMP_LTZ","TO_TIMESTAMP_NTZ","TO_TIMESTAMP_TZ","TO_VARIANT","TO_XML","TRANSLATE","TRIM","TRUNCATE","TRUNC","TRUNC","TRY_BASE64_DECODE_BINARY","TRY_BASE64_DECODE_STRING","TRY_CAST","TRY_HEX_DECODE_BINARY","TRY_HEX_DECODE_STRING","TRY_PARSE_JSON","TRY_TO_BINARY","TRY_TO_BOOLEAN","TRY_TO_DATE","TRY_TO_DECIMAL","TRY_TO_NUMBER","TRY_TO_NUMERIC","TRY_TO_DOUBLE","TRY_TO_GEOGRAPHY","TRY_TO_GEOMETRY","TRY_TO_TIME","TRY_TO_TIMESTAMP","TRY_TO_TIMESTAMP_LTZ","TRY_TO_TIMESTAMP_NTZ","TRY_TO_TIMESTAMP_TZ","TYPEOF","UNICODE","UNIFORM","UPPER","UUID_STRING","VALIDATE","VALIDATE_PIPE_LOAD","VAR_POP","VAR_SAMP","VARIANCE","VARIANCE_SAMP","VARIANCE_POP","WAREHOUSE_LOAD_HISTORY","WAREHOUSE_METERING_HISTORY","WIDTH_BUCKET","XMLGET","YEAR","YEAROFWEEK","YEAROFWEEKISO","DAY","DAYOFMONTH","DAYOFWEEK","DAYOFWEEKISO","DAYOFYEAR","WEEK","WEEK","WEEKOFYEAR","WEEKISO","MONTH","QUARTER","ZEROIFNULL","ZIPF"],UL=["ACCOUNT","ALL","ALTER","AND","ANY","AS","BETWEEN","BY","CASE","CAST","CHECK","COLUMN","CONNECT","CONNECTION","CONSTRAINT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","DATABASE","DELETE","DISTINCT","DROP","ELSE","EXISTS","FALSE","FOLLOWING","FOR","FROM","FULL","GRANT","GROUP","GSCLUSTER","HAVING","ILIKE","IN","INCREMENT","INNER","INSERT","INTERSECT","INTO","IS","ISSUE","JOIN","LATERAL","LEFT","LIKE","LOCALTIME","LOCALTIMESTAMP","MINUS","NATURAL","NOT","NULL","OF","ON","OR","ORDER","ORGANIZATION","QUALIFY","REGEXP","REVOKE","RIGHT","RLIKE","ROW","ROWS","SAMPLE","SCHEMA","SELECT","SET","SOME","START","TABLE","TABLESAMPLE","THEN","TO","TRIGGER","TRUE","TRY_CAST","UNION","UNIQUE","UPDATE","USING","VALUES","VIEW","WHEN","WHENEVER","WHERE","WITH","COMMENT"],bL=["NUMBER","DECIMAL","NUMERIC","INT","INTEGER","BIGINT","SMALLINT","TINYINT","BYTEINT","FLOAT","FLOAT4","FLOAT8","DOUBLE","DOUBLE PRECISION","REAL","VARCHAR","CHAR","CHARACTER","STRING","TEXT","BINARY","VARBINARY","BOOLEAN","DATE","DATETIME","TIME","TIMESTAMP","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP","TIMESTAMP_TZ","VARIANT","OBJECT","ARRAY","GEOGRAPHY","GEOMETRY"],GL=Q(["SELECT [ALL | DISTINCT]"]),BL=Q(["WITH [RECURSIVE]","FROM","WHERE","GROUP BY","HAVING","PARTITION BY","ORDER BY","QUALIFY","LIMIT","OFFSET","FETCH [FIRST | NEXT]","INSERT [OVERWRITE] [ALL INTO | INTO | ALL | FIRST]","{THEN | ELSE} INTO","VALUES","SET","CLUSTER BY","[WITH] {MASKING POLICY | TAG | ROW ACCESS POLICY}","COPY GRANTS","USING TEMPLATE","MERGE INTO","WHEN MATCHED [AND]","THEN {UPDATE SET | DELETE}","WHEN NOT MATCHED THEN INSERT"]),ld=Q(["CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]","CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"]),cc=Q(["CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]","UPDATE","DELETE FROM","DROP TABLE [IF EXISTS]","ALTER TABLE [IF EXISTS]","RENAME TO","SWAP WITH","[SUSPEND | RESUME] RECLUSTER","DROP CLUSTERING KEY","ADD [COLUMN]","RENAME COLUMN","{ALTER | MODIFY} [COLUMN]","DROP [COLUMN]","{ADD | ALTER | MODIFY | DROP} [CONSTRAINT]","RENAME CONSTRAINT","{ADD | DROP} SEARCH OPTIMIZATION","{SET | UNSET} TAG","{ADD | DROP} ROW ACCESS POLICY","DROP ALL ROW ACCESS POLICIES","{SET | DROP} DEFAULT","{SET | DROP} NOT NULL","SET DATA TYPE","UNSET COMMENT","{SET | UNSET} MASKING POLICY","TRUNCATE [TABLE] [IF EXISTS]","ALTER ACCOUNT","ALTER API INTEGRATION","ALTER CONNECTION","ALTER DATABASE","ALTER EXTERNAL TABLE","ALTER FAILOVER GROUP","ALTER FILE FORMAT","ALTER FUNCTION","ALTER INTEGRATION","ALTER MASKING POLICY","ALTER MATERIALIZED VIEW","ALTER NETWORK POLICY","ALTER NOTIFICATION INTEGRATION","ALTER PIPE","ALTER PROCEDURE","ALTER REPLICATION GROUP","ALTER RESOURCE MONITOR","ALTER ROLE","ALTER ROW ACCESS POLICY","ALTER SCHEMA","ALTER SECURITY INTEGRATION","ALTER SEQUENCE","ALTER SESSION","ALTER SESSION POLICY","ALTER SHARE","ALTER STAGE","ALTER STORAGE INTEGRATION","ALTER STREAM","ALTER TAG","ALTER TASK","ALTER USER","ALTER VIEW","ALTER WAREHOUSE","BEGIN","CALL","COMMIT","COPY INTO","CREATE ACCOUNT","CREATE API INTEGRATION","CREATE CONNECTION","CREATE DATABASE","CREATE EXTERNAL FUNCTION","CREATE EXTERNAL TABLE","CREATE FAILOVER GROUP","CREATE FILE FORMAT","CREATE FUNCTION","CREATE INTEGRATION","CREATE MANAGED ACCOUNT","CREATE MASKING POLICY","CREATE MATERIALIZED VIEW","CREATE NETWORK POLICY","CREATE NOTIFICATION INTEGRATION","CREATE PIPE","CREATE PROCEDURE","CREATE REPLICATION GROUP","CREATE RESOURCE MONITOR","CREATE ROLE","CREATE ROW ACCESS POLICY","CREATE SCHEMA","CREATE SECURITY INTEGRATION","CREATE SEQUENCE","CREATE SESSION POLICY","CREATE SHARE","CREATE STAGE","CREATE STORAGE INTEGRATION","CREATE STREAM","CREATE TAG","CREATE TASK","CREATE USER","CREATE WAREHOUSE","DELETE","DESCRIBE DATABASE","DESCRIBE EXTERNAL TABLE","DESCRIBE FILE FORMAT","DESCRIBE FUNCTION","DESCRIBE INTEGRATION","DESCRIBE MASKING POLICY","DESCRIBE MATERIALIZED VIEW","DESCRIBE NETWORK POLICY","DESCRIBE PIPE","DESCRIBE PROCEDURE","DESCRIBE RESULT","DESCRIBE ROW ACCESS POLICY","DESCRIBE SCHEMA","DESCRIBE SEQUENCE","DESCRIBE SESSION POLICY","DESCRIBE SHARE","DESCRIBE STAGE","DESCRIBE STREAM","DESCRIBE TABLE","DESCRIBE TASK","DESCRIBE TRANSACTION","DESCRIBE USER","DESCRIBE VIEW","DESCRIBE WAREHOUSE","DROP CONNECTION","DROP DATABASE","DROP EXTERNAL TABLE","DROP FAILOVER GROUP","DROP FILE FORMAT","DROP FUNCTION","DROP INTEGRATION","DROP MANAGED ACCOUNT","DROP MASKING POLICY","DROP MATERIALIZED VIEW","DROP NETWORK POLICY","DROP PIPE","DROP PROCEDURE","DROP REPLICATION GROUP","DROP RESOURCE MONITOR","DROP ROLE","DROP ROW ACCESS POLICY","DROP SCHEMA","DROP SEQUENCE","DROP SESSION POLICY","DROP SHARE","DROP STAGE","DROP STREAM","DROP TAG","DROP TASK","DROP USER","DROP VIEW","DROP WAREHOUSE","EXECUTE IMMEDIATE","EXECUTE TASK","EXPLAIN","GET","GRANT OWNERSHIP","GRANT ROLE","INSERT","LIST","MERGE","PUT","REMOVE","REVOKE ROLE","ROLLBACK","SHOW COLUMNS","SHOW CONNECTIONS","SHOW DATABASES","SHOW DATABASES IN FAILOVER GROUP","SHOW DATABASES IN REPLICATION GROUP","SHOW DELEGATED AUTHORIZATIONS","SHOW EXTERNAL FUNCTIONS","SHOW EXTERNAL TABLES","SHOW FAILOVER GROUPS","SHOW FILE FORMATS","SHOW FUNCTIONS","SHOW GLOBAL ACCOUNTS","SHOW GRANTS","SHOW INTEGRATIONS","SHOW LOCKS","SHOW MANAGED ACCOUNTS","SHOW MASKING POLICIES","SHOW MATERIALIZED VIEWS","SHOW NETWORK POLICIES","SHOW OBJECTS","SHOW ORGANIZATION ACCOUNTS","SHOW PARAMETERS","SHOW PIPES","SHOW PRIMARY KEYS","SHOW PROCEDURES","SHOW REGIONS","SHOW REPLICATION ACCOUNTS","SHOW REPLICATION DATABASES","SHOW REPLICATION GROUPS","SHOW RESOURCE MONITORS","SHOW ROLES","SHOW ROW ACCESS POLICIES","SHOW SCHEMAS","SHOW SEQUENCES","SHOW SESSION POLICIES","SHOW SHARES","SHOW SHARES IN FAILOVER GROUP","SHOW SHARES IN REPLICATION GROUP","SHOW STAGES","SHOW STREAMS","SHOW TABLES","SHOW TAGS","SHOW TASKS","SHOW TRANSACTIONS","SHOW USER FUNCTIONS","SHOW USERS","SHOW VARIABLES","SHOW VIEWS","SHOW WAREHOUSES","TRUNCATE MATERIALIZED VIEW","UNDROP DATABASE","UNDROP SCHEMA","UNDROP TABLE","UNDROP TAG","UNSET","USE DATABASE","USE ROLE","USE SCHEMA","USE SECONDARY ROLES","USE WAREHOUSE"]),HL=Q(["UNION [ALL]","MINUS","EXCEPT","INTERSECT"]),FL=Q(["[INNER] JOIN","[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN","{CROSS | NATURAL} JOIN"]),YL=Q(["{ROWS | RANGE} BETWEEN","ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"]),jL=Q([]),VL={name:"snowflake",tokenizerOptions:{reservedSelect:GL,reservedClauses:[...BL,...ld,...cc],reservedSetOperations:HL,reservedJoins:FL,reservedKeywordPhrases:YL,reservedDataTypePhrases:jL,reservedKeywords:UL,reservedDataTypes:bL,reservedFunctionNames:PL,stringTypes:["$$","''-qq-bs"],identTypes:['""-qq'],variableTypes:[{regex:"[$][1-9]\\d*"},{regex:"[$][_a-zA-Z][_a-zA-Z0-9$]*"}],extraParens:["[]"],identChars:{rest:"$"},lineCommentTypes:["--","//"],operators:["%","::","||","=>",":=","->"],propertyAccessOperators:[":"]},formatOptions:{alwaysDenseOperators:["::"],onelineClauses:[...ld,...cc],tabularOnelineClauses:cc}},wL=Object.freeze(Object.defineProperty({__proto__:null,bigquery:of,clickhouse:ff,db2:Mf,db2i:Vf,duckdb:Qf,hive:oC,mariadb:NC,mysql:xC,n1ql:kC,plsql:rp,postgresql:Ap,redshift:_p,singlestoredb:ML,snowflake:VL,spark:bp,sql:nL,sqlite:Kp,tidb:HC,transactsql:CL,trino:SL},Symbol.toStringTag,{value:"Module"})),Yl=r=>r[r.length-1],Fd=r=>r.sort((l,E)=>E.length-l.length||l.localeCompare(E)),Io=r=>r.replace(/\s+/gu," "),Sc=r=>/\n/.test(r),ra=r=>r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),id=/\s+/uy,Xr=r=>new RegExp(`(?:${r})`,"uy"),WL=r=>r.split("").map(l=>/ /gu.test(l)?"\\s+":`[${l.toUpperCase()}${l.toLowerCase()}]`).join(""),XL=r=>r+"(?:-"+r+")*",KL=({prefixes:r,requirePrefix:l})=>`(?:${r.map(WL).join("|")}${l?"":"|"})`,zL=r=>new RegExp(`(?:${r.map(ra).join("|")}).*?(?=\r
|\r|
|$)`,"uy"),od=(r,l=[])=>{const E=r==="open"?0:1,T=["()",...l].map(c=>c[E]);return Xr(T.map(ra).join("|"))},Ed=r=>Xr(`${Fd(r).map(ra).join("|")}`),kL=({rest:r,dashes:l})=>r||l?`(?![${r||""}${l?"-":""}])`:"",Ua=(r,l={})=>{if(r.length===0)return/^\b$/u;const E=kL(l),T=Fd(r).map(ra).join("|").replace(/ /gu,"\\s+");return new RegExp(`(?:${T})${E}\\b`,"iuy")},Rc=(r,l)=>{if(!r.length)return;const E=r.map(ra).join("|");return Xr(`(?:${E})(?:${l})`)},$L=()=>{const r={"<":">","[":"]","(":")","{":"}"},l="{left}(?:(?!{right}').)*?{right}",E=Object.entries(r).map(([N,L])=>l.replace(/{left}/g,ra(N)).replace(/{right}/g,ra(L))),T=ra(Object.keys(r).join(""));return`[Qq]'(?:${String.raw`(?<tag>[^\s${T}])(?:(?!\k<tag>').)*?\k<tag>`}|${E.join("|")})'`},Td={"``":"(?:`[^`]*`)+","[]":String.raw`(?:\[[^\]]*\])(?:\][^\]]*\])*`,'""-qq':String.raw`(?:"[^"]*")+`,'""-bs':String.raw`(?:"[^"\\]*(?:\\.[^"\\]*)*")`,'""-qq-bs':String.raw`(?:"[^"\\]*(?:\\.[^"\\]*)*")+`,'""-raw':String.raw`(?:"[^"]*")`,"''-qq":String.raw`(?:'[^']*')+`,"''-bs":String.raw`(?:'[^'\\]*(?:\\.[^'\\]*)*')`,"''-qq-bs":String.raw`(?:'[^'\\]*(?:\\.[^'\\]*)*')+`,"''-raw":String.raw`(?:'[^']*')`,$$:String.raw`(?<tag>\$\w*\$)[\s\S]*?\k<tag>`,"'''..'''":String.raw`'''[^\\]*?(?:\\.[^\\]*?)*?'''`,'""".."""':String.raw`"""[^\\]*?(?:\\.[^\\]*?)*?"""`,"{}":String.raw`(?:\{[^\}]*\})`,"q''":$L()},Yd=r=>typeof r=="string"?Td[r]:"regex"in r?r.regex:KL(r)+Td[r.quote],JL=r=>Xr(r.map(l=>"regex"in l?l.regex:Yd(l)).join("|")),jd=r=>r.map(Yd).join("|"),cd=r=>Xr(jd(r)),qL=(r={})=>Xr(Vd(r)),Vd=({first:r,rest:l,dashes:E,allowFirstCharNumber:T}={})=>{const c="\\p{Alphabetic}\\p{Mark}_",u="\\p{Decimal_Number}",N=ra(r??""),L=ra(l??""),I=T?`[${c}${u}${N}][${c}${u}${L}]*`:`[${c}${N}][${c}${u}${L}]*`;return E?XL(I):I};function wd(r,l){const E=r.slice(0,l).split(/\n/);return{line:E.length,col:E[E.length-1].length+1}}class QL{constructor(l,E){this.rules=l,this.dialectName=E,this.input="",this.index=0}tokenize(l){this.input=l,this.index=0;const E=[];let T;for(;this.index<this.input.length;){const c=this.getWhitespace();if(this.index<this.input.length){if(T=this.getNextToken(),!T)throw this.createParseError();E.push(Object.assign(Object.assign({},T),{precedingWhitespace:c}))}}return E}createParseError(){const l=this.input.slice(this.index,this.index+10),{line:E,col:T}=wd(this.input,this.index);return new Error(`Parse error: Unexpected "${l}" at line ${E} column ${T}.
${this.dialectInfo()}`)}dialectInfo(){return this.dialectName==="sql"?`This likely happens because you're using the default "sql" dialect.
If possible, please select a more specific dialect (like sqlite, postgresql, etc).`:`SQL dialect used: "${this.dialectName}".`}getWhitespace(){id.lastIndex=this.index;const l=id.exec(this.input);if(l)return this.index+=l[0].length,l[0]}getNextToken(){for(const l of this.rules){const E=this.match(l);if(E)return E}}match(l){l.regex.lastIndex=this.index;const E=l.regex.exec(this.input);if(E){const T=E[0],c={type:l.type,raw:T,text:l.text?l.text(T):T,start:this.index};return l.key&&(c.key=l.key(T)),this.index+=T.length,c}}}const Sd=/\/\*/uy,ZL=/[\s\S]/uy,e_=/\*\//uy;class t_{constructor(){this.lastIndex=0}exec(l){let E="",T,c=0;if(T=this.matchSection(Sd,l))E+=T,c++;else return null;for(;c>0;)if(T=this.matchSection(Sd,l))E+=T,c++;else if(T=this.matchSection(e_,l))E+=T,c--;else if(T=this.matchSection(ZL,l))E+=T;else return null;return[E]}matchSection(l,E){l.lastIndex=this.lastIndex;const T=l.exec(E);return T&&(this.lastIndex+=T[0].length),T?T[0]:null}}class n_{constructor(l,E){this.cfg=l,this.dialectName=E,this.rulesBeforeParams=this.buildRulesBeforeParams(l),this.rulesAfterParams=this.buildRulesAfterParams(l)}tokenize(l,E){const T=[...this.rulesBeforeParams,...this.buildParamRules(this.cfg,E),...this.rulesAfterParams],c=new QL(T,this.dialectName).tokenize(l);return this.cfg.postProcess?this.cfg.postProcess(c):c}buildRulesBeforeParams(l){var E,T,c;return this.validRules([{type:Ae.DISABLE_COMMENT,regex:/(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy},{type:Ae.BLOCK_COMMENT,regex:l.nestedBlockComments?new t_:/(\/\*[^]*?\*\/)/uy},{type:Ae.LINE_COMMENT,regex:zL((E=l.lineCommentTypes)!==null&&E!==void 0?E:["--"])},{type:Ae.QUOTED_IDENTIFIER,regex:cd(l.identTypes)},{type:Ae.NUMBER,regex:l.underscoresInNumbers?/(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy:/(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy},{type:Ae.RESERVED_KEYWORD_PHRASE,regex:Ua((T=l.reservedKeywordPhrases)!==null&&T!==void 0?T:[],l.identChars),text:Jt},{type:Ae.RESERVED_DATA_TYPE_PHRASE,regex:Ua((c=l.reservedDataTypePhrases)!==null&&c!==void 0?c:[],l.identChars),text:Jt},{type:Ae.CASE,regex:/CASE\b/iuy,text:Jt},{type:Ae.END,regex:/END\b/iuy,text:Jt},{type:Ae.BETWEEN,regex:/BETWEEN\b/iuy,text:Jt},{type:Ae.LIMIT,regex:l.reservedClauses.includes("LIMIT")?/LIMIT\b/iuy:void 0,text:Jt},{type:Ae.RESERVED_CLAUSE,regex:Ua(l.reservedClauses,l.identChars),text:Jt},{type:Ae.RESERVED_SELECT,regex:Ua(l.reservedSelect,l.identChars),text:Jt},{type:Ae.RESERVED_SET_OPERATION,regex:Ua(l.reservedSetOperations,l.identChars),text:Jt},{type:Ae.WHEN,regex:/WHEN\b/iuy,text:Jt},{type:Ae.ELSE,regex:/ELSE\b/iuy,text:Jt},{type:Ae.THEN,regex:/THEN\b/iuy,text:Jt},{type:Ae.RESERVED_JOIN,regex:Ua(l.reservedJoins,l.identChars),text:Jt},{type:Ae.AND,regex:/AND\b/iuy,text:Jt},{type:Ae.OR,regex:/OR\b/iuy,text:Jt},{type:Ae.XOR,regex:l.supportsXor?/XOR\b/iuy:void 0,text:Jt},...l.operatorKeyword?[{type:Ae.OPERATOR,regex:/OPERATOR *\([^)]+\)/iuy}]:[],{type:Ae.RESERVED_FUNCTION_NAME,regex:Ua(l.reservedFunctionNames,l.identChars),text:Jt},{type:Ae.RESERVED_DATA_TYPE,regex:Ua(l.reservedDataTypes,l.identChars),text:Jt},{type:Ae.RESERVED_KEYWORD,regex:Ua(l.reservedKeywords,l.identChars),text:Jt}])}buildRulesAfterParams(l){var E,T;return this.validRules([{type:Ae.VARIABLE,regex:l.variableTypes?JL(l.variableTypes):void 0},{type:Ae.STRING,regex:cd(l.stringTypes)},{type:Ae.IDENTIFIER,regex:qL(l.identChars)},{type:Ae.DELIMITER,regex:/[;]/uy},{type:Ae.COMMA,regex:/[,]/y},{type:Ae.OPEN_PAREN,regex:od("open",l.extraParens)},{type:Ae.CLOSE_PAREN,regex:od("close",l.extraParens)},{type:Ae.OPERATOR,regex:Ed(["+","-","/",">","<","=","<>","<=",">=","!=",...(E=l.operators)!==null&&E!==void 0?E:[]])},{type:Ae.ASTERISK,regex:/[*]/uy},{type:Ae.PROPERTY_ACCESS_OPERATOR,regex:Ed([".",...(T=l.propertyAccessOperators)!==null&&T!==void 0?T:[]])}])}buildParamRules(l,E){var T,c,u,N,L;const I={named:(E==null?void 0:E.named)||((T=l.paramTypes)===null||T===void 0?void 0:T.named)||[],quoted:(E==null?void 0:E.quoted)||((c=l.paramTypes)===null||c===void 0?void 0:c.quoted)||[],numbered:(E==null?void 0:E.numbered)||((u=l.paramTypes)===null||u===void 0?void 0:u.numbered)||[],positional:typeof(E==null?void 0:E.positional)=="boolean"?E.positional:(N=l.paramTypes)===null||N===void 0?void 0:N.positional,custom:(E==null?void 0:E.custom)||((L=l.paramTypes)===null||L===void 0?void 0:L.custom)||[]};return this.validRules([{type:Ae.NAMED_PARAMETER,regex:Rc(I.named,Vd(l.paramChars||l.identChars)),key:R=>R.slice(1)},{type:Ae.QUOTED_PARAMETER,regex:Rc(I.quoted,jd(l.identTypes)),key:R=>(({tokenKey:O,quoteChar:d})=>O.replace(new RegExp(ra("\\"+d),"gu"),d))({tokenKey:R.slice(2,-1),quoteChar:R.slice(-1)})},{type:Ae.NUMBERED_PARAMETER,regex:Rc(I.numbered,"[0-9]+"),key:R=>R.slice(1)},{type:Ae.POSITIONAL_PARAMETER,regex:I.positional?/[?]/y:void 0},...I.custom.map(R=>{var O;return{type:Ae.CUSTOM_PARAMETER,regex:Xr(R.regex),key:(O=R.key)!==null&&O!==void 0?O:(d=>d)}})])}validRules(l){return l.filter(E=>!!E.regex)}}const Jt=r=>Io(r.toUpperCase()),Rd=new Map,a_=r=>{let l=Rd.get(r);return l||(l=r_(r),Rd.set(r,l)),l},r_=r=>({tokenizer:new n_(r.tokenizerOptions,r.name),formatOptions:s_(r.formatOptions)}),s_=r=>{var l;return{alwaysDenseOperators:r.alwaysDenseOperators||[],onelineClauses:Object.fromEntries(r.onelineClauses.map(E=>[E,!0])),tabularOnelineClauses:Object.fromEntries(((l=r.tabularOnelineClauses)!==null&&l!==void 0?l:r.onelineClauses).map(E=>[E,!0]))}};function l_(r){return r.indentStyle==="tabularLeft"||r.indentStyle==="tabularRight"?" ".repeat(10):r.useTabs?"	":" ".repeat(r.tabWidth)}function gs(r){return r.indentStyle==="tabularLeft"||r.indentStyle==="tabularRight"}class i_{constructor(l){this.params=l,this.index=0}get({key:l,text:E}){return this.params?l?this.params[l]:this.params[this.index++]:E}getPositionalParameterIndex(){return this.index}setPositionalParameterIndex(l){this.index=l}}var ho={exports:{}},o_=ho.exports,ud;function E_(){return ud||(ud=1,(function(r){(function(l,E){r.exports?r.exports=E():l.nearley=E()})(o_,function(){function l(R,O,d){return this.id=++l.highestId,this.name=R,this.symbols=O,this.postprocess=d,this}l.highestId=0,l.prototype.toString=function(R){var O=typeof R>"u"?this.symbols.map(I).join(" "):this.symbols.slice(0,R).map(I).join(" ")+" ● "+this.symbols.slice(R).map(I).join(" ");return this.name+" → "+O};function E(R,O,d,_){this.rule=R,this.dot=O,this.reference=d,this.data=[],this.wantedBy=_,this.isComplete=this.dot===R.symbols.length}E.prototype.toString=function(){return"{"+this.rule.toString(this.dot)+"}, from: "+(this.reference||0)},E.prototype.nextState=function(R){var O=new E(this.rule,this.dot+1,this.reference,this.wantedBy);return O.left=this,O.right=R,O.isComplete&&(O.data=O.build(),O.right=void 0),O},E.prototype.build=function(){var R=[],O=this;do R.push(O.right.data),O=O.left;while(O.left);return R.reverse(),R},E.prototype.finish=function(){this.rule.postprocess&&(this.data=this.rule.postprocess(this.data,this.reference,N.fail))};function T(R,O){this.grammar=R,this.index=O,this.states=[],this.wants={},this.scannable=[],this.completed={}}T.prototype.process=function(R){for(var O=this.states,d=this.wants,_=this.completed,C=0;C<O.length;C++){var f=O[C];if(f.isComplete){if(f.finish(),f.data!==N.fail){for(var m=f.wantedBy,j=m.length;j--;){var W=m[j];this.complete(W,f)}if(f.reference===this.index){var P=f.rule.name;(this.completed[P]=this.completed[P]||[]).push(f)}}}else{var P=f.rule.symbols[f.dot];if(typeof P!="string"){this.scannable.push(f);continue}if(d[P]){if(d[P].push(f),_.hasOwnProperty(P))for(var Z=_[P],j=0;j<Z.length;j++){var v=Z[j];this.complete(f,v)}}else d[P]=[f],this.predict(P)}}},T.prototype.predict=function(R){for(var O=this.grammar.byName[R]||[],d=0;d<O.length;d++){var _=O[d],C=this.wants[R],f=new E(_,0,this.index,C);this.states.push(f)}},T.prototype.complete=function(R,O){var d=R.nextState(O);this.states.push(d)};function c(R,O){this.rules=R,this.start=O||this.rules[0].name;var d=this.byName={};this.rules.forEach(function(_){d.hasOwnProperty(_.name)||(d[_.name]=[]),d[_.name].push(_)})}c.fromCompiled=function(_,O){var d=_.Lexer;_.ParserStart&&(O=_.ParserStart,_=_.ParserRules);var _=_.map(function(f){return new l(f.name,f.symbols,f.postprocess)}),C=new c(_,O);return C.lexer=d,C};function u(){this.reset("")}u.prototype.reset=function(R,O){this.buffer=R,this.index=0,this.line=O?O.line:1,this.lastLineBreak=O?-O.col:0},u.prototype.next=function(){if(this.index<this.buffer.length){var R=this.buffer[this.index++];return R===`
`&&(this.line+=1,this.lastLineBreak=this.index),{value:R}}},u.prototype.save=function(){return{line:this.line,col:this.index-this.lastLineBreak}},u.prototype.formatError=function(R,O){var d=this.buffer;if(typeof d=="string"){var _=d.split(`
`).slice(Math.max(0,this.line-5),this.line),C=d.indexOf(`
`,this.index);C===-1&&(C=d.length);var f=this.index-this.lastLineBreak,m=String(this.line).length;return O+=" at line "+this.line+" col "+f+`:

`,O+=_.map(function(W,P){return j(this.line-_.length+P+1,m)+" "+W},this).join(`
`),O+=`
`+j("",m+f)+`^
`,O}else return O+" at index "+(this.index-1);function j(W,P){var Z=String(W);return Array(P-Z.length+1).join(" ")+Z}};function N(R,O,d){if(R instanceof c)var _=R,d=O;else var _=c.fromCompiled(R,O);this.grammar=_,this.options={keepHistory:!1,lexer:_.lexer||new u};for(var C in d||{})this.options[C]=d[C];this.lexer=this.options.lexer,this.lexerState=void 0;var f=new T(_,0);this.table=[f],f.wants[_.start]=[],f.predict(_.start),f.process(),this.current=0}N.fail={},N.prototype.feed=function(R){var O=this.lexer;O.reset(R,this.lexerState);for(var d;;){try{if(d=O.next(),!d)break}catch(B){var m=new T(this.grammar,this.current+1);this.table.push(m);var _=new Error(this.reportLexerError(B));throw _.offset=this.current,_.token=B.token,_}var C=this.table[this.current];this.options.keepHistory||delete this.table[this.current-1];var f=this.current+1,m=new T(this.grammar,f);this.table.push(m);for(var j=d.text!==void 0?d.text:d.value,W=O.constructor===u?d.value:d,P=C.scannable,Z=P.length;Z--;){var v=P[Z],M=v.rule.symbols[v.dot];if(M.test?M.test(W):M.type?M.type===d.type:M.literal===j){var Te=v.nextState({data:W,token:d,isToken:!0,reference:f-1});m.states.push(Te)}}if(m.process(),m.states.length===0){var _=new Error(this.reportError(d));throw _.offset=this.current,_.token=d,_}this.options.keepHistory&&(C.lexerState=O.save()),this.current++}return C&&(this.lexerState=O.save()),this.results=this.finish(),this},N.prototype.reportLexerError=function(R){var O,d,_=R.token;return _?(O="input "+JSON.stringify(_.text[0])+" (lexer error)",d=this.lexer.formatError(_,"Syntax error")):(O="input (lexer error)",d=R.message),this.reportErrorCommon(d,O)},N.prototype.reportError=function(R){var O=(R.type?R.type+" token: ":"")+JSON.stringify(R.value!==void 0?R.value:R),d=this.lexer.formatError(R,"Syntax error");return this.reportErrorCommon(d,O)},N.prototype.reportErrorCommon=function(R,O){var d=[];d.push(R);var _=this.table.length-2,C=this.table[_],f=C.states.filter(function(j){var W=j.rule.symbols[j.dot];return W&&typeof W!="string"});if(f.length===0)d.push("Unexpected "+O+`. I did not expect any more input. Here is the state of my parse table:
`),this.displayStateStack(C.states,d);else{d.push("Unexpected "+O+`. Instead, I was expecting to see one of the following:
`);var m=f.map(function(j){return this.buildFirstStateStack(j,[])||[j]},this);m.forEach(function(j){var W=j[0],P=W.rule.symbols[W.dot],Z=this.getSymbolDisplay(P);d.push("A "+Z+" based on:"),this.displayStateStack(j,d)},this)}return d.push(""),d.join(`
`)},N.prototype.displayStateStack=function(R,O){for(var d,_=0,C=0;C<R.length;C++){var f=R[C],m=f.rule.toString(f.dot);m===d?_++:(_>0&&O.push("    ^ "+_+" more lines identical to this"),_=0,O.push("    "+m)),d=m}},N.prototype.getSymbolDisplay=function(R){return L(R)},N.prototype.buildFirstStateStack=function(R,O){if(O.indexOf(R)!==-1)return null;if(R.wantedBy.length===0)return[R];var d=R.wantedBy[0],_=[R].concat(O),C=this.buildFirstStateStack(d,_);return C===null?null:[R].concat(C)},N.prototype.save=function(){var R=this.table[this.current];return R.lexerState=this.lexerState,R},N.prototype.restore=function(R){var O=R.index;this.current=O,this.table[O]=R,this.table.splice(O+1),this.lexerState=R.lexerState,this.results=this.finish()},N.prototype.rewind=function(R){if(!this.options.keepHistory)throw new Error("set option `keepHistory` to enable rewinding");this.restore(this.table[R])},N.prototype.finish=function(){var R=[],O=this.grammar.start,d=this.table[this.table.length-1];return d.states.forEach(function(_){_.rule.name===O&&_.dot===_.rule.symbols.length&&_.reference===0&&_.data!==N.fail&&R.push(_)}),R.map(function(_){return _.data})};function L(R){var O=typeof R;if(O==="string")return R;if(O==="object"){if(R.literal)return JSON.stringify(R.literal);if(R instanceof RegExp)return"character matching "+R;if(R.type)return R.type+" token";if(R.test)return"token matching "+String(R.test);throw new Error("Unknown symbol type: "+R)}}function I(R){var O=typeof R;if(O==="string")return R;if(O==="object"){if(R.literal)return JSON.stringify(R.literal);if(R instanceof RegExp)return R.toString();if(R.type)return"%"+R.type;if(R.test)return"<"+String(R.test)+">";throw new Error("Unknown symbol type: "+R)}}return{Parser:N,Grammar:c,Rule:l}})})(ho)),ho.exports}var T_=E_();const c_=Lc(T_);function S_(r){return r.map(R_).map(u_).map(A_).map(d_).map(O_)}const R_=(r,l,E)=>{if(Hd(r.type)){const T=N_(E,l);if(T&&T.type===Ae.PROPERTY_ACCESS_OPERATOR)return Object.assign(Object.assign({},r),{type:Ae.IDENTIFIER,text:r.raw});const c=Ys(E,l);if(c&&c.type===Ae.PROPERTY_ACCESS_OPERATOR)return Object.assign(Object.assign({},r),{type:Ae.IDENTIFIER,text:r.raw})}return r},u_=(r,l,E)=>{if(r.type===Ae.RESERVED_FUNCTION_NAME){const T=Ys(E,l);if(!T||!Wd(T))return Object.assign(Object.assign({},r),{type:Ae.IDENTIFIER,text:r.raw})}return r},A_=(r,l,E)=>{if(r.type===Ae.RESERVED_DATA_TYPE){const T=Ys(E,l);if(T&&Wd(T))return Object.assign(Object.assign({},r),{type:Ae.RESERVED_PARAMETERIZED_DATA_TYPE})}return r},d_=(r,l,E)=>{if(r.type===Ae.IDENTIFIER){const T=Ys(E,l);if(T&&Xd(T))return Object.assign(Object.assign({},r),{type:Ae.ARRAY_IDENTIFIER})}return r},O_=(r,l,E)=>{if(r.type===Ae.RESERVED_DATA_TYPE){const T=Ys(E,l);if(T&&Xd(T))return Object.assign(Object.assign({},r),{type:Ae.ARRAY_KEYWORD})}return r},N_=(r,l)=>Ys(r,l,-1),Ys=(r,l,E=1)=>{let T=1;for(;r[l+T*E]&&I_(r[l+T*E]);)T++;return r[l+T*E]},Wd=r=>r.type===Ae.OPEN_PAREN&&r.text==="(",Xd=r=>r.type===Ae.OPEN_PAREN&&r.text==="[",I_=r=>r.type===Ae.BLOCK_COMMENT||r.type===Ae.LINE_COMMENT;class Kd{constructor(l){this.tokenize=l,this.index=0,this.tokens=[],this.input=""}reset(l,E){this.input=l,this.index=0,this.tokens=this.tokenize(l)}next(){return this.tokens[this.index++]}save(){}formatError(l){const{line:E,col:T}=wd(this.input,l.start);return`Parse error at token: ${l.text} at line ${E} column ${T}`}has(l){return l in Ae}}var be;(function(r){r.statement="statement",r.clause="clause",r.set_operation="set_operation",r.function_call="function_call",r.parameterized_data_type="parameterized_data_type",r.array_subscript="array_subscript",r.property_access="property_access",r.parenthesis="parenthesis",r.between_predicate="between_predicate",r.case_expression="case_expression",r.case_when="case_when",r.case_else="case_else",r.limit_clause="limit_clause",r.all_columns_asterisk="all_columns_asterisk",r.literal="literal",r.identifier="identifier",r.keyword="keyword",r.data_type="data_type",r.parameter="parameter",r.operator="operator",r.comma="comma",r.line_comment="line_comment",r.block_comment="block_comment",r.disable_comment="disable_comment"})(be=be||(be={}));function uc(r){return r[0]}const we=new Kd(r=>[]),Gr=([[r]])=>r,en=r=>({type:be.keyword,tokenType:r.type,text:r.text,raw:r.raw}),Ad=r=>({type:be.data_type,text:r.text,raw:r.raw}),nn=(r,{leading:l,trailing:E})=>(l!=null&&l.length&&(r=Object.assign(Object.assign({},r),{leadingComments:l})),E!=null&&E.length&&(r=Object.assign(Object.assign({},r),{trailingComments:E})),r),h_=(r,{leading:l,trailing:E})=>{if(l!=null&&l.length){const[T,...c]=r;r=[nn(T,{leading:l}),...c]}if(E!=null&&E.length){const T=r.slice(0,-1),c=r[r.length-1];r=[...T,nn(c,{trailing:E})]}return r},f_={Lexer:we,ParserRules:[{name:"main$ebnf$1",symbols:[]},{name:"main$ebnf$1",symbols:["main$ebnf$1","statement"],postprocess:r=>r[0].concat([r[1]])},{name:"main",symbols:["main$ebnf$1"],postprocess:([r])=>{const l=r[r.length-1];return l&&!l.hasSemicolon?l.children.length>0?r:r.slice(0,-1):r}},{name:"statement$subexpression$1",symbols:[we.has("DELIMITER")?{type:"DELIMITER"}:DELIMITER]},{name:"statement$subexpression$1",symbols:[we.has("EOF")?{type:"EOF"}:EOF]},{name:"statement",symbols:["expressions_or_clauses","statement$subexpression$1"],postprocess:([r,[l]])=>({type:be.statement,children:r,hasSemicolon:l.type===Ae.DELIMITER})},{name:"expressions_or_clauses$ebnf$1",symbols:[]},{name:"expressions_or_clauses$ebnf$1",symbols:["expressions_or_clauses$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"expressions_or_clauses$ebnf$2",symbols:[]},{name:"expressions_or_clauses$ebnf$2",symbols:["expressions_or_clauses$ebnf$2","clause"],postprocess:r=>r[0].concat([r[1]])},{name:"expressions_or_clauses",symbols:["expressions_or_clauses$ebnf$1","expressions_or_clauses$ebnf$2"],postprocess:([r,l])=>[...r,...l]},{name:"clause$subexpression$1",symbols:["limit_clause"]},{name:"clause$subexpression$1",symbols:["select_clause"]},{name:"clause$subexpression$1",symbols:["other_clause"]},{name:"clause$subexpression$1",symbols:["set_operation"]},{name:"clause",symbols:["clause$subexpression$1"],postprocess:Gr},{name:"limit_clause$ebnf$1$subexpression$1$ebnf$1",symbols:["free_form_sql"]},{name:"limit_clause$ebnf$1$subexpression$1$ebnf$1",symbols:["limit_clause$ebnf$1$subexpression$1$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"limit_clause$ebnf$1$subexpression$1",symbols:[we.has("COMMA")?{type:"COMMA"}:COMMA,"limit_clause$ebnf$1$subexpression$1$ebnf$1"]},{name:"limit_clause$ebnf$1",symbols:["limit_clause$ebnf$1$subexpression$1"],postprocess:uc},{name:"limit_clause$ebnf$1",symbols:[],postprocess:()=>null},{name:"limit_clause",symbols:[we.has("LIMIT")?{type:"LIMIT"}:LIMIT,"_","expression_chain_","limit_clause$ebnf$1"],postprocess:([r,l,E,T])=>{if(T){const[c,u]=T;return{type:be.limit_clause,limitKw:nn(en(r),{trailing:l}),offset:E,count:u}}else return{type:be.limit_clause,limitKw:nn(en(r),{trailing:l}),count:E}}},{name:"select_clause$subexpression$1$ebnf$1",symbols:[]},{name:"select_clause$subexpression$1$ebnf$1",symbols:["select_clause$subexpression$1$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"select_clause$subexpression$1",symbols:["all_columns_asterisk","select_clause$subexpression$1$ebnf$1"]},{name:"select_clause$subexpression$1$ebnf$2",symbols:[]},{name:"select_clause$subexpression$1$ebnf$2",symbols:["select_clause$subexpression$1$ebnf$2","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"select_clause$subexpression$1",symbols:["asteriskless_free_form_sql","select_clause$subexpression$1$ebnf$2"]},{name:"select_clause",symbols:[we.has("RESERVED_SELECT")?{type:"RESERVED_SELECT"}:RESERVED_SELECT,"select_clause$subexpression$1"],postprocess:([r,[l,E]])=>({type:be.clause,nameKw:en(r),children:[l,...E]})},{name:"select_clause",symbols:[we.has("RESERVED_SELECT")?{type:"RESERVED_SELECT"}:RESERVED_SELECT],postprocess:([r])=>({type:be.clause,nameKw:en(r),children:[]})},{name:"all_columns_asterisk",symbols:[we.has("ASTERISK")?{type:"ASTERISK"}:ASTERISK],postprocess:()=>({type:be.all_columns_asterisk})},{name:"other_clause$ebnf$1",symbols:[]},{name:"other_clause$ebnf$1",symbols:["other_clause$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"other_clause",symbols:[we.has("RESERVED_CLAUSE")?{type:"RESERVED_CLAUSE"}:RESERVED_CLAUSE,"other_clause$ebnf$1"],postprocess:([r,l])=>({type:be.clause,nameKw:en(r),children:l})},{name:"set_operation$ebnf$1",symbols:[]},{name:"set_operation$ebnf$1",symbols:["set_operation$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"set_operation",symbols:[we.has("RESERVED_SET_OPERATION")?{type:"RESERVED_SET_OPERATION"}:RESERVED_SET_OPERATION,"set_operation$ebnf$1"],postprocess:([r,l])=>({type:be.set_operation,nameKw:en(r),children:l})},{name:"expression_chain_$ebnf$1",symbols:["expression_with_comments_"]},{name:"expression_chain_$ebnf$1",symbols:["expression_chain_$ebnf$1","expression_with_comments_"],postprocess:r=>r[0].concat([r[1]])},{name:"expression_chain_",symbols:["expression_chain_$ebnf$1"],postprocess:uc},{name:"expression_chain$ebnf$1",symbols:[]},{name:"expression_chain$ebnf$1",symbols:["expression_chain$ebnf$1","_expression_with_comments"],postprocess:r=>r[0].concat([r[1]])},{name:"expression_chain",symbols:["expression","expression_chain$ebnf$1"],postprocess:([r,l])=>[r,...l]},{name:"andless_expression_chain$ebnf$1",symbols:[]},{name:"andless_expression_chain$ebnf$1",symbols:["andless_expression_chain$ebnf$1","_andless_expression_with_comments"],postprocess:r=>r[0].concat([r[1]])},{name:"andless_expression_chain",symbols:["andless_expression","andless_expression_chain$ebnf$1"],postprocess:([r,l])=>[r,...l]},{name:"expression_with_comments_",symbols:["expression","_"],postprocess:([r,l])=>nn(r,{trailing:l})},{name:"_expression_with_comments",symbols:["_","expression"],postprocess:([r,l])=>nn(l,{leading:r})},{name:"_andless_expression_with_comments",symbols:["_","andless_expression"],postprocess:([r,l])=>nn(l,{leading:r})},{name:"free_form_sql$subexpression$1",symbols:["asteriskless_free_form_sql"]},{name:"free_form_sql$subexpression$1",symbols:["asterisk"]},{name:"free_form_sql",symbols:["free_form_sql$subexpression$1"],postprocess:Gr},{name:"asteriskless_free_form_sql$subexpression$1",symbols:["asteriskless_andless_expression"]},{name:"asteriskless_free_form_sql$subexpression$1",symbols:["logic_operator"]},{name:"asteriskless_free_form_sql$subexpression$1",symbols:["comma"]},{name:"asteriskless_free_form_sql$subexpression$1",symbols:["comment"]},{name:"asteriskless_free_form_sql$subexpression$1",symbols:["other_keyword"]},{name:"asteriskless_free_form_sql",symbols:["asteriskless_free_form_sql$subexpression$1"],postprocess:Gr},{name:"expression$subexpression$1",symbols:["andless_expression"]},{name:"expression$subexpression$1",symbols:["logic_operator"]},{name:"expression",symbols:["expression$subexpression$1"],postprocess:Gr},{name:"andless_expression$subexpression$1",symbols:["asteriskless_andless_expression"]},{name:"andless_expression$subexpression$1",symbols:["asterisk"]},{name:"andless_expression",symbols:["andless_expression$subexpression$1"],postprocess:Gr},{name:"asteriskless_andless_expression$subexpression$1",symbols:["atomic_expression"]},{name:"asteriskless_andless_expression$subexpression$1",symbols:["between_predicate"]},{name:"asteriskless_andless_expression$subexpression$1",symbols:["case_expression"]},{name:"asteriskless_andless_expression",symbols:["asteriskless_andless_expression$subexpression$1"],postprocess:Gr},{name:"atomic_expression$subexpression$1",symbols:["array_subscript"]},{name:"atomic_expression$subexpression$1",symbols:["function_call"]},{name:"atomic_expression$subexpression$1",symbols:["property_access"]},{name:"atomic_expression$subexpression$1",symbols:["parenthesis"]},{name:"atomic_expression$subexpression$1",symbols:["curly_braces"]},{name:"atomic_expression$subexpression$1",symbols:["square_brackets"]},{name:"atomic_expression$subexpression$1",symbols:["operator"]},{name:"atomic_expression$subexpression$1",symbols:["identifier"]},{name:"atomic_expression$subexpression$1",symbols:["parameter"]},{name:"atomic_expression$subexpression$1",symbols:["literal"]},{name:"atomic_expression$subexpression$1",symbols:["data_type"]},{name:"atomic_expression$subexpression$1",symbols:["keyword"]},{name:"atomic_expression",symbols:["atomic_expression$subexpression$1"],postprocess:Gr},{name:"array_subscript",symbols:[we.has("ARRAY_IDENTIFIER")?{type:"ARRAY_IDENTIFIER"}:ARRAY_IDENTIFIER,"_","square_brackets"],postprocess:([r,l,E])=>({type:be.array_subscript,array:nn({type:be.identifier,quoted:!1,text:r.text},{trailing:l}),parenthesis:E})},{name:"array_subscript",symbols:[we.has("ARRAY_KEYWORD")?{type:"ARRAY_KEYWORD"}:ARRAY_KEYWORD,"_","square_brackets"],postprocess:([r,l,E])=>({type:be.array_subscript,array:nn(en(r),{trailing:l}),parenthesis:E})},{name:"function_call",symbols:[we.has("RESERVED_FUNCTION_NAME")?{type:"RESERVED_FUNCTION_NAME"}:RESERVED_FUNCTION_NAME,"_","parenthesis"],postprocess:([r,l,E])=>({type:be.function_call,nameKw:nn(en(r),{trailing:l}),parenthesis:E})},{name:"parenthesis",symbols:[{literal:"("},"expressions_or_clauses",{literal:")"}],postprocess:([r,l,E])=>({type:be.parenthesis,children:l,openParen:"(",closeParen:")"})},{name:"curly_braces$ebnf$1",symbols:[]},{name:"curly_braces$ebnf$1",symbols:["curly_braces$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"curly_braces",symbols:[{literal:"{"},"curly_braces$ebnf$1",{literal:"}"}],postprocess:([r,l,E])=>({type:be.parenthesis,children:l,openParen:"{",closeParen:"}"})},{name:"square_brackets$ebnf$1",symbols:[]},{name:"square_brackets$ebnf$1",symbols:["square_brackets$ebnf$1","free_form_sql"],postprocess:r=>r[0].concat([r[1]])},{name:"square_brackets",symbols:[{literal:"["},"square_brackets$ebnf$1",{literal:"]"}],postprocess:([r,l,E])=>({type:be.parenthesis,children:l,openParen:"[",closeParen:"]"})},{name:"property_access$subexpression$1",symbols:["identifier"]},{name:"property_access$subexpression$1",symbols:["array_subscript"]},{name:"property_access$subexpression$1",symbols:["all_columns_asterisk"]},{name:"property_access$subexpression$1",symbols:["parameter"]},{name:"property_access",symbols:["atomic_expression","_",we.has("PROPERTY_ACCESS_OPERATOR")?{type:"PROPERTY_ACCESS_OPERATOR"}:PROPERTY_ACCESS_OPERATOR,"_","property_access$subexpression$1"],postprocess:([r,l,E,T,[c]])=>({type:be.property_access,object:nn(r,{trailing:l}),operator:E.text,property:nn(c,{leading:T})})},{name:"between_predicate",symbols:[we.has("BETWEEN")?{type:"BETWEEN"}:BETWEEN,"_","andless_expression_chain","_",we.has("AND")?{type:"AND"}:AND,"_","andless_expression"],postprocess:([r,l,E,T,c,u,N])=>({type:be.between_predicate,betweenKw:en(r),expr1:h_(E,{leading:l,trailing:T}),andKw:en(c),expr2:[nn(N,{leading:u})]})},{name:"case_expression$ebnf$1",symbols:["expression_chain_"],postprocess:uc},{name:"case_expression$ebnf$1",symbols:[],postprocess:()=>null},{name:"case_expression$ebnf$2",symbols:[]},{name:"case_expression$ebnf$2",symbols:["case_expression$ebnf$2","case_clause"],postprocess:r=>r[0].concat([r[1]])},{name:"case_expression",symbols:[we.has("CASE")?{type:"CASE"}:CASE,"_","case_expression$ebnf$1","case_expression$ebnf$2",we.has("END")?{type:"END"}:END],postprocess:([r,l,E,T,c])=>({type:be.case_expression,caseKw:nn(en(r),{trailing:l}),endKw:en(c),expr:E||[],clauses:T})},{name:"case_clause",symbols:[we.has("WHEN")?{type:"WHEN"}:WHEN,"_","expression_chain_",we.has("THEN")?{type:"THEN"}:THEN,"_","expression_chain_"],postprocess:([r,l,E,T,c,u])=>({type:be.case_when,whenKw:nn(en(r),{trailing:l}),thenKw:nn(en(T),{trailing:c}),condition:E,result:u})},{name:"case_clause",symbols:[we.has("ELSE")?{type:"ELSE"}:ELSE,"_","expression_chain_"],postprocess:([r,l,E])=>({type:be.case_else,elseKw:nn(en(r),{trailing:l}),result:E})},{name:"comma$subexpression$1",symbols:[we.has("COMMA")?{type:"COMMA"}:COMMA]},{name:"comma",symbols:["comma$subexpression$1"],postprocess:([[r]])=>({type:be.comma})},{name:"asterisk$subexpression$1",symbols:[we.has("ASTERISK")?{type:"ASTERISK"}:ASTERISK]},{name:"asterisk",symbols:["asterisk$subexpression$1"],postprocess:([[r]])=>({type:be.operator,text:r.text})},{name:"operator$subexpression$1",symbols:[we.has("OPERATOR")?{type:"OPERATOR"}:OPERATOR]},{name:"operator",symbols:["operator$subexpression$1"],postprocess:([[r]])=>({type:be.operator,text:r.text})},{name:"identifier$subexpression$1",symbols:[we.has("IDENTIFIER")?{type:"IDENTIFIER"}:IDENTIFIER]},{name:"identifier$subexpression$1",symbols:[we.has("QUOTED_IDENTIFIER")?{type:"QUOTED_IDENTIFIER"}:QUOTED_IDENTIFIER]},{name:"identifier$subexpression$1",symbols:[we.has("VARIABLE")?{type:"VARIABLE"}:VARIABLE]},{name:"identifier",symbols:["identifier$subexpression$1"],postprocess:([[r]])=>({type:be.identifier,quoted:r.type!=="IDENTIFIER",text:r.text})},{name:"parameter$subexpression$1",symbols:[we.has("NAMED_PARAMETER")?{type:"NAMED_PARAMETER"}:NAMED_PARAMETER]},{name:"parameter$subexpression$1",symbols:[we.has("QUOTED_PARAMETER")?{type:"QUOTED_PARAMETER"}:QUOTED_PARAMETER]},{name:"parameter$subexpression$1",symbols:[we.has("NUMBERED_PARAMETER")?{type:"NUMBERED_PARAMETER"}:NUMBERED_PARAMETER]},{name:"parameter$subexpression$1",symbols:[we.has("POSITIONAL_PARAMETER")?{type:"POSITIONAL_PARAMETER"}:POSITIONAL_PARAMETER]},{name:"parameter$subexpression$1",symbols:[we.has("CUSTOM_PARAMETER")?{type:"CUSTOM_PARAMETER"}:CUSTOM_PARAMETER]},{name:"parameter",symbols:["parameter$subexpression$1"],postprocess:([[r]])=>({type:be.parameter,key:r.key,text:r.text})},{name:"literal$subexpression$1",symbols:[we.has("NUMBER")?{type:"NUMBER"}:NUMBER]},{name:"literal$subexpression$1",symbols:[we.has("STRING")?{type:"STRING"}:STRING]},{name:"literal",symbols:["literal$subexpression$1"],postprocess:([[r]])=>({type:be.literal,text:r.text})},{name:"keyword$subexpression$1",symbols:[we.has("RESERVED_KEYWORD")?{type:"RESERVED_KEYWORD"}:RESERVED_KEYWORD]},{name:"keyword$subexpression$1",symbols:[we.has("RESERVED_KEYWORD_PHRASE")?{type:"RESERVED_KEYWORD_PHRASE"}:RESERVED_KEYWORD_PHRASE]},{name:"keyword$subexpression$1",symbols:[we.has("RESERVED_JOIN")?{type:"RESERVED_JOIN"}:RESERVED_JOIN]},{name:"keyword",symbols:["keyword$subexpression$1"],postprocess:([[r]])=>en(r)},{name:"data_type$subexpression$1",symbols:[we.has("RESERVED_DATA_TYPE")?{type:"RESERVED_DATA_TYPE"}:RESERVED_DATA_TYPE]},{name:"data_type$subexpression$1",symbols:[we.has("RESERVED_DATA_TYPE_PHRASE")?{type:"RESERVED_DATA_TYPE_PHRASE"}:RESERVED_DATA_TYPE_PHRASE]},{name:"data_type",symbols:["data_type$subexpression$1"],postprocess:([[r]])=>Ad(r)},{name:"data_type",symbols:[we.has("RESERVED_PARAMETERIZED_DATA_TYPE")?{type:"RESERVED_PARAMETERIZED_DATA_TYPE"}:RESERVED_PARAMETERIZED_DATA_TYPE,"_","parenthesis"],postprocess:([r,l,E])=>({type:be.parameterized_data_type,dataType:nn(Ad(r),{trailing:l}),parenthesis:E})},{name:"logic_operator$subexpression$1",symbols:[we.has("AND")?{type:"AND"}:AND]},{name:"logic_operator$subexpression$1",symbols:[we.has("OR")?{type:"OR"}:OR]},{name:"logic_operator$subexpression$1",symbols:[we.has("XOR")?{type:"XOR"}:XOR]},{name:"logic_operator",symbols:["logic_operator$subexpression$1"],postprocess:([[r]])=>en(r)},{name:"other_keyword$subexpression$1",symbols:[we.has("WHEN")?{type:"WHEN"}:WHEN]},{name:"other_keyword$subexpression$1",symbols:[we.has("THEN")?{type:"THEN"}:THEN]},{name:"other_keyword$subexpression$1",symbols:[we.has("ELSE")?{type:"ELSE"}:ELSE]},{name:"other_keyword$subexpression$1",symbols:[we.has("END")?{type:"END"}:END]},{name:"other_keyword",symbols:["other_keyword$subexpression$1"],postprocess:([[r]])=>en(r)},{name:"_$ebnf$1",symbols:[]},{name:"_$ebnf$1",symbols:["_$ebnf$1","comment"],postprocess:r=>r[0].concat([r[1]])},{name:"_",symbols:["_$ebnf$1"],postprocess:([r])=>r},{name:"comment",symbols:[we.has("LINE_COMMENT")?{type:"LINE_COMMENT"}:LINE_COMMENT],postprocess:([r])=>({type:be.line_comment,text:r.text,precedingWhitespace:r.precedingWhitespace})},{name:"comment",symbols:[we.has("BLOCK_COMMENT")?{type:"BLOCK_COMMENT"}:BLOCK_COMMENT],postprocess:([r])=>({type:be.block_comment,text:r.text,precedingWhitespace:r.precedingWhitespace})},{name:"comment",symbols:[we.has("DISABLE_COMMENT")?{type:"DISABLE_COMMENT"}:DISABLE_COMMENT],postprocess:([r])=>({type:be.disable_comment,text:r.text,precedingWhitespace:r.precedingWhitespace})}],ParserStart:"main"},{Parser:C_,Grammar:p_}=c_;function L_(r){let l={};const E=new Kd(c=>[...S_(r.tokenize(c,l)),Bd(c.length)]),T=new C_(p_.fromCompiled(f_),{lexer:E});return{parse:(c,u)=>{l=u;const{results:N}=T.feed(c);if(N.length===1)return N[0];throw N.length===0?new Error("Parse error: Invalid SQL"):new Error(`Parse error: Ambiguous grammar
${JSON.stringify(N,void 0,2)}`)}}}var Se;(function(r){r[r.SPACE=0]="SPACE",r[r.NO_SPACE=1]="NO_SPACE",r[r.NO_NEWLINE=2]="NO_NEWLINE",r[r.NEWLINE=3]="NEWLINE",r[r.MANDATORY_NEWLINE=4]="MANDATORY_NEWLINE",r[r.INDENT=5]="INDENT",r[r.SINGLE_INDENT=6]="SINGLE_INDENT"})(Se=Se||(Se={}));class zd{constructor(l){this.indentation=l,this.items=[]}add(...l){for(const E of l)switch(E){case Se.SPACE:this.items.push(Se.SPACE);break;case Se.NO_SPACE:this.trimHorizontalWhitespace();break;case Se.NO_NEWLINE:this.trimWhitespace();break;case Se.NEWLINE:this.trimHorizontalWhitespace(),this.addNewline(Se.NEWLINE);break;case Se.MANDATORY_NEWLINE:this.trimHorizontalWhitespace(),this.addNewline(Se.MANDATORY_NEWLINE);break;case Se.INDENT:this.addIndentation();break;case Se.SINGLE_INDENT:this.items.push(Se.SINGLE_INDENT);break;default:this.items.push(E)}}trimHorizontalWhitespace(){for(;__(Yl(this.items));)this.items.pop()}trimWhitespace(){for(;m_(Yl(this.items));)this.items.pop()}addNewline(l){if(this.items.length>0)switch(Yl(this.items)){case Se.NEWLINE:this.items.pop(),this.items.push(l);break;case Se.MANDATORY_NEWLINE:break;default:this.items.push(l);break}}addIndentation(){for(let l=0;l<this.indentation.getLevel();l++)this.items.push(Se.SINGLE_INDENT)}toString(){return this.items.map(l=>this.itemToString(l)).join("")}getLayoutItems(){return this.items}itemToString(l){switch(l){case Se.SPACE:return" ";case Se.NEWLINE:case Se.MANDATORY_NEWLINE:return`
`;case Se.SINGLE_INDENT:return this.indentation.getSingleIndent();default:return l}}}const __=r=>r===Se.SPACE||r===Se.SINGLE_INDENT,m_=r=>r===Se.SPACE||r===Se.SINGLE_INDENT||r===Se.NEWLINE;function dd(r,l){if(l==="standard")return r;let E=[];return r.length>=10&&r.includes(" ")&&([r,...E]=r.split(" ")),l==="tabularLeft"?r=r.padEnd(9," "):r=r.padStart(9," "),r+["",...E].join(" ")}function Od(r){return qh(r)||r===Ae.RESERVED_CLAUSE||r===Ae.RESERVED_SELECT||r===Ae.RESERVED_SET_OPERATION||r===Ae.RESERVED_JOIN||r===Ae.LIMIT}const Ac="top-level",v_="block-level";class kd{constructor(l){this.indent=l,this.indentTypes=[]}getSingleIndent(){return this.indent}getLevel(){return this.indentTypes.length}increaseTopLevel(){this.indentTypes.push(Ac)}increaseBlockLevel(){this.indentTypes.push(v_)}decreaseTopLevel(){this.indentTypes.length>0&&Yl(this.indentTypes)===Ac&&this.indentTypes.pop()}decreaseBlockLevel(){for(;this.indentTypes.length>0&&this.indentTypes.pop()===Ac;);}}class x_ extends zd{constructor(l){super(new kd("")),this.expressionWidth=l,this.length=0,this.trailingSpace=!1}add(...l){if(l.forEach(E=>this.addToLength(E)),this.length>this.expressionWidth)throw new fc;super.add(...l)}addToLength(l){if(typeof l=="string")this.length+=l.length,this.trailingSpace=!1;else{if(l===Se.MANDATORY_NEWLINE||l===Se.NEWLINE)throw new fc;l===Se.INDENT||l===Se.SINGLE_INDENT||l===Se.SPACE?this.trailingSpace||(this.length++,this.trailingSpace=!0):(l===Se.NO_NEWLINE||l===Se.NO_SPACE)&&this.trailingSpace&&(this.trailingSpace=!1,this.length--)}}}class fc extends Error{}class po{constructor({cfg:l,dialectCfg:E,params:T,layout:c,inline:u=!1}){this.inline=!1,this.nodes=[],this.index=-1,this.cfg=l,this.dialectCfg=E,this.inline=u,this.params=T,this.layout=c}format(l){for(this.nodes=l,this.index=0;this.index<this.nodes.length;this.index++)this.formatNode(this.nodes[this.index]);return this.layout}formatNode(l){this.formatComments(l.leadingComments),this.formatNodeWithoutComments(l),this.formatComments(l.trailingComments)}formatNodeWithoutComments(l){switch(l.type){case be.function_call:return this.formatFunctionCall(l);case be.parameterized_data_type:return this.formatParameterizedDataType(l);case be.array_subscript:return this.formatArraySubscript(l);case be.property_access:return this.formatPropertyAccess(l);case be.parenthesis:return this.formatParenthesis(l);case be.between_predicate:return this.formatBetweenPredicate(l);case be.case_expression:return this.formatCaseExpression(l);case be.case_when:return this.formatCaseWhen(l);case be.case_else:return this.formatCaseElse(l);case be.clause:return this.formatClause(l);case be.set_operation:return this.formatSetOperation(l);case be.limit_clause:return this.formatLimitClause(l);case be.all_columns_asterisk:return this.formatAllColumnsAsterisk(l);case be.literal:return this.formatLiteral(l);case be.identifier:return this.formatIdentifier(l);case be.parameter:return this.formatParameter(l);case be.operator:return this.formatOperator(l);case be.comma:return this.formatComma(l);case be.line_comment:return this.formatLineComment(l);case be.block_comment:return this.formatBlockComment(l);case be.disable_comment:return this.formatBlockComment(l);case be.data_type:return this.formatDataType(l);case be.keyword:return this.formatKeywordNode(l)}}formatFunctionCall(l){this.withComments(l.nameKw,()=>{this.layout.add(this.showFunctionKw(l.nameKw))}),this.formatNode(l.parenthesis)}formatParameterizedDataType(l){this.withComments(l.dataType,()=>{this.layout.add(this.showDataType(l.dataType))}),this.formatNode(l.parenthesis)}formatArraySubscript(l){let E;switch(l.array.type){case be.data_type:E=this.showDataType(l.array);break;case be.keyword:E=this.showKw(l.array);break;default:E=this.showIdentifier(l.array);break}this.withComments(l.array,()=>{this.layout.add(E)}),this.formatNode(l.parenthesis)}formatPropertyAccess(l){this.formatNode(l.object),this.layout.add(Se.NO_SPACE,l.operator),this.formatNode(l.property)}formatParenthesis(l){const E=this.formatInlineExpression(l.children);E?(this.layout.add(l.openParen),this.layout.add(...E.getLayoutItems()),this.layout.add(Se.NO_SPACE,l.closeParen,Se.SPACE)):(this.layout.add(l.openParen,Se.NEWLINE),gs(this.cfg)?(this.layout.add(Se.INDENT),this.layout=this.formatSubExpression(l.children)):(this.layout.indentation.increaseBlockLevel(),this.layout.add(Se.INDENT),this.layout=this.formatSubExpression(l.children),this.layout.indentation.decreaseBlockLevel()),this.layout.add(Se.NEWLINE,Se.INDENT,l.closeParen,Se.SPACE))}formatBetweenPredicate(l){this.layout.add(this.showKw(l.betweenKw),Se.SPACE),this.layout=this.formatSubExpression(l.expr1),this.layout.add(Se.NO_SPACE,Se.SPACE,this.showNonTabularKw(l.andKw),Se.SPACE),this.layout=this.formatSubExpression(l.expr2),this.layout.add(Se.SPACE)}formatCaseExpression(l){this.formatNode(l.caseKw),this.layout.indentation.increaseBlockLevel(),this.layout=this.formatSubExpression(l.expr),this.layout=this.formatSubExpression(l.clauses),this.layout.indentation.decreaseBlockLevel(),this.layout.add(Se.NEWLINE,Se.INDENT),this.formatNode(l.endKw)}formatCaseWhen(l){this.layout.add(Se.NEWLINE,Se.INDENT),this.formatNode(l.whenKw),this.layout=this.formatSubExpression(l.condition),this.formatNode(l.thenKw),this.layout=this.formatSubExpression(l.result)}formatCaseElse(l){this.layout.add(Se.NEWLINE,Se.INDENT),this.formatNode(l.elseKw),this.layout=this.formatSubExpression(l.result)}formatClause(l){this.isOnelineClause(l)?this.formatClauseInOnelineStyle(l):gs(this.cfg)?this.formatClauseInTabularStyle(l):this.formatClauseInIndentedStyle(l)}isOnelineClause(l){return gs(this.cfg)?this.dialectCfg.tabularOnelineClauses[l.nameKw.text]:this.dialectCfg.onelineClauses[l.nameKw.text]}formatClauseInIndentedStyle(l){this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l.nameKw),Se.NEWLINE),this.layout.indentation.increaseTopLevel(),this.layout.add(Se.INDENT),this.layout=this.formatSubExpression(l.children),this.layout.indentation.decreaseTopLevel()}formatClauseInOnelineStyle(l){this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l.nameKw),Se.SPACE),this.layout=this.formatSubExpression(l.children)}formatClauseInTabularStyle(l){this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l.nameKw),Se.SPACE),this.layout.indentation.increaseTopLevel(),this.layout=this.formatSubExpression(l.children),this.layout.indentation.decreaseTopLevel()}formatSetOperation(l){this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l.nameKw),Se.NEWLINE),this.layout.add(Se.INDENT),this.layout=this.formatSubExpression(l.children)}formatLimitClause(l){this.withComments(l.limitKw,()=>{this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l.limitKw))}),this.layout.indentation.increaseTopLevel(),gs(this.cfg)?this.layout.add(Se.SPACE):this.layout.add(Se.NEWLINE,Se.INDENT),l.offset?(this.layout=this.formatSubExpression(l.offset),this.layout.add(Se.NO_SPACE,",",Se.SPACE),this.layout=this.formatSubExpression(l.count)):this.layout=this.formatSubExpression(l.count),this.layout.indentation.decreaseTopLevel()}formatAllColumnsAsterisk(l){this.layout.add("*",Se.SPACE)}formatLiteral(l){this.layout.add(l.text,Se.SPACE)}formatIdentifier(l){this.layout.add(this.showIdentifier(l),Se.SPACE)}formatParameter(l){this.layout.add(this.params.get(l),Se.SPACE)}formatOperator({text:l}){this.cfg.denseOperators||this.dialectCfg.alwaysDenseOperators.includes(l)?this.layout.add(Se.NO_SPACE,l):l===":"?this.layout.add(Se.NO_SPACE,l,Se.SPACE):this.layout.add(l,Se.SPACE)}formatComma(l){this.inline?this.layout.add(Se.NO_SPACE,",",Se.SPACE):this.layout.add(Se.NO_SPACE,",",Se.NEWLINE,Se.INDENT)}withComments(l,E){this.formatComments(l.leadingComments),E(),this.formatComments(l.trailingComments)}formatComments(l){l&&l.forEach(E=>{E.type===be.line_comment?this.formatLineComment(E):this.formatBlockComment(E)})}formatLineComment(l){Sc(l.precedingWhitespace||"")?this.layout.add(Se.NEWLINE,Se.INDENT,l.text,Se.MANDATORY_NEWLINE,Se.INDENT):this.layout.getLayoutItems().length>0?this.layout.add(Se.NO_NEWLINE,Se.SPACE,l.text,Se.MANDATORY_NEWLINE,Se.INDENT):this.layout.add(l.text,Se.MANDATORY_NEWLINE,Se.INDENT)}formatBlockComment(l){l.type===be.block_comment&&this.isMultilineBlockComment(l)?(this.splitBlockComment(l.text).forEach(E=>{this.layout.add(Se.NEWLINE,Se.INDENT,E)}),this.layout.add(Se.NEWLINE,Se.INDENT)):this.layout.add(l.text,Se.SPACE)}isMultilineBlockComment(l){return Sc(l.text)||Sc(l.precedingWhitespace||"")}isDocComment(l){const E=l.split(/\n/);return/^\/\*\*?$/.test(E[0])&&E.slice(1,E.length-1).every(T=>/^\s*\*/.test(T))&&/^\s*\*\/$/.test(Yl(E))}splitBlockComment(l){return this.isDocComment(l)?l.split(/\n/).map(E=>/^\s*\*/.test(E)?" "+E.replace(/^\s*/,""):E):l.split(/\n/).map(E=>E.replace(/^\s*/,""))}formatSubExpression(l){return new po({cfg:this.cfg,dialectCfg:this.dialectCfg,params:this.params,layout:this.layout,inline:this.inline}).format(l)}formatInlineExpression(l){const E=this.params.getPositionalParameterIndex();try{return new po({cfg:this.cfg,dialectCfg:this.dialectCfg,params:this.params,layout:new x_(this.cfg.expressionWidth),inline:!0}).format(l)}catch(T){if(T instanceof fc){this.params.setPositionalParameterIndex(E);return}else throw T}}formatKeywordNode(l){switch(l.tokenType){case Ae.RESERVED_JOIN:return this.formatJoin(l);case Ae.AND:case Ae.OR:case Ae.XOR:return this.formatLogicalOperator(l);default:return this.formatKeyword(l)}}formatJoin(l){gs(this.cfg)?(this.layout.indentation.decreaseTopLevel(),this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l),Se.SPACE),this.layout.indentation.increaseTopLevel()):this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l),Se.SPACE)}formatKeyword(l){this.layout.add(this.showKw(l),Se.SPACE)}formatLogicalOperator(l){this.cfg.logicalOperatorNewline==="before"?gs(this.cfg)?(this.layout.indentation.decreaseTopLevel(),this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l),Se.SPACE),this.layout.indentation.increaseTopLevel()):this.layout.add(Se.NEWLINE,Se.INDENT,this.showKw(l),Se.SPACE):this.layout.add(this.showKw(l),Se.NEWLINE,Se.INDENT)}formatDataType(l){this.layout.add(this.showDataType(l),Se.SPACE)}showKw(l){return Od(l.tokenType)?dd(this.showNonTabularKw(l),this.cfg.indentStyle):this.showNonTabularKw(l)}showNonTabularKw(l){switch(this.cfg.keywordCase){case"preserve":return Io(l.raw);case"upper":return l.text;case"lower":return l.text.toLowerCase()}}showFunctionKw(l){return Od(l.tokenType)?dd(this.showNonTabularFunctionKw(l),this.cfg.indentStyle):this.showNonTabularFunctionKw(l)}showNonTabularFunctionKw(l){switch(this.cfg.functionCase){case"preserve":return Io(l.raw);case"upper":return l.text;case"lower":return l.text.toLowerCase()}}showIdentifier(l){if(l.quoted)return l.text;switch(this.cfg.identifierCase){case"preserve":return l.text;case"upper":return l.text.toUpperCase();case"lower":return l.text.toLowerCase()}}showDataType(l){switch(this.cfg.dataTypeCase){case"preserve":return Io(l.raw);case"upper":return l.text;case"lower":return l.text.toLowerCase()}}}class D_{constructor(l,E){this.dialect=l,this.cfg=E,this.params=new i_(this.cfg.params)}format(l){const E=this.parse(l);return this.formatAst(E).trimEnd()}parse(l){return L_(this.dialect.tokenizer).parse(l,this.cfg.paramTypes||{})}formatAst(l){return l.map(E=>this.formatStatement(E)).join(`
`.repeat(this.cfg.linesBetweenQueries+1))}formatStatement(l){const E=new po({cfg:this.cfg,dialectCfg:this.dialect.formatOptions,params:this.params,layout:new zd(new kd(l_(this.cfg)))}).format(l.children);return l.hasSemicolon&&(this.cfg.newlineBeforeSemicolon?E.add(Se.NEWLINE,";"):E.add(Se.NO_NEWLINE,";")),E.toString()}}class fo extends Error{}function y_(r){const l=["multilineLists","newlineBeforeOpenParen","newlineBeforeCloseParen","aliasAs","commaPosition","tabulateAlias"];for(const E of l)if(E in r)throw new fo(`${E} config is no more supported.`);if(r.expressionWidth<=0)throw new fo(`expressionWidth config must be positive number. Received ${r.expressionWidth} instead.`);if(r.params&&!g_(r.params)&&console.warn('WARNING: All "params" option values should be strings.'),r.paramTypes&&!M_(r.paramTypes))throw new fo("Empty regex given in custom paramTypes. That would result in matching infinite amount of parameters.");return r}function g_(r){return(r instanceof Array?r:Object.values(r)).every(E=>typeof E=="string")}function M_(r){return r.custom&&Array.isArray(r.custom)?r.custom.every(l=>l.regex!==""):!0}var P_=function(r,l){var E={};for(var T in r)Object.prototype.hasOwnProperty.call(r,T)&&l.indexOf(T)<0&&(E[T]=r[T]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var c=0,T=Object.getOwnPropertySymbols(r);c<T.length;c++)l.indexOf(T[c])<0&&Object.prototype.propertyIsEnumerable.call(r,T[c])&&(E[T[c]]=r[T[c]]);return E};const $d={bigquery:"bigquery",clickhouse:"clickhouse",db2:"db2",db2i:"db2i",duckdb:"duckdb",hive:"hive",mariadb:"mariadb",mysql:"mysql",n1ql:"n1ql",plsql:"plsql",postgresql:"postgresql",redshift:"redshift",spark:"spark",sqlite:"sqlite",sql:"sql",tidb:"tidb",trino:"trino",transactsql:"transactsql",tsql:"transactsql",singlestoredb:"singlestoredb",snowflake:"snowflake"},U_=Object.keys($d),b_={tabWidth:2,useTabs:!1,keywordCase:"preserve",identifierCase:"preserve",dataTypeCase:"preserve",functionCase:"preserve",indentStyle:"standard",logicalOperatorNewline:"before",expressionWidth:50,linesBetweenQueries:1,denseOperators:!1,newlineBeforeSemicolon:!1},G_=(r,l={})=>{if(typeof l.language=="string"&&!U_.includes(l.language))throw new fo(`Unsupported SQL dialect: ${l.language}`);const E=$d[l.language||"sql"];return B_(r,Object.assign(Object.assign({},l),{dialect:wL[E]}))},B_=(r,l)=>{var{dialect:E}=l,T=P_(l,["dialect"]);if(typeof r!="string")throw new Error("Invalid query argument. Expected string, instead got "+typeof r);const c=y_(Object.assign(Object.assign({},b_),T));return new D_(a_(E),c).format(r)};function H_(r,l){if(r===null&&l===null)return 0;if(r===null)return 1;if(l===null)return-1;const E=Number(r),T=Number(l);return!isNaN(E)&&!isNaN(T)?E-T:String(r).localeCompare(String(l))}const Ze={int:"var(--havn-accent)",float:"var(--havn-accent)",text:"var(--havn-green)",bool:"var(--havn-purple)",temporal:"var(--havn-yellow)",other:"var(--havn-text-dim)"};function F_(r){const l=r.toUpperCase().trim();return/^(BIGINT|INT8)$/.test(l)?{label:"123",color:Ze.int}:/^(INTEGER|INT4|INT|SIGNED)$/.test(l)?{label:"123",color:Ze.int}:/^(SMALLINT|INT2|SHORT)$/.test(l)?{label:"123",color:Ze.int}:/^(TINYINT|INT1)$/.test(l)?{label:"123",color:Ze.int}:/^(UBIGINT)$/.test(l)?{label:"123",color:Ze.int}:/^(UINTEGER|UINT)$/.test(l)?{label:"123",color:Ze.int}:/^(USMALLINT)$/.test(l)?{label:"123",color:Ze.int}:/^(UTINYINT)$/.test(l)?{label:"123",color:Ze.int}:/^(HUGEINT|UHUGEINT)$/.test(l)?{label:"123",color:Ze.int}:/^(FLOAT|FLOAT4|REAL)$/.test(l)?{label:"1.2",color:Ze.float}:/^(DOUBLE|FLOAT8)$/.test(l)?{label:"1.2",color:Ze.float}:/^DECIMAL|^NUMERIC/.test(l)?{label:"1.2",color:Ze.float}:/^BOOL(EAN)?$/.test(l)?{label:"T/F",color:Ze.bool}:/^VARCHAR/.test(l)?{label:"VARCHAR",color:Ze.text}:/^TEXT$/.test(l)?{label:"TEXT",color:Ze.text}:/^CHAR/.test(l)?{label:"CHAR",color:Ze.text}:/^STRING$/.test(l)?{label:"STRING",color:Ze.text}:/^BLOB|^BYTEA$/.test(l)?{label:"BLOB",color:Ze.text}:/^UUID$/.test(l)?{label:"UUID",color:Ze.text}:/^ENUM/.test(l)?{label:"ENUM",color:Ze.text}:/^TIMESTAMP\s*WITH\s*TIME\s*ZONE|^TIMESTAMPTZ/.test(l)?{label:"TIMESTAMPTZ",color:Ze.temporal}:/^TIMESTAMP/.test(l)?{label:"TIMESTAMP",color:Ze.temporal}:/^DATETIME$/.test(l)?{label:"DATETIME",color:Ze.temporal}:/^DATE$/.test(l)?{label:"DATE",color:Ze.temporal}:/^TIME\s*WITH\s*TIME\s*ZONE|^TIMETZ/.test(l)?{label:"TIMETZ",color:Ze.temporal}:/^TIME$/.test(l)?{label:"TIME",color:Ze.temporal}:/^INTERVAL/.test(l)?{label:"INTERVAL",color:Ze.temporal}:/^JSON$/.test(l)?{label:"JSON",color:Ze.other}:/^STRUCT|^MAP/.test(l)?{label:"{ }",color:Ze.other}:/^LIST|^ARRAY|\[\]/.test(l)?{label:"[ ]",color:Ze.other}:/^UNION/.test(l)?{label:"UNION",color:Ze.other}:{label:l.length>10?l.slice(0,10):l,color:Ze.other}}function Y_(r,l){for(let E=0;E<Math.min(r.length,20);E++){const T=r[E][l];if(T==null)continue;if(typeof T=="boolean"||T==="true"||T==="false")return{label:"T/F",color:Ze.bool};const c=String(T).trim();if(c!=="")return isNaN(Number(c))?/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(c)?{label:"TIMESTAMP",color:Ze.temporal}:/^\d{4}-\d{2}-\d{2}$/.test(c)?{label:"DATE",color:Ze.temporal}:/^\d{2}:\d{2}(:\d{2})?/.test(c)?{label:"TIME",color:Ze.temporal}:{label:"VARCHAR",color:Ze.text}:c.includes(".")?{label:"1.2",color:Ze.float}:{label:"123",color:Ze.int}}return{label:"VARCHAR",color:Ze.text}}function Fs({columns:r,rows:l,columnTypes:E}){const[T,c]=A.useState(null),[u,N]=A.useState("asc"),L=A.useMemo(()=>r.map((O,d)=>E&&E[d]?F_(E[d]):Y_(l,d)),[r,l,E]);function I(O){T===O?u==="asc"?N("desc"):(c(null),N("asc")):(c(O),N("asc"))}const R=A.useMemo(()=>{if(T===null)return l;const O=[...l].sort((d,_)=>H_(d[T],_[T]));return u==="desc"?O.reverse():O},[l,T,u]);return a.jsxs("table",{style:Br.table,children:[a.jsx("thead",{children:a.jsx("tr",{children:r.map((O,d)=>{const _=L[d],C=T===d;return a.jsx("th",{style:Br.th,onClick:()=>I(d),children:a.jsxs("span",{style:Br.thInner,children:[a.jsx("span",{children:O}),a.jsx("span",{style:{...Br.typeSymbol,color:_.color},children:_.label}),a.jsx("span",{style:{...Br.sortIcon,color:C?"var(--havn-accent)":"var(--havn-text-dim)"},children:C?u==="asc"?"▴":"▾":"▴▾"})]})},O)})})}),a.jsx("tbody",{children:R.map((O,d)=>a.jsx("tr",{children:O.map((_,C)=>a.jsx("td",{style:Br.td,title:_===null?"":String(_),children:_===null?a.jsx("span",{style:Br.null,children:"NULL"}):String(_)},C))},d))})]})}const Br={table:{width:"100%",borderCollapse:"collapse",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},th:{textAlign:"left",padding:"6px 12px",borderBottom:"2px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600,position:"sticky",top:0,background:"var(--havn-bg)",cursor:"pointer",userSelect:"none"},thInner:{display:"flex",alignItems:"center",gap:"6px",width:"100%"},typeSymbol:{fontSize:"9px",fontWeight:500,opacity:.8},sortIcon:{fontSize:"8px",lineHeight:1,marginLeft:"auto",flexShrink:0},td:{padding:"4px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"300px"},null:{color:"var(--havn-text-dim)",fontStyle:"italic",fontSize:"11px"}};function Ms(r,l,E=6){r===l&&(r=r===0?-1:r*.9,l=l===0?1:l*1.1);const c=(l-r)/E,u=Math.pow(10,Math.floor(Math.log10(c))),N=c/u;let L;N<=1.5?L=u:N<=3?L=2*u:N<=7?L=5*u:L=10*u;const I=Math.floor(r/L)*L,R=Math.ceil(l/L)*L,O=[];for(let d=I;d<=R+L*.001;d+=L)O.push(parseFloat(d.toPrecision(12)));return{min:I,max:R,ticks:O}}function Nd(r){if(r==null)return"";const l=Number(r);if(isNaN(l))return String(r);const E=Math.abs(l);return E>=1e9?(l/1e9).toFixed(1)+"B":E>=1e6?(l/1e6).toFixed(1)+"M":E>=1e3?(l/1e3).toFixed(1)+"K":Number.isInteger(l)?l.toLocaleString():l.toFixed(2)}function Ps(r){const l=Number(r);if(isNaN(l))return String(r);const E=Math.abs(l);return E>=1e9?(l/1e9).toFixed(1)+"B":E>=1e6?(l/1e6).toFixed(1)+"M":E>=1e4?(l/1e3).toFixed(0)+"K":Number.isInteger(l)?String(l):l.toFixed(E<1?2:1)}function co(r){return r==null||r===""?NaN:Number(r)}function Hr(r,l=12){return r=String(r),r.length>l?r.slice(0,l-1)+"…":r}function j_(r,l,E,T,c){const u=r+E*Math.cos(T),N=l+E*Math.sin(T),L=r+E*Math.cos(c),I=l+E*Math.sin(c),R=c-T>Math.PI?1:0;return`M ${r} ${l} L ${u} ${N} A ${E} ${E} 0 ${R} 1 ${L} ${I} Z`}function V_(r,l,E,T,c,u){const N=Math.cos(c),L=Math.sin(c),I=Math.cos(u),R=Math.sin(u),O=u-c>Math.PI?1:0;return[`M ${r+E*N} ${l+E*L}`,`A ${E} ${E} 0 ${O} 1 ${r+E*I} ${l+E*R}`,`L ${r+T*I} ${l+T*R}`,`A ${T} ${T} 0 ${O} 0 ${r+T*N} ${l+T*L}`,"Z"].join(" ")}function w_(r,l){return r.map((E,T)=>{let c=0,u=0,N=0;const L=Math.min(l.length,100),I=new Set;for(let _=0;_<L;_++){const C=l[_][T];if(C==null||C===""){N++;continue}I.add(C);const f=String(C).trim();f==="true"||f==="false"||(isNaN(Number(f))?/^\d{4}-\d{2}-\d{2}/.test(f)&&u++:c++)}const R=L-N,O=R>0&&c/R>.7,d=R>0&&u/R>.7;return{name:E,index:T,isNumeric:O,isTemporal:d,isText:!O&&!d,uniqueValues:I.size}})}function W_(r,l){const E=r.filter(u=>u.isNumeric),T=r.filter(u=>u.isTemporal),c=r.filter(u=>u.isText);return T.length>=1&&E.length>=1?{type:"line",x:T[0].index,y:E.slice(0,4).map(u=>u.index)}:E.length>=2&&c.length===0?{type:"scatter",x:E[0].index,y:[E[1].index]}:c.length>=1&&E.length>=1?l<=7&&E.length===1?{type:"donut",x:c[0].index,y:[E[0].index]}:{type:"bar",x:c[0].index,y:E.slice(0,4).map(u=>u.index)}:E.length===1?{type:"bar",x:0,y:[E[0].index]}:{type:"bar",x:0,y:[Math.min(1,r.length-1)]}}const ca=["#6366f1","#22c55e","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6","#f97316","#a855f7"],X_=[{id:"bar",label:"Bar"},{id:"line",label:"Line"},{id:"area",label:"Area"},{id:"scatter",label:"Scatter"},{id:"pie",label:"Pie"},{id:"donut",label:"Donut"},{id:"hbar",label:"H-Bar"},{id:"stacked",label:"Stacked"}],dn={top:28,right:28,bottom:52,left:60};function K_({type:r}){const l={width:16,height:14,viewBox:"0 0 16 14",fill:"currentColor",style:{display:"block"}};switch(r){case"bar":return a.jsxs("svg",{...l,children:[a.jsx("rect",{x:"1",y:"6",width:"3",height:"8",rx:"0.5"}),a.jsx("rect",{x:"6.5",y:"2",width:"3",height:"12",rx:"0.5"}),a.jsx("rect",{x:"12",y:"4",width:"3",height:"10",rx:"0.5"})]});case"line":return a.jsx("svg",{...l,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:a.jsx("polyline",{points:"1,10 5,4 9,8 15,2"})});case"area":return a.jsxs("svg",{...l,children:[a.jsx("path",{d:"M1,10 L5,4 L9,8 L15,2 L15,14 L1,14 Z",opacity:"0.3"}),a.jsx("polyline",{points:"1,10 5,4 9,8 15,2",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]});case"scatter":return a.jsxs("svg",{...l,children:[a.jsx("circle",{cx:"3",cy:"10",r:"1.5"}),a.jsx("circle",{cx:"6",cy:"5",r:"1.5"}),a.jsx("circle",{cx:"10",cy:"8",r:"1.5"}),a.jsx("circle",{cx:"13",cy:"3",r:"1.5"})]});case"pie":return a.jsxs("svg",{...l,viewBox:"0 0 16 16",children:[a.jsx("path",{d:"M8,8 L8,1 A7,7 0 1,1 2,11 Z",opacity:"0.7"}),a.jsx("path",{d:"M8,8 L2,11 A7,7 0 0,1 8,1 Z",opacity:"0.3"})]});case"donut":return a.jsxs("svg",{...l,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[a.jsx("path",{d:"M8,1 A7,7 0 1,1 2,11",opacity:"0.7"}),a.jsx("path",{d:"M2,11 A7,7 0 0,1 8,1",opacity:"0.3"})]});case"hbar":return a.jsxs("svg",{...l,children:[a.jsx("rect",{x:"0",y:"1",width:"10",height:"3",rx:"0.5"}),a.jsx("rect",{x:"0",y:"5.5",width:"14",height:"3",rx:"0.5"}),a.jsx("rect",{x:"0",y:"10",width:"8",height:"3",rx:"0.5"})]});case"stacked":return a.jsxs("svg",{...l,children:[a.jsx("rect",{x:"1",y:"5",width:"3",height:"4",opacity:"0.7"}),a.jsx("rect",{x:"1",y:"9",width:"3",height:"5",opacity:"0.35"}),a.jsx("rect",{x:"6.5",y:"2",width:"3",height:"5",opacity:"0.7"}),a.jsx("rect",{x:"6.5",y:"7",width:"3",height:"7",opacity:"0.35"}),a.jsx("rect",{x:"12",y:"3",width:"3",height:"4",opacity:"0.7"}),a.jsx("rect",{x:"12",y:"7",width:"3",height:"7",opacity:"0.35"})]});default:return null}}function Id(r,l){if(!r)return;let T=new XMLSerializer().serializeToString(r);if(l==="svg"){const d=new Blob([T],{type:"image/svg+xml"}),_=document.createElement("a");_.download="chart.svg",_.href=URL.createObjectURL(d),_.click(),URL.revokeObjectURL(_.href);return}const c=r.getBoundingClientRect(),u=2,N=document.createElement("canvas");N.width=c.width*u,N.height=c.height*u;const L=N.getContext("2d");L.scale(u,u);const I=new Image,R=new Blob([T],{type:"image/svg+xml;charset=utf-8"}),O=URL.createObjectURL(R);I.onload=()=>{const d=getComputedStyle(document.documentElement).getPropertyValue("--havn-bg").trim()||"#0c0e14";L.fillStyle=d,L.fillRect(0,0,c.width,c.height),L.drawImage(I,0,0,c.width,c.height),N.toBlob(_=>{const C=document.createElement("a");C.download="chart.png",C.href=URL.createObjectURL(_),C.click()}),URL.revokeObjectURL(O)},I.src=O}function z_({columns:r,rows:l}){const[E,T]=A.useState(null),[c,u]=A.useState(0),[N,L]=A.useState([1]),[I,R]=A.useState(null),[O,d]=A.useState(null),[_,C]=A.useState({width:800,height:400}),[f,m]=A.useState(!1),[j,W]=A.useState(!1),P=A.useRef(null),Z=A.useRef(null),v=A.useRef(null),M=A.useRef(null),Te=A.useMemo(()=>w_(r,l),[r,l]);A.useEffect(()=>{const F=W_(Te,l.length);T(F.type),u(F.x),L(F.y),R(null),d(null)},[Te,l.length]),A.useEffect(()=>{const F=P.current;if(!F)return;const te=new ResizeObserver(Y=>{const{width:le,height:he}=Y[0].contentRect;le>0&&he>0&&C({width:Math.floor(le),height:Math.floor(he)})});return te.observe(F),()=>te.disconnect()},[]),A.useEffect(()=>{if(!f&&!j)return;const F=te=>{f&&v.current&&!v.current.contains(te.target)&&m(!1),j&&M.current&&!M.current.contains(te.target)&&W(!1)};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[f,j]);const B=A.useMemo(()=>{const F=l.map(Ne=>String(Ne[c]??"")),te=N.map((Ne,b)=>({name:r[Ne],color:ca[b%ca.length],values:l.map(K=>{const Le=co(K[Ne]);return isNaN(Le)?0:Le})})),Y=te.flatMap(Ne=>Ne.values),le=Math.min(0,...Y),he=Math.max(0,...Y),xe=l.map(Ne=>({x:co(Ne[c]),y:co(Ne[N[0]])})).filter(Ne=>!isNaN(Ne.x)&&!isNaN(Ne.y)),ye=l.map(Ne=>({label:String(Ne[c]??""),value:Math.abs(co(Ne[N[0]])||0)})).filter(Ne=>Ne.value>0),_e=F.map((Ne,b)=>te.reduce((K,Le)=>K+Math.max(0,Le.values[b]),0)),me=Math.max(0,..._e);return{labels:F,series:te,yMin:le,yMax:he,scatterPoints:xe,slices:ye,stackMax:me}},[l,r,c,N]),se=A.useCallback((F,te,Y)=>{var he;const le=(he=P.current)==null?void 0:he.getBoundingClientRect();le&&d({x:F.clientX-le.left,y:F.clientY-le.top,label:te,values:Y})},[]),w=A.useCallback(()=>{d(null),R(null)},[]),$=Te.filter(F=>F.isNumeric&&!N.includes(F.index)&&F.index!==c),J=E==="pie"||E==="donut",Ce=!J;if(!r||r.length<2||l.length===0)return a.jsx("div",{style:at.empty,children:"Need at least 2 columns and 1 row to chart."});const{width:Ie,height:ve}=_,z=Ie-dn.left-dn.right,D=ve-dn.top-dn.bottom;function oe(){if(z<40||D<40)return null;switch(E){case"bar":return Oe();case"line":return x(!1);case"area":return x(!0);case"scatter":return y();case"pie":return p(!1);case"donut":return p(!0);case"hbar":return ne();case"stacked":return ae();default:return Oe()}}function Oe(){const{labels:F,series:te,yMin:Y,yMax:le}=B,he=Ms(Y,le),xe=he.max-he.min||1,ye=F.length,_e=z/ye,me=te.length,Ne=Math.min(_e*.7/me,48),b=Ne*me,K=De=>D-(De-he.min)/xe*D,Le=K(0),Ge=Math.max(1,Math.ceil(ye/24));return a.jsxs("g",{transform:`translate(${dn.left},${dn.top})`,children:[he.ticks.map(De=>a.jsxs("g",{children:[a.jsx("line",{x1:0,y1:K(De),x2:z,y2:K(De),stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.5}),a.jsx("text",{x:-8,y:K(De)+3.5,textAnchor:"end",style:Sa,children:Ps(De)})]},De)),F.map((De,ze)=>ze%Ge!==0&&ze!==ye-1?null:a.jsx("text",{x:ze*_e+_e/2,y:D+18,textAnchor:"middle",style:Sa,children:Hr(De)},ze)),te.map((De,ze)=>De.values.map((Xe,et)=>{const Xt=et*_e+(_e-b)/2+ze*Ne,st=Math.abs(K(Xe)-Le),Gt=Xe>=0?K(Xe):Le,Bt=I===et;return a.jsx("rect",{x:Xt,y:Gt,width:Ne-1,height:Math.max(st,1),rx:Math.min(3,Ne/4),fill:De.color,opacity:I!==null&&!Bt?.3:1,style:{transition:"opacity 0.15s"},onMouseMove:Ht=>{R(et),se(Ht,F[et],te.map((Pt,mn)=>({name:Pt.name,value:Pt.values[et],color:Pt.color})))},onMouseLeave:w},`${ze}-${et}`)})),he.min<0&&a.jsx("line",{x1:0,y1:Le,x2:z,y2:Le,stroke:"var(--havn-text-dim)",strokeWidth:1,opacity:.6})]})}function x(F){const{labels:te,series:Y,yMin:le,yMax:he}=B,xe=Ms(le,he),ye=xe.max-xe.min||1,_e=te.length,me=K=>D-(K-xe.min)/ye*D,Ne=K=>_e===1?z/2:K/(_e-1)*z,b=Math.max(1,Math.ceil(_e/20));return a.jsxs("g",{transform:`translate(${dn.left},${dn.top})`,children:[xe.ticks.map(K=>a.jsxs("g",{children:[a.jsx("line",{x1:0,y1:me(K),x2:z,y2:me(K),stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.5}),a.jsx("text",{x:-8,y:me(K)+3.5,textAnchor:"end",style:Sa,children:Ps(K)})]},K)),te.map((K,Le)=>Le%b!==0&&Le!==_e-1?null:a.jsx("text",{x:Ne(Le),y:D+18,textAnchor:"middle",style:Sa,children:Hr(K,10)},Le)),F&&Y.map((K,Le)=>{K.values.map((De,ze)=>`${Ne(ze)},${me(De)}`).join(" ");const Ge=`M ${Ne(0)},${me(K.values[0])} ${K.values.map((De,ze)=>`L ${Ne(ze)},${me(De)}`).join(" ")} L ${Ne(_e-1)},${D} L ${Ne(0)},${D} Z`;return a.jsx("path",{d:Ge,fill:K.color,opacity:.12},Le)}),Y.map((K,Le)=>{const Ge=K.values.map((De,ze)=>`${ze===0?"M":"L"} ${Ne(ze)},${me(De)}`).join(" ");return a.jsx("path",{d:Ge,fill:"none",stroke:K.color,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},Le)}),Y.map((K,Le)=>K.values.map((Ge,De)=>a.jsx("circle",{cx:Ne(De),cy:me(Ge),r:I===De?5:3,fill:K.color,stroke:"var(--havn-bg)",strokeWidth:2,opacity:I!==null&&I!==De?.3:1,style:{transition:"r 0.15s, opacity 0.15s"}},`${Le}-${De}`))),I!==null&&a.jsx("line",{x1:Ne(I),y1:0,x2:Ne(I),y2:D,stroke:"var(--havn-text-dim)",strokeWidth:1,strokeDasharray:"4,4",opacity:.6}),a.jsx("rect",{x:0,y:0,width:z,height:D,fill:"transparent",style:{cursor:"crosshair"},onMouseMove:K=>{const Le=K.currentTarget.ownerSVGElement.getBoundingClientRect(),Ge=K.clientX-Le.left-dn.left,De=_e===1?0:Math.round(Ge/(z/(_e-1))),ze=Math.max(0,Math.min(_e-1,De));R(ze),se(K,te[ze],Y.map(Xe=>({name:Xe.name,value:Xe.values[ze],color:Xe.color})))},onMouseLeave:w})]})}function y(){const{scatterPoints:F}=B;if(F.length===0)return a.jsx("text",{x:Ie/2,y:ve/2,textAnchor:"middle",style:{fill:"var(--havn-text-dim)",fontSize:"13px"},children:"No numeric data for scatter plot"});const te=F.map(b=>b.x),Y=F.map(b=>b.y),le=Ms(Math.min(...te),Math.max(...te)),he=Ms(Math.min(...Y),Math.max(...Y)),xe=le.max-le.min||1,ye=he.max-he.min||1,_e=b=>(b-le.min)/xe*z,me=b=>D-(b-he.min)/ye*D,Ne=Math.max(1,Math.ceil(le.ticks.length/10));return a.jsxs("g",{transform:`translate(${dn.left},${dn.top})`,children:[he.ticks.map(b=>a.jsxs("g",{children:[a.jsx("line",{x1:0,y1:me(b),x2:z,y2:me(b),stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.5}),a.jsx("text",{x:-8,y:me(b)+3.5,textAnchor:"end",style:Sa,children:Ps(b)})]},`y${b}`)),le.ticks.map((b,K)=>K%Ne!==0?null:a.jsxs("g",{children:[a.jsx("line",{x1:_e(b),y1:0,x2:_e(b),y2:D,stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.3}),a.jsx("text",{x:_e(b),y:D+18,textAnchor:"middle",style:Sa,children:Ps(b)})]},`x${b}`)),F.map((b,K)=>a.jsx("circle",{cx:_e(b.x),cy:me(b.y),r:I===K?6:4,fill:ca[0],opacity:I!==null&&I!==K?.2:.7,stroke:ca[0],strokeWidth:1,style:{transition:"r 0.15s, opacity 0.15s",cursor:"pointer"},onMouseMove:Le=>{R(K),se(Le,`Point ${K+1}`,[{name:r[c],value:b.x,color:ca[0]},{name:r[N[0]],value:b.y,color:ca[1]}])},onMouseLeave:w},K))]})}function p(F){const{slices:te}=B;if(te.length===0)return a.jsx("text",{x:Ie/2,y:ve/2,textAnchor:"middle",style:{fill:"var(--havn-text-dim)",fontSize:"13px"},children:"No data for chart"});const Y=te.reduce((Ne,b)=>Ne+b.value,0)||1,le=Ie/2,he=(ve-30)/2,xe=Math.min(le-40,he-20),ye=F?xe*.55:0;let _e=-Math.PI/2;const me=te.map((Ne,b)=>{const K=Ne.value/Y*Math.PI*2,Le=_e;_e+=K;const Ge=_e,De=Le+K/2;return{...Ne,start:Le,end:Ge,midAngle:De,pct:(Ne.value/Y*100).toFixed(1),color:ca[b%ca.length],index:b}});return a.jsxs("g",{children:[me.map(Ne=>{const b=I===Ne.index,K=b?Math.cos(Ne.midAngle)*6:0,Le=b?Math.sin(Ne.midAngle)*6:0,Ge=F?V_(le+K,he+Le,xe,ye,Ne.start,Ne.end):j_(le+K,he+Le,xe,Ne.start,Ne.end);return a.jsx("path",{d:Ge,fill:Ne.color,opacity:I!==null&&!b?.35:1,style:{transition:"opacity 0.15s",cursor:"pointer"},onMouseMove:De=>{R(Ne.index),se(De,Ne.label,[{name:`${Ne.pct}%`,value:Ne.value,color:Ne.color}])},onMouseLeave:w},Ne.index)}),me.map(Ne=>{if(Ne.end-Ne.start<.35)return null;const b=F?(xe+ye)/2:xe*.6,K=le+b*Math.cos(Ne.midAngle),Le=he+b*Math.sin(Ne.midAngle);return a.jsxs("text",{x:K,y:Le,textAnchor:"middle",dominantBaseline:"central",style:{fill:"#fff",fontSize:"11px",fontWeight:600,fontFamily:"var(--havn-font-mono)",pointerEvents:"none",textShadow:"0 1px 2px rgba(0,0,0,0.5)"},children:[Ne.pct,"%"]},`l${Ne.index}`)}),F&&a.jsxs("g",{children:[a.jsx("text",{x:le,y:he-6,textAnchor:"middle",style:{fill:"var(--havn-text)",fontSize:"18px",fontWeight:700,fontFamily:"var(--havn-font-mono)"},children:Nd(Y)}),a.jsx("text",{x:le,y:he+12,textAnchor:"middle",style:{fill:"var(--havn-text-dim)",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.5px"},children:"Total"})]}),H(me)]})}function H(F){const Y=ve-22,le=Math.floor((Ie-24)/100),he=F.slice(0,le);let xe=12;return a.jsx("g",{children:he.map(ye=>{const _e=xe,me=Math.min(Hr(ye.label,10).length*6.5+20,100);return xe+=me,a.jsxs("g",{children:[a.jsx("rect",{x:_e,y:Y,width:8,height:8,rx:2,fill:ye.color}),a.jsx("text",{x:_e+12,y:Y+8,style:{fill:"var(--havn-text-secondary)",fontSize:"10px",fontFamily:"var(--havn-font-mono)"},children:Hr(ye.label,10)})]},ye.index)})})}function ne(){const{labels:F,series:te,yMin:Y,yMax:le}=B,he=F.length,xe=Math.min(D/he*.7,32),ye=D/he,_e=te.flatMap(Xe=>Xe.values),me=Math.min(0,..._e),Ne=Math.max(0,..._e),b=Ms(me,Ne),K=b.max-b.min||1,Le={...dn,left:100},Ge=Ie-Le.left-Le.right,De=Xe=>(Xe-b.min)/K*Ge,ze=De(0);return a.jsxs("g",{transform:`translate(${Le.left},${dn.top})`,children:[b.ticks.map(Xe=>a.jsxs("g",{children:[a.jsx("line",{x1:De(Xe),y1:0,x2:De(Xe),y2:D,stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.5}),a.jsx("text",{x:De(Xe),y:D+18,textAnchor:"middle",style:Sa,children:Ps(Xe)})]},Xe)),F.map((Xe,et)=>a.jsx("text",{x:-8,y:et*ye+ye/2+4,textAnchor:"end",style:Sa,children:Hr(Xe,14)},et)),te.map((Xe,et)=>Xe.values.map((Xt,st)=>{const Gt=st*ye+(ye-xe*te.length)/2+et*xe,Bt=Math.abs(De(Xt)-ze),Ht=Xt>=0?ze:De(Xt),Pt=I===st;return a.jsx("rect",{x:Ht,y:Gt,width:Math.max(Bt,1),height:xe-1,rx:Math.min(3,xe/4),fill:Xe.color,opacity:I!==null&&!Pt?.3:1,style:{transition:"opacity 0.15s",cursor:"pointer"},onMouseMove:mn=>{R(st),se(mn,F[st],te.map(vn=>({name:vn.name,value:vn.values[st],color:vn.color})))},onMouseLeave:w},`${et}-${st}`)})),b.min<0&&a.jsx("line",{x1:ze,y1:0,x2:ze,y2:D,stroke:"var(--havn-text-dim)",strokeWidth:1,opacity:.6})]})}function ae(){const{labels:F,series:te,stackMax:Y}=B,le=Ms(0,Y),he=le.max-le.min||1,xe=F.length,ye=z/xe,_e=Math.min(ye*.7,48),me=b=>D-(b-le.min)/he*D,Ne=Math.max(1,Math.ceil(xe/24));return a.jsxs("g",{transform:`translate(${dn.left},${dn.top})`,children:[le.ticks.map(b=>a.jsxs("g",{children:[a.jsx("line",{x1:0,y1:me(b),x2:z,y2:me(b),stroke:"var(--havn-border-light)",strokeDasharray:"3,3",opacity:.5}),a.jsx("text",{x:-8,y:me(b)+3.5,textAnchor:"end",style:Sa,children:Ps(b)})]},b)),F.map((b,K)=>K%Ne!==0&&K!==xe-1?null:a.jsx("text",{x:K*ye+ye/2,y:D+18,textAnchor:"middle",style:Sa,children:Hr(b)},K)),F.map((b,K)=>{let Le=0;return te.map((Ge,De)=>{const ze=Math.max(0,Ge.values[K]),Xe=me(Le);Le+=ze;const et=me(Le),Xt=Math.max(Xe-et,0),st=K*ye+(ye-_e)/2,Gt=I===K;return a.jsx("rect",{x:st,y:et,width:_e,height:Math.max(Xt,ze>0?1:0),fill:Ge.color,rx:De===te.length-1?Math.min(3,_e/4):0,opacity:I!==null&&!Gt?.3:1,style:{transition:"opacity 0.15s",cursor:"pointer"},onMouseMove:Bt=>{R(K);const Ht=te.reduce((Pt,mn)=>Pt+Math.max(0,mn.values[K]),0);se(Bt,F[K],[...te.map(Pt=>({name:Pt.name,value:Math.max(0,Pt.values[K]),color:Pt.color})),{name:"Total",value:Ht,color:"var(--havn-text-secondary)"}])},onMouseLeave:w},`${De}-${K}`)})})]})}return a.jsxs("div",{style:at.container,children:[a.jsxs("div",{style:at.toolbar,children:[a.jsx("div",{style:at.typeGroup,children:X_.map(F=>a.jsx("button",{onClick:()=>T(F.id),title:F.label,style:E===F.id?at.typeBtnActive:at.typeBtn,children:a.jsx(K_,{type:F.id})},F.id))}),a.jsx("div",{style:at.sep}),!J&&a.jsxs("div",{style:at.axisGroup,children:[a.jsx("span",{style:at.axisLabel,children:"X"}),a.jsx("select",{value:c,onChange:F=>u(parseInt(F.target.value)),style:at.select,children:r.map((F,te)=>a.jsx("option",{value:te,children:F},te))})]}),a.jsxs("div",{style:at.axisGroup,children:[a.jsx("span",{style:at.axisLabel,children:J?"Label":"Y"}),J?a.jsx("select",{value:c,onChange:F=>u(parseInt(F.target.value)),style:at.select,children:r.map((F,te)=>a.jsx("option",{value:te,children:F},te))}):a.jsxs(a.Fragment,{children:[N.map(F=>a.jsxs("span",{style:at.yTag,children:[a.jsx("span",{style:{...at.yTagDot,background:ca[N.indexOf(F)%ca.length]}}),r[F],N.length>1&&a.jsx("button",{onClick:()=>L(N.filter(te=>te!==F)),style:at.yTagClose,children:"×"})]},F)),$.length>0&&a.jsxs("div",{ref:v,style:{position:"relative"},children:[a.jsx("button",{onClick:()=>m(!f),style:at.addBtn,children:"+"}),f&&a.jsx("div",{style:at.dropdown,children:$.map(F=>a.jsx("button",{style:at.dropdownItem,onClick:()=>{L([...N,F.index]),m(!1)},onMouseEnter:te=>te.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:te=>te.currentTarget.style.background="none",children:F.name},F.index))})]})]})]}),J&&a.jsxs("div",{style:at.axisGroup,children:[a.jsx("span",{style:at.axisLabel,children:"Value"}),a.jsx("select",{value:N[0],onChange:F=>L([parseInt(F.target.value)]),style:at.select,children:r.map((F,te)=>a.jsx("option",{value:te,children:F},te))})]}),a.jsxs("div",{ref:M,style:{position:"relative",marginLeft:"auto"},children:[a.jsx("button",{onClick:()=>W(!j),style:at.exportBtn,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:a.jsx("path",{d:"M7 2v8M4 7l3 3 3-3M2 12h10"})})}),j&&a.jsxs("div",{style:{...at.dropdown,right:0,left:"auto"},children:[a.jsx("button",{style:at.dropdownItem,onClick:()=>{Id(Z.current,"png"),W(!1)},onMouseEnter:F=>F.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:F=>F.currentTarget.style.background="none",children:"Download PNG"}),a.jsx("button",{style:at.dropdownItem,onClick:()=>{Id(Z.current,"svg"),W(!1)},onMouseEnter:F=>F.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:F=>F.currentTarget.style.background="none",children:"Download SVG"})]})]})]}),a.jsxs("div",{ref:P,style:at.chartArea,children:[a.jsx("svg",{ref:Z,width:Ie,height:ve,style:{display:"block"},xmlns:"http://www.w3.org/2000/svg",children:oe()}),O&&a.jsxs("div",{style:{...at.tooltip,left:O.x>Ie*.65?void 0:O.x+14,right:O.x>Ie*.65?Ie-O.x+14:void 0,top:O.y<60?O.y+20:O.y-12,transform:O.y<60?"none":"translateY(-100%)"},children:[a.jsx("div",{style:at.tipLabel,children:Hr(String(O.label),28)}),O.values.map((F,te)=>a.jsxs("div",{style:at.tipRow,children:[a.jsx("span",{style:{...at.tipDot,background:F.color}}),a.jsx("span",{style:at.tipName,children:F.name}),a.jsx("span",{style:at.tipVal,children:Nd(F.value)})]},te))]})]}),Ce&&N.length>1&&a.jsx("div",{style:at.legend,children:B.series.map((F,te)=>a.jsxs("div",{style:at.legendItem,children:[a.jsx("span",{style:{...at.legendDot,background:F.color}}),a.jsx("span",{style:at.legendName,children:F.name})]},te))})]})}const Sa={fill:"var(--havn-text-dim)",fontSize:"10px",fontFamily:"var(--havn-font-mono)"},at={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},empty:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--havn-text-dim)",fontSize:"13px"},toolbar:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 10px",borderBottom:"1px solid var(--havn-border)",background:"var(--havn-bg-secondary)",flexShrink:0,flexWrap:"wrap",minHeight:"36px"},typeGroup:{display:"flex",gap:"1px",background:"var(--havn-border)",borderRadius:"var(--havn-radius-lg)",overflow:"hidden"},typeBtn:{padding:"5px 8px",background:"var(--havn-btn-bg)",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",display:"flex",alignItems:"center"},typeBtnActive:{padding:"5px 8px",background:"var(--havn-bg)",border:"none",color:"var(--havn-accent)",cursor:"pointer",display:"flex",alignItems:"center"},sep:{width:"1px",height:"20px",background:"var(--havn-border)",flexShrink:0},axisGroup:{display:"flex",alignItems:"center",gap:"4px"},axisLabel:{fontSize:"10px",fontWeight:600,color:"var(--havn-text-dim)",textTransform:"uppercase",letterSpacing:"0.5px",flexShrink:0},select:{padding:"3px 6px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",maxWidth:"140px"},yTag:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px 2px 4px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",color:"var(--havn-text)"},yTagDot:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},yTagClose:{background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"14px",lineHeight:1,padding:"0 0 0 2px"},addBtn:{padding:"2px 8px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",fontWeight:600},exportBtn:{padding:"4px 8px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",cursor:"pointer",display:"flex",alignItems:"center"},dropdown:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius)",zIndex:100,minWidth:"120px",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",overflow:"hidden"},dropdownItem:{display:"block",width:"100%",padding:"6px 12px",background:"none",border:"none",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",fontFamily:"var(--havn-font-mono)",textAlign:"left",whiteSpace:"nowrap"},chartArea:{flex:1,position:"relative",overflow:"hidden",minHeight:0},tooltip:{position:"absolute",pointerEvents:"none",zIndex:50,background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",padding:"8px 12px",boxShadow:"0 6px 20px rgba(0,0,0,0.35)",maxWidth:"220px"},tipLabel:{fontSize:"11px",fontWeight:600,color:"var(--havn-text)",marginBottom:"4px",fontFamily:"var(--havn-font-mono)"},tipRow:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",lineHeight:"18px"},tipDot:{width:"7px",height:"7px",borderRadius:"2px",flexShrink:0},tipName:{color:"var(--havn-text-secondary)"},tipVal:{fontWeight:600,color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",marginLeft:"auto"},legend:{display:"flex",alignItems:"center",gap:"16px",padding:"6px 16px",borderTop:"1px solid var(--havn-border)",flexShrink:0,flexWrap:"wrap",background:"var(--havn-bg-secondary)"},legendItem:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px"},legendDot:{width:"8px",height:"8px",borderRadius:"2px",flexShrink:0},legendName:{color:"var(--havn-text-secondary)",fontFamily:"var(--havn-font-mono)"}},Hl=[{id:"first-pipeline-complete",text:"Pipeline complete. Use the Diff tab next time to preview what changes before you run.",action:{label:"Open Diff",navigate:"Diff"},target:"[data-havn-hint='run-summary']",priority:5,condition:r=>!!r.pipelineJustCompleted},{id:"first-editor-save",text:"Nice. You can run just this model with the Run Model button instead of running the full pipeline.",action:null,target:"[data-havn-hint='editor-toolbar']",priority:8,condition:r=>!!r.firstFileEdited},{id:"query-panel-intro",text:"Use the schema sidebar on the left to browse tables. Click any table name to insert it into your query.",action:null,target:"[data-havn-hint='query-sidebar']",priority:7,condition:r=>!!r.queryPanelOpened&&!!r.warehouseHasTables},{id:"first-connector-done",text:"Connector ready. It will sync on the schedule you set. You can also trigger a manual sync anytime from Data Sources.",action:null,target:"[data-havn-hint='connector-list']",priority:6,condition:r=>!!r.firstConnectorDone},{id:"connector-stale",text:"One or more connectors haven't synced in over a week. Check the scheduler or run a manual sync.",action:{label:"View connectors",navigate:"Data Sources"},target:"[data-havn-hint='connector-health']",priority:3,repeatable:!0,condition:r=>!!r.connectorStale},{id:"git-detected",text:"havn detected a git repo. Try `havn status` in your terminal or check the Diff tab to see data changes across branches.",action:{label:"Open Diff",navigate:"Diff"},target:"[data-havn-hint='git-status']",priority:9,condition:r=>!!r.gitDetected},{id:"uncommitted-changes",text:"You have uncommitted changes. Run `havn checkpoint` to commit with an auto-generated message.",action:null,target:"[data-havn-hint='git-status']",priority:4,condition:r=>!!r.gitDirty&&!!r.pipelineRanThisSession},{id:"diff-has-changes",text:"These are the rows that would change. Review them before running the pipeline to catch issues early.",action:null,target:"[data-havn-hint='diff-results']",priority:8,condition:r=>!!r.hasDiffChanges},{id:"dag-intro",text:"This shows how your models depend on each other. Click any node to jump to its source file.",action:null,target:"[data-havn-hint='dag-canvas']",priority:10,condition:r=>!!r.dagOpened},{id:"tables-click-columns",text:"Click any column chip to sort the preview. Use 'Query this table' to explore further.",action:null,target:"[data-havn-hint='columns-bar']",priority:9,condition:r=>!!r.firstTableSelected},{id:"keyboard-shortcuts",text:"Tip: use Alt+1 through Alt+5 to switch between tabs quickly.",action:null,target:"[data-havn-hint='tab-bar']",priority:12,condition:r=>(r.tabSwitchCount||0)>=5},{id:"overview-no-runs",text:"You have data in the warehouse but haven't run a pipeline yet. Set up transforms to build your silver and gold layers.",action:{label:"Open Editor",navigate:"Editor"},target:"[data-havn-hint='pipeline-health']",priority:6,condition:r=>!!r.overviewNoRuns&&!!r.warehouseHasTables}],xc="dp_dismissed_hints",Dc="dp_hint_stale_timestamps";function k_(){try{return JSON.parse(localStorage.getItem(xc)||"[]")}catch{return[]}}function $_(r){localStorage.setItem(xc,JSON.stringify(r))}function hd(){try{return JSON.parse(localStorage.getItem(Dc)||"{}")}catch{return{}}}function J_(r){localStorage.setItem(Dc,JSON.stringify(r))}const vo=A.createContext(null);function q_({children:r}){const[l,E]=A.useState(k_),[T,c]=A.useState({}),[u,N]=A.useState(null),L=A.useRef(null),I=A.useCallback(()=>{const m=Date.now(),j=hd(),W=Hl.filter(Z=>!Z.repeatable&&l.includes(Z.id)||Z.repeatable&&j[Z.id]&&m-j[Z.id]<6048e5||!Z.condition?!1:Z.condition(T)).sort((Z,v)=>Z.priority-v.priority),P=W.length>0?W[0].id:null;N(Z=>Z===P?Z:P)},[T,l]);A.useEffect(()=>{I()},[I]),A.useEffect(()=>{if(L.current&&(clearTimeout(L.current),L.current=null),!u)return;const m=Hl.find(W=>W.id===u),j=(m==null?void 0:m.autoDismissMs)??15e3;return L.current=setTimeout(()=>{R(u)},j),()=>{L.current&&(clearTimeout(L.current),L.current=null)}},[u]);const R=A.useCallback(m=>{const j=Hl.find(W=>W.id===m);if(j!=null&&j.repeatable){const W=hd();W[m]=Date.now(),J_(W)}else E(W=>{const P=W.includes(m)?W:[...W,m];return $_(P),P});N(W=>W===m?null:W)},[]),O=A.useCallback((m,j)=>{c(W=>W[m]===j?W:{...W,[m]:j})},[]),d=A.useCallback(()=>{localStorage.removeItem(xc),localStorage.removeItem(Dc),E([]),N(null)},[]),_=Hl.length,C=l.length,f={activeHintId:u,dismissed:l,hintState:T,setTrigger:O,dismiss:R,resetHints:d,totalHints:_,dismissedCount:C};return a.jsx(vo.Provider,{value:f,children:r})}function Ar(){const r=A.useContext(vo);return r?r.setTrigger:()=>{}}function Q_(){const r=A.useContext(vo);return r?{resetHints:r.resetHints,totalHints:r.totalHints,dismissedCount:r.dismissedCount}:{resetHints:()=>{},totalHints:0,dismissedCount:0}}function Z_(){const r=A.useContext(vo);if(!r||!r.activeHintId)return null;const l=Hl.find(E=>E.id===r.activeHintId);return l?{...l,dismiss:()=>r.dismiss(l.id)}:null}function bs({direction:r,onResize:l,onResizeStart:E}){const[T,c]=A.useState(!1),[u,N]=A.useState(!1),L=A.useRef(0),I=A.useRef(null),R=r==="horizontal",O=A.useCallback(f=>{f.preventDefault(),L.current=R?f.clientX:f.clientY,c(!0),E&&E();const m=document.createElement("div");m.style.cssText="position:fixed;inset:0;z-index:9998;cursor:"+(R?"col-resize":"row-resize"),document.body.appendChild(m),I.current=m,document.body.style.cursor=R?"col-resize":"row-resize",document.body.style.userSelect="none";function j(P){const v=(R?P.clientX:P.clientY)-L.current;l(v)}function W(){c(!1),document.body.style.cursor="",document.body.style.userSelect="",I.current&&(I.current.remove(),I.current=null),window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",W)}window.addEventListener("mousemove",j),window.addEventListener("mouseup",W)},[R,l,E]),d=T||u,_=R?{width:"6px",cursor:"col-resize",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,position:"relative"}:{height:"6px",cursor:"row-resize",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,position:"relative"},C=R?{width:"1px",height:"24px",borderRadius:"1px",background:d?"var(--havn-accent)":"var(--havn-border-light)",opacity:T?1:u?.6:.4,transition:"background 0.15s ease, opacity 0.15s ease"}:{height:"1px",width:"24px",borderRadius:"1px",background:d?"var(--havn-accent)":"var(--havn-border-light)",opacity:T?1:u?.6:.4,transition:"background 0.15s ease, opacity 0.15s ease"};return a.jsx("div",{"data-havn-resize-handle":"",style:_,onMouseDown:O,onMouseEnter:()=>N(!0),onMouseLeave:()=>N(!1),children:a.jsx("div",{style:C})})}function Gs(r,l,E,T){const[c,u]=A.useState(()=>{const R=localStorage.getItem(r);if(R){const O=parseInt(R,10);if(!isNaN(O))return Math.max(E,Math.min(T,O))}return l}),N=A.useRef(c),L=A.useCallback(()=>{N.current=c},[c]),I=A.useCallback(R=>{const O=Math.max(E,Math.min(T,N.current+R));u(O),localStorage.setItem(r,String(Math.round(O)))},[r,E,T]);return[c,I,L]}const em=50,tm={language:"sql",keywordCase:"upper",indentStyle:"standard"};function Pl(r){try{return G_(r,tm)}catch{return r}}function fd(){try{return JSON.parse(localStorage.getItem("dp_query_history")||"[]")}catch{return[]}}function Cd(r){localStorage.setItem("dp_query_history",JSON.stringify(r.slice(0,em)))}function nm({tables:r,onInsert:l}){const[E,T]=A.useState({}),c={};for(const I of r)c[I.schema]||(c[I.schema]=[]),c[I.schema].push(I);const u=["landing","bronze","silver","gold"],N=Object.keys(c).sort((I,R)=>{const O=u.indexOf(I),d=u.indexOf(R);return O!==-1&&d!==-1?O-d:O!==-1?-1:d!==-1?1:I.localeCompare(R)});async function L(I){if(E[I]){T(d=>({...d,[I]:null}));return}const[R,O]=I.split(".");try{const d=await Ee.describeTable(R,O);T(_=>({..._,[I]:d.columns||[]}))}catch{T(d=>({...d,[I]:[]}))}}return r.length===0?a.jsx("div",{style:_n.empty,children:"No tables in warehouse"}):a.jsxs("div",{style:_n.container,children:[a.jsx("div",{style:_n.header,children:"Tables"}),a.jsx("div",{style:_n.list,children:N.map(I=>a.jsxs("div",{children:[a.jsxs("div",{style:_n.schemaRow,children:[a.jsx("span",{style:_n.schemaName,children:I}),a.jsx("span",{style:_n.schemaCount,children:c[I].length})]}),c[I].map(R=>{const O=`${R.schema}.${R.name}`,d=E[O];return a.jsxs("div",{children:[a.jsxs("div",{style:_n.tableRow,children:[a.jsx("button",{onClick:()=>L(O),style:_n.expandBtn,children:d?"▾":"▸"}),a.jsx("button",{onClick:()=>l(O),style:_n.tableName,title:`Insert ${O}`,children:R.name})]}),d&&d.length>0&&a.jsx("div",{style:_n.colList,children:d.map(_=>a.jsxs("div",{style:_n.colItem,onClick:()=>l(_.name),title:`Insert ${_.name}`,children:[a.jsx("span",{style:_n.colName,children:_.name}),a.jsx("span",{style:_n.colType,children:_.type})]},_.name))})]},O)})]},I))})]})}const _n={container:{width:"100%",height:"100%",overflow:"auto",background:"var(--havn-bg-tertiary)",fontSize:"12px"},header:{padding:"8px 10px",fontWeight:600,fontSize:"11px",color:"var(--havn-text-secondary)",textTransform:"uppercase",letterSpacing:"0.3px",borderBottom:"1px solid var(--havn-border)"},list:{padding:"4px 0"},empty:{padding:"16px 10px",color:"var(--havn-text-dim)",fontSize:"12px",textAlign:"center"},schemaRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"5px 10px 2px",marginTop:"4px"},schemaName:{fontWeight:600,color:"var(--havn-accent)",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.3px"},schemaCount:{fontSize:"10px",color:"var(--havn-text-dim)"},tableRow:{display:"flex",alignItems:"center",padding:"2px 6px 2px 8px"},expandBtn:{background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"10px",padding:"2px 4px",width:"18px"},tableName:{background:"none",border:"none",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",fontFamily:"var(--havn-font-mono)",padding:"2px 4px",textAlign:"left",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},colList:{paddingLeft:"30px",paddingBottom:"2px"},colItem:{display:"flex",justifyContent:"space-between",gap:"6px",padding:"1px 8px",cursor:"pointer",borderRadius:"var(--havn-radius)"},colName:{fontFamily:"var(--havn-font-mono)",color:"var(--havn-text-secondary)",fontSize:"11px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},colType:{color:"var(--havn-text-dim)",fontSize:"10px",flexShrink:0}};function am({addOutput:r}){const[l,E]=A.useState(""),[T,c]=A.useState(null),[u,N]=A.useState(!1),[L,I]=A.useState(null),[R,O]=A.useState(fd),[d,_]=A.useState([]),[C,f]=A.useState(!1),[m,j]=A.useState("table"),W=A.useRef(null),P=A.useRef(null),Z=Ar(),[v,M,Te]=Gs("dp_query_sidebar_width",200,120,400),[B,se,w]=Gs("dp_query_editor_height",120,60,500),[$,J]=A.useState([]),[Ce,Ie]=A.useState(0),[ve,z]=A.useState(""),D=A.useRef({});A.useEffect(()=>{Ee.listTables().then(_).catch(Y=>console.warn("Failed to load tables:",Y.message)),Z("queryPanelOpened",!0)},[]);const oe=A.useRef(!1);A.useEffect(()=>{if(oe.current)return;const Y=window.__dp_prefill_query;if(!Y)return;oe.current=!0,delete window.__dp_prefill_query;const le=typeof Y=="string"?Y:Y.sql,he=typeof Y=="object"&&Y.run;E(Pl(le)),he&&setTimeout(async()=>{N(!0),I(null);try{const xe=await Ee.runQuery(le);c(xe);const ye=[{sql:le.trim(),ts:new Date().toISOString()},...fd().filter(_e=>_e.sql!==le.trim())];O(ye),Cd(ye),r("info",`Query: ${xe.rows.length} rows (${xe.columns.length} cols)`)}catch(xe){I(xe.message),r("error",`Query error: ${xe.message}`)}finally{N(!1)}},0)},[]),A.useEffect(()=>{if(!C)return;const Y=le=>{P.current&&!P.current.contains(le.target)&&f(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[C]);async function Oe(){if(l.trim()){N(!0),I(null);try{const Y=await Ee.runQuery(l);c(Y);const le=[{sql:l.trim(),ts:new Date().toISOString()},...R.filter(he=>he.sql!==l.trim())];O(le),Cd(le),r("info",`Query: ${Y.rows.length} rows (${Y.columns.length} cols)`)}catch(Y){I(Y.message),r("error",`Query error: ${Y.message}`)}finally{N(!1)}}}async function x(){if(l.trim()){N(!0),I(null);try{const Y=await Ee.explainQuery(l);c({columns:["Query Plan"],rows:Y.plan.split(`
`).map(le=>[le])}),r("info","EXPLAIN plan generated")}catch(Y){I(Y.message),r("error",`Explain error: ${Y.message}`)}finally{N(!1)}}}function y(){l.trim()&&E(Pl(l))}function p(Y){if($.length>0){if(Y.key==="ArrowDown"){Y.preventDefault(),Ie(le=>Math.min(le+1,$.length-1));return}if(Y.key==="ArrowUp"){Y.preventDefault(),Ie(le=>Math.max(le-1,0));return}if(Y.key==="Tab"||Y.key==="Enter"&&!Y.ctrlKey&&!Y.metaKey){Y.preventDefault(),H($[Ce]);return}if(Y.key==="Escape"){J([]);return}}(Y.ctrlKey||Y.metaKey)&&Y.key==="Enter"&&(Y.preventDefault(),Oe()),(Y.ctrlKey||Y.metaKey)&&Y.shiftKey&&Y.key==="F"&&(Y.preventDefault(),y())}function H(Y){const le=W.current;if(!le)return;const he=le.selectionStart,xe=l.substring(0,he-ve.length),ye=l.substring(he),_e=Y.insert,me=xe+_e+ye;E(me),J([]);const Ne=xe.length+_e.length;setTimeout(()=>{le.focus(),le.selectionStart=le.selectionEnd=Ne},0)}async function ne(Y,le){le==null&&(le=Y.length);const xe=Y.substring(0,le).match(/[\w.]+$/),ye=xe?xe[0]:"";if(ye.length<1){J([]);return}const _e=ye.indexOf(".");if(_e!==-1){const me=ye.substring(0,_e).toLowerCase(),Ne=ye.substring(_e+1).toLowerCase(),b=d.filter(De=>De.schema.toLowerCase()===me&&De.name.toLowerCase().startsWith(Ne)).slice(0,6).map(De=>({label:`${De.schema}.${De.name}`,insert:`${De.schema}.${De.name}`,kind:"table"})),K=d.find(De=>De.schema.toLowerCase()===me&&De.name.toLowerCase()===Ne);let Le=[];if(K){const De=`${K.schema}.${K.name}`;let ze=D.current[De];if(!ze)try{ze=(await Ee.describeTable(K.schema,K.name)).columns||[],D.current[De]=ze}catch{ze=[]}Le=ze.slice(0,8).map(Xe=>({label:`${Xe.name}  ${Xe.type}`,insert:Xe.name,kind:"column"}))}const Ge=[...b,...Le];z(ye),J(Ge),Ie(0)}else{const me=ye.toLowerCase(),Ne=d.filter(b=>b.schema.toLowerCase().startsWith(me)||b.name.toLowerCase().startsWith(me)||`${b.schema}.${b.name}`.toLowerCase().startsWith(me)).slice(0,8).map(b=>({label:`${b.schema}.${b.name}`,insert:`${b.schema}.${b.name}`,kind:"table"}));z(ye),J(Ne),Ie(0)}}function ae(Y){const le=W.current;if(!le){E(Ne=>Ne+(Ne?" ":"")+Y);return}const he=le.selectionStart,xe=le.selectionEnd,ye=l.substring(0,he),_e=l.substring(xe),me=ye+Y+_e;E(me),setTimeout(()=>{le.focus(),le.selectionStart=le.selectionEnd=he+Y.length},0)}function F(){if(d.length===0)return[];const Y=[],le=["gold","silver","bronze","landing"];for(const he of le){const xe=d.find(ye=>ye.schema===he);if(xe&&(Y.push({sql:Pl(`SELECT * FROM ${xe.schema}.${xe.name} LIMIT 10`),label:`Preview ${xe.schema}.${xe.name}`}),Y.length===1&&Y.push({sql:Pl(`SELECT COUNT(*) AS total FROM ${xe.schema}.${xe.name}`),label:`Count ${xe.schema}.${xe.name}`})),Y.length>=3)break}return Y.length<4&&Y.push({sql:Pl("SELECT table_schema, table_name FROM information_schema.tables WHERE table_schema NOT IN ('information_schema', '_dp_internal') ORDER BY table_schema, table_name"),label:"List all tables"}),Y}const te=F();return a.jsx("div",{style:qe.container,children:a.jsxs("div",{style:qe.main,children:[a.jsx("div",{"data-havn-hint":"query-sidebar",style:{display:"flex",flexDirection:"column",width:v,flexShrink:0},children:a.jsx(nm,{tables:d,onInsert:ae})}),a.jsx(bs,{direction:"horizontal",onResize:M,onResizeStart:Te}),a.jsxs("div",{style:qe.queryArea,children:[a.jsxs("div",{style:{...qe.editorWrapper,height:B},children:[a.jsx("textarea",{ref:W,value:l,onChange:Y=>{const le=Y.target.value,he=Y.target.selectionStart;E(le),ne(le,he)},onKeyDown:p,onBlur:()=>setTimeout(()=>J([]),150),placeholder:"Write SQL here...",style:{...qe.textarea,height:"calc(100% - 22px)",resize:"none"},spellCheck:!1}),a.jsxs("div",{style:qe.shortcutHint,children:[a.jsx("span",{style:qe.shortcutKey,children:"Ctrl+Enter"})," run  · ",a.jsx("span",{style:qe.shortcutKey,children:"Ctrl+Shift+F"})," format  · ",a.jsx("span",{style:qe.shortcutKey,children:"Tab"})," autocomplete"]})]}),$.length>0&&a.jsx("div",{style:qe.acDropdown,children:$.map((Y,le)=>a.jsxs("div",{onMouseDown:he=>{he.preventDefault(),H(Y)},style:le===Ce?qe.acItemActive:qe.acItem,children:[a.jsx("span",{style:qe.acKind,children:Y.kind==="column"?"col":"tbl"}),a.jsx("span",{style:qe.acLabel,children:Y.label})]},le))}),a.jsx(bs,{direction:"vertical",onResize:se,onResizeStart:w}),a.jsxs("div",{style:qe.toolbar,children:[a.jsxs("button",{onClick:Oe,disabled:u||!l.trim(),style:qe.runBtn,children:[u?"Running...":"Run"," ",a.jsx("span",{style:qe.shortcut,children:"Ctrl+Enter"})]}),a.jsx("button",{onClick:x,disabled:u||!l.trim(),style:qe.fmtBtn,title:"Show query execution plan",children:"Explain"}),a.jsxs("button",{onClick:y,disabled:!l.trim(),style:qe.fmtBtn,title:"Format SQL (Ctrl+Shift+F)",children:["Format ",a.jsx("span",{style:qe.shortcut,children:"Ctrl+Shift+F"})]}),a.jsxs("div",{ref:P,style:qe.historyWrapper,children:[a.jsxs("button",{onClick:()=>f(!C),style:qe.historyBtn,title:"Query history",children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5"}),a.jsx("path",{d:"M8 4.5V8l2.5 1.5"})]})," ",R.length>0&&a.jsx("span",{style:qe.historyCount,children:R.length})]}),C&&a.jsxs("div",{style:qe.historyDropdown,children:[a.jsx("div",{style:qe.historyHeader,children:"Recent Queries"}),R.length===0?a.jsx("div",{style:qe.historyEmpty,children:"No history yet"}):R.slice(0,20).map((Y,le)=>a.jsx("button",{onClick:()=>{E(Y.sql),f(!1)},style:qe.historyItem,onMouseEnter:he=>he.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:he=>he.currentTarget.style.background="none",children:a.jsxs("span",{style:qe.historySQL,children:[Y.sql.substring(0,80),Y.sql.length>80?"...":""]})},le))]})]}),T&&a.jsxs("div",{style:qe.viewToggle,children:[a.jsx("button",{onClick:()=>j("table"),style:m==="table"?qe.viewBtnActive:qe.viewBtn,children:"Table"}),a.jsx("button",{onClick:()=>j("chart"),style:m==="chart"?qe.viewBtnActive:qe.viewBtn,children:"Chart"})]})]}),!l.trim()&&te.length>0&&a.jsxs("div",{style:qe.suggestions,children:[a.jsx("span",{style:qe.suggestLabel,children:"Try:"}),te.map((Y,le)=>a.jsx("button",{onClick:()=>E(Y.sql),style:qe.suggestBtn,children:Y.label},le))]}),L&&a.jsxs("div",{style:qe.error,children:[a.jsx("span",{style:qe.errorLabel,children:"Error"}),L]}),T&&a.jsxs("div",{style:qe.results,children:[a.jsx("div",{style:qe.resultsHeader,children:a.jsxs("span",{children:[T.rows.length," row",T.rows.length!==1?"s":"",", ",T.columns.length," column",T.columns.length!==1?"s":""]})}),a.jsx("div",{style:qe.resultsBody,children:m==="table"?a.jsx(Fs,{columns:T.columns,rows:T.rows}):a.jsx(z_,{columns:T.columns,rows:T.rows})})]})]})]})})}const qe={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},main:{display:"flex",flex:1,overflow:"hidden"},queryArea:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},toolbar:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderBottom:"1px solid var(--havn-border)",flexShrink:0},runBtn:{padding:"5px 14px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,display:"flex",alignItems:"center",gap:"6px"},shortcut:{fontSize:"10px",opacity:.7},fmtBtn:{padding:"5px 10px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",fontWeight:500,display:"flex",alignItems:"center",gap:"6px"},historyWrapper:{position:"relative"},historyBtn:{background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text-secondary)",cursor:"pointer",padding:"4px 8px",fontSize:"14px",display:"flex",alignItems:"center",gap:"4px"},historyCount:{fontSize:"10px",background:"var(--havn-bg-tertiary)",padding:"0 5px",borderRadius:"8px",color:"var(--havn-text-dim)",fontWeight:500},historyDropdown:{position:"absolute",top:"100%",left:0,marginTop:"4px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius)",zIndex:100,width:"400px",maxHeight:"300px",overflow:"auto",boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},historyHeader:{padding:"6px 12px",fontSize:"11px",fontWeight:600,color:"var(--havn-text-secondary)",borderBottom:"1px solid var(--havn-border)"},historyEmpty:{padding:"16px",color:"var(--havn-text-dim)",fontSize:"12px",textAlign:"center"},historyItem:{display:"block",width:"100%",padding:"6px 12px",background:"none",border:"none",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",cursor:"pointer",textAlign:"left",fontSize:"12px"},historySQL:{fontFamily:"var(--havn-font-mono)",fontSize:"11px",color:"var(--havn-text)",display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},viewToggle:{display:"flex",marginLeft:"auto",gap:"1px",background:"var(--havn-border)",borderRadius:"var(--havn-radius-lg)",overflow:"hidden"},viewBtn:{padding:"3px 10px",background:"var(--havn-btn-bg)",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px",fontWeight:500},viewBtnActive:{padding:"3px 10px",background:"var(--havn-bg-secondary)",border:"none",color:"var(--havn-text)",cursor:"pointer",fontSize:"11px",fontWeight:600},editorWrapper:{flexShrink:0},textarea:{width:"100%",height:"100%",padding:"10px 12px",background:"var(--havn-bg)",border:"none",color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"13px",resize:"none",outline:"none",boxSizing:"border-box",lineHeight:1.5,display:"block"},shortcutHint:{height:"22px",display:"flex",alignItems:"center",padding:"0 10px",gap:"2px",fontSize:"10px",color:"var(--havn-text-dim)",background:"var(--havn-bg)",borderTop:"1px solid var(--havn-border)"},shortcutKey:{background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"3px",padding:"0 4px",fontSize:"10px",fontFamily:"var(--havn-font-mono)",color:"var(--havn-text-secondary)"},acDropdown:{maxHeight:"180px",overflow:"auto",background:"var(--havn-bg-secondary)",borderBottom:"1px solid var(--havn-border)",flexShrink:0},acItem:{display:"flex",alignItems:"center",gap:"8px",padding:"5px 10px",cursor:"pointer",fontSize:"12px"},acItemActive:{display:"flex",alignItems:"center",gap:"8px",padding:"5px 10px",cursor:"pointer",fontSize:"12px",background:"var(--havn-btn-bg)"},acKind:{fontSize:"9px",fontFamily:"var(--havn-font-mono)",color:"var(--havn-text-dim)",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border)",borderRadius:"3px",padding:"0 4px",flexShrink:0,width:"22px",textAlign:"center"},acLabel:{fontFamily:"var(--havn-font-mono)",color:"var(--havn-text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},suggestions:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",flexWrap:"wrap",borderBottom:"1px solid var(--havn-border)"},suggestLabel:{fontSize:"11px",color:"var(--havn-text-dim)",fontWeight:500},suggestBtn:{padding:"3px 10px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-accent)",cursor:"pointer",fontSize:"11px",fontWeight:500},error:{padding:"8px 12px",background:"rgba(255,0,0,0.05)",borderBottom:"1px solid var(--havn-red)",color:"var(--havn-red)",fontSize:"12px",fontFamily:"var(--havn-font-mono)",whiteSpace:"pre-wrap"},errorLabel:{fontWeight:600,marginRight:"8px"},results:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},resultsHeader:{padding:"6px 12px",fontSize:"11px",color:"var(--havn-text-secondary)",borderBottom:"1px solid var(--havn-border)",flexShrink:0},resultsBody:{flex:1,overflow:"auto",display:"flex",flexDirection:"column"}};function rm({selectedTable:r,onQueryTable:l}){const[E,T]=A.useState([]),[c,u]=A.useState(null),[N,L]=A.useState(!1),[I,R]=A.useState(null),[O,d]=A.useState(null),[_,C]=A.useState(null),[f,m]=A.useState("ASC"),[j,W]=A.useState(null),[P,Z]=A.useState(!1),v=Ar(),M=A.useRef(!1);A.useEffect(()=>{r&&!M.current&&(M.current=!0,v("firstTableSelected",!0))},[r]),A.useEffect(()=>{if(!r){T([]),u(null),d(null),C(null),W(null);return}const[$,J]=r.split(".");L(!0),R(null),d(null),C(null),W(null),Promise.all([Ee.describeTable($,J),Ee.runQuery(`SELECT * FROM ${$}.${J} LIMIT 100`),Ee.runQuery(`SELECT COUNT(*) AS cnt FROM ${$}.${J}`)]).then(([Ce,Ie,ve])=>{T(Ce.columns),u(Ie),ve.rows&&ve.rows[0]&&d(ve.rows[0][0])}).catch(Ce=>R(Ce.message||"Failed to load table data")).finally(()=>L(!1))},[r]);function Te($){if(!r)return;const[J,Ce]=r.split("."),Ie=_===$&&f==="ASC"?"DESC":"ASC";C($),m(Ie),L(!0),Ee.runQuery(`SELECT * FROM ${J}.${Ce} ORDER BY "${$}" ${Ie} LIMIT 100`).then(ve=>u(ve)).catch(ve=>R(ve.message||"Failed to sort table")).finally(()=>L(!1))}async function B(){if(!r||P)return;Z(!0);const[$,J]=r.split("."),Ce=E.filter(ve=>/int|float|double|decimal|numeric|bigint|smallint|tinyint|real/i.test(ve.type));if(Ce.length===0){W([]),Z(!1);return}const Ie=Ce.map(ve=>`MIN("${ve.name}") AS "${ve.name}_min", MAX("${ve.name}") AS "${ve.name}_max", SUM(CASE WHEN "${ve.name}" IS NULL THEN 1 ELSE 0 END) AS "${ve.name}_nulls"`).join(", ");try{const ve=await Ee.runQuery(`SELECT ${Ie} FROM ${$}.${J}`);if(ve.rows&&ve.rows[0]){const z=ve.rows[0],D=Ce.map((oe,Oe)=>({name:oe.name,type:oe.type,min:z[Oe*3],max:z[Oe*3+1],nulls:z[Oe*3+2]}));W(D)}}catch{W([])}finally{Z(!1)}}function se(){if(!r||!l)return;const[$,J]=r.split(".");l($,J)}if(!r)return a.jsx("div",{style:pt.placeholder,children:"Select a table from the sidebar to view its schema and data."});if(N&&!c)return a.jsx("div",{style:pt.placeholder,children:"Loading..."});if(I)return a.jsx("div",{style:{...pt.placeholder,color:"var(--havn-red)"},children:I});function w($){return $==null?"":$>=1e6?`${($/1e6).toFixed(1)}M rows`:$>=1e3?`${($/1e3).toFixed(1)}K rows`:`${$} row${$!==1?"s":""}`}return a.jsxs("div",{style:pt.container,children:[a.jsxs("div",{style:pt.tableHeader,children:[a.jsx("strong",{style:pt.selectedName,children:r}),a.jsxs("span",{style:pt.colCount,children:[E.length," columns"]}),O!=null&&a.jsx("span",{style:pt.rowCount,children:w(O)}),a.jsxs("div",{style:pt.headerActions,children:[l&&a.jsx("button",{onClick:se,style:pt.actionBtn,children:"Query this table"}),a.jsx("button",{onClick:B,disabled:P,style:pt.actionBtn,children:P?"Loading...":j?"Refresh Stats":"Show Stats"})]})]}),a.jsx("div",{style:pt.columnsBar,"data-havn-hint":"columns-bar",children:E.map($=>a.jsxs("button",{onClick:()=>Te($.name),style:{...pt.colChip,..._===$.name?pt.colChipActive:{}},title:`Sort by ${$.name}`,children:[$.name," ",a.jsx("span",{style:pt.colType,children:$.type}),_===$.name&&a.jsx("span",{style:pt.sortArrow,children:f==="ASC"?" ↑":" ↓"})]},$.name))}),j&&j.length>0&&a.jsxs("div",{style:pt.statsBar,children:[a.jsx("span",{style:pt.statsLabel,children:"Stats (numeric columns)"}),a.jsx("div",{style:pt.statsList,children:j.map($=>a.jsxs("div",{style:pt.statItem,children:[a.jsx("span",{style:pt.statName,children:$.name}),a.jsxs("span",{style:pt.statVal,children:["min: ",$.min??"NULL"]}),a.jsxs("span",{style:pt.statVal,children:["max: ",$.max??"NULL"]}),a.jsxs("span",{style:pt.statVal,children:["nulls: ",$.nulls]})]},$.name))})]}),j&&j.length===0&&a.jsx("div",{style:pt.statsBar,children:a.jsx("span",{style:pt.statsLabel,children:"No numeric columns for stats"})}),c&&a.jsx("div",{style:pt.previewWrap,children:a.jsx(Fs,{columns:c.columns,rows:c.rows,columnTypes:E.map($=>$.type)})})]})}const pt={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"auto",padding:"12px"},placeholder:{color:"var(--havn-text-dim)",padding:"24px",textAlign:"center"},tableHeader:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",fontSize:"13px",flexWrap:"wrap",borderBottom:"1px solid var(--havn-border)"},selectedName:{fontFamily:"var(--havn-font-mono)"},colCount:{color:"var(--havn-text-secondary)",fontSize:"12px"},rowCount:{color:"var(--havn-text-dim)",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},headerActions:{marginLeft:"auto",display:"flex",gap:"6px"},actionBtn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"11px",fontWeight:500},columnsBar:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"4px 8px 12px"},colChip:{background:"var(--havn-btn-bg)",border:"1px solid var(--havn-border)",padding:"3px 8px",borderRadius:"var(--havn-radius)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",cursor:"pointer",color:"var(--havn-text)"},colChipActive:{borderColor:"var(--havn-accent)",color:"var(--havn-accent)",fontWeight:600},colType:{color:"var(--havn-text-secondary)",marginLeft:"2px"},sortArrow:{color:"var(--havn-accent)",fontWeight:700},statsBar:{padding:"8px 8px 12px",borderTop:"1px solid var(--havn-border)",marginBottom:"4px"},statsLabel:{fontSize:"11px",color:"var(--havn-text-secondary)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px"},statsList:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"6px"},statItem:{display:"flex",gap:"8px",padding:"4px 10px",background:"var(--havn-bg-tertiary)",borderRadius:"var(--havn-radius)",fontSize:"11px",fontFamily:"var(--havn-font-mono)"},statName:{fontWeight:600,color:"var(--havn-text)"},statVal:{color:"var(--havn-text-secondary)"},previewWrap:{overflow:"auto",flex:1}};function sm({onOpenFile:r}){const[l,E]=A.useState([]),[T,c]=A.useState(!0),[u,N]=A.useState(null);A.useEffect(()=>{L()},[]);async function L(){c(!0),N(null);try{const I=await Ee.getHistory(100);E(I)}catch(I){N(I.message||"Failed to load history")}c(!1)}return a.jsxs("div",{style:vt.container,children:[a.jsx("div",{style:vt.header,children:a.jsx("button",{onClick:L,style:vt.refreshBtn,children:"Refresh"})}),T&&a.jsx("div",{style:vt.loading,children:"Loading..."}),!T&&u&&a.jsx("div",{style:vt.error,children:u}),!T&&!u&&l.length===0&&a.jsx("div",{style:vt.empty,children:"No runs yet. Execute a pipeline to see history here."}),!T&&l.length>0&&a.jsx("div",{style:vt.tableWrap,children:a.jsxs("table",{style:vt.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:vt.th,children:"Type"}),a.jsx("th",{style:vt.th,children:"Target"}),a.jsx("th",{style:vt.th,children:"Status"}),a.jsx("th",{style:vt.th,children:"Time"}),a.jsx("th",{style:vt.th,children:"Duration"}),a.jsx("th",{style:vt.th,children:"Rows"}),a.jsx("th",{style:vt.th,children:"Error"})]})}),a.jsx("tbody",{children:l.map(I=>a.jsxs("tr",{children:[a.jsx("td",{style:vt.td,children:a.jsx("span",{style:vt.typeBadge,children:I.run_type})}),a.jsx("td",{style:{...vt.td,fontFamily:"var(--havn-font-mono)",fontWeight:500},children:r&&I.target?a.jsx("span",{style:vt.fileLink,onClick:()=>r(I.target,1,1),onMouseEnter:R=>{R.currentTarget.style.color="var(--havn-accent)",R.currentTarget.style.textDecoration="underline"},onMouseLeave:R=>{R.currentTarget.style.color="",R.currentTarget.style.textDecoration=""},title:`Open ${I.target}`,children:I.target}):I.target}),a.jsx("td",{style:vt.td,children:a.jsx("span",{style:{...vt.statusBadge,background:I.status==="success"?"color-mix(in srgb, var(--havn-green) 12%, transparent)":"color-mix(in srgb, var(--havn-red) 12%, transparent)",color:I.status==="success"?"var(--havn-green)":"var(--havn-red)"},children:I.status})}),a.jsx("td",{style:{...vt.td,color:"var(--havn-text-secondary)"},children:I.started_at?I.started_at.slice(0,19).replace("T"," "):""}),a.jsx("td",{style:{...vt.td,textAlign:"right",fontFamily:"var(--havn-font-mono)"},children:I.duration_ms!=null?`${I.duration_ms}ms`:""}),a.jsx("td",{style:{...vt.td,textAlign:"right",fontFamily:"var(--havn-font-mono)"},children:I.rows_affected||""}),a.jsx("td",{style:{...vt.td,color:"var(--havn-red)",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.error||""})]},I.run_id))})]})})]})}const vt={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},refreshBtn:{background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",padding:"4px 12px",cursor:"pointer",fontSize:"11px",fontWeight:500},loading:{padding:"24px",color:"var(--havn-text-secondary)",textAlign:"center"},empty:{padding:"24px",color:"var(--havn-text-dim)",textAlign:"center"},error:{padding:"24px",color:"var(--havn-red)",textAlign:"center"},tableWrap:{flex:1,overflow:"auto"},table:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},th:{textAlign:"left",padding:"6px 12px",borderBottom:"2px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600,position:"sticky",top:0,background:"var(--havn-bg)"},td:{padding:"5px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",fontSize:"12px"},typeBadge:{background:"var(--havn-btn-bg)",padding:"2px 8px",borderRadius:"var(--havn-radius)",fontSize:"11px",fontWeight:500,textTransform:"capitalize"},statusBadge:{padding:"2px 8px",borderRadius:"var(--havn-radius)",fontSize:"11px",fontWeight:600},fileLink:{cursor:"pointer",transition:"color 0.15s"}},cr={landing:"#8b949e",bronze:"#d2a04a",silver:"#8b949e",gold:"#e3b341",source:"#484f58",ingest:"#58a6ff",import:"#bc8cff",seed:"#92400e",exposure:"#7c3aed"},Gn=160,Rn=56,Ul=220,So=78;function ta(r){return getComputedStyle(document.documentElement).getPropertyValue(r).trim()}function lm(r,l){if(l==null||r==null)return null;const E=r-l;return E===0?null:`${E>0?"+":""}${E.toLocaleString()}`}function im(r,l){const E={},T={},c={};for(const P of r)E[P.id]=[],T[P.id]=[],c[P.id]=0;for(const P of l)E[P.source]&&E[P.source].push(P.target),T[P.target]&&T[P.target].push(P.source),c[P.target]!==void 0&&c[P.target]++;const u={},N=r.filter(P=>c[P.id]===0).map(P=>P.id);for(const P of N)u[P]=0;const L=new Set,I=[...N];for(;I.length>0;){const P=I.shift();if(!L.has(P)){L.add(P);for(const Z of E[P]||[])u[Z]=Math.max(u[Z]||0,(u[P]||0)+1),c[Z]--,c[Z]===0&&I.push(Z)}}const R={};for(const P of r){const Z=u[P.id]||0;R[Z]||(R[Z]=[]),R[Z].push(P)}const O=Math.max(...Object.keys(R).map(Number),0),d={};for(let P=0;P<=O;P++)(R[P]||[]).forEach((v,M)=>{d[v.id]=M});for(let P=0;P<4;P++)if(P%2===0)for(let Z=1;Z<=O;Z++){const v=R[Z]||[];for(const M of v){const Te=T[M.id]||[];Te.length>0&&(d[M.id]=Te.reduce((B,se)=>B+(d[se]||0),0)/Te.length)}v.sort((M,Te)=>(d[M.id]||0)-(d[Te.id]||0)),v.forEach((M,Te)=>{d[M.id]=Te}),R[Z]=v}else for(let Z=O-1;Z>=0;Z--){const v=R[Z]||[];for(const M of v){const Te=E[M.id]||[];Te.length>0&&(d[M.id]=Te.reduce((B,se)=>B+(d[se]||0),0)/Te.length)}v.sort((M,Te)=>(d[M.id]||0)-(d[Te.id]||0)),v.forEach((M,Te)=>{d[M.id]=Te}),R[Z]=v}const _={},f=80+Math.max(...Object.values(R).map(P=>P.length),1)*(Rn+So);for(let P=0;P<=O;P++){const Z=R[P]||[],v=Z.length*(Rn+So)-So,M=Math.max(40,(f-v)/2);Z.forEach((Te,B)=>{_[Te.id]={x:60+P*Ul,y:M+B*(Rn+So)}})}const m={},j=20;for(const P of l){const Z=u[P.source]||0,v=u[P.target]||0,M=v-Z;if(M<2)continue;const Te=_[P.source],B=_[P.target];if(!Te||!B)continue;const se=Te.y+Rn/2,w=B.y+Rn/2,$=[];for(let J=Z+1;J<v;J++){const Ce=60+J*Ul,Ie=Ce-(Ul-Gn)/2,ve=Ce+Gn+(Ul-Gn)/2,z=(J-Z)/M,D=se+(w-se)*z,oe=R[J]||[];let Oe=!1;for(const te of oe){const Y=_[te.id];if(Y&&D>=Y.y-j&&D<=Y.y+Rn+j){Oe=!0;break}}if(!Oe){$.push({x:Ie,y:D}),$.push({x:ve,y:D});continue}const x=oe.map(te=>_[te.id].y).sort((te,Y)=>te-Y);let y=null,p=1/0;const H=x[0]-j-5;if(H>0){const te=Math.abs(D-H);te<p&&(p=te,y=H)}for(let te=0;te<x.length-1;te++){const Y=x[te]+Rn+j,le=x[te+1]-j;if(le>Y){const he=(Y+le)/2,xe=Math.abs(D-he);xe<p&&(p=xe,y=he)}}const ne=x[x.length-1]+Rn+j+5,ae=Math.abs(D-ne);ae<p&&(p=ae,y=ne);const F=y??D;$.push({x:Ie,y:F}),$.push({x:ve,y:F})}$.length>0&&(m[P.source+"|"+P.target]=$)}const W=120+(O+1)*Ul;return{positions:_,width:W,height:f,edgeRoutes:m}}function om({modelName:r,runId:l,runs:E,snapshotsByRun:T,onClose:c,onRestore:u,showConfirm:N}){var j,W;const[L,I]=A.useState(null),[R,O]=A.useState(!1),[d,_]=A.useState(!1),C=(j=T==null?void 0:T[l])==null?void 0:j[r];A.useEffect(()=>{if(!l||!r||!(C!=null&&C.file_path)){I(null);return}O(!0),Ee.getSnapshotSample(l,r,50).then(I).catch(()=>I(null)).finally(()=>O(!1))},[l,r]);const f=A.useMemo(()=>!E||!T?[]:E.slice().reverse().map(P=>{var v;const Z=(v=T[P.run_id])==null?void 0:v[r];return Z?{run_id:P.run_id,ts:P.started_at,row_count:Z.row_count}:null}).filter(Boolean),[E,T,r]);async function m(){if(!(N&&!await N("Restore Snapshot",`Restore ${r} from this run? Downstream models will be re-built.`,"Restore",!0))&&!(!N&&!confirm(`Restore ${r} from this run? Downstream models will be re-built.`))){_(!0);try{await u(l,r)}finally{_(!1)}}}return a.jsxs("div",{style:ut.panel,children:[a.jsxs("div",{style:ut.panelHeader,children:[a.jsx("span",{style:ut.panelTitle,children:r}),a.jsx("button",{onClick:c,style:ut.closeBtn,children:"x"})]}),C?a.jsxs("div",{style:ut.panelBody,children:[a.jsxs("div",{style:ut.statRow,children:[a.jsx("span",{style:ut.statLabel,children:"Rows"}),a.jsx("span",{style:ut.statValue,children:(W=C.row_count)==null?void 0:W.toLocaleString()})]}),a.jsxs("div",{style:ut.statRow,children:[a.jsx("span",{style:ut.statLabel,children:"Columns"}),a.jsx("span",{style:ut.statValue,children:C.col_count})]}),a.jsxs("div",{style:ut.statRow,children:[a.jsx("span",{style:ut.statLabel,children:"Size"}),a.jsx("span",{style:ut.statValue,children:C.size_bytes<1048576?`${(C.size_bytes/1024).toFixed(1)} KB`:`${(C.size_bytes/1048576).toFixed(1)} MB`})]}),a.jsxs("div",{style:ut.statRow,children:[a.jsx("span",{style:ut.statLabel,children:"Status"}),a.jsx("span",{style:{...ut.statValue,color:C.file_path?"var(--havn-green)":"var(--havn-text-dim)"},children:C.file_path?"Restorable":"Expired"})]}),f.length>1&&a.jsxs("div",{style:ut.histSection,children:[a.jsx("span",{style:ut.statLabel,children:"Row count history"}),a.jsx("div",{style:ut.sparkContainer,children:(()=>{const P=f.map(Te=>Te.row_count),Z=Math.max(...P,1),v=200,M=40;return a.jsx("svg",{width:v,height:M,style:{display:"block"},children:a.jsx("polyline",{fill:"none",stroke:"var(--havn-accent, #58a6ff)",strokeWidth:"1.5",points:P.map((Te,B)=>`${B/(P.length-1)*v},${M-Te/Z*(M-4)-2}`).join(" ")})})})()})]}),R&&a.jsx("div",{style:ut.loadingText,children:"Loading sample..."}),L&&L.columns&&L.rows&&L.rows.length>0&&a.jsxs("div",{style:ut.sampleSection,children:[a.jsx("span",{style:ut.statLabel,children:"Sample data"}),a.jsx("div",{style:ut.sampleTable,children:a.jsxs("table",{style:ut.table,children:[a.jsx("thead",{children:a.jsx("tr",{children:L.columns.map((P,Z)=>a.jsx("th",{style:ut.th,children:P},Z))})}),a.jsx("tbody",{children:L.rows.slice(0,10).map((P,Z)=>a.jsx("tr",{children:P.map((v,M)=>a.jsx("td",{style:ut.td,children:v??""},M))},Z))})]})})]}),C.file_path&&a.jsx("button",{onClick:m,disabled:d,style:ut.restoreBtn,children:d?"Restoring...":"Restore to this point"})]}):a.jsx("div",{style:ut.panelBody,children:a.jsx("div",{style:ut.loadingText,children:"No snapshot for this model at this run."})})]})}const ut={panel:{width:320,borderLeft:"1px solid var(--havn-border)",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--havn-bg-secondary)"},panelHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},panelTitle:{fontWeight:600,fontSize:13},closeBtn:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:14,padding:"2px 6px"},panelBody:{flex:1,overflow:"auto",padding:"10px 12px",fontSize:12},statRow:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderBottom:"1px solid var(--havn-border-light)"},statLabel:{color:"var(--havn-text-secondary)",fontSize:11,fontWeight:500},statValue:{fontWeight:600,fontSize:12},histSection:{marginTop:12},sparkContainer:{marginTop:4},sampleSection:{marginTop:12},sampleTable:{marginTop:4,overflow:"auto",maxHeight:200,border:"1px solid var(--havn-border-light)",borderRadius:4},table:{width:"100%",borderCollapse:"collapse",fontSize:10},th:{textAlign:"left",padding:"3px 6px",background:"var(--havn-bg-tertiary)",borderBottom:"1px solid var(--havn-border-light)",position:"sticky",top:0,fontWeight:600},td:{padding:"2px 6px",borderBottom:"1px solid var(--havn-border-light)",maxWidth:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},restoreBtn:{marginTop:12,padding:"4px 12px",background:"var(--havn-green)",color:"#fff",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500,width:"100%"},loadingText:{color:"var(--havn-text-dim)",fontStyle:"italic",padding:"8px 0"}};function Em({onOpenFile:r,showConfirm:l}){var oe,Oe;const E=A.useRef(null),[T,c]=A.useState(null),[u,N]=A.useState(null),L=Ar(),[I,R]=A.useState(null),[O,d]=A.useState("basic"),[_,C]=A.useState(null),[f,m]=A.useState([]),[j,W]=A.useState([]),[P,Z]=A.useState(-1),[v,M]=A.useState(!1);A.useEffect(()=>{R(null),O==="full"?(Ee.getFullDAG?Ee.getFullDAG():Promise.reject(new Error("not available"))).then(c).catch(()=>{Ee.getDAG().then(c).catch(x=>R(x.message||"Failed to load DAG"))}):Ee.getDAG().then(c).catch(x=>R(x.message||"Failed to load DAG")),L("dagOpened",!0)},[O]),A.useEffect(()=>{v&&Promise.all([Ee.getRewindRuns(),Ee.getRewindSnapshots()]).then(([x,y])=>{m(x),W(y),x.length>0&&Z(0)}).catch(()=>{})},[v]);const Te=A.useMemo(()=>{const x={};for(const y of j)x[y.run_id]||(x[y.run_id]={}),x[y.run_id][y.model_name]=y;return x},[j]),B=(oe=f[P])==null?void 0:oe.run_id,se=(Oe=f[P+1])==null?void 0:Oe.run_id,w=Te[B]||{},$=Te[se]||{},J=A.useMemo(()=>!T||T.nodes.length===0?null:im(T.nodes,T.edges),[T]),Ce=A.useCallback(()=>{var ye;if(!J||!E.current)return;const x=E.current,y=x.getContext("2d"),{nodes:p,edges:H}=T,{positions:ne,width:ae,height:F,edgeRoutes:te}=J,Y=window.devicePixelRatio||1;x.width=ae*Y,x.height=F*Y,x.style.width=ae+"px",x.style.height=F+"px",y.scale(Y,Y),y.clearRect(0,0,ae,F);let le=null;if(u){le=new Set([u]);const _e=[u];for(;_e.length>0;){const Ne=_e.pop();for(const b of H)b.target===Ne&&!le.has(b.source)&&(le.add(b.source),_e.push(b.source))}const me=[u];for(;me.length>0;){const Ne=me.pop();for(const b of H)b.source===Ne&&!le.has(b.target)&&(le.add(b.target),me.push(b.target))}}for(const _e of H){const me=ne[_e.source],Ne=ne[_e.target];if(!me||!Ne)continue;const b=le?le.has(_e.source)&&le.has(_e.target):!1;y.strokeStyle=ta(b?"--havn-accent":"--havn-border-light"),y.lineWidth=b?2:1.5,y.globalAlpha=b?1:u?.3:.8;const K=me.x+Gn,Le=me.y+Rn/2,Ge=Ne.x,De=Ne.y+Rn/2,ze=_e.source+"|"+_e.target,Xe=te[ze];if(Xe&&Xe.length>0){const et=[{x:K,y:Le},...Xe,{x:Ge,y:De}];y.beginPath(),y.moveTo(et[0].x,et[0].y);const Xt=.5;for(let st=0;st<et.length-1;st++){const Gt=et[Math.max(st-1,0)],Bt=et[st],Ht=et[st+1],Pt=et[Math.min(st+2,et.length-1)],mn=Bt.x+(Ht.x-Gt.x)/(6/Xt),vn=Bt.y+(Ht.y-Gt.y)/(6/Xt),dr=Ht.x-(Pt.x-Bt.x)/(6/Xt),Ha=Ht.y-(Pt.y-Bt.y)/(6/Xt);y.bezierCurveTo(mn,vn,dr,Ha,Ht.x,Ht.y)}y.stroke()}else{y.beginPath();const et=(K+Ge)/2;y.moveTo(K,Le),y.bezierCurveTo(et,Le,et,De,Ge,De),y.stroke()}y.fillStyle=y.strokeStyle,y.beginPath(),y.moveTo(Ge,De),y.lineTo(Ge-8,De-4),y.lineTo(Ge-8,De+4),y.closePath(),y.fill()}y.globalAlpha=1;const he=ta("--havn-font")||"-apple-system, sans-serif",xe=ta("--havn-font-mono")||"monospace";for(const _e of p){const me=ne[_e.id];if(!me)continue;const Ne=cr[_e.schema]||ta("--havn-accent"),b=u===_e.id,K=_===_e.id,Le=_e.type==="table",Ge=v?w[_e.id]:null,De=v?$[_e.id]:null;le&&!b?y.globalAlpha=le.has(_e.id)?1:.25:y.globalAlpha=1,y.fillStyle=ta(b||K?"--havn-bg":"--havn-bg-secondary"),y.strokeStyle=K?ta("--havn-accent"):Ne,y.lineWidth=b||K?2.5:Le?2:1.5;const ze=6;if((b||K)&&(y.shadowColor=K?ta("--havn-accent"):Ne,y.shadowBlur=12,y.shadowOffsetX=0,y.shadowOffsetY=2),y.beginPath(),y.roundRect(me.x,me.y,Gn,Rn,ze),y.fill(),y.stroke(),y.shadowColor="transparent",y.shadowBlur=0,y.fillStyle=ta(b?"--havn-accent":"--havn-text"),y.font=`500 11px ${he}`,y.textAlign="center",y.textBaseline="middle",y.fillText(_e.label,me.x+Gn/2,me.y+16,Gn-20),v&&Ge){const Xe=((ye=Ge.row_count)==null?void 0:ye.toLocaleString())??"?";y.fillStyle="var(--havn-text-secondary, #8b949e)",y.font=`500 10px ${xe}`,y.textAlign="center",y.fillText(`${Xe} rows`,me.x+Gn/2,me.y+Rn-14,Gn-16);const et=lm(Ge.row_count,De==null?void 0:De.row_count);et&&(y.fillStyle=et.startsWith("+")?"#3fb950":"#f85149",y.font=`bold 9px ${xe}`,y.textAlign="right",y.fillText(et,me.x+Gn-6,me.y+Rn-4)),De&&Ge.schema_hash&&De.schema_hash&&Ge.schema_hash!==De.schema_hash&&(y.fillStyle="#d29922",y.beginPath(),y.arc(me.x+10,me.y+10,4,0,Math.PI*2),y.fill()),Ge.file_path||(y.globalAlpha=.5,y.fillStyle="#8b949e",y.font=`9px ${xe}`,y.textAlign="left",y.fillText("expired",me.x+4,me.y+Rn-4),y.globalAlpha=1)}else if(!v){const Xe=_e.type==="ingest"?"I":_e.type==="import"?"↑":_e.type==="source"?"S":_e.type==="seed"?"D":_e.type==="exposure"?"E":_e.type==="table"?"T":"V";y.fillStyle=Ne,y.font=`bold 9px ${xe}`,y.textAlign="right",y.fillText(Xe,me.x+Gn-6,me.y+12)}}y.globalAlpha=1},[T,J,u,v,w,$,_]);A.useEffect(()=>{Ce()},[Ce]);function Ie(x){if(!J||!E.current)return;const y=E.current.getBoundingClientRect(),p=(x.clientX-y.left)*(E.current.width/y.width/(window.devicePixelRatio||1)),H=(x.clientY-y.top)*(E.current.height/y.height/(window.devicePixelRatio||1)),{positions:ne}=J;let ae=null;for(const F of T.nodes){const te=ne[F.id];if(te&&p>=te.x&&p<=te.x+Gn&&H>=te.y&&H<=te.y+Rn){ae=F.id;break}}N(ae),E.current.style.cursor=ae?"pointer":"default"}function ve(x){if(!J||!E.current)return;const y=E.current.getBoundingClientRect(),p=(x.clientX-y.left)*(E.current.width/y.width/(window.devicePixelRatio||1)),H=(x.clientY-y.top)*(E.current.height/y.height/(window.devicePixelRatio||1)),{positions:ne}=J;for(const ae of T.nodes){const F=ne[ae.id];if(F&&p>=F.x&&p<=F.x+Gn&&H>=F.y&&H<=F.y+Rn){v?C(_===ae.id?null:ae.id):r&&ae.path&&r(ae.path);return}}C(null)}async function z(x,y){try{const p=await Ee.restoreSnapshot(x,y,!0);if(p.status==="success"){alert(`Restored ${y}. ${p.cascade_results?Object.keys(p.cascade_results).length+" downstream models rebuilt.":""}`);const[H,ne]=await Promise.all([Ee.getRewindRuns(),Ee.getRewindSnapshots()]);m(H),W(ne)}}catch(p){alert("Restore failed: "+(p.message||p))}}if(I)return a.jsx("div",{style:{padding:"24px",color:"var(--havn-red)",textAlign:"center"},children:I});if(!T)return a.jsx("div",{style:xt.loading,children:"Loading DAG..."});if(T.nodes.length===0)return a.jsx("div",{style:xt.empty,children:"No models found. Add SQL files to transform/ to see the DAG."});const D=f[P];return a.jsxs("div",{style:xt.container,children:[a.jsx("div",{style:xt.header,children:a.jsxs("div",{style:xt.headerRight,children:[!v&&a.jsxs("div",{style:xt.legend,children:[a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.import}}),"imported"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.ingest}}),"ingest"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.bronze}}),"bronze"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.silver}}),"silver"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.gold}}),"gold"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.seed}}),"seed"]}),a.jsxs("span",{style:xt.legendItem,children:[a.jsx("span",{style:{...xt.legendDot,background:cr.exposure}}),"exposure"]})]}),!v&&a.jsx("div",{style:{display:"flex",gap:4,alignItems:"center"},children:["basic","full"].map(x=>a.jsx("button",{onClick:()=>d(x),style:{padding:"4px 12px",borderRadius:"var(--havn-radius-lg)",fontSize:11,cursor:"pointer",fontWeight:500,background:O===x?"var(--havn-accent)":"var(--havn-btn-bg)",color:O===x?"#fff":"var(--havn-text)",border:O===x?"1px solid var(--havn-accent)":"1px solid var(--havn-btn-border)"},children:x==="basic"?"Basic":"Full"},x))}),a.jsx("button",{onClick:()=>{M(!v),C(null)},style:{...xt.rewindBtn,background:v?"var(--havn-accent, #58a6ff)":"transparent",color:v?"#fff":"var(--havn-text-secondary)"},children:"Rewind"})]})}),v&&f.length>0&&(()=>{var te;const x=f.slice().reverse(),y=new Date(x[0].started_at).getTime(),H=new Date(x[x.length-1].started_at).getTime()-y||1,ne=Y=>(Y==null?void 0:Y.slice(0,10))||"",ae=Y=>(Y==null?void 0:Y.slice(11,16))||"",F=x.length-1-P;return a.jsxs("div",{style:xt.sliderContainer,children:[a.jsxs("span",{style:{fontSize:10,color:"var(--havn-text-dim)",whiteSpace:"nowrap",flexShrink:0},children:[ne(x[0].started_at),a.jsx("br",{}),ae(x[0].started_at)]}),a.jsxs("div",{style:{flex:1,position:"relative",height:32,cursor:"pointer",margin:"0 8px"},onClick:Y=>{const le=Y.currentTarget.getBoundingClientRect(),he=(Y.clientX-le.left)/le.width;let xe=0,ye=1/0;x.forEach((_e,me)=>{const Ne=new Date(_e.started_at).getTime(),b=x.length===1?.5:(Ne-y)/H,K=Math.abs(b-he);K<ye&&(ye=K,xe=me)}),Z(x.length-1-xe)},children:[a.jsx("div",{style:{position:"absolute",top:14,left:0,right:0,height:2,background:"var(--havn-border)",borderRadius:1}}),x.map((Y,le)=>{var me;const he=new Date(Y.started_at).getTime(),xe=x.length===1?50:(he-y)/H*100,ye=le===F,_e=Y.status==="success"?"var(--havn-green)":Y.status==="failed"?"var(--havn-red)":"var(--havn-yellow)";return a.jsx("div",{title:`${(me=Y.started_at)==null?void 0:me.slice(0,19)} — ${Y.status} (${Y.trigger})`,style:{position:"absolute",left:`${xe}%`,top:ye?7:10,width:ye?14:8,height:ye?14:8,borderRadius:"50%",background:ye?"var(--havn-accent, #58a6ff)":_e,border:ye?"2px solid #fff":"1px solid var(--havn-bg)",transform:"translateX(-50%)",transition:"all 0.15s ease",zIndex:ye?2:1,boxShadow:ye?"0 0 6px rgba(88,166,255,0.5)":"none"}},Y.run_id)})]}),a.jsxs("span",{style:{fontSize:10,color:"var(--havn-text-dim)",whiteSpace:"nowrap",flexShrink:0,textAlign:"right"},children:[ne(x[x.length-1].started_at),a.jsx("br",{}),ae(x[x.length-1].started_at)]}),D&&a.jsxs("div",{style:{marginLeft:12,fontSize:11,whiteSpace:"nowrap",flexShrink:0},children:[a.jsx("span",{style:{fontWeight:600},children:(te=D.started_at)==null?void 0:te.slice(11,19)}),a.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:600,color:D.status==="success"?"var(--havn-green)":D.status==="failed"?"var(--havn-red)":"var(--havn-yellow)"},children:D.status}),a.jsx("span",{style:{color:"var(--havn-text-dim)",marginLeft:6,fontSize:10},children:D.trigger})]})]})})(),v&&f.length===0&&a.jsx("div",{style:xt.sliderContainer,children:a.jsx("span",{style:{color:"var(--havn-text-dim)",fontSize:12},children:"No pipeline runs recorded. Run a transform to start capturing snapshots."})}),a.jsxs("div",{style:xt.mainArea,children:[a.jsx("div",{style:{flex:1,overflow:"auto",background:"var(--havn-bg-tertiary)"},"data-havn-hint":"dag-canvas",children:a.jsx("canvas",{ref:E,onMouseMove:Ie,onMouseLeave:()=>N(null),onClick:ve,style:xt.canvas})}),v&&_&&D&&a.jsx(om,{modelName:_,runId:D.run_id,runs:f,snapshotsByRun:Te,onClose:()=>C(null),onRestore:z,showConfirm:l})]})]})}const xt={container:{display:"flex",flexDirection:"column",flex:1,height:"100%",minHeight:0,overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)",fontSize:"13px",flexShrink:0},headerRight:{display:"flex",alignItems:"center",gap:12},legend:{display:"flex",gap:"10px",fontSize:"11px",color:"var(--havn-text-secondary)",alignItems:"center",flexWrap:"wrap"},legendItem:{display:"flex",alignItems:"center",gap:"4px"},legendDot:{width:"8px",height:"8px",borderRadius:"50%",display:"inline-block"},mainArea:{flex:1,display:"flex",overflow:"hidden",minHeight:0},canvas:{display:"block"},loading:{padding:"24px",color:"var(--havn-text-secondary)",textAlign:"center"},empty:{padding:"24px",color:"var(--havn-text-dim)",textAlign:"center"},rewindBtn:{border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",padding:"4px 12px",fontSize:11,fontWeight:500,cursor:"pointer"},sliderContainer:{display:"flex",alignItems:"center",gap:10,padding:"8px 16px",borderBottom:"1px solid var(--havn-border)",background:"var(--havn-bg-secondary)",fontSize:12,flexShrink:0}},Tm={breaking:"var(--havn-red)",warning:"var(--havn-yellow)",info:"var(--havn-text-dim)"},pd={direct:"var(--havn-red)",transitive:"var(--havn-yellow)",safe:"var(--havn-green)"};function cm(){var $;const[r,l]=A.useState("check"),[E,T]=A.useState(!1),[c,u]=A.useState(null),[N,L]=A.useState(null),[I,R]=A.useState([]),[O,d]=A.useState(null),[_,C]=A.useState([]),[f,m]=A.useState([]),[j,W]=A.useState(null),[P,Z]=A.useState([]),v=A.useCallback(async()=>{T(!0),u(null);try{const J=await Ee.runSentinelCheck();L(J)}catch(J){u(J.message||"Check failed")}finally{T(!1)}},[]),M=A.useCallback(async()=>{T(!0);try{const J=await Ee.getSentinelDiffs();R(J)}catch(J){u(J.message)}finally{T(!1)}},[]),Te=A.useCallback(async J=>{try{const Ce=await Ee.getSentinelImpacts(J);C(Ce),d(J)}catch(Ce){u(Ce.message)}},[]),B=A.useCallback(async()=>{try{const J=await Ee.getSentinelSources();m(J)}catch(J){u(J.message)}},[]),se=A.useCallback(async J=>{W(J);try{const Ce=await Ee.getSentinelHistory(J);Z(Ce)}catch(Ce){u(Ce.message)}},[]);A.useEffect(()=>{r==="diffs"&&M(),r==="history"&&B()},[r]);async function w(J,Ce){try{await Ee.resolveSentinelImpact(J,Ce),O&&Te(O)}catch(Ie){u(Ie.message)}}return a.jsxs("div",{style:He.container,children:[a.jsx("div",{style:He.header,children:a.jsx("div",{style:He.tabs,children:["check","diffs","history"].map(J=>a.jsx("button",{onClick:()=>l(J),style:{...He.tab,borderBottom:r===J?"2px solid var(--havn-accent, #58a6ff)":"2px solid transparent",color:r===J?"var(--havn-text)":"var(--havn-text-secondary)"},children:J.charAt(0).toUpperCase()+J.slice(1)},J))})}),c&&a.jsx("div",{style:He.error,children:c}),r==="check"&&a.jsxs("div",{style:He.body,children:[a.jsxs("div",{style:He.actionBar,children:[a.jsx("button",{onClick:v,disabled:E,style:He.btn,children:E?"Checking...":"Run Schema Check"}),N&&a.jsxs("span",{style:He.dim,children:[N.sources_checked," source(s) checked, ",(($=N.diffs)==null?void 0:$.length)||0," change(s)"]})]}),N&&N.diffs&&N.diffs.length===0&&a.jsx("div",{style:He.success,children:"No schema changes detected."}),N&&N.diffs&&N.diffs.map((J,Ce)=>a.jsxs("div",{style:He.diffCard,children:[a.jsxs("div",{style:He.diffHeader,children:[a.jsx("span",{style:He.diffSource,children:J.source_name}),J.has_breaking&&a.jsx("span",{style:He.breakingBadge,children:"BREAKING"}),a.jsxs("span",{style:He.dim,children:[J.changes.length," change(s)"]})]}),a.jsxs("table",{style:He.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:He.th,children:"Change"}),a.jsx("th",{style:He.th,children:"Severity"}),a.jsx("th",{style:He.th,children:"Column"}),a.jsx("th",{style:He.th,children:"Details"})]})}),a.jsx("tbody",{children:J.changes.map((Ie,ve)=>a.jsxs("tr",{children:[a.jsx("td",{style:He.td,children:Ie.change_type}),a.jsx("td",{style:He.td,children:a.jsx("span",{style:{...He.sevBadge,background:Tm[Ie.severity]||"var(--havn-text-dim)"},children:Ie.severity})}),a.jsx("td",{style:{...He.td,fontWeight:600},children:Ie.column_name}),a.jsxs("td",{style:He.td,children:[Ie.old_value&&Ie.new_value?`${Ie.old_value} → ${Ie.new_value}`:Ie.old_value?`was: ${Ie.old_value}`:Ie.new_value||"",Ie.rename_candidate&&a.jsxs("span",{style:{color:"var(--havn-yellow)",marginLeft:6,fontSize:11},children:["(rename? ",Ie.rename_candidate,")"]})]})]},ve))})]}),J.impacts&&J.impacts.length>0&&a.jsxs("div",{style:He.impactSection,children:[a.jsxs("div",{style:He.impactTitle,children:["Impact Analysis (",J.impacts.length," model",J.impacts.length!==1?"s":"",")"]}),J.impacts.map((Ie,ve)=>a.jsxs("div",{style:He.impactRow,children:[a.jsx("span",{style:{...He.impactBadge,background:pd[Ie.impact_type]||"var(--havn-text-dim)"},children:Ie.impact_type}),a.jsx("span",{style:He.impactModel,children:Ie.model_name}),Ie.columns_affected&&Ie.columns_affected.length>0&&a.jsxs("span",{style:He.dim,children:["cols: ",Ie.columns_affected.join(", ")]}),Ie.fix_suggestion&&a.jsx("div",{style:He.fixSuggestion,children:Ie.fix_suggestion}),!Ie.resolved_at&&a.jsx("button",{onClick:()=>w(J.diff_id,Ie.model_name),style:He.dismissBtn,children:"Dismiss"}),Ie.resolved_at&&a.jsx("span",{style:{...He.dim,fontSize:10},children:"Resolved"})]},ve))]})]},Ce))]}),r==="diffs"&&a.jsxs("div",{style:He.body,children:[E&&a.jsx("div",{style:He.dim,children:"Loading..."}),a.jsxs("div",{style:He.splitView,children:[a.jsxs("div",{style:He.leftPane,children:[I.length===0&&!E&&a.jsx("div",{style:He.dim,children:"No schema diffs recorded. Run a check first."}),I.map((J,Ce)=>{var Ie,ve,z;return a.jsxs("div",{onClick:()=>Te(J.diff_id),style:{...He.diffListItem,background:O===J.diff_id?"var(--havn-bg-tertiary)":"transparent"},children:[a.jsx("div",{style:{fontWeight:600,fontSize:12},children:J.source_name}),a.jsxs("div",{style:{fontSize:11,color:"var(--havn-text-dim)"},children:[(Ie=J.created_at)==null?void 0:Ie.slice(0,19)," · ",((ve=J.changes)==null?void 0:ve.length)||0," change(s)",((z=J.changes)==null?void 0:z.some(D=>D.severity==="breaking"))&&a.jsx("span",{style:{color:"var(--havn-red)",marginLeft:6},children:"BREAKING"})]})]},Ce)})]}),a.jsx("div",{style:He.rightPane,children:O&&_.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{style:{fontWeight:600,fontSize:13,marginBottom:8},children:"Impact Analysis"}),_.map((J,Ce)=>{var Ie;return a.jsxs("div",{style:He.impactRow,children:[a.jsx("span",{style:{...He.impactBadge,background:pd[J.impact_type]||"var(--havn-text-dim)"},children:J.impact_type}),a.jsx("span",{style:He.impactModel,children:J.model_name}),((Ie=J.columns_affected)==null?void 0:Ie.length)>0&&a.jsxs("span",{style:He.dim,children:["cols: ",J.columns_affected.join(", ")]}),J.fix_suggestion&&a.jsx("div",{style:He.fixSuggestion,children:J.fix_suggestion})]},Ce)})]}):O?a.jsx("div",{style:He.dim,children:"No impacts for this diff."}):a.jsx("div",{style:He.dim,children:"Select a diff to see impact analysis."})})]})]}),r==="history"&&a.jsx("div",{style:He.body,children:a.jsxs("div",{style:He.splitView,children:[a.jsxs("div",{style:He.leftPane,children:[a.jsx("div",{style:{fontSize:12,fontWeight:600,marginBottom:6},children:"Sources"}),f.map((J,Ce)=>a.jsxs("div",{onClick:()=>se(J.name),style:{...He.diffListItem,background:j===J.name?"var(--havn-bg-tertiary)":"transparent"},children:[a.jsx("span",{style:{fontWeight:500,fontSize:12},children:J.name}),a.jsx("span",{style:{fontSize:10,marginLeft:6,color:J.exists?"var(--havn-green)":"var(--havn-text-dim)"},children:J.exists?"exists":"missing"})]},Ce)),f.length===0&&a.jsx("div",{style:He.dim,children:"No sources found."})]}),a.jsx("div",{style:He.rightPane,children:j&&P.length>0?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{fontWeight:600,fontSize:13,marginBottom:8},children:["Schema History: ",j]}),P.map((J,Ce)=>{var Ie,ve,z,D,oe;return a.jsxs("div",{style:He.historyItem,children:[a.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a.jsx("span",{style:{fontSize:11,color:"var(--havn-text-dim)"},children:(Ie=J.captured_at)==null?void 0:Ie.slice(0,19)}),a.jsxs("span",{style:{fontSize:10,color:"var(--havn-text-dim)"},children:[(ve=J.columns)==null?void 0:ve.length," col(s) · ",(z=J.schema_hash)==null?void 0:z.slice(0,8)]})]}),a.jsxs("div",{style:{marginTop:4,fontSize:11},children:[(D=J.columns)==null?void 0:D.slice(0,10).map((Oe,x)=>a.jsxs("span",{style:He.colTag,children:[Oe.name,": ",a.jsx("span",{style:{color:"var(--havn-text-dim)"},children:Oe.type})]},x)),((oe=J.columns)==null?void 0:oe.length)>10&&a.jsxs("span",{style:{fontSize:10,color:"var(--havn-text-dim)"},children:["+",J.columns.length-10," more"]})]})]},Ce)})]}):j?a.jsxs("div",{style:He.dim,children:["No schema history for ",j,"."]}):a.jsx("div",{style:He.dim,children:"Select a source to see schema history."})})]})})]})}const He={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)",fontSize:13},tabs:{display:"flex",gap:4},tab:{background:"none",border:"none",cursor:"pointer",padding:"4px 10px",fontSize:12,fontWeight:500},body:{flex:1,overflow:"auto",padding:12},error:{padding:"8px 12px",background:"color-mix(in srgb, var(--havn-red) 12%, transparent)",color:"var(--havn-red)",fontSize:12,borderBottom:"1px solid var(--havn-border)"},actionBar:{display:"flex",alignItems:"center",gap:12,marginBottom:12},btn:{padding:"4px 12px",background:"var(--havn-green)",color:"#fff",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500},dim:{color:"var(--havn-text-dim)",fontSize:12},success:{padding:12,background:"color-mix(in srgb, var(--havn-green) 8%, transparent)",color:"var(--havn-green)",borderRadius:"var(--havn-radius-lg)",fontSize:12,fontWeight:500},diffCard:{border:"1px solid var(--havn-border)",borderRadius:6,marginBottom:12,overflow:"hidden"},diffHeader:{display:"flex",alignItems:"center",gap:10,padding:"8px 12px",background:"var(--havn-bg-secondary)",borderBottom:"1px solid var(--havn-border)"},diffSource:{fontWeight:600,fontSize:13},breakingBadge:{background:"var(--havn-red)",color:"#fff",padding:"1px 6px",borderRadius:3,fontSize:10,fontWeight:700},table:{width:"100%",borderCollapse:"collapse",fontSize:12},th:{textAlign:"left",padding:"6px 12px",background:"var(--havn-bg-tertiary)",borderBottom:"1px solid var(--havn-border)",fontWeight:600,fontSize:11},td:{padding:"5px 12px",borderBottom:"1px solid var(--havn-border-light)",fontSize:12},sevBadge:{color:"#fff",padding:"1px 5px",borderRadius:3,fontSize:10,fontWeight:600},impactSection:{padding:"8px 12px"},impactTitle:{fontWeight:600,fontSize:12,marginBottom:6,color:"var(--havn-text-secondary)"},impactRow:{padding:"6px 0",borderBottom:"1px solid var(--havn-border-light)",display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},impactBadge:{color:"#fff",padding:"1px 6px",borderRadius:3,fontSize:10,fontWeight:600},impactModel:{fontWeight:600,fontSize:12},fixSuggestion:{width:"100%",fontSize:11,color:"var(--havn-text-secondary)",marginTop:2,paddingLeft:4,borderLeft:"2px solid var(--havn-border-light)"},dismissBtn:{background:"none",border:"1px solid var(--havn-border)",borderRadius:3,padding:"1px 8px",fontSize:10,cursor:"pointer",color:"var(--havn-text-secondary)"},splitView:{display:"flex",gap:0,height:"calc(100% - 8px)"},leftPane:{width:280,borderRight:"1px solid var(--havn-border)",overflow:"auto",padding:"8px 0"},rightPane:{flex:1,overflow:"auto",padding:"8px 12px"},diffListItem:{padding:"8px 12px",cursor:"pointer",borderBottom:"1px solid var(--havn-border-light)"},historyItem:{padding:"8px 0",borderBottom:"1px solid var(--havn-border-light)"},colTag:{display:"inline-block",marginRight:8,fontSize:11}};function Sm({api:r,addOutput:l}){const[E,T]=A.useState(null),[c,u]=A.useState(!1),[N,L]=A.useState(null),I=Ar(),R=async()=>{u(!0),T(null);try{const d=await r.runDiff();T(d);const _=d.filter(C=>C.added||C.removed||C.modified||C.is_new||C.error||C.schema_changes&&C.schema_changes.length);_.length===0?l("info","Diff complete: no changes detected."):(l("info",`Diff complete: ${_.length} model(s) with changes.`),I("hasDiffChanges",!0))}catch(d){l("error",`Diff failed: ${d.message}`)}finally{u(!1)}},O=d=>{if(!d||!d.length)return"—";const _=d.filter(j=>j.change_type==="added").length,C=d.filter(j=>j.change_type==="removed").length,f=d.filter(j=>j.change_type==="type_changed").length,m=[];return _&&m.push(`+${_} col`),C&&m.push(`-${C} col`),f&&m.push(`~${f} col`),m.join(", ")};return a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[a.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},children:a.jsx("button",{onClick:R,disabled:c,style:{padding:"4px 12px",borderRadius:"var(--havn-radius-lg)",border:"1px solid var(--havn-green-border)",background:"var(--havn-green)",color:"#fff",cursor:c?"wait":"pointer",fontSize:"11px",fontWeight:500},children:c?"Running...":"Run Diff"})}),a.jsx("p",{style:{color:"var(--havn-text-secondary)",fontSize:13,marginBottom:16,padding:"0 12px"},children:"Compare model SQL output against currently materialized tables. Shows what would change if you run transforms now."}),E&&a.jsx("div",{"data-havn-hint":"diff-results",children:a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[a.jsx("thead",{children:a.jsxs("tr",{style:{borderBottom:"2px solid var(--havn-border)",textAlign:"left"},children:[a.jsx("th",{style:Fr,children:"Model"}),a.jsx("th",{style:{...Fr,textAlign:"right"},children:"Before"}),a.jsx("th",{style:{...Fr,textAlign:"right"},children:"After"}),a.jsx("th",{style:{...Fr,textAlign:"right"},children:"Added"}),a.jsx("th",{style:{...Fr,textAlign:"right"},children:"Removed"}),a.jsx("th",{style:{...Fr,textAlign:"right"},children:"Modified"}),a.jsx("th",{style:Fr,children:"Schema"})]})}),a.jsx("tbody",{children:E.map(d=>a.jsxs(aa.Fragment,{children:[a.jsxs("tr",{onClick:()=>L(N===d.model?null:d.model),style:{borderBottom:"1px solid var(--havn-border)",cursor:"pointer",background:N===d.model?"var(--bg-secondary)":"transparent"},children:[a.jsx("td",{style:Yr,children:a.jsx("strong",{children:d.model})}),a.jsx("td",{style:{...Yr,textAlign:"right"},children:d.error?"":d.is_new?"NEW":d.total_before.toLocaleString()}),a.jsx("td",{style:{...Yr,textAlign:"right"},children:d.error?"":d.total_after.toLocaleString()}),a.jsx("td",{style:{...Yr,textAlign:"right",color:d.added?"var(--havn-green)":void 0},children:d.error?"":d.added?`+${d.added}`:"0"}),a.jsx("td",{style:{...Yr,textAlign:"right",color:d.removed?"var(--havn-red)":void 0},children:d.error?"":d.removed||"0"}),a.jsx("td",{style:{...Yr,textAlign:"right",color:d.modified?"var(--havn-yellow)":void 0},children:d.error?"":d.modified||"0"}),a.jsx("td",{style:Yr,children:d.error?a.jsx("span",{style:{color:"var(--havn-red)"},children:"ERROR"}):a.jsx("span",{style:{color:d.schema_changes&&d.schema_changes.length?"var(--havn-accent)":void 0},children:O(d.schema_changes)})})]}),N===d.model&&a.jsx("tr",{children:a.jsx("td",{colSpan:7,style:{padding:"8px 12px"},children:a.jsx(Rm,{result:d})})})]},d.model))})]})})]})}function Rm({result:r}){var l,E,T,c;return r.error?a.jsxs("div",{style:{color:"var(--havn-red)",padding:8},children:["Error: ",r.error]}):a.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.schema_changes&&r.schema_changes.length>0&&a.jsxs("div",{children:[a.jsx("h4",{style:{margin:"0 0 8px 0",fontSize:13},children:"Schema Changes"}),r.schema_changes.map((u,N)=>a.jsxs("div",{style:{fontSize:12,padding:"2px 0"},children:[u.change_type==="added"&&a.jsxs("span",{style:{color:"var(--havn-green)"},children:["+ ",u.column," (",u.new_type,")"]}),u.change_type==="removed"&&a.jsxs("span",{style:{color:"var(--havn-red)"},children:["- ",u.column," (",u.old_type,")"]}),u.change_type==="type_changed"&&a.jsxs("span",{style:{color:"var(--havn-yellow)"},children:["~ ",u.column,": ",u.old_type," → ",u.new_type]})]},N))]}),r.sample_added&&r.sample_added.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{style:{margin:"0 0 8px 0",fontSize:13,color:"var(--havn-green)"},children:["Added Rows (",r.added,")"]}),a.jsx(Fs,{columns:Object.keys(r.sample_added[0]),rows:r.sample_added.map(u=>Object.values(u))})]}),r.sample_removed&&r.sample_removed.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{style:{margin:"0 0 8px 0",fontSize:13,color:"var(--havn-red)"},children:["Removed Rows (",r.removed,")"]}),a.jsx(Fs,{columns:Object.keys(r.sample_removed[0]),rows:r.sample_removed.map(u=>Object.values(u))})]}),r.sample_modified&&r.sample_modified.length>0&&a.jsxs("div",{children:[a.jsxs("h4",{style:{margin:"0 0 8px 0",fontSize:13,color:"var(--havn-yellow)"},children:["Modified Rows (",r.modified,")"]}),a.jsx(Fs,{columns:Object.keys(r.sample_modified[0]),rows:r.sample_modified.map(u=>Object.values(u))})]}),!((l=r.sample_added)!=null&&l.length)&&!((E=r.sample_removed)!=null&&E.length)&&!((T=r.sample_modified)!=null&&T.length)&&!((c=r.schema_changes)!=null&&c.length)&&a.jsx("div",{style:{color:"var(--havn-text-secondary)",fontSize:13},children:"No changes detected for this model."})]})}const Fr={padding:"8px 12px",fontWeight:600},Yr={padding:"8px 12px"};function um({table:r,isActive:l,onClick:E}){return a.jsxs("div",{style:{...Qe.navItem,background:l?"var(--havn-bg-secondary)":"transparent",borderLeft:l?"2px solid var(--havn-accent)":"2px solid transparent"},onClick:E,children:[a.jsx("span",{style:Qe.navLabel,children:r.name}),a.jsx("span",{style:Qe.navBadge,children:r.type})]})}function Am({table:r}){const[l,E]=A.useState(!1);if(!r)return a.jsx("div",{style:Qe.detailEmpty,children:"Select a table from the sidebar to view details."});const T=r.columns.some(c=>c.description);return a.jsxs("div",{style:Qe.detail,children:[a.jsxs("div",{style:Qe.detailHeader,children:[a.jsx("code",{style:Qe.detailTitle,children:r.full_name}),a.jsx("span",{style:Qe.detailType,children:r.type.toUpperCase()})]}),r.description&&a.jsx("p",{style:Qe.detailDesc,children:r.description}),a.jsxs("div",{style:Qe.metaRow,children:[r.materialized&&a.jsxs("span",{style:Qe.metaTag,children:["Materialized: ",r.materialized]}),r.row_count!=null&&a.jsxs("span",{style:Qe.metaTag,children:["Rows: ",r.row_count.toLocaleString()]}),r.depends_on&&r.depends_on.length>0&&a.jsxs("span",{style:Qe.metaTag,children:["Depends on: ",r.depends_on.map(c=>a.jsx("code",{style:Qe.depCode,children:c},c))]})]}),a.jsxs("h4",{style:Qe.sectionTitle,children:["Columns (",r.columns.length,")"]}),a.jsxs("table",{style:Qe.colTable,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:Qe.colTh,children:"Column"}),a.jsx("th",{style:Qe.colTh,children:"Type"}),a.jsx("th",{style:Qe.colTh,children:"Nullable"}),T&&a.jsx("th",{style:Qe.colTh,children:"Description"})]})}),a.jsx("tbody",{children:r.columns.map(c=>a.jsxs("tr",{children:[a.jsx("td",{style:Qe.colTdName,children:a.jsx("code",{children:c.name})}),a.jsx("td",{style:Qe.colTd,children:c.type}),a.jsx("td",{style:Qe.colTd,children:c.nullable?"yes":"no"}),T&&a.jsx("td",{style:Qe.colTd,children:c.description})]},c.name))})]}),r.sql&&a.jsxs("div",{style:Qe.sqlSection,children:[a.jsxs("button",{onClick:()=>E(!l),style:Qe.sqlToggle,children:[l?"▾":"▸"," SQL Source"]}),l&&a.jsx("pre",{style:Qe.sqlBlock,children:a.jsx("code",{children:r.sql})})]})]})}function dm(){const[r,l]=A.useState(null),[E,T]=A.useState(!0),[c,u]=A.useState(null),[N,L]=A.useState(null),[I,R]=A.useState({});A.useEffect(()=>{O()},[]);async function O(){var f;T(!0);try{const m=await Ee.getStructuredDocs();l(m);const j={};for(const W of m.schemas||[])j[W.name]=!0;R(j),!N&&((f=m.schemas)==null?void 0:f.length)>0&&m.schemas[0].tables.length>0&&L(m.schemas[0].tables[0].full_name)}catch(m){u(m.message||"Failed to load docs")}T(!1)}function d(f){R(m=>({...m,[f]:!m[f]}))}let _=null;if(r&&N)for(const f of r.schemas){for(const m of f.tables)if(m.full_name===N){_=m;break}if(_)break}const C=r?r.schemas.reduce((f,m)=>f+m.tables.length,0):0;return a.jsxs("div",{style:Qe.container,children:[a.jsxs("div",{style:Qe.header,children:[a.jsx("span",{style:Qe.headerCount,children:C>0?`${C} tables`:""}),a.jsx("button",{onClick:O,style:Qe.refreshBtn,children:"Refresh"})]}),a.jsxs("div",{style:Qe.body,children:[E&&a.jsx("div",{style:Qe.loading,children:"Loading docs..."}),!E&&c&&a.jsx("div",{style:{...Qe.loading,color:"var(--havn-red)"},children:c}),!E&&!c&&(!r||r.schemas.length===0)&&a.jsx("div",{style:Qe.loading,children:"No documentation available. Run a pipeline first."}),!E&&r&&r.schemas.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{style:Qe.nav,children:r.schemas.map(f=>a.jsxs("div",{children:[a.jsxs("div",{style:Qe.schemaRow,onClick:()=>d(f.name),children:[a.jsx("span",{style:{...Qe.schemaArrow,transform:I[f.name]?"rotate(0deg)":"rotate(-90deg)"},children:"▾"}),a.jsx("span",{style:Qe.schemaName,children:f.name}),a.jsx("span",{style:Qe.schemaCount,children:f.tables.length})]}),I[f.name]&&f.tables.map(m=>a.jsx(um,{table:m,isActive:N===m.full_name,onClick:()=>L(m.full_name)},m.full_name))]},f.name))}),a.jsx("div",{style:Qe.content,children:a.jsx(Am,{table:_})})]})]})]})}const Qe={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)",fontWeight:600,fontSize:"13px"},headerCount:{color:"var(--havn-text-dim)",fontWeight:400,fontSize:"12px",flex:1},refreshBtn:{background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",padding:"4px 12px",cursor:"pointer",fontSize:"11px",fontWeight:500},body:{display:"flex",flex:1,overflow:"hidden"},loading:{color:"var(--havn-text-secondary)",textAlign:"center",padding:"24px",width:"100%"},nav:{width:"220px",minWidth:"220px",borderRight:"1px solid var(--havn-border)",overflow:"auto",padding:"4px 0"},schemaRow:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",cursor:"pointer",fontSize:"11px",fontWeight:600,color:"var(--havn-text-dim)",letterSpacing:"0.5px",textTransform:"uppercase"},schemaArrow:{fontSize:"10px",width:"10px",display:"inline-block",transition:"transform 0.12s ease"},schemaName:{flex:1},schemaCount:{fontSize:"10px",color:"var(--havn-text-dim)",fontWeight:400},navItem:{display:"flex",alignItems:"center",gap:"6px",padding:"5px 12px 5px 28px",cursor:"pointer",fontSize:"12px",whiteSpace:"nowrap"},navLabel:{flex:1,overflow:"hidden",textOverflow:"ellipsis",color:"var(--havn-text)"},navBadge:{fontSize:"10px",color:"var(--havn-text-dim)",flexShrink:0},content:{flex:1,overflow:"auto",padding:"20px 28px"},detailEmpty:{color:"var(--havn-text-dim)",fontSize:"13px",padding:"24px",textAlign:"center"},detail:{},detailHeader:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"12px"},detailTitle:{fontSize:"18px",fontWeight:600,fontFamily:"var(--havn-font-mono)",color:"var(--havn-text)"},detailType:{fontSize:"11px",fontWeight:500,color:"var(--havn-text-dim)",background:"var(--havn-bg-secondary)",padding:"2px 8px",borderRadius:"var(--havn-radius)"},detailDesc:{margin:"0 0 12px",fontSize:"13px",lineHeight:1.5,color:"var(--havn-text-secondary)"},metaRow:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"},metaTag:{fontSize:"12px",color:"var(--havn-text-secondary)",background:"var(--havn-bg-secondary)",padding:"3px 10px",borderRadius:"var(--havn-radius)",display:"inline-flex",alignItems:"center",gap:"4px"},depCode:{fontFamily:"var(--havn-font-mono)",fontSize:"11px",color:"var(--havn-accent)"},sectionTitle:{fontSize:"13px",fontWeight:600,margin:"16px 0 8px",color:"var(--havn-text)"},colTable:{width:"100%",borderCollapse:"collapse",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},colTh:{textAlign:"left",padding:"6px 12px",borderBottom:"1px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600,fontFamily:"var(--havn-font)",fontSize:"11px"},colTd:{padding:"4px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",fontSize:"12px"},colTdName:{padding:"4px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-accent)",fontSize:"12px"},sqlSection:{marginTop:"16px"},sqlToggle:{background:"none",border:"none",color:"var(--havn-accent)",cursor:"pointer",fontSize:"12px",fontWeight:500,padding:"4px 0"},sqlBlock:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",padding:"12px",margin:"8px 0",fontSize:"12px",fontFamily:"var(--havn-font-mono)",overflow:"auto",color:"var(--havn-text)"}},dc=19.5,Ld=1e3;function xo({value:r,onChange:l,onKeyDown:E,minLines:T=3,spellCheck:c=!1}){const u=A.useRef(null),N=A.useRef(null),[L,I]=A.useState(null),R=r.split(`
`).length,O=R>Ld,d=Ld*dc+16,_=Math.max(T,R)*dc+16;A.useEffect(()=>{if(!O&&u.current){u.current.style.height="0px";const m=u.current.scrollHeight;u.current.style.height="",I(Math.max(m,_))}},[r,O,_]);const C=O?d:L||_,f=()=>{N.current&&u.current&&(N.current.scrollTop=u.current.scrollTop)};return a.jsxs("div",{style:{display:"flex",height:C},children:[a.jsx("div",{ref:N,style:{width:40,flexShrink:0,padding:"8px 0",overflow:"hidden",textAlign:"right",fontFamily:"var(--havn-font-mono)",fontSize:"13px",lineHeight:1.5,color:"var(--havn-text-dim)",userSelect:"none",borderRight:"1px solid var(--havn-border)",background:"var(--havn-bg-secondary)",boxSizing:"border-box"},children:Array.from({length:R},(m,j)=>a.jsx("div",{style:{paddingRight:8,height:dc},children:j+1},j))}),a.jsx("textarea",{ref:u,value:r,onChange:l,onKeyDown:E,onScroll:f,spellCheck:c,style:{flex:1,padding:"8px 12px",background:"transparent",border:"none",color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"13px",resize:"none",outline:"none",boxSizing:"border-box",lineHeight:1.5,height:"100%",overflow:O?"auto":"hidden"}})]})}const Om=[{value:"csv",label:"CSV File"},{value:"parquet",label:"Parquet File"},{value:"json",label:"JSON File"},{value:"url",label:"URL"},{value:"database",label:"Database Connection"}],Wr={source_type:"csv",source_path:"",target_schema:"landing",target_table:"",connection:"",options:{}};function yc({outputs:r}){return!r||r.length===0?null:a.jsx("div",{style:Et.outputArea,children:r.map((l,E)=>l.type==="table"?a.jsxs("div",{style:Et.tableWrap,children:[a.jsxs("table",{style:Et.table,children:[a.jsx("thead",{children:a.jsx("tr",{children:l.columns.map((T,c)=>a.jsx("th",{style:Et.th,children:T},c))})}),a.jsx("tbody",{children:l.rows.map((T,c)=>a.jsx("tr",{children:T.map((u,N)=>a.jsx("td",{style:Et.td,children:u===null?a.jsx("span",{style:Et.null,children:"NULL"}):String(u)},N))},c))})]}),l.truncated&&a.jsxs("div",{style:Et.truncated,children:["Results truncated (",l.total_rows," rows shown)"]})]},E):l.type==="error"?a.jsx("pre",{style:Et.error,children:l.text},E):a.jsx("pre",{style:Et.text,children:l.text},E))})}function Nm({cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}){const u=z=>{if(!z)return{...Wr};try{return{...Wr,...JSON.parse(z)}}catch{return{...Wr}}},[N,L]=A.useState(()=>u(r.source)),[I,R]=A.useState(!1),[O,d]=A.useState(r.source||JSON.stringify(Wr,null,2)),[_,C]=A.useState(r.outputs||[]),[f,m]=A.useState(!1),[j,W]=A.useState(r.duration_ms),[P,Z]=A.useState([]),[v,M]=A.useState(!1),Te=f||c;A.useEffect(()=>{C(r.outputs||[]),W(r.duration_ms)},[r.outputs,r.duration_ms]),A.useEffect(()=>{const z=u(r.source);L(z),d(r.source||JSON.stringify(Wr,null,2))},[r.id]),A.useEffect(()=>{N.source_type==="database"&&Ee.listConfiguredConnectors().then(Z).catch(()=>{})},[N.source_type]);const B=A.useCallback(z=>{L(D=>{const oe={...D,...z},Oe=JSON.stringify(oe);return d(JSON.stringify(oe,null,2)),E({...r,source:Oe}),oe})},[r,E]);function se(z){const D={source_path:z};(!N.target_table||N.target_table===w(N.source_path))&&(D.target_table=w(z)),B(D)}function w(z){return z?z.split("/").pop().split("\\").pop().replace(/\.[^.]+$/,"").replace(/[^a-zA-Z0-9_]/g,"_").toLowerCase():""}async function $(){m(!0);try{const z=I?O:JSON.stringify(N),D=await Ee.runCell(l,z,{cell_type:"ingest"});C(D.outputs),W(D.duration_ms),E({...r,source:z,outputs:D.outputs,duration_ms:D.duration_ms})}catch(z){C([{type:"error",text:z.message}])}m(!1)}function J(z){d(z);try{const D=JSON.parse(z);L({...Wr,...D}),E({...r,source:z})}catch{}}const Ce=["csv","parquet","json"].includes(N.source_type),Ie=N.source_type==="url",ve=N.source_type==="database";return a.jsxs("div",{style:Et.codeCell,children:[a.jsxs("div",{style:Et.cellHeader,children:[a.jsx("button",{onClick:$,disabled:Te,style:Et.runBtn,children:Te?"...":"▶"}),a.jsx("span",{style:{...Et.cellType,color:"var(--havn-blue, var(--havn-text-dim))"},children:"INGEST"}),a.jsx("span",{style:{flex:1}}),a.jsx("button",{onClick:()=>R(!I),style:Et.toggleBtn,title:I?"Show form":"Show source",children:I?"Form":"{ }"}),j!=null&&a.jsxs("span",{style:Et.duration,children:[j,"ms"]}),a.jsx("button",{"data-havn-danger":"",onClick:T,style:Et.deleteBtn,title:"Delete cell",children:"×"})]}),I?a.jsx(xo,{value:O,onChange:z=>J(z.target.value),onKeyDown:z=>{(z.ctrlKey||z.metaKey)&&z.key==="Enter"&&(z.preventDefault(),$())},minLines:4}):a.jsxs("div",{style:Dt.form,children:[a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"Source"}),a.jsx("select",{value:N.source_type,onChange:z=>B({source_type:z.target.value,connection:"",source_path:""}),style:Dt.select,children:Om.map(z=>a.jsx("option",{value:z.value,children:z.label},z.value))})]}),Ce&&a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"File Path"}),a.jsx("input",{value:N.source_path,onChange:z=>se(z.target.value),placeholder:"data/earthquakes.csv",style:Dt.input})]}),Ie&&a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"URL"}),a.jsx("input",{value:N.source_path,onChange:z=>se(z.target.value),placeholder:"https://example.com/data.csv",style:Dt.input})]}),ve&&a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"Connection"}),a.jsxs("select",{value:N.connection,onChange:z=>B({connection:z.target.value}),style:Dt.select,children:[a.jsx("option",{value:"",children:"Select connection..."}),P.map(z=>a.jsxs("option",{value:z.name,children:[z.name," (",z.type,")"]},z.name))]})]}),ve&&a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"Source Table"}),a.jsx("input",{value:N.source_path,onChange:z=>se(z.target.value),placeholder:"public.users",style:Dt.input})]}),a.jsxs("div",{style:Dt.row,children:[a.jsx("label",{style:Dt.label,children:"Target"}),a.jsxs("div",{style:Dt.targetRow,children:[a.jsx("input",{value:N.target_schema,onChange:z=>B({target_schema:z.target.value}),placeholder:"landing",style:{...Dt.input,flex:"0 0 120px"}}),a.jsx("span",{style:Dt.dot,children:"."}),a.jsx("input",{value:N.target_table,onChange:z=>B({target_table:z.target.value}),placeholder:"table_name",style:Dt.input})]})]}),a.jsx("div",{style:Dt.row,children:a.jsxs("button",{onClick:()=>M(!v),style:Dt.optionsToggle,children:[v?"▼":"▶"," Options"]})}),v&&a.jsx("div",{style:Dt.optionsArea,children:a.jsx("textarea",{value:JSON.stringify(N.options||{},null,2),onChange:z=>{try{B({options:JSON.parse(z.target.value)})}catch{}},placeholder:'{"delimiter": ",", "header": true}',style:{...Et.codeInput,minHeight:"48px"},rows:3,spellCheck:!1})})]}),a.jsx(yc,{outputs:_})]})}function Im({cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}){const[u,N]=A.useState(r.source||""),[L,I]=A.useState(r.outputs||[]),[R,O]=A.useState(!1),[d,_]=A.useState(r.duration_ms),C=R||c;A.useEffect(()=>{I(r.outputs||[]),_(r.duration_ms)},[r.outputs,r.duration_ms]),A.useEffect(()=>{N(r.source||"")},[r.id]);async function f(){O(!0);try{const m=await Ee.runCell(l,u,{cell_type:"sql"});I(m.outputs),_(m.duration_ms),E({...r,source:u,outputs:m.outputs,duration_ms:m.duration_ms})}catch(m){I([{type:"error",text:m.message}])}O(!1)}return a.jsxs("div",{style:Et.codeCell,children:[a.jsxs("div",{style:Et.cellHeader,children:[a.jsx("button",{onClick:f,disabled:C,style:Et.runBtn,children:C?"...":"▶"}),a.jsx("span",{style:Et.cellType,children:"SQL"}),a.jsx("span",{style:{flex:1}}),d!=null&&a.jsxs("span",{style:Et.duration,children:[d,"ms"]}),a.jsx("button",{"data-havn-danger":"",onClick:T,style:Et.deleteBtn,title:"Delete cell",children:"×"})]}),a.jsx(xo,{value:u,onChange:m=>{N(m.target.value),E({...r,source:m.target.value})},onKeyDown:m=>{(m.ctrlKey||m.metaKey)&&m.key==="Enter"&&(m.preventDefault(),f())}}),a.jsx(yc,{outputs:L})]})}function hm({cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}){const[u,N]=A.useState(r.source||""),[L,I]=A.useState(r.outputs||[]),[R,O]=A.useState(!1),[d,_]=A.useState(r.duration_ms),C=R||c;A.useEffect(()=>{I(r.outputs||[]),_(r.duration_ms)},[r.outputs,r.duration_ms]),A.useEffect(()=>{N(r.source||"")},[r.id]);async function f(){O(!0);try{const m=await Ee.runCell(l,u,{cell_type:"code"});I(m.outputs),_(m.duration_ms),E({...r,source:u,outputs:m.outputs,duration_ms:m.duration_ms})}catch(m){I([{type:"error",text:m.message}])}O(!1)}return a.jsxs("div",{style:Et.codeCell,children:[a.jsxs("div",{style:Et.cellHeader,children:[a.jsx("button",{onClick:f,disabled:C,style:Et.runBtn,children:C?"...":"▶"}),a.jsx("span",{style:Et.cellType,children:"PY"}),a.jsx("span",{style:{flex:1}}),d!=null&&a.jsxs("span",{style:Et.duration,children:[d,"ms"]}),a.jsx("button",{"data-havn-danger":"",onClick:T,style:Et.deleteBtn,title:"Delete cell",children:"×"})]}),a.jsx(xo,{value:u,onChange:m=>{N(m.target.value),E({...r,source:m.target.value})},onKeyDown:m=>{(m.ctrlKey||m.metaKey)&&m.key==="Enter"&&(m.preventDefault(),f())}}),a.jsx(yc,{outputs:L})]})}function fm({cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}){return r.type==="markdown"?a.jsx(Cm,{cell:r,onUpdate:E,onDelete:T}):r.type==="sql"?a.jsx(Im,{cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}):r.type==="ingest"?a.jsx(Nm,{cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c}):a.jsx(hm,{cell:r,notebookName:l,onUpdate:E,onDelete:T,externalRunning:c})}function Cm({cell:r,onUpdate:l,onDelete:E}){const[T,c]=A.useState(r.source||"");return A.useEffect(()=>{c(r.source||"")},[r.id]),a.jsxs("div",{style:Et.mdCell,children:[a.jsxs("div",{style:Et.cellHeader,children:[a.jsx("span",{style:Et.cellType,children:"MD"}),a.jsx("span",{style:{flex:1}}),a.jsx("button",{"data-havn-danger":"",onClick:E,style:Et.deleteBtn,title:"Delete cell",children:"×"})]}),a.jsx(xo,{value:T,onChange:u=>{c(u.target.value),l({...r,source:u.target.value})},minLines:2})]})}function pm({openPath:r}){const[l,E]=A.useState([]),[T,c]=A.useState(null),[u,N]=A.useState(null),[L,I]=A.useState(""),[R,O]=A.useState(!1),[d,_]=A.useState(null),[C,f]=A.useState(null);A.useEffect(()=>{m()},[]),A.useEffect(()=>{r&&r!==T&&j(r)},[r]);async function m(){try{const B=await Ee.listNotebooks();E(B)}catch(B){f(B.message||"Failed to load notebooks")}}async function j(B){f(null);try{const se=await Ee.getNotebook(B);c(B),N(se)}catch(se){f(se.message||"Failed to open notebook")}}async function W(){const B=L.trim().replace(/\s+/g,"_")||"untitled";f(null);try{const se=await Ee.createNotebook(B,B);I(""),await m(),c(B),N(se)}catch(se){f(se.message||"Failed to create notebook")}}async function P(){if(!(!T||!u))try{await Ee.saveNotebook(T,u)}catch(B){f(B.message||"Failed to save notebook")}}async function Z(){if(!(!T||!u||R)){O(!0),f(null);try{await P();const B=[...u.cells];let se=!0;for(let w=0;w<B.length;w++){const $=B[w];if($.type==="markdown")continue;_($.id);const J=$.type||"code";try{const Ce=await Ee.runCell(T,$.source,{reset:se,cell_type:J});se=!1,B[w]={...$,outputs:Ce.outputs,duration_ms:Ce.duration_ms},N(Ie=>({...Ie,cells:[...B]}))}catch(Ce){B[w]={...$,outputs:[{type:"error",text:Ce.message}]},N(Ie=>({...Ie,cells:[...B]}));break}}}catch(B){f(B.message||"Failed to run notebook")}_(null),O(!1)}}function v(B){if(!u)return;const se="cell_"+Math.random().toString(36).slice(2,8);let w="";B==="markdown"?w="## Heading":B==="ingest"?w=JSON.stringify(Wr,null,2):B==="sql"&&(w="SELECT 1");const $={id:se,type:B,source:w,outputs:[]};N({...u,cells:[...u.cells,$]})}function M(B,se){const w=[...u.cells];w[B]=se,N({...u,cells:w})}function Te(B){const se=u.cells.filter((w,$)=>$!==B);N({...u,cells:se})}return u?a.jsxs("div",{style:Mt.container,children:[a.jsxs("div",{style:Mt.nbHeader,children:[a.jsx("button",{onClick:()=>{N(null),c(null)},style:Mt.backBtn,children:"← Back"}),a.jsx("span",{style:Mt.nbTitle,children:u.title||T}),a.jsxs("div",{style:Mt.nbActions,children:[a.jsx("button",{onClick:()=>v("sql"),style:Mt.btn,children:"+ SQL"}),a.jsx("button",{onClick:()=>v("code"),style:Mt.btn,children:"+ Code"}),a.jsx("button",{onClick:()=>v("ingest"),style:Mt.btn,children:"+ Ingest"}),a.jsx("button",{onClick:()=>v("markdown"),style:Mt.btn,children:"+ Markdown"}),a.jsx("button",{onClick:P,style:Mt.btn,children:"Save"}),a.jsx("button",{onClick:Z,disabled:R,style:Mt.runAllBtn,children:R?"Running...":"Run All"})]})]}),a.jsxs("div",{style:Mt.cells,children:[u.cells.length===0&&a.jsx("div",{style:Mt.empty,children:"No cells yet. Add a SQL, code, ingest, or markdown cell above."}),u.cells.map((B,se)=>a.jsx("div",{style:Et.cellWrap,children:a.jsx(fm,{cell:B,notebookName:T,onUpdate:w=>M(se,w),onDelete:()=>Te(se),externalRunning:d===B.id})},B.id||se))]})]}):a.jsxs("div",{style:Mt.container,children:[a.jsx("div",{style:Mt.listHeader,children:a.jsxs("div",{style:Mt.newRow,children:[a.jsx("input",{value:L,onChange:B=>I(B.target.value),placeholder:"notebook name...",style:Mt.input,onKeyDown:B=>B.key==="Enter"&&W()}),a.jsx("button",{onClick:W,style:Mt.btn,children:"New"})]})}),C&&a.jsx("div",{style:{color:"var(--havn-red)",fontSize:"12px",padding:"6px 12px"},children:C}),a.jsxs("div",{style:Mt.list,children:[l.length===0&&a.jsx("div",{style:Mt.empty,children:"No notebooks yet. Create one above."}),l.map(B=>a.jsxs("div",{"data-havn-notebook":"",onClick:()=>j(B.path),style:Mt.nbItem,children:[a.jsx("span",{style:Mt.nbName,children:B.title||B.name}),a.jsxs("span",{style:Mt.nbMeta,children:[a.jsx("span",{style:Mt.nbPath,children:B.path})," · ",B.cells," cells"]})]},B.path))]})]})}const Mt={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},listHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},newRow:{display:"flex",gap:"8px",flex:1},input:{flex:1,padding:"6px 10px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontSize:"13px"},btn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"11px",fontWeight:500},list:{flex:1,overflow:"auto",padding:"8px"},empty:{color:"var(--havn-text-dim)",textAlign:"center",padding:"24px"},nbItem:{padding:"10px 12px",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"4px",border:"1px solid var(--havn-border)"},nbName:{fontWeight:500,fontSize:"13px"},nbMeta:{color:"var(--havn-text-secondary)",fontSize:"12px"},nbPath:{fontFamily:"var(--havn-font-mono)",fontSize:"11px",color:"var(--havn-text-dim)"},nbHeader:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},backBtn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"11px",fontWeight:500},nbTitle:{fontWeight:600,fontSize:"14px",flex:1},nbActions:{display:"flex",gap:"6px"},runAllBtn:{padding:"4px 12px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"11px",fontWeight:500},cells:{flex:1,overflow:"auto",padding:"12px 16px",maxWidth:"900px",margin:"0 auto",width:"100%",boxSizing:"border-box"}},Et={cellWrap:{position:"relative",marginBottom:"10px"},codeCell:{border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",background:"var(--havn-bg-tertiary)",overflow:"hidden"},mdCell:{border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",background:"var(--havn-bg-tertiary)",overflow:"hidden"},cellHeader:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",minHeight:"32px",borderBottom:"1px solid var(--havn-border)",background:"var(--havn-bg-secondary)"},cellType:{fontSize:"9px",fontWeight:700,color:"var(--havn-text-dim)",letterSpacing:"0.5px",textTransform:"uppercase"},runBtn:{width:"28px",height:"24px",background:"var(--havn-green)",border:"none",borderRadius:"var(--havn-radius)",color:"#fff",cursor:"pointer",fontSize:"11px",fontWeight:600},toggleBtn:{padding:"2px 8px",background:"none",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"10px",fontWeight:600},duration:{color:"var(--havn-text-secondary)",fontSize:"11px"},codeInput:{width:"100%",padding:"8px 12px",background:"transparent",border:"none",color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"13px",resize:"vertical",outline:"none",boxSizing:"border-box",lineHeight:1.5},outputArea:{borderTop:"1px solid var(--havn-border)",padding:"8px 12px",maxHeight:"300px",overflow:"auto",background:"color-mix(in srgb, var(--havn-bg) 50%, var(--havn-bg-tertiary))"},tableWrap:{overflow:"auto"},table:{width:"100%",borderCollapse:"collapse",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},th:{textAlign:"left",padding:"4px 8px",borderBottom:"1px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600},td:{padding:"3px 8px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)"},null:{color:"var(--havn-text-dim)",fontStyle:"italic"},truncated:{padding:"4px",color:"var(--havn-yellow)",fontSize:"11px"},error:{color:"var(--havn-red)",fontSize:"12px",fontFamily:"var(--havn-font-mono)",margin:0,whiteSpace:"pre-wrap"},text:{color:"var(--havn-text)",fontSize:"12px",fontFamily:"var(--havn-font-mono)",margin:0,whiteSpace:"pre-wrap"},deleteBtn:{width:"22px",height:"22px",background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"14px",lineHeight:"22px",textAlign:"center",borderRadius:"var(--havn-radius)",flexShrink:0}},Dt={form:{padding:"8px 12px"},row:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},label:{width:"70px",flexShrink:0,fontSize:"11px",fontWeight:600,color:"var(--havn-text-secondary)",textTransform:"uppercase",letterSpacing:"0.3px"},input:{flex:1,padding:"5px 8px",background:"var(--havn-bg)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"12px",outline:"none",boxSizing:"border-box"},select:{flex:1,padding:"5px 8px",background:"var(--havn-bg)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)",fontSize:"12px",outline:"none"},targetRow:{display:"flex",alignItems:"center",gap:"4px",flex:1},dot:{color:"var(--havn-text-dim)",fontSize:"14px",fontWeight:700},optionsToggle:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px",padding:"2px 0",fontWeight:500},optionsArea:{marginLeft:"78px",marginBottom:"4px"}};function Ro(r){if(!r)return"";const l=Math.floor((new Date-new Date(r))/1e3);if(l<60)return"just now";const E=Math.floor(l/60);if(E<60)return`${E}m ago`;const T=Math.floor(E/60);return T<24?`${T}h ago`:`${Math.floor(T/24)}d ago`}const jr={textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text-secondary)",fontSize:11,textTransform:"uppercase"},Vr={padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"};function Lm(){const[r,l]=A.useState([]),[E,T]=A.useState(!0),[c,u]=A.useState(null),[N,L]=A.useState(null);A.useEffect(()=>{I()},[]);const I=async()=>{T(!0);try{const O=await Ee.getCDCStatus();l(O||[])}catch(O){console.error("Failed to load CDC status:",O)}T(!1)},R=async O=>{u(O);try{await Ee.resetCDCWatermark(O),L(null),await I()}catch(d){console.error("Failed to reset watermark:",d)}u(null)};return E?a.jsx("p",{style:{color:"var(--havn-text-secondary)",padding:16},children:"Loading CDC status..."}):r.length===0?null:a.jsxs("div",{style:{marginTop:24},children:[a.jsx("h3",{style:{fontSize:15,fontWeight:600,color:"var(--havn-text)",marginBottom:12},children:"Change Data Capture"}),a.jsx("p",{style:{fontSize:13,color:"var(--havn-text-secondary)",marginBottom:12},children:"Track incremental data changes from connected sources."}),a.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:jr,children:"Connector"}),a.jsx("th",{style:jr,children:"Table"}),a.jsx("th",{style:jr,children:"CDC Mode"}),a.jsx("th",{style:jr,children:"Watermark"}),a.jsx("th",{style:jr,children:"Last Sync"}),a.jsx("th",{style:jr,children:"Rows Synced"}),a.jsx("th",{style:jr,children:"Actions"})]})}),a.jsx("tbody",{children:r.map((O,d)=>a.jsxs("tr",{children:[a.jsx("td",{style:Vr,children:O.connector||O.name||"—"}),a.jsx("td",{style:Vr,children:O.table||O.table_name||"—"}),a.jsx("td",{style:Vr,children:a.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,background:"var(--havn-bg-tertiary)",color:"var(--havn-accent)"},children:O.cdc_mode||O.mode||"—"})}),a.jsx("td",{style:Vr,children:a.jsx("code",{style:{fontSize:12},children:O.watermark||O.high_watermark||"—"})}),a.jsx("td",{style:Vr,children:O.last_sync||O.synced_at||"—"}),a.jsx("td",{style:Vr,children:O.rows_synced!=null?O.rows_synced.toLocaleString():"—"}),a.jsx("td",{style:Vr,children:N===(O.connector||O.name)?a.jsxs("span",{style:{display:"flex",gap:4},children:[a.jsx("button",{onClick:()=>R(O.connector||O.name),disabled:c===(O.connector||O.name),style:{padding:"4px 12px",background:"var(--havn-red-bg)",color:"var(--havn-red)",border:"1px solid var(--havn-red-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500},children:c===(O.connector||O.name)?"Resetting...":"Confirm"}),a.jsx("button",{onClick:()=>L(null),style:{padding:"4px 12px",background:"var(--havn-btn-bg)",color:"var(--havn-text)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500},children:"Cancel"})]}):a.jsx("button",{onClick:()=>L(O.connector||O.name),style:{padding:"4px 12px",background:"var(--havn-btn-bg)",color:"var(--havn-text)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500},children:"Reset Watermark"})})]},d))})]})]})}function _m({addOutput:r,showConfirm:l}){const[E,T]=A.useState("home"),[c,u]=A.useState([]),[N,L]=A.useState([]),[I,R]=A.useState(!0),O=Ar(),[d,_]=A.useState(""),[C,f]=A.useState("landing"),[m,j]=A.useState(""),[W,P]=A.useState(null),[Z,v]=A.useState(!1),[M,Te]=A.useState(null),[B,se]=A.useState("postgres"),[w,$]=A.useState({host:"localhost",port:"5432",database:"",user:"",password:""}),[J,Ce]=A.useState([]),[Ie,ve]=A.useState(!1),[z,D]=A.useState(""),[oe,Oe]=A.useState(null),[x,y]=A.useState(1),[p,H]=A.useState({}),[ne,ae]=A.useState(""),[F,te]=A.useState("landing"),[Y,le]=A.useState(""),[he,xe]=A.useState(null),[ye,_e]=A.useState(!1),[me,Ne]=A.useState([]),[b,K]=A.useState([]),[Le,Ge]=A.useState(!1),[De,ze]=A.useState(!1),[Xe,et]=A.useState(null),[Xt,st]=A.useState({}),[Gt,Bt]=A.useState(null);A.useEffect(()=>{Ht()},[]),A.useEffect(()=>{if(!Gt)return;const X=setTimeout(()=>Bt(null),8e3);return()=>clearTimeout(X)},[Gt]);async function Ht(){R(!0);try{const[X,Pe,Ke]=await Promise.all([Ee.listAvailableConnectors().catch(()=>[]),Ee.listConfiguredConnectors().catch(()=>[]),Ee.getConnectorHealth().catch(()=>[])]);L(X),u(Pe);const zt={};let Fa=!1;const kr=Date.now()-10080*60*1e3;for(const rn of Ke)zt[rn.target]=rn,rn.started_at&&new Date(rn.started_at).getTime()<kr&&(Fa=!0);st(zt),Fa&&O("connectorStale",!0)}finally{R(!1)}}async function Pt(X){const Pe=X.target.files[0];if(Pe)try{const Ke=await Ee.uploadFile(Pe);Te(Ke),_(Ke.path),j(Pe.name.split(".")[0].replace(/[^a-zA-Z0-9_]/g,"_")),r("info",`Uploaded ${Ke.name} (${(Ke.size/1024).toFixed(1)}KB)`)}catch(Ke){r("error",`Upload failed: ${Ke.message}`)}}async function mn(){try{const X=await Ee.previewFile(d,C,m);P(X),r("info",`Preview: ${X.total_preview} rows, ${X.columns.length} columns`)}catch(X){r("error",`Preview failed: ${X.message}`)}}async function vn(){v(!0);try{const X=await Ee.importFile(d,C,m||void 0);X.status==="success"?(r("info",`Imported ${X.rows} rows into ${X.table} (${X.duration_ms}ms)`),Bt({rows:X.rows,table:X.table}),Qt()):r("error",`Import failed: ${X.error}`)}catch(X){r("error",`Import error: ${X.message}`)}v(!1)}async function dr(){const X={...w,port:parseInt(w.port)||5432};try{const Pe=await Ee.testConnection(B,X);Pe.success?(ve(!0),Ce(Pe.tables||[]),r("info",`Connected! Found ${Pe.tables.length} tables.`)):r("error",`Connection failed: ${Pe.error}`)}catch(Pe){r("error",`Connection error: ${Pe.message}`)}}async function Ha(){v(!0);try{const X={...w,port:parseInt(w.port)||5432},Pe=await Ee.importFromConnection(B,X,z,C,m||void 0);Pe.status==="success"?(r("info",`Imported ${Pe.rows} rows into ${Pe.table} (${Pe.duration_ms}ms)`),Bt({rows:Pe.rows,table:Pe.table}),Qt()):r("error",`Import failed: ${Pe.error}`)}catch(X){r("error",`Import error: ${X.message}`)}v(!1)}function Jn(X){Oe(X),y(1),xe(null),Ne([]),K([]);const Pe={};for(const Ke of X.params)Pe[Ke.name]=Ke.default!=null?String(Ke.default):"";H(Pe),ae(X.name+"_1"),te("landing"),le(X.default_schedule||""),T("connector-setup")}async function qt(){_e(!0),xe(null);try{const X=await Ee.testConnector(oe.name,p);xe(X),X.success?(r("info",`Connection test passed for ${oe.display_name}`),y(3),an()):r("error",`Connection test failed: ${X.error}`)}catch(X){xe({success:!1,error:X.message}),r("error",`Connection test error: ${X.message}`)}finally{_e(!1)}}async function an(){Ge(!0);try{const X=await Ee.discoverConnector(oe.name,p);Ne(X),K(X.map(Pe=>Pe.name)),r("info",`Discovered ${X.length} resources`)}catch(X){r("error",`Discovery failed: ${X.message}`)}finally{Ge(!1)}}async function Kt(){ze(!0);try{const X=await Ee.setupConnector(oe.name,ne,p,b.length>0?b:null,F,Y||null);r("info",`Connector "${X.connection_name}" set up — ${X.tables.length} tables, script: ${X.script_path}`),O("firstConnectorDone",!0),await Ht(),T("home")}catch(X){r("error",`Setup failed: ${X.message}`)}finally{ze(!1)}}async function sa(X){et(X);try{const Pe=await Ee.syncConnector(X);Pe.status==="success"?r("info",`Synced "${X}" (${Pe.duration_ms}ms)`):r("error",`Sync failed for "${X}": ${Pe.error}`)}catch(Pe){r("error",`Sync error: ${Pe.message}`)}finally{et(null)}}async function Kr(X){if(!(l&&!await l("Remove Connector",`Remove connector "${X}"? This deletes the ingest script and config.`,"Remove",!0))&&!(!l&&!confirm(`Remove connector "${X}"? This deletes the ingest script and config.`)))try{await Ee.removeConnector(X),r("info",`Removed connector "${X}"`),await Ht()}catch(Pe){r("error",`Remove failed: ${Pe.message}`)}}async function zr(X){try{const Pe=await Ee.regenerateConnector(X);Pe.status==="success"?r("info",`Regenerated script for "${X}" — ${Pe.script_path}`):r("error",`Regenerate failed: ${Pe.error}`)}catch(Pe){r("error",`Regenerate error: ${Pe.message}`)}}function qn(X){K(Pe=>Pe.includes(X)?Pe.filter(Ke=>Ke!==X):[...Pe,X])}function Qt(){T("home"),P(null),Te(null),_(""),j(""),ve(!1),D("")}return I?a.jsx("div",{style:U.container,children:a.jsx("div",{style:U.center,children:"Loading..."})}):E==="connector-setup"&&oe?a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsxs("span",{style:U.title,children:["Set up ",oe.display_name]}),a.jsx("button",{onClick:Qt,style:U.btnText,children:"Cancel"})]}),a.jsx("div",{style:U.content,children:a.jsxs("div",{style:U.wizard,children:[a.jsx("div",{style:U.steps,children:["Configure","Test","Select Resources","Confirm"].map((X,Pe)=>a.jsxs("div",{style:{...U.step,...x>=Pe+1?U.stepActive:{}},children:[a.jsx("span",{style:U.stepNum,children:Pe+1}),a.jsx("span",{style:U.stepLabel,children:X})]},Pe))}),x>=1&&a.jsxs("div",{style:U.section,children:[a.jsx("h3",{style:U.sectionTitle,children:"Connection Parameters"}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Connection Name"}),a.jsx("input",{value:ne,onChange:X=>ae(X.target.value),style:U.input,placeholder:"my_connection"})]}),oe.params.map(X=>a.jsxs("div",{style:U.formGroup,children:[a.jsxs("label",{style:U.label,children:[X.name.replace(/_/g," "),X.required&&a.jsx("span",{style:U.required,children:"*"}),X.secret&&a.jsx("span",{style:U.secretBadge,children:"secret"})]}),a.jsx("input",{type:X.secret?"password":"text",value:p[X.name]||"",onChange:Pe=>H({...p,[X.name]:Pe.target.value}),style:U.input,placeholder:X.description}),X.description&&a.jsx("span",{style:U.hint,children:X.description})]},X.name)),a.jsxs("div",{style:U.formRow,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Target Schema"}),a.jsx("input",{value:F,onChange:X=>te(X.target.value),style:U.input})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Schedule (cron)"}),a.jsx("input",{value:Y,onChange:X=>le(X.target.value),style:U.input,placeholder:oe.default_schedule||"e.g. 0 6 * * *"})]})]}),a.jsxs("div",{style:U.actions,children:[a.jsx("button",{onClick:()=>{y(2),qt()},disabled:ye||!ne,style:U.btnPrimary,children:ye?"Testing...":"Test Connection"}),a.jsx("button",{onClick:()=>{y(3),an()},style:U.btn,children:"Skip Test"})]})]}),x>=2&&he&&a.jsxs("div",{style:U.section,children:[a.jsx("h3",{style:U.sectionTitle,children:"Connection Test"}),a.jsxs("div",{style:{...U.testResult,borderColor:he.success?"var(--havn-green)":"var(--havn-red)"},children:[a.jsx("span",{style:{color:he.success?"var(--havn-green)":"var(--havn-red)",fontWeight:600},children:he.success?"Connected successfully":"Connection failed"}),he.error&&a.jsx("div",{style:U.testError,children:he.error})]}),!he.success&&a.jsx("div",{style:U.actions,children:a.jsx("button",{onClick:()=>{y(1),xe(null)},style:U.btn,children:"Back to Configure"})})]}),x>=3&&a.jsxs("div",{style:U.section,children:[a.jsxs("h3",{style:U.sectionTitle,children:["Resources to Sync",Le&&a.jsx("span",{style:U.discovering,children:" (discovering...)"})]}),me.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{style:U.resourceList,children:me.map(X=>a.jsxs("label",{style:U.resourceItem,children:[a.jsx("input",{type:"checkbox",checked:b.includes(X.name),onChange:()=>qn(X.name),style:U.checkbox}),a.jsx("span",{style:U.resourceName,children:X.name}),X.description&&a.jsx("span",{style:U.resourceDesc,children:X.description})]},X.name))}),a.jsxs("div",{style:U.resourceActions,children:[a.jsx("button",{onClick:()=>K(me.map(X=>X.name)),style:U.btnSmall,children:"Select All"}),a.jsx("button",{onClick:()=>K([]),style:U.btnSmall,children:"Select None"}),a.jsxs("span",{style:U.resourceCount,children:[b.length,"/",me.length," selected"]})]})]}):!Le&&a.jsx("div",{style:U.dimText,children:"No resources discovered (tables will be auto-detected)"}),a.jsx("div",{style:U.actions,children:a.jsx("button",{onClick:()=>y(4),style:U.btnPrimary,children:"Continue"})})]}),x>=4&&a.jsxs("div",{style:U.section,children:[a.jsx("h3",{style:U.sectionTitle,children:"Review & Confirm"}),a.jsxs("div",{style:U.summary,children:[a.jsxs("div",{style:U.summaryRow,children:[a.jsx("span",{style:U.summaryLabel,children:"Connector"}),a.jsx("span",{children:oe.display_name})]}),a.jsxs("div",{style:U.summaryRow,children:[a.jsx("span",{style:U.summaryLabel,children:"Name"}),a.jsx("span",{style:U.mono,children:ne})]}),a.jsxs("div",{style:U.summaryRow,children:[a.jsx("span",{style:U.summaryLabel,children:"Schema"}),a.jsx("span",{style:U.mono,children:F})]}),a.jsxs("div",{style:U.summaryRow,children:[a.jsx("span",{style:U.summaryLabel,children:"Resources"}),a.jsx("span",{children:b.length||"auto-detect"})]}),Y&&a.jsxs("div",{style:U.summaryRow,children:[a.jsx("span",{style:U.summaryLabel,children:"Schedule"}),a.jsx("span",{style:U.mono,children:Y})]})]}),a.jsxs("div",{style:U.actions,children:[a.jsx("button",{onClick:Kt,disabled:De,style:U.btnPrimary,children:De?"Setting up...":"Create Connector"}),a.jsx("button",{onClick:()=>y(1),style:U.btn,children:"Back"})]})]})]})})]}):E==="connector-catalog"?a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsx("span",{style:U.title,children:"Choose a Connector"}),a.jsx("button",{onClick:Qt,style:U.btnText,children:"Back"})]}),a.jsx("div",{style:U.content,children:a.jsx("div",{style:U.catalog,children:N.map(X=>a.jsxs("div",{style:U.card,onClick:()=>Jn(X),children:[a.jsx("div",{style:U.cardName,children:X.display_name}),a.jsx("div",{style:U.cardDesc,children:X.description}),a.jsxs("div",{style:U.cardMeta,children:[a.jsx("span",{style:U.cardType,children:X.name}),X.default_schedule&&a.jsx("span",{style:U.cardSchedule,children:X.default_schedule})]})]},X.name))})})]}):E==="file"?a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsx("span",{style:U.title,children:"Import File"}),a.jsx("button",{onClick:Qt,style:U.btnText,children:"Back"})]}),a.jsxs("div",{style:U.content,children:[a.jsxs("div",{style:U.wizard,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Upload a CSV, Parquet, or JSON file"}),a.jsx("input",{type:"file",onChange:Pt,accept:".csv,.parquet,.pq,.json,.jsonl,.ndjson",style:U.fileInput}),M&&a.jsxs("div",{style:U.uploadInfo,children:["Uploaded: ",M.name]})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Or enter file path"}),a.jsx("input",{value:d,onChange:X=>_(X.target.value),style:U.input,placeholder:"/path/to/data.csv"})]}),a.jsxs("div",{style:U.formRow,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Target Schema"}),a.jsx("input",{value:C,onChange:X=>f(X.target.value),style:U.input})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Table Name (auto-detect if empty)"}),a.jsx("input",{value:m,onChange:X=>j(X.target.value),style:U.input,placeholder:"auto"})]})]}),a.jsxs("div",{style:U.actions,children:[a.jsx("button",{onClick:mn,disabled:!d,style:U.btn,children:"Preview"}),a.jsx("button",{onClick:vn,disabled:!d||Z,style:U.btnPrimary,children:Z?"Importing...":"Import"})]})]}),W&&a.jsxs("div",{style:U.previewSection,children:[a.jsxs("div",{style:U.previewHeader,children:["Preview: ",W.total_preview," rows, ",W.columns.length," columns"]}),a.jsx("div",{style:U.tableWrap,children:a.jsxs("table",{style:U.table,children:[a.jsx("thead",{children:a.jsx("tr",{children:W.columns.map((X,Pe)=>{var Ke;return a.jsxs("th",{style:U.th,children:[X,((Ke=W.column_types)==null?void 0:Ke[Pe])&&a.jsxs("span",{style:U.colType,children:[" ",W.column_types[Pe].type]})]},Pe)})})}),a.jsx("tbody",{children:W.rows.map((X,Pe)=>a.jsx("tr",{children:X.map((Ke,zt)=>a.jsx("td",{style:U.td,children:Ke===null?a.jsx("span",{style:U.null,children:"NULL"}):String(Ke)},zt))},Pe))})]})})]})]})]}):E==="database"?a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsx("span",{style:U.title,children:"Import from Database"}),a.jsx("button",{onClick:Qt,style:U.btnText,children:"Back"})]}),a.jsx("div",{style:U.content,children:a.jsxs("div",{style:U.wizard,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Connection Type"}),a.jsxs("select",{value:B,onChange:X=>{se(X.target.value),ve(!1)},style:U.select,children:[a.jsx("option",{value:"postgres",children:"PostgreSQL"}),a.jsx("option",{value:"mysql",children:"MySQL"}),a.jsx("option",{value:"sqlite",children:"SQLite"})]})]}),B!=="sqlite"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:U.formRow,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Host"}),a.jsx("input",{value:w.host,onChange:X=>$({...w,host:X.target.value}),style:U.input})]}),a.jsxs("div",{style:{...U.formGroup,maxWidth:"100px"},children:[a.jsx("label",{style:U.label,children:"Port"}),a.jsx("input",{value:w.port,onChange:X=>$({...w,port:X.target.value}),style:U.input})]})]}),a.jsxs("div",{style:U.formRow,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Database"}),a.jsx("input",{value:w.database,onChange:X=>$({...w,database:X.target.value}),style:U.input})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"User"}),a.jsx("input",{value:w.user,onChange:X=>$({...w,user:X.target.value}),style:U.input})]})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Password"}),a.jsx("input",{type:"password",value:w.password,onChange:X=>$({...w,password:X.target.value}),style:U.input})]})]}):a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Database Path"}),a.jsx("input",{value:w.database,onChange:X=>$({...w,database:X.target.value}),style:U.input,placeholder:"/path/to/db.sqlite"})]}),a.jsx("div",{style:U.actions,children:a.jsx("button",{onClick:dr,style:U.btn,children:"Test Connection"})}),Ie&&J.length>0&&a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Source Table"}),a.jsxs("select",{value:z,onChange:X=>D(X.target.value),style:U.select,children:[a.jsx("option",{value:"",children:"Select a table..."}),J.map(X=>a.jsxs("option",{value:`${X.schema}.${X.name}`,children:[X.schema,".",X.name]},`${X.schema}.${X.name}`))]})]}),Ie&&z&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:U.formRow,children:[a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Target Schema"}),a.jsx("input",{value:C,onChange:X=>f(X.target.value),style:U.input})]}),a.jsxs("div",{style:U.formGroup,children:[a.jsx("label",{style:U.label,children:"Table Name"}),a.jsx("input",{value:m,onChange:X=>j(X.target.value),style:U.input,placeholder:"auto"})]})]}),a.jsx("div",{style:U.actions,children:a.jsx("button",{onClick:Ha,disabled:Z,style:U.btnPrimary,children:Z?"Importing...":"Import"})})]})]})})]}):E==="manage"?a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsx("span",{style:U.title,children:"Manage Connectors"}),a.jsx("button",{onClick:Qt,style:U.btnText,children:"Back"})]}),a.jsxs("div",{style:U.content,children:[c.length===0?a.jsx("div",{style:U.emptyState,children:"No connectors configured yet."}):a.jsx("div",{style:U.connectorList,children:c.map(X=>{const Pe=`ingest/${X.name}.py`,Ke=Xt[Pe];return a.jsxs("div",{style:U.connectorItem,children:[a.jsxs("div",{style:U.connectorMain,children:[a.jsxs("div",{style:U.connectorNameRow,children:[a.jsx("span",{style:U.connectorName,children:X.name}),a.jsx("span",{style:U.connectorType,children:X.type}),a.jsx("span",{style:{...U.statusDot,background:Ke?Ke.status==="success"?"var(--havn-green)":"var(--havn-red)":X.has_script?"var(--havn-yellow)":"var(--havn-text-dim)"}}),Ke&&a.jsx("span",{style:{...U.healthInfo,color:Ke.status==="success"?"var(--havn-text-dim)":"var(--havn-red)"},children:Ke.status==="success"?`Last synced ${Ro(Ke.started_at)}`:`Last sync failed ${Ro(Ke.started_at)}`})]}),a.jsx("div",{style:U.connectorParams,children:Object.entries(X.params||{}).filter(([zt])=>zt!=="type").map(([zt,Fa])=>a.jsxs("span",{style:U.paramChip,children:[zt,": ",Fa]},zt))})]}),a.jsxs("div",{style:U.connectorActions,children:[a.jsx("button",{onClick:()=>sa(X.name),disabled:Xe===X.name||!X.has_script,style:U.btn,children:Xe===X.name?"Syncing...":"Sync"}),a.jsx("button",{onClick:()=>zr(X.name),style:U.btn,children:"Regen"}),a.jsx("button",{onClick:()=>Kr(X.name),style:U.btnDanger,children:"Remove"})]})]},X.name)})}),a.jsx(Lm,{})]})]}):a.jsxs("div",{style:U.container,children:[a.jsxs("div",{style:U.header,children:[a.jsx("span",{}),c.length>0&&a.jsxs("button",{onClick:()=>T("manage"),style:U.btn,children:["Manage (",c.length,")"]})]}),a.jsxs("div",{style:U.content,children:[Gt&&a.jsxs("div",{style:U.successBanner,onClick:()=>Bt(null),children:["Imported ",Gt.rows.toLocaleString()," rows into ",a.jsx("strong",{children:Gt.table})]}),a.jsx("div",{style:U.homeDesc,children:"How would you like to get data into your warehouse?"}),a.jsxs("div",{style:U.methodGrid,children:[a.jsxs("div",{style:U.methodCard,onClick:()=>T("file"),children:[a.jsx("div",{style:U.methodIcon,children:"^"}),a.jsx("div",{style:U.methodName,children:"Upload File"}),a.jsx("div",{style:U.methodDesc,children:"Import a CSV, Parquet, or JSON file as a one-time load."})]}),a.jsxs("div",{style:U.methodCard,onClick:()=>T("database"),children:[a.jsx("div",{style:U.methodIcon,children:"="}),a.jsx("div",{style:U.methodName,children:"Database Import"}),a.jsx("div",{style:U.methodDesc,children:"Connect to PostgreSQL, MySQL, or SQLite and import a table."})]}),a.jsxs("div",{style:U.methodCard,onClick:()=>T("connector-catalog"),children:[a.jsx("div",{style:U.methodIcon,children:"~"}),a.jsx("div",{style:U.methodName,children:"Recurring Connector"}),a.jsx("div",{style:U.methodDesc,children:"Set up a scheduled sync from databases, APIs, or other sources."})]})]}),c.length>0&&a.jsxs("div",{style:U.configuredSection,"data-havn-hint":"connector-list",children:[a.jsx("div",{style:U.configuredHeader,"data-havn-hint":"connector-health",children:"Active Connectors"}),c.map(X=>{const Pe=`ingest/${X.name}.py`,Ke=Xt[Pe];return a.jsxs("div",{style:U.configuredRow,children:[a.jsx("span",{style:{...U.statusDot,background:Ke?Ke.status==="success"?"var(--havn-green)":"var(--havn-red)":X.has_script?"var(--havn-yellow)":"var(--havn-text-dim)"}}),a.jsx("span",{style:U.connectorName,children:X.name}),a.jsx("span",{style:U.connectorType,children:X.type}),Ke&&a.jsx("span",{style:{...U.healthInfo,color:Ke.status==="success"?"var(--havn-text-dim)":"var(--havn-red)"},children:Ke.status==="success"?`synced ${Ro(Ke.started_at)}`:`failed ${Ro(Ke.started_at)}`}),a.jsx("button",{onClick:()=>sa(X.name),disabled:Xe===X.name||!X.has_script,style:U.btnSmall,children:Xe===X.name?"...":"Sync"})]},X.name)}),a.jsx("button",{onClick:()=>T("manage"),style:U.manageLink,children:"Manage all connectors"})]})]})]})}const U={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},center:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--havn-text-secondary)",fontSize:"13px"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},title:{fontWeight:600,fontSize:"13px"},content:{flex:1,overflow:"auto",padding:"16px"},homeDesc:{fontSize:"14px",color:"var(--havn-text-secondary)",marginBottom:"20px"},methodGrid:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"12px",maxWidth:"800px",marginBottom:"24px"},methodCard:{padding:"24px 20px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",textAlign:"center",transition:"border-color 0.15s"},methodIcon:{width:"40px",height:"40px",margin:"0 auto 12px",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--havn-bg-tertiary)",borderRadius:"var(--havn-radius-lg)",fontSize:"18px",fontWeight:700,color:"var(--havn-accent)",fontFamily:"var(--havn-font-mono)"},methodName:{fontSize:"14px",fontWeight:600,color:"var(--havn-text)",marginBottom:"6px"},methodDesc:{fontSize:"12px",color:"var(--havn-text-secondary)",lineHeight:1.5},configuredSection:{borderTop:"1px solid var(--havn-border)",paddingTop:"16px",maxWidth:"600px"},configuredHeader:{fontSize:"12px",fontWeight:600,color:"var(--havn-text-secondary)",marginBottom:"8px",textTransform:"uppercase",letterSpacing:"0.3px"},configuredRow:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 0",fontSize:"13px"},manageLink:{background:"none",border:"none",color:"var(--havn-accent)",cursor:"pointer",fontSize:"12px",fontWeight:500,padding:"8px 0 0"},btn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"11px",fontWeight:500},btnPrimary:{padding:"4px 12px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"11px",fontWeight:500},btnDanger:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-red)",cursor:"pointer",fontSize:"11px",fontWeight:500},btnText:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px",fontWeight:500},btnSmall:{padding:"2px 8px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px"},wizard:{maxWidth:"600px"},formGroup:{marginBottom:"12px",flex:1},formRow:{display:"flex",gap:"12px"},label:{display:"block",fontSize:"11px",color:"var(--havn-text-secondary)",marginBottom:"4px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.3px"},required:{color:"var(--havn-red)",marginLeft:"2px"},secretBadge:{marginLeft:"6px",fontSize:"9px",color:"var(--havn-yellow)",background:"var(--havn-bg-tertiary)",padding:"1px 4px",borderRadius:"var(--havn-radius)",fontWeight:500,textTransform:"none",letterSpacing:0},input:{width:"100%",padding:"6px 10px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontSize:"13px",boxSizing:"border-box"},select:{width:"100%",padding:"6px 10px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontSize:"13px"},hint:{display:"block",fontSize:"11px",color:"var(--havn-text-dim)",marginTop:"2px"},actions:{display:"flex",gap:"8px",marginTop:"12px"},fileInput:{fontSize:"12px",color:"var(--havn-text-secondary)"},uploadInfo:{fontSize:"12px",color:"var(--havn-accent)",marginTop:"4px"},previewSection:{marginTop:"24px",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",overflow:"hidden"},previewHeader:{padding:"8px 12px",background:"var(--havn-bg-secondary)",borderBottom:"1px solid var(--havn-border)",fontSize:"12px",color:"var(--havn-text-secondary)"},tableWrap:{maxHeight:"300px",overflow:"auto"},table:{width:"100%",borderCollapse:"collapse",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},th:{textAlign:"left",padding:"4px 8px",borderBottom:"1px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600,position:"sticky",top:0,background:"var(--havn-bg-tertiary)"},td:{padding:"3px 8px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)"},colType:{color:"var(--havn-text-dim)",fontWeight:400,fontSize:"10px"},null:{color:"var(--havn-text-dim)",fontStyle:"italic"},section:{marginBottom:"24px",paddingBottom:"16px",borderBottom:"1px solid var(--havn-border)"},sectionTitle:{fontSize:"14px",fontWeight:600,margin:"0 0 12px"},steps:{display:"flex",gap:"4px",marginBottom:"24px"},step:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 12px",borderRadius:"var(--havn-radius-lg)",fontSize:"12px",color:"var(--havn-text-dim)",background:"var(--havn-bg-tertiary)"},stepActive:{color:"var(--havn-text)",background:"var(--havn-btn-bg)",fontWeight:500},stepNum:{width:"18px",height:"18px",borderRadius:"50%",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:"10px",fontWeight:700,background:"var(--havn-bg-tertiary)",color:"var(--havn-text-secondary)"},stepLabel:{},testResult:{padding:"10px 14px",border:"1px solid",borderRadius:"var(--havn-radius-lg)",marginBottom:"8px"},testError:{fontSize:"12px",color:"var(--havn-text-secondary)",marginTop:"4px"},discovering:{fontSize:"12px",color:"var(--havn-text-secondary)",fontWeight:400},resourceList:{display:"flex",flexDirection:"column",gap:"2px",marginBottom:"8px"},resourceItem:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 8px",borderRadius:"var(--havn-radius)",cursor:"pointer",fontSize:"13px"},checkbox:{accentColor:"var(--havn-green)"},resourceName:{fontFamily:"var(--havn-font-mono)",fontWeight:500},resourceDesc:{color:"var(--havn-text-secondary)",fontSize:"12px"},resourceActions:{display:"flex",gap:"6px",alignItems:"center",marginBottom:"8px"},resourceCount:{fontSize:"11px",color:"var(--havn-text-dim)"},summary:{background:"var(--havn-bg-tertiary)",borderRadius:"var(--havn-radius-lg)",padding:"12px 16px",marginBottom:"12px"},summaryRow:{display:"flex",justifyContent:"space-between",padding:"4px 0",fontSize:"13px",borderBottom:"1px solid var(--havn-border)"},summaryLabel:{color:"var(--havn-text-secondary)",fontWeight:500},mono:{fontFamily:"var(--havn-font-mono)"},dimText:{fontSize:"12px",color:"var(--havn-text-dim)",marginBottom:"8px"},catalog:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(240px, 1fr))",gap:"12px",maxWidth:"900px"},card:{padding:"16px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",transition:"border-color 0.15s"},cardName:{fontWeight:600,fontSize:"14px",marginBottom:"8px"},cardDesc:{fontSize:"12px",color:"var(--havn-text-secondary)",lineHeight:1.5,marginBottom:"12px"},cardMeta:{display:"flex",gap:"8px",alignItems:"center"},cardType:{fontSize:"11px",color:"var(--havn-text-dim)",fontFamily:"var(--havn-font-mono)",background:"var(--havn-bg-tertiary)",padding:"1px 6px",borderRadius:"var(--havn-radius)"},cardSchedule:{fontSize:"10px",color:"var(--havn-text-dim)"},connectorList:{display:"flex",flexDirection:"column",gap:"8px",maxWidth:"800px"},connectorItem:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",gap:"16px"},connectorMain:{flex:1,minWidth:0},connectorNameRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},connectorName:{fontWeight:600,fontSize:"14px",fontFamily:"var(--havn-font-mono)"},connectorType:{fontSize:"11px",color:"var(--havn-text-secondary)",background:"var(--havn-bg-tertiary)",padding:"1px 6px",borderRadius:"var(--havn-radius)",fontWeight:500},statusDot:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},connectorParams:{display:"flex",flexWrap:"wrap",gap:"4px"},paramChip:{fontSize:"11px",color:"var(--havn-text-dim)",fontFamily:"var(--havn-font-mono)"},connectorActions:{display:"flex",gap:"6px",flexShrink:0},emptyState:{textAlign:"center",padding:"32px",color:"var(--havn-text-dim)",fontSize:"13px"},successBanner:{padding:"10px 16px",background:"rgba(46, 160, 67, 0.1)",border:"1px solid var(--havn-green)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-green)",fontSize:"13px",marginBottom:"16px",cursor:"pointer"},healthInfo:{fontSize:"11px",marginLeft:"auto"}};function Oc(r){if(!r)return"";const l=new Date,E=new Date(r),T=Math.floor((l-E)/1e3);if(T<60)return"just now";const c=Math.floor(T/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);return u<24?`${u}h ago`:`${Math.floor(u/24)}d ago`}function Nc(r){return r==null?"-":r>=1e6?`${(r/1e6).toFixed(1)}M`:r>=1e3?`${(r/1e3).toFixed(1)}K`:String(r)}function mm({onNavigate:r,onSelectTable:l,onOpenFile:E,onRunStream:T,streams:c}){var se;const[u,N]=A.useState(null),[L,I]=A.useState(!0),[R,O]=A.useState(!1),[d,_]=A.useState(null),[C,f]=A.useState(!1),m=Ar();A.useEffect(()=>{j(),W()},[]);async function j(){I(!0);try{const w=await Ee.getOverview();N(w),w.project_name&&(document.title=`${w.project_name} | havn`),(w.recent_runs||[]).length===0&&w.has_data&&m("overviewNoRuns",!0)}catch(w){console.error("Failed to load overview:",w)}finally{I(!1)}}async function W(){try{const w=await Ee.getGitStatus();_(w),w&&w.is_git_repo&&(m("gitDetected",!0),w.dirty&&m("gitDirty",!0))}catch{}}if(L)return a.jsx("div",{style:Me.container,children:a.jsx("div",{style:Me.center,children:"Loading overview..."})});if(!u)return a.jsx("div",{style:Me.container,children:a.jsx("div",{style:Me.center,children:"Failed to load overview."})});const P=u.recent_runs||[],Z=P.filter(w=>w.status==="success").length,v=P.filter(w=>w.status!=="success"),M=v.length,Te=u.schemas||[],B=P[0];return a.jsx("div",{style:Me.container,children:a.jsxs("div",{style:Me.scrollArea,children:[!u.has_data&&a.jsxs("div",{style:Me.hero,children:[a.jsx("img",{src:"/logo.svg",alt:"havn",width:"48",height:"48",style:{marginBottom:"12px"}}),a.jsx("div",{style:Me.heroTitle,children:"Get started with havn"}),a.jsx("div",{style:Me.heroDesc,children:"Connect a data source to start building your warehouse. Import a CSV, connect a database, or set up a recurring connector."}),a.jsxs("div",{style:Me.heroBtns,children:[a.jsx("button",{onClick:()=>r("Data Sources"),style:Me.heroCta,children:"Connect Your Data"}),c&&Object.keys(c).length>0&&T&&a.jsx("button",{onClick:()=>{O(!0),T(null,!0)},disabled:R,style:Me.heroSecondary,children:R?"Running...":"or run the sample pipeline"})]})]}),a.jsxs("div",{style:Me.statsRow,children:[a.jsxs("div",{style:Me.statCard,children:[a.jsx("div",{style:Me.statValue,children:u.total_tables}),a.jsx("div",{style:Me.statLabel,children:"Tables"})]}),a.jsxs("div",{style:Me.statCard,children:[a.jsx("div",{style:Me.statValue,children:Nc(u.total_rows)}),a.jsx("div",{style:Me.statLabel,children:"Total Rows"})]}),a.jsxs("div",{style:Me.statCard,children:[a.jsx("div",{style:Me.statValue,children:u.connectors}),a.jsx("div",{style:Me.statLabel,children:"Connectors"})]}),a.jsxs("div",{style:{...Me.statCard,cursor:M>0?"pointer":"default",outline:C?"2px solid var(--havn-red)":"none"},onClick:()=>{M>0&&f(!C)},title:M>0?"Click to show failures":"",children:[a.jsx("div",{style:{...Me.statValue,color:M>0?"var(--havn-red)":"var(--havn-green)"},children:P.length>0?`${Z}/${P.length}`:"-"}),a.jsx("div",{style:Me.statLabel,children:"Runs OK (latest)"}),M>0&&a.jsxs("div",{style:{fontSize:"10px",color:"var(--havn-red)",marginTop:"2px"},children:[M," failed ","▾"]})]})]}),C&&v.length>0&&a.jsxs("div",{style:Me.failedCard,children:[a.jsxs("div",{style:Me.failedHeader,children:[a.jsx("span",{style:Me.failedTitle,children:"Failed Runs"}),a.jsx("button",{onClick:()=>f(!1),style:Me.failedClose,children:"×"})]}),v.map(w=>a.jsxs("div",{style:Me.failedItem,children:[a.jsx("span",{style:Me.failedDot}),a.jsx("span",{style:Me.failedType,children:w.run_type}),a.jsx("span",{style:Me.failedTarget,onClick:()=>{const $=w.target||"";if(w.run_type==="transform"&&$.includes(".")){const[J,Ce]=$.split(".",2);l(J,Ce)}else(w.run_type==="ingest"||w.run_type==="export")&&E($)},children:w.target}),a.jsx("span",{style:Me.failedTime,children:Oc(w.started_at)}),w.error&&a.jsx("span",{style:Me.failedError,title:w.error,children:w.error})]},w.run_id))]}),d&&d.is_git_repo&&a.jsxs("div",{"data-havn-hint":"git-status",style:{...Me.card,marginBottom:16,padding:"10px 16px",display:"flex",alignItems:"center",gap:12,fontSize:12},children:[a.jsx("span",{style:{fontWeight:600,color:"var(--havn-text-secondary)"},children:"git"}),a.jsx("span",{style:{fontFamily:"var(--havn-font-mono)",color:"var(--havn-accent)"},children:d.branch}),a.jsx("span",{style:{color:d.dirty?"var(--havn-yellow, #eab308)":"var(--havn-green)",fontWeight:500},children:d.dirty?`${((se=d.changed_files)==null?void 0:se.length)||0} uncommitted`:"clean"}),d.last_message&&a.jsx("span",{style:{color:"var(--havn-text-dim)",marginLeft:"auto",maxWidth:300,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.last_message})]}),a.jsxs("div",{style:Me.columns,children:[a.jsx("div",{style:Me.column,children:a.jsxs("div",{style:Me.card,"data-havn-hint":"pipeline-health",children:[a.jsxs("div",{style:Me.cardHeader,children:[a.jsx("span",{style:Me.cardTitle,children:"Pipeline Health"}),B&&a.jsxs("span",{style:Me.cardSubtitle,children:["Last run ",Oc(B.started_at)]})]}),P.length===0?a.jsx("div",{style:Me.emptyState,children:"No pipeline runs yet. Run a stream or transform to see activity here."}):a.jsx("div",{style:Me.runList,children:P.slice(0,10).map(w=>a.jsxs("div",{style:Me.runItem,children:[a.jsx("span",{style:{...Me.statusDot,background:w.status==="success"?"var(--havn-green)":"var(--havn-red)"}}),a.jsx("span",{style:Me.runType,children:w.run_type}),a.jsx("span",{style:{...Me.runTarget,cursor:"pointer"},onClick:()=>{const $=w.target||"";if(w.run_type==="transform"&&$.includes(".")){const[J,Ce]=$.split(".",2);l(J,Ce)}else(w.run_type==="ingest"||w.run_type==="export")&&E($)},children:w.target}),a.jsxs("span",{style:Me.runMeta,children:[w.rows_affected>0&&a.jsxs("span",{children:[Nc(w.rows_affected)," rows"]}),w.duration_ms>0&&a.jsxs("span",{children:[w.duration_ms,"ms"]})]}),a.jsx("span",{style:Me.runTime,children:Oc(w.started_at)})]},w.run_id))}),P.length>0&&a.jsx("button",{onClick:()=>r("History"),style:Me.cardLink,children:"View all history"})]})}),a.jsxs("div",{style:Me.column,children:[a.jsxs("div",{style:Me.card,children:[a.jsx("div",{style:Me.cardHeader,children:a.jsx("span",{style:Me.cardTitle,children:"Warehouse"})}),Te.length===0?a.jsx("div",{style:Me.emptyState,children:"No data in the warehouse yet."}):a.jsx("div",{style:Me.schemaList,children:Te.map(w=>a.jsxs("div",{style:Me.schemaItem,children:[a.jsx("span",{style:{...Me.schemaName,cursor:"pointer"},onClick:()=>r("Tables"),children:w.name}),a.jsxs("span",{style:Me.schemaStat,children:[w.tables," table",w.tables!==1?"s":""]}),w.views>0&&a.jsxs("span",{style:Me.schemaStat,children:[w.views," view",w.views!==1?"s":""]}),a.jsxs("span",{style:Me.schemaRows,children:[Nc(w.total_rows)," rows"]})]},w.name))}),Te.length>0&&a.jsx("button",{onClick:()=>r("Tables"),style:Me.cardLink,children:"Browse tables"})]}),a.jsxs("div",{style:Me.card,children:[a.jsx("div",{style:Me.cardHeader,children:a.jsx("span",{style:Me.cardTitle,children:"Quick Actions"})}),a.jsxs("div",{style:Me.quickActions,children:[a.jsxs("button",{onClick:()=>r("Data Sources"),style:Me.quickAction,children:[a.jsx("span",{style:Me.qaIcon,children:"+"}),a.jsx("span",{children:"Add Data Source"})]}),a.jsxs("button",{onClick:()=>r("Query"),style:Me.quickAction,children:[a.jsx("span",{style:Me.qaIcon,children:">"}),a.jsx("span",{children:"Run a Query"})]}),a.jsxs("button",{onClick:()=>r("Editor"),style:Me.quickAction,children:[a.jsx("span",{style:Me.qaIcon,children:"#"}),a.jsx("span",{children:"Edit Transforms"})]}),a.jsxs("button",{onClick:()=>r("DAG"),style:Me.quickAction,children:[a.jsx("span",{style:Me.qaIcon,children:"•"}),a.jsx("span",{children:"View DAG"})]})]})]})]})]})]})})}const Me={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},center:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--havn-text-secondary)",fontSize:"13px"},scrollArea:{flex:1,overflow:"auto",padding:"20px 24px"},hero:{background:"linear-gradient(135deg, var(--havn-bg-secondary), var(--havn-bg-tertiary))",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",padding:"32px",textAlign:"center",marginBottom:"20px"},heroTitle:{fontSize:"20px",fontWeight:700,color:"var(--havn-text)",marginBottom:"8px"},heroDesc:{fontSize:"14px",color:"var(--havn-text-secondary)",lineHeight:1.6,maxWidth:"480px",margin:"0 auto 20px"},heroBtns:{display:"flex",flexDirection:"column",alignItems:"center",gap:"10px"},heroCta:{padding:"10px 28px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:600},heroSecondary:{padding:"6px 16px",background:"none",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",fontWeight:500},statsRow:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",marginBottom:"20px"},statCard:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",padding:"16px",textAlign:"center"},statValue:{fontSize:"24px",fontWeight:700,color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)"},statLabel:{fontSize:"11px",color:"var(--havn-text-secondary)",marginTop:"4px",textTransform:"uppercase",letterSpacing:"0.5px",fontWeight:500},failedCard:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-red, #c53030)",borderRadius:"var(--havn-radius-lg)",marginBottom:"20px",overflow:"hidden"},failedHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid var(--havn-border)"},failedTitle:{fontSize:"12px",fontWeight:600,color:"var(--havn-red, #c53030)"},failedClose:{background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"16px",lineHeight:1,padding:"0 4px"},failedItem:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",fontSize:"12px",borderBottom:"1px solid var(--havn-border)",flexWrap:"wrap"},failedDot:{width:"6px",height:"6px",borderRadius:"50%",background:"var(--havn-red, #c53030)",flexShrink:0},failedType:{fontSize:"10px",fontWeight:600,color:"var(--havn-text-secondary)",background:"var(--havn-bg-tertiary)",padding:"1px 6px",borderRadius:"var(--havn-radius)",textTransform:"uppercase",flexShrink:0},failedTarget:{fontFamily:"var(--havn-font-mono)",color:"var(--havn-accent)",cursor:"pointer",fontWeight:500},failedTime:{color:"var(--havn-text-dim)",fontSize:"11px",flexShrink:0},failedError:{color:"var(--havn-red, #c53030)",fontSize:"11px",width:"100%",paddingLeft:"14px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},columns:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},column:{display:"flex",flexDirection:"column",gap:"16px"},card:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",overflow:"hidden"},cardHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--havn-border)"},cardTitle:{fontSize:"13px",fontWeight:600,color:"var(--havn-text)"},cardSubtitle:{fontSize:"11px",color:"var(--havn-text-dim)"},cardLink:{display:"block",width:"100%",padding:"8px 16px",background:"none",border:"none",borderTop:"1px solid var(--havn-border)",color:"var(--havn-accent)",cursor:"pointer",fontSize:"12px",fontWeight:500,textAlign:"left"},emptyState:{padding:"20px 16px",color:"var(--havn-text-dim)",fontSize:"13px",textAlign:"center",lineHeight:1.5},runList:{padding:"4px 0"},runItem:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 16px",fontSize:"12px",borderBottom:"1px solid var(--havn-border)"},statusDot:{width:"6px",height:"6px",borderRadius:"50%",flexShrink:0},runType:{fontSize:"10px",fontWeight:600,color:"var(--havn-text-secondary)",background:"var(--havn-bg-tertiary)",padding:"1px 6px",borderRadius:"var(--havn-radius)",textTransform:"uppercase",flexShrink:0},runTarget:{fontFamily:"var(--havn-font-mono)",color:"var(--havn-accent)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},runMeta:{display:"flex",gap:"8px",color:"var(--havn-text-dim)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",flexShrink:0},runTime:{color:"var(--havn-text-dim)",fontSize:"11px",flexShrink:0},schemaList:{padding:"4px 0"},schemaItem:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 16px",fontSize:"13px",borderBottom:"1px solid var(--havn-border)"},schemaName:{fontWeight:600,fontFamily:"var(--havn-font-mono)",color:"var(--havn-accent)",minWidth:"70px"},schemaStat:{color:"var(--havn-text-secondary)",fontSize:"12px"},schemaRows:{marginLeft:"auto",fontFamily:"var(--havn-font-mono)",color:"var(--havn-text-dim)",fontSize:"12px"},quickActions:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1px",background:"var(--havn-border)"},quickAction:{display:"flex",alignItems:"center",gap:"8px",padding:"14px 16px",background:"var(--havn-bg-secondary)",border:"none",color:"var(--havn-text)",cursor:"pointer",fontSize:"13px",fontWeight:500,textAlign:"left"},qaIcon:{width:"24px",height:"24px",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--havn-bg-tertiary)",borderRadius:"var(--havn-radius)",fontFamily:"var(--havn-font-mono)",fontSize:"14px",fontWeight:700,color:"var(--havn-accent)",flexShrink:0}};function vm({summary:r,onNavigate:l,onDismiss:E}){if(!r)return null;const{type:T,status:c,models:u,totalRows:N,duration:L,errors:I}=r,R=c==="success",O=u?u.filter(C=>C.result==="built").length:0,d=u?u.filter(C=>C.result==="skipped").length:0,_=I||(u?u.filter(C=>C.result==="error").length:0);return a.jsxs("div",{style:{...ht.container,borderColor:R?"var(--havn-green)":"var(--havn-red)"},children:[a.jsxs("div",{style:ht.header,children:[a.jsx("span",{style:{...ht.statusBadge,background:R?"var(--havn-green)":"var(--havn-red)"},children:R?"Pipeline Complete":"Pipeline Failed"}),a.jsx("button",{onClick:E,style:ht.dismiss,children:"Dismiss"})]}),a.jsxs("div",{style:ht.stats,children:[O>0&&a.jsxs("div",{style:ht.stat,children:[a.jsx("span",{style:ht.statValue,children:O}),a.jsxs("span",{style:ht.statLabel,children:["model",O!==1?"s":""," built"]})]}),d>0&&a.jsxs("div",{style:ht.stat,children:[a.jsx("span",{style:{...ht.statValue,color:"var(--havn-text-secondary)"},children:d}),a.jsx("span",{style:ht.statLabel,children:"skipped"})]}),_>0&&a.jsxs("div",{style:ht.stat,children:[a.jsx("span",{style:{...ht.statValue,color:"var(--havn-red)"},children:_}),a.jsxs("span",{style:ht.statLabel,children:["error",_!==1?"s":""]})]}),N>0&&a.jsxs("div",{style:ht.stat,children:[a.jsx("span",{style:ht.statValue,children:N.toLocaleString()}),a.jsx("span",{style:ht.statLabel,children:"rows"})]}),L>0&&a.jsxs("div",{style:ht.stat,children:[a.jsx("span",{style:ht.statValue,children:L<1e3?`${L}ms`:`${(L/1e3).toFixed(1)}s`}),a.jsx("span",{style:ht.statLabel,children:"duration"})]})]}),u&&u.filter(C=>C.result==="built").length>0&&a.jsxs("div",{style:ht.modelList,children:[u.filter(C=>C.result==="built").slice(0,5).map(C=>a.jsx("span",{style:ht.modelChip,children:C.name},C.name)),u.filter(C=>C.result==="built").length>5&&a.jsxs("span",{style:ht.moreChip,children:["+",u.filter(C=>C.result==="built").length-5," more"]})]}),a.jsxs("div",{style:ht.actions,children:[a.jsx("button",{onClick:()=>l("Tables"),style:ht.actionBtn,children:"View Tables"}),a.jsx("button",{onClick:()=>l("Query"),style:ht.actionBtn,children:"Query Data"}),a.jsx("button",{onClick:()=>l("DAG"),style:ht.actionBtn,children:"See DAG"}),a.jsx("button",{onClick:()=>l("History"),style:ht.actionBtn,children:"History"})]})]})}const ht={container:{margin:"8px 12px",padding:"12px 16px",background:"var(--havn-bg-secondary)",border:"1px solid",borderRadius:"var(--havn-radius-lg)"},header:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"10px"},statusBadge:{padding:"3px 10px",borderRadius:"var(--havn-radius)",color:"#fff",fontSize:"12px",fontWeight:600},dismiss:{background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"11px"},stats:{display:"flex",gap:"20px",marginBottom:"10px"},stat:{display:"flex",alignItems:"baseline",gap:"4px"},statValue:{fontSize:"16px",fontWeight:700,color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)"},statLabel:{fontSize:"11px",color:"var(--havn-text-secondary)"},modelList:{display:"flex",flexWrap:"wrap",gap:"4px",marginBottom:"10px"},modelChip:{fontSize:"11px",fontFamily:"var(--havn-font-mono)",padding:"2px 8px",background:"var(--havn-bg-tertiary)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)"},moreChip:{fontSize:"11px",padding:"2px 8px",color:"var(--havn-text-dim)"},actions:{display:"flex",gap:"6px"},actionBtn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-accent)",cursor:"pointer",fontSize:"12px",fontWeight:500}};function xm(){const{colorThemeId:r,fontThemeId:l,setColorThemeId:E,setFontThemeId:T}=Gd();return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Colors"}),a.jsx("p",{style:ue.desc,children:"Choose a color palette. Combine with any font below."}),a.jsx("div",{style:ue.themeGrid,children:Ph().map(c=>{const u=Vl[c],N=r===c;return a.jsxs("button",{"data-havn-theme-card":"",onClick:()=>E(c),style:{...ue.themeCard,border:N?"2px solid var(--havn-accent)":"1px solid var(--havn-border)",background:u.vars["--havn-bg"]},children:[a.jsxs("div",{style:{display:"flex",gap:"4px",marginBottom:"8px"},children:[a.jsx("span",{style:{width:"14px",height:"14px",borderRadius:"50%",background:u.vars["--havn-accent"],border:`1px solid ${u.vars["--havn-border"]}`}}),a.jsx("span",{style:{width:"14px",height:"14px",borderRadius:"50%",background:u.vars["--havn-green"],border:`1px solid ${u.vars["--havn-border"]}`}}),a.jsx("span",{style:{width:"14px",height:"14px",borderRadius:"50%",background:u.vars["--havn-red"],border:`1px solid ${u.vars["--havn-border"]}`}})]}),a.jsx("div",{style:{color:u.vars["--havn-text"],fontSize:"12px",fontWeight:600,marginBottom:"2px"},children:u.name}),a.jsx("div",{style:{color:u.vars["--havn-text-secondary"],fontSize:"10px",lineHeight:"1.3"},children:u.description}),N&&a.jsx("div",{style:{marginTop:"6px",fontSize:"9px",color:u.vars["--havn-accent"],fontWeight:700,letterSpacing:"0.5px",textTransform:"uppercase"},children:"Active"})]},c)})}),a.jsx("h3",{style:{...ue.heading,marginTop:"20px"},children:"Fonts"}),a.jsx("p",{style:ue.desc,children:"Choose a font pairing. Works with any color theme above."}),a.jsx("div",{style:ue.fontGrid,children:Uh().map(c=>{const u=wl[c],N=l===c;return a.jsxs("button",{onClick:()=>T(c),style:{...ue.fontCard,border:N?"2px solid var(--havn-accent)":"1px solid var(--havn-border)",background:N?"var(--havn-bg-secondary)":"var(--havn-bg-tertiary)"},children:[a.jsx("div",{style:{fontSize:"14px",fontWeight:600,fontFamily:u.vars["--havn-font"],marginBottom:"2px",color:"var(--havn-text)"},children:"Aa"}),a.jsx("div",{style:{fontSize:"11px",fontFamily:u.vars["--havn-font-mono"],color:"var(--havn-accent)",marginBottom:"4px"},children:"0x1F "}),a.jsx("div",{style:{fontSize:"11px",fontWeight:500,color:"var(--havn-text)"},children:u.name}),a.jsx("div",{style:{fontSize:"10px",color:"var(--havn-text-secondary)",lineHeight:"1.3"},children:u.description}),N&&a.jsx("div",{style:{marginTop:"4px",fontSize:"9px",color:"var(--havn-accent)",fontWeight:700,letterSpacing:"0.5px",textTransform:"uppercase"},children:"Active"})]},c)})})]})}function Dm(){const[r,l]=A.useState([]),[E,T]=A.useState([]),[c,u]=A.useState(!0),[N,L]=A.useState(null);A.useEffect(()=>{I()},[]);const I=async()=>{u(!0);try{const[_,C]=await Promise.all([Ee.getScheduler(),Ee.getHistory()]);l(_.streams||[]),T(C||[])}catch(_){console.error("Failed to load scheduler data:",_)}u(!1)},R=_=>{if(!_)return"—";const C=_.split(" ");if(C.length!==5)return _;const[f,m,j,W,P]=C;return j==="*"&&W==="*"&&P==="*"?`Daily at ${m.padStart(2,"0")}:${f.padStart(2,"0")}`:j==="*"&&W==="*"?`${_} (weekly)`:_},O=_=>{const C=E.filter(m=>m.stream===_||m.name===_);if(C.length===0)return{status:"—",time:"—"};const f=C[0];return{status:f.status||f.result||"—",time:f.started_at||f.timestamp||"—"}},d=async _=>{L(_);try{await Ee.runStream(_),await I()}catch(C){console.error("Failed to run stream:",C)}L(null)};return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Scheduler"}),a.jsx("p",{style:ue.desc,children:"Configured pipeline schedules and their status."}),c?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"Loading..."}):r.length===0?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"No streams configured in project.yml"}):a.jsxs("table",{style:ue.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:ue.th,children:"Stream"}),a.jsx("th",{style:ue.th,children:"Description"}),a.jsx("th",{style:ue.th,children:"Schedule"}),a.jsx("th",{style:ue.th,children:"Last Run"}),a.jsx("th",{style:ue.th,children:"Status"}),a.jsx("th",{style:ue.th,children:"Actions"})]})}),a.jsx("tbody",{children:r.map(_=>{const C=O(_.name);return a.jsxs("tr",{children:[a.jsx("td",{style:ue.td,children:_.name}),a.jsx("td",{style:ue.td,children:_.description||"—"}),a.jsx("td",{style:ue.td,children:a.jsx("code",{style:ue.code,children:R(_.schedule)})}),a.jsx("td",{style:ue.td,children:C.time}),a.jsx("td",{style:ue.td,children:a.jsx("span",{style:{padding:"2px 8px",borderRadius:"var(--havn-radius)",fontSize:11,background:C.status==="success"?"var(--havn-green-bg)":C.status==="error"?"var(--havn-red-bg)":"var(--havn-btn-bg)",color:C.status==="success"?"var(--havn-green)":C.status==="error"?"var(--havn-red)":"var(--havn-text-secondary)"},children:C.status})}),a.jsx("td",{style:ue.td,children:a.jsx("button",{onClick:()=>d(_.name),disabled:N===_.name,style:{...ue.addBtn,opacity:N===_.name?.5:1},children:N===_.name?"Running...":"Run Now"})})]},_.name)})})]})]})}function ym({showConfirm:r}){const[l,E]=A.useState([]),[T,c]=A.useState(""),[u,N]=A.useState(""),[L,I]=A.useState(null);A.useEffect(()=>{R()},[]);async function R(){try{E(await Ee.listSecrets())}catch(_){I(_.message||"Failed to load secrets")}}async function O(){if(T.trim()){I(null);try{await Ee.setSecret(T.trim(),u),c(""),N(""),R()}catch(_){I(_.message||"Failed to add secret")}}}async function d(_){if(!(r&&!await r("Delete Secret",`Delete secret "${_}"?`,"Delete",!0))&&!(!r&&!confirm(`Delete secret "${_}"?`))){I(null);try{await Ee.deleteSecret(_),R()}catch(C){I(C.message||"Failed to delete secret")}}}return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Secrets (.env)"}),a.jsxs("p",{style:ue.desc,children:["Secrets are stored in .env and referenced as ","${VAR}"," in project.yml. Values are never exposed."]}),L&&a.jsx("p",{style:{color:"var(--havn-red)",fontSize:"12px",margin:"4px 0"},children:L}),l.length>0&&a.jsxs("table",{style:ue.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:ue.th,children:"Key"}),a.jsx("th",{style:ue.th,children:"Value"}),a.jsx("th",{style:ue.th})]})}),a.jsx("tbody",{children:l.map(_=>a.jsxs("tr",{children:[a.jsx("td",{style:ue.td,children:a.jsx("code",{style:ue.code,children:_.key})}),a.jsx("td",{style:ue.td,children:a.jsx("span",{style:ue.masked,children:_.masked_value})}),a.jsx("td",{style:{...ue.td,textAlign:"right"},children:a.jsx("button",{"data-havn-danger":"",onClick:()=>d(_.key),style:ue.delBtn,children:"Delete"})})]},_.key))})]}),a.jsxs("div",{style:ue.addRow,children:[a.jsx("input",{value:T,onChange:_=>c(_.target.value),placeholder:"KEY",style:ue.input}),a.jsx("input",{value:u,onChange:_=>N(_.target.value),placeholder:"value",style:ue.input,type:"password"}),a.jsx("button",{onClick:O,style:ue.addBtn,children:"Add"})]})]})}function gm({showConfirm:r}){const[l,E]=A.useState([]),[T,c]=A.useState(""),[u,N]=A.useState(""),[L,I]=A.useState("viewer"),[R,O]=A.useState(null);A.useEffect(()=>{d()},[]);async function d(){try{E(await Ee.listUsers())}catch(m){O(m.message||"Failed to load users")}}async function _(){if(!(!T.trim()||!u)){O(null);try{await Ee.createUser(T.trim(),u,L),c(""),N(""),d()}catch(m){O(m.message||"Failed to create user")}}}async function C(m){if(!(r&&!await r("Delete User",`Delete user "${m}"?`,"Delete",!0))&&!(!r&&!confirm(`Delete user "${m}"?`))){O(null);try{await Ee.deleteUser(m),d()}catch(j){O(j.message||"Failed to delete user")}}}async function f(m,j){O(null);try{await Ee.updateUser(m,{role:j}),d()}catch(W){O(W.message||"Failed to update role")}}return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Users"}),a.jsxs("p",{style:ue.desc,children:["Roles: ",a.jsx("strong",{children:"admin"})," (full access), ",a.jsx("strong",{children:"editor"})," (run + query), ",a.jsx("strong",{children:"viewer"})," (read-only). Enable auth with ",a.jsx("code",{style:ue.code,children:"havn serve --auth"}),"."]}),R&&a.jsx("p",{style:{color:"var(--havn-red)",fontSize:"12px",margin:"4px 0"},children:R}),l.length>0&&a.jsxs("table",{style:ue.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:ue.th,children:"Username"}),a.jsx("th",{style:ue.th,children:"Role"}),a.jsx("th",{style:ue.th,children:"Display Name"}),a.jsx("th",{style:ue.th,children:"Last Login"}),a.jsx("th",{style:ue.th})]})}),a.jsx("tbody",{children:l.map(m=>a.jsxs("tr",{children:[a.jsx("td",{style:ue.td,children:a.jsx("strong",{children:m.username})}),a.jsx("td",{style:ue.td,children:a.jsxs("select",{value:m.role,onChange:j=>f(m.username,j.target.value),style:ue.roleSelect,children:[a.jsx("option",{value:"admin",children:"admin"}),a.jsx("option",{value:"editor",children:"editor"}),a.jsx("option",{value:"viewer",children:"viewer"})]})}),a.jsx("td",{style:ue.td,children:m.display_name}),a.jsx("td",{style:{...ue.td,color:"var(--havn-text-secondary)"},children:m.last_login||"never"}),a.jsx("td",{style:{...ue.td,textAlign:"right"},children:a.jsx("button",{"data-havn-danger":"",onClick:()=>C(m.username),style:ue.delBtn,children:"Delete"})})]},m.username))})]}),a.jsxs("div",{style:ue.addRow,children:[a.jsx("input",{value:T,onChange:m=>c(m.target.value),placeholder:"username",style:ue.input}),a.jsx("input",{value:u,onChange:m=>N(m.target.value),placeholder:"password",style:ue.input,type:"password"}),a.jsxs("select",{value:L,onChange:m=>I(m.target.value),style:ue.roleSelect,children:[a.jsx("option",{value:"admin",children:"admin"}),a.jsx("option",{value:"editor",children:"editor"}),a.jsx("option",{value:"viewer",children:"viewer"})]}),a.jsx("button",{onClick:_,style:ue.addBtn,children:"Add User"})]})]})}function Mm(){const[r,l]=A.useState([]),[E,T]=A.useState(!0),[c,u]=A.useState(""),[N,L]=A.useState(""),[I,R]=A.useState(null),[O,d]=A.useState(null);A.useEffect(()=>{_()},[]);const _=async()=>{T(!0);try{const f=await Ee.getAlertHistory(50);l(f||[])}catch(f){console.error("Failed to load alert history:",f)}T(!1)},C=async f=>{R(f),d(null);try{const m=f==="slack"?{slack_webhook_url:c}:{webhook_url:N};await Ee.testAlert(f,m),d({channel:f,success:!0,message:"Test alert sent successfully!"})}catch(m){d({channel:f,success:!1,message:m.message||"Test failed"})}R(null)};return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Alerts"}),a.jsx("p",{style:ue.desc,children:"Configure and test alert channels. View alert history."}),a.jsxs("div",{style:{display:"flex",gap:16,marginBottom:16,flexWrap:"wrap"},children:[a.jsxs("div",{style:{flex:1,minWidth:280},children:[a.jsx("label",{style:ue.label,children:"Slack Webhook URL"}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("input",{style:{...ue.input,flex:1},placeholder:"https://hooks.slack.com/services/...",value:c,onChange:f=>u(f.target.value)}),a.jsx("button",{style:ue.addBtn,disabled:!c||I==="slack",onClick:()=>C("slack"),children:I==="slack"?"Testing...":"Test Slack"})]})]}),a.jsxs("div",{style:{flex:1,minWidth:280},children:[a.jsx("label",{style:ue.label,children:"Generic Webhook URL"}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("input",{style:{...ue.input,flex:1},placeholder:"https://example.com/webhook",value:N,onChange:f=>L(f.target.value)}),a.jsx("button",{style:ue.addBtn,disabled:!N||I==="webhook",onClick:()=>C("webhook"),children:I==="webhook"?"Testing...":"Test Webhook"})]})]})]}),O&&a.jsx("div",{style:{padding:"8px 12px",borderRadius:"var(--havn-radius-lg)",marginBottom:12,fontSize:13,background:O.success?"var(--havn-green-bg)":"var(--havn-red-bg)",color:O.success?"var(--havn-green)":"var(--havn-red)",border:`1px solid ${O.success?"var(--havn-green-border)":"var(--havn-red-border)"}`},children:O.message}),a.jsx("h4",{style:{...ue.heading,fontSize:14,marginTop:16},children:"Alert History"}),E?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"Loading..."}):r.length===0?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"No alerts sent yet."}):a.jsxs("table",{style:ue.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:ue.th,children:"Type"}),a.jsx("th",{style:ue.th,children:"Channel"}),a.jsx("th",{style:ue.th,children:"Target"}),a.jsx("th",{style:ue.th,children:"Message"}),a.jsx("th",{style:ue.th,children:"Status"}),a.jsx("th",{style:ue.th,children:"Sent At"})]})}),a.jsx("tbody",{children:r.map((f,m)=>a.jsxs("tr",{children:[a.jsx("td",{style:ue.td,children:f.type||f.alert_type||"—"}),a.jsx("td",{style:ue.td,children:f.channel||"—"}),a.jsx("td",{style:ue.td,title:f.target||f.webhook_url||"",children:(f.target||f.webhook_url||"—").slice(0,30)}),a.jsx("td",{style:ue.td,title:f.message||"",children:(f.message||"—").slice(0,50)}),a.jsx("td",{style:ue.td,children:a.jsx("span",{style:{padding:"2px 8px",borderRadius:"var(--havn-radius)",fontSize:11,background:f.status==="sent"||f.status==="success"?"var(--havn-green-bg)":"var(--havn-red-bg)",color:f.status==="sent"||f.status==="success"?"var(--havn-green)":"var(--havn-red)"},children:f.status||"—"})}),a.jsx("td",{style:ue.td,children:f.sent_at||f.created_at||"—"})]},m))})]})]})}const _d=`[sqlfluff]
dialect = duckdb
max_line_length = 120

[sqlfluff:rules:capitalisation.keywords]
capitalisation_policy = upper

[sqlfluff:rules:capitalisation.identifiers]
capitalisation_policy = lower

[sqlfluff:rules:capitalisation.functions]
capitalisation_policy = upper
`;function Pm({showConfirm:r}){const[l,E]=A.useState(""),[T,c]=A.useState(!1),[u,N]=A.useState(!1),[L,I]=A.useState(!0),[R,O]=A.useState(null);A.useEffect(()=>{d()},[]);async function d(){try{const f=await Ee.getLintConfig();c(f.exists),E(f.exists?f.content:_d)}catch(f){O(f.message||"Failed to load config")}I(!1)}async function _(){O(null);try{await Ee.saveLintConfig(l),c(!0),N(!0),setTimeout(()=>N(!1),2e3)}catch(f){O(f.message||"Failed to save config")}}async function C(){if(!(r&&!await r("Reset Lint Config","Delete .sqlfluff and revert to default lint settings?","Delete",!0))&&!(!r&&!confirm("Delete .sqlfluff and revert to default lint settings?"))){O(null);try{await Ee.deleteLintConfig(),c(!1),E(_d)}catch(f){O(f.message||"Failed to delete config")}}}return L?null:a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"SQLFluff Config"}),R&&a.jsx("p",{style:{color:"var(--havn-red)",fontSize:"12px",margin:"4px 0"},children:R}),a.jsx("p",{style:ue.desc,children:T?a.jsxs(a.Fragment,{children:["Editing ",a.jsx("code",{style:ue.code,children:".sqlfluff"})," in your project root. The linter uses this file."]}):a.jsxs(a.Fragment,{children:["No ",a.jsx("code",{style:ue.code,children:".sqlfluff"})," file found. Save to create one with custom lint rules."]})}),a.jsx("textarea",{value:l,onChange:f=>{E(f.target.value),N(!1)},style:ue.configTextarea,rows:14,spellCheck:!1}),a.jsxs("div",{style:{...ue.addRow,marginTop:"8px"},children:[a.jsx("button",{onClick:_,style:ue.addBtn,children:u?"Saved":"Save"}),T&&a.jsx("button",{onClick:C,style:ue.delBtn,children:"Delete .sqlfluff"})]})]})}function Um(){const{resetHints:r,totalHints:l,dismissedCount:E}=Q_(),[T,c]=A.useState(!1);function u(){r(),c(!0),setTimeout(()=>c(!1),2e3)}return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Contextual Hints"}),a.jsxs("p",{style:ue.desc,children:["Hints appear as you use the interface to highlight features at the right moment."," ",E," of ",l," hints dismissed."]}),a.jsx("button",{onClick:u,style:ue.addBtn,children:T?"Reset!":"Reset all hints"})]})}function bm({onShowGuide:r}){return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Getting Started Guide"}),a.jsx("p",{style:ue.desc,children:"Re-watch the interactive tour that explains the main areas of the interface."}),a.jsx("button",{onClick:r,style:ue.addBtn,children:"Show Guide"})]})}function Gm(){const[r,l]=A.useState(""),[E,T]=A.useState(""),[c,u]=A.useState(!1);A.useEffect(()=>{fetch("/api/config/database").then(L=>L.json()).then(L=>{l(L.memory_limit||""),T(L.threads!=null?String(L.threads):"")}).catch(()=>{})},[]);const N=()=>{fetch("/api/config/database",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({memory_limit:r||null,threads:E?parseInt(E,10):null})}).then(L=>L.json()).then(()=>{u(!0),setTimeout(()=>u(!1),2e3)}).catch(()=>{})};return a.jsxs("div",{style:ue.section,children:[a.jsx("h3",{style:ue.heading,children:"Resources"}),a.jsxs("p",{style:ue.desc,children:["Limit how much memory and CPU DuckDB can use. Useful for shared machines or large pipelines. Accepts absolute values (",a.jsx("span",{style:ue.code,children:"4GB"}),", ",a.jsx("span",{style:ue.code,children:"512MB"}),") or a percentage of system RAM (",a.jsx("span",{style:ue.code,children:"75%"}),")."]}),a.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-end",flexWrap:"wrap"},children:[a.jsxs("div",{children:[a.jsx("label",{style:ue.label,children:"Memory limit"}),a.jsx("input",{style:{...ue.input,width:"140px"},value:r,onChange:L=>l(L.target.value),placeholder:"e.g. 75% or 4GB"})]}),a.jsxs("div",{children:[a.jsx("label",{style:ue.label,children:"Max threads"}),a.jsx("input",{style:{...ue.input,width:"80px"},type:"number",min:"1",value:E,onChange:L=>T(L.target.value),placeholder:"auto"})]}),a.jsx("button",{onClick:N,style:ue.addBtn,children:c?"Saved":"Save"})]})]})}function Bm({onShowGuide:r,showConfirm:l}){return a.jsx("div",{style:ue.container,children:a.jsxs("div",{style:ue.content,children:[r&&a.jsx(bm,{onShowGuide:r}),a.jsx(Um,{}),a.jsx(xm,{}),a.jsx(Pm,{showConfirm:l}),a.jsx(Dm,{}),a.jsx(ym,{showConfirm:l}),a.jsx(gm,{showConfirm:l}),a.jsx(Mm,{}),a.jsx(Gm,{})]})})}const ue={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},content:{flex:1,overflow:"auto",padding:"16px 24px",maxWidth:"800px"},section:{marginBottom:"32px"},heading:{fontSize:"16px",fontWeight:600,margin:"0 0 4px"},desc:{fontSize:"12px",color:"var(--havn-text-secondary)",margin:"0 0 12px",lineHeight:1.6},code:{background:"var(--havn-btn-bg)",padding:"1px 5px",borderRadius:"3px",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},table:{width:"100%",borderCollapse:"collapse",marginBottom:"12px",fontSize:"12px"},th:{textAlign:"left",padding:"6px 10px",borderBottom:"2px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600},td:{padding:"6px 10px",borderBottom:"1px solid var(--havn-border)"},masked:{color:"var(--havn-text-secondary)",fontFamily:"var(--havn-font-mono)"},addRow:{display:"flex",gap:"8px",alignItems:"center"},input:{flex:1,padding:"6px 10px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontSize:"13px"},roleSelect:{padding:"4px 8px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text)",fontSize:"12px"},addBtn:{padding:"6px 14px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:500,whiteSpace:"nowrap"},delBtn:{padding:"3px 8px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius)",color:"var(--havn-red)",cursor:"pointer",fontSize:"11px"},label:{display:"block",fontSize:"12px",color:"var(--havn-text-secondary)",marginBottom:"4px"},configTextarea:{width:"100%",padding:"10px 12px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)",fontSize:"12px",lineHeight:1.6,resize:"vertical",boxSizing:"border-box",outline:"none"},themeGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:"10px"},themeCard:{padding:"12px",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",textAlign:"left",display:"block"},fontGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"10px"},fontCard:{padding:"12px",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",textAlign:"left",display:"block"}},Hm=["hash","redact","null","partial"],Fm=["admin","editor","viewer"],uo={schema_name:"",table_name:"",column_name:"",method:"hash",method_config:{},condition_column:"",condition_value:"",exempted_roles:["admin"]};function Ym(){const[r,l]=A.useState([]),[E,T]=A.useState(!0),[c,u]=A.useState(null),[N,L]=A.useState({...uo}),[I,R]=A.useState(!1),[O,d]=A.useState(null),[_,C]=A.useState(null);A.useEffect(()=>{f()},[]);const f=async()=>{T(!0);try{const v=await Ee.listMaskingPolicies();l(v||[])}catch(v){d(v.message)}T(!1)},m=async()=>{R(!0),d(null);try{const v={...N};v.method!=="partial"&&delete v.method_config,v.condition_column||(delete v.condition_column,delete v.condition_value),c==="new"?await Ee.createMaskingPolicy(v):await Ee.updateMaskingPolicy(c,v),u(null),L({...uo}),await f()}catch(v){d(v.message)}R(!1)},j=v=>{u(v.id),L({schema_name:v.schema_name||"",table_name:v.table_name||"",column_name:v.column_name||"",method:v.method||"hash",method_config:v.method_config||{},condition_column:v.condition_column||"",condition_value:v.condition_value||"",exempted_roles:v.exempted_roles||["admin"]})},W=async v=>{try{await Ee.deleteMaskingPolicy(v),C(null),await f()}catch(M){d(M.message)}},P=(v,M)=>L(Te=>({...Te,[v]:M})),Z=v=>{L(M=>({...M,exempted_roles:M.exempted_roles.includes(v)?M.exempted_roles.filter(Te=>Te!==v):[...M.exempted_roles,v]}))};return a.jsxs("div",{style:Ve.container,children:[a.jsxs("div",{style:Ve.header,children:[a.jsx("span",{}),c===null&&a.jsx("button",{style:Ve.btnPrimary,onClick:()=>{u("new"),L({...uo})},children:"+ Add Policy"})]}),a.jsxs("div",{style:Ve.content,children:[O&&a.jsxs("div",{style:Ve.error,children:[O,a.jsx("button",{onClick:()=>d(null),style:{background:"none",border:"none",color:"var(--havn-red)",cursor:"pointer",marginLeft:8},children:"×"})]}),c!==null&&a.jsxs("div",{style:Ve.formSection,children:[a.jsx("h4",{style:{color:"var(--havn-text)",fontSize:14,marginBottom:12},children:c==="new"?"New Masking Policy":"Edit Policy"}),a.jsxs("div",{style:Ve.formRow,children:[a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Schema"}),a.jsx("input",{style:Ve.input,value:N.schema_name,onChange:v=>P("schema_name",v.target.value),placeholder:"e.g. gold"})]}),a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Table"}),a.jsx("input",{style:Ve.input,value:N.table_name,onChange:v=>P("table_name",v.target.value),placeholder:"e.g. customers"})]}),a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Column"}),a.jsx("input",{style:Ve.input,value:N.column_name,onChange:v=>P("column_name",v.target.value),placeholder:"e.g. email"})]})]}),a.jsxs("div",{style:Ve.formRow,children:[a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Method"}),a.jsx("select",{style:Ve.select,value:N.method,onChange:v=>P("method",v.target.value),children:Hm.map(v=>a.jsx("option",{value:v,children:v},v))})]}),N.method==="partial"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Show First N"}),a.jsx("input",{style:Ve.input,type:"number",value:N.method_config.show_first||0,onChange:v=>L(M=>({...M,method_config:{...M.method_config,show_first:parseInt(v.target.value)||0}}))})]}),a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Show Last N"}),a.jsx("input",{style:Ve.input,type:"number",value:N.method_config.show_last||0,onChange:v=>L(M=>({...M,method_config:{...M.method_config,show_last:parseInt(v.target.value)||0}}))})]})]})]}),a.jsxs("div",{style:Ve.formRow,children:[a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Condition Column (optional)"}),a.jsx("input",{style:Ve.input,value:N.condition_column,onChange:v=>P("condition_column",v.target.value),placeholder:"e.g. region"})]}),a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Condition Value"}),a.jsx("input",{style:Ve.input,value:N.condition_value,onChange:v=>P("condition_value",v.target.value),placeholder:"e.g. EU"})]}),a.jsxs("div",{children:[a.jsx("label",{style:Ve.label,children:"Exempted Roles"}),a.jsx("div",{style:{display:"flex",gap:8,marginTop:4},children:Fm.map(v=>a.jsxs("label",{style:{display:"flex",alignItems:"center",gap:4,color:"var(--havn-text)",fontSize:13,cursor:"pointer"},children:[a.jsx("input",{type:"checkbox",checked:N.exempted_roles.includes(v),onChange:()=>Z(v)}),v]},v))})]})]}),a.jsxs("div",{style:{display:"flex",gap:8},children:[a.jsx("button",{style:Ve.btnPrimary,onClick:m,disabled:I||!N.schema_name||!N.table_name||!N.column_name,children:I?"Saving...":c==="new"?"Create Policy":"Update Policy"}),a.jsx("button",{style:Ve.btn,onClick:()=>{u(null),L({...uo})},children:"Cancel"})]})]}),E?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"Loading policies..."}):r.length===0&&c===null?a.jsxs("div",{style:{textAlign:"center",padding:40,color:"var(--havn-text-secondary)"},children:[a.jsx("p",{style:{fontSize:15,marginBottom:8},children:"No masking policies configured"}),a.jsx("p",{style:{fontSize:13},children:"Add policies to automatically mask sensitive data in query results."})]}):r.length>0&&a.jsxs("table",{style:Ve.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{style:Ve.th,children:"Schema"}),a.jsx("th",{style:Ve.th,children:"Table"}),a.jsx("th",{style:Ve.th,children:"Column"}),a.jsx("th",{style:Ve.th,children:"Method"}),a.jsx("th",{style:Ve.th,children:"Config"}),a.jsx("th",{style:Ve.th,children:"Condition"}),a.jsx("th",{style:Ve.th,children:"Exempted"}),a.jsx("th",{style:Ve.th,children:"Actions"})]})}),a.jsx("tbody",{children:r.map(v=>a.jsxs("tr",{children:[a.jsx("td",{style:Ve.td,children:v.schema_name}),a.jsx("td",{style:Ve.td,children:v.table_name}),a.jsx("td",{style:Ve.td,children:a.jsx("code",{style:Ve.code,children:v.column_name})}),a.jsx("td",{style:Ve.td,children:a.jsx("span",{style:Ve.badge,children:v.method})}),a.jsx("td",{style:Ve.td,children:v.method==="partial"?`first:${(v.method_config||{}).show_first||0} last:${(v.method_config||{}).show_last||0}`:"—"}),a.jsx("td",{style:Ve.td,children:v.condition_column?`${v.condition_column}=${v.condition_value}`:"—"}),a.jsx("td",{style:Ve.td,children:(v.exempted_roles||[]).join(", ")}),a.jsx("td",{style:Ve.td,children:a.jsxs("div",{style:{display:"flex",gap:4},children:[a.jsx("button",{style:Ve.btn,onClick:()=>j(v),children:"Edit"}),_===v.id?a.jsxs(a.Fragment,{children:[a.jsx("button",{style:Ve.btnDanger,onClick:()=>W(v.id),children:"Confirm"}),a.jsx("button",{style:{...Ve.btn,fontSize:12},onClick:()=>C(null),children:"Cancel"})]}):a.jsx("button",{style:{...Ve.btn,color:"var(--havn-red)"},onClick:()=>C(v.id),children:"Delete"})]})})]},v.id))})]})]})]})}const Ve={container:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},content:{flex:1,overflow:"auto",padding:"16px 24px",maxWidth:900},table:{width:"100%",borderCollapse:"collapse",marginBottom:12,fontSize:12},th:{textAlign:"left",padding:"6px 10px",borderBottom:"2px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontWeight:600,fontSize:11,textTransform:"uppercase"},td:{padding:"6px 10px",borderBottom:"1px solid var(--havn-border)"},btn:{padding:"4px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:11,fontWeight:500},btnPrimary:{padding:"4px 12px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:11,fontWeight:500,whiteSpace:"nowrap"},btnDanger:{padding:"4px 10px",background:"var(--havn-red-bg)",color:"var(--havn-red)",border:"1px solid var(--havn-red-border)",borderRadius:"var(--havn-radius)",cursor:"pointer",fontSize:12},input:{padding:"6px 10px",background:"var(--havn-bg-tertiary)",color:"var(--havn-text)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",fontSize:13,width:"100%",boxSizing:"border-box"},select:{padding:"6px 10px",background:"var(--havn-bg-tertiary)",color:"var(--havn-text)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",fontSize:12},label:{display:"block",fontSize:12,color:"var(--havn-text-secondary)",marginBottom:4},formRow:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:12,marginBottom:12},formSection:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",padding:16,marginBottom:16},badge:{padding:"2px 8px",borderRadius:"var(--havn-radius)",fontSize:11,background:"var(--havn-btn-bg)",color:"var(--havn-accent)"},code:{background:"var(--havn-btn-bg)",padding:"1px 5px",borderRadius:3,fontSize:12,fontFamily:"var(--havn-font-mono)"},error:{padding:"8px 12px",background:"var(--havn-red-bg)",color:"var(--havn-red)",border:"1px solid var(--havn-red-border)",borderRadius:"var(--havn-radius-lg)",marginBottom:12,fontSize:13}},jm=["Freshness","Profiles","Assertions","Contracts"];function Ao(r,l="asc"){const[E,T]=A.useState(r),[c,u]=A.useState(l);return{sortKey:E,sortDir:c,toggle:L=>{E===L?u(I=>I==="asc"?"desc":"asc"):(T(L),u("asc"))}}}function Oo(r,l,E,T){return l?[...r].sort((c,u)=>{const N=T(c,l),L=T(u,l);if(N==null&&L==null)return 0;if(N==null)return 1;if(L==null)return-1;if(typeof N=="number"&&typeof L=="number")return E==="asc"?N-L:L-N;const I=String(N).toLowerCase(),R=String(L).toLowerCase();return E==="asc"?I.localeCompare(R):R.localeCompare(I)}):r}function tn({label:r,sortKey:l,current:E,dir:T,onToggle:c,style:u}){const N=E===l?T==="asc"?" ▴":" ▾":"";return a.jsxs("th",{style:{...u,cursor:"pointer",userSelect:"none"},onClick:()=>c(l),children:[r,N]})}function Vm(){const[r,l]=A.useState("Freshness"),[E,T]=A.useState([]),[c,u]=A.useState([]),[N,L]=A.useState([]),[I,R]=A.useState([]),[O,d]=A.useState([]),[_,C]=A.useState(!0),[f,m]=A.useState(!1),[j,W]=A.useState(!1),[P,Z]=A.useState(null),[v,M]=A.useState(""),[Te,B]=A.useState("all"),[se,w]=A.useState(""),[$,J]=A.useState(""),[Ce,Ie]=A.useState("all"),[ve,z]=A.useState(""),[D,oe]=A.useState("all"),Oe=Ao("model"),x=Ao("model"),y=Ao("model"),p=Ao("model");A.useEffect(()=>{H()},[]);const H=async()=>{C(!0);try{const[b,K,Le,Ge,De]=await Promise.allSettled([Ee.getFreshness(24),Ee.getProfiles(),Ee.getAssertions(100),Ee.getContracts(),Ee.getContractHistory()]);T(b.status==="fulfilled"?Array.isArray(b.value)?b.value:[]:[]),u(K.status==="fulfilled"?K.value||[]:[]),L(Le.status==="fulfilled"?Le.value||[]:[]),R(Ge.status==="fulfilled"?Ge.value||[]:[]),d(De.status==="fulfilled"?De.value||[]:[])}catch(b){console.error(b)}C(!1)},ne=async()=>{W(!0);try{await Ee.runContracts(),await H()}catch(b){console.error(b)}W(!1)},ae=E.length,F=E.filter(b=>b.is_stale).length,te=N.filter(b=>b.passed===!0).length,Y=N.length>0?Math.round(te/N.length*100):100,le=O.filter(b=>b.passed===!0).length,he=O.length>0?Math.round(le/O.length*100):100,xe=A.useMemo(()=>{let b=E;return v&&(b=b.filter(K=>(K.model||"").toLowerCase().includes(v.toLowerCase()))),Te==="stale"&&(b=b.filter(K=>K.is_stale)),Te==="fresh"&&(b=b.filter(K=>!K.is_stale)),Oo(b,Oe.sortKey,Oe.sortDir,(K,Le)=>Le==="model"?K.model||"":Le==="hours_since_run"?K.hours_since_run??9999:Le==="is_stale"?K.is_stale?1:0:Le==="row_count"?K.row_count??0:K[Le])},[E,v,Te,Oe.sortKey,Oe.sortDir]),ye=A.useMemo(()=>{let b=c;return se&&(b=b.filter(K=>(K.model||"").toLowerCase().includes(se.toLowerCase()))),Oo(b,x.sortKey,x.sortDir,(K,Le)=>Le==="model"?K.model||"":Le==="row_count"?K.row_count??0:Le==="column_count"?K.column_count??0:K[Le])},[c,se,x.sortKey,x.sortDir]),_e=A.useMemo(()=>{let b=N;return $&&(b=b.filter(K=>(K.model||"").toLowerCase().includes($.toLowerCase())||(K.expression||"").toLowerCase().includes($.toLowerCase()))),Ce==="pass"&&(b=b.filter(K=>K.passed===!0)),Ce==="fail"&&(b=b.filter(K=>K.passed===!1)),Oo(b,y.sortKey,y.sortDir,(K,Le)=>Le==="model"?K.model||"":Le==="passed"?K.passed?0:1:Le==="checked_at"?K.checked_at||"":K[Le])},[N,$,Ce,y.sortKey,y.sortDir]),me=A.useMemo(()=>{let K=f?O:I;return ve&&(K=K.filter(Le=>(Le.model||"").toLowerCase().includes(ve.toLowerCase())||(Le.name||Le.contract_name||"").toLowerCase().includes(ve.toLowerCase()))),D==="pass"&&(K=K.filter(Le=>Le.passed===!0)),D==="fail"&&(K=K.filter(Le=>Le.passed===!1)),Oo(K,p.sortKey,p.sortDir,(Le,Ge)=>Ge==="model"?Le.model||"":Ge==="name"?Le.name||Le.contract_name||"":Ge==="severity"?Le.severity||"":Ge==="passed"?Le.passed?0:1:Le[Ge])},[I,O,f,ve,D,p.sortKey,p.sortDir]),Ne=b=>{const K=b.null_percentages||{},Le=b.distinct_counts||{};return[...new Set([...Object.keys(K),...Object.keys(Le)])].map(De=>({name:De,null_pct:K[De]??null,distinct:Le[De]??null}))};return a.jsxs("div",{style:pe.container,children:[a.jsxs("div",{style:pe.header,children:[a.jsxs("div",{style:pe.cards,children:[a.jsxs("div",{style:pe.card,children:[a.jsx("div",{style:pe.cardLabel,children:"Total Models"}),a.jsx("div",{style:pe.cardValue,children:ae})]}),a.jsxs("div",{style:pe.card,children:[a.jsx("div",{style:pe.cardLabel,children:"Stale Models"}),a.jsx("div",{style:{...pe.cardValue,color:F>0?"var(--havn-red)":"var(--havn-green)"},children:F})]}),a.jsxs("div",{style:pe.card,children:[a.jsx("div",{style:pe.cardLabel,children:"Assertion Pass Rate"}),a.jsxs("div",{style:{...pe.cardValue,color:Y===100?"var(--havn-green)":Y>=80?"var(--havn-yellow)":"var(--havn-red)"},children:[Y,"%"]})]}),a.jsxs("div",{style:pe.card,children:[a.jsx("div",{style:pe.cardLabel,children:"Contract Pass Rate"}),a.jsxs("div",{style:{...pe.cardValue,color:he===100?"var(--havn-green)":he>=80?"var(--havn-yellow)":"var(--havn-red)"},children:[he,"%"]})]})]}),a.jsx("div",{style:pe.tabs,children:jm.map(b=>a.jsx("div",{style:{...pe.tab,...r===b?pe.tabActive:{}},onClick:()=>l(b),children:b},b))})]}),a.jsx("div",{style:pe.content,children:_?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"Loading quality data..."}):a.jsxs(a.Fragment,{children:[r==="Freshness"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:pe.toolbar,children:[a.jsx("input",{style:pe.filterInput,placeholder:"Filter by model...",value:v,onChange:b=>M(b.target.value)}),a.jsxs("select",{style:pe.filterSelect,value:Te,onChange:b=>B(b.target.value),children:[a.jsx("option",{value:"all",children:"All"}),a.jsx("option",{value:"stale",children:"Stale Only"}),a.jsx("option",{value:"fresh",children:"Fresh Only"})]}),a.jsxs("span",{style:pe.count,children:[xe.length," of ",E.length]})]}),a.jsxs("table",{style:pe.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(tn,{label:"Model",sortKey:"model",current:Oe.sortKey,dir:Oe.sortDir,onToggle:Oe.toggle,style:pe.th}),a.jsx(tn,{label:"Last Run",sortKey:"last_run_at",current:Oe.sortKey,dir:Oe.sortDir,onToggle:Oe.toggle,style:pe.th}),a.jsx(tn,{label:"Hours Ago",sortKey:"hours_since_run",current:Oe.sortKey,dir:Oe.sortDir,onToggle:Oe.toggle,style:pe.th}),a.jsx(tn,{label:"Rows",sortKey:"row_count",current:Oe.sortKey,dir:Oe.sortDir,onToggle:Oe.toggle,style:pe.th}),a.jsx(tn,{label:"Status",sortKey:"is_stale",current:Oe.sortKey,dir:Oe.sortDir,onToggle:Oe.toggle,style:pe.th})]})}),a.jsx("tbody",{children:xe.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:5,style:{...pe.td,color:"var(--havn-text-dim)",textAlign:"center"},children:"No freshness data available"})}):xe.map((b,K)=>a.jsxs("tr",{children:[a.jsx("td",{style:pe.td,children:b.model}),a.jsx("td",{style:pe.td,children:b.last_run_at||"—"}),a.jsx("td",{style:pe.td,children:b.hours_since_run!=null?b.hours_since_run.toFixed(1):"—"}),a.jsx("td",{style:pe.td,children:b.row_count!=null?b.row_count.toLocaleString():"—"}),a.jsx("td",{style:pe.td,children:a.jsx("span",{style:pe.badge(!b.is_stale),children:b.is_stale?"STALE":"FRESH"})})]},K))})]})]}),r==="Profiles"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:pe.toolbar,children:[a.jsx("input",{style:pe.filterInput,placeholder:"Filter by model...",value:se,onChange:b=>w(b.target.value)}),a.jsxs("span",{style:pe.count,children:[ye.length," of ",c.length]})]}),a.jsxs("table",{style:pe.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(tn,{label:"Model",sortKey:"model",current:x.sortKey,dir:x.sortDir,onToggle:x.toggle,style:pe.th}),a.jsx(tn,{label:"Row Count",sortKey:"row_count",current:x.sortKey,dir:x.sortDir,onToggle:x.toggle,style:pe.th}),a.jsx(tn,{label:"Columns",sortKey:"column_count",current:x.sortKey,dir:x.sortDir,onToggle:x.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Profiled At"})]})}),a.jsx("tbody",{children:ye.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:4,style:{...pe.td,color:"var(--havn-text-dim)",textAlign:"center"},children:"No profiles available. Run profiling first."})}):ye.map((b,K)=>{const Le=Ne(b);return a.jsxs(aa.Fragment,{children:[a.jsxs("tr",{children:[a.jsx("td",{style:pe.td,children:Le.length>0?a.jsxs("span",{style:{cursor:"pointer",color:"var(--havn-accent)"},onClick:()=>Z(P===K?null:K),children:[P===K?"▾":"▸"," ",b.model]}):b.model}),a.jsx("td",{style:pe.td,children:b.row_count!=null?b.row_count.toLocaleString():"—"}),a.jsx("td",{style:pe.td,children:b.column_count||"—"}),a.jsx("td",{style:pe.td,children:b.profiled_at||"—"})]}),P===K&&Le.map((Ge,De)=>a.jsxs("tr",{style:{background:"var(--havn-bg-tertiary)"},children:[a.jsx("td",{style:{...pe.td,paddingLeft:32,fontFamily:"monospace",fontSize:12},children:Ge.name}),a.jsx("td",{style:pe.td,children:Ge.null_pct!=null?`${Ge.null_pct.toFixed(1)}% null`:"—"}),a.jsx("td",{style:pe.td,children:Ge.distinct!=null?`${Ge.distinct.toLocaleString()} distinct`:"—"}),a.jsx("td",{style:pe.td})]},`${K}-${De}`))]},K)})})]})]}),r==="Assertions"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:pe.toolbar,children:[a.jsx("input",{style:pe.filterInput,placeholder:"Filter by model or expression...",value:$,onChange:b=>J(b.target.value)}),a.jsxs("select",{style:pe.filterSelect,value:Ce,onChange:b=>Ie(b.target.value),children:[a.jsx("option",{value:"all",children:"All"}),a.jsx("option",{value:"pass",children:"Pass Only"}),a.jsx("option",{value:"fail",children:"Fail Only"})]}),a.jsxs("span",{style:pe.count,children:[_e.length," of ",N.length]})]}),a.jsxs("table",{style:pe.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(tn,{label:"Model",sortKey:"model",current:y.sortKey,dir:y.sortDir,onToggle:y.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Expression"}),a.jsx(tn,{label:"Status",sortKey:"passed",current:y.sortKey,dir:y.sortDir,onToggle:y.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Detail"}),a.jsx(tn,{label:"Checked At",sortKey:"checked_at",current:y.sortKey,dir:y.sortDir,onToggle:y.toggle,style:pe.th})]})}),a.jsx("tbody",{children:_e.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:5,style:{...pe.td,color:"var(--havn-text-dim)",textAlign:"center"},children:"No assertion results"})}):_e.map((b,K)=>a.jsxs("tr",{children:[a.jsx("td",{style:pe.td,children:b.model}),a.jsx("td",{style:pe.td,children:a.jsx("code",{style:{fontSize:12},children:b.expression})}),a.jsx("td",{style:pe.td,children:a.jsx("span",{style:pe.badge(b.passed),children:b.passed?"PASS":"FAIL"})}),a.jsx("td",{style:pe.td,children:b.detail||"—"}),a.jsx("td",{style:pe.td,children:b.checked_at||"—"})]},K))})]})]}),r==="Contracts"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:pe.toolbar,children:[a.jsx("button",{style:pe.btnPrimary,onClick:ne,disabled:j,children:j?"Running...":"Run Contracts"}),a.jsx("button",{style:pe.btn,onClick:()=>m(!f),children:f?"Show Definitions":"Show History"}),a.jsx("input",{style:pe.filterInput,placeholder:"Filter by model or name...",value:ve,onChange:b=>z(b.target.value)}),f&&a.jsxs("select",{style:pe.filterSelect,value:D,onChange:b=>oe(b.target.value),children:[a.jsx("option",{value:"all",children:"All"}),a.jsx("option",{value:"pass",children:"Pass Only"}),a.jsx("option",{value:"fail",children:"Fail Only"})]}),a.jsxs("span",{style:pe.count,children:[me.length," of ",(f?O:I).length]})]}),f?a.jsxs("table",{style:pe.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(tn,{label:"Contract",sortKey:"name",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx(tn,{label:"Model",sortKey:"model",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx(tn,{label:"Status",sortKey:"passed",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx(tn,{label:"Severity",sortKey:"severity",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Checked At"})]})}),a.jsx("tbody",{children:me.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:5,style:{...pe.td,color:"var(--havn-text-dim)",textAlign:"center"},children:"No contract history. Run contracts first."})}):me.map((b,K)=>a.jsxs("tr",{children:[a.jsx("td",{style:pe.td,children:b.contract_name}),a.jsx("td",{style:pe.td,children:b.model}),a.jsx("td",{style:pe.td,children:a.jsx("span",{style:pe.badge(b.passed),children:b.passed?"PASS":"FAIL"})}),a.jsx("td",{style:pe.td,children:a.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,background:b.severity==="warn"?"color-mix(in srgb, var(--havn-yellow) 15%, transparent)":"color-mix(in srgb, var(--havn-red) 15%, transparent)",color:b.severity==="warn"?"var(--havn-yellow)":"var(--havn-red)"},children:b.severity})}),a.jsx("td",{style:pe.td,children:b.checked_at||"—"})]},K))})]}):a.jsxs("table",{style:pe.table,children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(tn,{label:"Name",sortKey:"name",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx(tn,{label:"Model",sortKey:"model",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Description"}),a.jsx(tn,{label:"Severity",sortKey:"severity",current:p.sortKey,dir:p.sortDir,onToggle:p.toggle,style:pe.th}),a.jsx("th",{style:pe.th,children:"Assertions"})]})}),a.jsx("tbody",{children:me.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:5,style:{...pe.td,color:"var(--havn-text-dim)",textAlign:"center"},children:"No contracts defined. Add YAML files in contracts/"})}):me.map((b,K)=>a.jsxs("tr",{children:[a.jsx("td",{style:pe.td,children:b.name}),a.jsx("td",{style:pe.td,children:b.model}),a.jsx("td",{style:pe.td,children:b.description||"—"}),a.jsx("td",{style:pe.td,children:a.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,background:b.severity==="warn"?"color-mix(in srgb, var(--havn-yellow) 15%, transparent)":"color-mix(in srgb, var(--havn-red) 15%, transparent)",color:b.severity==="warn"?"var(--havn-yellow)":"var(--havn-red)"},children:b.severity})}),a.jsxs("td",{style:pe.td,children:[(b.assertions||[]).length," rule",(b.assertions||[]).length!==1?"s":""]})]},K))})]})]})]})})]})}const pe={container:{height:"100%",display:"flex",flexDirection:"column",background:"var(--havn-bg)"},header:{display:"flex",flexDirection:"column",padding:"8px 12px",borderBottom:"1px solid var(--havn-border)"},title:{fontSize:13,fontWeight:600,color:"var(--havn-text)"},cards:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},card:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:8,padding:"12px 16px"},cardLabel:{fontSize:11,color:"var(--havn-text-secondary)",textTransform:"uppercase",marginBottom:4},cardValue:{fontSize:24,fontWeight:700,color:"var(--havn-text)"},tabs:{display:"flex",gap:0},tab:{padding:"8px 20px",cursor:"pointer",fontSize:13,color:"var(--havn-text-secondary)",borderBottom:"2px solid transparent",background:"none"},tabActive:{color:"var(--havn-text)",borderBottom:"2px solid var(--havn-accent)"},content:{flex:1,overflow:"auto",padding:20},toolbar:{display:"flex",gap:8,marginBottom:12,alignItems:"center",flexWrap:"wrap"},filterInput:{padding:"5px 10px",background:"var(--havn-bg-tertiary)",color:"var(--havn-text)",border:"1px solid var(--havn-border-light)",borderRadius:6,fontSize:12,width:220},filterSelect:{padding:"5px 8px",background:"var(--havn-bg-tertiary)",color:"var(--havn-text)",border:"1px solid var(--havn-border-light)",borderRadius:6,fontSize:12},count:{fontSize:12,color:"var(--havn-text-dim)",marginLeft:"auto"},table:{width:"100%",borderCollapse:"collapse",fontSize:13},th:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--havn-border-light)",color:"var(--havn-text-secondary)",fontSize:11,textTransform:"uppercase"},td:{padding:"8px 12px",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)"},badge:r=>({padding:"2px 8px",borderRadius:4,fontSize:11,background:r?"color-mix(in srgb, var(--havn-green) 15%, transparent)":"color-mix(in srgb, var(--havn-red) 15%, transparent)",color:r?"var(--havn-green)":"var(--havn-red)"}),btn:{padding:"4px 12px",background:"var(--havn-btn-bg)",color:"var(--havn-text)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500},btnPrimary:{padding:"4px 12px",background:"var(--havn-green)",color:"#fff",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:11,fontWeight:500}};function wm(r){if(!r)return"";let l=r;return l=l.replace(/```(\w*)\n([\s\S]*?)```/g,(E,T,c)=>`<pre style="background:var(--havn-bg-tertiary);padding:12px;border-radius:var(--havn-radius-lg);overflow-x:auto;border:1px solid var(--havn-border)"><code>${c.replace(/</g,"&lt;").replace(/>/g,"&gt;")}</code></pre>`),l=l.replace(/`([^`]+)`/g,'<code style="background:var(--havn-btn-bg);padding:2px 6px;border-radius:3px;font-size:0.9em;font-family:var(--havn-font-mono)">$1</code>'),l=l.replace(/^### (.+)$/gm,'<h3 style="color:var(--havn-text);font-size:16px;margin:20px 0 8px">$1</h3>'),l=l.replace(/^## (.+)$/gm,'<h2 style="color:var(--havn-text);font-size:20px;margin:24px 0 10px;padding-bottom:6px;border-bottom:1px solid var(--havn-border)">$1</h2>'),l=l.replace(/^# (.+)$/gm,'<h1 style="color:var(--havn-text);font-size:26px;margin:0 0 16px;padding-bottom:8px;border-bottom:1px solid var(--havn-border-light)">$1</h1>'),l=l.replace(/\*\*(.+?)\*\*/g,'<strong style="color:var(--havn-text)">$1</strong>'),l=l.replace(/\*(.+?)\*/g,"<em>$1</em>"),l=l.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" style="color:var(--havn-accent);text-decoration:none" target="_blank">$1</a>'),l=l.replace(/(^\|.+\|$\n?)+/gm,E=>{const T=E.trim().split(`
`).filter(N=>N.trim());let c='<table style="border-collapse:collapse;width:100%;margin:12px 0">',u=!0;for(const N of T){const L=N.split("|").filter(O=>O.trim());if(L.every(O=>/^[\s-:]+$/.test(O)))continue;const I=u?"th":"td",R=u?"padding:6px 12px;border:1px solid var(--havn-border);font-weight:600;background:var(--havn-bg-secondary)":"padding:6px 12px;border:1px solid var(--havn-border)";c+="<tr>"+L.map(O=>`<${I} style="${R}">${O.trim()}</${I}>`).join("")+"</tr>",u=!1}return c+="</table>",c}),l=l.replace(/(^- .+$\n?)+/gm,E=>'<ul style="margin:8px 0;padding-left:24px">'+E.trim().split(`
`).map(c=>c.replace(/^- /,"")).map(c=>`<li style="margin:4px 0">${c}</li>`).join("")+"</ul>"),l=l.replace(/(^\d+\. .+$\n?)+/gm,E=>'<ol style="margin:8px 0;padding-left:24px">'+E.trim().split(`
`).map(c=>c.replace(/^\d+\. /,"")).map(c=>`<li style="margin:4px 0">${c}</li>`).join("")+"</ol>"),l=l.replace(/\n\n/g,'</p><p style="margin:8px 0;line-height:1.6">'),l=l.replace(/\n(?!<)/g,"<br/>"),`<p style="margin:8px 0;line-height:1.6">${l}</p>`}function Wm(){const[r,l]=A.useState([]),[E,T]=A.useState(null),[c,u]=A.useState(null),[N,L]=A.useState(!0),[I,R]=A.useState(!1),[O,d]=A.useState("");A.useEffect(()=>{_()},[]);const _=async()=>{L(!0);try{const W=await Ee.listWikiPages();if(l(W||[]),W&&W.length>0){const P=W.find(Z=>Z.slug==="index")||W[0];C(P.slug)}}catch(W){console.error(W)}L(!1)},C=async W=>{T(W),R(!0);try{const P=await Ee.getWikiPage(W);u(P)}catch{u({title:"Error",content:"Failed to load page."})}R(!1)},f=A.useMemo(()=>{const W={},P=r.filter(Z=>!O||Z.title.toLowerCase().includes(O.toLowerCase())||Z.slug.includes(O.toLowerCase()));for(const Z of P){const v=Z.category||"Other";W[v]||(W[v]=[]),W[v].push(Z)}return W},[r,O]),m=["Getting Started","Core Concepts","Data Integration","Data Quality","Security","Advanced","Reference"],j=()=>{if(E){const W=`${window.location.origin}/api/wiki/${E}`;window.open(W,"_blank")}};return a.jsxs("div",{style:Ra.container,children:[a.jsxs("div",{style:Ra.sidebar,children:[a.jsxs("div",{style:Ra.sidebarHeader,children:[a.jsx("div",{style:{fontSize:14,fontWeight:600,color:"var(--havn-text)",marginBottom:8},children:"Wiki"}),a.jsx("input",{style:Ra.search,placeholder:"Search pages...",value:O,onChange:W=>d(W.target.value)})]}),a.jsx("div",{style:Ra.sidebarContent,children:N?a.jsx("p",{style:{color:"var(--havn-text-secondary)",padding:16},children:"Loading..."}):m.filter(W=>f[W]).map(W=>a.jsxs("div",{children:[a.jsx("div",{style:Ra.category,children:W}),f[W].map(P=>a.jsx("div",{style:Ra.pageLink(E===P.slug),onClick:()=>C(P.slug),children:P.title},P.slug))]},W))})]}),a.jsx("div",{style:Ra.main,children:I?a.jsx("p",{style:{color:"var(--havn-text-secondary)"},children:"Loading..."}):c?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:Ra.mainHeader,children:[a.jsx("span",{}),a.jsx("button",{style:Ra.openBtn,onClick:j,children:"Open in New Tab"})]}),a.jsx("div",{style:{color:"var(--havn-text-secondary)",fontSize:14,lineHeight:1.7},dangerouslySetInnerHTML:{__html:wm(c.content)}})]}):a.jsx("div",{style:{color:"var(--havn-text-secondary)",textAlign:"center",marginTop:60},children:a.jsx("p",{style:{fontSize:16},children:"Select a page from the sidebar"})})})]})}const Ra={container:{height:"100%",display:"flex",background:"var(--havn-bg)"},sidebar:{width:250,borderRight:"1px solid var(--havn-border)",display:"flex",flexDirection:"column",flexShrink:0},sidebarHeader:{padding:"12px 16px",borderBottom:"1px solid var(--havn-border)"},sidebarContent:{flex:1,overflow:"auto",padding:"8px 0"},search:{width:"100%",padding:"6px 10px",background:"var(--havn-bg-tertiary)",color:"var(--havn-text)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",fontSize:13,boxSizing:"border-box"},category:{fontSize:11,color:"var(--havn-text-secondary)",textTransform:"uppercase",padding:"12px 16px 4px",letterSpacing:"0.5px"},pageLink:r=>({display:"block",padding:"6px 16px",cursor:"pointer",fontSize:13,color:r?"var(--havn-accent)":"var(--havn-text-secondary)",background:r?"var(--havn-bg-secondary)":"transparent",borderLeft:r?"2px solid var(--havn-accent)":"2px solid transparent",textDecoration:"none"}),main:{flex:1,overflow:"auto",padding:"24px 40px"},mainHeader:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},openBtn:{padding:"4px 12px",background:"var(--havn-btn-bg)",color:"var(--havn-text-secondary)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius)",cursor:"pointer",fontSize:12}};function Xm({onLogin:r,needsSetup:l}){const[E,T]=A.useState(""),[c,u]=A.useState(""),[N,L]=A.useState(""),[I,R]=A.useState(null),[O,d]=A.useState(!1);async function _(C){C.preventDefault(),d(!0),R(null);try{let f;l?f=await Ee.setup(E,c,N||E):f=await Ee.login(E,c),Ee.setToken(f.token),r(f)}catch(f){R(f.message)}d(!1)}return a.jsx("div",{style:On.backdrop,children:a.jsxs("form",{onSubmit:_,style:On.card,children:[a.jsxs("div",{style:On.logo,children:[a.jsx("img",{src:"/logo.svg",alt:"havn",width:"48",height:"48",style:{marginBottom:"8px"}}),a.jsx("div",{children:"havn"})]}),a.jsx("div",{style:On.subtitle,children:l?"Create your admin account":"Sign in to your data platform"}),I&&a.jsx("div",{style:On.error,children:I}),l&&a.jsxs("div",{style:On.fieldGroup,children:[a.jsx("label",{style:On.label,children:"Display Name"}),a.jsx("input",{value:N,onChange:C=>L(C.target.value),placeholder:"Your name",style:On.input})]}),a.jsxs("div",{style:On.fieldGroup,children:[a.jsx("label",{style:On.label,children:"Username"}),a.jsx("input",{value:E,onChange:C=>T(C.target.value),placeholder:"Enter username",style:On.input,autoFocus:!0})]}),a.jsxs("div",{style:On.fieldGroup,children:[a.jsx("label",{style:On.label,children:"Password"}),a.jsx("input",{value:c,onChange:C=>u(C.target.value),placeholder:"Enter password",type:"password",style:On.input})]}),a.jsx("button",{type:"submit",disabled:O||!E||!c,style:On.btn,children:O?"...":l?"Create Account":"Sign In"})]})})}const On={backdrop:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",background:"var(--havn-bg)",fontFamily:"var(--havn-font)"},card:{width:"360px",padding:"36px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg)",display:"flex",flexDirection:"column",gap:"16px",boxShadow:"0 4px 24px rgba(0,0,0,0.15)"},logo:{display:"flex",flexDirection:"column",alignItems:"center",fontSize:"36px",fontWeight:800,fontFamily:"var(--havn-font)",color:"var(--havn-accent)",textAlign:"center",letterSpacing:"-2px"},subtitle:{fontSize:"13px",color:"var(--havn-text-secondary)",textAlign:"center",marginBottom:"4px"},error:{padding:"8px 12px",background:"color-mix(in srgb, var(--havn-red) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--havn-red) 30%, transparent)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-red)",fontSize:"12px"},fieldGroup:{display:"flex",flexDirection:"column",gap:"4px"},label:{fontSize:"11px",fontWeight:600,color:"var(--havn-text-secondary)",textTransform:"uppercase",letterSpacing:"0.5px"},input:{padding:"10px 12px",background:"var(--havn-bg-tertiary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",fontSize:"14px"},btn:{padding:"11px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"14px",fontWeight:600,marginTop:"4px"}};function Km({steps:r,onComplete:l,isOpen:E}){const[T,c]=A.useState(0),[u,N]=A.useState(null),[L,I]=A.useState({top:0,left:0}),R=r[T],O=A.useCallback(()=>{if(!E||!R)return;if(R.position==="center"){N(null),I({top:"50%",left:"50%",transform:"translate(-50%, -50%)"});return}const d=document.querySelector(`[data-havn-guide="${R.id}"]`);if(!d){N(null),I({top:"50%",left:"50%",transform:"translate(-50%, -50%)"});return}const _=d.getBoundingClientRect(),C=6,f={top:_.top-C,left:_.left-C,width:_.width+C*2,height:_.height+C*2};N(f);const m=300,j=180,W=14;let P=0,Z=0;switch(R.position){case"right":P=f.top+f.height/2-j/2,Z=f.left+f.width+W;break;case"left":P=f.top+f.height/2-j/2,Z=f.left-m-W;break;case"bottom":P=f.top+f.height+W,Z=f.left+f.width/2-m/2;break;case"top":P=f.top-j-W,Z=f.left+f.width/2-m/2;break;default:P=f.top+f.height+W,Z=f.left}const v=window.innerWidth,M=window.innerHeight;P=Math.max(16,Math.min(M-j-16,P)),Z=Math.max(16,Math.min(v-m-16,Z)),I({top:P,left:Z})},[E,R]);return A.useEffect(()=>{O()},[O,T]),A.useEffect(()=>{if(E)return window.addEventListener("resize",O),()=>window.removeEventListener("resize",O)},[E,O]),A.useEffect(()=>{if(!E)return;function d(_){_.key==="Escape"?l():_.key==="ArrowRight"||_.key==="Enter"?T<r.length-1?c(C=>C+1):l():_.key==="ArrowLeft"&&T>0&&c(C=>C-1)}return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[E,T,r.length,l]),A.useEffect(()=>{E&&c(0)},[E]),!E||!R?null:a.jsxs("div",{style:na.overlay,children:[u?a.jsx("div",{style:{...na.spotlight,top:u.top,left:u.left,width:u.width,height:u.height}}):a.jsx("div",{style:na.dimBackground}),a.jsxs("div",{style:{...na.card,...typeof L.transform=="string"?{top:L.top,left:L.left,transform:L.transform}:{top:L.top,left:L.left}},children:[a.jsxs("div",{style:na.stepCounter,children:[T+1," of ",r.length]}),a.jsx("h3",{style:na.title,children:R.title}),a.jsx("p",{style:na.description,children:R.description}),a.jsxs("div",{style:na.buttons,children:[a.jsx("button",{onClick:l,style:na.btnSkip,children:"Skip"}),T>0&&a.jsx("button",{onClick:()=>c(d=>d-1),style:na.btnSecondary,children:"Previous"}),a.jsx("button",{onClick:()=>{T<r.length-1?c(d=>d+1):l()},style:na.btnPrimary,children:T===r.length-1?"Done":"Next"})]})]})]})}const na={overlay:{position:"fixed",inset:0,zIndex:9999,pointerEvents:"none"},spotlight:{position:"fixed",borderRadius:"var(--havn-radius-lg, 8px)",boxShadow:"0 0 0 9999px rgba(0, 0, 0, 0.55)",pointerEvents:"none",transition:"all 0.3s ease",zIndex:9999},dimBackground:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",pointerEvents:"none",zIndex:9999},card:{position:"fixed",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg, 8px)",padding:"18px 22px",width:"300px",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.35)",zIndex:1e4,pointerEvents:"auto",transition:"none"},stepCounter:{fontSize:"10px",color:"var(--havn-text-dim)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase",marginBottom:"8px"},title:{fontSize:"15px",fontWeight:600,color:"var(--havn-text)",margin:"0 0 6px"},description:{fontSize:"13px",color:"var(--havn-text-secondary)",lineHeight:1.6,margin:"0 0 16px"},buttons:{display:"flex",gap:"8px",justifyContent:"flex-end"},btnPrimary:{padding:"6px 16px",background:"var(--havn-accent)",border:"none",borderRadius:"var(--havn-radius, 4px)",color:"var(--havn-bg)",cursor:"pointer",fontSize:"12px",fontWeight:600},btnSecondary:{padding:"6px 14px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius, 4px)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px"},btnSkip:{padding:"6px 14px",background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"12px",marginRight:"auto"}};class Nn extends aa.Component{constructor(l){super(l),this.state={hasError:!1,error:null}}static getDerivedStateFromError(l){return{hasError:!0,error:l}}componentDidCatch(l,E){console.error(`[ErrorBoundary] ${this.props.name||"Unknown"}:`,l,E)}render(){var l;return this.state.hasError?a.jsxs("div",{style:bl.container,children:[a.jsx("div",{style:bl.icon,children:"!"}),a.jsx("div",{style:bl.title,children:this.props.name?`${this.props.name} crashed`:"Something went wrong"}),a.jsx("div",{style:bl.message,children:((l=this.state.error)==null?void 0:l.message)||"An unexpected error occurred."}),a.jsx("button",{style:bl.button,onClick:()=>this.setState({hasError:!1,error:null}),children:"Try Again"})]}):this.props.children}}const bl={container:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"24px",color:"var(--havn-text-secondary)",fontFamily:"var(--havn-font)",textAlign:"center",gap:"12px"},icon:{width:"36px",height:"36px",borderRadius:"50%",background:"var(--havn-red, #e53e3e)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"18px",fontWeight:"bold"},title:{fontSize:"14px",fontWeight:600,color:"var(--havn-text)"},message:{fontSize:"12px",color:"var(--havn-text-dim)",maxWidth:"400px",fontFamily:"var(--havn-font-mono)",wordBreak:"break-word"},button:{marginTop:"8px",padding:"6px 16px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",fontWeight:500}};function zm({onNavigate:r}){var R;const l=Z_(),[E,T]=A.useState(null),[c,u]=A.useState(!1),N=A.useRef(null),L=A.useCallback(()=>{if(!l){u(!1);return}const O=l.target?document.querySelector(l.target):null;if(!O){T({position:"fixed",bottom:72,right:16,top:"auto",left:"auto"}),u(!0);return}const d=O.getBoundingClientRect(),_=300,C=120,f=10,m=window.innerWidth,j=window.innerHeight;let W=d.bottom+f,P=d.left+d.width/2-_/2;W+C>j-60&&(W=d.top-C-f),P=Math.max(8,Math.min(m-_-8,P)),W=Math.max(8,Math.min(j-C-60,W)),T({position:"fixed",top:W,left:P,bottom:"auto",right:"auto"}),u(!0)},[l]);if(A.useEffect(()=>{L()},[L]),A.useEffect(()=>{if(l)return window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[l,L]),!l||!E)return null;const I=()=>{var O,d;(O=l.action)!=null&&O.navigate&&r&&r(l.action.navigate),(d=l.action)!=null&&d.callback&&l.action.callback(),l.dismiss()};return a.jsxs("div",{ref:N,style:{...wr.card,...E,opacity:c?1:0,transform:c?"translateY(0)":"translateY(6px)"},children:[a.jsxs("div",{style:wr.content,children:[a.jsx("span",{style:wr.icon,children:"*"}),a.jsx("p",{style:wr.text,children:l.text})]}),a.jsxs("div",{style:wr.buttons,children:[((R=l.action)==null?void 0:R.label)&&a.jsx("button",{onClick:I,style:wr.primaryBtn,children:l.action.label}),a.jsx("button",{onClick:()=>l.dismiss(),style:wr.dismissBtn,children:"Got it"})]})]})}const wr={card:{maxWidth:300,background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius-lg, 8px)",padding:"12px 14px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",zIndex:9e3,transition:"opacity 0.2s ease, transform 0.2s ease",pointerEvents:"auto"},content:{display:"flex",gap:"8px",alignItems:"flex-start",marginBottom:"10px"},icon:{flexShrink:0,width:"18px",height:"18px",display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--havn-bg-tertiary)",color:"var(--havn-accent)",fontSize:"12px",fontWeight:700,marginTop:"1px"},text:{margin:0,fontSize:"12px",lineHeight:1.5,color:"var(--havn-text-secondary)"},buttons:{display:"flex",gap:"6px",justifyContent:"flex-end"},primaryBtn:{padding:"4px 12px",background:"var(--havn-accent)",border:"none",borderRadius:"var(--havn-radius, 4px)",color:"var(--havn-bg)",cursor:"pointer",fontSize:"11px",fontWeight:600},dismissBtn:{padding:"4px 12px",background:"none",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius, 4px)",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"11px"}};function km({showConfirm:r}){const[l,E]=A.useState(null),[T,c]=A.useState(!0),[u,N]=A.useState(!1);if(A.useEffect(()=>{Ee.getEnvironment().then(E).catch(()=>{}).finally(()=>c(!1))},[]),T||!l||l.available.length===0)return null;const L=async I=>{if(I===l.active)return;let R;if(r?R=await r("Switch Environment",`Switch to environment "${I}"? This will reload the page and any unsaved changes will be lost.`,"Switch",!0):R=window.confirm(`Switch to environment "${I}"? This will reload the page and any unsaved changes will be lost.`),!!R){N(!0);try{const O=await Ee.switchEnvironment(I);E({...l,active:O.active,database_path:O.database_path}),window.location.reload()}catch(O){console.error("Failed to switch environment:",O)}finally{N(!1)}}};return a.jsxs("div",{className:"env-switcher",style:{display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"12px"},children:[a.jsx("span",{style:{color:"#888"},children:"env:"}),a.jsx("select",{value:l.active||"",onChange:I=>L(I.target.value),disabled:u,style:{background:"var(--bg-secondary, #1e1e1e)",color:"var(--text, #ccc)",border:"1px solid var(--border, #333)",borderRadius:"3px",padding:"2px 4px",fontSize:"12px"},children:l.available.map(I=>a.jsx("option",{value:I,children:I},I))}),a.jsxs("span",{style:{color:"#666",fontSize:"11px"},children:["(",l.database_path,")"]})]})}function $m({modelName:r,onClose:l,onSaved:E}){const[T,c]=A.useState(!0),[u,N]=A.useState(null),[L,I]=A.useState(""),[R,O]=A.useState(!1),[d,_]=A.useState(!1),[C,f]=A.useState(null),[m,j]=A.useState(!1),W=A.useCallback(async()=>{c(!0),f(null);try{const v=await Ee.getModelNotebookView(r);N(v),I(v.sql_source),O(!1)}catch(v){f(v.message)}finally{c(!1)}},[r]);A.useEffect(()=>{W()},[W]);const P=async()=>{if(u){_(!0);try{await Ee.saveFile(u.path,L),O(!1),E&&E()}catch(v){f(v.message)}finally{_(!1)}}},Z=async()=>{try{f(null),await Ee.runTransform([r],!1),await W()}catch(v){f(v.message)}};return T?a.jsx("div",{className:"model-notebook loading",children:"Loading model..."}):C&&!u?a.jsxs("div",{className:"model-notebook error",children:["Error: ",C]}):u?a.jsxs("div",{className:"model-notebook",children:[a.jsxs("div",{className:"model-notebook-header",children:[a.jsxs("div",{className:"model-notebook-title",children:[a.jsx("span",{className:"model-name",children:u.model}),a.jsx("span",{className:"model-type",children:u.materialized}),R&&a.jsx("span",{className:"model-dirty",children:"modified"})]}),a.jsxs("div",{className:"model-notebook-actions",children:[a.jsxs("button",{onClick:()=>j(!m),className:"btn-sm",children:[m?"Hide":"Show"," Lineage"]}),a.jsx("button",{onClick:P,disabled:!R||d,className:"btn-sm btn-primary",children:d?"Saving...":"Save"}),a.jsx("button",{onClick:Z,className:"btn-sm",children:"Run"}),l&&a.jsx("button",{onClick:l,className:"btn-sm",children:"Close"})]})]}),C&&a.jsx("div",{className:"model-notebook-error",children:C}),a.jsxs("div",{className:"model-notebook-body",style:{display:"flex"},children:[a.jsxs("div",{className:"model-notebook-cells",style:{flex:1},children:[a.jsxs("div",{className:"notebook-cell",children:[a.jsxs("div",{className:"cell-header",children:[a.jsx("span",{className:"cell-label",children:"SQL"}),a.jsx("span",{className:"cell-path",children:u.path})]}),a.jsx("textarea",{className:"cell-editor",value:L,onChange:v=>{I(v.target.value),O(!0)},spellCheck:!1,style:{fontFamily:"monospace",fontSize:"13px",width:"100%",minHeight:"200px",resize:"vertical",padding:"8px",border:"1px solid var(--border, #333)",borderRadius:"4px",backgroundColor:"var(--bg-secondary, #1e1e1e)",color:"var(--text, #ccc)"},onKeyDown:v=>{(v.ctrlKey||v.metaKey)&&v.key==="s"&&(v.preventDefault(),R&&P())}})]}),a.jsxs("div",{className:"notebook-cell",children:[a.jsxs("div",{className:"cell-header",children:[a.jsx("span",{className:"cell-label",children:"Output"}),a.jsxs("span",{className:"cell-info",children:["SELECT * FROM ",u.model," LIMIT 50"]})]}),u.sample_data?a.jsx("div",{className:"cell-output",style:{overflowX:"auto",maxHeight:"400px"},children:a.jsxs("table",{className:"sample-table",style:{fontSize:"12px",borderCollapse:"collapse",width:"100%"},children:[a.jsx("thead",{children:a.jsx("tr",{children:u.sample_data.columns.map(v=>a.jsx("th",{style:{padding:"4px 8px",borderBottom:"1px solid var(--border, #333)",textAlign:"left",whiteSpace:"nowrap"},children:v},v))})}),a.jsx("tbody",{children:u.sample_data.rows.map((v,M)=>a.jsx("tr",{children:v.map((Te,B)=>a.jsx("td",{style:{padding:"3px 8px",borderBottom:"1px solid var(--border, #222)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Te===null?a.jsx("span",{style:{color:"#666"},children:"null"}):String(Te)},B))},M))})]})}):a.jsx("div",{className:"cell-output-empty",style:{padding:"12px",color:"#666"},children:"No data. Run the model first."})]})]}),m&&a.jsxs("div",{className:"model-lineage-sidebar",style:{width:"250px",padding:"8px 12px",borderLeft:"1px solid var(--border, #333)",fontSize:"12px"},children:[a.jsx("h4",{style:{margin:"0 0 8px"},children:"Upstream"}),u.upstream.length>0?a.jsx("ul",{style:{listStyle:"none",padding:0,margin:"0 0 16px"},children:u.upstream.map(v=>a.jsx("li",{style:{padding:"2px 0"},children:v},v))}):a.jsx("p",{style:{color:"#666"},children:"None"}),a.jsx("h4",{style:{margin:"0 0 8px"},children:"Downstream"}),u.downstream.length>0?a.jsx("ul",{style:{listStyle:"none",padding:0,margin:"0 0 16px"},children:u.downstream.map(v=>a.jsx("li",{style:{padding:"2px 0"},children:v},v))}):a.jsx("p",{style:{color:"#666"},children:"None"}),u.lineage&&Object.keys(u.lineage).length>0&&a.jsxs(a.Fragment,{children:[a.jsx("h4",{style:{margin:"0 0 8px"},children:"Column Lineage"}),a.jsx("ul",{style:{listStyle:"none",padding:0},children:Object.entries(u.lineage).map(([v,M])=>a.jsxs("li",{style:{padding:"2px 0"},children:[a.jsx("strong",{children:v}),Array.isArray(M)&&M.length>0&&a.jsxs("span",{style:{color:"#888"},children:[" ← ",M.map(Te=>typeof Te=="string"?Te:`${Te.table}.${Te.column}`).join(", ")]})]},v))})]})]})]})]}):null}function Jm({onClose:r,onCreated:l}){const[E,T]=A.useState("model"),[c,u]=A.useState(""),[N,L]=A.useState("bronze"),[I,R]=A.useState("table"),[O,d]=A.useState(!1),[_,C]=A.useState(null),f=async()=>{if(!c.trim()){C("Name is required");return}d(!0),C(null);try{if(E==="model"){const m=await Ee.createModel(c,N,I);l&&l(m)}else if(E==="notebook"){const m=await Ee.createNotebook(c,c);l&&l(m)}else if(E==="ingest"){const m=`ingest/${c}.py`,j=`"""Ingest script: ${c}."""

import duckdb

db.execute("CREATE SCHEMA IF NOT EXISTS landing")
# Add your ingest logic here
print("Done")
`;await Ee.saveFile(m,j),l&&l({path:m})}r()}catch(m){C(m.message)}finally{d(!1)}};return a.jsx("div",{className:"dialog-overlay",onClick:r,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:a.jsxs("div",{className:"dialog",onClick:m=>m.stopPropagation(),style:{background:"var(--bg, #1e1e1e)",border:"1px solid var(--border, #333)",borderRadius:"8px",padding:"20px",width:"400px"},children:[a.jsx("h3",{style:{margin:"0 0 16px"},children:"New"}),a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"4px",fontSize:"12px",color:"#888"},children:"Type"}),a.jsxs("select",{value:E,onChange:m=>T(m.target.value),style:{width:"100%",padding:"6px",background:"var(--bg-secondary, #252525)",color:"var(--text, #ccc)",border:"1px solid var(--border, #333)",borderRadius:"4px"},children:[a.jsx("option",{value:"model",children:"SQL Model"}),a.jsx("option",{value:"notebook",children:"Notebook"}),a.jsx("option",{value:"ingest",children:"Ingest Script"})]})]}),a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"4px",fontSize:"12px",color:"#888"},children:"Name"}),a.jsx("input",{value:c,onChange:m=>u(m.target.value),placeholder:E==="model"?"my_model":E==="notebook"?"my_notebook":"my_ingest",style:{width:"100%",padding:"6px",background:"var(--bg-secondary, #252525)",color:"var(--text, #ccc)",border:"1px solid var(--border, #333)",borderRadius:"4px",boxSizing:"border-box"},autoFocus:!0,onKeyDown:m=>{m.key==="Enter"&&f()}})]}),E==="model"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"4px",fontSize:"12px",color:"#888"},children:"Schema"}),a.jsxs("select",{value:N,onChange:m=>L(m.target.value),style:{width:"100%",padding:"6px",background:"var(--bg-secondary, #252525)",color:"var(--text, #ccc)",border:"1px solid var(--border, #333)",borderRadius:"4px"},children:[a.jsx("option",{value:"bronze",children:"bronze"}),a.jsx("option",{value:"silver",children:"silver"}),a.jsx("option",{value:"gold",children:"gold"})]})]}),a.jsxs("div",{style:{marginBottom:"12px"},children:[a.jsx("label",{style:{display:"block",marginBottom:"4px",fontSize:"12px",color:"#888"},children:"Materialization"}),a.jsxs("select",{value:I,onChange:m=>R(m.target.value),style:{width:"100%",padding:"6px",background:"var(--bg-secondary, #252525)",color:"var(--text, #ccc)",border:"1px solid var(--border, #333)",borderRadius:"4px"},children:[a.jsx("option",{value:"table",children:"table"}),a.jsx("option",{value:"view",children:"view"})]})]})]}),_&&a.jsx("div",{style:{color:"#e74c3c",fontSize:"12px",marginBottom:"8px"},children:_}),a.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[a.jsx("button",{onClick:r,className:"btn-sm",children:"Cancel"}),a.jsx("button",{onClick:f,disabled:O,className:"btn-sm btn-primary",children:O?"Creating...":"Create"})]})]})})}const ba=[{id:"claude",name:"Claude Code",install:"npm install -g @anthropic-ai/claude-code",models:[{id:"",label:"Default"},{id:"claude-sonnet-4-5-20250514",label:"Sonnet 4.5"},{id:"claude-opus-4-6",label:"Opus 4.6"},{id:"claude-haiku-4-5-20251001",label:"Haiku 4.5"}]},{id:"codex",name:"Codex",install:"npm install -g @openai/codex",models:[{id:"",label:"Default"},{id:"gpt-5",label:"GPT-5"},{id:"o3",label:"o3"},{id:"o4-mini",label:"o4-mini"}]},{id:"gemini",name:"Gemini CLI",install:"npm install -g @google/gemini-cli",models:[{id:"gemini-3-flash-preview",label:"3 Flash"},{id:"gemini-3-pro-preview",label:"3 Pro"},{id:"",label:"Auto (Gemini 3)"},{id:"gemini-2.5-flash",label:"2.5 Flash"},{id:"gemini-2.5-pro",label:"2.5 Pro"}]}];function Gl(){return new Date().toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function qm(r,l){if(!r)return null;const E=[],T=r.split(/(```[\s\S]*?```)/g);for(const c of T)if(c.startsWith("```")&&c.endsWith("```")){const u=c.slice(3,-3).replace(/^[^\n]*\n/,"");E.push(a.jsx("code",{style:ge.codeBlock,children:u},E.length))}else{const u=c.split(`
`);let N=0;for(;N<u.length;){if(/^\s*\|/.test(u[N])){const R=[];for(;N<u.length&&/^\s*\|/.test(u[N]);)R.push(u[N]),N++;E.push(Qm(R,E.length));continue}N>0&&E.length>0&&!aa.isValidElement(E[E.length-1])?E.push(a.jsx("br",{},`br-${E.length}`)):N>0&&E.push(a.jsx("br",{},`br-${E.length}`));const L=u[N],I=L.match(/^(#{1,6})\s+(.+)$/);if(I){const R=I[1].length;E.push(a.jsx("span",{style:ge.heading(R),children:Ic(I[2],E.length,l)},E.length))}else/^(\s*[-*]\s)/.test(L)?E.push(a.jsx("span",{style:ge.listItem,children:Ic(L,E.length,l)},E.length)):E.push(a.jsx("span",{children:Ic(L,E.length,l)},E.length));N++}}return E}function Qm(r,l){if(r.length===0)return null;const E=N=>N.replace(/^\s*\|/,"").replace(/\|\s*$/,"").split("|").map(L=>L.trim()),T=E(r[0]),c=r.length>1&&/^[\s|:-]+$/.test(r[1])?2:1,u=r.slice(c).map(E);return a.jsxs("table",{style:ge.table,children:[a.jsx("thead",{children:a.jsx("tr",{children:T.map((N,L)=>a.jsx("th",{style:ge.th,children:N},L))})}),a.jsx("tbody",{children:u.map((N,L)=>a.jsx("tr",{children:N.map((I,R)=>a.jsx("td",{style:ge.td,children:I},R))},L))})]},l)}const Zm=/\.(?:sql|py|yml|yaml|json|csv|parquet|md|txt|toml|cfg|env|dpnb)$/;function Ic(r,l,E){const T=[],c=/(\*\*(.+?)\*\*|`([^`]+)`)/g;let u=0,N;for(;(N=c.exec(r))!==null;)N.index>u&&T.push({type:"plain",text:r.slice(u,N.index)}),N[2]?T.push({type:"bold",text:N[2]}):N[3]&&T.push({type:"code",text:N[3]}),u=c.lastIndex;u<r.length&&T.push({type:"plain",text:r.slice(u)});const L=[];let I=0;for(const R of T)if(R.type==="bold")L.push(a.jsx("strong",{style:{fontWeight:600},children:R.text},`${l}-b-${I++}`));else if(R.type==="code"){const O=ev(R.text,l,I,E);O?(L.push(O),I++):L.push(a.jsx("code",{style:ge.inlineCode,children:R.text},`${l}-c-${I++}`))}else{const O=/((?:[\w./-]+\/)+[\w.-]+\.(?:sql|py|yml|yaml|json|csv|parquet|md|txt|toml|cfg|env|dpnb))|\b((?:landing|bronze|silver|gold)\.([\w]+))\b/g;let d=0,_;for(;(_=O.exec(R.text))!==null;){if(_.index>d&&L.push(R.text.slice(d,_.index)),_[1]&&(E!=null&&E.onOpenFile)){const C=_[1];L.push(a.jsx("span",{style:ge.fileLink,onClick:()=>E.onOpenFile(C),children:C},`${l}-f-${I++}`))}else if(_[2]&&(E!=null&&E.onSelectTable)){const C=_[2].split(".")[0],f=_[3],m=_[2];L.push(a.jsx("span",{style:ge.tableLink,onClick:()=>E.onSelectTable(C,f),children:m},`${l}-t-${I++}`))}else L.push(_[0]);d=O.lastIndex}d<R.text.length&&L.push(R.text.slice(d))}return L}function ev(r,l,E,T){if(Zm.test(r)&&r.includes("/")&&(T!=null&&T.onOpenFile))return a.jsx("code",{style:{...ge.inlineCode,...ge.fileLinkCode},onClick:()=>T.onOpenFile(r),children:r},`${l}-fc-${E}`);const c=r.match(/^(landing|bronze|silver|gold)\.([\w]+)$/);return c&&(T!=null&&T.onSelectTable)?a.jsx("code",{style:{...ge.inlineCode,...ge.tableLinkCode},onClick:()=>T.onSelectTable(c[1],c[2]),children:r},`${l}-tc-${E}`):null}function tv({tool:r}){const[l,E]=A.useState(!1),T=r.detail||r.toolInput;return a.jsxs("div",{style:{display:"inline-flex",flexDirection:"column",gap:"2px"},children:[a.jsxs("span",{style:{...ge.toolChip,cursor:T?"pointer":"default"},onClick:()=>T&&E(!l),title:T?"Click to expand":r.name,children:[r.name,r.detail&&a.jsx("span",{style:ge.toolDetailInline,children:r.detail}),T&&a.jsx("span",{style:ge.toolExpandIcon,children:l?"▴":"▾"})]}),l&&r.toolInput&&a.jsxs("div",{style:ge.toolInputBlock,children:[r.toolInput.old_string!=null&&a.jsxs("div",{style:ge.diffBlock,children:[a.jsx("div",{style:ge.diffRemoved,children:r.toolInput.old_string}),a.jsx("div",{style:ge.diffAdded,children:r.toolInput.new_string})]}),r.toolInput.content!=null&&r.name==="Write"&&a.jsx("div",{style:ge.diffAdded,children:r.toolInput.content.length>500?r.toolInput.content.slice(0,500)+`
...`:r.toolInput.content}),r.toolInput.file_path&&a.jsx("div",{style:ge.toolFilePath,children:r.toolInput.file_path})]})]})}function nv({isOpen:r,onToggle:l,onFileChanged:E,onOpenFile:T,onSelectTable:c}){const[u,N]=A.useState("claude"),[L,I]=A.useState(null),[R,O]=A.useState(()=>{const x={};for(const y of ba)x[y.id]={messages:[],isConnected:!1,isStreaming:!1,permissionMode:"auto",selectedModel:""};return x}),[d,_]=A.useState(""),C=A.useRef({}),f=A.useRef({}),m=A.useRef({}),j=A.useRef(null),W=A.useRef(null),P=A.useRef(r),Z=A.useRef(E),v=A.useRef(R);P.current=r,Z.current=E,v.current=R;const M=A.useCallback((x,y)=>{O(p=>({...p,[x]:typeof y=="function"?y(p[x]):{...p[x],...y}}))},[]),Te=R[u]||{messages:[],isConnected:!1,isStreaming:!1,permissionMode:"auto",selectedModel:""};A.useEffect(()=>{fetch("/api/agents").then(x=>x.json()).then(I).catch(()=>{})},[]);const B=A.useCallback(x=>{C.current[x]&&(m.current[x]=!0,C.current[x].close());const y=window.location.protocol==="https:"?"wss:":"ws:",p=new WebSocket(`${y}//${window.location.host}/ws/agent`);C.current[x]=p,p.onopen=()=>{const H=v.current[x]||{};p.send(JSON.stringify({type:"start",agent:x,model:H.selectedModel||""}))},p.onmessage=H=>{const ne=JSON.parse(H.data);ne.type==="ready"?M(x,ae=>{var F;return{...ae,isConnected:!0,messages:[...ae.messages,{role:"system",content:`${((F=ba.find(te=>te.id===ne.agent))==null?void 0:F.name)||ne.agent} connected`,ts:Gl()}]}}):ne.type==="mode_changed"?M(x,{permissionMode:ne.mode}):ne.type==="model_changed"?M(x,{selectedModel:ne.model}):ne.type==="chunk"?(ne.chunk_type==="tool_use"&&/^(Edit|Write)$/.test(ne.content)&&Z.current&&setTimeout(()=>{var ae;return(ae=Z.current)==null?void 0:ae.call(Z)},500),M(x,ae=>{const F=ae.messages,te=F[F.length-1];let Y;return ne.chunk_type==="tool_use"?Y=[...te&&te.streaming?[...F.slice(0,-1),{...te,streaming:!1}]:[...F],{role:"assistant",content:ne.content,detail:ne.detail||"",toolInput:ne.tool_input||null,chunkType:"tool_use",streaming:!1,ts:Gl()}]:te&&te.role==="assistant"&&te.streaming&&te.chunkType==="text"?Y=[...F.slice(0,-1),{...te,content:te.content+ne.content}]:Y=[...te&&te.streaming?[...F.slice(0,-1),{...te,streaming:!1}]:[...F],{role:"assistant",content:ne.content,chunkType:ne.chunk_type||"text",streaming:!0,ts:Gl()}],{...ae,messages:Y}})):ne.type==="done"?M(x,ae=>{const F=ae.messages[ae.messages.length-1],te=F&&F.streaming?[...ae.messages.slice(0,-1),{...F,streaming:!1}]:ae.messages;return{...ae,isStreaming:!1,messages:te}}):ne.type==="error"&&M(x,ae=>({...ae,isStreaming:!1,messages:[...ae.messages,{role:"error",content:ne.message,ts:Gl()}]}))},p.onclose=()=>{if(M(x,{isConnected:!1}),m.current[x]){m.current[x]=!1;return}f.current[x]=setTimeout(()=>{P.current&&B(x)},3e3)},p.onerror=()=>{M(x,{isConnected:!1})}},[M]);A.useEffect(()=>{if(r)for(const x of ba)(!C.current[x.id]||C.current[x.id].readyState>WebSocket.OPEN)&&B(x.id);else for(const x of ba)clearTimeout(f.current[x.id]),C.current[x.id]&&(m.current[x.id]=!0,C.current[x.id].close(),C.current[x.id]=null);return()=>{for(const x of ba)clearTimeout(f.current[x.id]),C.current[x.id]&&(m.current[x.id]=!0,C.current[x.id].close(),C.current[x.id]=null)}},[r,B]),A.useEffect(()=>{var x;(x=j.current)==null||x.scrollIntoView({behavior:"smooth"})},[Te.messages]);const se=()=>{if(!d.trim()||!Te.isConnected||Te.isStreaming)return;const x=C.current[u];!x||x.readyState!==WebSocket.OPEN||(M(u,y=>({...y,messages:[...y.messages,{role:"user",content:d,ts:Gl()}],isStreaming:!0})),x.send(JSON.stringify({type:"message",message:d})),_(""),setTimeout(()=>{var y;return(y=W.current)==null?void 0:y.focus()},0))},w=x=>{x!==u&&N(x)},$=()=>{const x=Te.permissionMode==="auto"?"ask":"auto";M(u,{permissionMode:x});const y=C.current[u];y&&y.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"set_mode",mode:x}))},J=x=>{M(u,{selectedModel:x});const y=C.current[u];y&&y.readyState===WebSocket.OPEN&&y.send(JSON.stringify({type:"set_model",model:x}))};if(!r)return null;const Ce={};if(L)for(const x of L)Ce[x.id]=x.available;const{messages:Ie,isConnected:ve,isStreaming:z,permissionMode:D,selectedModel:oe}=Te,Oe=[];for(const x of Ie)if(x.role==="assistant"&&x.chunkType==="tool_use"){const y=Oe[Oe.length-1];y&&y._type==="tool_group"?(y.tools.push({name:x.content,detail:x.detail,toolInput:x.toolInput}),y.ts=x.ts):Oe.push({_type:"tool_group",tools:[{name:x.content,detail:x.detail,toolInput:x.toolInput}],ts:x.ts})}else Oe.push(x);return a.jsxs("div",{style:ge.sidebar,"data-havn-agent-sidebar":"",children:[a.jsx("style",{children:"@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }"}),a.jsxs("div",{style:ge.header,children:[a.jsx("span",{style:ge.headerTitle,children:"AGENT"}),a.jsxs("span",{style:ge.headerStatus,children:[a.jsx("span",{style:{...ge.statusDot,background:ve?"var(--havn-green)":"var(--havn-text-dim)"}}),ve?"Connected":"Connecting…"]}),a.jsxs("div",{style:{display:"flex",gap:"2px",alignItems:"center",marginLeft:"auto"},children:[Ie.length>0&&a.jsx("button",{onClick:()=>M(u,{messages:[]}),style:ge.clearBtn,children:"Clear"}),a.jsx("button",{onClick:l,style:ge.closeBtn,title:"Close agent sidebar",children:"×"})]})]}),a.jsx("div",{style:ge.picker,children:ba.map(x=>{const y=Ce[x.id]!==!1,p=u===x.id;return a.jsx("button",{"data-havn-tab":"","data-havn-active":p?"true":"false",style:{...ge.agentTab,...p?ge.agentTabActive:{},opacity:y?1:.35},onClick:()=>y&&w(x.id),title:y?x.name:`${x.name} (not installed)`,disabled:!y,children:x.name},x.id)})}),a.jsxs("div",{style:ge.log,children:[Ie.length===0&&(()=>{const x=L&&L.every(H=>!H.available),y=ba.find(H=>H.id===u),p=Ce[u]!==!1;return x?a.jsxs("div",{style:ge.emptyState,children:[a.jsx("div",{style:ge.emptyTitle,children:"No agents installed"}),a.jsx("div",{style:ge.emptyBody,children:"Install a coding agent CLI to get started:"}),ba.map(H=>a.jsxs("div",{style:ge.installHint,children:[a.jsx("span",{style:ge.installName,children:H.name}),a.jsx("code",{style:ge.installCmd,children:H.install})]},H.id)),a.jsx("div",{style:ge.emptyBody,children:"Then restart the havn server."})]}):!p&&y?a.jsxs("div",{style:ge.emptyState,children:[a.jsxs("div",{style:ge.emptyTitle,children:[y.name," not installed"]}),a.jsx("div",{style:ge.installHint,children:a.jsx("code",{style:ge.installCmd,children:y.install})}),a.jsx("div",{style:ge.emptyBody,children:"Then restart the havn server."})]}):a.jsx("div",{style:ge.placeholder,children:"Ask the agent to edit your project."})})(),Oe.map((x,y)=>x._type==="tool_group"?a.jsxs("div",{style:ge.toolGroup,children:[a.jsx("span",{style:{...ge.indicator,background:"var(--havn-purple)"}}),a.jsx("span",{style:ge.toolList,children:x.tools.map((p,H)=>a.jsx(tv,{tool:p},H))})]},y):x.role==="user"?a.jsxs("div",{style:ge.userEntry,children:[a.jsx("div",{style:ge.entryHeader,children:a.jsx("span",{style:ge.ts,children:x.ts})}),a.jsx("div",{style:ge.userText,children:x.content})]},y):x.role==="assistant"&&x.chunkType!=="tool_use"?a.jsx("div",{style:ge.assistantEntry,children:a.jsxs("div",{style:ge.assistantBody,children:[qm(x.content,{onOpenFile:T,onSelectTable:c}),x.streaming?a.jsx("span",{style:ge.cursor,children:"█"}):null]})},y):x.role==="system"?a.jsxs("div",{style:ge.entry,children:[a.jsx("span",{style:ge.ts,children:x.ts}),a.jsx("span",{style:{...ge.indicator,background:"var(--havn-text-dim)"}}),a.jsx("span",{style:ge.systemText,children:x.content})]},y):x.role==="error"?a.jsxs("div",{style:ge.entry,children:[a.jsx("span",{style:ge.ts,children:x.ts}),a.jsx("span",{style:{...ge.indicator,background:"var(--havn-red)"}}),a.jsx("span",{style:ge.errorText,children:x.content})]},y):null),z&&(()=>{const x=Oe[Oe.length-1];return!x||x.role!=="assistant"||x.chunkType==="tool_use"||x._type==="tool_group"?a.jsxs("div",{style:ge.loadingEntry,children:[a.jsx("span",{style:ge.loadingDots}),a.jsx("span",{style:ge.loadingText,children:"Working..."})]}):null})(),a.jsx("div",{ref:j})]}),a.jsxs("div",{style:ge.inputArea,children:[a.jsx("textarea",{ref:W,value:d,onChange:x=>_(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),se())},placeholder:ve?"Ask the agent…":"Connecting…",disabled:!ve||z,style:ge.textarea,rows:3}),a.jsxs("div",{style:ge.inputActions,children:[a.jsxs("button",{onClick:$,style:{...ge.modeBtn,...D==="auto"?ge.modeBtnAuto:ge.modeBtnAsk},title:D==="auto"?"Auto mode: agent can read and write files":"Ask mode: agent can only read files",children:[a.jsx("span",{style:ge.modeDot(D==="auto")}),D==="auto"?"Auto":"Ask"]}),(()=>{const x=ba.find(y=>y.id===u);return!(x!=null&&x.models)||x.models.length<=1?null:a.jsx("select",{value:oe,onChange:y=>J(y.target.value),style:ge.modelSelect,title:"Model",children:x.models.map(y=>a.jsx("option",{value:y.id,children:y.label},y.id))})})(),a.jsx("button",{onClick:se,disabled:!ve||z||!d.trim(),style:{...ge.sendBtn,opacity:!ve||z||!d.trim()?.35:1},children:z?"…":"Send"})]})]})]})}const ge={sidebar:{display:"flex",flexDirection:"column",height:"100%",background:"var(--havn-bg-tertiary)",overflow:"hidden"},header:{display:"flex",alignItems:"center",gap:"8px",padding:"4px 12px",fontSize:"12px",fontWeight:600,color:"var(--havn-text-secondary)",borderBottom:"1px solid var(--havn-border)",flexShrink:0},headerTitle:{fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},headerStatus:{display:"flex",alignItems:"center",gap:"4px",fontSize:"10px",color:"var(--havn-text-dim)",fontWeight:400},statusDot:{width:"5px",height:"5px",borderRadius:"50%",flexShrink:0},clearBtn:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px",padding:"2px 4px"},closeBtn:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"16px",lineHeight:1,padding:"0 2px"},picker:{display:"flex",alignItems:"center",borderBottom:"1px solid var(--havn-border)",padding:"0 8px",flexShrink:0},agentTab:{padding:"6px 12px",background:"none",border:"none",borderBottom:"2px solid transparent",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",whiteSpace:"nowrap",fontWeight:500,fontFamily:"var(--havn-font)"},agentTabActive:{borderBottom:"2px solid var(--havn-accent)",color:"var(--havn-text)",fontWeight:600},log:{flex:1,overflow:"auto",padding:"8px 12px",fontSize:"12px",fontFamily:"var(--havn-font-mono)",lineHeight:1.5,minHeight:0},placeholder:{color:"var(--havn-text-dim)",fontStyle:"italic",padding:"8px 0",fontSize:"12px"},emptyState:{padding:"16px 0",display:"flex",flexDirection:"column",gap:"8px"},emptyTitle:{fontSize:"13px",fontWeight:600,color:"var(--havn-text)"},emptyBody:{fontSize:"11px",color:"var(--havn-text-secondary)",lineHeight:1.5},installHint:{display:"flex",flexDirection:"column",gap:"2px",padding:"4px 0"},installName:{fontSize:"11px",fontWeight:600,color:"var(--havn-text-secondary)"},installCmd:{fontSize:"11px",fontFamily:"var(--havn-font-mono)",color:"var(--havn-accent)",background:"var(--havn-bg)",padding:"3px 6px",borderRadius:"3px",border:"1px solid var(--havn-border)",userSelect:"all"},entry:{display:"flex",gap:"8px",alignItems:"baseline",marginBottom:"2px",fontFamily:"var(--havn-font-mono)"},ts:{color:"var(--havn-text-dim)",flexShrink:0,fontSize:"10px",fontFamily:"var(--havn-font-mono)"},indicator:{width:"4px",height:"4px",borderRadius:"50%",flexShrink:0,marginTop:"2px"},userEntry:{margin:"8px 0 4px",borderLeft:"2px solid var(--havn-accent)",paddingLeft:"10px"},entryHeader:{display:"flex",gap:"6px",alignItems:"center",marginBottom:"2px"},userText:{color:"var(--havn-accent)",fontWeight:500,wordBreak:"break-word",fontSize:"12px",fontFamily:"var(--havn-font-mono)"},assistantEntry:{margin:"8px 0 4px",padding:"6px 10px",background:"var(--havn-bg-secondary)",borderLeft:"2px solid var(--havn-purple)"},assistantBody:{color:"var(--havn-text)",wordBreak:"break-word",fontSize:"12px",fontFamily:"var(--havn-font-mono)",lineHeight:1.5},cursor:{color:"var(--havn-accent)"},toolGroup:{display:"flex",gap:"6px",alignItems:"flex-start",margin:"3px 0",paddingLeft:"12px"},toolList:{display:"flex",gap:"4px",flexWrap:"wrap"},toolChip:{display:"inline-flex",alignItems:"center",gap:"3px",padding:"1px 6px",background:"color-mix(in srgb, var(--havn-purple) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--havn-purple) 25%, transparent)",borderRadius:"3px",color:"var(--havn-purple)",fontSize:"10px",fontFamily:"var(--havn-font-mono)",whiteSpace:"nowrap",flexWrap:"wrap"},toolExpandIcon:{fontSize:"8px",opacity:.6},toolDetailInline:{color:"var(--havn-text-secondary)",fontSize:"10px",marginLeft:"2px"},toolInputBlock:{padding:"4px 6px",background:"var(--havn-bg)",border:"1px solid var(--havn-border)",borderRadius:"3px",fontSize:"10px",fontFamily:"var(--havn-font-mono)",maxHeight:"200px",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all"},diffBlock:{display:"flex",flexDirection:"column",gap:"2px"},diffRemoved:{padding:"2px 4px",background:"color-mix(in srgb, var(--havn-red) 12%, transparent)",borderLeft:"2px solid var(--havn-red)",color:"var(--havn-text)",whiteSpace:"pre-wrap",fontSize:"10px",fontFamily:"var(--havn-font-mono)"},diffAdded:{padding:"2px 4px",background:"color-mix(in srgb, var(--havn-green) 12%, transparent)",borderLeft:"2px solid var(--havn-green)",color:"var(--havn-text)",whiteSpace:"pre-wrap",fontSize:"10px",fontFamily:"var(--havn-font-mono)"},toolFilePath:{color:"var(--havn-text-dim)",fontSize:"9px",marginTop:"2px"},inlineCode:{padding:"1px 3px",background:"var(--havn-bg)",borderRadius:"2px",fontFamily:"inherit",fontSize:"inherit",color:"var(--havn-accent)"},fileLink:{color:"var(--havn-accent)",cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted",textUnderlineOffset:"2px"},tableLink:{color:"var(--havn-purple)",cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted",textUnderlineOffset:"2px"},fileLinkCode:{cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted",textUnderlineOffset:"2px"},tableLinkCode:{color:"var(--havn-purple)",cursor:"pointer",textDecoration:"underline",textDecorationStyle:"dotted",textUnderlineOffset:"2px"},codeBlock:{display:"block",padding:"6px 8px",margin:"4px 0",background:"var(--havn-bg)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius)",fontFamily:"inherit",fontSize:"inherit",whiteSpace:"pre-wrap",overflowX:"auto"},listItem:{display:"block",paddingLeft:"8px"},heading:r=>({display:"block",fontWeight:700,fontSize:r<=2?"14px":r===3?"13px":"12px",color:"var(--havn-text)",margin:r<=2?"8px 0 4px":"6px 0 2px",letterSpacing:r<=2?"0.3px":"0"}),table:{borderCollapse:"collapse",margin:"6px 0",fontSize:"11px",fontFamily:"var(--havn-font-mono)",width:"100%"},th:{padding:"3px 8px",borderBottom:"1px solid var(--havn-border)",textAlign:"left",fontWeight:600,color:"var(--havn-text)",background:"var(--havn-bg)",fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.3px"},td:{padding:"2px 8px",borderBottom:"1px solid color-mix(in srgb, var(--havn-border) 50%, transparent)",color:"var(--havn-text-secondary)",fontSize:"11px"},systemText:{color:"var(--havn-text-dim)",fontStyle:"italic",fontSize:"11px"},errorText:{color:"var(--havn-red)",wordBreak:"break-word"},inputArea:{borderTop:"1px solid var(--havn-border)",flexShrink:0},textarea:{width:"100%",resize:"none",background:"var(--havn-bg)",border:"none",borderBottom:"1px solid var(--havn-border)",color:"var(--havn-text)",padding:"8px 12px",fontSize:"12px",fontFamily:"var(--havn-font-mono)",lineHeight:1.5,outline:"none",boxSizing:"border-box",display:"block"},inputActions:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"4px 8px",gap:"8px"},modeBtn:{display:"inline-flex",alignItems:"center",gap:"5px",padding:"3px 10px",borderRadius:"var(--havn-radius-lg)",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--havn-font-mono)",letterSpacing:"0.3px",flexShrink:0},modeBtnAuto:{background:"color-mix(in srgb, var(--havn-green) 15%, transparent)",border:"1px solid var(--havn-green)",color:"var(--havn-green)"},modeBtnAsk:{background:"color-mix(in srgb, var(--havn-accent) 15%, transparent)",border:"1px solid var(--havn-accent)",color:"var(--havn-accent)"},modeDot:r=>({width:"5px",height:"5px",borderRadius:"50%",background:r?"var(--havn-green)":"var(--havn-accent)",flexShrink:0}),modelSelect:{padding:"3px 4px",background:"var(--havn-bg)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",fontSize:"10px",fontFamily:"var(--havn-font-mono)",cursor:"pointer",outline:"none",flexShrink:1,minWidth:0},sendBtn:{padding:"4px 14px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,letterSpacing:"0.3px",flexShrink:0},loadingEntry:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",margin:"4px 0",borderLeft:"2px solid var(--havn-purple)"},loadingDots:{display:"inline-block",width:"6px",height:"6px",borderRadius:"50%",background:"var(--havn-purple)",animation:"pulse 1.2s ease-in-out infinite"},loadingText:{color:"var(--havn-text-dim)",fontSize:"11px",fontFamily:"var(--havn-font-mono)",fontStyle:"italic"}},Jd=A.createContext(null);function av({children:r}){const[l,E]=A.useState(!1),[T,c]=A.useState(!1),[u,N]=A.useState(!1),[L,I]=A.useState(null),R=A.useCallback(async()=>{try{const C=await Ee.getAuthStatus();if(!C.auth_enabled){E(!0),I({username:"local",role:"admin",display_name:"Local User"});return}if(C.needs_setup){N(!0),c(!0),E(!0);return}if(Ee.getToken())try{const f=await Ee.getMe();I(f),E(!0);return}catch{Ee.setToken(null)}c(!0),E(!0)}catch{E(!0),I({username:"local",role:"admin",display_name:"Local User"})}},[]);A.useEffect(()=>{R();const C=()=>c(!0);return window.addEventListener("dp_auth_required",C),()=>window.removeEventListener("dp_auth_required",C)},[R]);const O=A.useCallback(C=>{c(!1),N(!1),I({username:C.username,role:C.role||"admin"})},[]),d=A.useCallback(()=>{Ee.setToken(null),I(null),c(!0)},[]),_=l&&!T;return a.jsx(Jd.Provider,{value:{authChecked:l,authRequired:T,needsSetup:u,currentUser:L,handleLogin:O,handleLogout:d,isAuthenticated:_},children:r})}function qd(){const r=A.useContext(Jd);if(!r)throw new Error("useAuth must be used within AuthProvider");return r}const Qd=A.createContext(null);function rv({children:r,enabled:l}){const[E,T]=A.useState([]),[c,u]=A.useState([]),[N,L]=A.useState({}),I=A.useRef(!1),R=A.useCallback(async()=>{try{const C=await Ee.listTables();T(C)}catch(C){console.warn("Failed to load tables:",C.message)}},[]),O=A.useCallback(async()=>{try{const C=await Ee.listFiles();u(C.map(f=>{var m;return typeof f=="string"?{path:f.replace(/\\/g,"/"),type:"file"}:{...f,path:(m=f.path)==null?void 0:m.replace(/\\/g,"/")}}))}catch(C){console.warn("Failed to load files:",C.message)}},[]),d=A.useCallback(async()=>{try{const C=await Ee.listStreams();L(C)}catch(C){console.warn("Failed to load streams:",C.message)}},[]),_=A.useCallback(()=>{O(),R(),d()},[O,R,d]);return A.useEffect(()=>{l&&!I.current&&(I.current=!0,_())},[l,_]),A.useEffect(()=>{l||(I.current=!1)},[l]),a.jsx(Qd.Provider,{value:{tables:E,files:c,streams:N,loadTables:R,loadFiles:O,loadStreams:d,refreshAll:_},children:r})}function Zd(){const r=A.useContext(Qd);if(!r)throw new Error("useWarehouse must be used within WarehouseProvider");return r}const eO=A.createContext(null);function sv({children:r,onTablesChanged:l,onPipelineComplete:E}){const[T,c]=A.useState(!1),[u,N]=A.useState([]),[L,I]=A.useState(null),[R,O]=A.useState(0),d=A.useRef(null),_=A.useRef(0),C=A.useRef("");A.useEffect(()=>(T&&C.current&&(_.current=Date.now(),d.current=setInterval(()=>{const B=Math.floor((Date.now()-_.current)/1e3);N(se=>se.length===0?se:[{...se[0],message:`${C.current} ${B}s`},...se.slice(1)])},1e3)),()=>{d.current&&(clearInterval(d.current),d.current=null)}),[T]);const f=A.useCallback((B,se)=>{const w=new Date().toLocaleTimeString();N($=>[...$,{type:B,message:se,ts:w}])},[]),m=A.useCallback(()=>N([]),[]),j=A.useCallback(async(B=!1)=>{c(!0),I(null);const se=`Running transform (force=${B})...`;C.current=se,f("info",se);try{const w=await Ee.runTransform(null,B),$=[];for(const[Ce,Ie]of Object.entries(w.results||{}))f(Ie==="error"?"error":"info",`${Ce}: ${Ie}`),$.push({name:Ce,result:Ie});l();const J={type:"transform",status:$.some(Ce=>Ce.result==="error")?"failed":"success",models:$,totalRows:0,duration:0,errors:$.filter(Ce=>Ce.result==="error").length};I(J),J.status==="success"&&(E==null||E())}catch(w){f("error",w.message)}finally{C.current="",c(!1)}},[f,l,E]),W=A.useCallback(async(B,se=!1)=>{c(!0),I(null),O(0);const w=`Running pipeline${se?" (full refresh)":""}...`;C.current=w,f("info",w);const $=[];let J=0,Ce=!1,Ie=0,ve=0;const z={};return new Promise(D=>{const{abort:oe}=Ee.runStreamSSE(B,se,(Oe,x)=>{switch(Oe){case"start":Ie=x.total||0;break;case"step_start":break;case"model_start":{const y=x.action,p=x.name,H=x.num||0,ne=y==="ingest"?"Ingesting":y==="export"?"Exporting":"Building",ae=Ie&&H?`(${H}/${Ie}) `:"";z[p]=Date.now(),f("log",`${ae}${ne} ${p}...`);break}case"model_end":{ve++,Ie>0&&O(ve/Ie);const y=x.status,p=x.name,H=x.action,ne=x.duration_ms,ae=x.row_count,F=x.rows_affected,te=x.error,Y=x.num||0,le=Ie&&Y?`(${Y}/${Ie}) `:"";let he="";const ye=(z[p]?Date.now()-z[p]:ne)||ne||0,_e=ye?`(${(ye/1e3).toFixed(1)}s)`:"",me=H==="ingest"?"Ingested":H==="export"?"Exported":"Built",Ne=ae||F||0,K=[Ne?`${Ne.toLocaleString()} rows`:"",_e].filter(Boolean).join(" ");if(y==="skipped")he=`${le}Skipped ${p} (no changes)`;else if(y==="error"||y==="assertion_failed"){const Ge=(te==null?void 0:te.replace(/[\x00]/g,".").replace(/\.+/g,"."))||"";he=`${le}Failed ${p}${Ge?` — ${Ge}`:""}`}else he=`${le}${me} ${p}${K?` — ${K}`:""}`;Ne&&(J+=Ne),f(y==="error"||y==="assertion_failed"?"error":y==="skipped"?"log":"success",he),y!=="skipped"&&$.push({name:p,result:y}),(y==="error"||y==="assertion_failed")&&(Ce=!0);break}case"complete":{const y=x.duration_seconds||0,p=x.status,H=p==="cancelled";f(H?"warn":"info",`Pipeline ${p} in ${y}s`),O(1),C.current="",l();const ae={type:"stream",status:H||Ce?"failed":"success",models:$,totalRows:J,duration:Math.round(y*1e3),errors:$.filter(F=>F.result==="error").length};I(ae),!Ce&&!H&&(E==null||E()),c(!1),D();break}case"error":{const y=x.message;C.current="",y&&(y.includes("network error")||y.includes("Failed to fetch")||y.includes("AbortError"))?f("warn","Connection to server lost. The server may have been restarted."):f("error",y||"An unknown error occurred"),c(!1),D();break}}})})},[f,l,E]),P=A.useCallback(async()=>{try{await Ee.cancelStream(),f("warn","Cancellation requested...")}catch(B){f("error",B.message)}},[f]),Z=A.useCallback(async(B=!1)=>{c(!0),f("info",B?"Fixing SQL...":"Linting SQL...");try{const se=await Ee.runLint(B);for(const w of se.violations||[]){const $=B&&!w.fixable?" (unfixable)":"";f("warn",`${w.file}:${w.line}:${w.col} [${w.code}] ${w.description}${$}`)}if(B){const w=se.fixed??0,$=se.count,J=[];w>0&&J.push(`${w} fixed`),$>0&&J.push(`${$} violation(s) remain (unfixable by SQLFluff)`),f("info",J.length>0?J.join(", ")+".":"All fixable violations resolved.")}else f("info",se.count===0?"No lint violations found.":`${se.count} violation(s) found.`)}catch(se){f("error",se.message)}finally{c(!1)}},[f]),v=A.useCallback(async B=>{c(!0),f("info",`Running ${B}...`);try{const se=await Ee.runScript(B);f(se.status==="error"?"error":"info",`${B}: ${se.status} (${se.duration_ms}ms)`),se.log_output&&se.log_output.split(`
`).filter(w=>w.trim()).forEach(w=>f("log",w)),se.error&&f("error",se.error)}catch(se){f("error",se.message)}finally{c(!1)}},[f]),M=A.useCallback(async B=>{c(!0),I(null),f("info",`Running transform for ${B}...`);try{const se=await Ee.runTransform([B],!1),w=[];for(const[$,J]of Object.entries(se.results||{}))f(J==="error"?"error":"info",`${$}: ${J}`),w.push({name:$,result:J});l(),I({type:"transform",status:w.some($=>$.result==="error")?"failed":"success",models:w,totalRows:0,duration:0,errors:w.filter($=>$.result==="error").length})}catch(se){f("error",se.message)}finally{c(!1)}},[f,l]),Te=A.useCallback(async()=>{c(!0),f("info","Running contracts...");try{const B=await Ee.runContracts();if(B.total===0){f("warn","No contracts found. Create YAML files in contracts/ to get started.");return}for(const se of B.results){const w=se.passed?"pass":"FAIL",$=se.passed?"info":"error";f($,`${w}  ${se.contract_name} (${se.model}) [${se.duration_ms}ms]`);for(const J of se.assertions||[])J.passed?f("info",`  pass  ${J.expression}`):f("error",`  FAIL  ${J.expression} (${J.detail})`);se.error&&f("error",`  Error: ${se.error}`)}f("info",""),B.failed===0?f("info",`All ${B.passed} contract(s) passed.`):f("error",`${B.failed} contract(s) failed, ${B.passed} passed.`)}catch(B){f("error",B.message)}finally{c(!1)}},[f]);return a.jsx(eO.Provider,{value:{running:T,output:u,runSummary:L,progress:R,addOutput:f,clearOutput:m,setRunSummary:I,runTransformAll:j,runStream:W,cancelPipeline:P,runLint:Z,runCurrentScript:v,runSingleModel:M,runContracts:Te},children:r})}function lv(){const r=A.useContext(eO);if(!r)throw new Error("usePipeline must be used within PipelineProvider");return r}const iv=[{id:"welcome",title:"Welcome to havn",description:"havn is your self-hosted data platform. Data in safe waters. Let's take a quick tour of the interface.",position:"center"},{id:"sidebar",title:"File Tree",description:"Browse your project files here. SQL transforms, Python ingest/export scripts, and notebooks are organized by folder.",position:"right"},{id:"editor",title:"Code Editor",description:"Edit SQL transforms and Python scripts with syntax highlighting, auto-complete, and one-click execution.",position:"left"},{id:"tabs",title:"Navigation",description:"Sections group your workflow: Develop for code, Explore for data, Observe for monitoring, Configure for settings. Sub-tabs appear within each section.",position:"bottom"},{id:"actions",title:"Run Menu",description:"The Run button executes your pipeline. Click the arrow for more options: Transform, Lint, Contracts, and Full Refresh.",position:"bottom"},{id:"output",title:"Output Panel",description:"Execution logs, errors, and results appear here. After a pipeline runs, you'll see a summary with links to explore your data.",position:"top"},{id:"ready",title:"You're Ready!",description:"Start by connecting a data source from the Overview, or run a stream to kick off your pipeline. You can replay this guide from Settings.",position:"center"}],Bs=[{id:"Overview",label:"Overview",tabs:[]},{id:"Develop",label:"Develop",tabs:["Editor","Notebooks","DAG"]},{id:"Explore",label:"Explore",tabs:["Query","Tables","Data Sources"]},{id:"Observe",label:"Observe",tabs:["Quality","Sentinel","Diff","History"]},{id:"Configure",label:"Configure",tabs:["Masking","Wiki","Docs","Settings"]}],Cc={};for(const r of Bs){r.tabs.length===0&&(Cc[r.id]=r.id);for(const l of r.tabs)Cc[l]=r.id}const pc={};for(const r of Bs)pc[r.id]=r.tabs.length>0?r.tabs[0]:r.id;function ov({running:r,streams:l,onRunStream:E,onTransform:T,onLint:c,onContracts:u,onCancel:N,addOutput:L}){const[I,R]=A.useState(!1),O=A.useRef(null);A.useEffect(()=>{if(!I)return;const C=f=>{O.current&&!O.current.contains(f.target)&&R(!1)};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[I]);const d=Object.keys(l),_=()=>{d.length>0?E(d[0]):L("warn","No streams defined in project.yml")};return a.jsxs("div",{ref:O,style:Tn.wrapper,children:[r?a.jsxs("button",{onClick:N,style:{...Tn.btn,background:"var(--havn-error, #c0392b)",color:"#fff",borderColor:"var(--havn-error, #c0392b)",borderRadius:"var(--havn-radius-lg)"},children:["■"," Cancel"]}):a.jsxs(a.Fragment,{children:[a.jsxs("button",{onClick:_,disabled:r,style:Tn.btn,children:["▶"," Run"]}),a.jsx("button",{onClick:()=>R(!I),disabled:r,style:Tn.chevron,children:"▾"})]}),I&&a.jsxs("div",{style:Tn.menu,children:[a.jsx("div",{style:Tn.groupLabel,children:"Pipeline"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{_(),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Run Stream"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{d.length>0?E(d[0],!0):L("warn","No streams defined"),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Full Refresh"}),a.jsx("div",{style:Tn.divider}),a.jsx("div",{style:Tn.groupLabel,children:"Build"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{T(!1),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Transform"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{T(!0),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Transform (Force)"}),a.jsx("div",{style:Tn.divider}),a.jsx("div",{style:Tn.groupLabel,children:"Validate"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{c(!1),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Lint"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{c(!0),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Lint (Fix)"}),a.jsx("button",{style:Tn.item,disabled:r,onClick:()=>{u(),R(!1)},onMouseEnter:C=>C.currentTarget.style.background="var(--havn-btn-bg)",onMouseLeave:C=>C.currentTarget.style.background="none",children:"Contracts"})]})]})}const Tn={wrapper:{position:"relative",display:"inline-flex"},btn:{padding:"5px 14px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg) 0 0 var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,letterSpacing:"0.3px"},chevron:{padding:"5px 7px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"0 var(--havn-radius-lg) var(--havn-radius-lg) 0",color:"#fff",cursor:"pointer",fontSize:"10px",borderLeft:"1px solid rgba(255,255,255,0.2)",marginLeft:"-1px"},menu:{position:"absolute",top:"100%",right:0,marginTop:"4px",background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"var(--havn-radius)",zIndex:100,minWidth:"170px",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",padding:"4px 0"},groupLabel:{padding:"6px 12px 2px",fontSize:"10px",fontWeight:600,color:"var(--havn-text-dim)",textTransform:"uppercase",letterSpacing:"0.5px"},item:{display:"block",width:"100%",padding:"6px 12px",background:"none",border:"none",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",textAlign:"left",whiteSpace:"nowrap"},divider:{height:"1px",background:"var(--havn-border)",margin:"4px 0"}};function Ev(r){const l={};for(const E of r)l[E.schema]||(l[E.schema]=[]),l[E.schema].push(E);return l}function Tv({tables:r,selectedTable:l,onSelectTable:E}){const T=Ev(r),c=["seeds","landing","bronze","silver","gold"],u=Object.keys(T).sort((I,R)=>{const O=c.indexOf(I),d=c.indexOf(R);return O!==-1&&d!==-1?O-d:O!==-1?-1:d!==-1?1:I.localeCompare(R)}),[N,L]=A.useState(()=>{const I={};for(const R of u)I[R]=!0;return I});return A.useEffect(()=>{L(I=>{const R={...I};for(const O of u)O in R||(R[O]=!0);return R})},[r]),r.length===0?a.jsx("div",{style:Ga.empty,children:"No tables yet"}):a.jsx("div",{children:u.map(I=>a.jsxs("div",{children:[a.jsxs("div",{style:Ga.schemaRow,onClick:()=>L(R=>({...R,[I]:!R[I]})),children:[a.jsx("span",{style:{...Ga.arrow,transform:N[I]?"rotate(0deg)":"rotate(-90deg)"},children:"▾"}),a.jsx("span",{style:Ga.schemaName,children:I}),a.jsx("span",{style:Ga.schemaCount,children:T[I].length})]}),N[I]&&T[I].map(R=>{const O=`${R.schema}.${R.name}`,d=l===O;return a.jsxs("div",{"data-havn-file":"",style:{...Ga.tableRow,background:d?"var(--havn-bg-secondary)":"transparent",borderLeft:d?"2px solid var(--havn-accent)":"2px solid transparent"},onClick:()=>E(R.schema,R.name),children:[a.jsx("span",{style:{...Ga.typeIcon,color:R.type==="VIEW"?"var(--havn-purple)":"var(--havn-accent)"},children:R.type==="VIEW"?"V":"T"}),a.jsx("span",{style:d?Ga.tableNameActive:Ga.tableName,children:R.name})]},O)})]},I))})}const Ga={empty:{padding:"12px",color:"var(--havn-text-dim)",fontSize:"12px",textAlign:"center"},schemaRow:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",cursor:"pointer",margin:"0 4px",borderRadius:"3px"},arrow:{fontSize:"10px",color:"var(--havn-text-secondary)",width:"10px",display:"inline-block",transition:"transform 0.12s ease"},schemaName:{fontSize:"13px",fontWeight:500,color:"var(--havn-text)",fontFamily:"var(--havn-font-mono)"},schemaCount:{fontSize:"10px",color:"var(--havn-text-dim)",marginLeft:"auto"},tableRow:{display:"flex",alignItems:"center",gap:"6px",padding:"3px 8px 3px 30px",cursor:"pointer",fontSize:"12px",fontFamily:"var(--havn-font-mono)",margin:"0 4px",borderRadius:"3px"},typeIcon:{fontSize:"9px",fontWeight:700,flexShrink:0},tableName:{color:"var(--havn-text)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},tableNameActive:{color:"var(--havn-accent)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}};function cv(){const{currentUser:r,handleLogout:l}=qd(),{tables:E,files:T,streams:c,loadFiles:u,refreshAll:N}=Zd(),{running:L,output:I,runSummary:R,progress:O,addOutput:d,clearOutput:_,setRunSummary:C,runTransformAll:f,runStream:m,cancelPipeline:j,runLint:W,runCurrentScript:P,runSingleModel:Z,runContracts:v}=lv(),[M,Te]=A.useState(null),B=A.useRef(null),[se,w]=A.useState(""),[$,J]=A.useState("sql"),[Ce,Ie]=A.useState(!1),ve=A.useRef(!1),[z,D]=A.useState(null),[oe,Oe]=A.useState(null),[x,y]=A.useState(!1),[p,H,ne]=Gs("dp_editor_preview_height",200,80,600),[ae,F]=A.useState("Overview"),[te,Y]=A.useState(null),le=Cc[ae]||"Overview",he=Bs.find(ce=>ce.id===le),xe=(he==null?void 0:he.tabs)||[],[ye,_e,me]=Gs("dp_sidebar_width",240,150,500),[Ne,b,K]=Gs("dp_output_height",180,80,500),[Le,Ge,De]=Gs("dp_agent_width",340,240,600),ze=A.useRef(null),[Xe,et]=A.useState(null),[Xt,st]=A.useState(()=>!localStorage.getItem("dp_guide_completed")),Gt=Ar(),Bt=A.useRef(0);A.useEffect(()=>{Gt("warehouseHasTables",E.length>0)},[E,Gt]);const[Ht,Pt]=A.useState(null),[mn,vn]=A.useState(null),[dr,Ha]=A.useState(!1),[Jn,qt]=A.useState(!1),[an,Kt]=A.useState(null),sa=A.useRef(null),[Kr,zr]=A.useState(null),qn=A.useRef(null),[Qt,X]=A.useState(null),Pe=A.useRef(null);function Ke(ce,Fe,We="Confirm",ft=!1){return new Promise(Tt=>{Pe.current=Tt,X({title:ce,body:Fe,confirmLabel:We,danger:ft})})}function zt(ce){X(null),Pe.current&&(Pe.current(ce),Pe.current=null)}function Fa(){st(!1),localStorage.setItem("dp_guide_completed","true")}function kr(){st(!0)}function rn(ce){F(ce),Bt.current+=1,Gt("tabSwitchCount",Bt.current)}A.useEffect(()=>{function ce(Fe){if(!Fe.altKey||Fe.ctrlKey||Fe.metaKey||Fe.shiftKey)return;const We=parseInt(Fe.key);if(We>=1&&We<=Bs.length){Fe.preventDefault();const ft=Bs[We-1];rn(pc[ft.id])}}return document.addEventListener("keydown",ce),()=>document.removeEventListener("keydown",ce)},[]);async function Hn(ce,Fe={}){if(ce=ce.replace(/\\/g,"/"),ce.endsWith(".dpnb")){Pt(ce),F("Notebooks");return}if(ce.endsWith(".sql")&&ce.startsWith("transform/")&&Fe.notebookView){const We=ce.replace("transform/","").replace(".sql","").split("/");if(We.length>=2){vn(`${We[0]}.${We[1]}`);return}}if(!(Ce&&M&&!await Ke("Unsaved changes","Discard unsaved changes and open another file?","Discard",!0)))try{const We=await Ee.readFile(ce);Te(ce),w(We.content),J(We.language),Ie(!1),D(null),Oe(null),F("Editor")}catch(We){d("error",`Failed to open: ${We.message}`)}}function Do(ce){const Fe=ce.replace(/\\/g,"/");if(!/\.(sql|py|yml|yaml|json|csv|md|txt|dpnb)$/i.test(Fe)&&!Fe.includes("/")&&/^\w+\.\w+$/.test(Fe)){const[ft,Tt]=Fe.split(".");return`transform/${ft}/${Tt}.sql`}if(!Fe.includes("/")){const ft=[],Tt=ua=>{for(const Aa of ua)Aa.type==="file"&&ft.push(Aa.path),Aa.children&&Tt(Aa.children)};Tt(T);const yt=ft.find(ua=>ua.endsWith("/"+Fe)||ua===Fe);if(yt)return yt}return Fe}async function Kl(ce,Fe,We){const ft=Do(ce);if(M===ft)et({line:Fe,col:We||1}),F("Editor");else try{const Tt=await Ee.readFile(ft);Te(ft),w(Tt.content),J(Tt.language),Ie(!1),F("Editor"),setTimeout(()=>et({line:Fe,col:We||1}),50)}catch(Tt){d("error",`Failed to open: ${Tt.message}`)}}B.current=M,ve.current=Ce;async function zl(){const ce=B.current;if(ce&&!(ve.current&&await new Promise(We=>{qn.current=We,zr({path:ce})})!=="load"))try{const Fe=await Ee.readFile(ce);w(Fe.content),Ie(!1)}catch{}}function $r(ce){zr(null),qn.current&&(qn.current(ce),qn.current=null)}async function Or(){if(M)try{await Ee.saveFile(M,se),Ie(!1),d("info",`Saved ${M}`),Gt("firstFileEdited",!0)}catch(ce){d("error",`Failed to save: ${ce.message}`)}}async function js(ce){if(ce=ce.replace(/\\/g,"/"),!ce.trim())return;const Fe=ce.endsWith(".py")?"# A DuckDB connection is available as `db`\n\n":ce.endsWith(".sql")?`-- config: materialized=table

SELECT 1
`:"";try{await Ee.saveFile(ce,Fe),d("info",`Created ${ce}`),await u(),Hn(ce)}catch(We){d("error",`Failed to create: ${We.message}`)}}async function kl(ce){ce=ce.replace(/\\/g,"/");const Fe=ce.endsWith(".sql")&&ce.startsWith("transform/"),We=ce.endsWith(".csv")&&ce.startsWith("seeds/");let ft=!1;if(Fe||We){const Tt=ce.split("/"),ua=Tt[Tt.length-1].replace(/\.(sql|csv)$/,""),Aa=We?"seeds":Tt.length>=3?Tt[1]:"bronze",la=await new Promise(ja=>{sa.current=ja,Kt({path:ce,schema:Aa,name:ua,hasObject:!0})});if(la==="cancel")return;ft=la==="drop"}else if(await new Promise(yt=>{sa.current=yt,Kt({path:ce,hasObject:!1})})==="cancel")return;try{const Tt=await Ee.deleteFile(ce,ft);d("info",`Deleted ${ce}`),Tt.dropped&&d("info",`Dropped ${Tt.dropped} from warehouse`),M===ce&&(Te(null),w(""),Ie(!1)),await u()}catch(Tt){d("error",`Failed to delete: ${Tt.message}`)}}async function $l(ce,Fe){try{await Ee.moveFile(ce,Fe),d("info",`Moved ${ce} → ${Fe}`),M===ce&&Te(Fe),await u()}catch(We){d("error",`Failed to move: ${We.message}`)}}function un(ce){Kt(null),sa.current&&(sa.current(ce),sa.current=null)}async function kt(){M&&(Ce&&await Or(),M.endsWith(".sql")?await f(!1):M.endsWith(".py")?await P(M):M.endsWith(".yml")&&M.startsWith("contracts/")&&await v())}async function cn(){if(!M||!M.includes("transform/")||!M.endsWith(".sql"))return;Ce&&await Or();const ce=M.replace(/^transform\//,"").replace(/\.sql$/,"").replace(/\//g,".");await Z(ce)}async function Ya(){if(!(!M||!M.endsWith(".sql"))){d("info",`Formatting ${M}...`);try{const ce=await Ee.lintFile(M,!0,se);for(const We of ce.violations||[])d("warn",`${M}:${We.line}:${We.col} [${We.code}] ${We.description} (unfixable)`);const Fe=ce.fixed??0;Fe>0?d("info",`${Fe} issue(s) fixed.`):ce.count===0&&d("info","No violations found."),ce.content!=null&&w(ce.content)}catch(ce){d("error",ce.message)}}}async function Vs(){if(!M||!M.endsWith(".sql"))return;const ce=se.split(`
`);let Fe=0;for(const ft of ce){const Tt=ft.trim();if(Tt.startsWith("-- config:")||Tt.startsWith("-- depends_on:")||Tt==="")Fe++;else break}const We=ce.slice(Fe).join(`
`).trim();if(We){y(!0),Oe(null);try{const ft=await Ee.runQuery(We);D(ft)}catch(ft){Oe(ft.message),D(null)}finally{y(!1)}}}function ws(ce,Fe){Y(`${ce}.${Fe}`),F("Tables")}function yo(ce,Fe){rn("Query"),window.__dp_prefill_query={sql:`SELECT * FROM ${ce}.${Fe} LIMIT 1000`,run:!0}}async function Jl(ce=!1){if(await W(ce),ce&&M){const Fe=await Ee.readFile(M);w(Fe.content)}}const Nr=M&&M.includes("transform/")&&M.endsWith(".sql");return a.jsxs("div",{style:rt.container,children:[a.jsxs("header",{style:rt.header,children:[a.jsxs("button",{onClick:()=>rn("Overview"),style:rt.logo,title:"Home",children:[a.jsx("img",{src:"/logo.svg",alt:"havn",width:"22",height:"22",style:{marginRight:"6px",verticalAlign:"middle"}}),"havn"]}),a.jsx("nav",{style:rt.sectionNav,"data-havn-guide":"tabs",children:Bs.map((ce,Fe)=>{const We=le===ce.id;return a.jsx("button",{"data-havn-tab":"","data-havn-active":We?"true":"false",onClick:()=>rn(pc[ce.id]),style:We?rt.sectionActive:rt.section,title:`${ce.label} (Alt+${Fe+1})`,children:ce.label},ce.id)})}),a.jsxs("div",{style:rt.headerRight,"data-havn-guide":"actions",children:[a.jsx(ov,{running:L,streams:c,onRunStream:m,onTransform:f,onLint:Jl,onContracts:v,onCancel:j,addOutput:d}),a.jsx("button",{onClick:()=>Ha(!0),style:rt.btn,children:"+ New"}),a.jsx("button",{onClick:()=>qt(ce=>!ce),style:Jn?rt.btnPrimary:rt.btn,title:"Toggle agent sidebar",children:"Agent"}),a.jsx(km,{showConfirm:Ke}),r&&a.jsxs("div",{style:rt.userInfo,children:[a.jsx("span",{style:rt.userName,children:r.display_name||r.username}),a.jsx("span",{style:rt.userRole,children:r.role}),r.username!=="local"&&a.jsx("button",{onClick:l,style:rt.logoutBtn,children:"Logout"})]})]})]}),a.jsxs("div",{style:rt.main,children:[a.jsxs("aside",{style:{...rt.sidebar,width:ye},"data-havn-guide":"sidebar",children:[a.jsxs("div",{style:rt.sidebarPane,children:[a.jsxs("div",{style:rt.sidebarSectionHeader,children:[a.jsx("span",{children:"FILES"}),a.jsx("button",{onClick:N,style:rt.sidebarRefreshBtn,title:"Refresh files & tables",children:"↻"})]}),a.jsx("div",{style:rt.sidebarPaneContent,children:a.jsx(hI,{files:T,onSelect:Hn,activeFile:M,onNewFile:js,onDeleteFile:kl,onMoveFile:$l})})]}),a.jsx("div",{style:rt.sidebarDivider}),a.jsxs("div",{style:rt.sidebarPane,children:[a.jsx("div",{style:rt.sidebarSectionHeader,children:"TABLES"}),a.jsx("div",{style:rt.sidebarPaneContent,children:a.jsx(Tv,{tables:E,selectedTable:te,onSelectTable:ws})})]})]}),a.jsx(bs,{direction:"horizontal",onResize:_e,onResizeStart:me}),a.jsxs("div",{style:rt.content,children:[xe.length>0&&a.jsxs("div",{style:rt.subTabBar,"data-havn-hint":"tab-bar",children:[xe.map(ce=>a.jsx("button",{"data-havn-tab":"","data-havn-active":ae===ce?"true":"false",onClick:()=>rn(ce),style:ae===ce?rt.subTabActive:rt.subTab,children:ce==="Editor"&&Ce?ce+" *":ce},ce)),M&&ae==="Editor"&&a.jsxs("div",{style:rt.fileActions,"data-havn-hint":"editor-toolbar",children:[a.jsxs("span",{style:rt.fileName,children:[M,Ce&&a.jsx("span",{style:rt.modifiedDot,children:" *"})]}),a.jsx("button",{onClick:Or,disabled:!Ce,style:rt.btn,children:"Save"}),Nr&&a.jsx("button",{onClick:cn,disabled:L,style:rt.btn,title:"Run just this model",children:"Run Model"}),a.jsx("button",{onClick:kt,disabled:L,style:rt.btnPrimary,children:"Run"})]})]}),a.jsxs("div",{style:rt.panel,"data-havn-guide":"editor",children:[ae==="Overview"&&a.jsx(Nn,{name:"Overview",children:a.jsx(mm,{onNavigate:rn,onSelectTable:ws,onOpenFile:Hn,onRunStream:(ce,Fe)=>{if(ce)m(ce,Fe);else{const We=Object.keys(c);We.length>0?m(We[0],Fe):d("warn","No streams defined in project.yml")}},streams:c})}),ae==="Editor"&&a.jsx(Nn,{name:"Editor",children:a.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[a.jsx("div",{style:{flex:1,overflow:"hidden",minHeight:0},children:a.jsx(Hh,{content:se,language:$,onChange:ce=>{w(ce),Ie(!0)},activeFile:M,onMount:ce=>{ze.current=ce},goToLine:Xe,onFormat:M!=null&&M.endsWith(".sql")?Ya:void 0,onPreview:M!=null&&M.endsWith(".sql")?Vs:void 0})}),(z||oe||x)&&a.jsxs(a.Fragment,{children:[a.jsx(bs,{direction:"vertical",onResize:ce=>H(-ce),onResizeStart:ne}),a.jsxs("div",{style:{height:p,flexShrink:0,borderTop:"1px solid var(--havn-border)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[a.jsxs("div",{style:{padding:"4px 12px",fontSize:"11px",color:"var(--havn-text-secondary)",borderBottom:"1px solid var(--havn-border)",display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[a.jsx("span",{children:x?"Running…":oe?"Error":`${z.rows.length} row${z.rows.length!==1?"s":""}, ${z.columns.length} col${z.columns.length!==1?"s":""}`}),a.jsx("button",{onClick:()=>{D(null),Oe(null)},style:{background:"none",border:"none",color:"var(--havn-text-dim)",cursor:"pointer",fontSize:"14px",lineHeight:1},children:"×"})]}),a.jsx("div",{style:{flex:1,overflow:"auto"},children:oe?a.jsx("div",{style:{padding:"8px 12px",color:"var(--havn-red)",fontFamily:"var(--havn-font-mono)",fontSize:"12px",whiteSpace:"pre-wrap"},children:oe}):z&&a.jsx(Fs,{columns:z.columns,rows:z.rows})})]})]})]})}),ae==="Query"&&a.jsx(Nn,{name:"Query",children:a.jsx(am,{addOutput:d})}),ae==="Tables"&&a.jsx(Nn,{name:"Tables",children:a.jsx(rm,{selectedTable:te,onQueryTable:yo})}),ae==="Data Sources"&&a.jsx(Nn,{name:"Data Sources",children:a.jsx(_m,{addOutput:d,showConfirm:Ke})}),ae==="Notebooks"&&a.jsx(Nn,{name:"Notebooks",children:a.jsx(pm,{openPath:Ht})}),ae==="DAG"&&a.jsx(Nn,{name:"DAG",children:a.jsx(Em,{onOpenFile:Hn,showConfirm:Ke})}),ae==="Sentinel"&&a.jsx(Nn,{name:"Sentinel",children:a.jsx(cm,{})}),ae==="Diff"&&a.jsx(Nn,{name:"Diff",children:a.jsx(Sm,{api:Ee,addOutput:d})}),ae==="Docs"&&a.jsx(Nn,{name:"Docs",children:a.jsx(dm,{})}),ae==="Quality"&&a.jsx(Nn,{name:"Quality",children:a.jsx(Vm,{})}),ae==="Masking"&&a.jsx(Nn,{name:"Masking",children:a.jsx(Ym,{})}),ae==="Wiki"&&a.jsx(Nn,{name:"Wiki",children:a.jsx(Wm,{})}),ae==="History"&&a.jsx(Nn,{name:"History",children:a.jsx(sm,{onOpenFile:Hn})}),ae==="Settings"&&a.jsx(Nn,{name:"Settings",children:a.jsx(Bm,{onShowGuide:kr,showConfirm:Ke})})]}),R&&a.jsx("div",{"data-havn-hint":"run-summary",children:a.jsx(vm,{summary:R,onNavigate:rn,onDismiss:()=>C(null)})}),a.jsx(bs,{direction:"vertical",onResize:ce=>b(-ce),onResizeStart:K}),a.jsxs("div",{"data-havn-guide":"output",style:{flexShrink:0},children:[L&&O>0&&a.jsx("div",{style:{height:3,background:"#1a1a2e",width:"100%"},children:a.jsx("div",{style:{height:3,background:"#2dd4bf",width:`${Math.round(O*100)}%`,transition:"width 0.3s ease"}})}),a.jsx(Vh,{output:I,onClear:_,height:Ne,onOpenFile:Kl})]})]}),Jn&&a.jsxs(a.Fragment,{children:[a.jsx(bs,{direction:"horizontal",onResize:ce=>Ge(-ce),onResizeStart:De}),a.jsx("div",{style:{...rt.agentPanel,width:Le},children:a.jsx(nv,{isOpen:Jn,onToggle:()=>qt(!1),onFileChanged:()=>{zl(),N()},onOpenFile:Hn,onSelectTable:ws})})]})]}),a.jsx(zm,{onNavigate:rn}),a.jsx(Km,{steps:iv,onComplete:Fa,isOpen:Xt}),an&&a.jsx("div",{style:Lt.overlay,onClick:()=>un("cancel"),children:a.jsxs("div",{style:Lt.dialog,onClick:ce=>ce.stopPropagation(),children:[a.jsxs("div",{style:Lt.title,children:["Delete ",an.path,"?"]}),an.hasObject?a.jsxs(a.Fragment,{children:[a.jsxs("div",{style:Lt.body,children:["Also drop ",a.jsxs("strong",{children:[an.schema,".",an.name]})," table/view from the warehouse?"]}),a.jsxs("div",{style:Lt.footer,children:[a.jsx("button",{onClick:()=>un("cancel"),style:Lt.btnCancel,children:"Cancel"}),a.jsx("button",{onClick:()=>un("keep"),style:Lt.btnSecondary,children:"Delete File Only"}),a.jsx("button",{onClick:()=>un("drop"),style:Lt.btnDanger,children:"Delete & Drop"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{style:Lt.body,children:"This file will be permanently deleted."}),a.jsxs("div",{style:Lt.footer,children:[a.jsx("button",{onClick:()=>un("cancel"),style:Lt.btnCancel,children:"Cancel"}),a.jsx("button",{onClick:()=>un("keep"),style:Lt.btnDanger,children:"Delete"})]})]})]})}),Qt&&a.jsx("div",{style:Lt.overlay,onClick:()=>zt(!1),children:a.jsxs("div",{style:Lt.dialog,onClick:ce=>ce.stopPropagation(),children:[a.jsx("div",{style:Lt.title,children:Qt.title}),a.jsx("div",{style:Lt.body,children:Qt.body}),a.jsxs("div",{style:Lt.footer,children:[a.jsx("button",{onClick:()=>zt(!1),style:Lt.btnCancel,children:"Cancel"}),a.jsx("button",{onClick:()=>zt(!0),style:Qt.danger?Lt.btnDanger:Lt.btnSecondary,children:Qt.confirmLabel})]})]})}),Kr&&a.jsx("div",{style:Lt.overlay,onClick:()=>$r("keep"),children:a.jsxs("div",{style:Lt.dialog,onClick:ce=>ce.stopPropagation(),children:[a.jsxs("div",{style:Lt.title,children:["Agent edited ",Kr.path]}),a.jsx("div",{style:Lt.body,children:"You have unsaved changes to this file. Load the agent's version? Your unsaved changes will be lost."}),a.jsxs("div",{style:Lt.footer,children:[a.jsx("button",{onClick:()=>$r("keep"),style:Lt.btnCancel,children:"Keep my changes"}),a.jsx("button",{onClick:()=>$r("load"),style:Lt.btnDanger,children:"Load agent version"})]})]})}),mn&&a.jsx("div",{style:{position:"fixed",inset:0,background:"var(--havn-bg)",zIndex:900,overflow:"auto",padding:"16px"},children:a.jsx($m,{modelName:mn,onClose:()=>vn(null),onSaved:()=>{u()}})}),dr&&a.jsx(Jm,{onClose:()=>Ha(!1),onCreated:ce=>{u(),ce.path&&d("info",`Created ${ce.path}`)}})]})}function Sv({children:r,onPipelineComplete:l}){const{loadTables:E}=Zd();return a.jsx(sv,{onTablesChanged:E,onPipelineComplete:l,children:r})}function Rv(){const{authChecked:r,authRequired:l,needsSetup:E,handleLogin:T,isAuthenticated:c}=qd(),u=Ar(),N=A.useCallback(()=>{u("pipelineJustCompleted",!0),u("pipelineRanThisSession",!0)},[u]);return r?l?a.jsx(Xm,{onLogin:T,needsSetup:E}):a.jsx(rv,{enabled:c,children:a.jsx(Sv,{onPipelineComplete:N,children:a.jsx(cv,{})})}):a.jsx("div",{style:rt.loading,children:"Loading..."})}const rt={container:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--havn-bg)",color:"var(--havn-text)",fontFamily:"var(--havn-font)"},loading:{display:"flex",alignItems:"center",justifyContent:"center",height:"100vh",background:"var(--havn-bg)",color:"var(--havn-text-secondary)",fontFamily:"var(--havn-font)",fontSize:"14px"},header:{display:"flex",alignItems:"center",padding:"0 16px",borderBottom:"1px solid var(--havn-border)",background:"var(--havn-bg-secondary)",minHeight:"44px",gap:"16px"},logo:{display:"inline-flex",alignItems:"center",fontSize:"18px",fontWeight:700,fontFamily:"var(--havn-font)",color:"#3ECFB4",letterSpacing:"-0.5px",background:"none",border:"none",cursor:"pointer",padding:"8px 4px",flexShrink:0},sectionNav:{display:"flex",alignItems:"center",gap:"2px",flex:1},section:{padding:"10px 16px",background:"none",border:"none",borderBottom:"2px solid transparent",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"13px",whiteSpace:"nowrap",fontWeight:500,transition:"color 0.15s"},sectionActive:{padding:"10px 16px",background:"none",border:"none",borderBottom:"2px solid var(--havn-accent)",color:"var(--havn-text)",cursor:"pointer",fontSize:"13px",whiteSpace:"nowrap",fontWeight:500,transition:"color 0.15s"},headerRight:{display:"flex",alignItems:"center",gap:"8px",flexShrink:0},userInfo:{display:"flex",alignItems:"center",gap:"8px",marginLeft:"4px"},userName:{fontSize:"12px",color:"var(--havn-text)",fontWeight:500},userRole:{fontSize:"10px",color:"var(--havn-text-secondary)",background:"var(--havn-btn-bg)",padding:"2px 8px",borderRadius:"10px",fontWeight:500,textTransform:"capitalize"},logoutBtn:{padding:"3px 8px",background:"none",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"11px"},main:{display:"flex",flex:1,overflow:"hidden"},sidebar:{borderRight:"1px solid var(--havn-border)",overflow:"hidden",background:"var(--havn-bg-tertiary)",padding:"0",flexShrink:0,display:"flex",flexDirection:"column"},sidebarPane:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},sidebarPaneContent:{flex:1,overflow:"auto",minHeight:0,padding:"0 0 8px"},sidebarDivider:{height:"1px",background:"var(--havn-border)",margin:"0 12px",flexShrink:0},sidebarSectionHeader:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px 6px",fontSize:"10px",fontWeight:"600",color:"var(--havn-text-dim)",letterSpacing:"1px",textTransform:"uppercase",flexShrink:0},sidebarRefreshBtn:{background:"none",border:"none",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"13px",padding:"0 2px",lineHeight:1},content:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},agentPanel:{flexShrink:0,overflow:"hidden",height:"100%",display:"flex",flexDirection:"column"},subTabBar:{display:"flex",alignItems:"center",borderBottom:"1px solid var(--havn-border)",padding:"0 12px",background:"var(--havn-bg-tertiary)",minHeight:"32px"},subTab:{padding:"6px 14px",background:"none",border:"none",borderBottom:"2px solid transparent",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",whiteSpace:"nowrap",fontWeight:500},subTabActive:{padding:"6px 14px",background:"none",border:"none",borderBottom:"2px solid var(--havn-accent)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",whiteSpace:"nowrap",fontWeight:600},fileActions:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"8px",paddingLeft:"16px"},fileName:{fontSize:"12px",color:"var(--havn-text-secondary)",fontFamily:"var(--havn-font-mono)"},modifiedDot:{color:"var(--havn-accent)",fontWeight:700},panel:{flex:1,overflow:"hidden",minHeight:0},btn:{padding:"5px 12px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",fontWeight:500},btnPrimary:{padding:"5px 12px",background:"var(--havn-green)",border:"1px solid var(--havn-green-border)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:500}},Lt={overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},dialog:{background:"var(--havn-bg-secondary)",border:"1px solid var(--havn-border)",borderRadius:"8px",padding:"20px",width:"420px",maxWidth:"90vw"},title:{fontSize:"14px",fontWeight:600,color:"var(--havn-text)",marginBottom:"8px"},body:{fontSize:"13px",color:"var(--havn-text-secondary)",marginBottom:"16px",lineHeight:1.5},footer:{display:"flex",justifyContent:"flex-end",gap:"8px"},btnCancel:{padding:"6px 14px",background:"none",border:"1px solid var(--havn-border-light)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text-secondary)",cursor:"pointer",fontSize:"12px",fontWeight:500},btnSecondary:{padding:"6px 14px",background:"var(--havn-btn-bg)",border:"1px solid var(--havn-btn-border)",borderRadius:"var(--havn-radius-lg)",color:"var(--havn-text)",cursor:"pointer",fontSize:"12px",fontWeight:500},btnDanger:{padding:"6px 14px",background:"var(--havn-red, #c53030)",border:"1px solid var(--havn-red, #c53030)",borderRadius:"var(--havn-radius-lg)",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:500}};II.createRoot(document.getElementById("root")).render(a.jsx(aa.StrictMode,{children:a.jsx(Gh,{children:a.jsx(q_,{children:a.jsx(av,{children:a.jsx(Rv,{})})})})}));
