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

    ${e}

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

    An error occurred:

    "+nr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function QT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=Y4(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(X4(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&et.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;et.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(et.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&et.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function et(t,e,n){return QT(Mo.lex,Jc.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},D4(et.defaults),et};et.getDefaults=UT;et.defaults=Ml;et.use=function(...t){const e=et.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=et.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=et.defaults.renderer||new Qv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=et.defaults.tokenizer||new Yv;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=et.defaults.hooks||new bh;for(const s in n.hooks){const o=i[s];bh.passThroughHooks.has(s)?i[s]=l=>{if(et.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=et.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}et.setOptions(r)})};et.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(et,r)),r.type){case"table":{for(const i of r.header)n=n.concat(et.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(et.walkTokens(s.tokens,e));break}case"list":{n=n.concat(et.walkTokens(r.items,e));break}default:et.defaults.extensions&&et.defaults.extensions.childTokens&&et.defaults.extensions.childTokens[r.type]?et.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(et.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(et.walkTokens(r.tokens,e)))}return n};et.parseInline=QT(Mo.lexInline,Jc.parseInline);et.Parser=Jc;et.parser=Jc.parse;et.Renderer=Qv;et.TextRenderer=qT;et.Lexer=Mo;et.lexer=Mo.lex;et.Tokenizer=Yv;et.Slugger=YT;et.Hooks=bh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;Jc.parse;Mo.lex;const Q4=Qr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class J4 extends Ln.PureComponent{constructor(){super(...arguments);bt(this,"targetElement",null);bt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Ln.createElement(Q4,{ref:this.containerRefHook})}}const Z4=Qr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),e$=Qr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),t$=Qr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let qx=0;const Cp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=v.useRef(null),f=n??"";Wr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=v.useState(()=>"input-box-"+(qx=(qx+1)%1e7));v.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),v.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const h=v.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return v.createElement(t$,{className:"gdg-growing-entry"},v.createElement(e$,{className:u},f+` +`),v.createElement(Z4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Vg={};let Qs=null;function n$(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function N0(t){const e=t.toLowerCase().trim();if(Vg[e]!==void 0)return Vg[e];Qs=Qs||n$(),Qs.style.color="#000",Qs.style.color=e;const n=getComputedStyle(Qs).color;Qs.style.color="#fff",Qs.style.color=e;const r=getComputedStyle(Qs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Vg[e]=i,i}function wl(t,e){const[n,r,i]=N0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Yx=new Map;function Qx(t,e){const n=`${t}-${e}`,r=Yx.get(n);if(r!==void 0)return r;const i=Vr(t,e);return Yx.set(n,i),i}function Vr(t,e){if(e===void 0)return t;const[n,r,i,s]=N0(t);if(s===1)return t;const[o,l,a,u]=N0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var Yl=new Map,fa=new Map,D0=new Map;function r$(){Yl.clear(),D0.clear(),fa.clear()}function i$(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,m=c*p*r/d,x=h+m;n.set(f,x)}}function s$(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function tc(t,e,n,r){var i,s;let o=fa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=D0.get(n);if(u===void 0&&(u=s$(t,o.size),D0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return i$(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),fa.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)fa.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;fa.set(n,{count:o.count+e.length,size:f})}return l.width}function o$(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=tc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function l$(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Yl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` +`),c=fa.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let x=o$(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),Yl.set(o,a),Yl.size>500&&Yl.delete(Yl.keys().next().value),a}function a$(t,e){return Ln.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function JT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function f$(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&Jx(t,e,s)&&i++;for(const o of n.current.rangeStack)Jx(t,e,o)&&i++;return i}function eE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function La(t,e){let n=0;const r=eE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let m=l;m"u";async function g$(){var t;p$||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,Dd=0,rc={},r$())}g$();function tE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function Zc(t,e,n,r="middle"){const i=tE(t,e,r,n);let s=rc[i];return s===void 0&&(s=e.measureText(t),rc[i]=s,Dd++),Dd>1e4&&(rc={},Dd=0),s}function m$(t,e){const n=tE(t,void 0,"middle",e);return rc[n]}function Bs(t,e){return typeof e!="string"&&(e=e.baseFontFull),y$(t,e)}function Zx(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const eb=[];function y$(t,e){for(const s of eb)if(s.key===e)return s.val;const n=Zx(t,"alphabetic"),i=-(Zx(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return eb.push({key:e,val:i}),i}function v$(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function x$(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=l$(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=rE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let g=Math.max(r+l.cellVerticalPadding,x);for(const y of f)if(nE(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function As(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=w$(e,c));const d=Bs(s,l),h=qv(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?x$(s,e,a,u,c,f,d,l,n,i):nE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function cs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function b$(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function k$(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),m=1,x=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const g=p/2;let y=Math.abs(Math.cos(g)*i/Math.sin(g)),w;y>Math.min(c.len/2,f.len/2)?(y=Math.min(c.len/2,f.len/2),w=Math.abs(y*Math.sin(g)/Math.cos(g))):w=i;let k=a.x+f.nx*y,b=a.y+f.ny*y;k+=-f.ny*w*m,b+=f.nx*w*m,t.arc(k,b,w,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function L0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const m={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const g=o>t?-1:1,y=La(h);m.x+=y+a;for(let w=o;w!==t;w+=g)m.x+=h[g===1?w:w-1].width*g}else for(let g=0;g0&&Oc(h[g-1].group,y)&&h[g-1].sticky===w;){const b=h[g-1];m.x-=b.width,m.width+=b.width,g--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-d){let g=c-e;for(m.y=r;g>0;){const y=e+g-1;m.height=typeof p=="number"?p:p(y),m.y-=m.height,g--}m.height+=1}else{const g=l>e?-1:1;if(typeof p=="number"){const y=e-l;m.y+=y*p}else for(let y=l;y!==e;y+=g)m.y+=p(y)*g;m.height=(typeof p=="number"?p:p(e))+1}return m}const Jv=1<<21;function Pi(t,e){return(e+2)*Jv+t}function iE(t){return t%Jv}function Zv(t){return Math.floor(t/Jv)-2}function ew(t){const e=iE(t),n=Zv(t);return[e,n]}class sE{constructor(){bt(this,"visibleWindow",{x:0,y:0,width:0,height:0});bt(this,"freezeCols",0);bt(this,"freezeRows",[]);bt(this,"isInWindow",e=>{const n=iE(e),r=Zv(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&_a(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class S$ extends sE{constructor(){super(...arguments);bt(this,"cache",new Map);bt(this,"setValue",(n,r)=>{this.cache.set(Pi(n[0],n[1]),r)});bt(this,"getValue",n=>this.cache.get(Pi(n[0],n[1])));bt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class ic{constructor(e=[]){bt(this,"cells");this.cells=new Set(e.map(n=>Pi(n[0],n[1])))}add(e){this.cells.add(Pi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Pi(e[0],e[1]))}remove(e){this.cells.delete(Pi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(Zv(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=E$(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function A$(t,e,n,r,i,s,o,l,a){const u=v.useRef(e),c=v.useRef(n),f=v.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=v.useMemo(()=>{if(typeof window>"u")return[null,null];const y=document.createElement("canvas");return y.style.display="none",y.style.opacity="0",y.style.position="fixed",[y,y.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=v.useRef({}),m=v.useRef(),[x,g]=v.useState();return v.useLayoutEffect(()=>{const y=c.current;if(y===void 0||t.every(Wf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,w)},S={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=y(b,a.signal),M=k>0?y(S,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Rx(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Rx(M)]),m.current=t,g(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Wf)?t:h===null?t.map(T=>Wf(T)?T:{...T,width:F0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Wf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:F0};const M=aE(h,o,T,A,x,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,b=0;const S=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(b+=A.grow,S.push(T));if(k0){const T=[...w],A=r-k;let M=A;for(let O=0;O0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=R$(a),a in tb)return;tb[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":M$,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function O$(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var P$=O$,I$=P$,Ug=Xv;function N$(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Ug(n),n=n===n?n:0),e!==void 0&&(e=Ug(e),e=e===e?e:0),I$(Ug(t),e,n)}var D$=N$;const Oi=Bi(D$);var _$="__lodash_hash_undefined__";function L$(t){return this.__data__.set(t,_$),this}var F$=L$;function $$(t){return this.__data__.has(t)}var z$=$$,B$=$v,j$=F$,H$=z$;function kh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new B$;++e-1}var nz=tz;function rz(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=Sz){var u=e?null:bz(t);if(u)return kz(u);o=!1,i=xz,a=new yz}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?pE(l,e-1,n,r,i):_z(i,l):r||(i[i.length]=l)}return i}var Fz=pE,$z=Fz;function zz(t){var e=t==null?0:t.length;return e?$z(t,1):[]}var Bz=zz;const ib=Bi(Bz);var jz=Math.ceil,Hz=Math.max;function Wz(t,e,n,r){for(var i=-1,s=Hz(jz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var Vz=Wz,Uz=TT,Kz=Hv;function Xz(t){return t!=null&&Kz(t.length)&&!Uz(t)}var nw=Xz,Gz=Lv,qz=nw,Yz=jv,Qz=El;function Jz(t,e,n){if(!Qz(n))return!1;var r=typeof e;return(r=="number"?qz(n)&&Yz(e,n.length):r=="string"&&e in n)?Gz(n[e],t):!1}var Zz=Jz,eB=Xv,sb=1/0,tB=17976931348623157e292;function nB(t){if(!t)return t===0?t:0;if(t=eB(t),t===sb||t===-sb){var e=t<0?-1:1;return e*tB}return t===t?t:0}var rB=nB,iB=Vz,sB=Zz,Xg=rB;function oB(t){return function(e,n,r){return r&&typeof r!="number"&&sB(e,n,r)&&(n=r=void 0),e=Xg(e),n===void 0?(n=e,e=0):n=Xg(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function gE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Tp(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=h;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=h;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function hB(t,e,n,r){if(r==="any")return vE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),JT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Sh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Ep(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function vE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function pB(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function gB(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:m-p}}function mB(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:m,height:x}=t,g=[];if(m<=0||x<=0)return g;const y=h+m,w=p+x,k=hl,T=p+x>a,A=h>=s&&hs&&y<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const _=Math.max(h,s),P=Math.max(p,o),I=Math.min(y,l),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&b){const _=h,P=p,I=Math.min(y,s),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&A){const _=Math.max(h,s),P=p,I=Math.min(y,l),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&S){const _=Math.max(h,l),P=p,I=y,D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const _=h,P=Math.max(p,o),I=Math.min(y,s),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(S&&M){const _=Math.max(h,l),P=Math.max(p,o),I=y,D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const _=h,P=Math.max(p,a),I=Math.min(y,s),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const _=Math.max(h,s),P=Math.max(p,a),I=Math.min(y,l),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(S&&T){const _=Math.max(h,l),P=Math.max(p,a),I=y,D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return g}const yB={kind:ke.Loading,allowOverlay:!1};function ob(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A,M,O,_,P,I,D,Z,ne,oe,W){let U=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},H=[0,0],q=x>0?Rl(a,x,u):0;let B,V;const le=gE(y);return Lo(e,l,s,o,i,(ge,Me,Fe,_e,ft)=>{const Xe=Math.max(0,_e-Me),Ge=Me+Xe,lt=i+1,Ut=ge.width-Xe,Re=r-i-1;if(y.length>0){let wt=!1;for(let rt=0;rt{t.save(),t.beginPath(),t.rect(Ge,lt,Ut,Re),t.clip()},Qe=k.columns.hasIndex(ge.sourceIndex),nt=f(ge.group??"").overrideTheme,it=ge.themeOverride===void 0&&nt===void 0?I:To(I,nt,ge.themeOverride),$e=it.baseFontFull;$e!==N&&(N=$e,t.font=$e),we();let At;return Tp(ft,Fe,r,a,u,x,g,le,(wt,rt,me,Ne,Je)=>{var De,ze,An;if(rt<0||(H[0]=ge.sourceIndex,H[1]=rt,w!==void 0&&!w.has(H)))return;if(y.length>0){let z=!1;for(let ue=0;uedt.span!==void 0&&z>=dt.span[0]&&z<=dt.span[1]);vn&&!p&&m?In=0:vn&&m&&(In=Math.max(In,1)),Pr&&In++,vn||(tt&&In++,Qe&&!Je&&In++);const Ir=dt.kind===ke.Protected?Pt.bgCellMedium:Pt.bgCell;let Bt;if((Ne||Ir!==I.bgCell)&&(Bt=Vr(Ir,Bt)),In>0||Kt){Kt&&(Bt=Vr(Pt.bgHeader,Bt));for(let z=0;zW&&!Rt){const z=Pt.baseFontFull;z!==N&&(t.font=z,N=z),At=wE(t,dt,ge.sourceIndex,rt,xt,dn,ht,wt,pt,me,In>0,Pt,Bt??Pt.bgCell,T,A,(re==null?void 0:re.hoverAmount)??0,O,P,R,_,At,D,Z,ne,oe)}return ut&&t.restore(),dt.style==="faded"&&(t.globalAlpha=1),U--,Lt&&(t.restore(),(An=At==null?void 0:At.deprep)==null||An.call(At,L),At=void 0,we(),N=$e,t.font=$e),U<=0}),t.restore(),U<=0}),B}const Au=[0,0],Mu={x:0,y:0,width:0,height:0},Gg=[void 0,()=>{}];let $0=!1;function vB(){$0=!0}function wE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A){var Z,ne;let M,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(M=x[1][0],O=x[1][1]);let _;Au[0]=n,Au[1]=r,Mu.x=o,Mu.y=l,Mu.width=a,Mu.height=u,Gg[0]=S.getValue(Au),Gg[1]=oe=>S.setValue(Au,oe),$0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Mu,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:M,drawState:Gg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:vB},I=v$(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((Z=k==null?void 0:k.deprep)==null||Z.call(k,P),k=void 0);const oe=(ne=D.drawPrep)==null?void 0:ne.call(D,P,k);w!==void 0&&!ca(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=oe===void 0?void 0:{deprep:oe==null?void 0:oe.deprep,fillStyle:oe==null?void 0:oe.fillStyle,font:oe==null?void 0:oe.font,renderer:D}}return(I||$0)&&(b==null||b(Au)),_}function rw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let m=HT(c,o,e.cellVerticalPadding),x=m/2;const g=jT(f,r,s,e.cellHorizontalPadding,m),y=BT(g,h,m),w=WT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),cs(t,g-m/2,h-m/2,m,m,p),d==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(g-x+m/4.23,h-x+m/1.97),t.lineTo(g-x+m/2.42,h-x+m/1.44),t.lineTo(g-x+m/1.29,h-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case gh:case!1:{t.beginPath(),cs(t,g-m/2+.5,h-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case Wv:{t.beginPath(),cs(t,g-m/2,h-m/2,m,m,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(g-m/3,h),t.lineTo(g+m/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Rc()}}function wB(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,b]=(r==null?void 0:r[0])??[],S=f.headerFontFull;t.font=S,Lo(e,0,s,0,w,(T,A,M,O)=>{var L;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,O-A);t.save(),t.beginPath(),t.rect(A+_,l,T.width-_,o),t.clip();const P=m(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:To(f,P,T.themeOverride);I.bgHeader!==f.bgHeader&&(t.fillStyle=I.bgHeader,t.fill()),I!==f&&(t.font=I.baseFontFull);const D=c.columns.hasIndex(T.sourceIndex),Z=a!==void 0||u,ne=!Z&&b===-1&&k===T.sourceIndex,oe=Z?0:((L=h.find(H=>H.item[0]===T.sourceIndex&&H.item[1]===-1))==null?void 0:L.hoverAmount)??0,W=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,U=D?I.accentColor:W?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=U,t.fillRect(A+N,R,T.width-N,o)):(W||oe>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),W&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),oe>0&&(t.globalAlpha=oe,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),kE(t,A,R,T.width,o,T,D,I,ne,W,oe,d,g,y),t.restore()}),n&&xB(t,e,i,s,l,r,f,d,h,p,m,x)}function xB(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;mE(e,n,r,i,(x,g,y,w,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(y,w,k,b),t.clip();const S=c(g),T=(S==null?void 0:S.overrideTheme)===void 0?o:To(o,S.overrideTheme),A=p===-2&&h!==void 0&&h>=x[0]&&h<=x[1],M=A?T.bgHeaderHovered:T.bgHeader;if(M!==o.bgHeader&&(t.fillStyle=M,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,S!==void 0){let O=y;if(S.icon!==void 0&&(l.drawSprite(S.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(S.name,O+8,i/2+Bs(t,o.headerFontFull)),S.actions!==void 0&&A){const _=bE({x:y,y:w,width:k,height:b},S.actions);t.beginPath();const P=_[0].x-10,I=y+k-P;t.rect(P,0,I,i);const D=t.createLinearGradient(P,0,P+I,0),Z=wl(M,0);D.addColorStop(0,Z),D.addColorStop(10/I,M),D.addColorStop(1,M),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[ne,oe]=(s==null?void 0:s[1])??[-1,-1];for(let W=0;W35){const k=d?35:r-35,b=d?35*.7:r-35*.7,S=k/r,T=b/r,A=t.createLinearGradient(e,0,e+r,0),M=wl(m,0);A.addColorStop(d?1:0,m),A.addColorStop(S,m),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=m;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+Bs(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===mh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;k$(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===mh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;b$(t,w,k),t.fillStyle=m,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function kE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=qv(s.title)==="rtl",m=xE(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>lb(t,e,n,r,i,s,o,l,a,c,f,h,p,m)):lb(t,e,n,r,i,s,o,l,a,c,f,h,p,m)}var bB=Al,kB=function(){try{var t=bB(Object,"defineProperty");return t({},"",{}),t}catch{}}(),SB=kB,ab=SB;function CB(t,e,n){e=="__proto__"&&ab?ab(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var TB=CB;function EB(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Nj?new Rj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const M=Math.max(b,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Tp(A,S,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(W=>Sh(b,O,1e4,P,W.x,W.y,W.width,W.height)))return;const D=d.hasIndex(_),Z=h.hasIndex(_);t.beginPath();const ne=f==null?void 0:f(_),oe=ne===void 0?y:To(y,ne);oe.bgCell!==y.bgCell&&(t.fillStyle=oe.bgCell,t.fillRect(b,O,1e4,P)),Z&&(t.fillStyle=oe.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=oe.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function CW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?La(e):0;let h;if(d!==0&&(h=Qx(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:Qx(c,a.bgCell),m=Rl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const NE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function TW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var P;const m=p.bgCell,{minX:x,maxX:g,minY:y,maxY:w}=NE(l,s,o),k=[],b=o-Rl(h,d,u);let S=a,T=n,A=0;for(;S+i=y&&I<=w-1){const Z=c==null?void 0:c(T),ne=Z==null?void 0:Z.bgCell;ne!==void 0&&ne!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:ne})}S+=D,T0)for(let I=0;I=x&&Z<=g&&f(I+1)&&k.push({x:Z,y:A,w:D.width,h:O,color:ne}),M+=D.width}if(k.length===0)return;let _;t.beginPath();for(let I=k.length-1;I>=0;I--){const D=k[I];_===void 0?_=D.color:D.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=D.color),t.rect(D.x,D.y,D.w,D.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function Mb(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const P of a)t.rect(P.x+1,P.y+1,P.width-1,P.height-1);t.clip("evenodd")}const y=x.horizontalBorderColor??x.borderColor,w=x.borderColor,{minX:k,maxX:b,minY:S,maxY:T}=NE(l,s,o),A=[];t.beginPath();let M=.5;for(let P=0;P=k&&D<=b&&h(P+1)&&A.push({x1:D,y1:Math.max(u,S),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=S&&Z<=T-1){const ne=d==null?void 0:d(I);A.push({x1:k,y1:Z,x2:b,y2:Z,color:(ne==null?void 0:ne.horizontalBorderColor)??(ne==null?void 0:ne.borderColor)??y})}P+=f(I),I++}}const _=kW(A,P=>P.color);for(const P of Object.keys(_)){t.strokeStyle=P;for(const I of _[P])t.moveTo(I.x1,I.y1),t.lineTo(I.x2,I.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function EW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let S=0;if(typeof g=="number")S+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(S=-S),S+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let M=0;for(let D=T;Di.cellXOffset&&(M=-M),M+=l-i.translateX;const O=La(x);if(M!==0&&S!==0)return{regions:[]};const _=u>0?Rl(d,u,g):0,P=c-O-Math.abs(M),I=f-h-_-Math.abs(S)-1;if(P>150&&I>150){const D={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(S>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(S+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:S+1})):S<0&&(D.sy=(-S+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+S-_,width:c,height:-S+_})),M>0?(D.sx=O*p,D.sw=P*p,D.dx=(M+O)*p,D.dw=P*p,w.push({x:O-1,y:0,width:M+2,height:f})):M<0&&(D.sx=(O-M)*p,D.sw=P*p,D.dx=O*p,D.dw=P*p,w.push({x:c+M,y:0,width:-M,height:f})),t.setTransform(1,0,0,1,0,0),y){if(O>0&&M!==0&&S===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const Z=O*p,ne=f*p;t.drawImage(e,0,0,Z,ne,0,0,Z,ne)}if(_>0&&M===0&&S!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const Z=(f-_)*p,ne=c*p,oe=_*p;t.drawImage(e,0,Z,ne,oe,0,Z,ne,oe)}}t.drawImage(e,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function AW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Lo(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const m=Math.max(d,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function MW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const g=La(l),y=Rl(h,d,f),w=[a,0,l.length,h-d],k=[g,0,e,n-y],b=x.map(T=>{const A=T.range,M=T.style??"dashed";return mB(A,w,e,n,k).map(O=>{const _=O.rect,P=L0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:L0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return _.x+_.width>=l.length&&(I.width-=1),_.y+_.height>=h&&(I.height-=1),{color:T.color,style:M,clip:O.clip,rect:gB({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),S=()=>{t.lineWidth=1;let T=!1;for(const A of b)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Sh(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,_=!pB(M.clip,M.rect);_&&(t.save(),t.rect(M.clip.x,M.clip.y,M.clip.width,M.clip.height),t.clip()),M.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(M.style==="solid"||M.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=M.style==="solid-outline"?Vr(Vr(M.color,m.borderColor),m.bgCell):wl(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),_&&(t.restore(),T=O)}T&&t.setLineDash([])};return S(),S}function Ob(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function Qg(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x){if(c.current===void 0)return;const g=c.current.range,y=c.current.cell,w=[g.x+g.width-1,g.y+g.height-1];if(y[1]>=x&&w[1]>=x||!o.some(D=>D.sourceIndex===y[0]||D.sourceIndex===w[0]))return;const[b,S]=c.current.cell,T=d(c.current.cell),A=T.span??[b,b],M=S>=x-h,O=h>0&&!M?Rl(x,h,f)-1:0,_=w[1];let P;if(Lo(o,r,i,s,u,(D,Z,ne,oe,W)=>{if(D.sticky&&b>D.sourceIndex)return;const U=D.sourceIndexA[1],N=D.sourceIndex===w[0];if(!(!N&&(U||R)))return Tp(W,ne,n,x,f,h,p,void 0,(L,H,q)=>{if(H!==S&&H!==_)return;let B=Z,V=D.width;if(T.span!==void 0){const ge=yE(T.span,Z,L,D.width,q,D,l),Me=D.sticky?ge[0]:ge[1];Me!==void 0&&(B=Me.x,V=Me.width)}return H===_&&N&&m&&(P=()=>{var ge;oe>B&&!D.sticky&&(t.beginPath(),t.rect(oe,0,e-oe,n),t.clip()),t.beginPath(),t.rect(B+V-4,L+q-4,4,4),t.fillStyle=((ge=D.themeOverride)==null?void 0:ge.accentColor)??a.accentColor,t.fill()}),P!==void 0}),P!==void 0}),P===void 0)return;const I=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-O),t.clip(),P==null||P(),t.restore()};return I(),I}function RW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),mE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Lo(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,m=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function OW(t,e,n,r,i,s,o,l,a,u){let c=0;return Lo(t,s,r,i,n,(f,d,h,p,m)=>(Tp(m,h,e,o,l,a,u,void 0,(x,g,y,w)=>{w||(c=Math.max(g,c))}),!0)),c}function Pb(t,e){var ut;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:g,disabledRows:y,rowHeight:w,verticalBorder:k,overrideCursor:b,isResizing:S,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:Z,prelightCells:ne,drawCellCallback:oe,highlightRegions:W,resizeCol:U,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:H,hoverInfo:q,spriteManager:B,maxScaleFactor:V,hasAppendRow:le,touchMode:ge,enqueue:Me,renderStateProvider:Fe,getCellRenderer:_e,renderStrategy:ft,bufferACtx:Xe,bufferBCtx:Ge,damage:lt,minimumCellWidth:Ut}=t;if(i===0||s===0)return;const Re=ft==="double-buffer",we=Math.min(V,Math.ceil(window.devicePixelRatio??1)),Qe=ft!=="direct"&&MW(t,e),nt=n.canvas;(nt.width!==i*we||nt.height!==s*we)&&(nt.width=i*we,nt.height=s*we,nt.style.width=i+"px",nt.style.height=s+"px");const it=r.canvas,$e=f?g+x:x,At=$e+1;(it.width!==i*we||it.height!==At*we)&&(it.width=i*we,it.height=At*we,it.style.width=i+"px",it.style.height=At+"px");const wt=Xe.canvas,rt=Ge.canvas;Re&&(wt.width!==i*we||wt.height!==s*we)&&(wt.width=i*we,wt.height=s*we,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Re&&(rt.width!==i*we||rt.height!==s*we)&&(rt.width=i*we,rt.height=s*we,N.current!==void 0&&(N.current.bBufferScroll=void 0));const me=N.current;if(Qe===!0&&o===(me==null?void 0:me.cellXOffset)&&l===(me==null?void 0:me.cellYOffset)&&a===(me==null?void 0:me.translateX)&&u===(me==null?void 0:me.translateY))return;let Ne=null;Re&&(Ne=n);const Je=r;let tt;Re?lt!==void 0?tt=(me==null?void 0:me.lastBuffer)==="b"?Ge:Xe:tt=(me==null?void 0:me.lastBuffer)==="b"?Xe:Ge:tt=n;const Kt=tt.canvas,dt=Re?Kt===wt?rt:wt:nt,ht=typeof w=="number"?()=>w:w;Je.save(),tt.save(),Je.beginPath(),tt.beginPath(),Je.textBaseline="middle",tt.textBaseline="middle",we!==1&&(Je.scale(we,we),tt.scale(we,we));const pt=_0(c,o,i,h,a);let Lt=[];const Rt=m&&((ut=T.current)==null?void 0:ut.cell[1])===l&&u===0;let en=!1;if(W!==void 0){for(const xt of W)if(xt.style!=="no-outline"&&xt.range.y===l&&u===0){en=!0;break}}const Hn=()=>{wB(Je,pt,f,q,i,a,x,g,h,S,T,p,B,L,k,P,lt,Z,ge),Mb(Je,pt,l,a,u,i,s,void 0,void 0,g,$e,ht,I,k,M,O,p,!0),Je.beginPath(),Je.moveTo(0,At-.5),Je.lineTo(i,At-.5),Je.strokeStyle=Vr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Je.stroke(),en&&Rb(Je,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),Rt&&Qg(Je,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O)};if(lt!==void 0){const xt=pt[pt.length-1].sourceIndex+1,dn=lt.hasItemInRegion([{x:o,y:-2,width:xt,height:2},{x:o,y:l,width:xt,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:xt,height:M,when:M>0}]),re=De=>{ob(De,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,le,Lt,lt,T,ne,W,R,B,L,q,oe,H,p,Me,Fe,_e,b,Ut);const ze=T.current;A&&m&&ze!==void 0&<.has(ZT(ze.range))&&Qg(De,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O)};dn&&(re(tt),Ne!==null&&(Ne.save(),Ne.scale(we,we),Ne.textBaseline="middle",re(Ne),Ne.restore()),lt.hasHeader()&&(RW(Je,pt,i,g,$e,a,u,l,lt),Hn())),tt.restore(),Je.restore();return}if((Qe!==!0||o!==(me==null?void 0:me.cellXOffset)||a!==(me==null?void 0:me.translateX)||Rt!==(me==null?void 0:me.mustDrawFocusOnHeader)||en!==(me==null?void 0:me.mustDrawHighlightRingsOnHeader))&&Hn(),Qe===!0){Wr(dt!==void 0&&me!==void 0);const{regions:xt}=EW(tt,dt,dt===wt?me.aBufferScroll:me.bBufferScroll,dt===wt?me.bBufferScroll:me.aBufferScroll,me,o,l,a,u,M,i,s,O,$e,we,c,pt,w,Re);Lt=xt}else Qe!==!1&&(Wr(me!==void 0),Lt=AW(me,o,l,a,u,i,s,$e,pt,Qe));CW(tt,pt,i,s,M,O,k,ht,p);const Pt=Rb(tt,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),vn=m?Qg(tt,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,le,A,O):void 0;if(tt.fillStyle=p.bgCell,Lt.length>0){tt.beginPath();for(const xt of Lt)tt.rect(xt.x,xt.y,xt.width,xt.height);tt.clip(),tt.fill(),tt.beginPath()}else tt.fillRect(0,0,i,s);const In=ob(tt,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,le,Lt,lt,T,ne,W,R,B,L,q,oe,H,p,Me,Fe,_e,b,Ut);SW(tt,pt,c,i,s,$e,a,u,l,O,ht,I,T.rows,y,M,le,Lt,lt,p),TW(tt,pt,l,a,u,i,s,Lt,$e,ht,I,k,M,O,p),Mb(tt,pt,l,a,u,i,s,Lt,In,g,$e,ht,I,k,M,O,p),Pt==null||Pt(),vn==null||vn(),S&&Lo(pt,0,a,0,$e,(xt,dn)=>xt.sourceIndex===U?(Ob(Je,dn+xt.width,0,$e+1,Vr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ob(tt,dn+xt.width,$e,s,Vr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),Ne!==null&&(Ne.fillStyle=p.bgCell,Ne.fillRect(0,0,i,s),Ne.drawImage(tt.canvas,0,0));const Pr=OW(pt,s,$e,a,u,l,O,ht,M,le);R==null||R.setWindow({x:o,y:l,width:pt.length,height:Pr-l},d,Array.from({length:M},(xt,dn)=>O-1-dn));const Ir=me!==void 0&&(o!==me.cellXOffset||a!==me.translateX),Bt=me!==void 0&&(l!==me.cellYOffset||u!==me.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Rt,mustDrawHighlightRingsOnHeader:en,lastBuffer:Re?Kt===wt?"a":"b":void 0,aBufferScroll:Kt===wt?[Ir,Bt]:me==null?void 0:me.aBufferScroll,bBufferScroll:Kt===rt?[Ir,Bt]:me==null?void 0:me.bBufferScroll},tt.restore(),Je.restore()}const PW=80;function IW(t){const e=t-1;return e*e*e+1}class NW{constructor(e){bt(this,"callback");bt(this,"currentHoveredItem");bt(this,"leavingItems",[]);bt(this,"lastAnimationTime");bt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>nc(r.item,e.item))||this.leavingItems.push(e)});bt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>nc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});bt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});bt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});bt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:IW(e.hoverAmount)})));bt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/PW;for(const s of this.leavingItems)s.hoverAmount=Oi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Oi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});bt(this,"setHovered",e=>{var n;if(!nc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class DW{constructor(e){bt(this,"fn");bt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function sw(t){return new DW(t)}const _W=sw(()=>window.navigator.userAgent.includes("Firefox")),Eh=sw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Ah=sw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function LW(t){const e=v.useRef([]),n=v.useRef(0),r=v.useRef(t);r.current=t;const i=v.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(ew);e.current=[],r.current(new ic(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return v.useCallback(s=>{e.current.length===0&&i();const o=Pi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const to="header",Hr="group-header",Mh="out-of-bounds";var da;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(da||(da={}));function DE(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const Ib=6,FW=(t,e)=>{if(t.kind===ke.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},$W=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:g,onCanvasFocused:y,onCanvasBlur:w,isFocused:k,selection:b,freezeColumns:S,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:Z,onItemHovered:ne,dragAndDropState:oe,firstColAccessible:W,onKeyDown:U,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:H,onDragEnd:q,eventTargetRef:B,isResizing:V,resizeColumn:le,isDragging:ge,isDraggable:Me=!1,allowResize:Fe,disabledRows:_e,hasAppendRow:ft,getGroupDetails:Xe,theme:Ge,prelightCells:lt,headerIcons:Ut,verticalBorder:Re,drawCell:we,drawHeader:Qe,onCellFocused:nt,onDragOverCell:it,onDrop:$e,onDragLeave:At,imageWindowLoader:wt,smoothScrollX:rt=!1,smoothScrollY:me=!1,experimental:Ne,getCellRenderer:Je}=t,tt=t.translateX??0,Kt=t.translateY??0,dt=Math.max(S,Math.min(s.length-1,o)),ht=v.useRef(null),pt=wt,Lt=v.useRef(),[Rt,en]=v.useState(!1),Hn=v.useRef([]),Pt=v.useRef(),[vn,In]=v.useState(),[Pr,Ir]=v.useState(),Bt=v.useRef(null),[ut,xt]=v.useState(),[dn,re]=v.useState(!1),De=v.useRef(dn);De.current=dn;const ze=v.useMemo(()=>new dB(Ut,()=>{qn.current=void 0,zo.current()}),[Ut]),An=x?c+a:a,z=v.useRef(-1),ue=((Ne==null?void 0:Ne.enableFirefoxRescaling)??!1)&&_W.value,Y=((Ne==null?void 0:Ne.enableSafariRescaling)??!1)&&Eh.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!ue&&!Y||(z.current!==-1&&en(!0),window.clearTimeout(z.current),z.current=window.setTimeout(()=>{en(!1),z.current=-1},200))},[l,dt,tt,Kt,ue,Y]);const ce=a$(s,S),fe=M?La(ce,oe):0,Le=v.useCallback((j,se,xe)=>{const ye=j.getBoundingClientRect();if(se>=ce.length||xe>=d)return;const de=ye.width/n,Ae=L0(se,xe,n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f);return de!==1&&(Ae.x*=de,Ae.y*=de,Ae.width*=de,Ae.height*=de),Ae.x+=ye.x,Ae.y+=ye.y,Ae},[n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f]),Ee=v.useCallback((j,se,xe,ye)=>{const de=j.getBoundingClientRect(),Ae=de.width/n,st=(se-de.left)/Ae,ot=(xe-de.top)/Ae,Ce=5,Ft=_0(ce,dt,n,void 0,tt);let Be=0,zt=0;ye instanceof MouseEvent&&(Be=ye.button,zt=ye.buttons);const ct=d$(st,Ft,tt),St=h$(ot,r,x,a,c,d,f,l,Kt,A),wn=(ye==null?void 0:ye.shiftKey)===!0,gt=(ye==null?void 0:ye.ctrlKey)===!0,hn=(ye==null?void 0:ye.metaKey)===!0,Zr=ye!==void 0&&!(ye instanceof MouseEvent)||(ye==null?void 0:ye.pointerType)==="touch",ln=[st<0?-1:nn||ot>r){const It=st>n?1:st<0?-1:0,xn=ot>r?1:ot<0?-1:0;let Lr=It*2,Wi=xn*2;It===0&&(Lr=ct===-1?da.EndPadding:da.Center),xn===0&&(Wi=St===void 0?da.EndPadding:da.Center);let xi=!1;if(ct===-1&&St===-1){const jo=Le(j,ce.length-1,-1);Wr(jo!==void 0),xi=sen&&str&&ot=0?(xn=!0,It=Le(j,Lr,St),Wr(It!==void 0),_r={kind:x&&St===-2?Hr:to,location:[Lr,St],bounds:It,group:ce[Lr].group??"",isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:xe-It.y,button:Be,buttons:zt,scrollEdge:ln}):_r={kind:x&&St===-2?Hr:to,group:ce[ct].group??"",location:[ct,St],bounds:It,isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:xe-It.y,button:Be,buttons:zt,scrollEdge:ln}}else{const It=Le(j,ct,St);Wr(It!==void 0);const xn=It!==void 0&&It.x+It.width-se{}),Ot=v.useRef(vn);Ot.current=vn;const[Xt,Nn]=v.useMemo(()=>{const j=document.createElement("canvas"),se=document.createElement("canvas");return j.style.display="none",j.style.opacity="0",j.style.position="fixed",se.style.display="none",se.style.opacity="0",se.style.position="fixed",[j.getContext("2d",{alpha:!1}),se.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(Xt===null||Nn===null))return document.documentElement.append(Xt.canvas),document.documentElement.append(Nn.canvas),()=>{Xt.canvas.remove(),Nn.canvas.remove()}},[Xt,Nn]);const vr=v.useMemo(()=>new S$,[]),Mn=ue&&Rt?1:Y&&Rt?2:5,ms=(Ne==null?void 0:Ne.disableMinimumCellWidth)===!0?1:10,qn=v.useRef(),ys=v.useRef(null),vs=v.useRef(null),Ol=v.useCallback(()=>{var st;const j=ht.current,se=Bt.current;if(j===null||se===null||(ys.current===null&&(ys.current=j.getContext("2d",{alpha:!1}),j.width=0,j.height=0),vs.current===null&&(vs.current=se.getContext("2d",{alpha:!1}),se.width=0,se.height=0),ys.current===null||vs.current===null||Xt===null||Nn===null))return;let xe=!1;const ye=ot=>{xe=!0,xt(ot)},de=qn.current,Ae={headerCanvasCtx:vs.current,canvasCtx:ys.current,bufferACtx:Xt,bufferBCtx:Nn,width:n,height:r,cellXOffset:dt,cellYOffset:l,translateX:Math.round(tt),translateY:Math.round(Kt),mappedColumns:ce,enableGroups:x,freezeColumns:S,dragAndDropState:oe,theme:Ge,headerHeight:a,groupHeaderHeight:c,disabledRows:_e??Nt.empty(),rowHeight:f,verticalBorder:Re,isResizing:V,resizeCol:le,isFocused:k,selection:b,fillHandle:u,drawCellCallback:we,hasAppendRow:ft,overrideCursor:ye,maxScaleFactor:Mn,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:Xe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:Qe,prelightCells:lt,highlightRegions:N,imageLoader:pt,lastBlitData:Pt,damage:Lt.current,hoverValues:Hn.current,hoverInfo:Ot.current,spriteManager:ze,scrolling:Rt,hyperWrapping:(Ne==null?void 0:Ne.hyperWrapping)??!1,touchMode:dn,enqueue:at.current,renderStateProvider:vr,renderStrategy:(Ne==null?void 0:Ne.renderStrategy)??(Eh.value?"double-buffer":"single-buffer"),getCellRenderer:Je,minimumCellWidth:ms};Ae.damage===void 0?(qn.current=Ae,Pb(Ae,de)):Pb(Ae,void 0),!xe&&(Ae.damage===void 0||Ae.damage.has((st=Ot==null?void 0:Ot.current)==null?void 0:st[0]))&&xt(void 0)},[Xt,Nn,n,r,dt,l,tt,Kt,ce,x,S,oe,Ge,a,c,_e,f,Re,V,ft,le,k,b,u,A,d,_,Mn,h,Xe,p,we,Qe,lt,N,pt,ze,Rt,Ne==null?void 0:Ne.hyperWrapping,Ne==null?void 0:Ne.renderStrategy,dn,vr,Je,ms]),zo=v.useRef(Ol);v.useLayoutEffect(()=>{Ol(),zo.current=Ol},[Ol]),v.useLayoutEffect(()=>{(async()=>{var se;((se=document==null?void 0:document.fonts)==null?void 0:se.ready)!==void 0&&(await document.fonts.ready,qn.current=void 0,zo.current())})()},[]);const js=v.useCallback(j=>{Lt.current=j,zo.current(),Lt.current=void 0},[]),lf=LW(js);at.current=lf;const af=v.useCallback(j=>{js(new ic(j.map(se=>se.cell)))},[js]);pt.setCallback(js);const[jp,Hp]=v.useState(!1),[Pl,ws]=We??[],Wp=Pl!==void 0&&ws===-1,Vp=Pl!==void 0&&ws===-2;let uf=!1,Il=!1,Rn=ut;if(Rn===void 0&&Pl!==void 0&&ws!==void 0&&ws>-1&&ws({contain:"strict",display:"block",cursor:cf}),[cf]),iu=v.useRef("default"),Hs=B==null?void 0:B.current;Hs!=null&&iu.current!==Nl.cursor&&(Hs.style.cursor=iu.current=Nl.cursor);const Nr=v.useCallback((j,se,xe,ye)=>{if(Xe===void 0)return;const de=Xe(j);if(de.actions!==void 0){const Ae=bE(se,de.actions);for(const[st,ot]of Ae.entries())if(Ep(ot,xe+se.x,ye+ot.y))return de.actions[st]}},[Xe]),yi=v.useCallback((j,se,xe,ye)=>{const de=s[se];if(!ge&&!V&&de.hasMenu===!0&&!(Pr??!1)){const Ae=Le(j,se,-1);Wr(Ae!==void 0);const st=xE(Ae.x,Ae.y,Ae.width,Ae.height,qv(de.title)==="rtl");if(xe>st.x&&xest.y&&ye{const se=ht.current,xe=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==xe)return;ou.current=!0;let ye,de;if(j instanceof MouseEvent?(ye=j.clientX,de=j.clientY):(ye=j.touches[0].clientX,de=j.touches[0].clientY),j.target===xe&&xe!==null){const st=xe.getBoundingClientRect();if(ye>st.right||de>st.bottom)return}const Ae=Ee(se,ye,de,j);Ws.current=Ae.location,Ae.isTouch&&(su.current=Date.now()),De.current!==Ae.isTouch&&re(Ae.isTouch),!(Ae.kind===to&&yi(se,Ae.location[0],ye,de)!==void 0)&&(Ae.kind===Hr&&Nr(Ae.group,Ae.bounds,Ae.localEventX,Ae.localEventY)!==void 0||(P==null||P(Ae),!Ae.isTouch&&Me!==!0&&Me!==Ae.kind&&Ae.button<3&&Ae.button!==1&&j.preventDefault()))},[B,Me,Ee,Nr,yi,P]);Vn("touchstart",ar,window,!1),Vn("mousedown",ar,window,!1);const Dl=v.useRef(0),lu=v.useCallback(j=>{var zt,ct;const se=Dl.current;Dl.current=Date.now();const xe=ht.current;if(ou.current=!1,I===void 0||xe===null)return;const ye=B==null?void 0:B.current,de=j.target!==xe&&j.target!==ye;let Ae,st,ot=!0;if(j instanceof MouseEvent){if(Ae=j.clientX,st=j.clientY,ot=j.button<3,j.pointerType==="touch")return}else Ae=j.changedTouches[0].clientX,st=j.changedTouches[0].clientY;let Ce=Ee(xe,Ae,st,j);Ce.isTouch&&su.current!==0&&Date.now()-su.current>500&&(Ce={...Ce,isLongTouch:!0}),se!==0&&Date.now()-se<(Ce.isTouch?1e3:500)&&(Ce={...Ce,isDoubleClick:!0}),De.current!==Ce.isTouch&&re(Ce.isTouch),!de&&j.cancelable&&ot&&j.preventDefault();const[Ft]=Ce.location,Be=yi(xe,Ft,Ae,st);if(Ce.kind===to&&Be!==void 0){(Ce.button!==0||((zt=Ws.current)==null?void 0:zt[0])!==Ft||((ct=Ws.current)==null?void 0:ct[1])!==-1)&&I(Ce,!0);return}else if(Ce.kind===Hr){const St=Nr(Ce.group,Ce.bounds,Ce.localEventX,Ce.localEventY);if(St!==void 0){Ce.button===0&&St.onClick(Ce);return}}I(Ce,de)},[I,B,Ee,yi,Nr]);Vn("mouseup",lu,window,!1),Vn("touchend",lu,window,!1);const ff=v.useCallback(j=>{var Be,zt;const se=ht.current;if(se===null)return;const xe=B==null?void 0:B.current,ye=j.target!==se&&j.target!==xe;let de,Ae,st=!0;j instanceof MouseEvent?(de=j.clientX,Ae=j.clientY,st=j.button<3):(de=j.changedTouches[0].clientX,Ae=j.changedTouches[0].clientY);const ot=Ee(se,de,Ae,j);De.current!==ot.isTouch&&re(ot.isTouch),!ye&&j.cancelable&&st&&j.preventDefault();const[Ce]=ot.location,Ft=yi(se,Ce,de,Ae);if(ot.kind===to&&Ft!==void 0)ot.button===0&&((Be=Ws.current)==null?void 0:Be[0])===Ce&&((zt=Ws.current)==null?void 0:zt[1])===-1&&(m==null||m(Ce,Ft));else if(ot.kind===Hr){const ct=Nr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ct!==void 0&&ot.button===0&&ct.onClick(ot)}},[B,Ee,yi,m,Nr]);Vn("click",ff,window,!1);const Up=v.useCallback(j=>{const se=ht.current,xe=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==xe||T===void 0)return;const ye=Ee(se,j.clientX,j.clientY,j);T(ye,()=>{j.cancelable&&j.preventDefault()})},[B,Ee,T]);Vn("contextmenu",Up,(B==null?void 0:B.current)??null,!1);const df=v.useCallback(j=>{Lt.current=new ic(j.map(se=>se.item)),Hn.current=j,zo.current(),Lt.current=void 0},[]),vi=v.useMemo(()=>new NW(df),[df]),xs=v.useRef(vi);xs.current=vi,v.useLayoutEffect(()=>{const j=xs.current;if(We===void 0||We[1]<0){j.setHovered(We);return}const se=h(We,!0),xe=Je(se),ye=xe===void 0&&se.kind===ke.Custom||(xe==null?void 0:xe.needsHover)!==void 0&&(typeof xe.needsHover=="boolean"?xe.needsHover:xe.needsHover(se));j.setHovered(ye?We:void 0)},[h,Je,We]);const Dr=v.useRef(),G=v.useCallback(j=>{var ot;const se=ht.current;if(se===null)return;const xe=B==null?void 0:B.current,ye=j.target!==se&&j.target!==xe,de=Ee(se,j.clientX,j.clientY,j);if(de.kind!=="out-of-bounds"&&ye&&!ou.current&&!de.isTouch)return;const Ae=(Ce,Ft)=>{In(Be=>Be===Ce||(Be==null?void 0:Be[0][0])===(Ce==null?void 0:Ce[0][0])&&(Be==null?void 0:Be[0][1])===(Ce==null?void 0:Ce[0][1])&&((Be==null?void 0:Be[1][0])===(Ce==null?void 0:Ce[1][0])&&(Be==null?void 0:Be[1][1])===(Ce==null?void 0:Ce[1][1])||!Ft)?Be:Ce)};if(!DE(de,Dr.current))xt(void 0),ne==null||ne(de),Ae(de.kind===Mh?void 0:[de.location,[de.localEventX,de.localEventY]],!0),Dr.current=de;else if(de.kind==="cell"||de.kind===to||de.kind===Hr){let Ce=!1,Ft=!0;if(de.kind==="cell"){const zt=h(de.location);Ft=((ot=Je(zt))==null?void 0:ot.needsHoverPosition)??zt.kind===ke.Custom,Ce=Ft}else de.kind===Hr&&(Ce=!0);const Be=[de.location,[de.localEventX,de.localEventY]];Ae(Be,Ft),Ot.current=Be,Ce&&js(new ic([de.location]))}const st=de.location[0]>=(W?0:1);Ir(de.kind===to&&de.isEdge&&st&&Fe===!0),Hp(de.kind==="cell"&&de.isFillHandle),D==null||D(j),Z(de)},[B,Ee,W,Fe,D,Z,ne,h,Je,js]);Vn("mousemove",G,window,!0);const on=v.useCallback(j=>{const se=ht.current;if(se===null)return;let xe,ye;b.current!==void 0&&(xe=Le(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),U==null||U({bounds:xe,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ye})},[U,b,Le]),Bo=v.useCallback(j=>{const se=ht.current;if(se===null)return;let xe,ye;b.current!==void 0&&(xe=Le(se,b.current.cell[0],b.current.cell[1]),ye=b.current.cell),R==null||R({bounds:xe,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ye})},[R,b,Le]),Kp=v.useCallback(j=>{ht.current=j,L!==void 0&&(L.current=j)},[L]),hf=v.useCallback(j=>{const se=ht.current;if(se===null||Me===!1||V){j.preventDefault();return}let xe,ye;const de=Ee(se,j.clientX,j.clientY);if(Me!==!0&&de.kind!==Me){j.preventDefault();return}const Ae=(zt,ct)=>{xe=zt,ye=ct};let st,ot,Ce;const Ft=(zt,ct,St)=>{st=zt,ot=ct,Ce=St};let Be=!1;if(H==null||H({...de,setData:Ae,setDragImage:Ft,preventDefault:()=>Be=!0,defaultPrevented:()=>Be}),!Be&&xe!==void 0&&ye!==void 0&&j.dataTransfer!==null)if(j.dataTransfer.setData(xe,ye),j.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Ce!==void 0)j.dataTransfer.setDragImage(st,ot,Ce);else{const[zt,ct]=de.location;if(ct!==void 0){const St=document.createElement("canvas"),wn=Le(se,zt,ct);Wr(wn!==void 0);const gt=Math.ceil(window.devicePixelRatio??1);St.width=wn.width*gt,St.height=wn.height*gt;const hn=St.getContext("2d");hn!==null&&(hn.scale(gt,gt),hn.textBaseline="middle",ct===-1?(hn.font=Ge.headerFontFull,hn.fillStyle=Ge.bgHeader,hn.fillRect(0,0,St.width,St.height),kE(hn,0,0,wn.width,wn.height,ce[zt],!1,Ge,!1,!1,0,ze,Qe,!1)):(hn.font=Ge.baseFontFull,hn.fillStyle=Ge.bgCell,hn.fillRect(0,0,St.width,St.height),wE(hn,h([zt,ct]),0,ct,!1,!1,0,0,wn.width,wn.height,!1,Ge,Ge.bgCell,pt,ze,1,void 0,!1,0,void 0,void 0,void 0,vr,Je,()=>{}))),St.style.left="-100%",St.style.position="absolute",St.style.width=`${wn.width}px`,St.style.height=`${wn.height}px`,document.body.append(St),j.dataTransfer.setDragImage(St,wn.width/2,wn.height/2),window.setTimeout(()=>{St.remove()},0)}}else j.preventDefault()},[Me,V,Ee,H,Le,Ge,ce,ze,Qe,h,pt,vr,Je]);Vn("dragstart",hf,(B==null?void 0:B.current)??null,!1,!1);const au=v.useRef(),Xp=v.useCallback(j=>{const se=ht.current;if($e!==void 0&&j.preventDefault(),se===null||it===void 0)return;const xe=Ee(se,j.clientX,j.clientY),[ye,de]=xe.location,Ae=ye-(W?0:1),[st,ot]=au.current??[];(st!==Ae||ot!==de)&&(au.current=[Ae,de],it([Ae,de],j.dataTransfer))},[W,Ee,it,$e]);Vn("dragover",Xp,(B==null?void 0:B.current)??null,!1,!1);const Lw=v.useCallback(()=>{au.current=void 0,q==null||q()},[q]);Vn("dragend",Lw,(B==null?void 0:B.current)??null,!1,!1);const J=v.useCallback(j=>{const se=ht.current;if(se===null||$e===void 0)return;j.preventDefault();const xe=Ee(se,j.clientX,j.clientY),[ye,de]=xe.location,Ae=ye-(W?0:1);$e([Ae,de],j.dataTransfer)},[W,Ee,$e]);Vn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Yn=v.useCallback(()=>{At==null||At()},[At]);Vn("dragleave",Yn,(B==null?void 0:B.current)??null,!1,!1);const On=v.useRef(b);On.current=b;const _l=v.useRef(null),uu=v.useCallback(j=>{var se;ht.current===null||!ht.current.contains(document.activeElement)||(j===null&&On.current.current!==void 0?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j!==null&&j.focus({preventScroll:!0}),_l.current=j)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var se;const j=_l.current;j===null||!document.contains(j)?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j.focus({preventScroll:!0})},getBounds:(j,se)=>{if(!(L===void 0||L.current===null))return Le(L.current,j??0,se??-1)},damage:af}),[L,af,Le]);const Vs=v.useRef(),wr=A4(()=>{var ot,Ce,Ft;if(n<50||(Ne==null?void 0:Ne.disableAccessibilityTree)===!0)return null;let j=_0(ce,dt,n,oe,tt);const se=W?0:-1;!W&&((ot=j[0])==null?void 0:ot.sourceIndex)===0&&(j=j.slice(1));const[xe,ye]=((Ce=b.current)==null?void 0:Ce.cell)??[],de=(Ft=b.current)==null?void 0:Ft.range,Ae=j.map(Be=>Be.sourceIndex),st=nl(l,Math.min(d,l+i));return xe!==void 0&&ye!==void 0&&!(Ae.includes(xe)&&st.includes(ye))&&uu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":ce.length+se},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},j.map(Be=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Be.sourceIndex),"aria-colindex":Be.sourceIndex+1+se,tabIndex:-1,onFocus:zt=>{if(zt.target!==_l.current)return nt==null?void 0:nt([Be.sourceIndex,-1])},key:Be.sourceIndex},Be.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(Be=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Be),key:Be,"aria-rowindex":Be+2},j.map(zt=>{const ct=zt.sourceIndex,St=Pi(ct,Be),wn=xe===ct&&ye===Be,gt=de!==void 0&&ct>=de.x&&ct=de.y&&Be{const _r=L==null?void 0:L.current;if(_r!=null)return U==null?void 0:U({bounds:Le(_r,ct,Be),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Zr})},onFocusCapture:_r=>{var It,xn;if(!(_r.target===_l.current||((It=Vs.current)==null?void 0:It[0])===ct&&((xn=Vs.current)==null?void 0:xn[1])===Be))return Vs.current=Zr,nt==null?void 0:nt(Zr)},ref:wn?uu:void 0,tabIndex:-1},FW(ln,Je))})))))},[n,ce,dt,oe,tt,d,l,i,b,uu,h,L,U,Le,nt],200),wi=S===0||!M?0:dt>S?1:Oi(-tt/100,0,1),Gp=-l*32+Kt,Ll=O?Oi(-Gp/100,0,1):0,qp=v.useMemo(()=>{if(!wi&&!Ll)return null;const j={position:"absolute",top:0,left:fe,width:n-fe,height:r,opacity:wi,pointerEvents:"none",transition:rt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},se={position:"absolute",top:An,left:0,width:n,height:r,opacity:Ll,pointerEvents:"none",transition:me?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,wi>0&&v.createElement("div",{id:"shadow-x",style:j}),Ll>0&&v.createElement("div",{id:"shadow-y",style:se}))},[wi,Ll,fe,n,rt,An,r,me]),Yp=v.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return v.createElement(v.Fragment,null,v.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:on,onKeyUp:Bo,onFocus:y,onBlur:w,ref:Kp,style:Nl},wr),v.createElement("canvas",{ref:Bt,style:Yp}),qp)},zW=v.memo(v.forwardRef($W));function Ru(t,e,n,r){return Oi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const BW=t=>{const[e,n]=v.useState(),[r,i]=v.useState(),[s,o]=v.useState(),[l,a]=v.useState(),[u,c]=v.useState(!1),[f,d]=v.useState(),[h,p]=v.useState(),[m,x]=v.useState(),[g,y]=v.useState(!1),[w,k]=v.useState(),{onHeaderMenuClick:b,getCellContent:S,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:Z,onColumnProposeMove:ne,onMouseDown:oe,onMouseUp:W,onItemHovered:U,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:H,selection:q}=t,B=q.columns,V=v.useCallback(Re=>{const[we,Qe]=Re.location;s!==void 0&&l!==we&&we>=Z?(c(!0),a(we)):h!==void 0&&Qe!==void 0?(y(!0),x(Math.max(0,Qe))):r===void 0&&!u&&!g&&(U==null||U(Re))},[s,h,l,U,Z,r,u,g]),le=T!==void 0,ge=v.useCallback(Re=>{var we;if(Re.button===0){const[Qe,nt]=Re.location;if(Re.kind==="out-of-bounds"&&Re.isEdge&&L){const it=(we=_==null?void 0:_.current)==null?void 0:we.getBounds(H.length-1,-1);it!==void 0&&(n(it.x),i(H.length-1))}else if(Re.kind==="header"&&Qe>=Z){const it=N==null?void 0:N.current;if(Re.isEdge&&L&&it){n(Re.bounds.x),i(Qe);const At=it.getBoundingClientRect().width/it.offsetWidth,wt=Re.bounds.width/At;M==null||M(H[Qe],wt,Qe,wt+(H[Qe].growOffset??0))}else Re.kind==="header"&&le&&(d(Re.bounds.x),o(Qe))}else Re.kind==="cell"&&Z>0&&Qe===0&&nt!==void 0&&D!==void 0&&(k(Re.bounds.y),p(nt))}oe==null||oe(Re)},[oe,L,Z,D,_,H,le,M,N]),Me=v.useCallback((Re,we)=>{u||g||b==null||b(Re,we)},[u,g,b]),Fe=v.useRef(-1),_e=v.useCallback(()=>{Fe.current=-1,p(void 0),x(void 0),k(void 0),y(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),ft=v.useCallback((Re,we)=>{if(Re.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,Fe.current,I,P);A==null||A(it,$e,nt,$e+(it.growOffset??0))}const Qe=Ru(H[r],Fe.current,I,P);if(O==null||O(H[r],Qe,r,Qe+(H[r].growOffset??0)),B.hasIndex(r))for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,Fe.current,I,P);O==null||O(it,$e,nt,$e+(it.growOffset??0))}}_e(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}W==null||W(Re,we)},[W,r,s,l,h,m,B,O,H,I,P,A,T,D,_e]),Xe=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ne==null?void 0:ne(s,l))!==!1)return{src:s,dest:l}},[s,l,ne]),Ge=v.useCallback(Re=>{const we=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Re.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Re.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&we){const nt=we.getBoundingClientRect().width/we.offsetWidth,it=(Re.clientX-e)/nt,$e=H[r],At=Ru($e,it,I,P);if(A==null||A($e,At,r,At+($e.growOffset??0)),Fe.current=it,(B==null?void 0:B.first())===r)for(const wt of B){if(wt===r)continue;const rt=H[wt],me=Ru(rt,Fe.current,I,P);A==null||A(rt,me,wt,me+(rt.growOffset??0))}}},[s,f,h,w,r,e,H,I,P,A,B,N]),lt=v.useCallback((Re,we)=>{if(h===void 0||m===void 0)return S(Re,we);let[Qe,nt]=Re;return nt===m?nt=h:(nt>m&&(nt-=1),nt>=h&&(nt+=1)),S([Qe,nt],we)},[h,m,S]),Ut=v.useCallback(Re=>{R==null||R(Re),Re.defaultPrevented()||_e()},[_e,R]);return v.createElement(zW,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:lt,isResizing:r!==void 0,onHeaderMenuClick:Me,isDragging:u,onItemHovered:V,onDragStart:Ut,onMouseDown:ge,allowResize:L,onMouseUp:ft,dragAndDropState:Xe,onMouseMoveRaw:Ge,ref:_})};function jW(t){const e=v.useRef(null),[n,r]=v.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return v.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const HW=(t,e,n)=>{const r=v.useRef(null),i=v.useRef(null),s=v.useRef(null),o=v.useRef(0),l=v.useRef(e);l.current=e;const a=n.current;v.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},WW=()=>t=>t.isSafari?"scroll":"auto",VW=Qr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[WW()]}});function UW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return Vn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Vn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const KW=t=>{var H,q;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:m}=t,x=[],g=(d==null?void 0:d.sticky)??!1,y=(d==null?void 0:d.fill)??!1,w=v.useRef(0),k=v.useRef(0),b=v.useRef(null),S=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=v.useRef(null),M=UW(200),[O,_]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||M||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[V,le]=T.current.lockDirection;V!==void 0?B.scrollLeft=V:le!==void 0&&(B.scrollTop=le),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,V)=>{var we;const le=b.current;if(le===null)return;V=V??le.scrollTop,B=B??le.scrollLeft;const ge=T.current.scrollTop,Me=T.current.scrollLeft,Fe=B-Me,_e=V-ge;M&&Fe!==0&&_e!==0&&(Math.abs(Fe)>3||Math.abs(_e)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(Fe)0&&(Math.abs(Ut)>2e3||lt===0||lt===Re)&&r>le.scrollHeight+5){const Qe=lt/Re,nt=(r-Ge)*Qe;w.current=nt-lt}ft!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:lt+w.current,width:Xe-c,height:Ge-u,paddingRight:((we=A.current)==null?void 0:we.clientWidth)??0})},[u,c,r,s,a,M]);HW(h&&Eh.value,I,b);const D=v.useRef(I);D.current=I;const Z=v.useRef(),ne=v.useRef(!1);v.useLayoutEffect(()=>{ne.current?I():ne.current=!0},[I,u,c]);const oe=v.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let W=0,U=0;for(x.push(v.createElement("div",{key:W++,style:{width:i,height:0}}));UD.current(),0),Z.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(VW,{isSafari:Eh.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:oe,style:Z.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>I()},v.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},v.createElement("div",{className:"dvn-stack"},x),f!==void 0&&v.createElement(v.Fragment,null,!y&&v.createElement("div",{className:"dvn-spacer"}),v.createElement("div",{ref:A,style:{height:L,maxHeight:n-Math.ceil(S%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:y?1:void 0,right:g?c??0:void 0,pointerEvents:"auto"}},f))))))},XW=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:g,overscrollY:y,initialSize:w,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:S}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),Z=u+Math.max(0,g??0);let ne=o?i+s:i;if(typeof r=="number")ne+=n*r;else for(let R=0;R{var _e,ft;if(oe.current===void 0)return;const R={...oe.current};let N=0,L=R.x<0?-R.x:0,H=0,q=0;R.x=R.x<0?0:R.x;let B=0;for(let Xe=0;Xe=Ge+Xe.width)N+=Xe.width,q++,H++;else if(R.x>Ge)N+=Xe.width,k?L+=Ge-R.x:q++,H++;else if(R.x+R.width>Ge)N+=Xe.width,H++;else break}let V=0,le=0,ge=0;if(typeof r=="number")b?(le=Math.floor(R.y/r),V=le*r-R.y):le=Math.ceil(R.y/r),ge=Math.ceil(R.height/r)+le,V<0&&ge++;else{let Xe=0;for(let Ge=0;Ge=Xe+lt)Xe+=lt,le++,ge++;else if(R.y>Ut)Xe+=lt,b?V+=Ut-R.y:le++,ge++;else if(R.y+R.height>lt/2+Xe)Xe+=lt,ge++;else break}}const Me={x:q,y:le,width:H-q,height:ge-le},Fe=_.current;(Fe===void 0||Fe.y!==Me.y||Fe.x!==Me.x||Fe.height!==Me.height||Fe.width!==Me.width||P.current!==L||I.current!==V||R.width!==((_e=D.current)==null?void 0:_e[0])||R.height!==((ft=D.current)==null?void 0:ft[1]))&&(d==null||d({x:q,y:le,width:H-q,height:ge-le},R.width,R.height,R.paddingRight??0,L,V),_.current=Me,P.current=L,I.current=V,D.current=[R.width,R.height])},[e,r,n,d,l,k,b]),U=v.useCallback(R=>{oe.current=R,W()},[W]);return v.useEffect(()=>{W()},[W]),v.createElement(KW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:S===!0||typeof S=="string",scrollWidth:Z+(T??0),scrollHeight:ne+(A??0),clientHeight:O,rightElement:m,paddingBottom:A,paddingRight:T,rightElementProps:x,update:U,initialSize:w},v.createElement(BW,{eventTargetRef:h,width:M,height:O,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},GW=Qr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),qW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),YW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),QW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),JW=10,ZW=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=v.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=v.useState(""),x=o??p,g=v.useCallback(N=>{m(N),a==null||a(N)},[a]),[y,w]=v.useState(),k=v.useRef(y);k.current=y,v.useEffect(()=>{l!==void 0&&(l.length>0?w(N=>({rowsSearched:r,results:l.length,selectedIndex:(N==null?void 0:N.selectedIndex)??-1})):w(void 0))},[r,l]);const b=v.useRef();b.current===void 0&&(b.current=new AbortController);const S=v.useRef(),[T,A]=v.useState([]),M=l??T,O=v.useCallback(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0,b.current.abort())},[]),_=v.useRef(n);_.current=n;const P=v.useCallback(N=>{const L=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let H=_.current,q=Math.min(10,r),B=0;w(void 0),A([]);const V=[],le=async()=>{var Re;if(u===void 0)return;const ge=performance.now(),Me=r-B;let Fe=u({x:0,y:H,width:i.length,height:Math.min(q,Me,r-H)},b.current.signal);typeof Fe=="function"&&(Fe=await Fe());let _e=!1;for(const[we,Qe]of Fe.entries())for(const[nt,it]of Qe.entries()){let $e;switch(it.kind){case ke.Text:case ke.Number:$e=it.displayData;break;case ke.Uri:case ke.Markdown:$e=it.data;break;case ke.Boolean:$e=typeof it.data=="boolean"?it.data.toString():void 0;break;case ke.Image:case ke.Bubble:$e=it.data.join("🐳");break;case ke.Custom:$e=it.copyData;break}$e!==void 0&&L.test($e)&&(V.push([nt,we+H]),_e=!0)}const ft=performance.now();_e&&A([...V]),B+=Fe.length,Wr(B<=r);const Xe=((Re=k.current)==null?void 0:Re.selectedIndex)??-1;w({results:V.length,rowsSearched:B,selectedIndex:Xe}),c==null||c(V,Xe),H+q>=r?H=0:H+=q;const Ge=ft-ge,lt=Math.max(Ge,1),Ut=JW/lt;q=Math.ceil(q*Ut),B{var N;d==null||d(),w(void 0),A([]),c==null||c([],-1),O(),(N=e==null?void 0:e.current)==null||N.focus()},[O,e,d,c]),D=v.useCallback(N=>{g(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),O()):P(N.target.value))},[P,O,g,l]);v.useEffect(()=>{f&&s.current!==null&&(g(""),s.current.focus({preventScroll:!0}))},[f,s,g]);const Z=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(M,L)},[y,c,M]),ne=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;let L=(y.selectedIndex-1)%y.results;L<0&&(L+=y.results),w({...y,selectedIndex:L}),c==null||c(M,L)},[c,M,y]),oe=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ne():Z())},[I,Z,ne]);v.useEffect(()=>()=>{O()},[O]);const[W,U]=v.useState(!1);v.useEffect(()=>{if(f)U(!0);else{const N=setTimeout(()=>U(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!W)return null;let N;y!==void 0&&(N=y.results>=1e3?"over 1000":`${y.results} result${y.results!==1?"s":""}`,y.selectedIndex>=0&&(N=`${y.selectedIndex+1} of ${N}`));const L=B=>{B.stopPropagation()},q={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(GW,{className:f?"":"out",onMouseDown:L,onMouseMove:L,onMouseUp:L,onClick:L},v.createElement("div",{className:"gdg-search-bar-inner"},v.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:D,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:oe}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ne,disabled:((y==null?void 0:y.results)??0)===0},qW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:Z,disabled:((y==null?void 0:y.results)??0)===0},YW),d!==void 0&&v.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:I},QW)),y!==void 0?v.createElement(v.Fragment,null,v.createElement("div",{className:"gdg-search-status"},v.createElement("div",{"data-testid":"search-result-area"},N)),v.createElement("div",{className:"gdg-search-progress",style:q})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,W,y,r,h,s,D,x,oe,ne,Z,d,I]);return v.createElement(v.Fragment,null,v.createElement(XW,{prelightCells:M,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),R)};class e6 extends v.PureComponent{constructor(){super(...arguments);bt(this,"wrapperRef",v.createRef());bt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return v.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const t6=()=>t=>Math.max(16,t.targetHeight-10),n6=Qr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[t6(),"px"]}}),r6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Ln.useState(n);return Ln.createElement(e6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Ln.createElement(n6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function i6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function yt(t,e,n){const r=_E(t,e);return r&&(n.didMatch=!0),r}function _E(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(_E(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!i6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":Ah.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function s6(t,e,n,r,i,s){const o=Ln.useCallback((u,c,f,d)=>{var y;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,m=i==="mixed"&&h;let x={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((y=t.current)==null?void 0:y.rangeStack)??[]:[]},columns:p?t.columns:Nt.empty(),rows:m?t.rows:Nt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=Ln.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Nt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Nt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Ln.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Nt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Nt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function o6(t,e,n,r,i){const s=v.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:ke.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=v.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:ke.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:ke.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function l6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case ke.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Wv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case ke.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case ke.Image:case ke.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case ke.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case ke.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case ke.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case ke.Markdown:case ke.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case ke.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case ke.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case ke.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Rc()}}function a6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:l6(o))})}function Nb(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function u6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>Nb(o,!0)).join(",")):i.push(Nb(s.formatted,!1));e.push(i.join(" "))}return e.join(` +`)}function Jg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Db(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function c6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function f6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${Jg(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+Jg(o)+"
    2. ").join("")}
    ${Jg(i.formatted)}
    "),e.join("")}function d6(t,e){const n=a6(t,e),r=u6(n),i=f6(n);return{textPlain:r,textHtml:i}}function _b(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const m of d)m.replaceWith(` +`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:c6(h),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function h6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function Lb(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function p6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` +`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` +`?(r.push(t.slice(i,o)),i=o+1,l===` +`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` +`)&&(r.push(Lb(t.slice(i,o))),i=o+1,l===` +`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Fb(t,e,n){var l;const r=d6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function LE(t){return t!==!0}function $b(t){return typeof t=="string"?t:`${t}px`}const g6=()=>t=>t.innerWidth,m6=()=>t=>t.innerHeight,y6=Qr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[g6()],"wmyidgi-1":[m6()]}}),v6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(y6,{innerHeight:$b(n),innerWidth:$b(e),...i},r)},w6=2,x6=1300;function b6(t,e,n){const r=Ln.useRef(0),[i,s]=t??[0,0];Ln.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/x6);const d=r.current**1.618*f*w6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function k6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Ln.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=lE();return[typeof m=="number"?m*p:g=>Math.ceil(m(g)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const Js={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function vt(t,e){return t===!0?e:t===!1?"":t}function zb(t){const e=Ah.value;return{activateCell:vt(t.activateCell," |Enter|shift+Enter"),clear:vt(t.clear,"any+Escape"),closeOverlay:vt(t.closeOverlay,"any+Escape"),acceptOverlayDown:vt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:vt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:vt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:vt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:vt(t.delete,e?"Backspace|Delete":"Delete"),downFill:vt(t.downFill,"primary+_68"),scrollToSelectedCell:vt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:vt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:vt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:vt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:vt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:vt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:vt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:vt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:vt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:vt(t.goToFirstCell,"primary+Home"),goToFirstColumn:vt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:vt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:vt(t.goToLastCell,"primary+End"),goToLastColumn:vt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:vt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:vt(t.goToNextPage,"PageDown"),goToPreviousPage:vt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:vt(t.rightFill,"primary+_82"),search:vt(t.search,"primary+f"),selectAll:vt(t.selectAll,"primary+a"),selectColumn:vt(t.selectColumn,"ctrl+ "),selectGrowDown:vt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:vt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:vt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:vt(t.selectGrowUp,"shift+ArrowUp"),selectRow:vt(t.selectRow,"shift+ "),selectToFirstCell:vt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:vt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:vt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:vt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:vt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:vt(t.selectToLastRow,"primary+shift+ArrowDown")}}function S6(t){const e=I4(t);return Ln.useMemo(()=>{if(e===void 0)return zb(Js);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Js.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Js.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Js.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Js.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Js.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Js.selectToLastCell};return zb({...Js,...n})},[e])}const C6=v.lazy(async()=>await uE(()=>import("./data-grid-overlay-editor-BYOokjyr.js"),[]));let T6=0;function E6(t){return Rz(ib(ib(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return nl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Yf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const Zg={kind:ke.Loading,allowOverlay:!1},Qf={columns:Nt.empty(),rows:Nt.empty(),current:void 0},A6=(t,e)=>{var Yw,Qw,Jw;const[n,r]=v.useState(Qf),[i,s]=v.useState(),o=v.useRef(null),l=v.useRef(null),[a,u]=v.useState(),c=v.useRef(null),f=v.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:g,columns:y,rows:w,getCellContent:k,onCellClicked:b,onCellActivated:S,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:Z="default",onGroupHeaderClicked:ne,onCellContextMenu:oe,className:W,onHeaderContextMenu:U,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:H,onCellsEdited:q,onSearchResultsChanged:B,searchResults:V,onSearchValueChange:le,searchValue:ge,onKeyDown:Me,onKeyUp:Fe,keybindings:_e,editOnType:ft=!0,onRowAppended:Xe,onColumnMoved:Ge,validateCell:lt,highlightRegions:Ut,rangeSelect:Re="rect",columnSelect:we="multi",rowSelect:Qe="multi",rangeSelectionBlending:nt="exclusive",columnSelectionBlending:it="exclusive",rowSelectionBlending:$e="exclusive",onDelete:At,onDragStart:wt,onMouseMove:rt,onPaste:me,copyHeaders:Ne=!1,freezeColumns:Je=0,cellActivationBehavior:tt="second-click",rowSelectionMode:Kt="auto",onHeaderMenuClick:dt,getGroupDetails:ht,onSearchClose:pt,onItemHovered:Lt,onSelectionCleared:Rt,showSearch:en,onVisibleRegionChanged:Hn,gridSelection:Pt,onGridSelectionChange:vn,minColumnWidth:In=50,maxColumnWidth:Pr=500,maxColumnAutoWidth:Ir,provideEditor:Bt,trailingRowOptions:ut,freezeTrailingRows:xt=0,allowedFillDirections:dn="orthogonal",scrollOffsetX:re,scrollOffsetY:De,verticalBorder:ze,onDragOverCell:An,onDrop:z,onColumnResize:ue,onColumnResizeEnd:Y,onColumnResizeStart:ce,customRenderers:fe,fillHandle:Le,drawFocusRing:Ee=!0,experimental:We,fixedShadowX:at,fixedShadowY:Ot,headerIcons:Xt,imageWindowLoader:Nn,initialSize:vr,isDraggable:Mn,onDragLeave:ms,onRowMoved:qn,overscrollX:ys,overscrollY:vs,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:js,trapFocus:lf=!1,smoothScrollX:af,smoothScrollY:jp,scaleToRem:Hp=!1,rowHeight:Pl=34,headerHeight:ws=36,groupHeaderHeight:Wp=ws,theme:Vp,isOutsideClick:uf,renderers:Il}=t,Rn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Jr=(Rn==null?void 0:Rn.kind)??t.rowMarkers??"none",cf=(Rn==null?void 0:Rn.width)??t.rowMarkerWidth,Nl=(Rn==null?void 0:Rn.startIndex)??t.rowMarkerStartIndex??1,iu=(Rn==null?void 0:Rn.theme)??t.rowMarkerTheme,Hs=(Rn==null?void 0:Rn.checkboxStyle)??"square",Nr=Math.max(In,20),yi=Math.max(Pr,Nr),su=Math.max(Ir??yi,Nr),Ws=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),ou=v.useMemo(()=>Number.parseFloat(Ws.fontSize),[Ws]),{rowHeight:ar,headerHeight:Dl,groupHeaderHeight:lu,theme:ff,overscrollX:Up,overscrollY:df}=k6({groupHeaderHeight:Wp,headerHeight:ws,overscrollX:ys,overscrollY:vs,remSize:ou,rowHeight:Pl,scaleToRem:Hp,theme:Vp}),vi=S6(_e),xs=cf??(w>1e4?48:w>1e3?44:w>100?36:32),Dr=Jr!=="none",G=Dr?1:0,on=Xe!==void 0,Bo=(ut==null?void 0:ut.sticky)===!0,[Kp,hf]=v.useState(!1),au=en??Kp,Xp=v.useCallback(()=>{pt!==void 0?pt():hf(!1)},[pt]),J=v.useMemo(()=>Pt===void 0?void 0:Yf(Pt,G),[Pt,G])??n,Yn=v.useRef();Yn.current===void 0&&(Yn.current=new AbortController),v.useEffect(()=>()=>Yn==null?void 0:Yn.current.abort(),[]);const[On,_l]=o6(R,k,G,Yn.current,w),uu=v.useCallback((C,$,F)=>{if(lt===void 0)return!0;const K=[C[0]-G,C[1]];return lt==null?void 0:lt(K,$,F)},[G,lt]),Vs=v.useRef(Pt),wr=v.useCallback((C,$)=>{$&&(C=h6(C,On,G,Z,Yn.current)),vn!==void 0?(Vs.current=Yf(C,-G),vn(Vs.current)):r(C)},[vn,On,G,Z]),wi=Ul(ue,v.useCallback((C,$,F,K)=>{ue==null||ue(y[F-G],$,F-G,K)},[ue,G,y])),Gp=Ul(Y,v.useCallback((C,$,F,K)=>{Y==null||Y(y[F-G],$,F-G,K)},[Y,G,y])),Ll=Ul(ce,v.useCallback((C,$,F,K)=>{ce==null||ce(y[F-G],$,F-G,K)},[ce,G,y])),qp=Ul(O,v.useCallback((C,$)=>(O==null?void 0:O({...C,columnIndex:C.columnIndex-G},$))??!1,[O,G])),Yp=Ul(_,v.useCallback((C,$)=>(_==null?void 0:_({...C,col:C.col-G},$))??!1,[_,G])),j=v.useCallback(C=>{if(At!==void 0){const $=At(Yf(C,-G));return typeof $=="boolean"?$:Yf($,G)}return!0},[At,G]),[se,xe,ye]=s6(J,wr,nt,it,$e,Re),de=v.useMemo(()=>To(lE(),ff),[ff]),[Ae,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Il===void 0)return{};const C={};for(const $ of Il)C[$.kind]=$;return C},[Il]),Ce=v.useCallback(C=>C.kind!==ke.Custom?ot[C.kind]:fe==null?void 0:fe.find($=>$.isMatch(C)),[fe,ot]);let{sizedColumns:Ft,nonGrowWidth:Be}=A$(y,w,_l,Ae[0]-(G===0?0:xs)-Ae[2],Nr,su,de,Ce,Yn.current);Jr!=="none"&&(Be+=xs);const zt=v.useMemo(()=>Ft.some(C=>C.group!==void 0),[Ft]),ct=zt?Dl+lu:Dl,St=J.rows.length,wn=Jr==="none"?void 0:St===0?!1:St===w?!0:void 0,gt=v.useMemo(()=>Jr==="none"?Ft:[{title:"",width:xs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:iu,rowMarker:Hs,rowMarkerChecked:wn},...Ft],[Jr,Ft,xs,iu,Hs,wn]),[hn,Zr]=v.useMemo(()=>[De!==void 0&&typeof ar=="number"?Math.floor(De/ar):0,De!==void 0&&typeof ar=="number"?-(De%ar):0],[De,ar]),ln=v.useRef({height:1,width:1,x:0,y:0}),_r=v.useMemo(()=>({x:ln.current.x,y:hn,width:ln.current.width??1,height:ln.current.height??1,ty:Zr}),[Zr,hn]),It=v.useRef(!1),[xn,Lr,Wi]=P4(_r);ln.current=xn;const xi=(xn.height??1)>1;v.useLayoutEffect(()=>{if(De!==void 0&&c.current!==null&&xi){if(c.current.scrollTop===De)return;c.current.scrollTop=De,c.current.scrollTop!==De&&Wi(),It.current=!0}},[De,xi,Wi]);const Fl=(xn.width??1)>1;v.useLayoutEffect(()=>{if(re!==void 0&&c.current!==null&&Fl){if(c.current.scrollLeft===re)return;c.current.scrollLeft=re,c.current.scrollLeft!==re&&Wi(),It.current=!0}},[re,Fl,Wi]);const jo=xn.x+G,pf=xn.y,xr=v.useRef(null),ur=v.useCallback(C=>{var $;C===!0?($=xr.current)==null||$.focus():window.requestAnimationFrame(()=>{var F;(F=xr.current)==null||F.focus()})},[]),Qn=on?w+1:w,ei=v.useCallback(C=>{const $=G===0?C:C.map(K=>({...K,location:[K.location[0]-G,K.location[1]]})),F=q==null?void 0:q($);if(F!==!0)for(const K of $)H==null||H(K.location,K.value);return F},[H,q,G]),[Ho,Qp]=v.useState(),gf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,$l=Ee?(Yw=J.current)==null?void 0:Yw.cell:void 0,mf=$l==null?void 0:$l[0],yf=$l==null?void 0:$l[1],wR=v.useMemo(()=>{if((Ut===void 0||Ut.length===0)&&(gf??mf??yf??Ho)===void 0)return;const C=[];if(Ut!==void 0)for(const $ of Ut){const F=gt.length-$.range.x-G;F>0&&C.push({color:$.color,range:{...$.range,x:$.range.x+G,width:Math.min(F,$.range.width)},style:$.style})}return Ho!==void 0&&C.push({color:wl(de.accentColor,0),range:Ho,style:"dashed"}),gf!==void 0&&C.push({color:wl(de.accentColor,.5),range:gf,style:"solid-outline"}),mf!==void 0&&yf!==void 0&&C.push({color:de.accentColor,range:{x:mf,y:yf,width:1,height:1},style:"solid-outline"}),C.length>0?C:void 0},[Ho,gf,mf,yf,Ut,gt.length,de.accentColor,G]),Fw=v.useRef(gt);Fw.current=gt;const Fr=v.useCallback(([C,$],F=!1)=>{var te,Q,ee,ae,ie,Se,Oe;const K=on&&$===Qn-1;if(C===0&&Dr)return K?Zg:{kind:oi.Marker,allowOverlay:!1,checkboxStyle:Hs,checked:(J==null?void 0:J.rows.hasIndex($))===!0,markerKind:Jr==="clickable-number"?"number":Jr,row:Nl+$,drawHandle:qn!==void 0,cursor:Jr==="clickable-number"?"pointer":void 0};if(K){const Ve=C===G?(ut==null?void 0:ut.hint)??"":"",qe=Fw.current[C];if(((te=qe==null?void 0:qe.trailingRowOptions)==null?void 0:te.disabled)===!0)return Zg;{const Mt=((Q=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Q.hint)??Ve,Ze=((ee=qe==null?void 0:qe.trailingRowOptions)==null?void 0:ee.addIcon)??(ut==null?void 0:ut.addIcon);return{kind:oi.NewRow,hint:Mt,allowOverlay:!1,icon:Ze}}}else{const be=C-G;if(F||(We==null?void 0:We.strict)===!0){const qe=ln.current,Mt=qe.x>be||be>qe.x+qe.width||qe.y>$||$>qe.y+qe.height||$>=Zp.current,Ze=be===((ie=(ae=qe.extras)==null?void 0:ae.selected)==null?void 0:ie[0])&&$===((Se=qe.extras)==null?void 0:Se.selected[1]);let He=!1;if(((Oe=qe.extras)==null?void 0:Oe.freezeRegions)!==void 0){for(const Qt of qe.extras.freezeRegions)if(Ep(Qt,be,$)){He=!0;break}}if(Mt&&!Ze&&!He)return Zg}let Ve=k([be,$]);return G!==0&&Ve.span!==void 0&&(Ve={...Ve,span:[Ve.span[0]+G,Ve.span[1]+G]}),Ve}},[on,Qn,Dr,Hs,J==null?void 0:J.rows,Jr,Nl,qn,G,ut==null?void 0:ut.hint,ut==null?void 0:ut.addIcon,We==null?void 0:We.strict,k]),Jp=v.useCallback(C=>{let $=(ht==null?void 0:ht(C))??{name:C};return L!==void 0&&C!==""&&($={icon:$.icon,name:$.name,overrideTheme:$.overrideTheme,actions:[...$.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>tg({group:$.name,bounds:F.bounds})}]}),$},[ht,L]),vf=v.useCallback(C=>{var ee;const[$,F]=C.cell,K=gt[$],X=(K==null?void 0:K.group)!==void 0?(ee=Jp(K.group))==null?void 0:ee.overrideTheme:void 0,te=K==null?void 0:K.themeOverride,Q=p==null?void 0:p(F);s({...C,theme:To(de,X,te,Q,C.content.themeOverride)})},[p,gt,Jp,de]),zl=v.useCallback((C,$,F)=>{var Q;if(J.current===void 0)return;const[K,X]=J.current.cell,te=Fr([K,X]);if(te.kind!==ke.Boolean&&te.allowOverlay){let ee=te;if(F!==void 0)switch(ee.kind){case ke.Number:{const ae=dD(()=>F==="-"?-0:Number.parseFloat(F),0);ee={...ee,data:Number.isNaN(ae)?0:ae};break}case ke.Text:case ke.Markdown:case ke.Uri:ee={...ee,data:F};break}vf({target:C,content:ee,initialValue:F,cell:[K,X],highlight:F===void 0,forceEditMode:F!==void 0})}else te.kind===ke.Boolean&&$&&te.readonly!==!0&&(ei([{location:J.current.cell,value:{...te,data:LE(te.data)}}]),(Q=xr.current)==null||Q.damage([{cell:J.current.cell}]))},[Fr,J,ei,vf]),$w=v.useCallback((C,$)=>{var X;const F=(X=xr.current)==null?void 0:X.getBounds(C,$);if(F===void 0||c.current===null)return;const K=Fr([C,$]);K.allowOverlay&&vf({target:F,content:K,initialValue:void 0,highlight:!0,cell:[C,$],forceEditMode:!0})},[Fr,vf]),bn=v.useCallback((C,$,F="both",K=0,X=0,te=void 0)=>{if(c.current!==null){const Q=xr.current,ee=l.current,ae=typeof C!="number"?C.unit==="cell"?C.amount:void 0:C,ie=typeof $!="number"?$.unit==="cell"?$.amount:void 0:$,Se=typeof C!="number"&&C.unit==="px"?C.amount:void 0,Oe=typeof $!="number"&&$.unit==="px"?$.amount:void 0;if(Q!==null&&ee!==null){let be={x:0,y:0,width:0,height:0},Ve=0,qe=0;if((ae!==void 0||ie!==void 0)&&(be=Q.getBounds((ae??0)+G,ie??0)??be,be.width===0||be.height===0))return;const Mt=ee.getBoundingClientRect(),Ze=Mt.width/ee.offsetWidth;if(Se!==void 0&&(be={...be,x:Se-Mt.left-c.current.scrollLeft,width:1}),Oe!==void 0&&(be={...be,y:Oe+Mt.top-c.current.scrollTop,height:1}),be!==void 0){const He={x:be.x-K,y:be.y-X,width:be.width+2*K,height:be.height+2*X};let Qt=0;for(let lg=0;lg0&&(Jn=Rl(Qn,kn,ar));let ki=Qt*Ze+Mt.left+G*xs*Ze,Ui=Mt.right,Si=Mt.top+ct*Ze,Ki=Mt.bottom-Jn*Ze;const Cf=be.width+K*2;switch(te==null?void 0:te.hAlign){case"start":Ui=ki+Cf;break;case"end":ki=Ui-Cf;break;case"center":ki=Math.floor((ki+Ui)/2)-Cf/2,Ui=ki+Cf;break}const Tf=be.height+X*2;switch(te==null?void 0:te.vAlign){case"start":Ki=Si+Tf;break;case"end":Si=Ki-Tf;break;case"center":Si=Math.floor((Si+Ki)/2)-Tf/2,Ki=Si+Tf;break}ki>He.x?Ve=He.x-ki:UiHe.y?qe=He.y-Si:Ki=Qn-kn)&&(qe=0),(Ve!==0||qe!==0)&&(Ze!==1&&(Ve/=Ze,qe/=Ze),c.current.scrollTo(Ve+c.current.scrollLeft,qe+c.current.scrollTop))}}}},[G,xt,xs,ct,Je,Ft,Qn,Bo,ar]),zw=v.useRef($w),Bw=v.useRef(k),Zp=v.useRef(w);zw.current=$w,Bw.current=k,Zp.current=w;const Bl=v.useCallback(async(C,$=!0)=>{var ae;const F=gt[C];if(((ae=F==null?void 0:F.trailingRowOptions)==null?void 0:ae.disabled)===!0)return;const K=Xe==null?void 0:Xe();let X,te=!0;K!==void 0&&(X=await K,X==="top"&&(te=!1),typeof X=="number"&&(te=!1));let Q=0;const ee=()=>{if(Zp.current<=w){Q<500&&window.setTimeout(ee,Q),Q=50+Q*2;return}const ie=typeof X=="number"?X:te?w:0;Sf.current(C-G,ie),se({cell:[C,ie],range:{x:C,y:ie,width:1,height:1}},!1,!1,"edit");const Se=Bw.current([C-G,ie]);Se.allowOverlay&&Bu(Se)&&Se.readonly!==!0&&$&&window.setTimeout(()=>{zw.current(C,ie)},0)};ee()},[gt,Xe,G,w,se]),wf=v.useCallback(C=>{var F,K;const $=((K=(F=Ft[C])==null?void 0:F.trailingRowOptions)==null?void 0:K.targetColumn)??(ut==null?void 0:ut.targetColumn);if(typeof $=="number")return $+(Dr?1:0);if(typeof $=="object"){const X=y.indexOf($);if(X>=0)return X+(Dr?1:0)}},[Ft,y,Dr,ut==null?void 0:ut.targetColumn]),Us=v.useRef(),jl=v.useRef(),cu=v.useCallback((C,$)=>{var X;const[F,K]=$;return To(de,(X=gt[F])==null?void 0:X.themeOverride,p==null?void 0:p(K),C.themeOverride)},[p,gt,de]),fu=v.useCallback(C=>{var Se,Oe,be;const $=Ah.value?C.metaKey:C.ctrlKey,F=$&&Qe==="multi",K=$&&we==="multi",[X,te]=C.location,Q=J.columns,ee=J.rows,[ae,ie]=((Se=J.current)==null?void 0:Se.cell)??[];if(C.kind==="cell"){if(jl.current=void 0,Wo.current=[X,te],X===0&&Dr){if(on===!0&&te===w||Jr==="number"||Qe==="none")return;const Ve=Fr(C.location);if(Ve.kind!==oi.Marker)return;if(qn!==void 0){const Ze=Ce(Ve);Wr((Ze==null?void 0:Ze.kind)===oi.Marker);const He=(Oe=Ze==null?void 0:Ze.onClick)==null?void 0:Oe.call(Ze,{...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,theme:cu(Ve,C.location),preventDefault:()=>{}});if(He===void 0||He.checked===Ve.checked)return}s(void 0),ur();const qe=ee.hasIndex(te),Mt=Us.current;if(Qe==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Mt!==void 0&&ee.hasIndex(Mt)){const Ze=[Math.min(Mt,te),Math.max(Mt,te)+1];F||Kt==="multi"?xe(void 0,Ze,!0):xe(Nt.fromSingleSelection(Ze),void 0,F)}else F||C.isTouch||Kt==="multi"?qe?xe(ee.remove(te),void 0,!0):(xe(void 0,te,!0),Us.current=te):qe&&ee.length===1?xe(Nt.empty(),void 0,$):(xe(Nt.fromSingleSelection(te),void 0,$),Us.current=te)}else if(X>=G&&on&&te===w){const Ve=wf(X);Bl(Ve??X)}else if(ae!==X||ie!==te){const Ve=Fr(C.location),qe=Ce(Ve);if((qe==null?void 0:qe.onSelect)!==void 0){let He=!1;if(qe.onSelect({...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,preventDefault:()=>He=!0,theme:cu(Ve,C.location)}),He)return}const Mt=Bo&&te===w,Ze=Bo&&J!==void 0&&((be=J.current)==null?void 0:be.cell[1])===w;if((C.shiftKey||C.isLongTouch===!0)&&ae!==void 0&&ie!==void 0&&J.current!==void 0&&!Ze){if(Mt)return;const He=Math.min(X,ae),Qt=Math.max(X,ae),Jn=Math.min(te,ie),kn=Math.max(te,ie);se({...J.current,range:{x:He,y:Jn,width:Qt-He+1,height:kn-Jn+1}},!0,$,"click"),Us.current=void 0,ur()}else se({cell:[X,te],range:{x:X,y:te,width:1,height:1}},!0,$,"click"),Us.current=void 0,s(void 0),ur()}}else if(C.kind==="header")if(Wo.current=[X,te],s(void 0),Dr&&X===0)Us.current=void 0,jl.current=void 0,Qe==="multi"&&(ee.length!==w?xe(Nt.fromSingleSelection([0,w]),void 0,$):xe(Nt.empty(),void 0,$),ur());else{const Ve=jl.current;if(we==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ve!==void 0&&Q.hasIndex(Ve)){const qe=[Math.min(Ve,X),Math.max(Ve,X)+1];K?ye(void 0,qe,$):ye(Nt.fromSingleSelection(qe),void 0,$)}else K?(Q.hasIndex(X)?ye(Q.remove(X),void 0,$):ye(void 0,X,$),jl.current=X):we!=="none"&&(ye(Nt.fromSingleSelection(X),void 0,$),jl.current=X);Us.current=void 0,ur()}else C.kind===Hr?Wo.current=[X,te]:C.kind===Mh&&!C.isMaybeScrollbar&&(wr(Qf,!1),s(void 0),ur(),Rt==null||Rt(),Us.current=void 0,jl.current=void 0)},[Bl,we,ur,Ce,wf,Fr,J,Dr,Bo,Rt,qn,G,Jr,Qe,Kt,w,se,wr,ye,xe,on,cu]),du=v.useRef(!1),Wo=v.useRef(),jw=v.useRef(xn),ti=v.useRef(),xR=v.useCallback(C=>{if(Hl.current=!1,jw.current=ln.current,C.button!==0&&C.button!==1){ti.current=void 0;return}const $=performance.now();ti.current={button:C.button,time:$,location:C.location},(C==null?void 0:C.kind)==="header"&&(du.current=!0);const F=C.kind==="cell"&&C.isFillHandle;!F&&C.kind!=="cell"&&C.isEdge||(u({previousSelection:J,fillHandle:F}),Wo.current=void 0,!C.isTouch&&C.button===0&&!F?fu(C):!C.isTouch&&C.button===1&&(Wo.current=C.location))},[J,fu]),[eg,tg]=v.useState(),Hw=v.useCallback(C=>{if(C.kind!==Hr||we!=="multi")return;const $=Ah.value?C.metaKey:C.ctrlKey,[F]=C.location,K=J.columns;if(F=G&&Oc(X.group,gt[ee].group);ee--)te--;for(let ee=F+1;ee{if(On!==void 0&&wi!==void 0){const $=ln.current.y,F=ln.current.height;let K=On({x:C,y:$,width:1,height:Math.min(F,w-$)},Yn.current.signal);typeof K!="object"&&(K=await K());const X=Ft[C-G],Q=document.createElement("canvas").getContext("2d",{alpha:!1});if(Q!==null){Q.font=de.baseFontFull;const ee=aE(Q,de,X,0,K,Nr,yi,!1,Ce);wi==null||wi(X,ee.width,C,ee.width)}}},[Ft,On,yi,de,Nr,wi,G,w,Ce]),[bR,ng]=v.useState(),Wl=v.useCallback(async(C,$)=>{var ee,ae;const F=(ee=C.current)==null?void 0:ee.range;if(F===void 0||On===void 0||$.current===void 0)return;const K=$.current.range;if(T!==void 0){let ie=!1;if(T({fillDestination:{...K,x:K.x-G},patternSource:{...F,x:F.x-G},preventDefault:()=>ie=!0}),ie)return}let X=On(F,Yn.current.signal);typeof X!="object"&&(X=await X());const te=X,Q=[];for(let ie=0;ie({cell:ie.location})))},[On,ei,T,G]),Ww=v.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,width:1}}};Wl(C,J)},[Wl,J]),Vw=v.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,height:1}}};Wl(C,J)},[Wl,J]),kR=v.useCallback((C,$)=>{var Se,Oe;const F=a;if(u(void 0),Qp(void 0),ng(void 0),du.current=!1,$)return;if((F==null?void 0:F.fillHandle)===!0&&J.current!==void 0&&((Se=F.previousSelection)==null?void 0:Se.current)!==void 0){if(Ho===void 0)return;const be={...J,current:{...J.current,range:vE(F.previousSelection.current.range,Ho)}};Wl(F.previousSelection,be),wr(be,!0);return}const[K,X]=C.location,[te,Q]=Wo.current??[],ee=()=>{Hl.current=!0},ae=be=>{var qe,Mt,Ze;const Ve=be.isTouch||te===K&&Q===X;if(Ve&&(b==null||b([K-G,X],{...be,preventDefault:ee})),be.button===1)return!Hl.current;if(!Hl.current){const He=Fr(C.location),Qt=Ce(He);if(Qt!==void 0&&Qt.onClick!==void 0&&Ve){const kn=Qt.onClick({...be,cell:He,posX:be.localEventX,posY:be.localEventY,bounds:be.bounds,theme:cu(He,C.location),preventDefault:ee});kn!==void 0&&!ca(kn)&&ql(kn)&&(ei([{location:be.location,value:kn}]),(qe=xr.current)==null||qe.damage([{cell:be.location}]))}if(Hl.current||J.current===void 0)return!1;let Jn=!1;switch(He.activationBehaviorOverride??tt){case"double-click":case"second-click":{if(((Ze=(Mt=F==null?void 0:F.previousSelection)==null?void 0:Mt.current)==null?void 0:Ze.cell)===void 0)break;const[kn,ki]=J.current.cell,[Ui,Si]=F.previousSelection.current.cell;Jn=K===kn&&K===Ui&&X===ki&&X===Si&&(be.isDoubleClick===!0||tt==="second-click");break}case"single-click":{Jn=!0;break}}if(Jn)return S==null||S([K-G,X]),zl(be.bounds,!1),!0}return!1},ie=C.location[0]-G;if(C.isTouch){const be=ln.current,Ve=jw.current;if(be.x!==Ve.x||be.y!==Ve.y)return;if(C.isLongTouch===!0){if(C.kind==="cell"&&nc((Oe=J.current)==null?void 0:Oe.cell,C.location)){oe==null||oe([ie,C.location[1]],{...C,preventDefault:ee});return}else if(C.kind==="header"&&J.columns.hasIndex(K)){U==null||U(ie,{...C,preventDefault:ee});return}else if(C.kind===Hr){if(ie<0)return;N==null||N(ie,{...C,preventDefault:ee});return}}C.kind==="cell"?ae(C)||fu(C):C.kind===Hr?ne==null||ne(ie,{...C,preventDefault:ee}):(C.kind===to&&(I==null||I(ie,{...C,preventDefault:ee})),fu(C));return}if(C.kind==="header"){if(ie<0)return;C.isEdge?C.isDoubleClick===!0&&xf(K):C.button===0&&K===te&&X===Q&&(I==null||I(ie,{...C,preventDefault:ee}))}if(C.kind===Hr){if(ie<0)return;C.button===0&&K===te&&X===Q&&(ne==null||ne(ie,{...C,preventDefault:ee}),Hl.current||Hw(C))}C.kind==="cell"&&(C.button===0||C.button===1)&&ae(C),Wo.current=void 0},[a,J,G,Ho,Wl,wr,b,Fr,Ce,tt,cu,ei,S,zl,oe,U,N,fu,ne,I,xf,Hw]),SR=v.useCallback(C=>{const $={...C,location:[C.location[0]-G,C.location[1]]};rt==null||rt($),a!==void 0&&C.buttons===0&&(u(void 0),Qp(void 0),ng(void 0),du.current=!1),ng(F=>{var K;return du.current?[C.scrollEdge[0],0]:C.scrollEdge[0]===(F==null?void 0:F[0])&&C.scrollEdge[1]===F[1]?F:a===void 0||(((K=ti.current)==null?void 0:K.location[0])??0){dt==null||dt(C-G,$)},[dt,G]),Vi=(Qw=J==null?void 0:J.current)==null?void 0:Qw.cell,TR=v.useCallback((C,$,F,K,X,te)=>{It.current=!1;let Q=Vi;Q!==void 0&&(Q=[Q[0]-G,Q[1]]);const ee=Je===0?void 0:{x:0,y:C.y,width:Je,height:C.height},ae=[];ee!==void 0&&ae.push(ee),xt>0&&(ae.push({x:C.x-G,y:w-xt,width:C.width,height:xt}),Je>0&&ae.push({x:0,y:w-xt,width:Je,height:xt}));const ie={x:C.x-G,y:C.y,width:C.width,height:on&&C.y+C.height>=w?C.height-1:C.height,tx:X,ty:te,extras:{selected:Q,freezeRegion:ee,freezeRegions:ae}};ln.current=ie,Lr(ie),st([$,F,K]),Hn==null||Hn(ie,ie.tx,ie.ty,ie.extras)},[Vi,G,on,w,Je,xt,Lr,Hn]),ER=Ul(Ge,v.useCallback((C,$)=>{Ge==null||Ge(C-G,$-G),we!=="none"&&ye(Nt.fromSingleSelection($),void 0,!0)},[we,Ge,G,ye])),rg=v.useRef(!1),AR=v.useCallback(C=>{if(C.location[0]===0&&G>0){C.preventDefault();return}wt==null||wt({...C,location:[C.location[0]-G,C.location[1]]}),C.defaultPrevented()||(rg.current=!0),u(void 0)},[wt,G]),MR=v.useCallback(()=>{rg.current=!1},[]),ig=v.useRef(),sg=v.useCallback(C=>{var $,F,K;if(!DE(C,ig.current)&&(ig.current=C,!((($=ti==null?void 0:ti.current)==null?void 0:$.button)!==void 0&&ti.current.button>=1))){if(C.buttons!==0&&a!==void 0&&((F=ti.current)==null?void 0:F.location[0])===0&&C.location[0]===0&&G===1&&Qe==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ti.current.location[1])&&J.rows.hasIndex(ti.current.location[1])){const X=Math.min(ti.current.location[1],C.location[1]),te=Math.max(ti.current.location[1],C.location[1])+1;xe(Nt.fromSingleSelection([X,te]),void 0,!1)}if(C.buttons!==0&&a!==void 0&&J.current!==void 0&&!rg.current&&!du.current&&(Re==="rect"||Re==="multi-rect")){const[X,te]=J.current.cell;let[Q,ee]=C.location;if(ee<0&&(ee=ln.current.y),a.fillHandle===!0&&((K=a.previousSelection)==null?void 0:K.current)!==void 0){const ae=a.previousSelection.current.range;ee=Math.min(ee,on?w-1:w);const ie=hB(ae,Q,ee,dn);Qp(ie)}else{if(on&&te===w)return;if(on&&ee===w)if(C.kind===Mh)ee--;else return;Q=Math.max(Q,G);const Se=Q-X,Oe=ee-te,be={x:Se>=0?X:Q,y:Oe>=0?te:ee,width:Math.abs(Se)+1,height:Math.abs(Oe)+1};se({...J.current,range:be},!0,!1,"drag")}}Lt==null||Lt({...C,location:[C.location[0]-G,C.location[1]]})}},[dn,a,G,Qe,J,Re,Lt,xe,on,w,se]),RR=v.useCallback(()=>{var Q,ee;const C=ig.current;if(C===void 0)return;const[$,F]=C.scrollEdge;let[K,X]=C.location;const te=ln.current;$===-1?K=((ee=(Q=te.extras)==null?void 0:Q.freezeRegion)==null?void 0:ee.x)??te.x:$===1&&(K=te.x+te.width),F===-1?X=Math.max(0,te.y):F===1&&(X=Math.min(w-1,te.y+te.height)),K=Oi(K,0,gt.length-1),X=Oi(X,0,w-1),sg({...C,location:[K,X]})},[gt.length,sg,w]);b6(bR,c,RR);const bi=v.useCallback(C=>{if(J.current===void 0)return;const[$,F]=C,[K,X]=J.current.cell,te=J.current.range;let Q=te.x,ee=te.x+te.width,ae=te.y,ie=te.y+te.height;if(F!==0)switch(F){case 2:{ie=w,ae=X,bn(0,ie,"vertical");break}case-2:{ae=0,ie=X+1,bn(0,ae,"vertical");break}case 1:{aeX+1?(ie--,bn(0,ie,"vertical")):(ae=Math.max(0,ae-1),bn(0,ae,"vertical"));break}default:Rc()}if($!==0)if($===2)ee=gt.length,Q=K,bn(ee-1-G,0,"horizontal");else if($===-2)Q=G,ee=K+1,bn(Q-G,0,"horizontal");else{let Se=[];if(On!==void 0){const Oe=On({x:Q,y:ae,width:ee-Q-G,height:ie-ae},Yn.current.signal);typeof Oe=="object"&&(Se=E6(Oe))}if($===1){let Oe=!1;if(Q0){const be=nl(Q+1,K+1).find(Ve=>!Se.includes(Ve-G));be!==void 0&&(Q=be,Oe=!0)}else Q++,Oe=!0;Oe&&bn(Q,0,"horizontal")}Oe||(ee=Math.min(gt.length,ee+1),bn(ee-1-G,0,"horizontal"))}else if($===-1){let Oe=!1;if(ee>K+1){if(Se.length>0){const be=nl(ee-1,K,-1).find(Ve=>!Se.includes(Ve-G));be!==void 0&&(ee=be,Oe=!0)}else ee--,Oe=!0;Oe&&bn(ee-G,0,"horizontal")}Oe||(Q=Math.max(G,Q-1),bn(Q-G,0,"horizontal"))}else Rc()}se({cell:J.current.cell,range:{x:Q,y:ae,width:ee-Q,height:ie-ae}},!0,!1,"keyboard-select")},[On,J,gt.length,G,w,bn,se]),Ks=v.useCallback((C,$,F,K)=>{const X=Qn-(F?0:1);if(C=Oi(C,G,Ft.length-1+G),$=Oi($,0,X),C===(Vi==null?void 0:Vi[0])&&$===(Vi==null?void 0:Vi[1]))return!1;if(K&&J.current!==void 0){const te=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&te.push(J.current.range),wr({...J,current:{cell:[C,$],range:{x:C,y:$,width:1,height:1},rangeStack:te}},!0)}else se({cell:[C,$],range:{x:C,y:$,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===C&&f.current[1]===$&&(f.current=void 0),bn(C-G,$),!0},[Qn,G,Ft.length,Vi,J,bn,wr,se]),OR=v.useCallback((C,$)=>{(i==null?void 0:i.cell)!==void 0&&C!==void 0&&ql(C)&&(ei([{location:i.cell,value:C}]),window.requestAnimationFrame(()=>{var X;(X=xr.current)==null||X.damage([{cell:i.cell}])})),ur(!0),s(void 0);const[F,K]=$;if(J.current!==void 0&&(F!==0||K!==0)){const X=J.current.cell[1]===Qn-1&&C!==void 0;Ks(Oi(J.current.cell[0]+F,0,gt.length-1),Oi(J.current.cell[1]+K,0,Qn-1),X,!1)}A==null||A(C,$)},[i==null?void 0:i.cell,ur,J,A,ei,Qn,Ks,gt.length]),PR=v.useMemo(()=>`gdg-overlay-${T6++}`,[]),Vo=v.useCallback(C=>{var F,K,X,te;ur();const $=[];for(let Q=C.x;Q({cell:Q.location})))},[ur,k,Ce,ei,G]),hu=i!==void 0,Uw=v.useCallback(C=>{var Ve,qe;const $=()=>{C.stopPropagation(),C.preventDefault()},F={didMatch:!1},{bounds:K}=C,X=J.columns,te=J.rows,Q=vi;if(!hu&&yt(Q.clear,C,F))wr(Qf,!1),Rt==null||Rt();else if(!hu&&yt(Q.selectAll,C,F))wr({columns:Nt.empty(),rows:Nt.empty(),current:{cell:((Ve=J.current)==null?void 0:Ve.cell)??[G,0],range:{x:G,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(yt(Q.search,C,F))(qe=o==null?void 0:o.current)==null||qe.focus({preventScroll:!0}),hf(!0);else if(yt(Q.delete,C,F)){const Mt=(j==null?void 0:j(J))??!0;if(Mt!==!1){const Ze=Mt===!0?J:Mt;if(Ze.current!==void 0){Vo(Ze.current.range);for(const He of Ze.current.rangeStack)Vo(He)}for(const He of Ze.rows)Vo({x:G,y:He,width:y.length,height:1});for(const He of Ze.columns)Vo({x:He,y:0,width:1,height:w})}}if(F.didMatch)return $(),!0;if(J.current===void 0)return!1;let[ee,ae]=J.current.cell,ie=!1,Se=!1;yt(Q.scrollToSelectedCell,C,F)?Sf.current(ee-G,ae):we!=="none"&&yt(Q.selectColumn,C,F)?X.hasIndex(ee)?ye(X.remove(ee),void 0,!0):we==="single"?ye(Nt.fromSingleSelection(ee),void 0,!0):ye(void 0,ee,!0):Qe!=="none"&&yt(Q.selectRow,C,F)?te.hasIndex(ae)?xe(te.remove(ae),void 0,!0):Qe==="single"?xe(Nt.fromSingleSelection(ae),void 0,!0):xe(void 0,ae,!0):!hu&&K!==void 0&&yt(Q.activateCell,C,F)?ae===w&&on?window.setTimeout(()=>{const Mt=wf(ee);Bl(Mt??ee)},0):(S==null||S([ee-G,ae]),zl(K,!0)):J.current.range.height>1&&yt(Q.downFill,C,F)?Vw():J.current.range.width>1&&yt(Q.rightFill,C,F)?Ww():yt(Q.goToNextPage,C,F)?ae+=Math.max(1,ln.current.height-4):yt(Q.goToPreviousPage,C,F)?ae-=Math.max(1,ln.current.height-4):yt(Q.goToFirstCell,C,F)?(s(void 0),ae=0,ee=0):yt(Q.goToLastCell,C,F)?(s(void 0),ae=Number.MAX_SAFE_INTEGER,ee=Number.MAX_SAFE_INTEGER):yt(Q.selectToFirstCell,C,F)?(s(void 0),bi([-2,-2])):yt(Q.selectToLastCell,C,F)?(s(void 0),bi([2,2])):hu?(yt(Q.closeOverlay,C,F)&&s(void 0),yt(Q.acceptOverlayDown,C,F)&&(s(void 0),ae++),yt(Q.acceptOverlayUp,C,F)&&(s(void 0),ae--),yt(Q.acceptOverlayLeft,C,F)&&(s(void 0),ee--),yt(Q.acceptOverlayRight,C,F)&&(s(void 0),ee++)):(yt(Q.goDownCell,C,F)?ae+=1:yt(Q.goUpCell,C,F)?ae-=1:yt(Q.goRightCell,C,F)?ee+=1:yt(Q.goLeftCell,C,F)?ee-=1:yt(Q.goDownCellRetainSelection,C,F)?(ae+=1,ie=!0):yt(Q.goUpCellRetainSelection,C,F)?(ae-=1,ie=!0):yt(Q.goRightCellRetainSelection,C,F)?(ee+=1,ie=!0):yt(Q.goLeftCellRetainSelection,C,F)?(ee-=1,ie=!0):yt(Q.goToLastRow,C,F)?ae=w-1:yt(Q.goToFirstRow,C,F)?ae=Number.MIN_SAFE_INTEGER:yt(Q.goToLastColumn,C,F)?ee=Number.MAX_SAFE_INTEGER:yt(Q.goToFirstColumn,C,F)?ee=Number.MIN_SAFE_INTEGER:(Re==="rect"||Re==="multi-rect")&&(yt(Q.selectGrowDown,C,F)?bi([0,1]):yt(Q.selectGrowUp,C,F)?bi([0,-1]):yt(Q.selectGrowRight,C,F)?bi([1,0]):yt(Q.selectGrowLeft,C,F)?bi([-1,0]):yt(Q.selectToLastRow,C,F)?bi([0,2]):yt(Q.selectToFirstRow,C,F)?bi([0,-2]):yt(Q.selectToLastColumn,C,F)?bi([2,0]):yt(Q.selectToFirstColumn,C,F)&&bi([-2,0])),Se=F.didMatch);const Oe=Ks(ee,ae,!1,ie),be=F.didMatch;return be&&(Oe||!Se||lf)&&$(),be},[hu,J,vi,we,Qe,Re,G,w,Ks,wr,Rt,y.length,j,lf,Vo,ye,xe,on,wf,Bl,S,zl,Vw,Ww,bi]),pu=v.useCallback(C=>{let $=!1;if(Me!==void 0&&Me({...C,cancel:()=>{$=!0}}),$||Uw(C)||J.current===void 0)return;const[F,K]=J.current.cell,X=ln.current;if(ft&&!C.metaKey&&!C.ctrlKey&&J.current!==void 0&&C.key.length===1&&/[ -~]/g.test(C.key)&&C.bounds!==void 0&&Bu(k([F-G,Math.max(0,Math.min(K,w-1))]))){if((!on||K!==w)&&(X.y>K||K>X.y+X.height||X.x>F||F>X.x+X.width))return;zl(C.bounds,!0,C.key),C.stopPropagation(),C.preventDefault()}},[ft,Me,Uw,J,k,G,w,on,zl]),IR=v.useCallback((C,$)=>{const F=C.location[0]-G;if(C.kind==="header"&&(U==null||U(F,{...C,preventDefault:$})),C.kind===Hr){if(F<0)return;N==null||N(F,{...C,preventDefault:$})}if(C.kind==="cell"){const[K,X]=C.location;oe==null||oe([F,X],{...C,preventDefault:$}),u$(J,C.location)||Ks(K,X,!1,!1)}},[J,oe,N,U,G,Ks]),og=v.useCallback(async C=>{var Q,ee,ae;if(!vi.paste)return;function $(ie,Se,Oe,be){var qe,Mt;const Ve=typeof Oe=="object"?(Oe==null?void 0:Oe.join(` +`))??"":(Oe==null?void 0:Oe.toString())??"";if(!ca(ie)&&Bu(ie)&&ie.readonly!==!0){const Ze=M==null?void 0:M(Ve,ie);if(Ze!==void 0&&ql(Ze))return{location:Se,value:Ze};const He=Ce(ie);if(He===void 0)return;if(He.kind===ke.Custom){Wr(ie.kind===ke.Custom);const Qt=(qe=He.onPaste)==null?void 0:qe.call(He,Ve,ie.data);return Qt===void 0?void 0:{location:Se,value:{...ie,data:Qt}}}else{const Qt=(Mt=He.onPaste)==null?void 0:Mt.call(He,Ve,ie,{formatted:be,formattedString:typeof be=="string"?be:be==null?void 0:be.join(` +`),rawValue:Oe});return Qt===void 0?void 0:(Wr(Qt.kind===ie.kind),{location:Se,value:Qt})}}}const F=J.columns,K=J.rows,X=((Q=c.current)==null?void 0:Q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0;let te;if(J.current!==void 0?te=[J.current.range.x,J.current.range.y]:F.length===1?te=[F.first()??0,0]:K.length===1&&(te=[G,K.first()??0]),X&&te!==void 0){let ie,Se;const Oe="text/plain",be="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const He of Ze){if(He.types.includes(be)){const Jn=await(await He.getType(be)).text(),kn=_b(Jn);if(kn!==void 0){ie=kn;break}}He.types.includes(Oe)&&(Se=await(await He.getType(Oe)).text())}}else if(navigator.clipboard.readText!==void 0)Se=await navigator.clipboard.readText();else if(C!==void 0&&(C==null?void 0:C.clipboardData)!==null){if(C.clipboardData.types.includes(be)){const Ze=C.clipboardData.getData(be);ie=_b(Ze)}ie===void 0&&C.clipboardData.types.includes(Oe)&&(Se=C.clipboardData.getData(Oe))}else return;const[Ve,qe]=te,Mt=[];do{if(me===void 0){const Ze=Fr(te),He=Se??(ie==null?void 0:ie.map(Jn=>Jn.map(kn=>kn.rawValue).join(" ")).join(" "))??"",Qt=$(Ze,te,He,void 0);Qt!==void 0&&Mt.push(Qt);break}if(ie===void 0){if(Se===void 0)return;ie=p6(Se)}if(me===!1||typeof me=="function"&&(me==null?void 0:me([te[0]-G,te[1]],ie.map(Ze=>Ze.map(He=>{var Qt;return((Qt=He.rawValue)==null?void 0:Qt.toString())??""}))))!==!0)return;for(const[Ze,He]of ie.entries()){if(Ze+qe>=w)break;for(const[Qt,Jn]of He.entries()){const kn=[Qt+Ve,Ze+qe],[ki,Ui]=kn;if(ki>=gt.length||Ui>=Qn)continue;const Si=Fr(kn),Ki=$(Si,kn,Jn.rawValue,Jn.formatted);Ki!==void 0&&Mt.push(Ki)}}}while(!1);ei(Mt),(ae=xr.current)==null||ae.damage(Mt.map(Ze=>({cell:Ze.location})))}},[M,Ce,Fr,J,vi.paste,gt.length,ei,Qn,me,G,w]);Vn("paste",og,d,!1,!0);const gu=v.useCallback(async(C,$)=>{var Q,ee;if(!vi.copy)return;const F=$===!0||((Q=c.current)==null?void 0:Q.contains(document.activeElement))===!0||((ee=l.current)==null?void 0:ee.contains(document.activeElement))===!0,K=J.columns,X=J.rows,te=(ae,ie)=>{if(!Ne)Fb(ae,ie,C);else{const Se=ie.map(Oe=>({kind:ke.Text,data:y[Oe].title,displayData:y[Oe].title,allowOverlay:!1}));Fb([Se,...ae],ie,C)}};if(F&&On!==void 0){if(J.current!==void 0){let ae=On(J.current.range,Yn.current.signal);typeof ae!="object"&&(ae=await ae()),te(ae,nl(J.current.range.x-G,J.current.range.x+J.current.range.width-G))}else if(X!==void 0&&X.length>0){const ie=[...X].map(Se=>{const Oe=On({x:G,y:Se,width:y.length,height:1},Yn.current.signal);return typeof Oe=="object"?Oe[0]:Oe().then(be=>be[0])});if(ie.some(Se=>Se instanceof Promise)){const Se=await Promise.all(ie);te(Se,nl(y.length))}else te(ie,nl(y.length))}else if(K.length>0){const ae=[],ie=[];for(const Se of K){let Oe=On({x:Se,y:0,width:1,height:w},Yn.current.signal);typeof Oe!="object"&&(Oe=await Oe()),ae.push(Oe),ie.push(Se-G)}if(ae.length===1)te(ae[0],ie);else{const Se=ae.reduce((Oe,be)=>Oe.map((Ve,qe)=>[...Ve,...be[qe]]));te(Se,ie)}}}},[y,On,J,vi.copy,G,w,Ne]);Vn("copy",gu,d,!1,!1);const NR=v.useCallback(async C=>{var F,K;if(!(!vi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((K=l.current)==null?void 0:K.contains(document.activeElement))===!0))&&(await gu(C),J.current!==void 0)){let X={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:Nt.empty(),columns:Nt.empty()};const te=j==null?void 0:j(X);if(te===!1||(X=te===!0?X:te,X.current===void 0))return;Vo(X.current.range)}},[Vo,J,vi.cut,gu,j]);Vn("cut",NR,d,!1,!1);const DR=v.useCallback((C,$)=>{if(B!==void 0){G!==0&&(C=C.map(X=>[X[0]-G,X[1]])),B(C,$);return}if(C.length===0||$===-1)return;const[F,K]=C[$];f.current!==void 0&&f.current[0]===F&&f.current[1]===K||(f.current=[F,K],Ks(F,K,!1,!1))},[B,G,Ks]),[bf,kf]=((Jw=Pt==null?void 0:Pt.current)==null?void 0:Jw.cell)??[],Sf=v.useRef(bn);Sf.current=bn,v.useLayoutEffect(()=>{var C,$,F,K;!It.current&&bf!==void 0&&kf!==void 0&&(bf!==(($=(C=Vs.current)==null?void 0:C.current)==null?void 0:$.cell[0])||kf!==((K=(F=Vs.current)==null?void 0:F.current)==null?void 0:K.cell[1]))&&Sf.current(bf,kf),It.current=!1},[bf,kf]);const Kw=J.current!==void 0&&(J.current.cell[0]>=gt.length||J.current.cell[1]>=Qn);v.useLayoutEffect(()=>{Kw&&wr(Qf,!1)},[Kw,wr]);const _R=v.useMemo(()=>on===!0&&(ut==null?void 0:ut.tint)===!0?Nt.fromSingleSelection(Qn-1):Nt.empty(),[Qn,on,ut==null?void 0:ut.tint]),LR=v.useCallback(C=>typeof ze=="boolean"?ze:(ze==null?void 0:ze(C-G))??!0,[G,ze]),FR=v.useMemo(()=>{if(eg===void 0||l.current===null)return null;const{bounds:C,group:$}=eg,F=l.current.getBoundingClientRect();return v.createElement(r6,{bounds:C,group:$,canvasBounds:F,onClose:()=>tg(void 0),onFinish:K=>{tg(void 0),L==null||L($,K)}})},[L,eg]),$R=Math.min(gt.length,Je+(Dr?1:0));v.useImperativeHandle(e,()=>({appendRow:(C,$)=>Bl(C+G,$),updateCells:C=>{var $;return G!==0&&(C=C.map(F=>({cell:[F.cell[0]+G,F.cell[1]]}))),($=xr.current)==null?void 0:$.damage(C)},getBounds:(C,$)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(C===void 0&&$===void 0){const K=l.current.getBoundingClientRect(),X=K.width/c.current.clientWidth;return{x:K.x-c.current.scrollLeft*X,y:K.y-c.current.scrollTop*X,width:c.current.scrollWidth*X,height:c.current.scrollHeight*X}}return(F=xr.current)==null?void 0:F.getBounds((C??0)+G,$)}},focus:()=>{var C;return(C=xr.current)==null?void 0:C.focus()},emit:async C=>{switch(C){case"delete":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await gu(void 0,!0);break;case"paste":await og();break}},scrollTo:bn,remeasureColumns:C=>{for(const $ of C)xf($+G)}}),[Bl,xf,gu,pu,og,G,bn]);const[Xw,Gw]=Vi??[],zR=v.useCallback(C=>{const[$,F]=C;if(F===-1){we!=="none"&&(ye(Nt.fromSingleSelection($),void 0,!1),ur());return}Xw===$&&Gw===F||(se({cell:C,range:{x:$,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),bn($,F))},[we,ur,bn,Xw,Gw,se,ye]),[BR,jR]=v.useState(!1),qw=v.useRef(zT(C=>{jR(C)},5)),HR=v.useCallback(()=>{qw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&se({cell:[G,pf],range:{x:G,y:pf,width:1,height:1}},!0,!1,"keyboard-select")},[pf,J,a,G,se]),WR=v.useCallback(()=>{qw.current(!1)},[]),[VR,UR]=v.useMemo(()=>{let C;const $=(We==null?void 0:We.scrollbarWidthOverride)??P0(),F=w+(on?1:0);if(typeof ar=="number")C=ct+F*ar;else{let X=0;const te=Math.min(F,10);for(let Q=0;Qte.width+X,0)+$;return[`${Math.min(1e5,K)}px`,`${Math.min(1e5,C)}px`]},[gt,We==null?void 0:We.scrollbarWidthOverride,ar,w,on,ct]),KR=v.useMemo(()=>C$(de),[de]);return v.createElement(T$.Provider,{value:de},v.createElement(v6,{style:KR,className:W,inWidth:x??VR,inHeight:g??UR},v.createElement(ZW,{fillHandle:Le,drawFocusRing:Ee,experimental:We,fixedShadowX:at,fixedShadowY:Ot,getRowThemeOverride:p,headerIcons:Xt,imageWindowLoader:Nn,initialSize:vr,isDraggable:Mn,onDragLeave:ms,onRowMoved:qn,overscrollX:Up,overscrollY:df,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:js,smoothScrollX:af,smoothScrollY:jp,className:W,enableGroups:zt,onCanvasFocused:HR,onCanvasBlur:WR,canvasRef:l,onContextMenu:IR,theme:de,cellXOffset:jo,cellYOffset:pf,accessibilityHeight:xn.height,onDragEnd:MR,columns:gt,nonGrowWidth:Be,drawHeader:qp,onColumnProposeMove:D,drawCell:Yp,disabledRows:_R,freezeColumns:$R,lockColumns:G,firstColAccessible:G===0,getCellContent:Fr,minColumnWidth:Nr,maxColumnWidth:yi,searchInputRef:o,showSearch:au,onSearchClose:Xp,highlightRegions:wR,getCellsForSelection:On,getGroupDetails:Jp,headerHeight:Dl,isFocused:BR,groupHeaderHeight:zt?lu:0,freezeTrailingRows:xt+(on&&(ut==null?void 0:ut.sticky)===!0?1:0),hasAppendRow:on,onColumnResize:wi,onColumnResizeEnd:Gp,onColumnResizeStart:Ll,onCellFocused:zR,onColumnMoved:ER,onDragStart:AR,onHeaderMenuClick:CR,onItemHovered:sg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:SR,onKeyDown:pu,onKeyUp:Fe,onMouseDown:xR,onMouseUp:kR,onDragOverCell:An,onDrop:z,onSearchResultsChanged:DR,onVisibleRegionChanged:TR,clientSize:Ae,rowHeight:ar,searchResults:V,searchValue:ge,onSearchValueChange:le,rows:Qn,scrollRef:c,selection:J,translateX:xn.tx,translateY:xn.ty,verticalBorder:LR,gridRef:xr,getCellRenderer:Ce}),FR,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(C6,{...i,validateCell:uu,bloom:P,id:PR,getCellRenderer:Ce,className:(We==null?void 0:We.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Bt,imageEditorOverride:h,onFinishEditing:OR,markdownDivCreateNode:m,isOutsideClick:uf}))))},M6=v.forwardRef(A6),Bb=20,R6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:ke.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>O6(t,t.cell.data,E0(t.cell),t.cell.maxSize??Bb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Bb,f=Math.floor(i.y+l/2),d=HT(c,l,s.cellVerticalPadding),h=jT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=BT(h,f,d),m=WT(a+n,u+r,p);if(E0(e)&&m)return{...e,data:LE(e.data)}},onPaste:(t,e)=>{let n=gh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Wv),n===e.data?void 0:{...e,data:n}}};function O6(t,e,n,r){if(!n&&e===gh)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:m}=l,x=.35;let g=n?1-x+x*s:.4;e===gh&&(g*=s),g!==0&&(i.globalAlpha=g,rw(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const P6=Qr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),I6=t=>{const{bubbles:e}=t;return v.createElement(P6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},N6={getAccessibilityString:t=>VT(t.data),kind:ke.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>_6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(I6,{bubbles:e.data})},onPaste:()=>{}},D6=4;function _6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=D6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=Zc(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)cs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+Bs(i,r))}const L6=Qr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),F6=t=>{const{drilldowns:e}=t;return v.createElement(L6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&v.createElement("img",{src:n.img}),v.createElement("div",null,n.text))))},$6={getAccessibilityString:t=>VT(t.data.map(e=>e.text)),kind:ke.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>j6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(F6,{drilldowns:e.data})},onPaste:()=>{}},z6=4,em={};function B6(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(em[d]!==void 0)return{el:em[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),em[d]=h,p.beginPath(),cs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),cs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function j6(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=rE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,m=8,x=z6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=B6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=Zc(b.text,i,c).width;let A=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+m*2;k.push({x:g,width:M}),g+=M+x}if(w!==null){const{el:b,height:S,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:_}=w,P=A/O,I=_/O;for(const D of k){const Z=Math.floor(D.x),ne=Math.floor(D.width),oe=ne-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,A,S,Z-I,h,P,d),oe>0&&i.drawImage(b,A,0,T,S,Z+(P-I),h,oe,d),i.drawImage(b,M-A,0,A,S,Z+ne-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,S]of k.entries()){const T=e[b];let A=S.x+m;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const O=p-8;let _=0,P=0,I=M.width,D=M.height;I>D?(_+=(I-D)/2,I=D):D>I&&(P+=(D-I)/2,D=I),i.beginPath(),cs(i,A,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,_,P,I,D,A,h+d/2-O/2,O,O),i.restore(),A+=O+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+Bs(i,r))}}const H6={getAccessibilityString:t=>t.data.join(", "),kind:ke.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>W6(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??N4;return v.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},tm=4;function W6(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,m=[];let x=0;for(let y=0;y0&&(a.beginPath(),cs(a,g,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(y,g,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),g+=w+tm}}function V6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const U6={getAccessibilityString:()=>"",kind:ke.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(V6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);cs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=wl(o.textDark,.1),i.fill()},onPaste:()=>{}},K6=()=>t=>t.targetWidth,jb=Qr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[K6(),"px"]}}),X6=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=v.useState(a===""||r),d=v.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?v.createElement(jb,{targetWidth:s.width-20},v.createElement(Cp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),v.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},v.createElement(E4,null))):v.createElement(jb,{targetWidth:s.width},v.createElement(J4,{contents:a,createNode:i}),!u&&v.createElement(v.Fragment,null,v.createElement("div",{className:"spacer"}),v.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},v.createElement(Gv,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},G6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:ef,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>As(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return v.createElement(X6,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},q6={getAccessibilityString:t=>t.row.toString(),kind:oi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:Y6,measure:()=>44,draw:t=>J6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function Y6(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=Q6,n.textAlign="center",s}function Q6(t){const{ctx:e}=t;e.textAlign="start"}function J6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(rw(o,u,n,i?c+m:c,f,i?d-m:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const g of[-5,-1,3])o.rect(c+x,f+h/2+g,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,g=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,g,f+h/2+Bs(o,x)),a!==0&&(o.globalAlpha=1)}}const Z6={getAccessibilityString:()=>"",kind:oi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>e9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function e9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const m=f-8,x=a+8/2,g=u+8/2;l.drawSprite(n,"normal",r,x,g,m,o,d?1:s),h=m}else{h=24;const p=12,m=d?p:s*p,x=d?0:(1-s)*p*.5,g=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+g+x,u+f/2),r.lineTo(a+g+x+m,u+f/2),r.moveTo(a+g+x+m*.5,u+f/2-m*.5),r.lineTo(a+g+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+Bs(r,o)),r.beginPath()}const t9=v.lazy(async()=>await uE(()=>import("./number-overlay-editor-TWdf9NmZ.js"),[])),n9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:ef,draw:t=>As(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return v.createElement(v.Suspense,{fallback:null},v.createElement(t9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},r9={getAccessibilityString:()=>"",measure:()=>108,kind:ke.Protected,needsHover:!1,needsHoverPosition:!1,draw:i9,onPaste:()=>{}};function i9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Hx(30))*l,f=Math.sin(Hx(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const s9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>ef(t,e,t.theme.textLight),draw:t=>As(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Ln.createElement(Cp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},o9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:ef,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=Zc(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),cs(i,s.x+d/2,s.y+(s.height-x)/2+1,p.width+d*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=wl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}As(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` +`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return v.createElement(Cp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},l9=Qr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),a9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=v.useState(!i&&(e===""||r)),u=v.useCallback(()=>{a(!0)},[]);return l?v.createElement(Cp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(l9,null,v.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&v.createElement("div",{className:"gdg-edit-icon",onClick:u},v.createElement(Gv,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Hb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const u9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:ke.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:ef,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=Zc(a,l,n.baseFontFull),f=Hb(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:m}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+m+8){const x=Bs(l,n.baseFontFull);r("pointer");const g=5,y=h-x;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+y+m+g)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+y+m+g)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,As({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),As({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),As({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),As({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,As(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=m$(o,s.baseFontFull);if(l===void 0)return;const a=Hb(l,n,s,e.contentAlign);Ep({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return v.createElement(a9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},c9=[q6,Z6,R6,N6,$6,H6,U6,G6,n9,r9,s9,o9,u9];var f9=$T,d9=El,h9="Expected a function";function p9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(h9);return d9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),f9(t,e,{leading:r,maxWait:e,trailing:i})}var g9=p9;const m9=Bi(g9),nm=[];class y9 extends sE{constructor(){super(...arguments);bt(this,"imageLoaded",()=>{});bt(this,"loadedLocations",[]);bt(this,"cache",{});bt(this,"sendLoaded",m9(()=>{this.imageLoaded(new ic(this.loadedLocations)),this.loadedLocations=[]},20));bt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,nm.length<12?nm.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(ew(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Pi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const rm="\uFEFF";function v9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function w9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=r.length)break;if(r[y]===s){c=y+1,f=!0;continue}c=r[y]==="\r"&&r[y+1]===` +`?y+2:y+1,o.push(a),l.push({start:u+i,end:y+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const d=o.length>0?o[0]:[],h=d.length,p=o.slice(1),m=p.map(g=>g.length),x=p.map(g=>g.length===h?g:g.length>h?g.slice(0,h):[...g,...Array(h-g.length).fill("")]);return{headers:d,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function Ap(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` +`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function im(t,e,n=","){return[t,...e].map(r=>Ap(r,n)).join(` +`)}function ow(t,e){return tf(t,e).headers}function x9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function FE(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function b9(t,e){return t[e]==="\r"?t[e+1]===` +`?2:1:t[e]===` +`?1:0}function Wb(t,e){return t[e-2]==="\r"&&t[e-1]===` +`?2:t[e-1]==="\r"||t[e-1]===` +`?1:0}const Vb="\uFEFF";function $E(t,e){const n=t.startsWith(Vb)?Vb.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Wb(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Wb(t,t.length)}}function sm(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+b9(t,i.end),replacement:""}));return r.length===0?t:FE(t,r)}function Ub(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:Ap(a,e.delimiter)})}return FE(t,s)}function k9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=$E(t,e),s=ow(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=Ap(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const V0=50;function Go(t=""){return{past:[],present:t,future:[]}}function Kb(t,e,n=V0){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function S9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function C9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>V0?r.slice(r.length-V0):r,present:e,future:n}}function T9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const Xb=/^[+-]?\d{16,}$/;function E9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),m=Number.isNaN(h);if(p||m)return p&&m?0:p?1:-1;if(Xb.test(a)&&Xb.test(u)){const x=BigInt(a),g=BigInt(u);return s*(xg?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const M9=` + +`;function Jf(t,e){return Math.max(0,Math.min(t,e))}function Gb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Jf(a.x,r+i),c=Jf(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=Jf(a.y,e.length),p=Jf(a.y+a.height,e.length);if(p<=h)continue;const m=t.headers.slice(f,d),x=[];for(let g=h;gw[f+b]??""))}x.length!==0&&s.push(im(m,x,t.delimiter))}if(s.length>0)return s.join(M9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return im(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return im(a,u,t.delimiter)}return null}const qo=1e5,R9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function O9(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const m of n.ranges){if(o.size>=qo)break;const x=Math.max(0,m.x-r),g=Math.min(i,m.x+m.width-r);if(g<=x)continue;const y=Math.max(0,m.y),w=Math.min(s,m.y+m.height);if(!(w<=y))for(let k=y;k=qo);k++){const b=k*i;for(let S=x;S=qo));S++);}}for(const m of n.rows){if(o.size>=qo)break;if(m<0||m>=s)continue;const x=m*i;for(let g=0;g=qo));g++);}for(const m of n.columns){if(o.size>=qo)break;const x=m-r;if(!(x<0||x>=i))for(let g=0;g=qo));g++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const m of o){const x=Math.floor(m/i),g=m%i,y=e[x],k=((y!==void 0?(p=t.rows[y])==null?void 0:p[g]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),R9.test(k)){const b=Number(k);Number.isFinite(b)&&(u+=1,c+=b,(f===null||bd)&&(d=b))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const qb=24,om=26,Yb=110,lm=40,P9=12,zn=1,Qb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',Jb='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',I9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function Zb(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function ek(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Xl="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",_d=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function Zf(t){return _d.format(Object.is(t,-0)?0:t)}function N9(t){const e=[`Cells: ${_d.format(t.cellCount)}`,`Distinct: ${_d.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${_d.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${Zf(t.sum)}`,`Avg: ${Zf(t.avg)}`,`Min: ${Zf(t.min)}`,`Max: ${Zf(t.max)}`),e.join(" · ")}function D9(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Jb,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:Jb,lineHeight:1}}function _9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function zE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u}){const c=v.useRef(null),f=v.useRef(null),d=v.useRef(null),[h,p]=v.useState(""),[m,x]=v.useState(""),[g,y]=v.useState(null),w=v.useRef(g);w.current=g;const k=v.useRef(null),[b,S]=v.useState(null),[T,A]=v.useState(""),M=v.useRef(null),[O,_]=v.useState(void 0),[P,I]=v.useState(()=>new Set),D=v.useRef(P),[Z,ne]=v.useState(0),[oe,W]=v.useState({}),U=i!==void 0,R=a??oe,N=v.useCallback(z=>{W(z),u==null||u(z)},[u]),L=v.useMemo(()=>D9(r),[r]),H=_9(r),q=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",B=v.useRef();B.current===void 0&&(B.current=new y9);const V=v.useMemo(()=>tf(t,e),[t,e]),le=v.useMemo(()=>x9(V),[V]),ge=V.headers.length,Me=v.useRef({text:t,table:V});Me.current={text:t,table:V};const Fe=v.useRef(O);Fe.current=O,v.useEffect(()=>{const z=window.setTimeout(()=>x(h),150);return()=>window.clearTimeout(z)},[h]);const _e=v.useMemo(()=>{const z=E9(V.rows,m);return g?A9(z,V.rows,g.col,g.dir,le[g.col]??!1):z},[V,m,g,le]),ft=v.useRef(_e);ft.current=_e,v.useEffect(()=>{const z=f.current;if(!z||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>ne(z.clientWidth));return ue.observe(z),ne(z.clientWidth),()=>ue.disconnect()},[]);const Xe=Math.max(Yb,Math.floor((Z-lm)/Math.max(1,ge)));v.useEffect(()=>{I(z=>{let ue=!1;const Y=new Set;for(const ce of z)ce{_(z=>{if(!z||z.rows.length===0)return z;const ue=[];for(const ce of D.current){const fe=_e.indexOf(ce);fe!==-1&&ue.push(fe)}ue.sort((ce,fe)=>ce-fe);const Y=ue.reduce((ce,fe)=>ce.add(fe),Nt.empty());return Y.equals(z.rows)?z:{...z,rows:Y}})},[_e]),v.useEffect(()=>{y(z=>z!==null&&z.col>=ge?null:z),S(z=>z!==null&&z.col>=ge?null:z)},[ge]);const Ge=m!=="",lt=V.rows.length,Ut=om+Math.min(_e.length,P9)*qb,Re=()=>{p(""),x("")},we=v.useCallback((z,ue)=>{var ce;if(z0||Le.height>0)?{x:Math.max(0,Ee.x-Le.left),y:Math.max(0,Ee.y-Le.top),width:Ee.width,height:Ee.height}:Ee??{x:lm+Y*Xe,y:0,width:Xe,height:om};A(fe),S({col:Y,bounds:We});return}k.current=w.current,S(null),y(fe=>!fe||fe.col!==Y?{col:Y,dir:"asc"}:fe.dir==="asc"?{col:Y,dir:"desc"}:null)},[U,Xe]),Qe=v.useCallback(()=>{if(!b)return;const{col:z}=b;if(S(null),!i)return;const{text:ue,table:Y}=Me.current,ce=Y.headers[z]??"",fe=k9(ue,Y,z,T);if(fe!==ue){if(ce!==""&&ce!==T&&R[ce]!==void 0){const Le={...R},Ee=Le[ce];delete Le[ce],T!==""&&Ee!==void 0&&(Le[T]=Ee),N(Le)}i(fe)}},[b,T,i,R,N]),nt=v.useCallback(()=>{S(null)},[]);v.useEffect(()=>{if(!b)return;const z=M.current;z&&(z.focus(),z.select())},[b]);const it=v.useCallback((z,ue)=>{const Y=ft.current,ce=Y[ue];if(ce===void 0)return;const fe=D.current,Le=d.current;let Ee;if(z.shiftKey&&Le!==null&&Le!==ce){const at=Y.indexOf(Le),Ot=Y.indexOf(ce),Xt=at===-1?Ot:at,[Nn,vr]=Xt<=Ot?[Xt,Ot]:[Ot,Xt];Ee=z.metaKey||z.ctrlKey?new Set(fe):new Set;for(let Mn=Nn;Mn<=vr;Mn++){const ms=Y[Mn];ms!==void 0&&Ee.add(ms)}}else z.metaKey||z.ctrlKey?(Ee=new Set(fe),Ee.has(ce)?Ee.delete(ce):Ee.add(ce)):Ee=new Set([ce]);d.current=ce,D.current=Ee,I(Ee);const We=[...Ee].map(at=>Y.indexOf(at)).filter(at=>at!==-1).sort((at,Ot)=>at-Ot);_(at=>({current:at==null?void 0:at.current,columns:(at==null?void 0:at.columns)??Nt.empty(),rows:We.reduce((Ot,Xt)=>Ot.add(Xt),Nt.empty())}))},[]),$e=v.useCallback(()=>{d.current=null,D.current=new Set,I(new Set),_(void 0)},[]),At=v.useCallback(z=>{const ue=new Set;for(const Y of z.rows){const ce=ft.current[Y];ce!==void 0&&ue.add(ce)}D.current=ue,I(ue),_(z)},[]),wt=v.useCallback(()=>{$e()},[$e]),rt=v.useMemo(()=>_e.filter(z=>P.has(z)),[_e,P]),me=v.useMemo(()=>[...(O==null?void 0:O.columns)??[]].filter(z=>z>=zn).map(z=>z-zn),[O]),Ne=me.length,Je=v.useMemo(()=>me.map(z=>V.headers[z]).filter(z=>z!==void 0),[me,V.headers]),tt=v.useMemo(()=>{if(Je.length===0)return null;const z=R[Je[0]]??"auto";for(let ue=1;ue{if(!U||Je.length===0)return;const ue={...R};for(const Y of Je)z==="auto"?delete ue[Y]:ue[Y]=z;N(ue)},[U,Je,R,N]),dt=v.useMemo(()=>U?V.headers.filter(z=>Zb(R[z])!==null).length:0,[U,V.headers,R]),ht=v.useMemo(()=>({ranges:O!=null&&O.current?[O.current.range,...O.current.rangeStack]:[],columns:O?[...O.columns]:[],rows:P.size>0?_e.reduce((z,ue,Y)=>(P.has(ue)&&z.push(Y),z),[]):O?[...O.rows]:[]}),[O,P,_e]),pt=zn,Lt=v.useMemo(()=>O9(V,_e,ht,pt),[V,_e,ht,pt]),Rt=rt.length>0||Ne>0||Lt!==null,en=v.useRef(l);en.current=l;const Hn=()=>{var Y,ce;const z=Fe.current,ue=Gb(Me.current.table,ft.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},zn);ue!==null&&((Y=en.current)==null||Y.call(en),(ce=navigator.clipboard)==null||ce.writeText(ue).catch(()=>{}))};v.useEffect(()=>{const z=ue=>{var Ee,We;const Y=c.current;if(!Y||!Y.contains(document.activeElement))return;const ce=document.activeElement;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable))return;const fe=Fe.current,Le=Gb(Me.current.table,ft.current,{ranges:fe!=null&&fe.current?[fe.current.range,...fe.current.rangeStack]:[],columns:fe?[...fe.columns]:[],rows:fe?[...fe.rows]:[]},zn);Le!==null&&(ue.preventDefault(),ue.stopImmediatePropagation(),(Ee=ue.clipboardData)==null||Ee.setData("text/plain",Le),(We=en.current)==null||We.call(en))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const z=ue=>{const Y=c.current;if(!Y)return;const ce=ue.target instanceof Node&&Y.contains(ue.target),fe=document.activeElement instanceof Node&&Y.contains(document.activeElement);if(!ce&&!fe||ek(ue.target)||ek(document.activeElement))return;const Le=T9(ue);Le==="undo"&&s?(ue.preventDefault(),s()):Le==="redo"&&o&&(ue.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Pt=v.useCallback(z=>{var Y;const ue=c.current!==null&&document.activeElement instanceof Node&&c.current.contains(document.activeElement);$e(),i==null||i(z),ue&&((Y=f.current)==null||Y.focus({preventScroll:!0}))},[$e,i]),vn=ge>0&&me.length>=ge,In=()=>{!U||rt.length===0||Pt(sm(Me.current.text,Me.current.table,rt))},Pr=()=>{!U||vn||me.length===0||Pt(Ub(Me.current.text,Me.current.table,me))},Ir=v.useCallback(z=>{if(!i)return!1;const{text:Y,table:ce}=Me.current,fe=ft.current;if(z.rows.length>0){const We=[...z.rows].map(at=>fe[at]).filter(at=>at!==void 0);if(We.length>0)return Pt(sm(Y,ce,We)),!1}if(z.columns.length>0){const We=[...z.columns].filter(at=>at>=zn&&atat-zn);return We.length>0&&We.length0&&Pt(sm(Y,ce,Ee)),!1},[Pt,i]),Bt=v.useCallback(z=>{const ue=i;if(!ue)return!1;const{text:Y,table:ce}=Me.current,fe=ft.current,Le=[...z].sort((at,Ot)=>at.location[1]-Ot.location[1]);let Ee=Y,We=0;for(const{location:at,value:Ot}of Le){const Xt=at[0]-zn,Nn=at[1];if(Xt<0||Ot.kind!==ke.Text)continue;const vr=fe[Nn],Mn=vr===void 0?void 0:ce.rowSpans[vr];if(!Mn)continue;const ms=Ee.slice(Mn.start+We,Mn.end+We),qn=ow(ms,ce.delimiter);for(;qn.length<=Xt;)qn.push("");const ys=Ot.data??"";if(qn[Xt]===ys)continue;qn[Xt]=ys;const vs=Ap(qn,ce.delimiter);Ee=Ee.slice(0,Mn.start+We)+vs+Ee.slice(Mn.end+We),We+=vs.length-(Mn.end-Mn.start)}return Ee!==Y&&ue(Ee),!0},[i]),ut=v.useCallback(z=>{var Le;const[ue,Y]=z,ce=ft.current[Y];if(ue{const ue=[];for(let Y=z.y;Y{z[0]>=zn||it(ue,z[1])},[it]),re=v.useMemo(()=>{const z={title:"#",id:"__gutter",width:lm,themeOverride:{baseFontStyle:`11px ${Qb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ue=V.headers.map((Y,ce)=>{const fe=U?Zb(R[Y]):null;return{title:fe?`${Y.toUpperCase()} [${fe}]`:Y.toUpperCase(),id:`c${ce}`,width:Xe,themeOverride:le[ce]?{baseFontStyle:`12px ${Qb}`}:void 0}});return[z,...ue]},[V.headers,le,Xe,U,R]),De=v.useCallback((z,ue)=>{const{ctx:Y,columnIndex:ce,rect:fe,theme:Le,isSelected:Ee}=z;Y.save();try{if(Y.letterSpacing="0.5px",Ee&&(Y.fillStyle=Le.bgHeaderHovered,Y.fillRect(fe.x,fe.y,fe.width,fe.height),Y.fillStyle=Le.accentColor,Y.fillRect(fe.x,fe.y+fe.height-2,fe.width,2)),ce{const{ctx:Y,cell:ce,rect:fe,col:Le,theme:Ee}=z,We=Le-zn;if(We>=0&&Ge&&ce.kind===ke.Text){const at=L9(ce.data,m);if(at!==null){Y.save();try{const Ot=`${Ee.baseFontStyle} ${Ee.fontFamily}`;Y.font=Ot;let Xt=fe.x+Ee.cellHorizontalPadding;const Nn=fe.y+fe.height/2+Bs(Y,Ot);for(const vr of at){const Mn=Y.measureText(vr.text).width;vr.hit&&Mn>0&&(Y.fillStyle=H,Y.fillRect(Xt-1,Nn-7,Mn+2,14)),Xt+=Mn}}finally{Y.restore()}}}if(ue(),We>=0&&ce.kind===ke.Text&&ce.data===""){Y.save();try{Y.font=`${Ee.baseFontStyle} ${Ee.fontFamily}`,Y.fillStyle=Ee.textLight,Y.fillText("—",fe.x+Ee.cellHorizontalPadding,fe.y+fe.height/2+.5)}finally{Y.restore()}}},[Ge,m,H]),An=v.useCallback(z=>{const ue=ft.current[z];return ue!==void 0&&D.current.has(ue)?{bgCell:q,bgCellMedium:q}:void 0},[q]);return ge===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:c,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(lN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:h,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Escape"&&Re()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),h!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Re,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(ph,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:Ge?`${_e.length.toLocaleString()} of ${lt.toLocaleString()}`:`${lt.toLocaleString()} rows`}),U&&dt>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>N({}),title:"Reset all pinned column types to Auto",className:Xl,children:[`${dt} ${dt===1?"column type":"column types"} pinned`,E.jsx(ph,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),Rt&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:rt.length>0?`${rt.length.toLocaleString()} selected`:Ne>0?`${Ne.toLocaleString()} ${Ne===1?"column":"columns"} selected`:`${((Lt==null?void 0:Lt.cellCount)??0).toLocaleString()} cells selected`}),Lt!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:N9(Lt)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Hn,className:Xl,children:[E.jsx(Nv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),U&&rt.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:In,title:`Deletes the ${rt.length} selected ${rt.length===1?"row":"rows"} from the source CSV`,className:Xl,children:[E.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",rt.length.toLocaleString()," ",rt.length===1?"row":"rows"]}),U&&Ne>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:I9.map(({mode:z,label:ue})=>{const Y=tt===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":Y,onClick:()=>Kt(z),className:Y?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:ue},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:Pr,disabled:vn,title:vn?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Ne} selected ${Ne===1?"column":"columns"} from the source CSV`,className:`${Xl} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(hh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Ne.toLocaleString()," ",Ne===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:$e,className:Xl,children:"Clear"})]})]}),E.jsxs("div",{ref:f,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":_e.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Ut},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(M6,{imageWindowLoader:B.current,renderers:c9,columns:re,rows:_e.length,getCellContent:ut,getCellsForSelection:xt,onCellsEdited:U?Bt:void 0,onDelete:U?Ir:void 0,onCellClicked:dn,onHeaderClicked:we,onGridSelectionChange:At,onSelectionCleared:wt,gridSelection:O,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:qb,headerHeight:om,freezeColumns:zn,fillHandle:U,onPaste:U?()=>!0:!1,keybindings:{search:!1},theme:L,drawHeader:De,drawCell:ze,getRowThemeOverride:An,minColumnWidth:Yb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),b!==null&&E.jsx("input",{ref:M,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${V.headers[b.col]??""}`,value:T,onChange:z=>A(z.target.value),onBlur:Qe,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),Qe()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),nt())},style:{left:b.bounds.x,top:b.bounds.y,width:Math.max(60,b.bounds.width),height:b.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),Ge&&_e.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:Re,className:Xl,children:"Show all rows"})]}),U&&!Ge&&_e.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function L9(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=v.useRef(null);v.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(XI,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=B9(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(hT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(uN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let U0=[],BE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=BE[r])e=r+1;else return!0;if(e==n)return!1}}function tk(t){return t>=127462&&t<=127487}const nk=8205;function W9(t,e,n=!0,r=!0){return(n?jE:V9)(t,e,r)}function jE(t,e,n){if(e==t.length)return e;e&&HE(t.charCodeAt(e))&&WE(t.charCodeAt(e-1))&&e--;let r=am(t,e);for(e+=rk(r);e=0&&tk(am(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function V9(t,e,n){for(;e>1;){let r=jE(t,e-2,n);if(r=56320&&t<57344}function WE(t){return t>=55296&&t<56320}function rk(t){return t<65536?1:2}class Dt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Fa(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),es.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Fa(this,e,n);let r=[];return this.decompose(e,n,r,0),es.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new sc(this),s=new sc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new sc(this,e)}iterRange(e,n=this.length){return new VE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new UE(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Dt.empty:e.length<=32?new Sn(e):es.from(Sn.split(e,[]))}}class Sn extends Dt{constructor(e,n=U9(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new K9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Sn(ik(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Ld(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Sn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Sn(l.slice(0,a)),new Sn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Sn))return super.replace(e,n,r);[e,n]=Fa(this,e,n);let i=Ld(this.text,Ld(r.text,ik(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Sn(i,s):es.from(Sn.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Sn(r,i)),r=[],i=-1);return i>-1&&n.push(new Sn(r,i)),n}}class es extends Dt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Fa(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new es(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof es))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof es)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Sn&&a&&(p=c[c.length-1])instanceof Sn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:es.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new es(l,n)}}Dt.empty=new Sn([""],0);function U9(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ld(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Sn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(i instanceof Sn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Sn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class VE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new sc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class UE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Dt.prototype[Symbol.iterator]=function(){return this.iter()},sc.prototype[Symbol.iterator]=VE.prototype[Symbol.iterator]=UE.prototype[Symbol.iterator]=function(){return this});class K9{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Fa(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function sr(t,e,n=!0,r=!0){return W9(t,e,n,r)}function X9(t){return t>=56320&&t<57344}function G9(t){return t>=55296&&t<56320}function q9(t,e){let n=t.charCodeAt(e);if(!G9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return X9(r)?(n-55296<<10)+(r-56320)+65536:n}function Y9(t){return t<65536?1:2}const K0=/\r\n?|\n/;var kr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(kr||(kr={}));class fs{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=kr.Simple&&u>=e&&(r==kr.TrackDel&&ie||r==kr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new fs(e)}static create(e){return new fs(e)}}class _n extends fs{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return X0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return G0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&po(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?Dt.of(h.split(r||K0)):h:Dt.empty,m=p.length;if(f==d&&m==0)return;fo&&rr(i,f-o,-1),rr(i,d-f,m),po(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new _n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function po(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function G0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Pc(t),l=new Pc(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);rr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Pc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Dt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Dt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ao{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new ao(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return he.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return he.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return he.range(e.anchor,e.head)}static create(e,n,r,i){return new ao(e,n,r,i)}}class he{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:he.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new he(e.ranges.map(n=>ao.fromJSON(n)),e.main)}static single(e,n=e){return new he([he.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?he.range(a,l):he.range(l,a))}}return new he(e,n)}}function XE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let lw=0;class je{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=lw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new je(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:aw),!!e.static,e.enables)}of(e){return new Fd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Fd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function aw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Fd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=lw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||q0(f,c)){let h=r(f);if(l?!sk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=Oh(d,p);if(this.dependencies.every(x=>x instanceof je?d.facet(x)===f.facet(x):x instanceof gs?d.field(x,!1)==f.field(x,!1):!0)||(l?sk(h=r(f),m,i):i(h=r(f),m)))return f.values[o]=m,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function sk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(ed).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(ed),o=i.facet(ed),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,ed.of({field:this,create:e})]}get extension(){return this}}const rl={lowest:4,low:3,default:2,high:1,highest:0};function Ou(t){return e=>new GE(e,t)}const uw={highest:Ou(rl.highest),high:Ou(rl.high),default:Ou(rl.default),low:Ou(rl.low),lowest:Ou(rl.lowest)};class GE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class dl{of(e){return new Y0(this,e)}reconfigure(e){return dl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Y0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Rh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of J9(e,n,o))d instanceof gs?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=c&&c[d]||[];if(h.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,aw(m,h))a.push(r.facet(p));else{let x=p.combine(h.map(g=>g.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of h)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(g=>x.dynamicSlot(g)));l[p.id]=u.length<<1,u.push(x=>Q9(x,p,h))}}let f=u.map(d=>d(l));return new Rh(e,o,f,l,a,s)}}function J9(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof Y0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof Y0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof GE)s(o.inner,o.prec);else if(o instanceof gs)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Fd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,rl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,rl.default),r.reduce((o,l)=>o.concat(l))}function oc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Oh(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qE=je.define(),Q0=je.define({combine:t=>t.some(e=>e),static:!0}),YE=je.define({combine:t=>t.length?t[0]:void 0,static:!0}),QE=je.define(),JE=je.define(),ZE=je.define(),eA=je.define({combine:t=>t.length?t[0]:!1});class Fo{constructor(e,n){this.type=e,this.value=n}static define(){return new Z9}}class Z9{of(e){return new Fo(this,e)}}class eV{constructor(e){this.map=e}of(e){return new qt(this,e)}}class qt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new qt(this.type,n)}is(e){return this.type==e}static define(e={}){return new eV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}qt.reconfigure=qt.define();qt.appendConfig=qt.define();class $n{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&XE(r,n.newLength),s.some(l=>l.type==$n.time)||(this.annotations=s.concat($n.time.of(Date.now())))}static create(e,n,r,i,s,o){return new $n(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation($n.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}$n.time=Fo.define();$n.userEvent=Fo.define();$n.addToHistory=Fo.define();$n.remote=Fo.define();function tV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof $n?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof $n?t=s[0]:t=nA(e,Sa(s),!1)}return t}function rV(t){let e=t.startState,n=e.facet(ZE),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=tA(r,J0(e,s,t.changes.newLength),!0))}return r==t?t:$n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const iV=[];function Sa(t){return t==null?iV:Array.isArray(t)?t:[t]}var Ps=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ps||(Ps={}));const sV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Z0;try{Z0=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function oV(t){if(Z0)return Z0.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||sV.test(n)))return!0}return!1}function lV(t){return e=>{if(!/\S/.test(e))return Ps.Space;if(oV(e))return Ps.Word;for(let n=0;n-1)return Ps.Word;return Ps.Other}}class $t{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(qt.reconfigure)?(n=null,r=l.value):l.is(qt.appendConfig)&&(n=null,r=Sa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Rh.resolve(r,i,this),s=new $t(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Q0)?e.newSelection:e.newSelection.asSingle();new $t(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:he.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Sa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return $t.create({doc:e.doc,selection:he.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Rh.resolve(e.extensions||[],new Map),r=e.doc instanceof Dt?e.doc:Dt.of((e.doc||"").split(n.staticFacet($t.lineSeparator)||K0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return XE(i,r.length),n.staticFacet(Q0)||(i=i.asSingle()),new $t(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet($t.tabSize)}get lineBreak(){return this.facet($t.lineSeparator)||` +`}get readOnly(){return this.facet(eA)}phrase(e,...n){for(let r of this.facet($t.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(qE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return lV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=sr(n,o,!1);if(s(n.slice(a,o))!=Ps.Word)break;o=a}for(;lt.length?t[0]:4});$t.lineSeparator=YE;$t.readOnly=eA;$t.phrases=je.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});$t.languageData=qE;$t.changeFilter=QE;$t.transactionFilter=JE;$t.transactionExtender=ZE;dl.reconfigure=qt.define();function rA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class xl{eq(e){return this==e}range(e,n=e){return ey.create(e,n,this)}}xl.prototype.startSide=xl.prototype.endSide=0;xl.prototype.point=!1;xl.prototype.mapMode=kr.TrackDel;function cw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let ey=class iA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new iA(e,n,r)}};function ty(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class fw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new fw(i,s,r,l):null,pos:o}}}class Ht{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Ht(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(ty)),this.isEmpty)return n.length?Ht.of(n):this;let l=new sA(this,null,-1).goto(0),a=0,u=[],c=new $a;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Ic.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Ic.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ok(o,l,r),u=new Pu(o,a,s),c=new Pu(l,a,s);r.iterGaps((f,d,h)=>lk(u,f,c,d,h,i)),r.empty&&r.length==0&&lk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ok(s,o),a=new Pu(s,l,0).goto(r),u=new Pu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ny(a.active,u.active)||a.point&&(!u.point||!cw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Pu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new $a;for(let i of e instanceof ey?[e]:n?aV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ht.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ht.empty;i=i.nextLayer)n=new Ht(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Ht.empty=new Ht([],[],null,-1);function aV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ty);e=r}return t}Ht.empty.nextLayer=Ht.empty;class $a{finishChunk(e){this.chunks.push(new fw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new $a)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Ht.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Ht.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ok(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new sA(o,n,r,s));return i.length==1?i[0]:new Ic(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)um(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)um(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),um(this.heap,0)}}}function um(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Pu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ic.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){td(this.active,e),td(this.activeTo,e),td(this.activeRank,e),this.minActive=ak(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;nd(this.active,n,r),nd(this.activeTo,n,i),nd(this.activeRank,n,s),e&&nd(e,n,this.cursor.from),this.minActive=ak(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&td(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function lk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&cw(t.point,n.point)&&ny(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ny(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function ny(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function ak(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=sr(t,i)}return t.length}const ry="ͼ",uk=typeof Symbol>"u"?"__"+ry:Symbol.for(ry),iy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),ck=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ro{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=ck[uk]||1;return ck[uk]=e+1,ry+e.toString(36)}static mount(e,n,r){let i=e[iy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new cV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let fk=new Map;class cV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=fk.get(r);if(s)return e[iy]=s;this.sheet=new i.CSSStyleSheet,fk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[iy]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fV=typeof navigator<"u"&&/Mac/.test(navigator.platform),dV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Kn=0;Kn<10;Kn++)Oo[48+Kn]=Oo[96+Kn]=String(Kn);for(var Kn=1;Kn<=24;Kn++)Oo[Kn+111]="F"+Kn;for(var Kn=65;Kn<=90;Kn++)Oo[Kn]=String.fromCharCode(Kn+32),Nc[Kn]=String.fromCharCode(Kn);for(var cm in Oo)Nc.hasOwnProperty(cm)||(Nc[cm]=Oo[cm]);function hV(t){var e=fV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Nc:Oo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function ts(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Te={mac:pk||/Mac/.test(dr.platform),windows:/Win/.test(dr.platform),linux:/Linux|X11/.test(dr.platform),ie:Rp,ie_version:lA?sy.documentMode||6:ly?+ly[1]:oy?+oy[1]:0,gecko:dk,gecko_version:dk?+(/Firefox\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,chrome:!!fm,chrome_version:fm?+fm[1]:0,ios:pk,android:/Android\b/.test(dr.userAgent),webkit:hk,webkit_version:hk?+(/\bAppleWebKit\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,safari:ay,safari_version:ay?+(/\bVersion\/(\d+(\.\d+)?)/.exec(dr.userAgent)||[0,0])[1]:0,tabSize:sy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function dw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Ph=Object.create(null);function hw(t,e,n){if(t==e)return!0;t||(t=Ph),e||(e=Ph);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function pV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function gk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function gV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new bl(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=aA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new bl(e,r,i,n,e.widget||null,!0)}static line(e){return new rf(e)}static set(e,n=!1){return Ht.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Vt.none=Ht.empty;class nf extends Vt{constructor(e){let{start:n,end:r}=aA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?dw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ph}eq(e){return this==e||e instanceof nf&&this.tagName==e.tagName&&hw(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}nf.prototype.point=!1;class rf extends Vt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof rf&&this.spec.class==e.spec.class&&hw(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}rf.prototype.mapMode=kr.TrackBefore;rf.prototype.point=!0;class bl extends Vt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?kr.TrackBefore:kr.TrackAfter:kr.TrackDel}get type(){return this.startSide!=this.endSide?fi.WidgetRange:this.startSide<=0?fi.WidgetBefore:fi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof bl&&mV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}bl.prototype.point=!0;function aA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function mV(t,e){return t==e||!!(t&&e&&t.compare(e))}function Ca(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class Dc extends xl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Dc&&this.tagName==e.tagName&&hw(this.attributes,e.attributes)}static create(e){return new Dc(e.tagName,e.attributes||Ph,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Ht.of(e,n)}}Dc.prototype.startSide=Dc.prototype.endSide=-1;function _c(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function uy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function lc(t,e){if(!e.anchorNode)return!1;try{return uy(t,e.anchorNode)}catch{return!1}}function ac(t){return t.nodeType==3?Fc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function uc(t,e,n,r){return n?mk(t,e,n,r,-1)||mk(t,e,n,r,1):!1}function Po(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Ih(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function mk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:$s(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Po(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?$s(t):0}else return!1}}function $s(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Lc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function yV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function uA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function vV(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,m=1;if(h)d=yV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let y=c.getBoundingClientRect();({scaleX:p,scaleY:m}=uA(c,y)),d={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*m}}let x=0,g=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(g=e.bottom-d.bottom+o,n<0&&e.top-g0&&e.right>d.right+x&&(x=e.right-d.right+s)):e.right>d.right-s&&(x=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function cA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class wV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?$s(n):0),r,Math.min(e.focusOffset,r?$s(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function fA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function dA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let el=null;Te.safari&&Te.safari_version>=26&&(el=!1);function hA(t){if(t.setActive)return t.setActive();if(el)return t.focus(el);let e=fA(t);t.focus(el==null?{get preventScroll(){return el={preventScroll:!0},!0}}:void 0),el||(el=!1,dA(e))}let yk;function Fc(t,e,n=e){let r=yk||(yk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function Ta(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function xV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function bV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,$s(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=$s(n))}else{if(n==t)return!0;r=Po(n),n=n.parentNode}}function pA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function gA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=$s(n)}else if(n.parentNode&&!Ih(n))r=Po(n),n=n.parentNode;else return null}}function mA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function wA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(Gi[m+1]==-h){let x=Gi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Gt[f]=Gt[Gi[m]]=g),l=m;break}}else{if(Gi.length==189)break;Gi[l++]=f,Gi[l++]=d,Gi[l++]=a}else if((p=Gt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=Gi[x+2];if(g&2)break;if(m)Gi[x+2]|=2;else{if(g&4)break;Gi[x+2]|=4}}}}}function AV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Gt[--p]=h;a=c}else s=u,a++}}}function fy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new ss(a,m.from,h));let x=m.direction==kl!=!(h%2);dy(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Gt[p]!=l:Gt[p]==l))break;p++}d?fy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Gt[a-1];m!=l&&(c=!1,f=m==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,g=u;;){if(x==e)break e;if(g&&s[g-1].to==x)x=s[--g].from;else{if(Gt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toGt.length;)Gt[Gt.length]=256;let r=[],i=e==kl?0:1;return dy(t,i,i,n,0,t.length,r),r}function xA(t){return[new ss(0,t,0)]}let bA="";function RV(t,e,n,r,i){var s;let o=r.head-t.from,l=ss.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=sr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),bA=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),PV=je.define({combine:t=>t.some(e=>e)}),RA=je.define();class Ea{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ea(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ea(he.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const rd=qt.define({map:(t,e)=>t.map(e)}),OA=qt.define();function li(t,e,n){let r=t.facet(TA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Ms=je.define({combine:t=>t.length?t[0]:!0});let IV=0;const ha=je.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Op.of(u=>{let c=u.plugin(l);return c?o(c):Vt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return gi.define((r,i)=>new e(r,i),n)}}class dm{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(li(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){li(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){li(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const PA=je.define(),yw=je.define(),Op=je.define(),IA=je.define(),vw=je.define(),sf=je.define(),NA=je.define();function vk(t,e){let n=t.state.facet(NA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Ht.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=OV(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:h,inner:[]};f.push(m),f=m.inner}}}}),i}const DA=je.define();function ww(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(DA)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Hu=je.define();class ai{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ai(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new ai(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Nh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const NV=[];class yn{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return NV}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&pV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Po(this.dom),i=this.length?e>0:n>0;return new Ni(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Ip)return e;return null}static get(e){return e.cmTile}}class Pp extends yn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=wk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=wk(i);this.length=o}}function wk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Ip extends Pp{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=yn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ns)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ns extends Pp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ns(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class za extends Pp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new za(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&_V(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):DV(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ni(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ni(a.dom,0);a==r.tile&&(l=!0)}}return new Ni(this.dom,0)}}function DV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ac(e);return n[n.length-1]||null}function _V(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Te.chrome||Te.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Te.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Lc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new al(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Sl extends yn{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Lc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class LV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Sr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(hm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=yn.get(a.dom);f&&f.setDOM(hm(a.dom))}let c=Sr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=yn.get(e.text);s&&this.cache.reused.set(s,2);let o=new al(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=_A);let i=za.start(e,n||((r=this.cache.find(za))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Sr&&l.mark.eq(o))i=l,n--;else{let a=Sr.of(o,(r=this.cache.find(Sr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!xk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Te.ios&&xk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(pm,0,32)||new Sl(pm.toDOM(),0,pm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new FV(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(Dh,void 0,1);return r&&(r.flags=n),r||new Dh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class zV{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const _h=[Sl,za,al,Sr,Dh,Ns,Ip];for(let t=0;t<_h.length;t++)_h[t].bucket=t;class BV{constructor(e){this.view=e,this.buckets=_h.map(()=>[]),this.index=_h.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Sr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Sr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Ht.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof bl){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Ba.block:Ba.inline),p=HV(u),m=this.cache.findWidget(h,a-l,p)||Sl.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=WV(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=yn.get(i);if(i==this.view.contentDOM)break;s instanceof Sr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ns||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new za(i,_A):r||n.push(Sr.of(new nf({tagName:i.nodeName.toLowerCase(),attributes:gV(i)}),i)))}return{line:r,marks:n}}}function xk(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function HV(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const _A={class:"cm-line"};function WV(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&dw(n,t),r&&(t.class+=" "+r)),t}function VV(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Sr&&e.push(r.mark)}return e}function hm(t){let e=yn.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ba extends nu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ba.inline=new Ba("span");Ba.block=new Ba("div");const pm=new class extends nu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class bk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Vt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Ip(e,e.contentDOM),this.updateInner([new ai(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!ZV(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?KV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ai(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Te.ie||Te.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=qV(o,this.decorations,e.changes);a.length&&(r=ai.extendWithRanges(r,a));let u=QV(l,this.blockWrappers,e.changes);return u.length&&(r=ai.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new jV(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&yn.get(n.text)&&l.cache.reused.set(yn.get(n.text),2),this.tile=l.run(e,n),py(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Te.chrome||Te.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&lc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Te.gecko&&a.empty&&!this.hasComposition&&UV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ni(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!uc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!uc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Te.android&&Te.chrome&&r.contains(f.focusNode)&&JV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=_c(this.view.root);if(d)if(a.empty){if(Te.gecko){let h=XV(u.node,u.offset);if(h&&h!=3){let p=(h==1?gA:mA)(u.node,u.offset);p&&(u=new Ni(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ni(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ni(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&uc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=_c(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=$s(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!yn.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof gm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==mn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let m=f.children[p],x=d+m.length,g=m.dom.getBoundingClientRect(),{height:y}=g;if(h&&!p&&(u+=g.top-h.top),m instanceof Ns)x>r&&c(m,d,g);else if(d>=r&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let w=m.dom.lastChild,k=w?ac(w):[];if(k.length){let b=k[k.length-1],S=a?b.right-g.left:g.right-b.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=x)}}h&&p==f.children.length-1&&(u+=h.bottom-g.bottom),d=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?mn.RTL:mn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=ac(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=ac(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Vt.replace({widget:new gm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Vt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Op).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(vw).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Ht.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(RA))try{if(u(this.view,e.range,e))return!0}catch(c){li(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=ww(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(vV(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){py(this.tile)}}function py(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)py(r,e)}}function UV(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function LA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=gA(n.focusNode,n.focusOffset),i=mA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=yn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=yn.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function KV(t,e,n){let r=LA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new ai(a.mapPos(s),a.mapPos(o),s,o),text:i}}function XV(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class gm extends nu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function eU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return he.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=sr(i.text,s,!1):l=sr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=sr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+uV(o,s,t.state.tabSize)}function nU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==fi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function rU(t,e,n,r){let i=nU(t,e.head,e.assoc||-1),s=!r||i.type!=fi.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==mn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return he.cursor(a,n?-1:1)}return he.cursor(n?i.to:i.from,n?-1:1)}function kk(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=RV(i,s,o,l,n),c=bA;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` +`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function iU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Ps.Space&&(i=o),i==o}}function sU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return he.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let m=l+(h+p)*s,x=gy(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:y{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:he.cursor(r,rt.viewState.docHeight)return new ns(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==fi.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==fi.Text){let f=tU(t,i,u,o,l);return new ns(f,f==u.from?1:-1)}}if(u.type!=fi.Text)return a<(u.top+u.bottom)/2?new ns(u.from,1):new ns(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new oU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class oU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let y=1;y=s&&(w-=p),!o.has(w)){m=w;break t}}break e}o.add(m);let x=n(m),g=0;if(x)for(let y=0;y1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),g=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==mn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return Fc(e.dom,o,l).getClientRects()});return i.after?new ns(r[i.i+1],-1):new ns(r[i.i],1)}scanTile(e,n){if(!e.length)return new ns(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:Fc(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new ns(r[i.i+1],-1):new ns(o,1)}}const Ql="￿";class lU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Ql}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=yn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=yn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Ih(i))||Ih(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!uU(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=yn.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(aU(e,r.node,r.offset)?n:0))}}function aU(t,e,n){for(;;){if(!e||n<$s(e))return!1;if(e==t)return!0;n=Po(e)+1,e=e.parentNode}}function uU(t,e){let n;for(;!(t==e||!t);t=t.nextSibling){let r=yn.get(t);if(!(r!=null&&r.isWidget()))return!1;r&&(n||(n=[])).push(r)}if(n)for(let r of n){let i=r.overrideDOMText;if(i!=null&&i.length)return!1}return!0}class Sk{constructor(e,n){this.node=e,this.offset=n,this.pos=-1}}class cU{constructor(e,n,r,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=n>-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=$A(e.docView.tile,n,r,0))){let a=s||o?[]:dU(e),u=new lU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=hU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!uy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!uy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Te.ios||Te.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(he.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=he.create([he.cursor(u,h)])}else this.newSel=he.single(c,u)}}}function $A(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return $A(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function zA(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Te.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Dt.of(e.text.slice(s.from-l,d).split(Ql))}:(h=BA(f,e.text,u-l,c))&&(Te.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Ql+Ql&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:Dt.of(e.text.slice(h.from,h.toB).split(Ql))})}else r&&(!t.hasFocus&&i.facet(Ms)||Lh(r,s))&&(r=null);if(!n&&!r)return!1;if((Te.mac||Te.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Dt.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Te.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Dt.of([" "])}),n)return xw(t,n,r,o);if(r&&!Lh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=FA(i.facet(sf).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function xw(t,e,n,r=-1){if(Te.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Te.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ta(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&Ta(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ta(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=fU(t,e,n));return t.state.facet(EA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function fU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:he.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&LA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-h,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let g=i.changes({from:x,to:m,insert:e.insert}),y=p.to-s.to;return{changes:g,range:u?he.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(g)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function BA(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function dU(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Sk(n,r)),(i!=n||s!=r)&&e.push(new Sk(i,s))),e}function hU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?he.single(n+e,r+e):null}function Lh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class pU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Te.safari&&e.contentDOM.addEventListener("input",()=>null),Te.gecko&&OU(e.contentDOM.ownerDocument)}handleEvent(e){!SU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=mU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&HA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Te.android&&Te.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Te.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(jA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||yU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Te.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&gU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Te.safari&&!Te.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function gU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Ck(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){li(n.state,i)}}}function mU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(Ck(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(Ck(r.value,a))}}for(let r in zi)n(r).handlers.push(zi[r]);for(let r in gr)n(r).observers.push(gr[r]);return e}const jA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],yU="dthko",HA=[16,17,18,20,91,92,224,225],id=6;function sd(t){return Math.max(0,t)*.7+8}function vU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class wU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=cA(e.contentDOM),this.atoms=e.state.facet(sf).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet($t.allowMultipleSelections)&&xU(e,n),this.dragging=kU(e,n)&&UA(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&vU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=ww(this.view);e.clientX-a.left<=i+id?n=-sd(i-e.clientX):e.clientX+a.right>=o-id&&(n=sd(e.clientX-o)),e.clientY-a.top<=s+id?r=-sd(s-e.clientY):e.clientY+a.bottom>=l-id&&(r=sd(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=FA(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function xU(t,e){let n=t.state.facet(kA);return n.length?n[0](e):Te.mac?e.metaKey:e.ctrlKey}function bU(t,e){let n=t.state.facet(SA);return n.length?n[0](e):Te.mac?!e.altKey:!e.ctrlKey}function kU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=_c(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function SU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=yn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const zi=Object.create(null),gr=Object.create(null),WA=Te.ie&&Te.ie_version<15||Te.ios&&Te.webkit_version<604;function CU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),VA(t,n.value)},50)}function Np(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function VA(t,e){e=Np(t.state,gw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(my!=null&&n.selection.ranges.every(a=>a.empty)&&my==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:he.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:he.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}gr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Te.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};gr.wheel=gr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};zi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);gr.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};gr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};gr.touchend=(t,e)=>{t.inputState.touchActive=!1};zi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(CA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=EU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new wU(t,e,n,r)),r&&t.observer.ignore(()=>{hA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Tk(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return eU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Ak+1)%3:1}function EU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=UA(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Tk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Tk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=AU(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function AU(t,e){for(let n=0;n=e)return he.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}zi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=he.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Np(t.state,mw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};zi.dragend=t=>(t.inputState.draggedContent=null,!1);function Rk(t,e,n,r){if(n=Np(t.state,gw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&bU(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}zi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Rk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Rk(t,e,r,!0),!0}return!1};zi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=WA?null:e.clipboardData;return n?(VA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(CU(t),!1)};function MU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function RU(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Np(t,mw,e.join(t.lineBreak)),ranges:n,linewise:r}}let my=null;zi.copy=zi.cut=(t,e)=>{if(!lc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=RU(t.state);if(!n&&!i)return!1;my=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=WA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(MU(t,n),!1)};const KA=Fo.define();function XA(t,e){let n=[];for(let r of t.facet(AA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:KA.of(!0)}):null}function GA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=XA(t.state,e);n?t.dispatch(n):t.update([])}},10)}gr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),GA(t)};gr.blur=t=>{t.observer.clearSelectionRange(),GA(t)};gr.compositionstart=gr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};gr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Te.chrome&&Te.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};gr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};zi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return xw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Te.chrome&&Te.android&&(i=jA.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Te.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Te.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>gr.compositionend(t,e),20),!1};const Ok=new Set;function OU(t){Ok.has(t)||(Ok.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Pk=["pre-wrap","normal","pre-line","break-spaces"];let ja=!1;function Ik(){ja=!1}class PU{constructor(e){this.lineWrapping=e,this.doc=Dt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Pk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>$d&&(ja=!0),this.height=e)}replace(e,n,r){return pr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,Jt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,Jt.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,Jt.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class jr extends qA{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof jr||i instanceof Un&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Un?i=new jr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):pr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Un extends pr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Un?r[r.length-1]=new Un(s.length+i):r.push(null,new Un(i-1))}if(e>0){let s=r[0];s instanceof Un?r[0]=new Un(e+s.length):r.unshift(new Un(e-1),null)}return pr.of(r)}decomposeLeft(e,n){n.push(new Un(e-1),null)}decomposeRight(e,n){n.push(null,new Un(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Un(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=$d&&(a=-2);let h=new jr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Un(s-l).updateHeight(e,l));let u=pr.of(o);return(a<0||Math.abs(u.height-this.height)>=$d||Math.abs(a-this.heightMetrics(e,n).perLine)>=$d)&&(ja=!0),Fh(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class DU extends pr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==Jt.ByPosNoHeight?Jt.ByPosNoHeight:Jt.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,Jt.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&Nk(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?pr.of(this.break?[e,null,n]:[e,n]):(this.left=Fh(this.left,e),this.right=Fh(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function Nk(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Un&&(r=t[e+1])instanceof Un&&t.splice(e-1,3,new Un(n.length+1+r.length))}const _U=5;class bw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof jr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new jr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=_U)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new jr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Un(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof jr)return e;let n=new jr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof jr)&&!this.isCovered?this.nodes.push(new jr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function zU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function BU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class ym{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new PU(r),this.stateDeco=Lk(n),this.heightMap=pr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle.setDoc(n.doc),[new ai(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Vt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new od(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?_k:new kw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Wu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Lk(this.state);let i=e.changedRanges,s=ai.extendWithRanges(i,LU(r,this.stateDeco,e?e.changes:_n.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Ik(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ja)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(PV)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:S}=uA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=b,this.scaleY=S,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=cA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=pA(this.scrollParent||e.win);let m=(this.printing?BU:$U)(n,this.paddingTop),x=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!zU(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:S,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=S>0&&i.refresh(s,S,T,A,Math.max(5,w/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&g>0?c=Math.max(x,g):x<0&&g<0&&(c=Math.min(x,g)),Ik();for(let S of this.viewports){let T=S.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?pr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle,[new ai(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new IU(S.from,T))}ja&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new od(i.lineAt(o-r*1e3,Jt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Jt.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,Jt.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=mn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&gg.from>=d.from&&g.to<=d.to&&Math.abs(g.from-c)g.fromy));if(!x){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(he.cursor(f),!1,!0).head;w>c&&(f=w)}let g=this.gapSize(d,c,f,h),y=r||g<2e6?g:2e6;x=new ym(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let S of e)S.from>=c.from&&S.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Ht.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Wu(this.heightMap.lineAt(e,Jt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Wu(this.heightMap.lineAt(this.scaler.fromDOM(e),Jt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Wu(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class od{constructor(e,n){this.from=e,this.to=n}}function HU(t,e,n){let r=[],i=t,s=0;return Ht.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function ad(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function WU(t,e){for(let n of t)if(e(n))return n}const _k={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Lk(t){let e=t.facet(Op).filter(r=>typeof r!="function"),n=t.facet(vw).filter(r=>typeof r!="function");return n.length&&e.push(Ht.join(n)),e}class kw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Jt.ByPos,e,0,0).top,c=n.lineAt(a,Jt.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Wu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ii(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Wu(i,e)):t._content)}const ud=je.define({combine:t=>t.join(" ")}),yy=je.define({combine:t=>t.indexOf(!0)>-1}),vy=Ro.newName(),YA=Ro.newName(),QA=Ro.newName(),JA={"&light":"."+YA,"&dark":"."+QA};function wy(t,e,n){return new Ro(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const VU=wy("."+vy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},JA),UU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vm=Te.ie&&Te.ie_version<=11;class KU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new wV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Te.ie&&Te.ie_version<=11||Te.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Te.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Te.chrome&&Te.chrome_version<126)&&(this.editContext=new GU(e),e.state.facet(Ms)&&(e.contentDOM.editContext=this.editContext.editContext)),vm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Ms)?r.root.activeElement!=this.dom:!lc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Te.ie&&Te.ie_version<=11||Te.android&&Te.chrome)&&!r.state.selection.main.empty&&i.focusNode&&uc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=_c(e.root);if(!n)return!1;let r=Te.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&XU(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=lc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ta(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&lc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new cU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=zA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Lh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=Fk(n,e.previousSibling||e.target.previousSibling,-1),i=Fk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Ms)!=e.state.facet(Ms)&&(e.view.contentDOM.editContext=e.state.facet(Ms)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function Fk(t,e,n){for(;e;){let r=yn.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function $k(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return uc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function XU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return $k(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?$k(t,n):null}class GU{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=BA(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=he.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Lh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:Dt.of(r.text.slice(c.from,c.toB).split(` +`))};if((Te.mac||Te.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:Dt.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);xw(e,f,he.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=_c(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ke{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||xV(e.parent)||document,this.viewState=new Dk(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(rd)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ha).map(i=>new dm(i));for(let i of this.plugins)i.update(this);this.observer=new KU(this),this.inputState=new pU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new bk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof $n?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(KA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=XA(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet($t.phrases)!=this.state.facet($t.phrases))return this.setState(s);i=Nh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:m}=this.state.facet(Ke.cursorScrollMargin);f=new Ea(h.empty?h:he.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",m,p)}for(let h of d.effects)h.is(rd)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=$h.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Hu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(ud)!=i.state.facet(ud)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(hy))try{d(i)}catch(h){li(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!zA(this,c)&&u.force&&Ta(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Dk(this,e),this.plugins=e.facet(ha).map(r=>new dm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new bk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ha),r=e.state.facet(ha);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new dm(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(pA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return li(this.state,p),zk}}),f=Nh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Te.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(hy))l(n)}get themeClasses(){return vy+" "+(this.state.facet(yy)?QA:YA)+" "+this.state.facet(ud)}updateAttrs(){let e=Bk(this,PA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ms)?"true":"false",class:"cm-content",style:`${Te.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Bk(this,yw,n);let r=this.observer.ignore(()=>{let i=gk(this.contentDOM,this.contentAttrs,n),s=gk(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(Ke.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Hu);let e=this.state.facet(Ke.cspNonce);Ro.mount(this.root,this.styleModules.concat(VU).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return mm(this,e,kk(this,e,n,r))}moveByGroup(e,n){return mm(this,e,kk(this,e,n,r=>iU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return he.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return rU(this,e,n,r)}moveVertically(e,n,r){return mm(this,e,sU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=gy(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),gy(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[ss.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==mn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(MA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>qU)return xA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||wA(s.isolates,r=vk(this,e))))return s.order;r||(r=vk(this,e));let i=MV(e.text,n,r);return this.bidiCache.push(new $h(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Te.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{hA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return rd.of(new Ea(typeof e=="number"?he.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return rd.of(new Ea(he.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return gi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return gi.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Ro.newName(),i=[ud.of(r),Hu.of(wy(`.${r}`,e))];return n&&n.dark&&i.push(yy.of(!0)),i}static baseTheme(e){return uw.lowest(Hu.of(wy("."+vy,e,JA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&yn.get(r)||yn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ke.styleModule=Hu;Ke.inputHandler=EA;Ke.clipboardInputFilter=gw;Ke.clipboardOutputFilter=mw;Ke.scrollHandler=RA;Ke.focusChangeEffect=AA;Ke.perLineTextDirection=MA;Ke.exceptionSink=TA;Ke.updateListener=hy;Ke.editable=Ms;Ke.mouseSelectionStyle=CA;Ke.dragMovesSelection=SA;Ke.clickAddsSelectionRange=kA;Ke.decorations=Op;Ke.blockWrappers=IA;Ke.outerDecorations=vw;Ke.atomicRanges=sf;Ke.bidiIsolatedRanges=NA;Ke.cursorScrollMargin=je.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});Ke.scrollMargins=DA;Ke.darkTheme=yy;Ke.cspNonce=je.define({combine:t=>t.length?t[0]:""});Ke.contentAttributes=yw;Ke.editorAttributes=PA;Ke.lineWrapping=Ke.contentAttributes.of({class:"cm-lineWrapping"});Ke.announce=qt.define();const qU=4096,zk={};class $h{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:mn.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&dw(o,n)}return n}const YU=Te.mac?"mac":Te.windows?"win":Te.linux?"linux":"key";function QU(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let uo=null;const e7=4e3;function t7(t,e=YU){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>QU(g,e));for(let g=1;g{let k=uo={view:w,prefix:y,scope:o};return setTimeout(()=>{uo==k&&(uo=null)},e7),!0}]})}let m=p.join(" ");i(m,!1);let x=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,xy))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let xy=null;function n7(t,e,n,r){xy=e;let i=hV(e),s=q9(i,0),o=Y9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;uo&&uo.view==n&&uo.scope==r&&(l=uo.prefix+" ",HA.indexOf(e.keyCode)<0&&(u=!0,uo=null));let f=new Set,d=x=>{if(x){for(let g of x.run)if(!f.has(g)&&(f.add(g),g(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,m;return h&&(d(h[l+cd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Te.windows&&e.ctrlKey&&e.altKey)&&!(Te.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Oo[e.keyCode])&&p!=i?(d(h[l+cd(p,e,!0)])||e.shiftKey&&(m=Nc[e.keyCode])!=i&&m!=p&&d(h[l+cd(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+cd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),xy=null,a}class r7 extends nu{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?ac(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Lc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function i7(t){let e=gi.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Vt.set([Vt.widget({widget:new r7(t),side:1}).range(0)]):Vt.none}get decorations(){return this.view.state.doc.length?Vt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Ke.contentAttributes.of({"aria-placeholder":t})]:e}const fd="-10000px";class eM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function s7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const wm=je.define({combine:t=>{var e,n,r;return{position:Te.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||s7}}}),Hk=new WeakMap,tM=gi.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(wm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new eM(t,nM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(wm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=fd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Te.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=ww(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(wm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=fd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,x=(e=Hk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||l7,y=this.view.textDirection==mn.LTR,w=d.width>r.right-r.left?y?r.left:r.right-d.width:y?Math.max(r.left,Math.min(f.left-(h?14:0)+g.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(h?14:0)-g.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-g.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(bw&&A.topS&&(S=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-t.parent.top)/s+"px",Wk(c,(w-t.parent.left)/i)):(c.style.top=S/s+"px",Wk(c,w/i)),h){let A=f.left+(y?g.x:-g.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:S,right:T,bottom:S+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=fd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Wk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const o7=Ke.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),l7={x:0,y:0},nM=je.define({enables:[tM,o7]}),zh=je.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class Dp{static create(e){return new Dp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new eM(e,zh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const a7=nM.compute([zh],t=>{let e=t.facet(zh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:Dp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),u7=je.define();class c7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==mn.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>li(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(tM),n=e?e.manager.tooltips.findIndex(r=>r.create==Dp.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!f7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!d7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const dd=4;function f7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-dd&&e.clientX<=r+dd&&e.clientY>=i-dd&&e.clientY<=s+dd}function d7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function h7(t,e={}){let n=qt.define(),r=new WeakMap,i=gs.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,kr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(p7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>zh.from(o)});const s=gi.define(o=>new c7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,u7.of(s),a7]}}const p7=qt.define(),Vk=je.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),g7=gi.fromClass(class{constructor(t){this.input=t.state.facet(by),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Vk);this.top=new hd(t,!0,e.topContainer),this.bottom=new hd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Vk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new hd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new hd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(by);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ke.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class hd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Uk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Uk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Uk(t){let e=t.nextSibling;return t.remove(),e}const by=je.define({enables:g7});class Ha extends xl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ha.prototype.elementClass="";Ha.prototype.toDOM=void 0;Ha.prototype.mapMode=kr.TrackBefore;Ha.prototype.startSide=Ha.prototype.endSide=-1;Ha.prototype.point=!0;const rM=1024;let m7=0;class xm{constructor(e,n){this.from=e,this.to=n}}class Tt{constructor(e={}){this.id=m7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Or.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class fc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const y7=Object.create(null);class Or{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):y7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Or(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Or.none=new Or("",Object.create(null),0,8);class Sw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|gn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Ew(Or.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Tn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Tn(Or.none,n,r,i)))}static build(e){return b7(e)}}Tn.empty=new Tn(Or.none,[],[],0);class Cw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Cw(this.buffer,this.index)}}class Io{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Or.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function $c(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&gn.EnterBracketed&&c instanceof Tn&&(d=fc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!iM(i,r,f,f+c.length))){if(c instanceof Io){if(s&gn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new go(new v7(o,c,e,f),null,h)}else if(s&gn.IncludeAnonymous||!c.type.isAnonymous||Tw(c)){let h;if(!(s&gn.IgnoreMounts)&&(h=fc.get(c))&&!h.overlay)return new di(h.tree,f,e,o);let p=new di(c,f,e,o);return s&gn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&gn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&gn.IgnoreOverlays)&&(i=fc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&gn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new di(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function Xk(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function ky(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class v7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class go extends sM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new go(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&gn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new go(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new go(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new go(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function oM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new di(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push($c(l,e,n,!1))}}return i?oM(i):r}class Sy{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~gn.EnterBracketed,e instanceof di)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof di?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&gn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&gn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&gn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&gn.IncludeAnonymous||l instanceof Io||!l.type.isAnonymous||Tw(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return ky(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Tw(t){return t.children.some(e=>e instanceof Io||!e.type.isAnonymous||Tw(e))}function b7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=rM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Cw(n,n.length):n,a=r.types,u=0,c=0;function f(b,S,T,A,M,O){let{id:_,start:P,end:I,size:D}=l,Z=c,ne=u;if(D<0)if(l.next(),D==-1){let N=s[_];T.push(N),A.push(P-b);return}else if(D==-3){u=_;return}else if(D==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${D}`);let oe=a[_],W,U,R=P-b;if(I-P<=i&&(U=x(l.pos-S,M))){let N=new Uint16Array(U.size-U.skip),L=l.pos-U.size,H=N.length;for(;l.pos>L;)H=g(U.start,N,H);W=new Io(N,I-U.start,r),R=U.start-b}else{let N=l.pos-D;l.next();let L=[],H=[],q=_>=o?_:-1,B=0,V=I;for(;l.pos>N;)q>=0&&l.id==q&&l.size>=0?(l.end<=V-i&&(p(L,H,P,B,l.end,V,q,Z,ne),B=L.length,V=l.end),l.next()):O>2500?d(P,N,L,H):f(P,N,L,H,q,O+1);if(q>=0&&B>0&&B-1&&B>0){let le=h(oe,ne);W=Ew(oe,L,H,0,L.length,0,I-P,le,le)}else W=m(oe,L,H,I-P,Z-I,ne)}T.push(W),A.push(R)}function d(b,S,T,A){let M=[],O=0,_=-1;for(;l.pos>S;){let{id:P,start:I,end:D,size:Z}=l;if(Z>4)l.next();else{if(_>-1&&I<_)break;_<0&&(_=D-i),M.push(P,I,D),O++,l.next()}}if(O){let P=new Uint16Array(O*4),I=M[M.length-2];for(let D=M.length-3,Z=0;D>=0;D-=3)P[Z++]=M[D],P[Z++]=M[D+1]-I,P[Z++]=M[D+2]-I,P[Z++]=Z;T.push(new Io(P,M[2]-I,r)),A.push(I-b)}}function h(b,S){return(T,A,M)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Tn){if(!_&&P.type==b&&P.length==M)return P;(I=P.prop(Tt.lookAhead))&&(O=A[_]+P.length+I)}return m(b,T,A,M,O,S)}}function p(b,S,T,A,M,O,_,P,I){let D=[],Z=[];for(;b.length>A;)D.push(b.pop()),Z.push(S.pop()+T-M);b.push(m(r.types[_],D,Z,O-M,P-O,I)),S.push(M-T)}function m(b,S,T,A,M,O,_){if(O){let P=[Tt.contextHash,O];_=_?[P].concat(_):[P]}if(M>25){let P=[Tt.lookAhead,M];_=_?[P].concat(_):[P]}return new Tn(b,S,T,A,_)}function x(b,S){let T=l.fork(),A=0,M=0,O=0,_=T.end-i,P={size:0,start:0,skip:0};e:for(let I=T.pos-b;T.pos>I;){let D=T.size;if(T.id==S&&D>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let Z=T.pos-D;if(D<0||Z=o?4:0,oe=T.start;for(T.next();T.pos>Z;){if(T.size<0)if(T.size==-3||T.size==-4)ne+=4;else break e;else T.id>=o&&(ne+=4);T.next()}M=oe,A+=D,O+=ne}return(S<0||A==b)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function g(b,S,T){let{id:A,start:M,end:O,size:_}=l;if(l.next(),_>=0&&A4){let I=l.pos-(_-4);for(;l.pos>I;)T=g(b,S,T)}S[--T]=P,S[--T]=O-b,S[--T]=M-b,S[--T]=A}else _==-3?u=A:_==-4&&(c=A);return T}let y=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new Tn(a[t.topID],y.reverse(),w.reverse(),k)}const Gk=new WeakMap;function zd(t,e){if(!t.isAnonymous||e instanceof Io||e.type!=t)return 1;let n=Gk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Tn)){n=1;break}n+=zd(t,r)}Gk.set(e,n)}return n}function Ew(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;S+=T}if(w==k+1){if(S>c){let T=p[k];h(T.children,T.positions,0,T.children.length,m[k]+y);continue}f.push(p[k])}else{let T=m[w-1]+p[w-1].length-b;f.push(Ew(t,p,m,k,w,b,T,null,a))}d.push(b+y-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class hl{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new hl(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new hl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew xm(i.from,i.to)):[new xm(0,0)]:[new xm(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class k7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});let S7=0;class ii{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=S7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof ii&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new ii(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new Bh(e);return r=>r.modified.indexOf(n)>-1?r:Bh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let C7=0;class Bh{constructor(e){this.name=e,this.instances=[],this.id=C7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&T7(n,l.modified));if(r)return r;let i=[],s=new ii(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=E7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Bh.get(l,a));return s}}function T7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function E7(t){let e=[[]];for(let n=0;nr.length-n.length)}function aM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new zc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return uM.add(e)}const uM=new Tt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new zc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class zc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function A7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function M7(t,e,n,r=0,i=t.length){let s=new R7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class R7{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=O7(e)||zc.empty,f=A7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(Tt.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(d.tree.type)),m=e.firstChild();for(let x=0,g=l;;x++){let y=x=w||!e.nextSibling())););if(!y||w>r)break;g=y.to+l,g>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+l),Math.min(r,g),"",p),this.startSpan(Math.min(r,g),u))}m&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function O7(t){let e=t.type.prop(uM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ve=ii.define,gd=ve(),io=ve(),qk=ve(io),Yk=ve(io),so=ve(),md=ve(so),bm=ve(so),Qi=ve(),Yo=ve(Qi),qi=ve(),Yi=ve(),Cy=ve(),Iu=ve(Cy),yd=ve(),Ue={comment:gd,lineComment:ve(gd),blockComment:ve(gd),docComment:ve(gd),name:io,variableName:ve(io),typeName:qk,tagName:ve(qk),propertyName:Yk,attributeName:ve(Yk),className:ve(io),labelName:ve(io),namespace:ve(io),macroName:ve(io),literal:so,string:md,docString:ve(md),character:ve(md),attributeValue:ve(md),number:bm,integer:ve(bm),float:ve(bm),bool:ve(so),regexp:ve(so),escape:ve(so),color:ve(so),url:ve(so),keyword:qi,self:ve(qi),null:ve(qi),atom:ve(qi),unit:ve(qi),modifier:ve(qi),operatorKeyword:ve(qi),controlKeyword:ve(qi),definitionKeyword:ve(qi),moduleKeyword:ve(qi),operator:Yi,derefOperator:ve(Yi),arithmeticOperator:ve(Yi),logicOperator:ve(Yi),bitwiseOperator:ve(Yi),compareOperator:ve(Yi),updateOperator:ve(Yi),definitionOperator:ve(Yi),typeOperator:ve(Yi),controlOperator:ve(Yi),punctuation:Cy,separator:ve(Cy),bracket:Iu,angleBracket:ve(Iu),squareBracket:ve(Iu),paren:ve(Iu),brace:ve(Iu),content:Qi,heading:Yo,heading1:ve(Yo),heading2:ve(Yo),heading3:ve(Yo),heading4:ve(Yo),heading5:ve(Yo),heading6:ve(Yo),contentSeparator:ve(Qi),list:ve(Qi),quote:ve(Qi),emphasis:ve(Qi),strong:ve(Qi),link:ve(Qi),monospace:ve(Qi),strikethrough:ve(Qi),inserted:ve(),deleted:ve(),changed:ve(),invalid:ve(),meta:yd,documentMeta:ve(yd),annotation:ve(yd),processingInstruction:ve(yd),definition:ii.defineModifier("definition"),constant:ii.defineModifier("constant"),function:ii.defineModifier("function"),standard:ii.defineModifier("standard"),local:ii.defineModifier("local"),special:ii.defineModifier("special")};for(let t in Ue){let e=Ue[t];e instanceof ii&&(e.name=t)}cM([{tag:Ue.link,class:"tok-link"},{tag:Ue.heading,class:"tok-heading"},{tag:Ue.emphasis,class:"tok-emphasis"},{tag:Ue.strong,class:"tok-strong"},{tag:Ue.keyword,class:"tok-keyword"},{tag:Ue.atom,class:"tok-atom"},{tag:Ue.bool,class:"tok-bool"},{tag:Ue.url,class:"tok-url"},{tag:Ue.labelName,class:"tok-labelName"},{tag:Ue.inserted,class:"tok-inserted"},{tag:Ue.deleted,class:"tok-deleted"},{tag:Ue.literal,class:"tok-literal"},{tag:Ue.string,class:"tok-string"},{tag:Ue.number,class:"tok-number"},{tag:[Ue.regexp,Ue.escape,Ue.special(Ue.string)],class:"tok-string2"},{tag:Ue.variableName,class:"tok-variableName"},{tag:Ue.local(Ue.variableName),class:"tok-variableName tok-local"},{tag:Ue.definition(Ue.variableName),class:"tok-variableName tok-definition"},{tag:Ue.special(Ue.variableName),class:"tok-variableName2"},{tag:Ue.definition(Ue.propertyName),class:"tok-propertyName tok-definition"},{tag:Ue.typeName,class:"tok-typeName"},{tag:Ue.namespace,class:"tok-namespace"},{tag:Ue.className,class:"tok-className"},{tag:Ue.macroName,class:"tok-macroName"},{tag:Ue.propertyName,class:"tok-propertyName"},{tag:Ue.operator,class:"tok-operator"},{tag:Ue.comment,class:"tok-comment"},{tag:Ue.meta,class:"tok-meta"},{tag:Ue.invalid,class:"tok-invalid"},{tag:Ue.punctuation,class:"tok-punctuation"}]);var km;const pa=new Tt;function P7(t){return je.define({combine:t?e=>e.concat(t):void 0})}const I7=new Tt;class Di{constructor(e,n,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return ds(this)}}),this.parser=n,this.extension=[Va.of(this),$t.languageData.of((s,o,l)=>{let a=Qk(s,o,l),u=a.type.prop(pa);if(!u)return[];let c=s.facet(u),f=a.type.prop(I7);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Qk(e,n,r).type.prop(pa)==this.data}findRegions(e){let n=e.facet(Va);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(pa)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Tt.mounted);if(l){if(l.tree.prop(pa)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new jh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function ds(t){let e=t.field(Di.state,!1);return e?e.tree:Tn.empty}class N7{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Nu=null;class Hh{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Hh(e,n,[],Tn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new N7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(hl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Nu;Nu=this;try{return e()}finally{Nu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Jk(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=hl.applyChanges(r,a),i=Tn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=Jk(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends lM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Nu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Tn(Or.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Nu}}function Jk(t,e,n){return hl.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Wa{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Wa(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Hh.create(e.facet(Va).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wa(r)}}Di.state=gs.define({create:Wa.init,update(t,e){for(let n of e.effects)if(n.is(Di.setState))return n.value;return e.startState.facet(Va)!=e.state.facet(Va)?Wa.init(e.state):t.apply(e)}});let fM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(fM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Sm=typeof navigator<"u"&&(!((km=navigator.scheduling)===null||km===void 0)&&km.isInputPending)?()=>navigator.scheduling.isInputPending():null,D7=gi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Di.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Di.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=fM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Sm&&Sm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Di.setState.of(new Wa(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>li(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Va=je.define({combine(t){return t.length?t[0]:null},enables:t=>[Di.state,D7,Ke.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class _7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const L7=je.define(),Aw=je.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Wh(t){let e=t.facet(Aw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Vh(t,e){let n="",r=t.tabSize,i=t.facet(Aw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?F7(t,n,e):null}class _p{constructor(e,n={}){this.state=e,this.options=n,this.unit=Wh(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Mp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const hM=new Tt;function F7(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return pM(r,t,n)}function pM(t,e,n){for(let r=t;r;r=r.next){let i=z7(r.node);if(i)return i(Mw.create(e,n,r))}return 0}function $7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function z7(t){let e=t.type.prop(hM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Tt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>W7(o,!0,1,void 0,s&&!$7(o)?i.from:void 0)}return t.parent==null?B7:null}function B7(){return 0}class Mw extends _p{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Mw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(j7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return pM(this.context.next,this.base,this.pos)}}function j7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function H7(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function W7(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=H7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function Zk({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const V7=new Tt;function U7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(pa)==o.data:o?l=>l==o:void 0,this.style=cM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Ro(r):null,this.themeType=n.themeType}static define(e,n){return new Lp(e,n||{})}}const Ty=je.define(),K7=je.define({combine(t){return t.length?[t[0]]:null}});function Cm(t){let e=t.facet(Ty);return e.length?e:t.facet(K7)}function eS(t,e){let n=[G7],r;return t instanceof Lp&&(t.module&&n.push(Ke.styleModule.of(t.module)),r=t.themeType),r?n.push(Ty.computeN([Ke.darkTheme],i=>i.facet(Ke.darkTheme)==(r=="dark")?[t]:[])):n.push(Ty.of(t)),n}class X7{constructor(e){this.markCache=Object.create(null),this.tree=ds(e.state),this.decorations=this.buildDeco(e,Cm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=ds(e.state),r=Cm(e.state),i=r!=Cm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Vt.none;let r=new $a;for(let{from:i,to:s}of e.visibleRanges)M7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Vt.mark({class:a})))},i,s);return r.finish()}}const G7=uw.high(gi.fromClass(X7,{decorations:t=>t.decorations})),q7=1e4,Y7="()[]{}",Q7=new Tt;function Ey(t,e,n){let r=t.prop(e<0?Tt.openedBy:Tt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function Ay(t){let e=t.type.prop(Q7);return e?e(t.node):t}function ga(t,e,n,r={}){let i=r.maxScanDistance||q7,s=r.brackets||Y7,o=ds(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ey(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return J7(t,e,n,a,c,u,s)}}return Z7(t,e,n,o,l.type,i,s)}function J7(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let m=n>0?0:h.length-1,x=n>0?h.length:-1;m!=x;m+=n){let g=o.indexOf(h[m]);if(!(g<0||r.resolveInner(p+m,1).type!=i))if(g%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const eK=Object.create(null),tS=[Or.none],nS=[],rS=Object.create(null),tK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])tK[t]=nK(eK,e);function Tm(t,e){nS.indexOf(t)>-1||(nS.push(t),console.warn(e))}function nK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ue[u];c?typeof c=="function"?a.length?a=a.map(c):Tm(u,`Modifier ${u} used at start of tag`):a.length?Tm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Tm(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=rS[i];if(s)return s.id;let o=rS[i]=Or.define({id:tS.length,name:r,props:[aM({[r]:n})]});return tS.push(o),o.id}mn.RTL,mn.LTR;const rK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Ow(t.state,n.from);return r.line?iK(t):r.block?oK(t):!1};function Rw(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const iK=Rw(uK,0),sK=Rw(gM,0),oK=Rw((t,e)=>gM(t,e,aK(e)),0);function Ow(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Du=50;function lK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Du,r),o=t.sliceDoc(i,i+Du),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Du?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Du),f=t.sliceDoc(i-Du,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function aK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function gM(t,e,n=e.selection.ranges){let r=n.map(s=>Ow(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>lK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const My=Fo.define(),cK=Fo.define(),fK=je.define(),mM=je.define({combine(t){return rA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),yM=gs.define({create(){return os.empty},update(t,e){let n=e.state.facet(mM),r=e.annotation(My);if(r){let a=Er.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Uh(c,c.length,n.minDepth,a):c=xM(c,e.startState.selection),new os(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(cK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation($n.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Er.fromTransaction(e),o=e.annotation($n.time),l=e.annotation($n.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new os(t.done.map(Er.fromJSON),t.undone.map(Er.fromJSON))}});function dK(t={}){return[yM,mM.of(t),Ke.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?vM:e.inputType=="historyRedo"?Ry:null;return r?(e.preventDefault(),r(n)):!1}})]}function Fp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(yM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const vM=Fp(0,!1),Ry=Fp(1,!1),hK=Fp(0,!0),pK=Fp(1,!0);class Er{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Er(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Er(e.changes&&_n.fromJSON(e.changes),[],e.mapped&&fs.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=ui;for(let i of e.startState.facet(fK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Er(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ui)}static selection(e){return new Er(void 0,ui,void 0,void 0,e)}}function Uh(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function gK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function mK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function wM(t,e){return t.length?e.length?t.concat(e):t:e}const ui=[],yK=200;function xM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-yK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Uh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Er.selection([e])]}function vK(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Em(t,e){if(!t.length)return t;let n=t.length,r=ui;for(;n;){let i=wK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Er.selection(r)]:ui}function wK(t,e,n){let r=wM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ui,n);if(!t.changes)return Er.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Er(i,qt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const xK=/^(input\.type|delete)($|\.)/;class os{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new os(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||xK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):$p(n,e))}function lr(t){return t.textDirectionAt(t.state.selection.main.head)==mn.LTR}const kM=t=>bM(t,!lr(t)),SM=t=>bM(t,lr(t));function CM(t,e){return Hi(t,n=>n.empty?t.moveByGroup(n,e):$p(n,e))}const kK=t=>CM(t,!lr(t)),SK=t=>CM(t,lr(t));function CK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function zp(t,e,n){let r=ds(t).resolveInner(e.head),i=n?Tt.closedBy:Tt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;CK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ga(t,r.from,1):ga(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,he.cursor(l,n?-1:1)}const TK=t=>Hi(t,e=>zp(t.state,e,!lr(t))),EK=t=>Hi(t,e=>zp(t.state,e,lr(t)));function TM(t,e){return Hi(t,n=>{if(!n.empty)return $p(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const EM=t=>TM(t,!1),AM=t=>TM(t,!0);function MM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):$p(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomRM(t,!1),Oy=t=>RM(t,!0);function $o(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=he.cursor(r.from+s))}return i}const AK=t=>Hi(t,e=>$o(t,e,!0)),MK=t=>Hi(t,e=>$o(t,e,!1)),RK=t=>Hi(t,e=>$o(t,e,!lr(t))),OK=t=>Hi(t,e=>$o(t,e,lr(t))),PK=t=>Hi(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),IK=t=>Hi(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function NK(t,e,n){let r=!1,i=ru(t.selection,s=>{let o=ga(t,s.head,-1)||ga(t,s.head,1)||s.head>0&&ga(t,s.head-1,1)||s.headNK(t,e);function mi(t,e,n){let r=ru(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=he.range(i.head,i.anchor));let s=n(i);return he.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(ji(t.state,r)),!0)}function OM(t,e){return mi(t,e,n=>t.moveByChar(n,e))}const PM=t=>OM(t,!lr(t)),IM=t=>OM(t,lr(t));function NM(t,e){return mi(t,e,n=>t.moveByGroup(n,e))}const _K=t=>NM(t,!lr(t)),LK=t=>NM(t,lr(t)),FK=t=>{let e=!lr(t);return mi(t,e,n=>zp(t.state,n,e))},$K=t=>{let e=lr(t);return mi(t,e,n=>zp(t.state,n,e))};function DM(t,e){return mi(t,e,n=>t.moveVertically(n,e))}const _M=t=>DM(t,!1),LM=t=>DM(t,!0);function FM(t,e){return mi(t,e,n=>t.moveVertically(n,e,MM(t).height))}const sS=t=>FM(t,!1),oS=t=>FM(t,!0),zK=t=>mi(t,!0,e=>$o(t,e,!0)),BK=t=>mi(t,!1,e=>$o(t,e,!1)),jK=t=>{let e=!lr(t);return mi(t,e,n=>$o(t,n,e))},HK=t=>{let e=lr(t);return mi(t,e,n=>$o(t,n,e))},WK=t=>mi(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),VK=t=>mi(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),lS=({state:t,dispatch:e})=>(e(ji(t,{anchor:0})),!0),aS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.doc.length})),!0),uS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.selection.main.anchor,head:0})),!0),cS=({state:t,dispatch:e})=>(e(ji(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),UK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),KK=({state:t,dispatch:e})=>{let n=Bp(t).map(({from:r,to:i})=>he.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:he.create(n),userEvent:"select"})),!0},XK=({state:t,dispatch:e})=>{let n=ru(t.selection,r=>{let i=ds(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return he.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(ji(t,n)),!0)};function $M(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(ji(n,he.create(i,i.length-1))),!0)}const GK=t=>$M(t,!1),qK=t=>$M(t,!0),YK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=he.create([n.main]):n.main.empty||(r=he.create([he.cursor(n.main.head)])),r?(e(ji(t,r)),!0):!1};function of(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=vd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=vd(t,o,!1),l=vd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:he.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const zM=(t,e,n)=>of(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&izM(t,!1,!0),BM=t=>zM(t,!0,!1),jM=(t,e)=>of(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=sr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),HM=t=>jM(t,!1),QK=t=>jM(t,!0),JK=t=>of(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headof(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),eX=t=>of(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Dt.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},nX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:sr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:sr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:he.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Bp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function WM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Bp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(he.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(he.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:he.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rX=({state:t,dispatch:e})=>WM(t,e,!1),iX=({state:t,dispatch:e})=>WM(t,e,!0);function VM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Bp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const sX=({state:t,dispatch:e})=>VM(t,e,!1),oX=({state:t,dispatch:e})=>VM(t,e,!0),lX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Bp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function aX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=ds(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Tt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const fS=UM(!1),uX=UM(!0);function UM(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&aX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new _p(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=dM(u,s);for(c==null&&(c=Mp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:he.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const cX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new _p(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Pw(t,(s,o,l)=>{let a=dM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Vh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(Pw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Aw)})}),{userEvent:"input.indent"})),!0),XM=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Pw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Mp(i,t.tabSize),o=0,l=Vh(t,Math.max(0,s-Wh(t)));for(;o(t.setTabFocusMode(),!0),dX=[{key:"Ctrl-b",run:kM,shift:PM,preventDefault:!0},{key:"Ctrl-f",run:SM,shift:IM},{key:"Ctrl-p",run:EM,shift:_M},{key:"Ctrl-n",run:AM,shift:LM},{key:"Ctrl-a",run:PK,shift:WK},{key:"Ctrl-e",run:IK,shift:VK},{key:"Ctrl-d",run:BM},{key:"Ctrl-h",run:Py},{key:"Ctrl-k",run:JK},{key:"Ctrl-Alt-h",run:HM},{key:"Ctrl-o",run:tX},{key:"Ctrl-t",run:nX},{key:"Ctrl-v",run:Oy}],hX=[{key:"ArrowLeft",run:kM,shift:PM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kK,shift:_K,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:RK,shift:jK,preventDefault:!0},{key:"ArrowRight",run:SM,shift:IM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:SK,shift:LK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:OK,shift:HK,preventDefault:!0},{key:"ArrowUp",run:EM,shift:_M,preventDefault:!0},{mac:"Cmd-ArrowUp",run:lS,shift:uS},{mac:"Ctrl-ArrowUp",run:iS,shift:sS},{key:"ArrowDown",run:AM,shift:LM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:aS,shift:cS},{mac:"Ctrl-ArrowDown",run:Oy,shift:oS},{key:"PageUp",run:iS,shift:sS},{key:"PageDown",run:Oy,shift:oS},{key:"Home",run:MK,shift:BK,preventDefault:!0},{key:"Mod-Home",run:lS,shift:uS},{key:"End",run:AK,shift:zK,preventDefault:!0},{key:"Mod-End",run:aS,shift:cS},{key:"Enter",run:fS,shift:fS},{key:"Mod-a",run:UK},{key:"Backspace",run:Py,shift:Py,preventDefault:!0},{key:"Delete",run:BM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:HM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QK,preventDefault:!0},{mac:"Mod-Backspace",run:ZK,preventDefault:!0},{mac:"Mod-Delete",run:eX,preventDefault:!0}].concat(dX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),pX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:TK,shift:FK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:EK,shift:$K},{key:"Alt-ArrowUp",run:rX},{key:"Shift-Alt-ArrowUp",run:sX},{key:"Alt-ArrowDown",run:iX},{key:"Shift-Alt-ArrowDown",run:oX},{key:"Mod-Alt-ArrowUp",run:GK},{key:"Mod-Alt-ArrowDown",run:qK},{key:"Escape",run:YK},{key:"Mod-Enter",run:uX},{key:"Alt-l",mac:"Ctrl-l",run:KK},{key:"Mod-i",run:XK,preventDefault:!0},{key:"Mod-[",run:XM},{key:"Mod-]",run:KM},{key:"Mod-Alt-\\",run:cX},{key:"Shift-Mod-k",run:lX},{key:"Shift-Mod-\\",run:DK},{key:"Mod-/",run:rK},{key:"Alt-A",mac:"Ctrl-A",run:sK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:fX}].concat(hX),gX={key:"Tab",run:KM,shift:XM};var dS={};class Kh{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Kh(e,[],n,r,r,0,[],0,i?new hS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Kh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new mX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class hS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class mX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Xh{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Xh(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Xh(this.stack,this.pos,this.index)}}function wd(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class Bd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const pS=new Bd;class yX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=pS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=pS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Aa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;vX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Aa.prototype.contextual=Aa.prototype.fallback=Aa.prototype.extend=!1;Aa.prototype.fallback=Aa.prototype.extend=!1;function vX(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||wX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function gS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function wX(t,e,n,r){let i=gS(n,r,e);return i<0||gS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class xX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?mS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?mS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Tn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class bX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Bd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new Bd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Bd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new xX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&CX(i);if(o)return $r&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw $r&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return $r&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(Tt.contextHash)||0)==c))return e.useNode(f,d),$r&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Tn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Tn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),$r&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return yS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),$r&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&($r&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)$r&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))$r&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),$r&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),yS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Sw(n.map((l,a)=>Or.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=rM;let o=wd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Aa(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new kX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Es(this.data,s+2);else break;i=n(Es(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Es(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(Gh.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=vS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const TX=aM({String:Ue.string,Number:Ue.number,"True False":Ue.bool,PropertyName:Ue.propertyName,Null:Ue.null,", :":Ue.separator,"[ ]":Ue.squareBracket,"{ }":Ue.brace}),EX=Gh.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[TX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),AX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=MX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function MX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const RX=jh.define({name:"json",parser:EX.configure({props:[hM.add({Object:Zk({except:/^\s*\}/}),Array:Zk({except:/^\s*\]/})}),V7.add({"Object Array":U7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function wS(){return new _7(RX)}class xS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class il{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(ls).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new $a,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),h++}for(;hw.from||w.to==m))l.push(w),h++,x=Math.min(w.to,x);else{x=Math.min(w.from,x);break}}x=Math.min(x,f);let g=!1;if(l.some(w=>w.from==m&&(w.to==x||x==f))&&(g=m==x,!g&&x-m<10)){let w=m-(c+u.value.length);w>0&&(u.next(w),c=m);for(let k=m;;){if(k>=x){g=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=WX(l);if(g)o.add(m,m,Vt.widget({widget:new zX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Vt.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new xS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new xS(r.from,s,r.diagnostic)}}),r}function OX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(ls).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Iw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function PX(t,e){return t.field(_i,!1)?e:e.concat(qt.appendConfig.of(JM))}function IX(t,e){return{effects:PX(t,[Iw.of(e)])}}const Iw=qt.define(),GM=qt.define(),qM=qt.define(),_i=gs.define({create(){return new il(Vt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=Ua(n,t.selected.diagnostic,s)||Ua(n,null,s)}!n.size&&i&&e.state.facet(ls).autoPanel&&(i=null),t=new il(n,i,r)}for(let n of e.effects)if(n.is(Iw)){let r=e.state.facet(ls).autoPanel?n.value.length?qh.open:null:t.panel;t=il.init(n.value,r,e.state)}else n.is(GM)?t=new il(t.diagnostics,n.value?qh.open:null,t.selected):n.is(qM)&&(t=new il(t.diagnostics,t.panel,n.value));return t},provide:t=>[by.from(t,e=>e.panel),Ke.decorations.from(t,e=>e.diagnostics)]}),NX=Vt.mark({class:"cm-lintRange cm-lintRange-active"});function DX(t,e,n){let{diagnostics:r}=t.state.field(_i),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(eQM(t,n,!1)))}const bS=t=>{let e=t.state.field(_i,!1);return!e||!e.panel?!1:(t.dispatch({effects:GM.of(!1)}),!0)},LX=gi.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(ls);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(IX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{li(this.view.state,r)})}}update(t){let e=t.state.facet(ls);(t.docChanged||e!=t.startState.facet(ls)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function FX(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const ls=je.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...rA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:kS,tooltipFilter:kS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function kS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function $X(t,e={}){return[ls.of({source:t,config:e}),LX,JM]}function YM(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function QM(t,e,n){var r;let i=n?YM(e.actions):[];return ts("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ts("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=Ua(t.state.field(_i).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),ts("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return ts("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&ts("div",{class:"cm-diagnosticSource"},e.source))}class zX extends nu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ts("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class SS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QM(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)bS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=YM(s.actions);for(let l=0;l{for(let s=0;sbS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(_i).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(_i),r=Ua(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:qM.of(r)})}static open(e){return new qh(e)}}function BX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function xd(t){return BX(``,'width="6" height="3"')}const jX=Ke.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:xd("#f11")},".cm-lintRange-warning":{backgroundImage:xd("orange")},".cm-lintRange-info":{backgroundImage:xd("#999")},".cm-lintRange-hint":{backgroundImage:xd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function HX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function WX(t){let e="hint",n=1;for(let r of t){let i=HX(r.severity);i>n&&(n=i,e=r.severity)}return e}const VX=h7(DX,{hideOn:OX}),JM=[_i,Ke.decorations.compute([_i],t=>{let{selected:e,panel:n}=t.field(_i);return!e||!n||e.from==e.to?Vt.none:Vt.set([NX.range(e.from,e.to)])}),VX,jX],UX=512*1024,CS=512*1024,ZM=2e6;function KX(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` +`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const XX=t=>t.state.doc.length>UX?[]:AX()(t);function TS(t){return Lp.define([{tag:Ue.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ue.string,color:t?"#86efac":"#15803d"},{tag:Ue.number,color:t?"#fcd34d":"#b45309"},{tag:Ue.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ue.null,color:t?"#a1a1aa":"#71717a"}])}const GX=Ke.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function eR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=v.useRef(null),c=v.useRef(null),f=v.useRef(e);f.current=e;const d=v.useRef(i),h=v.useRef(null),p=v.useRef(null),m=v.useRef(null),x=n??e!==void 0,g=v.useRef(x),y=v.useRef(r),w=t.length>CS,k=v.useRef(w),b=!x&&t.length>ZM,S=b?KX(t,CS):t,T=v.useRef(!1),A=v.useCallback((M,O,_)=>M?[Ke.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[$X(XX,{delay:300})]]:[$t.readOnly.of(!0),Ke.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new dl,_=new dl,P=new dl,I=$t.create({doc:S,extensions:[P.of(w||!r?[]:wS()),Ke.lineWrapping,dK(),ZA.of([...pX,...bK,gX]),GX,O.of(eS(TS(i))),_.of(A(x,w,r)),...s?[i7(s)]:[]]}),D=new Ke({state:I,parent:M});return h.current=O,p.current=_,m.current=P,a==null||a(D),c.current=D,()=>{D.destroy(),c.current=null}},[]),v.useEffect(()=>{const M=c.current;if(!M)return;const O=m.current,_=p.current,P=[];(w!==k.current||r!==y.current)&&(k.current=w,y.current=r,O&&P.push(O.reconfigure(w||!r?[]:wS())),_&&P.push(_.reconfigure(A(x,w,r))));const I=M.state.doc.toString();if(!(I===S&&P.length===0)){T.current=!0;try{M.dispatch({...I!==S?{changes:{from:0,to:M.state.doc.length,insert:S}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[S,w,r,x,A]),v.useEffect(()=>{const M=c.current,O=p.current;!M||!O||x!==g.current&&(g.current=x,M.dispatch({effects:O.reconfigure(A(x,w,r))}))},[x,w,r,A]),v.useEffect(()=>{const M=c.current;if(!M||i===d.current)return;d.current=i;const O=h.current;O&&M.dispatch({effects:O.reconfigure(eS(TS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:Tr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[b?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function tR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const ul="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Iy={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(m,x){var g=new RegExp(m,"g");h[m]=(d.match(g)||[]).length,p=!p||h[m]>h[p]?m:p}),p}function u(d){for(var h={},p=0;p=0;p--){var m=d[p];h[m]>0&&(m=m+"__"+h[m]--),x.unshift(m)}return x}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var m=[];try{o=h.trim!==!1;var m=f.parse(d,l[p])}catch(oe){var x=d.lastIndexOf(` +`,oe.offset),g=d.indexOf(` +`,oe.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw oe.message+" On line "+oe.line+" and column "+oe.column+`. +`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),S=0;Sy&&(y=g,w=[]),w.push(R))}function b(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function S(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function T(){var R,N,L,H;return L=g,H=g,R=function(q){return Z="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function A(){var R,N,L,H;return L=g,H=g,R=function(q){return Z=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q,B){return B}(L,R[1])),R===null&&(g=L),R}function M(){var R,N,L,H,q,B,V,le,ge;for(B=g,V=g,R=[],/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=O(),N!==null){if(L=[],le=g,ge=g,/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]")),q!==null)for(H=[];q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));else H=null;for(H!==null?(q=O(),q!==null?H=[H,q]:(H=null,g=ge)):(H=null,g=ge),H!==null&&(H=function(Me,Fe){return Fe}(le,H[1])),H===null&&(g=le);H!==null;){if(L.push(H),le=g,ge=g,/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]")),q!==null)for(H=[];q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));else H=null;H!==null?(q=O(),q!==null?H=[H,q]:(H=null,g=ge)):(H=null,g=ge),H!==null&&(H=function(Me,Fe){return Fe}(le,H[1])),H===null&&(g=le)}if(L!==null){for(H=[],/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));q!==null;)H.push(q),/^[\n\r]/.test(p.charAt(g))?(q=p.charAt(g),g++):(q=null,k("[\\n\\r]"));H!==null?R=[R,N,L,H]:(R=null,g=V)}else R=null,g=V}else R=null,g=V;else R=null,g=V;return R!==null&&(R=function(Me,Fe,_e){return _e.unshift(Fe),_e}(B,R[1],R[2])),R===null&&(g=B),R}function O(){var R,N,L,H,q,B,V,le,ge;if(B=g,V=g,R=_(),R!==null){for(N=[],le=g,ge=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(Me,Fe){return Fe==Z}(g,L)?"":null,H!==null?(q=_(),q!==null?L=[L,H,q]:(L=null,g=ge)):(L=null,g=ge)):(L=null,g=ge),L!==null&&(L=function(Me,Fe,_e){return _e}(le,L[0],L[2])),L===null&&(g=le);L!==null;)N.push(L),le=g,ge=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(Me,Fe){return Fe==Z}(g,L)?"":null,H!==null?(q=_(),q!==null?L=[L,H,q]:(L=null,g=ge)):(L=null,g=ge)):(L=null,g=ge),L!==null&&(L=function(Me,Fe,_e){return _e}(le,L[0],L[2])),L===null&&(g=le);N!==null?(L=function(Me,Fe,_e){return!!Fe||_e.length}(g,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,g=V)):(R=null,g=V)}else R=null,g=V;return R!==null&&(R=function(Me,Fe,_e){return _e.unshift(Fe),_e}(B,R[0],R[1])),R===null&&(g=B),R}function _(){var R,N,L,H,q,B;if(H=g,q=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null){for(N=[],L=P();L!==null;)N.push(L),L=P();N!==null?(p.charCodeAt(g)===34?(L='"',g++):(L=null,k('"\\""')),L!==null?R=[R,N,L]:(R=null,g=q)):(R=null,g=q)}else R=null,g=q;if(R!==null&&(R=function(V,le){return le.join("")}(H,R[1])),R===null&&(g=H),R===null){for(H=g,R=[],q=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(V,le){return le!=Z}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(V,le){return le}(q,N[0])),N===null&&(g=q);N!==null;)R.push(N),q=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(V,le){return le!=Z}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(V,le){return le}(q,N[0])),N===null&&(g=q);R!==null&&(R=function(V,le){return(o?le.join("").trim():le.join("")).replace(/(^")|("$)/g,"")}(H,R)),R===null&&(g=H)}return R}function P(){var R,N,L,H;return L=g,H=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(g)===34?(N='"',g++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(q){return'"'}()),R===null&&(g=L),R===null&&(/^[^"]/.test(p.charAt(g))?(R=p.charAt(g),g++):(R=null,k('[^"]'))),R}function I(R){R.sort();for(var N=null,L=[],H=0;H=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function mo(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function iG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function sG(t){const e=n=>{if(!mo(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(iG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):mo(t)?e(t):t}function oG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function lG(t,e,n){if(n==="string")return t;if(n==="number")return AS(t);if(n==="boolean")return oG(t);if(e.parseJSON){const r=rG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?AS(t):t}function aG(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=lG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>mo(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=mo(s)?n(s):s;return r}const uG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function rR(t){const e=uG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function Dy(t){const e=new Set(t),n=new Map;for(const i of t){const s=rR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function MS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function RS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>rR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const m=d.get(p.index);m?m.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const m=d.get(p)??[],x={};for(const g of m){if(!g.subKey)continue;const y=t[g.column];MS(y,r)||(x[g.subKey]=y)}Object.keys(x).length>0&&h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const m=d.get(p);if(!m)continue;const x=t[m];MS(x,r)||h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function cG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!mo(r))return e;const i=Object.keys(r),s=Dy(i);return s.length===0?e:e.map(o=>mo(o)?RS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!mo(r))return e;const i=Object.keys(r),s=Dy(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=mo(a)?RS(a,i,s,n):a;return o}return e}function OS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(ES)?t.slice(ES.length):t;try{const i=YX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=aG(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?cG(i,s,n.emptyFields):s}catch(i){throw new Error(nR(i))}}function fG(t,e={}){try{const n=e.flatten?sG(t):t;return JX(n,e)}catch(n){const r=nR(n);throw tG.some(i=>r.startsWith(i))?new ZX(eG(r,e.flatten??!1)):new Error(r)}}function dG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const zr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},PS=["data","items","results","records","rows"];function IS(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function hG(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!IS(n))return[];const r=Object.keys(n),i=new Set(PS),s=[...PS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>IS(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function iR(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function pG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=iR(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function gG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const NS=t=>t==="auto"?void 0:t;function mG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:u}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=iR(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=NS(n.separator),s=fG(r,{separator:i,flatten:n.flatten}),o=tf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function wG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function _u({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:ul,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function xG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function bG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:m,onCellCommit:x,canUndo:g=!1,canRedo:y=!1,onUndo:w,onRedo:k,collapseIndexedArrays:b=!0,onToggleCollapseIndexedArrays:S,columnTypes:T,onChangeColumnTypes:A}){const[M,O]=v.useState(!1),[_,P]=v.useState(!1),I=v.useRef(0),D=v.useRef(null),Z=e.trim()==="",ne=t==="CSV",oe=v.useMemo(()=>{if(!ne||Z)return[];const V=xG(e),le=tf(V,m);return Dy(le.headers.map(ge=>ge.trim()))},[ne,Z,e,m]),W=v.useMemo(()=>ne||Z?[]:hG(e),[ne,Z,e]),U=v.useMemo(()=>ne||Z?null:pG(e),[ne,Z,e]),R=V=>{var le;V.preventDefault(),Array.from(((le=V.dataTransfer)==null?void 0:le.types)??[]).includes("Files")&&(I.current++,P(!0))},N=()=>{I.current=Math.max(0,I.current-1),I.current===0&&P(!1)},L=V=>{var ge,Me;V.preventDefault(),I.current=0,P(!1);const le=(Me=(ge=V.dataTransfer)==null?void 0:ge.files)==null?void 0:Me[0];le&&r(le,"drop")},H=V=>{var ge;if(!Z||V.defaultPrevented||V.target instanceof HTMLTextAreaElement||V.target instanceof HTMLInputElement)return;const le=(ge=V.clipboardData)==null?void 0:ge.getData("text/plain");le&&(V.preventDefault(),n(le))},q=ne?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!M,onClick:()=>O(!1),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",M?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(hN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":M,onClick:()=>O(!0),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",M?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(ux,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,B=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(wG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:R,onDragOver:V=>V.preventDefault(),onDragLeave:N,onDrop:L,onPaste:H,"data-drag-over":_||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(tR,{title:t,meta:B,actions:E.jsxs(E.Fragment,{children:[q,ne&&(g||y)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!g,onClick:()=>w==null?void 0:w(),className:ul,children:E.jsx(xN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!y,onClick:()=>k==null?void 0:k(),className:ul,children:E.jsx(nN,{"aria-hidden":"true"})})]}):null,U?E.jsx(_u,{label:U.label,testId:"json-format-toggle",onClick:()=>n(U.nextInput),Icon:ux,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:D,type:"file","data-testid":"file-input",accept:ne?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:V=>{var ge;const le=(ge=V.target.files)==null?void 0:ge[0];le&&r(le,"picker"),V.target.value=""}}),E.jsx(_u,{label:"Upload",testId:"upload",onClick:()=>{var V;return(V=D.current)==null?void 0:V.click()},Icon:hT}),E.jsx(_u,{label:"Copy",testId:"copy-input",onClick:o,Icon:Nv}),E.jsx(_u,{label:"Clear",testId:"clear-input",onClick:s,disabled:Z,Icon:hh}),E.jsx(_u,{label:"Download",testId:"download-input",onClick:a,disabled:Z,Icon:dT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[Z?E.jsx(j9,{format:t,onIngest:n,onBrowse:()=>{var V;return(V=D.current)==null?void 0:V.click()},onTryExample:i}):ne?E.jsxs(E.Fragment,{children:[oe.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${oe.map(V=>`${V.prefix}[${V.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>S==null?void 0:S(),className:Tr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",b?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:b?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,M?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:V=>n(V.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(zE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:T,onChangeColumnTypes:A})]}):E.jsxs(E.Fragment,{children:[W.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),W.map(V=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${V.key}`,onClick:()=>n(V.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${V.key} (${V.rowCount} ${V.rowCount===1?"row":"rows"})`},V.key))]}):null,E.jsx(eR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),_?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const kG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function SG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:kG.test(t.name)}const CG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function DS(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function sR(t){const[e,n]=v.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return v.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const oR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function _S(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function TG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=oR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function LS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function FS(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function $S({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function eo({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:Tr("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:Tr("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(_y,{text:r}):null]})}function _y({text:t}){const e=v.useId(),[n,r]=v.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function EG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=v.useState(!1),a=v.useRef(null),u=v.useRef(null),c=sR("(min-width: 98.5rem)"),f=t==="csv2json",d=TG(t,e),h=v.useCallback(()=>{var m;l(!1),(m=a.current)==null||m.focus()},[]);v.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&h()},x=g=>{const y=u.current;y===null||!(g.target instanceof Node)||y.contains(g.target)||h()};return document.addEventListener("keydown",m),document.addEventListener("click",x),()=>{document.removeEventListener("keydown",m),document.removeEventListener("click",x)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx($S,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:m=>n({separator:m.target.value}),className:LS(),children:oR.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(FS,{})]})]}),E.jsx(_y,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(_S,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx($S,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:m=>s(m.target.value),className:LS(),children:CG.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx(FS,{})]})]}),E.jsx(_y,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(_S,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(eo,{label:"Parse numbers",checked:e.parseNumbers,onChange:m=>n({parseNumbers:m}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(eo,{label:"Parse JSON",checked:e.parseJSON,onChange:m=>n({parseJSON:m}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(eo,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:m=>n({emptyFields:m?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(eo,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:m=>n({nullLiterals:m?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(eo,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(eo,{label:"Hash output",checked:e.hash,onChange:m=>n({hash:m}),hint:"The first column becomes the object key instead of a field."}),E.jsx(eo,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(eo,{label:"Flatten nested arrays",checked:e.flatten,onChange:m=>n({flatten:m}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(UI,{"aria-hidden":"true",className:Tr("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:Tr("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const AG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],MG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),RG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function jd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Nw(t){if(Array.isArray(t))return t.map(e=>jd(e)?e:{value:e});if(jd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>jd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function lR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function OG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!MG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function Mm(t){return`"${t.replace(/"/g,'""')}"`}function PG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function IG(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function NG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return Nw(n).map(i=>JSON.stringify(i)).join(` +`)}function DG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=Nw(r),s=lR(i),o=Mm(OG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=PG(h);return` ${Mm(d)} ${p}`}),a=`CREATE TABLE ${o} ( +${l.join(`, +`)} +);`;if(i.length===0)return a;const u=s.map(Mm).join(", "),c=i.map(d=>` (${s.map(p=>IG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES +${c.join(`, +`)};`;return`${a} + +${f}`}function aR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=uR(Array.from(new Set(t.map(n=>aR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return jd(t)?"Record":"unknown"}const zS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function uR(t){return[...t].sort((e,n)=>{const r=zS[e]??50,i=zS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function _G(t){return RG.test(t)?t:JSON.stringify(t)}function LG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=Nw(n),s=lR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(aR(h[l]))}const c=uR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${_G(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { +${s.join(` +`)} +}`:"export interface DataRow {}"} + +export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function FG(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return NG(i);case"sql":return DG(i,s);case"ts":return LG(i)}}const $G=3;function zG(t){const e=t.slice(0,$G),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function BG({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onNativeCopy:p,onDownload:m,onEgressFormatChange:x,onOutputChange:g,onRevert:y,onDiscardReconvert:w}){const k=t==="JSON",b=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(tR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:y,className:ul,children:[E.jsx(cx,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[k?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:AG.map(S=>{const T=u===S.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${S.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(S.format),className:Tr("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:S.label},S.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:ul,children:[E.jsx(Nv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:m,disabled:!n,className:ul,children:[E.jsx(dT,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:w?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:w,className:ul+" ml-2",children:[E.jsx(cx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:zG(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?k?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>p==null?void 0:p(),children:E.jsx(eR,{value:n,editable:a&&b&&n.length<=ZM,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):E.jsx(zE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function jG({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const Dw="csvjson:recent.v1",cR=10,fR=1e5,BS=80;function HG(t){return t==="csv2json"||t==="json2csv"}function WG(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function dR(t){if(typeof t!="object"||t===null)return{...zr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:zr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:zr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:zr.nullLiterals,o=WG(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:zr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:zr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:zr.transpose,hash:typeof e.hash=="boolean"?e.hash:zr.hash,minify:typeof e.minify=="boolean"?e.minify:zr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:zr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:zr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function hR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=BS?n:`${n.slice(0,BS-1)}…`}function VG(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!HG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>fR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function UG(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:dR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||hR(t.input)}}function pR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Dw,JSON.stringify(t))}catch{}}function KG(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function _w(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Dw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(VG).map(UG).sort((r,i)=>i.createdAt-r.createdAt).slice(0,cR):[]}catch{return[]}}function jS(t){const e=_w(),n=t.input.trim();if(n===""||t.input.length>fR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??KG(r),createdAt:r,direction:t.direction,input:t.input,options:dR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:hR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,cR);return pR(l),l}function XG(t){const n=_w().filter(r=>r.id!==t);return pR(n),n}function GG(){try{if(typeof window>"u")return;window.localStorage.removeItem(Dw)}catch{}}function qG(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function YG(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function QG(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function JG({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=v.useState(!1),o=v.useRef(null),l=v.useRef(null),a=v.useCallback(()=>{s(!1)},[]),u=v.useRef(!1);v.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),v.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(qI,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:YG(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:QG(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:qG(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(hh,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Ly=20,Fy=80,HS=50;function Rm(t){return Math.min(Fy,Math.max(Ly,t))}function ZG({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=v.useRef(null),[l,a]=v.useState(!1),u=t==="stacked";v.useEffect(()=>{if(!l)return;const f=h=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Rm(m*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(Rm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Rm(e+d));break;case"Home":f.preventDefault(),n(Ly);break;case"End":f.preventDefault(),n(Fy);break;case"Enter":case" ":f.preventDefault(),n(HS);break}};return E.jsxs("div",{ref:o,className:Tr("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:Tr("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Ly,"aria-valuemax":Fy,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(HS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:Tr("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:Tr("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function eq({theme:t}){return t==="dark"?E.jsx(fN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(eN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function tq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(eq,{theme:t})})]})}function nq(t){return[...t].sort((e,n)=>n.id-e.id)}const gR=[{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],rq=864e5;function WS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function iq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((WS(r)-WS(n))/rq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const mR="csvjson:changelog.v1",Hd=Math.max(...gR.map(t=>t.id),0),sq=nq(gR);function oq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!lq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function lq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function yR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Hd).sort((e,n)=>e-n)}function VS(t,e,n){const r=yR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function aq(){try{const t=window.localStorage.getItem(mR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return oq(e)?{...e,pendingIds:yR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function uq(t){try{window.localStorage.setItem(mR,JSON.stringify(t))}catch{}}function cq(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function fq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function US(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:iq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:US(e===1),children:E.jsx(yN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:US(e===-1),children:E.jsx(gN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function hq(){const[t,e]=v.useState(aq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{uq(b),i.current=b,e(b)},[]),[o,l]=v.useState(()=>new Set),a=v.useRef(new Set),u=v.useRef(null),c=v.useRef(null),f=v.useRef(new Map),d=t.lastSeenId!==null&&Hd>t.lastSeenId,h=v.useCallback((b,S)=>{l(T=>{const A=new Set(T);return S?A.add(b):A.delete(b),A})},[]),p=v.useCallback((b,S,T,A)=>{const M=(f.current.get(b)??0)+1;f.current.set(b,M),a.current.add(b),A&&h(b,!0),fq(T,b,S).then(O=>{f.current.get(b)===M&&(a.current.delete(b),O==="ok"&&(EI({entry_id:b,vote:S}),s(VS(i.current,b,!1))),A&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:S,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&S!==void 0)for(const O of M){if(O===b||a.current.has(O))continue;const _=A[O];_!==void 0&&p(O,_,S,!1)}},[p]),x=(b,S)=>{if(t.votes[b]===S){m();return}const T=t.clientId??cq();s(VS({...t,votes:{...t.votes,[b]:S},clientId:T},b,!0)),p(b,S,T,!0),m(b)},g=()=>{r(!0),TI(),t.lastSeenId!==Hd&&s({...t,lastSeenId:Hd}),m()},y=v.useCallback(()=>{r(!1)},[]),w=v.useRef(!1);v.useEffect(()=>{var b;w.current&&!n&&((b=c.current)==null||b.focus()),w.current=n},[n]);const k=v.useRef(!1);return v.useEffect(()=>{k.current||(k.current=!0,m())},[m]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&y()},S=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",S)}},[n,y]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?y():g(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(iN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:y,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:sq.map(b=>{var S;return E.jsx(dq,{entry:b,vote:t.votes[b.id],queued:((S=t.pendingIds)==null?void 0:S.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function pq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const gq={},mq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],yq=["csv2json","json2csv","csvjson2json"];function vq(t){return yq.includes(t)}const wq=/^[0-9a-f]{32}$/i,xq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Om=gq,bq=((Om==null?void 0:Om.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function kq(t){const e=xq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return mq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class $y extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Pm extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Im={csv:(t,e)=>{t.direction="csv2json",t.input=Yh(e)},json:(t,e)=>{t.input=Yh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Yh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function KS(t){return typeof t=="string"&&t.trim()!==""}function Gl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function Sq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Cq(t){var i;if(!Sq(t))return null;const e=KS(t.csv),n=KS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Im[s])==null||i.call(Im,r,o);return r.input=Yh(e?t.csv:t.json),r}async function Tq(t){if(!wq.test(t))throw new $y;let e;try{e=await fetch(`${bq}${t}`,{mode:"cors"})}catch(r){throw new Pm("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new $y;if(!e.ok)throw new Pm(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new Pm("Stored data for this link is malformed")}return n}function Eq(t){const e=v.useMemo(()=>t&&vq(t.tool)?t.id:null,[t]),[n,r]=v.useState(0),[i,s]=v.useState(e?"loading":"idle"),[o,l]=v.useState(null),[a,u]=v.useState("");return v.useEffect(()=>{if(!e)return;let c=!1;return Tq(e).then(f=>{if(c)return;const d=Cq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof $y?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function XS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const Aq="\uFEFF";function Mq(t,e){return e?Aq+t:t}function Rq(t,e,n){const r=Mq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Oq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Pq(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!Oq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function Iq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Pq(t)}.${r}`:`data.${r}`}function Nq(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function GS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Rq(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function Dq(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const _q=`album,year,US_peak_chart_post +The White Stripes,1999, +De Stijl,2000, +White Blood Cells,2001,61 +Elephant,2003,6 +Get Behind Me Satan,2005,3 +Icky Thump,2007,2`,Lq=`[ + { + "album": "Elephant", + "year": 2003, + "label": "XL Recordings" + }, + { + "album": "Icky Thump", + "year": 2007, + "label": "XL Recordings" + } +]`,vR="csvjson-theme";function Fq(){try{const t=localStorage.getItem(vR);return t==="dark"||t==="light"?t:null}catch{return null}}function $q(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function zq(){return Fq()??$q()}function Bq(t){try{localStorage.setItem(vR,t)}catch{}}function jq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const qS=2*1024*1024,Hq=150,Wq=1e3,Vq=2e3,Uq=2e3;function Kq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function YS(t){try{return JSON.parse(t),!0}catch{return!1}}function Xq(){var dn;const[t,e]=v.useState(zq);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(re=>{const De=re==="dark"?"light":"dark";return Bq(De),De}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":jq(window.location.search)),[s,o]=v.useState(()=>Go("")),l=s.present,[a,u]=v.useState(zr),[c,f]=v.useState("json"),[d,h]=v.useState(50),[p,m]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(null),[k,b]=v.useState("utf-8"),[S,T]=v.useState(_w),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=DI({settleMs:Vq,minWindowMs:Uq,isValid:(re,De)=>{const ze=A.current;return De===ze.input?ze.resultOk:Zs(re==="csv_to_json"?"csv2json":"json2csv",De,ze.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=sR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",Z=I?"JSON":"CSV",ne=l.trim()==="",oe=l.length>qS?Wq:Hq,W=pq(l,ne?0:oe),U=v.useRef(null),R=v.useRef(null),L=l!==""&&((dn=U.current)==null?void 0:dn.text)===l?l:W,H=v.useMemo(()=>typeof window>"u"?null:kq(window.location.pathname),[]),q=Eq(H),B=v.useMemo(()=>Zs(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const re=R.current;!re||re.text!==L||(R.current=null,O.discrete(re.direction,re.via,re.text))},[L,B,O]);const[V,le]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&B.ok&&le(B.text)},[B,L]),v.useEffect(()=>{L.trim()!==""&&(!B.ok||B.rows<=0&&B.cols<=0||T(jS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const ge=L.trim()!==""&&B.ok?B.text:V,[Me,Fe]=v.useState(!1),[_e,ft]=v.useState(null),Xe=Me?_e:ge,Ge=v.useMemo(()=>{if(!I||Xe===null||c==="json")return Xe;const re=Me&&_e!==null&&YS(_e)?_e:ge;return re===null?null:FG(re,c,a,p)},[I,Xe,c,Me,_e,ge,a,p]),lt=I&&c==="json"&&!ne&&Ge!==null&&(Me||B.ok),Ut=v.useCallback(re=>{if(re===ge){Fe(!1),ft(null);return}Fe(!0),ft(re)},[ge]),Re=v.useCallback(()=>{const re=Zs(r,l,a);re.ok&&le(re.text),Fe(!1),ft(null)},[r,l,a]),we=v.useCallback(re=>{o(De=>I?Kb(De,re):Go(re))},[I]),Qe=I&&s.past.length>0,nt=I&&s.future.length>0,it=v.useCallback(()=>{if(!I||s.past.length===0)return;const re=S9(s);w(null),o(re),O.edit("csv_to_json",re.present)},[I,s,O]),$e=v.useCallback(()=>{if(!I||s.future.length===0)return;const re=C9(s);w(null),o(re),O.edit("csv_to_json",re.present)},[I,s,O]),At=v.useCallback(re=>{w(null),U.current=null,i(re.direction),u({...re.options}),m(re.filename),Fe(!1),ft(null),o(De=>re.direction==="csv2json"&&r==="csv2json"?Kb(De,re.input):Go(re.input)),T(jS({direction:re.direction,input:re.input,options:re.options,filename:re.filename,rows:re.rows,cols:re.cols}))},[r]),wt=v.useCallback(re=>{T(XG(re))},[]),rt=v.useCallback(()=>{GG(),T([])},[]),me=()=>{const re=r==="csv2json"?"json2csv":"csv2json";if(Me){const De=_e??"",ze=YS(De)?De:l;o(Go(ze)),i(re),Fe(!1),ft(null),ze.trim()!==""&&(A.current={direction:re,options:a,input:ze,resultOk:Zs(re,ze,a).ok},O.discrete(re==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(re),ne)o(Go(""));else{const De=Zs(r,l,a),ze=De.ok?De.text:l;o(Go(ze)),ze.trim()!==""&&(A.current={direction:re,options:a,input:ze,resultOk:Zs(re,ze,a).ok},O.discrete(re==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},Ne=q.hydrated;v.useEffect(()=>{if(Ne===null)return;const re={...A.current.options,...Ne.options};A.current={direction:Ne.direction,options:re,input:Ne.input,resultOk:Zs(Ne.direction,Ne.input,re).ok},i(Ne.direction),o(Go(Ne.input)),u(De=>({...De,...Ne.options})),Fe(!1),ft(null),CI(),O.discrete(Ne.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Ne.input)},[Ne,O]);const Je=async(re,De)=>{if(!SG(re)){w(`Can't read "${re.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const ze=await DS(re,k);U.current={file:re,source:De,text:ze},R.current={direction:I?"csv_to_json":"json_to_csv",via:De==="drop"?"drag":"file",text:ze},we(ze),m(re.name),g(!1)}catch{g(!1),w(`Couldn't read "${re.name}".`)}},tt=async re=>{const De=k;b(re);const ze=U.current;if(!(!ze||l!==ze.text)){g(!0);try{const An=await DS(ze.file,re);U.current={...ze,text:An},R.current={direction:I?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:An},o(z=>({...z,present:An})),g(!1)}catch{g(!1),b(De),w(`Couldn't read "${ze.file.name}".`)}}},Kt=v.useCallback(re=>{w(null),re.trim()===""&&u(De=>{if(!De.columnTypes)return De;const ze={...De};return delete ze.columnTypes,ze}),we(re),O.edit(I?"csv_to_json":"json_to_csv",re)},[we,I,O]);v.useEffect(()=>{const re=De=>{var An;const ze=(An=De.clipboardData)==null?void 0:An.getData("text/plain");!ze||Dq(De.target)||(De.preventDefault(),De.stopPropagation(),m(null),Kt(ze))};return document.addEventListener("paste",re,!0),()=>document.removeEventListener("paste",re,!0)},[Kt]);const dt=B.ok?Kq(B.rows,B.cols):null,ht=!B.ok&&V?"Last valid result — input has errors":null,pt=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Lt=l.length>qS,Rt=I?"csv_to_json":"json_to_csv",en=I?c:"csv",Hn=()=>{Uo({via:"copy",format:I?"csv":"json",pane:"input",direction:Rt}),XS(l)},Pt=()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt}),Ge&&XS(Ge)},vn=()=>{Uo({via:"download",format:I?"csv":"json",pane:"input",direction:Rt}),GS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},In=()=>{Uo({via:"download",format:en,pane:"output",direction:Rt}),GS(Ge??"",Iq(p,I?"csv2json":"json2csv",c),{mime:Nq(I?"csv2json":"json2csv",c),bom:!I})},Pr=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"input",direction:Rt})},[Rt]),Ir=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"output",direction:Rt})},[Rt]),Bt=v.useCallback(()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt})},[en,Rt]),ut=E.jsx(bG,{format:D,input:l,onInputChange:Kt,onCellCommit:Kt,onFile:Je,onTryExample:()=>{w(null);const re=I?_q:Lq;A.current={direction:r,options:a,input:re,resultOk:Zs(r,re,a).ok},we(re),O.discrete(Rt,"example",re)},onClear:()=>{we(""),m(null),u(re=>{if(!re.columnTypes)return re;const De={...re};return delete De.columnTypes,De}),Fe(!1),ft(null),O.cancel()},onCopy:Hn,onCopySelection:Pr,onDownload:vn,canUndo:Qe,canRedo:nt,onUndo:it,onRedo:$e,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(re=>({...re,collapseIndexedArrays:!(re.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:re=>u(De=>{const ze={...De};return Object.keys(re).length>0?ze.columnTypes=re:delete ze.columnTypes,ze}),filename:p,reading:x,meta:dt,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),xt=E.jsx(BG,{format:Z,inputEmpty:ne,outputText:Ge,error:B.ok?null:B.error,meta:dt,staleNotice:ht,warnings:pt,edited:Me,editable:lt,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Pt,onCopySelection:Ir,onNativeCopy:Bt,onDownload:In,onEgressFormatChange:f,onOutputChange:Ut,onRevert:Re,onDiscardReconvert:Re});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(oD,{}),E.jsx(tq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(JG,{snapshots:S,onSelect:At,onRemove:wt,onClear:rt}),E.jsx(hq,{}),E.jsx(fD,{})]})}),H&&(q.phase==="loading"||q.phase==="not-found"||q.phase==="unsupported"||q.phase==="error")?E.jsx(jG,{phase:q.phase,message:q.phase==="error"?q.message:void 0,onRetry:q.retry}):null,E.jsx(ZG,{layout:P,split:d,onSplitChange:h,left:ut,right:xt,children:E.jsx(nD,{direction:r,onFlip:me})}),E.jsx(EG,{direction:r,options:a,onChange:re=>u(De=>({...De,...re})),uploadEncoding:k,onUploadEncodingChange:tt,notice:Lt?"Large file — converting on pause":null})]}),E.jsx(iD,{})]})}uT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(Xq,{})}));document.getElementById("root").removeAttribute("inert");kI();SI();export{e6 as C,Ln as R,T$ as T,ca as a,Q3 as b,xI as c,ql as i,C$ as m,v as r,Qr as s}; diff --git a/app/dist/assets/index-Bgv9nWtu.js b/app/dist/assets/index-Bgv9nWtu.js deleted file mode 100644 index 5727350..0000000 --- a/app/dist/assets/index-Bgv9nWtu.js +++ /dev/null @@ -1,307 +0,0 @@ -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 - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var Fc=Symbol.for("react.element"),XR=Symbol.for("react.portal"),GR=Symbol.for("react.fragment"),qR=Symbol.for("react.strict_mode"),YR=Symbol.for("react.profiler"),QR=Symbol.for("react.provider"),JR=Symbol.for("react.context"),ZR=Symbol.for("react.forward_ref"),eO=Symbol.for("react.suspense"),tO=Symbol.for("react.memo"),nO=Symbol.for("react.lazy"),Zw=Symbol.iterator;function rO(t){return t===null||typeof t!="object"?null:(t=Zw&&t[Zw]||t["@@iterator"],typeof t=="function"?t:null)}var QS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},JS=Object.assign,ZS={};function Ha(t,e,n){this.props=t,this.context=e,this.refs=ZS,this.updater=n||QS}Ha.prototype.isReactComponent={};Ha.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")};Ha.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function eC(){}eC.prototype=Ha.prototype;function $y(t,e,n){this.props=t,this.context=e,this.refs=ZS,this.updater=n||QS}var zy=$y.prototype=new eC;zy.constructor=$y;JS(zy,Ha.prototype);zy.isPureReactComponent=!0;var e1=Array.isArray,tC=Object.prototype.hasOwnProperty,By={current:null},nC={key:!0,ref:!0,__self:!0,__source:!0};function rC(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)tC.call(e,r)&&!nC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>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 - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var gO=v,jr=pO;function de(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"),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{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[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 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 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 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 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 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 _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: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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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: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+=` -`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Kx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Kx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Gx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Gx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,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`
    -${e}
    -`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} -`}return`${e} -`}hr(){return this.options.xhtml?`
    -`:`
    -`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> -`+e+" -`}listitem(e){return`
  • ${e}
  • -`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    -`}table(e,n){return n&&(n=`${n}`),` - -`+e+` -`+n+`
    -`}tablerow(e){return` -${e} -`}tablecell(e,n){const r=n.header?"th":"td";return(n.align?`<${r} align="${n.align}">`:`<${r}>`)+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,n,r){if(e=Vx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='
    ",i}image(e,n,r){if(e=Vx(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class 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(Lb(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function Fb(t,e,n){var l;const r=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 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 Wb(t,e){return t[e-2]==="\r"&&t[e-1]===` -`?2:t[e-1]==="\r"||t[e-1]===` -`?1:0}const Vb="\uFEFF";function 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 Jf(t,e){return Math.max(0,Math.min(t,e))}function Gb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Jf(a.x,r+i),c=Jf(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=Jf(a.y,e.length),p=Jf(a.y+a.height,e.length);if(p<=h)continue;const m=t.headers.slice(f,d),x=[];for(let g=h;gw[f+b]??""))}x.length!==0&&s.push(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=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 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(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 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 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`,Iq=`[ - { - "album": "Elephant", - "year": 2003, - "label": "XL Recordings" - }, - { - "album": "Icky Thump", - "year": 2007, - "label": "XL Recordings" - } -]`,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-ClJRXvW2.js b/app/dist/assets/number-overlay-editor-TWdf9NmZ.js similarity index 99% rename from app/dist/assets/number-overlay-editor-ClJRXvW2.js rename to app/dist/assets/number-overlay-editor-TWdf9NmZ.js index e909636..91ff627 100644 --- a/app/dist/assets/number-overlay-editor-ClJRXvW2.js +++ b/app/dist/assets/number-overlay-editor-TWdf9NmZ.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-Bgv9nWtu.js";const Fe=Be("div")({name:"NumberOverlayEditorStyle",class:"gdg-n15fjm3e",propsAsIs:!1});function pe(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(e);a=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start=p?a=a+ge("0",f-p):a=(a.substring(0,f)||"0")+"."+a.substring(f),r+a}function me(e,t,r){if(["","-"].indexOf(e)!==-1)return e;var n=(e.indexOf(".")!==-1||r)&&t,a=se(e),i=a.beforeDecimal,f=a.afterDecimal,p=a.hasNegation,m=parseFloat("0."+(f||"0")),x=f.length<=t?"0."+f:m.toFixed(t),h=x.split("."),s=i;i&&Number(h[0])&&(s=i.split("").reverse().reduce(function(I,C,g){return I.length>g?(Number(I[0])+Number(C)).toString()+I.substring(1,I.length):C+I},h[0]));var S=be(h[1]||"",t,r),y=p?"-":"",l=n?".":"";return""+y+s+l+S}function J(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var r=e.createTextRange();return r.move("character",t),r.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var Ne=_e(function(e,t){for(var r=0,n=0,a=e.length,i=t.length;e[r]===t[r]&&rr&&a-n>r;)n++;return{from:{start:r,end:a-n},to:{start:r,end:i-n}}}),Pe=function(e,t){var r=Math.min(e.selectionStart,t);return{from:{start:r,end:e.selectionEnd},to:{start:r,end:t}}};function Ke(e,t,r){return Math.min(Math.max(e,t),r)}function ce(e){return Math.max(e.selectionStart,e.selectionEnd)}function We(){return typeof navigator<"u"&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function Ue(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:""}}function $e(e){var t=e.currentValue,r=e.formattedValue,n=e.currentValueIndex,a=e.formattedValueIndex;return t[n]===r[a]}function Ge(e,t,r,n,a,i,f){f===void 0&&(f=$e);var p=a.findIndex(function(k){return k}),m=e.slice(0,p);!t&&!r.startsWith(m)&&(t=m,r=m+r,n=n+m.length);for(var x=r.length,h=e.length,s={},S=new Array(x),y=0;y0&&S[g]===-1;)g--;var F=g===-1||S[g]===-1?0:S[g]+1;return F>B?B:n-F=0&&!r[t];)t--;t===-1&&(t=r.indexOf(!0))}else{for(;t<=a&&!r[t];)t++;t>a&&(t=r.lastIndexOf(!0))}return t===-1&&(t=a),t}function Ze(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),r=0,n=t.length;rP.length-f.length||HL||s>e.length-f.length)&&(W=s),e=e.substring(0,W),e=Je(F?"-"+e:e,a),e=(e.match(Qe(l))||[]).join("");var U=e.indexOf(l);e=e.replace(new RegExp(ye(l),"g"),function(c,N){return N===U?".":""});var $=se(e,a),Q=$.beforeDecimal,te=$.afterDecimal,d=$.addNegation;return x.end-x.start - + diff --git a/app/src/App.test.tsx b/app/src/App.test.tsx index 0273965..8dc5504 100644 --- a/app/src/App.test.tsx +++ b/app/src/App.test.tsx @@ -1720,6 +1720,64 @@ describe("Developer egress formats in OutputPane header (AC-13 / D12)", () => { await flip(); expect(screen.queryByTestId("output-format-switcher")).toBeNull(); }); + + it("pins per-column types from the CSV table selection bar and updates JSON output immediately, resetting on Clear (AC-16 / D15)", async () => { + const user = userEvent.setup(); + render(); + + fireEvent.change(screen.getByTestId("paste-field"), { + target: { value: "zip,amount,active\n90210,42,yes\n10001,99,no" }, + }); + + // By default, 90210 is parsed as number 90210 and "yes" stays string "yes" + await waitFor(() => { + const output = JSON.parse(screen.getByTestId("output-view").textContent ?? "[]"); + expect(output).toEqual([ + { zip: 90210, amount: 42, active: "yes" }, + { zip: 10001, amount: 99, active: "no" }, + ]); + }); + + // Select column 0 ("zip" -> grid col 1) and pin to String + await user.click(screen.getByTestId("glide-select-column-1")); + await user.click(screen.getByTestId("input-table-column-type-string")); + + await waitFor(() => { + const output = JSON.parse(screen.getByTestId("output-view").textContent ?? "[]"); + expect(output).toEqual([ + { zip: "90210", amount: 42, active: "yes" }, + { zip: "10001", amount: 99, active: "no" }, + ]); + }); + expect(screen.getByTestId("glide-header-1")).toHaveTextContent("ZIP [STR]"); + + // Select column 2 ("active" -> grid col 3) and pin to Boolean + await user.click(screen.getByTestId("glide-select-column-3")); + await user.click(screen.getByTestId("input-table-column-type-boolean")); + + await waitFor(() => { + const output = JSON.parse(screen.getByTestId("output-view").textContent ?? "[]"); + expect(output).toEqual([ + { zip: "90210", amount: 42, active: true }, + { zip: "10001", amount: 99, active: false }, + ]); + }); + expect(screen.getByTestId("glide-header-3")).toHaveTextContent("ACTIVE [BOOL]"); + expect(screen.getByTestId("input-table-column-types-reset")).toHaveTextContent( + "2 column types pinned" + ); + + // Clear input -> resets pinned column types + await user.click(screen.getByTestId("clear-input")); + fireEvent.change(screen.getByTestId("paste-field"), { + target: { value: "zip,amount,active\n90210,42,yes" }, + }); + await waitFor(() => { + const output = JSON.parse(screen.getByTestId("output-view").textContent ?? "[]"); + expect(output).toEqual([{ zip: 90210, amount: 42, active: "yes" }]); + }); + expect(screen.queryByTestId("input-table-column-types-reset")).toBeNull(); + }); }); @@ -1727,3 +1785,4 @@ describe("Developer egress formats in OutputPane header (AC-13 / D12)", () => { + diff --git a/app/src/App.tsx b/app/src/App.tsx index 74c5d0c..b28f42e 100644 --- a/app/src/App.tsx +++ b/app/src/App.tsx @@ -547,6 +547,14 @@ export default function App() { const handleInputChange = useCallback( (value: string) => { setNotice(null); + if (value.trim() === "") { + setOptions((current) => { + if (!current.columnTypes) return current; + const next = { ...current }; + delete next.columnTypes; + return next; + }); + } commitInput(value); tracker.edit(csvToJson ? "csv_to_json" : "json_to_csv", value); }, @@ -707,6 +715,12 @@ export default function App() { onClear={() => { commitInput(""); setFilename(null); + setOptions((current) => { + if (!current.columnTypes) return current; + const next = { ...current }; + delete next.columnTypes; + return next; + }); // Clearing the input fully regenerates the output (empty state) — // the edited state has nothing to stay attached to. setOutputEdited(false); @@ -727,6 +741,18 @@ export default function App() { collapseIndexedArrays: !(current.collapseIndexedArrays ?? true), })) } + columnTypes={options.columnTypes ?? {}} + onChangeColumnTypes={(nextColumnTypes) => + setOptions((current) => { + const next = { ...current }; + if (Object.keys(nextColumnTypes).length > 0) { + next.columnTypes = nextColumnTypes; + } else { + delete next.columnTypes; + } + return next; + }) + } filename={filename} reading={reading} meta={meta} diff --git a/app/src/changelog/entries.ts b/app/src/changelog/entries.ts index 21c597a..e6ac0ef 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: 19, + date: "2026-10-20", + tag: "new", + title: "Pin per-column types in the CSV grid", + summary: + "Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings.", + }, { id: 18, date: "2026-10-20", diff --git a/app/src/components/CsvTable.test.tsx b/app/src/components/CsvTable.test.tsx index 180e4a7..eb52db9 100644 --- a/app/src/components/CsvTable.test.tsx +++ b/app/src/components/CsvTable.test.tsx @@ -801,4 +801,71 @@ describe("CsvTable selection aggregates", () => { }); }); +describe("CsvTable — per-column type override pills & header badges (AC-16 / D15)", () => { + it("renders Auto · String · Number · Boolean override pills when a column is selected in editable mode, updates header badges, and resets via chip", async () => { + const user = userEvent.setup(); + const onChangeColumnTypes = vi.fn(); + render( + + ); + + // Not visible before selecting a column + expect(screen.queryByTestId("input-table-column-type-group")).toBeNull(); + + // Select data column 1 ("year" -> grid column 2) + await user.click(screen.getByTestId("glide-select-column-2")); + expect(screen.getByTestId("input-table-column-type-group")).toBeInTheDocument(); + expect(screen.getByTestId("input-table-column-type-auto")).toHaveAttribute( + "aria-pressed", + "true" + ); + expect(screen.getByTestId("input-table-column-type-string")).toHaveAttribute( + "aria-pressed", + "false" + ); + + // Pin "year" to String + await user.click(screen.getByTestId("input-table-column-type-string")); + expect(onChangeColumnTypes).toHaveBeenLastCalledWith({ year: "string" }); + expect(screen.getByTestId("input-table-column-type-string")).toHaveAttribute( + "aria-pressed", + "true" + ); + expect(screen.getByTestId("glide-header-2")).toHaveTextContent("YEAR [STR]"); + expect(screen.getByTestId("input-table-column-types-reset")).toHaveTextContent( + "1 column type pinned" + ); + + // Pin "year" to Boolean -> badge updates to [BOOL] + await user.click(screen.getByTestId("input-table-column-type-boolean")); + expect(onChangeColumnTypes).toHaveBeenLastCalledWith({ year: "boolean" }); + expect(screen.getByTestId("glide-header-2")).toHaveTextContent("YEAR [BOOL]"); + + // Pin "year" back to Auto -> removes override and hides reset chip + await user.click(screen.getByTestId("input-table-column-type-auto")); + expect(onChangeColumnTypes).toHaveBeenLastCalledWith({}); + expect(screen.getByTestId("glide-header-2")).toHaveTextContent("YEAR"); + expect(screen.queryByTestId("input-table-column-types-reset")).toBeNull(); + + // Pin to Number, then click the toolbar reset chip + await user.click(screen.getByTestId("input-table-column-type-number")); + expect(screen.getByTestId("glide-header-2")).toHaveTextContent("YEAR [NUM]"); + await user.click(screen.getByTestId("input-table-column-types-reset")); + expect(onChangeColumnTypes).toHaveBeenLastCalledWith({}); + expect(screen.getByTestId("glide-header-2")).toHaveTextContent("YEAR"); + }); + + it("does not render column type override pills in read-only output tables", async () => { + const user = userEvent.setup(); + render(); + await user.click(screen.getByTestId("glide-select-column-2")); + expect(screen.queryByTestId("input-table-column-type-group")).toBeNull(); + }); +}); + diff --git a/app/src/components/CsvTable.tsx b/app/src/components/CsvTable.tsx index 9c07955..e8f7179 100644 --- a/app/src/components/CsvTable.tsx +++ b/app/src/components/CsvTable.tsx @@ -18,6 +18,7 @@ import { } from "@glideapps/glide-data-grid"; import "@glideapps/glide-data-grid/dist/index.css"; import { Copy, Search, Trash2, X } from "lucide-react"; +import { type ColumnTypeOverride } from "@/lib/convert"; import { numericColumns, parseCsvRecord, parseCsvTable, serializeCsvRow } from "@/lib/csvTable"; import { deleteColumns, deleteRows, renameHeader } from "@/lib/tableDeletion"; import { matchHistoryShortcut } from "@/lib/csvHistory"; @@ -90,8 +91,31 @@ type CsvTableProps = { onRedo?: () => void; /** Fired when non-empty selection is copied via the toolbar chip or Cmd/Ctrl+C. */ onCopySelection?: () => void; + /** Per-column type overrides (AC-16 / D15) keyed by header name. */ + columnTypes?: Record; + /** Updates per-column type overrides (input table only). */ + onChangeColumnTypes?: (columnTypes: Record) => void; }; +const COLUMN_TYPE_OPTIONS: readonly { + mode: ColumnTypeOverride; + label: string; +}[] = [ + { mode: "auto", label: "Auto" }, + { mode: "string", label: "String" }, + { mode: "number", label: "Number" }, + { mode: "boolean", label: "Boolean" }, +]; + +function columnTypeBadge( + mode: ColumnTypeOverride | undefined +): "STR" | "NUM" | "BOOL" | null { + if (mode === "string") return "STR"; + if (mode === "number") return "NUM"; + if (mode === "boolean") return "BOOL"; + return null; +} + function isTextEntryElement(node: EventTarget | Element | null): boolean { if (!(node instanceof HTMLElement)) return false; const tag = node.tagName; @@ -242,6 +266,8 @@ export function CsvTable({ onUndo, onRedo, onCopySelection, + columnTypes, + onChangeColumnTypes, }: CsvTableProps) { const rootRef = useRef(null); const gridWrapRef = useRef(null); @@ -262,8 +288,19 @@ export function CsvTable({ const selectedSourcesRef = useRef(selectedSources); /** Measured container width — drives the master table's 1fr column growth. */ const [containerWidth, setContainerWidth] = useState(0); + const [internalColumnTypes, setInternalColumnTypes] = useState< + Record + >({}); const editable = onCellCommit !== undefined; + const effectiveColumnTypes = columnTypes ?? internalColumnTypes; + const updateColumnTypes = useCallback( + (next: Record) => { + setInternalColumnTypes(next); + onChangeColumnTypes?.(next); + }, + [onChangeColumnTypes] + ); const palette = useMemo(() => buildTheme(dark), [dark]); const matchWash = highlightColor(dark); const selectedRowBg = dark ? "hsl(240 3.7% 15.9%)" : "hsl(240 4.8% 95.9%)"; @@ -420,11 +457,25 @@ export function CsvTable({ setEditingHeader(null); if (!onCellCommit) return; const { text: sourceText, table: current } = latestRef.current; + const oldHeader = current.headers[col] ?? ""; const nextText = renameHeader(sourceText, current, col, headerDraft); if (nextText !== sourceText) { + if ( + oldHeader !== "" && + oldHeader !== headerDraft && + effectiveColumnTypes[oldHeader] !== undefined + ) { + const nextTypes = { ...effectiveColumnTypes }; + const existingMode = nextTypes[oldHeader]; + delete nextTypes[oldHeader]; + if (headerDraft !== "" && existingMode !== undefined) { + nextTypes[headerDraft] = existingMode; + } + updateColumnTypes(nextTypes); + } onCellCommit(nextText); } - }, [editingHeader, headerDraft, onCellCommit]); + }, [editingHeader, headerDraft, onCellCommit, effectiveColumnTypes, updateColumnTypes]); const cancelHeaderRename = useCallback(() => { setEditingHeader(null); @@ -517,6 +568,45 @@ export function CsvTable({ [gridSelection] ); const selectedColumnCount = selectedDataColumns.length; + const selectedColumnHeaders = useMemo( + () => + selectedDataColumns + .map((colIndex) => table.headers[colIndex]) + .filter((header): header is string => header !== undefined), + [selectedDataColumns, table.headers] + ); + const sharedSelectedColumnType = useMemo(() => { + if (selectedColumnHeaders.length === 0) return null; + const first = effectiveColumnTypes[selectedColumnHeaders[0]] ?? "auto"; + for (let i = 1; i < selectedColumnHeaders.length; i += 1) { + const mode = effectiveColumnTypes[selectedColumnHeaders[i]] ?? "auto"; + if (mode !== first) return null; + } + return first; + }, [selectedColumnHeaders, effectiveColumnTypes]); + const setSelectedColumnsType = useCallback( + (mode: ColumnTypeOverride) => { + if (!editable || selectedColumnHeaders.length === 0) return; + const next: Record = { + ...effectiveColumnTypes, + }; + for (const header of selectedColumnHeaders) { + if (mode === "auto") { + delete next[header]; + } else { + next[header] = mode; + } + } + updateColumnTypes(next); + }, + [editable, selectedColumnHeaders, effectiveColumnTypes, updateColumnTypes] + ); + const pinnedColumnCount = useMemo(() => { + if (!editable) return 0; + return table.headers.filter( + (header) => columnTypeBadge(effectiveColumnTypes[header]) !== null + ).length; + }, [editable, table.headers, effectiveColumnTypes]); const selection = useMemo( () => ({ ranges: gridSelection?.current @@ -818,14 +908,19 @@ export function CsvTable({ width: GUTTER_WIDTH, themeOverride: { baseFontStyle: `11px ${MONO_FONT}`, textDark: "hsla(240, 3.8%, 46.1%, 0.4)" }, }; - const data: GridColumn[] = table.headers.map((header, index) => ({ - title: header.toUpperCase(), - id: `c${index}`, - width: columnWidth, - themeOverride: numeric[index] ? { baseFontStyle: `12px ${MONO_FONT}` } : undefined, - })); + const data: GridColumn[] = table.headers.map((header, index) => { + const badge = editable + ? columnTypeBadge(effectiveColumnTypes[header]) + : null; + return { + title: badge ? `${header.toUpperCase()} [${badge}]` : header.toUpperCase(), + id: `c${index}`, + width: columnWidth, + themeOverride: numeric[index] ? { baseFontStyle: `12px ${MONO_FONT}` } : undefined, + }; + }); return [gutter, ...data]; - }, [table.headers, numeric, columnWidth]); + }, [table.headers, numeric, columnWidth, editable, effectiveColumnTypes]); // Header strip: mono uppercase muted text, sort glyph on the sorted // column, right-aligned "#" in the gutter. A selected column header @@ -988,6 +1083,20 @@ export function CsvTable({ ? `${view.length.toLocaleString()} of ${total.toLocaleString()}` : `${total.toLocaleString()} rows`} + {editable && pinnedColumnCount > 0 && ( + + )} {showSelectionChip && ( )} {editable && selectedColumnCount > 0 && ( - + <> + + {COLUMN_TYPE_OPTIONS.map(({ mode, label }) => { + const active = sharedSelectedColumnType === mode; + return ( + + ); + })} + + + )}