From f2cd51266d90b794993f8b8ae65c1b966e8e1e0a Mon Sep 17 00:00:00 2001 From: Obvious Date: Tue, 20 Oct 2026 03:02:17 +0000 Subject: [PATCH] feat(csv): support Markdown, ChatGPT, and psql/MySQL box table paste (AC-14) - Add detectMarkdownOrCliTable in app/src/lib/markdownTable.ts to detect and normalize GitHub/ChatGPT Markdown pipe tables and psql/MySQL ASCII box tables into RFC 4180 CSV. - Auto-normalize detected Markdown/CLI tables inside parseCsvTable and convertText/csvToJson (when separator is auto) so pasted tables immediately render clean columns and rows in CsvTable and JSON output without divider rows or empty outer pipe columns. - Surface a contextual Clean Markdown table / Clean CLI table pill (data-testid="csv-clean-markdown-pill") in InputPane to rewrite raw input into canonical CSV in place while recording an undo snapshot. - Add bundled changelog entry #21 and unit/component test coverage. Co-authored-by: David Boskovic --- ...s => data-grid-overlay-editor-DkEjJU3p.js} | 2 +- app/dist/assets/index-BUu7Yvl3.js | 310 ++++++++++++++++++ app/dist/assets/index-BweuKm2D.js | 307 ----------------- ...7.js => number-overlay-editor-D2EysIl4.js} | 2 +- app/dist/index.html | 2 +- app/src/App.test.tsx | 89 +++++ app/src/changelog/entries.ts | 8 + app/src/components/CsvTable.tsx | 17 +- app/src/components/InputPane.tsx | 37 ++- app/src/lib/__tests__/convert.test.ts | 67 ++++ app/src/lib/convert.ts | 21 +- app/src/lib/csvTable.ts | 9 +- app/src/lib/markdownTable.test.ts | 127 +++++++ app/src/lib/markdownTable.ts | 238 ++++++++++++++ 14 files changed, 915 insertions(+), 321 deletions(-) rename app/dist/assets/{data-grid-overlay-editor-D184XVUK.js => data-grid-overlay-editor-DkEjJU3p.js} (98%) create mode 100644 app/dist/assets/index-BUu7Yvl3.js delete mode 100644 app/dist/assets/index-BweuKm2D.js rename app/dist/assets/{number-overlay-editor-cI9rZOV7.js => number-overlay-editor-D2EysIl4.js} (99%) create mode 100644 app/src/lib/markdownTable.test.ts create mode 100644 app/src/lib/markdownTable.ts diff --git a/app/dist/assets/data-grid-overlay-editor-D184XVUK.js b/app/dist/assets/data-grid-overlay-editor-DkEjJU3p.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-D184XVUK.js rename to app/dist/assets/data-grid-overlay-editor-DkEjJU3p.js index 0c11ef8..abfc8c5 100644 --- a/app/dist/assets/data-grid-overlay-editor-D184XVUK.js +++ b/app/dist/assets/data-grid-overlay-editor-DkEjJU3p.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-BweuKm2D.js";const te=()=>t=>t.targetX,re=()=>t=>t.targetY,ne=()=>t=>t.targetWidth,ie=()=>t=>t.targetHeight,se=()=>t=>t.targetY+10,ae=()=>t=>Math.max(0,(t.targetHeight-28)/2),oe=$("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[re(),"px"],"d19meir1-1":[te(),"px"],"d19meir1-2":[ne(),"px"],"d19meir1-3":[ie(),"px"],"d19meir1-4":[se(),"px"],"d19meir1-5":[ae(),"px"]}});function de(){const[t,s]=r.useState();return[t??void 0,s]}function le(){const[t,s]=de(),[i,y]=r.useState(0),[m,x]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&x(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:S}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-S-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const O=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:O}}const ce=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:x,imageEditorOverride:O,markdownDivCreateNode:a,highlight:o,className:S,theme:p,id:H,cell:v,bloom:c,validateCell:d,getCellRenderer:F,provideEditor:h,isOutsideClick:X}=t,[l,A]=r.useState(m?i:void 0),k=r.useRef(l??i);k.current=l??i;const[E,R]=r.useState(()=>d===void 0?!0:!(w(i)&&(d==null?void 0:d(v,i,k.current))===!1)),f=r.useCallback((e,n)=>{y(E?e:void 0,n)},[E,y]),K=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&w(e)){const n=d(v,e,k.current);n===!1?R(!1):(typeof n=="object"&&(e=n),R(!0))}A(e)},[v,d]),C=r.useRef(!1),g=r.useRef(void 0),W=r.useCallback(()=>{f(l,[0,0]),C.current=!0},[l,f]),Y=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),C.current=!0},[f]),j=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!C.current&&g.current!==void 0&&(f(n?l:void 0,g.current),C.current=!0)},0)},[f,l]),D=l??i,[u,q]=r.useMemo(()=>{var n,G;if(z(i))return[];const e=h==null?void 0:h(i);return e!==void 0?[e,!1]:[(G=(n=F(i))==null?void 0:n.provideEditor)==null?void 0:G.call(n,i),!1]},[i,F,h]),{ref:B,style:L}=le();let P=!0,M,_=!0,b;if(u!==void 0){P=u.disablePadding!==!0,_=u.disableStyling!==!0;const e=J(u);e&&(b=u.styleOverride);const n=e?u.editor:u;M=r.createElement(n,{isHighlighted:o,onChange:K,value:D,initialValue:x,onFinishedEditing:Y,validatedSelection:w(D)?D.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:O,markdownDivCreateNode:a,isValid:E,theme:p})}b={...b,...L};const N=document.getElementById("portal");if(N===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let I=_?"gdg-style":"gdg-unstyle";E||(I+=" gdg-invalid"),P&&(I+=" gdg-pad");const T=(c==null?void 0:c[0])??1,V=(c==null?void 0:c[1])??1;return Q.createPortal(r.createElement(U.Provider,{value:p},r.createElement(Z,{style:ee(p),className:S,onClickOutside:W,isOutsideClick:X},r.createElement(oe,{ref:B,id:H,className:I,style:b,as:q===!0?"label":void 0,targetX:s.x-T,targetY:s.y-V,targetWidth:s.width+T*2,targetHeight:s.height+V*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:j},M)))),N)};export{ce as default}; +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-BUu7Yvl3.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-BUu7Yvl3.js b/app/dist/assets/index-BUu7Yvl3.js new file mode 100644 index 0000000..04e4821 --- /dev/null +++ b/app/dist/assets/index-BUu7Yvl3.js @@ -0,0 +1,310 @@ +var rO=Object.defineProperty;var iO=(t,e,n)=>e in t?rO(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var xt=(t,e,n)=>iO(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 ho=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wi(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var oC={exports:{}},ip={},lC={exports:{}},Mt={};/** + * @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 Vc=Symbol.for("react.element"),sO=Symbol.for("react.portal"),oO=Symbol.for("react.fragment"),lO=Symbol.for("react.strict_mode"),aO=Symbol.for("react.profiler"),uO=Symbol.for("react.provider"),cO=Symbol.for("react.context"),fO=Symbol.for("react.forward_ref"),dO=Symbol.for("react.suspense"),hO=Symbol.for("react.memo"),pO=Symbol.for("react.lazy"),o1=Symbol.iterator;function gO(t){return t===null||typeof t!="object"?null:(t=o1&&t[o1]||t["@@iterator"],typeof t=="function"?t:null)}var aC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},uC=Object.assign,cC={};function Ka(t,e,n){this.props=t,this.context=e,this.refs=cC,this.updater=n||aC}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 fC(){}fC.prototype=Ka.prototype;function Uy(t,e,n){this.props=t,this.context=e,this.refs=cC,this.updater=n||aC}var Ky=Uy.prototype=new fC;Ky.constructor=Uy;uC(Ky,Ka.prototype);Ky.isPureReactComponent=!0;var l1=Array.isArray,dC=Object.prototype.hasOwnProperty,Xy={current:null},hC={key:!0,ref:!0,__self:!0,__source:!0};function pC(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)dC.call(e,r)&&!hC.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))mei(le,B)?(W[N]=le,W[me]=R,N=me):(W[N]=B,W[G]=R,N=G);else if(mei(le,R))W[N]=le,W[me]=R,N=me;else break e}}return V}function i(W,V){var R=W.sortIndex-V.sortIndex;return R!==0?R:W.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(W){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=W)r(u),V.sortIndex=V.expirationTime,e(a,V);else break;V=n(u)}}function k(W){if(g=!1,w(W),!p)if(n(a)!==null)p=!0,ie(x);else{var V=n(u);V!==null&&Z(k,V.startTime-W)}}function x(W,V){p=!1,g&&(g=!1,m(A),A=-1),h=!0;var R=d;try{for(w(V),f=n(a);f!==null&&(!(f.expirationTime>V)||W&&!D());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=V);V=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(V)}else r(a);f=n(a)}if(f!==null)var z=!0;else{var G=n(u);G!==null&&Z(k,G.startTime-V),z=!1}return z}finally{f=null,d=R,h=!1}}var S=!1,T=null,A=-1,M=5,O=-1;function D(){return!(t.unstable_now()-OW||125N?(W.sortIndex=R,e(u,W),n(a)===null&&W===n(u)&&(g?(m(A),A=-1):g=!0,Z(k,R-N))):(W.sortIndex=L,e(a,W),p||h||(p=!0,ie(x))),W},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(W){var V=d;return function(){var R=d;d=V;try{return W.apply(this,arguments)}finally{d=R}}}})(wC);vC.exports=wC;var EO=vC.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 AO=v,Gr=EO;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"),Bm=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]*$/,u1={},c1={};function RO(t){return Bm.call(c1,t)?!0:Bm.call(u1,t)?!1:MO.test(t)?c1[t]=!0:(u1[t]=!0,!1)}function OO(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 PO(t,e,n,r){if(e===null||typeof e>"u"||OO(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 wr(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 wr(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 wr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Gn[t]=new wr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Gn[t]=new wr(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 wr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Gn[t]=new wr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Gn[t]=new wr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Gn[t]=new wr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Gn[t]=new wr(t,5,!1,t.toLowerCase(),null,!1,!1)});var qy=/[\-:]([a-z])/g;function Yy(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(qy,Yy);Gn[e]=new wr(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(qy,Yy);Gn[e]=new wr(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(qy,Yy);Gn[e]=new wr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Gn[t]=new wr(t,1,!1,t.toLowerCase(),null,!1,!1)});Gn.xlinkHref=new wr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Gn[t]=new wr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Jy(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{yg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Fu(t):""}function IO(t){switch(t.tag){case 5:return Fu(t.type);case 16:return Fu("Lazy");case 13:return Fu("Suspense");case 19:return Fu("SuspenseList");case 0:case 2:case 15:return t=vg(t.type,!1),t;case 11:return t=vg(t.type.render,!1),t;case 1:return t=vg(t.type,!0),t;default:return""}}function Wm(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Zl:return"Fragment";case Ql:return"Portal";case zm:return"Profiler";case Qy:return"StrictMode";case jm:return"Suspense";case Hm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case kC:return(t.displayName||"Context")+".Consumer";case xC:return(t._context.displayName||"Context")+".Provider";case Zy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ev:return e=t.displayName||null,e!==null?e:Wm(t.type)||"Memo";case io:e=t._payload,t=t._init;try{return Wm(t(e))}catch{}}return null}function NO(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 Wm(e);case 8:return e===Qy?"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 Ao(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function CC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function _O(t){var e=CC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Nf(t){t._valueTracker||(t._valueTracker=_O(t))}function TC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=CC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Yd(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 Vm(t,e){var n=e.checked;return hn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function d1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Ao(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 EC(t,e){e=e.checked,e!=null&&Jy(t,"checked",e,!1)}function Um(t,e){EC(t,e);var n=Ao(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")?Km(t,e.type,n):e.hasOwnProperty("defaultValue")&&Km(t,e.type,Ao(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function h1(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 Km(t,e,n){(e!=="number"||Yd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Bu=Array.isArray;function ma(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=_f.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function yc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Ku={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},DO=["Webkit","ms","Moz","O"];Object.keys(Ku).forEach(function(t){DO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Ku[e]=Ku[t]})});function OC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Ku.hasOwnProperty(t)&&Ku[t]?(""+e).trim():e+"px"}function PC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=OC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var LO=hn({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 qm(t,e){if(e){if(LO[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 Ym(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Jm=null;function tv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Qm=null,ya=null,va=null;function m1(t){if(t=Xc(t)){if(typeof Qm!="function")throw Error(pe(280));var e=t.stateNode;e&&(e=up(e),Qm(t.stateNode,t.type,e))}}function IC(t){ya?va?va.push(t):va=[t]:ya=t}function NC(){if(ya){var t=ya,e=va;if(va=ya=null,m1(t),e)for(t=0;t>>=0,t===0?32:31-(XO(t)/GO|0)|0}var Df=64,Lf=4194304;function zu(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 eh(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=zu(l):(s&=o,s!==0&&(r=zu(s)))}else o=n&~i,o!==0?r=zu(o):s!==0&&(r=zu(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 Uc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Bi(e),t[e]=n}function QO(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=Gu),T1=" ",E1=!1;function ZC(t,e){switch(t){case"keyup":return EP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function e2(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function MP(t,e){switch(t){case"compositionend":return e2(e);case"keypress":return e.which!==32?null:(E1=!0,T1);case"textInput":return t=e.data,t===T1&&E1?null:t;default:return null}}function RP(t,e){if(ea)return t==="compositionend"||!uv&&ZC(t,e)?(t=JC(),Od=ov=po=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=O1(n)}}function i2(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?i2(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function s2(){for(var t=window,e=Yd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Yd(t.document)}return e}function cv(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 FP(t){var e=s2(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&i2(n.ownerDocument.documentElement,n)){if(r!==null&&cv(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=P1(n,s);var o=P1(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,i0=null,Yu=null,s0=!1;function I1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;s0||ta==null||ta!==Yd(r)||(r=ta,"selectionStart"in r&&cv(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}),Yu&&Sc(Yu,r)||(Yu=r,r=rh(i0,"onSelect"),0ia||(t.current=f0[ia],f0[ia]=null,ia--)}function en(t,e){ia++,f0[ia]=t.current,t.current=e}var Mo={},or=Do(Mo),Ar=Do(!1),gl=Mo;function Ra(t,e){var n=t.type.contextTypes;if(!n)return Mo;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 sh(){sn(Ar),sn(or)}function B1(t,e,n){if(or.current!==Mo)throw Error(pe(168));en(or,e),en(Ar,n)}function p2(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,NO(t)||"Unknown",i));return hn({},n,r)}function oh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Mo,gl=or.current,en(or,t),en(Ar,Ar.current),!0}function z1(t,e,n){var r=t.stateNode;if(!r)throw Error(pe(169));n?(t=p2(t,e,gl),r.__reactInternalMemoizedMergedChildContext=t,sn(Ar),sn(or),en(or,t)):sn(Ar),en(Ar,n)}var Es=null,cp=!1,Ig=!1;function g2(t){Es===null?Es=[t]:Es.push(t)}function YP(t){cp=!0,g2(t)}function Lo(){if(!Ig&&Es!==null){Ig=!0;var t=0,e=Ht;try{var n=Es;for(Ht=1;t>=o,i-=o,Ps=1<<32-Bi(e)+i|n<A?(M=T,T=null):M=T.sibling;var O=d(m,T,w[A],k);if(O===null){T===null&&(T=M);break}t&&T&&O.alternate===null&&e(m,T),y=s(O,y,A),S===null?x=O:S.sibling=O,S=O,T=M}if(A===w.length)return n(m,T),un&&Qo(m,A),x;if(T===null){for(;AA?(M=T,T=null):M=T.sibling;var D=d(m,T,O.value,k);if(D===null){T===null&&(T=M);break}t&&T&&D.alternate===null&&e(m,T),y=s(D,y,A),S===null?x=D:S.sibling=D,S=D,T=M}if(O.done)return n(m,T),un&&Qo(m,A),x;if(T===null){for(;!O.done;A++,O=w.next())O=f(m,O.value,k),O!==null&&(y=s(O,y,A),S===null?x=O:S.sibling=O,S=O);return un&&Qo(m,A),x}for(T=r(m,T);!O.done;A++,O=w.next())O=h(T,m,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?x=O:S.sibling=O,S=O);return t&&T.forEach(function(P){return e(m,P)}),un&&Qo(m,A),x}function b(m,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 If:e:{for(var x=w.key,S=y;S!==null;){if(S.key===x){if(x=w.type,x===Zl){if(S.tag===7){n(m,S.sibling),y=i(S,w.props.children),y.return=m,m=y;break e}}else if(S.elementType===x||typeof x=="object"&&x!==null&&x.$$typeof===io&&W1(x)===S.type){n(m,S.sibling),y=i(S,w.props),y.ref=xu(m,S,w),y.return=m,m=y;break e}n(m,S);break}else e(m,S);S=S.sibling}w.type===Zl?(y=dl(w.props.children,m.mode,k,w.key),y.return=m,m=y):(k=Fd(w.type,w.key,w.props,null,m.mode,k),k.ref=xu(m,y,w),k.return=m,m=k)}return o(m);case Ql:e:{for(S=w.key;y!==null;){if(y.key===S)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(m,y.sibling),y=i(y,w.children||[]),y.return=m,m=y;break e}else{n(m,y);break}else e(m,y);y=y.sibling}y=zg(w,m.mode,k),y.return=m,m=y}return o(m);case io:return S=w._init,b(m,y,S(w._payload),k)}if(Bu(w))return p(m,y,w,k);if(mu(w))return g(m,y,w,k);Wf(m,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(m,y.sibling),y=i(y,w),y.return=m,m=y):(n(m,y),y=Bg(w,m.mode,k),y.return=m,m=y),o(m)):n(m,y)}return b}var Pa=w2(!0),b2=w2(!1),uh=Do(null),ch=null,la=null,pv=null;function gv(){pv=la=ch=null}function mv(t){var e=uh.current;sn(uh),t._currentValue=e}function p0(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 ba(t,e){ch=t,pv=la=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Tr=!0),t.firstContext=null)}function gi(t){var e=t._currentValue;if(pv!==t)if(t={context:t,memoizedValue:e,next:null},la===null){if(ch===null)throw Error(pe(308));la=t,ch.dependencies={lanes:0,firstContext:t}}else la=la.next=t;return e}var ll=null;function yv(t){ll===null?ll=[t]:ll.push(t)}function x2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,yv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Fs(t,r)}function Fs(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var so=!1;function vv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function k2(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 _s(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function ko(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,Dt&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Fs(t,n)}return i=r.interleaved,i===null?(e.next=e,yv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Fs(t,n)}function Id(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,rv(t,n)}}function V1(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 fh(t,e,n,r){var i=t.updateQueue;so=!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,g=l;switch(d=e,h=n,g.tag){case 1:if(p=g.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=g.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=hn({},f,d);break e;case 2:so=!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);vl|=o,t.lanes=o,t.memoizedState=f}}function U1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=_g.transition;_g.transition={};try{t(!1),e()}finally{Ht=n,_g.transition=r}}function B2(){return mi().memoizedState}function eI(t,e,n){var r=Co(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},z2(t))j2(e,n);else if(n=x2(t,e,n,r),n!==null){var i=gr();zi(n,t,r,i),H2(n,e,r)}}function tI(t,e,n){var r=Co(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(z2(t))j2(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,ji(l,o)){var a=e.interleaved;a===null?(i.next=i,yv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=x2(t,e,i,r),n!==null&&(i=gr(),zi(n,t,r,i),H2(n,e,r))}}function z2(t){var e=t.alternate;return t===dn||e!==null&&e===dn}function j2(t,e){Ju=hh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function H2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,rv(t,n)}}var ph={readContext:gi,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},nI={readContext:gi,useCallback:function(t,e){return ts().memoizedState=[t,e===void 0?null:e],t},useContext:gi,useEffect:X1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,_d(4194308,4,_2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return _d(4194308,4,t,e)},useInsertionEffect:function(t,e){return _d(4,2,t,e)},useMemo:function(t,e){var n=ts();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=ts();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=eI.bind(null,dn,t),[r.memoizedState,t]},useRef:function(t){var e=ts();return t={current:t},e.memoizedState=t},useState:K1,useDebugValue:Ev,useDeferredValue:function(t){return ts().memoizedState=t},useTransition:function(){var t=K1(!1),e=t[0];return t=ZP.bind(null,t[1]),ts().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=dn,i=ts();if(un){if(n===void 0)throw Error(pe(407));n=n()}else{if(n=e(),Hn===null)throw Error(pe(349));yl&30||E2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,X1(M2.bind(null,r,s,t),[t]),r.flags|=2048,Pc(9,A2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=ts(),e=Hn.identifierPrefix;if(un){var n=Is,r=Ps;n=(r&~(1<<32-Bi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Rc++,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[ns]=e,t[Ec]=r,Q2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Ym(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;i_a&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304)}else{if(!r)if(t=dh(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&&!un)return er(e),null}else 2*En()-s.renderingStartTime>_a&&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=En(),e.sibling=null,n=fn.current,en(fn,r?n&1|2:n&1),e):(er(e),null);case 22:case 23:return Iv(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?zr&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 cI(t,e){switch(dv(e),e.tag){case 1:return Mr(e.type)&&sh(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ia(),sn(Ar),sn(or),xv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return bv(e),null;case 13:if(sn(fn),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(fn),null;case 4:return Ia(),null;case 10:return mv(e.type._context),null;case 22:case 23:return Iv(),null;case 24:return null;default:return null}}var Uf=!1,ir=!1,fI=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function aa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){mn(t,e,r)}else n.current=null}function S0(t,e,n){try{n()}catch(r){mn(t,e,r)}}var ib=!1;function dI(t,e){if(o0=th,t=s2(),cv(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(l0={focusedElem:t,selectionRange:n},th=!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 g=p.memoizedProps,b=p.memoizedState,m=e.stateNode,y=m.getSnapshotBeforeUpdate(e.elementType===e.type?g:Ri(e.type,g),b);m.__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){mn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Oe=t;break}Oe=e.return}return p=ib,ib=!1,p}function Qu(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&&S0(e,n,s)}i=i.next}while(i!==r)}}function hp(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 C0(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 tT(t){var e=t.alternate;e!==null&&(t.alternate=null,tT(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[ns],delete e[Ec],delete e[c0],delete e[GP],delete e[qP])),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 nT(t){return t.tag===5||t.tag===3||t.tag===4}function sb(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||nT(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 T0(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=ih));else if(r!==4&&(t=t.child,t!==null))for(T0(t,e,n),t=t.sibling;t!==null;)T0(t,e,n),t=t.sibling}function E0(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(E0(t,e,n),t=t.sibling;t!==null;)E0(t,e,n),t=t.sibling}var Wn=null,Oi=!1;function qs(t,e,n){for(n=n.child;n!==null;)rT(t,e,n),n=n.sibling}function rT(t,e,n){if(fs&&typeof fs.onCommitFiberUnmount=="function")try{fs.onCommitFiberUnmount(sp,n)}catch{}switch(n.tag){case 5:ir||aa(n,e);case 6:var r=Wn,i=Oi;Wn=null,qs(t,e,n),Wn=r,Oi=i,Wn!==null&&(Oi?(t=Wn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Wn.removeChild(n.stateNode));break;case 18:Wn!==null&&(Oi?(t=Wn,n=n.stateNode,t.nodeType===8?Pg(t.parentNode,n):t.nodeType===1&&Pg(t,n),xc(t)):Pg(Wn,n.stateNode));break;case 4:r=Wn,i=Oi,Wn=n.stateNode.containerInfo,Oi=!0,qs(t,e,n),Wn=r,Oi=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)&&S0(n,e,o),i=i.next}while(i!==r)}qs(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){mn(n,e,l)}qs(t,e,n);break;case 21:qs(t,e,n);break;case 22:n.mode&1?(ir=(r=ir)||n.memoizedState!==null,qs(t,e,n),ir=r):qs(t,e,n);break;default:qs(t,e,n)}}function ob(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new fI),e.forEach(function(r){var i=xI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ei(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=En()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*pI(r/1960))-r,10t?16:t,go===null)var r=!1;else{if(t=go,go=null,yh=0,Dt&6)throw Error(pe(331));var i=Dt;for(Dt|=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;aEn()-Ov?fl(t,0):Rv|=n),Rr(t,e)}function fT(t,e){e===0&&(t.mode&1?(e=Lf,Lf<<=1,!(Lf&130023424)&&(Lf=4194304)):e=1);var n=gr();t=Fs(t,e),t!==null&&(Uc(t,e,n),Rr(t,n))}function bI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),fT(t,n)}function xI(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),fT(t,n)}var dT;dT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ar.current)Tr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Tr=!1,aI(t,e,n);Tr=!!(t.flags&131072)}else Tr=!1,un&&e.flags&1048576&&m2(e,ah,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Dd(t,e),t=e.pendingProps;var i=Ra(e,or.current);ba(e,n),i=Sv(null,e,r,t,i,n);var s=Cv();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,oh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,vv(e),i.updater=dp,e.stateNode=i,i._reactInternals=e,m0(e,r,t,n),e=w0(null,e,r,!0,s,n)):(e.tag=0,un&&s&&fv(e),dr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Dd(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=SI(r),t=Ri(r,t),i){case 0:e=v0(null,e,r,t,n);break e;case 1:e=tb(null,e,r,t,n);break e;case 11:e=Z1(null,e,r,t,n);break e;case 14:e=eb(null,e,r,Ri(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:Ri(r,i),v0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ri(r,i),tb(t,e,r,i,n);case 3:e:{if(q2(e),t===null)throw Error(pe(387));r=e.pendingProps,s=e.memoizedState,i=s.element,k2(t,e),fh(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=nb(t,e,r,n,i);break e}else if(r!==i){i=Na(Error(pe(424)),e),e=nb(t,e,r,n,i);break e}else for(Kr=xo(e.stateNode.containerInfo.firstChild),Xr=e,un=!0,Pi=null,n=b2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Oa(),r===i){e=Bs(t,e,n);break e}dr(t,e,r,n)}e=e.child}return e;case 5:return S2(e),t===null&&h0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,a0(r,i)?o=null:s!==null&&a0(r,s)&&(e.flags|=32),G2(t,e),dr(t,e,o,n),e.child;case 6:return t===null&&h0(e),null;case 13:return Y2(t,e,n);case 4:return wv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Pa(e,null,r,n):dr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ri(r,i),Z1(t,e,r,i,n);case 7:return dr(t,e,e.pendingProps,n),e.child;case 8:return dr(t,e,e.pendingProps.children,n),e.child;case 12:return dr(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,en(uh,r._currentValue),r._currentValue=o,s!==null)if(ji(s.value,o)){if(s.children===i.children&&!Ar.current){e=Bs(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=_s(-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),p0(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),p0(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}dr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,ba(e,n),i=gi(i),r=r(i),e.flags|=1,dr(t,e,r,n),e.child;case 14:return r=e.type,i=Ri(r,e.pendingProps),i=Ri(r.type,i),eb(t,e,r,i,n);case 15:return K2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ri(r,i),Dd(t,e),e.tag=1,Mr(r)?(t=!0,oh(e)):t=!1,ba(e,n),W2(e,r,i),m0(e,r,i,n),w0(null,e,r,!0,t,n);case 19:return J2(t,e,n);case 22:return X2(t,e,n)}throw Error(pe(156,e.tag))};function hT(t,e){return zC(t,e)}function kI(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 li(t,e,n,r){return new kI(t,e,n,r)}function _v(t){return t=t.prototype,!(!t||!t.isReactComponent)}function SI(t){if(typeof t=="function")return _v(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Zy)return 11;if(t===ev)return 14}return 2}function To(t,e){var n=t.alternate;return n===null?(n=li(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 Fd(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")_v(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Zl:return dl(n.children,i,s,e);case Qy:o=8,i|=8;break;case zm:return t=li(12,n,e,i|2),t.elementType=zm,t.lanes=s,t;case jm:return t=li(13,n,e,i),t.elementType=jm,t.lanes=s,t;case Hm:return t=li(19,n,e,i),t.elementType=Hm,t.lanes=s,t;case SC:return gp(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case xC:o=10;break e;case kC:o=9;break e;case Zy:o=11;break e;case ev:o=14;break e;case io:o=16,r=null;break e}throw Error(pe(130,t==null?t:typeof t,""))}return e=li(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function dl(t,e,n,r){return t=li(7,t,r,e),t.lanes=n,t}function gp(t,e,n,r){return t=li(22,t,r,e),t.elementType=SC,t.lanes=n,t.stateNode={isHidden:!1},t}function Bg(t,e,n){return t=li(6,t,null,e),t.lanes=n,t}function zg(t,e,n){return e=li(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function CI(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=bg(0),this.expirationTimes=bg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=bg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Dv(t,e,n,r,i,s,o,l,a){return t=new CI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=li(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},vv(s),t}function TI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(yT)}catch(t){console.error(t)}}yT(),yC.exports=qr;var OI=yC.exports,vT,pb=OI;vT=pb.createRoot,pb.hydrateRoot;function wT(){return""}function PI(){return/^G-[A-Z0-9]+$/.test(wT())}function II(){const t=window.gtag;typeof t=="function"&&PI()&&t("config",wT(),{send_page_view:!1})}function NI(){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 _I(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function DI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function LI(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 $I(t){return t.charAt(0).toUpperCase()+t.slice(1)}function bp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,$I(t),{props:{...e}})}function FI(t){bp("input",t)}function BI(t){bp("conversion",t)}function Ko(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};bp("export",e)}function zI(t){bp("feedback",t)}function jI(t){return new TextEncoder().encode(t).length}function HI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function WI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function VI(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=jI(h.text),g=HI(p),b=i(h.direction,h.text),m=`${h.direction}:${h.input}:${p}:${WI(h.text)}`,y=r();return m!==l&&(a===0||y-a>=n)&&(l=m,a=y,FI({direction:h.direction,input:h.input,size:g,valid:b})),!b||m===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,g){s={direction:h,input:p,text:g},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 bT=(...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 UI=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 KI=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 gb=t=>{const e=KI(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 jg={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 XI=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},GI=v.createContext({}),qI=()=>v.useContext(GI),YI=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=""}=qI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,...jg,width:e??u??jg.width,height:e??u??jg.height,stroke:t??d,strokeWidth:p,className:bT("lucide",h,i),...!s&&!XI(l)&&{"aria-hidden":"true"},...l},[...o.map(([g,b])=>v.createElement(g,b)),...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 Mn=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement(YI,{ref:s,iconNode:e,className:bT(`lucide-${UI(gb(t))}`,`lucide-${t}`,r),...i}));return n.displayName=gb(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"}]],QI=Mn("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 ZI=[["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"}]],mb=Mn("braces",ZI);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const eN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],tN=Mn("chevron-down",eN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const nN=[["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"}]],rN=Mn("clipboard",nN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const iN=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],sN=Mn("clock",iN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const oN=[["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"}]],Bv=Mn("copy",oN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const lN=[["path",{d:"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"}]],xT=Mn("download",lN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const aN=[["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"}]],kT=Mn("file-up",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 uN=[["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"}]],cN=Mn("moon",uN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fN=[["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"}]],dN=Mn("redo-2",fN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hN=[["path",{d:"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"}]],pN=Mn("rotate-ccw-clock",hN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gN=[["path",{d:"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"}]],yb=Mn("rotate-ccw",gN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],yN=Mn("search",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:"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"}]],wN=Mn("sparkles",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 bN=[["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"}]],xN=Mn("sun",bN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kN=[["path",{d:"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"}]],SN=Mn("table",kN);/** + * @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:"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"}]],TN=Mn("thumbs-down",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 EN=[["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"}]],AN=Mn("thumbs-up",EN);/** + * @license lucide-react v1.41.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const 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"}]],bh=Mn("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 RN=[["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"}]],ON=Mn("undo-2",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 PN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],xh=Mn("x",PN);function ST(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=DN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(zv);return l[0]===""&&l.length!==1&&l.shift(),CT(l,e)||_N(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},CT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?CT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(zv);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},vb=/^\[(.+)\]$/,_N=t=>{if(vb.test(t)){const e=vb.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},DN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return $N(Object.entries(t.classGroups),n).forEach(([s,o])=>{P0(o,r,s,e)}),r},P0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:wb(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(LN(i)){P0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{P0(o,wb(e,s),n,r)})})},wb=(t,e)=>{let n=t;return e.split(zv).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},LN=t=>t.isThemeGetter,$N=(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,FN=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)}}},TT="!",BN=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 b=0;bc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:g}};return n?l=>n({className:l,parseClassName:o}):o},zN=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},jN=t=>({cache:FN(t.cacheSize),parseClassName:BN(t),...NN(t)}),HN=/\s+/,WN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(HN);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,g=r(p?d.substring(0,h):d);if(!g){if(!p){l=u+(l.length>0?" "+l:l);continue}if(g=r(d),!g){l=u+(l.length>0?" "+l:l);continue}p=!1}const b=zN(c).join(":"),m=f?b+TT:b,y=m+g;if(s.includes(y))continue;s.push(y);const w=i(g,p);for(let k=0;k0?" "+l:l)}return l};function VN(){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=jN(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=WN(a,n);return i(a,c),c}return function(){return s(VN.apply(null,arguments))}}const tn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},AT=/^\[(?:([a-z-]+):)?(.+)\]$/i,KN=/^\d+\/\d+$/,XN=new Set(["px","full","screen"]),GN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qN=/\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$/,YN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,JN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,QN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ss=t=>ka(t)||XN.has(t)||KN.test(t),Ys=t=>qa(t,"length",o_),ka=t=>!!t&&!Number.isNaN(Number(t)),Hg=t=>qa(t,"number",ka),Cu=t=>!!t&&Number.isInteger(Number(t)),ZN=t=>t.endsWith("%")&&ka(t.slice(0,-1)),mt=t=>AT.test(t),Js=t=>GN.test(t),e_=new Set(["length","size","percentage"]),t_=t=>qa(t,e_,MT),n_=t=>qa(t,"position",MT),r_=new Set(["image","url"]),i_=t=>qa(t,r_,a_),s_=t=>qa(t,"",l_),Tu=()=>!0,qa=(t,e,n)=>{const r=AT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},o_=t=>qN.test(t)&&!YN.test(t),MT=()=>!1,l_=t=>JN.test(t),a_=t=>QN.test(t),u_=()=>{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"),g=tn("inset"),b=tn("margin"),m=tn("opacity"),y=tn("padding"),w=tn("saturate"),k=tn("scale"),x=tn("sepia"),S=tn("skew"),T=tn("space"),A=tn("translate"),M=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],D=()=>["auto",mt,e],P=()=>[mt,e],I=()=>["",Ss,Ys],_=()=>["auto",ka,mt],te=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",mt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[ka,mt];return{cacheSize:500,separator:":",theme:{colors:[Tu],spacing:[Ss,Ys],blur:["none","",Js,mt],brightness:N(),borderColor:[t],borderRadius:["none","","full",Js,mt],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:V(),hueRotate:N(),invert:V(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[ZN,Ys],inset:D(),margin:D(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:V(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",mt]}],container:["container"],columns:[{columns:[Js]}],"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:[...te(),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:[g]}],"inset-x":[{"inset-x":[g]}],"inset-y":[{"inset-y":[g]}],start:[{start:[g]}],end:[{end:[g]}],top:[{top:[g]}],right:[{right:[g]}],bottom:[{bottom:[g]}],left:[{left:[g]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Cu,mt]}],basis:[{basis:D()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",mt]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",Cu,mt]}],"grid-cols":[{"grid-cols":[Tu]}],"col-start-end":[{col:["auto",{span:["full",Cu,mt]},mt]}],"col-start":[{"col-start":_()}],"col-end":[{"col-end":_()}],"grid-rows":[{"grid-rows":[Tu]}],"row-start-end":[{row:["auto",{span:[Cu,mt]},mt]}],"row-start":[{"row-start":_()}],"row-end":[{"row-end":_()}],"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:[b]}],mx:[{mx:[b]}],my:[{my:[b]}],ms:[{ms:[b]}],me:[{me:[b]}],mt:[{mt:[b]}],mr:[{mr:[b]}],mb:[{mb:[b]}],ml:[{ml:[b]}],"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:[Js]},Js]}],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",Js,Ys]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Hg]}],"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,Hg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ss,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":[m]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[m]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ss,Ys]}],"underline-offset":[{"underline-offset":["auto",Ss,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":[m]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...te(),n_]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",t_]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},i_]}],"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":[m]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[m]}],"divide-style":[{divide:ie()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[Ss,mt]}],"outline-w":[{outline:[Ss,Ys]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[m]}],"ring-offset-w":[{"ring-offset":[Ss,Ys]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Js,s_]}],"shadow-color":[{shadow:[Tu]}],opacity:[{opacity:[m]}],"mix-blend":[{"mix-blend":[...Z(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Z()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Js,mt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[x]}],"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":[m]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[x]}],"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:[Ss,Ys,Hg]}],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"]}}},c_=UN(u_);function pr(...t){return c_(IN(t))}function Wg(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function f_({flipped:t}){return E.jsx(QI,{size:18,strokeWidth:2,"aria-hidden":"true",className:pr("transition-transform duration-300",t&&"rotate-180")})}function d_({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 ${Wg(t)})`,"aria-label":`Switch conversion direction (currently ${Wg(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(f_,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Wg(t)})]})}const RT=[{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."}],h_={"@context":"https://schema.org","@type":"FAQPage",mainEntity:RT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function p_(){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:RT.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(h_)}})]})}const g_="https://github.com/FlatFilers/csvjson-app/discussions/163";function m_(){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:g_,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 OT="csvjson:feedback.v1",y_=[{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 v_(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 bb(){try{const t=window.localStorage.getItem(OT);if(t===null)return null;const e=JSON.parse(t);return v_(e)?e:null}catch{return null}}function xb(t){try{window.localStorage.setItem(OT,JSON.stringify(t))}catch{}}function kb(){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 w_(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 b_(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w_(t))})).ok?"ok":"failed"}catch{return"failed"}}function Sb(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 x_(){const[t,e]=v.useState(bb),[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((x,S)=>{const T={...x,pending:S==="failed"};xb(T),e(T),S==="ok"?zI({vote:x.vote,with_reason:x.reasonCode!==null}):u(!1)},[]),g=v.useCallback((x,S)=>{const T=++h.current;S&&f(!0),b_(x).then(A=>{h.current===T&&(p(x,A),A==="ok"&&u(!0))}).finally(()=>{S&&h.current===T&&f(!1)})},[p]),b=x=>{const S={...x,pending:!0};xb(S),e(S),g(S,!0)},m=v.useRef(!1);v.useEffect(()=>{if(m.current)return;m.current=!0;const x=bb();x!=null&&x.pending&&g(x,!1)},[g]),v.useEffect(()=>{if(!a)return;const x=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(x)},[a]),v.useEffect(()=>{if(!n)return;const x=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",x),document.addEventListener("mousedown",S),()=>{document.removeEventListener("keydown",x),document.removeEventListener("mousedown",S)}},[n]);const y=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}b({clientId:(t==null?void 0:t.clientId)??kb(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const x=o.trim();b({clientId:(t==null?void 0:t.clientId)??kb(),vote:-1,reasonCode:i,reasonText:x===""?null:x}),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:Sb((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:Sb((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:y_.map(x=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${x.value}`,"aria-pressed":i===x.value,onClick:()=>s(x.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===x.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:x.label},x.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:x=>l(x.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 PT(t="This should not happen"){throw new Error(t)}function Wr(t,e="Assertion failed"){if(!t)return PT(e)}function Nc(t,e){return PT(e??"Hell froze over")}function k_(t,e){try{return t()}catch{return e}}const Cb=Object.prototype.hasOwnProperty;function Da(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--&&Da(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(Cb.call(t,n)&&++r&&!Cb.call(e,n)||!(n in e)||!Da(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var S_=Object.prototype,C_=S_.hasOwnProperty;function T_(t,e){return t!=null&&C_.call(t,e)}var E_=T_,A_=Array.isArray,ms=A_,M_=typeof ho=="object"&&ho&&ho.Object===Object&&ho,IT=M_,R_=IT,O_=typeof self=="object"&&self&&self.Object===Object&&self,P_=R_||O_||Function("return this")(),ys=P_,I_=ys,N_=I_.Symbol,qc=N_,Tb=qc,NT=Object.prototype,__=NT.hasOwnProperty,D_=NT.toString,Eu=Tb?Tb.toStringTag:void 0;function L_(t){var e=__.call(t,Eu),n=t[Eu];try{t[Eu]=void 0;var r=!0}catch{}var i=D_.call(t);return r&&(e?t[Eu]=n:delete t[Eu]),i}var $_=L_,F_=Object.prototype,B_=F_.toString;function z_(t){return B_.call(t)}var j_=z_,Eb=qc,H_=$_,W_=j_,V_="[object Null]",U_="[object Undefined]",Ab=Eb?Eb.toStringTag:void 0;function K_(t){return t==null?t===void 0?U_:V_:Ab&&Ab in Object(t)?H_(t):W_(t)}var Yc=K_;function X_(t){return t!=null&&typeof t=="object"}var Jc=X_,G_=Yc,q_=Jc,Y_="[object Symbol]";function J_(t){return typeof t=="symbol"||q_(t)&&G_(t)==Y_}var xp=J_,Q_=ms,Z_=xp,eD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tD=/^\w*$/;function nD(t,e){if(Q_(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Z_(t)?!0:tD.test(t)||!eD.test(t)||e!=null&&t in Object(e)}var jv=nD;function rD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var Al=rD,iD=Yc,sD=Al,oD="[object AsyncFunction]",lD="[object Function]",aD="[object GeneratorFunction]",uD="[object Proxy]";function cD(t){if(!sD(t))return!1;var e=iD(t);return e==lD||e==aD||e==oD||e==uD}var _T=cD,fD=ys,dD=fD["__core-js_shared__"],hD=dD,Vg=hD,Mb=function(){var t=/[^.]+$/.exec(Vg&&Vg.keys&&Vg.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function pD(t){return!!Mb&&Mb in t}var gD=pD,mD=Function.prototype,yD=mD.toString;function vD(t){if(t!=null){try{return yD.call(t)}catch{}try{return t+""}catch{}}return""}var DT=vD,wD=_T,bD=gD,xD=Al,kD=DT,SD=/[\\^$.*+?()[\]{}|]/g,CD=/^\[object .+?Constructor\]$/,TD=Function.prototype,ED=Object.prototype,AD=TD.toString,MD=ED.hasOwnProperty,RD=RegExp("^"+AD.call(MD).replace(SD,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function OD(t){if(!xD(t)||bD(t))return!1;var e=wD(t)?RD:CD;return e.test(kD(t))}var PD=OD;function ID(t,e){return t==null?void 0:t[e]}var ND=ID,_D=PD,DD=ND;function LD(t,e){var n=DD(t,e);return _D(n)?n:void 0}var Ml=LD,$D=Ml,FD=$D(Object,"create"),kp=FD,Rb=kp;function BD(){this.__data__=Rb?Rb(null):{},this.size=0}var zD=BD;function jD(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var HD=jD,WD=kp,VD="__lodash_hash_undefined__",UD=Object.prototype,KD=UD.hasOwnProperty;function XD(t){var e=this.__data__;if(WD){var n=e[t];return n===VD?void 0:n}return KD.call(e,t)?e[t]:void 0}var GD=XD,qD=kp,YD=Object.prototype,JD=YD.hasOwnProperty;function QD(t){var e=this.__data__;return qD?e[t]!==void 0:JD.call(e,t)}var ZD=QD,eL=kp,tL="__lodash_hash_undefined__";function nL(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=eL&&e===void 0?tL:e,this}var rL=nL,iL=zD,sL=HD,oL=GD,lL=ZD,aL=rL;function Ya(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var TL=CL,EL=Sp;function AL(t,e){var n=this.__data__,r=EL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var ML=AL,RL=fL,OL=wL,PL=kL,IL=TL,NL=ML;function Ja(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=U3}var Gv=K3,X3=xp;function G3(t){if(typeof t=="string"||X3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var Ep=G3,q3=FT,Y3=Kv,J3=ms,Q3=Xv,Z3=Gv,e$=Ep;function t$(t,e,n){e=q3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new Ts(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=a$([...this.items,n]);return new Ts(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&&e$b??($b=new Ts([]))),xt(Ts,"fromSingleSelection",e=>Ts.empty().add(e));let Nt=Ts;function u$(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var c$=/^((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)-.*))$/,Ug=u$(function(t){return c$.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),f$=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(" ")},Fb=f$,d$=t=>t.toUpperCase()===t,h$=t=>e=>t.indexOf(e)===-1,jT=(t,e)=>{const n={};return Object.keys(t).filter(h$(e)).forEach(r=>{n[r]=t[r]}),n};function p$(t,e,n){const r=jT(e,n);if(!t){const i=typeof Ug=="function"?{default:Ug}:Ug;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var g$=(t,e)=>{};function m$(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&&!d$(l[0])):n.propsAsIs,c=p$(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Fb(n.class,c.className||a):Fb(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const g in f){const b=f[g],m=b[0],y=b[1]||"",w=typeof m=="function"?m(s):m;g$(w,n.name),d[`--${g}`]=`${w}${y}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(g=>{d[g]=h[g]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,$n.createElement(t,c)):$n.createElement(l,c)},i=$n.forwardRef?$n.forwardRef(r):s=>{const o=jT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Jr=m$;const y$=Jr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var HT={},Ap={},Yv={},Kg={},Xg={exports:{}},Gg,Bb;function v$(){if(Bb)return Gg;Bb=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Gg=t,Gg}var qg,zb;function w$(){if(zb)return qg;zb=1;var t=v$();function e(){}function n(){}return n.resetWarningCache=e,qg=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},qg}var jb;function b$(){return jb||(jb=1,Xg.exports=w$()()),Xg.exports}var Hb;function x$(){return Hb||(Hb=1,function(t){(function(e,n){n(t,v,b$())})(ho,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,x)&&(k[x]=y[x]);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 x=0;x0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?y:y.capture}function b(y){if("touches"in y){var w=y.touches[0],k=w.pageX,x=w.pageY;return{x:k,y:x}}var S=y.screenX,T=y.screenY;return{x:S,y:T}}var m=function(y){d(w,y);function w(){var k;u(this,w);for(var x=arguments.length,S=Array(x),T=0;TS&&this.props.onSwipeRight(1,x),this.movePosition.deltaY<-S?this.props.onSwipeUp(1,x):this.movePosition.deltaY>S&&this.props.onSwipeDown(1,x)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(x){this.swiper=x,this.props.innerRef(x)}},{key:"render",value:function(){var x=this.props;x.tagName;var S=x.className,T=x.style,A=x.children;x.allowMouseEvents,x.onSwipeUp,x.onSwipeDown,x.onSwipeLeft,x.onSwipeRight,x.onSwipeStart,x.onSwipeMove,x.onSwipeEnd,x.innerRef,x.tolerance;var M=a(x,["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);m.displayName="ReactSwipe",m.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},m.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=m})}(Kg)),Kg}(function(t){(function(e,n){n(t,x$())})(ho,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})})(Yv);var Qc={},WT={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 Ch(t){return Ch=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Ch(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 B$=function(e){return e.hasOwnProperty("key")},Jv=function(t){D$(n,t);var e=L$(n);function n(r){var i;return I$(this,n),i=e.call(this,r),tr(fr(i),"itemsWrapperRef",void 0),tr(fr(i),"itemsListRef",void 0),tr(fr(i),"thumbsRef",void 0),tr(fr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),tr(fr(i),"setItemsListRef",function(s){i.itemsListRef=s}),tr(fr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),tr(fr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Ai.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,R$.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,Wb.default)(h,"%",i.props.axis)}),!0}),tr(fr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),tr(fr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),tr(fr(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 _$(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,qf.default)().addEventListener("resize",this.updateSizes),(0,qf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,qf.default)().removeEventListener("resize",this.updateSizes),(0,qf.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,ls.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,ls.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,ls.setPosition)(0,e.axis)),r;var a=(0,ls.getPosition)(i,e),u=(0,q$.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=nl(nl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};os.slideAnimationHandler=Q$;var Z$=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=UT.Children.count(n.children),a=0,u=(0,ls.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,ls.getPosition)(l-1,n)-100:(0,ls.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,ls.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};os.slideSwipeAnimationHandler=Z$;var eF=function(e,n){var r=(0,ls.getPosition)(n.selectedItem,e),i=(0,ls.setPosition)(r,e.axis);return{itemListStyle:i}};os.slideStopSwipingHandler=eF;var tF=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=nl(nl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:nl(nl({},s),{},{opacity:1,position:"relative"}),prevStyle:nl({},s)}};os.fadeAnimationHandler=tF;Object.defineProperty(Ap,"__esModule",{value:!0});Ap.default=void 0;var zt=iF(v),nF=tf(Yv),As=tf(Qc),rF=tf(Zc),Yf=tf(Op),Jf=tf(ef),Wu=Ur,Th=os;function tf(t){return t&&t.__esModule?t:{default:t}}function KT(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return KT=function(){return t},t}function iF(t){if(t&&t.__esModule)return t;if(t===null||nc(t)!=="object"&&typeof t!="function")return{default:t};var e=KT();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 nc(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?nc=function(n){return typeof n}:nc=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},nc(t)}function D0(){return D0=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 Eh(t){return Eh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},Eh(t)}function Ct(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Qv=function(t){aF(n,t);var e=uF(n);function n(r){var i;sF(this,n),i=e.call(this,r),Ct(Et(i),"thumbsRef",void 0),Ct(Et(i),"carouselWrapperRef",void 0),Ct(Et(i),"listRef",void 0),Ct(Et(i),"itemsRef",void 0),Ct(Et(i),"timer",void 0),Ct(Et(i),"animationHandler",void 0),Ct(Et(i),"setThumbsRef",function(o){i.thumbsRef=o}),Ct(Et(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),Ct(Et(i),"setListRef",function(o){i.listRef=o}),Ct(Et(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),Ct(Et(i),"autoPlay",function(){zt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),Ct(Et(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),Ct(Et(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),Ct(Et(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),Ct(Et(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),Ct(Et(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Yf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Yf.default)().activeElement)):!1}),Ct(Et(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()}}),Ct(Et(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()}}}),Ct(Et(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),Ct(Et(i),"handleClickItem",function(o,l){if(zt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),Ct(Et(i),"handleOnChange",function(o,l){zt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),Ct(Et(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),Ct(Et(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),Ct(Et(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),Ct(Et(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Et(i)));return i.setState(Mi({},a)),!!Object.keys(a).length}),Ct(Et(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))}),Ct(Et(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))}),Ct(Et(i),"moveTo",function(o){if(typeof o=="number"){var l=zt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),Ct(Et(i),"onClickNext",function(){i.increment(1)}),Ct(Et(i),"onClickPrev",function(){i.decrement(1)}),Ct(Et(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),Ct(Et(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),Ct(Et(i),"changeItem",function(o){return function(l){(!(0,Wu.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),Ct(Et(i),"selectItem",function(o){i.setState(Mi({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,zt.Children.toArray(i.props.children)[o.selectedItem])}),Ct(Et(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),Ct(Et(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"&&Th.fadeAnimationHandler||Th.slideAnimationHandler,i.state=Mi(Mi({},s),i.animationHandler(r,s)),i}return lF(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(Mi({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&zt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,Jf.default)().addEventListener("resize",this.updateSizes),(0,Jf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Yf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Jf.default)().removeEventListener("resize",this.updateSizes),(0,Jf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Yf.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?zt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=Mi(Mi({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=Mi(Mi({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:As.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return zt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?zt.default.createElement("ul",{className:"control-dots"},zt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?zt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,zt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||zt.Children.count(this.props.children)===0?null:zt.default.createElement(rF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||zt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&zt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&zt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function m(){var S=Yg();if(b(S))return y(S);l=setTimeout(m,g(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(Yg())}function x(){var S=Yg(),T=b(S);if(r=arguments,i=this,a=S,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(m,e),h(a)}return l===void 0&&(l=setTimeout(m,e)),o}return x.cancel=w,x.flush=k,x}var XT=_F;const GT=Wi(XT);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 DF=Math.PI;function qb(t){return t*DF/180}const qT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),YT=(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}},JT=(t,e,n)=>Math.min(t,e-n*2),QT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,ew=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"}))},LF=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 $F(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(GT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const FF="֑-߿יִ-﷽ﹰ-ﻼ",BF="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",zF=new RegExp("^[^"+BF+"]*["+FF+"]");function tw(t){return zF.test(t)?"rtl":"not-rtl"}let Qf;function $0(){if(typeof document>"u")return 0;if(Qf!==void 0)return Qf;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(),Qf=n-r,Qf}const Go=Symbol();function jF(t){const e=v.useRef([Go,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!==Go&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Go&&i({}),r(u=>typeof l=="function"?l(a===Go?u:a):l),e.current[0]=Go)},[]),o=v.useCallback(()=>{e.current[0]=Go,i({})},[]);return[e.current[0]===Go?n:e.current[0],s,o]}function ZT(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 HF(t){const e=v.useRef(t);return Da(t,e.current)||(e.current=t),e.current}const WF=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(y$,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(HT.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(ew,null)))};function eE(){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 Rl=eE();function VF(t){Rl=t}const tE=/[&<>"']/,UF=new RegExp(tE.source,"g"),nE=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,KF=new RegExp(nE.source,"g"),XF={"&":"&","<":"<",">":">",'"':""","'":"'"},Yb=t=>XF[t];function nr(t,e){if(e){if(tE.test(t))return t.replace(UF,Yb)}else if(nE.test(t))return t.replace(KF,Yb);return t}const GF=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function rE(t){return t.replace(GF,(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 qF=/(^|[^\[])\^/g;function Jt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(qF,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const YF=/[^\w:]/g,JF=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Jb(t,e,n){if(t){let r;try{r=decodeURIComponent(rE(n)).replace(YF,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!JF.test(n)&&(n=t4(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const Zf={},QF=/^[^:]+:\/*[^/]*$/,ZF=/^([^:]+:)[\s\S]*$/,e4=/^([^:]+:\/*[^/]*)[\s\S]*$/;function t4(t,e){Zf[" "+t]||(QF.test(t)?Zf[" "+t]=t+"/":Zf[" "+t]=Bd(t,"/",!0)),t=Zf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(ZF,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(e4,"$1")+e:t+e}const Ah={exec:function(){}};function Qb(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 ex(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 i4(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 nw{constructor(e){this.options=e||Rl}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:Bd(r,` +`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=i4(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=Bd(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,g=n[1].trim();const b=g.length>1,m={type:"list",raw:"",ordered:b,start:b?+g.slice(0,-1):"",loose:!1,items:[]};g=b?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=b?g:"[*+-]");const y=new RegExp(`^( {0,3}${g})((?:[ ][^\\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|$))`),x=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)||x.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` +`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||S.test(c)||T.test(c)||x.test(c))break;h+=` +`+f}!a&&!f.trim()&&(a=!0),r+=d+` +`,e=e.substring(d.length+1),c=f.slice(o)}}m.loose||(u?m.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),m.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),m.raw+=r}m.items[m.items.length-1].raw=r.trimRight(),m.items[m.items.length-1].text=h.trimRight(),m.raw=m.raw.trimRight();const w=m.items.length;for(l=0;lS.type==="space"),x=k.length>0&&k.some(S=>/\n.*\n/.test(S.raw));m.loose=x}if(m.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:Qb(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=Bd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=n4(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)),ex(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 ex(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 Qe={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:Ah,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Qe._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Qe._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Qe.def=Jt(Qe.def).replace("label",Qe._label).replace("title",Qe._title).getRegex();Qe.bullet=/(?:[*+-]|\d{1,9}[.)])/;Qe.listItemStart=Jt(/^( *)(bull) */).replace("bull",Qe.bullet).getRegex();Qe.list=Jt(Qe.list).replace(/bull/g,Qe.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Qe.def.source+")").getRegex();Qe._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";Qe._comment=/|$)/;Qe.html=Jt(Qe.html,"i").replace("comment",Qe._comment).replace("tag",Qe._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Qe.paragraph=Jt(Qe._paragraph).replace("hr",Qe.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",Qe._tag).getRegex();Qe.blockquote=Jt(Qe.blockquote).replace("paragraph",Qe.paragraph).getRegex();Qe.normal={...Qe};Qe.gfm={...Qe.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Qe.gfm.table=Jt(Qe.gfm.table).replace("hr",Qe.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",Qe._tag).getRegex();Qe.gfm.paragraph=Jt(Qe._paragraph).replace("hr",Qe.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Qe.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",Qe._tag).getRegex();Qe.pedantic={...Qe.normal,html:Jt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Qe._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:Ah,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Jt(Qe.normal._paragraph).replace("hr",Qe.hr).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",Qe.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Pe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ah,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:Ah,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Pe.punctuation=Jt(Pe.punctuation).replace(/punctuation/g,Pe._punctuation).getRegex();Pe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Pe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Pe._comment=Jt(Qe._comment).replace("(?:-->|$)","-->").getRegex();Pe.emStrong.lDelim=Jt(Pe.emStrong.lDelim).replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimAst=Jt(Pe.emStrong.rDelimAst,"g").replace(/punct/g,Pe._punctuation).getRegex();Pe.emStrong.rDelimUnd=Jt(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=Jt(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=Jt(Pe.tag).replace("comment",Pe._comment).replace("attribute",Pe._attribute).getRegex();Pe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Pe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Pe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Pe.link=Jt(Pe.link).replace("label",Pe._label).replace("href",Pe._href).replace("title",Pe._title).getRegex();Pe.reflink=Jt(Pe.reflink).replace("label",Pe._label).replace("ref",Qe._label).getRegex();Pe.nolink=Jt(Pe.nolink).replace("ref",Qe._label).getRegex();Pe.reflinkSearch=Jt(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:Jt(/^!?\[(label)\]\((.*?)\)/).replace("label",Pe._label).getRegex(),reflink:Jt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Pe._label).getRegex()};Pe.gfm={...Pe.normal,escape:Jt(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 Ro{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Rl,this.options.tokenizer=this.options.tokenizer||new nw,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:Qe.normal,inline:Pe.normal};this.options.pedantic?(n.block=Qe.pedantic,n.inline=Pe.pedantic):this.options.gfm&&(n.block=Qe.gfm,this.options.breaks?n.inline=Pe.breaks:n.inline=Pe.gfm),this.tokenizer.rules=n}static get rules(){return{block:Qe,inline:Pe}}static lex(e,n){return new Ro(n).lex(e)}static lexInline(e,n){return new Ro(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)+"["+Zb("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)+"["+Zb("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,tx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,tx))){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,s4)){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 rw{constructor(e){this.options=e||Rl}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=Jb(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i='",i}image(e,n,r){if(e=Jb(this.options.sanitize,this.options.baseUrl,e),e===null)return r;let i=`${r}":">",i}text(e){return e}}class iE{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 sE{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 nf=class F0{constructor(e){this.options=e||Rl,this.options.renderer=this.options.renderer||new rw,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new iE,this.slugger=new sE}static parse(e,n){return new F0(n).parse(e)}static parseInline(e,n){return new F0(n).parseInline(e)}parse(e,n=!0){let r="",i,s,o,l,a,u,c,f,d,h,p,g,b,m,y,w,k,x,S;const T=e.length;for(i=0;i0&&y.tokens[0].type==="paragraph"?(y.tokens[0].text=x+" "+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=x+" "+y.tokens[0].tokens[0].text)):y.tokens.unshift({type:"text",text:x}):m+=x),m+=this.parse(y.tokens,b),d+=this.renderer.listitem(m,k,w);r+=this.renderer.list(d,p,g);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 oE(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=o4(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(r4(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 oE(Ro.lex,nf.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},VF(et.defaults),et};et.getDefaults=eE;et.defaults=Rl;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 rw;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 nw;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 Mh;for(const s in n.hooks){const o=i[s];Mh.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=oE(Ro.lexInline,nf.parseInline);et.Parser=nf;et.parser=nf.parse;et.Renderer=rw;et.TextRenderer=iE;et.Lexer=Ro;et.lexer=Ro.lex;et.Tokenizer=nw;et.Slugger=sE;et.Hooks=Mh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;nf.parse;Ro.lex;const l4=Jr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class a4 extends $n.PureComponent{constructor(){super(...arguments);xt(this,"targetElement",null);xt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),$n.createElement(l4,{ref:this.containerRefHook})}}const u4=Jr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),c4=Jr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),f4=Jr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let nx=0;const Pp=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-"+(nx=(nx+1)%1e7));v.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const g=f.toString().length;p.focus(),p.setSelectionRange(i?0:g,g)},[]),v.useLayoutEffect(()=>{var p;if(o!==void 0){const g=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(g[0],g[1])}},[o]);const h=v.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return v.createElement(f4,{className:"gdg-growing-entry"},v.createElement(c4,{className:u},f+` +`),v.createElement(u4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Jg={};let Zs=null;function d4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function B0(t){const e=t.toLowerCase().trim();if(Jg[e]!==void 0)return Jg[e];Zs=Zs||d4(),Zs.style.color="#000",Zs.style.color=e;const n=getComputedStyle(Zs).color;Zs.style.color="#fff",Zs.style.color=e;const r=getComputedStyle(Zs).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),Jg[e]=i,i}function bl(t,e){const[n,r,i]=B0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const rx=new Map;function ix(t,e){const n=`${t}-${e}`,r=rx.get(n);if(r!==void 0)return r;const i=Vr(t,e);return rx.set(n,i),i}function Vr(t,e){if(e===void 0)return t;const[n,r,i,s]=B0(t);if(s===1)return t;const[o,l,a,u]=B0(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,z0=new Map;function h4(){Yl.clear(),z0.clear(),fa.clear()}function p4(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,g=c*p*r/d,b=h+g;n.set(f,b)}}function g4(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 rc(t,e,n,r){var i,s;let o=fa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=z0.get(n);if(u===void 0&&(u=g4(t,o.size),z0.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 p4(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 m4(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=rc(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 y4(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=rc(t,h.slice(0,Math.max(0,f)),n,d),g=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let b=m4(t,h,r,n,p,g,d),m=h.slice(0,Math.max(0,b));h=h.slice(m.length),a.push(m),p=rc(t,h.slice(0,Math.max(0,f)),n,d),g=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 v4(t,e){return $n.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 lE(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 x4(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)&&sx(t,e,s)&&i++;for(const o of n.current.rangeStack)sx(t,e,o)&&i++;return i}function uE(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=uE(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 g}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 g=l;g"u";async function T4(){var t;C4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,zd=0,sc={},h4())}T4();function cE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function rf(t,e,n,r="middle"){const i=cE(t,e,r,n);let s=sc[i];return s===void 0&&(s=e.measureText(t),sc[i]=s,zd++),zd>1e4&&(sc={},zd=0),s}function E4(t,e){const n=cE(t,void 0,"middle",e);return sc[n]}function Hs(t,e){return typeof e!="string"&&(e=e.baseFontFull),A4(t,e)}function ox(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const lx=[];function A4(t,e){for(const s of lx)if(s.key===e)return s.val;const n=ox(t,"alphabetic"),i=-(ox(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return lx.push({key:e,val:i}),i}function M4(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 O4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=y4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=dE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),g=p+l.cellVerticalPadding>s;g&&(t.save(),t.rect(n,r,i,s),t.clip());const b=r+s/2-p/2;let m=Math.max(r+l.cellVerticalPadding,b);for(const y of f)if(fE(t,y,n,m,i,d,o,l,a),m+=h,m>r+s)break;g&&t.restore()}function Rs(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=R4(e,c));const d=Hs(s,l),h=tw(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?O4(s,e,a,u,c,f,d,l,n,i):fE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function hs(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 P4(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 I4(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),g=1,b=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,g=-1,b=!0):p>0&&(g=-1,b=!0),i=a.radius!==void 0?a.radius:n;const m=p/2;let y=Math.abs(Math.cos(m)*i/Math.sin(m)),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(m)/Math.cos(m))):w=i;let k=a.x+f.nx*y,x=a.y+f.ny*y;k+=-f.ny*w*g,x+=f.nx*w*g,t.arc(k,x,w,c.ang+Math.PI/2*g,f.ang-Math.PI/2*g,b),o=a,a=u}t.closePath()}function H0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const g={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return g;const b=s-i;if(t>=f){const m=o>t?-1:1,y=La(h);g.x+=y+a;for(let w=o;w!==t;w+=m)g.x+=h[m===1?w:w-1].width*m}else for(let m=0;m0&&_c(h[m-1].group,y)&&h[m-1].sticky===w;){const x=h[m-1];g.x-=x.width,g.width+=x.width,m--}let k=t;for(;k+1n&&(g.width=n-g.x)}}else if(e>=c-d){let m=c-e;for(g.y=r;m>0;){const y=e+m-1;g.height=typeof p=="number"?p:p(y),g.y-=g.height,m--}g.height+=1}else{const m=l>e?-1:1;if(typeof p=="number"){const y=e-l;g.y+=y*p}else for(let y=l;y!==e;y+=m)g.y+=p(y)*m;g.height=(typeof p=="number"?p:p(e))+1}return g}const iw=1<<21;function Ni(t,e){return(e+2)*iw+t}function hE(t){return t%iw}function sw(t){return Math.floor(t/iw)-2}function ow(t){const e=hE(t),n=sw(t);return[e,n]}class pE{constructor(){xt(this,"visibleWindow",{x:0,y:0,width:0,height:0});xt(this,"freezeCols",0);xt(this,"freezeRows",[]);xt(this,"isInWindow",e=>{const n=hE(e),r=sw(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&&Da(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class N4 extends pE{constructor(){super(...arguments);xt(this,"cache",new Map);xt(this,"setValue",(n,r)=>{this.cache.set(Ni(n[0],n[1]),r)});xt(this,"getValue",n=>this.cache.get(Ni(n[0],n[1])));xt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class oc{constructor(e=[]){xt(this,"cells");this.cells=new Set(e.map(n=>Ni(n[0],n[1])))}add(e){this.cells.add(Ni(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Ni(e[0],e[1]))}remove(e){this.cells.delete(Ni(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(sw(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=L4(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 $4(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({}),g=v.useRef(),[b,m]=v.useState();return v.useLayoutEffect(()=>{const y=c.current;if(y===void 0||t.every(Gf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const x={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(x,a.signal),M=k>0?y(S,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Lb(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Lb(M)]),g.current=t,m(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Gf)?t:h===null?t.map(T=>Gf(T)?T:{...T,width:W0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Gf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(b===void 0||g.current!==t||T.id===void 0)return{...T,width:W0};const M=yE(h,o,T,A,b,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,x=0;const S=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(x+=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=B4(a),a in ax)return;ax[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":F4,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 z4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var j4=z4,H4=j4,Qg=Zv;function W4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Qg(n),n=n===n?n:0),e!==void 0&&(e=Qg(e),e=e===e?e:0),H4(Qg(t),e,n)}var V4=W4;const Ii=Wi(V4);var U4="__lodash_hash_undefined__";function K4(t){return this.__data__.set(t,U4),this}var X4=K4;function G4(t){return this.__data__.has(t)}var q4=G4,Y4=Vv,J4=X4,Q4=q4;function Rh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Y4;++e-1}var dB=fB;function hB(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=NB){var u=e?null:PB(t);if(u)return IB(u);o=!1,i=OB,a=new AB}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?SE(l,e-1,n,r,i):UB(i,l):r||(i[i.length]=l)}return i}var XB=SE,GB=XB;function qB(t){var e=t==null?0:t.length;return e?GB(t,1):[]}var YB=qB;const fx=Wi(YB);var JB=Math.ceil,QB=Math.max;function ZB(t,e,n,r){for(var i=-1,s=QB(JB((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var e5=ZB,t5=_T,n5=Gv;function r5(t){return t!=null&&n5(t.length)&&!t5(t)}var aw=r5,i5=Hv,s5=aw,o5=Xv,l5=Al;function a5(t,e,n){if(!l5(n))return!1;var r=typeof e;return(r=="number"?s5(n)&&o5(e,n.length):r=="string"&&e in n)?i5(n[e],t):!1}var u5=a5,c5=Zv,dx=1/0,f5=17976931348623157e292;function d5(t){if(!t)return t===0?t:0;if(t=c5(t),t===dx||t===-dx){var e=t<0?-1:1;return e*f5}return t===t?t:0}var h5=d5,p5=e5,g5=u5,em=h5;function m5(t){return function(e,n,r){return r&&typeof r!="number"&&g5(e,n,r)&&(n=r=void 0),e=em(e),n===void 0?(n=e,e=0):n=em(n),r=r===void 0?e{g.drawImage(b,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function CE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Ip(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,g=r;for(let b=s.sourceIndex-1;b>=h;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=a;b++)g+=o[b].width;c={x:p,y:n,width:g,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,g=r;for(let b=s.sourceIndex-1;b>=l;b--)p-=o[b].width,g+=o[b].width;for(let b=s.sourceIndex+1;b<=h;b++)g+=o[b].width;u={x:p,y:n,width:g,height:i}}return[u,c]}function S5(t,e,n,r){if(r==="any")return AE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),lE([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 Oh(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Np(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function AE(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 C5(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 T5(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,g=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:g-p}}function E5(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:g,height:b}=t,m=[];if(g<=0||b<=0)return m;const y=h+g,w=p+b,k=hl,T=p+b>a,A=h>=s&&hs&&y<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const D=Math.max(h,s),P=Math.max(p,o),I=Math.min(y,l),_=Math.min(w,a);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&x){const D=h,P=p,I=Math.min(y,s),_=Math.min(w,o);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:0,y:0,width:u+1,height:c+1}})}if(x&&A){const D=Math.max(h,s),P=p,I=Math.min(y,l),_=Math.min(w,o);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(x&&S){const D=Math.max(h,l),P=p,I=y,_=Math.min(w,o);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const D=h,P=Math.max(p,o),I=Math.min(y,s),_=Math.min(w,a);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(S&&M){const D=Math.max(h,l),P=Math.max(p,o),I=y,_=Math.min(w,a);m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const D=h,P=Math.max(p,a),I=Math.min(y,s),_=w;m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const D=Math.max(h,s),P=Math.max(p,a),I=Math.min(y,l),_=w;m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(S&&T){const D=Math.max(h,l),P=Math.max(p,a),I=y,_=w;m.push({rect:{x:D,y:P,width:I-D,height:_-P},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return m}const A5={kind:Ce.Loading,allowOverlay:!1};function hx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,y,w,k,x,S,T,A,M,O,D,P,I,_,te,ie,Z,W){let V=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},z=[0,0],G=b>0?Ol(a,b,u):0;let B,me;const le=CE(y);return $o(e,l,s,o,i,(ve,Ne,se,_e,$e)=>{const Fe=Math.max(0,_e-Ne),qe=Ne+Fe,it=i+1,Wt=ve.width-Fe,Ie=r-i-1;if(y.length>0){let wt=!1;for(let bt=0;bt{t.save(),t.beginPath(),t.rect(qe,it,Wt,Ie),t.clip()},tt=k.columns.hasIndex(ve.sourceIndex),nt=f(ve.group??"").overrideTheme,lt=ve.themeOverride===void 0&&nt===void 0?I:Eo(I,nt,ve.themeOverride),Ve=lt.baseFontFull;Ve!==N&&(N=Ve,t.font=Ve),be();let kt;return Ip($e,se,r,a,u,b,m,le,(wt,bt,fe,Le,Ye)=>{var De,ze,Rn;if(bt<0||(z[0]=ve.sourceIndex,z[1]=bt,w!==void 0&&!w.has(z)))return;if(y.length>0){let pt=!1;for(let j=0;jdt.span!==void 0&&pt>=dt.span[0]&&pt<=dt.span[1]);on&&!p&&g?bn=0:on&&g&&(bn=Math.max(bn,1)),Pr&&bn++,on||(Be&&bn++,tt&&!Ye&&bn++);const Ir=dt.kind===Ce.Protected?Ut.bgCellMedium:Ut.bgCell;let Bt;if((Le||Ir!==I.bgCell)&&(Bt=Vr(Ir,Bt)),bn>0||Xt){Xt&&(Bt=Vr(Ut.bgHeader,Bt));for(let pt=0;ptW&&!St){const pt=Ut.baseFontFull;pt!==N&&(t.font=pt,N=pt),kt=ME(t,dt,ve.sourceIndex,bt,ft,pn,at,wt,ht,fe,bn>0,Ut,Bt??Ut.bgCell,T,A,(ne==null?void 0:ne.hoverAmount)??0,O,P,R,D,kt,_,te,ie,Z)}return ct&&t.restore(),dt.style==="faded"&&(t.globalAlpha=1),V--,Vt&&(t.restore(),(Rn=kt==null?void 0:kt.deprep)==null||Rn.call(kt,L),kt=void 0,be(),N=Ve,t.font=Ve),V<=0}),t.restore(),V<=0}),B}const Au=[0,0],Mu={x:0,y:0,width:0,height:0},tm=[void 0,()=>{}];let V0=!1;function M5(){V0=!0}function ME(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,y,w,k,x,S,T,A){var te,ie;let M,O;b!==void 0&&b[0][0]===n&&b[0][1]===r&&(M=b[1][0],O=b[1][1]);let D;Au[0]=n,Au[1]=r,Mu.x=o,Mu.y=l,Mu.width=a,Mu.height=u,tm[0]=S.getValue(Au),tm[1]=Z=>S.setValue(Au,Z),V0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Mu,highlighted:c,cellFillColor:d,hoverAmount:g,frameTime:y,hoverX:M,drawState:tm,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:m,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:M5},I=M4(P,e.lastUpdated,y,k,i,s),_=T(e);if(_!==void 0){(k==null?void 0:k.renderer)!==_&&((te=k==null?void 0:k.deprep)==null||te.call(k,P),k=void 0);const Z=(ie=_.drawPrep)==null?void 0:ie.call(_,P,k);w!==void 0&&!ca(P.cell)?w(P,()=>_.draw(P,e)):_.draw(P,e),D=Z===void 0?void 0:{deprep:Z==null?void 0:Z.deprep,fillStyle:Z==null?void 0:Z.fillStyle,font:Z==null?void 0:Z.font,renderer:_}}return(I||V0)&&(x==null||x(Au)),D}function uw(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 g=JT(c,o,e.cellVerticalPadding),b=g/2;const m=YT(f,r,s,e.cellHorizontalPadding,g),y=qT(m,h,g),w=QT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),hs(t,m-g/2,h-g/2,g,g,p),d==="circle"&&(b*=.8,g*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(m-b+g/4.23,h-b+g/1.97),t.lineTo(m-b+g/2.42,h-b+g/1.44),t.lineTo(m-b+g/1.29,h-b+g/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case kh:case!1:{t.beginPath(),hs(t,m-g/2+.5,h-g/2+.5,g-1,g-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case qv:{t.beginPath(),hs(t,m-g/2,h-g/2,g,g,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(b*=.8,g*=.8),t.beginPath(),t.moveTo(m-g/3,h),t.lineTo(m+g/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Nc()}}function R5(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,y){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,x]=(r==null?void 0:r[0])??[],S=f.headerFontFull;t.font=S,$o(e,0,s,0,w,(T,A,M,O)=>{var L;if(b!==void 0&&!b.has([T.sourceIndex,-1]))return;const D=Math.max(0,O-A);t.save(),t.beginPath(),t.rect(A+D,l,T.width-D,o),t.clip();const P=g(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:Eo(f,P,T.themeOverride);I.bgHeader!==f.bgHeader&&(t.fillStyle=I.bgHeader,t.fill()),I!==f&&(t.font=I.baseFontFull);const _=c.columns.hasIndex(T.sourceIndex),te=a!==void 0||u,ie=!te&&x===-1&&k===T.sourceIndex,Z=te?0:((L=h.find(z=>z.item[0]===T.sourceIndex&&z.item[1]===-1))==null?void 0:L.hoverAmount)??0,W=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,V=_?I.accentColor:W?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;_?(t.fillStyle=V,t.fillRect(A+N,R,T.width-N,o)):(W||Z>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),W&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),Z>0&&(t.globalAlpha=Z,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),PE(t,A,R,T.width,o,T,_,I,ie,W,Z,d,m,y),t.restore()}),n&&O5(t,e,i,s,l,r,f,d,h,p,g,b)}function O5(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let g=0;TE(e,n,r,i,(b,m,y,w,k,x)=>{if(f!==void 0&&!f.hasItemInRectangle({x:b[0],y:-2,width:b[1]-b[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(y,w,k,x),t.clip();const S=c(m),T=(S==null?void 0:S.overrideTheme)===void 0?o:Eo(o,S.overrideTheme),A=p===-2&&h!==void 0&&h>=b[0]&&h<=b[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+Hs(t,o.headerFontFull)),S.actions!==void 0&&A){const D=OE({x:y,y:w,width:k,height:x},S.actions);t.beginPath();const P=D[0].x-10,I=y+k-P;t.rect(P,0,I,i);const _=t.createLinearGradient(P,0,P+I,0),te=bl(M,0);_.addColorStop(0,te),_.addColorStop(10/I,M),_.addColorStop(1,M),t.fillStyle=_,t.fill(),t.globalAlpha=.6;const[ie,Z]=(s==null?void 0:s[1])??[-1,-1];for(let W=0;W35){const k=d?35:r-35,x=d?35*.7:r-35*.7,S=k/r,T=x/r,A=t.createLinearGradient(e,0,e+r,0),M=bl(g,0);A.addColorStop(d?1:0,g),A.addColorStop(S,g),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=g;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+Hs(t,l.headerFontFull)),d&&(t.textAlign="left"),b&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===Sh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;I4(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=g,t.fill()}else if(s.menuIcon===Sh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;P4(t,w,k),t.fillStyle=g,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 PE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=tw(s.title)==="rtl",g=RE(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:g},()=>px(t,e,n,r,i,s,o,l,a,c,f,h,p,g)):px(t,e,n,r,i,s,o,l,a,c,f,h,p,g)}var P5=Ml,I5=function(){try{var t=P5(Object,"defineProperty");return t({},"",{}),t}catch{}}(),N5=I5,gx=N5;function _5(t,e,n){e=="__proto__"&&gx?gx(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var D5=_5;function L5(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&Wj?new Bj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;x+=k.width;const M=Math.max(x,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Ip(A,S,i,u,c,p,g,w,(O,D,P,I)=>{if(!I&&b.length>0&&!b.some(W=>Oh(x,O,1e4,P,W.x,W.y,W.width,W.height)))return;const _=d.hasIndex(D),te=h.hasIndex(D);t.beginPath();const ie=f==null?void 0:f(D),Z=ie===void 0?y:Eo(y,ie);Z.bgCell!==y.bgCell&&(t.fillStyle=Z.bgCell,t.fillRect(x,O,1e4,P)),te&&(t.fillStyle=Z.bgHeader,t.fillRect(x,O,1e4,P)),_&&(t.fillStyle=Z.accentLight,t.fillRect(x,O,1e4,P))}),t.restore())})}function _W(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=ix(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:ix(c,a.bgCell),g=Ol(s,i,l);t.beginPath(),t.moveTo(0,r-g+.5),t.lineTo(n,r-g+.5),t.strokeStyle=p,t.stroke()}}const HE=(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 DW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var P;const g=p.bgCell,{minX:b,maxX:m,minY:y,maxY:w}=HE(l,s,o),k=[],x=o-Ol(h,d,u);let S=a,T=n,A=0;for(;S+i=y&&I<=w-1){const te=c==null?void 0:c(T),ie=te==null?void 0:te.bgCell;ie!==void 0&&ie!==g&&T>=h-d&&k.push({x:b,y:I,w:m-b,h:_,color:ie})}S+=_,T0)for(let I=0;I=b&&te<=m&&f(I+1)&&k.push({x:te,y:A,w:_.width,h:O,color:ie}),M+=_.width}if(k.length===0)return;let D;t.beginPath();for(let I=k.length-1;I>=0;I--){const _=k[I];D===void 0?D=_.color:_.color!==D&&(t.fillStyle=D,t.fill(),t.beginPath(),D=_.color),t.rect(_.x,_.y,_.w,_.h)}D!==void 0&&(t.fillStyle=D,t.fill()),t.beginPath()}function Dx(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m=!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=b.horizontalBorderColor??b.borderColor,w=b.borderColor,{minX:k,maxX:x,minY:S,maxY:T}=HE(l,s,o),A=[];t.beginPath();let M=.5;for(let P=0;P=k&&_<=x&&h(P+1)&&A.push({x1:_,y1:Math.max(u,S),x2:_,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=g-p;P=S&&te<=T-1){const ie=d==null?void 0:d(I);A.push({x1:k,y1:te,x2:x,y2:te,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??y})}P+=f(I),I++}}const D=IW(A,P=>P.color);for(const P of Object.keys(D)){t.strokeStyle=P;for(const I of D[P])t.moveTo(I.x1,I.y1),t.lineTo(I.x2,I.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function LW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b,m,y){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o);let S=0;if(typeof m=="number")S+=(x-k)*m;else for(let _=k;_i.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 _=T;_i.cellXOffset&&(M=-M),M+=l-i.translateX;const O=La(b);if(M!==0&&S!==0)return{regions:[]};const D=u>0?Ol(d,u,m):0,P=c-O-Math.abs(M),I=f-h-D-Math.abs(S)-1;if(P>150&&I>150){const _={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(S>0?(_.sy=(h+1)*p,_.sh=I*p,_.dy=(S+h+1)*p,_.dh=I*p,w.push({x:0,y:h,width:c,height:S+1})):S<0&&(_.sy=(-S+h+1)*p,_.sh=I*p,_.dy=(h+1)*p,_.dh=I*p,w.push({x:0,y:f+S-D,width:c,height:-S+D})),M>0?(_.sx=O*p,_.sw=P*p,_.dx=(M+O)*p,_.dw=P*p,w.push({x:O-1,y:0,width:M+2,height:f})):M<0&&(_.sx=(O-M)*p,_.sw=P*p,_.dx=O*p,_.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 te=O*p,ie=f*p;t.drawImage(e,0,0,te,ie,0,0,te,ie)}if(D>0&&M===0&&S!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const te=(f-D)*p,ie=c*p,Z=D*p;t.drawImage(e,0,te,ie,Z,0,te,ie,Z)}}t.drawImage(e,_.sx,_.sy,_.sw,_.sh,_.dx,_.dy,_.dw,_.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function $W(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||$o(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const g=Math.max(d,p)+1;return c.push({x:g,y:0,width:s-g,height:o}),!0}}),c}function FW(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(b===void 0||b.length===0)return;const m=La(l),y=Ol(h,d,f),w=[a,0,l.length,h-d],k=[m,0,e,n-y],x=b.map(T=>{const A=T.range,M=T.style??"dashed";return E5(A,w,e,n,k).map(O=>{const D=O.rect,P=H0(D.x,D.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=D.width===1&&D.height===1?P:H0(D.x+D.width-1,D.y+D.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return D.x+D.width>=l.length&&(I.width-=1),D.y+D.height>=h&&(I.height-=1),{color:T.color,style:M,clip:O.clip,rect:T5({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 x)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Oh(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,D=!C5(M.clip,M.rect);D&&(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,g.borderColor),g.bgCell):bl(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),D&&(t.restore(),T=O)}T&&t.setLineDash([])};return S(),S}function $x(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 im(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,g,b){if(c.current===void 0)return;const m=c.current.range,y=c.current.cell,w=[m.x+m.width-1,m.y+m.height-1];if(y[1]>=b&&w[1]>=b||!o.some(_=>_.sourceIndex===y[0]||_.sourceIndex===w[0]))return;const[x,S]=c.current.cell,T=d(c.current.cell),A=T.span??[x,x],M=S>=b-h,O=h>0&&!M?Ol(b,h,f)-1:0,D=w[1];let P;if($o(o,r,i,s,u,(_,te,ie,Z,W)=>{if(_.sticky&&x>_.sourceIndex)return;const V=_.sourceIndexA[1],N=_.sourceIndex===w[0];if(!(!N&&(V||R)))return Ip(W,ie,n,b,f,h,p,void 0,(L,z,G)=>{if(z!==S&&z!==D)return;let B=te,me=_.width;if(T.span!==void 0){const ve=EE(T.span,te,L,_.width,G,_,l),Ne=_.sticky?ve[0]:ve[1];Ne!==void 0&&(B=Ne.x,me=Ne.width)}return z===D&&N&&g&&(P=()=>{var ve;Z>B&&!_.sticky&&(t.beginPath(),t.rect(Z,0,e-Z,n),t.clip()),t.beginPath(),t.rect(B+me-4,L+G-4,4,4),t.fillStyle=((ve=_.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 BW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),TE(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)}),$o(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,g=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,g,i-r)}),t.clip())}function zW(t,e,n,r,i,s,o,l,a,u){let c=0;return $o(t,s,r,i,n,(f,d,h,p,g)=>(Ip(g,h,e,o,l,a,u,void 0,(b,m,y,w)=>{w||(c=Math.max(m,c))}),!0)),c}function Fx(t,e){var ct;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:g,headerHeight:b,groupHeaderHeight:m,disabledRows:y,rowHeight:w,verticalBorder:k,overrideCursor:x,isResizing:S,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:D,getGroupDetails:P,getRowThemeOverride:I,isFocused:_,drawHeaderCallback:te,prelightCells:ie,drawCellCallback:Z,highlightRegions:W,resizeCol:V,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:z,hoverInfo:G,spriteManager:B,maxScaleFactor:me,hasAppendRow:le,touchMode:ve,enqueue:Ne,renderStateProvider:se,getCellRenderer:_e,renderStrategy:$e,bufferACtx:Fe,bufferBCtx:qe,damage:it,minimumCellWidth:Wt}=t;if(i===0||s===0)return;const Ie=$e==="double-buffer",be=Math.min(me,Math.ceil(window.devicePixelRatio??1)),tt=$e!=="direct"&&FW(t,e),nt=n.canvas;(nt.width!==i*be||nt.height!==s*be)&&(nt.width=i*be,nt.height=s*be,nt.style.width=i+"px",nt.style.height=s+"px");const lt=r.canvas,Ve=f?m+b:b,kt=Ve+1;(lt.width!==i*be||lt.height!==kt*be)&&(lt.width=i*be,lt.height=kt*be,lt.style.width=i+"px",lt.style.height=kt+"px");const wt=Fe.canvas,bt=qe.canvas;Ie&&(wt.width!==i*be||wt.height!==s*be)&&(wt.width=i*be,wt.height=s*be,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Ie&&(bt.width!==i*be||bt.height!==s*be)&&(bt.width=i*be,bt.height=s*be,N.current!==void 0&&(N.current.bBufferScroll=void 0));const fe=N.current;if(tt===!0&&o===(fe==null?void 0:fe.cellXOffset)&&l===(fe==null?void 0:fe.cellYOffset)&&a===(fe==null?void 0:fe.translateX)&&u===(fe==null?void 0:fe.translateY))return;let Le=null;Ie&&(Le=n);const Ye=r;let Be;Ie?it!==void 0?Be=(fe==null?void 0:fe.lastBuffer)==="b"?qe:Fe:Be=(fe==null?void 0:fe.lastBuffer)==="b"?Fe:qe:Be=n;const Xt=Be.canvas,dt=Ie?Xt===wt?bt:wt:nt,at=typeof w=="number"?()=>w:w;Ye.save(),Be.save(),Ye.beginPath(),Be.beginPath(),Ye.textBaseline="middle",Be.textBaseline="middle",be!==1&&(Ye.scale(be,be),Be.scale(be,be));const ht=j0(c,o,i,h,a);let Vt=[];const St=g&&((ct=T.current)==null?void 0:ct.cell[1])===l&&u===0;let _n=!1;if(W!==void 0){for(const ft of W)if(ft.style!=="no-outline"&&ft.range.y===l&&u===0){_n=!0;break}}const cn=()=>{R5(Ye,ht,f,G,i,a,b,m,h,S,T,p,B,L,k,P,it,te,ve),Dx(Ye,ht,l,a,u,i,s,void 0,void 0,m,Ve,at,I,k,M,O,p,!0),Ye.beginPath(),Ye.moveTo(0,kt-.5),Ye.lineTo(i,kt-.5),Ye.strokeStyle=Vr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Ye.stroke(),_n&&Lx(Ye,i,s,o,l,a,u,c,d,b,m,w,M,O,W,p),St&&im(Ye,i,s,l,a,u,ht,c,p,Ve,T,at,D,M,le,A,O)};if(it!==void 0){const ft=ht[ht.length-1].sourceIndex+1,pn=it.hasItemInRegion([{x:o,y:-2,width:ft,height:2},{x:o,y:l,width:ft,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:ft,height:M,when:M>0}]),ne=De=>{hx(De,ht,c,s,Ve,a,u,l,O,at,D,P,I,y,_,g,M,le,Vt,it,T,ie,W,R,B,L,G,Z,z,p,Ne,se,_e,x,Wt);const ze=T.current;A&&g&&ze!==void 0&&it.has(aE(ze.range))&&im(De,i,s,l,a,u,ht,c,p,Ve,T,at,D,M,le,A,O)};pn&&(ne(Be),Le!==null&&(Le.save(),Le.scale(be,be),Le.textBaseline="middle",ne(Le),Le.restore()),it.hasHeader()&&(BW(Ye,ht,i,m,Ve,a,u,l,it),cn())),Be.restore(),Ye.restore();return}if((tt!==!0||o!==(fe==null?void 0:fe.cellXOffset)||a!==(fe==null?void 0:fe.translateX)||St!==(fe==null?void 0:fe.mustDrawFocusOnHeader)||_n!==(fe==null?void 0:fe.mustDrawHighlightRingsOnHeader))&&cn(),tt===!0){Wr(dt!==void 0&&fe!==void 0);const{regions:ft}=LW(Be,dt,dt===wt?fe.aBufferScroll:fe.bBufferScroll,dt===wt?fe.bBufferScroll:fe.aBufferScroll,fe,o,l,a,u,M,i,s,O,Ve,be,c,ht,w,Ie);Vt=ft}else tt!==!1&&(Wr(fe!==void 0),Vt=$W(fe,o,l,a,u,i,s,Ve,ht,tt));_W(Be,ht,i,s,M,O,k,at,p);const Ut=Lx(Be,i,s,o,l,a,u,c,d,b,m,w,M,O,W,p),on=g?im(Be,i,s,l,a,u,ht,c,p,Ve,T,at,D,M,le,A,O):void 0;if(Be.fillStyle=p.bgCell,Vt.length>0){Be.beginPath();for(const ft of Vt)Be.rect(ft.x,ft.y,ft.width,ft.height);Be.clip(),Be.fill(),Be.beginPath()}else Be.fillRect(0,0,i,s);const bn=hx(Be,ht,c,s,Ve,a,u,l,O,at,D,P,I,y,_,g,M,le,Vt,it,T,ie,W,R,B,L,G,Z,z,p,Ne,se,_e,x,Wt);NW(Be,ht,c,i,s,Ve,a,u,l,O,at,I,T.rows,y,M,le,Vt,it,p),DW(Be,ht,l,a,u,i,s,Vt,Ve,at,I,k,M,O,p),Dx(Be,ht,l,a,u,i,s,Vt,bn,m,Ve,at,I,k,M,O,p),Ut==null||Ut(),on==null||on(),S&&$o(ht,0,a,0,Ve,(ft,pn)=>ft.sourceIndex===V?($x(Ye,pn+ft.width,0,Ve+1,Vr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),$x(Be,pn+ft.width,Ve,s,Vr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),Le!==null&&(Le.fillStyle=p.bgCell,Le.fillRect(0,0,i,s),Le.drawImage(Be.canvas,0,0));const Pr=zW(ht,s,Ve,a,u,l,O,at,M,le);R==null||R.setWindow({x:o,y:l,width:ht.length,height:Pr-l},d,Array.from({length:M},(ft,pn)=>O-1-pn));const Ir=fe!==void 0&&(o!==fe.cellXOffset||a!==fe.translateX),Bt=fe!==void 0&&(l!==fe.cellYOffset||u!==fe.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:St,mustDrawHighlightRingsOnHeader:_n,lastBuffer:Ie?Xt===wt?"a":"b":void 0,aBufferScroll:Xt===wt?[Ir,Bt]:fe==null?void 0:fe.aBufferScroll,bBufferScroll:Xt===bt?[Ir,Bt]:fe==null?void 0:fe.bBufferScroll},Be.restore(),Ye.restore()}const jW=80;function HW(t){const e=t-1;return e*e*e+1}class WW{constructor(e){xt(this,"callback");xt(this,"currentHoveredItem");xt(this,"leavingItems",[]);xt(this,"lastAnimationTime");xt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>ic(r.item,e.item))||this.leavingItems.push(e)});xt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>ic(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});xt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});xt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});xt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:HW(e.hoverAmount)})));xt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/jW;for(const s of this.leavingItems)s.hoverAmount=Ii(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Ii(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});xt(this,"setHovered",e=>{var n;if(!ic((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 VW{constructor(e){xt(this,"fn");xt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function fw(t){return new VW(t)}const UW=fw(()=>window.navigator.userAgent.includes("Firefox")),Nh=fw(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),_h=fw(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function KW(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(ow);e.current=[],r.current(new oc(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=Ni(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const ro="header",Hr="group-header",Dh="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 WE(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 Bx=6,XW=(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))??""},GW=(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:g,enableGroups:b,isFilling:m,onCanvasFocused:y,onCanvasBlur:w,isFocused:k,selection:x,freezeColumns:S,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:D,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:_,onMouseMove:te,onItemHovered:ie,dragAndDropState:Z,firstColAccessible:W,onKeyDown:V,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:z,onDragEnd:G,eventTargetRef:B,isResizing:me,resizeColumn:le,isDragging:ve,isDraggable:Ne=!1,allowResize:se,disabledRows:_e,hasAppendRow:$e,getGroupDetails:Fe,theme:qe,prelightCells:it,headerIcons:Wt,verticalBorder:Ie,drawCell:be,drawHeader:tt,onCellFocused:nt,onDragOverCell:lt,onDrop:Ve,onDragLeave:kt,imageWindowLoader:wt,smoothScrollX:bt=!1,smoothScrollY:fe=!1,experimental:Le,getCellRenderer:Ye}=t,Be=t.translateX??0,Xt=t.translateY??0,dt=Math.max(S,Math.min(s.length-1,o)),at=v.useRef(null),ht=wt,Vt=v.useRef(),[St,_n]=v.useState(!1),cn=v.useRef([]),Ut=v.useRef(),[on,bn]=v.useState(),[Pr,Ir]=v.useState(),Bt=v.useRef(null),[ct,ft]=v.useState(),[pn,ne]=v.useState(!1),De=v.useRef(pn);De.current=pn;const ze=v.useMemo(()=>new k5(Wt,()=>{ar.current=void 0,zo.current()}),[Wt]),Rn=b?c+a:a,pt=v.useRef(-1),j=((Le==null?void 0:Le.enableFirefoxRescaling)??!1)&&UW.value,ue=((Le==null?void 0:Le.enableSafariRescaling)??!1)&&Nh.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!j&&!ue||(pt.current!==-1&&_n(!0),window.clearTimeout(pt.current),pt.current=window.setTimeout(()=>{_n(!1),pt.current=-1},200))},[l,dt,Be,Xt,j,ue]);const q=v4(s,S),ge=M?La(q,Z):0,ae=v.useCallback((H,oe,ke)=>{const ye=H.getBoundingClientRect();if(oe>=q.length||ke>=d)return;const de=ye.width/n,Me=H0(oe,ke,n,r,c,Rn,dt,l,Be,Xt,d,S,A,q,f);return de!==1&&(Me.x*=de,Me.y*=de,Me.width*=de,Me.height*=de),Me.x+=ye.x,Me.y+=ye.y,Me},[n,r,c,Rn,dt,l,Be,Xt,d,S,A,q,f]),je=v.useCallback((H,oe,ke,ye)=>{const de=H.getBoundingClientRect(),Me=de.width/n,st=(oe-de.left)/Me,ot=(ke-de.top)/Me,Ee=5,Lt=j0(q,dt,n,void 0,Be);let He=0,Ft=0;ye instanceof MouseEvent&&(He=ye.button,Ft=ye.buttons);const ut=k4(st,Lt,Be),Tt=S4(ot,r,b,a,c,d,f,l,Xt,A),xn=(ye==null?void 0:ye.shiftKey)===!0,gt=(ye==null?void 0:ye.ctrlKey)===!0,gn=(ye==null?void 0:ye.metaKey)===!0,ti=ye!==void 0&&!(ye instanceof MouseEvent)||(ye==null?void 0:ye.pointerType)==="touch",an=[st<0?-1:nn||ot>r){const It=st>n?1:st<0?-1:0,kn=ot>r?1:ot<0?-1:0;let Lr=It*2,Ki=kn*2;It===0&&(Lr=ut===-1?da.EndPadding:da.Center),kn===0&&(Ki=Tt===void 0?da.EndPadding:da.Center);let ki=!1;if(ut===-1&&Tt===-1){const Ho=ae(H,q.length-1,-1);Wr(Ho!==void 0),ki=oen&&str&&ot=0?(kn=!0,It=ae(H,Lr,Tt),Wr(It!==void 0),Dr={kind:b&&Tt===-2?Hr:ro,location:[Lr,Tt],bounds:It,group:q[Lr].group??"",isEdge:kn,shiftKey:xn,ctrlKey:gt,metaKey:gn,isTouch:ti,localEventX:oe-It.x,localEventY:ke-It.y,button:He,buttons:Ft,scrollEdge:an}):Dr={kind:b&&Tt===-2?Hr:ro,group:q[ut].group??"",location:[ut,Tt],bounds:It,isEdge:kn,shiftKey:xn,ctrlKey:gt,metaKey:gn,isTouch:ti,localEventX:oe-It.x,localEventY:ke-It.y,button:He,buttons:Ft,scrollEdge:an}}else{const It=ae(H,ut,Tt);Wr(It!==void 0);const kn=It!==void 0&&It.x+It.width-oe{}),rt=v.useRef(on);rt.current=on;const[Rt,Gt]=v.useMemo(()=>{const H=document.createElement("canvas"),oe=document.createElement("canvas");return H.style.display="none",H.style.opacity="0",H.style.position="fixed",oe.style.display="none",oe.style.opacity="0",oe.style.position="fixed",[H.getContext("2d",{alpha:!1}),oe.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(Rt===null||Gt===null))return document.documentElement.append(Rt.canvas),document.documentElement.append(Gt.canvas),()=>{Rt.canvas.remove(),Gt.canvas.remove()}},[Rt,Gt]);const qn=v.useMemo(()=>new N4,[]),Qr=j&&St?1:ue&&St?2:5,On=(Le==null?void 0:Le.disableMinimumCellWidth)===!0?1:10,ar=v.useRef(),Zr=v.useRef(null),ws=v.useRef(null),bs=v.useCallback(()=>{var st;const H=at.current,oe=Bt.current;if(H===null||oe===null||(Zr.current===null&&(Zr.current=H.getContext("2d",{alpha:!1}),H.width=0,H.height=0),ws.current===null&&(ws.current=oe.getContext("2d",{alpha:!1}),oe.width=0,oe.height=0),Zr.current===null||ws.current===null||Rt===null||Gt===null))return;let ke=!1;const ye=ot=>{ke=!0,ft(ot)},de=ar.current,Me={headerCanvasCtx:ws.current,canvasCtx:Zr.current,bufferACtx:Rt,bufferBCtx:Gt,width:n,height:r,cellXOffset:dt,cellYOffset:l,translateX:Math.round(Be),translateY:Math.round(Xt),mappedColumns:q,enableGroups:b,freezeColumns:S,dragAndDropState:Z,theme:qe,headerHeight:a,groupHeaderHeight:c,disabledRows:_e??Nt.empty(),rowHeight:f,verticalBorder:Ie,isResizing:me,resizeCol:le,isFocused:k,selection:x,fillHandle:u,drawCellCallback:be,hasAppendRow:$e,overrideCursor:ye,maxScaleFactor:Qr,freezeTrailingRows:A,rows:d,drawFocus:D,getCellContent:h,getGroupDetails:Fe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:tt,prelightCells:it,highlightRegions:N,imageLoader:ht,lastBlitData:Ut,damage:Vt.current,hoverValues:cn.current,hoverInfo:rt.current,spriteManager:ze,scrolling:St,hyperWrapping:(Le==null?void 0:Le.hyperWrapping)??!1,touchMode:pn,enqueue:Pt.current,renderStateProvider:qn,renderStrategy:(Le==null?void 0:Le.renderStrategy)??(Nh.value?"double-buffer":"single-buffer"),getCellRenderer:Ye,minimumCellWidth:On};Me.damage===void 0?(ar.current=Me,Fx(Me,de)):Fx(Me,void 0),!ke&&(Me.damage===void 0||Me.damage.has((st=rt==null?void 0:rt.current)==null?void 0:st[0]))&&ft(void 0)},[Rt,Gt,n,r,dt,l,Be,Xt,q,b,S,Z,qe,a,c,_e,f,Ie,me,$e,le,k,x,u,A,d,D,Qr,h,Fe,p,be,tt,it,N,ht,ze,St,Le==null?void 0:Le.hyperWrapping,Le==null?void 0:Le.renderStrategy,pn,qn,Ye,On]),zo=v.useRef(bs);v.useLayoutEffect(()=>{bs(),zo.current=bs},[bs]),v.useLayoutEffect(()=>{(async()=>{var oe;((oe=document==null?void 0:document.fonts)==null?void 0:oe.ready)!==void 0&&(await document.fonts.ready,ar.current=void 0,zo.current())})()},[]);const Ws=v.useCallback(H=>{Vt.current=H,zo.current(),Vt.current=void 0},[]),df=KW(Ws);Pt.current=df;const hf=v.useCallback(H=>{Ws(new oc(H.map(oe=>oe.cell)))},[Ws]);ht.setCallback(Ws);const[Gp,qp]=v.useState(!1),[Pl,xs]=xe??[],Yp=Pl!==void 0&&xs===-1,Jp=Pl!==void 0&&xs===-2;let pf=!1,Il=!1,Pn=ct;if(Pn===void 0&&Pl!==void 0&&xs!==void 0&&xs>-1&&xs({contain:"strict",display:"block",cursor:gf}),[gf]),iu=v.useRef("default"),Vs=B==null?void 0:B.current;Vs!=null&&iu.current!==Nl.cursor&&(Vs.style.cursor=iu.current=Nl.cursor);const Nr=v.useCallback((H,oe,ke,ye)=>{if(Fe===void 0)return;const de=Fe(H);if(de.actions!==void 0){const Me=OE(oe,de.actions);for(const[st,ot]of Me.entries())if(Np(ot,ke+oe.x,ye+ot.y))return de.actions[st]}},[Fe]),wi=v.useCallback((H,oe,ke,ye)=>{const de=s[oe];if(!ve&&!me&&de.hasMenu===!0&&!(Pr??!1)){const Me=ae(H,oe,-1);Wr(Me!==void 0);const st=RE(Me.x,Me.y,Me.width,Me.height,tw(de.title)==="rtl");if(ke>st.x&&kest.y&&ye{const oe=at.current,ke=B==null?void 0:B.current;if(oe===null||H.target!==oe&&H.target!==ke)return;ou.current=!0;let ye,de;if(H instanceof MouseEvent?(ye=H.clientX,de=H.clientY):(ye=H.touches[0].clientX,de=H.touches[0].clientY),H.target===ke&&ke!==null){const st=ke.getBoundingClientRect();if(ye>st.right||de>st.bottom)return}const Me=je(oe,ye,de,H);Us.current=Me.location,Me.isTouch&&(su.current=Date.now()),De.current!==Me.isTouch&&ne(Me.isTouch),!(Me.kind===ro&&wi(oe,Me.location[0],ye,de)!==void 0)&&(Me.kind===Hr&&Nr(Me.group,Me.bounds,Me.localEventX,Me.localEventY)!==void 0||(P==null||P(Me),!Me.isTouch&&Ne!==!0&&Ne!==Me.kind&&Me.button<3&&Me.button!==1&&H.preventDefault()))},[B,Ne,je,Nr,wi,P]);Vn("touchstart",ur,window,!1),Vn("mousedown",ur,window,!1);const _l=v.useRef(0),lu=v.useCallback(H=>{var Ft,ut;const oe=_l.current;_l.current=Date.now();const ke=at.current;if(ou.current=!1,I===void 0||ke===null)return;const ye=B==null?void 0:B.current,de=H.target!==ke&&H.target!==ye;let Me,st,ot=!0;if(H instanceof MouseEvent){if(Me=H.clientX,st=H.clientY,ot=H.button<3,H.pointerType==="touch")return}else Me=H.changedTouches[0].clientX,st=H.changedTouches[0].clientY;let Ee=je(ke,Me,st,H);Ee.isTouch&&su.current!==0&&Date.now()-su.current>500&&(Ee={...Ee,isLongTouch:!0}),oe!==0&&Date.now()-oe<(Ee.isTouch?1e3:500)&&(Ee={...Ee,isDoubleClick:!0}),De.current!==Ee.isTouch&&ne(Ee.isTouch),!de&&H.cancelable&&ot&&H.preventDefault();const[Lt]=Ee.location,He=wi(ke,Lt,Me,st);if(Ee.kind===ro&&He!==void 0){(Ee.button!==0||((Ft=Us.current)==null?void 0:Ft[0])!==Lt||((ut=Us.current)==null?void 0:ut[1])!==-1)&&I(Ee,!0);return}else if(Ee.kind===Hr){const Tt=Nr(Ee.group,Ee.bounds,Ee.localEventX,Ee.localEventY);if(Tt!==void 0){Ee.button===0&&Tt.onClick(Ee);return}}I(Ee,de)},[I,B,je,wi,Nr]);Vn("mouseup",lu,window,!1),Vn("touchend",lu,window,!1);const mf=v.useCallback(H=>{var He,Ft;const oe=at.current;if(oe===null)return;const ke=B==null?void 0:B.current,ye=H.target!==oe&&H.target!==ke;let de,Me,st=!0;H instanceof MouseEvent?(de=H.clientX,Me=H.clientY,st=H.button<3):(de=H.changedTouches[0].clientX,Me=H.changedTouches[0].clientY);const ot=je(oe,de,Me,H);De.current!==ot.isTouch&&ne(ot.isTouch),!ye&&H.cancelable&&st&&H.preventDefault();const[Ee]=ot.location,Lt=wi(oe,Ee,de,Me);if(ot.kind===ro&&Lt!==void 0)ot.button===0&&((He=Us.current)==null?void 0:He[0])===Ee&&((Ft=Us.current)==null?void 0:Ft[1])===-1&&(g==null||g(Ee,Lt));else if(ot.kind===Hr){const ut=Nr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ut!==void 0&&ot.button===0&&ut.onClick(ot)}},[B,je,wi,g,Nr]);Vn("click",mf,window,!1);const Qp=v.useCallback(H=>{const oe=at.current,ke=B==null?void 0:B.current;if(oe===null||H.target!==oe&&H.target!==ke||T===void 0)return;const ye=je(oe,H.clientX,H.clientY,H);T(ye,()=>{H.cancelable&&H.preventDefault()})},[B,je,T]);Vn("contextmenu",Qp,(B==null?void 0:B.current)??null,!1);const yf=v.useCallback(H=>{Vt.current=new oc(H.map(oe=>oe.item)),cn.current=H,zo.current(),Vt.current=void 0},[]),bi=v.useMemo(()=>new WW(yf),[yf]),ks=v.useRef(bi);ks.current=bi,v.useLayoutEffect(()=>{const H=ks.current;if(xe===void 0||xe[1]<0){H.setHovered(xe);return}const oe=h(xe,!0),ke=Ye(oe),ye=ke===void 0&&oe.kind===Ce.Custom||(ke==null?void 0:ke.needsHover)!==void 0&&(typeof ke.needsHover=="boolean"?ke.needsHover:ke.needsHover(oe));H.setHovered(ye?xe:void 0)},[h,Ye,xe]);const _r=v.useRef(),X=v.useCallback(H=>{var ot;const oe=at.current;if(oe===null)return;const ke=B==null?void 0:B.current,ye=H.target!==oe&&H.target!==ke,de=je(oe,H.clientX,H.clientY,H);if(de.kind!=="out-of-bounds"&&ye&&!ou.current&&!de.isTouch)return;const Me=(Ee,Lt)=>{bn(He=>He===Ee||(He==null?void 0:He[0][0])===(Ee==null?void 0:Ee[0][0])&&(He==null?void 0:He[0][1])===(Ee==null?void 0:Ee[0][1])&&((He==null?void 0:He[1][0])===(Ee==null?void 0:Ee[1][0])&&(He==null?void 0:He[1][1])===(Ee==null?void 0:Ee[1][1])||!Lt)?He:Ee)};if(!WE(de,_r.current))ft(void 0),ie==null||ie(de),Me(de.kind===Dh?void 0:[de.location,[de.localEventX,de.localEventY]],!0),_r.current=de;else if(de.kind==="cell"||de.kind===ro||de.kind===Hr){let Ee=!1,Lt=!0;if(de.kind==="cell"){const Ft=h(de.location);Lt=((ot=Ye(Ft))==null?void 0:ot.needsHoverPosition)??Ft.kind===Ce.Custom,Ee=Lt}else de.kind===Hr&&(Ee=!0);const He=[de.location,[de.localEventX,de.localEventY]];Me(He,Lt),rt.current=He,Ee&&Ws(new oc([de.location]))}const st=de.location[0]>=(W?0:1);Ir(de.kind===ro&&de.isEdge&&st&&se===!0),qp(de.kind==="cell"&&de.isFillHandle),_==null||_(H),te(de)},[B,je,W,se,_,te,ie,h,Ye,Ws]);Vn("mousemove",X,window,!0);const ln=v.useCallback(H=>{const oe=at.current;if(oe===null)return;let ke,ye;x.current!==void 0&&(ke=ae(oe,x.current.cell[0],x.current.cell[1]),ye=x.current.cell),V==null||V({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})},[V,x,ae]),jo=v.useCallback(H=>{const oe=at.current;if(oe===null)return;let ke,ye;x.current!==void 0&&(ke=ae(oe,x.current.cell[0],x.current.cell[1]),ye=x.current.cell),R==null||R({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})},[R,x,ae]),Zp=v.useCallback(H=>{at.current=H,L!==void 0&&(L.current=H)},[L]),vf=v.useCallback(H=>{const oe=at.current;if(oe===null||Ne===!1||me){H.preventDefault();return}let ke,ye;const de=je(oe,H.clientX,H.clientY);if(Ne!==!0&&de.kind!==Ne){H.preventDefault();return}const Me=(Ft,ut)=>{ke=Ft,ye=ut};let st,ot,Ee;const Lt=(Ft,ut,Tt)=>{st=Ft,ot=ut,Ee=Tt};let He=!1;if(z==null||z({...de,setData:Me,setDragImage:Lt,preventDefault:()=>He=!0,defaultPrevented:()=>He}),!He&&ke!==void 0&&ye!==void 0&&H.dataTransfer!==null)if(H.dataTransfer.setData(ke,ye),H.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Ee!==void 0)H.dataTransfer.setDragImage(st,ot,Ee);else{const[Ft,ut]=de.location;if(ut!==void 0){const Tt=document.createElement("canvas"),xn=ae(oe,Ft,ut);Wr(xn!==void 0);const gt=Math.ceil(window.devicePixelRatio??1);Tt.width=xn.width*gt,Tt.height=xn.height*gt;const gn=Tt.getContext("2d");gn!==null&&(gn.scale(gt,gt),gn.textBaseline="middle",ut===-1?(gn.font=qe.headerFontFull,gn.fillStyle=qe.bgHeader,gn.fillRect(0,0,Tt.width,Tt.height),PE(gn,0,0,xn.width,xn.height,q[Ft],!1,qe,!1,!1,0,ze,tt,!1)):(gn.font=qe.baseFontFull,gn.fillStyle=qe.bgCell,gn.fillRect(0,0,Tt.width,Tt.height),ME(gn,h([Ft,ut]),0,ut,!1,!1,0,0,xn.width,xn.height,!1,qe,qe.bgCell,ht,ze,1,void 0,!1,0,void 0,void 0,void 0,qn,Ye,()=>{}))),Tt.style.left="-100%",Tt.style.position="absolute",Tt.style.width=`${xn.width}px`,Tt.style.height=`${xn.height}px`,document.body.append(Tt),H.dataTransfer.setDragImage(Tt,xn.width/2,xn.height/2),window.setTimeout(()=>{Tt.remove()},0)}}else H.preventDefault()},[Ne,me,je,z,ae,qe,q,ze,tt,h,ht,qn,Ye]);Vn("dragstart",vf,(B==null?void 0:B.current)??null,!1,!1);const au=v.useRef(),eg=v.useCallback(H=>{const oe=at.current;if(Ve!==void 0&&H.preventDefault(),oe===null||lt===void 0)return;const ke=je(oe,H.clientX,H.clientY),[ye,de]=ke.location,Me=ye-(W?0:1),[st,ot]=au.current??[];(st!==Me||ot!==de)&&(au.current=[Me,de],lt([Me,de],H.dataTransfer))},[W,je,lt,Ve]);Vn("dragover",eg,(B==null?void 0:B.current)??null,!1,!1);const Ww=v.useCallback(()=>{au.current=void 0,G==null||G()},[G]);Vn("dragend",Ww,(B==null?void 0:B.current)??null,!1,!1);const J=v.useCallback(H=>{const oe=at.current;if(oe===null||Ve===void 0)return;H.preventDefault();const ke=je(oe,H.clientX,H.clientY),[ye,de]=ke.location,Me=ye-(W?0:1);Ve([Me,de],H.dataTransfer)},[W,je,Ve]);Vn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Yn=v.useCallback(()=>{kt==null||kt()},[kt]);Vn("dragleave",Yn,(B==null?void 0:B.current)??null,!1,!1);const In=v.useRef(x);In.current=x;const Dl=v.useRef(null),uu=v.useCallback(H=>{var oe;at.current===null||!at.current.contains(document.activeElement)||(H===null&&In.current.current!==void 0?(oe=L==null?void 0:L.current)==null||oe.focus({preventScroll:!0}):H!==null&&H.focus({preventScroll:!0}),Dl.current=H)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var oe;const H=Dl.current;H===null||!document.contains(H)?(oe=L==null?void 0:L.current)==null||oe.focus({preventScroll:!0}):H.focus({preventScroll:!0})},getBounds:(H,oe)=>{if(!(L===void 0||L.current===null))return ae(L.current,H??0,oe??-1)},damage:hf}),[L,hf,ae]);const Ks=v.useRef(),br=$F(()=>{var ot,Ee,Lt;if(n<50||(Le==null?void 0:Le.disableAccessibilityTree)===!0)return null;let H=j0(q,dt,n,Z,Be);const oe=W?0:-1;!W&&((ot=H[0])==null?void 0:ot.sourceIndex)===0&&(H=H.slice(1));const[ke,ye]=((Ee=x.current)==null?void 0:Ee.cell)??[],de=(Lt=x.current)==null?void 0:Lt.range,Me=H.map(He=>He.sourceIndex),st=rl(l,Math.min(d,l+i));return ke!==void 0&&ye!==void 0&&!(Me.includes(ke)&&st.includes(ye))&&uu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":q.length+oe},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},H.map(He=>v.createElement("th",{role:"columnheader","aria-selected":x.columns.hasIndex(He.sourceIndex),"aria-colindex":He.sourceIndex+1+oe,tabIndex:-1,onFocus:Ft=>{if(Ft.target!==Dl.current)return nt==null?void 0:nt([He.sourceIndex,-1])},key:He.sourceIndex},He.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(He=>v.createElement("tr",{role:"row","aria-selected":x.rows.hasIndex(He),key:He,"aria-rowindex":He+2},H.map(Ft=>{const ut=Ft.sourceIndex,Tt=Ni(ut,He),xn=ke===ut&&ye===He,gt=de!==void 0&&ut>=de.x&&ut=de.y&&He{const Dr=L==null?void 0:L.current;if(Dr!=null)return V==null?void 0:V({bounds:ae(Dr,ut,He),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:ti})},onFocusCapture:Dr=>{var It,kn;if(!(Dr.target===Dl.current||((It=Ks.current)==null?void 0:It[0])===ut&&((kn=Ks.current)==null?void 0:kn[1])===He))return Ks.current=ti,nt==null?void 0:nt(ti)},ref:xn?uu:void 0,tabIndex:-1},XW(an,Ye))})))))},[n,q,dt,Z,Be,d,l,i,x,uu,h,L,V,ae,nt],200),xi=S===0||!M?0:dt>S?1:Ii(-Be/100,0,1),tg=-l*32+Xt,Ll=O?Ii(-tg/100,0,1):0,ng=v.useMemo(()=>{if(!xi&&!Ll)return null;const H={position:"absolute",top:0,left:ge,width:n-ge,height:r,opacity:xi,pointerEvents:"none",transition:bt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},oe={position:"absolute",top:Rn,left:0,width:n,height:r,opacity:Ll,pointerEvents:"none",transition:fe?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,xi>0&&v.createElement("div",{id:"shadow-x",style:H}),Ll>0&&v.createElement("div",{id:"shadow-y",style:oe}))},[xi,Ll,ge,n,bt,Rn,r,fe]),rg=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:ln,onKeyUp:jo,onFocus:y,onBlur:w,ref:Zp,style:Nl},br),v.createElement("canvas",{ref:Bt,style:rg}),ng)},qW=v.memo(v.forwardRef(GW));function Ru(t,e,n,r){return Ii(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const YW=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(),[g,b]=v.useState(),[m,y]=v.useState(!1),[w,k]=v.useState(),{onHeaderMenuClick:x,getCellContent:S,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:D,maxColumnWidth:P,minColumnWidth:I,onRowMoved:_,lockColumns:te,onColumnProposeMove:ie,onMouseDown:Z,onMouseUp:W,onItemHovered:V,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:z,selection:G}=t,B=G.columns,me=v.useCallback(Ie=>{const[be,tt]=Ie.location;s!==void 0&&l!==be&&be>=te?(c(!0),a(be)):h!==void 0&&tt!==void 0?(y(!0),b(Math.max(0,tt))):r===void 0&&!u&&!m&&(V==null||V(Ie))},[s,h,l,V,te,r,u,m]),le=T!==void 0,ve=v.useCallback(Ie=>{var be;if(Ie.button===0){const[tt,nt]=Ie.location;if(Ie.kind==="out-of-bounds"&&Ie.isEdge&&L){const lt=(be=D==null?void 0:D.current)==null?void 0:be.getBounds(z.length-1,-1);lt!==void 0&&(n(lt.x),i(z.length-1))}else if(Ie.kind==="header"&&tt>=te){const lt=N==null?void 0:N.current;if(Ie.isEdge&&L&<){n(Ie.bounds.x),i(tt);const kt=lt.getBoundingClientRect().width/lt.offsetWidth,wt=Ie.bounds.width/kt;M==null||M(z[tt],wt,tt,wt+(z[tt].growOffset??0))}else Ie.kind==="header"&&le&&(d(Ie.bounds.x),o(tt))}else Ie.kind==="cell"&&te>0&&tt===0&&nt!==void 0&&_!==void 0&&(k(Ie.bounds.y),p(nt))}Z==null||Z(Ie)},[Z,L,te,_,D,z,le,M,N]),Ne=v.useCallback((Ie,be)=>{u||m||x==null||x(Ie,be)},[u,m,x]),se=v.useRef(-1),_e=v.useCallback(()=>{se.current=-1,p(void 0),b(void 0),k(void 0),y(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),$e=v.useCallback((Ie,be)=>{if(Ie.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 lt=z[nt],Ve=Ru(lt,se.current,I,P);A==null||A(lt,Ve,nt,Ve+(lt.growOffset??0))}const tt=Ru(z[r],se.current,I,P);if(O==null||O(z[r],tt,r,tt+(z[r].growOffset??0)),B.hasIndex(r))for(const nt of B){if(nt===r)continue;const lt=z[nt],Ve=Ru(lt,se.current,I,P);O==null||O(lt,Ve,nt,Ve+(lt.growOffset??0))}}_e(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&g!==void 0&&(_==null||_(h,g))}W==null||W(Ie,be)},[W,r,s,l,h,g,B,O,z,I,P,A,T,_,_e]),Fe=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ie==null?void 0:ie(s,l))!==!1)return{src:s,dest:l}},[s,l,ie]),qe=v.useCallback(Ie=>{const be=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&&be){const nt=be.getBoundingClientRect().width/be.offsetWidth,lt=(Ie.clientX-e)/nt,Ve=z[r],kt=Ru(Ve,lt,I,P);if(A==null||A(Ve,kt,r,kt+(Ve.growOffset??0)),se.current=lt,(B==null?void 0:B.first())===r)for(const wt of B){if(wt===r)continue;const bt=z[wt],fe=Ru(bt,se.current,I,P);A==null||A(bt,fe,wt,fe+(bt.growOffset??0))}}},[s,f,h,w,r,e,z,I,P,A,B,N]),it=v.useCallback((Ie,be)=>{if(h===void 0||g===void 0)return S(Ie,be);let[tt,nt]=Ie;return nt===g?nt=h:(nt>g&&(nt-=1),nt>=h&&(nt+=1)),S([tt,nt],be)},[h,g,S]),Wt=v.useCallback(Ie=>{R==null||R(Ie),Ie.defaultPrevented()||_e()},[_e,R]);return v.createElement(qW,{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:it,isResizing:r!==void 0,onHeaderMenuClick:Ne,isDragging:u,onItemHovered:me,onDragStart:Wt,onMouseDown:ve,allowResize:L,onMouseUp:$e,dragAndDropState:Fe,onMouseMoveRaw:qe,ref:D})};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 QW=(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])},ZW=()=>t=>t.isSafari?"scroll":"auto",e6=Jr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[ZW()]}});function t6(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 n6=t=>{var z,G;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:g}=t,b=[],m=(d==null?void 0:d.sticky)??!1,y=(d==null?void 0:d.fill)??!1,w=v.useRef(0),k=v.useRef(0),x=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=t6(200),[O,D]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||M||T.current.lockDirection===void 0)return;const B=x.current;if(B===null)return;const[me,le]=T.current.lockDirection;me!==void 0?B.scrollLeft=me:le!==void 0&&(B.scrollTop=le),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,me)=>{var be;const le=x.current;if(le===null)return;me=me??le.scrollTop,B=B??le.scrollLeft;const ve=T.current.scrollTop,Ne=T.current.scrollLeft,se=B-Ne,_e=me-ve;M&&se!==0&&_e!==0&&(Math.abs(se)>3||Math.abs(_e)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(se)0&&(Math.abs(Wt)>2e3||it===0||it===Ie)&&r>le.scrollHeight+5){const tt=it/Ie,nt=(r-qe)*tt;w.current=nt-it}$e!==void 0&&(window.clearTimeout(P.current),D(!1),P.current=window.setTimeout(()=>D(!0),200)),s({x:B,y:it+w.current,width:Fe-c,height:qe-u,paddingRight:((be=A.current)==null?void 0:be.clientWidth)??0})},[u,c,r,s,a,M]);QW(h&&Nh.value,I,x);const _=v.useRef(I);_.current=I;const te=v.useRef(),ie=v.useRef(!1);v.useLayoutEffect(()=>{ie.current?I():ie.current=!0},[I,u,c]);const Z=v.useCallback(B=>{x.current=B,p!==void 0&&(p.current=B)},[p]);let W=0,V=0;for(b.push(v.createElement("div",{key:W++,style:{width:i,height:0}}));V_.current(),0),te.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(e6,{isSafari:Nh.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:Z,style:te.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"},b),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:m?c??0:void 0,pointerEvents:"auto"}},f))))))},r6=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:g,rightElementProps:b,overscrollX:m,overscrollY:y,initialSize:w,smoothScrollX:k=!1,smoothScrollY:x=!1,isDraggable:S}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,D=v.useRef(),P=v.useRef(),I=v.useRef(),_=v.useRef(),te=u+Math.max(0,m??0);let ie=o?i+s:i;if(typeof r=="number")ie+=n*r;else for(let R=0;R{var _e,$e;if(Z.current===void 0)return;const R={...Z.current};let N=0,L=R.x<0?-R.x:0,z=0,G=0;R.x=R.x<0?0:R.x;let B=0;for(let Fe=0;Fe=qe+Fe.width)N+=Fe.width,G++,z++;else if(R.x>qe)N+=Fe.width,k?L+=qe-R.x:G++,z++;else if(R.x+R.width>qe)N+=Fe.width,z++;else break}let me=0,le=0,ve=0;if(typeof r=="number")x?(le=Math.floor(R.y/r),me=le*r-R.y):le=Math.ceil(R.y/r),ve=Math.ceil(R.height/r)+le,me<0&&ve++;else{let Fe=0;for(let qe=0;qe=Fe+it)Fe+=it,le++,ve++;else if(R.y>Wt)Fe+=it,x?me+=Wt-R.y:le++,ve++;else if(R.y+R.height>it/2+Fe)Fe+=it,ve++;else break}}const Ne={x:G,y:le,width:z-G,height:ve-le},se=D.current;(se===void 0||se.y!==Ne.y||se.x!==Ne.x||se.height!==Ne.height||se.width!==Ne.width||P.current!==L||I.current!==me||R.width!==((_e=_.current)==null?void 0:_e[0])||R.height!==(($e=_.current)==null?void 0:$e[1]))&&(d==null||d({x:G,y:le,width:z-G,height:ve-le},R.width,R.height,R.paddingRight??0,L,me),D.current=Ne,P.current=L,I.current=me,_.current=[R.width,R.height])},[e,r,n,d,l,k,x]),V=v.useCallback(R=>{Z.current=R,W()},[W]);return v.useEffect(()=>{W()},[W]),v.createElement(n6,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:S===!0||typeof S=="string",scrollWidth:te+(T??0),scrollHeight:ie+(A??0),clientHeight:O,rightElement:g,paddingBottom:A,paddingRight:T,rightElementProps:b,update:V,initialSize:w},v.createElement(YW,{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}))},i6=Jr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),s6=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"})),o6=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"})),l6=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"})),a6=10,u6=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,g]=v.useState(""),b=o??p,m=v.useCallback(N=>{g(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 x=v.useRef();x.current===void 0&&(x.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,x.current.abort())},[]),D=v.useRef(n);D.current=n;const P=v.useCallback(N=>{const L=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let z=D.current,G=Math.min(10,r),B=0;w(void 0),A([]);const me=[],le=async()=>{var Ie;if(u===void 0)return;const ve=performance.now(),Ne=r-B;let se=u({x:0,y:z,width:i.length,height:Math.min(G,Ne,r-z)},x.current.signal);typeof se=="function"&&(se=await se());let _e=!1;for(const[be,tt]of se.entries())for(const[nt,lt]of tt.entries()){let Ve;switch(lt.kind){case Ce.Text:case Ce.Number:Ve=lt.displayData;break;case Ce.Uri:case Ce.Markdown:Ve=lt.data;break;case Ce.Boolean:Ve=typeof lt.data=="boolean"?lt.data.toString():void 0;break;case Ce.Image:case Ce.Bubble:Ve=lt.data.join("🐳");break;case Ce.Custom:Ve=lt.copyData;break}Ve!==void 0&&L.test(Ve)&&(me.push([nt,be+z]),_e=!0)}const $e=performance.now();_e&&A([...me]),B+=se.length,Wr(B<=r);const Fe=((Ie=k.current)==null?void 0:Ie.selectedIndex)??-1;w({results:me.length,rowsSearched:B,selectedIndex:Fe}),c==null||c(me,Fe),z+G>=r?z=0:z+=G;const qe=$e-ve,it=Math.max(qe,1),Wt=a6/it;G=Math.ceil(G*Wt),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]),_=v.useCallback(N=>{m(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),O()):P(N.target.value))},[P,O,m,l]);v.useEffect(()=>{f&&s.current!==null&&(m(""),s.current.focus({preventScroll:!0}))},[f,s,m]);const te=v.useCallback(N=>{var z;if((z=N==null?void 0:N.stopPropagation)==null||z.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(M,L)},[y,c,M]),ie=v.useCallback(N=>{var z;if((z=N==null?void 0:N.stopPropagation)==null||z.call(N),y===void 0)return;let L=(y.selectedIndex-1)%y.results;L<0&&(L+=y.results),w({...y,selectedIndex:L}),c==null||c(M,L)},[c,M,y]),Z=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ie():te())},[I,te,ie]);v.useEffect(()=>()=>{O()},[O]);const[W,V]=v.useState(!1);v.useEffect(()=>{if(f)V(!0);else{const N=setTimeout(()=>V(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!W)return null;let N;y!==void 0&&(N=y.results>=1e3?"over 1000":`${y.results} result${y.results!==1?"s":""}`,y.selectedIndex>=0&&(N=`${y.selectedIndex+1} of ${N}`));const L=B=>{B.stopPropagation()},G={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(i6,{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:_,value:b,tabIndex:f?void 0:-1,onKeyDownCapture:Z}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ie,disabled:((y==null?void 0:y.results)??0)===0},s6),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:te,disabled:((y==null?void 0:y.results)??0)===0},o6),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},l6)),y!==void 0?v.createElement(v.Fragment,null,v.createElement("div",{className:"gdg-search-status"},v.createElement("div",{"data-testid":"search-result-area"},N)),v.createElement("div",{className:"gdg-search-progress",style:G})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,W,y,r,h,s,_,b,Z,ie,te,d,I]);return v.createElement(v.Fragment,null,v.createElement(r6,{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 c6 extends v.PureComponent{constructor(){super(...arguments);xt(this,"wrapperRef",v.createRef());xt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return v.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const f6=()=>t=>Math.max(16,t.targetHeight-10),d6=Jr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[f6(),"px"]}}),h6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=$n.useState(n);return $n.createElement(c6,{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},$n.createElement(d6,{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 p6(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=VE(t,e);return r&&(n.didMatch=!0),r}function VE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(VE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!p6(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":_h.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function g6(t,e,n,r,i,s){const o=$n.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,g=i==="mixed"&&h;let b={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:g?t.rows:Nt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&b.current!==void 0&&t.current!==void 0&&(b={...b,current:{...b.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(b,c)},[r,t,n,s,i,e]),l=$n.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=$n.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 m6(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 y6(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===qv?"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:Nc()}}function v6(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"}:y6(o))})}function zx(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function w6(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=>zx(o,!0)).join(",")):i.push(zx(s.formatted,!1));e.push(i.join(" "))}return e.join(` +`)}function sm(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function jx(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function b6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function x6(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("
    ${sm(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+sm(o)+"
    2. ").join("")}
    ${sm(i.formatted)}
    "),e.join("")}function k6(t,e){const n=v6(t,e),r=w6(n),i=x6(n);return{textPlain:r,textHtml:i}}function Hx(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 g of d)g.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 g=a.querySelectorAll("li");s==null||s.push({rawValue:[...g].map(b=>b.getAttribute("gdg-raw-value")??""),formatted:[...g].map(b=>b.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:b6(h),formatted:a.textContent??"",format:p});else{let g=a.textContent??"";f&&(g=g.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:g??"",formatted:g??"",format:p})}}}return s!==void 0&&i.push(s),i}function S6(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 Wx(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function C6(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(Wx(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 Vx(t,e,n){var l;const r=k6(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 UE(t){return t!==!0}function Ux(t){return typeof t=="string"?t:`${t}px`}const T6=()=>t=>t.innerWidth,E6=()=>t=>t.innerHeight,A6=Jr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[T6()],"wmyidgi-1":[E6()]}}),M6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(A6,{innerHeight:Ux(n),innerWidth:Ux(e),...i},r)},R6=2,O6=1300;function P6(t,e,n){const r=$n.useRef(0),[i,s]=t??[0,0];$n.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/O6);const d=r.current**1.618*f*R6;(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 I6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=$n.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,g=t,b=mE();return[typeof g=="number"?g*p:m=>Math.ceil(g(m)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??b.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??b.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??b.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 eo={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 Kx(t){const e=_h.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 N6(t){const e=HF(t);return $n.useMemo(()=>{if(e===void 0)return Kx(eo);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??eo.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??eo.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??eo.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??eo.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??eo.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??eo.selectToLastCell};return Kx({...eo,...n})},[e])}const _6=v.lazy(async()=>await vE(()=>import("./data-grid-overlay-editor-DkEjJU3p.js"),[]));let D6=0;function L6(t){return BB(fx(fx(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return rl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function td(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 om={kind:Ce.Loading,allowOverlay:!1},nd={columns:Nt.empty(),rows:Nt.empty(),current:void 0},$6=(t,e)=>{var r1,i1,s1;const[n,r]=v.useState(nd),[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:g,width:b,height:m,columns:y,rows:w,getCellContent:k,onCellClicked:x,onCellActivated:S,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:D,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:_,spanRangeBehavior:te="default",onGroupHeaderClicked:ie,onCellContextMenu:Z,className:W,onHeaderContextMenu:V,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:z,onCellsEdited:G,onSearchResultsChanged:B,searchResults:me,onSearchValueChange:le,searchValue:ve,onKeyDown:Ne,onKeyUp:se,keybindings:_e,editOnType:$e=!0,onRowAppended:Fe,onColumnMoved:qe,validateCell:it,highlightRegions:Wt,rangeSelect:Ie="rect",columnSelect:be="multi",rowSelect:tt="multi",rangeSelectionBlending:nt="exclusive",columnSelectionBlending:lt="exclusive",rowSelectionBlending:Ve="exclusive",onDelete:kt,onDragStart:wt,onMouseMove:bt,onPaste:fe,copyHeaders:Le=!1,freezeColumns:Ye=0,cellActivationBehavior:Be="second-click",rowSelectionMode:Xt="auto",onHeaderMenuClick:dt,getGroupDetails:at,onSearchClose:ht,onItemHovered:Vt,onSelectionCleared:St,showSearch:_n,onVisibleRegionChanged:cn,gridSelection:Ut,onGridSelectionChange:on,minColumnWidth:bn=50,maxColumnWidth:Pr=500,maxColumnAutoWidth:Ir,provideEditor:Bt,trailingRowOptions:ct,freezeTrailingRows:ft=0,allowedFillDirections:pn="orthogonal",scrollOffsetX:ne,scrollOffsetY:De,verticalBorder:ze,onDragOverCell:Rn,onDrop:pt,onColumnResize:j,onColumnResizeEnd:ue,onColumnResizeStart:q,customRenderers:ge,fillHandle:ae,drawFocusRing:je=!0,experimental:xe,fixedShadowX:Pt,fixedShadowY:rt,headerIcons:Rt,imageWindowLoader:Gt,initialSize:qn,isDraggable:Qr,onDragLeave:On,onRowMoved:ar,overscrollX:Zr,overscrollY:ws,preventDiagonalScrolling:bs,rightElement:zo,rightElementProps:Ws,trapFocus:df=!1,smoothScrollX:hf,smoothScrollY:Gp,scaleToRem:qp=!1,rowHeight:Pl=34,headerHeight:xs=36,groupHeaderHeight:Yp=xs,theme:Jp,isOutsideClick:pf,renderers:Il}=t,Pn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,ei=(Pn==null?void 0:Pn.kind)??t.rowMarkers??"none",gf=(Pn==null?void 0:Pn.width)??t.rowMarkerWidth,Nl=(Pn==null?void 0:Pn.startIndex)??t.rowMarkerStartIndex??1,iu=(Pn==null?void 0:Pn.theme)??t.rowMarkerTheme,Vs=(Pn==null?void 0:Pn.checkboxStyle)??"square",Nr=Math.max(bn,20),wi=Math.max(Pr,Nr),su=Math.max(Ir??wi,Nr),Us=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),ou=v.useMemo(()=>Number.parseFloat(Us.fontSize),[Us]),{rowHeight:ur,headerHeight:_l,groupHeaderHeight:lu,theme:mf,overscrollX:Qp,overscrollY:yf}=I6({groupHeaderHeight:Yp,headerHeight:xs,overscrollX:Zr,overscrollY:ws,remSize:ou,rowHeight:Pl,scaleToRem:qp,theme:Jp}),bi=N6(_e),ks=gf??(w>1e4?48:w>1e3?44:w>100?36:32),_r=ei!=="none",X=_r?1:0,ln=Fe!==void 0,jo=(ct==null?void 0:ct.sticky)===!0,[Zp,vf]=v.useState(!1),au=_n??Zp,eg=v.useCallback(()=>{ht!==void 0?ht():vf(!1)},[ht]),J=v.useMemo(()=>Ut===void 0?void 0:td(Ut,X),[Ut,X])??n,Yn=v.useRef();Yn.current===void 0&&(Yn.current=new AbortController),v.useEffect(()=>()=>Yn==null?void 0:Yn.current.abort(),[]);const[In,Dl]=m6(R,k,X,Yn.current,w),uu=v.useCallback((C,F,$)=>{if(it===void 0)return!0;const U=[C[0]-X,C[1]];return it==null?void 0:it(U,F,$)},[X,it]),Ks=v.useRef(Ut),br=v.useCallback((C,F)=>{F&&(C=S6(C,In,X,te,Yn.current)),on!==void 0?(Ks.current=td(C,-X),on(Ks.current)):r(C)},[on,In,X,te]),xi=Ul(j,v.useCallback((C,F,$,U)=>{j==null||j(y[$-X],F,$-X,U)},[j,X,y])),tg=Ul(ue,v.useCallback((C,F,$,U)=>{ue==null||ue(y[$-X],F,$-X,U)},[ue,X,y])),Ll=Ul(q,v.useCallback((C,F,$,U)=>{q==null||q(y[$-X],F,$-X,U)},[q,X,y])),ng=Ul(O,v.useCallback((C,F)=>(O==null?void 0:O({...C,columnIndex:C.columnIndex-X},F))??!1,[O,X])),rg=Ul(D,v.useCallback((C,F)=>(D==null?void 0:D({...C,col:C.col-X},F))??!1,[D,X])),H=v.useCallback(C=>{if(kt!==void 0){const F=kt(td(C,-X));return typeof F=="boolean"?F:td(F,X)}return!0},[kt,X]),[oe,ke,ye]=g6(J,br,nt,lt,Ve,Ie),de=v.useMemo(()=>Eo(mE(),mf),[mf]),[Me,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Il===void 0)return{};const C={};for(const F of Il)C[F.kind]=F;return C},[Il]),Ee=v.useCallback(C=>C.kind!==Ce.Custom?ot[C.kind]:ge==null?void 0:ge.find(F=>F.isMatch(C)),[ge,ot]);let{sizedColumns:Lt,nonGrowWidth:He}=$4(y,w,Dl,Me[0]-(X===0?0:ks)-Me[2],Nr,su,de,Ee,Yn.current);ei!=="none"&&(He+=ks);const Ft=v.useMemo(()=>Lt.some(C=>C.group!==void 0),[Lt]),ut=Ft?_l+lu:_l,Tt=J.rows.length,xn=ei==="none"?void 0:Tt===0?!1:Tt===w?!0:void 0,gt=v.useMemo(()=>ei==="none"?Lt:[{title:"",width:ks,icon:void 0,hasMenu:!1,style:"normal",themeOverride:iu,rowMarker:Vs,rowMarkerChecked:xn},...Lt],[ei,Lt,ks,iu,Vs,xn]),[gn,ti]=v.useMemo(()=>[De!==void 0&&typeof ur=="number"?Math.floor(De/ur):0,De!==void 0&&typeof ur=="number"?-(De%ur):0],[De,ur]),an=v.useRef({height:1,width:1,x:0,y:0}),Dr=v.useMemo(()=>({x:an.current.x,y:gn,width:an.current.width??1,height:an.current.height??1,ty:ti}),[ti,gn]),It=v.useRef(!1),[kn,Lr,Ki]=jF(Dr);an.current=kn;const ki=(kn.height??1)>1;v.useLayoutEffect(()=>{if(De!==void 0&&c.current!==null&&ki){if(c.current.scrollTop===De)return;c.current.scrollTop=De,c.current.scrollTop!==De&&Ki(),It.current=!0}},[De,ki,Ki]);const $l=(kn.width??1)>1;v.useLayoutEffect(()=>{if(ne!==void 0&&c.current!==null&&$l){if(c.current.scrollLeft===ne)return;c.current.scrollLeft=ne,c.current.scrollLeft!==ne&&Ki(),It.current=!0}},[ne,$l,Ki]);const Ho=kn.x+X,wf=kn.y,xr=v.useRef(null),cr=v.useCallback(C=>{var F;C===!0?(F=xr.current)==null||F.focus():window.requestAnimationFrame(()=>{var $;($=xr.current)==null||$.focus()})},[]),Jn=ln?w+1:w,ni=v.useCallback(C=>{const F=X===0?C:C.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),$=G==null?void 0:G(F);if($!==!0)for(const U of F)z==null||z(U.location,U.value);return $},[z,G,X]),[Wo,ig]=v.useState(),bf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,Fl=je?(r1=J.current)==null?void 0:r1.cell:void 0,xf=Fl==null?void 0:Fl[0],kf=Fl==null?void 0:Fl[1],RR=v.useMemo(()=>{if((Wt===void 0||Wt.length===0)&&(bf??xf??kf??Wo)===void 0)return;const C=[];if(Wt!==void 0)for(const F of Wt){const $=gt.length-F.range.x-X;$>0&&C.push({color:F.color,range:{...F.range,x:F.range.x+X,width:Math.min($,F.range.width)},style:F.style})}return Wo!==void 0&&C.push({color:bl(de.accentColor,0),range:Wo,style:"dashed"}),bf!==void 0&&C.push({color:bl(de.accentColor,.5),range:bf,style:"solid-outline"}),xf!==void 0&&kf!==void 0&&C.push({color:de.accentColor,range:{x:xf,y:kf,width:1,height:1},style:"solid-outline"}),C.length>0?C:void 0},[Wo,bf,xf,kf,Wt,gt.length,de.accentColor,X]),Vw=v.useRef(gt);Vw.current=gt;const $r=v.useCallback(([C,F],$=!1)=>{var ee,Y,Q,ce,re,Te,Re;const U=ln&&F===Jn-1;if(C===0&&_r)return U?om:{kind:ai.Marker,allowOverlay:!1,checkboxStyle:Vs,checked:(J==null?void 0:J.rows.hasIndex(F))===!0,markerKind:ei==="clickable-number"?"number":ei,row:Nl+F,drawHandle:ar!==void 0,cursor:ei==="clickable-number"?"pointer":void 0};if(U){const Ke=C===X?(ct==null?void 0:ct.hint)??"":"",Je=Vw.current[C];if(((ee=Je==null?void 0:Je.trailingRowOptions)==null?void 0:ee.disabled)===!0)return om;{const Ot=((Y=Je==null?void 0:Je.trailingRowOptions)==null?void 0:Y.hint)??Ke,Ze=((Q=Je==null?void 0:Je.trailingRowOptions)==null?void 0:Q.addIcon)??(ct==null?void 0:ct.addIcon);return{kind:ai.NewRow,hint:Ot,allowOverlay:!1,icon:Ze}}}else{const Se=C-X;if($||(xe==null?void 0:xe.strict)===!0){const Je=an.current,Ot=Je.x>Se||Se>Je.x+Je.width||Je.y>F||F>Je.y+Je.height||F>=og.current,Ze=Se===((re=(ce=Je.extras)==null?void 0:ce.selected)==null?void 0:re[0])&&F===((Te=Je.extras)==null?void 0:Te.selected[1]);let Ue=!1;if(((Re=Je.extras)==null?void 0:Re.freezeRegions)!==void 0){for(const Qt of Je.extras.freezeRegions)if(Np(Qt,Se,F)){Ue=!0;break}}if(Ot&&!Ze&&!Ue)return om}let Ke=k([Se,F]);return X!==0&&Ke.span!==void 0&&(Ke={...Ke,span:[Ke.span[0]+X,Ke.span[1]+X]}),Ke}},[ln,Jn,_r,Vs,J==null?void 0:J.rows,ei,Nl,ar,X,ct==null?void 0:ct.hint,ct==null?void 0:ct.addIcon,xe==null?void 0:xe.strict,k]),sg=v.useCallback(C=>{let F=(at==null?void 0:at(C))??{name:C};return L!==void 0&&C!==""&&(F={icon:F.icon,name:F.name,overrideTheme:F.overrideTheme,actions:[...F.actions??[],{title:"Rename",icon:"renameIcon",onClick:$=>ag({group:F.name,bounds:$.bounds})}]}),F},[at,L]),Sf=v.useCallback(C=>{var Q;const[F,$]=C.cell,U=gt[F],K=(U==null?void 0:U.group)!==void 0?(Q=sg(U.group))==null?void 0:Q.overrideTheme:void 0,ee=U==null?void 0:U.themeOverride,Y=p==null?void 0:p($);s({...C,theme:Eo(de,K,ee,Y,C.content.themeOverride)})},[p,gt,sg,de]),Bl=v.useCallback((C,F,$)=>{var Y;if(J.current===void 0)return;const[U,K]=J.current.cell,ee=$r([U,K]);if(ee.kind!==Ce.Boolean&&ee.allowOverlay){let Q=ee;if($!==void 0)switch(Q.kind){case Ce.Number:{const ce=k_(()=>$==="-"?-0:Number.parseFloat($),0);Q={...Q,data:Number.isNaN(ce)?0:ce};break}case Ce.Text:case Ce.Markdown:case Ce.Uri:Q={...Q,data:$};break}Sf({target:C,content:Q,initialValue:$,cell:[U,K],highlight:$===void 0,forceEditMode:$!==void 0})}else ee.kind===Ce.Boolean&&F&&ee.readonly!==!0&&(ni([{location:J.current.cell,value:{...ee,data:UE(ee.data)}}]),(Y=xr.current)==null||Y.damage([{cell:J.current.cell}]))},[$r,J,ni,Sf]),Uw=v.useCallback((C,F)=>{var K;const $=(K=xr.current)==null?void 0:K.getBounds(C,F);if($===void 0||c.current===null)return;const U=$r([C,F]);U.allowOverlay&&Sf({target:$,content:U,initialValue:void 0,highlight:!0,cell:[C,F],forceEditMode:!0})},[$r,Sf]),Sn=v.useCallback((C,F,$="both",U=0,K=0,ee=void 0)=>{if(c.current!==null){const Y=xr.current,Q=l.current,ce=typeof C!="number"?C.unit==="cell"?C.amount:void 0:C,re=typeof F!="number"?F.unit==="cell"?F.amount:void 0:F,Te=typeof C!="number"&&C.unit==="px"?C.amount:void 0,Re=typeof F!="number"&&F.unit==="px"?F.amount:void 0;if(Y!==null&&Q!==null){let Se={x:0,y:0,width:0,height:0},Ke=0,Je=0;if((ce!==void 0||re!==void 0)&&(Se=Y.getBounds((ce??0)+X,re??0)??Se,Se.width===0||Se.height===0))return;const Ot=Q.getBoundingClientRect(),Ze=Ot.width/Q.offsetWidth;if(Te!==void 0&&(Se={...Se,x:Te-Ot.left-c.current.scrollLeft,width:1}),Re!==void 0&&(Se={...Se,y:Re+Ot.top-c.current.scrollTop,height:1}),Se!==void 0){const Ue={x:Se.x-U,y:Se.y-K,width:Se.width+2*U,height:Se.height+2*K};let Qt=0;for(let pg=0;pg0&&(Qn=Ol(Jn,Cn,ur));let Ci=Qt*Ze+Ot.left+X*ks*Ze,Gi=Ot.right,Ti=Ot.top+ut*Ze,qi=Ot.bottom-Qn*Ze;const Rf=Se.width+U*2;switch(ee==null?void 0:ee.hAlign){case"start":Gi=Ci+Rf;break;case"end":Ci=Gi-Rf;break;case"center":Ci=Math.floor((Ci+Gi)/2)-Rf/2,Gi=Ci+Rf;break}const Of=Se.height+K*2;switch(ee==null?void 0:ee.vAlign){case"start":qi=Ti+Of;break;case"end":Ti=qi-Of;break;case"center":Ti=Math.floor((Ti+qi)/2)-Of/2,qi=Ti+Of;break}Ci>Ue.x?Ke=Ue.x-Ci:GiUe.y?Je=Ue.y-Ti:qi=Jn-Cn)&&(Je=0),(Ke!==0||Je!==0)&&(Ze!==1&&(Ke/=Ze,Je/=Ze),c.current.scrollTo(Ke+c.current.scrollLeft,Je+c.current.scrollTop))}}}},[X,ft,ks,ut,Ye,Lt,Jn,jo,ur]),Kw=v.useRef(Uw),Xw=v.useRef(k),og=v.useRef(w);Kw.current=Uw,Xw.current=k,og.current=w;const zl=v.useCallback(async(C,F=!0)=>{var ce;const $=gt[C];if(((ce=$==null?void 0:$.trailingRowOptions)==null?void 0:ce.disabled)===!0)return;const U=Fe==null?void 0:Fe();let K,ee=!0;U!==void 0&&(K=await U,K==="top"&&(ee=!1),typeof K=="number"&&(ee=!1));let Y=0;const Q=()=>{if(og.current<=w){Y<500&&window.setTimeout(Q,Y),Y=50+Y*2;return}const re=typeof K=="number"?K:ee?w:0;Mf.current(C-X,re),oe({cell:[C,re],range:{x:C,y:re,width:1,height:1}},!1,!1,"edit");const Te=Xw.current([C-X,re]);Te.allowOverlay&&Hu(Te)&&Te.readonly!==!0&&F&&window.setTimeout(()=>{Kw.current(C,re)},0)};Q()},[gt,Fe,X,w,oe]),Cf=v.useCallback(C=>{var $,U;const F=((U=($=Lt[C])==null?void 0:$.trailingRowOptions)==null?void 0:U.targetColumn)??(ct==null?void 0:ct.targetColumn);if(typeof F=="number")return F+(_r?1:0);if(typeof F=="object"){const K=y.indexOf(F);if(K>=0)return K+(_r?1:0)}},[Lt,y,_r,ct==null?void 0:ct.targetColumn]),Xs=v.useRef(),jl=v.useRef(),cu=v.useCallback((C,F)=>{var K;const[$,U]=F;return Eo(de,(K=gt[$])==null?void 0:K.themeOverride,p==null?void 0:p(U),C.themeOverride)},[p,gt,de]),fu=v.useCallback(C=>{var Te,Re,Se;const F=_h.value?C.metaKey:C.ctrlKey,$=F&&tt==="multi",U=F&&be==="multi",[K,ee]=C.location,Y=J.columns,Q=J.rows,[ce,re]=((Te=J.current)==null?void 0:Te.cell)??[];if(C.kind==="cell"){if(jl.current=void 0,Vo.current=[K,ee],K===0&&_r){if(ln===!0&&ee===w||ei==="number"||tt==="none")return;const Ke=$r(C.location);if(Ke.kind!==ai.Marker)return;if(ar!==void 0){const Ze=Ee(Ke);Wr((Ze==null?void 0:Ze.kind)===ai.Marker);const Ue=(Re=Ze==null?void 0:Ze.onClick)==null?void 0:Re.call(Ze,{...C,cell:Ke,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,theme:cu(Ke,C.location),preventDefault:()=>{}});if(Ue===void 0||Ue.checked===Ke.checked)return}s(void 0),cr();const Je=Q.hasIndex(ee),Ot=Xs.current;if(tt==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ot!==void 0&&Q.hasIndex(Ot)){const Ze=[Math.min(Ot,ee),Math.max(Ot,ee)+1];$||Xt==="multi"?ke(void 0,Ze,!0):ke(Nt.fromSingleSelection(Ze),void 0,$)}else $||C.isTouch||Xt==="multi"?Je?ke(Q.remove(ee),void 0,!0):(ke(void 0,ee,!0),Xs.current=ee):Je&&Q.length===1?ke(Nt.empty(),void 0,F):(ke(Nt.fromSingleSelection(ee),void 0,F),Xs.current=ee)}else if(K>=X&&ln&&ee===w){const Ke=Cf(K);zl(Ke??K)}else if(ce!==K||re!==ee){const Ke=$r(C.location),Je=Ee(Ke);if((Je==null?void 0:Je.onSelect)!==void 0){let Ue=!1;if(Je.onSelect({...C,cell:Ke,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,preventDefault:()=>Ue=!0,theme:cu(Ke,C.location)}),Ue)return}const Ot=jo&&ee===w,Ze=jo&&J!==void 0&&((Se=J.current)==null?void 0:Se.cell[1])===w;if((C.shiftKey||C.isLongTouch===!0)&&ce!==void 0&&re!==void 0&&J.current!==void 0&&!Ze){if(Ot)return;const Ue=Math.min(K,ce),Qt=Math.max(K,ce),Qn=Math.min(ee,re),Cn=Math.max(ee,re);oe({...J.current,range:{x:Ue,y:Qn,width:Qt-Ue+1,height:Cn-Qn+1}},!0,F,"click"),Xs.current=void 0,cr()}else oe({cell:[K,ee],range:{x:K,y:ee,width:1,height:1}},!0,F,"click"),Xs.current=void 0,s(void 0),cr()}}else if(C.kind==="header")if(Vo.current=[K,ee],s(void 0),_r&&K===0)Xs.current=void 0,jl.current=void 0,tt==="multi"&&(Q.length!==w?ke(Nt.fromSingleSelection([0,w]),void 0,F):ke(Nt.empty(),void 0,F),cr());else{const Ke=jl.current;if(be==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ke!==void 0&&Y.hasIndex(Ke)){const Je=[Math.min(Ke,K),Math.max(Ke,K)+1];U?ye(void 0,Je,F):ye(Nt.fromSingleSelection(Je),void 0,F)}else U?(Y.hasIndex(K)?ye(Y.remove(K),void 0,F):ye(void 0,K,F),jl.current=K):be!=="none"&&(ye(Nt.fromSingleSelection(K),void 0,F),jl.current=K);Xs.current=void 0,cr()}else C.kind===Hr?Vo.current=[K,ee]:C.kind===Dh&&!C.isMaybeScrollbar&&(br(nd,!1),s(void 0),cr(),St==null||St(),Xs.current=void 0,jl.current=void 0)},[zl,be,cr,Ee,Cf,$r,J,_r,jo,St,ar,X,ei,tt,Xt,w,oe,br,ye,ke,ln,cu]),du=v.useRef(!1),Vo=v.useRef(),Gw=v.useRef(kn),ri=v.useRef(),OR=v.useCallback(C=>{if(Hl.current=!1,Gw.current=an.current,C.button!==0&&C.button!==1){ri.current=void 0;return}const F=performance.now();ri.current={button:C.button,time:F,location:C.location},(C==null?void 0:C.kind)==="header"&&(du.current=!0);const $=C.kind==="cell"&&C.isFillHandle;!$&&C.kind!=="cell"&&C.isEdge||(u({previousSelection:J,fillHandle:$}),Vo.current=void 0,!C.isTouch&&C.button===0&&!$?fu(C):!C.isTouch&&C.button===1&&(Vo.current=C.location))},[J,fu]),[lg,ag]=v.useState(),qw=v.useCallback(C=>{if(C.kind!==Hr||be!=="multi")return;const F=_h.value?C.metaKey:C.ctrlKey,[$]=C.location,U=J.columns;if($=X&&_c(K.group,gt[Q].group);Q--)ee--;for(let Q=$+1;Q{if(In!==void 0&&xi!==void 0){const F=an.current.y,$=an.current.height;let U=In({x:C,y:F,width:1,height:Math.min($,w-F)},Yn.current.signal);typeof U!="object"&&(U=await U());const K=Lt[C-X],Y=document.createElement("canvas").getContext("2d",{alpha:!1});if(Y!==null){Y.font=de.baseFontFull;const Q=yE(Y,de,K,0,U,Nr,wi,!1,Ee);xi==null||xi(K,Q.width,C,Q.width)}}},[Lt,In,wi,de,Nr,xi,X,w,Ee]),[PR,ug]=v.useState(),Wl=v.useCallback(async(C,F)=>{var Q,ce;const $=(Q=C.current)==null?void 0:Q.range;if($===void 0||In===void 0||F.current===void 0)return;const U=F.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-X},patternSource:{...$,x:$.x-X},preventDefault:()=>re=!0}),re)return}let K=In($,Yn.current.signal);typeof K!="object"&&(K=await K());const ee=K,Y=[];for(let re=0;re({cell:re.location})))},[In,ni,T,X]),Yw=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]),Jw=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]),IR=v.useCallback((C,F)=>{var Te,Re;const $=a;if(u(void 0),ig(void 0),ug(void 0),du.current=!1,F)return;if(($==null?void 0:$.fillHandle)===!0&&J.current!==void 0&&((Te=$.previousSelection)==null?void 0:Te.current)!==void 0){if(Wo===void 0)return;const Se={...J,current:{...J.current,range:AE($.previousSelection.current.range,Wo)}};Wl($.previousSelection,Se),br(Se,!0);return}const[U,K]=C.location,[ee,Y]=Vo.current??[],Q=()=>{Hl.current=!0},ce=Se=>{var Je,Ot,Ze;const Ke=Se.isTouch||ee===U&&Y===K;if(Ke&&(x==null||x([U-X,K],{...Se,preventDefault:Q})),Se.button===1)return!Hl.current;if(!Hl.current){const Ue=$r(C.location),Qt=Ee(Ue);if(Qt!==void 0&&Qt.onClick!==void 0&&Ke){const Cn=Qt.onClick({...Se,cell:Ue,posX:Se.localEventX,posY:Se.localEventY,bounds:Se.bounds,theme:cu(Ue,C.location),preventDefault:Q});Cn!==void 0&&!ca(Cn)&&ql(Cn)&&(ni([{location:Se.location,value:Cn}]),(Je=xr.current)==null||Je.damage([{cell:Se.location}]))}if(Hl.current||J.current===void 0)return!1;let Qn=!1;switch(Ue.activationBehaviorOverride??Be){case"double-click":case"second-click":{if(((Ze=(Ot=$==null?void 0:$.previousSelection)==null?void 0:Ot.current)==null?void 0:Ze.cell)===void 0)break;const[Cn,Ci]=J.current.cell,[Gi,Ti]=$.previousSelection.current.cell;Qn=U===Cn&&U===Gi&&K===Ci&&K===Ti&&(Se.isDoubleClick===!0||Be==="second-click");break}case"single-click":{Qn=!0;break}}if(Qn)return S==null||S([U-X,K]),Bl(Se.bounds,!1),!0}return!1},re=C.location[0]-X;if(C.isTouch){const Se=an.current,Ke=Gw.current;if(Se.x!==Ke.x||Se.y!==Ke.y)return;if(C.isLongTouch===!0){if(C.kind==="cell"&&ic((Re=J.current)==null?void 0:Re.cell,C.location)){Z==null||Z([re,C.location[1]],{...C,preventDefault:Q});return}else if(C.kind==="header"&&J.columns.hasIndex(U)){V==null||V(re,{...C,preventDefault:Q});return}else if(C.kind===Hr){if(re<0)return;N==null||N(re,{...C,preventDefault:Q});return}}C.kind==="cell"?ce(C)||fu(C):C.kind===Hr?ie==null||ie(re,{...C,preventDefault:Q}):(C.kind===ro&&(I==null||I(re,{...C,preventDefault:Q})),fu(C));return}if(C.kind==="header"){if(re<0)return;C.isEdge?C.isDoubleClick===!0&&Tf(U):C.button===0&&U===ee&&K===Y&&(I==null||I(re,{...C,preventDefault:Q}))}if(C.kind===Hr){if(re<0)return;C.button===0&&U===ee&&K===Y&&(ie==null||ie(re,{...C,preventDefault:Q}),Hl.current||qw(C))}C.kind==="cell"&&(C.button===0||C.button===1)&&ce(C),Vo.current=void 0},[a,J,X,Wo,Wl,br,x,$r,Ee,Be,cu,ni,S,Bl,Z,V,N,fu,ie,I,Tf,qw]),NR=v.useCallback(C=>{const F={...C,location:[C.location[0]-X,C.location[1]]};bt==null||bt(F),a!==void 0&&C.buttons===0&&(u(void 0),ig(void 0),ug(void 0),du.current=!1),ug($=>{var U;return du.current?[C.scrollEdge[0],0]:C.scrollEdge[0]===($==null?void 0:$[0])&&C.scrollEdge[1]===$[1]?$:a===void 0||(((U=ri.current)==null?void 0:U.location[0])??0){dt==null||dt(C-X,F)},[dt,X]),Xi=(i1=J==null?void 0:J.current)==null?void 0:i1.cell,DR=v.useCallback((C,F,$,U,K,ee)=>{It.current=!1;let Y=Xi;Y!==void 0&&(Y=[Y[0]-X,Y[1]]);const Q=Ye===0?void 0:{x:0,y:C.y,width:Ye,height:C.height},ce=[];Q!==void 0&&ce.push(Q),ft>0&&(ce.push({x:C.x-X,y:w-ft,width:C.width,height:ft}),Ye>0&&ce.push({x:0,y:w-ft,width:Ye,height:ft}));const re={x:C.x-X,y:C.y,width:C.width,height:ln&&C.y+C.height>=w?C.height-1:C.height,tx:K,ty:ee,extras:{selected:Y,freezeRegion:Q,freezeRegions:ce}};an.current=re,Lr(re),st([F,$,U]),cn==null||cn(re,re.tx,re.ty,re.extras)},[Xi,X,ln,w,Ye,ft,Lr,cn]),LR=Ul(qe,v.useCallback((C,F)=>{qe==null||qe(C-X,F-X),be!=="none"&&ye(Nt.fromSingleSelection(F),void 0,!0)},[be,qe,X,ye])),cg=v.useRef(!1),$R=v.useCallback(C=>{if(C.location[0]===0&&X>0){C.preventDefault();return}wt==null||wt({...C,location:[C.location[0]-X,C.location[1]]}),C.defaultPrevented()||(cg.current=!0),u(void 0)},[wt,X]),FR=v.useCallback(()=>{cg.current=!1},[]),fg=v.useRef(),dg=v.useCallback(C=>{var F,$,U;if(!WE(C,fg.current)&&(fg.current=C,!(((F=ri==null?void 0:ri.current)==null?void 0:F.button)!==void 0&&ri.current.button>=1))){if(C.buttons!==0&&a!==void 0&&(($=ri.current)==null?void 0:$.location[0])===0&&C.location[0]===0&&X===1&&tt==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ri.current.location[1])&&J.rows.hasIndex(ri.current.location[1])){const K=Math.min(ri.current.location[1],C.location[1]),ee=Math.max(ri.current.location[1],C.location[1])+1;ke(Nt.fromSingleSelection([K,ee]),void 0,!1)}if(C.buttons!==0&&a!==void 0&&J.current!==void 0&&!cg.current&&!du.current&&(Ie==="rect"||Ie==="multi-rect")){const[K,ee]=J.current.cell;let[Y,Q]=C.location;if(Q<0&&(Q=an.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const ce=a.previousSelection.current.range;Q=Math.min(Q,ln?w-1:w);const re=S5(ce,Y,Q,pn);ig(re)}else{if(ln&&ee===w)return;if(ln&&Q===w)if(C.kind===Dh)Q--;else return;Y=Math.max(Y,X);const Te=Y-K,Re=Q-ee,Se={x:Te>=0?K:Y,y:Re>=0?ee:Q,width:Math.abs(Te)+1,height:Math.abs(Re)+1};oe({...J.current,range:Se},!0,!1,"drag")}}Vt==null||Vt({...C,location:[C.location[0]-X,C.location[1]]})}},[pn,a,X,tt,J,Ie,Vt,ke,ln,w,oe]),BR=v.useCallback(()=>{var Y,Q;const C=fg.current;if(C===void 0)return;const[F,$]=C.scrollEdge;let[U,K]=C.location;const ee=an.current;F===-1?U=((Q=(Y=ee.extras)==null?void 0:Y.freezeRegion)==null?void 0:Q.x)??ee.x:F===1&&(U=ee.x+ee.width),$===-1?K=Math.max(0,ee.y):$===1&&(K=Math.min(w-1,ee.y+ee.height)),U=Ii(U,0,gt.length-1),K=Ii(K,0,w-1),dg({...C,location:[U,K]})},[gt.length,dg,w]);P6(PR,c,BR);const Si=v.useCallback(C=>{if(J.current===void 0)return;const[F,$]=C,[U,K]=J.current.cell,ee=J.current.range;let Y=ee.x,Q=ee.x+ee.width,ce=ee.y,re=ee.y+ee.height;if($!==0)switch($){case 2:{re=w,ce=K,Sn(0,re,"vertical");break}case-2:{ce=0,re=K+1,Sn(0,ce,"vertical");break}case 1:{ceK+1?(re--,Sn(0,re,"vertical")):(ce=Math.max(0,ce-1),Sn(0,ce,"vertical"));break}default:Nc()}if(F!==0)if(F===2)Q=gt.length,Y=U,Sn(Q-1-X,0,"horizontal");else if(F===-2)Y=X,Q=U+1,Sn(Y-X,0,"horizontal");else{let Te=[];if(In!==void 0){const Re=In({x:Y,y:ce,width:Q-Y-X,height:re-ce},Yn.current.signal);typeof Re=="object"&&(Te=L6(Re))}if(F===1){let Re=!1;if(Y0){const Se=rl(Y+1,U+1).find(Ke=>!Te.includes(Ke-X));Se!==void 0&&(Y=Se,Re=!0)}else Y++,Re=!0;Re&&Sn(Y,0,"horizontal")}Re||(Q=Math.min(gt.length,Q+1),Sn(Q-1-X,0,"horizontal"))}else if(F===-1){let Re=!1;if(Q>U+1){if(Te.length>0){const Se=rl(Q-1,U,-1).find(Ke=>!Te.includes(Ke-X));Se!==void 0&&(Q=Se,Re=!0)}else Q--,Re=!0;Re&&Sn(Q-X,0,"horizontal")}Re||(Y=Math.max(X,Y-1),Sn(Y-X,0,"horizontal"))}else Nc()}oe({cell:J.current.cell,range:{x:Y,y:ce,width:Q-Y,height:re-ce}},!0,!1,"keyboard-select")},[In,J,gt.length,X,w,Sn,oe]),Gs=v.useCallback((C,F,$,U)=>{const K=Jn-($?0:1);if(C=Ii(C,X,Lt.length-1+X),F=Ii(F,0,K),C===(Xi==null?void 0:Xi[0])&&F===(Xi==null?void 0:Xi[1]))return!1;if(U&&J.current!==void 0){const ee=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&ee.push(J.current.range),br({...J,current:{cell:[C,F],range:{x:C,y:F,width:1,height:1},rangeStack:ee}},!0)}else oe({cell:[C,F],range:{x:C,y:F,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===C&&f.current[1]===F&&(f.current=void 0),Sn(C-X,F),!0},[Jn,X,Lt.length,Xi,J,Sn,br,oe]),zR=v.useCallback((C,F)=>{(i==null?void 0:i.cell)!==void 0&&C!==void 0&&ql(C)&&(ni([{location:i.cell,value:C}]),window.requestAnimationFrame(()=>{var K;(K=xr.current)==null||K.damage([{cell:i.cell}])})),cr(!0),s(void 0);const[$,U]=F;if(J.current!==void 0&&($!==0||U!==0)){const K=J.current.cell[1]===Jn-1&&C!==void 0;Gs(Ii(J.current.cell[0]+$,0,gt.length-1),Ii(J.current.cell[1]+U,0,Jn-1),K,!1)}A==null||A(C,F)},[i==null?void 0:i.cell,cr,J,A,ni,Jn,Gs,gt.length]),jR=v.useMemo(()=>`gdg-overlay-${D6++}`,[]),Uo=v.useCallback(C=>{var $,U,K,ee;cr();const F=[];for(let Y=C.x;Y({cell:Y.location})))},[cr,k,Ee,ni,X]),hu=i!==void 0,Qw=v.useCallback(C=>{var Ke,Je;const F=()=>{C.stopPropagation(),C.preventDefault()},$={didMatch:!1},{bounds:U}=C,K=J.columns,ee=J.rows,Y=bi;if(!hu&&yt(Y.clear,C,$))br(nd,!1),St==null||St();else if(!hu&&yt(Y.selectAll,C,$))br({columns:Nt.empty(),rows:Nt.empty(),current:{cell:((Ke=J.current)==null?void 0:Ke.cell)??[X,0],range:{x:X,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(yt(Y.search,C,$))(Je=o==null?void 0:o.current)==null||Je.focus({preventScroll:!0}),vf(!0);else if(yt(Y.delete,C,$)){const Ot=(H==null?void 0:H(J))??!0;if(Ot!==!1){const Ze=Ot===!0?J:Ot;if(Ze.current!==void 0){Uo(Ze.current.range);for(const Ue of Ze.current.rangeStack)Uo(Ue)}for(const Ue of Ze.rows)Uo({x:X,y:Ue,width:y.length,height:1});for(const Ue of Ze.columns)Uo({x:Ue,y:0,width:1,height:w})}}if($.didMatch)return F(),!0;if(J.current===void 0)return!1;let[Q,ce]=J.current.cell,re=!1,Te=!1;yt(Y.scrollToSelectedCell,C,$)?Mf.current(Q-X,ce):be!=="none"&&yt(Y.selectColumn,C,$)?K.hasIndex(Q)?ye(K.remove(Q),void 0,!0):be==="single"?ye(Nt.fromSingleSelection(Q),void 0,!0):ye(void 0,Q,!0):tt!=="none"&&yt(Y.selectRow,C,$)?ee.hasIndex(ce)?ke(ee.remove(ce),void 0,!0):tt==="single"?ke(Nt.fromSingleSelection(ce),void 0,!0):ke(void 0,ce,!0):!hu&&U!==void 0&&yt(Y.activateCell,C,$)?ce===w&&ln?window.setTimeout(()=>{const Ot=Cf(Q);zl(Ot??Q)},0):(S==null||S([Q-X,ce]),Bl(U,!0)):J.current.range.height>1&&yt(Y.downFill,C,$)?Jw():J.current.range.width>1&&yt(Y.rightFill,C,$)?Yw():yt(Y.goToNextPage,C,$)?ce+=Math.max(1,an.current.height-4):yt(Y.goToPreviousPage,C,$)?ce-=Math.max(1,an.current.height-4):yt(Y.goToFirstCell,C,$)?(s(void 0),ce=0,Q=0):yt(Y.goToLastCell,C,$)?(s(void 0),ce=Number.MAX_SAFE_INTEGER,Q=Number.MAX_SAFE_INTEGER):yt(Y.selectToFirstCell,C,$)?(s(void 0),Si([-2,-2])):yt(Y.selectToLastCell,C,$)?(s(void 0),Si([2,2])):hu?(yt(Y.closeOverlay,C,$)&&s(void 0),yt(Y.acceptOverlayDown,C,$)&&(s(void 0),ce++),yt(Y.acceptOverlayUp,C,$)&&(s(void 0),ce--),yt(Y.acceptOverlayLeft,C,$)&&(s(void 0),Q--),yt(Y.acceptOverlayRight,C,$)&&(s(void 0),Q++)):(yt(Y.goDownCell,C,$)?ce+=1:yt(Y.goUpCell,C,$)?ce-=1:yt(Y.goRightCell,C,$)?Q+=1:yt(Y.goLeftCell,C,$)?Q-=1:yt(Y.goDownCellRetainSelection,C,$)?(ce+=1,re=!0):yt(Y.goUpCellRetainSelection,C,$)?(ce-=1,re=!0):yt(Y.goRightCellRetainSelection,C,$)?(Q+=1,re=!0):yt(Y.goLeftCellRetainSelection,C,$)?(Q-=1,re=!0):yt(Y.goToLastRow,C,$)?ce=w-1:yt(Y.goToFirstRow,C,$)?ce=Number.MIN_SAFE_INTEGER:yt(Y.goToLastColumn,C,$)?Q=Number.MAX_SAFE_INTEGER:yt(Y.goToFirstColumn,C,$)?Q=Number.MIN_SAFE_INTEGER:(Ie==="rect"||Ie==="multi-rect")&&(yt(Y.selectGrowDown,C,$)?Si([0,1]):yt(Y.selectGrowUp,C,$)?Si([0,-1]):yt(Y.selectGrowRight,C,$)?Si([1,0]):yt(Y.selectGrowLeft,C,$)?Si([-1,0]):yt(Y.selectToLastRow,C,$)?Si([0,2]):yt(Y.selectToFirstRow,C,$)?Si([0,-2]):yt(Y.selectToLastColumn,C,$)?Si([2,0]):yt(Y.selectToFirstColumn,C,$)&&Si([-2,0])),Te=$.didMatch);const Re=Gs(Q,ce,!1,re),Se=$.didMatch;return Se&&(Re||!Te||df)&&F(),Se},[hu,J,bi,be,tt,Ie,X,w,Gs,br,St,y.length,H,df,Uo,ye,ke,ln,Cf,zl,S,Bl,Jw,Yw,Si]),pu=v.useCallback(C=>{let F=!1;if(Ne!==void 0&&Ne({...C,cancel:()=>{F=!0}}),F||Qw(C)||J.current===void 0)return;const[$,U]=J.current.cell,K=an.current;if($e&&!C.metaKey&&!C.ctrlKey&&J.current!==void 0&&C.key.length===1&&/[ -~]/g.test(C.key)&&C.bounds!==void 0&&Hu(k([$-X,Math.max(0,Math.min(U,w-1))]))){if((!ln||U!==w)&&(K.y>U||U>K.y+K.height||K.x>$||$>K.x+K.width))return;Bl(C.bounds,!0,C.key),C.stopPropagation(),C.preventDefault()}},[$e,Ne,Qw,J,k,X,w,ln,Bl]),HR=v.useCallback((C,F)=>{const $=C.location[0]-X;if(C.kind==="header"&&(V==null||V($,{...C,preventDefault:F})),C.kind===Hr){if($<0)return;N==null||N($,{...C,preventDefault:F})}if(C.kind==="cell"){const[U,K]=C.location;Z==null||Z([$,K],{...C,preventDefault:F}),w4(J,C.location)||Gs(U,K,!1,!1)}},[J,Z,N,V,X,Gs]),hg=v.useCallback(async C=>{var Y,Q,ce;if(!bi.paste)return;function F(re,Te,Re,Se){var Je,Ot;const Ke=typeof Re=="object"?(Re==null?void 0:Re.join(` +`))??"":(Re==null?void 0:Re.toString())??"";if(!ca(re)&&Hu(re)&&re.readonly!==!0){const Ze=M==null?void 0:M(Ke,re);if(Ze!==void 0&&ql(Ze))return{location:Te,value:Ze};const Ue=Ee(re);if(Ue===void 0)return;if(Ue.kind===Ce.Custom){Wr(re.kind===Ce.Custom);const Qt=(Je=Ue.onPaste)==null?void 0:Je.call(Ue,Ke,re.data);return Qt===void 0?void 0:{location:Te,value:{...re,data:Qt}}}else{const Qt=(Ot=Ue.onPaste)==null?void 0:Ot.call(Ue,Ke,re,{formatted:Se,formattedString:typeof Se=="string"?Se:Se==null?void 0:Se.join(` +`),rawValue:Re});return Qt===void 0?void 0:(Wr(Qt.kind===re.kind),{location:Te,value:Qt})}}}const $=J.columns,U=J.rows,K=((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0;let ee;if(J.current!==void 0?ee=[J.current.range.x,J.current.range.y]:$.length===1?ee=[$.first()??0,0]:U.length===1&&(ee=[X,U.first()??0]),K&&ee!==void 0){let re,Te;const Re="text/plain",Se="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const Ue of Ze){if(Ue.types.includes(Se)){const Qn=await(await Ue.getType(Se)).text(),Cn=Hx(Qn);if(Cn!==void 0){re=Cn;break}}Ue.types.includes(Re)&&(Te=await(await Ue.getType(Re)).text())}}else if(navigator.clipboard.readText!==void 0)Te=await navigator.clipboard.readText();else if(C!==void 0&&(C==null?void 0:C.clipboardData)!==null){if(C.clipboardData.types.includes(Se)){const Ze=C.clipboardData.getData(Se);re=Hx(Ze)}re===void 0&&C.clipboardData.types.includes(Re)&&(Te=C.clipboardData.getData(Re))}else return;const[Ke,Je]=ee,Ot=[];do{if(fe===void 0){const Ze=$r(ee),Ue=Te??(re==null?void 0:re.map(Qn=>Qn.map(Cn=>Cn.rawValue).join(" ")).join(" "))??"",Qt=F(Ze,ee,Ue,void 0);Qt!==void 0&&Ot.push(Qt);break}if(re===void 0){if(Te===void 0)return;re=C6(Te)}if(fe===!1||typeof fe=="function"&&(fe==null?void 0:fe([ee[0]-X,ee[1]],re.map(Ze=>Ze.map(Ue=>{var Qt;return((Qt=Ue.rawValue)==null?void 0:Qt.toString())??""}))))!==!0)return;for(const[Ze,Ue]of re.entries()){if(Ze+Je>=w)break;for(const[Qt,Qn]of Ue.entries()){const Cn=[Qt+Ke,Ze+Je],[Ci,Gi]=Cn;if(Ci>=gt.length||Gi>=Jn)continue;const Ti=$r(Cn),qi=F(Ti,Cn,Qn.rawValue,Qn.formatted);qi!==void 0&&Ot.push(qi)}}}while(!1);ni(Ot),(ce=xr.current)==null||ce.damage(Ot.map(Ze=>({cell:Ze.location})))}},[M,Ee,$r,J,bi.paste,gt.length,ni,Jn,fe,X,w]);Vn("paste",hg,d,!1,!0);const gu=v.useCallback(async(C,F)=>{var Y,Q;if(!bi.copy)return;const $=F===!0||((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0,U=J.columns,K=J.rows,ee=(ce,re)=>{if(!Le)Vx(ce,re,C);else{const Te=re.map(Re=>({kind:Ce.Text,data:y[Re].title,displayData:y[Re].title,allowOverlay:!1}));Vx([Te,...ce],re,C)}};if($&&In!==void 0){if(J.current!==void 0){let ce=In(J.current.range,Yn.current.signal);typeof ce!="object"&&(ce=await ce()),ee(ce,rl(J.current.range.x-X,J.current.range.x+J.current.range.width-X))}else if(K!==void 0&&K.length>0){const re=[...K].map(Te=>{const Re=In({x:X,y:Te,width:y.length,height:1},Yn.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);ee(Te,rl(y.length))}else ee(re,rl(y.length))}else if(U.length>0){const ce=[],re=[];for(const Te of U){let Re=In({x:Te,y:0,width:1,height:w},Yn.current.signal);typeof Re!="object"&&(Re=await Re()),ce.push(Re),re.push(Te-X)}if(ce.length===1)ee(ce[0],re);else{const Te=ce.reduce((Re,Se)=>Re.map((Ke,Je)=>[...Ke,...Se[Je]]));ee(Te,re)}}}},[y,In,J,bi.copy,X,w,Le]);Vn("copy",gu,d,!1,!1);const WR=v.useCallback(async C=>{var $,U;if(!(!bi.cut||!((($=c.current)==null?void 0:$.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await gu(C),J.current!==void 0)){let K={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:Nt.empty(),columns:Nt.empty()};const ee=H==null?void 0:H(K);if(ee===!1||(K=ee===!0?K:ee,K.current===void 0))return;Uo(K.current.range)}},[Uo,J,bi.cut,gu,H]);Vn("cut",WR,d,!1,!1);const VR=v.useCallback((C,F)=>{if(B!==void 0){X!==0&&(C=C.map(K=>[K[0]-X,K[1]])),B(C,F);return}if(C.length===0||F===-1)return;const[$,U]=C[F];f.current!==void 0&&f.current[0]===$&&f.current[1]===U||(f.current=[$,U],Gs($,U,!1,!1))},[B,X,Gs]),[Ef,Af]=((s1=Ut==null?void 0:Ut.current)==null?void 0:s1.cell)??[],Mf=v.useRef(Sn);Mf.current=Sn,v.useLayoutEffect(()=>{var C,F,$,U;!It.current&&Ef!==void 0&&Af!==void 0&&(Ef!==((F=(C=Ks.current)==null?void 0:C.current)==null?void 0:F.cell[0])||Af!==((U=($=Ks.current)==null?void 0:$.current)==null?void 0:U.cell[1]))&&Mf.current(Ef,Af),It.current=!1},[Ef,Af]);const Zw=J.current!==void 0&&(J.current.cell[0]>=gt.length||J.current.cell[1]>=Jn);v.useLayoutEffect(()=>{Zw&&br(nd,!1)},[Zw,br]);const UR=v.useMemo(()=>ln===!0&&(ct==null?void 0:ct.tint)===!0?Nt.fromSingleSelection(Jn-1):Nt.empty(),[Jn,ln,ct==null?void 0:ct.tint]),KR=v.useCallback(C=>typeof ze=="boolean"?ze:(ze==null?void 0:ze(C-X))??!0,[X,ze]),XR=v.useMemo(()=>{if(lg===void 0||l.current===null)return null;const{bounds:C,group:F}=lg,$=l.current.getBoundingClientRect();return v.createElement(h6,{bounds:C,group:F,canvasBounds:$,onClose:()=>ag(void 0),onFinish:U=>{ag(void 0),L==null||L(F,U)}})},[L,lg]),GR=Math.min(gt.length,Ye+(_r?1:0));v.useImperativeHandle(e,()=>({appendRow:(C,F)=>zl(C+X,F),updateCells:C=>{var F;return X!==0&&(C=C.map($=>({cell:[$.cell[0]+X,$.cell[1]]}))),(F=xr.current)==null?void 0:F.damage(C)},getBounds:(C,F)=>{var $;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(C===void 0&&F===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($=xr.current)==null?void 0:$.getBounds((C??0)+X,F)}},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 hg();break}},scrollTo:Sn,remeasureColumns:C=>{for(const F of C)Tf(F+X)}}),[zl,Tf,gu,pu,hg,X,Sn]);const[e1,t1]=Xi??[],qR=v.useCallback(C=>{const[F,$]=C;if($===-1){be!=="none"&&(ye(Nt.fromSingleSelection(F),void 0,!1),cr());return}e1===F&&t1===$||(oe({cell:C,range:{x:F,y:$,width:1,height:1}},!0,!1,"keyboard-nav"),Sn(F,$))},[be,cr,Sn,e1,t1,oe,ye]),[YR,JR]=v.useState(!1),n1=v.useRef(GT(C=>{JR(C)},5)),QR=v.useCallback(()=>{n1.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&oe({cell:[X,wf],range:{x:X,y:wf,width:1,height:1}},!0,!1,"keyboard-select")},[wf,J,a,X,oe]),ZR=v.useCallback(()=>{n1.current(!1)},[]),[eO,tO]=v.useMemo(()=>{let C;const F=(xe==null?void 0:xe.scrollbarWidthOverride)??$0(),$=w+(ln?1:0);if(typeof ur=="number")C=ut+$*ur;else{let K=0;const ee=Math.min($,10);for(let Y=0;Yee.width+K,0)+F;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,C)}px`]},[gt,xe==null?void 0:xe.scrollbarWidthOverride,ur,w,ln,ut]),nO=v.useMemo(()=>_4(de),[de]);return v.createElement(D4.Provider,{value:de},v.createElement(M6,{style:nO,className:W,inWidth:b??eO,inHeight:m??tO},v.createElement(u6,{fillHandle:ae,drawFocusRing:je,experimental:xe,fixedShadowX:Pt,fixedShadowY:rt,getRowThemeOverride:p,headerIcons:Rt,imageWindowLoader:Gt,initialSize:qn,isDraggable:Qr,onDragLeave:On,onRowMoved:ar,overscrollX:Qp,overscrollY:yf,preventDiagonalScrolling:bs,rightElement:zo,rightElementProps:Ws,smoothScrollX:hf,smoothScrollY:Gp,className:W,enableGroups:Ft,onCanvasFocused:QR,onCanvasBlur:ZR,canvasRef:l,onContextMenu:HR,theme:de,cellXOffset:Ho,cellYOffset:wf,accessibilityHeight:kn.height,onDragEnd:FR,columns:gt,nonGrowWidth:He,drawHeader:ng,onColumnProposeMove:_,drawCell:rg,disabledRows:UR,freezeColumns:GR,lockColumns:X,firstColAccessible:X===0,getCellContent:$r,minColumnWidth:Nr,maxColumnWidth:wi,searchInputRef:o,showSearch:au,onSearchClose:eg,highlightRegions:RR,getCellsForSelection:In,getGroupDetails:sg,headerHeight:_l,isFocused:YR,groupHeaderHeight:Ft?lu:0,freezeTrailingRows:ft+(ln&&(ct==null?void 0:ct.sticky)===!0?1:0),hasAppendRow:ln,onColumnResize:xi,onColumnResizeEnd:tg,onColumnResizeStart:Ll,onCellFocused:qR,onColumnMoved:LR,onDragStart:$R,onHeaderMenuClick:_R,onItemHovered:dg,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:NR,onKeyDown:pu,onKeyUp:se,onMouseDown:OR,onMouseUp:IR,onDragOverCell:Rn,onDrop:pt,onSearchResultsChanged:VR,onVisibleRegionChanged:DR,clientSize:Me,rowHeight:ur,searchResults:me,searchValue:ve,onSearchValueChange:le,rows:Jn,scrollRef:c,selection:J,translateX:kn.tx,translateY:kn.ty,verticalBorder:KR,gridRef:xr,getCellRenderer:Ee}),XR,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(_6,{...i,validateCell:uu,bloom:P,id:jR,getCellRenderer:Ee,className:(xe==null?void 0:xe.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Bt,imageEditorOverride:h,onFinishEditing:zR,markdownDivCreateNode:g,isOutsideClick:pf}))))},F6=v.forwardRef($6),Xx=20,B6={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=>z6(t,t.cell.data,I0(t.cell),t.cell.maxSize??Xx),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??Xx,f=Math.floor(i.y+l/2),d=JT(c,l,s.cellVerticalPadding),h=YT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=qT(h,f,d),g=QT(a+n,u+r,p);if(I0(e)&&g)return{...e,data:UE(e.data)}},onPaste:(t,e)=>{let n=kh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=qv),n===e.data?void 0:{...e,data:n}}};function z6(t,e,n,r){if(!n&&e===kh)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:g}=l,b=.35;let m=n?1-b+b*s:.4;e===kh&&(m*=s),m!==0&&(i.globalAlpha=m,uw(i,o,e,d,h,p,g,a,u,c,r,f),i.globalAlpha=1)}const j6=Jr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),H6=t=>{const{bubbles:e}=t;return v.createElement(j6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},W6={getAccessibilityString:t=>ZT(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=>U6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(H6,{bubbles:e.data})},onPaste:()=>{}},V6=4;function U6(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=V6;let h=o+r.cellHorizontalPadding;const p=[];for(const g of e){if(h>o+a)break;const b=rf(g,i,r.baseFontFull).width;p.push({x:h,width:b}),h+=b+f*2+d}i.beginPath();for(const g of p)hs(i,g.x,l+(u-c)/2,g.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[g,b]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[g],b.x+f,l+u/2+Hs(i,r))}const K6=Jr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),X6=t=>{const{drilldowns:e}=t;return v.createElement(K6,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))))},G6={getAccessibilityString:t=>ZT(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=>J6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(X6,{drilldowns:e.data})},onPaste:()=>{}},q6=4,lm={};function Y6(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(lm[d]!==void 0)return{el:lm[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),lm[d]=h,p.beginPath(),hs(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(),hs(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=dE(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,g=8,b=q6;let m=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=Y6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const x of e){if(m>a+u)break;const T=rf(x.text,i,c).width;let A=0;x.img!==void 0&&s.loadOrGetImage(x.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+g*2;k.push({x:m,width:M}),m+=M+b}if(w!==null){const{el:x,height:S,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:D}=w,P=A/O,I=D/O;for(const _ of k){const te=Math.floor(_.x),ie=Math.floor(_.width),Z=ie-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(x,0,0,A,S,te-I,h,P,d),Z>0&&i.drawImage(x,A,0,T,S,te+(P-I),h,Z,d),i.drawImage(x,M-A,0,A,S,te+ie-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[x,S]of k.entries()){const T=e[x];let A=S.x+g;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const O=p-8;let D=0,P=0,I=M.width,_=M.height;I>_?(D+=(I-_)/2,I=_):_>I&&(P+=(_-I)/2,_=I),i.beginPath(),hs(i,A,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,D,P,I,_,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+Hs(i,r))}}const Q6={getAccessibilityString:t=>t.data.join(", "),kind:Ce.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>Z6(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??WF;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}}},am=4;function Z6(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,g=[];let b=0;for(let y=0;y0&&(a.beginPath(),hs(a,m,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(y,m,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),m+=w+am}}function e9(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const t9={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(e9(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);hs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=bl(o.textDark,.1),i.fill()},onPaste:()=>{}},n9=()=>t=>t.targetWidth,Gx=Jr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[n9(),"px"]}}),r9=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(Gx,{targetWidth:s.width-20},v.createElement(Pp,{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(LF,null))):v.createElement(Gx,{targetWidth:s.width},v.createElement(a4,{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(ew,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},i9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:sf,measure:(t,e,n)=>{const r=e.data.split(` +`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>Rs(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(r9,{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}},s9={getAccessibilityString:t=>t.row.toString(),kind:ai.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:o9,measure:()=>44,draw:t=>a9(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 o9(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=l9,n.textAlign="center",s}function l9(t){const{ctx:e}=t;e.textAlign="start"}function a9(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 g=7*(n?a:1);if(uw(o,u,n,i?c+g:c,f,i?d-g:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const b of[3,6])for(const m of[-5,-1,3])o.rect(c+b,f+h/2+m,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const g=e.toString(),b=u.markerFontFull,m=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=b,o.fillText(g,m,f+h/2+Hs(o,b)),a!==0&&(o.globalAlpha=1)}}const u9={getAccessibilityString:()=>"",kind:ai.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>c9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function c9(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 g=f-8,b=a+8/2,m=u+8/2;l.drawSprite(n,"normal",r,b,m,g,o,d?1:s),h=g}else{h=24;const p=12,g=d?p:s*p,b=d?0:(1-s)*p*.5,m=o.cellHorizontalPadding+4;g>0&&(r.moveTo(a+m+b,u+f/2),r.lineTo(a+m+b+g,u+f/2),r.moveTo(a+m+b+g*.5,u+f/2-g*.5),r.lineTo(a+m+b+g*.5,u+f/2+g*.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+Hs(r,o)),r.beginPath()}const f9=v.lazy(async()=>await vE(()=>import("./number-overlay-editor-D2EysIl4.js"),[])),d9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:sf,draw:t=>Rs(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(f9,{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}}},h9={getAccessibilityString:()=>"",measure:()=>108,kind:Ce.Protected,needsHover:!1,needsHoverPosition:!1,draw:p9,onPaste:()=>{}};function p9(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(qb(30))*l,f=Math.sin(qb(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 g9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>sf(t,e,t.theme.textLight),draw:t=>Rs(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 $n.createElement(Pp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},m9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Ce.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:sf,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=rf(a,i,o.baseFontFull,"alphabetic"),g=s.height-h,b=Math.min(g,p.actualBoundingBoxAscent*2.5);i.beginPath(),hs(i,s.x+d/2,s.y+(s.height-b)/2+1,p.width+d*3,b-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=bl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}Rs(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(Pp,{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}},y9=Jr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),v9=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(Pp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(y9,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(ew,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function qx(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 w9={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:sf,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=rf(a,l,n.baseFontFull),f=qx(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:g}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+g+8){const b=Hs(l,n.baseFontFull);r("pointer");const m=5,y=h-b;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+y+g+m)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+y+g+m)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,Rs({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),Rs({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),Rs({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),Rs({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,Rs(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=E4(o,s.baseFontFull);if(l===void 0)return;const a=qx(l,n,s,e.contentAlign);Np({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(v9,{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}},b9=[s9,u9,B6,W6,G6,Q6,t9,i9,d9,h9,g9,m9,w9];var x9=XT,k9=Al,S9="Expected a function";function C9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(S9);return k9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),x9(t,e,{leading:r,maxWait:e,trailing:i})}var T9=C9;const E9=Wi(T9),um=[];class A9 extends pE{constructor(){super(...arguments);xt(this,"imageLoaded",()=>{});xt(this,"loadedLocations",[]);xt(this,"cache",{});xt(this,"sendLoaded",E9(()=>{this.imageLoaded(new oc(this.loadedLocations)),this.loadedLocations=[]},20));xt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,um.length<12?um.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(ow(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=Ni(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const Yx="\uFEFF",rd=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/,jd=/^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/,KE=/^\s*[-=]+(?:\+[-=]+)+\s*$/,M9=/^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i;function Ou(t){for(let e=0;e=0&&t[n]==="\\";n--)e++;return e%2===0}function Jx(t){let e=t.trim();e.startsWith("|")&&(e=e.slice(1)),R9(e)&&(e=e.slice(0,-1));const n=[];let r="";for(let i=0;ir.trim())}function O9(t,e){const n=[],r=Math.min(t.length,32768);let i=0;for(let s=0;s<=r;s++){const l=s===r?` +`:t[s];if(l===` +`||l==="\r"){const a=t.slice(i,s);if(a.trim().length>0&&(n.push(a),n.length>=e))return n;l==="\r"&&t[s+1]===` +`&&s++,i=s+1}}return n}function Pu(t){return jd.test(t)||KE.test(t)}function of(t){if(!t)return null;const e=t.startsWith(Yx)?t.slice(Yx.length):t,n=O9(e,3);if(n.length<2)return null;const r=Ou(n[0])&&!Pu(n[0])&&!rd.test(n[0])&&rd.test(n[1]),i=Ou(n[0])&&!Pu(n[0])&&(KE.test(n[1])||jd.test(n[1])),s=jd.test(n[0])&&Ou(n[1])&&!Pu(n[1])&&(n.length<3||Pu(n[2])||Ou(n[2]));if(!r&&!i&&!s)return null;const o=e.split(/\r?\n/).filter(g=>g.trim().length>0);if(o.length<2)return null;if(r&&rd.test(o[1])){const g=Jx(o[0]);if(g.length===0||g.every(y=>y===""))return null;const b=[];for(let y=2;y=2&&M9.test(o[l-1])&&l--;let a=!1;const u=[];for(let g=0;gg===""))return null;const h=u.slice(1).map(g=>Qx(g,f));return{cleanedCsv:lc(d,h,","),rows:h.length,cols:d.length,kind:"box"}}const cm="\uFEFF";function P9(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 I9(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=s.length)break;if(s[k]===l){d=k+1,h=!0;continue}d=s[k]==="\r"&&s[k+1]===` +`?k+2:k+1,a.push(c),u.push({start:f+o,end:k+o}),c=[]}c.length>0?(a.push(c),u.push({start:f+o,end:s.length+o})):a.length===0&&c.length===0&&s.length>0&&(a.push([""]),u.push({start:0+o,end:s.length+o}));const p=a.length>0?a[0]:[],g=p.length,b=a.slice(1),m=b.map(w=>w.length),y=b.map(w=>w.length===g?w:w.length>g?w.slice(0,g):[...w,...Array(g-w.length).fill("")]);return{headers:p,rows:y,delimiter:l,rowWidths:m,rowSpans:u.slice(1)}}function _p(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 lc(t,e,n=","){return[t,...e].map(r=>_p(r,n)).join(` +`)}function dw(t,e){return lf(t,e).headers}function N9(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 XE(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 _9(t,e){return t[e]==="\r"?t[e+1]===` +`?2:1:t[e]===` +`?1:0}function Zx(t,e){return t[e-2]==="\r"&&t[e-1]===` +`?2:t[e-1]==="\r"||t[e-1]===` +`?1:0}const ek="\uFEFF";function GE(t,e){const n=t.startsWith(ek)?ek.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Zx(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Zx(t,t.length)}}function fm(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+_9(t,i.end),replacement:""}));return r.length===0?t:XE(t,r)}function tk(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:_p(a,e.delimiter)})}return XE(t,s)}function D9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=GE(t,e),s=dw(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=_p(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const Y0=50;function qo(t=""){return{past:[],present:t,future:[]}}function nk(t,e,n=Y0){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 L9(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 $9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>Y0?r.slice(r.length-Y0):r,present:e,future:n}}function F9(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 rk=/^[+-]?\d{16,}$/;function B9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),g=Number.isNaN(h);if(p||g)return p&&g?0:p?1:-1;if(rk.test(a)&&rk.test(u)){const b=BigInt(a),m=BigInt(u);return s*(bm?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const j9=` + +`;function id(t,e){return Math.max(0,Math.min(t,e))}function ik(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=id(a.x,r+i),c=id(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=id(a.y,e.length),p=id(a.y+a.height,e.length);if(p<=h)continue;const g=t.headers.slice(f,d),b=[];for(let m=h;mw[f+x]??""))}b.length!==0&&s.push(lc(g,b,t.delimiter))}if(s.length>0)return s.join(j9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return lc(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 lc(a,u,t.delimiter)}return null}const Yo=1e5,H9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function W9(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 g of n.ranges){if(o.size>=Yo)break;const b=Math.max(0,g.x-r),m=Math.min(i,g.x+g.width-r);if(m<=b)continue;const y=Math.max(0,g.y),w=Math.min(s,g.y+g.height);if(!(w<=y))for(let k=y;k=Yo);k++){const x=k*i;for(let S=b;S=Yo));S++);}}for(const g of n.rows){if(o.size>=Yo)break;if(g<0||g>=s)continue;const b=g*i;for(let m=0;m=Yo));m++);}for(const g of n.columns){if(o.size>=Yo)break;const b=g-r;if(!(b<0||b>=i))for(let m=0;m=Yo));m++);}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 g of o){const b=Math.floor(g/i),m=g%i,y=e[b],k=((y!==void 0?(p=t.rows[y])==null?void 0:p[m]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),H9.test(k)){const x=Number(k);Number.isFinite(x)&&(u+=1,c+=x,(f===null||xd)&&(d=x))}}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 sk=24,dm=26,ok=110,hm=40,V9=12,zn=1,lk='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',ak='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',U9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function uk(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function ck(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",Hd=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function sd(t){return Hd.format(Object.is(t,-0)?0:t)}function K9(t){const e=[`Cells: ${Hd.format(t.cellCount)}`,`Distinct: ${Hd.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${Hd.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${sd(t.sum)}`,`Avg: ${sd(t.avg)}`,`Min: ${sd(t.min)}`,`Max: ${sd(t.max)}`),e.join(" · ")}function X9(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:ak,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:ak,lineHeight:1}}function G9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function qE({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(""),[g,b]=v.useState(""),[m,y]=v.useState(null),w=v.useRef(m);w.current=m;const k=v.useRef(null),[x,S]=v.useState(null),[T,A]=v.useState(""),M=v.useRef(null),[O,D]=v.useState(void 0),[P,I]=v.useState(()=>new Set),_=v.useRef(P),[te,ie]=v.useState(0),[Z,W]=v.useState({}),V=i!==void 0,R=a??Z,N=v.useCallback(j=>{W(j),u==null||u(j)},[u]),L=v.useMemo(()=>X9(r),[r]),z=G9(r),G=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",B=v.useRef();B.current===void 0&&(B.current=new A9);const me=v.useMemo(()=>{var j;return e===void 0?((j=of(t))==null?void 0:j.cleanedCsv)??t:t},[t,e]),le=v.useMemo(()=>lf(me,e),[me,e]),ve=v.useMemo(()=>N9(le),[le]),Ne=le.headers.length,se=v.useRef({text:me,table:le});se.current={text:me,table:le};const _e=v.useRef(O);_e.current=O,v.useEffect(()=>{const j=window.setTimeout(()=>b(h),150);return()=>window.clearTimeout(j)},[h]);const $e=v.useMemo(()=>{const j=B9(le.rows,g);return m?z9(j,le.rows,m.col,m.dir,ve[m.col]??!1):j},[le,g,m,ve]),Fe=v.useRef($e);Fe.current=$e,v.useEffect(()=>{const j=f.current;if(!j||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>ie(j.clientWidth));return ue.observe(j),ie(j.clientWidth),()=>ue.disconnect()},[]);const qe=Math.max(ok,Math.floor((te-hm)/Math.max(1,Ne)));v.useEffect(()=>{I(j=>{let ue=!1;const q=new Set;for(const ge of j)ge{D(j=>{if(!j||j.rows.length===0)return j;const ue=[];for(const ge of _.current){const ae=$e.indexOf(ge);ae!==-1&&ue.push(ae)}ue.sort((ge,ae)=>ge-ae);const q=ue.reduce((ge,ae)=>ge.add(ae),Nt.empty());return q.equals(j.rows)?j:{...j,rows:q}})},[$e]),v.useEffect(()=>{y(j=>j!==null&&j.col>=Ne?null:j),S(j=>j!==null&&j.col>=Ne?null:j)},[Ne]);const it=g!=="",Wt=le.rows.length,Ie=dm+Math.min($e.length,V9)*sk,be=()=>{p(""),b("")},tt=v.useCallback((j,ue)=>{var ge;if(j0||je.height>0)?{x:Math.max(0,xe.x-je.left),y:Math.max(0,xe.y-je.top),width:xe.width,height:xe.height}:xe??{x:hm+q*qe,y:0,width:qe,height:dm};A(ae),S({col:q,bounds:Pt});return}k.current=w.current,S(null),y(ae=>!ae||ae.col!==q?{col:q,dir:"asc"}:ae.dir==="asc"?{col:q,dir:"desc"}:null)},[V,qe]),nt=v.useCallback(()=>{if(!x)return;const{col:j}=x;if(S(null),!i)return;const{text:ue,table:q}=se.current,ge=q.headers[j]??"",ae=D9(ue,q,j,T);if(ae!==ue){if(ge!==""&&ge!==T&&R[ge]!==void 0){const je={...R},xe=je[ge];delete je[ge],T!==""&&xe!==void 0&&(je[T]=xe),N(je)}i(ae)}},[x,T,i,R,N]),lt=v.useCallback(()=>{S(null)},[]);v.useEffect(()=>{if(!x)return;const j=M.current;j&&(j.focus(),j.select())},[x]);const Ve=v.useCallback((j,ue)=>{const q=Fe.current,ge=q[ue];if(ge===void 0)return;const ae=_.current,je=d.current;let xe;if(j.shiftKey&&je!==null&&je!==ge){const rt=q.indexOf(je),Rt=q.indexOf(ge),Gt=rt===-1?Rt:rt,[qn,Qr]=Gt<=Rt?[Gt,Rt]:[Rt,Gt];xe=j.metaKey||j.ctrlKey?new Set(ae):new Set;for(let On=qn;On<=Qr;On++){const ar=q[On];ar!==void 0&&xe.add(ar)}}else j.metaKey||j.ctrlKey?(xe=new Set(ae),xe.has(ge)?xe.delete(ge):xe.add(ge)):xe=new Set([ge]);d.current=ge,_.current=xe,I(xe);const Pt=[...xe].map(rt=>q.indexOf(rt)).filter(rt=>rt!==-1).sort((rt,Rt)=>rt-Rt);D(rt=>({current:rt==null?void 0:rt.current,columns:(rt==null?void 0:rt.columns)??Nt.empty(),rows:Pt.reduce((Rt,Gt)=>Rt.add(Gt),Nt.empty())}))},[]),kt=v.useCallback(()=>{d.current=null,_.current=new Set,I(new Set),D(void 0)},[]),wt=v.useCallback(j=>{const ue=new Set;for(const q of j.rows){const ge=Fe.current[q];ge!==void 0&&ue.add(ge)}_.current=ue,I(ue),D(j)},[]),bt=v.useCallback(()=>{kt()},[kt]),fe=v.useMemo(()=>$e.filter(j=>P.has(j)),[$e,P]),Le=v.useMemo(()=>[...(O==null?void 0:O.columns)??[]].filter(j=>j>=zn).map(j=>j-zn),[O]),Ye=Le.length,Be=v.useMemo(()=>Le.map(j=>le.headers[j]).filter(j=>j!==void 0),[Le,le.headers]),Xt=v.useMemo(()=>{if(Be.length===0)return null;const j=R[Be[0]]??"auto";for(let ue=1;ue{if(!V||Be.length===0)return;const ue={...R};for(const q of Be)j==="auto"?delete ue[q]:ue[q]=j;N(ue)},[V,Be,R,N]),at=v.useMemo(()=>V?le.headers.filter(j=>uk(R[j])!==null).length:0,[V,le.headers,R]),ht=v.useMemo(()=>({ranges:O!=null&&O.current?[O.current.range,...O.current.rangeStack]:[],columns:O?[...O.columns]:[],rows:P.size>0?$e.reduce((j,ue,q)=>(P.has(ue)&&j.push(q),j),[]):O?[...O.rows]:[]}),[O,P,$e]),Vt=zn,St=v.useMemo(()=>W9(le,$e,ht,Vt),[le,$e,ht,Vt]),_n=fe.length>0||Ye>0||St!==null,cn=v.useRef(l);cn.current=l;const Ut=()=>{var q,ge;const j=_e.current,ue=ik(se.current.table,Fe.current,{ranges:j!=null&&j.current?[j.current.range,...j.current.rangeStack]:[],columns:j?[...j.columns]:[],rows:j?[...j.rows]:[]},zn);ue!==null&&((q=cn.current)==null||q.call(cn),(ge=navigator.clipboard)==null||ge.writeText(ue).catch(()=>{}))};v.useEffect(()=>{const j=ue=>{var xe,Pt;const q=c.current;if(!q||!q.contains(document.activeElement))return;const ge=document.activeElement;if(ge&&(ge.tagName==="INPUT"||ge.tagName==="TEXTAREA"||ge.isContentEditable))return;const ae=_e.current,je=ik(se.current.table,Fe.current,{ranges:ae!=null&&ae.current?[ae.current.range,...ae.current.rangeStack]:[],columns:ae?[...ae.columns]:[],rows:ae?[...ae.rows]:[]},zn);je!==null&&(ue.preventDefault(),ue.stopImmediatePropagation(),(xe=ue.clipboardData)==null||xe.setData("text/plain",je),(Pt=cn.current)==null||Pt.call(cn))};return window.addEventListener("copy",j,{capture:!0}),()=>window.removeEventListener("copy",j,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const j=ue=>{const q=c.current;if(!q)return;const ge=ue.target instanceof Node&&q.contains(ue.target),ae=document.activeElement instanceof Node&&q.contains(document.activeElement);if(!ge&&!ae||ck(ue.target)||ck(document.activeElement))return;const je=F9(ue);je==="undo"&&s?(ue.preventDefault(),s()):je==="redo"&&o&&(ue.preventDefault(),o())};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[s,o]);const on=v.useCallback(j=>{var q;const ue=c.current!==null&&document.activeElement instanceof Node&&c.current.contains(document.activeElement);kt(),i==null||i(j),ue&&((q=f.current)==null||q.focus({preventScroll:!0}))},[kt,i]),bn=Ne>0&&Le.length>=Ne,Pr=()=>{!V||fe.length===0||on(fm(se.current.text,se.current.table,fe))},Ir=()=>{!V||bn||Le.length===0||on(tk(se.current.text,se.current.table,Le))},Bt=v.useCallback(j=>{if(!i)return!1;const{text:q,table:ge}=se.current,ae=Fe.current;if(j.rows.length>0){const Pt=[...j.rows].map(rt=>ae[rt]).filter(rt=>rt!==void 0);if(Pt.length>0)return on(fm(q,ge,Pt)),!1}if(j.columns.length>0){const Pt=[...j.columns].filter(rt=>rt>=zn&&rtrt-zn);return Pt.length>0&&Pt.length0&&on(fm(q,ge,xe)),!1},[on,i]),ct=v.useCallback(j=>{const ue=i;if(!ue)return!1;const{text:q,table:ge}=se.current,ae=Fe.current,je=[...j].sort((rt,Rt)=>rt.location[1]-Rt.location[1]);let xe=q,Pt=0;for(const{location:rt,value:Rt}of je){const Gt=rt[0]-zn,qn=rt[1];if(Gt<0||Rt.kind!==Ce.Text)continue;const Qr=ae[qn],On=Qr===void 0?void 0:ge.rowSpans[Qr];if(!On)continue;const ar=xe.slice(On.start+Pt,On.end+Pt),Zr=dw(ar,ge.delimiter);for(;Zr.length<=Gt;)Zr.push("");const ws=Rt.data??"";if(Zr[Gt]===ws)continue;Zr[Gt]=ws;const bs=_p(Zr,ge.delimiter);xe=xe.slice(0,On.start+Pt)+bs+xe.slice(On.end+Pt),Pt+=bs.length-(On.end-On.start)}return xe!==q&&ue(xe),!0},[i]),ft=v.useCallback(j=>{var je;const[ue,q]=j,ge=Fe.current[q];if(ue{const ue=[];for(let q=j.y;q{j[0]>=zn||Ve(ue,j[1])},[Ve]),De=v.useMemo(()=>{const j={title:"#",id:"__gutter",width:hm,themeOverride:{baseFontStyle:`11px ${lk}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ue=le.headers.map((q,ge)=>{const ae=V?uk(R[q]):null;return{title:ae?`${q.toUpperCase()} [${ae}]`:q.toUpperCase(),id:`c${ge}`,width:qe,themeOverride:ve[ge]?{baseFontStyle:`12px ${lk}`}:void 0}});return[j,...ue]},[le.headers,ve,qe,V,R]),ze=v.useCallback((j,ue)=>{const{ctx:q,columnIndex:ge,rect:ae,theme:je,isSelected:xe}=j;q.save();try{if(q.letterSpacing="0.5px",xe&&(q.fillStyle=je.bgHeaderHovered,q.fillRect(ae.x,ae.y,ae.width,ae.height),q.fillStyle=je.accentColor,q.fillRect(ae.x,ae.y+ae.height-2,ae.width,2)),ge{const{ctx:q,cell:ge,rect:ae,col:je,theme:xe}=j,Pt=je-zn;if(Pt>=0&&it&&ge.kind===Ce.Text){const rt=q9(ge.data,g);if(rt!==null){q.save();try{const Rt=`${xe.baseFontStyle} ${xe.fontFamily}`;q.font=Rt;let Gt=ae.x+xe.cellHorizontalPadding;const qn=ae.y+ae.height/2+Hs(q,Rt);for(const Qr of rt){const On=q.measureText(Qr.text).width;Qr.hit&&On>0&&(q.fillStyle=z,q.fillRect(Gt-1,qn-7,On+2,14)),Gt+=On}}finally{q.restore()}}}if(ue(),Pt>=0&&ge.kind===Ce.Text&&ge.data===""){q.save();try{q.font=`${xe.baseFontStyle} ${xe.fontFamily}`,q.fillStyle=xe.textLight,q.fillText("—",ae.x+xe.cellHorizontalPadding,ae.y+ae.height/2+.5)}finally{q.restore()}}},[it,g,z]),pt=v.useCallback(j=>{const ue=Fe.current[j];return ue!==void 0&&_.current.has(ue)?{bgCell:G,bgCellMedium:G}:void 0},[G]);return Ne===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(yN,{"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:j=>p(j.target.value),onKeyDown:j=>{j.key==="Escape"&&be()},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:be,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(xh,{"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:it?`${$e.length.toLocaleString()} of ${Wt.toLocaleString()}`:`${Wt.toLocaleString()} rows`}),V&&at>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:[`${at} ${at===1?"column type":"column types"} pinned`,E.jsx(xh,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),_n&&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:fe.length>0?`${fe.length.toLocaleString()} selected`:Ye>0?`${Ye.toLocaleString()} ${Ye===1?"column":"columns"} selected`:`${((St==null?void 0:St.cellCount)??0).toLocaleString()} cells selected`}),St!==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:K9(St)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Ut,className:Xl,children:[E.jsx(Bv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),V&&fe.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:Pr,title:`Deletes the ${fe.length} selected ${fe.length===1?"row":"rows"} from the source CSV`,className:Xl,children:[E.jsx(bh,{"aria-hidden":"true",className:"size-3"}),"Delete ",fe.length.toLocaleString()," ",fe.length===1?"row":"rows"]}),V&&Ye>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:U9.map(({mode:j,label:ue})=>{const q=Xt===j;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${j}`,"aria-pressed":q,onClick:()=>dt(j),className:q?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:ue},j)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:Ir,disabled:bn,title:bn?"At least one column must remain — the converter needs a column to detect":`Deletes the ${Ye} selected ${Ye===1?"column":"columns"} from the source CSV`,className:`${Xl} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(bh,{"aria-hidden":"true",className:"size-3"}),"Delete ",Ye.toLocaleString()," ",Ye===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:kt,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:Ie},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(F6,{imageWindowLoader:B.current,renderers:b9,columns:De,rows:$e.length,getCellContent:ft,getCellsForSelection:pn,onCellsEdited:V?ct:void 0,onDelete:V?Bt:void 0,onCellClicked:ne,onHeaderClicked:tt,onGridSelectionChange:wt,onSelectionCleared:bt,gridSelection:O,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:sk,headerHeight:dm,freezeColumns:zn,fillHandle:V,onPaste:V?()=>!0:!1,keybindings:{search:!1},theme:L,drawHeader:ze,drawCell:Rn,getRowThemeOverride:pt,minColumnWidth:ok,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),x!==null&&E.jsx("input",{ref:M,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${le.headers[x.col]??""}`,value:T,onChange:j=>A(j.target.value),onBlur:nt,onKeyDown:j=>{j.key==="Enter"?(j.preventDefault(),j.stopPropagation(),nt()):j.key==="Escape"&&(j.preventDefault(),j.stopPropagation(),lt())},style:{left:x.bounds.x,top:x.bounds.y,width:Math.max(60,x.bounds.width),height:x.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"}),it&&$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 “",g,"”."]}),E.jsx("button",{type:"button",onClick:be,className:Xl,children:"Show all rows"})]}),V&&!it&&$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 q9(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(rN,{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=Z9(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(kT,{"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(wN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let J0=[],YE=[];(()=>{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=YE[r])e=r+1;else return!0;if(e==n)return!1}}function fk(t){return t>=127462&&t<=127487}const dk=8205;function nV(t,e,n=!0,r=!0){return(n?JE:rV)(t,e,r)}function JE(t,e,n){if(e==t.length)return e;e&&QE(t.charCodeAt(e))&&ZE(t.charCodeAt(e-1))&&e--;let r=pm(t,e);for(e+=hk(r);e=0&&fk(pm(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function rV(t,e,n){for(;e>1;){let r=JE(t,e-2,n);if(r=56320&&t<57344}function ZE(t){return t>=55296&&t<56320}function hk(t){return t<65536?1:2}class _t{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]=$a(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),rs.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]=$a(this,e,n);let r=[];return this.decompose(e,n,r,0),rs.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 ac(this),s=new ac(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 ac(this,e)}iterRange(e,n=this.length){return new eA(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 tA(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]?_t.empty:e.length<=32?new Tn(e):rs.from(Tn.split(e,[]))}}class Tn extends _t{constructor(e,n=iV(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 sV(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Tn(pk(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Wd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Tn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Tn(l.slice(0,a)),new Tn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Tn))return super.replace(e,n,r);[e,n]=$a(this,e,n);let i=Wd(this.text,Wd(r.text,pk(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Tn(i,s):rs.from(Tn.split(i,[]),s)}sliceString(e,n=this.length,r=` +`){[e,n]=$a(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 Tn(r,i)),r=[],i=-1);return i>-1&&n.push(new Tn(r,i)),n}}class rs extends _t{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]=$a(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 rs(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]=$a(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 rs))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 Tn(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 rs)for(let g of h.children)f(g);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Tn&&a&&(p=c[c.length-1])instanceof Tn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Tn(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]:rs.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new rs(l,n)}}_t.empty=new Tn([""],0);function iV(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Wd(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 Tn?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 Tn?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 Tn){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 Tn?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 eA{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ac(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 tA{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"&&(_t.prototype[Symbol.iterator]=function(){return this.iter()},ac.prototype[Symbol.iterator]=eA.prototype[Symbol.iterator]=tA.prototype[Symbol.iterator]=function(){return this});class sV{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 $a(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 nV(t,e,n,r)}function oV(t){return t>=56320&&t<57344}function lV(t){return t>=55296&&t<56320}function aV(t,e){let n=t.charCodeAt(e);if(!lV(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return oV(r)?(n-55296<<10)+(r-56320)+65536:n}function uV(t){return t<65536?1:2}const Q0=/\r\n?|\n/;var Sr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Sr||(Sr={}));class ps{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=Sr.Simple&&u>=e&&(r==Sr.TrackDel&&ie||r==Sr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ps(e)}static create(e){return new ps(e)}}class Ln extends ps{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 Z0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return ey(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&&mo(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"?_t.of(h.split(r||Q0)):h:_t.empty,g=p.length;if(f==d&&g==0)return;fo&&rr(i,f-o,-1),rr(i,d-f,g),mo(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new Ln(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 mo(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 ey(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Dc(t),l=new Dc(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 Dc{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?_t.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?_t.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 co{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 co(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 co(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=>co.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 rA(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let hw=0;class We{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=hw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new We(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:pw),!!e.static,e.enables)}of(e){return new Vd([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Vd(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Vd(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function pw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Vd{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=hw++}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)||ty(f,c)){let h=r(f);if(l?!gk(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 g=$h(d,p);if(this.dependencies.every(b=>b instanceof We?d.facet(b)===f.facet(b):b instanceof vs?d.field(b,!1)==f.field(b,!1):!0)||(l?gk(h=r(f),g,i):i(h=r(f),g)))return f.values[o]=g,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function gk(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(od).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(od),o=i.facet(od),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,od.of({field:this,create:e})]}get extension(){return this}}const il={lowest:4,low:3,default:2,high:1,highest:0};function Iu(t){return e=>new iA(e,t)}const gw={highest:Iu(il.highest),high:Iu(il.high),default:Iu(il.default),low:Iu(il.low),lowest:Iu(il.lowest)};class iA{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class hl{of(e){return new ny(this,e)}reconfigure(e){return hl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class ny{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Lh{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 fV(e,n,o))d instanceof vs?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,g=c&&c[d]||[];if(h.every(b=>b.type==0))if(l[p.id]=a.length<<1|1,pw(g,h))a.push(r.facet(p));else{let b=p.combine(h.map(m=>m.value));a.push(r&&p.compare(b,r.facet(p))?r.facet(p):b)}else{for(let b of h)b.type==0?(l[b.id]=a.length<<1|1,a.push(b.value)):(l[b.id]=u.length<<1,u.push(m=>b.dynamicSlot(m)));l[p.id]=u.length<<1,u.push(b=>cV(b,p,h))}}let f=u.map(d=>d(l));return new Lh(e,o,f,l,a,s)}}function fV(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 ny&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof ny){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 iA)s(o.inner,o.prec);else if(o instanceof vs)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof Vd)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,il.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,il.default),r.reduce((o,l)=>o.concat(l))}function uc(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 $h(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const sA=We.define(),ry=We.define({combine:t=>t.some(e=>e),static:!0}),oA=We.define({combine:t=>t.length?t[0]:void 0,static:!0}),lA=We.define(),aA=We.define(),uA=We.define(),cA=We.define({combine:t=>t.length?t[0]:!1});class Fo{constructor(e,n){this.type=e,this.value=n}static define(){return new dV}}class dV{of(e){return new Fo(this,e)}}class hV{constructor(e){this.map=e}of(e){return new Yt(this,e)}}class Yt{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 Yt(this.type,n)}is(e){return this.type==e}static define(e={}){return new hV(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}}Yt.reconfigure=Yt.define();Yt.appendConfig=Yt.define();class Bn{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&&rA(r,n.newLength),s.some(l=>l.type==Bn.time)||(this.annotations=s.concat(Bn.time.of(Date.now())))}static create(e,n,r,i,s,o){return new Bn(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(Bn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Bn.time=Fo.define();Bn.userEvent=Fo.define();Bn.addToHistory=Fo.define();Bn.remote=Fo.define();function pV(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 Bn?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof Bn?t=s[0]:t=dA(e,Sa(s),!1)}return t}function mV(t){let e=t.startState,n=e.facet(uA),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=fA(r,iy(e,s,t.changes.newLength),!0))}return r==t?t:Bn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const yV=[];function Sa(t){return t==null?yV:Array.isArray(t)?t:[t]}var Ns=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Ns||(Ns={}));const vV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sy;try{sy=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function wV(t){if(sy)return sy.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||vV.test(n)))return!0}return!1}function bV(t){return e=>{if(!/\S/.test(e))return Ns.Space;if(wV(e))return Ns.Word;for(let n=0;n-1)return Ns.Word;return Ns.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(Yt.reconfigure)?(n=null,r=l.value):l.is(Yt.appendConfig)&&(n=null,r=Sa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Lh.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(ry)?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=Lh.resolve(e.extensions||[],new Map),r=e.doc instanceof _t?e.doc:_t.of((e.doc||"").split(n.staticFacet($t.lineSeparator)||Q0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return rA(i,r.length),n.staticFacet(ry)||(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(cA)}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(sA))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 bV(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))!=Ns.Word)break;o=a}for(;lt.length?t[0]:4});$t.lineSeparator=oA;$t.readOnly=cA;$t.phrases=We.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=sA;$t.changeFilter=lA;$t.transactionFilter=aA;$t.transactionExtender=uA;hl.reconfigure=Yt.define();function hA(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 oy.create(e,n,this)}}xl.prototype.startSide=xl.prototype.endSide=0;xl.prototype.point=!1;xl.prototype.mapMode=Sr.TrackDel;function mw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let oy=class pA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new pA(e,n,r)}};function ly(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class yw{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 yw(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(ly)),this.isEmpty)return n.length?jt.of(n):this;let l=new gA(this,null,-1).goto(0),a=0,u=[],c=new Fa;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 Lc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Lc.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=mk(o,l,r),u=new Nu(o,a,s),c=new Nu(l,a,s);r.iterGaps((f,d,h)=>yk(u,f,c,d,h,i)),r.empty&&r.length==0&&yk(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=mk(s,o),a=new Nu(s,l,0).goto(r),u=new Nu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ay(a.active,u.active)||a.point&&(!u.point||!mw(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 Nu(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 Fa;for(let i of e instanceof oy?[e]:n?xV(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 xV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ly);e=r}return t}jt.empty.nextLayer=jt.empty;class Fa{finishChunk(e){this.chunks.push(new yw(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 Fa)).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 mk(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 gA(o,n,r,s));return i.length==1?i[0]:new Lc(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--)gm(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--)gm(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(),gm(this.heap,0)}}}function gm(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 Nu{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=Lc.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){ld(this.active,e),ld(this.activeTo,e),ld(this.activeRank,e),this.minActive=vk(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;ad(this.active,n,r),ad(this.activeTo,n,i),ad(this.activeRank,n,s),e&&ad(e,n,this.cursor.from),this.minActive=vk(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&&ld(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 yk(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&&mw(t.point,n.point)&&ay(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ay(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 ay(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 vk(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 uy="ͼ",wk=typeof Symbol>"u"?"__"+uy:Symbol.for(uy),cy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),bk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Oo{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(g=>o.map(b=>g.replace(/&/,b))).reduce((g,b)=>g.concat(b)),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,g=>"-"+g.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=bk[wk]||1;return bk[wk]=e+1,uy+e.toString(36)}static mount(e,n,r){let i=e[cy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new SV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let xk=new Map;class SV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=xk.get(r);if(s)return e[cy]=s;this.sheet=new i.CSSStyleSheet,xk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[cy]=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:'"'},CV=typeof navigator<"u"&&/Mac/.test(navigator.platform),TV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Kn=0;Kn<10;Kn++)Po[48+Kn]=Po[96+Kn]=String(Kn);for(var Kn=1;Kn<=24;Kn++)Po[Kn+111]="F"+Kn;for(var Kn=65;Kn<=90;Kn++)Po[Kn]=String.fromCharCode(Kn+32),$c[Kn]=String.fromCharCode(Kn);for(var mm in Po)$c.hasOwnProperty(mm)||($c[mm]=Po[mm]);function EV(t){var e=CV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||TV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?$c:Po)[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 is(){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:Ck||/Mac/.test(hr.platform),windows:/Win/.test(hr.platform),linux:/Linux|X11/.test(hr.platform),ie:Lp,ie_version:yA?fy.documentMode||6:hy?+hy[1]:dy?+dy[1]:0,gecko:kk,gecko_version:kk?+(/Firefox\/(\d+)/.exec(hr.userAgent)||[0,0])[1]:0,chrome:!!ym,chrome_version:ym?+ym[1]:0,ios:Ck,android:/Android\b/.test(hr.userAgent),webkit:Sk,webkit_version:Sk?+(/\bAppleWebKit\/(\d+)/.exec(hr.userAgent)||[0,0])[1]:0,safari:py,safari_version:py?+(/\bVersion\/(\d+(\.\d+)?)/.exec(hr.userAgent)||[0,0])[1]:0,tabSize:fy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function vw(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 Fh=Object.create(null);function ww(t,e,n){if(t==e)return!0;t||(t=Fh),e||(e=Fh);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 AV(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 Tk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function MV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new kl(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}=vA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new kl(e,r,i,n,e.widget||null,!0)}static line(e){return new uf(e)}static set(e,n=!1){return jt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Kt.none=jt.empty;class af extends Kt{constructor(e){let{start:n,end:r}=vA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?vw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Fh}eq(e){return this==e||e instanceof af&&this.tagName==e.tagName&&ww(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)}}af.prototype.point=!1;class uf extends Kt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof uf&&this.spec.class==e.spec.class&&ww(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)}}uf.prototype.mapMode=Sr.TrackBefore;uf.prototype.point=!0;class kl extends Kt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Sr.TrackBefore:Sr.TrackAfter:Sr.TrackDel}get type(){return this.startSide!=this.endSide?hi.WidgetRange:this.startSide<=0?hi.WidgetBefore:hi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof kl&&RV(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)}}kl.prototype.point=!0;function vA(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 RV(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 Fc extends xl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Fc&&this.tagName==e.tagName&&ww(this.attributes,e.attributes)}static create(e){return new Fc(e.tagName,e.attributes||Fh,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return jt.of(e,n)}}Fc.prototype.startSide=Fc.prototype.endSide=-1;function Bc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function gy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function cc(t,e){if(!e.anchorNode)return!1;try{return gy(t,e.anchorNode)}catch{return!1}}function fc(t){return t.nodeType==3?jc(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function dc(t,e,n,r){return n?Ek(t,e,n,r,-1)||Ek(t,e,n,r,1):!1}function Io(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Bh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function Ek(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:zs(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Io(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?zs(t):0}else return!1}}function zs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function zc(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 OV(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 wA(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 PV(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,g=1;if(h)d=OV(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:g}=wA(c,y)),d={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*g}}let b=0,m=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+m&&(m=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(m=e.bottom-d.bottom+o,n<0&&e.top-m0&&e.right>d.right+b&&(b=e.right-d.right+s)):e.right>d.right-s&&(b=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 bA(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 IV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?zs(n):0),r,Math.min(e.focusOffset,r?zs(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function xA(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 kA(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 tl=null;Ae.safari&&Ae.safari_version>=26&&(tl=!1);function SA(t){if(t.setActive)return t.setActive();if(tl)return t.focus(tl);let e=xA(t);t.focus(tl==null?{get preventScroll(){return tl={preventScroll:!0},!0}}:void 0),tl||(tl=!1,kA(e))}let Ak;function jc(t,e,n=e){let r=Ak||(Ak=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 NV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function _V(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,zs(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=zs(n))}else{if(n==t)return!0;r=Io(n),n=n.parentNode}}function CA(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 TA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=zs(n)}else if(n.parentNode&&!Bh(n))r=Io(n),n=n.parentNode;else return null}}function EA(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 RA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;g-=3)if(Ji[g+1]==-h){let b=Ji[g+2],m=b&2?i:b&4?b&1?s:i:0;m&&(qt[f]=qt[Ji[g]]=m),l=g;break}}else{if(Ji.length==189)break;Ji[l++]=f,Ji[l++]=d,Ji[l++]=a}else if((p=qt[f])==2||p==1){let g=p==i;a=g?0:1;for(let b=l-3;b>=0;b-=3){let m=Ji[b+2];if(m&2)break;if(g)Ji[b+2]|=2;else{if(m&4)break;Ji[b+2]|=4}}}}}function zV(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==b&&(p=n[--g].from,b=g?n[g-1].to:t),qt[--p]=h;a=c}else s=u,a++}}}function yy(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 as(a,g.from,h));let b=g.direction==Sl!=!(h%2);vy(t,b?r+1:r,i,g.inner,g.from,g.to,o),a=g.to}p=g.to}else{if(p==n||(c?qt[p]!=l:qt[p]==l))break;p++}d?yy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let g=qt[a-1];g!=l&&(c=!1,f=g==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 g=s[--u];if(!c)for(let b=g.from,m=u;;){if(b==e)break e;if(m&&s[m-1].to==b)b=s[--m].from;else{if(qt[b-1]==l)break e;break}}if(d)d.push(g);else{g.toqt.length;)qt[qt.length]=256;let r=[],i=e==Sl?0:1;return vy(t,i,i,n,0,t.length,r),r}function OA(t){return[new as(0,t,0)]}let PA="";function HV(t,e,n,r,i){var s;let o=r.head-t.from,l=as.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),PA=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)}),VV=We.define({combine:t=>t.some(e=>e)}),BA=We.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 ud=Yt.define({map:(t,e)=>t.map(e)}),zA=Yt.define();function ui(t,e,n){let r=t.facet(DA);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 Os=We.define({combine:t=>t.length?t[0]:!0});let UV=0;const ha=We.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push($p.of(u=>{let c=u.plugin(l);return c?o(c):Kt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return yi.define((r,i)=>new e(r,i),n)}}class vm{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(ui(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){ui(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){ui(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jA=We.define(),Sw=We.define(),$p=We.define(),HA=We.define(),Cw=We.define(),cf=We.define(),WA=We.define();function Mk(t,e){let n=t.state.facet(WA);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=WV(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 g={from:u,to:c,direction:h,inner:[]};f.push(g),f=g.inner}}}}),i}const VA=We.define();function Tw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(VA)){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 Vu=We.define();class ci{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ci(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 ci(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new zh(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 KV=[];class wn{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 KV}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&&AV(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=Io(this.dom),i=this.length?e>0:n>0;return new Di(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 Bp)return e;return null}static get(e){return e.cmTile}}class Fp extends wn{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=Rk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=Rk(i);this.length=o}}function Rk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Bp extends Fp{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=wn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ds)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ds extends Fp{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ds(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class Ba extends Fp{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new Ba(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&&GV(o,p)))&&(g>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=g}}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):XV(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 Di(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 Di(a.dom,0);a==r.tile&&(l=!0)}}return new Di(this.dom,0)}}function XV(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=fc(e);return n[n.length-1]||null}function GV(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:zc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new ul(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Cl extends wn{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 zc(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 qV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Cr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(wm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=wn.get(a.dom);f&&f.setDOM(wm(a.dom))}let c=Cr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=wn.get(e.text);s&&this.cache.reused.set(s,2);let o=new ul(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=UA);let i=Ba.start(e,n||((r=this.cache.find(Ba))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Cr&&l.mark.eq(o))i=l,n--;else{let a=Cr.of(o,(r=this.cache.find(Cr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Ok(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Ae.ios&&Ok(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(bm,0,32)||new Cl(bm.toDOM(),0,bm,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 YV(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(jh,void 0,1);return r&&(r.flags=n),r||new jh(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class QV{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 Hh=[Cl,Ba,ul,Cr,jh,Ds,Bp];for(let t=0;t[]),this.index=Hh.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Cr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Cr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=jt.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof kl){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?za.block:za.inline),p=tU(u),g=this.cache.findWidget(h,a-l,p)||Cl.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(g)):(i.ensureLine(r),i.addInlineWidget(g,c,f))}r=null}else r=nU(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=wn.get(i);if(i==this.view.contentDOM)break;s instanceof Cr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ds||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new Ba(i,UA):r||n.push(Cr.of(new af({tagName:i.nodeName.toLowerCase(),attributes:MV(i)}),i)))}return{line:r,marks:n}}}function Ok(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 tU(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 UA={class:"cm-line"};function nU(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&vw(n,t),r&&(t.class+=" "+r)),t}function rU(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Cr&&e.push(r.mark)}return e}function wm(t){let e=wn.get(t);return e&&e.setDOM(t.cloneNode()),t}class za 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}}za.inline=new za("span");za.block=new za("div");const bm=new class extends nu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Pk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Kt.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 Bp(e,e.contentDOM),this.updateInner([new ci(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:!dU(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?sU(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ci(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=aU(o,this.decorations,e.changes);a.length&&(r=ci.extendWithRanges(r,a));let u=cU(l,this.blockWrappers,e.changes);return u.length&&(r=ci.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 eU(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&wn.get(n.text)&&l.cache.reused.set(wn.get(n.text),2),this.tile=l.run(e,n),by(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)&&cc(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&&iU(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Di(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!dc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!dc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Ae.android&&Ae.chrome&&r.contains(f.focusNode)&&fU(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Bc(this.view.root);if(d)if(a.empty){if(Ae.gecko){let h=oU(u.node,u.offset);if(h&&h!=3){let p=(h==1?TA:EA)(u.node,u.offset);p&&(u=new Di(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 Di(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Di(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&dc(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=Bc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=zs(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!wn.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 xm?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==vn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let g=f.children[p],b=d+g.length,m=g.dom.getBoundingClientRect(),{height:y}=m;if(h&&!p&&(u+=m.top-h.top),g instanceof Ds)b>r&&c(g,d,m);else if(d>=r&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let w=g.dom.lastChild,k=w?fc(w):[];if(k.length){let x=k[k.length-1],S=a?x.right-m.left:m.right-x.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=b)}}h&&p==f.children.length-1&&(u+=h.bottom-m.bottom),d=b+g.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?vn.RTL:vn.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=fc(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=fc(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(Kt.replace({widget:new xm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Kt.set(e)}updateDeco(){let e=1,n=this.view.state.facet($p).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(Cw).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(BA))try{if(u(this.view,e.range,e))return!0}catch(c){ui(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=Tw(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(PV(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(){by(this.tile)}}function by(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)by(r,e)}}function iU(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 KA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=TA(n.focusNode,n.focusOffset),i=EA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=wn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=wn.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 sU(t,e,n){let r=KA(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 ci(a.mapPos(s),a.mapPos(o),s,o),text:i}}function oU(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class xm 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 hU(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+kV(o,s,t.state.tabSize)}function gU(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==hi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function mU(t,e,n,r){let i=gU(t,e.head,e.assoc||-1),s=!r||i.type!=hi.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==vn.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 Ik(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=HV(i,s,o,l,n),c=PA;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 yU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Ns.Space&&(i=o),i==o}}function vU(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 g=l+(h+p)*s,b=xy(t,{x:f,y:g},!1,s);if(n?g>a.bottom:gl: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 ss(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==hi.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==hi.Text){let f=pU(t,i,u,o,l);return new ss(f,f==u.from?1:-1)}}if(u.type!=hi.Text)return a<(u.top+u.bottom)/2?new ss(u.from,1):new ss(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 wU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class wU{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(g)){for(let y=1;y=s&&(w-=p),!o.has(w)){g=w;break t}}break e}o.add(g);let b=n(g),m=0;if(b)for(let y=0;y1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),m=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+g)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+g+g)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==vn.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 jc(e.dom,o,l).getClientRects()});return i.after?new ss(r[i.i+1],-1):new ss(r[i.i],1)}scanTile(e,n){if(!e.length)return new ss(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:jc(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 ss(r[i.i+1],-1):new ss(o,1)}}const Jl="￿";class bU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Jl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=wn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=wn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Bh(i))||Bh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!kU(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=wn.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+(xU(e,r.node,r.offset)?n:0))}}function xU(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=GA(e.docView.tile,n,r,0))){let a=s||o?[]:TU(e),u=new bU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=EU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!gy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!gy(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(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 GA(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 GA(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 qA(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:_t.of(e.text.slice(s.from-l,d).split(Jl))}:(h=YA(f,e.text,u-l,c))&&(Ae.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Jl+Jl&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:_t.of(e.text.slice(h.from,h.toB).split(Jl))})}else r&&(!t.hasFocus&&i.facet(Os)||Wh(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=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:_t.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=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:_t.of([" "])}),n)return Ew(t,n,r,o);if(r&&!Wh(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=XA(i.facet(cf).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function Ew(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&&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=CU(t,e,n));return t.state.facet(LA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function CU(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&&KA(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 g=p.to-h,b=g-c.length;if(t.state.sliceDoc(b,g)!=c||g>=f.from&&b<=f.to)return{range:p};let m=i.changes({from:b,to:g,insert:e.insert}),y=p.to-s.to;return{changes:m,range:u?he.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(m)}})}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 YA(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 TU(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 Nk(n,r)),(i!=n||s!=r)&&e.push(new Nk(i,s))),e}function EU(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 Wh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class AU{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&&WU(e.contentDOM.ownerDocument)}handleEvent(e){!LU(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=RU(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&&QA.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&&(JA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||OU.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)&&MU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0: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 MU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function _k(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){ui(n.state,i)}}}function RU(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(_k(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(_k(r.value,a))}}for(let r in Hi)n(r).handlers.push(Hi[r]);for(let r in yr)n(r).observers.push(yr[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"}],OU="dthko",QA=[16,17,18,20,91,92,224,225],cd=6;function fd(t){return Math.max(0,t)*.7+8}function PU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class IU{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=bA(e.contentDOM),this.atoms=e.state.facet(cf).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)&&NU(e,n),this.dragging=DU(e,n)&&tM(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&&PU(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=Tw(this.view);e.clientX-a.left<=i+cd?n=-fd(i-e.clientX):e.clientX+a.right>=o-cd&&(n=fd(e.clientX-o)),e.clientY-a.top<=s+cd?r=-fd(s-e.clientY):e.clientY+a.bottom>=l-cd&&(r=fd(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=XA(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 NU(t,e){let n=t.state.facet(IA);return n.length?n[0](e):Ae.mac?e.metaKey:e.ctrlKey}function _U(t,e){let n=t.state.facet(NA);return n.length?n[0](e):Ae.mac?!e.altKey:!e.ctrlKey}function DU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Bc(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 LU(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=wn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Hi=Object.create(null),yr=Object.create(null),ZA=Ae.ie&&Ae.ie_version<15||Ae.ios&&Ae.webkit_version<604;function $U(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(),eM(t,n.value)},50)}function zp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function eM(t,e){e=zp(t.state,xw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(ky!=null&&n.selection.ranges.every(a=>a.empty)&&ky==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})}yr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Ae.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};yr.wheel=yr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Hi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);yr.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")};yr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};yr.touchend=(t,e)=>{t.inputState.touchActive=!1};Hi.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(_A))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=BU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new IU(t,e,n,r)),r&&t.observer.ignore(()=>{SA(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 Dk(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return hU(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?($k+1)%3:1}function BU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=tM(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=Dk(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Dk(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=zU(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function zU(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}Hi.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",zp(t.state,kw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Hi.dragend=t=>(t.inputState.draggedContent=null,!1);function Bk(t,e,n,r){if(n=zp(t.state,xw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&_U(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}Hi.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&&Bk(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 Bk(t,e,r,!0),!0}return!1};Hi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=ZA?null:e.clipboardData;return n?(eM(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):($U(t),!1)};function jU(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 HU(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:zp(t,kw,e.join(t.lineBreak)),ranges:n,linewise:r}}let ky=null;Hi.copy=Hi.cut=(t,e)=>{if(!cc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=HU(t.state);if(!n&&!i)return!1;ky=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=ZA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(jU(t,n),!1)};const nM=Fo.define();function rM(t,e){let n=[];for(let r of t.facet($A)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:nM.of(!0)}):null}function iM(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=rM(t.state,e);n?t.dispatch(n):t.update([])}},10)}yr.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),iM(t)};yr.blur=t=>{t.observer.clearSelectionRange(),iM(t)};yr.compositionstart=yr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};yr.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))};yr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Hi.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 Ew(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Ae.chrome&&Ae.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 Ae.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Ae.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>yr.compositionend(t,e),20),!1};const zk=new Set;function WU(t){zk.has(t)||(zk.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const jk=["pre-wrap","normal","pre-line","break-spaces"];let ja=!1;function Hk(){ja=!1}class VU{constructor(e){this.lineWrapping=e,this.doc=_t.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 jk.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)>Ud&&(ja=!0),this.height=e)}replace(e,n,r){return mr.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,Zt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,Zt.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,Zt.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 sM{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 _i(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):mr.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 mr{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 mr.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)>=Ud&&(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=mr.of(o);return(a<0||Math.abs(u.height-this.height)>=Ud||Math.abs(a-this.heightMetrics(e,n).perLine)>=Ud)&&(ja=!0),Vh(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 XU extends mr{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==Zt.ByPosNoHeight?Zt.ByPosNoHeight:Zt.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,Zt.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&&Wk(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?mr.of(this.break?[e,null,n]:[e,n]):(this.left=Vh(this.left,e),this.right=Vh(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 Wk(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 GU=5;class Aw{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=GU)&&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 QU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function ZU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class Sm{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 VU(r),this.stateDeco=Kk(n),this.heightMap=mr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle.setDoc(n.doc),[new ci(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=Kt.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 dd(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?Uk:new Mw(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(Uu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=Kk(this.state);let i=e.changedRanges,s=ci.extendWithRanges(i,qU(r,this.stateDeco,e?e.changes:Ln.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Hk(),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(VV)&&(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"?vn.RTL:vn.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:x,scaleY:S}=wA(n,l);(x>.005&&Math.abs(this.scaleX-x)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=x,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=bA(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=CA(this.scrollParent||e.win);let g=(this.printing?ZU:JU)(n,this.paddingTop),b=g.top-this.pixelViewport.top,m=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;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&&!QU(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 x=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(x)&&(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),x),o&&(e.docView.minWidth=0,u|=16)}b>0&&m>0?c=Math.max(b,m):b<0&&m<0&&(c=Math.min(b,m)),Hk();for(let S of this.viewports){let T=S.from==this.viewport.from?x:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?mr.empty().applyChanges(this.stateDeco,_t.empty,this.heightOracle,[new ci(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new UU(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 dd(i.lineAt(o-r*1e3,Zt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Zt.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,Zt.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!=vn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&mm.from>=d.from&&m.to<=d.to&&Math.abs(m.from-c)m.fromy));if(!b){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(he.cursor(f),!1,!0).head;w>c&&(f=w)}let m=this.gapSize(d,c,f,h),y=r||m<2e6?m:2e6;b=new Sm(c,f,m,y)}l.push(b)},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=[];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)||Uu(this.heightMap.lineAt(e,Zt.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)||Uu(this.heightMap.lineAt(this.scaler.fromDOM(e),Zt.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 Uu(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 dd{constructor(e,n){this.from=e,this.to=n}}function t7(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 pd(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 n7(t,e){for(let n of t)if(e(n))return n}const Uk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function Kk(t){let e=t.facet($p).filter(r=>typeof r!="function"),n=t.facet(Cw).filter(r=>typeof r!="function");return n.length&&e.push(jt.join(n)),e}class Mw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Zt.ByPos,e,0,0).top,c=n.lineAt(a,Zt.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 Uu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new _i(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Uu(i,e)):t._content)}const gd=We.define({combine:t=>t.join(" ")}),Sy=We.define({combine:t=>t.indexOf(!0)>-1}),Cy=Oo.newName(),oM=Oo.newName(),lM=Oo.newName(),aM={"&light":"."+oM,"&dark":"."+lM};function Ty(t,e,n){return new Oo(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 r7=Ty("."+Cy,{"&":{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"}},aM),i7={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Cm=Ae.ie&&Ae.ie_version<=11;class s7{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new IV,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 l7(e),e.state.facet(Os)&&(e.contentDOM.editContext=this.editContext.editContext)),Cm&&(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(Os)?r.root.activeElement!=this.dom:!cc(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&&dc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Bc(e.root);if(!n)return!1;let r=Ae.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&o7(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=cc(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&&cc(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 SU(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=qA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Wh(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=Xk(n,e.previousSibling||e.target.previousSibling,-1),i=Xk(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(Os)!=e.state.facet(Os)&&(e.view.contentDOM.editContext=e.state.facet(Os)?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 Xk(t,e,n){for(;e;){let r=wn.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 Gk(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 dc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function o7(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Gk(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?Gk(t,n):null}class l7{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=YA(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));Wh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:_t.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:_t.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);Ew(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=Bc(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 Ge{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||NV(e.parent)||document,this.viewState=new Vk(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(ud)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ha).map(i=>new vm(i));for(let i of this.plugins)i.update(this);this.observer=new s7(this),this.inputState=new AU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Pk(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 Bn?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(nM))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=rM(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=zh.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:g}=this.state.facet(Ge.cursorScrollMargin);f=new Ea(h.empty?h:he.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",g,p)}for(let h of d.effects)h.is(ud)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=Uh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Vu)!=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(gd)!=i.state.facet(gd)&&(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(wy))try{d(i)}catch(h){ui(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!qA(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 Vk(this,e),this.plugins=e.facet(ha).map(r=>new vm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Pk(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 vm(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(CA(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 ui(this.state,p),qk}}),f=zh.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(wy))l(n)}get themeClasses(){return Cy+" "+(this.state.facet(Sy)?lM:oM)+" "+this.state.facet(gd)}updateAttrs(){let e=Yk(this,jA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Os)?"true":"false",class:"cm-content",style:`${Ae.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Yk(this,Sw,n);let r=this.observer.ignore(()=>{let i=Tk(this.contentDOM,this.contentAttrs,n),s=Tk(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(Ge.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(Vu);let e=this.state.facet(Ge.cspNonce);Oo.mount(this.root,this.styleModules.concat(r7).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 km(this,e,Ik(this,e,n,r))}moveByGroup(e,n){return km(this,e,Ik(this,e,n,r=>yU(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 mU(this,e,n,r)}moveVertically(e,n,r){return km(this,e,vU(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=xy(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),xy(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[as.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==vn.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(FA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>a7)return OA(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||RA(s.isolates,r=Mk(this,e))))return s.order;r||(r=Mk(this,e));let i=jV(e.text,n,r);return this.bidiCache.push(new Uh(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(()=>{SA(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 ud.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 ud.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 yi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return yi.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Oo.newName(),i=[gd.of(r),Vu.of(Ty(`.${r}`,e))];return n&&n.dark&&i.push(Sy.of(!0)),i}static baseTheme(e){return gw.lowest(Vu.of(Ty("."+Cy,e,aM)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&wn.get(r)||wn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ge.styleModule=Vu;Ge.inputHandler=LA;Ge.clipboardInputFilter=xw;Ge.clipboardOutputFilter=kw;Ge.scrollHandler=BA;Ge.focusChangeEffect=$A;Ge.perLineTextDirection=FA;Ge.exceptionSink=DA;Ge.updateListener=wy;Ge.editable=Os;Ge.mouseSelectionStyle=_A;Ge.dragMovesSelection=NA;Ge.clickAddsSelectionRange=IA;Ge.decorations=$p;Ge.blockWrappers=HA;Ge.outerDecorations=Cw;Ge.atomicRanges=cf;Ge.bidiIsolatedRanges=WA;Ge.cursorScrollMargin=We.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}}});Ge.scrollMargins=VA;Ge.darkTheme=Sy;Ge.cspNonce=We.define({combine:t=>t.length?t[0]:""});Ge.contentAttributes=Sw;Ge.editorAttributes=jA;Ge.lineWrapping=Ge.contentAttributes.of({class:"cm-lineWrapping"});Ge.announce=Yt.define();const a7=4096,qk={};class Uh{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:vn.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&&vw(o,n)}return n}const u7=Ae.mac?"mac":Ae.windows?"win":Ae.linux?"linux":"key";function c7(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 fo=null;const h7=4e3;function p7(t,e=u7){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(m=>c7(m,e));for(let m=1;m{let k=fo={view:w,prefix:y,scope:o};return setTimeout(()=>{fo==k&&(fo=null)},h7),!0}]})}let g=p.join(" ");i(g,!1);let b=h[g]||(h[g]={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&&b.run.push(a),u&&(b.preventDefault=!0),c&&(b.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,Ey))}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 Ey=null;function g7(t,e,n,r){Ey=e;let i=EV(e),s=aV(i,0),o=uV(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;fo&&fo.view==n&&fo.scope==r&&(l=fo.prefix+" ",QA.indexOf(e.keyCode)<0&&(u=!0,fo=null));let f=new Set,d=b=>{if(b){for(let m of b.run)if(!f.has(m)&&(f.add(m),m(n)))return b.stopPropagation&&(c=!0),!0;b.preventDefault&&(b.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,g;return h&&(d(h[l+md(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=Po[e.keyCode])&&p!=i?(d(h[l+md(p,e,!0)])||e.shiftKey&&(g=$c[e.keyCode])!=i&&g!=p&&d(h[l+md(g,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+md(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),Ey=null,a}class m7 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?fc(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=zc(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 y7(t){let e=yi.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Kt.set([Kt.widget({widget:new m7(t),side:1}).range(0)]):Kt.none}get decorations(){return this.view.state.doc.length?Kt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Ge.contentAttributes.of({"aria-placeholder":t})]:e}const yd="-10000px";class cM{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 v7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const Tm=We.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)||v7}}}),Qk=new WeakMap,fM=yi.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(Tm);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 cM(t,dM,(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(Tm);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=yd,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=Tw(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(Tm).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=yd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,g=d.right-d.left,b=(e=Qk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,m=u.offset||b7,y=this.view.textDirection==vn.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)+m.x,r.right-g)):Math.min(Math.max(r.left,f.left-g+(h?14:0)-m.x),r.right-g),k=this.above[l];!a.strictSide&&(k?f.top-b-p-m.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let x=(k?f.top-r.top:r.bottom-f.bottom)-p;if(xw&&A.topS&&(S=k?A.top-b-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-t.parent.top)/s+"px",Zk(c,(w-t.parent.left)/i)):(c.style.top=S/s+"px",Zk(c,w/i)),h){let A=f.left+(y?m.x:-m.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:S,right:T,bottom:S+b}),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=yd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Zk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const w7=Ge.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"}}}),b7={x:0,y:0},dM=We.define({enables:[fM,w7]}),Kh=We.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class jp{static create(e){return new jp(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new cM(e,Kh,(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 x7=dM.compute([Kh],t=>{let e=t.facet(Kh);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:jp.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),k7=We.define();class S7{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==vn.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=>ui(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(fM),n=e?e.manager.tooltips.findIndex(r=>r.create==jp.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&&!C7(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:!T7(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 vd=4;function C7(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-vd&&e.clientX<=r+vd&&e.clientY>=i-vd&&e.clientY<=s+vd}function T7(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 E7(t,e={}){let n=Yt.define(),r=new WeakMap,i=vs.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Sr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(A7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Kh.from(o)});const s=yi.define(o=>new S7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,k7.of(s),x7]}}const A7=Yt.define(),eS=We.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),M7=yi.fromClass(class{constructor(t){this.input=t.state.facet(Ay),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(eS);this.top=new wd(t,!0,e.topContainer),this.bottom=new wd(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(eS);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new wd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new wd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(Ay);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=>Ge.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class wd{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=tS(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=tS(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 tS(t){let e=t.nextSibling;return t.remove(),e}const Ay=We.define({enables:M7});class Ha extends xl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ha.prototype.elementClass="";Ha.prototype.toDOM=void 0;Ha.prototype.mapMode=Sr.TrackBefore;Ha.prototype.startSide=Ha.prototype.endSide=-1;Ha.prototype.point=!0;const hM=1024;let R7=0;class Em{constructor(e,n){this.from=e,this.to=n}}class At{constructor(e={}){this.id=R7++,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]}}}At.closedBy=new At({deserialize:t=>t.split(" ")});At.openedBy=new At({deserialize:t=>t.split(" ")});At.group=new At({deserialize:t=>t.split(" ")});At.isolate=new At({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});At.contextHash=new At({perNode:!0});At.lookAhead=new At({perNode:!0});At.mounted=new At({perNode:!0});class pc{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[At.mounted.id]}}const O7=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):O7,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(At.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(At.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 Rw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|yn.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:Iw(Or.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new An(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new An(Or.none,n,r,i)))}static build(e){return _7(e)}}An.empty=new An(Or.none,[],[],0);class Ow{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 Ow(this.buffer,this.index)}}class No{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 Hc(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&yn.EnterBracketed&&c instanceof An&&(d=pc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!pM(i,r,f,f+c.length))){if(c instanceof No){if(s&yn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new yo(new P7(o,c,e,f),null,h)}else if(s&yn.IncludeAnonymous||!c.type.isAnonymous||Pw(c)){let h;if(!(s&yn.IgnoreMounts)&&(h=pc.get(c))&&!h.overlay)return new pi(h.tree,f,e,o);let p=new pi(c,f,e,o);return s&yn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&yn.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&yn.IgnoreOverlays)&&(i=pc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&yn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new pi(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 rS(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 My(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 P7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class yo extends gM{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 yo(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&yn.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 yo(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 yo(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 yo(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 An(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function mM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new pi(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Hc(l,e,n,!1))}}return i?mM(i):r}class Ry{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&~yn.EnterBracketed,e instanceof pi)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 pi?(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&yn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&yn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&yn.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&yn.IncludeAnonymous||l instanceof No||!l.type.isAnonymous||Pw(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 My(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 Pw(t){return t.children.some(e=>e instanceof No||!e.type.isAnonymous||Pw(e))}function _7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=hM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Ow(n,n.length):n,a=r.types,u=0,c=0;function f(x,S,T,A,M,O){let{id:D,start:P,end:I,size:_}=l,te=c,ie=u;if(_<0)if(l.next(),_==-1){let N=s[D];T.push(N),A.push(P-x);return}else if(_==-3){u=D;return}else if(_==-4){c=D;return}else throw new RangeError(`Unrecognized record size: ${_}`);let Z=a[D],W,V,R=P-x;if(I-P<=i&&(V=b(l.pos-S,M))){let N=new Uint16Array(V.size-V.skip),L=l.pos-V.size,z=N.length;for(;l.pos>L;)z=m(V.start,N,z);W=new No(N,I-V.start,r),R=V.start-x}else{let N=l.pos-_;l.next();let L=[],z=[],G=D>=o?D:-1,B=0,me=I;for(;l.pos>N;)G>=0&&l.id==G&&l.size>=0?(l.end<=me-i&&(p(L,z,P,B,l.end,me,G,te,ie),B=L.length,me=l.end),l.next()):O>2500?d(P,N,L,z):f(P,N,L,z,G,O+1);if(G>=0&&B>0&&B-1&&B>0){let le=h(Z,ie);W=Iw(Z,L,z,0,L.length,0,I-P,le,le)}else W=g(Z,L,z,I-P,te-I,ie)}T.push(W),A.push(R)}function d(x,S,T,A){let M=[],O=0,D=-1;for(;l.pos>S;){let{id:P,start:I,end:_,size:te}=l;if(te>4)l.next();else{if(D>-1&&I=0;_-=3)P[te++]=M[_],P[te++]=M[_+1]-I,P[te++]=M[_+2]-I,P[te++]=te;T.push(new No(P,M[2]-I,r)),A.push(I-x)}}function h(x,S){return(T,A,M)=>{let O=0,D=T.length-1,P,I;if(D>=0&&(P=T[D])instanceof An){if(!D&&P.type==x&&P.length==M)return P;(I=P.prop(At.lookAhead))&&(O=A[D]+P.length+I)}return g(x,T,A,M,O,S)}}function p(x,S,T,A,M,O,D,P,I){let _=[],te=[];for(;x.length>A;)_.push(x.pop()),te.push(S.pop()+T-M);x.push(g(r.types[D],_,te,O-M,P-O,I)),S.push(M-T)}function g(x,S,T,A,M,O,D){if(O){let P=[At.contextHash,O];D=D?[P].concat(D):[P]}if(M>25){let P=[At.lookAhead,M];D=D?[P].concat(D):[P]}return new An(x,S,T,A,D)}function b(x,S){let T=l.fork(),A=0,M=0,O=0,D=T.end-i,P={size:0,start:0,skip:0};e:for(let I=T.pos-x;T.pos>I;){let _=T.size;if(T.id==S&&_>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let te=T.pos-_;if(_<0||te=o?4:0,Z=T.start;for(T.next();T.pos>te;){if(T.size<0)if(T.size==-3||T.size==-4)ie+=4;else break e;else T.id>=o&&(ie+=4);T.next()}M=Z,A+=_,O+=ie}return(S<0||A==x)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function m(x,S,T){let{id:A,start:M,end:O,size:D}=l;if(l.next(),D>=0&&A4){let I=l.pos-(D-4);for(;l.pos>I;)T=m(x,S,T)}S[--T]=P,S[--T]=O-x,S[--T]=M-x,S[--T]=A}else D==-3?u=A:D==-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 An(a[t.topID],y.reverse(),w.reverse(),k)}const iS=new WeakMap;function Kd(t,e){if(!t.isAnonymous||e instanceof No||e.type!=t)return 1;let n=iS.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof An)){n=1;break}n+=Kd(t,r)}iS.set(e,n)}return n}function Iw(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,g[k]+y);continue}f.push(p[k])}else{let T=g[w-1]+p[w-1].length-x;f.push(Iw(t,p,g,k,w,x,T,null,a))}d.push(x+y-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class pl{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 pl(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 pl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew Em(i.from,i.to)):[new Em(0,0)]:[new Em(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 D7{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 At({perNode:!0});let L7=0;class oi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=L7++}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 oi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new oi(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 Xh(e);return r=>r.modified.indexOf(n)>-1?r:Xh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let $7=0;class Xh{constructor(e){this.name=e,this.instances=[],this.id=$7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&F7(n,l.modified));if(r)return r;let i=[],s=new oi(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=B7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(Xh.get(l,a));return s}}function F7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function B7(t){let e=[[]];for(let n=0;nr.length-n.length)}function vM(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 Wc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return wM.add(e)}const wM=new At({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 Wc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Wc{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 z7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function j7(t,e,n,r=0,i=t.length){let s=new H7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class H7{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=W7(e)||Wc.empty,f=z7(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(At.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(b=>!b.scope||b.scope(d.tree.type)),g=e.firstChild();for(let b=0,m=l;;b++){let y=b=w||!e.nextSibling())););if(!y||w>r)break;m=y.to+l,m>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+l),Math.min(r,m),"",p),this.startSpan(Math.min(r,m),u))}g&&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 W7(t){let e=t.type.prop(wM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=oi.define,xd=we(),oo=we(),sS=we(oo),oS=we(oo),lo=we(),kd=we(lo),Am=we(lo),es=we(),Jo=we(es),Qi=we(),Zi=we(),Oy=we(),_u=we(Oy),Sd=we(),Xe={comment:xd,lineComment:we(xd),blockComment:we(xd),docComment:we(xd),name:oo,variableName:we(oo),typeName:sS,tagName:we(sS),propertyName:oS,attributeName:we(oS),className:we(oo),labelName:we(oo),namespace:we(oo),macroName:we(oo),literal:lo,string:kd,docString:we(kd),character:we(kd),attributeValue:we(kd),number:Am,integer:we(Am),float:we(Am),bool:we(lo),regexp:we(lo),escape:we(lo),color:we(lo),url:we(lo),keyword:Qi,self:we(Qi),null:we(Qi),atom:we(Qi),unit:we(Qi),modifier:we(Qi),operatorKeyword:we(Qi),controlKeyword:we(Qi),definitionKeyword:we(Qi),moduleKeyword:we(Qi),operator:Zi,derefOperator:we(Zi),arithmeticOperator:we(Zi),logicOperator:we(Zi),bitwiseOperator:we(Zi),compareOperator:we(Zi),updateOperator:we(Zi),definitionOperator:we(Zi),typeOperator:we(Zi),controlOperator:we(Zi),punctuation:Oy,separator:we(Oy),bracket:_u,angleBracket:we(_u),squareBracket:we(_u),paren:we(_u),brace:we(_u),content:es,heading:Jo,heading1:we(Jo),heading2:we(Jo),heading3:we(Jo),heading4:we(Jo),heading5:we(Jo),heading6:we(Jo),contentSeparator:we(es),list:we(es),quote:we(es),emphasis:we(es),strong:we(es),link:we(es),monospace:we(es),strikethrough:we(es),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:Sd,documentMeta:we(Sd),annotation:we(Sd),processingInstruction:we(Sd),definition:oi.defineModifier("definition"),constant:oi.defineModifier("constant"),function:oi.defineModifier("function"),standard:oi.defineModifier("standard"),local:oi.defineModifier("local"),special:oi.defineModifier("special")};for(let t in Xe){let e=Xe[t];e instanceof oi&&(e.name=t)}bM([{tag:Xe.link,class:"tok-link"},{tag:Xe.heading,class:"tok-heading"},{tag:Xe.emphasis,class:"tok-emphasis"},{tag:Xe.strong,class:"tok-strong"},{tag:Xe.keyword,class:"tok-keyword"},{tag:Xe.atom,class:"tok-atom"},{tag:Xe.bool,class:"tok-bool"},{tag:Xe.url,class:"tok-url"},{tag:Xe.labelName,class:"tok-labelName"},{tag:Xe.inserted,class:"tok-inserted"},{tag:Xe.deleted,class:"tok-deleted"},{tag:Xe.literal,class:"tok-literal"},{tag:Xe.string,class:"tok-string"},{tag:Xe.number,class:"tok-number"},{tag:[Xe.regexp,Xe.escape,Xe.special(Xe.string)],class:"tok-string2"},{tag:Xe.variableName,class:"tok-variableName"},{tag:Xe.local(Xe.variableName),class:"tok-variableName tok-local"},{tag:Xe.definition(Xe.variableName),class:"tok-variableName tok-definition"},{tag:Xe.special(Xe.variableName),class:"tok-variableName2"},{tag:Xe.definition(Xe.propertyName),class:"tok-propertyName tok-definition"},{tag:Xe.typeName,class:"tok-typeName"},{tag:Xe.namespace,class:"tok-namespace"},{tag:Xe.className,class:"tok-className"},{tag:Xe.macroName,class:"tok-macroName"},{tag:Xe.propertyName,class:"tok-propertyName"},{tag:Xe.operator,class:"tok-operator"},{tag:Xe.comment,class:"tok-comment"},{tag:Xe.meta,class:"tok-meta"},{tag:Xe.invalid,class:"tok-invalid"},{tag:Xe.punctuation,class:"tok-punctuation"}]);var Mm;const pa=new At;function V7(t){return We.define({combine:t?e=>e.concat(t):void 0})}const U7=new At;class Li{constructor(e,n,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return gs(this)}}),this.parser=n,this.extension=[Va.of(this),$t.languageData.of((s,o,l)=>{let a=lS(s,o,l),u=a.type.prop(pa);if(!u)return[];let c=s.facet(u),f=a.type.prop(U7);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 lS(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(At.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 Gh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function gs(t){let e=t.field(Li.state,!1);return e?e.tree:An.empty}class K7{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 Du=null;class qh{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 qh(e,n,[],An.empty,0,r,[],null)}startParse(){return this.parser.startParse(new K7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=An.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(pl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Du;Du=this;try{return e()}finally{Du=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=aS(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=pl.applyChanges(r,a),i=An.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=aS(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 yM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Du;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 An(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 Du}}function aS(t,e,n){return pl.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=qh.create(e.facet(Va).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wa(r)}}Li.state=vs.define({create:Wa.init,update(t,e){for(let n of e.effects)if(n.is(Li.setState))return n.value;return e.startState.facet(Va)!=e.state.facet(Va)?Wa.init(e.state):t.apply(e)}});let xM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(xM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Rm=typeof navigator<"u"&&(!((Mm=navigator.scheduling)===null||Mm===void 0)&&Mm.isInputPending)?()=>navigator.scheduling.isInputPending():null,X7=yi.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(Li.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(Li.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=xM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Rm&&Rm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Li.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=>ui(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=We.define({combine(t){return t.length?t[0]:null},enables:t=>[Li.state,X7,Ge.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class G7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const q7=We.define(),Nw=We.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 Yh(t){let e=t.facet(Nw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Jh(t,e){let n="",r=t.tabSize,i=t.facet(Nw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?Y7(t,n,e):null}class Hp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Yh(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 Dp(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 SM=new At;function Y7(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 CM(r,t,n)}function CM(t,e,n){for(let r=t;r;r=r.next){let i=Q7(r.node);if(i)return i(_w.create(e,n,r))}return 0}function J7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function Q7(t){let e=t.type.prop(SM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(At.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>nK(o,!0,1,void 0,s&&!J7(o)?i.from:void 0)}return t.parent==null?Z7:null}function Z7(){return 0}class _w extends Hp{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 _w(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(eK(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return CM(this.context.next,this.base,this.pos)}}function eK(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function tK(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 nK(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=tK(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function uS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const rK=new At;function iK(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(pa)==o.data:o?l=>l==o:void 0,this.style=bM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Oo(r):null,this.themeType=n.themeType}static define(e,n){return new Wp(e,n||{})}}const Py=We.define(),sK=We.define({combine(t){return t.length?[t[0]]:null}});function Om(t){let e=t.facet(Py);return e.length?e:t.facet(sK)}function cS(t,e){let n=[lK],r;return t instanceof Wp&&(t.module&&n.push(Ge.styleModule.of(t.module)),r=t.themeType),r?n.push(Py.computeN([Ge.darkTheme],i=>i.facet(Ge.darkTheme)==(r=="dark")?[t]:[])):n.push(Py.of(t)),n}class oK{constructor(e){this.markCache=Object.create(null),this.tree=gs(e.state),this.decorations=this.buildDeco(e,Om(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=gs(e.state),r=Om(e.state),i=r!=Om(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 Kt.none;let r=new Fa;for(let{from:i,to:s}of e.visibleRanges)j7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Kt.mark({class:a})))},i,s);return r.finish()}}const lK=gw.high(yi.fromClass(oK,{decorations:t=>t.decorations})),aK=1e4,uK="()[]{}",cK=new At;function Iy(t,e,n){let r=t.prop(e<0?At.openedBy:At.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 Ny(t){let e=t.type.prop(cK);return e?e(t.node):t}function ga(t,e,n,r={}){let i=r.maxScanDistance||aK,s=r.brackets||uK,o=gs(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Iy(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return fK(t,e,n,a,c,u,s)}}return dK(t,e,n,o,l.type,i,s)}function fK(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 g=n>0?0:h.length-1,b=n>0?h.length:-1;g!=b;g+=n){let m=o.indexOf(h[g]);if(!(m<0||r.resolveInner(p+g,1).type!=i))if(m%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+g,to:p+g+1},matched:m>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const hK=Object.create(null),fS=[Or.none],dS=[],hS=Object.create(null),pK=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"]])pK[t]=gK(hK,e);function Pm(t,e){dS.indexOf(t)>-1||(dS.push(t),console.warn(e))}function gK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Xe[u];c?typeof c=="function"?a.length?a=a.map(c):Pm(u,`Modifier ${u} used at start of tag`):a.length?Pm(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Pm(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=hS[i];if(s)return s.id;let o=hS[i]=Or.define({id:fS.length,name:r,props:[vM({[r]:n})]});return fS.push(o),o.id}vn.RTL,vn.LTR;const mK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Lw(t.state,n.from);return r.line?yK(t):r.block?wK(t):!1};function Dw(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 yK=Dw(kK,0),vK=Dw(TM,0),wK=Dw((t,e)=>TM(t,e,xK(e)),0);function Lw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Lu=50;function bK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Lu,r),o=t.sliceDoc(i,i+Lu),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*Lu?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Lu),f=t.sliceDoc(i-Lu,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 xK(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 TM(t,e,n=e.selection.ranges){let r=n.map(s=>Lw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>bK(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 _y=Fo.define(),SK=Fo.define(),CK=We.define(),EM=We.define({combine(t){return hA(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)})}}),AM=vs.define({create(){return us.empty},update(t,e){let n=e.state.facet(EM),r=e.annotation(_y);if(r){let a=Er.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Qh(c,c.length,n.minDepth,a):c=OM(c,e.startState.selection),new us(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(SK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(Bn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Er.fromTransaction(e),o=e.annotation(Bn.time),l=e.annotation(Bn.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 us(t.done.map(Er.fromJSON),t.undone.map(Er.fromJSON))}});function TK(t={}){return[AM,EM.of(t),Ge.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?MM:e.inputType=="historyRedo"?Dy:null;return r?(e.preventDefault(),r(n)):!1}})]}function Vp(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(AM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const MM=Vp(0,!1),Dy=Vp(1,!1),EK=Vp(0,!0),AK=Vp(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&&Ln.fromJSON(e.changes),[],e.mapped&&ps.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=fi;for(let i of e.startState.facet(CK)){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,fi)}static selection(e){return new Er(void 0,fi,void 0,void 0,e)}}function Qh(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function MK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function RK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function RM(t,e){return t.length?e.length?t.concat(e):t:e}const fi=[],OK=200;function OM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-OK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Qh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Er.selection([e])]}function PK(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 Im(t,e){if(!t.length)return t;let n=t.length,r=fi;for(;n;){let i=IK(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)]:fi}function IK(t,e,n){let r=RM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):fi,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,Yt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const NK=/^(input\.type|delete)($|\.)/;class us{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 us(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||NK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Up(n,e))}function lr(t){return t.textDirectionAt(t.state.selection.main.head)==vn.LTR}const IM=t=>PM(t,!lr(t)),NM=t=>PM(t,lr(t));function _M(t,e){return Ui(t,n=>n.empty?t.moveByGroup(n,e):Up(n,e))}const DK=t=>_M(t,!lr(t)),LK=t=>_M(t,lr(t));function $K(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 Kp(t,e,n){let r=gs(t).resolveInner(e.head),i=n?At.closedBy:At.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;$K(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 FK=t=>Ui(t,e=>Kp(t.state,e,!lr(t))),BK=t=>Ui(t,e=>Kp(t.state,e,lr(t)));function DM(t,e){return Ui(t,n=>{if(!n.empty)return Up(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const LM=t=>DM(t,!1),$M=t=>DM(t,!0);function FM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):Up(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.bottomBM(t,!1),Ly=t=>BM(t,!0);function Bo(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 zK=t=>Ui(t,e=>Bo(t,e,!0)),jK=t=>Ui(t,e=>Bo(t,e,!1)),HK=t=>Ui(t,e=>Bo(t,e,!lr(t))),WK=t=>Ui(t,e=>Bo(t,e,lr(t))),VK=t=>Ui(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),UK=t=>Ui(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function KK(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.headKK(t,e);function vi(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(Vi(t.state,r)),!0)}function zM(t,e){return vi(t,e,n=>t.moveByChar(n,e))}const jM=t=>zM(t,!lr(t)),HM=t=>zM(t,lr(t));function WM(t,e){return vi(t,e,n=>t.moveByGroup(n,e))}const GK=t=>WM(t,!lr(t)),qK=t=>WM(t,lr(t)),YK=t=>{let e=!lr(t);return vi(t,e,n=>Kp(t.state,n,e))},JK=t=>{let e=lr(t);return vi(t,e,n=>Kp(t.state,n,e))};function VM(t,e){return vi(t,e,n=>t.moveVertically(n,e))}const UM=t=>VM(t,!1),KM=t=>VM(t,!0);function XM(t,e){return vi(t,e,n=>t.moveVertically(n,e,FM(t).height))}const gS=t=>XM(t,!1),mS=t=>XM(t,!0),QK=t=>vi(t,!0,e=>Bo(t,e,!0)),ZK=t=>vi(t,!1,e=>Bo(t,e,!1)),eX=t=>{let e=!lr(t);return vi(t,e,n=>Bo(t,n,e))},tX=t=>{let e=lr(t);return vi(t,e,n=>Bo(t,n,e))},nX=t=>vi(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),rX=t=>vi(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),yS=({state:t,dispatch:e})=>(e(Vi(t,{anchor:0})),!0),vS=({state:t,dispatch:e})=>(e(Vi(t,{anchor:t.doc.length})),!0),wS=({state:t,dispatch:e})=>(e(Vi(t,{anchor:t.selection.main.anchor,head:0})),!0),bS=({state:t,dispatch:e})=>(e(Vi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),iX=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),sX=({state:t,dispatch:e})=>{let n=Xp(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},oX=({state:t,dispatch:e})=>{let n=ru(t.selection,r=>{let i=gs(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(Vi(t,n)),!0)};function GM(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(Vi(n,he.create(i,i.length-1))),!0)}const lX=t=>GM(t,!1),aX=t=>GM(t,!0),uX=({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(Vi(t,r)),!0):!1};function ff(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=Cd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Cd(t,o,!1),l=Cd(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 qM=(t,e,n)=>ff(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iqM(t,!1,!0),YM=t=>qM(t,!0,!1),JM=(t,e)=>ff(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}),QM=t=>JM(t,!1),cX=t=>JM(t,!0),fX=t=>ff(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headff(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),hX=t=>ff(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:_t.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},gX=({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 Xp(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 ZM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of Xp(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 mX=({state:t,dispatch:e})=>ZM(t,e,!1),yX=({state:t,dispatch:e})=>ZM(t,e,!0);function eR(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of Xp(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 vX=({state:t,dispatch:e})=>eR(t,e,!1),wX=({state:t,dispatch:e})=>eR(t,e,!0),bX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Xp(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 xX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=gs(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(At.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 xS=tR(!1),kX=tR(!0);function tR(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&&xX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Hp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=kM(u,s);for(c==null&&(c=Dp(/^\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 SX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Hp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=$w(t,(s,o,l)=>{let a=kM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Jh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update($w(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Nw)})}),{userEvent:"input.indent"})),!0),rR=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update($w(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Dp(i,t.tabSize),o=0,l=Jh(t,Math.max(0,s-Yh(t)));for(;o(t.setTabFocusMode(),!0),TX=[{key:"Ctrl-b",run:IM,shift:jM,preventDefault:!0},{key:"Ctrl-f",run:NM,shift:HM},{key:"Ctrl-p",run:LM,shift:UM},{key:"Ctrl-n",run:$M,shift:KM},{key:"Ctrl-a",run:VK,shift:nX},{key:"Ctrl-e",run:UK,shift:rX},{key:"Ctrl-d",run:YM},{key:"Ctrl-h",run:$y},{key:"Ctrl-k",run:fX},{key:"Ctrl-Alt-h",run:QM},{key:"Ctrl-o",run:pX},{key:"Ctrl-t",run:gX},{key:"Ctrl-v",run:Ly}],EX=[{key:"ArrowLeft",run:IM,shift:jM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:DK,shift:GK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:HK,shift:eX,preventDefault:!0},{key:"ArrowRight",run:NM,shift:HM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:LK,shift:qK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:WK,shift:tX,preventDefault:!0},{key:"ArrowUp",run:LM,shift:UM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:yS,shift:wS},{mac:"Ctrl-ArrowUp",run:pS,shift:gS},{key:"ArrowDown",run:$M,shift:KM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:vS,shift:bS},{mac:"Ctrl-ArrowDown",run:Ly,shift:mS},{key:"PageUp",run:pS,shift:gS},{key:"PageDown",run:Ly,shift:mS},{key:"Home",run:jK,shift:ZK,preventDefault:!0},{key:"Mod-Home",run:yS,shift:wS},{key:"End",run:zK,shift:QK,preventDefault:!0},{key:"Mod-End",run:vS,shift:bS},{key:"Enter",run:xS,shift:xS},{key:"Mod-a",run:iX},{key:"Backspace",run:$y,shift:$y,preventDefault:!0},{key:"Delete",run:YM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:QM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:cX,preventDefault:!0},{mac:"Mod-Backspace",run:dX,preventDefault:!0},{mac:"Mod-Delete",run:hX,preventDefault:!0}].concat(TX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),AX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:FK,shift:YK},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:BK,shift:JK},{key:"Alt-ArrowUp",run:mX},{key:"Shift-Alt-ArrowUp",run:vX},{key:"Alt-ArrowDown",run:yX},{key:"Shift-Alt-ArrowDown",run:wX},{key:"Mod-Alt-ArrowUp",run:lX},{key:"Mod-Alt-ArrowDown",run:aX},{key:"Escape",run:uX},{key:"Mod-Enter",run:kX},{key:"Alt-l",mac:"Ctrl-l",run:sX},{key:"Mod-i",run:oX,preventDefault:!0},{key:"Mod-[",run:rR},{key:"Mod-]",run:nR},{key:"Mod-Alt-\\",run:SX},{key:"Shift-Mod-k",run:bX},{key:"Shift-Mod-\\",run:XK},{key:"Mod-/",run:mK},{key:"Alt-A",mac:"Ctrl-A",run:vK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:CX}].concat(EX),MX={key:"Tab",run:nR,shift:rR};var kS={};class Zh{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 Zh(e,[],n,r,r,0,[],0,i?new SS(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 Zh(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 RX(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 SS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class RX{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 ep{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 ep(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 ep(this.stack,this.pos,this.index)}}function Td(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 Xd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const CS=new Xd;class OX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=CS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=CS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Aa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;PX(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 PX(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||IX(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),g=t[p],b=t[p+1]||65536;if(c=b)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function TS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function IX(t,e,n,r){let i=TS(n,r,e);return i<0||TS(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 NX{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?ES(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?ES(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 An){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 _X{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Xd)}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 Xd,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 Xd,{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 NX(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&&$X(i);if(o)return Fr&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw Fr&&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 Fr&&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(At.contextHash)||0)==c))return e.useNode(f,d),Fr&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof An)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof An&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),Fr&&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 AS(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(),Fr&&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()&&(Fr&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)Fr&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))Fr&&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),Fr&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),AS(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 Rw(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=hM;let o=Td(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 DX(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=Ms(this.data,s+2);else break;i=n(Ms(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=Ms(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(tp.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]=MS(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 FX=vM({String:Xe.string,Number:Xe.number,"True False":Xe.bool,PropertyName:Xe.propertyName,Null:Xe.null,", :":Xe.separator,"[ ]":Xe.squareBracket,"{ }":Xe.brace}),BX=tp.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:[FX],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}),zX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=jX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function jX(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 HX=Gh.define({name:"json",parser:BX.configure({props:[SM.add({Object:uS({except:/^\s*\}/}),Array:uS({except:/^\s*\]/})}),rK.add({"Object Array":iK})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function RS(){return new G7(HX)}class OS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class sl{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(cs).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new Fa,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 g,b;if(l.length)g=a,b=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>g?p.from:1e8);else{if(g=p.from,g>f)break;b=p.to,l.push(p),h++}for(;hw.from||w.to==g))l.push(w),h++,b=Math.min(w.to,b);else{b=Math.min(w.from,b);break}}b=Math.min(b,f);let m=!1;if(l.some(w=>w.from==g&&(w.to==b||b==f))&&(m=g==b,!m&&b-g<10)){let w=g-(c+u.value.length);w>0&&(u.next(w),c=g);for(let k=g;;){if(k>=b){m=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=nG(l);if(m)o.add(g,g,Kt.widget({widget:new QX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,x)=>x.markClass?k+" "+x.markClass:k,"");o.add(g,b,Kt.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>b)}))}if(a=b,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new OS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new OS(r.from,s,r.diagnostic)}}),r}function WX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(cs).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Fw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function VX(t,e){return t.field($i,!1)?e:e.concat(Yt.appendConfig.of(aR))}function UX(t,e){return{effects:VX(t,[Fw.of(e)])}}const Fw=Yt.define(),iR=Yt.define(),sR=Yt.define(),$i=vs.define({create(){return new sl(Kt.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(cs).autoPanel&&(i=null),t=new sl(n,i,r)}for(let n of e.effects)if(n.is(Fw)){let r=e.state.facet(cs).autoPanel?n.value.length?np.open:null:t.panel;t=sl.init(n.value,r,e.state)}else n.is(iR)?t=new sl(t.diagnostics,n.value?np.open:null,t.selected):n.is(sR)&&(t=new sl(t.diagnostics,t.panel,n.value));return t},provide:t=>[Ay.from(t,e=>e.panel),Ge.decorations.from(t,e=>e.diagnostics)]}),KX=Kt.mark({class:"cm-lintRange cm-lintRange-active"});function XX(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)&&(elR(t,n,!1)))}const PS=t=>{let e=t.state.field($i,!1);return!e||!e.panel?!1:(t.dispatch({effects:iR.of(!1)}),!0)},qX=yi.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(cs);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(UX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{ui(this.view.state,r)})}}update(t){let e=t.state.facet(cs);(t.docChanged||e!=t.startState.facet(cs)||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 YX(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 cs=We.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...hA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:IS,tooltipFilter:IS,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 IS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function JX(t,e={}){return[cs.of({source:t,config:e}),qX,aR]}function oR(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 lR(t,e,n){var r;let i=n?oR(e.actions):[];return is("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},is("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),is("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return is("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&is("div",{class:"cm-diagnosticSource"},e.source))}class QX extends nu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return is("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class NS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=lR(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class np{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)PS(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=oR(s.actions);for(let l=0;l{for(let s=0;sPS(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:sR.of(r)})}static open(e){return new np(e)}}function ZX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function Ed(t){return ZX(``,'width="6" height="3"')}const eG=Ge.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:Ed("#f11")},".cm-lintRange-warning":{backgroundImage:Ed("orange")},".cm-lintRange-info":{backgroundImage:Ed("#999")},".cm-lintRange-hint":{backgroundImage:Ed("#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 tG(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function nG(t){let e="hint",n=1;for(let r of t){let i=tG(r.severity);i>n&&(n=i,e=r.severity)}return e}const rG=E7(XX,{hideOn:WX}),aR=[$i,Ge.decorations.compute([$i],t=>{let{selected:e,panel:n}=t.field($i);return!e||!n||e.from==e.to?Kt.none:Kt.set([KX.range(e.from,e.to)])}),rG,eG],iG=512*1024,_S=512*1024,uR=2e6;function sG(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 oG=t=>t.state.doc.length>iG?[]:zX()(t);function DS(t){return Wp.define([{tag:Xe.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Xe.string,color:t?"#86efac":"#15803d"},{tag:Xe.number,color:t?"#fcd34d":"#b45309"},{tag:Xe.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Xe.null,color:t?"#a1a1aa":"#71717a"}])}const lG=Ge.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 cR({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),g=v.useRef(null),b=n??e!==void 0,m=v.useRef(b),y=v.useRef(r),w=t.length>_S,k=v.useRef(w),x=!b&&t.length>uR,S=x?sG(t,_S):t,T=v.useRef(!1),A=v.useCallback((M,O,D)=>M?[Ge.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!D?[]:[JX(oG,{delay:300})]]:[$t.readOnly.of(!0),Ge.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new hl,D=new hl,P=new hl,I=$t.create({doc:S,extensions:[P.of(w||!r?[]:RS()),Ge.lineWrapping,TK(),uM.of([...AX,..._K,MX]),lG,O.of(cS(DS(i))),D.of(A(b,w,r)),...s?[y7(s)]:[]]}),_=new Ge({state:I,parent:M});return h.current=O,p.current=D,g.current=P,a==null||a(_),c.current=_,()=>{_.destroy(),c.current=null}},[]),v.useEffect(()=>{const M=c.current;if(!M)return;const O=g.current,D=p.current,P=[];(w!==k.current||r!==y.current)&&(k.current=w,y.current=r,O&&P.push(O.reconfigure(w||!r?[]:RS())),D&&P.push(D.reconfigure(A(b,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,b,A]),v.useEffect(()=>{const M=c.current,O=p.current;!M||!O||b!==m.current&&(m.current=b,M.dispatch({effects:O.reconfigure(A(b,w,r))}))},[b,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(cS(DS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:pr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[x?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 fR({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 cl="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 Fy={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(g,b){var m=new RegExp(g,"g");h[g]=(d.match(m)||[]).length,p=!p||h[g]>h[p]?g:p}),p}function u(d){for(var h={},p=0;p=0;p--){var g=d[p];h[g]>0&&(g=g+"__"+h[g]--),b.unshift(g)}return b}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var g=[];try{o=h.trim!==!1;var g=f.parse(d,l[p])}catch(Z){var b=d.lastIndexOf(` +`,Z.offset),m=d.indexOf(` +`,Z.offset),y=d.substring(b>=-1?b:0,m>-1?m:d.length);throw Z.message+" On line "+Z.line+" and column "+Z.column+`. +`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=g[k].length);for(var x=new Array(w),S=0;Sy&&(y=m,w=[]),w.push(R))}function x(){var R,N,L,z;return L=m,z=m,R=function(G){return te=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=z)):(R=null,m=z),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(m=L),R}function S(){var R,N,L,z;return L=m,z=m,R=function(G){return te=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=z)):(R=null,m=z),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(m=L),R}function T(){var R,N,L,z;return L=m,z=m,R=function(G){return te="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=z)):(R=null,m=z),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(m=L),R}function A(){var R,N,L,z;return L=m,z=m,R=function(G){return te=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,m=z)):(R=null,m=z),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(m=L),R}function M(){var R,N,L,z,G,B,me,le,ve;for(B=m,me=m,R=[],/^[\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=O(),N!==null){if(L=[],le=m,ve=m,/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]")),G!==null)for(z=[];G!==null;)z.push(G),/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]"));else z=null;for(z!==null?(G=O(),G!==null?z=[z,G]:(z=null,m=ve)):(z=null,m=ve),z!==null&&(z=function(Ne,se){return se}(le,z[1])),z===null&&(m=le);z!==null;){if(L.push(z),le=m,ve=m,/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]")),G!==null)for(z=[];G!==null;)z.push(G),/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]"));else z=null;z!==null?(G=O(),G!==null?z=[z,G]:(z=null,m=ve)):(z=null,m=ve),z!==null&&(z=function(Ne,se){return se}(le,z[1])),z===null&&(m=le)}if(L!==null){for(z=[],/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]"));G!==null;)z.push(G),/^[\n\r]/.test(p.charAt(m))?(G=p.charAt(m),m++):(G=null,k("[\\n\\r]"));z!==null?R=[R,N,L,z]:(R=null,m=me)}else R=null,m=me}else R=null,m=me;else R=null,m=me;return R!==null&&(R=function(Ne,se,_e){return _e.unshift(se),_e}(B,R[1],R[2])),R===null&&(m=B),R}function O(){var R,N,L,z,G,B,me,le,ve;if(B=m,me=m,R=D(),R!==null){for(N=[],le=m,ve=m,p.length>m?(L=p.charAt(m),m++):(L=null,k("any character")),L!==null?(z=function(Ne,se){return se==te}(m,L)?"":null,z!==null?(G=D(),G!==null?L=[L,z,G]:(L=null,m=ve)):(L=null,m=ve)):(L=null,m=ve),L!==null&&(L=function(Ne,se,_e){return _e}(le,L[0],L[2])),L===null&&(m=le);L!==null;)N.push(L),le=m,ve=m,p.length>m?(L=p.charAt(m),m++):(L=null,k("any character")),L!==null?(z=function(Ne,se){return se==te}(m,L)?"":null,z!==null?(G=D(),G!==null?L=[L,z,G]:(L=null,m=ve)):(L=null,m=ve)):(L=null,m=ve),L!==null&&(L=function(Ne,se,_e){return _e}(le,L[0],L[2])),L===null&&(m=le);N!==null?(L=function(Ne,se,_e){return!!se||_e.length}(m,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,m=me)):(R=null,m=me)}else R=null,m=me;return R!==null&&(R=function(Ne,se,_e){return _e.unshift(se),_e}(B,R[0],R[1])),R===null&&(m=B),R}function D(){var R,N,L,z,G,B;if(z=m,G=m,p.charCodeAt(m)===34?(R='"',m++):(R=null,k('"\\""')),R!==null){for(N=[],L=P();L!==null;)N.push(L),L=P();N!==null?(p.charCodeAt(m)===34?(L='"',m++):(L=null,k('"\\""')),L!==null?R=[R,N,L]:(R=null,m=G)):(R=null,m=G)}else R=null,m=G;if(R!==null&&(R=function(me,le){return le.join("")}(z,R[1])),R===null&&(m=z),R===null){for(z=m,R=[],G=m,B=m,/^[^\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(me,le){return le!=te}(m,N)?"":null,L!==null?N=[N,L]:(N=null,m=B)):(N=null,m=B),N!==null&&(N=function(me,le){return le}(G,N[0])),N===null&&(m=G);N!==null;)R.push(N),G=m,B=m,/^[^\n\r]/.test(p.charAt(m))?(N=p.charAt(m),m++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(me,le){return le!=te}(m,N)?"":null,L!==null?N=[N,L]:(N=null,m=B)):(N=null,m=B),N!==null&&(N=function(me,le){return le}(G,N[0])),N===null&&(m=G);R!==null&&(R=function(me,le){return(o?le.join("").trim():le.join("")).replace(/(^")|("$)/g,"")}(z,R)),R===null&&(m=z)}return R}function P(){var R,N,L,z;return L=m,z=m,p.charCodeAt(m)===34?(R='"',m++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(m)===34?(N='"',m++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,m=z)):(R=null,m=z),R!==null&&(R=function(G){return'"'}()),R===null&&(m=L),R===null&&(/^[^"]/.test(p.charAt(m))?(R=p.charAt(m),m++):(R=null,k('[^"]'))),R}function I(R){R.sort();for(var N=null,L=[],z=0;z=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function Fi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function yG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function vG(t){const e=(r,i,s)=>{for(const[o,l]of Object.entries(r)){const a=i?`${i}.${o}`:o;Fi(l)&&Object.keys(l).length>0?e(l,a,s):Array.isArray(l)?s[a]=l.map(n):s[a]=l}},n=r=>{if(!Fi(r))return r;const i={};return e(r,"",i),i};return Array.isArray(t)?t.map(n):Fi(t)?n(t):t}function wG(t){const e=n=>{if(!Fi(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(yG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):Fi(t)?e(t):t}function bG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function xG(t,e,n){if(n==="string")return t;if(n==="number")return $S(t);if(n==="boolean")return bG(t);if(e.parseJSON){const r=mG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?$S(t):t}function kG(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=xG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>Fi(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=Fi(s)?n(s):s;return r}const SG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function hR(t){const e=SG.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 zy(t){const e=new Set(t),n=new Map;for(const i of t){const s=hR(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 FS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function BS(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=>hR(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 g=d.get(p.index);g?g.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const g=d.get(p)??[],b={};for(const m of g){if(!m.subKey)continue;const y=t[m.column];FS(y,r)||(b[m.subKey]=y)}Object.keys(b).length>0&&h.push(b)}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 g=d.get(p);if(!g)continue;const b=t[g];FS(b,r)||h.push(b)}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(!Fi(r))return e;const i=Object.keys(r),s=zy(i);return s.length===0?e:e.map(o=>Fi(o)?BS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!Fi(r))return e;const i=Object.keys(r),s=zy(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=Fi(a)?BS(a,i,s,n):a;return o}return e}function zS(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(LS)?t.slice(LS.length):t,i=e.separator===void 0?of(r):null,s=i?i.cleanedCsv:r;try{const o=uG(s,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),l=kG(o,n);return e.collapseIndexedArrays!==!1&&!e.transpose?CG(o,l,n.emptyFields):l}catch(o){throw new Error(dR(o))}}function TG(t,e={}){try{const n=e.flatten?wG(vG(t)):t;return fG(n,e)}catch(n){const r=dR(n);throw pG.some(i=>r.startsWith(i))?new dG(hG(r,e.flatten??!1)):new Error(r)}}function EG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const Br={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},jS=["data","items","results","records","rows"];function gc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function pR(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!gc(n))return[];const r=Object.keys(n),i=new Set(jS),s=[...jS.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=>gc(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function Bw(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 AG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=Bw(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function MG(t){const e=t.trim();if(e==="")return[];let n;try{n=JSON.parse(e)}catch{const o=Bw(e);if(o===null)return[];n=o}let r=[];if(Array.isArray(n)){if(n.length===0||!n.every(o=>gc(o)))return[];r=n}else if(gc(n)){if(pR(e).length>0)return[];r=[n]}else return[];const i=new Set,s=r.slice(0,50);for(const o of s)for(const[l,a]of Object.entries(o))(gc(a)||Array.isArray(a)&&a.length>0)&&i.add(l);return Array.from(i)}function RG(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 HS=t=>t==="auto"?void 0:t;function OG(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:f}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=Bw(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=HS(n.separator),s=TG(r,{separator:i,flatten:n.flatten}),o=lf(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 NG(){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:cl,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function _G(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function DG(t){const e=t.slice(0,3).map(r=>`.${r}`).join(", "),n=t.length-3;return n>0?`${e}, +${n} more`:e}function LG({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:g,onCellCommit:b,canUndo:m=!1,canRedo:y=!1,onUndo:w,onRedo:k,collapseIndexedArrays:x=!0,onToggleCollapseIndexedArrays:S,columnTypes:T,onChangeColumnTypes:A,flatten:M=!1,onToggleFlatten:O}){const[D,P]=v.useState(!1),[I,_]=v.useState(!1),te=v.useRef(0),ie=v.useRef(null),Z=e.trim()==="",W=t==="CSV",V=v.useMemo(()=>!W||Z||g!==void 0?null:of(e),[W,Z,e,g]),R=v.useMemo(()=>{if(!W||Z)return[];const se=V?V.cleanedCsv:e,_e=_G(se),$e=lf(_e,g);return zy($e.headers.map(Fe=>Fe.trim()))},[W,Z,e,g,V]),N=v.useMemo(()=>W||Z?[]:pR(e),[W,Z,e]),L=v.useMemo(()=>W||Z?[]:MG(e),[W,Z,e]),z=v.useMemo(()=>W||Z?null:AG(e),[W,Z,e]),G=se=>{var _e;se.preventDefault(),Array.from(((_e=se.dataTransfer)==null?void 0:_e.types)??[]).includes("Files")&&(te.current++,_(!0))},B=()=>{te.current=Math.max(0,te.current-1),te.current===0&&_(!1)},me=se=>{var $e,Fe;se.preventDefault(),te.current=0,_(!1);const _e=(Fe=($e=se.dataTransfer)==null?void 0:$e.files)==null?void 0:Fe[0];_e&&r(_e,"drop")},le=se=>{var $e;if(!Z||se.defaultPrevented||se.target instanceof HTMLTextAreaElement||se.target instanceof HTMLInputElement)return;const _e=($e=se.clipboardData)==null?void 0:$e.getData("text/plain");_e&&(se.preventDefault(),n(_e))},ve=W?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!D,onClick:()=>P(!1),className:pr("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",D?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(SN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":D,onClick:()=>P(!0),className:pr("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",D?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(mb,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,Ne=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(NG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:G,onDragOver:se=>se.preventDefault(),onDragLeave:B,onDrop:me,onPaste:le,"data-drag-over":I||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(fR,{title:t,meta:Ne,actions:E.jsxs(E.Fragment,{children:[ve,W&&(m||y)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!m,onClick:()=>w==null?void 0:w(),className:cl,children:E.jsx(ON,{"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:cl,children:E.jsx(dN,{"aria-hidden":"true"})})]}):null,z?E.jsx($u,{label:z.label,testId:"json-format-toggle",onClick:()=>n(z.nextInput),Icon:mb,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:ie,type:"file","data-testid":"file-input",accept:W?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:se=>{var $e;const _e=($e=se.target.files)==null?void 0:$e[0];_e&&r(_e,"picker"),se.target.value=""}}),E.jsx($u,{label:"Upload",testId:"upload",onClick:()=>{var se;return(se=ie.current)==null?void 0:se.click()},Icon:kT}),E.jsx($u,{label:"Copy",testId:"copy-input",onClick:o,Icon:Bv}),E.jsx($u,{label:"Clear",testId:"clear-input",onClick:s,disabled:Z,Icon:bh}),E.jsx($u,{label:"Download",testId:"download-input",onClick:a,disabled:Z,Icon:xT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[Z?E.jsx(eV,{format:t,onIngest:n,onBrowse:()=>{var se;return(se=ie.current)==null?void 0:se.click()},onTryExample:i}):W?E.jsxs(E.Fragment,{children:[V?E.jsxs("div",{"data-testid":"csv-markdown-table-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:V.kind==="box"?"ASCII CLI box table detected:":"Markdown pipe table detected:"}),E.jsx("button",{type:"button","data-testid":"csv-clean-markdown-pill",onClick:()=>n(V.cleanedCsv),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 hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:V.kind==="box"?`Clean CLI table (${V.rows} ${V.rows===1?"row":"rows"})`:`Clean Markdown table (${V.rows} ${V.rows===1?"row":"rows"})`})]}):null,R.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 (${R.map(se=>`${se.prefix}[${se.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":x,onClick:()=>S==null?void 0:S(),className:pr("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",x?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:x?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,D?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:se=>n(se.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(qE,{text:e,delimiter:g,testId:"input-table",dark:p,onCellCommit:b,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:T,onChangeColumnTypes:A})]}):E.jsxs(E.Fragment,{children:[N.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:"}),N.map(se=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${se.key}`,onClick:()=>n(se.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 .${se.key} (${se.rowCount} ${se.rowCount===1?"row":"rows"})`},se.key))]}):null,L.length>0?E.jsxs("div",{"data-testid":"json-flatten-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Nested keys (${L.length}):`}),E.jsx("button",{type:"button","data-testid":"json-flatten-pill","aria-pressed":M,onClick:()=>O==null?void 0:O(),className:pr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",M?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${M?"Flattened":"Flatten"} nested keys (${DG(L)})`})]}):null,E.jsx(cR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),I?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const $G=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function FG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:$G.test(t.name)}const BG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function WS(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 gR(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 mR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function VS(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function zG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=mR.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 US(){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 KS(){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 XS({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 no({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:pr("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:pr("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(jy,{text:r}):null]})}function jy({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 jG({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=gR("(min-width: 98.5rem)"),f=t==="csv2json",d=zG(t,e),h=v.useCallback(()=>{var g;l(!1),(g=a.current)==null||g.focus()},[]);v.useEffect(()=>{if(!o)return;const g=m=>{m.key==="Escape"&&h()},b=m=>{const y=u.current;y===null||!(m.target instanceof Node)||y.contains(m.target)||h()};return document.addEventListener("keydown",g),document.addEventListener("click",b),()=>{document.removeEventListener("keydown",g),document.removeEventListener("click",b)}},[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(XS,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:g=>n({separator:g.target.value}),className:US(),children:mR.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(KS,{})]})]}),E.jsx(jy,{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(VS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(XS,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:g=>s(g.target.value),className:US(),children:BG.map(g=>E.jsx("option",{value:g.value,children:g.label},g.value))}),E.jsx(KS,{})]})]}),E.jsx(jy,{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(VS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(no,{label:"Parse numbers",checked:e.parseNumbers,onChange:g=>n({parseNumbers:g}),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(no,{label:"Parse JSON",checked:e.parseJSON,onChange:g=>n({parseJSON:g}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(no,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:g=>n({emptyFields:g?"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(no,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:g=>n({nullLiterals:g?"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(no,{label:"Transpose",checked:e.transpose,onChange:g=>n({transpose:g}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(no,{label:"Hash output",checked:e.hash,onChange:g=>n({hash:g}),hint:"The first column becomes the object key instead of a field."}),E.jsx(no,{label:"Minify",checked:e.minify,onChange:g=>n({minify:g}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(no,{label:"Flatten nested arrays",checked:e.flatten,onChange:g=>n({flatten:g}),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(tN,{"aria-hidden":"true",className:pr("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:pr("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 HG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],WG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),VG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Gd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function zw(t){if(Array.isArray(t))return t.map(e=>Gd(e)?e:{value:e});if(Gd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>Gd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function yR(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 UG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!WG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function _m(t){return`"${t.replace(/"/g,'""')}"`}function KG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function XG(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 GG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return zw(n).map(i=>JSON.stringify(i)).join(` +`)}function qG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=zw(r),s=yR(i),o=_m(UG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(g=>g[d]),p=KG(h);return` ${_m(d)} ${p}`}),a=`CREATE TABLE ${o} ( +${l.join(`, +`)} +);`;if(i.length===0)return a;const u=s.map(_m).join(", "),c=i.map(d=>` (${s.map(p=>XG(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES +${c.join(`, +`)};`;return`${a} + +${f}`}function vR(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=wR(Array.from(new Set(t.map(n=>vR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return Gd(t)?"Record":"unknown"}const GS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function wR(t){return[...t].sort((e,n)=>{const r=GS[e]??50,i=GS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function YG(t){return VG.test(t)?t:JSON.stringify(t)}function JG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=zw(n),s=yR(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(vR(h[l]))}const c=wR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${YG(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 QG(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 GG(i);case"sql":return qG(i,s);case"ts":return JG(i)}}const ZG=3;function eq(t){const e=t.slice(0,ZG),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` +`)}function tq({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:g,onEgressFormatChange:b,onOutputChange:m,onRevert:y,onDiscardReconvert:w}){const k=t==="JSON",x=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(fR,{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:cl,children:[E.jsx(yb,{"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:HG.map(S=>{const T=u===S.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${S.format}`,"aria-pressed":T,onClick:()=>b==null?void 0:b(S.format),className:pr("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:cl,children:[E.jsx(Bv,{"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:g,disabled:!n,className:cl,children:[E.jsx(xT,{"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:cl+" ml-2",children:[E.jsx(yb,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:eq(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(cR,{value:n,editable:a&&x&&n.length<=uR,lintJson:x,onChange:m,dark:f,testId:"output-view"})}):E.jsx(qE,{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 nq({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 jw="csvjson:recent.v1",bR=10,xR=1e5,qS=80;function rq(t){return t==="csv2json"||t==="json2csv"}function iq(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 kR(t){if(typeof t!="object"||t===null)return{...Br};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:Br.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:Br.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:Br.nullLiterals,o=iq(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:Br.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:Br.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:Br.transpose,hash:typeof e.hash=="boolean"?e.hash:Br.hash,minify:typeof e.minify=="boolean"?e.minify:Br.minify,flatten:typeof e.flatten=="boolean"?e.flatten:Br.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:Br.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function SR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=qS?n:`${n.slice(0,qS-1)}…`}function sq(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)||!rq(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>xR||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 oq(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:kR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||SR(t.input)}}function CR(t){try{if(typeof window>"u")return;window.localStorage.setItem(jw,JSON.stringify(t))}catch{}}function lq(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 Hw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(jw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(sq).map(oq).sort((r,i)=>i.createdAt-r.createdAt).slice(0,bR):[]}catch{return[]}}function YS(t){const e=Hw(),n=t.input.trim();if(n===""||t.input.length>xR||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)??lq(r),createdAt:r,direction:t.direction,input:t.input,options:kR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:SR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,bR);return CR(l),l}function aq(t){const n=Hw().filter(r=>r.id!==t);return CR(n),n}function uq(){try{if(typeof window>"u")return;window.localStorage.removeItem(jw)}catch{}}function cq(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 fq(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function dq(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function hq({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(sN,{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(xh,{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:fq(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:dq(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:cq(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(bh,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Hy=20,Wy=80,JS=50;function Dm(t){return Math.min(Wy,Math.max(Hy,t))}function pq({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 b;const p=(b=o.current)==null?void 0:b.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const g=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Dm(g*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(Dm(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Dm(e+d));break;case"Home":f.preventDefault(),n(Hy);break;case"End":f.preventDefault(),n(Wy);break;case"Enter":case" ":f.preventDefault(),n(JS);break}};return E.jsxs("div",{ref:o,className:pr("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:pr("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":Hy,"aria-valuemax":Wy,"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(JS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:pr("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:pr("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 gq({theme:t}){return t==="dark"?E.jsx(xN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(cN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function mq({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(gq,{theme:t})})]})}function yq(t){return[...t].sort((e,n)=>n.id-e.id)}const TR=[{id:21,date:"2026-10-20",tag:"new",title:"Paste Markdown & CLI box tables directly into CSV → JSON",summary:"Paste GitHub/ChatGPT Markdown pipe tables or psql/MySQL ASCII box tables directly into CSV → JSON: divider rows, outer pipes, and (N rows) footers are stripped automatically, with a one-click Clean table action to normalize the raw CSV in place."},{id:20,date:"2026-10-20",tag:"new",title:"One-click nested JSON flattening in JSON → CSV",summary:"When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click."},{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],vq=864e5;function QS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function wq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((QS(r)-QS(n))/vq);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 ER="csvjson:changelog.v1",qd=Math.max(...TR.map(t=>t.id),0),bq=yq(TR);function xq(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&&!kq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function kq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function AR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=qd).sort((e,n)=>e-n)}function ZS(t,e,n){const r=AR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function Sq(){try{const t=window.localStorage.getItem(ER);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return xq(e)?{...e,pendingIds:AR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function Cq(t){try{window.localStorage.setItem(ER,JSON.stringify(t))}catch{}}function Tq(){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 Eq(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 eC(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 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:wq(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:eC(e===1),children:E.jsx(AN,{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:eC(e===-1),children:E.jsx(TN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function Mq(){const[t,e]=v.useState(Sq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(x=>{Cq(x),i.current=x,e(x)},[]),[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&&qd>t.lastSeenId,h=v.useCallback((x,S)=>{l(T=>{const A=new Set(T);return S?A.add(x):A.delete(x),A})},[]),p=v.useCallback((x,S,T,A)=>{const M=(f.current.get(x)??0)+1;f.current.set(x,M),a.current.add(x),A&&h(x,!0),Eq(T,x,S).then(O=>{f.current.get(x)===M&&(a.current.delete(x),O==="ok"&&(LI({entry_id:x,vote:S}),s(ZS(i.current,x,!1))),A&&h(x,!1))})},[s,h]),g=v.useCallback(x=>{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===x||a.current.has(O))continue;const D=A[O];D!==void 0&&p(O,D,S,!1)}},[p]),b=(x,S)=>{if(t.votes[x]===S){g();return}const T=t.clientId??Tq();s(ZS({...t,votes:{...t.votes,[x]:S},clientId:T},x,!0)),p(x,S,T,!0),g(x)},m=()=>{r(!0),DI(),t.lastSeenId!==qd&&s({...t,lastSeenId:qd}),g()},y=v.useCallback(()=>{r(!1)},[]),w=v.useRef(!1);v.useEffect(()=>{var x;w.current&&!n&&((x=c.current)==null||x.focus()),w.current=n},[n]);const k=v.useRef(!1);return v.useEffect(()=>{k.current||(k.current=!0,g())},[g]),v.useEffect(()=>{if(!n)return;const x=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",x),document.addEventListener("click",S),()=>{document.removeEventListener("keydown",x),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():m(),"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(pN,{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(xh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:bq.map(x=>{var S;return E.jsx(Aq,{entry:x,vote:t.votes[x.id],queued:((S=t.pendingIds)==null?void 0:S.includes(x.id))??!1,inFlight:o.has(x.id),onVote:b},x.id)})})]})]})}function Rq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const Oq={},Pq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],Iq=["csv2json","json2csv","csvjson2json"];function Nq(t){return Iq.includes(t)}const _q=/^[0-9a-f]{32}$/i,Dq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Lm=Oq,Lq=((Lm==null?void 0:Lm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function $q(t){const e=Dq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return Pq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class Vy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class $m extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Fm={csv:(t,e)=>{t.direction="csv2json",t.input=rp(e)},json:(t,e)=>{t.input=rp(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 rp(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function tC(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 Fq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Bq(t){var i;if(!Fq(t))return null;const e=tC(t.csv),n=tC(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Fm[s])==null||i.call(Fm,r,o);return r.input=rp(e?t.csv:t.json),r}async function zq(t){if(!_q.test(t))throw new Vy;let e;try{e=await fetch(`${Lq}${t}`,{mode:"cors"})}catch(r){throw new $m("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new Vy;if(!e.ok)throw new $m(`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 $m("Stored data for this link is malformed")}return n}function jq(t){const e=v.useMemo(()=>t&&Nq(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 zq(e).then(f=>{if(c)return;const d=Bq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof Vy?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 nC(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 Hq="\uFEFF";function Wq(t,e){return e?Hq+t:t}function Vq(t,e,n){const r=Wq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Uq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Kq(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(!Uq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function Xq(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Kq(t)}.${r}`:`data.${r}`}function Gq(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 rC(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Vq(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 qq(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 Yq=`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`,Jq=`[ + { + "album": "Elephant", + "year": 2003, + "label": "XL Recordings" + }, + { + "album": "Icky Thump", + "year": 2007, + "label": "XL Recordings" + } +]`,MR="csvjson-theme";function Qq(){try{const t=localStorage.getItem(MR);return t==="dark"||t==="light"?t:null}catch{return null}}function Zq(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function eY(){return Qq()??Zq()}function tY(t){try{localStorage.setItem(MR,t)}catch{}}function nY(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const iC=2*1024*1024,rY=150,iY=1e3,sY=2e3,oY=2e3;function lY(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function sC(t){try{return JSON.parse(t),!0}catch{return!1}}function aY(){var pn;const[t,e]=v.useState(eY);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(ne=>{const De=ne==="dark"?"light":"dark";return tY(De),De}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":nY(window.location.search)),[s,o]=v.useState(()=>qo("")),l=s.present,[a,u]=v.useState(Br),[c,f]=v.useState("json"),[d,h]=v.useState(50),[p,g]=v.useState(null),[b,m]=v.useState(!1),[y,w]=v.useState(null),[k,x]=v.useState("utf-8"),[S,T]=v.useState(Hw),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=VI({settleMs:sY,minWindowMs:oY,isValid:(ne,De)=>{const ze=A.current;return De===ze.input?ze.resultOk:to(ne==="csv_to_json"?"csv2json":"json2csv",De,ze.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=gR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",_=I?"CSV":"JSON",te=I?"JSON":"CSV",ie=l.trim()==="",Z=l.length>iC?iY:rY,W=Rq(l,ie?0:Z),V=v.useRef(null),R=v.useRef(null),L=l!==""&&((pn=V.current)==null?void 0:pn.text)===l?l:W,z=v.useMemo(()=>typeof window>"u"?null:$q(window.location.pathname),[]),G=jq(z),B=v.useMemo(()=>to(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const ne=R.current;!ne||ne.text!==L||(R.current=null,O.discrete(ne.direction,ne.via,ne.text))},[L,B,O]);const[me,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(YS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const ve=L.trim()!==""&&B.ok?B.text:me,[Ne,se]=v.useState(!1),[_e,$e]=v.useState(null),Fe=Ne?_e:ve,qe=v.useMemo(()=>{if(!I||Fe===null||c==="json")return Fe;const ne=Ne&&_e!==null&&sC(_e)?_e:ve;return ne===null?null:QG(ne,c,a,p)},[I,Fe,c,Ne,_e,ve,a,p]),it=I&&c==="json"&&!ie&&qe!==null&&(Ne||B.ok),Wt=v.useCallback(ne=>{if(ne===ve){se(!1),$e(null);return}se(!0),$e(ne)},[ve]),Ie=v.useCallback(()=>{const ne=to(r,l,a);ne.ok&&le(ne.text),se(!1),$e(null)},[r,l,a]),be=v.useCallback(ne=>{o(De=>I?nk(De,ne):qo(ne))},[I]),tt=I&&s.past.length>0,nt=I&&s.future.length>0,lt=v.useCallback(()=>{if(!I||s.past.length===0)return;const ne=L9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),Ve=v.useCallback(()=>{if(!I||s.future.length===0)return;const ne=$9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),kt=v.useCallback(ne=>{w(null),V.current=null,i(ne.direction),u({...ne.options}),g(ne.filename),se(!1),$e(null),o(De=>ne.direction==="csv2json"&&r==="csv2json"?nk(De,ne.input):qo(ne.input)),T(YS({direction:ne.direction,input:ne.input,options:ne.options,filename:ne.filename,rows:ne.rows,cols:ne.cols}))},[r]),wt=v.useCallback(ne=>{T(aq(ne))},[]),bt=v.useCallback(()=>{uq(),T([])},[]),fe=()=>{const ne=r==="csv2json"?"json2csv":"csv2json";if(Ne){const De=_e??"",ze=sC(De)?De:l;o(qo(ze)),i(ne),se(!1),$e(null),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:to(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(ne),ie)o(qo(""));else{const De=to(r,l,a),ze=De.ok?De.text:l;o(qo(ze)),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:to(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},Le=G.hydrated;v.useEffect(()=>{if(Le===null)return;const ne={...A.current.options,...Le.options};A.current={direction:Le.direction,options:ne,input:Le.input,resultOk:to(Le.direction,Le.input,ne).ok},i(Le.direction),o(qo(Le.input)),u(De=>({...De,...Le.options})),se(!1),$e(null),_I(),O.discrete(Le.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",Le.input)},[Le,O]);const Ye=async(ne,De)=>{if(!FG(ne)){w(`Can't read "${ne.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),m(!0);try{const ze=await WS(ne,k);V.current={file:ne,source:De,text:ze},R.current={direction:I?"csv_to_json":"json_to_csv",via:De==="drop"?"drag":"file",text:ze},be(ze),g(ne.name),m(!1)}catch{m(!1),w(`Couldn't read "${ne.name}".`)}},Be=async ne=>{const De=k;x(ne);const ze=V.current;if(!(!ze||l!==ze.text)){m(!0);try{const Rn=await WS(ze.file,ne);V.current={...ze,text:Rn},R.current={direction:I?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:Rn},o(pt=>({...pt,present:Rn})),m(!1)}catch{m(!1),x(De),w(`Couldn't read "${ze.file.name}".`)}}},Xt=v.useCallback(ne=>{w(null),ne.trim()===""&&u(De=>{if(!De.columnTypes)return De;const ze={...De};return delete ze.columnTypes,ze}),be(ne),O.edit(I?"csv_to_json":"json_to_csv",ne)},[be,I,O]);v.useEffect(()=>{const ne=De=>{var Rn;const ze=(Rn=De.clipboardData)==null?void 0:Rn.getData("text/plain");!ze||qq(De.target)||(De.preventDefault(),De.stopPropagation(),g(null),Xt(ze))};return document.addEventListener("paste",ne,!0),()=>document.removeEventListener("paste",ne,!0)},[Xt]);const dt=B.ok?lY(B.rows,B.cols):null,at=!B.ok&&me?"Last valid result — input has errors":null,ht=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Vt=l.length>iC,St=I?"csv_to_json":"json_to_csv",_n=I?c:"csv",cn=()=>{Ko({via:"copy",format:I?"csv":"json",pane:"input",direction:St}),nC(l)},Ut=()=>{Ko({via:"copy",format:_n,pane:"output",direction:St}),qe&&nC(qe)},on=()=>{Ko({via:"download",format:I?"csv":"json",pane:"input",direction:St}),rC(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},bn=()=>{Ko({via:"download",format:_n,pane:"output",direction:St}),rC(qe??"",Xq(p,I?"csv2json":"json2csv",c),{mime:Gq(I?"csv2json":"json2csv",c),bom:!I})},Pr=v.useCallback(()=>{Ko({via:"copy",format:"csv",pane:"input",direction:St})},[St]),Ir=v.useCallback(()=>{Ko({via:"copy",format:"csv",pane:"output",direction:St})},[St]),Bt=v.useCallback(()=>{Ko({via:"copy",format:_n,pane:"output",direction:St})},[_n,St]),ct=E.jsx(LG,{format:_,input:l,onInputChange:Xt,onCellCommit:Xt,onFile:Ye,onTryExample:()=>{w(null);const ne=I?Yq:Jq;A.current={direction:r,options:a,input:ne,resultOk:to(r,ne,a).ok},be(ne),O.discrete(St,"example",ne)},onClear:()=>{be(""),g(null),u(ne=>{if(!ne.columnTypes)return ne;const De={...ne};return delete De.columnTypes,De}),se(!1),$e(null),O.cancel()},onCopy:cn,onCopySelection:Pr,onDownload:on,canUndo:tt,canRedo:nt,onUndo:lt,onRedo:Ve,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(ne=>({...ne,collapseIndexedArrays:!(ne.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:ne=>u(De=>{const ze={...De};return Object.keys(ne).length>0?ze.columnTypes=ne:delete ze.columnTypes,ze}),flatten:a.flatten,onToggleFlatten:()=>u(ne=>({...ne,flatten:!ne.flatten})),filename:p,reading:b,meta:dt,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),ft=E.jsx(tq,{format:te,inputEmpty:ie,outputText:qe,error:B.ok?null:B.error,meta:dt,staleNotice:at,warnings:ht,edited:Ne,editable:it,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Ut,onCopySelection:Ir,onNativeCopy:Bt,onDownload:bn,onEgressFormatChange:f,onOutputChange:Wt,onRevert:Ie,onDiscardReconvert:Ie});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(m_,{}),E.jsx(mq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(hq,{snapshots:S,onSelect:kt,onRemove:wt,onClear:bt}),E.jsx(Mq,{}),E.jsx(x_,{})]})}),z&&(G.phase==="loading"||G.phase==="not-found"||G.phase==="unsupported"||G.phase==="error")?E.jsx(nq,{phase:G.phase,message:G.phase==="error"?G.message:void 0,onRetry:G.retry}):null,E.jsx(pq,{layout:P,split:d,onSplitChange:h,left:ct,right:ft,children:E.jsx(d_,{direction:r,onFlip:fe})}),E.jsx(jG,{direction:r,options:a,onChange:ne=>u(De=>({...De,...ne})),uploadEncoding:k,onUploadEncodingChange:Be,notice:Vt?"Large file — converting on pause":null})]}),E.jsx(p_,{})]})}vT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(aY,{})}));document.getElementById("root").removeAttribute("inert");II();NI();export{c6 as C,$n as R,D4 as T,ca as a,l$ as b,OI as c,ql as i,_4 as m,v as r,Jr as s}; diff --git a/app/dist/assets/index-BweuKm2D.js b/app/dist/assets/index-BweuKm2D.js deleted file mode 100644 index 0df6415..0000000 --- a/app/dist/assets/index-BweuKm2D.js +++ /dev/null @@ -1,307 +0,0 @@ -var GR=Object.defineProperty;var qR=(t,e,n)=>e in t?GR(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var bt=(t,e,n)=>qR(t,typeof e!="symbol"?e+"":e,n);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();var fo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ji(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var QS={exports:{}},Qh={},ZS={exports:{}},Et={};/** - * @license React - * react.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var jc=Symbol.for("react.element"),YR=Symbol.for("react.portal"),JR=Symbol.for("react.fragment"),QR=Symbol.for("react.strict_mode"),ZR=Symbol.for("react.profiler"),eO=Symbol.for("react.provider"),tO=Symbol.for("react.context"),nO=Symbol.for("react.forward_ref"),rO=Symbol.for("react.suspense"),iO=Symbol.for("react.memo"),sO=Symbol.for("react.lazy"),t1=Symbol.iterator;function oO(t){return t===null||typeof t!="object"?null:(t=t1&&t[t1]||t["@@iterator"],typeof t=="function"?t:null)}var eC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tC=Object.assign,nC={};function Ka(t,e,n){this.props=t,this.context=e,this.refs=nC,this.updater=n||eC}Ka.prototype.isReactComponent={};Ka.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Ka.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function rC(){}rC.prototype=Ka.prototype;function By(t,e,n){this.props=t,this.context=e,this.refs=nC,this.updater=n||eC}var jy=By.prototype=new rC;jy.constructor=By;tC(jy,Ka.prototype);jy.isPureReactComponent=!0;var n1=Array.isArray,iC=Object.prototype.hasOwnProperty,Hy={current:null},sC={key:!0,ref:!0,__self:!0,__source:!0};function oC(t,e,n){var r,i={},s=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(s=""+e.key),e)iC.call(e,r)&&!sC.hasOwnProperty(r)&&(i[r]=e[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1>>1,L=W[N];if(0>>1;Ni(B,R))lei(me,B)?(W[N]=me,W[le]=R,N=le):(W[N]=B,W[G]=R,N=G);else if(lei(me,R))W[N]=me,W[le]=R,N=le;else break e}}return V}function i(W,V){var R=W.sortIndex-V.sortIndex;return R!==0?R:W.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var a=[],u=[],c=1,f=null,d=3,h=!1,p=!1,m=!1,x=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(W){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=W)r(u),V.sortIndex=V.expirationTime,e(a,V);else break;V=n(u)}}function k(W){if(m=!1,w(W),!p)if(n(a)!==null)p=!0,ie(b);else{var V=n(u);V!==null&&te(k,V.startTime-W)}}function b(W,V){p=!1,m&&(m=!1,g(A),A=-1),h=!0;var R=d;try{for(w(V),f=n(a);f!==null&&(!(f.expirationTime>V)||W&&!_());){var N=f.callback;if(typeof N=="function"){f.callback=null,d=f.priorityLevel;var L=N(f.expirationTime<=V);V=t.unstable_now(),typeof L=="function"?f.callback=L:f===n(a)&&r(a),w(V)}else r(a);f=n(a)}if(f!==null)var H=!0;else{var G=n(u);G!==null&&te(k,G.startTime-V),H=!1}return H}finally{f=null,d=R,h=!1}}var S=!1,T=null,A=-1,M=5,O=-1;function _(){return!(t.unstable_now()-OW||125N?(W.sortIndex=R,e(u,W),n(a)===null&&W===n(u)&&(m?(g(A),A=-1):m=!0,te(k,R-N))):(W.sortIndex=L,e(a,W),p||h||(p=!0,ie(b))),W},t.unstable_shouldYield=_,t.unstable_wrapCallback=function(W){var V=d;return function(){var R=d;d=V;try{return W.apply(this,arguments)}finally{d=R}}}})(fC);cC.exports=fC;var yO=cC.exports;/** - * @license React - * react-dom.production.min.js - * - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */var vO=v,Gr=yO;function pe(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Dm=Object.prototype.hasOwnProperty,wO=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,i1={},s1={};function xO(t){return Dm.call(s1,t)?!0:Dm.call(i1,t)?!1:wO.test(t)?s1[t]=!0:(i1[t]=!0,!1)}function bO(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function kO(t,e,n,r){if(e===null||typeof e>"u"||bO(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function vr(t,e,n,r,i,s,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=s,this.removeEmptyString=o}var Gn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Gn[t]=new vr(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];Gn[e]=new vr(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Gn[t]=new vr(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Gn[t]=new vr(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){Gn[t]=new vr(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Gn[t]=new vr(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Gn[t]=new vr(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Gn[t]=new vr(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Gn[t]=new vr(t,5,!1,t.toLowerCase(),null,!1,!1)});var Vy=/[\-:]([a-z])/g;function Uy(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Vy,Uy);Gn[e]=new vr(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Gn[t]=new vr(t,1,!1,t.toLowerCase(),null,!1,!1)});Gn.xlinkHref=new vr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Gn[t]=new vr(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ky(t,e,n,r){var i=Gn.hasOwnProperty(e)?Gn[e]:null;(i!==null?i.type!==0:r||!(2l||i[o]!==s[l]){var a=` -`+i[o].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=o&&0<=l);break}}}finally{fg=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Lu(t):""}function SO(t){switch(t.tag){case 5:return Lu(t.type);case 16:return Lu("Lazy");case 13:return Lu("Suspense");case 19:return Lu("SuspenseList");case 0:case 2:case 15:return t=dg(t.type,!1),t;case 11:return t=dg(t.type.render,!1),t;case 1:return t=dg(t.type,!0),t;default:return""}}function $m(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case Zl:return"Fragment";case Ql:return"Portal";case _m:return"Profiler";case Xy:return"StrictMode";case Lm:return"Suspense";case Fm:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case pC:return(t.displayName||"Context")+".Consumer";case hC:return(t._context.displayName||"Context")+".Provider";case Gy:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case qy:return e=t.displayName||null,e!==null?e:$m(t.type)||"Memo";case ro:e=t._payload,t=t._init;try{return $m(t(e))}catch{}}return null}function CO(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return $m(e);case 8:return e===Xy?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Eo(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function mC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function TO(t){var e=mC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(o){r=""+o,s.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Rf(t){t._valueTracker||(t._valueTracker=TO(t))}function yC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=mC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Vd(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function zm(t,e){var n=e.checked;return fn({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function l1(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Eo(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function vC(t,e){e=e.checked,e!=null&&Ky(t,"checked",e,!1)}function Bm(t,e){vC(t,e);var n=Eo(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?jm(t,e.type,n):e.hasOwnProperty("defaultValue")&&jm(t,e.type,Eo(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function a1(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function jm(t,e,n){(e!=="number"||Vd(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Fu=Array.isArray;function ma(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=Of.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function pc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Vu={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},EO=["Webkit","ms","Moz","O"];Object.keys(Vu).forEach(function(t){EO.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Vu[e]=Vu[t]})});function kC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Vu.hasOwnProperty(t)&&Vu[t]?(""+e).trim():e+"px"}function SC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=kC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var AO=fn({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Vm(t,e){if(e){if(AO[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(pe(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(pe(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(pe(61))}if(e.style!=null&&typeof e.style!="object")throw Error(pe(62))}}function Um(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Km=null;function Yy(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Xm=null,ya=null,va=null;function f1(t){if(t=Vc(t)){if(typeof Xm!="function")throw Error(pe(280));var e=t.stateNode;e&&(e=rp(e),Xm(t.stateNode,t.type,e))}}function CC(t){ya?va?va.push(t):va=[t]:ya=t}function TC(){if(ya){var t=ya,e=va;if(va=ya=null,f1(t),e)for(t=0;t>>=0,t===0?32:31-($O(t)/zO|0)|0}var Pf=64,If=4194304;function $u(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Gd(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,s=t.pingedLanes,o=n&268435455;if(o!==0){var l=o&~i;l!==0?r=$u(l):(s&=o,s!==0&&(r=$u(s)))}else o=n&~i,o!==0?r=$u(o):s!==0&&(r=$u(s));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,s=e&-e,i>=s||i===16&&(s&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function Hc(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-Fi(e),t[e]=n}function WO(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Ku),x1=" ",b1=!1;function UC(t,e){switch(t){case"keyup":return yP.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function KC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ea=!1;function wP(t,e){switch(t){case"compositionend":return KC(e);case"keypress":return e.which!==32?null:(b1=!0,x1);case"textInput":return t=e.data,t===x1&&b1?null:t;default:return null}}function xP(t,e){if(ea)return t==="compositionend"||!iv&&UC(t,e)?(t=WC(),Td=tv=ho=null,ea=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=T1(n)}}function YC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?YC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function JC(){for(var t=window,e=Vd();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Vd(t.document)}return e}function sv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function RP(t){var e=JC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&YC(n.ownerDocument.documentElement,n)){if(r!==null&&sv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!t.extend&&s>r&&(i=r,r=s,s=i),i=E1(n,s);var o=E1(n,r);i&&o&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),s>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,ta=null,Zm=null,Gu=null,e0=!1;function A1(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;e0||ta==null||ta!==Vd(r)||(r=ta,"selectionStart"in r&&sv(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Gu&&xc(Gu,r)||(Gu=r,r=Jd(Zm,"onSelect"),0ia||(t.current=o0[ia],o0[ia]=null,ia--)}function Zt(t,e){ia++,o0[ia]=t.current,t.current=e}var Ao={},or=Do(Ao),Ar=Do(!1),pl=Ao;function Ra(t,e){var n=t.type.contextTypes;if(!n)return Ao;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=e[s];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function Mr(t){return t=t.childContextTypes,t!=null}function Zd(){sn(Ar),sn(or)}function D1(t,e,n){if(or.current!==Ao)throw Error(pe(168));Zt(or,e),Zt(Ar,n)}function o2(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(pe(108,CO(t)||"Unknown",i));return fn({},n,r)}function eh(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ao,pl=or.current,Zt(or,t),Zt(Ar,Ar.current),!0}function _1(t,e,n){var r=t.stateNode;if(!r)throw Error(pe(169));n?(t=o2(t,e,pl),r.__reactInternalMemoizedMergedChildContext=t,sn(Ar),sn(or),Zt(or,t)):sn(Ar),Zt(Ar,n)}var Ts=null,ip=!1,Eg=!1;function l2(t){Ts===null?Ts=[t]:Ts.push(t)}function jP(t){ip=!0,l2(t)}function _o(){if(!Eg&&Ts!==null){Eg=!0;var t=0,e=Wt;try{var n=Ts;for(Wt=1;t>=o,i-=o,Os=1<<32-Fi(e)+i|n<A?(M=T,T=null):M=T.sibling;var O=d(g,T,w[A],k);if(O===null){T===null&&(T=M);break}t&&T&&O.alternate===null&&e(g,T),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O,T=M}if(A===w.length)return n(g,T),an&&Jo(g,A),b;if(T===null){for(;AA?(M=T,T=null):M=T.sibling;var _=d(g,T,O.value,k);if(_===null){T===null&&(T=M);break}t&&T&&_.alternate===null&&e(g,T),y=s(_,y,A),S===null?b=_:S.sibling=_,S=_,T=M}if(O.done)return n(g,T),an&&Jo(g,A),b;if(T===null){for(;!O.done;A++,O=w.next())O=f(g,O.value,k),O!==null&&(y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return an&&Jo(g,A),b}for(T=r(g,T);!O.done;A++,O=w.next())O=h(T,g,A,O.value,k),O!==null&&(t&&O.alternate!==null&&T.delete(O.key===null?A:O.key),y=s(O,y,A),S===null?b=O:S.sibling=O,S=O);return t&&T.forEach(function(P){return e(g,P)}),an&&Jo(g,A),b}function x(g,y,w,k){if(typeof w=="object"&&w!==null&&w.type===Zl&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Mf:e:{for(var b=w.key,S=y;S!==null;){if(S.key===b){if(b=w.type,b===Zl){if(S.tag===7){n(g,S.sibling),y=i(S,w.props.children),y.return=g,g=y;break e}}else if(S.elementType===b||typeof b=="object"&&b!==null&&b.$$typeof===ro&&$1(b)===S.type){n(g,S.sibling),y=i(S,w.props),y.ref=bu(g,S,w),y.return=g,g=y;break e}n(g,S);break}else e(g,S);S=S.sibling}w.type===Zl?(y=fl(w.props.children,g.mode,k,w.key),y.return=g,g=y):(k=Nd(w.type,w.key,w.props,null,g.mode,k),k.ref=bu(g,y,w),k.return=g,g=k)}return o(g);case Ql:e:{for(S=w.key;y!==null;){if(y.key===S)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(g,y.sibling),y=i(y,w.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else e(g,y);y=y.sibling}y=Dg(w,g.mode,k),y.return=g,g=y}return o(g);case ro:return S=w._init,x(g,y,S(w._payload),k)}if(Fu(w))return p(g,y,w,k);if(mu(w))return m(g,y,w,k);zf(g,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(g,y.sibling),y=i(y,w),y.return=g,g=y):(n(g,y),y=Ng(w,g.mode,k),y.return=g,g=y),o(g)):n(g,y)}return x}var Pa=f2(!0),d2=f2(!1),rh=Do(null),ih=null,la=null,uv=null;function cv(){uv=la=ih=null}function fv(t){var e=rh.current;sn(rh),t._currentValue=e}function u0(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function xa(t,e){ih=t,uv=la=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(Tr=!0),t.firstContext=null)}function hi(t){var e=t._currentValue;if(uv!==t)if(t={context:t,memoizedValue:e,next:null},la===null){if(ih===null)throw Error(pe(308));la=t,ih.dependencies={lanes:0,firstContext:t}}else la=la.next=t;return e}var ol=null;function dv(t){ol===null?ol=[t]:ol.push(t)}function h2(t,e,n,r){var i=e.interleaved;return i===null?(n.next=n,dv(e)):(n.next=i.next,i.next=n),e.interleaved=n,Fs(t,r)}function Fs(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var io=!1;function hv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function p2(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Ns(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function bo(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,_t&2){var i=r.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),r.pending=e,Fs(t,n)}return i=r.interleaved,i===null?(e.next=e,dv(r)):(e.next=i.next,i.next=e),r.interleaved=e,Fs(t,n)}function Ad(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}function z1(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=o:s=s.next=o,n=n.next}while(n!==null);s===null?i=s=e:s=s.next=e}else i=s=e;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function sh(t,e,n,r){var i=t.updateQueue;io=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var a=l,u=a.next;a.next=null,o===null?s=u:o.next=u,o=a;var c=t.alternate;c!==null&&(c=c.updateQueue,l=c.lastBaseUpdate,l!==o&&(l===null?c.firstBaseUpdate=u:l.next=u,c.lastBaseUpdate=a))}if(s!==null){var f=i.baseState;o=0,c=u=a=null,l=s;do{var d=l.lane,h=l.eventTime;if((r&d)===d){c!==null&&(c=c.next={eventTime:h,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var p=t,m=l;switch(d=e,h=n,m.tag){case 1:if(p=m.payload,typeof p=="function"){f=p.call(h,f,d);break e}f=p;break e;case 3:p.flags=p.flags&-65537|128;case 0:if(p=m.payload,d=typeof p=="function"?p.call(h,f,d):p,d==null)break e;f=fn({},f,d);break e;case 2:io=!0}}l.callback!==null&&l.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else h={eventTime:h,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},c===null?(u=c=h,a=f):c=c.next=h,o|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(c===null&&(a=f),i.baseState=a,i.firstBaseUpdate=u,i.lastBaseUpdate=c,e=i.shared.interleaved,e!==null){i=e;do o|=i.lane,i=i.next;while(i!==e)}else s===null&&(i.shared.lanes=0);yl|=o,t.lanes=o,t.memoizedState=f}}function B1(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;en?n:4,t(!0);var r=Mg.transition;Mg.transition={};try{t(!1),e()}finally{Wt=n,Mg.transition=r}}function P2(){return pi().memoizedState}function UP(t,e,n){var r=So(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},I2(t))N2(e,n);else if(n=h2(t,e,n,r),n!==null){var i=pr();$i(n,t,r,i),D2(n,e,r)}}function KP(t,e,n){var r=So(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(I2(t))N2(e,i);else{var s=t.alternate;if(t.lanes===0&&(s===null||s.lanes===0)&&(s=e.lastRenderedReducer,s!==null))try{var o=e.lastRenderedState,l=s(o,n);if(i.hasEagerState=!0,i.eagerState=l,zi(l,o)){var a=e.interleaved;a===null?(i.next=i,dv(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=h2(t,e,i,r),n!==null&&(i=pr(),$i(n,t,r,i),D2(n,e,r))}}function I2(t){var e=t.alternate;return t===cn||e!==null&&e===cn}function N2(t,e){qu=lh=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function D2(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Qy(t,n)}}var ah={readContext:hi,useCallback:Zn,useContext:Zn,useEffect:Zn,useImperativeHandle:Zn,useInsertionEffect:Zn,useLayoutEffect:Zn,useMemo:Zn,useReducer:Zn,useRef:Zn,useState:Zn,useDebugValue:Zn,useDeferredValue:Zn,useTransition:Zn,useMutableSource:Zn,useSyncExternalStore:Zn,useId:Zn,unstable_isNewReconciler:!1},XP={readContext:hi,useCallback:function(t,e){return Zi().memoizedState=[t,e===void 0?null:e],t},useContext:hi,useEffect:H1,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Rd(4194308,4,E2.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Rd(4194308,4,t,e)},useInsertionEffect:function(t,e){return Rd(4,2,t,e)},useMemo:function(t,e){var n=Zi();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Zi();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=UP.bind(null,cn,t),[r.memoizedState,t]},useRef:function(t){var e=Zi();return t={current:t},e.memoizedState=t},useState:j1,useDebugValue:bv,useDeferredValue:function(t){return Zi().memoizedState=t},useTransition:function(){var t=j1(!1),e=t[0];return t=VP.bind(null,t[1]),Zi().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=cn,i=Zi();if(an){if(n===void 0)throw Error(pe(407));n=n()}else{if(n=e(),jn===null)throw Error(pe(349));ml&30||v2(r,e,n)}i.memoizedState=n;var s={value:n,getSnapshot:e};return i.queue=s,H1(x2.bind(null,r,s,t),[t]),r.flags|=2048,Mc(9,w2.bind(null,r,s,n,e),void 0,null),n},useId:function(){var t=Zi(),e=jn.identifierPrefix;if(an){var n=Ps,r=Os;n=(r&~(1<<32-Fi(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Ec++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[es]=e,t[Sc]=r,V2(t,e,!1,!1),e.stateNode=t;e:{switch(o=Um(n,r),n){case"dialog":nn("cancel",t),nn("close",t),i=r;break;case"iframe":case"object":case"embed":nn("load",t),i=r;break;case"video":case"audio":for(i=0;iDa&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304)}else{if(!r)if(t=oh(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),ku(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!an)return er(e),null}else 2*Cn()-s.renderingStartTime>Da&&n!==1073741824&&(e.flags|=128,r=!0,ku(s,!1),e.lanes=4194304);s.isBackwards?(o.sibling=e.child,e.child=o):(n=s.last,n!==null?n.sibling=o:e.child=o,s.last=o)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Cn(),e.sibling=null,n=un.current,Zt(un,r?n&1|2:n&1),e):(er(e),null);case 22:case 23:return Av(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Br&1073741824&&(er(e),e.subtreeFlags&6&&(e.flags|=8192)):er(e),null;case 24:return null;case 25:return null}throw Error(pe(156,e.tag))}function tI(t,e){switch(lv(e),e.tag){case 1:return Mr(e.type)&&Zd(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ia(),sn(Ar),sn(or),mv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return gv(e),null;case 13:if(sn(un),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(pe(340));Oa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return sn(un),null;case 4:return Ia(),null;case 10:return fv(e.type._context),null;case 22:case 23:return Av(),null;case 24:return null;default:return null}}var jf=!1,ir=!1,nI=typeof WeakSet=="function"?WeakSet:Set,Ne=null;function aa(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){pn(t,e,r)}else n.current=null}function v0(t,e,n){try{n()}catch(r){pn(t,e,r)}}var Z1=!1;function rI(t,e){if(t0=qd,t=JC(),sv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var o=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var h;f!==n||i!==0&&f.nodeType!==3||(l=o+i),f!==s||r!==0&&f.nodeType!==3||(a=o+r),f.nodeType===3&&(o+=f.nodeValue.length),(h=f.firstChild)!==null;)d=f,f=h;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=o),d===s&&++c===r&&(a=o),(h=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=h}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(n0={focusedElem:t,selectionRange:n},qd=!1,Ne=e;Ne!==null;)if(e=Ne,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ne=t;else for(;Ne!==null;){e=Ne;try{var p=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(p!==null){var m=p.memoizedProps,x=p.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:Ai(e.type,m),x);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(pe(163))}}catch(k){pn(e,e.return,k)}if(t=e.sibling,t!==null){t.return=e.return,Ne=t;break}Ne=e.return}return p=Z1,Z1=!1,p}function Yu(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var s=i.destroy;i.destroy=void 0,s!==void 0&&v0(e,n,s)}i=i.next}while(i!==r)}}function lp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function w0(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function X2(t){var e=t.alternate;e!==null&&(t.alternate=null,X2(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[es],delete e[Sc],delete e[s0],delete e[zP],delete e[BP])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function G2(t){return t.tag===5||t.tag===3||t.tag===4}function ex(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||G2(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function x0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Qd));else if(r!==4&&(t=t.child,t!==null))for(x0(t,e,n),t=t.sibling;t!==null;)x0(t,e,n),t=t.sibling}function b0(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(b0(t,e,n),t=t.sibling;t!==null;)b0(t,e,n),t=t.sibling}var Wn=null,Mi=!1;function Gs(t,e,n){for(n=n.child;n!==null;)q2(t,e,n),n=n.sibling}function q2(t,e,n){if(us&&typeof us.onCommitFiberUnmount=="function")try{us.onCommitFiberUnmount(Zh,n)}catch{}switch(n.tag){case 5:ir||aa(n,e);case 6:var r=Wn,i=Mi;Wn=null,Gs(t,e,n),Wn=r,Mi=i,Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Wn.removeChild(n.stateNode));break;case 18:Wn!==null&&(Mi?(t=Wn,n=n.stateNode,t.nodeType===8?Tg(t.parentNode,n):t.nodeType===1&&Tg(t,n),vc(t)):Tg(Wn,n.stateNode));break;case 4:r=Wn,i=Mi,Wn=n.stateNode.containerInfo,Mi=!0,Gs(t,e,n),Wn=r,Mi=i;break;case 0:case 11:case 14:case 15:if(!ir&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&v0(n,e,o),i=i.next}while(i!==r)}Gs(t,e,n);break;case 1:if(!ir&&(aa(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){pn(n,e,l)}Gs(t,e,n);break;case 21:Gs(t,e,n);break;case 22:n.mode&1?(ir=(r=ir)||n.memoizedState!==null,Gs(t,e,n),ir=r):Gs(t,e,n);break;default:Gs(t,e,n)}}function tx(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new nI),e.forEach(function(r){var i=dI.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Ci(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=o),r&=~s}if(r=i,r=Cn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*sI(r/1960))-r,10t?16:t,po===null)var r=!1;else{if(t=po,po=null,fh=0,_t&6)throw Error(pe(331));var i=_t;for(_t|=4,Ne=t.current;Ne!==null;){var s=Ne,o=s.child;if(Ne.flags&16){var l=s.deletions;if(l!==null){for(var a=0;aCn()-Tv?cl(t,0):Cv|=n),Rr(t,e)}function rT(t,e){e===0&&(t.mode&1?(e=If,If<<=1,!(If&130023424)&&(If=4194304)):e=1);var n=pr();t=Fs(t,e),t!==null&&(Hc(t,e,n),Rr(t,n))}function fI(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),rT(t,n)}function dI(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(pe(314))}r!==null&&r.delete(e),rT(t,n)}var iT;iT=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ar.current)Tr=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Tr=!1,ZP(t,e,n);Tr=!!(t.flags&131072)}else Tr=!1,an&&e.flags&1048576&&a2(e,nh,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Od(t,e),t=e.pendingProps;var i=Ra(e,or.current);xa(e,n),i=vv(null,e,r,t,i,n);var s=wv();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,Mr(r)?(s=!0,eh(e)):s=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,hv(e),i.updater=op,e.stateNode=i,i._reactInternals=e,f0(e,r,t,n),e=p0(null,e,r,!0,s,n)):(e.tag=0,an&&s&&ov(e),fr(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Od(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=pI(r),t=Ai(r,t),i){case 0:e=h0(null,e,r,t,n);break e;case 1:e=Y1(null,e,r,t,n);break e;case 11:e=G1(null,e,r,t,n);break e;case 14:e=q1(null,e,r,Ai(r.type,t),n);break e}throw Error(pe(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),h0(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),Y1(t,e,r,i,n);case 3:e:{if(j2(e),t===null)throw Error(pe(387));r=e.pendingProps,s=e.memoizedState,i=s.element,p2(t,e),sh(e,r,null,n);var o=e.memoizedState;if(r=o.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=s,e.memoizedState=s,e.flags&256){i=Na(Error(pe(423)),e),e=J1(t,e,r,n,i);break e}else if(r!==i){i=Na(Error(pe(424)),e),e=J1(t,e,r,n,i);break e}else for(Kr=xo(e.stateNode.containerInfo.firstChild),Xr=e,an=!0,Ri=null,n=d2(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Oa(),r===i){e=$s(t,e,n);break e}fr(t,e,r,n)}e=e.child}return e;case 5:return g2(e),t===null&&a0(e),r=e.type,i=e.pendingProps,s=t!==null?t.memoizedProps:null,o=i.children,r0(r,i)?o=null:s!==null&&r0(r,s)&&(e.flags|=32),B2(t,e),fr(t,e,o,n),e.child;case 6:return t===null&&a0(e),null;case 13:return H2(t,e,n);case 4:return pv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Pa(e,null,r,n):fr(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),G1(t,e,r,i,n);case 7:return fr(t,e,e.pendingProps,n),e.child;case 8:return fr(t,e,e.pendingProps.children,n),e.child;case 12:return fr(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,s=e.memoizedProps,o=i.value,Zt(rh,r._currentValue),r._currentValue=o,s!==null)if(zi(s.value,o)){if(s.children===i.children&&!Ar.current){e=$s(t,e,n);break e}}else for(s=e.child,s!==null&&(s.return=e);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(s.tag===1){a=Ns(-1,n&-n),a.tag=2;var u=s.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),u0(s.return,n,e),l.lanes|=n;break}a=a.next}}else if(s.tag===10)o=s.type===e.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(pe(341));o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),u0(o,n,e),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===e){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}fr(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,xa(e,n),i=hi(i),r=r(i),e.flags|=1,fr(t,e,r,n),e.child;case 14:return r=e.type,i=Ai(r,e.pendingProps),i=Ai(r.type,i),q1(t,e,r,i,n);case 15:return $2(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:Ai(r,i),Od(t,e),e.tag=1,Mr(r)?(t=!0,eh(e)):t=!1,xa(e,n),_2(e,r,i),f0(e,r,i,n),p0(null,e,r,!0,t,n);case 19:return W2(t,e,n);case 22:return z2(t,e,n)}throw Error(pe(156,e.tag))};function sT(t,e){return IC(t,e)}function hI(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function si(t,e,n,r){return new hI(t,e,n,r)}function Rv(t){return t=t.prototype,!(!t||!t.isReactComponent)}function pI(t){if(typeof t=="function")return Rv(t)?1:0;if(t!=null){if(t=t.$$typeof,t===Gy)return 11;if(t===qy)return 14}return 2}function Co(t,e){var n=t.alternate;return n===null?(n=si(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Nd(t,e,n,r,i,s){var o=2;if(r=t,typeof t=="function")Rv(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case Zl:return fl(n.children,i,s,e);case Xy:o=8,i|=8;break;case _m:return t=si(12,n,e,i|2),t.elementType=_m,t.lanes=s,t;case Lm:return t=si(13,n,e,i),t.elementType=Lm,t.lanes=s,t;case Fm:return t=si(19,n,e,i),t.elementType=Fm,t.lanes=s,t;case gC:return up(n,i,s,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case hC:o=10;break e;case pC:o=9;break e;case Gy:o=11;break e;case qy:o=14;break e;case ro:o=16,r=null;break e}throw Error(pe(130,t==null?t:typeof t,""))}return e=si(o,n,e,i),e.elementType=t,e.type=r,e.lanes=s,e}function fl(t,e,n,r){return t=si(7,t,r,e),t.lanes=n,t}function up(t,e,n,r){return t=si(22,t,r,e),t.elementType=gC,t.lanes=n,t.stateNode={isHidden:!1},t}function Ng(t,e,n){return t=si(6,t,null,e),t.lanes=n,t}function Dg(t,e,n){return e=si(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function gI(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=pg(0),this.expirationTimes=pg(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pg(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Ov(t,e,n,r,i,s,o,l,a){return t=new gI(t,e,n,l,a),e===1?(e=1,s===!0&&(e|=8)):e=0,s=si(3,null,null,e),t.current=s,s.stateNode=t,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hv(s),t}function mI(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(uT)}catch(t){console.error(t)}}uT(),uC.exports=qr;var bI=uC.exports,cT,ux=bI;cT=ux.createRoot,ux.hydrateRoot;function fT(){return""}function kI(){return/^G-[A-Z0-9]+$/.test(fT())}function SI(){const t=window.gtag;typeof t=="function"&&kI()&&t("config",fT(),{send_page_view:!1})}function CI(){var t,e;(t=window.gtag)==null||t.call(window,"event","page_view",{page_path:window.location.pathname,page_location:window.location.href}),(e=window.plausible)==null||e.call(window,"pageview")}function TI(){var t,e;(t=window.gtag)==null||t.call(window,"event","permalink_view"),(e=window.plausible)==null||e.call(window,"Permalink View")}function EI(){var t,e;(t=window.gtag)==null||t.call(window,"event","changelog_open"),(e=window.plausible)==null||e.call(window,"Changelog Open")}function AI(t){var e,n;(e=window.gtag)==null||e.call(window,"event","changelog_vote",{...t}),(n=window.plausible)==null||n.call(window,"Changelog Vote",{props:{...t}})}function MI(t){return t.charAt(0).toUpperCase()+t.slice(1)}function pp(t,e){var n,r;(n=window.gtag)==null||n.call(window,"event",t,{...e}),(r=window.plausible)==null||r.call(window,MI(t),{props:{...e}})}function RI(t){pp("input",t)}function OI(t){pp("conversion",t)}function Uo(t){const e={via:t.via,format:t.format,...t.pane!==void 0?{pane:t.pane}:{},...t.direction!==void 0?{direction:t.direction}:{}};pp("export",e)}function PI(t){pp("feedback",t)}function II(t){return new TextEncoder().encode(t).length}function NI(t){return t<10*1024?"<10KB":t<100*1024?"10-100KB":t<1024*1024?"100KB-1MB":">1MB"}function DI(t){let e=2166136261;for(let n=0;n>>0).toString(36)}function _I(t={}){const e=t.settleMs??2e3,n=t.minWindowMs??2e3,r=t.now??(()=>Date.now()),i=t.isValid??(()=>!0);let s=null,o,l=null,a=0,u=null,c=0;function f(h){if(h.text.trim()==="")return!1;const p=II(h.text),m=NI(p),x=i(h.direction,h.text),g=`${h.direction}:${h.input}:${p}:${DI(h.text)}`,y=r();return g!==l&&(a===0||y-a>=n)&&(l=g,a=y,RI({direction:h.direction,input:h.input,size:m,valid:x})),!x||g===u||c!==0&&y-c{o=void 0,s&&f(s)},e)}return{edit(h,p){s={direction:h,input:"paste",text:p},d()},discrete(h,p,m){s={direction:h,input:p,text:m},d(),f(s)},cancel(){s=null,l=null,u=null,o&&(clearTimeout(o),o=void 0)}}}/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const dT=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const LI=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const FI=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const cx=t=>{const e=FI(t);return e.charAt(0).toUpperCase()+e.slice(1)};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */var _g={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const $I=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1},zI=v.createContext({}),BI=()=>v.useContext(zI),jI=v.forwardRef(({color:t,size:e,strokeWidth:n,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>{const{size:u=24,strokeWidth:c=2,absoluteStrokeWidth:f=!1,color:d="currentColor",className:h=""}=BI()??{},p=r??f?Number(n??c)*24/Number(e??u):n??c;return v.createElement("svg",{ref:a,..._g,width:e??u??_g.width,height:e??u??_g.height,stroke:t??d,strokeWidth:p,className:dT("lucide",h,i),...!s&&!$I(l)&&{"aria-hidden":"true"},...l},[...o.map(([m,x])=>v.createElement(m,x)),...Array.isArray(s)?s:[s]])});/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const En=(t,e)=>{const n=v.forwardRef(({className:r,...i},s)=>v.createElement(jI,{ref:s,iconNode:e,className:dT(`lucide-${LI(cx(t))}`,`lucide-${t}`,r),...i}));return n.displayName=cx(t),n};/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const HI=[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]],WI=En("arrow-left-right",HI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const VI=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],fx=En("braces",VI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const UI=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],KI=En("chevron-down",UI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const XI=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]],GI=En("clipboard",XI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const qI=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],YI=En("clock",qI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const JI=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Dv=En("copy",JI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const QI=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],hT=En("download",QI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ZI=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]],pT=En("file-up",ZI);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const eN=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],tN=En("moon",eN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const nN=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],rN=En("redo-2",nN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const iN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],sN=En("rotate-ccw-clock",iN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const oN=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],dx=En("rotate-ccw",oN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const lN=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],aN=En("search",lN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const uN=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],cN=En("sparkles",uN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const fN=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],dN=En("sun",fN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const hN=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],pN=En("table",hN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const gN=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],mN=En("thumbs-down",gN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const yN=[["path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z",key:"emmmcr"}],["path",{d:"M7 10v12",key:"1qc93n"}]],vN=En("thumbs-up",yN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const wN=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ph=En("trash",wN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const xN=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],bN=En("undo-2",xN);/** - * @license lucide-react v1.41.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const kN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],gh=En("x",kN);function gT(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var i=t.length;for(e=0;e{const e=EN(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:o=>{const l=o.split(_v);return l[0]===""&&l.length!==1&&l.shift(),mT(l,e)||TN(o)},getConflictingClassGroupIds:(o,l)=>{const a=n[o]||[];return l&&r[o]?[...a,...r[o]]:a}}},mT=(t,e)=>{var o;if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),i=r?mT(t.slice(1),r):void 0;if(i)return i;if(e.validators.length===0)return;const s=t.join(_v);return(o=e.validators.find(({validator:l})=>l(s)))==null?void 0:o.classGroupId},hx=/^\[(.+)\]$/,TN=t=>{if(hx.test(t)){const e=hx.exec(t)[1],n=e==null?void 0:e.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},EN=t=>{const{theme:e,prefix:n}=t,r={nextPart:new Map,validators:[]};return MN(Object.entries(t.classGroups),n).forEach(([s,o])=>{E0(o,r,s,e)}),r},E0=(t,e,n,r)=>{t.forEach(i=>{if(typeof i=="string"){const s=i===""?e:px(e,i);s.classGroupId=n;return}if(typeof i=="function"){if(AN(i)){E0(i(r),e,n,r);return}e.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([s,o])=>{E0(o,px(e,s),n,r)})})},px=(t,e)=>{let n=t;return e.split(_v).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},AN=t=>t.isThemeGetter,MN=(t,e)=>e?t.map(([n,r])=>{const i=r.map(s=>typeof s=="string"?e+s:typeof s=="object"?Object.fromEntries(Object.entries(s).map(([o,l])=>[e+o,l])):s);return[n,i]}):t,RN=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const i=(s,o)=>{n.set(s,o),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let o=n.get(s);if(o!==void 0)return o;if((o=r.get(s))!==void 0)return i(s,o),o},set(s,o){n.has(s)?n.set(s,o):i(s,o)}}},yT="!",ON=t=>{const{separator:e,experimentalParseClassName:n}=t,r=e.length===1,i=e[0],s=e.length,o=l=>{const a=[];let u=0,c=0,f;for(let x=0;xc?f-c:void 0;return{modifiers:a,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}};return n?l=>n({className:l,parseClassName:o}):o},PN=t=>{if(t.length<=1)return t;const e=[];let n=[];return t.forEach(r=>{r[0]==="["?(e.push(...n.sort(),r),n=[]):n.push(r)}),e.push(...n.sort()),e},IN=t=>({cache:RN(t.cacheSize),parseClassName:ON(t),...CN(t)}),NN=/\s+/,DN=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=e,s=[],o=t.trim().split(NN);let l="";for(let a=o.length-1;a>=0;a-=1){const u=o[a],{modifiers:c,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}=n(u);let p=!!h,m=r(p?d.substring(0,h):d);if(!m){if(!p){l=u+(l.length>0?" "+l:l);continue}if(m=r(d),!m){l=u+(l.length>0?" "+l:l);continue}p=!1}const x=PN(c).join(":"),g=f?x+yT:x,y=g+m;if(s.includes(y))continue;s.push(y);const w=i(m,p);for(let k=0;k0?" "+l:l)}return l};function _N(){let t=0,e,n,r="";for(;t{if(typeof t=="string")return t;let e,n="";for(let r=0;rf(c),t());return n=IN(u),r=n.cache.get,i=n.cache.set,s=l,l(a)}function l(a){const u=r(a);if(u)return u;const c=DN(a,n);return i(a,c),c}return function(){return s(_N.apply(null,arguments))}}const tn=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},wT=/^\[(?:([a-z-]+):)?(.+)\]$/i,FN=/^\d+\/\d+$/,$N=new Set(["px","full","screen"]),zN=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,BN=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,jN=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,HN=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,WN=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ks=t=>ka(t)||$N.has(t)||FN.test(t),qs=t=>qa(t,"length",JN),ka=t=>!!t&&!Number.isNaN(Number(t)),Lg=t=>qa(t,"number",ka),Cu=t=>!!t&&Number.isInteger(Number(t)),VN=t=>t.endsWith("%")&&ka(t.slice(0,-1)),mt=t=>wT.test(t),Ys=t=>zN.test(t),UN=new Set(["length","size","percentage"]),KN=t=>qa(t,UN,xT),XN=t=>qa(t,"position",xT),GN=new Set(["image","url"]),qN=t=>qa(t,GN,ZN),YN=t=>qa(t,"",QN),Tu=()=>!0,qa=(t,e,n)=>{const r=wT.exec(t);return r?r[1]?typeof e=="string"?r[1]===e:e.has(r[1]):n(r[2]):!1},JN=t=>BN.test(t)&&!jN.test(t),xT=()=>!1,QN=t=>HN.test(t),ZN=t=>WN.test(t),eD=()=>{const t=tn("colors"),e=tn("spacing"),n=tn("blur"),r=tn("brightness"),i=tn("borderColor"),s=tn("borderRadius"),o=tn("borderSpacing"),l=tn("borderWidth"),a=tn("contrast"),u=tn("grayscale"),c=tn("hueRotate"),f=tn("invert"),d=tn("gap"),h=tn("gradientColorStops"),p=tn("gradientColorStopPositions"),m=tn("inset"),x=tn("margin"),g=tn("opacity"),y=tn("padding"),w=tn("saturate"),k=tn("scale"),b=tn("sepia"),S=tn("skew"),T=tn("space"),A=tn("translate"),M=()=>["auto","contain","none"],O=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",mt,e],P=()=>[mt,e],I=()=>["",ks,qs],D=()=>["auto",ka,mt],ee=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ie=()=>["solid","dashed","dotted","double","none"],te=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>["start","end","center","between","around","evenly","stretch"],V=()=>["","0",mt],R=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>[ka,mt];return{cacheSize:500,separator:":",theme:{colors:[Tu],spacing:[ks,qs],blur:["none","",Ys,mt],brightness:N(),borderColor:[t],borderRadius:["none","","full",Ys,mt],borderSpacing:P(),borderWidth:I(),contrast:N(),grayscale:V(),hueRotate:N(),invert:V(),gap:P(),gradientColorStops:[t],gradientColorStopPositions:[VN,qs],inset:_(),margin:_(),opacity:N(),padding:P(),saturate:N(),scale:N(),sepia:V(),skew:N(),space:P(),translate:P()},classGroups:{aspect:[{aspect:["auto","square","video",mt]}],container:["container"],columns:[{columns:[Ys]}],"break-after":[{"break-after":R()}],"break-before":[{"break-before":R()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...ee(),mt]}],overflow:[{overflow:O()}],"overflow-x":[{"overflow-x":O()}],"overflow-y":[{"overflow-y":O()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Cu,mt]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",mt]}],grow:[{grow:V()}],shrink:[{shrink:V()}],order:[{order:["first","last","none",Cu,mt]}],"grid-cols":[{"grid-cols":[Tu]}],"col-start-end":[{col:["auto",{span:["full",Cu,mt]},mt]}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":[Tu]}],"row-start-end":[{row:["auto",{span:[Cu,mt]},mt]}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",mt]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",mt]}],gap:[{gap:[d]}],"gap-x":[{"gap-x":[d]}],"gap-y":[{"gap-y":[d]}],"justify-content":[{justify:["normal",...W()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...W(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...W(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[y]}],px:[{px:[y]}],py:[{py:[y]}],ps:[{ps:[y]}],pe:[{pe:[y]}],pt:[{pt:[y]}],pr:[{pr:[y]}],pb:[{pb:[y]}],pl:[{pl:[y]}],m:[{m:[x]}],mx:[{mx:[x]}],my:[{my:[x]}],ms:[{ms:[x]}],me:[{me:[x]}],mt:[{mt:[x]}],mr:[{mr:[x]}],mb:[{mb:[x]}],ml:[{ml:[x]}],"space-x":[{"space-x":[T]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[T]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",mt,e]}],"min-w":[{"min-w":[mt,e,"min","max","fit"]}],"max-w":[{"max-w":[mt,e,"none","full","min","max","fit","prose",{screen:[Ys]},Ys]}],h:[{h:[mt,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[mt,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[mt,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Ys,qs]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Lg]}],"font-family":[{font:[Tu]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",mt]}],"line-clamp":[{"line-clamp":["none",ka,Lg]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",ks,mt]}],"list-image":[{"list-image":["none",mt]}],"list-style-type":[{list:["none","disc","decimal",mt]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[g]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[g]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ie(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",ks,qs]}],"underline-offset":[{"underline-offset":["auto",ks,mt]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",mt]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",mt]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[g]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ee(),XN]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",KN]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},qN]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[p]}],"gradient-via-pos":[{via:[p]}],"gradient-to-pos":[{to:[p]}],"gradient-from":[{from:[h]}],"gradient-via":[{via:[h]}],"gradient-to":[{to:[h]}],rounded:[{rounded:[s]}],"rounded-s":[{"rounded-s":[s]}],"rounded-e":[{"rounded-e":[s]}],"rounded-t":[{"rounded-t":[s]}],"rounded-r":[{"rounded-r":[s]}],"rounded-b":[{"rounded-b":[s]}],"rounded-l":[{"rounded-l":[s]}],"rounded-ss":[{"rounded-ss":[s]}],"rounded-se":[{"rounded-se":[s]}],"rounded-ee":[{"rounded-ee":[s]}],"rounded-es":[{"rounded-es":[s]}],"rounded-tl":[{"rounded-tl":[s]}],"rounded-tr":[{"rounded-tr":[s]}],"rounded-br":[{"rounded-br":[s]}],"rounded-bl":[{"rounded-bl":[s]}],"border-w":[{border:[l]}],"border-w-x":[{"border-x":[l]}],"border-w-y":[{"border-y":[l]}],"border-w-s":[{"border-s":[l]}],"border-w-e":[{"border-e":[l]}],"border-w-t":[{"border-t":[l]}],"border-w-r":[{"border-r":[l]}],"border-w-b":[{"border-b":[l]}],"border-w-l":[{"border-l":[l]}],"border-opacity":[{"border-opacity":[g]}],"border-style":[{border:[...ie(),"hidden"]}],"divide-x":[{"divide-x":[l]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[l]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[g]}],"divide-style":[{divide:ie()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-s":[{"border-s":[i]}],"border-color-e":[{"border-e":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ie()]}],"outline-offset":[{"outline-offset":[ks,mt]}],"outline-w":[{outline:[ks,qs]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:I()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[g]}],"ring-offset-w":[{"ring-offset":[ks,qs]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Ys,YN]}],"shadow-color":[{shadow:[Tu]}],opacity:[{opacity:[g]}],"mix-blend":[{"mix-blend":[...te(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":te()}],filter:[{filter:["","none"]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[a]}],"drop-shadow":[{"drop-shadow":["","none",Ys,mt]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[f]}],saturate:[{saturate:[w]}],sepia:[{sepia:[b]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[a]}],"backdrop-grayscale":[{"backdrop-grayscale":[u]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[f]}],"backdrop-opacity":[{"backdrop-opacity":[g]}],"backdrop-saturate":[{"backdrop-saturate":[w]}],"backdrop-sepia":[{"backdrop-sepia":[b]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[o]}],"border-spacing-x":[{"border-spacing-x":[o]}],"border-spacing-y":[{"border-spacing-y":[o]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",mt]}],duration:[{duration:N()}],ease:[{ease:["linear","in","out","in-out",mt]}],delay:[{delay:N()}],animate:[{animate:["none","spin","ping","pulse","bounce",mt]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[k]}],"scale-x":[{"scale-x":[k]}],"scale-y":[{"scale-y":[k]}],rotate:[{rotate:[Cu,mt]}],"translate-x":[{"translate-x":[A]}],"translate-y":[{"translate-y":[A]}],"skew-x":[{"skew-x":[S]}],"skew-y":[{"skew-y":[S]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",mt]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",mt]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",mt]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[ks,qs,Lg]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},tD=LN(eD);function hr(...t){return tD(SN(t))}function Fg(t){return t==="csv2json"?"CSV → JSON":"JSON → CSV"}function nD({flipped:t}){return E.jsx(WI,{size:18,strokeWidth:2,"aria-hidden":"true",className:hr("transition-transform duration-300",t&&"rotate-180")})}function rD({direction:t,onFlip:e}){return E.jsxs("button",{type:"button","data-testid":"divider-switch",onClick:e,onMouseDown:n=>n.stopPropagation(),onDoubleClick:n=>n.stopPropagation(),title:`Switch direction (currently ${Fg(t)})`,"aria-label":`Switch conversion direction (currently ${Fg(t)})`,className:"flex h-9 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border border-border bg-background px-3 text-xs font-medium text-muted-foreground shadow-sm transition-colors hover:border-muted-foreground/50 hover:text-foreground md:h-8 md:gap-1 md:px-2.5 md:text-[11px]",children:[E.jsx(nD,{flipped:t==="json2csv"}),E.jsx("span",{"data-testid":"divider-switch-label",children:Fg(t)})]})}const bT=[{question:"How does it work?",answer:"Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode."},{question:"What do the options do?",answer:"Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys."},{question:"TSV vs CSV — what changes?",answer:"Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them."},{question:"Does my data ever leave the browser?",answer:"No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else."}],iD={"@context":"https://schema.org","@type":"FAQPage",mainEntity:bT.map(t=>({"@type":"Question",name:t.question,acceptedAnswer:{"@type":"Answer",text:t.answer}}))};function sD(){const[t,e]=v.useState(!1),n=v.useId();return E.jsxs("section",{"data-testid":"faq","aria-label":"How it works and frequently asked questions",className:"flex-shrink-0 border-t border-border bg-panel px-4",children:[E.jsxs("button",{type:"button","data-testid":"faq-toggle","aria-expanded":t,"aria-controls":n,onClick:()=>e(r=>!r),className:"flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground",children:[E.jsx("span",{"aria-hidden":"true",className:"w-3 text-center",children:t?"▾":"▸"}),"How it works & FAQ"]}),E.jsx("div",{id:n,"data-testid":"faq-content",hidden:!t,className:"max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground",children:bT.map(r=>E.jsxs("div",{className:"mb-3 last:mb-0",children:[E.jsx("h2",{className:"mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground",children:r.question}),E.jsx("p",{children:r.answer})]},r.question))}),E.jsx("script",{type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(iD)}})]})}const oD="https://github.com/FlatFilers/csvjson-app/discussions/163";function lD(){return E.jsx("div",{"data-testid":"feedback-banner",className:"flex flex-shrink-0 items-center justify-center border-b border-border bg-muted px-3 py-1.5 text-xs text-muted-foreground sm:px-4 sm:text-sm",children:E.jsxs("p",{className:"text-center",children:["Enjoy a cleaner, simpler CSVJSON."," ",E.jsx("a",{"data-testid":"feedback-link",href:oD,target:"_blank",rel:"noopener noreferrer",className:"rounded-sm font-medium text-foreground underline decoration-border underline-offset-2 transition-colors hover:decoration-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",children:"Leave feedback or ask for features here"}),"."]})})}const kT="csvjson:feedback.v1",aD=[{value:"wrong_output",label:"The conversion is wrong"},{value:"hard_to_use",label:"Hard to use"},{value:"missing_feature",label:"Missing a feature"},{value:"slower",label:"Slower than the old site"},{value:"looks_worse",label:"Looks worse"},{value:"other",label:"Other"}];function uD(t){if(typeof t!="object"||t===null)return!1;const e=t;return typeof e.clientId=="string"&&e.clientId.length<=64&&(e.vote===1||e.vote===-1)&&(typeof e.reasonCode=="string"||e.reasonCode===null)&&(typeof e.reasonText=="string"||e.reasonText===null)&&typeof e.pending=="boolean"}function gx(){try{const t=window.localStorage.getItem(kT);if(t===null)return null;const e=JSON.parse(t);return uD(e)?e:null}catch{return null}}function mx(t){try{window.localStorage.setItem(kT,JSON.stringify(t))}catch{}}function yx(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}function cD(t){const e=window.location.pathname;return t.vote===1?{clientId:t.clientId,vote:1,path:e}:{clientId:t.clientId,vote:-1,reasonCode:t.reasonCode,reasonText:t.reasonText,path:e}}async function fD(t){try{return(await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(cD(t))})).ok?"ok":"failed"}catch{return"failed"}}function vx(t){return["flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function dD(){const[t,e]=v.useState(gx),[n,r]=v.useState(!1),[i,s]=v.useState(null),[o,l]=v.useState(""),[a,u]=v.useState(!1),[c,f]=v.useState(!1),d=v.useRef(null),h=v.useRef(0),p=v.useCallback((b,S)=>{const T={...b,pending:S==="failed"};mx(T),e(T),S==="ok"?PI({vote:b.vote,with_reason:b.reasonCode!==null}):u(!1)},[]),m=v.useCallback((b,S)=>{const T=++h.current;S&&f(!0),fD(b).then(A=>{h.current===T&&(p(b,A),A==="ok"&&u(!0))}).finally(()=>{S&&h.current===T&&f(!1)})},[p]),x=b=>{const S={...b,pending:!0};mx(S),e(S),m(S,!0)},g=v.useRef(!1);v.useEffect(()=>{if(g.current)return;g.current=!0;const b=gx();b!=null&&b.pending&&m(b,!1)},[m]),v.useEffect(()=>{if(!a)return;const b=setTimeout(()=>u(!1),3e3);return()=>clearTimeout(b)},[a]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&r(!1)},S=T=>{const A=d.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||r(!1)};return document.addEventListener("keydown",b),document.addEventListener("mousedown",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("mousedown",S)}},[n]);const y=()=>{if((t==null?void 0:t.vote)===1&&!t.pending){u(!0);return}x({clientId:(t==null?void 0:t.clientId)??yx(),vote:1,reasonCode:null,reasonText:null})},w=()=>{if(n){r(!1);return}s(null),l(""),r(!0)},k=()=>{if(i===null)return;const b=o.trim();x({clientId:(t==null?void 0:t.clientId)??yx(),vote:-1,reasonCode:i,reasonText:b===""?null:b}),r(!1)};return E.jsxs("div",{"data-testid":"feedback-vote",ref:d,className:"relative flex items-center gap-1 max-sm:static",children:[E.jsx("button",{type:"button","data-testid":"feedback-up",onClick:y,"aria-pressed":(t==null?void 0:t.vote)===1,"aria-label":"Helpful — send an upvote",title:"Helpful",className:vx((t==null?void 0:t.vote)===1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M7 10v12"}),E.jsx("path",{d:"M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"})]})}),E.jsx("button",{type:"button","data-testid":"feedback-down",onClick:w,"aria-pressed":(t==null?void 0:t.vote)===-1,"aria-haspopup":"dialog","aria-expanded":n,"aria-label":"Not helpful — send a downvote",title:"Not helpful",className:vx((t==null?void 0:t.vote)===-1),children:E.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[E.jsx("path",{d:"M17 14V2"}),E.jsx("path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"})]})}),a&&E.jsx("span",{"data-testid":"feedback-thanks",className:"text-xs text-muted-foreground",children:"Thanks for the feedback!"}),(t==null?void 0:t.pending)&&!c&&E.jsx("span",{"data-testid":"feedback-pending",role:"status",className:"max-w-44 text-right text-xs text-muted-foreground sm:max-w-none",children:"Feedback couldn't send — your vote is kept on this device and will send automatically once the service is back."}),n&&E.jsxs("div",{"data-testid":"feedback-popover",role:"dialog","aria-label":"What went wrong?",className:"absolute right-0 top-9 z-50 w-72 rounded-md border border-border bg-panel p-3 shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsx("p",{className:"mb-2 text-xs font-medium text-foreground",children:"What went wrong?"}),E.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:aD.map(b=>E.jsx("button",{type:"button","data-testid":`feedback-reason-${b.value}`,"aria-pressed":i===b.value,onClick:()=>s(b.value),className:["cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors",i===b.value?"border-foreground bg-foreground text-panel":"border-border text-muted-foreground hover:border-foreground hover:text-foreground"].join(" "),children:b.label},b.value))}),E.jsx("textarea",{"data-testid":"feedback-text",value:o,maxLength:500,rows:2,onChange:b=>l(b.target.value),placeholder:"Anything more? (optional)",className:"mb-2 w-full resize-none rounded-sm border border-border bg-panel px-2 py-1 text-xs text-foreground placeholder:text-muted-foreground/60 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring"}),E.jsxs("div",{className:"flex items-center justify-end gap-2",children:[E.jsxs("span",{className:"text-[10px] text-muted-foreground/70",children:[o.length,"/500"]}),E.jsx("button",{type:"button","data-testid":"feedback-submit",onClick:k,disabled:i===null,className:"cursor-pointer rounded-sm border border-border px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",children:"Send"})]})]})]})}function ST(t="This should not happen"){throw new Error(t)}function Wr(t,e="Assertion failed"){if(!t)return ST(e)}function Oc(t,e){return ST(e??"Hell froze over")}function hD(t,e){try{return t()}catch{return e}}const wx=Object.prototype.hasOwnProperty;function _a(t,e){let n,r;if(t===e)return!0;if(t&&e&&(n=t.constructor)===e.constructor){if(n===Date)return t.getTime()===e.getTime();if(n===RegExp)return t.toString()===e.toString();if(n===Array){if((r=t.length)===e.length)for(;r--&&_a(t[r],e[r]););return r===-1}if(!n||typeof t=="object"){r=0;for(n in t)if(wx.call(t,n)&&++r&&!wx.call(e,n)||!(n in e)||!_a(t[n],e[n]))return!1;return Object.keys(e).length===r}}return t!==t&&e!==e}var pD=Object.prototype,gD=pD.hasOwnProperty;function mD(t,e){return t!=null&&gD.call(t,e)}var yD=mD,vD=Array.isArray,ps=vD,wD=typeof fo=="object"&&fo&&fo.Object===Object&&fo,CT=wD,xD=CT,bD=typeof self=="object"&&self&&self.Object===Object&&self,kD=xD||bD||Function("return this")(),gs=kD,SD=gs,CD=SD.Symbol,Kc=CD,xx=Kc,TT=Object.prototype,TD=TT.hasOwnProperty,ED=TT.toString,Eu=xx?xx.toStringTag:void 0;function AD(t){var e=TD.call(t,Eu),n=t[Eu];try{t[Eu]=void 0;var r=!0}catch{}var i=ED.call(t);return r&&(e?t[Eu]=n:delete t[Eu]),i}var MD=AD,RD=Object.prototype,OD=RD.toString;function PD(t){return OD.call(t)}var ID=PD,bx=Kc,ND=MD,DD=ID,_D="[object Null]",LD="[object Undefined]",kx=bx?bx.toStringTag:void 0;function FD(t){return t==null?t===void 0?LD:_D:kx&&kx in Object(t)?ND(t):DD(t)}var Xc=FD;function $D(t){return t!=null&&typeof t=="object"}var Gc=$D,zD=Xc,BD=Gc,jD="[object Symbol]";function HD(t){return typeof t=="symbol"||BD(t)&&zD(t)==jD}var gp=HD,WD=ps,VD=gp,UD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,KD=/^\w*$/;function XD(t,e){if(WD(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||VD(t)?!0:KD.test(t)||!UD.test(t)||e!=null&&t in Object(e)}var Lv=XD;function GD(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var El=GD,qD=Xc,YD=El,JD="[object AsyncFunction]",QD="[object Function]",ZD="[object GeneratorFunction]",e_="[object Proxy]";function t_(t){if(!YD(t))return!1;var e=qD(t);return e==QD||e==ZD||e==JD||e==e_}var ET=t_,n_=gs,r_=n_["__core-js_shared__"],i_=r_,$g=i_,Sx=function(){var t=/[^.]+$/.exec($g&&$g.keys&&$g.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function s_(t){return!!Sx&&Sx in t}var o_=s_,l_=Function.prototype,a_=l_.toString;function u_(t){if(t!=null){try{return a_.call(t)}catch{}try{return t+""}catch{}}return""}var AT=u_,c_=ET,f_=o_,d_=El,h_=AT,p_=/[\\^$.*+?()[\]{}|]/g,g_=/^\[object .+?Constructor\]$/,m_=Function.prototype,y_=Object.prototype,v_=m_.toString,w_=y_.hasOwnProperty,x_=RegExp("^"+v_.call(w_).replace(p_,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function b_(t){if(!d_(t)||f_(t))return!1;var e=c_(t)?x_:g_;return e.test(h_(t))}var k_=b_;function S_(t,e){return t==null?void 0:t[e]}var C_=S_,T_=k_,E_=C_;function A_(t,e){var n=E_(t,e);return T_(n)?n:void 0}var Al=A_,M_=Al,R_=M_(Object,"create"),mp=R_,Cx=mp;function O_(){this.__data__=Cx?Cx(null):{},this.size=0}var P_=O_;function I_(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var N_=I_,D_=mp,__="__lodash_hash_undefined__",L_=Object.prototype,F_=L_.hasOwnProperty;function $_(t){var e=this.__data__;if(D_){var n=e[t];return n===__?void 0:n}return F_.call(e,t)?e[t]:void 0}var z_=$_,B_=mp,j_=Object.prototype,H_=j_.hasOwnProperty;function W_(t){var e=this.__data__;return B_?e[t]!==void 0:H_.call(e,t)}var V_=W_,U_=mp,K_="__lodash_hash_undefined__";function X_(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=U_&&e===void 0?K_:e,this}var G_=X_,q_=P_,Y_=N_,J_=z_,Q_=V_,Z_=G_;function Ya(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1}var mL=gL,yL=yp;function vL(t,e){var n=this.__data__,r=yL(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}var wL=vL,xL=nL,bL=cL,kL=hL,SL=mL,CL=wL;function Ja(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=L3}var Wv=F3,$3=gp;function z3(t){if(typeof t=="string"||$3(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var xp=z3,B3=OT,j3=jv,H3=ps,W3=Hv,V3=Wv,U3=xp;function K3(t,e,n){e=B3(e,t);for(var r=-1,i=e.length,s=!1;++r[r[0]+e,r[1]+e]);return new Cs(n)}add(e){const n=typeof e=="number"?[e,e+1]:e,r=Z3([...this.items,n]);return new Cs(r)}remove(e){const n=[...this.items],r=typeof e=="number"?e:e[0],i=typeof e=="number"?e+1:e[1];for(const[s,o]of n.entries()){const[l,a]=o;if(l<=i&&r<=a){const u=[];l=r&&eIx??(Ix=new Cs([]))),bt(Cs,"fromSingleSelection",e=>Cs.empty().add(e));let Nt=Cs;function eF(t){var e=Object.create(null);return function(n){return e[n]===void 0&&(e[n]=t(n)),e[n]}}var tF=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,zg=eF(function(t){return tF.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),nF=function(){const e=Array.prototype.slice.call(arguments).filter(Boolean),n={},r=[];e.forEach(s=>{(s?s.split(" "):[]).forEach(l=>{if(l.startsWith("atm_")){const[,a]=l.split("_");n[a]=l}else r.push(l)})});const i=[];for(const s in n)Object.prototype.hasOwnProperty.call(n,s)&&i.push(n[s]);return i.push(...r),i.join(" ")},Nx=nF,rF=t=>t.toUpperCase()===t,iF=t=>e=>t.indexOf(e)===-1,NT=(t,e)=>{const n={};return Object.keys(t).filter(iF(e)).forEach(r=>{n[r]=t[r]}),n};function sF(t,e,n){const r=NT(e,n);if(!t){const i=typeof zg=="function"?{default:zg}:zg;Object.keys(r).forEach(s=>{i.default(s)||delete r[s]})}return r}var oF=(t,e)=>{};function lF(t){let e="";return n=>{const r=(s,o)=>{const{as:l=t,class:a=e}=s,u=n.propsAsIs===void 0?!(typeof l=="string"&&l.indexOf("-")===-1&&!rF(l[0])):n.propsAsIs,c=sF(u,s,["as","class"]);c.ref=o,c.className=n.atomic?Nx(n.class,c.className||a):Nx(c.className||a,n.class);const{vars:f}=n;if(f){const d={};for(const m in f){const x=f[m],g=x[0],y=x[1]||"",w=typeof g=="function"?g(s):g;oF(w,n.name),d[`--${m}`]=`${w}${y}`}const h=c.style||{},p=Object.keys(h);p.length>0&&p.forEach(m=>{d[m]=h[m]}),c.style=d}return t.__linaria&&t!==l?(c.as=l,Ln.createElement(t,c)):Ln.createElement(l,c)},i=Ln.forwardRef?Ln.forwardRef(r):s=>{const o=NT(s,["innerRef"]);return r(o,s.innerRef)};return i.displayName=n.name,i.__linaria={className:n.class||e,extends:t},i}}var Jr=lF;const aF=Jr("div")({name:"ImageOverlayEditorStyle",class:"gdg-i2iowwq",propsAsIs:!1});var DT={},bp={},Uv={},Bg={},jg={exports:{}},Hg,Dx;function uF(){if(Dx)return Hg;Dx=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Hg=t,Hg}var Wg,_x;function cF(){if(_x)return Wg;_x=1;var t=uF();function e(){}function n(){}return n.resetWarningCache=e,Wg=function(){function r(o,l,a,u,c,f){if(f!==t){var d=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw d.name="Invariant Violation",d}}r.isRequired=r;function i(){return r}var s={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return s.PropTypes=s,s},Wg}var Lx;function fF(){return Lx||(Lx=1,jg.exports=cF()()),jg.exports}var Fx;function dF(){return Fx||(Fx=1,function(t){(function(e,n){n(t,v,fF())})(fo,function(e,n,r){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var i=o(n),s=o(r);function o(y){return y&&y.__esModule?y:{default:y}}var l=Object.assign||function(y){for(var w=1;w=0||Object.prototype.hasOwnProperty.call(y,b)&&(k[b]=y[b]);return k}function u(y,w){if(!(y instanceof w))throw new TypeError("Cannot call a class as a function")}var c=function(){function y(w,k){for(var b=0;b0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return h?y:y.capture}function x(y){if("touches"in y){var w=y.touches[0],k=w.pageX,b=w.pageY;return{x:k,y:b}}var S=y.screenX,T=y.screenY;return{x:S,y:T}}var g=function(y){d(w,y);function w(){var k;u(this,w);for(var b=arguments.length,S=Array(b),T=0;TS&&this.props.onSwipeRight(1,b),this.movePosition.deltaY<-S?this.props.onSwipeUp(1,b):this.movePosition.deltaY>S&&this.props.onSwipeDown(1,b)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:"_setSwiperRef",value:function(b){this.swiper=b,this.props.innerRef(b)}},{key:"render",value:function(){var b=this.props;b.tagName;var S=b.className,T=b.style,A=b.children;b.allowMouseEvents,b.onSwipeUp,b.onSwipeDown,b.onSwipeLeft,b.onSwipeRight,b.onSwipeStart,b.onSwipeMove,b.onSwipeEnd,b.innerRef,b.tolerance;var M=a(b,["tagName","className","style","children","allowMouseEvents","onSwipeUp","onSwipeDown","onSwipeLeft","onSwipeRight","onSwipeStart","onSwipeMove","onSwipeEnd","innerRef","tolerance"]);return i.default.createElement(this.props.tagName,l({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:S,style:T},M),A)}}]),w}(n.Component);g.displayName="ReactSwipe",g.propTypes={tagName:s.default.string,className:s.default.string,style:s.default.object,children:s.default.node,allowMouseEvents:s.default.bool,onSwipeUp:s.default.func,onSwipeDown:s.default.func,onSwipeLeft:s.default.func,onSwipeRight:s.default.func,onSwipeStart:s.default.func,onSwipeMove:s.default.func,onSwipeEnd:s.default.func,innerRef:s.default.func,tolerance:s.default.number.isRequired},g.defaultProps={tagName:"div",allowMouseEvents:!1,onSwipeUp:function(){},onSwipeDown:function(){},onSwipeLeft:function(){},onSwipeRight:function(){},onSwipeStart:function(){},onSwipeMove:function(){},onSwipeEnd:function(){},innerRef:function(){},tolerance:0},e.default=g})}(Bg)),Bg}(function(t){(function(e,n){n(t,dF())})(fo,function(e,n){Object.defineProperty(e,"__esModule",{value:!0});var r=i(n);function i(s){return s&&s.__esModule?s:{default:s}}e.default=r.default})})(Uv);var qc={},_T={exports:{}};/*! - Copyright (c) 2018 Jed Watson. - Licensed under the MIT License (MIT), see - http://jedwatson.github.io/classnames -*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function vh(t){return vh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},vh(t)}function tr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var OF=function(e){return e.hasOwnProperty("key")},Kv=function(t){EF(n,t);var e=AF(n);function n(r){var i;return SF(this,n),i=e.call(this,r),tr(cr(i),"itemsWrapperRef",void 0),tr(cr(i),"itemsListRef",void 0),tr(cr(i),"thumbsRef",void 0),tr(cr(i),"setItemsWrapperRef",function(s){i.itemsWrapperRef=s}),tr(cr(i),"setItemsListRef",function(s){i.itemsListRef=s}),tr(cr(i),"setThumbsRef",function(s,o){i.thumbsRef||(i.thumbsRef=[]),i.thumbsRef[o]=s}),tr(cr(i),"updateSizes",function(){if(!(!i.props.children||!i.itemsWrapperRef||!i.thumbsRef)){var s=Ti.Children.count(i.props.children),o=i.itemsWrapperRef.clientWidth,l=i.props.thumbWidth?i.props.thumbWidth:(0,xF.outerWidth)(i.thumbsRef[0]),a=Math.floor(o/l),u=a0&&(o=0),u===f&&o<0&&(o=0);var d=i.itemsWrapperRef.clientWidth,h=u+100/(d/o);return i.itemsListRef&&["WebkitTransform","MozTransform","MsTransform","OTransform","transform","msTransform"].forEach(function(p){i.itemsListRef.style[p]=(0,$x.default)(h,"%",i.props.axis)}),!0}),tr(cr(i),"slideRight",function(s){i.moveTo(i.state.firstItem-(typeof s=="number"?s:1))}),tr(cr(i),"slideLeft",function(s){i.moveTo(i.state.firstItem+(typeof s=="number"?s:1))}),tr(cr(i),"moveTo",function(s){s=s<0?0:s,s=s>=i.state.lastPosition?i.state.lastPosition:s,i.setState({firstItem:s})}),i.state={selectedItem:r.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},i}return TF(n,[{key:"componentDidMount",value:function(){this.setupThumbs()}},{key:"componentDidUpdate",value:function(i){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==i.children&&this.updateSizes()}},{key:"componentWillUnmount",value:function(){this.destroyThumbs()}},{key:"setupThumbs",value:function(){(0,Uf.default)().addEventListener("resize",this.updateSizes),(0,Uf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.updateSizes()}},{key:"destroyThumbs",value:function(){(0,Uf.default)().removeEventListener("resize",this.updateSizes),(0,Uf.default)().removeEventListener("DOMContentLoaded",this.updateSizes)}},{key:"getFirstItem",value:function(i){var s=i;return i>=this.state.lastPosition&&(s=this.state.lastPosition),i1,o=this.state.showArrows&&this.state.firstItem>0,l=this.state.showArrows&&this.state.firstItemo);if(l)return s<0?e.centerMode&&e.centerSlidePercentage&&e.axis==="horizontal"?r.itemListStyle=(0,ss.setPosition)(-(o+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):r.itemListStyle=(0,ss.setPosition)(-(o+2)*100,e.axis):s>o&&(r.itemListStyle=(0,ss.setPosition)(0,e.axis)),r;var a=(0,ss.getPosition)(i,e),u=(0,BF.default)(a,"%",e.axis),c=e.transitionTime+"ms";return r.itemListStyle={WebkitTransform:u,msTransform:u,OTransform:u,transform:u},n.swiping||(r.itemListStyle=tl(tl({},r.itemListStyle),{},{WebkitTransitionDuration:c,MozTransitionDuration:c,OTransitionDuration:c,transitionDuration:c,msTransitionDuration:c})),r};is.slideAnimationHandler=WF;var VF=function(e,n,r,i){var s={},o=n.axis==="horizontal",l=FT.Children.count(n.children),a=0,u=(0,ss.getPosition)(r.selectedItem,n),c=n.infiniteLoop?(0,ss.getPosition)(l-1,n)-100:(0,ss.getPosition)(l-1,n),f=o?e.x:e.y,d=f;u===a&&f>0&&(d=0),u===c&&f<0&&(d=0);var h=u+100/(r.itemSize/d),p=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&p&&(r.selectedItem===0&&h>-100?h-=l*100:r.selectedItem===l-1&&h<-l*100&&(h+=l*100)),(!n.preventMovementUntilSwipeScrollTolerance||p||r.swipeMovementStarted)&&(r.swipeMovementStarted||i({swipeMovementStarted:!0}),s.itemListStyle=(0,ss.setPosition)(h,n.axis)),p&&!r.cancelClick&&i({cancelClick:!0}),s};is.slideSwipeAnimationHandler=VF;var UF=function(e,n){var r=(0,ss.getPosition)(n.selectedItem,e),i=(0,ss.setPosition)(r,e.axis);return{itemListStyle:i}};is.slideStopSwipingHandler=UF;var KF=function(e,n){var r=e.transitionTime+"ms",i="ease-in-out",s={position:"absolute",display:"block",zIndex:-2,minHeight:"100%",opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:i,msTransitionTimingFunction:i,MozTransitionTimingFunction:i,WebkitTransitionTimingFunction:i,OTransitionTimingFunction:i};return n.swiping||(s=tl(tl({},s),{},{WebkitTransitionDuration:r,MozTransitionDuration:r,OTransitionDuration:r,transitionDuration:r,msTransitionDuration:r})),{slideStyle:s,selectedStyle:tl(tl({},s),{},{opacity:1,position:"relative"}),prevStyle:tl({},s)}};is.fadeAnimationHandler=KF;Object.defineProperty(bp,"__esModule",{value:!0});bp.default=void 0;var jt=qF(v),XF=Qc(Uv),Es=Qc(qc),GF=Qc(Yc),Kf=Qc(Cp),Xf=Qc(Jc),ju=Ur,wh=is;function Qc(t){return t&&t.__esModule?t:{default:t}}function $T(){if(typeof WeakMap!="function")return null;var t=new WeakMap;return $T=function(){return t},t}function qF(t){if(t&&t.__esModule)return t;if(t===null||ec(t)!=="object"&&typeof t!="function")return{default:t};var e=$T();if(e&&e.has(t))return e.get(t);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=r?Object.getOwnPropertyDescriptor(t,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=t[i]}return n.default=t,e&&e.set(t,n),n}function ec(t){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ec=function(n){return typeof n}:ec=function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},ec(t)}function O0(){return O0=Object.assign||function(t){for(var e=1;e"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function xh(t){return xh=Object.setPrototypeOf?Object.getPrototypeOf:function(n){return n.__proto__||Object.getPrototypeOf(n)},xh(t)}function kt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Xv=function(t){ZF(n,t);var e=e$(n);function n(r){var i;YF(this,n),i=e.call(this,r),kt(Ct(i),"thumbsRef",void 0),kt(Ct(i),"carouselWrapperRef",void 0),kt(Ct(i),"listRef",void 0),kt(Ct(i),"itemsRef",void 0),kt(Ct(i),"timer",void 0),kt(Ct(i),"animationHandler",void 0),kt(Ct(i),"setThumbsRef",function(o){i.thumbsRef=o}),kt(Ct(i),"setCarouselWrapperRef",function(o){i.carouselWrapperRef=o}),kt(Ct(i),"setListRef",function(o){i.listRef=o}),kt(Ct(i),"setItemsRef",function(o,l){i.itemsRef||(i.itemsRef=[]),i.itemsRef[l]=o}),kt(Ct(i),"autoPlay",function(){jt.Children.count(i.props.children)<=1||(i.clearAutoPlay(),i.props.autoPlay&&(i.timer=setTimeout(function(){i.increment()},i.props.interval)))}),kt(Ct(i),"clearAutoPlay",function(){i.timer&&clearTimeout(i.timer)}),kt(Ct(i),"resetAutoPlay",function(){i.clearAutoPlay(),i.autoPlay()}),kt(Ct(i),"stopOnHover",function(){i.setState({isMouseEntered:!0},i.clearAutoPlay)}),kt(Ct(i),"startOnLeave",function(){i.setState({isMouseEntered:!1},i.autoPlay)}),kt(Ct(i),"isFocusWithinTheCarousel",function(){return i.carouselWrapperRef?!!((0,Kf.default)().activeElement===i.carouselWrapperRef||i.carouselWrapperRef.contains((0,Kf.default)().activeElement)):!1}),kt(Ct(i),"navigateWithKeyboard",function(o){if(i.isFocusWithinTheCarousel()){var l=i.props.axis,a=l==="horizontal",u={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},c=a?u.ArrowRight:u.ArrowDown,f=a?u.ArrowLeft:u.ArrowUp;c===o.keyCode?i.increment():f===o.keyCode&&i.decrement()}}),kt(Ct(i),"updateSizes",function(){if(!(!i.state.initialized||!i.itemsRef||i.itemsRef.length===0)){var o=i.props.axis==="horizontal",l=i.itemsRef[0];if(l){var a=o?l.clientWidth:l.clientHeight;i.setState({itemSize:a}),i.thumbsRef&&i.thumbsRef.updateSizes()}}}),kt(Ct(i),"setMountState",function(){i.setState({hasMount:!0}),i.updateSizes()}),kt(Ct(i),"handleClickItem",function(o,l){if(jt.Children.count(i.props.children)!==0){if(i.state.cancelClick){i.setState({cancelClick:!1});return}i.props.onClickItem(o,l),o!==i.state.selectedItem&&i.setState({selectedItem:o})}}),kt(Ct(i),"handleOnChange",function(o,l){jt.Children.count(i.props.children)<=1||i.props.onChange(o,l)}),kt(Ct(i),"handleClickThumb",function(o,l){i.props.onClickThumb(o,l),i.moveTo(o)}),kt(Ct(i),"onSwipeStart",function(o){i.setState({swiping:!0}),i.props.onSwipeStart(o)}),kt(Ct(i),"onSwipeEnd",function(o){i.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),i.props.onSwipeEnd(o),i.clearAutoPlay(),i.state.autoPlay&&i.autoPlay()}),kt(Ct(i),"onSwipeMove",function(o,l){i.props.onSwipeMove(l);var a=i.props.swipeAnimationHandler(o,i.props,i.state,i.setState.bind(Ct(i)));return i.setState(Ei({},a)),!!Object.keys(a).length}),kt(Ct(i),"decrement",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem-(typeof o=="number"?o:1))}),kt(Ct(i),"increment",function(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;i.moveTo(i.state.selectedItem+(typeof o=="number"?o:1))}),kt(Ct(i),"moveTo",function(o){if(typeof o=="number"){var l=jt.Children.count(i.props.children)-1;o<0&&(o=i.props.infiniteLoop?l:0),o>l&&(o=i.props.infiniteLoop?0:l),i.selectItem({selectedItem:o}),i.state.autoPlay&&i.state.isMouseEntered===!1&&i.resetAutoPlay()}}),kt(Ct(i),"onClickNext",function(){i.increment(1)}),kt(Ct(i),"onClickPrev",function(){i.decrement(1)}),kt(Ct(i),"onSwipeForward",function(){i.increment(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"onSwipeBackwards",function(){i.decrement(1),i.props.emulateTouch&&i.setState({cancelClick:!0})}),kt(Ct(i),"changeItem",function(o){return function(l){(!(0,ju.isKeyboardEvent)(l)||l.key==="Enter")&&i.moveTo(o)}}),kt(Ct(i),"selectItem",function(o){i.setState(Ei({previousItem:i.state.selectedItem},o),function(){i.setState(i.animationHandler(i.props,i.state))}),i.handleOnChange(o.selectedItem,jt.Children.toArray(i.props.children)[o.selectedItem])}),kt(Ct(i),"getInitialImage",function(){var o=i.props.selectedItem,l=i.itemsRef&&i.itemsRef[o],a=l&&l.getElementsByTagName("img")||[];return a[0]}),kt(Ct(i),"getVariableItemHeight",function(o){var l=i.itemsRef&&i.itemsRef[o];if(i.state.hasMount&&l&&l.children.length){var a=l.children[0].getElementsByTagName("img")||[];if(a.length>0){var u=a[0];if(!u.complete){var c=function h(){i.forceUpdate(),u.removeEventListener("load",h)};u.addEventListener("load",c)}}var f=a[0]||l.children[0],d=f.clientHeight;return d>0?d:null}return null});var s={initialized:!1,previousItem:r.selectedItem,selectedItem:r.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:r.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return i.animationHandler=typeof r.animationHandler=="function"&&r.animationHandler||r.animationHandler==="fade"&&wh.fadeAnimationHandler||wh.slideAnimationHandler,i.state=Ei(Ei({},s),i.animationHandler(r,s)),i}return QF(n,[{key:"componentDidMount",value:function(){this.props.children&&this.setupCarousel()}},{key:"componentDidUpdate",value:function(i,s){!i.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!i.autoFocus&&this.props.autoFocus&&this.forceFocus(),s.swiping&&!this.state.swiping&&this.setState(Ei({},this.props.stopSwipingHandler(this.props,this.state))),(i.selectedItem!==this.props.selectedItem||i.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),i.autoPlay!==this.props.autoPlay&&(this.props.autoPlay?this.setupAutoPlay():this.destroyAutoPlay(),this.setState({autoPlay:this.props.autoPlay}))}},{key:"componentWillUnmount",value:function(){this.destroyCarousel()}},{key:"setupCarousel",value:function(){var i=this;this.bindEvents(),this.state.autoPlay&&jt.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var s=i.getInitialImage();s&&!s.complete?s.addEventListener("load",i.setMountState):i.setMountState()})}},{key:"destroyCarousel",value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:"setupAutoPlay",value:function(){this.autoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.addEventListener("mouseenter",this.stopOnHover),i.addEventListener("mouseleave",this.startOnLeave))}},{key:"destroyAutoPlay",value:function(){this.clearAutoPlay();var i=this.carouselWrapperRef;this.props.stopOnHover&&i&&(i.removeEventListener("mouseenter",this.stopOnHover),i.removeEventListener("mouseleave",this.startOnLeave))}},{key:"bindEvents",value:function(){(0,Xf.default)().addEventListener("resize",this.updateSizes),(0,Xf.default)().addEventListener("DOMContentLoaded",this.updateSizes),this.props.useKeyboardArrows&&(0,Kf.default)().addEventListener("keydown",this.navigateWithKeyboard)}},{key:"unbindEvents",value:function(){(0,Xf.default)().removeEventListener("resize",this.updateSizes),(0,Xf.default)().removeEventListener("DOMContentLoaded",this.updateSizes);var i=this.getInitialImage();i&&i.removeEventListener("load",this.setMountState),this.props.useKeyboardArrows&&(0,Kf.default)().removeEventListener("keydown",this.navigateWithKeyboard)}},{key:"forceFocus",value:function(){var i;(i=this.carouselWrapperRef)===null||i===void 0||i.focus()}},{key:"renderItems",value:function(i){var s=this;return this.props.children?jt.Children.map(this.props.children,function(o,l){var a=l===s.state.selectedItem,u=l===s.state.previousItem,c=a&&s.state.selectedStyle||u&&s.state.prevStyle||s.state.slideStyle||{};s.props.centerMode&&s.props.axis==="horizontal"&&(c=Ei(Ei({},c),{},{minWidth:s.props.centerSlidePercentage+"%"})),s.state.swiping&&s.state.swipeMovementStarted&&(c=Ei(Ei({},c),{},{pointerEvents:"none"}));var f={ref:function(h){return s.setItemsRef(h,l)},key:"itemKey"+l+(i?"clone":""),className:Es.default.ITEM(!0,l===s.state.selectedItem,l===s.state.previousItem),onClick:s.handleClickItem.bind(s,l,o),style:c};return jt.default.createElement("li",f,s.props.renderItem(o,{isSelected:l===s.state.selectedItem,isPrevious:l===s.state.previousItem}))}):[]}},{key:"renderControls",value:function(){var i=this,s=this.props,o=s.showIndicators,l=s.labels,a=s.renderIndicator,u=s.children;return o?jt.default.createElement("ul",{className:"control-dots"},jt.Children.map(u,function(c,f){return a&&a(i.changeItem(f),f===i.state.selectedItem,f,l.item)})):null}},{key:"renderStatus",value:function(){return this.props.showStatus?jt.default.createElement("p",{className:"carousel-status"},this.props.statusFormatter(this.state.selectedItem+1,jt.Children.count(this.props.children))):null}},{key:"renderThumbs",value:function(){return!this.props.showThumbs||!this.props.children||jt.Children.count(this.props.children)===0?null:jt.default.createElement(GF.default,{ref:this.setThumbsRef,onSelectItem:this.handleClickThumb,selectedItem:this.state.selectedItem,transitionTime:this.props.transitionTime,thumbWidth:this.props.thumbWidth,labels:this.props.labels,emulateTouch:this.props.emulateTouch},this.props.renderThumbs(this.props.children))}},{key:"render",value:function(){var i=this;if(!this.props.children||jt.Children.count(this.props.children)===0)return null;var s=this.props.swipeable&&jt.Children.count(this.props.children)>1,o=this.props.axis==="horizontal",l=this.props.showArrows&&jt.Children.count(this.props.children)>1,a=l&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,u=l&&(this.state.selectedItem=e||T<0||f&&A>=s}function g(){var S=Vg();if(x(S))return y(S);l=setTimeout(g,m(S))}function y(S){return l=void 0,d&&r?h(S):(r=i=void 0,o)}function w(){l!==void 0&&clearTimeout(l),u=0,r=a=i=l=void 0}function k(){return l===void 0?o:y(Vg())}function b(){var S=Vg(),T=x(S);if(r=arguments,i=this,a=S,T){if(l===void 0)return p(a);if(f)return clearTimeout(l),l=setTimeout(g,e),h(a)}return l===void 0&&(l=setTimeout(g,e)),o}return b.cancel=w,b.flush=k,b}var zT=T$;const BT=ji(zT);function Vn(t,e,n,r,i=!1){const s=v.useRef();s.current=e,v.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;const o=n,l=a=>{var u;(u=s.current)==null||u.call(o,a)};return o.addEventListener(t,l,{passive:r,capture:i}),()=>{o.removeEventListener(t,l,{capture:i})}},[t,n,r,i])}function Ul(t,e){return t===void 0?void 0:e}const E$=Math.PI;function Vx(t){return t*E$/180}const jT=(t,e,n)=>({x1:t-n/2,y1:e-n/2,x2:t+n/2,y2:e+n/2}),HT=(t,e,n,r,i)=>{switch(t){case"left":return Math.floor(e)+r+i/2;case"center":return Math.floor(e+n/2);case"right":return Math.floor(e+n)-r-i/2}},WT=(t,e,n)=>Math.min(t,e-n*2),VT=(t,e,n)=>n.x1<=t&&t<=n.x2&&n.y1<=e&&e<=n.y2,qv=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M12.7073 7.05029C7.87391 11.8837 10.4544 9.30322 6.03024 13.7273C5.77392 13.9836 5.58981 14.3071 5.50189 14.6587L4.52521 18.5655C4.38789 19.1148 4.88543 19.6123 5.43472 19.475L9.34146 18.4983C9.69313 18.4104 10.0143 18.2286 10.2706 17.9722L16.9499 11.2929",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),v.createElement("path",{d:"M20.4854 4.92901L19.0712 3.5148C18.2901 2.73375 17.0238 2.73375 16.2428 3.5148L14.475 5.28257C15.5326 7.71912 16.4736 8.6278 18.7176 9.52521L20.4854 7.75744C21.2665 6.97639 21.2665 5.71006 20.4854 4.92901Z",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",vectorEffect:"non-scaling-stroke"}))},A$=t=>{const e=t.fgColor??"currentColor";return v.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},v.createElement("path",{d:"M19 6L10.3802 17L5.34071 11.8758",vectorEffect:"non-scaling-stroke",stroke:e,strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function M$(t,e,n){const[r,i]=v.useState(t),s=v.useRef(!0);v.useEffect(()=>()=>{s.current=!1},[]);const o=v.useRef(BT(l=>{s.current&&i(l)},n));return v.useLayoutEffect(()=>{s.current&&o.current(()=>t())},e),r}const R$="֑-߿יִ-﷽ﹰ-ﻼ",O$="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",P$=new RegExp("^[^"+O$+"]*["+R$+"]");function Yv(t){return P$.test(t)?"rtl":"not-rtl"}let Gf;function I0(){if(typeof document>"u")return 0;if(Gf!==void 0)return Gf;const t=document.createElement("p");t.style.width="100%",t.style.height="200px";const e=document.createElement("div");e.id="testScrollbar",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.visibility="hidden",e.style.width="200px",e.style.height="150px",e.style.overflow="hidden",e.append(t),document.body.append(e);const n=t.offsetWidth;e.style.overflow="scroll";let r=t.offsetWidth;return n===r&&(r=e.clientWidth),e.remove(),Gf=n-r,Gf}const Xo=Symbol();function I$(t){const e=v.useRef([Xo,t]);e.current[1]!==t&&(e.current[0]=t),e.current[1]=t;const[n,r]=v.useState(t),[,i]=v.useState(),s=v.useCallback(l=>{const a=e.current[0];a!==Xo&&(l=typeof l=="function"?l(a):l,l===a)||(a!==Xo&&i({}),r(u=>typeof l=="function"?l(a===Xo?u:a):l),e.current[0]=Xo)},[]),o=v.useCallback(()=>{e.current[0]=Xo,i({})},[]);return[e.current[0]===Xo?n:e.current[0],s,o]}function UT(t){if(t.length===0)return"";let e=0,n=0;for(const r of t){if(n+=r.length,n>1e4)break;e++}return t.slice(0,e).join(", ")}function N$(t){const e=v.useRef(t);return _a(t,e.current)||(e.current=t),e.current}const D$=t=>{const{urls:e,canWrite:n,onEditClick:r,renderImage:i}=t,s=e.filter(l=>l!=="");if(s.length===0)return null;const o=s.length>1;return v.createElement(aF,{"data-testid":"GDG-default-image-overlay-editor"},v.createElement(DT.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},s.map(l=>{const a=(i==null?void 0:i(l))??v.createElement("img",{draggable:!1,src:l});return v.createElement("div",{className:"gdg-centering-container",key:l},a)})),n&&r&&v.createElement("button",{className:"gdg-edit-icon",onClick:r},v.createElement(qv,null)))};function KT(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let Ml=KT();function _$(t){Ml=t}const XT=/[&<>"']/,L$=new RegExp(XT.source,"g"),GT=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,F$=new RegExp(GT.source,"g"),$$={"&":"&","<":"<",">":">",'"':""","'":"'"},Ux=t=>$$[t];function nr(t,e){if(e){if(XT.test(t))return t.replace(L$,Ux)}else if(GT.test(t))return t.replace(F$,Ux);return t}const z$=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function qT(t){return t.replace(z$,(e,n)=>(n=n.toLowerCase(),n==="colon"?":":n.charAt(0)==="#"?n.charAt(1)==="x"?String.fromCharCode(parseInt(n.substring(2),16)):String.fromCharCode(+n.substring(1)):""))}const B$=/(^|[^\[])\^/g;function Yt(t,e){t=typeof t=="string"?t:t.source,e=e||"";const n={replace:(r,i)=>(i=i.source||i,i=i.replace(B$,"$1"),t=t.replace(r,i),n),getRegex:()=>new RegExp(t,e)};return n}const j$=/[^\w:]/g,H$=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Kx(t,e,n){if(t){let r;try{r=decodeURIComponent(qT(n)).replace(j$,"").toLowerCase()}catch{return null}if(r.indexOf("javascript:")===0||r.indexOf("vbscript:")===0||r.indexOf("data:")===0)return null}e&&!H$.test(n)&&(n=K$(e,n));try{n=encodeURI(n).replace(/%25/g,"%")}catch{return null}return n}const qf={},W$=/^[^:]+:\/*[^/]*$/,V$=/^([^:]+:)[\s\S]*$/,U$=/^([^:]+:\/*[^/]*)[\s\S]*$/;function K$(t,e){qf[" "+t]||(W$.test(t)?qf[" "+t]=t+"/":qf[" "+t]=Dd(t,"/",!0)),t=qf[" "+t];const n=t.indexOf(":")===-1;return e.substring(0,2)==="//"?n?e:t.replace(V$,"$1")+e:e.charAt(0)==="/"?n?e:t.replace(U$,"$1")+e:t+e}const bh={exec:function(){}};function Xx(t,e){const n=t.replace(/\|/g,(s,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),r=n.split(/ \|/);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r[r.length-1].trim()&&r.pop(),r.length>e)r.splice(e);else for(;r.length1;)e&1&&(n+=t),e>>=1,t+=t;return n+t}function qx(t,e,n,r){const i=e.href,s=e.title?nr(e.title):null,o=t[1].replace(/\\([\[\]])/g,"$1");if(t[0].charAt(0)!=="!"){r.state.inLink=!0;const l={type:"link",raw:n,href:i,title:s,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,l}return{type:"image",raw:n,href:i,title:s,text:nr(o)}}function q$(t,e){const n=t.match(/^(\s+)(?:```)/);if(n===null)return e;const r=n[1];return e.split(` -`).map(i=>{const s=i.match(/^\s+/);if(s===null)return i;const[o]=s;return o.length>=r.length?i.slice(r.length):i}).join(` -`)}class Jv{constructor(e){this.options=e||Ml}space(e){const n=this.rules.block.newline.exec(e);if(n&&n[0].length>0)return{type:"space",raw:n[0]}}code(e){const n=this.rules.block.code.exec(e);if(n){const r=n[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:n[0],codeBlockStyle:"indented",text:this.options.pedantic?r:Dd(r,` -`)}}}fences(e){const n=this.rules.block.fences.exec(e);if(n){const r=n[0],i=q$(r,n[3]||"");return{type:"code",raw:r,lang:n[2]?n[2].trim().replace(this.rules.inline._escapes,"$1"):n[2],text:i}}}heading(e){const n=this.rules.block.heading.exec(e);if(n){let r=n[2].trim();if(/#$/.test(r)){const i=Dd(r,"#");(this.options.pedantic||!i||/ $/.test(i))&&(r=i.trim())}return{type:"heading",raw:n[0],depth:n[1].length,text:r,tokens:this.lexer.inline(r)}}}hr(e){const n=this.rules.block.hr.exec(e);if(n)return{type:"hr",raw:n[0]}}blockquote(e){const n=this.rules.block.blockquote.exec(e);if(n){const r=n[0].replace(/^ *>[ \t]?/gm,""),i=this.lexer.state.top;this.lexer.state.top=!0;const s=this.lexer.blockTokens(r);return this.lexer.state.top=i,{type:"blockquote",raw:n[0],tokens:s,text:r}}}list(e){let n=this.rules.block.list.exec(e);if(n){let r,i,s,o,l,a,u,c,f,d,h,p,m=n[1].trim();const x=m.length>1,g={type:"list",raw:"",ordered:x,start:x?+m.slice(0,-1):"",loose:!1,items:[]};m=x?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=x?m:"[*+-]");const y=new RegExp(`^( {0,3}${m})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(n=y.exec(e))||this.rules.block.hr.test(e)));){if(r=n[0],e=e.substring(r.length),c=n[2].split(` -`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` -`,1)[0],this.options.pedantic?(o=2,h=c.trimLeft()):(o=n[2].search(/[^ ]/),o=o>4?1:o,h=c.slice(o),o+=n[1].length),a=!1,!c&&/^ *$/.test(f)&&(r+=f+` -`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),b=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),S=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(d=e.split(` -`,1)[0],f=d,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(S.test(f)||T.test(f)||k.test(f)||b.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())h+=` -`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||S.test(c)||T.test(c)||b.test(c))break;h+=` -`+f}!a&&!f.trim()&&(a=!0),r+=d+` -`,e=e.substring(d.length+1),c=f.slice(o)}}g.loose||(u?g.loose=!0:/\n *\n *$/.test(r)&&(u=!0)),this.options.gfm&&(i=/^\[[ xX]\] /.exec(h),i&&(s=i[0]!=="[ ] ",h=h.replace(/^\[[ xX]\] +/,""))),g.items.push({type:"list_item",raw:r,task:!!i,checked:s,loose:!1,text:h}),g.raw+=r}g.items[g.items.length-1].raw=r.trimRight(),g.items[g.items.length-1].text=h.trimRight(),g.raw=g.raw.trimRight();const w=g.items.length;for(l=0;lS.type==="space"),b=k.length>0&&k.some(S=>/\n.*\n/.test(S.raw));g.loose=b}if(g.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",s=n[3]?n[3].substring(1,n[3].length-1).replace(this.rules.inline._escapes,"$1"):n[3];return{type:"def",tag:r,raw:n[0],href:i,title:s}}}table(e){const n=this.rules.block.table.exec(e);if(n){const r={type:"table",header:Xx(n[1]).map(i=>({text:i})),align:n[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:n[3]&&n[3].trim()?n[3].replace(/\n[ \t]*$/,"").split(` -`):[]};if(r.header.length===r.align.length){r.raw=n[0];let i=r.align.length,s,o,l,a;for(s=0;s({text:u}));for(i=r.header.length,o=0;o/i.test(n[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(n[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(n[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:n[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):nr(n[0]):n[0]}}link(e){const n=this.rules.inline.link.exec(e);if(n){const r=n[2].trim();if(!this.options.pedantic&&/^$/.test(r))return;const o=Dd(r.slice(0,-1),"\\");if((r.length-o.length)%2===0)return}else{const o=X$(n[2],"()");if(o>-1){const a=(n[0].indexOf("!")===0?5:4)+n[1].length+o;n[2]=n[2].substring(0,o),n[0]=n[0].substring(0,a).trim(),n[3]=""}}let i=n[2],s="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);o&&(i=o[1],s=o[3])}else s=n[3]?n[3].slice(1,-1):"";return i=i.trim(),/^$/.test(r)?i=i.slice(1):i=i.slice(1,-1)),qx(n,{href:i&&i.replace(this.rules.inline._escapes,"$1"),title:s&&s.replace(this.rules.inline._escapes,"$1")},n[0],this.lexer)}}reflink(e,n){let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let i=(r[2]||r[1]).replace(/\s+/g," ");if(i=n[i.toLowerCase()],!i){const s=r[0].charAt(0);return{type:"text",raw:s,text:s}}return qx(r,i,r[0],this.lexer)}}emStrong(e,n,r=""){let i=this.rules.inline.emStrong.lDelim.exec(e);if(!i||i[3]&&r.match(/[\p{L}\p{N}]/u))return;const s=i[1]||i[2]||"";if(!s||s&&(r===""||this.rules.inline.punctuation.exec(r))){const o=i[0].length-1;let l,a,u=o,c=0;const f=i[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,n=n.slice(-1*e.length+o);(i=f.exec(n))!=null;){if(l=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!l)continue;if(a=l.length,i[3]||i[4]){u+=a;continue}else if((i[5]||i[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const d=e.slice(0,o+i.index+(i[0].length-l.length)+a);if(Math.min(o,a)%2){const p=d.slice(1,-1);return{type:"em",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}const h=d.slice(2,-2);return{type:"strong",raw:d,text:h,tokens:this.lexer.inlineTokens(h)}}}}codespan(e){const n=this.rules.inline.code.exec(e);if(n){let r=n[2].replace(/\n/g," ");const i=/[^ ]/.test(r),s=/^ /.test(r)&&/ $/.test(r);return i&&s&&(r=r.substring(1,r.length-1)),r=nr(r,!0),{type:"codespan",raw:n[0],text:r}}}br(e){const n=this.rules.inline.br.exec(e);if(n)return{type:"br",raw:n[0]}}del(e){const n=this.rules.inline.del.exec(e);if(n)return{type:"del",raw:n[0],text:n[2],tokens:this.lexer.inlineTokens(n[2])}}autolink(e,n){const r=this.rules.inline.autolink.exec(e);if(r){let i,s;return r[2]==="@"?(i=nr(this.options.mangle?n(r[1]):r[1]),s="mailto:"+i):(i=nr(r[1]),s=i),{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}url(e,n){let r;if(r=this.rules.inline.url.exec(e)){let i,s;if(r[2]==="@")i=nr(this.options.mangle?n(r[0]):r[0]),s="mailto:"+i;else{let o;do o=r[0],r[0]=this.rules.inline._backpedal.exec(r[0])[0];while(o!==r[0]);i=nr(r[0]),r[1]==="www."?s="http://"+r[0]:s=r[0]}return{type:"link",raw:r[0],text:i,href:s,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e,n){const r=this.rules.inline.text.exec(e);if(r){let i;return this.lexer.state.inRawBlock?i=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):nr(r[0]):r[0]:i=nr(this.options.smartypants?n(r[0]):r[0]),{type:"text",raw:r[0],text:i}}}}const Ye={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:bh,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ye._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ye._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ye.def=Yt(Ye.def).replace("label",Ye._label).replace("title",Ye._title).getRegex();Ye.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ye.listItemStart=Yt(/^( *)(bull) */).replace("bull",Ye.bullet).getRegex();Ye.list=Yt(Ye.list).replace(/bull/g,Ye.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ye.def.source+")").getRegex();Ye._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ye._comment=/|$)/;Ye.html=Yt(Ye.html,"i").replace("comment",Ye._comment).replace("tag",Ye._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ye.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.blockquote=Yt(Ye.blockquote).replace("paragraph",Ye.paragraph).getRegex();Ye.normal={...Ye};Ye.gfm={...Ye.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ye.gfm.table=Yt(Ye.gfm.table).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.gfm.paragraph=Yt(Ye._paragraph).replace("hr",Ye.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ye.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ye._tag).getRegex();Ye.pedantic={...Ye.normal,html:Yt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ye._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:bh,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Yt(Ye.normal._paragraph).replace("hr",Ye.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Ye.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const De={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:bh,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:bh,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";De.punctuation=Yt(De.punctuation).replace(/punctuation/g,De._punctuation).getRegex();De.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;De.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;De._comment=Yt(Ye._comment).replace("(?:-->|$)","-->").getRegex();De.emStrong.lDelim=Yt(De.emStrong.lDelim).replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimAst=Yt(De.emStrong.rDelimAst,"g").replace(/punct/g,De._punctuation).getRegex();De.emStrong.rDelimUnd=Yt(De.emStrong.rDelimUnd,"g").replace(/punct/g,De._punctuation).getRegex();De._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;De._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;De._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;De.autolink=Yt(De.autolink).replace("scheme",De._scheme).replace("email",De._email).getRegex();De._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;De.tag=Yt(De.tag).replace("comment",De._comment).replace("attribute",De._attribute).getRegex();De._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;De._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;De._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;De.link=Yt(De.link).replace("label",De._label).replace("href",De._href).replace("title",De._title).getRegex();De.reflink=Yt(De.reflink).replace("label",De._label).replace("ref",Ye._label).getRegex();De.nolink=Yt(De.nolink).replace("ref",Ye._label).getRegex();De.reflinkSearch=Yt(De.reflinkSearch,"g").replace("reflink",De.reflink).replace("nolink",De.nolink).getRegex();De.normal={...De};De.pedantic={...De.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Yt(/^!?\[(label)\]\((.*?)\)/).replace("label",De._label).getRegex(),reflink:Yt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",De._label).getRegex()};De.gfm={...De.normal,escape:Yt(De.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(r="x"+r.toString(16)),e+="&#"+r+";";return e}class Mo{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ml,this.options.tokenizer=this.options.tokenizer||new Jv,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={block:Ye.normal,inline:De.normal};this.options.pedantic?(n.block=Ye.pedantic,n.inline=De.pedantic):this.options.gfm&&(n.block=Ye.gfm,this.options.breaks?n.inline=De.breaks:n.inline=De.gfm),this.tokenizer.rules=n}static get rules(){return{block:Ye,inline:De}}static lex(e,n){return new Mo(n).lex(e)}static lexInline(e,n){return new Mo(n).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` -`),this.blockTokens(e,this.tokens);let n;for(;n=this.inlineQueue.shift();)this.inlineTokens(n.src,n.tokens);return this.tokens}blockTokens(e,n=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let r,i,s,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(r=l.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length),r.raw.length===1&&n.length>0?n[n.length-1].raw+=` -`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&(i.type==="paragraph"||i.type==="text")?(i.raw+=` -`+r.raw,i.text+=` -`+r.raw,this.inlineQueue[this.inlineQueue.length-1].src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(s=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){i=n[n.length-1],o&&i.type==="paragraph"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&i.type==="text"?(i.raw+=` -`+r.raw,i.text+=` -`+r.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=i.text):n.push(r);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r,i,s,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+Gx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+Gx("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(r=c.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))){if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length),i=n[n.length-1],i&&r.type==="text"&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(r=this.tokenizer.emStrong(e,o,u)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.autolink(e,Yx)){e=e.substring(r.raw.length),n.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e,Yx))){e=e.substring(r.raw.length),n.push(r);continue}if(s=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let d;this.options.extensions.startInline.forEach(function(h){d=h.call({lexer:this},f),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(s=e.substring(0,c+1))}if(r=this.tokenizer.inlineText(s,Y$)){e=e.substring(r.raw.length),r.raw.slice(-1)!=="_"&&(u=r.raw.slice(-1)),a=!0,i=n[n.length-1],i&&i.type==="text"?(i.raw+=r.raw,i.text+=r.text):n.push(r);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return n}}class Qv{constructor(e){this.options=e||Ml}code(e,n,r){const i=(n||"").match(/\S*/)[0];if(this.options.highlight){const s=this.options.highlight(e,i);s!=null&&s!==e&&(r=!0,e=s)}return e=e.replace(/\n$/,"")+` -`,i?'
    '+(r?e:nr(e,!0))+`
    -`:"
    "+(r?e:nr(e,!0))+`
    -`}blockquote(e){return`
    -${e}
    -`}html(e){return e}heading(e,n,r,i){if(this.options.headerIds){const s=this.options.headerPrefix+i.slug(r);return`${e} -`}return`${e} -`}hr(){return this.options.xhtml?`
    -`:`
    -`}list(e,n,r){const i=n?"ol":"ul",s=n&&r!==1?' start="'+r+'"':"";return"<"+i+s+`> -`+e+" -`}listitem(e){return`
  • ${e}
  • -`}checkbox(e){return" "}paragraph(e){return`

    ${e}

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

    An error occurred:

    "+nr(r.message+"",!0)+"
    ";if(e)return Promise.resolve(i);if(n){n(null,i);return}return i}if(e)return Promise.reject(r);if(n){n(r);return}throw r}}function QT(t,e){return(n,r,i)=>{typeof r=="function"&&(i=r,r=null);const s={...r};r={...et.defaults,...s};const o=J$(r.silent,r.async,i);if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));if(G$(r),r.hooks&&(r.hooks.options=r),i){const l=r.highlight;let a;try{r.hooks&&(n=r.hooks.preprocess(n)),a=t(n,r)}catch(f){return o(f)}const u=function(f){let d;if(!f)try{r.walkTokens&&et.walkTokens(a,r.walkTokens),d=e(a,r),r.hooks&&(d=r.hooks.postprocess(d))}catch(h){f=h}return r.highlight=l,f?o(f):i(null,d)};if(!l||l.length<3||(delete r.highlight,!a.length))return u();let c=0;et.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(d,h){if(d)return u(d);h!=null&&h!==f.text&&(f.text=h,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(l=>t(l,r)).then(l=>r.walkTokens?Promise.all(et.walkTokens(l,r.walkTokens)).then(()=>l):l).then(l=>e(l,r)).then(l=>r.hooks?r.hooks.postprocess(l):l).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));const l=t(n,r);r.walkTokens&&et.walkTokens(l,r.walkTokens);let a=e(l,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(l){return o(l)}}}function et(t,e,n){return QT(Mo.lex,Zc.parse)(t,e,n)}et.options=et.setOptions=function(t){return et.defaults={...et.defaults,...t},_$(et.defaults),et};et.getDefaults=KT;et.defaults=Ml;et.use=function(...t){const e=et.defaults.extensions||{renderers:{},childTokens:{}};t.forEach(n=>{const r={...n};if(r.async=et.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if(i.renderer){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if(i.tokenizer){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[i.level]?e[i.level].unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=et.defaults.renderer||new Qv;for(const s in n.renderer){const o=i[s];i[s]=(...l)=>{let a=n.renderer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.renderer=i}if(n.tokenizer){const i=et.defaults.tokenizer||new Jv;for(const s in n.tokenizer){const o=i[s];i[s]=(...l)=>{let a=n.tokenizer[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.tokenizer=i}if(n.hooks){const i=et.defaults.hooks||new kh;for(const s in n.hooks){const o=i[s];kh.passThroughHooks.has(s)?i[s]=l=>{if(et.defaults.async)return Promise.resolve(n.hooks[s].call(i,l)).then(u=>o.call(i,u));const a=n.hooks[s].call(i,l);return o.call(i,a)}:i[s]=(...l)=>{let a=n.hooks[s].apply(i,l);return a===!1&&(a=o.apply(i,l)),a}}r.hooks=i}if(n.walkTokens){const i=et.defaults.walkTokens;r.walkTokens=function(s){let o=[];return o.push(n.walkTokens.call(this,s)),i&&(o=o.concat(i.call(this,s))),o}}et.setOptions(r)})};et.walkTokens=function(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(et,r)),r.type){case"table":{for(const i of r.header)n=n.concat(et.walkTokens(i.tokens,e));for(const i of r.rows)for(const s of i)n=n.concat(et.walkTokens(s.tokens,e));break}case"list":{n=n.concat(et.walkTokens(r.items,e));break}default:et.defaults.extensions&&et.defaults.extensions.childTokens&&et.defaults.extensions.childTokens[r.type]?et.defaults.extensions.childTokens[r.type].forEach(function(i){n=n.concat(et.walkTokens(r[i],e))}):r.tokens&&(n=n.concat(et.walkTokens(r.tokens,e)))}return n};et.parseInline=QT(Mo.lexInline,Zc.parseInline);et.Parser=Zc;et.parser=Zc.parse;et.Renderer=Qv;et.TextRenderer=YT;et.Lexer=Mo;et.lexer=Mo.lex;et.Tokenizer=Jv;et.Slugger=JT;et.Hooks=kh;et.parse=et;et.options;et.setOptions;et.use;et.walkTokens;et.parseInline;Zc.parse;Mo.lex;const Q$=Jr("div")({name:"MarkdownContainer",class:"gdg-mnuv029",propsAsIs:!1});class Z$ extends Ln.PureComponent{constructor(){super(...arguments);bt(this,"targetElement",null);bt(this,"containerRefHook",n=>{this.targetElement=n,this.renderMarkdownIntoDiv()})}renderMarkdownIntoDiv(){const{targetElement:n,props:r}=this;if(n===null)return;const{contents:i,createNode:s}=r,o=et(i),l=document.createRange();l.selectNodeContents(n),l.deleteContents();let a=s==null?void 0:s(o);if(a===void 0){const c=document.createElement("template");c.innerHTML=o,a=c.content}n.append(a);const u=n.getElementsByTagName("a");for(const c of u)c.target="_blank",c.rel="noreferrer noopener"}render(){return this.renderMarkdownIntoDiv(),Ln.createElement(Q$,{ref:this.containerRefHook})}}const e4=Jr("textarea")({name:"InputBox",class:"gdg-izpuzkl",propsAsIs:!1}),t4=Jr("div")({name:"ShadowBox",class:"gdg-s69h75o",propsAsIs:!1}),n4=Jr("div")({name:"GrowingEntryStyle",class:"gdg-g1y0xocz",propsAsIs:!1});let Jx=0;const Tp=t=>{const{placeholder:e,value:n,onKeyDown:r,highlight:i,altNewline:s,validatedSelection:o,...l}=t,{onChange:a,className:u}=l,c=v.useRef(null),f=n??"";Wr(a!==void 0,"GrowingEntry must be a controlled input area");const[d]=v.useState(()=>"input-box-"+(Jx=(Jx+1)%1e7));v.useEffect(()=>{const p=c.current;if(p===null||p.disabled)return;const m=f.toString().length;p.focus(),p.setSelectionRange(i?0:m,m)},[]),v.useLayoutEffect(()=>{var p;if(o!==void 0){const m=typeof o=="number"?[o,null]:o;(p=c.current)==null||p.setSelectionRange(m[0],m[1])}},[o]);const h=v.useCallback(p=>{p.key==="Enter"&&p.shiftKey&&s===!0||r==null||r(p)},[s,r]);return v.createElement(n4,{className:"gdg-growing-entry"},v.createElement(t4,{className:u},f+` -`),v.createElement(e4,{...l,className:(u??"")+" gdg-input",id:d,ref:c,onKeyDown:h,value:f,placeholder:e,dir:"auto"}))},Ug={};let Qs=null;function r4(){const t=document.createElement("div");return t.style.opacity="0",t.style.pointerEvents="none",t.style.position="fixed",document.body.append(t),t}function D0(t){const e=t.toLowerCase().trim();if(Ug[e]!==void 0)return Ug[e];Qs=Qs||r4(),Qs.style.color="#000",Qs.style.color=e;const n=getComputedStyle(Qs).color;Qs.style.color="#fff",Qs.style.color=e;const r=getComputedStyle(Qs).color;if(r!==n)return[0,0,0,1];let i=r.replace(/[^\d.,]/g,"").split(",").map(Number.parseFloat);return i.length<4&&i.push(1),i=i.map(s=>Number.isNaN(s)?0:s),Ug[e]=i,i}function wl(t,e){const[n,r,i]=D0(t);return`rgba(${n}, ${r}, ${i}, ${e})`}const Qx=new Map;function Zx(t,e){const n=`${t}-${e}`,r=Qx.get(n);if(r!==void 0)return r;const i=Vr(t,e);return Qx.set(n,i),i}function Vr(t,e){if(e===void 0)return t;const[n,r,i,s]=D0(t);if(s===1)return t;const[o,l,a,u]=D0(e),c=s+u*(1-s),f=(s*n+u*o*(1-s))/c,d=(s*r+u*l*(1-s))/c,h=(s*i+u*a*(1-s))/c;return`rgba(${f}, ${d}, ${h}, ${c})`}var Yl=new Map,fa=new Map,_0=new Map;function i4(){Yl.clear(),_0.clear(),fa.clear()}function s4(t,e,n,r,i){var s,o,l;let a=0,u={};for(let f of t)a+=(s=n.get(f))!=null?s:i,u[f]=((o=u[f])!=null?o:0)+1;let c=e-a;for(let f of Object.keys(u)){let d=u[f],h=(l=n.get(f))!=null?l:i,p=h*d/a,m=c*p*r/d,x=h+m;n.set(f,x)}}function o4(t,e){var n;let r=new Map,i=0;for(let u of"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?"){let c=t.measureText(u).width;r.set(u,c),i+=c}let s=i/r.size,o=3,l=(e/s+o)/(o+1),a=r.keys();for(let u of a)r.set(u,((n=r.get(u))!=null?n:s)*l);return r}function tc(t,e,n,r){var i,s;let o=fa.get(n);if(r&&o!==void 0&&o.count>2e4){let u=_0.get(n);if(u===void 0&&(u=o4(t,o.size),_0.set(n,u)),o.count>5e5){let f=0;for(let d of e)f+=(i=u.get(d))!=null?i:o.size;return f*1.01}let c=t.measureText(e);return s4(e,c.width,u,Math.max(.05,1-o.count/2e5),o.size),fa.set(n,{count:o.count+e.length,size:o.size}),c.width}let l=t.measureText(e),a=l.width/e.length;if(((s=o==null?void 0:o.count)!=null?s:0)>2e4)return l.width;if(o===void 0)fa.set(n,{count:e.length,size:a});else{let u=a-o.size,c=e.length/(o.count+e.length),f=o.size+u*c;fa.set(n,{count:o.count+e.length,size:f})}return l.width}function l4(t,e,n,r,i,s,o,l){if(e.length<=1)return e.length;if(in;){let c=e.lastIndexOf(" ",a-1);c>0?a=c:a--,u=tc(t,e.slice(0,Math.max(0,a)),r,o)}if(e[a]!==" "){let c=0;c=e.lastIndexOf(" ",a),c>0&&(a=c)}return a}function a4(t,e,n,r,i,s){let o=`${e}_${n}_${r}px`,l=Yl.get(o);if(l!==void 0)return l;if(r<=0)return[];let a=[],u=e.split(` -`),c=fa.get(n),f=c===void 0?e.length:r/c.size*1.5,d=i&&c!==void 0&&c.count>2e4;for(let h of u){let p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f);if(p<=r)a.push(h);else{for(;p>r;){let x=l4(t,h,r,n,p,m,d),g=h.slice(0,Math.max(0,x));h=h.slice(g.length),a.push(g),p=tc(t,h.slice(0,Math.max(0,f)),n,d),m=Math.min(h.length,f)}p>0&&a.push(h)}}return a=a.map((h,p)=>p===0?h.trimEnd():h.trim()),Yl.set(o,a),Yl.size>500&&Yl.delete(Yl.keys().next().value),a}function u4(t,e){return Ln.useMemo(()=>t.map((n,r)=>({group:n.group,grow:n.grow,hasMenu:n.hasMenu,icon:n.icon,id:n.id,menuIcon:n.menuIcon,overlayIcon:n.overlayIcon,sourceIndex:r,sticky:r=s.x&&n=s.y&&r=e.span[0]&&n.current.cell[0]<=e.span[1]}function ZT(t,e){const[n,r]=t;return n>=e.x&&n=e.y&&ro)return!1;if(e.span===void 0)return l>=r&&l<=i;const[u,c]=e.span;return u>=r&&u<=i||c>=r&&u<=i||ui}function d4(t,e,n,r){let i=0;if(n.current===void 0)return i;const s=n.current.range;(r||s.height*s.width>1)&&eb(t,e,s)&&i++;for(const o of n.current.rangeStack)eb(t,e,o)&&i++;return i}function tE(t,e){let n=t;if(e!==void 0){let r=[...t];const i=n[e.src];e.src>e.dest?(r.splice(e.src,1),r.splice(e.dest,0,i)):(r.splice(e.dest+1,0,i),r.splice(e.src,1)),r=r.map((s,o)=>({...s,sticky:t[o].sticky})),n=r}return n}function La(t,e){let n=0;const r=tE(t,e);for(let i=0;i0)for(const u of o)n-=u.width;let l=e,a=i??0;for(;a<=n&&l=f)return m}const d=s-u,h=t-(a??0);if(typeof o=="number"){const p=Math.floor((h-c)/o)+l;return p>=d?void 0:p}else{let p=c;for(let m=l;m"u";async function m4(){var t;g4||((t=document==null?void 0:document.fonts)==null?void 0:t.ready)===void 0||(await document.fonts.ready,_d=0,rc={},i4())}m4();function nE(t,e,n,r){return`${t}_${r??(e==null?void 0:e.font)}_${n}`}function ef(t,e,n,r="middle"){const i=nE(t,e,r,n);let s=rc[i];return s===void 0&&(s=e.measureText(t),rc[i]=s,_d++),_d>1e4&&(rc={},_d=0),s}function y4(t,e){const n=nE(t,void 0,"middle",e);return rc[n]}function js(t,e){return typeof e!="string"&&(e=e.baseFontFull),v4(t,e)}function tb(t,e){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ";t.save(),t.textBaseline=e;const r=t.measureText(n);return t.restore(),r}const nb=[];function v4(t,e){for(const s of nb)if(s.key===e)return s.val;const n=tb(t,"alphabetic"),i=-(tb(t,"middle").actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return nb.push({key:e,val:i}),i}function w4(t,e,n,r,i,s){const{ctx:o,rect:l,theme:a}=t;let u=Number.MAX_SAFE_INTEGER;const c=500;if(e!==void 0&&(u=n-e,un&&(t=t.slice(0,n)),t}function b4(t,e,n,r,i,s,o,l,a,u){const c=l.baseFontFull,f=a4(t,e,c,i-l.cellHorizontalPadding*2,u??!1),d=iE(t,c),h=l.lineHeight*d,p=d+h*(f.length-1),m=p+l.cellVerticalPadding>s;m&&(t.save(),t.rect(n,r,i,s),t.clip());const x=r+s/2-p/2;let g=Math.max(r+l.cellVerticalPadding,x);for(const y of f)if(rE(t,y,n,g,i,d,o,l,a),g+=h,g>r+s)break;m&&t.restore()}function Ms(t,e,n,r,i){const{ctx:s,rect:o,theme:l}=t,{x:a,y:u,width:c,height:f}=o;r=r??!1,r||(e=x4(e,c));const d=js(s,l),h=Yv(e)==="rtl";if(n===void 0&&h&&(n="right"),h&&(s.direction="rtl"),e.length>0){let p=!1;n==="right"?(s.textAlign="right",p=!0):n!==void 0&&n!=="left"&&(s.textAlign=n,p=!0),r?b4(s,e,a,u,c,f,d,l,n,i):rE(s,e,a,u,c,f,d,l,n),p&&(s.textAlign="start"),h&&(s.direction="inherit")}}function fs(t,e,n,r,i,s){typeof s=="number"&&(s={tl:s,tr:s,br:s,bl:s}),s={tl:Math.max(0,Math.min(s.tl,i/2,r/2)),tr:Math.max(0,Math.min(s.tr,i/2,r/2)),bl:Math.max(0,Math.min(s.bl,i/2,r/2)),br:Math.max(0,Math.min(s.br,i/2,r/2))},t.moveTo(e+s.tl,n),t.arcTo(e+r,n,e+r,n+s.tr,s.tr),t.arcTo(e+r,n+i,e+r-s.br,n+i,s.br),t.arcTo(e,n+i,e,n+i-s.bl,s.bl),t.arcTo(e,n,e+s.tl,n,s.tl)}function k4(t,e,n){t.arc(e,n-1.25*3.5,1.25,0,2*Math.PI,!1),t.arc(e,n,1.25,0,2*Math.PI,!1),t.arc(e,n+1.25*3.5,1.25,0,2*Math.PI,!1)}function S4(t,e,n){const r=function(l,a){const u=a.x-l.x,c=a.y-l.y,f=Math.sqrt(u*u+c*c),d=u/f,h=c/f;return{x:u,y:a.y-l.y,len:f,nx:d,ny:h,ang:Math.atan2(h,d)}};let i;const s=e.length;let o=e[s-1];for(let l=0;l1?1:d),m=1,x=!1;h<0?p<0?p=Math.PI+p:(p=Math.PI-p,m=-1,x=!0):p>0&&(m=-1,x=!0),i=a.radius!==void 0?a.radius:n;const g=p/2;let y=Math.abs(Math.cos(g)*i/Math.sin(g)),w;y>Math.min(c.len/2,f.len/2)?(y=Math.min(c.len/2,f.len/2),w=Math.abs(y*Math.sin(g)/Math.cos(g))):w=i;let k=a.x+f.nx*y,b=a.y+f.ny*y;k+=-f.ny*w*m,b+=f.nx*w*m,t.arc(k,b,w,c.ang+Math.PI/2*m,f.ang-Math.PI/2*m,x),o=a,a=u}t.closePath()}function F0(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){const m={x:0,y:s+u,width:0,height:0};if(t>=h.length||e>=c||e<-2||t<0)return m;const x=s-i;if(t>=f){const g=o>t?-1:1,y=La(h);m.x+=y+a;for(let w=o;w!==t;w+=g)m.x+=h[g===1?w:w-1].width*g}else for(let g=0;g0&&Pc(h[g-1].group,y)&&h[g-1].sticky===w;){const b=h[g-1];m.x-=b.width,m.width+=b.width,g--}let k=t;for(;k+1n&&(m.width=n-m.x)}}else if(e>=c-d){let g=c-e;for(m.y=r;g>0;){const y=e+g-1;m.height=typeof p=="number"?p:p(y),m.y-=m.height,g--}m.height+=1}else{const g=l>e?-1:1;if(typeof p=="number"){const y=e-l;m.y+=y*p}else for(let y=l;y!==e;y+=g)m.y+=p(y)*g;m.height=(typeof p=="number"?p:p(e))+1}return m}const Zv=1<<21;function Pi(t,e){return(e+2)*Zv+t}function sE(t){return t%Zv}function ew(t){return Math.floor(t/Zv)-2}function tw(t){const e=sE(t),n=ew(t);return[e,n]}class oE{constructor(){bt(this,"visibleWindow",{x:0,y:0,width:0,height:0});bt(this,"freezeCols",0);bt(this,"freezeRows",[]);bt(this,"isInWindow",e=>{const n=sE(e),r=ew(e),i=this.visibleWindow,s=n>=i.x&&n<=i.x+i.width||n=i.y&&r<=i.y+i.height||this.freezeRows.includes(r);return s&&o})}setWindow(e,n,r){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===n&&_a(this.freezeRows,r)||(this.visibleWindow=e,this.freezeCols=n,this.freezeRows=r,this.clearOutOfWindow())}}class C4 extends oE{constructor(){super(...arguments);bt(this,"cache",new Map);bt(this,"setValue",(n,r)=>{this.cache.set(Pi(n[0],n[1]),r)});bt(this,"getValue",n=>this.cache.get(Pi(n[0],n[1])));bt(this,"clearOutOfWindow",()=>{for(const[n]of this.cache.entries())this.isInWindow(n)||this.cache.delete(n)})}}class ic{constructor(e=[]){bt(this,"cells");this.cells=new Set(e.map(n=>Pi(n[0],n[1])))}add(e){this.cells.add(Pi(e[0],e[1]))}has(e){return e===void 0?!1:this.cells.has(Pi(e[0],e[1]))}remove(e){this.cells.delete(Pi(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(const e of this.cells)if(ew(e)<0)return!0;return!1}hasItemInRectangle(e){for(let n=e.y;n{const h=A4(t,d[r],e,a);return u=Math.max(u,h),h});if(c.length>5&&l){u=0;let d=0;for(const p of c)d+=p;const h=d/c.length;for(let p=0;p=h*2?c[p]=0:u=Math.max(u,c[p])}u=Math.max(u,t.measureText(n.title).width+16+(n.icon===void 0?0:28));const f=Math.max(Math.ceil(s),Math.min(Math.floor(o),Math.ceil(u)));return{...n,width:f}}function M4(t,e,n,r,i,s,o,l,a){const u=v.useRef(e),c=v.useRef(n),f=v.useRef(o);u.current=e,c.current=n,f.current=o;const[d,h]=v.useMemo(()=>{if(typeof window>"u")return[null,null];const y=document.createElement("canvas");return y.style.display="none",y.style.opacity="0",y.style.position="fixed",[y,y.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>(d&&document.documentElement.append(d),()=>{d==null||d.remove()}),[d]);const p=v.useRef({}),m=v.useRef(),[x,g]=v.useState();return v.useLayoutEffect(()=>{const y=c.current;if(y===void 0||t.every(Vf))return;let w=Math.max(1,10-Math.floor(t.length/1e4)),k=0;w1&&(w--,k=1);const b={x:0,y:0,width:t.length,height:Math.min(u.current,w)},S={x:0,y:u.current-1,width:t.length,height:1};(async()=>{const A=y(b,a.signal),M=k>0?y(S,a.signal):void 0;let O;typeof A=="object"?O=A:O=await Px(A),M!==void 0&&(typeof M=="object"?O=[...O,...M]:O=[...O,...await Px(M)]),m.current=t,g(O)})()},[a.signal,t]),v.useMemo(()=>{let w=t.every(Vf)?t:h===null?t.map(T=>Vf(T)?T:{...T,width:$0}):(h.font=f.current.baseFontFull,t.map((T,A)=>{if(Vf(T))return T;if(p.current[T.id]!==void 0)return{...T,width:p.current[T.id]};if(x===void 0||m.current!==t||T.id===void 0)return{...T,width:$0};const M=uE(h,o,T,A,x,i,s,!0,l);return p.current[T.id]=M.width,M})),k=0,b=0;const S=[];for(const[T,A]of w.entries())k+=A.width,A.grow!==void 0&&A.grow>0&&(b+=A.grow,S.push(T));if(k0){const T=[...w],A=r-k;let M=A;for(let O=0;O0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),l=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(a=>{if(a=O4(a),a in rb)return;rb[a]=!0;const u=a.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${a}"]${c}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":R4,u||(f.as="script"),f.crossOrigin="",f.href=a,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((d,h)=>{f.addEventListener("load",d),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${a}`)))})}))}function s(o){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=o,window.dispatchEvent(l),!l.defaultPrevented)throw o}return i.then(o=>{for(const l of o||[])l.status==="rejected"&&s(l.reason);return e().catch(s)})};function P4(t,e,n){return t===t&&(n!==void 0&&(t=t<=n?t:n),e!==void 0&&(t=t>=e?t:e)),t}var I4=P4,N4=I4,Kg=Gv;function D4(t,e,n){return n===void 0&&(n=e,e=void 0),n!==void 0&&(n=Kg(n),n=n===n?n:0),e!==void 0&&(e=Kg(e),e=e===e?e:0),N4(Kg(t),e,n)}var _4=D4;const Oi=ji(_4);var L4="__lodash_hash_undefined__";function F4(t){return this.__data__.set(t,L4),this}var $4=F4;function z4(t){return this.__data__.has(t)}var B4=z4,j4=zv,H4=$4,W4=B4;function Sh(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new j4;++e-1}var rz=nz;function iz(t,e,n){for(var r=-1,i=t==null?0:t.length;++r=Cz){var u=e?null:kz(t);if(u)return Sz(u);o=!1,i=bz,a=new vz}else a=e?[]:l;e:for(;++r0&&n(l)?e>1?gE(l,e-1,n,r,i):Lz(i,l):r||(i[i.length]=l)}return i}var $z=gE,zz=$z;function Bz(t){var e=t==null?0:t.length;return e?zz(t,1):[]}var jz=Bz;const ob=ji(jz);var Hz=Math.ceil,Wz=Math.max;function Vz(t,e,n,r){for(var i=-1,s=Wz(Hz((e-t)/(n||1)),0),o=Array(s);s--;)o[r?s:++i]=t,t+=n;return o}var Uz=Vz,Kz=ET,Xz=Wv;function Gz(t){return t!=null&&Xz(t.length)&&!Kz(t)}var rw=Gz,qz=Fv,Yz=rw,Jz=Hv,Qz=El;function Zz(t,e,n){if(!Qz(n))return!1;var r=typeof e;return(r=="number"?Yz(n)&&Jz(e,n.length):r=="string"&&e in n)?qz(n[e],t):!1}var e5=Zz,t5=Gv,lb=1/0,n5=17976931348623157e292;function r5(t){if(!t)return t===0?t:0;if(t=t5(t),t===lb||t===-lb){var e=t<0?-1:1;return e*n5}return t===t?t:0}var i5=r5,s5=Uz,o5=e5,Gg=i5;function l5(t){return function(e,n,r){return r&&typeof r!="number"&&o5(e,n,r)&&(n=r=void 0),e=Gg(e),n===void 0?(n=e,e=0):n=Gg(n),r=r===void 0?e{m.drawImage(x,0,0,f,f)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else a<1&&(r.globalAlpha=a),r.drawImage(h,0,0,f,f,i,s,o,o),a<1&&(r.globalAlpha=1)}}function mE(t){if(t.length===0)return;let e;for(const n of t)e=Math.min(e??n.y,n.y)}function Ep(t,e,n,r,i,s,o,l,a){l=l??e;let u=e,c=t;const f=r-s;let d=!1;for(;ul&&a(u,c,h,!1,o&&c===r-1)===!0){d=!0;break}u+=h,c++}if(!d){u=n;for(let h=0;h!h.sticky))==null?void 0:d.sourceIndex)??0;if(a>f){const h=Math.max(l,f);let p=e,m=r;for(let x=s.sourceIndex-1;x>=h;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=a;x++)m+=o[x].width;c={x:p,y:n,width:m,height:i}}if(f>l){const h=Math.min(a,f-1);let p=e,m=r;for(let x=s.sourceIndex-1;x>=l;x--)p-=o[x].width,m+=o[x].width;for(let x=s.sourceIndex+1;x<=h;x++)m+=o[x].width;u={x:p,y:n,width:m,height:i}}return[u,c]}function p5(t,e,n,r){if(r==="any")return wE(t,{x:e,y:n,width:1,height:1});if(r==="vertical"&&(e=t.x),r==="horizontal"&&(n=t.y),ZT([e,n],t))return;const i=e-t.x,s=t.x+t.width-e,o=n-t.y+1,l=t.y+t.height-n,a=Math.min(r==="vertical"?Number.MAX_SAFE_INTEGER:i,r==="vertical"?Number.MAX_SAFE_INTEGER:s,r==="horizontal"?Number.MAX_SAFE_INTEGER:o,r==="horizontal"?Number.MAX_SAFE_INTEGER:l);return a===l?{x:t.x,y:t.y+t.height,width:t.width,height:n-t.y-t.height+1}:a===o?{x:t.x,y:n,width:t.width,height:t.y-n}:a===s?{x:t.x+t.width,y:t.y,width:e-t.x-t.width+1,height:t.height}:{x:e,y:t.y,width:t.x-e,height:t.height}}function Ch(t,e,n,r,i,s,o,l){return t<=i+o&&i<=t+n&&e<=s+l&&s<=e+r}function Ap(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height}function wE(t,e){const n=Math.min(t.x,e.x),r=Math.min(t.y,e.y),i=Math.max(t.x+t.width,e.x+e.width)-n,s=Math.max(t.y+t.height,e.y+e.height)-r;return{x:n,y:r,width:i,height:s}}function g5(t,e){return t.x<=e.x&&t.y<=e.y&&t.x+t.width>=e.x+e.width&&t.y+t.height>=e.y+e.height}function m5(t,e,n,r){if(t.x>e||t.y>n||t.x<0&&t.y<0&&t.x+t.width>e&&t.y+t.height>n)return;if(t.x>=0&&t.y>=0&&t.x+t.width<=e&&t.y+t.height<=n)return t;const i=-4,s=-4,o=e+4,l=n+4,a=i-t.x,u=t.x+t.width-o,c=s-t.y,f=t.y+t.height-l,d=a>0?t.x+Math.floor(a/r)*r:t.x,h=u>0?t.x+t.width-Math.floor(u/r)*r:t.x+t.width,p=c>0?t.y+Math.floor(c/r)*r:t.y,m=f>0?t.y+t.height-Math.floor(f/r)*r:t.y+t.height;return{x:d,y:p,width:h-d,height:m-p}}function y5(t,e,n,r,i){const[s,o,l,a]=e,[u,c,f,d]=i,{x:h,y:p,width:m,height:x}=t,g=[];if(m<=0||x<=0)return g;const y=h+m,w=p+x,k=hl,T=p+x>a,A=h>=s&&hs&&y<=l||hl,M=p>=o&&po&&w<=a||pa;if(A&&M){const _=Math.max(h,s),P=Math.max(p,o),I=Math.min(y,l),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:c,width:f-u+1,height:d-c+1}})}if(k&&b){const _=h,P=p,I=Math.min(y,s),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:0,width:u+1,height:c+1}})}if(b&&A){const _=Math.max(h,s),P=p,I=Math.min(y,l),D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:0,width:f-u+1,height:c+1}})}if(b&&S){const _=Math.max(h,l),P=p,I=y,D=Math.min(w,o);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:0,width:n-f+1,height:c+1}})}if(k&&M){const _=h,P=Math.max(p,o),I=Math.min(y,s),D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:c,width:u+1,height:d-c+1}})}if(S&&M){const _=Math.max(h,l),P=Math.max(p,o),I=y,D=Math.min(w,a);g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:c,width:n-f+1,height:d-c+1}})}if(k&&T){const _=h,P=Math.max(p,a),I=Math.min(y,s),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:0,y:d,width:u+1,height:r-d+1}})}if(T&&A){const _=Math.max(h,s),P=Math.max(p,a),I=Math.min(y,l),D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:u,y:d,width:f-u+1,height:r-d+1}})}if(S&&T){const _=Math.max(h,l),P=Math.max(p,a),I=y,D=w;g.push({rect:{x:_,y:P,width:I-_,height:D-P},clip:{x:f,y:d,width:n-f+1,height:r-d+1}})}return g}const v5={kind:Te.Loading,allowOverlay:!1};function ab(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A,M,O,_,P,I,D,ee,ie,te,W){let V=(w==null?void 0:w.size)??Number.MAX_SAFE_INTEGER;const R=performance.now();let N=I.baseFontFull;t.font=N;const L={ctx:t},H=[0,0],G=x>0?Rl(a,x,u):0;let B,le;const me=mE(y);return Lo(e,l,s,o,i,(ye,oe,be,Ce,lt)=>{const Xe=Math.max(0,Ce-oe),Ge=oe+Xe,at=i+1,Ut=ye.width-Xe,Pe=r-i-1;if(y.length>0){let wt=!1;for(let rt=0;rt{t.save(),t.beginPath(),t.rect(Ge,at,Ut,Pe),t.clip()},Je=k.columns.hasIndex(ye.sourceIndex),nt=f(ye.group??"").overrideTheme,it=ye.themeOverride===void 0&&nt===void 0?I:To(I,nt,ye.themeOverride),$e=it.baseFontFull;$e!==N&&(N=$e,t.font=$e),xe();let At;return Ep(lt,be,r,a,u,x,g,me,(wt,rt,ge,_e,Qe)=>{var Le,ze,An;if(rt<0||(H[0]=ye.sourceIndex,H[1]=rt,w!==void 0&&!w.has(H)))return;if(y.length>0){let z=!1;for(let ue=0;uedt.span!==void 0&&z>=dt.span[0]&&z<=dt.span[1]);vn&&!p&&m?In=0:vn&&m&&(In=Math.max(In,1)),Pr&&In++,vn||(tt&&In++,Je&&!Qe&&In++);const Ir=dt.kind===Te.Protected?Pt.bgCellMedium:Pt.bgCell;let Bt;if((_e||Ir!==I.bgCell)&&(Bt=Vr(Ir,Bt)),In>0||Kt){Kt&&(Bt=Vr(Pt.bgHeader,Bt));for(let z=0;zW&&!Rt){const z=Pt.baseFontFull;z!==N&&(t.font=z,N=z),At=xE(t,dt,ye.sourceIndex,rt,xt,dn,ht,wt,pt,ge,In>0,Pt,Bt??Pt.bgCell,T,A,(ne==null?void 0:ne.hoverAmount)??0,O,P,R,_,At,D,ee,ie,te)}return ct&&t.restore(),dt.style==="faded"&&(t.globalAlpha=1),V--,Lt&&(t.restore(),(An=At==null?void 0:At.deprep)==null||An.call(At,L),At=void 0,xe(),N=$e,t.font=$e),V<=0}),t.restore(),V<=0}),B}const Au=[0,0],Mu={x:0,y:0,width:0,height:0},qg=[void 0,()=>{}];let z0=!1;function w5(){z0=!0}function xE(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y,w,k,b,S,T,A){var ee,ie;let M,O;x!==void 0&&x[0][0]===n&&x[0][1]===r&&(M=x[1][0],O=x[1][1]);let _;Au[0]=n,Au[1]=r,Mu.x=o,Mu.y=l,Mu.width=a,Mu.height=u,qg[0]=S.getValue(Au),qg[1]=te=>S.setValue(Au,te),z0=!1;const P={ctx:t,theme:f,col:n,row:r,cell:e,rect:Mu,highlighted:c,cellFillColor:d,hoverAmount:m,frameTime:y,hoverX:M,drawState:qg,hoverY:O,imageLoader:h,spriteManager:p,hyperWrapping:g,overrideCursor:M!==void 0?A:void 0,requestAnimationFrame:w5},I=w4(P,e.lastUpdated,y,k,i,s),D=T(e);if(D!==void 0){(k==null?void 0:k.renderer)!==D&&((ee=k==null?void 0:k.deprep)==null||ee.call(k,P),k=void 0);const te=(ie=D.drawPrep)==null?void 0:ie.call(D,P,k);w!==void 0&&!ca(P.cell)?w(P,()=>D.draw(P,e)):D.draw(P,e),_=te===void 0?void 0:{deprep:te==null?void 0:te.deprep,fillStyle:te==null?void 0:te.fillStyle,font:te==null?void 0:te.font,renderer:D}}return(I||z0)&&(b==null||b(Au)),_}function iw(t,e,n,r,i,s,o,l,a=-20,u=-20,c=32,f="center",d="square"){const h=Math.floor(i+o/2),p=d==="circle"?1e4:e.roundingRadius??4;let m=WT(c,o,e.cellVerticalPadding),x=m/2;const g=HT(f,r,s,e.cellHorizontalPadding,m),y=jT(g,h,m),w=VT(r+a,i+u,y);switch(n){case!0:{t.beginPath(),fs(t,g-m/2,h-m/2,m,m,p),d==="circle"&&(x*=.8,m*=.8),t.fillStyle=l?e.accentColor:e.textMedium,t.fill(),t.beginPath(),t.moveTo(g-x+m/4.23,h-x+m/1.97),t.lineTo(g-x+m/2.42,h-x+m/1.44),t.lineTo(g-x+m/1.29,h-x+m/3.25),t.strokeStyle=e.bgCell,t.lineJoin="round",t.lineCap="round",t.lineWidth=1.9,t.stroke();break}case mh:case!1:{t.beginPath(),fs(t,g-m/2+.5,h-m/2+.5,m-1,m-1,p),t.lineWidth=1,t.strokeStyle=w?e.textDark:e.textMedium,t.stroke();break}case Vv:{t.beginPath(),fs(t,g-m/2,h-m/2,m,m,p),t.fillStyle=w?e.textMedium:e.textLight,t.fill(),d==="circle"&&(x*=.8,m*=.8),t.beginPath(),t.moveTo(g-m/3,h),t.lineTo(g+m/3,h),t.strokeStyle=e.bgCell,t.lineCap="round",t.lineWidth=1.9,t.stroke();break}default:Oc()}}function x5(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=o+l;if(w<=0)return;t.fillStyle=f.bgHeader,t.fillRect(0,0,i,w);const[k,b]=(r==null?void 0:r[0])??[],S=f.headerFontFull;t.font=S,Lo(e,0,s,0,w,(T,A,M,O)=>{var L;if(x!==void 0&&!x.has([T.sourceIndex,-1]))return;const _=Math.max(0,O-A);t.save(),t.beginPath(),t.rect(A+_,l,T.width-_,o),t.clip();const P=m(T.group??"").overrideTheme,I=T.themeOverride===void 0&&P===void 0?f:To(f,P,T.themeOverride);I.bgHeader!==f.bgHeader&&(t.fillStyle=I.bgHeader,t.fill()),I!==f&&(t.font=I.baseFontFull);const D=c.columns.hasIndex(T.sourceIndex),ee=a!==void 0||u,ie=!ee&&b===-1&&k===T.sourceIndex,te=ee?0:((L=h.find(H=>H.item[0]===T.sourceIndex&&H.item[1]===-1))==null?void 0:L.hoverAmount)??0,W=(c==null?void 0:c.current)!==void 0&&c.current.cell[0]===T.sourceIndex,V=D?I.accentColor:W?I.bgHeaderHasFocus:I.bgHeader,R=n?l:0,N=T.sourceIndex===0?0:1;D?(t.fillStyle=V,t.fillRect(A+N,R,T.width-N,o)):(W||te>0)&&(t.beginPath(),t.rect(A+N,R,T.width-N,o),W&&(t.fillStyle=I.bgHeaderHasFocus,t.fill()),te>0&&(t.globalAlpha=te,t.fillStyle=I.bgHeaderHovered,t.fill(),t.globalAlpha=1)),SE(t,A,R,T.width,o,T,D,I,ie,W,te,d,g,y),t.restore()}),n&&b5(t,e,i,s,l,r,f,d,h,p,m,x)}function b5(t,e,n,r,i,s,o,l,a,u,c,f){const[h,p]=(s==null?void 0:s[0])??[];let m=0;yE(e,n,r,i,(x,g,y,w,k,b)=>{if(f!==void 0&&!f.hasItemInRectangle({x:x[0],y:-2,width:x[1]-x[0]+1,height:1}))return;t.save(),t.beginPath(),t.rect(y,w,k,b),t.clip();const S=c(g),T=(S==null?void 0:S.overrideTheme)===void 0?o:To(o,S.overrideTheme),A=p===-2&&h!==void 0&&h>=x[0]&&h<=x[1],M=A?T.bgHeaderHovered:T.bgHeader;if(M!==o.bgHeader&&(t.fillStyle=M,t.fill()),t.fillStyle=T.textGroupHeader??T.textHeader,S!==void 0){let O=y;if(S.icon!==void 0&&(l.drawSprite(S.icon,"normal",t,O+8,(i-20)/2,20,T),O+=26),t.fillText(S.name,O+8,i/2+js(t,o.headerFontFull)),S.actions!==void 0&&A){const _=kE({x:y,y:w,width:k,height:b},S.actions);t.beginPath();const P=_[0].x-10,I=y+k-P;t.rect(P,0,I,i);const D=t.createLinearGradient(P,0,P+I,0),ee=wl(M,0);D.addColorStop(0,ee),D.addColorStop(10/I,M),D.addColorStop(1,M),t.fillStyle=D,t.fill(),t.globalAlpha=.6;const[ie,te]=(s==null?void 0:s[1])??[-1,-1];for(let W=0;W35){const k=d?35:r-35,b=d?35*.7:r-35*.7,S=k/r,T=b/r,A=t.createLinearGradient(e,0,e+r,0),M=wl(m,0);A.addColorStop(d?1:0,m),A.addColorStop(S,m),A.addColorStop(T,M),A.addColorStop(d?0:1,M),t.fillStyle=A}else t.fillStyle=m;if(d&&(t.textAlign="right"),t.fillText(s.title,y,n+i/2+js(t,l.headerFontFull)),d&&(t.textAlign="left"),x&&s.hasMenu===!0)if(s.menuIcon===void 0||s.menuIcon===yh.Triangle){t.beginPath();const w=h.x+h.width/2-5.5,k=h.y+h.height/2-3;S4(t,[{x:w,y:k},{x:w+11,y:k},{x:w+5.5,y:k+6}],1),t.fillStyle=m,t.fill()}else if(s.menuIcon===yh.Dots){t.beginPath();const w=h.x+h.width/2,k=h.y+h.height/2;k4(t,w,k),t.fillStyle=m,t.fill()}else{const w=h.x+(h.width-l.headerIconSize)/2,k=h.y+(h.height-l.headerIconSize)/2;c.drawSprite(s.menuIcon,"normal",t,w,k,l.headerIconSize,l)}}function SE(t,e,n,r,i,s,o,l,a,u,c,f,d,h){const p=Yv(s.title)==="rtl",m=bE(e,n,r,i,p);d!==void 0?d({ctx:t,theme:l,rect:{x:e,y:n,width:r,height:i},column:s,columnIndex:s.sourceIndex,isSelected:o,hoverAmount:c,isHovered:a,hasSelectedCell:u,spriteManager:f,menuBounds:m},()=>ub(t,e,n,r,i,s,o,l,a,c,f,h,p,m)):ub(t,e,n,r,i,s,o,l,a,c,f,h,p,m)}var k5=Al,S5=function(){try{var t=k5(Object,"defineProperty");return t({},"",{}),t}catch{}}(),C5=S5,cb=C5;function T5(t,e,n){e=="__proto__"&&cb?cb(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}var E5=T5;function A5(t,e,n,r){for(var i=-1,s=t==null?0:t.length;++il))return!1;var u=s.get(t),c=s.get(e);if(u&&c)return u==e&&c==t;var f=-1,d=!0,h=n&Dj?new Oj:void 0;for(s.set(t,e),s.set(e,t);++f{if(k!==e[e.length-1])return;b+=k.width;const M=Math.max(b,T);M>r||(t.save(),t.beginPath(),t.rect(M,s+1,1e4,i-s-1),t.clip(),Ep(A,S,i,u,c,p,m,w,(O,_,P,I)=>{if(!I&&x.length>0&&!x.some(W=>Ch(b,O,1e4,P,W.x,W.y,W.width,W.height)))return;const D=d.hasIndex(_),ee=h.hasIndex(_);t.beginPath();const ie=f==null?void 0:f(_),te=ie===void 0?y:To(y,ie);te.bgCell!==y.bgCell&&(t.fillStyle=te.bgCell,t.fillRect(b,O,1e4,P)),ee&&(t.fillStyle=te.bgHeader,t.fillRect(b,O,1e4,P)),D&&(t.fillStyle=te.accentLight,t.fillRect(b,O,1e4,P))}),t.restore())})}function TW(t,e,n,r,i,s,o,l,a){let u=!1;for(const p of e)if(!p.sticky){u=o(p.sourceIndex);break}const c=a.horizontalBorderColor??a.borderColor,f=a.borderColor,d=u?La(e):0;let h;if(d!==0&&(h=Zx(f,a.bgCell),t.beginPath(),t.moveTo(d+.5,0),t.lineTo(d+.5,r),t.strokeStyle=h,t.stroke()),i>0){const p=f===c&&h!==void 0?h:Zx(c,a.bgCell),m=Rl(s,i,l);t.beginPath(),t.moveTo(0,r-m+.5),t.lineTo(n,r-m+.5),t.strokeStyle=p,t.stroke()}}const DE=(t,e,n)=>{let r=0,i=e,s=0,o=n;if(t!==void 0&&t.length>0){r=Number.MAX_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER;for(const l of t)r=Math.min(r,l.x-1),i=Math.max(i,l.x+l.width+1),s=Math.min(s,l.y-1),o=Math.max(o,l.y+l.height+1)}return{minX:r,maxX:i,minY:s,maxY:o}};function EW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p){var P;const m=p.bgCell,{minX:x,maxX:g,minY:y,maxY:w}=DE(l,s,o),k=[],b=o-Rl(h,d,u);let S=a,T=n,A=0;for(;S+i=y&&I<=w-1){const ee=c==null?void 0:c(T),ie=ee==null?void 0:ee.bgCell;ie!==void 0&&ie!==m&&T>=h-d&&k.push({x,y:I,w:g-x,h:D,color:ie})}S+=D,T0)for(let I=0;I=x&&ee<=g&&f(I+1)&&k.push({x:ee,y:A,w:D.width,h:O,color:ie}),M+=D.width}if(k.length===0)return;let _;t.beginPath();for(let I=k.length-1;I>=0;I--){const D=k[I];_===void 0?_=D.color:D.color!==_&&(t.fillStyle=_,t.fill(),t.beginPath(),_=D.color),t.rect(D.x,D.y,D.w,D.h)}_!==void 0&&(t.fillStyle=_,t.fill()),t.beginPath()}function Ob(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g=!1){if(a!==void 0){t.beginPath(),t.save(),t.rect(0,0,s,o);for(const P of a)t.rect(P.x+1,P.y+1,P.width-1,P.height-1);t.clip("evenodd")}const y=x.horizontalBorderColor??x.borderColor,w=x.borderColor,{minX:k,maxX:b,minY:S,maxY:T}=DE(l,s,o),A=[];t.beginPath();let M=.5;for(let P=0;P=k&&D<=b&&h(P+1)&&A.push({x1:D,y1:Math.max(u,S),x2:D,y2:Math.min(o,T),color:w})}let O=o+.5;for(let P=m-p;P=S&&ee<=T-1){const ie=d==null?void 0:d(I);A.push({x1:k,y1:ee,x2:b,y2:ee,color:(ie==null?void 0:ie.horizontalBorderColor)??(ie==null?void 0:ie.borderColor)??y})}P+=f(I),I++}}const _=SW(A,P=>P.color);for(const P of Object.keys(_)){t.strokeStyle=P;for(const I of _[P])t.moveTo(I.x1,I.y1),t.lineTo(I.x2,I.y2);t.stroke(),t.beginPath()}a!==void 0&&t.restore()}function AW(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x,g,y){const w=[];t.imageSmoothingEnabled=!1;const k=Math.min(i.cellYOffset,o),b=Math.max(i.cellYOffset,o);let S=0;if(typeof g=="number")S+=(b-k)*g;else for(let D=k;Di.cellYOffset&&(S=-S),S+=a-i.translateY;const T=Math.min(i.cellXOffset,s),A=Math.max(i.cellXOffset,s);let M=0;for(let D=T;Di.cellXOffset&&(M=-M),M+=l-i.translateX;const O=La(x);if(M!==0&&S!==0)return{regions:[]};const _=u>0?Rl(d,u,g):0,P=c-O-Math.abs(M),I=f-h-_-Math.abs(S)-1;if(P>150&&I>150){const D={sx:0,sy:0,sw:c*p,sh:f*p,dx:0,dy:0,dw:c*p,dh:f*p};if(S>0?(D.sy=(h+1)*p,D.sh=I*p,D.dy=(S+h+1)*p,D.dh=I*p,w.push({x:0,y:h,width:c,height:S+1})):S<0&&(D.sy=(-S+h+1)*p,D.sh=I*p,D.dy=(h+1)*p,D.dh=I*p,w.push({x:0,y:f+S-_,width:c,height:-S+_})),M>0?(D.sx=O*p,D.sw=P*p,D.dx=(M+O)*p,D.dw=P*p,w.push({x:O-1,y:0,width:M+2,height:f})):M<0&&(D.sx=(O-M)*p,D.sw=P*p,D.dx=O*p,D.dw=P*p,w.push({x:c+M,y:0,width:-M,height:f})),t.setTransform(1,0,0,1,0,0),y){if(O>0&&M!==0&&S===0&&(r===void 0||(n==null?void 0:n[1])!==!1)){const ee=O*p,ie=f*p;t.drawImage(e,0,0,ee,ie,0,0,ee,ie)}if(_>0&&M===0&&S!==0&&(r===void 0||(n==null?void 0:n[0])!==!1)){const ee=(f-_)*p,ie=c*p,te=_*p;t.drawImage(e,0,ee,ie,te,0,ee,ie,te)}}t.drawImage(e,D.sx,D.sy,D.sw,D.sh,D.dx,D.dy,D.dw,D.dh),t.scale(p,p)}return t.imageSmoothingEnabled=!0,{regions:w}}function MW(t,e,n,r,i,s,o,l,a,u){const c=[];return e!==t.cellXOffset||n!==t.cellYOffset||r!==t.translateX||i!==t.translateY||Lo(a,n,r,i,l,(f,d,h,p)=>{if(f.sourceIndex===u){const m=Math.max(d,p)+1;return c.push({x:m,y:0,width:s-m,height:o}),!0}}),c}function RW(t,e){if(e===void 0||t.width!==e.width||t.height!==e.height||t.theme!==e.theme||t.headerHeight!==e.headerHeight||t.rowHeight!==e.rowHeight||t.rows!==e.rows||t.freezeColumns!==e.freezeColumns||t.getRowThemeOverride!==e.getRowThemeOverride||t.isFocused!==e.isFocused||t.isResizing!==e.isResizing||t.verticalBorder!==e.verticalBorder||t.getCellContent!==e.getCellContent||t.highlightRegions!==e.highlightRegions||t.selection!==e.selection||t.dragAndDropState!==e.dragAndDropState||t.prelightCells!==e.prelightCells||t.touchMode!==e.touchMode||t.maxScaleFactor!==e.maxScaleFactor)return!1;if(t.mappedColumns!==e.mappedColumns){if(t.mappedColumns.length>100||t.mappedColumns.length!==e.mappedColumns.length)return!1;let n;for(let r=0;rT.style!=="no-outline");if(x===void 0||x.length===0)return;const g=La(l),y=Rl(h,d,f),w=[a,0,l.length,h-d],k=[g,0,e,n-y],b=x.map(T=>{const A=T.range,M=T.style??"dashed";return y5(A,w,e,n,k).map(O=>{const _=O.rect,P=F0(_.x,_.y,e,n,c,u+c,r,i,s,o,h,a,d,l,f),I=_.width===1&&_.height===1?P:F0(_.x+_.width-1,_.y+_.height-1,e,n,c,u+c,r,i,s,o,h,a,d,l,f);return _.x+_.width>=l.length&&(I.width-=1),_.y+_.height>=h&&(I.height-=1),{color:T.color,style:M,clip:O.clip,rect:m5({x:P.x,y:P.y,width:I.x+I.width-P.x,height:I.y+I.height-P.y},e,n,8)}})}),S=()=>{t.lineWidth=1;let T=!1;for(const A of b)for(const M of A)if((M==null?void 0:M.rect)!==void 0&&Ch(0,0,e,n,M.rect.x,M.rect.y,M.rect.width,M.rect.height)){const O=T,_=!g5(M.clip,M.rect);_&&(t.save(),t.rect(M.clip.x,M.clip.y,M.clip.width,M.clip.height),t.clip()),M.style==="dashed"&&!T?(t.setLineDash([5,3]),T=!0):(M.style==="solid"||M.style==="solid-outline")&&T&&(t.setLineDash([]),T=!1),t.strokeStyle=M.style==="solid-outline"?Vr(Vr(M.color,m.borderColor),m.bgCell):wl(M.color,1),t.strokeRect(M.rect.x+.5,M.rect.y+.5,M.rect.width-1,M.rect.height-1),_&&(t.restore(),T=O)}T&&t.setLineDash([])};return S(),S}function Ib(t,e,n,r,i){t.beginPath(),t.moveTo(e,n),t.lineTo(e,r),t.lineWidth=2,t.strokeStyle=i,t.stroke(),t.globalAlpha=1}function Qg(t,e,n,r,i,s,o,l,a,u,c,f,d,h,p,m,x){if(c.current===void 0)return;const g=c.current.range,y=c.current.cell,w=[g.x+g.width-1,g.y+g.height-1];if(y[1]>=x&&w[1]>=x||!o.some(D=>D.sourceIndex===y[0]||D.sourceIndex===w[0]))return;const[b,S]=c.current.cell,T=d(c.current.cell),A=T.span??[b,b],M=S>=x-h,O=h>0&&!M?Rl(x,h,f)-1:0,_=w[1];let P;if(Lo(o,r,i,s,u,(D,ee,ie,te,W)=>{if(D.sticky&&b>D.sourceIndex)return;const V=D.sourceIndexA[1],N=D.sourceIndex===w[0];if(!(!N&&(V||R)))return Ep(W,ie,n,x,f,h,p,void 0,(L,H,G)=>{if(H!==S&&H!==_)return;let B=ee,le=D.width;if(T.span!==void 0){const ye=vE(T.span,ee,L,D.width,G,D,l),oe=D.sticky?ye[0]:ye[1];oe!==void 0&&(B=oe.x,le=oe.width)}return H===_&&N&&m&&(P=()=>{var ye;te>B&&!D.sticky&&(t.beginPath(),t.rect(te,0,e-te,n),t.clip()),t.beginPath(),t.rect(B+le-4,L+G-4,4,4),t.fillStyle=((ye=D.themeOverride)==null?void 0:ye.accentColor)??a.accentColor,t.fill()}),P!==void 0}),P!==void 0}),P===void 0)return;const I=()=>{t.save(),t.beginPath(),t.rect(0,u,e,n-u-O),t.clip(),P==null||P(),t.restore()};return I(),I}function OW(t,e,n,r,i,s,o,l,a){a===void 0||a.size===0||(t.beginPath(),yE(e,n,s,r,(u,c,f,d,h,p)=>{a.hasItemInRectangle({x:u[0],y:-2,width:u[1]-u[0]+1,height:1})&&t.rect(f,d,h,p)}),Lo(e,l,s,o,i,(u,c,f,d)=>{const h=Math.max(0,d-c),p=c+h+1,m=u.width-h-1;a.has([u.sourceIndex,-1])&&t.rect(p,r,m,i-r)}),t.clip())}function PW(t,e,n,r,i,s,o,l,a,u){let c=0;return Lo(t,s,r,i,n,(f,d,h,p,m)=>(Ep(m,h,e,o,l,a,u,void 0,(x,g,y,w)=>{w||(c=Math.max(g,c))}),!0)),c}function Nb(t,e){var ct;const{canvasCtx:n,headerCanvasCtx:r,width:i,height:s,cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mappedColumns:c,enableGroups:f,freezeColumns:d,dragAndDropState:h,theme:p,drawFocus:m,headerHeight:x,groupHeaderHeight:g,disabledRows:y,rowHeight:w,verticalBorder:k,overrideCursor:b,isResizing:S,selection:T,fillHandle:A,freezeTrailingRows:M,rows:O,getCellContent:_,getGroupDetails:P,getRowThemeOverride:I,isFocused:D,drawHeaderCallback:ee,prelightCells:ie,drawCellCallback:te,highlightRegions:W,resizeCol:V,imageLoader:R,lastBlitData:N,hoverValues:L,hyperWrapping:H,hoverInfo:G,spriteManager:B,maxScaleFactor:le,hasAppendRow:me,touchMode:ye,enqueue:oe,renderStateProvider:be,getCellRenderer:Ce,renderStrategy:lt,bufferACtx:Xe,bufferBCtx:Ge,damage:at,minimumCellWidth:Ut}=t;if(i===0||s===0)return;const Pe=lt==="double-buffer",xe=Math.min(le,Math.ceil(window.devicePixelRatio??1)),Je=lt!=="direct"&&RW(t,e),nt=n.canvas;(nt.width!==i*xe||nt.height!==s*xe)&&(nt.width=i*xe,nt.height=s*xe,nt.style.width=i+"px",nt.style.height=s+"px");const it=r.canvas,$e=f?g+x:x,At=$e+1;(it.width!==i*xe||it.height!==At*xe)&&(it.width=i*xe,it.height=At*xe,it.style.width=i+"px",it.style.height=At+"px");const wt=Xe.canvas,rt=Ge.canvas;Pe&&(wt.width!==i*xe||wt.height!==s*xe)&&(wt.width=i*xe,wt.height=s*xe,N.current!==void 0&&(N.current.aBufferScroll=void 0)),Pe&&(rt.width!==i*xe||rt.height!==s*xe)&&(rt.width=i*xe,rt.height=s*xe,N.current!==void 0&&(N.current.bBufferScroll=void 0));const ge=N.current;if(Je===!0&&o===(ge==null?void 0:ge.cellXOffset)&&l===(ge==null?void 0:ge.cellYOffset)&&a===(ge==null?void 0:ge.translateX)&&u===(ge==null?void 0:ge.translateY))return;let _e=null;Pe&&(_e=n);const Qe=r;let tt;Pe?at!==void 0?tt=(ge==null?void 0:ge.lastBuffer)==="b"?Ge:Xe:tt=(ge==null?void 0:ge.lastBuffer)==="b"?Xe:Ge:tt=n;const Kt=tt.canvas,dt=Pe?Kt===wt?rt:wt:nt,ht=typeof w=="number"?()=>w:w;Qe.save(),tt.save(),Qe.beginPath(),tt.beginPath(),Qe.textBaseline="middle",tt.textBaseline="middle",xe!==1&&(Qe.scale(xe,xe),tt.scale(xe,xe));const pt=L0(c,o,i,h,a);let Lt=[];const Rt=m&&((ct=T.current)==null?void 0:ct.cell[1])===l&&u===0;let en=!1;if(W!==void 0){for(const xt of W)if(xt.style!=="no-outline"&&xt.range.y===l&&u===0){en=!0;break}}const Hn=()=>{x5(Qe,pt,f,G,i,a,x,g,h,S,T,p,B,L,k,P,at,ee,ye),Ob(Qe,pt,l,a,u,i,s,void 0,void 0,g,$e,ht,I,k,M,O,p,!0),Qe.beginPath(),Qe.moveTo(0,At-.5),Qe.lineTo(i,At-.5),Qe.strokeStyle=Vr(p.headerBottomBorderColor??p.horizontalBorderColor??p.borderColor,p.bgHeader),Qe.stroke(),en&&Pb(Qe,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),Rt&&Qg(Qe,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O)};if(at!==void 0){const xt=pt[pt.length-1].sourceIndex+1,dn=at.hasItemInRegion([{x:o,y:-2,width:xt,height:2},{x:o,y:l,width:xt,height:300},{x:0,y:l,width:d,height:300},{x:0,y:-2,width:d,height:2},{x:o,y:O-M,width:xt,height:M,when:M>0}]),ne=Le=>{ab(Le,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,me,Lt,at,T,ie,W,R,B,L,G,te,H,p,oe,be,Ce,b,Ut);const ze=T.current;A&&m&&ze!==void 0&&at.has(eE(ze.range))&&Qg(Le,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O)};dn&&(ne(tt),_e!==null&&(_e.save(),_e.scale(xe,xe),_e.textBaseline="middle",ne(_e),_e.restore()),at.hasHeader()&&(OW(Qe,pt,i,g,$e,a,u,l,at),Hn())),tt.restore(),Qe.restore();return}if((Je!==!0||o!==(ge==null?void 0:ge.cellXOffset)||a!==(ge==null?void 0:ge.translateX)||Rt!==(ge==null?void 0:ge.mustDrawFocusOnHeader)||en!==(ge==null?void 0:ge.mustDrawHighlightRingsOnHeader))&&Hn(),Je===!0){Wr(dt!==void 0&&ge!==void 0);const{regions:xt}=AW(tt,dt,dt===wt?ge.aBufferScroll:ge.bBufferScroll,dt===wt?ge.bBufferScroll:ge.aBufferScroll,ge,o,l,a,u,M,i,s,O,$e,xe,c,pt,w,Pe);Lt=xt}else Je!==!1&&(Wr(ge!==void 0),Lt=MW(ge,o,l,a,u,i,s,$e,pt,Je));TW(tt,pt,i,s,M,O,k,ht,p);const Pt=Pb(tt,i,s,o,l,a,u,c,d,x,g,w,M,O,W,p),vn=m?Qg(tt,i,s,l,a,u,pt,c,p,$e,T,ht,_,M,me,A,O):void 0;if(tt.fillStyle=p.bgCell,Lt.length>0){tt.beginPath();for(const xt of Lt)tt.rect(xt.x,xt.y,xt.width,xt.height);tt.clip(),tt.fill(),tt.beginPath()}else tt.fillRect(0,0,i,s);const In=ab(tt,pt,c,s,$e,a,u,l,O,ht,_,P,I,y,D,m,M,me,Lt,at,T,ie,W,R,B,L,G,te,H,p,oe,be,Ce,b,Ut);CW(tt,pt,c,i,s,$e,a,u,l,O,ht,I,T.rows,y,M,me,Lt,at,p),EW(tt,pt,l,a,u,i,s,Lt,$e,ht,I,k,M,O,p),Ob(tt,pt,l,a,u,i,s,Lt,In,g,$e,ht,I,k,M,O,p),Pt==null||Pt(),vn==null||vn(),S&&Lo(pt,0,a,0,$e,(xt,dn)=>xt.sourceIndex===V?(Ib(Qe,dn+xt.width,0,$e+1,Vr(p.resizeIndicatorColor??p.accentLight,p.bgHeader)),Ib(tt,dn+xt.width,$e,s,Vr(p.resizeIndicatorColor??p.accentLight,p.bgCell)),!0):!1),_e!==null&&(_e.fillStyle=p.bgCell,_e.fillRect(0,0,i,s),_e.drawImage(tt.canvas,0,0));const Pr=PW(pt,s,$e,a,u,l,O,ht,M,me);R==null||R.setWindow({x:o,y:l,width:pt.length,height:Pr-l},d,Array.from({length:M},(xt,dn)=>O-1-dn));const Ir=ge!==void 0&&(o!==ge.cellXOffset||a!==ge.translateX),Bt=ge!==void 0&&(l!==ge.cellYOffset||u!==ge.translateY);N.current={cellXOffset:o,cellYOffset:l,translateX:a,translateY:u,mustDrawFocusOnHeader:Rt,mustDrawHighlightRingsOnHeader:en,lastBuffer:Pe?Kt===wt?"a":"b":void 0,aBufferScroll:Kt===wt?[Ir,Bt]:ge==null?void 0:ge.aBufferScroll,bBufferScroll:Kt===rt?[Ir,Bt]:ge==null?void 0:ge.bBufferScroll},tt.restore(),Qe.restore()}const IW=80;function NW(t){const e=t-1;return e*e*e+1}class DW{constructor(e){bt(this,"callback");bt(this,"currentHoveredItem");bt(this,"leavingItems",[]);bt(this,"lastAnimationTime");bt(this,"addToLeavingItems",e=>{this.leavingItems.some(r=>nc(r.item,e.item))||this.leavingItems.push(e)});bt(this,"removeFromLeavingItems",e=>{const n=this.leavingItems.find(r=>nc(r.item,e));return this.leavingItems=this.leavingItems.filter(r=>r!==n),(n==null?void 0:n.hoverAmount)??0});bt(this,"cleanUpLeavingElements",()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)});bt(this,"shouldStep",()=>{const e=this.leavingItems.length>0,n=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||n});bt(this,"getAnimatingItems",()=>this.currentHoveredItem!==void 0?[...this.leavingItems,this.currentHoveredItem]:this.leavingItems.map(e=>({...e,hoverAmount:NW(e.hoverAmount)})));bt(this,"step",e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{const r=(e-this.lastAnimationTime)/IW;for(const s of this.leavingItems)s.hoverAmount=Oi(s.hoverAmount-r,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=Oi(this.currentHoveredItem.hoverAmount+r,0,1));const i=this.getAnimatingItems();this.callback(i),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0});bt(this,"setHovered",e=>{var n;if(!nc((n=this.currentHoveredItem)==null?void 0:n.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){const r=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:r}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}});this.callback=e}}class _W{constructor(e){bt(this,"fn");bt(this,"val");this.fn=e}get value(){return this.val??(this.val=this.fn())}}function ow(t){return new _W(t)}const LW=ow(()=>window.navigator.userAgent.includes("Firefox")),Ah=ow(()=>window.navigator.userAgent.includes("Mac OS")&&window.navigator.userAgent.includes("Safari")&&!window.navigator.userAgent.includes("Chrome")),Mh=ow(()=>window.navigator.platform.toLowerCase().startsWith("mac"));function FW(t){const e=v.useRef([]),n=v.useRef(0),r=v.useRef(t);r.current=t;const i=v.useCallback(()=>{const s=()=>window.requestAnimationFrame(o),o=()=>{const l=e.current.map(tw);e.current=[],r.current(new ic(l)),e.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?s:o)},[]);return v.useCallback(s=>{e.current.length===0&&i();const o=Pi(s[0],s[1]);e.current.includes(o)||e.current.push(o)},[i])}const no="header",Hr="group-header",Rh="out-of-bounds";var da;(function(t){t[t.Start=-2]="Start",t[t.StartPadding=-1]="StartPadding",t[t.Center=0]="Center",t[t.EndPadding=1]="EndPadding",t[t.End=2]="End"})(da||(da={}));function _E(t,e){return t===e?!0:(t==null?void 0:t.kind)==="out-of-bounds"?(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])&&(t==null?void 0:t.region[0])===(e==null?void 0:e.region[0])&&(t==null?void 0:t.region[1])===(e==null?void 0:e.region[1]):(t==null?void 0:t.kind)===(e==null?void 0:e.kind)&&(t==null?void 0:t.location[0])===(e==null?void 0:e.location[0])&&(t==null?void 0:t.location[1])===(e==null?void 0:e.location[1])}const Db=6,$W=(t,e)=>{if(t.kind===Te.Custom)return t.copyData;const n=e==null?void 0:e(t);return(n==null?void 0:n.getAccessibilityString(t))??""},zW=(t,e)=>{const{width:n,height:r,accessibilityHeight:i,columns:s,cellXOffset:o,cellYOffset:l,headerHeight:a,fillHandle:u=!1,groupHeaderHeight:c,rowHeight:f,rows:d,getCellContent:h,getRowThemeOverride:p,onHeaderMenuClick:m,enableGroups:x,isFilling:g,onCanvasFocused:y,onCanvasBlur:w,isFocused:k,selection:b,freezeColumns:S,onContextMenu:T,freezeTrailingRows:A,fixedShadowX:M=!0,fixedShadowY:O=!0,drawFocusRing:_,onMouseDown:P,onMouseUp:I,onMouseMoveRaw:D,onMouseMove:ee,onItemHovered:ie,dragAndDropState:te,firstColAccessible:W,onKeyDown:V,onKeyUp:R,highlightRegions:N,canvasRef:L,onDragStart:H,onDragEnd:G,eventTargetRef:B,isResizing:le,resizeColumn:me,isDragging:ye,isDraggable:oe=!1,allowResize:be,disabledRows:Ce,hasAppendRow:lt,getGroupDetails:Xe,theme:Ge,prelightCells:at,headerIcons:Ut,verticalBorder:Pe,drawCell:xe,drawHeader:Je,onCellFocused:nt,onDragOverCell:it,onDrop:$e,onDragLeave:At,imageWindowLoader:wt,smoothScrollX:rt=!1,smoothScrollY:ge=!1,experimental:_e,getCellRenderer:Qe}=t,tt=t.translateX??0,Kt=t.translateY??0,dt=Math.max(S,Math.min(s.length-1,o)),ht=v.useRef(null),pt=wt,Lt=v.useRef(),[Rt,en]=v.useState(!1),Hn=v.useRef([]),Pt=v.useRef(),[vn,In]=v.useState(),[Pr,Ir]=v.useState(),Bt=v.useRef(null),[ct,xt]=v.useState(),[dn,ne]=v.useState(!1),Le=v.useRef(dn);Le.current=dn;const ze=v.useMemo(()=>new h5(Ut,()=>{qn.current=void 0,zo.current()}),[Ut]),An=x?c+a:a,z=v.useRef(-1),ue=((_e==null?void 0:_e.enableFirefoxRescaling)??!1)&&LW.value,q=((_e==null?void 0:_e.enableSafariRescaling)??!1)&&Ah.value;v.useLayoutEffect(()=>{window.devicePixelRatio===1||!ue&&!q||(z.current!==-1&&en(!0),window.clearTimeout(z.current),z.current=window.setTimeout(()=>{en(!1),z.current=-1},200))},[l,dt,tt,Kt,ue,q]);const ce=u4(s,S),fe=M?La(ce,te):0,Fe=v.useCallback((j,se,ke)=>{const ve=j.getBoundingClientRect();if(se>=ce.length||ke>=d)return;const de=ve.width/n,Oe=F0(se,ke,n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f);return de!==1&&(Oe.x*=de,Oe.y*=de,Oe.width*=de,Oe.height*=de),Oe.x+=ve.x,Oe.y+=ve.y,Oe},[n,r,c,An,dt,l,tt,Kt,d,S,A,ce,f]),Re=v.useCallback((j,se,ke,ve)=>{const de=j.getBoundingClientRect(),Oe=de.width/n,st=(se-de.left)/Oe,ot=(ke-de.top)/Oe,Ae=5,Ft=L0(ce,dt,n,void 0,tt);let Be=0,zt=0;ve instanceof MouseEvent&&(Be=ve.button,zt=ve.buttons);const ft=h4(st,Ft,tt),St=p4(ot,r,x,a,c,d,f,l,Kt,A),wn=(ve==null?void 0:ve.shiftKey)===!0,gt=(ve==null?void 0:ve.ctrlKey)===!0,hn=(ve==null?void 0:ve.metaKey)===!0,Zr=ve!==void 0&&!(ve instanceof MouseEvent)||(ve==null?void 0:ve.pointerType)==="touch",ln=[st<0?-1:nn||ot>r){const It=st>n?1:st<0?-1:0,xn=ot>r?1:ot<0?-1:0;let Lr=It*2,Vi=xn*2;It===0&&(Lr=ft===-1?da.EndPadding:da.Center),xn===0&&(Vi=St===void 0?da.EndPadding:da.Center);let xi=!1;if(ft===-1&&St===-1){const jo=Fe(j,ce.length-1,-1);Wr(jo!==void 0),xi=sen&&str&&ot=0?(xn=!0,It=Fe(j,Lr,St),Wr(It!==void 0),_r={kind:x&&St===-2?Hr:no,location:[Lr,St],bounds:It,group:ce[Lr].group??"",isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:ke-It.y,button:Be,buttons:zt,scrollEdge:ln}):_r={kind:x&&St===-2?Hr:no,group:ce[ft].group??"",location:[ft,St],bounds:It,isEdge:xn,shiftKey:wn,ctrlKey:gt,metaKey:hn,isTouch:Zr,localEventX:se-It.x,localEventY:ke-It.y,button:Be,buttons:zt,scrollEdge:ln}}else{const It=Fe(j,ft,St);Wr(It!==void 0);const xn=It!==void 0&&It.x+It.width-se{}),Ot=v.useRef(vn);Ot.current=vn;const[Xt,Nn]=v.useMemo(()=>{const j=document.createElement("canvas"),se=document.createElement("canvas");return j.style.display="none",j.style.opacity="0",j.style.position="fixed",se.style.display="none",se.style.opacity="0",se.style.position="fixed",[j.getContext("2d",{alpha:!1}),se.getContext("2d",{alpha:!1})]},[]);v.useLayoutEffect(()=>{if(!(Xt===null||Nn===null))return document.documentElement.append(Xt.canvas),document.documentElement.append(Nn.canvas),()=>{Xt.canvas.remove(),Nn.canvas.remove()}},[Xt,Nn]);const wr=v.useMemo(()=>new C4,[]),Mn=ue&&Rt?1:q&&Rt?2:5,ys=(_e==null?void 0:_e.disableMinimumCellWidth)===!0?1:10,qn=v.useRef(),vs=v.useRef(null),ws=v.useRef(null),Ol=v.useCallback(()=>{var st;const j=ht.current,se=Bt.current;if(j===null||se===null||(vs.current===null&&(vs.current=j.getContext("2d",{alpha:!1}),j.width=0,j.height=0),ws.current===null&&(ws.current=se.getContext("2d",{alpha:!1}),se.width=0,se.height=0),vs.current===null||ws.current===null||Xt===null||Nn===null))return;let ke=!1;const ve=ot=>{ke=!0,xt(ot)},de=qn.current,Oe={headerCanvasCtx:ws.current,canvasCtx:vs.current,bufferACtx:Xt,bufferBCtx:Nn,width:n,height:r,cellXOffset:dt,cellYOffset:l,translateX:Math.round(tt),translateY:Math.round(Kt),mappedColumns:ce,enableGroups:x,freezeColumns:S,dragAndDropState:te,theme:Ge,headerHeight:a,groupHeaderHeight:c,disabledRows:Ce??Nt.empty(),rowHeight:f,verticalBorder:Pe,isResizing:le,resizeCol:me,isFocused:k,selection:b,fillHandle:u,drawCellCallback:xe,hasAppendRow:lt,overrideCursor:ve,maxScaleFactor:Mn,freezeTrailingRows:A,rows:d,drawFocus:_,getCellContent:h,getGroupDetails:Xe??(ot=>({name:ot})),getRowThemeOverride:p,drawHeaderCallback:Je,prelightCells:at,highlightRegions:N,imageLoader:pt,lastBlitData:Pt,damage:Lt.current,hoverValues:Hn.current,hoverInfo:Ot.current,spriteManager:ze,scrolling:Rt,hyperWrapping:(_e==null?void 0:_e.hyperWrapping)??!1,touchMode:dn,enqueue:ut.current,renderStateProvider:wr,renderStrategy:(_e==null?void 0:_e.renderStrategy)??(Ah.value?"double-buffer":"single-buffer"),getCellRenderer:Qe,minimumCellWidth:ys};Oe.damage===void 0?(qn.current=Oe,Nb(Oe,de)):Nb(Oe,void 0),!ke&&(Oe.damage===void 0||Oe.damage.has((st=Ot==null?void 0:Ot.current)==null?void 0:st[0]))&&xt(void 0)},[Xt,Nn,n,r,dt,l,tt,Kt,ce,x,S,te,Ge,a,c,Ce,f,Pe,le,lt,me,k,b,u,A,d,_,Mn,h,Xe,p,xe,Je,at,N,pt,ze,Rt,_e==null?void 0:_e.hyperWrapping,_e==null?void 0:_e.renderStrategy,dn,wr,Qe,ys]),zo=v.useRef(Ol);v.useLayoutEffect(()=>{Ol(),zo.current=Ol},[Ol]),v.useLayoutEffect(()=>{(async()=>{var se;((se=document==null?void 0:document.fonts)==null?void 0:se.ready)!==void 0&&(await document.fonts.ready,qn.current=void 0,zo.current())})()},[]);const Hs=v.useCallback(j=>{Lt.current=j,zo.current(),Lt.current=void 0},[]),af=FW(Hs);ut.current=af;const uf=v.useCallback(j=>{Hs(new ic(j.map(se=>se.cell)))},[Hs]);pt.setCallback(Hs);const[Hp,Wp]=v.useState(!1),[Pl,xs]=We??[],Vp=Pl!==void 0&&xs===-1,Up=Pl!==void 0&&xs===-2;let cf=!1,Il=!1,Rn=ct;if(Rn===void 0&&Pl!==void 0&&xs!==void 0&&xs>-1&&xs({contain:"strict",display:"block",cursor:ff}),[ff]),iu=v.useRef("default"),Ws=B==null?void 0:B.current;Ws!=null&&iu.current!==Nl.cursor&&(Ws.style.cursor=iu.current=Nl.cursor);const Nr=v.useCallback((j,se,ke,ve)=>{if(Xe===void 0)return;const de=Xe(j);if(de.actions!==void 0){const Oe=kE(se,de.actions);for(const[st,ot]of Oe.entries())if(Ap(ot,ke+se.x,ve+ot.y))return de.actions[st]}},[Xe]),yi=v.useCallback((j,se,ke,ve)=>{const de=s[se];if(!ye&&!le&&de.hasMenu===!0&&!(Pr??!1)){const Oe=Fe(j,se,-1);Wr(Oe!==void 0);const st=bE(Oe.x,Oe.y,Oe.width,Oe.height,Yv(de.title)==="rtl");if(ke>st.x&&kest.y&&ve{const se=ht.current,ke=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==ke)return;ou.current=!0;let ve,de;if(j instanceof MouseEvent?(ve=j.clientX,de=j.clientY):(ve=j.touches[0].clientX,de=j.touches[0].clientY),j.target===ke&&ke!==null){const st=ke.getBoundingClientRect();if(ve>st.right||de>st.bottom)return}const Oe=Re(se,ve,de,j);Vs.current=Oe.location,Oe.isTouch&&(su.current=Date.now()),Le.current!==Oe.isTouch&&ne(Oe.isTouch),!(Oe.kind===no&&yi(se,Oe.location[0],ve,de)!==void 0)&&(Oe.kind===Hr&&Nr(Oe.group,Oe.bounds,Oe.localEventX,Oe.localEventY)!==void 0||(P==null||P(Oe),!Oe.isTouch&&oe!==!0&&oe!==Oe.kind&&Oe.button<3&&Oe.button!==1&&j.preventDefault()))},[B,oe,Re,Nr,yi,P]);Vn("touchstart",ar,window,!1),Vn("mousedown",ar,window,!1);const Dl=v.useRef(0),lu=v.useCallback(j=>{var zt,ft;const se=Dl.current;Dl.current=Date.now();const ke=ht.current;if(ou.current=!1,I===void 0||ke===null)return;const ve=B==null?void 0:B.current,de=j.target!==ke&&j.target!==ve;let Oe,st,ot=!0;if(j instanceof MouseEvent){if(Oe=j.clientX,st=j.clientY,ot=j.button<3,j.pointerType==="touch")return}else Oe=j.changedTouches[0].clientX,st=j.changedTouches[0].clientY;let Ae=Re(ke,Oe,st,j);Ae.isTouch&&su.current!==0&&Date.now()-su.current>500&&(Ae={...Ae,isLongTouch:!0}),se!==0&&Date.now()-se<(Ae.isTouch?1e3:500)&&(Ae={...Ae,isDoubleClick:!0}),Le.current!==Ae.isTouch&&ne(Ae.isTouch),!de&&j.cancelable&&ot&&j.preventDefault();const[Ft]=Ae.location,Be=yi(ke,Ft,Oe,st);if(Ae.kind===no&&Be!==void 0){(Ae.button!==0||((zt=Vs.current)==null?void 0:zt[0])!==Ft||((ft=Vs.current)==null?void 0:ft[1])!==-1)&&I(Ae,!0);return}else if(Ae.kind===Hr){const St=Nr(Ae.group,Ae.bounds,Ae.localEventX,Ae.localEventY);if(St!==void 0){Ae.button===0&&St.onClick(Ae);return}}I(Ae,de)},[I,B,Re,yi,Nr]);Vn("mouseup",lu,window,!1),Vn("touchend",lu,window,!1);const df=v.useCallback(j=>{var Be,zt;const se=ht.current;if(se===null)return;const ke=B==null?void 0:B.current,ve=j.target!==se&&j.target!==ke;let de,Oe,st=!0;j instanceof MouseEvent?(de=j.clientX,Oe=j.clientY,st=j.button<3):(de=j.changedTouches[0].clientX,Oe=j.changedTouches[0].clientY);const ot=Re(se,de,Oe,j);Le.current!==ot.isTouch&&ne(ot.isTouch),!ve&&j.cancelable&&st&&j.preventDefault();const[Ae]=ot.location,Ft=yi(se,Ae,de,Oe);if(ot.kind===no&&Ft!==void 0)ot.button===0&&((Be=Vs.current)==null?void 0:Be[0])===Ae&&((zt=Vs.current)==null?void 0:zt[1])===-1&&(m==null||m(Ae,Ft));else if(ot.kind===Hr){const ft=Nr(ot.group,ot.bounds,ot.localEventX,ot.localEventY);ft!==void 0&&ot.button===0&&ft.onClick(ot)}},[B,Re,yi,m,Nr]);Vn("click",df,window,!1);const Kp=v.useCallback(j=>{const se=ht.current,ke=B==null?void 0:B.current;if(se===null||j.target!==se&&j.target!==ke||T===void 0)return;const ve=Re(se,j.clientX,j.clientY,j);T(ve,()=>{j.cancelable&&j.preventDefault()})},[B,Re,T]);Vn("contextmenu",Kp,(B==null?void 0:B.current)??null,!1);const hf=v.useCallback(j=>{Lt.current=new ic(j.map(se=>se.item)),Hn.current=j,zo.current(),Lt.current=void 0},[]),vi=v.useMemo(()=>new DW(hf),[hf]),bs=v.useRef(vi);bs.current=vi,v.useLayoutEffect(()=>{const j=bs.current;if(We===void 0||We[1]<0){j.setHovered(We);return}const se=h(We,!0),ke=Qe(se),ve=ke===void 0&&se.kind===Te.Custom||(ke==null?void 0:ke.needsHover)!==void 0&&(typeof ke.needsHover=="boolean"?ke.needsHover:ke.needsHover(se));j.setHovered(ve?We:void 0)},[h,Qe,We]);const Dr=v.useRef(),X=v.useCallback(j=>{var ot;const se=ht.current;if(se===null)return;const ke=B==null?void 0:B.current,ve=j.target!==se&&j.target!==ke,de=Re(se,j.clientX,j.clientY,j);if(de.kind!=="out-of-bounds"&&ve&&!ou.current&&!de.isTouch)return;const Oe=(Ae,Ft)=>{In(Be=>Be===Ae||(Be==null?void 0:Be[0][0])===(Ae==null?void 0:Ae[0][0])&&(Be==null?void 0:Be[0][1])===(Ae==null?void 0:Ae[0][1])&&((Be==null?void 0:Be[1][0])===(Ae==null?void 0:Ae[1][0])&&(Be==null?void 0:Be[1][1])===(Ae==null?void 0:Ae[1][1])||!Ft)?Be:Ae)};if(!_E(de,Dr.current))xt(void 0),ie==null||ie(de),Oe(de.kind===Rh?void 0:[de.location,[de.localEventX,de.localEventY]],!0),Dr.current=de;else if(de.kind==="cell"||de.kind===no||de.kind===Hr){let Ae=!1,Ft=!0;if(de.kind==="cell"){const zt=h(de.location);Ft=((ot=Qe(zt))==null?void 0:ot.needsHoverPosition)??zt.kind===Te.Custom,Ae=Ft}else de.kind===Hr&&(Ae=!0);const Be=[de.location,[de.localEventX,de.localEventY]];Oe(Be,Ft),Ot.current=Be,Ae&&Hs(new ic([de.location]))}const st=de.location[0]>=(W?0:1);Ir(de.kind===no&&de.isEdge&&st&&be===!0),Wp(de.kind==="cell"&&de.isFillHandle),D==null||D(j),ee(de)},[B,Re,W,be,D,ee,ie,h,Qe,Hs]);Vn("mousemove",X,window,!0);const on=v.useCallback(j=>{const se=ht.current;if(se===null)return;let ke,ve;b.current!==void 0&&(ke=Fe(se,b.current.cell[0],b.current.cell[1]),ve=b.current.cell),V==null||V({bounds:ke,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ve})},[V,b,Fe]),Bo=v.useCallback(j=>{const se=ht.current;if(se===null)return;let ke,ve;b.current!==void 0&&(ke=Fe(se,b.current.cell[0],b.current.cell[1]),ve=b.current.cell),R==null||R({bounds:ke,stopPropagation:()=>j.stopPropagation(),preventDefault:()=>j.preventDefault(),cancel:()=>{},ctrlKey:j.ctrlKey,metaKey:j.metaKey,shiftKey:j.shiftKey,altKey:j.altKey,key:j.key,keyCode:j.keyCode,rawEvent:j,location:ve})},[R,b,Fe]),Xp=v.useCallback(j=>{ht.current=j,L!==void 0&&(L.current=j)},[L]),pf=v.useCallback(j=>{const se=ht.current;if(se===null||oe===!1||le){j.preventDefault();return}let ke,ve;const de=Re(se,j.clientX,j.clientY);if(oe!==!0&&de.kind!==oe){j.preventDefault();return}const Oe=(zt,ft)=>{ke=zt,ve=ft};let st,ot,Ae;const Ft=(zt,ft,St)=>{st=zt,ot=ft,Ae=St};let Be=!1;if(H==null||H({...de,setData:Oe,setDragImage:Ft,preventDefault:()=>Be=!0,defaultPrevented:()=>Be}),!Be&&ke!==void 0&&ve!==void 0&&j.dataTransfer!==null)if(j.dataTransfer.setData(ke,ve),j.dataTransfer.effectAllowed="copyLink",st!==void 0&&ot!==void 0&&Ae!==void 0)j.dataTransfer.setDragImage(st,ot,Ae);else{const[zt,ft]=de.location;if(ft!==void 0){const St=document.createElement("canvas"),wn=Fe(se,zt,ft);Wr(wn!==void 0);const gt=Math.ceil(window.devicePixelRatio??1);St.width=wn.width*gt,St.height=wn.height*gt;const hn=St.getContext("2d");hn!==null&&(hn.scale(gt,gt),hn.textBaseline="middle",ft===-1?(hn.font=Ge.headerFontFull,hn.fillStyle=Ge.bgHeader,hn.fillRect(0,0,St.width,St.height),SE(hn,0,0,wn.width,wn.height,ce[zt],!1,Ge,!1,!1,0,ze,Je,!1)):(hn.font=Ge.baseFontFull,hn.fillStyle=Ge.bgCell,hn.fillRect(0,0,St.width,St.height),xE(hn,h([zt,ft]),0,ft,!1,!1,0,0,wn.width,wn.height,!1,Ge,Ge.bgCell,pt,ze,1,void 0,!1,0,void 0,void 0,void 0,wr,Qe,()=>{}))),St.style.left="-100%",St.style.position="absolute",St.style.width=`${wn.width}px`,St.style.height=`${wn.height}px`,document.body.append(St),j.dataTransfer.setDragImage(St,wn.width/2,wn.height/2),window.setTimeout(()=>{St.remove()},0)}}else j.preventDefault()},[oe,le,Re,H,Fe,Ge,ce,ze,Je,h,pt,wr,Qe]);Vn("dragstart",pf,(B==null?void 0:B.current)??null,!1,!1);const au=v.useRef(),Gp=v.useCallback(j=>{const se=ht.current;if($e!==void 0&&j.preventDefault(),se===null||it===void 0)return;const ke=Re(se,j.clientX,j.clientY),[ve,de]=ke.location,Oe=ve-(W?0:1),[st,ot]=au.current??[];(st!==Oe||ot!==de)&&(au.current=[Oe,de],it([Oe,de],j.dataTransfer))},[W,Re,it,$e]);Vn("dragover",Gp,(B==null?void 0:B.current)??null,!1,!1);const $w=v.useCallback(()=>{au.current=void 0,G==null||G()},[G]);Vn("dragend",$w,(B==null?void 0:B.current)??null,!1,!1);const J=v.useCallback(j=>{const se=ht.current;if(se===null||$e===void 0)return;j.preventDefault();const ke=Re(se,j.clientX,j.clientY),[ve,de]=ke.location,Oe=ve-(W?0:1);$e([Oe,de],j.dataTransfer)},[W,Re,$e]);Vn("drop",J,(B==null?void 0:B.current)??null,!1,!1);const Yn=v.useCallback(()=>{At==null||At()},[At]);Vn("dragleave",Yn,(B==null?void 0:B.current)??null,!1,!1);const On=v.useRef(b);On.current=b;const _l=v.useRef(null),uu=v.useCallback(j=>{var se;ht.current===null||!ht.current.contains(document.activeElement)||(j===null&&On.current.current!==void 0?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j!==null&&j.focus({preventScroll:!0}),_l.current=j)},[L]);v.useImperativeHandle(e,()=>({focus:()=>{var se;const j=_l.current;j===null||!document.contains(j)?(se=L==null?void 0:L.current)==null||se.focus({preventScroll:!0}):j.focus({preventScroll:!0})},getBounds:(j,se)=>{if(!(L===void 0||L.current===null))return Fe(L.current,j??0,se??-1)},damage:uf}),[L,uf,Fe]);const Us=v.useRef(),xr=M$(()=>{var ot,Ae,Ft;if(n<50||(_e==null?void 0:_e.disableAccessibilityTree)===!0)return null;let j=L0(ce,dt,n,te,tt);const se=W?0:-1;!W&&((ot=j[0])==null?void 0:ot.sourceIndex)===0&&(j=j.slice(1));const[ke,ve]=((Ae=b.current)==null?void 0:Ae.cell)??[],de=(Ft=b.current)==null?void 0:Ft.range,Oe=j.map(Be=>Be.sourceIndex),st=nl(l,Math.min(d,l+i));return ke!==void 0&&ve!==void 0&&!(Oe.includes(ke)&&st.includes(ve))&&uu(null),v.createElement("table",{key:"access-tree",role:"grid","aria-rowcount":d+1,"aria-multiselectable":"true","aria-colcount":ce.length+se},v.createElement("thead",{role:"rowgroup"},v.createElement("tr",{role:"row","aria-rowindex":1},j.map(Be=>v.createElement("th",{role:"columnheader","aria-selected":b.columns.hasIndex(Be.sourceIndex),"aria-colindex":Be.sourceIndex+1+se,tabIndex:-1,onFocus:zt=>{if(zt.target!==_l.current)return nt==null?void 0:nt([Be.sourceIndex,-1])},key:Be.sourceIndex},Be.title)))),v.createElement("tbody",{role:"rowgroup"},st.map(Be=>v.createElement("tr",{role:"row","aria-selected":b.rows.hasIndex(Be),key:Be,"aria-rowindex":Be+2},j.map(zt=>{const ft=zt.sourceIndex,St=Pi(ft,Be),wn=ke===ft&&ve===Be,gt=de!==void 0&&ft>=de.x&&ft=de.y&&Be{const _r=L==null?void 0:L.current;if(_r!=null)return V==null?void 0:V({bounds:Fe(_r,ft,Be),cancel:()=>{},preventDefault:()=>{},stopPropagation:()=>{},ctrlKey:!1,key:"Enter",keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:Zr})},onFocusCapture:_r=>{var It,xn;if(!(_r.target===_l.current||((It=Us.current)==null?void 0:It[0])===ft&&((xn=Us.current)==null?void 0:xn[1])===Be))return Us.current=Zr,nt==null?void 0:nt(Zr)},ref:wn?uu:void 0,tabIndex:-1},$W(ln,Qe))})))))},[n,ce,dt,te,tt,d,l,i,b,uu,h,L,V,Fe,nt],200),wi=S===0||!M?0:dt>S?1:Oi(-tt/100,0,1),qp=-l*32+Kt,Ll=O?Oi(-qp/100,0,1):0,Yp=v.useMemo(()=>{if(!wi&&!Ll)return null;const j={position:"absolute",top:0,left:fe,width:n-fe,height:r,opacity:wi,pointerEvents:"none",transition:rt?void 0:"opacity 0.2s",boxShadow:"inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)"},se={position:"absolute",top:An,left:0,width:n,height:r,opacity:Ll,pointerEvents:"none",transition:ge?void 0:"opacity 0.2s",boxShadow:"inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)"};return v.createElement(v.Fragment,null,wi>0&&v.createElement("div",{id:"shadow-x",style:j}),Ll>0&&v.createElement("div",{id:"shadow-y",style:se}))},[wi,Ll,fe,n,rt,An,r,ge]),Jp=v.useMemo(()=>({position:"absolute",top:0,left:0}),[]);return v.createElement(v.Fragment,null,v.createElement("canvas",{"data-testid":"data-grid-canvas",tabIndex:0,onKeyDown:on,onKeyUp:Bo,onFocus:y,onBlur:w,ref:Xp,style:Nl},xr),v.createElement("canvas",{ref:Bt,style:Jp}),Yp)},BW=v.memo(v.forwardRef(zW));function Ru(t,e,n,r){return Oi(Math.round(e-(t.growOffset??0)),Math.ceil(n),Math.floor(r))}const jW=t=>{const[e,n]=v.useState(),[r,i]=v.useState(),[s,o]=v.useState(),[l,a]=v.useState(),[u,c]=v.useState(!1),[f,d]=v.useState(),[h,p]=v.useState(),[m,x]=v.useState(),[g,y]=v.useState(!1),[w,k]=v.useState(),{onHeaderMenuClick:b,getCellContent:S,onColumnMoved:T,onColumnResize:A,onColumnResizeStart:M,onColumnResizeEnd:O,gridRef:_,maxColumnWidth:P,minColumnWidth:I,onRowMoved:D,lockColumns:ee,onColumnProposeMove:ie,onMouseDown:te,onMouseUp:W,onItemHovered:V,onDragStart:R,canvasRef:N}=t,L=(A??O??M)!==void 0,{columns:H,selection:G}=t,B=G.columns,le=v.useCallback(Pe=>{const[xe,Je]=Pe.location;s!==void 0&&l!==xe&&xe>=ee?(c(!0),a(xe)):h!==void 0&&Je!==void 0?(y(!0),x(Math.max(0,Je))):r===void 0&&!u&&!g&&(V==null||V(Pe))},[s,h,l,V,ee,r,u,g]),me=T!==void 0,ye=v.useCallback(Pe=>{var xe;if(Pe.button===0){const[Je,nt]=Pe.location;if(Pe.kind==="out-of-bounds"&&Pe.isEdge&&L){const it=(xe=_==null?void 0:_.current)==null?void 0:xe.getBounds(H.length-1,-1);it!==void 0&&(n(it.x),i(H.length-1))}else if(Pe.kind==="header"&&Je>=ee){const it=N==null?void 0:N.current;if(Pe.isEdge&&L&&it){n(Pe.bounds.x),i(Je);const At=it.getBoundingClientRect().width/it.offsetWidth,wt=Pe.bounds.width/At;M==null||M(H[Je],wt,Je,wt+(H[Je].growOffset??0))}else Pe.kind==="header"&&me&&(d(Pe.bounds.x),o(Je))}else Pe.kind==="cell"&&ee>0&&Je===0&&nt!==void 0&&D!==void 0&&(k(Pe.bounds.y),p(nt))}te==null||te(Pe)},[te,L,ee,D,_,H,me,M,N]),oe=v.useCallback((Pe,xe)=>{u||g||b==null||b(Pe,xe)},[u,g,b]),be=v.useRef(-1),Ce=v.useCallback(()=>{be.current=-1,p(void 0),x(void 0),k(void 0),y(!1),o(void 0),a(void 0),d(void 0),c(!1),i(void 0),n(void 0)},[]),lt=v.useCallback((Pe,xe)=>{if(Pe.button===0){if(r!==void 0){if((B==null?void 0:B.hasIndex(r))===!0)for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,be.current,I,P);A==null||A(it,$e,nt,$e+(it.growOffset??0))}const Je=Ru(H[r],be.current,I,P);if(O==null||O(H[r],Je,r,Je+(H[r].growOffset??0)),B.hasIndex(r))for(const nt of B){if(nt===r)continue;const it=H[nt],$e=Ru(it,be.current,I,P);O==null||O(it,$e,nt,$e+(it.growOffset??0))}}Ce(),s!==void 0&&l!==void 0&&(T==null||T(s,l)),h!==void 0&&m!==void 0&&(D==null||D(h,m))}W==null||W(Pe,xe)},[W,r,s,l,h,m,B,O,H,I,P,A,T,D,Ce]),Xe=v.useMemo(()=>{if(!(s===void 0||l===void 0)&&s!==l&&(ie==null?void 0:ie(s,l))!==!1)return{src:s,dest:l}},[s,l,ie]),Ge=v.useCallback(Pe=>{const xe=N==null?void 0:N.current;if(s!==void 0&&f!==void 0)Math.abs(Pe.clientX-f)>20&&c(!0);else if(h!==void 0&&w!==void 0)Math.abs(Pe.clientY-w)>20&&y(!0);else if(r!==void 0&&e!==void 0&&xe){const nt=xe.getBoundingClientRect().width/xe.offsetWidth,it=(Pe.clientX-e)/nt,$e=H[r],At=Ru($e,it,I,P);if(A==null||A($e,At,r,At+($e.growOffset??0)),be.current=it,(B==null?void 0:B.first())===r)for(const wt of B){if(wt===r)continue;const rt=H[wt],ge=Ru(rt,be.current,I,P);A==null||A(rt,ge,wt,ge+(rt.growOffset??0))}}},[s,f,h,w,r,e,H,I,P,A,B,N]),at=v.useCallback((Pe,xe)=>{if(h===void 0||m===void 0)return S(Pe,xe);let[Je,nt]=Pe;return nt===m?nt=h:(nt>m&&(nt-=1),nt>=h&&(nt+=1)),S([Je,nt],xe)},[h,m,S]),Ut=v.useCallback(Pe=>{R==null||R(Pe),Pe.defaultPrevented()||Ce()},[Ce,R]);return v.createElement(BW,{accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,enableGroups:t.enableGroups,eventTargetRef:t.eventTargetRef,experimental:t.experimental,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,headerIcons:t.headerIcons,height:t.height,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,resizeColumn:r,isDraggable:t.isDraggable,isFilling:t.isFilling,isFocused:t.isFocused,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDrop:t.onDrop,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,width:t.width,getCellContent:at,isResizing:r!==void 0,onHeaderMenuClick:oe,isDragging:u,onItemHovered:le,onDragStart:Ut,onMouseDown:ye,allowResize:L,onMouseUp:lt,dragAndDropState:Xe,onMouseMoveRaw:Ge,ref:_})};function HW(t){const e=v.useRef(null),[n,r]=v.useState({width:t==null?void 0:t[0],height:t==null?void 0:t[1]});return v.useLayoutEffect(()=>{const i=o=>{for(const l of o){const{width:a,height:u}=l&&l.contentRect||{};r(c=>c.width===a&&c.height===u?c:{width:a,height:u})}},s=new window.ResizeObserver(i);return e.current&&s.observe(e.current,void 0),()=>{s.disconnect()}},[e.current]),{ref:e,...n}}const WW=(t,e,n)=>{const r=v.useRef(null),i=v.useRef(null),s=v.useRef(null),o=v.useRef(0),l=v.useRef(e);l.current=e;const a=n.current;v.useEffect(()=>{const u=()=>{var d,h;if(i.current===!1&&a!==null){const p=[a.scrollLeft,a.scrollTop];if(((d=s.current)==null?void 0:d[0])===p[0]&&((h=s.current)==null?void 0:h[1])===p[1])if(o.current>10){s.current=null,i.current=null;return}else o.current++;else o.current=0,l.current(p[0],p[1]),s.current=p;r.current=window.setTimeout(u,8.333333333333334)}},c=()=>{i.current=!0,s.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},f=d=>{d.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(u,8.333333333333334))};if(t&&a!==null){const d=a;return d.addEventListener("touchstart",c),d.addEventListener("touchend",f),()=>{d.removeEventListener("touchstart",c),d.removeEventListener("touchend",f),r.current!==null&&window.clearTimeout(r.current)}}},[t,a])},VW=()=>t=>t.isSafari?"scroll":"auto",UW=Jr("div")({name:"ScrollRegionStyle",class:"gdg-s1dgczr6",propsAsIs:!1,vars:{"s1dgczr6-0":[VW()]}});function KW(t){const[e,n]=v.useState(!1),r=typeof window>"u"?null:window,i=v.useRef(0);return Vn("touchstart",v.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Vn("touchend",v.useCallback(s=>{s.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),t))},[t]),r,!0,!1),e}const XW=t=>{var H,G;const{children:e,clientHeight:n,scrollHeight:r,scrollWidth:i,update:s,draggable:o,className:l,preventDiagonalScrolling:a=!1,paddingBottom:u=0,paddingRight:c=0,rightElement:f,rightElementProps:d,kineticScrollPerfHack:h=!1,scrollRef:p,initialSize:m}=t,x=[],g=(d==null?void 0:d.sticky)??!1,y=(d==null?void 0:d.fill)??!1,w=v.useRef(0),k=v.useRef(0),b=v.useRef(null),S=typeof window>"u"?1:window.devicePixelRatio,T=v.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),A=v.useRef(null),M=KW(200),[O,_]=v.useState(!0),P=v.useRef(0);v.useLayoutEffect(()=>{if(!O||M||T.current.lockDirection===void 0)return;const B=b.current;if(B===null)return;const[le,me]=T.current.lockDirection;le!==void 0?B.scrollLeft=le:me!==void 0&&(B.scrollTop=me),T.current.lockDirection=void 0},[M,O]);const I=v.useCallback((B,le)=>{var xe;const me=b.current;if(me===null)return;le=le??me.scrollTop,B=B??me.scrollLeft;const ye=T.current.scrollTop,oe=T.current.scrollLeft,be=B-oe,Ce=le-ye;M&&be!==0&&Ce!==0&&(Math.abs(be)>3||Math.abs(Ce)>3)&&a&&T.current.lockDirection===void 0&&(T.current.lockDirection=Math.abs(be)0&&(Math.abs(Ut)>2e3||at===0||at===Pe)&&r>me.scrollHeight+5){const Je=at/Pe,nt=(r-Ge)*Je;w.current=nt-at}lt!==void 0&&(window.clearTimeout(P.current),_(!1),P.current=window.setTimeout(()=>_(!0),200)),s({x:B,y:at+w.current,width:Xe-c,height:Ge-u,paddingRight:((xe=A.current)==null?void 0:xe.clientWidth)??0})},[u,c,r,s,a,M]);WW(h&&Ah.value,I,b);const D=v.useRef(I);D.current=I;const ee=v.useRef(),ie=v.useRef(!1);v.useLayoutEffect(()=>{ie.current?I():ie.current=!0},[I,u,c]);const te=v.useCallback(B=>{b.current=B,p!==void 0&&(p.current=B)},[p]);let W=0,V=0;for(x.push(v.createElement("div",{key:W++,style:{width:i,height:0}}));VD.current(),0),ee.current={width:N,height:L}),(N??0)===0||(L??0)===0?v.createElement("div",{ref:R}):v.createElement("div",{ref:R},v.createElement(UW,{isSafari:Ah.value},v.createElement("div",{className:"dvn-underlay"},e),v.createElement("div",{ref:te,style:ee.current,draggable:o,onDragStart:B=>{o||(B.stopPropagation(),B.preventDefault())},className:"dvn-scroller "+(l??""),onScroll:()=>I()},v.createElement("div",{className:"dvn-scroll-inner"+(f===void 0?" dvn-hidden":"")},v.createElement("div",{className:"dvn-stack"},x),f!==void 0&&v.createElement(v.Fragment,null,!y&&v.createElement("div",{className:"dvn-spacer"}),v.createElement("div",{ref:A,style:{height:L,maxHeight:n-Math.ceil(S%1),position:"sticky",top:0,paddingLeft:1,marginBottom:-40,marginRight:c,flexGrow:y?1:void 0,right:g?c??0:void 0,pointerEvents:"auto"}},f))))))},GW=t=>{const{columns:e,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:s,enableGroups:o,freezeColumns:l,experimental:a,nonGrowWidth:u,clientSize:c,className:f,onVisibleRegionChanged:d,scrollRef:h,preventDiagonalScrolling:p,rightElement:m,rightElementProps:x,overscrollX:g,overscrollY:y,initialSize:w,smoothScrollX:k=!1,smoothScrollY:b=!1,isDraggable:S}=t,{paddingRight:T,paddingBottom:A}=a??{},[M,O]=c,_=v.useRef(),P=v.useRef(),I=v.useRef(),D=v.useRef(),ee=u+Math.max(0,g??0);let ie=o?i+s:i;if(typeof r=="number")ie+=n*r;else for(let R=0;R{var Ce,lt;if(te.current===void 0)return;const R={...te.current};let N=0,L=R.x<0?-R.x:0,H=0,G=0;R.x=R.x<0?0:R.x;let B=0;for(let Xe=0;Xe=Ge+Xe.width)N+=Xe.width,G++,H++;else if(R.x>Ge)N+=Xe.width,k?L+=Ge-R.x:G++,H++;else if(R.x+R.width>Ge)N+=Xe.width,H++;else break}let le=0,me=0,ye=0;if(typeof r=="number")b?(me=Math.floor(R.y/r),le=me*r-R.y):me=Math.ceil(R.y/r),ye=Math.ceil(R.height/r)+me,le<0&&ye++;else{let Xe=0;for(let Ge=0;Ge=Xe+at)Xe+=at,me++,ye++;else if(R.y>Ut)Xe+=at,b?le+=Ut-R.y:me++,ye++;else if(R.y+R.height>at/2+Xe)Xe+=at,ye++;else break}}const oe={x:G,y:me,width:H-G,height:ye-me},be=_.current;(be===void 0||be.y!==oe.y||be.x!==oe.x||be.height!==oe.height||be.width!==oe.width||P.current!==L||I.current!==le||R.width!==((Ce=D.current)==null?void 0:Ce[0])||R.height!==((lt=D.current)==null?void 0:lt[1]))&&(d==null||d({x:G,y:me,width:H-G,height:ye-me},R.width,R.height,R.paddingRight??0,L,le),_.current=oe,P.current=L,I.current=le,D.current=[R.width,R.height])},[e,r,n,d,l,k,b]),V=v.useCallback(R=>{te.current=R,W()},[W]);return v.useEffect(()=>{W()},[W]),v.createElement(XW,{scrollRef:h,className:f,kineticScrollPerfHack:a==null?void 0:a.kineticScrollPerfHack,preventDiagonalScrolling:p,draggable:S===!0||typeof S=="string",scrollWidth:ee+(T??0),scrollHeight:ie+(A??0),clientHeight:O,rightElement:m,paddingBottom:A,paddingRight:T,rightElementProps:x,update:V,initialSize:w},v.createElement(jW,{eventTargetRef:h,width:M,height:O,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,prelightCells:t.prelightCells,rowHeight:t.rowHeight,rows:t.rows,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,onColumnProposeMove:t.onColumnProposeMove,verticalBorder:t.verticalBorder,drawFocusRing:t.drawFocusRing,drawHeader:t.drawHeader,drawCell:t.drawCell,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}))},qW=Jr("div")({name:"SearchWrapper",class:"gdg-seveqep",propsAsIs:!1}),YW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 244l144-144 144 144M256 120v292"})),JW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"48",d:"M112 268l144 144 144-144M256 392V100"})),QW=v.createElement("svg",{className:"button-icon",viewBox:"0 0 512 512"},v.createElement("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32",d:"M368 368L144 144M368 144L144 368"})),ZW=10,e6=t=>{const{canvasRef:e,cellYOffset:n,rows:r,columns:i,searchInputRef:s,searchValue:o,searchResults:l,onSearchValueChange:a,getCellsForSelection:u,onSearchResultsChanged:c,showSearch:f=!1,onSearchClose:d}=t,[h]=v.useState(()=>"search-box-"+Math.round(Math.random()*1e3)),[p,m]=v.useState(""),x=o??p,g=v.useCallback(N=>{m(N),a==null||a(N)},[a]),[y,w]=v.useState(),k=v.useRef(y);k.current=y,v.useEffect(()=>{l!==void 0&&(l.length>0?w(N=>({rowsSearched:r,results:l.length,selectedIndex:(N==null?void 0:N.selectedIndex)??-1})):w(void 0))},[r,l]);const b=v.useRef();b.current===void 0&&(b.current=new AbortController);const S=v.useRef(),[T,A]=v.useState([]),M=l??T,O=v.useCallback(()=>{S.current!==void 0&&(window.cancelAnimationFrame(S.current),S.current=void 0,b.current.abort())},[]),_=v.useRef(n);_.current=n;const P=v.useCallback(N=>{const L=new RegExp(N.replace(/([$()*+.?[\\\]^{|}-])/g,"\\$1"),"i");let H=_.current,G=Math.min(10,r),B=0;w(void 0),A([]);const le=[],me=async()=>{var Pe;if(u===void 0)return;const ye=performance.now(),oe=r-B;let be=u({x:0,y:H,width:i.length,height:Math.min(G,oe,r-H)},b.current.signal);typeof be=="function"&&(be=await be());let Ce=!1;for(const[xe,Je]of be.entries())for(const[nt,it]of Je.entries()){let $e;switch(it.kind){case Te.Text:case Te.Number:$e=it.displayData;break;case Te.Uri:case Te.Markdown:$e=it.data;break;case Te.Boolean:$e=typeof it.data=="boolean"?it.data.toString():void 0;break;case Te.Image:case Te.Bubble:$e=it.data.join("🐳");break;case Te.Custom:$e=it.copyData;break}$e!==void 0&&L.test($e)&&(le.push([nt,xe+H]),Ce=!0)}const lt=performance.now();Ce&&A([...le]),B+=be.length,Wr(B<=r);const Xe=((Pe=k.current)==null?void 0:Pe.selectedIndex)??-1;w({results:le.length,rowsSearched:B,selectedIndex:Xe}),c==null||c(le,Xe),H+G>=r?H=0:H+=G;const Ge=lt-ye,at=Math.max(Ge,1),Ut=ZW/at;G=Math.ceil(G*Ut),B{var N;d==null||d(),w(void 0),A([]),c==null||c([],-1),O(),(N=e==null?void 0:e.current)==null||N.focus()},[O,e,d,c]),D=v.useCallback(N=>{g(N.target.value),l===void 0&&(N.target.value===""?(w(void 0),A([]),O()):P(N.target.value))},[P,O,g,l]);v.useEffect(()=>{f&&s.current!==null&&(g(""),s.current.focus({preventScroll:!0}))},[f,s,g]);const ee=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;const L=(y.selectedIndex+1)%y.results;w({...y,selectedIndex:L}),c==null||c(M,L)},[y,c,M]),ie=v.useCallback(N=>{var H;if((H=N==null?void 0:N.stopPropagation)==null||H.call(N),y===void 0)return;let L=(y.selectedIndex-1)%y.results;L<0&&(L+=y.results),w({...y,selectedIndex:L}),c==null||c(M,L)},[c,M,y]),te=v.useCallback(N=>{(N.ctrlKey||N.metaKey)&&N.nativeEvent.code==="KeyF"||N.key==="Escape"?(I(),N.stopPropagation(),N.preventDefault()):N.key==="Enter"&&(N.shiftKey?ie():ee())},[I,ee,ie]);v.useEffect(()=>()=>{O()},[O]);const[W,V]=v.useState(!1);v.useEffect(()=>{if(f)V(!0);else{const N=setTimeout(()=>V(!1),150);return()=>clearTimeout(N)}},[f]);const R=v.useMemo(()=>{if(!f&&!W)return null;let N;y!==void 0&&(N=y.results>=1e3?"over 1000":`${y.results} result${y.results!==1?"s":""}`,y.selectedIndex>=0&&(N=`${y.selectedIndex+1} of ${N}`));const L=B=>{B.stopPropagation()},G={width:`${Math.floor(((y==null?void 0:y.rowsSearched)??0)/r*100)}%`};return v.createElement(qW,{className:f?"":"out",onMouseDown:L,onMouseMove:L,onMouseUp:L,onClick:L},v.createElement("div",{className:"gdg-search-bar-inner"},v.createElement("input",{id:h,"aria-hidden":!f,"data-testid":"search-input",ref:s,onChange:D,value:x,tabIndex:f?void 0:-1,onKeyDownCapture:te}),v.createElement("button",{"aria-label":"Previous Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ie,disabled:((y==null?void 0:y.results)??0)===0},YW),v.createElement("button",{"aria-label":"Next Result","aria-hidden":!f,tabIndex:f?void 0:-1,onClick:ee,disabled:((y==null?void 0:y.results)??0)===0},JW),d!==void 0&&v.createElement("button",{"aria-label":"Close Search","aria-hidden":!f,"data-testid":"search-close-button",tabIndex:f?void 0:-1,onClick:I},QW)),y!==void 0?v.createElement(v.Fragment,null,v.createElement("div",{className:"gdg-search-status"},v.createElement("div",{"data-testid":"search-result-area"},N)),v.createElement("div",{className:"gdg-search-progress",style:G})):v.createElement("div",{className:"gdg-search-status"},v.createElement("label",{htmlFor:h},"Type to search")))},[f,W,y,r,h,s,D,x,te,ie,ee,d,I]);return v.createElement(v.Fragment,null,v.createElement(GW,{prelightCells:M,accessibilityHeight:t.accessibilityHeight,canvasRef:t.canvasRef,cellXOffset:t.cellXOffset,cellYOffset:t.cellYOffset,className:t.className,clientSize:t.clientSize,columns:t.columns,disabledRows:t.disabledRows,enableGroups:t.enableGroups,fillHandle:t.fillHandle,firstColAccessible:t.firstColAccessible,nonGrowWidth:t.nonGrowWidth,fixedShadowX:t.fixedShadowX,fixedShadowY:t.fixedShadowY,freezeColumns:t.freezeColumns,getCellContent:t.getCellContent,getCellRenderer:t.getCellRenderer,getGroupDetails:t.getGroupDetails,getRowThemeOverride:t.getRowThemeOverride,groupHeaderHeight:t.groupHeaderHeight,headerHeight:t.headerHeight,highlightRegions:t.highlightRegions,imageWindowLoader:t.imageWindowLoader,initialSize:t.initialSize,isFilling:t.isFilling,isFocused:t.isFocused,lockColumns:t.lockColumns,maxColumnWidth:t.maxColumnWidth,minColumnWidth:t.minColumnWidth,onHeaderMenuClick:t.onHeaderMenuClick,onMouseMove:t.onMouseMove,onVisibleRegionChanged:t.onVisibleRegionChanged,overscrollX:t.overscrollX,overscrollY:t.overscrollY,preventDiagonalScrolling:t.preventDiagonalScrolling,rightElement:t.rightElement,rightElementProps:t.rightElementProps,rowHeight:t.rowHeight,rows:t.rows,scrollRef:t.scrollRef,selection:t.selection,theme:t.theme,freezeTrailingRows:t.freezeTrailingRows,hasAppendRow:t.hasAppendRow,translateX:t.translateX,translateY:t.translateY,verticalBorder:t.verticalBorder,onColumnProposeMove:t.onColumnProposeMove,drawFocusRing:t.drawFocusRing,drawCell:t.drawCell,drawHeader:t.drawHeader,experimental:t.experimental,gridRef:t.gridRef,headerIcons:t.headerIcons,isDraggable:t.isDraggable,onCanvasBlur:t.onCanvasBlur,onCanvasFocused:t.onCanvasFocused,onCellFocused:t.onCellFocused,onColumnMoved:t.onColumnMoved,onColumnResize:t.onColumnResize,onColumnResizeEnd:t.onColumnResizeEnd,onColumnResizeStart:t.onColumnResizeStart,onContextMenu:t.onContextMenu,onDragEnd:t.onDragEnd,onDragLeave:t.onDragLeave,onDragOverCell:t.onDragOverCell,onDragStart:t.onDragStart,onDrop:t.onDrop,onItemHovered:t.onItemHovered,onKeyDown:t.onKeyDown,onKeyUp:t.onKeyUp,onMouseDown:t.onMouseDown,onMouseUp:t.onMouseUp,onRowMoved:t.onRowMoved,smoothScrollX:t.smoothScrollX,smoothScrollY:t.smoothScrollY}),R)};class t6 extends v.PureComponent{constructor(){super(...arguments);bt(this,"wrapperRef",v.createRef());bt(this,"clickOutside",n=>{if(!(this.props.isOutsideClick&&!this.props.isOutsideClick(n))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(n.target)){let r=n.target;for(;r!==null;){if(r.classList.contains("click-outside-ignore"))return;r=r.parentElement}this.props.onClickOutside()}})}componentDidMount(){document.addEventListener("touchend",this.clickOutside,!0),document.addEventListener("mousedown",this.clickOutside,!0),document.addEventListener("contextmenu",this.clickOutside,!0)}componentWillUnmount(){document.removeEventListener("touchend",this.clickOutside,!0),document.removeEventListener("mousedown",this.clickOutside,!0),document.removeEventListener("contextmenu",this.clickOutside,!0)}render(){const{onClickOutside:n,isOutsideClick:r,...i}=this.props;return v.createElement("div",{...i,ref:this.wrapperRef},this.props.children)}}const n6=()=>t=>Math.max(16,t.targetHeight-10),r6=Jr("input")({name:"RenameInput",class:"gdg-r17m35ur",propsAsIs:!1,vars:{"r17m35ur-0":[n6(),"px"]}}),i6=t=>{const{bounds:e,group:n,onClose:r,canvasBounds:i,onFinish:s}=t,[o,l]=Ln.useState(n);return Ln.createElement(t6,{style:{position:"absolute",left:e.x-i.left+1,top:e.y-i.top,width:e.width-2,height:e.height},className:"gdg-c1tqibwd",onClickOutside:r},Ln.createElement(r6,{targetHeight:e.height,"data-testid":"group-rename-input",value:o,onBlur:r,onFocus:a=>a.target.setSelectionRange(0,o.length),onChange:a=>l(a.target.value),onKeyDown:a=>{a.key==="Enter"?s(o):a.key==="Escape"&&r()},autoFocus:!0}))};function s6(t,e){return t===void 0?!1:t.length>1&&t.startsWith("_")?Number.parseInt(t.slice(1))===e.keyCode:t.length===1&&t>="a"&&t<="z"?t.toUpperCase().codePointAt(0)===e.keyCode:t===e.key}function yt(t,e,n){const r=LE(t,e);return r&&(n.didMatch=!0),r}function LE(t,e){if(t.length===0)return!1;if(t.includes("|")){const a=t.split("|");for(const u of a)if(LE(u,e))return!0;return!1}let n=!1,r=!1,i=!1,s=!1;const o=t.split("+"),l=o.pop();if(!s6(l,e))return!1;if(o[0]==="any")return!0;for(const a of o)switch(a){case"ctrl":n=!0;break;case"shift":r=!0;break;case"alt":i=!0;break;case"meta":s=!0;break;case"primary":Mh.value?s=!0:n=!0;break}return e.altKey===i&&e.ctrlKey===n&&e.shiftKey===r&&e.metaKey===s}function o6(t,e,n,r,i,s){const o=Ln.useCallback((u,c,f,d)=>{var y;(s==="cell"||s==="multi-cell")&&u!==void 0&&(u={...u,range:{x:u.cell[0],y:u.cell[1],width:1,height:1}});const h=n==="mixed"&&(f||d==="drag"),p=r==="mixed"&&h,m=i==="mixed"&&h;let x={current:u===void 0?void 0:{...u,rangeStack:d==="drag"?((y=t.current)==null?void 0:y.rangeStack)??[]:[]},columns:p?t.columns:Nt.empty(),rows:m?t.rows:Nt.empty()};f&&(s==="multi-rect"||s==="multi-cell")&&x.current!==void 0&&t.current!==void 0&&(x={...x,current:{...x.current,rangeStack:[...t.current.rangeStack,t.current.range]}}),e(x,c)},[r,t,n,s,i,e]),l=Ln.useCallback((u,c,f)=>{u=u??t.rows,c!==void 0&&(u=u.add(c));let d;if(i==="exclusive"&&u.length>0)d={current:void 0,columns:Nt.empty(),rows:u};else{const h=f&&n==="mixed",p=f&&r==="mixed";d={current:h?t.current:void 0,columns:p?t.columns:Nt.empty(),rows:u}}e(d,!1)},[r,t,n,i,e]),a=Ln.useCallback((u,c,f)=>{u=u??t.columns,c!==void 0&&(u=u.add(c));let d;if(r==="exclusive"&&u.length>0)d={current:void 0,rows:Nt.empty(),columns:u};else{const h=f&&n==="mixed",p=f&&i==="mixed";d={current:h?t.current:void 0,rows:p?t.rows:Nt.empty(),columns:u}}e(d,!1)},[r,t,n,i,e]);return[o,l,a]}function l6(t,e,n,r,i){const s=v.useCallback(u=>{if(t===!0){const c=[];for(let f=u.y;f=i?d.push({kind:Te.Loading,allowOverlay:!1}):d.push(e([h,f]));c.push(d)}return c}return(t==null?void 0:t(u,r.signal))??[]},[r.signal,e,t,i]),o=t!==void 0?s:void 0,l=v.useCallback(u=>{if(o===void 0)return[];const c={...u,x:u.x-n};if(c.x<0){c.x=0,c.width--;const f=o(c,r.signal);return typeof f=="function"?async()=>(await f()).map(d=>[{kind:Te.Loading,allowOverlay:!1},...d]):f.map(d=>[{kind:Te.Loading,allowOverlay:!1},...d])}return o(c,r.signal)},[r.signal,o,n]);return[t!==void 0?l:void 0,o]}function a6(t){if(t.copyData!==void 0)return{formatted:t.copyData,rawValue:t.copyData,format:"string"};switch(t.kind){case Te.Boolean:return{formatted:t.data===!0?"TRUE":t.data===!1?"FALSE":t.data===Vv?"INDETERMINATE":"",rawValue:t.data,format:"boolean"};case Te.Custom:return{formatted:t.copyData,rawValue:t.copyData,format:"string"};case Te.Image:case Te.Bubble:return{formatted:t.data,rawValue:t.data,format:"string-array"};case Te.Drilldown:return{formatted:t.data.map(e=>e.text),rawValue:t.data.map(e=>e.text),format:"string-array"};case Te.Text:return{formatted:t.displayData??t.data,rawValue:t.data,format:"string"};case Te.Uri:return{formatted:t.displayData??t.data,rawValue:t.data,format:"url"};case Te.Markdown:case Te.RowID:return{formatted:t.data,rawValue:t.data,format:"string"};case Te.Number:return{formatted:t.displayData,rawValue:t.data,format:"number"};case Te.Loading:return{formatted:"#LOADING",rawValue:"",format:"string"};case Te.Protected:return{formatted:"************",rawValue:"",format:"string"};default:Oc()}}function u6(t,e){return t.map((r,i)=>{const s=e[i];return r.map(o=>o.span!==void 0&&o.span[0]!==s?{formatted:"",rawValue:"",format:"string"}:a6(o))})}function _b(t,e){return(e?/[\t\n",]/:/[\t\n"]/).test(t)&&(t=`"${t.replace(/"/g,'""')}"`),t}function c6(t){var n;const e=[];for(const r of t){const i=[];for(const s of r)s.format==="url"?i.push(((n=s.rawValue)==null?void 0:n.toString())??""):s.format==="string-array"?i.push(s.formatted.map(o=>_b(o,!0)).join(",")):i.push(_b(s.formatted,!1));e.push(i.join(" "))}return e.join(` -`)}function Zg(t){return t.replace(/\t/g," ").replace(/ {2,}/g,e=>" ".repeat(e.length))}function Lb(t){return'"'+t.replace(/&/g,"&").replace(/"/g,""").replace(//g,">")+'"'}function f6(t){return t.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function d6(t){var n;const e=[];e.push('',"");for(const r of t){e.push("");for(const i of r){const s=`gdg-format="${i.format}"`;i.format==="url"?e.push(``):i.format==="string-array"?e.push(``):e.push(``)}e.push("")}return e.push("
    ${Zg(i.formatted)}
      ${i.formatted.map((o,l)=>`
    1. `+Zg(o)+"
    2. ").join("")}
    ${Zg(i.formatted)}
    "),e.join("")}function h6(t,e){const n=u6(t,e),r=c6(n),i=d6(n);return{textPlain:r,textHtml:i}}function Fb(t){var o;const e=document.createElement("html");e.innerHTML=t.replace(/ /g," ");const n=e.querySelector("table");if(n===null)return;const r=[n],i=[];let s;for(;r.length>0;){const l=r.pop();if(l===void 0)break;if(l instanceof HTMLTableElement||l.nodeName==="TBODY")r.push(...[...l.children].reverse());else if(l instanceof HTMLTableRowElement)s!==void 0&&i.push(s),s=[],r.push(...[...l.children].reverse());else if(l instanceof HTMLTableCellElement){const a=l.cloneNode(!0),c=a.children.length===1&&a.children[0].nodeName==="P"?a.children[0]:null,f=(c==null?void 0:c.children.length)===1&&c.children[0].nodeName==="FONT",d=a.querySelectorAll("br");for(const m of d)m.replaceWith(` -`);const h=a.getAttribute("gdg-raw-value"),p=a.getAttribute("gdg-format")??"string";if(a.querySelector("a")!==null)s==null||s.push({rawValue:((o=a.querySelector("a"))==null?void 0:o.getAttribute("href"))??"",formatted:a.textContent??"",format:p});else if(a.querySelector("ol")!==null){const m=a.querySelectorAll("li");s==null||s.push({rawValue:[...m].map(x=>x.getAttribute("gdg-raw-value")??""),formatted:[...m].map(x=>x.textContent??""),format:"string-array"})}else if(h!==null)s==null||s.push({rawValue:f6(h),formatted:a.textContent??"",format:p});else{let m=a.textContent??"";f&&(m=m.replace(/\n(?!\n)/g,"")),s==null||s.push({rawValue:m??"",formatted:m??"",format:p})}}}return s!==void 0&&i.push(s),i}function p6(t,e,n,r,i){var l;const s=t;if(r==="allowPartial"||t.current===void 0||e===void 0)return t;let o=!1;do{if((t==null?void 0:t.current)===void 0)break;const a=(l=t.current)==null?void 0:l.range,u=[];if(a.width>2){const d=e({x:a.x,y:a.y,width:1,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d);const h=e({x:a.x+a.width-1,y:a.y,width:1,height:a.height},i.signal);if(typeof h=="function")return s;u.push(...h)}else{const d=e({x:a.x,y:a.y,width:a.width,height:a.height},i.signal);if(typeof d=="function")return s;u.push(...d)}let c=a.x-n,f=a.x+a.width-1-n;for(const d of u)for(const h of d)h.span!==void 0&&(c=Math.min(h.span[0],c),f=Math.max(h.span[1],f));c===a.x-n&&f===a.x+a.width-1-n?o=!0:t={current:{cell:t.current.cell??[0,0],range:{x:c+n,y:a.y,width:f-c+1,height:a.height},rangeStack:t.current.rangeStack},columns:t.columns,rows:t.rows}}while(!o);return t}function $b(t){return t.startsWith('"')&&t.endsWith('"')&&(t=t.slice(1,-1).replace(/""/g,'"')),t}function g6(t){let e;(function(l){l[l.None=0]="None",l[l.inString=1]="inString",l[l.inStringPostQuote=2]="inStringPostQuote"})(e||(e={}));const n=[];let r=[],i=0,s=e.None;t=t.replace(/\r\n/g,` -`);let o=0;for(const l of t){switch(s){case e.None:l===" "||l===` -`?(r.push(t.slice(i,o)),i=o+1,l===` -`&&(n.push(r),r=[])):l==='"'&&(s=e.inString);break;case e.inString:l==='"'&&(s=e.inStringPostQuote);break;case e.inStringPostQuote:l==='"'?s=e.inString:((l===" "||l===` -`)&&(r.push($b(t.slice(i,o))),i=o+1,l===` -`&&(n.push(r),r=[])),s=e.None);break}o++}return il.map(a=>({rawValue:a,formatted:a,format:"string"})))}function zb(t,e,n){var l;const r=h6(t,e),i=a=>{var u;(u=window.navigator.clipboard)==null||u.writeText(a)},s=(a,u)=>{var c;return((c=window.navigator.clipboard)==null?void 0:c.write)===void 0?!1:(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([a],{type:"text/plain"}),"text/html":new Blob([u],{type:"text/html"})})]),!0)},o=(a,u)=>{var c,f;try{if(n===void 0||n.clipboardData===null)throw new Error("No clipboard data");(c=n==null?void 0:n.clipboardData)==null||c.setData("text/plain",a),(f=n==null?void 0:n.clipboardData)==null||f.setData("text/html",u)}catch{s(a,u)||i(a)}};((l=window.navigator.clipboard)==null?void 0:l.write)!==void 0||(n==null?void 0:n.clipboardData)!==void 0?o(r.textPlain,r.textHtml):i(r.textPlain),n==null||n.preventDefault()}function FE(t){return t!==!0}function Bb(t){return typeof t=="string"?t:`${t}px`}const m6=()=>t=>t.innerWidth,y6=()=>t=>t.innerHeight,v6=Jr("div")({name:"Wrapper",class:"gdg-wmyidgi",propsAsIs:!1,vars:{"wmyidgi-0":[m6()],"wmyidgi-1":[y6()]}}),w6=t=>{const{inWidth:e,inHeight:n,children:r,...i}=t;return v.createElement(v6,{innerHeight:Bb(n),innerWidth:Bb(e),...i},r)},x6=2,b6=1300;function k6(t,e,n){const r=Ln.useRef(0),[i,s]=t??[0,0];Ln.useEffect(()=>{if(i===0&&s===0){r.current=0;return}let o=!1,l=0;const a=u=>{var c;if(!o){if(l===0)l=u;else{const f=u-l;r.current=Math.min(1,r.current+f/b6);const d=r.current**1.618*f*x6;(c=e.current)==null||c.scrollBy(i*d,s*d),l=u,n==null||n()}window.requestAnimationFrame(a)}};return window.requestAnimationFrame(a),()=>{o=!0}},[e,i,s,n])}function S6({rowHeight:t,headerHeight:e,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:s,scaleToRem:o,remSize:l}){const[a,u,c,f,d,h]=Ln.useMemo(()=>{if(!o||l===16)return[t,e,n,r,i,s];const p=l/16,m=t,x=aE();return[typeof m=="number"?m*p:g=>Math.ceil(m(g)*p),Math.ceil(e*p),Math.ceil(n*p),{...r,headerIconSize:((r==null?void 0:r.headerIconSize)??x.headerIconSize)*p,cellHorizontalPadding:((r==null?void 0:r.cellHorizontalPadding)??x.cellHorizontalPadding)*p,cellVerticalPadding:((r==null?void 0:r.cellVerticalPadding)??x.cellVerticalPadding)*p},Math.ceil((i??0)*p),Math.ceil((s??0)*p)]},[n,e,i,s,l,t,o,r]);return{rowHeight:a,headerHeight:u,groupHeaderHeight:c,theme:f,overscrollX:d,overscrollY:h}}const Zs={downFill:!1,rightFill:!1,clear:!0,closeOverlay:!0,acceptOverlayDown:!0,acceptOverlayUp:!0,acceptOverlayLeft:!0,acceptOverlayRight:!0,copy:!0,paste:!0,cut:!0,search:!1,delete:!0,activateCell:!0,scrollToSelectedCell:!0,goToFirstCell:!0,goToFirstColumn:!0,goToFirstRow:!0,goToLastCell:!0,goToLastColumn:!0,goToLastRow:!0,goToNextPage:!0,goToPreviousPage:!0,selectToFirstCell:!0,selectToFirstColumn:!0,selectToFirstRow:!0,selectToLastCell:!0,selectToLastColumn:!0,selectToLastRow:!0,selectAll:!0,selectRow:!0,selectColumn:!0,goUpCell:!0,goRightCell:!0,goDownCell:!0,goLeftCell:!0,goUpCellRetainSelection:!0,goRightCellRetainSelection:!0,goDownCellRetainSelection:!0,goLeftCellRetainSelection:!0,selectGrowUp:!0,selectGrowRight:!0,selectGrowDown:!0,selectGrowLeft:!0};function vt(t,e){return t===!0?e:t===!1?"":t}function jb(t){const e=Mh.value;return{activateCell:vt(t.activateCell," |Enter|shift+Enter"),clear:vt(t.clear,"any+Escape"),closeOverlay:vt(t.closeOverlay,"any+Escape"),acceptOverlayDown:vt(t.acceptOverlayDown,"Enter"),acceptOverlayUp:vt(t.acceptOverlayUp,"shift+Enter"),acceptOverlayLeft:vt(t.acceptOverlayLeft,"shift+Tab"),acceptOverlayRight:vt(t.acceptOverlayRight,"Tab"),copy:t.copy,cut:t.cut,delete:vt(t.delete,e?"Backspace|Delete":"Delete"),downFill:vt(t.downFill,"primary+_68"),scrollToSelectedCell:vt(t.scrollToSelectedCell,"primary+Enter"),goDownCell:vt(t.goDownCell,"ArrowDown"),goDownCellRetainSelection:vt(t.goDownCellRetainSelection,"alt+ArrowDown"),goLeftCell:vt(t.goLeftCell,"ArrowLeft|shift+Tab"),goLeftCellRetainSelection:vt(t.goLeftCellRetainSelection,"alt+ArrowLeft"),goRightCell:vt(t.goRightCell,"ArrowRight|Tab"),goRightCellRetainSelection:vt(t.goRightCellRetainSelection,"alt+ArrowRight"),goUpCell:vt(t.goUpCell,"ArrowUp"),goUpCellRetainSelection:vt(t.goUpCellRetainSelection,"alt+ArrowUp"),goToFirstCell:vt(t.goToFirstCell,"primary+Home"),goToFirstColumn:vt(t.goToFirstColumn,"Home|primary+ArrowLeft"),goToFirstRow:vt(t.goToFirstRow,"primary+ArrowUp"),goToLastCell:vt(t.goToLastCell,"primary+End"),goToLastColumn:vt(t.goToLastColumn,"End|primary+ArrowRight"),goToLastRow:vt(t.goToLastRow,"primary+ArrowDown"),goToNextPage:vt(t.goToNextPage,"PageDown"),goToPreviousPage:vt(t.goToPreviousPage,"PageUp"),paste:t.paste,rightFill:vt(t.rightFill,"primary+_82"),search:vt(t.search,"primary+f"),selectAll:vt(t.selectAll,"primary+a"),selectColumn:vt(t.selectColumn,"ctrl+ "),selectGrowDown:vt(t.selectGrowDown,"shift+ArrowDown"),selectGrowLeft:vt(t.selectGrowLeft,"shift+ArrowLeft"),selectGrowRight:vt(t.selectGrowRight,"shift+ArrowRight"),selectGrowUp:vt(t.selectGrowUp,"shift+ArrowUp"),selectRow:vt(t.selectRow,"shift+ "),selectToFirstCell:vt(t.selectToFirstCell,"primary+shift+Home"),selectToFirstColumn:vt(t.selectToFirstColumn,"primary+shift+ArrowLeft"),selectToFirstRow:vt(t.selectToFirstRow,"primary+shift+ArrowUp"),selectToLastCell:vt(t.selectToLastCell,"primary+shift+End"),selectToLastColumn:vt(t.selectToLastColumn,"primary+shift+ArrowRight"),selectToLastRow:vt(t.selectToLastRow,"primary+shift+ArrowDown")}}function C6(t){const e=N$(t);return Ln.useMemo(()=>{if(e===void 0)return jb(Zs);const n={...e,goToNextPage:(e==null?void 0:e.goToNextPage)??(e==null?void 0:e.pageDown)??Zs.goToNextPage,goToPreviousPage:(e==null?void 0:e.goToPreviousPage)??(e==null?void 0:e.pageUp)??Zs.goToPreviousPage,goToFirstCell:(e==null?void 0:e.goToFirstCell)??(e==null?void 0:e.first)??Zs.goToFirstCell,goToLastCell:(e==null?void 0:e.goToLastCell)??(e==null?void 0:e.last)??Zs.goToLastCell,selectToFirstCell:(e==null?void 0:e.selectToFirstCell)??(e==null?void 0:e.first)??Zs.selectToFirstCell,selectToLastCell:(e==null?void 0:e.selectToLastCell)??(e==null?void 0:e.last)??Zs.selectToLastCell};return jb({...Zs,...n})},[e])}const T6=v.lazy(async()=>await cE(()=>import("./data-grid-overlay-editor-D184XVUK.js"),[]));let E6=0;function A6(t){return Oz(ob(ob(t).filter(e=>e.span!==void 0).map(e=>{var n,r;return nl((((n=e.span)==null?void 0:n[0])??0)+1,(((r=e.span)==null?void 0:r[1])??0)+1)})))}function Jf(t,e){return t===void 0||e===0||t.columns.length===0&&t.current===void 0?t:{current:t.current===void 0?void 0:{cell:[t.current.cell[0]+e,t.current.cell[1]],range:{...t.current.range,x:t.current.range.x+e},rangeStack:t.current.rangeStack.map(n=>({...n,x:n.x+e}))},rows:t.rows,columns:t.columns.offset(e)}}const em={kind:Te.Loading,allowOverlay:!1},Qf={columns:Nt.empty(),rows:Nt.empty(),current:void 0},M6=(t,e)=>{var Qw,Zw,e1;const[n,r]=v.useState(Qf),[i,s]=v.useState(),o=v.useRef(null),l=v.useRef(null),[a,u]=v.useState(),c=v.useRef(null),f=v.useRef(),d=typeof window>"u"?null:window,{imageEditorOverride:h,getRowThemeOverride:p,markdownDivCreateNode:m,width:x,height:g,columns:y,rows:w,getCellContent:k,onCellClicked:b,onCellActivated:S,onFillPattern:T,onFinishedEditing:A,coercePasteValue:M,drawHeader:O,drawCell:_,editorBloom:P,onHeaderClicked:I,onColumnProposeMove:D,spanRangeBehavior:ee="default",onGroupHeaderClicked:ie,onCellContextMenu:te,className:W,onHeaderContextMenu:V,getCellsForSelection:R,onGroupHeaderContextMenu:N,onGroupHeaderRenamed:L,onCellEdited:H,onCellsEdited:G,onSearchResultsChanged:B,searchResults:le,onSearchValueChange:me,searchValue:ye,onKeyDown:oe,onKeyUp:be,keybindings:Ce,editOnType:lt=!0,onRowAppended:Xe,onColumnMoved:Ge,validateCell:at,highlightRegions:Ut,rangeSelect:Pe="rect",columnSelect:xe="multi",rowSelect:Je="multi",rangeSelectionBlending:nt="exclusive",columnSelectionBlending:it="exclusive",rowSelectionBlending:$e="exclusive",onDelete:At,onDragStart:wt,onMouseMove:rt,onPaste:ge,copyHeaders:_e=!1,freezeColumns:Qe=0,cellActivationBehavior:tt="second-click",rowSelectionMode:Kt="auto",onHeaderMenuClick:dt,getGroupDetails:ht,onSearchClose:pt,onItemHovered:Lt,onSelectionCleared:Rt,showSearch:en,onVisibleRegionChanged:Hn,gridSelection:Pt,onGridSelectionChange:vn,minColumnWidth:In=50,maxColumnWidth:Pr=500,maxColumnAutoWidth:Ir,provideEditor:Bt,trailingRowOptions:ct,freezeTrailingRows:xt=0,allowedFillDirections:dn="orthogonal",scrollOffsetX:ne,scrollOffsetY:Le,verticalBorder:ze,onDragOverCell:An,onDrop:z,onColumnResize:ue,onColumnResizeEnd:q,onColumnResizeStart:ce,customRenderers:fe,fillHandle:Fe,drawFocusRing:Re=!0,experimental:We,fixedShadowX:ut,fixedShadowY:Ot,headerIcons:Xt,imageWindowLoader:Nn,initialSize:wr,isDraggable:Mn,onDragLeave:ys,onRowMoved:qn,overscrollX:vs,overscrollY:ws,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:Hs,trapFocus:af=!1,smoothScrollX:uf,smoothScrollY:Hp,scaleToRem:Wp=!1,rowHeight:Pl=34,headerHeight:xs=36,groupHeaderHeight:Vp=xs,theme:Up,isOutsideClick:cf,renderers:Il}=t,Rn=typeof t.rowMarkers=="string"?void 0:t.rowMarkers,Qr=(Rn==null?void 0:Rn.kind)??t.rowMarkers??"none",ff=(Rn==null?void 0:Rn.width)??t.rowMarkerWidth,Nl=(Rn==null?void 0:Rn.startIndex)??t.rowMarkerStartIndex??1,iu=(Rn==null?void 0:Rn.theme)??t.rowMarkerTheme,Ws=(Rn==null?void 0:Rn.checkboxStyle)??"square",Nr=Math.max(In,20),yi=Math.max(Pr,Nr),su=Math.max(Ir??yi,Nr),Vs=v.useMemo(()=>typeof window>"u"?{fontSize:"16px"}:window.getComputedStyle(document.documentElement),[]),ou=v.useMemo(()=>Number.parseFloat(Vs.fontSize),[Vs]),{rowHeight:ar,headerHeight:Dl,groupHeaderHeight:lu,theme:df,overscrollX:Kp,overscrollY:hf}=S6({groupHeaderHeight:Vp,headerHeight:xs,overscrollX:vs,overscrollY:ws,remSize:ou,rowHeight:Pl,scaleToRem:Wp,theme:Up}),vi=C6(Ce),bs=ff??(w>1e4?48:w>1e3?44:w>100?36:32),Dr=Qr!=="none",X=Dr?1:0,on=Xe!==void 0,Bo=(ct==null?void 0:ct.sticky)===!0,[Xp,pf]=v.useState(!1),au=en??Xp,Gp=v.useCallback(()=>{pt!==void 0?pt():pf(!1)},[pt]),J=v.useMemo(()=>Pt===void 0?void 0:Jf(Pt,X),[Pt,X])??n,Yn=v.useRef();Yn.current===void 0&&(Yn.current=new AbortController),v.useEffect(()=>()=>Yn==null?void 0:Yn.current.abort(),[]);const[On,_l]=l6(R,k,X,Yn.current,w),uu=v.useCallback((C,$,F)=>{if(at===void 0)return!0;const U=[C[0]-X,C[1]];return at==null?void 0:at(U,$,F)},[X,at]),Us=v.useRef(Pt),xr=v.useCallback((C,$)=>{$&&(C=p6(C,On,X,ee,Yn.current)),vn!==void 0?(Us.current=Jf(C,-X),vn(Us.current)):r(C)},[vn,On,X,ee]),wi=Ul(ue,v.useCallback((C,$,F,U)=>{ue==null||ue(y[F-X],$,F-X,U)},[ue,X,y])),qp=Ul(q,v.useCallback((C,$,F,U)=>{q==null||q(y[F-X],$,F-X,U)},[q,X,y])),Ll=Ul(ce,v.useCallback((C,$,F,U)=>{ce==null||ce(y[F-X],$,F-X,U)},[ce,X,y])),Yp=Ul(O,v.useCallback((C,$)=>(O==null?void 0:O({...C,columnIndex:C.columnIndex-X},$))??!1,[O,X])),Jp=Ul(_,v.useCallback((C,$)=>(_==null?void 0:_({...C,col:C.col-X},$))??!1,[_,X])),j=v.useCallback(C=>{if(At!==void 0){const $=At(Jf(C,-X));return typeof $=="boolean"?$:Jf($,X)}return!0},[At,X]),[se,ke,ve]=o6(J,xr,nt,it,$e,Pe),de=v.useMemo(()=>To(aE(),df),[df]),[Oe,st]=v.useState([0,0,0]),ot=v.useMemo(()=>{if(Il===void 0)return{};const C={};for(const $ of Il)C[$.kind]=$;return C},[Il]),Ae=v.useCallback(C=>C.kind!==Te.Custom?ot[C.kind]:fe==null?void 0:fe.find($=>$.isMatch(C)),[fe,ot]);let{sizedColumns:Ft,nonGrowWidth:Be}=M4(y,w,_l,Oe[0]-(X===0?0:bs)-Oe[2],Nr,su,de,Ae,Yn.current);Qr!=="none"&&(Be+=bs);const zt=v.useMemo(()=>Ft.some(C=>C.group!==void 0),[Ft]),ft=zt?Dl+lu:Dl,St=J.rows.length,wn=Qr==="none"?void 0:St===0?!1:St===w?!0:void 0,gt=v.useMemo(()=>Qr==="none"?Ft:[{title:"",width:bs,icon:void 0,hasMenu:!1,style:"normal",themeOverride:iu,rowMarker:Ws,rowMarkerChecked:wn},...Ft],[Qr,Ft,bs,iu,Ws,wn]),[hn,Zr]=v.useMemo(()=>[Le!==void 0&&typeof ar=="number"?Math.floor(Le/ar):0,Le!==void 0&&typeof ar=="number"?-(Le%ar):0],[Le,ar]),ln=v.useRef({height:1,width:1,x:0,y:0}),_r=v.useMemo(()=>({x:ln.current.x,y:hn,width:ln.current.width??1,height:ln.current.height??1,ty:Zr}),[Zr,hn]),It=v.useRef(!1),[xn,Lr,Vi]=I$(_r);ln.current=xn;const xi=(xn.height??1)>1;v.useLayoutEffect(()=>{if(Le!==void 0&&c.current!==null&&xi){if(c.current.scrollTop===Le)return;c.current.scrollTop=Le,c.current.scrollTop!==Le&&Vi(),It.current=!0}},[Le,xi,Vi]);const Fl=(xn.width??1)>1;v.useLayoutEffect(()=>{if(ne!==void 0&&c.current!==null&&Fl){if(c.current.scrollLeft===ne)return;c.current.scrollLeft=ne,c.current.scrollLeft!==ne&&Vi(),It.current=!0}},[ne,Fl,Vi]);const jo=xn.x+X,gf=xn.y,br=v.useRef(null),ur=v.useCallback(C=>{var $;C===!0?($=br.current)==null||$.focus():window.requestAnimationFrame(()=>{var F;(F=br.current)==null||F.focus()})},[]),Jn=on?w+1:w,ei=v.useCallback(C=>{const $=X===0?C:C.map(U=>({...U,location:[U.location[0]-X,U.location[1]]})),F=G==null?void 0:G($);if(F!==!0)for(const U of $)H==null||H(U.location,U.value);return F},[H,G,X]),[Ho,Qp]=v.useState(),mf=J.current!==void 0&&J.current.range.width*J.current.range.height>1?J.current.range:void 0,$l=Re?(Qw=J.current)==null?void 0:Qw.cell:void 0,yf=$l==null?void 0:$l[0],vf=$l==null?void 0:$l[1],xR=v.useMemo(()=>{if((Ut===void 0||Ut.length===0)&&(mf??yf??vf??Ho)===void 0)return;const C=[];if(Ut!==void 0)for(const $ of Ut){const F=gt.length-$.range.x-X;F>0&&C.push({color:$.color,range:{...$.range,x:$.range.x+X,width:Math.min(F,$.range.width)},style:$.style})}return Ho!==void 0&&C.push({color:wl(de.accentColor,0),range:Ho,style:"dashed"}),mf!==void 0&&C.push({color:wl(de.accentColor,.5),range:mf,style:"solid-outline"}),yf!==void 0&&vf!==void 0&&C.push({color:de.accentColor,range:{x:yf,y:vf,width:1,height:1},style:"solid-outline"}),C.length>0?C:void 0},[Ho,mf,yf,vf,Ut,gt.length,de.accentColor,X]),zw=v.useRef(gt);zw.current=gt;const Fr=v.useCallback(([C,$],F=!1)=>{var Z,Y,Q,ae,re,Ee,Ie;const U=on&&$===Jn-1;if(C===0&&Dr)return U?em:{kind:oi.Marker,allowOverlay:!1,checkboxStyle:Ws,checked:(J==null?void 0:J.rows.hasIndex($))===!0,markerKind:Qr==="clickable-number"?"number":Qr,row:Nl+$,drawHandle:qn!==void 0,cursor:Qr==="clickable-number"?"pointer":void 0};if(U){const Ve=C===X?(ct==null?void 0:ct.hint)??"":"",qe=zw.current[C];if(((Z=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Z.disabled)===!0)return em;{const Mt=((Y=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Y.hint)??Ve,Ze=((Q=qe==null?void 0:qe.trailingRowOptions)==null?void 0:Q.addIcon)??(ct==null?void 0:ct.addIcon);return{kind:oi.NewRow,hint:Mt,allowOverlay:!1,icon:Ze}}}else{const Se=C-X;if(F||(We==null?void 0:We.strict)===!0){const qe=ln.current,Mt=qe.x>Se||Se>qe.x+qe.width||qe.y>$||$>qe.y+qe.height||$>=eg.current,Ze=Se===((re=(ae=qe.extras)==null?void 0:ae.selected)==null?void 0:re[0])&&$===((Ee=qe.extras)==null?void 0:Ee.selected[1]);let He=!1;if(((Ie=qe.extras)==null?void 0:Ie.freezeRegions)!==void 0){for(const Jt of qe.extras.freezeRegions)if(Ap(Jt,Se,$)){He=!0;break}}if(Mt&&!Ze&&!He)return em}let Ve=k([Se,$]);return X!==0&&Ve.span!==void 0&&(Ve={...Ve,span:[Ve.span[0]+X,Ve.span[1]+X]}),Ve}},[on,Jn,Dr,Ws,J==null?void 0:J.rows,Qr,Nl,qn,X,ct==null?void 0:ct.hint,ct==null?void 0:ct.addIcon,We==null?void 0:We.strict,k]),Zp=v.useCallback(C=>{let $=(ht==null?void 0:ht(C))??{name:C};return L!==void 0&&C!==""&&($={icon:$.icon,name:$.name,overrideTheme:$.overrideTheme,actions:[...$.actions??[],{title:"Rename",icon:"renameIcon",onClick:F=>ng({group:$.name,bounds:F.bounds})}]}),$},[ht,L]),wf=v.useCallback(C=>{var Q;const[$,F]=C.cell,U=gt[$],K=(U==null?void 0:U.group)!==void 0?(Q=Zp(U.group))==null?void 0:Q.overrideTheme:void 0,Z=U==null?void 0:U.themeOverride,Y=p==null?void 0:p(F);s({...C,theme:To(de,K,Z,Y,C.content.themeOverride)})},[p,gt,Zp,de]),zl=v.useCallback((C,$,F)=>{var Y;if(J.current===void 0)return;const[U,K]=J.current.cell,Z=Fr([U,K]);if(Z.kind!==Te.Boolean&&Z.allowOverlay){let Q=Z;if(F!==void 0)switch(Q.kind){case Te.Number:{const ae=hD(()=>F==="-"?-0:Number.parseFloat(F),0);Q={...Q,data:Number.isNaN(ae)?0:ae};break}case Te.Text:case Te.Markdown:case Te.Uri:Q={...Q,data:F};break}wf({target:C,content:Q,initialValue:F,cell:[U,K],highlight:F===void 0,forceEditMode:F!==void 0})}else Z.kind===Te.Boolean&&$&&Z.readonly!==!0&&(ei([{location:J.current.cell,value:{...Z,data:FE(Z.data)}}]),(Y=br.current)==null||Y.damage([{cell:J.current.cell}]))},[Fr,J,ei,wf]),Bw=v.useCallback((C,$)=>{var K;const F=(K=br.current)==null?void 0:K.getBounds(C,$);if(F===void 0||c.current===null)return;const U=Fr([C,$]);U.allowOverlay&&wf({target:F,content:U,initialValue:void 0,highlight:!0,cell:[C,$],forceEditMode:!0})},[Fr,wf]),bn=v.useCallback((C,$,F="both",U=0,K=0,Z=void 0)=>{if(c.current!==null){const Y=br.current,Q=l.current,ae=typeof C!="number"?C.unit==="cell"?C.amount:void 0:C,re=typeof $!="number"?$.unit==="cell"?$.amount:void 0:$,Ee=typeof C!="number"&&C.unit==="px"?C.amount:void 0,Ie=typeof $!="number"&&$.unit==="px"?$.amount:void 0;if(Y!==null&&Q!==null){let Se={x:0,y:0,width:0,height:0},Ve=0,qe=0;if((ae!==void 0||re!==void 0)&&(Se=Y.getBounds((ae??0)+X,re??0)??Se,Se.width===0||Se.height===0))return;const Mt=Q.getBoundingClientRect(),Ze=Mt.width/Q.offsetWidth;if(Ee!==void 0&&(Se={...Se,x:Ee-Mt.left-c.current.scrollLeft,width:1}),Ie!==void 0&&(Se={...Se,y:Ie+Mt.top-c.current.scrollTop,height:1}),Se!==void 0){const He={x:Se.x-U,y:Se.y-K,width:Se.width+2*U,height:Se.height+2*K};let Jt=0;for(let ag=0;ag0&&(Qn=Rl(Jn,kn,ar));let ki=Jt*Ze+Mt.left+X*bs*Ze,Ki=Mt.right,Si=Mt.top+ft*Ze,Xi=Mt.bottom-Qn*Ze;const Tf=Se.width+U*2;switch(Z==null?void 0:Z.hAlign){case"start":Ki=ki+Tf;break;case"end":ki=Ki-Tf;break;case"center":ki=Math.floor((ki+Ki)/2)-Tf/2,Ki=ki+Tf;break}const Ef=Se.height+K*2;switch(Z==null?void 0:Z.vAlign){case"start":Xi=Si+Ef;break;case"end":Si=Xi-Ef;break;case"center":Si=Math.floor((Si+Xi)/2)-Ef/2,Xi=Si+Ef;break}ki>He.x?Ve=He.x-ki:KiHe.y?qe=He.y-Si:Xi=Jn-kn)&&(qe=0),(Ve!==0||qe!==0)&&(Ze!==1&&(Ve/=Ze,qe/=Ze),c.current.scrollTo(Ve+c.current.scrollLeft,qe+c.current.scrollTop))}}}},[X,xt,bs,ft,Qe,Ft,Jn,Bo,ar]),jw=v.useRef(Bw),Hw=v.useRef(k),eg=v.useRef(w);jw.current=Bw,Hw.current=k,eg.current=w;const Bl=v.useCallback(async(C,$=!0)=>{var ae;const F=gt[C];if(((ae=F==null?void 0:F.trailingRowOptions)==null?void 0:ae.disabled)===!0)return;const U=Xe==null?void 0:Xe();let K,Z=!0;U!==void 0&&(K=await U,K==="top"&&(Z=!1),typeof K=="number"&&(Z=!1));let Y=0;const Q=()=>{if(eg.current<=w){Y<500&&window.setTimeout(Q,Y),Y=50+Y*2;return}const re=typeof K=="number"?K:Z?w:0;Cf.current(C-X,re),se({cell:[C,re],range:{x:C,y:re,width:1,height:1}},!1,!1,"edit");const Ee=Hw.current([C-X,re]);Ee.allowOverlay&&Bu(Ee)&&Ee.readonly!==!0&&$&&window.setTimeout(()=>{jw.current(C,re)},0)};Q()},[gt,Xe,X,w,se]),xf=v.useCallback(C=>{var F,U;const $=((U=(F=Ft[C])==null?void 0:F.trailingRowOptions)==null?void 0:U.targetColumn)??(ct==null?void 0:ct.targetColumn);if(typeof $=="number")return $+(Dr?1:0);if(typeof $=="object"){const K=y.indexOf($);if(K>=0)return K+(Dr?1:0)}},[Ft,y,Dr,ct==null?void 0:ct.targetColumn]),Ks=v.useRef(),jl=v.useRef(),cu=v.useCallback((C,$)=>{var K;const[F,U]=$;return To(de,(K=gt[F])==null?void 0:K.themeOverride,p==null?void 0:p(U),C.themeOverride)},[p,gt,de]),fu=v.useCallback(C=>{var Ee,Ie,Se;const $=Mh.value?C.metaKey:C.ctrlKey,F=$&&Je==="multi",U=$&&xe==="multi",[K,Z]=C.location,Y=J.columns,Q=J.rows,[ae,re]=((Ee=J.current)==null?void 0:Ee.cell)??[];if(C.kind==="cell"){if(jl.current=void 0,Wo.current=[K,Z],K===0&&Dr){if(on===!0&&Z===w||Qr==="number"||Je==="none")return;const Ve=Fr(C.location);if(Ve.kind!==oi.Marker)return;if(qn!==void 0){const Ze=Ae(Ve);Wr((Ze==null?void 0:Ze.kind)===oi.Marker);const He=(Ie=Ze==null?void 0:Ze.onClick)==null?void 0:Ie.call(Ze,{...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,theme:cu(Ve,C.location),preventDefault:()=>{}});if(He===void 0||He.checked===Ve.checked)return}s(void 0),ur();const qe=Q.hasIndex(Z),Mt=Ks.current;if(Je==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Mt!==void 0&&Q.hasIndex(Mt)){const Ze=[Math.min(Mt,Z),Math.max(Mt,Z)+1];F||Kt==="multi"?ke(void 0,Ze,!0):ke(Nt.fromSingleSelection(Ze),void 0,F)}else F||C.isTouch||Kt==="multi"?qe?ke(Q.remove(Z),void 0,!0):(ke(void 0,Z,!0),Ks.current=Z):qe&&Q.length===1?ke(Nt.empty(),void 0,$):(ke(Nt.fromSingleSelection(Z),void 0,$),Ks.current=Z)}else if(K>=X&&on&&Z===w){const Ve=xf(K);Bl(Ve??K)}else if(ae!==K||re!==Z){const Ve=Fr(C.location),qe=Ae(Ve);if((qe==null?void 0:qe.onSelect)!==void 0){let He=!1;if(qe.onSelect({...C,cell:Ve,posX:C.localEventX,posY:C.localEventY,bounds:C.bounds,preventDefault:()=>He=!0,theme:cu(Ve,C.location)}),He)return}const Mt=Bo&&Z===w,Ze=Bo&&J!==void 0&&((Se=J.current)==null?void 0:Se.cell[1])===w;if((C.shiftKey||C.isLongTouch===!0)&&ae!==void 0&&re!==void 0&&J.current!==void 0&&!Ze){if(Mt)return;const He=Math.min(K,ae),Jt=Math.max(K,ae),Qn=Math.min(Z,re),kn=Math.max(Z,re);se({...J.current,range:{x:He,y:Qn,width:Jt-He+1,height:kn-Qn+1}},!0,$,"click"),Ks.current=void 0,ur()}else se({cell:[K,Z],range:{x:K,y:Z,width:1,height:1}},!0,$,"click"),Ks.current=void 0,s(void 0),ur()}}else if(C.kind==="header")if(Wo.current=[K,Z],s(void 0),Dr&&K===0)Ks.current=void 0,jl.current=void 0,Je==="multi"&&(Q.length!==w?ke(Nt.fromSingleSelection([0,w]),void 0,$):ke(Nt.empty(),void 0,$),ur());else{const Ve=jl.current;if(xe==="multi"&&(C.shiftKey||C.isLongTouch===!0)&&Ve!==void 0&&Y.hasIndex(Ve)){const qe=[Math.min(Ve,K),Math.max(Ve,K)+1];U?ve(void 0,qe,$):ve(Nt.fromSingleSelection(qe),void 0,$)}else U?(Y.hasIndex(K)?ve(Y.remove(K),void 0,$):ve(void 0,K,$),jl.current=K):xe!=="none"&&(ve(Nt.fromSingleSelection(K),void 0,$),jl.current=K);Ks.current=void 0,ur()}else C.kind===Hr?Wo.current=[K,Z]:C.kind===Rh&&!C.isMaybeScrollbar&&(xr(Qf,!1),s(void 0),ur(),Rt==null||Rt(),Ks.current=void 0,jl.current=void 0)},[Bl,xe,ur,Ae,xf,Fr,J,Dr,Bo,Rt,qn,X,Qr,Je,Kt,w,se,xr,ve,ke,on,cu]),du=v.useRef(!1),Wo=v.useRef(),Ww=v.useRef(xn),ti=v.useRef(),bR=v.useCallback(C=>{if(Hl.current=!1,Ww.current=ln.current,C.button!==0&&C.button!==1){ti.current=void 0;return}const $=performance.now();ti.current={button:C.button,time:$,location:C.location},(C==null?void 0:C.kind)==="header"&&(du.current=!0);const F=C.kind==="cell"&&C.isFillHandle;!F&&C.kind!=="cell"&&C.isEdge||(u({previousSelection:J,fillHandle:F}),Wo.current=void 0,!C.isTouch&&C.button===0&&!F?fu(C):!C.isTouch&&C.button===1&&(Wo.current=C.location))},[J,fu]),[tg,ng]=v.useState(),Vw=v.useCallback(C=>{if(C.kind!==Hr||xe!=="multi")return;const $=Mh.value?C.metaKey:C.ctrlKey,[F]=C.location,U=J.columns;if(F=X&&Pc(K.group,gt[Q].group);Q--)Z--;for(let Q=F+1;Q{if(On!==void 0&&wi!==void 0){const $=ln.current.y,F=ln.current.height;let U=On({x:C,y:$,width:1,height:Math.min(F,w-$)},Yn.current.signal);typeof U!="object"&&(U=await U());const K=Ft[C-X],Y=document.createElement("canvas").getContext("2d",{alpha:!1});if(Y!==null){Y.font=de.baseFontFull;const Q=uE(Y,de,K,0,U,Nr,yi,!1,Ae);wi==null||wi(K,Q.width,C,Q.width)}}},[Ft,On,yi,de,Nr,wi,X,w,Ae]),[kR,rg]=v.useState(),Wl=v.useCallback(async(C,$)=>{var Q,ae;const F=(Q=C.current)==null?void 0:Q.range;if(F===void 0||On===void 0||$.current===void 0)return;const U=$.current.range;if(T!==void 0){let re=!1;if(T({fillDestination:{...U,x:U.x-X},patternSource:{...F,x:F.x-X},preventDefault:()=>re=!0}),re)return}let K=On(F,Yn.current.signal);typeof K!="object"&&(K=await K());const Z=K,Y=[];for(let re=0;re({cell:re.location})))},[On,ei,T,X]),Uw=v.useCallback(()=>{if(J.current===void 0||J.current.range.width<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,width:1}}};Wl(C,J)},[Wl,J]),Kw=v.useCallback(()=>{if(J.current===void 0||J.current.range.height<=1)return;const C={...J,current:{...J.current,range:{...J.current.range,height:1}}};Wl(C,J)},[Wl,J]),SR=v.useCallback((C,$)=>{var Ee,Ie;const F=a;if(u(void 0),Qp(void 0),rg(void 0),du.current=!1,$)return;if((F==null?void 0:F.fillHandle)===!0&&J.current!==void 0&&((Ee=F.previousSelection)==null?void 0:Ee.current)!==void 0){if(Ho===void 0)return;const Se={...J,current:{...J.current,range:wE(F.previousSelection.current.range,Ho)}};Wl(F.previousSelection,Se),xr(Se,!0);return}const[U,K]=C.location,[Z,Y]=Wo.current??[],Q=()=>{Hl.current=!0},ae=Se=>{var qe,Mt,Ze;const Ve=Se.isTouch||Z===U&&Y===K;if(Ve&&(b==null||b([U-X,K],{...Se,preventDefault:Q})),Se.button===1)return!Hl.current;if(!Hl.current){const He=Fr(C.location),Jt=Ae(He);if(Jt!==void 0&&Jt.onClick!==void 0&&Ve){const kn=Jt.onClick({...Se,cell:He,posX:Se.localEventX,posY:Se.localEventY,bounds:Se.bounds,theme:cu(He,C.location),preventDefault:Q});kn!==void 0&&!ca(kn)&&ql(kn)&&(ei([{location:Se.location,value:kn}]),(qe=br.current)==null||qe.damage([{cell:Se.location}]))}if(Hl.current||J.current===void 0)return!1;let Qn=!1;switch(He.activationBehaviorOverride??tt){case"double-click":case"second-click":{if(((Ze=(Mt=F==null?void 0:F.previousSelection)==null?void 0:Mt.current)==null?void 0:Ze.cell)===void 0)break;const[kn,ki]=J.current.cell,[Ki,Si]=F.previousSelection.current.cell;Qn=U===kn&&U===Ki&&K===ki&&K===Si&&(Se.isDoubleClick===!0||tt==="second-click");break}case"single-click":{Qn=!0;break}}if(Qn)return S==null||S([U-X,K]),zl(Se.bounds,!1),!0}return!1},re=C.location[0]-X;if(C.isTouch){const Se=ln.current,Ve=Ww.current;if(Se.x!==Ve.x||Se.y!==Ve.y)return;if(C.isLongTouch===!0){if(C.kind==="cell"&&nc((Ie=J.current)==null?void 0:Ie.cell,C.location)){te==null||te([re,C.location[1]],{...C,preventDefault:Q});return}else if(C.kind==="header"&&J.columns.hasIndex(U)){V==null||V(re,{...C,preventDefault:Q});return}else if(C.kind===Hr){if(re<0)return;N==null||N(re,{...C,preventDefault:Q});return}}C.kind==="cell"?ae(C)||fu(C):C.kind===Hr?ie==null||ie(re,{...C,preventDefault:Q}):(C.kind===no&&(I==null||I(re,{...C,preventDefault:Q})),fu(C));return}if(C.kind==="header"){if(re<0)return;C.isEdge?C.isDoubleClick===!0&&bf(U):C.button===0&&U===Z&&K===Y&&(I==null||I(re,{...C,preventDefault:Q}))}if(C.kind===Hr){if(re<0)return;C.button===0&&U===Z&&K===Y&&(ie==null||ie(re,{...C,preventDefault:Q}),Hl.current||Vw(C))}C.kind==="cell"&&(C.button===0||C.button===1)&&ae(C),Wo.current=void 0},[a,J,X,Ho,Wl,xr,b,Fr,Ae,tt,cu,ei,S,zl,te,V,N,fu,ie,I,bf,Vw]),CR=v.useCallback(C=>{const $={...C,location:[C.location[0]-X,C.location[1]]};rt==null||rt($),a!==void 0&&C.buttons===0&&(u(void 0),Qp(void 0),rg(void 0),du.current=!1),rg(F=>{var U;return du.current?[C.scrollEdge[0],0]:C.scrollEdge[0]===(F==null?void 0:F[0])&&C.scrollEdge[1]===F[1]?F:a===void 0||(((U=ti.current)==null?void 0:U.location[0])??0){dt==null||dt(C-X,$)},[dt,X]),Ui=(Zw=J==null?void 0:J.current)==null?void 0:Zw.cell,ER=v.useCallback((C,$,F,U,K,Z)=>{It.current=!1;let Y=Ui;Y!==void 0&&(Y=[Y[0]-X,Y[1]]);const Q=Qe===0?void 0:{x:0,y:C.y,width:Qe,height:C.height},ae=[];Q!==void 0&&ae.push(Q),xt>0&&(ae.push({x:C.x-X,y:w-xt,width:C.width,height:xt}),Qe>0&&ae.push({x:0,y:w-xt,width:Qe,height:xt}));const re={x:C.x-X,y:C.y,width:C.width,height:on&&C.y+C.height>=w?C.height-1:C.height,tx:K,ty:Z,extras:{selected:Y,freezeRegion:Q,freezeRegions:ae}};ln.current=re,Lr(re),st([$,F,U]),Hn==null||Hn(re,re.tx,re.ty,re.extras)},[Ui,X,on,w,Qe,xt,Lr,Hn]),AR=Ul(Ge,v.useCallback((C,$)=>{Ge==null||Ge(C-X,$-X),xe!=="none"&&ve(Nt.fromSingleSelection($),void 0,!0)},[xe,Ge,X,ve])),ig=v.useRef(!1),MR=v.useCallback(C=>{if(C.location[0]===0&&X>0){C.preventDefault();return}wt==null||wt({...C,location:[C.location[0]-X,C.location[1]]}),C.defaultPrevented()||(ig.current=!0),u(void 0)},[wt,X]),RR=v.useCallback(()=>{ig.current=!1},[]),sg=v.useRef(),og=v.useCallback(C=>{var $,F,U;if(!_E(C,sg.current)&&(sg.current=C,!((($=ti==null?void 0:ti.current)==null?void 0:$.button)!==void 0&&ti.current.button>=1))){if(C.buttons!==0&&a!==void 0&&((F=ti.current)==null?void 0:F.location[0])===0&&C.location[0]===0&&X===1&&Je==="multi"&&a.previousSelection&&!a.previousSelection.rows.hasIndex(ti.current.location[1])&&J.rows.hasIndex(ti.current.location[1])){const K=Math.min(ti.current.location[1],C.location[1]),Z=Math.max(ti.current.location[1],C.location[1])+1;ke(Nt.fromSingleSelection([K,Z]),void 0,!1)}if(C.buttons!==0&&a!==void 0&&J.current!==void 0&&!ig.current&&!du.current&&(Pe==="rect"||Pe==="multi-rect")){const[K,Z]=J.current.cell;let[Y,Q]=C.location;if(Q<0&&(Q=ln.current.y),a.fillHandle===!0&&((U=a.previousSelection)==null?void 0:U.current)!==void 0){const ae=a.previousSelection.current.range;Q=Math.min(Q,on?w-1:w);const re=p5(ae,Y,Q,dn);Qp(re)}else{if(on&&Z===w)return;if(on&&Q===w)if(C.kind===Rh)Q--;else return;Y=Math.max(Y,X);const Ee=Y-K,Ie=Q-Z,Se={x:Ee>=0?K:Y,y:Ie>=0?Z:Q,width:Math.abs(Ee)+1,height:Math.abs(Ie)+1};se({...J.current,range:Se},!0,!1,"drag")}}Lt==null||Lt({...C,location:[C.location[0]-X,C.location[1]]})}},[dn,a,X,Je,J,Pe,Lt,ke,on,w,se]),OR=v.useCallback(()=>{var Y,Q;const C=sg.current;if(C===void 0)return;const[$,F]=C.scrollEdge;let[U,K]=C.location;const Z=ln.current;$===-1?U=((Q=(Y=Z.extras)==null?void 0:Y.freezeRegion)==null?void 0:Q.x)??Z.x:$===1&&(U=Z.x+Z.width),F===-1?K=Math.max(0,Z.y):F===1&&(K=Math.min(w-1,Z.y+Z.height)),U=Oi(U,0,gt.length-1),K=Oi(K,0,w-1),og({...C,location:[U,K]})},[gt.length,og,w]);k6(kR,c,OR);const bi=v.useCallback(C=>{if(J.current===void 0)return;const[$,F]=C,[U,K]=J.current.cell,Z=J.current.range;let Y=Z.x,Q=Z.x+Z.width,ae=Z.y,re=Z.y+Z.height;if(F!==0)switch(F){case 2:{re=w,ae=K,bn(0,re,"vertical");break}case-2:{ae=0,re=K+1,bn(0,ae,"vertical");break}case 1:{aeK+1?(re--,bn(0,re,"vertical")):(ae=Math.max(0,ae-1),bn(0,ae,"vertical"));break}default:Oc()}if($!==0)if($===2)Q=gt.length,Y=U,bn(Q-1-X,0,"horizontal");else if($===-2)Y=X,Q=U+1,bn(Y-X,0,"horizontal");else{let Ee=[];if(On!==void 0){const Ie=On({x:Y,y:ae,width:Q-Y-X,height:re-ae},Yn.current.signal);typeof Ie=="object"&&(Ee=A6(Ie))}if($===1){let Ie=!1;if(Y0){const Se=nl(Y+1,U+1).find(Ve=>!Ee.includes(Ve-X));Se!==void 0&&(Y=Se,Ie=!0)}else Y++,Ie=!0;Ie&&bn(Y,0,"horizontal")}Ie||(Q=Math.min(gt.length,Q+1),bn(Q-1-X,0,"horizontal"))}else if($===-1){let Ie=!1;if(Q>U+1){if(Ee.length>0){const Se=nl(Q-1,U,-1).find(Ve=>!Ee.includes(Ve-X));Se!==void 0&&(Q=Se,Ie=!0)}else Q--,Ie=!0;Ie&&bn(Q-X,0,"horizontal")}Ie||(Y=Math.max(X,Y-1),bn(Y-X,0,"horizontal"))}else Oc()}se({cell:J.current.cell,range:{x:Y,y:ae,width:Q-Y,height:re-ae}},!0,!1,"keyboard-select")},[On,J,gt.length,X,w,bn,se]),Xs=v.useCallback((C,$,F,U)=>{const K=Jn-(F?0:1);if(C=Oi(C,X,Ft.length-1+X),$=Oi($,0,K),C===(Ui==null?void 0:Ui[0])&&$===(Ui==null?void 0:Ui[1]))return!1;if(U&&J.current!==void 0){const Z=[...J.current.rangeStack];(J.current.range.width>1||J.current.range.height>1)&&Z.push(J.current.range),xr({...J,current:{cell:[C,$],range:{x:C,y:$,width:1,height:1},rangeStack:Z}},!0)}else se({cell:[C,$],range:{x:C,y:$,width:1,height:1}},!0,!1,"keyboard-nav");return f.current!==void 0&&f.current[0]===C&&f.current[1]===$&&(f.current=void 0),bn(C-X,$),!0},[Jn,X,Ft.length,Ui,J,bn,xr,se]),PR=v.useCallback((C,$)=>{(i==null?void 0:i.cell)!==void 0&&C!==void 0&&ql(C)&&(ei([{location:i.cell,value:C}]),window.requestAnimationFrame(()=>{var K;(K=br.current)==null||K.damage([{cell:i.cell}])})),ur(!0),s(void 0);const[F,U]=$;if(J.current!==void 0&&(F!==0||U!==0)){const K=J.current.cell[1]===Jn-1&&C!==void 0;Xs(Oi(J.current.cell[0]+F,0,gt.length-1),Oi(J.current.cell[1]+U,0,Jn-1),K,!1)}A==null||A(C,$)},[i==null?void 0:i.cell,ur,J,A,ei,Jn,Xs,gt.length]),IR=v.useMemo(()=>`gdg-overlay-${E6++}`,[]),Vo=v.useCallback(C=>{var F,U,K,Z;ur();const $=[];for(let Y=C.x;Y({cell:Y.location})))},[ur,k,Ae,ei,X]),hu=i!==void 0,Xw=v.useCallback(C=>{var Ve,qe;const $=()=>{C.stopPropagation(),C.preventDefault()},F={didMatch:!1},{bounds:U}=C,K=J.columns,Z=J.rows,Y=vi;if(!hu&&yt(Y.clear,C,F))xr(Qf,!1),Rt==null||Rt();else if(!hu&&yt(Y.selectAll,C,F))xr({columns:Nt.empty(),rows:Nt.empty(),current:{cell:((Ve=J.current)==null?void 0:Ve.cell)??[X,0],range:{x:X,y:0,width:y.length,height:w},rangeStack:[]}},!1);else if(yt(Y.search,C,F))(qe=o==null?void 0:o.current)==null||qe.focus({preventScroll:!0}),pf(!0);else if(yt(Y.delete,C,F)){const Mt=(j==null?void 0:j(J))??!0;if(Mt!==!1){const Ze=Mt===!0?J:Mt;if(Ze.current!==void 0){Vo(Ze.current.range);for(const He of Ze.current.rangeStack)Vo(He)}for(const He of Ze.rows)Vo({x:X,y:He,width:y.length,height:1});for(const He of Ze.columns)Vo({x:He,y:0,width:1,height:w})}}if(F.didMatch)return $(),!0;if(J.current===void 0)return!1;let[Q,ae]=J.current.cell,re=!1,Ee=!1;yt(Y.scrollToSelectedCell,C,F)?Cf.current(Q-X,ae):xe!=="none"&&yt(Y.selectColumn,C,F)?K.hasIndex(Q)?ve(K.remove(Q),void 0,!0):xe==="single"?ve(Nt.fromSingleSelection(Q),void 0,!0):ve(void 0,Q,!0):Je!=="none"&&yt(Y.selectRow,C,F)?Z.hasIndex(ae)?ke(Z.remove(ae),void 0,!0):Je==="single"?ke(Nt.fromSingleSelection(ae),void 0,!0):ke(void 0,ae,!0):!hu&&U!==void 0&&yt(Y.activateCell,C,F)?ae===w&&on?window.setTimeout(()=>{const Mt=xf(Q);Bl(Mt??Q)},0):(S==null||S([Q-X,ae]),zl(U,!0)):J.current.range.height>1&&yt(Y.downFill,C,F)?Kw():J.current.range.width>1&&yt(Y.rightFill,C,F)?Uw():yt(Y.goToNextPage,C,F)?ae+=Math.max(1,ln.current.height-4):yt(Y.goToPreviousPage,C,F)?ae-=Math.max(1,ln.current.height-4):yt(Y.goToFirstCell,C,F)?(s(void 0),ae=0,Q=0):yt(Y.goToLastCell,C,F)?(s(void 0),ae=Number.MAX_SAFE_INTEGER,Q=Number.MAX_SAFE_INTEGER):yt(Y.selectToFirstCell,C,F)?(s(void 0),bi([-2,-2])):yt(Y.selectToLastCell,C,F)?(s(void 0),bi([2,2])):hu?(yt(Y.closeOverlay,C,F)&&s(void 0),yt(Y.acceptOverlayDown,C,F)&&(s(void 0),ae++),yt(Y.acceptOverlayUp,C,F)&&(s(void 0),ae--),yt(Y.acceptOverlayLeft,C,F)&&(s(void 0),Q--),yt(Y.acceptOverlayRight,C,F)&&(s(void 0),Q++)):(yt(Y.goDownCell,C,F)?ae+=1:yt(Y.goUpCell,C,F)?ae-=1:yt(Y.goRightCell,C,F)?Q+=1:yt(Y.goLeftCell,C,F)?Q-=1:yt(Y.goDownCellRetainSelection,C,F)?(ae+=1,re=!0):yt(Y.goUpCellRetainSelection,C,F)?(ae-=1,re=!0):yt(Y.goRightCellRetainSelection,C,F)?(Q+=1,re=!0):yt(Y.goLeftCellRetainSelection,C,F)?(Q-=1,re=!0):yt(Y.goToLastRow,C,F)?ae=w-1:yt(Y.goToFirstRow,C,F)?ae=Number.MIN_SAFE_INTEGER:yt(Y.goToLastColumn,C,F)?Q=Number.MAX_SAFE_INTEGER:yt(Y.goToFirstColumn,C,F)?Q=Number.MIN_SAFE_INTEGER:(Pe==="rect"||Pe==="multi-rect")&&(yt(Y.selectGrowDown,C,F)?bi([0,1]):yt(Y.selectGrowUp,C,F)?bi([0,-1]):yt(Y.selectGrowRight,C,F)?bi([1,0]):yt(Y.selectGrowLeft,C,F)?bi([-1,0]):yt(Y.selectToLastRow,C,F)?bi([0,2]):yt(Y.selectToFirstRow,C,F)?bi([0,-2]):yt(Y.selectToLastColumn,C,F)?bi([2,0]):yt(Y.selectToFirstColumn,C,F)&&bi([-2,0])),Ee=F.didMatch);const Ie=Xs(Q,ae,!1,re),Se=F.didMatch;return Se&&(Ie||!Ee||af)&&$(),Se},[hu,J,vi,xe,Je,Pe,X,w,Xs,xr,Rt,y.length,j,af,Vo,ve,ke,on,xf,Bl,S,zl,Kw,Uw,bi]),pu=v.useCallback(C=>{let $=!1;if(oe!==void 0&&oe({...C,cancel:()=>{$=!0}}),$||Xw(C)||J.current===void 0)return;const[F,U]=J.current.cell,K=ln.current;if(lt&&!C.metaKey&&!C.ctrlKey&&J.current!==void 0&&C.key.length===1&&/[ -~]/g.test(C.key)&&C.bounds!==void 0&&Bu(k([F-X,Math.max(0,Math.min(U,w-1))]))){if((!on||U!==w)&&(K.y>U||U>K.y+K.height||K.x>F||F>K.x+K.width))return;zl(C.bounds,!0,C.key),C.stopPropagation(),C.preventDefault()}},[lt,oe,Xw,J,k,X,w,on,zl]),NR=v.useCallback((C,$)=>{const F=C.location[0]-X;if(C.kind==="header"&&(V==null||V(F,{...C,preventDefault:$})),C.kind===Hr){if(F<0)return;N==null||N(F,{...C,preventDefault:$})}if(C.kind==="cell"){const[U,K]=C.location;te==null||te([F,K],{...C,preventDefault:$}),c4(J,C.location)||Xs(U,K,!1,!1)}},[J,te,N,V,X,Xs]),lg=v.useCallback(async C=>{var Y,Q,ae;if(!vi.paste)return;function $(re,Ee,Ie,Se){var qe,Mt;const Ve=typeof Ie=="object"?(Ie==null?void 0:Ie.join(` -`))??"":(Ie==null?void 0:Ie.toString())??"";if(!ca(re)&&Bu(re)&&re.readonly!==!0){const Ze=M==null?void 0:M(Ve,re);if(Ze!==void 0&&ql(Ze))return{location:Ee,value:Ze};const He=Ae(re);if(He===void 0)return;if(He.kind===Te.Custom){Wr(re.kind===Te.Custom);const Jt=(qe=He.onPaste)==null?void 0:qe.call(He,Ve,re.data);return Jt===void 0?void 0:{location:Ee,value:{...re,data:Jt}}}else{const Jt=(Mt=He.onPaste)==null?void 0:Mt.call(He,Ve,re,{formatted:Se,formattedString:typeof Se=="string"?Se:Se==null?void 0:Se.join(` -`),rawValue:Ie});return Jt===void 0?void 0:(Wr(Jt.kind===re.kind),{location:Ee,value:Jt})}}}const F=J.columns,U=J.rows,K=((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0;let Z;if(J.current!==void 0?Z=[J.current.range.x,J.current.range.y]:F.length===1?Z=[F.first()??0,0]:U.length===1&&(Z=[X,U.first()??0]),K&&Z!==void 0){let re,Ee;const Ie="text/plain",Se="text/html";if(navigator.clipboard.read!==void 0){const Ze=await navigator.clipboard.read();for(const He of Ze){if(He.types.includes(Se)){const Qn=await(await He.getType(Se)).text(),kn=Fb(Qn);if(kn!==void 0){re=kn;break}}He.types.includes(Ie)&&(Ee=await(await He.getType(Ie)).text())}}else if(navigator.clipboard.readText!==void 0)Ee=await navigator.clipboard.readText();else if(C!==void 0&&(C==null?void 0:C.clipboardData)!==null){if(C.clipboardData.types.includes(Se)){const Ze=C.clipboardData.getData(Se);re=Fb(Ze)}re===void 0&&C.clipboardData.types.includes(Ie)&&(Ee=C.clipboardData.getData(Ie))}else return;const[Ve,qe]=Z,Mt=[];do{if(ge===void 0){const Ze=Fr(Z),He=Ee??(re==null?void 0:re.map(Qn=>Qn.map(kn=>kn.rawValue).join(" ")).join(" "))??"",Jt=$(Ze,Z,He,void 0);Jt!==void 0&&Mt.push(Jt);break}if(re===void 0){if(Ee===void 0)return;re=g6(Ee)}if(ge===!1||typeof ge=="function"&&(ge==null?void 0:ge([Z[0]-X,Z[1]],re.map(Ze=>Ze.map(He=>{var Jt;return((Jt=He.rawValue)==null?void 0:Jt.toString())??""}))))!==!0)return;for(const[Ze,He]of re.entries()){if(Ze+qe>=w)break;for(const[Jt,Qn]of He.entries()){const kn=[Jt+Ve,Ze+qe],[ki,Ki]=kn;if(ki>=gt.length||Ki>=Jn)continue;const Si=Fr(kn),Xi=$(Si,kn,Qn.rawValue,Qn.formatted);Xi!==void 0&&Mt.push(Xi)}}}while(!1);ei(Mt),(ae=br.current)==null||ae.damage(Mt.map(Ze=>({cell:Ze.location})))}},[M,Ae,Fr,J,vi.paste,gt.length,ei,Jn,ge,X,w]);Vn("paste",lg,d,!1,!0);const gu=v.useCallback(async(C,$)=>{var Y,Q;if(!vi.copy)return;const F=$===!0||((Y=c.current)==null?void 0:Y.contains(document.activeElement))===!0||((Q=l.current)==null?void 0:Q.contains(document.activeElement))===!0,U=J.columns,K=J.rows,Z=(ae,re)=>{if(!_e)zb(ae,re,C);else{const Ee=re.map(Ie=>({kind:Te.Text,data:y[Ie].title,displayData:y[Ie].title,allowOverlay:!1}));zb([Ee,...ae],re,C)}};if(F&&On!==void 0){if(J.current!==void 0){let ae=On(J.current.range,Yn.current.signal);typeof ae!="object"&&(ae=await ae()),Z(ae,nl(J.current.range.x-X,J.current.range.x+J.current.range.width-X))}else if(K!==void 0&&K.length>0){const re=[...K].map(Ee=>{const Ie=On({x:X,y:Ee,width:y.length,height:1},Yn.current.signal);return typeof Ie=="object"?Ie[0]:Ie().then(Se=>Se[0])});if(re.some(Ee=>Ee instanceof Promise)){const Ee=await Promise.all(re);Z(Ee,nl(y.length))}else Z(re,nl(y.length))}else if(U.length>0){const ae=[],re=[];for(const Ee of U){let Ie=On({x:Ee,y:0,width:1,height:w},Yn.current.signal);typeof Ie!="object"&&(Ie=await Ie()),ae.push(Ie),re.push(Ee-X)}if(ae.length===1)Z(ae[0],re);else{const Ee=ae.reduce((Ie,Se)=>Ie.map((Ve,qe)=>[...Ve,...Se[qe]]));Z(Ee,re)}}}},[y,On,J,vi.copy,X,w,_e]);Vn("copy",gu,d,!1,!1);const DR=v.useCallback(async C=>{var F,U;if(!(!vi.cut||!(((F=c.current)==null?void 0:F.contains(document.activeElement))===!0||((U=l.current)==null?void 0:U.contains(document.activeElement))===!0))&&(await gu(C),J.current!==void 0)){let K={current:{cell:J.current.cell,range:J.current.range,rangeStack:[]},rows:Nt.empty(),columns:Nt.empty()};const Z=j==null?void 0:j(K);if(Z===!1||(K=Z===!0?K:Z,K.current===void 0))return;Vo(K.current.range)}},[Vo,J,vi.cut,gu,j]);Vn("cut",DR,d,!1,!1);const _R=v.useCallback((C,$)=>{if(B!==void 0){X!==0&&(C=C.map(K=>[K[0]-X,K[1]])),B(C,$);return}if(C.length===0||$===-1)return;const[F,U]=C[$];f.current!==void 0&&f.current[0]===F&&f.current[1]===U||(f.current=[F,U],Xs(F,U,!1,!1))},[B,X,Xs]),[kf,Sf]=((e1=Pt==null?void 0:Pt.current)==null?void 0:e1.cell)??[],Cf=v.useRef(bn);Cf.current=bn,v.useLayoutEffect(()=>{var C,$,F,U;!It.current&&kf!==void 0&&Sf!==void 0&&(kf!==(($=(C=Us.current)==null?void 0:C.current)==null?void 0:$.cell[0])||Sf!==((U=(F=Us.current)==null?void 0:F.current)==null?void 0:U.cell[1]))&&Cf.current(kf,Sf),It.current=!1},[kf,Sf]);const Gw=J.current!==void 0&&(J.current.cell[0]>=gt.length||J.current.cell[1]>=Jn);v.useLayoutEffect(()=>{Gw&&xr(Qf,!1)},[Gw,xr]);const LR=v.useMemo(()=>on===!0&&(ct==null?void 0:ct.tint)===!0?Nt.fromSingleSelection(Jn-1):Nt.empty(),[Jn,on,ct==null?void 0:ct.tint]),FR=v.useCallback(C=>typeof ze=="boolean"?ze:(ze==null?void 0:ze(C-X))??!0,[X,ze]),$R=v.useMemo(()=>{if(tg===void 0||l.current===null)return null;const{bounds:C,group:$}=tg,F=l.current.getBoundingClientRect();return v.createElement(i6,{bounds:C,group:$,canvasBounds:F,onClose:()=>ng(void 0),onFinish:U=>{ng(void 0),L==null||L($,U)}})},[L,tg]),zR=Math.min(gt.length,Qe+(Dr?1:0));v.useImperativeHandle(e,()=>({appendRow:(C,$)=>Bl(C+X,$),updateCells:C=>{var $;return X!==0&&(C=C.map(F=>({cell:[F.cell[0]+X,F.cell[1]]}))),($=br.current)==null?void 0:$.damage(C)},getBounds:(C,$)=>{var F;if(!((l==null?void 0:l.current)===null||(c==null?void 0:c.current)===null)){if(C===void 0&&$===void 0){const U=l.current.getBoundingClientRect(),K=U.width/c.current.clientWidth;return{x:U.x-c.current.scrollLeft*K,y:U.y-c.current.scrollTop*K,width:c.current.scrollWidth*K,height:c.current.scrollHeight*K}}return(F=br.current)==null?void 0:F.getBounds((C??0)+X,$)}},focus:()=>{var C;return(C=br.current)==null?void 0:C.focus()},emit:async C=>{switch(C){case"delete":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!1,key:"Delete",keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-right":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"r",keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"fill-down":pu({bounds:void 0,cancel:()=>{},stopPropagation:()=>{},preventDefault:()=>{},ctrlKey:!0,key:"d",keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case"copy":await gu(void 0,!0);break;case"paste":await lg();break}},scrollTo:bn,remeasureColumns:C=>{for(const $ of C)bf($+X)}}),[Bl,bf,gu,pu,lg,X,bn]);const[qw,Yw]=Ui??[],BR=v.useCallback(C=>{const[$,F]=C;if(F===-1){xe!=="none"&&(ve(Nt.fromSingleSelection($),void 0,!1),ur());return}qw===$&&Yw===F||(se({cell:C,range:{x:$,y:F,width:1,height:1}},!0,!1,"keyboard-nav"),bn($,F))},[xe,ur,bn,qw,Yw,se,ve]),[jR,HR]=v.useState(!1),Jw=v.useRef(BT(C=>{HR(C)},5)),WR=v.useCallback(()=>{Jw.current(!0),J.current===void 0&&J.columns.length===0&&J.rows.length===0&&a===void 0&&se({cell:[X,gf],range:{x:X,y:gf,width:1,height:1}},!0,!1,"keyboard-select")},[gf,J,a,X,se]),VR=v.useCallback(()=>{Jw.current(!1)},[]),[UR,KR]=v.useMemo(()=>{let C;const $=(We==null?void 0:We.scrollbarWidthOverride)??I0(),F=w+(on?1:0);if(typeof ar=="number")C=ft+F*ar;else{let K=0;const Z=Math.min(F,10);for(let Y=0;YZ.width+K,0)+$;return[`${Math.min(1e5,U)}px`,`${Math.min(1e5,C)}px`]},[gt,We==null?void 0:We.scrollbarWidthOverride,ar,w,on,ft]),XR=v.useMemo(()=>T4(de),[de]);return v.createElement(E4.Provider,{value:de},v.createElement(w6,{style:XR,className:W,inWidth:x??UR,inHeight:g??KR},v.createElement(e6,{fillHandle:Fe,drawFocusRing:Re,experimental:We,fixedShadowX:ut,fixedShadowY:Ot,getRowThemeOverride:p,headerIcons:Xt,imageWindowLoader:Nn,initialSize:wr,isDraggable:Mn,onDragLeave:ys,onRowMoved:qn,overscrollX:Kp,overscrollY:hf,preventDiagonalScrolling:Ol,rightElement:zo,rightElementProps:Hs,smoothScrollX:uf,smoothScrollY:Hp,className:W,enableGroups:zt,onCanvasFocused:WR,onCanvasBlur:VR,canvasRef:l,onContextMenu:NR,theme:de,cellXOffset:jo,cellYOffset:gf,accessibilityHeight:xn.height,onDragEnd:RR,columns:gt,nonGrowWidth:Be,drawHeader:Yp,onColumnProposeMove:D,drawCell:Jp,disabledRows:LR,freezeColumns:zR,lockColumns:X,firstColAccessible:X===0,getCellContent:Fr,minColumnWidth:Nr,maxColumnWidth:yi,searchInputRef:o,showSearch:au,onSearchClose:Gp,highlightRegions:xR,getCellsForSelection:On,getGroupDetails:Zp,headerHeight:Dl,isFocused:jR,groupHeaderHeight:zt?lu:0,freezeTrailingRows:xt+(on&&(ct==null?void 0:ct.sticky)===!0?1:0),hasAppendRow:on,onColumnResize:wi,onColumnResizeEnd:qp,onColumnResizeStart:Ll,onCellFocused:BR,onColumnMoved:AR,onDragStart:MR,onHeaderMenuClick:TR,onItemHovered:og,isFilling:(a==null?void 0:a.fillHandle)===!0,onMouseMove:CR,onKeyDown:pu,onKeyUp:be,onMouseDown:bR,onMouseUp:SR,onDragOverCell:An,onDrop:z,onSearchResultsChanged:_R,onVisibleRegionChanged:ER,clientSize:Oe,rowHeight:ar,searchResults:le,searchValue:ye,onSearchValueChange:me,rows:Jn,scrollRef:c,selection:J,translateX:xn.tx,translateY:xn.ty,verticalBorder:FR,gridRef:br,getCellRenderer:Ae}),$R,i!==void 0&&v.createElement(v.Suspense,{fallback:null},v.createElement(T6,{...i,validateCell:uu,bloom:P,id:IR,getCellRenderer:Ae,className:(We==null?void 0:We.isSubGrid)===!0?"click-outside-ignore":void 0,provideEditor:Bt,imageEditorOverride:h,onFinishEditing:PR,markdownDivCreateNode:m,isOutsideClick:cf}))))},R6=v.forwardRef(M6),Hb=20,O6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??"false"},kind:Te.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:t=>P6(t,t.cell.data,A0(t.cell),t.cell.maxSize??Hb),onDelete:t=>({...t,data:!1}),onClick:t=>{const{cell:e,posX:n,posY:r,bounds:i,theme:s}=t,{width:o,height:l,x:a,y:u}=i,c=e.maxSize??Hb,f=Math.floor(i.y+l/2),d=WT(c,l,s.cellVerticalPadding),h=HT(e.contentAlign??"center",a,o,s.cellHorizontalPadding,d),p=jT(h,f,d),m=VT(a+n,u+r,p);if(A0(e)&&m)return{...e,data:FE(e.data)}},onPaste:(t,e)=>{let n=mh;return t.toLowerCase()==="true"?n=!0:t.toLowerCase()==="false"?n=!1:t.toLowerCase()==="indeterminate"&&(n=Vv),n===e.data?void 0:{...e,data:n}}};function P6(t,e,n,r){if(!n&&e===mh)return;const{ctx:i,hoverAmount:s,theme:o,rect:l,highlighted:a,hoverX:u,hoverY:c,cell:{contentAlign:f}}=t,{x:d,y:h,width:p,height:m}=l,x=.35;let g=n?1-x+x*s:.4;e===mh&&(g*=s),g!==0&&(i.globalAlpha=g,iw(i,o,e,d,h,p,m,a,u,c,r,f),i.globalAlpha=1)}const I6=Jr("div")({name:"BubblesOverlayEditorStyle",class:"gdg-b1ygi5by",propsAsIs:!1}),N6=t=>{const{bubbles:e}=t;return v.createElement(I6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"boe-bubble"},n)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))},D6={getAccessibilityString:t=>UT(t.data),kind:Te.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i).width+r+20,0)+2*n.cellHorizontalPadding-4,draw:t=>L6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement(N6,{bubbles:e.data})},onPaste:()=>{}},_6=4;function L6(t,e){const{rect:n,theme:r,ctx:i,highlighted:s}=t,{x:o,y:l,width:a,height:u}=n,c=20,f=8,d=_6;let h=o+r.cellHorizontalPadding;const p=[];for(const m of e){if(h>o+a)break;const x=ef(m,i,r.baseFontFull).width;p.push({x:h,width:x}),h+=x+f*2+d}i.beginPath();for(const m of p)fs(i,m.x,l+(u-c)/2,m.width+f*2,c,r.roundingRadius??c/2);i.fillStyle=s?r.bgBubbleSelected:r.bgBubble,i.fill();for(const[m,x]of p.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(e[m],x.x+f,l+u/2+js(i,r))}const F6=Jr("div")({name:"DrilldownOverlayEditorStyle",class:"gdg-d4zsq0x",propsAsIs:!1}),$6=t=>{const{drilldowns:e}=t;return v.createElement(F6,null,e.map((n,r)=>v.createElement("div",{key:r,className:"doe-bubble"},n.img!==void 0&&v.createElement("img",{src:n.img}),v.createElement("div",null,n.text))))},z6={getAccessibilityString:t=>UT(t.data.map(e=>e.text)),kind:Te.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(t,e,n)=>e.data.reduce((r,i)=>t.measureText(i.text).width+r+20+(i.img!==void 0?18:0),0)+2*n.cellHorizontalPadding-4,draw:t=>H6(t,t.cell.data),provideEditor:()=>t=>{const{value:e}=t;return v.createElement($6,{drilldowns:e.data})},onPaste:()=>{}},B6=4,tm={};function j6(t,e,n,r){const i=Math.ceil(window.devicePixelRatio),s=5,o=n-s*2,l=4,a=n*i,u=r+s,c=r*3,f=(c+s*2)*i,d=`${t},${e},${i},${n}`;if(tm[d]!==void 0)return{el:tm[d],height:a,width:f,middleWidth:l*i,sideWidth:u*i,padding:s*i,dpr:i};const h=document.createElement("canvas"),p=h.getContext("2d");return p===null?null:(h.width=f,h.height=a,p.scale(i,i),tm[d]=h,p.beginPath(),fs(p,s,s,c,o,r),p.shadowColor="rgba(24, 25, 34, 0.4)",p.shadowBlur=1,p.fillStyle=t,p.fill(),p.shadowColor="rgba(24, 25, 34, 0.3)",p.shadowOffsetY=1,p.shadowBlur=5,p.fillStyle=t,p.fill(),p.shadowOffsetY=0,p.shadowBlur=0,p.shadowBlur=0,p.beginPath(),fs(p,s+.5,s+.5,c,o,r),p.strokeStyle=e,p.lineWidth=1,p.stroke(),{el:h,height:a,width:f,sideWidth:u*i,middleWidth:r*i,padding:s*i,dpr:i})}function H6(t,e){const{rect:n,theme:r,ctx:i,imageLoader:s,col:o,row:l}=t,{x:a,width:u}=n,c=r.baseFontFull,f=iE(i,c),d=Math.min(n.height,Math.max(16,Math.ceil(f*r.lineHeight)*2)),h=Math.floor(n.y+(n.height-d)/2),p=d-10,m=8,x=B6;let g=a+r.cellHorizontalPadding;const y=r.roundingRadius??6,w=j6(r.bgCell,r.drilldownBorder,d,y),k=[];for(const b of e){if(g>a+u)break;const T=ef(b.text,i,c).width;let A=0;b.img!==void 0&&s.loadOrGetImage(b.img,o,l)!==void 0&&(A=p-8+4);const M=T+A+m*2;k.push({x:g,width:M}),g+=M+x}if(w!==null){const{el:b,height:S,middleWidth:T,sideWidth:A,width:M,dpr:O,padding:_}=w,P=A/O,I=_/O;for(const D of k){const ee=Math.floor(D.x),ie=Math.floor(D.width),te=ie-(P-I)*2;i.imageSmoothingEnabled=!1,i.drawImage(b,0,0,A,S,ee-I,h,P,d),te>0&&i.drawImage(b,A,0,T,S,ee+(P-I),h,te,d),i.drawImage(b,M-A,0,A,S,ee+ie-(P-I),h,P,d),i.imageSmoothingEnabled=!0}}i.beginPath();for(const[b,S]of k.entries()){const T=e[b];let A=S.x+m;if(T.img!==void 0){const M=s.loadOrGetImage(T.img,o,l);if(M!==void 0){const O=p-8;let _=0,P=0,I=M.width,D=M.height;I>D?(_+=(I-D)/2,I=D):D>I&&(P+=(D-I)/2,D=I),i.beginPath(),fs(i,A,h+d/2-O/2,O,O,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(M,_,P,I,D,A,h+d/2-O/2,O,O),i.restore(),A+=O+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(T.text,A,h+d/2+js(i,r))}}const W6={getAccessibilityString:t=>t.data.join(", "),kind:Te.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:t=>V6(t,t.cell.displayData??t.cell.data,t.cell.rounding??t.theme.roundingRadius??4,t.cell.contentAlign),measure:(t,e)=>e.data.length*50,onDelete:t=>({...t,data:[]}),provideEditor:()=>t=>{const{value:e,onFinishedEditing:n,imageEditorOverride:r}=t,i=r??D$;return v.createElement(i,{urls:e.data,canWrite:e.readonly!==!1,onCancel:n,onChange:s=>{n({...e,data:[s]})}})},onPaste:(t,e)=>{t=t.trim();const r=t.split(",").map(i=>{try{return new URL(i),i}catch{return}}).filter(i=>i!==void 0);if(!(r.length===e.data.length&&r.every((i,s)=>i===e.data[s])))return{...e,data:r}}},nm=4;function V6(t,e,n,r){const{rect:i,col:s,row:o,theme:l,ctx:a,imageLoader:u}=t,{x:c,y:f,height:d,width:h}=i,p=d-l.cellVerticalPadding*2,m=[];let x=0;for(let y=0;y0&&(a.beginPath(),fs(a,g,f+l.cellVerticalPadding,w,p,n),a.save(),a.clip()),a.drawImage(y,g,f+l.cellVerticalPadding,w,p),n>0&&a.restore(),g+=w+nm}}function U6(t,e){let n=t*49632+e*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}const K6={getAccessibilityString:()=>"",kind:Te.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:t=>{const{cell:e,col:n,row:r,ctx:i,rect:s,theme:o}=t;if(e.skeletonWidth===void 0||e.skeletonWidth===0)return;let l=e.skeletonWidth;e.skeletonWidthVariability!==void 0&&e.skeletonWidthVariability>0&&(l+=Math.round(U6(n,r)*e.skeletonWidthVariability));const a=o.cellHorizontalPadding,u=e.skeletonHeight??Math.min(18,s.height-2*o.cellVerticalPadding);fs(i,s.x+a,s.y+(s.height-u)/2,l,u,o.roundingRadius??3),i.fillStyle=wl(o.textDark,.1),i.fill()},onPaste:()=>{}},X6=()=>t=>t.targetWidth,Wb=Jr("div")({name:"MarkdownOverlayEditorStyle",class:"gdg-m1pnx84e",propsAsIs:!1,vars:{"m1pnx84e-0":[X6(),"px"]}}),G6=t=>{const{value:e,onChange:n,forceEditMode:r,createNode:i,targetRect:s,onFinish:o,validatedSelection:l}=t,a=e.data,u=e.readonly===!0,[c,f]=v.useState(a===""||r),d=v.useCallback(()=>{f(p=>!p)},[]),h=a?"gdg-ml-6":"";return c?v.createElement(Wb,{targetWidth:s.width-20},v.createElement(Tp,{autoFocus:!0,highlight:!1,validatedSelection:l,value:a,onKeyDown:p=>{p.key==="Enter"&&p.stopPropagation()},onChange:n}),v.createElement("div",{className:`gdg-edit-icon gdg-checkmark-hover ${h}`,onClick:()=>o(e)},v.createElement(A$,null))):v.createElement(Wb,{targetWidth:s.width},v.createElement(Z$,{contents:a,createNode:i}),!u&&v.createElement(v.Fragment,null,v.createElement("div",{className:"spacer"}),v.createElement("div",{className:`gdg-edit-icon gdg-edit-hover ${h}`,onClick:d},v.createElement(qv,null))),v.createElement("textarea",{className:"gdg-md-edit-textarea gdg-input",autoFocus:!0}))},q6={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:tf,measure:(t,e,n)=>{const r=e.data.split(` -`)[0];return t.measureText(r).width+2*n.cellHorizontalPadding},draw:t=>Ms(t,t.cell.data,t.cell.contentAlign),onDelete:t=>({...t,data:""}),provideEditor:()=>t=>{const{onChange:e,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:s,forceEditMode:o,validatedSelection:l}=t;return v.createElement(G6,{onFinish:i,targetRect:r,value:n,validatedSelection:l,onChange:a=>e({...n,data:a.target.value}),forceEditMode:o,createNode:s})},onPaste:(t,e)=>t===e.data?void 0:{...e,data:t}},Y6={getAccessibilityString:t=>t.row.toString(),kind:oi.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:J6,measure:()=>44,draw:t=>Z6(t,t.cell.row,t.cell.checked,t.cell.markerKind,t.cell.drawHandle,t.cell.checkboxStyle),onClick:t=>{const{bounds:e,cell:n,posX:r,posY:i}=t,{width:s,height:o}=e,l=n.drawHandle?7+(s-7)/2:s/2,a=o/2;if(Math.abs(r-l)<=10&&Math.abs(i-a)<=10)return{...n,checked:!n.checked}},onPaste:()=>{}};function J6(t,e){const{ctx:n,theme:r}=t,i=r.markerFontFull,s=e??{};return(s==null?void 0:s.font)!==i&&(n.font=i,s.font=i),s.deprep=Q6,n.textAlign="center",s}function Q6(t){const{ctx:e}=t;e.textAlign="start"}function Z6(t,e,n,r,i,s){const{ctx:o,rect:l,hoverAmount:a,theme:u}=t,{x:c,y:f,width:d,height:h}=l,p=n?1:r==="checkbox-visible"?.6+.4*a:a;if(r!=="number"&&p>0){o.globalAlpha=p;const m=7*(n?a:1);if(iw(o,u,n,i?c+m:c,f,i?d-m:d,h,!0,void 0,void 0,18,"center",s),i){o.globalAlpha=a,o.beginPath();for(const x of[3,6])for(const g of[-5,-1,3])o.rect(c+x,f+h/2+g,2,2);o.fillStyle=u.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r==="number"||r==="both"&&!n){const m=e.toString(),x=u.markerFontFull,g=c+d/2;r==="both"&&a!==0&&(o.globalAlpha=1-a),o.fillStyle=u.textLight,o.font=x,o.fillText(m,g,f+h/2+js(o,x)),a!==0&&(o.globalAlpha=1)}}const e9={getAccessibilityString:()=>"",kind:oi.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:t=>t9(t,t.cell.hint,t.cell.icon),onPaste:()=>{}};function t9(t,e,n){const{ctx:r,rect:i,hoverAmount:s,theme:o,spriteManager:l}=t,{x:a,y:u,width:c,height:f}=i;r.beginPath(),r.globalAlpha=s,r.rect(a+1,u+1,c,f-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();const d=e!=="";let h=0;if(n!==void 0){const m=f-8,x=a+8/2,g=u+8/2;l.drawSprite(n,"normal",r,x,g,m,o,d?1:s),h=m}else{h=24;const p=12,m=d?p:s*p,x=d?0:(1-s)*p*.5,g=o.cellHorizontalPadding+4;m>0&&(r.moveTo(a+g+x,u+f/2),r.lineTo(a+g+x+m,u+f/2),r.moveTo(a+g+x+m*.5,u+f/2-m*.5),r.lineTo(a+g+x+m*.5,u+f/2+m*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap="round",r.stroke())}r.fillStyle=o.textMedium,r.fillText(e,h+a+o.cellHorizontalPadding+.5,u+f/2+js(r,o)),r.beginPath()}const n9=v.lazy(async()=>await cE(()=>import("./number-overlay-editor-cI9rZOV7.js"),[])),r9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:tf,draw:t=>Ms(t,t.cell.displayData,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.displayData).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:void 0}),provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return v.createElement(v.Suspense,{fallback:null},v.createElement(n9,{highlight:e,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:s=>n({...r,data:Number.isNaN(s.floatValue??0)?0:s.floatValue})}))},onPaste:(t,e,n)=>{const r=typeof n.rawValue=="number"?n.rawValue:Number.parseFloat(typeof n.rawValue=="string"?n.rawValue:t);if(!(Number.isNaN(r)||e.data===r))return{...e,data:r,displayData:n.formattedString??e.displayData}}},i9={getAccessibilityString:()=>"",measure:()=>108,kind:Te.Protected,needsHover:!1,needsHoverPosition:!1,draw:s9,onPaste:()=>{}};function s9(t){const{ctx:e,theme:n,rect:r}=t,{x:i,y:s,height:o}=r;e.beginPath();const l=2.5;let a=i+n.cellHorizontalPadding+l;const u=s+o/2,c=Math.cos(Vx(30))*l,f=Math.sin(Vx(30))*l;for(let d=0;d<12;d++)e.moveTo(a,u-l),e.lineTo(a,u+l),e.moveTo(a+c,u-f),e.lineTo(a-c,u+f),e.moveTo(a-c,u-f),e.lineTo(a+c,u+f),a+=8;e.lineWidth=1.1,e.lineCap="square",e.strokeStyle=n.textLight,e.stroke()}const o9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(t,e)=>tf(t,e,t.theme.textLight),draw:t=>Ms(t,t.cell.data,t.cell.contentAlign),measure:(t,e,n)=>t.measureText(e.data).width+n.cellHorizontalPadding*2,provideEditor:()=>t=>{const{isHighlighted:e,onChange:n,value:r,validatedSelection:i}=t;return Ln.createElement(Tp,{highlight:e,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:s=>n({...r,data:s.target.value})})},onPaste:()=>{}},l9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Text,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!1,drawPrep:tf,useLabel:!0,draw:t=>{const{cell:e,hoverAmount:n,hyperWrapping:r,ctx:i,rect:s,theme:o,overrideCursor:l}=t,{displayData:a,contentAlign:u,hoverEffect:c,allowWrapping:f}=e;if(c===!0&&n>0){i.textBaseline="alphabetic";const d=o.cellHorizontalPadding,h=o.cellVerticalPadding,p=ef(a,i,o.baseFontFull,"alphabetic"),m=s.height-h,x=Math.min(m,p.actualBoundingBoxAscent*2.5);i.beginPath(),fs(i,s.x+d/2,s.y+(s.height-x)/2+1,p.width+d*3,x-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=wl(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline="middle",l==null||l("text")}Ms(t,a,u,f,r)},measure:(t,e,n)=>{const r=e.displayData.split(` -`,e.allowWrapping===!0?void 0:1);let i=0;for(const s of r)i=Math.max(i,t.measureText(s).width);return i+2*n.cellHorizontalPadding},onDelete:t=>({...t,data:""}),provideEditor:t=>({disablePadding:t.allowWrapping===!0,editor:e=>{const{isHighlighted:n,onChange:r,value:i,validatedSelection:s}=e;return v.createElement(Tp,{style:t.allowWrapping===!0?{padding:"3px 8.5px"}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:s,onChange:o=>r({...i,data:o.target.value})})}}),onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},a9=Jr("div")({name:"UriOverlayEditorStyle",class:"gdg-u1rrojo",propsAsIs:!1}),u9=t=>{const{uri:e,onChange:n,forceEditMode:r,readonly:i,validatedSelection:s,preview:o}=t,[l,a]=v.useState(!i&&(e===""||r)),u=v.useCallback(()=>{a(!0)},[]);return l?v.createElement(Tp,{validatedSelection:s,highlight:!0,autoFocus:!0,value:e,onChange:n}):v.createElement(a9,null,v.createElement("a",{className:"gdg-link-area",href:e,target:"_blank",rel:"noopener noreferrer"},o),!i&&v.createElement("div",{className:"gdg-edit-icon",onClick:u},v.createElement(qv,null)),v.createElement("textarea",{className:"gdg-input",autoFocus:!0}))};function Vb(t,e,n,r){let i=n.cellHorizontalPadding;const s=e.height/2-t.actualBoundingBoxAscent/2,o=t.width,l=t.actualBoundingBoxAscent;return r==="right"?i=e.width-o-n.cellHorizontalPadding:r==="center"&&(i=e.width/2-o/2),{x:i,y:s,width:o,height:l}}const c9={getAccessibilityString:t=>{var e;return((e=t.data)==null?void 0:e.toString())??""},kind:Te.Uri,needsHover:t=>t.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:tf,draw:t=>{const{cell:e,theme:n,overrideCursor:r,hoverX:i,hoverY:s,rect:o,ctx:l}=t,a=e.displayData??e.data,u=e.hoverEffect===!0;if(r!==void 0&&u&&i!==void 0&&s!==void 0){const c=ef(a,l,n.baseFontFull),f=Vb(c,o,n,e.contentAlign),{x:d,y:h,width:p,height:m}=f;if(i>=d-4&&i<=d-4+p+8&&s>=h-4&&s<=h-4+m+8){const x=js(l,n.baseFontFull);r("pointer");const g=5,y=h-x;l.beginPath(),l.moveTo(o.x+d,Math.floor(o.y+y+m+g)+.5),l.lineTo(o.x+d+p,Math.floor(o.y+y+m+g)+.5),l.strokeStyle=n.linkColor,l.stroke(),l.save(),l.fillStyle=t.cellFillColor,Ms({...t,rect:{...o,x:o.x-1}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x-2}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x+1}},a,e.contentAlign),Ms({...t,rect:{...o,x:o.x+2}},a,e.contentAlign),l.restore()}}l.fillStyle=u?n.linkColor:n.textDark,Ms(t,a,e.contentAlign)},onClick:t=>{const{cell:e,bounds:n,posX:r,posY:i,theme:s}=t,o=e.displayData??e.data;if(e.hoverEffect!==!0||e.onClickUri===void 0)return;const l=y4(o,s.baseFontFull);if(l===void 0)return;const a=Vb(l,n,s,e.contentAlign);Ap({x:a.x-4,y:a.y-4,width:a.width+8,height:a.height+8},r,i)&&e.onClickUri(t)},measure:(t,e,n)=>t.measureText(e.displayData??e.data).width+n.cellHorizontalPadding*2,onDelete:t=>({...t,data:""}),provideEditor:t=>e=>{const{onChange:n,value:r,forceEditMode:i,validatedSelection:s}=e;return v.createElement(u9,{forceEditMode:r.readonly!==!0&&(i||t.hoverEffect===!0&&t.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:s,readonly:r.readonly===!0,onChange:o=>n({...r,data:o.target.value})})},onPaste:(t,e,n)=>t===e.data?void 0:{...e,data:t,displayData:n.formattedString??e.displayData}},f9=[Y6,e9,O6,D6,z6,W6,K6,q6,r9,i9,o9,l9,c9];var d9=zT,h9=El,p9="Expected a function";function g9(t,e,n){var r=!0,i=!0;if(typeof t!="function")throw new TypeError(p9);return h9(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),d9(t,e,{leading:r,maxWait:e,trailing:i})}var m9=g9;const y9=ji(m9),rm=[];class v9 extends oE{constructor(){super(...arguments);bt(this,"imageLoaded",()=>{});bt(this,"loadedLocations",[]);bt(this,"cache",{});bt(this,"sendLoaded",y9(()=>{this.imageLoaded(new ic(this.loadedLocations)),this.loadedLocations=[]},20));bt(this,"clearOutOfWindow",()=>{const n=Object.keys(this.cache);for(const r of n){const i=this.cache[r];let s=!1;for(let o=0;o{a||(a=!0,rm.length<12?rm.unshift(l):o||(l.src=""))}},c=new Promise(f=>l.addEventListener("load",()=>f(null)));requestAnimationFrame(async()=>{try{l.src=n,await c,await l.decode();const f=this.cache[s];if(f!==void 0&&!a){f.img=l;for(const d of f.cells)this.loadedLocations.push(tw(d));o=!0,this.sendLoaded()}}catch{u.cancel()}}),this.cache[s]=u}loadOrGetImage(n,r,i){const s=n,o=this.cache[s];if(o!==void 0){const l=Pi(r,i);return o.cells.includes(l)||o.cells.push(l),o.img}else this.loadImage(n,r,i,s)}}const im="\uFEFF";function w9(t){const e={",":0,";":0," ":0};let n=",",r=-1,i=0,s=!1;for(let o=0;or&&(n=o,r=e[o]);return n}function x9(t,e,n){if(t[e]==='"'){let i="",s=e+1;for(;;){if(s>=t.length)return[i,s];const o=t[s];if(o==='"')if(t[s+1]==='"')i+='"',s+=2;else{for(s++;s=r.length)break;if(r[y]===s){c=y+1,f=!0;continue}c=r[y]==="\r"&&r[y+1]===` -`?y+2:y+1,o.push(a),l.push({start:u+i,end:y+i}),a=[]}a.length>0?(o.push(a),l.push({start:u+i,end:r.length+i})):o.length===0&&a.length===0&&r.length>0&&(o.push([""]),l.push({start:0+i,end:r.length+i}));const d=o.length>0?o[0]:[],h=d.length,p=o.slice(1),m=p.map(g=>g.length),x=p.map(g=>g.length===h?g:g.length>h?g.slice(0,h):[...g,...Array(h-g.length).fill("")]);return{headers:d,rows:x,delimiter:s,rowWidths:m,rowSpans:l.slice(1)}}function Mp(t,e=","){const n=r=>r.includes('"')?`"${r.replaceAll('"','""')}"`:r.includes(e)||r.includes(` -`)||r.includes("\r")?`"${r}"`:r;return t.map(n).join(e)}function sm(t,e,n=","){return[t,...e].map(r=>Mp(r,n)).join(` -`)}function lw(t,e){return nf(t,e).headers}function b9(t){const e=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:t.headers.length},()=>!0),r=Array.from({length:t.headers.length},()=>!1);for(const i of t.rows)for(let s=0;si&&r[s])}function $E(t,e){let n="",r=0;for(const{start:i,end:s,replacement:o}of e)n+=t.slice(r,i)+o,r=s;return n+t.slice(r)}function k9(t,e){return t[e]==="\r"?t[e+1]===` -`?2:1:t[e]===` -`?1:0}function Ub(t,e){return t[e-2]==="\r"&&t[e-1]===` -`?2:t[e-1]==="\r"||t[e-1]===` -`?1:0}const Kb="\uFEFF";function zE(t,e){const n=t.startsWith(Kb)?Kb.length:0,r=e.rowSpans[0];if(r!==void 0)return{start:n,end:r.start-Ub(t,r.start)};const i=t.slice(n);return{start:n,end:n+i.length-Ub(t,t.length)}}function om(t,e,n){const r=[...new Set(n)].flatMap(i=>{const s=e.rowSpans[i];return s===void 0?[]:[s]}).sort((i,s)=>i.start-s.start).map(i=>({start:i.start,end:i.end+k9(t,i.end),replacement:""}));return r.length===0?t:$E(t,r)}function Xb(t,e,n){const r=new Set([...n].filter(o=>o>=0&&ou!r.has(c));s.push({start:o.start,end:o.end,replacement:Mp(a,e.delimiter)})}return $E(t,s)}function S9(t,e,n,r){if(!t||n<0||n>=e.headers.length)return t;const i=zE(t,e),s=lw(t.slice(i.start,i.end),e.delimiter);if(n>=s.length||s[n]===r)return t;const o=s.map((a,u)=>u===n?r:a),l=Mp(o,e.delimiter);return t.slice(0,i.start)+l+t.slice(i.end)}const U0=50;function Go(t=""){return{past:[],present:t,future:[]}}function Gb(t,e,n=U0){if(e===t.present)return t;if(t.present===""&&t.past.length===0&&t.future.length===0)return{past:[],present:e,future:[]};const r=[...t.past,t.present];return{past:r.length>n?r.slice(r.length-n):r,present:e,future:[]}}function C9(t){if(t.past.length===0)return t;const e=t.past[t.past.length-1];return{past:t.past.slice(0,t.past.length-1),present:e,future:[t.present,...t.future]}}function T9(t){if(t.future.length===0)return t;const[e,...n]=t.future,r=[...t.past,t.present];return{past:r.length>U0?r.slice(r.length-U0):r,present:e,future:n}}function E9(t){if(t.altKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.key.toLowerCase();return e==="z"?t.shiftKey?"redo":"undo":e==="y"&&!t.shiftKey?"redo":null}const qb=/^[+-]?\d{16,}$/;function A9(t,e){const n=Array.from({length:t.length},(i,s)=>s);if(e==="")return n;const r=e.toLowerCase();return n.filter(i=>{const s=t[i];for(let o=0;o{var c,f;const a=((c=e[o])==null?void 0:c[n])??"",u=((f=e[l])==null?void 0:f[n])??"";if(i){const d=a===""?NaN:Number(a),h=u===""?NaN:Number(u),p=Number.isNaN(d),m=Number.isNaN(h);if(p||m)return p&&m?0:p?1:-1;if(qb.test(a)&&qb.test(u)){const x=BigInt(a),g=BigInt(u);return s*(xg?1:0)}return s*(d-h)}return s*a.localeCompare(u)})}const R9=` - -`;function Zf(t,e){return Math.max(0,Math.min(t,e))}function Yb(t,e,n,r){const i=t.headers.length,s=[];for(const a of n.ranges){const u=Zf(a.x,r+i),c=Zf(a.x+a.width,r+i);if(c<=r)continue;const f=Math.max(0,u-r),d=c-r;if(d<=f)continue;const h=Zf(a.y,e.length),p=Zf(a.y+a.height,e.length);if(p<=h)continue;const m=t.headers.slice(f,d),x=[];for(let g=h;gw[f+b]??""))}x.length!==0&&s.push(sm(m,x,t.delimiter))}if(s.length>0)return s.join(R9);const o=[...n.rows].filter(a=>a>=0&&ae[a]).filter(a=>a!==void 0);if(o.length>0)return sm(t.headers,o.map(a=>t.rows[a]??[]),t.delimiter);const l=[...n.columns].filter(a=>a>=r&&a0){const a=l.map(c=>t.headers[c-r]),u=e.map(c=>{const f=t.rows[c]??[];return l.map(d=>f[d-r]??"")});return sm(a,u,t.delimiter)}return null}const qo=1e5,O9=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function P9(t,e,n,r){var p;const i=t.headers.length,s=e.length;if(i===0||s===0)return null;const o=new Set;for(const m of n.ranges){if(o.size>=qo)break;const x=Math.max(0,m.x-r),g=Math.min(i,m.x+m.width-r);if(g<=x)continue;const y=Math.max(0,m.y),w=Math.min(s,m.y+m.height);if(!(w<=y))for(let k=y;k=qo);k++){const b=k*i;for(let S=x;S=qo));S++);}}for(const m of n.rows){if(o.size>=qo)break;if(m<0||m>=s)continue;const x=m*i;for(let g=0;g=qo));g++);}for(const m of n.columns){if(o.size>=qo)break;const x=m-r;if(!(x<0||x>=i))for(let g=0;g=qo));g++);}const l=o.size;if(l===0||l<2&&n.rows.length===0&&n.columns.length===0)return null;let a=0,u=0,c=0,f=null,d=null;const h=new Set;for(const m of o){const x=Math.floor(m/i),g=m%i,y=e[x],k=((y!==void 0?(p=t.rows[y])==null?void 0:p[g]:void 0)??"").trim();if(k===""){a+=1;continue}if(h.add(k),O9.test(k)){const b=Number(k);Number.isFinite(b)&&(u+=1,c+=b,(f===null||bd)&&(d=b))}}return{cellCount:l,distinctCount:h.size,emptyCount:a,numericCount:u,sum:u>0?c:null,avg:u>0?c/u:null,min:u>0?f:null,max:u>0?d:null}}const Jb=24,lm=26,Qb=110,am=40,I9=12,zn=1,Zb='ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace',ek='ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif',N9=[{mode:"auto",label:"Auto"},{mode:"string",label:"String"},{mode:"number",label:"Number"},{mode:"boolean",label:"Boolean"}];function tk(t){return t==="string"?"STR":t==="number"?"NUM":t==="boolean"?"BOOL":null}function nk(t){if(!(t instanceof HTMLElement))return!1;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"||t.isContentEditable}const Xl="inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground hover:bg-muted outline-none focus-visible:ring-3 focus-visible:ring-ring/50",Ld=new Intl.NumberFormat("en-US",{maximumFractionDigits:4});function ed(t){return Ld.format(Object.is(t,-0)?0:t)}function D9(t){const e=[`Cells: ${Ld.format(t.cellCount)}`,`Distinct: ${Ld.format(t.distinctCount)}`];return t.emptyCount>0&&e.push(`Empty: ${Ld.format(t.emptyCount)}`),t.numericCount>0&&t.sum!==null&&t.avg!==null&&t.min!==null&&t.max!==null&&e.push(`Sum: ${ed(t.sum)}`,`Avg: ${ed(t.avg)}`,`Min: ${ed(t.min)}`,`Max: ${ed(t.max)}`),e.join(" · ")}function _9(t){return t?{accentColor:"hsl(0 0% 98%)",accentFg:"hsl(240 10% 3.9%)",accentLight:"hsla(240, 4.9%, 70%, 0.18)",textDark:"hsl(0 0% 98%)",textMedium:"hsl(240 5% 64.9%)",textLight:"hsla(240, 5%, 64.9%, 0.4)",textBubble:"hsl(0 0% 98%)",textHeader:"hsl(240 5% 64.9%)",textHeaderSelected:"hsl(0 0% 98%)",bgCell:"hsl(240 6% 7%)",bgCellMedium:"hsl(240 6% 7%)",bgHeader:"hsl(240 6% 7%)",bgHeaderHasFocus:"hsl(240 3.7% 15.9%)",bgHeaderHovered:"hsl(240 3.7% 15.9%)",bgBubble:"hsl(240 3.7% 15.9%)",bgBubbleSelected:"hsl(240 6% 7%)",bgSearchResult:"hsl(240 3.7% 15.9%)",borderColor:"hsl(240 3.7% 15.9%)",horizontalBorderColor:"hsla(240, 3.7%, 15.9%, 0.6)",headerBottomBorderColor:"hsl(240 3.7% 15.9%)",linkColor:"hsl(0 0% 98%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ek,lineHeight:1}:{accentColor:"hsl(240 10% 3.9%)",accentFg:"hsl(0 0% 100%)",accentLight:"hsla(240, 4.8%, 45%, 0.14)",textDark:"hsl(240 10% 3.9%)",textMedium:"hsl(240 3.8% 46.1%)",textLight:"hsla(240, 3.8%, 46.1%, 0.4)",textBubble:"hsl(240 10% 3.9%)",textHeader:"hsl(240 3.8% 46.1%)",textHeaderSelected:"hsl(240 10% 3.9%)",bgCell:"hsl(0 0% 100%)",bgCellMedium:"hsl(0 0% 100%)",bgHeader:"hsl(0 0% 100%)",bgHeaderHasFocus:"hsl(240 4.8% 95.9%)",bgHeaderHovered:"hsl(240 4.8% 95.9%)",bgBubble:"hsl(240 4.8% 95.9%)",bgBubbleSelected:"hsl(0 0% 100%)",bgSearchResult:"hsl(48 96% 89%)",borderColor:"hsl(240 5.9% 90%)",horizontalBorderColor:"hsla(240, 5.9%, 90%, 0.6)",headerBottomBorderColor:"hsl(240 5.9% 90%)",linkColor:"hsl(240 10% 3.9%)",cellHorizontalPadding:8,cellVerticalPadding:3,headerFontStyle:"600 11px",baseFontStyle:"12px",editorFontSize:"12px",fontFamily:ek,lineHeight:1}}function L9(t){return t?"hsla(45, 96%, 65%, 0.3)":"hsl(48 96% 89%)"}function BE({text:t,delimiter:e,testId:n="csv-table",dark:r=!1,onCellCommit:i,onUndo:s,onRedo:o,onCopySelection:l,columnTypes:a,onChangeColumnTypes:u}){const c=v.useRef(null),f=v.useRef(null),d=v.useRef(null),[h,p]=v.useState(""),[m,x]=v.useState(""),[g,y]=v.useState(null),w=v.useRef(g);w.current=g;const k=v.useRef(null),[b,S]=v.useState(null),[T,A]=v.useState(""),M=v.useRef(null),[O,_]=v.useState(void 0),[P,I]=v.useState(()=>new Set),D=v.useRef(P),[ee,ie]=v.useState(0),[te,W]=v.useState({}),V=i!==void 0,R=a??te,N=v.useCallback(z=>{W(z),u==null||u(z)},[u]),L=v.useMemo(()=>_9(r),[r]),H=L9(r),G=r?"hsl(240 3.7% 15.9%)":"hsl(240 4.8% 95.9%)",B=v.useRef();B.current===void 0&&(B.current=new v9);const le=v.useMemo(()=>nf(t,e),[t,e]),me=v.useMemo(()=>b9(le),[le]),ye=le.headers.length,oe=v.useRef({text:t,table:le});oe.current={text:t,table:le};const be=v.useRef(O);be.current=O,v.useEffect(()=>{const z=window.setTimeout(()=>x(h),150);return()=>window.clearTimeout(z)},[h]);const Ce=v.useMemo(()=>{const z=A9(le.rows,m);return g?M9(z,le.rows,g.col,g.dir,me[g.col]??!1):z},[le,m,g,me]),lt=v.useRef(Ce);lt.current=Ce,v.useEffect(()=>{const z=f.current;if(!z||typeof ResizeObserver>"u")return;const ue=new ResizeObserver(()=>ie(z.clientWidth));return ue.observe(z),ie(z.clientWidth),()=>ue.disconnect()},[]);const Xe=Math.max(Qb,Math.floor((ee-am)/Math.max(1,ye)));v.useEffect(()=>{I(z=>{let ue=!1;const q=new Set;for(const ce of z)ce{_(z=>{if(!z||z.rows.length===0)return z;const ue=[];for(const ce of D.current){const fe=Ce.indexOf(ce);fe!==-1&&ue.push(fe)}ue.sort((ce,fe)=>ce-fe);const q=ue.reduce((ce,fe)=>ce.add(fe),Nt.empty());return q.equals(z.rows)?z:{...z,rows:q}})},[Ce]),v.useEffect(()=>{y(z=>z!==null&&z.col>=ye?null:z),S(z=>z!==null&&z.col>=ye?null:z)},[ye]);const Ge=m!=="",at=le.rows.length,Ut=lm+Math.min(Ce.length,I9)*Jb,Pe=()=>{p(""),x("")},xe=v.useCallback((z,ue)=>{var ce;if(z0||Fe.height>0)?{x:Math.max(0,Re.x-Fe.left),y:Math.max(0,Re.y-Fe.top),width:Re.width,height:Re.height}:Re??{x:am+q*Xe,y:0,width:Xe,height:lm};A(fe),S({col:q,bounds:We});return}k.current=w.current,S(null),y(fe=>!fe||fe.col!==q?{col:q,dir:"asc"}:fe.dir==="asc"?{col:q,dir:"desc"}:null)},[V,Xe]),Je=v.useCallback(()=>{if(!b)return;const{col:z}=b;if(S(null),!i)return;const{text:ue,table:q}=oe.current,ce=q.headers[z]??"",fe=S9(ue,q,z,T);if(fe!==ue){if(ce!==""&&ce!==T&&R[ce]!==void 0){const Fe={...R},Re=Fe[ce];delete Fe[ce],T!==""&&Re!==void 0&&(Fe[T]=Re),N(Fe)}i(fe)}},[b,T,i,R,N]),nt=v.useCallback(()=>{S(null)},[]);v.useEffect(()=>{if(!b)return;const z=M.current;z&&(z.focus(),z.select())},[b]);const it=v.useCallback((z,ue)=>{const q=lt.current,ce=q[ue];if(ce===void 0)return;const fe=D.current,Fe=d.current;let Re;if(z.shiftKey&&Fe!==null&&Fe!==ce){const ut=q.indexOf(Fe),Ot=q.indexOf(ce),Xt=ut===-1?Ot:ut,[Nn,wr]=Xt<=Ot?[Xt,Ot]:[Ot,Xt];Re=z.metaKey||z.ctrlKey?new Set(fe):new Set;for(let Mn=Nn;Mn<=wr;Mn++){const ys=q[Mn];ys!==void 0&&Re.add(ys)}}else z.metaKey||z.ctrlKey?(Re=new Set(fe),Re.has(ce)?Re.delete(ce):Re.add(ce)):Re=new Set([ce]);d.current=ce,D.current=Re,I(Re);const We=[...Re].map(ut=>q.indexOf(ut)).filter(ut=>ut!==-1).sort((ut,Ot)=>ut-Ot);_(ut=>({current:ut==null?void 0:ut.current,columns:(ut==null?void 0:ut.columns)??Nt.empty(),rows:We.reduce((Ot,Xt)=>Ot.add(Xt),Nt.empty())}))},[]),$e=v.useCallback(()=>{d.current=null,D.current=new Set,I(new Set),_(void 0)},[]),At=v.useCallback(z=>{const ue=new Set;for(const q of z.rows){const ce=lt.current[q];ce!==void 0&&ue.add(ce)}D.current=ue,I(ue),_(z)},[]),wt=v.useCallback(()=>{$e()},[$e]),rt=v.useMemo(()=>Ce.filter(z=>P.has(z)),[Ce,P]),ge=v.useMemo(()=>[...(O==null?void 0:O.columns)??[]].filter(z=>z>=zn).map(z=>z-zn),[O]),_e=ge.length,Qe=v.useMemo(()=>ge.map(z=>le.headers[z]).filter(z=>z!==void 0),[ge,le.headers]),tt=v.useMemo(()=>{if(Qe.length===0)return null;const z=R[Qe[0]]??"auto";for(let ue=1;ue{if(!V||Qe.length===0)return;const ue={...R};for(const q of Qe)z==="auto"?delete ue[q]:ue[q]=z;N(ue)},[V,Qe,R,N]),dt=v.useMemo(()=>V?le.headers.filter(z=>tk(R[z])!==null).length:0,[V,le.headers,R]),ht=v.useMemo(()=>({ranges:O!=null&&O.current?[O.current.range,...O.current.rangeStack]:[],columns:O?[...O.columns]:[],rows:P.size>0?Ce.reduce((z,ue,q)=>(P.has(ue)&&z.push(q),z),[]):O?[...O.rows]:[]}),[O,P,Ce]),pt=zn,Lt=v.useMemo(()=>P9(le,Ce,ht,pt),[le,Ce,ht,pt]),Rt=rt.length>0||_e>0||Lt!==null,en=v.useRef(l);en.current=l;const Hn=()=>{var q,ce;const z=be.current,ue=Yb(oe.current.table,lt.current,{ranges:z!=null&&z.current?[z.current.range,...z.current.rangeStack]:[],columns:z?[...z.columns]:[],rows:z?[...z.rows]:[]},zn);ue!==null&&((q=en.current)==null||q.call(en),(ce=navigator.clipboard)==null||ce.writeText(ue).catch(()=>{}))};v.useEffect(()=>{const z=ue=>{var Re,We;const q=c.current;if(!q||!q.contains(document.activeElement))return;const ce=document.activeElement;if(ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable))return;const fe=be.current,Fe=Yb(oe.current.table,lt.current,{ranges:fe!=null&&fe.current?[fe.current.range,...fe.current.rangeStack]:[],columns:fe?[...fe.columns]:[],rows:fe?[...fe.rows]:[]},zn);Fe!==null&&(ue.preventDefault(),ue.stopImmediatePropagation(),(Re=ue.clipboardData)==null||Re.setData("text/plain",Fe),(We=en.current)==null||We.call(en))};return window.addEventListener("copy",z,{capture:!0}),()=>window.removeEventListener("copy",z,{capture:!0})},[]),v.useEffect(()=>{if(!s&&!o)return;const z=ue=>{const q=c.current;if(!q)return;const ce=ue.target instanceof Node&&q.contains(ue.target),fe=document.activeElement instanceof Node&&q.contains(document.activeElement);if(!ce&&!fe||nk(ue.target)||nk(document.activeElement))return;const Fe=E9(ue);Fe==="undo"&&s?(ue.preventDefault(),s()):Fe==="redo"&&o&&(ue.preventDefault(),o())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[s,o]);const Pt=v.useCallback(z=>{var q;const ue=c.current!==null&&document.activeElement instanceof Node&&c.current.contains(document.activeElement);$e(),i==null||i(z),ue&&((q=f.current)==null||q.focus({preventScroll:!0}))},[$e,i]),vn=ye>0&&ge.length>=ye,In=()=>{!V||rt.length===0||Pt(om(oe.current.text,oe.current.table,rt))},Pr=()=>{!V||vn||ge.length===0||Pt(Xb(oe.current.text,oe.current.table,ge))},Ir=v.useCallback(z=>{if(!i)return!1;const{text:q,table:ce}=oe.current,fe=lt.current;if(z.rows.length>0){const We=[...z.rows].map(ut=>fe[ut]).filter(ut=>ut!==void 0);if(We.length>0)return Pt(om(q,ce,We)),!1}if(z.columns.length>0){const We=[...z.columns].filter(ut=>ut>=zn&&utut-zn);return We.length>0&&We.length0&&Pt(om(q,ce,Re)),!1},[Pt,i]),Bt=v.useCallback(z=>{const ue=i;if(!ue)return!1;const{text:q,table:ce}=oe.current,fe=lt.current,Fe=[...z].sort((ut,Ot)=>ut.location[1]-Ot.location[1]);let Re=q,We=0;for(const{location:ut,value:Ot}of Fe){const Xt=ut[0]-zn,Nn=ut[1];if(Xt<0||Ot.kind!==Te.Text)continue;const wr=fe[Nn],Mn=wr===void 0?void 0:ce.rowSpans[wr];if(!Mn)continue;const ys=Re.slice(Mn.start+We,Mn.end+We),qn=lw(ys,ce.delimiter);for(;qn.length<=Xt;)qn.push("");const vs=Ot.data??"";if(qn[Xt]===vs)continue;qn[Xt]=vs;const ws=Mp(qn,ce.delimiter);Re=Re.slice(0,Mn.start+We)+ws+Re.slice(Mn.end+We),We+=ws.length-(Mn.end-Mn.start)}return Re!==q&&ue(Re),!0},[i]),ct=v.useCallback(z=>{var Fe;const[ue,q]=z,ce=lt.current[q];if(ue{const ue=[];for(let q=z.y;q{z[0]>=zn||it(ue,z[1])},[it]),ne=v.useMemo(()=>{const z={title:"#",id:"__gutter",width:am,themeOverride:{baseFontStyle:`11px ${Zb}`,textDark:"hsla(240, 3.8%, 46.1%, 0.4)"}},ue=le.headers.map((q,ce)=>{const fe=V?tk(R[q]):null;return{title:fe?`${q.toUpperCase()} [${fe}]`:q.toUpperCase(),id:`c${ce}`,width:Xe,themeOverride:me[ce]?{baseFontStyle:`12px ${Zb}`}:void 0}});return[z,...ue]},[le.headers,me,Xe,V,R]),Le=v.useCallback((z,ue)=>{const{ctx:q,columnIndex:ce,rect:fe,theme:Fe,isSelected:Re}=z;q.save();try{if(q.letterSpacing="0.5px",Re&&(q.fillStyle=Fe.bgHeaderHovered,q.fillRect(fe.x,fe.y,fe.width,fe.height),q.fillStyle=Fe.accentColor,q.fillRect(fe.x,fe.y+fe.height-2,fe.width,2)),ce{const{ctx:q,cell:ce,rect:fe,col:Fe,theme:Re}=z,We=Fe-zn;if(We>=0&&Ge&&ce.kind===Te.Text){const ut=F9(ce.data,m);if(ut!==null){q.save();try{const Ot=`${Re.baseFontStyle} ${Re.fontFamily}`;q.font=Ot;let Xt=fe.x+Re.cellHorizontalPadding;const Nn=fe.y+fe.height/2+js(q,Ot);for(const wr of ut){const Mn=q.measureText(wr.text).width;wr.hit&&Mn>0&&(q.fillStyle=H,q.fillRect(Xt-1,Nn-7,Mn+2,14)),Xt+=Mn}}finally{q.restore()}}}if(ue(),We>=0&&ce.kind===Te.Text&&ce.data===""){q.save();try{q.font=`${Re.baseFontStyle} ${Re.fontFamily}`,q.fillStyle=Re.textLight,q.fillText("—",fe.x+Re.cellHorizontalPadding,fe.y+fe.height/2+.5)}finally{q.restore()}}},[Ge,m,H]),An=v.useCallback(z=>{const ue=lt.current[z];return ue!==void 0&&D.current.has(ue)?{bgCell:G,bgCellMedium:G}:void 0},[G]);return ye===0?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"No columns detected."}):E.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",ref:c,children:[E.jsxs("div",{"data-testid":`${n}-toolbar`,className:"flex flex-none flex-wrap items-center gap-1.5 border-b border-border bg-panel px-2 py-1",children:[E.jsxs("div",{className:"relative min-w-32 flex-1 sm:max-w-64",children:[E.jsx(aN,{"aria-hidden":"true",className:"pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60"}),E.jsx("input",{type:"text","data-testid":`${n}-search`,"aria-label":"Search rows",value:h,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Escape"&&Pe()},placeholder:"Search…",className:"h-6 w-full rounded-md border border-border bg-background pl-6 pr-6 text-xs text-foreground outline-none placeholder:text-muted-foreground/50 focus-visible:ring-3 focus-visible:ring-ring/50"}),h!==""&&E.jsx("button",{type:"button","data-testid":`${n}-clear-search`,"aria-label":"Clear search",onClick:Pe,className:"absolute right-1 top-1/2 -translate-y-1/2 cursor-pointer rounded p-0.5 text-muted-foreground/60 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(gh,{"aria-hidden":"true",className:"size-3"})})]}),E.jsx("span",{"data-testid":`${n}-count`,role:"status",className:"rounded-full bg-muted px-2 py-0.5 text-[11px] font-medium tabular-nums text-muted-foreground",children:Ge?`${Ce.length.toLocaleString()} of ${at.toLocaleString()}`:`${at.toLocaleString()} rows`}),V&&dt>0&&E.jsxs("button",{type:"button","data-testid":"input-table-column-types-reset",onClick:()=>N({}),title:"Reset all pinned column types to Auto",className:Xl,children:[`${dt} ${dt===1?"column type":"column types"} pinned`,E.jsx(gh,{"aria-hidden":"true",className:"size-3 text-muted-foreground"})]}),Rt&&E.jsxs("span",{className:"flex flex-wrap items-center gap-1.5",children:[E.jsx("span",{"data-testid":`${n}-selected-count`,className:"text-[11px] font-medium tabular-nums text-muted-foreground",children:rt.length>0?`${rt.length.toLocaleString()} selected`:_e>0?`${_e.toLocaleString()} ${_e===1?"column":"columns"} selected`:`${((Lt==null?void 0:Lt.cellCount)??0).toLocaleString()} cells selected`}),Lt!==null&&E.jsx("span",{"data-testid":`${n}-selection-stats`,className:"rounded-md bg-muted px-2 py-0.5 font-mono text-[11px] font-medium tabular-nums text-muted-foreground",children:D9(Lt)}),E.jsxs("button",{type:"button","data-testid":`${n}-copy`,onClick:Hn,className:Xl,children:[E.jsx(Dv,{"aria-hidden":"true",className:"size-3"}),"Copy as CSV"]}),V&&rt.length>0&&E.jsxs("button",{type:"button","data-testid":`${n}-delete-rows`,onClick:In,title:`Deletes the ${rt.length} selected ${rt.length===1?"row":"rows"} from the source CSV`,className:Xl,children:[E.jsx(ph,{"aria-hidden":"true",className:"size-3"}),"Delete ",rt.length.toLocaleString()," ",rt.length===1?"row":"rows"]}),V&&_e>0&&E.jsxs(E.Fragment,{children:[E.jsx("span",{role:"group","aria-label":"Column type override","data-testid":"input-table-column-type-group",className:"inline-flex items-center gap-0.5 rounded-md border border-border bg-muted/60 p-0.5",children:N9.map(({mode:z,label:ue})=>{const q=tt===z;return E.jsx("button",{type:"button","data-testid":`input-table-column-type-${z}`,"aria-pressed":q,onClick:()=>Kt(z),className:q?"cursor-pointer rounded bg-background px-1.5 py-0.5 text-[11px] font-medium text-foreground shadow-2xs outline-none focus-visible:ring-3 focus-visible:ring-ring/50":"cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:ue},z)})}),E.jsxs("button",{type:"button","data-testid":`${n}-delete-columns`,onClick:Pr,disabled:vn,title:vn?"At least one column must remain — the converter needs a column to detect":`Deletes the ${_e} selected ${_e===1?"column":"columns"} from the source CSV`,className:`${Xl} disabled:cursor-not-allowed disabled:opacity-50`,children:[E.jsx(ph,{"aria-hidden":"true",className:"size-3"}),"Delete ",_e.toLocaleString()," ",_e===1?"column":"columns"]})]}),E.jsx("button",{type:"button","data-testid":`${n}-clear-selection`,onClick:$e,className:Xl,children:"Clear"})]})]}),E.jsxs("div",{ref:f,"data-testid":n,role:"grid",tabIndex:-1,"aria-rowcount":Ce.length+1,className:"relative min-h-0 flex-1 outline-none",style:{minHeight:Ut},children:[E.jsx("div",{className:"absolute inset-0",children:E.jsx(R6,{imageWindowLoader:B.current,renderers:f9,columns:ne,rows:Ce.length,getCellContent:ct,getCellsForSelection:xt,onCellsEdited:V?Bt:void 0,onDelete:V?Ir:void 0,onCellClicked:dn,onHeaderClicked:xe,onGridSelectionChange:At,onSelectionCleared:wt,gridSelection:O,rangeSelect:"multi-rect",columnSelect:"multi",rowSelect:"multi",rowHeight:Jb,headerHeight:lm,freezeColumns:zn,fillHandle:V,onPaste:V?()=>!0:!1,keybindings:{search:!1},theme:L,drawHeader:Le,drawCell:ze,getRowThemeOverride:An,minColumnWidth:Qb,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),b!==null&&E.jsx("input",{ref:M,type:"text","data-testid":"csv-header-rename-input","aria-label":`Rename column ${le.headers[b.col]??""}`,value:T,onChange:z=>A(z.target.value),onBlur:Je,onKeyDown:z=>{z.key==="Enter"?(z.preventDefault(),z.stopPropagation(),Je()):z.key==="Escape"&&(z.preventDefault(),z.stopPropagation(),nt())},style:{left:b.bounds.x,top:b.bounds.y,width:Math.max(60,b.bounds.width),height:b.bounds.height},className:"absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50"}),Ge&&Ce.length===0&&E.jsxs("div",{"data-testid":`${n}-empty-filter`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:[E.jsxs("span",{children:["No rows matching “",m,"”."]}),E.jsx("button",{type:"button",onClick:Pe,className:Xl,children:"Show all rows"})]}),V&&!Ge&&Ce.length===0&&E.jsx("div",{"data-testid":`${n}-empty-rows`,className:"absolute inset-x-0 top-0 z-10 flex flex-col items-center gap-2 p-6 text-sm text-muted-foreground",children:E.jsx("span",{children:"No rows. Paste or upload data to start over."})})]})]})}function F9(t,e){if(e===""||t==="")return null;const n=e.toLowerCase();if(!t.toLowerCase().includes(n))return null;const r=[],i=t.toLowerCase();let s=0;for(;;){const o=i.indexOf(n,s);if(o===-1)break;o>s&&r.push({text:t.slice(s,o),hit:!1}),r.push({text:t.slice(o,o+n.length),hit:!0}),s=o+n.length}return s"u"?void 0:navigator),s=v.useRef(null);v.useEffect(()=>{var l;(l=s.current)==null||l.focus()},[]);const o=t==="CSV";return E.jsx("div",{"data-testid":"dropzone",className:"flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16",children:E.jsxs("div",{className:"flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3",children:[E.jsx("div",{"aria-hidden":"true",className:"flex size-9 items-center justify-center rounded-xl border border-border bg-muted/50 text-muted-foreground md:size-11",children:E.jsx(GI,{className:"size-4 md:size-5"})}),E.jsxs("p",{className:"text-sm font-medium text-foreground",children:["Paste ",o?"CSV or TSV":"JSON"," here"]}),E.jsx("textarea",{ref:s,"data-testid":"paste-field",rows:1,"aria-label":`Paste ${o?"CSV or TSV":"JSON"} data — or press ${i} to paste anywhere on this page`,placeholder:o?"Paste CSV or TSV text here":"Paste JSON here",spellCheck:!1,onChange:l=>{const a=l.currentTarget;a.rows=j9(a.value),e(a.value)},className:"min-h-11 w-full resize-none rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400"}),E.jsxs("p",{className:"text-center text-[13px] leading-relaxed text-muted-foreground",children:["or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (",E.jsx("kbd",{"data-testid":"paste-shortcut",className:"rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-[11px] font-medium text-foreground",children:i}),")"]}),E.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[E.jsxs("button",{type:"button","data-testid":"choose-file",onClick:n,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg border border-border bg-background px-3 text-[13px] font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(pT,{"aria-hidden":"true"}),"Choose file"]}),E.jsxs("button",{type:"button","data-testid":"try-example",onClick:r,className:"inline-flex h-8 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-lg px-3 text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-3 focus-visible:ring-ring/50 [&_svg]:size-3.5",children:[E.jsx(cN,{"aria-hidden":"true"}),"Try an example"]})]})]})})}let K0=[],jE=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=jE[r])e=r+1;else return!0;if(e==n)return!1}}function rk(t){return t>=127462&&t<=127487}const ik=8205;function V9(t,e,n=!0,r=!0){return(n?HE:U9)(t,e,r)}function HE(t,e,n){if(e==t.length)return e;e&&WE(t.charCodeAt(e))&&VE(t.charCodeAt(e-1))&&e--;let r=um(t,e);for(e+=sk(r);e=0&&rk(um(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function U9(t,e,n){for(;e>1;){let r=HE(t,e-2,n);if(r=56320&&t<57344}function VE(t){return t>=55296&&t<56320}function sk(t){return t<65536?1:2}class Dt{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Fa(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),ts.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Fa(this,e,n);let r=[];return this.decompose(e,n,r,0),ts.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new sc(this),s=new sc(e);for(let o=n,l=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(l+=i.value.length,i.done||l>=r)return!0}}iter(e=1){return new sc(this,e)}iterRange(e,n=this.length){return new UE(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new KE(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?Dt.empty:e.length<=32?new Sn(e):ts.from(Sn.split(e,[]))}}class Sn extends Dt{constructor(e,n=K9(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],l=i+o.length;if((n?r:l)>=e)return new X9(i,l,r,o);i=l+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Sn(ok(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),l=Fd(s.text,o.text.slice(),0,s.length);if(l.length<=32)r.push(new Sn(l,o.length+s.length));else{let a=l.length>>1;r.push(new Sn(l.slice(0,a)),new Sn(l.slice(a)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Sn))return super.replace(e,n,r);[e,n]=Fa(this,e,n);let i=Fd(this.text,Fd(r.text,ok(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Sn(i,s):ts.from(Sn.split(i,[]),s)}sliceString(e,n=this.length,r=` -`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;s<=n&&oe&&o&&(i+=r),es&&(i+=l.slice(Math.max(0,e-s),n-s)),s=a+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Sn(r,i)),r=[],i=-1);return i>-1&&n.push(new Sn(r,i)),n}}class ts extends Dt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],l=i+o.length,a=r+o.lines-1;if((n?a:l)>=e)return o.lineInner(e,n,r,i);i=l+1,r=a+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s=o){let u=i&((o<=e?1:0)|(a>=n?2:0));o>=e&&a<=n&&!u?r.push(l):l.decompose(e-o,n-o,r,u)}o=a+1}}replace(e,n,r){if([e,n]=Fa(this,e,n),r.lines=s&&n<=l){let a=o.replace(e-s,n-s,r),u=this.lines-o.lines+a.lines;if(a.lines>4&&a.lines>u>>6){let c=this.children.slice();return c[i]=a,new ts(c,this.length-(n-e)+r.length)}return super.replace(s,l,a)}s=l+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=Fa(this,e,n);let i="";for(let s=0,o=0;se&&s&&(i+=r),eo&&(i+=l.sliceString(e-o,n-o,r)),o=a+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof ts))return 0;let r=0,[i,s,o,l]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==l)return r;let a=this.children[i],u=e.children[s];if(a!=u)return r+a.scanIdentical(u,n);r+=a.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let h of e)r+=h.lines;if(r<32){let h=[];for(let p of e)p.flatten(h);return new Sn(h,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,l=[],a=0,u=-1,c=[];function f(h){let p;if(h.lines>s&&h instanceof ts)for(let m of h.children)f(m);else h.lines>o&&(a>o||!a)?(d(),l.push(h)):h instanceof Sn&&a&&(p=c[c.length-1])instanceof Sn&&h.lines+p.lines<=32?(a+=h.lines,u+=h.length+1,c[c.length-1]=new Sn(p.text.concat(h.text),p.length+1+h.length)):(a+h.lines>i&&d(),a+=h.lines,u+=h.length+1,c.push(h))}function d(){a!=0&&(l.push(c.length==1?c[0]:ts.from(c,u)),u=-1,a=c.length=0)}for(let h of e)f(h);return d(),l.length==1?l[0]:new ts(l,n)}}Dt.empty=new Sn([""],0);function K9(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Fd(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s=n&&(a>r&&(l=l.slice(0,r-i)),i0?1:(e instanceof Sn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,l=i instanceof Sn?i.text.length:i.children.length;if(o==(n>0?l:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(i instanceof Sn){let a=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,a.length>Math.max(0,e))return this.value=e==0?a:n>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=i.children[o+(n<0?-1:0)];e>a.length?(e-=a.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(a),this.offsets.push(n>0?1:(a instanceof Sn?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class UE{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new sc(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class KE{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Dt.prototype[Symbol.iterator]=function(){return this.iter()},sc.prototype[Symbol.iterator]=UE.prototype[Symbol.iterator]=KE.prototype[Symbol.iterator]=function(){return this});class X9{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Fa(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function sr(t,e,n=!0,r=!0){return V9(t,e,n,r)}function G9(t){return t>=56320&&t<57344}function q9(t){return t>=55296&&t<56320}function Y9(t,e){let n=t.charCodeAt(e);if(!q9(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return G9(r)?(n-55296<<10)+(r-56320)+65536:n}function J9(t){return t<65536?1:2}const X0=/\r\n?|\n/;var Sr=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Sr||(Sr={}));class ds{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return s+(e-i);s+=l}else{if(r!=Sr.Simple&&u>=e&&(r==Sr.TrackDel&&ie||r==Sr.TrackBefore&&ie))return null;if(u>e||u==e&&n<0&&!l)return e==i||n<0?s:s+a;s+=a}i=u}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r=0&&i<=n&&l>=e)return in?"cover":!0;i=l}return!1}toString(){let e="";for(let n=0;n=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new ds(e)}static create(e){return new ds(e)}}class _n extends ds{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return G0(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return q0(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i=0){n[i]=l,n[i+1]=o;let a=i>>1;for(;r.length0&&go(r,n,s.text),s.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,l=null;function a(c=!1){if(!c&&!i.length)return;od||f<0||d>n)throw new RangeError(`Invalid change range ${f} to ${d} (in doc of length ${n})`);let p=h?typeof h=="string"?Dt.of(h.split(r||X0)):h:Dt.empty,m=p.length;if(f==d&&m==0)return;fo&&rr(i,f-o,-1),rr(i,d-f,m),go(s,i,p),o=d}}return u(e),a(!l),l}static empty(e){return new _n(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;il&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function go(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)l=t.sections[o++],a=t.sections[o++];e(i,u,s,c,f),i=u,s=c}}}function q0(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Ic(t),l=new Ic(e);for(let a=-1;;){if(o.done&&l.len||l.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);rr(i,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||r.length>u),s.forward2(a),o.forward(a)}}}}class Ic{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?Dt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Dt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class uo{constructor(e,n,r,i){this.from=e,this.to=n,this.flags=r,this.goalColumn=i}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new uo(r,i,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return he.range(e,n,void 0,void 0,r);let i=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return he.range(this.anchor,i,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return he.range(e.anchor,e.head)}static create(e,n,r,i){return new uo(e,n,r,i)}}class he{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:he.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new he(e.ranges.map(n=>uo.fromJSON(n)),e.main)}static single(e,n=e){return new he([he.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;ii.from-s.from),n=e.indexOf(r);for(let i=1;is.head?he.range(a,l):he.range(l,a))}}return new he(e,n)}}function GE(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let aw=0;class je{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=aw++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new je(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:uw),!!e.static,e.enables)}of(e){return new $d([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new $d(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new $d(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function uw(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class $d{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=aw++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((n=e[f.id])!==null&&n!==void 0?n:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=r(f),1},update(f,d){if(a&&d.docChanged||u&&(d.docChanged||d.selection)||Y0(f,c)){let h=r(f);if(l?!lk(h,f.values[o],i):!i(h,f.values[o]))return f.values[o]=h,1}return 0},reconfigure:(f,d)=>{let h,p=d.config.address[s];if(p!=null){let m=Ph(d,p);if(this.dependencies.every(x=>x instanceof je?d.facet(x)===f.facet(x):x instanceof ms?d.field(x,!1)==f.field(x,!1):!0)||(l?lk(h=r(f),m,i):i(h=r(f),m)))return f.values[o]=m,0}else h=r(f);return f.values[o]=h,1}}}get extension(){return this}}function lk(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[a.id]),i=n.map(a=>a.type),s=r.filter(a=>!(a&1)),o=t[e.id]>>1;function l(a){let u=[];for(let c=0;cr===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(td).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(td),o=i.facet(td),l;return(l=s.find(a=>a.field==this))&&l!=o.find(a=>a.field==this)?(r.values[n]=l.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,td.of({field:this,create:e})]}get extension(){return this}}const rl={lowest:4,low:3,default:2,high:1,highest:0};function Ou(t){return e=>new qE(e,t)}const cw={highest:Ou(rl.highest),high:Ou(rl.high),default:Ou(rl.default),low:Ou(rl.low),lowest:Ou(rl.lowest)};class qE{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class dl{of(e){return new J0(this,e)}reconfigure(e){return dl.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class J0{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Oh{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let d of Z9(e,n,o))d instanceof ms?i.push(d):(s[d.facet.id]||(s[d.facet.id]=[])).push(d);let l=Object.create(null),a=[],u=[];for(let d of i)l[d.id]=u.length<<1,u.push(h=>d.slot(h));let c=r==null?void 0:r.config.facets;for(let d in s){let h=s[d],p=h[0].facet,m=c&&c[d]||[];if(h.every(x=>x.type==0))if(l[p.id]=a.length<<1|1,uw(m,h))a.push(r.facet(p));else{let x=p.combine(h.map(g=>g.value));a.push(r&&p.compare(x,r.facet(p))?r.facet(p):x)}else{for(let x of h)x.type==0?(l[x.id]=a.length<<1|1,a.push(x.value)):(l[x.id]=u.length<<1,u.push(g=>x.dynamicSlot(g)));l[p.id]=u.length<<1,u.push(x=>Q9(x,p,h))}}let f=u.map(d=>d(l));return new Oh(e,o,f,l,a,s)}}function Z9(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,l){let a=i.get(o);if(a!=null){if(a<=l)return;let u=r[a].indexOf(o);u>-1&&r[a].splice(u,1),o instanceof J0&&n.delete(o.compartment)}if(i.set(o,l),Array.isArray(o))for(let u of o)s(u,l);else if(o instanceof J0){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;n.set(o.compartment,u),s(u,l)}else if(o instanceof qE)s(o.inner,o.prec);else if(o instanceof ms)r[l].push(o),o.provides&&s(o.provides,l);else if(o instanceof $d)r[l].push(o),o.facet.extensions&&s(o.facet.extensions,rl.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}).`);if(u==o)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(u,l)}}return s(t,rl.default),r.reduce((o,l)=>o.concat(l))}function oc(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function Ph(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const YE=je.define(),Q0=je.define({combine:t=>t.some(e=>e),static:!0}),JE=je.define({combine:t=>t.length?t[0]:void 0,static:!0}),QE=je.define(),ZE=je.define(),eA=je.define(),tA=je.define({combine:t=>t.length?t[0]:!1});class Fo{constructor(e,n){this.type=e,this.value=n}static define(){return new eV}}class eV{of(e){return new Fo(this,e)}}class tV{constructor(e){this.map=e}of(e){return new qt(this,e)}}class qt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new qt(this.type,n)}is(e){return this.type==e}static define(e={}){return new tV(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}qt.reconfigure=qt.define();qt.appendConfig=qt.define();class $n{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&GE(r,n.newLength),s.some(l=>l.type==$n.time)||(this.annotations=s.concat($n.time.of(Date.now())))}static create(e,n,r,i,s,o){return new $n(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation($n.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}$n.time=Fo.define();$n.userEvent=Fo.define();$n.addToHistory=Fo.define();$n.remote=Fo.define();function nV(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r=t[r]))s=t[r++],o=t[r++];else if(i=0;i--){let s=r[i](t);s instanceof $n?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof $n?t=s[0]:t=rA(e,Sa(s),!1)}return t}function iV(t){let e=t.startState,n=e.facet(eA),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=nA(r,Z0(e,s,t.changes.newLength),!0))}return r==t?t:$n.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const sV=[];function Sa(t){return t==null?sV:Array.isArray(t)?t:[t]}var Is=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(Is||(Is={}));const oV=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let ey;try{ey=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function lV(t){if(ey)return ey.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||oV.test(n)))return!0}return!1}function aV(t){return e=>{if(!/\S/.test(e))return Is.Space;if(lV(e))return Is.Word;for(let n=0;n-1)return Is.Word;return Is.Other}}class $t{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let l=0;li.set(u,a)),n=null),i.set(l.value.compartment,l.value.extension)):l.is(qt.reconfigure)?(n=null,r=l.value):l.is(qt.appendConfig)&&(n=null,r=Sa(r).concat(l.value));let s;n?s=e.startState.values.slice():(n=Oh.resolve(r,i,this),s=new $t(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(a,u)=>u.reconfigure(a,this),null).values);let o=e.startState.facet(Q0)?e.newSelection:e.newSelection.asSingle();new $t(n,e.newDoc,o,s,(l,a)=>a.update(l,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:he.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=Sa(r.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return $t.create({doc:e.doc,selection:he.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=Oh.resolve(e.extensions||[],new Map),r=e.doc instanceof Dt?e.doc:Dt.of((e.doc||"").split(n.staticFacet($t.lineSeparator)||X0)),i=e.selection?e.selection instanceof he?e.selection:he.single(e.selection.anchor,e.selection.head):he.single(0);return GE(i,r.length),n.staticFacet(Q0)||(i=i.asSingle()),new $t(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet($t.tabSize)}get lineBreak(){return this.facet($t.lineSeparator)||` -`}get readOnly(){return this.facet(tA)}phrase(e,...n){for(let r of this.facet($t.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,i)=>{if(i=="$")return"$";let s=+(i||1);return!s||s>n.length?r:n[s-1]})),e}languageDataAt(e,n,r=-1){let i=[];for(let s of this.facet(YE))for(let o of s(this,n,r))Object.prototype.hasOwnProperty.call(o,e)&&i.push(o[e]);return i}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return aV(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:i}=this.doc.lineAt(e),s=this.charCategorizer(e),o=e-r,l=e-r;for(;o>0;){let a=sr(n,o,!1);if(s(n.slice(a,o))!=Is.Word)break;o=a}for(;lt.length?t[0]:4});$t.lineSeparator=JE;$t.readOnly=tA;$t.phrases=je.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(i=>t[i]==e[i])}});$t.languageData=YE;$t.changeFilter=QE;$t.transactionFilter=ZE;$t.transactionExtender=eA;dl.reconfigure=qt.define();function iA(t,e,n={}){let r={};for(let i of t)for(let s of Object.keys(i)){let o=i[s],l=r[s];if(l===void 0)r[s]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(n,s))r[s]=n[s](l,o);else throw new Error("Config merge conflict for field "+s)}for(let i in e)r[i]===void 0&&(r[i]=e[i]);return r}class xl{eq(e){return this==e}range(e,n=e){return ty.create(e,n,this)}}xl.prototype.startSide=xl.prototype.endSide=0;xl.prototype.point=!1;xl.prototype.mapMode=Sr.TrackDel;function fw(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let ty=class sA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new sA(e,n,r)}};function ny(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class dw{constructor(e,n,r,i){this.from=e,this.to=n,this.value=r,this.maxPoint=i}get length(){return this.to[this.to.length-1]}findIndex(e,n,r,i=0){let s=r?this.to:this.from;for(let o=i,l=s.length;;){if(o==l)return o;let a=o+l>>1,u=s[a]-e||(r?this.value[a].endSide:this.value[a].startSide)-n;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,n,r,i){for(let s=this.findIndex(n,-1e9,!0),o=this.findIndex(r,1e9,!1,s);sh||d==h&&u.startSide>0&&u.endSide<=0)continue;(h-d||u.endSide-u.startSide)<0||(o<0&&(o=d),u.point&&(l=Math.max(l,h-d)),r.push(u),i.push(d-o),s.push(h-o))}return{mapped:r.length?new dw(i,s,r,l):null,pos:o}}}class Ht{constructor(e,n,r,i){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=i}static create(e,n,r,i){return new Ht(e,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:s=this.length}=e,o=e.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(ny)),this.isEmpty)return n.length?Ht.of(n):this;let l=new oA(this,null,-1).goto(0),a=0,u=[],c=new $a;for(;l.value||a=0){let f=n[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||sl.to||s=s&&e<=s+o.length&&o.between(s,e-s,n-s,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return Nc.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return Nc.from(e).goto(n)}static compare(e,n,r,i,s=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),l=n.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=s),a=ak(o,l,r),u=new Pu(o,a,s),c=new Pu(l,a,s);r.iterGaps((f,d,h)=>uk(u,f,c,d,h,i)),r.empty&&r.length==0&&uk(u,0,c,0,0,i)}static eq(e,n,r=0,i){i==null&&(i=999999999);let s=e.filter(c=>!c.isEmpty&&n.indexOf(c)<0),o=n.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(s.length!=o.length)return!1;if(!s.length)return!0;let l=ak(s,o),a=new Pu(s,l,0).goto(r),u=new Pu(o,l,0).goto(r);for(;;){if(a.to!=u.to||!ry(a.active,u.active)||a.point&&(!u.point||!fw(a.point,u.point)))return!1;if(a.to>i)return!0;a.next(),u.next()}}static spans(e,n,r,i,s=-1){let o=new Pu(e,null,s).goto(n),l=n,a=o.openStart;for(;;){let u=Math.min(o.to,r);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(i.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>r)return a+(o.point&&o.to>r?1:0);l=o.to,o.next()}}static of(e,n=!1){let r=new $a;for(let i of e instanceof ty?[e]:n?uV(e):e)r.add(i.from,i.to,i.value);return r.finish()}static join(e){if(!e.length)return Ht.empty;let n=e[e.length-1];for(let r=e.length-2;r>=0;r--)for(let i=e[r];i!=Ht.empty;i=i.nextLayer)n=new Ht(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}}Ht.empty=new Ht([],[],null,-1);function uV(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(ny);e=r}return t}Ht.empty.nextLayer=Ht.empty;class $a{finishChunk(e){this.chunks.push(new dw(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,n,r){this.addInner(e,n,r)||(this.nextLayer||(this.nextLayer=new $a)).add(e,n,r)}addInner(e,n,r){let i=e-this.lastTo||r.startSide-this.last.endSide;if(i<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(Ht.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=Ht.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function ak(t,e,n){let r=new Map;for(let s of t)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&i.push(new oA(o,n,r,s));return i.length==1?i[0]:new Nc(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)cm(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)cm(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),cm(this.heap,0)}}}function cm(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let i=t[r];if(r+1=0&&(i=t[r+1],r++),n.compare(i)<0)break;t[r]=n,t[e]=i,e=r}}class Pu{constructor(e,n,r){this.minPoint=r,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Nc.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){nd(this.active,e),nd(this.activeTo,e),nd(this.activeRank,e),this.minActive=ck(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:i,rank:s}=this.cursor;for(;n0;)n++;rd(this.active,n,r),rd(this.activeTo,n,i),rd(this.activeRank,n,s),e&&rd(e,n,this.cursor.from),this.minActive=ck(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)<0){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),r&&nd(r,i)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let s=this.cursor.value;if(!s.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[i]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function uk(t,e,n,r,i,s){t.goto(e),n.goto(r);let o=r+i,l=r,a=r-e,u=!!s.boundChange;for(let c=!1;;){let f=t.to+a-n.to,d=f||t.endSide-n.endSide,h=d<0?t.to+a:n.to,p=Math.min(h,o);if(t.point||n.point?(t.point&&n.point&&fw(t.point,n.point)&&ry(t.activeForPoint(t.to),n.activeForPoint(n.to))||s.comparePoint(l,p,t.point,n.point),c=!1):(c&&s.boundChange(l),p>l&&!ry(t.active,n.active)&&s.compareRange(l,p,t.active,n.active),u&&po)break;l=h,d<=0&&t.next(),d>=0&&n.next()}}function ry(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function ck(t,e){let n=-1,r=1e9;for(let i=0;i=e)return i;if(i==t.length)break;s+=t.charCodeAt(i)==9?n-s%n:1,i=sr(t,i)}return t.length}const iy="ͼ",fk=typeof Symbol>"u"?"__"+iy:Symbol.for(iy),sy=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),dk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Ro{constructor(e,n){this.rules=[];let{finish:r}=n||{};function i(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function s(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),d=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let h in l){let p=l[h];if(/&/.test(h))s(h.split(/,\s*/).map(m=>o.map(x=>m.replace(/&/,x))).reduce((m,x)=>m.concat(x)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+h+") should be a primitive value.");s(i(h),p,c,d)}else p!=null&&c.push(h.replace(/_.*/,"").replace(/[A-Z]/g,m=>"-"+m.toLowerCase())+": "+p+";")}(c.length||d)&&a.push((r&&!f&&!u?o.map(r):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)s(i(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=dk[fk]||1;return dk[fk]=e+1,iy+e.toString(36)}static mount(e,n,r){let i=e[sy],s=r&&r.nonce;i?s&&i.setNonce(s):i=new fV(e,s),i.mount(Array.isArray(n)?n:[n],e)}}let hk=new Map;class fV{constructor(e,n){let r=e.ownerDocument||e,i=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=hk.get(r);if(s)return e[sy]=s;this.sheet=new i.CSSStyleSheet,hk.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[sy]=this}mount(e,n){let r=this.sheet,i=0,s=0;for(let o=0;o-1&&(this.modules.splice(a,1),s--,a=-1),a==-1){if(this.modules.splice(s++,0,l),r)for(let u=0;u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},dV=typeof navigator<"u"&&/Mac/.test(navigator.platform),hV=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Kn=0;Kn<10;Kn++)Oo[48+Kn]=Oo[96+Kn]=String(Kn);for(var Kn=1;Kn<=24;Kn++)Oo[Kn+111]="F"+Kn;for(var Kn=65;Kn<=90;Kn++)Oo[Kn]=String.fromCharCode(Kn+32),Dc[Kn]=String.fromCharCode(Kn);for(var fm in Oo)Dc.hasOwnProperty(fm)||(Dc[fm]=Oo[fm]);function pV(t){var e=dV&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||hV&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Dc:Oo)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}function ns(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,n=arguments[1];if(n&&typeof n=="object"&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i=="string"?t.setAttribute(r,i):i!=null&&(t[r]=i)}e++}for(;e2);var Me={mac:mk||/Mac/.test(dr.platform),windows:/Win/.test(dr.platform),linux:/Linux|X11/.test(dr.platform),ie:Op,ie_version:aA?oy.documentMode||6:ay?+ay[1]:ly?+ly[1]:0,gecko:pk,gecko_version:pk?+(/Firefox\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,chrome:!!dm,chrome_version:dm?+dm[1]:0,ios:mk,android:/Android\b/.test(dr.userAgent),webkit:gk,webkit_version:gk?+(/\bAppleWebKit\/(\d+)/.exec(dr.userAgent)||[0,0])[1]:0,safari:uy,safari_version:uy?+(/\bVersion\/(\d+(\.\d+)?)/.exec(dr.userAgent)||[0,0])[1]:0,tabSize:oy.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function hw(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const Ih=Object.create(null);function pw(t,e,n){if(t==e)return!0;t||(t=Ih),e||(e=Ih);let r=Object.keys(t),i=Object.keys(e);if(r.length-0!=i.length-0)return!1;for(let s of r)if(s!=n&&(i.indexOf(s)==-1||t[s]!==e[s]))return!1;return!0}function gV(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function yk(t,e,n){let r=!1;if(e)for(let i in e)n&&i in n||(r=!0,i=="style"?t.style.cssText="":t.removeAttribute(i));if(n)for(let i in n)e&&e[i]==n[i]||(r=!0,i=="style"?t.style.cssText=n[i]:t.setAttribute(i,n[i]));return r}function mV(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new bl(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,i;if(e.isBlockGap)r=-5e8,i=4e8;else{let{start:s,end:o}=uA(e,n);r=(s?n?-3e8:-1:5e8)-1,i=(o?n?2e8:1:-6e8)+1}return new bl(e,r,i,n,e.widget||null,!0)}static line(e){return new sf(e)}static set(e,n=!1){return Ht.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}Vt.none=Ht.empty;class rf extends Vt{constructor(e){let{start:n,end:r}=uA(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?hw(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||Ih}eq(e){return this==e||e instanceof rf&&this.tagName==e.tagName&&pw(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}rf.prototype.point=!1;class sf extends Vt{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof sf&&this.spec.class==e.spec.class&&pw(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}sf.prototype.mapMode=Sr.TrackBefore;sf.prototype.point=!0;class bl extends Vt{constructor(e,n,r,i,s,o){super(n,r,s,e),this.block=i,this.isReplace=o,this.mapMode=i?n<=0?Sr.TrackBefore:Sr.TrackAfter:Sr.TrackDel}get type(){return this.startSide!=this.endSide?fi.WidgetRange:this.startSide<=0?fi.WidgetBefore:fi.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof bl&&yV(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}bl.prototype.point=!0;function uA(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function yV(t,e){return t==e||!!(t&&e&&t.compare(e))}function Ca(t,e,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=t?n[i]=Math.max(n[i],e):n.push(t,e)}class _c extends xl{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof _c&&this.tagName==e.tagName&&pw(this.attributes,e.attributes)}static create(e){return new _c(e.tagName,e.attributes||Ih,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return Ht.of(e,n)}}_c.prototype.startSide=_c.prototype.endSide=-1;function Lc(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function cy(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function lc(t,e){if(!e.anchorNode)return!1;try{return cy(t,e.anchorNode)}catch{return!1}}function ac(t){return t.nodeType==3?$c(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function uc(t,e,n,r){return n?vk(t,e,n,r,-1)||vk(t,e,n,r,1):!1}function Po(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function Nh(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function vk(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:zs(t))){if(t.nodeName=="DIV")return!1;let s=t.parentNode;if(!s||s.nodeType!=1)return!1;e=Po(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=i<0?zs(t):0}else return!1}}function zs(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Fc(t,e){let{left:n,right:r}=t;if(n==r)return t;let i=e?n:r;return{left:i,right:i,top:t.top,bottom:t.bottom}}function vV(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function cA(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function wV(t,e,n,r,i,s,o,l){let a=t.ownerDocument,u=a.defaultView||window;for(let c=t,f=!1;c&&!f;)if(c.nodeType==1){let d,h=c==a.body,p=1,m=1;if(h)d=vV(u);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(f=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let y=c.getBoundingClientRect();({scaleX:p,scaleY:m}=cA(c,y)),d={left:y.left,right:y.left+c.clientWidth*p,top:y.top,bottom:y.top+c.clientHeight*m}}let x=0,g=0;if(i=="nearest")e.top0&&e.bottom>d.bottom+g&&(g=e.bottom-d.bottom+o)):e.bottom>d.bottom-o&&(g=e.bottom-d.bottom+o,n<0&&e.top-g0&&e.right>d.right+x&&(x=e.right-d.right+s)):e.right>d.right-s&&(x=e.right-d.right+s,n<0&&e.leftd.bottom||e.leftd.right)&&(e={left:Math.max(e.left,d.left),right:Math.min(e.right,d.right),top:Math.max(e.top,d.top),bottom:Math.min(e.bottom,d.bottom)}),c=c.assignedSlot||c.parentNode}else if(c.nodeType==11)c=c.host;else break}function fA(t,e=!0){let n=t.ownerDocument,r=null,i=null;for(let s=t.parentNode;s&&!(s==n.body||(!e||r)&&i);)if(s.nodeType==1)!i&&s.scrollHeight>s.clientHeight&&(i=s),e&&!r&&s.scrollWidth>s.clientWidth&&(r=s),s=s.assignedSlot||s.parentNode;else if(s.nodeType==11)s=s.host;else break;return{x:r,y:i}}class xV{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?zs(n):0),r,Math.min(e.focusOffset,r?zs(r):0))}set(e,n,r,i){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=i}}function dA(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function hA(t,e=!0){for(let{node:n,left:r,top:i}of t)e&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}let el=null;Me.safari&&Me.safari_version>=26&&(el=!1);function pA(t){if(t.setActive)return t.setActive();if(el)return t.focus(el);let e=dA(t);t.focus(el==null?{get preventScroll(){return el={preventScroll:!0},!0}}:void 0),el||(el=!1,hA(e))}let wk;function $c(t,e,n=e){let r=wk||(wk=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function Ta(t,e,n,r){let i={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let s=new KeyboardEvent("keydown",i);s.synthetic=!0,t.dispatchEvent(s);let o=new KeyboardEvent("keyup",i);return o.synthetic=!0,t.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function bV(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function kV(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,zs(n));;)if(r){if(n.nodeType!=1)return!1;let i=n.childNodes[r-1];i.contentEditable=="false"?r--:(n=i,r=zs(n))}else{if(n==t)return!0;r=Po(n),n=n.parentNode}}function gA(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function mA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=zs(n)}else if(n.parentNode&&!Nh(n))r=Po(n),n=n.parentNode;else return null}}function yA(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(l.level==r)return o;(s<0||(i!=0?i<0?l.fromn:e[s].level>l.level))&&(s=o)}}if(s<0)throw new RangeError("Index out of range");return s}}function xA(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;m-=3)if(qi[m+1]==-h){let x=qi[m+2],g=x&2?i:x&4?x&1?s:i:0;g&&(Gt[f]=Gt[qi[m]]=g),l=m;break}}else{if(qi.length==189)break;qi[l++]=f,qi[l++]=d,qi[l++]=a}else if((p=Gt[f])==2||p==1){let m=p==i;a=m?0:1;for(let x=l-3;x>=0;x-=3){let g=qi[x+2];if(g&2)break;if(m)qi[x+2]|=2;else{if(g&4)break;qi[x+2]|=4}}}}}function MV(t,e,n,r){for(let i=0,s=r;i<=n.length;i++){let o=i?n[i-1].to:t,l=ia;)p==x&&(p=n[--m].from,x=m?n[m-1].to:t),Gt[--p]=h;a=c}else s=u,a++}}}function dy(t,e,n,r,i,s,o){let l=r%2?2:1;if(r%2==i%2)for(let a=e,u=0;aa&&o.push(new os(a,m.from,h));let x=m.direction==kl!=!(h%2);hy(t,x?r+1:r,i,m.inner,m.from,m.to,o),a=m.to}p=m.to}else{if(p==n||(c?Gt[p]!=l:Gt[p]==l))break;p++}d?dy(t,a,p,r+1,i,d,o):ae;){let c=!0,f=!1;if(!u||a>s[u-1].to){let m=Gt[a-1];m!=l&&(c=!1,f=m==16)}let d=!c&&l==1?[]:null,h=c?r:r+1,p=a;e:for(;;)if(u&&p==s[u-1].to){if(f)break e;let m=s[--u];if(!c)for(let x=m.from,g=u;;){if(x==e)break e;if(g&&s[g-1].to==x)x=s[--g].from;else{if(Gt[x-1]==l)break e;break}}if(d)d.push(m);else{m.toGt.length;)Gt[Gt.length]=256;let r=[],i=e==kl?0:1;return hy(t,i,i,n,0,t.length,r),r}function bA(t){return[new os(0,t,0)]}let kA="";function OV(t,e,n,r,i){var s;let o=r.head-t.from,l=os.find(e,o,(s=r.bidiLevel)!==null&&s!==void 0?s:-1,r.assoc),a=e[l],u=a.side(i,n);if(o==u){let d=l+=i?1:-1;if(d<0||d>=e.length)return null;a=e[l=d],o=a.side(!i,n),u=a.side(i,n)}let c=sr(t.text,o,a.forward(i,n));(ca.to)&&(c=u),kA=t.text.slice(Math.min(o,c),Math.max(o,c));let f=l==(i?e.length-1:0)?null:e[l+(i?1:-1)];return f&&c==u&&f.level+(i?0:1)t.some(e=>e)}),IV=je.define({combine:t=>t.some(e=>e)}),OA=je.define();class Ea{constructor(e,n,r,i,s,o=!1){this.range=e,this.y=n,this.x=r,this.yMargin=i,this.xMargin=s,this.isSnapshot=o}map(e){return e.empty?this:new Ea(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new Ea(he.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const id=qt.define({map:(t,e)=>t.map(e)}),PA=qt.define();function li(t,e,n){let r=t.facet(EA);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const Rs=je.define({combine:t=>t.length?t[0]:!0});let NV=0;const ha=je.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let a=[];return o&&a.push(Pp.of(u=>{let c=u.plugin(l);return c?o(c):Vt.none})),s&&a.push(s(l)),a})}static fromClass(e,n){return gi.define((r,i)=>new e(r,i),n)}}class hm{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(li(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){li(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){li(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const IA=je.define(),vw=je.define(),Pp=je.define(),NA=je.define(),ww=je.define(),of=je.define(),DA=je.define();function xk(t,e){let n=t.state.facet(DA);if(!n.length)return n;let r=n.map(s=>s instanceof Function?s(t):s),i=[];return Ht.spans(r,e.from,e.to,{point(){},span(s,o,l,a){let u=s-e.from,c=o-e.from,f=i;for(let d=l.length-1;d>=0;d--,a--){let h=l[d].spec.bidiIsolate,p;if(h==null&&(h=PV(e.text,u,c)),a>0&&f.length&&(p=f[f.length-1]).to==u&&p.direction==h)p.to=c,f=p.inner;else{let m={from:u,to:c,direction:h,inner:[]};f.push(m),f=m.inner}}}}),i}const _A=je.define();function xw(t){let e=0,n=0,r=0,i=0;for(let s of t.state.facet(_A)){let o=s(t);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:e,right:n,top:r,bottom:i}}const Hu=je.define();class ai{constructor(e,n,r,i){this.fromA=e,this.toA=n,this.fromB=r,this.toB=i}join(e){return new ai(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let n=e.length,r=this;for(;n>0;n--){let i=e[n-1];if(!(i.fromA>r.toA)){if(i.toAi.push(new ai(s,o,l,a))),this.changedRanges=i}static create(e,n,r){return new Dh(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const DV=[];class yn{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return DV}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&gV(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let i of this.children){if(i==e)return r;r+=i.length+i.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Po(this.dom),i=this.length?e>0:n>0;return new Ni(this.parent.dom,r+(i?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof Np)return e;return null}static get(e){return e.cmTile}}class Ip extends yn{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,i,s=(e==null?void 0:e.node)==n?e:null,o=0;for(let l of this.children){if(l.sync(e),o+=l.length+l.breakAfter,i=r?r.nextSibling:n.firstChild,s&&i!=l.dom&&(s.written=!0),l.dom.parentNode==n)for(;i&&i!=l.dom;)i=bk(i);else n.insertBefore(l.dom,i);r=l.dom}for(i=r?r.nextSibling:n.firstChild,s&&i&&(s.written=!0);i;)i=bk(i);this.length=o}}function bk(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Np extends Ip{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=yn.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,i=0,s=0;;)if(i==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&s++,i=n.pop()}else{let o=r.children[i++];if(o instanceof Ds)n.push(i),r=o,i=0;else{let l=s+o.length,a=e(o,s);if(a!==void 0)return a;s=l+o.breakAfter}}}resolveBlock(e,n){let r,i=-1,s,o=-1;if(this.blockTiles((l,a)=>{let u=a+l.length;if(e>=a&&e<=u){if(l.isWidget()&&n>=-1&&n<=1){if(l.flags&32)return!0;l.flags&16&&(r=void 0)}(ae||e==a&&(n>1?l.length:l.covers(-1)))&&(!s||!l.isWidget()&&s.isWidget())&&(s=l,o=e-a)}}),!r&&!s)throw new Error("No tile at position "+e);return r&&n<0||!s?{tile:r,offset:i}:{tile:s,offset:o}}}class Ds extends Ip{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new Ds(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class za extends Ip{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let i=new za(n||document.createElement("div"),e);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,n,r){let i=null,s=-1,o=null,l=-1;function a(c,f){for(let d=0,h=0;d=f&&(p.isComposite()?a(p,f-h):(!o||o.isHidden&&(n>0&&!(o.flags&32)||r&&LV(o,p)))&&(m>f||p.flags&32&&n<=1)?(o=p,l=f-h):(h=-1)&&(i=p,s=f-h)),h=m}}a(this,e);let u=(n<0?i:o)||i||o;return u?{tile:u,offset:u==i?s:l}:null}coordsIn(e,n,r){let i=this.resolveInline(e,n,!0);return i?i.tile.coordsIn(Math.max(0,i.offset),n,r):_V(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:i,offset:s}=r;if(this.dom.contains(i.dom))return i.isText()?new Ni(i.dom,Math.min(i.dom.nodeValue.length,s)):i.domPosFor(s,i.flags&16?1:i.flags&32?-1:n);let o=r.tile.parent,l=!1;for(let a of o.children){if(l)return new Ni(a.dom,0);a==r.tile&&(l=!0)}}return new Ni(this.dom,0)}}function _V(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=ac(e);return n[n.length-1]||null}function LV(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.topi&&(e=i);let s=e,o=e,l=0;e==0&&n<0||e==i&&n>=0?Me.chrome||Me.gecko||(e?(s--,l=1):o=0)?0:a.length-1];return Me.safari&&!l&&u.width==0&&(u=Array.prototype.find.call(a,c=>c.width)||u),r==null?u:Fc(u,(l?l>0:n<0)==r)}static of(e,n){let r=new al(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Sl extends yn{constructor(e,n,r,i){super(e,n,i),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let i=this.widget.coordsAt(this.dom,e,n);if(i)return i;if(r)return Fc(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let s=this.dom.getClientRects(),o=null;if(!s.length)return null;let l=this.flags&16?!0:this.flags&32?!1:e>0;for(let a=l?s.length-1:0;o=s[a],!(e>0?a==0:a==s.length-1||o.top0==r)}}class FV{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:i,index:s,beforeBreak:o,parents:l}=this;for(;e||n>0;)if(i.isComposite())if(o){if(!e)break;r&&r.break(),e--,o=!1}else if(s==i.children.length){if(!e&&!l.length)break;r&&r.leave(i),o=!!i.breakAfter,{tile:i,index:s}=l.pop(),s++}else{let a=i.children[s],u=a.breakAfter;(n>0?a.length<=e:a.length=0;l--){let a=n.marks[l],u=i.lastChild;if(u instanceof Cr&&u.mark.eq(a.mark))u.dom!=a.dom&&u.setDOM(pm(a.dom)),i=u;else{if(this.cache.reused.get(a)){let f=yn.get(a.dom);f&&f.setDOM(pm(a.dom))}let c=Cr.of(a.mark,a.dom);i.append(c),i=c}this.cache.reused.set(a,2)}let s=yn.get(e.text);s&&this.cache.reused.set(s,2);let o=new al(e.text,e.text.nodeValue);o.flags|=8,this.pos=e.range.toB,i.append(o)}addInlineWidget(e,n,r){let i=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);i||this.flushBuffer();let s=this.ensureMarks(n,r);!i&&!(e.flags&16)&&s.append(this.getBuffer(1)),s.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=LA);let i=za.start(e,n||((r=this.cache.find(za))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=i)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let i=this.curLine;for(let s=e.length-1;s>=0;s--){let o=e[s],l;if(n>0&&(l=i.lastChild)&&l instanceof Cr&&l.mark.eq(o))i=l,n--;else{let a=Cr.of(o,(r=this.cache.find(Cr,u=>u.mark.eq(o)))===null||r===void 0?void 0:r.dom);i.append(a),i=a,n=0}}return i}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!kk(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&kk(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(gm,0,32)||new Sl(gm.toDOM(),0,gm,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new $V(e.from,e.to,e.value,n),i=this.wrappers.length;for(;i>0&&(this.wrappers[i-1].rank-r.rank||this.wrappers[i-1].to-r.to)<0;)i--;this.wrappers.splice(i,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let i=n.lastChild;if(r.fromo.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(s),n=s}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(_h,void 0,1);return r&&(r.flags=n),r||new _h(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class BV{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:i,lineBreak:s,done:o}=this.cursor.next(this.skipCount);if(this.skipCount=0,o)throw new Error("Ran out of text content when drawing inline views");this.text=i;let l=this.textOff=Math.min(e,i.length);return s?null:i.slice(0,l)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const Lh=[Sl,za,al,Cr,_h,Ds,Np];for(let t=0;t[]),this.index=Lh.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let i=e.bucket,s=this.buckets[i],o=this.index[i];for(let l=0;l{if(this.cache.add(o),o.isComposite())return!1},enter:o=>this.cache.add(o),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let i=0,s=0,o=0;;){let l=oi){let u=a-i;this.preserve(u,!o,!l),i=a,s+=u}if(!l)break;n&&l.fromA<=n.range.fromA&&l.toA>=n.range.toA?(this.forward(l.fromA,n.range.fromA,n.range.fromA{if(o.isWidget())if(this.openWidget)this.builder.continueWidget(a-l);else{let u=a>0||l{o.isLine()?this.builder.addLineStart(o.attrs,this.cache.maybeReuse(o)):(this.cache.add(o),o instanceof Cr&&i.unshift(o.mark)),this.openWidget=!1},leave:o=>{o.isLine()?i.length&&(i.length=s=0):o instanceof Cr&&(i.shift(),s=Math.min(s,i.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,i=this.builder,s=-1,o=Ht.spans(this.decorations,e,n,{point:(l,a,u,c,f,d)=>{if(u instanceof bl){if(this.disallowBlockEffectsFor[d]){if(u.block)throw new RangeError("Block decorations may not be specified via plugins");if(a>this.view.state.doc.lineAt(l).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(s=c.length,f>c.length)i.continueWidget(a-l);else{let h=u.widget||(u.block?Ba.block:Ba.inline),p=WV(u),m=this.cache.findWidget(h,a-l,p)||Sl.of(h,this.view,a-l,p);u.block?(u.startSide>0&&i.addLineStartIfNotCovered(r),i.addBlockWidget(m)):(i.ensureLine(r),i.addInlineWidget(m,c,f))}r=null}else r=VV(r,u);a>l&&this.text.skip(a-l)},span:(l,a,u,c)=>{for(let f=l;f-1&&(this.openWidget=o>s),this.openWidget||i.addLineStartIfNotCovered(r),this.openMarks=o}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let i=e.parentNode;;i=i.parentNode){let s=yn.get(i);if(i==this.view.contentDOM)break;s instanceof Cr?n.push(s):s!=null&&s.isLine()?r=s:s instanceof Ds||(i.nodeName=="DIV"&&!r&&i!=this.view.contentDOM?r=new za(i,LA):r||n.push(Cr.of(new rf({tagName:i.nodeName.toLowerCase(),attributes:mV(i)}),i)))}return{line:r,marks:n}}}function kk(t,e){let n=r=>{for(let i of r.children)if((e?i.isText():i.length)||n(i))return!0;return!1};return n(t)}function WV(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const LA={class:"cm-line"};function VV(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&hw(n,t),r&&(t.class+=" "+r)),t}function UV(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Cr&&e.push(r.mark)}return e}function pm(t){let e=yn.get(t);return e&&e.setDOM(t.cloneNode()),t}class Ba extends nu{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}Ba.inline=new Ba("span");Ba.block=new Ba("div");const gm=new class extends nu{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Sk{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=Vt.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new Np(e,e.contentDOM),this.updateInner([new ai(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:c,toA:f})=>fthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let i=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?i=this.domChanged.newSel.head:!eU(e.changes,this.hasComposition)&&!e.selectionSet&&(i=e.state.selection.main.head));let s=i>-1?XV(this.view,e.changes,i):null;if(this.domChanged=null,this.hasComposition){let{from:c,to:f}=this.hasComposition;r=new ai(c,f,e.changes.mapPos(c,-1),e.changes.mapPos(f,1)).addToSet(r.slice())}this.hasComposition=s?{from:s.range.fromB,to:s.range.toB}:null,(Me.ie||Me.chrome)&&!s&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let o=this.decorations,l=this.blockWrappers;this.updateDeco();let a=YV(o,this.decorations,e.changes);a.length&&(r=ai.extendWithRanges(r,a));let u=QV(l,this.blockWrappers,e.changes);return u.length&&(r=ai.extendWithRanges(r,u)),s&&!r.some(c=>c.fromA<=s.range.fromA&&c.toA>=s.range.toA)&&(r=s.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,s),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let o=this.tile,l=new HV(this.view,o,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&yn.get(n.text)&&l.cache.reused.set(yn.get(n.text),2),this.tile=l.run(e,n),gy(o,l.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let s=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(s),s&&(s.written||r.selectionRange.focusNode!=s.node||!this.tile.dom.contains(s.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let i=[];if(this.view.viewport.from||this.view.viewport.to-1)&&lc(r,this.view.observer.selectionRange)&&!(i&&r.contains(i));if(!(s||n||o))return;let l=this.forceSelection;this.forceSelection=!1;let a=this.view.state.selection.main,u,c;if(a.empty?c=u=this.inlineDOMNearPos(a.anchor,a.assoc||1):(c=this.inlineDOMNearPos(a.head,a.head==a.from?1:-1),u=this.inlineDOMNearPos(a.anchor,a.anchor==a.from?1:-1)),Me.gecko&&a.empty&&!this.hasComposition&&KV(u)){let d=document.createTextNode("");this.view.observer.ignore(()=>u.node.insertBefore(d,u.node.childNodes[u.offset]||null)),u=c=new Ni(d,0),l=!0}let f=this.view.observer.selectionRange;(l||!f.focusNode||(!uc(u.node,u.offset,f.anchorNode,f.anchorOffset)||!uc(c.node,c.offset,f.focusNode,f.focusOffset))&&!this.suppressWidgetCursorChange(f,a))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(f.focusNode)&&ZV(f.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let d=Lc(this.view.root);if(d)if(a.empty){if(Me.gecko){let h=GV(u.node,u.offset);if(h&&h!=3){let p=(h==1?mA:yA)(u.node,u.offset);p&&(u=new Ni(p.node,p.offset))}}d.collapse(u.node,u.offset),a.bidiLevel!=null&&d.caretBidiLevel!==void 0&&(d.caretBidiLevel=a.bidiLevel)}else if(d.extend){d.collapse(u.node,u.offset);try{d.extend(c.node,c.offset)}catch{}}else{let h=document.createRange();a.anchor>a.head&&([u,c]=[c,u]),h.setEnd(c.node,c.offset),h.setStart(u.node,u.offset),d.removeAllRanges(),d.addRange(h)}o&&this.view.root.activeElement==r&&(r.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(u,c)),this.impreciseAnchor=u.precise?null:new Ni(f.anchorNode,f.anchorOffset),this.impreciseHead=c.precise?null:new Ni(f.focusNode,f.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&uc(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Lc(e.root),{anchorNode:i,anchorOffset:s}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let o=this.lineAt(n.head,n.assoc);if(!o)return;let l=o.posAtStart;if(n.head==l||n.head==l+o.length)return;let a=this.coordsAt(n.head,-1),u=this.coordsAt(n.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(c.node,c.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=n.from&&r.collapse(i,s)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let i=r.posAtStart;if(r.isComposite()){let s;if(e==r.dom)s=r.dom.childNodes[n];else{let o=zs(e)==0?0:n==0?-1:1;for(;;){let l=e.parentNode;if(l==r.dom)break;o==0&&l.firstChild!=l.lastChild&&(e==l.firstChild?o=-1:o=1),e=l}o<0?s=e:s=e.nextSibling}if(s==r.dom.firstChild)return i;for(;s&&!yn.get(s);)s=s.nextSibling;if(!s)return i+r.length;for(let o=0,l=i;;o++){let a=r.children[o];if(a.dom==s)return l;l+=a.length+a.breakAfter}}else return r.isText()?e==r.dom?i+n:i+(n?r.length:0):i}domAtPos(e,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(i,n):r.domIn(i,n)}inlineDOMNearPos(e,n){let r,i=-1,s=!1,o,l=-1,a=!1;return this.tile.blockTiles((u,c)=>{if(u.isWidget()){if(u.flags&32&&c>=e)return!0;u.flags&16&&(s=!0)}else{let f=c+u.length;if(c<=e&&(r=u,i=e-c,s=f=e&&!o&&(o=u,l=e-c,a=c>e),c>e&&o)return!0}}),!r&&!o?this.domAtPos(e,n):(s&&o?r=null:a&&r&&(o=null),r&&n<0||!o?r.domIn(i,n):o.domIn(l,n))}coordsAt(e,n,r){let{tile:i,offset:s}=this.tile.resolveBlock(e,n);return i.isWidget()?i.widget instanceof mm?null:i.coordsInWidget(s,n,!0):i.coordsIn(s,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function i(s,o){if(s.isComposite())for(let l of s.children){if(l.length>=o){let a=i(l,o);if(a)return a}if(o-=l.length,o<0)break}else if(s.isText()&&oMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==mn.LTR,u=0,c=(f,d,h)=>{for(let p=0;pi);p++){let m=f.children[p],x=d+m.length,g=m.dom.getBoundingClientRect(),{height:y}=g;if(h&&!p&&(u+=g.top-h.top),m instanceof Ds)x>r&&c(m,d,g);else if(d>=r&&(u>0&&n.push(-u),n.push(y+u),u=0,o)){let w=m.dom.lastChild,k=w?ac(w):[];if(k.length){let b=k[k.length-1],S=a?b.right-g.left:g.right-b.left;S>l&&(l=S,this.minWidth=s,this.minWidthFrom=d,this.minWidthTo=x)}}h&&p==f.children.length-1&&(u+=h.bottom-g.bottom),d=x+m.breakAfter}};return c(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?mn.RTL:mn.LTR}measureTextSize(){let e=this.tile.blockTiles(o=>{if(o.isLine()&&o.children.length&&o.length<=20){let l=0,a;for(let u of o.children){if(!u.isText()||/[^ -~]/.test(u.text))return;let c=ac(u.dom);if(c.length!=1)return;l+=c[0].width,a=c[0].height}if(l)return{lineHeight:o.dom.getBoundingClientRect().height,charWidth:l/o.length,textHeight:a}}});if(e)return e;let n=document.createElement("div"),r,i,s;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let o=ac(n.firstChild)[0];r=n.getBoundingClientRect().height,i=o&&o.width?o.width/27:7,s=o&&o.height?o.height:r,n.remove()}),{lineHeight:r,charWidth:i,textHeight:s}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,i=0;;i++){let s=i==n.viewports.length?null:n.viewports[i],o=s?s.from-1:this.view.state.doc.length;if(o>r){let l=(n.lineBlockAt(o).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(Vt.replace({widget:new mm(l),block:!0,inclusive:!0,isBlockGap:!0}).range(r,o))}if(!s)break;r=s.to+1}return Vt.set(e)}updateDeco(){let e=1,n=this.view.state.facet(Pp).map(s=>(this.dynamicDecorationMap[e++]=typeof s=="function")?s(this.view):s),r=!1,i=this.view.state.facet(ww).map((s,o)=>{let l=typeof s=="function";return l&&(r=!0),l?s(this.view):s});for(i.length&&(this.dynamicDecorationMap[e++]=r,n.push(Ht.join(i))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof s=="function"?s(this.view):s)}scrollIntoView(e){if(e.isSnapshot){let u=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=u.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let u of this.view.state.facet(OA))try{if(u(this.view,e.range,e))return!0}catch(c){li(this.view.state,c,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),i;if(!r)return;!n.empty&&(i=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,i.left),top:Math.min(r.top,i.top),right:Math.max(r.right,i.right),bottom:Math.max(r.bottom,i.bottom)});let s=xw(this.view),o={left:r.left-s.left,top:r.top-s.top,right:r.right+s.right,bottom:r.bottom+s.bottom},{offsetWidth:l,offsetHeight:a}=this.view.scrollDOM;if(wV(this.view.scrollDOM,o,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){gy(this.tile)}}function gy(t,e){let n=e==null?void 0:e.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)gy(r,e)}}function KV(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function FA(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=mA(n.focusNode,n.focusOffset),i=yA(n.focusNode,n.focusOffset),s=r||i;if(i&&r&&i.node!=r.node){let l=yn.get(i.node);if(!l||l.isText()&&l.text!=i.node.nodeValue)s=i;else if(t.docView.lastCompositionAfterCursor){let a=yn.get(r.node);!a||a.isText()&&a.text!=r.node.nodeValue||(s=i)}}if(t.docView.lastCompositionAfterCursor=s!=r,!s)return null;let o=e-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}function XV(t,e,n){let r=FA(t,n);if(!r)return null;let{node:i,from:s,to:o}=r,l=i.nodeValue;if(/[\n\r]/.test(l)||t.state.doc.sliceString(r.from,r.to)!=l)return null;let a=e.invertedDesc;return{range:new ai(a.mapPos(s),a.mapPos(o),s,o),text:i}}function GV(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class mm extends nu{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function tU(t,e,n=1){let r=t.charCategorizer(e),i=t.doc.lineAt(e),s=e-i.from;if(i.length==0)return he.cursor(e);s==0?n=1:s==i.length&&(n=-1);let o=s,l=s;n<0?o=sr(i.text,s,!1):l=sr(i.text,s);let a=r(i.text.slice(o,l));for(;o>0;){let u=sr(i.text,o,!1);if(r(i.text.slice(u,o))!=a)break;o=u}for(;lt.defaultLineHeight*1.5){let l=t.viewState.heightOracle.textHeight,a=Math.floor((i-n.top-(t.defaultLineHeight-l)*.5)/l);s+=a*t.viewState.heightOracle.lineLength}let o=t.state.sliceDoc(n.from,n.to);return n.from+cV(o,s,t.state.tabSize)}function rU(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let i;for(let s of r.type){if(s.from>e)break;if(!(s.toe)return s;(!i||s.type==fi.Text&&(i.type!=s.type||(n<0?s.frome)))&&(i=s)}}return i||r}return r}function iU(t,e,n,r){let i=rU(t,e.head,e.assoc||-1),s=!r||i.type!=fi.Text||!(t.lineWrapping||i.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>i.from?e.head-1:e.head);if(s){let o=t.dom.getBoundingClientRect(),l=t.textDirectionAt(i.from),a=t.posAtCoords({x:n==(l==mn.LTR)?o.right-1:o.left+1,y:(s.top+s.bottom)/2});if(a!=null)return he.cursor(a,n?-1:1)}return he.cursor(n?i.to:i.from,n?-1:1)}function Ck(t,e,n,r){let i=t.state.doc.lineAt(e.head),s=t.bidiSpans(i),o=t.textDirectionAt(i.from);for(let l=e,a=null;;){let u=OV(i,s,o,l,n),c=kA;if(!u){if(i.number==(n?t.state.doc.lines:1))return l;c=` -`,i=t.state.doc.line(i.number+(n?1:-1)),s=t.bidiSpans(i),u=t.visualLineSide(i,!n)}if(a){if(!a(c))return l}else{if(!r)return u;a=r(c)}l=u}}function sU(t,e,n){let r=t.state.charCategorizer(e),i=r(n);return s=>{let o=r(s);return i==Is.Space&&(i=o),i==o}}function oU(t,e,n,r){let i=e.head,s=n?1:-1;if(i==(n?t.state.doc.length:0))return he.cursor(i,e.assoc);let o=e.goalColumn,l,a=t.contentDOM.getBoundingClientRect(),u=t.coordsAtPos(i,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),c=t.documentTop;if(u)o==null&&(o=u.left-a.left),l=s<0?u.top:u.bottom;else{let p=t.viewState.lineBlockAt(i);o==null&&(o=Math.min(a.right-a.left,t.defaultCharacterWidth*(i-p.from))),l=(s<0?p.top:p.bottom)+c}let f=a.left+o,d=t.viewState.heightOracle.textHeight>>1,h=r??d;for(let p=0;;p+=d){let m=l+(h+p)*s,x=my(t,{x:f,y:m},!1,s);if(n?m>a.bottom:ml:y{if(e>s&&ei(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:he.cursor(r,rt.viewState.docHeight)return new rs(t.state.doc.length,-1);if(u=t.elementAtHeight(a),r==null)break;if(u.type==fi.Text){if(r<0?u.tot.viewport.to)break;let d=t.docView.coordsAt(r<0?u.from:u.to,r>0?-1:1);if(d&&(r<0?d.top<=a+s:d.bottom>=a+s))break}let f=t.viewState.heightOracle.textHeight/2;a=r>0?u.bottom+f:u.top-f}if(t.viewport.from>=u.to||t.viewport.to<=u.from){if(n)return null;if(u.type==fi.Text){let f=nU(t,i,u,o,l);return new rs(f,f==u.from?1:-1)}}if(u.type!=fi.Text)return a<(u.top+u.bottom)/2?new rs(u.from,1):new rs(u.to,-1);let c=t.docView.lineAt(u.from,2);return(!c||c.length!=u.length)&&(c=t.docView.lineAt(u.from,-2)),new lU(t,o,l,t.textDirectionAt(u.from)).scanTile(c,u.from)}class lU{constructor(e,n,r,i){this.view=e,this.x=n,this.y=r,this.baseDir=i,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+i.from>1;t:if(o.has(m)){for(let y=1;y=s&&(w-=p),!o.has(w)){m=w;break t}}break e}o.add(m);let x=n(m),g=0;if(x)for(let y=0;y1))if(w.bottomthis.y)(!u||u.top>w.top)&&(u=w),g=-1;else{let k=w.left>this.x?this.x-w.left:w.right(p+p+m)/3)return this.y=a.bottom-1,this.scan(e,n,!0);if(u&&u.top<(p+m+m)/3)return this.y=u.top+1,this.scan(e,n,!0)}let h=(l?this.dirAt(e[c],1):this.baseDir)==mn.LTR;return{i:c,after:this.x>(d.left+d.right)/2==h}}scanText(e,n){let r=[];for(let s=0;s{let o=r[s]-n,l=r[s+1]-n;return $c(e.dom,o,l).getClientRects()});return i.after?new rs(r[i.i+1],-1):new rs(r[i.i],1)}scanTile(e,n){if(!e.length)return new rs(n,1);if(e.children.length==1){let l=e.children[0];if(l.isText())return this.scanText(l,n);if(l.isComposite())return this.scanTile(l,n)}let r=[n];for(let l=0,a=n;l{let a=e.children[l];return a.flags&48?null:(a.dom.nodeType==1?a.dom:$c(a.dom,0,a.length)).getClientRects()}),s=e.children[i.i],o=r[i.i];return s.isText()?this.scanText(s,o):s.isComposite()?this.scanTile(s,o):i.after?new rs(r[i.i+1],-1):new rs(o,1)}}const Jl="￿";class aU{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet($t.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=Jl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let i=e;;){this.findPointBefore(r,i);let s=this.text.length;this.readNode(i);let o=yn.get(i),l=i.nextSibling;if(l==n){o!=null&&o.breakAfter&&!l&&r!=this.view.contentDOM&&this.lineBreak();break}let a=yn.get(l);(o&&a?o.breakAfter:(o?o.breakAfter:Nh(i))||Nh(l)&&(i.nodeName!="BR"||o!=null&&o.isWidget())&&this.text.length>s)&&!cU(l,n)&&this.lineBreak(),i=l}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,i=this.lineSeparator?null:/\r\n?|\n/g;;){let s=-1,o=1,l;if(this.lineSeparator?(s=n.indexOf(this.lineSeparator,r),o=this.lineSeparator.length):(l=i.exec(n))&&(s=l.index,o=l[0].length),this.append(n.slice(r,s<0?n.length:s)),s<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);r=s+o}}readNode(e){let n=yn.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let i=r.iter();!i.next().done;)i.lineBreak?this.lineBreak():this.append(i.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(uU(e,r.node,r.offset)?n:0))}}function uU(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:s,impreciseAnchor:o}=e.docView,l=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=zA(e.docView.tile,n,r,0))){let a=s||o?[]:hU(e),u=new aU(a,e);u.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=u.text,this.newSel=pU(a,this.bounds.from)}else{let a=e.observer.selectionRange,u=s&&s.node==a.focusNode&&s.offset==a.focusOffset||!cy(e.contentDOM,a.focusNode)?l.main.head:e.docView.posFromDOM(a.focusNode,a.focusOffset),c=o&&o.node==a.anchorNode&&o.offset==a.anchorOffset||!cy(e.contentDOM,a.anchorNode)?l.main.anchor:e.docView.posFromDOM(a.anchorNode,a.anchorOffset),f=e.viewport;if((Me.ios||Me.chrome)&&u!=c&&Math.min(u,c)<=l.main.from&&Math.max(u,c)>=l.main.to&&(f.from>0||f.to-1&&l.ranges.length>1)this.newSel=l.replaceRange(he.range(c,u));else if(e.lineWrapping&&c==u&&!(l.main.empty&&l.main.head==u)&&e.inputState.lastTouchTime>Date.now()-100){let d=e.coordsAtPos(u,-1),h=0;d&&(h=e.inputState.lastTouchY<=d.bottom?-1:1),this.newSel=he.create([he.cursor(u,h)])}else this.newSel=he.single(c,u)}}}function zA(t,e,n,r){if(t.isComposite()){let i=-1,s=-1,o=-1,l=-1;for(let a=0,u=r,c=r;an)return zA(f,e,n,u);if(d>=e&&i==-1&&(i=a,s=u),u>n&&f.dom.parentNode==t.dom){o=a,l=c;break}c=d,u=d+f.breakAfter}return{from:s,to:l<0?r+t.length:l,startDOM:(i?t.children[i-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:o=0?t.children[o].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function BA(t,e){let n,{newSel:r}=e,{state:i}=t,s=i.selection.main,o=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:l,to:a}=e.bounds,u=s.from,c=null;(o===8||Me.android&&e.text.length=l&&s.to<=a&&(e.typeOver||f!=e.text)&&f.slice(0,s.from-l)==e.text.slice(0,s.from-l)&&f.slice(s.to-l)==e.text.slice(d=e.text.length-(f.length-(s.to-l)))?n={from:s.from,to:s.to,insert:Dt.of(e.text.slice(s.from-l,d).split(Jl))}:(h=jA(f,e.text,u-l,c))&&(Me.chrome&&o==13&&h.toB==h.from+2&&e.text.slice(h.from,h.toB)==Jl+Jl&&h.toB--,n={from:l+h.from,to:l+h.toA,insert:Dt.of(e.text.slice(h.from,h.toB).split(Jl))})}else r&&(!t.hasFocus&&i.facet(Rs)||Fh(r,s))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==s.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Dt.of([n.insert.toString().replace("."," ")])}):i.doc.lineAt(s.from).toDate.now()-50?n={from:s.from,to:s.to,insert:i.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==s.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=he.single(r.main.anchor-1,r.main.head-1)),n={from:s.from,to:s.to,insert:Dt.of([" "])}),n)return bw(t,n,r,o);if(r&&!Fh(r,s)){let l=!1,a="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(l=!0),a=t.inputState.lastSelectionOrigin,a=="select.pointer"&&(r=$A(i.facet(of).map(u=>u(t)),r))),t.dispatch({selection:r,scrollIntoView:l,userEvent:a}),!0}else return!1}function bw(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let i=t.state.selection.main;if(Me.android&&(e.to==i.to&&(e.from==i.from||e.from==i.from-1&&t.state.sliceDoc(e.from,i.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&Ta(t.contentDOM,"Enter",13)||(e.from==i.from-1&&e.to==i.to&&e.insert.length==0||r==8&&e.insert.lengthi.head)&&Ta(t.contentDOM,"Backspace",8)||e.from==i.from&&e.to==i.to+1&&e.insert.length==0&&Ta(t.contentDOM,"Delete",46)))return!0;let s=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let o,l=()=>o||(o=dU(t,e,n));return t.state.facet(AA).some(a=>a(t,e.from,e.to,s,l))||t.dispatch(l()),!0}function dU(t,e,n){let r,i=t.state,s=i.selection.main,o=-1;if(e.from==e.to&&e.froms.to){let a=e.fromf(t)),u,a);e.from==c&&(o=c)}if(o>-1)r={changes:e,selection:he.cursor(e.from+e.insert.length,-1)};else if(e.from>=s.from&&e.to<=s.to&&e.to-e.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let a=s.frome.to?i.sliceDoc(e.to,s.to):"";r=i.replaceSelection(t.state.toText(a+e.insert.sliceString(0,void 0,t.state.lineBreak)+u))}else{let a=i.changes(e),u=n&&n.main.to<=a.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=s.to+10&&e.to>=s.to-10){let c=t.state.sliceDoc(e.from,e.to),f,d=n&&FA(t,n.main.head);if(d){let p=e.insert.length-(e.to-e.from);f={from:d.from,to:d.to-p}}else f=t.state.doc.lineAt(s.head);let h=s.to-e.to;r=i.changeByRange(p=>{if(p.from==s.from&&p.to==s.to)return{changes:a,range:u||p.map(a)};let m=p.to-h,x=m-c.length;if(t.state.sliceDoc(x,m)!=c||m>=f.from&&x<=f.to)return{range:p};let g=i.changes({from:x,to:m,insert:e.insert}),y=p.to-s.to;return{changes:g,range:u?he.range(Math.max(0,u.anchor+y),Math.max(0,u.head+y)):p.map(g)}})}else r={changes:a,selection:u&&i.selection.replaceRange(u)}}let l="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,l+=".compose",t.inputState.compositionFirstChange&&(l+=".start",t.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:l,scrollIntoView:!0})}function jA(t,e,n,r){let i=Math.min(t.length,e.length),s=0;for(;s0&&l>0&&t.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(r=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o=o?s-n:0;s-=a,l=s+(l-o),o=s}else if(l=l?s-n:0;s-=a,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}function hU(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}=t.observer.selectionRange;return n&&(e.push(new Tk(n,r)),(i!=n||s!=r)&&e.push(new Tk(i,s))),e}function pU(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?he.single(n+e,r+e):null}function Fh(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class gU{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&PU(e.contentDOM.ownerDocument)}handleEvent(e){!CU(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let i of r.observers)i(this.view,n);for(let i of r.handlers){if(n.defaultPrevented)break;if(i(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=yU(e),r=this.handlers,i=this.view.contentDOM;for(let s in n)if(s!="scroll"){let o=!n[s].handlers.length,l=r[s];l&&o!=!l.handlers.length&&(i.removeEventListener(s,this.handleEvent),l=null),l||i.addEventListener(s,this.handleEvent,{passive:o})}for(let s in r)s!="scroll"&&!n[s]&&i.removeEventListener(s,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&WA.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(HA.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||vU.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&mU(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),250),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function mU(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Ek(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(i){li(n.state,i)}}}function yU(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let i=r.spec,s=i&&i.plugin.domEventHandlers,o=i&&i.plugin.domEventObservers;if(s)for(let l in s){let a=s[l];a&&n(l).handlers.push(Ek(r.value,a))}if(o)for(let l in o){let a=o[l];a&&n(l).observers.push(Ek(r.value,a))}}for(let r in Bi)n(r).handlers.push(Bi[r]);for(let r in mr)n(r).observers.push(mr[r]);return e}const HA=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],vU="dthko",WA=[16,17,18,20,91,92,224,225],sd=6;function od(t){return Math.max(0,t)*.7+8}function wU(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class xU{constructor(e,n,r,i){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=fA(e.contentDOM),this.atoms=e.state.facet(of).map(o=>o(e));let s=e.contentDOM.ownerDocument;s.addEventListener("mousemove",this.move=this.move.bind(this)),s.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet($t.allowMultipleSelections)&&bU(e,n),this.dragging=SU(e,n)&&KA(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&wU(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,i=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:i,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=xw(this.view);e.clientX-a.left<=i+sd?n=-od(i-e.clientX):e.clientX+a.right>=o-sd&&(n=od(e.clientX-o)),e.clientY-a.top<=s+sd?r=-od(s-e.clientY):e.clientY+a.bottom>=l-sd&&(r=od(e.clientY-l)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=$A(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function bU(t,e){let n=t.state.facet(SA);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function kU(t,e){let n=t.state.facet(CA);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function SU(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Lc(t.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let s=0;s=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function CU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=yn.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Bi=Object.create(null),mr=Object.create(null),VA=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function TU(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),UA(t,n.value)},50)}function Dp(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function UA(t,e){e=Dp(t.state,mw,e);let{state:n}=t,r,i=1,s=n.toText(e),o=s.lines==n.selection.ranges.length;if(yy!=null&&n.selection.ranges.every(a=>a.empty)&&yy==s.toString()){let a=-1;r=n.changeByRange(u=>{let c=n.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=n.toText((o?s.line(i++).text:e)+n.lineBreak);return{changes:{from:c.from,insert:f},range:he.cursor(u.from+f.length)}})}else o?r=n.changeByRange(a=>{let u=s.line(i++);return{changes:{from:a.from,to:a.to,insert:u.text},range:he.cursor(a.from+u.length)}}):r=n.replaceSelection(s);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}mr.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())};mr.wheel=mr.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()};Bi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1);mr.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")};mr.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")};mr.touchend=(t,e)=>{t.inputState.touchActive=!1};Bi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(TA))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=AU(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new xU(t,e,n,r)),r&&t.observer.ignore(()=>{pA(t.contentDOM);let s=t.root.activeElement;s&&!s.contains(t.contentDOM)&&s.blur()});let i=t.inputState.mouseSelection;if(i)return i.start(e),i.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Ak(t,e,n,r){if(r==1)return he.cursor(e,n);if(r==2)return tU(t.state,e,n);{let i=t.docView.lineAt(e,n),s=t.state.doc.lineAt(i?i.posAtEnd:e),o=i?i.posAtStart:s.from,l=i?i.posAtEnd:s.to;return lDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Rk+1)%3:1}function AU(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=KA(e),i=t.state.selection;return{update(s){s.docChanged&&(n.pos=s.changes.mapPos(n.pos),i=i.map(s.changes))},get(s,o,l){let a=t.posAndSideAtCoords({x:s.clientX,y:s.clientY},!1),u,c=Ak(t,a.pos,a.assoc,r);if(n.pos!=a.pos&&!o){let f=Ak(t,n.pos,n.assoc,r),d=Math.min(f.from,c.from),h=Math.max(f.to,c.to);c=d1&&(u=MU(i,a.pos))?u:l?i.addRange(c):he.create([c])}}}function MU(t,e){for(let n=0;n=e)return he.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Bi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let i=t.docView.tile.nearest(e.target);if(i&&i.isWidget()){let s=i.posAtStart,o=s+i.length;(s>=n.to||o<=n.from)&&(n=he.undirectionalRange(s,o))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",Dp(t.state,yw,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1};Bi.dragend=t=>(t.inputState.draggedContent=null,!1);function Pk(t,e,n,r){if(n=Dp(t.state,mw,n),!n)return;let i=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:s}=t.inputState,o=r&&s&&kU(t,e)?{from:s.from,to:s.to}:null,l={from:i,insert:n},a=t.state.changes(o?[o,l]:l);t.focus(),t.dispatch({changes:a,selection:{anchor:a.mapPos(i,-1),head:a.mapPos(i,1)},userEvent:o?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Bi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,s=()=>{++i==n.length&&Pk(t,e,r.filter(o=>o!=null).join(t.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(r[o]=l.result),s()},l.readAsText(n[o])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return Pk(t,e,r,!0),!0}return!1};Bi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=VA?null:e.clipboardData;return n?(UA(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(TU(t),!1)};function RU(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function OU(t){let e=[],n=[],r=!1;for(let i of t.selection.ranges)i.empty||(e.push(t.sliceDoc(i.from,i.to)),n.push(i));if(!e.length){let i=-1;for(let{from:s}of t.selection.ranges){let o=t.doc.lineAt(s);o.number>i&&(e.push(o.text),n.push({from:o.from,to:Math.min(t.doc.length,o.to+1)})),i=o.number}r=!0}return{text:Dp(t,yw,e.join(t.lineBreak)),ranges:n,linewise:r}}let yy=null;Bi.copy=Bi.cut=(t,e)=>{if(!lc(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=OU(t.state);if(!n&&!i)return!1;yy=i?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let s=VA?null:e.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(RU(t,n),!1)};const XA=Fo.define();function GA(t,e){let n=[];for(let r of t.facet(MA)){let i=r(t,e);i&&n.push(i)}return n.length?t.update({effects:n,annotations:XA.of(!0)}):null}function qA(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=GA(t.state,e);n?t.dispatch(n):t.update([])}},10)}mr.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),qA(t)};mr.blur=t=>{t.observer.clearSelectionRange(),qA(t)};mr.compositionstart=mr.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))};mr.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))};mr.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()};Bi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let s=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),o=e.getTargetRanges();if(s&&o.length){let l=o[0],a=t.posAtDOM(l.startContainer,l.startOffset),u=t.posAtDOM(l.endContainer,l.endOffset);return bw(t,{from:a,to:u,insert:t.state.toText(s)},null),!0}}let i;if(Me.chrome&&Me.android&&(i=HA.find(s=>s.inputType==e.inputType))&&(t.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var o;(((o=window.visualViewport)===null||o===void 0?void 0:o.height)||0)>s+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>mr.compositionend(t,e),20),!1};const Ik=new Set;function PU(t){Ik.has(t)||(Ik.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const Nk=["pre-wrap","normal","pre-line","break-spaces"];let ja=!1;function Dk(){ja=!1}class IU{constructor(e){this.lineWrapping=e,this.doc=Dt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return Nk.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,a=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=n,this.charWidth=r,this.textHeight=i,this.lineLength=s,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>zd&&(ja=!0),this.height=e)}replace(e,n,r){return gr.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,i){let s=this,o=r.doc;for(let l=i.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=i[l],d=s.lineAt(a,Qt.ByPosNoHeight,r.setDoc(n),0,0),h=d.to>=u?d:s.lineAt(u,Qt.ByPosNoHeight,r,0,0);for(f+=h.to-u,u=h.to;l>0&&d.from<=i[l-1].toA;)a=i[l-1].fromA,c=i[l-1].fromB,l--,as*2){let l=e[n-1];l.break?e.splice(--n,1,l.left,null,l.right):e.splice(--n,1,l.left,l.right),r+=1+l.break,i-=l.size}else if(s>i*2){let l=e[r];l.break?e.splice(r,1,l.left,null,l.right):e.splice(r,1,l.left,l.right),r+=2+l.break,s-=l.size}else break;else if(i=s&&o(this.lineAt(0,Qt.ByPos,r,i,s))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more&&this.setMeasuredHeight(i),this.outdated=!1,this}toString(){return`block(${this.length})`}}class jr extends YA{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ii(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let i=r[0];return r.length==1&&(i instanceof jr||i instanceof Un&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof Un?i=new jr(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):gr.of(r)}updateHeight(e,n=0,r=!1,i){return i&&i.from<=n&&i.more?this.setMeasuredHeight(i):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class Un extends gr{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,i=e.doc.lineAt(n+this.length).number,s=i-r+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*s);o=a/s,this.length>s+1&&(l=(this.height-a)/(this.length-s-1))}else o=this.height/s;return{firstLine:r,lastLine:i,perLine:o,perChar:l}}blockAt(e,n,r,i){let{firstLine:s,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(n,i);if(n.lineWrapping){let u=i+(e0){let s=r[r.length-1];s instanceof Un?r[r.length-1]=new Un(s.length+i):r.push(null,new Un(i-1))}if(e>0){let s=r[0];s instanceof Un?r[0]=new Un(e+s.length):r.unshift(new Un(e-1),null)}return gr.of(r)}decomposeLeft(e,n){n.push(new Un(e-1),null)}decomposeRight(e,n){n.push(null,new Un(this.length-e-1))}updateHeight(e,n=0,r=!1,i){let s=n+this.length;if(i&&i.from<=n+this.length&&i.more){let o=[],l=Math.max(n,i.from),a=-1;for(i.from>n&&o.push(new Un(i.from-n-1).updateHeight(e,n));l<=s&&i.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=i.heights[i.index++],d=0;f<0&&(d=-f,f=i.heights[i.index++]),a==-1?a=f:Math.abs(f-a)>=zd&&(a=-2);let h=new jr(c,f,d);h.outdated=!1,o.push(h),l+=c+1}l<=s&&o.push(null,new Un(s-l).updateHeight(e,l));let u=gr.of(o);return(a<0||Math.abs(u.height-this.height)>=zd||Math.abs(a-this.heightMetrics(e,n).perLine)>=zd)&&(ja=!0),$h(this,u)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class _U extends gr{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,i){let s=r+this.left.height;return el))return u;let c=n==Qt.ByPosNoHeight?Qt.ByPosNoHeight:Qt.ByPos;return a?u.join(this.right.lineAt(l,c,r,o,l)):this.left.lineAt(l,c,r,i,s).join(u)}forEachLine(e,n,r,i,s,o){let l=i+this.left.height,a=s+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,n,r,l,a,o);else{let u=this.lineAt(a,Qt.ByPos,r,i,s);e=e&&u.from<=n&&o(u),n>u.to&&this.right.forEachLine(u.to+1,n,r,l,a,o)}}replace(e,n,r){let i=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-i,n-i,r));let s=[];e>0&&this.decomposeLeft(e,s);let o=s.length;for(let l of r)s.push(l);if(e>0&&_k(s,o-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,i=r+this.break;if(e>=i)return this.right.decomposeRight(e-i,n);e2*n.size||n.size>2*e.size?gr.of(this.break?[e,null,n]:[e,n]):(this.left=$h(this.left,e),this.right=$h(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,i){let{left:s,right:o}=this,l=n+s.length+this.break,a=null;return i&&i.from<=n+s.length&&i.more?a=s=s.updateHeight(e,n,r,i):s.updateHeight(e,n,r),i&&i.from<=l+o.length&&i.more?a=o=o.updateHeight(e,l,r,i):o.updateHeight(e,l,r),a?this.balanced(s,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function _k(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof Un&&(r=t[e+1])instanceof Un&&t.splice(e-1,3,new Un(n.length+1+r.length))}const LU=5;class kw{constructor(e,n){this.pos=e,this.oracle=n,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),i=this.nodes[this.nodes.length-1];i instanceof jr?i.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new jr(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=LU)&&this.addLineDeco(i,s,o)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new jr(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new Un(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof jr)return e;let n=new jr(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let i=this.ensureLine();i.length+=r,i.collapsed+=r,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof jr)&&!this.isCovered?this.nodes.push(new jr(0,-1,0)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let d=c.getBoundingClientRect();s=Math.max(s,d.left),o=Math.min(o,d.right),l=Math.max(l,d.top),a=Math.min(u==t.parentNode?i.innerHeight:a,d.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+e),bottom:Math.max(l,a)-(n.top+e)}}function BU(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function jU(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class vm{constructor(e,n,r,i){this.from=e,this.to=n,this.size=r,this.displaySize=i}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new IU(r),this.stateDeco=$k(n),this.heightMap=gr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle.setDoc(n.doc),[new ai(0,0,0,n.doc.length)]);for(let i=0;i<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());i++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=Vt.set(this.lineGaps.map(i=>i.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let i=r?n.head:n.anchor;if(!e.some(({from:s,to:o})=>i>=s&&i<=o)){let{from:s,to:o}=this.lineBlockAt(i);e.push(new ld(s,o))}}return this.viewports=e.sort((r,i)=>r.from-i.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Fk:new Sw(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Wu(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=$k(this.state);let i=e.changedRanges,s=ai.extendWithRanges(i,FU(r,this.stateDeco,e?e.changes:_n.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);Dk(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),s),(this.heightMap.height!=o||ja)&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=o);let a=s.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,n));let u=a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,e.flags|=this.updateForViewport(),(u||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(IV)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),i=this.heightOracle,s=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?mn.RTL:mn.LTR;let o=this.heightOracle.mustRefreshForWrapping(s)||this.mustMeasureContent==="refresh",l=n.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0;if(l.width&&l.height){let{scaleX:b,scaleY:S}=cA(n,l);(b>.005&&Math.abs(this.scaleX-b)>.005||S>.005&&Math.abs(this.scaleY-S)>.005)&&(this.scaleX=b,this.scaleY=S,u|=16,o=a=!0)}let f=(parseInt(r.paddingTop)||0)*this.scaleY,d=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=d)&&(this.paddingTop=f,this.paddingBottom=d,u|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(i.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=16);let h=fA(this.view.contentDOM,!1).y;h!=this.scrollParent&&(this.scrollParent=h,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=gA(this.scrollParent||e.win);let m=(this.printing?jU:zU)(n,this.paddingTop),x=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let y=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(y!=this.inView&&(this.inView=y,y&&(a=!0)),!this.inView&&!this.scrollTarget&&!BU(e.dom))return 0;let w=l.width;if((this.contentDOMWidth!=w||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=16),a){let b=e.docView.measureVisibleLineHeights(this.viewport);if(i.mustRefreshForHeights(b)&&(o=!0),o||i.lineWrapping&&Math.abs(w-this.contentDOMWidth)>i.charWidth){let{lineHeight:S,charWidth:T,textHeight:A}=e.docView.measureTextSize();o=S>0&&i.refresh(s,S,T,A,Math.max(5,w/T),b),o&&(e.docView.minWidth=0,u|=16)}x>0&&g>0?c=Math.max(x,g):x<0&&g<0&&(c=Math.min(x,g)),Dk();for(let S of this.viewports){let T=S.from==this.viewport.from?b:e.docView.measureVisibleLineHeights(S);this.heightMap=(o?gr.empty().applyChanges(this.stateDeco,Dt.empty,this.heightOracle,[new ai(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(i,0,o,new NU(S.from,T))}ja&&(u|=2)}let k=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return k&&(u&2&&(u|=this.updateScaler()),this.viewport=this.getViewport(c,this.scrollTarget),u|=this.updateForViewport()),(u&2||k)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),i=this.heightMap,s=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new ld(i.lineAt(o-r*1e3,Qt.ByHeight,s,0,0).from,i.lineAt(l+(1-r)*1e3,Qt.ByHeight,s,0,0).to);if(n){let{head:u}=n.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=i.lineAt(u,Qt.ByPos,s,0,0),d;n.y=="center"?d=(f.top+f.bottom)/2-c/2:n.y=="start"||n.y=="nearest"&&u=l+Math.max(10,Math.min(r,250)))&&i>o-2*1e3&&s>1,o=i<<1;if(this.defaultTextDirection!=mn.LTR&&!r)return[];let l=[],a=(c,f,d,h)=>{if(f-cc&&gg.from>=d.from&&g.to<=d.to&&Math.abs(g.from-c)g.fromy));if(!x){if(fw.from<=f&&w.to>=f)){let w=n.moveToLineBoundary(he.cursor(f),!1,!0).head;w>c&&(f=w)}let g=this.gapSize(d,c,f,h),y=r||g<2e6?g:2e6;x=new vm(c,f,g,y)}l.push(x)},u=c=>{if(c.length2e6)for(let S of e)S.from>=c.from&&S.fromc.from&&a(c.from,h,c,f),pn.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];Ht.spans(n,this.viewport.from,this.viewport.to,{span(s,o){r.push({from:s,to:o})},point(){}},20);let i=0;if(r.length!=this.visibleRanges.length)i=12;else for(let s=0;s=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Wu(this.heightMap.lineAt(e,Qt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Wu(this.heightMap.lineAt(this.scaler.fromDOM(e),Qt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return(this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top)*this.scaleY}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Wu(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class ld{constructor(e,n){this.from=e,this.to=n}}function WU(t,e,n){let r=[],i=t,s=0;return Ht.spans(n,t,e,{span(){},point(o,l){o>i&&(r.push({from:i,to:o}),s+=o-i),i=l}},20),i=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let i=0;;i++){let{from:s,to:o}=e[i],l=o-s;if(r<=l)return s+r;r-=l}}function ud(t,e){let n=0;for(let{from:r,to:i}of t.ranges){if(e<=i){n+=e-r;break}n+=i-r}return n/t.total}function VU(t,e){for(let n of t)if(e(n))return n}const Fk={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function $k(t){let e=t.facet(Pp).filter(r=>typeof r!="function"),n=t.facet(ww).filter(r=>typeof r!="function");return n.length&&e.push(Ht.join(n)),e}class Sw{constructor(e,n,r){let i=0,s=0,o=0;this.viewports=r.map(({from:l,to:a})=>{let u=n.lineAt(l,Qt.ByPos,e,0,0).top,c=n.lineAt(a,Qt.ByPos,e,0,0).bottom;return i+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(n.height-i);for(let l of this.viewports)l.domTop=o+(l.top-s)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),s=l.bottom}toDOM(e){for(let n=0,r=0,i=0;;n++){let s=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Wu(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ii(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(i=>Wu(i,e)):t._content)}const cd=je.define({combine:t=>t.join(" ")}),vy=je.define({combine:t=>t.indexOf(!0)>-1}),wy=Ro.newName(),JA=Ro.newName(),QA=Ro.newName(),ZA={"&light":"."+JA,"&dark":"."+QA};function xy(t,e,n){return new Ro(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,i=>{if(i=="&")return t;if(!n||!n[i])throw new RangeError(`Unsupported selector: ${i}`);return n[i]}):t+" "+r}})}const UU=xy("."+wy,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},ZA),KU={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},wm=Me.ie&&Me.ie_version<=11;class XU{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new xV,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new qU(e),e.state.facet(Rs)&&(e.contentDOM.editContext=this.editContext.editContext)),wm&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,i=this.selectionRange;if(r.state.facet(Rs)?r.root.activeElement!=this.dom:!lc(this.dom,i))return;let s=i.anchorNode&&r.docView.tile.nearest(i.anchorNode);if(s&&s.isWidget()&&s.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&i.focusNode&&uc(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Lc(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&GU(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let i=lc(this.dom,r);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let s=this.delayedAndroidKey;s&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=s.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&s.force&&Ta(this.dom,s.key,s.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(i)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,i=!1;for(let s of e){let o=this.readMutation(s);o&&(o.typeOver&&(i=!0),n==-1?{from:n,to:r}=o:(n=Math.min(o.from,n),r=Math.max(o.to,r)))}return{from:n,to:r,typeOver:i}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),i=this.selectionChanged&&lc(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let s=new fU(this.view,e,n,r);return this.view.docView.domChanged={newSel:s.newSel?s.newSel.main:null},s}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=BA(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!Fh(this.view.state.selection,n.newSel.main))&&this.view.update([]),i}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=zk(n,e.previousSibling||e.target.previousSibling,-1),i=zk(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:i?n.posBefore(i):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(Rs)!=e.state.facet(Rs)&&(e.view.contentDOM.editContext=e.state.facet(Rs)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let i of this.scrollTargets)i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function zk(t,e,n){for(;e;){let r=yn.get(e);if(r&&r.parent==t)return r;let i=e.parentNode;e=i!=t.dom?i:n>0?e.nextSibling:e.previousSibling}return null}function Bk(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.docView.domAtPos(t.state.selection.main.anchor,1);return uc(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function GU(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Bk(t,i)}let n=null;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?Bk(t,n):null}class qU{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let i=e.state.selection.main,{anchor:s,head:o}=i,l=this.toEditorPos(r.updateRangeStart),a=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:l,drifted:!1});let u=a-l>r.text.length;l==this.from&&sthis.to&&(a=s);let c=jA(e.state.sliceDoc(l,a),r.text,(u?i.from:i.to)-l,u?"end":null);if(!c){let d=he.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));Fh(d,i)||e.dispatch({selection:d,userEvent:"select"});return}let f={from:c.from+l,to:c.toA+l,insert:Dt.of(r.text.slice(c.from,c.toB).split(` -`))};if((Me.mac||Me.android)&&f.from==o-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:l,to:a,insert:Dt.of([r.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let d=this.to-this.from+(f.to-f.from+f.insert.length);bw(e,f,he.single(this.toEditorPos(r.selectionStart,d),this.toEditorPos(r.selectionEnd,d)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let i=[],s=null;for(let o=this.toEditorPos(r.rangeStart),l=this.toEditorPos(r.rangeEnd);o{let i=[];for(let s of r.getTextFormats()){let o=s.underlineStyle,l=s.underlineThickness;if(!/none/i.test(o)&&!/none/i.test(l)){let a=this.toEditorPos(s.rangeStart),u=this.toEditorPos(s.rangeEnd);if(a{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let i=Lc(r.root);i&&i.rangeCount&&this.editContext.updateSelectionBounds(i.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,i=this.pendingContextChange;return e.changes.iterChanges((s,o,l,a,u)=>{if(r)return;let c=u.length-(o-s);if(i&&o>=i.to)if(i.from==s&&i.to==o&&i.insert.eq(u)){i=this.pendingContextChange=null,n+=c,this.to+=c;return}else i=null,this.revertPending(e.state);if(s+=n,o+=n,o<=this.from)this.from+=c,this.to+=c;else if(sthis.to||this.to-this.from+u.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(s),this.toContextPos(o),u.toString()),this.to+=c}n+=c}),i&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(i=>!i.isUserEvent("input.type")&&i.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),i=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(r,i)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to1e4*3)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ke{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(i=>i.forEach(s=>r(s,this)))||(i=>this.update(i)),this.dispatch=this.dispatch.bind(this),this._root=e.root||bV(e.parent)||document,this.viewState=new Lk(this,e.state||$t.create(e)),e.scrollTo&&e.scrollTo.is(id)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(ha).map(i=>new hm(i));for(let i of this.plugins)i.update(this);this.observer=new XU(this),this.inputState=new gU(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Sk(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof $n?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,i,s=this.state;for(let d of e){if(d.startState!=s)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");s=d.state}if(this.destroyed){this.viewState.state=s;return}let o=this.hasFocus,l=0,a=null;e.some(d=>d.annotation(XA))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=GA(s,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(s.doc)||!this.state.selection.eq(s.selection))&&(c=null)):this.observer.clear(),s.facet($t.phrases)!=this.state.facet($t.phrases))return this.setState(s);i=Dh.create(this,s,e),i.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let d of e){if(f&&(f=f.map(d.changes)),d.scrollIntoView){let{main:h}=d.state.selection,{x:p,y:m}=this.state.facet(Ke.cursorScrollMargin);f=new Ea(h.empty?h:he.cursor(h.head,h.head>h.anchor?-1:1),"nearest","nearest",m,p)}for(let h of d.effects)h.is(id)&&(f=h.value.clip(this.state))}this.viewState.update(i,f),this.bidiCache=zh.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Hu)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(d=>d.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(cd)!=i.state.facet(cd)&&(this.viewState.mustMeasureContent=!0),(n||r||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let d of this.state.facet(py))try{d(i)}catch(h){li(this.state,h,"update listener")}(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!BA(this,c)&&u.force&&Ta(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new Lk(this,e),this.plugins=e.facet(ha).map(r=>new hm(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Sk(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(ha),r=e.state.facet(ha);if(n!=r){let i=[];for(let s of r){let o=n.indexOf(s);if(o<0)i.push(new hm(s));else{let l=this.plugins[o];l.mustUpdate=e,i.push(l)}}for(let s of this.plugins)s.mustUpdate!=e&&s.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let i of this.plugins)i.mustUpdate=e;for(let i=0;i-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,i=this.viewState.getScrollOffset(),{scrollAnchorPos:s,scrollAnchorHeight:o}=this.viewState;Math.abs(i-this.viewState.scrollOffset)>1&&(o=-1),this.viewState.scrollAnchorHeight=-1;try{for(let l=0;;l++){if(o<0)if(gA(r||this.win))s=-1,o=this.viewState.heightMap.height;else{let h=this.viewState.scrollAnchorAt(i);s=h.from,o=h.top}this.updateState=1;let a=this.viewState.measure();if(!a&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(l>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let u=[];a&4||([this.measureRequests,u]=[u,this.measureRequests]);let c=u.map(h=>{try{return h.read(this)}catch(p){return li(this.state,p),jk}}),f=Dh.create(this,this.state,[]),d=!1;f.flags|=a,n?n.flags|=a:n=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),d=this.docView.update(f),d&&this.docViewUpdate());for(let h=0;h1||p<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){i=i+p,r?s<0?r.scrollTop=r.scrollHeight:r.scrollTop+=p:this.win.scrollBy(0,p),o=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let l of this.state.facet(py))l(n)}get themeClasses(){return wy+" "+(this.state.facet(vy)?QA:JA)+" "+this.state.facet(cd)}updateAttrs(){let e=Hk(this,IA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Rs)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),Hk(this,vw,n);let r=this.observer.ignore(()=>{let i=yk(this.contentDOM,this.contentAttrs,n),s=yk(this.dom,this.editorAttrs,e);return i||s});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let i of r.effects)if(i.is(Ke.announce)){n&&(this.announceDOM.textContent=""),n=!1;let s=this.announceDOM.appendChild(document.createElement("div"));s.textContent=i.value}}mountStyles(){this.styleModules=this.state.facet(Hu);let e=this.state.facet(Ke.cspNonce);Ro.mount(this.root,this.styleModules.concat(UU).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,n,r){return ym(this,e,Ck(this,e,n,r))}moveByGroup(e,n){return ym(this,e,Ck(this,e,n,r=>sU(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),i=this.textDirectionAt(e.from),s=r[n?r.length-1:0];return he.cursor(s.side(n,i)+e.from,s.forward(!n,i)?1:-1)}moveToLineBoundary(e,n,r=!0){return iU(this,e,n,r)}moveVertically(e,n,r){return ym(this,e,oU(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=my(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),my(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),i=this.bidiSpans(r),s=i[os.find(i,e-r.from,-1,n)];return this.docView.coordsAt(e,n,s.dir==mn.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(RA)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>YU)return bA(e.length);let n=this.textDirectionAt(e.from),r;for(let s of this.bidiCache)if(s.from==e.from&&s.dir==n&&(s.fresh||xA(s.isolates,r=xk(this,e))))return s.order;r||(r=xk(this,e));let i=RV(e.text,n,r);return this.bidiCache.push(new zh(e.from,e.to,n,r,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{pA(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,i,s,o;return id.of(new Ea(typeof e=="number"?he.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(i=n.x)!==null&&i!==void 0?i:"nearest",(s=n.yMargin)!==null&&s!==void 0?s:5,(o=n.xMargin)!==null&&o!==void 0?o:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return id.of(new Ea(he.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return gi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return gi.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=Ro.newName(),i=[cd.of(r),Hu.of(xy(`.${r}`,e))];return n&&n.dark&&i.push(vy.of(!0)),i}static baseTheme(e){return cw.lowest(Hu.of(xy("."+wy,e,ZA)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),i=r&&yn.get(r)||yn.get(e);return((n=i==null?void 0:i.root)===null||n===void 0?void 0:n.view)||null}}Ke.styleModule=Hu;Ke.inputHandler=AA;Ke.clipboardInputFilter=mw;Ke.clipboardOutputFilter=yw;Ke.scrollHandler=OA;Ke.focusChangeEffect=MA;Ke.perLineTextDirection=RA;Ke.exceptionSink=EA;Ke.updateListener=py;Ke.editable=Rs;Ke.mouseSelectionStyle=TA;Ke.dragMovesSelection=CA;Ke.clickAddsSelectionRange=SA;Ke.decorations=Pp;Ke.blockWrappers=NA;Ke.outerDecorations=ww;Ke.atomicRanges=of;Ke.bidiIsolatedRanges=DA;Ke.cursorScrollMargin=je.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}});Ke.scrollMargins=_A;Ke.darkTheme=vy;Ke.cspNonce=je.define({combine:t=>t.length?t[0]:""});Ke.contentAttributes=vw;Ke.editorAttributes=IA;Ke.lineWrapping=Ke.contentAttributes.of({class:"cm-lineWrapping"});Ke.announce=qt.define();const YU=4096,jk={};class zh{constructor(e,n,r,i,s,o){this.from=e,this.to=n,this.dir=r,this.isolates=i,this.fresh=s,this.order=o}static update(e,n){if(n.empty&&!e.some(s=>s.fresh))return e;let r=[],i=e.length?e[e.length-1].dir:mn.LTR;for(let s=Math.max(0,e.length-10);s=0;i--){let s=r[i],o=typeof s=="function"?s(t):s;o&&hw(o,n)}return n}const JU=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function QU(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,s,o,l;for(let a=0;ar.concat(i),[]))),n}let co=null;const t7=4e3;function n7(t,e=JU){let n=Object.create(null),r=Object.create(null),i=(o,l)=>{let a=r[o];if(a==null)r[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},s=(o,l,a,u,c)=>{var f,d;let h=n[o]||(n[o]=Object.create(null)),p=l.split(/ (?!$)/).map(g=>QU(g,e));for(let g=1;g{let k=co={view:w,prefix:y,scope:o};return setTimeout(()=>{co==k&&(co=null)},t7),!0}]})}let m=p.join(" ");i(m,!1);let x=h[m]||(h[m]={preventDefault:!1,stopPropagation:!1,run:((d=(f=h._any)===null||f===void 0?void 0:f.run)===null||d===void 0?void 0:d.slice())||[]});a&&x.run.push(a),u&&(x.preventDefault=!0),c&&(x.stopPropagation=!0)};for(let o of t){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=n[u]||(n[u]=Object.create(null));c._any||(c._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=o;for(let d in c)c[d].run.push(h=>f(h,by))}let a=o[e]||o.key;if(a)for(let u of l)s(u,a,o.run,o.preventDefault,o.stopPropagation),o.shift&&s(u,"Shift-"+a,o.shift,o.preventDefault,o.stopPropagation)}return n}let by=null;function r7(t,e,n,r){by=e;let i=pV(e),s=Y9(i,0),o=J9(s)==i.length&&i!=" ",l="",a=!1,u=!1,c=!1;co&&co.view==n&&co.scope==r&&(l=co.prefix+" ",WA.indexOf(e.keyCode)<0&&(u=!0,co=null));let f=new Set,d=x=>{if(x){for(let g of x.run)if(!f.has(g)&&(f.add(g),g(n)))return x.stopPropagation&&(c=!0),!0;x.preventDefault&&(x.stopPropagation&&(c=!0),u=!0)}return!1},h=t[r],p,m;return h&&(d(h[l+fd(i,e,!o)])?a=!0:o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=Oo[e.keyCode])&&p!=i?(d(h[l+fd(p,e,!0)])||e.shiftKey&&(m=Dc[e.keyCode])!=i&&m!=p&&d(h[l+fd(m,e,!1)]))&&(a=!0):o&&e.shiftKey&&d(h[l+fd(i,e,!0)])&&(a=!0),!a&&d(h._any)&&(a=!0)),u&&(a=!0),a&&c&&e.stopPropagation(),by=null,a}class i7 extends nu{constructor(e){super(),this.content=e}toDOM(e){let n=document.createElement("span");return n.className="cm-placeholder",n.style.pointerEvents="none",n.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),n.setAttribute("aria-hidden","true"),n}coordsAt(e){let n=e.firstChild?ac(e.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(e.parentNode),i=Fc(n[0],r.direction!="rtl"),s=parseInt(r.lineHeight);return i.bottom-i.top>s*1.5?{left:i.left,right:i.right,top:i.top,bottom:i.top+s}:i}ignoreEvent(){return!1}}function s7(t){let e=gi.fromClass(class{constructor(n){this.view=n,this.placeholder=t?Vt.set([Vt.widget({widget:new i7(t),side:1}).range(0)]):Vt.none}get decorations(){return this.view.state.doc.length?Vt.none:this.placeholder}},{decorations:n=>n.decorations});return typeof t=="string"?[e,Ke.contentAttributes.of({"aria-placeholder":t})]:e}const dd="-10000px";class tM{constructor(e,n,r,i){this.facet=n,this.createTooltipView=r,this.removeTooltipView=i,this.input=e.state.facet(n),this.tooltips=this.input.filter(o=>o);let s=null;this.tooltipViews=this.tooltips.map(o=>s=r(o,s))}update(e,n){var r;let i=e.state.facet(this.facet),s=i.filter(a=>a);if(i===this.input){for(let a of this.tooltipViews)a.update&&a.update(e);return!1}let o=[],l=n?[]:null;for(let a=0;an[u]=a),n.length=l.length),this.input=i,this.tooltips=s,this.tooltipViews=o,!0}}function o7(t){let e=t.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const xm=je.define({combine:t=>{var e,n,r;return{position:Me.ios?"absolute":((e=t.find(i=>i.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((n=t.find(i=>i.parent))===null||n===void 0?void 0:n.parent)||null,tooltipSpace:((r=t.find(i=>i.tooltipSpace))===null||r===void 0?void 0:r.tooltipSpace)||o7}}}),Vk=new WeakMap,nM=gi.fromClass(class{constructor(t){this.view=t,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=t.state.facet(xm);this.position=e.position,this.parent=e.parent,this.classes=t.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new tM(t,rM,(n,r)=>this.createTooltip(n,r),n=>{this.resizeObserver&&this.resizeObserver.unobserve(n.dom),n.dom.remove()}),this.above=this.manager.tooltips.map(n=>!!n.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(n=>{Date.now()>this.lastTransaction-50&&n.length>0&&n[n.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),t.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let t of this.manager.tooltipViews)this.intersectionObserver.observe(t.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(t){t.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(t,this.above);e&&this.observeIntersection();let n=e||t.geometryChanged,r=t.state.facet(xm);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let i of this.manager.tooltipViews)i.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let i of this.manager.tooltipViews)this.container.appendChild(i.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(t,e){let n=t.create(this.view),r=e?e.dom:null;if(n.dom.classList.add("cm-tooltip"),t.arrow&&!n.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let i=document.createElement("div");i.className="cm-tooltip-arrow",n.dom.appendChild(i)}return n.dom.style.position=this.position,n.dom.style.top=dd,n.dom.style.left="0px",this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var t,e,n;this.view.win.removeEventListener("resize",this.measureSoon);for(let r of this.manager.tooltipViews)r.dom.remove(),(t=r.destroy)===null||t===void 0||t.call(r);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(n=this.intersectionObserver)===null||n===void 0||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let t=1,e=1,n=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:s}=this.manager.tooltipViews[0];if(Me.safari){let o=s.getBoundingClientRect();n=Math.abs(o.top+1e4)>1||Math.abs(o.left)>1}else n=!!s.offsetParent&&s.offsetParent!=this.container.ownerDocument.body}if(n||this.position=="absolute")if(this.parent){let s=this.parent.getBoundingClientRect();s.width&&s.height&&(t=s.width/this.parent.offsetWidth,e=s.height/this.parent.offsetHeight)}else({scaleX:t,scaleY:e}=this.view.viewState);let r=this.view.scrollDOM.getBoundingClientRect(),i=xw(this.view);return{visible:{left:r.left+i.left,top:r.top+i.top,right:r.right-i.right,bottom:r.bottom-i.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((s,o)=>{let l=this.manager.tooltipViews[o];return l.getCoords?l.getCoords(s.pos):this.view.coordsAtPos(s.pos)}),size:this.manager.tooltipViews.map(({dom:s})=>s.getBoundingClientRect()),space:this.view.state.facet(xm).tooltipSpace(this.view),scaleX:t,scaleY:e,makeAbsolute:n}}writeMeasure(t){var e;if(t.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let l of this.manager.tooltipViews)l.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:s}=t,o=[];for(let l=0;l=Math.min(n.bottom,r.bottom)||f.rightMath.min(n.right,r.right)+.1)){c.style.top=dd;continue}let h=a.arrow?u.dom.querySelector(".cm-tooltip-arrow"):null,p=h?7:0,m=d.right-d.left,x=(e=Vk.get(u))!==null&&e!==void 0?e:d.bottom-d.top,g=u.offset||a7,y=this.view.textDirection==mn.LTR,w=d.width>r.right-r.left?y?r.left:r.right-d.width:y?Math.max(r.left,Math.min(f.left-(h?14:0)+g.x,r.right-m)):Math.min(Math.max(r.left,f.left-m+(h?14:0)-g.x),r.right-m),k=this.above[l];!a.strictSide&&(k?f.top-x-p-g.yr.bottom)&&k==r.bottom-f.bottom>f.top-r.top&&(k=this.above[l]=!k);let b=(k?f.top-r.top:r.bottom-f.bottom)-p;if(bw&&A.topS&&(S=k?A.top-x-2-p:A.bottom+p+2);if(this.position=="absolute"?(c.style.top=(S-t.parent.top)/s+"px",Uk(c,(w-t.parent.left)/i)):(c.style.top=S/s+"px",Uk(c,w/i)),h){let A=f.left+(y?g.x:-g.x)-(w+14-7);h.style.left=A/i+"px"}u.overlap!==!0&&o.push({left:w,top:S,right:T,bottom:S+x}),c.classList.toggle("cm-tooltip-above",k),c.classList.toggle("cm-tooltip-below",!k),u.positioned&&u.positioned(t.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let t of this.manager.tooltipViews)t.dom.style.top=dd}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Uk(t,e){let n=parseInt(t.style.left,10);(isNaN(n)||Math.abs(e-n)>1)&&(t.style.left=e+"px")}const l7=Ke.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),a7={x:0,y:0},rM=je.define({enables:[nM,l7]}),Bh=je.define({combine:t=>t.reduce((e,n)=>e.concat(n),[])});class _p{static create(e){return new _p(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new tM(e,Bh,(n,r)=>this.createHostedView(n,r),n=>n.dom.remove())}createHostedView(e,n){let r=e.create(this.view);return r.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(r.dom,n?n.dom.nextSibling:this.dom.firstChild),this.mounted&&r.mount&&r.mount(this.view),r}mount(e){for(let n of this.manager.tooltipViews)n.mount&&n.mount(e);this.mounted=!0}positioned(e){for(let n of this.manager.tooltipViews)n.positioned&&n.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let n of this.manager.tooltipViews)(e=n.destroy)===null||e===void 0||e.call(n)}passProp(e){let n;for(let r of this.manager.tooltipViews){let i=r[e];if(i!==void 0){if(n===void 0)n=i;else if(n!==i)return}}return n}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const u7=rM.compute([Bh],t=>{let e=t.facet(Bh);return e.length===0?null:{pos:Math.min(...e.map(n=>n.pos)),end:Math.max(...e.map(n=>{var r;return(r=n.end)!==null&&r!==void 0?r:n.pos})),create:_p.create,above:e[0].above,arrow:e.some(n=>n.arrow)}}),c7=je.define();class f7{constructor(e,n,r,i,s,o){this.view=e,this.source=n,this.field=r,this.locked=i,this.setHover=s,this.hoverTime=o,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||n.xo.right+e.defaultCharacterWidth)return;let l=e.bidiSpans(e.state.doc.lineAt(i)).find(u=>u.from<=i&&u.to>=i),a=l&&l.dir==mn.RTL?-1:1;s=n.x{if(l&&!(Array.isArray(l)&&!l.length)){let a=Array.isArray(l)?l:[l];i&&this.locked.set(a,i),e.dispatch({effects:this.setHover.of(a)})}};if(s&&"then"in s){let l=this.pending={pos:n};s.then(a=>{this.pending==l&&(this.pending=null,o(a))},a=>li(e.state,a,"hover tooltip"))}else o(s)}get tooltip(){let e=this.view.plugin(nM),n=e?e.manager.tooltips.findIndex(r=>r.create==_p.create):-1;return n>-1?e.manager.tooltipViews[n]:null}mousemove(e){var n,r;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:s}=this;if(i.length&&!this.locked.has(i)&&s&&!d7(s.dom,e)||this.pending){let{pos:o}=i[0]||this.pending,l=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:o;(o==l?this.view.posAtCoords(this.lastMove)!=o:!h7(this.view,o,l,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:n}=this;if(n.length&&!this.locked.has(n)){let{tooltip:r}=this;r&&r.dom.contains(e.relatedTarget)?this.watchTooltipLeave(r.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let n=r=>{e.removeEventListener("mouseleave",n);let{active:i}=this;i.length&&!this.locked.has(i)&&!this.view.dom.contains(r.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",n)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const hd=4;function d7(t,e){let{left:n,right:r,top:i,bottom:s}=t.getBoundingClientRect(),o;if(o=t.querySelector(".cm-tooltip-arrow")){let l=o.getBoundingClientRect();i=Math.min(l.top,i),s=Math.max(l.bottom,s)}return e.clientX>=n-hd&&e.clientX<=r+hd&&e.clientY>=i-hd&&e.clientY<=s+hd}function h7(t,e,n,r,i,s){let o=t.scrollDOM.getBoundingClientRect(),l=t.documentTop+t.documentPadding.top+t.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,l)=e&&a<=n}function p7(t,e={}){let n=qt.define(),r=new WeakMap,i=ms.define({create(){return[]},update(o,l){let a=r.get(o);if(o.length&&(e.hideOnChange&&(l.docChanged||l.selection)?o=[]:a&&a(l)?o=[]:e.hideOn&&(o=o.filter(u=>!e.hideOn(l,u)))),l.docChanged&&o.length){let u=[];for(let c of o){let f=l.changes.mapPos(c.pos,-1,Sr.TrackDel);if(f!=null){let d=Object.assign(Object.create(null),c);d.pos=f,d.end!=null&&(d.end=l.changes.mapPos(d.end)),u.push(d)}}o=u}for(let u of l.effects)u.is(n)&&(o=u.value,a=void 0),(u.is(g7)&&!u.value||u.value==i)&&(o=[]);return o.length&&a&&r.set(o,a),o},provide:o=>Bh.from(o)});const s=gi.define(o=>new f7(o,t,i,r,n,e.hoverTime||300));return{active:i,extension:[i,s,c7.of(s),u7]}}const g7=qt.define(),Kk=je.define({combine(t){let e,n;for(let r of t)e=e||r.topContainer,n=n||r.bottomContainer;return{topContainer:e,bottomContainer:n}}}),m7=gi.fromClass(class{constructor(t){this.input=t.state.facet(ky),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(t));let e=t.state.facet(Kk);this.top=new pd(t,!0,e.topContainer),this.bottom=new pd(t,!1,e.bottomContainer),this.top.sync(this.panels.filter(n=>n.top)),this.bottom.sync(this.panels.filter(n=>!n.top));for(let n of this.panels)n.dom.classList.add("cm-panel"),n.mount&&n.mount()}update(t){let e=t.state.facet(Kk);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new pd(t.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new pd(t.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=t.state.facet(ky);if(n!=this.input){let r=n.filter(a=>a),i=[],s=[],o=[],l=[];for(let a of r){let u=this.specs.indexOf(a),c;u<0?(c=a(t.view),l.push(c)):(c=this.panels[u],c.update&&c.update(t)),i.push(c),(c.top?s:o).push(c)}this.specs=r,this.panels=i,this.top.sync(s),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let r of this.panels)r.update&&r.update(t)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:t=>Ke.scrollMargins.of(e=>{let n=e.plugin(t);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class pd{constructor(e,n,r){this.view=e,this.top=n,this.container=r,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let n of this.panels)n.destroy&&e.indexOf(n)<0&&n.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom";let n=this.container||this.view.dom;n.insertBefore(this.dom,this.top?n.firstChild:null)}let e=this.dom.firstChild;for(let n of this.panels)if(n.dom.parentNode==this.dom){for(;e!=n.dom;)e=Xk(e);e=e.nextSibling}else this.dom.insertBefore(n.dom,e);for(;e;)e=Xk(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function Xk(t){let e=t.nextSibling;return t.remove(),e}const ky=je.define({enables:m7});class Ha extends xl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Ha.prototype.elementClass="";Ha.prototype.toDOM=void 0;Ha.prototype.mapMode=Sr.TrackBefore;Ha.prototype.startSide=Ha.prototype.endSide=-1;Ha.prototype.point=!0;const iM=1024;let y7=0;class bm{constructor(e,n){this.from=e,this.to=n}}class Tt{constructor(e={}){this.id=y7++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Or.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class fc{constructor(e,n,r,i=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=i}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const v7=Object.create(null);class Or{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):v7,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new Or(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}Or.none=new Or("",Object.create(null),0,8);class Cw{constructor(e){this.types=e;for(let n=0;n0;for(let a=this.cursor(o|gn.IncludeAnonymous);;){let u=!1;if(a.from<=s&&a.to>=i&&(!l&&a.type.isAnonymous||n(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&r&&(l||!a.type.isAnonymous)&&r(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Aw(Or.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Tn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Tn(Or.none,n,r,i)))}static build(e){return k7(e)}}Tn.empty=new Tn(Or.none,[],[],0);class Tw{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Tw(this.buffer,this.index)}}class Io{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Or.none}toString(){let e=[];for(let n=0;n0));a=o[a+3]);return l}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let l=e,a=0;l=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function zc(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?l.length:-1;e!=u;e+=n){let c=l[e],f=a[e]+o.from,d;if(!(!(s&gn.EnterBracketed&&c instanceof Tn&&(d=fc.get(c))&&!d.overlay&&d.bracketed&&r>=f&&r<=f+c.length)&&!sM(i,r,f,f+c.length))){if(c instanceof Io){if(s&gn.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,n,r-f,i);if(h>-1)return new mo(new w7(o,c,e,f),null,h)}else if(s&gn.IncludeAnonymous||!c.type.isAnonymous||Ew(c)){let h;if(!(s&gn.IgnoreMounts)&&(h=fc.get(c))&&!h.overlay)return new di(h.tree,f,e,o);let p=new di(c,f,e,o);return s&gn.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?c.children.length-1:0,n,r,i,s)}}}if(s&gn.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let i;if(!(r&gn.IgnoreOverlays)&&(i=fc.get(this._tree))&&i.overlay){let s=e-this.from,o=r&gn.EnterBracketed&&i.bracketed;for(let{from:l,to:a}of i.overlay)if((n>0||o?l<=s:l=s:a>s))return new di(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function qk(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function Sy(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class w7{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class mo extends oM{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new mo(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&gn.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new mo(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new mo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new mo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Tn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function lM(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;sn.from||o.to=e){let l=new di(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(zc(l,e,n,!1))}}return i?lM(i):r}class Cy{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~gn.EnterBracketed,e instanceof di)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof di?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&gn.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&gn.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&gn.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let l=r._tree.children[s];if(this.mode&gn.IncludeAnonymous||l instanceof Io||!l.type.isAnonymous||Ew(l))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i=0;s--){if(s<0)return Sy(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function Ew(t){return t.children.some(e=>e instanceof Io||!e.type.isAnonymous||Ew(e))}function k7(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=iM,reused:s=[],minRepeatType:o=r.types.length}=t,l=Array.isArray(n)?new Tw(n,n.length):n,a=r.types,u=0,c=0;function f(b,S,T,A,M,O){let{id:_,start:P,end:I,size:D}=l,ee=c,ie=u;if(D<0)if(l.next(),D==-1){let N=s[_];T.push(N),A.push(P-b);return}else if(D==-3){u=_;return}else if(D==-4){c=_;return}else throw new RangeError(`Unrecognized record size: ${D}`);let te=a[_],W,V,R=P-b;if(I-P<=i&&(V=x(l.pos-S,M))){let N=new Uint16Array(V.size-V.skip),L=l.pos-V.size,H=N.length;for(;l.pos>L;)H=g(V.start,N,H);W=new Io(N,I-V.start,r),R=V.start-b}else{let N=l.pos-D;l.next();let L=[],H=[],G=_>=o?_:-1,B=0,le=I;for(;l.pos>N;)G>=0&&l.id==G&&l.size>=0?(l.end<=le-i&&(p(L,H,P,B,l.end,le,G,ee,ie),B=L.length,le=l.end),l.next()):O>2500?d(P,N,L,H):f(P,N,L,H,G,O+1);if(G>=0&&B>0&&B-1&&B>0){let me=h(te,ie);W=Aw(te,L,H,0,L.length,0,I-P,me,me)}else W=m(te,L,H,I-P,ee-I,ie)}T.push(W),A.push(R)}function d(b,S,T,A){let M=[],O=0,_=-1;for(;l.pos>S;){let{id:P,start:I,end:D,size:ee}=l;if(ee>4)l.next();else{if(_>-1&&I<_)break;_<0&&(_=D-i),M.push(P,I,D),O++,l.next()}}if(O){let P=new Uint16Array(O*4),I=M[M.length-2];for(let D=M.length-3,ee=0;D>=0;D-=3)P[ee++]=M[D],P[ee++]=M[D+1]-I,P[ee++]=M[D+2]-I,P[ee++]=ee;T.push(new Io(P,M[2]-I,r)),A.push(I-b)}}function h(b,S){return(T,A,M)=>{let O=0,_=T.length-1,P,I;if(_>=0&&(P=T[_])instanceof Tn){if(!_&&P.type==b&&P.length==M)return P;(I=P.prop(Tt.lookAhead))&&(O=A[_]+P.length+I)}return m(b,T,A,M,O,S)}}function p(b,S,T,A,M,O,_,P,I){let D=[],ee=[];for(;b.length>A;)D.push(b.pop()),ee.push(S.pop()+T-M);b.push(m(r.types[_],D,ee,O-M,P-O,I)),S.push(M-T)}function m(b,S,T,A,M,O,_){if(O){let P=[Tt.contextHash,O];_=_?[P].concat(_):[P]}if(M>25){let P=[Tt.lookAhead,M];_=_?[P].concat(_):[P]}return new Tn(b,S,T,A,_)}function x(b,S){let T=l.fork(),A=0,M=0,O=0,_=T.end-i,P={size:0,start:0,skip:0};e:for(let I=T.pos-b;T.pos>I;){let D=T.size;if(T.id==S&&D>=0){P.size=A,P.start=M,P.skip=O,O+=4,A+=4,T.next();continue}let ee=T.pos-D;if(D<0||ee=o?4:0,te=T.start;for(T.next();T.pos>ee;){if(T.size<0)if(T.size==-3||T.size==-4)ie+=4;else break e;else T.id>=o&&(ie+=4);T.next()}M=te,A+=D,O+=ie}return(S<0||A==b)&&(P.size=A,P.start=M,P.skip=O),P.size>4?P:void 0}function g(b,S,T){let{id:A,start:M,end:O,size:_}=l;if(l.next(),_>=0&&A4){let I=l.pos-(_-4);for(;l.pos>I;)T=g(b,S,T)}S[--T]=P,S[--T]=O-b,S[--T]=M-b,S[--T]=A}else _==-3?u=A:_==-4&&(c=A);return T}let y=[],w=[];for(;l.pos>0;)f(t.start||0,t.bufferStart||0,y,w,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:y.length?w[0]+y[0].length:0;return new Tn(a[t.topID],y.reverse(),w.reverse(),k)}const Yk=new WeakMap;function Bd(t,e){if(!t.isAnonymous||e instanceof Io||e.type!=t)return 1;let n=Yk.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Tn)){n=1;break}n+=Bd(t,r)}Yk.set(e,n)}return n}function Aw(t,e,n,r,i,s,o,l,a){let u=0;for(let p=r;p=c)break;S+=T}if(w==k+1){if(S>c){let T=p[k];h(T.children,T.positions,0,T.children.length,m[k]+y);continue}f.push(p[k])}else{let T=m[w-1]+p[w-1].length-b;f.push(Aw(t,p,m,k,w,b,T,null,a))}d.push(b+y-s)}}return h(e,n,r,i,0),(l||a)(f,d,o)}class hl{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new hl(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=r)for(;o&&o.from=d.from||f<=d.to||u){let h=Math.max(d.from,a)-u,p=Math.min(d.to,f)-u;d=h>=p?null:new hl(h,p,d.tree,d.offset+u,l>0,!!c)}if(d&&i.push(d),o.to>f)break;o=snew bm(i.from,i.to)):[new bm(0,0)]:[new bm(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class S7{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});let C7=0;class ii{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=C7++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof ii&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new ii(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new jh(e);return r=>r.modified.indexOf(n)>-1?r:jh.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let T7=0;class jh{constructor(e){this.name=e,this.instances=[],this.id=T7++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(l=>l.base==e&&E7(n,l.modified));if(r)return r;let i=[],s=new ii(e.name,i,e,n);for(let l of n)l.instances.push(s);let o=A7(n);for(let l of e.set)if(!l.modified.length)for(let a of o)i.push(jh.get(l,a));return s}}function E7(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function A7(t){let e=[[]];for(let n=0;nr.length-n.length)}function uM(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,l=i;for(let f=0;;){if(l=="..."&&f>0&&f+3==i.length){o=1;break}let d=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!d)throw new RangeError("Invalid path: "+i);if(s.push(d[0]=="*"?"":d[0][0]=='"'?JSON.parse(d[0]):d[0]),f+=d[0].length,f==i.length)break;let h=i[f++];if(f==i.length&&h=="!"){o=0;break}if(h!="/")throw new RangeError("Invalid path: "+i);l=i.slice(f)}let a=s.length-1,u=s[a];if(!u)throw new RangeError("Invalid path: "+i);let c=new Bc(r,o,a>0?s.slice(0,a):null);e[u]=c.sort(e[u])}}return cM.add(e)}const cM=new Tt({combine(t,e){let n,r,i;for(;t||e;){if(!t||e&&t.depth>=e.depth?(i=e,e=e.next):(i=t,t=t.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let s=new Bc(i.tags,i.mode,i.context);n?n.next=s:r=s,n=s}return r}});class Bc{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=i;for(let l of s)for(let a of l.set){let u=n[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:r}}function M7(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function R7(t,e,n,r=0,i=t.length){let s=new O7(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class O7{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:l,to:a}=e;if(l>=r||a<=n)return;o.isTop&&(s=this.highlighters.filter(h=>!h.scope||h.scope(o)));let u=i,c=P7(e)||Bc.empty,f=M7(s,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(i+=(i?" ":"")+f)),this.startSpan(Math.max(n,l),u),c.opaque)return;let d=e.tree&&e.tree.prop(Tt.mounted);if(d&&d.overlay){let h=e.node.enter(d.overlay[0].from+l,1),p=this.highlighters.filter(x=>!x.scope||x.scope(d.tree.type)),m=e.firstChild();for(let x=0,g=l;;x++){let y=x=w||!e.nextSibling())););if(!y||w>r)break;g=y.to+l,g>n&&(this.highlightRange(h.cursor(),Math.max(n,y.from+l),Math.min(r,g),"",p),this.startSpan(Math.min(r,g),u))}m&&e.parent()}else if(e.firstChild()){d&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),u)}while(e.nextSibling());e.parent()}}}function P7(t){let e=t.type.prop(cM);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const we=ii.define,md=we(),so=we(),Jk=we(so),Qk=we(so),oo=we(),yd=we(oo),km=we(oo),Qi=we(),Yo=we(Qi),Yi=we(),Ji=we(),Ty=we(),Iu=we(Ty),vd=we(),Ue={comment:md,lineComment:we(md),blockComment:we(md),docComment:we(md),name:so,variableName:we(so),typeName:Jk,tagName:we(Jk),propertyName:Qk,attributeName:we(Qk),className:we(so),labelName:we(so),namespace:we(so),macroName:we(so),literal:oo,string:yd,docString:we(yd),character:we(yd),attributeValue:we(yd),number:km,integer:we(km),float:we(km),bool:we(oo),regexp:we(oo),escape:we(oo),color:we(oo),url:we(oo),keyword:Yi,self:we(Yi),null:we(Yi),atom:we(Yi),unit:we(Yi),modifier:we(Yi),operatorKeyword:we(Yi),controlKeyword:we(Yi),definitionKeyword:we(Yi),moduleKeyword:we(Yi),operator:Ji,derefOperator:we(Ji),arithmeticOperator:we(Ji),logicOperator:we(Ji),bitwiseOperator:we(Ji),compareOperator:we(Ji),updateOperator:we(Ji),definitionOperator:we(Ji),typeOperator:we(Ji),controlOperator:we(Ji),punctuation:Ty,separator:we(Ty),bracket:Iu,angleBracket:we(Iu),squareBracket:we(Iu),paren:we(Iu),brace:we(Iu),content:Qi,heading:Yo,heading1:we(Yo),heading2:we(Yo),heading3:we(Yo),heading4:we(Yo),heading5:we(Yo),heading6:we(Yo),contentSeparator:we(Qi),list:we(Qi),quote:we(Qi),emphasis:we(Qi),strong:we(Qi),link:we(Qi),monospace:we(Qi),strikethrough:we(Qi),inserted:we(),deleted:we(),changed:we(),invalid:we(),meta:vd,documentMeta:we(vd),annotation:we(vd),processingInstruction:we(vd),definition:ii.defineModifier("definition"),constant:ii.defineModifier("constant"),function:ii.defineModifier("function"),standard:ii.defineModifier("standard"),local:ii.defineModifier("local"),special:ii.defineModifier("special")};for(let t in Ue){let e=Ue[t];e instanceof ii&&(e.name=t)}fM([{tag:Ue.link,class:"tok-link"},{tag:Ue.heading,class:"tok-heading"},{tag:Ue.emphasis,class:"tok-emphasis"},{tag:Ue.strong,class:"tok-strong"},{tag:Ue.keyword,class:"tok-keyword"},{tag:Ue.atom,class:"tok-atom"},{tag:Ue.bool,class:"tok-bool"},{tag:Ue.url,class:"tok-url"},{tag:Ue.labelName,class:"tok-labelName"},{tag:Ue.inserted,class:"tok-inserted"},{tag:Ue.deleted,class:"tok-deleted"},{tag:Ue.literal,class:"tok-literal"},{tag:Ue.string,class:"tok-string"},{tag:Ue.number,class:"tok-number"},{tag:[Ue.regexp,Ue.escape,Ue.special(Ue.string)],class:"tok-string2"},{tag:Ue.variableName,class:"tok-variableName"},{tag:Ue.local(Ue.variableName),class:"tok-variableName tok-local"},{tag:Ue.definition(Ue.variableName),class:"tok-variableName tok-definition"},{tag:Ue.special(Ue.variableName),class:"tok-variableName2"},{tag:Ue.definition(Ue.propertyName),class:"tok-propertyName tok-definition"},{tag:Ue.typeName,class:"tok-typeName"},{tag:Ue.namespace,class:"tok-namespace"},{tag:Ue.className,class:"tok-className"},{tag:Ue.macroName,class:"tok-macroName"},{tag:Ue.propertyName,class:"tok-propertyName"},{tag:Ue.operator,class:"tok-operator"},{tag:Ue.comment,class:"tok-comment"},{tag:Ue.meta,class:"tok-meta"},{tag:Ue.invalid,class:"tok-invalid"},{tag:Ue.punctuation,class:"tok-punctuation"}]);var Sm;const pa=new Tt;function I7(t){return je.define({combine:t?e=>e.concat(t):void 0})}const N7=new Tt;class Di{constructor(e,n,r=[],i=""){this.data=e,this.name=i,$t.prototype.hasOwnProperty("tree")||Object.defineProperty($t.prototype,"tree",{get(){return hs(this)}}),this.parser=n,this.extension=[Va.of(this),$t.languageData.of((s,o,l)=>{let a=Zk(s,o,l),u=a.type.prop(pa);if(!u)return[];let c=s.facet(u),f=a.type.prop(N7);if(f){let d=a.resolve(o-a.from,l);for(let h of f)if(h.test(d,s)){let p=s.facet(h.facet);return h.type=="replace"?p:p.concat(c)}}return c})].concat(r)}isActiveAt(e,n,r=-1){return Zk(e,n,r).type.prop(pa)==this.data}findRegions(e){let n=e.facet(Va);if((n==null?void 0:n.data)==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(s,o)=>{if(s.prop(pa)==this.data){r.push({from:o,to:o+s.length});return}let l=s.prop(Tt.mounted);if(l){if(l.tree.prop(pa)==this.data){if(l.overlay)for(let a of l.overlay)r.push({from:a.from+o,to:a.to+o});else r.push({from:o,to:o+s.length});return}else if(l.overlay){let a=r.length;if(i(l.tree,l.overlay[0].from+o),r.length>a)return}}for(let a=0;ar.isTop?n:void 0)]}),e.name)}configure(e,n){return new Hh(this.data,this.parser.configure(e),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function hs(t){let e=t.field(Di.state,!1);return e?e.tree:Tn.empty}class D7{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,n){let r=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Nu=null;class Wh{constructor(e,n,r=[],i,s,o,l,a){this.parser=e,this.state=n,this.fragments=r,this.tree=i,this.treeLen=s,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new Wh(e,n,[],Tn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new D7(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=Tn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let i=Date.now()+e;e=()=>Date.now()>i}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(hl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Nu;Nu=this;try{return e()}finally{Nu=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=eS(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:i,treeLen:s,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,d)=>a.push({fromA:u,toA:c,fromB:f,toB:d})),r=hl.applyChanges(r,a),i=Tn.empty,s=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=eS(this.fragments,i,s),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends aM{createParse(n,r,i){let s=i[0].from,o=i[i.length-1].to;return{parsedPos:s,advance(){let a=Nu;if(a){for(let u of i)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new Tn(Or.none,[],[],o-s)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Nu}}function eS(t,e,n){return hl.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class Wa{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new Wa(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=Wh.create(e.facet(Va).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Wa(r)}}Di.state=ms.define({create:Wa.init,update(t,e){for(let n of e.effects)if(n.is(Di.setState))return n.value;return e.startState.facet(Va)!=e.state.facet(Va)?Wa.init(e.state):t.apply(e)}});let dM=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(dM=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const Cm=typeof navigator<"u"&&(!((Sm=navigator.scheduling)===null||Sm===void 0)&&Sm.isInputPending)?()=>navigator.scheduling.isInputPending():null,_7=gi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let n=this.view.state.field(Di.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(Di.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=dM(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEndi+1e3,a=s.context.work(()=>Cm&&Cm()||Date.now()>o,i+(l?0:1e5));this.chunkBudget-=Date.now()-n,(a||this.chunkBudget<=0)&&(s.context.takeTree(),this.view.dispatch({effects:Di.setState.of(new Wa(s.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(s.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>li(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Va=je.define({combine(t){return t.length?t[0]:null},enables:t=>[Di.state,_7,Ke.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]});class L7{constructor(e,n=[]){this.language=e,this.support=n,this.extension=[e,n]}}const F7=je.define(),Mw=je.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Vh(t){let e=t.facet(Mw);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Uh(t,e){let n="",r=t.tabSize,i=t.facet(Mw)[0];if(i==" "){for(;e>=r;)n+=" ",e-=r;i=" "}for(let s=0;s=e?$7(t,n,e):null}class Lp{constructor(e,n={}){this.state=e,this.options=n,this.unit=Vh(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:s}=this.options;return i!=null&&i>=r.from&&i<=r.to?s&&i==e?{text:"",from:e}:(n<0?i-1&&(s+=o-this.countColumn(r,r.search(/\S|$/))),s}countColumn(e,n=e.length){return Rp(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:i}=this.lineAt(e,n),s=this.options.overrideIndentation;if(s){let o=s(i);if(o>-1)return o}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const pM=new Tt;function $7(t,e,n){let r=e.resolveStack(n),i=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let s=[];for(let o=i;o&&!(o.fromr.node.to||o.from==r.node.from&&o.type==r.node.type);o=o.parent)s.push(o);for(let o=s.length-1;o>=0;o--)r={node:s[o],next:r}}return gM(r,t,n)}function gM(t,e,n){for(let r=t;r;r=r.next){let i=B7(r.node);if(i)return i(Rw.create(e,n,r))}return 0}function z7(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function B7(t){let e=t.type.prop(pM);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(Tt.closedBy))){let i=t.lastChild,s=i&&r.indexOf(i.name)>-1;return o=>V7(o,!0,1,void 0,s&&!z7(o)?i.from:void 0)}return t.parent==null?j7:null}function j7(){return 0}class Rw extends Lp{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new Rw(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(H7(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return gM(this.context.next,this.base,this.pos)}}function H7(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function W7(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let i=t.options.simulateBreak,s=t.state.doc.lineAt(n.from),o=i==null||i<=s.from?s.to:Math.min(s.to,i);for(let l=n.to;;){let a=e.childAfter(l);if(!a||a==r)return null;if(!a.type.isSkipped){if(a.from>=o)return null;let u=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+u}}l=a.to}}function V7(t,e,n,r,i){let s=t.textAfter,o=s.match(/^\s*/)[0].length,l=r&&s.slice(o,o+r.length)==r||i==t.pos+o,a=W7(t);return a?l?t.column(a.from):t.column(a.to):t.baseIndent+(l?0:t.unit*n)}function tS({except:t,units:e=1}={}){return n=>{let r=t&&t.test(n.textAfter);return n.baseIndent+(r?0:e*n.unit)}}const U7=new Tt;function K7(t){let e=t.firstChild,n=t.lastChild;return e&&e.tol.prop(pa)==o.data:o?l=>l==o:void 0,this.style=fM(e.map(l=>({tag:l.tag,class:l.class||i(Object.assign({},l,{tag:null}))})),{all:s}).style,this.module=r?new Ro(r):null,this.themeType=n.themeType}static define(e,n){return new Fp(e,n||{})}}const Ey=je.define(),X7=je.define({combine(t){return t.length?[t[0]]:null}});function Tm(t){let e=t.facet(Ey);return e.length?e:t.facet(X7)}function nS(t,e){let n=[q7],r;return t instanceof Fp&&(t.module&&n.push(Ke.styleModule.of(t.module)),r=t.themeType),r?n.push(Ey.computeN([Ke.darkTheme],i=>i.facet(Ke.darkTheme)==(r=="dark")?[t]:[])):n.push(Ey.of(t)),n}class G7{constructor(e){this.markCache=Object.create(null),this.tree=hs(e.state),this.decorations=this.buildDeco(e,Tm(e.state)),this.decoratedTo=e.viewport.to}update(e){let n=hs(e.state),r=Tm(e.state),i=r!=Tm(e.startState),{viewport:s}=e.view,o=e.changes.mapPos(this.decoratedTo,1);n.length=s.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=o):(n!=this.tree||e.viewportChanged||i)&&(this.tree=n,this.decorations=this.buildDeco(e.view,r),this.decoratedTo=s.to)}buildDeco(e,n){if(!n||!this.tree.length)return Vt.none;let r=new $a;for(let{from:i,to:s}of e.visibleRanges)R7(this.tree,n,(o,l,a)=>{r.add(o,l,this.markCache[a]||(this.markCache[a]=Vt.mark({class:a})))},i,s);return r.finish()}}const q7=cw.high(gi.fromClass(G7,{decorations:t=>t.decorations})),Y7=1e4,J7="()[]{}",Q7=new Tt;function Ay(t,e,n){let r=t.prop(e<0?Tt.openedBy:Tt.closedBy);if(r)return r;if(t.name.length==1){let i=n.indexOf(t.name);if(i>-1&&i%2==(e<0?1:0))return[n[i+e]]}return null}function My(t){let e=t.type.prop(Q7);return e?e(t.node):t}function ga(t,e,n,r={}){let i=r.maxScanDistance||Y7,s=r.brackets||J7,o=hs(t),l=o.resolveInner(e,n);for(let a=l;a;a=a.parent){let u=Ay(a.type,n,s);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return Z7(t,e,n,a,c,u,s)}}return eK(t,e,n,o,l.type,i,s)}function Z7(t,e,n,r,i,s,o){let l=r.parent,a={from:i.from,to:i.to},u=0,c=l==null?void 0:l.cursor();if(c&&(n<0?c.childBefore(r.from):c.childAfter(r.to)))do if(n<0?c.to<=r.from:c.from>=r.to){if(u==0&&s.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:n<0?e-1:e,to:n>0?e+1:e},c=t.doc.iterRange(e,n>0?t.doc.length:0),f=0;for(let d=0;!c.next().done&&d<=s;){let h=c.value;n<0&&(d+=h.length);let p=e+d*n;for(let m=n>0?0:h.length-1,x=n>0?h.length:-1;m!=x;m+=n){let g=o.indexOf(h[m]);if(!(g<0||r.resolveInner(p+m,1).type!=i))if(g%2==0==n>0)f++;else{if(f==1)return{start:u,end:{from:p+m,to:p+m+1},matched:g>>1==a>>1};f--}}n>0&&(d+=h.length)}return c.done?{start:u,matched:!1}:null}const tK=Object.create(null),rS=[Or.none],iS=[],sS=Object.create(null),nK=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])nK[t]=rK(tK,e);function Em(t,e){iS.indexOf(t)>-1||(iS.push(t),console.warn(e))}function rK(t,e){let n=[];for(let l of e.split(" ")){let a=[];for(let u of l.split(".")){let c=t[u]||Ue[u];c?typeof c=="function"?a.length?a=a.map(c):Em(u,`Modifier ${u} used at start of tag`):a.length?Em(u,`Tag ${u} used as modifier`):a=Array.isArray(c)?c:[c]:Em(u,`Unknown highlighting tag ${u}`)}for(let u of a)n.push(u)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),i=r+" "+n.map(l=>l.id),s=sS[i];if(s)return s.id;let o=sS[i]=Or.define({id:rS.length,name:r,props:[uM({[r]:n})]});return rS.push(o),o.id}mn.RTL,mn.LTR;const iK=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=Pw(t.state,n.from);return r.line?sK(t):r.block?lK(t):!1};function Ow(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=t(e,n);return i?(r(n.update(i)),!0):!1}}const sK=Ow(cK,0),oK=Ow(mM,0),lK=Ow((t,e)=>mM(t,e,uK(e)),0);function Pw(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const Du=50;function aK(t,{open:e,close:n},r,i){let s=t.sliceDoc(r-Du,r),o=t.sliceDoc(i,i+Du),l=/\s*$/.exec(s)[0].length,a=/^\s*/.exec(o)[0].length,u=s.length-l;if(s.slice(u-e.length,u)==e&&o.slice(a,a+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,f;i-r<=2*Du?c=f=t.sliceDoc(r,i):(c=t.sliceDoc(r,r+Du),f=t.sliceDoc(i-Du,i));let d=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(f)[0].length,p=f.length-h-n.length;return c.slice(d,d+e.length)==e&&f.slice(p,p+n.length)==n?{open:{pos:r+d+e.length,margin:/\s/.test(c.charAt(d+e.length))?1:0},close:{pos:i-h-n.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function uK(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),i=n.to<=r.to?r:t.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let s=e.length-1;s>=0&&e[s].to>r.from?e[s].to=i.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return e}function mM(t,e,n=e.selection.ranges){let r=n.map(s=>Pw(e,s.from).block);if(!r.every(s=>s))return null;let i=n.map((s,o)=>aK(e,r[o],s.from,s.to));if(t!=2&&!i.every(s=>s))return{changes:e.changes(n.map((s,o)=>i[o]?[]:[{from:s.from,insert:r[o].open+" "},{from:s.to,insert:" "+r[o].close}]))};if(t!=1&&i.some(s=>s)){let s=[];for(let o=0,l;oi&&(s==o||o>f.from)){i=f.from;let d=/^\s*/.exec(f.text)[0].length,h=d==f.length,p=f.text.slice(d,d+u.length)==u?d:-1;ds.comment<0&&(!s.empty||s.single))){let s=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of r)(f||!c)&&s.push({from:l.from+u,insert:a+" "});let o=e.changes(s);return{changes:o,selection:e.selection.map(o,1)}}else if(t!=1&&r.some(s=>s.comment>=0)){let s=[];for(let{line:o,comment:l,token:a}of r)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,s.push({from:u,to:c})}return{changes:s}}return null}const Ry=Fo.define(),fK=Fo.define(),dK=je.define(),yM=je.define({combine(t){return iA(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,i)=>e(r,i)||n(r,i)})}}),vM=ms.define({create(){return ls.empty},update(t,e){let n=e.state.facet(yM),r=e.annotation(Ry);if(r){let a=Er.fromTransaction(e,r.selection),u=r.side,c=u==0?t.undone:t.done;return a?c=Kh(c,c.length,n.minDepth,a):c=bM(c,e.startState.selection),new ls(u==0?r.rest:c,u==0?c:r.rest)}let i=e.annotation(fK);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation($n.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let s=Er.fromTransaction(e),o=e.annotation($n.time),l=e.annotation($n.userEvent);return s?t=t.addChanges(s,o,l,n,e):e.selection&&(t=t.addSelection(e.startState.selection,o,l,n.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new ls(t.done.map(Er.fromJSON),t.undone.map(Er.fromJSON))}});function hK(t={}){return[vM,yM.of(t),Ke.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?wM:e.inputType=="historyRedo"?Oy:null;return r?(e.preventDefault(),r(n)):!1}})]}function $p(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let i=n.field(vM,!1);if(!i)return!1;let s=i.pop(t,n,e);return s?(r(s),!0):!1}}const wM=$p(0,!1),Oy=$p(1,!1),pK=$p(0,!0),gK=$p(1,!0);class Er{constructor(e,n,r,i,s){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=i,this.selectionsAfter=s}setSelAfter(e){return new Er(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new Er(e.changes&&_n.fromJSON(e.changes),[],e.mapped&&ds.fromJSON(e.mapped),e.startSelection&&he.fromJSON(e.startSelection),e.selectionsAfter.map(he.fromJSON))}static fromTransaction(e,n){let r=ui;for(let i of e.startState.facet(dK)){let s=i(e);s.length&&(r=r.concat(s))}return!r.length&&e.changes.empty?null:new Er(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,ui)}static selection(e){return new Er(void 0,ui,void 0,void 0,e)}}function Kh(t,e,n,r){let i=e+1>n+20?e-n-1:0,s=t.slice(i,e);return s.push(r),s}function mK(t,e){let n=[],r=!1;return t.iterChangedRanges((i,s)=>n.push(i,s)),e.iterChangedRanges((i,s,o,l)=>{for(let a=0;a=u&&o<=c&&(r=!0)}}),r}function yK(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function xM(t,e){return t.length?e.length?t.concat(e):t:e}const ui=[],vK=200;function bM(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-vK));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Kh(t,t.length-1,1e9,n.setSelAfter(r)))}else return[Er.selection([e])]}function wK(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Am(t,e){if(!t.length)return t;let n=t.length,r=ui;for(;n;){let i=xK(t[n-1],e,r);if(i.changes&&!i.changes.empty||i.effects.length){let s=t.slice(0,n);return s[n-1]=i,s}else e=i.mapped,n--,r=i.selectionsAfter}return r.length?[Er.selection(r)]:ui}function xK(t,e,n){let r=xM(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):ui,n);if(!t.changes)return Er.selection(r);let i=t.changes.map(e),s=e.mapDesc(t.changes,!0),o=t.mapped?t.mapped.composeDesc(s):s;return new Er(i,qt.mapEffects(t.effects,e),o,t.startSelection.map(s),r)}const bK=/^(input\.type|delete)($|\.)/;class ls{constructor(e,n,r=0,i=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=i}isolate(){return this.prevTime?new ls(this.done,this.undone):this}addChanges(e,n,r,i,s){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!r||bK.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):zp(n,e))}function lr(t){return t.textDirectionAt(t.state.selection.main.head)==mn.LTR}const SM=t=>kM(t,!lr(t)),CM=t=>kM(t,lr(t));function TM(t,e){return Wi(t,n=>n.empty?t.moveByGroup(n,e):zp(n,e))}const SK=t=>TM(t,!lr(t)),CK=t=>TM(t,lr(t));function TK(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Bp(t,e,n){let r=hs(t).resolveInner(e.head),i=n?Tt.closedBy:Tt.openedBy;for(let a=e.head;;){let u=n?r.childAfter(a):r.childBefore(a);if(!u)break;TK(t,u,i)?r=u:a=n?u.to:u.from}let s=r.type.prop(i),o,l;return s&&(o=n?ga(t,r.from,1):ga(t,r.to,-1))&&o.matched?l=n?o.end.to:o.end.from:l=n?r.to:r.from,he.cursor(l,n?-1:1)}const EK=t=>Wi(t,e=>Bp(t.state,e,!lr(t))),AK=t=>Wi(t,e=>Bp(t.state,e,lr(t)));function EM(t,e){return Wi(t,n=>{if(!n.empty)return zp(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const AM=t=>EM(t,!1),MM=t=>EM(t,!0);function RM(t){let e=t.scrollDOM.clientHeighto.empty?t.moveVertically(o,e,n.height):zp(o,e));if(i.eq(r.selection))return!1;let s;if(n.selfScroll){let o=t.coordsAtPos(r.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+n.marginTop,u=l.bottom-n.marginBottom;o&&o.top>a&&o.bottomOM(t,!1),Py=t=>OM(t,!0);function $o(t,e,n){let r=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,n);if(i.head==e.head&&i.head!=(n?r.to:r.from)&&(i=t.moveToLineBoundary(e,n,!1)),!n&&i.head==r.from&&r.length){let s=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;s&&e.head!=r.from+s&&(i=he.cursor(r.from+s))}return i}const MK=t=>Wi(t,e=>$o(t,e,!0)),RK=t=>Wi(t,e=>$o(t,e,!1)),OK=t=>Wi(t,e=>$o(t,e,!lr(t))),PK=t=>Wi(t,e=>$o(t,e,lr(t))),IK=t=>Wi(t,e=>he.cursor(t.lineBlockAt(e.head).from,1)),NK=t=>Wi(t,e=>he.cursor(t.lineBlockAt(e.head).to,-1));function DK(t,e,n){let r=!1,i=ru(t.selection,s=>{let o=ga(t,s.head,-1)||ga(t,s.head,1)||s.head>0&&ga(t,s.head-1,1)||s.headDK(t,e);function mi(t,e,n){let r=ru(t.state.selection,i=>{i.undirectional&&i.head>=i.anchor!=e&&(i=he.range(i.head,i.anchor));let s=n(i);return he.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Hi(t.state,r)),!0)}function PM(t,e){return mi(t,e,n=>t.moveByChar(n,e))}const IM=t=>PM(t,!lr(t)),NM=t=>PM(t,lr(t));function DM(t,e){return mi(t,e,n=>t.moveByGroup(n,e))}const LK=t=>DM(t,!lr(t)),FK=t=>DM(t,lr(t)),$K=t=>{let e=!lr(t);return mi(t,e,n=>Bp(t.state,n,e))},zK=t=>{let e=lr(t);return mi(t,e,n=>Bp(t.state,n,e))};function _M(t,e){return mi(t,e,n=>t.moveVertically(n,e))}const LM=t=>_M(t,!1),FM=t=>_M(t,!0);function $M(t,e){return mi(t,e,n=>t.moveVertically(n,e,RM(t).height))}const lS=t=>$M(t,!1),aS=t=>$M(t,!0),BK=t=>mi(t,!0,e=>$o(t,e,!0)),jK=t=>mi(t,!1,e=>$o(t,e,!1)),HK=t=>{let e=!lr(t);return mi(t,e,n=>$o(t,n,e))},WK=t=>{let e=lr(t);return mi(t,e,n=>$o(t,n,e))},VK=t=>mi(t,!1,e=>he.cursor(t.lineBlockAt(e.head).from)),UK=t=>mi(t,!0,e=>he.cursor(t.lineBlockAt(e.head).to)),uS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:0})),!0),cS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.doc.length})),!0),fS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.selection.main.anchor,head:0})),!0),dS=({state:t,dispatch:e})=>(e(Hi(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),KK=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),XK=({state:t,dispatch:e})=>{let n=jp(t).map(({from:r,to:i})=>he.undirectionalRange(r,Math.min(i+1,t.doc.length)));return e(t.update({selection:he.create(n),userEvent:"select"})),!0},GK=({state:t,dispatch:e})=>{let n=ru(t.selection,r=>{let i=hs(t),s=i.resolveStack(r.from,1);if(r.empty){let o=i.resolveStack(r.from,-1);o.node.from>=s.node.from&&o.node.to<=s.node.to&&(s=o)}for(let o=s;o;o=o.next){let{node:l}=o;if((l.from=r.to||l.to>r.to&&l.from<=r.from)&&o.next)return he.undirectionalRange(l.from,l.to)}return r});return n.eq(t.selection)?!1:(e(Hi(t,n)),!0)};function zM(t,e){let{state:n}=t,r=n.selection,i=n.selection.ranges.slice();for(let s of n.selection.ranges){let o=n.doc.lineAt(s.head);if(e?o.to0)for(let l=s;;){let a=t.moveVertically(l,e);if(a.heado.to){i.some(u=>u.head==a.head)||i.push(a);break}else{if(a.head==l.head)break;l=a}}}return i.length==r.ranges.length?!1:(t.dispatch(Hi(n,he.create(i,i.length-1))),!0)}const qK=t=>zM(t,!1),YK=t=>zM(t,!0),JK=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=he.create([n.main]):n.main.empty||(r=he.create([he.cursor(n.main.head)])),r?(e(Hi(t,r)),!0):!1};function lf(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,i=r.changeByRange(s=>{let{from:o,to:l}=s;if(o==l){let a=e(s);ao&&(n="delete.forward",a=wd(t,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=wd(t,o,!1),l=wd(t,l,!0);return o==l?{range:s}:{changes:{from:o,to:l},range:he.cursor(o,oi(t)))r.between(e,e,(i,s)=>{ie&&(e=n?s:i)});return e}const BM=(t,e,n)=>lf(t,r=>{let i=r.from,{state:s}=t,o=s.doc.lineAt(i),l,a;if(n&&!e&&i>o.from&&iBM(t,!1,!0),jM=t=>BM(t,!0,!1),HM=(t,e)=>lf(t,n=>{let r=n.head,{state:i}=t,s=i.doc.lineAt(r),o=i.charCategorizer(r);for(let l=null;;){if(r==(e?s.to:s.from)){r==n.head&&s.number!=(e?i.doc.lines:1)&&(r+=e?1:-1);break}let a=sr(s.text,r-s.from,e)+s.from,u=s.text.slice(Math.min(r,a)-s.from,Math.max(r,a)-s.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||r!=n.head)&&(l=c),r=a}return r}),WM=t=>HM(t,!1),QK=t=>HM(t,!0),ZK=t=>lf(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headlf(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),tX=t=>lf(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:Dt.of(["",""])},range:he.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},rX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let i=r.from,s=t.doc.lineAt(i),o=i==s.from?i-1:sr(s.text,i-s.from,!1)+s.from,l=i==s.to?i+1:sr(s.text,i-s.from,!0)+s.from;return{changes:{from:o,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(o,i))},range:he.cursor(l)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function jp(t){let e=[],n=-1;for(let r of t.selection.ranges){let i=t.doc.lineAt(r.from),s=t.doc.lineAt(r.to);if(!r.empty&&r.to==s.from&&(s=t.doc.lineAt(r.to-1)),n>=i.number){let o=e[e.length-1];o.to=s.to,o.ranges.push(r)}else e.push({from:i.from,to:s.to,ranges:[r]});n=s.number+1}return e}function VM(t,e,n){if(t.readOnly)return!1;let r=[],i=[];for(let s of jp(t)){if(n?s.to==t.doc.length:s.from==0)continue;let o=t.doc.lineAt(n?s.to+1:s.from-1),l=o.length+1;if(n){r.push({from:s.to,to:o.to},{from:s.from,insert:o.text+t.lineBreak});for(let a of s.ranges)i.push(he.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)))}else{r.push({from:o.from,to:s.from},{from:s.to,insert:t.lineBreak+o.text});for(let a of s.ranges)i.push(he.range(a.anchor-l,a.head-l))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:he.create(i,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const iX=({state:t,dispatch:e})=>VM(t,e,!1),sX=({state:t,dispatch:e})=>VM(t,e,!0);function UM(t,e,n){if(t.readOnly)return!1;let r=[];for(let s of jp(t))n?r.push({from:s.from,insert:t.doc.slice(s.from,s.to)+t.lineBreak}):r.push({from:s.to,insert:t.lineBreak+t.doc.slice(s.from,s.to)});let i=t.changes(r);return e(t.update({changes:i,selection:t.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const oX=({state:t,dispatch:e})=>UM(t,e,!1),lX=({state:t,dispatch:e})=>UM(t,e,!0),aX=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(jp(e).map(({from:i,to:s})=>(i>0?i--:s{let s;if(t.lineWrapping){let o=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(s=o.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2)}return t.moveVertically(i,!0,s)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function uX(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=hs(t).resolveInner(e),r=n.childBefore(e),i=n.childAfter(e),s;return r&&i&&r.to<=e&&i.from>=e&&(s=r.type.prop(Tt.closedBy))&&s.indexOf(i.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}const hS=KM(!1),cX=KM(!0);function KM(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(i=>{let{from:s,to:o}=i,l=e.doc.lineAt(s),a=!t&&s==o&&uX(e,s);t&&(s=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new Lp(e,{simulateBreak:s,simulateDoubleBreak:!!a}),c=hM(u,s);for(c==null&&(c=Rp(/^\s*/.exec(e.doc.lineAt(s).text)[0],e.tabSize));ol.from&&s{let i=[];for(let o=r.from;o<=r.to;){let l=t.doc.lineAt(o);l.number>n&&(r.empty||r.to>l.from)&&(e(l,i,r),n=l.number),o=l.to+1}let s=t.changes(i);return{changes:i,range:he.range(s.mapPos(r.anchor,1),s.mapPos(r.head,1))}})}const fX=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new Lp(t,{overrideIndentation:s=>{let o=n[s];return o??-1}}),i=Iw(t,(s,o,l)=>{let a=hM(r,s.from);if(a==null)return;/\S/.test(s.text)||(a=0);let u=/^\s*/.exec(s.text)[0],c=Uh(t,a);(u!=c||l.fromt.readOnly?!1:(e(t.update(Iw(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Mw)})}),{userEvent:"input.indent"})),!0),GM=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Iw(t,(n,r)=>{let i=/^\s*/.exec(n.text)[0];if(!i)return;let s=Rp(i,t.tabSize),o=0,l=Uh(t,Math.max(0,s-Vh(t)));for(;o(t.setTabFocusMode(),!0),hX=[{key:"Ctrl-b",run:SM,shift:IM,preventDefault:!0},{key:"Ctrl-f",run:CM,shift:NM},{key:"Ctrl-p",run:AM,shift:LM},{key:"Ctrl-n",run:MM,shift:FM},{key:"Ctrl-a",run:IK,shift:VK},{key:"Ctrl-e",run:NK,shift:UK},{key:"Ctrl-d",run:jM},{key:"Ctrl-h",run:Iy},{key:"Ctrl-k",run:ZK},{key:"Ctrl-Alt-h",run:WM},{key:"Ctrl-o",run:nX},{key:"Ctrl-t",run:rX},{key:"Ctrl-v",run:Py}],pX=[{key:"ArrowLeft",run:SM,shift:IM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:SK,shift:LK,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:OK,shift:HK,preventDefault:!0},{key:"ArrowRight",run:CM,shift:NM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:CK,shift:FK,preventDefault:!0},{mac:"Cmd-ArrowRight",run:PK,shift:WK,preventDefault:!0},{key:"ArrowUp",run:AM,shift:LM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:uS,shift:fS},{mac:"Ctrl-ArrowUp",run:oS,shift:lS},{key:"ArrowDown",run:MM,shift:FM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:cS,shift:dS},{mac:"Ctrl-ArrowDown",run:Py,shift:aS},{key:"PageUp",run:oS,shift:lS},{key:"PageDown",run:Py,shift:aS},{key:"Home",run:RK,shift:jK,preventDefault:!0},{key:"Mod-Home",run:uS,shift:fS},{key:"End",run:MK,shift:BK,preventDefault:!0},{key:"Mod-End",run:cS,shift:dS},{key:"Enter",run:hS,shift:hS},{key:"Mod-a",run:KK},{key:"Backspace",run:Iy,shift:Iy,preventDefault:!0},{key:"Delete",run:jM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:WM,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:QK,preventDefault:!0},{mac:"Mod-Backspace",run:eX,preventDefault:!0},{mac:"Mod-Delete",run:tX,preventDefault:!0}].concat(hX.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),gX=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:EK,shift:$K},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:AK,shift:zK},{key:"Alt-ArrowUp",run:iX},{key:"Shift-Alt-ArrowUp",run:oX},{key:"Alt-ArrowDown",run:sX},{key:"Shift-Alt-ArrowDown",run:lX},{key:"Mod-Alt-ArrowUp",run:qK},{key:"Mod-Alt-ArrowDown",run:YK},{key:"Escape",run:JK},{key:"Mod-Enter",run:cX},{key:"Alt-l",mac:"Ctrl-l",run:XK},{key:"Mod-i",run:GK,preventDefault:!0},{key:"Mod-[",run:GM},{key:"Mod-]",run:XM},{key:"Mod-Alt-\\",run:fX},{key:"Shift-Mod-k",run:aX},{key:"Shift-Mod-\\",run:_K},{key:"Mod-/",run:iK},{key:"Alt-A",mac:"Ctrl-A",run:oK},{key:"Ctrl-m",mac:"Shift-Alt-m",run:dX}].concat(pX),mX={key:"Tab",run:XM,shift:GM};var pS={};class Xh{constructor(e,n,r,i,s,o,l,a,u,c=0,f){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new Xh(e,[],n,r,r,0,[],0,i?new gS(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(u==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizea;)this.stack.pop();this.reduceContext(i,u)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[o-4]==0&&this.buffer[o-1]>-1){if(n==r)return;if(this.buffer[o-2]>=n){this.buffer[o-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&(this.buffer[o-4]!=0||this.buffer[o-1]<0)){let l=!1;for(let a=o;a>0&&this.buffer[a-2]>r;a-=4)if(this.buffer[a-1]>=0){l=!0;break}if(l)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;this.pos=i;let l=o.stateFlag(s,1);!l&&(i>r||n<=o.maxNode)&&(this.reducePos=i),this.pushState(s,l?r:Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(n&&e.buffer[n-4]==0&&(n-=4);n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new Xh(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new yX(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;sa&1&&l==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-s;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=r(o,s+1);if(l!=null)return l}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n0&&this.emitLookAhead()}}class gS{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class yX{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class Gh{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Gh(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Gh(this.stack,this.pos,this.index)}}function xd(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),s+=a,l)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class jd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const mS=new jd;class vX{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mS,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;sr.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n=this.chunk2Pos&&rl.to&&(this.chunk2=this.chunk2.slice(0,l.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=mS,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class Aa{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;wX(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Aa.prototype.contextual=Aa.prototype.fallback=Aa.prototype.extend=!1;Aa.prototype.fallback=Aa.prototype.extend=!1;function wX(t,e,n,r,i,s){let o=0,l=1<0){let p=t[h];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||xX(p,e.token.value,i,s))){e.acceptToken(p);break}}let c=e.next,f=0,d=t[o+2];if(e.next<0&&d>f&&t[u+d*3-3]==65535){o=t[u+d*3-1];continue e}for(;f>1,p=u+h+(h<<1),m=t[p],x=t[p+1]||65536;if(c=x)f=h+1;else{o=t[p+2],e.advance();continue e}}break}}function yS(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function xX(t,e,n,r){let i=yS(n,r,e);return i<0||yS(n,r,t)e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class bX{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?vS(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?vS(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(s instanceof Tn){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class kX{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new jd)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let d=n;if(f.extended>-1&&(n=this.addActions(e,f.extended,f.end,n)),n=this.addActions(e,f.value,f.end,n),!c.extend&&(r=f,n>d))break}}for(;this.actions.length>n;)this.actions.pop();return a&&e.setLookAhead(a),!r&&e.pos==this.stream.end&&(r=new jd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new jd,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o=0&&r.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;se.bufferLength*4?new bX(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;on)r.push(l);else{if(this.advanceStack(l,r,e))continue;{i||(i=[],s=[]),i.push(l);let a=this.tokens.getMainToken(l);s.push(a.value,a.end)}}break}}if(!r.length){let o=i&&TX(i);if(o)return $r&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw $r&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return $r&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((l,a)=>a.score-l.score);r.length>o;)r.pop();r.some(l=>l.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)r.splice(a--,1);else{r.splice(o--,1);continue e}}}r.length>12&&(r.sort((o,l)=>l.score-o.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let o=1;o ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let u=e.curContext&&e.curContext.tracker.strict,c=u?e.curContext.hash:0;for(let f=this.fragments.nodeAt(i);f;){let d=this.parser.nodeSet.types[f.type.id]==f.type?s.getGoto(e.state,f.type.id):-1;if(d>-1&&f.length&&(!u||(f.prop(Tt.contextHash)||0)==c))return e.useNode(f,d),$r&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(f.type.id)})`),!0;if(!(f instanceof Tn)||f.children.length==0||f.positions[0]>0)break;let h=f.children[0];if(h instanceof Tn&&f.positions[0]==0)f=h;else break}}let l=s.stateSlot(e.state,4);if(l>0)return e.reduce(l),$r&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(l&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let a=this.tokens.getActions(e);for(let u=0;ui?n.push(p):r.push(p)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return wS(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o ":"";if(l.deadEnd&&(s||(s=!0,l.restart(),$r&&console.log(c+this.stackID(l)+" (restarted)"),this.advanceFully(l,r))))continue;let f=l.split(),d=c;for(let h=0;h<10&&f.forceReduce()&&($r&&console.log(d+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,r));h++)$r&&(d=this.stackID(f)+" -> ");for(let h of l.recoverByInsert(a))$r&&console.log(c+this.stackID(h)+" (via recover-insert)"),this.advanceFully(h,r);this.stream.end>l.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),$r&&console.log(c+this.stackID(l)+` (via recover-delete ${this.parser.getName(a)})`),wS(l,r)):(!i||i.scoree.topRules[l][1]),i=[];for(let l=0;l=0)s(c,a,l[u++]);else{let f=l[u+-c];for(let d=-c;d>0;d--)s(l[u++],a,f);u++}}}this.nodeSet=new Cw(n.map((l,a)=>Or.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:i[a],top:r.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=iM;let o=xd(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Aa(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new SX(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],l=o&1,a=i[s++];if(l&&r)return a;for(let u=s+(o>>1);s0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=As(this.data,s+2);else break;i=n(As(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=As(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(qh.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(l=>l.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=xS(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;sr)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.scoret.external(n,r)<<1|e}return t.get}const EX=uM({String:Ue.string,Number:Ue.number,"True False":Ue.bool,PropertyName:Ue.propertyName,Null:Ue.null,", :":Ue.separator,"[ ]":Ue.squareBracket,"{ }":Ue.brace}),AX=qh.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[EX],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),MX=()=>t=>{try{JSON.parse(t.state.doc.toString())}catch(e){if(!(e instanceof SyntaxError))throw e;const n=RX(e,t.state.doc);return[{from:n,message:e.message,severity:"error",to:n}]}return[]};function RX(t,e){let n;return(n=t.message.match(/at position (\d+)/))?Math.min(+n[1],e.length):(n=t.message.match(/at line (\d+) column (\d+)/))?Math.min(e.line(+n[1]).from+ +n[2]-1,e.length):0}const OX=Hh.define({name:"json",parser:AX.configure({props:[pM.add({Object:tS({except:/^\s*\}/}),Array:tS({except:/^\s*\]/})}),U7.add({"Object Array":K7})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function bS(){return new L7(OX)}class kS{constructor(e,n,r){this.from=e,this.to=n,this.diagnostic=r}}class il{constructor(e,n,r){this.diagnostics=e,this.panel=n,this.selected=r}static init(e,n,r){let i=r.facet(as).markerFilter;i&&(e=i(e,r));let s=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),o=new $a,l=[],a=0,u=r.doc.iter(),c=0,f=r.doc.length;for(let h=0;;){let p=h==s.length?null:s[h];if(!p&&!l.length)break;let m,x;if(l.length)m=a,x=l.reduce((w,k)=>Math.min(w,k.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;x=p.to,l.push(p),h++}for(;hw.from||w.to==m))l.push(w),h++,x=Math.min(w.to,x);else{x=Math.min(w.from,x);break}}x=Math.min(x,f);let g=!1;if(l.some(w=>w.from==m&&(w.to==x||x==f))&&(g=m==x,!g&&x-m<10)){let w=m-(c+u.value.length);w>0&&(u.next(w),c=m);for(let k=m;;){if(k>=x){g=!0;break}if(!u.lineBreak&&c+u.value.length>k)break;k=c+u.value.length,c+=u.value.length,u.next()}}let y=VX(l);if(g)o.add(m,m,Vt.widget({widget:new BX(y),diagnostics:l.slice()}));else{let w=l.reduce((k,b)=>b.markClass?k+" "+b.markClass:k,"");o.add(m,x,Vt.mark({class:"cm-lintRange cm-lintRange-"+y+w,diagnostics:l.slice(),inclusiveEnd:l.some(k=>k.to>x)}))}if(a=x,a==f)break;for(let w=0;w{if(!(e&&o.diagnostics.indexOf(e)<0))if(!r)r=new kS(i,s,e||o.diagnostics[0]);else{if(o.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new kS(r.from,s,r.diagnostic)}}),r}function PX(t,e){let n=e.pos,r=e.end||n,i=t.state.facet(as).hideOn(t,n,r);if(i!=null)return i;let s=t.startState.doc.lineAt(e.pos);return!!(t.effects.some(o=>o.is(Nw))||t.changes.touchesRange(s.from,Math.max(s.to,r)))}function IX(t,e){return t.field(_i,!1)?e:e.concat(qt.appendConfig.of(ZM))}function NX(t,e){return{effects:IX(t,[Nw.of(e)])}}const Nw=qt.define(),qM=qt.define(),YM=qt.define(),_i=ms.define({create(){return new il(Vt.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let n=t.diagnostics.map(e.changes),r=null,i=t.panel;if(t.selected){let s=e.changes.mapPos(t.selected.from,1);r=Ua(n,t.selected.diagnostic,s)||Ua(n,null,s)}!n.size&&i&&e.state.facet(as).autoPanel&&(i=null),t=new il(n,i,r)}for(let n of e.effects)if(n.is(Nw)){let r=e.state.facet(as).autoPanel?n.value.length?Yh.open:null:t.panel;t=il.init(n.value,r,e.state)}else n.is(qM)?t=new il(t.diagnostics,n.value?Yh.open:null,t.selected):n.is(YM)&&(t=new il(t.diagnostics,t.panel,n.value));return t},provide:t=>[ky.from(t,e=>e.panel),Ke.decorations.from(t,e=>e.diagnostics)]}),DX=Vt.mark({class:"cm-lintRange cm-lintRange-active"});function _X(t,e,n){let{diagnostics:r}=t.state.field(_i),i,s=-1,o=-1;r.between(e-(n<0?1:0),e+(n>0?1:0),(a,u,{spec:c})=>{if(e>=a&&e<=u&&(a==u||(e>a||n>0)&&(eQM(t,n,!1)))}const SS=t=>{let e=t.state.field(_i,!1);return!e||!e.panel?!1:(t.dispatch({effects:qM.of(!1)}),!0)},FX=gi.fromClass(class{constructor(t){this.view=t,this.timeout=-1,this.set=!0;let{delay:e}=t.state.facet(as);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let t=Date.now();if(tPromise.resolve(r(this.view))),r=>{this.view.state.doc==e.doc&&this.view.dispatch(NX(this.view.state,r.reduce((i,s)=>i.concat(s))))},r=>{li(this.view.state,r)})}}update(t){let e=t.state.facet(as);(t.docChanged||e!=t.startState.facet(as)||e.needsRefresh&&e.needsRefresh(t))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function $X(t,e,n){let r=[],i=-1;for(let s of t)s.then(o=>{r.push(o),clearTimeout(i),r.length==t.length?e(r):i=setTimeout(()=>e(r),200)},n)}const as=je.define({combine(t){return{sources:t.map(e=>e.source).filter(e=>e!=null),...iA(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:CS,tooltipFilter:CS,needsRefresh:(e,n)=>e?n?r=>e(r)||n(r):e:n,hideOn:(e,n)=>e?n?(r,i,s)=>e(r,i,s)||n(r,i,s):e:n,autoPanel:(e,n)=>e||n})}}});function CS(t,e){return t?e?(n,r)=>e(t(n,r),r):t:e}function zX(t,e={}){return[as.of({source:t,config:e}),FX,ZM]}function JM(t){let e=[];if(t)e:for(let{name:n}of t){for(let r=0;rs.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("")}return e}function QM(t,e,n){var r;let i=n?JM(e.actions):[];return ns("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},ns("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(r=e.actions)===null||r===void 0?void 0:r.map((s,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let p=Ua(t.state.field(_i).diagnostics,e);p&&s.apply(t,p.from,p.to)},{name:u}=s,c=i[o]?u.indexOf(i[o]):-1,f=c<0?u:[u.slice(0,c),ns("u",u.slice(c,c+1)),u.slice(c+1)],d=s.markClass?" "+s.markClass:"";return ns("button",{type:"button",class:"cm-diagnosticAction"+d,onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${i[o]})"`}.`},f)}),e.source&&ns("div",{class:"cm-diagnosticSource"},e.source))}class BX extends nu{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return ns("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class TS{constructor(e,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=QM(e,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class Yh{constructor(e){this.view=e,this.items=[];let n=i=>{if(!(i.ctrlKey||i.altKey||i.metaKey)){if(i.keyCode==27)SS(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:s}=this.items[this.selectedIndex],o=JM(s.actions);for(let l=0;l{for(let s=0;sSS(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(_i).selected;if(!e)return-1;for(let n=0;n{for(let c of u.diagnostics){if(o.has(c))continue;o.add(c);let f=-1,d;for(let h=r;hr&&(this.items.splice(r,f-r),i=!0)),n&&d.diagnostic==n.diagnostic?d.dom.hasAttribute("aria-selected")||(d.dom.setAttribute("aria-selected","true"),s=d):d.dom.hasAttribute("aria-selected")&&d.dom.removeAttribute("aria-selected"),r++}});r({sel:s.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let u=a.height/this.list.offsetHeight;l.topa.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync()}sync(){let e=this.list.firstChild;function n(){let r=e;e=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;e!=r.dom;)n();e=r.dom.nextSibling}else this.list.insertBefore(r.dom,e);for(;e;)n()}moveSelection(e){if(this.selectedIndex<0)return;let n=this.view.state.field(_i),r=Ua(n.diagnostics,this.items[e].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:YM.of(r)})}static open(e){return new Yh(e)}}function jX(t,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(t)}')`}function bd(t){return jX(``,'width="6" height="3"')}const HX=Ke.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:bd("#f11")},".cm-lintRange-warning":{backgroundImage:bd("orange")},".cm-lintRange-info":{backgroundImage:bd("#999")},".cm-lintRange-hint":{backgroundImage:bd("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function WX(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function VX(t){let e="hint",n=1;for(let r of t){let i=WX(r.severity);i>n&&(n=i,e=r.severity)}return e}const UX=p7(_X,{hideOn:PX}),ZM=[_i,Ke.decorations.compute([_i],t=>{let{selected:e,panel:n}=t.field(_i);return!e||!n||e.from==e.to?Vt.none:Vt.set([DX.range(e.from,e.to)])}),UX,HX],KX=512*1024,ES=512*1024,eR=2e6;function XX(t,e){if(t.length<=e)return t;const n=t.lastIndexOf(` -`,e);return n>e*.5?t.slice(0,n):t.slice(0,e)}const GX=t=>t.state.doc.length>KX?[]:MX()(t);function AS(t){return Fp.define([{tag:Ue.propertyName,color:t?"#7dd3fc":"#0369a1"},{tag:Ue.string,color:t?"#86efac":"#15803d"},{tag:Ue.number,color:t?"#fcd34d":"#b45309"},{tag:Ue.bool,color:t?"#d8b4fe":"#7e22ce"},{tag:Ue.null,color:t?"#a1a1aa":"#71717a"}])}const qX=Ke.theme({"&":{height:"100%",fontSize:"13px",backgroundColor:"transparent"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:"inherit",lineHeight:"1.5rem",overflow:"auto"},".cm-gutters":{display:"none"},".cm-activeLine":{backgroundColor:"transparent"},".cm-content":{caretColor:"currentColor",fontFamily:"inherit",letterSpacing:"-0.025em"},".cm-placeholder":{color:"var(--color-muted-foreground)"}});function tR({value:t,onChange:e,editable:n,lintJson:r=!0,dark:i,placeholder:s,testId:o="json-editor",className:l,onReady:a}){const u=v.useRef(null),c=v.useRef(null),f=v.useRef(e);f.current=e;const d=v.useRef(i),h=v.useRef(null),p=v.useRef(null),m=v.useRef(null),x=n??e!==void 0,g=v.useRef(x),y=v.useRef(r),w=t.length>ES,k=v.useRef(w),b=!x&&t.length>eR,S=b?XX(t,ES):t,T=v.useRef(!1),A=v.useCallback((M,O,_)=>M?[Ke.updateListener.of(P=>{var I;P.docChanged&&!T.current&&((I=f.current)==null||I.call(f,P.state.doc.toString()))}),...O||!_?[]:[zX(GX,{delay:300})]]:[$t.readOnly.of(!0),Ke.editable.of(!1)],[]);return v.useEffect(()=>{const M=u.current;if(!M)return;const O=new dl,_=new dl,P=new dl,I=$t.create({doc:S,extensions:[P.of(w||!r?[]:bS()),Ke.lineWrapping,hK(),eM.of([...gX,...kK,mX]),qX,O.of(nS(AS(i))),_.of(A(x,w,r)),...s?[s7(s)]:[]]}),D=new Ke({state:I,parent:M});return h.current=O,p.current=_,m.current=P,a==null||a(D),c.current=D,()=>{D.destroy(),c.current=null}},[]),v.useEffect(()=>{const M=c.current;if(!M)return;const O=m.current,_=p.current,P=[];(w!==k.current||r!==y.current)&&(k.current=w,y.current=r,O&&P.push(O.reconfigure(w||!r?[]:bS())),_&&P.push(_.reconfigure(A(x,w,r))));const I=M.state.doc.toString();if(!(I===S&&P.length===0)){T.current=!0;try{M.dispatch({...I!==S?{changes:{from:0,to:M.state.doc.length,insert:S}}:{},...P.length>0?{effects:P}:{}})}finally{T.current=!1}}},[S,w,r,x,A]),v.useEffect(()=>{const M=c.current,O=p.current;!M||!O||x!==g.current&&(g.current=x,M.dispatch({effects:O.reconfigure(A(x,w,r))}))},[x,w,r,A]),v.useEffect(()=>{const M=c.current;if(!M||i===d.current)return;d.current=i;const O=h.current;O&&M.dispatch({effects:O.reconfigure(nS(AS(i)))})},[i]),E.jsxs("div",{"data-testid":o,className:hr("flex min-h-0 flex-1 flex-col overflow-hidden font-mono",l),children:[b?E.jsx("div",{"data-testid":"large-output-preview-banner",role:"status",className:"border-b border-border bg-muted/40 px-5 py-1.5 font-sans text-xs text-muted-foreground",children:"Showing first 512 KB preview in editor — Copy and Download include the full output"}):null,E.jsx("div",{ref:u,className:"min-h-0 flex-1 overflow-hidden px-5 py-4"})]})}function nR({title:t,meta:e,actions:n,status:r,children:i}){return E.jsxs("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col",children:[E.jsxs("div",{className:"flex min-h-[42px] flex-shrink-0 flex-wrap items-center justify-between gap-x-2 gap-y-1.5 border-b border-border px-3.5 py-2 max-md:gap-2 md:min-h-12 md:py-1.5 md:pr-2.5 md:pl-3.5 lg:gap-x-3 lg:pr-3 lg:pl-5",children:[E.jsxs("div",{className:"flex items-center gap-2 lg:gap-3",children:[E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground",children:t}),e?E.jsx("span",{"data-testid":"pane-meta",className:"text-xs tabular-nums text-muted-foreground/70",children:e}):null]}),E.jsx("div",{className:"flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1",children:n})]}),E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:i}),r?E.jsxs("div",{"data-testid":"pane-status",className:r.kind==="error"?"flex-shrink-0 px-3.5 pb-2 text-xs text-destructive":"flex-shrink-0 whitespace-pre-line px-3.5 pb-2 text-xs text-muted-foreground",role:"status",children:[r.message,r.action]}):null]})}const ul="inline-flex h-7 cursor-pointer items-center gap-1.5 rounded-md px-2 text-[13px] font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-3.5";var Ny={exports:{}};(function(t,e){(function(){var n="We could not detect the separator.",r="Empty CSV. Please provide something.",i="Could not detect header. Ensure first row cotains your column headers.",s=[",",";"," "],o=!0,l={",":"comma",";":"semicolon"," ":"tab","|":"pipe"};function a(d){var h={},p;return s.forEach(function(m,x){var g=new RegExp(m,"g");h[m]=(d.match(g)||[]).length,p=!p||h[m]>h[p]?m:p}),p}function u(d){for(var h={},p=0;p=0;p--){var m=d[p];h[m]>0&&(m=m+"__"+h[m]--),x.unshift(m)}return x}function c(d,h){if(h||(h={}),d.length==0)throw r;var p=h.separator||a(d);if(!p)throw n;var m=[];try{o=h.trim!==!1;var m=f.parse(d,l[p])}catch(te){var x=d.lastIndexOf(` -`,te.offset),g=d.indexOf(` -`,te.offset),y=d.substring(x>=-1?x:0,g>-1?g:d.length);throw te.message+" On line "+te.line+" and column "+te.column+`. -`+y}if(h.transpose){for(var w=0,k=0;kw&&(w=m[k].length);for(var b=new Array(w),S=0;Sy&&(y=g,w=[]),w.push(R))}function b(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=","}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function S(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=";"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function T(){var R,N,L,H;return L=g,H=g,R=function(G){return ee="|"}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function A(){var R,N,L,H;return L=g,H=g,R=function(G){return ee=" "}()?"":null,R!==null?(N=M(),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G,B){return B}(L,R[1])),R===null&&(g=L),R}function M(){var R,N,L,H,G,B,le,me,ye;for(B=g,le=g,R=[],/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));N!==null;)R.push(N),/^[\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[\\n\\r]"));if(R!==null)if(N=O(),N!==null){if(L=[],me=g,ye=g,/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]")),G!==null)for(H=[];G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));else H=null;for(H!==null?(G=O(),G!==null?H=[H,G]:(H=null,g=ye)):(H=null,g=ye),H!==null&&(H=function(oe,be){return be}(me,H[1])),H===null&&(g=me);H!==null;){if(L.push(H),me=g,ye=g,/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]")),G!==null)for(H=[];G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));else H=null;H!==null?(G=O(),G!==null?H=[H,G]:(H=null,g=ye)):(H=null,g=ye),H!==null&&(H=function(oe,be){return be}(me,H[1])),H===null&&(g=me)}if(L!==null){for(H=[],/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));G!==null;)H.push(G),/^[\n\r]/.test(p.charAt(g))?(G=p.charAt(g),g++):(G=null,k("[\\n\\r]"));H!==null?R=[R,N,L,H]:(R=null,g=le)}else R=null,g=le}else R=null,g=le;else R=null,g=le;return R!==null&&(R=function(oe,be,Ce){return Ce.unshift(be),Ce}(B,R[1],R[2])),R===null&&(g=B),R}function O(){var R,N,L,H,G,B,le,me,ye;if(B=g,le=g,R=_(),R!==null){for(N=[],me=g,ye=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(oe,be){return be==ee}(g,L)?"":null,H!==null?(G=_(),G!==null?L=[L,H,G]:(L=null,g=ye)):(L=null,g=ye)):(L=null,g=ye),L!==null&&(L=function(oe,be,Ce){return Ce}(me,L[0],L[2])),L===null&&(g=me);L!==null;)N.push(L),me=g,ye=g,p.length>g?(L=p.charAt(g),g++):(L=null,k("any character")),L!==null?(H=function(oe,be){return be==ee}(g,L)?"":null,H!==null?(G=_(),G!==null?L=[L,H,G]:(L=null,g=ye)):(L=null,g=ye)):(L=null,g=ye),L!==null&&(L=function(oe,be,Ce){return Ce}(me,L[0],L[2])),L===null&&(g=me);N!==null?(L=function(oe,be,Ce){return!!be||Ce.length}(g,R,N)?"":null,L!==null?R=[R,N,L]:(R=null,g=le)):(R=null,g=le)}else R=null,g=le;return R!==null&&(R=function(oe,be,Ce){return Ce.unshift(be),Ce}(B,R[0],R[1])),R===null&&(g=B),R}function _(){var R,N,L,H,G,B;if(H=g,G=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null){for(N=[],L=P();L!==null;)N.push(L),L=P();N!==null?(p.charCodeAt(g)===34?(L='"',g++):(L=null,k('"\\""')),L!==null?R=[R,N,L]:(R=null,g=G)):(R=null,g=G)}else R=null,g=G;if(R!==null&&(R=function(le,me){return me.join("")}(H,R[1])),R===null&&(g=H),R===null){for(H=g,R=[],G=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(le,me){return me!=ee}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(le,me){return me}(G,N[0])),N===null&&(g=G);N!==null;)R.push(N),G=g,B=g,/^[^\n\r]/.test(p.charAt(g))?(N=p.charAt(g),g++):(N=null,k("[^\\n\\r]")),N!==null?(L=function(le,me){return me!=ee}(g,N)?"":null,L!==null?N=[N,L]:(N=null,g=B)):(N=null,g=B),N!==null&&(N=function(le,me){return me}(G,N[0])),N===null&&(g=G);R!==null&&(R=function(le,me){return(o?me.join("").trim():me.join("")).replace(/(^")|("$)/g,"")}(H,R)),R===null&&(g=H)}return R}function P(){var R,N,L,H;return L=g,H=g,p.charCodeAt(g)===34?(R='"',g++):(R=null,k('"\\""')),R!==null?(p.charCodeAt(g)===34?(N='"',g++):(N=null,k('"\\""')),N!==null?R=[R,N]:(R=null,g=H)):(R=null,g=H),R!==null&&(R=function(G){return'"'}()),R===null&&(g=L),R===null&&(/^[^"]/.test(p.charAt(g))?(R=p.charAt(g),g++):(R=null,k('[^"]'))),R}function I(R){R.sort();for(var N=null,L=[],H=0;H=2)try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}return{ok:!1}}function Li(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sG(t){return t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function oG(t){const e=(r,i,s)=>{for(const[o,l]of Object.entries(r)){const a=i?`${i}.${o}`:o;Li(l)&&Object.keys(l).length>0?e(l,a,s):Array.isArray(l)?s[a]=l.map(n):s[a]=l}},n=r=>{if(!Li(r))return r;const i={};return e(r,"",i),i};return Array.isArray(t)?t.map(n):Li(t)?n(t):t}function lG(t){const e=n=>{if(!Li(n))return n;const r={};for(const[i,s]of Object.entries(n))Array.isArray(s)&&s.length>0&&s.every(sG)?r[i]=s.join(", "):Array.isArray(s)?r[i]=s.map(e):r[i]=s;return r};return Array.isArray(t)?t.map(e):Li(t)?e(t):t}function aG(t){const e=t.trim().toLowerCase();return e==="true"||e==="1"||e==="yes"?!0:e==="false"||e==="0"||e==="no"?!1:t}function uG(t,e,n){if(n==="string")return t;if(n==="number")return RS(t);if(n==="boolean")return aG(t);if(e.parseJSON){const r=iG(t);if(r.ok&&typeof r.value!="number")return r.value}return e.parseNumbers?RS(t):t}function cG(t,e){const n=i=>{var o;const s={};for(const l of Object.keys(i)){const a=i[l];if(typeof a!="string"){s[l]=a;continue}if(e.emptyFields==="skip"&&a==="")continue;if(e.nullLiterals==="null"&&a==="NULL"){s[l]=null;continue}const u=(o=e.columnTypes)==null?void 0:o[l],c=uG(a,e,u);s[l]=c}return s};if(Array.isArray(t))return t.map(i=>Li(i)?n(i):i);const r={};for(const[i,s]of Object.entries(t))r[i]=Li(s)?n(s):s;return r}const fG=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function iR(t){const e=fG.exec(t);if(!e)return null;const n=e[1],r=e[2],i=e[3],s=e[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:t,prefix:n,index:o,notation:r!==void 0?"dot":"bracket",...s!==void 0?{subKey:s}:{}}:null}function _y(t){const e=new Set(t),n=new Map;for(const i of t){const s=iR(i);if(!s)continue;const o=n.get(s.prefix);o?o.push(s):n.set(s.prefix,[s])}const r=[];for(const[i,s]of n.entries()){if(e.has(i))continue;const o=s[0].subKey!==void 0,l=s[0].notation;if(s.some(h=>h.subKey!==void 0!==o||h.notation!==l))continue;const a=new Set;let u=!1;for(const h of s){const p=`${h.index}:${h.subKey??""}`;if(a.has(p)){u=!0;break}a.add(p)}if(u)continue;const c=Array.from(new Set(s.map(h=>h.index))).sort((h,p)=>h-p);if(c.length<2)continue;const f=c[0];f!==0&&f!==1||!c.every((h,p)=>h===f+p)||r.push({prefix:i,indices:c,columns:s.map(h=>h.column)})}return r}function OS(t,e){return t===void 0||t===""||e==="skip"&&t===null}function PS(t,e,n,r){const i=new Map,s=new Set,o=new Map;for(const a of n)if(a.columns.length!==0){i.set(a.columns[0],a);for(const u of a.columns)s.add(u);o.set(a.prefix,a.columns.map(u=>iR(u)).filter(u=>u!==null))}const l={};for(const a of e){const u=i.get(a);if(u){const c=o.get(u.prefix)??[];if(c.some(d=>d.subKey!==void 0)){const d=new Map;for(const p of c){const m=d.get(p.index);m?m.push(p):d.set(p.index,[p])}const h=[];for(const p of u.indices){const m=d.get(p)??[],x={};for(const g of m){if(!g.subKey)continue;const y=t[g.column];OS(y,r)||(x[g.subKey]=y)}Object.keys(x).length>0&&h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}else{const d=new Map;for(const p of c)d.set(p.index,p.column);const h=[];for(const p of u.indices){const m=d.get(p);if(!m)continue;const x=t[m];OS(x,r)||h.push(x)}if(h.length===0&&r==="skip")continue;l[u.prefix]=h}continue}s.has(a)||Object.prototype.hasOwnProperty.call(t,a)&&(l[a]=t[a])}return l}function dG(t,e,n){if(Array.isArray(t)&&Array.isArray(e)){const r=t[0];if(!Li(r))return e;const i=Object.keys(r),s=_y(i);return s.length===0?e:e.map(o=>Li(o)?PS(o,i,s,n):o)}if(!Array.isArray(t)&&!Array.isArray(e)){const r=Object.values(t)[0];if(!Li(r))return e;const i=Object.keys(r),s=_y(i);if(s.length===0)return e;const o={};for(const[l,a]of Object.entries(e))o[l]=Li(a)?PS(a,i,s,n):a;return o}return e}function IS(t,e={}){const n={parseNumbers:e.parseNumbers??!0,parseJSON:e.parseJSON??!1,emptyFields:e.emptyFields??"keep",nullLiterals:e.nullLiterals??"string",columnTypes:e.columnTypes},r=t.startsWith(MS)?t.slice(MS.length):t;try{const i=JX(r,{...e,parseNumbers:!1,parseJSON:!1,trim:!1}),s=cG(i,n);return e.collapseIndexedArrays!==!1&&!e.transpose?dG(i,s,n.emptyFields):s}catch(i){throw new Error(rR(i))}}function hG(t,e={}){try{const n=e.flatten?lG(oG(t)):t;return ZX(n,e)}catch(n){const r=rR(n);throw nG.some(i=>r.startsWith(i))?new eG(tG(r,e.flatten??!1)):new Error(r)}}function pG(t,e={}){return JSON.stringify(t,null,e.minify?void 0:2)}const zr={separator:"auto",parseNumbers:!0,parseJSON:!0,emptyFields:"keep",nullLiterals:"string",transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},NS=["data","items","results","records","rows"];function dc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function sR(t){const e=t.trim();if(e===""||!e.startsWith("{"))return[];let n;try{n=JSON.parse(e)}catch{return[]}if(!dc(n))return[];const r=Object.keys(n),i=new Set(NS),s=[...NS.filter(l=>r.includes(l)),...r.filter(l=>!i.has(l))],o=[];for(const l of s){const a=n[l];Array.isArray(a)&&a.length>0&&a.every(u=>dc(u))&&o.push({key:l,rowCount:a.length,unwrappedJson:JSON.stringify(a,null,2)})}return o}function Dw(t){const e=t.split(/\r?\n/).map(r=>r.trim()).filter(r=>r.length>0);if(e.length<2)return null;const n=[];for(const r of e)try{const i=JSON.parse(r);if(typeof i!="object"||i===null)return null;n.push(i)}catch{return null}return n}function gG(t){const e=t.trim();if(e==="")return null;let n;try{n=JSON.parse(e)}catch{const i=Dw(e);if(i===null)return null;n=i}const r=JSON.stringify(n,null,2);return e===r?{label:"Minify",nextInput:JSON.stringify(n)}:{label:"Format",nextInput:r}}function mG(t){const e=t.trim();if(e==="")return[];let n;try{n=JSON.parse(e)}catch{const o=Dw(e);if(o===null)return[];n=o}let r=[];if(Array.isArray(n)){if(n.length===0||!n.every(o=>dc(o)))return[];r=n}else if(dc(n)){if(sR(e).length>0)return[];r=[n]}else return[];const i=new Set,s=r.slice(0,50);for(const o of s)for(const[l,a]of Object.entries(o))(dc(a)||Array.isArray(a)&&a.length>0)&&i.add(l);return Array.from(i)}function yG(t){const e=n=>{const r=new Set;for(const i of n)i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).forEach(s=>r.add(s));return r};if(Array.isArray(t))return{rows:t.length,cols:e(t).size};if(t&&typeof t=="object"){const n=Object.values(t);return{rows:n.length,cols:e(n).size}}return{rows:0,cols:0}}const DS=t=>t==="auto"?void 0:t;function vG(t){let e=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((o,l)=>{if(s&&l===i.rowWidths.length-1)return;const a=i.rows[l];o===1&&a[0]===""||o!==i.headers.length&&n.push(o0?{warnings:u}:{}}}let r;try{r=JSON.parse(e)}catch(l){const a=Dw(e);if(a!==null)r=a;else return{ok:!1,error:`Invalid JSON — ${l instanceof Error?l.message:String(l)}`}}const i=DS(n.separator),s=hG(r,{separator:i,flatten:n.flatten}),o=nf(s,i);return{ok:!0,text:s,rows:o.rows.length,cols:o.headers.length}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function bG(){return E.jsx("svg",{"data-testid":"reading-spinner",className:"animate-spin",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,"aria-label":"Reading file",children:E.jsx("path",{d:"M21 12a9 9 0 1 1-6.2-8.56",strokeLinecap:"round"})})}function _u({label:t,testId:e,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:s=!1}){return E.jsxs("button",{type:"button","data-testid":e,"aria-label":t,disabled:r,onClick:n,title:t,className:ul,children:[i?E.jsx(i,{"aria-hidden":"true"}):null,i&&!s?E.jsx("span",{className:"hidden xl:inline",children:t}):t]})}function kG(t){const e=Math.min(t.length,65536);let n=!1,r=0;for(let i=0;i=3))return t.slice(0,i+1)}return t.slice(0,e)}function SG(t){const e=t.slice(0,3).map(r=>`.${r}`).join(", "),n=t.length-3;return n>0?`${e}, +${n} more`:e}function CG({format:t,input:e,onInputChange:n,onFile:r,onTryExample:i,onClear:s,onCopy:o,onCopySelection:l,onDownload:a,filename:u,reading:c,meta:f,error:d,notice:h,dark:p,delimiter:m,onCellCommit:x,canUndo:g=!1,canRedo:y=!1,onUndo:w,onRedo:k,collapseIndexedArrays:b=!0,onToggleCollapseIndexedArrays:S,columnTypes:T,onChangeColumnTypes:A,flatten:M=!1,onToggleFlatten:O}){const[_,P]=v.useState(!1),[I,D]=v.useState(!1),ee=v.useRef(0),ie=v.useRef(null),te=e.trim()==="",W=t==="CSV",V=v.useMemo(()=>{if(!W||te)return[];const oe=kG(e),be=nf(oe,m);return _y(be.headers.map(Ce=>Ce.trim()))},[W,te,e,m]),R=v.useMemo(()=>W||te?[]:sR(e),[W,te,e]),N=v.useMemo(()=>W||te?[]:mG(e),[W,te,e]),L=v.useMemo(()=>W||te?null:gG(e),[W,te,e]),H=oe=>{var be;oe.preventDefault(),Array.from(((be=oe.dataTransfer)==null?void 0:be.types)??[]).includes("Files")&&(ee.current++,D(!0))},G=()=>{ee.current=Math.max(0,ee.current-1),ee.current===0&&D(!1)},B=oe=>{var Ce,lt;oe.preventDefault(),ee.current=0,D(!1);const be=(lt=(Ce=oe.dataTransfer)==null?void 0:Ce.files)==null?void 0:lt[0];be&&r(be,"drop")},le=oe=>{var Ce;if(!te||oe.defaultPrevented||oe.target instanceof HTMLTextAreaElement||oe.target instanceof HTMLInputElement)return;const be=(Ce=oe.clipboardData)==null?void 0:Ce.getData("text/plain");be&&(oe.preventDefault(),n(be))},me=W?E.jsxs("span",{"data-testid":"view-mode",role:"group","aria-label":"View mode",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:[E.jsxs("button",{type:"button","data-testid":"view-table","aria-pressed":!_,onClick:()=>P(!1),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"text-muted-foreground hover:text-foreground":"bg-background text-foreground shadow-sm"),children:[E.jsx(pN,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Table"]}),E.jsxs("button",{type:"button","data-testid":"raw-toggle","aria-pressed":_,onClick:()=>P(!0),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-[7px] px-2 py-1 text-xs font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 lg:px-2.5",_?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[E.jsx(fx,{"aria-hidden":"true",className:"size-3.5 md:hidden lg:inline"}),"Raw"]})]}):null,ye=c&&u?E.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[E.jsx(bG,{})," ",u]}):u?f?`${u} · ${f}`:u:f;return E.jsx("div",{"data-testid":"input-pane",onDragEnter:H,onDragOver:oe=>oe.preventDefault(),onDragLeave:G,onDrop:B,onPaste:le,"data-drag-over":I||void 0,className:"relative flex min-h-0 min-w-0 flex-1 flex-col",children:E.jsxs(nR,{title:t,meta:ye,actions:E.jsxs(E.Fragment,{children:[me,W&&(g||y)?E.jsxs(E.Fragment,{children:[E.jsx("button",{type:"button","data-testid":"csv-undo-button","aria-label":"Undo",title:"Undo",disabled:!g,onClick:()=>w==null?void 0:w(),className:ul,children:E.jsx(bN,{"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":"csv-redo-button","aria-label":"Redo",title:"Redo",disabled:!y,onClick:()=>k==null?void 0:k(),className:ul,children:E.jsx(rN,{"aria-hidden":"true"})})]}):null,L?E.jsx(_u,{label:L.label,testId:"json-format-toggle",onClick:()=>n(L.nextInput),Icon:fx,keepLabelOnMobile:!0}):null,E.jsx("input",{ref:ie,type:"file","data-testid":"file-input",accept:W?".csv,.tsv,.txt,text/csv,text/tab-separated-values":".json,.txt,application/json",className:"hidden",onChange:oe=>{var Ce;const be=(Ce=oe.target.files)==null?void 0:Ce[0];be&&r(be,"picker"),oe.target.value=""}}),E.jsx(_u,{label:"Upload",testId:"upload",onClick:()=>{var oe;return(oe=ie.current)==null?void 0:oe.click()},Icon:pT}),E.jsx(_u,{label:"Copy",testId:"copy-input",onClick:o,Icon:Dv}),E.jsx(_u,{label:"Clear",testId:"clear-input",onClick:s,disabled:te,Icon:ph}),E.jsx(_u,{label:"Download",testId:"download-input",onClick:a,disabled:te,Icon:hT})]}),status:d?{kind:"error",message:d}:h?{kind:"notice",message:h}:null,children:[te?E.jsx(H9,{format:t,onIngest:n,onBrowse:()=>{var oe;return(oe=ie.current)==null?void 0:oe.click()},onTryExample:i}):W?E.jsxs(E.Fragment,{children:[V.length>0?E.jsxs("div",{"data-testid":"csv-indexed-array-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Indexed columns (${V.map(oe=>`${oe.prefix}[${oe.indices.length}]`).join(", ")}):`}),E.jsx("button",{type:"button","data-testid":"csv-indexed-array-pill","aria-pressed":b,onClick:()=>S==null?void 0:S(),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",b?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:b?"Arrays: .0, .1 → []":"Keep flat keys (.0, .1)"})]}):null,_?E.jsx("textarea",{"data-testid":"input-editor",value:e,onChange:oe=>n(oe.target.value),spellCheck:!1,className:"min-h-0 flex-1 resize-none bg-transparent px-5 py-4 font-mono text-[13px] leading-6 tracking-tight focus:outline-none"}):E.jsx(BE,{text:e,delimiter:m,testId:"input-table",dark:p,onCellCommit:x,onUndo:w,onRedo:k,onCopySelection:l,columnTypes:T,onChangeColumnTypes:A})]}):E.jsxs(E.Fragment,{children:[R.length>0?E.jsxs("div",{"data-testid":"json-unwrap-bar",className:"flex flex-shrink-0 flex-wrap items-center gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:"Nested array detected:"}),R.map(oe=>E.jsx("button",{type:"button","data-testid":`json-unwrap-pill-${oe.key}`,onClick:()=>n(oe.unwrappedJson),className:"inline-flex cursor-pointer items-center gap-1 rounded-md border border-border bg-background px-2 py-0.5 font-mono text-xs font-medium text-foreground shadow-2xs transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50",children:`Unwrap .${oe.key} (${oe.rowCount} ${oe.rowCount===1?"row":"rows"})`},oe.key))]}):null,N.length>0?E.jsxs("div",{"data-testid":"json-flatten-bar",className:"flex flex-shrink-0 flex-wrap items-center justify-between gap-1.5 border-b border-border bg-muted/30 px-3.5 py-1.5",children:[E.jsx("span",{className:"text-xs text-muted-foreground",children:`Nested keys (${N.length}):`}),E.jsx("button",{type:"button","data-testid":"json-flatten-pill","aria-pressed":M,onClick:()=>O==null?void 0:O(),className:hr("inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 font-mono text-xs font-medium shadow-2xs transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50",M?"border-border bg-background text-foreground hover:bg-muted":"border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground"),children:`${M?"Flattened":"Flatten"} nested keys (${SG(N)})`})]}):null,E.jsx(tR,{value:e,onChange:n,dark:p,testId:"input-editor"})]}),I?E.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-3 z-10 flex items-center justify-center rounded-xl border-2 border-dashed border-primary/50 bg-background/80 backdrop-blur-sm",children:E.jsx("p",{className:"text-sm font-medium text-foreground",children:"Drop file to import"})}):null]})})}const TG=/\.(csv|tsv|txt|json|ndjson|md|log)$/i;function EG(t){return t.type.startsWith("text/")||t.type==="application/json"?!0:TG.test(t.name)}const AG=[{value:"utf-8",label:"UTF-8"},{value:"windows-1252",label:"Windows-1252"}];async function _S(t,e){const n=t.stream().getReader();let r="";try{const i=[];let s=0;for(;s<2;){const{done:u,value:c}=await n.read();if(u)break;c&&c.byteLength>0&&(i.push(c),s+=c.byteLength)}let o=null;if(i.length===1)o=i[0];else if(i.length>1){o=new Uint8Array(s);let u=0;for(const c of i)o.set(c,u),u+=c.byteLength}let l=e;e==="utf-8"&&o&&o.byteLength>=2&&(o[0]===255&&o[1]===254?l="utf-16le":o[0]===254&&o[1]===255&&(l="utf-16be"));const a=new TextDecoder(l,{fatal:!1});for(o&&(r+=a.decode(o,{stream:!0}));;){const{done:u,value:c}=await n.read();if(u)break;r+=a.decode(c,{stream:!0})}return r+a.decode()}finally{n.releaseLock()}}function oR(t){const[e,n]=v.useState(()=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(t).matches);return v.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(t),i=s=>n(s.matches);return n(r.matches),r.addEventListener("change",i),()=>r.removeEventListener("change",i)},[t]),e}const lR=[{value:"auto",label:"Auto-detect"},{value:",",label:"Comma"},{value:";",label:"Semicolon"},{value:" ",label:"Tab"},{value:"|",label:"Pipe"}];function LS(){return E.jsx("div",{className:"hidden h-5 w-px shrink-0 bg-border fit:block","aria-hidden":"true"})}function MG(t,e){var i;const r=[e.separator==="auto"?"Auto":((i=lR.find(s=>s.value===e.separator))==null?void 0:i.label)??"Auto"];return t==="csv2json"?(e.parseNumbers&&r.push("Parse numbers"),e.parseJSON&&r.push("Parse JSON"),e.emptyFields==="skip"&&r.push("Skip empty"),e.nullLiterals==="null"&&r.push("NULL→null"),e.transpose&&r.push("Transpose"),e.hash&&r.push("Hash"),e.minify&&r.push("Minify")):e.flatten&&r.push("Flatten"),r.join(" · ")}function FS(){return"h-7 cursor-pointer appearance-none rounded-md border border-border bg-background py-0 pl-2.5 pr-6 text-[13px] font-medium text-foreground transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50"}function $S(){return E.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"pointer-events-none absolute top-1/2 right-1.5 size-3.5 -translate-y-1/2 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:E.jsx("path",{d:"m4 6 4 4 4-4",strokeLinecap:"round",strokeLinejoin:"round"})})}function zS({children:t}){return E.jsx("span",{className:"font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase",children:t})}function to({label:t,checked:e,onChange:n,hint:r}){return E.jsxs("span",{className:"inline-flex items-center gap-1",children:[E.jsxs("label",{className:"flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground",children:[E.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":t,onClick:()=>n(!e),className:"flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx("span",{className:hr("relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors",e?"border-primary bg-primary":"border-border bg-muted"),children:E.jsx("span",{className:hr("pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform",e?"translate-x-[15px]":"translate-x-[2px]")})})}),E.jsx("span",{className:"select-none",children:t})]}),r?E.jsx(Ly,{text:r}):null]})}function Ly({text:t}){const e=v.useId(),[n,r]=v.useState(!1);return E.jsxs("span",{className:"relative inline-flex items-center",children:[E.jsx("button",{type:"button","aria-label":"What does this option do?","aria-expanded":n,"aria-describedby":e,title:"What does this option do?",onClick:()=>r(i=>!i),className:"flex h-4 w-4 cursor-pointer items-center justify-center rounded-full border border-border text-[9px] font-semibold leading-none text-muted-foreground hover:text-foreground",children:"i"}),E.jsx("span",{"data-hint":!0,id:e,hidden:!n,className:"ml-1 text-muted-foreground",children:t})]})}function RG({direction:t,options:e,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:s}){const[o,l]=v.useState(!1),a=v.useRef(null),u=v.useRef(null),c=oR("(min-width: 98.5rem)"),f=t==="csv2json",d=MG(t,e),h=v.useCallback(()=>{var m;l(!1),(m=a.current)==null||m.focus()},[]);v.useEffect(()=>{if(!o)return;const m=g=>{g.key==="Escape"&&h()},x=g=>{const y=u.current;y===null||!(g.target instanceof Node)||y.contains(g.target)||h()};return document.addEventListener("keydown",m),document.addEventListener("click",x),()=>{document.removeEventListener("keydown",m),document.removeEventListener("click",x)}},[o,h]);const p=E.jsxs(E.Fragment,{children:[E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(zS,{children:"Separator"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-separator",value:e.separator,onChange:m=>n({separator:m.target.value}),className:FS(),children:lR.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx($S,{})]})]}),E.jsx(Ly,{text:"Auto-detect is conservative — it only picks comma, semicolon, or tab. Pipe never auto-detects because normal prose is full of pipes, so pipe-separated text must be selected explicitly."})]}),i&&s?E.jsxs(E.Fragment,{children:[E.jsx(LS,{}),E.jsxs("span",{className:"inline-flex items-center gap-2",children:[E.jsxs("label",{className:"flex items-center gap-2",children:[E.jsx(zS,{children:"Encoding"}),E.jsxs("span",{className:"relative inline-flex",children:[E.jsx("select",{"data-testid":"opt-encoding",value:i,onChange:m=>s(m.target.value),className:FS(),children:AG.map(m=>E.jsx("option",{value:m.value,children:m.label},m.value))}),E.jsx($S,{})]})]}),E.jsx(Ly,{text:"Applies to file uploads and drops only — pasted or typed text is always read as UTF-8. Switch to Windows-1252 for CSVs saved by legacy Excel to fix mangled accents like ü and ö."})]})]}):null,E.jsx(LS,{}),f?E.jsxs(E.Fragment,{children:[E.jsx(to,{label:"Parse numbers",checked:e.parseNumbers,onChange:m=>n({parseNumbers:m}),hint:"On by default — plain numbers like 5 or 19.99 become real JSON numbers; leading-zero values like 00721 and very long IDs stay strings. Uncheck to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on."}),E.jsx(to,{label:"Parse JSON",checked:e.parseJSON,onChange:m=>n({parseJSON:m}),hint:"Turns null, true, false, [] and {} into real JSON values instead of strings."}),E.jsx(to,{label:"Skip empty fields",checked:e.emptyFields==="skip",onChange:m=>n({emptyFields:m?"skip":"keep"}),hint:'Empty cells are dropped from the output instead of becoming "" — a column that is empty in every row disappears from the output and the counts.'}),E.jsx(to,{label:"NULL as null",checked:e.nullLiterals==="null",onChange:m=>n({nullLiterals:m?"null":"string"}),hint:"The string NULL becomes JSON null. Matching is exact and case-sensitive — SQL exports write uppercase NULL; Null and nULL are untouched, and lowercase null already converts when Parse JSON is on."}),E.jsx(to,{label:"Transpose",checked:e.transpose,onChange:m=>n({transpose:m}),hint:"Flip rows and columns — the first column becomes the header row."}),E.jsx(to,{label:"Hash output",checked:e.hash,onChange:m=>n({hash:m}),hint:"The first column becomes the object key instead of a field."}),E.jsx(to,{label:"Minify",checked:e.minify,onChange:m=>n({minify:m}),hint:"Remove indentation from the JSON output. Data is untouched."})]}):E.jsx(to,{label:"Flatten nested arrays",checked:e.flatten,onChange:m=>n({flatten:m}),hint:"Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table."})]});return c?E.jsx("div",{"data-testid":"options-row",className:"flex flex-shrink-0 flex-row items-center gap-5 border-t border-border bg-panel px-5 py-2.5 text-[13px] text-muted-foreground",children:E.jsxs("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",className:"flex flex-1 flex-wrap items-center gap-x-4 gap-y-2.5",children:[p,r?E.jsxs(E.Fragment,{children:[E.jsx("div",{className:"flex-1"}),E.jsx("span",{"data-testid":"options-notice",children:r})]}):null]})}):E.jsxs("div",{"data-testid":"options-row",ref:u,className:"relative flex flex-shrink-0 flex-col border-t border-border bg-panel px-3.5 py-2 text-[13px] text-muted-foreground md:px-4",children:[E.jsxs("div",{className:"flex w-full items-center gap-2",children:[E.jsxs("button",{type:"button",ref:a,"data-testid":"options-settings-toggle","aria-expanded":o,"aria-haspopup":"true",onClick:()=>o?h():l(!0),className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-md py-0.5 text-[13px] font-medium text-foreground outline-none focus-visible:ring-3 focus-visible:ring-ring/50",children:["Parse settings",E.jsx(KI,{"aria-hidden":"true",className:hr("size-3.5 shrink-0 transition-transform",o&&"rotate-180")})]}),E.jsx("span",{"data-testid":"options-settings-summary",className:"min-w-0 truncate",children:d}),r?E.jsx("span",{"data-testid":"options-notice",className:"ml-auto shrink-0 text-right",children:r}):null]}),E.jsx("div",{"data-testid":"options-settings-menu",role:"group","aria-label":"Parse settings",hidden:!o,className:hr("absolute bottom-full left-0 z-50 mb-2 w-full items-center gap-x-4 gap-y-2.5 rounded-md border border-border bg-panel p-3 shadow-md",o?"flex flex-wrap":"hidden"),children:p})]})}const OG=[{format:"json",label:"JSON",extension:"json",mime:"application/json"},{format:"jsonl",label:"JSONL",extension:"jsonl",mime:"application/x-ndjson"},{format:"sql",label:"SQL",extension:"sql",mime:"application/sql"},{format:"ts",label:"TS",extension:"ts",mime:"text/typescript"}],PG=new Set(["csv","tsv","txt","json","jsonl","sql","ts"]),IG=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function Hd(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function _w(t){if(Array.isArray(t))return t.map(e=>Hd(e)?e:{value:e});if(Hd(t)){const e=Object.entries(t);return e.length===0?[]:e.every(([,n])=>Hd(n))?e.map(([n,r])=>{const i=r;return"key"in i?i:{key:n,...i}}):[t]}return[]}function aR(t){const e=new Set,n=[];for(const r of t)for(const i of Object.keys(r))e.has(i)||(e.add(i),n.push(i));return n}function NG(t){if(!t)return"data";let e=t.trim();const n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\"));for(n>=0&&(e=e.slice(n+1));;){const i=e.lastIndexOf(".");if(i<=0)break;if(i===e.length-1){e=e.slice(0,i);continue}const s=e.slice(i+1).toLowerCase();if(!PG.has(s))break;e=e.slice(0,i)}const r=e.replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return r.length>0?r:"data"}function Rm(t){return`"${t.replace(/"/g,'""')}"`}function DG(t){const e=t.filter(n=>n!=null);return e.length===0?"TEXT":e.every(n=>typeof n=="boolean")?"BOOLEAN":e.every(n=>typeof n=="number"&&Number.isFinite(n))?e.every(n=>Number.isInteger(n))?"INTEGER":"NUMERIC":"TEXT"}function _G(t){return t==null?"NULL":typeof t=="boolean"?t?"TRUE":"FALSE":typeof t=="number"?Number.isFinite(t)?String(t):"NULL":typeof t=="string"?`'${t.replace(/'/g,"''")}'`:`'${JSON.stringify(t).replace(/'/g,"''")}'`}function LG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}return _w(n).map(i=>JSON.stringify(i)).join(` -`)}function FG(t,e){const n=t.trim();if(n==="")return"";let r;try{r=JSON.parse(n)}catch{return t}const i=_w(r),s=aR(i),o=Rm(NG(e));if(s.length===0)return`CREATE TABLE ${o} ();`;const l=s.map(d=>{const h=i.map(m=>m[d]),p=DG(h);return` ${Rm(d)} ${p}`}),a=`CREATE TABLE ${o} ( -${l.join(`, -`)} -);`;if(i.length===0)return a;const u=s.map(Rm).join(", "),c=i.map(d=>` (${s.map(p=>_G(d[p])).join(", ")})`),f=`INSERT INTO ${o} (${u}) VALUES -${c.join(`, -`)};`;return`${a} - -${f}`}function uR(t){if(t===null)return"null";if(typeof t=="string")return"string";if(typeof t=="number")return"number";if(typeof t=="boolean")return"boolean";if(Array.isArray(t)){if(t.length===0)return"unknown[]";const e=cR(Array.from(new Set(t.map(n=>uR(n)))));return e.length===1?`${e[0]}[]`:`(${e.join(" | ")})[]`}return Hd(t)?"Record":"unknown"}const BS={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function cR(t){return[...t].sort((e,n)=>{const r=BS[e]??50,i=BS[n]??50;return r!==i?r-i:e.localeCompare(n)})}function $G(t){return IG.test(t)?t:JSON.stringify(t)}function zG(t){const e=t.trim();if(e==="")return"";let n;try{n=JSON.parse(e)}catch{return t}const r=_w(n),s=aR(r).map(l=>{let a=!1;const u=new Set;for(const h of r){if(!Object.prototype.hasOwnProperty.call(h,l)||h[l]===void 0){a=!0;continue}u.add(uR(h[l]))}const c=cR(Array.from(u)),f=c.length>0?c.join(" | "):"unknown",d=a?"?":"";return` ${$G(l)}${d}: ${f};`});return`${s.length>0?`export interface DataRow { -${s.join(` -`)} -}`:"export interface DataRow {}"} - -export const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function BG(t,e,n,r){const i=typeof t=="string"?t:t.text,s=typeof n=="string"||n===null?n:r??null;switch(e){case"json":return i;case"jsonl":return LG(i);case"sql":return FG(i,s);case"ts":return zG(i)}}const jG=3;function HG(t){const e=t.slice(0,jG),n=t.length-e.length;return(n>0?[...e,`+${n} more`]:e).join(` -`)}function WG({format:t,inputEmpty:e,outputText:n,error:r,meta:i,staleNotice:s,warnings:o,edited:l,editable:a,egressFormat:u="json",delimiter:c,dark:f,onCopy:d,onCopySelection:h,onNativeCopy:p,onDownload:m,onEgressFormatChange:x,onOutputChange:g,onRevert:y,onDiscardReconvert:w}){const k=t==="JSON",b=u==="json";return E.jsx("div",{"data-testid":"output-pane","data-surface":"output",className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:E.jsx(nR,{title:t,meta:e?null:l?E.jsxs("span",{className:"flex items-center gap-1.5",children:[E.jsx("span",{"data-testid":"edited-badge",role:"status","aria-label":"Output edited",className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.08em] text-amber-700 dark:bg-amber-400/15 dark:text-amber-400",children:"Edited"}),E.jsxs("button",{type:"button","data-testid":"revert-output",onClick:y,className:ul,children:[E.jsx(dx,{"aria-hidden":"true"}),"Revert"]})]}):s?E.jsx("span",{"data-testid":"stale-notice",className:"text-xs text-amber-600 dark:text-amber-400",children:s}):i,actions:E.jsxs(E.Fragment,{children:[k?E.jsx("span",{"data-testid":"output-format-switcher",role:"group","aria-label":"Output format",className:"inline-flex items-center gap-0.5 rounded-lg border border-border bg-muted/60 p-0.5",children:OG.map(S=>{const T=u===S.format;return E.jsx("button",{type:"button","data-testid":`output-format-option-${S.format}`,"aria-pressed":T,onClick:()=>x==null?void 0:x(S.format),className:hr("inline-flex cursor-pointer items-center rounded-[7px] px-1.5 py-0.5 font-mono text-[11px] font-medium transition-all outline-none focus-visible:ring-3 focus-visible:ring-ring/50 sm:px-2 sm:py-1",T?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:S.label},S.format)})}):null,E.jsxs("button",{type:"button","data-testid":"copy-output","aria-label":"Copy",title:"Copy",onClick:d,disabled:!n,className:ul,children:[E.jsx(Dv,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Copy"})]}),E.jsxs("button",{type:"button","data-testid":"download-output","aria-label":"Download",title:"Download",onClick:m,disabled:!n,className:ul,children:[E.jsx(hT,{"aria-hidden":"true"}),E.jsx("span",{className:"hidden xl:inline",children:"Download"})]})]}),status:l?{kind:"notice",message:"Output edited — CSV and option changes aren't applied.",action:w?E.jsxs("button",{type:"button","data-testid":"discard-reconvert",onClick:w,className:ul+" ml-2",children:[E.jsx(dx,{"aria-hidden":"true"}),"Discard edits & reconvert"]}):void 0}:r?{kind:"error",message:r}:o&&o.length>0?{kind:"notice",message:HG(o)}:null,children:e?E.jsxs("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:["Your ",t," appears here."]}):n?k?E.jsx("div",{className:"flex min-h-0 flex-1 flex-col",onCopy:()=>p==null?void 0:p(),children:E.jsx(tR,{value:n,editable:a&&b&&n.length<=eR,lintJson:b,onChange:g,dark:f,testId:"output-view"})}):E.jsx(BE,{text:n,delimiter:c,testId:"output-table",dark:f,onCopySelection:h}):r?E.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Resolve the error to see output."}):E.jsx("div",{"data-testid":"output-converting-placeholder",className:"flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground",children:"Converting…"})})})}function VG({phase:t,message:e,onRetry:n}){return t==="loading"?E.jsx("div",{role:"status","aria-busy":"true","data-testid":"permalink-loading",className:"mx-4 mt-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-muted-foreground",children:"Loading shared data…"}):t==="not-found"?E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This data doesn't exist (or was deleted)."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):t==="unsupported"?E.jsxs("div",{role:"alert","data-testid":"permalink-unsupported",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-2 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:"This link's saved data can't be shown in the new converter."}),E.jsx("a",{href:"/",className:"font-medium underline underline-offset-2",children:"Go to the converter"})]}):E.jsxs("div",{role:"alert","data-testid":"permalink-notice",className:"mx-4 mt-3 flex flex-wrap items-center gap-x-3 rounded-md border border-border bg-muted px-4 py-2 text-sm text-foreground",children:[E.jsx("span",{children:e||"Couldn't load this data."}),E.jsx("button",{type:"button","data-testid":"permalink-retry",onClick:n,className:"rounded-md border border-border bg-background px-2 py-1 text-sm font-medium hover:bg-accent",children:"Retry"})]})}const Lw="csvjson:recent.v1",fR=10,dR=1e5,jS=80;function UG(t){return t==="csv2json"||t==="json2csv"}function KG(t){if(!t||typeof t!="object"||Array.isArray(t))return;const e={};for(const[n,r]of Object.entries(t))(r==="string"||r==="number"||r==="boolean"||r==="auto")&&(e[n]=r);return Object.keys(e).length>0?e:void 0}function hR(t){if(typeof t!="object"||t===null)return{...zr};const e=t,n=e.separator,r=n==="auto"||n===","||n===";"||n===" "||n==="|"?n:zr.separator,i=e.emptyFields==="keep"||e.emptyFields==="skip"?e.emptyFields:zr.emptyFields,s=e.nullLiterals==="string"||e.nullLiterals==="null"?e.nullLiterals:zr.nullLiterals,o=KG(e.columnTypes);return{separator:r,parseNumbers:typeof e.parseNumbers=="boolean"?e.parseNumbers:zr.parseNumbers,parseJSON:typeof e.parseJSON=="boolean"?e.parseJSON:zr.parseJSON,emptyFields:i,nullLiterals:s,transpose:typeof e.transpose=="boolean"?e.transpose:zr.transpose,hash:typeof e.hash=="boolean"?e.hash:zr.hash,minify:typeof e.minify=="boolean"?e.minify:zr.minify,flatten:typeof e.flatten=="boolean"?e.flatten:zr.flatten,collapseIndexedArrays:typeof e.collapseIndexedArrays=="boolean"?e.collapseIndexedArrays:zr.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function pR(t){const n=(t.split(/\r?\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/\s+/g," ");return n.length<=jS?n:`${n.slice(0,jS-1)}…`}function XG(t){if(typeof t!="object"||t===null)return!1;const e=t;return!(typeof e.id!="string"||e.id.trim()===""||typeof e.createdAt!="number"||!Number.isFinite(e.createdAt)||!UG(e.direction)||typeof e.input!="string"||e.input.trim()===""||e.input.length>dR||e.filename!==null&&typeof e.filename!="string"||typeof e.rows!="number"||!Number.isInteger(e.rows)||e.rows<0||typeof e.cols!="number"||!Number.isInteger(e.cols)||e.cols<0||typeof e.preview!="string")}function GG(t){return{id:t.id,createdAt:t.createdAt,direction:t.direction,input:t.input,options:hR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:t.preview||pR(t.input)}}function gR(t){try{if(typeof window>"u")return;window.localStorage.setItem(Lw,JSON.stringify(t))}catch{}}function qG(t){var e;return typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function"?globalThis.crypto.randomUUID():`snap-${t}-${Math.random().toString(36).slice(2,10)}`}function Fw(){try{if(typeof window>"u")return[];const t=window.localStorage.getItem(Lw);if(t===null)return[];const e=JSON.parse(t);return Array.isArray(e)?e.filter(XG).map(GG).sort((r,i)=>i.createdAt-r.createdAt).slice(0,fR):[]}catch{return[]}}function HS(t){const e=Fw(),n=t.input.trim();if(n===""||t.input.length>dR||t.rows<=0&&t.cols<=0)return e;const r=t.createdAt??Date.now(),i=e.find(a=>a.direction===t.direction&&a.input.trim()===n),s={id:(i==null?void 0:i.id)??qG(r),createdAt:r,direction:t.direction,input:t.input,options:hR(t.options),filename:t.filename,rows:t.rows,cols:t.cols,preview:pR(t.input)},o=e.filter(a=>!(a.direction===t.direction&&a.input.trim()===n)),l=[s,...o].slice(0,fR);return gR(l),l}function YG(t){const n=Fw().filter(r=>r.id!==t);return gR(n),n}function JG(){try{if(typeof window>"u")return;window.localStorage.removeItem(Lw)}catch{}}function QG(t,e=Date.now()){const n=Math.max(0,e-t),r=Math.floor(n/1e3);if(r<45)return"just now";const i=Math.floor(r/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);if(s<24)return`${s}h ago`;const o=Math.floor(s/24);return o===1?"yesterday":o<7?`${o}d ago`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}function ZG(t){return t==="csv2json"?"CSV→JSON":"JSON→CSV"}function eq(t,e){return t>0&&e>0?`${t} rows · ${e} cols`:t>0?`${t} rows`:e>0?`${e} cols`:"0 rows"}function tq({snapshots:t,onSelect:e,onRemove:n,onClear:r}){const[i,s]=v.useState(!1),o=v.useRef(null),l=v.useRef(null),a=v.useCallback(()=>{s(!1)},[]),u=v.useRef(!1);v.useEffect(()=>{var f;u.current&&!i&&((f=l.current)==null||f.focus()),u.current=i},[i]),v.useEffect(()=>{if(!i)return;const f=h=>{h.key==="Escape"&&a()},d=h=>{const p=o.current;p===null||!(h.target instanceof Node)||p.contains(h.target)||a()};return document.addEventListener("keydown",f),document.addEventListener("click",d),()=>{document.removeEventListener("keydown",f),document.removeEventListener("click",d)}},[i,a]);const c=t.length;return E.jsxs("div",{"data-testid":"recent-history",ref:o,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"recent-history-toggle",ref:l,onClick:()=>s(f=>!f),"aria-expanded":i,"aria-haspopup":"dialog","aria-label":"Recent conversions",title:"Recent conversions",className:"relative inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-border bg-panel px-2.5 text-xs font-medium text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(YI,{size:14,strokeWidth:2,"aria-hidden":"true"}),E.jsx("span",{className:"hidden sm:inline",children:"Recent"}),c>0&&E.jsx("span",{"data-testid":"recent-history-count",className:"rounded-full bg-muted px-1.5 py-px text-[10px] font-semibold tabular-nums text-foreground",children:c})]}),i&&E.jsxs("div",{"data-testid":"recent-history-popout",role:"dialog","aria-label":"Recent conversions",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"Recent conversions"}),E.jsxs("div",{className:"flex items-center gap-1",children:[c>0&&E.jsx("button",{type:"button","data-testid":"recent-history-clear",onClick:()=>{r()},className:"cursor-pointer rounded-md px-2 py-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Clear history"}),E.jsx("button",{type:"button","data-testid":"recent-history-close",onClick:a,"aria-label":"Close recent conversions",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(gh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]})]}),c===0?E.jsx("div",{"data-testid":"recent-history-empty",className:"px-3 py-6 text-center text-xs text-muted-foreground",children:"No recent conversions saved on this device yet."}):E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:t.map(f=>E.jsxs("div",{className:"flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50",children:[E.jsxs("button",{type:"button","data-testid":`recent-history-item-${f.id}`,onClick:()=>{e(f),a()},className:"flex min-w-0 flex-1 cursor-pointer flex-col items-start text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/50 rounded-sm px-1 py-0.5",children:[E.jsxs("div",{className:"mb-1 flex w-full items-center gap-1.5",children:[E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:ZG(f.direction)}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:eq(f.rows,f.cols)}),E.jsx("span",{className:"ml-auto text-[11px] text-muted-foreground",children:QG(f.createdAt)})]}),E.jsx("span",{className:"w-full truncate font-mono text-xs text-foreground",children:f.filename??f.preview})]}),E.jsx("button",{type:"button","data-testid":`recent-history-delete-${f.id}`,onClick:d=>{d.stopPropagation(),n(f.id)},"aria-label":`Delete recent snapshot ${f.filename??f.preview}`,title:"Delete snapshot",className:"mt-0.5 flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(ph,{size:13,strokeWidth:2,"aria-hidden":"true"})})]},f.id))})]})]})}const Fy=20,$y=80,WS=50;function Om(t){return Math.min($y,Math.max(Fy,t))}function nq({layout:t,split:e,onSplitChange:n,left:r,right:i,children:s}){const o=v.useRef(null),[l,a]=v.useState(!1),u=t==="stacked";v.useEffect(()=>{if(!l)return;const f=h=>{var x;const p=(x=o.current)==null?void 0:x.getBoundingClientRect();if(!p||p.width===0||p.height===0)return;const m=u?(h.clientY-p.top)/p.height:(h.clientX-p.left)/p.width;n(Om(m*100))},d=()=>a(!1);return window.addEventListener("pointermove",f),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",d),()=>{window.removeEventListener("pointermove",f),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",d)}},[l,u,n]);const c=f=>{const d=f.shiftKey?5:1;switch(f.key){case"ArrowLeft":case"ArrowUp":f.preventDefault(),n(Om(e-d));break;case"ArrowRight":case"ArrowDown":f.preventDefault(),n(Om(e+d));break;case"Home":f.preventDefault(),n(Fy);break;case"End":f.preventDefault(),n($y);break;case"Enter":case" ":f.preventDefault(),n(WS);break}};return E.jsxs("div",{ref:o,className:hr("relative flex min-h-0 flex-1","flex-col md:flex-row",l&&"select-none"),children:[E.jsx("div",{"data-testid":"pane-left",style:{"--split":`${e}%`},className:hr("flex min-h-0 min-w-0 flex-col overflow-hidden border-border bg-panel max-md:min-h-[280px] max-md:max-h-[360px]","h-[var(--split)] border-b","md:h-auto md:w-[var(--split)] md:border-b-0 md:border-r"),children:r}),E.jsxs("div",{"data-testid":"seam",role:"separator",tabIndex:0,"aria-orientation":u?"horizontal":"vertical","aria-valuenow":Math.round(e),"aria-valuemin":Fy,"aria-valuemax":$y,"aria-label":"Resize panes",title:"Drag to resize · double-click to reset",onPointerDown:f=>{var d,h;f.target instanceof Element&&f.target.closest("button")||(f.preventDefault(),(h=(d=f.currentTarget).setPointerCapture)==null||h.call(d,f.pointerId),a(!0))},onPointerUp:()=>a(!1),onDoubleClick:()=>n(WS),onKeyDown:c,style:{"--split":`${e}%`,touchAction:"none"},className:hr("relative z-10 flex h-9 flex-shrink-0 items-center justify-center border-b border-border bg-muted/20 cursor-row-resize","md:absolute md:top-0 md:right-auto md:bottom-0 md:left-[var(--split)] md:h-auto md:w-0 md:border-b-0 md:bg-transparent md:cursor-col-resize"),children:[E.jsx("div",{className:hr("absolute","inset-0","md:inset-auto md:top-0 md:right-auto md:bottom-0 md:-left-1.5 md:h-auto md:w-3")}),s?E.jsx("div",{className:"relative z-10 md:absolute md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2",children:s}):null]}),E.jsx("div",{"data-testid":"pane-right",className:"flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel max-md:min-h-[240px] max-md:max-h-[340px]",children:i})]})}function rq({theme:t}){return t==="dark"?E.jsx(dN,{size:15,strokeWidth:2,"aria-hidden":"true"}):E.jsx(tN,{size:15,strokeWidth:2,"aria-hidden":"true"})}function iq({theme:t,onToggleTheme:e,slot:n}){return E.jsxs("header",{"data-testid":"topbar",className:"relative flex h-14 flex-shrink-0 items-center gap-3 border-b border-border bg-panel px-5",children:[E.jsxs("div",{className:"flex items-baseline gap-2",children:[E.jsx("span",{className:"text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap",children:"csvjson"}),E.jsx("span",{className:"hidden text-[13px] font-medium text-muted-foreground sm:inline",children:"CSV → JSON converter"})]}),E.jsx("div",{className:"flex-1"}),E.jsx("div",{"data-testid":"topbar-slot",children:n}),E.jsx("button",{type:"button","data-testid":"theme-toggle",onClick:e,"aria-label":t==="dark"?"Switch to light mode":"Switch to dark mode",title:t==="dark"?"Switch to light mode":"Switch to dark mode",className:"inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:E.jsx(rq,{theme:t})})]})}function sq(t){return[...t].sort((e,n)=>n.id-e.id)}const mR=[{id:20,date:"2026-10-20",tag:"new",title:"One-click nested JSON flattening in JSON → CSV",summary:"When JSON → CSV input contains nested objects or arrays, a contextual Flatten nested keys pill appears above the editor to expand deep objects into dotted CSV column headers (like user.profile.name) and join scalar arrays in one click."},{id:19,date:"2026-10-20",tag:"new",title:"Pin per-column types in the CSV grid",summary:"Select any column in the CSV table to pin its JSON output type to String, Number, Boolean, or Auto — keeping postal codes and IDs as strings or coercing yes/no/1/0 columns to booleans without changing global parse settings."},{id:18,date:"2026-10-20",tag:"new",title:"Live spreadsheet selection aggregates in the table toolbar",summary:"Select any range of cells, rows, or columns in the data table to see instant cell, distinct, and empty counts alongside numeric Sum, Avg, Min, and Max aggregates. Range selections also expose one-click Copy as CSV right from the toolbar."},{id:17,date:"2026-10-20",tag:"new",title:"Export CSV as JSONL, SQL INSERTs, or TypeScript",summary:"Switch the CSV → JSON output header between JSON, JSONL, SQL, and TS to generate newline-delimited records, CREATE TABLE and INSERT statements with inferred types, or a typed TypeScript DataRow interface and array ready to copy or download."},{id:16,date:"2026-10-20",tag:"new",title:"Restore recent conversions from the top bar",summary:"The new Recent menu in the top bar saves up to 10 valid conversions locally on your device so you can jump back to an earlier dataset in one click. Fresh page loads still start on a clean empty dropzone."},{id:15,date:"2026-10-18",tag:"improvement",title:"Options fold into a Parse settings menu",summary:"On narrower screens the converter's options bar no longer wraps onto extra lines — it collapses to a single Parse settings line showing your active options, with the full control set in a drop-up above it. Small screens lose the accordion that squeezed the panes."},{id:14,date:"2026-10-17",tag:"improvement",title:"Polished mobile stacked panes and collapsible options bar",summary:"Small screens now stack the input and output panes with an in-flow direction switch and compact icon actions so nothing overlaps. The options bar collapses into a one-tap summary on phones while keeping every setting a tap away."},{id:13,date:"2026-10-15",tag:"fix",title:"Faster large CSV uploads without page freezes",summary:"Uploading large CSV files now converts in a single pass without freezing the tab or flashing a false error state, previews multi-megabyte JSON outputs smoothly while keeping full Copy and Download, and decodes UTF-16 CSV exports automatically."},{id:12,date:"2026-10-15",tag:"improvement",title:"Table undo, header rename, and smarter JSON input",summary:"Undo or redo CSV table edits, double-click any column header to rename it in place, and collapse .0, .1 indexed columns into JSON arrays. JSON → CSV now formats or minifies JSON in one click, unwraps nested record arrays, parses JSONL, and previews pipe-delimited output accurately."},{id:11,date:"2026-10-03",tag:"improvement",title:"The switch names the direction",summary:"The ⇄ switch now labels the active conversion, and legacy /json2csv links land you in JSON → CSV mode again — it never left."},{id:10,date:"2026-09-08",tag:"new",title:"Delete rows and columns from the table",summary:"Select rows or columns in the input table and delete them by button or the Delete key — the raw CSV updates and reconverts in place, with at least one column always kept. Selected column headers are also readable again in both themes."},{id:9,date:"2026-09-08",tag:"new",title:"Spreadsheet-grade data table",summary:"The rebuilt data table adds drag-to-select ranges, Shift+Arrow range extension, fill, and spreadsheet-style cell editing — with copy/paste always producing clean CSV."},{id:8,date:"2026-09-07",tag:"new",title:"Search, sort, and select in the data table",summary:"The CSV table now has a search bar with a live row count, click-to-sort columns, and row selection with copy-as-CSV — on both the input and output tables."},{id:7,date:"2026-09-07",tag:"fix",title:"No more layout flash on load",summary:"The converter now renders side-by-side immediately on desktop, instead of stacking the panes and snapping into columns as the page loads."},{id:6,date:"2026-09-07",tag:"new",title:"Introducing the changelog",summary:"This changelog keeps you posted on what's new — recent updates appear here with an unseen dot when you come back. Feel free to vote on what you find useful."},{id:5,date:"2026-09-05",tag:"improvement",title:"Icons match the design",summary:"Action buttons, view toggle, and the empty state now use the same crisp icon set as the rest of the interface."},{id:4,date:"2026-09-05",tag:"new",title:"Edit the JSON output in place",summary:"The output pane is now an editor. Hand edits survive until you reconvert; revert and discard keep you safe."},{id:3,date:"2026-09-05",tag:"fix",title:"Pastes land where they belong",summary:"Paste anywhere on the page and your data routes to the input — including pastes over the read-only output pane."},{id:2,date:"2026-09-04",tag:"improvement",title:"A calmer empty state",summary:"Empty panes now open on a compact paste field with a Choose file button, so starting is obvious on any screen."},{id:1,date:"2026-09-04",tag:"improvement",title:"Smarter number handling",summary:"Numbers convert sensibly out of the box: leading-zero values like 00721 and very long IDs stay strings so nothing gets silently mangled."}],oq=864e5;function VS(t){return Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}function lq(t,e=Date.now()){const n=new Date(`${t}T00:00:00Z`),r=new Date(e),i=Math.round((VS(r)-VS(n))/oq);if(i<=0)return"today";if(i===1)return"yesterday";if(i<7)return`${i} days ago`;const s=n.toLocaleDateString("en-US",{month:"short",day:"numeric",timeZone:"UTC"});return n.getUTCFullYear()===r.getUTCFullYear()?s:`${s}, ${n.getUTCFullYear()}`}const yR="csvjson:changelog.v1",Wd=Math.max(...mR.map(t=>t.id),0),aq=sq(mR);function uq(t){if(typeof t!="object"||t===null)return!1;const e=t;if(e.lastSeenId!==null&&typeof e.lastSeenId!="number"||typeof e.votes!="object"||e.votes===null)return!1;for(const[n,r]of Object.entries(e.votes))if(!/^\d+$/.test(n)||r!==1&&r!==-1)return!1;return!(e.clientId!==void 0&&!cq(e.clientId)||e.pendingIds!==void 0&&(!Array.isArray(e.pendingIds)||e.pendingIds.some(n=>typeof n!="number"||!Number.isInteger(n)||n<1)))}function cq(t){return typeof t=="string"&&/^[0-9a-fA-F-]{8,64}$/.test(t)}function vR(t){return t===void 0?[]:[...new Set(t)].filter(e=>e>=1&&e<=Wd).sort((e,n)=>e-n)}function US(t,e,n){const r=vR(t.pendingIds),i=n?[...new Set([...r,e])].sort((s,o)=>s-o):r.filter(s=>s!==e);return{...t,pendingIds:i}}function fq(){try{const t=window.localStorage.getItem(yR);if(t===null)return{lastSeenId:null,votes:{}};const e=JSON.parse(t);return uq(e)?{...e,pendingIds:vR(e.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function dq(t){try{window.localStorage.setItem(yR,JSON.stringify(t))}catch{}}function hq(){var n,r,i;if(typeof((n=globalThis.crypto)==null?void 0:n.randomUUID)=="function")return globalThis.crypto.randomUUID();const t=(i=(r=globalThis.crypto)==null?void 0:r.getRandomValues)==null?void 0:i.call(r,new Uint8Array(16));if(t===void 0)throw new Error("no secure randomness available");t[6]=t[6]&15|64,t[8]=t[8]&63|128;const e=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");return`${e.slice(0,8)}-${e.slice(8,12)}-${e.slice(12,16)}-${e.slice(16,20)}-${e.slice(20)}`}async function pq(t,e,n){try{return(await fetch("/api/changelog-vote",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:t,entryId:e,vote:n})})).ok?"ok":"failed"}catch{return"failed"}}function KS(t){return["flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors",t?"bg-muted text-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"].join(" ")}function gq({entry:t,vote:e,queued:n,inFlight:r,onVote:i}){return E.jsxs("article",{className:"px-3 py-2.5","data-testid":`changelog-entry-${t.id}`,children:[E.jsxs("div",{className:"mb-1 flex items-center gap-1.5",children:[t.tag!==void 0&&E.jsx("span",{className:"rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.tag}),E.jsx("span",{className:"text-[11px] text-muted-foreground",children:lq(t.date)})]}),E.jsx("h3",{className:"text-xs font-semibold text-foreground",children:t.title}),E.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-muted-foreground",children:t.summary}),E.jsxs("div",{className:"mt-1.5 flex gap-1",children:[E.jsx("button",{type:"button","data-testid":`changelog-up-${t.id}`,onClick:()=>i(t.id,1),"aria-pressed":e===1,"aria-label":`Upvote: ${t.title}`,title:"Good change",className:KS(e===1),children:E.jsx(vN,{size:13,strokeWidth:2,"aria-hidden":"true"})}),E.jsx("button",{type:"button","data-testid":`changelog-down-${t.id}`,onClick:()=>i(t.id,-1),"aria-pressed":e===-1,"aria-label":`Downvote: ${t.title}`,title:"Not for me",className:KS(e===-1),children:E.jsx(mN,{size:13,strokeWidth:2,"aria-hidden":"true"})})]}),n&&!r&&E.jsx("p",{"data-testid":`changelog-queued-${t.id}`,role:"status",className:"mt-1.5 rounded-sm border border-dashed border-border px-2 py-1 text-[11px] text-muted-foreground",children:"Vote queued — it will retry on your next interaction."})]})}function mq(){const[t,e]=v.useState(fq),[n,r]=v.useState(!1),i=v.useRef(t),s=v.useCallback(b=>{dq(b),i.current=b,e(b)},[]),[o,l]=v.useState(()=>new Set),a=v.useRef(new Set),u=v.useRef(null),c=v.useRef(null),f=v.useRef(new Map),d=t.lastSeenId!==null&&Wd>t.lastSeenId,h=v.useCallback((b,S)=>{l(T=>{const A=new Set(T);return S?A.add(b):A.delete(b),A})},[]),p=v.useCallback((b,S,T,A)=>{const M=(f.current.get(b)??0)+1;f.current.set(b,M),a.current.add(b),A&&h(b,!0),pq(T,b,S).then(O=>{f.current.get(b)===M&&(a.current.delete(b),O==="ok"&&(AI({entry_id:b,vote:S}),s(US(i.current,b,!1))),A&&h(b,!1))})},[s,h]),m=v.useCallback(b=>{const{clientId:S,pendingIds:T,votes:A}=i.current,M=T??[];if(M.length!==0&&S!==void 0)for(const O of M){if(O===b||a.current.has(O))continue;const _=A[O];_!==void 0&&p(O,_,S,!1)}},[p]),x=(b,S)=>{if(t.votes[b]===S){m();return}const T=t.clientId??hq();s(US({...t,votes:{...t.votes,[b]:S},clientId:T},b,!0)),p(b,S,T,!0),m(b)},g=()=>{r(!0),EI(),t.lastSeenId!==Wd&&s({...t,lastSeenId:Wd}),m()},y=v.useCallback(()=>{r(!1)},[]),w=v.useRef(!1);v.useEffect(()=>{var b;w.current&&!n&&((b=c.current)==null||b.focus()),w.current=n},[n]);const k=v.useRef(!1);return v.useEffect(()=>{k.current||(k.current=!0,m())},[m]),v.useEffect(()=>{if(!n)return;const b=T=>{T.key==="Escape"&&y()},S=T=>{const A=u.current;A===null||!(T.target instanceof Node)||A.contains(T.target)||y()};return document.addEventListener("keydown",b),document.addEventListener("click",S),()=>{document.removeEventListener("keydown",b),document.removeEventListener("click",S)}},[n,y]),E.jsxs("div",{"data-testid":"changelog",ref:u,className:"relative max-sm:static",children:[E.jsxs("button",{type:"button","data-testid":"changelog-toggle",ref:c,onClick:()=>n?y():g(),"aria-expanded":n,"aria-haspopup":"dialog","aria-label":"Changelog",title:"What's new",className:"relative inline-flex size-8 cursor-pointer items-center justify-center rounded-lg border border-border bg-panel text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50",children:[E.jsx(sN,{size:15,strokeWidth:2,"aria-hidden":"true"}),d&&E.jsx("span",{"data-testid":"changelog-dot","aria-hidden":"true",className:"absolute right-1 top-1 size-1.5 rounded-full bg-foreground"})]}),n&&E.jsxs("div",{"data-testid":"changelog-popout",role:"dialog","aria-label":"Changelog",className:"absolute right-0 top-9 z-50 w-80 rounded-md border border-border bg-panel shadow-md max-sm:inset-x-2 max-sm:top-14 max-sm:w-auto",children:[E.jsxs("div",{className:"flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5",children:[E.jsx("span",{className:"text-xs font-semibold tracking-tight text-foreground",children:"What's new"}),E.jsx("button",{type:"button","data-testid":"changelog-close",onClick:y,"aria-label":"Close changelog",className:"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:E.jsx(gh,{size:14,strokeWidth:2,"aria-hidden":"true"})})]}),E.jsx("div",{className:"max-h-96 divide-y divide-border overflow-y-auto",children:aq.map(b=>{var S;return E.jsx(gq,{entry:b,vote:t.votes[b.id],queued:((S=t.pendingIds)==null?void 0:S.includes(b.id))??!1,inFlight:o.has(b.id),onVote:x},b.id)})})]})]})}function yq(t,e){const[n,r]=v.useState(t);return v.useEffect(()=>{const i=setTimeout(()=>r(t),e);return()=>clearTimeout(i)},[t,e]),n}const vq={},wq=["csv2json","json2csv","json_validator","json_beautifier","sql2json","csvjson2json","datajanitor"],xq=["csv2json","json2csv","csvjson2json"];function bq(t){return xq.includes(t)}const kq=/^[0-9a-f]{32}$/i,Sq=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,Pm=vq,Cq=((Pm==null?void 0:Pm.VITE_S3_DATA_URL)??"https://csvjson.s3.us-east-2.amazonaws.com/data/").replace(/\/*$/,"/");function Tq(t){const e=Sq.exec(t);if(!e)return null;const n=e[1].toLowerCase();return wq.includes(n)?{tool:n,id:e[2].toLowerCase()}:null}class zy extends Error{constructor(){super("This data doesn't exist (or was deleted)"),this.name="PermalinkNotFoundError"}}class Im extends Error{constructor(e,n){super(e,n),this.name="PermalinkFetchError"}}const Nm={csv:(t,e)=>{t.direction="csv2json",t.input=Jh(e)},json:(t,e)=>{t.input=Jh(e),t.direction="json2csv"},parseNumbers:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseNumbers=n)},parseJSON:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.parseJSON=n)},transpose:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.transpose=n)},"output-array":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=!n)},"output-hash":(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.hash=n)},flatten:(t,e)=>{const n=Gl(e);n!==void 0&&(t.options.flatten=n)},output_csvjson_variant:()=>{}};function Jh(t){return typeof t=="string"?t:typeof t=="number"?String(t):""}function XS(t){return typeof t=="string"&&t.trim()!==""}function Gl(t){if(t===!0||t==="true")return!0;if(t===!1||t==="false")return!1}function Eq(t){return t===null||typeof t!="object"||Array.isArray(t)?!1:Object.values(t).every(e=>typeof e=="string"||typeof e=="boolean")}function Aq(t){var i;if(!Eq(t))return null;const e=XS(t.csv),n=XS(t.json);if(!e&&!n)return null;const r={direction:e?"csv2json":"json2csv",input:"",options:{}};for(const[s,o]of Object.entries(t))(i=Nm[s])==null||i.call(Nm,r,o);return r.input=Jh(e?t.csv:t.json),r}async function Mq(t){if(!kq.test(t))throw new zy;let e;try{e=await fetch(`${Cq}${t}`,{mode:"cors"})}catch(r){throw new Im("Network error while loading this data",{cause:r})}if(e.status===403||e.status===404)throw new zy;if(!e.ok)throw new Im(`Unexpected response while loading this data (HTTP ${e.status})`);let n;try{const r=await e.text();if(r.trim()==="")throw new Error("empty body");n=JSON.parse(r)}catch{throw new Im("Stored data for this link is malformed")}return n}function Rq(t){const e=v.useMemo(()=>t&&bq(t.tool)?t.id:null,[t]),[n,r]=v.useState(0),[i,s]=v.useState(e?"loading":"idle"),[o,l]=v.useState(null),[a,u]=v.useState("");return v.useEffect(()=>{if(!e)return;let c=!1;return Mq(e).then(f=>{if(c)return;const d=Aq(f);d?(l(d),s("hydrated")):s("unsupported")}).catch(f=>{c||(f instanceof zy?s("not-found"):(u(f instanceof Error?f.message:"Couldn't load this data"),s("error")))}),()=>{c=!0}},[e,n]),{phase:i,hydrated:o,message:a,retry:()=>{i==="error"&&(s("loading"),r(c=>c+1))}}}async function GS(t){try{if(typeof navigator<"u"&&navigator.clipboard)return await navigator.clipboard.writeText(t),!0}catch{}try{const e=document.createElement("textarea");e.value=t,e.setAttribute("readonly",""),e.style.position="fixed",e.style.opacity="0",document.body.appendChild(e),e.select();const n=document.execCommand("copy");return e.remove(),n}catch{return!1}}const Oq="\uFEFF";function Pq(t,e){return e?Oq+t:t}function Iq(t,e,n){const r=Pq(t,n);return new Blob([r],{type:`${e};charset=utf-8`})}const Nq=new Set(["csv","tsv","json","jsonl","sql","ts","txt"]);function Dq(t){let e=t;for(;;){const n=e.lastIndexOf(".");if(n<=0)break;if(n===e.length-1){e=e.slice(0,n);continue}if(!Nq.has(e.slice(n+1).toLowerCase()))break;e=e.slice(0,n)}return e}function _q(t,e,n="json"){const r=e==="csv2json"?n:"csv";return t?`${Dq(t)}.${r}`:`data.${r}`}function Lq(t,e="json"){if(t==="json2csv")return"text/csv";switch(e){case"json":return"application/json";case"jsonl":return"application/x-ndjson";case"sql":return"application/sql";case"ts":return"text/typescript"}}function qS(t,e,{mime:n="text/plain",bom:r=!1}={}){const i=Iq(t,n,r),s=URL.createObjectURL(i),o=document.createElement("a");return o.href=s,o.download=e,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(s),0),e}function Fq(t){if(!(t instanceof HTMLElement))return!1;if(t.isContentEditable)return!0;const e=t.tagName;return e==="INPUT"||e==="TEXTAREA"?!0:t.closest('[contenteditable="true"]')!==null}const $q=`album,year,US_peak_chart_post -The White Stripes,1999, -De Stijl,2000, -White Blood Cells,2001,61 -Elephant,2003,6 -Get Behind Me Satan,2005,3 -Icky Thump,2007,2`,zq=`[ - { - "album": "Elephant", - "year": 2003, - "label": "XL Recordings" - }, - { - "album": "Icky Thump", - "year": 2007, - "label": "XL Recordings" - } -]`,wR="csvjson-theme";function Bq(){try{const t=localStorage.getItem(wR);return t==="dark"||t==="light"?t:null}catch{return null}}function jq(){try{if(typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: dark)").matches)return"dark"}catch{}return"light"}function Hq(){return Bq()??jq()}function Wq(t){try{localStorage.setItem(wR,t)}catch{}}function Vq(t){return new URLSearchParams(t).get("direction")==="json2csv"?"json2csv":"csv2json"}const YS=2*1024*1024,Uq=150,Kq=1e3,Xq=2e3,Gq=2e3;function qq(t,e){return t===0?null:e>0?`${t} rows · ${e} cols`:`${t} rows`}function JS(t){try{return JSON.parse(t),!0}catch{return!1}}function Yq(){var dn;const[t,e]=v.useState(Hq);v.useEffect(()=>{document.documentElement.classList.toggle("dark",t==="dark")},[t]);const n=()=>e(ne=>{const Le=ne==="dark"?"light":"dark";return Wq(Le),Le}),[r,i]=v.useState(()=>typeof window>"u"?"csv2json":Vq(window.location.search)),[s,o]=v.useState(()=>Go("")),l=s.present,[a,u]=v.useState(zr),[c,f]=v.useState("json"),[d,h]=v.useState(50),[p,m]=v.useState(null),[x,g]=v.useState(!1),[y,w]=v.useState(null),[k,b]=v.useState("utf-8"),[S,T]=v.useState(Fw),A=v.useRef({direction:r,options:a,input:l,resultOk:!0}),M=v.useRef(null);M.current||(M.current=_I({settleMs:Xq,minWindowMs:Gq,isValid:(ne,Le)=>{const ze=A.current;return Le===ze.input?ze.resultOk:eo(ne==="csv_to_json"?"csv2json":"json2csv",Le,ze.options).ok}}));const O=M.current;v.useEffect(()=>()=>O.cancel(),[O]);const P=oR("(min-width: 48rem)")?"side-by-side":"stacked",I=r==="csv2json",D=I?"CSV":"JSON",ee=I?"JSON":"CSV",ie=l.trim()==="",te=l.length>YS?Kq:Uq,W=yq(l,ie?0:te),V=v.useRef(null),R=v.useRef(null),L=l!==""&&((dn=V.current)==null?void 0:dn.text)===l?l:W,H=v.useMemo(()=>typeof window>"u"?null:Tq(window.location.pathname),[]),G=Rq(H),B=v.useMemo(()=>eo(r,L,a),[r,L,a]);A.current={direction:r,options:a,input:L,resultOk:B.ok},v.useEffect(()=>{const ne=R.current;!ne||ne.text!==L||(R.current=null,O.discrete(ne.direction,ne.via,ne.text))},[L,B,O]);const[le,me]=v.useState(null);v.useEffect(()=>{L.trim()!==""&&B.ok&&me(B.text)},[B,L]),v.useEffect(()=>{L.trim()!==""&&(!B.ok||B.rows<=0&&B.cols<=0||T(HS({direction:r,input:L,options:a,filename:p,rows:B.rows,cols:B.cols})))},[r,L,p,a,B]);const ye=L.trim()!==""&&B.ok?B.text:le,[oe,be]=v.useState(!1),[Ce,lt]=v.useState(null),Xe=oe?Ce:ye,Ge=v.useMemo(()=>{if(!I||Xe===null||c==="json")return Xe;const ne=oe&&Ce!==null&&JS(Ce)?Ce:ye;return ne===null?null:BG(ne,c,a,p)},[I,Xe,c,oe,Ce,ye,a,p]),at=I&&c==="json"&&!ie&&Ge!==null&&(oe||B.ok),Ut=v.useCallback(ne=>{if(ne===ye){be(!1),lt(null);return}be(!0),lt(ne)},[ye]),Pe=v.useCallback(()=>{const ne=eo(r,l,a);ne.ok&&me(ne.text),be(!1),lt(null)},[r,l,a]),xe=v.useCallback(ne=>{o(Le=>I?Gb(Le,ne):Go(ne))},[I]),Je=I&&s.past.length>0,nt=I&&s.future.length>0,it=v.useCallback(()=>{if(!I||s.past.length===0)return;const ne=C9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),$e=v.useCallback(()=>{if(!I||s.future.length===0)return;const ne=T9(s);w(null),o(ne),O.edit("csv_to_json",ne.present)},[I,s,O]),At=v.useCallback(ne=>{w(null),V.current=null,i(ne.direction),u({...ne.options}),m(ne.filename),be(!1),lt(null),o(Le=>ne.direction==="csv2json"&&r==="csv2json"?Gb(Le,ne.input):Go(ne.input)),T(HS({direction:ne.direction,input:ne.input,options:ne.options,filename:ne.filename,rows:ne.rows,cols:ne.cols}))},[r]),wt=v.useCallback(ne=>{T(YG(ne))},[]),rt=v.useCallback(()=>{JG(),T([])},[]),ge=()=>{const ne=r==="csv2json"?"json2csv":"csv2json";if(oe){const Le=Ce??"",ze=JS(Le)?Le:l;o(Go(ze)),i(ne),be(!1),lt(null),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:eo(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze));return}if(i(ne),ie)o(Go(""));else{const Le=eo(r,l,a),ze=Le.ok?Le.text:l;o(Go(ze)),ze.trim()!==""&&(A.current={direction:ne,options:a,input:ze,resultOk:eo(ne,ze,a).ok},O.discrete(ne==="csv2json"?"csv_to_json":"json_to_csv","flip",ze))}},_e=G.hydrated;v.useEffect(()=>{if(_e===null)return;const ne={...A.current.options,..._e.options};A.current={direction:_e.direction,options:ne,input:_e.input,resultOk:eo(_e.direction,_e.input,ne).ok},i(_e.direction),o(Go(_e.input)),u(Le=>({...Le,..._e.options})),be(!1),lt(null),TI(),O.discrete(_e.direction==="csv2json"?"csv_to_json":"json_to_csv","permalink",_e.input)},[_e,O]);const Qe=async(ne,Le)=>{if(!EG(ne)){w(`Can't read "${ne.name}" as text — drop a ${I?".csv / .tsv":".json"} file.`);return}w(null),g(!0);try{const ze=await _S(ne,k);V.current={file:ne,source:Le,text:ze},R.current={direction:I?"csv_to_json":"json_to_csv",via:Le==="drop"?"drag":"file",text:ze},xe(ze),m(ne.name),g(!1)}catch{g(!1),w(`Couldn't read "${ne.name}".`)}},tt=async ne=>{const Le=k;b(ne);const ze=V.current;if(!(!ze||l!==ze.text)){g(!0);try{const An=await _S(ze.file,ne);V.current={...ze,text:An},R.current={direction:I?"csv_to_json":"json_to_csv",via:ze.source==="drop"?"drag":"file",text:An},o(z=>({...z,present:An})),g(!1)}catch{g(!1),b(Le),w(`Couldn't read "${ze.file.name}".`)}}},Kt=v.useCallback(ne=>{w(null),ne.trim()===""&&u(Le=>{if(!Le.columnTypes)return Le;const ze={...Le};return delete ze.columnTypes,ze}),xe(ne),O.edit(I?"csv_to_json":"json_to_csv",ne)},[xe,I,O]);v.useEffect(()=>{const ne=Le=>{var An;const ze=(An=Le.clipboardData)==null?void 0:An.getData("text/plain");!ze||Fq(Le.target)||(Le.preventDefault(),Le.stopPropagation(),m(null),Kt(ze))};return document.addEventListener("paste",ne,!0),()=>document.removeEventListener("paste",ne,!0)},[Kt]);const dt=B.ok?qq(B.rows,B.cols):null,ht=!B.ok&&le?"Last valid result — input has errors":null,pt=B.ok&&B.warnings&&B.warnings.length>0?B.warnings:null,Lt=l.length>YS,Rt=I?"csv_to_json":"json_to_csv",en=I?c:"csv",Hn=()=>{Uo({via:"copy",format:I?"csv":"json",pane:"input",direction:Rt}),GS(l)},Pt=()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt}),Ge&&GS(Ge)},vn=()=>{Uo({via:"download",format:I?"csv":"json",pane:"input",direction:Rt}),qS(l,p??(I?"data.csv":"data.json"),{mime:I?"text/csv":"application/json",bom:I})},In=()=>{Uo({via:"download",format:en,pane:"output",direction:Rt}),qS(Ge??"",_q(p,I?"csv2json":"json2csv",c),{mime:Lq(I?"csv2json":"json2csv",c),bom:!I})},Pr=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"input",direction:Rt})},[Rt]),Ir=v.useCallback(()=>{Uo({via:"copy",format:"csv",pane:"output",direction:Rt})},[Rt]),Bt=v.useCallback(()=>{Uo({via:"copy",format:en,pane:"output",direction:Rt})},[en,Rt]),ct=E.jsx(CG,{format:D,input:l,onInputChange:Kt,onCellCommit:Kt,onFile:Qe,onTryExample:()=>{w(null);const ne=I?$q:zq;A.current={direction:r,options:a,input:ne,resultOk:eo(r,ne,a).ok},xe(ne),O.discrete(Rt,"example",ne)},onClear:()=>{xe(""),m(null),u(ne=>{if(!ne.columnTypes)return ne;const Le={...ne};return delete Le.columnTypes,Le}),be(!1),lt(null),O.cancel()},onCopy:Hn,onCopySelection:Pr,onDownload:vn,canUndo:Je,canRedo:nt,onUndo:it,onRedo:$e,collapseIndexedArrays:a.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>u(ne=>({...ne,collapseIndexedArrays:!(ne.collapseIndexedArrays??!0)})),columnTypes:a.columnTypes??{},onChangeColumnTypes:ne=>u(Le=>{const ze={...Le};return Object.keys(ne).length>0?ze.columnTypes=ne:delete ze.columnTypes,ze}),flatten:a.flatten,onToggleFlatten:()=>u(ne=>({...ne,flatten:!ne.flatten})),filename:p,reading:x,meta:dt,error:null,notice:y,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark"}),xt=E.jsx(WG,{format:ee,inputEmpty:ie,outputText:Ge,error:B.ok?null:B.error,meta:dt,staleNotice:ht,warnings:pt,edited:oe,editable:at,egressFormat:c,delimiter:a.separator==="auto"?void 0:a.separator,dark:t==="dark",onCopy:Pt,onCopySelection:Ir,onNativeCopy:Bt,onDownload:In,onEgressFormatChange:f,onOutputChange:Ut,onRevert:Pe,onDiscardReconvert:Pe});return E.jsxs("div",{className:"flex min-h-svh flex-col bg-background text-foreground",children:[E.jsx("h1",{className:"sr-only",children:"CSV to JSON and JSON to CSV converter"}),E.jsxs("div",{className:"flex min-h-svh flex-col md:h-svh md:min-h-0",children:[E.jsx(lD,{}),E.jsx(iq,{theme:t,onToggleTheme:n,slot:E.jsxs("div",{className:"flex items-center gap-1",children:[E.jsx(tq,{snapshots:S,onSelect:At,onRemove:wt,onClear:rt}),E.jsx(mq,{}),E.jsx(dD,{})]})}),H&&(G.phase==="loading"||G.phase==="not-found"||G.phase==="unsupported"||G.phase==="error")?E.jsx(VG,{phase:G.phase,message:G.phase==="error"?G.message:void 0,onRetry:G.retry}):null,E.jsx(nq,{layout:P,split:d,onSplitChange:h,left:ct,right:xt,children:E.jsx(rD,{direction:r,onFlip:ge})}),E.jsx(RG,{direction:r,options:a,onChange:ne=>u(Le=>({...Le,...ne})),uploadEncoding:k,onUploadEncodingChange:tt,notice:Lt?"Large file — converting on pause":null})]}),E.jsx(sD,{})]})}cT(document.getElementById("root")).render(E.jsx(v.StrictMode,{children:E.jsx(Yq,{})}));document.getElementById("root").removeAttribute("inert");SI();CI();export{t6 as C,Ln as R,E4 as T,ca as a,Q3 as b,bI as c,ql as i,T4 as m,v as r,Jr as s}; diff --git a/app/dist/assets/number-overlay-editor-cI9rZOV7.js b/app/dist/assets/number-overlay-editor-D2EysIl4.js similarity index 99% rename from app/dist/assets/number-overlay-editor-cI9rZOV7.js rename to app/dist/assets/number-overlay-editor-D2EysIl4.js index 3e1706e..901b065 100644 --- a/app/dist/assets/number-overlay-editor-cI9rZOV7.js +++ b/app/dist/assets/number-overlay-editor-D2EysIl4.js @@ -1,4 +1,4 @@ -import{s as Be,R as Y,r as O}from"./index-BweuKm2D.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 dc04d43..344fb6c 100644 --- a/app/src/App.test.tsx +++ b/app/src/App.test.tsx @@ -1871,6 +1871,95 @@ describe("Symmetric JSON → CSV nested object flatten pill (AC-15 / D14)", () = }); }); +describe("Markdown & CLI box table paste in CSV → JSON (AC-14 / D13)", () => { + it("auto-renders Markdown pipe tables in the CSV table and JSON output, surfaces Clean Markdown table pill, normalizes raw input in place, and supports undo", async () => { + const user = userEvent.setup(); + render(); + + const mdTable = [ + "| name | role | score |", + "| :--- | :---: | ---: |", + "| Ada | Engineer | 98 |", + "| Linus | Kernel | 95 |", + ].join("\n"); + + fireEvent.change(screen.getByTestId("paste-field"), { + target: { value: mdTable }, + }); + + await waitFor(() => { + const output = JSON.parse( + screen.getByTestId("output-view").textContent ?? "[]" + ); + expect(output).toEqual([ + { name: "Ada", role: "Engineer", score: 98 }, + { name: "Linus", role: "Kernel", score: 95 }, + ]); + }); + + const inputTable = screen.getByTestId("input-table"); + expect(within(inputTable).getByText("NAME")).toBeInTheDocument(); + expect(within(inputTable).getByText("ROLE")).toBeInTheDocument(); + expect(within(inputTable).getByText("SCORE")).toBeInTheDocument(); + expect(within(inputTable).getByText("Ada")).toBeInTheDocument(); + + const pill = screen.getByTestId("csv-clean-markdown-pill"); + expect(pill).toHaveTextContent("Clean Markdown table (2 rows)"); + + await user.click(pill); + + expect(screen.queryByTestId("csv-clean-markdown-pill")).toBeNull(); + + await user.click(screen.getByTestId("raw-toggle")); + const rawEditor = screen.getByTestId( + "input-editor" + ) as HTMLTextAreaElement; + expect(rawEditor.value).toBe( + "name,role,score\nAda,Engineer,98\nLinus,Kernel,95" + ); + + await user.click(screen.getByTestId("csv-undo-button")); + expect(rawEditor.value).toBe(mdTable); + expect(screen.getByTestId("csv-clean-markdown-pill")).toHaveTextContent( + "Clean Markdown table (2 rows)" + ); + }); + + it("auto-renders psql ASCII box tables and surfaces Clean CLI table pill", async () => { + const user = userEvent.setup(); + render(); + + const psqlTable = [ + " id | host | port ", + "----+-----------+------", + " 1 | db-prod-1 | 5432 ", + " 2 | db-read-2 | 5433 ", + "(2 rows)", + ].join("\n"); + + fireEvent.change(screen.getByTestId("paste-field"), { + target: { value: psqlTable }, + }); + + await waitFor(() => { + const output = JSON.parse( + screen.getByTestId("output-view").textContent ?? "[]" + ); + expect(output).toEqual([ + { id: 1, host: "db-prod-1", port: 5432 }, + { id: 2, host: "db-read-2", port: 5433 }, + ]); + }); + + const pill = screen.getByTestId("csv-clean-markdown-pill"); + expect(pill).toHaveTextContent("Clean CLI table (2 rows)"); + + await user.click(pill); + expect(screen.queryByTestId("csv-clean-markdown-pill")).toBeNull(); + }); +}); + + diff --git a/app/src/changelog/entries.ts b/app/src/changelog/entries.ts index 80502aa..ee53789 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: 21, + date: "2026-10-20", + tag: "new", + title: "Paste Markdown & CLI box tables directly into CSV → JSON", + summary: + "Paste GitHub/ChatGPT Markdown pipe tables or psql/MySQL ASCII box tables directly into CSV → JSON: divider rows, outer pipes, and (N rows) footers are stripped automatically, with a one-click Clean table action to normalize the raw CSV in place.", + }, { id: 20, date: "2026-10-20", diff --git a/app/src/components/CsvTable.tsx b/app/src/components/CsvTable.tsx index e8f7179..e7cbad3 100644 --- a/app/src/components/CsvTable.tsx +++ b/app/src/components/CsvTable.tsx @@ -20,6 +20,7 @@ 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 { detectMarkdownOrCliTable } from "@/lib/markdownTable"; import { deleteColumns, deleteRows, renameHeader } from "@/lib/tableDeletion"; import { matchHistoryShortcut } from "@/lib/csvHistory"; import { filterRowIndices, sortRowIndices, type SortDir } from "@/lib/tableView"; @@ -309,14 +310,24 @@ export function CsvTable({ const imageWindowLoaderRef = useRef(); if (imageWindowLoaderRef.current === undefined) imageWindowLoaderRef.current = new ImageWindowLoaderImpl(); - const table = useMemo(() => parseCsvTable(text, delimiter), [text, delimiter]); + const effectiveText = useMemo( + () => + delimiter === undefined + ? (detectMarkdownOrCliTable(text)?.cleanedCsv ?? text) + : text, + [text, delimiter] + ); + const table = useMemo( + () => parseCsvTable(effectiveText, delimiter), + [effectiveText, delimiter] + ); const numeric = useMemo(() => numericColumns(table), [table]); const columnsCount = table.headers.length; // Latest-value mirrors: event handlers (copy key, edit commits, canvas // draw callbacks) must always see the props of the last completed render. - const latestRef = useRef({ text, table }); - latestRef.current = { text, table }; + const latestRef = useRef({ text: effectiveText, table }); + latestRef.current = { text: effectiveText, table }; const gridSelectionRef = useRef(gridSelection); gridSelectionRef.current = gridSelection; diff --git a/app/src/components/InputPane.tsx b/app/src/components/InputPane.tsx index f704a93..2183019 100644 --- a/app/src/components/InputPane.tsx +++ b/app/src/components/InputPane.tsx @@ -13,6 +13,7 @@ import { resolveJsonFormatToggle, } from "@/lib/convert"; import { parseCsvTable } from "@/lib/csvTable"; +import { detectMarkdownOrCliTable } from "@/lib/markdownTable"; import { cn } from "@/lib/utils"; /** @@ -188,12 +189,22 @@ export function InputPane({ const fileInputRef = useRef(null); const inputEmpty = input.trim() === ""; const isCsv = format === "CSV"; + const detectedMarkdownTable = useMemo( + () => + !isCsv || inputEmpty || delimiter !== undefined + ? null + : detectMarkdownOrCliTable(input), + [isCsv, inputEmpty, input, delimiter] + ); const indexedHeaderGroups = useMemo(() => { if (!isCsv || inputEmpty) return []; - const headerSlice = sliceFirstCsvRecord(input); + const sourceCsv = detectedMarkdownTable + ? detectedMarkdownTable.cleanedCsv + : input; + const headerSlice = sliceFirstCsvRecord(sourceCsv); const table = parseCsvTable(headerSlice, delimiter); return detectIndexedHeaderGroups(table.headers.map((h) => h.trim())); - }, [isCsv, inputEmpty, input, delimiter]); + }, [isCsv, inputEmpty, input, delimiter, detectedMarkdownTable]); const wrapperCandidates = useMemo( () => (isCsv || inputEmpty ? [] : detectJsonWrapperCandidates(input)), [isCsv, inputEmpty, input] @@ -411,6 +422,28 @@ export function InputPane({ /> ) : isCsv ? ( <> + {detectedMarkdownTable ? ( +
    + + {detectedMarkdownTable.kind === "box" + ? "ASCII CLI box table detected:" + : "Markdown pipe table detected:"} + + +
    + ) : null} {indexedHeaderGroups.length > 0 ? (
    { + it("auto-normalizes GitHub / ChatGPT Markdown pipe tables in csvToJson and convertText", () => { + const md = [ + "| service | port | active |", + "| :--- | ---: | :---: |", + "| auth-api | 8080 | true |", + "| billing | 9090 | false |", + ].join("\n"); + + const parsed = csvToJson(md, { parseNumbers: true, parseJSON: true }); + expect(parsed).toEqual([ + { service: "auth-api", port: 8080, active: true }, + { service: "billing", port: 9090, active: false }, + ]); + + const res = convertText("csv2json", md, DEFAULT_OPTIONS); + expect(res.ok).toBe(true); + if (res.ok) { + expect(res.rows).toBe(2); + expect(res.cols).toBe(3); + expect(res.warnings).toBeUndefined(); + expect(JSON.parse(res.text)).toEqual([ + { service: "auth-api", port: 8080, active: true }, + { service: "billing", port: 9090, active: false }, + ]); + } + }); + + it("auto-normalizes psql and MySQL ASCII box tables (stripping borders and (N rows) footers)", () => { + const psql = [ + " id | city | pop ", + "----+----------+-----", + " 1 | Lisbon | 545 ", + " 2 | Porto | 231 ", + "(2 rows)", + ].join("\n"); + + const res = convertText("csv2json", psql, DEFAULT_OPTIONS); + expect(res.ok).toBe(true); + if (res.ok) { + expect(res.rows).toBe(2); + expect(res.cols).toBe(3); + expect(res.warnings).toBeUndefined(); + expect(JSON.parse(res.text)).toEqual([ + { id: 1, city: "Lisbon", pop: 545 }, + { id: 2, city: "Porto", pop: 231 }, + ]); + } + }); + + it("preserves explicit pipe separator behavior for plain pipe-separated CSV without divider rules", () => { + const plainPipe = "a|b\n1|2\n3|4"; + const res = convertText("csv2json", plainPipe, { + ...DEFAULT_OPTIONS, + separator: "|", + }); + expect(res.ok).toBe(true); + if (res.ok) { + expect(JSON.parse(res.text)).toEqual([ + { a: 1, b: 2 }, + { a: 3, b: 4 }, + ]); + } + }); +}); + + diff --git a/app/src/lib/convert.ts b/app/src/lib/convert.ts index 20c0373..85af92e 100644 --- a/app/src/lib/convert.ts +++ b/app/src/lib/convert.ts @@ -1,6 +1,7 @@ import csv2json from "csvjson-csv2json"; import json2csv from "csvjson-json2csv"; import { parseCsvTable } from "./csvTable"; +import { detectMarkdownOrCliTable } from "./markdownTable"; /** * Typed wrapper over the csvjson conversion packages. The packages are @@ -616,7 +617,12 @@ export function csvToJson( }; // Belt and suspenders: the package tolerates a BOM, but stripping it here // guarantees header detection never sees it (spec: UTF-8 BOM stripped on input). - const input = csv.startsWith(UTF8_BOM) ? csv.slice(UTF8_BOM.length) : csv; + const rawInput = csv.startsWith(UTF8_BOM) ? csv.slice(UTF8_BOM.length) : csv; + const normalizedTable = + options.separator === undefined + ? detectMarkdownOrCliTable(rawInput) + : null; + const input = normalizedTable ? normalizedTable.cleanedCsv : rawInput; try { // Structural parsing only: the package's own value coercion (parseNumbers // mangles leading zeros; parseJSON JSON.parses every cell, turning @@ -1061,15 +1067,22 @@ export function convertText( collapseIndexedArrays: options.collapseIndexedArrays ?? true, columnTypes: options.columnTypes, }; - const json = csvToJson(input, csv2jsonOptions); - let warnings = csvWarnings(input, csv2jsonOptions.separator); + const normalizedTable = + csv2jsonOptions.separator === undefined + ? detectMarkdownOrCliTable(input) + : null; + const effectiveInput = normalizedTable + ? normalizedTable.cleanedCsv + : input; + const json = csvToJson(effectiveInput, csv2jsonOptions); + let warnings = csvWarnings(effectiveInput, csv2jsonOptions.separator); if (options.hash && !Array.isArray(json)) { // The hash result carries no memory of how many rows went in (B4, // #143) — count what hashing started from: the array result for the // same input and options, minus hash. The parse is identical to the // run above, so this cannot fail where it passed, and the displayed // hash output stays exactly what the package produced. - const arrayJson = csvToJson(input, { ...csv2jsonOptions, hash: false }); + const arrayJson = csvToJson(effectiveInput, { ...csv2jsonOptions, hash: false }); const arrayRows = Array.isArray(arrayJson) ? arrayJson.length : 0; const collapse = duplicateKeyWarning( arrayRows, diff --git a/app/src/lib/csvTable.ts b/app/src/lib/csvTable.ts index 78f0d77..39e1a32 100644 --- a/app/src/lib/csvTable.ts +++ b/app/src/lib/csvTable.ts @@ -9,6 +9,8 @@ * and embedded newlines. Ragged rows are padded to the header width. */ +import { detectMarkdownOrCliTable } from "./markdownTable"; + export type CsvTableData = { headers: string[]; /** Data rows, padded to headers.length. Empty cells stay "" — never null. */ @@ -101,8 +103,11 @@ function parseField(source: string, start: number, delimiter: string): [string, * an empty trailing row. */ export function parseCsvTable(raw: string, forcedDelimiter?: string): CsvTableData { - const bomStripped = raw.startsWith(UTF8_BOM); - const text = bomStripped ? raw.slice(UTF8_BOM.length) : raw; + const mdTable = + forcedDelimiter === undefined ? detectMarkdownOrCliTable(raw) : null; + const effectiveRaw = mdTable ? mdTable.cleanedCsv : raw; + const bomStripped = effectiveRaw.startsWith(UTF8_BOM); + const text = bomStripped ? effectiveRaw.slice(UTF8_BOM.length) : effectiveRaw; // Row spans report offsets into the caller's string (BOM included), so a // commit can slice/splice the very text it holds. const spanBase = bomStripped ? UTF8_BOM.length : 0; diff --git a/app/src/lib/markdownTable.test.ts b/app/src/lib/markdownTable.test.ts new file mode 100644 index 0000000..56a1aaa --- /dev/null +++ b/app/src/lib/markdownTable.test.ts @@ -0,0 +1,127 @@ +import { describe, expect, it } from "vitest"; +import { detectMarkdownOrCliTable } from "./markdownTable"; + +describe("detectMarkdownOrCliTable (AC-14 / D13)", () => { + it("detects and normalizes a GitHub / ChatGPT Markdown pipe table with outer pipes and alignment colons", () => { + const md = [ + "| id | album | year |", + "| :--- | :---: | ---: |", + "| 1 | Elephant | 2003 |", + "| 2 | De Stijl | 2000 |", + ].join("\n"); + + const detected = detectMarkdownOrCliTable(md); + expect(detected).toEqual({ + cleanedCsv: "id,album,year\n1,Elephant,2003\n2,De Stijl,2000", + rows: 2, + cols: 3, + kind: "markdown", + }); + }); + + it("detects Markdown pipe tables without outer pipes and unescapes \\| inside cells", () => { + const md = [ + "cmd | description | notes", + "--- | --- | ---", + "a \\| b | Pipe expression, with comma | ok", + "c \\| d | Second \"quoted\" item | done", + ].join("\r\n"); + + const detected = detectMarkdownOrCliTable(md); + expect(detected).toEqual({ + cleanedCsv: + 'cmd,description,notes\na | b,"Pipe expression, with comma",ok\nc | d,"Second ""quoted"" item",done', + rows: 2, + cols: 3, + kind: "markdown", + }); + }); + + it("supports header-only Markdown pipe tables (0 data rows)", () => { + const md = "| col1 | col2 |\n| --- | --- |"; + const detected = detectMarkdownOrCliTable(md); + expect(detected).toEqual({ + cleanedCsv: "col1,col2", + rows: 0, + cols: 2, + kind: "markdown", + }); + }); + + it("detects and normalizes psql ASCII tables with ----+---- separator and (N rows) footer", () => { + const psql = [ + " id | album | year ", + "----+----------+------", + " 1 | Elephant | 2003", + " 2 | De Stijl | 2000", + "(2 rows)", + ].join("\n"); + + const detected = detectMarkdownOrCliTable(psql); + expect(detected).toEqual({ + cleanedCsv: "id,album,year\n1,Elephant,2003\n2,De Stijl,2000", + rows: 2, + cols: 3, + kind: "box", + }); + }); + + it("detects psql 1-row singular footer (1 row) and tables without a footer", () => { + const psqlSingle = [ + " id | name ", + "----+------", + " 1 | Ada ", + "(1 row)", + ].join("\n"); + + expect(detectMarkdownOrCliTable(psqlSingle)).toEqual({ + cleanedCsv: "id,name\n1,Ada", + rows: 1, + cols: 2, + kind: "box", + }); + + const psqlNoFooter = [ + " id | name ", + "----+------", + " 1 | Ada ", + ].join("\n"); + + expect(detectMarkdownOrCliTable(psqlNoFooter)).toEqual({ + cleanedCsv: "id,name\n1,Ada", + rows: 1, + cols: 2, + kind: "box", + }); + }); + + it("detects and normalizes MySQL / bordered +----+----+ ASCII box tables", () => { + const mysql = [ + "+----+----------+------+", + "| id | album | year |", + "+----+----------+------+", + "| 1 | Elephant | 2003 |", + "| 2 | De Stijl | 2000 |", + "+----+----------+------+", + ].join("\n"); + + const detected = detectMarkdownOrCliTable(mysql); + expect(detected).toEqual({ + cleanedCsv: "id,album,year\n1,Elephant,2003\n2,De Stijl,2000", + rows: 2, + cols: 3, + kind: "box", + }); + }); + + it("returns null for regular comma CSV, TSV, JSON, and plain pipe-separated CSV without separator rule lines", () => { + expect(detectMarkdownOrCliTable("")).toBeNull(); + expect(detectMarkdownOrCliTable("id,album,year\n1,Elephant,2003")).toBeNull(); + expect(detectMarkdownOrCliTable("id\talbum\tyear\n1\tElephant\t2003")).toBeNull(); + expect(detectMarkdownOrCliTable('[{"id":1,"album":"Elephant"}]')).toBeNull(); + // Plain pipe-separated CSV without |---|---| or ----+---- or +---+---+ must NOT match + expect( + detectMarkdownOrCliTable("id|album|year\n1|Elephant|2003\n2|De Stijl|2000") + ).toBeNull(); + }); +}); diff --git a/app/src/lib/markdownTable.ts b/app/src/lib/markdownTable.ts new file mode 100644 index 0000000..3f5cf8b --- /dev/null +++ b/app/src/lib/markdownTable.ts @@ -0,0 +1,238 @@ +import { serializeCsvTable } from "./csvTable"; + +export interface DetectedTablePaste { + cleanedCsv: string; + rows: number; + cols: number; + kind: "markdown" | "box"; +} + +const UTF8_BOM = "\uFEFF"; + +/** + * GitHub / ChatGPT Markdown pipe table alignment separator row: + * e.g. `| --- | :---: | ---: |` or `---|---` or `| --- |`. + */ +const MD_SEPARATOR_ROW_RE = + /^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/; + +/** + * ASCII box horizontal border line (`+----+----+` or `+====+====+`). + */ +const BOX_BORDER_LINE_RE = /^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/; + +/** + * `psql` horizontal separator rule line (`----+----+----` or `====+====`). + */ +const PSQL_RULE_LINE_RE = /^\s*[-=]+(?:\+[-=]+)+\s*$/; + +/** + * Optional trailing CLI row-count footer (`(2 rows)`, `(1 row)`, `2 rows in set (0.00 sec)`). + */ +const CLI_FOOTER_LINE_RE = + /^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i; + +function hasUnescapedPipe(line: string): boolean { + for (let i = 0; i < line.length; i++) { + if (line[i] === "\\" && i + 1 < line.length) { + i++; + continue; + } + if (line[i] === "|") return true; + } + return false; +} + +function endsWithUnescapedPipe(trimmed: string): boolean { + if (!trimmed.endsWith("|")) return false; + let backslashes = 0; + for (let i = trimmed.length - 2; i >= 0 && trimmed[i] === "\\"; i--) { + backslashes++; + } + return backslashes % 2 === 0; +} + +/** + * Split a Markdown table row on unescaped `|`, stripping optional outer + * leading/trailing `|`, unescaping `\|` -> `|`, and trimming cell padding. + */ +function parseMarkdownRow(line: string): string[] { + let body = line.trim(); + if (body.startsWith("|")) { + body = body.slice(1); + } + if (endsWithUnescapedPipe(body)) { + body = body.slice(0, -1); + } + + const cells: string[] = []; + let current = ""; + for (let i = 0; i < body.length; i++) { + const ch = body[i]; + if (ch === "\\" && body[i + 1] === "|") { + current += "|"; + i++; + continue; + } + if (ch === "|") { + cells.push(current.trim()); + current = ""; + continue; + } + current += ch; + } + cells.push(current.trim()); + return cells; +} + +/** + * Split a CLI / ASCII box row on `|`, stripping outer border pipes when the + * table is framed (`| a | b |`) and trimming cell whitespace. + */ +function parseBoxRow(line: string, framed: boolean): string[] { + let body = line.trim(); + if (framed) { + if (body.startsWith("|")) body = body.slice(1); + if (body.endsWith("|")) body = body.slice(0, -1); + } + return body.split("|").map((cell) => cell.trim()); +} + +/** + * Extract the first `limit` non-empty lines from `text` without splitting the + * entire string — keeps large-CSV non-matches O(1). + */ +function peekFirstNonEmptyLines(text: string, limit: number): string[] { + const result: string[] = []; + const maxScan = Math.min(text.length, 32 * 1024); + let lineStart = 0; + + for (let i = 0; i <= maxScan; i++) { + const atEnd = i === maxScan; + const ch = atEnd ? "\n" : text[i]; + if (ch === "\n" || ch === "\r") { + const line = text.slice(lineStart, i); + if (line.trim().length > 0) { + result.push(line); + if (result.length >= limit) return result; + } + if (ch === "\r" && text[i + 1] === "\n") { + i++; + } + lineStart = i + 1; + } + } + return result; +} + +function isBoxRuleOrBorder(line: string): boolean { + return BOX_BORDER_LINE_RE.test(line) || PSQL_RULE_LINE_RE.test(line); +} + +/** + * Detect and normalize GitHub/ChatGPT Markdown pipe tables and `psql`/MySQL + * ASCII box tables into canonical comma-delimited RFC 4180 CSV. + * + * Returns `null` for plain CSV, TSV, JSON, or pipe-delimited CSV that lacks a + * Markdown alignment separator row (`|---|---|`) or CLI box border/rule line + * (`+---+---+` / `----+----`). + */ +export function detectMarkdownOrCliTable( + input: string +): DetectedTablePaste | null { + if (!input) return null; + const raw = input.startsWith(UTF8_BOM) ? input.slice(UTF8_BOM.length) : input; + + // Fast O(1) pre-check over the first 3 non-empty lines so large regular CSVs + // never allocate a full-file line split. + const head = peekFirstNonEmptyLines(raw, 3); + if (head.length < 2) return null; + + const isMarkdownCandidate = + hasUnescapedPipe(head[0]) && + !isBoxRuleOrBorder(head[0]) && + !MD_SEPARATOR_ROW_RE.test(head[0]) && + MD_SEPARATOR_ROW_RE.test(head[1]); + + const isPsqlCandidate = + hasUnescapedPipe(head[0]) && + !isBoxRuleOrBorder(head[0]) && + (PSQL_RULE_LINE_RE.test(head[1]) || BOX_BORDER_LINE_RE.test(head[1])); + + const isBorderedBoxCandidate = + BOX_BORDER_LINE_RE.test(head[0]) && + hasUnescapedPipe(head[1]) && + !isBoxRuleOrBorder(head[1]) && + (head.length < 3 || isBoxRuleOrBorder(head[2]) || hasUnescapedPipe(head[2])); + + if (!isMarkdownCandidate && !isPsqlCandidate && !isBorderedBoxCandidate) { + return null; + } + + const nonEmptyLines = raw + .split(/\r?\n/) + .filter((line) => line.trim().length > 0); + if (nonEmptyLines.length < 2) return null; + + // Path A: GitHub / ChatGPT Markdown pipe table + if (isMarkdownCandidate && MD_SEPARATOR_ROW_RE.test(nonEmptyLines[1])) { + const headers = parseMarkdownRow(nonEmptyLines[0]); + if (headers.length === 0 || headers.every((h) => h === "")) return null; + + const dataRows: string[][] = []; + for (let i = 2; i < nonEmptyLines.length; i++) { + const line = nonEmptyLines[i]; + if (MD_SEPARATOR_ROW_RE.test(line)) continue; + if (!hasUnescapedPipe(line)) return null; + dataRows.push(parseMarkdownRow(line)); + } + + const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + return { + cleanedCsv, + rows: dataRows.length, + cols: headers.length, + kind: "markdown", + }; + } + + // Path B: psql / MySQL ASCII box table + let lineCount = nonEmptyLines.length; + if (lineCount >= 2 && CLI_FOOTER_LINE_RE.test(nonEmptyLines[lineCount - 1])) { + lineCount--; + } + + let sawRuleOrBorder = false; + const contentLines: string[] = []; + for (let i = 0; i < lineCount; i++) { + const line = nonEmptyLines[i]; + if (isBoxRuleOrBorder(line)) { + sawRuleOrBorder = true; + continue; + } + if (! line.includes("|")) return null; + contentLines.push(line); + } + + if (!sawRuleOrBorder || contentLines.length === 0) return null; + + const firstContent = contentLines[0].trim(); + const framed = + BOX_BORDER_LINE_RE.test(nonEmptyLines[0]) || + (firstContent.startsWith("|") && firstContent.endsWith("|")); + + const headers = parseBoxRow(contentLines[0], framed); + if (headers.length === 0 || headers.every((h) => h === "")) return null; + + const dataRows = contentLines + .slice(1) + .map((line) => parseBoxRow(line, framed)); + + const cleanedCsv = serializeCsvTable(headers, dataRows, ","); + return { + cleanedCsv, + rows: dataRows.length, + cols: headers.length, + kind: "box", + }; +}