diff --git a/app/dist/assets/data-grid-overlay-editor-CglJRbhF.js b/app/dist/assets/data-grid-overlay-editor-B9d-8QKg.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-CglJRbhF.js rename to app/dist/assets/data-grid-overlay-editor-B9d-8QKg.js index d0763d7..04f5e3a 100644 --- a/app/dist/assets/data-grid-overlay-editor-CglJRbhF.js +++ b/app/dist/assets/data-grid-overlay-editor-B9d-8QKg.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-D0wq-_gy.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-Bgv9nWtu.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-D0wq-_gy.js b/app/dist/assets/index-Bgv9nWtu.js similarity index 51% rename from app/dist/assets/index-D0wq-_gy.js rename to app/dist/assets/index-Bgv9nWtu.js index 93c4451..5727350 100644 --- a/app/dist/assets/index-D0wq-_gy.js +++ b/app/dist/assets/index-Bgv9nWtu.js @@ -1,4 +1,4 @@ -var HR=Object.defineProperty;var WR=(t,e,n)=>e in t?HR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var xt=(t,e,n)=>WR(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 io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ni(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var KS={exports:{}},Xh={},XS={exports:{}},Tt={};/** +var UR=Object.defineProperty;var KR=(t,e,n)=>e in t?UR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var vt=(t,e,n)=>KR(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 io=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ni(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var qS={exports:{}},Yh={},YS={exports:{}},St={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ var HR=Object.defineProperty;var WR=(t,e,n)=>e in t?HR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Lc=Symbol.for("react.element"),VR=Symbol.for("react.portal"),UR=Symbol.for("react.fragment"),KR=Symbol.for("react.strict_mode"),XR=Symbol.for("react.profiler"),GR=Symbol.for("react.provider"),qR=Symbol.for("react.context"),YR=Symbol.for("react.forward_ref"),QR=Symbol.for("react.suspense"),JR=Symbol.for("react.memo"),ZR=Symbol.for("react.lazy"),Yw=Symbol.iterator;function eO(t){return t===null||typeof t!="object"?null:(t=Yw&&t[Yw]||t["@@iterator"],typeof t=="function"?t:null)}var GS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qS=Object.assign,YS={};function ja(t,e,n){this.props=t,this.context=e,this.refs=YS,this.updater=n||GS}ja.prototype.isReactComponent={};ja.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")};ja.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function QS(){}QS.prototype=ja.prototype;function _y(t,e,n){this.props=t,this.context=e,this.refs=YS,this.updater=n||GS}var Ly=_y.prototype=new QS;Ly.constructor=_y;qS(Ly,ja.prototype);Ly.isPureReactComponent=!0;var Qw=Array.isArray,JS=Object.prototype.hasOwnProperty,Fy={current:null},ZS={key:!0,ref:!0,__self:!0,__source:!0};function eC(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)JS.call(e,r)&&!ZS.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1e in t?HR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var sO=v,oO=Symbol.for("react.element"),lO=Symbol.for("react.fragment"),aO=Object.prototype.hasOwnProperty,uO=sO.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,cO={key:!0,ref:!0,__self:!0,__source:!0};function nC(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)aO.call(e,r)&&!cO.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:oO,type:t,key:s,ref:o,props:i,_owner:uO.current}}Xh.Fragment=lO;Xh.jsx=nC;Xh.jsxs=nC;KS.exports=Xh;var E=KS.exports,rC={exports:{}},Hr={},iC={exports:{}},sC={};/** + */var aO=v,uO=Symbol.for("react.element"),cO=Symbol.for("react.fragment"),fO=Object.prototype.hasOwnProperty,dO=aO.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,hO={key:!0,ref:!0,__self:!0,__source:!0};function sC(t,e,n){var r,i={},s=null,o=null;n!==void 0&&(s=""+n),e.key!==void 0&&(s=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)fO.call(e,r)&&!hO.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:uO,type:t,key:s,ref:o,props:i,_owner:dO.current}}Yh.Fragment=cO;Yh.jsx=sC;Yh.jsxs=sC;qS.exports=Yh;var A=qS.exports,oC={exports:{}},Hr={},lC={exports:{}},aC={};/** * @license React * scheduler.production.min.js * @@ -22,7 +22,7 @@ var HR=Object.defineProperty;var WR=(t,e,n)=>e in t?HR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(V,J){var R=V.length;V.push(J);e:for(;0>>1,L=V[N];if(0>>1;Ni(B,R))oei(fe,B)?(V[N]=fe,V[oe]=R,N=oe):(V[N]=B,V[j]=R,N=j);else if(oei(fe,R))V[N]=fe,V[oe]=R,N=oe;else break e}}return J}function i(V,J){var R=V.sortIndex-J.sortIndex;return R!==0?R:V.id-J.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(V){for(var J=n(u);J!==null;){if(J.callback===null)r(u);else if(J.startTime<=V)r(u),J.sortIndex=J.expirationTime,e(a,J);else break;J=n(u)}}function k(V){if(m=!1,w(V),!p)if(n(a)!==null)p=!0,ie(b);else{var J=n(u);J!==null&&se(k,J.startTime-V)}}function b(V,J){p=!1,m&&(m=!1,g(A),A=-1),h=!0;var R=d;try{for(w(J),f=n(a);f!==null&&(!(f.expirationTime>J)||V&&!_());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=J);J=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(J)}else r(a);f=n(a)}if(f!==null)var z=!0;else{var j=n(u);j!==null&&se(k,j.startTime-J),z=!1}return z}finally{f=null,d=R,h=!1}}var C=!1,T=null,A=-1,M=5,O=-1;function _(){return!(t.unstable_now()-OV||125N?(V.sortIndex=R,e(u,V),n(a)===null&&V===n(u)&&(m?(g(A),A=-1):m=!0,se(k,R-N))):(V.sortIndex=L,e(a,V),p||h||(p=!0,ie(b))),V},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(V){var J=d;return function(){var R=d;d=J;try{return V.apply(this,arguments)}finally{d=R}}}})(sC);iC.exports=sC;var fO=iC.exports;/** + */(function(t){function e(V,Z){var M=V.length;V.push(Z);e:for(;0>>1,L=V[N];if(0>>1;Ni($,M))aei(he,$)?(V[N]=he,V[ae]=M,N=ae):(V[N]=$,V[j]=M,N=j);else if(aei(he,M))V[N]=he,V[ae]=M,N=ae;else break e}}return Z}function i(V,Z){var M=V.sortIndex-Z.sortIndex;return M!==0?M:V.id-Z.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(V){for(var Z=n(u);Z!==null;){if(Z.callback===null)r(u);else if(Z.startTime<=V)r(u),Z.sortIndex=Z.expirationTime,e(a,Z);else break;Z=n(u)}}function k(V){if(m=!1,w(V),!p)if(n(a)!==null)p=!0,oe(b);else{var Z=n(u);Z!==null&&le(k,Z.startTime-V)}}function b(V,Z){p=!1,m&&(m=!1,g(E),E=-1),h=!0;var M=d;try{for(w(Z),f=n(a);f!==null&&(!(f.expirationTime>Z)||V&&!_());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=Z);Z=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(Z)}else r(a);f=n(a)}if(f!==null)var B=!0;else{var j=n(u);j!==null&&le(k,j.startTime-Z),B=!1}return B}finally{f=null,d=M,h=!1}}var C=!1,T=null,E=-1,R=5,O=-1;function _(){return!(t.unstable_now()-OV||125N?(V.sortIndex=M,e(u,V),n(a)===null&&V===n(u)&&(m?(g(E),E=-1):m=!0,le(k,M-N))):(V.sortIndex=L,e(a,V),p||h||(p=!0,oe(b))),V},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(V){var Z=d;return function(){var M=d;d=Z;try{return V.apply(this,arguments)}finally{d=M}}}})(aC);lC.exports=aC;var pO=lC.exports;/** * @license React * react-dom.production.min.js * @@ -30,171 +30,171 @@ var HR=Object.defineProperty;var WR=(t,e,n)=>e in t?HR(t,e,{enumerable:!0,config * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var dO=v,jr=fO;function ce(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"),Rm=Object.prototype.hasOwnProperty,hO=/^[: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]*$/,Zw={},e1={};function pO(t){return Rm.call(e1,t)?!0:Rm.call(Zw,t)?!1:hO.test(t)?e1[t]=!0:(Zw[t]=!0,!1)}function gO(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 mO(t,e,n,r){if(e===null||typeof e>"u"||gO(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 hr(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 Un={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Un[t]=new hr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Un[e]=new hr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Un[t]=new hr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Un[t]=new hr(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){Un[t]=new hr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Un[t]=new hr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Un[t]=new hr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Un[t]=new hr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Un[t]=new hr(t,5,!1,t.toLowerCase(),null,!1,!1)});var By=/[\-:]([a-z])/g;function zy(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(By,zy);Un[e]=new hr(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(By,zy);Un[e]=new hr(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(By,zy);Un[e]=new hr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Un[t]=new hr(t,1,!1,t.toLowerCase(),null,!1,!1)});Un.xlinkHref=new hr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Un[t]=new hr(t,1,!1,t.toLowerCase(),null,!0,!0)});function jy(t,e,n,r){var i=Un.hasOwnProperty(e)?Un[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Im=Object.prototype.hasOwnProperty,mO=/^[: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 yO(t){return Im.call(r1,t)?!0:Im.call(n1,t)?!1:mO.test(t)?r1[t]=!0:(n1[t]=!0,!1)}function vO(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 wO(t,e,n,r){if(e===null||typeof e>"u"||vO(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 hr(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 Un={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Un[t]=new hr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Un[e]=new hr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Un[t]=new hr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Un[t]=new hr(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){Un[t]=new hr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Un[t]=new hr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Un[t]=new hr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Un[t]=new hr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Un[t]=new hr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Hy=/[\-:]([a-z])/g;function Wy(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(Hy,Wy);Un[e]=new hr(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(Hy,Wy);Un[e]=new hr(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(Hy,Wy);Un[e]=new hr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Un[t]=new hr(t,1,!1,t.toLowerCase(),null,!1,!1)});Un.xlinkHref=new hr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Un[t]=new hr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Vy(t,e,n,r){var i=Un.hasOwnProperty(e)?Un[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{og=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Iu(t):""}function yO(t){switch(t.tag){case 5:return Iu(t.type);case 16:return Iu("Lazy");case 13:return Iu("Suspense");case 19:return Iu("SuspenseList");case 0:case 2:case 15:return t=lg(t.type,!1),t;case 11:return t=lg(t.type.render,!1),t;case 1:return t=lg(t.type,!0),t;default:return""}}function Nm(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 Gl:return"Fragment";case Xl:return"Portal";case Om:return"Profiler";case Hy:return"StrictMode";case Pm:return"Suspense";case Im:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case aC:return(t.displayName||"Context")+".Consumer";case lC:return(t._context.displayName||"Context")+".Provider";case Wy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Vy:return e=t.displayName||null,e!==null?e:Nm(t.type)||"Memo";case Ys:e=t._payload,t=t._init;try{return Nm(t(e))}catch{}}return null}function vO(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 Nm(e);case 8:return e===Hy?"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 xo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function cC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function wO(t){var e=cC(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 Af(t){t._valueTracker||(t._valueTracker=wO(t))}function fC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=cC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function zd(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 Dm(t,e){var n=e.checked;return fn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function n1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=xo(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 dC(t,e){e=e.checked,e!=null&&jy(t,"checked",e,!1)}function _m(t,e){dC(t,e);var n=xo(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")?Lm(t,e.type,n):e.hasOwnProperty("defaultValue")&&Lm(t,e.type,xo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function r1(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 Lm(t,e,n){(e!=="number"||zd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Nu=Array.isArray;function fa(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Mf.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function uc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var zu={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},xO=["Webkit","ms","Moz","O"];Object.keys(zu).forEach(function(t){xO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),zu[e]=zu[t]})});function mC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||zu.hasOwnProperty(t)&&zu[t]?(""+e).trim():e+"px"}function yC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=mC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var bO=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 Bm(t,e){if(e){if(bO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ce(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ce(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ce(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ce(62))}}function zm(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 jm=null;function Uy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Hm=null,da=null,ha=null;function o1(t){if(t=Bc(t)){if(typeof Hm!="function")throw Error(ce(280));var e=t.stateNode;e&&(e=Jh(e),Hm(t.stateNode,t.type,e))}}function vC(t){da?ha?ha.push(t):ha=[t]:da=t}function wC(){if(da){var t=da,e=ha;if(ha=da=null,o1(t),e)for(t=0;t>>=0,t===0?32:31-(IO(t)/NO|0)|0}var Rf=64,Of=4194304;function Du(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 Vd(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=Du(l):(s&=o,s!==0&&(r=Du(s)))}else o=n&~i,o!==0?r=Du(o):s!==0&&(r=Du(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 Fc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ri(e),t[e]=n}function FO(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=Hu),g1=" ",m1=!1;function BC(t,e){switch(t){case"keyup":return fP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function zC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ql=!1;function hP(t,e){switch(t){case"compositionend":return zC(e);case"keypress":return e.which!==32?null:(m1=!0,g1);case"textInput":return t=e.data,t===g1&&m1?null:t;default:return null}}function pP(t,e){if(ql)return t==="compositionend"||!Zy&&BC(t,e)?(t=FC(),kd=Yy=so=null,ql=!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=x1(n)}}function VC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?VC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function UC(){for(var t=window,e=zd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=zd(t.document)}return e}function ev(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 SP(t){var e=UC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&VC(n.ownerDocument.documentElement,n)){if(r!==null&&ev(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=b1(n,s);var o=b1(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,Yl=null,Gm=null,Vu=null,qm=!1;function k1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;qm||Yl==null||Yl!==zd(r)||(r=Yl,"selectionStart"in r&&ev(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}),Vu&&gc(Vu,r)||(Vu=r,r=Xd(Gm,"onSelect"),0Zl||(t.current=t0[Zl],t0[Zl]=null,Zl--)}function Jt(t,e){Zl++,t0[Zl]=t.current,t.current=e}var bo={},nr=Mo(bo),kr=Mo(!1),ll=bo;function Ca(t,e){var n=t.type.contextTypes;if(!n)return bo;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 Sr(t){return t=t.childContextTypes,t!=null}function qd(){rn(kr),rn(nr)}function R1(t,e,n){if(nr.current!==bo)throw Error(ce(168));Jt(nr,e),Jt(kr,n)}function e2(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(ce(108,vO(t)||"Unknown",i));return fn({},n,r)}function Yd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bo,ll=nr.current,Jt(nr,t),Jt(kr,kr.current),!0}function O1(t,e,n){var r=t.stateNode;if(!r)throw Error(ce(169));n?(t=e2(t,e,ll),r.__reactInternalMemoizedMergedChildContext=t,rn(kr),rn(nr),Jt(nr,t)):rn(kr),Jt(kr,n)}var ys=null,Zh=!1,bg=!1;function t2(t){ys===null?ys=[t]:ys.push(t)}function _P(t){Zh=!0,t2(t)}function Ro(){if(!bg&&ys!==null){bg=!0;var t=0,e=Ht;try{var n=ys;for(Ht=1;t>=o,i-=o,ks=1<<32-Ri(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),C===null?b=O:C.sibling=O,C=O,T=M}if(A===w.length)return n(g,T),an&&Vo(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),C===null?b=_:C.sibling=_,C=_,T=M}if(O.done)return n(g,T),an&&Vo(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),C===null?b=O:C.sibling=O,C=O);return an&&Vo(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),C===null?b=O:C.sibling=O,C=O);return t&&T.forEach(function(P){return e(g,P)}),an&&Vo(g,A),b}function x(g,y,w,k){if(typeof w=="object"&&w!==null&&w.type===Gl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Ef:e:{for(var b=w.key,C=y;C!==null;){if(C.key===b){if(b=w.type,b===Gl){if(C.tag===7){n(g,C.sibling),y=i(C,w.props.children),y.return=g,g=y;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===Ys&&N1(b)===C.type){n(g,C.sibling),y=i(C,w.props),y.ref=mu(g,C,w),y.return=g,g=y;break e}n(g,C);break}else e(g,C);C=C.sibling}w.type===Gl?(y=il(w.props.children,g.mode,k,w.key),y.return=g,g=y):(k=Od(w.type,w.key,w.props,null,g.mode,k),k.ref=mu(g,y,w),k.return=g,g=k)}return o(g);case Xl:e:{for(C=w.key;y!==null;){if(y.key===C)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=Rg(w,g.mode,k),y.return=g,g=y}return o(g);case Ys:return C=w._init,x(g,y,C(w._payload),k)}if(Nu(w))return p(g,y,w,k);if(fu(w))return m(g,y,w,k);Ff(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=Mg(w,g.mode,k),y.return=g,g=y),o(g)):n(g,y)}return x}var Ea=s2(!0),o2=s2(!1),Zd=Mo(null),eh=null,na=null,iv=null;function sv(){iv=na=eh=null}function ov(t){var e=Zd.current;rn(Zd),t._currentValue=e}function i0(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 ga(t,e){eh=t,iv=na=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(wr=!0),t.firstContext=null)}function oi(t){var e=t._currentValue;if(iv!==t)if(t={context:t,memoizedValue:e,next:null},na===null){if(eh===null)throw Error(ce(308));na=t,eh.dependencies={lanes:0,firstContext:t}}else na=na.next=t;return e}var Zo=null;function lv(t){Zo===null?Zo=[t]:Zo.push(t)}function l2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,lv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Rs(t,r)}function Rs(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 Qs=!1;function av(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function a2(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 Ts(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function go(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Nt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Rs(t,n)}return i=r.interleaved,i===null?(e.next=e,lv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Rs(t,n)}function Cd(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,Xy(t,n)}}function D1(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 th(t,e,n,r){var i=t.updateQueue;Qs=!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:Qs=!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);cl|=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=Sg.transition;Sg.transition={};try{t(!1),e()}finally{Ht=n,Sg.transition=r}}function T2(){return li().memoizedState}function BP(t,e,n){var r=yo(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},E2(t))A2(e,n);else if(n=l2(t,e,n,r),n!==null){var i=ur();Oi(n,t,r,i),M2(n,e,r)}}function zP(t,e,n){var r=yo(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(E2(t))A2(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,Pi(l,o)){var a=e.interleaved;a===null?(i.next=i,lv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=l2(t,e,i,r),n!==null&&(i=ur(),Oi(n,t,r,i),M2(n,e,r))}}function E2(t){var e=t.alternate;return t===cn||e!==null&&e===cn}function A2(t,e){Uu=rh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function M2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Xy(t,n)}}var ih={readContext:oi,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},jP={readContext:oi,useCallback:function(t,e){return Ki().memoizedState=[t,e===void 0?null:e],t},useContext:oi,useEffect:F1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Ed(4194308,4,x2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Ed(4194308,4,t,e)},useInsertionEffect:function(t,e){return Ed(4,2,t,e)},useMemo:function(t,e){var n=Ki();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Ki();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=BP.bind(null,cn,t),[r.memoizedState,t]},useRef:function(t){var e=Ki();return t={current:t},e.memoizedState=t},useState:L1,useDebugValue:mv,useDeferredValue:function(t){return Ki().memoizedState=t},useTransition:function(){var t=L1(!1),e=t[0];return t=$P.bind(null,t[1]),Ki().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=cn,i=Ki();if(an){if(n===void 0)throw Error(ce(407));n=n()}else{if(n=e(),Fn===null)throw Error(ce(349));ul&30||d2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,F1(p2.bind(null,r,s,t),[t]),r.flags|=2048,Sc(9,h2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Ki(),e=Fn.identifierPrefix;if(an){var n=Ss,r=ks;n=(r&~(1<<32-Ri(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=bc++,0")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{ug=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Nu(t):""}function xO(t){switch(t.tag){case 5:return Nu(t.type);case 16:return Nu("Lazy");case 13:return Nu("Suspense");case 19:return Nu("SuspenseList");case 0:case 2:case 15:return t=cg(t.type,!1),t;case 11:return t=cg(t.type.render,!1),t;case 1:return t=cg(t.type,!0),t;default:return""}}function Lm(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 ql:return"Fragment";case Gl:return"Portal";case Nm:return"Profiler";case Uy:return"StrictMode";case Dm:return"Suspense";case _m:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case fC:return(t.displayName||"Context")+".Consumer";case cC:return(t._context.displayName||"Context")+".Provider";case Ky:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Xy:return e=t.displayName||null,e!==null?e:Lm(t.type)||"Memo";case Ys:e=t._payload,t=t._init;try{return Lm(t(e))}catch{}}return null}function bO(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 Lm(e);case 8:return e===Uy?"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 xo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function hC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function kO(t){var e=hC(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=kO(t))}function pC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=hC(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 Fm(t,e){var n=e.checked;return un({},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=xo(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 gC(t,e){e=e.checked,e!=null&&Vy(t,"checked",e,!1)}function $m(t,e){gC(t,e);var n=xo(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")?zm(t,e.type,n):e.hasOwnProperty("defaultValue")&&zm(t,e.type,xo(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 zm(t,e,n){(e!=="number"||Wd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Du=Array.isArray;function da(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 cc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var ju={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},SO=["Webkit","ms","Moz","O"];Object.keys(ju).forEach(function(t){SO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),ju[e]=ju[t]})});function wC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||ju.hasOwnProperty(t)&&ju[t]?(""+e).trim():e+"px"}function xC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=wC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var CO=un({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 Hm(t,e){if(e){if(CO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(de(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(de(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(de(61))}if(e.style!=null&&typeof e.style!="object")throw Error(de(62))}}function Wm(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 Vm=null;function Gy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Um=null,ha=null,pa=null;function u1(t){if(t=Bc(t)){if(typeof Um!="function")throw Error(de(280));var e=t.stateNode;e&&(e=tp(e),Um(t.stateNode,t.type,e))}}function bC(t){ha?pa?pa.push(t):pa=[t]:ha=t}function kC(){if(ha){var t=ha,e=pa;if(pa=ha=null,u1(t),e)for(t=0;t>>=0,t===0?32:31-(_O(t)/LO|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 $c(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Ri(e),t[e]=n}function BO(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=Wu),v1=" ",w1=!1;function HC(t,e){switch(t){case"keyup":return pP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function WC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Yl=!1;function mP(t,e){switch(t){case"compositionend":return WC(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 yP(t,e){if(Yl)return t==="compositionend"||!nv&&HC(t,e)?(t=BC(),Cd=Zy=so=null,Yl=!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 XC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?XC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function GC(){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 rv(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 EP(t){var e=GC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&XC(n.ownerDocument.documentElement,n)){if(r!==null&&rv(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,Ql=null,Qm=null,Uu=null,Jm=!1;function T1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Jm||Ql==null||Ql!==Wd(r)||(r=Ql,"selectionStart"in r&&rv(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}),Uu&&mc(Uu,r)||(Uu=r,r=Yd(Qm,"onSelect"),0ea||(t.current=i0[ea],i0[ea]=null,ea--)}function Jt(t,e){ea++,i0[ea]=t.current,t.current=e}var bo={},nr=Mo(bo),kr=Mo(!1),al=bo;function Ta(t,e){var n=t.type.contextTypes;if(!n)return bo;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 Sr(t){return t=t.childContextTypes,t!=null}function Jd(){nn(kr),nn(nr)}function I1(t,e,n){if(nr.current!==bo)throw Error(de(168));Jt(nr,e),Jt(kr,n)}function r2(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(de(108,bO(t)||"Unknown",i));return un({},n,r)}function Zd(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||bo,al=nr.current,Jt(nr,t),Jt(kr,kr.current),!0}function N1(t,e,n){var r=t.stateNode;if(!r)throw Error(de(169));n?(t=r2(t,e,al),r.__reactInternalMemoizedMergedChildContext=t,nn(kr),nn(nr),Jt(nr,t)):nn(kr),Jt(kr,n)}var ys=null,np=!1,Cg=!1;function i2(t){ys===null?ys=[t]:ys.push(t)}function $P(t){np=!0,i2(t)}function Ro(){if(!Cg&&ys!==null){Cg=!0;var t=0,e=Ht;try{var n=ys;for(Ht=1;t>=o,i-=o,ks=1<<32-Ri(e)+i|n<E?(R=T,T=null):R=T.sibling;var O=d(g,T,w[E],k);if(O===null){T===null&&(T=R);break}t&&T&&O.alternate===null&&e(g,T),y=s(O,y,E),C===null?b=O:C.sibling=O,C=O,T=R}if(E===w.length)return n(g,T),on&&Uo(g,E),b;if(T===null){for(;EE?(R=T,T=null):R=T.sibling;var _=d(g,T,O.value,k);if(_===null){T===null&&(T=R);break}t&&T&&_.alternate===null&&e(g,T),y=s(_,y,E),C===null?b=_:C.sibling=_,C=_,T=R}if(O.done)return n(g,T),on&&Uo(g,E),b;if(T===null){for(;!O.done;E++,O=w.next())O=f(g,O.value,k),O!==null&&(y=s(O,y,E),C===null?b=O:C.sibling=O,C=O);return on&&Uo(g,E),b}for(T=r(g,T);!O.done;E++,O=w.next())O=h(T,g,E,O.value,k),O!==null&&(t&&O.alternate!==null&&T.delete(O.key===null?E:O.key),y=s(O,y,E),C===null?b=O:C.sibling=O,C=O);return t&&T.forEach(function(P){return e(g,P)}),on&&Uo(g,E),b}function x(g,y,w,k){if(typeof w=="object"&&w!==null&&w.type===ql&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Af:e:{for(var b=w.key,C=y;C!==null;){if(C.key===b){if(b=w.type,b===ql){if(C.tag===7){n(g,C.sibling),y=i(C,w.props.children),y.return=g,g=y;break e}}else if(C.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===Ys&&L1(b)===C.type){n(g,C.sibling),y=i(C,w.props),y.ref=yu(g,C,w),y.return=g,g=y;break e}n(g,C);break}else e(g,C);C=C.sibling}w.type===ql?(y=sl(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=yu(g,y,w),k.return=g,g=k)}return o(g);case Gl:e:{for(C=w.key;y!==null;){if(y.key===C)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=Ig(w,g.mode,k),y.return=g,g=y}return o(g);case Ys:return C=w._init,x(g,y,C(w._payload),k)}if(Du(w))return p(g,y,w,k);if(du(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=Pg(w,g.mode,k),y.return=g,g=y),o(g)):n(g,y)}return x}var Aa=a2(!0),u2=a2(!1),nh=Mo(null),rh=null,ra=null,lv=null;function av(){lv=ra=rh=null}function uv(t){var e=nh.current;nn(nh),t._currentValue=e}function l0(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 ma(t,e){rh=t,lv=ra=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(wr=!0),t.firstContext=null)}function oi(t){var e=t._currentValue;if(lv!==t)if(t={context:t,memoizedValue:e,next:null},ra===null){if(rh===null)throw Error(de(308));ra=t,rh.dependencies={lanes:0,firstContext:t}}else ra=ra.next=t;return e}var el=null;function cv(t){el===null?el=[t]:el.push(t)}function c2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,cv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Rs(t,r)}function Rs(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 Qs=!1;function fv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function f2(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 Ts(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function go(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Nt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Rs(t,n)}return i=r.interleaved,i===null?(e.next=e,cv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Rs(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,Yy(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;Qs=!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=un({},f,d);break e;case 2:Qs=!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);fl|=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=Eg.transition;Eg.transition={};try{t(!1),e()}finally{Ht=n,Eg.transition=r}}function M2(){return li().memoizedState}function HP(t,e,n){var r=yo(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},R2(t))O2(e,n);else if(n=c2(t,e,n,r),n!==null){var i=ur();Oi(n,t,r,i),P2(n,e,r)}}function WP(t,e,n){var r=yo(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(R2(t))O2(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,Pi(l,o)){var a=e.interleaved;a===null?(i.next=i,cv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=c2(t,e,i,r),n!==null&&(i=ur(),Oi(n,t,r,i),P2(n,e,r))}}function R2(t){var e=t.alternate;return t===an||e!==null&&e===an}function O2(t,e){Ku=oh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function P2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Yy(t,n)}}var lh={readContext:oi,useCallback:qn,useContext:qn,useEffect:qn,useImperativeHandle:qn,useInsertionEffect:qn,useLayoutEffect:qn,useMemo:qn,useReducer:qn,useRef:qn,useState:qn,useDebugValue:qn,useDeferredValue:qn,useTransition:qn,useMutableSource:qn,useSyncExternalStore:qn,useId:qn,unstable_isNewReconciler:!1},VP={readContext:oi,useCallback:function(t,e){return Ki().memoizedState=[t,e===void 0?null:e],t},useContext:oi,useEffect:B1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Md(4194308,4,S2.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=Ki();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Ki();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=HP.bind(null,an,t),[r.memoizedState,t]},useRef:function(t){var e=Ki();return t={current:t},e.memoizedState=t},useState:z1,useDebugValue:wv,useDeferredValue:function(t){return Ki().memoizedState=t},useTransition:function(){var t=z1(!1),e=t[0];return t=jP.bind(null,t[1]),Ki().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=an,i=Ki();if(on){if(n===void 0)throw Error(de(407));n=n()}else{if(n=e(),$n===null)throw Error(de(349));cl&30||g2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,B1(y2.bind(null,r,s,t),[t]),r.flags|=2048,Cc(9,m2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Ki(),e=$n.identifierPrefix;if(on){var n=Ss,r=ks;n=(r&~(1<<32-Ri(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=kc++,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[Xi]=e,t[vc]=r,$2(t,e,!1,!1),e.stateNode=t;e:{switch(o=zm(n,r),n){case"dialog":tn("cancel",t),tn("close",t),i=r;break;case"iframe":case"object":case"embed":tn("load",t),i=r;break;case"video":case"audio":for(i=0;i<_u.length;i++)tn(_u[i],t);i=r;break;case"source":tn("error",t),i=r;break;case"img":case"image":case"link":tn("error",t),tn("load",t),i=r;break;case"details":tn("toggle",t),i=r;break;case"input":n1(t,r),i=Dm(t,r),tn("invalid",t);break;case"option":i=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},i=fn({},r,{value:void 0}),tn("invalid",t);break;case"textarea":i1(t,r),i=Fm(t,r),tn("invalid",t);break;default:i=r}Bm(n,i),l=i;for(s in l)if(l.hasOwnProperty(s)){var a=l[s];s==="style"?yC(t,a):s==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,a!=null&&gC(t,a)):s==="children"?typeof a=="string"?(n!=="textarea"||a!=="")&&uc(t,a):typeof a=="number"&&uc(t,""+a):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(ac.hasOwnProperty(s)?a!=null&&s==="onScroll"&&tn("scroll",t):a!=null&&jy(t,s,a,o))}switch(n){case"input":Af(t),r1(t,r,!1);break;case"textarea":Af(t),s1(t);break;case"option":r.value!=null&&t.setAttribute("value",""+xo(r.value));break;case"select":t.multiple=!!r.multiple,s=r.value,s!=null?fa(t,!!r.multiple,s,!1):r.defaultValue!=null&&fa(t,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(t.onclick=Gd)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return Yn(e),null;case 6:if(t&&e.stateNode!=null)z2(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(ce(166));if(n=el(xc.current),el(rs.current),Lf(e)){if(r=e.stateNode,n=e.memoizedProps,r[Xi]=e,(s=r.nodeValue!==n)&&(t=zr,t!==null))switch(t.tag){case 3:_f(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&_f(r.nodeValue,n,(t.mode&1)!==0)}s&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Xi]=e,e.stateNode=r}return Yn(e),null;case 13:if(rn(un),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(an&&Br!==null&&e.mode&1&&!(e.flags&128))i2(),Ta(),e.flags|=98560,s=!1;else if(s=Lf(e),r!==null&&r.dehydrated!==null){if(t===null){if(!s)throw Error(ce(318));if(s=e.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(ce(317));s[Xi]=e}else Ta(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;Yn(e),s=!1}else ki!==null&&(x0(ki),ki=null),s=!0;if(!s)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||un.current&1?Dn===0&&(Dn=3):Sv())),e.updateQueue!==null&&(e.flags|=4),Yn(e),null);case 4:return Aa(),d0(t,e),t===null&&mc(e.stateNode.containerInfo),Yn(e),null;case 10:return ov(e.type._context),Yn(e),null;case 17:return Sr(e.type)&&qd(),Yn(e),null;case 19:if(rn(un),s=e.memoizedState,s===null)return Yn(e),null;if(r=(e.flags&128)!==0,o=s.rendering,o===null)if(r)yu(s,!1);else{if(Dn!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=nh(t),o!==null){for(e.flags|=128,yu(s,!1),r=o.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)s=n,t=r,s.flags&=14680066,o=s.alternate,o===null?(s.childLanes=0,s.lanes=t,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=o.childLanes,s.lanes=o.lanes,s.child=o.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=o.memoizedProps,s.memoizedState=o.memoizedState,s.updateQueue=o.updateQueue,s.type=o.type,t=o.dependencies,s.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return Jt(un,un.current&1|2),e.child}t=t.sibling}s.tail!==null&&kn()>Ra&&(e.flags|=128,r=!0,yu(s,!1),e.lanes=4194304)}else{if(!r)if(t=nh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),yu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!an)return Yn(e),null}else 2*kn()-s.renderingStartTime>Ra&&n!==1073741824&&(e.flags|=128,r=!0,yu(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=kn(),e.sibling=null,n=un.current,Jt(un,r?n&1|2:n&1),e):(Yn(e),null);case 22:case 23:return kv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Nr&1073741824&&(Yn(e),e.subtreeFlags&6&&(e.flags|=8192)):Yn(e),null;case 24:return null;case 25:return null}throw Error(ce(156,e.tag))}function qP(t,e){switch(nv(e),e.tag){case 1:return Sr(e.type)&&qd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Aa(),rn(kr),rn(nr),fv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return cv(e),null;case 13:if(rn(un),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ce(340));Ta()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return rn(un),null;case 4:return Aa(),null;case 10:return ov(e.type._context),null;case 22:case 23:return kv(),null;case 24:return null;default:return null}}var Bf=!1,er=!1,YP=typeof WeakSet=="function"?WeakSet:Set,Pe=null;function ra(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){hn(t,e,r)}else n.current=null}function h0(t,e,n){try{n()}catch(r){hn(t,e,r)}}var G1=!1;function QP(t,e){if(Ym=Ud,t=UC(),ev(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(Qm={focusedElem:t,selectionRange:n},Ud=!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:xi(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(ce(163))}}catch(k){hn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Pe=t;break}Pe=e.return}return p=G1,G1=!1,p}function Ku(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&&h0(e,n,s)}i=i.next}while(i!==r)}}function np(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 p0(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 j2(t){var e=t.alternate;e!==null&&(t.alternate=null,j2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Xi],delete e[vc],delete e[e0],delete e[NP],delete e[DP])),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 H2(t){return t.tag===5||t.tag===3||t.tag===4}function q1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||H2(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 g0(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=Gd));else if(r!==4&&(t=t.child,t!==null))for(g0(t,e,n),t=t.sibling;t!==null;)g0(t,e,n),t=t.sibling}function m0(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(m0(t,e,n),t=t.sibling;t!==null;)m0(t,e,n),t=t.sibling}var zn=null,bi=!1;function js(t,e,n){for(n=n.child;n!==null;)W2(t,e,n),n=n.sibling}function W2(t,e,n){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(Gh,n)}catch{}switch(n.tag){case 5:er||ra(n,e);case 6:var r=zn,i=bi;zn=null,js(t,e,n),zn=r,bi=i,zn!==null&&(bi?(t=zn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):zn.removeChild(n.stateNode));break;case 18:zn!==null&&(bi?(t=zn,n=n.stateNode,t.nodeType===8?xg(t.parentNode,n):t.nodeType===1&&xg(t,n),hc(t)):xg(zn,n.stateNode));break;case 4:r=zn,i=bi,zn=n.stateNode.containerInfo,bi=!0,js(t,e,n),zn=r,bi=i;break;case 0:case 11:case 14:case 15:if(!er&&(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)&&h0(n,e,o),i=i.next}while(i!==r)}js(t,e,n);break;case 1:if(!er&&(ra(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){hn(n,e,l)}js(t,e,n);break;case 21:js(t,e,n);break;case 22:n.mode&1?(er=(r=er)||n.memoizedState!==null,js(t,e,n),er=r):js(t,e,n);break;default:js(t,e,n)}}function Y1(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new YP),e.forEach(function(r){var i=oI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function yi(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=kn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ZP(r/1960))-r,10t?16:t,oo===null)var r=!1;else{if(t=oo,oo=null,lh=0,Nt&6)throw Error(ce(331));var i=Nt;for(Nt|=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;akn()-xv?rl(t,0):wv|=n),Cr(t,e)}function Q2(t,e){e===0&&(t.mode&1?(e=Of,Of<<=1,!(Of&130023424)&&(Of=4194304)):e=1);var n=ur();t=Rs(t,e),t!==null&&(Fc(t,e,n),Cr(t,n))}function sI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),Q2(t,n)}function oI(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(ce(314))}r!==null&&r.delete(e),Q2(t,n)}var J2;J2=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||kr.current)wr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return wr=!1,XP(t,e,n);wr=!!(t.flags&131072)}else wr=!1,an&&e.flags&1048576&&n2(e,Jd,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Ad(t,e),t=e.pendingProps;var i=Ca(e,nr.current);ga(e,n),i=hv(null,e,r,t,i,n);var s=pv();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,Sr(r)?(s=!0,Yd(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,av(e),i.updater=tp,e.stateNode=i,i._reactInternals=e,o0(e,r,t,n),e=u0(null,e,r,!0,s,n)):(e.tag=0,an&&s&&tv(e),lr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Ad(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=aI(r),t=xi(r,t),i){case 0:e=a0(null,e,r,t,n);break e;case 1:e=U1(null,e,r,t,n);break e;case 11:e=W1(null,e,r,t,n);break e;case 14:e=V1(null,e,r,xi(r.type,t),n);break e}throw Error(ce(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),a0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),U1(t,e,r,i,n);case 3:e:{if(_2(e),t===null)throw Error(ce(387));r=e.pendingProps,s=e.memoizedState,i=s.element,a2(t,e),th(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=Ma(Error(ce(423)),e),e=K1(t,e,r,n,i);break e}else if(r!==i){i=Ma(Error(ce(424)),e),e=K1(t,e,r,n,i);break e}else for(Br=po(e.stateNode.containerInfo.firstChild),zr=e,an=!0,ki=null,n=o2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ta(),r===i){e=Os(t,e,n);break e}lr(t,e,r,n)}e=e.child}return e;case 5:return u2(e),t===null&&r0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,Jm(r,i)?o=null:s!==null&&Jm(r,s)&&(e.flags|=32),D2(t,e),lr(t,e,o,n),e.child;case 6:return t===null&&r0(e),null;case 13:return L2(t,e,n);case 4:return uv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ea(e,null,r,n):lr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),W1(t,e,r,i,n);case 7:return lr(t,e,e.pendingProps,n),e.child;case 8:return lr(t,e,e.pendingProps.children,n),e.child;case 12:return lr(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,Jt(Zd,r._currentValue),r._currentValue=o,s!==null)if(Pi(s.value,o)){if(s.children===i.children&&!kr.current){e=Os(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=Ts(-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),i0(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(ce(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),i0(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}lr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,ga(e,n),i=oi(i),r=r(i),e.flags|=1,lr(t,e,r,n),e.child;case 14:return r=e.type,i=xi(r,e.pendingProps),i=xi(r.type,i),V1(t,e,r,i,n);case 15:return I2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),Ad(t,e),e.tag=1,Sr(r)?(t=!0,Yd(e)):t=!1,ga(e,n),R2(e,r,i),o0(e,r,i,n),u0(null,e,r,!0,t,n);case 19:return F2(t,e,n);case 22:return N2(t,e,n)}throw Error(ce(156,e.tag))};function Z2(t,e){return EC(t,e)}function lI(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 Jr(t,e,n,r){return new lI(t,e,n,r)}function Cv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function aI(t){if(typeof t=="function")return Cv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Wy)return 11;if(t===Vy)return 14}return 2}function vo(t,e){var n=t.alternate;return n===null?(n=Jr(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 Od(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Cv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Gl:return il(n.children,i,s,e);case Hy:o=8,i|=8;break;case Om:return t=Jr(12,n,e,i|2),t.elementType=Om,t.lanes=s,t;case Pm:return t=Jr(13,n,e,i),t.elementType=Pm,t.lanes=s,t;case Im:return t=Jr(19,n,e,i),t.elementType=Im,t.lanes=s,t;case uC:return ip(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case lC:o=10;break e;case aC:o=9;break e;case Wy:o=11;break e;case Vy:o=14;break e;case Ys:o=16,r=null;break e}throw Error(ce(130,t==null?t:typeof t,""))}return e=Jr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function il(t,e,n,r){return t=Jr(7,t,r,e),t.lanes=n,t}function ip(t,e,n,r){return t=Jr(22,t,r,e),t.elementType=uC,t.lanes=n,t.stateNode={isHidden:!1},t}function Mg(t,e,n){return t=Jr(6,t,null,e),t.lanes=n,t}function Rg(t,e,n){return e=Jr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function uI(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=ug(0),this.expirationTimes=ug(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ug(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Tv(t,e,n,r,i,s,o,l,a){return t=new uI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Jr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},av(s),t}function cI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rT)}catch(t){console.error(t)}}rT(),rC.exports=Hr;var gI=rC.exports,iT,ix=gI;iT=ix.createRoot,ix.hydrateRoot;function sT(){return""}function mI(){return/^G-[A-Z0-9]+$/.test(sT())}function yI(){const t=window.gtag;typeof t=="function"&&mI()&&t("config",sT(),{send_page_view:!1})}function vI(){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 wI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function xI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function bI(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 kI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function up(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,kI(t),{props:{...e}})}function SI(t){up("input",t)}function CI(t){up("conversion",t)}function Bo(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};up("export",e)}function TI(t){up("feedback",t)}function EI(t){return new TextEncoder().encode(t).length}function AI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function MI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function RI(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=EI(h.text),m=AI(p),x=i(h.direction,h.text),g=`${h.direction}:${h.input}:${p}:${MI(h.text)}`,y=r();return g!==l&&(a===0||y-a>=n)&&(l=g,a=y,SI({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)}}}/** +`+s.stack}return{value:t,source:e,stack:i,digest:null}}function Rg(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function c0(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var XP=typeof WeakMap=="function"?WeakMap:Map;function N2(t,e,n){n=Ts(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){uh||(uh=!0,x0=r),c0(t,e)},n}function D2(t,e,n){n=Ts(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){c0(t,e)}}var s=t.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){c0(t,e),typeof r!="function"&&(mo===null?mo=new Set([this]):mo.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function W1(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new XP;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=lI.bind(null,t,e,n),e.then(t,t))}function V1(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function U1(t,e,n,r,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Ts(-1,1),e.tag=2,go(n,e,1))),n.lanes|=1),t)}var GP=Is.ReactCurrentOwner,wr=!1;function lr(t,e,n,r){e.child=t===null?u2(e,null,n,r):Aa(e,t.child,n,r)}function K1(t,e,n,r,i){n=n.render;var s=e.ref;return ma(e,i),r=mv(t,e,n,r,s,i),n=yv(),t!==null&&!wr?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Os(t,e,i)):(on&&n&&iv(e),e.flags|=1,lr(t,e,r,i),e.child)}function X1(t,e,n,r,i){if(t===null){var s=n.type;return typeof s=="function"&&!Av(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=s,_2(t,e,s,r,i)):(t=Id(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(s=t.child,!(t.lanes&i)){var o=s.memoizedProps;if(n=n.compare,n=n!==null?n:mc,n(o,r)&&t.ref===e.ref)return Os(t,e,i)}return e.flags|=1,t=vo(s,r),t.ref=e.ref,t.return=e,e.child=t}function _2(t,e,n,r,i){if(t!==null){var s=t.memoizedProps;if(mc(s,r)&&t.ref===e.ref)if(wr=!1,e.pendingProps=r=s,(t.lanes&i)!==0)t.flags&131072&&(wr=!0);else return e.lanes=t.lanes,Os(t,e,i)}return f0(t,e,n,r,i)}function L2(t,e,n){var r=e.pendingProps,i=r.children,s=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},Jt(sa,Nr),Nr|=n;else{if(!(n&1073741824))return t=s!==null?s.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,Jt(sa,Nr),Nr|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Jt(sa,Nr),Nr|=r}else s!==null?(r=s.baseLanes|n,e.memoizedState=null):r=n,Jt(sa,Nr),Nr|=r;return lr(t,e,i,n),e.child}function F2(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function f0(t,e,n,r,i){var s=Sr(n)?al:nr.current;return s=Ta(e,s),ma(e,i),n=mv(t,e,n,r,s,i),r=yv(),t!==null&&!wr?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Os(t,e,i)):(on&&r&&iv(e),e.flags|=1,lr(t,e,n,i),e.child)}function G1(t,e,n,r,i){if(Sr(n)){var s=!0;Zd(e)}else s=!1;if(ma(e,i),e.stateNode===null)Rd(t,e),I2(e,n,r),u0(e,n,r,i),r=!0;else if(t===null){var o=e.stateNode,l=e.memoizedProps;o.props=l;var a=o.context,u=n.contextType;typeof u=="object"&&u!==null?u=oi(u):(u=Sr(n)?al:nr.current,u=Ta(e,u));var c=n.getDerivedStateFromProps,f=typeof c=="function"||typeof o.getSnapshotBeforeUpdate=="function";f||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==r||a!==u)&&H1(e,o,r,u),Qs=!1;var d=e.memoizedState;o.state=d,ih(e,r,o,i),a=e.memoizedState,l!==r||d!==a||kr.current||Qs?(typeof c=="function"&&(a0(e,n,c,r),a=e.memoizedState),(l=Qs||j1(e,n,l,r,d,a,u))?(f||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=a),o.props=r,o.state=a,o.context=u,r=l):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,f2(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:xi(e.type,l),o.props=u,f=e.pendingProps,d=o.context,a=n.contextType,typeof a=="object"&&a!==null?a=oi(a):(a=Sr(n)?al:nr.current,a=Ta(e,a));var h=n.getDerivedStateFromProps;(c=typeof h=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(l!==f||d!==a)&&H1(e,o,r,a),Qs=!1,d=e.memoizedState,o.state=d,ih(e,r,o,i);var p=e.memoizedState;l!==f||d!==p||kr.current||Qs?(typeof h=="function"&&(a0(e,n,h,r),p=e.memoizedState),(u=Qs||j1(e,n,u,r,d,p,a)||!1)?(c||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,p,a),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,p,a)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=p),o.props=r,o.state=p,o.context=a,r=u):(typeof o.componentDidUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),r=!1)}return d0(t,e,n,r,s,i)}function d0(t,e,n,r,i,s){F2(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return i&&N1(e,n,!1),Os(t,e,s);r=e.stateNode,GP.current=e;var l=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Aa(e,t.child,null,s),e.child=Aa(e,null,l,s)):lr(t,e,l,s),e.memoizedState=r.state,i&&N1(e,n,!0),e.child}function $2(t){var e=t.stateNode;e.pendingContext?I1(t,e.pendingContext,e.pendingContext!==e.context):e.context&&I1(t,e.context,!1),dv(t,e.containerInfo)}function q1(t,e,n,r,i){return Ea(),ov(i),e.flags|=256,lr(t,e,n,r),e.child}var h0={dehydrated:null,treeContext:null,retryLane:0};function p0(t){return{baseLanes:t,cachePool:null,transitions:null}}function z2(t,e,n){var r=e.pendingProps,i=ln.current,s=!1,o=(e.flags&128)!==0,l;if((l=o)||(l=t!==null&&t.memoizedState===null?!1:(i&2)!==0),l?(s=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),Jt(ln,i&1),t===null)return o0(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,s?(r=e.mode,s=e.child,o={mode:"hidden",children:o},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=o):s=lp(o,r,0,null),t=sl(t,r,n,null),s.return=e,t.return=e,s.sibling=t,e.child=s,e.child.memoizedState=p0(n),e.memoizedState=h0,t):xv(e,o));if(i=t.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return qP(t,e,o,r,l,i,n);if(s){s=r.fallback,o=e.mode,i=t.child,l=i.sibling;var a={mode:"hidden",children:r.children};return!(o&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=a,e.deletions=null):(r=vo(i,a),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?s=vo(l,s):(s=sl(s,o,n,null),s.flags|=2),s.return=e,r.return=e,r.sibling=s,e.child=r,r=s,s=e.child,o=t.child.memoizedState,o=o===null?p0(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},s.memoizedState=o,s.childLanes=t.childLanes&~n,e.memoizedState=h0,r}return s=t.child,t=s.sibling,r=vo(s,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function xv(t,e){return e=lp({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function zf(t,e,n,r){return r!==null&&ov(r),Aa(e,t.child,null,n),t=xv(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function qP(t,e,n,r,i,s,o){if(n)return e.flags&256?(e.flags&=-257,r=Rg(Error(de(422))),zf(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(s=r.fallback,i=e.mode,r=lp({mode:"visible",children:r.children},i,0,null),s=sl(s,i,o,null),s.flags|=2,r.return=e,s.return=e,r.sibling=s,e.child=r,e.mode&1&&Aa(e,t.child,null,o),e.child.memoizedState=p0(o),e.memoizedState=h0,s);if(!(e.mode&1))return zf(t,e,o,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(de(419)),r=Rg(s,r,void 0),zf(t,e,o,r)}if(l=(o&t.childLanes)!==0,wr||l){if(r=$n,r!==null){switch(o&-o){case 4:i=2;break;case 16:i=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|o)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,Rs(t,i),Oi(r,t,i,-1))}return Ev(),r=Rg(Error(de(421))),zf(t,e,o,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=aI.bind(null,t),i._reactRetry=e,null):(t=s.treeContext,zr=po(i.nextSibling),Br=e,on=!0,ki=null,t!==null&&(qr[Yr++]=ks,qr[Yr++]=Ss,qr[Yr++]=ul,ks=t.id,Ss=t.overflow,ul=e),e=xv(e,r.children),e.flags|=4096,e)}function Y1(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),l0(t.return,e,n)}function Og(t,e,n,r,i){var s=t.memoizedState;s===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=e,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function B2(t,e,n){var r=e.pendingProps,i=r.revealOrder,s=r.tail;if(lr(t,e,r.children,n),r=ln.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&Y1(t,n,e);else if(t.tag===19)Y1(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(Jt(ln,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&sh(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Og(e,!1,i,n,s);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&sh(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Og(e,!0,n,null,s);break;case"together":Og(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Rd(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Os(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),fl|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(de(153));if(e.child!==null){for(t=e.child,n=vo(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=vo(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function YP(t,e,n){switch(e.tag){case 3:$2(e),Ea();break;case 5:d2(e);break;case 1:Sr(e.type)&&Zd(e);break;case 4:dv(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;Jt(nh,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(Jt(ln,ln.current&1),e.flags|=128,null):n&e.child.childLanes?z2(t,e,n):(Jt(ln,ln.current&1),t=Os(t,e,n),t!==null?t.sibling:null);Jt(ln,ln.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return B2(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Jt(ln,ln.current),r)break;return null;case 22:case 23:return e.lanes=0,L2(t,e,n)}return Os(t,e,n)}var j2,g0,H2,W2;j2=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};g0=function(){};H2=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,tl(rs.current);var s=null;switch(n){case"input":i=Fm(t,i),r=Fm(t,r),s=[];break;case"select":i=un({},i,{value:void 0}),r=un({},r,{value:void 0}),s=[];break;case"textarea":i=Bm(t,i),r=Bm(t,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Qd)}Hm(n,r);var o;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(o in l)l.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(uc.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var a=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(o in l)!l.hasOwnProperty(o)||a&&a.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in a)a.hasOwnProperty(o)&&l[o]!==a[o]&&(n||(n={}),n[o]=a[o])}else n||(s||(s=[]),s.push(u,n)),n=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(s=s||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(s=s||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(uc.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&en("scroll",t),s||l===a||(s=[])):(s=s||[]).push(u,a))}n&&(s=s||[]).push("style",n);var u=s;(e.updateQueue=u)&&(e.flags|=4)}};W2=function(t,e,n,r){n!==r&&(e.flags|=4)};function vu(t,e){if(!on)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function Yn(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function QP(t,e,n){var r=e.pendingProps;switch(sv(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Yn(e),null;case 1:return Sr(e.type)&&Jd(),Yn(e),null;case 3:return r=e.stateNode,Ma(),nn(kr),nn(nr),pv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(Ff(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,ki!==null&&(S0(ki),ki=null))),g0(t,e),Yn(e),null;case 5:hv(e);var i=tl(bc.current);if(n=e.type,t!==null&&e.stateNode!=null)H2(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(de(166));return Yn(e),null}if(t=tl(rs.current),Ff(e)){r=e.stateNode,n=e.type;var s=e.memoizedProps;switch(r[Xi]=e,r[wc]=s,t=(e.mode&1)!==0,n){case"dialog":en("cancel",r),en("close",r);break;case"iframe":case"object":case"embed":en("load",r);break;case"video":case"audio":for(i=0;i<\/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[Xi]=e,t[wc]=r,j2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Wm(n,r),n){case"dialog":en("cancel",t),en("close",t),i=r;break;case"iframe":case"object":case"embed":en("load",t),i=r;break;case"video":case"audio":for(i=0;iOa&&(e.flags|=128,r=!0,vu(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),vu(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!on)return Yn(e),null}else 2*kn()-s.renderingStartTime>Oa&&n!==1073741824&&(e.flags|=128,r=!0,vu(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=kn(),e.sibling=null,n=ln.current,Jt(ln,r?n&1|2:n&1),e):(Yn(e),null);case 22:case 23:return Tv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Nr&1073741824&&(Yn(e),e.subtreeFlags&6&&(e.flags|=8192)):Yn(e),null;case 24:return null;case 25:return null}throw Error(de(156,e.tag))}function JP(t,e){switch(sv(e),e.tag){case 1:return Sr(e.type)&&Jd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ma(),nn(kr),nn(nr),pv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return hv(e),null;case 13:if(nn(ln),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(de(340));Ea()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return nn(ln),null;case 4:return Ma(),null;case 10:return uv(e.type._context),null;case 22:case 23:return Tv(),null;case 24:return null;default:return null}}var Bf=!1,er=!1,ZP=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function ia(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){hn(t,e,r)}else n.current=null}function m0(t,e,n){try{n()}catch(r){hn(t,e,r)}}var Q1=!1;function eI(t,e){if(Zm=Gd,t=GC(),rv(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(e0={focusedElem:t,selectionRange:n},Gd=!1,Oe=e;Oe!==null;)if(e=Oe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Oe=t;else for(;Oe!==null;){e=Oe;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:xi(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(de(163))}}catch(k){hn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Oe=t;break}Oe=e.return}return p=Q1,Q1=!1,p}function Xu(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&&m0(e,n,s)}i=i.next}while(i!==r)}}function sp(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 y0(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 V2(t){var e=t.alternate;e!==null&&(t.alternate=null,V2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Xi],delete e[wc],delete e[r0],delete e[LP],delete e[FP])),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 U2(t){return t.tag===5||t.tag===3||t.tag===4}function J1(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||U2(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 v0(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(v0(t,e,n),t=t.sibling;t!==null;)v0(t,e,n),t=t.sibling}function w0(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(w0(t,e,n),t=t.sibling;t!==null;)w0(t,e,n),t=t.sibling}var Bn=null,bi=!1;function js(t,e,n){for(n=n.child;n!==null;)K2(t,e,n),n=n.sibling}function K2(t,e,n){if(ns&&typeof ns.onCommitFiberUnmount=="function")try{ns.onCommitFiberUnmount(Qh,n)}catch{}switch(n.tag){case 5:er||ia(n,e);case 6:var r=Bn,i=bi;Bn=null,js(t,e,n),Bn=r,bi=i,Bn!==null&&(bi?(t=Bn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Bn.removeChild(n.stateNode));break;case 18:Bn!==null&&(bi?(t=Bn,n=n.stateNode,t.nodeType===8?Sg(t.parentNode,n):t.nodeType===1&&Sg(t,n),pc(t)):Sg(Bn,n.stateNode));break;case 4:r=Bn,i=bi,Bn=n.stateNode.containerInfo,bi=!0,js(t,e,n),Bn=r,bi=i;break;case 0:case 11:case 14:case 15:if(!er&&(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)&&m0(n,e,o),i=i.next}while(i!==r)}js(t,e,n);break;case 1:if(!er&&(ia(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){hn(n,e,l)}js(t,e,n);break;case 21:js(t,e,n);break;case 22:n.mode&1?(er=(r=er)||n.memoizedState!==null,js(t,e,n),er=r):js(t,e,n);break;default:js(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 ZP),e.forEach(function(r){var i=uI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function yi(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=kn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*nI(r/1960))-r,10t?16:t,oo===null)var r=!1;else{if(t=oo,oo=null,ch=0,Nt&6)throw Error(de(331));var i=Nt;for(Nt|=4,Oe=t.current;Oe!==null;){var s=Oe,o=s.child;if(Oe.flags&16){var l=s.deletions;if(l!==null){for(var a=0;akn()-Sv?il(t,0):kv|=n),Cr(t,e)}function eT(t,e){e===0&&(t.mode&1?(e=Pf,Pf<<=1,!(Pf&130023424)&&(Pf=4194304)):e=1);var n=ur();t=Rs(t,e),t!==null&&($c(t,e,n),Cr(t,n))}function aI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),eT(t,n)}function uI(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(de(314))}r!==null&&r.delete(e),eT(t,n)}var tT;tT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||kr.current)wr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return wr=!1,YP(t,e,n);wr=!!(t.flags&131072)}else wr=!1,on&&e.flags&1048576&&s2(e,th,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Rd(t,e),t=e.pendingProps;var i=Ta(e,nr.current);ma(e,n),i=mv(null,e,r,t,i,n);var s=yv();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,Sr(r)?(s=!0,Zd(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,fv(e),i.updater=ip,e.stateNode=i,i._reactInternals=e,u0(e,r,t,n),e=d0(null,e,r,!0,s,n)):(e.tag=0,on&&s&&iv(e),lr(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=fI(r),t=xi(r,t),i){case 0:e=f0(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,xi(r.type,t),n);break e}throw Error(de(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),f0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),G1(t,e,r,i,n);case 3:e:{if($2(e),t===null)throw Error(de(387));r=e.pendingProps,s=e.memoizedState,i=s.element,f2(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=Ra(Error(de(423)),e),e=q1(t,e,r,n,i);break e}else if(r!==i){i=Ra(Error(de(424)),e),e=q1(t,e,r,n,i);break e}else for(zr=po(e.stateNode.containerInfo.firstChild),Br=e,on=!0,ki=null,n=u2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ea(),r===i){e=Os(t,e,n);break e}lr(t,e,r,n)}e=e.child}return e;case 5:return d2(e),t===null&&o0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,t0(r,i)?o=null:s!==null&&t0(r,s)&&(e.flags|=32),F2(t,e),lr(t,e,o,n),e.child;case 6:return t===null&&o0(e),null;case 13:return z2(t,e,n);case 4:return dv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Aa(e,null,r,n):lr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:xi(r,i),K1(t,e,r,i,n);case 7:return lr(t,e,e.pendingProps,n),e.child;case 8:return lr(t,e,e.pendingProps.children,n),e.child;case 12:return lr(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,Jt(nh,r._currentValue),r._currentValue=o,s!==null)if(Pi(s.value,o)){if(s.children===i.children&&!kr.current){e=Os(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=Ts(-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),l0(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(de(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),l0(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}lr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,ma(e,n),i=oi(i),r=r(i),e.flags|=1,lr(t,e,r,n),e.child;case 14:return r=e.type,i=xi(r,e.pendingProps),i=xi(r.type,i),X1(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:xi(r,i),Rd(t,e),e.tag=1,Sr(r)?(t=!0,Zd(e)):t=!1,ma(e,n),I2(e,r,i),u0(e,r,i,n),d0(null,e,r,!0,t,n);case 19:return B2(t,e,n);case 22:return L2(t,e,n)}throw Error(de(156,e.tag))};function nT(t,e){return RC(t,e)}function cI(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 Jr(t,e,n,r){return new cI(t,e,n,r)}function Av(t){return t=t.prototype,!(!t||!t.isReactComponent)}function fI(t){if(typeof t=="function")return Av(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Ky)return 11;if(t===Xy)return 14}return 2}function vo(t,e){var n=t.alternate;return n===null?(n=Jr(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")Av(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case ql:return sl(n.children,i,s,e);case Uy:o=8,i|=8;break;case Nm:return t=Jr(12,n,e,i|2),t.elementType=Nm,t.lanes=s,t;case Dm:return t=Jr(13,n,e,i),t.elementType=Dm,t.lanes=s,t;case _m:return t=Jr(19,n,e,i),t.elementType=_m,t.lanes=s,t;case dC:return lp(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case cC:o=10;break e;case fC:o=9;break e;case Ky:o=11;break e;case Xy:o=14;break e;case Ys:o=16,r=null;break e}throw Error(de(130,t==null?t:typeof t,""))}return e=Jr(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function sl(t,e,n,r){return t=Jr(7,t,r,e),t.lanes=n,t}function lp(t,e,n,r){return t=Jr(22,t,r,e),t.elementType=dC,t.lanes=n,t.stateNode={isHidden:!1},t}function Pg(t,e,n){return t=Jr(6,t,null,e),t.lanes=n,t}function Ig(t,e,n){return e=Jr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function dI(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=dg(0),this.expirationTimes=dg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Mv(t,e,n,r,i,s,o,l,a){return t=new dI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=Jr(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},fv(s),t}function hI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(oT)}catch(t){console.error(t)}}oT(),oC.exports=Hr;var vI=oC.exports,lT,lx=vI;lT=lx.createRoot,lx.hydrateRoot;function aT(){return""}function wI(){return/^G-[A-Z0-9]+$/.test(aT())}function xI(){const t=window.gtag;typeof t=="function"&&wI()&&t("config",aT(),{send_page_view:!1})}function bI(){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 kI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function SI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function CI(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 TI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function dp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,TI(t),{props:{...e}})}function EI(t){dp("input",t)}function AI(t){dp("conversion",t)}function zo(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};dp("export",e)}function MI(t){dp("feedback",t)}function RI(t){return new TextEncoder().encode(t).length}function OI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function PI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function II(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=RI(h.text),m=OI(p),x=i(h.direction,h.text),g=`${h.direction}:${h.input}:${p}:${PI(h.text)}`,y=r();return g!==l&&(a===0||y-a>=n)&&(l=g,a=y,EI({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 oT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** + */const uT=(...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 OI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** + */const NI=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 PI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** + */const DI=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 sx=t=>{const e=PI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** + */const ax=t=>{const e=DI(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 Og={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"};/** + */var Ng={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 II=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},NI=v.createContext({}),DI=()=>v.useContext(NI),_I=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=""}=DI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,...Og,width:e??u??Og.width,height:e??u??Og.height,stroke:t??d,strokeWidth:p,className:oT("lucide",h,i),...!s&&!II(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>v.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** + */const _I=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},LI=v.createContext({}),FI=()=>v.useContext(LI),$I=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=""}=FI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,...Ng,width:e??u??Ng.width,height:e??u??Ng.height,stroke:t??d,strokeWidth:p,className:uT("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 Cn=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement(_I,{ref:s,iconNode:e,className:oT(`lucide-${OI(sx(t))}`,`lucide-${t}`,r),...i}));return n.displayName=sx(t),n};/** + */const Cn=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement($I,{ref:s,iconNode:e,className:uT(`lucide-${NI(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 LI=[["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"}]],FI=Cn("arrow-left-right",LI);/** + */const zI=[["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"}]],BI=Cn("arrow-left-right",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 $I=[["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"}]],ox=Cn("braces",$I);/** + */const jI=[["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=Cn("braces",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 BI=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],zI=Cn("chevron-down",BI);/** + */const HI=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],WI=Cn("chevron-down",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 jI=[["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"}]],HI=Cn("clipboard",jI);/** + */const VI=[["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"}]],UI=Cn("clipboard",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 WI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],VI=Cn("clock",WI);/** + */const KI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],XI=Cn("clock",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 UI=[["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"}]],Rv=Cn("copy",UI);/** + */const GI=[["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"}]],Iv=Cn("copy",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 KI=[["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"}]],lT=Cn("download",KI);/** + */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"}]],cT=Cn("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 XI=[["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"}]],aT=Cn("file-up",XI);/** + */const YI=[["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"}]],fT=Cn("file-up",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 GI=[["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"}]],qI=Cn("moon",GI);/** + */const QI=[["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"}]],JI=Cn("moon",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 YI=[["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"}]],QI=Cn("redo-2",YI);/** + */const ZI=[["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"}]],eN=Cn("redo-2",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 JI=[["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"}]],ZI=Cn("rotate-ccw-clock",JI);/** + */const tN=[["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"}]],nN=Cn("rotate-ccw-clock",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 eN=[["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"}]],lx=Cn("rotate-ccw",eN);/** + */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"}]],cx=Cn("rotate-ccw",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 tN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],nN=Cn("search",tN);/** + */const iN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],sN=Cn("search",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 rN=[["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"}]],iN=Cn("sparkles",rN);/** + */const oN=[["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"}]],lN=Cn("sparkles",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 sN=[["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"}]],oN=Cn("sun",sN);/** + */const aN=[["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"}]],uN=Cn("sun",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 lN=[["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"}]],aN=Cn("table",lN);/** + */const cN=[["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"}]],fN=Cn("table",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 uN=[["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"}]],cN=Cn("thumbs-down",uN);/** + */const dN=[["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"}]],hN=Cn("thumbs-down",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 fN=[["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"}]],dN=Cn("thumbs-up",fN);/** + */const pN=[["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"}]],gN=Cn("thumbs-up",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 hN=[["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"}]],ch=Cn("trash",hN);/** + */const mN=[["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=Cn("trash",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 pN=[["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"}]],gN=Cn("undo-2",pN);/** + */const yN=[["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"}]],vN=Cn("undo-2",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 mN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ov=Cn("x",mN);function uT(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=xN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(Pv);return l[0]===""&&l.length!==1&&l.shift(),cT(l,e)||wN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},cT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?cT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(Pv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},ax=/^\[(.+)\]$/,wN=t=>{if(ax.test(t)){const e=ax.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},xN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return kN(Object.entries(t.classGroups),n).forEach(([s,o])=>{b0(o,r,s,e)}),r},b0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:ux(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(bN(i)){b0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{b0(o,ux(e,s),n,r)})})},ux=(t,e)=>{let n=t;return e.split(Pv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},bN=t=>t.isThemeGetter,kN=(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,SN=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)}}},fT="!",CN=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},TN=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},EN=t=>({cache:SN(t.cacheSize),parseClassName:CN(t),...vN(t)}),AN=/\s+/,MN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(AN);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=TN(c).join(":"),g=f?x+fT: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 RN(){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=EN(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=MN(a,n);return i(a,c),c}return function(){return s(RN.apply(null,arguments))}}const en=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},hT=/^\[(?:([a-z-]+):)?(.+)\]$/i,PN=/^\d+\/\d+$/,IN=new Set(["px","full","screen"]),NN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,DN=/\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$/,_N=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,LN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,FN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ps=t=>ya(t)||IN.has(t)||PN.test(t),Hs=t=>Va(t,"length",UN),ya=t=>!!t&&!Number.isNaN(Number(t)),Pg=t=>Va(t,"number",ya),wu=t=>!!t&&Number.isInteger(Number(t)),$N=t=>t.endsWith("%")&&ya(t.slice(0,-1)),gt=t=>hT.test(t),Ws=t=>NN.test(t),BN=new Set(["length","size","percentage"]),zN=t=>Va(t,BN,pT),jN=t=>Va(t,"position",pT),HN=new Set(["image","url"]),WN=t=>Va(t,HN,XN),VN=t=>Va(t,"",KN),xu=()=>!0,Va=(t,e,n)=>{const r=hT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},UN=t=>DN.test(t)&&!_N.test(t),pT=()=>!1,KN=t=>LN.test(t),XN=t=>FN.test(t),GN=()=>{const t=en("colors"),e=en("spacing"),n=en("blur"),r=en("brightness"),i=en("borderColor"),s=en("borderRadius"),o=en("borderSpacing"),l=en("borderWidth"),a=en("contrast"),u=en("grayscale"),c=en("hueRotate"),f=en("invert"),d=en("gap"),h=en("gradientColorStops"),p=en("gradientColorStopPositions"),m=en("inset"),x=en("margin"),g=en("opacity"),y=en("padding"),w=en("saturate"),k=en("scale"),b=en("sepia"),C=en("skew"),T=en("space"),A=en("translate"),M=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",gt,e],P=()=>[gt,e],I=()=>["",ps,Hs],D=()=>["auto",ya,gt],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>["start","end","center","between","around","evenly","stretch"],J=()=>["","0",gt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[ya,gt];return{cacheSize:500,separator:":",theme:{colors:[xu],spacing:[ps,Hs],blur:["none","",Ws,gt],brightness:N(),borderColor:[t],borderRadius:["none","","full",Ws,gt],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:J(),hueRotate:N(),invert:J(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[$N,Hs],inset:_(),margin:_(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:J(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",gt]}],container:["container"],columns:[{columns:[Ws]}],"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:[...Y(),gt]}],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",wu,gt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",gt]}],grow:[{grow:J()}],shrink:[{shrink:J()}],order:[{order:["first","last","none",wu,gt]}],"grid-cols":[{"grid-cols":[xu]}],"col-start-end":[{col:["auto",{span:["full",wu,gt]},gt]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[xu]}],"row-start-end":[{row:["auto",{span:[wu,gt]},gt]}],"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",gt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",gt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...V()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...V(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...V(),"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",gt,e]}],"min-w":[{"min-w":[gt,e,"min","max","fit"]}],"max-w":[{"max-w":[gt,e,"none","full","min","max","fit","prose",{screen:[Ws]},Ws]}],h:[{h:[gt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[gt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[gt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[gt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ws,Hs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Pg]}],"font-family":[{font:[xu]}],"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",gt]}],"line-clamp":[{"line-clamp":["none",ya,Pg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ps,gt]}],"list-image":[{"list-image":["none",gt]}],"list-style-type":[{list:["none","disc","decimal",gt]}],"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",ps,Hs]}],"underline-offset":[{"underline-offset":["auto",ps,gt]}],"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",gt]}],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",gt]}],"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:[...Y(),jN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",zN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},WN]}],"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":[ps,gt]}],"outline-w":[{outline:[ps,Hs]}],"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":[ps,Hs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ws,VN]}],"shadow-color":[{shadow:[xu]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":se()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Ws,gt]}],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",gt]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",gt]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",gt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[wu,gt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",gt]}],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",gt]}],"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",gt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ps,Hs,Pg]}],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"]}}},qN=ON(GN);function xr(...t){return qN(yN(t))}function Ig(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function YN({flipped:t}){return E.jsx(FI,{size:18,strokeWidth:2,"aria-hidden":"true",className:xr("transition-transform duration-300",t&&"rotate-180")})}function QN({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 ${Ig(t)})`,"aria-label":`Switch conversion direction (currently ${Ig(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(YN,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Ig(t)})]})}const gT=[{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."}],JN={"@context":"https://schema.org","@type":"FAQPage",mainEntity:gT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function ZN(){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:gT.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(JN)}})]})}const eD="https://github.com/FlatFilers/csvjson-app/discussions/163";function tD(){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:eD,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 mT="csvjson:feedback.v1",nD=[{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 rD(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 cx(){try{const t=window.localStorage.getItem(mT);if(t===null)return null;const e=JSON.parse(t);return rD(e)?e:null}catch{return null}}function fx(t){try{window.localStorage.setItem(mT,JSON.stringify(t))}catch{}}function dx(){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 iD(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 sD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(iD(t))})).ok?"ok":"failed"}catch{return"failed"}}function hx(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 oD(){const[t,e]=v.useState(cx),[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,C)=>{const T={...b,pending:C==="failed"};fx(T),e(T),C==="ok"?TI({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=v.useCallback((b,C)=>{const T=++h.current;C&&f(!0),sD(b).then(A=>{h.current===T&&(p(b,A),A==="ok"&&u(!0))}).finally(()=>{C&&h.current===T&&f(!1)})},[p]),x=b=>{const C={...b,pending:!0};fx(C),e(C),m(C,!0)},g=v.useRef(!1);v.useEffect(()=>{if(g.current)return;g.current=!0;const b=cx();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)},C=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",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",C)}},[n]);const y=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??dx(),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)??dx(),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:hx((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:hx((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:nD.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 yT(t="This should not happen"){throw new Error(t)}function Lr(t,e="Assertion failed"){if(!t)return yT(e)}function Tc(t,e){return yT(e??"Hell froze over")}function lD(t,e){try{return t()}catch{return e}}const px=Object.prototype.hasOwnProperty;function Oa(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--&&Oa(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(px.call(t,n)&&++r&&!px.call(e,n)||!(n in e)||!Oa(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var aD=Object.prototype,uD=aD.hasOwnProperty;function cD(t,e){return t!=null&&uD.call(t,e)}var fD=cD,dD=Array.isArray,ls=dD,hD=typeof io=="object"&&io&&io.Object===Object&&io,vT=hD,pD=vT,gD=typeof self=="object"&&self&&self.Object===Object&&self,mD=pD||gD||Function("return this")(),as=mD,yD=as,vD=yD.Symbol,jc=vD,gx=jc,wT=Object.prototype,wD=wT.hasOwnProperty,xD=wT.toString,bu=gx?gx.toStringTag:void 0;function bD(t){var e=wD.call(t,bu),n=t[bu];try{t[bu]=void 0;var r=!0}catch{}var i=xD.call(t);return r&&(e?t[bu]=n:delete t[bu]),i}var kD=bD,SD=Object.prototype,CD=SD.toString;function TD(t){return CD.call(t)}var ED=TD,mx=jc,AD=kD,MD=ED,RD="[object Null]",OD="[object Undefined]",yx=mx?mx.toStringTag:void 0;function PD(t){return t==null?t===void 0?OD:RD:yx&&yx in Object(t)?AD(t):MD(t)}var Hc=PD;function ID(t){return t!=null&&typeof t=="object"}var Wc=ID,ND=Hc,DD=Wc,_D="[object Symbol]";function LD(t){return typeof t=="symbol"||DD(t)&&ND(t)==_D}var cp=LD,FD=ls,$D=cp,BD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,zD=/^\w*$/;function jD(t,e){if(FD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||$D(t)?!0:zD.test(t)||!BD.test(t)||e!=null&&t in Object(e)}var Iv=jD;function HD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var wl=HD,WD=Hc,VD=wl,UD="[object AsyncFunction]",KD="[object Function]",XD="[object GeneratorFunction]",GD="[object Proxy]";function qD(t){if(!VD(t))return!1;var e=WD(t);return e==KD||e==XD||e==UD||e==GD}var xT=qD,YD=as,QD=YD["__core-js_shared__"],JD=QD,Ng=JD,vx=function(){var t=/[^.]+$/.exec(Ng&&Ng.keys&&Ng.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ZD(t){return!!vx&&vx in t}var e_=ZD,t_=Function.prototype,n_=t_.toString;function r_(t){if(t!=null){try{return n_.call(t)}catch{}try{return t+""}catch{}}return""}var bT=r_,i_=xT,s_=e_,o_=wl,l_=bT,a_=/[\\^$.*+?()[\]{}|]/g,u_=/^\[object .+?Constructor\]$/,c_=Function.prototype,f_=Object.prototype,d_=c_.toString,h_=f_.hasOwnProperty,p_=RegExp("^"+d_.call(h_).replace(a_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function g_(t){if(!o_(t)||s_(t))return!1;var e=i_(t)?p_:u_;return e.test(l_(t))}var m_=g_;function y_(t,e){return t==null?void 0:t[e]}var v_=y_,w_=m_,x_=v_;function b_(t,e){var n=x_(t,e);return w_(n)?n:void 0}var xl=b_,k_=xl,S_=k_(Object,"create"),fp=S_,wx=fp;function C_(){this.__data__=wx?wx(null):{},this.size=0}var T_=C_;function E_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var A_=E_,M_=fp,R_="__lodash_hash_undefined__",O_=Object.prototype,P_=O_.hasOwnProperty;function I_(t){var e=this.__data__;if(M_){var n=e[t];return n===R_?void 0:n}return P_.call(e,t)?e[t]:void 0}var N_=I_,D_=fp,__=Object.prototype,L_=__.hasOwnProperty;function F_(t){var e=this.__data__;return D_?e[t]!==void 0:L_.call(e,t)}var $_=F_,B_=fp,z_="__lodash_hash_undefined__";function j_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=B_&&e===void 0?z_:e,this}var H_=j_,W_=T_,V_=A_,U_=N_,K_=$_,X_=H_;function Ua(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var cL=uL,fL=dp;function dL(t,e){var n=this.__data__,r=fL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var hL=dL,pL=Y_,gL=iL,mL=lL,yL=cL,vL=hL;function Ka(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=O3}var Bv=P3,I3=cp;function N3(t){if(typeof t=="string"||I3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var gp=N3,D3=CT,_3=Fv,L3=ls,F3=$v,$3=Bv,B3=gp;function z3(t,e,n){e=D3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new ms(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=X3([...this.items,n]);return new ms(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&&eAx??(Ax=new ms([]))),xt(ms,"fromSingleSelection",e=>ms.empty().add(e));let Pt=ms;function G3(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var q3=/^((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)-.*))$/,Dg=G3(function(t){return q3.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Y3=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(" ")},Mx=Y3,Q3=t=>t.toUpperCase()===t,J3=t=>e=>t.indexOf(e)===-1,AT=(t,e)=>{const n={};return Object.keys(t).filter(J3(e)).forEach(r=>{n[r]=t[r]}),n};function Z3(t,e,n){const r=AT(e,n);if(!t){const i=typeof Dg=="function"?{default:Dg}:Dg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var eF=(t,e)=>{};function tF(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&&!Q3(l[0])):n.propsAsIs,c=Z3(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Mx(n.class,c.className||a):Mx(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;eF(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,Nn.createElement(t,c)):Nn.createElement(l,c)},i=Nn.forwardRef?Nn.forwardRef(r):s=>{const o=AT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Vr=tF;const nF=Vr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var MT={},mp={},jv={},_g={},Lg={exports:{}},Fg,Rx;function rF(){if(Rx)return Fg;Rx=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Fg=t,Fg}var $g,Ox;function iF(){if(Ox)return $g;Ox=1;var t=rF();function e(){}function n(){}return n.resetWarningCache=e,$g=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},$g}var Px;function sF(){return Px||(Px=1,Lg.exports=iF()()),Lg.exports}var Ix;function oF(){return Ix||(Ix=1,function(t){(function(e,n){n(t,v,sF())})(io,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 C=y.screenX,T=y.screenY;return{x:C,y:T}}var g=function(y){d(w,y);function w(){var k;u(this,w);for(var b=arguments.length,C=Array(b),T=0;TC&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,b):this.movePosition.deltaY>C&&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 C=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:C,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})}(_g)),_g}(function(t){(function(e,n){n(t,oF())})(io,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})})(jv);var Vc={},RT={exports:{}};/*! + */const wN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Nv=Cn("x",wN);function dT(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=SN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(Dv);return l[0]===""&&l.length!==1&&l.shift(),hT(l,e)||kN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},hT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?hT(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=/^\[(.+)\]$/,kN=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}},SN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return TN(Object.entries(t.classGroups),n).forEach(([s,o])=>{C0(o,r,s,e)}),r},C0=(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(CN(i)){C0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{C0(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},CN=t=>t.isThemeGetter,TN=(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,EN=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)}}},pT="!",AN=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},MN=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},RN=t=>({cache:EN(t.cacheSize),parseClassName:AN(t),...bN(t)}),ON=/\s+/,PN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(ON);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=MN(c).join(":"),g=f?x+pT: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 IN(){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=RN(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=PN(a,n);return i(a,c),c}return function(){return s(IN.apply(null,arguments))}}const Zt=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},mT=/^\[(?:([a-z-]+):)?(.+)\]$/i,DN=/^\d+\/\d+$/,_N=new Set(["px","full","screen"]),LN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,FN=/\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$/,$N=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,zN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,BN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ps=t=>va(t)||_N.has(t)||DN.test(t),Hs=t=>Ua(t,"length",GN),va=t=>!!t&&!Number.isNaN(Number(t)),Dg=t=>Ua(t,"number",va),xu=t=>!!t&&Number.isInteger(Number(t)),jN=t=>t.endsWith("%")&&va(t.slice(0,-1)),ht=t=>mT.test(t),Ws=t=>LN.test(t),HN=new Set(["length","size","percentage"]),WN=t=>Ua(t,HN,yT),VN=t=>Ua(t,"position",yT),UN=new Set(["image","url"]),KN=t=>Ua(t,UN,YN),XN=t=>Ua(t,"",qN),bu=()=>!0,Ua=(t,e,n)=>{const r=mT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},GN=t=>FN.test(t)&&!$N.test(t),yT=()=>!1,qN=t=>zN.test(t),YN=t=>BN.test(t),QN=()=>{const t=Zt("colors"),e=Zt("spacing"),n=Zt("blur"),r=Zt("brightness"),i=Zt("borderColor"),s=Zt("borderRadius"),o=Zt("borderSpacing"),l=Zt("borderWidth"),a=Zt("contrast"),u=Zt("grayscale"),c=Zt("hueRotate"),f=Zt("invert"),d=Zt("gap"),h=Zt("gradientColorStops"),p=Zt("gradientColorStopPositions"),m=Zt("inset"),x=Zt("margin"),g=Zt("opacity"),y=Zt("padding"),w=Zt("saturate"),k=Zt("scale"),b=Zt("sepia"),C=Zt("skew"),T=Zt("space"),E=Zt("translate"),R=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",ht,e],P=()=>[ht,e],I=()=>["",ps,Hs],D=()=>["auto",va,ht],Y=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],oe=()=>["solid","dashed","dotted","double","none"],le=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>["start","end","center","between","around","evenly","stretch"],Z=()=>["","0",ht],M=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[va,ht];return{cacheSize:500,separator:":",theme:{colors:[bu],spacing:[ps,Hs],blur:["none","",Ws,ht],brightness:N(),borderColor:[t],borderRadius:["none","","full",Ws,ht],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:Z(),hueRotate:N(),invert:Z(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[jN,Hs],inset:_(),margin:_(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:Z(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",ht]}],container:["container"],columns:[{columns:[Ws]}],"break-after":[{"break-after":M()}],"break-before":[{"break-before":M()}],"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:[...Y(),ht]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:R()}],"overscroll-x":[{"overscroll-x":R()}],"overscroll-y":[{"overscroll-y":R()}],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",xu,ht]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ht]}],grow:[{grow:Z()}],shrink:[{shrink:Z()}],order:[{order:["first","last","none",xu,ht]}],"grid-cols":[{"grid-cols":[bu]}],"col-start-end":[{col:["auto",{span:["full",xu,ht]},ht]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[bu]}],"row-start-end":[{row:["auto",{span:[xu,ht]},ht]}],"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",ht]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ht]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...V()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...V(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...V(),"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",ht,e]}],"min-w":[{"min-w":[ht,e,"min","max","fit"]}],"max-w":[{"max-w":[ht,e,"none","full","min","max","fit","prose",{screen:[Ws]},Ws]}],h:[{h:[ht,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ht,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ht,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ht,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ws,Hs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Dg]}],"font-family":[{font:[bu]}],"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",ht]}],"line-clamp":[{"line-clamp":["none",va,Dg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ps,ht]}],"list-image":[{"list-image":["none",ht]}],"list-style-type":[{list:["none","disc","decimal",ht]}],"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:[...oe(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ps,Hs]}],"underline-offset":[{"underline-offset":["auto",ps,ht]}],"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",ht]}],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",ht]}],"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:[...Y(),VN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",WN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},KN]}],"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:[...oe(),"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:oe()}],"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:["",...oe()]}],"outline-offset":[{"outline-offset":[ps,ht]}],"outline-w":[{outline:[ps,Hs]}],"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":[ps,Hs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ws,XN]}],"shadow-color":[{shadow:[bu]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...le(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":le()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Ws,ht]}],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",ht]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",ht]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",ht]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[xu,ht]}],"translate-x":[{"translate-x":[E]}],"translate-y":[{"translate-y":[E]}],"skew-x":[{"skew-x":[C]}],"skew-y":[{"skew-y":[C]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ht]}],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",ht]}],"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",ht]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ps,Hs,Dg]}],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"]}}},JN=NN(QN);function xr(...t){return JN(xN(t))}function _g(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function ZN({flipped:t}){return A.jsx(BI,{size:18,strokeWidth:2,"aria-hidden":"true",className:xr("transition-transform duration-300",t&&"rotate-180")})}function eD({direction:t,onFlip:e}){return A.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${_g(t)})`,"aria-label":`Switch conversion direction (currently ${_g(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:[A.jsx(ZN,{flipped:t==="json2csv"}),A.jsx("span",{"data-testid":"divider-switch-label",children:_g(t)})]})}const vT=[{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."}],tD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:vT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function nD(){const[t,e]=v.useState(!1),n=v.useId();return A.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:[A.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:[A.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),A.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:vT.map(r=>A.jsxs("div",{className:"mb-3 last:mb-0",children:[A.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),A.jsx("p",{children:r.answer})]},r.question))}),A.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(tD)}})]})}const rD="https://github.com/FlatFilers/csvjson-app/discussions/163";function iD(){return A.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:A.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",A.jsx("a",{"data-testid":"feedback-link",href:rD,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 wT="csvjson:feedback.v1",sD=[{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 oD(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(wT);if(t===null)return null;const e=JSON.parse(t);return oD(e)?e:null}catch{return null}}function px(t){try{window.localStorage.setItem(wT,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 lD(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 aD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(lD(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 uD(){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,C)=>{const T={...b,pending:C==="failed"};px(T),e(T),C==="ok"?MI({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=v.useCallback((b,C)=>{const T=++h.current;C&&f(!0),aD(b).then(E=>{h.current===T&&(p(b,E),E==="ok"&&u(!0))}).finally(()=>{C&&h.current===T&&f(!1)})},[p]),x=b=>{const C={...b,pending:!0};px(C),e(C),m(C,!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)},C=T=>{const E=d.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",C)}},[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 A.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[A.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:A.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:[A.jsx("path",{d:"M7 10v12"}),A.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"})]})}),A.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:A.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:[A.jsx("path",{d:"M17 14V2"}),A.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&&A.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&A.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&&A.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:[A.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),A.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:sD.map(b=>A.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))}),A.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"}),A.jsxs("div",{className:"flex items-center justify-end gap-2",children:[A.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),A.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 xT(t="This should not happen"){throw new Error(t)}function Lr(t,e="Assertion failed"){if(!t)return xT(e)}function Ec(t,e){return xT(e??"Hell froze over")}function cD(t,e){try{return t()}catch{return e}}const yx=Object.prototype.hasOwnProperty;function Pa(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--&&Pa(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)||!Pa(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var fD=Object.prototype,dD=fD.hasOwnProperty;function hD(t,e){return t!=null&&dD.call(t,e)}var pD=hD,gD=Array.isArray,ls=gD,mD=typeof io=="object"&&io&&io.Object===Object&&io,bT=mD,yD=bT,vD=typeof self=="object"&&self&&self.Object===Object&&self,wD=yD||vD||Function("return this")(),as=wD,xD=as,bD=xD.Symbol,Hc=bD,vx=Hc,kT=Object.prototype,kD=kT.hasOwnProperty,SD=kT.toString,ku=vx?vx.toStringTag:void 0;function CD(t){var e=kD.call(t,ku),n=t[ku];try{t[ku]=void 0;var r=!0}catch{}var i=SD.call(t);return r&&(e?t[ku]=n:delete t[ku]),i}var TD=CD,ED=Object.prototype,AD=ED.toString;function MD(t){return AD.call(t)}var RD=MD,wx=Hc,OD=TD,PD=RD,ID="[object Null]",ND="[object Undefined]",xx=wx?wx.toStringTag:void 0;function DD(t){return t==null?t===void 0?ND:ID:xx&&xx in Object(t)?OD(t):PD(t)}var Wc=DD;function _D(t){return t!=null&&typeof t=="object"}var Vc=_D,LD=Wc,FD=Vc,$D="[object Symbol]";function zD(t){return typeof t=="symbol"||FD(t)&&LD(t)==$D}var hp=zD,BD=ls,jD=hp,HD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,WD=/^\w*$/;function VD(t,e){if(BD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||jD(t)?!0:WD.test(t)||!HD.test(t)||e!=null&&t in Object(e)}var _v=VD;function UD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var xl=UD,KD=Wc,XD=xl,GD="[object AsyncFunction]",qD="[object Function]",YD="[object GeneratorFunction]",QD="[object Proxy]";function JD(t){if(!XD(t))return!1;var e=KD(t);return e==qD||e==YD||e==GD||e==QD}var ST=JD,ZD=as,e_=ZD["__core-js_shared__"],t_=e_,Lg=t_,bx=function(){var t=/[^.]+$/.exec(Lg&&Lg.keys&&Lg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function n_(t){return!!bx&&bx in t}var r_=n_,i_=Function.prototype,s_=i_.toString;function o_(t){if(t!=null){try{return s_.call(t)}catch{}try{return t+""}catch{}}return""}var CT=o_,l_=ST,a_=r_,u_=xl,c_=CT,f_=/[\\^$.*+?()[\]{}|]/g,d_=/^\[object .+?Constructor\]$/,h_=Function.prototype,p_=Object.prototype,g_=h_.toString,m_=p_.hasOwnProperty,y_=RegExp("^"+g_.call(m_).replace(f_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function v_(t){if(!u_(t)||a_(t))return!1;var e=l_(t)?y_:d_;return e.test(c_(t))}var w_=v_;function x_(t,e){return t==null?void 0:t[e]}var b_=x_,k_=w_,S_=b_;function C_(t,e){var n=S_(t,e);return k_(n)?n:void 0}var bl=C_,T_=bl,E_=T_(Object,"create"),pp=E_,kx=pp;function A_(){this.__data__=kx?kx(null):{},this.size=0}var M_=A_;function R_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var O_=R_,P_=pp,I_="__lodash_hash_undefined__",N_=Object.prototype,D_=N_.hasOwnProperty;function __(t){var e=this.__data__;if(P_){var n=e[t];return n===I_?void 0:n}return D_.call(e,t)?e[t]:void 0}var L_=__,F_=pp,$_=Object.prototype,z_=$_.hasOwnProperty;function B_(t){var e=this.__data__;return F_?e[t]!==void 0:z_.call(e,t)}var j_=B_,H_=pp,W_="__lodash_hash_undefined__";function V_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=H_&&e===void 0?W_:e,this}var U_=V_,K_=M_,X_=O_,G_=L_,q_=j_,Y_=U_;function Ka(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var hL=dL,pL=gp;function gL(t,e){var n=this.__data__,r=pL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var mL=gL,yL=Z_,vL=lL,wL=cL,xL=hL,bL=mL;function Xa(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=N3}var Hv=D3,_3=hp;function L3(t){if(typeof t=="string"||_3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var vp=L3,F3=AT,$3=Bv,z3=ls,B3=jv,j3=Hv,H3=vp;function W3(t,e,n){e=F3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new ms(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=Y3([...this.items,n]);return new ms(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 ms([]))),vt(ms,"fromSingleSelection",e=>ms.empty().add(e));let Pt=ms;function Q3(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var J3=/^((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)-.*))$/,Fg=Q3(function(t){return J3.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Z3=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=Z3,eF=t=>t.toUpperCase()===t,tF=t=>e=>t.indexOf(e)===-1,OT=(t,e)=>{const n={};return Object.keys(t).filter(tF(e)).forEach(r=>{n[r]=t[r]}),n};function nF(t,e,n){const r=OT(e,n);if(!t){const i=typeof Fg=="function"?{default:Fg}:Fg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var rF=(t,e)=>{};function iF(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&&!eF(l[0])):n.propsAsIs,c=nF(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;rF(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,Nn.createElement(t,c)):Nn.createElement(l,c)},i=Nn.forwardRef?Nn.forwardRef(r):s=>{const o=OT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Vr=iF;const sF=Vr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var PT={},wp={},Vv={},$g={},zg={exports:{}},Bg,Ix;function oF(){if(Ix)return Bg;Ix=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Bg=t,Bg}var jg,Nx;function lF(){if(Nx)return jg;Nx=1;var t=oF();function e(){}function n(){}return n.resetWarningCache=e,jg=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},jg}var Dx;function aF(){return Dx||(Dx=1,zg.exports=lF()()),zg.exports}var _x;function uF(){return _x||(_x=1,function(t){(function(e,n){n(t,v,aF())})(io,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 C=y.screenX,T=y.screenY;return{x:C,y:T}}var g=function(y){d(w,y);function w(){var k;u(this,w);for(var b=arguments.length,C=Array(b),T=0;TC&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-C?this.props.onSwipeUp(1,b):this.movePosition.deltaY>C&&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 C=b.className,T=b.style,E=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var R=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:C,style:T},R),E)}}]),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})}($g)),$g}(function(t){(function(e,n){n(t,uF())})(io,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 Uc={},IT={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 hh(t){return hh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},hh(t)}function Qn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var CF=function(e){return e.hasOwnProperty("key")},Hv=function(t){xF(n,t);var e=bF(n);function n(r){var i;return yF(this,n),i=e.call(this,r),Qn(or(i),"itemsWrapperRef",void 0),Qn(or(i),"itemsListRef",void 0),Qn(or(i),"thumbsRef",void 0),Qn(or(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),Qn(or(i),"setItemsListRef",function(s){i.itemsListRef=s}),Qn(or(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),Qn(or(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=vi.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,pF.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,Nx.default)(h,"%",i.props.axis)}),!0}),Qn(or(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),Qn(or(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),Qn(or(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 wF(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,Wf.default)().addEventListener("resize",this.updateSizes),(0,Wf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,Wf.default)().removeEventListener("resize",this.updateSizes),(0,Wf.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,Ji.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,Ji.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,Ji.setPosition)(0,e.axis)),r;var a=(0,Ji.getPosition)(i,e),u=(0,DF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=Go(Go({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};Qi.slideAnimationHandler=FF;var $F=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=PT.Children.count(n.children),a=0,u=(0,Ji.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,Ji.getPosition)(l-1,n)-100:(0,Ji.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,Ji.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};Qi.slideSwipeAnimationHandler=$F;var BF=function(e,n){var r=(0,Ji.getPosition)(n.selectedItem,e),i=(0,Ji.setPosition)(r,e.axis);return{itemListStyle:i}};Qi.slideStopSwipingHandler=BF;var zF=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=Go(Go({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:Go(Go({},s),{},{opacity:1,position:"relative"}),prevStyle:Go({},s)}};Qi.fadeAnimationHandler=zF;Object.defineProperty(mp,"__esModule",{value:!0});mp.default=void 0;var zt=WF(v),jF=Xc(jv),vs=Xc(Vc),HF=Xc(Uc),Vf=Xc(wp),Uf=Xc(Kc),Fu=$r,ph=Qi;function Xc(t){return t&&t.__esModule?t:{default:t}}function IT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return IT=function(){return t},t}function WF(t){if(t&&t.__esModule)return t;if(t===null||Yu(t)!=="object"&&typeof t!="function")return{default:t};var e=IT();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 Yu(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Yu=function(n){return typeof n}:Yu=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Yu(t)}function T0(){return T0=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 gh(t){return gh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},gh(t)}function bt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Wv=function(t){XF(n,t);var e=GF(n);function n(r){var i;VF(this,n),i=e.call(this,r),bt(St(i),"thumbsRef",void 0),bt(St(i),"carouselWrapperRef",void 0),bt(St(i),"listRef",void 0),bt(St(i),"itemsRef",void 0),bt(St(i),"timer",void 0),bt(St(i),"animationHandler",void 0),bt(St(i),"setThumbsRef",function(o){i.thumbsRef=o}),bt(St(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),bt(St(i),"setListRef",function(o){i.listRef=o}),bt(St(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),bt(St(i),"autoPlay",function(){zt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),bt(St(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),bt(St(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),bt(St(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),bt(St(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),bt(St(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Vf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Vf.default)().activeElement)):!1}),bt(St(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()}}),bt(St(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()}}}),bt(St(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),bt(St(i),"handleClickItem",function(o,l){if(zt.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})}}),bt(St(i),"handleOnChange",function(o,l){zt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),bt(St(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),bt(St(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),bt(St(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),bt(St(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(St(i)));return i.setState(wi({},a)),!!Object.keys(a).length}),bt(St(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))}),bt(St(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))}),bt(St(i),"moveTo",function(o){if(typeof o=="number"){var l=zt.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()}}),bt(St(i),"onClickNext",function(){i.increment(1)}),bt(St(i),"onClickPrev",function(){i.decrement(1)}),bt(St(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),bt(St(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),bt(St(i),"changeItem",function(o){return function(l){(!(0,Fu.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),bt(St(i),"selectItem",function(o){i.setState(wi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,zt.Children.toArray(i.props.children)[o.selectedItem])}),bt(St(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),bt(St(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"&&ph.fadeAnimationHandler||ph.slideAnimationHandler,i.state=wi(wi({},s),i.animationHandler(r,s)),i}return KF(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(wi({},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&&zt.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,Uf.default)().addEventListener("resize",this.updateSizes),(0,Uf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Vf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Uf.default)().removeEventListener("resize",this.updateSizes),(0,Uf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Vf.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?zt.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=wi(wi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=wi(wi({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:vs.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return zt.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?zt.default.createElement("ul",{className:"control-dots"},zt.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?zt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,zt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||zt.Children.count(this.props.children)===0?null:zt.default.createElement(HF.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||zt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&zt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&zt.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 C=Bg();if(x(C))return y(C);l=setTimeout(g,m(C))}function y(C){return l=void 0,d&&r?h(C):(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(Bg())}function b(){var C=Bg(),T=x(C);if(r=arguments,i=this,a=C,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 NT=w4;const DT=Ni(NT);function jn(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 jl(t,e){return t===void 0?void 0:e}const x4=Math.PI;function Bx(t){return t*x4/180}const _T=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),LT=(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}},FT=(t,e,n)=>Math.min(t,e-n*2),$T=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,Uv=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"}))},b4=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 k4(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(DT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const S4="֑-߿יִ-﷽ﹰ-ﻼ",C4="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",T4=new RegExp("^[^"+C4+"]*["+S4+"]");function Kv(t){return T4.test(t)?"rtl":"not-rtl"}let Kf;function A0(){if(typeof document>"u")return 0;if(Kf!==void 0)return Kf;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(),Kf=n-r,Kf}const jo=Symbol();function E4(t){const e=v.useRef([jo,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!==jo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==jo&&i({}),r(u=>typeof l=="function"?l(a===jo?u:a):l),e.current[0]=jo)},[]),o=v.useCallback(()=>{e.current[0]=jo,i({})},[]);return[e.current[0]===jo?n:e.current[0],s,o]}function BT(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 A4(t){const e=v.useRef(t);return Oa(t,e.current)||(e.current=t),e.current}const M4=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(nF,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(MT.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(Uv,null)))};function zT(){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 bl=zT();function R4(t){bl=t}const jT=/[&<>"']/,O4=new RegExp(jT.source,"g"),HT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,P4=new RegExp(HT.source,"g"),I4={"&":"&","<":"<",">":">",'"':""","'":"'"},zx=t=>I4[t];function Jn(t,e){if(e){if(jT.test(t))return t.replace(O4,zx)}else if(HT.test(t))return t.replace(P4,zx);return t}const N4=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function WT(t){return t.replace(N4,(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 D4=/(^|[^\[])\^/g;function Gt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(D4,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const _4=/[^\w:]/g,L4=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function jx(t,e,n){if(t){let r;try{r=decodeURIComponent(WT(n)).replace(_4,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!L4.test(n)&&(n=z4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Xf={},F4=/^[^:]+:\/*[^/]*$/,$4=/^([^:]+:)[\s\S]*$/,B4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function z4(t,e){Xf[" "+t]||(F4.test(t)?Xf[" "+t]=t+"/":Xf[" "+t]=Pd(t,"/",!0)),t=Xf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace($4,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(B4,"$1")+e:t+e}const mh={exec:function(){}};function Hx(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 Vx(t,e,n,r){const i=e.href,s=e.title?Jn(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:Jn(o)}}function W4(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` +*/(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 mh(t){return mh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},mh(t)}function Qn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var AF=function(e){return e.hasOwnProperty("key")},Uv=function(t){SF(n,t);var e=CF(n);function n(r){var i;return xF(this,n),i=e.call(this,r),Qn(or(i),"itemsWrapperRef",void 0),Qn(or(i),"itemsListRef",void 0),Qn(or(i),"thumbsRef",void 0),Qn(or(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),Qn(or(i),"setItemsListRef",function(s){i.itemsListRef=s}),Qn(or(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),Qn(or(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=vi.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,yF.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}),Qn(or(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),Qn(or(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),Qn(or(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 kF(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,Ji.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,Ji.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,Ji.setPosition)(0,e.axis)),r;var a=(0,Ji.getPosition)(i,e),u=(0,FF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=qo(qo({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};Qi.slideAnimationHandler=BF;var jF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=DT.Children.count(n.children),a=0,u=(0,Ji.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,Ji.getPosition)(l-1,n)-100:(0,Ji.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,Ji.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};Qi.slideSwipeAnimationHandler=jF;var HF=function(e,n){var r=(0,Ji.getPosition)(n.selectedItem,e),i=(0,Ji.setPosition)(r,e.axis);return{itemListStyle:i}};Qi.slideStopSwipingHandler=HF;var WF=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=qo(qo({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:qo(qo({},s),{},{opacity:1,position:"relative"}),prevStyle:qo({},s)}};Qi.fadeAnimationHandler=WF;Object.defineProperty(wp,"__esModule",{value:!0});wp.default=void 0;var Bt=KF(v),VF=Gc(Vv),vs=Gc(Uc),UF=Gc(Kc),Uf=Gc(kp),Kf=Gc(Xc),$u=$r,yh=Qi;function Gc(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 KF(t){if(t&&t.__esModule)return t;if(t===null||Qu(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 Qu(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Qu=function(n){return typeof n}:Qu=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},Qu(t)}function M0(){return M0=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 vh(t){return vh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},vh(t)}function wt(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){YF(n,t);var e=QF(n);function n(r){var i;XF(this,n),i=e.call(this,r),wt(bt(i),"thumbsRef",void 0),wt(bt(i),"carouselWrapperRef",void 0),wt(bt(i),"listRef",void 0),wt(bt(i),"itemsRef",void 0),wt(bt(i),"timer",void 0),wt(bt(i),"animationHandler",void 0),wt(bt(i),"setThumbsRef",function(o){i.thumbsRef=o}),wt(bt(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),wt(bt(i),"setListRef",function(o){i.listRef=o}),wt(bt(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),wt(bt(i),"autoPlay",function(){Bt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),wt(bt(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),wt(bt(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),wt(bt(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),wt(bt(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),wt(bt(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Uf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Uf.default)().activeElement)):!1}),wt(bt(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()}}),wt(bt(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()}}}),wt(bt(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),wt(bt(i),"handleClickItem",function(o,l){if(Bt.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})}}),wt(bt(i),"handleOnChange",function(o,l){Bt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),wt(bt(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),wt(bt(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),wt(bt(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),wt(bt(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(bt(i)));return i.setState(wi({},a)),!!Object.keys(a).length}),wt(bt(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))}),wt(bt(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))}),wt(bt(i),"moveTo",function(o){if(typeof o=="number"){var l=Bt.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()}}),wt(bt(i),"onClickNext",function(){i.increment(1)}),wt(bt(i),"onClickPrev",function(){i.decrement(1)}),wt(bt(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),wt(bt(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),wt(bt(i),"changeItem",function(o){return function(l){(!(0,$u.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),wt(bt(i),"selectItem",function(o){i.setState(wi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,Bt.Children.toArray(i.props.children)[o.selectedItem])}),wt(bt(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),wt(bt(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"&&yh.fadeAnimationHandler||yh.slideAnimationHandler,i.state=wi(wi({},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(wi({},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&&Bt.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?Bt.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=wi(wi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=wi(wi({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:vs.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return Bt.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?Bt.default.createElement("ul",{className:"control-dots"},Bt.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?Bt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,Bt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||Bt.Children.count(this.props.children)===0?null:Bt.default.createElement(UF.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||Bt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&Bt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&Bt.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&&E>=s}function g(){var C=Hg();if(x(C))return y(C);l=setTimeout(g,m(C))}function y(C){return l=void 0,d&&r?h(C):(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(Hg())}function b(){var C=Hg(),T=x(C);if(r=arguments,i=this,a=C,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 LT=k4;const FT=Ni(LT);function jn(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 Hl(t,e){return t===void 0?void 0:e}const S4=Math.PI;function Hx(t){return t*S4/180}const $T=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),zT=(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}},BT=(t,e,n)=>Math.min(t,e-n*2),jT=(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"}))},C4=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 T4(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(FT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const E4="֑-߿יִ-﷽ﹰ-ﻼ",A4="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",M4=new RegExp("^[^"+A4+"]*["+E4+"]");function qv(t){return M4.test(t)?"rtl":"not-rtl"}let Xf;function O0(){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 jo=Symbol();function R4(t){const e=v.useRef([jo,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!==jo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==jo&&i({}),r(u=>typeof l=="function"?l(a===jo?u:a):l),e.current[0]=jo)},[]),o=v.useCallback(()=>{e.current[0]=jo,i({})},[]);return[e.current[0]===jo?n:e.current[0],s,o]}function HT(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 O4(t){const e=v.useRef(t);return Pa(t,e.current)||(e.current=t),e.current}const P4=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(sF,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(PT.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 WT(){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 kl=WT();function I4(t){kl=t}const VT=/[&<>"']/,N4=new RegExp(VT.source,"g"),UT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,D4=new RegExp(UT.source,"g"),_4={"&":"&","<":"<",">":">",'"':""","'":"'"},Wx=t=>_4[t];function Jn(t,e){if(e){if(VT.test(t))return t.replace(N4,Wx)}else if(UT.test(t))return t.replace(D4,Wx);return t}const L4=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function KT(t){return t.replace(L4,(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 F4=/(^|[^\[])\^/g;function qt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(F4,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const $4=/[^\w:]/g,z4=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Vx(t,e,n){if(t){let r;try{r=decodeURIComponent(KT(n)).replace($4,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!z4.test(n)&&(n=W4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Gf={},B4=/^[^:]+:\/*[^/]*$/,j4=/^([^:]+:)[\s\S]*$/,H4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function W4(t,e){Gf[" "+t]||(B4.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(j4,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(H4,"$1")+e:t+e}const wh={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?Jn(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:Jn(o)}}function K4(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 Xv{constructor(e){this.options=e||bl}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:Pd(r,` -`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=W4(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=Pd(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(` +`)}class Yv{constructor(e){this.options=e||kl}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=K4(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+|$)`),C=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," ")),!(C.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||C.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;lC.type==="space"),b=k.length>0&&k.some(C=>/\n.*\n/.test(C.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:Hx(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]):Jn(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=Pd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=j4(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)),Vx(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 Vx(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=Jn(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=Jn(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=Jn(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=Jn(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=Jn(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]):Jn(r[0]):r[0]:i=Jn(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Je={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:mh,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Je._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Je._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Je.def=Gt(Je.def).replace("label",Je._label).replace("title",Je._title).getRegex();Je.bullet=/(?:[*+-]|\d{1,9}[.)])/;Je.listItemStart=Gt(/^( *)(bull) */).replace("bull",Je.bullet).getRegex();Je.list=Gt(Je.list).replace(/bull/g,Je.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Je.def.source+")").getRegex();Je._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";Je._comment=/|$)/;Je.html=Gt(Je.html,"i").replace("comment",Je._comment).replace("tag",Je._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Je.paragraph=Gt(Je._paragraph).replace("hr",Je.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",Je._tag).getRegex();Je.blockquote=Gt(Je.blockquote).replace("paragraph",Je.paragraph).getRegex();Je.normal={...Je};Je.gfm={...Je.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Je.gfm.table=Gt(Je.gfm.table).replace("hr",Je.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",Je._tag).getRegex();Je.gfm.paragraph=Gt(Je._paragraph).replace("hr",Je.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Je.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",Je._tag).getRegex();Je.pedantic={...Je.normal,html:Gt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Je._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:mh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Gt(Je.normal._paragraph).replace("hr",Je.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Je.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Ie={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:mh,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:mh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Ie.punctuation=Gt(Ie.punctuation).replace(/punctuation/g,Ie._punctuation).getRegex();Ie.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Ie.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Ie._comment=Gt(Je._comment).replace("(?:-->|$)","-->").getRegex();Ie.emStrong.lDelim=Gt(Ie.emStrong.lDelim).replace(/punct/g,Ie._punctuation).getRegex();Ie.emStrong.rDelimAst=Gt(Ie.emStrong.rDelimAst,"g").replace(/punct/g,Ie._punctuation).getRegex();Ie.emStrong.rDelimUnd=Gt(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=Gt(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=Gt(Ie.tag).replace("comment",Ie._comment).replace("attribute",Ie._attribute).getRegex();Ie._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Ie._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Ie._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Ie.link=Gt(Ie.link).replace("label",Ie._label).replace("href",Ie._href).replace("title",Ie._title).getRegex();Ie.reflink=Gt(Ie.reflink).replace("label",Ie._label).replace("ref",Je._label).getRegex();Ie.nolink=Gt(Ie.nolink).replace("ref",Je._label).getRegex();Ie.reflinkSearch=Gt(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:Gt(/^!?\[(label)\]\((.*?)\)/).replace("label",Ie._label).getRegex(),reflink:Gt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Ie._label).getRegex()};Ie.gfm={...Ie.normal,escape:Gt(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 ko{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||bl,this.options.tokenizer=this.options.tokenizer||new Xv,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:Je.normal,inline:Ie.normal};this.options.pedantic?(n.block=Je.pedantic,n.inline=Ie.pedantic):this.options.gfm&&(n.block=Je.gfm,this.options.breaks?n.inline=Ie.breaks:n.inline=Ie.gfm),this.tokenizer.rules=n}static get rules(){return{block:Je,inline:Ie}}static lex(e,n){return new ko(n).lex(e)}static lexInline(e,n){return new ko(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` +`,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;lC.type==="space"),b=k.length>0&&k.some(C=>/\n.*\n/.test(C.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]):Jn(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=V4(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=Jn(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=Jn(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=Jn(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=Jn(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=Jn(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]):Jn(r[0]):r[0]:i=Jn(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:wh,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=qt(Ye.def).replace("label",Ye._label).replace("title",Ye._title).getRegex();Ye.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ye.listItemStart=qt(/^( *)(bull) */).replace("bull",Ye.bullet).getRegex();Ye.list=qt(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=qt(Ye.html,"i").replace("comment",Ye._comment).replace("tag",Ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ye.paragraph=qt(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=qt(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=qt(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=qt(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:qt(`^ *(?: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:wh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:qt(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 Pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:wh,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:wh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Pe.punctuation=qt(Pe.punctuation).replace(/punctuation/g,Pe._punctuation).getRegex();Pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Pe._comment=qt(Ye._comment).replace("(?:-->|$)","-->").getRegex();Pe.emStrong.lDelim=qt(Pe.emStrong.lDelim).replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimAst=qt(Pe.emStrong.rDelimAst,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimUnd=qt(Pe.emStrong.rDelimUnd,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Pe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Pe._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])?)+(?![-_])/;Pe.autolink=qt(Pe.autolink).replace("scheme",Pe._scheme).replace("email",Pe._email).getRegex();Pe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Pe.tag=qt(Pe.tag).replace("comment",Pe._comment).replace("attribute",Pe._attribute).getRegex();Pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Pe.link=qt(Pe.link).replace("label",Pe._label).replace("href",Pe._href).replace("title",Pe._title).getRegex();Pe.reflink=qt(Pe.reflink).replace("label",Pe._label).replace("ref",Ye._label).getRegex();Pe.nolink=qt(Pe.nolink).replace("ref",Ye._label).getRegex();Pe.reflinkSearch=qt(Pe.reflinkSearch,"g").replace("reflink",Pe.reflink).replace("nolink",Pe.nolink).getRegex();Pe.normal={...Pe};Pe.pedantic={...Pe.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:qt(/^!?\[(label)\]\((.*?)\)/).replace("label",Pe._label).getRegex(),reflink:qt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pe._label).getRegex()};Pe.gfm={...Pe.normal,escape:qt(Pe.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 ko{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||kl,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:Pe.normal};this.options.pedantic?(n.block=Ye.pedantic,n.inline=Pe.pedantic):this.options.gfm&&(n.block=Ye.gfm,this.options.breaks?n.inline=Pe.breaks:n.inline=Pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ye,inline:Pe}}static lex(e,n){return new ko(n).lex(e)}static lexInline(e,n){return new ko(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+=` @@ -204,7 +204,7 @@ Error generating stack: `+s.message+` `+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)+"["+Wx("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)+"["+Wx("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,Ux)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Ux))){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,V4)){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 Gv{constructor(e){this.options=e||bl}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$/,"")+` +`+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,X4)){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||kl}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:Jn(e,!0))+`
`:"
"+(r?e:Jn(e,!0))+`
`}blockquote(e){return`
@@ -224,76 +224,76 @@ ${e}
`}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=jx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='",i}image(e,n,r){if(e=jx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class VT{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 UT{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 Gc=class M0{constructor(e){this.options=e||bl,this.options.renderer=this.options.renderer||new Gv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new VT,this.slugger=new UT}static parse(e,n){return new M0(n).parse(e)}static parseInline(e,n){return new M0(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,C;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:

"+Jn(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 KT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=U4(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(H4(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 KT(ko.lex,Gc.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},R4(et.defaults),et};et.getDefaults=zT;et.defaults=bl;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 Gv;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 Xv;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 yh;for(const s in n.hooks){const o=i[s];yh.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=KT(ko.lexInline,Gc.parseInline);et.Parser=Gc;et.parser=Gc.parse;et.Renderer=Gv;et.TextRenderer=VT;et.Lexer=ko;et.lexer=ko.lex;et.Tokenizer=Xv;et.Slugger=UT;et.Hooks=yh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;Gc.parse;ko.lex;const K4=Vr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class X4 extends Nn.PureComponent{constructor(){super(...arguments);xt(this,"targetElement",null);xt(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(),Nn.createElement(K4,{ref:this.containerRefHook})}}const G4=Vr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),q4=Vr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),Y4=Vr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Kx=0;const xp=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??"";Lr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=v.useState(()=>"input-box-"+(Kx=(Kx+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(Y4,{className:"gdg-growing-entry"},v.createElement(q4,{className:u},f+` -`),v.createElement(G4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},zg={};let Us=null;function Q4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function R0(t){const e=t.toLowerCase().trim();if(zg[e]!==void 0)return zg[e];Us=Us||Q4(),Us.style.color="#000",Us.style.color=e;const n=getComputedStyle(Us).color;Us.style.color="#fff",Us.style.color=e;const r=getComputedStyle(Us).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),zg[e]=i,i}function dl(t,e){const[n,r,i]=R0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Xx=new Map;function Gx(t,e){const n=`${t}-${e}`,r=Xx.get(n);if(r!==void 0)return r;const i=Fr(t,e);return Xx.set(n,i),i}function Fr(t,e){if(e===void 0)return t;const[n,r,i,s]=R0(t);if(s===1)return t;const[o,l,a,u]=R0(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 Ul=new Map,oa=new Map,O0=new Map;function J4(){Ul.clear(),O0.clear(),oa.clear()}function Z4(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 e$(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 Qu(t,e,n,r){var i,s;let o=oa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=O0.get(n);if(u===void 0&&(u=e$(t,o.size),O0.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 Z4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),oa.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)oa.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;oa.set(n,{count:o.count+e.length,size:f})}return l.width}function t$(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=Qu(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 n$(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Ul.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` -`),c=oa.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=Qu(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=t$(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=Qu(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()),Ul.set(o,a),Ul.size>500&&Ul.delete(Ul.keys().next().value),a}function r$(t,e){return Nn.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 XT(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 o$(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)&&qx(t,e,s)&&i++;for(const o of n.current.rangeStack)qx(t,e,o)&&i++;return i}function qT(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 Pa(t,e){let n=0;const r=qT(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 c$(){var t;u$||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Id=0,Zu={},J4())}c$();function YT(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function qc(t,e,n,r="middle"){const i=YT(t,e,r,n);let s=Zu[i];return s===void 0&&(s=e.measureText(t),Zu[i]=s,Id++),Id>1e4&&(Zu={},Id=0),s}function f$(t,e){const n=YT(t,void 0,"middle",e);return Zu[n]}function Ns(t,e){return typeof e!="string"&&(e=e.baseFontFull),d$(t,e)}function Yx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const Qx=[];function d$(t,e){for(const s of Qx)if(s.key===e)return s.val;const n=Yx(t,"alphabetic"),i=-(Yx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return Qx.push({key:e,val:i}),i}function h$(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 g$(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=n$(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=JT(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(QT(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function xs(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=p$(e,c));const d=Ns(s,l),h=Kv(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?g$(s,e,a,u,c,f,d,l,n,i):QT(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function is(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 m$(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 y$(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 I0(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=Pa(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&&Ec(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 qv=1<<21;function Ci(t,e){return(e+2)*qv+t}function ZT(t){return t%qv}function Yv(t){return Math.floor(t/qv)-2}function Qv(t){const e=ZT(t),n=Yv(t);return[e,n]}class eE{constructor(){xt(this,"visibleWindow",{x:0,y:0,width:0,height:0});xt(this,"freezeCols",0);xt(this,"freezeRows",[]);xt(this,"isInWindow",e=>{const n=ZT(e),r=Yv(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&&Oa(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class v$ extends eE{constructor(){super(...arguments);xt(this,"cache",new Map);xt(this,"setValue",(n,r)=>{this.cache.set(Ci(n[0],n[1]),r)});xt(this,"getValue",n=>this.cache.get(Ci(n[0],n[1])));xt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class ec{constructor(e=[]){xt(this,"cells");this.cells=new Set(e.map(n=>Ci(n[0],n[1])))}add(e){this.cells.add(Ci(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Ci(e[0],e[1]))}remove(e){this.cells.delete(Ci(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(Yv(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=b$(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 k$(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(Hf))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)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=y(b,a.signal),M=k>0?y(C,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Ex(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Ex(M)]),m.current=t,g(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Hf)?t:h===null?t.map(T=>Hf(T)?T:{...T,width:N0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Hf(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:N0};const M=rE(h,o,T,A,x,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,b=0;const C=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(b+=A.grow,C.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=C$(a),a in Jx)return;Jx[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":S$,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 T$(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var E$=T$,A$=E$,jg=Vv;function M$(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=jg(n),n=n===n?n:0),e!==void 0&&(e=jg(e),e=e===e?e:0),A$(jg(t),e,n)}var R$=M$;const Si=Ni(R$);var O$="__lodash_hash_undefined__";function P$(t){return this.__data__.set(t,O$),this}var I$=P$;function N$(t){return this.__data__.has(t)}var D$=N$,_$=_v,L$=I$,F$=D$;function vh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new _$;++e-1}var Q$=Y$;function J$(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=vB){var u=e?null:mB(t);if(u)return yB(u);o=!1,i=gB,a=new dB}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?uE(l,e-1,n,r,i):OB(i,l):r||(i[i.length]=l)}return i}var IB=uE,NB=IB;function DB(t){var e=t==null?0:t.length;return e?NB(t,1):[]}var _B=DB;const tb=Ni(_B);var LB=Math.ceil,FB=Math.max;function $B(t,e,n,r){for(var i=-1,s=FB(LB((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var BB=$B,zB=xT,jB=Bv;function HB(t){return t!=null&&jB(t.length)&&!zB(t)}var Zv=HB,WB=Nv,VB=Zv,UB=$v,KB=wl;function XB(t,e,n){if(!KB(n))return!1;var r=typeof e;return(r=="number"?VB(n)&&UB(e,n.length):r=="string"&&e in n)?WB(n[e],t):!1}var GB=XB,qB=Vv,nb=1/0,YB=17976931348623157e292;function QB(t){if(!t)return t===0?t:0;if(t=qB(t),t===nb||t===-nb){var e=t<0?-1:1;return e*YB}return t===t?t:0}var JB=QB,ZB=BB,ez=GB,Wg=JB;function tz(t){return function(e,n,r){return r&&typeof r!="number"&&ez(e,n,r)&&(n=r=void 0),e=Wg(e),n===void 0?(n=e,e=0):n=Wg(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 cE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function bp(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 az(t,e,n,r){if(r==="any")return hE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),XT([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 wh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function kp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function hE(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 uz(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 cz(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 fz(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&&C){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(C&&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(C&&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 dz={kind:Se.Loading,allowOverlay:!1};function rb(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,C,T,A,M,O,_,P,I,D,Y,ie,se,V){let J=(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},z=[0,0],j=x>0?kl(a,x,u):0;let B,oe;const fe=cE(y);return Oo(e,l,s,o,i,(me,ze,Fe,nt,Et)=>{const rt=Math.max(0,nt-ze),it=ze+rt,lt=i+1,_t=me.width-rt,Ne=r-i-1;if(y.length>0){let vt=!1;for(let at=0;at{t.save(),t.beginPath(),t.rect(it,lt,_t,Ne),t.clip()},_e=k.columns.hasIndex(me.sourceIndex),Ye=f(me.group??"").overrideTheme,Ke=me.themeOverride===void 0&&Ye===void 0?I:wo(I,Ye,me.themeOverride),Ue=Ke.baseFontFull;Ue!==N&&(N=Ue,t.font=Ue),xe();let ht;return bp(Et,Fe,r,a,u,x,g,fe,(vt,at,he,Be,ut)=>{var Ae,$e,qt;if(at<0||(z[0]=me.sourceIndex,z[1]=at,w!==void 0&&!w.has(z)))return;if(y.length>0){let We=!1;for(let Bt=0;Btft.span!==void 0&&We>=ft.span[0]&&We<=ft.span[1]);ye&&!p&&m?re=0:ye&&m&&(re=Math.max(re,1)),we&&re++,ye||(tt&&re++,_e&&!ut&&re++);const pe=ft.kind===Se.Protected?W.bgCellMedium:W.bgCell;let Le;if((Be||pe!==I.bgCell)&&(Le=Fr(pe,Le)),re>0||Vt){Vt&&(Le=Fr(W.bgHeader,Le));for(let We=0;WeV&&!Mt){const We=W.baseFontFull;We!==N&&(t.font=We,N=We),ht=pE(t,ft,me.sourceIndex,at,Re,De,dt,vt,wt,he,re>0,W,Le??W.bgCell,T,A,(q==null?void 0:q.hoverAmount)??0,O,P,R,_,ht,D,Y,ie,se)}return de&&t.restore(),ft.style==="faded"&&(t.globalAlpha=1),J--,Ut&&(t.restore(),(qt=ht==null?void 0:ht.deprep)==null||qt.call(ht,L),ht=void 0,xe(),N=Ue,t.font=Ue),J<=0}),t.restore(),J<=0}),B}const ku=[0,0],Su={x:0,y:0,width:0,height:0},Vg=[void 0,()=>{}];let D0=!1;function hz(){D0=!0}function pE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,C,T,A){var Y,ie;let M,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(M=x[1][0],O=x[1][1]);let _;ku[0]=n,ku[1]=r,Su.x=o,Su.y=l,Su.width=a,Su.height=u,Vg[0]=C.getValue(ku),Vg[1]=se=>C.setValue(ku,se),D0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Su,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:M,drawState:Vg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:hz},I=h$(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((Y=k==null?void 0:k.deprep)==null||Y.call(k,P),k=void 0);const se=(ie=D.drawPrep)==null?void 0:ie.call(D,P,k);w!==void 0&&!sa(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=se===void 0?void 0:{deprep:se==null?void 0:se.deprep,fillStyle:se==null?void 0:se.fillStyle,font:se==null?void 0:se.font,renderer:D}}return(I||D0)&&(b==null||b(ku)),_}function ew(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=FT(c,o,e.cellVerticalPadding),x=m/2;const g=LT(f,r,s,e.cellHorizontalPadding,m),y=_T(g,h,m),w=$T(r+a,i+u,y);switch(n){case!0:{t.beginPath(),is(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 fh:case!1:{t.beginPath(),is(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 zv:{t.beginPath(),is(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:Tc()}}function pz(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])??[],C=f.headerFontFull;t.font=C,Oo(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:wo(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),Y=a!==void 0||u,ie=!Y&&b===-1&&k===T.sourceIndex,se=Y?0:((L=h.find(z=>z.item[0]===T.sourceIndex&&z.item[1]===-1))==null?void 0:L.hoverAmount)??0,V=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,J=D?I.accentColor:V?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=J,t.fillRect(A+N,R,T.width-N,o)):(V||se>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),V&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),se>0&&(t.globalAlpha=se,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),yE(t,A,R,T.width,o,T,D,I,ie,V,se,d,g,y),t.restore()}),n&&gz(t,e,i,s,l,r,f,d,h,p,m,x)}function gz(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;fE(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 C=c(g),T=(C==null?void 0:C.overrideTheme)===void 0?o:wo(o,C.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,C!==void 0){let O=y;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(C.name,O+8,i/2+Ns(t,o.headerFontFull)),C.actions!==void 0&&A){const _=mE({x:y,y:w,width:k,height:b},C.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),Y=dl(M,0);D.addColorStop(0,Y),D.addColorStop(10/I,M),D.addColorStop(1,M),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[ie,se]=(s==null?void 0:s[1])??[-1,-1];for(let V=0;V35){const k=d?35:r-35,b=d?35*.7:r-35*.7,C=k/r,T=b/r,A=t.createLinearGradient(e,0,e+r,0),M=dl(m,0);A.addColorStop(d?1:0,m),A.addColorStop(C,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+Ns(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===dh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;y$(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===dh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;m$(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 yE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=Kv(s.title)==="rtl",m=gE(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},()=>ib(t,e,n,r,i,s,o,l,a,c,f,h,p,m)):ib(t,e,n,r,i,s,o,l,a,c,f,h,p,m)}var mz=xl,yz=function(){try{var t=mz(Object,"defineProperty");return t({},"",{}),t}catch{}}(),vz=yz,sb=vz;function wz(t,e,n){e=="__proto__"&&sb?sb(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var xz=wz;function bz(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&Mj?new Cj: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(),bp(A,C,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(V=>wh(b,O,1e4,P,V.x,V.y,V.width,V.height)))return;const D=d.hasIndex(_),Y=h.hasIndex(_);t.beginPath();const ie=f==null?void 0:f(_),se=ie===void 0?y:wo(y,ie);se.bgCell!==y.bgCell&&(t.fillStyle=se.bgCell,t.fillRect(b,O,1e4,P)),Y&&(t.fillStyle=se.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=se.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function wW(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?Pa(e):0;let h;if(d!==0&&(h=Gx(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:Gx(c,a.bgCell),m=kl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const ME=(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 xW(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}=ME(l,s,o),k=[],b=o-kl(h,d,u);let C=a,T=n,A=0;for(;C+i=y&&I<=w-1){const Y=c==null?void 0:c(T),ie=Y==null?void 0:Y.bgCell;ie!==void 0&&ie!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:ie})}C+=D,T0)for(let I=0;I=x&&Y<=g&&f(I+1)&&k.push({x:Y,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 Tb(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:C,maxY:T}=ME(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,C),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=C&&Y<=T-1){const ie=d==null?void 0:d(I);A.push({x1:k,y1:Y,x2:b,y2:Y,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??y})}P+=f(I),I++}}const _=yW(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 bW(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 C=0;if(typeof g=="number")C+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(C=-C),C+=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=Pa(x);if(M!==0&&C!==0)return{regions:[]};const _=u>0?kl(d,u,g):0,P=c-O-Math.abs(M),I=f-h-_-Math.abs(C)-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(C>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(C+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:C+1})):C<0&&(D.sy=(-C+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+C-_,width:c,height:-C+_})),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&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Y=O*p,ie=f*p;t.drawImage(e,0,0,Y,ie,0,0,Y,ie)}if(_>0&&M===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Y=(f-_)*p,ie=c*p,se=_*p;t.drawImage(e,0,Y,ie,se,0,Y,ie,se)}}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 kW(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||Oo(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 SW(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=Pa(l),y=kl(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 fz(A,w,e,n,k).map(O=>{const _=O.rect,P=I0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:I0(_.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:cz({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),C=()=>{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&&wh(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,_=!uz(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"?Fr(Fr(M.color,m.borderColor),m.bgCell):dl(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 C(),C}function Ab(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 Xg(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,C]=c.current.cell,T=d(c.current.cell),A=T.span??[b,b],M=C>=x-h,O=h>0&&!M?kl(x,h,f)-1:0,_=w[1];let P;if(Oo(o,r,i,s,u,(D,Y,ie,se,V)=>{if(D.sticky&&b>D.sourceIndex)return;const J=D.sourceIndexA[1],N=D.sourceIndex===w[0];if(!(!N&&(J||R)))return bp(V,ie,n,x,f,h,p,void 0,(L,z,j)=>{if(z!==C&&z!==_)return;let B=Y,oe=D.width;if(T.span!==void 0){const me=dE(T.span,Y,L,D.width,j,D,l),ze=D.sticky?me[0]:me[1];ze!==void 0&&(B=ze.x,oe=ze.width)}return z===_&&N&&m&&(P=()=>{var me;se>B&&!D.sticky&&(t.beginPath(),t.rect(se,0,e-se,n),t.clip()),t.beginPath(),t.rect(B+oe-4,L+j-4,4,4),t.fillStyle=((me=D.themeOverride)==null?void 0:me.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 CW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),fE(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)}),Oo(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 TW(t,e,n,r,i,s,o,l,a,u){let c=0;return Oo(t,s,r,i,n,(f,d,h,p,m)=>(bp(m,h,e,o,l,a,u,void 0,(x,g,y,w)=>{w||(c=Math.max(g,c))}),!0)),c}function Mb(t,e){var de;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:C,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:Y,prelightCells:ie,drawCellCallback:se,highlightRegions:V,resizeCol:J,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:z,hoverInfo:j,spriteManager:B,maxScaleFactor:oe,hasAppendRow:fe,touchMode:me,enqueue:ze,renderStateProvider:Fe,getCellRenderer:nt,renderStrategy:Et,bufferACtx:rt,bufferBCtx:it,damage:lt,minimumCellWidth:_t}=t;if(i===0||s===0)return;const Ne=Et==="double-buffer",xe=Math.min(oe,Math.ceil(window.devicePixelRatio??1)),_e=Et!=="direct"&&SW(t,e),Ye=n.canvas;(Ye.width!==i*xe||Ye.height!==s*xe)&&(Ye.width=i*xe,Ye.height=s*xe,Ye.style.width=i+"px",Ye.style.height=s+"px");const Ke=r.canvas,Ue=f?g+x:x,ht=Ue+1;(Ke.width!==i*xe||Ke.height!==ht*xe)&&(Ke.width=i*xe,Ke.height=ht*xe,Ke.style.width=i+"px",Ke.style.height=ht+"px");const vt=rt.canvas,at=it.canvas;Ne&&(vt.width!==i*xe||vt.height!==s*xe)&&(vt.width=i*xe,vt.height=s*xe,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Ne&&(at.width!==i*xe||at.height!==s*xe)&&(at.width=i*xe,at.height=s*xe,N.current!==void 0&&(N.current.bBufferScroll=void 0));const he=N.current;if(_e===!0&&o===(he==null?void 0:he.cellXOffset)&&l===(he==null?void 0:he.cellYOffset)&&a===(he==null?void 0:he.translateX)&&u===(he==null?void 0:he.translateY))return;let Be=null;Ne&&(Be=n);const ut=r;let tt;Ne?lt!==void 0?tt=(he==null?void 0:he.lastBuffer)==="b"?it:rt:tt=(he==null?void 0:he.lastBuffer)==="b"?rt:it:tt=n;const Vt=tt.canvas,ft=Ne?Vt===vt?at:vt:Ye,dt=typeof w=="number"?()=>w:w;ut.save(),tt.save(),ut.beginPath(),tt.beginPath(),ut.textBaseline="middle",tt.textBaseline="middle",xe!==1&&(ut.scale(xe,xe),tt.scale(xe,xe));const wt=P0(c,o,i,h,a);let Ut=[];const Mt=m&&((de=T.current)==null?void 0:de.cell[1])===l&&u===0;let Rn=!1;if(V!==void 0){for(const Re of V)if(Re.style!=="no-outline"&&Re.range.y===l&&u===0){Rn=!0;break}}const $n=()=>{pz(ut,wt,f,j,i,a,x,g,h,C,T,p,B,L,k,P,lt,Y,me),Tb(ut,wt,l,a,u,i,s,void 0,void 0,g,Ue,dt,I,k,M,O,p,!0),ut.beginPath(),ut.moveTo(0,ht-.5),ut.lineTo(i,ht-.5),ut.strokeStyle=Fr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),ut.stroke(),Rn&&Eb(ut,i,s,o,l,a,u,c,d,x,g,w,M,O,V,p),Mt&&Xg(ut,i,s,l,a,u,wt,c,p,Ue,T,dt,_,M,fe,A,O)};if(lt!==void 0){const Re=wt[wt.length-1].sourceIndex+1,De=lt.hasItemInRegion([{x:o,y:-2,width:Re,height:2},{x:o,y:l,width:Re,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:Re,height:M,when:M>0}]),q=Ae=>{rb(Ae,wt,c,s,Ue,a,u,l,O,dt,_,P,I,y,D,m,M,fe,Ut,lt,T,ie,V,R,B,L,j,se,z,p,ze,Fe,nt,b,_t);const $e=T.current;A&&m&&$e!==void 0&<.has(GT($e.range))&&Xg(Ae,i,s,l,a,u,wt,c,p,Ue,T,dt,_,M,fe,A,O)};De&&(q(tt),Be!==null&&(Be.save(),Be.scale(xe,xe),Be.textBaseline="middle",q(Be),Be.restore()),lt.hasHeader()&&(CW(ut,wt,i,g,Ue,a,u,l,lt),$n())),tt.restore(),ut.restore();return}if((_e!==!0||o!==(he==null?void 0:he.cellXOffset)||a!==(he==null?void 0:he.translateX)||Mt!==(he==null?void 0:he.mustDrawFocusOnHeader)||Rn!==(he==null?void 0:he.mustDrawHighlightRingsOnHeader))&&$n(),_e===!0){Lr(ft!==void 0&&he!==void 0);const{regions:Re}=bW(tt,ft,ft===vt?he.aBufferScroll:he.bBufferScroll,ft===vt?he.bBufferScroll:he.aBufferScroll,he,o,l,a,u,M,i,s,O,Ue,xe,c,wt,w,Ne);Ut=Re}else _e!==!1&&(Lr(he!==void 0),Ut=kW(he,o,l,a,u,i,s,Ue,wt,_e));wW(tt,wt,i,s,M,O,k,dt,p);const W=Eb(tt,i,s,o,l,a,u,c,d,x,g,w,M,O,V,p),ye=m?Xg(tt,i,s,l,a,u,wt,c,p,Ue,T,dt,_,M,fe,A,O):void 0;if(tt.fillStyle=p.bgCell,Ut.length>0){tt.beginPath();for(const Re of Ut)tt.rect(Re.x,Re.y,Re.width,Re.height);tt.clip(),tt.fill(),tt.beginPath()}else tt.fillRect(0,0,i,s);const re=rb(tt,wt,c,s,Ue,a,u,l,O,dt,_,P,I,y,D,m,M,fe,Ut,lt,T,ie,V,R,B,L,j,se,z,p,ze,Fe,nt,b,_t);vW(tt,wt,c,i,s,Ue,a,u,l,O,dt,I,T.rows,y,M,fe,Ut,lt,p),xW(tt,wt,l,a,u,i,s,Ut,Ue,dt,I,k,M,O,p),Tb(tt,wt,l,a,u,i,s,Ut,re,g,Ue,dt,I,k,M,O,p),W==null||W(),ye==null||ye(),C&&Oo(wt,0,a,0,Ue,(Re,De)=>Re.sourceIndex===J?(Ab(ut,De+Re.width,0,Ue+1,Fr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ab(tt,De+Re.width,Ue,s,Fr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),Be!==null&&(Be.fillStyle=p.bgCell,Be.fillRect(0,0,i,s),Be.drawImage(tt.canvas,0,0));const we=TW(wt,s,Ue,a,u,l,O,dt,M,fe);R==null||R.setWindow({x:o,y:l,width:wt.length,height:we-l},d,Array.from({length:M},(Re,De)=>O-1-De));const pe=he!==void 0&&(o!==he.cellXOffset||a!==he.translateX),Le=he!==void 0&&(l!==he.cellYOffset||u!==he.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Mt,mustDrawHighlightRingsOnHeader:Rn,lastBuffer:Ne?Vt===vt?"a":"b":void 0,aBufferScroll:Vt===vt?[pe,Le]:he==null?void 0:he.aBufferScroll,bBufferScroll:Vt===at?[pe,Le]:he==null?void 0:he.bBufferScroll},tt.restore(),ut.restore()}const EW=80;function AW(t){const e=t-1;return e*e*e+1}class MW{constructor(e){xt(this,"callback");xt(this,"currentHoveredItem");xt(this,"leavingItems",[]);xt(this,"lastAnimationTime");xt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>Ju(r.item,e.item))||this.leavingItems.push(e)});xt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>Ju(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});xt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});xt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});xt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:AW(e.hoverAmount)})));xt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/EW;for(const s of this.leavingItems)s.hoverAmount=Si(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Si(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});xt(this,"setHovered",e=>{var n;if(!Ju((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 RW{constructor(e){xt(this,"fn");xt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function nw(t){return new RW(t)}const OW=nw(()=>window.navigator.userAgent.includes("Firefox")),kh=nw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Sh=nw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function PW(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(Qv);e.current=[],r.current(new ec(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=Ci(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const qs="header",_r="group-header",Ch="out-of-bounds";var la;(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"})(la||(la={}));function RE(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 Rb=6,IW=(t,e)=>{if(t.kind===Se.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},NW=(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:C,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:Y,onItemHovered:ie,dragAndDropState:se,firstColAccessible:V,onKeyDown:J,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:z,onDragEnd:j,eventTargetRef:B,isResizing:oe,resizeColumn:fe,isDragging:me,isDraggable:ze=!1,allowResize:Fe,disabledRows:nt,hasAppendRow:Et,getGroupDetails:rt,theme:it,prelightCells:lt,headerIcons:_t,verticalBorder:Ne,drawCell:xe,drawHeader:_e,onCellFocused:Ye,onDragOverCell:Ke,onDrop:Ue,onDragLeave:ht,imageWindowLoader:vt,smoothScrollX:at=!1,smoothScrollY:he=!1,experimental:Be,getCellRenderer:ut}=t,tt=t.translateX??0,Vt=t.translateY??0,ft=Math.max(C,Math.min(s.length-1,o)),dt=v.useRef(null),wt=vt,Ut=v.useRef(),[Mt,Rn]=v.useState(!1),$n=v.useRef([]),W=v.useRef(),[ye,re]=v.useState(),[we,pe]=v.useState(),Le=v.useRef(null),[de,Re]=v.useState(),[De,q]=v.useState(!1),Ae=v.useRef(De);Ae.current=De;const $e=v.useMemo(()=>new lz(_t,()=>{Li.current=void 0,No.current()}),[_t]),qt=x?c+a:a,We=v.useRef(-1),Bt=((Be==null?void 0:Be.enableFirefoxRescaling)??!1)&&OW.value,Rt=((Be==null?void 0:Be.enableSafariRescaling)??!1)&&kh.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!Bt&&!Rt||(We.current!==-1&&Rn(!0),window.clearTimeout(We.current),We.current=window.setTimeout(()=>{Rn(!1),We.current=-1},200))},[l,ft,tt,Vt,Bt,Rt]);const Ft=r$(s,C),Tn=M?Pa(Ft,se):0,Zt=v.useCallback((H,ne,be)=>{const ge=H.getBoundingClientRect();if(ne>=Ft.length||be>=d)return;const ae=ge.width/n,Me=I0(ne,be,n,r,c,qt,ft,l,tt,Vt,d,C,A,Ft,f);return ae!==1&&(Me.x*=ae,Me.y*=ae,Me.width*=ae,Me.height*=ae),Me.x+=ge.x,Me.y+=ge.y,Me},[n,r,c,qt,ft,l,tt,Vt,d,C,A,Ft,f]),On=v.useCallback((H,ne,be,ge)=>{const ae=H.getBoundingClientRect(),Me=ae.width/n,st=(ne-ae.left)/Me,ot=(be-ae.top)/Me,Te=5,Dt=P0(Ft,ft,n,void 0,tt);let je=0,$t=0;ge instanceof MouseEvent&&(je=ge.button,$t=ge.buttons);const ct=l$(st,Dt,tt),kt=a$(ot,r,x,a,c,d,f,l,Vt,A),yn=(ge==null?void 0:ge.shiftKey)===!0,pt=(ge==null?void 0:ge.ctrlKey)===!0,dn=(ge==null?void 0:ge.metaKey)===!0,Kr=ge!==void 0&&!(ge instanceof MouseEvent)||(ge==null?void 0:ge.pointerType)==="touch",ln=[st<0?-1:nn||ot>r){const Ot=st>n?1:st<0?-1:0,vn=ot>r?1:ot<0?-1:0;let Rr=Ot*2,Fi=vn*2;Ot===0&&(Rr=ct===-1?la.EndPadding:la.Center),vn===0&&(Fi=kt===void 0?la.EndPadding:la.Center);let hi=!1;if(ct===-1&&kt===-1){const _o=Zt(H,Ft.length-1,-1);Lr(_o!==void 0),hi=ne<_o.x+_o.width+Te}const Nl=st>n&&str&&ot=0?(vn=!0,Ot=Zt(H,Rr,kt),Lr(Ot!==void 0),Mr={kind:x&&kt===-2?_r:qs,location:[Rr,kt],bounds:Ot,group:Ft[Rr].group??"",isEdge:vn,shiftKey:yn,ctrlKey:pt,metaKey:dn,isTouch:Kr,localEventX:ne-Ot.x,localEventY:be-Ot.y,button:je,buttons:$t,scrollEdge:ln}):Mr={kind:x&&kt===-2?_r:qs,group:Ft[ct].group??"",location:[ct,kt],bounds:Ot,isEdge:vn,shiftKey:yn,ctrlKey:pt,metaKey:dn,isTouch:Kr,localEventX:ne-Ot.x,localEventY:be-Ot.y,button:je,buttons:$t,scrollEdge:ln}}else{const Ot=Zt(H,ct,kt);Lr(Ot!==void 0);const vn=Ot!==void 0&&Ot.x+Ot.width-ne{}),Ds=v.useRef(ye);Ds.current=ye;const[cs,fs]=v.useMemo(()=>{const H=document.createElement("canvas"),ne=document.createElement("canvas");return H.style.display="none",H.style.opacity="0",H.style.position="fixed",ne.style.display="none",ne.style.opacity="0",ne.style.position="fixed",[H.getContext("2d",{alpha:!1}),ne.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(cs===null||fs===null))return document.documentElement.append(cs.canvas),document.documentElement.append(fs.canvas),()=>{cs.canvas.remove(),fs.canvas.remove()}},[cs,fs]);const Sl=v.useMemo(()=>new v$,[]),rf=Bt&&Mt?1:Rt&&Mt?2:5,sf=(Be==null?void 0:Be.disableMinimumCellWidth)===!0?1:10,Li=v.useRef(),Cl=v.useRef(null),Tl=v.useRef(null),El=v.useCallback(()=>{var st;const H=dt.current,ne=Le.current;if(H===null||ne===null||(Cl.current===null&&(Cl.current=H.getContext("2d",{alpha:!1}),H.width=0,H.height=0),Tl.current===null&&(Tl.current=ne.getContext("2d",{alpha:!1}),ne.width=0,ne.height=0),Cl.current===null||Tl.current===null||cs===null||fs===null))return;let be=!1;const ge=ot=>{be=!0,Re(ot)},ae=Li.current,Me={headerCanvasCtx:Tl.current,canvasCtx:Cl.current,bufferACtx:cs,bufferBCtx:fs,width:n,height:r,cellXOffset:ft,cellYOffset:l,translateX:Math.round(tt),translateY:Math.round(Vt),mappedColumns:Ft,enableGroups:x,freezeColumns:C,dragAndDropState:se,theme:it,headerHeight:a,groupHeaderHeight:c,disabledRows:nt??Pt.empty(),rowHeight:f,verticalBorder:Ne,isResizing:oe,resizeCol:fe,isFocused:k,selection:b,fillHandle:u,drawCellCallback:xe,hasAppendRow:Et,overrideCursor:ge,maxScaleFactor:rf,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:rt??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:_e,prelightCells:lt,highlightRegions:N,imageLoader:wt,lastBlitData:W,damage:Ut.current,hoverValues:$n.current,hoverInfo:Ds.current,spriteManager:$e,scrolling:Mt,hyperWrapping:(Be==null?void 0:Be.hyperWrapping)??!1,touchMode:De,enqueue:nf.current,renderStateProvider:Sl,renderStrategy:(Be==null?void 0:Be.renderStrategy)??(kh.value?"double-buffer":"single-buffer"),getCellRenderer:ut,minimumCellWidth:sf};Me.damage===void 0?(Li.current=Me,Mb(Me,ae)):Mb(Me,void 0),!be&&(Me.damage===void 0||Me.damage.has((st=Ds==null?void 0:Ds.current)==null?void 0:st[0]))&&Re(void 0)},[cs,fs,n,r,ft,l,tt,Vt,Ft,x,C,se,it,a,c,nt,f,Ne,oe,Et,fe,k,b,u,A,d,_,rf,h,rt,p,xe,_e,lt,N,wt,$e,Mt,Be==null?void 0:Be.hyperWrapping,Be==null?void 0:Be.renderStrategy,De,Sl,ut,sf]),No=v.useRef(El);v.useLayoutEffect(()=>{El(),No.current=El},[El]),v.useLayoutEffect(()=>{(async()=>{var ne;((ne=document==null?void 0:document.fonts)==null?void 0:ne.ready)!==void 0&&(await document.fonts.ready,Li.current=void 0,No.current())})()},[]);const _s=v.useCallback(H=>{Ut.current=H,No.current(),Ut.current=void 0},[]),of=PW(_s);nf.current=of;const lf=v.useCallback(H=>{_s(new ec(H.map(ne=>ne.cell)))},[_s]);wt.setCallback(_s);const[Fp,$p]=v.useState(!1),[Al,ds]=sn??[],Bp=Al!==void 0&&ds===-1,zp=Al!==void 0&&ds===-2;let af=!1,Ml=!1,En=de;if(En===void 0&&Al!==void 0&&ds!==void 0&&ds>-1&&ds({contain:"strict",display:"block",cursor:uf}),[uf]),Za=v.useRef("default"),Ls=B==null?void 0:B.current;Ls!=null&&Za.current!==Rl.cursor&&(Ls.style.cursor=Za.current=Rl.cursor);const Er=v.useCallback((H,ne,be,ge)=>{if(rt===void 0)return;const ae=rt(H);if(ae.actions!==void 0){const Me=mE(ne,ae.actions);for(const[st,ot]of Me.entries())if(kp(ot,be+ne.x,ge+ot.y))return ae.actions[st]}},[rt]),ci=v.useCallback((H,ne,be,ge)=>{const ae=s[ne];if(!me&&!oe&&ae.hasMenu===!0&&!(we??!1)){const Me=Zt(H,ne,-1);Lr(Me!==void 0);const st=gE(Me.x,Me.y,Me.width,Me.height,Kv(ae.title)==="rtl");if(be>st.x&&best.y&&ge{const ne=dt.current,be=B==null?void 0:B.current;if(ne===null||H.target!==ne&&H.target!==be)return;tu.current=!0;let ge,ae;if(H instanceof MouseEvent?(ge=H.clientX,ae=H.clientY):(ge=H.touches[0].clientX,ae=H.touches[0].clientY),H.target===be&&be!==null){const st=be.getBoundingClientRect();if(ge>st.right||ae>st.bottom)return}const Me=On(ne,ge,ae,H);Fs.current=Me.location,Me.isTouch&&(eu.current=Date.now()),Ae.current!==Me.isTouch&&q(Me.isTouch),!(Me.kind===qs&&ci(ne,Me.location[0],ge,ae)!==void 0)&&(Me.kind===_r&&Er(Me.group,Me.bounds,Me.localEventX,Me.localEventY)!==void 0||(P==null||P(Me),!Me.isTouch&&ze!==!0&&ze!==Me.kind&&Me.button<3&&Me.button!==1&&H.preventDefault()))},[B,ze,On,Er,ci,P]);jn("touchstart",ir,window,!1),jn("mousedown",ir,window,!1);const Ol=v.useRef(0),nu=v.useCallback(H=>{var $t,ct;const ne=Ol.current;Ol.current=Date.now();const be=dt.current;if(tu.current=!1,I===void 0||be===null)return;const ge=B==null?void 0:B.current,ae=H.target!==be&&H.target!==ge;let Me,st,ot=!0;if(H instanceof MouseEvent){if(Me=H.clientX,st=H.clientY,ot=H.button<3,H.pointerType==="touch")return}else Me=H.changedTouches[0].clientX,st=H.changedTouches[0].clientY;let Te=On(be,Me,st,H);Te.isTouch&&eu.current!==0&&Date.now()-eu.current>500&&(Te={...Te,isLongTouch:!0}),ne!==0&&Date.now()-ne<(Te.isTouch?1e3:500)&&(Te={...Te,isDoubleClick:!0}),Ae.current!==Te.isTouch&&q(Te.isTouch),!ae&&H.cancelable&&ot&&H.preventDefault();const[Dt]=Te.location,je=ci(be,Dt,Me,st);if(Te.kind===qs&&je!==void 0){(Te.button!==0||(($t=Fs.current)==null?void 0:$t[0])!==Dt||((ct=Fs.current)==null?void 0:ct[1])!==-1)&&I(Te,!0);return}else if(Te.kind===_r){const kt=Er(Te.group,Te.bounds,Te.localEventX,Te.localEventY);if(kt!==void 0){Te.button===0&&kt.onClick(Te);return}}I(Te,ae)},[I,B,On,ci,Er]);jn("mouseup",nu,window,!1),jn("touchend",nu,window,!1);const cf=v.useCallback(H=>{var je,$t;const ne=dt.current;if(ne===null)return;const be=B==null?void 0:B.current,ge=H.target!==ne&&H.target!==be;let ae,Me,st=!0;H instanceof MouseEvent?(ae=H.clientX,Me=H.clientY,st=H.button<3):(ae=H.changedTouches[0].clientX,Me=H.changedTouches[0].clientY);const ot=On(ne,ae,Me,H);Ae.current!==ot.isTouch&&q(ot.isTouch),!ge&&H.cancelable&&st&&H.preventDefault();const[Te]=ot.location,Dt=ci(ne,Te,ae,Me);if(ot.kind===qs&&Dt!==void 0)ot.button===0&&((je=Fs.current)==null?void 0:je[0])===Te&&(($t=Fs.current)==null?void 0:$t[1])===-1&&(m==null||m(Te,Dt));else if(ot.kind===_r){const ct=Er(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ct!==void 0&&ot.button===0&&ct.onClick(ot)}},[B,On,ci,m,Er]);jn("click",cf,window,!1);const jp=v.useCallback(H=>{const ne=dt.current,be=B==null?void 0:B.current;if(ne===null||H.target!==ne&&H.target!==be||T===void 0)return;const ge=On(ne,H.clientX,H.clientY,H);T(ge,()=>{H.cancelable&&H.preventDefault()})},[B,On,T]);jn("contextmenu",jp,(B==null?void 0:B.current)??null,!1);const ff=v.useCallback(H=>{Ut.current=new ec(H.map(ne=>ne.item)),$n.current=H,No.current(),Ut.current=void 0},[]),fi=v.useMemo(()=>new MW(ff),[ff]),hs=v.useRef(fi);hs.current=fi,v.useLayoutEffect(()=>{const H=hs.current;if(sn===void 0||sn[1]<0){H.setHovered(sn);return}const ne=h(sn,!0),be=ut(ne),ge=be===void 0&&ne.kind===Se.Custom||(be==null?void 0:be.needsHover)!==void 0&&(typeof be.needsHover=="boolean"?be.needsHover:be.needsHover(ne));H.setHovered(ge?sn:void 0)},[h,ut,sn]);const Ar=v.useRef(),X=v.useCallback(H=>{var ot;const ne=dt.current;if(ne===null)return;const be=B==null?void 0:B.current,ge=H.target!==ne&&H.target!==be,ae=On(ne,H.clientX,H.clientY,H);if(ae.kind!=="out-of-bounds"&&ge&&!tu.current&&!ae.isTouch)return;const Me=(Te,Dt)=>{re(je=>je===Te||(je==null?void 0:je[0][0])===(Te==null?void 0:Te[0][0])&&(je==null?void 0:je[0][1])===(Te==null?void 0:Te[0][1])&&((je==null?void 0:je[1][0])===(Te==null?void 0:Te[1][0])&&(je==null?void 0:je[1][1])===(Te==null?void 0:Te[1][1])||!Dt)?je:Te)};if(!RE(ae,Ar.current))Re(void 0),ie==null||ie(ae),Me(ae.kind===Ch?void 0:[ae.location,[ae.localEventX,ae.localEventY]],!0),Ar.current=ae;else if(ae.kind==="cell"||ae.kind===qs||ae.kind===_r){let Te=!1,Dt=!0;if(ae.kind==="cell"){const $t=h(ae.location);Dt=((ot=ut($t))==null?void 0:ot.needsHoverPosition)??$t.kind===Se.Custom,Te=Dt}else ae.kind===_r&&(Te=!0);const je=[ae.location,[ae.localEventX,ae.localEventY]];Me(je,Dt),Ds.current=je,Te&&_s(new ec([ae.location]))}const st=ae.location[0]>=(V?0:1);pe(ae.kind===qs&&ae.isEdge&&st&&Fe===!0),$p(ae.kind==="cell"&&ae.isFillHandle),D==null||D(H),Y(ae)},[B,On,V,Fe,D,Y,ie,h,ut,_s]);jn("mousemove",X,window,!0);const on=v.useCallback(H=>{const ne=dt.current;if(ne===null)return;let be,ge;b.current!==void 0&&(be=Zt(ne,b.current.cell[0],b.current.cell[1]),ge=b.current.cell),J==null||J({bounds:be,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:ge})},[J,b,Zt]),Do=v.useCallback(H=>{const ne=dt.current;if(ne===null)return;let be,ge;b.current!==void 0&&(be=Zt(ne,b.current.cell[0],b.current.cell[1]),ge=b.current.cell),R==null||R({bounds:be,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:ge})},[R,b,Zt]),Hp=v.useCallback(H=>{dt.current=H,L!==void 0&&(L.current=H)},[L]),df=v.useCallback(H=>{const ne=dt.current;if(ne===null||ze===!1||oe){H.preventDefault();return}let be,ge;const ae=On(ne,H.clientX,H.clientY);if(ze!==!0&&ae.kind!==ze){H.preventDefault();return}const Me=($t,ct)=>{be=$t,ge=ct};let st,ot,Te;const Dt=($t,ct,kt)=>{st=$t,ot=ct,Te=kt};let je=!1;if(z==null||z({...ae,setData:Me,setDragImage:Dt,preventDefault:()=>je=!0,defaultPrevented:()=>je}),!je&&be!==void 0&&ge!==void 0&&H.dataTransfer!==null)if(H.dataTransfer.setData(be,ge),H.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Te!==void 0)H.dataTransfer.setDragImage(st,ot,Te);else{const[$t,ct]=ae.location;if(ct!==void 0){const kt=document.createElement("canvas"),yn=Zt(ne,$t,ct);Lr(yn!==void 0);const pt=Math.ceil(window.devicePixelRatio??1);kt.width=yn.width*pt,kt.height=yn.height*pt;const dn=kt.getContext("2d");dn!==null&&(dn.scale(pt,pt),dn.textBaseline="middle",ct===-1?(dn.font=it.headerFontFull,dn.fillStyle=it.bgHeader,dn.fillRect(0,0,kt.width,kt.height),yE(dn,0,0,yn.width,yn.height,Ft[$t],!1,it,!1,!1,0,$e,_e,!1)):(dn.font=it.baseFontFull,dn.fillStyle=it.bgCell,dn.fillRect(0,0,kt.width,kt.height),pE(dn,h([$t,ct]),0,ct,!1,!1,0,0,yn.width,yn.height,!1,it,it.bgCell,wt,$e,1,void 0,!1,0,void 0,void 0,void 0,Sl,ut,()=>{}))),kt.style.left="-100%",kt.style.position="absolute",kt.style.width=`${yn.width}px`,kt.style.height=`${yn.height}px`,document.body.append(kt),H.dataTransfer.setDragImage(kt,yn.width/2,yn.height/2),window.setTimeout(()=>{kt.remove()},0)}}else H.preventDefault()},[ze,oe,On,z,Zt,it,Ft,$e,_e,h,wt,Sl,ut]);jn("dragstart",df,(B==null?void 0:B.current)??null,!1,!1);const ru=v.useRef(),Wp=v.useCallback(H=>{const ne=dt.current;if(Ue!==void 0&&H.preventDefault(),ne===null||Ke===void 0)return;const be=On(ne,H.clientX,H.clientY),[ge,ae]=be.location,Me=ge-(V?0:1),[st,ot]=ru.current??[];(st!==Me||ot!==ae)&&(ru.current=[Me,ae],Ke([Me,ae],H.dataTransfer))},[V,On,Ke,Ue]);jn("dragover",Wp,(B==null?void 0:B.current)??null,!1,!1);const Nw=v.useCallback(()=>{ru.current=void 0,j==null||j()},[j]);jn("dragend",Nw,(B==null?void 0:B.current)??null,!1,!1);const Q=v.useCallback(H=>{const ne=dt.current;if(ne===null||Ue===void 0)return;H.preventDefault();const be=On(ne,H.clientX,H.clientY),[ge,ae]=be.location,Me=ge-(V?0:1);Ue([Me,ae],H.dataTransfer)},[V,On,Ue]);jn("drop",Q,(B==null?void 0:B.current)??null,!1,!1);const Kn=v.useCallback(()=>{ht==null||ht()},[ht]);jn("dragleave",Kn,(B==null?void 0:B.current)??null,!1,!1);const An=v.useRef(b);An.current=b;const Pl=v.useRef(null),iu=v.useCallback(H=>{var ne;dt.current===null||!dt.current.contains(document.activeElement)||(H===null&&An.current.current!==void 0?(ne=L==null?void 0:L.current)==null||ne.focus({preventScroll:!0}):H!==null&&H.focus({preventScroll:!0}),Pl.current=H)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var ne;const H=Pl.current;H===null||!document.contains(H)?(ne=L==null?void 0:L.current)==null||ne.focus({preventScroll:!0}):H.focus({preventScroll:!0})},getBounds:(H,ne)=>{if(!(L===void 0||L.current===null))return Zt(L.current,H??0,ne??-1)},damage:lf}),[L,lf,Zt]);const $s=v.useRef(),pr=k4(()=>{var ot,Te,Dt;if(n<50||(Be==null?void 0:Be.disableAccessibilityTree)===!0)return null;let H=P0(Ft,ft,n,se,tt);const ne=V?0:-1;!V&&((ot=H[0])==null?void 0:ot.sourceIndex)===0&&(H=H.slice(1));const[be,ge]=((Te=b.current)==null?void 0:Te.cell)??[],ae=(Dt=b.current)==null?void 0:Dt.range,Me=H.map(je=>je.sourceIndex),st=qo(l,Math.min(d,l+i));return be!==void 0&&ge!==void 0&&!(Me.includes(be)&&st.includes(ge))&&iu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":Ft.length+ne},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},H.map(je=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(je.sourceIndex),"aria-colindex":je.sourceIndex+1+ne,tabIndex:-1,onFocus:$t=>{if($t.target!==Pl.current)return Ye==null?void 0:Ye([je.sourceIndex,-1])},key:je.sourceIndex},je.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(je=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(je),key:je,"aria-rowindex":je+2},H.map($t=>{const ct=$t.sourceIndex,kt=Ci(ct,je),yn=be===ct&&ge===je,pt=ae!==void 0&&ct>=ae.x&&ct=ae.y&&je{const Mr=L==null?void 0:L.current;if(Mr!=null)return J==null?void 0:J({bounds:Zt(Mr,ct,je),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Kr})},onFocusCapture:Mr=>{var Ot,vn;if(!(Mr.target===Pl.current||((Ot=$s.current)==null?void 0:Ot[0])===ct&&((vn=$s.current)==null?void 0:vn[1])===je))return $s.current=Kr,Ye==null?void 0:Ye(Kr)},ref:yn?iu:void 0,tabIndex:-1},IW(ln,ut))})))))},[n,Ft,ft,se,tt,d,l,i,b,iu,h,L,J,Zt,Ye],200),di=C===0||!M?0:ft>C?1:Si(-tt/100,0,1),Vp=-l*32+Vt,Il=O?Si(-Vp/100,0,1):0,Up=v.useMemo(()=>{if(!di&&!Il)return null;const H={position:"absolute",top:0,left:Tn,width:n-Tn,height:r,opacity:di,pointerEvents:"none",transition:at?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},ne={position:"absolute",top:qt,left:0,width:n,height:r,opacity:Il,pointerEvents:"none",transition:he?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,di>0&&v.createElement("div",{id:"shadow-x",style:H}),Il>0&&v.createElement("div",{id:"shadow-y",style:ne}))},[di,Il,Tn,n,at,qt,r,he]),Kp=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:Do,onFocus:y,onBlur:w,ref:Hp,style:Rl},pr),v.createElement("canvas",{ref:Le,style:Kp}),Up)},DW=v.memo(v.forwardRef(NW));function Cu(t,e,n,r){return Si(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const _W=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:C,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:Y,onColumnProposeMove:ie,onMouseDown:se,onMouseUp:V,onItemHovered:J,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:z,selection:j}=t,B=j.columns,oe=v.useCallback(Ne=>{const[xe,_e]=Ne.location;s!==void 0&&l!==xe&&xe>=Y?(c(!0),a(xe)):h!==void 0&&_e!==void 0?(y(!0),x(Math.max(0,_e))):r===void 0&&!u&&!g&&(J==null||J(Ne))},[s,h,l,J,Y,r,u,g]),fe=T!==void 0,me=v.useCallback(Ne=>{var xe;if(Ne.button===0){const[_e,Ye]=Ne.location;if(Ne.kind==="out-of-bounds"&&Ne.isEdge&&L){const Ke=(xe=_==null?void 0:_.current)==null?void 0:xe.getBounds(z.length-1,-1);Ke!==void 0&&(n(Ke.x),i(z.length-1))}else if(Ne.kind==="header"&&_e>=Y){const Ke=N==null?void 0:N.current;if(Ne.isEdge&&L&&Ke){n(Ne.bounds.x),i(_e);const ht=Ke.getBoundingClientRect().width/Ke.offsetWidth,vt=Ne.bounds.width/ht;M==null||M(z[_e],vt,_e,vt+(z[_e].growOffset??0))}else Ne.kind==="header"&&fe&&(d(Ne.bounds.x),o(_e))}else Ne.kind==="cell"&&Y>0&&_e===0&&Ye!==void 0&&D!==void 0&&(k(Ne.bounds.y),p(Ye))}se==null||se(Ne)},[se,L,Y,D,_,z,fe,M,N]),ze=v.useCallback((Ne,xe)=>{u||g||b==null||b(Ne,xe)},[u,g,b]),Fe=v.useRef(-1),nt=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)},[]),Et=v.useCallback((Ne,xe)=>{if(Ne.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const Ye of B){if(Ye===r)continue;const Ke=z[Ye],Ue=Cu(Ke,Fe.current,I,P);A==null||A(Ke,Ue,Ye,Ue+(Ke.growOffset??0))}const _e=Cu(z[r],Fe.current,I,P);if(O==null||O(z[r],_e,r,_e+(z[r].growOffset??0)),B.hasIndex(r))for(const Ye of B){if(Ye===r)continue;const Ke=z[Ye],Ue=Cu(Ke,Fe.current,I,P);O==null||O(Ke,Ue,Ye,Ue+(Ke.growOffset??0))}}nt(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}V==null||V(Ne,xe)},[V,r,s,l,h,m,B,O,z,I,P,A,T,D,nt]),rt=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]),it=v.useCallback(Ne=>{const xe=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Ne.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Ne.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&xe){const Ye=xe.getBoundingClientRect().width/xe.offsetWidth,Ke=(Ne.clientX-e)/Ye,Ue=z[r],ht=Cu(Ue,Ke,I,P);if(A==null||A(Ue,ht,r,ht+(Ue.growOffset??0)),Fe.current=Ke,(B==null?void 0:B.first())===r)for(const vt of B){if(vt===r)continue;const at=z[vt],he=Cu(at,Fe.current,I,P);A==null||A(at,he,vt,he+(at.growOffset??0))}}},[s,f,h,w,r,e,z,I,P,A,B,N]),lt=v.useCallback((Ne,xe)=>{if(h===void 0||m===void 0)return C(Ne,xe);let[_e,Ye]=Ne;return Ye===m?Ye=h:(Ye>m&&(Ye-=1),Ye>=h&&(Ye+=1)),C([_e,Ye],xe)},[h,m,C]),_t=v.useCallback(Ne=>{R==null||R(Ne),Ne.defaultPrevented()||nt()},[nt,R]);return v.createElement(DW,{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:ze,isDragging:u,onItemHovered:oe,onDragStart:_t,onMouseDown:me,allowResize:L,onMouseUp:Et,dragAndDropState:rt,onMouseMoveRaw:it,ref:_})};function LW(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 FW=(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])},$W=()=>t=>t.isSafari?"scroll":"auto",BW=Vr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[$W()]}});function zW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return jn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),jn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const jW=t=>{var z,j;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),C=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=v.useRef(null),M=zW(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[oe,fe]=T.current.lockDirection;oe!==void 0?B.scrollLeft=oe:fe!==void 0&&(B.scrollTop=fe),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,oe)=>{var xe;const fe=b.current;if(fe===null)return;oe=oe??fe.scrollTop,B=B??fe.scrollLeft;const me=T.current.scrollTop,ze=T.current.scrollLeft,Fe=B-ze,nt=oe-me;M&&Fe!==0&&nt!==0&&(Math.abs(Fe)>3||Math.abs(nt)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(Fe)0&&(Math.abs(_t)>2e3||lt===0||lt===Ne)&&r>fe.scrollHeight+5){const _e=lt/Ne,Ye=(r-it)*_e;w.current=Ye-lt}Et!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:lt+w.current,width:rt-c,height:it-u,paddingRight:((xe=A.current)==null?void 0:xe.clientWidth)??0})},[u,c,r,s,a,M]);FW(h&&kh.value,I,b);const D=v.useRef(I);D.current=I;const Y=v.useRef(),ie=v.useRef(!1);v.useLayoutEffect(()=>{ie.current?I():ie.current=!0},[I,u,c]);const se=v.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let V=0,J=0;for(x.push(v.createElement("div",{key:V++,style:{width:i,height:0}}));JD.current(),0),Y.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(BW,{isSafari:kh.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:se,style:Y.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(C%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))))))},HW=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:C}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),Y=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 nt,Et;if(se.current===void 0)return;const R={...se.current};let N=0,L=R.x<0?-R.x:0,z=0,j=0;R.x=R.x<0?0:R.x;let B=0;for(let rt=0;rt=it+rt.width)N+=rt.width,j++,z++;else if(R.x>it)N+=rt.width,k?L+=it-R.x:j++,z++;else if(R.x+R.width>it)N+=rt.width,z++;else break}let oe=0,fe=0,me=0;if(typeof r=="number")b?(fe=Math.floor(R.y/r),oe=fe*r-R.y):fe=Math.ceil(R.y/r),me=Math.ceil(R.height/r)+fe,oe<0&&me++;else{let rt=0;for(let it=0;it=rt+lt)rt+=lt,fe++,me++;else if(R.y>_t)rt+=lt,b?oe+=_t-R.y:fe++,me++;else if(R.y+R.height>lt/2+rt)rt+=lt,me++;else break}}const ze={x:j,y:fe,width:z-j,height:me-fe},Fe=_.current;(Fe===void 0||Fe.y!==ze.y||Fe.x!==ze.x||Fe.height!==ze.height||Fe.width!==ze.width||P.current!==L||I.current!==oe||R.width!==((nt=D.current)==null?void 0:nt[0])||R.height!==((Et=D.current)==null?void 0:Et[1]))&&(d==null||d({x:j,y:fe,width:z-j,height:me-fe},R.width,R.height,R.paddingRight??0,L,oe),_.current=ze,P.current=L,I.current=oe,D.current=[R.width,R.height])},[e,r,n,d,l,k,b]),J=v.useCallback(R=>{se.current=R,V()},[V]);return v.useEffect(()=>{V()},[V]),v.createElement(jW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:Y+(T??0),scrollHeight:ie+(A??0),clientHeight:O,rightElement:m,paddingBottom:A,paddingRight:T,rightElementProps:x,update:J,initialSize:w},v.createElement(_W,{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}))},WW=Vr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),VW=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"})),UW=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"})),KW=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"})),XW=10,GW=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 C=v.useRef(),[T,A]=v.useState([]),M=l??T,O=v.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.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 z=_.current,j=Math.min(10,r),B=0;w(void 0),A([]);const oe=[],fe=async()=>{var Ne;if(u===void 0)return;const me=performance.now(),ze=r-B;let Fe=u({x:0,y:z,width:i.length,height:Math.min(j,ze,r-z)},b.current.signal);typeof Fe=="function"&&(Fe=await Fe());let nt=!1;for(const[xe,_e]of Fe.entries())for(const[Ye,Ke]of _e.entries()){let Ue;switch(Ke.kind){case Se.Text:case Se.Number:Ue=Ke.displayData;break;case Se.Uri:case Se.Markdown:Ue=Ke.data;break;case Se.Boolean:Ue=typeof Ke.data=="boolean"?Ke.data.toString():void 0;break;case Se.Image:case Se.Bubble:Ue=Ke.data.join("🐳");break;case Se.Custom:Ue=Ke.copyData;break}Ue!==void 0&&L.test(Ue)&&(oe.push([Ye,xe+z]),nt=!0)}const Et=performance.now();nt&&A([...oe]),B+=Fe.length,Lr(B<=r);const rt=((Ne=k.current)==null?void 0:Ne.selectedIndex)??-1;w({results:oe.length,rowsSearched:B,selectedIndex:rt}),c==null||c(oe,rt),z+j>=r?z=0:z+=j;const it=Et-me,lt=Math.max(it,1),_t=XW/lt;j=Math.ceil(j*_t),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 Y=v.useCallback(N=>{var z;if((z=N==null?void 0:N.stopPropagation)==null||z.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 z;if((z=N==null?void 0:N.stopPropagation)==null||z.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]),se=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():Y())},[I,Y,ie]);v.useEffect(()=>()=>{O()},[O]);const[V,J]=v.useState(!1);v.useEffect(()=>{if(f)J(!0);else{const N=setTimeout(()=>J(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!V)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()},j={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(WW,{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:se}),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},VW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Y,disabled:((y==null?void 0:y.results)??0)===0},UW),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},KW)),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:j})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,V,y,r,h,s,D,x,se,ie,Y,d,I]);return v.createElement(v.Fragment,null,v.createElement(HW,{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 qW extends v.PureComponent{constructor(){super(...arguments);xt(this,"wrapperRef",v.createRef());xt(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 YW=()=>t=>Math.max(16,t.targetHeight-10),QW=Vr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[YW(),"px"]}}),JW=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Nn.useState(n);return Nn.createElement(qW,{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},Nn.createElement(QW,{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 ZW(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 mt(t,e,n){const r=OE(t,e);return r&&(n.didMatch=!0),r}function OE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(OE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!ZW(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":Sh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function e6(t,e,n,r,i,s){const o=Nn.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:Pt.empty(),rows:m?t.rows:Pt.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=Nn.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:Pt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Pt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Nn.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:Pt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Pt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function t6(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:Se.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:Se.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Se.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function n6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Se.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===zv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Se.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Se.Image:case Se.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Se.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Se.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Se.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Se.Markdown:case Se.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Se.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Se.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Se.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Tc()}}function r6(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"}:n6(o))})}function Ob(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function i6(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=>Ob(o,!0)).join(",")):i.push(Ob(s.formatted,!1));e.push(i.join(" "))}return e.join(` -`)}function Gg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Pb(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function s6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function o6(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("
${Gg(i.formatted)}
    ${i.formatted.map((o,l)=>`
  1. `+Gg(o)+"
  2. ").join("")}
${Gg(i.formatted)}
"),e.join("")}function l6(t,e){const n=r6(t,e),r=i6(n),i=o6(n);return{textPlain:r,textHtml:i}}function Ib(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:s6(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 a6(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 Nb(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function u6(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,` +`}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 XT{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 GT{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 qc=class P0{constructor(e){this.options=e||kl,this.options.renderer=this.options.renderer||new Qv,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new XT,this.slugger=new GT}static parse(e,n){return new P0(n).parse(e)}static parseInline(e,n){return new P0(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,C;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:

"+Jn(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={...Je.defaults,...s};const o=G4(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(U4(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&&Je.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;Je.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(Je.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&&Je.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function Je(t,e,n){return qT(ko.lex,qc.parse)(t,e,n)}Je.options=Je.setOptions=function(t){return Je.defaults={...Je.defaults,...t},I4(Je.defaults),Je};Je.getDefaults=WT;Je.defaults=kl;Je.use=function(...t){const e=Je.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=Je.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=Je.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=Je.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=Je.defaults.hooks||new xh;for(const s in n.hooks){const o=i[s];xh.passThroughHooks.has(s)?i[s]=l=>{if(Je.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=Je.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}}Je.setOptions(r)})};Je.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(Je,r)),r.type){case"table":{for(const i of r.header)n=n.concat(Je.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(Je.walkTokens(s.tokens,e));break}case"list":{n=n.concat(Je.walkTokens(r.items,e));break}default:Je.defaults.extensions&&Je.defaults.extensions.childTokens&&Je.defaults.extensions.childTokens[r.type]?Je.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(Je.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(Je.walkTokens(r.tokens,e)))}return n};Je.parseInline=qT(ko.lexInline,qc.parseInline);Je.Parser=qc;Je.parser=qc.parse;Je.Renderer=Qv;Je.TextRenderer=XT;Je.Lexer=ko;Je.lexer=ko.lex;Je.Tokenizer=Yv;Je.Slugger=GT;Je.Hooks=xh;Je.parse=Je;Je.options;Je.setOptions;Je.use;Je.walkTokens;Je.parseInline;qc.parse;ko.lex;const q4=Vr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class Y4 extends Nn.PureComponent{constructor(){super(...arguments);vt(this,"targetElement",null);vt(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=Je(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(),Nn.createElement(q4,{ref:this.containerRefHook})}}const Q4=Vr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),J4=Vr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),Z4=Vr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let qx=0;const Sp=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??"";Lr(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(Z4,{className:"gdg-growing-entry"},v.createElement(J4,{className:u},f+` +`),v.createElement(Q4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Wg={};let Us=null;function e$(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function I0(t){const e=t.toLowerCase().trim();if(Wg[e]!==void 0)return Wg[e];Us=Us||e$(),Us.style.color="#000",Us.style.color=e;const n=getComputedStyle(Us).color;Us.style.color="#fff",Us.style.color=e;const r=getComputedStyle(Us).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),Wg[e]=i,i}function hl(t,e){const[n,r,i]=I0(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=Fr(t,e);return Yx.set(n,i),i}function Fr(t,e){if(e===void 0)return t;const[n,r,i,s]=I0(t);if(s===1)return t;const[o,l,a,u]=I0(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 Kl=new Map,la=new Map,N0=new Map;function t$(){Kl.clear(),N0.clear(),la.clear()}function n$(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 r$(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 Ju(t,e,n,r){var i,s;let o=la.get(n);if(r&&o!==void 0&&o.count>2e4){let u=N0.get(n);if(u===void 0&&(u=r$(t,o.size),N0.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 n$(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),la.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)la.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;la.set(n,{count:o.count+e.length,size:f})}return l.width}function i$(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=Ju(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 s$(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Kl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` +`),c=la.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=Ju(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=i$(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=Ju(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()),Kl.set(o,a),Kl.size>500&&Kl.delete(Kl.keys().next().value),a}function o$(t,e){return Nn.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 YT(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 u$(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 JT(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 Ia(t,e){let n=0;const r=JT(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 h$(){var t;d$||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Dd=0,ec={},t$())}h$();function ZT(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function Yc(t,e,n,r="middle"){const i=ZT(t,e,r,n);let s=ec[i];return s===void 0&&(s=e.measureText(t),ec[i]=s,Dd++),Dd>1e4&&(ec={},Dd=0),s}function p$(t,e){const n=ZT(t,void 0,"middle",e);return ec[n]}function Ns(t,e){return typeof e!="string"&&(e=e.baseFontFull),g$(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 g$(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 m$(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 v$(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=s$(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=tE(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(eE(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function xs(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=y$(e,c));const d=Ns(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?v$(s,e,a,u,c,f,d,l,n,i):eE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function is(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 w$(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 x$(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 _0(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=Ia(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&&Ac(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 Ci(t,e){return(e+2)*Jv+t}function nE(t){return t%Jv}function Zv(t){return Math.floor(t/Jv)-2}function ew(t){const e=nE(t),n=Zv(t);return[e,n]}class rE{constructor(){vt(this,"visibleWindow",{x:0,y:0,width:0,height:0});vt(this,"freezeCols",0);vt(this,"freezeRows",[]);vt(this,"isInWindow",e=>{const n=nE(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&&Pa(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class b$ extends rE{constructor(){super(...arguments);vt(this,"cache",new Map);vt(this,"setValue",(n,r)=>{this.cache.set(Ci(n[0],n[1]),r)});vt(this,"getValue",n=>this.cache.get(Ci(n[0],n[1])));vt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class tc{constructor(e=[]){vt(this,"cells");this.cells=new Set(e.map(n=>Ci(n[0],n[1])))}add(e){this.cells.add(Ci(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Ci(e[0],e[1]))}remove(e){this.cells.delete(Ci(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=C$(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 T$(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)},C={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const E=y(b,a.signal),R=k>0?y(C,a.signal):void 0;let O;typeof E=="object"?O=E:O=await Rx(E),R!==void 0&&(typeof R=="object"?O=[...O,...R]:O=[...O,...await Rx(R)]),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:L0}):(h.font=f.current.baseFontFull,t.map((T,E)=>{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:L0};const R=oE(h,o,T,E,x,i,s,!0,l);return p.current[T.id]=R.width,R})),k=0,b=0;const C=[];for(const[T,E]of w.entries())k+=E.width,E.grow!==void 0&&E.grow>0&&(b+=E.grow,C.push(T));if(k0){const T=[...w],E=r-k;let R=E;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=A$(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":E$,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 M$(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var R$=M$,O$=R$,Vg=Xv;function P$(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Vg(n),n=n===n?n:0),e!==void 0&&(e=Vg(e),e=e===e?e:0),O$(Vg(t),e,n)}var I$=P$;const Si=Ni(I$);var N$="__lodash_hash_undefined__";function D$(t){return this.__data__.set(t,N$),this}var _$=D$;function L$(t){return this.__data__.has(t)}var F$=L$,$$=$v,z$=_$,B$=F$;function bh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new $$;++e-1}var ez=Z$;function tz(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=bz){var u=e?null:wz(t);if(u)return xz(u);o=!1,i=vz,a=new gz}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?dE(l,e-1,n,r,i):Nz(i,l):r||(i[i.length]=l)}return i}var _z=dE,Lz=_z;function Fz(t){var e=t==null?0:t.length;return e?Lz(t,1):[]}var $z=Fz;const ib=Ni($z);var zz=Math.ceil,Bz=Math.max;function jz(t,e,n,r){for(var i=-1,s=Bz(zz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var Hz=jz,Wz=ST,Vz=Hv;function Uz(t){return t!=null&&Vz(t.length)&&!Wz(t)}var nw=Uz,Kz=Lv,Xz=nw,Gz=jv,qz=xl;function Yz(t,e,n){if(!qz(n))return!1;var r=typeof e;return(r=="number"?Xz(n)&&Gz(e,n.length):r=="string"&&e in n)?Kz(n[e],t):!1}var Qz=Yz,Jz=Xv,sb=1/0,Zz=17976931348623157e292;function eB(t){if(!t)return t===0?t:0;if(t=Jz(t),t===sb||t===-sb){var e=t<0?-1:1;return e*Zz}return t===t?t:0}var tB=eB,nB=Hz,rB=Qz,Kg=tB;function iB(t){return function(e,n,r){return r&&typeof r!="number"&&rB(e,n,r)&&(n=r=void 0),e=Kg(e),n===void 0?(n=e,e=0):n=Kg(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 hE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Cp(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 fB(t,e,n,r){if(r==="any")return mE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),YT([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 kh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Tp(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function mE(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 dB(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 hB(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 pB(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,E=h>=s&&hs&&y<=l||hl,R=p>=o&&po&&w<=a||pa;if(E&&R){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&&E){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&&C){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&&R){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(C&&R){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&&E){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(C&&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 gB={kind:Ce.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,C,T,E,R,O,_,P,I,D,Y,oe,le,V){let Z=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const M=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},B=[0,0],j=x>0?Sl(a,x,u):0;let $,ae;const he=hE(y);return Oo(e,l,s,o,i,(ve,Fe,De,Ze,Tt)=>{const et=Math.max(0,Ze-Fe),nt=Fe+et,st=i+1,_t=ve.width-et,Ie=r-i-1;if(y.length>0){let ot=!1;for(let mt=0;mt{t.save(),t.beginPath(),t.rect(nt,st,_t,Ie),t.clip()},Ne=k.columns.hasIndex(ve.sourceIndex),Ke=f(ve.group??"").overrideTheme,He=ve.themeOverride===void 0&&Ke===void 0?I:wo(I,Ke,ve.themeOverride),Be=He.baseFontFull;Be!==N&&(N=Be,t.font=Be),xe();let Ct;return Cp(Tt,De,r,a,u,x,g,he,(ot,mt,pe,_e,tt)=>{var me,ge,lt;if(mt<0||(B[0]=ve.sourceIndex,B[1]=mt,w!==void 0&&!w.has(B)))return;if(y.length>0){let Le=!1;for(let Rt=0;Rtft.span!==void 0&&Le>=ft.span[0]&&Le<=ft.span[1]);Rn&&!p&&m?On=0:Rn&&m&&(On=Math.max(On,1)),G&&On++,Rn||(Xe&&On++,Ne&&!tt&&On++);const be=ft.kind===Ce.Protected?Wt.bgCellMedium:Wt.bgCell;let J;if((_e||be!==I.bgCell)&&(J=Fr(be,J)),On>0||Ut){Ut&&(J=Fr(Wt.bgHeader,J));for(let Le=0;LeV&&!Mt){const Le=Wt.baseFontFull;Le!==N&&(t.font=Le,N=Le),Ct=yE(t,ft,ve.sourceIndex,mt,ne,Ge,ct,ot,yt,pe,On>0,Wt,J??Wt.bgCell,T,E,(W==null?void 0:W.hoverAmount)??0,O,P,M,_,Ct,D,Y,oe,le)}return ie&&t.restore(),ft.style==="faded"&&(t.globalAlpha=1),Z--,zt&&(t.restore(),(lt=Ct==null?void 0:Ct.deprep)==null||lt.call(Ct,L),Ct=void 0,xe(),N=Be,t.font=Be),Z<=0}),t.restore(),Z<=0}),$}const Su=[0,0],Cu={x:0,y:0,width:0,height:0},Xg=[void 0,()=>{}];let F0=!1;function mB(){F0=!0}function yE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,C,T,E){var Y,oe;let R,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(R=x[1][0],O=x[1][1]);let _;Su[0]=n,Su[1]=r,Cu.x=o,Cu.y=l,Cu.width=a,Cu.height=u,Xg[0]=C.getValue(Su),Xg[1]=le=>C.setValue(Su,le),F0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Cu,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:R,drawState:Xg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:R!==void 0?E:void 0,requestAnimationFrame:mB},I=m$(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((Y=k==null?void 0:k.deprep)==null||Y.call(k,P),k=void 0);const le=(oe=D.drawPrep)==null?void 0:oe.call(D,P,k);w!==void 0&&!oa(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=le===void 0?void 0:{deprep:le==null?void 0:le.deprep,fillStyle:le==null?void 0:le.fillStyle,font:le==null?void 0:le.font,renderer:D}}return(I||F0)&&(b==null||b(Su)),_}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=BT(c,o,e.cellVerticalPadding),x=m/2;const g=zT(f,r,s,e.cellHorizontalPadding,m),y=$T(g,h,m),w=jT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),is(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 ph:case!1:{t.beginPath(),is(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(),is(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:Ec()}}function yB(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])??[],C=f.headerFontFull;t.font=C,Oo(e,0,s,0,w,(T,E,R,O)=>{var L;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,O-E);t.save(),t.beginPath(),t.rect(E+_,l,T.width-_,o),t.clip();const P=m(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:wo(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),Y=a!==void 0||u,oe=!Y&&b===-1&&k===T.sourceIndex,le=Y?0:((L=h.find(B=>B.item[0]===T.sourceIndex&&B.item[1]===-1))==null?void 0:L.hoverAmount)??0,V=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,Z=D?I.accentColor:V?I.bgHeaderHasFocus:I.bgHeader,M=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=Z,t.fillRect(E+N,M,T.width-N,o)):(V||le>0)&&(t.beginPath(),t.rect(E+N,M,T.width-N,o),V&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),le>0&&(t.globalAlpha=le,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),xE(t,E,M,T.width,o,T,D,I,oe,V,le,d,g,y),t.restore()}),n&&vB(t,e,i,s,l,r,f,d,h,p,m,x)}function vB(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;pE(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 C=c(g),T=(C==null?void 0:C.overrideTheme)===void 0?o:wo(o,C.overrideTheme),E=p===-2&&h!==void 0&&h>=x[0]&&h<=x[1],R=E?T.bgHeaderHovered:T.bgHeader;if(R!==o.bgHeader&&(t.fillStyle=R,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,C!==void 0){let O=y;if(C.icon!==void 0&&(l.drawSprite(C.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(C.name,O+8,i/2+Ns(t,o.headerFontFull)),C.actions!==void 0&&E){const _=wE({x:y,y:w,width:k,height:b},C.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),Y=hl(R,0);D.addColorStop(0,Y),D.addColorStop(10/I,R),D.addColorStop(1,R),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[oe,le]=(s==null?void 0:s[1])??[-1,-1];for(let V=0;V35){const k=d?35:r-35,b=d?35*.7:r-35*.7,C=k/r,T=b/r,E=t.createLinearGradient(e,0,e+r,0),R=hl(m,0);E.addColorStop(d?1:0,m),E.addColorStop(C,m),E.addColorStop(T,R),E.addColorStop(d?0:1,R),t.fillStyle=E}else t.fillStyle=m;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+Ns(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===gh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;x$(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===gh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;w$(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 xE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=qv(s.title)==="rtl",m=vE(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 wB=bl,xB=function(){try{var t=wB(Object,"defineProperty");return t({},"",{}),t}catch{}}(),bB=xB,ab=bB;function kB(t,e,n){e=="__proto__"&&ab?ab(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var SB=kB;function CB(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&Pj?new Aj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const R=Math.max(b,T);R>r||(t.save(),t.beginPath(),t.rect(R,s+1,1e4,i-s-1),t.clip(),Cp(E,C,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(V=>kh(b,O,1e4,P,V.x,V.y,V.width,V.height)))return;const D=d.hasIndex(_),Y=h.hasIndex(_);t.beginPath();const oe=f==null?void 0:f(_),le=oe===void 0?y:wo(y,oe);le.bgCell!==y.bgCell&&(t.fillStyle=le.bgCell,t.fillRect(b,O,1e4,P)),Y&&(t.fillStyle=le.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=le.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function kW(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?Ia(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=Sl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const PE=(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 SW(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}=PE(l,s,o),k=[],b=o-Sl(h,d,u);let C=a,T=n,E=0;for(;C+i=y&&I<=w-1){const Y=c==null?void 0:c(T),oe=Y==null?void 0:Y.bgCell;oe!==void 0&&oe!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:oe})}C+=D,T0)for(let I=0;I=x&&Y<=g&&f(I+1)&&k.push({x:Y,y:E,w:D.width,h:O,color:oe}),R+=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:C,maxY:T}=PE(l,s,o),E=[];t.beginPath();let R=.5;for(let P=0;P=k&&D<=b&&h(P+1)&&E.push({x1:D,y1:Math.max(u,C),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=C&&Y<=T-1){const oe=d==null?void 0:d(I);E.push({x1:k,y1:Y,x2:b,y2:Y,color:(oe==null?void 0:oe.horizontalBorderColor)??(oe==null?void 0:oe.borderColor)??y})}P+=f(I),I++}}const _=xW(E,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 CW(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 C=0;if(typeof g=="number")C+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(C=-C),C+=a-i.translateY;const T=Math.min(i.cellXOffset,s),E=Math.max(i.cellXOffset,s);let R=0;for(let D=T;Di.cellXOffset&&(R=-R),R+=l-i.translateX;const O=Ia(x);if(R!==0&&C!==0)return{regions:[]};const _=u>0?Sl(d,u,g):0,P=c-O-Math.abs(R),I=f-h-_-Math.abs(C)-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(C>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(C+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:C+1})):C<0&&(D.sy=(-C+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+C-_,width:c,height:-C+_})),R>0?(D.sx=O*p,D.sw=P*p,D.dx=(R+O)*p,D.dw=P*p,w.push({x:O-1,y:0,width:R+2,height:f})):R<0&&(D.sx=(O-R)*p,D.sw=P*p,D.dx=O*p,D.dw=P*p,w.push({x:c+R,y:0,width:-R,height:f})),t.setTransform(1,0,0,1,0,0),y){if(O>0&&R!==0&&C===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Y=O*p,oe=f*p;t.drawImage(e,0,0,Y,oe,0,0,Y,oe)}if(_>0&&R===0&&C!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Y=(f-_)*p,oe=c*p,le=_*p;t.drawImage(e,0,Y,oe,le,0,Y,oe,le)}}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 TW(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||Oo(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 EW(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=Ia(l),y=Sl(h,d,f),w=[a,0,l.length,h-d],k=[g,0,e,n-y],b=x.map(T=>{const E=T.range,R=T.style??"dashed";return pB(E,w,e,n,k).map(O=>{const _=O.rect,P=_0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:_0(_.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:R,clip:O.clip,rect:hB({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),C=()=>{t.lineWidth=1;let T=!1;for(const E of b)for(const R of E)if((R==null?void 0:R.rect)!==void 0&&kh(0,0,e,n,R.rect.x,R.rect.y,R.rect.width,R.rect.height)){const O=T,_=!dB(R.clip,R.rect);_&&(t.save(),t.rect(R.clip.x,R.clip.y,R.clip.width,R.clip.height),t.clip()),R.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(R.style==="solid"||R.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=R.style==="solid-outline"?Fr(Fr(R.color,m.borderColor),m.bgCell):hl(R.color,1),t.strokeRect(R.rect.x+.5,R.rect.y+.5,R.rect.width-1,R.rect.height-1),_&&(t.restore(),T=O)}T&&t.setLineDash([])};return C(),C}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 Yg(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,C]=c.current.cell,T=d(c.current.cell),E=T.span??[b,b],R=C>=x-h,O=h>0&&!R?Sl(x,h,f)-1:0,_=w[1];let P;if(Oo(o,r,i,s,u,(D,Y,oe,le,V)=>{if(D.sticky&&b>D.sourceIndex)return;const Z=D.sourceIndexE[1],N=D.sourceIndex===w[0];if(!(!N&&(Z||M)))return Cp(V,oe,n,x,f,h,p,void 0,(L,B,j)=>{if(B!==C&&B!==_)return;let $=Y,ae=D.width;if(T.span!==void 0){const ve=gE(T.span,Y,L,D.width,j,D,l),Fe=D.sticky?ve[0]:ve[1];Fe!==void 0&&($=Fe.x,ae=Fe.width)}return B===_&&N&&m&&(P=()=>{var ve;le>$&&!D.sticky&&(t.beginPath(),t.rect(le,0,e-le,n),t.clip()),t.beginPath(),t.rect($+ae-4,L+j-4,4,4),t.fillStyle=((ve=D.themeOverride)==null?void 0:ve.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 AW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),pE(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)}),Oo(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 MW(t,e,n,r,i,s,o,l,a,u){let c=0;return Oo(t,s,r,i,n,(f,d,h,p,m)=>(Cp(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 ie;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:C,selection:T,fillHandle:E,freezeTrailingRows:R,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:Y,prelightCells:oe,drawCellCallback:le,highlightRegions:V,resizeCol:Z,imageLoader:M,lastBlitData:N,hoverValues:L,hyperWrapping:B,hoverInfo:j,spriteManager:$,maxScaleFactor:ae,hasAppendRow:he,touchMode:ve,enqueue:Fe,renderStateProvider:De,getCellRenderer:Ze,renderStrategy:Tt,bufferACtx:et,bufferBCtx:nt,damage:st,minimumCellWidth:_t}=t;if(i===0||s===0)return;const Ie=Tt==="double-buffer",xe=Math.min(ae,Math.ceil(window.devicePixelRatio??1)),Ne=Tt!=="direct"&&EW(t,e),Ke=n.canvas;(Ke.width!==i*xe||Ke.height!==s*xe)&&(Ke.width=i*xe,Ke.height=s*xe,Ke.style.width=i+"px",Ke.style.height=s+"px");const He=r.canvas,Be=f?g+x:x,Ct=Be+1;(He.width!==i*xe||He.height!==Ct*xe)&&(He.width=i*xe,He.height=Ct*xe,He.style.width=i+"px",He.style.height=Ct+"px");const ot=et.canvas,mt=nt.canvas;Ie&&(ot.width!==i*xe||ot.height!==s*xe)&&(ot.width=i*xe,ot.height=s*xe,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Ie&&(mt.width!==i*xe||mt.height!==s*xe)&&(mt.width=i*xe,mt.height=s*xe,N.current!==void 0&&(N.current.bBufferScroll=void 0));const pe=N.current;if(Ne===!0&&o===(pe==null?void 0:pe.cellXOffset)&&l===(pe==null?void 0:pe.cellYOffset)&&a===(pe==null?void 0:pe.translateX)&&u===(pe==null?void 0:pe.translateY))return;let _e=null;Ie&&(_e=n);const tt=r;let Xe;Ie?st!==void 0?Xe=(pe==null?void 0:pe.lastBuffer)==="b"?nt:et:Xe=(pe==null?void 0:pe.lastBuffer)==="b"?et:nt:Xe=n;const Ut=Xe.canvas,ft=Ie?Ut===ot?mt:ot:Ke,ct=typeof w=="number"?()=>w:w;tt.save(),Xe.save(),tt.beginPath(),Xe.beginPath(),tt.textBaseline="middle",Xe.textBaseline="middle",xe!==1&&(tt.scale(xe,xe),Xe.scale(xe,xe));const yt=D0(c,o,i,h,a);let zt=[];const Mt=m&&((ie=T.current)==null?void 0:ie.cell[1])===l&&u===0;let Mn=!1;if(V!==void 0){for(const ne of V)if(ne.style!=="no-outline"&&ne.range.y===l&&u===0){Mn=!0;break}}const zn=()=>{yB(tt,yt,f,j,i,a,x,g,h,C,T,p,$,L,k,P,st,Y,ve),Mb(tt,yt,l,a,u,i,s,void 0,void 0,g,Be,ct,I,k,R,O,p,!0),tt.beginPath(),tt.moveTo(0,Ct-.5),tt.lineTo(i,Ct-.5),tt.strokeStyle=Fr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),tt.stroke(),Mn&&Rb(tt,i,s,o,l,a,u,c,d,x,g,w,R,O,V,p),Mt&&Yg(tt,i,s,l,a,u,yt,c,p,Be,T,ct,_,R,he,E,O)};if(st!==void 0){const ne=yt[yt.length-1].sourceIndex+1,Ge=st.hasItemInRegion([{x:o,y:-2,width:ne,height:2},{x:o,y:l,width:ne,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-R,width:ne,height:R,when:R>0}]),W=me=>{ob(me,yt,c,s,Be,a,u,l,O,ct,_,P,I,y,D,m,R,he,zt,st,T,oe,V,M,$,L,j,le,B,p,Fe,De,Ze,b,_t);const ge=T.current;E&&m&&ge!==void 0&&st.has(QT(ge.range))&&Yg(me,i,s,l,a,u,yt,c,p,Be,T,ct,_,R,he,E,O)};Ge&&(W(Xe),_e!==null&&(_e.save(),_e.scale(xe,xe),_e.textBaseline="middle",W(_e),_e.restore()),st.hasHeader()&&(AW(tt,yt,i,g,Be,a,u,l,st),zn())),Xe.restore(),tt.restore();return}if((Ne!==!0||o!==(pe==null?void 0:pe.cellXOffset)||a!==(pe==null?void 0:pe.translateX)||Mt!==(pe==null?void 0:pe.mustDrawFocusOnHeader)||Mn!==(pe==null?void 0:pe.mustDrawHighlightRingsOnHeader))&&zn(),Ne===!0){Lr(ft!==void 0&&pe!==void 0);const{regions:ne}=CW(Xe,ft,ft===ot?pe.aBufferScroll:pe.bBufferScroll,ft===ot?pe.bBufferScroll:pe.aBufferScroll,pe,o,l,a,u,R,i,s,O,Be,xe,c,yt,w,Ie);zt=ne}else Ne!==!1&&(Lr(pe!==void 0),zt=TW(pe,o,l,a,u,i,s,Be,yt,Ne));kW(Xe,yt,i,s,R,O,k,ct,p);const Wt=Rb(Xe,i,s,o,l,a,u,c,d,x,g,w,R,O,V,p),Rn=m?Yg(Xe,i,s,l,a,u,yt,c,p,Be,T,ct,_,R,he,E,O):void 0;if(Xe.fillStyle=p.bgCell,zt.length>0){Xe.beginPath();for(const ne of zt)Xe.rect(ne.x,ne.y,ne.width,ne.height);Xe.clip(),Xe.fill(),Xe.beginPath()}else Xe.fillRect(0,0,i,s);const On=ob(Xe,yt,c,s,Be,a,u,l,O,ct,_,P,I,y,D,m,R,he,zt,st,T,oe,V,M,$,L,j,le,B,p,Fe,De,Ze,b,_t);bW(Xe,yt,c,i,s,Be,a,u,l,O,ct,I,T.rows,y,R,he,zt,st,p),SW(Xe,yt,l,a,u,i,s,zt,Be,ct,I,k,R,O,p),Mb(Xe,yt,l,a,u,i,s,zt,On,g,Be,ct,I,k,R,O,p),Wt==null||Wt(),Rn==null||Rn(),C&&Oo(yt,0,a,0,Be,(ne,Ge)=>ne.sourceIndex===Z?(Ob(tt,Ge+ne.width,0,Be+1,Fr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ob(Xe,Ge+ne.width,Be,s,Fr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),_e!==null&&(_e.fillStyle=p.bgCell,_e.fillRect(0,0,i,s),_e.drawImage(Xe.canvas,0,0));const G=MW(yt,s,Be,a,u,l,O,ct,R,he);M==null||M.setWindow({x:o,y:l,width:yt.length,height:G-l},d,Array.from({length:R},(ne,Ge)=>O-1-Ge));const be=pe!==void 0&&(o!==pe.cellXOffset||a!==pe.translateX),J=pe!==void 0&&(l!==pe.cellYOffset||u!==pe.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Mt,mustDrawHighlightRingsOnHeader:Mn,lastBuffer:Ie?Ut===ot?"a":"b":void 0,aBufferScroll:Ut===ot?[be,J]:pe==null?void 0:pe.aBufferScroll,bBufferScroll:Ut===mt?[be,J]:pe==null?void 0:pe.bBufferScroll},Xe.restore(),tt.restore()}const RW=80;function OW(t){const e=t-1;return e*e*e+1}class PW{constructor(e){vt(this,"callback");vt(this,"currentHoveredItem");vt(this,"leavingItems",[]);vt(this,"lastAnimationTime");vt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>Zu(r.item,e.item))||this.leavingItems.push(e)});vt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>Zu(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});vt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});vt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});vt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:OW(e.hoverAmount)})));vt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/RW;for(const s of this.leavingItems)s.hoverAmount=Si(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Si(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});vt(this,"setHovered",e=>{var n;if(!Zu((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 IW{constructor(e){vt(this,"fn");vt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function sw(t){return new IW(t)}const NW=sw(()=>window.navigator.userAgent.includes("Firefox")),Th=sw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Eh=sw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function DW(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 tc(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=Ci(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const qs="header",_r="group-header",Ah="out-of-bounds";var aa;(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"})(aa||(aa={}));function IE(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,_W=(t,e)=>{if(t.kind===Ce.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},LW=(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:C,onContextMenu:T,freezeTrailingRows:E,fixedShadowX:R=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:Y,onItemHovered:oe,dragAndDropState:le,firstColAccessible:V,onKeyDown:Z,onKeyUp:M,highlightRegions:N,canvasRef:L,onDragStart:B,onDragEnd:j,eventTargetRef:$,isResizing:ae,resizeColumn:he,isDragging:ve,isDraggable:Fe=!1,allowResize:De,disabledRows:Ze,hasAppendRow:Tt,getGroupDetails:et,theme:nt,prelightCells:st,headerIcons:_t,verticalBorder:Ie,drawCell:xe,drawHeader:Ne,onCellFocused:Ke,onDragOverCell:He,onDrop:Be,onDragLeave:Ct,imageWindowLoader:ot,smoothScrollX:mt=!1,smoothScrollY:pe=!1,experimental:_e,getCellRenderer:tt}=t,Xe=t.translateX??0,Ut=t.translateY??0,ft=Math.max(C,Math.min(s.length-1,o)),ct=v.useRef(null),yt=ot,zt=v.useRef(),[Mt,Mn]=v.useState(!1),zn=v.useRef([]),Wt=v.useRef(),[Rn,On]=v.useState(),[G,be]=v.useState(),J=v.useRef(null),[ie,ne]=v.useState(),[Ge,W]=v.useState(!1),me=v.useRef(Ge);me.current=Ge;const ge=v.useMemo(()=>new cB(_t,()=>{Li.current=void 0,No.current()}),[_t]),lt=x?c+a:a,Le=v.useRef(-1),Rt=((_e==null?void 0:_e.enableFirefoxRescaling)??!1)&&NW.value,Et=((_e==null?void 0:_e.enableSafariRescaling)??!1)&&Th.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!Rt&&!Et||(Le.current!==-1&&Mn(!0),window.clearTimeout(Le.current),Le.current=window.setTimeout(()=>{Mn(!1),Le.current=-1},200))},[l,ft,Xe,Ut,Rt,Et]);const ut=o$(s,C),cn=R?Ia(ut,le):0,Lt=v.useCallback((H,se,ke)=>{const ye=H.getBoundingClientRect();if(se>=ut.length||ke>=d)return;const ce=ye.width/n,Me=_0(se,ke,n,r,c,lt,ft,l,Xe,Ut,d,C,E,ut,f);return ce!==1&&(Me.x*=ce,Me.y*=ce,Me.width*=ce,Me.height*=ce),Me.x+=ye.x,Me.y+=ye.y,Me},[n,r,c,lt,ft,l,Xe,Ut,d,C,E,ut,f]),fn=v.useCallback((H,se,ke,ye)=>{const ce=H.getBoundingClientRect(),Me=ce.width/n,rt=(se-ce.left)/Me,it=(ke-ce.top)/Me,Ee=5,Dt=D0(ut,ft,n,void 0,Xe);let $e=0,$t=0;ye instanceof MouseEvent&&($e=ye.button,$t=ye.buttons);const at=c$(rt,Dt,Xe),xt=f$(it,r,x,a,c,d,f,l,Ut,E),yn=(ye==null?void 0:ye.shiftKey)===!0,dt=(ye==null?void 0:ye.ctrlKey)===!0,dn=(ye==null?void 0:ye.metaKey)===!0,Kr=ye!==void 0&&!(ye instanceof MouseEvent)||(ye==null?void 0:ye.pointerType)==="touch",sn=[rt<0?-1:nn||it>r){const Ot=rt>n?1:rt<0?-1:0,vn=it>r?1:it<0?-1:0;let Rr=Ot*2,Fi=vn*2;Ot===0&&(Rr=at===-1?aa.EndPadding:aa.Center),vn===0&&(Fi=xt===void 0?aa.EndPadding:aa.Center);let hi=!1;if(at===-1&&xt===-1){const _o=Lt(H,ut.length-1,-1);Lr(_o!==void 0),hi=se<_o.x+_o.width+Ee}const Dl=rt>n&&rtr&&it=0?(vn=!0,Ot=Lt(H,Rr,xt),Lr(Ot!==void 0),Mr={kind:x&&xt===-2?_r:qs,location:[Rr,xt],bounds:Ot,group:ut[Rr].group??"",isEdge:vn,shiftKey:yn,ctrlKey:dt,metaKey:dn,isTouch:Kr,localEventX:se-Ot.x,localEventY:ke-Ot.y,button:$e,buttons:$t,scrollEdge:sn}):Mr={kind:x&&xt===-2?_r:qs,group:ut[at].group??"",location:[at,xt],bounds:Ot,isEdge:vn,shiftKey:yn,ctrlKey:dt,metaKey:dn,isTouch:Kr,localEventX:se-Ot.x,localEventY:ke-Ot.y,button:$e,buttons:$t,scrollEdge:sn}}else{const Ot=Lt(H,at,xt);Lr(Ot!==void 0);const vn=Ot!==void 0&&Ot.x+Ot.width-se{}),Ds=v.useRef(Rn);Ds.current=Rn;const[cs,fs]=v.useMemo(()=>{const H=document.createElement("canvas"),se=document.createElement("canvas");return H.style.display="none",H.style.opacity="0",H.style.position="fixed",se.style.display="none",se.style.opacity="0",se.style.position="fixed",[H.getContext("2d",{alpha:!1}),se.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(cs===null||fs===null))return document.documentElement.append(cs.canvas),document.documentElement.append(fs.canvas),()=>{cs.canvas.remove(),fs.canvas.remove()}},[cs,fs]);const Cl=v.useMemo(()=>new b$,[]),sf=Rt&&Mt?1:Et&&Mt?2:5,of=(_e==null?void 0:_e.disableMinimumCellWidth)===!0?1:10,Li=v.useRef(),Tl=v.useRef(null),El=v.useRef(null),Al=v.useCallback(()=>{var rt;const H=ct.current,se=J.current;if(H===null||se===null||(Tl.current===null&&(Tl.current=H.getContext("2d",{alpha:!1}),H.width=0,H.height=0),El.current===null&&(El.current=se.getContext("2d",{alpha:!1}),se.width=0,se.height=0),Tl.current===null||El.current===null||cs===null||fs===null))return;let ke=!1;const ye=it=>{ke=!0,ne(it)},ce=Li.current,Me={headerCanvasCtx:El.current,canvasCtx:Tl.current,bufferACtx:cs,bufferBCtx:fs,width:n,height:r,cellXOffset:ft,cellYOffset:l,translateX:Math.round(Xe),translateY:Math.round(Ut),mappedColumns:ut,enableGroups:x,freezeColumns:C,dragAndDropState:le,theme:nt,headerHeight:a,groupHeaderHeight:c,disabledRows:Ze??Pt.empty(),rowHeight:f,verticalBorder:Ie,isResizing:ae,resizeCol:he,isFocused:k,selection:b,fillHandle:u,drawCellCallback:xe,hasAppendRow:Tt,overrideCursor:ye,maxScaleFactor:sf,freezeTrailingRows:E,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:et??(it=>({name:it})),getRowThemeOverride:p,drawHeaderCallback:Ne,prelightCells:st,highlightRegions:N,imageLoader:yt,lastBlitData:Wt,damage:zt.current,hoverValues:zn.current,hoverInfo:Ds.current,spriteManager:ge,scrolling:Mt,hyperWrapping:(_e==null?void 0:_e.hyperWrapping)??!1,touchMode:Ge,enqueue:rf.current,renderStateProvider:Cl,renderStrategy:(_e==null?void 0:_e.renderStrategy)??(Th.value?"double-buffer":"single-buffer"),getCellRenderer:tt,minimumCellWidth:of};Me.damage===void 0?(Li.current=Me,Pb(Me,ce)):Pb(Me,void 0),!ke&&(Me.damage===void 0||Me.damage.has((rt=Ds==null?void 0:Ds.current)==null?void 0:rt[0]))&&ne(void 0)},[cs,fs,n,r,ft,l,Xe,Ut,ut,x,C,le,nt,a,c,Ze,f,Ie,ae,Tt,he,k,b,u,E,d,_,sf,h,et,p,xe,Ne,st,N,yt,ge,Mt,_e==null?void 0:_e.hyperWrapping,_e==null?void 0:_e.renderStrategy,Ge,Cl,tt,of]),No=v.useRef(Al);v.useLayoutEffect(()=>{Al(),No.current=Al},[Al]),v.useLayoutEffect(()=>{(async()=>{var se;((se=document==null?void 0:document.fonts)==null?void 0:se.ready)!==void 0&&(await document.fonts.ready,Li.current=void 0,No.current())})()},[]);const _s=v.useCallback(H=>{zt.current=H,No.current(),zt.current=void 0},[]),lf=DW(_s);rf.current=lf;const af=v.useCallback(H=>{_s(new tc(H.map(se=>se.cell)))},[_s]);yt.setCallback(_s);const[Bp,jp]=v.useState(!1),[Ml,ds]=Kt??[],Hp=Ml!==void 0&&ds===-1,Wp=Ml!==void 0&&ds===-2;let uf=!1,Rl=!1,Tn=ie;if(Tn===void 0&&Ml!==void 0&&ds!==void 0&&ds>-1&&ds({contain:"strict",display:"block",cursor:cf}),[cf]),eu=v.useRef("default"),Ls=$==null?void 0:$.current;Ls!=null&&eu.current!==Ol.cursor&&(Ls.style.cursor=eu.current=Ol.cursor);const Er=v.useCallback((H,se,ke,ye)=>{if(et===void 0)return;const ce=et(H);if(ce.actions!==void 0){const Me=wE(se,ce.actions);for(const[rt,it]of Me.entries())if(Tp(it,ke+se.x,ye+it.y))return ce.actions[rt]}},[et]),ci=v.useCallback((H,se,ke,ye)=>{const ce=s[se];if(!ve&&!ae&&ce.hasMenu===!0&&!(G??!1)){const Me=Lt(H,se,-1);Lr(Me!==void 0);const rt=vE(Me.x,Me.y,Me.width,Me.height,qv(ce.title)==="rtl");if(ke>rt.x&&kert.y&&ye{const se=ct.current,ke=$==null?void 0:$.current;if(se===null||H.target!==se&&H.target!==ke)return;nu.current=!0;let ye,ce;if(H instanceof MouseEvent?(ye=H.clientX,ce=H.clientY):(ye=H.touches[0].clientX,ce=H.touches[0].clientY),H.target===ke&&ke!==null){const rt=ke.getBoundingClientRect();if(ye>rt.right||ce>rt.bottom)return}const Me=fn(se,ye,ce,H);Fs.current=Me.location,Me.isTouch&&(tu.current=Date.now()),me.current!==Me.isTouch&&W(Me.isTouch),!(Me.kind===qs&&ci(se,Me.location[0],ye,ce)!==void 0)&&(Me.kind===_r&&Er(Me.group,Me.bounds,Me.localEventX,Me.localEventY)!==void 0||(P==null||P(Me),!Me.isTouch&&Fe!==!0&&Fe!==Me.kind&&Me.button<3&&Me.button!==1&&H.preventDefault()))},[$,Fe,fn,Er,ci,P]);jn("touchstart",ir,window,!1),jn("mousedown",ir,window,!1);const Pl=v.useRef(0),ru=v.useCallback(H=>{var $t,at;const se=Pl.current;Pl.current=Date.now();const ke=ct.current;if(nu.current=!1,I===void 0||ke===null)return;const ye=$==null?void 0:$.current,ce=H.target!==ke&&H.target!==ye;let Me,rt,it=!0;if(H instanceof MouseEvent){if(Me=H.clientX,rt=H.clientY,it=H.button<3,H.pointerType==="touch")return}else Me=H.changedTouches[0].clientX,rt=H.changedTouches[0].clientY;let Ee=fn(ke,Me,rt,H);Ee.isTouch&&tu.current!==0&&Date.now()-tu.current>500&&(Ee={...Ee,isLongTouch:!0}),se!==0&&Date.now()-se<(Ee.isTouch?1e3:500)&&(Ee={...Ee,isDoubleClick:!0}),me.current!==Ee.isTouch&&W(Ee.isTouch),!ce&&H.cancelable&&it&&H.preventDefault();const[Dt]=Ee.location,$e=ci(ke,Dt,Me,rt);if(Ee.kind===qs&&$e!==void 0){(Ee.button!==0||(($t=Fs.current)==null?void 0:$t[0])!==Dt||((at=Fs.current)==null?void 0:at[1])!==-1)&&I(Ee,!0);return}else if(Ee.kind===_r){const xt=Er(Ee.group,Ee.bounds,Ee.localEventX,Ee.localEventY);if(xt!==void 0){Ee.button===0&&xt.onClick(Ee);return}}I(Ee,ce)},[I,$,fn,ci,Er]);jn("mouseup",ru,window,!1),jn("touchend",ru,window,!1);const ff=v.useCallback(H=>{var $e,$t;const se=ct.current;if(se===null)return;const ke=$==null?void 0:$.current,ye=H.target!==se&&H.target!==ke;let ce,Me,rt=!0;H instanceof MouseEvent?(ce=H.clientX,Me=H.clientY,rt=H.button<3):(ce=H.changedTouches[0].clientX,Me=H.changedTouches[0].clientY);const it=fn(se,ce,Me,H);me.current!==it.isTouch&&W(it.isTouch),!ye&&H.cancelable&&rt&&H.preventDefault();const[Ee]=it.location,Dt=ci(se,Ee,ce,Me);if(it.kind===qs&&Dt!==void 0)it.button===0&&(($e=Fs.current)==null?void 0:$e[0])===Ee&&(($t=Fs.current)==null?void 0:$t[1])===-1&&(m==null||m(Ee,Dt));else if(it.kind===_r){const at=Er(it.group,it.bounds,it.localEventX,it.localEventY);at!==void 0&&it.button===0&&at.onClick(it)}},[$,fn,ci,m,Er]);jn("click",ff,window,!1);const Vp=v.useCallback(H=>{const se=ct.current,ke=$==null?void 0:$.current;if(se===null||H.target!==se&&H.target!==ke||T===void 0)return;const ye=fn(se,H.clientX,H.clientY,H);T(ye,()=>{H.cancelable&&H.preventDefault()})},[$,fn,T]);jn("contextmenu",Vp,($==null?void 0:$.current)??null,!1);const df=v.useCallback(H=>{zt.current=new tc(H.map(se=>se.item)),zn.current=H,No.current(),zt.current=void 0},[]),fi=v.useMemo(()=>new PW(df),[df]),hs=v.useRef(fi);hs.current=fi,v.useLayoutEffect(()=>{const H=hs.current;if(Kt===void 0||Kt[1]<0){H.setHovered(Kt);return}const se=h(Kt,!0),ke=tt(se),ye=ke===void 0&&se.kind===Ce.Custom||(ke==null?void 0:ke.needsHover)!==void 0&&(typeof ke.needsHover=="boolean"?ke.needsHover:ke.needsHover(se));H.setHovered(ye?Kt:void 0)},[h,tt,Kt]);const Ar=v.useRef(),X=v.useCallback(H=>{var it;const se=ct.current;if(se===null)return;const ke=$==null?void 0:$.current,ye=H.target!==se&&H.target!==ke,ce=fn(se,H.clientX,H.clientY,H);if(ce.kind!=="out-of-bounds"&&ye&&!nu.current&&!ce.isTouch)return;const Me=(Ee,Dt)=>{On($e=>$e===Ee||($e==null?void 0:$e[0][0])===(Ee==null?void 0:Ee[0][0])&&($e==null?void 0:$e[0][1])===(Ee==null?void 0:Ee[0][1])&&(($e==null?void 0:$e[1][0])===(Ee==null?void 0:Ee[1][0])&&($e==null?void 0:$e[1][1])===(Ee==null?void 0:Ee[1][1])||!Dt)?$e:Ee)};if(!IE(ce,Ar.current))ne(void 0),oe==null||oe(ce),Me(ce.kind===Ah?void 0:[ce.location,[ce.localEventX,ce.localEventY]],!0),Ar.current=ce;else if(ce.kind==="cell"||ce.kind===qs||ce.kind===_r){let Ee=!1,Dt=!0;if(ce.kind==="cell"){const $t=h(ce.location);Dt=((it=tt($t))==null?void 0:it.needsHoverPosition)??$t.kind===Ce.Custom,Ee=Dt}else ce.kind===_r&&(Ee=!0);const $e=[ce.location,[ce.localEventX,ce.localEventY]];Me($e,Dt),Ds.current=$e,Ee&&_s(new tc([ce.location]))}const rt=ce.location[0]>=(V?0:1);be(ce.kind===qs&&ce.isEdge&&rt&&De===!0),jp(ce.kind==="cell"&&ce.isFillHandle),D==null||D(H),Y(ce)},[$,fn,V,De,D,Y,oe,h,tt,_s]);jn("mousemove",X,window,!0);const rn=v.useCallback(H=>{const se=ct.current;if(se===null)return;let ke,ye;b.current!==void 0&&(ke=Lt(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),Z==null||Z({bounds:ke,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:ye})},[Z,b,Lt]),Do=v.useCallback(H=>{const se=ct.current;if(se===null)return;let ke,ye;b.current!==void 0&&(ke=Lt(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),M==null||M({bounds:ke,stopPropagation:()=>H.stopPropagation(),preventDefault:()=>H.preventDefault(),cancel:()=>{},ctrlKey:H.ctrlKey,metaKey:H.metaKey,shiftKey:H.shiftKey,altKey:H.altKey,key:H.key,keyCode:H.keyCode,rawEvent:H,location:ye})},[M,b,Lt]),Up=v.useCallback(H=>{ct.current=H,L!==void 0&&(L.current=H)},[L]),hf=v.useCallback(H=>{const se=ct.current;if(se===null||Fe===!1||ae){H.preventDefault();return}let ke,ye;const ce=fn(se,H.clientX,H.clientY);if(Fe!==!0&&ce.kind!==Fe){H.preventDefault();return}const Me=($t,at)=>{ke=$t,ye=at};let rt,it,Ee;const Dt=($t,at,xt)=>{rt=$t,it=at,Ee=xt};let $e=!1;if(B==null||B({...ce,setData:Me,setDragImage:Dt,preventDefault:()=>$e=!0,defaultPrevented:()=>$e}),!$e&&ke!==void 0&&ye!==void 0&&H.dataTransfer!==null)if(H.dataTransfer.setData(ke,ye),H.dataTransfer.effectAllowed="copyLink",rt!==void 0&&it!==void 0&&Ee!==void 0)H.dataTransfer.setDragImage(rt,it,Ee);else{const[$t,at]=ce.location;if(at!==void 0){const xt=document.createElement("canvas"),yn=Lt(se,$t,at);Lr(yn!==void 0);const dt=Math.ceil(window.devicePixelRatio??1);xt.width=yn.width*dt,xt.height=yn.height*dt;const dn=xt.getContext("2d");dn!==null&&(dn.scale(dt,dt),dn.textBaseline="middle",at===-1?(dn.font=nt.headerFontFull,dn.fillStyle=nt.bgHeader,dn.fillRect(0,0,xt.width,xt.height),xE(dn,0,0,yn.width,yn.height,ut[$t],!1,nt,!1,!1,0,ge,Ne,!1)):(dn.font=nt.baseFontFull,dn.fillStyle=nt.bgCell,dn.fillRect(0,0,xt.width,xt.height),yE(dn,h([$t,at]),0,at,!1,!1,0,0,yn.width,yn.height,!1,nt,nt.bgCell,yt,ge,1,void 0,!1,0,void 0,void 0,void 0,Cl,tt,()=>{}))),xt.style.left="-100%",xt.style.position="absolute",xt.style.width=`${yn.width}px`,xt.style.height=`${yn.height}px`,document.body.append(xt),H.dataTransfer.setDragImage(xt,yn.width/2,yn.height/2),window.setTimeout(()=>{xt.remove()},0)}}else H.preventDefault()},[Fe,ae,fn,B,Lt,nt,ut,ge,Ne,h,yt,Cl,tt]);jn("dragstart",hf,($==null?void 0:$.current)??null,!1,!1);const iu=v.useRef(),Kp=v.useCallback(H=>{const se=ct.current;if(Be!==void 0&&H.preventDefault(),se===null||He===void 0)return;const ke=fn(se,H.clientX,H.clientY),[ye,ce]=ke.location,Me=ye-(V?0:1),[rt,it]=iu.current??[];(rt!==Me||it!==ce)&&(iu.current=[Me,ce],He([Me,ce],H.dataTransfer))},[V,fn,He,Be]);jn("dragover",Kp,($==null?void 0:$.current)??null,!1,!1);const Lw=v.useCallback(()=>{iu.current=void 0,j==null||j()},[j]);jn("dragend",Lw,($==null?void 0:$.current)??null,!1,!1);const Q=v.useCallback(H=>{const se=ct.current;if(se===null||Be===void 0)return;H.preventDefault();const ke=fn(se,H.clientX,H.clientY),[ye,ce]=ke.location,Me=ye-(V?0:1);Be([Me,ce],H.dataTransfer)},[V,fn,Be]);jn("drop",Q,($==null?void 0:$.current)??null,!1,!1);const Kn=v.useCallback(()=>{Ct==null||Ct()},[Ct]);jn("dragleave",Kn,($==null?void 0:$.current)??null,!1,!1);const En=v.useRef(b);En.current=b;const Il=v.useRef(null),su=v.useCallback(H=>{var se;ct.current===null||!ct.current.contains(document.activeElement)||(H===null&&En.current.current!==void 0?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):H!==null&&H.focus({preventScroll:!0}),Il.current=H)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var se;const H=Il.current;H===null||!document.contains(H)?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):H.focus({preventScroll:!0})},getBounds:(H,se)=>{if(!(L===void 0||L.current===null))return Lt(L.current,H??0,se??-1)},damage:af}),[L,af,Lt]);const $s=v.useRef(),pr=T4(()=>{var it,Ee,Dt;if(n<50||(_e==null?void 0:_e.disableAccessibilityTree)===!0)return null;let H=D0(ut,ft,n,le,Xe);const se=V?0:-1;!V&&((it=H[0])==null?void 0:it.sourceIndex)===0&&(H=H.slice(1));const[ke,ye]=((Ee=b.current)==null?void 0:Ee.cell)??[],ce=(Dt=b.current)==null?void 0:Dt.range,Me=H.map($e=>$e.sourceIndex),rt=Yo(l,Math.min(d,l+i));return ke!==void 0&&ye!==void 0&&!(Me.includes(ke)&&rt.includes(ye))&&su(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":ut.length+se},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},H.map($e=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex($e.sourceIndex),"aria-colindex":$e.sourceIndex+1+se,tabIndex:-1,onFocus:$t=>{if($t.target!==Il.current)return Ke==null?void 0:Ke([$e.sourceIndex,-1])},key:$e.sourceIndex},$e.title)))),v.createElement("tbody",{role:"rowgroup"},rt.map($e=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex($e),key:$e,"aria-rowindex":$e+2},H.map($t=>{const at=$t.sourceIndex,xt=Ci(at,$e),yn=ke===at&&ye===$e,dt=ce!==void 0&&at>=ce.x&&at=ce.y&&$e{const Mr=L==null?void 0:L.current;if(Mr!=null)return Z==null?void 0:Z({bounds:Lt(Mr,at,$e),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Kr})},onFocusCapture:Mr=>{var Ot,vn;if(!(Mr.target===Il.current||((Ot=$s.current)==null?void 0:Ot[0])===at&&((vn=$s.current)==null?void 0:vn[1])===$e))return $s.current=Kr,Ke==null?void 0:Ke(Kr)},ref:yn?su:void 0,tabIndex:-1},_W(sn,tt))})))))},[n,ut,ft,le,Xe,d,l,i,b,su,h,L,Z,Lt,Ke],200),di=C===0||!R?0:ft>C?1:Si(-Xe/100,0,1),Xp=-l*32+Ut,Nl=O?Si(-Xp/100,0,1):0,Gp=v.useMemo(()=>{if(!di&&!Nl)return null;const H={position:"absolute",top:0,left:cn,width:n-cn,height:r,opacity:di,pointerEvents:"none",transition:mt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},se={position:"absolute",top:lt,left:0,width:n,height:r,opacity:Nl,pointerEvents:"none",transition:pe?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,di>0&&v.createElement("div",{id:"shadow-x",style:H}),Nl>0&&v.createElement("div",{id:"shadow-y",style:se}))},[di,Nl,cn,n,mt,lt,r,pe]),qp=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:rn,onKeyUp:Do,onFocus:y,onBlur:w,ref:Up,style:Ol},pr),v.createElement("canvas",{ref:J,style:qp}),Gp)},FW=v.memo(v.forwardRef(LW));function Tu(t,e,n,r){return Si(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const $W=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:C,onColumnMoved:T,onColumnResize:E,onColumnResizeStart:R,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:Y,onColumnProposeMove:oe,onMouseDown:le,onMouseUp:V,onItemHovered:Z,onDragStart:M,canvasRef:N}=t,L=(E??O??R)!==void 0,{columns:B,selection:j}=t,$=j.columns,ae=v.useCallback(Ie=>{const[xe,Ne]=Ie.location;s!==void 0&&l!==xe&&xe>=Y?(c(!0),a(xe)):h!==void 0&&Ne!==void 0?(y(!0),x(Math.max(0,Ne))):r===void 0&&!u&&!g&&(Z==null||Z(Ie))},[s,h,l,Z,Y,r,u,g]),he=T!==void 0,ve=v.useCallback(Ie=>{var xe;if(Ie.button===0){const[Ne,Ke]=Ie.location;if(Ie.kind==="out-of-bounds"&&Ie.isEdge&&L){const He=(xe=_==null?void 0:_.current)==null?void 0:xe.getBounds(B.length-1,-1);He!==void 0&&(n(He.x),i(B.length-1))}else if(Ie.kind==="header"&&Ne>=Y){const He=N==null?void 0:N.current;if(Ie.isEdge&&L&&He){n(Ie.bounds.x),i(Ne);const Ct=He.getBoundingClientRect().width/He.offsetWidth,ot=Ie.bounds.width/Ct;R==null||R(B[Ne],ot,Ne,ot+(B[Ne].growOffset??0))}else Ie.kind==="header"&&he&&(d(Ie.bounds.x),o(Ne))}else Ie.kind==="cell"&&Y>0&&Ne===0&&Ke!==void 0&&D!==void 0&&(k(Ie.bounds.y),p(Ke))}le==null||le(Ie)},[le,L,Y,D,_,B,he,R,N]),Fe=v.useCallback((Ie,xe)=>{u||g||b==null||b(Ie,xe)},[u,g,b]),De=v.useRef(-1),Ze=v.useCallback(()=>{De.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)},[]),Tt=v.useCallback((Ie,xe)=>{if(Ie.button===0){if(r!==void 0){if(($==null?void 0:$.hasIndex(r))===!0)for(const Ke of $){if(Ke===r)continue;const He=B[Ke],Be=Tu(He,De.current,I,P);E==null||E(He,Be,Ke,Be+(He.growOffset??0))}const Ne=Tu(B[r],De.current,I,P);if(O==null||O(B[r],Ne,r,Ne+(B[r].growOffset??0)),$.hasIndex(r))for(const Ke of $){if(Ke===r)continue;const He=B[Ke],Be=Tu(He,De.current,I,P);O==null||O(He,Be,Ke,Be+(He.growOffset??0))}}Ze(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}V==null||V(Ie,xe)},[V,r,s,l,h,m,$,O,B,I,P,E,T,D,Ze]),et=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(oe==null?void 0:oe(s,l))!==!1)return{src:s,dest:l}},[s,l,oe]),nt=v.useCallback(Ie=>{const xe=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Ie.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Ie.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&xe){const Ke=xe.getBoundingClientRect().width/xe.offsetWidth,He=(Ie.clientX-e)/Ke,Be=B[r],Ct=Tu(Be,He,I,P);if(E==null||E(Be,Ct,r,Ct+(Be.growOffset??0)),De.current=He,($==null?void 0:$.first())===r)for(const ot of $){if(ot===r)continue;const mt=B[ot],pe=Tu(mt,De.current,I,P);E==null||E(mt,pe,ot,pe+(mt.growOffset??0))}}},[s,f,h,w,r,e,B,I,P,E,$,N]),st=v.useCallback((Ie,xe)=>{if(h===void 0||m===void 0)return C(Ie,xe);let[Ne,Ke]=Ie;return Ke===m?Ke=h:(Ke>m&&(Ke-=1),Ke>=h&&(Ke+=1)),C([Ne,Ke],xe)},[h,m,C]),_t=v.useCallback(Ie=>{M==null||M(Ie),Ie.defaultPrevented()||Ze()},[Ze,M]);return v.createElement(FW,{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:st,isResizing:r!==void 0,onHeaderMenuClick:Fe,isDragging:u,onItemHovered:ae,onDragStart:_t,onMouseDown:ve,allowResize:L,onMouseUp:Tt,dragAndDropState:et,onMouseMoveRaw:nt,ref:_})};function zW(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 BW=(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])},jW=()=>t=>t.isSafari?"scroll":"auto",HW=Vr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[jW()]}});function WW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return jn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),jn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const VW=t=>{var B,j;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),C=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),E=v.useRef(null),R=WW(200),[O,_]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||R||T.current.lockDirection===void 0)return;const $=b.current;if($===null)return;const[ae,he]=T.current.lockDirection;ae!==void 0?$.scrollLeft=ae:he!==void 0&&($.scrollTop=he),T.current.lockDirection=void 0},[R,O]);const I=v.useCallback(($,ae)=>{var xe;const he=b.current;if(he===null)return;ae=ae??he.scrollTop,$=$??he.scrollLeft;const ve=T.current.scrollTop,Fe=T.current.scrollLeft,De=$-Fe,Ze=ae-ve;R&&De!==0&&Ze!==0&&(Math.abs(De)>3||Math.abs(Ze)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(De)0&&(Math.abs(_t)>2e3||st===0||st===Ie)&&r>he.scrollHeight+5){const Ne=st/Ie,Ke=(r-nt)*Ne;w.current=Ke-st}Tt!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:$,y:st+w.current,width:et-c,height:nt-u,paddingRight:((xe=E.current)==null?void 0:xe.clientWidth)??0})},[u,c,r,s,a,R]);BW(h&&Th.value,I,b);const D=v.useRef(I);D.current=I;const Y=v.useRef(),oe=v.useRef(!1);v.useLayoutEffect(()=>{oe.current?I():oe.current=!0},[I,u,c]);const le=v.useCallback($=>{b.current=$,p!==void 0&&(p.current=$)},[p]);let V=0,Z=0;for(x.push(v.createElement("div",{key:V++,style:{width:i,height:0}}));ZD.current(),0),Y.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:M}):v.createElement("div",{ref:M},v.createElement(HW,{isSafari:Th.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:le,style:Y.current,draggable:o,onDragStart:$=>{o||($.stopPropagation(),$.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:E,style:{height:L,maxHeight:n-Math.ceil(C%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))))))},UW=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:C}=t,{paddingRight:T,paddingBottom:E}=a??{},[R,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),Y=u+Math.max(0,g??0);let oe=o?i+s:i;if(typeof r=="number")oe+=n*r;else for(let M=0;M{var Ze,Tt;if(le.current===void 0)return;const M={...le.current};let N=0,L=M.x<0?-M.x:0,B=0,j=0;M.x=M.x<0?0:M.x;let $=0;for(let et=0;et=nt+et.width)N+=et.width,j++,B++;else if(M.x>nt)N+=et.width,k?L+=nt-M.x:j++,B++;else if(M.x+M.width>nt)N+=et.width,B++;else break}let ae=0,he=0,ve=0;if(typeof r=="number")b?(he=Math.floor(M.y/r),ae=he*r-M.y):he=Math.ceil(M.y/r),ve=Math.ceil(M.height/r)+he,ae<0&&ve++;else{let et=0;for(let nt=0;nt=et+st)et+=st,he++,ve++;else if(M.y>_t)et+=st,b?ae+=_t-M.y:he++,ve++;else if(M.y+M.height>st/2+et)et+=st,ve++;else break}}const Fe={x:j,y:he,width:B-j,height:ve-he},De=_.current;(De===void 0||De.y!==Fe.y||De.x!==Fe.x||De.height!==Fe.height||De.width!==Fe.width||P.current!==L||I.current!==ae||M.width!==((Ze=D.current)==null?void 0:Ze[0])||M.height!==((Tt=D.current)==null?void 0:Tt[1]))&&(d==null||d({x:j,y:he,width:B-j,height:ve-he},M.width,M.height,M.paddingRight??0,L,ae),_.current=Fe,P.current=L,I.current=ae,D.current=[M.width,M.height])},[e,r,n,d,l,k,b]),Z=v.useCallback(M=>{le.current=M,V()},[V]);return v.useEffect(()=>{V()},[V]),v.createElement(VW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:C===!0||typeof C=="string",scrollWidth:Y+(T??0),scrollHeight:oe+(E??0),clientHeight:O,rightElement:m,paddingBottom:E,paddingRight:T,rightElementProps:x,update:Z,initialSize:w},v.createElement($W,{eventTargetRef:h,width:R,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}))},KW=Vr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),XW=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"})),GW=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"})),YW=10,QW=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 C=v.useRef(),[T,E]=v.useState([]),R=l??T,O=v.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.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 B=_.current,j=Math.min(10,r),$=0;w(void 0),E([]);const ae=[],he=async()=>{var Ie;if(u===void 0)return;const ve=performance.now(),Fe=r-$;let De=u({x:0,y:B,width:i.length,height:Math.min(j,Fe,r-B)},b.current.signal);typeof De=="function"&&(De=await De());let Ze=!1;for(const[xe,Ne]of De.entries())for(const[Ke,He]of Ne.entries()){let Be;switch(He.kind){case Ce.Text:case Ce.Number:Be=He.displayData;break;case Ce.Uri:case Ce.Markdown:Be=He.data;break;case Ce.Boolean:Be=typeof He.data=="boolean"?He.data.toString():void 0;break;case Ce.Image:case Ce.Bubble:Be=He.data.join("🐳");break;case Ce.Custom:Be=He.copyData;break}Be!==void 0&&L.test(Be)&&(ae.push([Ke,xe+B]),Ze=!0)}const Tt=performance.now();Ze&&E([...ae]),$+=De.length,Lr($<=r);const et=((Ie=k.current)==null?void 0:Ie.selectedIndex)??-1;w({results:ae.length,rowsSearched:$,selectedIndex:et}),c==null||c(ae,et),B+j>=r?B=0:B+=j;const nt=Tt-ve,st=Math.max(nt,1),_t=YW/st;j=Math.ceil(j*_t),${var N;d==null||d(),w(void 0),E([]),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),E([]),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 Y=v.useCallback(N=>{var B;if((B=N==null?void 0:N.stopPropagation)==null||B.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(R,L)},[y,c,R]),oe=v.useCallback(N=>{var B;if((B=N==null?void 0:N.stopPropagation)==null||B.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(R,L)},[c,R,y]),le=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?oe():Y())},[I,Y,oe]);v.useEffect(()=>()=>{O()},[O]);const[V,Z]=v.useState(!1);v.useEffect(()=>{if(f)Z(!0);else{const N=setTimeout(()=>Z(!1),150);return()=>clearTimeout(N)}},[f]);const M=v.useMemo(()=>{if(!f&&!V)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=$=>{$.stopPropagation()},j={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(KW,{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:le}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:oe,disabled:((y==null?void 0:y.results)??0)===0},XW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Y,disabled:((y==null?void 0:y.results)??0)===0},GW),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:j})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,V,y,r,h,s,D,x,le,oe,Y,d,I]);return v.createElement(v.Fragment,null,v.createElement(UW,{prelightCells:R,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}),M)};class JW extends v.PureComponent{constructor(){super(...arguments);vt(this,"wrapperRef",v.createRef());vt(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 ZW=()=>t=>Math.max(16,t.targetHeight-10),e6=Vr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[ZW(),"px"]}}),t6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Nn.useState(n);return Nn.createElement(JW,{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},Nn.createElement(e6,{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 n6(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 pt(t,e,n){const r=NE(t,e);return r&&(n.didMatch=!0),r}function NE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(NE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!n6(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":Eh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function r6(t,e,n,r,i,s){const o=Nn.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:Pt.empty(),rows:m?t.rows:Pt.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=Nn.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:Pt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Pt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Nn.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:Pt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Pt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function i6(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:Ce.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:Ce.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Ce.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function s6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Ce.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Wv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Ce.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Ce.Image:case Ce.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Ce.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Ce.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Ce.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Ce.Markdown:case Ce.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Ce.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Ce.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Ce.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Ec()}}function o6(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"}:s6(o))})}function Nb(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function l6(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 Qg(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 a6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function u6(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("
${Qg(i.formatted)}
    ${i.formatted.map((o,l)=>`
  1. `+Qg(o)+"
  2. ").join("")}
${Qg(i.formatted)}
"),e.join("")}function c6(t,e){const n=o6(t,e),r=l6(n),i=u6(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:a6(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 f6(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 d6(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(Nb(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 Db(t,e,n){var l;const r=l6(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 PE(t){return t!==!0}function _b(t){return typeof t=="string"?t:`${t}px`}const c6=()=>t=>t.innerWidth,f6=()=>t=>t.innerHeight,d6=Vr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[c6()],"wmyidgi-1":[f6()]}}),h6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(d6,{innerHeight:_b(n),innerWidth:_b(e),...i},r)},p6=2,g6=1300;function m6(t,e,n){const r=Nn.useRef(0),[i,s]=t??[0,0];Nn.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/g6);const d=r.current**1.618*f*p6;(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 y6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Nn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=nE();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 Ks={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 yt(t,e){return t===!0?e:t===!1?"":t}function Lb(t){const e=Sh.value;return{activateCell:yt(t.activateCell," |Enter|shift+Enter"),clear:yt(t.clear,"any+Escape"),closeOverlay:yt(t.closeOverlay,"any+Escape"),acceptOverlayDown:yt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:yt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:yt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:yt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:yt(t.delete,e?"Backspace|Delete":"Delete"),downFill:yt(t.downFill,"primary+_68"),scrollToSelectedCell:yt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:yt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:yt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:yt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:yt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:yt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:yt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:yt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:yt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:yt(t.goToFirstCell,"primary+Home"),goToFirstColumn:yt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:yt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:yt(t.goToLastCell,"primary+End"),goToLastColumn:yt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:yt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:yt(t.goToNextPage,"PageDown"),goToPreviousPage:yt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:yt(t.rightFill,"primary+_82"),search:yt(t.search,"primary+f"),selectAll:yt(t.selectAll,"primary+a"),selectColumn:yt(t.selectColumn,"ctrl+ "),selectGrowDown:yt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:yt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:yt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:yt(t.selectGrowUp,"shift+ArrowUp"),selectRow:yt(t.selectRow,"shift+ "),selectToFirstCell:yt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:yt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:yt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:yt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:yt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:yt(t.selectToLastRow,"primary+shift+ArrowDown")}}function v6(t){const e=A4(t);return Nn.useMemo(()=>{if(e===void 0)return Lb(Ks);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Ks.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Ks.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Ks.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Ks.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Ks.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Ks.selectToLastCell};return Lb({...Ks,...n})},[e])}const w6=v.lazy(async()=>await iE(()=>import("./data-grid-overlay-editor-CglJRbhF.js"),[]));let x6=0;function b6(t){return CB(tb(tb(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return qo((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function qf(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 qg={kind:Se.Loading,allowOverlay:!1},Yf={columns:Pt.empty(),rows:Pt.empty(),current:void 0},k6=(t,e)=>{var Xw,Gw,qw;const[n,r]=v.useState(Yf),[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:C,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:Y="default",onGroupHeaderClicked:ie,onCellContextMenu:se,className:V,onHeaderContextMenu:J,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:z,onCellsEdited:j,onSearchResultsChanged:B,searchResults:oe,onSearchValueChange:fe,searchValue:me,onKeyDown:ze,onKeyUp:Fe,keybindings:nt,editOnType:Et=!0,onRowAppended:rt,onColumnMoved:it,validateCell:lt,highlightRegions:_t,rangeSelect:Ne="rect",columnSelect:xe="multi",rowSelect:_e="multi",rangeSelectionBlending:Ye="exclusive",columnSelectionBlending:Ke="exclusive",rowSelectionBlending:Ue="exclusive",onDelete:ht,onDragStart:vt,onMouseMove:at,onPaste:he,copyHeaders:Be=!1,freezeColumns:ut=0,cellActivationBehavior:tt="second-click",rowSelectionMode:Vt="auto",onHeaderMenuClick:ft,getGroupDetails:dt,onSearchClose:wt,onItemHovered:Ut,onSelectionCleared:Mt,showSearch:Rn,onVisibleRegionChanged:$n,gridSelection:W,onGridSelectionChange:ye,minColumnWidth:re=50,maxColumnWidth:we=500,maxColumnAutoWidth:pe,provideEditor:Le,trailingRowOptions:de,freezeTrailingRows:Re=0,allowedFillDirections:De="orthogonal",scrollOffsetX:q,scrollOffsetY:Ae,verticalBorder:$e,onDragOverCell:qt,onDrop:We,onColumnResize:Bt,onColumnResizeEnd:Rt,onColumnResizeStart:Ft,customRenderers:Tn,fillHandle:Zt,drawFocusRing:On=!0,experimental:sn,fixedShadowX:nf,fixedShadowY:Ds,headerIcons:cs,imageWindowLoader:fs,initialSize:Sl,isDraggable:rf,onDragLeave:sf,onRowMoved:Li,overscrollX:Cl,overscrollY:Tl,preventDiagonalScrolling:El,rightElement:No,rightElementProps:_s,trapFocus:of=!1,smoothScrollX:lf,smoothScrollY:Fp,scaleToRem:$p=!1,rowHeight:Al=34,headerHeight:ds=36,groupHeaderHeight:Bp=ds,theme:zp,isOutsideClick:af,renderers:Ml}=t,En=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Ur=(En==null?void 0:En.kind)??t.rowMarkers??"none",uf=(En==null?void 0:En.width)??t.rowMarkerWidth,Rl=(En==null?void 0:En.startIndex)??t.rowMarkerStartIndex??1,Za=(En==null?void 0:En.theme)??t.rowMarkerTheme,Ls=(En==null?void 0:En.checkboxStyle)??"square",Er=Math.max(re,20),ci=Math.max(we,Er),eu=Math.max(pe??ci,Er),Fs=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),tu=v.useMemo(()=>Number.parseFloat(Fs.fontSize),[Fs]),{rowHeight:ir,headerHeight:Ol,groupHeaderHeight:nu,theme:cf,overscrollX:jp,overscrollY:ff}=y6({groupHeaderHeight:Bp,headerHeight:ds,overscrollX:Cl,overscrollY:Tl,remSize:tu,rowHeight:Al,scaleToRem:$p,theme:zp}),fi=v6(nt),hs=uf??(w>1e4?48:w>1e3?44:w>100?36:32),Ar=Ur!=="none",X=Ar?1:0,on=rt!==void 0,Do=(de==null?void 0:de.sticky)===!0,[Hp,df]=v.useState(!1),ru=Rn??Hp,Wp=v.useCallback(()=>{wt!==void 0?wt():df(!1)},[wt]),Q=v.useMemo(()=>W===void 0?void 0:qf(W,X),[W,X])??n,Kn=v.useRef();Kn.current===void 0&&(Kn.current=new AbortController),v.useEffect(()=>()=>Kn==null?void 0:Kn.current.abort(),[]);const[An,Pl]=t6(R,k,X,Kn.current,w),iu=v.useCallback((S,$,F)=>{if(lt===void 0)return!0;const U=[S[0]-X,S[1]];return lt==null?void 0:lt(U,$,F)},[X,lt]),$s=v.useRef(W),pr=v.useCallback((S,$)=>{$&&(S=a6(S,An,X,Y,Kn.current)),ye!==void 0?($s.current=qf(S,-X),ye($s.current)):r(S)},[ye,An,X,Y]),di=jl(Bt,v.useCallback((S,$,F,U)=>{Bt==null||Bt(y[F-X],$,F-X,U)},[Bt,X,y])),Vp=jl(Rt,v.useCallback((S,$,F,U)=>{Rt==null||Rt(y[F-X],$,F-X,U)},[Rt,X,y])),Il=jl(Ft,v.useCallback((S,$,F,U)=>{Ft==null||Ft(y[F-X],$,F-X,U)},[Ft,X,y])),Up=jl(O,v.useCallback((S,$)=>(O==null?void 0:O({...S,columnIndex:S.columnIndex-X},$))??!1,[O,X])),Kp=jl(_,v.useCallback((S,$)=>(_==null?void 0:_({...S,col:S.col-X},$))??!1,[_,X])),H=v.useCallback(S=>{if(ht!==void 0){const $=ht(qf(S,-X));return typeof $=="boolean"?$:qf($,X)}return!0},[ht,X]),[ne,be,ge]=e6(Q,pr,Ye,Ke,Ue,Ne),ae=v.useMemo(()=>wo(nE(),cf),[cf]),[Me,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Ml===void 0)return{};const S={};for(const $ of Ml)S[$.kind]=$;return S},[Ml]),Te=v.useCallback(S=>S.kind!==Se.Custom?ot[S.kind]:Tn==null?void 0:Tn.find($=>$.isMatch(S)),[Tn,ot]);let{sizedColumns:Dt,nonGrowWidth:je}=k$(y,w,Pl,Me[0]-(X===0?0:hs)-Me[2],Er,eu,ae,Te,Kn.current);Ur!=="none"&&(je+=hs);const $t=v.useMemo(()=>Dt.some(S=>S.group!==void 0),[Dt]),ct=$t?Ol+nu:Ol,kt=Q.rows.length,yn=Ur==="none"?void 0:kt===0?!1:kt===w?!0:void 0,pt=v.useMemo(()=>Ur==="none"?Dt:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:Za,rowMarker:Ls,rowMarkerChecked:yn},...Dt],[Ur,Dt,hs,Za,Ls,yn]),[dn,Kr]=v.useMemo(()=>[Ae!==void 0&&typeof ir=="number"?Math.floor(Ae/ir):0,Ae!==void 0&&typeof ir=="number"?-(Ae%ir):0],[Ae,ir]),ln=v.useRef({height:1,width:1,x:0,y:0}),Mr=v.useMemo(()=>({x:ln.current.x,y:dn,width:ln.current.width??1,height:ln.current.height??1,ty:Kr}),[Kr,dn]),Ot=v.useRef(!1),[vn,Rr,Fi]=E4(Mr);ln.current=vn;const hi=(vn.height??1)>1;v.useLayoutEffect(()=>{if(Ae!==void 0&&c.current!==null&&hi){if(c.current.scrollTop===Ae)return;c.current.scrollTop=Ae,c.current.scrollTop!==Ae&&Fi(),Ot.current=!0}},[Ae,hi,Fi]);const Nl=(vn.width??1)>1;v.useLayoutEffect(()=>{if(q!==void 0&&c.current!==null&&Nl){if(c.current.scrollLeft===q)return;c.current.scrollLeft=q,c.current.scrollLeft!==q&&Fi(),Ot.current=!0}},[q,Nl,Fi]);const _o=vn.x+X,hf=vn.y,gr=v.useRef(null),sr=v.useCallback(S=>{var $;S===!0?($=gr.current)==null||$.focus():window.requestAnimationFrame(()=>{var F;(F=gr.current)==null||F.focus()})},[]),Xn=on?w+1:w,Xr=v.useCallback(S=>{const $=X===0?S:S.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),F=j==null?void 0:j($);if(F!==!0)for(const U of $)z==null||z(U.location,U.value);return F},[z,j,X]),[Lo,Xp]=v.useState(),pf=Q.current!==void 0&&Q.current.range.width*Q.current.range.height>1?Q.current.range:void 0,Dl=On?(Xw=Q.current)==null?void 0:Xw.cell:void 0,gf=Dl==null?void 0:Dl[0],mf=Dl==null?void 0:Dl[1],pR=v.useMemo(()=>{if((_t===void 0||_t.length===0)&&(pf??gf??mf??Lo)===void 0)return;const S=[];if(_t!==void 0)for(const $ of _t){const F=pt.length-$.range.x-X;F>0&&S.push({color:$.color,range:{...$.range,x:$.range.x+X,width:Math.min(F,$.range.width)},style:$.style})}return Lo!==void 0&&S.push({color:dl(ae.accentColor,0),range:Lo,style:"dashed"}),pf!==void 0&&S.push({color:dl(ae.accentColor,.5),range:pf,style:"solid-outline"}),gf!==void 0&&mf!==void 0&&S.push({color:ae.accentColor,range:{x:gf,y:mf,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Lo,pf,gf,mf,_t,pt.length,ae.accentColor,X]),Dw=v.useRef(pt);Dw.current=pt;const Or=v.useCallback(([S,$],F=!1)=>{var ee,G,Z,le,te,Ce,Oe;const U=on&&$===Xn-1;if(S===0&&Ar)return U?qg:{kind:Zr.Marker,allowOverlay:!1,checkboxStyle:Ls,checked:(Q==null?void 0:Q.rows.hasIndex($))===!0,markerKind:Ur==="clickable-number"?"number":Ur,row:Rl+$,drawHandle:Li!==void 0,cursor:Ur==="clickable-number"?"pointer":void 0};if(U){const Xe=S===X?(de==null?void 0:de.hint)??"":"",Qe=Dw.current[S];if(((ee=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:ee.disabled)===!0)return qg;{const At=((G=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:G.hint)??Xe,Ze=((Z=Qe==null?void 0:Qe.trailingRowOptions)==null?void 0:Z.addIcon)??(de==null?void 0:de.addIcon);return{kind:Zr.NewRow,hint:At,allowOverlay:!1,icon:Ze}}}else{const ke=S-X;if(F||(sn==null?void 0:sn.strict)===!0){const Qe=ln.current,At=Qe.x>ke||ke>Qe.x+Qe.width||Qe.y>$||$>Qe.y+Qe.height||$>=qp.current,Ze=ke===((te=(le=Qe.extras)==null?void 0:le.selected)==null?void 0:te[0])&&$===((Ce=Qe.extras)==null?void 0:Ce.selected[1]);let Ve=!1;if(((Oe=Qe.extras)==null?void 0:Oe.freezeRegions)!==void 0){for(const Yt of Qe.extras.freezeRegions)if(kp(Yt,ke,$)){Ve=!0;break}}if(At&&!Ze&&!Ve)return qg}let Xe=k([ke,$]);return X!==0&&Xe.span!==void 0&&(Xe={...Xe,span:[Xe.span[0]+X,Xe.span[1]+X]}),Xe}},[on,Xn,Ar,Ls,Q==null?void 0:Q.rows,Ur,Rl,Li,X,de==null?void 0:de.hint,de==null?void 0:de.addIcon,sn==null?void 0:sn.strict,k]),Gp=v.useCallback(S=>{let $=(dt==null?void 0:dt(S))??{name:S};return L!==void 0&&S!==""&&($={icon:$.icon,name:$.name,overrideTheme:$.overrideTheme,actions:[...$.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>Qp({group:$.name,bounds:F.bounds})}]}),$},[dt,L]),yf=v.useCallback(S=>{var Z;const[$,F]=S.cell,U=pt[$],K=(U==null?void 0:U.group)!==void 0?(Z=Gp(U.group))==null?void 0:Z.overrideTheme:void 0,ee=U==null?void 0:U.themeOverride,G=p==null?void 0:p(F);s({...S,theme:wo(ae,K,ee,G,S.content.themeOverride)})},[p,pt,Gp,ae]),_l=v.useCallback((S,$,F)=>{var G;if(Q.current===void 0)return;const[U,K]=Q.current.cell,ee=Or([U,K]);if(ee.kind!==Se.Boolean&&ee.allowOverlay){let Z=ee;if(F!==void 0)switch(Z.kind){case Se.Number:{const le=lD(()=>F==="-"?-0:Number.parseFloat(F),0);Z={...Z,data:Number.isNaN(le)?0:le};break}case Se.Text:case Se.Markdown:case Se.Uri:Z={...Z,data:F};break}yf({target:S,content:Z,initialValue:F,cell:[U,K],highlight:F===void 0,forceEditMode:F!==void 0})}else ee.kind===Se.Boolean&&$&&ee.readonly!==!0&&(Xr([{location:Q.current.cell,value:{...ee,data:PE(ee.data)}}]),(G=gr.current)==null||G.damage([{cell:Q.current.cell}]))},[Or,Q,Xr,yf]),_w=v.useCallback((S,$)=>{var K;const F=(K=gr.current)==null?void 0:K.getBounds(S,$);if(F===void 0||c.current===null)return;const U=Or([S,$]);U.allowOverlay&&yf({target:F,content:U,initialValue:void 0,highlight:!0,cell:[S,$],forceEditMode:!0})},[Or,yf]),wn=v.useCallback((S,$,F="both",U=0,K=0,ee=void 0)=>{if(c.current!==null){const G=gr.current,Z=l.current,le=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,te=typeof $!="number"?$.unit==="cell"?$.amount:void 0:$,Ce=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Oe=typeof $!="number"&&$.unit==="px"?$.amount:void 0;if(G!==null&&Z!==null){let ke={x:0,y:0,width:0,height:0},Xe=0,Qe=0;if((le!==void 0||te!==void 0)&&(ke=G.getBounds((le??0)+X,te??0)??ke,ke.width===0||ke.height===0))return;const At=Z.getBoundingClientRect(),Ze=At.width/Z.offsetWidth;if(Ce!==void 0&&(ke={...ke,x:Ce-At.left-c.current.scrollLeft,width:1}),Oe!==void 0&&(ke={...ke,y:Oe+At.top-c.current.scrollTop,height:1}),ke!==void 0){const Ve={x:ke.x-U,y:ke.y-K,width:ke.width+2*U,height:ke.height+2*K};let Yt=0;for(let rg=0;rg0&&(Gn=kl(Xn,xn,ir));let gi=Yt*Ze+At.left+X*hs*Ze,Bi=At.right,mi=At.top+ct*Ze,zi=At.bottom-Gn*Ze;const Sf=ke.width+U*2;switch(ee==null?void 0:ee.hAlign){case"start":Bi=gi+Sf;break;case"end":gi=Bi-Sf;break;case"center":gi=Math.floor((gi+Bi)/2)-Sf/2,Bi=gi+Sf;break}const Cf=ke.height+K*2;switch(ee==null?void 0:ee.vAlign){case"start":zi=mi+Cf;break;case"end":mi=zi-Cf;break;case"center":mi=Math.floor((mi+zi)/2)-Cf/2,zi=mi+Cf;break}gi>Ve.x?Xe=Ve.x-gi:BiVe.y?Qe=Ve.y-mi:zi=Xn-xn)&&(Qe=0),(Xe!==0||Qe!==0)&&(Ze!==1&&(Xe/=Ze,Qe/=Ze),c.current.scrollTo(Xe+c.current.scrollLeft,Qe+c.current.scrollTop))}}}},[X,Re,hs,ct,ut,Dt,Xn,Do,ir]),Lw=v.useRef(_w),Fw=v.useRef(k),qp=v.useRef(w);Lw.current=_w,Fw.current=k,qp.current=w;const Ll=v.useCallback(async(S,$=!0)=>{var le;const F=pt[S];if(((le=F==null?void 0:F.trailingRowOptions)==null?void 0:le.disabled)===!0)return;const U=rt==null?void 0:rt();let K,ee=!0;U!==void 0&&(K=await U,K==="top"&&(ee=!1),typeof K=="number"&&(ee=!1));let G=0;const Z=()=>{if(qp.current<=w){G<500&&window.setTimeout(Z,G),G=50+G*2;return}const te=typeof K=="number"?K:ee?w:0;kf.current(S-X,te),ne({cell:[S,te],range:{x:S,y:te,width:1,height:1}},!1,!1,"edit");const Ce=Fw.current([S-X,te]);Ce.allowOverlay&&Lu(Ce)&&Ce.readonly!==!0&&$&&window.setTimeout(()=>{Lw.current(S,te)},0)};Z()},[pt,rt,X,w,ne]),vf=v.useCallback(S=>{var F,U;const $=((U=(F=Dt[S])==null?void 0:F.trailingRowOptions)==null?void 0:U.targetColumn)??(de==null?void 0:de.targetColumn);if(typeof $=="number")return $+(Ar?1:0);if(typeof $=="object"){const K=y.indexOf($);if(K>=0)return K+(Ar?1:0)}},[Dt,y,Ar,de==null?void 0:de.targetColumn]),Bs=v.useRef(),Fl=v.useRef(),su=v.useCallback((S,$)=>{var K;const[F,U]=$;return wo(ae,(K=pt[F])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,pt,ae]),ou=v.useCallback(S=>{var Ce,Oe,ke;const $=Sh.value?S.metaKey:S.ctrlKey,F=$&&_e==="multi",U=$&&xe==="multi",[K,ee]=S.location,G=Q.columns,Z=Q.rows,[le,te]=((Ce=Q.current)==null?void 0:Ce.cell)??[];if(S.kind==="cell"){if(Fl.current=void 0,Fo.current=[K,ee],K===0&&Ar){if(on===!0&&ee===w||Ur==="number"||_e==="none")return;const Xe=Or(S.location);if(Xe.kind!==Zr.Marker)return;if(Li!==void 0){const Ze=Te(Xe);Lr((Ze==null?void 0:Ze.kind)===Zr.Marker);const Ve=(Oe=Ze==null?void 0:Ze.onClick)==null?void 0:Oe.call(Ze,{...S,cell:Xe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:su(Xe,S.location),preventDefault:()=>{}});if(Ve===void 0||Ve.checked===Xe.checked)return}s(void 0),sr();const Qe=Z.hasIndex(ee),At=Bs.current;if(_e==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&At!==void 0&&Z.hasIndex(At)){const Ze=[Math.min(At,ee),Math.max(At,ee)+1];F||Vt==="multi"?be(void 0,Ze,!0):be(Pt.fromSingleSelection(Ze),void 0,F)}else F||S.isTouch||Vt==="multi"?Qe?be(Z.remove(ee),void 0,!0):(be(void 0,ee,!0),Bs.current=ee):Qe&&Z.length===1?be(Pt.empty(),void 0,$):(be(Pt.fromSingleSelection(ee),void 0,$),Bs.current=ee)}else if(K>=X&&on&&ee===w){const Xe=vf(K);Ll(Xe??K)}else if(le!==K||te!==ee){const Xe=Or(S.location),Qe=Te(Xe);if((Qe==null?void 0:Qe.onSelect)!==void 0){let Ve=!1;if(Qe.onSelect({...S,cell:Xe,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>Ve=!0,theme:su(Xe,S.location)}),Ve)return}const At=Do&&ee===w,Ze=Do&&Q!==void 0&&((ke=Q.current)==null?void 0:ke.cell[1])===w;if((S.shiftKey||S.isLongTouch===!0)&&le!==void 0&&te!==void 0&&Q.current!==void 0&&!Ze){if(At)return;const Ve=Math.min(K,le),Yt=Math.max(K,le),Gn=Math.min(ee,te),xn=Math.max(ee,te);ne({...Q.current,range:{x:Ve,y:Gn,width:Yt-Ve+1,height:xn-Gn+1}},!0,$,"click"),Bs.current=void 0,sr()}else ne({cell:[K,ee],range:{x:K,y:ee,width:1,height:1}},!0,$,"click"),Bs.current=void 0,s(void 0),sr()}}else if(S.kind==="header")if(Fo.current=[K,ee],s(void 0),Ar&&K===0)Bs.current=void 0,Fl.current=void 0,_e==="multi"&&(Z.length!==w?be(Pt.fromSingleSelection([0,w]),void 0,$):be(Pt.empty(),void 0,$),sr());else{const Xe=Fl.current;if(xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&Xe!==void 0&&G.hasIndex(Xe)){const Qe=[Math.min(Xe,K),Math.max(Xe,K)+1];U?ge(void 0,Qe,$):ge(Pt.fromSingleSelection(Qe),void 0,$)}else U?(G.hasIndex(K)?ge(G.remove(K),void 0,$):ge(void 0,K,$),Fl.current=K):xe!=="none"&&(ge(Pt.fromSingleSelection(K),void 0,$),Fl.current=K);Bs.current=void 0,sr()}else S.kind===_r?Fo.current=[K,ee]:S.kind===Ch&&!S.isMaybeScrollbar&&(pr(Yf,!1),s(void 0),sr(),Mt==null||Mt(),Bs.current=void 0,Fl.current=void 0)},[Ll,xe,sr,Te,vf,Or,Q,Ar,Do,Mt,Li,X,Ur,_e,Vt,w,ne,pr,ge,be,on,su]),lu=v.useRef(!1),Fo=v.useRef(),$w=v.useRef(vn),Gr=v.useRef(),gR=v.useCallback(S=>{if($l.current=!1,$w.current=ln.current,S.button!==0&&S.button!==1){Gr.current=void 0;return}const $=performance.now();Gr.current={button:S.button,time:$,location:S.location},(S==null?void 0:S.kind)==="header"&&(lu.current=!0);const F=S.kind==="cell"&&S.isFillHandle;!F&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:Q,fillHandle:F}),Fo.current=void 0,!S.isTouch&&S.button===0&&!F?ou(S):!S.isTouch&&S.button===1&&(Fo.current=S.location))},[Q,ou]),[Yp,Qp]=v.useState(),Bw=v.useCallback(S=>{if(S.kind!==_r||xe!=="multi")return;const $=Sh.value?S.metaKey:S.ctrlKey,[F]=S.location,U=Q.columns;if(F=X&&Ec(K.group,pt[Z].group);Z--)ee--;for(let Z=F+1;Z{if(An!==void 0&&di!==void 0){const $=ln.current.y,F=ln.current.height;let U=An({x:S,y:$,width:1,height:Math.min(F,w-$)},Kn.current.signal);typeof U!="object"&&(U=await U());const K=Dt[S-X],G=document.createElement("canvas").getContext("2d",{alpha:!1});if(G!==null){G.font=ae.baseFontFull;const Z=rE(G,ae,K,0,U,Er,ci,!1,Te);di==null||di(K,Z.width,S,Z.width)}}},[Dt,An,ci,ae,Er,di,X,w,Te]),[mR,Jp]=v.useState(),Bl=v.useCallback(async(S,$)=>{var Z,le;const F=(Z=S.current)==null?void 0:Z.range;if(F===void 0||An===void 0||$.current===void 0)return;const U=$.current.range;if(T!==void 0){let te=!1;if(T({fillDestination:{...U,x:U.x-X},patternSource:{...F,x:F.x-X},preventDefault:()=>te=!0}),te)return}let K=An(F,Kn.current.signal);typeof K!="object"&&(K=await K());const ee=K,G=[];for(let te=0;te({cell:te.location})))},[An,Xr,T,X]),zw=v.useCallback(()=>{if(Q.current===void 0||Q.current.range.width<=1)return;const S={...Q,current:{...Q.current,range:{...Q.current.range,width:1}}};Bl(S,Q)},[Bl,Q]),jw=v.useCallback(()=>{if(Q.current===void 0||Q.current.range.height<=1)return;const S={...Q,current:{...Q.current,range:{...Q.current.range,height:1}}};Bl(S,Q)},[Bl,Q]),yR=v.useCallback((S,$)=>{var Ce,Oe;const F=a;if(u(void 0),Xp(void 0),Jp(void 0),lu.current=!1,$)return;if((F==null?void 0:F.fillHandle)===!0&&Q.current!==void 0&&((Ce=F.previousSelection)==null?void 0:Ce.current)!==void 0){if(Lo===void 0)return;const ke={...Q,current:{...Q.current,range:hE(F.previousSelection.current.range,Lo)}};Bl(F.previousSelection,ke),pr(ke,!0);return}const[U,K]=S.location,[ee,G]=Fo.current??[],Z=()=>{$l.current=!0},le=ke=>{var Qe,At,Ze;const Xe=ke.isTouch||ee===U&&G===K;if(Xe&&(b==null||b([U-X,K],{...ke,preventDefault:Z})),ke.button===1)return!$l.current;if(!$l.current){const Ve=Or(S.location),Yt=Te(Ve);if(Yt!==void 0&&Yt.onClick!==void 0&&Xe){const xn=Yt.onClick({...ke,cell:Ve,posX:ke.localEventX,posY:ke.localEventY,bounds:ke.bounds,theme:su(Ve,S.location),preventDefault:Z});xn!==void 0&&!sa(xn)&&Vl(xn)&&(Xr([{location:ke.location,value:xn}]),(Qe=gr.current)==null||Qe.damage([{cell:ke.location}]))}if($l.current||Q.current===void 0)return!1;let Gn=!1;switch(Ve.activationBehaviorOverride??tt){case"double-click":case"second-click":{if(((Ze=(At=F==null?void 0:F.previousSelection)==null?void 0:At.current)==null?void 0:Ze.cell)===void 0)break;const[xn,gi]=Q.current.cell,[Bi,mi]=F.previousSelection.current.cell;Gn=U===xn&&U===Bi&&K===gi&&K===mi&&(ke.isDoubleClick===!0||tt==="second-click");break}case"single-click":{Gn=!0;break}}if(Gn)return C==null||C([U-X,K]),_l(ke.bounds,!1),!0}return!1},te=S.location[0]-X;if(S.isTouch){const ke=ln.current,Xe=$w.current;if(ke.x!==Xe.x||ke.y!==Xe.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Ju((Oe=Q.current)==null?void 0:Oe.cell,S.location)){se==null||se([te,S.location[1]],{...S,preventDefault:Z});return}else if(S.kind==="header"&&Q.columns.hasIndex(U)){J==null||J(te,{...S,preventDefault:Z});return}else if(S.kind===_r){if(te<0)return;N==null||N(te,{...S,preventDefault:Z});return}}S.kind==="cell"?le(S)||ou(S):S.kind===_r?ie==null||ie(te,{...S,preventDefault:Z}):(S.kind===qs&&(I==null||I(te,{...S,preventDefault:Z})),ou(S));return}if(S.kind==="header"){if(te<0)return;S.isEdge?S.isDoubleClick===!0&&wf(U):S.button===0&&U===ee&&K===G&&(I==null||I(te,{...S,preventDefault:Z}))}if(S.kind===_r){if(te<0)return;S.button===0&&U===ee&&K===G&&(ie==null||ie(te,{...S,preventDefault:Z}),$l.current||Bw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&le(S),Fo.current=void 0},[a,Q,X,Lo,Bl,pr,b,Or,Te,tt,su,Xr,C,_l,se,J,N,ou,ie,I,wf,Bw]),vR=v.useCallback(S=>{const $={...S,location:[S.location[0]-X,S.location[1]]};at==null||at($),a!==void 0&&S.buttons===0&&(u(void 0),Xp(void 0),Jp(void 0),lu.current=!1),Jp(F=>{var U;return lu.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(F==null?void 0:F[0])&&S.scrollEdge[1]===F[1]?F:a===void 0||(((U=Gr.current)==null?void 0:U.location[0])??0){ft==null||ft(S-X,$)},[ft,X]),$i=(Gw=Q==null?void 0:Q.current)==null?void 0:Gw.cell,xR=v.useCallback((S,$,F,U,K,ee)=>{Ot.current=!1;let G=$i;G!==void 0&&(G=[G[0]-X,G[1]]);const Z=ut===0?void 0:{x:0,y:S.y,width:ut,height:S.height},le=[];Z!==void 0&&le.push(Z),Re>0&&(le.push({x:S.x-X,y:w-Re,width:S.width,height:Re}),ut>0&&le.push({x:0,y:w-Re,width:ut,height:Re}));const te={x:S.x-X,y:S.y,width:S.width,height:on&&S.y+S.height>=w?S.height-1:S.height,tx:K,ty:ee,extras:{selected:G,freezeRegion:Z,freezeRegions:le}};ln.current=te,Rr(te),st([$,F,U]),$n==null||$n(te,te.tx,te.ty,te.extras)},[$i,X,on,w,ut,Re,Rr,$n]),bR=jl(it,v.useCallback((S,$)=>{it==null||it(S-X,$-X),xe!=="none"&&ge(Pt.fromSingleSelection($),void 0,!0)},[xe,it,X,ge])),Zp=v.useRef(!1),kR=v.useCallback(S=>{if(S.location[0]===0&&X>0){S.preventDefault();return}vt==null||vt({...S,location:[S.location[0]-X,S.location[1]]}),S.defaultPrevented()||(Zp.current=!0),u(void 0)},[vt,X]),SR=v.useCallback(()=>{Zp.current=!1},[]),eg=v.useRef(),tg=v.useCallback(S=>{var $,F,U;if(!RE(S,eg.current)&&(eg.current=S,!((($=Gr==null?void 0:Gr.current)==null?void 0:$.button)!==void 0&&Gr.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((F=Gr.current)==null?void 0:F.location[0])===0&&S.location[0]===0&&X===1&&_e==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(Gr.current.location[1])&&Q.rows.hasIndex(Gr.current.location[1])){const K=Math.min(Gr.current.location[1],S.location[1]),ee=Math.max(Gr.current.location[1],S.location[1])+1;be(Pt.fromSingleSelection([K,ee]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&Q.current!==void 0&&!Zp.current&&!lu.current&&(Ne==="rect"||Ne==="multi-rect")){const[K,ee]=Q.current.cell;let[G,Z]=S.location;if(Z<0&&(Z=ln.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const le=a.previousSelection.current.range;Z=Math.min(Z,on?w-1:w);const te=az(le,G,Z,De);Xp(te)}else{if(on&&ee===w)return;if(on&&Z===w)if(S.kind===Ch)Z--;else return;G=Math.max(G,X);const Ce=G-K,Oe=Z-ee,ke={x:Ce>=0?K:G,y:Oe>=0?ee:Z,width:Math.abs(Ce)+1,height:Math.abs(Oe)+1};ne({...Q.current,range:ke},!0,!1,"drag")}}Ut==null||Ut({...S,location:[S.location[0]-X,S.location[1]]})}},[De,a,X,_e,Q,Ne,Ut,be,on,w,ne]),CR=v.useCallback(()=>{var G,Z;const S=eg.current;if(S===void 0)return;const[$,F]=S.scrollEdge;let[U,K]=S.location;const ee=ln.current;$===-1?U=((Z=(G=ee.extras)==null?void 0:G.freezeRegion)==null?void 0:Z.x)??ee.x:$===1&&(U=ee.x+ee.width),F===-1?K=Math.max(0,ee.y):F===1&&(K=Math.min(w-1,ee.y+ee.height)),U=Si(U,0,pt.length-1),K=Si(K,0,w-1),tg({...S,location:[U,K]})},[pt.length,tg,w]);m6(mR,c,CR);const pi=v.useCallback(S=>{if(Q.current===void 0)return;const[$,F]=S,[U,K]=Q.current.cell,ee=Q.current.range;let G=ee.x,Z=ee.x+ee.width,le=ee.y,te=ee.y+ee.height;if(F!==0)switch(F){case 2:{te=w,le=K,wn(0,te,"vertical");break}case-2:{le=0,te=K+1,wn(0,le,"vertical");break}case 1:{leK+1?(te--,wn(0,te,"vertical")):(le=Math.max(0,le-1),wn(0,le,"vertical"));break}default:Tc()}if($!==0)if($===2)Z=pt.length,G=U,wn(Z-1-X,0,"horizontal");else if($===-2)G=X,Z=U+1,wn(G-X,0,"horizontal");else{let Ce=[];if(An!==void 0){const Oe=An({x:G,y:le,width:Z-G-X,height:te-le},Kn.current.signal);typeof Oe=="object"&&(Ce=b6(Oe))}if($===1){let Oe=!1;if(G0){const ke=qo(G+1,U+1).find(Xe=>!Ce.includes(Xe-X));ke!==void 0&&(G=ke,Oe=!0)}else G++,Oe=!0;Oe&&wn(G,0,"horizontal")}Oe||(Z=Math.min(pt.length,Z+1),wn(Z-1-X,0,"horizontal"))}else if($===-1){let Oe=!1;if(Z>U+1){if(Ce.length>0){const ke=qo(Z-1,U,-1).find(Xe=>!Ce.includes(Xe-X));ke!==void 0&&(Z=ke,Oe=!0)}else Z--,Oe=!0;Oe&&wn(Z-X,0,"horizontal")}Oe||(G=Math.max(X,G-1),wn(G-X,0,"horizontal"))}else Tc()}ne({cell:Q.current.cell,range:{x:G,y:le,width:Z-G,height:te-le}},!0,!1,"keyboard-select")},[An,Q,pt.length,X,w,wn,ne]),zs=v.useCallback((S,$,F,U)=>{const K=Xn-(F?0:1);if(S=Si(S,X,Dt.length-1+X),$=Si($,0,K),S===($i==null?void 0:$i[0])&&$===($i==null?void 0:$i[1]))return!1;if(U&&Q.current!==void 0){const ee=[...Q.current.rangeStack];(Q.current.range.width>1||Q.current.range.height>1)&&ee.push(Q.current.range),pr({...Q,current:{cell:[S,$],range:{x:S,y:$,width:1,height:1},rangeStack:ee}},!0)}else ne({cell:[S,$],range:{x:S,y:$,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===$&&(f.current=void 0),wn(S-X,$),!0},[Xn,X,Dt.length,$i,Q,wn,pr,ne]),TR=v.useCallback((S,$)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Vl(S)&&(Xr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=gr.current)==null||K.damage([{cell:i.cell}])})),sr(!0),s(void 0);const[F,U]=$;if(Q.current!==void 0&&(F!==0||U!==0)){const K=Q.current.cell[1]===Xn-1&&S!==void 0;zs(Si(Q.current.cell[0]+F,0,pt.length-1),Si(Q.current.cell[1]+U,0,Xn-1),K,!1)}A==null||A(S,$)},[i==null?void 0:i.cell,sr,Q,A,Xr,Xn,zs,pt.length]),ER=v.useMemo(()=>`gdg-overlay-${x6++}`,[]),$o=v.useCallback(S=>{var F,U,K,ee;sr();const $=[];for(let G=S.x;G({cell:G.location})))},[sr,k,Te,Xr,X]),au=i!==void 0,Hw=v.useCallback(S=>{var Xe,Qe;const $=()=>{S.stopPropagation(),S.preventDefault()},F={didMatch:!1},{bounds:U}=S,K=Q.columns,ee=Q.rows,G=fi;if(!au&&mt(G.clear,S,F))pr(Yf,!1),Mt==null||Mt();else if(!au&&mt(G.selectAll,S,F))pr({columns:Pt.empty(),rows:Pt.empty(),current:{cell:((Xe=Q.current)==null?void 0:Xe.cell)??[X,0],range:{x:X,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(mt(G.search,S,F))(Qe=o==null?void 0:o.current)==null||Qe.focus({preventScroll:!0}),df(!0);else if(mt(G.delete,S,F)){const At=(H==null?void 0:H(Q))??!0;if(At!==!1){const Ze=At===!0?Q:At;if(Ze.current!==void 0){$o(Ze.current.range);for(const Ve of Ze.current.rangeStack)$o(Ve)}for(const Ve of Ze.rows)$o({x:X,y:Ve,width:y.length,height:1});for(const Ve of Ze.columns)$o({x:Ve,y:0,width:1,height:w})}}if(F.didMatch)return $(),!0;if(Q.current===void 0)return!1;let[Z,le]=Q.current.cell,te=!1,Ce=!1;mt(G.scrollToSelectedCell,S,F)?kf.current(Z-X,le):xe!=="none"&&mt(G.selectColumn,S,F)?K.hasIndex(Z)?ge(K.remove(Z),void 0,!0):xe==="single"?ge(Pt.fromSingleSelection(Z),void 0,!0):ge(void 0,Z,!0):_e!=="none"&&mt(G.selectRow,S,F)?ee.hasIndex(le)?be(ee.remove(le),void 0,!0):_e==="single"?be(Pt.fromSingleSelection(le),void 0,!0):be(void 0,le,!0):!au&&U!==void 0&&mt(G.activateCell,S,F)?le===w&&on?window.setTimeout(()=>{const At=vf(Z);Ll(At??Z)},0):(C==null||C([Z-X,le]),_l(U,!0)):Q.current.range.height>1&&mt(G.downFill,S,F)?jw():Q.current.range.width>1&&mt(G.rightFill,S,F)?zw():mt(G.goToNextPage,S,F)?le+=Math.max(1,ln.current.height-4):mt(G.goToPreviousPage,S,F)?le-=Math.max(1,ln.current.height-4):mt(G.goToFirstCell,S,F)?(s(void 0),le=0,Z=0):mt(G.goToLastCell,S,F)?(s(void 0),le=Number.MAX_SAFE_INTEGER,Z=Number.MAX_SAFE_INTEGER):mt(G.selectToFirstCell,S,F)?(s(void 0),pi([-2,-2])):mt(G.selectToLastCell,S,F)?(s(void 0),pi([2,2])):au?(mt(G.closeOverlay,S,F)&&s(void 0),mt(G.acceptOverlayDown,S,F)&&(s(void 0),le++),mt(G.acceptOverlayUp,S,F)&&(s(void 0),le--),mt(G.acceptOverlayLeft,S,F)&&(s(void 0),Z--),mt(G.acceptOverlayRight,S,F)&&(s(void 0),Z++)):(mt(G.goDownCell,S,F)?le+=1:mt(G.goUpCell,S,F)?le-=1:mt(G.goRightCell,S,F)?Z+=1:mt(G.goLeftCell,S,F)?Z-=1:mt(G.goDownCellRetainSelection,S,F)?(le+=1,te=!0):mt(G.goUpCellRetainSelection,S,F)?(le-=1,te=!0):mt(G.goRightCellRetainSelection,S,F)?(Z+=1,te=!0):mt(G.goLeftCellRetainSelection,S,F)?(Z-=1,te=!0):mt(G.goToLastRow,S,F)?le=w-1:mt(G.goToFirstRow,S,F)?le=Number.MIN_SAFE_INTEGER:mt(G.goToLastColumn,S,F)?Z=Number.MAX_SAFE_INTEGER:mt(G.goToFirstColumn,S,F)?Z=Number.MIN_SAFE_INTEGER:(Ne==="rect"||Ne==="multi-rect")&&(mt(G.selectGrowDown,S,F)?pi([0,1]):mt(G.selectGrowUp,S,F)?pi([0,-1]):mt(G.selectGrowRight,S,F)?pi([1,0]):mt(G.selectGrowLeft,S,F)?pi([-1,0]):mt(G.selectToLastRow,S,F)?pi([0,2]):mt(G.selectToFirstRow,S,F)?pi([0,-2]):mt(G.selectToLastColumn,S,F)?pi([2,0]):mt(G.selectToFirstColumn,S,F)&&pi([-2,0])),Ce=F.didMatch);const Oe=zs(Z,le,!1,te),ke=F.didMatch;return ke&&(Oe||!Ce||of)&&$(),ke},[au,Q,fi,xe,_e,Ne,X,w,zs,pr,Mt,y.length,H,of,$o,ge,be,on,vf,Ll,C,_l,jw,zw,pi]),uu=v.useCallback(S=>{let $=!1;if(ze!==void 0&&ze({...S,cancel:()=>{$=!0}}),$||Hw(S)||Q.current===void 0)return;const[F,U]=Q.current.cell,K=ln.current;if(Et&&!S.metaKey&&!S.ctrlKey&&Q.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Lu(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;_l(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Et,ze,Hw,Q,k,X,w,on,_l]),AR=v.useCallback((S,$)=>{const F=S.location[0]-X;if(S.kind==="header"&&(J==null||J(F,{...S,preventDefault:$})),S.kind===_r){if(F<0)return;N==null||N(F,{...S,preventDefault:$})}if(S.kind==="cell"){const[U,K]=S.location;se==null||se([F,K],{...S,preventDefault:$}),i$(Q,S.location)||zs(U,K,!1,!1)}},[Q,se,N,J,X,zs]),ng=v.useCallback(async S=>{var G,Z,le;if(!fi.paste)return;function $(te,Ce,Oe,ke){var Qe,At;const Xe=typeof Oe=="object"?(Oe==null?void 0:Oe.join(` -`))??"":(Oe==null?void 0:Oe.toString())??"";if(!sa(te)&&Lu(te)&&te.readonly!==!0){const Ze=M==null?void 0:M(Xe,te);if(Ze!==void 0&&Vl(Ze))return{location:Ce,value:Ze};const Ve=Te(te);if(Ve===void 0)return;if(Ve.kind===Se.Custom){Lr(te.kind===Se.Custom);const Yt=(Qe=Ve.onPaste)==null?void 0:Qe.call(Ve,Xe,te.data);return Yt===void 0?void 0:{location:Ce,value:{...te,data:Yt}}}else{const Yt=(At=Ve.onPaste)==null?void 0:At.call(Ve,Xe,te,{formatted:ke,formattedString:typeof ke=="string"?ke:ke==null?void 0:ke.join(` -`),rawValue:Oe});return Yt===void 0?void 0:(Lr(Yt.kind===te.kind),{location:Ce,value:Yt})}}}const F=Q.columns,U=Q.rows,K=((G=c.current)==null?void 0:G.contains(document.activeElement))===!0||((Z=l.current)==null?void 0:Z.contains(document.activeElement))===!0;let ee;if(Q.current!==void 0?ee=[Q.current.range.x,Q.current.range.y]:F.length===1?ee=[F.first()??0,0]:U.length===1&&(ee=[X,U.first()??0]),K&&ee!==void 0){let te,Ce;const Oe="text/plain",ke="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const Ve of Ze){if(Ve.types.includes(ke)){const Gn=await(await Ve.getType(ke)).text(),xn=Ib(Gn);if(xn!==void 0){te=xn;break}}Ve.types.includes(Oe)&&(Ce=await(await Ve.getType(Oe)).text())}}else if(navigator.clipboard.readText!==void 0)Ce=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(ke)){const Ze=S.clipboardData.getData(ke);te=Ib(Ze)}te===void 0&&S.clipboardData.types.includes(Oe)&&(Ce=S.clipboardData.getData(Oe))}else return;const[Xe,Qe]=ee,At=[];do{if(he===void 0){const Ze=Or(ee),Ve=Ce??(te==null?void 0:te.map(Gn=>Gn.map(xn=>xn.rawValue).join(" ")).join(" "))??"",Yt=$(Ze,ee,Ve,void 0);Yt!==void 0&&At.push(Yt);break}if(te===void 0){if(Ce===void 0)return;te=u6(Ce)}if(he===!1||typeof he=="function"&&(he==null?void 0:he([ee[0]-X,ee[1]],te.map(Ze=>Ze.map(Ve=>{var Yt;return((Yt=Ve.rawValue)==null?void 0:Yt.toString())??""}))))!==!0)return;for(const[Ze,Ve]of te.entries()){if(Ze+Qe>=w)break;for(const[Yt,Gn]of Ve.entries()){const xn=[Yt+Xe,Ze+Qe],[gi,Bi]=xn;if(gi>=pt.length||Bi>=Xn)continue;const mi=Or(xn),zi=$(mi,xn,Gn.rawValue,Gn.formatted);zi!==void 0&&At.push(zi)}}}while(!1);Xr(At),(le=gr.current)==null||le.damage(At.map(Ze=>({cell:Ze.location})))}},[M,Te,Or,Q,fi.paste,pt.length,Xr,Xn,he,X,w]);jn("paste",ng,d,!1,!0);const cu=v.useCallback(async(S,$)=>{var G,Z;if(!fi.copy)return;const F=$===!0||((G=c.current)==null?void 0:G.contains(document.activeElement))===!0||((Z=l.current)==null?void 0:Z.contains(document.activeElement))===!0,U=Q.columns,K=Q.rows,ee=(le,te)=>{if(!Be)Db(le,te,S);else{const Ce=te.map(Oe=>({kind:Se.Text,data:y[Oe].title,displayData:y[Oe].title,allowOverlay:!1}));Db([Ce,...le],te,S)}};if(F&&An!==void 0){if(Q.current!==void 0){let le=An(Q.current.range,Kn.current.signal);typeof le!="object"&&(le=await le()),ee(le,qo(Q.current.range.x-X,Q.current.range.x+Q.current.range.width-X))}else if(K!==void 0&&K.length>0){const te=[...K].map(Ce=>{const Oe=An({x:X,y:Ce,width:y.length,height:1},Kn.current.signal);return typeof Oe=="object"?Oe[0]:Oe().then(ke=>ke[0])});if(te.some(Ce=>Ce instanceof Promise)){const Ce=await Promise.all(te);ee(Ce,qo(y.length))}else ee(te,qo(y.length))}else if(U.length>0){const le=[],te=[];for(const Ce of U){let Oe=An({x:Ce,y:0,width:1,height:w},Kn.current.signal);typeof Oe!="object"&&(Oe=await Oe()),le.push(Oe),te.push(Ce-X)}if(le.length===1)ee(le[0],te);else{const Ce=le.reduce((Oe,ke)=>Oe.map((Xe,Qe)=>[...Xe,...ke[Qe]]));ee(Ce,te)}}}},[y,An,Q,fi.copy,X,w,Be]);jn("copy",cu,d,!1,!1);const MR=v.useCallback(async S=>{var F,U;if(!(!fi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await cu(S),Q.current!==void 0)){let K={current:{cell:Q.current.cell,range:Q.current.range,rangeStack:[]},rows:Pt.empty(),columns:Pt.empty()};const ee=H==null?void 0:H(K);if(ee===!1||(K=ee===!0?K:ee,K.current===void 0))return;$o(K.current.range)}},[$o,Q,fi.cut,cu,H]);jn("cut",MR,d,!1,!1);const RR=v.useCallback((S,$)=>{if(B!==void 0){X!==0&&(S=S.map(K=>[K[0]-X,K[1]])),B(S,$);return}if(S.length===0||$===-1)return;const[F,U]=S[$];f.current!==void 0&&f.current[0]===F&&f.current[1]===U||(f.current=[F,U],zs(F,U,!1,!1))},[B,X,zs]),[xf,bf]=((qw=W==null?void 0:W.current)==null?void 0:qw.cell)??[],kf=v.useRef(wn);kf.current=wn,v.useLayoutEffect(()=>{var S,$,F,U;!Ot.current&&xf!==void 0&&bf!==void 0&&(xf!==(($=(S=$s.current)==null?void 0:S.current)==null?void 0:$.cell[0])||bf!==((U=(F=$s.current)==null?void 0:F.current)==null?void 0:U.cell[1]))&&kf.current(xf,bf),Ot.current=!1},[xf,bf]);const Ww=Q.current!==void 0&&(Q.current.cell[0]>=pt.length||Q.current.cell[1]>=Xn);v.useLayoutEffect(()=>{Ww&&pr(Yf,!1)},[Ww,pr]);const OR=v.useMemo(()=>on===!0&&(de==null?void 0:de.tint)===!0?Pt.fromSingleSelection(Xn-1):Pt.empty(),[Xn,on,de==null?void 0:de.tint]),PR=v.useCallback(S=>typeof $e=="boolean"?$e:($e==null?void 0:$e(S-X))??!0,[X,$e]),IR=v.useMemo(()=>{if(Yp===void 0||l.current===null)return null;const{bounds:S,group:$}=Yp,F=l.current.getBoundingClientRect();return v.createElement(JW,{bounds:S,group:$,canvasBounds:F,onClose:()=>Qp(void 0),onFinish:U=>{Qp(void 0),L==null||L($,U)}})},[L,Yp]),NR=Math.min(pt.length,ut+(Ar?1:0));v.useImperativeHandle(e,()=>({appendRow:(S,$)=>Ll(S+X,$),updateCells:S=>{var $;return X!==0&&(S=S.map(F=>({cell:[F.cell[0]+X,F.cell[1]]}))),($=gr.current)==null?void 0:$.damage(S)},getBounds:(S,$)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===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=gr.current)==null?void 0:F.getBounds((S??0)+X,$)}},focus:()=>{var S;return(S=gr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":uu({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":uu({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":uu({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 cu(void 0,!0);break;case"paste":await ng();break}},scrollTo:wn,remeasureColumns:S=>{for(const $ of S)wf($+X)}}),[Ll,wf,cu,uu,ng,X,wn]);const[Vw,Uw]=$i??[],DR=v.useCallback(S=>{const[$,F]=S;if(F===-1){xe!=="none"&&(ge(Pt.fromSingleSelection($),void 0,!1),sr());return}Vw===$&&Uw===F||(ne({cell:S,range:{x:$,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),wn($,F))},[xe,sr,wn,Vw,Uw,ne,ge]),[_R,LR]=v.useState(!1),Kw=v.useRef(DT(S=>{LR(S)},5)),FR=v.useCallback(()=>{Kw.current(!0),Q.current===void 0&&Q.columns.length===0&&Q.rows.length===0&&a===void 0&&ne({cell:[X,hf],range:{x:X,y:hf,width:1,height:1}},!0,!1,"keyboard-select")},[hf,Q,a,X,ne]),$R=v.useCallback(()=>{Kw.current(!1)},[]),[BR,zR]=v.useMemo(()=>{let S;const $=(sn==null?void 0:sn.scrollbarWidthOverride)??A0(),F=w+(on?1:0);if(typeof ir=="number")S=ct+F*ir;else{let K=0;const ee=Math.min(F,10);for(let G=0;Gee.width+K,0)+$;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,S)}px`]},[pt,sn==null?void 0:sn.scrollbarWidthOverride,ir,w,on,ct]),jR=v.useMemo(()=>w$(ae),[ae]);return v.createElement(x$.Provider,{value:ae},v.createElement(h6,{style:jR,className:V,inWidth:x??BR,inHeight:g??zR},v.createElement(GW,{fillHandle:Zt,drawFocusRing:On,experimental:sn,fixedShadowX:nf,fixedShadowY:Ds,getRowThemeOverride:p,headerIcons:cs,imageWindowLoader:fs,initialSize:Sl,isDraggable:rf,onDragLeave:sf,onRowMoved:Li,overscrollX:jp,overscrollY:ff,preventDiagonalScrolling:El,rightElement:No,rightElementProps:_s,smoothScrollX:lf,smoothScrollY:Fp,className:V,enableGroups:$t,onCanvasFocused:FR,onCanvasBlur:$R,canvasRef:l,onContextMenu:AR,theme:ae,cellXOffset:_o,cellYOffset:hf,accessibilityHeight:vn.height,onDragEnd:SR,columns:pt,nonGrowWidth:je,drawHeader:Up,onColumnProposeMove:D,drawCell:Kp,disabledRows:OR,freezeColumns:NR,lockColumns:X,firstColAccessible:X===0,getCellContent:Or,minColumnWidth:Er,maxColumnWidth:ci,searchInputRef:o,showSearch:ru,onSearchClose:Wp,highlightRegions:pR,getCellsForSelection:An,getGroupDetails:Gp,headerHeight:Ol,isFocused:_R,groupHeaderHeight:$t?nu:0,freezeTrailingRows:Re+(on&&(de==null?void 0:de.sticky)===!0?1:0),hasAppendRow:on,onColumnResize:di,onColumnResizeEnd:Vp,onColumnResizeStart:Il,onCellFocused:DR,onColumnMoved:bR,onDragStart:kR,onHeaderMenuClick:wR,onItemHovered:tg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:vR,onKeyDown:uu,onKeyUp:Fe,onMouseDown:gR,onMouseUp:yR,onDragOverCell:qt,onDrop:We,onSearchResultsChanged:RR,onVisibleRegionChanged:xR,clientSize:Me,rowHeight:ir,searchResults:oe,searchValue:me,onSearchValueChange:fe,rows:Xn,scrollRef:c,selection:Q,translateX:vn.tx,translateY:vn.ty,verticalBorder:PR,gridRef:gr,getCellRenderer:Te}),IR,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(w6,{...i,validateCell:iu,bloom:P,id:ER,getCellRenderer:Te,className:(sn==null?void 0:sn.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Le,imageEditorOverride:h,onFinishEditing:TR,markdownDivCreateNode:m,isOutsideClick:af}))))},S6=v.forwardRef(k6),Fb=20,C6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Se.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>T6(t,t.cell.data,k0(t.cell),t.cell.maxSize??Fb),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??Fb,f=Math.floor(i.y+l/2),d=FT(c,l,s.cellVerticalPadding),h=LT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=_T(h,f,d),m=$T(a+n,u+r,p);if(k0(e)&&m)return{...e,data:PE(e.data)}},onPaste:(t,e)=>{let n=fh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=zv),n===e.data?void 0:{...e,data:n}}};function T6(t,e,n,r){if(!n&&e===fh)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===fh&&(g*=s),g!==0&&(i.globalAlpha=g,ew(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const E6=Vr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),A6=t=>{const{bubbles:e}=t;return v.createElement(E6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},M6={getAccessibilityString:t=>BT(t.data),kind:Se.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=>O6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(A6,{bubbles:e.data})},onPaste:()=>{}},R6=4;function O6(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=R6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=qc(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)is(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+Ns(i,r))}const P6=Vr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),I6=t=>{const{drilldowns:e}=t;return v.createElement(P6,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))))},N6={getAccessibilityString:t=>BT(t.data.map(e=>e.text)),kind:Se.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=>L6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(I6,{drilldowns:e.data})},onPaste:()=>{}},D6=4,Yg={};function _6(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(Yg[d]!==void 0)return{el:Yg[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),Yg[d]=h,p.beginPath(),is(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(),is(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 L6(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=JT(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=D6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=_6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=qc(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:C,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:_}=w,P=A/O,I=_/O;for(const D of k){const Y=Math.floor(D.x),ie=Math.floor(D.width),se=ie-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,A,C,Y-I,h,P,d),se>0&&i.drawImage(b,A,0,T,C,Y+(P-I),h,se,d),i.drawImage(b,M-A,0,A,C,Y+ie-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,C]of k.entries()){const T=e[b];let A=C.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(),is(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+Ns(i,r))}}const F6={getAccessibilityString:t=>t.data.join(", "),kind:Se.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>$6(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??M4;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}}},Qg=4;function $6(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(),is(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+Qg}}function B6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const z6={getAccessibilityString:()=>"",kind:Se.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(B6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);is(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=dl(o.textDark,.1),i.fill()},onPaste:()=>{}},j6=()=>t=>t.targetWidth,$b=Vr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[j6(),"px"]}}),H6=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($b,{targetWidth:s.width-20},v.createElement(xp,{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(b4,null))):v.createElement($b,{targetWidth:s.width},v.createElement(X4,{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(Uv,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},W6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Yc,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>xs(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(H6,{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}},V6={getAccessibilityString:t=>t.row.toString(),kind:Zr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:U6,measure:()=>44,draw:t=>X6(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 U6(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=K6,n.textAlign="center",s}function K6(t){const{ctx:e}=t;e.textAlign="start"}function X6(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(ew(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+Ns(o,x)),a!==0&&(o.globalAlpha=1)}}const G6={getAccessibilityString:()=>"",kind:Zr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>q6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function q6(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+Ns(r,o)),r.beginPath()}const Y6=v.lazy(async()=>await iE(()=>import("./number-overlay-editor-_d0W8y81.js"),[])),Q6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Yc,draw:t=>xs(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(Y6,{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}}},J6={getAccessibilityString:()=>"",measure:()=>108,kind:Se.Protected,needsHover:!1,needsHoverPosition:!1,draw:Z6,onPaste:()=>{}};function Z6(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(Bx(30))*l,f=Math.sin(Bx(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 e9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Yc(t,e,t.theme.textLight),draw:t=>xs(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 Nn.createElement(xp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},t9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Yc,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=qc(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),is(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=dl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}xs(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(xp,{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}},n9=Vr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),r9=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(xp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(n9,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(Uv,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Bb(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 i9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Se.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Yc,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=qc(a,l,n.baseFontFull),f=Bb(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=Ns(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,xs({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,xs(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=f$(o,s.baseFontFull);if(l===void 0)return;const a=Bb(l,n,s,e.contentAlign);kp({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(r9,{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}},s9=[V6,G6,C6,M6,N6,F6,z6,W6,Q6,J6,e9,t9,i9];var o9=NT,l9=wl,a9="Expected a function";function u9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(a9);return l9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),o9(t,e,{leading:r,maxWait:e,trailing:i})}var c9=u9;const f9=Ni(c9),Jg=[];class d9 extends eE{constructor(){super(...arguments);xt(this,"imageLoaded",()=>{});xt(this,"loadedLocations",[]);xt(this,"cache",{});xt(this,"sendLoaded",f9(()=>{this.imageLoaded(new ec(this.loadedLocations)),this.loadedLocations=[]},20));xt(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,Jg.length<12?Jg.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(Qv(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=Ci(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Zg="\uFEFF";function h9(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 p9(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++;sl.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Fb(t,e,n){var l;const r=c6(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 DE(t){return t!==!0}function $b(t){return typeof t=="string"?t:`${t}px`}const h6=()=>t=>t.innerWidth,p6=()=>t=>t.innerHeight,g6=Vr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[h6()],"wmyidgi-1":[p6()]}}),m6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(g6,{innerHeight:$b(n),innerWidth:$b(e),...i},r)},y6=2,v6=1300;function w6(t,e,n){const r=Nn.useRef(0),[i,s]=t??[0,0];Nn.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/v6);const d=r.current**1.618*f*y6;(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 x6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Nn.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=sE();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 Ks={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 gt(t,e){return t===!0?e:t===!1?"":t}function zb(t){const e=Eh.value;return{activateCell:gt(t.activateCell," |Enter|shift+Enter"),clear:gt(t.clear,"any+Escape"),closeOverlay:gt(t.closeOverlay,"any+Escape"),acceptOverlayDown:gt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:gt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:gt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:gt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:gt(t.delete,e?"Backspace|Delete":"Delete"),downFill:gt(t.downFill,"primary+_68"),scrollToSelectedCell:gt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:gt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:gt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:gt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:gt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:gt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:gt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:gt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:gt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:gt(t.goToFirstCell,"primary+Home"),goToFirstColumn:gt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:gt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:gt(t.goToLastCell,"primary+End"),goToLastColumn:gt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:gt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:gt(t.goToNextPage,"PageDown"),goToPreviousPage:gt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:gt(t.rightFill,"primary+_82"),search:gt(t.search,"primary+f"),selectAll:gt(t.selectAll,"primary+a"),selectColumn:gt(t.selectColumn,"ctrl+ "),selectGrowDown:gt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:gt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:gt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:gt(t.selectGrowUp,"shift+ArrowUp"),selectRow:gt(t.selectRow,"shift+ "),selectToFirstCell:gt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:gt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:gt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:gt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:gt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:gt(t.selectToLastRow,"primary+shift+ArrowDown")}}function b6(t){const e=O4(t);return Nn.useMemo(()=>{if(e===void 0)return zb(Ks);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Ks.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Ks.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Ks.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Ks.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Ks.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Ks.selectToLastCell};return zb({...Ks,...n})},[e])}const k6=v.lazy(async()=>await lE(()=>import("./data-grid-overlay-editor-B9d-8QKg.js"),[]));let S6=0;function C6(t){return Az(ib(ib(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return Yo((((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 Jg={kind:Ce.Loading,allowOverlay:!1},Qf={columns:Pt.empty(),rows:Pt.empty(),current:void 0},T6=(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:C,onFillPattern:T,onFinishedEditing:E,coercePasteValue:R,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:Y="default",onGroupHeaderClicked:oe,onCellContextMenu:le,className:V,onHeaderContextMenu:Z,getCellsForSelection:M,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:B,onCellsEdited:j,onSearchResultsChanged:$,searchResults:ae,onSearchValueChange:he,searchValue:ve,onKeyDown:Fe,onKeyUp:De,keybindings:Ze,editOnType:Tt=!0,onRowAppended:et,onColumnMoved:nt,validateCell:st,highlightRegions:_t,rangeSelect:Ie="rect",columnSelect:xe="multi",rowSelect:Ne="multi",rangeSelectionBlending:Ke="exclusive",columnSelectionBlending:He="exclusive",rowSelectionBlending:Be="exclusive",onDelete:Ct,onDragStart:ot,onMouseMove:mt,onPaste:pe,copyHeaders:_e=!1,freezeColumns:tt=0,cellActivationBehavior:Xe="second-click",rowSelectionMode:Ut="auto",onHeaderMenuClick:ft,getGroupDetails:ct,onSearchClose:yt,onItemHovered:zt,onSelectionCleared:Mt,showSearch:Mn,onVisibleRegionChanged:zn,gridSelection:Wt,onGridSelectionChange:Rn,minColumnWidth:On=50,maxColumnWidth:G=500,maxColumnAutoWidth:be,provideEditor:J,trailingRowOptions:ie,freezeTrailingRows:ne=0,allowedFillDirections:Ge="orthogonal",scrollOffsetX:W,scrollOffsetY:me,verticalBorder:ge,onDragOverCell:lt,onDrop:Le,onColumnResize:Rt,onColumnResizeEnd:Et,onColumnResizeStart:ut,customRenderers:cn,fillHandle:Lt,drawFocusRing:fn=!0,experimental:Kt,fixedShadowX:rf,fixedShadowY:Ds,headerIcons:cs,imageWindowLoader:fs,initialSize:Cl,isDraggable:sf,onDragLeave:of,onRowMoved:Li,overscrollX:Tl,overscrollY:El,preventDiagonalScrolling:Al,rightElement:No,rightElementProps:_s,trapFocus:lf=!1,smoothScrollX:af,smoothScrollY:Bp,scaleToRem:jp=!1,rowHeight:Ml=34,headerHeight:ds=36,groupHeaderHeight:Hp=ds,theme:Wp,isOutsideClick:uf,renderers:Rl}=t,Tn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Ur=(Tn==null?void 0:Tn.kind)??t.rowMarkers??"none",cf=(Tn==null?void 0:Tn.width)??t.rowMarkerWidth,Ol=(Tn==null?void 0:Tn.startIndex)??t.rowMarkerStartIndex??1,eu=(Tn==null?void 0:Tn.theme)??t.rowMarkerTheme,Ls=(Tn==null?void 0:Tn.checkboxStyle)??"square",Er=Math.max(On,20),ci=Math.max(G,Er),tu=Math.max(be??ci,Er),Fs=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),nu=v.useMemo(()=>Number.parseFloat(Fs.fontSize),[Fs]),{rowHeight:ir,headerHeight:Pl,groupHeaderHeight:ru,theme:ff,overscrollX:Vp,overscrollY:df}=x6({groupHeaderHeight:Hp,headerHeight:ds,overscrollX:Tl,overscrollY:El,remSize:nu,rowHeight:Ml,scaleToRem:jp,theme:Wp}),fi=b6(Ze),hs=cf??(w>1e4?48:w>1e3?44:w>100?36:32),Ar=Ur!=="none",X=Ar?1:0,rn=et!==void 0,Do=(ie==null?void 0:ie.sticky)===!0,[Up,hf]=v.useState(!1),iu=Mn??Up,Kp=v.useCallback(()=>{yt!==void 0?yt():hf(!1)},[yt]),Q=v.useMemo(()=>Wt===void 0?void 0:Yf(Wt,X),[Wt,X])??n,Kn=v.useRef();Kn.current===void 0&&(Kn.current=new AbortController),v.useEffect(()=>()=>Kn==null?void 0:Kn.current.abort(),[]);const[En,Il]=i6(M,k,X,Kn.current,w),su=v.useCallback((S,z,F)=>{if(st===void 0)return!0;const U=[S[0]-X,S[1]];return st==null?void 0:st(U,z,F)},[X,st]),$s=v.useRef(Wt),pr=v.useCallback((S,z)=>{z&&(S=f6(S,En,X,Y,Kn.current)),Rn!==void 0?($s.current=Yf(S,-X),Rn($s.current)):r(S)},[Rn,En,X,Y]),di=Hl(Rt,v.useCallback((S,z,F,U)=>{Rt==null||Rt(y[F-X],z,F-X,U)},[Rt,X,y])),Xp=Hl(Et,v.useCallback((S,z,F,U)=>{Et==null||Et(y[F-X],z,F-X,U)},[Et,X,y])),Nl=Hl(ut,v.useCallback((S,z,F,U)=>{ut==null||ut(y[F-X],z,F-X,U)},[ut,X,y])),Gp=Hl(O,v.useCallback((S,z)=>(O==null?void 0:O({...S,columnIndex:S.columnIndex-X},z))??!1,[O,X])),qp=Hl(_,v.useCallback((S,z)=>(_==null?void 0:_({...S,col:S.col-X},z))??!1,[_,X])),H=v.useCallback(S=>{if(Ct!==void 0){const z=Ct(Yf(S,-X));return typeof z=="boolean"?z:Yf(z,X)}return!0},[Ct,X]),[se,ke,ye]=r6(Q,pr,Ke,He,Be,Ie),ce=v.useMemo(()=>wo(sE(),ff),[ff]),[Me,rt]=v.useState([0,0,0]),it=v.useMemo(()=>{if(Rl===void 0)return{};const S={};for(const z of Rl)S[z.kind]=z;return S},[Rl]),Ee=v.useCallback(S=>S.kind!==Ce.Custom?it[S.kind]:cn==null?void 0:cn.find(z=>z.isMatch(S)),[cn,it]);let{sizedColumns:Dt,nonGrowWidth:$e}=T$(y,w,Il,Me[0]-(X===0?0:hs)-Me[2],Er,tu,ce,Ee,Kn.current);Ur!=="none"&&($e+=hs);const $t=v.useMemo(()=>Dt.some(S=>S.group!==void 0),[Dt]),at=$t?Pl+ru:Pl,xt=Q.rows.length,yn=Ur==="none"?void 0:xt===0?!1:xt===w?!0:void 0,dt=v.useMemo(()=>Ur==="none"?Dt:[{title:"",width:hs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:eu,rowMarker:Ls,rowMarkerChecked:yn},...Dt],[Ur,Dt,hs,eu,Ls,yn]),[dn,Kr]=v.useMemo(()=>[me!==void 0&&typeof ir=="number"?Math.floor(me/ir):0,me!==void 0&&typeof ir=="number"?-(me%ir):0],[me,ir]),sn=v.useRef({height:1,width:1,x:0,y:0}),Mr=v.useMemo(()=>({x:sn.current.x,y:dn,width:sn.current.width??1,height:sn.current.height??1,ty:Kr}),[Kr,dn]),Ot=v.useRef(!1),[vn,Rr,Fi]=R4(Mr);sn.current=vn;const hi=(vn.height??1)>1;v.useLayoutEffect(()=>{if(me!==void 0&&c.current!==null&&hi){if(c.current.scrollTop===me)return;c.current.scrollTop=me,c.current.scrollTop!==me&&Fi(),Ot.current=!0}},[me,hi,Fi]);const Dl=(vn.width??1)>1;v.useLayoutEffect(()=>{if(W!==void 0&&c.current!==null&&Dl){if(c.current.scrollLeft===W)return;c.current.scrollLeft=W,c.current.scrollLeft!==W&&Fi(),Ot.current=!0}},[W,Dl,Fi]);const _o=vn.x+X,pf=vn.y,gr=v.useRef(null),sr=v.useCallback(S=>{var z;S===!0?(z=gr.current)==null||z.focus():window.requestAnimationFrame(()=>{var F;(F=gr.current)==null||F.focus()})},[]),Xn=rn?w+1:w,Xr=v.useCallback(S=>{const z=X===0?S:S.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),F=j==null?void 0:j(z);if(F!==!0)for(const U of z)B==null||B(U.location,U.value);return F},[B,j,X]),[Lo,Yp]=v.useState(),gf=Q.current!==void 0&&Q.current.range.width*Q.current.range.height>1?Q.current.range:void 0,_l=fn?(Yw=Q.current)==null?void 0:Yw.cell:void 0,mf=_l==null?void 0:_l[0],yf=_l==null?void 0:_l[1],yR=v.useMemo(()=>{if((_t===void 0||_t.length===0)&&(gf??mf??yf??Lo)===void 0)return;const S=[];if(_t!==void 0)for(const z of _t){const F=dt.length-z.range.x-X;F>0&&S.push({color:z.color,range:{...z.range,x:z.range.x+X,width:Math.min(F,z.range.width)},style:z.style})}return Lo!==void 0&&S.push({color:hl(ce.accentColor,0),range:Lo,style:"dashed"}),gf!==void 0&&S.push({color:hl(ce.accentColor,.5),range:gf,style:"solid-outline"}),mf!==void 0&&yf!==void 0&&S.push({color:ce.accentColor,range:{x:mf,y:yf,width:1,height:1},style:"solid-outline"}),S.length>0?S:void 0},[Lo,gf,mf,yf,_t,dt.length,ce.accentColor,X]),Fw=v.useRef(dt);Fw.current=dt;const Or=v.useCallback(([S,z],F=!1)=>{var te,q,ee,ue,re,Te,Re;const U=rn&&z===Xn-1;if(S===0&&Ar)return U?Jg:{kind:Zr.Marker,allowOverlay:!1,checkboxStyle:Ls,checked:(Q==null?void 0:Q.rows.hasIndex(z))===!0,markerKind:Ur==="clickable-number"?"number":Ur,row:Ol+z,drawHandle:Li!==void 0,cursor:Ur==="clickable-number"?"pointer":void 0};if(U){const We=S===X?(ie==null?void 0:ie.hint)??"":"",qe=Fw.current[S];if(((te=qe==null?void 0:qe.trailingRowOptions)==null?void 0:te.disabled)===!0)return Jg;{const At=((q=qe==null?void 0:qe.trailingRowOptions)==null?void 0:q.hint)??We,Qe=((ee=qe==null?void 0:qe.trailingRowOptions)==null?void 0:ee.addIcon)??(ie==null?void 0:ie.addIcon);return{kind:Zr.NewRow,hint:At,allowOverlay:!1,icon:Qe}}}else{const Se=S-X;if(F||(Kt==null?void 0:Kt.strict)===!0){const qe=sn.current,At=qe.x>Se||Se>qe.x+qe.width||qe.y>z||z>qe.y+qe.height||z>=Jp.current,Qe=Se===((re=(ue=qe.extras)==null?void 0:ue.selected)==null?void 0:re[0])&&z===((Te=qe.extras)==null?void 0:Te.selected[1]);let je=!1;if(((Re=qe.extras)==null?void 0:Re.freezeRegions)!==void 0){for(const Yt of qe.extras.freezeRegions)if(Tp(Yt,Se,z)){je=!0;break}}if(At&&!Qe&&!je)return Jg}let We=k([Se,z]);return X!==0&&We.span!==void 0&&(We={...We,span:[We.span[0]+X,We.span[1]+X]}),We}},[rn,Xn,Ar,Ls,Q==null?void 0:Q.rows,Ur,Ol,Li,X,ie==null?void 0:ie.hint,ie==null?void 0:ie.addIcon,Kt==null?void 0:Kt.strict,k]),Qp=v.useCallback(S=>{let z=(ct==null?void 0:ct(S))??{name:S};return L!==void 0&&S!==""&&(z={icon:z.icon,name:z.name,overrideTheme:z.overrideTheme,actions:[...z.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>eg({group:z.name,bounds:F.bounds})}]}),z},[ct,L]),vf=v.useCallback(S=>{var ee;const[z,F]=S.cell,U=dt[z],K=(U==null?void 0:U.group)!==void 0?(ee=Qp(U.group))==null?void 0:ee.overrideTheme:void 0,te=U==null?void 0:U.themeOverride,q=p==null?void 0:p(F);s({...S,theme:wo(ce,K,te,q,S.content.themeOverride)})},[p,dt,Qp,ce]),Ll=v.useCallback((S,z,F)=>{var q;if(Q.current===void 0)return;const[U,K]=Q.current.cell,te=Or([U,K]);if(te.kind!==Ce.Boolean&&te.allowOverlay){let ee=te;if(F!==void 0)switch(ee.kind){case Ce.Number:{const ue=cD(()=>F==="-"?-0:Number.parseFloat(F),0);ee={...ee,data:Number.isNaN(ue)?0:ue};break}case Ce.Text:case Ce.Markdown:case Ce.Uri:ee={...ee,data:F};break}vf({target:S,content:ee,initialValue:F,cell:[U,K],highlight:F===void 0,forceEditMode:F!==void 0})}else te.kind===Ce.Boolean&&z&&te.readonly!==!0&&(Xr([{location:Q.current.cell,value:{...te,data:DE(te.data)}}]),(q=gr.current)==null||q.damage([{cell:Q.current.cell}]))},[Or,Q,Xr,vf]),$w=v.useCallback((S,z)=>{var K;const F=(K=gr.current)==null?void 0:K.getBounds(S,z);if(F===void 0||c.current===null)return;const U=Or([S,z]);U.allowOverlay&&vf({target:F,content:U,initialValue:void 0,highlight:!0,cell:[S,z],forceEditMode:!0})},[Or,vf]),wn=v.useCallback((S,z,F="both",U=0,K=0,te=void 0)=>{if(c.current!==null){const q=gr.current,ee=l.current,ue=typeof S!="number"?S.unit==="cell"?S.amount:void 0:S,re=typeof z!="number"?z.unit==="cell"?z.amount:void 0:z,Te=typeof S!="number"&&S.unit==="px"?S.amount:void 0,Re=typeof z!="number"&&z.unit==="px"?z.amount:void 0;if(q!==null&&ee!==null){let Se={x:0,y:0,width:0,height:0},We=0,qe=0;if((ue!==void 0||re!==void 0)&&(Se=q.getBounds((ue??0)+X,re??0)??Se,Se.width===0||Se.height===0))return;const At=ee.getBoundingClientRect(),Qe=At.width/ee.offsetWidth;if(Te!==void 0&&(Se={...Se,x:Te-At.left-c.current.scrollLeft,width:1}),Re!==void 0&&(Se={...Se,y:Re+At.top-c.current.scrollTop,height:1}),Se!==void 0){const je={x:Se.x-U,y:Se.y-K,width:Se.width+2*U,height:Se.height+2*K};let Yt=0;for(let og=0;og0&&(Gn=Sl(Xn,xn,ir));let gi=Yt*Qe+At.left+X*hs*Qe,zi=At.right,mi=At.top+at*Qe,Bi=At.bottom-Gn*Qe;const Cf=Se.width+U*2;switch(te==null?void 0:te.hAlign){case"start":zi=gi+Cf;break;case"end":gi=zi-Cf;break;case"center":gi=Math.floor((gi+zi)/2)-Cf/2,zi=gi+Cf;break}const Tf=Se.height+K*2;switch(te==null?void 0:te.vAlign){case"start":Bi=mi+Tf;break;case"end":mi=Bi-Tf;break;case"center":mi=Math.floor((mi+Bi)/2)-Tf/2,Bi=mi+Tf;break}gi>je.x?We=je.x-gi:zije.y?qe=je.y-mi:Bi=Xn-xn)&&(qe=0),(We!==0||qe!==0)&&(Qe!==1&&(We/=Qe,qe/=Qe),c.current.scrollTo(We+c.current.scrollLeft,qe+c.current.scrollTop))}}}},[X,ne,hs,at,tt,Dt,Xn,Do,ir]),zw=v.useRef($w),Bw=v.useRef(k),Jp=v.useRef(w);zw.current=$w,Bw.current=k,Jp.current=w;const Fl=v.useCallback(async(S,z=!0)=>{var ue;const F=dt[S];if(((ue=F==null?void 0:F.trailingRowOptions)==null?void 0:ue.disabled)===!0)return;const U=et==null?void 0:et();let K,te=!0;U!==void 0&&(K=await U,K==="top"&&(te=!1),typeof K=="number"&&(te=!1));let q=0;const ee=()=>{if(Jp.current<=w){q<500&&window.setTimeout(ee,q),q=50+q*2;return}const re=typeof K=="number"?K:te?w:0;Sf.current(S-X,re),se({cell:[S,re],range:{x:S,y:re,width:1,height:1}},!1,!1,"edit");const Te=Bw.current([S-X,re]);Te.allowOverlay&&Fu(Te)&&Te.readonly!==!0&&z&&window.setTimeout(()=>{zw.current(S,re)},0)};ee()},[dt,et,X,w,se]),wf=v.useCallback(S=>{var F,U;const z=((U=(F=Dt[S])==null?void 0:F.trailingRowOptions)==null?void 0:U.targetColumn)??(ie==null?void 0:ie.targetColumn);if(typeof z=="number")return z+(Ar?1:0);if(typeof z=="object"){const K=y.indexOf(z);if(K>=0)return K+(Ar?1:0)}},[Dt,y,Ar,ie==null?void 0:ie.targetColumn]),zs=v.useRef(),$l=v.useRef(),ou=v.useCallback((S,z)=>{var K;const[F,U]=z;return wo(ce,(K=dt[F])==null?void 0:K.themeOverride,p==null?void 0:p(U),S.themeOverride)},[p,dt,ce]),lu=v.useCallback(S=>{var Te,Re,Se;const z=Eh.value?S.metaKey:S.ctrlKey,F=z&&Ne==="multi",U=z&&xe==="multi",[K,te]=S.location,q=Q.columns,ee=Q.rows,[ue,re]=((Te=Q.current)==null?void 0:Te.cell)??[];if(S.kind==="cell"){if($l.current=void 0,Fo.current=[K,te],K===0&&Ar){if(rn===!0&&te===w||Ur==="number"||Ne==="none")return;const We=Or(S.location);if(We.kind!==Zr.Marker)return;if(Li!==void 0){const Qe=Ee(We);Lr((Qe==null?void 0:Qe.kind)===Zr.Marker);const je=(Re=Qe==null?void 0:Qe.onClick)==null?void 0:Re.call(Qe,{...S,cell:We,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,theme:ou(We,S.location),preventDefault:()=>{}});if(je===void 0||je.checked===We.checked)return}s(void 0),sr();const qe=ee.hasIndex(te),At=zs.current;if(Ne==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&At!==void 0&&ee.hasIndex(At)){const Qe=[Math.min(At,te),Math.max(At,te)+1];F||Ut==="multi"?ke(void 0,Qe,!0):ke(Pt.fromSingleSelection(Qe),void 0,F)}else F||S.isTouch||Ut==="multi"?qe?ke(ee.remove(te),void 0,!0):(ke(void 0,te,!0),zs.current=te):qe&&ee.length===1?ke(Pt.empty(),void 0,z):(ke(Pt.fromSingleSelection(te),void 0,z),zs.current=te)}else if(K>=X&&rn&&te===w){const We=wf(K);Fl(We??K)}else if(ue!==K||re!==te){const We=Or(S.location),qe=Ee(We);if((qe==null?void 0:qe.onSelect)!==void 0){let je=!1;if(qe.onSelect({...S,cell:We,posX:S.localEventX,posY:S.localEventY,bounds:S.bounds,preventDefault:()=>je=!0,theme:ou(We,S.location)}),je)return}const At=Do&&te===w,Qe=Do&&Q!==void 0&&((Se=Q.current)==null?void 0:Se.cell[1])===w;if((S.shiftKey||S.isLongTouch===!0)&&ue!==void 0&&re!==void 0&&Q.current!==void 0&&!Qe){if(At)return;const je=Math.min(K,ue),Yt=Math.max(K,ue),Gn=Math.min(te,re),xn=Math.max(te,re);se({...Q.current,range:{x:je,y:Gn,width:Yt-je+1,height:xn-Gn+1}},!0,z,"click"),zs.current=void 0,sr()}else se({cell:[K,te],range:{x:K,y:te,width:1,height:1}},!0,z,"click"),zs.current=void 0,s(void 0),sr()}}else if(S.kind==="header")if(Fo.current=[K,te],s(void 0),Ar&&K===0)zs.current=void 0,$l.current=void 0,Ne==="multi"&&(ee.length!==w?ke(Pt.fromSingleSelection([0,w]),void 0,z):ke(Pt.empty(),void 0,z),sr());else{const We=$l.current;if(xe==="multi"&&(S.shiftKey||S.isLongTouch===!0)&&We!==void 0&&q.hasIndex(We)){const qe=[Math.min(We,K),Math.max(We,K)+1];U?ye(void 0,qe,z):ye(Pt.fromSingleSelection(qe),void 0,z)}else U?(q.hasIndex(K)?ye(q.remove(K),void 0,z):ye(void 0,K,z),$l.current=K):xe!=="none"&&(ye(Pt.fromSingleSelection(K),void 0,z),$l.current=K);zs.current=void 0,sr()}else S.kind===_r?Fo.current=[K,te]:S.kind===Ah&&!S.isMaybeScrollbar&&(pr(Qf,!1),s(void 0),sr(),Mt==null||Mt(),zs.current=void 0,$l.current=void 0)},[Fl,xe,sr,Ee,wf,Or,Q,Ar,Do,Mt,Li,X,Ur,Ne,Ut,w,se,pr,ye,ke,rn,ou]),au=v.useRef(!1),Fo=v.useRef(),jw=v.useRef(vn),Gr=v.useRef(),vR=v.useCallback(S=>{if(zl.current=!1,jw.current=sn.current,S.button!==0&&S.button!==1){Gr.current=void 0;return}const z=performance.now();Gr.current={button:S.button,time:z,location:S.location},(S==null?void 0:S.kind)==="header"&&(au.current=!0);const F=S.kind==="cell"&&S.isFillHandle;!F&&S.kind!=="cell"&&S.isEdge||(u({previousSelection:Q,fillHandle:F}),Fo.current=void 0,!S.isTouch&&S.button===0&&!F?lu(S):!S.isTouch&&S.button===1&&(Fo.current=S.location))},[Q,lu]),[Zp,eg]=v.useState(),Hw=v.useCallback(S=>{if(S.kind!==_r||xe!=="multi")return;const z=Eh.value?S.metaKey:S.ctrlKey,[F]=S.location,U=Q.columns;if(F=X&&Ac(K.group,dt[ee].group);ee--)te--;for(let ee=F+1;ee{if(En!==void 0&&di!==void 0){const z=sn.current.y,F=sn.current.height;let U=En({x:S,y:z,width:1,height:Math.min(F,w-z)},Kn.current.signal);typeof U!="object"&&(U=await U());const K=Dt[S-X],q=document.createElement("canvas").getContext("2d",{alpha:!1});if(q!==null){q.font=ce.baseFontFull;const ee=oE(q,ce,K,0,U,Er,ci,!1,Ee);di==null||di(K,ee.width,S,ee.width)}}},[Dt,En,ci,ce,Er,di,X,w,Ee]),[wR,tg]=v.useState(),Bl=v.useCallback(async(S,z)=>{var ee,ue;const F=(ee=S.current)==null?void 0:ee.range;if(F===void 0||En===void 0||z.current===void 0)return;const U=z.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=En(F,Kn.current.signal);typeof K!="object"&&(K=await K());const te=K,q=[];for(let re=0;re({cell:re.location})))},[En,Xr,T,X]),Ww=v.useCallback(()=>{if(Q.current===void 0||Q.current.range.width<=1)return;const S={...Q,current:{...Q.current,range:{...Q.current.range,width:1}}};Bl(S,Q)},[Bl,Q]),Vw=v.useCallback(()=>{if(Q.current===void 0||Q.current.range.height<=1)return;const S={...Q,current:{...Q.current,range:{...Q.current.range,height:1}}};Bl(S,Q)},[Bl,Q]),xR=v.useCallback((S,z)=>{var Te,Re;const F=a;if(u(void 0),Yp(void 0),tg(void 0),au.current=!1,z)return;if((F==null?void 0:F.fillHandle)===!0&&Q.current!==void 0&&((Te=F.previousSelection)==null?void 0:Te.current)!==void 0){if(Lo===void 0)return;const Se={...Q,current:{...Q.current,range:mE(F.previousSelection.current.range,Lo)}};Bl(F.previousSelection,Se),pr(Se,!0);return}const[U,K]=S.location,[te,q]=Fo.current??[],ee=()=>{zl.current=!0},ue=Se=>{var qe,At,Qe;const We=Se.isTouch||te===U&&q===K;if(We&&(b==null||b([U-X,K],{...Se,preventDefault:ee})),Se.button===1)return!zl.current;if(!zl.current){const je=Or(S.location),Yt=Ee(je);if(Yt!==void 0&&Yt.onClick!==void 0&&We){const xn=Yt.onClick({...Se,cell:je,posX:Se.localEventX,posY:Se.localEventY,bounds:Se.bounds,theme:ou(je,S.location),preventDefault:ee});xn!==void 0&&!oa(xn)&&Ul(xn)&&(Xr([{location:Se.location,value:xn}]),(qe=gr.current)==null||qe.damage([{cell:Se.location}]))}if(zl.current||Q.current===void 0)return!1;let Gn=!1;switch(je.activationBehaviorOverride??Xe){case"double-click":case"second-click":{if(((Qe=(At=F==null?void 0:F.previousSelection)==null?void 0:At.current)==null?void 0:Qe.cell)===void 0)break;const[xn,gi]=Q.current.cell,[zi,mi]=F.previousSelection.current.cell;Gn=U===xn&&U===zi&&K===gi&&K===mi&&(Se.isDoubleClick===!0||Xe==="second-click");break}case"single-click":{Gn=!0;break}}if(Gn)return C==null||C([U-X,K]),Ll(Se.bounds,!1),!0}return!1},re=S.location[0]-X;if(S.isTouch){const Se=sn.current,We=jw.current;if(Se.x!==We.x||Se.y!==We.y)return;if(S.isLongTouch===!0){if(S.kind==="cell"&&Zu((Re=Q.current)==null?void 0:Re.cell,S.location)){le==null||le([re,S.location[1]],{...S,preventDefault:ee});return}else if(S.kind==="header"&&Q.columns.hasIndex(U)){Z==null||Z(re,{...S,preventDefault:ee});return}else if(S.kind===_r){if(re<0)return;N==null||N(re,{...S,preventDefault:ee});return}}S.kind==="cell"?ue(S)||lu(S):S.kind===_r?oe==null||oe(re,{...S,preventDefault:ee}):(S.kind===qs&&(I==null||I(re,{...S,preventDefault:ee})),lu(S));return}if(S.kind==="header"){if(re<0)return;S.isEdge?S.isDoubleClick===!0&&xf(U):S.button===0&&U===te&&K===q&&(I==null||I(re,{...S,preventDefault:ee}))}if(S.kind===_r){if(re<0)return;S.button===0&&U===te&&K===q&&(oe==null||oe(re,{...S,preventDefault:ee}),zl.current||Hw(S))}S.kind==="cell"&&(S.button===0||S.button===1)&&ue(S),Fo.current=void 0},[a,Q,X,Lo,Bl,pr,b,Or,Ee,Xe,ou,Xr,C,Ll,le,Z,N,lu,oe,I,xf,Hw]),bR=v.useCallback(S=>{const z={...S,location:[S.location[0]-X,S.location[1]]};mt==null||mt(z),a!==void 0&&S.buttons===0&&(u(void 0),Yp(void 0),tg(void 0),au.current=!1),tg(F=>{var U;return au.current?[S.scrollEdge[0],0]:S.scrollEdge[0]===(F==null?void 0:F[0])&&S.scrollEdge[1]===F[1]?F:a===void 0||(((U=Gr.current)==null?void 0:U.location[0])??0){ft==null||ft(S-X,z)},[ft,X]),$i=(Qw=Q==null?void 0:Q.current)==null?void 0:Qw.cell,SR=v.useCallback((S,z,F,U,K,te)=>{Ot.current=!1;let q=$i;q!==void 0&&(q=[q[0]-X,q[1]]);const ee=tt===0?void 0:{x:0,y:S.y,width:tt,height:S.height},ue=[];ee!==void 0&&ue.push(ee),ne>0&&(ue.push({x:S.x-X,y:w-ne,width:S.width,height:ne}),tt>0&&ue.push({x:0,y:w-ne,width:tt,height:ne}));const re={x:S.x-X,y:S.y,width:S.width,height:rn&&S.y+S.height>=w?S.height-1:S.height,tx:K,ty:te,extras:{selected:q,freezeRegion:ee,freezeRegions:ue}};sn.current=re,Rr(re),rt([z,F,U]),zn==null||zn(re,re.tx,re.ty,re.extras)},[$i,X,rn,w,tt,ne,Rr,zn]),CR=Hl(nt,v.useCallback((S,z)=>{nt==null||nt(S-X,z-X),xe!=="none"&&ye(Pt.fromSingleSelection(z),void 0,!0)},[xe,nt,X,ye])),ng=v.useRef(!1),TR=v.useCallback(S=>{if(S.location[0]===0&&X>0){S.preventDefault();return}ot==null||ot({...S,location:[S.location[0]-X,S.location[1]]}),S.defaultPrevented()||(ng.current=!0),u(void 0)},[ot,X]),ER=v.useCallback(()=>{ng.current=!1},[]),rg=v.useRef(),ig=v.useCallback(S=>{var z,F,U;if(!IE(S,rg.current)&&(rg.current=S,!(((z=Gr==null?void 0:Gr.current)==null?void 0:z.button)!==void 0&&Gr.current.button>=1))){if(S.buttons!==0&&a!==void 0&&((F=Gr.current)==null?void 0:F.location[0])===0&&S.location[0]===0&&X===1&&Ne==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(Gr.current.location[1])&&Q.rows.hasIndex(Gr.current.location[1])){const K=Math.min(Gr.current.location[1],S.location[1]),te=Math.max(Gr.current.location[1],S.location[1])+1;ke(Pt.fromSingleSelection([K,te]),void 0,!1)}if(S.buttons!==0&&a!==void 0&&Q.current!==void 0&&!ng.current&&!au.current&&(Ie==="rect"||Ie==="multi-rect")){const[K,te]=Q.current.cell;let[q,ee]=S.location;if(ee<0&&(ee=sn.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const ue=a.previousSelection.current.range;ee=Math.min(ee,rn?w-1:w);const re=fB(ue,q,ee,Ge);Yp(re)}else{if(rn&&te===w)return;if(rn&&ee===w)if(S.kind===Ah)ee--;else return;q=Math.max(q,X);const Te=q-K,Re=ee-te,Se={x:Te>=0?K:q,y:Re>=0?te:ee,width:Math.abs(Te)+1,height:Math.abs(Re)+1};se({...Q.current,range:Se},!0,!1,"drag")}}zt==null||zt({...S,location:[S.location[0]-X,S.location[1]]})}},[Ge,a,X,Ne,Q,Ie,zt,ke,rn,w,se]),AR=v.useCallback(()=>{var q,ee;const S=rg.current;if(S===void 0)return;const[z,F]=S.scrollEdge;let[U,K]=S.location;const te=sn.current;z===-1?U=((ee=(q=te.extras)==null?void 0:q.freezeRegion)==null?void 0:ee.x)??te.x:z===1&&(U=te.x+te.width),F===-1?K=Math.max(0,te.y):F===1&&(K=Math.min(w-1,te.y+te.height)),U=Si(U,0,dt.length-1),K=Si(K,0,w-1),ig({...S,location:[U,K]})},[dt.length,ig,w]);w6(wR,c,AR);const pi=v.useCallback(S=>{if(Q.current===void 0)return;const[z,F]=S,[U,K]=Q.current.cell,te=Q.current.range;let q=te.x,ee=te.x+te.width,ue=te.y,re=te.y+te.height;if(F!==0)switch(F){case 2:{re=w,ue=K,wn(0,re,"vertical");break}case-2:{ue=0,re=K+1,wn(0,ue,"vertical");break}case 1:{ueK+1?(re--,wn(0,re,"vertical")):(ue=Math.max(0,ue-1),wn(0,ue,"vertical"));break}default:Ec()}if(z!==0)if(z===2)ee=dt.length,q=U,wn(ee-1-X,0,"horizontal");else if(z===-2)q=X,ee=U+1,wn(q-X,0,"horizontal");else{let Te=[];if(En!==void 0){const Re=En({x:q,y:ue,width:ee-q-X,height:re-ue},Kn.current.signal);typeof Re=="object"&&(Te=C6(Re))}if(z===1){let Re=!1;if(q0){const Se=Yo(q+1,U+1).find(We=>!Te.includes(We-X));Se!==void 0&&(q=Se,Re=!0)}else q++,Re=!0;Re&&wn(q,0,"horizontal")}Re||(ee=Math.min(dt.length,ee+1),wn(ee-1-X,0,"horizontal"))}else if(z===-1){let Re=!1;if(ee>U+1){if(Te.length>0){const Se=Yo(ee-1,U,-1).find(We=>!Te.includes(We-X));Se!==void 0&&(ee=Se,Re=!0)}else ee--,Re=!0;Re&&wn(ee-X,0,"horizontal")}Re||(q=Math.max(X,q-1),wn(q-X,0,"horizontal"))}else Ec()}se({cell:Q.current.cell,range:{x:q,y:ue,width:ee-q,height:re-ue}},!0,!1,"keyboard-select")},[En,Q,dt.length,X,w,wn,se]),Bs=v.useCallback((S,z,F,U)=>{const K=Xn-(F?0:1);if(S=Si(S,X,Dt.length-1+X),z=Si(z,0,K),S===($i==null?void 0:$i[0])&&z===($i==null?void 0:$i[1]))return!1;if(U&&Q.current!==void 0){const te=[...Q.current.rangeStack];(Q.current.range.width>1||Q.current.range.height>1)&&te.push(Q.current.range),pr({...Q,current:{cell:[S,z],range:{x:S,y:z,width:1,height:1},rangeStack:te}},!0)}else se({cell:[S,z],range:{x:S,y:z,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===S&&f.current[1]===z&&(f.current=void 0),wn(S-X,z),!0},[Xn,X,Dt.length,$i,Q,wn,pr,se]),MR=v.useCallback((S,z)=>{(i==null?void 0:i.cell)!==void 0&&S!==void 0&&Ul(S)&&(Xr([{location:i.cell,value:S}]),window.requestAnimationFrame(()=>{var K;(K=gr.current)==null||K.damage([{cell:i.cell}])})),sr(!0),s(void 0);const[F,U]=z;if(Q.current!==void 0&&(F!==0||U!==0)){const K=Q.current.cell[1]===Xn-1&&S!==void 0;Bs(Si(Q.current.cell[0]+F,0,dt.length-1),Si(Q.current.cell[1]+U,0,Xn-1),K,!1)}E==null||E(S,z)},[i==null?void 0:i.cell,sr,Q,E,Xr,Xn,Bs,dt.length]),RR=v.useMemo(()=>`gdg-overlay-${S6++}`,[]),$o=v.useCallback(S=>{var F,U,K,te;sr();const z=[];for(let q=S.x;q({cell:q.location})))},[sr,k,Ee,Xr,X]),uu=i!==void 0,Uw=v.useCallback(S=>{var We,qe;const z=()=>{S.stopPropagation(),S.preventDefault()},F={didMatch:!1},{bounds:U}=S,K=Q.columns,te=Q.rows,q=fi;if(!uu&&pt(q.clear,S,F))pr(Qf,!1),Mt==null||Mt();else if(!uu&&pt(q.selectAll,S,F))pr({columns:Pt.empty(),rows:Pt.empty(),current:{cell:((We=Q.current)==null?void 0:We.cell)??[X,0],range:{x:X,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(pt(q.search,S,F))(qe=o==null?void 0:o.current)==null||qe.focus({preventScroll:!0}),hf(!0);else if(pt(q.delete,S,F)){const At=(H==null?void 0:H(Q))??!0;if(At!==!1){const Qe=At===!0?Q:At;if(Qe.current!==void 0){$o(Qe.current.range);for(const je of Qe.current.rangeStack)$o(je)}for(const je of Qe.rows)$o({x:X,y:je,width:y.length,height:1});for(const je of Qe.columns)$o({x:je,y:0,width:1,height:w})}}if(F.didMatch)return z(),!0;if(Q.current===void 0)return!1;let[ee,ue]=Q.current.cell,re=!1,Te=!1;pt(q.scrollToSelectedCell,S,F)?Sf.current(ee-X,ue):xe!=="none"&&pt(q.selectColumn,S,F)?K.hasIndex(ee)?ye(K.remove(ee),void 0,!0):xe==="single"?ye(Pt.fromSingleSelection(ee),void 0,!0):ye(void 0,ee,!0):Ne!=="none"&&pt(q.selectRow,S,F)?te.hasIndex(ue)?ke(te.remove(ue),void 0,!0):Ne==="single"?ke(Pt.fromSingleSelection(ue),void 0,!0):ke(void 0,ue,!0):!uu&&U!==void 0&&pt(q.activateCell,S,F)?ue===w&&rn?window.setTimeout(()=>{const At=wf(ee);Fl(At??ee)},0):(C==null||C([ee-X,ue]),Ll(U,!0)):Q.current.range.height>1&&pt(q.downFill,S,F)?Vw():Q.current.range.width>1&&pt(q.rightFill,S,F)?Ww():pt(q.goToNextPage,S,F)?ue+=Math.max(1,sn.current.height-4):pt(q.goToPreviousPage,S,F)?ue-=Math.max(1,sn.current.height-4):pt(q.goToFirstCell,S,F)?(s(void 0),ue=0,ee=0):pt(q.goToLastCell,S,F)?(s(void 0),ue=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):pt(q.selectToFirstCell,S,F)?(s(void 0),pi([-2,-2])):pt(q.selectToLastCell,S,F)?(s(void 0),pi([2,2])):uu?(pt(q.closeOverlay,S,F)&&s(void 0),pt(q.acceptOverlayDown,S,F)&&(s(void 0),ue++),pt(q.acceptOverlayUp,S,F)&&(s(void 0),ue--),pt(q.acceptOverlayLeft,S,F)&&(s(void 0),ee--),pt(q.acceptOverlayRight,S,F)&&(s(void 0),ee++)):(pt(q.goDownCell,S,F)?ue+=1:pt(q.goUpCell,S,F)?ue-=1:pt(q.goRightCell,S,F)?ee+=1:pt(q.goLeftCell,S,F)?ee-=1:pt(q.goDownCellRetainSelection,S,F)?(ue+=1,re=!0):pt(q.goUpCellRetainSelection,S,F)?(ue-=1,re=!0):pt(q.goRightCellRetainSelection,S,F)?(ee+=1,re=!0):pt(q.goLeftCellRetainSelection,S,F)?(ee-=1,re=!0):pt(q.goToLastRow,S,F)?ue=w-1:pt(q.goToFirstRow,S,F)?ue=Number.MIN_SAFE_INTEGER:pt(q.goToLastColumn,S,F)?ee=Number.MAX_SAFE_INTEGER:pt(q.goToFirstColumn,S,F)?ee=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(pt(q.selectGrowDown,S,F)?pi([0,1]):pt(q.selectGrowUp,S,F)?pi([0,-1]):pt(q.selectGrowRight,S,F)?pi([1,0]):pt(q.selectGrowLeft,S,F)?pi([-1,0]):pt(q.selectToLastRow,S,F)?pi([0,2]):pt(q.selectToFirstRow,S,F)?pi([0,-2]):pt(q.selectToLastColumn,S,F)?pi([2,0]):pt(q.selectToFirstColumn,S,F)&&pi([-2,0])),Te=F.didMatch);const Re=Bs(ee,ue,!1,re),Se=F.didMatch;return Se&&(Re||!Te||lf)&&z(),Se},[uu,Q,fi,xe,Ne,Ie,X,w,Bs,pr,Mt,y.length,H,lf,$o,ye,ke,rn,wf,Fl,C,Ll,Vw,Ww,pi]),cu=v.useCallback(S=>{let z=!1;if(Fe!==void 0&&Fe({...S,cancel:()=>{z=!0}}),z||Uw(S)||Q.current===void 0)return;const[F,U]=Q.current.cell,K=sn.current;if(Tt&&!S.metaKey&&!S.ctrlKey&&Q.current!==void 0&&S.key.length===1&&/[ -~]/g.test(S.key)&&S.bounds!==void 0&&Fu(k([F-X,Math.max(0,Math.min(U,w-1))]))){if((!rn||U!==w)&&(K.y>U||U>K.y+K.height||K.x>F||F>K.x+K.width))return;Ll(S.bounds,!0,S.key),S.stopPropagation(),S.preventDefault()}},[Tt,Fe,Uw,Q,k,X,w,rn,Ll]),OR=v.useCallback((S,z)=>{const F=S.location[0]-X;if(S.kind==="header"&&(Z==null||Z(F,{...S,preventDefault:z})),S.kind===_r){if(F<0)return;N==null||N(F,{...S,preventDefault:z})}if(S.kind==="cell"){const[U,K]=S.location;le==null||le([F,K],{...S,preventDefault:z}),l$(Q,S.location)||Bs(U,K,!1,!1)}},[Q,le,N,Z,X,Bs]),sg=v.useCallback(async S=>{var q,ee,ue;if(!fi.paste)return;function z(re,Te,Re,Se){var qe,At;const We=typeof Re=="object"?(Re==null?void 0:Re.join(` +`))??"":(Re==null?void 0:Re.toString())??"";if(!oa(re)&&Fu(re)&&re.readonly!==!0){const Qe=R==null?void 0:R(We,re);if(Qe!==void 0&&Ul(Qe))return{location:Te,value:Qe};const je=Ee(re);if(je===void 0)return;if(je.kind===Ce.Custom){Lr(re.kind===Ce.Custom);const Yt=(qe=je.onPaste)==null?void 0:qe.call(je,We,re.data);return Yt===void 0?void 0:{location:Te,value:{...re,data:Yt}}}else{const Yt=(At=je.onPaste)==null?void 0:At.call(je,We,re,{formatted:Se,formattedString:typeof Se=="string"?Se:Se==null?void 0:Se.join(` +`),rawValue:Re});return Yt===void 0?void 0:(Lr(Yt.kind===re.kind),{location:Te,value:Yt})}}}const F=Q.columns,U=Q.rows,K=((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(Q.current!==void 0?te=[Q.current.range.x,Q.current.range.y]:F.length===1?te=[F.first()??0,0]:U.length===1&&(te=[X,U.first()??0]),K&&te!==void 0){let re,Te;const Re="text/plain",Se="text/html";if(navigator.clipboard.read!==void 0){const Qe=await navigator.clipboard.read();for(const je of Qe){if(je.types.includes(Se)){const Gn=await(await je.getType(Se)).text(),xn=_b(Gn);if(xn!==void 0){re=xn;break}}je.types.includes(Re)&&(Te=await(await je.getType(Re)).text())}}else if(navigator.clipboard.readText!==void 0)Te=await navigator.clipboard.readText();else if(S!==void 0&&(S==null?void 0:S.clipboardData)!==null){if(S.clipboardData.types.includes(Se)){const Qe=S.clipboardData.getData(Se);re=_b(Qe)}re===void 0&&S.clipboardData.types.includes(Re)&&(Te=S.clipboardData.getData(Re))}else return;const[We,qe]=te,At=[];do{if(pe===void 0){const Qe=Or(te),je=Te??(re==null?void 0:re.map(Gn=>Gn.map(xn=>xn.rawValue).join(" ")).join(" "))??"",Yt=z(Qe,te,je,void 0);Yt!==void 0&&At.push(Yt);break}if(re===void 0){if(Te===void 0)return;re=d6(Te)}if(pe===!1||typeof pe=="function"&&(pe==null?void 0:pe([te[0]-X,te[1]],re.map(Qe=>Qe.map(je=>{var Yt;return((Yt=je.rawValue)==null?void 0:Yt.toString())??""}))))!==!0)return;for(const[Qe,je]of re.entries()){if(Qe+qe>=w)break;for(const[Yt,Gn]of je.entries()){const xn=[Yt+We,Qe+qe],[gi,zi]=xn;if(gi>=dt.length||zi>=Xn)continue;const mi=Or(xn),Bi=z(mi,xn,Gn.rawValue,Gn.formatted);Bi!==void 0&&At.push(Bi)}}}while(!1);Xr(At),(ue=gr.current)==null||ue.damage(At.map(Qe=>({cell:Qe.location})))}},[R,Ee,Or,Q,fi.paste,dt.length,Xr,Xn,pe,X,w]);jn("paste",sg,d,!1,!0);const fu=v.useCallback(async(S,z)=>{var q,ee;if(!fi.copy)return;const F=z===!0||((q=c.current)==null?void 0:q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,U=Q.columns,K=Q.rows,te=(ue,re)=>{if(!_e)Fb(ue,re,S);else{const Te=re.map(Re=>({kind:Ce.Text,data:y[Re].title,displayData:y[Re].title,allowOverlay:!1}));Fb([Te,...ue],re,S)}};if(F&&En!==void 0){if(Q.current!==void 0){let ue=En(Q.current.range,Kn.current.signal);typeof ue!="object"&&(ue=await ue()),te(ue,Yo(Q.current.range.x-X,Q.current.range.x+Q.current.range.width-X))}else if(K!==void 0&&K.length>0){const re=[...K].map(Te=>{const Re=En({x:X,y:Te,width:y.length,height:1},Kn.current.signal);return typeof Re=="object"?Re[0]:Re().then(Se=>Se[0])});if(re.some(Te=>Te instanceof Promise)){const Te=await Promise.all(re);te(Te,Yo(y.length))}else te(re,Yo(y.length))}else if(U.length>0){const ue=[],re=[];for(const Te of U){let Re=En({x:Te,y:0,width:1,height:w},Kn.current.signal);typeof Re!="object"&&(Re=await Re()),ue.push(Re),re.push(Te-X)}if(ue.length===1)te(ue[0],re);else{const Te=ue.reduce((Re,Se)=>Re.map((We,qe)=>[...We,...Se[qe]]));te(Te,re)}}}},[y,En,Q,fi.copy,X,w,_e]);jn("copy",fu,d,!1,!1);const PR=v.useCallback(async S=>{var F,U;if(!(!fi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await fu(S),Q.current!==void 0)){let K={current:{cell:Q.current.cell,range:Q.current.range,rangeStack:[]},rows:Pt.empty(),columns:Pt.empty()};const te=H==null?void 0:H(K);if(te===!1||(K=te===!0?K:te,K.current===void 0))return;$o(K.current.range)}},[$o,Q,fi.cut,fu,H]);jn("cut",PR,d,!1,!1);const IR=v.useCallback((S,z)=>{if($!==void 0){X!==0&&(S=S.map(K=>[K[0]-X,K[1]])),$(S,z);return}if(S.length===0||z===-1)return;const[F,U]=S[z];f.current!==void 0&&f.current[0]===F&&f.current[1]===U||(f.current=[F,U],Bs(F,U,!1,!1))},[$,X,Bs]),[bf,kf]=((Jw=Wt==null?void 0:Wt.current)==null?void 0:Jw.cell)??[],Sf=v.useRef(wn);Sf.current=wn,v.useLayoutEffect(()=>{var S,z,F,U;!Ot.current&&bf!==void 0&&kf!==void 0&&(bf!==((z=(S=$s.current)==null?void 0:S.current)==null?void 0:z.cell[0])||kf!==((U=(F=$s.current)==null?void 0:F.current)==null?void 0:U.cell[1]))&&Sf.current(bf,kf),Ot.current=!1},[bf,kf]);const Kw=Q.current!==void 0&&(Q.current.cell[0]>=dt.length||Q.current.cell[1]>=Xn);v.useLayoutEffect(()=>{Kw&&pr(Qf,!1)},[Kw,pr]);const NR=v.useMemo(()=>rn===!0&&(ie==null?void 0:ie.tint)===!0?Pt.fromSingleSelection(Xn-1):Pt.empty(),[Xn,rn,ie==null?void 0:ie.tint]),DR=v.useCallback(S=>typeof ge=="boolean"?ge:(ge==null?void 0:ge(S-X))??!0,[X,ge]),_R=v.useMemo(()=>{if(Zp===void 0||l.current===null)return null;const{bounds:S,group:z}=Zp,F=l.current.getBoundingClientRect();return v.createElement(t6,{bounds:S,group:z,canvasBounds:F,onClose:()=>eg(void 0),onFinish:U=>{eg(void 0),L==null||L(z,U)}})},[L,Zp]),LR=Math.min(dt.length,tt+(Ar?1:0));v.useImperativeHandle(e,()=>({appendRow:(S,z)=>Fl(S+X,z),updateCells:S=>{var z;return X!==0&&(S=S.map(F=>({cell:[F.cell[0]+X,F.cell[1]]}))),(z=gr.current)==null?void 0:z.damage(S)},getBounds:(S,z)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(S===void 0&&z===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=gr.current)==null?void 0:F.getBounds((S??0)+X,z)}},focus:()=>{var S;return(S=gr.current)==null?void 0:S.focus()},emit:async S=>{switch(S){case"delete":cu({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":cu({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":cu({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 fu(void 0,!0);break;case"paste":await sg();break}},scrollTo:wn,remeasureColumns:S=>{for(const z of S)xf(z+X)}}),[Fl,xf,fu,cu,sg,X,wn]);const[Xw,Gw]=$i??[],FR=v.useCallback(S=>{const[z,F]=S;if(F===-1){xe!=="none"&&(ye(Pt.fromSingleSelection(z),void 0,!1),sr());return}Xw===z&&Gw===F||(se({cell:S,range:{x:z,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),wn(z,F))},[xe,sr,wn,Xw,Gw,se,ye]),[$R,zR]=v.useState(!1),qw=v.useRef(FT(S=>{zR(S)},5)),BR=v.useCallback(()=>{qw.current(!0),Q.current===void 0&&Q.columns.length===0&&Q.rows.length===0&&a===void 0&&se({cell:[X,pf],range:{x:X,y:pf,width:1,height:1}},!0,!1,"keyboard-select")},[pf,Q,a,X,se]),jR=v.useCallback(()=>{qw.current(!1)},[]),[HR,WR]=v.useMemo(()=>{let S;const z=(Kt==null?void 0:Kt.scrollbarWidthOverride)??O0(),F=w+(rn?1:0);if(typeof ir=="number")S=at+F*ir;else{let K=0;const te=Math.min(F,10);for(let q=0;qte.width+K,0)+z;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,S)}px`]},[dt,Kt==null?void 0:Kt.scrollbarWidthOverride,ir,w,rn,at]),VR=v.useMemo(()=>k$(ce),[ce]);return v.createElement(S$.Provider,{value:ce},v.createElement(m6,{style:VR,className:V,inWidth:x??HR,inHeight:g??WR},v.createElement(QW,{fillHandle:Lt,drawFocusRing:fn,experimental:Kt,fixedShadowX:rf,fixedShadowY:Ds,getRowThemeOverride:p,headerIcons:cs,imageWindowLoader:fs,initialSize:Cl,isDraggable:sf,onDragLeave:of,onRowMoved:Li,overscrollX:Vp,overscrollY:df,preventDiagonalScrolling:Al,rightElement:No,rightElementProps:_s,smoothScrollX:af,smoothScrollY:Bp,className:V,enableGroups:$t,onCanvasFocused:BR,onCanvasBlur:jR,canvasRef:l,onContextMenu:OR,theme:ce,cellXOffset:_o,cellYOffset:pf,accessibilityHeight:vn.height,onDragEnd:ER,columns:dt,nonGrowWidth:$e,drawHeader:Gp,onColumnProposeMove:D,drawCell:qp,disabledRows:NR,freezeColumns:LR,lockColumns:X,firstColAccessible:X===0,getCellContent:Or,minColumnWidth:Er,maxColumnWidth:ci,searchInputRef:o,showSearch:iu,onSearchClose:Kp,highlightRegions:yR,getCellsForSelection:En,getGroupDetails:Qp,headerHeight:Pl,isFocused:$R,groupHeaderHeight:$t?ru:0,freezeTrailingRows:ne+(rn&&(ie==null?void 0:ie.sticky)===!0?1:0),hasAppendRow:rn,onColumnResize:di,onColumnResizeEnd:Xp,onColumnResizeStart:Nl,onCellFocused:FR,onColumnMoved:CR,onDragStart:TR,onHeaderMenuClick:kR,onItemHovered:ig,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:bR,onKeyDown:cu,onKeyUp:De,onMouseDown:vR,onMouseUp:xR,onDragOverCell:lt,onDrop:Le,onSearchResultsChanged:IR,onVisibleRegionChanged:SR,clientSize:Me,rowHeight:ir,searchResults:ae,searchValue:ve,onSearchValueChange:he,rows:Xn,scrollRef:c,selection:Q,translateX:vn.tx,translateY:vn.ty,verticalBorder:DR,gridRef:gr,getCellRenderer:Ee}),_R,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(k6,{...i,validateCell:su,bloom:P,id:RR,getCellRenderer:Ee,className:(Kt==null?void 0:Kt.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:J,imageEditorOverride:h,onFinishEditing:MR,markdownDivCreateNode:m,isOutsideClick:uf}))))},E6=v.forwardRef(T6),Bb=20,A6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Ce.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>M6(t,t.cell.data,T0(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=BT(c,l,s.cellVerticalPadding),h=zT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=$T(h,f,d),m=jT(a+n,u+r,p);if(T0(e)&&m)return{...e,data:DE(e.data)}},onPaste:(t,e)=>{let n=ph;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 M6(t,e,n,r){if(!n&&e===ph)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===ph&&(g*=s),g!==0&&(i.globalAlpha=g,rw(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const R6=Vr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),O6=t=>{const{bubbles:e}=t;return v.createElement(R6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},P6={getAccessibilityString:t=>HT(t.data),kind:Ce.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=>N6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(O6,{bubbles:e.data})},onPaste:()=>{}},I6=4;function N6(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=I6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=Yc(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)is(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+Ns(i,r))}const D6=Vr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),_6=t=>{const{drilldowns:e}=t;return v.createElement(D6,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))))},L6={getAccessibilityString:t=>HT(t.data.map(e=>e.text)),kind:Ce.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=>z6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(_6,{drilldowns:e.data})},onPaste:()=>{}},F6=4,Zg={};function $6(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(Zg[d]!==void 0)return{el:Zg[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),Zg[d]=h,p.beginPath(),is(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(),is(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 z6(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=tE(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=F6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=$6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=Yc(b.text,i,c).width;let E=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(E=p-8+4);const R=T+E+m*2;k.push({x:g,width:R}),g+=R+x}if(w!==null){const{el:b,height:C,middleWidth:T,sideWidth:E,width:R,dpr:O,padding:_}=w,P=E/O,I=_/O;for(const D of k){const Y=Math.floor(D.x),oe=Math.floor(D.width),le=oe-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,E,C,Y-I,h,P,d),le>0&&i.drawImage(b,E,0,T,C,Y+(P-I),h,le,d),i.drawImage(b,R-E,0,E,C,Y+oe-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,C]of k.entries()){const T=e[b];let E=C.x+m;if(T.img!==void 0){const R=s.loadOrGetImage(T.img,o,l);if(R!==void 0){const O=p-8;let _=0,P=0,I=R.width,D=R.height;I>D?(_+=(I-D)/2,I=D):D>I&&(P+=(D-I)/2,D=I),i.beginPath(),is(i,E,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(R,_,P,I,D,E,h+d/2-O/2,O,O),i.restore(),E+=O+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,E,h+d/2+Ns(i,r))}}const B6={getAccessibilityString:t=>t.data.join(", "),kind:Ce.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>j6(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??P4;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}}},em=4;function j6(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(),is(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+em}}function H6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const W6={getAccessibilityString:()=>"",kind:Ce.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(H6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);is(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=hl(o.textDark,.1),i.fill()},onPaste:()=>{}},V6=()=>t=>t.targetWidth,jb=Vr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[V6(),"px"]}}),U6=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(Sp,{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(C4,null))):v.createElement(jb,{targetWidth:s.width},v.createElement(Y4,{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}))},K6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Qc,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>xs(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(U6,{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}},X6={getAccessibilityString:t=>t.row.toString(),kind:Zr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:G6,measure:()=>44,draw:t=>Y6(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 G6(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 Y6(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+Ns(o,x)),a!==0&&(o.globalAlpha=1)}}const Q6={getAccessibilityString:()=>"",kind:Zr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>J6(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function J6(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+Ns(r,o)),r.beginPath()}const Z6=v.lazy(async()=>await lE(()=>import("./number-overlay-editor-ClJRXvW2.js"),[])),e9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Qc,draw:t=>xs(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(Z6,{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}}},t9={getAccessibilityString:()=>"",measure:()=>108,kind:Ce.Protected,needsHover:!1,needsHoverPosition:!1,draw:n9,onPaste:()=>{}};function n9(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 r9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>Qc(t,e,t.theme.textLight),draw:t=>xs(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 Nn.createElement(Sp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},i9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Qc,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=Yc(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),is(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=hl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}xs(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(Sp,{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}},s9=Vr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),o9=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(Sp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(s9,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 l9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Qc,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=Yc(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=Ns(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,xs({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),xs({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,xs(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=p$(o,s.baseFontFull);if(l===void 0)return;const a=Hb(l,n,s,e.contentAlign);Tp({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(o9,{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}},a9=[X6,Q6,A6,P6,L6,B6,W6,K6,e9,t9,r9,i9,l9];var u9=LT,c9=xl,f9="Expected a function";function d9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(f9);return c9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),u9(t,e,{leading:r,maxWait:e,trailing:i})}var h9=d9;const p9=Ni(h9),tm=[];class g9 extends rE{constructor(){super(...arguments);vt(this,"imageLoaded",()=>{});vt(this,"loadedLocations",[]);vt(this,"cache",{});vt(this,"sendLoaded",p9(()=>{this.imageLoaded(new tc(this.loadedLocations)),this.loadedLocations=[]},20));vt(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,tm.length<12?tm.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=Ci(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const nm="\uFEFF";function m9(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 y9(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 Sp(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 em(t,e,n=","){return[t,...e].map(r=>Sp(r,n)).join(` -`)}function rw(t,e){return Qc(t,e).headers}function g9(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 IE(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 m9(t,e){return t[e]==="\r"?t[e+1]===` +`&&t[r]!=="\r";)r++;return[t.slice(e,r),r]}function Jc(t,e){const n=t.startsWith(nm),r=n?t.slice(nm.length):t,i=n?nm.length:0,s=e??m9(r),o=[],l=[];let a=[],u=0,c=0,f=!1;for(;c=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 Ep(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 rm(t,e,n=","){return[t,...e].map(r=>Ep(r,n)).join(` +`)}function ow(t,e){return Jc(t,e).headers}function v9(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 w9(t,e){return t[e]==="\r"?t[e+1]===` `?2:1:t[e]===` -`?1:0}function zb(t,e){return t[e-2]==="\r"&&t[e-1]===` +`?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 jb="\uFEFF";function NE(t,e){const n=t.startsWith(jb)?jb.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-zb(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-zb(t,t.length)}}function tm(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+m9(t,i.end),replacement:""}));return r.length===0?t:IE(t,r)}function Hb(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:Sp(a,e.delimiter)})}return IE(t,s)}function y9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=NE(t,e),s=rw(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=Sp(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const z0=50;function Ho(t=""){return{past:[],present:t,future:[]}}function Wb(t,e,n=z0){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 v9(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 w9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>z0?r.slice(r.length-z0):r,present:e,future:n}}function x9(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 Vb=/^[+-]?\d{16,}$/;function b9(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(Vb.test(a)&&Vb.test(u)){const x=BigInt(a),g=BigInt(u);return s*(xg?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const S9=` +`?1:0}const Vb="\uFEFF";function LE(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 im(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+w9(t,i.end),replacement:""}));return r.length===0?t:_E(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:Ep(a,e.delimiter)})}return _E(t,s)}function x9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=LE(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=Ep(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const W0=50;function Ho(t=""){return{past:[],present:t,future:[]}}function Kb(t,e,n=W0){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 b9(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 k9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>W0?r.slice(r.length-W0):r,present:e,future:n}}function S9(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 C9(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 E9=` -`;function Qf(t,e){return Math.max(0,Math.min(t,e))}function Ub(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Qf(a.x,r+i),c=Qf(a.x+a.width,r+i);if(c<=r)continue;const f=u-r,d=c-r;if(d<=f)continue;const h=Qf(a.y,e.length),p=Qf(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(em(m,x,t.delimiter))}if(s.length>0)return s.join(S9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return em(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 em(a,u,t.delimiter)}return null}const Kb=24,nm=26,Xb=110,rm=40,C9=12,Bn=1,Gb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',qb='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif';function Yb(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Tu="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";function T9(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:qb,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:qb,lineHeight:1}}function E9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function DE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l}){const a=v.useRef(null),u=v.useRef(null),c=v.useRef(null),[f,d]=v.useState(""),[h,p]=v.useState(""),[m,x]=v.useState(null),g=v.useRef(m);g.current=m;const y=v.useRef(null),[w,k]=v.useState(null),[b,C]=v.useState(""),T=v.useRef(null),[A,M]=v.useState(void 0),[O,_]=v.useState(()=>new Set),P=v.useRef(O),[I,D]=v.useState(0),Y=i!==void 0,ie=v.useMemo(()=>T9(r),[r]),se=E9(r),V=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",J=v.useRef();J.current===void 0&&(J.current=new d9);const R=v.useMemo(()=>Qc(t,e),[t,e]),N=v.useMemo(()=>g9(R),[R]),L=R.headers.length,z=v.useRef({text:t,table:R});z.current={text:t,table:R};const j=v.useRef(A);j.current=A,v.useEffect(()=>{const W=window.setTimeout(()=>p(f),150);return()=>window.clearTimeout(W)},[f]);const B=v.useMemo(()=>{const W=b9(R.rows,h);return m?k9(W,R.rows,m.col,m.dir,N[m.col]??!1):W},[R,h,m,N]),oe=v.useRef(B);oe.current=B,v.useEffect(()=>{const W=u.current;if(!W||typeof ResizeObserver>"u")return;const ye=new ResizeObserver(()=>D(W.clientWidth));return ye.observe(W),D(W.clientWidth),()=>ye.disconnect()},[]);const fe=Math.max(Xb,Math.floor((I-rm)/Math.max(1,L)));v.useEffect(()=>{_(W=>{let ye=!1;const re=new Set;for(const we of W)we{M(W=>{if(!W||W.rows.length===0)return W;const ye=[];for(const we of P.current){const pe=B.indexOf(we);pe!==-1&&ye.push(pe)}ye.sort((we,pe)=>we-pe);const re=ye.reduce((we,pe)=>we.add(pe),Pt.empty());return re.equals(W.rows)?W:{...W,rows:re}})},[B]),v.useEffect(()=>{x(W=>W!==null&&W.col>=L?null:W),k(W=>W!==null&&W.col>=L?null:W)},[L]);const me=h!=="",ze=R.rows.length,Fe=nm+Math.min(B.length,C9)*Kb,nt=()=>{d(""),p("")},Et=v.useCallback((W,ye)=>{var we;if(W0||Le.height>0)?{x:Math.max(0,de.x-Le.left),y:Math.max(0,de.y-Le.top),width:de.width,height:de.height}:de??{x:rm+re*fe,y:0,width:fe,height:nm};C(pe),k({col:re,bounds:Re});return}y.current=g.current,k(null),x(pe=>!pe||pe.col!==re?{col:re,dir:"asc"}:pe.dir==="asc"?{col:re,dir:"desc"}:null)},[Y,fe]),rt=v.useCallback(()=>{if(!w)return;const{col:W}=w;if(k(null),!i)return;const{text:ye,table:re}=z.current,we=y9(ye,re,W,b);we!==ye&&i(we)},[w,b,i]),it=v.useCallback(()=>{k(null)},[]);v.useEffect(()=>{if(!w)return;const W=T.current;W&&(W.focus(),W.select())},[w]);const lt=v.useCallback((W,ye)=>{const re=oe.current,we=re[ye];if(we===void 0)return;const pe=P.current,Le=c.current;let de;if(W.shiftKey&&Le!==null&&Le!==we){const De=re.indexOf(Le),q=re.indexOf(we),Ae=De===-1?q:De,[$e,qt]=Ae<=q?[Ae,q]:[q,Ae];de=W.metaKey||W.ctrlKey?new Set(pe):new Set;for(let We=$e;We<=qt;We++){const Bt=re[We];Bt!==void 0&&de.add(Bt)}}else W.metaKey||W.ctrlKey?(de=new Set(pe),de.has(we)?de.delete(we):de.add(we)):de=new Set([we]);c.current=we,P.current=de,_(de);const Re=[...de].map(De=>re.indexOf(De)).filter(De=>De!==-1).sort((De,q)=>De-q);M(De=>({current:De==null?void 0:De.current,columns:(De==null?void 0:De.columns)??Pt.empty(),rows:Re.reduce((q,Ae)=>q.add(Ae),Pt.empty())}))},[]),_t=v.useCallback(()=>{c.current=null,P.current=new Set,_(new Set),M(void 0)},[]),Ne=v.useCallback(W=>{const ye=new Set;for(const re of W.rows){const we=oe.current[re];we!==void 0&&ye.add(we)}P.current=ye,_(ye),M(W)},[]),xe=v.useCallback(()=>{_t()},[_t]),_e=v.useMemo(()=>B.filter(W=>O.has(W)),[B,O]),Ye=v.useMemo(()=>[...(A==null?void 0:A.columns)??[]].filter(W=>W>=Bn).map(W=>W-Bn),[A]),Ke=Ye.length,Ue=_e.length>0||Ke>0,ht=v.useRef(l);ht.current=l;const vt=()=>{var re,we;const W=j.current,ye=Ub(z.current.table,oe.current,{ranges:W!=null&&W.current?[W.current.range,...W.current.rangeStack]:[],columns:W?[...W.columns]:[],rows:W?[...W.rows]:[]},Bn);ye!==null&&((re=ht.current)==null||re.call(ht),(we=navigator.clipboard)==null||we.writeText(ye).catch(()=>{}))};v.useEffect(()=>{const W=ye=>{var de,Re;const re=a.current;if(!re||!re.contains(document.activeElement))return;const we=document.activeElement;if(we&&(we.tagName==="INPUT"||we.tagName==="TEXTAREA"||we.isContentEditable))return;const pe=j.current,Le=Ub(z.current.table,oe.current,{ranges:pe!=null&&pe.current?[pe.current.range,...pe.current.rangeStack]:[],columns:pe?[...pe.columns]:[],rows:pe?[...pe.rows]:[]},Bn);Le!==null&&(ye.preventDefault(),ye.stopImmediatePropagation(),(de=ye.clipboardData)==null||de.setData("text/plain",Le),(Re=ht.current)==null||Re.call(ht))};return window.addEventListener("copy",W,{capture:!0}),()=>window.removeEventListener("copy",W,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const W=ye=>{const re=a.current;if(!re)return;const we=ye.target instanceof Node&&re.contains(ye.target),pe=document.activeElement instanceof Node&&re.contains(document.activeElement);if(!we&&!pe||Yb(ye.target)||Yb(document.activeElement))return;const Le=x9(ye);Le==="undo"&&s?(ye.preventDefault(),s()):Le==="redo"&&o&&(ye.preventDefault(),o())};return window.addEventListener("keydown",W),()=>window.removeEventListener("keydown",W)},[s,o]);const at=v.useCallback(W=>{var re;const ye=a.current!==null&&document.activeElement instanceof Node&&a.current.contains(document.activeElement);_t(),i==null||i(W),ye&&((re=u.current)==null||re.focus({preventScroll:!0}))},[_t,i]),he=L>0&&Ye.length>=L,Be=()=>{!Y||_e.length===0||at(tm(z.current.text,z.current.table,_e))},ut=()=>{!Y||he||Ye.length===0||at(Hb(z.current.text,z.current.table,Ye))},tt=v.useCallback(W=>{if(!i)return!1;const{text:re,table:we}=z.current,pe=oe.current;if(W.rows.length>0){const Re=[...W.rows].map(De=>pe[De]).filter(De=>De!==void 0);if(Re.length>0)return at(tm(re,we,Re)),!1}if(W.columns.length>0){const Re=[...W.columns].filter(De=>De>=Bn&&DeDe-Bn);return Re.length>0&&Re.length0&&at(tm(re,we,de)),!1},[at,i]),Vt=v.useCallback(W=>{const ye=i;if(!ye)return!1;const{text:re,table:we}=z.current,pe=oe.current,Le=[...W].sort((De,q)=>De.location[1]-q.location[1]);let de=re,Re=0;for(const{location:De,value:q}of Le){const Ae=De[0]-Bn,$e=De[1];if(Ae<0||q.kind!==Se.Text)continue;const qt=pe[$e],We=qt===void 0?void 0:we.rowSpans[qt];if(!We)continue;const Bt=de.slice(We.start+Re,We.end+Re),Rt=rw(Bt,we.delimiter);for(;Rt.length<=Ae;)Rt.push("");const Ft=q.data??"";if(Rt[Ae]===Ft)continue;Rt[Ae]=Ft;const Tn=Sp(Rt,we.delimiter);de=de.slice(0,We.start+Re)+Tn+de.slice(We.end+Re),Re+=Tn.length-(We.end-We.start)}return de!==re&&ye(de),!0},[i]),ft=v.useCallback(W=>{var Le;const[ye,re]=W,we=oe.current[re];if(ye{const ye=[];for(let re=W.y;re{W[0]>=Bn||lt(ye,W[1])},[lt]),Ut=v.useMemo(()=>{const W={title:"#",id:"__gutter",width:rm,themeOverride:{baseFontStyle:`11px ${Gb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ye=R.headers.map((re,we)=>({title:re.toUpperCase(),id:`c${we}`,width:fe,themeOverride:N[we]?{baseFontStyle:`12px ${Gb}`}:void 0}));return[W,...ye]},[R.headers,N,fe]),Mt=v.useCallback((W,ye)=>{const{ctx:re,columnIndex:we,rect:pe,theme:Le,isSelected:de}=W;re.save();try{if(re.letterSpacing="0.5px",de&&(re.fillStyle=Le.bgHeaderHovered,re.fillRect(pe.x,pe.y,pe.width,pe.height),re.fillStyle=Le.accentColor,re.fillRect(pe.x,pe.y+pe.height-2,pe.width,2)),we{const{ctx:re,cell:we,rect:pe,col:Le,theme:de}=W,Re=Le-Bn;if(Re>=0&&me&&we.kind===Se.Text){const De=A9(we.data,h);if(De!==null){re.save();try{const q=`${de.baseFontStyle} ${de.fontFamily}`;re.font=q;let Ae=pe.x+de.cellHorizontalPadding;const $e=pe.y+pe.height/2+Ns(re,q);for(const qt of De){const We=re.measureText(qt.text).width;qt.hit&&We>0&&(re.fillStyle=se,re.fillRect(Ae-1,$e-7,We+2,14)),Ae+=We}}finally{re.restore()}}}if(ye(),Re>=0&&we.kind===Se.Text&&we.data===""){re.save();try{re.font=`${de.baseFontStyle} ${de.fontFamily}`,re.fillStyle=de.textLight,re.fillText("—",pe.x+de.cellHorizontalPadding,pe.y+pe.height/2+.5)}finally{re.restore()}}},[me,h,se]),$n=v.useCallback(W=>{const ye=oe.current[W];return ye!==void 0&&P.current.has(ye)?{bgCell:V,bgCellMedium:V}:void 0},[V]);return L===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:a,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(nN,{"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:f,onChange:W=>d(W.target.value),onKeyDown:W=>{W.key==="Escape"&&nt()},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"}),f!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:nt,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(Ov,{"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:me?`${B.length.toLocaleString()} of ${ze.toLocaleString()}`:`${ze.toLocaleString()} rows`}),Ue&&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:_e.length>0?`${_e.length.toLocaleString()} selected`:`${Ke.toLocaleString()} ${Ke===1?"column":"columns"} selected`}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:vt,className:Tu,children:[E.jsx(Rv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),Y&&_e.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:Be,title:`Deletes the ${_e.length} selected ${_e.length===1?"row":"rows"} from the source CSV`,className:Tu,children:[E.jsx(ch,{"aria-hidden":"true",className:"size-3"}),"Delete ",_e.length.toLocaleString()," ",_e.length===1?"row":"rows"]}),Y&&Ke>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:ut,disabled:he,title:he?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Ke} selected ${Ke===1?"column":"columns"} from the source CSV`,className:`${Tu} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(ch,{"aria-hidden":"true",className:"size-3"}),"Delete ",Ke.toLocaleString()," ",Ke===1?"column":"columns"]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:_t,className:Tu,children:"Clear"})]})]}),E.jsxs("div",{ref:u,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":B.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Fe},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(S6,{imageWindowLoader:J.current,renderers:s9,columns:Ut,rows:B.length,getCellContent:ft,getCellsForSelection:dt,onCellsEdited:Y?Vt:void 0,onDelete:Y?tt:void 0,onCellClicked:wt,onHeaderClicked:Et,onGridSelectionChange:Ne,onSelectionCleared:xe,gridSelection:A,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Kb,headerHeight:nm,freezeColumns:Bn,fillHandle:Y,onPaste:Y?()=>!0:!1,keybindings:{search:!1},theme:ie,drawHeader:Mt,drawCell:Rn,getRowThemeOverride:$n,minColumnWidth:Xb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),w!==null&&E.jsx("input",{ref:T,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${R.headers[w.col]??""}`,value:b,onChange:W=>C(W.target.value),onBlur:rt,onKeyDown:W=>{W.key==="Enter"?(W.preventDefault(),W.stopPropagation(),rt()):W.key==="Escape"&&(W.preventDefault(),W.stopPropagation(),it())},style:{left:w.bounds.x,top:w.bounds.y,width:Math.max(60,w.bounds.width),height:w.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"}),me&&B.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 “",h,"”."]}),E.jsx("button",{type:"button",onClick:nt,className:Tu,children:"Show all rows"})]}),Y&&!me&&B.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 A9(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(HI,{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=P9(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(aT,{"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(iN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let j0=[],_E=[];(()=>{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=_E[r])e=r+1;else return!0;if(e==n)return!1}}function Qb(t){return t>=127462&&t<=127487}const Jb=8205;function D9(t,e,n=!0,r=!0){return(n?LE:_9)(t,e,r)}function LE(t,e,n){if(e==t.length)return e;e&&FE(t.charCodeAt(e))&&$E(t.charCodeAt(e-1))&&e--;let r=im(t,e);for(e+=Zb(r);e=0&&Qb(im(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function _9(t,e,n){for(;e>1;){let r=LE(t,e-2,n);if(r=56320&&t<57344}function $E(t){return t>=55296&&t<56320}function Zb(t){return t<65536?1:2}class It{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]=Ia(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),Gi.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]=Ia(this,e,n);let r=[];return this.decompose(e,n,r,0),Gi.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 tc(this),s=new tc(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 tc(this,e)}iterRange(e,n=this.length){return new BE(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 zE(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]?It.empty:e.length<=32?new bn(e):Gi.from(bn.split(e,[]))}}class bn extends It{constructor(e,n=L9(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 F9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new bn(ek(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Nd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new bn(l,o.length+s.length));else{let a=l.length>>1;r.push(new bn(l.slice(0,a)),new bn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof bn))return super.replace(e,n,r);[e,n]=Ia(this,e,n);let i=Nd(this.text,Nd(r.text,ek(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new bn(i,s):Gi.from(bn.split(i,[]),s)}sliceString(e,n=this.length,r=` -`){[e,n]=Ia(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 bn(r,i)),r=[],i=-1);return i>-1&&n.push(new bn(r,i)),n}}class Gi extends It{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]=Ia(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 Gi(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]=Ia(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 Gi))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 bn(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 Gi)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof bn&&a&&(p=c[c.length-1])instanceof bn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new bn(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]:Gi.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new Gi(l,n)}}It.empty=new bn([""],0);function L9(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Nd(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 bn?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 bn?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 bn){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 bn?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 BE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new tc(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 zE{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"&&(It.prototype[Symbol.iterator]=function(){return this.iter()},tc.prototype[Symbol.iterator]=BE.prototype[Symbol.iterator]=zE.prototype[Symbol.iterator]=function(){return this});class F9{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 Ia(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function tr(t,e,n=!0,r=!0){return D9(t,e,n,r)}function $9(t){return t>=56320&&t<57344}function B9(t){return t>=55296&&t<56320}function z9(t,e){let n=t.charCodeAt(e);if(!B9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return $9(r)?(n-55296<<10)+(r-56320)+65536:n}function j9(t){return t<65536?1:2}const H0=/\r\n?|\n/;var yr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(yr||(yr={}));class ss{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=yr.Simple&&u>=e&&(r==yr.TrackDel&&ie||r==yr.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 ss(e)}static create(e){return new ss(e)}}class In extends ss{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 W0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return V0(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&&lo(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"?It.of(h.split(r||H0)):h:It.empty,m=p.length;if(f==d&&m==0)return;fo&&Zn(i,f-o,-1),Zn(i,d-f,m),lo(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new In(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 lo(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 V0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Ac(t),l=new Ac(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);Zn(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 Ac{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?It.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?It.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 no{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 no(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ue.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ue.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 ue.range(e.anchor,e.head)}static create(e,n,r,i){return new no(e,n,r,i)}}class ue{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ue.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 ue(e.ranges.map(n=>no.fromJSON(n)),e.main)}static single(e,n=e){return new ue([ue.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?ue.range(a,l):ue.range(l,a))}}return new ue(e,n)}}function HE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let iw=0;class He{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=iw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new He(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:sw),!!e.static,e.enables)}of(e){return new Dd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Dd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Dd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function sw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Dd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=iw++}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)||U0(f,c)){let h=r(f);if(l?!tk(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=Eh(d,p);if(this.dependencies.every(x=>x instanceof He?d.facet(x)===f.facet(x):x instanceof us?d.field(x,!1)==f.field(x,!1):!0)||(l?tk(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 tk(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(Jf).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(Jf),o=i.facet(Jf),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,Jf.of({field:this,create:e})]}get extension(){return this}}const Yo={lowest:4,low:3,default:2,high:1,highest:0};function Eu(t){return e=>new WE(e,t)}const ow={highest:Eu(Yo.highest),high:Eu(Yo.high),default:Eu(Yo.default),low:Eu(Yo.low),lowest:Eu(Yo.lowest)};class WE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class sl{of(e){return new K0(this,e)}reconfigure(e){return sl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class K0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Th{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 W9(e,n,o))d instanceof us?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,sw(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=>H9(x,p,h))}}let f=u.map(d=>d(l));return new Th(e,o,f,l,a,s)}}function W9(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 K0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof K0){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 WE)s(o.inner,o.prec);else if(o instanceof us)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Dd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,Yo.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,Yo.default),r.reduce((o,l)=>o.concat(l))}function nc(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 Eh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const VE=He.define(),X0=He.define({combine:t=>t.some(e=>e),static:!0}),UE=He.define({combine:t=>t.length?t[0]:void 0,static:!0}),KE=He.define(),XE=He.define(),GE=He.define(),qE=He.define({combine:t=>t.length?t[0]:!1});class Po{constructor(e,n){this.type=e,this.value=n}static define(){return new V9}}class V9{of(e){return new Po(this,e)}}class U9{constructor(e){this.map=e}of(e){return new Xt(this,e)}}class Xt{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 Xt(this.type,n)}is(e){return this.type==e}static define(e={}){return new U9(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}}Xt.reconfigure=Xt.define();Xt.appendConfig=Xt.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&&HE(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=Po.define();_n.userEvent=Po.define();_n.addToHistory=Po.define();_n.remote=Po.define();function K9(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=QE(e,va(s),!1)}return t}function G9(t){let e=t.startState,n=e.facet(GE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=YE(r,G0(e,s,t.changes.newLength),!0))}return r==t?t:_n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const q9=[];function va(t){return t==null?q9:Array.isArray(t)?t:[t]}var Cs=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Cs||(Cs={}));const Y9=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let q0;try{q0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Q9(t){if(q0)return q0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||Y9.test(n)))return!0}return!1}function J9(t){return e=>{if(!/\S/.test(e))return Cs.Space;if(Q9(e))return Cs.Word;for(let n=0;n-1)return Cs.Word;return Cs.Other}}class Lt{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(Xt.reconfigure)?(n=null,r=l.value):l.is(Xt.appendConfig)&&(n=null,r=va(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Th.resolve(r,i,this),s=new Lt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(X0)?e.newSelection:e.newSelection.asSingle();new Lt(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:ue.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=va(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return Lt.create({doc:e.doc,selection:ue.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Th.resolve(e.extensions||[],new Map),r=e.doc instanceof It?e.doc:It.of((e.doc||"").split(n.staticFacet(Lt.lineSeparator)||H0)),i=e.selection?e.selection instanceof ue?e.selection:ue.single(e.selection.anchor,e.selection.head):ue.single(0);return HE(i,r.length),n.staticFacet(X0)||(i=i.asSingle()),new Lt(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Lt.tabSize)}get lineBreak(){return this.facet(Lt.lineSeparator)||` -`}get readOnly(){return this.facet(qE)}phrase(e,...n){for(let r of this.facet(Lt.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(VE))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 J9(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=tr(n,o,!1);if(s(n.slice(a,o))!=Cs.Word)break;o=a}for(;lt.length?t[0]:4});Lt.lineSeparator=UE;Lt.readOnly=qE;Lt.phrases=He.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])}});Lt.languageData=VE;Lt.changeFilter=KE;Lt.transactionFilter=XE;Lt.transactionExtender=GE;sl.reconfigure=Xt.define();function JE(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 hl{eq(e){return this==e}range(e,n=e){return Y0.create(e,n,this)}}hl.prototype.startSide=hl.prototype.endSide=0;hl.prototype.point=!1;hl.prototype.mapMode=yr.TrackDel;function lw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Y0=class ZE{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new ZE(e,n,r)}};function Q0(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class aw{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 aw(i,s,r,l):null,pos:o}}}class jt{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 jt(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(Q0)),this.isEmpty)return n.length?jt.of(n):this;let l=new eA(this,null,-1).goto(0),a=0,u=[],c=new Na;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 Mc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Mc.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=nk(o,l,r),u=new Au(o,a,s),c=new Au(l,a,s);r.iterGaps((f,d,h)=>rk(u,f,c,d,h,i)),r.empty&&r.length==0&&rk(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=nk(s,o),a=new Au(s,l,0).goto(r),u=new Au(o,l,0).goto(r);for(;;){if(a.to!=u.to||!J0(a.active,u.active)||a.point&&(!u.point||!lw(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 Au(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 Na;for(let i of e instanceof Y0?[e]:n?Z9(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return jt.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=jt.empty;i=i.nextLayer)n=new jt(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}jt.empty=new jt([],[],null,-1);function Z9(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(Q0);e=r}return t}jt.empty.nextLayer=jt.empty;class Na{finishChunk(e){this.chunks.push(new aw(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 Na)).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(jt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=jt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function nk(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 eA(o,n,r,s));return i.length==1?i[0]:new Mc(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--)sm(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--)sm(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(),sm(this.heap,0)}}}function sm(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 Au{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=Mc.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){Zf(this.active,e),Zf(this.activeTo,e),Zf(this.activeRank,e),this.minActive=ik(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;ed(this.active,n,r),ed(this.activeTo,n,i),ed(this.activeRank,n,s),e&&ed(e,n,this.cursor.from),this.minActive=ik(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&&Zf(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 rk(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&&lw(t.point,n.point)&&J0(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!J0(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 J0(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 ik(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=tr(t,i)}return t.length}const Z0="ͼ",sk=typeof Symbol>"u"?"__"+Z0:Symbol.for(Z0),ey=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ok=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class So{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=ok[sk]||1;return ok[sk]=e+1,Z0+e.toString(36)}static mount(e,n,r){let i=e[ey],s=r&&r.nonce;i?s&&i.setNonce(s):i=new tV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let lk=new Map;class tV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=lk.get(r);if(s)return e[ey]=s;this.sheet=new i.CSSStyleSheet,lk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[ey]=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:'"'},nV=typeof navigator<"u"&&/Mac/.test(navigator.platform),rV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wn=0;Wn<10;Wn++)Co[48+Wn]=Co[96+Wn]=String(Wn);for(var Wn=1;Wn<=24;Wn++)Co[Wn+111]="F"+Wn;for(var Wn=65;Wn<=90;Wn++)Co[Wn]=String.fromCharCode(Wn+32),Rc[Wn]=String.fromCharCode(Wn);for(var om in Co)Rc.hasOwnProperty(om)||(Rc[om]=Co[om]);function iV(t){var e=nV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||rV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Rc:Co)[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 qi(){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 Ee={mac:ck||/Mac/.test(ar.platform),windows:/Win/.test(ar.platform),linux:/Linux|X11/.test(ar.platform),ie:Tp,ie_version:nA?ty.documentMode||6:ry?+ry[1]:ny?+ny[1]:0,gecko:ak,gecko_version:ak?+(/Firefox\/(\d+)/.exec(ar.userAgent)||[0,0])[1]:0,chrome:!!lm,chrome_version:lm?+lm[1]:0,ios:ck,android:/Android\b/.test(ar.userAgent),webkit:uk,webkit_version:uk?+(/\bAppleWebKit\/(\d+)/.exec(ar.userAgent)||[0,0])[1]:0,safari:iy,safari_version:iy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ar.userAgent)||[0,0])[1]:0,tabSize:ty.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function uw(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 Ah=Object.create(null);function cw(t,e,n){if(t==e)return!0;t||(t=Ah),e||(e=Ah);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 sV(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 fk(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 oV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new pl(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}=rA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new pl(e,r,i,n,e.widget||null,!0)}static line(e){return new Zc(e)}static set(e,n=!1){return jt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Wt.none=jt.empty;class Jc extends Wt{constructor(e){let{start:n,end:r}=rA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?uw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ah}eq(e){return this==e||e instanceof Jc&&this.tagName==e.tagName&&cw(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)}}Jc.prototype.point=!1;class Zc extends Wt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof Zc&&this.spec.class==e.spec.class&&cw(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)}}Zc.prototype.mapMode=yr.TrackBefore;Zc.prototype.point=!0;class pl extends Wt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?yr.TrackBefore:yr.TrackAfter:yr.TrackDel}get type(){return this.startSide!=this.endSide?ii.WidgetRange:this.startSide<=0?ii.WidgetBefore:ii.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof pl&&lV(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)}}pl.prototype.point=!0;function rA(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 lV(t,e){return t==e||!!(t&&e&&t.compare(e))}function wa(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 Oc extends hl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Oc&&this.tagName==e.tagName&&cw(this.attributes,e.attributes)}static create(e){return new Oc(e.tagName,e.attributes||Ah,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return jt.of(e,n)}}Oc.prototype.startSide=Oc.prototype.endSide=-1;function Pc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function sy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function rc(t,e){if(!e.anchorNode)return!1;try{return sy(t,e.anchorNode)}catch{return!1}}function ic(t){return t.nodeType==3?Nc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function sc(t,e,n,r){return n?dk(t,e,n,r,-1)||dk(t,e,n,r,1):!1}function To(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Mh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function dk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ps(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=To(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?Ps(t):0}else return!1}}function Ps(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ic(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 aV(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 iA(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 uV(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=aV(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}=iA(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 sA(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 cV{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?Ps(n):0),r,Math.min(e.focusOffset,r?Ps(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function oA(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 lA(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 Xo=null;Ee.safari&&Ee.safari_version>=26&&(Xo=!1);function aA(t){if(t.setActive)return t.setActive();if(Xo)return t.focus(Xo);let e=oA(t);t.focus(Xo==null?{get preventScroll(){return Xo={preventScroll:!0},!0}}:void 0),Xo||(Xo=!1,lA(e))}let hk;function Nc(t,e,n=e){let r=hk||(hk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function xa(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 fV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function dV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,Ps(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Ps(n))}else{if(n==t)return!0;r=To(n),n=n.parentNode}}function uA(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 cA(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=Ps(n)}else if(n.parentNode&&!Mh(n))r=To(n),n=n.parentNode;else return null}}function fA(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 pA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(Hi[m+1]==-h){let x=Hi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Kt[f]=Kt[Hi[m]]=g),l=m;break}}else{if(Hi.length==189)break;Hi[l++]=f,Hi[l++]=d,Hi[l++]=a}else if((p=Kt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=Hi[x+2];if(g&2)break;if(m)Hi[x+2]|=2;else{if(g&4)break;Hi[x+2]|=4}}}}}function vV(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),Kt[--p]=h;a=c}else s=u,a++}}}function ly(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 Zi(a,m.from,h));let x=m.direction==gl!=!(h%2);ay(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Kt[p]!=l:Kt[p]==l))break;p++}d?ly(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Kt[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(Kt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toKt.length;)Kt[Kt.length]=256;let r=[],i=e==gl?0:1;return ay(t,i,i,n,0,t.length,r),r}function gA(t){return[new Zi(0,t,0)]}let mA="";function xV(t,e,n,r,i){var s;let o=r.head-t.from,l=Zi.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=tr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),mA=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)}),kV=He.define({combine:t=>t.some(e=>e)}),CA=He.define();class ba{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 ba(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 ba(ue.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const td=Xt.define({map:(t,e)=>t.map(e)}),TA=Xt.define();function ei(t,e,n){let r=t.facet(xA);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 bs=He.define({combine:t=>t.length?t[0]:!0});let SV=0;const aa=He.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Ep.of(u=>{let c=u.plugin(l);return c?o(c):Wt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return ai.define((r,i)=>new e(r,i),n)}}class am{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(ei(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){ei(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){ei(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const EA=He.define(),pw=He.define(),Ep=He.define(),AA=He.define(),gw=He.define(),ef=He.define(),MA=He.define();function pk(t,e){let n=t.state.facet(MA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return jt.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=bV(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 RA=He.define();function mw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(RA)){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 $u=He.define();class ti{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ti(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 ti(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Rh(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 CV=[];class mn{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 CV}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&&sV(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=To(this.dom),i=this.length?e>0:n>0;return new Ei(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 Mp)return e;return null}static get(e){return e.cmTile}}class Ap extends mn{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=gk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=gk(i);this.length=o}}function gk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Mp extends Ap{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=mn.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 Es)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 Es extends Ap{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 Es(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class Da extends Ap{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new Da(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&&EV(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):TV(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 Ei(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 Ei(a.dom,0);a==r.tile&&(l=!0)}}return new Ei(this.dom,0)}}function TV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ic(e);return n[n.length-1]||null}function EV(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?Ee.chrome||Ee.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Ee.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Ic(u,(l?l>0:n<0)==r)}static of(e,n){let r=new tl(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class ml extends mn{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 Ic(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 AV{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 vr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(um(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=mn.get(a.dom);f&&f.setDOM(um(a.dom))}let c=vr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=mn.get(e.text);s&&this.cache.reused.set(s,2);let o=new tl(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=OA);let i=Da.start(e,n||((r=this.cache.find(Da))===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 vr&&l.mark.eq(o))i=l,n--;else{let a=vr.of(o,(r=this.cache.find(vr,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||!mk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ee.ios&&mk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(cm,0,32)||new ml(cm.toDOM(),0,cm,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 MV(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(Oh,void 0,1);return r&&(r.flags=n),r||new Oh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class OV{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 Ph=[ml,Da,tl,vr,Oh,Es,Mp];for(let t=0;t[]),this.index=Ph.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 vr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof vr&&(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=jt.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof pl){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?_a.block:_a.inline),p=NV(u),m=this.cache.findWidget(h,a-l,p)||ml.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=DV(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=mn.get(i);if(i==this.view.contentDOM)break;s instanceof vr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Es||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Da(i,OA):r||n.push(vr.of(new Jc({tagName:i.nodeName.toLowerCase(),attributes:oV(i)}),i)))}return{line:r,marks:n}}}function mk(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 NV(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 OA={class:"cm-line"};function DV(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&uw(n,t),r&&(t.class+=" "+r)),t}function _V(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 vr&&e.push(r.mark)}return e}function um(t){let e=mn.get(t);return e&&e.setDOM(t.cloneNode()),t}class _a extends Qa{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}}_a.inline=new _a("span");_a.block=new _a("div");const cm=new class extends Qa{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class yk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Wt.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 Mp(e,e.contentDOM),this.updateInner([new ti(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:!VV(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?FV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ti(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,(Ee.ie||Ee.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=zV(o,this.decorations,e.changes);a.length&&(r=ti.extendWithRanges(r,a));let u=HV(l,this.blockWrappers,e.changes);return u.length&&(r=ti.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 IV(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&mn.get(n.text)&&l.cache.reused.set(mn.get(n.text),2),this.tile=l.run(e,n),cy(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=Ee.chrome||Ee.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)&&rc(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)),Ee.gecko&&a.empty&&!this.hasComposition&&LV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ei(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!sc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!sc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Ee.android&&Ee.chrome&&r.contains(f.focusNode)&&WV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Pc(this.view.root);if(d)if(a.empty){if(Ee.gecko){let h=$V(u.node,u.offset);if(h&&h!=3){let p=(h==1?cA:fA)(u.node,u.offset);p&&(u=new Ei(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 Ei(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ei(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&sc(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=Pc(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=Ps(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&&!mn.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 fm?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==gn.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 Es)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?ic(w):[];if(k.length){let b=k[k.length-1],C=a?b.right-g.left:g.right-b.left;C>l&&(l=C,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"?gn.RTL:gn.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=ic(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=ic(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(Wt.replace({widget:new fm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Wt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Ep).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(gw).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(jt.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(CA))try{if(u(this.view,e.range,e))return!0}catch(c){ei(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=mw(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(uV(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(){cy(this.tile)}}function cy(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)cy(r,e)}}function LV(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 PA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=cA(n.focusNode,n.focusOffset),i=fA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=mn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=mn.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 FV(t,e,n){let r=PA(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 ti(a.mapPos(s),a.mapPos(o),s,o),text:i}}function $V(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class fm extends Qa{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 UV(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return ue.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=tr(i.text,s,!1):l=tr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=tr(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+eV(o,s,t.state.tabSize)}function XV(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==ii.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function GV(t,e,n,r){let i=XV(t,e.head,e.assoc||-1),s=!r||i.type!=ii.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==gn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return ue.cursor(a,n?-1:1)}return ue.cursor(n?i.to:i.from,n?-1:1)}function vk(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=xV(i,s,o,l,n),c=mA;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 qV(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Cs.Space&&(i=o),i==o}}function YV(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return ue.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=fy(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:ue.cursor(r,rt.viewState.docHeight)return new Yi(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==ii.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==ii.Text){let f=KV(t,i,u,o,l);return new Yi(f,f==u.from?1:-1)}}if(u.type!=ii.Text)return a<(u.top+u.bottom)/2?new Yi(u.from,1):new Yi(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 QV(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class QV{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)==gn.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 Nc(e.dom,o,l).getClientRects()});return i.after?new Yi(r[i.i+1],-1):new Yi(r[i.i],1)}scanTile(e,n){if(!e.length)return new Yi(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:Nc(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 Yi(r[i.i+1],-1):new Yi(o,1)}}const Kl="￿";class JV{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(Lt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Kl}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=mn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=mn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Mh(i))||Mh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!eU(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=mn.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+(ZV(e,r.node,r.offset)?n:0))}}function ZV(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=NA(e.docView.tile,n,r,0))){let a=s||o?[]:rU(e),u=new JV(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=iU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!sy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!sy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Ee.ios||Ee.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(ue.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=ue.create([ue.cursor(u,h)])}else this.newSel=ue.single(c,u)}}}function NA(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 NA(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 DA(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||Ee.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:It.of(e.text.slice(s.from-l,d).split(Kl))}:(h=_A(f,e.text,u-l,c))&&(Ee.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Kl+Kl&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:It.of(e.text.slice(h.from,h.toB).split(Kl))})}else r&&(!t.hasFocus&&i.facet(bs)||Ih(r,s))&&(r=null);if(!n&&!r)return!1;if((Ee.mac||Ee.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=ue.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:It.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)}:Ee.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=ue.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:It.of([" "])}),n)return yw(t,n,r,o);if(r&&!Ih(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=IA(i.facet(ef).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function yw(t,e,n,r=-1){if(Ee.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Ee.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&&xa(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&xa(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&xa(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=nU(t,e,n));return t.state.facet(bA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function nU(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:ue.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&&PA(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?ue.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 _A(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 rU(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 wk(n,r)),(i!=n||s!=r)&&e.push(new wk(i,s))),e}function iU(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?ue.single(n+e,r+e):null}function Ih(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class sU{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,Ee.safari&&e.contentDOM.addEventListener("input",()=>null),Ee.gecko&&bU(e.contentDOM.ownerDocument)}handleEvent(e){!pU(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=lU(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&&FA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ee.android&&Ee.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Ee.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(LA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||aU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Ee.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&oU(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:Ee.safari&&!Ee.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 oU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function xk(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){ei(n.state,i)}}}function lU(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(xk(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(xk(r.value,a))}}for(let r in Ii)n(r).handlers.push(Ii[r]);for(let r in fr)n(r).observers.push(fr[r]);return e}const LA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],aU="dthko",FA=[16,17,18,20,91,92,224,225],nd=6;function rd(t){return Math.max(0,t)*.7+8}function uU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class cU{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=sA(e.contentDOM),this.atoms=e.state.facet(ef).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(Lt.allowMultipleSelections)&&fU(e,n),this.dragging=hU(e,n)&&zA(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&&uU(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=mw(this.view);e.clientX-a.left<=i+nd?n=-rd(i-e.clientX):e.clientX+a.right>=o-nd&&(n=rd(e.clientX-o)),e.clientY-a.top<=s+nd?r=-rd(s-e.clientY):e.clientY+a.bottom>=l-nd&&(r=rd(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=IA(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 fU(t,e){let n=t.state.facet(yA);return n.length?n[0](e):Ee.mac?e.metaKey:e.ctrlKey}function dU(t,e){let n=t.state.facet(vA);return n.length?n[0](e):Ee.mac?!e.altKey:!e.ctrlKey}function hU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Pc(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 pU(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=mn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Ii=Object.create(null),fr=Object.create(null),$A=Ee.ie&&Ee.ie_version<15||Ee.ios&&Ee.webkit_version<604;function gU(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(),BA(t,n.value)},50)}function Rp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function BA(t,e){e=Rp(t.state,dw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(dy!=null&&n.selection.ranges.every(a=>a.empty)&&dy==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:ue.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:ue.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}fr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Ee.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};fr.wheel=fr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ii.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);fr.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")};fr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};fr.touchend=(t,e)=>{t.inputState.touchActive=!1};Ii.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(wA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=yU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new cU(t,e,n,r)),r&&t.observer.ignore(()=>{aA(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 bk(t,e,n,r){if(r==1)return ue.cursor(e,n);if(r==2)return UV(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?(Sk+1)%3:1}function yU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=zA(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=bk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=bk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=vU(i,a.pos))?u:l?i.addRange(c):ue.create([c])}}}function vU(t,e){for(let n=0;n=e)return ue.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}Ii.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=ue.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Rp(t.state,hw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ii.dragend=t=>(t.inputState.draggedContent=null,!1);function Tk(t,e,n,r){if(n=Rp(t.state,dw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&dU(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}Ii.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&&Tk(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 Tk(t,e,r,!0),!0}return!1};Ii.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=$A?null:e.clipboardData;return n?(BA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(gU(t),!1)};function wU(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 xU(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:Rp(t,hw,e.join(t.lineBreak)),ranges:n,linewise:r}}let dy=null;Ii.copy=Ii.cut=(t,e)=>{if(!rc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=xU(t.state);if(!n&&!i)return!1;dy=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=$A?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(wU(t,n),!1)};const jA=Po.define();function HA(t,e){let n=[];for(let r of t.facet(kA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:jA.of(!0)}):null}function WA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=HA(t.state,e);n?t.dispatch(n):t.update([])}},10)}fr.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),WA(t)};fr.blur=t=>{t.observer.clearSelectionRange(),WA(t)};fr.compositionstart=fr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};fr.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,Ee.chrome&&Ee.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};fr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ii.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 yw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Ee.chrome&&Ee.android&&(i=LA.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 Ee.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ee.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>fr.compositionend(t,e),20),!1};const Ek=new Set;function bU(t){Ek.has(t)||(Ek.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Ak=["pre-wrap","normal","pre-line","break-spaces"];let La=!1;function Mk(){La=!1}class kU{constructor(e){this.lineWrapping=e,this.doc=It.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 Ak.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&&(La=!0),this.height=e)}replace(e,n,r){return cr.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 Dr extends VA{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 Ti(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 Dr||i instanceof Hn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Hn?i=new Dr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):cr.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 Hn extends cr{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 Hn?r[r.length-1]=new Hn(s.length+i):r.push(null,new Hn(i-1))}if(e>0){let s=r[0];s instanceof Hn?r[0]=new Hn(e+s.length):r.unshift(new Hn(e-1),null)}return cr.of(r)}decomposeLeft(e,n){n.push(new Hn(e-1),null)}decomposeRight(e,n){n.push(null,new Hn(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 Hn(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 Dr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Hn(s-l).updateHeight(e,l));let u=cr.of(o);return(a<0||Math.abs(u.height-this.height)>=_d||Math.abs(a-this.heightMetrics(e,n).perLine)>=_d)&&(La=!0),Nh(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 TU extends cr{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&&Rk(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?cr.of(this.break?[e,null,n]:[e,n]):(this.left=Nh(this.left,e),this.right=Nh(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 Rk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Hn&&(r=t[e+1])instanceof Hn&&t.splice(e-1,3,new Hn(n.length+1+r.length))}const EU=5;class vw{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 Dr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Dr(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=EU)&&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 Dr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Hn(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 Dr)return e;let n=new Dr(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 Dr)&&!this.isCovered?this.nodes.push(new Dr(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 OU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function PU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class hm{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 kU(r),this.stateDeco=Ik(n),this.heightMap=cr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle.setDoc(n.doc),[new ti(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=Wt.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 id(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?Pk:new ww(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(Bu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Ik(this.state);let i=e.changedRanges,s=ti.extendWithRanges(i,AU(r,this.stateDeco,e?e.changes:In.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Mk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||La)&&(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(kV)&&(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"?gn.RTL:gn.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:C}=iA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=b,this.scaleY=C,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=sA(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=uA(this.scrollParent||e.win);let m=(this.printing?PU:RU)(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&&!OU(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:C,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,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)),Mk();for(let C of this.viewports){let T=C.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?cr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle,[new ti(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new SU(C.from,T))}La&&(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 id(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!=gn.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(ue.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 hm(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.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=[];jt.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)||Bu(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)||Bu(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 Bu(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 id{constructor(e,n){this.from=e,this.to=n}}function NU(t,e,n){let r=[],i=t,s=0;return jt.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 od(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 DU(t,e){for(let n of t)if(e(n))return n}const Pk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Ik(t){let e=t.facet(Ep).filter(r=>typeof r!="function"),n=t.facet(gw).filter(r=>typeof r!="function");return n.length&&e.push(jt.join(n)),e}class ww{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 Bu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ti(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Bu(i,e)):t._content)}const ld=He.define({combine:t=>t.join(" ")}),hy=He.define({combine:t=>t.indexOf(!0)>-1}),py=So.newName(),UA=So.newName(),KA=So.newName(),XA={"&light":"."+UA,"&dark":"."+KA};function gy(t,e,n){return new So(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 _U=gy("."+py,{"&":{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"}},XA),LU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},pm=Ee.ie&&Ee.ie_version<=11;class FU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new cV,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);(Ee.ie&&Ee.ie_version<=11||Ee.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&&Ee.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ee.chrome&&Ee.chrome_version<126)&&(this.editContext=new BU(e),e.state.facet(bs)&&(e.contentDOM.editContext=this.editContext.editContext)),pm&&(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(bs)?r.root.activeElement!=this.dom:!rc(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}(Ee.ie&&Ee.ie_version<=11||Ee.android&&Ee.chrome)&&!r.state.selection.main.empty&&i.focusNode&&sc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Pc(e.root);if(!n)return!1;let r=Ee.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&$U(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=rc(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&&xa(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&&rc(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 tU(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=DA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Ih(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=Nk(n,e.previousSibling||e.target.previousSibling,-1),i=Nk(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(bs)!=e.state.facet(bs)&&(e.view.contentDOM.editContext=e.state.facet(bs)?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 Nk(t,e,n){for(;e;){let r=mn.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 Dk(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 sc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function $U(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Dk(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?Dk(t,n):null}class BU{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=_A(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=ue.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Ih(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:It.of(r.text.slice(c.from,c.toB).split(` -`))};if((Ee.mac||Ee.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:It.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);yw(e,f,ue.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=Pc(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 qe{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||fV(e.parent)||document,this.viewState=new Ok(this,e.state||Lt.create(e)),e.scrollTo&&e.scrollTo.is(td)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(aa).map(i=>new am(i));for(let i of this.plugins)i.update(this);this.observer=new FU(this),this.inputState=new sU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new yk(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(jA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=HA(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(Lt.phrases)!=this.state.facet(Lt.phrases))return this.setState(s);i=Rh.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(qe.cursorScrollMargin);f=new ba(h.empty?h:ue.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",m,p)}for(let h of d.effects)h.is(td)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Dh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet($u)!=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(ld)!=i.state.facet(ld)&&(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(uy))try{d(i)}catch(h){ei(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!DA(this,c)&&u.force&&xa(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 Ok(this,e),this.plugins=e.facet(aa).map(r=>new am(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new yk(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(aa),r=e.state.facet(aa);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new am(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(uA(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 ei(this.state,p),_k}}),f=Rh.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)&&!(Ee.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(uy))l(n)}get themeClasses(){return py+" "+(this.state.facet(hy)?KA:UA)+" "+this.state.facet(ld)}updateAttrs(){let e=Lk(this,EA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(bs)?"true":"false",class:"cm-content",style:`${Ee.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Lk(this,pw,n);let r=this.observer.ignore(()=>{let i=fk(this.contentDOM,this.contentAttrs,n),s=fk(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(qe.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($u);let e=this.state.facet(qe.cspNonce);So.mount(this.root,this.styleModules.concat(_U).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 dm(this,e,vk(this,e,n,r))}moveByGroup(e,n){return dm(this,e,vk(this,e,n,r=>qV(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 ue.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return GV(this,e,n,r)}moveVertically(e,n,r){return dm(this,e,YV(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=fy(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),fy(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Zi.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==gn.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(SA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>zU)return gA(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||pA(s.isolates,r=pk(this,e))))return s.order;r||(r=pk(this,e));let i=wV(e.text,n,r);return this.bidiCache.push(new Dh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ee.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{aA(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 td.of(new ba(typeof e=="number"?ue.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 td.of(new ba(ue.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 ai.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ai.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=So.newName(),i=[ld.of(r),$u.of(gy(`.${r}`,e))];return n&&n.dark&&i.push(hy.of(!0)),i}static baseTheme(e){return ow.lowest($u.of(gy("."+py,e,XA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&mn.get(r)||mn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}qe.styleModule=$u;qe.inputHandler=bA;qe.clipboardInputFilter=dw;qe.clipboardOutputFilter=hw;qe.scrollHandler=CA;qe.focusChangeEffect=kA;qe.perLineTextDirection=SA;qe.exceptionSink=xA;qe.updateListener=uy;qe.editable=bs;qe.mouseSelectionStyle=wA;qe.dragMovesSelection=vA;qe.clickAddsSelectionRange=yA;qe.decorations=Ep;qe.blockWrappers=AA;qe.outerDecorations=gw;qe.atomicRanges=ef;qe.bidiIsolatedRanges=MA;qe.cursorScrollMargin=He.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}}});qe.scrollMargins=RA;qe.darkTheme=hy;qe.cspNonce=He.define({combine:t=>t.length?t[0]:""});qe.contentAttributes=pw;qe.editorAttributes=EA;qe.lineWrapping=qe.contentAttributes.of({class:"cm-lineWrapping"});qe.announce=Xt.define();const zU=4096,_k={};class Dh{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:gn.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&&uw(o,n)}return n}const jU=Ee.mac?"mac":Ee.windows?"win":Ee.linux?"linux":"key";function HU(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 ro=null;const UU=4e3;function KU(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=>HU(g,e));for(let g=1;g{let k=ro={view:w,prefix:y,scope:o};return setTimeout(()=>{ro==k&&(ro=null)},UU),!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,my))}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 my=null;function XU(t,e,n,r){my=e;let i=iV(e),s=z9(i,0),o=j9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;ro&&ro.view==n&&ro.scope==r&&(l=ro.prefix+" ",FA.indexOf(e.keyCode)<0&&(u=!0,ro=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+ad(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Ee.windows&&e.ctrlKey&&e.altKey)&&!(Ee.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Co[e.keyCode])&&p!=i?(d(h[l+ad(p,e,!0)])||e.shiftKey&&(m=Rc[e.keyCode])!=i&&m!=p&&d(h[l+ad(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+ad(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),my=null,a}class GU extends Qa{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?ic(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Ic(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 qU(t){let e=ai.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Wt.set([Wt.widget({widget:new GU(t),side:1}).range(0)]):Wt.none}get decorations(){return this.view.state.doc.length?Wt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,qe.contentAttributes.of({"aria-placeholder":t})]:e}const ud="-10000px";class qA{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 YU(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const gm=He.define({combine:t=>{var e,n,r;return{position:Ee.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)||YU}}}),$k=new WeakMap,YA=ai.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(gm);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 qA(t,QA,(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(gm);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=ud,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(Ee.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=mw(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(gm).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=ud;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,x=(e=$k.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||JU,y=this.view.textDirection==gn.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.topC&&(C=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",Bk(c,(w-t.parent.left)/i)):(c.style.top=C/s+"px",Bk(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:C,right:T,bottom:C+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=ud}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Bk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const QU=qe.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"}}}),JU={x:0,y:0},QA=He.define({enables:[YA,QU]}),_h=He.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Op{static create(e){return new Op(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new qA(e,_h,(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 ZU=QA.compute([_h],t=>{let e=t.facet(_h);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:Op.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),e7=He.define();class t7{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==gn.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=>ei(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(YA),n=e?e.manager.tooltips.findIndex(r=>r.create==Op.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&&!n7(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:!r7(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 cd=4;function n7(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-cd&&e.clientX<=r+cd&&e.clientY>=i-cd&&e.clientY<=s+cd}function r7(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 i7(t,e={}){let n=Xt.define(),r=new WeakMap,i=us.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,yr.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(s7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>_h.from(o)});const s=ai.define(o=>new t7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,e7.of(s),ZU]}}const s7=Xt.define(),zk=He.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),o7=ai.fromClass(class{constructor(t){this.input=t.state.facet(yy),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(zk);this.top=new fd(t,!0,e.topContainer),this.bottom=new fd(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(zk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new fd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new fd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(yy);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=>qe.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class fd{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=jk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=jk(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 jk(t){let e=t.nextSibling;return t.remove(),e}const yy=He.define({enables:o7});class Fa extends hl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Fa.prototype.elementClass="";Fa.prototype.toDOM=void 0;Fa.prototype.mapMode=yr.TrackBefore;Fa.prototype.startSide=Fa.prototype.endSide=-1;Fa.prototype.point=!0;const JA=1024;let l7=0;class mm{constructor(e,n){this.from=e,this.to=n}}class Ct{constructor(e={}){this.id=l7++,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=Tr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Ct.closedBy=new Ct({deserialize:t=>t.split(" ")});Ct.openedBy=new Ct({deserialize:t=>t.split(" ")});Ct.group=new Ct({deserialize:t=>t.split(" ")});Ct.isolate=new Ct({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Ct.contextHash=new Ct({perNode:!0});Ct.lookAhead=new Ct({perNode:!0});Ct.mounted=new Ct({perNode:!0});class lc{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[Ct.mounted.id]}}const a7=Object.create(null);class Tr{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):a7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Tr(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(Ct.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(Ct.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Tr.none=new Tr("",Object.create(null),0,8);class xw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|pn.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:Sw(Tr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Sn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Sn(Tr.none,n,r,i)))}static build(e){return d7(e)}}Sn.empty=new Sn(Tr.none,[],[],0);class bw{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 bw(this.buffer,this.index)}}class Eo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Tr.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 Dc(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&pn.EnterBracketed&&c instanceof Sn&&(d=lc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!ZA(i,r,f,f+c.length))){if(c instanceof Eo){if(s&pn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new ao(new u7(o,c,e,f),null,h)}else if(s&pn.IncludeAnonymous||!c.type.isAnonymous||kw(c)){let h;if(!(s&pn.IgnoreMounts)&&(h=lc.get(c))&&!h.overlay)return new si(h.tree,f,e,o);let p=new si(c,f,e,o);return s&pn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&pn.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&pn.IgnoreOverlays)&&(i=lc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&pn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new si(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 Wk(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 vy(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 u7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class ao extends eM{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 ao(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&pn.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 ao(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 ao(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 ao(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 Sn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function tM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new si(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Dc(l,e,n,!1))}}return i?tM(i):r}class wy{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&~pn.EnterBracketed,e instanceof si)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 si?(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&pn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&pn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&pn.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&pn.IncludeAnonymous||l instanceof Eo||!l.type.isAnonymous||kw(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 vy(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 kw(t){return t.children.some(e=>e instanceof Eo||!e.type.isAnonymous||kw(e))}function d7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=JA,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new bw(n,n.length):n,a=r.types,u=0,c=0;function f(b,C,T,A,M,O){let{id:_,start:P,end:I,size:D}=l,Y=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 se=a[_],V,J,R=P-b;if(I-P<=i&&(J=x(l.pos-C,M))){let N=new Uint16Array(J.size-J.skip),L=l.pos-J.size,z=N.length;for(;l.pos>L;)z=g(J.start,N,z);V=new Eo(N,I-J.start,r),R=J.start-b}else{let N=l.pos-D;l.next();let L=[],z=[],j=_>=o?_:-1,B=0,oe=I;for(;l.pos>N;)j>=0&&l.id==j&&l.size>=0?(l.end<=oe-i&&(p(L,z,P,B,l.end,oe,j,Y,ie),B=L.length,oe=l.end),l.next()):O>2500?d(P,N,L,z):f(P,N,L,z,j,O+1);if(j>=0&&B>0&&B-1&&B>0){let fe=h(se,ie);V=Sw(se,L,z,0,L.length,0,I-P,fe,fe)}else V=m(se,L,z,I-P,Y-I,ie)}T.push(V),A.push(R)}function d(b,C,T,A){let M=[],O=0,_=-1;for(;l.pos>C;){let{id:P,start:I,end:D,size:Y}=l;if(Y>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,Y=0;D>=0;D-=3)P[Y++]=M[D],P[Y++]=M[D+1]-I,P[Y++]=M[D+2]-I,P[Y++]=Y;T.push(new Eo(P,M[2]-I,r)),A.push(I-b)}}function h(b,C){return(T,A,M)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Sn){if(!_&&P.type==b&&P.length==M)return P;(I=P.prop(Ct.lookAhead))&&(O=A[_]+P.length+I)}return m(b,T,A,M,O,C)}}function p(b,C,T,A,M,O,_,P,I){let D=[],Y=[];for(;b.length>A;)D.push(b.pop()),Y.push(C.pop()+T-M);b.push(m(r.types[_],D,Y,O-M,P-O,I)),C.push(M-T)}function m(b,C,T,A,M,O,_){if(O){let P=[Ct.contextHash,O];_=_?[P].concat(_):[P]}if(M>25){let P=[Ct.lookAhead,M];_=_?[P].concat(_):[P]}return new Sn(b,C,T,A,_)}function x(b,C){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==C&&D>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let Y=T.pos-D;if(D<0||Y=o?4:0,se=T.start;for(T.next();T.pos>Y;){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=se,A+=D,O+=ie}return(C<0||A==b)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function g(b,C,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,C,T)}C[--T]=P,C[--T]=O-b,C[--T]=M-b,C[--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 Sn(a[t.topID],y.reverse(),w.reverse(),k)}const Vk=new WeakMap;function Ld(t,e){if(!t.isAnonymous||e instanceof Eo||e.type!=t)return 1;let n=Vk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Sn)){n=1;break}n+=Ld(t,r)}Vk.set(e,n)}return n}function Sw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;C+=T}if(w==k+1){if(C>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(Sw(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 ol{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 ol(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 ol(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew mm(i.from,i.to)):[new mm(0,0)]:[new mm(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 h7{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 Ct({perNode:!0});let p7=0;class Qr{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=p7++}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 Qr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Qr(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 Lh(e);return r=>r.modified.indexOf(n)>-1?r:Lh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let g7=0;class Lh{constructor(e){this.name=e,this.instances=[],this.id=g7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&m7(n,l.modified));if(r)return r;let i=[],s=new Qr(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=y7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Lh.get(l,a));return s}}function m7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function y7(t){let e=[[]];for(let n=0;nr.length-n.length)}function rM(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 _c(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return iM.add(e)}const iM=new Ct({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 _c(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class _c{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 v7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function w7(t,e,n,r=0,i=t.length){let s=new x7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class x7{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=b7(e)||_c.empty,f=v7(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(Ct.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 b7(t){let e=t.type.prop(iM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ve=Qr.define,hd=ve(),Js=ve(),Uk=ve(Js),Kk=ve(Js),Zs=ve(),pd=ve(Zs),ym=ve(Zs),Ui=ve(),Wo=ve(Ui),Wi=ve(),Vi=ve(),xy=ve(),Mu=ve(xy),gd=ve(),Ge={comment:hd,lineComment:ve(hd),blockComment:ve(hd),docComment:ve(hd),name:Js,variableName:ve(Js),typeName:Uk,tagName:ve(Uk),propertyName:Kk,attributeName:ve(Kk),className:ve(Js),labelName:ve(Js),namespace:ve(Js),macroName:ve(Js),literal:Zs,string:pd,docString:ve(pd),character:ve(pd),attributeValue:ve(pd),number:ym,integer:ve(ym),float:ve(ym),bool:ve(Zs),regexp:ve(Zs),escape:ve(Zs),color:ve(Zs),url:ve(Zs),keyword:Wi,self:ve(Wi),null:ve(Wi),atom:ve(Wi),unit:ve(Wi),modifier:ve(Wi),operatorKeyword:ve(Wi),controlKeyword:ve(Wi),definitionKeyword:ve(Wi),moduleKeyword:ve(Wi),operator:Vi,derefOperator:ve(Vi),arithmeticOperator:ve(Vi),logicOperator:ve(Vi),bitwiseOperator:ve(Vi),compareOperator:ve(Vi),updateOperator:ve(Vi),definitionOperator:ve(Vi),typeOperator:ve(Vi),controlOperator:ve(Vi),punctuation:xy,separator:ve(xy),bracket:Mu,angleBracket:ve(Mu),squareBracket:ve(Mu),paren:ve(Mu),brace:ve(Mu),content:Ui,heading:Wo,heading1:ve(Wo),heading2:ve(Wo),heading3:ve(Wo),heading4:ve(Wo),heading5:ve(Wo),heading6:ve(Wo),contentSeparator:ve(Ui),list:ve(Ui),quote:ve(Ui),emphasis:ve(Ui),strong:ve(Ui),link:ve(Ui),monospace:ve(Ui),strikethrough:ve(Ui),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:gd,documentMeta:ve(gd),annotation:ve(gd),processingInstruction:ve(gd),definition:Qr.defineModifier("definition"),constant:Qr.defineModifier("constant"),function:Qr.defineModifier("function"),standard:Qr.defineModifier("standard"),local:Qr.defineModifier("local"),special:Qr.defineModifier("special")};for(let t in Ge){let e=Ge[t];e instanceof Qr&&(e.name=t)}sM([{tag:Ge.link,class:"tok-link"},{tag:Ge.heading,class:"tok-heading"},{tag:Ge.emphasis,class:"tok-emphasis"},{tag:Ge.strong,class:"tok-strong"},{tag:Ge.keyword,class:"tok-keyword"},{tag:Ge.atom,class:"tok-atom"},{tag:Ge.bool,class:"tok-bool"},{tag:Ge.url,class:"tok-url"},{tag:Ge.labelName,class:"tok-labelName"},{tag:Ge.inserted,class:"tok-inserted"},{tag:Ge.deleted,class:"tok-deleted"},{tag:Ge.literal,class:"tok-literal"},{tag:Ge.string,class:"tok-string"},{tag:Ge.number,class:"tok-number"},{tag:[Ge.regexp,Ge.escape,Ge.special(Ge.string)],class:"tok-string2"},{tag:Ge.variableName,class:"tok-variableName"},{tag:Ge.local(Ge.variableName),class:"tok-variableName tok-local"},{tag:Ge.definition(Ge.variableName),class:"tok-variableName tok-definition"},{tag:Ge.special(Ge.variableName),class:"tok-variableName2"},{tag:Ge.definition(Ge.propertyName),class:"tok-propertyName tok-definition"},{tag:Ge.typeName,class:"tok-typeName"},{tag:Ge.namespace,class:"tok-namespace"},{tag:Ge.className,class:"tok-className"},{tag:Ge.macroName,class:"tok-macroName"},{tag:Ge.propertyName,class:"tok-propertyName"},{tag:Ge.operator,class:"tok-operator"},{tag:Ge.comment,class:"tok-comment"},{tag:Ge.meta,class:"tok-meta"},{tag:Ge.invalid,class:"tok-invalid"},{tag:Ge.punctuation,class:"tok-punctuation"}]);var vm;const ua=new Ct;function k7(t){return He.define({combine:t?e=>e.concat(t):void 0})}const S7=new Ct;class Ai{constructor(e,n,r=[],i=""){this.data=e,this.name=i,Lt.prototype.hasOwnProperty("tree")||Object.defineProperty(Lt.prototype,"tree",{get(){return os(this)}}),this.parser=n,this.extension=[Ba.of(this),Lt.languageData.of((s,o,l)=>{let a=Xk(s,o,l),u=a.type.prop(ua);if(!u)return[];let c=s.facet(u),f=a.type.prop(S7);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 Xk(e,n,r).type.prop(ua)==this.data}findRegions(e){let n=e.facet(Ba);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(ua)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Ct.mounted);if(l){if(l.tree.prop(ua)==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 Fh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function os(t){let e=t.field(Ai.state,!1);return e?e.tree:Sn.empty}class C7{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 Ru=null;class $h{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 $h(e,n,[],Sn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new C7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Sn.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(ol.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ru;Ru=this;try{return e()}finally{Ru=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Gk(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=ol.applyChanges(r,a),i=Sn.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=Gk(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 nM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Ru;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 Sn(Tr.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 Ru}}function Gk(t,e,n){return ol.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class $a{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 $a(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$h.create(e.facet(Ba).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new $a(r)}}Ai.state=us.define({create:$a.init,update(t,e){for(let n of e.effects)if(n.is(Ai.setState))return n.value;return e.startState.facet(Ba)!=e.state.facet(Ba)?$a.init(e.state):t.apply(e)}});let oM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(oM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const wm=typeof navigator<"u"&&(!((vm=navigator.scheduling)===null||vm===void 0)&&vm.isInputPending)?()=>navigator.scheduling.isInputPending():null,T7=ai.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(Ai.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(Ai.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=oM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>wm&&wm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ai.setState.of(new $a(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=>ei(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()}}}),Ba=He.define({combine(t){return t.length?t[0]:null},enables:t=>[Ai.state,T7,qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class E7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const A7=He.define(),Cw=He.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 Bh(t){let e=t.facet(Cw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function zh(t,e){let n="",r=t.tabSize,i=t.facet(Cw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?M7(t,n,e):null}class Pp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Bh(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 Cp(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 aM=new Ct;function M7(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 uM(r,t,n)}function uM(t,e,n){for(let r=t;r;r=r.next){let i=O7(r.node);if(i)return i(Tw.create(e,n,r))}return 0}function R7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function O7(t){let e=t.type.prop(aM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Ct.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>D7(o,!0,1,void 0,s&&!R7(o)?i.from:void 0)}return t.parent==null?P7:null}function P7(){return 0}class Tw extends Pp{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 Tw(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(I7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return uM(this.context.next,this.base,this.pos)}}function I7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function N7(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 D7(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=N7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function qk({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const _7=new Ct;function L7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(ua)==o.data:o?l=>l==o:void 0,this.style=sM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new So(r):null,this.themeType=n.themeType}static define(e,n){return new Ip(e,n||{})}}const by=He.define(),F7=He.define({combine(t){return t.length?[t[0]]:null}});function xm(t){let e=t.facet(by);return e.length?e:t.facet(F7)}function Yk(t,e){let n=[B7],r;return t instanceof Ip&&(t.module&&n.push(qe.styleModule.of(t.module)),r=t.themeType),r?n.push(by.computeN([qe.darkTheme],i=>i.facet(qe.darkTheme)==(r=="dark")?[t]:[])):n.push(by.of(t)),n}class $7{constructor(e){this.markCache=Object.create(null),this.tree=os(e.state),this.decorations=this.buildDeco(e,xm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=os(e.state),r=xm(e.state),i=r!=xm(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 Wt.none;let r=new Na;for(let{from:i,to:s}of e.visibleRanges)w7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Wt.mark({class:a})))},i,s);return r.finish()}}const B7=ow.high(ai.fromClass($7,{decorations:t=>t.decorations})),z7=1e4,j7="()[]{}",H7=new Ct;function ky(t,e,n){let r=t.prop(e<0?Ct.openedBy:Ct.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 Sy(t){let e=t.type.prop(H7);return e?e(t.node):t}function ca(t,e,n,r={}){let i=r.maxScanDistance||z7,s=r.brackets||j7,o=os(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=ky(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return W7(t,e,n,a,c,u,s)}}return V7(t,e,n,o,l.type,i,s)}function W7(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 U7=Object.create(null),Qk=[Tr.none],Jk=[],Zk=Object.create(null),K7=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"]])K7[t]=X7(U7,e);function bm(t,e){Jk.indexOf(t)>-1||(Jk.push(t),console.warn(e))}function X7(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ge[u];c?typeof c=="function"?a.length?a=a.map(c):bm(u,`Modifier ${u} used at start of tag`):a.length?bm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:bm(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=Zk[i];if(s)return s.id;let o=Zk[i]=Tr.define({id:Qk.length,name:r,props:[rM({[r]:n})]});return Qk.push(o),o.id}gn.RTL,gn.LTR;const G7=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Aw(t.state,n.from);return r.line?q7(t):r.block?Q7(t):!1};function Ew(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 q7=Ew(eK,0),Y7=Ew(cM,0),Q7=Ew((t,e)=>cM(t,e,Z7(e)),0);function Aw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Ou=50;function J7(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Ou,r),o=t.sliceDoc(i,i+Ou),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*Ou?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Ou),f=t.sliceDoc(i-Ou,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 Z7(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 cM(t,e,n=e.selection.ranges){let r=n.map(s=>Aw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>J7(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 Cy=Po.define(),tK=Po.define(),nK=He.define(),fM=He.define({combine(t){return JE(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)})}}),dM=us.define({create(){return es.empty},update(t,e){let n=e.state.facet(fM),r=e.annotation(Cy);if(r){let a=br.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=jh(c,c.length,n.minDepth,a):c=gM(c,e.startState.selection),new es(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(tK);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=br.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 es(t.done.map(br.fromJSON),t.undone.map(br.fromJSON))}});function rK(t={}){return[dM,fM.of(t),qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?hM:e.inputType=="historyRedo"?Ty:null;return r?(e.preventDefault(),r(n)):!1}})]}function Np(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(dM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const hM=Np(0,!1),Ty=Np(1,!1),iK=Np(0,!0),sK=Np(1,!0);class br{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 br(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 br(e.changes&&In.fromJSON(e.changes),[],e.mapped&&ss.fromJSON(e.mapped),e.startSelection&&ue.fromJSON(e.startSelection),e.selectionsAfter.map(ue.fromJSON))}static fromTransaction(e,n){let r=ni;for(let i of e.startState.facet(nK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new br(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ni)}static selection(e){return new br(void 0,ni,void 0,void 0,e)}}function jh(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 oK(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 lK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function pM(t,e){return t.length?e.length?t.concat(e):t:e}const ni=[],aK=200;function gM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-aK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),jh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[br.selection([e])]}function uK(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 km(t,e){if(!t.length)return t;let n=t.length,r=ni;for(;n;){let i=cK(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?[br.selection(r)]:ni}function cK(t,e,n){let r=pM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ni,n);if(!t.changes)return br.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new br(i,Xt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const fK=/^(input\.type|delete)($|\.)/;class es{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 es(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||fK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Dp(n,e))}function rr(t){return t.textDirectionAt(t.state.selection.main.head)==gn.LTR}const yM=t=>mM(t,!rr(t)),vM=t=>mM(t,rr(t));function wM(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Dp(n,e))}const hK=t=>wM(t,!rr(t)),pK=t=>wM(t,rr(t));function gK(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 _p(t,e,n){let r=os(t).resolveInner(e.head),i=n?Ct.closedBy:Ct.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;gK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ca(t,r.from,1):ca(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,ue.cursor(l,n?-1:1)}const mK=t=>_i(t,e=>_p(t.state,e,!rr(t))),yK=t=>_i(t,e=>_p(t.state,e,rr(t)));function xM(t,e){return _i(t,n=>{if(!n.empty)return Dp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const bM=t=>xM(t,!1),kM=t=>xM(t,!0);function SM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Dp(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.bottomCM(t,!1),Ey=t=>CM(t,!0);function Io(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=ue.cursor(r.from+s))}return i}const vK=t=>_i(t,e=>Io(t,e,!0)),wK=t=>_i(t,e=>Io(t,e,!1)),xK=t=>_i(t,e=>Io(t,e,!rr(t))),bK=t=>_i(t,e=>Io(t,e,rr(t))),kK=t=>_i(t,e=>ue.cursor(t.lineBlockAt(e.head).from,1)),SK=t=>_i(t,e=>ue.cursor(t.lineBlockAt(e.head).to,-1));function CK(t,e,n){let r=!1,i=Ja(t.selection,s=>{let o=ca(t,s.head,-1)||ca(t,s.head,1)||s.head>0&&ca(t,s.head-1,1)||s.headCK(t,e);function ui(t,e,n){let r=Ja(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=ue.range(i.head,i.anchor));let s=n(i);return ue.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function TM(t,e){return ui(t,e,n=>t.moveByChar(n,e))}const EM=t=>TM(t,!rr(t)),AM=t=>TM(t,rr(t));function MM(t,e){return ui(t,e,n=>t.moveByGroup(n,e))}const EK=t=>MM(t,!rr(t)),AK=t=>MM(t,rr(t)),MK=t=>{let e=!rr(t);return ui(t,e,n=>_p(t.state,n,e))},RK=t=>{let e=rr(t);return ui(t,e,n=>_p(t.state,n,e))};function RM(t,e){return ui(t,e,n=>t.moveVertically(n,e))}const OM=t=>RM(t,!1),PM=t=>RM(t,!0);function IM(t,e){return ui(t,e,n=>t.moveVertically(n,e,SM(t).height))}const tS=t=>IM(t,!1),nS=t=>IM(t,!0),OK=t=>ui(t,!0,e=>Io(t,e,!0)),PK=t=>ui(t,!1,e=>Io(t,e,!1)),IK=t=>{let e=!rr(t);return ui(t,e,n=>Io(t,n,e))},NK=t=>{let e=rr(t);return ui(t,e,n=>Io(t,n,e))},DK=t=>ui(t,!1,e=>ue.cursor(t.lineBlockAt(e.head).from)),_K=t=>ui(t,!0,e=>ue.cursor(t.lineBlockAt(e.head).to)),rS=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),iS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),sS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),oS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),LK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),FK=({state:t,dispatch:e})=>{let n=Lp(t).map(({from:r,to:i})=>ue.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:ue.create(n),userEvent:"select"})),!0},$K=({state:t,dispatch:e})=>{let n=Ja(t.selection,r=>{let i=os(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 ue.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function NM(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(Di(n,ue.create(i,i.length-1))),!0)}const BK=t=>NM(t,!1),zK=t=>NM(t,!0),jK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ue.create([n.main]):n.main.empty||(r=ue.create([ue.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function tf(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=md(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=md(t,o,!1),l=md(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:ue.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const DM=(t,e,n)=>tf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iDM(t,!1,!0),_M=t=>DM(t,!0,!1),LM=(t,e)=>tf(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=tr(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}),FM=t=>LM(t,!1),HK=t=>LM(t,!0),WK=t=>tf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headtf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),UK=t=>tf(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:It.of(["",""])},range:ue.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},XK=({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:tr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:tr(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:ue.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Lp(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 $M(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Lp(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(ue.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(ue.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ue.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const GK=({state:t,dispatch:e})=>$M(t,e,!1),qK=({state:t,dispatch:e})=>$M(t,e,!0);function BM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Lp(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 YK=({state:t,dispatch:e})=>BM(t,e,!1),QK=({state:t,dispatch:e})=>BM(t,e,!0),JK=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Lp(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 ZK(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=os(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(Ct.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 lS=zM(!1),eX=zM(!0);function zM(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&&ZK(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Pp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=lM(u,s);for(c==null&&(c=Cp(/^\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:ue.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const tX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Pp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Mw(t,(s,o,l)=>{let a=lM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=zh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(Mw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Cw)})}),{userEvent:"input.indent"})),!0),HM=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Mw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Cp(i,t.tabSize),o=0,l=zh(t,Math.max(0,s-Bh(t)));for(;o(t.setTabFocusMode(),!0),rX=[{key:"Ctrl-b",run:yM,shift:EM,preventDefault:!0},{key:"Ctrl-f",run:vM,shift:AM},{key:"Ctrl-p",run:bM,shift:OM},{key:"Ctrl-n",run:kM,shift:PM},{key:"Ctrl-a",run:kK,shift:DK},{key:"Ctrl-e",run:SK,shift:_K},{key:"Ctrl-d",run:_M},{key:"Ctrl-h",run:Ay},{key:"Ctrl-k",run:WK},{key:"Ctrl-Alt-h",run:FM},{key:"Ctrl-o",run:KK},{key:"Ctrl-t",run:XK},{key:"Ctrl-v",run:Ey}],iX=[{key:"ArrowLeft",run:yM,shift:EM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:hK,shift:EK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:xK,shift:IK,preventDefault:!0},{key:"ArrowRight",run:vM,shift:AM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:pK,shift:AK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:bK,shift:NK,preventDefault:!0},{key:"ArrowUp",run:bM,shift:OM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:rS,shift:sS},{mac:"Ctrl-ArrowUp",run:eS,shift:tS},{key:"ArrowDown",run:kM,shift:PM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:iS,shift:oS},{mac:"Ctrl-ArrowDown",run:Ey,shift:nS},{key:"PageUp",run:eS,shift:tS},{key:"PageDown",run:Ey,shift:nS},{key:"Home",run:wK,shift:PK,preventDefault:!0},{key:"Mod-Home",run:rS,shift:sS},{key:"End",run:vK,shift:OK,preventDefault:!0},{key:"Mod-End",run:iS,shift:oS},{key:"Enter",run:lS,shift:lS},{key:"Mod-a",run:LK},{key:"Backspace",run:Ay,shift:Ay,preventDefault:!0},{key:"Delete",run:_M,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:FM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:HK,preventDefault:!0},{mac:"Mod-Backspace",run:VK,preventDefault:!0},{mac:"Mod-Delete",run:UK,preventDefault:!0}].concat(rX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),sX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:mK,shift:MK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:yK,shift:RK},{key:"Alt-ArrowUp",run:GK},{key:"Shift-Alt-ArrowUp",run:YK},{key:"Alt-ArrowDown",run:qK},{key:"Shift-Alt-ArrowDown",run:QK},{key:"Mod-Alt-ArrowUp",run:BK},{key:"Mod-Alt-ArrowDown",run:zK},{key:"Escape",run:jK},{key:"Mod-Enter",run:eX},{key:"Alt-l",mac:"Ctrl-l",run:FK},{key:"Mod-i",run:$K,preventDefault:!0},{key:"Mod-[",run:HM},{key:"Mod-]",run:jM},{key:"Mod-Alt-\\",run:tX},{key:"Shift-Mod-k",run:JK},{key:"Shift-Mod-\\",run:TK},{key:"Mod-/",run:G7},{key:"Alt-A",mac:"Ctrl-A",run:Y7},{key:"Ctrl-m",mac:"Shift-Alt-m",run:nX}].concat(iX),oX={key:"Tab",run:jM,shift:HM};var aS={};class Hh{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 Hh(e,[],n,r,r,0,[],0,i?new uS(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 Hh(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 lX(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 uS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class lX{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 Wh{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 Wh(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 Wh(this.stack,this.pos,this.index)}}function yd(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 Fd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const cS=new Fd;class aX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=cS,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=cS,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 ka{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;uX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}ka.prototype.contextual=ka.prototype.fallback=ka.prototype.extend=!1;ka.prototype.fallback=ka.prototype.extend=!1;function uX(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||cX(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 fS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function cX(t,e,n,r){let i=fS(n,r,e);return i<0||fS(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 fX{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?dS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?dS(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 Sn){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 dX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Fd)}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 Fd,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 Fd,{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 fX(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&&gX(i);if(o)return Pr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Pr&&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 Pr&&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(Ct.contextHash)||0)==c))return e.useNode(f,d),Pr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Sn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Sn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Pr&&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 hS(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(),Pr&&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()&&(Pr&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)Pr&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))Pr&&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),Pr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),hS(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 xw(n.map((l,a)=>Tr.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=JA;let o=yd(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 ka(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 hX(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=ws(this.data,s+2);else break;i=n(ws(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=ws(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(Vh.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]=pS(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 mX=rM({String:Ge.string,Number:Ge.number,"True False":Ge.bool,PropertyName:Ge.propertyName,Null:Ge.null,", :":Ge.separator,"[ ]":Ge.squareBracket,"{ }":Ge.brace}),yX=Vh.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:[mX],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}),vX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=wX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function wX(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 xX=Fh.define({name:"json",parser:yX.configure({props:[aM.add({Object:qk({except:/^\s*\}/}),Array:qk({except:/^\s*\]/})}),_7.add({"Object Array":L7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function gS(){return new E7(xX)}class mS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Qo{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ts).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new Na,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=DX(l);if(g)o.add(m,m,Wt.widget({widget:new OX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Wt.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 mS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new mS(r.from,s,r.diagnostic)}}),r}function bX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ts).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Rw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function kX(t,e){return t.field(Mi,!1)?e:e.concat(Xt.appendConfig.of(XM))}function SX(t,e){return{effects:kX(t,[Rw.of(e)])}}const Rw=Xt.define(),WM=Xt.define(),VM=Xt.define(),Mi=us.define({create(){return new Qo(Wt.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=za(n,t.selected.diagnostic,s)||za(n,null,s)}!n.size&&i&&e.state.facet(ts).autoPanel&&(i=null),t=new Qo(n,i,r)}for(let n of e.effects)if(n.is(Rw)){let r=e.state.facet(ts).autoPanel?n.value.length?Uh.open:null:t.panel;t=Qo.init(n.value,r,e.state)}else n.is(WM)?t=new Qo(t.diagnostics,n.value?Uh.open:null,t.selected):n.is(VM)&&(t=new Qo(t.diagnostics,t.panel,n.value));return t},provide:t=>[yy.from(t,e=>e.panel),qe.decorations.from(t,e=>e.diagnostics)]}),CX=Wt.mark({class:"cm-lintRange cm-lintRange-active"});function TX(t,e,n){let{diagnostics:r}=t.state.field(Mi),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)&&(eKM(t,n,!1)))}const yS=t=>{let e=t.state.field(Mi,!1);return!e||!e.panel?!1:(t.dispatch({effects:WM.of(!1)}),!0)},AX=ai.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ts);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(SX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{ei(this.view.state,r)})}}update(t){let e=t.state.facet(ts);(t.docChanged||e!=t.startState.facet(ts)||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 MX(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 ts=He.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...JE(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:vS,tooltipFilter:vS,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 vS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function RX(t,e={}){return[ts.of({source:t,config:e}),AX,XM]}function UM(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 KM(t,e,n){var r;let i=n?UM(e.actions):[];return qi("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},qi("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=za(t.state.field(Mi).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),qi("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return qi("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&qi("div",{class:"cm-diagnosticSource"},e.source))}class OX extends Qa{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return qi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class wS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=KM(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Uh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)yS(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=UM(s.actions);for(let l=0;l{for(let s=0;syS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Mi).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(Mi),r=za(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:VM.of(r)})}static open(e){return new Uh(e)}}function PX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function vd(t){return PX(``,'width="6" height="3"')}const IX=qe.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:vd("#f11")},".cm-lintRange-warning":{backgroundImage:vd("orange")},".cm-lintRange-info":{backgroundImage:vd("#999")},".cm-lintRange-hint":{backgroundImage:vd("#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 NX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function DX(t){let e="hint",n=1;for(let r of t){let i=NX(r.severity);i>n&&(n=i,e=r.severity)}return e}const _X=i7(TX,{hideOn:bX}),XM=[Mi,qe.decorations.compute([Mi],t=>{let{selected:e,panel:n}=t.field(Mi);return!e||!n||e.from==e.to?Wt.none:Wt.set([CX.range(e.from,e.to)])}),_X,IX],LX=512*1024,xS=512*1024,GM=2e6;function FX(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 $X=t=>t.state.doc.length>LX?[]:vX()(t);function bS(t){return Ip.define([{tag:Ge.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ge.string,color:t?"#86efac":"#15803d"},{tag:Ge.number,color:t?"#fcd34d":"#b45309"},{tag:Ge.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ge.null,color:t?"#a1a1aa":"#71717a"}])}const BX=qe.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 qM({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>xS,k=v.useRef(w),b=!x&&t.length>GM,C=b?FX(t,xS):t,T=v.useRef(!1),A=v.useCallback((M,O,_)=>M?[qe.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[RX($X,{delay:300})]]:[Lt.readOnly.of(!0),qe.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new sl,_=new sl,P=new sl,I=Lt.create({doc:C,extensions:[P.of(w||!r?[]:gS()),qe.lineWrapping,rK(),GA.of([...sX,...dK,oX]),BX,O.of(Yk(bS(i))),_.of(A(x,w,r)),...s?[qU(s)]:[]]}),D=new qe({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?[]:gS())),_&&P.push(_.reconfigure(A(x,w,r))));const I=M.state.doc.toString();if(!(I===C&&P.length===0)){T.current=!0;try{M.dispatch({...I!==C?{changes:{from:0,to:M.state.doc.length,insert:C}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[C,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(Yk(bS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:xr("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 YM({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 nl="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 My={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(se){var x=d.lastIndexOf(` -`,se.offset),g=d.indexOf(` -`,se.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw se.message+" On line "+se.line+" and column "+se.column+`. -`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),C=0;Cy&&(y=g,w=[]),w.push(R))}function b(){var R,N,L,z;return L=g,z=g,R=function(j){return Y=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=z)):(R=null,g=z),R!==null&&(R=function(j,B){return B}(L,R[1])),R===null&&(g=L),R}function C(){var R,N,L,z;return L=g,z=g,R=function(j){return Y=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=z)):(R=null,g=z),R!==null&&(R=function(j,B){return B}(L,R[1])),R===null&&(g=L),R}function T(){var R,N,L,z;return L=g,z=g,R=function(j){return Y="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=z)):(R=null,g=z),R!==null&&(R=function(j,B){return B}(L,R[1])),R===null&&(g=L),R}function A(){var R,N,L,z;return L=g,z=g,R=function(j){return Y=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=z)):(R=null,g=z),R!==null&&(R=function(j,B){return B}(L,R[1])),R===null&&(g=L),R}function M(){var R,N,L,z,j,B,oe,fe,me;for(B=g,oe=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=[],fe=g,me=g,/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]")),j!==null)for(z=[];j!==null;)z.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));else z=null;for(z!==null?(j=O(),j!==null?z=[z,j]:(z=null,g=me)):(z=null,g=me),z!==null&&(z=function(ze,Fe){return Fe}(fe,z[1])),z===null&&(g=fe);z!==null;){if(L.push(z),fe=g,me=g,/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]")),j!==null)for(z=[];j!==null;)z.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));else z=null;z!==null?(j=O(),j!==null?z=[z,j]:(z=null,g=me)):(z=null,g=me),z!==null&&(z=function(ze,Fe){return Fe}(fe,z[1])),z===null&&(g=fe)}if(L!==null){for(z=[],/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));j!==null;)z.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));z!==null?R=[R,N,L,z]:(R=null,g=oe)}else R=null,g=oe}else R=null,g=oe;else R=null,g=oe;return R!==null&&(R=function(ze,Fe,nt){return nt.unshift(Fe),nt}(B,R[1],R[2])),R===null&&(g=B),R}function O(){var R,N,L,z,j,B,oe,fe,me;if(B=g,oe=g,R=_(),R!==null){for(N=[],fe=g,me=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(z=function(ze,Fe){return Fe==Y}(g,L)?"":null,z!==null?(j=_(),j!==null?L=[L,z,j]:(L=null,g=me)):(L=null,g=me)):(L=null,g=me),L!==null&&(L=function(ze,Fe,nt){return nt}(fe,L[0],L[2])),L===null&&(g=fe);L!==null;)N.push(L),fe=g,me=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(z=function(ze,Fe){return Fe==Y}(g,L)?"":null,z!==null?(j=_(),j!==null?L=[L,z,j]:(L=null,g=me)):(L=null,g=me)):(L=null,g=me),L!==null&&(L=function(ze,Fe,nt){return nt}(fe,L[0],L[2])),L===null&&(g=fe);N!==null?(L=function(ze,Fe,nt){return!!Fe||nt.length}(g,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,g=oe)):(R=null,g=oe)}else R=null,g=oe;return R!==null&&(R=function(ze,Fe,nt){return nt.unshift(Fe),nt}(B,R[0],R[1])),R===null&&(g=B),R}function _(){var R,N,L,z,j,B;if(z=g,j=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=j)):(R=null,g=j)}else R=null,g=j;if(R!==null&&(R=function(oe,fe){return fe.join("")}(z,R[1])),R===null&&(g=z),R===null){for(z=g,R=[],j=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(oe,fe){return fe!=Y}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(oe,fe){return fe}(j,N[0])),N===null&&(g=j);N!==null;)R.push(N),j=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(oe,fe){return fe!=Y}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(oe,fe){return fe}(j,N[0])),N===null&&(g=j);R!==null&&(R=function(oe,fe){return(o?fe.join("").trim():fe.join("")).replace(/(^")|("$)/g,"")}(z,R)),R===null&&(g=z)}return R}function P(){var R,N,L,z;return L=g,z=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=z)):(R=null,g=z),R!==null&&(R=function(j){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=[],z=0;z=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function uo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function YX(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function QX(t){const e=n=>{if(!uo(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(YX)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):uo(t)?e(t):t}function JX(t,e){if(e.parseJSON){const n=qX(t);if(n.ok&&typeof n.value!="number")return n.value}return e.parseNumbers?GX(t):t}function ZX(t,e){const n=i=>{const s={};for(const o of Object.keys(i)){const l=i[o];if(typeof l!="string"){s[o]=l;continue}const a=JX(l,e);if(!(e.emptyFields==="skip"&&a==="")){if(e.nullLiterals==="null"&&a==="NULL"){s[o]=null;continue}s[o]=a}}return s};if(Array.isArray(t))return t.map(i=>uo(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=uo(s)?n(s):s;return r}const eG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function JM(t){const e=eG.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 Oy(t){const e=new Set(t),n=new Map;for(const i of t){const s=JM(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 SS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function CS(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=>JM(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];SS(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];SS(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 tG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!uo(r))return e;const i=Object.keys(r),s=Oy(i);return s.length===0?e:e.map(o=>uo(o)?CS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!uo(r))return e;const i=Object.keys(r),s=Oy(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=uo(a)?CS(a,i,s,n):a;return o}return e}function TS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string"},r=t.startsWith(kS)?t.slice(kS.length):t;try{const i=jX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=ZX(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?tG(i,s,n.emptyFields):s}catch(i){throw new Error(QM(i))}}function nG(t,e={}){try{const n=e.flatten?QX(t):t;return WX(n,e)}catch(n){const r=QM(n);throw KX.some(i=>r.startsWith(i))?new VX(UX(r,e.flatten??!1)):new Error(r)}}function rG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const Ir={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},ES=["data","items","results","records","rows"];function AS(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function iG(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!AS(n))return[];const r=Object.keys(n),i=new Set(ES),s=[...ES.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=>AS(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function ZM(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 sG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=ZM(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 oG(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 MS=t=>t==="auto"?void 0:t;function lG(t){let e=!1,n=1;for(let r=0;rw[f+b]??""))}x.length!==0&&s.push(rm(m,x,t.delimiter))}if(s.length>0)return s.join(E9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return rm(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 rm(a,u,t.delimiter)}return null}const Wo=1e5,A9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function M9(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>=Wo)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=Wo);k++){const b=k*i;for(let C=x;C=Wo));C++);}}for(const m of n.rows){if(o.size>=Wo)break;if(m<0||m>=s)continue;const x=m*i;for(let g=0;g=Wo));g++);}for(const m of n.columns){if(o.size>=Wo)break;const x=m-r;if(!(x<0||x>=i))for(let g=0;g=Wo));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),A9.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,sm=26,Yb=110,om=40,R9=12,Ln=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';function Zb(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Eu="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 O9(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 P9(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 I9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function FE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l}){const a=v.useRef(null),u=v.useRef(null),c=v.useRef(null),[f,d]=v.useState(""),[h,p]=v.useState(""),[m,x]=v.useState(null),g=v.useRef(m);g.current=m;const y=v.useRef(null),[w,k]=v.useState(null),[b,C]=v.useState(""),T=v.useRef(null),[E,R]=v.useState(void 0),[O,_]=v.useState(()=>new Set),P=v.useRef(O),[I,D]=v.useState(0),Y=i!==void 0,oe=v.useMemo(()=>P9(r),[r]),le=I9(r),V=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",Z=v.useRef();Z.current===void 0&&(Z.current=new g9);const M=v.useMemo(()=>Jc(t,e),[t,e]),N=v.useMemo(()=>v9(M),[M]),L=M.headers.length,B=v.useRef({text:t,table:M});B.current={text:t,table:M};const j=v.useRef(E);j.current=E,v.useEffect(()=>{const G=window.setTimeout(()=>p(f),150);return()=>window.clearTimeout(G)},[f]);const $=v.useMemo(()=>{const G=C9(M.rows,h);return m?T9(G,M.rows,m.col,m.dir,N[m.col]??!1):G},[M,h,m,N]),ae=v.useRef($);ae.current=$,v.useEffect(()=>{const G=u.current;if(!G||typeof ResizeObserver>"u")return;const be=new ResizeObserver(()=>D(G.clientWidth));return be.observe(G),D(G.clientWidth),()=>be.disconnect()},[]);const he=Math.max(Yb,Math.floor((I-om)/Math.max(1,L)));v.useEffect(()=>{_(G=>{let be=!1;const J=new Set;for(const ie of G)ie{R(G=>{if(!G||G.rows.length===0)return G;const be=[];for(const ie of P.current){const ne=$.indexOf(ie);ne!==-1&&be.push(ne)}be.sort((ie,ne)=>ie-ne);const J=be.reduce((ie,ne)=>ie.add(ne),Pt.empty());return J.equals(G.rows)?G:{...G,rows:J}})},[$]),v.useEffect(()=>{x(G=>G!==null&&G.col>=L?null:G),k(G=>G!==null&&G.col>=L?null:G)},[L]);const ve=h!=="",Fe=M.rows.length,De=sm+Math.min($.length,R9)*qb,Ze=()=>{d(""),p("")},Tt=v.useCallback((G,be)=>{var ie;if(G0||Ge.height>0)?{x:Math.max(0,W.x-Ge.left),y:Math.max(0,W.y-Ge.top),width:W.width,height:W.height}:W??{x:om+J*he,y:0,width:he,height:sm};C(ne),k({col:J,bounds:me});return}y.current=g.current,k(null),x(ne=>!ne||ne.col!==J?{col:J,dir:"asc"}:ne.dir==="asc"?{col:J,dir:"desc"}:null)},[Y,he]),et=v.useCallback(()=>{if(!w)return;const{col:G}=w;if(k(null),!i)return;const{text:be,table:J}=B.current,ie=x9(be,J,G,b);ie!==be&&i(ie)},[w,b,i]),nt=v.useCallback(()=>{k(null)},[]);v.useEffect(()=>{if(!w)return;const G=T.current;G&&(G.focus(),G.select())},[w]);const st=v.useCallback((G,be)=>{const J=ae.current,ie=J[be];if(ie===void 0)return;const ne=P.current,Ge=c.current;let W;if(G.shiftKey&&Ge!==null&&Ge!==ie){const ge=J.indexOf(Ge),lt=J.indexOf(ie),Le=ge===-1?lt:ge,[Rt,Et]=Le<=lt?[Le,lt]:[lt,Le];W=G.metaKey||G.ctrlKey?new Set(ne):new Set;for(let ut=Rt;ut<=Et;ut++){const cn=J[ut];cn!==void 0&&W.add(cn)}}else G.metaKey||G.ctrlKey?(W=new Set(ne),W.has(ie)?W.delete(ie):W.add(ie)):W=new Set([ie]);c.current=ie,P.current=W,_(W);const me=[...W].map(ge=>J.indexOf(ge)).filter(ge=>ge!==-1).sort((ge,lt)=>ge-lt);R(ge=>({current:ge==null?void 0:ge.current,columns:(ge==null?void 0:ge.columns)??Pt.empty(),rows:me.reduce((lt,Le)=>lt.add(Le),Pt.empty())}))},[]),_t=v.useCallback(()=>{c.current=null,P.current=new Set,_(new Set),R(void 0)},[]),Ie=v.useCallback(G=>{const be=new Set;for(const J of G.rows){const ie=ae.current[J];ie!==void 0&&be.add(ie)}P.current=be,_(be),R(G)},[]),xe=v.useCallback(()=>{_t()},[_t]),Ne=v.useMemo(()=>$.filter(G=>O.has(G)),[$,O]),Ke=v.useMemo(()=>[...(E==null?void 0:E.columns)??[]].filter(G=>G>=Ln).map(G=>G-Ln),[E]),He=Ke.length,Be=v.useMemo(()=>({ranges:E!=null&&E.current?[E.current.range,...E.current.rangeStack]:[],columns:E?[...E.columns]:[],rows:O.size>0?$.reduce((G,be,J)=>(O.has(be)&&G.push(J),G),[]):E?[...E.rows]:[]}),[E,O,$]),Ct=Ln,ot=v.useMemo(()=>M9(M,$,Be,Ct),[M,$,Be,Ct]),mt=Ne.length>0||He>0||ot!==null,pe=v.useRef(l);pe.current=l;const _e=()=>{var J,ie;const G=j.current,be=Gb(B.current.table,ae.current,{ranges:G!=null&&G.current?[G.current.range,...G.current.rangeStack]:[],columns:G?[...G.columns]:[],rows:G?[...G.rows]:[]},Ln);be!==null&&((J=pe.current)==null||J.call(pe),(ie=navigator.clipboard)==null||ie.writeText(be).catch(()=>{}))};v.useEffect(()=>{const G=be=>{var W,me;const J=a.current;if(!J||!J.contains(document.activeElement))return;const ie=document.activeElement;if(ie&&(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.isContentEditable))return;const ne=j.current,Ge=Gb(B.current.table,ae.current,{ranges:ne!=null&&ne.current?[ne.current.range,...ne.current.rangeStack]:[],columns:ne?[...ne.columns]:[],rows:ne?[...ne.rows]:[]},Ln);Ge!==null&&(be.preventDefault(),be.stopImmediatePropagation(),(W=be.clipboardData)==null||W.setData("text/plain",Ge),(me=pe.current)==null||me.call(pe))};return window.addEventListener("copy",G,{capture:!0}),()=>window.removeEventListener("copy",G,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const G=be=>{const J=a.current;if(!J)return;const ie=be.target instanceof Node&&J.contains(be.target),ne=document.activeElement instanceof Node&&J.contains(document.activeElement);if(!ie&&!ne||Zb(be.target)||Zb(document.activeElement))return;const Ge=S9(be);Ge==="undo"&&s?(be.preventDefault(),s()):Ge==="redo"&&o&&(be.preventDefault(),o())};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[s,o]);const tt=v.useCallback(G=>{var J;const be=a.current!==null&&document.activeElement instanceof Node&&a.current.contains(document.activeElement);_t(),i==null||i(G),be&&((J=u.current)==null||J.focus({preventScroll:!0}))},[_t,i]),Xe=L>0&&Ke.length>=L,Ut=()=>{!Y||Ne.length===0||tt(im(B.current.text,B.current.table,Ne))},ft=()=>{!Y||Xe||Ke.length===0||tt(Ub(B.current.text,B.current.table,Ke))},ct=v.useCallback(G=>{if(!i)return!1;const{text:J,table:ie}=B.current,ne=ae.current;if(G.rows.length>0){const me=[...G.rows].map(ge=>ne[ge]).filter(ge=>ge!==void 0);if(me.length>0)return tt(im(J,ie,me)),!1}if(G.columns.length>0){const me=[...G.columns].filter(ge=>ge>=Ln&&gege-Ln);return me.length>0&&me.length0&&tt(im(J,ie,W)),!1},[tt,i]),yt=v.useCallback(G=>{const be=i;if(!be)return!1;const{text:J,table:ie}=B.current,ne=ae.current,Ge=[...G].sort((ge,lt)=>ge.location[1]-lt.location[1]);let W=J,me=0;for(const{location:ge,value:lt}of Ge){const Le=ge[0]-Ln,Rt=ge[1];if(Le<0||lt.kind!==Ce.Text)continue;const Et=ne[Rt],ut=Et===void 0?void 0:ie.rowSpans[Et];if(!ut)continue;const cn=W.slice(ut.start+me,ut.end+me),Lt=ow(cn,ie.delimiter);for(;Lt.length<=Le;)Lt.push("");const fn=lt.data??"";if(Lt[Le]===fn)continue;Lt[Le]=fn;const Kt=Ep(Lt,ie.delimiter);W=W.slice(0,ut.start+me)+Kt+W.slice(ut.end+me),me+=Kt.length-(ut.end-ut.start)}return W!==J&&be(W),!0},[i]),zt=v.useCallback(G=>{var Ge;const[be,J]=G,ie=ae.current[J];if(be{const be=[];for(let J=G.y;J{G[0]>=Ln||st(be,G[1])},[st]),zn=v.useMemo(()=>{const G={title:"#",id:"__gutter",width:om,themeOverride:{baseFontStyle:`11px ${Qb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},be=M.headers.map((J,ie)=>({title:J.toUpperCase(),id:`c${ie}`,width:he,themeOverride:N[ie]?{baseFontStyle:`12px ${Qb}`}:void 0}));return[G,...be]},[M.headers,N,he]),Wt=v.useCallback((G,be)=>{const{ctx:J,columnIndex:ie,rect:ne,theme:Ge,isSelected:W}=G;J.save();try{if(J.letterSpacing="0.5px",W&&(J.fillStyle=Ge.bgHeaderHovered,J.fillRect(ne.x,ne.y,ne.width,ne.height),J.fillStyle=Ge.accentColor,J.fillRect(ne.x,ne.y+ne.height-2,ne.width,2)),ie{const{ctx:J,cell:ie,rect:ne,col:Ge,theme:W}=G,me=Ge-Ln;if(me>=0&&ve&&ie.kind===Ce.Text){const ge=N9(ie.data,h);if(ge!==null){J.save();try{const lt=`${W.baseFontStyle} ${W.fontFamily}`;J.font=lt;let Le=ne.x+W.cellHorizontalPadding;const Rt=ne.y+ne.height/2+Ns(J,lt);for(const Et of ge){const ut=J.measureText(Et.text).width;Et.hit&&ut>0&&(J.fillStyle=le,J.fillRect(Le-1,Rt-7,ut+2,14)),Le+=ut}}finally{J.restore()}}}if(be(),me>=0&&ie.kind===Ce.Text&&ie.data===""){J.save();try{J.font=`${W.baseFontStyle} ${W.fontFamily}`,J.fillStyle=W.textLight,J.fillText("—",ne.x+W.cellHorizontalPadding,ne.y+ne.height/2+.5)}finally{J.restore()}}},[ve,h,le]),On=v.useCallback(G=>{const be=ae.current[G];return be!==void 0&&P.current.has(be)?{bgCell:V,bgCellMedium:V}:void 0},[V]);return L===0?A.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):A.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:a,children:[A.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:[A.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[A.jsx(sN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),A.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:f,onChange:G=>d(G.target.value),onKeyDown:G=>{G.key==="Escape"&&Ze()},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"}),f!==""&&A.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Ze,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:A.jsx(Nv,{"aria-hidden":"true",className:"size-3"})})]}),A.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:ve?`${$.length.toLocaleString()} of ${Fe.toLocaleString()}`:`${Fe.toLocaleString()} rows`}),mt&&A.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[A.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:Ne.length>0?`${Ne.length.toLocaleString()} selected`:He>0?`${He.toLocaleString()} ${He===1?"column":"columns"} selected`:`${((ot==null?void 0:ot.cellCount)??0).toLocaleString()} cells selected`}),ot!==null&&A.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:O9(ot)}),A.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:_e,className:Eu,children:[A.jsx(Iv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),Y&&Ne.length>0&&A.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:Ut,title:`Deletes the ${Ne.length} selected ${Ne.length===1?"row":"rows"} from the source CSV`,className:Eu,children:[A.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Ne.length.toLocaleString()," ",Ne.length===1?"row":"rows"]}),Y&&He>0&&A.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:ft,disabled:Xe,title:Xe?"At least one column must remain — the converter needs a column to detect":`Deletes the ${He} selected ${He===1?"column":"columns"} from the source CSV`,className:`${Eu} disabled:cursor-not-allowed disabled:opacity-50`,children:[A.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",He.toLocaleString()," ",He===1?"column":"columns"]}),A.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:_t,className:Eu,children:"Clear"})]})]}),A.jsxs("div",{ref:u,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":$.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:De},children:[A.jsx("div",{className:"absolute inset-0",children:A.jsx(E6,{imageWindowLoader:Z.current,renderers:a9,columns:zn,rows:$.length,getCellContent:zt,getCellsForSelection:Mt,onCellsEdited:Y?yt:void 0,onDelete:Y?ct:void 0,onCellClicked:Mn,onHeaderClicked:Tt,onGridSelectionChange:Ie,onSelectionCleared:xe,gridSelection:E,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:qb,headerHeight:sm,freezeColumns:Ln,fillHandle:Y,onPaste:Y?()=>!0:!1,keybindings:{search:!1},theme:oe,drawHeader:Wt,drawCell:Rn,getRowThemeOverride:On,minColumnWidth:Yb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),w!==null&&A.jsx("input",{ref:T,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${M.headers[w.col]??""}`,value:b,onChange:G=>C(G.target.value),onBlur:et,onKeyDown:G=>{G.key==="Enter"?(G.preventDefault(),G.stopPropagation(),et()):G.key==="Escape"&&(G.preventDefault(),G.stopPropagation(),nt())},style:{left:w.bounds.x,top:w.bounds.y,width:Math.max(60,w.bounds.width),height:w.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"}),ve&&$.length===0&&A.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:[A.jsxs("span",{children:["No rows matching “",h,"”."]}),A.jsx("button",{type:"button",onClick:Ze,className:Eu,children:"Show all rows"})]}),Y&&!ve&&$.length===0&&A.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:A.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function N9(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 A.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:A.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[A.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:A.jsx(UI,{className:"size-4 md:size-5"})}),A.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),A.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=F9(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"}),A.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 (",A.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}),")"]}),A.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[A.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:[A.jsx(fT,{"aria-hidden":"true"}),"Choose file"]}),A.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:[A.jsx(lN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let V0=[],$E=[];(()=>{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=$E[r])e=r+1;else return!0;if(e==n)return!1}}function ek(t){return t>=127462&&t<=127487}const tk=8205;function B9(t,e,n=!0,r=!0){return(n?zE:j9)(t,e,r)}function zE(t,e,n){if(e==t.length)return e;e&&BE(t.charCodeAt(e))&&jE(t.charCodeAt(e-1))&&e--;let r=lm(t,e);for(e+=nk(r);e=0&&ek(lm(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function j9(t,e,n){for(;e>1;){let r=zE(t,e-2,n);if(r=56320&&t<57344}function jE(t){return t>=55296&&t<56320}function nk(t){return t<65536?1:2}class It{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]=Na(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),Gi.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]=Na(this,e,n);let r=[];return this.decompose(e,n,r,0),Gi.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 nc(this),s=new nc(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 nc(this,e)}iterRange(e,n=this.length){return new HE(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 WE(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]?It.empty:e.length<=32?new bn(e):Gi.from(bn.split(e,[]))}}class bn extends It{constructor(e,n=H9(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 W9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new bn(rk(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 bn(l,o.length+s.length));else{let a=l.length>>1;r.push(new bn(l.slice(0,a)),new bn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof bn))return super.replace(e,n,r);[e,n]=Na(this,e,n);let i=Ld(this.text,Ld(r.text,rk(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new bn(i,s):Gi.from(bn.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=Na(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 bn(r,i)),r=[],i=-1);return i>-1&&n.push(new bn(r,i)),n}}class Gi extends It{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]=Na(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 Gi(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]=Na(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 Gi))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 bn(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 Gi)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof bn&&a&&(p=c[c.length-1])instanceof bn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new bn(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]:Gi.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new Gi(l,n)}}It.empty=new bn([""],0);function H9(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 bn?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 bn?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 bn){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 bn?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 HE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new nc(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 WE{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"&&(It.prototype[Symbol.iterator]=function(){return this.iter()},nc.prototype[Symbol.iterator]=HE.prototype[Symbol.iterator]=WE.prototype[Symbol.iterator]=function(){return this});class W9{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 Na(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function tr(t,e,n=!0,r=!0){return B9(t,e,n,r)}function V9(t){return t>=56320&&t<57344}function U9(t){return t>=55296&&t<56320}function K9(t,e){let n=t.charCodeAt(e);if(!U9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return V9(r)?(n-55296<<10)+(r-56320)+65536:n}function X9(t){return t<65536?1:2}const U0=/\r\n?|\n/;var yr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(yr||(yr={}));class ss{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=yr.Simple&&u>=e&&(r==yr.TrackDel&&ie||r==yr.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 ss(e)}static create(e){return new ss(e)}}class In extends ss{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 K0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return X0(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&&lo(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"?It.of(h.split(r||U0)):h:It.empty,m=p.length;if(f==d&&m==0)return;fo&&Zn(i,f-o,-1),Zn(i,d-f,m),lo(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new In(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 lo(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 X0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Mc(t),l=new Mc(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);Zn(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 Mc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?It.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?It.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 no{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 no(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return fe.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return fe.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 fe.range(e.anchor,e.head)}static create(e,n,r,i){return new no(e,n,r,i)}}class fe{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:fe.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 fe(e.ranges.map(n=>no.fromJSON(n)),e.main)}static single(e,n=e){return new fe([fe.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?fe.range(a,l):fe.range(l,a))}}return new fe(e,n)}}function UE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let lw=0;class ze{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 ze(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)||G0(f,c)){let h=r(f);if(l?!ik(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=Rh(d,p);if(this.dependencies.every(x=>x instanceof ze?d.facet(x)===f.facet(x):x instanceof us?d.field(x,!1)==f.field(x,!1):!0)||(l?ik(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 ik(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 Qo={lowest:4,low:3,default:2,high:1,highest:0};function Au(t){return e=>new KE(e,t)}const uw={highest:Au(Qo.highest),high:Au(Qo.high),default:Au(Qo.default),low:Au(Qo.low),lowest:Au(Qo.lowest)};class KE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class ol{of(e){return new q0(this,e)}reconfigure(e){return ol.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class q0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Mh{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 q9(e,n,o))d instanceof us?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=>G9(x,p,h))}}let f=u.map(d=>d(l));return new Mh(e,o,f,l,a,s)}}function q9(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 q0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof q0){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 KE)s(o.inner,o.prec);else if(o instanceof us)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,Qo.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,Qo.default),r.reduce((o,l)=>o.concat(l))}function rc(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 Rh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const XE=ze.define(),Y0=ze.define({combine:t=>t.some(e=>e),static:!0}),GE=ze.define({combine:t=>t.length?t[0]:void 0,static:!0}),qE=ze.define(),YE=ze.define(),QE=ze.define(),JE=ze.define({combine:t=>t.length?t[0]:!1});class Po{constructor(e,n){this.type=e,this.value=n}static define(){return new Y9}}class Y9{of(e){return new Po(this,e)}}class Q9{constructor(e){this.map=e}of(e){return new Gt(this,e)}}class Gt{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 Gt(this.type,n)}is(e){return this.type==e}static define(e={}){return new Q9(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}}Gt.reconfigure=Gt.define();Gt.appendConfig=Gt.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&&UE(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=Po.define();_n.userEvent=Po.define();_n.addToHistory=Po.define();_n.remote=Po.define();function J9(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=eA(e,wa(s),!1)}return t}function eV(t){let e=t.startState,n=e.facet(QE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=ZE(r,Q0(e,s,t.changes.newLength),!0))}return r==t?t:_n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const tV=[];function wa(t){return t==null?tV:Array.isArray(t)?t:[t]}var Cs=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Cs||(Cs={}));const nV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let J0;try{J0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function rV(t){if(J0)return J0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||nV.test(n)))return!0}return!1}function iV(t){return e=>{if(!/\S/.test(e))return Cs.Space;if(rV(e))return Cs.Word;for(let n=0;n-1)return Cs.Word;return Cs.Other}}class Ft{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(Gt.reconfigure)?(n=null,r=l.value):l.is(Gt.appendConfig)&&(n=null,r=wa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Mh.resolve(r,i,this),s=new Ft(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Y0)?e.newSelection:e.newSelection.asSingle();new Ft(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:fe.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=wa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return Ft.create({doc:e.doc,selection:fe.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Mh.resolve(e.extensions||[],new Map),r=e.doc instanceof It?e.doc:It.of((e.doc||"").split(n.staticFacet(Ft.lineSeparator)||U0)),i=e.selection?e.selection instanceof fe?e.selection:fe.single(e.selection.anchor,e.selection.head):fe.single(0);return UE(i,r.length),n.staticFacet(Y0)||(i=i.asSingle()),new Ft(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(Ft.tabSize)}get lineBreak(){return this.facet(Ft.lineSeparator)||` +`}get readOnly(){return this.facet(JE)}phrase(e,...n){for(let r of this.facet(Ft.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(XE))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 iV(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=tr(n,o,!1);if(s(n.slice(a,o))!=Cs.Word)break;o=a}for(;lt.length?t[0]:4});Ft.lineSeparator=GE;Ft.readOnly=JE;Ft.phrases=ze.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])}});Ft.languageData=XE;Ft.changeFilter=qE;Ft.transactionFilter=YE;Ft.transactionExtender=QE;ol.reconfigure=Gt.define();function tA(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 pl{eq(e){return this==e}range(e,n=e){return Z0.create(e,n,this)}}pl.prototype.startSide=pl.prototype.endSide=0;pl.prototype.point=!1;pl.prototype.mapMode=yr.TrackDel;function cw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Z0=class nA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new nA(e,n,r)}};function ey(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 jt{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 jt(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(ey)),this.isEmpty)return n.length?jt.of(n):this;let l=new rA(this,null,-1).goto(0),a=0,u=[],c=new Da;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 Rc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Rc.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=sk(o,l,r),u=new Mu(o,a,s),c=new Mu(l,a,s);r.iterGaps((f,d,h)=>ok(u,f,c,d,h,i)),r.empty&&r.length==0&&ok(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=sk(s,o),a=new Mu(s,l,0).goto(r),u=new Mu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ty(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 Mu(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 Da;for(let i of e instanceof Z0?[e]:n?sV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return jt.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=jt.empty;i=i.nextLayer)n=new jt(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}jt.empty=new jt([],[],null,-1);function sV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ey);e=r}return t}jt.empty.nextLayer=jt.empty;class Da{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 Da)).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(jt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=jt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function sk(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 rA(o,n,r,s));return i.length==1?i[0]:new Rc(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--)am(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--)am(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(),am(this.heap,0)}}}function am(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 Mu{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=Rc.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=lk(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=lk(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 ok(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)&&ty(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ty(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 ty(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 lk(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=tr(t,i)}return t.length}const ny="ͼ",ak=typeof Symbol>"u"?"__"+ny:Symbol.for(ny),ry=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),uk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class So{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=uk[ak]||1;return uk[ak]=e+1,ny+e.toString(36)}static mount(e,n,r){let i=e[ry],s=r&&r.nonce;i?s&&i.setNonce(s):i=new lV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let ck=new Map;class lV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=ck.get(r);if(s)return e[ry]=s;this.sheet=new i.CSSStyleSheet,ck.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[ry]=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:'"'},aV=typeof navigator<"u"&&/Mac/.test(navigator.platform),uV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Wn=0;Wn<10;Wn++)Co[48+Wn]=Co[96+Wn]=String(Wn);for(var Wn=1;Wn<=24;Wn++)Co[Wn+111]="F"+Wn;for(var Wn=65;Wn<=90;Wn++)Co[Wn]=String.fromCharCode(Wn+32),Oc[Wn]=String.fromCharCode(Wn);for(var um in Co)Oc.hasOwnProperty(um)||(Oc[um]=Co[um]);function cV(t){var e=aV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||uV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Oc:Co)[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 qi(){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 Ae={mac:hk||/Mac/.test(ar.platform),windows:/Win/.test(ar.platform),linux:/Linux|X11/.test(ar.platform),ie:Mp,ie_version:sA?iy.documentMode||6:oy?+oy[1]:sy?+sy[1]:0,gecko:fk,gecko_version:fk?+(/Firefox\/(\d+)/.exec(ar.userAgent)||[0,0])[1]:0,chrome:!!cm,chrome_version:cm?+cm[1]:0,ios:hk,android:/Android\b/.test(ar.userAgent),webkit:dk,webkit_version:dk?+(/\bAppleWebKit\/(\d+)/.exec(ar.userAgent)||[0,0])[1]:0,safari:ly,safari_version:ly?+(/\bVersion\/(\d+(\.\d+)?)/.exec(ar.userAgent)||[0,0])[1]:0,tabSize:iy.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 Oh=Object.create(null);function hw(t,e,n){if(t==e)return!0;t||(t=Oh),e||(e=Oh);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 fV(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 pk(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 dV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new gl(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}=oA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new gl(e,r,i,n,e.widget||null,!0)}static line(e){return new ef(e)}static set(e,n=!1){return jt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Vt.none=jt.empty;class Zc extends Vt{constructor(e){let{start:n,end:r}=oA(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||Oh}eq(e){return this==e||e instanceof Zc&&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)}}Zc.prototype.point=!1;class ef extends Vt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ef&&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)}}ef.prototype.mapMode=yr.TrackBefore;ef.prototype.point=!0;class gl 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?yr.TrackBefore:yr.TrackAfter:yr.TrackDel}get type(){return this.startSide!=this.endSide?ii.WidgetRange:this.startSide<=0?ii.WidgetBefore:ii.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof gl&&hV(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)}}gl.prototype.point=!0;function oA(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 hV(t,e){return t==e||!!(t&&e&&t.compare(e))}function xa(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 Pc extends pl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Pc&&this.tagName==e.tagName&&hw(this.attributes,e.attributes)}static create(e){return new Pc(e.tagName,e.attributes||Oh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return jt.of(e,n)}}Pc.prototype.startSide=Pc.prototype.endSide=-1;function Ic(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function ay(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function ic(t,e){if(!e.anchorNode)return!1;try{return ay(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Dc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function oc(t,e,n,r){return n?gk(t,e,n,r,-1)||gk(t,e,n,r,1):!1}function To(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Ph(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function gk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Ps(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=To(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?Ps(t):0}else return!1}}function Ps(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Nc(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 pV(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 lA(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 gV(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=pV(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}=lA(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 aA(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 mV{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?Ps(n):0),r,Math.min(e.focusOffset,r?Ps(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function uA(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 cA(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 Go=null;Ae.safari&&Ae.safari_version>=26&&(Go=!1);function fA(t){if(t.setActive)return t.setActive();if(Go)return t.focus(Go);let e=uA(t);t.focus(Go==null?{get preventScroll(){return Go={preventScroll:!0},!0}}:void 0),Go||(Go=!1,cA(e))}let mk;function Dc(t,e,n=e){let r=mk||(mk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function ba(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 yV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function vV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,Ps(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=Ps(n))}else{if(n==t)return!0;r=To(n),n=n.parentNode}}function dA(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 hA(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=Ps(n)}else if(n.parentNode&&!Ph(n))r=To(n),n=n.parentNode;else return null}}function pA(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 yA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(Hi[m+1]==-h){let x=Hi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Xt[f]=Xt[Hi[m]]=g),l=m;break}}else{if(Hi.length==189)break;Hi[l++]=f,Hi[l++]=d,Hi[l++]=a}else if((p=Xt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=Hi[x+2];if(g&2)break;if(m)Hi[x+2]|=2;else{if(g&4)break;Hi[x+2]|=4}}}}}function CV(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),Xt[--p]=h;a=c}else s=u,a++}}}function cy(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 Zi(a,m.from,h));let x=m.direction==ml!=!(h%2);fy(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Xt[p]!=l:Xt[p]==l))break;p++}d?cy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Xt[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(Xt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toXt.length;)Xt[Xt.length]=256;let r=[],i=e==ml?0:1;return fy(t,i,i,n,0,t.length,r),r}function vA(t){return[new Zi(0,t,0)]}let wA="";function EV(t,e,n,r,i){var s;let o=r.head-t.from,l=Zi.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=tr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),wA=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)}),MV=ze.define({combine:t=>t.some(e=>e)}),AA=ze.define();class ka{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 ka(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 ka(fe.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const rd=Gt.define({map:(t,e)=>t.map(e)}),MA=Gt.define();function ei(t,e,n){let r=t.facet(SA);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 bs=ze.define({combine:t=>t.length?t[0]:!0});let RV=0;const ua=ze.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Rp.of(u=>{let c=u.plugin(l);return c?o(c):Vt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return ai.define((r,i)=>new e(r,i),n)}}class fm{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(ei(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){ei(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){ei(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const RA=ze.define(),yw=ze.define(),Rp=ze.define(),OA=ze.define(),vw=ze.define(),tf=ze.define(),PA=ze.define();function yk(t,e){let n=t.state.facet(PA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return jt.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=AV(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 IA=ze.define();function ww(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(IA)){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 zu=ze.define();class ti{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ti(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 ti(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Ih(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 OV=[];class mn{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 OV}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&&fV(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=To(this.dom),i=this.length?e>0:n>0;return new Ei(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 Pp)return e;return null}static get(e){return e.cmTile}}class Op extends mn{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=vk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=vk(i);this.length=o}}function vk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Pp extends Op{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=mn.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 Es)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 Es extends Op{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 Es(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class _a extends Op{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new _a(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&&IV(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):PV(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 Ei(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 Ei(a.dom,0);a==r.tile&&(l=!0)}}return new Ei(this.dom,0)}}function PV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function IV(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?Ae.chrome||Ae.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Ae.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Nc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new nl(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class yl extends mn{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 Nc(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 NV{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 vr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(dm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=mn.get(a.dom);f&&f.setDOM(dm(a.dom))}let c=vr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=mn.get(e.text);s&&this.cache.reused.set(s,2);let o=new nl(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=NA);let i=_a.start(e,n||((r=this.cache.find(_a))===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 vr&&l.mark.eq(o))i=l,n--;else{let a=vr.of(o,(r=this.cache.find(vr,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||!wk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ae.ios&&wk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(hm,0,32)||new yl(hm.toDOM(),0,hm,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 DV(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(Nh,void 0,1);return r&&(r.flags=n),r||new Nh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class LV{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 Dh=[yl,_a,nl,vr,Nh,Es,Pp];for(let t=0;t[]),this.index=Dh.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 vr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof vr&&(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=jt.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof gl){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?La.block:La.inline),p=zV(u),m=this.cache.findWidget(h,a-l,p)||yl.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=BV(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=mn.get(i);if(i==this.view.contentDOM)break;s instanceof vr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Es||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new _a(i,NA):r||n.push(vr.of(new Zc({tagName:i.nodeName.toLowerCase(),attributes:dV(i)}),i)))}return{line:r,marks:n}}}function wk(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 zV(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 NA={class:"cm-line"};function BV(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 jV(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 vr&&e.push(r.mark)}return e}function dm(t){let e=mn.get(t);return e&&e.setDOM(t.cloneNode()),t}class La extends Ja{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}}La.inline=new La("span");La.block=new La("div");const hm=new class extends Ja{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class xk{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 Pp(e,e.contentDOM),this.updateInner([new ti(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:!YV(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?WV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ti(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,(Ae.ie||Ae.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=KV(o,this.decorations,e.changes);a.length&&(r=ti.extendWithRanges(r,a));let u=GV(l,this.blockWrappers,e.changes);return u.length&&(r=ti.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 $V(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&mn.get(n.text)&&l.cache.reused.set(mn.get(n.text),2),this.tile=l.run(e,n),hy(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=Ae.chrome||Ae.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)&&ic(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)),Ae.gecko&&a.empty&&!this.hasComposition&&HV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ei(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!oc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!oc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Ae.android&&Ae.chrome&&r.contains(f.focusNode)&&qV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Ic(this.view.root);if(d)if(a.empty){if(Ae.gecko){let h=VV(u.node,u.offset);if(h&&h!=3){let p=(h==1?hA:pA)(u.node,u.offset);p&&(u=new Ei(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 Ei(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ei(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&oc(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=Ic(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=Ps(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&&!mn.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 pm?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==gn.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 Es)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?sc(w):[];if(k.length){let b=k[k.length-1],C=a?b.right-g.left:g.right-b.left;C>l&&(l=C,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"?gn.RTL:gn.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=sc(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=sc(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 pm(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(Rp).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(jt.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(AA))try{if(u(this.view,e.range,e))return!0}catch(c){ei(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(gV(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(){hy(this.tile)}}function hy(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)hy(r,e)}}function HV(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 DA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=hA(n.focusNode,n.focusOffset),i=pA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=mn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=mn.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 WV(t,e,n){let r=DA(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 ti(a.mapPos(s),a.mapPos(o),s,o),text:i}}function VV(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class pm extends Ja{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 QV(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return fe.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=tr(i.text,s,!1):l=tr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=tr(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+oV(o,s,t.state.tabSize)}function ZV(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==ii.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function eU(t,e,n,r){let i=ZV(t,e.head,e.assoc||-1),s=!r||i.type!=ii.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==gn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return fe.cursor(a,n?-1:1)}return fe.cursor(n?i.to:i.from,n?-1:1)}function bk(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=EV(i,s,o,l,n),c=wA;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 tU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Cs.Space&&(i=o),i==o}}function nU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return fe.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=py(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:fe.cursor(r,rt.viewState.docHeight)return new Yi(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==ii.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==ii.Text){let f=JV(t,i,u,o,l);return new Yi(f,f==u.from?1:-1)}}if(u.type!=ii.Text)return a<(u.top+u.bottom)/2?new Yi(u.from,1):new Yi(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 rU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class rU{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)==gn.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 Dc(e.dom,o,l).getClientRects()});return i.after?new Yi(r[i.i+1],-1):new Yi(r[i.i],1)}scanTile(e,n){if(!e.length)return new Yi(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:Dc(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 Yi(r[i.i+1],-1):new Yi(o,1)}}const Xl="￿";class iU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(Ft.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Xl}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=mn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=mn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Ph(i))||Ph(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!oU(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=mn.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+(sU(e,r.node,r.offset)?n:0))}}function sU(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=LA(e.docView.tile,n,r,0))){let a=s||o?[]:uU(e),u=new iU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=cU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!ay(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!ay(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Ae.ios||Ae.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(fe.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=fe.create([fe.cursor(u,h)])}else this.newSel=fe.single(c,u)}}}function LA(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 LA(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 FA(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||Ae.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:It.of(e.text.slice(s.from-l,d).split(Xl))}:(h=$A(f,e.text,u-l,c))&&(Ae.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Xl+Xl&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:It.of(e.text.slice(h.from,h.toB).split(Xl))})}else r&&(!t.hasFocus&&i.facet(bs)||_h(r,s))&&(r=null);if(!n&&!r)return!1;if((Ae.mac||Ae.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=fe.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:It.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)}:Ae.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=fe.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:It.of([" "])}),n)return xw(t,n,r,o);if(r&&!_h(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(tf).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(Ae.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Ae.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&&ba(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&ba(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&ba(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=aU(t,e,n));return t.state.facet(CA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function aU(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:fe.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&&DA(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?fe.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 $A(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 uU(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 kk(n,r)),(i!=n||s!=r)&&e.push(new kk(i,s))),e}function cU(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?fe.single(n+e,r+e):null}function _h(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class fU{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,Ae.safari&&e.contentDOM.addEventListener("input",()=>null),Ae.gecko&&AU(e.contentDOM.ownerDocument)}handleEvent(e){!xU(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=hU(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&&BA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Ae.android&&Ae.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Ae.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(zA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||pU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Ae.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&dU(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:Ae.safari&&!Ae.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 dU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Sk(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){ei(n.state,i)}}}function hU(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(Sk(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(Sk(r.value,a))}}for(let r in Ii)n(r).handlers.push(Ii[r]);for(let r in fr)n(r).observers.push(fr[r]);return e}const zA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],pU="dthko",BA=[16,17,18,20,91,92,224,225],id=6;function sd(t){return Math.max(0,t)*.7+8}function gU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class mU{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=aA(e.contentDOM),this.atoms=e.state.facet(tf).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(Ft.allowMultipleSelections)&&yU(e,n),this.dragging=wU(e,n)&&WA(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&&gU(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=_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 yU(t,e){let n=t.state.facet(xA);return n.length?n[0](e):Ae.mac?e.metaKey:e.ctrlKey}function vU(t,e){let n=t.state.facet(bA);return n.length?n[0](e):Ae.mac?!e.altKey:!e.ctrlKey}function wU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Ic(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 xU(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=mn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Ii=Object.create(null),fr=Object.create(null),jA=Ae.ie&&Ae.ie_version<15||Ae.ios&&Ae.webkit_version<604;function bU(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(),HA(t,n.value)},50)}function Ip(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function HA(t,e){e=Ip(t.state,gw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(gy!=null&&n.selection.ranges.every(a=>a.empty)&&gy==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:fe.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:fe.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}fr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Ae.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};fr.wheel=fr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Ii.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);fr.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")};fr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};fr.touchend=(t,e)=>{t.inputState.touchActive=!1};Ii.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(kA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=SU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new mU(t,e,n,r)),r&&t.observer.ignore(()=>{fA(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 Ck(t,e,n,r){if(r==1)return fe.cursor(e,n);if(r==2)return QV(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?(Ek+1)%3:1}function SU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=WA(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=Ck(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Ck(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=CU(i,a.pos))?u:l?i.addRange(c):fe.create([c])}}}function CU(t,e){for(let n=0;n=e)return fe.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}Ii.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=fe.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Ip(t.state,mw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Ii.dragend=t=>(t.inputState.draggedContent=null,!1);function Mk(t,e,n,r){if(n=Ip(t.state,gw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&vU(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}Ii.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&&Mk(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 Mk(t,e,r,!0),!0}return!1};Ii.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=jA?null:e.clipboardData;return n?(HA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(bU(t),!1)};function TU(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 EU(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:Ip(t,mw,e.join(t.lineBreak)),ranges:n,linewise:r}}let gy=null;Ii.copy=Ii.cut=(t,e)=>{if(!ic(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=EU(t.state);if(!n&&!i)return!1;gy=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=jA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(TU(t,n),!1)};const VA=Po.define();function UA(t,e){let n=[];for(let r of t.facet(TA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:VA.of(!0)}):null}function KA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=UA(t.state,e);n?t.dispatch(n):t.update([])}},10)}fr.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),KA(t)};fr.blur=t=>{t.observer.clearSelectionRange(),KA(t)};fr.compositionstart=fr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};fr.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,Ae.chrome&&Ae.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};fr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Ii.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(Ae.chrome&&Ae.android&&(i=zA.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 Ae.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ae.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>fr.compositionend(t,e),20),!1};const Rk=new Set;function AU(t){Rk.has(t)||(Rk.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Ok=["pre-wrap","normal","pre-line","break-spaces"];let Fa=!1;function Pk(){Fa=!1}class MU{constructor(e){this.lineWrapping=e,this.doc=It.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 Ok.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&&(Fa=!0),this.height=e)}replace(e,n,r){return cr.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 Dr extends XA{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 Ti(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 Dr||i instanceof Hn&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Hn?i=new Dr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):cr.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 Hn extends cr{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 Hn?r[r.length-1]=new Hn(s.length+i):r.push(null,new Hn(i-1))}if(e>0){let s=r[0];s instanceof Hn?r[0]=new Hn(e+s.length):r.unshift(new Hn(e-1),null)}return cr.of(r)}decomposeLeft(e,n){n.push(new Hn(e-1),null)}decomposeRight(e,n){n.push(null,new Hn(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 Hn(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 Dr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Hn(s-l).updateHeight(e,l));let u=cr.of(o);return(a<0||Math.abs(u.height-this.height)>=$d||Math.abs(a-this.heightMetrics(e,n).perLine)>=$d)&&(Fa=!0),Lh(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 PU extends cr{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&&Ik(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?cr.of(this.break?[e,null,n]:[e,n]):(this.left=Lh(this.left,e),this.right=Lh(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 Ik(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Hn&&(r=t[e+1])instanceof Hn&&t.splice(e-1,3,new Hn(n.length+1+r.length))}const IU=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 Dr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Dr(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=IU)&&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 Dr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Hn(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 Dr)return e;let n=new Dr(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 Dr)&&!this.isCovered?this.nodes.push(new Dr(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 LU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function FU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mm{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 MU(r),this.stateDeco=_k(n),this.heightMap=cr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle.setDoc(n.doc),[new ti(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?Dk: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(Bu(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=ti.extendWithRanges(i,NU(r,this.stateDeco,e?e.changes:In.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Pk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||Fa)&&(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(MV)&&(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"?gn.RTL:gn.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:C}=lA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||C>.005&&Math.abs(this.scaleY-C)>.005)&&(this.scaleX=b,this.scaleY=C,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=aA(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=dA(this.scrollParent||e.win);let m=(this.printing?FU:_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&&!LU(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:C,charWidth:T,textHeight:E}=e.docView.measureTextSize();o=C>0&&i.refresh(s,C,T,E,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)),Pk();for(let C of this.viewports){let T=C.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(C);this.heightMap=(o?cr.empty().applyChanges(this.stateDeco,It.empty,this.heightOracle,[new ti(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new RU(C.from,T))}Fa&&(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,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!=gn.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(fe.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 mm(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let C of e)C.from>=c.from&&C.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=[];jt.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)||Bu(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)||Bu(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 Bu(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 zU(t,e,n){let r=[],i=t,s=0;return jt.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 BU(t,e){for(let n of t)if(e(n))return n}const Dk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function _k(t){let e=t.facet(Rp).filter(r=>typeof r!="function"),n=t.facet(vw).filter(r=>typeof r!="function");return n.length&&e.push(jt.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,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 Bu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ti(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Bu(i,e)):t._content)}const ud=ze.define({combine:t=>t.join(" ")}),my=ze.define({combine:t=>t.indexOf(!0)>-1}),yy=So.newName(),GA=So.newName(),qA=So.newName(),YA={"&light":"."+GA,"&dark":"."+qA};function vy(t,e,n){return new So(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 jU=vy("."+yy,{"&":{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"}},YA),HU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},ym=Ae.ie&&Ae.ie_version<=11;class WU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new mV,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);(Ae.ie&&Ae.ie_version<=11||Ae.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&&Ae.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Ae.chrome&&Ae.chrome_version<126)&&(this.editContext=new UU(e),e.state.facet(bs)&&(e.contentDOM.editContext=this.editContext.editContext)),ym&&(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(bs)?r.root.activeElement!=this.dom:!ic(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}(Ae.ie&&Ae.ie_version<=11||Ae.android&&Ae.chrome)&&!r.state.selection.main.empty&&i.focusNode&&oc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Ic(e.root);if(!n)return!1;let r=Ae.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&VU(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=ic(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&&ba(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&&ic(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 lU(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=FA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!_h(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=Lk(n,e.previousSibling||e.target.previousSibling,-1),i=Lk(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(bs)!=e.state.facet(bs)&&(e.view.contentDOM.editContext=e.state.facet(bs)?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 Lk(t,e,n){for(;e;){let r=mn.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 Fk(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 oc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function VU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Fk(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?Fk(t,n):null}class UU{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=$A(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=fe.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));_h(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:It.of(r.text.slice(c.from,c.toB).split(` +`))};if((Ae.mac||Ae.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:It.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,fe.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=Ic(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 Ue{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||yV(e.parent)||document,this.viewState=new Nk(this,e.state||Ft.create(e)),e.scrollTo&&e.scrollTo.is(rd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ua).map(i=>new fm(i));for(let i of this.plugins)i.update(this);this.observer=new WU(this),this.inputState=new fU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new xk(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(VA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=UA(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(Ft.phrases)!=this.state.facet(Ft.phrases))return this.setState(s);i=Ih.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(Ue.cursorScrollMargin);f=new ka(h.empty?h:fe.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=Fh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(zu)!=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(dy))try{d(i)}catch(h){ei(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!FA(this,c)&&u.force&&ba(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 Nk(this,e),this.plugins=e.facet(ua).map(r=>new fm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new xk(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(ua),r=e.state.facet(ua);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new fm(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(dA(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 ei(this.state,p),$k}}),f=Ih.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)&&!(Ae.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(dy))l(n)}get themeClasses(){return yy+" "+(this.state.facet(my)?qA:GA)+" "+this.state.facet(ud)}updateAttrs(){let e=zk(this,RA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(bs)?"true":"false",class:"cm-content",style:`${Ae.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),zk(this,yw,n);let r=this.observer.ignore(()=>{let i=pk(this.contentDOM,this.contentAttrs,n),s=pk(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(Ue.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(zu);let e=this.state.facet(Ue.cspNonce);So.mount(this.root,this.styleModules.concat(jU).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 gm(this,e,bk(this,e,n,r))}moveByGroup(e,n){return gm(this,e,bk(this,e,n,r=>tU(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 fe.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return eU(this,e,n,r)}moveVertically(e,n,r){return gm(this,e,nU(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=py(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),py(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[Zi.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==gn.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(EA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>KU)return vA(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||yA(s.isolates,r=yk(this,e))))return s.order;r||(r=yk(this,e));let i=TV(e.text,n,r);return this.bidiCache.push(new Fh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Ae.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{fA(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 ka(typeof e=="number"?fe.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 ka(fe.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 ai.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return ai.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=So.newName(),i=[ud.of(r),zu.of(vy(`.${r}`,e))];return n&&n.dark&&i.push(my.of(!0)),i}static baseTheme(e){return uw.lowest(zu.of(vy("."+yy,e,YA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&mn.get(r)||mn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ue.styleModule=zu;Ue.inputHandler=CA;Ue.clipboardInputFilter=gw;Ue.clipboardOutputFilter=mw;Ue.scrollHandler=AA;Ue.focusChangeEffect=TA;Ue.perLineTextDirection=EA;Ue.exceptionSink=SA;Ue.updateListener=dy;Ue.editable=bs;Ue.mouseSelectionStyle=kA;Ue.dragMovesSelection=bA;Ue.clickAddsSelectionRange=xA;Ue.decorations=Rp;Ue.blockWrappers=OA;Ue.outerDecorations=vw;Ue.atomicRanges=tf;Ue.bidiIsolatedRanges=PA;Ue.cursorScrollMargin=ze.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}}});Ue.scrollMargins=IA;Ue.darkTheme=my;Ue.cspNonce=ze.define({combine:t=>t.length?t[0]:""});Ue.contentAttributes=yw;Ue.editorAttributes=RA;Ue.lineWrapping=Ue.contentAttributes.of({class:"cm-lineWrapping"});Ue.announce=Gt.define();const KU=4096,$k={};class Fh{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:gn.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 XU=Ae.mac?"mac":Ae.windows?"win":Ae.linux?"linux":"key";function GU(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 ro=null;const QU=4e3;function JU(t,e=XU){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=>GU(g,e));for(let g=1;g{let k=ro={view:w,prefix:y,scope:o};return setTimeout(()=>{ro==k&&(ro=null)},QU),!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,wy))}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 wy=null;function ZU(t,e,n,r){wy=e;let i=cV(e),s=K9(i,0),o=X9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;ro&&ro.view==n&&ro.scope==r&&(l=ro.prefix+" ",BA.indexOf(e.keyCode)<0&&(u=!0,ro=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)&&!(Ae.windows&&e.ctrlKey&&e.altKey)&&!(Ae.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Co[e.keyCode])&&p!=i?(d(h[l+cd(p,e,!0)])||e.shiftKey&&(m=Oc[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(),wy=null,a}class e7 extends Ja{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?sc(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Nc(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 t7(t){let e=ai.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Vt.set([Vt.widget({widget:new e7(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,Ue.contentAttributes.of({"aria-placeholder":t})]:e}const fd="-10000px";class JA{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 n7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const vm=ze.define({combine:t=>{var e,n,r;return{position:Ae.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)||n7}}}),jk=new WeakMap,ZA=ai.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(vm);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 JA(t,eM,(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(vm);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(Ae.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(vm).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=jk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||i7,y=this.view.textDirection==gn.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&&E.topC&&(C=k?E.top-x-2-p:E.bottom+p+2);if(this.position=="absolute"?(c.style.top=(C-t.parent.top)/s+"px",Hk(c,(w-t.parent.left)/i)):(c.style.top=C/s+"px",Hk(c,w/i)),h){let E=f.left+(y?g.x:-g.x)-(w+14-7);h.style.left=E/i+"px"}u.overlap!==!0&&o.push({left:w,top:C,right:T,bottom:C+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 Hk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const r7=Ue.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"}}}),i7={x:0,y:0},eM=ze.define({enables:[ZA,r7]}),$h=ze.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Np{static create(e){return new Np(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new JA(e,$h,(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 s7=eM.compute([$h],t=>{let e=t.facet($h);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:Np.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),o7=ze.define();class l7{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==gn.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=>ei(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(ZA),n=e?e.manager.tooltips.findIndex(r=>r.create==Np.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&&!a7(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:!u7(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 a7(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 u7(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 c7(t,e={}){let n=Gt.define(),r=new WeakMap,i=us.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,yr.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(f7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>$h.from(o)});const s=ai.define(o=>new l7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,o7.of(s),s7]}}const f7=Gt.define(),Wk=ze.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),d7=ai.fromClass(class{constructor(t){this.input=t.state.facet(xy),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Wk);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(Wk);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(xy);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=>Ue.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=Vk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Vk(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 Vk(t){let e=t.nextSibling;return t.remove(),e}const xy=ze.define({enables:d7});class $a extends pl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}$a.prototype.elementClass="";$a.prototype.toDOM=void 0;$a.prototype.mapMode=yr.TrackBefore;$a.prototype.startSide=$a.prototype.endSide=-1;$a.prototype.point=!0;const tM=1024;let h7=0;class wm{constructor(e,n){this.from=e,this.to=n}}class kt{constructor(e={}){this.id=h7++,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=Tr.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}kt.closedBy=new kt({deserialize:t=>t.split(" ")});kt.openedBy=new kt({deserialize:t=>t.split(" ")});kt.group=new kt({deserialize:t=>t.split(" ")});kt.isolate=new kt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});kt.contextHash=new kt({perNode:!0});kt.lookAhead=new kt({perNode:!0});kt.mounted=new kt({perNode:!0});class ac{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[kt.mounted.id]}}const p7=Object.create(null);class Tr{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):p7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Tr(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(kt.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(kt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Tr.none=new Tr("",Object.create(null),0,8);class Sw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|pn.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(Tr.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Sn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Sn(Tr.none,n,r,i)))}static build(e){return v7(e)}}Sn.empty=new Sn(Tr.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 Eo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Tr.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&pn.EnterBracketed&&c instanceof Sn&&(d=ac.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!nM(i,r,f,f+c.length))){if(c instanceof Eo){if(s&pn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new ao(new g7(o,c,e,f),null,h)}else if(s&pn.IncludeAnonymous||!c.type.isAnonymous||Tw(c)){let h;if(!(s&pn.IgnoreMounts)&&(h=ac.get(c))&&!h.overlay)return new si(h.tree,f,e,o);let p=new si(c,f,e,o);return s&pn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&pn.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&pn.IgnoreOverlays)&&(i=ac.get(this._tree))&&i.overlay){let s=e-this.from,o=r&pn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new si(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 Kk(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 by(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 g7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class ao extends rM{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 ao(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&pn.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 ao(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 ao(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 ao(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 Sn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function iM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new si(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(_c(l,e,n,!1))}}return i?iM(i):r}class ky{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&~pn.EnterBracketed,e instanceof si)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 si?(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&pn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&pn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&pn.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&pn.IncludeAnonymous||l instanceof Eo||!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 by(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 Eo||!e.type.isAnonymous||Tw(e))}function v7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=tM,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,C,T,E,R,O){let{id:_,start:P,end:I,size:D}=l,Y=c,oe=u;if(D<0)if(l.next(),D==-1){let N=s[_];T.push(N),E.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 le=a[_],V,Z,M=P-b;if(I-P<=i&&(Z=x(l.pos-C,R))){let N=new Uint16Array(Z.size-Z.skip),L=l.pos-Z.size,B=N.length;for(;l.pos>L;)B=g(Z.start,N,B);V=new Eo(N,I-Z.start,r),M=Z.start-b}else{let N=l.pos-D;l.next();let L=[],B=[],j=_>=o?_:-1,$=0,ae=I;for(;l.pos>N;)j>=0&&l.id==j&&l.size>=0?(l.end<=ae-i&&(p(L,B,P,$,l.end,ae,j,Y,oe),$=L.length,ae=l.end),l.next()):O>2500?d(P,N,L,B):f(P,N,L,B,j,O+1);if(j>=0&&$>0&&$-1&&$>0){let he=h(le,oe);V=Ew(le,L,B,0,L.length,0,I-P,he,he)}else V=m(le,L,B,I-P,Y-I,oe)}T.push(V),E.push(M)}function d(b,C,T,E){let R=[],O=0,_=-1;for(;l.pos>C;){let{id:P,start:I,end:D,size:Y}=l;if(Y>4)l.next();else{if(_>-1&&I<_)break;_<0&&(_=D-i),R.push(P,I,D),O++,l.next()}}if(O){let P=new Uint16Array(O*4),I=R[R.length-2];for(let D=R.length-3,Y=0;D>=0;D-=3)P[Y++]=R[D],P[Y++]=R[D+1]-I,P[Y++]=R[D+2]-I,P[Y++]=Y;T.push(new Eo(P,R[2]-I,r)),E.push(I-b)}}function h(b,C){return(T,E,R)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Sn){if(!_&&P.type==b&&P.length==R)return P;(I=P.prop(kt.lookAhead))&&(O=E[_]+P.length+I)}return m(b,T,E,R,O,C)}}function p(b,C,T,E,R,O,_,P,I){let D=[],Y=[];for(;b.length>E;)D.push(b.pop()),Y.push(C.pop()+T-R);b.push(m(r.types[_],D,Y,O-R,P-O,I)),C.push(R-T)}function m(b,C,T,E,R,O,_){if(O){let P=[kt.contextHash,O];_=_?[P].concat(_):[P]}if(R>25){let P=[kt.lookAhead,R];_=_?[P].concat(_):[P]}return new Sn(b,C,T,E,_)}function x(b,C){let T=l.fork(),E=0,R=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==C&&D>=0){P.size=E,P.start=R,P.skip=O,O+=4,E+=4,T.next();continue}let Y=T.pos-D;if(D<0||Y=o?4:0,le=T.start;for(T.next();T.pos>Y;){if(T.size<0)if(T.size==-3||T.size==-4)oe+=4;else break e;else T.id>=o&&(oe+=4);T.next()}R=le,E+=D,O+=oe}return(C<0||E==b)&&(P.size=E,P.start=R,P.skip=O),P.size>4?P:void 0}function g(b,C,T){let{id:E,start:R,end:O,size:_}=l;if(l.next(),_>=0&&E4){let I=l.pos-(_-4);for(;l.pos>I;)T=g(b,C,T)}C[--T]=P,C[--T]=O-b,C[--T]=R-b,C[--T]=E}else _==-3?u=E:_==-4&&(c=E);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 Sn(a[t.topID],y.reverse(),w.reverse(),k)}const Xk=new WeakMap;function zd(t,e){if(!t.isAnonymous||e instanceof Eo||e.type!=t)return 1;let n=Xk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Sn)){n=1;break}n+=zd(t,r)}Xk.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;C+=T}if(w==k+1){if(C>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 ll{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 ll(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 ll(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew wm(i.from,i.to)):[new wm(0,0)]:[new wm(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 w7{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 kt({perNode:!0});let x7=0;class Qr{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=x7++}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 Qr&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Qr(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 zh(e);return r=>r.modified.indexOf(n)>-1?r:zh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let b7=0;class zh{constructor(e){this.name=e,this.instances=[],this.id=b7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&k7(n,l.modified));if(r)return r;let i=[],s=new Qr(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=S7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(zh.get(l,a));return s}}function k7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function S7(t){let e=[[]];for(let n=0;nr.length-n.length)}function oM(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 Lc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return lM.add(e)}const lM=new kt({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 Lc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Lc{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 C7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function T7(t,e,n,r=0,i=t.length){let s=new E7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class E7{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=A7(e)||Lc.empty,f=C7(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(kt.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 A7(t){let e=t.type.prop(lM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=Qr.define,gd=we(),Js=we(),Gk=we(Js),qk=we(Js),Zs=we(),md=we(Zs),xm=we(Zs),Ui=we(),Vo=we(Ui),Wi=we(),Vi=we(),Sy=we(),Ru=we(Sy),yd=we(),Ve={comment:gd,lineComment:we(gd),blockComment:we(gd),docComment:we(gd),name:Js,variableName:we(Js),typeName:Gk,tagName:we(Gk),propertyName:qk,attributeName:we(qk),className:we(Js),labelName:we(Js),namespace:we(Js),macroName:we(Js),literal:Zs,string:md,docString:we(md),character:we(md),attributeValue:we(md),number:xm,integer:we(xm),float:we(xm),bool:we(Zs),regexp:we(Zs),escape:we(Zs),color:we(Zs),url:we(Zs),keyword:Wi,self:we(Wi),null:we(Wi),atom:we(Wi),unit:we(Wi),modifier:we(Wi),operatorKeyword:we(Wi),controlKeyword:we(Wi),definitionKeyword:we(Wi),moduleKeyword:we(Wi),operator:Vi,derefOperator:we(Vi),arithmeticOperator:we(Vi),logicOperator:we(Vi),bitwiseOperator:we(Vi),compareOperator:we(Vi),updateOperator:we(Vi),definitionOperator:we(Vi),typeOperator:we(Vi),controlOperator:we(Vi),punctuation:Sy,separator:we(Sy),bracket:Ru,angleBracket:we(Ru),squareBracket:we(Ru),paren:we(Ru),brace:we(Ru),content:Ui,heading:Vo,heading1:we(Vo),heading2:we(Vo),heading3:we(Vo),heading4:we(Vo),heading5:we(Vo),heading6:we(Vo),contentSeparator:we(Ui),list:we(Ui),quote:we(Ui),emphasis:we(Ui),strong:we(Ui),link:we(Ui),monospace:we(Ui),strikethrough:we(Ui),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:yd,documentMeta:we(yd),annotation:we(yd),processingInstruction:we(yd),definition:Qr.defineModifier("definition"),constant:Qr.defineModifier("constant"),function:Qr.defineModifier("function"),standard:Qr.defineModifier("standard"),local:Qr.defineModifier("local"),special:Qr.defineModifier("special")};for(let t in Ve){let e=Ve[t];e instanceof Qr&&(e.name=t)}aM([{tag:Ve.link,class:"tok-link"},{tag:Ve.heading,class:"tok-heading"},{tag:Ve.emphasis,class:"tok-emphasis"},{tag:Ve.strong,class:"tok-strong"},{tag:Ve.keyword,class:"tok-keyword"},{tag:Ve.atom,class:"tok-atom"},{tag:Ve.bool,class:"tok-bool"},{tag:Ve.url,class:"tok-url"},{tag:Ve.labelName,class:"tok-labelName"},{tag:Ve.inserted,class:"tok-inserted"},{tag:Ve.deleted,class:"tok-deleted"},{tag:Ve.literal,class:"tok-literal"},{tag:Ve.string,class:"tok-string"},{tag:Ve.number,class:"tok-number"},{tag:[Ve.regexp,Ve.escape,Ve.special(Ve.string)],class:"tok-string2"},{tag:Ve.variableName,class:"tok-variableName"},{tag:Ve.local(Ve.variableName),class:"tok-variableName tok-local"},{tag:Ve.definition(Ve.variableName),class:"tok-variableName tok-definition"},{tag:Ve.special(Ve.variableName),class:"tok-variableName2"},{tag:Ve.definition(Ve.propertyName),class:"tok-propertyName tok-definition"},{tag:Ve.typeName,class:"tok-typeName"},{tag:Ve.namespace,class:"tok-namespace"},{tag:Ve.className,class:"tok-className"},{tag:Ve.macroName,class:"tok-macroName"},{tag:Ve.propertyName,class:"tok-propertyName"},{tag:Ve.operator,class:"tok-operator"},{tag:Ve.comment,class:"tok-comment"},{tag:Ve.meta,class:"tok-meta"},{tag:Ve.invalid,class:"tok-invalid"},{tag:Ve.punctuation,class:"tok-punctuation"}]);var bm;const ca=new kt;function M7(t){return ze.define({combine:t?e=>e.concat(t):void 0})}const R7=new kt;class Ai{constructor(e,n,r=[],i=""){this.data=e,this.name=i,Ft.prototype.hasOwnProperty("tree")||Object.defineProperty(Ft.prototype,"tree",{get(){return os(this)}}),this.parser=n,this.extension=[Ba.of(this),Ft.languageData.of((s,o,l)=>{let a=Yk(s,o,l),u=a.type.prop(ca);if(!u)return[];let c=s.facet(u),f=a.type.prop(R7);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 Yk(e,n,r).type.prop(ca)==this.data}findRegions(e){let n=e.facet(Ba);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(ca)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(kt.mounted);if(l){if(l.tree.prop(ca)==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 Bh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function os(t){let e=t.field(Ai.state,!1);return e?e.tree:Sn.empty}class O7{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 Ou=null;class jh{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 jh(e,n,[],Sn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new O7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Sn.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(ll.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ou;Ou=this;try{return e()}finally{Ou=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Qk(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=ll.applyChanges(r,a),i=Sn.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=Qk(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 sM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Ou;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 Sn(Tr.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 Ou}}function Qk(t,e,n){return ll.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class za{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 za(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=jh.create(e.facet(Ba).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new za(r)}}Ai.state=us.define({create:za.init,update(t,e){for(let n of e.effects)if(n.is(Ai.setState))return n.value;return e.startState.facet(Ba)!=e.state.facet(Ba)?za.init(e.state):t.apply(e)}});let uM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(uM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const km=typeof navigator<"u"&&(!((bm=navigator.scheduling)===null||bm===void 0)&&bm.isInputPending)?()=>navigator.scheduling.isInputPending():null,P7=ai.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(Ai.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(Ai.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=uM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>km&&km()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Ai.setState.of(new za(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=>ei(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()}}}),Ba=ze.define({combine(t){return t.length?t[0]:null},enables:t=>[Ai.state,P7,Ue.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class I7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const N7=ze.define(),Aw=ze.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 Hh(t){let e=t.facet(Aw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Wh(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?D7(t,n,e):null}class Dp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Hh(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 Ap(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 fM=new kt;function D7(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 dM(r,t,n)}function dM(t,e,n){for(let r=t;r;r=r.next){let i=L7(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 L7(t){let e=t.type.prop(fM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(kt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>B7(o,!0,1,void 0,s&&!_7(o)?i.from:void 0)}return t.parent==null?F7:null}function F7(){return 0}class Mw extends Dp{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($7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return dM(this.context.next,this.base,this.pos)}}function $7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function z7(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 B7(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=z7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Jk({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const j7=new kt;function H7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(ca)==o.data:o?l=>l==o:void 0,this.style=aM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new So(r):null,this.themeType=n.themeType}static define(e,n){return new _p(e,n||{})}}const Cy=ze.define(),W7=ze.define({combine(t){return t.length?[t[0]]:null}});function Sm(t){let e=t.facet(Cy);return e.length?e:t.facet(W7)}function Zk(t,e){let n=[U7],r;return t instanceof _p&&(t.module&&n.push(Ue.styleModule.of(t.module)),r=t.themeType),r?n.push(Cy.computeN([Ue.darkTheme],i=>i.facet(Ue.darkTheme)==(r=="dark")?[t]:[])):n.push(Cy.of(t)),n}class V7{constructor(e){this.markCache=Object.create(null),this.tree=os(e.state),this.decorations=this.buildDeco(e,Sm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=os(e.state),r=Sm(e.state),i=r!=Sm(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 Da;for(let{from:i,to:s}of e.visibleRanges)T7(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 U7=uw.high(ai.fromClass(V7,{decorations:t=>t.decorations})),K7=1e4,X7="()[]{}",G7=new kt;function Ty(t,e,n){let r=t.prop(e<0?kt.openedBy:kt.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 Ey(t){let e=t.type.prop(G7);return e?e(t.node):t}function fa(t,e,n,r={}){let i=r.maxScanDistance||K7,s=r.brackets||X7,o=os(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ty(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return q7(t,e,n,a,c,u,s)}}return Y7(t,e,n,o,l.type,i,s)}function q7(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 Q7=Object.create(null),eS=[Tr.none],tS=[],nS=Object.create(null),J7=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"]])J7[t]=Z7(Q7,e);function Cm(t,e){tS.indexOf(t)>-1||(tS.push(t),console.warn(e))}function Z7(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ve[u];c?typeof c=="function"?a.length?a=a.map(c):Cm(u,`Modifier ${u} used at start of tag`):a.length?Cm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Cm(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=nS[i];if(s)return s.id;let o=nS[i]=Tr.define({id:eS.length,name:r,props:[oM({[r]:n})]});return eS.push(o),o.id}gn.RTL,gn.LTR;const eK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Ow(t.state,n.from);return r.line?tK(t):r.block?rK(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 tK=Rw(oK,0),nK=Rw(hM,0),rK=Rw((t,e)=>hM(t,e,sK(e)),0);function Ow(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Pu=50;function iK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Pu,r),o=t.sliceDoc(i,i+Pu),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*Pu?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Pu),f=t.sliceDoc(i-Pu,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 sK(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 hM(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)=>iK(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 Ay=Po.define(),lK=Po.define(),aK=ze.define(),pM=ze.define({combine(t){return tA(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)})}}),gM=us.define({create(){return es.empty},update(t,e){let n=e.state.facet(pM),r=e.annotation(Ay);if(r){let a=br.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Vh(c,c.length,n.minDepth,a):c=vM(c,e.startState.selection),new es(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(lK);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=br.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 es(t.done.map(br.fromJSON),t.undone.map(br.fromJSON))}});function uK(t={}){return[gM,pM.of(t),Ue.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?mM:e.inputType=="historyRedo"?My:null;return r?(e.preventDefault(),r(n)):!1}})]}function Lp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(gM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const mM=Lp(0,!1),My=Lp(1,!1),cK=Lp(0,!0),fK=Lp(1,!0);class br{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 br(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 br(e.changes&&In.fromJSON(e.changes),[],e.mapped&&ss.fromJSON(e.mapped),e.startSelection&&fe.fromJSON(e.startSelection),e.selectionsAfter.map(fe.fromJSON))}static fromTransaction(e,n){let r=ni;for(let i of e.startState.facet(aK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new br(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ni)}static selection(e){return new br(void 0,ni,void 0,void 0,e)}}function Vh(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 dK(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 hK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function yM(t,e){return t.length?e.length?t.concat(e):t:e}const ni=[],pK=200;function vM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-pK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[br.selection([e])]}function gK(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 Tm(t,e){if(!t.length)return t;let n=t.length,r=ni;for(;n;){let i=mK(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?[br.selection(r)]:ni}function mK(t,e,n){let r=yM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ni,n);if(!t.changes)return br.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new br(i,Gt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const yK=/^(input\.type|delete)($|\.)/;class es{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 es(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||yK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fp(n,e))}function rr(t){return t.textDirectionAt(t.state.selection.main.head)==gn.LTR}const xM=t=>wM(t,!rr(t)),bM=t=>wM(t,rr(t));function kM(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fp(n,e))}const wK=t=>kM(t,!rr(t)),xK=t=>kM(t,rr(t));function bK(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 $p(t,e,n){let r=os(t).resolveInner(e.head),i=n?kt.closedBy:kt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;bK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?fa(t,r.from,1):fa(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,fe.cursor(l,n?-1:1)}const kK=t=>_i(t,e=>$p(t.state,e,!rr(t))),SK=t=>_i(t,e=>$p(t.state,e,rr(t)));function SM(t,e){return _i(t,n=>{if(!n.empty)return Fp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const CM=t=>SM(t,!1),TM=t=>SM(t,!0);function EM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Fp(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.bottomAM(t,!1),Ry=t=>AM(t,!0);function Io(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=fe.cursor(r.from+s))}return i}const CK=t=>_i(t,e=>Io(t,e,!0)),TK=t=>_i(t,e=>Io(t,e,!1)),EK=t=>_i(t,e=>Io(t,e,!rr(t))),AK=t=>_i(t,e=>Io(t,e,rr(t))),MK=t=>_i(t,e=>fe.cursor(t.lineBlockAt(e.head).from,1)),RK=t=>_i(t,e=>fe.cursor(t.lineBlockAt(e.head).to,-1));function OK(t,e,n){let r=!1,i=Za(t.selection,s=>{let o=fa(t,s.head,-1)||fa(t,s.head,1)||s.head>0&&fa(t,s.head-1,1)||s.headOK(t,e);function ui(t,e,n){let r=Za(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=fe.range(i.head,i.anchor));let s=n(i);return fe.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function MM(t,e){return ui(t,e,n=>t.moveByChar(n,e))}const RM=t=>MM(t,!rr(t)),OM=t=>MM(t,rr(t));function PM(t,e){return ui(t,e,n=>t.moveByGroup(n,e))}const IK=t=>PM(t,!rr(t)),NK=t=>PM(t,rr(t)),DK=t=>{let e=!rr(t);return ui(t,e,n=>$p(t.state,n,e))},_K=t=>{let e=rr(t);return ui(t,e,n=>$p(t.state,n,e))};function IM(t,e){return ui(t,e,n=>t.moveVertically(n,e))}const NM=t=>IM(t,!1),DM=t=>IM(t,!0);function _M(t,e){return ui(t,e,n=>t.moveVertically(n,e,EM(t).height))}const iS=t=>_M(t,!1),sS=t=>_M(t,!0),LK=t=>ui(t,!0,e=>Io(t,e,!0)),FK=t=>ui(t,!1,e=>Io(t,e,!1)),$K=t=>{let e=!rr(t);return ui(t,e,n=>Io(t,n,e))},zK=t=>{let e=rr(t);return ui(t,e,n=>Io(t,n,e))},BK=t=>ui(t,!1,e=>fe.cursor(t.lineBlockAt(e.head).from)),jK=t=>ui(t,!0,e=>fe.cursor(t.lineBlockAt(e.head).to)),oS=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),lS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),aS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),uS=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),HK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),WK=({state:t,dispatch:e})=>{let n=zp(t).map(({from:r,to:i})=>fe.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:fe.create(n),userEvent:"select"})),!0},VK=({state:t,dispatch:e})=>{let n=Za(t.selection,r=>{let i=os(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 fe.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function LM(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(Di(n,fe.create(i,i.length-1))),!0)}const UK=t=>LM(t,!1),KK=t=>LM(t,!0),XK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=fe.create([n.main]):n.main.empty||(r=fe.create([fe.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function nf(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:fe.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const FM=(t,e,n)=>nf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iFM(t,!1,!0),$M=t=>FM(t,!0,!1),zM=(t,e)=>nf(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=tr(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}),BM=t=>zM(t,!1),GK=t=>zM(t,!0),qK=t=>nf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headnf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),QK=t=>nf(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:It.of(["",""])},range:fe.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},ZK=({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:tr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:tr(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:fe.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function zp(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 jM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of zp(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(fe.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(fe.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:fe.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const eX=({state:t,dispatch:e})=>jM(t,e,!1),tX=({state:t,dispatch:e})=>jM(t,e,!0);function HM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of zp(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 nX=({state:t,dispatch:e})=>HM(t,e,!1),rX=({state:t,dispatch:e})=>HM(t,e,!0),iX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(zp(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 sX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=os(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(kt.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 cS=WM(!1),oX=WM(!0);function WM(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&&sX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Dp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=cM(u,s);for(c==null&&(c=Ap(/^\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:fe.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const lX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Dp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Pw(t,(s,o,l)=>{let a=cM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Wh(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),UM=({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=Ap(i,t.tabSize),o=0,l=Wh(t,Math.max(0,s-Hh(t)));for(;o(t.setTabFocusMode(),!0),uX=[{key:"Ctrl-b",run:xM,shift:RM,preventDefault:!0},{key:"Ctrl-f",run:bM,shift:OM},{key:"Ctrl-p",run:CM,shift:NM},{key:"Ctrl-n",run:TM,shift:DM},{key:"Ctrl-a",run:MK,shift:BK},{key:"Ctrl-e",run:RK,shift:jK},{key:"Ctrl-d",run:$M},{key:"Ctrl-h",run:Oy},{key:"Ctrl-k",run:qK},{key:"Ctrl-Alt-h",run:BM},{key:"Ctrl-o",run:JK},{key:"Ctrl-t",run:ZK},{key:"Ctrl-v",run:Ry}],cX=[{key:"ArrowLeft",run:xM,shift:RM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:wK,shift:IK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:EK,shift:$K,preventDefault:!0},{key:"ArrowRight",run:bM,shift:OM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:xK,shift:NK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:AK,shift:zK,preventDefault:!0},{key:"ArrowUp",run:CM,shift:NM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:oS,shift:aS},{mac:"Ctrl-ArrowUp",run:rS,shift:iS},{key:"ArrowDown",run:TM,shift:DM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:lS,shift:uS},{mac:"Ctrl-ArrowDown",run:Ry,shift:sS},{key:"PageUp",run:rS,shift:iS},{key:"PageDown",run:Ry,shift:sS},{key:"Home",run:TK,shift:FK,preventDefault:!0},{key:"Mod-Home",run:oS,shift:aS},{key:"End",run:CK,shift:LK,preventDefault:!0},{key:"Mod-End",run:lS,shift:uS},{key:"Enter",run:cS,shift:cS},{key:"Mod-a",run:HK},{key:"Backspace",run:Oy,shift:Oy,preventDefault:!0},{key:"Delete",run:$M,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:BM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:GK,preventDefault:!0},{mac:"Mod-Backspace",run:YK,preventDefault:!0},{mac:"Mod-Delete",run:QK,preventDefault:!0}].concat(uX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),fX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:kK,shift:DK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:SK,shift:_K},{key:"Alt-ArrowUp",run:eX},{key:"Shift-Alt-ArrowUp",run:nX},{key:"Alt-ArrowDown",run:tX},{key:"Shift-Alt-ArrowDown",run:rX},{key:"Mod-Alt-ArrowUp",run:UK},{key:"Mod-Alt-ArrowDown",run:KK},{key:"Escape",run:XK},{key:"Mod-Enter",run:oX},{key:"Alt-l",mac:"Ctrl-l",run:WK},{key:"Mod-i",run:VK,preventDefault:!0},{key:"Mod-[",run:UM},{key:"Mod-]",run:VM},{key:"Mod-Alt-\\",run:lX},{key:"Shift-Mod-k",run:iX},{key:"Shift-Mod-\\",run:PK},{key:"Mod-/",run:eK},{key:"Alt-A",mac:"Ctrl-A",run:nK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:aX}].concat(cX),dX={key:"Tab",run:VM,shift:UM};var fS={};class Uh{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 Uh(e,[],n,r,r,0,[],0,i?new dS(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 Uh(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 hX(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 dS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class hX{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 Kh{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 Kh(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 Kh(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 hS=new Bd;class pX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=hS,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=hS,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 Sa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;gX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Sa.prototype.contextual=Sa.prototype.fallback=Sa.prototype.extend=!1;Sa.prototype.fallback=Sa.prototype.extend=!1;function gX(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||mX(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 pS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function mX(t,e,n,r){let i=pS(n,r,e);return i<0||pS(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 yX{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?gS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?gS(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 Sn){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 vX{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 yX(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&&bX(i);if(o)return Pr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Pr&&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 Pr&&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(kt.contextHash)||0)==c))return e.useNode(f,d),Pr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Sn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Sn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Pr&&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 mS(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(),Pr&&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()&&(Pr&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)Pr&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))Pr&&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),Pr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),mS(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)=>Tr.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=tM;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 Sa(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 wX(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=ws(this.data,s+2);else break;i=n(ws(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=ws(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(Xh.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]=yS(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 kX=oM({String:Ve.string,Number:Ve.number,"True False":Ve.bool,PropertyName:Ve.propertyName,Null:Ve.null,", :":Ve.separator,"[ ]":Ve.squareBracket,"{ }":Ve.brace}),SX=Xh.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:[kX],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}),CX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=TX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function TX(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 EX=Bh.define({name:"json",parser:SX.configure({props:[fM.add({Object:Jk({except:/^\s*\}/}),Array:Jk({except:/^\s*\]/})}),j7.add({"Object Array":H7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function vS(){return new I7(EX)}class wS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class Jo{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ts).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new Da,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=BX(l);if(g)o.add(m,m,Vt.widget({widget:new LX(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 wS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new wS(r.from,s,r.diagnostic)}}),r}function AX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ts).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 MX(t,e){return t.field(Mi,!1)?e:e.concat(Gt.appendConfig.of(YM))}function RX(t,e){return{effects:MX(t,[Iw.of(e)])}}const Iw=Gt.define(),KM=Gt.define(),XM=Gt.define(),Mi=us.define({create(){return new Jo(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=ja(n,t.selected.diagnostic,s)||ja(n,null,s)}!n.size&&i&&e.state.facet(ts).autoPanel&&(i=null),t=new Jo(n,i,r)}for(let n of e.effects)if(n.is(Iw)){let r=e.state.facet(ts).autoPanel?n.value.length?Gh.open:null:t.panel;t=Jo.init(n.value,r,e.state)}else n.is(KM)?t=new Jo(t.diagnostics,n.value?Gh.open:null,t.selected):n.is(XM)&&(t=new Jo(t.diagnostics,t.panel,n.value));return t},provide:t=>[xy.from(t,e=>e.panel),Ue.decorations.from(t,e=>e.diagnostics)]}),OX=Vt.mark({class:"cm-lintRange cm-lintRange-active"});function PX(t,e,n){let{diagnostics:r}=t.state.field(Mi),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 xS=t=>{let e=t.state.field(Mi,!1);return!e||!e.panel?!1:(t.dispatch({effects:KM.of(!1)}),!0)},NX=ai.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ts);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(RX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{ei(this.view.state,r)})}}update(t){let e=t.state.facet(ts);(t.docChanged||e!=t.startState.facet(ts)||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 DX(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 ts=ze.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...tA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:bS,tooltipFilter:bS,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 bS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function _X(t,e={}){return[ts.of({source:t,config:e}),NX,YM]}function GM(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?GM(e.actions):[];return qi("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},qi("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=ja(t.state.field(Mi).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),qi("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return qi("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&qi("div",{class:"cm-diagnosticSource"},e.source))}class LX extends Ja{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return qi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class kS{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 Gh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)xS(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=GM(s.actions);for(let l=0;l{for(let s=0;sxS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Mi).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(Mi),r=ja(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:XM.of(r)})}static open(e){return new Gh(e)}}function FX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function xd(t){return FX(``,'width="6" height="3"')}const $X=Ue.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 zX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function BX(t){let e="hint",n=1;for(let r of t){let i=zX(r.severity);i>n&&(n=i,e=r.severity)}return e}const jX=c7(PX,{hideOn:AX}),YM=[Mi,Ue.decorations.compute([Mi],t=>{let{selected:e,panel:n}=t.field(Mi);return!e||!n||e.from==e.to?Vt.none:Vt.set([OX.range(e.from,e.to)])}),jX,$X],HX=512*1024,SS=512*1024,QM=2e6;function WX(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 VX=t=>t.state.doc.length>HX?[]:CX()(t);function CS(t){return _p.define([{tag:Ve.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ve.string,color:t?"#86efac":"#15803d"},{tag:Ve.number,color:t?"#fcd34d":"#b45309"},{tag:Ve.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ve.null,color:t?"#a1a1aa":"#71717a"}])}const UX=Ue.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 JM({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>SS,k=v.useRef(w),b=!x&&t.length>QM,C=b?WX(t,SS):t,T=v.useRef(!1),E=v.useCallback((R,O,_)=>R?[Ue.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[_X(VX,{delay:300})]]:[Ft.readOnly.of(!0),Ue.editable.of(!1)],[]);return v.useEffect(()=>{const R=u.current;if(!R)return;const O=new ol,_=new ol,P=new ol,I=Ft.create({doc:C,extensions:[P.of(w||!r?[]:vS()),Ue.lineWrapping,uK(),QA.of([...fX,...vK,dX]),UX,O.of(Zk(CS(i))),_.of(E(x,w,r)),...s?[t7(s)]:[]]}),D=new Ue({state:I,parent:R});return h.current=O,p.current=_,m.current=P,a==null||a(D),c.current=D,()=>{D.destroy(),c.current=null}},[]),v.useEffect(()=>{const R=c.current;if(!R)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?[]:vS())),_&&P.push(_.reconfigure(E(x,w,r))));const I=R.state.doc.toString();if(!(I===C&&P.length===0)){T.current=!0;try{R.dispatch({...I!==C?{changes:{from:0,to:R.state.doc.length,insert:C}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[C,w,r,x,E]),v.useEffect(()=>{const R=c.current,O=p.current;!R||!O||x!==g.current&&(g.current=x,R.dispatch({effects:O.reconfigure(E(x,w,r))}))},[x,w,r,E]),v.useEffect(()=>{const R=c.current;if(!R||i===d.current)return;d.current=i;const O=h.current;O&&R.dispatch({effects:O.reconfigure(Zk(CS(i)))})},[i]),A.jsxs("div",{"data-testid":o,className:xr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[b?A.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,A.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function ZM({title:t,meta:e,actions:n,status:r,children:i}){return A.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[A.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:[A.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[A.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?A.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),A.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),A.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?A.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 rl="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 Py={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(le){var x=d.lastIndexOf(` +`,le.offset),g=d.indexOf(` +`,le.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw le.message+" On line "+le.line+" and column "+le.column+`. +`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),C=0;Cy&&(y=g,w=[]),w.push(M))}function b(){var M,N,L,B;return L=g,B=g,M=function(j){return Y=","}()?"":null,M!==null?(N=R(),N!==null?M=[M,N]:(M=null,g=B)):(M=null,g=B),M!==null&&(M=function(j,$){return $}(L,M[1])),M===null&&(g=L),M}function C(){var M,N,L,B;return L=g,B=g,M=function(j){return Y=";"}()?"":null,M!==null?(N=R(),N!==null?M=[M,N]:(M=null,g=B)):(M=null,g=B),M!==null&&(M=function(j,$){return $}(L,M[1])),M===null&&(g=L),M}function T(){var M,N,L,B;return L=g,B=g,M=function(j){return Y="|"}()?"":null,M!==null?(N=R(),N!==null?M=[M,N]:(M=null,g=B)):(M=null,g=B),M!==null&&(M=function(j,$){return $}(L,M[1])),M===null&&(g=L),M}function E(){var M,N,L,B;return L=g,B=g,M=function(j){return Y=" "}()?"":null,M!==null?(N=R(),N!==null?M=[M,N]:(M=null,g=B)):(M=null,g=B),M!==null&&(M=function(j,$){return $}(L,M[1])),M===null&&(g=L),M}function R(){var M,N,L,B,j,$,ae,he,ve;for($=g,ae=g,M=[],/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));N!==null;)M.push(N),/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));if(M!==null)if(N=O(),N!==null){if(L=[],he=g,ve=g,/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]")),j!==null)for(B=[];j!==null;)B.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));else B=null;for(B!==null?(j=O(),j!==null?B=[B,j]:(B=null,g=ve)):(B=null,g=ve),B!==null&&(B=function(Fe,De){return De}(he,B[1])),B===null&&(g=he);B!==null;){if(L.push(B),he=g,ve=g,/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]")),j!==null)for(B=[];j!==null;)B.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));else B=null;B!==null?(j=O(),j!==null?B=[B,j]:(B=null,g=ve)):(B=null,g=ve),B!==null&&(B=function(Fe,De){return De}(he,B[1])),B===null&&(g=he)}if(L!==null){for(B=[],/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));j!==null;)B.push(j),/^[\n\r]/.test(p.charAt(g))?(j=p.charAt(g),g++):(j=null,k("[\\n\\r]"));B!==null?M=[M,N,L,B]:(M=null,g=ae)}else M=null,g=ae}else M=null,g=ae;else M=null,g=ae;return M!==null&&(M=function(Fe,De,Ze){return Ze.unshift(De),Ze}($,M[1],M[2])),M===null&&(g=$),M}function O(){var M,N,L,B,j,$,ae,he,ve;if($=g,ae=g,M=_(),M!==null){for(N=[],he=g,ve=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(B=function(Fe,De){return De==Y}(g,L)?"":null,B!==null?(j=_(),j!==null?L=[L,B,j]:(L=null,g=ve)):(L=null,g=ve)):(L=null,g=ve),L!==null&&(L=function(Fe,De,Ze){return Ze}(he,L[0],L[2])),L===null&&(g=he);L!==null;)N.push(L),he=g,ve=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(B=function(Fe,De){return De==Y}(g,L)?"":null,B!==null?(j=_(),j!==null?L=[L,B,j]:(L=null,g=ve)):(L=null,g=ve)):(L=null,g=ve),L!==null&&(L=function(Fe,De,Ze){return Ze}(he,L[0],L[2])),L===null&&(g=he);N!==null?(L=function(Fe,De,Ze){return!!De||Ze.length}(g,M,N)?"":null,L!==null?M=[M,N,L]:(M=null,g=ae)):(M=null,g=ae)}else M=null,g=ae;return M!==null&&(M=function(Fe,De,Ze){return Ze.unshift(De),Ze}($,M[0],M[1])),M===null&&(g=$),M}function _(){var M,N,L,B,j,$;if(B=g,j=g,p.charCodeAt(g)===34?(M='"',g++):(M=null,k('"\\""')),M!==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?M=[M,N,L]:(M=null,g=j)):(M=null,g=j)}else M=null,g=j;if(M!==null&&(M=function(ae,he){return he.join("")}(B,M[1])),M===null&&(g=B),M===null){for(B=g,M=[],j=g,$=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(ae,he){return he!=Y}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=$)):(N=null,g=$),N!==null&&(N=function(ae,he){return he}(j,N[0])),N===null&&(g=j);N!==null;)M.push(N),j=g,$=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(ae,he){return he!=Y}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=$)):(N=null,g=$),N!==null&&(N=function(ae,he){return he}(j,N[0])),N===null&&(g=j);M!==null&&(M=function(ae,he){return(o?he.join("").trim():he.join("")).replace(/(^")|("$)/g,"")}(B,M)),M===null&&(g=B)}return M}function P(){var M,N,L,B;return L=g,B=g,p.charCodeAt(g)===34?(M='"',g++):(M=null,k('"\\""')),M!==null?(p.charCodeAt(g)===34?(N='"',g++):(N=null,k('"\\""')),N!==null?M=[M,N]:(M=null,g=B)):(M=null,g=B),M!==null&&(M=function(j){return'"'}()),M===null&&(g=L),M===null&&(/^[^"]/.test(p.charAt(g))?(M=p.charAt(g),g++):(M=null,k('[^"]'))),M}function I(M){M.sort();for(var N=null,L=[],B=0;B=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function uo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function nG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function rG(t){const e=n=>{if(!uo(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(nG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):uo(t)?e(t):t}function iG(t,e){if(e.parseJSON){const n=tG(t);if(n.ok&&typeof n.value!="number")return n.value}return e.parseNumbers?eG(t):t}function sG(t,e){const n=i=>{const s={};for(const o of Object.keys(i)){const l=i[o];if(typeof l!="string"){s[o]=l;continue}const a=iG(l,e);if(!(e.emptyFields==="skip"&&a==="")){if(e.nullLiterals==="null"&&a==="NULL"){s[o]=null;continue}s[o]=a}}return s};if(Array.isArray(t))return t.map(i=>uo(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=uo(s)?n(s):s;return r}const oG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function tR(t){const e=oG.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 Ny(t){const e=new Set(t),n=new Map;for(const i of t){const s=tR(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 ES(t,e){return t===void 0||t===""||e==="skip"&&t===null}function AS(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=>tR(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];ES(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];ES(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 lG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!uo(r))return e;const i=Object.keys(r),s=Ny(i);return s.length===0?e:e.map(o=>uo(o)?AS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!uo(r))return e;const i=Object.keys(r),s=Ny(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=uo(a)?AS(a,i,s,n):a;return o}return e}function MS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string"},r=t.startsWith(TS)?t.slice(TS.length):t;try{const i=XX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=sG(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?lG(i,s,n.emptyFields):s}catch(i){throw new Error(eR(i))}}function aG(t,e={}){try{const n=e.flatten?rG(t):t;return qX(n,e)}catch(n){const r=eR(n);throw JX.some(i=>r.startsWith(i))?new YX(QX(r,e.flatten??!1)):new Error(r)}}function uG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const Ir={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},RS=["data","items","results","records","rows"];function OS(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function cG(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!OS(n))return[];const r=Object.keys(n),i=new Set(RS),s=[...RS.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=>OS(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function nR(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 fG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=nR(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 dG(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 PS=t=>t==="auto"?void 0:t;function hG(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=ZM(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=MS(n.separator),s=nG(r,{separator:i,flatten:n.flatten}),o=Qc(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 cG(){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 Pu({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:nl,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function fG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i0;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=nR(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=PS(n.separator),s=aG(r,{separator:i,flatten:n.flatten}),o=Jc(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 mG(){return A.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:A.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function Iu({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return A.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:rl,children:[i?A.jsx(i,{"aria-hidden":"true"}):null,i&&!s?A.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function yG(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 dG({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:C}){const[T,A]=v.useState(!1),[M,O]=v.useState(!1),_=v.useRef(0),P=v.useRef(null),I=e.trim()==="",D=t==="CSV",Y=v.useMemo(()=>{if(!D||I)return[];const j=fG(e),B=Qc(j,m);return Oy(B.headers.map(oe=>oe.trim()))},[D,I,e,m]),ie=v.useMemo(()=>D||I?[]:iG(e),[D,I,e]),se=v.useMemo(()=>D||I?null:sG(e),[D,I,e]),V=j=>{var B;j.preventDefault(),Array.from(((B=j.dataTransfer)==null?void 0:B.types)??[]).includes("Files")&&(_.current++,O(!0))},J=()=>{_.current=Math.max(0,_.current-1),_.current===0&&O(!1)},R=j=>{var oe,fe;j.preventDefault(),_.current=0,O(!1);const B=(fe=(oe=j.dataTransfer)==null?void 0:oe.files)==null?void 0:fe[0];B&&r(B,"drop")},N=j=>{var oe;if(!I||j.defaultPrevented||j.target instanceof HTMLTextAreaElement||j.target instanceof HTMLInputElement)return;const B=(oe=j.clipboardData)==null?void 0:oe.getData("text/plain");B&&(j.preventDefault(),n(B))},L=D?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":!T,onClick:()=>A(!1),className:xr("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",T?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(aN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":T,onClick:()=>A(!0),className:xr("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",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(ox,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,z=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(cG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:V,onDragOver:j=>j.preventDefault(),onDragLeave:J,onDrop:R,onPaste:N,"data-drag-over":M||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(YM,{title:t,meta:z,actions:E.jsxs(E.Fragment,{children:[L,D&&(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:nl,children:E.jsx(gN,{"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:nl,children:E.jsx(QI,{"aria-hidden":"true"})})]}):null,se?E.jsx(Pu,{label:se.label,testId:"json-format-toggle",onClick:()=>n(se.nextInput),Icon:ox,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:P,type:"file","data-testid":"file-input",accept:D?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:j=>{var oe;const B=(oe=j.target.files)==null?void 0:oe[0];B&&r(B,"picker"),j.target.value=""}}),E.jsx(Pu,{label:"Upload",testId:"upload",onClick:()=>{var j;return(j=P.current)==null?void 0:j.click()},Icon:aT}),E.jsx(Pu,{label:"Copy",testId:"copy-input",onClick:o,Icon:Rv}),E.jsx(Pu,{label:"Clear",testId:"clear-input",onClick:s,disabled:I,Icon:ch}),E.jsx(Pu,{label:"Download",testId:"download-input",onClick:a,disabled:I,Icon:lT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[I?E.jsx(I9,{format:t,onIngest:n,onBrowse:()=>{var j;return(j=P.current)==null?void 0:j.click()},onTryExample:i}):D?E.jsxs(E.Fragment,{children:[Y.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 (${Y.map(j=>`${j.prefix}[${j.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>C==null?void 0:C(),className:xr("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,T?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:j=>n(j.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(DE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l})]}):E.jsxs(E.Fragment,{children:[ie.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:"}),ie.map(j=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${j.key}`,onClick:()=>n(j.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 .${j.key} (${j.rowCount} ${j.rowCount===1?"row":"rows"})`},j.key))]}):null,E.jsx(qM,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),M?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 hG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function pG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:hG.test(t.name)}const gG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function RS(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 eR(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 tR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function OS(){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=tR.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 PS(){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 IS(){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 NS({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 Gs({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:xr("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:xr("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(Py,{text:r}):null]})}function Py({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 yG({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=eR("(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(NS,{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:PS(),children:tR.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(IS,{})]})]}),E.jsx(Py,{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(OS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(NS,{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:PS(),children:gG.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(IS,{})]})]}),E.jsx(Py,{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(OS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(Gs,{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(Gs,{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(Gs,{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(Gs,{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(Gs,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(Gs,{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(Gs,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(Gs,{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(zI,{"aria-hidden":"true",className:xr("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:xr("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 vG=[{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"}],wG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),xG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function $d(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Ow(t){if(Array.isArray(t))return t.map(e=>$d(e)?e:{value:e});if($d(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>$d(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function nR(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 bG(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(!wG.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 Cm(t){return`"${t.replace(/"/g,'""')}"`}function kG(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 SG(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 CG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return Ow(n).map(i=>JSON.stringify(i)).join(` -`)}function TG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Ow(r),s=nR(i),o=Cm(bG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=kG(h);return` ${Cm(d)} ${p}`}),a=`CREATE TABLE ${o} ( +`&&(i+=1),r+=1,r>=3))return t.slice(0,i+1)}return t.slice(0,e)}function vG({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:C}){const[T,E]=v.useState(!1),[R,O]=v.useState(!1),_=v.useRef(0),P=v.useRef(null),I=e.trim()==="",D=t==="CSV",Y=v.useMemo(()=>{if(!D||I)return[];const j=yG(e),$=Jc(j,m);return Ny($.headers.map(ae=>ae.trim()))},[D,I,e,m]),oe=v.useMemo(()=>D||I?[]:cG(e),[D,I,e]),le=v.useMemo(()=>D||I?null:fG(e),[D,I,e]),V=j=>{var $;j.preventDefault(),Array.from((($=j.dataTransfer)==null?void 0:$.types)??[]).includes("Files")&&(_.current++,O(!0))},Z=()=>{_.current=Math.max(0,_.current-1),_.current===0&&O(!1)},M=j=>{var ae,he;j.preventDefault(),_.current=0,O(!1);const $=(he=(ae=j.dataTransfer)==null?void 0:ae.files)==null?void 0:he[0];$&&r($,"drop")},N=j=>{var ae;if(!I||j.defaultPrevented||j.target instanceof HTMLTextAreaElement||j.target instanceof HTMLInputElement)return;const $=(ae=j.clipboardData)==null?void 0:ae.getData("text/plain");$&&(j.preventDefault(),n($))},L=D?A.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:[A.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!T,onClick:()=>E(!1),className:xr("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",T?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[A.jsx(fN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),A.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":T,onClick:()=>E(!0),className:xr("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",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[A.jsx(ux,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,B=c&&u?A.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[A.jsx(mG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return A.jsx("div",{"data-testid":"input-pane",onDragEnter:V,onDragOver:j=>j.preventDefault(),onDragLeave:Z,onDrop:M,onPaste:N,"data-drag-over":R||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:A.jsxs(ZM,{title:t,meta:B,actions:A.jsxs(A.Fragment,{children:[L,D&&(g||y)?A.jsxs(A.Fragment,{children:[A.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!g,onClick:()=>w==null?void 0:w(),className:rl,children:A.jsx(vN,{"aria-hidden":"true"})}),A.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!y,onClick:()=>k==null?void 0:k(),className:rl,children:A.jsx(eN,{"aria-hidden":"true"})})]}):null,le?A.jsx(Iu,{label:le.label,testId:"json-format-toggle",onClick:()=>n(le.nextInput),Icon:ux,keepLabelOnMobile:!0}):null,A.jsx("input",{ref:P,type:"file","data-testid":"file-input",accept:D?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:j=>{var ae;const $=(ae=j.target.files)==null?void 0:ae[0];$&&r($,"picker"),j.target.value=""}}),A.jsx(Iu,{label:"Upload",testId:"upload",onClick:()=>{var j;return(j=P.current)==null?void 0:j.click()},Icon:fT}),A.jsx(Iu,{label:"Copy",testId:"copy-input",onClick:o,Icon:Iv}),A.jsx(Iu,{label:"Clear",testId:"clear-input",onClick:s,disabled:I,Icon:hh}),A.jsx(Iu,{label:"Download",testId:"download-input",onClick:a,disabled:I,Icon:cT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[I?A.jsx($9,{format:t,onIngest:n,onBrowse:()=>{var j;return(j=P.current)==null?void 0:j.click()},onTryExample:i}):D?A.jsxs(A.Fragment,{children:[Y.length>0?A.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:[A.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${Y.map(j=>`${j.prefix}[${j.indices.length}]`).join(", ")}):`}),A.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>C==null?void 0:C(),className:xr("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,T?A.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:j=>n(j.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"}):A.jsx(FE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l})]}):A.jsxs(A.Fragment,{children:[oe.length>0?A.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:[A.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),oe.map(j=>A.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${j.key}`,onClick:()=>n(j.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 .${j.key} (${j.rowCount} ${j.rowCount===1?"row":"rows"})`},j.key))]}):null,A.jsx(JM,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),R?A.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:A.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const wG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function xG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:wG.test(t.name)}const bG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function IS(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 rR(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 iR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function NS(){return A.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function kG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=iR.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 DS(){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 A.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:A.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function LS({children:t}){return A.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function Gs({label:t,checked:e,onChange:n,hint:r}){return A.jsxs("span",{className:"inline-flex items-center gap-1",children:[A.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[A.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:A.jsx("span",{className:xr("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:A.jsx("span",{className:xr("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),A.jsx("span",{className:"select-none",children:t})]}),r?A.jsx(Dy,{text:r}):null]})}function Dy({text:t}){const e=v.useId(),[n,r]=v.useState(!1);return A.jsxs("span",{className:"relative inline-flex items-center",children:[A.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"}),A.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function SG({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=rR("(min-width: 98.5rem)"),f=t==="csv2json",d=kG(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=A.jsxs(A.Fragment,{children:[A.jsxs("span",{className:"inline-flex items-center gap-2",children:[A.jsxs("label",{className:"flex items-center gap-2",children:[A.jsx(LS,{children:"Separator"}),A.jsxs("span",{className:"relative inline-flex",children:[A.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:m=>n({separator:m.target.value}),className:DS(),children:iR.map(m=>A.jsx("option",{value:m.value,children:m.label},m.value))}),A.jsx(_S,{})]})]}),A.jsx(Dy,{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?A.jsxs(A.Fragment,{children:[A.jsx(NS,{}),A.jsxs("span",{className:"inline-flex items-center gap-2",children:[A.jsxs("label",{className:"flex items-center gap-2",children:[A.jsx(LS,{children:"Encoding"}),A.jsxs("span",{className:"relative inline-flex",children:[A.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:m=>s(m.target.value),className:DS(),children:bG.map(m=>A.jsx("option",{value:m.value,children:m.label},m.value))}),A.jsx(_S,{})]})]}),A.jsx(Dy,{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,A.jsx(NS,{}),f?A.jsxs(A.Fragment,{children:[A.jsx(Gs,{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."}),A.jsx(Gs,{label:"Parse JSON",checked:e.parseJSON,onChange:m=>n({parseJSON:m}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),A.jsx(Gs,{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.'}),A.jsx(Gs,{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."}),A.jsx(Gs,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),A.jsx(Gs,{label:"Hash output",checked:e.hash,onChange:m=>n({hash:m}),hint:"The first column becomes the object key instead of a field."}),A.jsx(Gs,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):A.jsx(Gs,{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?A.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:A.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?A.jsxs(A.Fragment,{children:[A.jsx("div",{className:"flex-1"}),A.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):A.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:[A.jsxs("div",{className:"flex w-full items-center gap-2",children:[A.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",A.jsx(WI,{"aria-hidden":"true",className:xr("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),A.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?A.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),A.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:xr("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 CG=[{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"}],TG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),EG=/^[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 sR(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 AG(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(!TG.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 Am(t){return`"${t.replace(/"/g,'""')}"`}function MG(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 RG(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 OG(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 PG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Nw(r),s=sR(i),o=Am(AG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=MG(h);return` ${Am(d)} ${p}`}),a=`CREATE TABLE ${o} ( ${l.join(`, `)} -);`;if(i.length===0)return a;const u=s.map(Cm).join(", "),c=i.map(d=>` (${s.map(p=>SG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES +);`;if(i.length===0)return a;const u=s.map(Am).join(", "),c=i.map(d=>` (${s.map(p=>RG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES ${c.join(`, `)};`;return`${a} -${f}`}function rR(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=iR(Array.from(new Set(t.map(n=>rR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return $d(t)?"Record":"unknown"}const DS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function iR(t){return[...t].sort((e,n)=>{const r=DS[e]??50,i=DS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function EG(t){return xG.test(t)?t:JSON.stringify(t)}function AG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Ow(n),s=nR(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(rR(h[l]))}const c=iR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${EG(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { +${f}`}function oR(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=lR(Array.from(new Set(t.map(n=>oR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return jd(t)?"Record":"unknown"}const FS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function lR(t){return[...t].sort((e,n)=>{const r=FS[e]??50,i=FS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function IG(t){return EG.test(t)?t:JSON.stringify(t)}function NG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Nw(n),s=sR(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(oR(h[l]))}const c=lR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${IG(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 MG(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 CG(i);case"sql":return TG(i,s);case"ts":return AG(i)}}const RG=3;function OG(t){const e=t.slice(0,RG),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` -`)}function PG({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(YM,{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:nl,children:[E.jsx(lx,{"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:vG.map(C=>{const T=u===C.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${C.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(C.format),className:xr("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:C.label},C.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:nl,children:[E.jsx(Rv,{"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:nl,children:[E.jsx(lT,{"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:nl+" ml-2",children:[E.jsx(lx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:OG(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(qM,{value:n,editable:a&&b&&n.length<=GM,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):E.jsx(DE,{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 IG({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 Pw="csvjson:recent.v1",sR=10,oR=1e5,_S=80;function NG(t){return t==="csv2json"||t==="json2csv"}function lR(t){if(typeof t!="object"||t===null)return{...Ir};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:Ir.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:Ir.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:Ir.nullLiterals;return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:Ir.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:Ir.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:Ir.transpose,hash:typeof e.hash=="boolean"?e.hash:Ir.hash,minify:typeof e.minify=="boolean"?e.minify:Ir.minify,flatten:typeof e.flatten=="boolean"?e.flatten:Ir.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:Ir.collapseIndexedArrays}}function aR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=_S?n:`${n.slice(0,_S-1)}…`}function DG(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)||!NG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>oR||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 _G(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:lR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||aR(t.input)}}function uR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Pw,JSON.stringify(t))}catch{}}function LG(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 Iw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Pw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(DG).map(_G).sort((r,i)=>i.createdAt-r.createdAt).slice(0,sR):[]}catch{return[]}}function LS(t){const e=Iw(),n=t.input.trim();if(n===""||t.input.length>oR||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)??LG(r),createdAt:r,direction:t.direction,input:t.input,options:lR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:aR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,sR);return uR(l),l}function FG(t){const n=Iw().filter(r=>r.id!==t);return uR(n),n}function $G(){try{if(typeof window>"u")return;window.localStorage.removeItem(Pw)}catch{}}function BG(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 jG(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function HG({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(VI,{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(Ov,{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:jG(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:BG(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(ch,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Iy=20,Ny=80,FS=50;function Tm(t){return Math.min(Ny,Math.max(Iy,t))}function WG({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(Tm(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(Tm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Tm(e+d));break;case"Home":f.preventDefault(),n(Iy);break;case"End":f.preventDefault(),n(Ny);break;case"Enter":case" ":f.preventDefault(),n(FS);break}};return E.jsxs("div",{ref:o,className:xr("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:xr("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":Iy,"aria-valuemax":Ny,"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(FS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:xr("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:xr("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 VG({theme:t}){return t==="dark"?E.jsx(oN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(qI,{size:15,strokeWidth:2,"aria-hidden":"true"})}function UG({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(VG,{theme:t})})]})}function KG(t){return[...t].sort((e,n)=>n.id-e.id)}const cR=[{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."}],XG=864e5;function $S(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function GG(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round(($S(r)-$S(n))/XG);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 fR="csvjson:changelog.v1",Bd=Math.max(...cR.map(t=>t.id),0),qG=KG(cR);function YG(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&&!QG(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function QG(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function dR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Bd).sort((e,n)=>e-n)}function BS(t,e,n){const r=dR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function JG(){try{const t=window.localStorage.getItem(fR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return YG(e)?{...e,pendingIds:dR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function ZG(t){try{window.localStorage.setItem(fR,JSON.stringify(t))}catch{}}function eq(){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 tq(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 zS(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 nq({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:GG(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:zS(e===1),children:E.jsx(dN,{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:zS(e===-1),children:E.jsx(cN,{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 rq(){const[t,e]=v.useState(JG),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{ZG(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&&Bd>t.lastSeenId,h=v.useCallback((b,C)=>{l(T=>{const A=new Set(T);return C?A.add(b):A.delete(b),A})},[]),p=v.useCallback((b,C,T,A)=>{const M=(f.current.get(b)??0)+1;f.current.set(b,M),a.current.add(b),A&&h(b,!0),tq(T,b,C).then(O=>{f.current.get(b)===M&&(a.current.delete(b),O==="ok"&&(bI({entry_id:b,vote:C}),s(BS(i.current,b,!1))),A&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:C,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&C!==void 0)for(const O of M){if(O===b||a.current.has(O))continue;const _=A[O];_!==void 0&&p(O,_,C,!1)}},[p]),x=(b,C)=>{if(t.votes[b]===C){m();return}const T=t.clientId??eq();s(BS({...t,votes:{...t.votes,[b]:C},clientId:T},b,!0)),p(b,C,T,!0),m(b)},g=()=>{r(!0),xI(),t.lastSeenId!==Bd&&s({...t,lastSeenId:Bd}),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()},C=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",C)}},[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(ZI,{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(Ov,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:qG.map(b=>{var C;return E.jsx(nq,{entry:b,vote:t.votes[b.id],queued:((C=t.pendingIds)==null?void 0:C.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function iq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const sq={},oq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],lq=["csv2json","json2csv","csvjson2json"];function aq(t){return lq.includes(t)}const uq=/^[0-9a-f]{32}$/i,cq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Em=sq,fq=((Em==null?void 0:Em.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function dq(t){const e=cq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return oq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class Dy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Am extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Mm={csv:(t,e)=>{t.direction="csv2json",t.input=Kh(e)},json:(t,e)=>{t.input=Kh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Wl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Kh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function jS(t){return typeof t=="string"&&t.trim()!==""}function Wl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function hq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function pq(t){var i;if(!hq(t))return null;const e=jS(t.csv),n=jS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Mm[s])==null||i.call(Mm,r,o);return r.input=Kh(e?t.csv:t.json),r}async function gq(t){if(!uq.test(t))throw new Dy;let e;try{e=await fetch(`${fq}${t}`,{mode:"cors"})}catch(r){throw new Am("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new Dy;if(!e.ok)throw new Am(`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 Am("Stored data for this link is malformed")}return n}function mq(t){const e=v.useMemo(()=>t&&aq(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 gq(e).then(f=>{if(c)return;const d=pq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof Dy?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 HS(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 yq="\uFEFF";function vq(t,e){return e?yq+t:t}function wq(t,e,n){const r=vq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const xq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function bq(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(!xq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function kq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${bq(t)}.${r}`:`data.${r}`}function Sq(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 WS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=wq(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 Cq(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 Tq=`album,year,US_peak_chart_post +export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function DG(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 OG(i);case"sql":return PG(i,s);case"ts":return NG(i)}}const _G=3;function LG(t){const e=t.slice(0,_G),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function FG({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 A.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:A.jsx(ZM,{title:t,meta:e?null:l?A.jsxs("span",{className:"flex items-center gap-1.5",children:[A.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"}),A.jsxs("button",{type:"button","data-testid":"revert-output",onClick:y,className:rl,children:[A.jsx(cx,{"aria-hidden":"true"}),"Revert"]})]}):s?A.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:A.jsxs(A.Fragment,{children:[k?A.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:CG.map(C=>{const T=u===C.format;return A.jsx("button",{type:"button","data-testid":`output-format-option-${C.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(C.format),className:xr("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:C.label},C.format)})}):null,A.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:rl,children:[A.jsx(Iv,{"aria-hidden":"true"}),A.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),A.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:m,disabled:!n,className:rl,children:[A.jsx(cT,{"aria-hidden":"true"}),A.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:w?A.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:w,className:rl+" ml-2",children:[A.jsx(cx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:LG(o)}:null,children:e?A.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?k?A.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>p==null?void 0:p(),children:A.jsx(JM,{value:n,editable:a&&b&&n.length<=QM,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):A.jsx(FE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h}):r?A.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):A.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 $G({phase:t,message:e,onRetry:n}){return t==="loading"?A.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"?A.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:[A.jsx("span",{children:"This data doesn't exist (or was deleted)."}),A.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?A.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:[A.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),A.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):A.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:[A.jsx("span",{children:e||"Couldn't load this data."}),A.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",aR=10,uR=1e5,$S=80;function zG(t){return t==="csv2json"||t==="json2csv"}function cR(t){if(typeof t!="object"||t===null)return{...Ir};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:Ir.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:Ir.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:Ir.nullLiterals;return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:Ir.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:Ir.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:Ir.transpose,hash:typeof e.hash=="boolean"?e.hash:Ir.hash,minify:typeof e.minify=="boolean"?e.minify:Ir.minify,flatten:typeof e.flatten=="boolean"?e.flatten:Ir.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:Ir.collapseIndexedArrays}}function fR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=$S?n:`${n.slice(0,$S-1)}…`}function BG(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)||!zG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>uR||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 jG(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:cR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||fR(t.input)}}function dR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Dw,JSON.stringify(t))}catch{}}function HG(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(BG).map(jG).sort((r,i)=>i.createdAt-r.createdAt).slice(0,aR):[]}catch{return[]}}function zS(t){const e=_w(),n=t.input.trim();if(n===""||t.input.length>uR||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)??HG(r),createdAt:r,direction:t.direction,input:t.input,options:cR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:fR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,aR);return dR(l),l}function WG(t){const n=_w().filter(r=>r.id!==t);return dR(n),n}function VG(){try{if(typeof window>"u")return;window.localStorage.removeItem(Dw)}catch{}}function UG(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 KG(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function XG(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function GG({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 A.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[A.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:[A.jsx(XI,{size:14,strokeWidth:2,"aria-hidden":"true"}),A.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&A.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&&A.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:[A.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[A.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),A.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&A.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"}),A.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:A.jsx(Nv,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?A.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."}):A.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>A.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[A.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:[A.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[A.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:KG(f.direction)}),A.jsx("span",{className:"text-[11px] text-muted-foreground",children:XG(f.rows,f.cols)}),A.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:UG(f.createdAt)})]}),A.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),A.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:A.jsx(hh,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const _y=20,Ly=80,BS=50;function Mm(t){return Math.min(Ly,Math.max(_y,t))}function qG({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(Mm(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(Mm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Mm(e+d));break;case"Home":f.preventDefault(),n(_y);break;case"End":f.preventDefault(),n(Ly);break;case"Enter":case" ":f.preventDefault(),n(BS);break}};return A.jsxs("div",{ref:o,className:xr("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[A.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:xr("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}),A.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":_y,"aria-valuemax":Ly,"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(BS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:xr("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:[A.jsx("div",{className:xr("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?A.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]}),A.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 YG({theme:t}){return t==="dark"?A.jsx(uN,{size:15,strokeWidth:2,"aria-hidden":"true"}):A.jsx(JI,{size:15,strokeWidth:2,"aria-hidden":"true"})}function QG({theme:t,onToggleTheme:e,slot:n}){return A.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:[A.jsxs("div",{className:"flex items-baseline gap-2",children:[A.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),A.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),A.jsx("div",{className:"flex-1"}),A.jsx("div",{"data-testid":"topbar-slot",children:n}),A.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:A.jsx(YG,{theme:t})})]})}function JG(t){return[...t].sort((e,n)=>n.id-e.id)}const hR=[{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."}],ZG=864e5;function jS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function eq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((jS(r)-jS(n))/ZG);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 pR="csvjson:changelog.v1",Hd=Math.max(...hR.map(t=>t.id),0),tq=JG(hR);function nq(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&&!rq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function rq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function gR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Hd).sort((e,n)=>e-n)}function HS(t,e,n){const r=gR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function iq(){try{const t=window.localStorage.getItem(pR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return nq(e)?{...e,pendingIds:gR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function sq(t){try{window.localStorage.setItem(pR,JSON.stringify(t))}catch{}}function oq(){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 lq(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 WS(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 aq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return A.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[A.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&A.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}),A.jsx("span",{className:"text-[11px] text-muted-foreground",children:eq(t.date)})]}),A.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),A.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),A.jsxs("div",{className:"mt-1.5 flex gap-1",children:[A.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:WS(e===1),children:A.jsx(gN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),A.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:WS(e===-1),children:A.jsx(hN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&A.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 uq(){const[t,e]=v.useState(iq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{sq(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,C)=>{l(T=>{const E=new Set(T);return C?E.add(b):E.delete(b),E})},[]),p=v.useCallback((b,C,T,E)=>{const R=(f.current.get(b)??0)+1;f.current.set(b,R),a.current.add(b),E&&h(b,!0),lq(T,b,C).then(O=>{f.current.get(b)===R&&(a.current.delete(b),O==="ok"&&(CI({entry_id:b,vote:C}),s(HS(i.current,b,!1))),E&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:C,pendingIds:T,votes:E}=i.current,R=T??[];if(R.length!==0&&C!==void 0)for(const O of R){if(O===b||a.current.has(O))continue;const _=E[O];_!==void 0&&p(O,_,C,!1)}},[p]),x=(b,C)=>{if(t.votes[b]===C){m();return}const T=t.clientId??oq();s(HS({...t,votes:{...t.votes,[b]:C},clientId:T},b,!0)),p(b,C,T,!0),m(b)},g=()=>{r(!0),SI(),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()},C=T=>{const E=u.current;E===null||!(T.target instanceof Node)||E.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",C),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",C)}},[n,y]),A.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[A.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:[A.jsx(nN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&A.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&A.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:[A.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[A.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),A.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:A.jsx(Nv,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),A.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:tq.map(b=>{var C;return A.jsx(aq,{entry:b,vote:t.votes[b.id],queued:((C=t.pendingIds)==null?void 0:C.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function cq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const fq={},dq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],hq=["csv2json","json2csv","csvjson2json"];function pq(t){return hq.includes(t)}const gq=/^[0-9a-f]{32}$/i,mq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Rm=fq,yq=((Rm==null?void 0:Rm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function vq(t){const e=mq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return dq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class Fy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Om extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Pm={csv:(t,e)=>{t.direction="csv2json",t.input=qh(e)},json:(t,e)=>{t.input=qh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Vl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function qh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function VS(t){return typeof t=="string"&&t.trim()!==""}function Vl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function wq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function xq(t){var i;if(!wq(t))return null;const e=VS(t.csv),n=VS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Pm[s])==null||i.call(Pm,r,o);return r.input=qh(e?t.csv:t.json),r}async function bq(t){if(!gq.test(t))throw new Fy;let e;try{e=await fetch(`${yq}${t}`,{mode:"cors"})}catch(r){throw new Om("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new Fy;if(!e.ok)throw new Om(`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 Om("Stored data for this link is malformed")}return n}function kq(t){const e=v.useMemo(()=>t&&pq(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 bq(e).then(f=>{if(c)return;const d=xq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof Fy?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 US(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 Sq="\uFEFF";function Cq(t,e){return e?Sq+t:t}function Tq(t,e,n){const r=Cq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Eq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Aq(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(!Eq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function Mq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Aq(t)}.${r}`:`data.${r}`}function Rq(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 KS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Tq(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 Oq(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 Pq=`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`,Eq=`[ +Icky Thump,2007,2`,Iq=`[ { "album": "Elephant", "year": 2003, @@ -304,4 +304,4 @@ Icky Thump,2007,2`,Eq=`[ "year": 2007, "label": "XL Recordings" } -]`,hR="csvjson-theme";function Aq(){try{const t=localStorage.getItem(hR);return t==="dark"||t==="light"?t:null}catch{return null}}function Mq(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function Rq(){return Aq()??Mq()}function Oq(t){try{localStorage.setItem(hR,t)}catch{}}function Pq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const VS=2*1024*1024,Iq=150,Nq=1e3,Dq=2e3,_q=2e3;function Lq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function US(t){try{return JSON.parse(t),!0}catch{return!1}}function Fq(){var De;const[t,e]=v.useState(Rq);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(q=>{const Ae=q==="dark"?"light":"dark";return Oq(Ae),Ae}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":Pq(window.location.search)),[s,o]=v.useState(()=>Ho("")),l=s.present,[a,u]=v.useState(Ir),[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"),[C,T]=v.useState(Iw),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=RI({settleMs:Dq,minWindowMs:_q,isValid:(q,Ae)=>{const $e=A.current;return Ae===$e.input?$e.resultOk:Xs(q==="csv_to_json"?"csv2json":"json2csv",Ae,$e.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=eR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",Y=I?"JSON":"CSV",ie=l.trim()==="",se=l.length>VS?Nq:Iq,V=iq(l,ie?0:se),J=v.useRef(null),R=v.useRef(null),L=l!==""&&((De=J.current)==null?void 0:De.text)===l?l:V,z=v.useMemo(()=>typeof window>"u"?null:dq(window.location.pathname),[]),j=mq(z),B=v.useMemo(()=>Xs(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const q=R.current;!q||q.text!==L||(R.current=null,O.discrete(q.direction,q.via,q.text))},[L,B,O]);const[oe,fe]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&B.ok&&fe(B.text)},[B,L]),v.useEffect(()=>{L.trim()!==""&&(!B.ok||B.rows<=0&&B.cols<=0||T(LS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const me=L.trim()!==""&&B.ok?B.text:oe,[ze,Fe]=v.useState(!1),[nt,Et]=v.useState(null),rt=ze?nt:me,it=v.useMemo(()=>{if(!I||rt===null||c==="json")return rt;const q=ze&&nt!==null&&US(nt)?nt:me;return q===null?null:MG(q,c,a,p)},[I,rt,c,ze,nt,me,a,p]),lt=I&&c==="json"&&!ie&&it!==null&&(ze||B.ok),_t=v.useCallback(q=>{if(q===me){Fe(!1),Et(null);return}Fe(!0),Et(q)},[me]),Ne=v.useCallback(()=>{const q=Xs(r,l,a);q.ok&&fe(q.text),Fe(!1),Et(null)},[r,l,a]),xe=v.useCallback(q=>{o(Ae=>I?Wb(Ae,q):Ho(q))},[I]),_e=I&&s.past.length>0,Ye=I&&s.future.length>0,Ke=v.useCallback(()=>{if(!I||s.past.length===0)return;const q=v9(s);w(null),o(q),O.edit("csv_to_json",q.present)},[I,s,O]),Ue=v.useCallback(()=>{if(!I||s.future.length===0)return;const q=w9(s);w(null),o(q),O.edit("csv_to_json",q.present)},[I,s,O]),ht=v.useCallback(q=>{w(null),J.current=null,i(q.direction),u({...q.options}),m(q.filename),Fe(!1),Et(null),o(Ae=>q.direction==="csv2json"&&r==="csv2json"?Wb(Ae,q.input):Ho(q.input)),T(LS({direction:q.direction,input:q.input,options:q.options,filename:q.filename,rows:q.rows,cols:q.cols}))},[r]),vt=v.useCallback(q=>{T(FG(q))},[]),at=v.useCallback(()=>{$G(),T([])},[]),he=()=>{const q=r==="csv2json"?"json2csv":"csv2json";if(ze){const Ae=nt??"",$e=US(Ae)?Ae:l;o(Ho($e)),i(q),Fe(!1),Et(null),$e.trim()!==""&&(A.current={direction:q,options:a,input:$e,resultOk:Xs(q,$e,a).ok},O.discrete(q==="csv2json"?"csv_to_json":"json_to_csv","flip",$e));return}if(i(q),ie)o(Ho(""));else{const Ae=Xs(r,l,a),$e=Ae.ok?Ae.text:l;o(Ho($e)),$e.trim()!==""&&(A.current={direction:q,options:a,input:$e,resultOk:Xs(q,$e,a).ok},O.discrete(q==="csv2json"?"csv_to_json":"json_to_csv","flip",$e))}},Be=j.hydrated;v.useEffect(()=>{if(Be===null)return;const q={...A.current.options,...Be.options};A.current={direction:Be.direction,options:q,input:Be.input,resultOk:Xs(Be.direction,Be.input,q).ok},i(Be.direction),o(Ho(Be.input)),u(Ae=>({...Ae,...Be.options})),Fe(!1),Et(null),wI(),O.discrete(Be.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Be.input)},[Be,O]);const ut=async(q,Ae)=>{if(!pG(q)){w(`Can't read "${q.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const $e=await RS(q,k);J.current={file:q,source:Ae,text:$e},R.current={direction:I?"csv_to_json":"json_to_csv",via:Ae==="drop"?"drag":"file",text:$e},xe($e),m(q.name),g(!1)}catch{g(!1),w(`Couldn't read "${q.name}".`)}},tt=async q=>{const Ae=k;b(q);const $e=J.current;if(!(!$e||l!==$e.text)){g(!0);try{const qt=await RS($e.file,q);J.current={...$e,text:qt},R.current={direction:I?"csv_to_json":"json_to_csv",via:$e.source==="drop"?"drag":"file",text:qt},o(We=>({...We,present:qt})),g(!1)}catch{g(!1),b(Ae),w(`Couldn't read "${$e.file.name}".`)}}},Vt=v.useCallback(q=>{w(null),xe(q),O.edit(I?"csv_to_json":"json_to_csv",q)},[xe,I,O]);v.useEffect(()=>{const q=Ae=>{var qt;const $e=(qt=Ae.clipboardData)==null?void 0:qt.getData("text/plain");!$e||Cq(Ae.target)||(Ae.preventDefault(),Ae.stopPropagation(),m(null),Vt($e))};return document.addEventListener("paste",q,!0),()=>document.removeEventListener("paste",q,!0)},[Vt]);const ft=B.ok?Lq(B.rows,B.cols):null,dt=!B.ok&&oe?"Last valid result — input has errors":null,wt=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Ut=l.length>VS,Mt=I?"csv_to_json":"json_to_csv",Rn=I?c:"csv",$n=()=>{Bo({via:"copy",format:I?"csv":"json",pane:"input",direction:Mt}),HS(l)},W=()=>{Bo({via:"copy",format:Rn,pane:"output",direction:Mt}),it&&HS(it)},ye=()=>{Bo({via:"download",format:I?"csv":"json",pane:"input",direction:Mt}),WS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},re=()=>{Bo({via:"download",format:Rn,pane:"output",direction:Mt}),WS(it??"",kq(p,I?"csv2json":"json2csv",c),{mime:Sq(I?"csv2json":"json2csv",c),bom:!I})},we=v.useCallback(()=>{Bo({via:"copy",format:"csv",pane:"input",direction:Mt})},[Mt]),pe=v.useCallback(()=>{Bo({via:"copy",format:"csv",pane:"output",direction:Mt})},[Mt]),Le=v.useCallback(()=>{Bo({via:"copy",format:Rn,pane:"output",direction:Mt})},[Rn,Mt]),de=E.jsx(dG,{format:D,input:l,onInputChange:Vt,onCellCommit:Vt,onFile:ut,onTryExample:()=>{w(null);const q=I?Tq:Eq;A.current={direction:r,options:a,input:q,resultOk:Xs(r,q,a).ok},xe(q),O.discrete(Mt,"example",q)},onClear:()=>{xe(""),m(null),Fe(!1),Et(null),O.cancel()},onCopy:$n,onCopySelection:we,onDownload:ye,canUndo:_e,canRedo:Ye,onUndo:Ke,onRedo:Ue,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(q=>({...q,collapseIndexedArrays:!(q.collapseIndexedArrays??!0)})),filename:p,reading:x,meta:ft,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),Re=E.jsx(PG,{format:Y,inputEmpty:ie,outputText:it,error:B.ok?null:B.error,meta:ft,staleNotice:dt,warnings:wt,edited:ze,editable:lt,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:W,onCopySelection:pe,onNativeCopy:Le,onDownload:re,onEgressFormatChange:f,onOutputChange:_t,onRevert:Ne,onDiscardReconvert:Ne});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(tD,{}),E.jsx(UG,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(HG,{snapshots:C,onSelect:ht,onRemove:vt,onClear:at}),E.jsx(rq,{}),E.jsx(oD,{})]})}),z&&(j.phase==="loading"||j.phase==="not-found"||j.phase==="unsupported"||j.phase==="error")?E.jsx(IG,{phase:j.phase,message:j.phase==="error"?j.message:void 0,onRetry:j.retry}):null,E.jsx(WG,{layout:P,split:d,onSplitChange:h,left:de,right:Re,children:E.jsx(QN,{direction:r,onFlip:he})}),E.jsx(yG,{direction:r,options:a,onChange:q=>u(Ae=>({...Ae,...q})),uploadEncoding:k,onUploadEncodingChange:tt,notice:Ut?"Large file — converting on pause":null})]}),E.jsx(ZN,{})]})}iT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(Fq,{})}));document.getElementById("root").removeAttribute("inert");yI();vI();export{qW as C,Nn as R,x$ as T,sa as a,K3 as b,gI as c,Vl as i,w$ as m,v as r,Vr as s}; +]`,mR="csvjson-theme";function Nq(){try{const t=localStorage.getItem(mR);return t==="dark"||t==="light"?t:null}catch{return null}}function Dq(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function _q(){return Nq()??Dq()}function Lq(t){try{localStorage.setItem(mR,t)}catch{}}function Fq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const XS=2*1024*1024,$q=150,zq=1e3,Bq=2e3,jq=2e3;function Hq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function GS(t){try{return JSON.parse(t),!0}catch{return!1}}function Wq(){var Ge;const[t,e]=v.useState(_q);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(W=>{const me=W==="dark"?"light":"dark";return Lq(me),me}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":Fq(window.location.search)),[s,o]=v.useState(()=>Ho("")),l=s.present,[a,u]=v.useState(Ir),[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"),[C,T]=v.useState(_w),E=v.useRef({direction:r,options:a,input:l,resultOk:!0}),R=v.useRef(null);R.current||(R.current=II({settleMs:Bq,minWindowMs:jq,isValid:(W,me)=>{const ge=E.current;return me===ge.input?ge.resultOk:Xs(W==="csv_to_json"?"csv2json":"json2csv",me,ge.options).ok}}));const O=R.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=rR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",Y=I?"JSON":"CSV",oe=l.trim()==="",le=l.length>XS?zq:$q,V=cq(l,oe?0:le),Z=v.useRef(null),M=v.useRef(null),L=l!==""&&((Ge=Z.current)==null?void 0:Ge.text)===l?l:V,B=v.useMemo(()=>typeof window>"u"?null:vq(window.location.pathname),[]),j=kq(B),$=v.useMemo(()=>Xs(r,L,a),[r,L,a]);E.current={direction:r,options:a,input:L,resultOk:$.ok},v.useEffect(()=>{const W=M.current;!W||W.text!==L||(M.current=null,O.discrete(W.direction,W.via,W.text))},[L,$,O]);const[ae,he]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&$.ok&&he($.text)},[$,L]),v.useEffect(()=>{L.trim()!==""&&(!$.ok||$.rows<=0&&$.cols<=0||T(zS({direction:r,input:L,options:a,filename:p,rows:$.rows,cols:$.cols})))},[r,L,p,a,$]);const ve=L.trim()!==""&&$.ok?$.text:ae,[Fe,De]=v.useState(!1),[Ze,Tt]=v.useState(null),et=Fe?Ze:ve,nt=v.useMemo(()=>{if(!I||et===null||c==="json")return et;const W=Fe&&Ze!==null&&GS(Ze)?Ze:ve;return W===null?null:DG(W,c,a,p)},[I,et,c,Fe,Ze,ve,a,p]),st=I&&c==="json"&&!oe&&nt!==null&&(Fe||$.ok),_t=v.useCallback(W=>{if(W===ve){De(!1),Tt(null);return}De(!0),Tt(W)},[ve]),Ie=v.useCallback(()=>{const W=Xs(r,l,a);W.ok&&he(W.text),De(!1),Tt(null)},[r,l,a]),xe=v.useCallback(W=>{o(me=>I?Kb(me,W):Ho(W))},[I]),Ne=I&&s.past.length>0,Ke=I&&s.future.length>0,He=v.useCallback(()=>{if(!I||s.past.length===0)return;const W=b9(s);w(null),o(W),O.edit("csv_to_json",W.present)},[I,s,O]),Be=v.useCallback(()=>{if(!I||s.future.length===0)return;const W=k9(s);w(null),o(W),O.edit("csv_to_json",W.present)},[I,s,O]),Ct=v.useCallback(W=>{w(null),Z.current=null,i(W.direction),u({...W.options}),m(W.filename),De(!1),Tt(null),o(me=>W.direction==="csv2json"&&r==="csv2json"?Kb(me,W.input):Ho(W.input)),T(zS({direction:W.direction,input:W.input,options:W.options,filename:W.filename,rows:W.rows,cols:W.cols}))},[r]),ot=v.useCallback(W=>{T(WG(W))},[]),mt=v.useCallback(()=>{VG(),T([])},[]),pe=()=>{const W=r==="csv2json"?"json2csv":"csv2json";if(Fe){const me=Ze??"",ge=GS(me)?me:l;o(Ho(ge)),i(W),De(!1),Tt(null),ge.trim()!==""&&(E.current={direction:W,options:a,input:ge,resultOk:Xs(W,ge,a).ok},O.discrete(W==="csv2json"?"csv_to_json":"json_to_csv","flip",ge));return}if(i(W),oe)o(Ho(""));else{const me=Xs(r,l,a),ge=me.ok?me.text:l;o(Ho(ge)),ge.trim()!==""&&(E.current={direction:W,options:a,input:ge,resultOk:Xs(W,ge,a).ok},O.discrete(W==="csv2json"?"csv_to_json":"json_to_csv","flip",ge))}},_e=j.hydrated;v.useEffect(()=>{if(_e===null)return;const W={...E.current.options,..._e.options};E.current={direction:_e.direction,options:W,input:_e.input,resultOk:Xs(_e.direction,_e.input,W).ok},i(_e.direction),o(Ho(_e.input)),u(me=>({...me,..._e.options})),De(!1),Tt(null),kI(),O.discrete(_e.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",_e.input)},[_e,O]);const tt=async(W,me)=>{if(!xG(W)){w(`Can't read "${W.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const ge=await IS(W,k);Z.current={file:W,source:me,text:ge},M.current={direction:I?"csv_to_json":"json_to_csv",via:me==="drop"?"drag":"file",text:ge},xe(ge),m(W.name),g(!1)}catch{g(!1),w(`Couldn't read "${W.name}".`)}},Xe=async W=>{const me=k;b(W);const ge=Z.current;if(!(!ge||l!==ge.text)){g(!0);try{const lt=await IS(ge.file,W);Z.current={...ge,text:lt},M.current={direction:I?"csv_to_json":"json_to_csv",via:ge.source==="drop"?"drag":"file",text:lt},o(Le=>({...Le,present:lt})),g(!1)}catch{g(!1),b(me),w(`Couldn't read "${ge.file.name}".`)}}},Ut=v.useCallback(W=>{w(null),xe(W),O.edit(I?"csv_to_json":"json_to_csv",W)},[xe,I,O]);v.useEffect(()=>{const W=me=>{var lt;const ge=(lt=me.clipboardData)==null?void 0:lt.getData("text/plain");!ge||Oq(me.target)||(me.preventDefault(),me.stopPropagation(),m(null),Ut(ge))};return document.addEventListener("paste",W,!0),()=>document.removeEventListener("paste",W,!0)},[Ut]);const ft=$.ok?Hq($.rows,$.cols):null,ct=!$.ok&&ae?"Last valid result — input has errors":null,yt=$.ok&&$.warnings&&$.warnings.length>0?$.warnings:null,zt=l.length>XS,Mt=I?"csv_to_json":"json_to_csv",Mn=I?c:"csv",zn=()=>{zo({via:"copy",format:I?"csv":"json",pane:"input",direction:Mt}),US(l)},Wt=()=>{zo({via:"copy",format:Mn,pane:"output",direction:Mt}),nt&&US(nt)},Rn=()=>{zo({via:"download",format:I?"csv":"json",pane:"input",direction:Mt}),KS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},On=()=>{zo({via:"download",format:Mn,pane:"output",direction:Mt}),KS(nt??"",Mq(p,I?"csv2json":"json2csv",c),{mime:Rq(I?"csv2json":"json2csv",c),bom:!I})},G=v.useCallback(()=>{zo({via:"copy",format:"csv",pane:"input",direction:Mt})},[Mt]),be=v.useCallback(()=>{zo({via:"copy",format:"csv",pane:"output",direction:Mt})},[Mt]),J=v.useCallback(()=>{zo({via:"copy",format:Mn,pane:"output",direction:Mt})},[Mn,Mt]),ie=A.jsx(vG,{format:D,input:l,onInputChange:Ut,onCellCommit:Ut,onFile:tt,onTryExample:()=>{w(null);const W=I?Pq:Iq;E.current={direction:r,options:a,input:W,resultOk:Xs(r,W,a).ok},xe(W),O.discrete(Mt,"example",W)},onClear:()=>{xe(""),m(null),De(!1),Tt(null),O.cancel()},onCopy:zn,onCopySelection:G,onDownload:Rn,canUndo:Ne,canRedo:Ke,onUndo:He,onRedo:Be,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(W=>({...W,collapseIndexedArrays:!(W.collapseIndexedArrays??!0)})),filename:p,reading:x,meta:ft,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),ne=A.jsx(FG,{format:Y,inputEmpty:oe,outputText:nt,error:$.ok?null:$.error,meta:ft,staleNotice:ct,warnings:yt,edited:Fe,editable:st,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Wt,onCopySelection:be,onNativeCopy:J,onDownload:On,onEgressFormatChange:f,onOutputChange:_t,onRevert:Ie,onDiscardReconvert:Ie});return A.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[A.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),A.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[A.jsx(iD,{}),A.jsx(QG,{theme:t,onToggleTheme:n,slot:A.jsxs("div",{className:"flex items-center gap-1",children:[A.jsx(GG,{snapshots:C,onSelect:Ct,onRemove:ot,onClear:mt}),A.jsx(uq,{}),A.jsx(uD,{})]})}),B&&(j.phase==="loading"||j.phase==="not-found"||j.phase==="unsupported"||j.phase==="error")?A.jsx($G,{phase:j.phase,message:j.phase==="error"?j.message:void 0,onRetry:j.retry}):null,A.jsx(qG,{layout:P,split:d,onSplitChange:h,left:ie,right:ne,children:A.jsx(eD,{direction:r,onFlip:pe})}),A.jsx(SG,{direction:r,options:a,onChange:W=>u(me=>({...me,...W})),uploadEncoding:k,onUploadEncodingChange:Xe,notice:zt?"Large file — converting on pause":null})]}),A.jsx(nD,{})]})}lT(document.getElementById("root")).render(A.jsx(v.StrictMode,{children:A.jsx(Wq,{})}));document.getElementById("root").removeAttribute("inert");xI();bI();export{JW as C,Nn as R,S$ as T,oa as a,q3 as b,vI as c,Ul as i,k$ as m,v as r,Vr as s}; diff --git a/app/dist/assets/number-overlay-editor-_d0W8y81.js b/app/dist/assets/number-overlay-editor-ClJRXvW2.js similarity index 99% rename from app/dist/assets/number-overlay-editor-_d0W8y81.js rename to app/dist/assets/number-overlay-editor-ClJRXvW2.js index 8d67f6d..e909636 100644 --- a/app/dist/assets/number-overlay-editor-_d0W8y81.js +++ b/app/dist/assets/number-overlay-editor-ClJRXvW2.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-D0wq-_gy.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/changelog/entries.ts b/app/src/changelog/entries.ts index a80d5cc..21c597a 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: 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", diff --git a/app/src/components/CsvTable.test.tsx b/app/src/components/CsvTable.test.tsx index 7e71704..180e4a7 100644 --- a/app/src/components/CsvTable.test.tsx +++ b/app/src/components/CsvTable.test.tsx @@ -744,3 +744,61 @@ describe("CsvTable double-click header rename (input table only)", () => { }); }); +describe("CsvTable selection aggregates", () => { + it("shows selection stats and enables Copy as CSV for a multi-cell range selection", async () => { + const user = userEvent.setup(); + const writeText = stubClipboard(); + render(); + + // 1x2 range in album column (rows 0-1: De Stijl, Elephant) + await user.click(screen.getByTestId("glide-select-range")); + + expect(screen.getByTestId("csv-table-selected-count")).toHaveTextContent("2 cells selected"); + expect(screen.getByTestId("csv-table-selection-stats")).toHaveTextContent( + "Cells: 2 · Distinct: 2" + ); + expect(screen.getByTestId("csv-table-selection-stats")).not.toHaveTextContent("Empty:"); + expect(screen.getByTestId("csv-table-selection-stats")).not.toHaveTextContent("Sum:"); + + await user.click(screen.getByTestId("csv-table-copy")); + await waitFor(() => expect(writeText).toHaveBeenCalledTimes(1)); + expect(writeText).toHaveBeenCalledWith("album\nDe Stijl\nElephant"); + + await user.click(screen.getByTestId("csv-table-clear-selection")); + expect(screen.queryByTestId("csv-table-selection-stats")).toBeNull(); + }); + + it("displays Empty and formatted numeric Sum, Avg, Min, Max for rectangular ranges, rows, and columns", async () => { + const user = userEvent.setup(); + const csvWithBlanksAndNumbers = [ + "album,sales", + "De Stijl,1250.5", + "Elephant,", + "De Stijl,-250.25", + "Get Behind Me Satan,500", + ].join("\n"); + render(); + + // 2x3 rectangular range: rows 0..2, cols 0..1 (6 cells: 3 albums with 2 distinct, 2 numeric sales + 1 empty) + await user.click(screen.getByTestId("glide-select-rect-range")); + expect(screen.getByTestId("csv-table-selection-stats")).toHaveTextContent( + "Cells: 6 · Distinct: 4 · Empty: 1 · Sum: 1,000.25 · Avg: 500.125 · Min: -250.25 · Max: 1,250.5" + ); + + // Select the numeric column (grid col 2 = sales): 4 cells, 1 empty, 3 numeric (1250.5, -250.25, 500 -> sum 1500.25, avg 500.0833) + await user.click(screen.getByTestId("glide-select-column-2")); + expect(screen.getByTestId("csv-table-selection-stats")).toHaveTextContent( + "Cells: 4 · Distinct: 3 · Empty: 1 · Sum: 1,500.25 · Avg: 500.0833 · Min: -250.25 · Max: 1,250.5" + ); + }); + + it("hides selection stats when only a single cell is selected without a row or column selection", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-select-single-cell")); + expect(screen.queryByTestId("csv-table-selection-stats")).toBeNull(); + expect(screen.queryByTestId("csv-table-selected-count")).toBeNull(); + }); +}); + + diff --git a/app/src/components/CsvTable.tsx b/app/src/components/CsvTable.tsx index 2c3af2f..9c07955 100644 --- a/app/src/components/CsvTable.tsx +++ b/app/src/components/CsvTable.tsx @@ -22,7 +22,12 @@ import { numericColumns, parseCsvRecord, parseCsvTable, serializeCsvRow } from " import { deleteColumns, deleteRows, renameHeader } from "@/lib/tableDeletion"; import { matchHistoryShortcut } from "@/lib/csvHistory"; import { filterRowIndices, sortRowIndices, type SortDir } from "@/lib/tableView"; -import { serializeGridSelection } from "@/lib/tableSelection"; +import { + computeSelectionStats, + serializeGridSelection, + type SelectionShape, + type SelectionStats, +} from "@/lib/tableSelection"; /** * Dense full-bleed CSV/TSV table (spec: CSV pane — sticky header, compact @@ -111,6 +116,37 @@ type GutterClickEvent = { shiftKey?: boolean; metaKey?: boolean; ctrlKey?: boole const TOOLBAR_BUTTON = "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"; +const STAT_NUMBER_FORMATTER = new Intl.NumberFormat("en-US", { maximumFractionDigits: 4 }); + +function formatStatNumber(value: number): string { + return STAT_NUMBER_FORMATTER.format(Object.is(value, -0) ? 0 : value); +} + +function formatSelectionStatsLabel(stats: SelectionStats): string { + const parts = [ + `Cells: ${STAT_NUMBER_FORMATTER.format(stats.cellCount)}`, + `Distinct: ${STAT_NUMBER_FORMATTER.format(stats.distinctCount)}`, + ]; + if (stats.emptyCount > 0) { + parts.push(`Empty: ${STAT_NUMBER_FORMATTER.format(stats.emptyCount)}`); + } + if ( + stats.numericCount > 0 && + stats.sum !== null && + stats.avg !== null && + stats.min !== null && + stats.max !== null + ) { + parts.push( + `Sum: ${formatStatNumber(stats.sum)}`, + `Avg: ${formatStatNumber(stats.avg)}`, + `Min: ${formatStatNumber(stats.min)}`, + `Max: ${formatStatNumber(stats.max)}` + ); + } + return parts.join(" · "); +} + /** Canvas has no CSS variables — resolve the palette per theme explicitly. * * Selected-header contract (contrast fix, 2026-09-08): Glide pre-fills a @@ -481,7 +517,31 @@ export function CsvTable({ [gridSelection] ); const selectedColumnCount = selectedDataColumns.length; - const showSelectionChip = selectedInView.length > 0 || selectedColumnCount > 0; + const selection = useMemo( + () => ({ + ranges: gridSelection?.current + ? [gridSelection.current.range, ...gridSelection.current.rangeStack] + : [], + columns: gridSelection ? [...gridSelection.columns] : [], + rows: + selectedSources.size > 0 + ? view.reduce((acc, source, viewRow) => { + if (selectedSources.has(source)) acc.push(viewRow); + return acc; + }, []) + : gridSelection + ? [...gridSelection.rows] + : [], + }), + [gridSelection, selectedSources, view] + ); + const gutterColumns = GUTTER_COLUMNS; + const selectionStats = useMemo( + () => computeSelectionStats(table, view, selection, gutterColumns), + [table, view, selection, gutterColumns] + ); + const showSelectionChip = + selectedInView.length > 0 || selectedColumnCount > 0 || selectionStats !== null; const onCopySelectionRef = useRef(onCopySelection); onCopySelectionRef.current = onCopySelection; @@ -936,10 +996,20 @@ export function CsvTable({ > {selectedInView.length > 0 ? `${selectedInView.length.toLocaleString()} selected` - : `${selectedColumnCount.toLocaleString()} ${ - selectedColumnCount === 1 ? "column" : "columns" - } selected`} + : selectedColumnCount > 0 + ? `${selectedColumnCount.toLocaleString()} ${ + selectedColumnCount === 1 ? "column" : "columns" + } selected` + : `${(selectionStats?.cellCount ?? 0).toLocaleString()} cells selected`} + {selectionStats !== null && ( + + {formatSelectionStatsLabel(selectionStats)} + + )}