diff --git a/app/dist/assets/data-grid-overlay-editor-BYOokjyr.js b/app/dist/assets/data-grid-overlay-editor-D184XVUK.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-BYOokjyr.js rename to app/dist/assets/data-grid-overlay-editor-D184XVUK.js index e1f8506..0c11ef8 100644 --- a/app/dist/assets/data-grid-overlay-editor-BYOokjyr.js +++ b/app/dist/assets/data-grid-overlay-editor-D184XVUK.js @@ -1 +1 @@ -import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BVybGQOI.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; +import{s as $,r,i as w,a as z,b as J,c as Q,T as U,C as Z,m as ee}from"./index-BweuKm2D.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; diff --git a/app/dist/assets/index-BVybGQOI.js b/app/dist/assets/index-BVybGQOI.js deleted file mode 100644 index 3c99b83..0000000 --- a/app/dist/assets/index-BVybGQOI.js +++ /dev/null @@ -1,307 +0,0 @@ -var XR=Object.defineProperty;var GR=(t,e,n)=>e in t?XR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var bt=(t,e,n)=>GR(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var co=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var QS={exports:{}},Qh={},JS={exports:{}},Et={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Bc=Symbol.for("react.element"),qR=Symbol.for("react.portal"),YR=Symbol.for("react.fragment"),QR=Symbol.for("react.strict_mode"),JR=Symbol.for("react.profiler"),ZR=Symbol.for("react.provider"),eO=Symbol.for("react.context"),tO=Symbol.for("react.forward_ref"),nO=Symbol.for("react.suspense"),rO=Symbol.for("react.memo"),iO=Symbol.for("react.lazy"),Zw=Symbol.iterator;function sO(t){return t===null||typeof t!="object"?null:(t=Zw&&t[Zw]||t["@@iterator"],typeof t=="function"?t:null)}var ZS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},eC=Object.assign,tC={};function Ka(t,e,n){this.props=t,this.context=e,this.refs=tC,this.updater=n||ZS}Ka.prototype.isReactComponent={};Ka.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Ka.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function nC(){}nC.prototype=Ka.prototype;function zy(t,e,n){this.props=t,this.context=e,this.refs=tC,this.updater=n||ZS}var By=zy.prototype=new nC;By.constructor=zy;eC(By,Ka.prototype);By.isPureReactComponent=!0;var e1=Array.isArray,rC=Object.prototype.hasOwnProperty,jy={current:null},iC={key:!0,ref:!0,__self:!0,__source:!0};function sC(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)rC.call(e,r)&&!iC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,L=W[N];if(0>>1;Ni(B,R))Vi(le,B)?(W[N]=le,W[V]=R,N=V):(W[N]=B,W[q]=R,N=q);else if(Vi(le,R))W[N]=le,W[V]=R,N=V;else break e}}return U}function i(W,U){var R=W.sortIndex-U.sortIndex;return R!==0?R:W.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(W){for(var U=n(u);U!==null;){if(U.callback===null)r(u);else if(U.startTime<=W)r(u),U.sortIndex=U.expirationTime,e(a,U);else break;U=n(u)}}function k(W){if(m=!1,w(W),!p)if(n(a)!==null)p=!0,ne(b);else{var U=n(u);U!==null&&oe(k,U.startTime-W)}}function b(W,U){p=!1,m&&(m=!1,g(A),A=-1),h=!0;var R=d;try{for(w(U),f=n(a);f!==null&&(!(f.expirationTime>U)||W&&!_());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=U);U=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(U)}else r(a);f=n(a)}if(f!==null)var H=!0;else{var q=n(u);q!==null&&oe(k,q.startTime-U),H=!1}return H}finally{f=null,d=R,h=!1}}var S=!1,T=null,A=-1,M=5,O=-1;function _(){return!(t.unstable_now()-OW||125N?(W.sortIndex=R,e(u,W),n(a)===null&&W===n(u)&&(m?(g(A),A=-1):m=!0,oe(k,R-N))):(W.sortIndex=L,e(a,W),p||h||(p=!0,ne(b))),W},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(W){var U=d;return function(){var R=d;d=U;try{return W.apply(this,arguments)}finally{d=R}}}})(cC);uC.exports=cC;var mO=uC.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var yO=v,Gr=mO;function pe(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nm=Object.prototype.hasOwnProperty,vO=/^[: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]*$/,n1={},r1={};function wO(t){return Nm.call(r1,t)?!0:Nm.call(n1,t)?!1:vO.test(t)?r1[t]=!0:(n1[t]=!0,!1)}function xO(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function bO(t,e,n,r){if(e===null||typeof e>"u"||xO(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function yr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Gn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Gn[t]=new yr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Gn[e]=new yr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Gn[t]=new yr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Gn[t]=new yr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Gn[t]=new yr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Gn[t]=new yr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Gn[t]=new yr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Gn[t]=new yr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Gn[t]=new yr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Wy=/[\-:]([a-z])/g;function Vy(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Wy,Vy);Gn[e]=new yr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Wy,Vy);Gn[e]=new yr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Wy,Vy);Gn[e]=new yr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Gn[t]=new yr(t,1,!1,t.toLowerCase(),null,!1,!1)});Gn.xlinkHref=new yr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Gn[t]=new yr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Uy(t,e,n,r){var i=Gn.hasOwnProperty(e)?Gn[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` -`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{cg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Lu(t):""}function kO(t){switch(t.tag){case 5:return Lu(t.type);case 16:return Lu("Lazy");case 13:return Lu("Suspense");case 19:return Lu("SuspenseList");case 0:case 2:case 15:return t=fg(t.type,!1),t;case 11:return t=fg(t.type.render,!1),t;case 1:return t=fg(t.type,!0),t;default:return""}}function Fm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Zl:return"Fragment";case Jl:return"Portal";case Dm:return"Profiler";case Ky:return"StrictMode";case _m:return"Suspense";case Lm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case hC:return(t.displayName||"Context")+".Consumer";case dC:return(t._context.displayName||"Context")+".Provider";case Xy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Gy:return e=t.displayName||null,e!==null?e:Fm(t.type)||"Memo";case no:e=t._payload,t=t._init;try{return Fm(t(e))}catch{}}return null}function SO(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Fm(e);case 8:return e===Ky?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Eo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function gC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function CO(t){var e=gC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Mf(t){t._valueTracker||(t._valueTracker=CO(t))}function mC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=gC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Wd(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function $m(t,e){var n=e.checked;return fn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function s1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Eo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function yC(t,e){e=e.checked,e!=null&&Uy(t,"checked",e,!1)}function zm(t,e){yC(t,e);var n=Eo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Bm(t,e.type,n):e.hasOwnProperty("defaultValue")&&Bm(t,e.type,Eo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function o1(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Bm(t,e,n){(e!=="number"||Wd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Fu=Array.isArray;function ma(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Rf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function hc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Vu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},TO=["Webkit","ms","Moz","O"];Object.keys(Vu).forEach(function(t){TO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Vu[e]=Vu[t]})});function bC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Vu.hasOwnProperty(t)&&Vu[t]?(""+e).trim():e+"px"}function kC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=bC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var EO=fn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Wm(t,e){if(e){if(EO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(pe(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(pe(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(pe(61))}if(e.style!=null&&typeof e.style!="object")throw Error(pe(62))}}function Vm(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Um=null;function qy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Km=null,ya=null,va=null;function u1(t){if(t=Wc(t)){if(typeof Km!="function")throw Error(pe(280));var e=t.stateNode;e&&(e=np(e),Km(t.stateNode,t.type,e))}}function SC(t){ya?va?va.push(t):va=[t]:ya=t}function CC(){if(ya){var t=ya,e=va;if(va=ya=null,u1(t),e)for(t=0;t>>=0,t===0?32:31-(FO(t)/$O|0)|0}var Of=64,Pf=4194304;function $u(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Xd(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=$u(l):(s&=o,s!==0&&(r=$u(s)))}else o=n&~i,o!==0?r=$u(o):s!==0&&(r=$u(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function jc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Li(e),t[e]=n}function HO(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Ku),v1=" ",w1=!1;function VC(t,e){switch(t){case"keyup":return mP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function UC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function vP(t,e){switch(t){case"compositionend":return UC(e);case"keypress":return e.which!==32?null:(w1=!0,v1);case"textInput":return t=e.data,t===v1&&w1?null:t;default:return null}}function wP(t,e){if(ea)return t==="compositionend"||!rv&&VC(t,e)?(t=HC(),Cd=ev=fo=null,ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=S1(n)}}function qC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?qC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function YC(){for(var t=window,e=Wd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Wd(t.document)}return e}function iv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function MP(t){var e=YC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&qC(n.ownerDocument.documentElement,n)){if(r!==null&&iv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=C1(n,s);var o=C1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ta=null,Jm=null,Gu=null,Zm=!1;function T1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zm||ta==null||ta!==Wd(r)||(r=ta,"selectionStart"in r&&iv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gu&&wc(Gu,r)||(Gu=r,r=Yd(Jm,"onSelect"),0ia||(t.current=s0[ia],s0[ia]=null,ia--)}function Zt(t,e){ia++,s0[ia]=t.current,t.current=e}var Ao={},or=Do(Ao),Ar=Do(!1),pl=Ao;function Ra(t,e){var n=t.type.contextTypes;if(!n)return Ao;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Mr(t){return t=t.childContextTypes,t!=null}function Jd(){sn(Ar),sn(or)}function I1(t,e,n){if(or.current!==Ao)throw Error(pe(168));Zt(or,e),Zt(Ar,n)}function s2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(pe(108,SO(t)||"Unknown",i));return fn({},n,r)}function Zd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ao,pl=or.current,Zt(or,t),Zt(Ar,Ar.current),!0}function N1(t,e,n){var r=t.stateNode;if(!r)throw Error(pe(169));n?(t=s2(t,e,pl),r.__reactInternalMemoizedMergedChildContext=t,sn(Ar),sn(or),Zt(or,t)):sn(Ar),Zt(Ar,n)}var Cs=null,rp=!1,Tg=!1;function o2(t){Cs===null?Cs=[t]:Cs.push(t)}function BP(t){rp=!0,o2(t)}function _o(){if(!Tg&&Cs!==null){Tg=!0;var t=0,e=Wt;try{var n=Cs;for(Wt=1;t>=o,i-=o,Rs=1<<32-Li(e)+i|n<A?(M=T,T=null):M=T.sibling;var O=d(g,T,w[A],k);if(O===null){T===null&&(T=M);break}t&&T&&O.alternate===null&&e(g,T),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O,T=M}if(A===w.length)return n(g,T),an&&Qo(g,A),b;if(T===null){for(;AA?(M=T,T=null):M=T.sibling;var _=d(g,T,O.value,k);if(_===null){T===null&&(T=M);break}t&&T&&_.alternate===null&&e(g,T),y=s(_,y,A),S===null?b=_:S.sibling=_,S=_,T=M}if(O.done)return n(g,T),an&&Qo(g,A),b;if(T===null){for(;!O.done;A++,O=w.next())O=f(g,O.value,k),O!==null&&(y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return an&&Qo(g,A),b}for(T=r(g,T);!O.done;A++,O=w.next())O=h(T,g,A,O.value,k),O!==null&&(t&&O.alternate!==null&&T.delete(O.key===null?A:O.key),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return t&&T.forEach(function(P){return e(g,P)}),an&&Qo(g,A),b}function x(g,y,w,k){if(typeof w=="object"&&w!==null&&w.type===Zl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Af:e:{for(var b=w.key,S=y;S!==null;){if(S.key===b){if(b=w.type,b===Zl){if(S.tag===7){n(g,S.sibling),y=i(S,w.props.children),y.return=g,g=y;break e}}else if(S.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===no&&L1(b)===S.type){n(g,S.sibling),y=i(S,w.props),y.ref=bu(g,S,w),y.return=g,g=y;break e}n(g,S);break}else e(g,S);S=S.sibling}w.type===Zl?(y=fl(w.props.children,g.mode,k,w.key),y.return=g,g=y):(k=Id(w.type,w.key,w.props,null,g.mode,k),k.ref=bu(g,y,w),k.return=g,g=k)}return o(g);case Jl:e:{for(S=w.key;y!==null;){if(y.key===S)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(g,y.sibling),y=i(y,w.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else e(g,y);y=y.sibling}y=Ng(w,g.mode,k),y.return=g,g=y}return o(g);case no:return S=w._init,x(g,y,S(w._payload),k)}if(Fu(w))return p(g,y,w,k);if(mu(w))return m(g,y,w,k);$f(g,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(g,y.sibling),y=i(y,w),y.return=g,g=y):(n(g,y),y=Ig(w,g.mode,k),y.return=g,g=y),o(g)):n(g,y)}return x}var Pa=c2(!0),f2=c2(!1),nh=Do(null),rh=null,la=null,av=null;function uv(){av=la=rh=null}function cv(t){var e=nh.current;sn(nh),t._currentValue=e}function a0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function xa(t,e){rh=t,av=la=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Cr=!0),t.firstContext=null)}function hi(t){var e=t._currentValue;if(av!==t)if(t={context:t,memoizedValue:e,next:null},la===null){if(rh===null)throw Error(pe(308));la=t,rh.dependencies={lanes:0,firstContext:t}}else la=la.next=t;return e}var ol=null;function fv(t){ol===null?ol=[t]:ol.push(t)}function d2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,fv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Ls(t,r)}function Ls(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var ro=!1;function dv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function h2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Is(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function bo(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,_t&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Ls(t,n)}return i=r.interleaved,i===null?(e.next=e,fv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Ls(t,n)}function Ed(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}function F1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function ih(t,e,n,r){var i=t.updateQueue;ro=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var d=l.lane,h=l.eventTime;if((r&d)===d){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,m=l;switch(d=e,h=n,m.tag){case 1:if(p=m.payload,typeof p=="function"){f=p.call(h,f,d);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=fn({},f,d);break e;case 2:ro=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=f):c=c.next=h,o|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);yl|=o,t.lanes=o,t.memoizedState=f}}function $1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=Ag.transition;Ag.transition={};try{t(!1),e()}finally{Wt=n,Ag.transition=r}}function O2(){return pi().memoizedState}function VP(t,e,n){var r=So(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},P2(t))I2(e,n);else if(n=d2(t,e,n,r),n!==null){var i=hr();Fi(n,t,r,i),N2(n,e,r)}}function UP(t,e,n){var r=So(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(P2(t))I2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,$i(l,o)){var a=e.interleaved;a===null?(i.next=i,fv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=d2(t,e,i,r),n!==null&&(i=hr(),Fi(n,t,r,i),N2(n,e,r))}}function P2(t){var e=t.alternate;return t===cn||e!==null&&e===cn}function I2(t,e){qu=oh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function N2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}var lh={readContext:hi,useCallback:Zn,useContext:Zn,useEffect:Zn,useImperativeHandle:Zn,useInsertionEffect:Zn,useLayoutEffect:Zn,useMemo:Zn,useReducer:Zn,useRef:Zn,useState:Zn,useDebugValue:Zn,useDeferredValue:Zn,useTransition:Zn,useMutableSource:Zn,useSyncExternalStore:Zn,useId:Zn,unstable_isNewReconciler:!1},KP={readContext:hi,useCallback:function(t,e){return Ji().memoizedState=[t,e===void 0?null:e],t},useContext:hi,useEffect:B1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Md(4194308,4,T2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Md(4194308,4,t,e)},useInsertionEffect:function(t,e){return Md(4,2,t,e)},useMemo:function(t,e){var n=Ji();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Ji();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=VP.bind(null,cn,t),[r.memoizedState,t]},useRef:function(t){var e=Ji();return t={current:t},e.memoizedState=t},useState:z1,useDebugValue:xv,useDeferredValue:function(t){return Ji().memoizedState=t},useTransition:function(){var t=z1(!1),e=t[0];return t=WP.bind(null,t[1]),Ji().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=cn,i=Ji();if(an){if(n===void 0)throw Error(pe(407));n=n()}else{if(n=e(),jn===null)throw Error(pe(349));ml&30||y2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,B1(w2.bind(null,r,s,t),[t]),r.flags|=2048,Ac(9,v2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Ji(),e=jn.identifierPrefix;if(an){var n=Os,r=Rs;n=(r&~(1<<32-Li(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Tc++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[Zi]=e,t[kc]=r,W2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Vm(n,r),n){case"dialog":nn("cancel",t),nn("close",t),i=r;break;case"iframe":case"object":case"embed":nn("load",t),i=r;break;case"video":case"audio":for(i=0;iDa&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304)}else{if(!r)if(t=sh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ku(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!an)return er(e),null}else 2*Cn()-s.renderingStartTime>Da&&n!==1073741824&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Cn(),e.sibling=null,n=un.current,Zt(un,r?n&1|2:n&1),e):(er(e),null);case 22:case 23:return Ev(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Br&1073741824&&(er(e),e.subtreeFlags&6&&(e.flags|=8192)):er(e),null;case 24:return null;case 25:return null}throw Error(pe(156,e.tag))}function eI(t,e){switch(ov(e),e.tag){case 1:return Mr(e.type)&&Jd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ia(),sn(Ar),sn(or),gv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return pv(e),null;case 13:if(sn(un),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(pe(340));Oa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return sn(un),null;case 4:return Ia(),null;case 10:return cv(e.type._context),null;case 22:case 23:return Ev(),null;case 24:return null;default:return null}}var Bf=!1,ir=!1,tI=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function aa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){pn(t,e,r)}else n.current=null}function y0(t,e,n){try{n()}catch(r){pn(t,e,r)}}var Q1=!1;function nI(t,e){if(e0=Gd,t=YC(),iv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=o),d===s&&++c===r&&(a=o),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(t0={focusedElem:t,selectionRange:n},Gd=!1,Pe=e;Pe!==null;)if(e=Pe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Pe=t;else for(;Pe!==null;){e=Pe;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var m=p.memoizedProps,x=p.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:Ai(e.type,m),x);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(pe(163))}}catch(k){pn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Pe=t;break}Pe=e.return}return p=Q1,Q1=!1,p}function Yu(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&y0(e,n,s)}i=i.next}while(i!==r)}}function op(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function v0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function K2(t){var e=t.alternate;e!==null&&(t.alternate=null,K2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Zi],delete e[kc],delete e[i0],delete e[$P],delete e[zP])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function X2(t){return t.tag===5||t.tag===3||t.tag===4}function J1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||X2(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function w0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Qd));else if(r!==4&&(t=t.child,t!==null))for(w0(t,e,n),t=t.sibling;t!==null;)w0(t,e,n),t=t.sibling}function x0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(x0(t,e,n),t=t.sibling;t!==null;)x0(t,e,n),t=t.sibling}var Wn=null,Mi=!1;function Xs(t,e,n){for(n=n.child;n!==null;)G2(t,e,n),n=n.sibling}function G2(t,e,n){if(as&&typeof as.onCommitFiberUnmount=="function")try{as.onCommitFiberUnmount(Jh,n)}catch{}switch(n.tag){case 5:ir||aa(n,e);case 6:var r=Wn,i=Mi;Wn=null,Xs(t,e,n),Wn=r,Mi=i,Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Wn.removeChild(n.stateNode));break;case 18:Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?Cg(t.parentNode,n):t.nodeType===1&&Cg(t,n),yc(t)):Cg(Wn,n.stateNode));break;case 4:r=Wn,i=Mi,Wn=n.stateNode.containerInfo,Mi=!0,Xs(t,e,n),Wn=r,Mi=i;break;case 0:case 11:case 14:case 15:if(!ir&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&y0(n,e,o),i=i.next}while(i!==r)}Xs(t,e,n);break;case 1:if(!ir&&(aa(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){pn(n,e,l)}Xs(t,e,n);break;case 21:Xs(t,e,n);break;case 22:n.mode&1?(ir=(r=ir)||n.memoizedState!==null,Xs(t,e,n),ir=r):Xs(t,e,n);break;default:Xs(t,e,n)}}function Z1(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new tI),e.forEach(function(r){var i=fI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ci(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Cn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*iI(r/1960))-r,10t?16:t,ho===null)var r=!1;else{if(t=ho,ho=null,ch=0,_t&6)throw Error(pe(331));var i=_t;for(_t|=4,Pe=t.current;Pe!==null;){var s=Pe,o=s.child;if(Pe.flags&16){var l=s.deletions;if(l!==null){for(var a=0;aCn()-Cv?cl(t,0):Sv|=n),Rr(t,e)}function nT(t,e){e===0&&(t.mode&1?(e=Pf,Pf<<=1,!(Pf&130023424)&&(Pf=4194304)):e=1);var n=hr();t=Ls(t,e),t!==null&&(jc(t,e,n),Rr(t,n))}function cI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),nT(t,n)}function fI(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(pe(314))}r!==null&&r.delete(e),nT(t,n)}var rT;rT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ar.current)Cr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Cr=!1,JP(t,e,n);Cr=!!(t.flags&131072)}else Cr=!1,an&&e.flags&1048576&&l2(e,th,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Rd(t,e),t=e.pendingProps;var i=Ra(e,or.current);xa(e,n),i=yv(null,e,r,t,i,n);var s=vv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Mr(r)?(s=!0,Zd(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,dv(e),i.updater=sp,e.stateNode=i,i._reactInternals=e,c0(e,r,t,n),e=h0(null,e,r,!0,s,n)):(e.tag=0,an&&s&&sv(e),fr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Rd(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=hI(r),t=Ai(r,t),i){case 0:e=d0(null,e,r,t,n);break e;case 1:e=G1(null,e,r,t,n);break e;case 11:e=K1(null,e,r,t,n);break e;case 14:e=X1(null,e,r,Ai(r.type,t),n);break e}throw Error(pe(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),d0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),G1(t,e,r,i,n);case 3:e:{if(B2(e),t===null)throw Error(pe(387));r=e.pendingProps,s=e.memoizedState,i=s.element,h2(t,e),ih(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Na(Error(pe(423)),e),e=q1(t,e,r,n,i);break e}else if(r!==i){i=Na(Error(pe(424)),e),e=q1(t,e,r,n,i);break e}else for(Kr=xo(e.stateNode.containerInfo.firstChild),Xr=e,an=!0,Ri=null,n=f2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Oa(),r===i){e=Fs(t,e,n);break e}fr(t,e,r,n)}e=e.child}return e;case 5:return p2(e),t===null&&l0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,n0(r,i)?o=null:s!==null&&n0(r,s)&&(e.flags|=32),z2(t,e),fr(t,e,o,n),e.child;case 6:return t===null&&l0(e),null;case 13:return j2(t,e,n);case 4:return hv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Pa(e,null,r,n):fr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),K1(t,e,r,i,n);case 7:return fr(t,e,e.pendingProps,n),e.child;case 8:return fr(t,e,e.pendingProps.children,n),e.child;case 12:return fr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Zt(nh,r._currentValue),r._currentValue=o,s!==null)if($i(s.value,o)){if(s.children===i.children&&!Ar.current){e=Fs(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Is(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),a0(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(pe(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),a0(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}fr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,xa(e,n),i=hi(i),r=r(i),e.flags|=1,fr(t,e,r,n),e.child;case 14:return r=e.type,i=Ai(r,e.pendingProps),i=Ai(r.type,i),X1(t,e,r,i,n);case 15:return F2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),Rd(t,e),e.tag=1,Mr(r)?(t=!0,Zd(e)):t=!1,xa(e,n),D2(e,r,i),c0(e,r,i,n),h0(null,e,r,!0,t,n);case 19:return H2(t,e,n);case 22:return $2(t,e,n)}throw Error(pe(156,e.tag))};function iT(t,e){return PC(t,e)}function dI(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function si(t,e,n,r){return new dI(t,e,n,r)}function Mv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function hI(t){if(typeof t=="function")return Mv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Xy)return 11;if(t===Gy)return 14}return 2}function Co(t,e){var n=t.alternate;return n===null?(n=si(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Id(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Mv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Zl:return fl(n.children,i,s,e);case Ky:o=8,i|=8;break;case Dm:return t=si(12,n,e,i|2),t.elementType=Dm,t.lanes=s,t;case _m:return t=si(13,n,e,i),t.elementType=_m,t.lanes=s,t;case Lm:return t=si(19,n,e,i),t.elementType=Lm,t.lanes=s,t;case pC:return ap(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case dC:o=10;break e;case hC:o=9;break e;case Xy:o=11;break e;case Gy:o=14;break e;case no:o=16,r=null;break e}throw Error(pe(130,t==null?t:typeof t,""))}return e=si(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function fl(t,e,n,r){return t=si(7,t,r,e),t.lanes=n,t}function ap(t,e,n,r){return t=si(22,t,r,e),t.elementType=pC,t.lanes=n,t.stateNode={isHidden:!1},t}function Ig(t,e,n){return t=si(6,t,null,e),t.lanes=n,t}function Ng(t,e,n){return e=si(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function pI(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=hg(0),this.expirationTimes=hg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=hg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Rv(t,e,n,r,i,s,o,l,a){return t=new pI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=si(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},dv(s),t}function gI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(aT)}catch(t){console.error(t)}}aT(),aC.exports=qr;var xI=aC.exports,uT,lx=xI;uT=lx.createRoot,lx.hydrateRoot;function cT(){return""}function bI(){return/^G-[A-Z0-9]+$/.test(cT())}function kI(){const t=window.gtag;typeof t=="function"&&bI()&&t("config",cT(),{send_page_view:!1})}function SI(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function CI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function TI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function EI(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function AI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function hp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,AI(t),{props:{...e}})}function MI(t){hp("input",t)}function RI(t){hp("conversion",t)}function Uo(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};hp("export",e)}function OI(t){hp("feedback",t)}function PI(t){return new TextEncoder().encode(t).length}function II(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function NI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function DI(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0,u=null,c=0;function f(h){if(h.text.trim()==="")return!1;const p=PI(h.text),m=II(p),x=i(h.direction,h.text),g=`${h.direction}:${h.input}:${p}:${NI(h.text)}`,y=r();return g!==l&&(a===0||y-a>=n)&&(l=g,a=y,MI({direction:h.direction,input:h.input,size:m,valid:x})),!x||g===u||c!==0&&y-c{o=void 0,s&&f(s)},e)}return{edit(h,p){s={direction:h,input:"paste",text:p},d()},discrete(h,p,m){s={direction:h,input:p,text:m},d(),f(s)},cancel(){s=null,l=null,u=null,o&&(clearTimeout(o),o=void 0)}}}/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const _I=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const LI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ax=t=>{const e=LI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var Dg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FI=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},$I=v.createContext({}),zI=()=>v.useContext($I),BI=v.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:d="currentColor",className:h=""}=zI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,...Dg,width:e??u??Dg.width,height:e??u??Dg.height,stroke:t??d,strokeWidth:p,className:fT("lucide",h,i),...!s&&!FI(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>v.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const En=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement(BI,{ref:s,iconNode:e,className:fT(`lucide-${_I(ax(t))}`,`lucide-${t}`,r),...i}));return n.displayName=ax(t),n};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const jI=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],HI=En("arrow-left-right",jI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const WI=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],ux=En("braces",WI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VI=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],UI=En("chevron-down",VI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const KI=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],XI=En("clipboard",KI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const GI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],qI=En("clock",GI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const YI=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Nv=En("copy",YI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QI=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],dT=En("download",QI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JI=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],hT=En("file-up",JI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZI=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],eN=En("moon",ZI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const tN=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],nN=En("redo-2",tN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const rN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],iN=En("rotate-ccw-clock",rN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const sN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],cx=En("rotate-ccw",sN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],lN=En("search",oN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const aN=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],uN=En("sparkles",aN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cN=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],fN=En("sun",cN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dN=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],hN=En("table",dN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const pN=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],gN=En("thumbs-down",pN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const mN=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],yN=En("thumbs-up",mN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const vN=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],hh=En("trash",vN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wN=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],xN=En("undo-2",wN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const bN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],ph=En("x",bN);function pT(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=TN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(Dv);return l[0]===""&&l.length!==1&&l.shift(),gT(l,e)||CN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},gT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?gT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Dv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},fx=/^\[(.+)\]$/,CN=t=>{if(fx.test(t)){const e=fx.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},TN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return AN(Object.entries(t.classGroups),n).forEach(([s,o])=>{T0(o,r,s,e)}),r},T0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:dx(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(EN(i)){T0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{T0(o,dx(e,s),n,r)})})},dx=(t,e)=>{let n=t;return e.split(Dv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},EN=t=>t.isThemeGetter,AN=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,MN=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},mT="!",RN=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let x=0;xc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:o}):o},ON=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},PN=t=>({cache:MN(t.cacheSize),parseClassName:RN(t),...SN(t)}),IN=/\s+/,NN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(IN);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}=n(u);let p=!!h,m=r(p?d.substring(0,h):d);if(!m){if(!p){l=u+(l.length>0?" "+l:l);continue}if(m=r(d),!m){l=u+(l.length>0?" "+l:l);continue}p=!1}const x=ON(c).join(":"),g=f?x+mT:x,y=g+m;if(s.includes(y))continue;s.push(y);const w=i(m,p);for(let k=0;k0?" "+l:l)}return l};function DN(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=PN(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=NN(a,n);return i(a,c),c}return function(){return s(DN.apply(null,arguments))}}const tn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},vT=/^\[(?:([a-z-]+):)?(.+)\]$/i,LN=/^\d+\/\d+$/,FN=new Set(["px","full","screen"]),$N=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,zN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,BN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,jN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,HN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,bs=t=>ka(t)||FN.has(t)||LN.test(t),Gs=t=>qa(t,"length",YN),ka=t=>!!t&&!Number.isNaN(Number(t)),_g=t=>qa(t,"number",ka),Cu=t=>!!t&&Number.isInteger(Number(t)),WN=t=>t.endsWith("%")&&ka(t.slice(0,-1)),mt=t=>vT.test(t),qs=t=>$N.test(t),VN=new Set(["length","size","percentage"]),UN=t=>qa(t,VN,wT),KN=t=>qa(t,"position",wT),XN=new Set(["image","url"]),GN=t=>qa(t,XN,JN),qN=t=>qa(t,"",QN),Tu=()=>!0,qa=(t,e,n)=>{const r=vT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},YN=t=>zN.test(t)&&!BN.test(t),wT=()=>!1,QN=t=>jN.test(t),JN=t=>HN.test(t),ZN=()=>{const t=tn("colors"),e=tn("spacing"),n=tn("blur"),r=tn("brightness"),i=tn("borderColor"),s=tn("borderRadius"),o=tn("borderSpacing"),l=tn("borderWidth"),a=tn("contrast"),u=tn("grayscale"),c=tn("hueRotate"),f=tn("invert"),d=tn("gap"),h=tn("gradientColorStops"),p=tn("gradientColorStopPositions"),m=tn("inset"),x=tn("margin"),g=tn("opacity"),y=tn("padding"),w=tn("saturate"),k=tn("scale"),b=tn("sepia"),S=tn("skew"),T=tn("space"),A=tn("translate"),M=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",mt,e],P=()=>[mt,e],I=()=>["",bs,Gs],D=()=>["auto",ka,mt],Z=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],oe=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>["start","end","center","between","around","evenly","stretch"],U=()=>["","0",mt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[ka,mt];return{cacheSize:500,separator:":",theme:{colors:[Tu],spacing:[bs,Gs],blur:["none","",qs,mt],brightness:N(),borderColor:[t],borderRadius:["none","","full",qs,mt],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:U(),hueRotate:N(),invert:U(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[WN,Gs],inset:_(),margin:_(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:U(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",mt]}],container:["container"],columns:[{columns:[qs]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Z(),mt]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Cu,mt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",mt]}],grow:[{grow:U()}],shrink:[{shrink:U()}],order:[{order:["first","last","none",Cu,mt]}],"grid-cols":[{"grid-cols":[Tu]}],"col-start-end":[{col:["auto",{span:["full",Cu,mt]},mt]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[Tu]}],"row-start-end":[{row:["auto",{span:[Cu,mt]},mt]}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",mt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",mt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...W()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...W(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...W(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",mt,e]}],"min-w":[{"min-w":[mt,e,"min","max","fit"]}],"max-w":[{"max-w":[mt,e,"none","full","min","max","fit","prose",{screen:[qs]},qs]}],h:[{h:[mt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[mt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",qs,Gs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",_g]}],"font-family":[{font:[Tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",mt]}],"line-clamp":[{"line-clamp":["none",ka,_g]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",bs,mt]}],"list-image":[{"list-image":["none",mt]}],"list-style-type":[{list:["none","disc","decimal",mt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",bs,Gs]}],"underline-offset":[{"underline-offset":["auto",bs,mt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",mt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",mt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Z(),KN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",UN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},GN]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[bs,mt]}],"outline-w":[{outline:[bs,Gs]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[bs,Gs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",qs,qN]}],"shadow-color":[{shadow:[Tu]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...oe(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":oe()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",qs,mt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[b]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[b]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",mt]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",mt]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",mt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Cu,mt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",mt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",mt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",mt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[bs,Gs,_g]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},eD=_N(ZN);function Tr(...t){return eD(kN(t))}function Lg(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function tD({flipped:t}){return E.jsx(HI,{size:18,strokeWidth:2,"aria-hidden":"true",className:Tr("transition-transform duration-300",t&&"rotate-180")})}function nD({direction:t,onFlip:e}){return E.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${Lg(t)})`,"aria-label":`Switch conversion direction (currently ${Lg(t)})`,className:"flex h-9 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-background px-3 text-xs font-medium text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground md:h-8 md:gap-1 md:px-2.5 md:text-[11px]",children:[E.jsx(tD,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Lg(t)})]})}const xT=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],rD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:xT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function iD(){const[t,e]=v.useState(!1),n=v.useId();return E.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[E.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[E.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),E.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:xT.map(r=>E.jsxs("div",{className:"mb-3 last:mb-0",children:[E.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),E.jsx("p",{children:r.answer})]},r.question))}),E.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(rD)}})]})}const sD="https://github.com/FlatFilers/csvjson-app/discussions/163";function oD(){return E.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-3 py-1.5 text-xs text-muted-foreground sm:px-4 sm:text-sm",children:E.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",E.jsx("a",{"data-testid":"feedback-link",href:sD,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const bT="csvjson:feedback.v1",lD=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function aD(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function hx(){try{const t=window.localStorage.getItem(bT);if(t===null)return null;const e=JSON.parse(t);return aD(e)?e:null}catch{return null}}function px(t){try{window.localStorage.setItem(bT,JSON.stringify(t))}catch{}}function gx(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function uD(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function cD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(uD(t))})).ok?"ok":"failed"}catch{return"failed"}}function mx(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function fD(){const[t,e]=v.useState(hx),[n,r]=v.useState(!1),[i,s]=v.useState(null),[o,l]=v.useState(""),[a,u]=v.useState(!1),[c,f]=v.useState(!1),d=v.useRef(null),h=v.useRef(0),p=v.useCallback((b,S)=>{const T={...b,pending:S==="failed"};px(T),e(T),S==="ok"?OI({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=v.useCallback((b,S)=>{const T=++h.current;S&&f(!0),cD(b).then(A=>{h.current===T&&(p(b,A),A==="ok"&&u(!0))}).finally(()=>{S&&h.current===T&&f(!1)})},[p]),x=b=>{const S={...b,pending:!0};px(S),e(S),m(S,!0)},g=v.useRef(!1);v.useEffect(()=>{if(g.current)return;g.current=!0;const b=hx();b!=null&&b.pending&&m(b,!1)},[m]),v.useEffect(()=>{if(!a)return;const b=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(b)},[a]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&r(!1)},S=T=>{const A=d.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",S)}},[n]);const y=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??gx(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const b=o.trim();x({clientId:(t==null?void 0:t.clientId)??gx(),vote:-1,reasonCode:i,reasonText:b===""?null:b}),r(!1)};return E.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[E.jsx("button",{type:"button","data-testid":"feedback-up",onClick:y,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:mx((t==null?void 0:t.vote)===1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M7 10v12"}),E.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),E.jsx("button",{type:"button","data-testid":"feedback-down",onClick:w,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:mx((t==null?void 0:t.vote)===-1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M17 14V2"}),E.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&E.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&E.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&E.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),E.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:lD.map(b=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${b.value}`,"aria-pressed":i===b.value,onClick:()=>s(b.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===b.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:b.label},b.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:b=>l(b.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),E.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),E.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function kT(t="This should not happen"){throw new Error(t)}function Wr(t,e="Assertion failed"){if(!t)return kT(e)}function Rc(t,e){return kT(e??"Hell froze over")}function dD(t,e){try{return t()}catch{return e}}const yx=Object.prototype.hasOwnProperty;function _a(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&_a(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(yx.call(t,n)&&++r&&!yx.call(e,n)||!(n in e)||!_a(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var hD=Object.prototype,pD=hD.hasOwnProperty;function gD(t,e){return t!=null&&pD.call(t,e)}var mD=gD,yD=Array.isArray,hs=yD,vD=typeof co=="object"&&co&&co.Object===Object&&co,ST=vD,wD=ST,xD=typeof self=="object"&&self&&self.Object===Object&&self,bD=wD||xD||Function("return this")(),ps=bD,kD=ps,SD=kD.Symbol,Uc=SD,vx=Uc,CT=Object.prototype,CD=CT.hasOwnProperty,TD=CT.toString,Eu=vx?vx.toStringTag:void 0;function ED(t){var e=CD.call(t,Eu),n=t[Eu];try{t[Eu]=void 0;var r=!0}catch{}var i=TD.call(t);return r&&(e?t[Eu]=n:delete t[Eu]),i}var AD=ED,MD=Object.prototype,RD=MD.toString;function OD(t){return RD.call(t)}var PD=OD,wx=Uc,ID=AD,ND=PD,DD="[object Null]",_D="[object Undefined]",xx=wx?wx.toStringTag:void 0;function LD(t){return t==null?t===void 0?_D:DD:xx&&xx in Object(t)?ID(t):ND(t)}var Kc=LD;function FD(t){return t!=null&&typeof t=="object"}var Xc=FD,$D=Kc,zD=Xc,BD="[object Symbol]";function jD(t){return typeof t=="symbol"||zD(t)&&$D(t)==BD}var pp=jD,HD=hs,WD=pp,VD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,UD=/^\w*$/;function KD(t,e){if(HD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||WD(t)?!0:UD.test(t)||!VD.test(t)||e!=null&&t in Object(e)}var _v=KD;function XD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var El=XD,GD=Kc,qD=El,YD="[object AsyncFunction]",QD="[object Function]",JD="[object GeneratorFunction]",ZD="[object Proxy]";function e_(t){if(!qD(t))return!1;var e=GD(t);return e==QD||e==JD||e==YD||e==ZD}var TT=e_,t_=ps,n_=t_["__core-js_shared__"],r_=n_,Fg=r_,bx=function(){var t=/[^.]+$/.exec(Fg&&Fg.keys&&Fg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function i_(t){return!!bx&&bx in t}var s_=i_,o_=Function.prototype,l_=o_.toString;function a_(t){if(t!=null){try{return l_.call(t)}catch{}try{return t+""}catch{}}return""}var ET=a_,u_=TT,c_=s_,f_=El,d_=ET,h_=/[\\^$.*+?()[\]{}|]/g,p_=/^\[object .+?Constructor\]$/,g_=Function.prototype,m_=Object.prototype,y_=g_.toString,v_=m_.hasOwnProperty,w_=RegExp("^"+y_.call(v_).replace(h_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function x_(t){if(!f_(t)||c_(t))return!1;var e=u_(t)?w_:p_;return e.test(d_(t))}var b_=x_;function k_(t,e){return t==null?void 0:t[e]}var S_=k_,C_=b_,T_=S_;function E_(t,e){var n=T_(t,e);return C_(n)?n:void 0}var Al=E_,A_=Al,M_=A_(Object,"create"),gp=M_,kx=gp;function R_(){this.__data__=kx?kx(null):{},this.size=0}var O_=R_;function P_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var I_=P_,N_=gp,D_="__lodash_hash_undefined__",__=Object.prototype,L_=__.hasOwnProperty;function F_(t){var e=this.__data__;if(N_){var n=e[t];return n===D_?void 0:n}return L_.call(e,t)?e[t]:void 0}var $_=F_,z_=gp,B_=Object.prototype,j_=B_.hasOwnProperty;function H_(t){var e=this.__data__;return z_?e[t]!==void 0:j_.call(e,t)}var W_=H_,V_=gp,U_="__lodash_hash_undefined__";function K_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=V_&&e===void 0?U_:e,this}var X_=K_,G_=O_,q_=I_,Y_=$_,Q_=W_,J_=X_;function Ya(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var gL=pL,mL=mp;function yL(t,e){var n=this.__data__,r=mL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var vL=yL,wL=tL,xL=uL,bL=dL,kL=gL,SL=vL;function Qa(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=_3}var Hv=L3,F3=pp;function $3(t){if(typeof t=="string"||F3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var wp=$3,z3=RT,B3=Bv,j3=hs,H3=jv,W3=Hv,V3=wp;function U3(t,e,n){e=z3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new Ss(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=J3([...this.items,n]);return new Ss(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&eOx??(Ox=new Ss([]))),bt(Ss,"fromSingleSelection",e=>Ss.empty().add(e));let Nt=Ss;function Z3(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var eF=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,$g=Z3(function(t){return eF.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),tF=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},Px=tF,nF=t=>t.toUpperCase()===t,rF=t=>e=>t.indexOf(e)===-1,IT=(t,e)=>{const n={};return Object.keys(t).filter(rF(e)).forEach(r=>{n[r]=t[r]}),n};function iF(t,e,n){const r=IT(e,n);if(!t){const i=typeof $g=="function"?{default:$g}:$g;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var sF=(t,e)=>{};function oF(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!nF(l[0])):n.propsAsIs,c=iF(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Px(n.class,c.className||a):Px(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const m in f){const x=f[m],g=x[0],y=x[1]||"",w=typeof g=="function"?g(s):g;sF(w,n.name),d[`--${m}`]=`${w}${y}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(m=>{d[m]=h[m]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,Ln.createElement(t,c)):Ln.createElement(l,c)},i=Ln.forwardRef?Ln.forwardRef(r):s=>{const o=IT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Qr=oF;const lF=Qr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var NT={},xp={},Vv={},zg={},Bg={exports:{}},jg,Ix;function aF(){if(Ix)return jg;Ix=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return jg=t,jg}var Hg,Nx;function uF(){if(Nx)return Hg;Nx=1;var t=aF();function e(){}function n(){}return n.resetWarningCache=e,Hg=function(){function r(o,l,a,u,c,f){if(f!==t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Hg}var Dx;function cF(){return Dx||(Dx=1,Bg.exports=uF()()),Bg.exports}var _x;function fF(){return _x||(_x=1,function(t){(function(e,n){n(t,v,cF())})(co,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(y){return y&&y.__esModule?y:{default:y}}var l=Object.assign||function(y){for(var w=1;w=0||Object.prototype.hasOwnProperty.call(y,b)&&(k[b]=y[b]);return k}function u(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")}var c=function(){function y(w,k){for(var b=0;b0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?y:y.capture}function x(y){if("touches"in y){var w=y.touches[0],k=w.pageX,b=w.pageY;return{x:k,y:b}}var S=y.screenX,T=y.screenY;return{x:S,y:T}}var g=function(y){d(w,y);function w(){var k;u(this,w);for(var b=arguments.length,S=Array(b),T=0;TS&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-S?this.props.onSwipeUp(1,b):this.movePosition.deltaY>S&&this.props.onSwipeDown(1,b)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(b){this.swiper=b,this.props.innerRef(b)}},{key:"render",value:function(){var b=this.props;b.tagName;var S=b.className,T=b.style,A=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var M=a(b,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:S,style:T},M),A)}}]),w}(n.Component);g.displayName="ReactSwipe",g.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},g.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=g})}(zg)),zg}(function(t){(function(e,n){n(t,fF())})(co,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Vv);var Gc={},DT={exports:{}};/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function yh(t){return yh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},yh(t)}function tr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var RF=function(e){return e.hasOwnProperty("key")},Uv=function(t){TF(n,t);var e=EF(n);function n(r){var i;return kF(this,n),i=e.call(this,r),tr(cr(i),"itemsWrapperRef",void 0),tr(cr(i),"itemsListRef",void 0),tr(cr(i),"thumbsRef",void 0),tr(cr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),tr(cr(i),"setItemsListRef",function(s){i.itemsListRef=s}),tr(cr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),tr(cr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Ti.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,wF.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var d=i.itemsWrapperRef.clientWidth,h=u+100/(d/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,Lx.default)(h,"%",i.props.axis)}),!0}),tr(cr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),tr(cr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),tr(cr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return CF(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,Vf.default)().addEventListener("resize",this.updateSizes),(0,Vf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,Vf.default)().removeEventListener("resize",this.updateSizes),(0,Vf.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,is.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,is.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,is.setPosition)(0,e.axis)),r;var a=(0,is.getPosition)(i,e),u=(0,zF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=tl(tl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};rs.slideAnimationHandler=HF;var WF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=LT.Children.count(n.children),a=0,u=(0,is.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,is.getPosition)(l-1,n)-100:(0,is.getPosition)(l-1,n),f=o?e.x:e.y,d=f;u===a&&f>0&&(d=0),u===c&&f<0&&(d=0);var h=u+100/(r.itemSize/d),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&h>-100?h-=l*100:r.selectedItem===l-1&&h<-l*100&&(h+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,is.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};rs.slideSwipeAnimationHandler=WF;var VF=function(e,n){var r=(0,is.getPosition)(n.selectedItem,e),i=(0,is.setPosition)(r,e.axis);return{itemListStyle:i}};rs.slideStopSwipingHandler=VF;var UF=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=tl(tl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:tl(tl({},s),{},{opacity:1,position:"relative"}),prevStyle:tl({},s)}};rs.fadeAnimationHandler=UF;Object.defineProperty(xp,"__esModule",{value:!0});xp.default=void 0;var jt=GF(v),KF=Qc(Vv),Ts=Qc(Gc),XF=Qc(qc),Uf=Qc(Sp),Kf=Qc(Yc),ju=Ur,vh=rs;function Qc(t){return t&&t.__esModule?t:{default:t}}function FT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return FT=function(){return t},t}function GF(t){if(t&&t.__esModule)return t;if(t===null||ec(t)!=="object"&&typeof t!="function")return{default:t};var e=FT();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function ec(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ec=function(n){return typeof n}:ec=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ec(t)}function R0(){return R0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function wh(t){return wh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},wh(t)}function kt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Kv=function(t){JF(n,t);var e=ZF(n);function n(r){var i;qF(this,n),i=e.call(this,r),kt(Ct(i),"thumbsRef",void 0),kt(Ct(i),"carouselWrapperRef",void 0),kt(Ct(i),"listRef",void 0),kt(Ct(i),"itemsRef",void 0),kt(Ct(i),"timer",void 0),kt(Ct(i),"animationHandler",void 0),kt(Ct(i),"setThumbsRef",function(o){i.thumbsRef=o}),kt(Ct(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),kt(Ct(i),"setListRef",function(o){i.listRef=o}),kt(Ct(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),kt(Ct(i),"autoPlay",function(){jt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),kt(Ct(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),kt(Ct(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),kt(Ct(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),kt(Ct(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),kt(Ct(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Uf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Uf.default)().activeElement)):!1}),kt(Ct(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),kt(Ct(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),kt(Ct(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),kt(Ct(i),"handleClickItem",function(o,l){if(jt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),kt(Ct(i),"handleOnChange",function(o,l){jt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),kt(Ct(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),kt(Ct(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),kt(Ct(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),kt(Ct(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Ct(i)));return i.setState(Ei({},a)),!!Object.keys(a).length}),kt(Ct(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),kt(Ct(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),kt(Ct(i),"moveTo",function(o){if(typeof o=="number"){var l=jt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),kt(Ct(i),"onClickNext",function(){i.increment(1)}),kt(Ct(i),"onClickPrev",function(){i.decrement(1)}),kt(Ct(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"changeItem",function(o){return function(l){(!(0,ju.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),kt(Ct(i),"selectItem",function(o){i.setState(Ei({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,jt.Children.toArray(i.props.children)[o.selectedItem])}),kt(Ct(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),kt(Ct(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function h(){i.forceUpdate(),u.removeEventListener("load",h)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],d=f.clientHeight;return d>0?d:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&vh.fadeAnimationHandler||vh.slideAnimationHandler,i.state=Ei(Ei({},s),i.animationHandler(r,s)),i}return QF(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(Ei({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&jt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,Kf.default)().addEventListener("resize",this.updateSizes),(0,Kf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Uf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Kf.default)().removeEventListener("resize",this.updateSizes),(0,Kf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Uf.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?jt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=Ei(Ei({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=Ei(Ei({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:Ts.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return jt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?jt.default.createElement("ul",{className:"control-dots"},jt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?jt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,jt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||jt.Children.count(this.props.children)===0?null:jt.default.createElement(XF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||jt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&jt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&jt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function g(){var S=Wg();if(x(S))return y(S);l=setTimeout(g,m(S))}function y(S){return l=void 0,d&&r?h(S):(r=i=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:y(Wg())}function b(){var S=Wg(),T=x(S);if(r=arguments,i=this,a=S,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(g,e),h(a)}return l===void 0&&(l=setTimeout(g,e)),o}return b.cancel=w,b.flush=k,b}var $T=C4;const zT=Bi($T);function Vn(t,e,n,r,i=!1){const s=v.useRef();s.current=e,v.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function Ul(t,e){return t===void 0?void 0:e}const T4=Math.PI;function Hx(t){return t*T4/180}const BT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),jT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},HT=(t,e,n)=>Math.min(t,e-n*2),WT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,Gv=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),v.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},E4=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function A4(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(zT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const M4="֑-߿יִ-﷽ﹰ-ﻼ",R4="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",O4=new RegExp("^[^"+R4+"]*["+M4+"]");function qv(t){return O4.test(t)?"rtl":"not-rtl"}let Xf;function P0(){if(typeof document>"u")return 0;if(Xf!==void 0)return Xf;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),Xf=n-r,Xf}const Xo=Symbol();function P4(t){const e=v.useRef([Xo,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=v.useState(t),[,i]=v.useState(),s=v.useCallback(l=>{const a=e.current[0];a!==Xo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Xo&&i({}),r(u=>typeof l=="function"?l(a===Xo?u:a):l),e.current[0]=Xo)},[]),o=v.useCallback(()=>{e.current[0]=Xo,i({})},[]);return[e.current[0]===Xo?n:e.current[0],s,o]}function VT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function I4(t){const e=v.useRef(t);return _a(t,e.current)||(e.current=t),e.current}const N4=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return v.createElement(lF,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(NT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??v.createElement("img",{draggable:!1,src:l});return v.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&v.createElement("button",{className:"gdg-edit-icon",onClick:r},v.createElement(Gv,null)))};function UT(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Ml=UT();function D4(t){Ml=t}const KT=/[&<>"']/,_4=new RegExp(KT.source,"g"),XT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,L4=new RegExp(XT.source,"g"),F4={"&":"&","<":"<",">":">",'"':""","'":"'"},Wx=t=>F4[t];function nr(t,e){if(e){if(KT.test(t))return t.replace(_4,Wx)}else if(XT.test(t))return t.replace(L4,Wx);return t}const $4=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function GT(t){return t.replace($4,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const z4=/(^|[^\[])\^/g;function Yt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(z4,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const B4=/[^\w:]/g,j4=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Vx(t,e,n){if(t){let r;try{r=decodeURIComponent(GT(n)).replace(B4,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!j4.test(n)&&(n=U4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gf={},H4=/^[^:]+:\/*[^/]*$/,W4=/^([^:]+:)[\s\S]*$/,V4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function U4(t,e){Gf[" "+t]||(H4.test(t)?Gf[" "+t]=t+"/":Gf[" "+t]=Nd(t,"/",!0)),t=Gf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(W4,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(V4,"$1")+e:t+e}const xh={exec:function(){}};function Ux(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function Xx(t,e,n,r){const i=e.href,s=e.title?nr(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:nr(o)}}function G4(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` -`).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` -`)}class Yv{constructor(e){this.options=e||Ml}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Nd(r,` -`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=G4(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Nd(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,d,h,p,m=n[1].trim();const x=m.length>1,g={type:"list",raw:"",ordered:x,start:x?+m.slice(0,-1):"",loose:!1,items:[]};m=x?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=x?m:"[*+-]");const y=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=y.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` -`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` -`,1)[0],this.options.pedantic?(o=2,h=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,h=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` -`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),S=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(d=e.split(` -`,1)[0],f=d,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(S.test(f)||T.test(f)||k.test(f)||b.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` -`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||S.test(c)||T.test(c)||b.test(c))break;h+=` -`+f}!a&&!f.trim()&&(a=!0),r+=d+` -`,e=e.substring(d.length+1),c=f.slice(o)}}g.loose||(u?g.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=h.trimRight(),g.raw=g.raw.trimRight();const w=g.items.length;for(l=0;lS.type==="space"),b=k.length>0&&k.some(S=>/\n.*\n/.test(S.raw));g.loose=b}if(g.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Ux(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` -`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):nr(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Nd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=K4(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),Xx(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return Xx(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const d=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}const h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=nr(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=nr(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=nr(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=nr(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=nr(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):nr(r[0]):r[0]:i=nr(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Ye={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:xh,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ye._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ye._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ye.def=Yt(Ye.def).replace("label",Ye._label).replace("title",Ye._title).getRegex();Ye.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ye.listItemStart=Yt(/^( *)(bull) */).replace("bull",Ye.bullet).getRegex();Ye.list=Yt(Ye.list).replace(/bull/g,Ye.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ye.def.source+")").getRegex();Ye._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ye._comment=/|$)/;Ye.html=Yt(Ye.html,"i").replace("comment",Ye._comment).replace("tag",Ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ye.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.blockquote=Yt(Ye.blockquote).replace("paragraph",Ye.paragraph).getRegex();Ye.normal={...Ye};Ye.gfm={...Ye.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ye.gfm.table=Yt(Ye.gfm.table).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.gfm.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ye.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.pedantic={...Ye.normal,html:Yt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ye._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Yt(Ye.normal._paragraph).replace("hr",Ye.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Ie={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:xh,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:xh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Ie.punctuation=Yt(Ie.punctuation).replace(/punctuation/g,Ie._punctuation).getRegex();Ie.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Ie.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Ie._comment=Yt(Ye._comment).replace("(?:-->|$)","-->").getRegex();Ie.emStrong.lDelim=Yt(Ie.emStrong.lDelim).replace(/punct/g,Ie._punctuation).getRegex();Ie.emStrong.rDelimAst=Yt(Ie.emStrong.rDelimAst,"g").replace(/punct/g,Ie._punctuation).getRegex();Ie.emStrong.rDelimUnd=Yt(Ie.emStrong.rDelimUnd,"g").replace(/punct/g,Ie._punctuation).getRegex();Ie._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Ie._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Ie._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;Ie.autolink=Yt(Ie.autolink).replace("scheme",Ie._scheme).replace("email",Ie._email).getRegex();Ie._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Ie.tag=Yt(Ie.tag).replace("comment",Ie._comment).replace("attribute",Ie._attribute).getRegex();Ie._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Ie._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Ie._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Ie.link=Yt(Ie.link).replace("label",Ie._label).replace("href",Ie._href).replace("title",Ie._title).getRegex();Ie.reflink=Yt(Ie.reflink).replace("label",Ie._label).replace("ref",Ye._label).getRegex();Ie.nolink=Yt(Ie.nolink).replace("ref",Ye._label).getRegex();Ie.reflinkSearch=Yt(Ie.reflinkSearch,"g").replace("reflink",Ie.reflink).replace("nolink",Ie.nolink).getRegex();Ie.normal={...Ie};Ie.pedantic={...Ie.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Yt(/^!?\[(label)\]\((.*?)\)/).replace("label",Ie._label).getRegex(),reflink:Yt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ie._label).getRegex()};Ie.gfm={...Ie.normal,escape:Yt(Ie.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class Mo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ml,this.options.tokenizer=this.options.tokenizer||new Yv,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ye.normal,inline:Ie.normal};this.options.pedantic?(n.block=Ye.pedantic,n.inline=Ie.pedantic):this.options.gfm&&(n.block=Ye.gfm,this.options.breaks?n.inline=Ie.breaks:n.inline=Ie.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ye,inline:Ie}}static lex(e,n){return new Mo(n).lex(e)}static lexInline(e,n){return new Mo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` -`),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` -`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Kx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Kx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Gx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Gx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,q4)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class Qv{constructor(e){this.options=e||Ml}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` -`,i?'
'+(r?e:nr(e,!0))+`
-`:"
"+(r?e:nr(e,!0))+`
-`}blockquote(e){return`
-${e}
-`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} -`}return`${e} -`}hr(){return this.options.xhtml?`
-`:`
-`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> -`+e+" -`}listitem(e){return`
  • ${e}
  • -`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    -`}table(e,n){return n&&(n=`${n}`),` - -`+e+` -`+n+`
    -`}tablerow(e){return` -${e} -`}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,n,r){if(e=Vx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='",i}image(e,n,r){if(e=Vx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class qT{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class YT{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let Jc=class I0{constructor(e){this.options=e||Ml,this.options.renderer=this.options.renderer||new Qv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new qT,this.slugger=new YT}static parse(e,n){return new I0(n).parse(e)}static parseInline(e,n){return new I0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S;const T=e.length;for(i=0;i0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=b+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=b+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:b}):g+=b),g+=this.parse(y.tokens,x),d+=this.renderer.listitem(g,k,w);r+=this.renderer.list(d,p,m);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(d=h.tokens?this.parseInline(h.tokens):h.text;i+1{if(r.message+=` -Please report this to https://github.com/markedjs/marked.`,t){const i="

    An error occurred:

    "+nr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function QT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=Y4(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(X4(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&et.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;et.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(et.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&et.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function et(t,e,n){return QT(Mo.lex,Jc.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},D4(et.defaults),et};et.getDefaults=UT;et.defaults=Ml;et.use=function(...t){const e=et.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=et.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=et.defaults.renderer||new Qv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=et.defaults.tokenizer||new Yv;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=et.defaults.hooks||new bh;for(const s in n.hooks){const o=i[s];bh.passThroughHooks.has(s)?i[s]=l=>{if(et.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=et.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}et.setOptions(r)})};et.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(et,r)),r.type){case"table":{for(const i of r.header)n=n.concat(et.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(et.walkTokens(s.tokens,e));break}case"list":{n=n.concat(et.walkTokens(r.items,e));break}default:et.defaults.extensions&&et.defaults.extensions.childTokens&&et.defaults.extensions.childTokens[r.type]?et.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(et.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(et.walkTokens(r.tokens,e)))}return n};et.parseInline=QT(Mo.lexInline,Jc.parseInline);et.Parser=Jc;et.parser=Jc.parse;et.Renderer=Qv;et.TextRenderer=qT;et.Lexer=Mo;et.lexer=Mo.lex;et.Tokenizer=Yv;et.Slugger=YT;et.Hooks=bh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;Jc.parse;Mo.lex;const Q4=Qr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class J4 extends Ln.PureComponent{constructor(){super(...arguments);bt(this,"targetElement",null);bt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Ln.createElement(Q4,{ref:this.containerRefHook})}}const Z4=Qr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),e$=Qr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),t$=Qr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let qx=0;const Cp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=v.useRef(null),f=n??"";Wr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=v.useState(()=>"input-box-"+(qx=(qx+1)%1e7));v.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),v.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const h=v.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return v.createElement(t$,{className:"gdg-growing-entry"},v.createElement(e$,{className:u},f+` -`),v.createElement(Z4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Vg={};let Qs=null;function n$(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function N0(t){const e=t.toLowerCase().trim();if(Vg[e]!==void 0)return Vg[e];Qs=Qs||n$(),Qs.style.color="#000",Qs.style.color=e;const n=getComputedStyle(Qs).color;Qs.style.color="#fff",Qs.style.color=e;const r=getComputedStyle(Qs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Vg[e]=i,i}function wl(t,e){const[n,r,i]=N0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Yx=new Map;function Qx(t,e){const n=`${t}-${e}`,r=Yx.get(n);if(r!==void 0)return r;const i=Vr(t,e);return Yx.set(n,i),i}function Vr(t,e){if(e===void 0)return t;const[n,r,i,s]=N0(t);if(s===1)return t;const[o,l,a,u]=N0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var Yl=new Map,fa=new Map,D0=new Map;function r$(){Yl.clear(),D0.clear(),fa.clear()}function i$(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,m=c*p*r/d,x=h+m;n.set(f,x)}}function s$(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function tc(t,e,n,r){var i,s;let o=fa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=D0.get(n);if(u===void 0&&(u=s$(t,o.size),D0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return i$(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),fa.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)fa.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;fa.set(n,{count:o.count+e.length,size:f})}return l.width}function o$(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=tc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function l$(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Yl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` -`),c=fa.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let x=o$(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),Yl.set(o,a),Yl.size>500&&Yl.delete(Yl.keys().next().value),a}function a$(t,e){return Ln.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function JT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function f$(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&Jx(t,e,s)&&i++;for(const o of n.current.rangeStack)Jx(t,e,o)&&i++;return i}function eE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function La(t,e){let n=0;const r=eE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let m=l;m"u";async function g$(){var t;p$||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Dd=0,rc={},r$())}g$();function tE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function Zc(t,e,n,r="middle"){const i=tE(t,e,r,n);let s=rc[i];return s===void 0&&(s=e.measureText(t),rc[i]=s,Dd++),Dd>1e4&&(rc={},Dd=0),s}function m$(t,e){const n=tE(t,void 0,"middle",e);return rc[n]}function Bs(t,e){return typeof e!="string"&&(e=e.baseFontFull),y$(t,e)}function Zx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const eb=[];function y$(t,e){for(const s of eb)if(s.key===e)return s.val;const n=Zx(t,"alphabetic"),i=-(Zx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return eb.push({key:e,val:i}),i}function v$(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function x$(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=l$(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=rE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let g=Math.max(r+l.cellVerticalPadding,x);for(const y of f)if(nE(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function As(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=w$(e,c));const d=Bs(s,l),h=qv(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?x$(s,e,a,u,c,f,d,l,n,i):nE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function cs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function b$(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function k$(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),m=1,x=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const g=p/2;let y=Math.abs(Math.cos(g)*i/Math.sin(g)),w;y>Math.min(c.len/2,f.len/2)?(y=Math.min(c.len/2,f.len/2),w=Math.abs(y*Math.sin(g)/Math.cos(g))):w=i;let k=a.x+f.nx*y,b=a.y+f.ny*y;k+=-f.ny*w*m,b+=f.nx*w*m,t.arc(k,b,w,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function L0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const m={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const g=o>t?-1:1,y=La(h);m.x+=y+a;for(let w=o;w!==t;w+=g)m.x+=h[g===1?w:w-1].width*g}else for(let g=0;g0&&Oc(h[g-1].group,y)&&h[g-1].sticky===w;){const b=h[g-1];m.x-=b.width,m.width+=b.width,g--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-d){let g=c-e;for(m.y=r;g>0;){const y=e+g-1;m.height=typeof p=="number"?p:p(y),m.y-=m.height,g--}m.height+=1}else{const g=l>e?-1:1;if(typeof p=="number"){const y=e-l;m.y+=y*p}else for(let y=l;y!==e;y+=g)m.y+=p(y)*g;m.height=(typeof p=="number"?p:p(e))+1}return m}const Jv=1<<21;function Pi(t,e){return(e+2)*Jv+t}function iE(t){return t%Jv}function Zv(t){return Math.floor(t/Jv)-2}function ew(t){const e=iE(t),n=Zv(t);return[e,n]}class sE{constructor(){bt(this,"visibleWindow",{x:0,y:0,width:0,height:0});bt(this,"freezeCols",0);bt(this,"freezeRows",[]);bt(this,"isInWindow",e=>{const n=iE(e),r=Zv(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&_a(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class S$ extends sE{constructor(){super(...arguments);bt(this,"cache",new Map);bt(this,"setValue",(n,r)=>{this.cache.set(Pi(n[0],n[1]),r)});bt(this,"getValue",n=>this.cache.get(Pi(n[0],n[1])));bt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class ic{constructor(e=[]){bt(this,"cells");this.cells=new Set(e.map(n=>Pi(n[0],n[1])))}add(e){this.cells.add(Pi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Pi(e[0],e[1]))}remove(e){this.cells.delete(Pi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(Zv(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=E$(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function A$(t,e,n,r,i,s,o,l,a){const u=v.useRef(e),c=v.useRef(n),f=v.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=v.useMemo(()=>{if(typeof window>"u")return[null,null];const y=document.createElement("canvas");return y.style.display="none",y.style.opacity="0",y.style.position="fixed",[y,y.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=v.useRef({}),m=v.useRef(),[x,g]=v.useState();return v.useLayoutEffect(()=>{const y=c.current;if(y===void 0||t.every(Wf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,w)},S={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=y(b,a.signal),M=k>0?y(S,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Rx(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Rx(M)]),m.current=t,g(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Wf)?t:h===null?t.map(T=>Wf(T)?T:{...T,width:F0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Wf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:F0};const M=aE(h,o,T,A,x,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,b=0;const S=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(b+=A.grow,S.push(T));if(k0){const T=[...w],A=r-k;let M=A;for(let O=0;O0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=R$(a),a in tb)return;tb[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":M$,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function O$(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var P$=O$,I$=P$,Ug=Xv;function N$(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Ug(n),n=n===n?n:0),e!==void 0&&(e=Ug(e),e=e===e?e:0),I$(Ug(t),e,n)}var D$=N$;const Oi=Bi(D$);var _$="__lodash_hash_undefined__";function L$(t){return this.__data__.set(t,_$),this}var F$=L$;function $$(t){return this.__data__.has(t)}var z$=$$,B$=$v,j$=F$,H$=z$;function kh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new B$;++e-1}var nz=tz;function rz(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=Sz){var u=e?null:bz(t);if(u)return kz(u);o=!1,i=xz,a=new yz}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?pE(l,e-1,n,r,i):_z(i,l):r||(i[i.length]=l)}return i}var Fz=pE,$z=Fz;function zz(t){var e=t==null?0:t.length;return e?$z(t,1):[]}var Bz=zz;const ib=Bi(Bz);var jz=Math.ceil,Hz=Math.max;function Wz(t,e,n,r){for(var i=-1,s=Hz(jz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var Vz=Wz,Uz=TT,Kz=Hv;function Xz(t){return t!=null&&Kz(t.length)&&!Uz(t)}var nw=Xz,Gz=Lv,qz=nw,Yz=jv,Qz=El;function Jz(t,e,n){if(!Qz(n))return!1;var r=typeof e;return(r=="number"?qz(n)&&Yz(e,n.length):r=="string"&&e in n)?Gz(n[e],t):!1}var Zz=Jz,eB=Xv,sb=1/0,tB=17976931348623157e292;function nB(t){if(!t)return t===0?t:0;if(t=eB(t),t===sb||t===-sb){var e=t<0?-1:1;return e*tB}return t===t?t:0}var rB=nB,iB=Vz,sB=Zz,Xg=rB;function oB(t){return function(e,n,r){return r&&typeof r!="number"&&sB(e,n,r)&&(n=r=void 0),e=Xg(e),n===void 0?(n=e,e=0):n=Xg(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function gE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Tp(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=h;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=h;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function hB(t,e,n,r){if(r==="any")return vE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),JT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Sh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Ep(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function vE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function pB(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function gB(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:m-p}}function mB(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:m,height:x}=t,g=[];if(m<=0||x<=0)return g;const y=h+m,w=p+x,k=hl,T=p+x>a,A=h>=s&&hs&&y<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const _=Math.max(h,s),P=Math.max(p,o),I=Math.min(y,l),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&b){const _=h,P=p,I=Math.min(y,s),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&A){const _=Math.max(h,s),P=p,I=Math.min(y,l),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&S){const _=Math.max(h,l),P=p,I=y,D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const _=h,P=Math.max(p,o),I=Math.min(y,s),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(S&&M){const _=Math.max(h,l),P=Math.max(p,o),I=y,D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const _=h,P=Math.max(p,a),I=Math.min(y,s),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const _=Math.max(h,s),P=Math.max(p,a),I=Math.min(y,l),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(S&&T){const _=Math.max(h,l),P=Math.max(p,a),I=y,D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return g}const yB={kind:ke.Loading,allowOverlay:!1};function ob(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A,M,O,_,P,I,D,Z,ne,oe,W){let U=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},H=[0,0],q=x>0?Rl(a,x,u):0;let B,V;const le=gE(y);return Lo(e,l,s,o,i,(ge,Me,Fe,_e,ft)=>{const Xe=Math.max(0,_e-Me),Ge=Me+Xe,lt=i+1,Ut=ge.width-Xe,Re=r-i-1;if(y.length>0){let wt=!1;for(let rt=0;rt{t.save(),t.beginPath(),t.rect(Ge,lt,Ut,Re),t.clip()},Qe=k.columns.hasIndex(ge.sourceIndex),nt=f(ge.group??"").overrideTheme,it=ge.themeOverride===void 0&&nt===void 0?I:To(I,nt,ge.themeOverride),$e=it.baseFontFull;$e!==N&&(N=$e,t.font=$e),we();let At;return Tp(ft,Fe,r,a,u,x,g,le,(wt,rt,me,Ne,Je)=>{var De,ze,An;if(rt<0||(H[0]=ge.sourceIndex,H[1]=rt,w!==void 0&&!w.has(H)))return;if(y.length>0){let z=!1;for(let ue=0;uedt.span!==void 0&&z>=dt.span[0]&&z<=dt.span[1]);vn&&!p&&m?In=0:vn&&m&&(In=Math.max(In,1)),Pr&&In++,vn||(tt&&In++,Qe&&!Je&&In++);const Ir=dt.kind===ke.Protected?Pt.bgCellMedium:Pt.bgCell;let Bt;if((Ne||Ir!==I.bgCell)&&(Bt=Vr(Ir,Bt)),In>0||Kt){Kt&&(Bt=Vr(Pt.bgHeader,Bt));for(let z=0;zW&&!Rt){const z=Pt.baseFontFull;z!==N&&(t.font=z,N=z),At=wE(t,dt,ge.sourceIndex,rt,xt,dn,ht,wt,pt,me,In>0,Pt,Bt??Pt.bgCell,T,A,(re==null?void 0:re.hoverAmount)??0,O,P,R,_,At,D,Z,ne,oe)}return ut&&t.restore(),dt.style==="faded"&&(t.globalAlpha=1),U--,Lt&&(t.restore(),(An=At==null?void 0:At.deprep)==null||An.call(At,L),At=void 0,we(),N=$e,t.font=$e),U<=0}),t.restore(),U<=0}),B}const Au=[0,0],Mu={x:0,y:0,width:0,height:0},Gg=[void 0,()=>{}];let $0=!1;function vB(){$0=!0}function wE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A){var Z,ne;let M,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(M=x[1][0],O=x[1][1]);let _;Au[0]=n,Au[1]=r,Mu.x=o,Mu.y=l,Mu.width=a,Mu.height=u,Gg[0]=S.getValue(Au),Gg[1]=oe=>S.setValue(Au,oe),$0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Mu,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:M,drawState:Gg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:vB},I=v$(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((Z=k==null?void 0:k.deprep)==null||Z.call(k,P),k=void 0);const oe=(ne=D.drawPrep)==null?void 0:ne.call(D,P,k);w!==void 0&&!ca(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=oe===void 0?void 0:{deprep:oe==null?void 0:oe.deprep,fillStyle:oe==null?void 0:oe.fillStyle,font:oe==null?void 0:oe.font,renderer:D}}return(I||$0)&&(b==null||b(Au)),_}function rw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let m=HT(c,o,e.cellVerticalPadding),x=m/2;const g=jT(f,r,s,e.cellHorizontalPadding,m),y=BT(g,h,m),w=WT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),cs(t,g-m/2,h-m/2,m,m,p),d==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(g-x+m/4.23,h-x+m/1.97),t.lineTo(g-x+m/2.42,h-x+m/1.44),t.lineTo(g-x+m/1.29,h-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case gh:case!1:{t.beginPath(),cs(t,g-m/2+.5,h-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case Wv:{t.beginPath(),cs(t,g-m/2,h-m/2,m,m,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(g-m/3,h),t.lineTo(g+m/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Rc()}}function wB(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,b]=(r==null?void 0:r[0])??[],S=f.headerFontFull;t.font=S,Lo(e,0,s,0,w,(T,A,M,O)=>{var L;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,O-A);t.save(),t.beginPath(),t.rect(A+_,l,T.width-_,o),t.clip();const P=m(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:To(f,P,T.themeOverride);I.bgHeader!==f.bgHeader&&(t.fillStyle=I.bgHeader,t.fill()),I!==f&&(t.font=I.baseFontFull);const D=c.columns.hasIndex(T.sourceIndex),Z=a!==void 0||u,ne=!Z&&b===-1&&k===T.sourceIndex,oe=Z?0:((L=h.find(H=>H.item[0]===T.sourceIndex&&H.item[1]===-1))==null?void 0:L.hoverAmount)??0,W=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,U=D?I.accentColor:W?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=U,t.fillRect(A+N,R,T.width-N,o)):(W||oe>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),W&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),oe>0&&(t.globalAlpha=oe,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),kE(t,A,R,T.width,o,T,D,I,ne,W,oe,d,g,y),t.restore()}),n&&xB(t,e,i,s,l,r,f,d,h,p,m,x)}function xB(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;mE(e,n,r,i,(x,g,y,w,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(y,w,k,b),t.clip();const S=c(g),T=(S==null?void 0:S.overrideTheme)===void 0?o:To(o,S.overrideTheme),A=p===-2&&h!==void 0&&h>=x[0]&&h<=x[1],M=A?T.bgHeaderHovered:T.bgHeader;if(M!==o.bgHeader&&(t.fillStyle=M,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,S!==void 0){let O=y;if(S.icon!==void 0&&(l.drawSprite(S.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(S.name,O+8,i/2+Bs(t,o.headerFontFull)),S.actions!==void 0&&A){const _=bE({x:y,y:w,width:k,height:b},S.actions);t.beginPath();const P=_[0].x-10,I=y+k-P;t.rect(P,0,I,i);const D=t.createLinearGradient(P,0,P+I,0),Z=wl(M,0);D.addColorStop(0,Z),D.addColorStop(10/I,M),D.addColorStop(1,M),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[ne,oe]=(s==null?void 0:s[1])??[-1,-1];for(let W=0;W35){const k=d?35:r-35,b=d?35*.7:r-35*.7,S=k/r,T=b/r,A=t.createLinearGradient(e,0,e+r,0),M=wl(m,0);A.addColorStop(d?1:0,m),A.addColorStop(S,m),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=m;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+Bs(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===mh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;k$(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===mh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;b$(t,w,k),t.fillStyle=m,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function kE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=qv(s.title)==="rtl",m=xE(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>lb(t,e,n,r,i,s,o,l,a,c,f,h,p,m)):lb(t,e,n,r,i,s,o,l,a,c,f,h,p,m)}var bB=Al,kB=function(){try{var t=bB(Object,"defineProperty");return t({},"",{}),t}catch{}}(),SB=kB,ab=SB;function CB(t,e,n){e=="__proto__"&&ab?ab(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var TB=CB;function EB(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Nj?new Rj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const M=Math.max(b,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Tp(A,S,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(W=>Sh(b,O,1e4,P,W.x,W.y,W.width,W.height)))return;const D=d.hasIndex(_),Z=h.hasIndex(_);t.beginPath();const ne=f==null?void 0:f(_),oe=ne===void 0?y:To(y,ne);oe.bgCell!==y.bgCell&&(t.fillStyle=oe.bgCell,t.fillRect(b,O,1e4,P)),Z&&(t.fillStyle=oe.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=oe.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function CW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?La(e):0;let h;if(d!==0&&(h=Qx(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:Qx(c,a.bgCell),m=Rl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const NE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function TW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var P;const m=p.bgCell,{minX:x,maxX:g,minY:y,maxY:w}=NE(l,s,o),k=[],b=o-Rl(h,d,u);let S=a,T=n,A=0;for(;S+i=y&&I<=w-1){const Z=c==null?void 0:c(T),ne=Z==null?void 0:Z.bgCell;ne!==void 0&&ne!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:ne})}S+=D,T0)for(let I=0;I=x&&Z<=g&&f(I+1)&&k.push({x:Z,y:A,w:D.width,h:O,color:ne}),M+=D.width}if(k.length===0)return;let _;t.beginPath();for(let I=k.length-1;I>=0;I--){const D=k[I];_===void 0?_=D.color:D.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=D.color),t.rect(D.x,D.y,D.w,D.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function Mb(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const P of a)t.rect(P.x+1,P.y+1,P.width-1,P.height-1);t.clip("evenodd")}const y=x.horizontalBorderColor??x.borderColor,w=x.borderColor,{minX:k,maxX:b,minY:S,maxY:T}=NE(l,s,o),A=[];t.beginPath();let M=.5;for(let P=0;P=k&&D<=b&&h(P+1)&&A.push({x1:D,y1:Math.max(u,S),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=S&&Z<=T-1){const ne=d==null?void 0:d(I);A.push({x1:k,y1:Z,x2:b,y2:Z,color:(ne==null?void 0:ne.horizontalBorderColor)??(ne==null?void 0:ne.borderColor)??y})}P+=f(I),I++}}const _=kW(A,P=>P.color);for(const P of Object.keys(_)){t.strokeStyle=P;for(const I of _[P])t.moveTo(I.x1,I.y1),t.lineTo(I.x2,I.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function EW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let S=0;if(typeof g=="number")S+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(S=-S),S+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let M=0;for(let D=T;Di.cellXOffset&&(M=-M),M+=l-i.translateX;const O=La(x);if(M!==0&&S!==0)return{regions:[]};const _=u>0?Rl(d,u,g):0,P=c-O-Math.abs(M),I=f-h-_-Math.abs(S)-1;if(P>150&&I>150){const D={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(S>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(S+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:S+1})):S<0&&(D.sy=(-S+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+S-_,width:c,height:-S+_})),M>0?(D.sx=O*p,D.sw=P*p,D.dx=(M+O)*p,D.dw=P*p,w.push({x:O-1,y:0,width:M+2,height:f})):M<0&&(D.sx=(O-M)*p,D.sw=P*p,D.dx=O*p,D.dw=P*p,w.push({x:c+M,y:0,width:-M,height:f})),t.setTransform(1,0,0,1,0,0),y){if(O>0&&M!==0&&S===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Z=O*p,ne=f*p;t.drawImage(e,0,0,Z,ne,0,0,Z,ne)}if(_>0&&M===0&&S!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Z=(f-_)*p,ne=c*p,oe=_*p;t.drawImage(e,0,Z,ne,oe,0,Z,ne,oe)}}t.drawImage(e,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function AW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Lo(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const m=Math.max(d,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function MW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const g=La(l),y=Rl(h,d,f),w=[a,0,l.length,h-d],k=[g,0,e,n-y],b=x.map(T=>{const A=T.range,M=T.style??"dashed";return mB(A,w,e,n,k).map(O=>{const _=O.rect,P=L0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:L0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return _.x+_.width>=l.length&&(I.width-=1),_.y+_.height>=h&&(I.height-=1),{color:T.color,style:M,clip:O.clip,rect:gB({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),S=()=>{t.lineWidth=1;let T=!1;for(const A of b)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Sh(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,_=!pB(M.clip,M.rect);_&&(t.save(),t.rect(M.clip.x,M.clip.y,M.clip.width,M.clip.height),t.clip()),M.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(M.style==="solid"||M.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=M.style==="solid-outline"?Vr(Vr(M.color,m.borderColor),m.bgCell):wl(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),_&&(t.restore(),T=O)}T&&t.setLineDash([])};return S(),S}function Ob(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function Qg(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x){if(c.current===void 0)return;const g=c.current.range,y=c.current.cell,w=[g.x+g.width-1,g.y+g.height-1];if(y[1]>=x&&w[1]>=x||!o.some(D=>D.sourceIndex===y[0]||D.sourceIndex===w[0]))return;const[b,S]=c.current.cell,T=d(c.current.cell),A=T.span??[b,b],M=S>=x-h,O=h>0&&!M?Rl(x,h,f)-1:0,_=w[1];let P;if(Lo(o,r,i,s,u,(D,Z,ne,oe,W)=>{if(D.sticky&&b>D.sourceIndex)return;const U=D.sourceIndexA[1],N=D.sourceIndex===w[0];if(!(!N&&(U||R)))return Tp(W,ne,n,x,f,h,p,void 0,(L,H,q)=>{if(H!==S&&H!==_)return;let B=Z,V=D.width;if(T.span!==void 0){const ge=yE(T.span,Z,L,D.width,q,D,l),Me=D.sticky?ge[0]:ge[1];Me!==void 0&&(B=Me.x,V=Me.width)}return H===_&&N&&m&&(P=()=>{var ge;oe>B&&!D.sticky&&(t.beginPath(),t.rect(oe,0,e-oe,n),t.clip()),t.beginPath(),t.rect(B+V-4,L+q-4,4,4),t.fillStyle=((ge=D.themeOverride)==null?void 0:ge.accentColor)??a.accentColor,t.fill()}),P!==void 0}),P!==void 0}),P===void 0)return;const I=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-O),t.clip(),P==null||P(),t.restore()};return I(),I}function RW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),mE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Lo(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,m=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function OW(t,e,n,r,i,s,o,l,a,u){let c=0;return Lo(t,s,r,i,n,(f,d,h,p,m)=>(Tp(m,h,e,o,l,a,u,void 0,(x,g,y,w)=>{w||(c=Math.max(g,c))}),!0)),c}function Pb(t,e){var ut;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:g,disabledRows:y,rowHeight:w,verticalBorder:k,overrideCursor:b,isResizing:S,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:Z,prelightCells:ne,drawCellCallback:oe,highlightRegions:W,resizeCol:U,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:H,hoverInfo:q,spriteManager:B,maxScaleFactor:V,hasAppendRow:le,touchMode:ge,enqueue:Me,renderStateProvider:Fe,getCellRenderer:_e,renderStrategy:ft,bufferACtx:Xe,bufferBCtx:Ge,damage:lt,minimumCellWidth:Ut}=t;if(i===0||s===0)return;const Re=ft==="double-buffer",we=Math.min(V,Math.ceil(window.devicePixelRatio??1)),Qe=ft!=="direct"&&MW(t,e),nt=n.canvas;(nt.width!==i*we||nt.height!==s*we)&&(nt.width=i*we,nt.height=s*we,nt.style.width=i+"px",nt.style.height=s+"px");const it=r.canvas,$e=f?g+x:x,At=$e+1;(it.width!==i*we||it.height!==At*we)&&(it.width=i*we,it.height=At*we,it.style.width=i+"px",it.style.height=At+"px");const wt=Xe.canvas,rt=Ge.canvas;Re&&(wt.width!==i*we||wt.height!==s*we)&&(wt.width=i*we,wt.height=s*we,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Re&&(rt.width!==i*we||rt.height!==s*we)&&(rt.width=i*we,rt.height=s*we,N.current!==void 0&&(N.current.bBufferScroll=void 0));const me=N.current;if(Qe===!0&&o===(me==null?void 0:me.cellXOffset)&&l===(me==null?void 0:me.cellYOffset)&&a===(me==null?void 0:me.translateX)&&u===(me==null?void 0:me.translateY))return;let Ne=null;Re&&(Ne=n);const Je=r;let tt;Re?lt!==void 0?tt=(me==null?void 0:me.lastBuffer)==="b"?Ge:Xe:tt=(me==null?void 0:me.lastBuffer)==="b"?Xe:Ge:tt=n;const Kt=tt.canvas,dt=Re?Kt===wt?rt:wt:nt,ht=typeof w=="number"?()=>w:w;Je.save(),tt.save(),Je.beginPath(),tt.beginPath(),Je.textBaseline="middle",tt.textBaseline="middle",we!==1&&(Je.scale(we,we),tt.scale(we,we));const pt=_0(c,o,i,h,a);let Lt=[];const Rt=m&&((ut=T.current)==null?void 0:ut.cell[1])===l&&u===0;let en=!1;if(W!==void 0){for(const xt of W)if(xt.style!=="no-outline"&&xt.range.y===l&&u===0){en=!0;break}}const Hn=()=>{wB(Je,pt,f,q,i,a,x,g,h,S,T,p,B,L,k,P,lt,Z,ge),Mb(Je,pt,l,a,u,i,s,void 0,void 0,g,$e,ht,I,k,M,O,p,!0),Je.beginPath(),Je.moveTo(0,At-.5),Je.lineTo(i,At-.5),Je.strokeStyle=Vr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Je.stroke(),en&&Rb(Je,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),Rt&&Qg(Je,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O)};if(lt!==void 0){const xt=pt[pt.length-1].sourceIndex+1,dn=lt.hasItemInRegion([{x:o,y:-2,width:xt,height:2},{x:o,y:l,width:xt,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:xt,height:M,when:M>0}]),re=De=>{ob(De,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,le,Lt,lt,T,ne,W,R,B,L,q,oe,H,p,Me,Fe,_e,b,Ut);const ze=T.current;A&&m&&ze!==void 0&<.has(ZT(ze.range))&&Qg(De,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O)};dn&&(re(tt),Ne!==null&&(Ne.save(),Ne.scale(we,we),Ne.textBaseline="middle",re(Ne),Ne.restore()),lt.hasHeader()&&(RW(Je,pt,i,g,$e,a,u,l,lt),Hn())),tt.restore(),Je.restore();return}if((Qe!==!0||o!==(me==null?void 0:me.cellXOffset)||a!==(me==null?void 0:me.translateX)||Rt!==(me==null?void 0:me.mustDrawFocusOnHeader)||en!==(me==null?void 0:me.mustDrawHighlightRingsOnHeader))&&Hn(),Qe===!0){Wr(dt!==void 0&&me!==void 0);const{regions:xt}=EW(tt,dt,dt===wt?me.aBufferScroll:me.bBufferScroll,dt===wt?me.bBufferScroll:me.aBufferScroll,me,o,l,a,u,M,i,s,O,$e,we,c,pt,w,Re);Lt=xt}else Qe!==!1&&(Wr(me!==void 0),Lt=AW(me,o,l,a,u,i,s,$e,pt,Qe));CW(tt,pt,i,s,M,O,k,ht,p);const Pt=Rb(tt,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),vn=m?Qg(tt,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O):void 0;if(tt.fillStyle=p.bgCell,Lt.length>0){tt.beginPath();for(const xt of Lt)tt.rect(xt.x,xt.y,xt.width,xt.height);tt.clip(),tt.fill(),tt.beginPath()}else tt.fillRect(0,0,i,s);const In=ob(tt,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,le,Lt,lt,T,ne,W,R,B,L,q,oe,H,p,Me,Fe,_e,b,Ut);SW(tt,pt,c,i,s,$e,a,u,l,O,ht,I,T.rows,y,M,le,Lt,lt,p),TW(tt,pt,l,a,u,i,s,Lt,$e,ht,I,k,M,O,p),Mb(tt,pt,l,a,u,i,s,Lt,In,g,$e,ht,I,k,M,O,p),Pt==null||Pt(),vn==null||vn(),S&&Lo(pt,0,a,0,$e,(xt,dn)=>xt.sourceIndex===U?(Ob(Je,dn+xt.width,0,$e+1,Vr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ob(tt,dn+xt.width,$e,s,Vr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),Ne!==null&&(Ne.fillStyle=p.bgCell,Ne.fillRect(0,0,i,s),Ne.drawImage(tt.canvas,0,0));const Pr=OW(pt,s,$e,a,u,l,O,ht,M,le);R==null||R.setWindow({x:o,y:l,width:pt.length,height:Pr-l},d,Array.from({length:M},(xt,dn)=>O-1-dn));const Ir=me!==void 0&&(o!==me.cellXOffset||a!==me.translateX),Bt=me!==void 0&&(l!==me.cellYOffset||u!==me.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Rt,mustDrawHighlightRingsOnHeader:en,lastBuffer:Re?Kt===wt?"a":"b":void 0,aBufferScroll:Kt===wt?[Ir,Bt]:me==null?void 0:me.aBufferScroll,bBufferScroll:Kt===rt?[Ir,Bt]:me==null?void 0:me.bBufferScroll},tt.restore(),Je.restore()}const PW=80;function IW(t){const e=t-1;return e*e*e+1}class NW{constructor(e){bt(this,"callback");bt(this,"currentHoveredItem");bt(this,"leavingItems",[]);bt(this,"lastAnimationTime");bt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>nc(r.item,e.item))||this.leavingItems.push(e)});bt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>nc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});bt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});bt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});bt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:IW(e.hoverAmount)})));bt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/PW;for(const s of this.leavingItems)s.hoverAmount=Oi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Oi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});bt(this,"setHovered",e=>{var n;if(!nc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class DW{constructor(e){bt(this,"fn");bt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function sw(t){return new DW(t)}const _W=sw(()=>window.navigator.userAgent.includes("Firefox")),Eh=sw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Ah=sw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function LW(t){const e=v.useRef([]),n=v.useRef(0),r=v.useRef(t);r.current=t;const i=v.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(ew);e.current=[],r.current(new ic(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return v.useCallback(s=>{e.current.length===0&&i();const o=Pi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const to="header",Hr="group-header",Mh="out-of-bounds";var da;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(da||(da={}));function DE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const Ib=6,FW=(t,e)=>{if(t.kind===ke.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},$W=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:g,onCanvasFocused:y,onCanvasBlur:w,isFocused:k,selection:b,freezeColumns:S,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:Z,onItemHovered:ne,dragAndDropState:oe,firstColAccessible:W,onKeyDown:U,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:H,onDragEnd:q,eventTargetRef:B,isResizing:V,resizeColumn:le,isDragging:ge,isDraggable:Me=!1,allowResize:Fe,disabledRows:_e,hasAppendRow:ft,getGroupDetails:Xe,theme:Ge,prelightCells:lt,headerIcons:Ut,verticalBorder:Re,drawCell:we,drawHeader:Qe,onCellFocused:nt,onDragOverCell:it,onDrop:$e,onDragLeave:At,imageWindowLoader:wt,smoothScrollX:rt=!1,smoothScrollY:me=!1,experimental:Ne,getCellRenderer:Je}=t,tt=t.translateX??0,Kt=t.translateY??0,dt=Math.max(S,Math.min(s.length-1,o)),ht=v.useRef(null),pt=wt,Lt=v.useRef(),[Rt,en]=v.useState(!1),Hn=v.useRef([]),Pt=v.useRef(),[vn,In]=v.useState(),[Pr,Ir]=v.useState(),Bt=v.useRef(null),[ut,xt]=v.useState(),[dn,re]=v.useState(!1),De=v.useRef(dn);De.current=dn;const ze=v.useMemo(()=>new dB(Ut,()=>{qn.current=void 0,zo.current()}),[Ut]),An=x?c+a:a,z=v.useRef(-1),ue=((Ne==null?void 0:Ne.enableFirefoxRescaling)??!1)&&_W.value,Y=((Ne==null?void 0:Ne.enableSafariRescaling)??!1)&&Eh.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!ue&&!Y||(z.current!==-1&&en(!0),window.clearTimeout(z.current),z.current=window.setTimeout(()=>{en(!1),z.current=-1},200))},[l,dt,tt,Kt,ue,Y]);const ce=a$(s,S),fe=M?La(ce,oe):0,Le=v.useCallback((j,se,xe)=>{const ye=j.getBoundingClientRect();if(se>=ce.length||xe>=d)return;const de=ye.width/n,Ae=L0(se,xe,n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f);return de!==1&&(Ae.x*=de,Ae.y*=de,Ae.width*=de,Ae.height*=de),Ae.x+=ye.x,Ae.y+=ye.y,Ae},[n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f]),Ee=v.useCallback((j,se,xe,ye)=>{const de=j.getBoundingClientRect(),Ae=de.width/n,st=(se-de.left)/Ae,ot=(xe-de.top)/Ae,Ce=5,Ft=_0(ce,dt,n,void 0,tt);let Be=0,zt=0;ye instanceof MouseEvent&&(Be=ye.button,zt=ye.buttons);const ct=d$(st,Ft,tt),St=h$(ot,r,x,a,c,d,f,l,Kt,A),wn=(ye==null?void 0:ye.shiftKey)===!0,gt=(ye==null?void 0:ye.ctrlKey)===!0,hn=(ye==null?void 0:ye.metaKey)===!0,Zr=ye!==void 0&&!(ye instanceof MouseEvent)||(ye==null?void 0:ye.pointerType)==="touch",ln=[st<0?-1:nn||ot>r){const It=st>n?1:st<0?-1:0,xn=ot>r?1:ot<0?-1:0;let Lr=It*2,Wi=xn*2;It===0&&(Lr=ct===-1?da.EndPadding:da.Center),xn===0&&(Wi=St===void 0?da.EndPadding:da.Center);let xi=!1;if(ct===-1&&St===-1){const jo=Le(j,ce.length-1,-1);Wr(jo!==void 0),xi=sen&&str&&ot=0?(xn=!0,It=Le(j,Lr,St),Wr(It!==void 0),_r={kind:x&&St===-2?Hr:to,location:[Lr,St],bounds:It,group:ce[Lr].group??"",isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:xe-It.y,button:Be,buttons:zt,scrollEdge:ln}):_r={kind:x&&St===-2?Hr:to,group:ce[ct].group??"",location:[ct,St],bounds:It,isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:xe-It.y,button:Be,buttons:zt,scrollEdge:ln}}else{const It=Le(j,ct,St);Wr(It!==void 0);const xn=It!==void 0&&It.x+It.width-se{}),Ot=v.useRef(vn);Ot.current=vn;const[Xt,Nn]=v.useMemo(()=>{const j=document.createElement("canvas"),se=document.createElement("canvas");return j.style.display="none",j.style.opacity="0",j.style.position="fixed",se.style.display="none",se.style.opacity="0",se.style.position="fixed",[j.getContext("2d",{alpha:!1}),se.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(Xt===null||Nn===null))return document.documentElement.append(Xt.canvas),document.documentElement.append(Nn.canvas),()=>{Xt.canvas.remove(),Nn.canvas.remove()}},[Xt,Nn]);const vr=v.useMemo(()=>new S$,[]),Mn=ue&&Rt?1:Y&&Rt?2:5,ms=(Ne==null?void 0:Ne.disableMinimumCellWidth)===!0?1:10,qn=v.useRef(),ys=v.useRef(null),vs=v.useRef(null),Ol=v.useCallback(()=>{var st;const j=ht.current,se=Bt.current;if(j===null||se===null||(ys.current===null&&(ys.current=j.getContext("2d",{alpha:!1}),j.width=0,j.height=0),vs.current===null&&(vs.current=se.getContext("2d",{alpha:!1}),se.width=0,se.height=0),ys.current===null||vs.current===null||Xt===null||Nn===null))return;let xe=!1;const ye=ot=>{xe=!0,xt(ot)},de=qn.current,Ae={headerCanvasCtx:vs.current,canvasCtx:ys.current,bufferACtx:Xt,bufferBCtx:Nn,width:n,height:r,cellXOffset:dt,cellYOffset:l,translateX:Math.round(tt),translateY:Math.round(Kt),mappedColumns:ce,enableGroups:x,freezeColumns:S,dragAndDropState:oe,theme:Ge,headerHeight:a,groupHeaderHeight:c,disabledRows:_e??Nt.empty(),rowHeight:f,verticalBorder:Re,isResizing:V,resizeCol:le,isFocused:k,selection:b,fillHandle:u,drawCellCallback:we,hasAppendRow:ft,overrideCursor:ye,maxScaleFactor:Mn,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:Xe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:Qe,prelightCells:lt,highlightRegions:N,imageLoader:pt,lastBlitData:Pt,damage:Lt.current,hoverValues:Hn.current,hoverInfo:Ot.current,spriteManager:ze,scrolling:Rt,hyperWrapping:(Ne==null?void 0:Ne.hyperWrapping)??!1,touchMode:dn,enqueue:at.current,renderStateProvider:vr,renderStrategy:(Ne==null?void 0:Ne.renderStrategy)??(Eh.value?"double-buffer":"single-buffer"),getCellRenderer:Je,minimumCellWidth:ms};Ae.damage===void 0?(qn.current=Ae,Pb(Ae,de)):Pb(Ae,void 0),!xe&&(Ae.damage===void 0||Ae.damage.has((st=Ot==null?void 0:Ot.current)==null?void 0:st[0]))&&xt(void 0)},[Xt,Nn,n,r,dt,l,tt,Kt,ce,x,S,oe,Ge,a,c,_e,f,Re,V,ft,le,k,b,u,A,d,_,Mn,h,Xe,p,we,Qe,lt,N,pt,ze,Rt,Ne==null?void 0:Ne.hyperWrapping,Ne==null?void 0:Ne.renderStrategy,dn,vr,Je,ms]),zo=v.useRef(Ol);v.useLayoutEffect(()=>{Ol(),zo.current=Ol},[Ol]),v.useLayoutEffect(()=>{(async()=>{var se;((se=document==null?void 0:document.fonts)==null?void 0:se.ready)!==void 0&&(await document.fonts.ready,qn.current=void 0,zo.current())})()},[]);const js=v.useCallback(j=>{Lt.current=j,zo.current(),Lt.current=void 0},[]),lf=LW(js);at.current=lf;const af=v.useCallback(j=>{js(new ic(j.map(se=>se.cell)))},[js]);pt.setCallback(js);const[jp,Hp]=v.useState(!1),[Pl,ws]=We??[],Wp=Pl!==void 0&&ws===-1,Vp=Pl!==void 0&&ws===-2;let uf=!1,Il=!1,Rn=ut;if(Rn===void 0&&Pl!==void 0&&ws!==void 0&&ws>-1&&ws({contain:"strict",display:"block",cursor:cf}),[cf]),iu=v.useRef("default"),Hs=B==null?void 0:B.current;Hs!=null&&iu.current!==Nl.cursor&&(Hs.style.cursor=iu.current=Nl.cursor);const Nr=v.useCallback((j,se,xe,ye)=>{if(Xe===void 0)return;const de=Xe(j);if(de.actions!==void 0){const Ae=bE(se,de.actions);for(const[st,ot]of Ae.entries())if(Ep(ot,xe+se.x,ye+ot.y))return de.actions[st]}},[Xe]),yi=v.useCallback((j,se,xe,ye)=>{const de=s[se];if(!ge&&!V&&de.hasMenu===!0&&!(Pr??!1)){const Ae=Le(j,se,-1);Wr(Ae!==void 0);const st=xE(Ae.x,Ae.y,Ae.width,Ae.height,qv(de.title)==="rtl");if(xe>st.x&&xest.y&&ye{const se=ht.current,xe=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==xe)return;ou.current=!0;let ye,de;if(j instanceof MouseEvent?(ye=j.clientX,de=j.clientY):(ye=j.touches[0].clientX,de=j.touches[0].clientY),j.target===xe&&xe!==null){const st=xe.getBoundingClientRect();if(ye>st.right||de>st.bottom)return}const Ae=Ee(se,ye,de,j);Ws.current=Ae.location,Ae.isTouch&&(su.current=Date.now()),De.current!==Ae.isTouch&&re(Ae.isTouch),!(Ae.kind===to&&yi(se,Ae.location[0],ye,de)!==void 0)&&(Ae.kind===Hr&&Nr(Ae.group,Ae.bounds,Ae.localEventX,Ae.localEventY)!==void 0||(P==null||P(Ae),!Ae.isTouch&&Me!==!0&&Me!==Ae.kind&&Ae.button<3&&Ae.button!==1&&j.preventDefault()))},[B,Me,Ee,Nr,yi,P]);Vn("touchstart",ar,window,!1),Vn("mousedown",ar,window,!1);const Dl=v.useRef(0),lu=v.useCallback(j=>{var zt,ct;const se=Dl.current;Dl.current=Date.now();const xe=ht.current;if(ou.current=!1,I===void 0||xe===null)return;const ye=B==null?void 0:B.current,de=j.target!==xe&&j.target!==ye;let Ae,st,ot=!0;if(j instanceof MouseEvent){if(Ae=j.clientX,st=j.clientY,ot=j.button<3,j.pointerType==="touch")return}else Ae=j.changedTouches[0].clientX,st=j.changedTouches[0].clientY;let Ce=Ee(xe,Ae,st,j);Ce.isTouch&&su.current!==0&&Date.now()-su.current>500&&(Ce={...Ce,isLongTouch:!0}),se!==0&&Date.now()-se<(Ce.isTouch?1e3:500)&&(Ce={...Ce,isDoubleClick:!0}),De.current!==Ce.isTouch&&re(Ce.isTouch),!de&&j.cancelable&&ot&&j.preventDefault();const[Ft]=Ce.location,Be=yi(xe,Ft,Ae,st);if(Ce.kind===to&&Be!==void 0){(Ce.button!==0||((zt=Ws.current)==null?void 0:zt[0])!==Ft||((ct=Ws.current)==null?void 0:ct[1])!==-1)&&I(Ce,!0);return}else if(Ce.kind===Hr){const St=Nr(Ce.group,Ce.bounds,Ce.localEventX,Ce.localEventY);if(St!==void 0){Ce.button===0&&St.onClick(Ce);return}}I(Ce,de)},[I,B,Ee,yi,Nr]);Vn("mouseup",lu,window,!1),Vn("touchend",lu,window,!1);const ff=v.useCallback(j=>{var Be,zt;const se=ht.current;if(se===null)return;const xe=B==null?void 0:B.current,ye=j.target!==se&&j.target!==xe;let de,Ae,st=!0;j instanceof MouseEvent?(de=j.clientX,Ae=j.clientY,st=j.button<3):(de=j.changedTouches[0].clientX,Ae=j.changedTouches[0].clientY);const ot=Ee(se,de,Ae,j);De.current!==ot.isTouch&&re(ot.isTouch),!ye&&j.cancelable&&st&&j.preventDefault();const[Ce]=ot.location,Ft=yi(se,Ce,de,Ae);if(ot.kind===to&&Ft!==void 0)ot.button===0&&((Be=Ws.current)==null?void 0:Be[0])===Ce&&((zt=Ws.current)==null?void 0:zt[1])===-1&&(m==null||m(Ce,Ft));else if(ot.kind===Hr){const ct=Nr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ct!==void 0&&ot.button===0&&ct.onClick(ot)}},[B,Ee,yi,m,Nr]);Vn("click",ff,window,!1);const Up=v.useCallback(j=>{const se=ht.current,xe=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==xe||T===void 0)return;const ye=Ee(se,j.clientX,j.clientY,j);T(ye,()=>{j.cancelable&&j.preventDefault()})},[B,Ee,T]);Vn("contextmenu",Up,(B==null?void 0:B.current)??null,!1);const df=v.useCallback(j=>{Lt.current=new ic(j.map(se=>se.item)),Hn.current=j,zo.current(),Lt.current=void 0},[]),vi=v.useMemo(()=>new NW(df),[df]),xs=v.useRef(vi);xs.current=vi,v.useLayoutEffect(()=>{const j=xs.current;if(We===void 0||We[1]<0){j.setHovered(We);return}const se=h(We,!0),xe=Je(se),ye=xe===void 0&&se.kind===ke.Custom||(xe==null?void 0:xe.needsHover)!==void 0&&(typeof xe.needsHover=="boolean"?xe.needsHover:xe.needsHover(se));j.setHovered(ye?We:void 0)},[h,Je,We]);const Dr=v.useRef(),G=v.useCallback(j=>{var ot;const se=ht.current;if(se===null)return;const xe=B==null?void 0:B.current,ye=j.target!==se&&j.target!==xe,de=Ee(se,j.clientX,j.clientY,j);if(de.kind!=="out-of-bounds"&&ye&&!ou.current&&!de.isTouch)return;const Ae=(Ce,Ft)=>{In(Be=>Be===Ce||(Be==null?void 0:Be[0][0])===(Ce==null?void 0:Ce[0][0])&&(Be==null?void 0:Be[0][1])===(Ce==null?void 0:Ce[0][1])&&((Be==null?void 0:Be[1][0])===(Ce==null?void 0:Ce[1][0])&&(Be==null?void 0:Be[1][1])===(Ce==null?void 0:Ce[1][1])||!Ft)?Be:Ce)};if(!DE(de,Dr.current))xt(void 0),ne==null||ne(de),Ae(de.kind===Mh?void 0:[de.location,[de.localEventX,de.localEventY]],!0),Dr.current=de;else if(de.kind==="cell"||de.kind===to||de.kind===Hr){let Ce=!1,Ft=!0;if(de.kind==="cell"){const zt=h(de.location);Ft=((ot=Je(zt))==null?void 0:ot.needsHoverPosition)??zt.kind===ke.Custom,Ce=Ft}else de.kind===Hr&&(Ce=!0);const Be=[de.location,[de.localEventX,de.localEventY]];Ae(Be,Ft),Ot.current=Be,Ce&&js(new ic([de.location]))}const st=de.location[0]>=(W?0:1);Ir(de.kind===to&&de.isEdge&&st&&Fe===!0),Hp(de.kind==="cell"&&de.isFillHandle),D==null||D(j),Z(de)},[B,Ee,W,Fe,D,Z,ne,h,Je,js]);Vn("mousemove",G,window,!0);const on=v.useCallback(j=>{const se=ht.current;if(se===null)return;let xe,ye;b.current!==void 0&&(xe=Le(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),U==null||U({bounds:xe,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ye})},[U,b,Le]),Bo=v.useCallback(j=>{const se=ht.current;if(se===null)return;let xe,ye;b.current!==void 0&&(xe=Le(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),R==null||R({bounds:xe,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ye})},[R,b,Le]),Kp=v.useCallback(j=>{ht.current=j,L!==void 0&&(L.current=j)},[L]),hf=v.useCallback(j=>{const se=ht.current;if(se===null||Me===!1||V){j.preventDefault();return}let xe,ye;const de=Ee(se,j.clientX,j.clientY);if(Me!==!0&&de.kind!==Me){j.preventDefault();return}const Ae=(zt,ct)=>{xe=zt,ye=ct};let st,ot,Ce;const Ft=(zt,ct,St)=>{st=zt,ot=ct,Ce=St};let Be=!1;if(H==null||H({...de,setData:Ae,setDragImage:Ft,preventDefault:()=>Be=!0,defaultPrevented:()=>Be}),!Be&&xe!==void 0&&ye!==void 0&&j.dataTransfer!==null)if(j.dataTransfer.setData(xe,ye),j.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Ce!==void 0)j.dataTransfer.setDragImage(st,ot,Ce);else{const[zt,ct]=de.location;if(ct!==void 0){const St=document.createElement("canvas"),wn=Le(se,zt,ct);Wr(wn!==void 0);const gt=Math.ceil(window.devicePixelRatio??1);St.width=wn.width*gt,St.height=wn.height*gt;const hn=St.getContext("2d");hn!==null&&(hn.scale(gt,gt),hn.textBaseline="middle",ct===-1?(hn.font=Ge.headerFontFull,hn.fillStyle=Ge.bgHeader,hn.fillRect(0,0,St.width,St.height),kE(hn,0,0,wn.width,wn.height,ce[zt],!1,Ge,!1,!1,0,ze,Qe,!1)):(hn.font=Ge.baseFontFull,hn.fillStyle=Ge.bgCell,hn.fillRect(0,0,St.width,St.height),wE(hn,h([zt,ct]),0,ct,!1,!1,0,0,wn.width,wn.height,!1,Ge,Ge.bgCell,pt,ze,1,void 0,!1,0,void 0,void 0,void 0,vr,Je,()=>{}))),St.style.left="-100%",St.style.position="absolute",St.style.width=`${wn.width}px`,St.style.height=`${wn.height}px`,document.body.append(St),j.dataTransfer.setDragImage(St,wn.width/2,wn.height/2),window.setTimeout(()=>{St.remove()},0)}}else j.preventDefault()},[Me,V,Ee,H,Le,Ge,ce,ze,Qe,h,pt,vr,Je]);Vn("dragstart",hf,(B==null?void 0:B.current)??null,!1,!1);const au=v.useRef(),Xp=v.useCallback(j=>{const se=ht.current;if($e!==void 0&&j.preventDefault(),se===null||it===void 0)return;const xe=Ee(se,j.clientX,j.clientY),[ye,de]=xe.location,Ae=ye-(W?0:1),[st,ot]=au.current??[];(st!==Ae||ot!==de)&&(au.current=[Ae,de],it([Ae,de],j.dataTransfer))},[W,Ee,it,$e]);Vn("dragover",Xp,(B==null?void 0:B.current)??null,!1,!1);const Lw=v.useCallback(()=>{au.current=void 0,q==null||q()},[q]);Vn("dragend",Lw,(B==null?void 0:B.current)??null,!1,!1);const J=v.useCallback(j=>{const se=ht.current;if(se===null||$e===void 0)return;j.preventDefault();const xe=Ee(se,j.clientX,j.clientY),[ye,de]=xe.location,Ae=ye-(W?0:1);$e([Ae,de],j.dataTransfer)},[W,Ee,$e]);Vn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Yn=v.useCallback(()=>{At==null||At()},[At]);Vn("dragleave",Yn,(B==null?void 0:B.current)??null,!1,!1);const On=v.useRef(b);On.current=b;const _l=v.useRef(null),uu=v.useCallback(j=>{var se;ht.current===null||!ht.current.contains(document.activeElement)||(j===null&&On.current.current!==void 0?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j!==null&&j.focus({preventScroll:!0}),_l.current=j)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var se;const j=_l.current;j===null||!document.contains(j)?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j.focus({preventScroll:!0})},getBounds:(j,se)=>{if(!(L===void 0||L.current===null))return Le(L.current,j??0,se??-1)},damage:af}),[L,af,Le]);const Vs=v.useRef(),wr=A4(()=>{var ot,Ce,Ft;if(n<50||(Ne==null?void 0:Ne.disableAccessibilityTree)===!0)return null;let j=_0(ce,dt,n,oe,tt);const se=W?0:-1;!W&&((ot=j[0])==null?void 0:ot.sourceIndex)===0&&(j=j.slice(1));const[xe,ye]=((Ce=b.current)==null?void 0:Ce.cell)??[],de=(Ft=b.current)==null?void 0:Ft.range,Ae=j.map(Be=>Be.sourceIndex),st=nl(l,Math.min(d,l+i));return xe!==void 0&&ye!==void 0&&!(Ae.includes(xe)&&st.includes(ye))&&uu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":ce.length+se},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},j.map(Be=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Be.sourceIndex),"aria-colindex":Be.sourceIndex+1+se,tabIndex:-1,onFocus:zt=>{if(zt.target!==_l.current)return nt==null?void 0:nt([Be.sourceIndex,-1])},key:Be.sourceIndex},Be.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(Be=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Be),key:Be,"aria-rowindex":Be+2},j.map(zt=>{const ct=zt.sourceIndex,St=Pi(ct,Be),wn=xe===ct&&ye===Be,gt=de!==void 0&&ct>=de.x&&ct=de.y&&Be{const _r=L==null?void 0:L.current;if(_r!=null)return U==null?void 0:U({bounds:Le(_r,ct,Be),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Zr})},onFocusCapture:_r=>{var It,xn;if(!(_r.target===_l.current||((It=Vs.current)==null?void 0:It[0])===ct&&((xn=Vs.current)==null?void 0:xn[1])===Be))return Vs.current=Zr,nt==null?void 0:nt(Zr)},ref:wn?uu:void 0,tabIndex:-1},FW(ln,Je))})))))},[n,ce,dt,oe,tt,d,l,i,b,uu,h,L,U,Le,nt],200),wi=S===0||!M?0:dt>S?1:Oi(-tt/100,0,1),Gp=-l*32+Kt,Ll=O?Oi(-Gp/100,0,1):0,qp=v.useMemo(()=>{if(!wi&&!Ll)return null;const j={position:"absolute",top:0,left:fe,width:n-fe,height:r,opacity:wi,pointerEvents:"none",transition:rt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},se={position:"absolute",top:An,left:0,width:n,height:r,opacity:Ll,pointerEvents:"none",transition:me?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,wi>0&&v.createElement("div",{id:"shadow-x",style:j}),Ll>0&&v.createElement("div",{id:"shadow-y",style:se}))},[wi,Ll,fe,n,rt,An,r,me]),Yp=v.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return v.createElement(v.Fragment,null,v.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:on,onKeyUp:Bo,onFocus:y,onBlur:w,ref:Kp,style:Nl},wr),v.createElement("canvas",{ref:Bt,style:Yp}),qp)},zW=v.memo(v.forwardRef($W));function Ru(t,e,n,r){return Oi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const BW=t=>{const[e,n]=v.useState(),[r,i]=v.useState(),[s,o]=v.useState(),[l,a]=v.useState(),[u,c]=v.useState(!1),[f,d]=v.useState(),[h,p]=v.useState(),[m,x]=v.useState(),[g,y]=v.useState(!1),[w,k]=v.useState(),{onHeaderMenuClick:b,getCellContent:S,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:Z,onColumnProposeMove:ne,onMouseDown:oe,onMouseUp:W,onItemHovered:U,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:H,selection:q}=t,B=q.columns,V=v.useCallback(Re=>{const[we,Qe]=Re.location;s!==void 0&&l!==we&&we>=Z?(c(!0),a(we)):h!==void 0&&Qe!==void 0?(y(!0),x(Math.max(0,Qe))):r===void 0&&!u&&!g&&(U==null||U(Re))},[s,h,l,U,Z,r,u,g]),le=T!==void 0,ge=v.useCallback(Re=>{var we;if(Re.button===0){const[Qe,nt]=Re.location;if(Re.kind==="out-of-bounds"&&Re.isEdge&&L){const it=(we=_==null?void 0:_.current)==null?void 0:we.getBounds(H.length-1,-1);it!==void 0&&(n(it.x),i(H.length-1))}else if(Re.kind==="header"&&Qe>=Z){const it=N==null?void 0:N.current;if(Re.isEdge&&L&&it){n(Re.bounds.x),i(Qe);const At=it.getBoundingClientRect().width/it.offsetWidth,wt=Re.bounds.width/At;M==null||M(H[Qe],wt,Qe,wt+(H[Qe].growOffset??0))}else Re.kind==="header"&&le&&(d(Re.bounds.x),o(Qe))}else Re.kind==="cell"&&Z>0&&Qe===0&&nt!==void 0&&D!==void 0&&(k(Re.bounds.y),p(nt))}oe==null||oe(Re)},[oe,L,Z,D,_,H,le,M,N]),Me=v.useCallback((Re,we)=>{u||g||b==null||b(Re,we)},[u,g,b]),Fe=v.useRef(-1),_e=v.useCallback(()=>{Fe.current=-1,p(void 0),x(void 0),k(void 0),y(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),ft=v.useCallback((Re,we)=>{if(Re.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,Fe.current,I,P);A==null||A(it,$e,nt,$e+(it.growOffset??0))}const Qe=Ru(H[r],Fe.current,I,P);if(O==null||O(H[r],Qe,r,Qe+(H[r].growOffset??0)),B.hasIndex(r))for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,Fe.current,I,P);O==null||O(it,$e,nt,$e+(it.growOffset??0))}}_e(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}W==null||W(Re,we)},[W,r,s,l,h,m,B,O,H,I,P,A,T,D,_e]),Xe=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ne==null?void 0:ne(s,l))!==!1)return{src:s,dest:l}},[s,l,ne]),Ge=v.useCallback(Re=>{const we=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Re.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Re.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&we){const nt=we.getBoundingClientRect().width/we.offsetWidth,it=(Re.clientX-e)/nt,$e=H[r],At=Ru($e,it,I,P);if(A==null||A($e,At,r,At+($e.growOffset??0)),Fe.current=it,(B==null?void 0:B.first())===r)for(const wt of B){if(wt===r)continue;const rt=H[wt],me=Ru(rt,Fe.current,I,P);A==null||A(rt,me,wt,me+(rt.growOffset??0))}}},[s,f,h,w,r,e,H,I,P,A,B,N]),lt=v.useCallback((Re,we)=>{if(h===void 0||m===void 0)return S(Re,we);let[Qe,nt]=Re;return nt===m?nt=h:(nt>m&&(nt-=1),nt>=h&&(nt+=1)),S([Qe,nt],we)},[h,m,S]),Ut=v.useCallback(Re=>{R==null||R(Re),Re.defaultPrevented()||_e()},[_e,R]);return v.createElement(zW,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:lt,isResizing:r!==void 0,onHeaderMenuClick:Me,isDragging:u,onItemHovered:V,onDragStart:Ut,onMouseDown:ge,allowResize:L,onMouseUp:ft,dragAndDropState:Xe,onMouseMoveRaw:Ge,ref:_})};function jW(t){const e=v.useRef(null),[n,r]=v.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return v.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const HW=(t,e,n)=>{const r=v.useRef(null),i=v.useRef(null),s=v.useRef(null),o=v.useRef(0),l=v.useRef(e);l.current=e;const a=n.current;v.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},WW=()=>t=>t.isSafari?"scroll":"auto",VW=Qr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[WW()]}});function UW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return Vn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Vn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const KW=t=>{var H,q;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:m}=t,x=[],g=(d==null?void 0:d.sticky)??!1,y=(d==null?void 0:d.fill)??!1,w=v.useRef(0),k=v.useRef(0),b=v.useRef(null),S=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=v.useRef(null),M=UW(200),[O,_]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||M||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[V,le]=T.current.lockDirection;V!==void 0?B.scrollLeft=V:le!==void 0&&(B.scrollTop=le),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,V)=>{var we;const le=b.current;if(le===null)return;V=V??le.scrollTop,B=B??le.scrollLeft;const ge=T.current.scrollTop,Me=T.current.scrollLeft,Fe=B-Me,_e=V-ge;M&&Fe!==0&&_e!==0&&(Math.abs(Fe)>3||Math.abs(_e)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(Fe)0&&(Math.abs(Ut)>2e3||lt===0||lt===Re)&&r>le.scrollHeight+5){const Qe=lt/Re,nt=(r-Ge)*Qe;w.current=nt-lt}ft!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:lt+w.current,width:Xe-c,height:Ge-u,paddingRight:((we=A.current)==null?void 0:we.clientWidth)??0})},[u,c,r,s,a,M]);HW(h&&Eh.value,I,b);const D=v.useRef(I);D.current=I;const Z=v.useRef(),ne=v.useRef(!1);v.useLayoutEffect(()=>{ne.current?I():ne.current=!0},[I,u,c]);const oe=v.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let W=0,U=0;for(x.push(v.createElement("div",{key:W++,style:{width:i,height:0}}));UD.current(),0),Z.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(VW,{isSafari:Eh.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:oe,style:Z.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>I()},v.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},v.createElement("div",{className:"dvn-stack"},x),f!==void 0&&v.createElement(v.Fragment,null,!y&&v.createElement("div",{className:"dvn-spacer"}),v.createElement("div",{ref:A,style:{height:L,maxHeight:n-Math.ceil(S%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:y?1:void 0,right:g?c??0:void 0,pointerEvents:"auto"}},f))))))},XW=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:g,overscrollY:y,initialSize:w,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:S}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),Z=u+Math.max(0,g??0);let ne=o?i+s:i;if(typeof r=="number")ne+=n*r;else for(let R=0;R{var _e,ft;if(oe.current===void 0)return;const R={...oe.current};let N=0,L=R.x<0?-R.x:0,H=0,q=0;R.x=R.x<0?0:R.x;let B=0;for(let Xe=0;Xe=Ge+Xe.width)N+=Xe.width,q++,H++;else if(R.x>Ge)N+=Xe.width,k?L+=Ge-R.x:q++,H++;else if(R.x+R.width>Ge)N+=Xe.width,H++;else break}let V=0,le=0,ge=0;if(typeof r=="number")b?(le=Math.floor(R.y/r),V=le*r-R.y):le=Math.ceil(R.y/r),ge=Math.ceil(R.height/r)+le,V<0&&ge++;else{let Xe=0;for(let Ge=0;Ge=Xe+lt)Xe+=lt,le++,ge++;else if(R.y>Ut)Xe+=lt,b?V+=Ut-R.y:le++,ge++;else if(R.y+R.height>lt/2+Xe)Xe+=lt,ge++;else break}}const Me={x:q,y:le,width:H-q,height:ge-le},Fe=_.current;(Fe===void 0||Fe.y!==Me.y||Fe.x!==Me.x||Fe.height!==Me.height||Fe.width!==Me.width||P.current!==L||I.current!==V||R.width!==((_e=D.current)==null?void 0:_e[0])||R.height!==((ft=D.current)==null?void 0:ft[1]))&&(d==null||d({x:q,y:le,width:H-q,height:ge-le},R.width,R.height,R.paddingRight??0,L,V),_.current=Me,P.current=L,I.current=V,D.current=[R.width,R.height])},[e,r,n,d,l,k,b]),U=v.useCallback(R=>{oe.current=R,W()},[W]);return v.useEffect(()=>{W()},[W]),v.createElement(KW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:S===!0||typeof S=="string",scrollWidth:Z+(T??0),scrollHeight:ne+(A??0),clientHeight:O,rightElement:m,paddingBottom:A,paddingRight:T,rightElementProps:x,update:U,initialSize:w},v.createElement(BW,{eventTargetRef:h,width:M,height:O,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},GW=Qr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),qW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),YW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),QW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),JW=10,ZW=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=v.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=v.useState(""),x=o??p,g=v.useCallback(N=>{m(N),a==null||a(N)},[a]),[y,w]=v.useState(),k=v.useRef(y);k.current=y,v.useEffect(()=>{l!==void 0&&(l.length>0?w(N=>({rowsSearched:r,results:l.length,selectedIndex:(N==null?void 0:N.selectedIndex)??-1})):w(void 0))},[r,l]);const b=v.useRef();b.current===void 0&&(b.current=new AbortController);const S=v.useRef(),[T,A]=v.useState([]),M=l??T,O=v.useCallback(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0,b.current.abort())},[]),_=v.useRef(n);_.current=n;const P=v.useCallback(N=>{const L=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let H=_.current,q=Math.min(10,r),B=0;w(void 0),A([]);const V=[],le=async()=>{var Re;if(u===void 0)return;const ge=performance.now(),Me=r-B;let Fe=u({x:0,y:H,width:i.length,height:Math.min(q,Me,r-H)},b.current.signal);typeof Fe=="function"&&(Fe=await Fe());let _e=!1;for(const[we,Qe]of Fe.entries())for(const[nt,it]of Qe.entries()){let $e;switch(it.kind){case ke.Text:case ke.Number:$e=it.displayData;break;case ke.Uri:case ke.Markdown:$e=it.data;break;case ke.Boolean:$e=typeof it.data=="boolean"?it.data.toString():void 0;break;case ke.Image:case ke.Bubble:$e=it.data.join("🐳");break;case ke.Custom:$e=it.copyData;break}$e!==void 0&&L.test($e)&&(V.push([nt,we+H]),_e=!0)}const ft=performance.now();_e&&A([...V]),B+=Fe.length,Wr(B<=r);const Xe=((Re=k.current)==null?void 0:Re.selectedIndex)??-1;w({results:V.length,rowsSearched:B,selectedIndex:Xe}),c==null||c(V,Xe),H+q>=r?H=0:H+=q;const Ge=ft-ge,lt=Math.max(Ge,1),Ut=JW/lt;q=Math.ceil(q*Ut),B{var N;d==null||d(),w(void 0),A([]),c==null||c([],-1),O(),(N=e==null?void 0:e.current)==null||N.focus()},[O,e,d,c]),D=v.useCallback(N=>{g(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),O()):P(N.target.value))},[P,O,g,l]);v.useEffect(()=>{f&&s.current!==null&&(g(""),s.current.focus({preventScroll:!0}))},[f,s,g]);const Z=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(M,L)},[y,c,M]),ne=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;let L=(y.selectedIndex-1)%y.results;L<0&&(L+=y.results),w({...y,selectedIndex:L}),c==null||c(M,L)},[c,M,y]),oe=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ne():Z())},[I,Z,ne]);v.useEffect(()=>()=>{O()},[O]);const[W,U]=v.useState(!1);v.useEffect(()=>{if(f)U(!0);else{const N=setTimeout(()=>U(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!W)return null;let N;y!==void 0&&(N=y.results>=1e3?"over 1000":`${y.results} result${y.results!==1?"s":""}`,y.selectedIndex>=0&&(N=`${y.selectedIndex+1} of ${N}`));const L=B=>{B.stopPropagation()},q={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(GW,{className:f?"":"out",onMouseDown:L,onMouseMove:L,onMouseUp:L,onClick:L},v.createElement("div",{className:"gdg-search-bar-inner"},v.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:D,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:oe}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ne,disabled:((y==null?void 0:y.results)??0)===0},qW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Z,disabled:((y==null?void 0:y.results)??0)===0},YW),d!==void 0&&v.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:I},QW)),y!==void 0?v.createElement(v.Fragment,null,v.createElement("div",{className:"gdg-search-status"},v.createElement("div",{"data-testid":"search-result-area"},N)),v.createElement("div",{className:"gdg-search-progress",style:q})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,W,y,r,h,s,D,x,oe,ne,Z,d,I]);return v.createElement(v.Fragment,null,v.createElement(XW,{prelightCells:M,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),R)};class e6 extends v.PureComponent{constructor(){super(...arguments);bt(this,"wrapperRef",v.createRef());bt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return v.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const t6=()=>t=>Math.max(16,t.targetHeight-10),n6=Qr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[t6(),"px"]}}),r6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Ln.useState(n);return Ln.createElement(e6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Ln.createElement(n6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function i6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function yt(t,e,n){const r=_E(t,e);return r&&(n.didMatch=!0),r}function _E(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(_E(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!i6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":Ah.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function s6(t,e,n,r,i,s){const o=Ln.useCallback((u,c,f,d)=>{var y;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,m=i==="mixed"&&h;let x={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((y=t.current)==null?void 0:y.rangeStack)??[]:[]},columns:p?t.columns:Nt.empty(),rows:m?t.rows:Nt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=Ln.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Nt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Nt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Ln.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Nt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Nt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function o6(t,e,n,r,i){const s=v.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:ke.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=v.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:ke.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:ke.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function l6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case ke.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Wv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case ke.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case ke.Image:case ke.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case ke.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case ke.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case ke.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case ke.Markdown:case ke.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case ke.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case ke.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ke.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Rc()}}function a6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:l6(o))})}function Nb(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function u6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>Nb(o,!0)).join(",")):i.push(Nb(s.formatted,!1));e.push(i.join(" "))}return e.join(` -`)}function Jg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Db(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function c6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function f6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${Jg(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+Jg(o)+"
    2. ").join("")}
    ${Jg(i.formatted)}
    "),e.join("")}function d6(t,e){const n=a6(t,e),r=u6(n),i=f6(n);return{textPlain:r,textHtml:i}}function _b(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const m of d)m.replaceWith(` -`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:c6(h),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function h6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function Lb(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function p6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` -`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` -`?(r.push(t.slice(i,o)),i=o+1,l===` -`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` -`)&&(r.push(Lb(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Fb(t,e,n){var l;const r=d6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function LE(t){return t!==!0}function $b(t){return typeof t=="string"?t:`${t}px`}const g6=()=>t=>t.innerWidth,m6=()=>t=>t.innerHeight,y6=Qr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[g6()],"wmyidgi-1":[m6()]}}),v6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(y6,{innerHeight:$b(n),innerWidth:$b(e),...i},r)},w6=2,x6=1300;function b6(t,e,n){const r=Ln.useRef(0),[i,s]=t??[0,0];Ln.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/x6);const d=r.current**1.618*f*w6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function k6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Ln.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=lE();return[typeof m=="number"?m*p:g=>Math.ceil(m(g)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const Js={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function vt(t,e){return t===!0?e:t===!1?"":t}function zb(t){const e=Ah.value;return{activateCell:vt(t.activateCell," |Enter|shift+Enter"),clear:vt(t.clear,"any+Escape"),closeOverlay:vt(t.closeOverlay,"any+Escape"),acceptOverlayDown:vt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:vt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:vt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:vt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:vt(t.delete,e?"Backspace|Delete":"Delete"),downFill:vt(t.downFill,"primary+_68"),scrollToSelectedCell:vt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:vt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:vt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:vt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:vt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:vt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:vt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:vt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:vt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:vt(t.goToFirstCell,"primary+Home"),goToFirstColumn:vt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:vt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:vt(t.goToLastCell,"primary+End"),goToLastColumn:vt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:vt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:vt(t.goToNextPage,"PageDown"),goToPreviousPage:vt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:vt(t.rightFill,"primary+_82"),search:vt(t.search,"primary+f"),selectAll:vt(t.selectAll,"primary+a"),selectColumn:vt(t.selectColumn,"ctrl+ "),selectGrowDown:vt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:vt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:vt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:vt(t.selectGrowUp,"shift+ArrowUp"),selectRow:vt(t.selectRow,"shift+ "),selectToFirstCell:vt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:vt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:vt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:vt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:vt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:vt(t.selectToLastRow,"primary+shift+ArrowDown")}}function S6(t){const e=I4(t);return Ln.useMemo(()=>{if(e===void 0)return zb(Js);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Js.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Js.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Js.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Js.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Js.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Js.selectToLastCell};return zb({...Js,...n})},[e])}const C6=v.lazy(async()=>await uE(()=>import("./data-grid-overlay-editor-BYOokjyr.js"),[]));let T6=0;function E6(t){return Rz(ib(ib(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return nl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Yf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Zg={kind:ke.Loading,allowOverlay:!1},Qf={columns:Nt.empty(),rows:Nt.empty(),current:void 0},A6=(t,e)=>{var Yw,Qw,Jw;const[n,r]=v.useState(Qf),[i,s]=v.useState(),o=v.useRef(null),l=v.useRef(null),[a,u]=v.useState(),c=v.useRef(null),f=v.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:g,columns:y,rows:w,getCellContent:k,onCellClicked:b,onCellActivated:S,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:Z="default",onGroupHeaderClicked:ne,onCellContextMenu:oe,className:W,onHeaderContextMenu:U,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:H,onCellsEdited:q,onSearchResultsChanged:B,searchResults:V,onSearchValueChange:le,searchValue:ge,onKeyDown:Me,onKeyUp:Fe,keybindings:_e,editOnType:ft=!0,onRowAppended:Xe,onColumnMoved:Ge,validateCell:lt,highlightRegions:Ut,rangeSelect:Re="rect",columnSelect:we="multi",rowSelect:Qe="multi",rangeSelectionBlending:nt="exclusive",columnSelectionBlending:it="exclusive",rowSelectionBlending:$e="exclusive",onDelete:At,onDragStart:wt,onMouseMove:rt,onPaste:me,copyHeaders:Ne=!1,freezeColumns:Je=0,cellActivationBehavior:tt="second-click",rowSelectionMode:Kt="auto",onHeaderMenuClick:dt,getGroupDetails:ht,onSearchClose:pt,onItemHovered:Lt,onSelectionCleared:Rt,showSearch:en,onVisibleRegionChanged:Hn,gridSelection:Pt,onGridSelectionChange:vn,minColumnWidth:In=50,maxColumnWidth:Pr=500,maxColumnAutoWidth:Ir,provideEditor:Bt,trailingRowOptions:ut,freezeTrailingRows:xt=0,allowedFillDirections:dn="orthogonal",scrollOffsetX:re,scrollOffsetY:De,verticalBorder:ze,onDragOverCell:An,onDrop:z,onColumnResize:ue,onColumnResizeEnd:Y,onColumnResizeStart:ce,customRenderers:fe,fillHandle:Le,drawFocusRing:Ee=!0,experimental:We,fixedShadowX:at,fixedShadowY:Ot,headerIcons:Xt,imageWindowLoader:Nn,initialSize:vr,isDraggable:Mn,onDragLeave:ms,onRowMoved:qn,overscrollX:ys,overscrollY:vs,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:js,trapFocus:lf=!1,smoothScrollX:af,smoothScrollY:jp,scaleToRem:Hp=!1,rowHeight:Pl=34,headerHeight:ws=36,groupHeaderHeight:Wp=ws,theme:Vp,isOutsideClick:uf,renderers:Il}=t,Rn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Jr=(Rn==null?void 0:Rn.kind)??t.rowMarkers??"none",cf=(Rn==null?void 0:Rn.width)??t.rowMarkerWidth,Nl=(Rn==null?void 0:Rn.startIndex)??t.rowMarkerStartIndex??1,iu=(Rn==null?void 0:Rn.theme)??t.rowMarkerTheme,Hs=(Rn==null?void 0:Rn.checkboxStyle)??"square",Nr=Math.max(In,20),yi=Math.max(Pr,Nr),su=Math.max(Ir??yi,Nr),Ws=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),ou=v.useMemo(()=>Number.parseFloat(Ws.fontSize),[Ws]),{rowHeight:ar,headerHeight:Dl,groupHeaderHeight:lu,theme:ff,overscrollX:Up,overscrollY:df}=k6({groupHeaderHeight:Wp,headerHeight:ws,overscrollX:ys,overscrollY:vs,remSize:ou,rowHeight:Pl,scaleToRem:Hp,theme:Vp}),vi=S6(_e),xs=cf??(w>1e4?48:w>1e3?44:w>100?36:32),Dr=Jr!=="none",G=Dr?1:0,on=Xe!==void 0,Bo=(ut==null?void 0:ut.sticky)===!0,[Kp,hf]=v.useState(!1),au=en??Kp,Xp=v.useCallback(()=>{pt!==void 0?pt():hf(!1)},[pt]),J=v.useMemo(()=>Pt===void 0?void 0:Yf(Pt,G),[Pt,G])??n,Yn=v.useRef();Yn.current===void 0&&(Yn.current=new AbortController),v.useEffect(()=>()=>Yn==null?void 0:Yn.current.abort(),[]);const[On,_l]=o6(R,k,G,Yn.current,w),uu=v.useCallback((C,$,F)=>{if(lt===void 0)return!0;const K=[C[0]-G,C[1]];return lt==null?void 0:lt(K,$,F)},[G,lt]),Vs=v.useRef(Pt),wr=v.useCallback((C,$)=>{$&&(C=h6(C,On,G,Z,Yn.current)),vn!==void 0?(Vs.current=Yf(C,-G),vn(Vs.current)):r(C)},[vn,On,G,Z]),wi=Ul(ue,v.useCallback((C,$,F,K)=>{ue==null||ue(y[F-G],$,F-G,K)},[ue,G,y])),Gp=Ul(Y,v.useCallback((C,$,F,K)=>{Y==null||Y(y[F-G],$,F-G,K)},[Y,G,y])),Ll=Ul(ce,v.useCallback((C,$,F,K)=>{ce==null||ce(y[F-G],$,F-G,K)},[ce,G,y])),qp=Ul(O,v.useCallback((C,$)=>(O==null?void 0:O({...C,columnIndex:C.columnIndex-G},$))??!1,[O,G])),Yp=Ul(_,v.useCallback((C,$)=>(_==null?void 0:_({...C,col:C.col-G},$))??!1,[_,G])),j=v.useCallback(C=>{if(At!==void 0){const $=At(Yf(C,-G));return typeof $=="boolean"?$:Yf($,G)}return!0},[At,G]),[se,xe,ye]=s6(J,wr,nt,it,$e,Re),de=v.useMemo(()=>To(lE(),ff),[ff]),[Ae,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Il===void 0)return{};const C={};for(const $ of Il)C[$.kind]=$;return C},[Il]),Ce=v.useCallback(C=>C.kind!==ke.Custom?ot[C.kind]:fe==null?void 0:fe.find($=>$.isMatch(C)),[fe,ot]);let{sizedColumns:Ft,nonGrowWidth:Be}=A$(y,w,_l,Ae[0]-(G===0?0:xs)-Ae[2],Nr,su,de,Ce,Yn.current);Jr!=="none"&&(Be+=xs);const zt=v.useMemo(()=>Ft.some(C=>C.group!==void 0),[Ft]),ct=zt?Dl+lu:Dl,St=J.rows.length,wn=Jr==="none"?void 0:St===0?!1:St===w?!0:void 0,gt=v.useMemo(()=>Jr==="none"?Ft:[{title:"",width:xs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:iu,rowMarker:Hs,rowMarkerChecked:wn},...Ft],[Jr,Ft,xs,iu,Hs,wn]),[hn,Zr]=v.useMemo(()=>[De!==void 0&&typeof ar=="number"?Math.floor(De/ar):0,De!==void 0&&typeof ar=="number"?-(De%ar):0],[De,ar]),ln=v.useRef({height:1,width:1,x:0,y:0}),_r=v.useMemo(()=>({x:ln.current.x,y:hn,width:ln.current.width??1,height:ln.current.height??1,ty:Zr}),[Zr,hn]),It=v.useRef(!1),[xn,Lr,Wi]=P4(_r);ln.current=xn;const xi=(xn.height??1)>1;v.useLayoutEffect(()=>{if(De!==void 0&&c.current!==null&&xi){if(c.current.scrollTop===De)return;c.current.scrollTop=De,c.current.scrollTop!==De&&Wi(),It.current=!0}},[De,xi,Wi]);const Fl=(xn.width??1)>1;v.useLayoutEffect(()=>{if(re!==void 0&&c.current!==null&&Fl){if(c.current.scrollLeft===re)return;c.current.scrollLeft=re,c.current.scrollLeft!==re&&Wi(),It.current=!0}},[re,Fl,Wi]);const jo=xn.x+G,pf=xn.y,xr=v.useRef(null),ur=v.useCallback(C=>{var $;C===!0?($=xr.current)==null||$.focus():window.requestAnimationFrame(()=>{var F;(F=xr.current)==null||F.focus()})},[]),Qn=on?w+1:w,ei=v.useCallback(C=>{const $=G===0?C:C.map(K=>({...K,location:[K.location[0]-G,K.location[1]]})),F=q==null?void 0:q($);if(F!==!0)for(const K of $)H==null||H(K.location,K.value);return F},[H,q,G]),[Ho,Qp]=v.useState(),gf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,$l=Ee?(Yw=J.current)==null?void 0:Yw.cell:void 0,mf=$l==null?void 0:$l[0],yf=$l==null?void 0:$l[1],wR=v.useMemo(()=>{if((Ut===void 0||Ut.length===0)&&(gf??mf??yf??Ho)===void 0)return;const C=[];if(Ut!==void 0)for(const $ of Ut){const F=gt.length-$.range.x-G;F>0&&C.push({color:$.color,range:{...$.range,x:$.range.x+G,width:Math.min(F,$.range.width)},style:$.style})}return Ho!==void 0&&C.push({color:wl(de.accentColor,0),range:Ho,style:"dashed"}),gf!==void 0&&C.push({color:wl(de.accentColor,.5),range:gf,style:"solid-outline"}),mf!==void 0&&yf!==void 0&&C.push({color:de.accentColor,range:{x:mf,y:yf,width:1,height:1},style:"solid-outline"}),C.length>0?C:void 0},[Ho,gf,mf,yf,Ut,gt.length,de.accentColor,G]),Fw=v.useRef(gt);Fw.current=gt;const Fr=v.useCallback(([C,$],F=!1)=>{var te,Q,ee,ae,ie,Se,Oe;const K=on&&$===Qn-1;if(C===0&&Dr)return K?Zg:{kind:oi.Marker,allowOverlay:!1,checkboxStyle:Hs,checked:(J==null?void 0:J.rows.hasIndex($))===!0,markerKind:Jr==="clickable-number"?"number":Jr,row:Nl+$,drawHandle:qn!==void 0,cursor:Jr==="clickable-number"?"pointer":void 0};if(K){const Ve=C===G?(ut==null?void 0:ut.hint)??"":"",qe=Fw.current[C];if(((te=qe==null?void 0:qe.trailingRowOptions)==null?void 0:te.disabled)===!0)return Zg;{const Mt=((Q=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Q.hint)??Ve,Ze=((ee=qe==null?void 0:qe.trailingRowOptions)==null?void 0:ee.addIcon)??(ut==null?void 0:ut.addIcon);return{kind:oi.NewRow,hint:Mt,allowOverlay:!1,icon:Ze}}}else{const be=C-G;if(F||(We==null?void 0:We.strict)===!0){const qe=ln.current,Mt=qe.x>be||be>qe.x+qe.width||qe.y>$||$>qe.y+qe.height||$>=Zp.current,Ze=be===((ie=(ae=qe.extras)==null?void 0:ae.selected)==null?void 0:ie[0])&&$===((Se=qe.extras)==null?void 0:Se.selected[1]);let He=!1;if(((Oe=qe.extras)==null?void 0:Oe.freezeRegions)!==void 0){for(const Qt of qe.extras.freezeRegions)if(Ep(Qt,be,$)){He=!0;break}}if(Mt&&!Ze&&!He)return Zg}let Ve=k([be,$]);return G!==0&&Ve.span!==void 0&&(Ve={...Ve,span:[Ve.span[0]+G,Ve.span[1]+G]}),Ve}},[on,Qn,Dr,Hs,J==null?void 0:J.rows,Jr,Nl,qn,G,ut==null?void 0:ut.hint,ut==null?void 0:ut.addIcon,We==null?void 0:We.strict,k]),Jp=v.useCallback(C=>{let $=(ht==null?void 0:ht(C))??{name:C};return L!==void 0&&C!==""&&($={icon:$.icon,name:$.name,overrideTheme:$.overrideTheme,actions:[...$.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>tg({group:$.name,bounds:F.bounds})}]}),$},[ht,L]),vf=v.useCallback(C=>{var ee;const[$,F]=C.cell,K=gt[$],X=(K==null?void 0:K.group)!==void 0?(ee=Jp(K.group))==null?void 0:ee.overrideTheme:void 0,te=K==null?void 0:K.themeOverride,Q=p==null?void 0:p(F);s({...C,theme:To(de,X,te,Q,C.content.themeOverride)})},[p,gt,Jp,de]),zl=v.useCallback((C,$,F)=>{var Q;if(J.current===void 0)return;const[K,X]=J.current.cell,te=Fr([K,X]);if(te.kind!==ke.Boolean&&te.allowOverlay){let ee=te;if(F!==void 0)switch(ee.kind){case ke.Number:{const ae=dD(()=>F==="-"?-0:Number.parseFloat(F),0);ee={...ee,data:Number.isNaN(ae)?0:ae};break}case ke.Text:case ke.Markdown:case ke.Uri:ee={...ee,data:F};break}vf({target:C,content:ee,initialValue:F,cell:[K,X],highlight:F===void 0,forceEditMode:F!==void 0})}else te.kind===ke.Boolean&&$&&te.readonly!==!0&&(ei([{location:J.current.cell,value:{...te,data:LE(te.data)}}]),(Q=xr.current)==null||Q.damage([{cell:J.current.cell}]))},[Fr,J,ei,vf]),$w=v.useCallback((C,$)=>{var X;const F=(X=xr.current)==null?void 0:X.getBounds(C,$);if(F===void 0||c.current===null)return;const K=Fr([C,$]);K.allowOverlay&&vf({target:F,content:K,initialValue:void 0,highlight:!0,cell:[C,$],forceEditMode:!0})},[Fr,vf]),bn=v.useCallback((C,$,F="both",K=0,X=0,te=void 0)=>{if(c.current!==null){const Q=xr.current,ee=l.current,ae=typeof C!="number"?C.unit==="cell"?C.amount:void 0:C,ie=typeof $!="number"?$.unit==="cell"?$.amount:void 0:$,Se=typeof C!="number"&&C.unit==="px"?C.amount:void 0,Oe=typeof $!="number"&&$.unit==="px"?$.amount:void 0;if(Q!==null&&ee!==null){let be={x:0,y:0,width:0,height:0},Ve=0,qe=0;if((ae!==void 0||ie!==void 0)&&(be=Q.getBounds((ae??0)+G,ie??0)??be,be.width===0||be.height===0))return;const Mt=ee.getBoundingClientRect(),Ze=Mt.width/ee.offsetWidth;if(Se!==void 0&&(be={...be,x:Se-Mt.left-c.current.scrollLeft,width:1}),Oe!==void 0&&(be={...be,y:Oe+Mt.top-c.current.scrollTop,height:1}),be!==void 0){const He={x:be.x-K,y:be.y-X,width:be.width+2*K,height:be.height+2*X};let Qt=0;for(let lg=0;lg0&&(Jn=Rl(Qn,kn,ar));let ki=Qt*Ze+Mt.left+G*xs*Ze,Ui=Mt.right,Si=Mt.top+ct*Ze,Ki=Mt.bottom-Jn*Ze;const Cf=be.width+K*2;switch(te==null?void 0:te.hAlign){case"start":Ui=ki+Cf;break;case"end":ki=Ui-Cf;break;case"center":ki=Math.floor((ki+Ui)/2)-Cf/2,Ui=ki+Cf;break}const Tf=be.height+X*2;switch(te==null?void 0:te.vAlign){case"start":Ki=Si+Tf;break;case"end":Si=Ki-Tf;break;case"center":Si=Math.floor((Si+Ki)/2)-Tf/2,Ki=Si+Tf;break}ki>He.x?Ve=He.x-ki:UiHe.y?qe=He.y-Si:Ki=Qn-kn)&&(qe=0),(Ve!==0||qe!==0)&&(Ze!==1&&(Ve/=Ze,qe/=Ze),c.current.scrollTo(Ve+c.current.scrollLeft,qe+c.current.scrollTop))}}}},[G,xt,xs,ct,Je,Ft,Qn,Bo,ar]),zw=v.useRef($w),Bw=v.useRef(k),Zp=v.useRef(w);zw.current=$w,Bw.current=k,Zp.current=w;const Bl=v.useCallback(async(C,$=!0)=>{var ae;const F=gt[C];if(((ae=F==null?void 0:F.trailingRowOptions)==null?void 0:ae.disabled)===!0)return;const K=Xe==null?void 0:Xe();let X,te=!0;K!==void 0&&(X=await K,X==="top"&&(te=!1),typeof X=="number"&&(te=!1));let Q=0;const ee=()=>{if(Zp.current<=w){Q<500&&window.setTimeout(ee,Q),Q=50+Q*2;return}const ie=typeof X=="number"?X:te?w:0;Sf.current(C-G,ie),se({cell:[C,ie],range:{x:C,y:ie,width:1,height:1}},!1,!1,"edit");const Se=Bw.current([C-G,ie]);Se.allowOverlay&&Bu(Se)&&Se.readonly!==!0&&$&&window.setTimeout(()=>{zw.current(C,ie)},0)};ee()},[gt,Xe,G,w,se]),wf=v.useCallback(C=>{var F,K;const $=((K=(F=Ft[C])==null?void 0:F.trailingRowOptions)==null?void 0:K.targetColumn)??(ut==null?void 0:ut.targetColumn);if(typeof $=="number")return $+(Dr?1:0);if(typeof $=="object"){const X=y.indexOf($);if(X>=0)return X+(Dr?1:0)}},[Ft,y,Dr,ut==null?void 0:ut.targetColumn]),Us=v.useRef(),jl=v.useRef(),cu=v.useCallback((C,$)=>{var X;const[F,K]=$;return To(de,(X=gt[F])==null?void 0:X.themeOverride,p==null?void 0:p(K),C.themeOverride)},[p,gt,de]),fu=v.useCallback(C=>{var Se,Oe,be;const $=Ah.value?C.metaKey:C.ctrlKey,F=$&&Qe==="multi",K=$&&we==="multi",[X,te]=C.location,Q=J.columns,ee=J.rows,[ae,ie]=((Se=J.current)==null?void 0:Se.cell)??[];if(C.kind==="cell"){if(jl.current=void 0,Wo.current=[X,te],X===0&&Dr){if(on===!0&&te===w||Jr==="number"||Qe==="none")return;const Ve=Fr(C.location);if(Ve.kind!==oi.Marker)return;if(qn!==void 0){const Ze=Ce(Ve);Wr((Ze==null?void 0:Ze.kind)===oi.Marker);const He=(Oe=Ze==null?void 0:Ze.onClick)==null?void 0:Oe.call(Ze,{...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,theme:cu(Ve,C.location),preventDefault:()=>{}});if(He===void 0||He.checked===Ve.checked)return}s(void 0),ur();const qe=ee.hasIndex(te),Mt=Us.current;if(Qe==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Mt!==void 0&&ee.hasIndex(Mt)){const Ze=[Math.min(Mt,te),Math.max(Mt,te)+1];F||Kt==="multi"?xe(void 0,Ze,!0):xe(Nt.fromSingleSelection(Ze),void 0,F)}else F||C.isTouch||Kt==="multi"?qe?xe(ee.remove(te),void 0,!0):(xe(void 0,te,!0),Us.current=te):qe&&ee.length===1?xe(Nt.empty(),void 0,$):(xe(Nt.fromSingleSelection(te),void 0,$),Us.current=te)}else if(X>=G&&on&&te===w){const Ve=wf(X);Bl(Ve??X)}else if(ae!==X||ie!==te){const Ve=Fr(C.location),qe=Ce(Ve);if((qe==null?void 0:qe.onSelect)!==void 0){let He=!1;if(qe.onSelect({...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,preventDefault:()=>He=!0,theme:cu(Ve,C.location)}),He)return}const Mt=Bo&&te===w,Ze=Bo&&J!==void 0&&((be=J.current)==null?void 0:be.cell[1])===w;if((C.shiftKey||C.isLongTouch===!0)&&ae!==void 0&&ie!==void 0&&J.current!==void 0&&!Ze){if(Mt)return;const He=Math.min(X,ae),Qt=Math.max(X,ae),Jn=Math.min(te,ie),kn=Math.max(te,ie);se({...J.current,range:{x:He,y:Jn,width:Qt-He+1,height:kn-Jn+1}},!0,$,"click"),Us.current=void 0,ur()}else se({cell:[X,te],range:{x:X,y:te,width:1,height:1}},!0,$,"click"),Us.current=void 0,s(void 0),ur()}}else if(C.kind==="header")if(Wo.current=[X,te],s(void 0),Dr&&X===0)Us.current=void 0,jl.current=void 0,Qe==="multi"&&(ee.length!==w?xe(Nt.fromSingleSelection([0,w]),void 0,$):xe(Nt.empty(),void 0,$),ur());else{const Ve=jl.current;if(we==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ve!==void 0&&Q.hasIndex(Ve)){const qe=[Math.min(Ve,X),Math.max(Ve,X)+1];K?ye(void 0,qe,$):ye(Nt.fromSingleSelection(qe),void 0,$)}else K?(Q.hasIndex(X)?ye(Q.remove(X),void 0,$):ye(void 0,X,$),jl.current=X):we!=="none"&&(ye(Nt.fromSingleSelection(X),void 0,$),jl.current=X);Us.current=void 0,ur()}else C.kind===Hr?Wo.current=[X,te]:C.kind===Mh&&!C.isMaybeScrollbar&&(wr(Qf,!1),s(void 0),ur(),Rt==null||Rt(),Us.current=void 0,jl.current=void 0)},[Bl,we,ur,Ce,wf,Fr,J,Dr,Bo,Rt,qn,G,Jr,Qe,Kt,w,se,wr,ye,xe,on,cu]),du=v.useRef(!1),Wo=v.useRef(),jw=v.useRef(xn),ti=v.useRef(),xR=v.useCallback(C=>{if(Hl.current=!1,jw.current=ln.current,C.button!==0&&C.button!==1){ti.current=void 0;return}const $=performance.now();ti.current={button:C.button,time:$,location:C.location},(C==null?void 0:C.kind)==="header"&&(du.current=!0);const F=C.kind==="cell"&&C.isFillHandle;!F&&C.kind!=="cell"&&C.isEdge||(u({previousSelection:J,fillHandle:F}),Wo.current=void 0,!C.isTouch&&C.button===0&&!F?fu(C):!C.isTouch&&C.button===1&&(Wo.current=C.location))},[J,fu]),[eg,tg]=v.useState(),Hw=v.useCallback(C=>{if(C.kind!==Hr||we!=="multi")return;const $=Ah.value?C.metaKey:C.ctrlKey,[F]=C.location,K=J.columns;if(F=G&&Oc(X.group,gt[ee].group);ee--)te--;for(let ee=F+1;ee{if(On!==void 0&&wi!==void 0){const $=ln.current.y,F=ln.current.height;let K=On({x:C,y:$,width:1,height:Math.min(F,w-$)},Yn.current.signal);typeof K!="object"&&(K=await K());const X=Ft[C-G],Q=document.createElement("canvas").getContext("2d",{alpha:!1});if(Q!==null){Q.font=de.baseFontFull;const ee=aE(Q,de,X,0,K,Nr,yi,!1,Ce);wi==null||wi(X,ee.width,C,ee.width)}}},[Ft,On,yi,de,Nr,wi,G,w,Ce]),[bR,ng]=v.useState(),Wl=v.useCallback(async(C,$)=>{var ee,ae;const F=(ee=C.current)==null?void 0:ee.range;if(F===void 0||On===void 0||$.current===void 0)return;const K=$.current.range;if(T!==void 0){let ie=!1;if(T({fillDestination:{...K,x:K.x-G},patternSource:{...F,x:F.x-G},preventDefault:()=>ie=!0}),ie)return}let X=On(F,Yn.current.signal);typeof X!="object"&&(X=await X());const te=X,Q=[];for(let ie=0;ie({cell:ie.location})))},[On,ei,T,G]),Ww=v.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,width:1}}};Wl(C,J)},[Wl,J]),Vw=v.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,height:1}}};Wl(C,J)},[Wl,J]),kR=v.useCallback((C,$)=>{var Se,Oe;const F=a;if(u(void 0),Qp(void 0),ng(void 0),du.current=!1,$)return;if((F==null?void 0:F.fillHandle)===!0&&J.current!==void 0&&((Se=F.previousSelection)==null?void 0:Se.current)!==void 0){if(Ho===void 0)return;const be={...J,current:{...J.current,range:vE(F.previousSelection.current.range,Ho)}};Wl(F.previousSelection,be),wr(be,!0);return}const[K,X]=C.location,[te,Q]=Wo.current??[],ee=()=>{Hl.current=!0},ae=be=>{var qe,Mt,Ze;const Ve=be.isTouch||te===K&&Q===X;if(Ve&&(b==null||b([K-G,X],{...be,preventDefault:ee})),be.button===1)return!Hl.current;if(!Hl.current){const He=Fr(C.location),Qt=Ce(He);if(Qt!==void 0&&Qt.onClick!==void 0&&Ve){const kn=Qt.onClick({...be,cell:He,posX:be.localEventX,posY:be.localEventY,bounds:be.bounds,theme:cu(He,C.location),preventDefault:ee});kn!==void 0&&!ca(kn)&&ql(kn)&&(ei([{location:be.location,value:kn}]),(qe=xr.current)==null||qe.damage([{cell:be.location}]))}if(Hl.current||J.current===void 0)return!1;let Jn=!1;switch(He.activationBehaviorOverride??tt){case"double-click":case"second-click":{if(((Ze=(Mt=F==null?void 0:F.previousSelection)==null?void 0:Mt.current)==null?void 0:Ze.cell)===void 0)break;const[kn,ki]=J.current.cell,[Ui,Si]=F.previousSelection.current.cell;Jn=K===kn&&K===Ui&&X===ki&&X===Si&&(be.isDoubleClick===!0||tt==="second-click");break}case"single-click":{Jn=!0;break}}if(Jn)return S==null||S([K-G,X]),zl(be.bounds,!1),!0}return!1},ie=C.location[0]-G;if(C.isTouch){const be=ln.current,Ve=jw.current;if(be.x!==Ve.x||be.y!==Ve.y)return;if(C.isLongTouch===!0){if(C.kind==="cell"&&nc((Oe=J.current)==null?void 0:Oe.cell,C.location)){oe==null||oe([ie,C.location[1]],{...C,preventDefault:ee});return}else if(C.kind==="header"&&J.columns.hasIndex(K)){U==null||U(ie,{...C,preventDefault:ee});return}else if(C.kind===Hr){if(ie<0)return;N==null||N(ie,{...C,preventDefault:ee});return}}C.kind==="cell"?ae(C)||fu(C):C.kind===Hr?ne==null||ne(ie,{...C,preventDefault:ee}):(C.kind===to&&(I==null||I(ie,{...C,preventDefault:ee})),fu(C));return}if(C.kind==="header"){if(ie<0)return;C.isEdge?C.isDoubleClick===!0&&xf(K):C.button===0&&K===te&&X===Q&&(I==null||I(ie,{...C,preventDefault:ee}))}if(C.kind===Hr){if(ie<0)return;C.button===0&&K===te&&X===Q&&(ne==null||ne(ie,{...C,preventDefault:ee}),Hl.current||Hw(C))}C.kind==="cell"&&(C.button===0||C.button===1)&&ae(C),Wo.current=void 0},[a,J,G,Ho,Wl,wr,b,Fr,Ce,tt,cu,ei,S,zl,oe,U,N,fu,ne,I,xf,Hw]),SR=v.useCallback(C=>{const $={...C,location:[C.location[0]-G,C.location[1]]};rt==null||rt($),a!==void 0&&C.buttons===0&&(u(void 0),Qp(void 0),ng(void 0),du.current=!1),ng(F=>{var K;return du.current?[C.scrollEdge[0],0]:C.scrollEdge[0]===(F==null?void 0:F[0])&&C.scrollEdge[1]===F[1]?F:a===void 0||(((K=ti.current)==null?void 0:K.location[0])??0){dt==null||dt(C-G,$)},[dt,G]),Vi=(Qw=J==null?void 0:J.current)==null?void 0:Qw.cell,TR=v.useCallback((C,$,F,K,X,te)=>{It.current=!1;let Q=Vi;Q!==void 0&&(Q=[Q[0]-G,Q[1]]);const ee=Je===0?void 0:{x:0,y:C.y,width:Je,height:C.height},ae=[];ee!==void 0&&ae.push(ee),xt>0&&(ae.push({x:C.x-G,y:w-xt,width:C.width,height:xt}),Je>0&&ae.push({x:0,y:w-xt,width:Je,height:xt}));const ie={x:C.x-G,y:C.y,width:C.width,height:on&&C.y+C.height>=w?C.height-1:C.height,tx:X,ty:te,extras:{selected:Q,freezeRegion:ee,freezeRegions:ae}};ln.current=ie,Lr(ie),st([$,F,K]),Hn==null||Hn(ie,ie.tx,ie.ty,ie.extras)},[Vi,G,on,w,Je,xt,Lr,Hn]),ER=Ul(Ge,v.useCallback((C,$)=>{Ge==null||Ge(C-G,$-G),we!=="none"&&ye(Nt.fromSingleSelection($),void 0,!0)},[we,Ge,G,ye])),rg=v.useRef(!1),AR=v.useCallback(C=>{if(C.location[0]===0&&G>0){C.preventDefault();return}wt==null||wt({...C,location:[C.location[0]-G,C.location[1]]}),C.defaultPrevented()||(rg.current=!0),u(void 0)},[wt,G]),MR=v.useCallback(()=>{rg.current=!1},[]),ig=v.useRef(),sg=v.useCallback(C=>{var $,F,K;if(!DE(C,ig.current)&&(ig.current=C,!((($=ti==null?void 0:ti.current)==null?void 0:$.button)!==void 0&&ti.current.button>=1))){if(C.buttons!==0&&a!==void 0&&((F=ti.current)==null?void 0:F.location[0])===0&&C.location[0]===0&&G===1&&Qe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ti.current.location[1])&&J.rows.hasIndex(ti.current.location[1])){const X=Math.min(ti.current.location[1],C.location[1]),te=Math.max(ti.current.location[1],C.location[1])+1;xe(Nt.fromSingleSelection([X,te]),void 0,!1)}if(C.buttons!==0&&a!==void 0&&J.current!==void 0&&!rg.current&&!du.current&&(Re==="rect"||Re==="multi-rect")){const[X,te]=J.current.cell;let[Q,ee]=C.location;if(ee<0&&(ee=ln.current.y),a.fillHandle===!0&&((K=a.previousSelection)==null?void 0:K.current)!==void 0){const ae=a.previousSelection.current.range;ee=Math.min(ee,on?w-1:w);const ie=hB(ae,Q,ee,dn);Qp(ie)}else{if(on&&te===w)return;if(on&&ee===w)if(C.kind===Mh)ee--;else return;Q=Math.max(Q,G);const Se=Q-X,Oe=ee-te,be={x:Se>=0?X:Q,y:Oe>=0?te:ee,width:Math.abs(Se)+1,height:Math.abs(Oe)+1};se({...J.current,range:be},!0,!1,"drag")}}Lt==null||Lt({...C,location:[C.location[0]-G,C.location[1]]})}},[dn,a,G,Qe,J,Re,Lt,xe,on,w,se]),RR=v.useCallback(()=>{var Q,ee;const C=ig.current;if(C===void 0)return;const[$,F]=C.scrollEdge;let[K,X]=C.location;const te=ln.current;$===-1?K=((ee=(Q=te.extras)==null?void 0:Q.freezeRegion)==null?void 0:ee.x)??te.x:$===1&&(K=te.x+te.width),F===-1?X=Math.max(0,te.y):F===1&&(X=Math.min(w-1,te.y+te.height)),K=Oi(K,0,gt.length-1),X=Oi(X,0,w-1),sg({...C,location:[K,X]})},[gt.length,sg,w]);b6(bR,c,RR);const bi=v.useCallback(C=>{if(J.current===void 0)return;const[$,F]=C,[K,X]=J.current.cell,te=J.current.range;let Q=te.x,ee=te.x+te.width,ae=te.y,ie=te.y+te.height;if(F!==0)switch(F){case 2:{ie=w,ae=X,bn(0,ie,"vertical");break}case-2:{ae=0,ie=X+1,bn(0,ae,"vertical");break}case 1:{aeX+1?(ie--,bn(0,ie,"vertical")):(ae=Math.max(0,ae-1),bn(0,ae,"vertical"));break}default:Rc()}if($!==0)if($===2)ee=gt.length,Q=K,bn(ee-1-G,0,"horizontal");else if($===-2)Q=G,ee=K+1,bn(Q-G,0,"horizontal");else{let Se=[];if(On!==void 0){const Oe=On({x:Q,y:ae,width:ee-Q-G,height:ie-ae},Yn.current.signal);typeof Oe=="object"&&(Se=E6(Oe))}if($===1){let Oe=!1;if(Q0){const be=nl(Q+1,K+1).find(Ve=>!Se.includes(Ve-G));be!==void 0&&(Q=be,Oe=!0)}else Q++,Oe=!0;Oe&&bn(Q,0,"horizontal")}Oe||(ee=Math.min(gt.length,ee+1),bn(ee-1-G,0,"horizontal"))}else if($===-1){let Oe=!1;if(ee>K+1){if(Se.length>0){const be=nl(ee-1,K,-1).find(Ve=>!Se.includes(Ve-G));be!==void 0&&(ee=be,Oe=!0)}else ee--,Oe=!0;Oe&&bn(ee-G,0,"horizontal")}Oe||(Q=Math.max(G,Q-1),bn(Q-G,0,"horizontal"))}else Rc()}se({cell:J.current.cell,range:{x:Q,y:ae,width:ee-Q,height:ie-ae}},!0,!1,"keyboard-select")},[On,J,gt.length,G,w,bn,se]),Ks=v.useCallback((C,$,F,K)=>{const X=Qn-(F?0:1);if(C=Oi(C,G,Ft.length-1+G),$=Oi($,0,X),C===(Vi==null?void 0:Vi[0])&&$===(Vi==null?void 0:Vi[1]))return!1;if(K&&J.current!==void 0){const te=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&te.push(J.current.range),wr({...J,current:{cell:[C,$],range:{x:C,y:$,width:1,height:1},rangeStack:te}},!0)}else se({cell:[C,$],range:{x:C,y:$,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===C&&f.current[1]===$&&(f.current=void 0),bn(C-G,$),!0},[Qn,G,Ft.length,Vi,J,bn,wr,se]),OR=v.useCallback((C,$)=>{(i==null?void 0:i.cell)!==void 0&&C!==void 0&&ql(C)&&(ei([{location:i.cell,value:C}]),window.requestAnimationFrame(()=>{var X;(X=xr.current)==null||X.damage([{cell:i.cell}])})),ur(!0),s(void 0);const[F,K]=$;if(J.current!==void 0&&(F!==0||K!==0)){const X=J.current.cell[1]===Qn-1&&C!==void 0;Ks(Oi(J.current.cell[0]+F,0,gt.length-1),Oi(J.current.cell[1]+K,0,Qn-1),X,!1)}A==null||A(C,$)},[i==null?void 0:i.cell,ur,J,A,ei,Qn,Ks,gt.length]),PR=v.useMemo(()=>`gdg-overlay-${T6++}`,[]),Vo=v.useCallback(C=>{var F,K,X,te;ur();const $=[];for(let Q=C.x;Q({cell:Q.location})))},[ur,k,Ce,ei,G]),hu=i!==void 0,Uw=v.useCallback(C=>{var Ve,qe;const $=()=>{C.stopPropagation(),C.preventDefault()},F={didMatch:!1},{bounds:K}=C,X=J.columns,te=J.rows,Q=vi;if(!hu&&yt(Q.clear,C,F))wr(Qf,!1),Rt==null||Rt();else if(!hu&&yt(Q.selectAll,C,F))wr({columns:Nt.empty(),rows:Nt.empty(),current:{cell:((Ve=J.current)==null?void 0:Ve.cell)??[G,0],range:{x:G,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(yt(Q.search,C,F))(qe=o==null?void 0:o.current)==null||qe.focus({preventScroll:!0}),hf(!0);else if(yt(Q.delete,C,F)){const Mt=(j==null?void 0:j(J))??!0;if(Mt!==!1){const Ze=Mt===!0?J:Mt;if(Ze.current!==void 0){Vo(Ze.current.range);for(const He of Ze.current.rangeStack)Vo(He)}for(const He of Ze.rows)Vo({x:G,y:He,width:y.length,height:1});for(const He of Ze.columns)Vo({x:He,y:0,width:1,height:w})}}if(F.didMatch)return $(),!0;if(J.current===void 0)return!1;let[ee,ae]=J.current.cell,ie=!1,Se=!1;yt(Q.scrollToSelectedCell,C,F)?Sf.current(ee-G,ae):we!=="none"&&yt(Q.selectColumn,C,F)?X.hasIndex(ee)?ye(X.remove(ee),void 0,!0):we==="single"?ye(Nt.fromSingleSelection(ee),void 0,!0):ye(void 0,ee,!0):Qe!=="none"&&yt(Q.selectRow,C,F)?te.hasIndex(ae)?xe(te.remove(ae),void 0,!0):Qe==="single"?xe(Nt.fromSingleSelection(ae),void 0,!0):xe(void 0,ae,!0):!hu&&K!==void 0&&yt(Q.activateCell,C,F)?ae===w&&on?window.setTimeout(()=>{const Mt=wf(ee);Bl(Mt??ee)},0):(S==null||S([ee-G,ae]),zl(K,!0)):J.current.range.height>1&&yt(Q.downFill,C,F)?Vw():J.current.range.width>1&&yt(Q.rightFill,C,F)?Ww():yt(Q.goToNextPage,C,F)?ae+=Math.max(1,ln.current.height-4):yt(Q.goToPreviousPage,C,F)?ae-=Math.max(1,ln.current.height-4):yt(Q.goToFirstCell,C,F)?(s(void 0),ae=0,ee=0):yt(Q.goToLastCell,C,F)?(s(void 0),ae=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):yt(Q.selectToFirstCell,C,F)?(s(void 0),bi([-2,-2])):yt(Q.selectToLastCell,C,F)?(s(void 0),bi([2,2])):hu?(yt(Q.closeOverlay,C,F)&&s(void 0),yt(Q.acceptOverlayDown,C,F)&&(s(void 0),ae++),yt(Q.acceptOverlayUp,C,F)&&(s(void 0),ae--),yt(Q.acceptOverlayLeft,C,F)&&(s(void 0),ee--),yt(Q.acceptOverlayRight,C,F)&&(s(void 0),ee++)):(yt(Q.goDownCell,C,F)?ae+=1:yt(Q.goUpCell,C,F)?ae-=1:yt(Q.goRightCell,C,F)?ee+=1:yt(Q.goLeftCell,C,F)?ee-=1:yt(Q.goDownCellRetainSelection,C,F)?(ae+=1,ie=!0):yt(Q.goUpCellRetainSelection,C,F)?(ae-=1,ie=!0):yt(Q.goRightCellRetainSelection,C,F)?(ee+=1,ie=!0):yt(Q.goLeftCellRetainSelection,C,F)?(ee-=1,ie=!0):yt(Q.goToLastRow,C,F)?ae=w-1:yt(Q.goToFirstRow,C,F)?ae=Number.MIN_SAFE_INTEGER:yt(Q.goToLastColumn,C,F)?ee=Number.MAX_SAFE_INTEGER:yt(Q.goToFirstColumn,C,F)?ee=Number.MIN_SAFE_INTEGER:(Re==="rect"||Re==="multi-rect")&&(yt(Q.selectGrowDown,C,F)?bi([0,1]):yt(Q.selectGrowUp,C,F)?bi([0,-1]):yt(Q.selectGrowRight,C,F)?bi([1,0]):yt(Q.selectGrowLeft,C,F)?bi([-1,0]):yt(Q.selectToLastRow,C,F)?bi([0,2]):yt(Q.selectToFirstRow,C,F)?bi([0,-2]):yt(Q.selectToLastColumn,C,F)?bi([2,0]):yt(Q.selectToFirstColumn,C,F)&&bi([-2,0])),Se=F.didMatch);const Oe=Ks(ee,ae,!1,ie),be=F.didMatch;return be&&(Oe||!Se||lf)&&$(),be},[hu,J,vi,we,Qe,Re,G,w,Ks,wr,Rt,y.length,j,lf,Vo,ye,xe,on,wf,Bl,S,zl,Vw,Ww,bi]),pu=v.useCallback(C=>{let $=!1;if(Me!==void 0&&Me({...C,cancel:()=>{$=!0}}),$||Uw(C)||J.current===void 0)return;const[F,K]=J.current.cell,X=ln.current;if(ft&&!C.metaKey&&!C.ctrlKey&&J.current!==void 0&&C.key.length===1&&/[ -~]/g.test(C.key)&&C.bounds!==void 0&&Bu(k([F-G,Math.max(0,Math.min(K,w-1))]))){if((!on||K!==w)&&(X.y>K||K>X.y+X.height||X.x>F||F>X.x+X.width))return;zl(C.bounds,!0,C.key),C.stopPropagation(),C.preventDefault()}},[ft,Me,Uw,J,k,G,w,on,zl]),IR=v.useCallback((C,$)=>{const F=C.location[0]-G;if(C.kind==="header"&&(U==null||U(F,{...C,preventDefault:$})),C.kind===Hr){if(F<0)return;N==null||N(F,{...C,preventDefault:$})}if(C.kind==="cell"){const[K,X]=C.location;oe==null||oe([F,X],{...C,preventDefault:$}),u$(J,C.location)||Ks(K,X,!1,!1)}},[J,oe,N,U,G,Ks]),og=v.useCallback(async C=>{var Q,ee,ae;if(!vi.paste)return;function $(ie,Se,Oe,be){var qe,Mt;const Ve=typeof Oe=="object"?(Oe==null?void 0:Oe.join(` -`))??"":(Oe==null?void 0:Oe.toString())??"";if(!ca(ie)&&Bu(ie)&&ie.readonly!==!0){const Ze=M==null?void 0:M(Ve,ie);if(Ze!==void 0&&ql(Ze))return{location:Se,value:Ze};const He=Ce(ie);if(He===void 0)return;if(He.kind===ke.Custom){Wr(ie.kind===ke.Custom);const Qt=(qe=He.onPaste)==null?void 0:qe.call(He,Ve,ie.data);return Qt===void 0?void 0:{location:Se,value:{...ie,data:Qt}}}else{const Qt=(Mt=He.onPaste)==null?void 0:Mt.call(He,Ve,ie,{formatted:be,formattedString:typeof be=="string"?be:be==null?void 0:be.join(` -`),rawValue:Oe});return Qt===void 0?void 0:(Wr(Qt.kind===ie.kind),{location:Se,value:Qt})}}}const F=J.columns,K=J.rows,X=((Q=c.current)==null?void 0:Q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0;let te;if(J.current!==void 0?te=[J.current.range.x,J.current.range.y]:F.length===1?te=[F.first()??0,0]:K.length===1&&(te=[G,K.first()??0]),X&&te!==void 0){let ie,Se;const Oe="text/plain",be="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const He of Ze){if(He.types.includes(be)){const Jn=await(await He.getType(be)).text(),kn=_b(Jn);if(kn!==void 0){ie=kn;break}}He.types.includes(Oe)&&(Se=await(await He.getType(Oe)).text())}}else if(navigator.clipboard.readText!==void 0)Se=await navigator.clipboard.readText();else if(C!==void 0&&(C==null?void 0:C.clipboardData)!==null){if(C.clipboardData.types.includes(be)){const Ze=C.clipboardData.getData(be);ie=_b(Ze)}ie===void 0&&C.clipboardData.types.includes(Oe)&&(Se=C.clipboardData.getData(Oe))}else return;const[Ve,qe]=te,Mt=[];do{if(me===void 0){const Ze=Fr(te),He=Se??(ie==null?void 0:ie.map(Jn=>Jn.map(kn=>kn.rawValue).join(" ")).join(" "))??"",Qt=$(Ze,te,He,void 0);Qt!==void 0&&Mt.push(Qt);break}if(ie===void 0){if(Se===void 0)return;ie=p6(Se)}if(me===!1||typeof me=="function"&&(me==null?void 0:me([te[0]-G,te[1]],ie.map(Ze=>Ze.map(He=>{var Qt;return((Qt=He.rawValue)==null?void 0:Qt.toString())??""}))))!==!0)return;for(const[Ze,He]of ie.entries()){if(Ze+qe>=w)break;for(const[Qt,Jn]of He.entries()){const kn=[Qt+Ve,Ze+qe],[ki,Ui]=kn;if(ki>=gt.length||Ui>=Qn)continue;const Si=Fr(kn),Ki=$(Si,kn,Jn.rawValue,Jn.formatted);Ki!==void 0&&Mt.push(Ki)}}}while(!1);ei(Mt),(ae=xr.current)==null||ae.damage(Mt.map(Ze=>({cell:Ze.location})))}},[M,Ce,Fr,J,vi.paste,gt.length,ei,Qn,me,G,w]);Vn("paste",og,d,!1,!0);const gu=v.useCallback(async(C,$)=>{var Q,ee;if(!vi.copy)return;const F=$===!0||((Q=c.current)==null?void 0:Q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,K=J.columns,X=J.rows,te=(ae,ie)=>{if(!Ne)Fb(ae,ie,C);else{const Se=ie.map(Oe=>({kind:ke.Text,data:y[Oe].title,displayData:y[Oe].title,allowOverlay:!1}));Fb([Se,...ae],ie,C)}};if(F&&On!==void 0){if(J.current!==void 0){let ae=On(J.current.range,Yn.current.signal);typeof ae!="object"&&(ae=await ae()),te(ae,nl(J.current.range.x-G,J.current.range.x+J.current.range.width-G))}else if(X!==void 0&&X.length>0){const ie=[...X].map(Se=>{const Oe=On({x:G,y:Se,width:y.length,height:1},Yn.current.signal);return typeof Oe=="object"?Oe[0]:Oe().then(be=>be[0])});if(ie.some(Se=>Se instanceof Promise)){const Se=await Promise.all(ie);te(Se,nl(y.length))}else te(ie,nl(y.length))}else if(K.length>0){const ae=[],ie=[];for(const Se of K){let Oe=On({x:Se,y:0,width:1,height:w},Yn.current.signal);typeof Oe!="object"&&(Oe=await Oe()),ae.push(Oe),ie.push(Se-G)}if(ae.length===1)te(ae[0],ie);else{const Se=ae.reduce((Oe,be)=>Oe.map((Ve,qe)=>[...Ve,...be[qe]]));te(Se,ie)}}}},[y,On,J,vi.copy,G,w,Ne]);Vn("copy",gu,d,!1,!1);const NR=v.useCallback(async C=>{var F,K;if(!(!vi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((K=l.current)==null?void 0:K.contains(document.activeElement))===!0))&&(await gu(C),J.current!==void 0)){let X={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:Nt.empty(),columns:Nt.empty()};const te=j==null?void 0:j(X);if(te===!1||(X=te===!0?X:te,X.current===void 0))return;Vo(X.current.range)}},[Vo,J,vi.cut,gu,j]);Vn("cut",NR,d,!1,!1);const DR=v.useCallback((C,$)=>{if(B!==void 0){G!==0&&(C=C.map(X=>[X[0]-G,X[1]])),B(C,$);return}if(C.length===0||$===-1)return;const[F,K]=C[$];f.current!==void 0&&f.current[0]===F&&f.current[1]===K||(f.current=[F,K],Ks(F,K,!1,!1))},[B,G,Ks]),[bf,kf]=((Jw=Pt==null?void 0:Pt.current)==null?void 0:Jw.cell)??[],Sf=v.useRef(bn);Sf.current=bn,v.useLayoutEffect(()=>{var C,$,F,K;!It.current&&bf!==void 0&&kf!==void 0&&(bf!==(($=(C=Vs.current)==null?void 0:C.current)==null?void 0:$.cell[0])||kf!==((K=(F=Vs.current)==null?void 0:F.current)==null?void 0:K.cell[1]))&&Sf.current(bf,kf),It.current=!1},[bf,kf]);const Kw=J.current!==void 0&&(J.current.cell[0]>=gt.length||J.current.cell[1]>=Qn);v.useLayoutEffect(()=>{Kw&&wr(Qf,!1)},[Kw,wr]);const _R=v.useMemo(()=>on===!0&&(ut==null?void 0:ut.tint)===!0?Nt.fromSingleSelection(Qn-1):Nt.empty(),[Qn,on,ut==null?void 0:ut.tint]),LR=v.useCallback(C=>typeof ze=="boolean"?ze:(ze==null?void 0:ze(C-G))??!0,[G,ze]),FR=v.useMemo(()=>{if(eg===void 0||l.current===null)return null;const{bounds:C,group:$}=eg,F=l.current.getBoundingClientRect();return v.createElement(r6,{bounds:C,group:$,canvasBounds:F,onClose:()=>tg(void 0),onFinish:K=>{tg(void 0),L==null||L($,K)}})},[L,eg]),$R=Math.min(gt.length,Je+(Dr?1:0));v.useImperativeHandle(e,()=>({appendRow:(C,$)=>Bl(C+G,$),updateCells:C=>{var $;return G!==0&&(C=C.map(F=>({cell:[F.cell[0]+G,F.cell[1]]}))),($=xr.current)==null?void 0:$.damage(C)},getBounds:(C,$)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(C===void 0&&$===void 0){const K=l.current.getBoundingClientRect(),X=K.width/c.current.clientWidth;return{x:K.x-c.current.scrollLeft*X,y:K.y-c.current.scrollTop*X,width:c.current.scrollWidth*X,height:c.current.scrollHeight*X}}return(F=xr.current)==null?void 0:F.getBounds((C??0)+G,$)}},focus:()=>{var C;return(C=xr.current)==null?void 0:C.focus()},emit:async C=>{switch(C){case"delete":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await gu(void 0,!0);break;case"paste":await og();break}},scrollTo:bn,remeasureColumns:C=>{for(const $ of C)xf($+G)}}),[Bl,xf,gu,pu,og,G,bn]);const[Xw,Gw]=Vi??[],zR=v.useCallback(C=>{const[$,F]=C;if(F===-1){we!=="none"&&(ye(Nt.fromSingleSelection($),void 0,!1),ur());return}Xw===$&&Gw===F||(se({cell:C,range:{x:$,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),bn($,F))},[we,ur,bn,Xw,Gw,se,ye]),[BR,jR]=v.useState(!1),qw=v.useRef(zT(C=>{jR(C)},5)),HR=v.useCallback(()=>{qw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&se({cell:[G,pf],range:{x:G,y:pf,width:1,height:1}},!0,!1,"keyboard-select")},[pf,J,a,G,se]),WR=v.useCallback(()=>{qw.current(!1)},[]),[VR,UR]=v.useMemo(()=>{let C;const $=(We==null?void 0:We.scrollbarWidthOverride)??P0(),F=w+(on?1:0);if(typeof ar=="number")C=ct+F*ar;else{let X=0;const te=Math.min(F,10);for(let Q=0;Qte.width+X,0)+$;return[`${Math.min(1e5,K)}px`,`${Math.min(1e5,C)}px`]},[gt,We==null?void 0:We.scrollbarWidthOverride,ar,w,on,ct]),KR=v.useMemo(()=>C$(de),[de]);return v.createElement(T$.Provider,{value:de},v.createElement(v6,{style:KR,className:W,inWidth:x??VR,inHeight:g??UR},v.createElement(ZW,{fillHandle:Le,drawFocusRing:Ee,experimental:We,fixedShadowX:at,fixedShadowY:Ot,getRowThemeOverride:p,headerIcons:Xt,imageWindowLoader:Nn,initialSize:vr,isDraggable:Mn,onDragLeave:ms,onRowMoved:qn,overscrollX:Up,overscrollY:df,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:js,smoothScrollX:af,smoothScrollY:jp,className:W,enableGroups:zt,onCanvasFocused:HR,onCanvasBlur:WR,canvasRef:l,onContextMenu:IR,theme:de,cellXOffset:jo,cellYOffset:pf,accessibilityHeight:xn.height,onDragEnd:MR,columns:gt,nonGrowWidth:Be,drawHeader:qp,onColumnProposeMove:D,drawCell:Yp,disabledRows:_R,freezeColumns:$R,lockColumns:G,firstColAccessible:G===0,getCellContent:Fr,minColumnWidth:Nr,maxColumnWidth:yi,searchInputRef:o,showSearch:au,onSearchClose:Xp,highlightRegions:wR,getCellsForSelection:On,getGroupDetails:Jp,headerHeight:Dl,isFocused:BR,groupHeaderHeight:zt?lu:0,freezeTrailingRows:xt+(on&&(ut==null?void 0:ut.sticky)===!0?1:0),hasAppendRow:on,onColumnResize:wi,onColumnResizeEnd:Gp,onColumnResizeStart:Ll,onCellFocused:zR,onColumnMoved:ER,onDragStart:AR,onHeaderMenuClick:CR,onItemHovered:sg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:SR,onKeyDown:pu,onKeyUp:Fe,onMouseDown:xR,onMouseUp:kR,onDragOverCell:An,onDrop:z,onSearchResultsChanged:DR,onVisibleRegionChanged:TR,clientSize:Ae,rowHeight:ar,searchResults:V,searchValue:ge,onSearchValueChange:le,rows:Qn,scrollRef:c,selection:J,translateX:xn.tx,translateY:xn.ty,verticalBorder:LR,gridRef:xr,getCellRenderer:Ce}),FR,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(C6,{...i,validateCell:uu,bloom:P,id:PR,getCellRenderer:Ce,className:(We==null?void 0:We.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Bt,imageEditorOverride:h,onFinishEditing:OR,markdownDivCreateNode:m,isOutsideClick:uf}))))},M6=v.forwardRef(A6),Bb=20,R6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:ke.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>O6(t,t.cell.data,E0(t.cell),t.cell.maxSize??Bb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Bb,f=Math.floor(i.y+l/2),d=HT(c,l,s.cellVerticalPadding),h=jT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=BT(h,f,d),m=WT(a+n,u+r,p);if(E0(e)&&m)return{...e,data:LE(e.data)}},onPaste:(t,e)=>{let n=gh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Wv),n===e.data?void 0:{...e,data:n}}};function O6(t,e,n,r){if(!n&&e===gh)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:m}=l,x=.35;let g=n?1-x+x*s:.4;e===gh&&(g*=s),g!==0&&(i.globalAlpha=g,rw(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const P6=Qr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),I6=t=>{const{bubbles:e}=t;return v.createElement(P6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},N6={getAccessibilityString:t=>VT(t.data),kind:ke.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>_6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(I6,{bubbles:e.data})},onPaste:()=>{}},D6=4;function _6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=D6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=Zc(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)cs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+Bs(i,r))}const L6=Qr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),F6=t=>{const{drilldowns:e}=t;return v.createElement(L6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&v.createElement("img",{src:n.img}),v.createElement("div",null,n.text))))},$6={getAccessibilityString:t=>VT(t.data.map(e=>e.text)),kind:ke.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>j6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(F6,{drilldowns:e.data})},onPaste:()=>{}},z6=4,em={};function B6(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(em[d]!==void 0)return{el:em[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),em[d]=h,p.beginPath(),cs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),cs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function j6(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=rE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,m=8,x=z6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=B6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=Zc(b.text,i,c).width;let A=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+m*2;k.push({x:g,width:M}),g+=M+x}if(w!==null){const{el:b,height:S,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:_}=w,P=A/O,I=_/O;for(const D of k){const Z=Math.floor(D.x),ne=Math.floor(D.width),oe=ne-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,A,S,Z-I,h,P,d),oe>0&&i.drawImage(b,A,0,T,S,Z+(P-I),h,oe,d),i.drawImage(b,M-A,0,A,S,Z+ne-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,S]of k.entries()){const T=e[b];let A=S.x+m;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const O=p-8;let _=0,P=0,I=M.width,D=M.height;I>D?(_+=(I-D)/2,I=D):D>I&&(P+=(D-I)/2,D=I),i.beginPath(),cs(i,A,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,_,P,I,D,A,h+d/2-O/2,O,O),i.restore(),A+=O+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+Bs(i,r))}}const H6={getAccessibilityString:t=>t.data.join(", "),kind:ke.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>W6(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??N4;return v.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},tm=4;function W6(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,m=[];let x=0;for(let y=0;y0&&(a.beginPath(),cs(a,g,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(y,g,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),g+=w+tm}}function V6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const U6={getAccessibilityString:()=>"",kind:ke.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(V6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);cs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=wl(o.textDark,.1),i.fill()},onPaste:()=>{}},K6=()=>t=>t.targetWidth,jb=Qr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[K6(),"px"]}}),X6=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=v.useState(a===""||r),d=v.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?v.createElement(jb,{targetWidth:s.width-20},v.createElement(Cp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),v.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},v.createElement(E4,null))):v.createElement(jb,{targetWidth:s.width},v.createElement(J4,{contents:a,createNode:i}),!u&&v.createElement(v.Fragment,null,v.createElement("div",{className:"spacer"}),v.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},v.createElement(Gv,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},G6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:ef,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>As(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return v.createElement(X6,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},q6={getAccessibilityString:t=>t.row.toString(),kind:oi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:Y6,measure:()=>44,draw:t=>J6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function Y6(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=Q6,n.textAlign="center",s}function Q6(t){const{ctx:e}=t;e.textAlign="start"}function J6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(rw(o,u,n,i?c+m:c,f,i?d-m:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const g of[-5,-1,3])o.rect(c+x,f+h/2+g,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,g=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,g,f+h/2+Bs(o,x)),a!==0&&(o.globalAlpha=1)}}const Z6={getAccessibilityString:()=>"",kind:oi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>e9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function e9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const m=f-8,x=a+8/2,g=u+8/2;l.drawSprite(n,"normal",r,x,g,m,o,d?1:s),h=m}else{h=24;const p=12,m=d?p:s*p,x=d?0:(1-s)*p*.5,g=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+g+x,u+f/2),r.lineTo(a+g+x+m,u+f/2),r.moveTo(a+g+x+m*.5,u+f/2-m*.5),r.lineTo(a+g+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+Bs(r,o)),r.beginPath()}const t9=v.lazy(async()=>await uE(()=>import("./number-overlay-editor-TWdf9NmZ.js"),[])),n9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:ef,draw:t=>As(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return v.createElement(v.Suspense,{fallback:null},v.createElement(t9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},r9={getAccessibilityString:()=>"",measure:()=>108,kind:ke.Protected,needsHover:!1,needsHoverPosition:!1,draw:i9,onPaste:()=>{}};function i9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Hx(30))*l,f=Math.sin(Hx(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const s9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>ef(t,e,t.theme.textLight),draw:t=>As(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Ln.createElement(Cp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},o9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:ef,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=Zc(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),cs(i,s.x+d/2,s.y+(s.height-x)/2+1,p.width+d*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=wl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}As(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` -`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return v.createElement(Cp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},l9=Qr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),a9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=v.useState(!i&&(e===""||r)),u=v.useCallback(()=>{a(!0)},[]);return l?v.createElement(Cp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(l9,null,v.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&v.createElement("div",{className:"gdg-edit-icon",onClick:u},v.createElement(Gv,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Hb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const u9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:ef,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=Zc(a,l,n.baseFontFull),f=Hb(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:m}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+m+8){const x=Bs(l,n.baseFontFull);r("pointer");const g=5,y=h-x;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+y+m+g)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+y+m+g)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,As({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),As({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),As({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),As({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,As(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=m$(o,s.baseFontFull);if(l===void 0)return;const a=Hb(l,n,s,e.contentAlign);Ep({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return v.createElement(a9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},c9=[q6,Z6,R6,N6,$6,H6,U6,G6,n9,r9,s9,o9,u9];var f9=$T,d9=El,h9="Expected a function";function p9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(h9);return d9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),f9(t,e,{leading:r,maxWait:e,trailing:i})}var g9=p9;const m9=Bi(g9),nm=[];class y9 extends sE{constructor(){super(...arguments);bt(this,"imageLoaded",()=>{});bt(this,"loadedLocations",[]);bt(this,"cache",{});bt(this,"sendLoaded",m9(()=>{this.imageLoaded(new ic(this.loadedLocations)),this.loadedLocations=[]},20));bt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,nm.length<12?nm.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(ew(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Pi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const rm="\uFEFF";function v9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function w9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=r.length)break;if(r[y]===s){c=y+1,f=!0;continue}c=r[y]==="\r"&&r[y+1]===` -`?y+2:y+1,o.push(a),l.push({start:u+i,end:y+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const d=o.length>0?o[0]:[],h=d.length,p=o.slice(1),m=p.map(g=>g.length),x=p.map(g=>g.length===h?g:g.length>h?g.slice(0,h):[...g,...Array(h-g.length).fill("")]);return{headers:d,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function Ap(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` -`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function im(t,e,n=","){return[t,...e].map(r=>Ap(r,n)).join(` -`)}function ow(t,e){return tf(t,e).headers}function x9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function FE(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function b9(t,e){return t[e]==="\r"?t[e+1]===` -`?2:1:t[e]===` -`?1:0}function Wb(t,e){return t[e-2]==="\r"&&t[e-1]===` -`?2:t[e-1]==="\r"||t[e-1]===` -`?1:0}const Vb="\uFEFF";function $E(t,e){const n=t.startsWith(Vb)?Vb.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Wb(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Wb(t,t.length)}}function sm(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+b9(t,i.end),replacement:""}));return r.length===0?t:FE(t,r)}function Ub(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:Ap(a,e.delimiter)})}return FE(t,s)}function k9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=$E(t,e),s=ow(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=Ap(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const V0=50;function Go(t=""){return{past:[],present:t,future:[]}}function Kb(t,e,n=V0){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function S9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function C9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>V0?r.slice(r.length-V0):r,present:e,future:n}}function T9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const Xb=/^[+-]?\d{16,}$/;function E9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),m=Number.isNaN(h);if(p||m)return p&&m?0:p?1:-1;if(Xb.test(a)&&Xb.test(u)){const x=BigInt(a),g=BigInt(u);return s*(xg?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const M9=` - -`;function Jf(t,e){return Math.max(0,Math.min(t,e))}function Gb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Jf(a.x,r+i),c=Jf(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=Jf(a.y,e.length),p=Jf(a.y+a.height,e.length);if(p<=h)continue;const m=t.headers.slice(f,d),x=[];for(let g=h;gw[f+b]??""))}x.length!==0&&s.push(im(m,x,t.delimiter))}if(s.length>0)return s.join(M9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return im(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return im(a,u,t.delimiter)}return null}const qo=1e5,R9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function O9(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const m of n.ranges){if(o.size>=qo)break;const x=Math.max(0,m.x-r),g=Math.min(i,m.x+m.width-r);if(g<=x)continue;const y=Math.max(0,m.y),w=Math.min(s,m.y+m.height);if(!(w<=y))for(let k=y;k=qo);k++){const b=k*i;for(let S=x;S=qo));S++);}}for(const m of n.rows){if(o.size>=qo)break;if(m<0||m>=s)continue;const x=m*i;for(let g=0;g=qo));g++);}for(const m of n.columns){if(o.size>=qo)break;const x=m-r;if(!(x<0||x>=i))for(let g=0;g=qo));g++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const m of o){const x=Math.floor(m/i),g=m%i,y=e[x],k=((y!==void 0?(p=t.rows[y])==null?void 0:p[g]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),R9.test(k)){const b=Number(k);Number.isFinite(b)&&(u+=1,c+=b,(f===null||bd)&&(d=b))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const qb=24,om=26,Yb=110,lm=40,P9=12,zn=1,Qb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Jb='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',I9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function Zb(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function ek(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Xl="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",_d=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function Zf(t){return _d.format(Object.is(t,-0)?0:t)}function N9(t){const e=[`Cells: ${_d.format(t.cellCount)}`,`Distinct: ${_d.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${_d.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${Zf(t.sum)}`,`Avg: ${Zf(t.avg)}`,`Min: ${Zf(t.min)}`,`Max: ${Zf(t.max)}`),e.join(" · ")}function D9(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Jb,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Jb,lineHeight:1}}function _9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function zE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u}){const c=v.useRef(null),f=v.useRef(null),d=v.useRef(null),[h,p]=v.useState(""),[m,x]=v.useState(""),[g,y]=v.useState(null),w=v.useRef(g);w.current=g;const k=v.useRef(null),[b,S]=v.useState(null),[T,A]=v.useState(""),M=v.useRef(null),[O,_]=v.useState(void 0),[P,I]=v.useState(()=>new Set),D=v.useRef(P),[Z,ne]=v.useState(0),[oe,W]=v.useState({}),U=i!==void 0,R=a??oe,N=v.useCallback(z=>{W(z),u==null||u(z)},[u]),L=v.useMemo(()=>D9(r),[r]),H=_9(r),q=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",B=v.useRef();B.current===void 0&&(B.current=new y9);const V=v.useMemo(()=>tf(t,e),[t,e]),le=v.useMemo(()=>x9(V),[V]),ge=V.headers.length,Me=v.useRef({text:t,table:V});Me.current={text:t,table:V};const Fe=v.useRef(O);Fe.current=O,v.useEffect(()=>{const z=window.setTimeout(()=>x(h),150);return()=>window.clearTimeout(z)},[h]);const _e=v.useMemo(()=>{const z=E9(V.rows,m);return g?A9(z,V.rows,g.col,g.dir,le[g.col]??!1):z},[V,m,g,le]),ft=v.useRef(_e);ft.current=_e,v.useEffect(()=>{const z=f.current;if(!z||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>ne(z.clientWidth));return ue.observe(z),ne(z.clientWidth),()=>ue.disconnect()},[]);const Xe=Math.max(Yb,Math.floor((Z-lm)/Math.max(1,ge)));v.useEffect(()=>{I(z=>{let ue=!1;const Y=new Set;for(const ce of z)ce{_(z=>{if(!z||z.rows.length===0)return z;const ue=[];for(const ce of D.current){const fe=_e.indexOf(ce);fe!==-1&&ue.push(fe)}ue.sort((ce,fe)=>ce-fe);const Y=ue.reduce((ce,fe)=>ce.add(fe),Nt.empty());return Y.equals(z.rows)?z:{...z,rows:Y}})},[_e]),v.useEffect(()=>{y(z=>z!==null&&z.col>=ge?null:z),S(z=>z!==null&&z.col>=ge?null:z)},[ge]);const Ge=m!=="",lt=V.rows.length,Ut=om+Math.min(_e.length,P9)*qb,Re=()=>{p(""),x("")},we=v.useCallback((z,ue)=>{var ce;if(z0||Le.height>0)?{x:Math.max(0,Ee.x-Le.left),y:Math.max(0,Ee.y-Le.top),width:Ee.width,height:Ee.height}:Ee??{x:lm+Y*Xe,y:0,width:Xe,height:om};A(fe),S({col:Y,bounds:We});return}k.current=w.current,S(null),y(fe=>!fe||fe.col!==Y?{col:Y,dir:"asc"}:fe.dir==="asc"?{col:Y,dir:"desc"}:null)},[U,Xe]),Qe=v.useCallback(()=>{if(!b)return;const{col:z}=b;if(S(null),!i)return;const{text:ue,table:Y}=Me.current,ce=Y.headers[z]??"",fe=k9(ue,Y,z,T);if(fe!==ue){if(ce!==""&&ce!==T&&R[ce]!==void 0){const Le={...R},Ee=Le[ce];delete Le[ce],T!==""&&Ee!==void 0&&(Le[T]=Ee),N(Le)}i(fe)}},[b,T,i,R,N]),nt=v.useCallback(()=>{S(null)},[]);v.useEffect(()=>{if(!b)return;const z=M.current;z&&(z.focus(),z.select())},[b]);const it=v.useCallback((z,ue)=>{const Y=ft.current,ce=Y[ue];if(ce===void 0)return;const fe=D.current,Le=d.current;let Ee;if(z.shiftKey&&Le!==null&&Le!==ce){const at=Y.indexOf(Le),Ot=Y.indexOf(ce),Xt=at===-1?Ot:at,[Nn,vr]=Xt<=Ot?[Xt,Ot]:[Ot,Xt];Ee=z.metaKey||z.ctrlKey?new Set(fe):new Set;for(let Mn=Nn;Mn<=vr;Mn++){const ms=Y[Mn];ms!==void 0&&Ee.add(ms)}}else z.metaKey||z.ctrlKey?(Ee=new Set(fe),Ee.has(ce)?Ee.delete(ce):Ee.add(ce)):Ee=new Set([ce]);d.current=ce,D.current=Ee,I(Ee);const We=[...Ee].map(at=>Y.indexOf(at)).filter(at=>at!==-1).sort((at,Ot)=>at-Ot);_(at=>({current:at==null?void 0:at.current,columns:(at==null?void 0:at.columns)??Nt.empty(),rows:We.reduce((Ot,Xt)=>Ot.add(Xt),Nt.empty())}))},[]),$e=v.useCallback(()=>{d.current=null,D.current=new Set,I(new Set),_(void 0)},[]),At=v.useCallback(z=>{const ue=new Set;for(const Y of z.rows){const ce=ft.current[Y];ce!==void 0&&ue.add(ce)}D.current=ue,I(ue),_(z)},[]),wt=v.useCallback(()=>{$e()},[$e]),rt=v.useMemo(()=>_e.filter(z=>P.has(z)),[_e,P]),me=v.useMemo(()=>[...(O==null?void 0:O.columns)??[]].filter(z=>z>=zn).map(z=>z-zn),[O]),Ne=me.length,Je=v.useMemo(()=>me.map(z=>V.headers[z]).filter(z=>z!==void 0),[me,V.headers]),tt=v.useMemo(()=>{if(Je.length===0)return null;const z=R[Je[0]]??"auto";for(let ue=1;ue{if(!U||Je.length===0)return;const ue={...R};for(const Y of Je)z==="auto"?delete ue[Y]:ue[Y]=z;N(ue)},[U,Je,R,N]),dt=v.useMemo(()=>U?V.headers.filter(z=>Zb(R[z])!==null).length:0,[U,V.headers,R]),ht=v.useMemo(()=>({ranges:O!=null&&O.current?[O.current.range,...O.current.rangeStack]:[],columns:O?[...O.columns]:[],rows:P.size>0?_e.reduce((z,ue,Y)=>(P.has(ue)&&z.push(Y),z),[]):O?[...O.rows]:[]}),[O,P,_e]),pt=zn,Lt=v.useMemo(()=>O9(V,_e,ht,pt),[V,_e,ht,pt]),Rt=rt.length>0||Ne>0||Lt!==null,en=v.useRef(l);en.current=l;const Hn=()=>{var Y,ce;const z=Fe.current,ue=Gb(Me.current.table,ft.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},zn);ue!==null&&((Y=en.current)==null||Y.call(en),(ce=navigator.clipboard)==null||ce.writeText(ue).catch(()=>{}))};v.useEffect(()=>{const z=ue=>{var Ee,We;const Y=c.current;if(!Y||!Y.contains(document.activeElement))return;const ce=document.activeElement;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable))return;const fe=Fe.current,Le=Gb(Me.current.table,ft.current,{ranges:fe!=null&&fe.current?[fe.current.range,...fe.current.rangeStack]:[],columns:fe?[...fe.columns]:[],rows:fe?[...fe.rows]:[]},zn);Le!==null&&(ue.preventDefault(),ue.stopImmediatePropagation(),(Ee=ue.clipboardData)==null||Ee.setData("text/plain",Le),(We=en.current)==null||We.call(en))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const z=ue=>{const Y=c.current;if(!Y)return;const ce=ue.target instanceof Node&&Y.contains(ue.target),fe=document.activeElement instanceof Node&&Y.contains(document.activeElement);if(!ce&&!fe||ek(ue.target)||ek(document.activeElement))return;const Le=T9(ue);Le==="undo"&&s?(ue.preventDefault(),s()):Le==="redo"&&o&&(ue.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Pt=v.useCallback(z=>{var Y;const ue=c.current!==null&&document.activeElement instanceof Node&&c.current.contains(document.activeElement);$e(),i==null||i(z),ue&&((Y=f.current)==null||Y.focus({preventScroll:!0}))},[$e,i]),vn=ge>0&&me.length>=ge,In=()=>{!U||rt.length===0||Pt(sm(Me.current.text,Me.current.table,rt))},Pr=()=>{!U||vn||me.length===0||Pt(Ub(Me.current.text,Me.current.table,me))},Ir=v.useCallback(z=>{if(!i)return!1;const{text:Y,table:ce}=Me.current,fe=ft.current;if(z.rows.length>0){const We=[...z.rows].map(at=>fe[at]).filter(at=>at!==void 0);if(We.length>0)return Pt(sm(Y,ce,We)),!1}if(z.columns.length>0){const We=[...z.columns].filter(at=>at>=zn&&atat-zn);return We.length>0&&We.length0&&Pt(sm(Y,ce,Ee)),!1},[Pt,i]),Bt=v.useCallback(z=>{const ue=i;if(!ue)return!1;const{text:Y,table:ce}=Me.current,fe=ft.current,Le=[...z].sort((at,Ot)=>at.location[1]-Ot.location[1]);let Ee=Y,We=0;for(const{location:at,value:Ot}of Le){const Xt=at[0]-zn,Nn=at[1];if(Xt<0||Ot.kind!==ke.Text)continue;const vr=fe[Nn],Mn=vr===void 0?void 0:ce.rowSpans[vr];if(!Mn)continue;const ms=Ee.slice(Mn.start+We,Mn.end+We),qn=ow(ms,ce.delimiter);for(;qn.length<=Xt;)qn.push("");const ys=Ot.data??"";if(qn[Xt]===ys)continue;qn[Xt]=ys;const vs=Ap(qn,ce.delimiter);Ee=Ee.slice(0,Mn.start+We)+vs+Ee.slice(Mn.end+We),We+=vs.length-(Mn.end-Mn.start)}return Ee!==Y&&ue(Ee),!0},[i]),ut=v.useCallback(z=>{var Le;const[ue,Y]=z,ce=ft.current[Y];if(ue{const ue=[];for(let Y=z.y;Y{z[0]>=zn||it(ue,z[1])},[it]),re=v.useMemo(()=>{const z={title:"#",id:"__gutter",width:lm,themeOverride:{baseFontStyle:`11px ${Qb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ue=V.headers.map((Y,ce)=>{const fe=U?Zb(R[Y]):null;return{title:fe?`${Y.toUpperCase()} [${fe}]`:Y.toUpperCase(),id:`c${ce}`,width:Xe,themeOverride:le[ce]?{baseFontStyle:`12px ${Qb}`}:void 0}});return[z,...ue]},[V.headers,le,Xe,U,R]),De=v.useCallback((z,ue)=>{const{ctx:Y,columnIndex:ce,rect:fe,theme:Le,isSelected:Ee}=z;Y.save();try{if(Y.letterSpacing="0.5px",Ee&&(Y.fillStyle=Le.bgHeaderHovered,Y.fillRect(fe.x,fe.y,fe.width,fe.height),Y.fillStyle=Le.accentColor,Y.fillRect(fe.x,fe.y+fe.height-2,fe.width,2)),ce{const{ctx:Y,cell:ce,rect:fe,col:Le,theme:Ee}=z,We=Le-zn;if(We>=0&&Ge&&ce.kind===ke.Text){const at=L9(ce.data,m);if(at!==null){Y.save();try{const Ot=`${Ee.baseFontStyle} ${Ee.fontFamily}`;Y.font=Ot;let Xt=fe.x+Ee.cellHorizontalPadding;const Nn=fe.y+fe.height/2+Bs(Y,Ot);for(const vr of at){const Mn=Y.measureText(vr.text).width;vr.hit&&Mn>0&&(Y.fillStyle=H,Y.fillRect(Xt-1,Nn-7,Mn+2,14)),Xt+=Mn}}finally{Y.restore()}}}if(ue(),We>=0&&ce.kind===ke.Text&&ce.data===""){Y.save();try{Y.font=`${Ee.baseFontStyle} ${Ee.fontFamily}`,Y.fillStyle=Ee.textLight,Y.fillText("—",fe.x+Ee.cellHorizontalPadding,fe.y+fe.height/2+.5)}finally{Y.restore()}}},[Ge,m,H]),An=v.useCallback(z=>{const ue=ft.current[z];return ue!==void 0&&D.current.has(ue)?{bgCell:q,bgCellMedium:q}:void 0},[q]);return ge===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:c,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(lN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:h,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Escape"&&Re()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),h!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Re,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(ph,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:Ge?`${_e.length.toLocaleString()} of ${lt.toLocaleString()}`:`${lt.toLocaleString()} rows`}),U&&dt>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>N({}),title:"Reset all pinned column types to Auto",className:Xl,children:[`${dt} ${dt===1?"column type":"column types"} pinned`,E.jsx(ph,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),Rt&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:rt.length>0?`${rt.length.toLocaleString()} selected`:Ne>0?`${Ne.toLocaleString()} ${Ne===1?"column":"columns"} selected`:`${((Lt==null?void 0:Lt.cellCount)??0).toLocaleString()} cells selected`}),Lt!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:N9(Lt)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Hn,className:Xl,children:[E.jsx(Nv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),U&&rt.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:In,title:`Deletes the ${rt.length} selected ${rt.length===1?"row":"rows"} from the source CSV`,className:Xl,children:[E.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",rt.length.toLocaleString()," ",rt.length===1?"row":"rows"]}),U&&Ne>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:I9.map(({mode:z,label:ue})=>{const Y=tt===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":Y,onClick:()=>Kt(z),className:Y?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:ue},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:Pr,disabled:vn,title:vn?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Ne} selected ${Ne===1?"column":"columns"} from the source CSV`,className:`${Xl} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Ne.toLocaleString()," ",Ne===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:$e,className:Xl,children:"Clear"})]})]}),E.jsxs("div",{ref:f,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":_e.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Ut},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(M6,{imageWindowLoader:B.current,renderers:c9,columns:re,rows:_e.length,getCellContent:ut,getCellsForSelection:xt,onCellsEdited:U?Bt:void 0,onDelete:U?Ir:void 0,onCellClicked:dn,onHeaderClicked:we,onGridSelectionChange:At,onSelectionCleared:wt,gridSelection:O,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:qb,headerHeight:om,freezeColumns:zn,fillHandle:U,onPaste:U?()=>!0:!1,keybindings:{search:!1},theme:L,drawHeader:De,drawCell:ze,getRowThemeOverride:An,minColumnWidth:Yb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),b!==null&&E.jsx("input",{ref:M,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${V.headers[b.col]??""}`,value:T,onChange:z=>A(z.target.value),onBlur:Qe,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),Qe()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),nt())},style:{left:b.bounds.x,top:b.bounds.y,width:Math.max(60,b.bounds.width),height:b.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),Ge&&_e.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:Re,className:Xl,children:"Show all rows"})]}),U&&!Ge&&_e.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function L9(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=v.useRef(null);v.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(XI,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=B9(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(hT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(uN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let U0=[],BE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=BE[r])e=r+1;else return!0;if(e==n)return!1}}function tk(t){return t>=127462&&t<=127487}const nk=8205;function W9(t,e,n=!0,r=!0){return(n?jE:V9)(t,e,r)}function jE(t,e,n){if(e==t.length)return e;e&&HE(t.charCodeAt(e))&&WE(t.charCodeAt(e-1))&&e--;let r=am(t,e);for(e+=rk(r);e=0&&tk(am(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function V9(t,e,n){for(;e>1;){let r=jE(t,e-2,n);if(r=56320&&t<57344}function WE(t){return t>=55296&&t<56320}function rk(t){return t<65536?1:2}class Dt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Fa(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),es.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Fa(this,e,n);let r=[];return this.decompose(e,n,r,0),es.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new sc(this),s=new sc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new sc(this,e)}iterRange(e,n=this.length){return new VE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new UE(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Dt.empty:e.length<=32?new Sn(e):es.from(Sn.split(e,[]))}}class Sn extends Dt{constructor(e,n=U9(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new K9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Sn(ik(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Ld(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Sn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Sn(l.slice(0,a)),new Sn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Sn))return super.replace(e,n,r);[e,n]=Fa(this,e,n);let i=Ld(this.text,Ld(r.text,ik(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Sn(i,s):es.from(Sn.split(i,[]),s)}sliceString(e,n=this.length,r=` -`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Sn(r,i)),r=[],i=-1);return i>-1&&n.push(new Sn(r,i)),n}}class es extends Dt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Fa(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new es(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof es))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof es)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Sn&&a&&(p=c[c.length-1])instanceof Sn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:es.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new es(l,n)}}Dt.empty=new Sn([""],0);function U9(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ld(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Sn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof Sn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Sn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class VE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new sc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class UE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Dt.prototype[Symbol.iterator]=function(){return this.iter()},sc.prototype[Symbol.iterator]=VE.prototype[Symbol.iterator]=UE.prototype[Symbol.iterator]=function(){return this});class K9{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Fa(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function sr(t,e,n=!0,r=!0){return W9(t,e,n,r)}function X9(t){return t>=56320&&t<57344}function G9(t){return t>=55296&&t<56320}function q9(t,e){let n=t.charCodeAt(e);if(!G9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return X9(r)?(n-55296<<10)+(r-56320)+65536:n}function Y9(t){return t<65536?1:2}const K0=/\r\n?|\n/;var kr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(kr||(kr={}));class fs{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=kr.Simple&&u>=e&&(r==kr.TrackDel&&ie||r==kr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new fs(e)}static create(e){return new fs(e)}}class _n extends fs{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return X0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return G0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&po(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?Dt.of(h.split(r||K0)):h:Dt.empty,m=p.length;if(f==d&&m==0)return;fo&&rr(i,f-o,-1),rr(i,d-f,m),po(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new _n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function po(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function G0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Pc(t),l=new Pc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);rr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Pc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Dt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Dt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ao{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new ao(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return he.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return he.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return he.range(e.anchor,e.head)}static create(e,n,r,i){return new ao(e,n,r,i)}}class he{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:he.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new he(e.ranges.map(n=>ao.fromJSON(n)),e.main)}static single(e,n=e){return new he([he.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?he.range(a,l):he.range(l,a))}}return new he(e,n)}}function XE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let lw=0;class je{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=lw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new je(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:aw),!!e.static,e.enables)}of(e){return new Fd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function aw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Fd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=lw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||q0(f,c)){let h=r(f);if(l?!sk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=Oh(d,p);if(this.dependencies.every(x=>x instanceof je?d.facet(x)===f.facet(x):x instanceof gs?d.field(x,!1)==f.field(x,!1):!0)||(l?sk(h=r(f),m,i):i(h=r(f),m)))return f.values[o]=m,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function sk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(ed).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(ed),o=i.facet(ed),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,ed.of({field:this,create:e})]}get extension(){return this}}const rl={lowest:4,low:3,default:2,high:1,highest:0};function Ou(t){return e=>new GE(e,t)}const uw={highest:Ou(rl.highest),high:Ou(rl.high),default:Ou(rl.default),low:Ou(rl.low),lowest:Ou(rl.lowest)};class GE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class dl{of(e){return new Y0(this,e)}reconfigure(e){return dl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Y0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Rh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of J9(e,n,o))d instanceof gs?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=c&&c[d]||[];if(h.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,aw(m,h))a.push(r.facet(p));else{let x=p.combine(h.map(g=>g.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of h)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(g=>x.dynamicSlot(g)));l[p.id]=u.length<<1,u.push(x=>Q9(x,p,h))}}let f=u.map(d=>d(l));return new Rh(e,o,f,l,a,s)}}function J9(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof Y0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Y0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof GE)s(o.inner,o.prec);else if(o instanceof gs)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Fd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,rl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,rl.default),r.reduce((o,l)=>o.concat(l))}function oc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Oh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qE=je.define(),Q0=je.define({combine:t=>t.some(e=>e),static:!0}),YE=je.define({combine:t=>t.length?t[0]:void 0,static:!0}),QE=je.define(),JE=je.define(),ZE=je.define(),eA=je.define({combine:t=>t.length?t[0]:!1});class Fo{constructor(e,n){this.type=e,this.value=n}static define(){return new Z9}}class Z9{of(e){return new Fo(this,e)}}class eV{constructor(e){this.map=e}of(e){return new qt(this,e)}}class qt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new qt(this.type,n)}is(e){return this.type==e}static define(e={}){return new eV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}qt.reconfigure=qt.define();qt.appendConfig=qt.define();class $n{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&XE(r,n.newLength),s.some(l=>l.type==$n.time)||(this.annotations=s.concat($n.time.of(Date.now())))}static create(e,n,r,i,s,o){return new $n(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation($n.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}$n.time=Fo.define();$n.userEvent=Fo.define();$n.addToHistory=Fo.define();$n.remote=Fo.define();function tV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof $n?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof $n?t=s[0]:t=nA(e,Sa(s),!1)}return t}function rV(t){let e=t.startState,n=e.facet(ZE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=tA(r,J0(e,s,t.changes.newLength),!0))}return r==t?t:$n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const iV=[];function Sa(t){return t==null?iV:Array.isArray(t)?t:[t]}var Ps=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ps||(Ps={}));const sV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Z0;try{Z0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function oV(t){if(Z0)return Z0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||sV.test(n)))return!0}return!1}function lV(t){return e=>{if(!/\S/.test(e))return Ps.Space;if(oV(e))return Ps.Word;for(let n=0;n-1)return Ps.Word;return Ps.Other}}class $t{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(qt.reconfigure)?(n=null,r=l.value):l.is(qt.appendConfig)&&(n=null,r=Sa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Rh.resolve(r,i,this),s=new $t(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Q0)?e.newSelection:e.newSelection.asSingle();new $t(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:he.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Sa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return $t.create({doc:e.doc,selection:he.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Rh.resolve(e.extensions||[],new Map),r=e.doc instanceof Dt?e.doc:Dt.of((e.doc||"").split(n.staticFacet($t.lineSeparator)||K0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return XE(i,r.length),n.staticFacet(Q0)||(i=i.asSingle()),new $t(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet($t.tabSize)}get lineBreak(){return this.facet($t.lineSeparator)||` -`}get readOnly(){return this.facet(eA)}phrase(e,...n){for(let r of this.facet($t.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(qE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return lV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=sr(n,o,!1);if(s(n.slice(a,o))!=Ps.Word)break;o=a}for(;lt.length?t[0]:4});$t.lineSeparator=YE;$t.readOnly=eA;$t.phrases=je.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});$t.languageData=qE;$t.changeFilter=QE;$t.transactionFilter=JE;$t.transactionExtender=ZE;dl.reconfigure=qt.define();function rA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class xl{eq(e){return this==e}range(e,n=e){return ey.create(e,n,this)}}xl.prototype.startSide=xl.prototype.endSide=0;xl.prototype.point=!1;xl.prototype.mapMode=kr.TrackDel;function cw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let ey=class iA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new iA(e,n,r)}};function ty(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class fw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new fw(i,s,r,l):null,pos:o}}}class Ht{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Ht(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(ty)),this.isEmpty)return n.length?Ht.of(n):this;let l=new sA(this,null,-1).goto(0),a=0,u=[],c=new $a;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Ic.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Ic.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ok(o,l,r),u=new Pu(o,a,s),c=new Pu(l,a,s);r.iterGaps((f,d,h)=>lk(u,f,c,d,h,i)),r.empty&&r.length==0&&lk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ok(s,o),a=new Pu(s,l,0).goto(r),u=new Pu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ny(a.active,u.active)||a.point&&(!u.point||!cw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Pu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new $a;for(let i of e instanceof ey?[e]:n?aV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ht.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ht.empty;i=i.nextLayer)n=new Ht(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Ht.empty=new Ht([],[],null,-1);function aV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ty);e=r}return t}Ht.empty.nextLayer=Ht.empty;class $a{finishChunk(e){this.chunks.push(new fw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new $a)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Ht.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Ht.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ok(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new sA(o,n,r,s));return i.length==1?i[0]:new Ic(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)um(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)um(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),um(this.heap,0)}}}function um(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Pu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ic.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){td(this.active,e),td(this.activeTo,e),td(this.activeRank,e),this.minActive=ak(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;nd(this.active,n,r),nd(this.activeTo,n,i),nd(this.activeRank,n,s),e&&nd(e,n,this.cursor.from),this.minActive=ak(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&td(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function lk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&cw(t.point,n.point)&&ny(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ny(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function ny(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function ak(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=sr(t,i)}return t.length}const ry="ͼ",uk=typeof Symbol>"u"?"__"+ry:Symbol.for(ry),iy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ck=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ro{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=ck[uk]||1;return ck[uk]=e+1,ry+e.toString(36)}static mount(e,n,r){let i=e[iy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new cV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let fk=new Map;class cV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=fk.get(r);if(s)return e[iy]=s;this.sheet=new i.CSSStyleSheet,fk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[iy]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fV=typeof navigator<"u"&&/Mac/.test(navigator.platform),dV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Kn=0;Kn<10;Kn++)Oo[48+Kn]=Oo[96+Kn]=String(Kn);for(var Kn=1;Kn<=24;Kn++)Oo[Kn+111]="F"+Kn;for(var Kn=65;Kn<=90;Kn++)Oo[Kn]=String.fromCharCode(Kn+32),Nc[Kn]=String.fromCharCode(Kn);for(var cm in Oo)Nc.hasOwnProperty(cm)||(Nc[cm]=Oo[cm]);function hV(t){var e=fV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Nc:Oo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function ts(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Te={mac:pk||/Mac/.test(dr.platform),windows:/Win/.test(dr.platform),linux:/Linux|X11/.test(dr.platform),ie:Rp,ie_version:lA?sy.documentMode||6:ly?+ly[1]:oy?+oy[1]:0,gecko:dk,gecko_version:dk?+(/Firefox\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,chrome:!!fm,chrome_version:fm?+fm[1]:0,ios:pk,android:/Android\b/.test(dr.userAgent),webkit:hk,webkit_version:hk?+(/\bAppleWebKit\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,safari:ay,safari_version:ay?+(/\bVersion\/(\d+(\.\d+)?)/.exec(dr.userAgent)||[0,0])[1]:0,tabSize:sy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function dw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Ph=Object.create(null);function hw(t,e,n){if(t==e)return!0;t||(t=Ph),e||(e=Ph);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function pV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function gk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function gV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new bl(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=aA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new bl(e,r,i,n,e.widget||null,!0)}static line(e){return new rf(e)}static set(e,n=!1){return Ht.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Vt.none=Ht.empty;class nf extends Vt{constructor(e){let{start:n,end:r}=aA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?dw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ph}eq(e){return this==e||e instanceof nf&&this.tagName==e.tagName&&hw(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}nf.prototype.point=!1;class rf extends Vt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof rf&&this.spec.class==e.spec.class&&hw(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}rf.prototype.mapMode=kr.TrackBefore;rf.prototype.point=!0;class bl extends Vt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?kr.TrackBefore:kr.TrackAfter:kr.TrackDel}get type(){return this.startSide!=this.endSide?fi.WidgetRange:this.startSide<=0?fi.WidgetBefore:fi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof bl&&mV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}bl.prototype.point=!0;function aA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function mV(t,e){return t==e||!!(t&&e&&t.compare(e))}function Ca(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Dc extends xl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Dc&&this.tagName==e.tagName&&hw(this.attributes,e.attributes)}static create(e){return new Dc(e.tagName,e.attributes||Ph,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Ht.of(e,n)}}Dc.prototype.startSide=Dc.prototype.endSide=-1;function _c(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function uy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function lc(t,e){if(!e.anchorNode)return!1;try{return uy(t,e.anchorNode)}catch{return!1}}function ac(t){return t.nodeType==3?Fc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function uc(t,e,n,r){return n?mk(t,e,n,r,-1)||mk(t,e,n,r,1):!1}function Po(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Ih(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function mk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:$s(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Po(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?$s(t):0}else return!1}}function $s(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Lc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function yV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function uA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function vV(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,m=1;if(h)d=yV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let y=c.getBoundingClientRect();({scaleX:p,scaleY:m}=uA(c,y)),d={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*m}}let x=0,g=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(g=e.bottom-d.bottom+o,n<0&&e.top-g0&&e.right>d.right+x&&(x=e.right-d.right+s)):e.right>d.right-s&&(x=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function cA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class wV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?$s(n):0),r,Math.min(e.focusOffset,r?$s(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function fA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function dA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let el=null;Te.safari&&Te.safari_version>=26&&(el=!1);function hA(t){if(t.setActive)return t.setActive();if(el)return t.focus(el);let e=fA(t);t.focus(el==null?{get preventScroll(){return el={preventScroll:!0},!0}}:void 0),el||(el=!1,dA(e))}let yk;function Fc(t,e,n=e){let r=yk||(yk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function Ta(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function xV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function bV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,$s(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=$s(n))}else{if(n==t)return!0;r=Po(n),n=n.parentNode}}function pA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function gA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=$s(n)}else if(n.parentNode&&!Ih(n))r=Po(n),n=n.parentNode;else return null}}function mA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function wA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(Gi[m+1]==-h){let x=Gi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Gt[f]=Gt[Gi[m]]=g),l=m;break}}else{if(Gi.length==189)break;Gi[l++]=f,Gi[l++]=d,Gi[l++]=a}else if((p=Gt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=Gi[x+2];if(g&2)break;if(m)Gi[x+2]|=2;else{if(g&4)break;Gi[x+2]|=4}}}}}function AV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Gt[--p]=h;a=c}else s=u,a++}}}function fy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new ss(a,m.from,h));let x=m.direction==kl!=!(h%2);dy(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Gt[p]!=l:Gt[p]==l))break;p++}d?fy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Gt[a-1];m!=l&&(c=!1,f=m==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,g=u;;){if(x==e)break e;if(g&&s[g-1].to==x)x=s[--g].from;else{if(Gt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toGt.length;)Gt[Gt.length]=256;let r=[],i=e==kl?0:1;return dy(t,i,i,n,0,t.length,r),r}function xA(t){return[new ss(0,t,0)]}let bA="";function RV(t,e,n,r,i){var s;let o=r.head-t.from,l=ss.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=sr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),bA=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),PV=je.define({combine:t=>t.some(e=>e)}),RA=je.define();class Ea{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ea(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ea(he.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const rd=qt.define({map:(t,e)=>t.map(e)}),OA=qt.define();function li(t,e,n){let r=t.facet(TA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Ms=je.define({combine:t=>t.length?t[0]:!0});let IV=0;const ha=je.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Op.of(u=>{let c=u.plugin(l);return c?o(c):Vt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return gi.define((r,i)=>new e(r,i),n)}}class dm{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(li(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){li(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){li(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const PA=je.define(),yw=je.define(),Op=je.define(),IA=je.define(),vw=je.define(),sf=je.define(),NA=je.define();function vk(t,e){let n=t.state.facet(NA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Ht.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=OV(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:h,inner:[]};f.push(m),f=m.inner}}}}),i}const DA=je.define();function ww(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(DA)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Hu=je.define();class ai{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ai(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new ai(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Nh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const NV=[];class yn{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return NV}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&pV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Po(this.dom),i=this.length?e>0:n>0;return new Ni(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Ip)return e;return null}static get(e){return e.cmTile}}class Pp extends yn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=wk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=wk(i);this.length=o}}function wk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ip extends Pp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=yn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ns)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ns extends Pp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ns(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class za extends Pp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new za(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&_V(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):DV(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ni(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ni(a.dom,0);a==r.tile&&(l=!0)}}return new Ni(this.dom,0)}}function DV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ac(e);return n[n.length-1]||null}function _V(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Te.chrome||Te.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Te.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Lc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new al(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Sl extends yn{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Lc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class LV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Sr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(hm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=yn.get(a.dom);f&&f.setDOM(hm(a.dom))}let c=Sr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=yn.get(e.text);s&&this.cache.reused.set(s,2);let o=new al(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=_A);let i=za.start(e,n||((r=this.cache.find(za))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Sr&&l.mark.eq(o))i=l,n--;else{let a=Sr.of(o,(r=this.cache.find(Sr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!xk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Te.ios&&xk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(pm,0,32)||new Sl(pm.toDOM(),0,pm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new FV(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Dh,void 0,1);return r&&(r.flags=n),r||new Dh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zV{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const _h=[Sl,za,al,Sr,Dh,Ns,Ip];for(let t=0;t<_h.length;t++)_h[t].bucket=t;class BV{constructor(e){this.view=e,this.buckets=_h.map(()=>[]),this.index=_h.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Sr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Sr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Ht.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof bl){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Ba.block:Ba.inline),p=HV(u),m=this.cache.findWidget(h,a-l,p)||Sl.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=WV(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=yn.get(i);if(i==this.view.contentDOM)break;s instanceof Sr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ns||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new za(i,_A):r||n.push(Sr.of(new nf({tagName:i.nodeName.toLowerCase(),attributes:gV(i)}),i)))}return{line:r,marks:n}}}function xk(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function HV(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const _A={class:"cm-line"};function WV(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&dw(n,t),r&&(t.class+=" "+r)),t}function VV(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Sr&&e.push(r.mark)}return e}function hm(t){let e=yn.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ba extends nu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ba.inline=new Ba("span");Ba.block=new Ba("div");const pm=new class extends nu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class bk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Vt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Ip(e,e.contentDOM),this.updateInner([new ai(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!ZV(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?KV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ai(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=qV(o,this.decorations,e.changes);a.length&&(r=ai.extendWithRanges(r,a));let u=QV(l,this.blockWrappers,e.changes);return u.length&&(r=ai.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new jV(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&yn.get(n.text)&&l.cache.reused.set(yn.get(n.text),2),this.tile=l.run(e,n),py(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Te.chrome||Te.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&lc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Te.gecko&&a.empty&&!this.hasComposition&&UV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ni(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!uc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!uc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Te.android&&Te.chrome&&r.contains(f.focusNode)&&JV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=_c(this.view.root);if(d)if(a.empty){if(Te.gecko){let h=XV(u.node,u.offset);if(h&&h!=3){let p=(h==1?gA:mA)(u.node,u.offset);p&&(u=new Ni(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ni(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ni(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&uc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=_c(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=$s(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!yn.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof gm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==mn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let m=f.children[p],x=d+m.length,g=m.dom.getBoundingClientRect(),{height:y}=g;if(h&&!p&&(u+=g.top-h.top),m instanceof Ns)x>r&&c(m,d,g);else if(d>=r&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let w=m.dom.lastChild,k=w?ac(w):[];if(k.length){let b=k[k.length-1],S=a?b.right-g.left:g.right-b.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=x)}}h&&p==f.children.length-1&&(u+=h.bottom-g.bottom),d=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?mn.RTL:mn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=ac(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=ac(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Vt.replace({widget:new gm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Vt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Op).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(vw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Ht.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(RA))try{if(u(this.view,e.range,e))return!0}catch(c){li(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=ww(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(vV(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){py(this.tile)}}function py(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)py(r,e)}}function UV(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function LA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=gA(n.focusNode,n.focusOffset),i=mA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=yn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=yn.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function KV(t,e,n){let r=LA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new ai(a.mapPos(s),a.mapPos(o),s,o),text:i}}function XV(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class gm extends nu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function eU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return he.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=sr(i.text,s,!1):l=sr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=sr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+uV(o,s,t.state.tabSize)}function nU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==fi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function rU(t,e,n,r){let i=nU(t,e.head,e.assoc||-1),s=!r||i.type!=fi.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==mn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return he.cursor(a,n?-1:1)}return he.cursor(n?i.to:i.from,n?-1:1)}function kk(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=RV(i,s,o,l,n),c=bA;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` -`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function iU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Ps.Space&&(i=o),i==o}}function sU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return he.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let m=l+(h+p)*s,x=gy(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:y{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:he.cursor(r,rt.viewState.docHeight)return new ns(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==fi.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==fi.Text){let f=tU(t,i,u,o,l);return new ns(f,f==u.from?1:-1)}}if(u.type!=fi.Text)return a<(u.top+u.bottom)/2?new ns(u.from,1):new ns(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new oU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class oU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let y=1;y=s&&(w-=p),!o.has(w)){m=w;break t}}break e}o.add(m);let x=n(m),g=0;if(x)for(let y=0;y1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),g=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==mn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Fc(e.dom,o,l).getClientRects()});return i.after?new ns(r[i.i+1],-1):new ns(r[i.i],1)}scanTile(e,n){if(!e.length)return new ns(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Fc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new ns(r[i.i+1],-1):new ns(o,1)}}const Ql="￿";class lU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ql}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=yn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=yn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Ih(i))||Ih(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!uU(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=yn.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(aU(e,r.node,r.offset)?n:0))}}function aU(t,e,n){for(;;){if(!e||n<$s(e))return!1;if(e==t)return!0;n=Po(e)+1,e=e.parentNode}}function uU(t,e){let n;for(;!(t==e||!t);t=t.nextSibling){let r=yn.get(t);if(!(r!=null&&r.isWidget()))return!1;r&&(n||(n=[])).push(r)}if(n)for(let r of n){let i=r.overrideDOMText;if(i!=null&&i.length)return!1}return!0}class Sk{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class cU{constructor(e,n,r,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=$A(e.docView.tile,n,r,0))){let a=s||o?[]:dU(e),u=new lU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=hU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!uy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!uy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Te.ios||Te.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(he.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=he.create([he.cursor(u,h)])}else this.newSel=he.single(c,u)}}}function $A(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return $A(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function zA(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Te.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Dt.of(e.text.slice(s.from-l,d).split(Ql))}:(h=BA(f,e.text,u-l,c))&&(Te.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Ql+Ql&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:Dt.of(e.text.slice(h.from,h.toB).split(Ql))})}else r&&(!t.hasFocus&&i.facet(Ms)||Lh(r,s))&&(r=null);if(!n&&!r)return!1;if((Te.mac||Te.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Dt.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Te.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Dt.of([" "])}),n)return xw(t,n,r,o);if(r&&!Lh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=FA(i.facet(sf).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function xw(t,e,n,r=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Te.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ta(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&Ta(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ta(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=fU(t,e,n));return t.state.facet(EA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function fU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:he.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&LA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-h,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let g=i.changes({from:x,to:m,insert:e.insert}),y=p.to-s.to;return{changes:g,range:u?he.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(g)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function BA(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function dU(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Sk(n,r)),(i!=n||s!=r)&&e.push(new Sk(i,s))),e}function hU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?he.single(n+e,r+e):null}function Lh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class pU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Te.safari&&e.contentDOM.addEventListener("input",()=>null),Te.gecko&&OU(e.contentDOM.ownerDocument)}handleEvent(e){!SU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=mU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&HA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Te.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(jA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||yU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Te.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&gU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Te.safari&&!Te.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function gU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Ck(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){li(n.state,i)}}}function mU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(Ck(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(Ck(r.value,a))}}for(let r in zi)n(r).handlers.push(zi[r]);for(let r in gr)n(r).observers.push(gr[r]);return e}const jA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yU="dthko",HA=[16,17,18,20,91,92,224,225],id=6;function sd(t){return Math.max(0,t)*.7+8}function vU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class wU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=cA(e.contentDOM),this.atoms=e.state.facet(sf).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet($t.allowMultipleSelections)&&xU(e,n),this.dragging=kU(e,n)&&UA(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&vU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ww(this.view);e.clientX-a.left<=i+id?n=-sd(i-e.clientX):e.clientX+a.right>=o-id&&(n=sd(e.clientX-o)),e.clientY-a.top<=s+id?r=-sd(s-e.clientY):e.clientY+a.bottom>=l-id&&(r=sd(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=FA(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function xU(t,e){let n=t.state.facet(kA);return n.length?n[0](e):Te.mac?e.metaKey:e.ctrlKey}function bU(t,e){let n=t.state.facet(SA);return n.length?n[0](e):Te.mac?!e.altKey:!e.ctrlKey}function kU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=_c(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function SU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=yn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const zi=Object.create(null),gr=Object.create(null),WA=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function CU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),VA(t,n.value)},50)}function Np(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function VA(t,e){e=Np(t.state,gw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(my!=null&&n.selection.ranges.every(a=>a.empty)&&my==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:he.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:he.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}gr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Te.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};gr.wheel=gr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};zi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);gr.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};gr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};gr.touchend=(t,e)=>{t.inputState.touchActive=!1};zi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(CA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=EU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new wU(t,e,n,r)),r&&t.observer.ignore(()=>{hA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Tk(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return eU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ak+1)%3:1}function EU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=UA(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Tk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Tk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=AU(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function AU(t,e){for(let n=0;n=e)return he.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}zi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=he.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Np(t.state,mw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};zi.dragend=t=>(t.inputState.draggedContent=null,!1);function Rk(t,e,n,r){if(n=Np(t.state,gw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&bU(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}zi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Rk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Rk(t,e,r,!0),!0}return!1};zi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=WA?null:e.clipboardData;return n?(VA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(CU(t),!1)};function MU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function RU(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Np(t,mw,e.join(t.lineBreak)),ranges:n,linewise:r}}let my=null;zi.copy=zi.cut=(t,e)=>{if(!lc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=RU(t.state);if(!n&&!i)return!1;my=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=WA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(MU(t,n),!1)};const KA=Fo.define();function XA(t,e){let n=[];for(let r of t.facet(AA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:KA.of(!0)}):null}function GA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=XA(t.state,e);n?t.dispatch(n):t.update([])}},10)}gr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),GA(t)};gr.blur=t=>{t.observer.clearSelectionRange(),GA(t)};gr.compositionstart=gr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};gr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};gr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};zi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return xw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Te.chrome&&Te.android&&(i=jA.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Te.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Te.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>gr.compositionend(t,e),20),!1};const Ok=new Set;function OU(t){Ok.has(t)||(Ok.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Pk=["pre-wrap","normal","pre-line","break-spaces"];let ja=!1;function Ik(){ja=!1}class PU{constructor(e){this.lineWrapping=e,this.doc=Dt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Pk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>$d&&(ja=!0),this.height=e)}replace(e,n,r){return pr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,Jt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,Jt.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,Jt.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class jr extends qA{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof jr||i instanceof Un&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Un?i=new jr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):pr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Un extends pr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Un?r[r.length-1]=new Un(s.length+i):r.push(null,new Un(i-1))}if(e>0){let s=r[0];s instanceof Un?r[0]=new Un(e+s.length):r.unshift(new Un(e-1),null)}return pr.of(r)}decomposeLeft(e,n){n.push(new Un(e-1),null)}decomposeRight(e,n){n.push(null,new Un(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Un(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=$d&&(a=-2);let h=new jr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Un(s-l).updateHeight(e,l));let u=pr.of(o);return(a<0||Math.abs(u.height-this.height)>=$d||Math.abs(a-this.heightMetrics(e,n).perLine)>=$d)&&(ja=!0),Fh(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class DU extends pr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==Jt.ByPosNoHeight?Jt.ByPosNoHeight:Jt.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,Jt.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&Nk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?pr.of(this.break?[e,null,n]:[e,n]):(this.left=Fh(this.left,e),this.right=Fh(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Nk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Un&&(r=t[e+1])instanceof Un&&t.splice(e-1,3,new Un(n.length+1+r.length))}const _U=5;class bw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof jr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new jr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=_U)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new jr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Un(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof jr)return e;let n=new jr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof jr)&&!this.isCovered?this.nodes.push(new jr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function zU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function BU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class ym{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new PU(r),this.stateDeco=Lk(n),this.heightMap=pr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle.setDoc(n.doc),[new ai(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Vt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new od(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?_k:new kw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Wu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Lk(this.state);let i=e.changedRanges,s=ai.extendWithRanges(i,LU(r,this.stateDeco,e?e.changes:_n.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ik(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ja)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(PV)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:S}=uA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=b,this.scaleY=S,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=cA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=pA(this.scrollParent||e.win);let m=(this.printing?BU:$U)(n,this.paddingTop),x=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!zU(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:S,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=S>0&&i.refresh(s,S,T,A,Math.max(5,w/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&g>0?c=Math.max(x,g):x<0&&g<0&&(c=Math.min(x,g)),Ik();for(let S of this.viewports){let T=S.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?pr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle,[new ai(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new IU(S.from,T))}ja&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new od(i.lineAt(o-r*1e3,Jt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Jt.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,Jt.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=mn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&gg.from>=d.from&&g.to<=d.to&&Math.abs(g.from-c)g.fromy));if(!x){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(he.cursor(f),!1,!0).head;w>c&&(f=w)}let g=this.gapSize(d,c,f,h),y=r||g<2e6?g:2e6;x=new ym(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let S of e)S.from>=c.from&&S.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Ht.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Wu(this.heightMap.lineAt(e,Jt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Wu(this.heightMap.lineAt(this.scaler.fromDOM(e),Jt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Wu(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class od{constructor(e,n){this.from=e,this.to=n}}function HU(t,e,n){let r=[],i=t,s=0;return Ht.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function ad(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function WU(t,e){for(let n of t)if(e(n))return n}const _k={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Lk(t){let e=t.facet(Op).filter(r=>typeof r!="function"),n=t.facet(vw).filter(r=>typeof r!="function");return n.length&&e.push(Ht.join(n)),e}class kw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Jt.ByPos,e,0,0).top,c=n.lineAt(a,Jt.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Wu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ii(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Wu(i,e)):t._content)}const ud=je.define({combine:t=>t.join(" ")}),yy=je.define({combine:t=>t.indexOf(!0)>-1}),vy=Ro.newName(),YA=Ro.newName(),QA=Ro.newName(),JA={"&light":"."+YA,"&dark":"."+QA};function wy(t,e,n){return new Ro(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const VU=wy("."+vy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},JA),UU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vm=Te.ie&&Te.ie_version<=11;class KU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new wV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Te.ie&&Te.ie_version<=11||Te.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Te.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Te.chrome&&Te.chrome_version<126)&&(this.editContext=new GU(e),e.state.facet(Ms)&&(e.contentDOM.editContext=this.editContext.editContext)),vm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Ms)?r.root.activeElement!=this.dom:!lc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!r.state.selection.main.empty&&i.focusNode&&uc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=_c(e.root);if(!n)return!1;let r=Te.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&XU(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=lc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ta(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&lc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new cU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=zA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Lh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=Fk(n,e.previousSibling||e.target.previousSibling,-1),i=Fk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ms)!=e.state.facet(Ms)&&(e.view.contentDOM.editContext=e.state.facet(Ms)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Fk(t,e,n){for(;e;){let r=yn.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function $k(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return uc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function XU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return $k(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?$k(t,n):null}class GU{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=BA(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=he.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Lh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:Dt.of(r.text.slice(c.from,c.toB).split(` -`))};if((Te.mac||Te.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:Dt.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);xw(e,f,he.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=_c(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ke{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||xV(e.parent)||document,this.viewState=new Dk(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(rd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ha).map(i=>new dm(i));for(let i of this.plugins)i.update(this);this.observer=new KU(this),this.inputState=new pU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new bk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof $n?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(KA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=XA(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet($t.phrases)!=this.state.facet($t.phrases))return this.setState(s);i=Nh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:m}=this.state.facet(Ke.cursorScrollMargin);f=new Ea(h.empty?h:he.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",m,p)}for(let h of d.effects)h.is(rd)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=$h.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Hu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(ud)!=i.state.facet(ud)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(hy))try{d(i)}catch(h){li(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!zA(this,c)&&u.force&&Ta(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Dk(this,e),this.plugins=e.facet(ha).map(r=>new dm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new bk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ha),r=e.state.facet(ha);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new dm(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(pA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return li(this.state,p),zk}}),f=Nh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Te.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(hy))l(n)}get themeClasses(){return vy+" "+(this.state.facet(yy)?QA:YA)+" "+this.state.facet(ud)}updateAttrs(){let e=Bk(this,PA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ms)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Bk(this,yw,n);let r=this.observer.ignore(()=>{let i=gk(this.contentDOM,this.contentAttrs,n),s=gk(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(Ke.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Hu);let e=this.state.facet(Ke.cspNonce);Ro.mount(this.root,this.styleModules.concat(VU).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return mm(this,e,kk(this,e,n,r))}moveByGroup(e,n){return mm(this,e,kk(this,e,n,r=>iU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return he.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return rU(this,e,n,r)}moveVertically(e,n,r){return mm(this,e,sU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=gy(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),gy(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[ss.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==mn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(MA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>qU)return xA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||wA(s.isolates,r=vk(this,e))))return s.order;r||(r=vk(this,e));let i=MV(e.text,n,r);return this.bidiCache.push(new $h(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Te.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{hA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return rd.of(new Ea(typeof e=="number"?he.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return rd.of(new Ea(he.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return gi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return gi.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Ro.newName(),i=[ud.of(r),Hu.of(wy(`.${r}`,e))];return n&&n.dark&&i.push(yy.of(!0)),i}static baseTheme(e){return uw.lowest(Hu.of(wy("."+vy,e,JA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&yn.get(r)||yn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ke.styleModule=Hu;Ke.inputHandler=EA;Ke.clipboardInputFilter=gw;Ke.clipboardOutputFilter=mw;Ke.scrollHandler=RA;Ke.focusChangeEffect=AA;Ke.perLineTextDirection=MA;Ke.exceptionSink=TA;Ke.updateListener=hy;Ke.editable=Ms;Ke.mouseSelectionStyle=CA;Ke.dragMovesSelection=SA;Ke.clickAddsSelectionRange=kA;Ke.decorations=Op;Ke.blockWrappers=IA;Ke.outerDecorations=vw;Ke.atomicRanges=sf;Ke.bidiIsolatedRanges=NA;Ke.cursorScrollMargin=je.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});Ke.scrollMargins=DA;Ke.darkTheme=yy;Ke.cspNonce=je.define({combine:t=>t.length?t[0]:""});Ke.contentAttributes=yw;Ke.editorAttributes=PA;Ke.lineWrapping=Ke.contentAttributes.of({class:"cm-lineWrapping"});Ke.announce=qt.define();const qU=4096,zk={};class $h{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:mn.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&dw(o,n)}return n}const YU=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function QU(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let uo=null;const e7=4e3;function t7(t,e=YU){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>QU(g,e));for(let g=1;g{let k=uo={view:w,prefix:y,scope:o};return setTimeout(()=>{uo==k&&(uo=null)},e7),!0}]})}let m=p.join(" ");i(m,!1);let x=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,xy))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let xy=null;function n7(t,e,n,r){xy=e;let i=hV(e),s=q9(i,0),o=Y9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;uo&&uo.view==n&&uo.scope==r&&(l=uo.prefix+" ",HA.indexOf(e.keyCode)<0&&(u=!0,uo=null));let f=new Set,d=x=>{if(x){for(let g of x.run)if(!f.has(g)&&(f.add(g),g(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,m;return h&&(d(h[l+cd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&!(Te.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Oo[e.keyCode])&&p!=i?(d(h[l+cd(p,e,!0)])||e.shiftKey&&(m=Nc[e.keyCode])!=i&&m!=p&&d(h[l+cd(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+cd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),xy=null,a}class r7 extends nu{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?ac(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Lc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function i7(t){let e=gi.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Vt.set([Vt.widget({widget:new r7(t),side:1}).range(0)]):Vt.none}get decorations(){return this.view.state.doc.length?Vt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Ke.contentAttributes.of({"aria-placeholder":t})]:e}const fd="-10000px";class eM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function s7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const wm=je.define({combine:t=>{var e,n,r;return{position:Te.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||s7}}}),Hk=new WeakMap,tM=gi.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(wm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new eM(t,nM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(wm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=fd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Te.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=ww(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(wm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=fd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,x=(e=Hk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||l7,y=this.view.textDirection==mn.LTR,w=d.width>r.right-r.left?y?r.left:r.right-d.width:y?Math.max(r.left,Math.min(f.left-(h?14:0)+g.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(h?14:0)-g.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-g.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(bw&&A.topS&&(S=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-t.parent.top)/s+"px",Wk(c,(w-t.parent.left)/i)):(c.style.top=S/s+"px",Wk(c,w/i)),h){let A=f.left+(y?g.x:-g.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:S,right:T,bottom:S+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=fd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Wk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const o7=Ke.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),l7={x:0,y:0},nM=je.define({enables:[tM,o7]}),zh=je.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Dp{static create(e){return new Dp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new eM(e,zh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const a7=nM.compute([zh],t=>{let e=t.facet(zh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Dp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),u7=je.define();class c7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==mn.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>li(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(tM),n=e?e.manager.tooltips.findIndex(r=>r.create==Dp.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!f7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!d7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const dd=4;function f7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-dd&&e.clientX<=r+dd&&e.clientY>=i-dd&&e.clientY<=s+dd}function d7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function h7(t,e={}){let n=qt.define(),r=new WeakMap,i=gs.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,kr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(p7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>zh.from(o)});const s=gi.define(o=>new c7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,u7.of(s),a7]}}const p7=qt.define(),Vk=je.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),g7=gi.fromClass(class{constructor(t){this.input=t.state.facet(by),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Vk);this.top=new hd(t,!0,e.topContainer),this.bottom=new hd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Vk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new hd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new hd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(by);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ke.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class hd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Uk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Uk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Uk(t){let e=t.nextSibling;return t.remove(),e}const by=je.define({enables:g7});class Ha extends xl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ha.prototype.elementClass="";Ha.prototype.toDOM=void 0;Ha.prototype.mapMode=kr.TrackBefore;Ha.prototype.startSide=Ha.prototype.endSide=-1;Ha.prototype.point=!0;const rM=1024;let m7=0;class xm{constructor(e,n){this.from=e,this.to=n}}class Tt{constructor(e={}){this.id=m7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Or.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class fc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const y7=Object.create(null);class Or{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):y7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Or(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Or.none=new Or("",Object.create(null),0,8);class Sw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|gn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Ew(Or.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Tn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Tn(Or.none,n,r,i)))}static build(e){return b7(e)}}Tn.empty=new Tn(Or.none,[],[],0);class Cw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Cw(this.buffer,this.index)}}class Io{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Or.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function $c(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&gn.EnterBracketed&&c instanceof Tn&&(d=fc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!iM(i,r,f,f+c.length))){if(c instanceof Io){if(s&gn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new go(new v7(o,c,e,f),null,h)}else if(s&gn.IncludeAnonymous||!c.type.isAnonymous||Tw(c)){let h;if(!(s&gn.IgnoreMounts)&&(h=fc.get(c))&&!h.overlay)return new di(h.tree,f,e,o);let p=new di(c,f,e,o);return s&gn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&gn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&gn.IgnoreOverlays)&&(i=fc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&gn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new di(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Xk(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function ky(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class v7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class go extends sM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new go(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&gn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new go(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new go(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new go(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function oM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new di(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push($c(l,e,n,!1))}}return i?oM(i):r}class Sy{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~gn.EnterBracketed,e instanceof di)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof di?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&gn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&gn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&gn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&gn.IncludeAnonymous||l instanceof Io||!l.type.isAnonymous||Tw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return ky(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Tw(t){return t.children.some(e=>e instanceof Io||!e.type.isAnonymous||Tw(e))}function b7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=rM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Cw(n,n.length):n,a=r.types,u=0,c=0;function f(b,S,T,A,M,O){let{id:_,start:P,end:I,size:D}=l,Z=c,ne=u;if(D<0)if(l.next(),D==-1){let N=s[_];T.push(N),A.push(P-b);return}else if(D==-3){u=_;return}else if(D==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${D}`);let oe=a[_],W,U,R=P-b;if(I-P<=i&&(U=x(l.pos-S,M))){let N=new Uint16Array(U.size-U.skip),L=l.pos-U.size,H=N.length;for(;l.pos>L;)H=g(U.start,N,H);W=new Io(N,I-U.start,r),R=U.start-b}else{let N=l.pos-D;l.next();let L=[],H=[],q=_>=o?_:-1,B=0,V=I;for(;l.pos>N;)q>=0&&l.id==q&&l.size>=0?(l.end<=V-i&&(p(L,H,P,B,l.end,V,q,Z,ne),B=L.length,V=l.end),l.next()):O>2500?d(P,N,L,H):f(P,N,L,H,q,O+1);if(q>=0&&B>0&&B-1&&B>0){let le=h(oe,ne);W=Ew(oe,L,H,0,L.length,0,I-P,le,le)}else W=m(oe,L,H,I-P,Z-I,ne)}T.push(W),A.push(R)}function d(b,S,T,A){let M=[],O=0,_=-1;for(;l.pos>S;){let{id:P,start:I,end:D,size:Z}=l;if(Z>4)l.next();else{if(_>-1&&I<_)break;_<0&&(_=D-i),M.push(P,I,D),O++,l.next()}}if(O){let P=new Uint16Array(O*4),I=M[M.length-2];for(let D=M.length-3,Z=0;D>=0;D-=3)P[Z++]=M[D],P[Z++]=M[D+1]-I,P[Z++]=M[D+2]-I,P[Z++]=Z;T.push(new Io(P,M[2]-I,r)),A.push(I-b)}}function h(b,S){return(T,A,M)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Tn){if(!_&&P.type==b&&P.length==M)return P;(I=P.prop(Tt.lookAhead))&&(O=A[_]+P.length+I)}return m(b,T,A,M,O,S)}}function p(b,S,T,A,M,O,_,P,I){let D=[],Z=[];for(;b.length>A;)D.push(b.pop()),Z.push(S.pop()+T-M);b.push(m(r.types[_],D,Z,O-M,P-O,I)),S.push(M-T)}function m(b,S,T,A,M,O,_){if(O){let P=[Tt.contextHash,O];_=_?[P].concat(_):[P]}if(M>25){let P=[Tt.lookAhead,M];_=_?[P].concat(_):[P]}return new Tn(b,S,T,A,_)}function x(b,S){let T=l.fork(),A=0,M=0,O=0,_=T.end-i,P={size:0,start:0,skip:0};e:for(let I=T.pos-b;T.pos>I;){let D=T.size;if(T.id==S&&D>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let Z=T.pos-D;if(D<0||Z=o?4:0,oe=T.start;for(T.next();T.pos>Z;){if(T.size<0)if(T.size==-3||T.size==-4)ne+=4;else break e;else T.id>=o&&(ne+=4);T.next()}M=oe,A+=D,O+=ne}return(S<0||A==b)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function g(b,S,T){let{id:A,start:M,end:O,size:_}=l;if(l.next(),_>=0&&A4){let I=l.pos-(_-4);for(;l.pos>I;)T=g(b,S,T)}S[--T]=P,S[--T]=O-b,S[--T]=M-b,S[--T]=A}else _==-3?u=A:_==-4&&(c=A);return T}let y=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new Tn(a[t.topID],y.reverse(),w.reverse(),k)}const Gk=new WeakMap;function zd(t,e){if(!t.isAnonymous||e instanceof Io||e.type!=t)return 1;let n=Gk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Tn)){n=1;break}n+=zd(t,r)}Gk.set(e,n)}return n}function Ew(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;S+=T}if(w==k+1){if(S>c){let T=p[k];h(T.children,T.positions,0,T.children.length,m[k]+y);continue}f.push(p[k])}else{let T=m[w-1]+p[w-1].length-b;f.push(Ew(t,p,m,k,w,b,T,null,a))}d.push(b+y-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class hl{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new hl(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new hl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew xm(i.from,i.to)):[new xm(0,0)]:[new xm(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class k7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});let S7=0;class ii{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=S7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof ii&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new ii(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Bh(e);return r=>r.modified.indexOf(n)>-1?r:Bh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let C7=0;class Bh{constructor(e){this.name=e,this.instances=[],this.id=C7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&T7(n,l.modified));if(r)return r;let i=[],s=new ii(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=E7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Bh.get(l,a));return s}}function T7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function E7(t){let e=[[]];for(let n=0;nr.length-n.length)}function aM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new zc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return uM.add(e)}const uM=new Tt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new zc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class zc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function A7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function M7(t,e,n,r=0,i=t.length){let s=new R7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class R7{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=O7(e)||zc.empty,f=A7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(Tt.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(d.tree.type)),m=e.firstChild();for(let x=0,g=l;;x++){let y=x=w||!e.nextSibling())););if(!y||w>r)break;g=y.to+l,g>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+l),Math.min(r,g),"",p),this.startSpan(Math.min(r,g),u))}m&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function O7(t){let e=t.type.prop(uM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ve=ii.define,gd=ve(),io=ve(),qk=ve(io),Yk=ve(io),so=ve(),md=ve(so),bm=ve(so),Qi=ve(),Yo=ve(Qi),qi=ve(),Yi=ve(),Cy=ve(),Iu=ve(Cy),yd=ve(),Ue={comment:gd,lineComment:ve(gd),blockComment:ve(gd),docComment:ve(gd),name:io,variableName:ve(io),typeName:qk,tagName:ve(qk),propertyName:Yk,attributeName:ve(Yk),className:ve(io),labelName:ve(io),namespace:ve(io),macroName:ve(io),literal:so,string:md,docString:ve(md),character:ve(md),attributeValue:ve(md),number:bm,integer:ve(bm),float:ve(bm),bool:ve(so),regexp:ve(so),escape:ve(so),color:ve(so),url:ve(so),keyword:qi,self:ve(qi),null:ve(qi),atom:ve(qi),unit:ve(qi),modifier:ve(qi),operatorKeyword:ve(qi),controlKeyword:ve(qi),definitionKeyword:ve(qi),moduleKeyword:ve(qi),operator:Yi,derefOperator:ve(Yi),arithmeticOperator:ve(Yi),logicOperator:ve(Yi),bitwiseOperator:ve(Yi),compareOperator:ve(Yi),updateOperator:ve(Yi),definitionOperator:ve(Yi),typeOperator:ve(Yi),controlOperator:ve(Yi),punctuation:Cy,separator:ve(Cy),bracket:Iu,angleBracket:ve(Iu),squareBracket:ve(Iu),paren:ve(Iu),brace:ve(Iu),content:Qi,heading:Yo,heading1:ve(Yo),heading2:ve(Yo),heading3:ve(Yo),heading4:ve(Yo),heading5:ve(Yo),heading6:ve(Yo),contentSeparator:ve(Qi),list:ve(Qi),quote:ve(Qi),emphasis:ve(Qi),strong:ve(Qi),link:ve(Qi),monospace:ve(Qi),strikethrough:ve(Qi),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:yd,documentMeta:ve(yd),annotation:ve(yd),processingInstruction:ve(yd),definition:ii.defineModifier("definition"),constant:ii.defineModifier("constant"),function:ii.defineModifier("function"),standard:ii.defineModifier("standard"),local:ii.defineModifier("local"),special:ii.defineModifier("special")};for(let t in Ue){let e=Ue[t];e instanceof ii&&(e.name=t)}cM([{tag:Ue.link,class:"tok-link"},{tag:Ue.heading,class:"tok-heading"},{tag:Ue.emphasis,class:"tok-emphasis"},{tag:Ue.strong,class:"tok-strong"},{tag:Ue.keyword,class:"tok-keyword"},{tag:Ue.atom,class:"tok-atom"},{tag:Ue.bool,class:"tok-bool"},{tag:Ue.url,class:"tok-url"},{tag:Ue.labelName,class:"tok-labelName"},{tag:Ue.inserted,class:"tok-inserted"},{tag:Ue.deleted,class:"tok-deleted"},{tag:Ue.literal,class:"tok-literal"},{tag:Ue.string,class:"tok-string"},{tag:Ue.number,class:"tok-number"},{tag:[Ue.regexp,Ue.escape,Ue.special(Ue.string)],class:"tok-string2"},{tag:Ue.variableName,class:"tok-variableName"},{tag:Ue.local(Ue.variableName),class:"tok-variableName tok-local"},{tag:Ue.definition(Ue.variableName),class:"tok-variableName tok-definition"},{tag:Ue.special(Ue.variableName),class:"tok-variableName2"},{tag:Ue.definition(Ue.propertyName),class:"tok-propertyName tok-definition"},{tag:Ue.typeName,class:"tok-typeName"},{tag:Ue.namespace,class:"tok-namespace"},{tag:Ue.className,class:"tok-className"},{tag:Ue.macroName,class:"tok-macroName"},{tag:Ue.propertyName,class:"tok-propertyName"},{tag:Ue.operator,class:"tok-operator"},{tag:Ue.comment,class:"tok-comment"},{tag:Ue.meta,class:"tok-meta"},{tag:Ue.invalid,class:"tok-invalid"},{tag:Ue.punctuation,class:"tok-punctuation"}]);var km;const pa=new Tt;function P7(t){return je.define({combine:t?e=>e.concat(t):void 0})}const I7=new Tt;class Di{constructor(e,n,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return ds(this)}}),this.parser=n,this.extension=[Va.of(this),$t.languageData.of((s,o,l)=>{let a=Qk(s,o,l),u=a.type.prop(pa);if(!u)return[];let c=s.facet(u),f=a.type.prop(I7);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Qk(e,n,r).type.prop(pa)==this.data}findRegions(e){let n=e.facet(Va);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(pa)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Tt.mounted);if(l){if(l.tree.prop(pa)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new jh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ds(t){let e=t.field(Di.state,!1);return e?e.tree:Tn.empty}class N7{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Nu=null;class Hh{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Hh(e,n,[],Tn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new N7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(hl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Nu;Nu=this;try{return e()}finally{Nu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Jk(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=hl.applyChanges(r,a),i=Tn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=Jk(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends lM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Nu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Tn(Or.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Nu}}function Jk(t,e,n){return hl.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Wa{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Wa(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Hh.create(e.facet(Va).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wa(r)}}Di.state=gs.define({create:Wa.init,update(t,e){for(let n of e.effects)if(n.is(Di.setState))return n.value;return e.startState.facet(Va)!=e.state.facet(Va)?Wa.init(e.state):t.apply(e)}});let fM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(fM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Sm=typeof navigator<"u"&&(!((km=navigator.scheduling)===null||km===void 0)&&km.isInputPending)?()=>navigator.scheduling.isInputPending():null,D7=gi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Di.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Di.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=fM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Sm&&Sm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Di.setState.of(new Wa(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>li(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Va=je.define({combine(t){return t.length?t[0]:null},enables:t=>[Di.state,D7,Ke.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class _7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const L7=je.define(),Aw=je.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Wh(t){let e=t.facet(Aw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Vh(t,e){let n="",r=t.tabSize,i=t.facet(Aw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?F7(t,n,e):null}class _p{constructor(e,n={}){this.state=e,this.options=n,this.unit=Wh(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Mp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const hM=new Tt;function F7(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return pM(r,t,n)}function pM(t,e,n){for(let r=t;r;r=r.next){let i=z7(r.node);if(i)return i(Mw.create(e,n,r))}return 0}function $7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function z7(t){let e=t.type.prop(hM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Tt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>W7(o,!0,1,void 0,s&&!$7(o)?i.from:void 0)}return t.parent==null?B7:null}function B7(){return 0}class Mw extends _p{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Mw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(j7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return pM(this.context.next,this.base,this.pos)}}function j7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function H7(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function W7(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=H7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Zk({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const V7=new Tt;function U7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(pa)==o.data:o?l=>l==o:void 0,this.style=cM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Ro(r):null,this.themeType=n.themeType}static define(e,n){return new Lp(e,n||{})}}const Ty=je.define(),K7=je.define({combine(t){return t.length?[t[0]]:null}});function Cm(t){let e=t.facet(Ty);return e.length?e:t.facet(K7)}function eS(t,e){let n=[G7],r;return t instanceof Lp&&(t.module&&n.push(Ke.styleModule.of(t.module)),r=t.themeType),r?n.push(Ty.computeN([Ke.darkTheme],i=>i.facet(Ke.darkTheme)==(r=="dark")?[t]:[])):n.push(Ty.of(t)),n}class X7{constructor(e){this.markCache=Object.create(null),this.tree=ds(e.state),this.decorations=this.buildDeco(e,Cm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=ds(e.state),r=Cm(e.state),i=r!=Cm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Vt.none;let r=new $a;for(let{from:i,to:s}of e.visibleRanges)M7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Vt.mark({class:a})))},i,s);return r.finish()}}const G7=uw.high(gi.fromClass(X7,{decorations:t=>t.decorations})),q7=1e4,Y7="()[]{}",Q7=new Tt;function Ey(t,e,n){let r=t.prop(e<0?Tt.openedBy:Tt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function Ay(t){let e=t.type.prop(Q7);return e?e(t.node):t}function ga(t,e,n,r={}){let i=r.maxScanDistance||q7,s=r.brackets||Y7,o=ds(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ey(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return J7(t,e,n,a,c,u,s)}}return Z7(t,e,n,o,l.type,i,s)}function J7(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let m=n>0?0:h.length-1,x=n>0?h.length:-1;m!=x;m+=n){let g=o.indexOf(h[m]);if(!(g<0||r.resolveInner(p+m,1).type!=i))if(g%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const eK=Object.create(null),tS=[Or.none],nS=[],rS=Object.create(null),tK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tK[t]=nK(eK,e);function Tm(t,e){nS.indexOf(t)>-1||(nS.push(t),console.warn(e))}function nK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ue[u];c?typeof c=="function"?a.length?a=a.map(c):Tm(u,`Modifier ${u} used at start of tag`):a.length?Tm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Tm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=rS[i];if(s)return s.id;let o=rS[i]=Or.define({id:tS.length,name:r,props:[aM({[r]:n})]});return tS.push(o),o.id}mn.RTL,mn.LTR;const rK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Ow(t.state,n.from);return r.line?iK(t):r.block?oK(t):!1};function Rw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const iK=Rw(uK,0),sK=Rw(gM,0),oK=Rw((t,e)=>gM(t,e,aK(e)),0);function Ow(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Du=50;function lK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Du,r),o=t.sliceDoc(i,i+Du),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Du?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Du),f=t.sliceDoc(i-Du,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function aK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function gM(t,e,n=e.selection.ranges){let r=n.map(s=>Ow(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>lK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const My=Fo.define(),cK=Fo.define(),fK=je.define(),mM=je.define({combine(t){return rA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),yM=gs.define({create(){return os.empty},update(t,e){let n=e.state.facet(mM),r=e.annotation(My);if(r){let a=Er.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Uh(c,c.length,n.minDepth,a):c=xM(c,e.startState.selection),new os(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(cK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation($n.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Er.fromTransaction(e),o=e.annotation($n.time),l=e.annotation($n.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new os(t.done.map(Er.fromJSON),t.undone.map(Er.fromJSON))}});function dK(t={}){return[yM,mM.of(t),Ke.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?vM:e.inputType=="historyRedo"?Ry:null;return r?(e.preventDefault(),r(n)):!1}})]}function Fp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(yM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const vM=Fp(0,!1),Ry=Fp(1,!1),hK=Fp(0,!0),pK=Fp(1,!0);class Er{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Er(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Er(e.changes&&_n.fromJSON(e.changes),[],e.mapped&&fs.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=ui;for(let i of e.startState.facet(fK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Er(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ui)}static selection(e){return new Er(void 0,ui,void 0,void 0,e)}}function Uh(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function gK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function mK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function wM(t,e){return t.length?e.length?t.concat(e):t:e}const ui=[],yK=200;function xM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-yK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Uh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Er.selection([e])]}function vK(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Em(t,e){if(!t.length)return t;let n=t.length,r=ui;for(;n;){let i=wK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Er.selection(r)]:ui}function wK(t,e,n){let r=wM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ui,n);if(!t.changes)return Er.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Er(i,qt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const xK=/^(input\.type|delete)($|\.)/;class os{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new os(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||xK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):$p(n,e))}function lr(t){return t.textDirectionAt(t.state.selection.main.head)==mn.LTR}const kM=t=>bM(t,!lr(t)),SM=t=>bM(t,lr(t));function CM(t,e){return Hi(t,n=>n.empty?t.moveByGroup(n,e):$p(n,e))}const kK=t=>CM(t,!lr(t)),SK=t=>CM(t,lr(t));function CK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function zp(t,e,n){let r=ds(t).resolveInner(e.head),i=n?Tt.closedBy:Tt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;CK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ga(t,r.from,1):ga(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,he.cursor(l,n?-1:1)}const TK=t=>Hi(t,e=>zp(t.state,e,!lr(t))),EK=t=>Hi(t,e=>zp(t.state,e,lr(t)));function TM(t,e){return Hi(t,n=>{if(!n.empty)return $p(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const EM=t=>TM(t,!1),AM=t=>TM(t,!0);function MM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):$p(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomRM(t,!1),Oy=t=>RM(t,!0);function $o(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=he.cursor(r.from+s))}return i}const AK=t=>Hi(t,e=>$o(t,e,!0)),MK=t=>Hi(t,e=>$o(t,e,!1)),RK=t=>Hi(t,e=>$o(t,e,!lr(t))),OK=t=>Hi(t,e=>$o(t,e,lr(t))),PK=t=>Hi(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),IK=t=>Hi(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function NK(t,e,n){let r=!1,i=ru(t.selection,s=>{let o=ga(t,s.head,-1)||ga(t,s.head,1)||s.head>0&&ga(t,s.head-1,1)||s.headNK(t,e);function mi(t,e,n){let r=ru(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=he.range(i.head,i.anchor));let s=n(i);return he.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(ji(t.state,r)),!0)}function OM(t,e){return mi(t,e,n=>t.moveByChar(n,e))}const PM=t=>OM(t,!lr(t)),IM=t=>OM(t,lr(t));function NM(t,e){return mi(t,e,n=>t.moveByGroup(n,e))}const _K=t=>NM(t,!lr(t)),LK=t=>NM(t,lr(t)),FK=t=>{let e=!lr(t);return mi(t,e,n=>zp(t.state,n,e))},$K=t=>{let e=lr(t);return mi(t,e,n=>zp(t.state,n,e))};function DM(t,e){return mi(t,e,n=>t.moveVertically(n,e))}const _M=t=>DM(t,!1),LM=t=>DM(t,!0);function FM(t,e){return mi(t,e,n=>t.moveVertically(n,e,MM(t).height))}const sS=t=>FM(t,!1),oS=t=>FM(t,!0),zK=t=>mi(t,!0,e=>$o(t,e,!0)),BK=t=>mi(t,!1,e=>$o(t,e,!1)),jK=t=>{let e=!lr(t);return mi(t,e,n=>$o(t,n,e))},HK=t=>{let e=lr(t);return mi(t,e,n=>$o(t,n,e))},WK=t=>mi(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),VK=t=>mi(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),lS=({state:t,dispatch:e})=>(e(ji(t,{anchor:0})),!0),aS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.doc.length})),!0),uS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.selection.main.anchor,head:0})),!0),cS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),UK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),KK=({state:t,dispatch:e})=>{let n=Bp(t).map(({from:r,to:i})=>he.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:he.create(n),userEvent:"select"})),!0},XK=({state:t,dispatch:e})=>{let n=ru(t.selection,r=>{let i=ds(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return he.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(ji(t,n)),!0)};function $M(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(ji(n,he.create(i,i.length-1))),!0)}const GK=t=>$M(t,!1),qK=t=>$M(t,!0),YK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=he.create([n.main]):n.main.empty||(r=he.create([he.cursor(n.main.head)])),r?(e(ji(t,r)),!0):!1};function of(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=vd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=vd(t,o,!1),l=vd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:he.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const zM=(t,e,n)=>of(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&izM(t,!1,!0),BM=t=>zM(t,!0,!1),jM=(t,e)=>of(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=sr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),HM=t=>jM(t,!1),QK=t=>jM(t,!0),JK=t=>of(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headof(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),eX=t=>of(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Dt.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:sr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:sr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:he.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Bp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function WM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Bp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(he.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(he.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:he.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rX=({state:t,dispatch:e})=>WM(t,e,!1),iX=({state:t,dispatch:e})=>WM(t,e,!0);function VM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Bp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const sX=({state:t,dispatch:e})=>VM(t,e,!1),oX=({state:t,dispatch:e})=>VM(t,e,!0),lX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Bp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function aX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=ds(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Tt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const fS=UM(!1),uX=UM(!0);function UM(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&aX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new _p(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=dM(u,s);for(c==null&&(c=Mp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:he.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const cX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new _p(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Pw(t,(s,o,l)=>{let a=dM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Vh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(Pw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Aw)})}),{userEvent:"input.indent"})),!0),XM=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Pw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Mp(i,t.tabSize),o=0,l=Vh(t,Math.max(0,s-Wh(t)));for(;o(t.setTabFocusMode(),!0),dX=[{key:"Ctrl-b",run:kM,shift:PM,preventDefault:!0},{key:"Ctrl-f",run:SM,shift:IM},{key:"Ctrl-p",run:EM,shift:_M},{key:"Ctrl-n",run:AM,shift:LM},{key:"Ctrl-a",run:PK,shift:WK},{key:"Ctrl-e",run:IK,shift:VK},{key:"Ctrl-d",run:BM},{key:"Ctrl-h",run:Py},{key:"Ctrl-k",run:JK},{key:"Ctrl-Alt-h",run:HM},{key:"Ctrl-o",run:tX},{key:"Ctrl-t",run:nX},{key:"Ctrl-v",run:Oy}],hX=[{key:"ArrowLeft",run:kM,shift:PM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kK,shift:_K,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:RK,shift:jK,preventDefault:!0},{key:"ArrowRight",run:SM,shift:IM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:SK,shift:LK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:OK,shift:HK,preventDefault:!0},{key:"ArrowUp",run:EM,shift:_M,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lS,shift:uS},{mac:"Ctrl-ArrowUp",run:iS,shift:sS},{key:"ArrowDown",run:AM,shift:LM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:aS,shift:cS},{mac:"Ctrl-ArrowDown",run:Oy,shift:oS},{key:"PageUp",run:iS,shift:sS},{key:"PageDown",run:Oy,shift:oS},{key:"Home",run:MK,shift:BK,preventDefault:!0},{key:"Mod-Home",run:lS,shift:uS},{key:"End",run:AK,shift:zK,preventDefault:!0},{key:"Mod-End",run:aS,shift:cS},{key:"Enter",run:fS,shift:fS},{key:"Mod-a",run:UK},{key:"Backspace",run:Py,shift:Py,preventDefault:!0},{key:"Delete",run:BM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:HM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QK,preventDefault:!0},{mac:"Mod-Backspace",run:ZK,preventDefault:!0},{mac:"Mod-Delete",run:eX,preventDefault:!0}].concat(dX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),pX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:TK,shift:FK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:EK,shift:$K},{key:"Alt-ArrowUp",run:rX},{key:"Shift-Alt-ArrowUp",run:sX},{key:"Alt-ArrowDown",run:iX},{key:"Shift-Alt-ArrowDown",run:oX},{key:"Mod-Alt-ArrowUp",run:GK},{key:"Mod-Alt-ArrowDown",run:qK},{key:"Escape",run:YK},{key:"Mod-Enter",run:uX},{key:"Alt-l",mac:"Ctrl-l",run:KK},{key:"Mod-i",run:XK,preventDefault:!0},{key:"Mod-[",run:XM},{key:"Mod-]",run:KM},{key:"Mod-Alt-\\",run:cX},{key:"Shift-Mod-k",run:lX},{key:"Shift-Mod-\\",run:DK},{key:"Mod-/",run:rK},{key:"Alt-A",mac:"Ctrl-A",run:sK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:fX}].concat(hX),gX={key:"Tab",run:KM,shift:XM};var dS={};class Kh{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Kh(e,[],n,r,r,0,[],0,i?new hS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Kh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new mX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class hS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class mX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Xh{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Xh(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Xh(this.stack,this.pos,this.index)}}function wd(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Bd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const pS=new Bd;class yX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=pS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=pS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Aa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;vX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Aa.prototype.contextual=Aa.prototype.fallback=Aa.prototype.extend=!1;Aa.prototype.fallback=Aa.prototype.extend=!1;function vX(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||wX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function gS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function wX(t,e,n,r){let i=gS(n,r,e);return i<0||gS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class xX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?mS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?mS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Tn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class bX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Bd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new Bd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Bd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new xX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&CX(i);if(o)return $r&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw $r&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return $r&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(Tt.contextHash)||0)==c))return e.useNode(f,d),$r&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Tn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Tn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),$r&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return yS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),$r&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&($r&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)$r&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))$r&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),$r&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),yS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Sw(n.map((l,a)=>Or.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=rM;let o=wd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Aa(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new kX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Es(this.data,s+2);else break;i=n(Es(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Es(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Gh.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=vS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const TX=aM({String:Ue.string,Number:Ue.number,"True False":Ue.bool,PropertyName:Ue.propertyName,Null:Ue.null,", :":Ue.separator,"[ ]":Ue.squareBracket,"{ }":Ue.brace}),EX=Gh.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[TX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),AX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=MX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function MX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const RX=jh.define({name:"json",parser:EX.configure({props:[hM.add({Object:Zk({except:/^\s*\}/}),Array:Zk({except:/^\s*\]/})}),V7.add({"Object Array":U7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function wS(){return new _7(RX)}class xS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class il{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ls).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new $a,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),h++}for(;hw.from||w.to==m))l.push(w),h++,x=Math.min(w.to,x);else{x=Math.min(w.from,x);break}}x=Math.min(x,f);let g=!1;if(l.some(w=>w.from==m&&(w.to==x||x==f))&&(g=m==x,!g&&x-m<10)){let w=m-(c+u.value.length);w>0&&(u.next(w),c=m);for(let k=m;;){if(k>=x){g=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=WX(l);if(g)o.add(m,m,Vt.widget({widget:new zX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Vt.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new xS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new xS(r.from,s,r.diagnostic)}}),r}function OX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ls).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Iw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function PX(t,e){return t.field(_i,!1)?e:e.concat(qt.appendConfig.of(JM))}function IX(t,e){return{effects:PX(t,[Iw.of(e)])}}const Iw=qt.define(),GM=qt.define(),qM=qt.define(),_i=gs.define({create(){return new il(Vt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=Ua(n,t.selected.diagnostic,s)||Ua(n,null,s)}!n.size&&i&&e.state.facet(ls).autoPanel&&(i=null),t=new il(n,i,r)}for(let n of e.effects)if(n.is(Iw)){let r=e.state.facet(ls).autoPanel?n.value.length?qh.open:null:t.panel;t=il.init(n.value,r,e.state)}else n.is(GM)?t=new il(t.diagnostics,n.value?qh.open:null,t.selected):n.is(qM)&&(t=new il(t.diagnostics,t.panel,n.value));return t},provide:t=>[by.from(t,e=>e.panel),Ke.decorations.from(t,e=>e.diagnostics)]}),NX=Vt.mark({class:"cm-lintRange cm-lintRange-active"});function DX(t,e,n){let{diagnostics:r}=t.state.field(_i),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(eQM(t,n,!1)))}const bS=t=>{let e=t.state.field(_i,!1);return!e||!e.panel?!1:(t.dispatch({effects:GM.of(!1)}),!0)},LX=gi.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ls);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(IX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{li(this.view.state,r)})}}update(t){let e=t.state.facet(ls);(t.docChanged||e!=t.startState.facet(ls)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function FX(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const ls=je.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...rA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:kS,tooltipFilter:kS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function kS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function $X(t,e={}){return[ls.of({source:t,config:e}),LX,JM]}function YM(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function QM(t,e,n){var r;let i=n?YM(e.actions):[];return ts("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ts("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=Ua(t.state.field(_i).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),ts("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return ts("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&ts("div",{class:"cm-diagnosticSource"},e.source))}class zX extends nu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ts("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class SS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QM(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)bS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=YM(s.actions);for(let l=0;l{for(let s=0;sbS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(_i).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(_i),r=Ua(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:qM.of(r)})}static open(e){return new qh(e)}}function BX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function xd(t){return BX(``,'width="6" height="3"')}const jX=Ke.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:xd("#f11")},".cm-lintRange-warning":{backgroundImage:xd("orange")},".cm-lintRange-info":{backgroundImage:xd("#999")},".cm-lintRange-hint":{backgroundImage:xd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function HX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function WX(t){let e="hint",n=1;for(let r of t){let i=HX(r.severity);i>n&&(n=i,e=r.severity)}return e}const VX=h7(DX,{hideOn:OX}),JM=[_i,Ke.decorations.compute([_i],t=>{let{selected:e,panel:n}=t.field(_i);return!e||!n||e.from==e.to?Vt.none:Vt.set([NX.range(e.from,e.to)])}),VX,jX],UX=512*1024,CS=512*1024,ZM=2e6;function KX(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` -`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const XX=t=>t.state.doc.length>UX?[]:AX()(t);function TS(t){return Lp.define([{tag:Ue.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ue.string,color:t?"#86efac":"#15803d"},{tag:Ue.number,color:t?"#fcd34d":"#b45309"},{tag:Ue.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ue.null,color:t?"#a1a1aa":"#71717a"}])}const GX=Ke.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function eR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=v.useRef(null),c=v.useRef(null),f=v.useRef(e);f.current=e;const d=v.useRef(i),h=v.useRef(null),p=v.useRef(null),m=v.useRef(null),x=n??e!==void 0,g=v.useRef(x),y=v.useRef(r),w=t.length>CS,k=v.useRef(w),b=!x&&t.length>ZM,S=b?KX(t,CS):t,T=v.useRef(!1),A=v.useCallback((M,O,_)=>M?[Ke.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[$X(XX,{delay:300})]]:[$t.readOnly.of(!0),Ke.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new dl,_=new dl,P=new dl,I=$t.create({doc:S,extensions:[P.of(w||!r?[]:wS()),Ke.lineWrapping,dK(),ZA.of([...pX,...bK,gX]),GX,O.of(eS(TS(i))),_.of(A(x,w,r)),...s?[i7(s)]:[]]}),D=new Ke({state:I,parent:M});return h.current=O,p.current=_,m.current=P,a==null||a(D),c.current=D,()=>{D.destroy(),c.current=null}},[]),v.useEffect(()=>{const M=c.current;if(!M)return;const O=m.current,_=p.current,P=[];(w!==k.current||r!==y.current)&&(k.current=w,y.current=r,O&&P.push(O.reconfigure(w||!r?[]:wS())),_&&P.push(_.reconfigure(A(x,w,r))));const I=M.state.doc.toString();if(!(I===S&&P.length===0)){T.current=!0;try{M.dispatch({...I!==S?{changes:{from:0,to:M.state.doc.length,insert:S}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[S,w,r,x,A]),v.useEffect(()=>{const M=c.current,O=p.current;!M||!O||x!==g.current&&(g.current=x,M.dispatch({effects:O.reconfigure(A(x,w,r))}))},[x,w,r,A]),v.useEffect(()=>{const M=c.current;if(!M||i===d.current)return;d.current=i;const O=h.current;O&&M.dispatch({effects:O.reconfigure(eS(TS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:Tr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[b?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function tR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const ul="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Iy={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(m,x){var g=new RegExp(m,"g");h[m]=(d.match(g)||[]).length,p=!p||h[m]>h[p]?m:p}),p}function u(d){for(var h={},p=0;p=0;p--){var m=d[p];h[m]>0&&(m=m+"__"+h[m]--),x.unshift(m)}return x}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var m=[];try{o=h.trim!==!1;var m=f.parse(d,l[p])}catch(oe){var x=d.lastIndexOf(` -`,oe.offset),g=d.indexOf(` -`,oe.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw oe.message+" On line "+oe.line+" and column "+oe.column+`. -`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),S=0;Sy&&(y=g,w=[]),w.push(R))}function b(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function S(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function T(){var R,N,L,H;return L=g,H=g,R=function(q){return Z="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function A(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function M(){var R,N,L,H,q,B,V,le,ge;for(B=g,V=g,R=[],/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=O(),N!==null){if(L=[],le=g,ge=g,/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]")),q!==null)for(H=[];q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));else H=null;for(H!==null?(q=O(),q!==null?H=[H,q]:(H=null,g=ge)):(H=null,g=ge),H!==null&&(H=function(Me,Fe){return Fe}(le,H[1])),H===null&&(g=le);H!==null;){if(L.push(H),le=g,ge=g,/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]")),q!==null)for(H=[];q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));else H=null;H!==null?(q=O(),q!==null?H=[H,q]:(H=null,g=ge)):(H=null,g=ge),H!==null&&(H=function(Me,Fe){return Fe}(le,H[1])),H===null&&(g=le)}if(L!==null){for(H=[],/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));H!==null?R=[R,N,L,H]:(R=null,g=V)}else R=null,g=V}else R=null,g=V;else R=null,g=V;return R!==null&&(R=function(Me,Fe,_e){return _e.unshift(Fe),_e}(B,R[1],R[2])),R===null&&(g=B),R}function O(){var R,N,L,H,q,B,V,le,ge;if(B=g,V=g,R=_(),R!==null){for(N=[],le=g,ge=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(Me,Fe){return Fe==Z}(g,L)?"":null,H!==null?(q=_(),q!==null?L=[L,H,q]:(L=null,g=ge)):(L=null,g=ge)):(L=null,g=ge),L!==null&&(L=function(Me,Fe,_e){return _e}(le,L[0],L[2])),L===null&&(g=le);L!==null;)N.push(L),le=g,ge=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(Me,Fe){return Fe==Z}(g,L)?"":null,H!==null?(q=_(),q!==null?L=[L,H,q]:(L=null,g=ge)):(L=null,g=ge)):(L=null,g=ge),L!==null&&(L=function(Me,Fe,_e){return _e}(le,L[0],L[2])),L===null&&(g=le);N!==null?(L=function(Me,Fe,_e){return!!Fe||_e.length}(g,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,g=V)):(R=null,g=V)}else R=null,g=V;return R!==null&&(R=function(Me,Fe,_e){return _e.unshift(Fe),_e}(B,R[0],R[1])),R===null&&(g=B),R}function _(){var R,N,L,H,q,B;if(H=g,q=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null){for(N=[],L=P();L!==null;)N.push(L),L=P();N!==null?(p.charCodeAt(g)===34?(L='"',g++):(L=null,k('"\\""')),L!==null?R=[R,N,L]:(R=null,g=q)):(R=null,g=q)}else R=null,g=q;if(R!==null&&(R=function(V,le){return le.join("")}(H,R[1])),R===null&&(g=H),R===null){for(H=g,R=[],q=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(V,le){return le!=Z}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(V,le){return le}(q,N[0])),N===null&&(g=q);N!==null;)R.push(N),q=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(V,le){return le!=Z}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(V,le){return le}(q,N[0])),N===null&&(g=q);R!==null&&(R=function(V,le){return(o?le.join("").trim():le.join("")).replace(/(^")|("$)/g,"")}(H,R)),R===null&&(g=H)}return R}function P(){var R,N,L,H;return L=g,H=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(g)===34?(N='"',g++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q){return'"'}()),R===null&&(g=L),R===null&&(/^[^"]/.test(p.charAt(g))?(R=p.charAt(g),g++):(R=null,k('[^"]'))),R}function I(R){R.sort();for(var N=null,L=[],H=0;H=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function iG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function sG(t){const e=n=>{if(!mo(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(iG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):mo(t)?e(t):t}function oG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function lG(t,e,n){if(n==="string")return t;if(n==="number")return AS(t);if(n==="boolean")return oG(t);if(e.parseJSON){const r=rG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?AS(t):t}function aG(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=lG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>mo(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=mo(s)?n(s):s;return r}const uG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function rR(t){const e=uG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function Dy(t){const e=new Set(t),n=new Map;for(const i of t){const s=rR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function MS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function RS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>rR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const m=d.get(p.index);m?m.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const m=d.get(p)??[],x={};for(const g of m){if(!g.subKey)continue;const y=t[g.column];MS(y,r)||(x[g.subKey]=y)}Object.keys(x).length>0&&h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const m=d.get(p);if(!m)continue;const x=t[m];MS(x,r)||h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function cG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!mo(r))return e;const i=Object.keys(r),s=Dy(i);return s.length===0?e:e.map(o=>mo(o)?RS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!mo(r))return e;const i=Object.keys(r),s=Dy(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=mo(a)?RS(a,i,s,n):a;return o}return e}function OS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(ES)?t.slice(ES.length):t;try{const i=YX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=aG(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?cG(i,s,n.emptyFields):s}catch(i){throw new Error(nR(i))}}function fG(t,e={}){try{const n=e.flatten?sG(t):t;return JX(n,e)}catch(n){const r=nR(n);throw tG.some(i=>r.startsWith(i))?new ZX(eG(r,e.flatten??!1)):new Error(r)}}function dG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const zr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},PS=["data","items","results","records","rows"];function IS(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hG(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!IS(n))return[];const r=Object.keys(n),i=new Set(PS),s=[...PS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>IS(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function iR(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function pG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=iR(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function gG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const NS=t=>t==="auto"?void 0:t;function mG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:u}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=iR(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=NS(n.separator),s=fG(r,{separator:i,flatten:n.flatten}),o=tf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function wG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function _u({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:ul,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function xG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function bG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:m,onCellCommit:x,canUndo:g=!1,canRedo:y=!1,onUndo:w,onRedo:k,collapseIndexedArrays:b=!0,onToggleCollapseIndexedArrays:S,columnTypes:T,onChangeColumnTypes:A}){const[M,O]=v.useState(!1),[_,P]=v.useState(!1),I=v.useRef(0),D=v.useRef(null),Z=e.trim()==="",ne=t==="CSV",oe=v.useMemo(()=>{if(!ne||Z)return[];const V=xG(e),le=tf(V,m);return Dy(le.headers.map(ge=>ge.trim()))},[ne,Z,e,m]),W=v.useMemo(()=>ne||Z?[]:hG(e),[ne,Z,e]),U=v.useMemo(()=>ne||Z?null:pG(e),[ne,Z,e]),R=V=>{var le;V.preventDefault(),Array.from(((le=V.dataTransfer)==null?void 0:le.types)??[]).includes("Files")&&(I.current++,P(!0))},N=()=>{I.current=Math.max(0,I.current-1),I.current===0&&P(!1)},L=V=>{var ge,Me;V.preventDefault(),I.current=0,P(!1);const le=(Me=(ge=V.dataTransfer)==null?void 0:ge.files)==null?void 0:Me[0];le&&r(le,"drop")},H=V=>{var ge;if(!Z||V.defaultPrevented||V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLInputElement)return;const le=(ge=V.clipboardData)==null?void 0:ge.getData("text/plain");le&&(V.preventDefault(),n(le))},q=ne?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!M,onClick:()=>O(!1),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",M?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(hN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":M,onClick:()=>O(!0),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(ux,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,B=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(wG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:R,onDragOver:V=>V.preventDefault(),onDragLeave:N,onDrop:L,onPaste:H,"data-drag-over":_||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(tR,{title:t,meta:B,actions:E.jsxs(E.Fragment,{children:[q,ne&&(g||y)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!g,onClick:()=>w==null?void 0:w(),className:ul,children:E.jsx(xN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!y,onClick:()=>k==null?void 0:k(),className:ul,children:E.jsx(nN,{"aria-hidden":"true"})})]}):null,U?E.jsx(_u,{label:U.label,testId:"json-format-toggle",onClick:()=>n(U.nextInput),Icon:ux,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:D,type:"file","data-testid":"file-input",accept:ne?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:V=>{var ge;const le=(ge=V.target.files)==null?void 0:ge[0];le&&r(le,"picker"),V.target.value=""}}),E.jsx(_u,{label:"Upload",testId:"upload",onClick:()=>{var V;return(V=D.current)==null?void 0:V.click()},Icon:hT}),E.jsx(_u,{label:"Copy",testId:"copy-input",onClick:o,Icon:Nv}),E.jsx(_u,{label:"Clear",testId:"clear-input",onClick:s,disabled:Z,Icon:hh}),E.jsx(_u,{label:"Download",testId:"download-input",onClick:a,disabled:Z,Icon:dT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[Z?E.jsx(j9,{format:t,onIngest:n,onBrowse:()=>{var V;return(V=D.current)==null?void 0:V.click()},onTryExample:i}):ne?E.jsxs(E.Fragment,{children:[oe.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${oe.map(V=>`${V.prefix}[${V.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>S==null?void 0:S(),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",b?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:b?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,M?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:V=>n(V.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(zE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:T,onChangeColumnTypes:A})]}):E.jsxs(E.Fragment,{children:[W.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),W.map(V=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${V.key}`,onClick:()=>n(V.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${V.key} (${V.rowCount} ${V.rowCount===1?"row":"rows"})`},V.key))]}):null,E.jsx(eR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),_?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const kG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function SG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:kG.test(t.name)}const CG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function DS(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function sR(t){const[e,n]=v.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return v.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const oR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function _S(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function TG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=oR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function LS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function FS(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function $S({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function eo({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:Tr("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:Tr("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(_y,{text:r}):null]})}function _y({text:t}){const e=v.useId(),[n,r]=v.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function EG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=v.useState(!1),a=v.useRef(null),u=v.useRef(null),c=sR("(min-width: 98.5rem)"),f=t==="csv2json",d=TG(t,e),h=v.useCallback(()=>{var m;l(!1),(m=a.current)==null||m.focus()},[]);v.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&h()},x=g=>{const y=u.current;y===null||!(g.target instanceof Node)||y.contains(g.target)||h()};return document.addEventListener("keydown",m),document.addEventListener("click",x),()=>{document.removeEventListener("keydown",m),document.removeEventListener("click",x)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx($S,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:m=>n({separator:m.target.value}),className:LS(),children:oR.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(FS,{})]})]}),E.jsx(_y,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(_S,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx($S,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:m=>s(m.target.value),className:LS(),children:CG.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(FS,{})]})]}),E.jsx(_y,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(_S,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(eo,{label:"Parse numbers",checked:e.parseNumbers,onChange:m=>n({parseNumbers:m}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(eo,{label:"Parse JSON",checked:e.parseJSON,onChange:m=>n({parseJSON:m}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(eo,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:m=>n({emptyFields:m?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(eo,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:m=>n({nullLiterals:m?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(eo,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(eo,{label:"Hash output",checked:e.hash,onChange:m=>n({hash:m}),hint:"The first column becomes the object key instead of a field."}),E.jsx(eo,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(eo,{label:"Flatten nested arrays",checked:e.flatten,onChange:m=>n({flatten:m}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(UI,{"aria-hidden":"true",className:Tr("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:Tr("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const AG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],MG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),RG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function jd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Nw(t){if(Array.isArray(t))return t.map(e=>jd(e)?e:{value:e});if(jd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>jd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function lR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function OG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!MG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function Mm(t){return`"${t.replace(/"/g,'""')}"`}function PG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function IG(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function NG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return Nw(n).map(i=>JSON.stringify(i)).join(` -`)}function DG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Nw(r),s=lR(i),o=Mm(OG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=PG(h);return` ${Mm(d)} ${p}`}),a=`CREATE TABLE ${o} ( -${l.join(`, -`)} -);`;if(i.length===0)return a;const u=s.map(Mm).join(", "),c=i.map(d=>` (${s.map(p=>IG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES -${c.join(`, -`)};`;return`${a} - -${f}`}function aR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=uR(Array.from(new Set(t.map(n=>aR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return jd(t)?"Record":"unknown"}const zS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function uR(t){return[...t].sort((e,n)=>{const r=zS[e]??50,i=zS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function _G(t){return RG.test(t)?t:JSON.stringify(t)}function LG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Nw(n),s=lR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(aR(h[l]))}const c=uR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${_G(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { -${s.join(` -`)} -}`:"export interface DataRow {}"} - -export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function FG(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return NG(i);case"sql":return DG(i,s);case"ts":return LG(i)}}const $G=3;function zG(t){const e=t.slice(0,$G),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` -`)}function BG({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onNativeCopy:p,onDownload:m,onEgressFormatChange:x,onOutputChange:g,onRevert:y,onDiscardReconvert:w}){const k=t==="JSON",b=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(tR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:y,className:ul,children:[E.jsx(cx,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[k?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:AG.map(S=>{const T=u===S.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${S.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(S.format),className:Tr("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:S.label},S.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:ul,children:[E.jsx(Nv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:m,disabled:!n,className:ul,children:[E.jsx(dT,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:w?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:w,className:ul+" ml-2",children:[E.jsx(cx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:zG(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?k?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>p==null?void 0:p(),children:E.jsx(eR,{value:n,editable:a&&b&&n.length<=ZM,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):E.jsx(zE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function jG({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const Dw="csvjson:recent.v1",cR=10,fR=1e5,BS=80;function HG(t){return t==="csv2json"||t==="json2csv"}function WG(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function dR(t){if(typeof t!="object"||t===null)return{...zr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:zr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:zr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:zr.nullLiterals,o=WG(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:zr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:zr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:zr.transpose,hash:typeof e.hash=="boolean"?e.hash:zr.hash,minify:typeof e.minify=="boolean"?e.minify:zr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:zr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:zr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function hR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=BS?n:`${n.slice(0,BS-1)}…`}function VG(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!HG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>fR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function UG(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:dR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||hR(t.input)}}function pR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Dw,JSON.stringify(t))}catch{}}function KG(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function _w(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Dw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(VG).map(UG).sort((r,i)=>i.createdAt-r.createdAt).slice(0,cR):[]}catch{return[]}}function jS(t){const e=_w(),n=t.input.trim();if(n===""||t.input.length>fR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??KG(r),createdAt:r,direction:t.direction,input:t.input,options:dR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:hR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,cR);return pR(l),l}function XG(t){const n=_w().filter(r=>r.id!==t);return pR(n),n}function GG(){try{if(typeof window>"u")return;window.localStorage.removeItem(Dw)}catch{}}function qG(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function YG(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function QG(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function JG({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=v.useState(!1),o=v.useRef(null),l=v.useRef(null),a=v.useCallback(()=>{s(!1)},[]),u=v.useRef(!1);v.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),v.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(qI,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:YG(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:QG(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:qG(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(hh,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Ly=20,Fy=80,HS=50;function Rm(t){return Math.min(Fy,Math.max(Ly,t))}function ZG({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=v.useRef(null),[l,a]=v.useState(!1),u=t==="stacked";v.useEffect(()=>{if(!l)return;const f=h=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Rm(m*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(Rm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Rm(e+d));break;case"Home":f.preventDefault(),n(Ly);break;case"End":f.preventDefault(),n(Fy);break;case"Enter":case" ":f.preventDefault(),n(HS);break}};return E.jsxs("div",{ref:o,className:Tr("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:Tr("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Ly,"aria-valuemax":Fy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(HS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:Tr("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:Tr("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function eq({theme:t}){return t==="dark"?E.jsx(fN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(eN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function tq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(eq,{theme:t})})]})}function nq(t){return[...t].sort((e,n)=>n.id-e.id)}const gR=[{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],rq=864e5;function WS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function iq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((WS(r)-WS(n))/rq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const mR="csvjson:changelog.v1",Hd=Math.max(...gR.map(t=>t.id),0),sq=nq(gR);function oq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!lq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function lq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function yR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Hd).sort((e,n)=>e-n)}function VS(t,e,n){const r=yR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function aq(){try{const t=window.localStorage.getItem(mR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return oq(e)?{...e,pendingIds:yR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function uq(t){try{window.localStorage.setItem(mR,JSON.stringify(t))}catch{}}function cq(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function fq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function US(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:iq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:US(e===1),children:E.jsx(yN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:US(e===-1),children:E.jsx(gN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function hq(){const[t,e]=v.useState(aq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{uq(b),i.current=b,e(b)},[]),[o,l]=v.useState(()=>new Set),a=v.useRef(new Set),u=v.useRef(null),c=v.useRef(null),f=v.useRef(new Map),d=t.lastSeenId!==null&&Hd>t.lastSeenId,h=v.useCallback((b,S)=>{l(T=>{const A=new Set(T);return S?A.add(b):A.delete(b),A})},[]),p=v.useCallback((b,S,T,A)=>{const M=(f.current.get(b)??0)+1;f.current.set(b,M),a.current.add(b),A&&h(b,!0),fq(T,b,S).then(O=>{f.current.get(b)===M&&(a.current.delete(b),O==="ok"&&(EI({entry_id:b,vote:S}),s(VS(i.current,b,!1))),A&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:S,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&S!==void 0)for(const O of M){if(O===b||a.current.has(O))continue;const _=A[O];_!==void 0&&p(O,_,S,!1)}},[p]),x=(b,S)=>{if(t.votes[b]===S){m();return}const T=t.clientId??cq();s(VS({...t,votes:{...t.votes,[b]:S},clientId:T},b,!0)),p(b,S,T,!0),m(b)},g=()=>{r(!0),TI(),t.lastSeenId!==Hd&&s({...t,lastSeenId:Hd}),m()},y=v.useCallback(()=>{r(!1)},[]),w=v.useRef(!1);v.useEffect(()=>{var b;w.current&&!n&&((b=c.current)==null||b.focus()),w.current=n},[n]);const k=v.useRef(!1);return v.useEffect(()=>{k.current||(k.current=!0,m())},[m]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&y()},S=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",S)}},[n,y]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?y():g(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(iN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:y,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:sq.map(b=>{var S;return E.jsx(dq,{entry:b,vote:t.votes[b.id],queued:((S=t.pendingIds)==null?void 0:S.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function pq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const gq={},mq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],yq=["csv2json","json2csv","csvjson2json"];function vq(t){return yq.includes(t)}const wq=/^[0-9a-f]{32}$/i,xq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Om=gq,bq=((Om==null?void 0:Om.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function kq(t){const e=xq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return mq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class $y extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Pm extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Im={csv:(t,e)=>{t.direction="csv2json",t.input=Yh(e)},json:(t,e)=>{t.input=Yh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Yh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function KS(t){return typeof t=="string"&&t.trim()!==""}function Gl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function Sq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Cq(t){var i;if(!Sq(t))return null;const e=KS(t.csv),n=KS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Im[s])==null||i.call(Im,r,o);return r.input=Yh(e?t.csv:t.json),r}async function Tq(t){if(!wq.test(t))throw new $y;let e;try{e=await fetch(`${bq}${t}`,{mode:"cors"})}catch(r){throw new Pm("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new $y;if(!e.ok)throw new Pm(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new Pm("Stored data for this link is malformed")}return n}function Eq(t){const e=v.useMemo(()=>t&&vq(t.tool)?t.id:null,[t]),[n,r]=v.useState(0),[i,s]=v.useState(e?"loading":"idle"),[o,l]=v.useState(null),[a,u]=v.useState("");return v.useEffect(()=>{if(!e)return;let c=!1;return Tq(e).then(f=>{if(c)return;const d=Cq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof $y?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function XS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const Aq="\uFEFF";function Mq(t,e){return e?Aq+t:t}function Rq(t,e,n){const r=Mq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Oq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Pq(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!Oq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function Iq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Pq(t)}.${r}`:`data.${r}`}function Nq(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function GS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Rq(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function Dq(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const _q=`album,year,US_peak_chart_post -The White Stripes,1999, -De Stijl,2000, -White Blood Cells,2001,61 -Elephant,2003,6 -Get Behind Me Satan,2005,3 -Icky Thump,2007,2`,Lq=`[ - { - "album": "Elephant", - "year": 2003, - "label": "XL Recordings" - }, - { - "album": "Icky Thump", - "year": 2007, - "label": "XL Recordings" - } -]`,vR="csvjson-theme";function Fq(){try{const t=localStorage.getItem(vR);return t==="dark"||t==="light"?t:null}catch{return null}}function $q(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function zq(){return Fq()??$q()}function Bq(t){try{localStorage.setItem(vR,t)}catch{}}function jq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const qS=2*1024*1024,Hq=150,Wq=1e3,Vq=2e3,Uq=2e3;function Kq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function YS(t){try{return JSON.parse(t),!0}catch{return!1}}function Xq(){var dn;const[t,e]=v.useState(zq);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(re=>{const De=re==="dark"?"light":"dark";return Bq(De),De}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":jq(window.location.search)),[s,o]=v.useState(()=>Go("")),l=s.present,[a,u]=v.useState(zr),[c,f]=v.useState("json"),[d,h]=v.useState(50),[p,m]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(null),[k,b]=v.useState("utf-8"),[S,T]=v.useState(_w),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=DI({settleMs:Vq,minWindowMs:Uq,isValid:(re,De)=>{const ze=A.current;return De===ze.input?ze.resultOk:Zs(re==="csv_to_json"?"csv2json":"json2csv",De,ze.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=sR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",Z=I?"JSON":"CSV",ne=l.trim()==="",oe=l.length>qS?Wq:Hq,W=pq(l,ne?0:oe),U=v.useRef(null),R=v.useRef(null),L=l!==""&&((dn=U.current)==null?void 0:dn.text)===l?l:W,H=v.useMemo(()=>typeof window>"u"?null:kq(window.location.pathname),[]),q=Eq(H),B=v.useMemo(()=>Zs(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const re=R.current;!re||re.text!==L||(R.current=null,O.discrete(re.direction,re.via,re.text))},[L,B,O]);const[V,le]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&B.ok&&le(B.text)},[B,L]),v.useEffect(()=>{L.trim()!==""&&(!B.ok||B.rows<=0&&B.cols<=0||T(jS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const ge=L.trim()!==""&&B.ok?B.text:V,[Me,Fe]=v.useState(!1),[_e,ft]=v.useState(null),Xe=Me?_e:ge,Ge=v.useMemo(()=>{if(!I||Xe===null||c==="json")return Xe;const re=Me&&_e!==null&&YS(_e)?_e:ge;return re===null?null:FG(re,c,a,p)},[I,Xe,c,Me,_e,ge,a,p]),lt=I&&c==="json"&&!ne&&Ge!==null&&(Me||B.ok),Ut=v.useCallback(re=>{if(re===ge){Fe(!1),ft(null);return}Fe(!0),ft(re)},[ge]),Re=v.useCallback(()=>{const re=Zs(r,l,a);re.ok&&le(re.text),Fe(!1),ft(null)},[r,l,a]),we=v.useCallback(re=>{o(De=>I?Kb(De,re):Go(re))},[I]),Qe=I&&s.past.length>0,nt=I&&s.future.length>0,it=v.useCallback(()=>{if(!I||s.past.length===0)return;const re=S9(s);w(null),o(re),O.edit("csv_to_json",re.present)},[I,s,O]),$e=v.useCallback(()=>{if(!I||s.future.length===0)return;const re=C9(s);w(null),o(re),O.edit("csv_to_json",re.present)},[I,s,O]),At=v.useCallback(re=>{w(null),U.current=null,i(re.direction),u({...re.options}),m(re.filename),Fe(!1),ft(null),o(De=>re.direction==="csv2json"&&r==="csv2json"?Kb(De,re.input):Go(re.input)),T(jS({direction:re.direction,input:re.input,options:re.options,filename:re.filename,rows:re.rows,cols:re.cols}))},[r]),wt=v.useCallback(re=>{T(XG(re))},[]),rt=v.useCallback(()=>{GG(),T([])},[]),me=()=>{const re=r==="csv2json"?"json2csv":"csv2json";if(Me){const De=_e??"",ze=YS(De)?De:l;o(Go(ze)),i(re),Fe(!1),ft(null),ze.trim()!==""&&(A.current={direction:re,options:a,input:ze,resultOk:Zs(re,ze,a).ok},O.discrete(re==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(re),ne)o(Go(""));else{const De=Zs(r,l,a),ze=De.ok?De.text:l;o(Go(ze)),ze.trim()!==""&&(A.current={direction:re,options:a,input:ze,resultOk:Zs(re,ze,a).ok},O.discrete(re==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},Ne=q.hydrated;v.useEffect(()=>{if(Ne===null)return;const re={...A.current.options,...Ne.options};A.current={direction:Ne.direction,options:re,input:Ne.input,resultOk:Zs(Ne.direction,Ne.input,re).ok},i(Ne.direction),o(Go(Ne.input)),u(De=>({...De,...Ne.options})),Fe(!1),ft(null),CI(),O.discrete(Ne.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Ne.input)},[Ne,O]);const Je=async(re,De)=>{if(!SG(re)){w(`Can't read "${re.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const ze=await DS(re,k);U.current={file:re,source:De,text:ze},R.current={direction:I?"csv_to_json":"json_to_csv",via:De==="drop"?"drag":"file",text:ze},we(ze),m(re.name),g(!1)}catch{g(!1),w(`Couldn't read "${re.name}".`)}},tt=async re=>{const De=k;b(re);const ze=U.current;if(!(!ze||l!==ze.text)){g(!0);try{const An=await DS(ze.file,re);U.current={...ze,text:An},R.current={direction:I?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:An},o(z=>({...z,present:An})),g(!1)}catch{g(!1),b(De),w(`Couldn't read "${ze.file.name}".`)}}},Kt=v.useCallback(re=>{w(null),re.trim()===""&&u(De=>{if(!De.columnTypes)return De;const ze={...De};return delete ze.columnTypes,ze}),we(re),O.edit(I?"csv_to_json":"json_to_csv",re)},[we,I,O]);v.useEffect(()=>{const re=De=>{var An;const ze=(An=De.clipboardData)==null?void 0:An.getData("text/plain");!ze||Dq(De.target)||(De.preventDefault(),De.stopPropagation(),m(null),Kt(ze))};return document.addEventListener("paste",re,!0),()=>document.removeEventListener("paste",re,!0)},[Kt]);const dt=B.ok?Kq(B.rows,B.cols):null,ht=!B.ok&&V?"Last valid result — input has errors":null,pt=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Lt=l.length>qS,Rt=I?"csv_to_json":"json_to_csv",en=I?c:"csv",Hn=()=>{Uo({via:"copy",format:I?"csv":"json",pane:"input",direction:Rt}),XS(l)},Pt=()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt}),Ge&&XS(Ge)},vn=()=>{Uo({via:"download",format:I?"csv":"json",pane:"input",direction:Rt}),GS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},In=()=>{Uo({via:"download",format:en,pane:"output",direction:Rt}),GS(Ge??"",Iq(p,I?"csv2json":"json2csv",c),{mime:Nq(I?"csv2json":"json2csv",c),bom:!I})},Pr=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"input",direction:Rt})},[Rt]),Ir=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"output",direction:Rt})},[Rt]),Bt=v.useCallback(()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt})},[en,Rt]),ut=E.jsx(bG,{format:D,input:l,onInputChange:Kt,onCellCommit:Kt,onFile:Je,onTryExample:()=>{w(null);const re=I?_q:Lq;A.current={direction:r,options:a,input:re,resultOk:Zs(r,re,a).ok},we(re),O.discrete(Rt,"example",re)},onClear:()=>{we(""),m(null),u(re=>{if(!re.columnTypes)return re;const De={...re};return delete De.columnTypes,De}),Fe(!1),ft(null),O.cancel()},onCopy:Hn,onCopySelection:Pr,onDownload:vn,canUndo:Qe,canRedo:nt,onUndo:it,onRedo:$e,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(re=>({...re,collapseIndexedArrays:!(re.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:re=>u(De=>{const ze={...De};return Object.keys(re).length>0?ze.columnTypes=re:delete ze.columnTypes,ze}),filename:p,reading:x,meta:dt,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),xt=E.jsx(BG,{format:Z,inputEmpty:ne,outputText:Ge,error:B.ok?null:B.error,meta:dt,staleNotice:ht,warnings:pt,edited:Me,editable:lt,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Pt,onCopySelection:Ir,onNativeCopy:Bt,onDownload:In,onEgressFormatChange:f,onOutputChange:Ut,onRevert:Re,onDiscardReconvert:Re});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(oD,{}),E.jsx(tq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(JG,{snapshots:S,onSelect:At,onRemove:wt,onClear:rt}),E.jsx(hq,{}),E.jsx(fD,{})]})}),H&&(q.phase==="loading"||q.phase==="not-found"||q.phase==="unsupported"||q.phase==="error")?E.jsx(jG,{phase:q.phase,message:q.phase==="error"?q.message:void 0,onRetry:q.retry}):null,E.jsx(ZG,{layout:P,split:d,onSplitChange:h,left:ut,right:xt,children:E.jsx(nD,{direction:r,onFlip:me})}),E.jsx(EG,{direction:r,options:a,onChange:re=>u(De=>({...De,...re})),uploadEncoding:k,onUploadEncodingChange:tt,notice:Lt?"Large file — converting on pause":null})]}),E.jsx(iD,{})]})}uT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(Xq,{})}));document.getElementById("root").removeAttribute("inert");kI();SI();export{e6 as C,Ln as R,T$ as T,ca as a,Q3 as b,xI as c,ql as i,C$ as m,v as r,Qr as s}; diff --git a/app/dist/assets/index-BweuKm2D.js b/app/dist/assets/index-BweuKm2D.js new file mode 100644 index 0000000..0df6415 --- /dev/null +++ b/app/dist/assets/index-BweuKm2D.js @@ -0,0 +1,307 @@ +var GR=Object.defineProperty;var qR=(t,e,n)=>e in t?GR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var bt=(t,e,n)=>qR(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var fo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var QS={exports:{}},Qh={},ZS={exports:{}},Et={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var jc=Symbol.for("react.element"),YR=Symbol.for("react.portal"),JR=Symbol.for("react.fragment"),QR=Symbol.for("react.strict_mode"),ZR=Symbol.for("react.profiler"),eO=Symbol.for("react.provider"),tO=Symbol.for("react.context"),nO=Symbol.for("react.forward_ref"),rO=Symbol.for("react.suspense"),iO=Symbol.for("react.memo"),sO=Symbol.for("react.lazy"),t1=Symbol.iterator;function oO(t){return t===null||typeof t!="object"?null:(t=t1&&t[t1]||t["@@iterator"],typeof t=="function"?t:null)}var eC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tC=Object.assign,nC={};function Ka(t,e,n){this.props=t,this.context=e,this.refs=nC,this.updater=n||eC}Ka.prototype.isReactComponent={};Ka.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Ka.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function rC(){}rC.prototype=Ka.prototype;function By(t,e,n){this.props=t,this.context=e,this.refs=nC,this.updater=n||eC}var jy=By.prototype=new rC;jy.constructor=By;tC(jy,Ka.prototype);jy.isPureReactComponent=!0;var n1=Array.isArray,iC=Object.prototype.hasOwnProperty,Hy={current:null},sC={key:!0,ref:!0,__self:!0,__source:!0};function oC(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)iC.call(e,r)&&!sC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,L=W[N];if(0>>1;Ni(B,R))lei(me,B)?(W[N]=me,W[le]=R,N=le):(W[N]=B,W[G]=R,N=G);else if(lei(me,R))W[N]=me,W[le]=R,N=le;else break e}}return V}function i(W,V){var R=W.sortIndex-V.sortIndex;return R!==0?R:W.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(W){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=W)r(u),V.sortIndex=V.expirationTime,e(a,V);else break;V=n(u)}}function k(W){if(m=!1,w(W),!p)if(n(a)!==null)p=!0,ie(b);else{var V=n(u);V!==null&&te(k,V.startTime-W)}}function b(W,V){p=!1,m&&(m=!1,g(A),A=-1),h=!0;var R=d;try{for(w(V),f=n(a);f!==null&&(!(f.expirationTime>V)||W&&!_());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=V);V=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(V)}else r(a);f=n(a)}if(f!==null)var H=!0;else{var G=n(u);G!==null&&te(k,G.startTime-V),H=!1}return H}finally{f=null,d=R,h=!1}}var S=!1,T=null,A=-1,M=5,O=-1;function _(){return!(t.unstable_now()-OW||125N?(W.sortIndex=R,e(u,W),n(a)===null&&W===n(u)&&(m?(g(A),A=-1):m=!0,te(k,R-N))):(W.sortIndex=L,e(a,W),p||h||(p=!0,ie(b))),W},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(W){var V=d;return function(){var R=d;d=V;try{return W.apply(this,arguments)}finally{d=R}}}})(fC);cC.exports=fC;var yO=cC.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var vO=v,Gr=yO;function pe(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dm=Object.prototype.hasOwnProperty,wO=/^[: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]*$/,i1={},s1={};function xO(t){return Dm.call(s1,t)?!0:Dm.call(i1,t)?!1:wO.test(t)?s1[t]=!0:(i1[t]=!0,!1)}function bO(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function kO(t,e,n,r){if(e===null||typeof e>"u"||bO(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function vr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Gn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Gn[t]=new vr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Gn[e]=new vr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Gn[t]=new vr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Gn[t]=new vr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Gn[t]=new vr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Gn[t]=new vr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Gn[t]=new vr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Gn[t]=new vr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Gn[t]=new vr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Vy=/[\-:]([a-z])/g;function Uy(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Gn[t]=new vr(t,1,!1,t.toLowerCase(),null,!1,!1)});Gn.xlinkHref=new vr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Gn[t]=new vr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ky(t,e,n,r){var i=Gn.hasOwnProperty(e)?Gn[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` +`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{fg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Lu(t):""}function SO(t){switch(t.tag){case 5:return Lu(t.type);case 16:return Lu("Lazy");case 13:return Lu("Suspense");case 19:return Lu("SuspenseList");case 0:case 2:case 15:return t=dg(t.type,!1),t;case 11:return t=dg(t.type.render,!1),t;case 1:return t=dg(t.type,!0),t;default:return""}}function $m(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Zl:return"Fragment";case Ql:return"Portal";case _m:return"Profiler";case Xy:return"StrictMode";case Lm:return"Suspense";case Fm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case pC:return(t.displayName||"Context")+".Consumer";case hC:return(t._context.displayName||"Context")+".Provider";case Gy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case qy:return e=t.displayName||null,e!==null?e:$m(t.type)||"Memo";case ro:e=t._payload,t=t._init;try{return $m(t(e))}catch{}}return null}function CO(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $m(e);case 8:return e===Xy?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Eo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function mC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function TO(t){var e=mC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Rf(t){t._valueTracker||(t._valueTracker=TO(t))}function yC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=mC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Vd(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function zm(t,e){var n=e.checked;return fn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function l1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Eo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function vC(t,e){e=e.checked,e!=null&&Ky(t,"checked",e,!1)}function Bm(t,e){vC(t,e);var n=Eo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?jm(t,e.type,n):e.hasOwnProperty("defaultValue")&&jm(t,e.type,Eo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function a1(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function jm(t,e,n){(e!=="number"||Vd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Fu=Array.isArray;function ma(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Of.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function pc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Vu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},EO=["Webkit","ms","Moz","O"];Object.keys(Vu).forEach(function(t){EO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Vu[e]=Vu[t]})});function kC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Vu.hasOwnProperty(t)&&Vu[t]?(""+e).trim():e+"px"}function SC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=kC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var AO=fn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vm(t,e){if(e){if(AO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(pe(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(pe(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(pe(61))}if(e.style!=null&&typeof e.style!="object")throw Error(pe(62))}}function Um(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Km=null;function Yy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Xm=null,ya=null,va=null;function f1(t){if(t=Vc(t)){if(typeof Xm!="function")throw Error(pe(280));var e=t.stateNode;e&&(e=rp(e),Xm(t.stateNode,t.type,e))}}function CC(t){ya?va?va.push(t):va=[t]:ya=t}function TC(){if(ya){var t=ya,e=va;if(va=ya=null,f1(t),e)for(t=0;t>>=0,t===0?32:31-($O(t)/zO|0)|0}var Pf=64,If=4194304;function $u(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Gd(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=$u(l):(s&=o,s!==0&&(r=$u(s)))}else o=n&~i,o!==0?r=$u(o):s!==0&&(r=$u(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Hc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Fi(e),t[e]=n}function WO(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Ku),x1=" ",b1=!1;function UC(t,e){switch(t){case"keyup":return yP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function KC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function wP(t,e){switch(t){case"compositionend":return KC(e);case"keypress":return e.which!==32?null:(b1=!0,x1);case"textInput":return t=e.data,t===x1&&b1?null:t;default:return null}}function xP(t,e){if(ea)return t==="compositionend"||!iv&&UC(t,e)?(t=WC(),Td=tv=ho=null,ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=T1(n)}}function YC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?YC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function JC(){for(var t=window,e=Vd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Vd(t.document)}return e}function sv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function RP(t){var e=JC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&YC(n.ownerDocument.documentElement,n)){if(r!==null&&sv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=E1(n,s);var o=E1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ta=null,Zm=null,Gu=null,e0=!1;function A1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;e0||ta==null||ta!==Vd(r)||(r=ta,"selectionStart"in r&&sv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gu&&xc(Gu,r)||(Gu=r,r=Jd(Zm,"onSelect"),0ia||(t.current=o0[ia],o0[ia]=null,ia--)}function Zt(t,e){ia++,o0[ia]=t.current,t.current=e}var Ao={},or=Do(Ao),Ar=Do(!1),pl=Ao;function Ra(t,e){var n=t.type.contextTypes;if(!n)return Ao;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Mr(t){return t=t.childContextTypes,t!=null}function Zd(){sn(Ar),sn(or)}function D1(t,e,n){if(or.current!==Ao)throw Error(pe(168));Zt(or,e),Zt(Ar,n)}function o2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(pe(108,CO(t)||"Unknown",i));return fn({},n,r)}function eh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ao,pl=or.current,Zt(or,t),Zt(Ar,Ar.current),!0}function _1(t,e,n){var r=t.stateNode;if(!r)throw Error(pe(169));n?(t=o2(t,e,pl),r.__reactInternalMemoizedMergedChildContext=t,sn(Ar),sn(or),Zt(or,t)):sn(Ar),Zt(Ar,n)}var Ts=null,ip=!1,Eg=!1;function l2(t){Ts===null?Ts=[t]:Ts.push(t)}function jP(t){ip=!0,l2(t)}function _o(){if(!Eg&&Ts!==null){Eg=!0;var t=0,e=Wt;try{var n=Ts;for(Wt=1;t>=o,i-=o,Os=1<<32-Fi(e)+i|n<A?(M=T,T=null):M=T.sibling;var O=d(g,T,w[A],k);if(O===null){T===null&&(T=M);break}t&&T&&O.alternate===null&&e(g,T),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O,T=M}if(A===w.length)return n(g,T),an&&Jo(g,A),b;if(T===null){for(;AA?(M=T,T=null):M=T.sibling;var _=d(g,T,O.value,k);if(_===null){T===null&&(T=M);break}t&&T&&_.alternate===null&&e(g,T),y=s(_,y,A),S===null?b=_:S.sibling=_,S=_,T=M}if(O.done)return n(g,T),an&&Jo(g,A),b;if(T===null){for(;!O.done;A++,O=w.next())O=f(g,O.value,k),O!==null&&(y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return an&&Jo(g,A),b}for(T=r(g,T);!O.done;A++,O=w.next())O=h(T,g,A,O.value,k),O!==null&&(t&&O.alternate!==null&&T.delete(O.key===null?A:O.key),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return t&&T.forEach(function(P){return e(g,P)}),an&&Jo(g,A),b}function x(g,y,w,k){if(typeof w=="object"&&w!==null&&w.type===Zl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Mf:e:{for(var b=w.key,S=y;S!==null;){if(S.key===b){if(b=w.type,b===Zl){if(S.tag===7){n(g,S.sibling),y=i(S,w.props.children),y.return=g,g=y;break e}}else if(S.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===ro&&$1(b)===S.type){n(g,S.sibling),y=i(S,w.props),y.ref=bu(g,S,w),y.return=g,g=y;break e}n(g,S);break}else e(g,S);S=S.sibling}w.type===Zl?(y=fl(w.props.children,g.mode,k,w.key),y.return=g,g=y):(k=Nd(w.type,w.key,w.props,null,g.mode,k),k.ref=bu(g,y,w),k.return=g,g=k)}return o(g);case Ql:e:{for(S=w.key;y!==null;){if(y.key===S)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(g,y.sibling),y=i(y,w.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else e(g,y);y=y.sibling}y=Dg(w,g.mode,k),y.return=g,g=y}return o(g);case ro:return S=w._init,x(g,y,S(w._payload),k)}if(Fu(w))return p(g,y,w,k);if(mu(w))return m(g,y,w,k);zf(g,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(g,y.sibling),y=i(y,w),y.return=g,g=y):(n(g,y),y=Ng(w,g.mode,k),y.return=g,g=y),o(g)):n(g,y)}return x}var Pa=f2(!0),d2=f2(!1),rh=Do(null),ih=null,la=null,uv=null;function cv(){uv=la=ih=null}function fv(t){var e=rh.current;sn(rh),t._currentValue=e}function u0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function xa(t,e){ih=t,uv=la=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Tr=!0),t.firstContext=null)}function hi(t){var e=t._currentValue;if(uv!==t)if(t={context:t,memoizedValue:e,next:null},la===null){if(ih===null)throw Error(pe(308));la=t,ih.dependencies={lanes:0,firstContext:t}}else la=la.next=t;return e}var ol=null;function dv(t){ol===null?ol=[t]:ol.push(t)}function h2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,dv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Fs(t,r)}function Fs(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var io=!1;function hv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function p2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ns(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function bo(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,_t&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Fs(t,n)}return i=r.interleaved,i===null?(e.next=e,dv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Fs(t,n)}function Ad(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}function z1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function sh(t,e,n,r){var i=t.updateQueue;io=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var d=l.lane,h=l.eventTime;if((r&d)===d){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,m=l;switch(d=e,h=n,m.tag){case 1:if(p=m.payload,typeof p=="function"){f=p.call(h,f,d);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=fn({},f,d);break e;case 2:io=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=f):c=c.next=h,o|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);yl|=o,t.lanes=o,t.memoizedState=f}}function B1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=Mg.transition;Mg.transition={};try{t(!1),e()}finally{Wt=n,Mg.transition=r}}function P2(){return pi().memoizedState}function UP(t,e,n){var r=So(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},I2(t))N2(e,n);else if(n=h2(t,e,n,r),n!==null){var i=pr();$i(n,t,r,i),D2(n,e,r)}}function KP(t,e,n){var r=So(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(I2(t))N2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,zi(l,o)){var a=e.interleaved;a===null?(i.next=i,dv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=h2(t,e,i,r),n!==null&&(i=pr(),$i(n,t,r,i),D2(n,e,r))}}function I2(t){var e=t.alternate;return t===cn||e!==null&&e===cn}function N2(t,e){qu=lh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function D2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}var ah={readContext:hi,useCallback:Zn,useContext:Zn,useEffect:Zn,useImperativeHandle:Zn,useInsertionEffect:Zn,useLayoutEffect:Zn,useMemo:Zn,useReducer:Zn,useRef:Zn,useState:Zn,useDebugValue:Zn,useDeferredValue:Zn,useTransition:Zn,useMutableSource:Zn,useSyncExternalStore:Zn,useId:Zn,unstable_isNewReconciler:!1},XP={readContext:hi,useCallback:function(t,e){return Zi().memoizedState=[t,e===void 0?null:e],t},useContext:hi,useEffect:H1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Rd(4194308,4,E2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Rd(4194308,4,t,e)},useInsertionEffect:function(t,e){return Rd(4,2,t,e)},useMemo:function(t,e){var n=Zi();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Zi();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=UP.bind(null,cn,t),[r.memoizedState,t]},useRef:function(t){var e=Zi();return t={current:t},e.memoizedState=t},useState:j1,useDebugValue:bv,useDeferredValue:function(t){return Zi().memoizedState=t},useTransition:function(){var t=j1(!1),e=t[0];return t=VP.bind(null,t[1]),Zi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=cn,i=Zi();if(an){if(n===void 0)throw Error(pe(407));n=n()}else{if(n=e(),jn===null)throw Error(pe(349));ml&30||v2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,H1(x2.bind(null,r,s,t),[t]),r.flags|=2048,Mc(9,w2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Zi(),e=jn.identifierPrefix;if(an){var n=Ps,r=Os;n=(r&~(1<<32-Fi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Ec++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[es]=e,t[Sc]=r,V2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Um(n,r),n){case"dialog":nn("cancel",t),nn("close",t),i=r;break;case"iframe":case"object":case"embed":nn("load",t),i=r;break;case"video":case"audio":for(i=0;iDa&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304)}else{if(!r)if(t=oh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ku(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!an)return er(e),null}else 2*Cn()-s.renderingStartTime>Da&&n!==1073741824&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Cn(),e.sibling=null,n=un.current,Zt(un,r?n&1|2:n&1),e):(er(e),null);case 22:case 23:return Av(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Br&1073741824&&(er(e),e.subtreeFlags&6&&(e.flags|=8192)):er(e),null;case 24:return null;case 25:return null}throw Error(pe(156,e.tag))}function tI(t,e){switch(lv(e),e.tag){case 1:return Mr(e.type)&&Zd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ia(),sn(Ar),sn(or),mv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return gv(e),null;case 13:if(sn(un),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(pe(340));Oa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return sn(un),null;case 4:return Ia(),null;case 10:return fv(e.type._context),null;case 22:case 23:return Av(),null;case 24:return null;default:return null}}var jf=!1,ir=!1,nI=typeof WeakSet=="function"?WeakSet:Set,Ne=null;function aa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){pn(t,e,r)}else n.current=null}function v0(t,e,n){try{n()}catch(r){pn(t,e,r)}}var Z1=!1;function rI(t,e){if(t0=qd,t=JC(),sv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=o),d===s&&++c===r&&(a=o),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(n0={focusedElem:t,selectionRange:n},qd=!1,Ne=e;Ne!==null;)if(e=Ne,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ne=t;else for(;Ne!==null;){e=Ne;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var m=p.memoizedProps,x=p.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:Ai(e.type,m),x);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(pe(163))}}catch(k){pn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Ne=t;break}Ne=e.return}return p=Z1,Z1=!1,p}function Yu(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&v0(e,n,s)}i=i.next}while(i!==r)}}function lp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function w0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function X2(t){var e=t.alternate;e!==null&&(t.alternate=null,X2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[es],delete e[Sc],delete e[s0],delete e[zP],delete e[BP])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function G2(t){return t.tag===5||t.tag===3||t.tag===4}function ex(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||G2(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function x0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Qd));else if(r!==4&&(t=t.child,t!==null))for(x0(t,e,n),t=t.sibling;t!==null;)x0(t,e,n),t=t.sibling}function b0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(b0(t,e,n),t=t.sibling;t!==null;)b0(t,e,n),t=t.sibling}var Wn=null,Mi=!1;function Gs(t,e,n){for(n=n.child;n!==null;)q2(t,e,n),n=n.sibling}function q2(t,e,n){if(us&&typeof us.onCommitFiberUnmount=="function")try{us.onCommitFiberUnmount(Zh,n)}catch{}switch(n.tag){case 5:ir||aa(n,e);case 6:var r=Wn,i=Mi;Wn=null,Gs(t,e,n),Wn=r,Mi=i,Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Wn.removeChild(n.stateNode));break;case 18:Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?Tg(t.parentNode,n):t.nodeType===1&&Tg(t,n),vc(t)):Tg(Wn,n.stateNode));break;case 4:r=Wn,i=Mi,Wn=n.stateNode.containerInfo,Mi=!0,Gs(t,e,n),Wn=r,Mi=i;break;case 0:case 11:case 14:case 15:if(!ir&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&v0(n,e,o),i=i.next}while(i!==r)}Gs(t,e,n);break;case 1:if(!ir&&(aa(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){pn(n,e,l)}Gs(t,e,n);break;case 21:Gs(t,e,n);break;case 22:n.mode&1?(ir=(r=ir)||n.memoizedState!==null,Gs(t,e,n),ir=r):Gs(t,e,n);break;default:Gs(t,e,n)}}function tx(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new nI),e.forEach(function(r){var i=dI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ci(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Cn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*sI(r/1960))-r,10t?16:t,po===null)var r=!1;else{if(t=po,po=null,fh=0,_t&6)throw Error(pe(331));var i=_t;for(_t|=4,Ne=t.current;Ne!==null;){var s=Ne,o=s.child;if(Ne.flags&16){var l=s.deletions;if(l!==null){for(var a=0;aCn()-Tv?cl(t,0):Cv|=n),Rr(t,e)}function rT(t,e){e===0&&(t.mode&1?(e=If,If<<=1,!(If&130023424)&&(If=4194304)):e=1);var n=pr();t=Fs(t,e),t!==null&&(Hc(t,e,n),Rr(t,n))}function fI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),rT(t,n)}function dI(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(pe(314))}r!==null&&r.delete(e),rT(t,n)}var iT;iT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ar.current)Tr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Tr=!1,ZP(t,e,n);Tr=!!(t.flags&131072)}else Tr=!1,an&&e.flags&1048576&&a2(e,nh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Od(t,e),t=e.pendingProps;var i=Ra(e,or.current);xa(e,n),i=vv(null,e,r,t,i,n);var s=wv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Mr(r)?(s=!0,eh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,hv(e),i.updater=op,e.stateNode=i,i._reactInternals=e,f0(e,r,t,n),e=p0(null,e,r,!0,s,n)):(e.tag=0,an&&s&&ov(e),fr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Od(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=pI(r),t=Ai(r,t),i){case 0:e=h0(null,e,r,t,n);break e;case 1:e=Y1(null,e,r,t,n);break e;case 11:e=G1(null,e,r,t,n);break e;case 14:e=q1(null,e,r,Ai(r.type,t),n);break e}throw Error(pe(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),h0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),Y1(t,e,r,i,n);case 3:e:{if(j2(e),t===null)throw Error(pe(387));r=e.pendingProps,s=e.memoizedState,i=s.element,p2(t,e),sh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Na(Error(pe(423)),e),e=J1(t,e,r,n,i);break e}else if(r!==i){i=Na(Error(pe(424)),e),e=J1(t,e,r,n,i);break e}else for(Kr=xo(e.stateNode.containerInfo.firstChild),Xr=e,an=!0,Ri=null,n=d2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Oa(),r===i){e=$s(t,e,n);break e}fr(t,e,r,n)}e=e.child}return e;case 5:return g2(e),t===null&&a0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,r0(r,i)?o=null:s!==null&&r0(r,s)&&(e.flags|=32),B2(t,e),fr(t,e,o,n),e.child;case 6:return t===null&&a0(e),null;case 13:return H2(t,e,n);case 4:return pv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Pa(e,null,r,n):fr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),G1(t,e,r,i,n);case 7:return fr(t,e,e.pendingProps,n),e.child;case 8:return fr(t,e,e.pendingProps.children,n),e.child;case 12:return fr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Zt(rh,r._currentValue),r._currentValue=o,s!==null)if(zi(s.value,o)){if(s.children===i.children&&!Ar.current){e=$s(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Ns(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),u0(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(pe(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),u0(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}fr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,xa(e,n),i=hi(i),r=r(i),e.flags|=1,fr(t,e,r,n),e.child;case 14:return r=e.type,i=Ai(r,e.pendingProps),i=Ai(r.type,i),q1(t,e,r,i,n);case 15:return $2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),Od(t,e),e.tag=1,Mr(r)?(t=!0,eh(e)):t=!1,xa(e,n),_2(e,r,i),f0(e,r,i,n),p0(null,e,r,!0,t,n);case 19:return W2(t,e,n);case 22:return z2(t,e,n)}throw Error(pe(156,e.tag))};function sT(t,e){return IC(t,e)}function hI(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function si(t,e,n,r){return new hI(t,e,n,r)}function Rv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function pI(t){if(typeof t=="function")return Rv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Gy)return 11;if(t===qy)return 14}return 2}function Co(t,e){var n=t.alternate;return n===null?(n=si(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Nd(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Rv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Zl:return fl(n.children,i,s,e);case Xy:o=8,i|=8;break;case _m:return t=si(12,n,e,i|2),t.elementType=_m,t.lanes=s,t;case Lm:return t=si(13,n,e,i),t.elementType=Lm,t.lanes=s,t;case Fm:return t=si(19,n,e,i),t.elementType=Fm,t.lanes=s,t;case gC:return up(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case hC:o=10;break e;case pC:o=9;break e;case Gy:o=11;break e;case qy:o=14;break e;case ro:o=16,r=null;break e}throw Error(pe(130,t==null?t:typeof t,""))}return e=si(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function fl(t,e,n,r){return t=si(7,t,r,e),t.lanes=n,t}function up(t,e,n,r){return t=si(22,t,r,e),t.elementType=gC,t.lanes=n,t.stateNode={isHidden:!1},t}function Ng(t,e,n){return t=si(6,t,null,e),t.lanes=n,t}function Dg(t,e,n){return e=si(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function gI(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pg(0),this.expirationTimes=pg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Ov(t,e,n,r,i,s,o,l,a){return t=new gI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=si(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hv(s),t}function mI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uT)}catch(t){console.error(t)}}uT(),uC.exports=qr;var bI=uC.exports,cT,ux=bI;cT=ux.createRoot,ux.hydrateRoot;function fT(){return""}function kI(){return/^G-[A-Z0-9]+$/.test(fT())}function SI(){const t=window.gtag;typeof t=="function"&&kI()&&t("config",fT(),{send_page_view:!1})}function CI(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function TI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function EI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function AI(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function MI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function pp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,MI(t),{props:{...e}})}function RI(t){pp("input",t)}function OI(t){pp("conversion",t)}function Uo(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};pp("export",e)}function PI(t){pp("feedback",t)}function II(t){return new TextEncoder().encode(t).length}function NI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function DI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function _I(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0,u=null,c=0;function f(h){if(h.text.trim()==="")return!1;const p=II(h.text),m=NI(p),x=i(h.direction,h.text),g=`${h.direction}:${h.input}:${p}:${DI(h.text)}`,y=r();return g!==l&&(a===0||y-a>=n)&&(l=g,a=y,RI({direction:h.direction,input:h.input,size:m,valid:x})),!x||g===u||c!==0&&y-c{o=void 0,s&&f(s)},e)}return{edit(h,p){s={direction:h,input:"paste",text:p},d()},discrete(h,p,m){s={direction:h,input:p,text:m},d(),f(s)},cancel(){s=null,l=null,u=null,o&&(clearTimeout(o),o=void 0)}}}/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const dT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const LI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const FI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cx=t=>{const e=FI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var _g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $I=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},zI=v.createContext({}),BI=()=>v.useContext(zI),jI=v.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:d="currentColor",className:h=""}=BI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,..._g,width:e??u??_g.width,height:e??u??_g.height,stroke:t??d,strokeWidth:p,className:dT("lucide",h,i),...!s&&!$I(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>v.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const En=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement(jI,{ref:s,iconNode:e,className:dT(`lucide-${LI(cx(t))}`,`lucide-${t}`,r),...i}));return n.displayName=cx(t),n};/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const HI=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],WI=En("arrow-left-right",HI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const VI=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],fx=En("braces",VI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const UI=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],KI=En("chevron-down",UI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const XI=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],GI=En("clipboard",XI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],YI=En("clock",qI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const JI=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Dv=En("copy",JI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const QI=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],hT=En("download",QI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ZI=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],pT=En("file-up",ZI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const eN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],tN=En("moon",eN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const nN=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],rN=En("redo-2",nN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],sN=En("rotate-ccw-clock",iN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],dx=En("rotate-ccw",oN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],aN=En("search",lN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const uN=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],cN=En("sparkles",uN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fN=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],dN=En("sun",fN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hN=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],pN=En("table",hN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gN=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],mN=En("thumbs-down",gN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yN=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],vN=En("thumbs-up",yN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wN=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ph=En("trash",wN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xN=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],bN=En("undo-2",xN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gh=En("x",kN);function gT(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=EN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(_v);return l[0]===""&&l.length!==1&&l.shift(),mT(l,e)||TN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},mT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?mT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(_v);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},hx=/^\[(.+)\]$/,TN=t=>{if(hx.test(t)){const e=hx.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},EN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return MN(Object.entries(t.classGroups),n).forEach(([s,o])=>{E0(o,r,s,e)}),r},E0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:px(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(AN(i)){E0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{E0(o,px(e,s),n,r)})})},px=(t,e)=>{let n=t;return e.split(_v).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},AN=t=>t.isThemeGetter,MN=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,RN=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},yT="!",ON=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let x=0;xc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:o}):o},PN=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},IN=t=>({cache:RN(t.cacheSize),parseClassName:ON(t),...CN(t)}),NN=/\s+/,DN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(NN);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}=n(u);let p=!!h,m=r(p?d.substring(0,h):d);if(!m){if(!p){l=u+(l.length>0?" "+l:l);continue}if(m=r(d),!m){l=u+(l.length>0?" "+l:l);continue}p=!1}const x=PN(c).join(":"),g=f?x+yT:x,y=g+m;if(s.includes(y))continue;s.push(y);const w=i(m,p);for(let k=0;k0?" "+l:l)}return l};function _N(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=IN(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=DN(a,n);return i(a,c),c}return function(){return s(_N.apply(null,arguments))}}const tn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},wT=/^\[(?:([a-z-]+):)?(.+)\]$/i,FN=/^\d+\/\d+$/,$N=new Set(["px","full","screen"]),zN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,BN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,HN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,WN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ks=t=>ka(t)||$N.has(t)||FN.test(t),qs=t=>qa(t,"length",JN),ka=t=>!!t&&!Number.isNaN(Number(t)),Lg=t=>qa(t,"number",ka),Cu=t=>!!t&&Number.isInteger(Number(t)),VN=t=>t.endsWith("%")&&ka(t.slice(0,-1)),mt=t=>wT.test(t),Ys=t=>zN.test(t),UN=new Set(["length","size","percentage"]),KN=t=>qa(t,UN,xT),XN=t=>qa(t,"position",xT),GN=new Set(["image","url"]),qN=t=>qa(t,GN,ZN),YN=t=>qa(t,"",QN),Tu=()=>!0,qa=(t,e,n)=>{const r=wT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},JN=t=>BN.test(t)&&!jN.test(t),xT=()=>!1,QN=t=>HN.test(t),ZN=t=>WN.test(t),eD=()=>{const t=tn("colors"),e=tn("spacing"),n=tn("blur"),r=tn("brightness"),i=tn("borderColor"),s=tn("borderRadius"),o=tn("borderSpacing"),l=tn("borderWidth"),a=tn("contrast"),u=tn("grayscale"),c=tn("hueRotate"),f=tn("invert"),d=tn("gap"),h=tn("gradientColorStops"),p=tn("gradientColorStopPositions"),m=tn("inset"),x=tn("margin"),g=tn("opacity"),y=tn("padding"),w=tn("saturate"),k=tn("scale"),b=tn("sepia"),S=tn("skew"),T=tn("space"),A=tn("translate"),M=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",mt,e],P=()=>[mt,e],I=()=>["",ks,qs],D=()=>["auto",ka,mt],ee=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",mt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[ka,mt];return{cacheSize:500,separator:":",theme:{colors:[Tu],spacing:[ks,qs],blur:["none","",Ys,mt],brightness:N(),borderColor:[t],borderRadius:["none","","full",Ys,mt],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:V(),hueRotate:N(),invert:V(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[VN,qs],inset:_(),margin:_(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:V(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",mt]}],container:["container"],columns:[{columns:[Ys]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ee(),mt]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Cu,mt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",mt]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",Cu,mt]}],"grid-cols":[{"grid-cols":[Tu]}],"col-start-end":[{col:["auto",{span:["full",Cu,mt]},mt]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[Tu]}],"row-start-end":[{row:["auto",{span:[Cu,mt]},mt]}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",mt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",mt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...W()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...W(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...W(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",mt,e]}],"min-w":[{"min-w":[mt,e,"min","max","fit"]}],"max-w":[{"max-w":[mt,e,"none","full","min","max","fit","prose",{screen:[Ys]},Ys]}],h:[{h:[mt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[mt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ys,qs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Lg]}],"font-family":[{font:[Tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",mt]}],"line-clamp":[{"line-clamp":["none",ka,Lg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ks,mt]}],"list-image":[{"list-image":["none",mt]}],"list-style-type":[{list:["none","disc","decimal",mt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ks,qs]}],"underline-offset":[{"underline-offset":["auto",ks,mt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",mt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",mt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ee(),XN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",KN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},qN]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:ie()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[ks,mt]}],"outline-w":[{outline:[ks,qs]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[ks,qs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ys,YN]}],"shadow-color":[{shadow:[Tu]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Ys,mt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[b]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[b]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",mt]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",mt]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",mt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Cu,mt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",mt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",mt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",mt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ks,qs,Lg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},tD=LN(eD);function hr(...t){return tD(SN(t))}function Fg(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function nD({flipped:t}){return E.jsx(WI,{size:18,strokeWidth:2,"aria-hidden":"true",className:hr("transition-transform duration-300",t&&"rotate-180")})}function rD({direction:t,onFlip:e}){return E.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${Fg(t)})`,"aria-label":`Switch conversion direction (currently ${Fg(t)})`,className:"flex h-9 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-background px-3 text-xs font-medium text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground md:h-8 md:gap-1 md:px-2.5 md:text-[11px]",children:[E.jsx(nD,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Fg(t)})]})}const bT=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],iD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:bT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function sD(){const[t,e]=v.useState(!1),n=v.useId();return E.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[E.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[E.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),E.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:bT.map(r=>E.jsxs("div",{className:"mb-3 last:mb-0",children:[E.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),E.jsx("p",{children:r.answer})]},r.question))}),E.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(iD)}})]})}const oD="https://github.com/FlatFilers/csvjson-app/discussions/163";function lD(){return E.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-3 py-1.5 text-xs text-muted-foreground sm:px-4 sm:text-sm",children:E.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",E.jsx("a",{"data-testid":"feedback-link",href:oD,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const kT="csvjson:feedback.v1",aD=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function uD(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function gx(){try{const t=window.localStorage.getItem(kT);if(t===null)return null;const e=JSON.parse(t);return uD(e)?e:null}catch{return null}}function mx(t){try{window.localStorage.setItem(kT,JSON.stringify(t))}catch{}}function yx(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function cD(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function fD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(cD(t))})).ok?"ok":"failed"}catch{return"failed"}}function vx(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dD(){const[t,e]=v.useState(gx),[n,r]=v.useState(!1),[i,s]=v.useState(null),[o,l]=v.useState(""),[a,u]=v.useState(!1),[c,f]=v.useState(!1),d=v.useRef(null),h=v.useRef(0),p=v.useCallback((b,S)=>{const T={...b,pending:S==="failed"};mx(T),e(T),S==="ok"?PI({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=v.useCallback((b,S)=>{const T=++h.current;S&&f(!0),fD(b).then(A=>{h.current===T&&(p(b,A),A==="ok"&&u(!0))}).finally(()=>{S&&h.current===T&&f(!1)})},[p]),x=b=>{const S={...b,pending:!0};mx(S),e(S),m(S,!0)},g=v.useRef(!1);v.useEffect(()=>{if(g.current)return;g.current=!0;const b=gx();b!=null&&b.pending&&m(b,!1)},[m]),v.useEffect(()=>{if(!a)return;const b=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(b)},[a]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&r(!1)},S=T=>{const A=d.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",S)}},[n]);const y=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??yx(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const b=o.trim();x({clientId:(t==null?void 0:t.clientId)??yx(),vote:-1,reasonCode:i,reasonText:b===""?null:b}),r(!1)};return E.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[E.jsx("button",{type:"button","data-testid":"feedback-up",onClick:y,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:vx((t==null?void 0:t.vote)===1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M7 10v12"}),E.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),E.jsx("button",{type:"button","data-testid":"feedback-down",onClick:w,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:vx((t==null?void 0:t.vote)===-1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M17 14V2"}),E.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&E.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&E.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&E.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),E.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:aD.map(b=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${b.value}`,"aria-pressed":i===b.value,onClick:()=>s(b.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===b.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:b.label},b.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:b=>l(b.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),E.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),E.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function ST(t="This should not happen"){throw new Error(t)}function Wr(t,e="Assertion failed"){if(!t)return ST(e)}function Oc(t,e){return ST(e??"Hell froze over")}function hD(t,e){try{return t()}catch{return e}}const wx=Object.prototype.hasOwnProperty;function _a(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&_a(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(wx.call(t,n)&&++r&&!wx.call(e,n)||!(n in e)||!_a(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var pD=Object.prototype,gD=pD.hasOwnProperty;function mD(t,e){return t!=null&&gD.call(t,e)}var yD=mD,vD=Array.isArray,ps=vD,wD=typeof fo=="object"&&fo&&fo.Object===Object&&fo,CT=wD,xD=CT,bD=typeof self=="object"&&self&&self.Object===Object&&self,kD=xD||bD||Function("return this")(),gs=kD,SD=gs,CD=SD.Symbol,Kc=CD,xx=Kc,TT=Object.prototype,TD=TT.hasOwnProperty,ED=TT.toString,Eu=xx?xx.toStringTag:void 0;function AD(t){var e=TD.call(t,Eu),n=t[Eu];try{t[Eu]=void 0;var r=!0}catch{}var i=ED.call(t);return r&&(e?t[Eu]=n:delete t[Eu]),i}var MD=AD,RD=Object.prototype,OD=RD.toString;function PD(t){return OD.call(t)}var ID=PD,bx=Kc,ND=MD,DD=ID,_D="[object Null]",LD="[object Undefined]",kx=bx?bx.toStringTag:void 0;function FD(t){return t==null?t===void 0?LD:_D:kx&&kx in Object(t)?ND(t):DD(t)}var Xc=FD;function $D(t){return t!=null&&typeof t=="object"}var Gc=$D,zD=Xc,BD=Gc,jD="[object Symbol]";function HD(t){return typeof t=="symbol"||BD(t)&&zD(t)==jD}var gp=HD,WD=ps,VD=gp,UD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KD=/^\w*$/;function XD(t,e){if(WD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||VD(t)?!0:KD.test(t)||!UD.test(t)||e!=null&&t in Object(e)}var Lv=XD;function GD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var El=GD,qD=Xc,YD=El,JD="[object AsyncFunction]",QD="[object Function]",ZD="[object GeneratorFunction]",e_="[object Proxy]";function t_(t){if(!YD(t))return!1;var e=qD(t);return e==QD||e==ZD||e==JD||e==e_}var ET=t_,n_=gs,r_=n_["__core-js_shared__"],i_=r_,$g=i_,Sx=function(){var t=/[^.]+$/.exec($g&&$g.keys&&$g.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function s_(t){return!!Sx&&Sx in t}var o_=s_,l_=Function.prototype,a_=l_.toString;function u_(t){if(t!=null){try{return a_.call(t)}catch{}try{return t+""}catch{}}return""}var AT=u_,c_=ET,f_=o_,d_=El,h_=AT,p_=/[\\^$.*+?()[\]{}|]/g,g_=/^\[object .+?Constructor\]$/,m_=Function.prototype,y_=Object.prototype,v_=m_.toString,w_=y_.hasOwnProperty,x_=RegExp("^"+v_.call(w_).replace(p_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function b_(t){if(!d_(t)||f_(t))return!1;var e=c_(t)?x_:g_;return e.test(h_(t))}var k_=b_;function S_(t,e){return t==null?void 0:t[e]}var C_=S_,T_=k_,E_=C_;function A_(t,e){var n=E_(t,e);return T_(n)?n:void 0}var Al=A_,M_=Al,R_=M_(Object,"create"),mp=R_,Cx=mp;function O_(){this.__data__=Cx?Cx(null):{},this.size=0}var P_=O_;function I_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var N_=I_,D_=mp,__="__lodash_hash_undefined__",L_=Object.prototype,F_=L_.hasOwnProperty;function $_(t){var e=this.__data__;if(D_){var n=e[t];return n===__?void 0:n}return F_.call(e,t)?e[t]:void 0}var z_=$_,B_=mp,j_=Object.prototype,H_=j_.hasOwnProperty;function W_(t){var e=this.__data__;return B_?e[t]!==void 0:H_.call(e,t)}var V_=W_,U_=mp,K_="__lodash_hash_undefined__";function X_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=U_&&e===void 0?K_:e,this}var G_=X_,q_=P_,Y_=N_,J_=z_,Q_=V_,Z_=G_;function Ya(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var mL=gL,yL=yp;function vL(t,e){var n=this.__data__,r=yL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var wL=vL,xL=nL,bL=cL,kL=hL,SL=mL,CL=wL;function Ja(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=L3}var Wv=F3,$3=gp;function z3(t){if(typeof t=="string"||$3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var xp=z3,B3=OT,j3=jv,H3=ps,W3=Hv,V3=Wv,U3=xp;function K3(t,e,n){e=B3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new Cs(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=Z3([...this.items,n]);return new Cs(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&eIx??(Ix=new Cs([]))),bt(Cs,"fromSingleSelection",e=>Cs.empty().add(e));let Nt=Cs;function eF(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var tF=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,zg=eF(function(t){return tF.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),nF=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},Nx=nF,rF=t=>t.toUpperCase()===t,iF=t=>e=>t.indexOf(e)===-1,NT=(t,e)=>{const n={};return Object.keys(t).filter(iF(e)).forEach(r=>{n[r]=t[r]}),n};function sF(t,e,n){const r=NT(e,n);if(!t){const i=typeof zg=="function"?{default:zg}:zg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var oF=(t,e)=>{};function lF(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!rF(l[0])):n.propsAsIs,c=sF(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Nx(n.class,c.className||a):Nx(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const m in f){const x=f[m],g=x[0],y=x[1]||"",w=typeof g=="function"?g(s):g;oF(w,n.name),d[`--${m}`]=`${w}${y}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(m=>{d[m]=h[m]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,Ln.createElement(t,c)):Ln.createElement(l,c)},i=Ln.forwardRef?Ln.forwardRef(r):s=>{const o=NT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Jr=lF;const aF=Jr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var DT={},bp={},Uv={},Bg={},jg={exports:{}},Hg,Dx;function uF(){if(Dx)return Hg;Dx=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Hg=t,Hg}var Wg,_x;function cF(){if(_x)return Wg;_x=1;var t=uF();function e(){}function n(){}return n.resetWarningCache=e,Wg=function(){function r(o,l,a,u,c,f){if(f!==t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Wg}var Lx;function fF(){return Lx||(Lx=1,jg.exports=cF()()),jg.exports}var Fx;function dF(){return Fx||(Fx=1,function(t){(function(e,n){n(t,v,fF())})(fo,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(y){return y&&y.__esModule?y:{default:y}}var l=Object.assign||function(y){for(var w=1;w=0||Object.prototype.hasOwnProperty.call(y,b)&&(k[b]=y[b]);return k}function u(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")}var c=function(){function y(w,k){for(var b=0;b0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?y:y.capture}function x(y){if("touches"in y){var w=y.touches[0],k=w.pageX,b=w.pageY;return{x:k,y:b}}var S=y.screenX,T=y.screenY;return{x:S,y:T}}var g=function(y){d(w,y);function w(){var k;u(this,w);for(var b=arguments.length,S=Array(b),T=0;TS&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-S?this.props.onSwipeUp(1,b):this.movePosition.deltaY>S&&this.props.onSwipeDown(1,b)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(b){this.swiper=b,this.props.innerRef(b)}},{key:"render",value:function(){var b=this.props;b.tagName;var S=b.className,T=b.style,A=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var M=a(b,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:S,style:T},M),A)}}]),w}(n.Component);g.displayName="ReactSwipe",g.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},g.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=g})}(Bg)),Bg}(function(t){(function(e,n){n(t,dF())})(fo,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Uv);var qc={},_T={exports:{}};/*! + Copyright (c) 2018 Jed Watson. + Licensed under the MIT License (MIT), see + http://jedwatson.github.io/classnames +*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function vh(t){return vh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},vh(t)}function tr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var OF=function(e){return e.hasOwnProperty("key")},Kv=function(t){EF(n,t);var e=AF(n);function n(r){var i;return SF(this,n),i=e.call(this,r),tr(cr(i),"itemsWrapperRef",void 0),tr(cr(i),"itemsListRef",void 0),tr(cr(i),"thumbsRef",void 0),tr(cr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),tr(cr(i),"setItemsListRef",function(s){i.itemsListRef=s}),tr(cr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),tr(cr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Ti.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,xF.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var d=i.itemsWrapperRef.clientWidth,h=u+100/(d/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,$x.default)(h,"%",i.props.axis)}),!0}),tr(cr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),tr(cr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),tr(cr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return TF(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,Uf.default)().addEventListener("resize",this.updateSizes),(0,Uf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,Uf.default)().removeEventListener("resize",this.updateSizes),(0,Uf.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,ss.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,ss.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,ss.setPosition)(0,e.axis)),r;var a=(0,ss.getPosition)(i,e),u=(0,BF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=tl(tl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};is.slideAnimationHandler=WF;var VF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=FT.Children.count(n.children),a=0,u=(0,ss.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,ss.getPosition)(l-1,n)-100:(0,ss.getPosition)(l-1,n),f=o?e.x:e.y,d=f;u===a&&f>0&&(d=0),u===c&&f<0&&(d=0);var h=u+100/(r.itemSize/d),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&h>-100?h-=l*100:r.selectedItem===l-1&&h<-l*100&&(h+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,ss.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};is.slideSwipeAnimationHandler=VF;var UF=function(e,n){var r=(0,ss.getPosition)(n.selectedItem,e),i=(0,ss.setPosition)(r,e.axis);return{itemListStyle:i}};is.slideStopSwipingHandler=UF;var KF=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=tl(tl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:tl(tl({},s),{},{opacity:1,position:"relative"}),prevStyle:tl({},s)}};is.fadeAnimationHandler=KF;Object.defineProperty(bp,"__esModule",{value:!0});bp.default=void 0;var jt=qF(v),XF=Qc(Uv),Es=Qc(qc),GF=Qc(Yc),Kf=Qc(Cp),Xf=Qc(Jc),ju=Ur,wh=is;function Qc(t){return t&&t.__esModule?t:{default:t}}function $T(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return $T=function(){return t},t}function qF(t){if(t&&t.__esModule)return t;if(t===null||ec(t)!=="object"&&typeof t!="function")return{default:t};var e=$T();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function ec(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ec=function(n){return typeof n}:ec=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ec(t)}function O0(){return O0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function xh(t){return xh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},xh(t)}function kt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Xv=function(t){ZF(n,t);var e=e$(n);function n(r){var i;YF(this,n),i=e.call(this,r),kt(Ct(i),"thumbsRef",void 0),kt(Ct(i),"carouselWrapperRef",void 0),kt(Ct(i),"listRef",void 0),kt(Ct(i),"itemsRef",void 0),kt(Ct(i),"timer",void 0),kt(Ct(i),"animationHandler",void 0),kt(Ct(i),"setThumbsRef",function(o){i.thumbsRef=o}),kt(Ct(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),kt(Ct(i),"setListRef",function(o){i.listRef=o}),kt(Ct(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),kt(Ct(i),"autoPlay",function(){jt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),kt(Ct(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),kt(Ct(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),kt(Ct(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),kt(Ct(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),kt(Ct(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Kf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Kf.default)().activeElement)):!1}),kt(Ct(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),kt(Ct(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),kt(Ct(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),kt(Ct(i),"handleClickItem",function(o,l){if(jt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),kt(Ct(i),"handleOnChange",function(o,l){jt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),kt(Ct(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),kt(Ct(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),kt(Ct(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),kt(Ct(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Ct(i)));return i.setState(Ei({},a)),!!Object.keys(a).length}),kt(Ct(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),kt(Ct(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),kt(Ct(i),"moveTo",function(o){if(typeof o=="number"){var l=jt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),kt(Ct(i),"onClickNext",function(){i.increment(1)}),kt(Ct(i),"onClickPrev",function(){i.decrement(1)}),kt(Ct(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"changeItem",function(o){return function(l){(!(0,ju.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),kt(Ct(i),"selectItem",function(o){i.setState(Ei({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,jt.Children.toArray(i.props.children)[o.selectedItem])}),kt(Ct(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),kt(Ct(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function h(){i.forceUpdate(),u.removeEventListener("load",h)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],d=f.clientHeight;return d>0?d:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&wh.fadeAnimationHandler||wh.slideAnimationHandler,i.state=Ei(Ei({},s),i.animationHandler(r,s)),i}return QF(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(Ei({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&jt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,Xf.default)().addEventListener("resize",this.updateSizes),(0,Xf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Kf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Xf.default)().removeEventListener("resize",this.updateSizes),(0,Xf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Kf.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?jt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=Ei(Ei({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=Ei(Ei({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:Es.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return jt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?jt.default.createElement("ul",{className:"control-dots"},jt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?jt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,jt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||jt.Children.count(this.props.children)===0?null:jt.default.createElement(GF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||jt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&jt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&jt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function g(){var S=Vg();if(x(S))return y(S);l=setTimeout(g,m(S))}function y(S){return l=void 0,d&&r?h(S):(r=i=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:y(Vg())}function b(){var S=Vg(),T=x(S);if(r=arguments,i=this,a=S,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(g,e),h(a)}return l===void 0&&(l=setTimeout(g,e)),o}return b.cancel=w,b.flush=k,b}var zT=T$;const BT=ji(zT);function Vn(t,e,n,r,i=!1){const s=v.useRef();s.current=e,v.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function Ul(t,e){return t===void 0?void 0:e}const E$=Math.PI;function Vx(t){return t*E$/180}const jT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),HT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},WT=(t,e,n)=>Math.min(t,e-n*2),VT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,qv=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),v.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},A$=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function M$(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(BT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const R$="֑-߿יִ-﷽ﹰ-ﻼ",O$="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",P$=new RegExp("^[^"+O$+"]*["+R$+"]");function Yv(t){return P$.test(t)?"rtl":"not-rtl"}let Gf;function I0(){if(typeof document>"u")return 0;if(Gf!==void 0)return Gf;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),Gf=n-r,Gf}const Xo=Symbol();function I$(t){const e=v.useRef([Xo,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=v.useState(t),[,i]=v.useState(),s=v.useCallback(l=>{const a=e.current[0];a!==Xo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Xo&&i({}),r(u=>typeof l=="function"?l(a===Xo?u:a):l),e.current[0]=Xo)},[]),o=v.useCallback(()=>{e.current[0]=Xo,i({})},[]);return[e.current[0]===Xo?n:e.current[0],s,o]}function UT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function N$(t){const e=v.useRef(t);return _a(t,e.current)||(e.current=t),e.current}const D$=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return v.createElement(aF,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(DT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??v.createElement("img",{draggable:!1,src:l});return v.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&v.createElement("button",{className:"gdg-edit-icon",onClick:r},v.createElement(qv,null)))};function KT(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Ml=KT();function _$(t){Ml=t}const XT=/[&<>"']/,L$=new RegExp(XT.source,"g"),GT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,F$=new RegExp(GT.source,"g"),$$={"&":"&","<":"<",">":">",'"':""","'":"'"},Ux=t=>$$[t];function nr(t,e){if(e){if(XT.test(t))return t.replace(L$,Ux)}else if(GT.test(t))return t.replace(F$,Ux);return t}const z$=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function qT(t){return t.replace(z$,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const B$=/(^|[^\[])\^/g;function Yt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(B$,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const j$=/[^\w:]/g,H$=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Kx(t,e,n){if(t){let r;try{r=decodeURIComponent(qT(n)).replace(j$,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!H$.test(n)&&(n=K$(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qf={},W$=/^[^:]+:\/*[^/]*$/,V$=/^([^:]+:)[\s\S]*$/,U$=/^([^:]+:\/*[^/]*)[\s\S]*$/;function K$(t,e){qf[" "+t]||(W$.test(t)?qf[" "+t]=t+"/":qf[" "+t]=Dd(t,"/",!0)),t=qf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(V$,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(U$,"$1")+e:t+e}const bh={exec:function(){}};function Xx(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function qx(t,e,n,r){const i=e.href,s=e.title?nr(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:nr(o)}}function q$(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` +`).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` +`)}class Jv{constructor(e){this.options=e||Ml}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Dd(r,` +`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=q$(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Dd(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,d,h,p,m=n[1].trim();const x=m.length>1,g={type:"list",raw:"",ordered:x,start:x?+m.slice(0,-1):"",loose:!1,items:[]};m=x?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=x?m:"[*+-]");const y=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=y.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` +`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` +`,1)[0],this.options.pedantic?(o=2,h=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,h=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` +`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),S=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(d=e.split(` +`,1)[0],f=d,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(S.test(f)||T.test(f)||k.test(f)||b.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` +`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||S.test(c)||T.test(c)||b.test(c))break;h+=` +`+f}!a&&!f.trim()&&(a=!0),r+=d+` +`,e=e.substring(d.length+1),c=f.slice(o)}}g.loose||(u?g.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=h.trimRight(),g.raw=g.raw.trimRight();const w=g.items.length;for(l=0;lS.type==="space"),b=k.length>0&&k.some(S=>/\n.*\n/.test(S.raw));g.loose=b}if(g.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Xx(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` +`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):nr(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Dd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=X$(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),qx(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return qx(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const d=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}const h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=nr(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=nr(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=nr(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=nr(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=nr(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):nr(r[0]):r[0]:i=nr(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Ye={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:bh,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ye._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ye._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ye.def=Yt(Ye.def).replace("label",Ye._label).replace("title",Ye._title).getRegex();Ye.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ye.listItemStart=Yt(/^( *)(bull) */).replace("bull",Ye.bullet).getRegex();Ye.list=Yt(Ye.list).replace(/bull/g,Ye.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ye.def.source+")").getRegex();Ye._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ye._comment=/|$)/;Ye.html=Yt(Ye.html,"i").replace("comment",Ye._comment).replace("tag",Ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ye.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.blockquote=Yt(Ye.blockquote).replace("paragraph",Ye.paragraph).getRegex();Ye.normal={...Ye};Ye.gfm={...Ye.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ye.gfm.table=Yt(Ye.gfm.table).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.gfm.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ye.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.pedantic={...Ye.normal,html:Yt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ye._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:bh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Yt(Ye.normal._paragraph).replace("hr",Ye.hr).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",Ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const De={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:bh,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:bh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";De.punctuation=Yt(De.punctuation).replace(/punctuation/g,De._punctuation).getRegex();De.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;De.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;De._comment=Yt(Ye._comment).replace("(?:-->|$)","-->").getRegex();De.emStrong.lDelim=Yt(De.emStrong.lDelim).replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimAst=Yt(De.emStrong.rDelimAst,"g").replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimUnd=Yt(De.emStrong.rDelimUnd,"g").replace(/punct/g,De._punctuation).getRegex();De._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;De._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;De._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;De.autolink=Yt(De.autolink).replace("scheme",De._scheme).replace("email",De._email).getRegex();De._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;De.tag=Yt(De.tag).replace("comment",De._comment).replace("attribute",De._attribute).getRegex();De._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;De._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;De._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;De.link=Yt(De.link).replace("label",De._label).replace("href",De._href).replace("title",De._title).getRegex();De.reflink=Yt(De.reflink).replace("label",De._label).replace("ref",Ye._label).getRegex();De.nolink=Yt(De.nolink).replace("ref",Ye._label).getRegex();De.reflinkSearch=Yt(De.reflinkSearch,"g").replace("reflink",De.reflink).replace("nolink",De.nolink).getRegex();De.normal={...De};De.pedantic={...De.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Yt(/^!?\[(label)\]\((.*?)\)/).replace("label",De._label).getRegex(),reflink:Yt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",De._label).getRegex()};De.gfm={...De.normal,escape:Yt(De.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class Mo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ml,this.options.tokenizer=this.options.tokenizer||new Jv,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ye.normal,inline:De.normal};this.options.pedantic?(n.block=Ye.pedantic,n.inline=De.pedantic):this.options.gfm&&(n.block=Ye.gfm,this.options.breaks?n.inline=De.breaks:n.inline=De.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ye,inline:De}}static lex(e,n){return new Mo(n).lex(e)}static lexInline(e,n){return new Mo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` +`),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` +`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` +`+r.raw,i.text+=` +`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` +`+r.raw,i.text+=` +`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Gx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Gx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Yx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Yx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,Y$)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class Qv{constructor(e){this.options=e||Ml}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` +`,i?'
    '+(r?e:nr(e,!0))+`
    +`:"
    "+(r?e:nr(e,!0))+`
    +`}blockquote(e){return`
    +${e}
    +`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} +`}return`${e} +`}hr(){return this.options.xhtml?`
    +`:`
    +`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> +`+e+" +`}listitem(e){return`
  • ${e}
  • +`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    +`}table(e,n){return n&&(n=`${n}`),` + +`+e+` +`+n+`
    +`}tablerow(e){return` +${e} +`}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` +`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,n,r){if(e=Kx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='
    ",i}image(e,n,r){if(e=Kx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class YT{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,n,r){return""+r}image(e,n,r){return""+r}br(){return""}}class JT{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,n){let r=e,i=0;if(this.seen.hasOwnProperty(r)){i=this.seen[e];do i++,r=e+"-"+i;while(this.seen.hasOwnProperty(r))}return n||(this.seen[e]=i,this.seen[r]=0),r}slug(e,n={}){const r=this.serialize(e);return this.getNextSafeSlug(r,n.dryrun)}}let Zc=class N0{constructor(e){this.options=e||Ml,this.options.renderer=this.options.renderer||new Qv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new YT,this.slugger=new JT}static parse(e,n){return new N0(n).parse(e)}static parseInline(e,n){return new N0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S;const T=e.length;for(i=0;i0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=b+" "+y.tokens[0].text,y.tokens[0].tokens&&y.tokens[0].tokens.length>0&&y.tokens[0].tokens[0].type==="text"&&(y.tokens[0].tokens[0].text=b+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:b}):g+=b),g+=this.parse(y.tokens,x),d+=this.renderer.listitem(g,k,w);r+=this.renderer.list(d,p,m);continue}case"html":{r+=this.renderer.html(h.text);continue}case"paragraph":{r+=this.renderer.paragraph(this.parseInline(h.tokens));continue}case"text":{for(d=h.tokens?this.parseInline(h.tokens):h.text;i+1{if(r.message+=` +Please report this to https://github.com/markedjs/marked.`,t){const i="

    An error occurred:

    "+nr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function QT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=J$(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(G$(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&et.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;et.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(et.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&et.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function et(t,e,n){return QT(Mo.lex,Zc.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},_$(et.defaults),et};et.getDefaults=KT;et.defaults=Ml;et.use=function(...t){const e=et.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=et.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=et.defaults.renderer||new Qv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=et.defaults.tokenizer||new Jv;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=et.defaults.hooks||new kh;for(const s in n.hooks){const o=i[s];kh.passThroughHooks.has(s)?i[s]=l=>{if(et.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=et.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}et.setOptions(r)})};et.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(et,r)),r.type){case"table":{for(const i of r.header)n=n.concat(et.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(et.walkTokens(s.tokens,e));break}case"list":{n=n.concat(et.walkTokens(r.items,e));break}default:et.defaults.extensions&&et.defaults.extensions.childTokens&&et.defaults.extensions.childTokens[r.type]?et.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(et.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(et.walkTokens(r.tokens,e)))}return n};et.parseInline=QT(Mo.lexInline,Zc.parseInline);et.Parser=Zc;et.parser=Zc.parse;et.Renderer=Qv;et.TextRenderer=YT;et.Lexer=Mo;et.lexer=Mo.lex;et.Tokenizer=Jv;et.Slugger=JT;et.Hooks=kh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;Zc.parse;Mo.lex;const Q$=Jr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class Z$ extends Ln.PureComponent{constructor(){super(...arguments);bt(this,"targetElement",null);bt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Ln.createElement(Q$,{ref:this.containerRefHook})}}const e4=Jr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),t4=Jr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),n4=Jr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Jx=0;const Tp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=v.useRef(null),f=n??"";Wr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=v.useState(()=>"input-box-"+(Jx=(Jx+1)%1e7));v.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),v.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const h=v.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return v.createElement(n4,{className:"gdg-growing-entry"},v.createElement(t4,{className:u},f+` +`),v.createElement(e4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Ug={};let Qs=null;function r4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function D0(t){const e=t.toLowerCase().trim();if(Ug[e]!==void 0)return Ug[e];Qs=Qs||r4(),Qs.style.color="#000",Qs.style.color=e;const n=getComputedStyle(Qs).color;Qs.style.color="#fff",Qs.style.color=e;const r=getComputedStyle(Qs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Ug[e]=i,i}function wl(t,e){const[n,r,i]=D0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Qx=new Map;function Zx(t,e){const n=`${t}-${e}`,r=Qx.get(n);if(r!==void 0)return r;const i=Vr(t,e);return Qx.set(n,i),i}function Vr(t,e){if(e===void 0)return t;const[n,r,i,s]=D0(t);if(s===1)return t;const[o,l,a,u]=D0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var Yl=new Map,fa=new Map,_0=new Map;function i4(){Yl.clear(),_0.clear(),fa.clear()}function s4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,m=c*p*r/d,x=h+m;n.set(f,x)}}function o4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function tc(t,e,n,r){var i,s;let o=fa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=_0.get(n);if(u===void 0&&(u=o4(t,o.size),_0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return s4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),fa.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)fa.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;fa.set(n,{count:o.count+e.length,size:f})}return l.width}function l4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=tc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function a4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Yl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` +`),c=fa.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let x=l4(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),Yl.set(o,a),Yl.size>500&&Yl.delete(Yl.keys().next().value),a}function u4(t,e){return Ln.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function ZT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function d4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&eb(t,e,s)&&i++;for(const o of n.current.rangeStack)eb(t,e,o)&&i++;return i}function tE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function La(t,e){let n=0;const r=tE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let m=l;m"u";async function m4(){var t;g4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,_d=0,rc={},i4())}m4();function nE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function ef(t,e,n,r="middle"){const i=nE(t,e,r,n);let s=rc[i];return s===void 0&&(s=e.measureText(t),rc[i]=s,_d++),_d>1e4&&(rc={},_d=0),s}function y4(t,e){const n=nE(t,void 0,"middle",e);return rc[n]}function js(t,e){return typeof e!="string"&&(e=e.baseFontFull),v4(t,e)}function tb(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const nb=[];function v4(t,e){for(const s of nb)if(s.key===e)return s.val;const n=tb(t,"alphabetic"),i=-(tb(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return nb.push({key:e,val:i}),i}function w4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function b4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=a4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=iE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let g=Math.max(r+l.cellVerticalPadding,x);for(const y of f)if(rE(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function Ms(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=x4(e,c));const d=js(s,l),h=Yv(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?b4(s,e,a,u,c,f,d,l,n,i):rE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function fs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function k4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function S4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),m=1,x=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const g=p/2;let y=Math.abs(Math.cos(g)*i/Math.sin(g)),w;y>Math.min(c.len/2,f.len/2)?(y=Math.min(c.len/2,f.len/2),w=Math.abs(y*Math.sin(g)/Math.cos(g))):w=i;let k=a.x+f.nx*y,b=a.y+f.ny*y;k+=-f.ny*w*m,b+=f.nx*w*m,t.arc(k,b,w,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function F0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const m={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const g=o>t?-1:1,y=La(h);m.x+=y+a;for(let w=o;w!==t;w+=g)m.x+=h[g===1?w:w-1].width*g}else for(let g=0;g0&&Pc(h[g-1].group,y)&&h[g-1].sticky===w;){const b=h[g-1];m.x-=b.width,m.width+=b.width,g--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-d){let g=c-e;for(m.y=r;g>0;){const y=e+g-1;m.height=typeof p=="number"?p:p(y),m.y-=m.height,g--}m.height+=1}else{const g=l>e?-1:1;if(typeof p=="number"){const y=e-l;m.y+=y*p}else for(let y=l;y!==e;y+=g)m.y+=p(y)*g;m.height=(typeof p=="number"?p:p(e))+1}return m}const Zv=1<<21;function Pi(t,e){return(e+2)*Zv+t}function sE(t){return t%Zv}function ew(t){return Math.floor(t/Zv)-2}function tw(t){const e=sE(t),n=ew(t);return[e,n]}class oE{constructor(){bt(this,"visibleWindow",{x:0,y:0,width:0,height:0});bt(this,"freezeCols",0);bt(this,"freezeRows",[]);bt(this,"isInWindow",e=>{const n=sE(e),r=ew(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&_a(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class C4 extends oE{constructor(){super(...arguments);bt(this,"cache",new Map);bt(this,"setValue",(n,r)=>{this.cache.set(Pi(n[0],n[1]),r)});bt(this,"getValue",n=>this.cache.get(Pi(n[0],n[1])));bt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class ic{constructor(e=[]){bt(this,"cells");this.cells=new Set(e.map(n=>Pi(n[0],n[1])))}add(e){this.cells.add(Pi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Pi(e[0],e[1]))}remove(e){this.cells.delete(Pi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(ew(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=A4(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function M4(t,e,n,r,i,s,o,l,a){const u=v.useRef(e),c=v.useRef(n),f=v.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=v.useMemo(()=>{if(typeof window>"u")return[null,null];const y=document.createElement("canvas");return y.style.display="none",y.style.opacity="0",y.style.position="fixed",[y,y.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=v.useRef({}),m=v.useRef(),[x,g]=v.useState();return v.useLayoutEffect(()=>{const y=c.current;if(y===void 0||t.every(Vf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,w)},S={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=y(b,a.signal),M=k>0?y(S,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Px(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Px(M)]),m.current=t,g(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Vf)?t:h===null?t.map(T=>Vf(T)?T:{...T,width:$0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Vf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:$0};const M=uE(h,o,T,A,x,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,b=0;const S=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(b+=A.grow,S.push(T));if(k0){const T=[...w],A=r-k;let M=A;for(let O=0;O0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=O4(a),a in rb)return;rb[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":R4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function P4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var I4=P4,N4=I4,Kg=Gv;function D4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Kg(n),n=n===n?n:0),e!==void 0&&(e=Kg(e),e=e===e?e:0),N4(Kg(t),e,n)}var _4=D4;const Oi=ji(_4);var L4="__lodash_hash_undefined__";function F4(t){return this.__data__.set(t,L4),this}var $4=F4;function z4(t){return this.__data__.has(t)}var B4=z4,j4=zv,H4=$4,W4=B4;function Sh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new j4;++e-1}var rz=nz;function iz(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=Cz){var u=e?null:kz(t);if(u)return Sz(u);o=!1,i=bz,a=new vz}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?gE(l,e-1,n,r,i):Lz(i,l):r||(i[i.length]=l)}return i}var $z=gE,zz=$z;function Bz(t){var e=t==null?0:t.length;return e?zz(t,1):[]}var jz=Bz;const ob=ji(jz);var Hz=Math.ceil,Wz=Math.max;function Vz(t,e,n,r){for(var i=-1,s=Wz(Hz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var Uz=Vz,Kz=ET,Xz=Wv;function Gz(t){return t!=null&&Xz(t.length)&&!Kz(t)}var rw=Gz,qz=Fv,Yz=rw,Jz=Hv,Qz=El;function Zz(t,e,n){if(!Qz(n))return!1;var r=typeof e;return(r=="number"?Yz(n)&&Jz(e,n.length):r=="string"&&e in n)?qz(n[e],t):!1}var e5=Zz,t5=Gv,lb=1/0,n5=17976931348623157e292;function r5(t){if(!t)return t===0?t:0;if(t=t5(t),t===lb||t===-lb){var e=t<0?-1:1;return e*n5}return t===t?t:0}var i5=r5,s5=Uz,o5=e5,Gg=i5;function l5(t){return function(e,n,r){return r&&typeof r!="number"&&o5(e,n,r)&&(n=r=void 0),e=Gg(e),n===void 0?(n=e,e=0):n=Gg(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function mE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Ep(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=h;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=h;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function p5(t,e,n,r){if(r==="any")return wE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),ZT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Ch(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Ap(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function wE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function g5(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function m5(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:m-p}}function y5(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:m,height:x}=t,g=[];if(m<=0||x<=0)return g;const y=h+m,w=p+x,k=hl,T=p+x>a,A=h>=s&&hs&&y<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const _=Math.max(h,s),P=Math.max(p,o),I=Math.min(y,l),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&b){const _=h,P=p,I=Math.min(y,s),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&A){const _=Math.max(h,s),P=p,I=Math.min(y,l),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&S){const _=Math.max(h,l),P=p,I=y,D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const _=h,P=Math.max(p,o),I=Math.min(y,s),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(S&&M){const _=Math.max(h,l),P=Math.max(p,o),I=y,D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const _=h,P=Math.max(p,a),I=Math.min(y,s),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const _=Math.max(h,s),P=Math.max(p,a),I=Math.min(y,l),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(S&&T){const _=Math.max(h,l),P=Math.max(p,a),I=y,D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return g}const v5={kind:Te.Loading,allowOverlay:!1};function ab(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A,M,O,_,P,I,D,ee,ie,te,W){let V=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},H=[0,0],G=x>0?Rl(a,x,u):0;let B,le;const me=mE(y);return Lo(e,l,s,o,i,(ye,oe,be,Ce,lt)=>{const Xe=Math.max(0,Ce-oe),Ge=oe+Xe,at=i+1,Ut=ye.width-Xe,Pe=r-i-1;if(y.length>0){let wt=!1;for(let rt=0;rt{t.save(),t.beginPath(),t.rect(Ge,at,Ut,Pe),t.clip()},Je=k.columns.hasIndex(ye.sourceIndex),nt=f(ye.group??"").overrideTheme,it=ye.themeOverride===void 0&&nt===void 0?I:To(I,nt,ye.themeOverride),$e=it.baseFontFull;$e!==N&&(N=$e,t.font=$e),xe();let At;return Ep(lt,be,r,a,u,x,g,me,(wt,rt,ge,_e,Qe)=>{var Le,ze,An;if(rt<0||(H[0]=ye.sourceIndex,H[1]=rt,w!==void 0&&!w.has(H)))return;if(y.length>0){let z=!1;for(let ue=0;uedt.span!==void 0&&z>=dt.span[0]&&z<=dt.span[1]);vn&&!p&&m?In=0:vn&&m&&(In=Math.max(In,1)),Pr&&In++,vn||(tt&&In++,Je&&!Qe&&In++);const Ir=dt.kind===Te.Protected?Pt.bgCellMedium:Pt.bgCell;let Bt;if((_e||Ir!==I.bgCell)&&(Bt=Vr(Ir,Bt)),In>0||Kt){Kt&&(Bt=Vr(Pt.bgHeader,Bt));for(let z=0;zW&&!Rt){const z=Pt.baseFontFull;z!==N&&(t.font=z,N=z),At=xE(t,dt,ye.sourceIndex,rt,xt,dn,ht,wt,pt,ge,In>0,Pt,Bt??Pt.bgCell,T,A,(ne==null?void 0:ne.hoverAmount)??0,O,P,R,_,At,D,ee,ie,te)}return ct&&t.restore(),dt.style==="faded"&&(t.globalAlpha=1),V--,Lt&&(t.restore(),(An=At==null?void 0:At.deprep)==null||An.call(At,L),At=void 0,xe(),N=$e,t.font=$e),V<=0}),t.restore(),V<=0}),B}const Au=[0,0],Mu={x:0,y:0,width:0,height:0},qg=[void 0,()=>{}];let z0=!1;function w5(){z0=!0}function xE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A){var ee,ie;let M,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(M=x[1][0],O=x[1][1]);let _;Au[0]=n,Au[1]=r,Mu.x=o,Mu.y=l,Mu.width=a,Mu.height=u,qg[0]=S.getValue(Au),qg[1]=te=>S.setValue(Au,te),z0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Mu,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:M,drawState:qg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:w5},I=w4(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((ee=k==null?void 0:k.deprep)==null||ee.call(k,P),k=void 0);const te=(ie=D.drawPrep)==null?void 0:ie.call(D,P,k);w!==void 0&&!ca(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=te===void 0?void 0:{deprep:te==null?void 0:te.deprep,fillStyle:te==null?void 0:te.fillStyle,font:te==null?void 0:te.font,renderer:D}}return(I||z0)&&(b==null||b(Au)),_}function iw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let m=WT(c,o,e.cellVerticalPadding),x=m/2;const g=HT(f,r,s,e.cellHorizontalPadding,m),y=jT(g,h,m),w=VT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),fs(t,g-m/2,h-m/2,m,m,p),d==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(g-x+m/4.23,h-x+m/1.97),t.lineTo(g-x+m/2.42,h-x+m/1.44),t.lineTo(g-x+m/1.29,h-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case mh:case!1:{t.beginPath(),fs(t,g-m/2+.5,h-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case Vv:{t.beginPath(),fs(t,g-m/2,h-m/2,m,m,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(g-m/3,h),t.lineTo(g+m/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Oc()}}function x5(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,b]=(r==null?void 0:r[0])??[],S=f.headerFontFull;t.font=S,Lo(e,0,s,0,w,(T,A,M,O)=>{var L;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,O-A);t.save(),t.beginPath(),t.rect(A+_,l,T.width-_,o),t.clip();const P=m(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:To(f,P,T.themeOverride);I.bgHeader!==f.bgHeader&&(t.fillStyle=I.bgHeader,t.fill()),I!==f&&(t.font=I.baseFontFull);const D=c.columns.hasIndex(T.sourceIndex),ee=a!==void 0||u,ie=!ee&&b===-1&&k===T.sourceIndex,te=ee?0:((L=h.find(H=>H.item[0]===T.sourceIndex&&H.item[1]===-1))==null?void 0:L.hoverAmount)??0,W=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,V=D?I.accentColor:W?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=V,t.fillRect(A+N,R,T.width-N,o)):(W||te>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),W&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),te>0&&(t.globalAlpha=te,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),SE(t,A,R,T.width,o,T,D,I,ie,W,te,d,g,y),t.restore()}),n&&b5(t,e,i,s,l,r,f,d,h,p,m,x)}function b5(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;yE(e,n,r,i,(x,g,y,w,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(y,w,k,b),t.clip();const S=c(g),T=(S==null?void 0:S.overrideTheme)===void 0?o:To(o,S.overrideTheme),A=p===-2&&h!==void 0&&h>=x[0]&&h<=x[1],M=A?T.bgHeaderHovered:T.bgHeader;if(M!==o.bgHeader&&(t.fillStyle=M,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,S!==void 0){let O=y;if(S.icon!==void 0&&(l.drawSprite(S.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(S.name,O+8,i/2+js(t,o.headerFontFull)),S.actions!==void 0&&A){const _=kE({x:y,y:w,width:k,height:b},S.actions);t.beginPath();const P=_[0].x-10,I=y+k-P;t.rect(P,0,I,i);const D=t.createLinearGradient(P,0,P+I,0),ee=wl(M,0);D.addColorStop(0,ee),D.addColorStop(10/I,M),D.addColorStop(1,M),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[ie,te]=(s==null?void 0:s[1])??[-1,-1];for(let W=0;W35){const k=d?35:r-35,b=d?35*.7:r-35*.7,S=k/r,T=b/r,A=t.createLinearGradient(e,0,e+r,0),M=wl(m,0);A.addColorStop(d?1:0,m),A.addColorStop(S,m),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=m;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+js(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===yh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;S4(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===yh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;k4(t,w,k),t.fillStyle=m,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function SE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=Yv(s.title)==="rtl",m=bE(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>ub(t,e,n,r,i,s,o,l,a,c,f,h,p,m)):ub(t,e,n,r,i,s,o,l,a,c,f,h,p,m)}var k5=Al,S5=function(){try{var t=k5(Object,"defineProperty");return t({},"",{}),t}catch{}}(),C5=S5,cb=C5;function T5(t,e,n){e=="__proto__"&&cb?cb(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var E5=T5;function A5(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Dj?new Oj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const M=Math.max(b,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Ep(A,S,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(W=>Ch(b,O,1e4,P,W.x,W.y,W.width,W.height)))return;const D=d.hasIndex(_),ee=h.hasIndex(_);t.beginPath();const ie=f==null?void 0:f(_),te=ie===void 0?y:To(y,ie);te.bgCell!==y.bgCell&&(t.fillStyle=te.bgCell,t.fillRect(b,O,1e4,P)),ee&&(t.fillStyle=te.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=te.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function TW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?La(e):0;let h;if(d!==0&&(h=Zx(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:Zx(c,a.bgCell),m=Rl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const DE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function EW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var P;const m=p.bgCell,{minX:x,maxX:g,minY:y,maxY:w}=DE(l,s,o),k=[],b=o-Rl(h,d,u);let S=a,T=n,A=0;for(;S+i=y&&I<=w-1){const ee=c==null?void 0:c(T),ie=ee==null?void 0:ee.bgCell;ie!==void 0&&ie!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:ie})}S+=D,T0)for(let I=0;I=x&&ee<=g&&f(I+1)&&k.push({x:ee,y:A,w:D.width,h:O,color:ie}),M+=D.width}if(k.length===0)return;let _;t.beginPath();for(let I=k.length-1;I>=0;I--){const D=k[I];_===void 0?_=D.color:D.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=D.color),t.rect(D.x,D.y,D.w,D.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function Ob(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const P of a)t.rect(P.x+1,P.y+1,P.width-1,P.height-1);t.clip("evenodd")}const y=x.horizontalBorderColor??x.borderColor,w=x.borderColor,{minX:k,maxX:b,minY:S,maxY:T}=DE(l,s,o),A=[];t.beginPath();let M=.5;for(let P=0;P=k&&D<=b&&h(P+1)&&A.push({x1:D,y1:Math.max(u,S),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=S&&ee<=T-1){const ie=d==null?void 0:d(I);A.push({x1:k,y1:ee,x2:b,y2:ee,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??y})}P+=f(I),I++}}const _=SW(A,P=>P.color);for(const P of Object.keys(_)){t.strokeStyle=P;for(const I of _[P])t.moveTo(I.x1,I.y1),t.lineTo(I.x2,I.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function AW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let S=0;if(typeof g=="number")S+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(S=-S),S+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let M=0;for(let D=T;Di.cellXOffset&&(M=-M),M+=l-i.translateX;const O=La(x);if(M!==0&&S!==0)return{regions:[]};const _=u>0?Rl(d,u,g):0,P=c-O-Math.abs(M),I=f-h-_-Math.abs(S)-1;if(P>150&&I>150){const D={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(S>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(S+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:S+1})):S<0&&(D.sy=(-S+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+S-_,width:c,height:-S+_})),M>0?(D.sx=O*p,D.sw=P*p,D.dx=(M+O)*p,D.dw=P*p,w.push({x:O-1,y:0,width:M+2,height:f})):M<0&&(D.sx=(O-M)*p,D.sw=P*p,D.dx=O*p,D.dw=P*p,w.push({x:c+M,y:0,width:-M,height:f})),t.setTransform(1,0,0,1,0,0),y){if(O>0&&M!==0&&S===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const ee=O*p,ie=f*p;t.drawImage(e,0,0,ee,ie,0,0,ee,ie)}if(_>0&&M===0&&S!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const ee=(f-_)*p,ie=c*p,te=_*p;t.drawImage(e,0,ee,ie,te,0,ee,ie,te)}}t.drawImage(e,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function MW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Lo(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const m=Math.max(d,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function RW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const g=La(l),y=Rl(h,d,f),w=[a,0,l.length,h-d],k=[g,0,e,n-y],b=x.map(T=>{const A=T.range,M=T.style??"dashed";return y5(A,w,e,n,k).map(O=>{const _=O.rect,P=F0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:F0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return _.x+_.width>=l.length&&(I.width-=1),_.y+_.height>=h&&(I.height-=1),{color:T.color,style:M,clip:O.clip,rect:m5({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),S=()=>{t.lineWidth=1;let T=!1;for(const A of b)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Ch(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,_=!g5(M.clip,M.rect);_&&(t.save(),t.rect(M.clip.x,M.clip.y,M.clip.width,M.clip.height),t.clip()),M.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(M.style==="solid"||M.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=M.style==="solid-outline"?Vr(Vr(M.color,m.borderColor),m.bgCell):wl(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),_&&(t.restore(),T=O)}T&&t.setLineDash([])};return S(),S}function Ib(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function Qg(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x){if(c.current===void 0)return;const g=c.current.range,y=c.current.cell,w=[g.x+g.width-1,g.y+g.height-1];if(y[1]>=x&&w[1]>=x||!o.some(D=>D.sourceIndex===y[0]||D.sourceIndex===w[0]))return;const[b,S]=c.current.cell,T=d(c.current.cell),A=T.span??[b,b],M=S>=x-h,O=h>0&&!M?Rl(x,h,f)-1:0,_=w[1];let P;if(Lo(o,r,i,s,u,(D,ee,ie,te,W)=>{if(D.sticky&&b>D.sourceIndex)return;const V=D.sourceIndexA[1],N=D.sourceIndex===w[0];if(!(!N&&(V||R)))return Ep(W,ie,n,x,f,h,p,void 0,(L,H,G)=>{if(H!==S&&H!==_)return;let B=ee,le=D.width;if(T.span!==void 0){const ye=vE(T.span,ee,L,D.width,G,D,l),oe=D.sticky?ye[0]:ye[1];oe!==void 0&&(B=oe.x,le=oe.width)}return H===_&&N&&m&&(P=()=>{var ye;te>B&&!D.sticky&&(t.beginPath(),t.rect(te,0,e-te,n),t.clip()),t.beginPath(),t.rect(B+le-4,L+G-4,4,4),t.fillStyle=((ye=D.themeOverride)==null?void 0:ye.accentColor)??a.accentColor,t.fill()}),P!==void 0}),P!==void 0}),P===void 0)return;const I=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-O),t.clip(),P==null||P(),t.restore()};return I(),I}function OW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),yE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Lo(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,m=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function PW(t,e,n,r,i,s,o,l,a,u){let c=0;return Lo(t,s,r,i,n,(f,d,h,p,m)=>(Ep(m,h,e,o,l,a,u,void 0,(x,g,y,w)=>{w||(c=Math.max(g,c))}),!0)),c}function Nb(t,e){var ct;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:g,disabledRows:y,rowHeight:w,verticalBorder:k,overrideCursor:b,isResizing:S,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:ee,prelightCells:ie,drawCellCallback:te,highlightRegions:W,resizeCol:V,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:H,hoverInfo:G,spriteManager:B,maxScaleFactor:le,hasAppendRow:me,touchMode:ye,enqueue:oe,renderStateProvider:be,getCellRenderer:Ce,renderStrategy:lt,bufferACtx:Xe,bufferBCtx:Ge,damage:at,minimumCellWidth:Ut}=t;if(i===0||s===0)return;const Pe=lt==="double-buffer",xe=Math.min(le,Math.ceil(window.devicePixelRatio??1)),Je=lt!=="direct"&&RW(t,e),nt=n.canvas;(nt.width!==i*xe||nt.height!==s*xe)&&(nt.width=i*xe,nt.height=s*xe,nt.style.width=i+"px",nt.style.height=s+"px");const it=r.canvas,$e=f?g+x:x,At=$e+1;(it.width!==i*xe||it.height!==At*xe)&&(it.width=i*xe,it.height=At*xe,it.style.width=i+"px",it.style.height=At+"px");const wt=Xe.canvas,rt=Ge.canvas;Pe&&(wt.width!==i*xe||wt.height!==s*xe)&&(wt.width=i*xe,wt.height=s*xe,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Pe&&(rt.width!==i*xe||rt.height!==s*xe)&&(rt.width=i*xe,rt.height=s*xe,N.current!==void 0&&(N.current.bBufferScroll=void 0));const ge=N.current;if(Je===!0&&o===(ge==null?void 0:ge.cellXOffset)&&l===(ge==null?void 0:ge.cellYOffset)&&a===(ge==null?void 0:ge.translateX)&&u===(ge==null?void 0:ge.translateY))return;let _e=null;Pe&&(_e=n);const Qe=r;let tt;Pe?at!==void 0?tt=(ge==null?void 0:ge.lastBuffer)==="b"?Ge:Xe:tt=(ge==null?void 0:ge.lastBuffer)==="b"?Xe:Ge:tt=n;const Kt=tt.canvas,dt=Pe?Kt===wt?rt:wt:nt,ht=typeof w=="number"?()=>w:w;Qe.save(),tt.save(),Qe.beginPath(),tt.beginPath(),Qe.textBaseline="middle",tt.textBaseline="middle",xe!==1&&(Qe.scale(xe,xe),tt.scale(xe,xe));const pt=L0(c,o,i,h,a);let Lt=[];const Rt=m&&((ct=T.current)==null?void 0:ct.cell[1])===l&&u===0;let en=!1;if(W!==void 0){for(const xt of W)if(xt.style!=="no-outline"&&xt.range.y===l&&u===0){en=!0;break}}const Hn=()=>{x5(Qe,pt,f,G,i,a,x,g,h,S,T,p,B,L,k,P,at,ee,ye),Ob(Qe,pt,l,a,u,i,s,void 0,void 0,g,$e,ht,I,k,M,O,p,!0),Qe.beginPath(),Qe.moveTo(0,At-.5),Qe.lineTo(i,At-.5),Qe.strokeStyle=Vr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Qe.stroke(),en&&Pb(Qe,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),Rt&&Qg(Qe,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O)};if(at!==void 0){const xt=pt[pt.length-1].sourceIndex+1,dn=at.hasItemInRegion([{x:o,y:-2,width:xt,height:2},{x:o,y:l,width:xt,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:xt,height:M,when:M>0}]),ne=Le=>{ab(Le,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,me,Lt,at,T,ie,W,R,B,L,G,te,H,p,oe,be,Ce,b,Ut);const ze=T.current;A&&m&&ze!==void 0&&at.has(eE(ze.range))&&Qg(Le,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O)};dn&&(ne(tt),_e!==null&&(_e.save(),_e.scale(xe,xe),_e.textBaseline="middle",ne(_e),_e.restore()),at.hasHeader()&&(OW(Qe,pt,i,g,$e,a,u,l,at),Hn())),tt.restore(),Qe.restore();return}if((Je!==!0||o!==(ge==null?void 0:ge.cellXOffset)||a!==(ge==null?void 0:ge.translateX)||Rt!==(ge==null?void 0:ge.mustDrawFocusOnHeader)||en!==(ge==null?void 0:ge.mustDrawHighlightRingsOnHeader))&&Hn(),Je===!0){Wr(dt!==void 0&&ge!==void 0);const{regions:xt}=AW(tt,dt,dt===wt?ge.aBufferScroll:ge.bBufferScroll,dt===wt?ge.bBufferScroll:ge.aBufferScroll,ge,o,l,a,u,M,i,s,O,$e,xe,c,pt,w,Pe);Lt=xt}else Je!==!1&&(Wr(ge!==void 0),Lt=MW(ge,o,l,a,u,i,s,$e,pt,Je));TW(tt,pt,i,s,M,O,k,ht,p);const Pt=Pb(tt,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),vn=m?Qg(tt,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O):void 0;if(tt.fillStyle=p.bgCell,Lt.length>0){tt.beginPath();for(const xt of Lt)tt.rect(xt.x,xt.y,xt.width,xt.height);tt.clip(),tt.fill(),tt.beginPath()}else tt.fillRect(0,0,i,s);const In=ab(tt,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,me,Lt,at,T,ie,W,R,B,L,G,te,H,p,oe,be,Ce,b,Ut);CW(tt,pt,c,i,s,$e,a,u,l,O,ht,I,T.rows,y,M,me,Lt,at,p),EW(tt,pt,l,a,u,i,s,Lt,$e,ht,I,k,M,O,p),Ob(tt,pt,l,a,u,i,s,Lt,In,g,$e,ht,I,k,M,O,p),Pt==null||Pt(),vn==null||vn(),S&&Lo(pt,0,a,0,$e,(xt,dn)=>xt.sourceIndex===V?(Ib(Qe,dn+xt.width,0,$e+1,Vr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ib(tt,dn+xt.width,$e,s,Vr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),_e!==null&&(_e.fillStyle=p.bgCell,_e.fillRect(0,0,i,s),_e.drawImage(tt.canvas,0,0));const Pr=PW(pt,s,$e,a,u,l,O,ht,M,me);R==null||R.setWindow({x:o,y:l,width:pt.length,height:Pr-l},d,Array.from({length:M},(xt,dn)=>O-1-dn));const Ir=ge!==void 0&&(o!==ge.cellXOffset||a!==ge.translateX),Bt=ge!==void 0&&(l!==ge.cellYOffset||u!==ge.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Rt,mustDrawHighlightRingsOnHeader:en,lastBuffer:Pe?Kt===wt?"a":"b":void 0,aBufferScroll:Kt===wt?[Ir,Bt]:ge==null?void 0:ge.aBufferScroll,bBufferScroll:Kt===rt?[Ir,Bt]:ge==null?void 0:ge.bBufferScroll},tt.restore(),Qe.restore()}const IW=80;function NW(t){const e=t-1;return e*e*e+1}class DW{constructor(e){bt(this,"callback");bt(this,"currentHoveredItem");bt(this,"leavingItems",[]);bt(this,"lastAnimationTime");bt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>nc(r.item,e.item))||this.leavingItems.push(e)});bt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>nc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});bt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});bt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});bt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:NW(e.hoverAmount)})));bt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/IW;for(const s of this.leavingItems)s.hoverAmount=Oi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Oi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});bt(this,"setHovered",e=>{var n;if(!nc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class _W{constructor(e){bt(this,"fn");bt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function ow(t){return new _W(t)}const LW=ow(()=>window.navigator.userAgent.includes("Firefox")),Ah=ow(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Mh=ow(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function FW(t){const e=v.useRef([]),n=v.useRef(0),r=v.useRef(t);r.current=t;const i=v.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(tw);e.current=[],r.current(new ic(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return v.useCallback(s=>{e.current.length===0&&i();const o=Pi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const no="header",Hr="group-header",Rh="out-of-bounds";var da;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(da||(da={}));function _E(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const Db=6,$W=(t,e)=>{if(t.kind===Te.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},zW=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:g,onCanvasFocused:y,onCanvasBlur:w,isFocused:k,selection:b,freezeColumns:S,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:ee,onItemHovered:ie,dragAndDropState:te,firstColAccessible:W,onKeyDown:V,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:H,onDragEnd:G,eventTargetRef:B,isResizing:le,resizeColumn:me,isDragging:ye,isDraggable:oe=!1,allowResize:be,disabledRows:Ce,hasAppendRow:lt,getGroupDetails:Xe,theme:Ge,prelightCells:at,headerIcons:Ut,verticalBorder:Pe,drawCell:xe,drawHeader:Je,onCellFocused:nt,onDragOverCell:it,onDrop:$e,onDragLeave:At,imageWindowLoader:wt,smoothScrollX:rt=!1,smoothScrollY:ge=!1,experimental:_e,getCellRenderer:Qe}=t,tt=t.translateX??0,Kt=t.translateY??0,dt=Math.max(S,Math.min(s.length-1,o)),ht=v.useRef(null),pt=wt,Lt=v.useRef(),[Rt,en]=v.useState(!1),Hn=v.useRef([]),Pt=v.useRef(),[vn,In]=v.useState(),[Pr,Ir]=v.useState(),Bt=v.useRef(null),[ct,xt]=v.useState(),[dn,ne]=v.useState(!1),Le=v.useRef(dn);Le.current=dn;const ze=v.useMemo(()=>new h5(Ut,()=>{qn.current=void 0,zo.current()}),[Ut]),An=x?c+a:a,z=v.useRef(-1),ue=((_e==null?void 0:_e.enableFirefoxRescaling)??!1)&&LW.value,q=((_e==null?void 0:_e.enableSafariRescaling)??!1)&&Ah.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!ue&&!q||(z.current!==-1&&en(!0),window.clearTimeout(z.current),z.current=window.setTimeout(()=>{en(!1),z.current=-1},200))},[l,dt,tt,Kt,ue,q]);const ce=u4(s,S),fe=M?La(ce,te):0,Fe=v.useCallback((j,se,ke)=>{const ve=j.getBoundingClientRect();if(se>=ce.length||ke>=d)return;const de=ve.width/n,Oe=F0(se,ke,n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f);return de!==1&&(Oe.x*=de,Oe.y*=de,Oe.width*=de,Oe.height*=de),Oe.x+=ve.x,Oe.y+=ve.y,Oe},[n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f]),Re=v.useCallback((j,se,ke,ve)=>{const de=j.getBoundingClientRect(),Oe=de.width/n,st=(se-de.left)/Oe,ot=(ke-de.top)/Oe,Ae=5,Ft=L0(ce,dt,n,void 0,tt);let Be=0,zt=0;ve instanceof MouseEvent&&(Be=ve.button,zt=ve.buttons);const ft=h4(st,Ft,tt),St=p4(ot,r,x,a,c,d,f,l,Kt,A),wn=(ve==null?void 0:ve.shiftKey)===!0,gt=(ve==null?void 0:ve.ctrlKey)===!0,hn=(ve==null?void 0:ve.metaKey)===!0,Zr=ve!==void 0&&!(ve instanceof MouseEvent)||(ve==null?void 0:ve.pointerType)==="touch",ln=[st<0?-1:nn||ot>r){const It=st>n?1:st<0?-1:0,xn=ot>r?1:ot<0?-1:0;let Lr=It*2,Vi=xn*2;It===0&&(Lr=ft===-1?da.EndPadding:da.Center),xn===0&&(Vi=St===void 0?da.EndPadding:da.Center);let xi=!1;if(ft===-1&&St===-1){const jo=Fe(j,ce.length-1,-1);Wr(jo!==void 0),xi=sen&&str&&ot=0?(xn=!0,It=Fe(j,Lr,St),Wr(It!==void 0),_r={kind:x&&St===-2?Hr:no,location:[Lr,St],bounds:It,group:ce[Lr].group??"",isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:ke-It.y,button:Be,buttons:zt,scrollEdge:ln}):_r={kind:x&&St===-2?Hr:no,group:ce[ft].group??"",location:[ft,St],bounds:It,isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:ke-It.y,button:Be,buttons:zt,scrollEdge:ln}}else{const It=Fe(j,ft,St);Wr(It!==void 0);const xn=It!==void 0&&It.x+It.width-se{}),Ot=v.useRef(vn);Ot.current=vn;const[Xt,Nn]=v.useMemo(()=>{const j=document.createElement("canvas"),se=document.createElement("canvas");return j.style.display="none",j.style.opacity="0",j.style.position="fixed",se.style.display="none",se.style.opacity="0",se.style.position="fixed",[j.getContext("2d",{alpha:!1}),se.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(Xt===null||Nn===null))return document.documentElement.append(Xt.canvas),document.documentElement.append(Nn.canvas),()=>{Xt.canvas.remove(),Nn.canvas.remove()}},[Xt,Nn]);const wr=v.useMemo(()=>new C4,[]),Mn=ue&&Rt?1:q&&Rt?2:5,ys=(_e==null?void 0:_e.disableMinimumCellWidth)===!0?1:10,qn=v.useRef(),vs=v.useRef(null),ws=v.useRef(null),Ol=v.useCallback(()=>{var st;const j=ht.current,se=Bt.current;if(j===null||se===null||(vs.current===null&&(vs.current=j.getContext("2d",{alpha:!1}),j.width=0,j.height=0),ws.current===null&&(ws.current=se.getContext("2d",{alpha:!1}),se.width=0,se.height=0),vs.current===null||ws.current===null||Xt===null||Nn===null))return;let ke=!1;const ve=ot=>{ke=!0,xt(ot)},de=qn.current,Oe={headerCanvasCtx:ws.current,canvasCtx:vs.current,bufferACtx:Xt,bufferBCtx:Nn,width:n,height:r,cellXOffset:dt,cellYOffset:l,translateX:Math.round(tt),translateY:Math.round(Kt),mappedColumns:ce,enableGroups:x,freezeColumns:S,dragAndDropState:te,theme:Ge,headerHeight:a,groupHeaderHeight:c,disabledRows:Ce??Nt.empty(),rowHeight:f,verticalBorder:Pe,isResizing:le,resizeCol:me,isFocused:k,selection:b,fillHandle:u,drawCellCallback:xe,hasAppendRow:lt,overrideCursor:ve,maxScaleFactor:Mn,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:Xe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:Je,prelightCells:at,highlightRegions:N,imageLoader:pt,lastBlitData:Pt,damage:Lt.current,hoverValues:Hn.current,hoverInfo:Ot.current,spriteManager:ze,scrolling:Rt,hyperWrapping:(_e==null?void 0:_e.hyperWrapping)??!1,touchMode:dn,enqueue:ut.current,renderStateProvider:wr,renderStrategy:(_e==null?void 0:_e.renderStrategy)??(Ah.value?"double-buffer":"single-buffer"),getCellRenderer:Qe,minimumCellWidth:ys};Oe.damage===void 0?(qn.current=Oe,Nb(Oe,de)):Nb(Oe,void 0),!ke&&(Oe.damage===void 0||Oe.damage.has((st=Ot==null?void 0:Ot.current)==null?void 0:st[0]))&&xt(void 0)},[Xt,Nn,n,r,dt,l,tt,Kt,ce,x,S,te,Ge,a,c,Ce,f,Pe,le,lt,me,k,b,u,A,d,_,Mn,h,Xe,p,xe,Je,at,N,pt,ze,Rt,_e==null?void 0:_e.hyperWrapping,_e==null?void 0:_e.renderStrategy,dn,wr,Qe,ys]),zo=v.useRef(Ol);v.useLayoutEffect(()=>{Ol(),zo.current=Ol},[Ol]),v.useLayoutEffect(()=>{(async()=>{var se;((se=document==null?void 0:document.fonts)==null?void 0:se.ready)!==void 0&&(await document.fonts.ready,qn.current=void 0,zo.current())})()},[]);const Hs=v.useCallback(j=>{Lt.current=j,zo.current(),Lt.current=void 0},[]),af=FW(Hs);ut.current=af;const uf=v.useCallback(j=>{Hs(new ic(j.map(se=>se.cell)))},[Hs]);pt.setCallback(Hs);const[Hp,Wp]=v.useState(!1),[Pl,xs]=We??[],Vp=Pl!==void 0&&xs===-1,Up=Pl!==void 0&&xs===-2;let cf=!1,Il=!1,Rn=ct;if(Rn===void 0&&Pl!==void 0&&xs!==void 0&&xs>-1&&xs({contain:"strict",display:"block",cursor:ff}),[ff]),iu=v.useRef("default"),Ws=B==null?void 0:B.current;Ws!=null&&iu.current!==Nl.cursor&&(Ws.style.cursor=iu.current=Nl.cursor);const Nr=v.useCallback((j,se,ke,ve)=>{if(Xe===void 0)return;const de=Xe(j);if(de.actions!==void 0){const Oe=kE(se,de.actions);for(const[st,ot]of Oe.entries())if(Ap(ot,ke+se.x,ve+ot.y))return de.actions[st]}},[Xe]),yi=v.useCallback((j,se,ke,ve)=>{const de=s[se];if(!ye&&!le&&de.hasMenu===!0&&!(Pr??!1)){const Oe=Fe(j,se,-1);Wr(Oe!==void 0);const st=bE(Oe.x,Oe.y,Oe.width,Oe.height,Yv(de.title)==="rtl");if(ke>st.x&&kest.y&&ve{const se=ht.current,ke=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==ke)return;ou.current=!0;let ve,de;if(j instanceof MouseEvent?(ve=j.clientX,de=j.clientY):(ve=j.touches[0].clientX,de=j.touches[0].clientY),j.target===ke&&ke!==null){const st=ke.getBoundingClientRect();if(ve>st.right||de>st.bottom)return}const Oe=Re(se,ve,de,j);Vs.current=Oe.location,Oe.isTouch&&(su.current=Date.now()),Le.current!==Oe.isTouch&&ne(Oe.isTouch),!(Oe.kind===no&&yi(se,Oe.location[0],ve,de)!==void 0)&&(Oe.kind===Hr&&Nr(Oe.group,Oe.bounds,Oe.localEventX,Oe.localEventY)!==void 0||(P==null||P(Oe),!Oe.isTouch&&oe!==!0&&oe!==Oe.kind&&Oe.button<3&&Oe.button!==1&&j.preventDefault()))},[B,oe,Re,Nr,yi,P]);Vn("touchstart",ar,window,!1),Vn("mousedown",ar,window,!1);const Dl=v.useRef(0),lu=v.useCallback(j=>{var zt,ft;const se=Dl.current;Dl.current=Date.now();const ke=ht.current;if(ou.current=!1,I===void 0||ke===null)return;const ve=B==null?void 0:B.current,de=j.target!==ke&&j.target!==ve;let Oe,st,ot=!0;if(j instanceof MouseEvent){if(Oe=j.clientX,st=j.clientY,ot=j.button<3,j.pointerType==="touch")return}else Oe=j.changedTouches[0].clientX,st=j.changedTouches[0].clientY;let Ae=Re(ke,Oe,st,j);Ae.isTouch&&su.current!==0&&Date.now()-su.current>500&&(Ae={...Ae,isLongTouch:!0}),se!==0&&Date.now()-se<(Ae.isTouch?1e3:500)&&(Ae={...Ae,isDoubleClick:!0}),Le.current!==Ae.isTouch&&ne(Ae.isTouch),!de&&j.cancelable&&ot&&j.preventDefault();const[Ft]=Ae.location,Be=yi(ke,Ft,Oe,st);if(Ae.kind===no&&Be!==void 0){(Ae.button!==0||((zt=Vs.current)==null?void 0:zt[0])!==Ft||((ft=Vs.current)==null?void 0:ft[1])!==-1)&&I(Ae,!0);return}else if(Ae.kind===Hr){const St=Nr(Ae.group,Ae.bounds,Ae.localEventX,Ae.localEventY);if(St!==void 0){Ae.button===0&&St.onClick(Ae);return}}I(Ae,de)},[I,B,Re,yi,Nr]);Vn("mouseup",lu,window,!1),Vn("touchend",lu,window,!1);const df=v.useCallback(j=>{var Be,zt;const se=ht.current;if(se===null)return;const ke=B==null?void 0:B.current,ve=j.target!==se&&j.target!==ke;let de,Oe,st=!0;j instanceof MouseEvent?(de=j.clientX,Oe=j.clientY,st=j.button<3):(de=j.changedTouches[0].clientX,Oe=j.changedTouches[0].clientY);const ot=Re(se,de,Oe,j);Le.current!==ot.isTouch&&ne(ot.isTouch),!ve&&j.cancelable&&st&&j.preventDefault();const[Ae]=ot.location,Ft=yi(se,Ae,de,Oe);if(ot.kind===no&&Ft!==void 0)ot.button===0&&((Be=Vs.current)==null?void 0:Be[0])===Ae&&((zt=Vs.current)==null?void 0:zt[1])===-1&&(m==null||m(Ae,Ft));else if(ot.kind===Hr){const ft=Nr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ft!==void 0&&ot.button===0&&ft.onClick(ot)}},[B,Re,yi,m,Nr]);Vn("click",df,window,!1);const Kp=v.useCallback(j=>{const se=ht.current,ke=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==ke||T===void 0)return;const ve=Re(se,j.clientX,j.clientY,j);T(ve,()=>{j.cancelable&&j.preventDefault()})},[B,Re,T]);Vn("contextmenu",Kp,(B==null?void 0:B.current)??null,!1);const hf=v.useCallback(j=>{Lt.current=new ic(j.map(se=>se.item)),Hn.current=j,zo.current(),Lt.current=void 0},[]),vi=v.useMemo(()=>new DW(hf),[hf]),bs=v.useRef(vi);bs.current=vi,v.useLayoutEffect(()=>{const j=bs.current;if(We===void 0||We[1]<0){j.setHovered(We);return}const se=h(We,!0),ke=Qe(se),ve=ke===void 0&&se.kind===Te.Custom||(ke==null?void 0:ke.needsHover)!==void 0&&(typeof ke.needsHover=="boolean"?ke.needsHover:ke.needsHover(se));j.setHovered(ve?We:void 0)},[h,Qe,We]);const Dr=v.useRef(),X=v.useCallback(j=>{var ot;const se=ht.current;if(se===null)return;const ke=B==null?void 0:B.current,ve=j.target!==se&&j.target!==ke,de=Re(se,j.clientX,j.clientY,j);if(de.kind!=="out-of-bounds"&&ve&&!ou.current&&!de.isTouch)return;const Oe=(Ae,Ft)=>{In(Be=>Be===Ae||(Be==null?void 0:Be[0][0])===(Ae==null?void 0:Ae[0][0])&&(Be==null?void 0:Be[0][1])===(Ae==null?void 0:Ae[0][1])&&((Be==null?void 0:Be[1][0])===(Ae==null?void 0:Ae[1][0])&&(Be==null?void 0:Be[1][1])===(Ae==null?void 0:Ae[1][1])||!Ft)?Be:Ae)};if(!_E(de,Dr.current))xt(void 0),ie==null||ie(de),Oe(de.kind===Rh?void 0:[de.location,[de.localEventX,de.localEventY]],!0),Dr.current=de;else if(de.kind==="cell"||de.kind===no||de.kind===Hr){let Ae=!1,Ft=!0;if(de.kind==="cell"){const zt=h(de.location);Ft=((ot=Qe(zt))==null?void 0:ot.needsHoverPosition)??zt.kind===Te.Custom,Ae=Ft}else de.kind===Hr&&(Ae=!0);const Be=[de.location,[de.localEventX,de.localEventY]];Oe(Be,Ft),Ot.current=Be,Ae&&Hs(new ic([de.location]))}const st=de.location[0]>=(W?0:1);Ir(de.kind===no&&de.isEdge&&st&&be===!0),Wp(de.kind==="cell"&&de.isFillHandle),D==null||D(j),ee(de)},[B,Re,W,be,D,ee,ie,h,Qe,Hs]);Vn("mousemove",X,window,!0);const on=v.useCallback(j=>{const se=ht.current;if(se===null)return;let ke,ve;b.current!==void 0&&(ke=Fe(se,b.current.cell[0],b.current.cell[1]),ve=b.current.cell),V==null||V({bounds:ke,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ve})},[V,b,Fe]),Bo=v.useCallback(j=>{const se=ht.current;if(se===null)return;let ke,ve;b.current!==void 0&&(ke=Fe(se,b.current.cell[0],b.current.cell[1]),ve=b.current.cell),R==null||R({bounds:ke,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ve})},[R,b,Fe]),Xp=v.useCallback(j=>{ht.current=j,L!==void 0&&(L.current=j)},[L]),pf=v.useCallback(j=>{const se=ht.current;if(se===null||oe===!1||le){j.preventDefault();return}let ke,ve;const de=Re(se,j.clientX,j.clientY);if(oe!==!0&&de.kind!==oe){j.preventDefault();return}const Oe=(zt,ft)=>{ke=zt,ve=ft};let st,ot,Ae;const Ft=(zt,ft,St)=>{st=zt,ot=ft,Ae=St};let Be=!1;if(H==null||H({...de,setData:Oe,setDragImage:Ft,preventDefault:()=>Be=!0,defaultPrevented:()=>Be}),!Be&&ke!==void 0&&ve!==void 0&&j.dataTransfer!==null)if(j.dataTransfer.setData(ke,ve),j.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Ae!==void 0)j.dataTransfer.setDragImage(st,ot,Ae);else{const[zt,ft]=de.location;if(ft!==void 0){const St=document.createElement("canvas"),wn=Fe(se,zt,ft);Wr(wn!==void 0);const gt=Math.ceil(window.devicePixelRatio??1);St.width=wn.width*gt,St.height=wn.height*gt;const hn=St.getContext("2d");hn!==null&&(hn.scale(gt,gt),hn.textBaseline="middle",ft===-1?(hn.font=Ge.headerFontFull,hn.fillStyle=Ge.bgHeader,hn.fillRect(0,0,St.width,St.height),SE(hn,0,0,wn.width,wn.height,ce[zt],!1,Ge,!1,!1,0,ze,Je,!1)):(hn.font=Ge.baseFontFull,hn.fillStyle=Ge.bgCell,hn.fillRect(0,0,St.width,St.height),xE(hn,h([zt,ft]),0,ft,!1,!1,0,0,wn.width,wn.height,!1,Ge,Ge.bgCell,pt,ze,1,void 0,!1,0,void 0,void 0,void 0,wr,Qe,()=>{}))),St.style.left="-100%",St.style.position="absolute",St.style.width=`${wn.width}px`,St.style.height=`${wn.height}px`,document.body.append(St),j.dataTransfer.setDragImage(St,wn.width/2,wn.height/2),window.setTimeout(()=>{St.remove()},0)}}else j.preventDefault()},[oe,le,Re,H,Fe,Ge,ce,ze,Je,h,pt,wr,Qe]);Vn("dragstart",pf,(B==null?void 0:B.current)??null,!1,!1);const au=v.useRef(),Gp=v.useCallback(j=>{const se=ht.current;if($e!==void 0&&j.preventDefault(),se===null||it===void 0)return;const ke=Re(se,j.clientX,j.clientY),[ve,de]=ke.location,Oe=ve-(W?0:1),[st,ot]=au.current??[];(st!==Oe||ot!==de)&&(au.current=[Oe,de],it([Oe,de],j.dataTransfer))},[W,Re,it,$e]);Vn("dragover",Gp,(B==null?void 0:B.current)??null,!1,!1);const $w=v.useCallback(()=>{au.current=void 0,G==null||G()},[G]);Vn("dragend",$w,(B==null?void 0:B.current)??null,!1,!1);const J=v.useCallback(j=>{const se=ht.current;if(se===null||$e===void 0)return;j.preventDefault();const ke=Re(se,j.clientX,j.clientY),[ve,de]=ke.location,Oe=ve-(W?0:1);$e([Oe,de],j.dataTransfer)},[W,Re,$e]);Vn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Yn=v.useCallback(()=>{At==null||At()},[At]);Vn("dragleave",Yn,(B==null?void 0:B.current)??null,!1,!1);const On=v.useRef(b);On.current=b;const _l=v.useRef(null),uu=v.useCallback(j=>{var se;ht.current===null||!ht.current.contains(document.activeElement)||(j===null&&On.current.current!==void 0?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j!==null&&j.focus({preventScroll:!0}),_l.current=j)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var se;const j=_l.current;j===null||!document.contains(j)?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j.focus({preventScroll:!0})},getBounds:(j,se)=>{if(!(L===void 0||L.current===null))return Fe(L.current,j??0,se??-1)},damage:uf}),[L,uf,Fe]);const Us=v.useRef(),xr=M$(()=>{var ot,Ae,Ft;if(n<50||(_e==null?void 0:_e.disableAccessibilityTree)===!0)return null;let j=L0(ce,dt,n,te,tt);const se=W?0:-1;!W&&((ot=j[0])==null?void 0:ot.sourceIndex)===0&&(j=j.slice(1));const[ke,ve]=((Ae=b.current)==null?void 0:Ae.cell)??[],de=(Ft=b.current)==null?void 0:Ft.range,Oe=j.map(Be=>Be.sourceIndex),st=nl(l,Math.min(d,l+i));return ke!==void 0&&ve!==void 0&&!(Oe.includes(ke)&&st.includes(ve))&&uu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":ce.length+se},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},j.map(Be=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Be.sourceIndex),"aria-colindex":Be.sourceIndex+1+se,tabIndex:-1,onFocus:zt=>{if(zt.target!==_l.current)return nt==null?void 0:nt([Be.sourceIndex,-1])},key:Be.sourceIndex},Be.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(Be=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Be),key:Be,"aria-rowindex":Be+2},j.map(zt=>{const ft=zt.sourceIndex,St=Pi(ft,Be),wn=ke===ft&&ve===Be,gt=de!==void 0&&ft>=de.x&&ft=de.y&&Be{const _r=L==null?void 0:L.current;if(_r!=null)return V==null?void 0:V({bounds:Fe(_r,ft,Be),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Zr})},onFocusCapture:_r=>{var It,xn;if(!(_r.target===_l.current||((It=Us.current)==null?void 0:It[0])===ft&&((xn=Us.current)==null?void 0:xn[1])===Be))return Us.current=Zr,nt==null?void 0:nt(Zr)},ref:wn?uu:void 0,tabIndex:-1},$W(ln,Qe))})))))},[n,ce,dt,te,tt,d,l,i,b,uu,h,L,V,Fe,nt],200),wi=S===0||!M?0:dt>S?1:Oi(-tt/100,0,1),qp=-l*32+Kt,Ll=O?Oi(-qp/100,0,1):0,Yp=v.useMemo(()=>{if(!wi&&!Ll)return null;const j={position:"absolute",top:0,left:fe,width:n-fe,height:r,opacity:wi,pointerEvents:"none",transition:rt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},se={position:"absolute",top:An,left:0,width:n,height:r,opacity:Ll,pointerEvents:"none",transition:ge?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,wi>0&&v.createElement("div",{id:"shadow-x",style:j}),Ll>0&&v.createElement("div",{id:"shadow-y",style:se}))},[wi,Ll,fe,n,rt,An,r,ge]),Jp=v.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return v.createElement(v.Fragment,null,v.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:on,onKeyUp:Bo,onFocus:y,onBlur:w,ref:Xp,style:Nl},xr),v.createElement("canvas",{ref:Bt,style:Jp}),Yp)},BW=v.memo(v.forwardRef(zW));function Ru(t,e,n,r){return Oi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const jW=t=>{const[e,n]=v.useState(),[r,i]=v.useState(),[s,o]=v.useState(),[l,a]=v.useState(),[u,c]=v.useState(!1),[f,d]=v.useState(),[h,p]=v.useState(),[m,x]=v.useState(),[g,y]=v.useState(!1),[w,k]=v.useState(),{onHeaderMenuClick:b,getCellContent:S,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:ee,onColumnProposeMove:ie,onMouseDown:te,onMouseUp:W,onItemHovered:V,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:H,selection:G}=t,B=G.columns,le=v.useCallback(Pe=>{const[xe,Je]=Pe.location;s!==void 0&&l!==xe&&xe>=ee?(c(!0),a(xe)):h!==void 0&&Je!==void 0?(y(!0),x(Math.max(0,Je))):r===void 0&&!u&&!g&&(V==null||V(Pe))},[s,h,l,V,ee,r,u,g]),me=T!==void 0,ye=v.useCallback(Pe=>{var xe;if(Pe.button===0){const[Je,nt]=Pe.location;if(Pe.kind==="out-of-bounds"&&Pe.isEdge&&L){const it=(xe=_==null?void 0:_.current)==null?void 0:xe.getBounds(H.length-1,-1);it!==void 0&&(n(it.x),i(H.length-1))}else if(Pe.kind==="header"&&Je>=ee){const it=N==null?void 0:N.current;if(Pe.isEdge&&L&&it){n(Pe.bounds.x),i(Je);const At=it.getBoundingClientRect().width/it.offsetWidth,wt=Pe.bounds.width/At;M==null||M(H[Je],wt,Je,wt+(H[Je].growOffset??0))}else Pe.kind==="header"&&me&&(d(Pe.bounds.x),o(Je))}else Pe.kind==="cell"&&ee>0&&Je===0&&nt!==void 0&&D!==void 0&&(k(Pe.bounds.y),p(nt))}te==null||te(Pe)},[te,L,ee,D,_,H,me,M,N]),oe=v.useCallback((Pe,xe)=>{u||g||b==null||b(Pe,xe)},[u,g,b]),be=v.useRef(-1),Ce=v.useCallback(()=>{be.current=-1,p(void 0),x(void 0),k(void 0),y(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),lt=v.useCallback((Pe,xe)=>{if(Pe.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,be.current,I,P);A==null||A(it,$e,nt,$e+(it.growOffset??0))}const Je=Ru(H[r],be.current,I,P);if(O==null||O(H[r],Je,r,Je+(H[r].growOffset??0)),B.hasIndex(r))for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,be.current,I,P);O==null||O(it,$e,nt,$e+(it.growOffset??0))}}Ce(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}W==null||W(Pe,xe)},[W,r,s,l,h,m,B,O,H,I,P,A,T,D,Ce]),Xe=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ie==null?void 0:ie(s,l))!==!1)return{src:s,dest:l}},[s,l,ie]),Ge=v.useCallback(Pe=>{const xe=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Pe.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Pe.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&xe){const nt=xe.getBoundingClientRect().width/xe.offsetWidth,it=(Pe.clientX-e)/nt,$e=H[r],At=Ru($e,it,I,P);if(A==null||A($e,At,r,At+($e.growOffset??0)),be.current=it,(B==null?void 0:B.first())===r)for(const wt of B){if(wt===r)continue;const rt=H[wt],ge=Ru(rt,be.current,I,P);A==null||A(rt,ge,wt,ge+(rt.growOffset??0))}}},[s,f,h,w,r,e,H,I,P,A,B,N]),at=v.useCallback((Pe,xe)=>{if(h===void 0||m===void 0)return S(Pe,xe);let[Je,nt]=Pe;return nt===m?nt=h:(nt>m&&(nt-=1),nt>=h&&(nt+=1)),S([Je,nt],xe)},[h,m,S]),Ut=v.useCallback(Pe=>{R==null||R(Pe),Pe.defaultPrevented()||Ce()},[Ce,R]);return v.createElement(BW,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:at,isResizing:r!==void 0,onHeaderMenuClick:oe,isDragging:u,onItemHovered:le,onDragStart:Ut,onMouseDown:ye,allowResize:L,onMouseUp:lt,dragAndDropState:Xe,onMouseMoveRaw:Ge,ref:_})};function HW(t){const e=v.useRef(null),[n,r]=v.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return v.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const WW=(t,e,n)=>{const r=v.useRef(null),i=v.useRef(null),s=v.useRef(null),o=v.useRef(0),l=v.useRef(e);l.current=e;const a=n.current;v.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},VW=()=>t=>t.isSafari?"scroll":"auto",UW=Jr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[VW()]}});function KW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return Vn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Vn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const XW=t=>{var H,G;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:m}=t,x=[],g=(d==null?void 0:d.sticky)??!1,y=(d==null?void 0:d.fill)??!1,w=v.useRef(0),k=v.useRef(0),b=v.useRef(null),S=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=v.useRef(null),M=KW(200),[O,_]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||M||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[le,me]=T.current.lockDirection;le!==void 0?B.scrollLeft=le:me!==void 0&&(B.scrollTop=me),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,le)=>{var xe;const me=b.current;if(me===null)return;le=le??me.scrollTop,B=B??me.scrollLeft;const ye=T.current.scrollTop,oe=T.current.scrollLeft,be=B-oe,Ce=le-ye;M&&be!==0&&Ce!==0&&(Math.abs(be)>3||Math.abs(Ce)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(be)0&&(Math.abs(Ut)>2e3||at===0||at===Pe)&&r>me.scrollHeight+5){const Je=at/Pe,nt=(r-Ge)*Je;w.current=nt-at}lt!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:at+w.current,width:Xe-c,height:Ge-u,paddingRight:((xe=A.current)==null?void 0:xe.clientWidth)??0})},[u,c,r,s,a,M]);WW(h&&Ah.value,I,b);const D=v.useRef(I);D.current=I;const ee=v.useRef(),ie=v.useRef(!1);v.useLayoutEffect(()=>{ie.current?I():ie.current=!0},[I,u,c]);const te=v.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let W=0,V=0;for(x.push(v.createElement("div",{key:W++,style:{width:i,height:0}}));VD.current(),0),ee.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(UW,{isSafari:Ah.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:te,style:ee.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>I()},v.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},v.createElement("div",{className:"dvn-stack"},x),f!==void 0&&v.createElement(v.Fragment,null,!y&&v.createElement("div",{className:"dvn-spacer"}),v.createElement("div",{ref:A,style:{height:L,maxHeight:n-Math.ceil(S%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:y?1:void 0,right:g?c??0:void 0,pointerEvents:"auto"}},f))))))},GW=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:g,overscrollY:y,initialSize:w,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:S}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),ee=u+Math.max(0,g??0);let ie=o?i+s:i;if(typeof r=="number")ie+=n*r;else for(let R=0;R{var Ce,lt;if(te.current===void 0)return;const R={...te.current};let N=0,L=R.x<0?-R.x:0,H=0,G=0;R.x=R.x<0?0:R.x;let B=0;for(let Xe=0;Xe=Ge+Xe.width)N+=Xe.width,G++,H++;else if(R.x>Ge)N+=Xe.width,k?L+=Ge-R.x:G++,H++;else if(R.x+R.width>Ge)N+=Xe.width,H++;else break}let le=0,me=0,ye=0;if(typeof r=="number")b?(me=Math.floor(R.y/r),le=me*r-R.y):me=Math.ceil(R.y/r),ye=Math.ceil(R.height/r)+me,le<0&&ye++;else{let Xe=0;for(let Ge=0;Ge=Xe+at)Xe+=at,me++,ye++;else if(R.y>Ut)Xe+=at,b?le+=Ut-R.y:me++,ye++;else if(R.y+R.height>at/2+Xe)Xe+=at,ye++;else break}}const oe={x:G,y:me,width:H-G,height:ye-me},be=_.current;(be===void 0||be.y!==oe.y||be.x!==oe.x||be.height!==oe.height||be.width!==oe.width||P.current!==L||I.current!==le||R.width!==((Ce=D.current)==null?void 0:Ce[0])||R.height!==((lt=D.current)==null?void 0:lt[1]))&&(d==null||d({x:G,y:me,width:H-G,height:ye-me},R.width,R.height,R.paddingRight??0,L,le),_.current=oe,P.current=L,I.current=le,D.current=[R.width,R.height])},[e,r,n,d,l,k,b]),V=v.useCallback(R=>{te.current=R,W()},[W]);return v.useEffect(()=>{W()},[W]),v.createElement(XW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:S===!0||typeof S=="string",scrollWidth:ee+(T??0),scrollHeight:ie+(A??0),clientHeight:O,rightElement:m,paddingBottom:A,paddingRight:T,rightElementProps:x,update:V,initialSize:w},v.createElement(jW,{eventTargetRef:h,width:M,height:O,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},qW=Jr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),YW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),JW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),QW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),ZW=10,e6=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=v.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=v.useState(""),x=o??p,g=v.useCallback(N=>{m(N),a==null||a(N)},[a]),[y,w]=v.useState(),k=v.useRef(y);k.current=y,v.useEffect(()=>{l!==void 0&&(l.length>0?w(N=>({rowsSearched:r,results:l.length,selectedIndex:(N==null?void 0:N.selectedIndex)??-1})):w(void 0))},[r,l]);const b=v.useRef();b.current===void 0&&(b.current=new AbortController);const S=v.useRef(),[T,A]=v.useState([]),M=l??T,O=v.useCallback(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0,b.current.abort())},[]),_=v.useRef(n);_.current=n;const P=v.useCallback(N=>{const L=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let H=_.current,G=Math.min(10,r),B=0;w(void 0),A([]);const le=[],me=async()=>{var Pe;if(u===void 0)return;const ye=performance.now(),oe=r-B;let be=u({x:0,y:H,width:i.length,height:Math.min(G,oe,r-H)},b.current.signal);typeof be=="function"&&(be=await be());let Ce=!1;for(const[xe,Je]of be.entries())for(const[nt,it]of Je.entries()){let $e;switch(it.kind){case Te.Text:case Te.Number:$e=it.displayData;break;case Te.Uri:case Te.Markdown:$e=it.data;break;case Te.Boolean:$e=typeof it.data=="boolean"?it.data.toString():void 0;break;case Te.Image:case Te.Bubble:$e=it.data.join("🐳");break;case Te.Custom:$e=it.copyData;break}$e!==void 0&&L.test($e)&&(le.push([nt,xe+H]),Ce=!0)}const lt=performance.now();Ce&&A([...le]),B+=be.length,Wr(B<=r);const Xe=((Pe=k.current)==null?void 0:Pe.selectedIndex)??-1;w({results:le.length,rowsSearched:B,selectedIndex:Xe}),c==null||c(le,Xe),H+G>=r?H=0:H+=G;const Ge=lt-ye,at=Math.max(Ge,1),Ut=ZW/at;G=Math.ceil(G*Ut),B{var N;d==null||d(),w(void 0),A([]),c==null||c([],-1),O(),(N=e==null?void 0:e.current)==null||N.focus()},[O,e,d,c]),D=v.useCallback(N=>{g(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),O()):P(N.target.value))},[P,O,g,l]);v.useEffect(()=>{f&&s.current!==null&&(g(""),s.current.focus({preventScroll:!0}))},[f,s,g]);const ee=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(M,L)},[y,c,M]),ie=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;let L=(y.selectedIndex-1)%y.results;L<0&&(L+=y.results),w({...y,selectedIndex:L}),c==null||c(M,L)},[c,M,y]),te=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ie():ee())},[I,ee,ie]);v.useEffect(()=>()=>{O()},[O]);const[W,V]=v.useState(!1);v.useEffect(()=>{if(f)V(!0);else{const N=setTimeout(()=>V(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!W)return null;let N;y!==void 0&&(N=y.results>=1e3?"over 1000":`${y.results} result${y.results!==1?"s":""}`,y.selectedIndex>=0&&(N=`${y.selectedIndex+1} of ${N}`));const L=B=>{B.stopPropagation()},G={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(qW,{className:f?"":"out",onMouseDown:L,onMouseMove:L,onMouseUp:L,onClick:L},v.createElement("div",{className:"gdg-search-bar-inner"},v.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:D,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:te}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ie,disabled:((y==null?void 0:y.results)??0)===0},YW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ee,disabled:((y==null?void 0:y.results)??0)===0},JW),d!==void 0&&v.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:I},QW)),y!==void 0?v.createElement(v.Fragment,null,v.createElement("div",{className:"gdg-search-status"},v.createElement("div",{"data-testid":"search-result-area"},N)),v.createElement("div",{className:"gdg-search-progress",style:G})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,W,y,r,h,s,D,x,te,ie,ee,d,I]);return v.createElement(v.Fragment,null,v.createElement(GW,{prelightCells:M,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),R)};class t6 extends v.PureComponent{constructor(){super(...arguments);bt(this,"wrapperRef",v.createRef());bt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return v.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const n6=()=>t=>Math.max(16,t.targetHeight-10),r6=Jr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[n6(),"px"]}}),i6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Ln.useState(n);return Ln.createElement(t6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Ln.createElement(r6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function s6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function yt(t,e,n){const r=LE(t,e);return r&&(n.didMatch=!0),r}function LE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(LE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!s6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":Mh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function o6(t,e,n,r,i,s){const o=Ln.useCallback((u,c,f,d)=>{var y;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,m=i==="mixed"&&h;let x={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((y=t.current)==null?void 0:y.rangeStack)??[]:[]},columns:p?t.columns:Nt.empty(),rows:m?t.rows:Nt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=Ln.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Nt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Nt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Ln.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Nt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Nt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function l6(t,e,n,r,i){const s=v.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:Te.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=v.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:Te.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Te.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function a6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Te.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Vv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Te.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Te.Image:case Te.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Te.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Te.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Te.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Te.Markdown:case Te.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Te.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Te.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Te.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Oc()}}function u6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:a6(o))})}function _b(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function c6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>_b(o,!0)).join(",")):i.push(_b(s.formatted,!1));e.push(i.join(" "))}return e.join(` +`)}function Zg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Lb(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function f6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function d6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${Zg(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+Zg(o)+"
    2. ").join("")}
    ${Zg(i.formatted)}
    "),e.join("")}function h6(t,e){const n=u6(t,e),r=c6(n),i=d6(n);return{textPlain:r,textHtml:i}}function Fb(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const m of d)m.replaceWith(` +`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:f6(h),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function p6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function $b(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function g6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` +`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` +`?(r.push(t.slice(i,o)),i=o+1,l===` +`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` +`)&&(r.push($b(t.slice(i,o))),i=o+1,l===` +`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function zb(t,e,n){var l;const r=h6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function FE(t){return t!==!0}function Bb(t){return typeof t=="string"?t:`${t}px`}const m6=()=>t=>t.innerWidth,y6=()=>t=>t.innerHeight,v6=Jr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[m6()],"wmyidgi-1":[y6()]}}),w6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(v6,{innerHeight:Bb(n),innerWidth:Bb(e),...i},r)},x6=2,b6=1300;function k6(t,e,n){const r=Ln.useRef(0),[i,s]=t??[0,0];Ln.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/b6);const d=r.current**1.618*f*x6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function S6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Ln.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=aE();return[typeof m=="number"?m*p:g=>Math.ceil(m(g)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const Zs={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function vt(t,e){return t===!0?e:t===!1?"":t}function jb(t){const e=Mh.value;return{activateCell:vt(t.activateCell," |Enter|shift+Enter"),clear:vt(t.clear,"any+Escape"),closeOverlay:vt(t.closeOverlay,"any+Escape"),acceptOverlayDown:vt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:vt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:vt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:vt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:vt(t.delete,e?"Backspace|Delete":"Delete"),downFill:vt(t.downFill,"primary+_68"),scrollToSelectedCell:vt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:vt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:vt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:vt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:vt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:vt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:vt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:vt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:vt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:vt(t.goToFirstCell,"primary+Home"),goToFirstColumn:vt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:vt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:vt(t.goToLastCell,"primary+End"),goToLastColumn:vt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:vt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:vt(t.goToNextPage,"PageDown"),goToPreviousPage:vt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:vt(t.rightFill,"primary+_82"),search:vt(t.search,"primary+f"),selectAll:vt(t.selectAll,"primary+a"),selectColumn:vt(t.selectColumn,"ctrl+ "),selectGrowDown:vt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:vt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:vt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:vt(t.selectGrowUp,"shift+ArrowUp"),selectRow:vt(t.selectRow,"shift+ "),selectToFirstCell:vt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:vt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:vt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:vt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:vt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:vt(t.selectToLastRow,"primary+shift+ArrowDown")}}function C6(t){const e=N$(t);return Ln.useMemo(()=>{if(e===void 0)return jb(Zs);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Zs.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Zs.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Zs.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Zs.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Zs.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Zs.selectToLastCell};return jb({...Zs,...n})},[e])}const T6=v.lazy(async()=>await cE(()=>import("./data-grid-overlay-editor-D184XVUK.js"),[]));let E6=0;function A6(t){return Oz(ob(ob(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return nl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Jf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const em={kind:Te.Loading,allowOverlay:!1},Qf={columns:Nt.empty(),rows:Nt.empty(),current:void 0},M6=(t,e)=>{var Qw,Zw,e1;const[n,r]=v.useState(Qf),[i,s]=v.useState(),o=v.useRef(null),l=v.useRef(null),[a,u]=v.useState(),c=v.useRef(null),f=v.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:g,columns:y,rows:w,getCellContent:k,onCellClicked:b,onCellActivated:S,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:ee="default",onGroupHeaderClicked:ie,onCellContextMenu:te,className:W,onHeaderContextMenu:V,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:H,onCellsEdited:G,onSearchResultsChanged:B,searchResults:le,onSearchValueChange:me,searchValue:ye,onKeyDown:oe,onKeyUp:be,keybindings:Ce,editOnType:lt=!0,onRowAppended:Xe,onColumnMoved:Ge,validateCell:at,highlightRegions:Ut,rangeSelect:Pe="rect",columnSelect:xe="multi",rowSelect:Je="multi",rangeSelectionBlending:nt="exclusive",columnSelectionBlending:it="exclusive",rowSelectionBlending:$e="exclusive",onDelete:At,onDragStart:wt,onMouseMove:rt,onPaste:ge,copyHeaders:_e=!1,freezeColumns:Qe=0,cellActivationBehavior:tt="second-click",rowSelectionMode:Kt="auto",onHeaderMenuClick:dt,getGroupDetails:ht,onSearchClose:pt,onItemHovered:Lt,onSelectionCleared:Rt,showSearch:en,onVisibleRegionChanged:Hn,gridSelection:Pt,onGridSelectionChange:vn,minColumnWidth:In=50,maxColumnWidth:Pr=500,maxColumnAutoWidth:Ir,provideEditor:Bt,trailingRowOptions:ct,freezeTrailingRows:xt=0,allowedFillDirections:dn="orthogonal",scrollOffsetX:ne,scrollOffsetY:Le,verticalBorder:ze,onDragOverCell:An,onDrop:z,onColumnResize:ue,onColumnResizeEnd:q,onColumnResizeStart:ce,customRenderers:fe,fillHandle:Fe,drawFocusRing:Re=!0,experimental:We,fixedShadowX:ut,fixedShadowY:Ot,headerIcons:Xt,imageWindowLoader:Nn,initialSize:wr,isDraggable:Mn,onDragLeave:ys,onRowMoved:qn,overscrollX:vs,overscrollY:ws,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:Hs,trapFocus:af=!1,smoothScrollX:uf,smoothScrollY:Hp,scaleToRem:Wp=!1,rowHeight:Pl=34,headerHeight:xs=36,groupHeaderHeight:Vp=xs,theme:Up,isOutsideClick:cf,renderers:Il}=t,Rn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Qr=(Rn==null?void 0:Rn.kind)??t.rowMarkers??"none",ff=(Rn==null?void 0:Rn.width)??t.rowMarkerWidth,Nl=(Rn==null?void 0:Rn.startIndex)??t.rowMarkerStartIndex??1,iu=(Rn==null?void 0:Rn.theme)??t.rowMarkerTheme,Ws=(Rn==null?void 0:Rn.checkboxStyle)??"square",Nr=Math.max(In,20),yi=Math.max(Pr,Nr),su=Math.max(Ir??yi,Nr),Vs=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),ou=v.useMemo(()=>Number.parseFloat(Vs.fontSize),[Vs]),{rowHeight:ar,headerHeight:Dl,groupHeaderHeight:lu,theme:df,overscrollX:Kp,overscrollY:hf}=S6({groupHeaderHeight:Vp,headerHeight:xs,overscrollX:vs,overscrollY:ws,remSize:ou,rowHeight:Pl,scaleToRem:Wp,theme:Up}),vi=C6(Ce),bs=ff??(w>1e4?48:w>1e3?44:w>100?36:32),Dr=Qr!=="none",X=Dr?1:0,on=Xe!==void 0,Bo=(ct==null?void 0:ct.sticky)===!0,[Xp,pf]=v.useState(!1),au=en??Xp,Gp=v.useCallback(()=>{pt!==void 0?pt():pf(!1)},[pt]),J=v.useMemo(()=>Pt===void 0?void 0:Jf(Pt,X),[Pt,X])??n,Yn=v.useRef();Yn.current===void 0&&(Yn.current=new AbortController),v.useEffect(()=>()=>Yn==null?void 0:Yn.current.abort(),[]);const[On,_l]=l6(R,k,X,Yn.current,w),uu=v.useCallback((C,$,F)=>{if(at===void 0)return!0;const U=[C[0]-X,C[1]];return at==null?void 0:at(U,$,F)},[X,at]),Us=v.useRef(Pt),xr=v.useCallback((C,$)=>{$&&(C=p6(C,On,X,ee,Yn.current)),vn!==void 0?(Us.current=Jf(C,-X),vn(Us.current)):r(C)},[vn,On,X,ee]),wi=Ul(ue,v.useCallback((C,$,F,U)=>{ue==null||ue(y[F-X],$,F-X,U)},[ue,X,y])),qp=Ul(q,v.useCallback((C,$,F,U)=>{q==null||q(y[F-X],$,F-X,U)},[q,X,y])),Ll=Ul(ce,v.useCallback((C,$,F,U)=>{ce==null||ce(y[F-X],$,F-X,U)},[ce,X,y])),Yp=Ul(O,v.useCallback((C,$)=>(O==null?void 0:O({...C,columnIndex:C.columnIndex-X},$))??!1,[O,X])),Jp=Ul(_,v.useCallback((C,$)=>(_==null?void 0:_({...C,col:C.col-X},$))??!1,[_,X])),j=v.useCallback(C=>{if(At!==void 0){const $=At(Jf(C,-X));return typeof $=="boolean"?$:Jf($,X)}return!0},[At,X]),[se,ke,ve]=o6(J,xr,nt,it,$e,Pe),de=v.useMemo(()=>To(aE(),df),[df]),[Oe,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Il===void 0)return{};const C={};for(const $ of Il)C[$.kind]=$;return C},[Il]),Ae=v.useCallback(C=>C.kind!==Te.Custom?ot[C.kind]:fe==null?void 0:fe.find($=>$.isMatch(C)),[fe,ot]);let{sizedColumns:Ft,nonGrowWidth:Be}=M4(y,w,_l,Oe[0]-(X===0?0:bs)-Oe[2],Nr,su,de,Ae,Yn.current);Qr!=="none"&&(Be+=bs);const zt=v.useMemo(()=>Ft.some(C=>C.group!==void 0),[Ft]),ft=zt?Dl+lu:Dl,St=J.rows.length,wn=Qr==="none"?void 0:St===0?!1:St===w?!0:void 0,gt=v.useMemo(()=>Qr==="none"?Ft:[{title:"",width:bs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:iu,rowMarker:Ws,rowMarkerChecked:wn},...Ft],[Qr,Ft,bs,iu,Ws,wn]),[hn,Zr]=v.useMemo(()=>[Le!==void 0&&typeof ar=="number"?Math.floor(Le/ar):0,Le!==void 0&&typeof ar=="number"?-(Le%ar):0],[Le,ar]),ln=v.useRef({height:1,width:1,x:0,y:0}),_r=v.useMemo(()=>({x:ln.current.x,y:hn,width:ln.current.width??1,height:ln.current.height??1,ty:Zr}),[Zr,hn]),It=v.useRef(!1),[xn,Lr,Vi]=I$(_r);ln.current=xn;const xi=(xn.height??1)>1;v.useLayoutEffect(()=>{if(Le!==void 0&&c.current!==null&&xi){if(c.current.scrollTop===Le)return;c.current.scrollTop=Le,c.current.scrollTop!==Le&&Vi(),It.current=!0}},[Le,xi,Vi]);const Fl=(xn.width??1)>1;v.useLayoutEffect(()=>{if(ne!==void 0&&c.current!==null&&Fl){if(c.current.scrollLeft===ne)return;c.current.scrollLeft=ne,c.current.scrollLeft!==ne&&Vi(),It.current=!0}},[ne,Fl,Vi]);const jo=xn.x+X,gf=xn.y,br=v.useRef(null),ur=v.useCallback(C=>{var $;C===!0?($=br.current)==null||$.focus():window.requestAnimationFrame(()=>{var F;(F=br.current)==null||F.focus()})},[]),Jn=on?w+1:w,ei=v.useCallback(C=>{const $=X===0?C:C.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),F=G==null?void 0:G($);if(F!==!0)for(const U of $)H==null||H(U.location,U.value);return F},[H,G,X]),[Ho,Qp]=v.useState(),mf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,$l=Re?(Qw=J.current)==null?void 0:Qw.cell:void 0,yf=$l==null?void 0:$l[0],vf=$l==null?void 0:$l[1],xR=v.useMemo(()=>{if((Ut===void 0||Ut.length===0)&&(mf??yf??vf??Ho)===void 0)return;const C=[];if(Ut!==void 0)for(const $ of Ut){const F=gt.length-$.range.x-X;F>0&&C.push({color:$.color,range:{...$.range,x:$.range.x+X,width:Math.min(F,$.range.width)},style:$.style})}return Ho!==void 0&&C.push({color:wl(de.accentColor,0),range:Ho,style:"dashed"}),mf!==void 0&&C.push({color:wl(de.accentColor,.5),range:mf,style:"solid-outline"}),yf!==void 0&&vf!==void 0&&C.push({color:de.accentColor,range:{x:yf,y:vf,width:1,height:1},style:"solid-outline"}),C.length>0?C:void 0},[Ho,mf,yf,vf,Ut,gt.length,de.accentColor,X]),zw=v.useRef(gt);zw.current=gt;const Fr=v.useCallback(([C,$],F=!1)=>{var Z,Y,Q,ae,re,Ee,Ie;const U=on&&$===Jn-1;if(C===0&&Dr)return U?em:{kind:oi.Marker,allowOverlay:!1,checkboxStyle:Ws,checked:(J==null?void 0:J.rows.hasIndex($))===!0,markerKind:Qr==="clickable-number"?"number":Qr,row:Nl+$,drawHandle:qn!==void 0,cursor:Qr==="clickable-number"?"pointer":void 0};if(U){const Ve=C===X?(ct==null?void 0:ct.hint)??"":"",qe=zw.current[C];if(((Z=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Z.disabled)===!0)return em;{const Mt=((Y=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Y.hint)??Ve,Ze=((Q=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Q.addIcon)??(ct==null?void 0:ct.addIcon);return{kind:oi.NewRow,hint:Mt,allowOverlay:!1,icon:Ze}}}else{const Se=C-X;if(F||(We==null?void 0:We.strict)===!0){const qe=ln.current,Mt=qe.x>Se||Se>qe.x+qe.width||qe.y>$||$>qe.y+qe.height||$>=eg.current,Ze=Se===((re=(ae=qe.extras)==null?void 0:ae.selected)==null?void 0:re[0])&&$===((Ee=qe.extras)==null?void 0:Ee.selected[1]);let He=!1;if(((Ie=qe.extras)==null?void 0:Ie.freezeRegions)!==void 0){for(const Jt of qe.extras.freezeRegions)if(Ap(Jt,Se,$)){He=!0;break}}if(Mt&&!Ze&&!He)return em}let Ve=k([Se,$]);return X!==0&&Ve.span!==void 0&&(Ve={...Ve,span:[Ve.span[0]+X,Ve.span[1]+X]}),Ve}},[on,Jn,Dr,Ws,J==null?void 0:J.rows,Qr,Nl,qn,X,ct==null?void 0:ct.hint,ct==null?void 0:ct.addIcon,We==null?void 0:We.strict,k]),Zp=v.useCallback(C=>{let $=(ht==null?void 0:ht(C))??{name:C};return L!==void 0&&C!==""&&($={icon:$.icon,name:$.name,overrideTheme:$.overrideTheme,actions:[...$.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>ng({group:$.name,bounds:F.bounds})}]}),$},[ht,L]),wf=v.useCallback(C=>{var Q;const[$,F]=C.cell,U=gt[$],K=(U==null?void 0:U.group)!==void 0?(Q=Zp(U.group))==null?void 0:Q.overrideTheme:void 0,Z=U==null?void 0:U.themeOverride,Y=p==null?void 0:p(F);s({...C,theme:To(de,K,Z,Y,C.content.themeOverride)})},[p,gt,Zp,de]),zl=v.useCallback((C,$,F)=>{var Y;if(J.current===void 0)return;const[U,K]=J.current.cell,Z=Fr([U,K]);if(Z.kind!==Te.Boolean&&Z.allowOverlay){let Q=Z;if(F!==void 0)switch(Q.kind){case Te.Number:{const ae=hD(()=>F==="-"?-0:Number.parseFloat(F),0);Q={...Q,data:Number.isNaN(ae)?0:ae};break}case Te.Text:case Te.Markdown:case Te.Uri:Q={...Q,data:F};break}wf({target:C,content:Q,initialValue:F,cell:[U,K],highlight:F===void 0,forceEditMode:F!==void 0})}else Z.kind===Te.Boolean&&$&&Z.readonly!==!0&&(ei([{location:J.current.cell,value:{...Z,data:FE(Z.data)}}]),(Y=br.current)==null||Y.damage([{cell:J.current.cell}]))},[Fr,J,ei,wf]),Bw=v.useCallback((C,$)=>{var K;const F=(K=br.current)==null?void 0:K.getBounds(C,$);if(F===void 0||c.current===null)return;const U=Fr([C,$]);U.allowOverlay&&wf({target:F,content:U,initialValue:void 0,highlight:!0,cell:[C,$],forceEditMode:!0})},[Fr,wf]),bn=v.useCallback((C,$,F="both",U=0,K=0,Z=void 0)=>{if(c.current!==null){const Y=br.current,Q=l.current,ae=typeof C!="number"?C.unit==="cell"?C.amount:void 0:C,re=typeof $!="number"?$.unit==="cell"?$.amount:void 0:$,Ee=typeof C!="number"&&C.unit==="px"?C.amount:void 0,Ie=typeof $!="number"&&$.unit==="px"?$.amount:void 0;if(Y!==null&&Q!==null){let Se={x:0,y:0,width:0,height:0},Ve=0,qe=0;if((ae!==void 0||re!==void 0)&&(Se=Y.getBounds((ae??0)+X,re??0)??Se,Se.width===0||Se.height===0))return;const Mt=Q.getBoundingClientRect(),Ze=Mt.width/Q.offsetWidth;if(Ee!==void 0&&(Se={...Se,x:Ee-Mt.left-c.current.scrollLeft,width:1}),Ie!==void 0&&(Se={...Se,y:Ie+Mt.top-c.current.scrollTop,height:1}),Se!==void 0){const He={x:Se.x-U,y:Se.y-K,width:Se.width+2*U,height:Se.height+2*K};let Jt=0;for(let ag=0;ag0&&(Qn=Rl(Jn,kn,ar));let ki=Jt*Ze+Mt.left+X*bs*Ze,Ki=Mt.right,Si=Mt.top+ft*Ze,Xi=Mt.bottom-Qn*Ze;const Tf=Se.width+U*2;switch(Z==null?void 0:Z.hAlign){case"start":Ki=ki+Tf;break;case"end":ki=Ki-Tf;break;case"center":ki=Math.floor((ki+Ki)/2)-Tf/2,Ki=ki+Tf;break}const Ef=Se.height+K*2;switch(Z==null?void 0:Z.vAlign){case"start":Xi=Si+Ef;break;case"end":Si=Xi-Ef;break;case"center":Si=Math.floor((Si+Xi)/2)-Ef/2,Xi=Si+Ef;break}ki>He.x?Ve=He.x-ki:KiHe.y?qe=He.y-Si:Xi=Jn-kn)&&(qe=0),(Ve!==0||qe!==0)&&(Ze!==1&&(Ve/=Ze,qe/=Ze),c.current.scrollTo(Ve+c.current.scrollLeft,qe+c.current.scrollTop))}}}},[X,xt,bs,ft,Qe,Ft,Jn,Bo,ar]),jw=v.useRef(Bw),Hw=v.useRef(k),eg=v.useRef(w);jw.current=Bw,Hw.current=k,eg.current=w;const Bl=v.useCallback(async(C,$=!0)=>{var ae;const F=gt[C];if(((ae=F==null?void 0:F.trailingRowOptions)==null?void 0:ae.disabled)===!0)return;const U=Xe==null?void 0:Xe();let K,Z=!0;U!==void 0&&(K=await U,K==="top"&&(Z=!1),typeof K=="number"&&(Z=!1));let Y=0;const Q=()=>{if(eg.current<=w){Y<500&&window.setTimeout(Q,Y),Y=50+Y*2;return}const re=typeof K=="number"?K:Z?w:0;Cf.current(C-X,re),se({cell:[C,re],range:{x:C,y:re,width:1,height:1}},!1,!1,"edit");const Ee=Hw.current([C-X,re]);Ee.allowOverlay&&Bu(Ee)&&Ee.readonly!==!0&&$&&window.setTimeout(()=>{jw.current(C,re)},0)};Q()},[gt,Xe,X,w,se]),xf=v.useCallback(C=>{var F,U;const $=((U=(F=Ft[C])==null?void 0:F.trailingRowOptions)==null?void 0:U.targetColumn)??(ct==null?void 0:ct.targetColumn);if(typeof $=="number")return $+(Dr?1:0);if(typeof $=="object"){const K=y.indexOf($);if(K>=0)return K+(Dr?1:0)}},[Ft,y,Dr,ct==null?void 0:ct.targetColumn]),Ks=v.useRef(),jl=v.useRef(),cu=v.useCallback((C,$)=>{var K;const[F,U]=$;return To(de,(K=gt[F])==null?void 0:K.themeOverride,p==null?void 0:p(U),C.themeOverride)},[p,gt,de]),fu=v.useCallback(C=>{var Ee,Ie,Se;const $=Mh.value?C.metaKey:C.ctrlKey,F=$&&Je==="multi",U=$&&xe==="multi",[K,Z]=C.location,Y=J.columns,Q=J.rows,[ae,re]=((Ee=J.current)==null?void 0:Ee.cell)??[];if(C.kind==="cell"){if(jl.current=void 0,Wo.current=[K,Z],K===0&&Dr){if(on===!0&&Z===w||Qr==="number"||Je==="none")return;const Ve=Fr(C.location);if(Ve.kind!==oi.Marker)return;if(qn!==void 0){const Ze=Ae(Ve);Wr((Ze==null?void 0:Ze.kind)===oi.Marker);const He=(Ie=Ze==null?void 0:Ze.onClick)==null?void 0:Ie.call(Ze,{...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,theme:cu(Ve,C.location),preventDefault:()=>{}});if(He===void 0||He.checked===Ve.checked)return}s(void 0),ur();const qe=Q.hasIndex(Z),Mt=Ks.current;if(Je==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Mt!==void 0&&Q.hasIndex(Mt)){const Ze=[Math.min(Mt,Z),Math.max(Mt,Z)+1];F||Kt==="multi"?ke(void 0,Ze,!0):ke(Nt.fromSingleSelection(Ze),void 0,F)}else F||C.isTouch||Kt==="multi"?qe?ke(Q.remove(Z),void 0,!0):(ke(void 0,Z,!0),Ks.current=Z):qe&&Q.length===1?ke(Nt.empty(),void 0,$):(ke(Nt.fromSingleSelection(Z),void 0,$),Ks.current=Z)}else if(K>=X&&on&&Z===w){const Ve=xf(K);Bl(Ve??K)}else if(ae!==K||re!==Z){const Ve=Fr(C.location),qe=Ae(Ve);if((qe==null?void 0:qe.onSelect)!==void 0){let He=!1;if(qe.onSelect({...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,preventDefault:()=>He=!0,theme:cu(Ve,C.location)}),He)return}const Mt=Bo&&Z===w,Ze=Bo&&J!==void 0&&((Se=J.current)==null?void 0:Se.cell[1])===w;if((C.shiftKey||C.isLongTouch===!0)&&ae!==void 0&&re!==void 0&&J.current!==void 0&&!Ze){if(Mt)return;const He=Math.min(K,ae),Jt=Math.max(K,ae),Qn=Math.min(Z,re),kn=Math.max(Z,re);se({...J.current,range:{x:He,y:Qn,width:Jt-He+1,height:kn-Qn+1}},!0,$,"click"),Ks.current=void 0,ur()}else se({cell:[K,Z],range:{x:K,y:Z,width:1,height:1}},!0,$,"click"),Ks.current=void 0,s(void 0),ur()}}else if(C.kind==="header")if(Wo.current=[K,Z],s(void 0),Dr&&K===0)Ks.current=void 0,jl.current=void 0,Je==="multi"&&(Q.length!==w?ke(Nt.fromSingleSelection([0,w]),void 0,$):ke(Nt.empty(),void 0,$),ur());else{const Ve=jl.current;if(xe==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ve!==void 0&&Y.hasIndex(Ve)){const qe=[Math.min(Ve,K),Math.max(Ve,K)+1];U?ve(void 0,qe,$):ve(Nt.fromSingleSelection(qe),void 0,$)}else U?(Y.hasIndex(K)?ve(Y.remove(K),void 0,$):ve(void 0,K,$),jl.current=K):xe!=="none"&&(ve(Nt.fromSingleSelection(K),void 0,$),jl.current=K);Ks.current=void 0,ur()}else C.kind===Hr?Wo.current=[K,Z]:C.kind===Rh&&!C.isMaybeScrollbar&&(xr(Qf,!1),s(void 0),ur(),Rt==null||Rt(),Ks.current=void 0,jl.current=void 0)},[Bl,xe,ur,Ae,xf,Fr,J,Dr,Bo,Rt,qn,X,Qr,Je,Kt,w,se,xr,ve,ke,on,cu]),du=v.useRef(!1),Wo=v.useRef(),Ww=v.useRef(xn),ti=v.useRef(),bR=v.useCallback(C=>{if(Hl.current=!1,Ww.current=ln.current,C.button!==0&&C.button!==1){ti.current=void 0;return}const $=performance.now();ti.current={button:C.button,time:$,location:C.location},(C==null?void 0:C.kind)==="header"&&(du.current=!0);const F=C.kind==="cell"&&C.isFillHandle;!F&&C.kind!=="cell"&&C.isEdge||(u({previousSelection:J,fillHandle:F}),Wo.current=void 0,!C.isTouch&&C.button===0&&!F?fu(C):!C.isTouch&&C.button===1&&(Wo.current=C.location))},[J,fu]),[tg,ng]=v.useState(),Vw=v.useCallback(C=>{if(C.kind!==Hr||xe!=="multi")return;const $=Mh.value?C.metaKey:C.ctrlKey,[F]=C.location,U=J.columns;if(F=X&&Pc(K.group,gt[Q].group);Q--)Z--;for(let Q=F+1;Q{if(On!==void 0&&wi!==void 0){const $=ln.current.y,F=ln.current.height;let U=On({x:C,y:$,width:1,height:Math.min(F,w-$)},Yn.current.signal);typeof U!="object"&&(U=await U());const K=Ft[C-X],Y=document.createElement("canvas").getContext("2d",{alpha:!1});if(Y!==null){Y.font=de.baseFontFull;const Q=uE(Y,de,K,0,U,Nr,yi,!1,Ae);wi==null||wi(K,Q.width,C,Q.width)}}},[Ft,On,yi,de,Nr,wi,X,w,Ae]),[kR,rg]=v.useState(),Wl=v.useCallback(async(C,$)=>{var Q,ae;const F=(Q=C.current)==null?void 0:Q.range;if(F===void 0||On===void 0||$.current===void 0)return;const U=$.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-X},patternSource:{...F,x:F.x-X},preventDefault:()=>re=!0}),re)return}let K=On(F,Yn.current.signal);typeof K!="object"&&(K=await K());const Z=K,Y=[];for(let re=0;re({cell:re.location})))},[On,ei,T,X]),Uw=v.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,width:1}}};Wl(C,J)},[Wl,J]),Kw=v.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,height:1}}};Wl(C,J)},[Wl,J]),SR=v.useCallback((C,$)=>{var Ee,Ie;const F=a;if(u(void 0),Qp(void 0),rg(void 0),du.current=!1,$)return;if((F==null?void 0:F.fillHandle)===!0&&J.current!==void 0&&((Ee=F.previousSelection)==null?void 0:Ee.current)!==void 0){if(Ho===void 0)return;const Se={...J,current:{...J.current,range:wE(F.previousSelection.current.range,Ho)}};Wl(F.previousSelection,Se),xr(Se,!0);return}const[U,K]=C.location,[Z,Y]=Wo.current??[],Q=()=>{Hl.current=!0},ae=Se=>{var qe,Mt,Ze;const Ve=Se.isTouch||Z===U&&Y===K;if(Ve&&(b==null||b([U-X,K],{...Se,preventDefault:Q})),Se.button===1)return!Hl.current;if(!Hl.current){const He=Fr(C.location),Jt=Ae(He);if(Jt!==void 0&&Jt.onClick!==void 0&&Ve){const kn=Jt.onClick({...Se,cell:He,posX:Se.localEventX,posY:Se.localEventY,bounds:Se.bounds,theme:cu(He,C.location),preventDefault:Q});kn!==void 0&&!ca(kn)&&ql(kn)&&(ei([{location:Se.location,value:kn}]),(qe=br.current)==null||qe.damage([{cell:Se.location}]))}if(Hl.current||J.current===void 0)return!1;let Qn=!1;switch(He.activationBehaviorOverride??tt){case"double-click":case"second-click":{if(((Ze=(Mt=F==null?void 0:F.previousSelection)==null?void 0:Mt.current)==null?void 0:Ze.cell)===void 0)break;const[kn,ki]=J.current.cell,[Ki,Si]=F.previousSelection.current.cell;Qn=U===kn&&U===Ki&&K===ki&&K===Si&&(Se.isDoubleClick===!0||tt==="second-click");break}case"single-click":{Qn=!0;break}}if(Qn)return S==null||S([U-X,K]),zl(Se.bounds,!1),!0}return!1},re=C.location[0]-X;if(C.isTouch){const Se=ln.current,Ve=Ww.current;if(Se.x!==Ve.x||Se.y!==Ve.y)return;if(C.isLongTouch===!0){if(C.kind==="cell"&&nc((Ie=J.current)==null?void 0:Ie.cell,C.location)){te==null||te([re,C.location[1]],{...C,preventDefault:Q});return}else if(C.kind==="header"&&J.columns.hasIndex(U)){V==null||V(re,{...C,preventDefault:Q});return}else if(C.kind===Hr){if(re<0)return;N==null||N(re,{...C,preventDefault:Q});return}}C.kind==="cell"?ae(C)||fu(C):C.kind===Hr?ie==null||ie(re,{...C,preventDefault:Q}):(C.kind===no&&(I==null||I(re,{...C,preventDefault:Q})),fu(C));return}if(C.kind==="header"){if(re<0)return;C.isEdge?C.isDoubleClick===!0&&bf(U):C.button===0&&U===Z&&K===Y&&(I==null||I(re,{...C,preventDefault:Q}))}if(C.kind===Hr){if(re<0)return;C.button===0&&U===Z&&K===Y&&(ie==null||ie(re,{...C,preventDefault:Q}),Hl.current||Vw(C))}C.kind==="cell"&&(C.button===0||C.button===1)&&ae(C),Wo.current=void 0},[a,J,X,Ho,Wl,xr,b,Fr,Ae,tt,cu,ei,S,zl,te,V,N,fu,ie,I,bf,Vw]),CR=v.useCallback(C=>{const $={...C,location:[C.location[0]-X,C.location[1]]};rt==null||rt($),a!==void 0&&C.buttons===0&&(u(void 0),Qp(void 0),rg(void 0),du.current=!1),rg(F=>{var U;return du.current?[C.scrollEdge[0],0]:C.scrollEdge[0]===(F==null?void 0:F[0])&&C.scrollEdge[1]===F[1]?F:a===void 0||(((U=ti.current)==null?void 0:U.location[0])??0){dt==null||dt(C-X,$)},[dt,X]),Ui=(Zw=J==null?void 0:J.current)==null?void 0:Zw.cell,ER=v.useCallback((C,$,F,U,K,Z)=>{It.current=!1;let Y=Ui;Y!==void 0&&(Y=[Y[0]-X,Y[1]]);const Q=Qe===0?void 0:{x:0,y:C.y,width:Qe,height:C.height},ae=[];Q!==void 0&&ae.push(Q),xt>0&&(ae.push({x:C.x-X,y:w-xt,width:C.width,height:xt}),Qe>0&&ae.push({x:0,y:w-xt,width:Qe,height:xt}));const re={x:C.x-X,y:C.y,width:C.width,height:on&&C.y+C.height>=w?C.height-1:C.height,tx:K,ty:Z,extras:{selected:Y,freezeRegion:Q,freezeRegions:ae}};ln.current=re,Lr(re),st([$,F,U]),Hn==null||Hn(re,re.tx,re.ty,re.extras)},[Ui,X,on,w,Qe,xt,Lr,Hn]),AR=Ul(Ge,v.useCallback((C,$)=>{Ge==null||Ge(C-X,$-X),xe!=="none"&&ve(Nt.fromSingleSelection($),void 0,!0)},[xe,Ge,X,ve])),ig=v.useRef(!1),MR=v.useCallback(C=>{if(C.location[0]===0&&X>0){C.preventDefault();return}wt==null||wt({...C,location:[C.location[0]-X,C.location[1]]}),C.defaultPrevented()||(ig.current=!0),u(void 0)},[wt,X]),RR=v.useCallback(()=>{ig.current=!1},[]),sg=v.useRef(),og=v.useCallback(C=>{var $,F,U;if(!_E(C,sg.current)&&(sg.current=C,!((($=ti==null?void 0:ti.current)==null?void 0:$.button)!==void 0&&ti.current.button>=1))){if(C.buttons!==0&&a!==void 0&&((F=ti.current)==null?void 0:F.location[0])===0&&C.location[0]===0&&X===1&&Je==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ti.current.location[1])&&J.rows.hasIndex(ti.current.location[1])){const K=Math.min(ti.current.location[1],C.location[1]),Z=Math.max(ti.current.location[1],C.location[1])+1;ke(Nt.fromSingleSelection([K,Z]),void 0,!1)}if(C.buttons!==0&&a!==void 0&&J.current!==void 0&&!ig.current&&!du.current&&(Pe==="rect"||Pe==="multi-rect")){const[K,Z]=J.current.cell;let[Y,Q]=C.location;if(Q<0&&(Q=ln.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const ae=a.previousSelection.current.range;Q=Math.min(Q,on?w-1:w);const re=p5(ae,Y,Q,dn);Qp(re)}else{if(on&&Z===w)return;if(on&&Q===w)if(C.kind===Rh)Q--;else return;Y=Math.max(Y,X);const Ee=Y-K,Ie=Q-Z,Se={x:Ee>=0?K:Y,y:Ie>=0?Z:Q,width:Math.abs(Ee)+1,height:Math.abs(Ie)+1};se({...J.current,range:Se},!0,!1,"drag")}}Lt==null||Lt({...C,location:[C.location[0]-X,C.location[1]]})}},[dn,a,X,Je,J,Pe,Lt,ke,on,w,se]),OR=v.useCallback(()=>{var Y,Q;const C=sg.current;if(C===void 0)return;const[$,F]=C.scrollEdge;let[U,K]=C.location;const Z=ln.current;$===-1?U=((Q=(Y=Z.extras)==null?void 0:Y.freezeRegion)==null?void 0:Q.x)??Z.x:$===1&&(U=Z.x+Z.width),F===-1?K=Math.max(0,Z.y):F===1&&(K=Math.min(w-1,Z.y+Z.height)),U=Oi(U,0,gt.length-1),K=Oi(K,0,w-1),og({...C,location:[U,K]})},[gt.length,og,w]);k6(kR,c,OR);const bi=v.useCallback(C=>{if(J.current===void 0)return;const[$,F]=C,[U,K]=J.current.cell,Z=J.current.range;let Y=Z.x,Q=Z.x+Z.width,ae=Z.y,re=Z.y+Z.height;if(F!==0)switch(F){case 2:{re=w,ae=K,bn(0,re,"vertical");break}case-2:{ae=0,re=K+1,bn(0,ae,"vertical");break}case 1:{aeK+1?(re--,bn(0,re,"vertical")):(ae=Math.max(0,ae-1),bn(0,ae,"vertical"));break}default:Oc()}if($!==0)if($===2)Q=gt.length,Y=U,bn(Q-1-X,0,"horizontal");else if($===-2)Y=X,Q=U+1,bn(Y-X,0,"horizontal");else{let Ee=[];if(On!==void 0){const Ie=On({x:Y,y:ae,width:Q-Y-X,height:re-ae},Yn.current.signal);typeof Ie=="object"&&(Ee=A6(Ie))}if($===1){let Ie=!1;if(Y0){const Se=nl(Y+1,U+1).find(Ve=>!Ee.includes(Ve-X));Se!==void 0&&(Y=Se,Ie=!0)}else Y++,Ie=!0;Ie&&bn(Y,0,"horizontal")}Ie||(Q=Math.min(gt.length,Q+1),bn(Q-1-X,0,"horizontal"))}else if($===-1){let Ie=!1;if(Q>U+1){if(Ee.length>0){const Se=nl(Q-1,U,-1).find(Ve=>!Ee.includes(Ve-X));Se!==void 0&&(Q=Se,Ie=!0)}else Q--,Ie=!0;Ie&&bn(Q-X,0,"horizontal")}Ie||(Y=Math.max(X,Y-1),bn(Y-X,0,"horizontal"))}else Oc()}se({cell:J.current.cell,range:{x:Y,y:ae,width:Q-Y,height:re-ae}},!0,!1,"keyboard-select")},[On,J,gt.length,X,w,bn,se]),Xs=v.useCallback((C,$,F,U)=>{const K=Jn-(F?0:1);if(C=Oi(C,X,Ft.length-1+X),$=Oi($,0,K),C===(Ui==null?void 0:Ui[0])&&$===(Ui==null?void 0:Ui[1]))return!1;if(U&&J.current!==void 0){const Z=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&Z.push(J.current.range),xr({...J,current:{cell:[C,$],range:{x:C,y:$,width:1,height:1},rangeStack:Z}},!0)}else se({cell:[C,$],range:{x:C,y:$,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===C&&f.current[1]===$&&(f.current=void 0),bn(C-X,$),!0},[Jn,X,Ft.length,Ui,J,bn,xr,se]),PR=v.useCallback((C,$)=>{(i==null?void 0:i.cell)!==void 0&&C!==void 0&&ql(C)&&(ei([{location:i.cell,value:C}]),window.requestAnimationFrame(()=>{var K;(K=br.current)==null||K.damage([{cell:i.cell}])})),ur(!0),s(void 0);const[F,U]=$;if(J.current!==void 0&&(F!==0||U!==0)){const K=J.current.cell[1]===Jn-1&&C!==void 0;Xs(Oi(J.current.cell[0]+F,0,gt.length-1),Oi(J.current.cell[1]+U,0,Jn-1),K,!1)}A==null||A(C,$)},[i==null?void 0:i.cell,ur,J,A,ei,Jn,Xs,gt.length]),IR=v.useMemo(()=>`gdg-overlay-${E6++}`,[]),Vo=v.useCallback(C=>{var F,U,K,Z;ur();const $=[];for(let Y=C.x;Y({cell:Y.location})))},[ur,k,Ae,ei,X]),hu=i!==void 0,Xw=v.useCallback(C=>{var Ve,qe;const $=()=>{C.stopPropagation(),C.preventDefault()},F={didMatch:!1},{bounds:U}=C,K=J.columns,Z=J.rows,Y=vi;if(!hu&&yt(Y.clear,C,F))xr(Qf,!1),Rt==null||Rt();else if(!hu&&yt(Y.selectAll,C,F))xr({columns:Nt.empty(),rows:Nt.empty(),current:{cell:((Ve=J.current)==null?void 0:Ve.cell)??[X,0],range:{x:X,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(yt(Y.search,C,F))(qe=o==null?void 0:o.current)==null||qe.focus({preventScroll:!0}),pf(!0);else if(yt(Y.delete,C,F)){const Mt=(j==null?void 0:j(J))??!0;if(Mt!==!1){const Ze=Mt===!0?J:Mt;if(Ze.current!==void 0){Vo(Ze.current.range);for(const He of Ze.current.rangeStack)Vo(He)}for(const He of Ze.rows)Vo({x:X,y:He,width:y.length,height:1});for(const He of Ze.columns)Vo({x:He,y:0,width:1,height:w})}}if(F.didMatch)return $(),!0;if(J.current===void 0)return!1;let[Q,ae]=J.current.cell,re=!1,Ee=!1;yt(Y.scrollToSelectedCell,C,F)?Cf.current(Q-X,ae):xe!=="none"&&yt(Y.selectColumn,C,F)?K.hasIndex(Q)?ve(K.remove(Q),void 0,!0):xe==="single"?ve(Nt.fromSingleSelection(Q),void 0,!0):ve(void 0,Q,!0):Je!=="none"&&yt(Y.selectRow,C,F)?Z.hasIndex(ae)?ke(Z.remove(ae),void 0,!0):Je==="single"?ke(Nt.fromSingleSelection(ae),void 0,!0):ke(void 0,ae,!0):!hu&&U!==void 0&&yt(Y.activateCell,C,F)?ae===w&&on?window.setTimeout(()=>{const Mt=xf(Q);Bl(Mt??Q)},0):(S==null||S([Q-X,ae]),zl(U,!0)):J.current.range.height>1&&yt(Y.downFill,C,F)?Kw():J.current.range.width>1&&yt(Y.rightFill,C,F)?Uw():yt(Y.goToNextPage,C,F)?ae+=Math.max(1,ln.current.height-4):yt(Y.goToPreviousPage,C,F)?ae-=Math.max(1,ln.current.height-4):yt(Y.goToFirstCell,C,F)?(s(void 0),ae=0,Q=0):yt(Y.goToLastCell,C,F)?(s(void 0),ae=Number.MAX_SAFE_INTEGER,Q=Number.MAX_SAFE_INTEGER):yt(Y.selectToFirstCell,C,F)?(s(void 0),bi([-2,-2])):yt(Y.selectToLastCell,C,F)?(s(void 0),bi([2,2])):hu?(yt(Y.closeOverlay,C,F)&&s(void 0),yt(Y.acceptOverlayDown,C,F)&&(s(void 0),ae++),yt(Y.acceptOverlayUp,C,F)&&(s(void 0),ae--),yt(Y.acceptOverlayLeft,C,F)&&(s(void 0),Q--),yt(Y.acceptOverlayRight,C,F)&&(s(void 0),Q++)):(yt(Y.goDownCell,C,F)?ae+=1:yt(Y.goUpCell,C,F)?ae-=1:yt(Y.goRightCell,C,F)?Q+=1:yt(Y.goLeftCell,C,F)?Q-=1:yt(Y.goDownCellRetainSelection,C,F)?(ae+=1,re=!0):yt(Y.goUpCellRetainSelection,C,F)?(ae-=1,re=!0):yt(Y.goRightCellRetainSelection,C,F)?(Q+=1,re=!0):yt(Y.goLeftCellRetainSelection,C,F)?(Q-=1,re=!0):yt(Y.goToLastRow,C,F)?ae=w-1:yt(Y.goToFirstRow,C,F)?ae=Number.MIN_SAFE_INTEGER:yt(Y.goToLastColumn,C,F)?Q=Number.MAX_SAFE_INTEGER:yt(Y.goToFirstColumn,C,F)?Q=Number.MIN_SAFE_INTEGER:(Pe==="rect"||Pe==="multi-rect")&&(yt(Y.selectGrowDown,C,F)?bi([0,1]):yt(Y.selectGrowUp,C,F)?bi([0,-1]):yt(Y.selectGrowRight,C,F)?bi([1,0]):yt(Y.selectGrowLeft,C,F)?bi([-1,0]):yt(Y.selectToLastRow,C,F)?bi([0,2]):yt(Y.selectToFirstRow,C,F)?bi([0,-2]):yt(Y.selectToLastColumn,C,F)?bi([2,0]):yt(Y.selectToFirstColumn,C,F)&&bi([-2,0])),Ee=F.didMatch);const Ie=Xs(Q,ae,!1,re),Se=F.didMatch;return Se&&(Ie||!Ee||af)&&$(),Se},[hu,J,vi,xe,Je,Pe,X,w,Xs,xr,Rt,y.length,j,af,Vo,ve,ke,on,xf,Bl,S,zl,Kw,Uw,bi]),pu=v.useCallback(C=>{let $=!1;if(oe!==void 0&&oe({...C,cancel:()=>{$=!0}}),$||Xw(C)||J.current===void 0)return;const[F,U]=J.current.cell,K=ln.current;if(lt&&!C.metaKey&&!C.ctrlKey&&J.current!==void 0&&C.key.length===1&&/[ -~]/g.test(C.key)&&C.bounds!==void 0&&Bu(k([F-X,Math.max(0,Math.min(U,w-1))]))){if((!on||U!==w)&&(K.y>U||U>K.y+K.height||K.x>F||F>K.x+K.width))return;zl(C.bounds,!0,C.key),C.stopPropagation(),C.preventDefault()}},[lt,oe,Xw,J,k,X,w,on,zl]),NR=v.useCallback((C,$)=>{const F=C.location[0]-X;if(C.kind==="header"&&(V==null||V(F,{...C,preventDefault:$})),C.kind===Hr){if(F<0)return;N==null||N(F,{...C,preventDefault:$})}if(C.kind==="cell"){const[U,K]=C.location;te==null||te([F,K],{...C,preventDefault:$}),c4(J,C.location)||Xs(U,K,!1,!1)}},[J,te,N,V,X,Xs]),lg=v.useCallback(async C=>{var Y,Q,ae;if(!vi.paste)return;function $(re,Ee,Ie,Se){var qe,Mt;const Ve=typeof Ie=="object"?(Ie==null?void 0:Ie.join(` +`))??"":(Ie==null?void 0:Ie.toString())??"";if(!ca(re)&&Bu(re)&&re.readonly!==!0){const Ze=M==null?void 0:M(Ve,re);if(Ze!==void 0&&ql(Ze))return{location:Ee,value:Ze};const He=Ae(re);if(He===void 0)return;if(He.kind===Te.Custom){Wr(re.kind===Te.Custom);const Jt=(qe=He.onPaste)==null?void 0:qe.call(He,Ve,re.data);return Jt===void 0?void 0:{location:Ee,value:{...re,data:Jt}}}else{const Jt=(Mt=He.onPaste)==null?void 0:Mt.call(He,Ve,re,{formatted:Se,formattedString:typeof Se=="string"?Se:Se==null?void 0:Se.join(` +`),rawValue:Ie});return Jt===void 0?void 0:(Wr(Jt.kind===re.kind),{location:Ee,value:Jt})}}}const F=J.columns,U=J.rows,K=((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0;let Z;if(J.current!==void 0?Z=[J.current.range.x,J.current.range.y]:F.length===1?Z=[F.first()??0,0]:U.length===1&&(Z=[X,U.first()??0]),K&&Z!==void 0){let re,Ee;const Ie="text/plain",Se="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const He of Ze){if(He.types.includes(Se)){const Qn=await(await He.getType(Se)).text(),kn=Fb(Qn);if(kn!==void 0){re=kn;break}}He.types.includes(Ie)&&(Ee=await(await He.getType(Ie)).text())}}else if(navigator.clipboard.readText!==void 0)Ee=await navigator.clipboard.readText();else if(C!==void 0&&(C==null?void 0:C.clipboardData)!==null){if(C.clipboardData.types.includes(Se)){const Ze=C.clipboardData.getData(Se);re=Fb(Ze)}re===void 0&&C.clipboardData.types.includes(Ie)&&(Ee=C.clipboardData.getData(Ie))}else return;const[Ve,qe]=Z,Mt=[];do{if(ge===void 0){const Ze=Fr(Z),He=Ee??(re==null?void 0:re.map(Qn=>Qn.map(kn=>kn.rawValue).join(" ")).join(" "))??"",Jt=$(Ze,Z,He,void 0);Jt!==void 0&&Mt.push(Jt);break}if(re===void 0){if(Ee===void 0)return;re=g6(Ee)}if(ge===!1||typeof ge=="function"&&(ge==null?void 0:ge([Z[0]-X,Z[1]],re.map(Ze=>Ze.map(He=>{var Jt;return((Jt=He.rawValue)==null?void 0:Jt.toString())??""}))))!==!0)return;for(const[Ze,He]of re.entries()){if(Ze+qe>=w)break;for(const[Jt,Qn]of He.entries()){const kn=[Jt+Ve,Ze+qe],[ki,Ki]=kn;if(ki>=gt.length||Ki>=Jn)continue;const Si=Fr(kn),Xi=$(Si,kn,Qn.rawValue,Qn.formatted);Xi!==void 0&&Mt.push(Xi)}}}while(!1);ei(Mt),(ae=br.current)==null||ae.damage(Mt.map(Ze=>({cell:Ze.location})))}},[M,Ae,Fr,J,vi.paste,gt.length,ei,Jn,ge,X,w]);Vn("paste",lg,d,!1,!0);const gu=v.useCallback(async(C,$)=>{var Y,Q;if(!vi.copy)return;const F=$===!0||((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0,U=J.columns,K=J.rows,Z=(ae,re)=>{if(!_e)zb(ae,re,C);else{const Ee=re.map(Ie=>({kind:Te.Text,data:y[Ie].title,displayData:y[Ie].title,allowOverlay:!1}));zb([Ee,...ae],re,C)}};if(F&&On!==void 0){if(J.current!==void 0){let ae=On(J.current.range,Yn.current.signal);typeof ae!="object"&&(ae=await ae()),Z(ae,nl(J.current.range.x-X,J.current.range.x+J.current.range.width-X))}else if(K!==void 0&&K.length>0){const re=[...K].map(Ee=>{const Ie=On({x:X,y:Ee,width:y.length,height:1},Yn.current.signal);return typeof Ie=="object"?Ie[0]:Ie().then(Se=>Se[0])});if(re.some(Ee=>Ee instanceof Promise)){const Ee=await Promise.all(re);Z(Ee,nl(y.length))}else Z(re,nl(y.length))}else if(U.length>0){const ae=[],re=[];for(const Ee of U){let Ie=On({x:Ee,y:0,width:1,height:w},Yn.current.signal);typeof Ie!="object"&&(Ie=await Ie()),ae.push(Ie),re.push(Ee-X)}if(ae.length===1)Z(ae[0],re);else{const Ee=ae.reduce((Ie,Se)=>Ie.map((Ve,qe)=>[...Ve,...Se[qe]]));Z(Ee,re)}}}},[y,On,J,vi.copy,X,w,_e]);Vn("copy",gu,d,!1,!1);const DR=v.useCallback(async C=>{var F,U;if(!(!vi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await gu(C),J.current!==void 0)){let K={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:Nt.empty(),columns:Nt.empty()};const Z=j==null?void 0:j(K);if(Z===!1||(K=Z===!0?K:Z,K.current===void 0))return;Vo(K.current.range)}},[Vo,J,vi.cut,gu,j]);Vn("cut",DR,d,!1,!1);const _R=v.useCallback((C,$)=>{if(B!==void 0){X!==0&&(C=C.map(K=>[K[0]-X,K[1]])),B(C,$);return}if(C.length===0||$===-1)return;const[F,U]=C[$];f.current!==void 0&&f.current[0]===F&&f.current[1]===U||(f.current=[F,U],Xs(F,U,!1,!1))},[B,X,Xs]),[kf,Sf]=((e1=Pt==null?void 0:Pt.current)==null?void 0:e1.cell)??[],Cf=v.useRef(bn);Cf.current=bn,v.useLayoutEffect(()=>{var C,$,F,U;!It.current&&kf!==void 0&&Sf!==void 0&&(kf!==(($=(C=Us.current)==null?void 0:C.current)==null?void 0:$.cell[0])||Sf!==((U=(F=Us.current)==null?void 0:F.current)==null?void 0:U.cell[1]))&&Cf.current(kf,Sf),It.current=!1},[kf,Sf]);const Gw=J.current!==void 0&&(J.current.cell[0]>=gt.length||J.current.cell[1]>=Jn);v.useLayoutEffect(()=>{Gw&&xr(Qf,!1)},[Gw,xr]);const LR=v.useMemo(()=>on===!0&&(ct==null?void 0:ct.tint)===!0?Nt.fromSingleSelection(Jn-1):Nt.empty(),[Jn,on,ct==null?void 0:ct.tint]),FR=v.useCallback(C=>typeof ze=="boolean"?ze:(ze==null?void 0:ze(C-X))??!0,[X,ze]),$R=v.useMemo(()=>{if(tg===void 0||l.current===null)return null;const{bounds:C,group:$}=tg,F=l.current.getBoundingClientRect();return v.createElement(i6,{bounds:C,group:$,canvasBounds:F,onClose:()=>ng(void 0),onFinish:U=>{ng(void 0),L==null||L($,U)}})},[L,tg]),zR=Math.min(gt.length,Qe+(Dr?1:0));v.useImperativeHandle(e,()=>({appendRow:(C,$)=>Bl(C+X,$),updateCells:C=>{var $;return X!==0&&(C=C.map(F=>({cell:[F.cell[0]+X,F.cell[1]]}))),($=br.current)==null?void 0:$.damage(C)},getBounds:(C,$)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(C===void 0&&$===void 0){const U=l.current.getBoundingClientRect(),K=U.width/c.current.clientWidth;return{x:U.x-c.current.scrollLeft*K,y:U.y-c.current.scrollTop*K,width:c.current.scrollWidth*K,height:c.current.scrollHeight*K}}return(F=br.current)==null?void 0:F.getBounds((C??0)+X,$)}},focus:()=>{var C;return(C=br.current)==null?void 0:C.focus()},emit:async C=>{switch(C){case"delete":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await gu(void 0,!0);break;case"paste":await lg();break}},scrollTo:bn,remeasureColumns:C=>{for(const $ of C)bf($+X)}}),[Bl,bf,gu,pu,lg,X,bn]);const[qw,Yw]=Ui??[],BR=v.useCallback(C=>{const[$,F]=C;if(F===-1){xe!=="none"&&(ve(Nt.fromSingleSelection($),void 0,!1),ur());return}qw===$&&Yw===F||(se({cell:C,range:{x:$,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),bn($,F))},[xe,ur,bn,qw,Yw,se,ve]),[jR,HR]=v.useState(!1),Jw=v.useRef(BT(C=>{HR(C)},5)),WR=v.useCallback(()=>{Jw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&se({cell:[X,gf],range:{x:X,y:gf,width:1,height:1}},!0,!1,"keyboard-select")},[gf,J,a,X,se]),VR=v.useCallback(()=>{Jw.current(!1)},[]),[UR,KR]=v.useMemo(()=>{let C;const $=(We==null?void 0:We.scrollbarWidthOverride)??I0(),F=w+(on?1:0);if(typeof ar=="number")C=ft+F*ar;else{let K=0;const Z=Math.min(F,10);for(let Y=0;YZ.width+K,0)+$;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,C)}px`]},[gt,We==null?void 0:We.scrollbarWidthOverride,ar,w,on,ft]),XR=v.useMemo(()=>T4(de),[de]);return v.createElement(E4.Provider,{value:de},v.createElement(w6,{style:XR,className:W,inWidth:x??UR,inHeight:g??KR},v.createElement(e6,{fillHandle:Fe,drawFocusRing:Re,experimental:We,fixedShadowX:ut,fixedShadowY:Ot,getRowThemeOverride:p,headerIcons:Xt,imageWindowLoader:Nn,initialSize:wr,isDraggable:Mn,onDragLeave:ys,onRowMoved:qn,overscrollX:Kp,overscrollY:hf,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:Hs,smoothScrollX:uf,smoothScrollY:Hp,className:W,enableGroups:zt,onCanvasFocused:WR,onCanvasBlur:VR,canvasRef:l,onContextMenu:NR,theme:de,cellXOffset:jo,cellYOffset:gf,accessibilityHeight:xn.height,onDragEnd:RR,columns:gt,nonGrowWidth:Be,drawHeader:Yp,onColumnProposeMove:D,drawCell:Jp,disabledRows:LR,freezeColumns:zR,lockColumns:X,firstColAccessible:X===0,getCellContent:Fr,minColumnWidth:Nr,maxColumnWidth:yi,searchInputRef:o,showSearch:au,onSearchClose:Gp,highlightRegions:xR,getCellsForSelection:On,getGroupDetails:Zp,headerHeight:Dl,isFocused:jR,groupHeaderHeight:zt?lu:0,freezeTrailingRows:xt+(on&&(ct==null?void 0:ct.sticky)===!0?1:0),hasAppendRow:on,onColumnResize:wi,onColumnResizeEnd:qp,onColumnResizeStart:Ll,onCellFocused:BR,onColumnMoved:AR,onDragStart:MR,onHeaderMenuClick:TR,onItemHovered:og,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:CR,onKeyDown:pu,onKeyUp:be,onMouseDown:bR,onMouseUp:SR,onDragOverCell:An,onDrop:z,onSearchResultsChanged:_R,onVisibleRegionChanged:ER,clientSize:Oe,rowHeight:ar,searchResults:le,searchValue:ye,onSearchValueChange:me,rows:Jn,scrollRef:c,selection:J,translateX:xn.tx,translateY:xn.ty,verticalBorder:FR,gridRef:br,getCellRenderer:Ae}),$R,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(T6,{...i,validateCell:uu,bloom:P,id:IR,getCellRenderer:Ae,className:(We==null?void 0:We.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Bt,imageEditorOverride:h,onFinishEditing:PR,markdownDivCreateNode:m,isOutsideClick:cf}))))},R6=v.forwardRef(M6),Hb=20,O6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Te.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>P6(t,t.cell.data,A0(t.cell),t.cell.maxSize??Hb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Hb,f=Math.floor(i.y+l/2),d=WT(c,l,s.cellVerticalPadding),h=HT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=jT(h,f,d),m=VT(a+n,u+r,p);if(A0(e)&&m)return{...e,data:FE(e.data)}},onPaste:(t,e)=>{let n=mh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Vv),n===e.data?void 0:{...e,data:n}}};function P6(t,e,n,r){if(!n&&e===mh)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:m}=l,x=.35;let g=n?1-x+x*s:.4;e===mh&&(g*=s),g!==0&&(i.globalAlpha=g,iw(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const I6=Jr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),N6=t=>{const{bubbles:e}=t;return v.createElement(I6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},D6={getAccessibilityString:t=>UT(t.data),kind:Te.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>L6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(N6,{bubbles:e.data})},onPaste:()=>{}},_6=4;function L6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=_6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=ef(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)fs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+js(i,r))}const F6=Jr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),$6=t=>{const{drilldowns:e}=t;return v.createElement(F6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&v.createElement("img",{src:n.img}),v.createElement("div",null,n.text))))},z6={getAccessibilityString:t=>UT(t.data.map(e=>e.text)),kind:Te.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>H6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement($6,{drilldowns:e.data})},onPaste:()=>{}},B6=4,tm={};function j6(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(tm[d]!==void 0)return{el:tm[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),tm[d]=h,p.beginPath(),fs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),fs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function H6(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=iE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,m=8,x=B6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=j6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=ef(b.text,i,c).width;let A=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+m*2;k.push({x:g,width:M}),g+=M+x}if(w!==null){const{el:b,height:S,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:_}=w,P=A/O,I=_/O;for(const D of k){const ee=Math.floor(D.x),ie=Math.floor(D.width),te=ie-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,A,S,ee-I,h,P,d),te>0&&i.drawImage(b,A,0,T,S,ee+(P-I),h,te,d),i.drawImage(b,M-A,0,A,S,ee+ie-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,S]of k.entries()){const T=e[b];let A=S.x+m;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const O=p-8;let _=0,P=0,I=M.width,D=M.height;I>D?(_+=(I-D)/2,I=D):D>I&&(P+=(D-I)/2,D=I),i.beginPath(),fs(i,A,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,_,P,I,D,A,h+d/2-O/2,O,O),i.restore(),A+=O+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+js(i,r))}}const W6={getAccessibilityString:t=>t.data.join(", "),kind:Te.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>V6(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??D$;return v.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},nm=4;function V6(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,m=[];let x=0;for(let y=0;y0&&(a.beginPath(),fs(a,g,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(y,g,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),g+=w+nm}}function U6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const K6={getAccessibilityString:()=>"",kind:Te.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(U6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);fs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=wl(o.textDark,.1),i.fill()},onPaste:()=>{}},X6=()=>t=>t.targetWidth,Wb=Jr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[X6(),"px"]}}),G6=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=v.useState(a===""||r),d=v.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?v.createElement(Wb,{targetWidth:s.width-20},v.createElement(Tp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),v.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},v.createElement(A$,null))):v.createElement(Wb,{targetWidth:s.width},v.createElement(Z$,{contents:a,createNode:i}),!u&&v.createElement(v.Fragment,null,v.createElement("div",{className:"spacer"}),v.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},v.createElement(qv,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},q6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:tf,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>Ms(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return v.createElement(G6,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},Y6={getAccessibilityString:t=>t.row.toString(),kind:oi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:J6,measure:()=>44,draw:t=>Z6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function J6(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=Q6,n.textAlign="center",s}function Q6(t){const{ctx:e}=t;e.textAlign="start"}function Z6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(iw(o,u,n,i?c+m:c,f,i?d-m:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const g of[-5,-1,3])o.rect(c+x,f+h/2+g,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,g=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,g,f+h/2+js(o,x)),a!==0&&(o.globalAlpha=1)}}const e9={getAccessibilityString:()=>"",kind:oi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>t9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function t9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const m=f-8,x=a+8/2,g=u+8/2;l.drawSprite(n,"normal",r,x,g,m,o,d?1:s),h=m}else{h=24;const p=12,m=d?p:s*p,x=d?0:(1-s)*p*.5,g=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+g+x,u+f/2),r.lineTo(a+g+x+m,u+f/2),r.moveTo(a+g+x+m*.5,u+f/2-m*.5),r.lineTo(a+g+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+js(r,o)),r.beginPath()}const n9=v.lazy(async()=>await cE(()=>import("./number-overlay-editor-cI9rZOV7.js"),[])),r9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:tf,draw:t=>Ms(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return v.createElement(v.Suspense,{fallback:null},v.createElement(n9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},i9={getAccessibilityString:()=>"",measure:()=>108,kind:Te.Protected,needsHover:!1,needsHoverPosition:!1,draw:s9,onPaste:()=>{}};function s9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Vx(30))*l,f=Math.sin(Vx(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const o9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>tf(t,e,t.theme.textLight),draw:t=>Ms(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Ln.createElement(Tp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},l9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:tf,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=ef(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),fs(i,s.x+d/2,s.y+(s.height-x)/2+1,p.width+d*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=wl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}Ms(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` +`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return v.createElement(Tp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},a9=Jr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),u9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=v.useState(!i&&(e===""||r)),u=v.useCallback(()=>{a(!0)},[]);return l?v.createElement(Tp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(a9,null,v.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&v.createElement("div",{className:"gdg-edit-icon",onClick:u},v.createElement(qv,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Vb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const c9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:tf,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=ef(a,l,n.baseFontFull),f=Vb(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:m}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+m+8){const x=js(l,n.baseFontFull);r("pointer");const g=5,y=h-x;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+y+m+g)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+y+m+g)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,Ms({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,Ms(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=y4(o,s.baseFontFull);if(l===void 0)return;const a=Vb(l,n,s,e.contentAlign);Ap({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return v.createElement(u9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},f9=[Y6,e9,O6,D6,z6,W6,K6,q6,r9,i9,o9,l9,c9];var d9=zT,h9=El,p9="Expected a function";function g9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(p9);return h9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),d9(t,e,{leading:r,maxWait:e,trailing:i})}var m9=g9;const y9=ji(m9),rm=[];class v9 extends oE{constructor(){super(...arguments);bt(this,"imageLoaded",()=>{});bt(this,"loadedLocations",[]);bt(this,"cache",{});bt(this,"sendLoaded",y9(()=>{this.imageLoaded(new ic(this.loadedLocations)),this.loadedLocations=[]},20));bt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,rm.length<12?rm.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(tw(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Pi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const im="\uFEFF";function w9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function x9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=r.length)break;if(r[y]===s){c=y+1,f=!0;continue}c=r[y]==="\r"&&r[y+1]===` +`?y+2:y+1,o.push(a),l.push({start:u+i,end:y+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const d=o.length>0?o[0]:[],h=d.length,p=o.slice(1),m=p.map(g=>g.length),x=p.map(g=>g.length===h?g:g.length>h?g.slice(0,h):[...g,...Array(h-g.length).fill("")]);return{headers:d,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function Mp(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` +`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function sm(t,e,n=","){return[t,...e].map(r=>Mp(r,n)).join(` +`)}function lw(t,e){return nf(t,e).headers}function b9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function $E(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function k9(t,e){return t[e]==="\r"?t[e+1]===` +`?2:1:t[e]===` +`?1:0}function Ub(t,e){return t[e-2]==="\r"&&t[e-1]===` +`?2:t[e-1]==="\r"||t[e-1]===` +`?1:0}const Kb="\uFEFF";function zE(t,e){const n=t.startsWith(Kb)?Kb.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Ub(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Ub(t,t.length)}}function om(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+k9(t,i.end),replacement:""}));return r.length===0?t:$E(t,r)}function Xb(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:Mp(a,e.delimiter)})}return $E(t,s)}function S9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=zE(t,e),s=lw(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=Mp(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const U0=50;function Go(t=""){return{past:[],present:t,future:[]}}function Gb(t,e,n=U0){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function C9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function T9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>U0?r.slice(r.length-U0):r,present:e,future:n}}function E9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const qb=/^[+-]?\d{16,}$/;function A9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),m=Number.isNaN(h);if(p||m)return p&&m?0:p?1:-1;if(qb.test(a)&&qb.test(u)){const x=BigInt(a),g=BigInt(u);return s*(xg?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const R9=` + +`;function Zf(t,e){return Math.max(0,Math.min(t,e))}function Yb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Zf(a.x,r+i),c=Zf(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=Zf(a.y,e.length),p=Zf(a.y+a.height,e.length);if(p<=h)continue;const m=t.headers.slice(f,d),x=[];for(let g=h;gw[f+b]??""))}x.length!==0&&s.push(sm(m,x,t.delimiter))}if(s.length>0)return s.join(R9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return sm(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return sm(a,u,t.delimiter)}return null}const qo=1e5,O9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function P9(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const m of n.ranges){if(o.size>=qo)break;const x=Math.max(0,m.x-r),g=Math.min(i,m.x+m.width-r);if(g<=x)continue;const y=Math.max(0,m.y),w=Math.min(s,m.y+m.height);if(!(w<=y))for(let k=y;k=qo);k++){const b=k*i;for(let S=x;S=qo));S++);}}for(const m of n.rows){if(o.size>=qo)break;if(m<0||m>=s)continue;const x=m*i;for(let g=0;g=qo));g++);}for(const m of n.columns){if(o.size>=qo)break;const x=m-r;if(!(x<0||x>=i))for(let g=0;g=qo));g++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const m of o){const x=Math.floor(m/i),g=m%i,y=e[x],k=((y!==void 0?(p=t.rows[y])==null?void 0:p[g]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),O9.test(k)){const b=Number(k);Number.isFinite(b)&&(u+=1,c+=b,(f===null||bd)&&(d=b))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const Jb=24,lm=26,Qb=110,am=40,I9=12,zn=1,Zb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',ek='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',N9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function tk(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function nk(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Xl="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",Ld=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function ed(t){return Ld.format(Object.is(t,-0)?0:t)}function D9(t){const e=[`Cells: ${Ld.format(t.cellCount)}`,`Distinct: ${Ld.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${Ld.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${ed(t.sum)}`,`Avg: ${ed(t.avg)}`,`Min: ${ed(t.min)}`,`Max: ${ed(t.max)}`),e.join(" · ")}function _9(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ek,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ek,lineHeight:1}}function L9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function BE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u}){const c=v.useRef(null),f=v.useRef(null),d=v.useRef(null),[h,p]=v.useState(""),[m,x]=v.useState(""),[g,y]=v.useState(null),w=v.useRef(g);w.current=g;const k=v.useRef(null),[b,S]=v.useState(null),[T,A]=v.useState(""),M=v.useRef(null),[O,_]=v.useState(void 0),[P,I]=v.useState(()=>new Set),D=v.useRef(P),[ee,ie]=v.useState(0),[te,W]=v.useState({}),V=i!==void 0,R=a??te,N=v.useCallback(z=>{W(z),u==null||u(z)},[u]),L=v.useMemo(()=>_9(r),[r]),H=L9(r),G=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",B=v.useRef();B.current===void 0&&(B.current=new v9);const le=v.useMemo(()=>nf(t,e),[t,e]),me=v.useMemo(()=>b9(le),[le]),ye=le.headers.length,oe=v.useRef({text:t,table:le});oe.current={text:t,table:le};const be=v.useRef(O);be.current=O,v.useEffect(()=>{const z=window.setTimeout(()=>x(h),150);return()=>window.clearTimeout(z)},[h]);const Ce=v.useMemo(()=>{const z=A9(le.rows,m);return g?M9(z,le.rows,g.col,g.dir,me[g.col]??!1):z},[le,m,g,me]),lt=v.useRef(Ce);lt.current=Ce,v.useEffect(()=>{const z=f.current;if(!z||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>ie(z.clientWidth));return ue.observe(z),ie(z.clientWidth),()=>ue.disconnect()},[]);const Xe=Math.max(Qb,Math.floor((ee-am)/Math.max(1,ye)));v.useEffect(()=>{I(z=>{let ue=!1;const q=new Set;for(const ce of z)ce{_(z=>{if(!z||z.rows.length===0)return z;const ue=[];for(const ce of D.current){const fe=Ce.indexOf(ce);fe!==-1&&ue.push(fe)}ue.sort((ce,fe)=>ce-fe);const q=ue.reduce((ce,fe)=>ce.add(fe),Nt.empty());return q.equals(z.rows)?z:{...z,rows:q}})},[Ce]),v.useEffect(()=>{y(z=>z!==null&&z.col>=ye?null:z),S(z=>z!==null&&z.col>=ye?null:z)},[ye]);const Ge=m!=="",at=le.rows.length,Ut=lm+Math.min(Ce.length,I9)*Jb,Pe=()=>{p(""),x("")},xe=v.useCallback((z,ue)=>{var ce;if(z0||Fe.height>0)?{x:Math.max(0,Re.x-Fe.left),y:Math.max(0,Re.y-Fe.top),width:Re.width,height:Re.height}:Re??{x:am+q*Xe,y:0,width:Xe,height:lm};A(fe),S({col:q,bounds:We});return}k.current=w.current,S(null),y(fe=>!fe||fe.col!==q?{col:q,dir:"asc"}:fe.dir==="asc"?{col:q,dir:"desc"}:null)},[V,Xe]),Je=v.useCallback(()=>{if(!b)return;const{col:z}=b;if(S(null),!i)return;const{text:ue,table:q}=oe.current,ce=q.headers[z]??"",fe=S9(ue,q,z,T);if(fe!==ue){if(ce!==""&&ce!==T&&R[ce]!==void 0){const Fe={...R},Re=Fe[ce];delete Fe[ce],T!==""&&Re!==void 0&&(Fe[T]=Re),N(Fe)}i(fe)}},[b,T,i,R,N]),nt=v.useCallback(()=>{S(null)},[]);v.useEffect(()=>{if(!b)return;const z=M.current;z&&(z.focus(),z.select())},[b]);const it=v.useCallback((z,ue)=>{const q=lt.current,ce=q[ue];if(ce===void 0)return;const fe=D.current,Fe=d.current;let Re;if(z.shiftKey&&Fe!==null&&Fe!==ce){const ut=q.indexOf(Fe),Ot=q.indexOf(ce),Xt=ut===-1?Ot:ut,[Nn,wr]=Xt<=Ot?[Xt,Ot]:[Ot,Xt];Re=z.metaKey||z.ctrlKey?new Set(fe):new Set;for(let Mn=Nn;Mn<=wr;Mn++){const ys=q[Mn];ys!==void 0&&Re.add(ys)}}else z.metaKey||z.ctrlKey?(Re=new Set(fe),Re.has(ce)?Re.delete(ce):Re.add(ce)):Re=new Set([ce]);d.current=ce,D.current=Re,I(Re);const We=[...Re].map(ut=>q.indexOf(ut)).filter(ut=>ut!==-1).sort((ut,Ot)=>ut-Ot);_(ut=>({current:ut==null?void 0:ut.current,columns:(ut==null?void 0:ut.columns)??Nt.empty(),rows:We.reduce((Ot,Xt)=>Ot.add(Xt),Nt.empty())}))},[]),$e=v.useCallback(()=>{d.current=null,D.current=new Set,I(new Set),_(void 0)},[]),At=v.useCallback(z=>{const ue=new Set;for(const q of z.rows){const ce=lt.current[q];ce!==void 0&&ue.add(ce)}D.current=ue,I(ue),_(z)},[]),wt=v.useCallback(()=>{$e()},[$e]),rt=v.useMemo(()=>Ce.filter(z=>P.has(z)),[Ce,P]),ge=v.useMemo(()=>[...(O==null?void 0:O.columns)??[]].filter(z=>z>=zn).map(z=>z-zn),[O]),_e=ge.length,Qe=v.useMemo(()=>ge.map(z=>le.headers[z]).filter(z=>z!==void 0),[ge,le.headers]),tt=v.useMemo(()=>{if(Qe.length===0)return null;const z=R[Qe[0]]??"auto";for(let ue=1;ue{if(!V||Qe.length===0)return;const ue={...R};for(const q of Qe)z==="auto"?delete ue[q]:ue[q]=z;N(ue)},[V,Qe,R,N]),dt=v.useMemo(()=>V?le.headers.filter(z=>tk(R[z])!==null).length:0,[V,le.headers,R]),ht=v.useMemo(()=>({ranges:O!=null&&O.current?[O.current.range,...O.current.rangeStack]:[],columns:O?[...O.columns]:[],rows:P.size>0?Ce.reduce((z,ue,q)=>(P.has(ue)&&z.push(q),z),[]):O?[...O.rows]:[]}),[O,P,Ce]),pt=zn,Lt=v.useMemo(()=>P9(le,Ce,ht,pt),[le,Ce,ht,pt]),Rt=rt.length>0||_e>0||Lt!==null,en=v.useRef(l);en.current=l;const Hn=()=>{var q,ce;const z=be.current,ue=Yb(oe.current.table,lt.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},zn);ue!==null&&((q=en.current)==null||q.call(en),(ce=navigator.clipboard)==null||ce.writeText(ue).catch(()=>{}))};v.useEffect(()=>{const z=ue=>{var Re,We;const q=c.current;if(!q||!q.contains(document.activeElement))return;const ce=document.activeElement;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable))return;const fe=be.current,Fe=Yb(oe.current.table,lt.current,{ranges:fe!=null&&fe.current?[fe.current.range,...fe.current.rangeStack]:[],columns:fe?[...fe.columns]:[],rows:fe?[...fe.rows]:[]},zn);Fe!==null&&(ue.preventDefault(),ue.stopImmediatePropagation(),(Re=ue.clipboardData)==null||Re.setData("text/plain",Fe),(We=en.current)==null||We.call(en))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const z=ue=>{const q=c.current;if(!q)return;const ce=ue.target instanceof Node&&q.contains(ue.target),fe=document.activeElement instanceof Node&&q.contains(document.activeElement);if(!ce&&!fe||nk(ue.target)||nk(document.activeElement))return;const Fe=E9(ue);Fe==="undo"&&s?(ue.preventDefault(),s()):Fe==="redo"&&o&&(ue.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Pt=v.useCallback(z=>{var q;const ue=c.current!==null&&document.activeElement instanceof Node&&c.current.contains(document.activeElement);$e(),i==null||i(z),ue&&((q=f.current)==null||q.focus({preventScroll:!0}))},[$e,i]),vn=ye>0&&ge.length>=ye,In=()=>{!V||rt.length===0||Pt(om(oe.current.text,oe.current.table,rt))},Pr=()=>{!V||vn||ge.length===0||Pt(Xb(oe.current.text,oe.current.table,ge))},Ir=v.useCallback(z=>{if(!i)return!1;const{text:q,table:ce}=oe.current,fe=lt.current;if(z.rows.length>0){const We=[...z.rows].map(ut=>fe[ut]).filter(ut=>ut!==void 0);if(We.length>0)return Pt(om(q,ce,We)),!1}if(z.columns.length>0){const We=[...z.columns].filter(ut=>ut>=zn&&utut-zn);return We.length>0&&We.length0&&Pt(om(q,ce,Re)),!1},[Pt,i]),Bt=v.useCallback(z=>{const ue=i;if(!ue)return!1;const{text:q,table:ce}=oe.current,fe=lt.current,Fe=[...z].sort((ut,Ot)=>ut.location[1]-Ot.location[1]);let Re=q,We=0;for(const{location:ut,value:Ot}of Fe){const Xt=ut[0]-zn,Nn=ut[1];if(Xt<0||Ot.kind!==Te.Text)continue;const wr=fe[Nn],Mn=wr===void 0?void 0:ce.rowSpans[wr];if(!Mn)continue;const ys=Re.slice(Mn.start+We,Mn.end+We),qn=lw(ys,ce.delimiter);for(;qn.length<=Xt;)qn.push("");const vs=Ot.data??"";if(qn[Xt]===vs)continue;qn[Xt]=vs;const ws=Mp(qn,ce.delimiter);Re=Re.slice(0,Mn.start+We)+ws+Re.slice(Mn.end+We),We+=ws.length-(Mn.end-Mn.start)}return Re!==q&&ue(Re),!0},[i]),ct=v.useCallback(z=>{var Fe;const[ue,q]=z,ce=lt.current[q];if(ue{const ue=[];for(let q=z.y;q{z[0]>=zn||it(ue,z[1])},[it]),ne=v.useMemo(()=>{const z={title:"#",id:"__gutter",width:am,themeOverride:{baseFontStyle:`11px ${Zb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ue=le.headers.map((q,ce)=>{const fe=V?tk(R[q]):null;return{title:fe?`${q.toUpperCase()} [${fe}]`:q.toUpperCase(),id:`c${ce}`,width:Xe,themeOverride:me[ce]?{baseFontStyle:`12px ${Zb}`}:void 0}});return[z,...ue]},[le.headers,me,Xe,V,R]),Le=v.useCallback((z,ue)=>{const{ctx:q,columnIndex:ce,rect:fe,theme:Fe,isSelected:Re}=z;q.save();try{if(q.letterSpacing="0.5px",Re&&(q.fillStyle=Fe.bgHeaderHovered,q.fillRect(fe.x,fe.y,fe.width,fe.height),q.fillStyle=Fe.accentColor,q.fillRect(fe.x,fe.y+fe.height-2,fe.width,2)),ce{const{ctx:q,cell:ce,rect:fe,col:Fe,theme:Re}=z,We=Fe-zn;if(We>=0&&Ge&&ce.kind===Te.Text){const ut=F9(ce.data,m);if(ut!==null){q.save();try{const Ot=`${Re.baseFontStyle} ${Re.fontFamily}`;q.font=Ot;let Xt=fe.x+Re.cellHorizontalPadding;const Nn=fe.y+fe.height/2+js(q,Ot);for(const wr of ut){const Mn=q.measureText(wr.text).width;wr.hit&&Mn>0&&(q.fillStyle=H,q.fillRect(Xt-1,Nn-7,Mn+2,14)),Xt+=Mn}}finally{q.restore()}}}if(ue(),We>=0&&ce.kind===Te.Text&&ce.data===""){q.save();try{q.font=`${Re.baseFontStyle} ${Re.fontFamily}`,q.fillStyle=Re.textLight,q.fillText("—",fe.x+Re.cellHorizontalPadding,fe.y+fe.height/2+.5)}finally{q.restore()}}},[Ge,m,H]),An=v.useCallback(z=>{const ue=lt.current[z];return ue!==void 0&&D.current.has(ue)?{bgCell:G,bgCellMedium:G}:void 0},[G]);return ye===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:c,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(aN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:h,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Escape"&&Pe()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),h!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Pe,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(gh,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:Ge?`${Ce.length.toLocaleString()} of ${at.toLocaleString()}`:`${at.toLocaleString()} rows`}),V&&dt>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>N({}),title:"Reset all pinned column types to Auto",className:Xl,children:[`${dt} ${dt===1?"column type":"column types"} pinned`,E.jsx(gh,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),Rt&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:rt.length>0?`${rt.length.toLocaleString()} selected`:_e>0?`${_e.toLocaleString()} ${_e===1?"column":"columns"} selected`:`${((Lt==null?void 0:Lt.cellCount)??0).toLocaleString()} cells selected`}),Lt!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:D9(Lt)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Hn,className:Xl,children:[E.jsx(Dv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),V&&rt.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:In,title:`Deletes the ${rt.length} selected ${rt.length===1?"row":"rows"} from the source CSV`,className:Xl,children:[E.jsx(ph,{"aria-hidden":"true",className:"size-3"}),"Delete ",rt.length.toLocaleString()," ",rt.length===1?"row":"rows"]}),V&&_e>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:N9.map(({mode:z,label:ue})=>{const q=tt===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":q,onClick:()=>Kt(z),className:q?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:ue},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:Pr,disabled:vn,title:vn?"At least one column must remain — the converter needs a column to detect":`Deletes the ${_e} selected ${_e===1?"column":"columns"} from the source CSV`,className:`${Xl} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(ph,{"aria-hidden":"true",className:"size-3"}),"Delete ",_e.toLocaleString()," ",_e===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:$e,className:Xl,children:"Clear"})]})]}),E.jsxs("div",{ref:f,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":Ce.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Ut},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(R6,{imageWindowLoader:B.current,renderers:f9,columns:ne,rows:Ce.length,getCellContent:ct,getCellsForSelection:xt,onCellsEdited:V?Bt:void 0,onDelete:V?Ir:void 0,onCellClicked:dn,onHeaderClicked:xe,onGridSelectionChange:At,onSelectionCleared:wt,gridSelection:O,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Jb,headerHeight:lm,freezeColumns:zn,fillHandle:V,onPaste:V?()=>!0:!1,keybindings:{search:!1},theme:L,drawHeader:Le,drawCell:ze,getRowThemeOverride:An,minColumnWidth:Qb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),b!==null&&E.jsx("input",{ref:M,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${le.headers[b.col]??""}`,value:T,onChange:z=>A(z.target.value),onBlur:Je,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),Je()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),nt())},style:{left:b.bounds.x,top:b.bounds.y,width:Math.max(60,b.bounds.width),height:b.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),Ge&&Ce.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:Pe,className:Xl,children:"Show all rows"})]}),V&&!Ge&&Ce.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function F9(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=v.useRef(null);v.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(GI,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=j9(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(pT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(cN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let K0=[],jE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=jE[r])e=r+1;else return!0;if(e==n)return!1}}function rk(t){return t>=127462&&t<=127487}const ik=8205;function V9(t,e,n=!0,r=!0){return(n?HE:U9)(t,e,r)}function HE(t,e,n){if(e==t.length)return e;e&&WE(t.charCodeAt(e))&&VE(t.charCodeAt(e-1))&&e--;let r=um(t,e);for(e+=sk(r);e=0&&rk(um(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function U9(t,e,n){for(;e>1;){let r=HE(t,e-2,n);if(r=56320&&t<57344}function VE(t){return t>=55296&&t<56320}function sk(t){return t<65536?1:2}class Dt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Fa(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),ts.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Fa(this,e,n);let r=[];return this.decompose(e,n,r,0),ts.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new sc(this),s=new sc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new sc(this,e)}iterRange(e,n=this.length){return new UE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new KE(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Dt.empty:e.length<=32?new Sn(e):ts.from(Sn.split(e,[]))}}class Sn extends Dt{constructor(e,n=K9(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new X9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Sn(ok(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Fd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Sn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Sn(l.slice(0,a)),new Sn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Sn))return super.replace(e,n,r);[e,n]=Fa(this,e,n);let i=Fd(this.text,Fd(r.text,ok(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Sn(i,s):ts.from(Sn.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Sn(r,i)),r=[],i=-1);return i>-1&&n.push(new Sn(r,i)),n}}class ts extends Dt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Fa(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new ts(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof ts))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof ts)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Sn&&a&&(p=c[c.length-1])instanceof Sn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:ts.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new ts(l,n)}}Dt.empty=new Sn([""],0);function K9(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Fd(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Sn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof Sn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Sn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class UE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new sc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class KE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Dt.prototype[Symbol.iterator]=function(){return this.iter()},sc.prototype[Symbol.iterator]=UE.prototype[Symbol.iterator]=KE.prototype[Symbol.iterator]=function(){return this});class X9{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Fa(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function sr(t,e,n=!0,r=!0){return V9(t,e,n,r)}function G9(t){return t>=56320&&t<57344}function q9(t){return t>=55296&&t<56320}function Y9(t,e){let n=t.charCodeAt(e);if(!q9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return G9(r)?(n-55296<<10)+(r-56320)+65536:n}function J9(t){return t<65536?1:2}const X0=/\r\n?|\n/;var Sr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Sr||(Sr={}));class ds{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=Sr.Simple&&u>=e&&(r==Sr.TrackDel&&ie||r==Sr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ds(e)}static create(e){return new ds(e)}}class _n extends ds{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return G0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return q0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&go(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?Dt.of(h.split(r||X0)):h:Dt.empty,m=p.length;if(f==d&&m==0)return;fo&&rr(i,f-o,-1),rr(i,d-f,m),go(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new _n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function go(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function q0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Ic(t),l=new Ic(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);rr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Ic{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Dt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Dt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class uo{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new uo(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return he.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return he.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return he.range(e.anchor,e.head)}static create(e,n,r,i){return new uo(e,n,r,i)}}class he{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:he.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new he(e.ranges.map(n=>uo.fromJSON(n)),e.main)}static single(e,n=e){return new he([he.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?he.range(a,l):he.range(l,a))}}return new he(e,n)}}function GE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let aw=0;class je{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=aw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new je(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:uw),!!e.static,e.enables)}of(e){return new $d([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new $d(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new $d(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function uw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class $d{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=aw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||Y0(f,c)){let h=r(f);if(l?!lk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=Ph(d,p);if(this.dependencies.every(x=>x instanceof je?d.facet(x)===f.facet(x):x instanceof ms?d.field(x,!1)==f.field(x,!1):!0)||(l?lk(h=r(f),m,i):i(h=r(f),m)))return f.values[o]=m,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function lk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(td).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(td),o=i.facet(td),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,td.of({field:this,create:e})]}get extension(){return this}}const rl={lowest:4,low:3,default:2,high:1,highest:0};function Ou(t){return e=>new qE(e,t)}const cw={highest:Ou(rl.highest),high:Ou(rl.high),default:Ou(rl.default),low:Ou(rl.low),lowest:Ou(rl.lowest)};class qE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class dl{of(e){return new J0(this,e)}reconfigure(e){return dl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class J0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Oh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of Z9(e,n,o))d instanceof ms?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=c&&c[d]||[];if(h.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,uw(m,h))a.push(r.facet(p));else{let x=p.combine(h.map(g=>g.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of h)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(g=>x.dynamicSlot(g)));l[p.id]=u.length<<1,u.push(x=>Q9(x,p,h))}}let f=u.map(d=>d(l));return new Oh(e,o,f,l,a,s)}}function Z9(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof J0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof J0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof qE)s(o.inner,o.prec);else if(o instanceof ms)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof $d)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,rl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,rl.default),r.reduce((o,l)=>o.concat(l))}function oc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Ph(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const YE=je.define(),Q0=je.define({combine:t=>t.some(e=>e),static:!0}),JE=je.define({combine:t=>t.length?t[0]:void 0,static:!0}),QE=je.define(),ZE=je.define(),eA=je.define(),tA=je.define({combine:t=>t.length?t[0]:!1});class Fo{constructor(e,n){this.type=e,this.value=n}static define(){return new eV}}class eV{of(e){return new Fo(this,e)}}class tV{constructor(e){this.map=e}of(e){return new qt(this,e)}}class qt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new qt(this.type,n)}is(e){return this.type==e}static define(e={}){return new tV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}qt.reconfigure=qt.define();qt.appendConfig=qt.define();class $n{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&GE(r,n.newLength),s.some(l=>l.type==$n.time)||(this.annotations=s.concat($n.time.of(Date.now())))}static create(e,n,r,i,s,o){return new $n(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation($n.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}$n.time=Fo.define();$n.userEvent=Fo.define();$n.addToHistory=Fo.define();$n.remote=Fo.define();function nV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof $n?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof $n?t=s[0]:t=rA(e,Sa(s),!1)}return t}function iV(t){let e=t.startState,n=e.facet(eA),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=nA(r,Z0(e,s,t.changes.newLength),!0))}return r==t?t:$n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const sV=[];function Sa(t){return t==null?sV:Array.isArray(t)?t:[t]}var Is=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Is||(Is={}));const oV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ey;try{ey=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function lV(t){if(ey)return ey.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||oV.test(n)))return!0}return!1}function aV(t){return e=>{if(!/\S/.test(e))return Is.Space;if(lV(e))return Is.Word;for(let n=0;n-1)return Is.Word;return Is.Other}}class $t{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(qt.reconfigure)?(n=null,r=l.value):l.is(qt.appendConfig)&&(n=null,r=Sa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Oh.resolve(r,i,this),s=new $t(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Q0)?e.newSelection:e.newSelection.asSingle();new $t(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:he.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Sa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return $t.create({doc:e.doc,selection:he.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Oh.resolve(e.extensions||[],new Map),r=e.doc instanceof Dt?e.doc:Dt.of((e.doc||"").split(n.staticFacet($t.lineSeparator)||X0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return GE(i,r.length),n.staticFacet(Q0)||(i=i.asSingle()),new $t(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet($t.tabSize)}get lineBreak(){return this.facet($t.lineSeparator)||` +`}get readOnly(){return this.facet(tA)}phrase(e,...n){for(let r of this.facet($t.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(YE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return aV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=sr(n,o,!1);if(s(n.slice(a,o))!=Is.Word)break;o=a}for(;lt.length?t[0]:4});$t.lineSeparator=JE;$t.readOnly=tA;$t.phrases=je.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});$t.languageData=YE;$t.changeFilter=QE;$t.transactionFilter=ZE;$t.transactionExtender=eA;dl.reconfigure=qt.define();function iA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class xl{eq(e){return this==e}range(e,n=e){return ty.create(e,n,this)}}xl.prototype.startSide=xl.prototype.endSide=0;xl.prototype.point=!1;xl.prototype.mapMode=Sr.TrackDel;function fw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let ty=class sA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new sA(e,n,r)}};function ny(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class dw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new dw(i,s,r,l):null,pos:o}}}class Ht{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Ht(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(ny)),this.isEmpty)return n.length?Ht.of(n):this;let l=new oA(this,null,-1).goto(0),a=0,u=[],c=new $a;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Nc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Nc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ak(o,l,r),u=new Pu(o,a,s),c=new Pu(l,a,s);r.iterGaps((f,d,h)=>uk(u,f,c,d,h,i)),r.empty&&r.length==0&&uk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ak(s,o),a=new Pu(s,l,0).goto(r),u=new Pu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ry(a.active,u.active)||a.point&&(!u.point||!fw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Pu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new $a;for(let i of e instanceof ty?[e]:n?uV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ht.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ht.empty;i=i.nextLayer)n=new Ht(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Ht.empty=new Ht([],[],null,-1);function uV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ny);e=r}return t}Ht.empty.nextLayer=Ht.empty;class $a{finishChunk(e){this.chunks.push(new dw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new $a)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Ht.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Ht.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ak(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new oA(o,n,r,s));return i.length==1?i[0]:new Nc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)cm(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)cm(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),cm(this.heap,0)}}}function cm(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Pu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){nd(this.active,e),nd(this.activeTo,e),nd(this.activeRank,e),this.minActive=ck(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;rd(this.active,n,r),rd(this.activeTo,n,i),rd(this.activeRank,n,s),e&&rd(e,n,this.cursor.from),this.minActive=ck(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&nd(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function uk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&fw(t.point,n.point)&&ry(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ry(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function ry(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function ck(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=sr(t,i)}return t.length}const iy="ͼ",fk=typeof Symbol>"u"?"__"+iy:Symbol.for(iy),sy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),dk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ro{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=dk[fk]||1;return dk[fk]=e+1,iy+e.toString(36)}static mount(e,n,r){let i=e[sy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new fV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let hk=new Map;class fV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=hk.get(r);if(s)return e[sy]=s;this.sheet=new i.CSSStyleSheet,hk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[sy]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dV=typeof navigator<"u"&&/Mac/.test(navigator.platform),hV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Kn=0;Kn<10;Kn++)Oo[48+Kn]=Oo[96+Kn]=String(Kn);for(var Kn=1;Kn<=24;Kn++)Oo[Kn+111]="F"+Kn;for(var Kn=65;Kn<=90;Kn++)Oo[Kn]=String.fromCharCode(Kn+32),Dc[Kn]=String.fromCharCode(Kn);for(var fm in Oo)Dc.hasOwnProperty(fm)||(Dc[fm]=Oo[fm]);function pV(t){var e=dV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||hV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Dc:Oo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function ns(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Me={mac:mk||/Mac/.test(dr.platform),windows:/Win/.test(dr.platform),linux:/Linux|X11/.test(dr.platform),ie:Op,ie_version:aA?oy.documentMode||6:ay?+ay[1]:ly?+ly[1]:0,gecko:pk,gecko_version:pk?+(/Firefox\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,chrome:!!dm,chrome_version:dm?+dm[1]:0,ios:mk,android:/Android\b/.test(dr.userAgent),webkit:gk,webkit_version:gk?+(/\bAppleWebKit\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,safari:uy,safari_version:uy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(dr.userAgent)||[0,0])[1]:0,tabSize:oy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function hw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Ih=Object.create(null);function pw(t,e,n){if(t==e)return!0;t||(t=Ih),e||(e=Ih);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function gV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function yk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function mV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new bl(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=uA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new bl(e,r,i,n,e.widget||null,!0)}static line(e){return new sf(e)}static set(e,n=!1){return Ht.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Vt.none=Ht.empty;class rf extends Vt{constructor(e){let{start:n,end:r}=uA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?hw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ih}eq(e){return this==e||e instanceof rf&&this.tagName==e.tagName&&pw(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}rf.prototype.point=!1;class sf extends Vt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof sf&&this.spec.class==e.spec.class&&pw(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}sf.prototype.mapMode=Sr.TrackBefore;sf.prototype.point=!0;class bl extends Vt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Sr.TrackBefore:Sr.TrackAfter:Sr.TrackDel}get type(){return this.startSide!=this.endSide?fi.WidgetRange:this.startSide<=0?fi.WidgetBefore:fi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof bl&&yV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}bl.prototype.point=!0;function uA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function yV(t,e){return t==e||!!(t&&e&&t.compare(e))}function Ca(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class _c extends xl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof _c&&this.tagName==e.tagName&&pw(this.attributes,e.attributes)}static create(e){return new _c(e.tagName,e.attributes||Ih,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Ht.of(e,n)}}_c.prototype.startSide=_c.prototype.endSide=-1;function Lc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function cy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function lc(t,e){if(!e.anchorNode)return!1;try{return cy(t,e.anchorNode)}catch{return!1}}function ac(t){return t.nodeType==3?$c(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function uc(t,e,n,r){return n?vk(t,e,n,r,-1)||vk(t,e,n,r,1):!1}function Po(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Nh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function vk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:zs(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Po(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?zs(t):0}else return!1}}function zs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Fc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function vV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function cA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function wV(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,m=1;if(h)d=vV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let y=c.getBoundingClientRect();({scaleX:p,scaleY:m}=cA(c,y)),d={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*m}}let x=0,g=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(g=e.bottom-d.bottom+o,n<0&&e.top-g0&&e.right>d.right+x&&(x=e.right-d.right+s)):e.right>d.right-s&&(x=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function fA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class xV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?zs(n):0),r,Math.min(e.focusOffset,r?zs(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function dA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function hA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let el=null;Me.safari&&Me.safari_version>=26&&(el=!1);function pA(t){if(t.setActive)return t.setActive();if(el)return t.focus(el);let e=dA(t);t.focus(el==null?{get preventScroll(){return el={preventScroll:!0},!0}}:void 0),el||(el=!1,hA(e))}let wk;function $c(t,e,n=e){let r=wk||(wk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function Ta(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function bV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function kV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,zs(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=zs(n))}else{if(n==t)return!0;r=Po(n),n=n.parentNode}}function gA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function mA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=zs(n)}else if(n.parentNode&&!Nh(n))r=Po(n),n=n.parentNode;else return null}}function yA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function xA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(qi[m+1]==-h){let x=qi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Gt[f]=Gt[qi[m]]=g),l=m;break}}else{if(qi.length==189)break;qi[l++]=f,qi[l++]=d,qi[l++]=a}else if((p=Gt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=qi[x+2];if(g&2)break;if(m)qi[x+2]|=2;else{if(g&4)break;qi[x+2]|=4}}}}}function MV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Gt[--p]=h;a=c}else s=u,a++}}}function dy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new os(a,m.from,h));let x=m.direction==kl!=!(h%2);hy(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Gt[p]!=l:Gt[p]==l))break;p++}d?dy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Gt[a-1];m!=l&&(c=!1,f=m==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,g=u;;){if(x==e)break e;if(g&&s[g-1].to==x)x=s[--g].from;else{if(Gt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toGt.length;)Gt[Gt.length]=256;let r=[],i=e==kl?0:1;return hy(t,i,i,n,0,t.length,r),r}function bA(t){return[new os(0,t,0)]}let kA="";function OV(t,e,n,r,i){var s;let o=r.head-t.from,l=os.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=sr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),kA=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),IV=je.define({combine:t=>t.some(e=>e)}),OA=je.define();class Ea{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ea(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ea(he.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const id=qt.define({map:(t,e)=>t.map(e)}),PA=qt.define();function li(t,e,n){let r=t.facet(EA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Rs=je.define({combine:t=>t.length?t[0]:!0});let NV=0;const ha=je.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Pp.of(u=>{let c=u.plugin(l);return c?o(c):Vt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return gi.define((r,i)=>new e(r,i),n)}}class hm{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(li(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){li(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){li(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const IA=je.define(),vw=je.define(),Pp=je.define(),NA=je.define(),ww=je.define(),of=je.define(),DA=je.define();function xk(t,e){let n=t.state.facet(DA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Ht.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=PV(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:h,inner:[]};f.push(m),f=m.inner}}}}),i}const _A=je.define();function xw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(_A)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Hu=je.define();class ai{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ai(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new ai(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Dh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const DV=[];class yn{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return DV}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&gV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Po(this.dom),i=this.length?e>0:n>0;return new Ni(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Np)return e;return null}static get(e){return e.cmTile}}class Ip extends yn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=bk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=bk(i);this.length=o}}function bk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Np extends Ip{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=yn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ds)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ds extends Ip{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ds(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class za extends Ip{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new za(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&LV(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):_V(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ni(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ni(a.dom,0);a==r.tile&&(l=!0)}}return new Ni(this.dom,0)}}function _V(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ac(e);return n[n.length-1]||null}function LV(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Me.chrome||Me.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Me.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Fc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new al(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Sl extends yn{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Fc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class FV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Cr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(pm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=yn.get(a.dom);f&&f.setDOM(pm(a.dom))}let c=Cr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=yn.get(e.text);s&&this.cache.reused.set(s,2);let o=new al(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=LA);let i=za.start(e,n||((r=this.cache.find(za))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Cr&&l.mark.eq(o))i=l,n--;else{let a=Cr.of(o,(r=this.cache.find(Cr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!kk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&kk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(gm,0,32)||new Sl(gm.toDOM(),0,gm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new $V(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(_h,void 0,1);return r&&(r.flags=n),r||new _h(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class BV{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Lh=[Sl,za,al,Cr,_h,Ds,Np];for(let t=0;t[]),this.index=Lh.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Cr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Cr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Ht.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof bl){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Ba.block:Ba.inline),p=WV(u),m=this.cache.findWidget(h,a-l,p)||Sl.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=VV(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=yn.get(i);if(i==this.view.contentDOM)break;s instanceof Cr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ds||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new za(i,LA):r||n.push(Cr.of(new rf({tagName:i.nodeName.toLowerCase(),attributes:mV(i)}),i)))}return{line:r,marks:n}}}function kk(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function WV(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const LA={class:"cm-line"};function VV(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&hw(n,t),r&&(t.class+=" "+r)),t}function UV(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Cr&&e.push(r.mark)}return e}function pm(t){let e=yn.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ba extends nu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ba.inline=new Ba("span");Ba.block=new Ba("div");const gm=new class extends nu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Sk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Vt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Np(e,e.contentDOM),this.updateInner([new ai(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!eU(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?XV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ai(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Me.ie||Me.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=YV(o,this.decorations,e.changes);a.length&&(r=ai.extendWithRanges(r,a));let u=QV(l,this.blockWrappers,e.changes);return u.length&&(r=ai.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new HV(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&yn.get(n.text)&&l.cache.reused.set(yn.get(n.text),2),this.tile=l.run(e,n),gy(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&lc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Me.gecko&&a.empty&&!this.hasComposition&&KV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ni(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!uc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!uc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(f.focusNode)&&ZV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Lc(this.view.root);if(d)if(a.empty){if(Me.gecko){let h=GV(u.node,u.offset);if(h&&h!=3){let p=(h==1?mA:yA)(u.node,u.offset);p&&(u=new Ni(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ni(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ni(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&uc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Lc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=zs(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!yn.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof mm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==mn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let m=f.children[p],x=d+m.length,g=m.dom.getBoundingClientRect(),{height:y}=g;if(h&&!p&&(u+=g.top-h.top),m instanceof Ds)x>r&&c(m,d,g);else if(d>=r&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let w=m.dom.lastChild,k=w?ac(w):[];if(k.length){let b=k[k.length-1],S=a?b.right-g.left:g.right-b.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=x)}}h&&p==f.children.length-1&&(u+=h.bottom-g.bottom),d=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?mn.RTL:mn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=ac(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=ac(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Vt.replace({widget:new mm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Vt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Pp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(ww).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Ht.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(OA))try{if(u(this.view,e.range,e))return!0}catch(c){li(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=xw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(wV(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){gy(this.tile)}}function gy(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)gy(r,e)}}function KV(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function FA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=mA(n.focusNode,n.focusOffset),i=yA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=yn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=yn.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function XV(t,e,n){let r=FA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new ai(a.mapPos(s),a.mapPos(o),s,o),text:i}}function GV(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class mm extends nu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function tU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return he.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=sr(i.text,s,!1):l=sr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=sr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+cV(o,s,t.state.tabSize)}function rU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==fi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function iU(t,e,n,r){let i=rU(t,e.head,e.assoc||-1),s=!r||i.type!=fi.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==mn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return he.cursor(a,n?-1:1)}return he.cursor(n?i.to:i.from,n?-1:1)}function Ck(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=OV(i,s,o,l,n),c=kA;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` +`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function sU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Is.Space&&(i=o),i==o}}function oU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return he.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let m=l+(h+p)*s,x=my(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:y{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:he.cursor(r,rt.viewState.docHeight)return new rs(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==fi.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==fi.Text){let f=nU(t,i,u,o,l);return new rs(f,f==u.from?1:-1)}}if(u.type!=fi.Text)return a<(u.top+u.bottom)/2?new rs(u.from,1):new rs(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new lU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class lU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let y=1;y=s&&(w-=p),!o.has(w)){m=w;break t}}break e}o.add(m);let x=n(m),g=0;if(x)for(let y=0;y1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),g=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==mn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return $c(e.dom,o,l).getClientRects()});return i.after?new rs(r[i.i+1],-1):new rs(r[i.i],1)}scanTile(e,n){if(!e.length)return new rs(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:$c(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new rs(r[i.i+1],-1):new rs(o,1)}}const Jl="￿";class aU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Jl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=yn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=yn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Nh(i))||Nh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!cU(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=yn.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(uU(e,r.node,r.offset)?n:0))}}function uU(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=zA(e.docView.tile,n,r,0))){let a=s||o?[]:hU(e),u=new aU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=pU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!cy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!cy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Me.ios||Me.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(he.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=he.create([he.cursor(u,h)])}else this.newSel=he.single(c,u)}}}function zA(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return zA(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function BA(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Me.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Dt.of(e.text.slice(s.from-l,d).split(Jl))}:(h=jA(f,e.text,u-l,c))&&(Me.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Jl+Jl&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:Dt.of(e.text.slice(h.from,h.toB).split(Jl))})}else r&&(!t.hasFocus&&i.facet(Rs)||Fh(r,s))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Dt.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Dt.of([" "])}),n)return bw(t,n,r,o);if(r&&!Fh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=$A(i.facet(of).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function bw(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Me.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ta(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&Ta(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ta(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=dU(t,e,n));return t.state.facet(AA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function dU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:he.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&FA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-h,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let g=i.changes({from:x,to:m,insert:e.insert}),y=p.to-s.to;return{changes:g,range:u?he.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(g)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function jA(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function hU(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Tk(n,r)),(i!=n||s!=r)&&e.push(new Tk(i,s))),e}function pU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?he.single(n+e,r+e):null}function Fh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class gU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&PU(e.contentDOM.ownerDocument)}handleEvent(e){!CU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=yU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&WA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(HA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||vU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&mU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Ek(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){li(n.state,i)}}}function yU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(Ek(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(Ek(r.value,a))}}for(let r in Bi)n(r).handlers.push(Bi[r]);for(let r in mr)n(r).observers.push(mr[r]);return e}const HA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],vU="dthko",WA=[16,17,18,20,91,92,224,225],sd=6;function od(t){return Math.max(0,t)*.7+8}function wU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class xU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=fA(e.contentDOM),this.atoms=e.state.facet(of).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet($t.allowMultipleSelections)&&bU(e,n),this.dragging=SU(e,n)&&KA(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&wU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=xw(this.view);e.clientX-a.left<=i+sd?n=-od(i-e.clientX):e.clientX+a.right>=o-sd&&(n=od(e.clientX-o)),e.clientY-a.top<=s+sd?r=-od(s-e.clientY):e.clientY+a.bottom>=l-sd&&(r=od(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=$A(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function bU(t,e){let n=t.state.facet(SA);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function kU(t,e){let n=t.state.facet(CA);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function SU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Lc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function CU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=yn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Bi=Object.create(null),mr=Object.create(null),VA=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function TU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),UA(t,n.value)},50)}function Dp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function UA(t,e){e=Dp(t.state,mw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(yy!=null&&n.selection.ranges.every(a=>a.empty)&&yy==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:he.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:he.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}mr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};mr.wheel=mr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Bi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);mr.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};mr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};mr.touchend=(t,e)=>{t.inputState.touchActive=!1};Bi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(TA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=AU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new xU(t,e,n,r)),r&&t.observer.ignore(()=>{pA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Ak(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return tU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Rk+1)%3:1}function AU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=KA(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Ak(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Ak(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=MU(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function MU(t,e){for(let n=0;n=e)return he.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Bi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=he.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Dp(t.state,yw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Bi.dragend=t=>(t.inputState.draggedContent=null,!1);function Pk(t,e,n,r){if(n=Dp(t.state,mw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&kU(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Bi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Pk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Pk(t,e,r,!0),!0}return!1};Bi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=VA?null:e.clipboardData;return n?(UA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(TU(t),!1)};function RU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function OU(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Dp(t,yw,e.join(t.lineBreak)),ranges:n,linewise:r}}let yy=null;Bi.copy=Bi.cut=(t,e)=>{if(!lc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=OU(t.state);if(!n&&!i)return!1;yy=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=VA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(RU(t,n),!1)};const XA=Fo.define();function GA(t,e){let n=[];for(let r of t.facet(MA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:XA.of(!0)}):null}function qA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=GA(t.state,e);n?t.dispatch(n):t.update([])}},10)}mr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),qA(t)};mr.blur=t=>{t.observer.clearSelectionRange(),qA(t)};mr.compositionstart=mr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};mr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};mr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Bi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return bw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Me.chrome&&Me.android&&(i=HA.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>mr.compositionend(t,e),20),!1};const Ik=new Set;function PU(t){Ik.has(t)||(Ik.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Nk=["pre-wrap","normal","pre-line","break-spaces"];let ja=!1;function Dk(){ja=!1}class IU{constructor(e){this.lineWrapping=e,this.doc=Dt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Nk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>zd&&(ja=!0),this.height=e)}replace(e,n,r){return gr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,Qt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,Qt.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,Qt.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class jr extends YA{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof jr||i instanceof Un&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Un?i=new jr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):gr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Un extends gr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Un?r[r.length-1]=new Un(s.length+i):r.push(null,new Un(i-1))}if(e>0){let s=r[0];s instanceof Un?r[0]=new Un(e+s.length):r.unshift(new Un(e-1),null)}return gr.of(r)}decomposeLeft(e,n){n.push(new Un(e-1),null)}decomposeRight(e,n){n.push(null,new Un(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Un(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=zd&&(a=-2);let h=new jr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Un(s-l).updateHeight(e,l));let u=gr.of(o);return(a<0||Math.abs(u.height-this.height)>=zd||Math.abs(a-this.heightMetrics(e,n).perLine)>=zd)&&(ja=!0),$h(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class _U extends gr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==Qt.ByPosNoHeight?Qt.ByPosNoHeight:Qt.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,Qt.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&_k(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?gr.of(this.break?[e,null,n]:[e,n]):(this.left=$h(this.left,e),this.right=$h(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function _k(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Un&&(r=t[e+1])instanceof Un&&t.splice(e-1,3,new Un(n.length+1+r.length))}const LU=5;class kw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof jr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new jr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=LU)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new jr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Un(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof jr)return e;let n=new jr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof jr)&&!this.isCovered?this.nodes.push(new jr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function BU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function jU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class vm{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new IU(r),this.stateDeco=$k(n),this.heightMap=gr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle.setDoc(n.doc),[new ai(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Vt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new ld(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Fk:new Sw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Wu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=$k(this.state);let i=e.changedRanges,s=ai.extendWithRanges(i,FU(r,this.stateDeco,e?e.changes:_n.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Dk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ja)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(IV)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:S}=cA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=b,this.scaleY=S,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=fA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=gA(this.scrollParent||e.win);let m=(this.printing?jU:zU)(n,this.paddingTop),x=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!BU(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:S,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=S>0&&i.refresh(s,S,T,A,Math.max(5,w/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&g>0?c=Math.max(x,g):x<0&&g<0&&(c=Math.min(x,g)),Dk();for(let S of this.viewports){let T=S.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?gr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle,[new ai(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new NU(S.from,T))}ja&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new ld(i.lineAt(o-r*1e3,Qt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Qt.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,Qt.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=mn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&gg.from>=d.from&&g.to<=d.to&&Math.abs(g.from-c)g.fromy));if(!x){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(he.cursor(f),!1,!0).head;w>c&&(f=w)}let g=this.gapSize(d,c,f,h),y=r||g<2e6?g:2e6;x=new vm(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let S of e)S.from>=c.from&&S.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Ht.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Wu(this.heightMap.lineAt(e,Qt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Wu(this.heightMap.lineAt(this.scaler.fromDOM(e),Qt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Wu(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ld{constructor(e,n){this.from=e,this.to=n}}function WU(t,e,n){let r=[],i=t,s=0;return Ht.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function ud(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function VU(t,e){for(let n of t)if(e(n))return n}const Fk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function $k(t){let e=t.facet(Pp).filter(r=>typeof r!="function"),n=t.facet(ww).filter(r=>typeof r!="function");return n.length&&e.push(Ht.join(n)),e}class Sw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Qt.ByPos,e,0,0).top,c=n.lineAt(a,Qt.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Wu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ii(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Wu(i,e)):t._content)}const cd=je.define({combine:t=>t.join(" ")}),vy=je.define({combine:t=>t.indexOf(!0)>-1}),wy=Ro.newName(),JA=Ro.newName(),QA=Ro.newName(),ZA={"&light":"."+JA,"&dark":"."+QA};function xy(t,e,n){return new Ro(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const UU=xy("."+wy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ZA),KU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wm=Me.ie&&Me.ie_version<=11;class XU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new xV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new qU(e),e.state.facet(Rs)&&(e.contentDOM.editContext=this.editContext.editContext)),wm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Rs)?r.root.activeElement!=this.dom:!lc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&i.focusNode&&uc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Lc(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&GU(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=lc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ta(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&lc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new fU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=BA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Fh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=zk(n,e.previousSibling||e.target.previousSibling,-1),i=zk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Rs)!=e.state.facet(Rs)&&(e.view.contentDOM.editContext=e.state.facet(Rs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function zk(t,e,n){for(;e;){let r=yn.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function Bk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return uc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function GU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Bk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?Bk(t,n):null}class qU{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=jA(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=he.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Fh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:Dt.of(r.text.slice(c.from,c.toB).split(` +`))};if((Me.mac||Me.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:Dt.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);bw(e,f,he.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Lc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ke{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||bV(e.parent)||document,this.viewState=new Lk(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(id)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ha).map(i=>new hm(i));for(let i of this.plugins)i.update(this);this.observer=new XU(this),this.inputState=new gU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Sk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof $n?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(XA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=GA(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet($t.phrases)!=this.state.facet($t.phrases))return this.setState(s);i=Dh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:m}=this.state.facet(Ke.cursorScrollMargin);f=new Ea(h.empty?h:he.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",m,p)}for(let h of d.effects)h.is(id)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=zh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Hu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(cd)!=i.state.facet(cd)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(py))try{d(i)}catch(h){li(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!BA(this,c)&&u.force&&Ta(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Lk(this,e),this.plugins=e.facet(ha).map(r=>new hm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Sk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ha),r=e.state.facet(ha);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new hm(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(gA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return li(this.state,p),jk}}),f=Dh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(py))l(n)}get themeClasses(){return wy+" "+(this.state.facet(vy)?QA:JA)+" "+this.state.facet(cd)}updateAttrs(){let e=Hk(this,IA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Rs)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Hk(this,vw,n);let r=this.observer.ignore(()=>{let i=yk(this.contentDOM,this.contentAttrs,n),s=yk(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(Ke.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Hu);let e=this.state.facet(Ke.cspNonce);Ro.mount(this.root,this.styleModules.concat(UU).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return ym(this,e,Ck(this,e,n,r))}moveByGroup(e,n){return ym(this,e,Ck(this,e,n,r=>sU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return he.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return iU(this,e,n,r)}moveVertically(e,n,r){return ym(this,e,oU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=my(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),my(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[os.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==mn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(RA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>YU)return bA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||xA(s.isolates,r=xk(this,e))))return s.order;r||(r=xk(this,e));let i=RV(e.text,n,r);return this.bidiCache.push(new zh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{pA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return id.of(new Ea(typeof e=="number"?he.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return id.of(new Ea(he.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return gi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return gi.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Ro.newName(),i=[cd.of(r),Hu.of(xy(`.${r}`,e))];return n&&n.dark&&i.push(vy.of(!0)),i}static baseTheme(e){return cw.lowest(Hu.of(xy("."+wy,e,ZA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&yn.get(r)||yn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ke.styleModule=Hu;Ke.inputHandler=AA;Ke.clipboardInputFilter=mw;Ke.clipboardOutputFilter=yw;Ke.scrollHandler=OA;Ke.focusChangeEffect=MA;Ke.perLineTextDirection=RA;Ke.exceptionSink=EA;Ke.updateListener=py;Ke.editable=Rs;Ke.mouseSelectionStyle=TA;Ke.dragMovesSelection=CA;Ke.clickAddsSelectionRange=SA;Ke.decorations=Pp;Ke.blockWrappers=NA;Ke.outerDecorations=ww;Ke.atomicRanges=of;Ke.bidiIsolatedRanges=DA;Ke.cursorScrollMargin=je.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});Ke.scrollMargins=_A;Ke.darkTheme=vy;Ke.cspNonce=je.define({combine:t=>t.length?t[0]:""});Ke.contentAttributes=vw;Ke.editorAttributes=IA;Ke.lineWrapping=Ke.contentAttributes.of({class:"cm-lineWrapping"});Ke.announce=qt.define();const YU=4096,jk={};class zh{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:mn.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&hw(o,n)}return n}const JU=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function QU(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let co=null;const t7=4e3;function n7(t,e=JU){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>QU(g,e));for(let g=1;g{let k=co={view:w,prefix:y,scope:o};return setTimeout(()=>{co==k&&(co=null)},t7),!0}]})}let m=p.join(" ");i(m,!1);let x=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,by))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let by=null;function r7(t,e,n,r){by=e;let i=pV(e),s=Y9(i,0),o=J9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;co&&co.view==n&&co.scope==r&&(l=co.prefix+" ",WA.indexOf(e.keyCode)<0&&(u=!0,co=null));let f=new Set,d=x=>{if(x){for(let g of x.run)if(!f.has(g)&&(f.add(g),g(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,m;return h&&(d(h[l+fd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Oo[e.keyCode])&&p!=i?(d(h[l+fd(p,e,!0)])||e.shiftKey&&(m=Dc[e.keyCode])!=i&&m!=p&&d(h[l+fd(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+fd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),by=null,a}class i7 extends nu{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?ac(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Fc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function s7(t){let e=gi.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Vt.set([Vt.widget({widget:new i7(t),side:1}).range(0)]):Vt.none}get decorations(){return this.view.state.doc.length?Vt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Ke.contentAttributes.of({"aria-placeholder":t})]:e}const dd="-10000px";class tM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function o7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const xm=je.define({combine:t=>{var e,n,r;return{position:Me.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||o7}}}),Vk=new WeakMap,nM=gi.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(xm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new tM(t,rM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(xm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=dd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Me.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=xw(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(xm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=dd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,x=(e=Vk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||a7,y=this.view.textDirection==mn.LTR,w=d.width>r.right-r.left?y?r.left:r.right-d.width:y?Math.max(r.left,Math.min(f.left-(h?14:0)+g.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(h?14:0)-g.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-g.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(bw&&A.topS&&(S=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-t.parent.top)/s+"px",Uk(c,(w-t.parent.left)/i)):(c.style.top=S/s+"px",Uk(c,w/i)),h){let A=f.left+(y?g.x:-g.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:S,right:T,bottom:S+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=dd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Uk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const l7=Ke.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),a7={x:0,y:0},rM=je.define({enables:[nM,l7]}),Bh=je.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class _p{static create(e){return new _p(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new tM(e,Bh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const u7=rM.compute([Bh],t=>{let e=t.facet(Bh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:_p.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),c7=je.define();class f7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==mn.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>li(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(nM),n=e?e.manager.tooltips.findIndex(r=>r.create==_p.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!d7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!h7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const hd=4;function d7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-hd&&e.clientX<=r+hd&&e.clientY>=i-hd&&e.clientY<=s+hd}function h7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function p7(t,e={}){let n=qt.define(),r=new WeakMap,i=ms.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Sr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(g7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Bh.from(o)});const s=gi.define(o=>new f7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,c7.of(s),u7]}}const g7=qt.define(),Kk=je.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),m7=gi.fromClass(class{constructor(t){this.input=t.state.facet(ky),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Kk);this.top=new pd(t,!0,e.topContainer),this.bottom=new pd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Kk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new pd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new pd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(ky);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ke.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class pd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Xk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Xk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Xk(t){let e=t.nextSibling;return t.remove(),e}const ky=je.define({enables:m7});class Ha extends xl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ha.prototype.elementClass="";Ha.prototype.toDOM=void 0;Ha.prototype.mapMode=Sr.TrackBefore;Ha.prototype.startSide=Ha.prototype.endSide=-1;Ha.prototype.point=!0;const iM=1024;let y7=0;class bm{constructor(e,n){this.from=e,this.to=n}}class Tt{constructor(e={}){this.id=y7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Or.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class fc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const v7=Object.create(null);class Or{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):v7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Or(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Or.none=new Or("",Object.create(null),0,8);class Cw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|gn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Aw(Or.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Tn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Tn(Or.none,n,r,i)))}static build(e){return k7(e)}}Tn.empty=new Tn(Or.none,[],[],0);class Tw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Tw(this.buffer,this.index)}}class Io{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Or.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function zc(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&gn.EnterBracketed&&c instanceof Tn&&(d=fc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!sM(i,r,f,f+c.length))){if(c instanceof Io){if(s&gn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new mo(new w7(o,c,e,f),null,h)}else if(s&gn.IncludeAnonymous||!c.type.isAnonymous||Ew(c)){let h;if(!(s&gn.IgnoreMounts)&&(h=fc.get(c))&&!h.overlay)return new di(h.tree,f,e,o);let p=new di(c,f,e,o);return s&gn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&gn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&gn.IgnoreOverlays)&&(i=fc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&gn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new di(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function qk(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function Sy(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class w7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class mo extends oM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new mo(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&gn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new mo(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new mo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new mo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function lM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new di(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(zc(l,e,n,!1))}}return i?lM(i):r}class Cy{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~gn.EnterBracketed,e instanceof di)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof di?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&gn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&gn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&gn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&gn.IncludeAnonymous||l instanceof Io||!l.type.isAnonymous||Ew(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return Sy(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Ew(t){return t.children.some(e=>e instanceof Io||!e.type.isAnonymous||Ew(e))}function k7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=iM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Tw(n,n.length):n,a=r.types,u=0,c=0;function f(b,S,T,A,M,O){let{id:_,start:P,end:I,size:D}=l,ee=c,ie=u;if(D<0)if(l.next(),D==-1){let N=s[_];T.push(N),A.push(P-b);return}else if(D==-3){u=_;return}else if(D==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${D}`);let te=a[_],W,V,R=P-b;if(I-P<=i&&(V=x(l.pos-S,M))){let N=new Uint16Array(V.size-V.skip),L=l.pos-V.size,H=N.length;for(;l.pos>L;)H=g(V.start,N,H);W=new Io(N,I-V.start,r),R=V.start-b}else{let N=l.pos-D;l.next();let L=[],H=[],G=_>=o?_:-1,B=0,le=I;for(;l.pos>N;)G>=0&&l.id==G&&l.size>=0?(l.end<=le-i&&(p(L,H,P,B,l.end,le,G,ee,ie),B=L.length,le=l.end),l.next()):O>2500?d(P,N,L,H):f(P,N,L,H,G,O+1);if(G>=0&&B>0&&B-1&&B>0){let me=h(te,ie);W=Aw(te,L,H,0,L.length,0,I-P,me,me)}else W=m(te,L,H,I-P,ee-I,ie)}T.push(W),A.push(R)}function d(b,S,T,A){let M=[],O=0,_=-1;for(;l.pos>S;){let{id:P,start:I,end:D,size:ee}=l;if(ee>4)l.next();else{if(_>-1&&I<_)break;_<0&&(_=D-i),M.push(P,I,D),O++,l.next()}}if(O){let P=new Uint16Array(O*4),I=M[M.length-2];for(let D=M.length-3,ee=0;D>=0;D-=3)P[ee++]=M[D],P[ee++]=M[D+1]-I,P[ee++]=M[D+2]-I,P[ee++]=ee;T.push(new Io(P,M[2]-I,r)),A.push(I-b)}}function h(b,S){return(T,A,M)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Tn){if(!_&&P.type==b&&P.length==M)return P;(I=P.prop(Tt.lookAhead))&&(O=A[_]+P.length+I)}return m(b,T,A,M,O,S)}}function p(b,S,T,A,M,O,_,P,I){let D=[],ee=[];for(;b.length>A;)D.push(b.pop()),ee.push(S.pop()+T-M);b.push(m(r.types[_],D,ee,O-M,P-O,I)),S.push(M-T)}function m(b,S,T,A,M,O,_){if(O){let P=[Tt.contextHash,O];_=_?[P].concat(_):[P]}if(M>25){let P=[Tt.lookAhead,M];_=_?[P].concat(_):[P]}return new Tn(b,S,T,A,_)}function x(b,S){let T=l.fork(),A=0,M=0,O=0,_=T.end-i,P={size:0,start:0,skip:0};e:for(let I=T.pos-b;T.pos>I;){let D=T.size;if(T.id==S&&D>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let ee=T.pos-D;if(D<0||ee=o?4:0,te=T.start;for(T.next();T.pos>ee;){if(T.size<0)if(T.size==-3||T.size==-4)ie+=4;else break e;else T.id>=o&&(ie+=4);T.next()}M=te,A+=D,O+=ie}return(S<0||A==b)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function g(b,S,T){let{id:A,start:M,end:O,size:_}=l;if(l.next(),_>=0&&A4){let I=l.pos-(_-4);for(;l.pos>I;)T=g(b,S,T)}S[--T]=P,S[--T]=O-b,S[--T]=M-b,S[--T]=A}else _==-3?u=A:_==-4&&(c=A);return T}let y=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new Tn(a[t.topID],y.reverse(),w.reverse(),k)}const Yk=new WeakMap;function Bd(t,e){if(!t.isAnonymous||e instanceof Io||e.type!=t)return 1;let n=Yk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Tn)){n=1;break}n+=Bd(t,r)}Yk.set(e,n)}return n}function Aw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;S+=T}if(w==k+1){if(S>c){let T=p[k];h(T.children,T.positions,0,T.children.length,m[k]+y);continue}f.push(p[k])}else{let T=m[w-1]+p[w-1].length-b;f.push(Aw(t,p,m,k,w,b,T,null,a))}d.push(b+y-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class hl{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new hl(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new hl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew bm(i.from,i.to)):[new bm(0,0)]:[new bm(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class S7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});let C7=0;class ii{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=C7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof ii&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new ii(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new jh(e);return r=>r.modified.indexOf(n)>-1?r:jh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let T7=0;class jh{constructor(e){this.name=e,this.instances=[],this.id=T7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&E7(n,l.modified));if(r)return r;let i=[],s=new ii(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=A7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(jh.get(l,a));return s}}function E7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function A7(t){let e=[[]];for(let n=0;nr.length-n.length)}function uM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Bc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return cM.add(e)}const cM=new Tt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Bc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Bc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function M7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function R7(t,e,n,r=0,i=t.length){let s=new O7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class O7{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=P7(e)||Bc.empty,f=M7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(Tt.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(d.tree.type)),m=e.firstChild();for(let x=0,g=l;;x++){let y=x=w||!e.nextSibling())););if(!y||w>r)break;g=y.to+l,g>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+l),Math.min(r,g),"",p),this.startSpan(Math.min(r,g),u))}m&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function P7(t){let e=t.type.prop(cM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=ii.define,md=we(),so=we(),Jk=we(so),Qk=we(so),oo=we(),yd=we(oo),km=we(oo),Qi=we(),Yo=we(Qi),Yi=we(),Ji=we(),Ty=we(),Iu=we(Ty),vd=we(),Ue={comment:md,lineComment:we(md),blockComment:we(md),docComment:we(md),name:so,variableName:we(so),typeName:Jk,tagName:we(Jk),propertyName:Qk,attributeName:we(Qk),className:we(so),labelName:we(so),namespace:we(so),macroName:we(so),literal:oo,string:yd,docString:we(yd),character:we(yd),attributeValue:we(yd),number:km,integer:we(km),float:we(km),bool:we(oo),regexp:we(oo),escape:we(oo),color:we(oo),url:we(oo),keyword:Yi,self:we(Yi),null:we(Yi),atom:we(Yi),unit:we(Yi),modifier:we(Yi),operatorKeyword:we(Yi),controlKeyword:we(Yi),definitionKeyword:we(Yi),moduleKeyword:we(Yi),operator:Ji,derefOperator:we(Ji),arithmeticOperator:we(Ji),logicOperator:we(Ji),bitwiseOperator:we(Ji),compareOperator:we(Ji),updateOperator:we(Ji),definitionOperator:we(Ji),typeOperator:we(Ji),controlOperator:we(Ji),punctuation:Ty,separator:we(Ty),bracket:Iu,angleBracket:we(Iu),squareBracket:we(Iu),paren:we(Iu),brace:we(Iu),content:Qi,heading:Yo,heading1:we(Yo),heading2:we(Yo),heading3:we(Yo),heading4:we(Yo),heading5:we(Yo),heading6:we(Yo),contentSeparator:we(Qi),list:we(Qi),quote:we(Qi),emphasis:we(Qi),strong:we(Qi),link:we(Qi),monospace:we(Qi),strikethrough:we(Qi),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:vd,documentMeta:we(vd),annotation:we(vd),processingInstruction:we(vd),definition:ii.defineModifier("definition"),constant:ii.defineModifier("constant"),function:ii.defineModifier("function"),standard:ii.defineModifier("standard"),local:ii.defineModifier("local"),special:ii.defineModifier("special")};for(let t in Ue){let e=Ue[t];e instanceof ii&&(e.name=t)}fM([{tag:Ue.link,class:"tok-link"},{tag:Ue.heading,class:"tok-heading"},{tag:Ue.emphasis,class:"tok-emphasis"},{tag:Ue.strong,class:"tok-strong"},{tag:Ue.keyword,class:"tok-keyword"},{tag:Ue.atom,class:"tok-atom"},{tag:Ue.bool,class:"tok-bool"},{tag:Ue.url,class:"tok-url"},{tag:Ue.labelName,class:"tok-labelName"},{tag:Ue.inserted,class:"tok-inserted"},{tag:Ue.deleted,class:"tok-deleted"},{tag:Ue.literal,class:"tok-literal"},{tag:Ue.string,class:"tok-string"},{tag:Ue.number,class:"tok-number"},{tag:[Ue.regexp,Ue.escape,Ue.special(Ue.string)],class:"tok-string2"},{tag:Ue.variableName,class:"tok-variableName"},{tag:Ue.local(Ue.variableName),class:"tok-variableName tok-local"},{tag:Ue.definition(Ue.variableName),class:"tok-variableName tok-definition"},{tag:Ue.special(Ue.variableName),class:"tok-variableName2"},{tag:Ue.definition(Ue.propertyName),class:"tok-propertyName tok-definition"},{tag:Ue.typeName,class:"tok-typeName"},{tag:Ue.namespace,class:"tok-namespace"},{tag:Ue.className,class:"tok-className"},{tag:Ue.macroName,class:"tok-macroName"},{tag:Ue.propertyName,class:"tok-propertyName"},{tag:Ue.operator,class:"tok-operator"},{tag:Ue.comment,class:"tok-comment"},{tag:Ue.meta,class:"tok-meta"},{tag:Ue.invalid,class:"tok-invalid"},{tag:Ue.punctuation,class:"tok-punctuation"}]);var Sm;const pa=new Tt;function I7(t){return je.define({combine:t?e=>e.concat(t):void 0})}const N7=new Tt;class Di{constructor(e,n,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return hs(this)}}),this.parser=n,this.extension=[Va.of(this),$t.languageData.of((s,o,l)=>{let a=Zk(s,o,l),u=a.type.prop(pa);if(!u)return[];let c=s.facet(u),f=a.type.prop(N7);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Zk(e,n,r).type.prop(pa)==this.data}findRegions(e){let n=e.facet(Va);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(pa)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Tt.mounted);if(l){if(l.tree.prop(pa)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new Hh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function hs(t){let e=t.field(Di.state,!1);return e?e.tree:Tn.empty}class D7{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Nu=null;class Wh{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Wh(e,n,[],Tn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new D7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(hl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Nu;Nu=this;try{return e()}finally{Nu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=eS(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=hl.applyChanges(r,a),i=Tn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=eS(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends aM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Nu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Tn(Or.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Nu}}function eS(t,e,n){return hl.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Wa{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Wa(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Wh.create(e.facet(Va).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wa(r)}}Di.state=ms.define({create:Wa.init,update(t,e){for(let n of e.effects)if(n.is(Di.setState))return n.value;return e.startState.facet(Va)!=e.state.facet(Va)?Wa.init(e.state):t.apply(e)}});let dM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(dM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Cm=typeof navigator<"u"&&(!((Sm=navigator.scheduling)===null||Sm===void 0)&&Sm.isInputPending)?()=>navigator.scheduling.isInputPending():null,_7=gi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Di.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Di.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=dM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Cm&&Cm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Di.setState.of(new Wa(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>li(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Va=je.define({combine(t){return t.length?t[0]:null},enables:t=>[Di.state,_7,Ke.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class L7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const F7=je.define(),Mw=je.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Vh(t){let e=t.facet(Mw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Uh(t,e){let n="",r=t.tabSize,i=t.facet(Mw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?$7(t,n,e):null}class Lp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Vh(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Rp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const pM=new Tt;function $7(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return gM(r,t,n)}function gM(t,e,n){for(let r=t;r;r=r.next){let i=B7(r.node);if(i)return i(Rw.create(e,n,r))}return 0}function z7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function B7(t){let e=t.type.prop(pM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Tt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>V7(o,!0,1,void 0,s&&!z7(o)?i.from:void 0)}return t.parent==null?j7:null}function j7(){return 0}class Rw extends Lp{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Rw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(H7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return gM(this.context.next,this.base,this.pos)}}function H7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function W7(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function V7(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=W7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function tS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const U7=new Tt;function K7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(pa)==o.data:o?l=>l==o:void 0,this.style=fM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Ro(r):null,this.themeType=n.themeType}static define(e,n){return new Fp(e,n||{})}}const Ey=je.define(),X7=je.define({combine(t){return t.length?[t[0]]:null}});function Tm(t){let e=t.facet(Ey);return e.length?e:t.facet(X7)}function nS(t,e){let n=[q7],r;return t instanceof Fp&&(t.module&&n.push(Ke.styleModule.of(t.module)),r=t.themeType),r?n.push(Ey.computeN([Ke.darkTheme],i=>i.facet(Ke.darkTheme)==(r=="dark")?[t]:[])):n.push(Ey.of(t)),n}class G7{constructor(e){this.markCache=Object.create(null),this.tree=hs(e.state),this.decorations=this.buildDeco(e,Tm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=hs(e.state),r=Tm(e.state),i=r!=Tm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Vt.none;let r=new $a;for(let{from:i,to:s}of e.visibleRanges)R7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Vt.mark({class:a})))},i,s);return r.finish()}}const q7=cw.high(gi.fromClass(G7,{decorations:t=>t.decorations})),Y7=1e4,J7="()[]{}",Q7=new Tt;function Ay(t,e,n){let r=t.prop(e<0?Tt.openedBy:Tt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function My(t){let e=t.type.prop(Q7);return e?e(t.node):t}function ga(t,e,n,r={}){let i=r.maxScanDistance||Y7,s=r.brackets||J7,o=hs(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ay(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return Z7(t,e,n,a,c,u,s)}}return eK(t,e,n,o,l.type,i,s)}function Z7(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let m=n>0?0:h.length-1,x=n>0?h.length:-1;m!=x;m+=n){let g=o.indexOf(h[m]);if(!(g<0||r.resolveInner(p+m,1).type!=i))if(g%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const tK=Object.create(null),rS=[Or.none],iS=[],sS=Object.create(null),nK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])nK[t]=rK(tK,e);function Em(t,e){iS.indexOf(t)>-1||(iS.push(t),console.warn(e))}function rK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ue[u];c?typeof c=="function"?a.length?a=a.map(c):Em(u,`Modifier ${u} used at start of tag`):a.length?Em(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Em(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=sS[i];if(s)return s.id;let o=sS[i]=Or.define({id:rS.length,name:r,props:[uM({[r]:n})]});return rS.push(o),o.id}mn.RTL,mn.LTR;const iK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Pw(t.state,n.from);return r.line?sK(t):r.block?lK(t):!1};function Ow(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const sK=Ow(cK,0),oK=Ow(mM,0),lK=Ow((t,e)=>mM(t,e,uK(e)),0);function Pw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Du=50;function aK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Du,r),o=t.sliceDoc(i,i+Du),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Du?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Du),f=t.sliceDoc(i-Du,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function uK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function mM(t,e,n=e.selection.ranges){let r=n.map(s=>Pw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>aK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const Ry=Fo.define(),fK=Fo.define(),dK=je.define(),yM=je.define({combine(t){return iA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),vM=ms.define({create(){return ls.empty},update(t,e){let n=e.state.facet(yM),r=e.annotation(Ry);if(r){let a=Er.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Kh(c,c.length,n.minDepth,a):c=bM(c,e.startState.selection),new ls(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(fK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation($n.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Er.fromTransaction(e),o=e.annotation($n.time),l=e.annotation($n.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new ls(t.done.map(Er.fromJSON),t.undone.map(Er.fromJSON))}});function hK(t={}){return[vM,yM.of(t),Ke.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?wM:e.inputType=="historyRedo"?Oy:null;return r?(e.preventDefault(),r(n)):!1}})]}function $p(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(vM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const wM=$p(0,!1),Oy=$p(1,!1),pK=$p(0,!0),gK=$p(1,!0);class Er{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Er(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Er(e.changes&&_n.fromJSON(e.changes),[],e.mapped&&ds.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=ui;for(let i of e.startState.facet(dK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Er(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ui)}static selection(e){return new Er(void 0,ui,void 0,void 0,e)}}function Kh(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function mK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function yK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function xM(t,e){return t.length?e.length?t.concat(e):t:e}const ui=[],vK=200;function bM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-vK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Kh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Er.selection([e])]}function wK(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Am(t,e){if(!t.length)return t;let n=t.length,r=ui;for(;n;){let i=xK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Er.selection(r)]:ui}function xK(t,e,n){let r=xM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ui,n);if(!t.changes)return Er.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Er(i,qt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const bK=/^(input\.type|delete)($|\.)/;class ls{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new ls(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||bK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):zp(n,e))}function lr(t){return t.textDirectionAt(t.state.selection.main.head)==mn.LTR}const SM=t=>kM(t,!lr(t)),CM=t=>kM(t,lr(t));function TM(t,e){return Wi(t,n=>n.empty?t.moveByGroup(n,e):zp(n,e))}const SK=t=>TM(t,!lr(t)),CK=t=>TM(t,lr(t));function TK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Bp(t,e,n){let r=hs(t).resolveInner(e.head),i=n?Tt.closedBy:Tt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;TK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ga(t,r.from,1):ga(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,he.cursor(l,n?-1:1)}const EK=t=>Wi(t,e=>Bp(t.state,e,!lr(t))),AK=t=>Wi(t,e=>Bp(t.state,e,lr(t)));function EM(t,e){return Wi(t,n=>{if(!n.empty)return zp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const AM=t=>EM(t,!1),MM=t=>EM(t,!0);function RM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):zp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomOM(t,!1),Py=t=>OM(t,!0);function $o(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=he.cursor(r.from+s))}return i}const MK=t=>Wi(t,e=>$o(t,e,!0)),RK=t=>Wi(t,e=>$o(t,e,!1)),OK=t=>Wi(t,e=>$o(t,e,!lr(t))),PK=t=>Wi(t,e=>$o(t,e,lr(t))),IK=t=>Wi(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),NK=t=>Wi(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function DK(t,e,n){let r=!1,i=ru(t.selection,s=>{let o=ga(t,s.head,-1)||ga(t,s.head,1)||s.head>0&&ga(t,s.head-1,1)||s.headDK(t,e);function mi(t,e,n){let r=ru(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=he.range(i.head,i.anchor));let s=n(i);return he.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Hi(t.state,r)),!0)}function PM(t,e){return mi(t,e,n=>t.moveByChar(n,e))}const IM=t=>PM(t,!lr(t)),NM=t=>PM(t,lr(t));function DM(t,e){return mi(t,e,n=>t.moveByGroup(n,e))}const LK=t=>DM(t,!lr(t)),FK=t=>DM(t,lr(t)),$K=t=>{let e=!lr(t);return mi(t,e,n=>Bp(t.state,n,e))},zK=t=>{let e=lr(t);return mi(t,e,n=>Bp(t.state,n,e))};function _M(t,e){return mi(t,e,n=>t.moveVertically(n,e))}const LM=t=>_M(t,!1),FM=t=>_M(t,!0);function $M(t,e){return mi(t,e,n=>t.moveVertically(n,e,RM(t).height))}const lS=t=>$M(t,!1),aS=t=>$M(t,!0),BK=t=>mi(t,!0,e=>$o(t,e,!0)),jK=t=>mi(t,!1,e=>$o(t,e,!1)),HK=t=>{let e=!lr(t);return mi(t,e,n=>$o(t,n,e))},WK=t=>{let e=lr(t);return mi(t,e,n=>$o(t,n,e))},VK=t=>mi(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),UK=t=>mi(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),uS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:0})),!0),cS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.doc.length})),!0),fS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.selection.main.anchor,head:0})),!0),dS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),KK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),XK=({state:t,dispatch:e})=>{let n=jp(t).map(({from:r,to:i})=>he.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:he.create(n),userEvent:"select"})),!0},GK=({state:t,dispatch:e})=>{let n=ru(t.selection,r=>{let i=hs(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return he.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Hi(t,n)),!0)};function zM(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(Hi(n,he.create(i,i.length-1))),!0)}const qK=t=>zM(t,!1),YK=t=>zM(t,!0),JK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=he.create([n.main]):n.main.empty||(r=he.create([he.cursor(n.main.head)])),r?(e(Hi(t,r)),!0):!1};function lf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=wd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=wd(t,o,!1),l=wd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:he.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const BM=(t,e,n)=>lf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iBM(t,!1,!0),jM=t=>BM(t,!0,!1),HM=(t,e)=>lf(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=sr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),WM=t=>HM(t,!1),QK=t=>HM(t,!0),ZK=t=>lf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headlf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),tX=t=>lf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Dt.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},rX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:sr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:sr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:he.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function jp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function VM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of jp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(he.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(he.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:he.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const iX=({state:t,dispatch:e})=>VM(t,e,!1),sX=({state:t,dispatch:e})=>VM(t,e,!0);function UM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of jp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const oX=({state:t,dispatch:e})=>UM(t,e,!1),lX=({state:t,dispatch:e})=>UM(t,e,!0),aX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(jp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function uX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=hs(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Tt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const hS=KM(!1),cX=KM(!0);function KM(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&uX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Lp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=hM(u,s);for(c==null&&(c=Rp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:he.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const fX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Lp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Iw(t,(s,o,l)=>{let a=hM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Uh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(Iw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Mw)})}),{userEvent:"input.indent"})),!0),GM=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Iw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Rp(i,t.tabSize),o=0,l=Uh(t,Math.max(0,s-Vh(t)));for(;o(t.setTabFocusMode(),!0),hX=[{key:"Ctrl-b",run:SM,shift:IM,preventDefault:!0},{key:"Ctrl-f",run:CM,shift:NM},{key:"Ctrl-p",run:AM,shift:LM},{key:"Ctrl-n",run:MM,shift:FM},{key:"Ctrl-a",run:IK,shift:VK},{key:"Ctrl-e",run:NK,shift:UK},{key:"Ctrl-d",run:jM},{key:"Ctrl-h",run:Iy},{key:"Ctrl-k",run:ZK},{key:"Ctrl-Alt-h",run:WM},{key:"Ctrl-o",run:nX},{key:"Ctrl-t",run:rX},{key:"Ctrl-v",run:Py}],pX=[{key:"ArrowLeft",run:SM,shift:IM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:SK,shift:LK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:OK,shift:HK,preventDefault:!0},{key:"ArrowRight",run:CM,shift:NM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:CK,shift:FK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:PK,shift:WK,preventDefault:!0},{key:"ArrowUp",run:AM,shift:LM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:uS,shift:fS},{mac:"Ctrl-ArrowUp",run:oS,shift:lS},{key:"ArrowDown",run:MM,shift:FM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cS,shift:dS},{mac:"Ctrl-ArrowDown",run:Py,shift:aS},{key:"PageUp",run:oS,shift:lS},{key:"PageDown",run:Py,shift:aS},{key:"Home",run:RK,shift:jK,preventDefault:!0},{key:"Mod-Home",run:uS,shift:fS},{key:"End",run:MK,shift:BK,preventDefault:!0},{key:"Mod-End",run:cS,shift:dS},{key:"Enter",run:hS,shift:hS},{key:"Mod-a",run:KK},{key:"Backspace",run:Iy,shift:Iy,preventDefault:!0},{key:"Delete",run:jM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:WM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QK,preventDefault:!0},{mac:"Mod-Backspace",run:eX,preventDefault:!0},{mac:"Mod-Delete",run:tX,preventDefault:!0}].concat(hX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),gX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:EK,shift:$K},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:AK,shift:zK},{key:"Alt-ArrowUp",run:iX},{key:"Shift-Alt-ArrowUp",run:oX},{key:"Alt-ArrowDown",run:sX},{key:"Shift-Alt-ArrowDown",run:lX},{key:"Mod-Alt-ArrowUp",run:qK},{key:"Mod-Alt-ArrowDown",run:YK},{key:"Escape",run:JK},{key:"Mod-Enter",run:cX},{key:"Alt-l",mac:"Ctrl-l",run:XK},{key:"Mod-i",run:GK,preventDefault:!0},{key:"Mod-[",run:GM},{key:"Mod-]",run:XM},{key:"Mod-Alt-\\",run:fX},{key:"Shift-Mod-k",run:aX},{key:"Shift-Mod-\\",run:_K},{key:"Mod-/",run:iK},{key:"Alt-A",mac:"Ctrl-A",run:oK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:dX}].concat(pX),mX={key:"Tab",run:XM,shift:GM};var pS={};class Xh{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Xh(e,[],n,r,r,0,[],0,i?new gS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Xh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new yX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class gS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class yX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Gh{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Gh(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gh(this.stack,this.pos,this.index)}}function xd(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class jd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const mS=new jd;class vX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=mS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Aa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;wX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Aa.prototype.contextual=Aa.prototype.fallback=Aa.prototype.extend=!1;Aa.prototype.fallback=Aa.prototype.extend=!1;function wX(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||xX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function yS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function xX(t,e,n,r){let i=yS(n,r,e);return i<0||yS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class bX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?vS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?vS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Tn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class kX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new jd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new jd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new jd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new bX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&TX(i);if(o)return $r&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw $r&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return $r&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(Tt.contextHash)||0)==c))return e.useNode(f,d),$r&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Tn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Tn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),$r&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return wS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),$r&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&($r&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)$r&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))$r&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),$r&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),wS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Cw(n.map((l,a)=>Or.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iM;let o=xd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Aa(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new SX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=As(this.data,s+2);else break;i=n(As(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=As(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(qh.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=xS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const EX=uM({String:Ue.string,Number:Ue.number,"True False":Ue.bool,PropertyName:Ue.propertyName,Null:Ue.null,", :":Ue.separator,"[ ]":Ue.squareBracket,"{ }":Ue.brace}),AX=qh.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[EX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),MX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=RX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function RX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const OX=Hh.define({name:"json",parser:AX.configure({props:[pM.add({Object:tS({except:/^\s*\}/}),Array:tS({except:/^\s*\]/})}),U7.add({"Object Array":K7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function bS(){return new L7(OX)}class kS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class il{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(as).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new $a,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),h++}for(;hw.from||w.to==m))l.push(w),h++,x=Math.min(w.to,x);else{x=Math.min(w.from,x);break}}x=Math.min(x,f);let g=!1;if(l.some(w=>w.from==m&&(w.to==x||x==f))&&(g=m==x,!g&&x-m<10)){let w=m-(c+u.value.length);w>0&&(u.next(w),c=m);for(let k=m;;){if(k>=x){g=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=VX(l);if(g)o.add(m,m,Vt.widget({widget:new BX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Vt.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new kS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new kS(r.from,s,r.diagnostic)}}),r}function PX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(as).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Nw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function IX(t,e){return t.field(_i,!1)?e:e.concat(qt.appendConfig.of(ZM))}function NX(t,e){return{effects:IX(t,[Nw.of(e)])}}const Nw=qt.define(),qM=qt.define(),YM=qt.define(),_i=ms.define({create(){return new il(Vt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=Ua(n,t.selected.diagnostic,s)||Ua(n,null,s)}!n.size&&i&&e.state.facet(as).autoPanel&&(i=null),t=new il(n,i,r)}for(let n of e.effects)if(n.is(Nw)){let r=e.state.facet(as).autoPanel?n.value.length?Yh.open:null:t.panel;t=il.init(n.value,r,e.state)}else n.is(qM)?t=new il(t.diagnostics,n.value?Yh.open:null,t.selected):n.is(YM)&&(t=new il(t.diagnostics,t.panel,n.value));return t},provide:t=>[ky.from(t,e=>e.panel),Ke.decorations.from(t,e=>e.diagnostics)]}),DX=Vt.mark({class:"cm-lintRange cm-lintRange-active"});function _X(t,e,n){let{diagnostics:r}=t.state.field(_i),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(eQM(t,n,!1)))}const SS=t=>{let e=t.state.field(_i,!1);return!e||!e.panel?!1:(t.dispatch({effects:qM.of(!1)}),!0)},FX=gi.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(as);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(NX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{li(this.view.state,r)})}}update(t){let e=t.state.facet(as);(t.docChanged||e!=t.startState.facet(as)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function $X(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const as=je.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...iA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:CS,tooltipFilter:CS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function CS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function zX(t,e={}){return[as.of({source:t,config:e}),FX,ZM]}function JM(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function QM(t,e,n){var r;let i=n?JM(e.actions):[];return ns("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ns("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=Ua(t.state.field(_i).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),ns("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return ns("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&ns("div",{class:"cm-diagnosticSource"},e.source))}class BX extends nu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ns("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class TS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QM(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Yh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)SS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=JM(s.actions);for(let l=0;l{for(let s=0;sSS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(_i).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(_i),r=Ua(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:YM.of(r)})}static open(e){return new Yh(e)}}function jX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function bd(t){return jX(``,'width="6" height="3"')}const HX=Ke.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:bd("#f11")},".cm-lintRange-warning":{backgroundImage:bd("orange")},".cm-lintRange-info":{backgroundImage:bd("#999")},".cm-lintRange-hint":{backgroundImage:bd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function WX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function VX(t){let e="hint",n=1;for(let r of t){let i=WX(r.severity);i>n&&(n=i,e=r.severity)}return e}const UX=p7(_X,{hideOn:PX}),ZM=[_i,Ke.decorations.compute([_i],t=>{let{selected:e,panel:n}=t.field(_i);return!e||!n||e.from==e.to?Vt.none:Vt.set([DX.range(e.from,e.to)])}),UX,HX],KX=512*1024,ES=512*1024,eR=2e6;function XX(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` +`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const GX=t=>t.state.doc.length>KX?[]:MX()(t);function AS(t){return Fp.define([{tag:Ue.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ue.string,color:t?"#86efac":"#15803d"},{tag:Ue.number,color:t?"#fcd34d":"#b45309"},{tag:Ue.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ue.null,color:t?"#a1a1aa":"#71717a"}])}const qX=Ke.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function tR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=v.useRef(null),c=v.useRef(null),f=v.useRef(e);f.current=e;const d=v.useRef(i),h=v.useRef(null),p=v.useRef(null),m=v.useRef(null),x=n??e!==void 0,g=v.useRef(x),y=v.useRef(r),w=t.length>ES,k=v.useRef(w),b=!x&&t.length>eR,S=b?XX(t,ES):t,T=v.useRef(!1),A=v.useCallback((M,O,_)=>M?[Ke.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[zX(GX,{delay:300})]]:[$t.readOnly.of(!0),Ke.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new dl,_=new dl,P=new dl,I=$t.create({doc:S,extensions:[P.of(w||!r?[]:bS()),Ke.lineWrapping,hK(),eM.of([...gX,...kK,mX]),qX,O.of(nS(AS(i))),_.of(A(x,w,r)),...s?[s7(s)]:[]]}),D=new Ke({state:I,parent:M});return h.current=O,p.current=_,m.current=P,a==null||a(D),c.current=D,()=>{D.destroy(),c.current=null}},[]),v.useEffect(()=>{const M=c.current;if(!M)return;const O=m.current,_=p.current,P=[];(w!==k.current||r!==y.current)&&(k.current=w,y.current=r,O&&P.push(O.reconfigure(w||!r?[]:bS())),_&&P.push(_.reconfigure(A(x,w,r))));const I=M.state.doc.toString();if(!(I===S&&P.length===0)){T.current=!0;try{M.dispatch({...I!==S?{changes:{from:0,to:M.state.doc.length,insert:S}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[S,w,r,x,A]),v.useEffect(()=>{const M=c.current,O=p.current;!M||!O||x!==g.current&&(g.current=x,M.dispatch({effects:O.reconfigure(A(x,w,r))}))},[x,w,r,A]),v.useEffect(()=>{const M=c.current;if(!M||i===d.current)return;d.current=i;const O=h.current;O&&M.dispatch({effects:O.reconfigure(nS(AS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:hr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[b?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function nR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const ul="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Ny={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(m,x){var g=new RegExp(m,"g");h[m]=(d.match(g)||[]).length,p=!p||h[m]>h[p]?m:p}),p}function u(d){for(var h={},p=0;p=0;p--){var m=d[p];h[m]>0&&(m=m+"__"+h[m]--),x.unshift(m)}return x}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var m=[];try{o=h.trim!==!1;var m=f.parse(d,l[p])}catch(te){var x=d.lastIndexOf(` +`,te.offset),g=d.indexOf(` +`,te.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw te.message+" On line "+te.line+" and column "+te.column+`. +`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),S=0;Sy&&(y=g,w=[]),w.push(R))}function b(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function S(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function T(){var R,N,L,H;return L=g,H=g,R=function(G){return ee="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function A(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function M(){var R,N,L,H,G,B,le,me,ye;for(B=g,le=g,R=[],/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=O(),N!==null){if(L=[],me=g,ye=g,/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]")),G!==null)for(H=[];G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));else H=null;for(H!==null?(G=O(),G!==null?H=[H,G]:(H=null,g=ye)):(H=null,g=ye),H!==null&&(H=function(oe,be){return be}(me,H[1])),H===null&&(g=me);H!==null;){if(L.push(H),me=g,ye=g,/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]")),G!==null)for(H=[];G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));else H=null;H!==null?(G=O(),G!==null?H=[H,G]:(H=null,g=ye)):(H=null,g=ye),H!==null&&(H=function(oe,be){return be}(me,H[1])),H===null&&(g=me)}if(L!==null){for(H=[],/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));H!==null?R=[R,N,L,H]:(R=null,g=le)}else R=null,g=le}else R=null,g=le;else R=null,g=le;return R!==null&&(R=function(oe,be,Ce){return Ce.unshift(be),Ce}(B,R[1],R[2])),R===null&&(g=B),R}function O(){var R,N,L,H,G,B,le,me,ye;if(B=g,le=g,R=_(),R!==null){for(N=[],me=g,ye=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(oe,be){return be==ee}(g,L)?"":null,H!==null?(G=_(),G!==null?L=[L,H,G]:(L=null,g=ye)):(L=null,g=ye)):(L=null,g=ye),L!==null&&(L=function(oe,be,Ce){return Ce}(me,L[0],L[2])),L===null&&(g=me);L!==null;)N.push(L),me=g,ye=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(oe,be){return be==ee}(g,L)?"":null,H!==null?(G=_(),G!==null?L=[L,H,G]:(L=null,g=ye)):(L=null,g=ye)):(L=null,g=ye),L!==null&&(L=function(oe,be,Ce){return Ce}(me,L[0],L[2])),L===null&&(g=me);N!==null?(L=function(oe,be,Ce){return!!be||Ce.length}(g,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,g=le)):(R=null,g=le)}else R=null,g=le;return R!==null&&(R=function(oe,be,Ce){return Ce.unshift(be),Ce}(B,R[0],R[1])),R===null&&(g=B),R}function _(){var R,N,L,H,G,B;if(H=g,G=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null){for(N=[],L=P();L!==null;)N.push(L),L=P();N!==null?(p.charCodeAt(g)===34?(L='"',g++):(L=null,k('"\\""')),L!==null?R=[R,N,L]:(R=null,g=G)):(R=null,g=G)}else R=null,g=G;if(R!==null&&(R=function(le,me){return me.join("")}(H,R[1])),R===null&&(g=H),R===null){for(H=g,R=[],G=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(le,me){return me!=ee}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(le,me){return me}(G,N[0])),N===null&&(g=G);N!==null;)R.push(N),G=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(le,me){return me!=ee}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(le,me){return me}(G,N[0])),N===null&&(g=G);R!==null&&(R=function(le,me){return(o?me.join("").trim():me.join("")).replace(/(^")|("$)/g,"")}(H,R)),R===null&&(g=H)}return R}function P(){var R,N,L,H;return L=g,H=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(g)===34?(N='"',g++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G){return'"'}()),R===null&&(g=L),R===null&&(/^[^"]/.test(p.charAt(g))?(R=p.charAt(g),g++):(R=null,k('[^"]'))),R}function I(R){R.sort();for(var N=null,L=[],H=0;H=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function Li(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function oG(t){const e=(r,i,s)=>{for(const[o,l]of Object.entries(r)){const a=i?`${i}.${o}`:o;Li(l)&&Object.keys(l).length>0?e(l,a,s):Array.isArray(l)?s[a]=l.map(n):s[a]=l}},n=r=>{if(!Li(r))return r;const i={};return e(r,"",i),i};return Array.isArray(t)?t.map(n):Li(t)?n(t):t}function lG(t){const e=n=>{if(!Li(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(sG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):Li(t)?e(t):t}function aG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function uG(t,e,n){if(n==="string")return t;if(n==="number")return RS(t);if(n==="boolean")return aG(t);if(e.parseJSON){const r=iG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?RS(t):t}function cG(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=uG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>Li(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=Li(s)?n(s):s;return r}const fG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function iR(t){const e=fG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function _y(t){const e=new Set(t),n=new Map;for(const i of t){const s=iR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function OS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function PS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>iR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const m=d.get(p.index);m?m.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const m=d.get(p)??[],x={};for(const g of m){if(!g.subKey)continue;const y=t[g.column];OS(y,r)||(x[g.subKey]=y)}Object.keys(x).length>0&&h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const m=d.get(p);if(!m)continue;const x=t[m];OS(x,r)||h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function dG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!Li(r))return e;const i=Object.keys(r),s=_y(i);return s.length===0?e:e.map(o=>Li(o)?PS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!Li(r))return e;const i=Object.keys(r),s=_y(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=Li(a)?PS(a,i,s,n):a;return o}return e}function IS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(MS)?t.slice(MS.length):t;try{const i=JX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=cG(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?dG(i,s,n.emptyFields):s}catch(i){throw new Error(rR(i))}}function hG(t,e={}){try{const n=e.flatten?lG(oG(t)):t;return ZX(n,e)}catch(n){const r=rR(n);throw nG.some(i=>r.startsWith(i))?new eG(tG(r,e.flatten??!1)):new Error(r)}}function pG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const zr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},NS=["data","items","results","records","rows"];function dc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sR(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!dc(n))return[];const r=Object.keys(n),i=new Set(NS),s=[...NS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>dc(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function Dw(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function gG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=Dw(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function mG(t){const e=t.trim();if(e==="")return[];let n;try{n=JSON.parse(e)}catch{const o=Dw(e);if(o===null)return[];n=o}let r=[];if(Array.isArray(n)){if(n.length===0||!n.every(o=>dc(o)))return[];r=n}else if(dc(n)){if(sR(e).length>0)return[];r=[n]}else return[];const i=new Set,s=r.slice(0,50);for(const o of s)for(const[l,a]of Object.entries(o))(dc(a)||Array.isArray(a)&&a.length>0)&&i.add(l);return Array.from(i)}function yG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const DS=t=>t==="auto"?void 0:t;function vG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:u}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=Dw(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=DS(n.separator),s=hG(r,{separator:i,flatten:n.flatten}),o=nf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function bG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function _u({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:ul,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function kG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function SG(t){const e=t.slice(0,3).map(r=>`.${r}`).join(", "),n=t.length-3;return n>0?`${e}, +${n} more`:e}function CG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:m,onCellCommit:x,canUndo:g=!1,canRedo:y=!1,onUndo:w,onRedo:k,collapseIndexedArrays:b=!0,onToggleCollapseIndexedArrays:S,columnTypes:T,onChangeColumnTypes:A,flatten:M=!1,onToggleFlatten:O}){const[_,P]=v.useState(!1),[I,D]=v.useState(!1),ee=v.useRef(0),ie=v.useRef(null),te=e.trim()==="",W=t==="CSV",V=v.useMemo(()=>{if(!W||te)return[];const oe=kG(e),be=nf(oe,m);return _y(be.headers.map(Ce=>Ce.trim()))},[W,te,e,m]),R=v.useMemo(()=>W||te?[]:sR(e),[W,te,e]),N=v.useMemo(()=>W||te?[]:mG(e),[W,te,e]),L=v.useMemo(()=>W||te?null:gG(e),[W,te,e]),H=oe=>{var be;oe.preventDefault(),Array.from(((be=oe.dataTransfer)==null?void 0:be.types)??[]).includes("Files")&&(ee.current++,D(!0))},G=()=>{ee.current=Math.max(0,ee.current-1),ee.current===0&&D(!1)},B=oe=>{var Ce,lt;oe.preventDefault(),ee.current=0,D(!1);const be=(lt=(Ce=oe.dataTransfer)==null?void 0:Ce.files)==null?void 0:lt[0];be&&r(be,"drop")},le=oe=>{var Ce;if(!te||oe.defaultPrevented||oe.target instanceof HTMLTextAreaElement||oe.target instanceof HTMLInputElement)return;const be=(Ce=oe.clipboardData)==null?void 0:Ce.getData("text/plain");be&&(oe.preventDefault(),n(be))},me=W?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!_,onClick:()=>P(!1),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(pN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":_,onClick:()=>P(!0),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(fx,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,ye=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(bG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:H,onDragOver:oe=>oe.preventDefault(),onDragLeave:G,onDrop:B,onPaste:le,"data-drag-over":I||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(nR,{title:t,meta:ye,actions:E.jsxs(E.Fragment,{children:[me,W&&(g||y)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!g,onClick:()=>w==null?void 0:w(),className:ul,children:E.jsx(bN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!y,onClick:()=>k==null?void 0:k(),className:ul,children:E.jsx(rN,{"aria-hidden":"true"})})]}):null,L?E.jsx(_u,{label:L.label,testId:"json-format-toggle",onClick:()=>n(L.nextInput),Icon:fx,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:ie,type:"file","data-testid":"file-input",accept:W?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:oe=>{var Ce;const be=(Ce=oe.target.files)==null?void 0:Ce[0];be&&r(be,"picker"),oe.target.value=""}}),E.jsx(_u,{label:"Upload",testId:"upload",onClick:()=>{var oe;return(oe=ie.current)==null?void 0:oe.click()},Icon:pT}),E.jsx(_u,{label:"Copy",testId:"copy-input",onClick:o,Icon:Dv}),E.jsx(_u,{label:"Clear",testId:"clear-input",onClick:s,disabled:te,Icon:ph}),E.jsx(_u,{label:"Download",testId:"download-input",onClick:a,disabled:te,Icon:hT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[te?E.jsx(H9,{format:t,onIngest:n,onBrowse:()=>{var oe;return(oe=ie.current)==null?void 0:oe.click()},onTryExample:i}):W?E.jsxs(E.Fragment,{children:[V.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${V.map(oe=>`${oe.prefix}[${oe.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>S==null?void 0:S(),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",b?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:b?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,_?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:oe=>n(oe.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(BE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:T,onChangeColumnTypes:A})]}):E.jsxs(E.Fragment,{children:[R.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),R.map(oe=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${oe.key}`,onClick:()=>n(oe.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${oe.key} (${oe.rowCount} ${oe.rowCount===1?"row":"rows"})`},oe.key))]}):null,N.length>0?E.jsxs("div",{"data-testid":"json-flatten-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Nested keys (${N.length}):`}),E.jsx("button",{type:"button","data-testid":"json-flatten-pill","aria-pressed":M,onClick:()=>O==null?void 0:O(),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",M?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${M?"Flattened":"Flatten"} nested keys (${SG(N)})`})]}):null,E.jsx(tR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),I?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const TG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function EG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:TG.test(t.name)}const AG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function _S(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function oR(t){const[e,n]=v.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return v.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const lR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function LS(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function MG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=lR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function FS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function $S(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function zS({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function to({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:hr("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:hr("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(Ly,{text:r}):null]})}function Ly({text:t}){const e=v.useId(),[n,r]=v.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function RG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=v.useState(!1),a=v.useRef(null),u=v.useRef(null),c=oR("(min-width: 98.5rem)"),f=t==="csv2json",d=MG(t,e),h=v.useCallback(()=>{var m;l(!1),(m=a.current)==null||m.focus()},[]);v.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&h()},x=g=>{const y=u.current;y===null||!(g.target instanceof Node)||y.contains(g.target)||h()};return document.addEventListener("keydown",m),document.addEventListener("click",x),()=>{document.removeEventListener("keydown",m),document.removeEventListener("click",x)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(zS,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:m=>n({separator:m.target.value}),className:FS(),children:lR.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx($S,{})]})]}),E.jsx(Ly,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(LS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(zS,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:m=>s(m.target.value),className:FS(),children:AG.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx($S,{})]})]}),E.jsx(Ly,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(LS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(to,{label:"Parse numbers",checked:e.parseNumbers,onChange:m=>n({parseNumbers:m}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(to,{label:"Parse JSON",checked:e.parseJSON,onChange:m=>n({parseJSON:m}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(to,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:m=>n({emptyFields:m?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(to,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:m=>n({nullLiterals:m?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(to,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(to,{label:"Hash output",checked:e.hash,onChange:m=>n({hash:m}),hint:"The first column becomes the object key instead of a field."}),E.jsx(to,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(to,{label:"Flatten nested arrays",checked:e.flatten,onChange:m=>n({flatten:m}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(KI,{"aria-hidden":"true",className:hr("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:hr("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const OG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],PG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),IG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Hd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _w(t){if(Array.isArray(t))return t.map(e=>Hd(e)?e:{value:e});if(Hd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>Hd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function aR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function NG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!PG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function Rm(t){return`"${t.replace(/"/g,'""')}"`}function DG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function _G(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function LG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return _w(n).map(i=>JSON.stringify(i)).join(` +`)}function FG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=_w(r),s=aR(i),o=Rm(NG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=DG(h);return` ${Rm(d)} ${p}`}),a=`CREATE TABLE ${o} ( +${l.join(`, +`)} +);`;if(i.length===0)return a;const u=s.map(Rm).join(", "),c=i.map(d=>` (${s.map(p=>_G(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES +${c.join(`, +`)};`;return`${a} + +${f}`}function uR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=cR(Array.from(new Set(t.map(n=>uR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return Hd(t)?"Record":"unknown"}const BS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function cR(t){return[...t].sort((e,n)=>{const r=BS[e]??50,i=BS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function $G(t){return IG.test(t)?t:JSON.stringify(t)}function zG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=_w(n),s=aR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(uR(h[l]))}const c=cR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${$G(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { +${s.join(` +`)} +}`:"export interface DataRow {}"} + +export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function BG(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return LG(i);case"sql":return FG(i,s);case"ts":return zG(i)}}const jG=3;function HG(t){const e=t.slice(0,jG),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function WG({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onNativeCopy:p,onDownload:m,onEgressFormatChange:x,onOutputChange:g,onRevert:y,onDiscardReconvert:w}){const k=t==="JSON",b=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(nR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:y,className:ul,children:[E.jsx(dx,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[k?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:OG.map(S=>{const T=u===S.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${S.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(S.format),className:hr("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:S.label},S.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:ul,children:[E.jsx(Dv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:m,disabled:!n,className:ul,children:[E.jsx(hT,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:w?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:w,className:ul+" ml-2",children:[E.jsx(dx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:HG(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?k?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>p==null?void 0:p(),children:E.jsx(tR,{value:n,editable:a&&b&&n.length<=eR,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):E.jsx(BE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function VG({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const Lw="csvjson:recent.v1",fR=10,dR=1e5,jS=80;function UG(t){return t==="csv2json"||t==="json2csv"}function KG(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function hR(t){if(typeof t!="object"||t===null)return{...zr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:zr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:zr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:zr.nullLiterals,o=KG(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:zr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:zr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:zr.transpose,hash:typeof e.hash=="boolean"?e.hash:zr.hash,minify:typeof e.minify=="boolean"?e.minify:zr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:zr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:zr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function pR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=jS?n:`${n.slice(0,jS-1)}…`}function XG(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!UG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>dR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function GG(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:hR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||pR(t.input)}}function gR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Lw,JSON.stringify(t))}catch{}}function qG(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function Fw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Lw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(XG).map(GG).sort((r,i)=>i.createdAt-r.createdAt).slice(0,fR):[]}catch{return[]}}function HS(t){const e=Fw(),n=t.input.trim();if(n===""||t.input.length>dR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??qG(r),createdAt:r,direction:t.direction,input:t.input,options:hR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:pR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,fR);return gR(l),l}function YG(t){const n=Fw().filter(r=>r.id!==t);return gR(n),n}function JG(){try{if(typeof window>"u")return;window.localStorage.removeItem(Lw)}catch{}}function QG(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ZG(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function eq(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function tq({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=v.useState(!1),o=v.useRef(null),l=v.useRef(null),a=v.useCallback(()=>{s(!1)},[]),u=v.useRef(!1);v.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),v.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(YI,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(gh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:ZG(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:eq(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:QG(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Fy=20,$y=80,WS=50;function Om(t){return Math.min($y,Math.max(Fy,t))}function nq({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=v.useRef(null),[l,a]=v.useState(!1),u=t==="stacked";v.useEffect(()=>{if(!l)return;const f=h=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Om(m*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(Om(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Om(e+d));break;case"Home":f.preventDefault(),n(Fy);break;case"End":f.preventDefault(),n($y);break;case"Enter":case" ":f.preventDefault(),n(WS);break}};return E.jsxs("div",{ref:o,className:hr("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:hr("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Fy,"aria-valuemax":$y,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(WS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:hr("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:hr("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function rq({theme:t}){return t==="dark"?E.jsx(dN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(tN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function iq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(rq,{theme:t})})]})}function sq(t){return[...t].sort((e,n)=>n.id-e.id)}const mR=[{id:20,date:"2026-10-20",tag:"new",title:"One-click nested JSON flattening in JSON → CSV",summary:"When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click."},{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],oq=864e5;function VS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function lq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((VS(r)-VS(n))/oq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const yR="csvjson:changelog.v1",Wd=Math.max(...mR.map(t=>t.id),0),aq=sq(mR);function uq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!cq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function cq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function vR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Wd).sort((e,n)=>e-n)}function US(t,e,n){const r=vR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function fq(){try{const t=window.localStorage.getItem(yR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return uq(e)?{...e,pendingIds:vR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function dq(t){try{window.localStorage.setItem(yR,JSON.stringify(t))}catch{}}function hq(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function pq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function KS(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function gq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:lq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:KS(e===1),children:E.jsx(vN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:KS(e===-1),children:E.jsx(mN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function mq(){const[t,e]=v.useState(fq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{dq(b),i.current=b,e(b)},[]),[o,l]=v.useState(()=>new Set),a=v.useRef(new Set),u=v.useRef(null),c=v.useRef(null),f=v.useRef(new Map),d=t.lastSeenId!==null&&Wd>t.lastSeenId,h=v.useCallback((b,S)=>{l(T=>{const A=new Set(T);return S?A.add(b):A.delete(b),A})},[]),p=v.useCallback((b,S,T,A)=>{const M=(f.current.get(b)??0)+1;f.current.set(b,M),a.current.add(b),A&&h(b,!0),pq(T,b,S).then(O=>{f.current.get(b)===M&&(a.current.delete(b),O==="ok"&&(AI({entry_id:b,vote:S}),s(US(i.current,b,!1))),A&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:S,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&S!==void 0)for(const O of M){if(O===b||a.current.has(O))continue;const _=A[O];_!==void 0&&p(O,_,S,!1)}},[p]),x=(b,S)=>{if(t.votes[b]===S){m();return}const T=t.clientId??hq();s(US({...t,votes:{...t.votes,[b]:S},clientId:T},b,!0)),p(b,S,T,!0),m(b)},g=()=>{r(!0),EI(),t.lastSeenId!==Wd&&s({...t,lastSeenId:Wd}),m()},y=v.useCallback(()=>{r(!1)},[]),w=v.useRef(!1);v.useEffect(()=>{var b;w.current&&!n&&((b=c.current)==null||b.focus()),w.current=n},[n]);const k=v.useRef(!1);return v.useEffect(()=>{k.current||(k.current=!0,m())},[m]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&y()},S=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",S)}},[n,y]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?y():g(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(sN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:y,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(gh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:aq.map(b=>{var S;return E.jsx(gq,{entry:b,vote:t.votes[b.id],queued:((S=t.pendingIds)==null?void 0:S.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function yq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const vq={},wq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],xq=["csv2json","json2csv","csvjson2json"];function bq(t){return xq.includes(t)}const kq=/^[0-9a-f]{32}$/i,Sq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Pm=vq,Cq=((Pm==null?void 0:Pm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function Tq(t){const e=Sq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return wq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class zy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Im extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Nm={csv:(t,e)=>{t.direction="csv2json",t.input=Jh(e)},json:(t,e)=>{t.input=Jh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Jh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function XS(t){return typeof t=="string"&&t.trim()!==""}function Gl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function Eq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Aq(t){var i;if(!Eq(t))return null;const e=XS(t.csv),n=XS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Nm[s])==null||i.call(Nm,r,o);return r.input=Jh(e?t.csv:t.json),r}async function Mq(t){if(!kq.test(t))throw new zy;let e;try{e=await fetch(`${Cq}${t}`,{mode:"cors"})}catch(r){throw new Im("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new zy;if(!e.ok)throw new Im(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new Im("Stored data for this link is malformed")}return n}function Rq(t){const e=v.useMemo(()=>t&&bq(t.tool)?t.id:null,[t]),[n,r]=v.useState(0),[i,s]=v.useState(e?"loading":"idle"),[o,l]=v.useState(null),[a,u]=v.useState("");return v.useEffect(()=>{if(!e)return;let c=!1;return Mq(e).then(f=>{if(c)return;const d=Aq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof zy?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function GS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const Oq="\uFEFF";function Pq(t,e){return e?Oq+t:t}function Iq(t,e,n){const r=Pq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Nq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Dq(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!Nq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function _q(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Dq(t)}.${r}`:`data.${r}`}function Lq(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function qS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Iq(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function Fq(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const $q=`album,year,US_peak_chart_post +The White Stripes,1999, +De Stijl,2000, +White Blood Cells,2001,61 +Elephant,2003,6 +Get Behind Me Satan,2005,3 +Icky Thump,2007,2`,zq=`[ + { + "album": "Elephant", + "year": 2003, + "label": "XL Recordings" + }, + { + "album": "Icky Thump", + "year": 2007, + "label": "XL Recordings" + } +]`,wR="csvjson-theme";function Bq(){try{const t=localStorage.getItem(wR);return t==="dark"||t==="light"?t:null}catch{return null}}function jq(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function Hq(){return Bq()??jq()}function Wq(t){try{localStorage.setItem(wR,t)}catch{}}function Vq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const YS=2*1024*1024,Uq=150,Kq=1e3,Xq=2e3,Gq=2e3;function qq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function JS(t){try{return JSON.parse(t),!0}catch{return!1}}function Yq(){var dn;const[t,e]=v.useState(Hq);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(ne=>{const Le=ne==="dark"?"light":"dark";return Wq(Le),Le}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":Vq(window.location.search)),[s,o]=v.useState(()=>Go("")),l=s.present,[a,u]=v.useState(zr),[c,f]=v.useState("json"),[d,h]=v.useState(50),[p,m]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(null),[k,b]=v.useState("utf-8"),[S,T]=v.useState(Fw),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=_I({settleMs:Xq,minWindowMs:Gq,isValid:(ne,Le)=>{const ze=A.current;return Le===ze.input?ze.resultOk:eo(ne==="csv_to_json"?"csv2json":"json2csv",Le,ze.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=oR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",ee=I?"JSON":"CSV",ie=l.trim()==="",te=l.length>YS?Kq:Uq,W=yq(l,ie?0:te),V=v.useRef(null),R=v.useRef(null),L=l!==""&&((dn=V.current)==null?void 0:dn.text)===l?l:W,H=v.useMemo(()=>typeof window>"u"?null:Tq(window.location.pathname),[]),G=Rq(H),B=v.useMemo(()=>eo(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const ne=R.current;!ne||ne.text!==L||(R.current=null,O.discrete(ne.direction,ne.via,ne.text))},[L,B,O]);const[le,me]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&B.ok&&me(B.text)},[B,L]),v.useEffect(()=>{L.trim()!==""&&(!B.ok||B.rows<=0&&B.cols<=0||T(HS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const ye=L.trim()!==""&&B.ok?B.text:le,[oe,be]=v.useState(!1),[Ce,lt]=v.useState(null),Xe=oe?Ce:ye,Ge=v.useMemo(()=>{if(!I||Xe===null||c==="json")return Xe;const ne=oe&&Ce!==null&&JS(Ce)?Ce:ye;return ne===null?null:BG(ne,c,a,p)},[I,Xe,c,oe,Ce,ye,a,p]),at=I&&c==="json"&&!ie&&Ge!==null&&(oe||B.ok),Ut=v.useCallback(ne=>{if(ne===ye){be(!1),lt(null);return}be(!0),lt(ne)},[ye]),Pe=v.useCallback(()=>{const ne=eo(r,l,a);ne.ok&&me(ne.text),be(!1),lt(null)},[r,l,a]),xe=v.useCallback(ne=>{o(Le=>I?Gb(Le,ne):Go(ne))},[I]),Je=I&&s.past.length>0,nt=I&&s.future.length>0,it=v.useCallback(()=>{if(!I||s.past.length===0)return;const ne=C9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),$e=v.useCallback(()=>{if(!I||s.future.length===0)return;const ne=T9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),At=v.useCallback(ne=>{w(null),V.current=null,i(ne.direction),u({...ne.options}),m(ne.filename),be(!1),lt(null),o(Le=>ne.direction==="csv2json"&&r==="csv2json"?Gb(Le,ne.input):Go(ne.input)),T(HS({direction:ne.direction,input:ne.input,options:ne.options,filename:ne.filename,rows:ne.rows,cols:ne.cols}))},[r]),wt=v.useCallback(ne=>{T(YG(ne))},[]),rt=v.useCallback(()=>{JG(),T([])},[]),ge=()=>{const ne=r==="csv2json"?"json2csv":"csv2json";if(oe){const Le=Ce??"",ze=JS(Le)?Le:l;o(Go(ze)),i(ne),be(!1),lt(null),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:eo(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(ne),ie)o(Go(""));else{const Le=eo(r,l,a),ze=Le.ok?Le.text:l;o(Go(ze)),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:eo(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},_e=G.hydrated;v.useEffect(()=>{if(_e===null)return;const ne={...A.current.options,..._e.options};A.current={direction:_e.direction,options:ne,input:_e.input,resultOk:eo(_e.direction,_e.input,ne).ok},i(_e.direction),o(Go(_e.input)),u(Le=>({...Le,..._e.options})),be(!1),lt(null),TI(),O.discrete(_e.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",_e.input)},[_e,O]);const Qe=async(ne,Le)=>{if(!EG(ne)){w(`Can't read "${ne.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const ze=await _S(ne,k);V.current={file:ne,source:Le,text:ze},R.current={direction:I?"csv_to_json":"json_to_csv",via:Le==="drop"?"drag":"file",text:ze},xe(ze),m(ne.name),g(!1)}catch{g(!1),w(`Couldn't read "${ne.name}".`)}},tt=async ne=>{const Le=k;b(ne);const ze=V.current;if(!(!ze||l!==ze.text)){g(!0);try{const An=await _S(ze.file,ne);V.current={...ze,text:An},R.current={direction:I?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:An},o(z=>({...z,present:An})),g(!1)}catch{g(!1),b(Le),w(`Couldn't read "${ze.file.name}".`)}}},Kt=v.useCallback(ne=>{w(null),ne.trim()===""&&u(Le=>{if(!Le.columnTypes)return Le;const ze={...Le};return delete ze.columnTypes,ze}),xe(ne),O.edit(I?"csv_to_json":"json_to_csv",ne)},[xe,I,O]);v.useEffect(()=>{const ne=Le=>{var An;const ze=(An=Le.clipboardData)==null?void 0:An.getData("text/plain");!ze||Fq(Le.target)||(Le.preventDefault(),Le.stopPropagation(),m(null),Kt(ze))};return document.addEventListener("paste",ne,!0),()=>document.removeEventListener("paste",ne,!0)},[Kt]);const dt=B.ok?qq(B.rows,B.cols):null,ht=!B.ok&&le?"Last valid result — input has errors":null,pt=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Lt=l.length>YS,Rt=I?"csv_to_json":"json_to_csv",en=I?c:"csv",Hn=()=>{Uo({via:"copy",format:I?"csv":"json",pane:"input",direction:Rt}),GS(l)},Pt=()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt}),Ge&&GS(Ge)},vn=()=>{Uo({via:"download",format:I?"csv":"json",pane:"input",direction:Rt}),qS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},In=()=>{Uo({via:"download",format:en,pane:"output",direction:Rt}),qS(Ge??"",_q(p,I?"csv2json":"json2csv",c),{mime:Lq(I?"csv2json":"json2csv",c),bom:!I})},Pr=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"input",direction:Rt})},[Rt]),Ir=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"output",direction:Rt})},[Rt]),Bt=v.useCallback(()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt})},[en,Rt]),ct=E.jsx(CG,{format:D,input:l,onInputChange:Kt,onCellCommit:Kt,onFile:Qe,onTryExample:()=>{w(null);const ne=I?$q:zq;A.current={direction:r,options:a,input:ne,resultOk:eo(r,ne,a).ok},xe(ne),O.discrete(Rt,"example",ne)},onClear:()=>{xe(""),m(null),u(ne=>{if(!ne.columnTypes)return ne;const Le={...ne};return delete Le.columnTypes,Le}),be(!1),lt(null),O.cancel()},onCopy:Hn,onCopySelection:Pr,onDownload:vn,canUndo:Je,canRedo:nt,onUndo:it,onRedo:$e,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(ne=>({...ne,collapseIndexedArrays:!(ne.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:ne=>u(Le=>{const ze={...Le};return Object.keys(ne).length>0?ze.columnTypes=ne:delete ze.columnTypes,ze}),flatten:a.flatten,onToggleFlatten:()=>u(ne=>({...ne,flatten:!ne.flatten})),filename:p,reading:x,meta:dt,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),xt=E.jsx(WG,{format:ee,inputEmpty:ie,outputText:Ge,error:B.ok?null:B.error,meta:dt,staleNotice:ht,warnings:pt,edited:oe,editable:at,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Pt,onCopySelection:Ir,onNativeCopy:Bt,onDownload:In,onEgressFormatChange:f,onOutputChange:Ut,onRevert:Pe,onDiscardReconvert:Pe});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(lD,{}),E.jsx(iq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(tq,{snapshots:S,onSelect:At,onRemove:wt,onClear:rt}),E.jsx(mq,{}),E.jsx(dD,{})]})}),H&&(G.phase==="loading"||G.phase==="not-found"||G.phase==="unsupported"||G.phase==="error")?E.jsx(VG,{phase:G.phase,message:G.phase==="error"?G.message:void 0,onRetry:G.retry}):null,E.jsx(nq,{layout:P,split:d,onSplitChange:h,left:ct,right:xt,children:E.jsx(rD,{direction:r,onFlip:ge})}),E.jsx(RG,{direction:r,options:a,onChange:ne=>u(Le=>({...Le,...ne})),uploadEncoding:k,onUploadEncodingChange:tt,notice:Lt?"Large file — converting on pause":null})]}),E.jsx(sD,{})]})}cT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(Yq,{})}));document.getElementById("root").removeAttribute("inert");SI();CI();export{t6 as C,Ln as R,E4 as T,ca as a,Q3 as b,bI as c,ql as i,T4 as m,v as r,Jr as s}; diff --git a/app/dist/assets/number-overlay-editor-TWdf9NmZ.js b/app/dist/assets/number-overlay-editor-cI9rZOV7.js similarity index 99% rename from app/dist/assets/number-overlay-editor-TWdf9NmZ.js rename to app/dist/assets/number-overlay-editor-cI9rZOV7.js index 91ff627..3e1706e 100644 --- a/app/dist/assets/number-overlay-editor-TWdf9NmZ.js +++ b/app/dist/assets/number-overlay-editor-cI9rZOV7.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-BVybGQOI.js";const Fe=Be("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start - + diff --git a/app/src/App.test.tsx b/app/src/App.test.tsx index 8dc5504..dc04d43 100644 --- a/app/src/App.test.tsx +++ b/app/src/App.test.tsx @@ -1780,6 +1780,97 @@ describe("Developer egress formats in OutputPane header (AC-13 / D12)", () => { }); }); +describe("Symmetric JSON → CSV nested object flatten pill (AC-15 / D14)", () => { + it("surfaces the contextual Flatten nested keys pill in JSON → CSV mode, toggles options.flatten, and flattens deep objects into dotted CSV columns", async () => { + const user = userEvent.setup(); + render(); + await flip(); + + const nestedJson = JSON.stringify([ + { + id: 1, + user: { profile: { name: "Ada", city: "London" } }, + tags: ["math", "code"], + }, + { + id: 2, + user: { profile: { name: "Grace", city: "NY" } }, + tags: ["compilers"], + }, + ]); + fireEvent.paste(screen.getByTestId("input-pane"), { + clipboardData: { getData: () => nestedJson }, + }); + + const bar = await screen.findByTestId("json-flatten-bar"); + expect(bar).toBeInTheDocument(); + const pill = screen.getByTestId("json-flatten-pill"); + expect(pill).toHaveAttribute("aria-pressed", "false"); + expect(pill).toHaveTextContent("Flatten nested keys (.user, .tags)"); + + // Before toggling flatten: output table keeps nested object/array as unflattened JSON cells + await waitFor(() => { + expect(screen.getByTestId("output-table")).toHaveTextContent( + '{"profile":{"name":"Ada","city":"London"}}' + ); + }); + + // Click pill to enable flatten + await user.click(pill); + expect(pill).toHaveAttribute("aria-pressed", "true"); + expect(pill).toHaveTextContent("Flattened nested keys (.user, .tags)"); + + await waitFor(() => { + const outputTable = screen.getByTestId("output-table"); + expect(outputTable).toHaveTextContent(/user\.profile\.name/i); + expect(outputTable).toHaveTextContent(/user\.profile\.city/i); + expect(outputTable).toHaveTextContent("math, code"); + }); + + // Click pill again to disable flatten -> restores JSON-encoded nested cell values + await user.click(pill); + expect(pill).toHaveAttribute("aria-pressed", "false"); + expect(pill).toHaveTextContent("Flatten nested keys (.user, .tags)"); + await waitFor(() => { + const outputTable = screen.getByTestId("output-table"); + expect(outputTable).not.toHaveTextContent(/user\.profile\.name/i); + expect(outputTable).toHaveTextContent('{"profile":{"name":"Ada","city":"London"}}'); + }); + }); + + it("truncates more than 3 nested keys with +N more and hides the bar when JSON input is flat", async () => { + const user = userEvent.setup(); + render(); + await flip(); + + const fiveNestedKeys = JSON.stringify([ + { + a: { v: 1 }, + b: { v: 2 }, + c: [1, 2], + d: { v: 4 }, + e: ["x"], + }, + ]); + fireEvent.paste(screen.getByTestId("input-pane"), { + clipboardData: { getData: () => fiveNestedKeys }, + }); + + const pill = await screen.findByTestId("json-flatten-pill"); + expect(pill).toHaveTextContent("Flatten nested keys (.a, .b, .c, +2 more)"); + + // Clear and ingest flat JSON -> flatten bar hides + await user.click(screen.getByTestId("clear-input")); + fireEvent.paste(screen.getByTestId("input-pane"), { + clipboardData: { getData: () => '[{"id":1,"name":"Ada"}]' }, + }); + await waitFor(() => { + expect(screen.getByTestId("output-table")).toHaveTextContent("Ada"); + }); + expect(screen.queryByTestId("json-flatten-bar")).toBeNull(); + }); +}); + diff --git a/app/src/App.tsx b/app/src/App.tsx index b28f42e..e98a7d5 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -753,6 +753,10 @@ export default function App() { return next; }) } + flatten={options.flatten} + onToggleFlatten={() => + setOptions((prev) => ({ ...prev, flatten: !prev.flatten })) + } filename={filename} reading={reading} meta={meta} diff --git a/app/src/changelog/entries.ts b/app/src/changelog/entries.ts index e6ac0ef..80502aa 100644 --- a/app/src/changelog/entries.ts +++ b/app/src/changelog/entries.ts @@ -34,6 +34,14 @@ export function newestFirst(entries: ChangelogEntry[]): ChangelogEntry[] { } export const changelogEntries: ChangelogEntry[] = [ + { + id: 20, + date: "2026-10-20", + tag: "new", + title: "One-click nested JSON flattening in JSON → CSV", + summary: + "When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click.", + }, { id: 19, date: "2026-10-20", diff --git a/app/src/components/InputPane.tsx b/app/src/components/InputPane.tsx index 41c8729..f704a93 100644 --- a/app/src/components/InputPane.tsx +++ b/app/src/components/InputPane.tsx @@ -9,6 +9,7 @@ import { type ColumnTypeOverride, detectIndexedHeaderGroups, detectJsonWrapperCandidates, + detectNestedJsonKeys, resolveJsonFormatToggle, } from "@/lib/convert"; import { parseCsvTable } from "@/lib/csvTable"; @@ -51,6 +52,8 @@ type InputPaneProps = { onToggleCollapseIndexedArrays?: () => void; columnTypes?: Record; onChangeColumnTypes?: (columnTypes: Record) => void; + flatten?: boolean; + onToggleFlatten?: () => void; }; function ReadingSpinner() { @@ -141,6 +144,15 @@ function sliceFirstCsvRecord(csv: string): string { return csv.slice(0, maxScan); } +function formatNestedKeysSummary(keys: string[]): string { + const shown = keys + .slice(0, 3) + .map((k) => `.${k}`) + .join(", "); + const remaining = keys.length - 3; + return remaining > 0 ? `${shown}, +${remaining} more` : shown; +} + export function InputPane({ format, input, @@ -167,6 +179,8 @@ export function InputPane({ onToggleCollapseIndexedArrays, columnTypes, onChangeColumnTypes, + flatten = false, + onToggleFlatten, }: InputPaneProps) { const [rawMode, setRawMode] = useState(false); const [dragOver, setDragOver] = useState(false); @@ -184,6 +198,10 @@ export function InputPane({ () => (isCsv || inputEmpty ? [] : detectJsonWrapperCandidates(input)), [isCsv, inputEmpty, input] ); + const nestedJsonKeys = useMemo( + () => (isCsv || inputEmpty ? [] : detectNestedJsonKeys(input)), + [isCsv, inputEmpty, input] + ); const jsonFormatAction = useMemo( () => (isCsv || inputEmpty ? null : resolveJsonFormatToggle(input)), [isCsv, inputEmpty, input] @@ -465,6 +483,30 @@ export function InputPane({ ))}
    ) : null} + {nestedJsonKeys.length > 0 ? ( +
    + + {`Nested keys (${nestedJsonKeys.length}):`} + + +
    + ) : null} { - it("round-trips nested JSON cells through parseCsvTable with flatten", () => { + it("flattens nested plain objects and explodes array rows through parseCsvTable with flatten", () => { const csv = jsonToJsonCsv(R1_CUSTOMERS, { flatten: true }); const table = parseCsvTable(csv); expect(table.headers).toEqual([ "name", "email", - "note", + "note.text", + "note.priority", "items.sku", "items.qty", ]); - // Exploded rows repeat the scalars; the JSON cell arrives intact. + // Exploded rows repeat the scalars and flattened object keys. expect(table.rows).toEqual([ [ "Ada Lovelace", "ada@example.com", - '{"text":"ships expedited","priority":1}', + "ships expedited", + "1", "SKU-1", "1", ], [ "Ada Lovelace", "ada@example.com", - '{"text":"ships expedited","priority":1}', + "ships expedited", + "1", "SKU-2", "3", ], [ "Grace Hopper", "grace@example.com", - '{"text":"leave at desk","priority":2}', + "leave at desk", + "2", "SKU-3", "2", ], @@ -505,28 +510,31 @@ describe("lib output → preview table round-trip (art_afRt2cdg R1)", () => { ]); }); - it("flattened output with JSON cells round-trips through csv2json", () => { + it("flattened output with dotted object keys round-trips through csv2json", () => { const csv = jsonToJsonCsv(R1_CUSTOMERS, { flatten: true }); - // Dotted headers stay literal keys; the JSON cells come back as values. + // Dotted headers stay literal keys when read back by csvToJson. expect(csvToJson(csv, { parseJSON: true })).toEqual([ { name: "Ada Lovelace", email: "ada@example.com", - note: { text: "ships expedited", priority: 1 }, + "note.text": "ships expedited", + "note.priority": 1, "items.sku": "SKU-1", "items.qty": 1, }, { name: "Ada Lovelace", email: "ada@example.com", - note: { text: "ships expedited", priority: 1 }, + "note.text": "ships expedited", + "note.priority": 1, "items.sku": "SKU-2", "items.qty": 3, }, { name: "Grace Hopper", email: "grace@example.com", - note: { text: "leave at desk", priority: 2 }, + "note.text": "leave at desk", + "note.priority": 2, "items.sku": "SKU-3", "items.qty": 2, }, @@ -561,10 +569,10 @@ describe("count parity — count == preview == download (art_afRt2cdg R1/R1b/R1c expect(result.ok).toBe(true); if (!result.ok) return; const table = parseCsvTable(result.text); - // 2 customers (one with 2 items) explode to 3 rows; dotted keys → 5 cols. + // 2 customers (one with 2 items) explode to 3 rows; dotted keys → 6 cols. // The input shape said 2 rows · 4 cols — the defect. expect(result.rows).toBe(3); - expect(result.cols).toBe(5); + expect(result.cols).toBe(6); expect(table.rows).toHaveLength(result.rows); expect(table.headers).toHaveLength(result.cols); }); @@ -830,10 +838,10 @@ describe("P2 — scalar arrays under Flatten (art_RfUU1oAy, fixes #80)", () => { expect(csv).toBe('"id","tags.t"\n1,"a"\n1,"b"'); }); - it("keeps nested objects as lossless JSON cells — no join inside them", () => { + it("flattens nested plain objects and joins scalar arrays inside them under Flatten", () => { expect( jsonToJsonCsv([{ meta: { tags: ["x", "y"] } }], { flatten: true }) - ).toBe('"meta"\n"{""tags"":[""x"",""y""]}"'); + ).toBe('"meta.tags"\n"x, y"'); }); it("never advises enabling Flatten when Flatten is on", () => { @@ -1344,7 +1352,117 @@ describe("per-column type overrides (AC-16 / D15)", () => { }); }); +describe("Symmetric JSON → CSV nested object flatten & detectNestedJsonKeys (AC-15 / D14, art_MJHTha6X)", () => { + it("detectNestedJsonKeys returns unique top-level keys holding plain objects or non-empty arrays in insertion order", () => { + const input = JSON.stringify([ + { id: 1, name: "Ada", user: { role: "admin" }, tags: [] }, + { id: 2, name: "Grace", tags: ["pioneer", "navy"], address: { city: "NY" }, user: { role: "lead" } }, + ]); + expect(detectNestedJsonKeys(input)).toEqual(["user", "tags", "address"]); + }); + it("detectNestedJsonKeys returns [] for flat records, invalid JSON, empty input, or wrappable REST containers", () => { + expect(detectNestedJsonKeys("")).toEqual([]); + expect(detectNestedJsonKeys("{invalid")).toEqual([]); + expect( + detectNestedJsonKeys( + JSON.stringify([ + { id: 1, name: "Ada", emptyList: [], nothing: null }, + { id: 2, name: "Grace", active: true }, + ]) + ) + ).toEqual([]); + // A root object wrapping an array of records is handled by Unwrap .data pill instead. + expect( + detectNestedJsonKeys( + JSON.stringify({ + data: [{ id: 1, user: { name: "Ada" } }], + meta: { page: 1 }, + }) + ) + ).toEqual([]); + }); + + it("detectNestedJsonKeys supports JSONL / NDJSON and single non-wrappable root objects and caps scanning at 50 records", () => { + const jsonl = [ + '{"id":1,"profile":{"handle":"ada"}}', + '{"id":2,"scores":[10,20]}', + ].join("\n"); + expect(detectNestedJsonKeys(jsonl)).toEqual(["profile", "scores"]); + + const singleObject = JSON.stringify({ + id: 1, + user: { profile: { name: "Ada" } }, + roles: ["admin", "dev"], + }); + expect(detectNestedJsonKeys(singleObject)).toEqual(["user", "roles"]); + + const manyRecords: Array> = Array.from( + { length: 55 }, + (_, idx) => (idx === 52 ? { id: idx, lateNested: { x: 1 } } : { id: idx }) + ); + expect(detectNestedJsonKeys(JSON.stringify(manyRecords))).toEqual([]); + manyRecords[49] = { id: 49, fiftiethNested: { y: 2 } }; + expect(detectNestedJsonKeys(JSON.stringify(manyRecords))).toEqual([ + "fiftiethNested", + ]); + }); + + it("flattens 2–3 level deep plain objects into dotted column headers and joins scalar arrays when flatten is true", () => { + const input = [ + { + id: 1, + user: { + profile: { + name: "Ada Lovelace", + address: { city: "London", country: "UK" }, + }, + roles: ["math", "computing"], + }, + }, + ]; + + const flattenedCsv = jsonToJsonCsv(input, { flatten: true }); + expect(flattenedCsv).toBe( + [ + '"id","user.profile.name","user.profile.address.city","user.profile.address.country","user.roles"', + '1,"Ada Lovelace","London","UK","math, computing"', + ].join("\n") + ); + + // Toggling flatten off preserves JSON-encoded nested cell values. + const unflattenedCsv = jsonToJsonCsv(input, { flatten: false }); + const table = parseCsvTable(unflattenedCsv); + expect(table.headers).toEqual(["id", "user"]); + expect(JSON.parse(table.rows[0][1])).toEqual(input[0].user); + }); + + it("flattens nested plain objects and scalar arrays inside arrays of objects without throwing NonTabularJsonError", () => { + const input = [ + { + orderId: 101, + lineItems: [ + { + sku: "SKU-1", + meta: { warehouse: { code: "EU-1" }, labels: ["fragile", "priority"] }, + }, + { + sku: "SKU-2", + meta: { warehouse: { code: "US-2" }, labels: ["standard"] }, + }, + ], + }, + ]; + const csv = jsonToJsonCsv(input, { flatten: true }); + expect(csv).toBe( + [ + '"orderId","lineItems.sku","lineItems.meta.warehouse.code","lineItems.meta.labels"', + '101,"SKU-1","EU-1","fragile, priority"', + '101,"SKU-2","US-2","standard"', + ].join("\n") + ); + }); +}); diff --git a/app/src/lib/convert.ts b/app/src/lib/convert.ts index e6e5102..20c0373 100644 --- a/app/src/lib/convert.ts +++ b/app/src/lib/convert.ts @@ -193,6 +193,47 @@ function isJsonScalar(value: unknown): value is JsonScalar { ); } +/** + * Recursively flattens nested plain objects (`Record`) into + * dotted keys (`{ user: { profile: { name: "Ada" } } }` → + * `{ "user.profile.name": "Ada" }`) when `options.flatten === true`. + * + * Non-empty scalar arrays are preserved at their dotted key so `joinScalarArrays` + * can join them into `"a, b"`, and arrays of objects are preserved (with any + * nested plain objects inside their element records flattened) so the package's + * `flattenArray` can explode them into rows. Empty plain objects (`{}`) are kept + * at their key so the column is not dropped. + */ +function flattenNestedPlainObjects(data: unknown): unknown { + const flattenObjectEntries = ( + obj: Record, + prefix: string, + out: Record + ): void => { + for (const [key, value] of Object.entries(obj)) { + const nextKey = prefix ? `${prefix}.${key}` : key; + if (isRecord(value) && Object.keys(value).length > 0) { + flattenObjectEntries(value, nextKey, out); + } else if (Array.isArray(value)) { + out[nextKey] = value.map(flattenRow); + } else { + out[nextKey] = value; + } + } + }; + + const flattenRow = (row: unknown): unknown => { + if (!isRecord(row)) return row; + const out: Record = {}; + flattenObjectEntries(row, "", out); + return out; + }; + + if (Array.isArray(data)) return data.map(flattenRow); + if (isRecord(data)) return flattenRow(data); + return data; +} + /** * P2 (art_RfUU1oAy, fixes #80): under Flatten, a non-empty array of JSON * scalars serializes as a single column named after its key, elements @@ -610,9 +651,12 @@ export function jsonToJsonCsv( options: Json2CsvOptions = {} ): string { try { - // P2: under Flatten the scalar-array join runs before the package sees - // the data — its own flatten would reject those arrays (#80). - const prepared = options.flatten ? joinScalarArrays(data) : data; + // D14 / AC-15 + P2: under Flatten, first recursively flatten nested plain + // objects into dotted keys, then join scalar arrays into ", "-separated + // strings before handing the records to csvjson-json2csv. + const prepared = options.flatten + ? joinScalarArrays(flattenNestedPlainObjects(data)) + : data; return json2csv(prepared, options); } catch (e) { // The packages throw plain strings — rethrow as real Errors so callers @@ -823,6 +867,53 @@ export function resolveJsonFormatToggle( }; } +/** + * Inspect valid JSON (or valid multi-line JSONL via `tryParseJsonLines`) in + * `JSON → CSV` mode and return unique top-level keys across up to the first 50 + * record objects whose value is a non-null plain object or a non-empty array. + * Returns `[]` when the input is empty, invalid, or a wrappable REST container + * (where `detectJsonWrapperCandidates` takes precedence). + */ +export function detectNestedJsonKeys(input: string): string[] { + const trimmed = input.trim(); + if (trimmed === "") return []; + + let parsed: unknown; + try { + parsed = JSON.parse(trimmed); + } catch { + const jsonlData = tryParseJsonLines(trimmed); + if (jsonlData === null) return []; + parsed = jsonlData; + } + + let records: Record[] = []; + if (Array.isArray(parsed)) { + if (parsed.length === 0 || !parsed.every((item) => isPlainRecord(item))) { + return []; + } + records = parsed; + } else if (isPlainRecord(parsed)) { + if (detectJsonWrapperCandidates(trimmed).length > 0) { + return []; + } + records = [parsed]; + } else { + return []; + } + + const keys = new Set(); + const sample = records.slice(0, 50); + for (const record of sample) { + for (const [key, val] of Object.entries(record)) { + if (isPlainRecord(val) || (Array.isArray(val) && val.length > 0)) { + keys.add(key); + } + } + } + return Array.from(keys); +} + /** Best-effort row/col counts for the pane headers. Empty cells → 0. */ function countShape(json: unknown): { rows: number; cols: number } { const collectKeys = (rows: unknown[]): Set => {