From 7b5e471eb5374dc84bd2a62a61fa41bdf5338f8b Mon Sep 17 00:00:00 2001 From: Obvious Date: Sun, 1 Nov 2026 17:08:30 +0000 Subject: [PATCH] build(deps): bump runtime and test-support minors; unpin lucide-react lucide-react 1.41.0 -> ^1.66.0 (unpinned to caret), tailwind-merge ^2.6.0 -> ^3.7.0, @tanstack/react-virtual ^3.14.25, @codemirror/state ^6.7.6, @codemirror/view ^6.43.15, @testing-library/dom ^10.4.2, @testing-library/user-event ^14.6.8. Rebuilt app/dist (hash guard). Co-authored-by: David Boskovic --- ...s => data-grid-overlay-editor-BCyLLTrp.js} | 2 +- app/dist/assets/index-C58ChW15.js | 114 +++++++++++++++++ app/dist/assets/index-Dw_RpILp.js | 114 ----------------- ...B.js => number-overlay-editor-Cch5pRMh.js} | 2 +- app/dist/index.html | 4 +- app/package-lock.json | 119 +++++++----------- app/package.json | 14 +-- 7 files changed, 167 insertions(+), 202 deletions(-) rename app/dist/assets/{data-grid-overlay-editor-upJpLw4s.js => data-grid-overlay-editor-BCyLLTrp.js} (98%) create mode 100644 app/dist/assets/index-C58ChW15.js delete mode 100644 app/dist/assets/index-Dw_RpILp.js rename app/dist/assets/{number-overlay-editor-DAo7GPxB.js => number-overlay-editor-Cch5pRMh.js} (99%) diff --git a/app/dist/assets/data-grid-overlay-editor-upJpLw4s.js b/app/dist/assets/data-grid-overlay-editor-BCyLLTrp.js similarity index 98% rename from app/dist/assets/data-grid-overlay-editor-upJpLw4s.js rename to app/dist/assets/data-grid-overlay-editor-BCyLLTrp.js index 593fe97..ad8bfe9 100644 --- a/app/dist/assets/data-grid-overlay-editor-upJpLw4s.js +++ b/app/dist/assets/data-grid-overlay-editor-BCyLLTrp.js @@ -1 +1 @@ -import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./index-Dw_RpILp.js";var u=l(r(),1),d=t(),f=n(`div`)({name:`DataGridOverlayEditorStyle`,class:`gdg-d19meir1`,propsAsIs:!1,vars:{"d19meir1-0":[e=>e.targetY,`px`],"d19meir1-1":[e=>e.targetX,`px`],"d19meir1-2":[e=>e.targetWidth,`px`],"d19meir1-3":[e=>e.targetHeight,`px`],"d19meir1-4":[e=>e.targetY+10,`px`],"d19meir1-5":[e=>Math.max(0,(e.targetHeight-28)/2),`px`]}});function p(){let[e,t]=u.useState();return[e??void 0,t]}function m(){let[e,t]=p(),[n,r]=u.useState(0),[i,a]=u.useState(!0);return u.useLayoutEffect(()=>{if(e===void 0||!(`IntersectionObserver`in window))return;let t=new IntersectionObserver(e=>{e.length!==0&&a(e[0].isIntersecting)},{threshold:1});return t.observe(e),()=>t.disconnect()},[e]),u.useEffect(()=>{if(i||e===void 0)return;let t,n=()=>{let{right:i}=e.getBoundingClientRect();r(e=>Math.min(e+window.innerWidth-i-10,0)),t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>{t!==void 0&&cancelAnimationFrame(t)}},[e,i]),{ref:t,style:u.useMemo(()=>({transform:`translateX(${n}px)`}),[n])}}var h=t=>{let{target:n,content:r,onFinishEditing:l,forceEditMode:p,initialValue:h,imageEditorOverride:g,markdownDivCreateNode:_,highlight:v,className:y,theme:b,id:x,cell:S,bloom:C,validateCell:w,getCellRenderer:T,provideEditor:E,isOutsideClick:D}=t,[O,k]=u.useState(p?r:void 0),A=u.useRef(O??r);A.current=O??r;let[j,M]=u.useState(()=>w===void 0||!(e(r)&&w?.(S,r,A.current)===!1)),N=u.useCallback((e,t)=>{l(j?e:void 0,t)},[j,l]),P=u.useCallback(t=>{if(w!==void 0&&t!==void 0&&e(t)){let e=w(S,t,A.current);e===!1?M(!1):(typeof e==`object`&&(t=e),M(!0))}k(t)},[S,w]),F=u.useRef(!1),I=u.useRef(void 0),L=u.useCallback(()=>{N(O,[0,0]),F.current=!0},[O,N]),R=u.useCallback((e,t)=>{N(e,t??I.current??[0,0]),F.current=!0},[N]),z=u.useCallback(async e=>{let t=!1;e.key===`Escape`?(e.stopPropagation(),e.preventDefault(),I.current=[0,0]):e.key===`Enter`&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),I.current=[0,1],t=!0):e.key===`Tab`&&(e.stopPropagation(),e.preventDefault(),I.current=[e.shiftKey?-1:1,0],t=!0),window.setTimeout(()=>{!F.current&&I.current!==void 0&&(N(t?O:void 0,I.current),F.current=!0)},0)},[N,O]),B=O??r,[V,H]=u.useMemo(()=>{if(a(r))return[];let e=E?.(r);return e===void 0?[T(r)?.provideEditor?.(r),!1]:[e,!1]},[r,T,E]),{ref:U,style:W}=m(),G=!0,K,q=!0,J;if(V!==void 0){G=V.disablePadding!==!0,q=V.disableStyling!==!0;let t=s(V);t&&(J=V.styleOverride);let r=t?V.editor:V;K=u.createElement(r,{isHighlighted:v,onChange:P,value:B,initialValue:h,onFinishedEditing:R,validatedSelection:e(B)?B.selectionRange:void 0,forceEditMode:p,target:n,imageEditorOverride:g,markdownDivCreateNode:_,isValid:j,theme:b})}J={...J,...W};let Y=document.getElementById(`portal`);if(Y===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let X=q?`gdg-style`:`gdg-unstyle`;j||(X+=` gdg-invalid`),G&&(X+=` gdg-pad`);let Z=C?.[0]??1,Q=C?.[1]??1;return(0,d.createPortal)(u.createElement(i.Provider,{value:b},u.createElement(c,{style:o(b),className:y,onClickOutside:L,isOutsideClick:D},u.createElement(f,{ref:U,id:x,className:X,style:J,as:H===!0?`label`:void 0,targetX:n.x-Z,targetY:n.y-Q,targetWidth:n.width+Z*2,targetHeight:n.height+Q*2},u.createElement(`div`,{className:`gdg-clip-region`,onKeyDown:z},K)))),Y)};export{h as default}; \ No newline at end of file +import{a as e,c as t,i as n,l as r,n as i,o as a,r as o,s,t as c,u as l}from"./index-C58ChW15.js";var u=l(r(),1),d=t(),f=n(`div`)({name:`DataGridOverlayEditorStyle`,class:`gdg-d19meir1`,propsAsIs:!1,vars:{"d19meir1-0":[e=>e.targetY,`px`],"d19meir1-1":[e=>e.targetX,`px`],"d19meir1-2":[e=>e.targetWidth,`px`],"d19meir1-3":[e=>e.targetHeight,`px`],"d19meir1-4":[e=>e.targetY+10,`px`],"d19meir1-5":[e=>Math.max(0,(e.targetHeight-28)/2),`px`]}});function p(){let[e,t]=u.useState();return[e??void 0,t]}function m(){let[e,t]=p(),[n,r]=u.useState(0),[i,a]=u.useState(!0);return u.useLayoutEffect(()=>{if(e===void 0||!(`IntersectionObserver`in window))return;let t=new IntersectionObserver(e=>{e.length!==0&&a(e[0].isIntersecting)},{threshold:1});return t.observe(e),()=>t.disconnect()},[e]),u.useEffect(()=>{if(i||e===void 0)return;let t,n=()=>{let{right:i}=e.getBoundingClientRect();r(e=>Math.min(e+window.innerWidth-i-10,0)),t=requestAnimationFrame(n)};return t=requestAnimationFrame(n),()=>{t!==void 0&&cancelAnimationFrame(t)}},[e,i]),{ref:t,style:u.useMemo(()=>({transform:`translateX(${n}px)`}),[n])}}var h=t=>{let{target:n,content:r,onFinishEditing:l,forceEditMode:p,initialValue:h,imageEditorOverride:g,markdownDivCreateNode:_,highlight:v,className:y,theme:b,id:x,cell:S,bloom:C,validateCell:w,getCellRenderer:T,provideEditor:E,isOutsideClick:D}=t,[O,k]=u.useState(p?r:void 0),A=u.useRef(O??r);A.current=O??r;let[j,M]=u.useState(()=>w===void 0||!(e(r)&&w?.(S,r,A.current)===!1)),N=u.useCallback((e,t)=>{l(j?e:void 0,t)},[j,l]),P=u.useCallback(t=>{if(w!==void 0&&t!==void 0&&e(t)){let e=w(S,t,A.current);e===!1?M(!1):(typeof e==`object`&&(t=e),M(!0))}k(t)},[S,w]),F=u.useRef(!1),I=u.useRef(void 0),L=u.useCallback(()=>{N(O,[0,0]),F.current=!0},[O,N]),R=u.useCallback((e,t)=>{N(e,t??I.current??[0,0]),F.current=!0},[N]),z=u.useCallback(async e=>{let t=!1;e.key===`Escape`?(e.stopPropagation(),e.preventDefault(),I.current=[0,0]):e.key===`Enter`&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),I.current=[0,1],t=!0):e.key===`Tab`&&(e.stopPropagation(),e.preventDefault(),I.current=[e.shiftKey?-1:1,0],t=!0),window.setTimeout(()=>{!F.current&&I.current!==void 0&&(N(t?O:void 0,I.current),F.current=!0)},0)},[N,O]),B=O??r,[V,H]=u.useMemo(()=>{if(a(r))return[];let e=E?.(r);return e===void 0?[T(r)?.provideEditor?.(r),!1]:[e,!1]},[r,T,E]),{ref:U,style:W}=m(),G=!0,K,q=!0,J;if(V!==void 0){G=V.disablePadding!==!0,q=V.disableStyling!==!0;let t=s(V);t&&(J=V.styleOverride);let r=t?V.editor:V;K=u.createElement(r,{isHighlighted:v,onChange:P,value:B,initialValue:h,onFinishedEditing:R,validatedSelection:e(B)?B.selectionRange:void 0,forceEditMode:p,target:n,imageEditorOverride:g,markdownDivCreateNode:_,isValid:j,theme:b})}J={...J,...W};let Y=document.getElementById(`portal`);if(Y===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `
` as the last child of your ``.'),null;let X=q?`gdg-style`:`gdg-unstyle`;j||(X+=` gdg-invalid`),G&&(X+=` gdg-pad`);let Z=C?.[0]??1,Q=C?.[1]??1;return(0,d.createPortal)(u.createElement(i.Provider,{value:b},u.createElement(c,{style:o(b),className:y,onClickOutside:L,isOutsideClick:D},u.createElement(f,{ref:U,id:x,className:X,style:J,as:H===!0?`label`:void 0,targetX:n.x-Z,targetY:n.y-Q,targetWidth:n.width+Z*2,targetHeight:n.height+Q*2},u.createElement(`div`,{className:`gdg-clip-region`,onKeyDown:z},K)))),Y)};export{h as default}; \ No newline at end of file diff --git a/app/dist/assets/index-C58ChW15.js b/app/dist/assets/index-C58ChW15.js new file mode 100644 index 0000000..36c8872 --- /dev/null +++ b/app/dist/assets/index-C58ChW15.js @@ -0,0 +1,114 @@ +var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,te(x);else{var t=n(l);t!==null&&ne(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&ne(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,ne(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,te(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;nt}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,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(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[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(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` +`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{F=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?P(e):``}function I(e){switch(e.tag){case 5:return P(e.type);case 16:return P(`Lazy`);case 13:return P(`Suspense`);case 19:return P(`SuspenseList`);case 0:case 2:case 15:return e=se(e.type,!1),e;case 11:return e=se(e.type.render,!1),e;case 1:return e=se(e.type,!0),e;default:return``}}function ce(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case te:return`Suspense`;case ne:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case A:return(e.displayName||`Context`)+`.Consumer`;case k:return(e._context.displayName||`Context`)+`.Provider`;case ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}function le(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return ce(t);case 8:return t===D?`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 t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function ue(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function de(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function fe(e){var t=de(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pe(e){e._valueTracker||=fe(e)}function me(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=de(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function L(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function he(e,t){var n=t.checked;return N({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function R(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=ue(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function ge(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function z(e,t){ge(e,t);var n=ue(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?ve(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&ve(e,t.type,ue(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function _e(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function ve(e,t,n){(t!==`number`||L(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var ye=Array.isArray;function be(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ee.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oe(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ke={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},Ae=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(ke).forEach(function(e){Ae.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ke[t]=ke[e]})});function je(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||ke.hasOwnProperty(e)&&ke[e]?(``+t).trim():t+`px`}function Me(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=je(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Ne=N({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 Pe(e,t){if(t){if(Ne[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Fe(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ie=null;function Le(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Re=null,ze=null,Be=null;function Ve(e){if(e=Ii(e)){if(typeof Re!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Ri(t),Re(e.stateNode,e.type,t))}}function He(e){ze?Be?Be.push(e):Be=[e]:ze=e}function Ue(){if(ze){var e=ze,t=Be;if(Be=ze=null,Ve(e),t)for(e=0;e>>=0,e===0?32:31-(Et(e)/Dt|0)|0}var kt=64,At=4194304;function jt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Mt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=jt(a))):r=jt(s)}else o=n&~i,o===0?a!==0&&(r=jt(a)):r=jt(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Rt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Tt(t),e[t]=n}function zt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Xn),$n=` `,er=!1;function tr(e,t){switch(e){case`keyup`:return Jn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function nr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var rr=!1;function ir(e,t){switch(e){case`compositionend`:return nr(t);case`keypress`:return t.which===32?(er=!0,$n):null;case`textInput`:return e=t.data,e===$n&&er?null:e;default:return null}}function ar(e,t){if(rr)return e===`compositionend`||!Yn&&tr(e,t)?(e=bn(),yn=vn=_n=null,rr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Dr(n)}}function kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ar(){for(var e=window,t=L();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=L(e.document)}return t}function jr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Mr(e){var t=Ar(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&kr(n.ownerDocument.documentElement,n)){if(r!==null&&jr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=Or(n,a);var o=Or(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Pr=null,Fr=null,Ir=null,Lr=!1;function Rr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Lr||Pr==null||Pr!==L(r)||(r=Pr,`selectionStart`in r&&jr(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}),Ir&&Er(Ir,r)||(Ir=r,r=li(Fr,`onSelect`),0Bi||(e.current=zi[Bi],zi[Bi]=null,Bi--)}function Ui(e,t){Bi++,zi[Bi]=e.current,e.current=t}var Wi={},Gi=Vi(Wi),Ki=Vi(!1),qi=Wi;function Ji(e,t){var n=e.type.contextTypes;if(!n)return Wi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Yi(e){return e=e.childContextTypes,e!=null}function Xi(){Hi(Ki),Hi(Gi)}function Zi(e,t,n){if(Gi.current!==Wi)throw Error(r(168));Ui(Gi,t),Ui(Ki,n)}function Qi(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,le(e)||`Unknown`,a));return N({},n,i)}function $i(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wi,qi=Gi.current,Ui(Gi,e),Ui(Ki,Ki.current),!0}function ea(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=Qi(e,t,qi),i.__reactInternalMemoizedMergedChildContext=e,Hi(Ki),Hi(Gi),Ui(Gi,e)):Hi(Ki),Ui(Ki,n)}var ta=null,na=!1,ra=!1;function ia(e){ta===null?ta=[e]:ta.push(e)}function aa(e){na=!0,ia(e)}function oa(){if(!ra&&ta!==null){ra=!0;var e=0,t=Vt;try{var n=ta;for(Vt=1;e>=o,i-=o,ma=1<<32-Tt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),Sa&&ga(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Sa&&ga(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Sa&&ga(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Sa&&ga(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===j&&Ia(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Pa(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===E?(r=tu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=eu(i.type,i.key,i.props,null,e.mode,o),o.ref=Pa(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=iu(i,e.mode,o),r.return=e,e=r}return s(e);case j:return l=i._init,_(e,r,l(i._payload),o)}if(ye(i))return h(e,r,i,o);if(ae(i))return g(e,r,i,o);Fa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=ru(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var Ra=La(!0),za=La(!1),Ba=Vi(null),Va=null,Ha=null,Ua=null;function Wa(){Ua=Ha=Va=null}function Ga(e){var t=Ba.current;Hi(Ba),e._currentValue=t}function q(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ka(e,t){Va=e,Ua=Ha=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Fs=!0),e.firstContext=null)}function qa(e){var t=e._currentValue;if(Ua!==e){if(e={context:e,memoizedValue:t,next:null},Ha===null){if(Va===null)throw Error(r(308));Ha=e,Va.dependencies={lanes:0,firstContext:e}}else Ha=Ha.next=e}return t}var Ja=null;function Ya(e){Ja===null?Ja=[e]:Ja.push(e)}function Xa(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ya(t)):(n.next=i.next,i.next=n),t.interleaved=n,Za(e,r)}function Za(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qa=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function eo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function to(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function J(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Wc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Za(e,n)}return i=r.interleaved,i===null?(t.next=t,Ya(r)):(t.next=i.next,i.next=t),r.interleaved=t,Za(e,n)}function no(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Bt(e,n)}}function ro(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=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};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function io(e,t,n,r){var i=e.updateQueue;Qa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=N({},d,f);break a;case 2:Qa=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);Qc|=o,e.lanes=o,e.memoizedState=d}}function ao(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=xo.transition;xo.transition={};try{e(!1),t()}finally{Vt=n,xo.transition=r}}function cs(){return Fo().memoizedState}function ls(e,t,n){var r=_l(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ds(e))fs(t,n);else if(n=Xa(e,t,n,r),n!==null){var i=gl();vl(n,e,r,i),ps(n,t,r)}}function us(e,t,n){var r=_l(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ds(e))fs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Tr(s,o)){var c=t.interleaved;c===null?(i.next=i,Ya(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Xa(e,t,i,r),n!==null&&(i=gl(),vl(n,e,r,i),ps(n,t,r))}}function ds(e){var t=e.alternate;return e===Co||t!==null&&t===Co}function fs(e,t){Do=Eo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ps(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Bt(e,n)}}var ms={readContext:qa,useCallback:Ao,useContext:Ao,useEffect:Ao,useImperativeHandle:Ao,useInsertionEffect:Ao,useLayoutEffect:Ao,useMemo:Ao,useReducer:Ao,useRef:Ao,useState:Ao,useDebugValue:Ao,useDeferredValue:Ao,useTransition:Ao,useMutableSource:Ao,useSyncExternalStore:Ao,useId:Ao,unstable_isNewReconciler:!1},hs={readContext:qa,useCallback:function(e,t){return Po().memoizedState=[e,t===void 0?null:t],e},useContext:qa,useEffect:Zo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Yo(4194308,4,ts.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Yo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Yo(4,2,e,t)},useMemo:function(e,t){var n=Po();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Po();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=ls.bind(null,Co,e),[r.memoizedState,e]},useRef:function(e){var t=Po();return e={current:e},t.memoizedState=e},useState:Ko,useDebugValue:rs,useDeferredValue:function(e){return Po().memoizedState=e},useTransition:function(){var e=Ko(!1),t=e[0];return e=ss.bind(null,e[1]),Po().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=Co,a=Po();if(Sa){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Gc===null)throw Error(r(349));So&30||Vo(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Zo(Uo.bind(null,i,o,e),[e]),i.flags|=2048,qo(9,Ho.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Po(),t=Gc.identifierPrefix;if(Sa){var n=ha,r=ma;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=Oo++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[ki]=t,e[Ai]=i,ac(e,t,!1,!1),t.stateNode=e;a:{switch(c=Fe(n,i),n){case`dialog`:ni(`cancel`,e),ni(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:ni(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;o<$r.length;o++)ni($r[o],e);o=i;break;case`source`:ni(`error`,e),o=i;break;case`img`:case`image`:case`link`:ni(`error`,e),ni(`load`,e),o=i;break;case`details`:ni(`toggle`,e),o=i;break;case`input`:R(e,i),o=he(e,i),ni(`invalid`,e);break;case`option`:o=i;break;case`select`:e._wrapperState={wasMultiple:!!i.multiple},o=N({},i,{value:void 0}),ni(`invalid`,e);break;case`textarea`:Se(e,i),o=xe(e,i),ni(`invalid`,e);break;default:o=i}for(s in Pe(n,o),l=o,l)if(l.hasOwnProperty(s)){var u=l[s];s===`style`?Me(e,u):s===`dangerouslySetInnerHTML`?(u=u?u.__html:void 0,u!=null&&De(e,u)):s===`children`?typeof u==`string`?(n!==`textarea`||u!==``)&&Oe(e,u):typeof u==`number`&&Oe(e,``+u):s!==`suppressContentEditableWarning`&&s!==`suppressHydrationWarning`&&s!==`autoFocus`&&(a.hasOwnProperty(s)?u!=null&&s===`onScroll`&&ni(`scroll`,e):u!=null&&S(e,s,u,c))}switch(n){case`input`:pe(e),_e(e,i,!1);break;case`textarea`:pe(e),we(e);break;case`option`:i.value!=null&&e.setAttribute(`value`,``+ue(i.value));break;case`select`:e.multiple=!!i.multiple,s=i.value,s==null?i.defaultValue!=null&&be(e,!!i.multiple,i.defaultValue,!0):be(e,!!i.multiple,s,!1);break;default:typeof o.onClick==`function`&&(e.onclick=gi)}switch(n){case`button`:case`input`:case`select`:case`textarea`:i=!!i.autoFocus;break a;case`img`:i=!0;break a;default:i=!1}}i&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return lc(t),null;case 6:if(e&&t.stateNode!=null)sc(e,t,e.memoizedProps,i);else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(n=uo(lo.current),uo(so.current),ka(t)){if(i=t.stateNode,n=t.memoizedProps,i[ki]=t,(s=i.nodeValue!==n)&&(e=ba,e!==null))switch(e.tag){case 3:hi(i.nodeValue,n,!!(e.mode&1));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&hi(i.nodeValue,n,!!(e.mode&1))}s&&(t.flags|=4)}else i=(n.nodeType===9?n:n.ownerDocument).createTextNode(i),i[ki]=t,t.stateNode=i}return lc(t),null;case 13:if(Hi(go),i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Sa&&xa!==null&&t.mode&1&&!(t.flags&128))Aa(),ja(),t.flags|=98560,s=!1;else if(s=ka(t),i!==null&&i.dehydrated!==null){if(e===null){if(!s)throw Error(r(318));if(s=t.memoizedState,s=s===null?null:s.dehydrated,!s)throw Error(r(317));s[ki]=t}else ja(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;lc(t),s=!1}else Ca!==null&&(Sl(Ca),Ca=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(i=i!==null,i!==(e!==null&&e.memoizedState!==null)&&i&&(t.child.flags|=8192,t.mode&1&&(e===null||go.current&1?Xc===0&&(Xc=3):Ml())),t.updateQueue!==null&&(t.flags|=4),lc(t),null);case 4:return po(),e===null&&ai(t.stateNode.containerInfo),lc(t),null;case 10:return Ga(t.type._context),lc(t),null;case 17:return Yi(t.type)&&Xi(),lc(t),null;case 19:if(Hi(go),s=t.memoizedState,s===null)return lc(t),null;if(i=!!(t.flags&128),c=s.rendering,c===null){if(i)cc(s,!1);else{if(Xc!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(c=_o(e),c!==null){for(t.flags|=128,cc(s,!1),i=c.updateQueue,i!==null&&(t.updateQueue=i,t.flags|=4),t.subtreeFlags=0,i=n,n=t.child;n!==null;)s=n,e=i,s.flags&=14680066,c=s.alternate,c===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=c.childLanes,s.lanes=c.lanes,s.child=c.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=c.memoizedProps,s.memoizedState=c.memoizedState,s.updateQueue=c.updateQueue,s.type=c.type,e=c.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Ui(go,go.current&1|2),t.child}e=e.sibling}s.tail!==null&&ht()>il&&(t.flags|=128,i=!0,cc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=_o(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),cc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!Sa)return lc(t),null}else 2*ht()-s.renderingStartTime>il&&n!==1073741824&&(t.flags|=128,i=!0,cc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(lc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=ht(),t.sibling=null,n=go.current,Ui(go,i?n&1|2:n&1),t);case 22:case 23:return Ol(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Jc&1073741824&&(lc(t),t.subtreeFlags&6&&(t.flags|=8192)):lc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function dc(e,t){switch(ya(t),t.tag){case 1:return Yi(t.type)&&Xi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return po(),Hi(Ki),Hi(Gi),yo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ho(t),null;case 13:if(Hi(go),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));ja()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Hi(go),null;case 4:return po(),null;case 10:return Ga(t.type._context),null;case 22:case 23:return Ol(),null;case 24:return null;default:return null}}var fc=!1,pc=!1,mc=typeof WeakSet==`function`?WeakSet:Set,Y=null;function hc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Hl(e,t,n)}else n.current=null}}function gc(e,t,n){try{n()}catch(n){Hl(e,t,n)}}var _c=!1;function vc(e,t){if(_i=un,e=Ar(),jr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(vi={focusedElem:e,selectionRange:n},un=!1,Y=t;Y!==null;)if(t=Y,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Y=e;else for(;Y!==null;){t=Y;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:vs(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Hl(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,Y=e;break}Y=t.return}return h=_c,_c=!1,h}function yc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&gc(t,n,a)}i=i.next}while(i!==r)}}function bc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function xc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Sc(e){var t=e.alternate;t!==null&&(e.alternate=null,Sc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ki],delete t[Ai],delete t[Mi],delete t[Ni],delete t[Pi])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Cc(e){return e.tag===5||e.tag===3||e.tag===4}function wc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Cc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Tc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=gi));else if(r!==4&&(e=e.child,e!==null))for(Tc(e,t,n),e=e.sibling;e!==null;)Tc(e,t,n),e=e.sibling}function Ec(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ec(e,t,n),e=e.sibling;e!==null;)Ec(e,t,n),e=e.sibling}var Dc=null,Oc=!1;function kc(e,t,n){for(n=n.child;n!==null;)Ac(e,t,n),n=n.sibling}function Ac(e,t,n){if(Ct&&typeof Ct.onCommitFiberUnmount==`function`)try{Ct.onCommitFiberUnmount(St,n)}catch{}switch(n.tag){case 5:pc||hc(n,t);case 6:var r=Dc,i=Oc;Dc=null,kc(e,t,n),Dc=r,Oc=i,Dc!==null&&(Oc?(e=Dc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Dc.removeChild(n.stateNode));break;case 18:Dc!==null&&(Oc?(e=Dc,n=n.stateNode,e.nodeType===8?Ti(e.parentNode,n):e.nodeType===1&&Ti(e,n),cn(e)):Ti(Dc,n.stateNode));break;case 4:r=Dc,i=Oc,Dc=n.stateNode.containerInfo,Oc=!0,kc(e,t,n),Dc=r,Oc=i;break;case 0:case 11:case 14:case 15:if(!pc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&gc(n,t,o),i=i.next}while(i!==r)}kc(e,t,n);break;case 1:if(!pc&&(hc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Hl(n,t,e)}kc(e,t,n);break;case 21:kc(e,t,n);break;case 22:n.mode&1?(pc=(r=pc)||n.memoizedState!==null,kc(e,t,n),pc=r):kc(e,t,n);break;default:kc(e,t,n)}}function jc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new mc),t.forEach(function(t){var r=Kl.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Mc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=ht()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Bc(i/1960))-i,10e?16:e,ul===null)var i=!1;else{if(e=ul,ul=null,dl=0,Wc&6)throw Error(r(331));var a=Wc;for(Wc|=4,Y=e.current;Y!==null;){var o=Y,s=o.child;if(Y.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lht()-rl?kl(e,0):el|=n),yl(e,t)}function Wl(e,t){t===0&&(e.mode&1?(t=At,At<<=1,!(At&130023424)&&(At=4194304)):t=1);var n=gl();e=Za(e,t),e!==null&&(Rt(e,t,n),yl(e,n))}function Gl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Wl(e,n)}function Kl(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Wl(e,n)}var ql=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Ki.current)Fs=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Fs=!1,ic(e,t,n);Fs=!!(e.flags&131072)}}else Fs=!1,Sa&&t.flags&1048576&&_a(t,ua,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;nc(e,t),e=t.pendingProps;var a=Ji(t,Gi.current);Ka(t,n),a=Mo(null,t,i,e,a,n);var o=No();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Yi(i)?(o=!0,$i(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,$a(t),a.updater=bs,t.stateNode=a,a._reactInternals=t,ws(t,i,e,n),t=Ws(null,t,i,!0,o,n)):(t.tag=0,Sa&&o&&va(t),Is(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(nc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=Ql(i),e=vs(i,e),a){case 0:t=Hs(null,t,i,e,n);break a;case 1:t=Us(null,t,i,e,n);break a;case 11:t=Ls(null,t,i,e,n);break a;case 14:t=Rs(null,t,i,vs(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Hs(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Us(e,t,i,a,n);case 3:a:{if(Gs(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,eo(e,t),io(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Ts(Error(r(423)),t),t=Ks(e,t,i,n,a);break a}if(i!==a){a=Ts(Error(r(424)),t),t=Ks(e,t,i,n,a);break a}for(xa=Ei(t.stateNode.containerInfo.firstChild),ba=t,Sa=!0,Ca=null,n=za(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ja(),i===a){t=rc(e,t,n);break a}Is(e,t,i,n)}t=t.child}return t;case 5:return mo(t),e===null&&Da(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,yi(i,a)?s=null:o!==null&&yi(i,o)&&(t.flags|=32),Vs(e,t),Is(e,t,s,n),t.child;case 6:return e===null&&Da(t),null;case 13:return Ys(e,t,n);case 4:return fo(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Ra(t,null,i,n):Is(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),Ls(e,t,i,a,n);case 7:return Is(e,t,t.pendingProps,n),t.child;case 8:return Is(e,t,t.pendingProps.children,n),t.child;case 12:return Is(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ui(Ba,i._currentValue),i._currentValue=s,o!==null){if(Tr(o.value,s)){if(o.children===a.children&&!Ki.current){t=rc(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=to(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),q(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),q(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Is(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Ka(t,n),a=qa(a),i=i(a),t.flags|=1,Is(e,t,i,n),t.child;case 14:return i=t.type,a=vs(i,t.pendingProps),a=vs(i.type,a),Rs(e,t,i,a,n);case 15:return zs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:vs(i,a),nc(e,t),t.tag=1,Yi(i)?(e=!0,$i(t)):e=!1,Ka(t,n),Ss(t,i,a),ws(t,i,a,n),Ws(null,t,i,!0,e,n);case 19:return tc(e,t,n);case 22:return Bs(e,t,n)}throw Error(r(156,t.tag))};function Jl(e,t){return dt(e,t)}function Yl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Xl(e,t,n,r){return new Yl(e,t,n,r)}function Zl(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Ql(e){if(typeof e==`function`)return+!!Zl(e);if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===re)return 14}return 2}function $l(e,t){var n=e.alternate;return n===null?(n=Xl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function eu(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Zl(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return tu(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Xl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case te:return e=Xl(13,n,t,a),e.elementType=te,e.lanes=o,e;case ne:return e=Xl(19,n,t,a),e.elementType=ne,e.lanes=o,e;case M:return nu(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case ee:s=11;break a;case re:s=14;break a;case j:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Xl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function tu(e,t,n,r){return e=Xl(7,e,r,t),e.lanes=n,e}function nu(e,t,n,r){return e=Xl(22,e,r,t),e.elementType=M,e.lanes=n,e.stateNode={isHidden:!1},e}function ru(e,t,n){return e=Xl(6,e,null,t),e.lanes=n,e}function iu(e,t,n){return t=Xl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function au(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Lt(0),this.expirationTimes=Lt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lt(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ou(e,t,n,r,i,a,o,s,c){return e=new au(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Xl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(a),e}function su(e,t,n){var r=3{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u(),1),_=h();function v(){return``}function y(){return/^G-[A-Z0-9]+$/.test(v())}function b(){let e=window.gtag;typeof e==`function`&&y()&&e(`config`,v(),{send_page_view:!1})}function x(){window.gtag?.(`event`,`page_view`,{page_path:window.location.pathname,page_location:window.location.href}),window.plausible?.(`pageview`)}function S(){window.gtag?.(`event`,`permalink_view`),window.plausible?.(`Permalink View`)}function C(){window.gtag?.(`event`,`changelog_open`),window.plausible?.(`Changelog Open`)}function w(e){window.gtag?.(`event`,`changelog_vote`,{...e}),window.plausible?.(`Changelog Vote`,{props:{...e}})}function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}function E(e,t){window.gtag?.(`event`,e,{...t}),window.plausible?.(T(e),{props:{...t}})}function D(e){E(`input`,e)}function O(e){E(`conversion`,e)}function k(e){E(`export`,{via:e.via,format:e.format,...e.pane===void 0?{}:{pane:e.pane},...e.direction===void 0?{}:{direction:e.direction}})}function A(e){E(`feedback`,e)}function ee(e){return new TextEncoder().encode(e).length}function te(e){return e<10240?`<10KB`:e<102400?`10-100KB`:e<1048576?`100KB-1MB`:`>1MB`}function ne(e){let t=2166136261;for(let n=0;n>>0).toString(36)}function re(e={}){let t=e.settleMs??2e3,n=e.minWindowMs??2e3,r=e.now??(()=>Date.now()),i=e.isValid??(()=>!0),a=null,o,s=null,c=0,l=null,u=0;function d(e){if(e.text.trim()===``)return!1;let t=ee(e.text),a=te(t),o=i(e.direction,e.text),d=`${e.direction}:${e.input}:${t}:${ne(e.text)}`,f=r();return d!==s&&(c===0||f-c>=n)&&(s=d,c=f,D({direction:e.direction,input:e.input,size:a,valid:o})),!o||d===l||u!==0&&f-u{o=void 0,a&&d(a)},t)}return{edit(e,t){a={direction:e,input:`paste`,text:t},f()},discrete(e,t,n){a={direction:e,input:t,text:n},f(),d(a)},cancel(){a=null,s=null,l=null,o&&=(clearTimeout(o),void 0)}}}var j=e=>e?.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase();function M(e,t,n=[]){if(t==null)throw Error(`[lucide]: iconNode is required when icon name is used`);return{name:j(e),size:24,node:t,...n.length>0?{aliases:n}:{}}}var ie=e=>{let t=``,n=!1;for(let r of e)r===`-`||r===`_`||r<=` `?n=t.length>0:(t.length===0?t+=r.toLowerCase():t+=n?r.toUpperCase():r,n=!1);return t},ae=e=>{let t=ie(e);return t.charAt(0).toUpperCase()+t.slice(1)},N=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),oe={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,"stroke-width":2,"stroke-linecap":`round`,"stroke-linejoin":`round`};function P(e){return e!=null}function F(e,t={}){let n=t.attributeNames??{},r=e=>n[e]??e,i=e.size??e.width??oe.width,a=e.size??e.height??oe.height,o=e.aliases?.filter(e=>typeof e==`string`&&e.trim()!==``).map(e=>`lucide-${e}`)??[],s=[...e.name?[`lucide-${e.name}`]:[],...o],c=t.className?.split(` `).filter(Boolean)??[],l=t.includeDefaultClasses===!1?N(...c):N(`lucide`,...s,...c),u=t.absoluteStrokeWidth?Number(t.strokeWidth??oe[`stroke-width`])*Number(e.size??e.width??oe.width)/Number(t.size??t.width??oe.width):t.strokeWidth??oe[`stroke-width`];return[`svg`,{...Object.entries(oe).reduce((e,[t,n])=>(e[r(t)]=n,e),{}),...`color`in t&&t.color&&{[r(`stroke`)]:t.color},...`size`in t&&P(t.size)&&{[r(`width`)]:t.size,[r(`height`)]:t.size},...`width`in t&&P(t.width)&&{[r(`width`)]:t.width},...`height`in t&&P(t.height)&&{[r(`height`)]:t.height},[r(`stroke-width`)]:u,...l&&{[r(`class`)]:l},[r(`viewBox`)]:`0 0 ${i} ${a}`,...t.hasA11yProp===!1?{[r(`aria-hidden`)]:`true`}:{},...`attributes`in t&&t.attributes},e.node.map(e=>{let[n,i,a]=e,o=t.nonScalingStroke?{[r(`vector-effect`)]:`non-scaling-stroke`,...i}:i;return a?[n,o,a]:[n,o]})]}function se(e,t={}){return F(e,{...t,attributeNames:{...t.attributeNames,class:`className`,"stroke-width":`strokeWidth`,"stroke-linecap":`strokeLinecap`,"stroke-linejoin":`strokeLinejoin`,"vector-effect":`vectorEffect`}})}var I=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},ce=(0,g.createContext)({}),le=()=>(0,g.useContext)(ce),ue=(0,g.forwardRef)(({color:e,size:t,width:n,height:r,strokeWidth:i,absoluteStrokeWidth:a,nonScalingStroke:o,className:s=``,children:c,iconNode:l=[],icon:u={node:l,aliases:[],size:24},...d},f)=>{let{size:p=24,strokeWidth:m=2,absoluteStrokeWidth:h=!1,nonScalingStroke:_=!1,color:v=`currentColor`,className:y=``}=le()??{},b=!!c||I(d),[x,S,C=[]]=se(u,{color:e??v,width:n??t??p,height:r??t??p,strokeWidth:i??m,absoluteStrokeWidth:a??h,nonScalingStroke:o??_,className:N(y,s),hasA11yProp:b,attributes:d});return(0,g.createElement)(x,{ref:f,...S},[...C.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(c)?c:[c]])});function de(e,t=[],n=[]){let r=typeof e==`string`?M(e,t,n):e,i=(0,g.forwardRef)(({className:e,...t},n)=>(0,g.createElement)(ue,{ref:n,icon:r,className:e,...t}));return r.name&&(i.displayName=ae(r.name)),i}var fe={name:`arrow-left-right`,size:24,node:[[`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`}]]};fe.node;var pe=de(fe),me={name:`braces`,size:24,node:[[`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`}]],aliases:[`curly-braces`]};me.node;var L=de(me),he={name:`chevron-down`,size:24,node:[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]};he.node;var R=de(he),ge={name:`clipboard`,size:24,node:[[`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`}]]};ge.node;var z=de(ge),_e={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};_e.node;var ve=de(_e),ye={name:`columns-3`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]],aliases:[`panels-left-right`]};ye.node;var be=de(ye),xe={name:`copy`,size:24,node:[[`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`}]]};xe.node;var Se=de(xe),Ce={name:`download`,size:24,node:[[`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`}]]};Ce.node;var we=de(Ce),B={name:`file-up`,size:24,node:[[`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`}]]};B.node;var Te=de(B),Ee={name:`moon`,size:24,node:[[`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`}]]};Ee.node;var De=de(Ee),Oe={name:`redo-2`,size:24,node:[[`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`}]]};Oe.node;var ke=de(Oe),Ae={name:`rotate-ccw-clock`,size:24,node:[[`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`}]],aliases:[`history`]};Ae.node;var je=de(Ae),Me={name:`rotate-ccw`,size:24,node:[[`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`}]]};Me.node;var Ne=de(Me),Pe={name:`search`,size:24,node:[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]};Pe.node;var Fe=de(Pe),Ie={name:`sparkles`,size:24,node:[[`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`}]],aliases:[`stars`]};Ie.node;var Le=de(Ie),Re={name:`sun`,size:24,node:[[`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`}]]};Re.node;var ze=de(Re),Be={name:`table`,size:24,node:[[`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`}]]};Be.node;var Ve=de(Be),He={name:`thumbs-down`,size:24,node:[[`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`}]]};He.node;var Ue=de(He),We={name:`thumbs-up`,size:24,node:[[`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`}]]};We.node;var Ge=de(We),Ke={name:`trash`,size:24,node:[[`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`}]],aliases:[`trash-2`]};Ke.node;var qe=de(Ke),Je={name:`undo-2`,size:24,node:[[`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`}]]};Je.node;var Ye=de(Je),Xe={name:`x`,size:24,node:[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]};Xe.node;var Ze=de(Xe);function Qe(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t{let n=Array(e.length+t.length);for(let t=0;t({classGroupId:e,validator:t}),nt=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),rt=`-`,it=[],at=`arbitrary..`,ot=e=>{let t=lt(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return ct(e);let n=e.split(rt);return st(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?et(i,t):t:i||it}return n[e]||it}}},st=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=st(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(rt):e.slice(t).join(rt),s=a.length;for(let e=0;ee.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?at+r:void 0})(),lt=e=>{let{theme:t,classGroups:n}=e;return ut(n,t)},ut=(e,t)=>{let n=nt();for(let r in e){let i=e[r];dt(i,n,r,t)}return n},dt=(e,t,n,r)=>{let i=e.length;for(let a=0;a{typeof e==`string`?pt(e,t,n):typeof e==`function`?mt(e,t,n,r):ht(e,t,n,r)},pt=(e,t,n)=>{let r=e===``?t:gt(t,e);r.classGroupId=n},mt=(e,t,n,r)=>{_t(e)?dt(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(tt(n,e)))},ht=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e{let n=e,r=t.split(rt),i=r.length;for(let e=0;e`isThemeGetter`in e&&e.isThemeGetter===!0,vt=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},yt=`!`,bt=`:`,xt=[],St=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Ct=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;si?a-i:void 0;return St(t,l,c,u)};if(t){let e=t+bt,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):St(xt,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},wt=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Tt=e=>({cache:vt(e.cacheSize),parseClassName:Ct(e),sortModifiers:wt(e),postfixLookupClassGroupIds:Et(e),...ot(e)}),Et=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Dt),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+yt:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e0?` `+l:l)}return l},kt=(...e)=>{let t=0,n,r,i=``;for(;t{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r{let n,r,i,a,o=o=>(n=Tt(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Ot(e,n);return i(e,a),a};return a=o,(...e)=>a(kt(...e))},Mt=[],Nt=e=>{let t=t=>t[e]||Mt;return t.isThemeGetter=!0,t.themeKey=e,t},Pt=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ft=/^\((?:(\w[\w-]*):)?(.+)\)$/i,It=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Lt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rt=/\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$/,zt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,Bt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Vt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ht=e=>It.test(e),V=e=>!!e&&!Number.isNaN(Number(e)),Ut=e=>!!e&&Number.isInteger(Number(e)),Wt=e=>e.endsWith(`%`)&&V(e.slice(0,-1)),Gt=e=>Lt.test(e),Kt=()=>!0,qt=e=>Rt.test(e)&&!zt.test(e),Jt=()=>!1,H=e=>Bt.test(e),Yt=e=>Vt.test(e),Xt=e=>!U(e)&&!W(e),Zt=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Qt=e=>mn(e,vn,Jt),U=e=>Pt.test(e),$t=e=>mn(e,yn,qt),en=e=>mn(e,bn,V),tn=e=>mn(e,Sn,Kt),nn=e=>mn(e,xn,Jt),rn=e=>mn(e,gn,Jt),an=e=>mn(e,_n,Yt),on=e=>mn(e,Cn,H),W=e=>Ft.test(e),sn=e=>hn(e,yn),cn=e=>hn(e,xn),ln=e=>hn(e,gn),un=e=>hn(e,vn),dn=e=>hn(e,_n),fn=e=>hn(e,Cn,!0),pn=e=>hn(e,Sn,!0),mn=(e,t,n)=>{let r=Pt.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},hn=(e,t,n=!1)=>{let r=Ft.exec(e);return r?r[1]?t(r[1]):n:!1},gn=e=>e===`position`||e===`percentage`,_n=e=>e===`image`||e===`url`,vn=e=>e===`length`||e===`size`||e===`bg-size`,yn=e=>e===`length`,bn=e=>e===`number`,xn=e=>e===`family-name`,Sn=e=>e===`number`||e===`weight`,Cn=e=>e===`shadow`,wn=jt(()=>{let e=Nt(`color`),t=Nt(`font`),n=Nt(`text`),r=Nt(`font-weight`),i=Nt(`tracking`),a=Nt(`leading`),o=Nt(`breakpoint`),s=Nt(`container`),c=Nt(`spacing`),l=Nt(`radius`),u=Nt(`shadow`),d=Nt(`inset-shadow`),f=Nt(`text-shadow`),p=Nt(`drop-shadow`),m=Nt(`blur`),h=Nt(`perspective`),g=Nt(`aspect`),_=Nt(`ease`),v=Nt(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),W,U],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[W,U,c],T=()=>[Ht,`full`,`auto`,...w()],E=()=>[Ut,`none`,`subgrid`,W,U],D=()=>[`auto`,{span:[`full`,Ut,W,U]},Ut,W,U],O=()=>[Ut,`auto`,W,U],k=()=>[`auto`,`min`,`max`,`fr`,W,U],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],ee=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],te=()=>[`auto`,...w()],ne=()=>[Ht,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],re=()=>[s,Ht,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],j=()=>[Ht,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],M=()=>[e,W,U],ie=()=>[...b(),ln,rn,{position:[W,U]}],ae=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],N=()=>[`auto`,`cover`,`contain`,un,Qt,{size:[W,U]}],oe=()=>[Wt,sn,$t],P=()=>[``,`none`,`full`,l,W,U],F=()=>[``,V,sn,$t],se=()=>[`solid`,`dashed`,`dotted`,`double`],I=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ce=()=>[V,Wt,ln,rn],le=()=>[``,`none`,m,W,U],ue=()=>[`none`,V,W,U],de=()=>[`none`,V,W,U],fe=()=>[V,W,U],pe=()=>[Ht,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Gt],breakpoint:[Gt],color:[Kt],container:[Gt],"drop-shadow":[Gt],ease:[`in`,`out`,`in-out`],font:[Xt],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Gt],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Gt],shadow:[Gt],spacing:[`px`,V],text:[Gt],"text-shadow":[Gt],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,Ht,U,W,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,W,U]}],"container-named":[Zt],columns:[{columns:[V,`auto`,U,W,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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`],sr:[`sr-only`,`not-sr-only`],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:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Ut,`auto`,W,U]}],basis:[{basis:[Ht,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[V,Ht,`auto`,`initial`,`none`,U]}],grow:[{grow:[``,V,W,U]}],shrink:[{shrink:[``,V,W,U]}],order:[{order:[Ut,`first`,`last`,`none`,W,U]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...ee(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...ee()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...ee(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...ee(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...ee(),`baseline`]}],"place-self":[{"place-self":[`auto`,...ee()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:ne()}],"inline-size":[{inline:[`auto`,...re()]}],"min-inline-size":[{"min-inline":[`auto`,...re()]}],"max-inline-size":[{"max-inline":[`none`,...re()]}],"block-size":[{block:[`auto`,...j()]}],"min-block-size":[{"min-block":[`auto`,...j()]}],"max-block-size":[{"max-block":[`none`,...j()]}],w:[{w:[s,`screen`,...ne()]}],"min-w":[{"min-w":[s,`screen`,`none`,...ne()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...ne()]}],h:[{h:[`screen`,`lh`,...ne()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...ne()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...ne()]}],"font-size":[{text:[`base`,n,sn,$t]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,pn,tn]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Wt,U]}],"font-family":[{font:[cn,nn,t]}],"font-features":[{"font-features":[U]}],"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:[i,W,U]}],"line-clamp":[{"line-clamp":[V,`none`,W,en]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,W,U]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,W,U]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...se(),`wavy`]}],"text-decoration-thickness":[{decoration:[V,`from-font`,`auto`,W,$t]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[V,`auto`,W,U]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[Ut,W,U]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,W,U]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,W,U]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:ie()}],"bg-repeat":[{bg:ae()}],"bg-size":[{bg:N()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Ut,W,U],radial:[``,W,U],conic:[``,Ut,W,U]},dn,an]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:oe()}],"gradient-via-pos":[{via:oe()}],"gradient-to-pos":[{to:oe()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:P()}],"rounded-s":[{"rounded-s":P()}],"rounded-e":[{"rounded-e":P()}],"rounded-t":[{"rounded-t":P()}],"rounded-r":[{"rounded-r":P()}],"rounded-b":[{"rounded-b":P()}],"rounded-l":[{"rounded-l":P()}],"rounded-ss":[{"rounded-ss":P()}],"rounded-se":[{"rounded-se":P()}],"rounded-ee":[{"rounded-ee":P()}],"rounded-es":[{"rounded-es":P()}],"rounded-tl":[{"rounded-tl":P()}],"rounded-tr":[{"rounded-tr":P()}],"rounded-br":[{"rounded-br":P()}],"rounded-bl":[{"rounded-bl":P()}],"border-w":[{border:F()}],"border-w-x":[{"border-x":F()}],"border-w-y":[{"border-y":F()}],"border-w-s":[{"border-s":F()}],"border-w-e":[{"border-e":F()}],"border-w-bs":[{"border-bs":F()}],"border-w-be":[{"border-be":F()}],"border-w-t":[{"border-t":F()}],"border-w-r":[{"border-r":F()}],"border-w-b":[{"border-b":F()}],"border-w-l":[{"border-l":F()}],"divide-x":[{"divide-x":F()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":F()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...se(),`hidden`,`none`]}],"divide-style":[{divide:[...se(),`hidden`,`none`]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...se(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[V,W,U]}],"outline-w":[{outline:[``,V,sn,$t]}],"outline-color":[{outline:M()}],shadow:[{shadow:[``,`inner`,`none`,u,fn,on]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":[`none`,d,fn,on]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:F()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[V,$t]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":F()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":[`none`,f,fn,on]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[V,W,U]}],"mix-blend":[{"mix-blend":[...I(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":I()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[V]}],"mask-image-linear-from-pos":[{"mask-linear-from":ce()}],"mask-image-linear-to-pos":[{"mask-linear-to":ce()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":ce()}],"mask-image-t-to-pos":[{"mask-t-to":ce()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":ce()}],"mask-image-r-to-pos":[{"mask-r-to":ce()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":ce()}],"mask-image-b-to-pos":[{"mask-b-to":ce()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":ce()}],"mask-image-l-to-pos":[{"mask-l-to":ce()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":ce()}],"mask-image-x-to-pos":[{"mask-x-to":ce()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":ce()}],"mask-image-y-to-pos":[{"mask-y-to":ce()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[W,U]}],"mask-image-radial-from-pos":[{"mask-radial-from":ce()}],"mask-image-radial-to-pos":[{"mask-radial-to":ce()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[V]}],"mask-image-conic-from-pos":[{"mask-conic-from":ce()}],"mask-image-conic-to-pos":[{"mask-conic-to":ce()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:ie()}],"mask-repeat":[{mask:ae()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,W,U]}],filter:[{filter:[``,`none`,W,U]}],blur:[{blur:le()}],brightness:[{brightness:[V,W,U]}],contrast:[{contrast:[V,W,U]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,fn,on]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:[``,V,W,U]}],"hue-rotate":[{"hue-rotate":[V,W,U]}],invert:[{invert:[``,V,W,U]}],saturate:[{saturate:[V,W,U]}],sepia:[{sepia:[``,V,W,U]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,W,U]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[V,W,U]}],"backdrop-contrast":[{"backdrop-contrast":[V,W,U]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,V,W,U]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[V,W,U]}],"backdrop-invert":[{"backdrop-invert":[``,V,W,U]}],"backdrop-opacity":[{"backdrop-opacity":[V,W,U]}],"backdrop-saturate":[{"backdrop-saturate":[V,W,U]}],"backdrop-sepia":[{"backdrop-sepia":[``,V,W,U]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,W,U]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[V,`initial`,W,U]}],ease:[{ease:[`linear`,`initial`,_,W,U]}],delay:[{delay:[V,W,U]}],animate:[{animate:[`none`,v,W,U]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,W,U]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:ue()}],"rotate-x":[{"rotate-x":ue()}],"rotate-y":[{"rotate-y":ue()}],"rotate-z":[{"rotate-z":ue()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":[`scale-3d`],skew:[{skew:fe()}],"skew-x":[{"skew-x":fe()}],"skew-y":[{"skew-y":fe()}],transform:[{transform:[W,U,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:pe()}],"translate-x":[{"translate-x":pe()}],"translate-y":[{"translate-y":pe()}],"translate-z":[{"translate-z":pe()}],"translate-none":[`translate-none`],zoom:[{zoom:[Ut,W,U]}],accent:[{accent:M()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:M()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],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`,W,U]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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`,W,U]}],fill:[{fill:[`none`,...M()]}],"stroke-w":[{stroke:[V,sn,$t,en]}],stroke:[{stroke:[`none`,...M()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`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-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function Tn(...e){return wn($e(e))}var En=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),G=o(((e,t)=>{t.exports=En()}))();function Dn(e){return e===`csv2json`?`CSV → JSON`:`JSON → CSV`}function On({flipped:e}){return(0,G.jsx)(pe,{size:18,strokeWidth:2,"aria-hidden":`true`,className:Tn(`transition-transform duration-300`,e&&`rotate-180`)})}function kn({direction:e,onFlip:t}){return(0,G.jsxs)(`button`,{type:`button`,"data-testid":`divider-switch`,onClick:t,onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),title:`Switch direction (currently ${Dn(e)})`,"aria-label":`Switch conversion direction (currently ${Dn(e)})`,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:[(0,G.jsx)(On,{flipped:e===`json2csv`}),(0,G.jsx)(`span`,{"data-testid":`divider-switch-label`,children:Dn(e)})]})}var An=[{question:`How does it work?`,answer:`Paste CSV or JSON into the left pane and the conversion runs as you type — no upload, no submit button. Flip the direction with the switch between the panes to convert JSON back to CSV, then copy the result or download it as a file. The converter understands quoted fields, embedded separators, and Unicode.`},{question:`What do the options do?`,answer:`Separator picks the delimiter — auto-detect covers comma, semicolon, and tab. Parse numbers is on by default with smart semantics — plain numbers like 5 or 19.99 become real JSON numbers, while leading-zero values like 00721 and very long IDs stay strings; uncheck it to keep numeric cells as strings — booleans, null, and containers still convert while Parse JSON is on. Parse JSON converts null, true, false, [] and {} cells into real JSON values instead of strings. Transpose flips rows and columns; Hash output makes the first column the object key; Minify removes indentation from JSON output. On the JSON to CSV side, Flatten explodes nested arrays into extra rows with dotted keys.`},{question:`TSV vs CSV — what changes?`,answer:`Only the delimiter: TSV separates cells with tabs, CSV with commas. Anything you can paste from Excel or Google Sheets is tab-separated, and auto-detect picks that up — or choose Tab in the separator menu. Quoting rules only apply to comma and semicolon output; TSV rarely needs them.`},{question:`Does my data ever leave the browser?`,answer:`No. The conversion runs entirely in your browser — nothing is uploaded, nothing is stored, nothing is logged. Files you open are read locally in the page, there is no account and no server processing. The site's analytics never see your data: Plausible counts visits cookieless, and the Google tag is a standard conversion-measurement tag that uses the page URL, referrer, and a first-party conversion cookie to measure ad performance. Your files and converted output never leave the browser. When you send feedback, we store your vote and anything you choose to write — nothing else.`}],jn={"@context":`https://schema.org`,"@type":`FAQPage`,mainEntity:An.map(e=>({"@type":`Question`,name:e.question,acceptedAnswer:{"@type":`Answer`,text:e.answer}}))};function Mn(){let[e,t]=(0,g.useState)(!1),n=(0,g.useId)();return(0,G.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:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`faq-toggle`,"aria-expanded":e,"aria-controls":n,onClick:()=>t(e=>!e),className:`flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 text-center`,children:e?`▾`:`▸`}),`How it works & FAQ`]}),(0,G.jsx)(`div`,{id:n,"data-testid":`faq-content`,hidden:!e,className:`max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground`,children:An.map(e=>(0,G.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,G.jsx)(`h2`,{className:`mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground`,children:e.question}),(0,G.jsx)(`p`,{children:e.answer})]},e.question))}),(0,G.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:JSON.stringify(jn)}})]})}var Nn=`https://github.com/FlatFilers/csvjson-app/discussions/163`;function Pn(){return(0,G.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:(0,G.jsxs)(`p`,{className:`text-center`,children:[`Enjoy a cleaner, simpler CSVJSON.`,` `,(0,G.jsx)(`a`,{"data-testid":`feedback-link`,href:Nn,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`}),`.`]})})}var Fn=`csvjson:feedback.v1`,In=[{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 Ln(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.clientId==`string`&&t.clientId.length<=64&&(t.vote===1||t.vote===-1)&&(typeof t.reasonCode==`string`||t.reasonCode===null)&&(typeof t.reasonText==`string`||t.reasonText===null)&&typeof t.pending==`boolean`}function Rn(){try{let e=window.localStorage.getItem(Fn);if(e===null)return null;let t=JSON.parse(e);return Ln(t)?t:null}catch{return null}}function zn(e){try{window.localStorage.setItem(Fn,JSON.stringify(e))}catch{}}function Bn(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=globalThis.crypto?.getRandomValues?.(new Uint8Array(16));if(e===void 0)throw Error(`no secure randomness available`);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Vn(e){let t=window.location.pathname;return e.vote===1?{clientId:e.clientId,vote:1,path:t}:{clientId:e.clientId,vote:-1,reasonCode:e.reasonCode,reasonText:e.reasonText,path:t}}async function Hn(e){try{return(await fetch(`/api/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Vn(e))})).ok?`ok`:`failed`}catch{return`failed`}}function Un(e){return[`flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors`,e?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`].join(` `)}function Wn(){let[e,t]=(0,g.useState)(Rn),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(0),m=(0,g.useCallback)((e,n)=>{let r={...e,pending:n===`failed`};zn(r),t(r),n===`ok`?A({vote:e.vote,with_reason:e.reasonCode!==null}):l(!1)},[]),h=(0,g.useCallback)((e,t)=>{let n=++p.current;t&&d(!0),Hn(e).then(t=>{p.current===n&&(m(e,t),t===`ok`&&l(!0))}).finally(()=>{t&&p.current===n&&d(!1)})},[m]),_=e=>{let n={...e,pending:!0};zn(n),t(n),h(n,!0)},v=(0,g.useRef)(!1);return(0,g.useEffect)(()=>{if(v.current)return;v.current=!0;let e=Rn();e?.pending&&h(e,!1)},[h]),(0,g.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),3e3);return()=>clearTimeout(e)},[c]),(0,g.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)},t=e=>{let t=f.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||r(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[n]),(0,G.jsxs)(`div`,{"data-testid":`feedback-vote`,ref:f,className:`relative flex items-center gap-1 max-sm:static`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`feedback-up`,onClick:()=>{e?.vote===1&&!e.pending?l(!0):_({clientId:e?.clientId??Bn(),vote:1,reasonCode:null,reasonText:null})},"aria-pressed":e?.vote===1,"aria-label":`Helpful — send an upvote`,title:`Helpful`,className:Un(e?.vote===1),children:(0,G.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:[(0,G.jsx)(`path`,{d:`M7 10v12`}),(0,G.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`})]})}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`feedback-down`,onClick:()=>{n?r(!1):(a(null),s(``),r(!0))},"aria-pressed":e?.vote===-1,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":`Not helpful — send a downvote`,title:`Not helpful`,className:Un(e?.vote===-1),children:(0,G.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:[(0,G.jsx)(`path`,{d:`M17 14V2`}),(0,G.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`})]})}),c&&(0,G.jsx)(`span`,{"data-testid":`feedback-thanks`,className:`text-xs text-muted-foreground`,children:`Thanks for the feedback!`}),e?.pending&&!u&&(0,G.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&&(0,G.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:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium text-foreground`,children:`What went wrong?`}),(0,G.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:In.map(e=>(0,G.jsx)(`button`,{type:`button`,"data-testid":`feedback-reason-${e.value}`,"aria-pressed":i===e.value,onClick:()=>a(e.value),className:[`cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors`,i===e.value?`border-foreground bg-foreground text-panel`:`border-border text-muted-foreground hover:border-foreground hover:text-foreground`].join(` `),children:e.label},e.value))}),(0,G.jsx)(`textarea`,{"data-testid":`feedback-text`,value:o,maxLength:500,rows:2,onChange:e=>s(e.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`}),(0,G.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:[o.length,`/500`]}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`feedback-submit`,onClick:()=>{if(i===null)return;let t=o.trim();_({clientId:e?.clientId??Bn(),vote:-1,reasonCode:i,reasonText:t===``?null:t}),r(!1)},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 Gn(e=`This should not happen`){throw Error(e)}function Kn(e,t=`Assertion failed`){if(!e)return Gn(t)}function qn(e,t){return Gn(t??`Hell froze over`)}function Jn(e,t){try{return e()}catch{return t}}var Yn=Object.prototype.hasOwnProperty;function Xn(e,t){let n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&Xn(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(Yn.call(e,n)&&++r&&!Yn.call(t,n)||!(n in t)||!Xn(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var Zn=o(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e,t){return e!=null&&n.call(e,t)}t.exports=r})),Qn=o(((e,t)=>{t.exports=Array.isArray})),$n=o(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),er=o(((e,t)=>{var n=$n(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),tr=o(((e,t)=>{t.exports=er().Symbol})),nr=o(((e,t)=>{var n=tr(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),rr=o(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),ir=o(((e,t)=>{var n=tr(),r=nr(),i=rr(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),ar=o(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),or=o(((e,t)=>{var n=ir(),r=ar(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),sr=o(((e,t)=>{var n=Qn(),r=or(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),cr=o(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),lr=o(((e,t)=>{var n=ir(),r=cr(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),ur=o(((e,t)=>{t.exports=er()[`__core-js_shared__`]})),dr=o(((e,t)=>{var n=ur(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),fr=o(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),pr=o(((e,t)=>{var n=lr(),r=dr(),i=cr(),a=fr(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),mr=o(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),hr=o(((e,t)=>{var n=pr(),r=mr();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),gr=o(((e,t)=>{t.exports=hr()(Object,`create`)})),_r=o(((e,t)=>{var n=gr();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),vr=o(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),yr=o(((e,t)=>{var n=gr(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),br=o(((e,t)=>{var n=gr(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),xr=o(((e,t)=>{var n=gr(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),Sr=o(((e,t)=>{var n=_r(),r=vr(),i=yr(),a=br(),o=xr();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{function n(){this.__data__=[],this.size=0}t.exports=n})),wr=o(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Tr=o(((e,t)=>{var n=wr();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),Er=o(((e,t)=>{var n=Tr(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Dr=o(((e,t)=>{var n=Tr();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),Or=o(((e,t)=>{var n=Tr();function r(e){return n(this.__data__,e)>-1}t.exports=r})),kr=o(((e,t)=>{var n=Tr();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),Ar=o(((e,t)=>{var n=Cr(),r=Er(),i=Dr(),a=Or(),o=kr();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{t.exports=hr()(er(),`Map`)})),Mr=o(((e,t)=>{var n=Sr(),r=Ar(),i=jr();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),Nr=o(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Pr=o(((e,t)=>{var n=Nr();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),Fr=o(((e,t)=>{var n=Pr();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),Ir=o(((e,t)=>{var n=Pr();function r(e){return n(this,e).get(e)}t.exports=r})),Lr=o(((e,t)=>{var n=Pr();function r(e){return n(this,e).has(e)}t.exports=r})),Rr=o(((e,t)=>{var n=Pr();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),zr=o(((e,t)=>{var n=Mr(),r=Fr(),i=Ir(),a=Lr(),o=Rr();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{var n=zr(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),Vr=o(((e,t)=>{var n=Br(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),Hr=o(((e,t)=>{var n=Vr(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),Ur=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n{var n=tr(),r=Ur(),i=Qn(),a=or(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),Gr=o(((e,t)=>{var n=Wr();function r(e){return e==null?``:n(e)}t.exports=r})),Kr=o(((e,t)=>{var n=Qn(),r=sr(),i=Hr(),a=Gr();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),qr=o(((e,t)=>{var n=ir(),r=ar(),i=`[object Arguments]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),Jr=o(((e,t)=>{var n=qr(),r=ar(),i=Object.prototype,a=i.hasOwnProperty,o=i.propertyIsEnumerable;t.exports=n(function(){return arguments}())?n:function(e){return r(e)&&a.call(e,`callee`)&&!o.call(e,`callee`)}})),Yr=o(((e,t)=>{var n=/^(?:0|[1-9]\d*)$/;function r(e,t){var r=typeof e;return t??=9007199254740991,!!t&&(r==`number`||r!=`symbol`&&n.test(e))&&e>-1&&e%1==0&&e{function n(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991}t.exports=n})),Zr=o(((e,t)=>{var n=or(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Qr=o(((e,t)=>{var n=Kr(),r=Jr(),i=Qn(),a=Yr(),o=Xr(),s=Zr();function c(e,t,c){t=n(t,e);for(var l=-1,u=t.length,d=!1;++l{var n=Zn(),r=Qr();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i}))(),1),K;(function(e){e.Uri=`uri`,e.Text=`text`,e.Image=`image`,e.RowID=`row-id`,e.Number=`number`,e.Bubble=`bubble`,e.Boolean=`boolean`,e.Loading=`loading`,e.Markdown=`markdown`,e.Drilldown=`drilldown`,e.Protected=`protected`,e.Custom=`custom`})(K||={});var ei;(function(e){e.HeaderRowID=`headerRowID`,e.HeaderCode=`headerCode`,e.HeaderNumber=`headerNumber`,e.HeaderString=`headerString`,e.HeaderBoolean=`headerBoolean`,e.HeaderAudioUri=`headerAudioUri`,e.HeaderVideoUri=`headerVideoUri`,e.HeaderEmoji=`headerEmoji`,e.HeaderImage=`headerImage`,e.HeaderUri=`headerUri`,e.HeaderPhone=`headerPhone`,e.HeaderMarkdown=`headerMarkdown`,e.HeaderDate=`headerDate`,e.HeaderTime=`headerTime`,e.HeaderEmail=`headerEmail`,e.HeaderReference=`headerReference`,e.HeaderIfThenElse=`headerIfThenElse`,e.HeaderSingleValue=`headerSingleValue`,e.HeaderLookup=`headerLookup`,e.HeaderTextTemplate=`headerTextTemplate`,e.HeaderMath=`headerMath`,e.HeaderRollup=`headerRollup`,e.HeaderJoinStrings=`headerJoinStrings`,e.HeaderSplitString=`headerSplitString`,e.HeaderGeoDistance=`headerGeoDistance`,e.HeaderArray=`headerArray`,e.RowOwnerOverlay=`rowOwnerOverlay`,e.ProtectedColumnOverlay=`protectedColumnOverlay`})(ei||={});var ti;(function(e){e.Triangle=`triangle`,e.Dots=`dots`})(ti||={});function ni(e){return`width`in e&&typeof e.width==`number`}async function ri(e){return typeof e==`object`?e:await e()}function ii(e){return e.kind!==K.Loading&&e.kind!==K.Bubble&&e.kind!==K.RowID&&e.kind!==K.Protected&&e.kind!==K.Drilldown}function ai(e){return e.kind===li.Marker||e.kind===li.NewRow}function oi(e){if(!ii(e)||e.kind===K.Image)return!1;if(e.kind===K.Text||e.kind===K.Number||e.kind===K.Markdown||e.kind===K.Uri||e.kind===K.Custom||e.kind===K.Boolean)return e.readonly!==!0;qn(e,`A cell was passed with an invalid kind`)}function si(e){return(0,$r.default)(e,`editor`)}function ci(e){return!(e.readonly??!1)}var li;(function(e){e.NewRow=`new-row`,e.Marker=`marker`})(li||={});function ui(e){if(e.length===0)return[];let t=[...e],n=[];t.sort(function(e,t){return e[0]-t[0]}),n.push([...t[0]]);for(let e of t.slice(1)){let t=n[n.length-1];t[1]di??=new e([]);static fromSingleSelection=t=>e.empty().add(t);offset(t){if(t===0)return this;let n=this.items.map(e=>[e[0]+t,e[1]+t]);return new e(n)}add(t){let n=typeof t==`number`?[t,t+1]:t,r=ui([...this.items,n]);return new e(r)}remove(t){let n=[...this.items],r=typeof t==`number`?t:t[0],i=typeof t==`number`?t+1:t[1];for(let[e,t]of n.entries()){let[a,o]=t;if(a<=i&&r<=o){let t=[];a=n&&e{(e?e.split(` `):[]).forEach(e=>{if(e.startsWith(`atm_`)){let[,n]=e.split(`_`);t[n]=e}else n.push(e)})});let r=[];for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(t[e]);return r.push(...n),r.join(` `)},_i=e=>e.toUpperCase()===e,vi=e=>t=>e.indexOf(t)===-1,yi=(e,t)=>{let n={};return Object.keys(e).filter(vi(t)).forEach(t=>{n[t]=e[t]}),n};function bi(e,t,n){let r=yi(t,n);if(!e){let e=typeof hi==`function`?{default:hi}:hi;Object.keys(r).forEach(t=>{e.default(t)||delete r[t]})}return r}function xi(e){return t=>{let n=(n,r)=>{let{as:i=e,class:a=``}=n,o=bi(t.propsAsIs===void 0?!(typeof i==`string`&&i.indexOf(`-`)===-1&&!_i(i[0])):t.propsAsIs,n,[`as`,`class`]);o.ref=r,o.className=t.atomic?gi(t.class,o.className||a):gi(o.className||a,t.class);let{vars:s}=t;if(s){let e={};for(let r in s){let i=s[r],a=i[0],o=i[1]||``,c=typeof a==`function`?a(n):a;t.name,e[`--${r}`]=`${c}${o}`}let r=o.style||{},i=Object.keys(r);i.length>0&&i.forEach(t=>{e[t]=r[t]}),o.style=e}return e.__linaria&&e!==i?(o.as=i,g.createElement(e,o)):g.createElement(i,o)},r=g.forwardRef?g.forwardRef(n):e=>{let t=yi(e,[`innerRef`]);return n(t,e.innerRef)};return r.displayName=t.name,r.__linaria={className:t.class||``,extends:e},r}}var Si=xi,Ci=Si(`div`)({name:`ImageOverlayEditorStyle`,class:`gdg-i2iowwq`,propsAsIs:!1}),wi=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Ti=o(((e,t)=>{var n=wi();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=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 s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Ei=o(((e,t)=>{t.exports=Ti()()})),Di=o(((e,t,n)=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`react`,`prop-types`],n);else if(e!==void 0)n(e,u(),Ei());else{var r={exports:{}};n(r.exports,t.react,t.propTypes),t.reactSwipe=r.exports}})(n,function(e,t,n){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var r=a(t),i=a(n);function a(e){return e&&e.__esModule?e:{default:e}}var o=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function c(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var l=function(){function e(e,t){for(var n=0;n0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return f?e:e.capture}function h(e){if(`touches`in e){var t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.screenX,y:e.screenY}}var g=function(e){d(t,e);function t(){var e;c(this,t);var n=[...arguments],r=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(n)));return r._handleSwipeStart=r._handleSwipeStart.bind(r),r._handleSwipeMove=r._handleSwipeMove.bind(r),r._handleSwipeEnd=r._handleSwipeEnd.bind(r),r._onMouseDown=r._onMouseDown.bind(r),r._onMouseMove=r._onMouseMove.bind(r),r._onMouseUp=r._onMouseUp.bind(r),r._setSwiperRef=r._setSwiperRef.bind(r),r}return l(t,[{key:`componentDidMount`,value:function(){this.swiper&&this.swiper.addEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`componentWillUnmount`,value:function(){this.swiper&&this.swiper.removeEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`_onMouseDown`,value:function(e){this.props.allowMouseEvents&&(this.mouseDown=!0,document.addEventListener(`mouseup`,this._onMouseUp),document.addEventListener(`mousemove`,this._onMouseMove),this._handleSwipeStart(e))}},{key:`_onMouseMove`,value:function(e){this.mouseDown&&this._handleSwipeMove(e)}},{key:`_onMouseUp`,value:function(e){this.mouseDown=!1,document.removeEventListener(`mouseup`,this._onMouseUp),document.removeEventListener(`mousemove`,this._onMouseMove),this._handleSwipeEnd(e)}},{key:`_handleSwipeStart`,value:function(e){var t=h(e),n=t.x,r=t.y;this.moveStart={x:n,y:r},this.props.onSwipeStart(e)}},{key:`_handleSwipeMove`,value:function(e){if(this.moveStart){var t=h(e),n=t.x,r=t.y,i=n-this.moveStart.x,a=r-this.moveStart.y;this.moving=!0,this.props.onSwipeMove({x:i,y:a},e)&&e.cancelable&&e.preventDefault(),this.movePosition={deltaX:i,deltaY:a}}}},{key:`_handleSwipeEnd`,value:function(e){this.props.onSwipeEnd(e);var t=this.props.tolerance;this.moving&&this.movePosition&&(this.movePosition.deltaX<-t?this.props.onSwipeLeft(1,e):this.movePosition.deltaX>t&&this.props.onSwipeRight(1,e),this.movePosition.deltaY<-t?this.props.onSwipeUp(1,e):this.movePosition.deltaY>t&&this.props.onSwipeDown(1,e)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:`_setSwiperRef`,value:function(e){this.swiper=e,this.props.innerRef(e)}},{key:`render`,value:function(){var e=this.props;e.tagName;var t=e.className,n=e.style,i=e.children;e.allowMouseEvents,e.onSwipeUp,e.onSwipeDown,e.onSwipeLeft,e.onSwipeRight,e.onSwipeStart,e.onSwipeMove,e.onSwipeEnd,e.innerRef,e.tolerance;var a=s(e,[`tagName`,`className`,`style`,`children`,`allowMouseEvents`,`onSwipeUp`,`onSwipeDown`,`onSwipeLeft`,`onSwipeRight`,`onSwipeStart`,`onSwipeMove`,`onSwipeEnd`,`innerRef`,`tolerance`]);return r.default.createElement(this.props.tagName,o({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:t,style:n},a),i)}}]),t}(t.Component);g.displayName=`ReactSwipe`,g.propTypes={tagName:i.default.string,className:i.default.string,style:i.default.object,children:i.default.node,allowMouseEvents:i.default.bool,onSwipeUp:i.default.func,onSwipeDown:i.default.func,onSwipeLeft:i.default.func,onSwipeRight:i.default.func,onSwipeStart:i.default.func,onSwipeMove:i.default.func,onSwipeEnd:i.default.func,innerRef:i.default.func,tolerance:i.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})})),Oi=o(((e,t,n)=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`./react-swipe`],n);else if(e!==void 0)n(e,Di());else{var r={exports:{}};n(r.exports,t.reactSwipe),t.index=r.exports}})(n,function(e,t){Object.defineProperty(e,"__esModule",{value:!0});var n=r(t);function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default})})),ki=o(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(ki());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.default={ROOT:function(e){return(0,t.default)(r({"carousel-root":!0},e||``,!!e))},CAROUSEL:function(e){return(0,t.default)({carousel:!0,"carousel-slider":e})},WRAPPER:function(e,n){return(0,t.default)({"thumbs-wrapper":!e,"slider-wrapper":e,"axis-horizontal":n===`horizontal`,"axis-vertical":n!==`horizontal`})},SLIDER:function(e,n){return(0,t.default)({thumbs:!e,slider:e,animated:!n})},ITEM:function(e,n,r){return(0,t.default)({thumb:!e,slide:e,selected:n,previous:r})},ARROW_PREV:function(e){return(0,t.default)({"control-arrow control-prev":!0,"control-disabled":e})},ARROW_NEXT:function(e){return(0,t.default)({"control-arrow control-next":!0,"control-disabled":e})},DOT:function(e){return(0,t.default)({dot:!0,selected:e})}}})),ji=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.outerWidth=void 0,e.outerWidth=function(e){var t=e.offsetWidth,n=getComputedStyle(e);return t+=parseInt(n.marginLeft)+parseInt(n.marginRight),t}})),Mi=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(e,t,n){var r=e===0?e:e+t;return`translate3d`+(`(`+(n===`horizontal`?[r,0,0]:[0,r,0]).join(`,`)+`)`)}})),Ni=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return window}})),Pi=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=l(u()),n=s(Ai()),r=ji(),i=s(Mi()),a=s(Oi()),o=s(Ni());function s(e){return e&&e.__esModule?e:{default:e}}function c(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){if(e&&e.__esModule)return e;if(e===null||d(e)!==`object`&&typeof e!=`function`)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(){return f=Object.assign||function(e){for(var t=1;t`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 S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=function(e){return e.hasOwnProperty(`key`)},T=function(e){g(c,e);var s=v(c);function c(e){var n;return p(this,c),n=s.call(this,e),C(b(n),`itemsWrapperRef`,void 0),C(b(n),`itemsListRef`,void 0),C(b(n),`thumbsRef`,void 0),C(b(n),`setItemsWrapperRef`,function(e){n.itemsWrapperRef=e}),C(b(n),`setItemsListRef`,function(e){n.itemsListRef=e}),C(b(n),`setThumbsRef`,function(e,t){n.thumbsRef||(n.thumbsRef=[]),n.thumbsRef[t]=e}),C(b(n),`updateSizes`,function(){if(n.props.children&&n.itemsWrapperRef&&n.thumbsRef){var e=t.Children.count(n.props.children),i=n.itemsWrapperRef.clientWidth,a=n.props.thumbWidth?n.props.thumbWidth:(0,r.outerWidth)(n.thumbsRef[0]),o=Math.floor(i/a),s=o0&&(r=0),s===c&&r<0&&(r=0);var l=s+100/(n.itemsWrapperRef.clientWidth/r);return n.itemsListRef&&[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(e){n.itemsListRef.style[e]=(0,i.default)(l,`%`,n.props.axis)}),!0}),C(b(n),`slideRight`,function(e){n.moveTo(n.state.firstItem-(typeof e==`number`?e:1))}),C(b(n),`slideLeft`,function(e){n.moveTo(n.state.firstItem+(typeof e==`number`?e:1))}),C(b(n),`moveTo`,function(e){e=e<0?0:e,e=e>=n.state.lastPosition?n.state.lastPosition:e,n.setState({firstItem:e})}),n.state={selectedItem:e.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},n}return h(c,[{key:`componentDidMount`,value:function(){this.setupThumbs()}},{key:`componentDidUpdate`,value:function(e){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==e.children&&this.updateSizes()}},{key:`componentWillUnmount`,value:function(){this.destroyThumbs()}},{key:`setupThumbs`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.updateSizes()}},{key:`destroyThumbs`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes)}},{key:`getFirstItem`,value:function(e){var t=e;return e>=this.state.lastPosition&&(t=this.state.lastPosition),e1,o=this.state.showArrows&&this.state.firstItem>0,s=this.state.showArrows&&this.state.firstItem{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return document}})),Ii=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setPosition=e.getPosition=e.isKeyboardEvent=e.defaultStatusFormatter=e.noop=void 0;var t=u(),n=r(Mi());function r(e){return e&&e.__esModule?e:{default:e}}e.noop=function(){},e.defaultStatusFormatter=function(e,t){return`${e} of ${t}`},e.isKeyboardEvent=function(e){return e?e.hasOwnProperty(`key`):!1},e.getPosition=function(e,n){if(n.infiniteLoop&&++e,e===0)return 0;var r=t.Children.count(n.children);if(n.centerMode&&n.axis===`horizontal`){var i=-e*n.centerSlidePercentage,a=r-1;return e&&(e!==a||n.infiniteLoop)?i+=(100-n.centerSlidePercentage)/2:e===a&&(i+=100-n.centerSlidePercentage),i}return-e*100},e.setPosition=function(e,t){var r={};return[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(i){r[i]=(0,n.default)(e,`%`,t)}),r}})),Li=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fadeAnimationHandler=e.slideStopSwipingHandler=e.slideSwipeAnimationHandler=e.slideAnimationHandler=void 0;var t=u(),n=i(Mi()),r=Ii();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;tl))return c<0?a.itemListStyle=e.centerMode&&e.centerSlidePercentage&&e.axis===`horizontal`?(0,r.setPosition)(-(l+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):(0,r.setPosition)(-(l+2)*100,e.axis):c>l&&(a.itemListStyle=(0,r.setPosition)(0,e.axis)),a;var u=(0,r.getPosition)(s,e),d=(0,n.default)(u,`%`,e.axis),f=e.transitionTime+`ms`;return a.itemListStyle={WebkitTransform:d,msTransform:d,OTransform:d,transform:d},i.swiping||(a.itemListStyle=o(o({},a.itemListStyle),{},{WebkitTransitionDuration:f,MozTransitionDuration:f,OTransitionDuration:f,transitionDuration:f,msTransitionDuration:f})),a},e.slideSwipeAnimationHandler=function(e,n,i,a){var o={},s=n.axis===`horizontal`,c=t.Children.count(n.children),l=0,u=(0,r.getPosition)(i.selectedItem,n),d=n.infiniteLoop?(0,r.getPosition)(c-1,n)-100:(0,r.getPosition)(c-1,n),f=s?e.x:e.y,p=f;u===l&&f>0&&(p=0),u===d&&f<0&&(p=0);var m=u+100/(i.itemSize/p),h=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&h&&(i.selectedItem===0&&m>-100?m-=c*100:i.selectedItem===c-1&&m<-c*100&&(m+=c*100)),(!n.preventMovementUntilSwipeScrollTolerance||h||i.swipeMovementStarted)&&(i.swipeMovementStarted||a({swipeMovementStarted:!0}),o.itemListStyle=(0,r.setPosition)(m,n.axis)),h&&!i.cancelClick&&a({cancelClick:!0}),o},e.slideStopSwipingHandler=function(e,t){var n=(0,r.getPosition)(t.selectedItem,e);return{itemListStyle:(0,r.setPosition)(n,e.axis)}},e.fadeAnimationHandler=function(e,t){var n=e.transitionTime+`ms`,r=`ease-in-out`,i={position:`absolute`,display:`block`,zIndex:-2,minHeight:`100%`,opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:r,msTransitionTimingFunction:r,MozTransitionTimingFunction:r,WebkitTransitionTimingFunction:r,OTransitionTimingFunction:r};return t.swiping||(i=o(o({},i),{},{WebkitTransitionDuration:n,MozTransitionDuration:n,OTransitionDuration:n,transitionDuration:n,msTransitionDuration:n})),{slideStyle:i,selectedStyle:o(o({},i),{},{opacity:1,position:`relative`}),prevStyle:o({},i)}}})),Ri=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=f(u()),n=l(Oi()),r=l(Ai()),i=l(Pi()),a=l(Fi()),o=l(Ni()),s=Ii(),c=Li();function l(e){return e&&e.__esModule?e:{default:e}}function d(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return d=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(e===null||p(e)!==`object`&&typeof e!=`function`)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(){return m=Object.assign||function(e){for(var t=1;t`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 E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=function(e){b(u,e);var l=S(u);function u(e){var n;_(this,u),n=l.call(this,e),D(w(n),`thumbsRef`,void 0),D(w(n),`carouselWrapperRef`,void 0),D(w(n),`listRef`,void 0),D(w(n),`itemsRef`,void 0),D(w(n),`timer`,void 0),D(w(n),`animationHandler`,void 0),D(w(n),`setThumbsRef`,function(e){n.thumbsRef=e}),D(w(n),`setCarouselWrapperRef`,function(e){n.carouselWrapperRef=e}),D(w(n),`setListRef`,function(e){n.listRef=e}),D(w(n),`setItemsRef`,function(e,t){n.itemsRef||(n.itemsRef=[]),n.itemsRef[t]=e}),D(w(n),`autoPlay`,function(){t.Children.count(n.props.children)<=1||(n.clearAutoPlay(),n.props.autoPlay&&(n.timer=setTimeout(function(){n.increment()},n.props.interval)))}),D(w(n),`clearAutoPlay`,function(){n.timer&&clearTimeout(n.timer)}),D(w(n),`resetAutoPlay`,function(){n.clearAutoPlay(),n.autoPlay()}),D(w(n),`stopOnHover`,function(){n.setState({isMouseEntered:!0},n.clearAutoPlay)}),D(w(n),`startOnLeave`,function(){n.setState({isMouseEntered:!1},n.autoPlay)}),D(w(n),`isFocusWithinTheCarousel`,function(){return n.carouselWrapperRef?!!((0,a.default)().activeElement===n.carouselWrapperRef||n.carouselWrapperRef.contains((0,a.default)().activeElement)):!1}),D(w(n),`navigateWithKeyboard`,function(e){if(n.isFocusWithinTheCarousel()){var t=n.props.axis===`horizontal`,r={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},i=t?r.ArrowRight:r.ArrowDown,a=t?r.ArrowLeft:r.ArrowUp;i===e.keyCode?n.increment():a===e.keyCode&&n.decrement()}}),D(w(n),`updateSizes`,function(){if(n.state.initialized&&n.itemsRef&&n.itemsRef.length!==0){var e=n.props.axis===`horizontal`,t=n.itemsRef[0];if(t){var r=e?t.clientWidth:t.clientHeight;n.setState({itemSize:r}),n.thumbsRef&&n.thumbsRef.updateSizes()}}}),D(w(n),`setMountState`,function(){n.setState({hasMount:!0}),n.updateSizes()}),D(w(n),`handleClickItem`,function(e,r){t.Children.count(n.props.children)!==0&&(n.state.cancelClick?n.setState({cancelClick:!1}):(n.props.onClickItem(e,r),e!==n.state.selectedItem&&n.setState({selectedItem:e})))}),D(w(n),`handleOnChange`,function(e,r){t.Children.count(n.props.children)<=1||n.props.onChange(e,r)}),D(w(n),`handleClickThumb`,function(e,t){n.props.onClickThumb(e,t),n.moveTo(e)}),D(w(n),`onSwipeStart`,function(e){n.setState({swiping:!0}),n.props.onSwipeStart(e)}),D(w(n),`onSwipeEnd`,function(e){n.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),n.props.onSwipeEnd(e),n.clearAutoPlay(),n.state.autoPlay&&n.autoPlay()}),D(w(n),`onSwipeMove`,function(e,t){n.props.onSwipeMove(t);var r=n.props.swipeAnimationHandler(e,n.props,n.state,n.setState.bind(w(n)));return n.setState(g({},r)),!!Object.keys(r).length}),D(w(n),`decrement`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem-(typeof e==`number`?e:1))}),D(w(n),`increment`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem+(typeof e==`number`?e:1))}),D(w(n),`moveTo`,function(e){if(typeof e==`number`){var r=t.Children.count(n.props.children)-1;e<0&&(e=n.props.infiniteLoop?r:0),e>r&&(e=n.props.infiniteLoop?0:r),n.selectItem({selectedItem:e}),n.state.autoPlay&&n.state.isMouseEntered===!1&&n.resetAutoPlay()}}),D(w(n),`onClickNext`,function(){n.increment(1)}),D(w(n),`onClickPrev`,function(){n.decrement(1)}),D(w(n),`onSwipeForward`,function(){n.increment(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`onSwipeBackwards`,function(){n.decrement(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`changeItem`,function(e){return function(t){(0,s.isKeyboardEvent)(t)&&t.key!==`Enter`||n.moveTo(e)}}),D(w(n),`selectItem`,function(e){n.setState(g({previousItem:n.state.selectedItem},e),function(){n.setState(n.animationHandler(n.props,n.state))}),n.handleOnChange(e.selectedItem,t.Children.toArray(n.props.children)[e.selectedItem])}),D(w(n),`getInitialImage`,function(){var e=n.props.selectedItem,t=n.itemsRef&&n.itemsRef[e];return(t&&t.getElementsByTagName(`img`)||[])[0]}),D(w(n),`getVariableItemHeight`,function(e){var t=n.itemsRef&&n.itemsRef[e];if(n.state.hasMount&&t&&t.children.length){var r=t.children[0].getElementsByTagName(`img`)||[];if(r.length>0){var i=r[0];i.complete||i.addEventListener(`load`,function e(){n.forceUpdate(),i.removeEventListener(`load`,e)})}var a=(r[0]||t.children[0]).clientHeight;return a>0?a:null}return null});var r={initialized:!1,previousItem:e.selectedItem,selectedItem:e.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:e.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return n.animationHandler=typeof e.animationHandler==`function`&&e.animationHandler||e.animationHandler===`fade`&&c.fadeAnimationHandler||c.slideAnimationHandler,n.state=g(g({},r),n.animationHandler(e,r)),n}return y(u,[{key:`componentDidMount`,value:function(){this.props.children&&this.setupCarousel()}},{key:`componentDidUpdate`,value:function(e,t){!e.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!e.autoFocus&&this.props.autoFocus&&this.forceFocus(),t.swiping&&!this.state.swiping&&this.setState(g({},this.props.stopSwipingHandler(this.props,this.state))),(e.selectedItem!==this.props.selectedItem||e.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),e.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 e=this;this.bindEvents(),this.state.autoPlay&&t.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var t=e.getInitialImage();t&&!t.complete?t.addEventListener(`load`,e.setMountState):e.setMountState()})}},{key:`destroyCarousel`,value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:`setupAutoPlay`,value:function(){this.autoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.addEventListener(`mouseenter`,this.stopOnHover),e.addEventListener(`mouseleave`,this.startOnLeave))}},{key:`destroyAutoPlay`,value:function(){this.clearAutoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.removeEventListener(`mouseenter`,this.stopOnHover),e.removeEventListener(`mouseleave`,this.startOnLeave))}},{key:`bindEvents`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.props.useKeyboardArrows&&(0,a.default)().addEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`unbindEvents`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes);var e=this.getInitialImage();e&&e.removeEventListener(`load`,this.setMountState),this.props.useKeyboardArrows&&(0,a.default)().removeEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`forceFocus`,value:function(){var e;(e=this.carouselWrapperRef)==null||e.focus()}},{key:`renderItems`,value:function(e){var n=this;return this.props.children?t.Children.map(this.props.children,function(i,a){var o=a===n.state.selectedItem,s=a===n.state.previousItem,c=o&&n.state.selectedStyle||s&&n.state.prevStyle||n.state.slideStyle||{};n.props.centerMode&&n.props.axis===`horizontal`&&(c=g(g({},c),{},{minWidth:n.props.centerSlidePercentage+`%`})),n.state.swiping&&n.state.swipeMovementStarted&&(c=g(g({},c),{},{pointerEvents:`none`}));var l={ref:function(e){return n.setItemsRef(e,a)},key:`itemKey`+a+(e?`clone`:``),className:r.default.ITEM(!0,a===n.state.selectedItem,a===n.state.previousItem),onClick:n.handleClickItem.bind(n,a,i),style:c};return t.default.createElement(`li`,l,n.props.renderItem(i,{isSelected:a===n.state.selectedItem,isPrevious:a===n.state.previousItem}))}):[]}},{key:`renderControls`,value:function(){var e=this,n=this.props,r=n.showIndicators,i=n.labels,a=n.renderIndicator,o=n.children;return r?t.default.createElement(`ul`,{className:`control-dots`},t.Children.map(o,function(t,n){return a&&a(e.changeItem(n),n===e.state.selectedItem,n,i.item)})):null}},{key:`renderStatus`,value:function(){return this.props.showStatus?t.default.createElement(`p`,{className:`carousel-status`},this.props.statusFormatter(this.state.selectedItem+1,t.Children.count(this.props.children))):null}},{key:`renderThumbs`,value:function(){return!this.props.showThumbs||!this.props.children||t.Children.count(this.props.children)===0?null:t.default.createElement(i.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 e=this;if(!this.props.children||t.Children.count(this.props.children)===0)return null;var i=this.props.swipeable&&t.Children.count(this.props.children)>1,a=this.props.axis===`horizontal`,o=this.props.showArrows&&t.Children.count(this.props.children)>1,s=o&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,c=o&&(this.state.selectedItem{})),Bi=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Carousel",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"CarouselProps",{enumerable:!0,get:function(){return n.CarouselProps}}),Object.defineProperty(e,"Thumbs",{enumerable:!0,get:function(){return r.default}});var t=i(Ri()),n=zi(),r=i(Pi());function i(e){return e&&e.__esModule?e:{default:e}}})),Vi=o(((e,t)=>{var n=er();t.exports=function(){return n.Date.now()}})),Hi=o(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Ui=o(((e,t)=>{var n=Hi(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Wi=o(((e,t)=>{var n=Ui(),r=cr(),i=or(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Gi=o(((e,t)=>{var n=cr(),r=Vi(),i=Wi(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),Ki=c(Gi(),1);function qi(e,t,n,r,i=!1){let a=g.useRef();a.current=t,g.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;let t=n,o=e=>{a.current?.call(t,e)};return t.addEventListener(e,o,{passive:r,capture:i}),()=>{t.removeEventListener(e,o,{capture:i})}},[e,n,r,i])}function Ji(e,t){return e===void 0?void 0:t}var Yi=Math.PI;function Xi(e){return e*Yi/180}var Zi=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),Qi=(e,t,n,r,i)=>{switch(e){case`left`:return Math.floor(t)+r+i/2;case`center`:return Math.floor(t+n/2);case`right`:return Math.floor(t+n)-r-i/2}},$i=(e,t,n)=>Math.min(e,t-n*2),ea=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2,ta=e=>{let t=e.fgColor??`currentColor`;return g.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},g.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:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}),g.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:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}))},na=e=>{let t=e.fgColor??`currentColor`;return g.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},g.createElement(`path`,{d:`M19 6L10.3802 17L5.34071 11.8758`,vectorEffect:`non-scaling-stroke`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}))};function ra(e,t,n){let[r,i]=g.useState(e),a=g.useRef(!0);g.useEffect(()=>()=>{a.current=!1},[]);let o=g.useRef((0,Ki.default)(e=>{a.current&&i(e)},n));return g.useLayoutEffect(()=>{a.current&&o.current(()=>e())},t),r}var ia=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]`);function aa(e){return ia.test(e)?`rtl`:`not-rtl`}var oa=void 0;function sa(){if(typeof document>`u`)return 0;if(oa!==void 0)return oa;let e=document.createElement(`p`);e.style.width=`100%`,e.style.height=`200px`;let t=document.createElement(`div`);t.id=`testScrollbar`,t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.visibility=`hidden`,t.style.width=`200px`,t.style.height=`150px`,t.style.overflow=`hidden`,t.append(e),document.body.append(t);let n=e.offsetWidth;t.style.overflow=`scroll`;let r=e.offsetWidth;return n===r&&(r=t.clientWidth),t.remove(),oa=n-r,oa}var ca=Symbol();function la(e){let t=g.useRef([ca,e]);t.current[1]!==e&&(t.current[0]=e),t.current[1]=e;let[n,r]=g.useState(e),[,i]=g.useState(),a=g.useCallback(e=>{let n=t.current[0];n!==ca&&(e=typeof e==`function`?e(n):e,e===n)||(n!==ca&&i({}),r(t=>typeof e==`function`?e(n===ca?t:n):e),t.current[0]=ca)},[]),o=g.useCallback(()=>{t.current[0]=ca,i({})},[]);return[t.current[0]===ca?n:t.current[0],a,o]}function ua(e){if(e.length===0)return``;let t=0,n=0;for(let r of e){if(n+=r.length,n>1e4)break;t++}return e.slice(0,t).join(`, `)}function da(e){let t=g.useRef(e);return Xn(e,t.current)||(t.current=e),t.current}var fa=Bi(),pa=e=>{let{urls:t,canWrite:n,onEditClick:r,renderImage:i}=e,a=t.filter(e=>e!==``);if(a.length===0)return null;let o=a.length>1;return g.createElement(Ci,{"data-testid":`GDG-default-image-overlay-editor`},g.createElement(fa.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},a.map(e=>{let t=i?.(e)??g.createElement(`img`,{draggable:!1,src:e});return g.createElement(`div`,{className:`gdg-centering-container`,key:e},t)})),n&&r&&g.createElement(`button`,{className:`gdg-edit-icon`,onClick:r},g.createElement(ta,null)))};function ma(){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}}var ha=ma();function ga(e){ha=e}var _a=/[&<>"']/,va=new RegExp(_a.source,`g`),ya=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,ba=new RegExp(ya.source,`g`),xa={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Sa=e=>xa[e];function Ca(e,t){if(t){if(_a.test(e))return e.replace(va,Sa)}else if(ya.test(e))return e.replace(ba,Sa);return e}var wa=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function Ta(e){return e.replace(wa,(e,t)=>(t=t.toLowerCase(),t===`colon`?`:`:t.charAt(0)===`#`?t.charAt(1)===`x`?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):``))}var Ea=/(^|[^\[])\^/g;function Da(e,t){e=typeof e==`string`?e:e.source,t||=``;let n={replace:(t,r)=>(r=r.source||r,r=r.replace(Ea,`$1`),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}var Oa=/[^\w:]/g,ka=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Aa(e,t,n){if(e){let e;try{e=decodeURIComponent(Ta(n)).replace(Oa,``).toLowerCase()}catch{return null}if(e.indexOf(`javascript:`)===0||e.indexOf(`vbscript:`)===0||e.indexOf(`data:`)===0)return null}t&&!ka.test(n)&&(n=Fa(t,n));try{n=encodeURI(n).replace(/%25/g,`%`)}catch{return null}return n}var ja={},Ma=/^[^:]+:\/*[^/]*$/,Na=/^([^:]+:)[\s\S]*$/,Pa=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Fa(e,t){ja[` `+e]||(Ma.test(e)?ja[` `+e]=e+`/`:ja[` `+e]=Ra(e,`/`,!0)),e=ja[` `+e];let n=e.indexOf(`:`)===-1;return t.substring(0,2)===`//`?n?t:e.replace(Na,`$1`)+t:t.charAt(0)===`/`?n?t:e.replace(Pa,`$1`)+t:e+t}var Ia={exec:function(){}};function La(e,t){let n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(/ \|/),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Ha(e,t,n,r){let i=t.href,a=t.title?Ca(t.title):null,o=e[1].replace(/\\([\[\]])/g,`$1`);if(e[0].charAt(0)!==`!`){r.state.inLink=!0;let e={type:`link`,raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,e}return{type:`image`,raw:n,href:i,title:a,text:Ca(o)}}function Ua(e,t){let n=e.match(/^(\s+)(?:```)/);if(n===null)return t;let r=n[1];return t.split(` +`).map(e=>{let t=e.match(/^\s+/);if(t===null)return e;let[n]=t;return n.length>=r.length?e.slice(r.length):e}).join(` +`)}var Wa=class{constructor(e){this.options=e||ha}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(/^ {1,4}/gm,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Ra(e,` +`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Ua(e,t[3]||``);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){let t=Ra(e,`#`);(this.options.pedantic||!t||/ $/.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/^ *>[ \t]?/gm,``),n=this.lexer.state.top;this.lexer.state.top=!0;let r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:`blockquote`,raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,r,i,a,o,s,c,l,u,d,f,p,m=t[1].trim(),h=m.length>1,g={type:`list`,raw:``,ordered:h,start:h?+m.slice(0,-1):``,loose:!1,items:[]};m=h?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=h?m:`[*+-]`);let _=RegExp(`^( {0,3}${m})((?:[\t ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,(t=_.exec(e))&&!this.rules.block.hr.test(e));){if(n=t[0],e=e.substring(n.length),l=t[2].split(` +`,1)[0].replace(/^\t+/,e=>` `.repeat(3*e.length)),u=e.split(` +`,1)[0],this.options.pedantic?(a=2,f=l.trimLeft()):(a=t[2].search(/[^ ]/),a=a>4?1:a,f=l.slice(a),a+=t[1].length),s=!1,!l&&/^ *$/.test(u)&&(n+=u+` +`,e=e.substring(u.length+1),p=!0),!p){let t=RegExp(`^ {0,${Math.min(3,a-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),r=RegExp(`^ {0,${Math.min(3,a-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=RegExp(`^ {0,${Math.min(3,a-1)}}(?:\`\`\`|~~~)`),o=RegExp(`^ {0,${Math.min(3,a-1)}}#`);for(;e&&(d=e.split(` +`,1)[0],u=d,this.options.pedantic&&(u=u.replace(/^ {1,4}(?=( {4})*[^ ])/g,` `)),!(i.test(u)||o.test(u)||t.test(u)||r.test(e)));){if(u.search(/[^ ]/)>=a||!u.trim())f+=` +`+u.slice(a);else{if(s||l.search(/[^ ]/)>=4||i.test(l)||o.test(l)||r.test(l))break;f+=` +`+u}!s&&!u.trim()&&(s=!0),n+=d+` +`,e=e.substring(d.length+1),l=u.slice(a)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(n)&&(c=!0)),this.options.gfm&&(r=/^\[[ xX]\] /.exec(f),r&&(i=r[0]!==`[ ] `,f=f.replace(/^\[[ xX]\] +/,``))),g.items.push({type:`list_item`,raw:n,task:!!r,checked:i,loose:!1,text:f}),g.raw+=n}g.items[g.items.length-1].raw=n.trimRight(),g.items[g.items.length-1].text=f.trimRight(),g.raw=g.raw.trimRight();let v=g.items.length;for(o=0;oe.type===`space`);g.loose=e.length>0&&e.some(e=>/\n.*\n/.test(e.raw))}if(g.loose)for(o=0;o$/,`$1`).replace(this.rules.inline._escapes,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(t){let e={type:`table`,header:La(t[1]).map(e=>({text:e})),align:t[2].replace(/^ *|\| *$/g,``).split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,``).split(` +`):[]};if(e.header.length===e.align.length){e.raw=t[0];let n=e.align.length,r,i,a,o;for(r=0;r({text:e}));for(n=e.header.length,i=0;i/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?`text`:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):Ca(t[0]):t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;let t=Ra(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=za(t[2],`()`);if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),Ha(t,{href:n&&n.replace(this.rules.inline._escapes,`$1`),title:r&&r.replace(this.rules.inline._escapes,`$1`)},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g,` `);if(e=t[e.toLowerCase()],!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Ha(n,e,n[0],this.lexer)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrong.lDelim.exec(e);if(!r||r[3]&&n.match(/[\p{L}\p{N}]/u))return;let i=r[1]||r[2]||``;if(!i||i&&(n===``||this.rules.inline.punctuation.exec(n))){let n=r[0].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=i.length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=e.slice(0,n+r.index+(r[0].length-i.length)+a);if(Math.min(n,a)%2){let e=t.slice(1,-1);return{type:`em`,raw:t,text:e,tokens:this.lexer.inlineTokens(e)}}let c=t.slice(2,-2);return{type:`strong`,raw:t,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g,` `),n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=Ca(e,!0),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){let n=this.rules.inline.autolink.exec(e);if(n){let e,r;return n[2]===`@`?(e=Ca(this.options.mangle?t(n[1]):n[1]),r=`mailto:`+e):(e=Ca(n[1]),r=e),{type:`link`,raw:n[0],text:e,href:r,tokens:[{type:`text`,raw:e,text:e}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let e,r;if(n[2]===`@`)e=Ca(this.options.mangle?t(n[0]):n[0]),r=`mailto:`+e;else{let t;do t=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0];while(t!==n[0]);e=Ca(n[0]),r=n[1]===`www.`?`http://`+n[0]:n[0]}return{type:`link`,raw:n[0],text:e,href:r,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e,t){let n=this.rules.inline.text.exec(e);if(n){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):Ca(n[0]):n[0]:Ca(this.options.smartypants?t(n[0]):n[0]),{type:`text`,raw:n[0],text:e}}}},Ga={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:Ia,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ga._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ga._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,Ga.def=Da(Ga.def).replace(`label`,Ga._label).replace(`title`,Ga._title).getRegex(),Ga.bullet=/(?:[*+-]|\d{1,9}[.)])/,Ga.listItemStart=Da(/^( *)(bull) */).replace(`bull`,Ga.bullet).getRegex(),Ga.list=Da(Ga.list).replace(/bull/g,Ga.bullet).replace(`hr`,`\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))`).replace(`def`,`\\n+(?=`+Ga.def.source+`)`).getRegex(),Ga._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`,Ga._comment=/|$)/,Ga.html=Da(Ga.html,`i`).replace(`comment`,Ga._comment).replace(`tag`,Ga._tag).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ga.paragraph=Da(Ga._paragraph).replace(`hr`,Ga.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`,Ga._tag).getRegex(),Ga.blockquote=Da(Ga.blockquote).replace(`paragraph`,Ga.paragraph).getRegex(),Ga.normal={...Ga},Ga.gfm={...Ga.normal,table:`^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`},Ga.gfm.table=Da(Ga.gfm.table).replace(`hr`,Ga.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`,Ga._tag).getRegex(),Ga.gfm.paragraph=Da(Ga._paragraph).replace(`hr`,Ga.hr).replace(`heading`,` {0,3}#{1,6} `).replace(`|lheading`,``).replace(`table`,Ga.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`,Ga._tag).getRegex(),Ga.pedantic={...Ga.normal,html:Da(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Ga._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:Ia,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Da(Ga.normal._paragraph).replace(`hr`,Ga.hr).replace(`heading`,` *#{1,6} *[^ +]`).replace(`lheading`,Ga.lheading).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).getRegex()};var q={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Ia,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:Ia,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]\`^{|}~`,q.punctuation=Da(q.punctuation).replace(/punctuation/g,q._punctuation).getRegex(),q.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,q.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,q._comment=Da(Ga._comment).replace(`(?:-->|$)`,`-->`).getRegex(),q.emStrong.lDelim=Da(q.emStrong.lDelim).replace(/punct/g,q._punctuation).getRegex(),q.emStrong.rDelimAst=Da(q.emStrong.rDelimAst,`g`).replace(/punct/g,q._punctuation).getRegex(),q.emStrong.rDelimUnd=Da(q.emStrong.rDelimUnd,`g`).replace(/punct/g,q._punctuation).getRegex(),q._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,q._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,q._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])?)+(?![-_])/,q.autolink=Da(q.autolink).replace(`scheme`,q._scheme).replace(`email`,q._email).getRegex(),q._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,q.tag=Da(q.tag).replace(`comment`,q._comment).replace(`attribute`,q._attribute).getRegex(),q._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,q._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,q._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,q.link=Da(q.link).replace(`label`,q._label).replace(`href`,q._href).replace(`title`,q._title).getRegex(),q.reflink=Da(q.reflink).replace(`label`,q._label).replace(`ref`,Ga._label).getRegex(),q.nolink=Da(q.nolink).replace(`ref`,Ga._label).getRegex(),q.reflinkSearch=Da(q.reflinkSearch,`g`).replace(`reflink`,q.reflink).replace(`nolink`,q.nolink).getRegex(),q.normal={...q},q.pedantic={...q.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:Da(/^!?\[(label)\]\((.*?)\)/).replace(`label`,q._label).getRegex(),reflink:Da(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,q._label).getRegex()},q.gfm={...q.normal,escape:Da(q.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)),t+=`&#`+r+`;`;return t}var Ja=class e{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ha,this.options.tokenizer=this.options.tokenizer||new Wa,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:Ga.normal,inline:q.normal};this.options.pedantic?(t.block=Ga.pedantic,t.inline=q.pedantic):this.options.gfm&&(t.block=Ga.gfm,t.inline=this.options.breaks?q.breaks:q.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ga,inline:q}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(/\r\n|\r/g,` +`),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){e=this.options.pedantic?e.replace(/\t/g,` `).replace(/^ +$/gm,``):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+` `.repeat(n.length));let n,r,i,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=` +`:t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&(r.type===`paragraph`||r.type===`text`)?(r.raw+=` +`+n.raw,r.text+=` +`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&(r.type===`paragraph`||r.type===`text`)?(r.raw+=` +`+n.raw,r.text+=` +`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(function(e){r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],a&&r.type===`paragraph`?(r.raw+=` +`+n.raw,r.text+=` +`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),a=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&r.type===`text`?(r.raw+=` +`+n.raw,r.text+=` +`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,a=e,o,s,c;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)e.includes(o[0].slice(o[0].lastIndexOf(`[`)+1,-1))&&(a=a.slice(0,o.index)+`[`+Va(`a`,o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+`[`+Va(`a`,o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.escapedEmSt.exec(a))!=null;)a=a.slice(0,o.index+o[0].length-2)+`++`+a.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(s||(c=``),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,c))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e,qa))e=e.substring(n.raw.length),t.push(n);else if(!this.state.inLink&&(n=this.tokenizer.url(e,qa)))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(function(e){r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i,Ka))e=e.substring(n.raw.length),n.raw.slice(-1)!==`_`&&(c=n.raw.slice(-1)),s=!0,r=t[t.length-1],r&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}}return t}},Ya=class{constructor(e){this.options=e||ha}code(e,t,n){let r=(t||``).match(/\S*/)[0];if(this.options.highlight){let t=this.options.highlight(e,r);t!=null&&t!==e&&(n=!0,e=t)}return e=e.replace(/\n$/,``)+` +`,r?`
`+(n?e:Ca(e,!0))+`
+`:`
`+(n?e:Ca(e,!0))+`
+`}blockquote(e){return`
\n${e}
\n`}html(e){return e}heading(e,t,n,r){return this.options.headerIds?`${e}\n`:`${e}\n`}hr(){return this.options.xhtml?`
+`:`
+`}list(e,t,n){let r=t?`ol`:`ul`,i=t&&n!==1?` start="`+n+`"`:``;return`<`+r+i+`> +`+e+` +`}listitem(e){return`
  • ${e}
  • \n`}checkbox(e){return` `}paragraph(e){return`

    ${e}

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

    An error occurred:

    `+Ca(r.message+``,!0)+`
    `;if(t)return Promise.resolve(e);if(n){n(null,e);return}return e}if(t)return Promise.reject(r);if(n)n(r);else throw r}}function to(e,t){return(n,r,i)=>{typeof r==`function`&&(i=r,r=null);let a={...r};r={...J.defaults,...a};let o=eo(r.silent,r.async,i);if(n==null)return o(Error(`marked(): input parameter is undefined or null`));if(typeof n!=`string`)return o(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(n)+`, string expected`));if(Ba(r),r.hooks&&(r.hooks.options=r),i){let a=r.highlight,s;try{r.hooks&&(n=r.hooks.preprocess(n)),s=e(n,r)}catch(e){return o(e)}let c=function(e){let n;if(!e)try{r.walkTokens&&J.walkTokens(s,r.walkTokens),n=t(s,r),r.hooks&&(n=r.hooks.postprocess(n))}catch(t){e=t}return r.highlight=a,e?o(e):i(null,n)};if(!a||a.length<3||(delete r.highlight,!s.length))return c();let l=0;J.walkTokens(s,function(e){e.type===`code`&&(l++,setTimeout(()=>{a(e.text,e.lang,function(t,n){if(t)return c(t);n!=null&&n!==e.text&&(e.text=n,e.escaped=!0),l--,l===0&&c()})},0))}),l===0&&c()}else{if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(t=>e(t,r)).then(e=>r.walkTokens?Promise.all(J.walkTokens(e,r.walkTokens)).then(()=>e):e).then(e=>t(e,r)).then(e=>r.hooks?r.hooks.postprocess(e):e).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let i=e(n,r);r.walkTokens&&J.walkTokens(i,r.walkTokens);let a=t(i,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(e){return o(e)}}}}function J(e,t,n){return to(Ja.lex,Qa.parse)(e,t,n)}J.options=J.setOptions=function(e){return J.defaults={...J.defaults,...e},ga(J.defaults),J},J.getDefaults=ma,J.defaults=ha,J.use=function(...e){let t=J.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(e=>{let n={...e};if(n.async=J.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(e.renderer){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(e.tokenizer){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);t[e.level]?t[e.level].unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=J.defaults.renderer||new Ya;for(let n in e.renderer){let r=t[n];t[n]=(...i)=>{let a=e.renderer[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.renderer=t}if(e.tokenizer){let t=J.defaults.tokenizer||new Wa;for(let n in e.tokenizer){let r=t[n];t[n]=(...i)=>{let a=e.tokenizer[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.tokenizer=t}if(e.hooks){let t=J.defaults.hooks||new $a;for(let n in e.hooks){let r=t[n];t[n]=$a.passThroughHooks.has(n)?i=>{if(J.defaults.async)return Promise.resolve(e.hooks[n].call(t,i)).then(e=>r.call(t,e));let a=e.hooks[n].call(t,i);return r.call(t,a)}:(...i)=>{let a=e.hooks[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.hooks=t}if(e.walkTokens){let t=J.defaults.walkTokens;n.walkTokens=function(n){let r=[];return r.push(e.walkTokens.call(this,n)),t&&(r=r.concat(t.call(this,n))),r}}J.setOptions(n)})},J.walkTokens=function(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(J,r)),r.type){case`table`:for(let e of r.header)n=n.concat(J.walkTokens(e.tokens,t));for(let e of r.rows)for(let r of e)n=n.concat(J.walkTokens(r.tokens,t));break;case`list`:n=n.concat(J.walkTokens(r.items,t));break;default:J.defaults.extensions&&J.defaults.extensions.childTokens&&J.defaults.extensions.childTokens[r.type]?J.defaults.extensions.childTokens[r.type].forEach(function(e){n=n.concat(J.walkTokens(r[e],t))}):r.tokens&&(n=n.concat(J.walkTokens(r.tokens,t)))}return n},J.parseInline=to(Ja.lexInline,Qa.parseInline),J.Parser=Qa,J.parser=Qa.parse,J.Renderer=Ya,J.TextRenderer=Xa,J.Lexer=Ja,J.lexer=Ja.lex,J.Tokenizer=Wa,J.Slugger=Za,J.Hooks=$a,J.parse=J,J.options,J.setOptions,J.use,J.walkTokens,J.parseInline,Qa.parse,Ja.lex;var no=Si(`div`)({name:`MarkdownContainer`,class:`gdg-mnuv029`,propsAsIs:!1}),ro=class extends g.PureComponent{targetElement=null;renderMarkdownIntoDiv(){let{targetElement:e,props:t}=this;if(e===null)return;let{contents:n,createNode:r}=t,i=J(n),a=document.createRange();a.selectNodeContents(e),a.deleteContents();let o=r?.(i);if(o===void 0){let e=document.createElement(`template`);e.innerHTML=i,o=e.content}e.append(o);let s=e.getElementsByTagName(`a`);for(let e of s)e.target=`_blank`,e.rel=`noreferrer noopener`}containerRefHook=e=>{this.targetElement=e,this.renderMarkdownIntoDiv()};render(){return this.renderMarkdownIntoDiv(),g.createElement(no,{ref:this.containerRefHook})}},io=Si(`textarea`)({name:`InputBox`,class:`gdg-izpuzkl`,propsAsIs:!1}),ao=Si(`div`)({name:`ShadowBox`,class:`gdg-s69h75o`,propsAsIs:!1}),oo=Si(`div`)({name:`GrowingEntryStyle`,class:`gdg-g1y0xocz`,propsAsIs:!1}),so=0,co=e=>{let{placeholder:t,value:n,onKeyDown:r,highlight:i,altNewline:a,validatedSelection:o,...s}=e,{onChange:c,className:l}=s,u=g.useRef(null),d=n??``;Kn(c!==void 0,`GrowingEntry must be a controlled input area`);let[f]=g.useState(()=>`input-box-`+(so=(so+1)%1e7));g.useEffect(()=>{let e=u.current;if(e===null||e.disabled)return;let t=d.toString().length;e.focus(),e.setSelectionRange(i?0:t,t)},[]),g.useLayoutEffect(()=>{if(o!==void 0){let e=typeof o==`number`?[o,null]:o;u.current?.setSelectionRange(e[0],e[1])}},[o]);let p=g.useCallback(e=>{e.key===`Enter`&&e.shiftKey&&a===!0||r?.(e)},[a,r]);return g.createElement(oo,{className:`gdg-growing-entry`},g.createElement(ao,{className:l},d+` +`),g.createElement(io,{...s,className:(l??``)+` gdg-input`,id:f,ref:u,onKeyDown:p,value:d,placeholder:t,dir:`auto`}))},lo={},uo=null;function fo(){let e=document.createElement(`div`);return e.style.opacity=`0`,e.style.pointerEvents=`none`,e.style.position=`fixed`,document.body.append(e),e}function po(e){let t=e.toLowerCase().trim();if(lo[t]!==void 0)return lo[t];uo||=fo(),uo.style.color=`#000`,uo.style.color=t;let n=getComputedStyle(uo).color;uo.style.color=`#fff`,uo.style.color=t;let r=getComputedStyle(uo).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(e=>Number.isNaN(e)?0:e),lo[t]=i,i}function mo(e,t){let[n,r,i]=po(e);return`rgba(${n}, ${r}, ${i}, ${t})`}var ho=new Map;function go(e,t){let n=`${e}-${t}`,r=ho.get(n);if(r!==void 0)return r;let i=_o(e,t);return ho.set(n,i),i}function _o(e,t){if(t===void 0)return e;let[n,r,i,a]=po(e);if(a===1)return e;let[o,s,c,l]=po(t),u=a+l*(1-a);return`rgba(${(a*n+l*o*(1-a))/u}, ${(a*r+l*s*(1-a))/u}, ${(a*i+l*c*(1-a))/u}, ${u})`}var vo=new Map,yo=new Map,bo=new Map;function xo(){vo.clear(),bo.clear(),yo.clear()}function So(e,t,n,r,i){let a=0,o={};for(let t of e)a+=n.get(t)??i,o[t]=(o[t]??0)+1;let s=t-a;for(let e of Object.keys(o)){let t=o[e],c=n.get(e)??i,l=c+s*(c*t/a)*r/t;n.set(e,l)}}function Co(e,t){let n=new Map,r=0;for(let t of`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?`){let i=e.measureText(t).width;n.set(t,i),r+=i}let i=r/n.size,a=(t/i+3)/4,o=n.keys();for(let e of o)n.set(e,(n.get(e)??i)*a);return n}function wo(e,t,n,r){let i=yo.get(n);if(r&&i!==void 0&&i.count>2e4){let r=bo.get(n);if(r===void 0&&(r=Co(e,i.size),bo.set(n,r)),i.count>5e5){let e=0;for(let n of t)e+=r.get(n)??i.size;return e*1.01}let a=e.measureText(t);return So(t,a.width,r,Math.max(.05,1-i.count/2e5),i.size),yo.set(n,{count:i.count+t.length,size:i.size}),a.width}let a=e.measureText(t),o=a.width/t.length;if((i?.count??0)>2e4)return a.width;if(i===void 0)yo.set(n,{count:t.length,size:o});else{let e=o-i.size,r=t.length/(i.count+t.length),a=i.size+e*r;yo.set(n,{count:i.count+t.length,size:a})}return a.width}function To(e,t,n,r,i,a,o,s){if(t.length<=1)return t.length;if(in;){let n=u===void 0?t.lastIndexOf(` `,c-1):0;n>0?c=n:c--,l=wo(e,t.slice(0,Math.max(0,c)),r,o)}}if(t[c]!==` `){let e=0;if(u===void 0)e=t.lastIndexOf(` `,c);else for(let t of u){if(t>c)break;e=t}e>0&&(c=e)}return c}function Eo(e,t,n,r,i,a){let o=`${t}_${n}_${r}px`,s=vo.get(o);if(s!==void 0)return s;if(r<=0)return[];let c=[],l=t.split(` +`),u=yo.get(n),d=u===void 0?t.length:r/u.size*1.5,f=i&&u!==void 0&&u.count>2e4;for(let t of l){let i=wo(e,t.slice(0,Math.max(0,d)),n,f),o=Math.min(t.length,d);if(i<=r)c.push(t);else{for(;i>r;){let s=To(e,t,r,n,i,o,f,a),l=t.slice(0,Math.max(0,s));t=t.slice(l.length),c.push(l),i=wo(e,t.slice(0,Math.max(0,d)),n,f),o=Math.min(t.length,d)}i>0&&c.push(t)}}return c=c.map((e,t)=>t===0?e.trimEnd():e.trim()),vo.set(o,c),vo.size>500&&vo.delete(vo.keys().next().value),c}function Do(e,t){return g.useMemo(()=>e.map((e,n)=>({group:e.group,grow:e.grow,hasMenu:e.hasMenu,icon:e.icon,id:e.id,menuIcon:e.menuIcon,overlayIcon:e.overlayIcon,sourceIndex:n,sticky:n=e.x&&n=e.y&&r=t.span[0]&&n.current.cell[0]<=t.span[1]}function jo(e,t){let[n,r]=e;return n>=t.x&&n=t.y&&ro)return!1;if(t.span===void 0)return s>=r&&s<=i;let[l,u]=t.span;return l>=r&&l<=i||u>=r&&l<=i||li}function Fo(e,t,n,r){let i=0;if(n.current===void 0)return i;let a=n.current.range;(r||a.height*a.width>1)&&Po(e,t,a)&&i++;for(let r of n.current.rangeStack)Po(e,t,r)&&i++;return i}function Io(e,t){let n=e;if(t!==void 0){let r=[...e],i=n[t.src];t.src>t.dest?(r.splice(t.src,1),r.splice(t.dest,0,i)):(r.splice(t.dest+1,0,i),r.splice(t.src,1)),r=r.map((t,n)=>({...t,sticky:e[n].sticky})),n=r}return n}function Lo(e,t){let n=0,r=Io(e,t);for(let e=0;e0)for(let e of o)n-=e.width;let s=t,c=i??0;for(;c<=n&&s=d)return n}let f=a-l,p=e-(c??0);if(typeof o==`number`){let e=Math.floor((p-u)/o)+s;return e>=f?void 0:e}{let e=u;for(let t=s;t`u`;async function Go(){Wo||document?.fonts?.ready===void 0||(await document.fonts.ready,Ho=0,Uo={},xo())}Go();function Ko(e,t,n,r){return`${e}_${r??t?.font}_${n}`}function qo(e,t,n,r=`middle`){let i=Ko(e,t,r,n),a=Uo[i];return a===void 0&&(a=t.measureText(e),Uo[i]=a,Ho++),Ho>1e4&&(Uo={},Ho=0),a}function Jo(e,t){let n=Ko(e,void 0,`middle`,t);return Uo[n]}function Yo(e,t){return typeof t!=`string`&&(t=t.baseFontFull),Qo(e,t)}function Xo(e,t){e.save(),e.textBaseline=t;let n=e.measureText(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`);return e.restore(),n}var Zo=[];function Qo(e,t){for(let e of Zo)if(e.key===t)return e.val;let n=Xo(e,`alphabetic`),r=-(Xo(e,`middle`).actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return Zo.push({key:t,val:r}),r}function $o(e,t,n,r,i,a){let{ctx:o,rect:s,theme:c}=e,l=2**53-1;return t!==void 0&&(l=n-t,l<500&&(o.globalAlpha=1-l/500,o.fillStyle=c.bgSearchResult,o.fillRect(s.x+1,s.y+1,s.width-(i?2:1),s.height-(a?2:1)),o.globalAlpha=1,r!==void 0&&(r.fillStyle=c.bgSearchResult))),l<500}function es(e,t,n){let{ctx:r,theme:i}=e,a=t??{},o=n??i.textDark;return o!==a.fillStyle&&(r.fillStyle=o,a.fillStyle=o),a}function ts(e,t,n,r,i,a,o,s,c){c===`right`?e.fillText(t,n+i-(s.cellHorizontalPadding+.5),r+a/2+o):c===`center`?e.fillText(t,n+i/2,r+a/2+o):e.fillText(t,n+s.cellHorizontalPadding+.5,r+a/2+o)}function ns(e,t){let n=qo(`ABCi09jgqpy`,e,t);return n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}function rs(e,t){e.includes(` +`)&&(e=e.split(/\r?\n/,1)[0]);let n=t/4;return e.length>n&&(e=e.slice(0,n)),e}function is(e,t,n,r,i,a,o,s,c,l){let u=s.baseFontFull,d=Eo(e,t,u,i-s.cellHorizontalPadding*2,l??!1),f=ns(e,u),p=s.lineHeight*f,m=f+p*(d.length-1),h=m+s.cellVerticalPadding>a;h&&(e.save(),e.rect(n,r,i,a),e.clip());let g=r+a/2-m/2,_=Math.max(r+s.cellVerticalPadding,g);for(let t of d)if(ts(e,t,n,_,i,f,o,s,c),_+=p,_>r+a)break;h&&e.restore()}function as(e,t,n,r,i){let{ctx:a,rect:o,theme:s}=e,{x:c,y:l,width:u,height:d}=o;r??=!1,r||(t=rs(t,u));let f=Yo(a,s),p=aa(t)===`rtl`;if(n===void 0&&p&&(n=`right`),p&&(a.direction=`rtl`),t.length>0){let e=!1;n===`right`?(a.textAlign=`right`,e=!0):n!==void 0&&n!==`left`&&(a.textAlign=n,e=!0),r?is(a,t,c,l,u,d,f,s,n,i):ts(a,t,c,l,u,d,f,s,n),e&&(a.textAlign=`start`),p&&(a.direction=`inherit`)}}function os(e,t,n,r,i,a){typeof a==`number`&&(a={tl:a,tr:a,br:a,bl:a}),a={tl:Math.max(0,Math.min(a.tl,i/2,r/2)),tr:Math.max(0,Math.min(a.tr,i/2,r/2)),bl:Math.max(0,Math.min(a.bl,i/2,r/2)),br:Math.max(0,Math.min(a.br,i/2,r/2))},e.moveTo(t+a.tl,n),e.arcTo(t+r,n,t+r,n+a.tr,a.tr),e.arcTo(t+r,n+i,t+r-a.br,n+i,a.br),e.arcTo(t,n+i,t,n+i-a.bl,a.bl),e.arcTo(t,n,t+a.tl,n,a.tl)}function ss(e,t,n){let r=1.25;e.arc(t,n-r*3.5,r,0,2*Math.PI,!1),e.arc(t,n,r,0,2*Math.PI,!1),e.arc(t,n+r*3.5,r,0,2*Math.PI,!1)}function cs(e,t,n){let r=function(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),a=n/i,o=r/i;return{x:n,y:t.y-e.y,len:i,nx:a,ny:o,ang:Math.atan2(o,a)}},i,a=t.length,o=t[a-1];for(let s=0;s1?1:f),h=1,g=!1;p<0?m<0?m=Math.PI+m:(m=Math.PI-m,h=-1,g=!0):m>0&&(h=-1,g=!0),i=c.radius===void 0?n:c.radius;let _=m/2,v=Math.abs(Math.cos(_)*i/Math.sin(_)),y;v>Math.min(u.len/2,d.len/2)?(v=Math.min(u.len/2,d.len/2),y=Math.abs(v*Math.sin(_)/Math.cos(_))):y=i;let b=c.x+d.nx*v,x=c.y+d.ny*v;b+=-d.ny*y*h,x+=d.nx*y*h,e.arc(b,x,y,u.ang+Math.PI/2*h,d.ang-Math.PI/2*h,g),o=c,c=l}e.closePath()}function ls(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h={x:0,y:a+l,width:0,height:0};if(e>=p.length||t>=u||t<-2||e<0)return h;let g=a-i;if(e>=d){let t=o>e?-1:1,n=Lo(p);h.x+=n+c;for(let n=o;n!==e;n+=t)h.x+=p[t===1?n:n-1].width*t}else for(let t=0;t0&&ko(p[t-1].group,r)&&p[t-1].sticky===a;){let e=p[t-1];h.x-=e.width,h.width+=e.width,t--}let o=e;for(;o+1n&&(h.width=n-h.x)}}else if(t>=u-f){let e=u-t;for(h.y=r;e>0;){let n=t+e-1;h.height=typeof m==`number`?m:m(n),h.y-=h.height,e--}h.height+=1}else{let e=s>t?-1:1;if(typeof m==`number`){let e=t-s;h.y+=e*m}else for(let n=s;n!==t;n+=e)h.y+=m(n)*e;h.height=(typeof m==`number`?m:m(t))+1}return h}var us=1<<21;function ds(e,t){return(t+2)*us+e}function fs(e){return e%us}function ps(e){return Math.floor(e/us)-2}function ms(e){return[fs(e),ps(e)]}var hs=class{visibleWindow={x:0,y:0,width:0,height:0};freezeCols=0;freezeRows=[];isInWindow=e=>{let t=fs(e),n=ps(e),r=this.visibleWindow,i=t>=r.x&&t<=r.x+r.width||t=r.y&&n<=r.y+r.height||this.freezeRows.includes(n);return i&&a};setWindow(e,t,n){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===t&&Xn(this.freezeRows,n)||(this.visibleWindow=e,this.freezeCols=t,this.freezeRows=n,this.clearOutOfWindow())}},gs=class extends hs{cache=new Map;setValue=(e,t)=>{this.cache.set(ds(e[0],e[1]),t)};getValue=e=>this.cache.get(ds(e[0],e[1]));clearOutOfWindow=()=>{for(let[e]of this.cache.entries())this.isInWindow(e)||this.cache.delete(e)}},_s=class{cells;constructor(e=[]){this.cells=new Set(e.map(e=>ds(e[0],e[1])))}add(e){this.cells.add(ds(e[0],e[1]))}has(e){return e!==void 0&&this.cells.has(ds(e[0],e[1]))}remove(e){this.cells.delete(ds(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(let e of this.cells)if(ps(e)<0)return!0;return!1}hasItemInRectangle(e){for(let t=e.y;t{let i=ws(e,n[r],t,c);return l=Math.max(l,i),i});if(u.length>5&&s){l=0;let e=0;for(let t of u)e+=t;let t=e/u.length;for(let e=0;e=t*2?u[e]=0:l=Math.max(l,u[e])}l=Math.max(l,e.measureText(n.title).width+16+(n.icon===void 0?0:28));let d=Math.max(Math.ceil(a),Math.min(Math.floor(o),Math.ceil(l)));return{...n,width:d}}function Es(e,t,n,r,i,a,o,s,c){let l=g.useRef(t),u=g.useRef(n),d=g.useRef(o);l.current=t,u.current=n,d.current=o;let[f,p]=g.useMemo(()=>{if(typeof window>`u`)return[null,null];let e=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,[e,e.getContext(`2d`,{alpha:!1})]},[]);g.useLayoutEffect(()=>(f&&document.documentElement.append(f),()=>{f?.remove()}),[f]);let m=g.useRef({}),h=g.useRef(),[_,v]=g.useState();return g.useLayoutEffect(()=>{let t=u.current;if(t===void 0||e.every(ni))return;let n=Math.max(1,10-Math.floor(e.length/1e4)),r=0;n1&&(n--,r=1);let i={x:0,y:0,width:e.length,height:Math.min(l.current,n)},a={x:0,y:l.current-1,width:e.length,height:1};(async()=>{let n=t(i,c.signal),o=r>0?t(a,c.signal):void 0,s;s=typeof n==`object`?n:await ri(n),o!==void 0&&(s=typeof o==`object`?[...s,...o]:[...s,...await ri(o)]),h.current=e,v(s)})()},[c.signal,e]),g.useMemo(()=>{let t=e.every(ni)?e:p===null?e.map(e=>ni(e)?e:{...e,width:Cs}):(p.font=d.current.baseFontFull,e.map((t,n)=>{if(ni(t))return t;if(m.current[t.id]!==void 0)return{...t,width:m.current[t.id]};if(_===void 0||h.current!==e||t.id===void 0)return{...t,width:Cs};let r=Ts(p,o,t,n,_,i,a,!0,s);return m.current[t.id]=r.width,r})),n=0,c=0,l=[];for(let[e,r]of t.entries())n+=r.width,r.grow!==void 0&&r.grow>0&&(c+=r.grow,l.push(e));if(n0){let e=[...t],i=r-n,a=i;for(let n=0;n{function n(e,t,n){return e===e&&(n!==void 0&&(e=e<=n?e:n),t!==void 0&&(e=e>=t?e:t)),e}t.exports=n})),Os=o(((e,t)=>{var n=Ds(),r=Wi();function i(e,t,i){return i===void 0&&(i=t,t=void 0),i!==void 0&&(i=r(i),i=i===i?i:0),t!==void 0&&(t=r(t),t=t===t?t:0),n(r(e),t,i)}t.exports=i})),ks=o(((e,t)=>{function n(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this}t.exports=n})),As=o(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),js=o(((e,t)=>{var n=zr(),r=ks(),i=As();function a(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new n;++t{function n(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a{function n(e){return e!==e}t.exports=n})),Ps=o(((e,t)=>{function n(e,t,n){for(var r=n-1,i=e.length;++r{var n=Ms(),r=Ns(),i=Ps();function a(e,t,a){return t===t?i(e,t,a):n(e,r,a)}t.exports=a})),Is=o(((e,t)=>{var n=Fs();function r(e,t){return!!(e!=null&&e.length)&&n(e,t,0)>-1}t.exports=r})),Ls=o(((e,t)=>{function n(e,t,n){for(var r=-1,i=e==null?0:e.length;++r{function n(e,t){return e.has(t)}t.exports=n})),zs=o(((e,t)=>{t.exports=hr()(er(),`Set`)})),Bs=o(((e,t)=>{function n(){}t.exports=n})),Vs=o(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}t.exports=n})),Hs=o(((e,t)=>{var n=zs(),r=Bs(),i=Vs();t.exports=n&&1/i(new n([,-0]))[1]==1/0?function(e){return new n(e)}:r})),Us=o(((e,t)=>{var n=js(),r=Is(),i=Ls(),a=Rs(),o=Hs(),s=Vs(),c=200;function l(e,t,l){var u=-1,d=r,f=e.length,p=!0,m=[],h=m;if(l)p=!1,d=i;else if(f>=c){var g=t?null:o(e);if(g)return s(g);p=!1,d=a,h=new n}else h=t?[]:m;outer:for(;++u{var n=Us();function r(e){return e&&e.length?n(e):[]}t.exports=r})),Gs=o(((e,t)=>{function n(e,t){for(var n=-1,r=t.length,i=e.length;++n{var n=tr(),r=Jr(),i=Qn(),a=n?n.isConcatSpreadable:void 0;function o(e){return i(e)||r(e)||!!(a&&e&&e[a])}t.exports=o})),qs=o(((e,t)=>{var n=Gs(),r=Ks();function i(e,t,a,o,s){var c=-1,l=e.length;for(a||=r,s||=[];++c0&&a(u)?t>1?i(u,t-1,a,o,s):n(s,u):o||(s[s.length]=u)}return s}t.exports=i})),Js=o(((e,t)=>{var n=qs();function r(e){return e!=null&&e.length?n(e,1):[]}t.exports=r})),Ys=o(((e,t)=>{var n=Math.ceil,r=Math.max;function i(e,t,i,a){for(var o=-1,s=r(n((t-e)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=e,e+=i;return c}t.exports=i})),Xs=o(((e,t)=>{var n=lr(),r=Xr();function i(e){return e!=null&&r(e.length)&&!n(e)}t.exports=i})),Zs=o(((e,t)=>{var n=wr(),r=Xs(),i=Yr(),a=cr();function o(e,t,o){if(!a(o))return!1;var s=typeof t;return(s==`number`?r(o)&&i(t,o.length):s==`string`&&t in o)?n(o[t],e):!1}t.exports=o})),Qs=o(((e,t)=>{var n=Wi(),r=1/0,i=17976931348623157e292;function a(e){return e?(e=n(e),e===r||e===-r?(e<0?-1:1)*i:e===e?e:0):e===0?e:0}t.exports=a})),$s=o(((e,t)=>{var n=Ys(),r=Zs(),i=Qs();function a(e){return function(t,a,o){return o&&typeof o!=`number`&&r(t,a,o)&&(a=o=void 0),t=i(t),a===void 0?(a=t,t=0):a=i(a),o=o===void 0?t{t.exports=$s()()}));function tc(e,t){return e===`normal`?[t.bgIconHeader,t.fgIconHeader]:e===`selected`?[`white`,t.accentColor]:[t.accentColor,t.bgHeader]}var nc=class{onSettled;spriteMap=new Map;headerIcons;inFlight=0;constructor(e,t){this.onSettled=t,this.headerIcons=e??{}}drawSprite(e,t,n,r,i,a,o,s=1){let[c,l]=tc(t,o),u=a*Math.ceil(window.devicePixelRatio),d=`${c}_${l}_${u}_${e}`,f=this.spriteMap.get(d);if(f===void 0){let t=this.headerIcons[e];if(t===void 0)return;f=document.createElement(`canvas`);let n=f.getContext(`2d`);if(n===null)return;let r=new Image;r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t({fgColor:l,bgColor:c}))}`,this.spriteMap.set(d,f);let i=r.decode();if(i===void 0)return;this.inFlight++,i.then(()=>{n.drawImage(r,0,0,u,u)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else s<1&&(n.globalAlpha=s),n.drawImage(f,0,0,u,u,r,i,a,a),s<1&&(n.globalAlpha=1)}};function rc(e){if(e.length===0)return;let t;for(let n of e)t=Math.min(t??n.y,n.y)}function ic(e,t,n,r,i,a,o,s,c){s??=t;let l=t,u=e,d=r-a,f=!1;for(;ls&&c(l,u,e,!1,o&&u===r-1)===!0){f=!0;break}l+=e,u++}if(!f){l=n;for(let e=0;e!e.sticky)?.sourceIndex??0;if(c>d){let e=Math.max(s,d),l=t,f=r;for(let t=a.sourceIndex-1;t>=e;t--)l-=o[t].width,f+=o[t].width;for(let e=a.sourceIndex+1;e<=c;e++)f+=o[e].width;u={x:l,y:n,width:f,height:i}}if(d>s){let e=Math.min(c,d-1),u=t,f=r;for(let e=a.sourceIndex-1;e>=s;e--)u-=o[e].width,f+=o[e].width;for(let t=a.sourceIndex+1;t<=e;t++)f+=o[t].width;l={x:u,y:n,width:f,height:i}}return[l,u]}function cc(e,t,n,r){if(r===`any`)return dc(e,{x:t,y:n,width:1,height:1});if(r===`vertical`&&(t=e.x),r===`horizontal`&&(n=e.y),jo([t,n],e))return;let i=t-e.x,a=e.x+e.width-t,o=n-e.y+1,s=e.y+e.height-n,c=Math.min(r===`vertical`?2**53-1:i,r===`vertical`?2**53-1:a,r===`horizontal`?2**53-1:o,r===`horizontal`?2**53-1:s);return c===s?{x:e.x,y:e.y+e.height,width:e.width,height:n-e.y-e.height+1}:c===o?{x:e.x,y:n,width:e.width,height:e.y-n}:c===a?{x:e.x+e.width,y:e.y,width:t-e.x-e.width+1,height:e.height}:{x:t,y:e.y,width:e.x-t,height:e.height}}function lc(e,t,n,r,i,a,o,s){return e<=i+o&&i<=e+n&&t<=a+s&&a<=t+r}function uc(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function dc(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function fc(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function pc(e,t,n,r){if(e.x>t||e.y>n||e.x<0&&e.y<0&&e.x+e.width>t&&e.y+e.height>n)return;if(e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n)return e;let i=t+4,a=n+4,o=-4-e.x,s=e.x+e.width-i,c=-4-e.y,l=e.y+e.height-a,u=o>0?e.x+Math.floor(o/r)*r:e.x,d=s>0?e.x+e.width-Math.floor(s/r)*r:e.x+e.width,f=c>0?e.y+Math.floor(c/r)*r:e.y,p=l>0?e.y+e.height-Math.floor(l/r)*r:e.y+e.height;return{x:u,y:f,width:d-u,height:p-f}}function mc(e,t,n,r,i){let[a,o,s,c]=t,[l,u,d,f]=i,{x:p,y:m,width:h,height:g}=e,_=[];if(h<=0||g<=0)return _;let v=p+h,y=m+g,b=ps,C=m+g>c,w=p>=a&&pa&&v<=s||ps,T=m>=o&&mo&&y<=c||mc;if(w&&T){let e=Math.max(p,a),t=Math.max(m,o),n=Math.min(v,s),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:u,width:d-l+1,height:f-u+1}})}if(b&&x){let e=p,t=m,n=Math.min(v,a),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:0,width:l+1,height:u+1}})}if(x&&w){let e=Math.max(p,a),t=m,n=Math.min(v,s),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:0,width:d-l+1,height:u+1}})}if(x&&S){let e=Math.max(p,s),t=m,r=v,i=Math.min(y,o);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:0,width:n-d+1,height:u+1}})}if(b&&T){let e=p,t=Math.max(m,o),n=Math.min(v,a),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:u,width:l+1,height:f-u+1}})}if(S&&T){let e=Math.max(p,s),t=Math.max(m,o),r=v,i=Math.min(y,c);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:u,width:n-d+1,height:f-u+1}})}if(b&&C){let e=p,t=Math.max(m,c),n=Math.min(v,a),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:0,y:f,width:l+1,height:r-f+1}})}if(C&&w){let e=Math.max(p,a),t=Math.max(m,c),n=Math.min(v,s),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:l,y:f,width:d-l+1,height:r-f+1}})}if(S&&C){let e=Math.max(p,s),t=Math.max(m,c),i=v,a=y;_.push({rect:{x:e,y:t,width:i-e,height:a-t},clip:{x:d,y:f,width:n-d+1,height:r-f+1}})}return _}var Y={kind:K.Loading,allowOverlay:!1};function hc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,ee,te,ne,re){let j=y?.size??2**53-1,M=performance.now(),ie=k.baseFontFull;e.font=ie;let ae={ctx:e},N=[0,0],oe=g>0?Ro(c,g,l):0,P,F,se=rc(v);return ac(t,s,a,o,i,(t,a,o,s,I)=>{let ce=Math.max(0,s-a),le=a+ce,ue=i+1,de=t.width-ce,fe=r-i-1;if(v.length>0){let e=!1;for(let t=0;t{e.save(),e.beginPath(),e.rect(le,ue,de,fe),e.clip()},me=b.columns.hasIndex(t.sourceIndex),L=d(t.group??``).overrideTheme,he=t.themeOverride===void 0&&L===void 0?k:Ss(k,L,t.themeOverride),R=he.baseFontFull;R!==ie&&(ie=R,e.font=R),pe();let ge;return ic(I,o,r,c,l,g,_,se,(i,o,l,d,g)=>{if(o<0||(N[0]=t.sourceIndex,N[1]=o,y!==void 0&&!y.has(N)))return;if(v.length>0){let e=!1;for(let n=0;nI.span!==void 0&&e>=I.span[0]&&e<=I.span[1]);_e&&!m&&h?ve=0:_e&&h&&(ve=Math.max(ve,1)),ye&&ve++,_e||(_&&ve++,me&&!g&&ve++);let be=I.kind===K.Protected?z.bgCellMedium:z.bgCell,xe;if((d||be!==k.bgCell)&&(xe=_o(be,xe)),ve>0||se){se&&(xe=_o(z.bgHeader,xe));for(let e=0;ere&&!de){let n=z.baseFontFull;n!==ie&&(e.font=n,ie=n),ge=xc(e,I,t.sourceIndex,o,Ce,we,ce,i,le,l,ve>0,z,xe??z.bgCell,C,w,B?.hoverAmount??0,E,O,M,D,ge,A,ee,te,ne)}return Se&&e.restore(),I.style===`faded`&&(e.globalAlpha=1),j--,ue&&(e.restore(),ge?.deprep?.(ae),ge=void 0,pe(),ie=R,e.font=R),j<=0}),e.restore(),j<=0}),P}var gc=[0,0],_c={x:0,y:0,width:0,height:0},vc=[void 0,()=>void 0],yc=!1;function bc(){yc=!0}function xc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w){let T,E;g!==void 0&&g[0][0]===n&&g[0][1]===r&&(T=g[1][0],E=g[1][1]);let D;gc[0]=n,gc[1]=r,_c.x=o,_c.y=s,_c.width=c,_c.height=l,vc[0]=S.getValue(gc),vc[1]=e=>S.setValue(gc,e),yc=!1;let O={ctx:e,theme:d,col:n,row:r,cell:t,rect:_c,highlighted:u,cellFillColor:f,hoverAmount:h,frameTime:v,hoverX:T,drawState:vc,hoverY:E,imageLoader:p,spriteManager:m,hyperWrapping:_,overrideCursor:T===void 0?void 0:w,requestAnimationFrame:bc},k=$o(O,t.lastUpdated,v,b,i,a),A=C(t);if(A!==void 0){b?.renderer!==A&&(b?.deprep?.(O),b=void 0);let e=A.drawPrep?.(O,b);y!==void 0&&!ai(O.cell)?y(O,()=>A.draw(O,t)):A.draw(O,t),D=e===void 0?void 0:{deprep:e?.deprep,fillStyle:e?.fillStyle,font:e?.font,renderer:A}}return(k||yc)&&x?.(gc),D}function Sc(e,t,n,r,i,a,o,s,c=-20,l=-20,u=32,d=`center`,f=`square`){let p=Math.floor(i+o/2),m=f===`circle`?1e4:t.roundingRadius??4,h=$i(u,o,t.cellVerticalPadding),g=h/2,_=Qi(d,r,a,t.cellHorizontalPadding,h),v=Zi(_,p,h),y=ea(r+c,i+l,v);switch(n){case!0:e.beginPath(),os(e,_-h/2,p-h/2,h,h,m),f===`circle`&&(g*=.8,h*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(_-g+h/4.23,p-g+h/1.97),e.lineTo(_-g+h/2.42,p-g+h/1.44),e.lineTo(_-g+h/1.29,p-g+h/3.25),e.strokeStyle=t.bgCell,e.lineJoin=`round`,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;case null:case!1:e.beginPath(),os(e,_-h/2+.5,p-h/2+.5,h-1,h-1,m),e.lineWidth=1,e.strokeStyle=y?t.textDark:t.textMedium,e.stroke();break;case void 0:e.beginPath(),os(e,_-h/2,p-h/2,h,h,m),e.fillStyle=y?t.textMedium:t.textLight,e.fill(),f===`circle`&&(g*=.8,h*=.8),e.beginPath(),e.moveTo(_-h/3,p),e.lineTo(_+h/3,p),e.strokeStyle=t.bgCell,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;default:qn(n)}}function Cc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=o+s;if(y<=0)return;e.fillStyle=d.bgHeader,e.fillRect(0,0,i,y);let[b,x]=r?.[0]??[];e.font=d.headerFontFull,ac(t,0,a,0,y,(t,r,i,a)=>{if(g!==void 0&&!g.has([t.sourceIndex,-1]))return;let m=Math.max(0,a-r);e.save(),e.beginPath(),e.rect(r+m,s,t.width-m,o),e.clip();let y=h(t.group??``).overrideTheme,S=t.themeOverride===void 0&&y===void 0?d:Ss(d,y,t.themeOverride);S.bgHeader!==d.bgHeader&&(e.fillStyle=S.bgHeader,e.fill()),S!==d&&(e.font=S.baseFontFull);let C=u.columns.hasIndex(t.sourceIndex),w=c!==void 0||l,T=!w&&x===-1&&b===t.sourceIndex,E=w?0:p.find(e=>e.item[0]===t.sourceIndex&&e.item[1]===-1)?.hoverAmount??0,D=u?.current!==void 0&&u.current.cell[0]===t.sourceIndex,O=C?S.accentColor:D?S.bgHeaderHasFocus:S.bgHeader,k=n?s:0,A=t.sourceIndex===0?0:1;C?(e.fillStyle=O,e.fillRect(r+A,k,t.width-A,o)):(D||E>0)&&(e.beginPath(),e.rect(r+A,k,t.width-A,o),D&&(e.fillStyle=S.bgHeaderHasFocus,e.fill()),E>0&&(e.globalAlpha=E,e.fillStyle=S.bgHeaderHovered,e.fill(),e.globalAlpha=1)),kc(e,r,k,t.width,o,t,C,S,T,D,E,f,_,v),e.restore()}),n&&wc(e,t,i,a,s,r,d,f,p,m,h,g)}function wc(e,t,n,r,i,a,o,s,c,l,u,d){let[f,p]=a?.[0]??[],m=0;oc(t,n,r,i,(t,n,r,c,h,g)=>{if(d!==void 0&&!d.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1}))return;e.save(),e.beginPath(),e.rect(r,c,h,g),e.clip();let _=u(n),v=_?.overrideTheme===void 0?o:Ss(o,_.overrideTheme),y=p===-2&&f!==void 0&&f>=t[0]&&f<=t[1],b=y?v.bgHeaderHovered:v.bgHeader;if(b!==o.bgHeader&&(e.fillStyle=b,e.fill()),e.fillStyle=v.textGroupHeader??v.textHeader,_!==void 0){let t=r;if(_.icon!==void 0&&(s.drawSprite(_.icon,`normal`,e,t+8,(i-20)/2,20,v),t+=26),e.fillText(_.name,t+8,i/2+Yo(e,o.headerFontFull)),_.actions!==void 0&&y){let t=Dc({x:r,y:c,width:h,height:g},_.actions);e.beginPath();let n=t[0].x-10,o=r+h-n;e.rect(n,0,o,i);let l=e.createLinearGradient(n,0,n+o,0),u=mo(b,0);l.addColorStop(0,u),l.addColorStop(10/o,b),l.addColorStop(1,b),e.fillStyle=l,e.fill(),e.globalAlpha=.6;let[d,f]=a?.[1]??[-1,-1];for(let n=0;n<_.actions.length;n++){let i=_.actions[n],a=t[n],o=uc(a,d+r,f);o&&(e.globalAlpha=1),s.drawSprite(i.icon,`normal`,e,a.x+a.width/2-10,a.y+a.height/2-10,20,v),o&&(e.globalAlpha=.6)}e.globalAlpha=1}}r!==0&&l(t[0])&&(e.beginPath(),e.moveTo(r+.5,0),e.lineTo(r+.5,i),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()),e.restore(),m=r+h}),e.beginPath(),e.moveTo(m+.5,0),e.lineTo(m+.5,i),e.moveTo(0,i+.5),e.lineTo(n,i+.5),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()}var Tc=30;function Ec(e,t,n,r,i){return i?{x:e,y:t,width:Tc,height:Math.min(Tc,r)}:{x:e+n-Tc,y:Math.max(t,t+r/2-Tc/2),width:Tc,height:Math.min(Tc,r)}}function Dc(e,t){let n=[],r=e.x+e.width-26*t.length,i=e.y+e.height/2-13;for(let e=0;e35){let n=f?35:r-35,i=f?24.5:r-24.5,a=n/r,o=i/r,s=e.createLinearGradient(t,0,t+r,0),c=mo(h,0);s.addColorStop(+!!f,h),s.addColorStop(a,h),s.addColorStop(o,c),s.addColorStop(+!f,c),e.fillStyle=s}else e.fillStyle=h;if(f&&(e.textAlign=`right`),e.fillText(a.title,v,n+i/2+Yo(e,s.headerFontFull)),f&&(e.textAlign=`left`),g&&a.hasMenu===!0){if(a.menuIcon===void 0||a.menuIcon===ti.Triangle){e.beginPath();let t=p.x+p.width/2-5.5,n=p.y+p.height/2-3;cs(e,[{x:t,y:n},{x:t+11,y:n},{x:t+5.5,y:n+6}],1),e.fillStyle=h,e.fill()}else if(a.menuIcon===ti.Dots)e.beginPath(),ss(e,p.x+p.width/2,p.y+p.height/2),e.fillStyle=h,e.fill();else{let t=p.x+(p.width-s.headerIconSize)/2,n=p.y+(p.height-s.headerIconSize)/2;u.drawSprite(a.menuIcon,`normal`,e,t,n,s.headerIconSize,s)}}}function kc(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=aa(a.title)===`rtl`,h=Ec(t,n,r,i,m);f===void 0?Oc(e,t,n,r,i,a,o,s,c,u,d,p,m,h):f({ctx:e,theme:s,rect:{x:t,y:n,width:r,height:i},column:a,columnIndex:a.sourceIndex,isSelected:o,hoverAmount:u,isHovered:c,hasSelectedCell:l,spriteManager:d,menuBounds:h},()=>Oc(e,t,n,r,i,a,o,s,c,u,d,p,m,h))}var Ac=o(((e,t)=>{var n=hr();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),jc=o(((e,t)=>{var n=Ac();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),Mc=o(((e,t)=>{function n(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i{function n(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}t.exports=n})),Pc=o(((e,t)=>{t.exports=Nc()()})),Fc=o(((e,t)=>{function n(e,t){for(var n=-1,r=Array(e);++n{function n(){return!1}t.exports=n})),Lc=o(((e,t)=>{var n=er(),r=Ic(),i=typeof e==`object`&&e&&!e.nodeType&&e,a=i&&typeof t==`object`&&t&&!t.nodeType&&t,o=a&&a.exports===i?n.Buffer:void 0;t.exports=(o?o.isBuffer:void 0)||r})),Rc=o(((e,t)=>{var n=ir(),r=Xr(),i=ar(),a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,S=`[object Int8Array]`,C=`[object Int16Array]`,w=`[object Int32Array]`,T=`[object Uint8Array]`,E=`[object Uint8ClampedArray]`,D=`[object Uint16Array]`,O=`[object Uint32Array]`,k={};k[b]=k[x]=k[S]=k[C]=k[w]=k[T]=k[E]=k[D]=k[O]=!0,k[a]=k[o]=k[v]=k[s]=k[y]=k[c]=k[l]=k[u]=k[d]=k[f]=k[p]=k[m]=k[h]=k[g]=k[_]=!1;function A(e){return i(e)&&r(e.length)&&!!k[n(e)]}t.exports=A})),zc=o(((e,t)=>{function n(e){return function(t){return e(t)}}t.exports=n})),Bc=o(((e,t)=>{var n=$n(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r&&n.process;t.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})),Vc=o(((e,t)=>{var n=Rc(),r=zc(),i=Bc(),a=i&&i.isTypedArray;t.exports=a?r(a):n})),Hc=o(((e,t)=>{var n=Fc(),r=Jr(),i=Qn(),a=Lc(),o=Yr(),s=Vc(),c=Object.prototype.hasOwnProperty;function l(e,t){var l=i(e),u=!l&&r(e),d=!l&&!u&&a(e),f=!l&&!u&&!d&&s(e),p=l||u||d||f,m=p?n(e.length,String):[],h=m.length;for(var g in e)(t||c.call(e,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||o(g,h)))&&m.push(g);return m}t.exports=l})),Uc=o(((e,t)=>{var n=Object.prototype;function r(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||n)}t.exports=r})),Wc=o(((e,t)=>{function n(e,t){return function(n){return e(t(n))}}t.exports=n})),Gc=o(((e,t)=>{t.exports=Wc()(Object.keys,Object)})),Kc=o(((e,t)=>{var n=Uc(),r=Gc(),i=Object.prototype.hasOwnProperty;function a(e){if(!n(e))return r(e);var t=[];for(var a in Object(e))i.call(e,a)&&a!=`constructor`&&t.push(a);return t}t.exports=a})),qc=o(((e,t)=>{var n=Hc(),r=Kc(),i=Xs();function a(e){return i(e)?n(e):r(e)}t.exports=a})),Jc=o(((e,t)=>{var n=Pc(),r=qc();function i(e,t){return e&&n(e,t,r)}t.exports=i})),Yc=o(((e,t)=>{var n=Xs();function r(e,t){return function(r,i){if(r==null)return r;if(!n(r))return e(r,i);for(var a=r.length,o=t?a:-1,s=Object(r);(t?o--:++o{var n=Jc();t.exports=Yc()(n)})),Zc=o(((e,t)=>{var n=Xc();function r(e,t,r,i){return n(e,function(e,n,a){t(i,e,r(e),a)}),i}t.exports=r})),Qc=o(((e,t)=>{var n=Ar();function r(){this.__data__=new n,this.size=0}t.exports=r})),$c=o(((e,t)=>{function n(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}t.exports=n})),el=o(((e,t)=>{function n(e){return this.__data__.get(e)}t.exports=n})),tl=o(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),nl=o(((e,t)=>{var n=Ar(),r=jr(),i=zr(),a=200;function o(e,t){var o=this.__data__;if(o instanceof n){var s=o.__data__;if(!r||s.length{var n=Ar(),r=Qc(),i=$c(),a=el(),o=tl(),s=nl();function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c})),il=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n{var n=js(),r=il(),i=Rs(),a=1,o=2;function s(e,t,s,c,l,u){var d=s&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(e),h=u.get(t);if(m&&h)return m==t&&h==e;var g=-1,_=!0,v=s&o?new n:void 0;for(u.set(e,t),u.set(t,e);++g{t.exports=er().Uint8Array})),sl=o(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}t.exports=n})),cl=o(((e,t)=>{var n=tr(),r=ol(),i=wr(),a=al(),o=sl(),s=Vs(),c=1,l=2,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Map]`,m=`[object Number]`,h=`[object RegExp]`,g=`[object Set]`,_=`[object String]`,v=`[object Symbol]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=n?n.prototype:void 0,S=x?x.valueOf:void 0;function C(e,t,n,x,C,w,T){switch(n){case b:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case y:return!(e.byteLength!=t.byteLength||!w(new r(e),new r(t)));case u:case d:case m:return i(+e,+t);case f:return e.name==t.name&&e.message==t.message;case h:case _:return e==t+``;case p:var E=o;case g:var D=x&c;if(E||=s,e.size!=t.size&&!D)return!1;var O=T.get(e);if(O)return O==t;x|=l,T.set(e,t);var k=a(E(e),E(t),x,C,w,T);return T.delete(e),k;case v:if(S)return S.call(e)==S.call(t)}return!1}t.exports=C})),ll=o(((e,t)=>{var n=Gs(),r=Qn();function i(e,t,i){var a=t(e);return r(e)?a:n(a,i(e))}t.exports=i})),ul=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n{function n(){return[]}t.exports=n})),fl=o(((e,t)=>{var n=ul(),r=dl(),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;t.exports=a?function(e){return e==null?[]:(e=Object(e),n(a(e),function(t){return i.call(e,t)}))}:r})),pl=o(((e,t)=>{var n=ll(),r=fl(),i=qc();function a(e){return n(e,i,r)}t.exports=a})),ml=o(((e,t)=>{var n=pl(),r=1,i=Object.prototype.hasOwnProperty;function a(e,t,a,o,s,c){var l=a&r,u=n(e),d=u.length;if(d!=n(t).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in t:i.call(t,p)))return!1}var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=!0;c.set(e,t),c.set(t,e);for(var _=l;++f{t.exports=hr()(er(),`DataView`)})),gl=o(((e,t)=>{t.exports=hr()(er(),`Promise`)})),_l=o(((e,t)=>{t.exports=hr()(er(),`WeakMap`)})),vl=o(((e,t)=>{var n=hl(),r=jr(),i=gl(),a=zs(),o=_l(),s=ir(),c=fr(),l=`[object Map]`,u=`[object Object]`,d=`[object Promise]`,f=`[object Set]`,p=`[object WeakMap]`,m=`[object DataView]`,h=c(n),g=c(r),_=c(i),v=c(a),y=c(o),b=s;(n&&b(new n(new ArrayBuffer(1)))!=m||r&&b(new r)!=l||i&&b(i.resolve())!=d||a&&b(new a)!=f||o&&b(new o)!=p)&&(b=function(e){var t=s(e),n=t==u?e.constructor:void 0,r=n?c(n):``;if(r)switch(r){case h:return m;case g:return l;case _:return d;case v:return f;case y:return p}return t}),t.exports=b})),yl=o(((e,t)=>{var n=rl(),r=al(),i=cl(),a=ml(),o=vl(),s=Qn(),c=Lc(),l=Vc(),u=1,d=`[object Arguments]`,f=`[object Array]`,p=`[object Object]`,m=Object.prototype.hasOwnProperty;function h(e,t,h,g,_,v){var y=s(e),b=s(t),x=y?f:o(e),S=b?f:o(t);x=x==d?p:x,S=S==d?p:S;var C=x==p,w=S==p,T=x==S;if(T&&c(e)){if(!c(t))return!1;y=!0,C=!1}if(T&&!C)return v||=new n,y||l(e)?r(e,t,h,g,_,v):i(e,t,x,h,g,_,v);if(!(h&u)){var E=C&&m.call(e,`__wrapped__`),D=w&&m.call(t,`__wrapped__`);if(E||D){var O=E?e.value():e,k=D?t.value():t;return v||=new n,_(O,k,h,g,v)}}return T?(v||=new n,a(e,t,h,g,_,v)):!1}t.exports=h})),bl=o(((e,t)=>{var n=yl(),r=ar();function i(e,t,a,o,s){return e===t?!0:e==null||t==null||!r(e)&&!r(t)?e!==e&&t!==t:n(e,t,a,o,i,s)}t.exports=i})),xl=o(((e,t)=>{var n=rl(),r=bl(),i=1,a=2;function o(e,t,o,s){var c=o.length,l=c,u=!s;if(e==null)return!l;for(e=Object(e);c--;){var d=o[c];if(u&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++c{var n=cr();function r(e){return e===e&&!n(e)}t.exports=r})),Cl=o(((e,t)=>{var n=Sl(),r=qc();function i(e){for(var t=r(e),i=t.length;i--;){var a=t[i],o=e[a];t[i]=[a,o,n(o)]}return t}t.exports=i})),wl=o(((e,t)=>{function n(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}t.exports=n})),Tl=o(((e,t)=>{var n=xl(),r=Cl(),i=wl();function a(e){var t=r(e);return t.length==1&&t[0][2]?i(t[0][0],t[0][1]):function(r){return r===e||n(r,e,t)}}t.exports=a})),El=o(((e,t)=>{var n=Kr(),r=Zr();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i{var n=El();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),Ol=o(((e,t)=>{function n(e,t){return e!=null&&t in Object(e)}t.exports=n})),kl=o(((e,t)=>{var n=Ol(),r=Qr();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),Al=o(((e,t)=>{var n=bl(),r=Dl(),i=kl(),a=sr(),o=Sl(),s=wl(),c=Zr(),l=1,u=2;function d(e,t){return a(e)&&o(t)?s(c(e),t):function(a){var o=r(a,e);return o===void 0&&o===t?i(a,e):n(t,o,l|u)}}t.exports=d})),jl=o(((e,t)=>{function n(e){return e}t.exports=n})),Ml=o(((e,t)=>{function n(e){return function(t){return t?.[e]}}t.exports=n})),Nl=o(((e,t)=>{var n=El();function r(e){return function(t){return n(t,e)}}t.exports=r})),Pl=o(((e,t)=>{var n=Ml(),r=Nl(),i=sr(),a=Zr();function o(e){return i(e)?n(a(e)):r(e)}t.exports=o})),Fl=o(((e,t)=>{var n=Tl(),r=Al(),i=jl(),a=Qn(),o=Pl();function s(e){return typeof e==`function`?e:e==null?i:typeof e==`object`?a(e)?r(e[0],e[1]):n(e):o(e)}t.exports=s})),Il=o(((e,t)=>{var n=Mc(),r=Zc(),i=Fl(),a=Qn();function o(e,t){return function(o,s){var c=a(o)?n:r,l=t?t():{};return c(o,e,i(s,2),l)}}t.exports=o})),Ll=c(o(((e,t)=>{var n=jc(),r=Il(),i=Object.prototype.hasOwnProperty;t.exports=r(function(e,t,r){i.call(e,r)?e[r].push(t):n(e,r,[t])})}))(),1);function Rl(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){if(_!==void 0||t[t.length-1]!==n[t.length-1])return;let y=rc(g);ac(t,c,o,s,a,(n,o,s,c,_)=>{if(n!==t[t.length-1])return;o+=n.width;let b=Math.max(o,c);b>r||(e.save(),e.beginPath(),e.rect(b,a+1,1e4,i-a-1),e.clip(),ic(_,s,i,l,u,m,h,y,(t,n,r,i)=>{if(!i&&g.length>0&&!g.some(e=>lc(o,t,1e4,r,e.x,e.y,e.width,e.height)))return;let a=f.hasIndex(n),s=p.hasIndex(n);e.beginPath();let c=d?.(n),l=c===void 0?v:Ss(v,c);l.bgCell!==v.bgCell&&(e.fillStyle=l.bgCell,e.fillRect(o,t,1e4,r)),s&&(e.fillStyle=l.bgHeader,e.fillRect(o,t,1e4,r)),a&&(e.fillStyle=l.accentLight,e.fillRect(o,t,1e4,r))}),e.restore())})}function zl(e,t,n,r,i,a,o,s,c){let l=!1;for(let e of t)if(!e.sticky){l=o(e.sourceIndex);break}let u=c.horizontalBorderColor??c.borderColor,d=c.borderColor,f=l?Lo(t):0,p;if(f!==0&&(p=go(d,c.bgCell),e.beginPath(),e.moveTo(f+.5,0),e.lineTo(f+.5,r),e.strokeStyle=p,e.stroke()),i>0){let t=d===u&&p!==void 0?p:go(u,c.bgCell),o=Ro(a,i,s);e.beginPath(),e.moveTo(0,r-o+.5),e.lineTo(n,r-o+.5),e.strokeStyle=t,e.stroke()}}var Bl=(e,t,n)=>{let r=0,i=t,a=0,o=n;if(e!==void 0&&e.length>0){r=2**53-1,a=2**53-1,i=-(2**53-1),o=-(2**53-1);for(let t of e)r=Math.min(r,t.x-1),i=Math.max(i,t.x+t.width+1),a=Math.min(a,t.y-1),o=Math.max(o,t.y+t.height+1)}return{minX:r,maxX:i,minY:a,maxY:o}};function Vl(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=m.bgCell,{minX:g,maxX:_,minY:v,maxY:y}=Bl(s,a,o),b=[],x=o-Ro(p,f,l),S=c,C=n,w=0;for(;S+i=v&&e<=y-1){let n=u?.(C)?.bgCell;n!==void 0&&n!==h&&C>=p-f&&b.push({x:g,y:e,w:_-g,h:t,color:n})}S+=t,C0)for(let e=0;e=g&&i<=_&&d(e+1)&&b.push({x:i,y:w,w:n.width,h:E,color:a}),T+=n.width}if(b.length===0)return;let D;e.beginPath();for(let t=b.length-1;t>=0;t--){let n=b[t];D===void 0?D=n.color:n.color!==D&&(e.fillStyle=D,e.fill(),e.beginPath(),D=n.color),e.rect(n.x,n.y,n.w,n.h)}D!==void 0&&(e.fillStyle=D,e.fill()),e.beginPath()}function Hl(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=!1){if(c!==void 0){e.beginPath(),e.save(),e.rect(0,0,a,o);for(let t of c)e.rect(t.x+1,t.y+1,t.width-1,t.height-1);e.clip(`evenodd`)}let v=g.horizontalBorderColor??g.borderColor,y=g.borderColor,{minX:b,maxX:x,minY:S,maxY:C}=Bl(s,a,o),w=[];e.beginPath();let T=.5;for(let e=0;e=b&&i<=x&&p(e+1)&&w.push({x1:i,y1:Math.max(l,S),x2:i,y2:Math.min(o,C),color:y})}let E=o+.5;for(let e=h-m;e=S&&n<=C-1){let e=f?.(t);w.push({x1:b,y1:n,x2:x,y2:n,color:e?.horizontalBorderColor??e?.borderColor??v})}e+=d(t),t++}}let D=(0,Ll.default)(w,e=>e.color);for(let t of Object.keys(D)){e.strokeStyle=t;for(let n of D[t])e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke(),e.beginPath()}c!==void 0&&e.restore()}function Ul(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=[];e.imageSmoothingEnabled=!1;let b=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o),S=0;if(typeof _==`number`)S+=(x-b)*_;else for(let e=b;ei.cellYOffset&&(S=-S),S+=c-i.translateY;let C=Math.min(i.cellXOffset,a),w=Math.max(i.cellXOffset,a),T=0;for(let e=C;ei.cellXOffset&&(T=-T),T+=s-i.translateX;let E=Lo(g);if(T!==0&&S!==0)return{regions:[]};let D=l>0?Ro(f,l,_):0,O=u-E-Math.abs(T),k=d-p-D-Math.abs(S)-1;if(O>150&&k>150){let i={sx:0,sy:0,sw:u*m,sh:d*m,dx:0,dy:0,dw:u*m,dh:d*m};if(S>0?(i.sy=(p+1)*m,i.sh=k*m,i.dy=(S+p+1)*m,i.dh=k*m,y.push({x:0,y:p,width:u,height:S+1})):S<0&&(i.sy=(-S+p+1)*m,i.sh=k*m,i.dy=(p+1)*m,i.dh=k*m,y.push({x:0,y:d+S-D,width:u,height:-S+D})),T>0?(i.sx=E*m,i.sw=O*m,i.dx=(T+E)*m,i.dw=O*m,y.push({x:E-1,y:0,width:T+2,height:d})):T<0&&(i.sx=(E-T)*m,i.sw=O*m,i.dx=E*m,i.dw=O*m,y.push({x:u+T,y:0,width:-T,height:d})),e.setTransform(1,0,0,1,0,0),v){if(E>0&&T!==0&&S===0&&(r===void 0||n?.[1]!==!1)){let n=E*m,r=d*m;e.drawImage(t,0,0,n,r,0,0,n,r)}if(D>0&&T===0&&S!==0&&(r===void 0||n?.[0]!==!1)){let n=(d-D)*m,r=u*m,i=D*m;e.drawImage(t,0,n,r,i,0,n,r,i)}}e.drawImage(t,i.sx,i.sy,i.sw,i.sh,i.dx,i.dy,i.dw,i.dh),e.scale(m,m)}return e.imageSmoothingEnabled=!0,{regions:y}}function Wl(e,t,n,r,i,a,o,s,c,l){let u=[];return t!==e.cellXOffset||n!==e.cellYOffset||r!==e.translateX||i!==e.translateY||ac(c,n,r,i,s,(e,t,n,r)=>{if(e.sourceIndex===l){let e=Math.max(t,r)+1;return u.push({x:e,y:0,width:a-e,height:o}),!0}}),u}function Gl(e,t){if(t===void 0||e.width!==t.width||e.height!==t.height||e.theme!==t.theme||e.headerHeight!==t.headerHeight||e.rowHeight!==t.rowHeight||e.rows!==t.rows||e.freezeColumns!==t.freezeColumns||e.getRowThemeOverride!==t.getRowThemeOverride||e.isFocused!==t.isFocused||e.isResizing!==t.isResizing||e.verticalBorder!==t.verticalBorder||e.getCellContent!==t.getCellContent||e.highlightRegions!==t.highlightRegions||e.selection!==t.selection||e.dragAndDropState!==t.dragAndDropState||e.prelightCells!==t.prelightCells||e.touchMode!==t.touchMode||e.maxScaleFactor!==t.maxScaleFactor)return!1;if(e.mappedColumns!==t.mappedColumns){if(e.mappedColumns.length>100||e.mappedColumns.length!==t.mappedColumns.length)return!1;let n;for(let r=0;re.style!==`no-outline`);if(g===void 0||g.length===0)return;let _=Lo(s),v=Ro(p,f,d),y=[c,0,s.length,p-f],b=[_,0,t,n-v],x=g.map(e=>{let m=e.range,h=e.style??`dashed`;return mc(m,y,t,n,b).map(m=>{let g=m.rect,_=ls(g.x,g.y,t,n,u,l+u,r,i,a,o,p,c,f,s,d),v=g.width===1&&g.height===1?_:ls(g.x+g.width-1,g.y+g.height-1,t,n,u,l+u,r,i,a,o,p,c,f,s,d);return g.x+g.width>=s.length&&--v.width,g.y+g.height>=p&&--v.height,{color:e.color,style:h,clip:m.clip,rect:pc({x:_.x,y:_.y,width:v.x+v.width-_.x,height:v.y+v.height-_.y},t,n,8)}})}),S=()=>{e.lineWidth=1;let r=!1;for(let i of x)for(let a of i)if(a?.rect!==void 0&&lc(0,0,t,n,a.rect.x,a.rect.y,a.rect.width,a.rect.height)){let t=r,n=!fc(a.clip,a.rect);n&&(e.save(),e.rect(a.clip.x,a.clip.y,a.clip.width,a.clip.height),e.clip()),a.style===`dashed`&&!r?(e.setLineDash([5,3]),r=!0):(a.style===`solid`||a.style===`solid-outline`)&&r&&(e.setLineDash([]),r=!1),e.strokeStyle=a.style===`solid-outline`?_o(_o(a.color,h.borderColor),h.bgCell):mo(a.color,1),e.strokeRect(a.rect.x+.5,a.rect.y+.5,a.rect.width-1,a.rect.height-1),n&&(e.restore(),r=t)}r&&e.setLineDash([])};return S(),S}function ql(e,t,n,r,i){e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.lineWidth=2,e.strokeStyle=i,e.stroke(),e.globalAlpha=1}function Jl(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(u.current===void 0)return;let _=u.current.range,v=u.current.cell,y=[_.x+_.width-1,_.y+_.height-1];if(v[1]>=g&&y[1]>=g||!o.some(e=>e.sourceIndex===v[0]||e.sourceIndex===y[0]))return;let[b,x]=u.current.cell,S=f(u.current.cell),C=S.span??[b,b],w=x>=g-p,T=p>0&&!w?Ro(g,p,d)-1:0,E=y[1],D;if(ac(o,r,i,a,l,(r,i,a,o,l)=>{if(r.sticky&&b>r.sourceIndex)return;let u=r.sourceIndexC[1],_=r.sourceIndex===y[0];if(_||!u&&!f)return ic(l,a,n,g,d,p,m,void 0,(a,l,u)=>{if(l!==x&&l!==E)return;let d=i,f=r.width;if(S.span!==void 0){let e=sc(S.span,i,a,r.width,u,r,s),t=r.sticky?e[0]:e[1];t!==void 0&&(d=t.x,f=t.width)}return l===E&&_&&h&&(D=()=>{o>d&&!r.sticky&&(e.beginPath(),e.rect(o,0,t-o,n),e.clip()),e.beginPath(),e.rect(d+f-4,a+u-4,4,4),e.fillStyle=r.themeOverride?.accentColor??c.accentColor,e.fill()}),D!==void 0}),D!==void 0}),D===void 0)return;let O=()=>{e.save(),e.beginPath(),e.rect(0,l,t,n-l-T),e.clip(),D?.(),e.restore()};return O(),O}function Yl(e,t,n,r,i,a,o,s,c){c!==void 0&&c.size!==0&&(e.beginPath(),oc(t,n,a,r,(t,n,r,i,a,o)=>{c.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1})&&e.rect(r,i,a,o)}),ac(t,s,a,o,i,(t,n,a,o)=>{let s=Math.max(0,o-n),l=n+s+1,u=t.width-s-1;c.has([t.sourceIndex,-1])&&e.rect(l,r,u,i-r)}),e.clip())}function Xl(e,t,n,r,i,a,o,s,c,l){let u=0;return ac(e,a,r,i,n,(e,n,r,i,a)=>(ic(a,r,t,o,s,c,l,void 0,(e,t,n,r)=>{r||(u=Math.max(t,u))}),!0)),u}function Zl(e,t){let{canvasCtx:n,headerCanvasCtx:r,width:i,height:a,cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mappedColumns:u,enableGroups:d,freezeColumns:f,dragAndDropState:p,theme:m,drawFocus:h,headerHeight:g,groupHeaderHeight:_,disabledRows:v,rowHeight:y,verticalBorder:b,overrideCursor:x,isResizing:S,selection:C,fillHandle:w,freezeTrailingRows:T,rows:E,getCellContent:D,getGroupDetails:O,getRowThemeOverride:k,isFocused:A,drawHeaderCallback:ee,prelightCells:te,drawCellCallback:ne,highlightRegions:re,resizeCol:j,imageLoader:M,lastBlitData:ie,hoverValues:ae,hyperWrapping:N,hoverInfo:oe,spriteManager:P,maxScaleFactor:F,hasAppendRow:se,touchMode:I,enqueue:ce,renderStateProvider:le,getCellRenderer:ue,renderStrategy:de,bufferACtx:fe,bufferBCtx:pe,damage:me,minimumCellWidth:L}=e;if(i===0||a===0)return;let he=de===`double-buffer`,R=Math.min(F,Math.ceil(window.devicePixelRatio??1)),ge=de!==`direct`&&Gl(e,t),z=n.canvas;(z.width!==i*R||z.height!==a*R)&&(z.width=i*R,z.height=a*R,z.style.width=i+`px`,z.style.height=a+`px`);let _e=r.canvas,ve=d?_+g:g,ye=ve+1;(_e.width!==i*R||_e.height!==ye*R)&&(_e.width=i*R,_e.height=ye*R,_e.style.width=i+`px`,_e.style.height=ye+`px`);let be=fe.canvas,xe=pe.canvas;he&&(be.width!==i*R||be.height!==a*R)&&(be.width=i*R,be.height=a*R,ie.current!==void 0&&(ie.current.aBufferScroll=void 0)),he&&(xe.width!==i*R||xe.height!==a*R)&&(xe.width=i*R,xe.height=a*R,ie.current!==void 0&&(ie.current.bBufferScroll=void 0));let Se=ie.current;if(ge===!0&&o===Se?.cellXOffset&&s===Se?.cellYOffset&&c===Se?.translateX&&l===Se?.translateY)return;let Ce=null;he&&(Ce=n);let we=r,B;B=he?me===void 0?Se?.lastBuffer===`b`?fe:pe:Se?.lastBuffer===`b`?pe:fe:n;let Te=B.canvas,Ee=he?Te===be?xe:be:z,De=typeof y==`number`?()=>y:y;we.save(),B.save(),we.beginPath(),B.beginPath(),we.textBaseline=`middle`,B.textBaseline=`middle`,R!==1&&(we.scale(R,R),B.scale(R,R));let Oe=zo(u,o,i,p,c),ke=[],Ae=h&&C.current?.cell[1]===s&&l===0,je=!1;if(re!==void 0){for(let e of re)if(e.style!==`no-outline`&&e.range.y===s&&l===0){je=!0;break}}let Me=()=>{Cc(we,Oe,d,oe,i,c,g,_,p,S,C,m,P,ae,b,O,me,ee,I),Hl(we,Oe,s,c,l,i,a,void 0,void 0,_,ve,De,k,b,T,E,m,!0),we.beginPath(),we.moveTo(0,ye-.5),we.lineTo(i,ye-.5),we.strokeStyle=_o(m.headerBottomBorderColor??m.horizontalBorderColor??m.borderColor,m.bgHeader),we.stroke(),je&&Kl(we,i,a,o,s,c,l,u,f,g,_,y,T,E,re,m),Ae&&Jl(we,i,a,s,c,l,Oe,u,m,ve,C,De,D,T,se,w,E)};if(me!==void 0){let e=Oe[Oe.length-1].sourceIndex+1,t=me.hasItemInRegion([{x:o,y:-2,width:e,height:2},{x:o,y:s,width:e,height:300},{x:0,y:s,width:f,height:300},{x:0,y:-2,width:f,height:2},{x:o,y:E-T,width:e,height:T,when:T>0}]),n=e=>{hc(e,Oe,u,a,ve,c,l,s,E,De,D,O,k,v,A,h,T,se,ke,me,C,te,re,M,P,ae,oe,ne,N,m,ce,le,ue,x,L);let t=C.current;w&&h&&t!==void 0&&me.has(No(t.range))&&Jl(e,i,a,s,c,l,Oe,u,m,ve,C,De,D,T,se,w,E)};t&&(n(B),Ce!==null&&(Ce.save(),Ce.scale(R,R),Ce.textBaseline=`middle`,n(Ce),Ce.restore()),me.hasHeader()&&(Yl(we,Oe,i,_,ve,c,l,s,me),Me())),B.restore(),we.restore();return}if((ge!==!0||o!==Se?.cellXOffset||c!==Se?.translateX||Ae!==Se?.mustDrawFocusOnHeader||je!==Se?.mustDrawHighlightRingsOnHeader)&&Me(),ge===!0){Kn(Ee!==void 0&&Se!==void 0);let{regions:e}=Ul(B,Ee,Ee===be?Se.aBufferScroll:Se.bBufferScroll,Ee===be?Se.bBufferScroll:Se.aBufferScroll,Se,o,s,c,l,T,i,a,E,ve,R,u,Oe,y,he);ke=e}else ge!==!1&&(Kn(Se!==void 0),ke=Wl(Se,o,s,c,l,i,a,ve,Oe,ge));zl(B,Oe,i,a,T,E,b,De,m);let Ne=Kl(B,i,a,o,s,c,l,u,f,g,_,y,T,E,re,m),Pe=h?Jl(B,i,a,s,c,l,Oe,u,m,ve,C,De,D,T,se,w,E):void 0;if(B.fillStyle=m.bgCell,ke.length>0){B.beginPath();for(let e of ke)B.rect(e.x,e.y,e.width,e.height);B.clip(),B.fill(),B.beginPath()}else B.fillRect(0,0,i,a);let Fe=hc(B,Oe,u,a,ve,c,l,s,E,De,D,O,k,v,A,h,T,se,ke,me,C,te,re,M,P,ae,oe,ne,N,m,ce,le,ue,x,L);Rl(B,Oe,u,i,a,ve,c,l,s,E,De,k,C.rows,v,T,se,ke,me,m),Vl(B,Oe,s,c,l,i,a,ke,ve,De,k,b,T,E,m),Hl(B,Oe,s,c,l,i,a,ke,Fe,_,ve,De,k,b,T,E,m),Ne?.(),Pe?.(),S&&ac(Oe,0,c,0,ve,(e,t)=>e.sourceIndex===j&&(ql(we,t+e.width,0,ve+1,_o(m.resizeIndicatorColor??m.accentLight,m.bgHeader)),ql(B,t+e.width,ve,a,_o(m.resizeIndicatorColor??m.accentLight,m.bgCell)),!0)),Ce!==null&&(Ce.fillStyle=m.bgCell,Ce.fillRect(0,0,i,a),Ce.drawImage(B.canvas,0,0));let Ie=Xl(Oe,a,ve,c,l,s,E,De,T,se);M?.setWindow({x:o,y:s,width:Oe.length,height:Ie-s},f,Array.from({length:T},(e,t)=>E-1-t));let Le=Se!==void 0&&(o!==Se.cellXOffset||c!==Se.translateX),Re=Se!==void 0&&(s!==Se.cellYOffset||l!==Se.translateY);ie.current={cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mustDrawFocusOnHeader:Ae,mustDrawHighlightRingsOnHeader:je,lastBuffer:he?Te===be?`a`:`b`:void 0,aBufferScroll:Te===be?[Le,Re]:Se?.aBufferScroll,bBufferScroll:Te===xe?[Le,Re]:Se?.bBufferScroll},B.restore(),we.restore()}var Ql=c(Os(),1),$l=80;function eu(e){let t=e-1;return t*t*t+1}var tu=class{callback;constructor(e){this.callback=e}currentHoveredItem=void 0;leavingItems=[];lastAnimationTime;addToLeavingItems=e=>{this.leavingItems.some(t=>Mo(t.item,e.item))||this.leavingItems.push(e)};removeFromLeavingItems=e=>{let t=this.leavingItems.find(t=>Mo(t.item,e));return this.leavingItems=this.leavingItems.filter(e=>e!==t),t?.hoverAmount??0};cleanUpLeavingElements=()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)};shouldStep=()=>{let e=this.leavingItems.length>0,t=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||t};getAnimatingItems=()=>this.currentHoveredItem===void 0?this.leavingItems.map(e=>({...e,hoverAmount:eu(e.hoverAmount)})):[...this.leavingItems,this.currentHoveredItem];step=e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{let t=(e-this.lastAnimationTime)/$l;for(let e of this.leavingItems)e.hoverAmount=(0,Ql.default)(e.hoverAmount-t,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=(0,Ql.default)(this.currentHoveredItem.hoverAmount+t,0,1));let n=this.getAnimatingItems();this.callback(n),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0};setHovered=e=>{if(!Mo(this.currentHoveredItem?.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){let t=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:t}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}}},nu=class{fn;val;constructor(e){this.fn=e}get value(){return this.val??=this.fn()}};function ru(e){return new nu(e)}var iu=ru(()=>window.navigator.userAgent.includes(`Firefox`)),au=ru(()=>window.navigator.userAgent.includes(`Mac OS`)&&window.navigator.userAgent.includes(`Safari`)&&!window.navigator.userAgent.includes(`Chrome`)),ou=ru(()=>window.navigator.platform.toLowerCase().startsWith(`mac`));function su(e){let t=g.useRef([]),n=g.useRef(0),r=g.useRef(e);r.current=e;let i=g.useCallback(()=>{let e=()=>window.requestAnimationFrame(i),i=()=>{let e=t.current.map(ms);t.current=[],r.current(new _s(e)),t.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?e:i)},[]);return g.useCallback(e=>{t.current.length===0&&i();let n=ds(e[0],e[1]);t.current.includes(n)||t.current.push(n)},[i])}var cu=`header`,lu=`group-header`,uu=`out-of-bounds`,du;(function(e){e[e.Start=-2]=`Start`,e[e.StartPadding=-1]=`StartPadding`,e[e.Center=0]=`Center`,e[e.EndPadding=1]=`EndPadding`,e[e.End=2]=`End`})(du||={});function fu(e,t){return e===t?!0:e?.kind===`out-of-bounds`?e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]&&e?.region[0]===t?.region[0]&&e?.region[1]===t?.region[1]:e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]}var pu=c(ec(),1),mu=6,hu=(e,t)=>e.kind===K.Custom?e.copyData:(t?.(e))?.getAccessibilityString(e)??``,gu=g.memo(g.forwardRef((e,t)=>{let{width:n,height:r,accessibilityHeight:i,columns:a,cellXOffset:o,cellYOffset:s,headerHeight:c,fillHandle:l=!1,groupHeaderHeight:u,rowHeight:d,rows:f,getCellContent:p,getRowThemeOverride:m,onHeaderMenuClick:h,enableGroups:_,isFilling:v,onCanvasFocused:y,onCanvasBlur:b,isFocused:x,selection:S,freezeColumns:C,onContextMenu:w,freezeTrailingRows:T,fixedShadowX:E=!0,fixedShadowY:D=!0,drawFocusRing:O,onMouseDown:k,onMouseUp:A,onMouseMoveRaw:ee,onMouseMove:te,onItemHovered:ne,dragAndDropState:re,firstColAccessible:j,onKeyDown:M,onKeyUp:ie,highlightRegions:ae,canvasRef:N,onDragStart:oe,onDragEnd:P,eventTargetRef:F,isResizing:se,resizeColumn:I,isDragging:ce,isDraggable:le=!1,allowResize:ue,disabledRows:de,hasAppendRow:fe,getGroupDetails:pe,theme:me,prelightCells:L,headerIcons:he,verticalBorder:R,drawCell:ge,drawHeader:z,onCellFocused:_e,onDragOverCell:ve,onDrop:ye,onDragLeave:be,imageWindowLoader:xe,smoothScrollX:Se=!1,smoothScrollY:Ce=!1,experimental:we,getCellRenderer:B}=e,Te=e.translateX??0,Ee=e.translateY??0,De=Math.max(C,Math.min(a.length-1,o)),Oe=g.useRef(null),ke=xe,Ae=g.useRef(),[je,Me]=g.useState(!1),Ne=g.useRef([]),Pe=g.useRef(),[Fe,Ie]=g.useState(),[Le,Re]=g.useState(),ze=g.useRef(null),[Be,Ve]=g.useState(),[He,Ue]=g.useState(!1),We=g.useRef(He);We.current=He;let Ge=g.useMemo(()=>new nc(he,()=>{ct.current=void 0,ft.current()}),[he]),Ke=_?u+c:c,qe=g.useRef(-1),Je=(we?.enableFirefoxRescaling??!1)&&iu.value,Ye=(we?.enableSafariRescaling??!1)&&au.value;g.useLayoutEffect(()=>{window.devicePixelRatio!==1&&(Je||Ye)&&(qe.current!==-1&&Me(!0),window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{Me(!1),qe.current=-1},200))},[s,De,Te,Ee,Je,Ye]);let Xe=Do(a,C),Ze=E?Lo(Xe,re):0,Qe=g.useCallback((e,t,i)=>{let a=e.getBoundingClientRect();if(t>=Xe.length||i>=f)return;let o=a.width/n,c=ls(t,i,n,r,u,Ke,De,s,Te,Ee,f,C,T,Xe,d);return o!==1&&(c.x*=o,c.y*=o,c.width*=o,c.height*=o),c.x+=a.x,c.y+=a.y,c},[n,r,u,Ke,De,s,Te,Ee,f,C,T,Xe,d]),$e=g.useCallback((e,t,i,a)=>{let o=e.getBoundingClientRect(),p=o.width/n,m=(t-o.left)/p,h=(i-o.top)/p,g=zo(Xe,De,n,void 0,Te),v=0,y=0;a instanceof MouseEvent&&(v=a.button,y=a.buttons);let b=Bo(m,g,Te),x=Vo(h,r,_,c,u,f,d,s,Ee,T),C=a?.shiftKey===!0,w=a?.ctrlKey===!0,E=a?.metaKey===!0,D=a!==void 0&&!(a instanceof MouseEvent)||a?.pointerType===`touch`,O=[m<0?-1:+(nn||h>r){let i=m>n?1:m<0?-1:0,a=h>r?1:h<0?-1:0,o=i*2,s=a*2;i===0&&(o=b===-1?du.EndPadding:du.Center),a===0&&(s=x===void 0?du.EndPadding:du.Center);let c=!1;if(b===-1&&x===-1){let n=Qe(e,Xe.length-1,-1);Kn(n!==void 0),c=tn&&mr&&h=0?(r=!0,n=Qe(e,a,x),Kn(n!==void 0),k={kind:_&&x===-2?lu:cu,location:[a,x],bounds:n,group:Xe[a].group??``,isEdge:r,shiftKey:C,ctrlKey:w,metaKey:E,isTouch:D,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:O}):k={kind:_&&x===-2?lu:cu,group:Xe[b].group??``,location:[b,x],bounds:n,isEdge:r,shiftKey:C,ctrlKey:w,metaKey:E,isTouch:D,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:O}}else{let n=Qe(e,b,x);Kn(n!==void 0);let r=n!==void 0&&n.x+n.width-t<5,a=!1;if(l&&S.current!==void 0){let n=No(S.current.range),r=Qe(e,n[0],n[1]);if(r!==void 0){let e=r.x+r.width-2,n=r.y+r.height-2;a=Math.abs(e-t){}),nt=g.useRef(Fe);nt.current=Fe;let[rt,it]=g.useMemo(()=>{let e=document.createElement(`canvas`),t=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,t.style.display=`none`,t.style.opacity=`0`,t.style.position=`fixed`,[e.getContext(`2d`,{alpha:!1}),t.getContext(`2d`,{alpha:!1})]},[]);g.useLayoutEffect(()=>{if(rt!==null&&it!==null)return document.documentElement.append(rt.canvas),document.documentElement.append(it.canvas),()=>{rt.canvas.remove(),it.canvas.remove()}},[rt,it]);let at=g.useMemo(()=>new gs,[]),ot=Je&&je?1:Ye&&je?2:5,st=we?.disableMinimumCellWidth===!0?1:10,ct=g.useRef(),lt=g.useRef(null),ut=g.useRef(null),dt=g.useCallback(()=>{let e=Oe.current,t=ze.current;if(e===null||t===null||(lt.current===null&&(lt.current=e.getContext(`2d`,{alpha:!1}),e.width=0,e.height=0),ut.current===null&&(ut.current=t.getContext(`2d`,{alpha:!1}),t.width=0,t.height=0),lt.current===null||ut.current===null||rt===null||it===null))return;let i=!1,a=e=>{i=!0,Ve(e)},o=ct.current,h={headerCanvasCtx:ut.current,canvasCtx:lt.current,bufferACtx:rt,bufferBCtx:it,width:n,height:r,cellXOffset:De,cellYOffset:s,translateX:Math.round(Te),translateY:Math.round(Ee),mappedColumns:Xe,enableGroups:_,freezeColumns:C,dragAndDropState:re,theme:me,headerHeight:c,groupHeaderHeight:u,disabledRows:de??fi.empty(),rowHeight:d,verticalBorder:R,isResizing:se,resizeCol:I,isFocused:x,selection:S,fillHandle:l,drawCellCallback:ge,hasAppendRow:fe,overrideCursor:a,maxScaleFactor:ot,freezeTrailingRows:T,rows:f,drawFocus:O,getCellContent:p,getGroupDetails:pe??(e=>({name:e})),getRowThemeOverride:m,drawHeaderCallback:z,prelightCells:L,highlightRegions:ae,imageLoader:ke,lastBlitData:Pe,damage:Ae.current,hoverValues:Ne.current,hoverInfo:nt.current,spriteManager:Ge,scrolling:je,hyperWrapping:we?.hyperWrapping??!1,touchMode:He,enqueue:tt.current,renderStateProvider:at,renderStrategy:we?.renderStrategy??(au.value?`double-buffer`:`single-buffer`),getCellRenderer:B,minimumCellWidth:st};h.damage===void 0?(ct.current=h,Zl(h,o)):Zl(h,void 0),!i&&(h.damage===void 0||h.damage.has(nt?.current?.[0]))&&Ve(void 0)},[rt,it,n,r,De,s,Te,Ee,Xe,_,C,re,me,c,u,de,d,R,se,fe,I,x,S,l,T,f,O,ot,p,pe,m,ge,z,L,ae,ke,Ge,je,we?.hyperWrapping,we?.renderStrategy,He,at,B,st]),ft=g.useRef(dt);g.useLayoutEffect(()=>{dt(),ft.current=dt},[dt]),g.useLayoutEffect(()=>{(async()=>{document?.fonts?.ready!==void 0&&(await document.fonts.ready,ct.current=void 0,ft.current())})()},[]);let pt=g.useCallback(e=>{Ae.current=e,ft.current(),Ae.current=void 0},[]);tt.current=su(pt);let mt=g.useCallback(e=>{pt(new _s(e.map(e=>e.cell)))},[pt]);ke.setCallback(pt);let[ht,gt]=g.useState(!1),[_t,vt]=et??[],yt=_t!==void 0&&vt===-1,bt=_t!==void 0&&vt===-2,xt=!1,St=!1,Ct=Be;if(Ct===void 0&&_t!==void 0&&vt!==void 0&&vt>-1&&vt({contain:`strict`,display:`block`,cursor:wt}),[wt]),Et=g.useRef(`default`),Dt=F?.current;Dt!=null&&Et.current!==Tt.cursor&&(Dt.style.cursor=Et.current=Tt.cursor);let Ot=g.useCallback((e,t,n,r)=>{if(pe===void 0)return;let i=pe(e);if(i.actions!==void 0){let e=Dc(t,i.actions);for(let[a,o]of e.entries())if(uc(o,n+t.x,r+o.y))return i.actions[a]}},[pe]),kt=g.useCallback((e,t,n,r)=>{let i=a[t];if(!ce&&!se&&i.hasMenu===!0&&!(Le??!1)){let a=Qe(e,t,-1);Kn(a!==void 0);let o=Ec(a.x,a.y,a.width,a.height,aa(i.title)===`rtl`);if(n>o.x&&no.y&&r{let t=Oe.current,n=F?.current;if(t===null||e.target!==t&&e.target!==n)return;Mt.current=!0;let r,i;if(e instanceof MouseEvent?(r=e.clientX,i=e.clientY):(r=e.touches[0].clientX,i=e.touches[0].clientY),e.target===n&&n!==null){let e=n.getBoundingClientRect();if(r>e.right||i>e.bottom)return}let a=$e(t,r,i,e);jt.current=a.location,a.isTouch&&(At.current=Date.now()),We.current!==a.isTouch&&Ue(a.isTouch),a.kind===`header`&&kt(t,a.location[0],r,i)!==void 0||a.kind===`group-header`&&Ot(a.group,a.bounds,a.localEventX,a.localEventY)!==void 0||(k?.(a),!a.isTouch&&le!==!0&&le!==a.kind&&a.button<3&&a.button!==1&&e.preventDefault())},[F,le,$e,Ot,kt,k]);qi(`touchstart`,Nt,window,!1),qi(`mousedown`,Nt,window,!1);let Pt=g.useRef(0),Ft=g.useCallback(e=>{let t=Pt.current;Pt.current=Date.now();let n=Oe.current;if(Mt.current=!1,A===void 0||n===null)return;let r=F?.current,i=e.target!==n&&e.target!==r,a,o,s=!0;if(e instanceof MouseEvent){if(a=e.clientX,o=e.clientY,s=e.button<3,e.pointerType===`touch`)return}else a=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY;let c=$e(n,a,o,e);c.isTouch&&At.current!==0&&Date.now()-At.current>500&&(c={...c,isLongTouch:!0}),t!==0&&Date.now()-t<(c.isTouch?1e3:500)&&(c={...c,isDoubleClick:!0}),We.current!==c.isTouch&&Ue(c.isTouch),!i&&e.cancelable&&s&&e.preventDefault();let[l]=c.location,u=kt(n,l,a,o);if(c.kind===`header`&&u!==void 0)(c.button!==0||jt.current?.[0]!==l||jt.current?.[1]!==-1)&&A(c,!0);else{if(c.kind===`group-header`){let e=Ot(c.group,c.bounds,c.localEventX,c.localEventY);if(e!==void 0){c.button===0&&e.onClick(c);return}}A(c,i)}},[A,F,$e,kt,Ot]);qi(`mouseup`,Ft,window,!1),qi(`touchend`,Ft,window,!1),qi(`click`,g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n=F?.current,r=e.target!==t&&e.target!==n,i,a,o=!0;e instanceof MouseEvent?(i=e.clientX,a=e.clientY,o=e.button<3):(i=e.changedTouches[0].clientX,a=e.changedTouches[0].clientY);let s=$e(t,i,a,e);We.current!==s.isTouch&&Ue(s.isTouch),!r&&e.cancelable&&o&&e.preventDefault();let[c]=s.location,l=kt(t,c,i,a);if(s.kind===`header`&&l!==void 0)s.button===0&&jt.current?.[0]===c&&jt.current?.[1]===-1&&h?.(c,l);else if(s.kind===`group-header`){let e=Ot(s.group,s.bounds,s.localEventX,s.localEventY);e!==void 0&&s.button===0&&e.onClick(s)}},[F,$e,kt,h,Ot]),window,!1),qi(`contextmenu`,g.useCallback(e=>{let t=Oe.current,n=F?.current;if(t===null||e.target!==t&&e.target!==n||w===void 0)return;let r=$e(t,e.clientX,e.clientY,e);w(r,()=>{e.cancelable&&e.preventDefault()})},[F,$e,w]),F?.current??null,!1);let It=g.useCallback(e=>{Ae.current=new _s(e.map(e=>e.item)),Ne.current=e,ft.current(),Ae.current=void 0},[]),Lt=g.useMemo(()=>new tu(It),[It]),Rt=g.useRef(Lt);Rt.current=Lt,g.useLayoutEffect(()=>{let e=Rt.current;if(et===void 0||et[1]<0){e.setHovered(et);return}let t=p(et,!0),n=B(t),r=n===void 0&&t.kind===K.Custom||n?.needsHover!==void 0&&(typeof n.needsHover==`boolean`?n.needsHover:n.needsHover(t));e.setHovered(r?et:void 0)},[p,B,et]);let zt=g.useRef();qi(`mousemove`,g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n=F?.current,r=e.target!==t&&e.target!==n,i=$e(t,e.clientX,e.clientY,e);if(i.kind!==`out-of-bounds`&&r&&!Mt.current&&!i.isTouch)return;let a=(e,t)=>{Ie(n=>n===e||n?.[0][0]===e?.[0][0]&&n?.[0][1]===e?.[0][1]&&(n?.[1][0]===e?.[1][0]&&n?.[1][1]===e?.[1][1]||!t)?n:e)};if(!fu(i,zt.current))Ve(void 0),ne?.(i),a(i.kind===`out-of-bounds`?void 0:[i.location,[i.localEventX,i.localEventY]],!0),zt.current=i;else if(i.kind===`cell`||i.kind===`header`||i.kind===`group-header`){let e=!1,t=!0;if(i.kind===`cell`){let n=p(i.location);t=B(n)?.needsHoverPosition??n.kind===K.Custom,e=t}else i.kind===`group-header`&&(e=!0);let n=[i.location,[i.localEventX,i.localEventY]];a(n,t),nt.current=n,e&&pt(new _s([i.location]))}let o=i.location[0]>=+!j;Re(i.kind===`header`&&i.isEdge&&o&&ue===!0),gt(i.kind===`cell`&&i.isFillHandle),ee?.(e),te(i)},[F,$e,j,ue,ee,te,ne,p,B,pt]),window,!0);let Bt=g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n,r;S.current!==void 0&&(n=Qe(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),M?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[M,S,Qe]),Vt=g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n,r;S.current!==void 0&&(n=Qe(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),ie?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[ie,S,Qe]),Ht=g.useCallback(e=>{Oe.current=e,N!==void 0&&(N.current=e)},[N]);qi(`dragstart`,g.useCallback(e=>{let t=Oe.current;if(t===null||le===!1||se){e.preventDefault();return}let n,r,i=$e(t,e.clientX,e.clientY);if(le!==!0&&i.kind!==le){e.preventDefault();return}let a=(e,t)=>{n=e,r=t},o,s,c,l=(e,t,n)=>{o=e,s=t,c=n},u=!1;if(oe?.({...i,setData:a,setDragImage:l,preventDefault:()=>u=!0,defaultPrevented:()=>u}),!u&&n!==void 0&&r!==void 0&&e.dataTransfer!==null){if(e.dataTransfer.setData(n,r),e.dataTransfer.effectAllowed=`copyLink`,o!==void 0&&s!==void 0&&c!==void 0)e.dataTransfer.setDragImage(o,s,c);else{let[n,r]=i.location;if(r!==void 0){let i=document.createElement(`canvas`),a=Qe(t,n,r);Kn(a!==void 0);let o=Math.ceil(window.devicePixelRatio??1);i.width=a.width*o,i.height=a.height*o;let s=i.getContext(`2d`);s!==null&&(s.scale(o,o),s.textBaseline=`middle`,r===-1?(s.font=me.headerFontFull,s.fillStyle=me.bgHeader,s.fillRect(0,0,i.width,i.height),kc(s,0,0,a.width,a.height,Xe[n],!1,me,!1,!1,0,Ge,z,!1)):(s.font=me.baseFontFull,s.fillStyle=me.bgCell,s.fillRect(0,0,i.width,i.height),xc(s,p([n,r]),0,r,!1,!1,0,0,a.width,a.height,!1,me,me.bgCell,ke,Ge,1,void 0,!1,0,void 0,void 0,void 0,at,B,()=>void 0))),i.style.left=`-100%`,i.style.position=`absolute`,i.style.width=`${a.width}px`,i.style.height=`${a.height}px`,document.body.append(i),e.dataTransfer.setDragImage(i,a.width/2,a.height/2),window.setTimeout(()=>{i.remove()},0)}}}else e.preventDefault()},[le,se,$e,oe,Qe,me,Xe,Ge,z,p,ke,at,B]),F?.current??null,!1,!1);let V=g.useRef();qi(`dragover`,g.useCallback(e=>{let t=Oe.current;if(ye!==void 0&&e.preventDefault(),t===null||ve===void 0)return;let[n,r]=$e(t,e.clientX,e.clientY).location,i=n-+!j,[a,o]=V.current??[];(a!==i||o!==r)&&(V.current=[i,r],ve([i,r],e.dataTransfer))},[j,$e,ve,ye]),F?.current??null,!1,!1),qi(`dragend`,g.useCallback(()=>{V.current=void 0,P?.()},[P]),F?.current??null,!1,!1),qi(`drop`,g.useCallback(e=>{let t=Oe.current;if(t===null||ye===void 0)return;e.preventDefault();let[n,r]=$e(t,e.clientX,e.clientY).location,i=n-+!j;ye([i,r],e.dataTransfer)},[j,$e,ye]),F?.current??null,!1,!1),qi(`dragleave`,g.useCallback(()=>{be?.()},[be]),F?.current??null,!1,!1);let Ut=g.useRef(S);Ut.current=S;let Wt=g.useRef(null),Gt=g.useCallback(e=>{Oe.current!==null&&Oe.current.contains(document.activeElement)&&(e===null&&Ut.current.current!==void 0?N?.current?.focus({preventScroll:!0}):e!==null&&e.focus({preventScroll:!0}),Wt.current=e)},[N]);g.useImperativeHandle(t,()=>({focus:()=>{let e=Wt.current;e===null||!document.contains(e)?N?.current?.focus({preventScroll:!0}):e.focus({preventScroll:!0})},getBounds:(e,t)=>{if(N!==void 0&&N.current!==null)return Qe(N.current,e??0,t??-1)},damage:mt}),[N,mt,Qe]);let Kt=g.useRef(),qt=ra(()=>{if(n<50||we?.disableAccessibilityTree===!0)return null;let e=zo(Xe,De,n,re,Te),t=j?0:-1;!j&&e[0]?.sourceIndex===0&&(e=e.slice(1));let[r,a]=S.current?.cell??[],o=S.current?.range,c=e.map(e=>e.sourceIndex),l=(0,pu.default)(s,Math.min(f,s+i));return r!==void 0&&a!==void 0&&!(c.includes(r)&&l.includes(a))&&Gt(null),g.createElement(`table`,{key:`access-tree`,role:`grid`,"aria-rowcount":f+1,"aria-multiselectable":`true`,"aria-colcount":Xe.length+t},g.createElement(`thead`,{role:`rowgroup`},g.createElement(`tr`,{role:`row`,"aria-rowindex":1},e.map(e=>g.createElement(`th`,{role:`columnheader`,"aria-selected":S.columns.hasIndex(e.sourceIndex),"aria-colindex":e.sourceIndex+1+t,tabIndex:-1,onFocus:t=>{if(t.target!==Wt.current)return _e?.([e.sourceIndex,-1])},key:e.sourceIndex},e.title)))),g.createElement(`tbody`,{role:`rowgroup`},l.map(n=>g.createElement(`tr`,{role:`row`,"aria-selected":S.rows.hasIndex(n),key:n,"aria-rowindex":n+2},e.map(e=>{let i=e.sourceIndex,s=ds(i,n),c=r===i&&a===n,l=o!==void 0&&i>=o.x&&i=o.y&&n{let e=N?.current;if(e!=null)return M?.({bounds:Qe(e,i,n),cancel:()=>void 0,preventDefault:()=>void 0,stopPropagation:()=>void 0,ctrlKey:!1,key:`Enter`,keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:d})},onFocusCapture:e=>{if(!(e.target===Wt.current||Kt.current?.[0]===i&&Kt.current?.[1]===n))return Kt.current=d,_e?.(d)},ref:c?Gt:void 0,tabIndex:-1},hu(f,B))})))))},[n,Xe,De,re,Te,f,s,i,S,Gt,p,N,M,Qe,_e],200),Jt=C===0||!E?0:De>C?1:(0,Ql.default)(-Te/100,0,1),H=-s*32+Ee,Yt=D?(0,Ql.default)(-H/100,0,1):0,Xt=g.useMemo(()=>{if(!Jt&&!Yt)return null;let e={position:`absolute`,top:0,left:Ze,width:n-Ze,height:r,opacity:Jt,pointerEvents:`none`,transition:Se?void 0:`opacity 0.2s`,boxShadow:`inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)`},t={position:`absolute`,top:Ke,left:0,width:n,height:r,opacity:Yt,pointerEvents:`none`,transition:Ce?void 0:`opacity 0.2s`,boxShadow:`inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)`};return g.createElement(g.Fragment,null,Jt>0&&g.createElement(`div`,{id:`shadow-x`,style:e}),Yt>0&&g.createElement(`div`,{id:`shadow-y`,style:t}))},[Jt,Yt,Ze,n,Se,Ke,r,Ce]),Zt=g.useMemo(()=>({position:`absolute`,top:0,left:0}),[]);return g.createElement(g.Fragment,null,g.createElement(`canvas`,{"data-testid":`data-grid-canvas`,tabIndex:0,onKeyDown:Bt,onKeyUp:Vt,onFocus:y,onBlur:b,ref:Ht,style:Tt},qt),g.createElement(`canvas`,{ref:ze,style:Zt}),Xt)}));function _u(e,t,n,r){return(0,Ql.default)(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}var vu=e=>{let[t,n]=g.useState(),[r,i]=g.useState(),[a,o]=g.useState(),[s,c]=g.useState(),[l,u]=g.useState(!1),[d,f]=g.useState(),[p,m]=g.useState(),[h,_]=g.useState(),[v,y]=g.useState(!1),[b,x]=g.useState(),{onHeaderMenuClick:S,getCellContent:C,onColumnMoved:w,onColumnResize:T,onColumnResizeStart:E,onColumnResizeEnd:D,gridRef:O,maxColumnWidth:k,minColumnWidth:A,onRowMoved:ee,lockColumns:te,onColumnProposeMove:ne,onMouseDown:re,onMouseUp:j,onItemHovered:M,onDragStart:ie,canvasRef:ae}=e,N=(T??D??E)!==void 0,{columns:oe,selection:P}=e,F=P.columns,se=g.useCallback(e=>{let[t,n]=e.location;a!==void 0&&s!==t&&t>=te?(u(!0),c(t)):p!==void 0&&n!==void 0?(y(!0),_(Math.max(0,n))):r===void 0&&!l&&!v&&M?.(e)},[a,p,s,M,te,r,l,v]),I=w!==void 0,ce=g.useCallback(e=>{if(e.button===0){let[t,r]=e.location;if(e.kind===`out-of-bounds`&&e.isEdge&&N){let e=O?.current?.getBounds(oe.length-1,-1);e!==void 0&&(n(e.x),i(oe.length-1))}else if(e.kind===`header`&&t>=te){let r=ae?.current;if(e.isEdge&&N&&r){n(e.bounds.x),i(t);let a=r.getBoundingClientRect().width/r.offsetWidth,o=e.bounds.width/a;E?.(oe[t],o,t,o+(oe[t].growOffset??0))}else e.kind===`header`&&I&&(f(e.bounds.x),o(t))}else e.kind===`cell`&&te>0&&t===0&&r!==void 0&&ee!==void 0&&(x(e.bounds.y),m(r))}re?.(e)},[re,N,te,ee,O,oe,I,E,ae]),le=g.useCallback((e,t)=>{l||v||S?.(e,t)},[l,v,S]),ue=g.useRef(-1),de=g.useCallback(()=>{ue.current=-1,m(void 0),_(void 0),x(void 0),y(!1),o(void 0),c(void 0),f(void 0),u(!1),i(void 0),n(void 0)},[]),fe=g.useCallback((e,t)=>{if(e.button===0){if(r!==void 0){if(F?.hasIndex(r)===!0)for(let e of F){if(e===r)continue;let t=oe[e],n=_u(t,ue.current,A,k);T?.(t,n,e,n+(t.growOffset??0))}let e=_u(oe[r],ue.current,A,k);if(D?.(oe[r],e,r,e+(oe[r].growOffset??0)),F.hasIndex(r))for(let e of F){if(e===r)continue;let t=oe[e],n=_u(t,ue.current,A,k);D?.(t,n,e,n+(t.growOffset??0))}}de(),a!==void 0&&s!==void 0&&w?.(a,s),p!==void 0&&h!==void 0&&ee?.(p,h)}j?.(e,t)},[j,r,a,s,p,h,F,D,oe,A,k,T,w,ee,de]),pe=g.useMemo(()=>{if(a!==void 0&&s!==void 0&&a!==s&&ne?.(a,s)!==!1)return{src:a,dest:s}},[a,s,ne]),me=g.useCallback(e=>{let n=ae?.current;if(a!==void 0&&d!==void 0)Math.abs(e.clientX-d)>20&&u(!0);else if(p!==void 0&&b!==void 0)Math.abs(e.clientY-b)>20&&y(!0);else if(r!==void 0&&t!==void 0&&n){let i=n.getBoundingClientRect().width/n.offsetWidth,a=(e.clientX-t)/i,o=oe[r],s=_u(o,a,A,k);if(T?.(o,s,r,s+(o.growOffset??0)),ue.current=a,F?.first()===r)for(let e of F){if(e===r)continue;let t=oe[e],n=_u(t,ue.current,A,k);T?.(t,n,e,n+(t.growOffset??0))}}},[a,d,p,b,r,t,oe,A,k,T,F,ae]),L=g.useCallback((e,t)=>{if(p===void 0||h===void 0)return C(e,t);let[n,r]=e;return r===h?r=p:(r>h&&--r,r>=p&&(r+=1)),C([n,r],t)},[p,h,C]),he=g.useCallback(e=>{ie?.(e),e.defaultPrevented()||de()},[de,ie]);return g.createElement(gu,{accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,enableGroups:e.enableGroups,eventTargetRef:e.eventTargetRef,experimental:e.experimental,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,headerIcons:e.headerIcons,height:e.height,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,resizeColumn:r,isDraggable:e.isDraggable,isFilling:e.isFilling,isFocused:e.isFocused,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDrop:e.onDrop,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,width:e.width,getCellContent:L,isResizing:r!==void 0,onHeaderMenuClick:le,isDragging:l,onItemHovered:se,onDragStart:he,onMouseDown:ce,allowResize:N,onMouseUp:fe,dragAndDropState:pe,onMouseMoveRaw:me,ref:O})};function yu(e){let t=(0,g.useRef)(null),[n,r]=(0,g.useState)({width:e?.[0],height:e?.[1]});return(0,g.useLayoutEffect)(()=>{let e=new window.ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t&&t.contentRect||{};r(t=>t.width===e&&t.height===n?t:{width:e,height:n})}});return t.current&&e.observe(t.current,void 0),()=>{e.disconnect()}},[t.current]),{ref:t,...n}}var bu=(e,t,n)=>{let r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null),o=(0,g.useRef)(0),s=(0,g.useRef)(t);s.current=t;let c=n.current;(0,g.useEffect)(()=>{let t=()=>{if(i.current===!1&&c!==null){let e=[c.scrollLeft,c.scrollTop];if(a.current?.[0]===e[0]&&a.current?.[1]===e[1]){if(o.current>10){a.current=null,i.current=null;return}o.current++}else o.current=0,s.current(e[0],e[1]),a.current=e;r.current=window.setTimeout(t,1e3/120)}},n=()=>{i.current=!0,a.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},l=e=>{e.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(t,1e3/120))};if(e&&c!==null){let e=c;return e.addEventListener(`touchstart`,n),e.addEventListener(`touchend`,l),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchend`,l),r.current!==null&&window.clearTimeout(r.current)}}},[e,c])},xu=Si(`div`)({name:`ScrollRegionStyle`,class:`gdg-s1dgczr6`,propsAsIs:!1,vars:{"s1dgczr6-0":[e=>e.isSafari?`scroll`:`auto`]}});function Su(e){let[t,n]=g.useState(!1),r=typeof window>`u`?null:window,i=g.useRef(0);return qi(`touchstart`,g.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),qi(`touchend`,g.useCallback(t=>{t.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}var Cu=e=>{let{children:t,clientHeight:n,scrollHeight:r,scrollWidth:i,update:a,draggable:o,className:s,preventDiagonalScrolling:c=!1,paddingBottom:l=0,paddingRight:u=0,rightElement:d,rightElementProps:f,kineticScrollPerfHack:p=!1,scrollRef:m,initialSize:h}=e,_=[],v=f?.sticky??!1,y=f?.fill??!1,b=g.useRef(0),x=g.useRef(0),S=g.useRef(null),C=typeof window>`u`?1:window.devicePixelRatio,w=g.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),T=g.useRef(null),E=Su(200),[D,O]=g.useState(!0),k=g.useRef(0);g.useLayoutEffect(()=>{if(!D||E||w.current.lockDirection===void 0)return;let e=S.current;if(e===null)return;let[t,n]=w.current.lockDirection;t===void 0?n!==void 0&&(e.scrollTop=n):e.scrollLeft=t,w.current.lockDirection=void 0},[E,D]);let A=g.useCallback((e,t)=>{let n=S.current;if(n===null)return;t??=n.scrollTop,e??=n.scrollLeft;let i=w.current.scrollTop,o=w.current.scrollLeft,s=e-o,d=t-i;E&&s!==0&&d!==0&&(Math.abs(s)>3||Math.abs(d)>3)&&c&&w.current.lockDirection===void 0&&(w.current.lockDirection=Math.abs(s)0&&(Math.abs(g)>2e3||h===0||h===_)&&r>n.scrollHeight+5){let e=h/_,t=(r-m)*e;b.current=t-h}f!==void 0&&(window.clearTimeout(k.current),O(!1),k.current=window.setTimeout(()=>O(!0),200)),a({x:e,y:h+b.current,width:p-u,height:m-l,paddingRight:T.current?.clientWidth??0})},[l,u,r,a,c,E]);bu(p&&au.value,A,S);let ee=g.useRef(A);ee.current=A;let te=g.useRef(),ne=g.useRef(!1);g.useLayoutEffect(()=>{ne.current?A():ne.current=!0},[A,l,u]);let re=g.useCallback(e=>{S.current=e,m!==void 0&&(m.current=e)},[m]),j=0,M=0;for(_.push(g.createElement(`div`,{key:j++,style:{width:i,height:0}}));Mee.current(),0),te.current={width:ae,height:N}),(ae??0)===0||(N??0)===0?g.createElement(`div`,{ref:ie}):g.createElement(`div`,{ref:ie},g.createElement(xu,{isSafari:au.value},g.createElement(`div`,{className:`dvn-underlay`},t),g.createElement(`div`,{ref:re,style:te.current,draggable:o,onDragStart:e=>{o||(e.stopPropagation(),e.preventDefault())},className:`dvn-scroller `+(s??``),onScroll:()=>A()},g.createElement(`div`,{className:`dvn-scroll-inner`+(d===void 0?` dvn-hidden`:``)},g.createElement(`div`,{className:`dvn-stack`},_),d!==void 0&&g.createElement(g.Fragment,null,!y&&g.createElement(`div`,{className:`dvn-spacer`}),g.createElement(`div`,{ref:T,style:{height:N,maxHeight:n-Math.ceil(C%1),position:`sticky`,top:0,paddingLeft:1,marginBottom:-40,marginRight:u,flexGrow:y?1:void 0,right:v?u??0:void 0,pointerEvents:`auto`}},d))))))},wu=e=>{let{columns:t,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:a,enableGroups:o,freezeColumns:s,experimental:c,nonGrowWidth:l,clientSize:u,className:d,onVisibleRegionChanged:f,scrollRef:p,preventDiagonalScrolling:m,rightElement:h,rightElementProps:_,overscrollX:v,overscrollY:y,initialSize:b,smoothScrollX:x=!1,smoothScrollY:S=!1,isDraggable:C}=e,{paddingRight:w,paddingBottom:T}=c??{},[E,D]=u,O=g.useRef(),k=g.useRef(),A=g.useRef(),ee=g.useRef(),te=l+Math.max(0,v??0),ne=o?i+a:i;if(typeof r==`number`)ne+=n*r;else for(let e=0;e{if(re.current===void 0)return;let e={...re.current},i=0,a=e.x<0?-e.x:0,o=0,c=0;e.x=e.x<0?0:e.x;let l=0;for(let e=0;e=t+n.width)i+=n.width,c++,o++;else if(e.x>t)i+=n.width,x?a+=t-e.x:c++,o++;else if(e.x+e.width>t)i+=n.width,o++;else break}let u=0,d=0,p=0;if(typeof r==`number`)S?(d=Math.floor(e.y/r),u=d*r-e.y):d=Math.ceil(e.y/r),p=Math.ceil(e.height/r)+d,u<0&&p++;else{let t=0;for(let i=0;i=t+n)t+=n,d++,p++;else if(e.y>a)t+=n,S?u+=a-e.y:d++,p++;else if(e.y+e.height>n/2+t)t+=n,p++;else break}}let m={x:c,y:d,width:o-c,height:p-d},h=O.current;(h===void 0||h.y!==m.y||h.x!==m.x||h.height!==m.height||h.width!==m.width||k.current!==a||A.current!==u||e.width!==ee.current?.[0]||e.height!==ee.current?.[1])&&(f?.({x:c,y:d,width:o-c,height:p-d},e.width,e.height,e.paddingRight??0,a,u),O.current=m,k.current=a,A.current=u,ee.current=[e.width,e.height])},[t,r,n,f,s,x,S]),M=g.useCallback(e=>{re.current=e,j()},[j]);return g.useEffect(()=>{j()},[j]),g.createElement(Cu,{scrollRef:p,className:d,kineticScrollPerfHack:c?.kineticScrollPerfHack,preventDiagonalScrolling:m,draggable:C===!0||typeof C==`string`,scrollWidth:te+(w??0),scrollHeight:ne+(T??0),clientHeight:D,rightElement:h,paddingBottom:T,paddingRight:w,rightElementProps:_,update:M,initialSize:b},g.createElement(vu,{eventTargetRef:p,width:E,height:D,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,onColumnProposeMove:e.onColumnProposeMove,verticalBorder:e.verticalBorder,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}))},Tu=Si(`div`)({name:`SearchWrapper`,class:`gdg-seveqep`,propsAsIs:!1}),Eu=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 244l144-144 144 144M256 120v292`})),Du=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 268l144 144 144-144M256 392V100`})),Ou=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`32`,d:`M368 368L144 144M368 144L144 368`})),ku=10,Au=e=>{let{canvasRef:t,cellYOffset:n,rows:r,columns:i,searchInputRef:a,searchValue:o,searchResults:s,onSearchValueChange:c,getCellsForSelection:l,onSearchResultsChanged:u,showSearch:d=!1,onSearchClose:f}=e,[p]=g.useState(()=>`search-box-`+Math.round(Math.random()*1e3)),[m,h]=g.useState(``),_=o??m,v=g.useCallback(e=>{h(e),c?.(e)},[c]),[y,b]=g.useState(),x=g.useRef(y);x.current=y,g.useEffect(()=>{s!==void 0&&(s.length>0?b(e=>({rowsSearched:r,results:s.length,selectedIndex:e?.selectedIndex??-1})):b(void 0))},[r,s]);let S=g.useRef();S.current===void 0&&(S.current=new AbortController);let C=g.useRef(),[w,T]=g.useState([]),E=s??w,D=g.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,S.current.abort())},[]),O=g.useRef(n);O.current=n;let k=g.useCallback(e=>{let t=new RegExp(e.replace(/([$()*+.?[\\\]^{|}-])/g,`\\$1`),`i`),n=O.current,a=Math.min(10,r),o=0;b(void 0),T([]);let s=[],c=async()=>{if(l===void 0)return;let e=performance.now(),d=r-o,f=l({x:0,y:n,width:i.length,height:Math.min(a,d,r-n)},S.current.signal);typeof f==`function`&&(f=await f());let p=!1;for(let[e,r]of f.entries())for(let[i,a]of r.entries()){let r;switch(a.kind){case K.Text:case K.Number:r=a.displayData;break;case K.Uri:case K.Markdown:r=a.data;break;case K.Boolean:r=typeof a.data==`boolean`?a.data.toString():void 0;break;case K.Image:case K.Bubble:r=a.data.join(`🐳`);break;case K.Custom:r=a.copyData}r!==void 0&&t.test(r)&&(s.push([i,e+n]),p=!0)}let m=performance.now();p&&T([...s]),o+=f.length,Kn(o<=r);let h=x.current?.selectedIndex??-1;b({results:s.length,rowsSearched:o,selectedIndex:h}),u?.(s,h),n+a>=r?n=0:n+=a;let g=m-e,_=ku/Math.max(g,1);a=Math.ceil(a*_),o{f?.(),b(void 0),T([]),u?.([],-1),D(),t?.current?.focus()},[D,t,f,u]),ee=g.useCallback(e=>{v(e.target.value),s===void 0&&(e.target.value===``?(b(void 0),T([]),D()):k(e.target.value))},[k,D,v,s]);g.useEffect(()=>{d&&a.current!==null&&(v(``),a.current.focus({preventScroll:!0}))},[d,a,v]);let te=g.useCallback(e=>{if(e?.stopPropagation?.(),y===void 0)return;let t=(y.selectedIndex+1)%y.results;b({...y,selectedIndex:t}),u?.(E,t)},[y,u,E]),ne=g.useCallback(e=>{if(e?.stopPropagation?.(),y===void 0)return;let t=(y.selectedIndex-1)%y.results;t<0&&(t+=y.results),b({...y,selectedIndex:t}),u?.(E,t)},[u,E,y]),re=g.useCallback(e=>{(e.ctrlKey||e.metaKey)&&e.nativeEvent.code===`KeyF`||e.key===`Escape`?(A(),e.stopPropagation(),e.preventDefault()):e.key===`Enter`&&(e.shiftKey?ne():te())},[A,te,ne]);g.useEffect(()=>()=>{D()},[D]);let[j,M]=g.useState(!1);g.useEffect(()=>{if(d)M(!0);else{let e=setTimeout(()=>M(!1),150);return()=>clearTimeout(e)}},[d]);let ie=g.useMemo(()=>{if(!d&&!j)return null;let e;y!==void 0&&(e=y.results>=1e3?`over 1000`:`${y.results} result${y.results===1?``:`s`}`,y.selectedIndex>=0&&(e=`${y.selectedIndex+1} of ${e}`));let t=e=>{e.stopPropagation()},n={width:`${Math.floor((y?.rowsSearched??0)/r*100)}%`};return g.createElement(Tu,{className:d?``:`out`,onMouseDown:t,onMouseMove:t,onMouseUp:t,onClick:t},g.createElement(`div`,{className:`gdg-search-bar-inner`},g.createElement(`input`,{id:p,"aria-hidden":!d,"data-testid":`search-input`,ref:a,onChange:ee,value:_,tabIndex:d?void 0:-1,onKeyDownCapture:re}),g.createElement(`button`,{"aria-label":`Previous Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:ne,disabled:(y?.results??0)===0},Eu),g.createElement(`button`,{"aria-label":`Next Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:te,disabled:(y?.results??0)===0},Du),f!==void 0&&g.createElement(`button`,{"aria-label":`Close Search`,"aria-hidden":!d,"data-testid":`search-close-button`,tabIndex:d?void 0:-1,onClick:A},Ou)),y===void 0?g.createElement(`div`,{className:`gdg-search-status`},g.createElement(`label`,{htmlFor:p},`Type to search`)):g.createElement(g.Fragment,null,g.createElement(`div`,{className:`gdg-search-status`},g.createElement(`div`,{"data-testid":`search-result-area`},e)),g.createElement(`div`,{className:`gdg-search-progress`,style:n})))},[d,j,y,r,p,a,ee,_,re,ne,te,f,A]);return g.createElement(g.Fragment,null,g.createElement(wu,{prelightCells:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,className:e.className,clientSize:e.clientSize,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,nonGrowWidth:e.nonGrowWidth,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,initialSize:e.initialSize,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,onVisibleRegionChanged:e.onVisibleRegionChanged,overscrollX:e.overscrollX,overscrollY:e.overscrollY,preventDiagonalScrolling:e.preventDiagonalScrolling,rightElement:e.rightElement,rightElementProps:e.rightElementProps,rowHeight:e.rowHeight,rows:e.rows,scrollRef:e.scrollRef,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,onColumnProposeMove:e.onColumnProposeMove,drawFocusRing:e.drawFocusRing,drawCell:e.drawCell,drawHeader:e.drawHeader,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}),ie)},ju=class extends g.PureComponent{wrapperRef=g.createRef();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)}clickOutside=e=>{if((!this.props.isOutsideClick||this.props.isOutsideClick(e))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(e.target)){let t=e.target;for(;t!==null;){if(t.classList.contains(`click-outside-ignore`))return;t=t.parentElement}this.props.onClickOutside()}};render(){let{onClickOutside:e,isOutsideClick:t,...n}=this.props;return g.createElement(`div`,{...n,ref:this.wrapperRef},this.props.children)}},Mu=Si(`input`)({name:`RenameInput`,class:`gdg-r17m35ur`,propsAsIs:!1,vars:{"r17m35ur-0":[e=>Math.max(16,e.targetHeight-10),`px`]}}),Nu=e=>{let{bounds:t,group:n,onClose:r,canvasBounds:i,onFinish:a}=e,[o,s]=g.useState(n);return g.createElement(ju,{style:{position:`absolute`,left:t.x-i.left+1,top:t.y-i.top,width:t.width-2,height:t.height},className:`gdg-c1tqibwd`,onClickOutside:r},g.createElement(Mu,{targetHeight:t.height,"data-testid":`group-rename-input`,value:o,onBlur:r,onFocus:e=>e.target.setSelectionRange(0,o.length),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?a(o):e.key===`Escape`&&r()},autoFocus:!0}))};function Pu(e,t){return e===void 0?!1:e.length>1&&e.startsWith(`_`)?Number.parseInt(e.slice(1))===t.keyCode:e.length===1&&e>=`a`&&e<=`z`?e.toUpperCase().codePointAt(0)===t.keyCode:e===t.key}function Fu(e,t,n){let r=Iu(e,t);return r&&(n.didMatch=!0),r}function Iu(e,t){if(e.length===0)return!1;if(e.includes(`|`)){let n=e.split(`|`);for(let e of n)if(Iu(e,t))return!0;return!1}let n=!1,r=!1,i=!1,a=!1,o=e.split(`+`);if(!Pu(o.pop(),t))return!1;if(o[0]===`any`)return!0;for(let e of o)switch(e){case`ctrl`:n=!0;break;case`shift`:r=!0;break;case`alt`:i=!0;break;case`meta`:a=!0;break;case`primary`:ou.value?a=!0:n=!0}return t.altKey===i&&t.ctrlKey===n&&t.shiftKey===r&&t.metaKey===a}function Lu(e,t,n,r,i,a){return[g.useCallback((o,s,c,l)=>{(a===`cell`||a===`multi-cell`)&&o!==void 0&&(o={...o,range:{x:o.cell[0],y:o.cell[1],width:1,height:1}});let u=n===`mixed`&&(c||l===`drag`),d=r===`mixed`&&u,f=i===`mixed`&&u,p={current:o===void 0?void 0:{...o,rangeStack:l===`drag`?e.current?.rangeStack??[]:[]},columns:d?e.columns:fi.empty(),rows:f?e.rows:fi.empty()};c&&(a===`multi-rect`||a===`multi-cell`)&&p.current!==void 0&&e.current!==void 0&&(p={...p,current:{...p.current,rangeStack:[...e.current.rangeStack,e.current.range]}}),t(p,s)},[r,e,n,a,i,t]),g.useCallback((a,o,s)=>{a??=e.rows,o!==void 0&&(a=a.add(o));let c;if(i===`exclusive`&&a.length>0)c={current:void 0,columns:fi.empty(),rows:a};else{let t=s&&n===`mixed`,i=s&&r===`mixed`;c={current:t?e.current:void 0,columns:i?e.columns:fi.empty(),rows:a}}t(c,!1)},[r,e,n,i,t]),g.useCallback((a,o,s)=>{a??=e.columns,o!==void 0&&(a=a.add(o));let c;if(r===`exclusive`&&a.length>0)c={current:void 0,rows:fi.empty(),columns:a};else{let t=s&&n===`mixed`,r=s&&i===`mixed`;c={current:t?e.current:void 0,rows:r?e.rows:fi.empty(),columns:a}}t(c,!1)},[r,e,n,i,t])]}function Ru(e,t,n,r,i){let a=g.useCallback(n=>{if(e===!0){let e=[];for(let r=n.y;r=i?a.push({kind:K.Loading,allowOverlay:!1}):a.push(t([e,r]));e.push(a)}return e}return e?.(n,r.signal)??[]},[r.signal,t,e,i]),o=e===void 0?void 0:a,s=g.useCallback(e=>{if(o===void 0)return[];let t={...e,x:e.x-n};if(t.x<0){t.x=0,t.width--;let e=o(t,r.signal);return typeof e==`function`?async()=>(await e()).map(e=>[{kind:K.Loading,allowOverlay:!1},...e]):e.map(e=>[{kind:K.Loading,allowOverlay:!1},...e])}return o(t,r.signal)},[r.signal,o,n]);return[e===void 0?void 0:s,o]}function zu(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:`string`};switch(e.kind){case K.Boolean:return{formatted:e.data===!0?`TRUE`:e.data===!1?`FALSE`:e.data===void 0?`INDETERMINATE`:``,rawValue:e.data,format:`boolean`};case K.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:`string`};case K.Image:case K.Bubble:return{formatted:e.data,rawValue:e.data,format:`string-array`};case K.Drilldown:return{formatted:e.data.map(e=>e.text),rawValue:e.data.map(e=>e.text),format:`string-array`};case K.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:`string`};case K.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:`url`};case K.Markdown:case K.RowID:return{formatted:e.data,rawValue:e.data,format:`string`};case K.Number:return{formatted:e.displayData,rawValue:e.data,format:`number`};case K.Loading:return{formatted:`#LOADING`,rawValue:``,format:`string`};case K.Protected:return{formatted:`************`,rawValue:``,format:`string`};default:qn(e)}}function Bu(e,t){return e.map((e,n)=>{let r=t[n];return e.map(e=>e.span!==void 0&&e.span[0]!==r?{formatted:``,rawValue:``,format:`string`}:zu(e))})}function Vu(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,`""`)}"`),e}function Hu(e){let t=[];for(let n of e){let e=[];for(let t of n)t.format===`url`?e.push(t.rawValue?.toString()??``):t.format===`string-array`?e.push(t.formatted.map(e=>Vu(e,!0)).join(`,`)):e.push(Vu(t.formatted,!1));t.push(e.join(` `))}return t.join(` +`)}function Uu(e){return e.replace(/\t/g,` `).replace(/ {2,}/g,e=>` `.repeat(e.length))}function Wu(e){return`"`+e.replace(/&/g,`&`).replace(/"/g,`"`).replace(//g,`>`)+`"`}function Gu(e){return e.replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function Ku(e){let t=[];t.push(``,``);for(let n of e){t.push(``);for(let e of n){let n=`gdg-format="${e.format}"`;e.format===`url`?t.push(``):e.format===`string-array`?t.push(``):t.push(``)}t.push(``)}return t.push(`
    ${Uu(e.formatted)}
      ${e.formatted.map((t,n)=>`
    1. `+Uu(t)+`
    2. `).join(``)}
    ${Uu(e.formatted)}
    `),t.join(``)}function qu(e,t){let n=Bu(e,t);return{textPlain:Hu(n),textHtml:Ku(n)}}function Ju(e){let t=document.createElement(`html`);t.innerHTML=e.replace(/ /g,` `);let n=t.querySelector(`table`);if(n===null)return;let r=[n],i=[],a;for(;r.length>0;){let e=r.pop();if(e===void 0)break;if(e instanceof HTMLTableElement||e.nodeName===`TBODY`)r.push(...[...e.children].reverse());else if(e instanceof HTMLTableRowElement)a!==void 0&&i.push(a),a=[],r.push(...[...e.children].reverse());else if(e instanceof HTMLTableCellElement){let t=e.cloneNode(!0),n=t.children.length===1&&t.children[0].nodeName===`P`?t.children[0]:null,r=n?.children.length===1&&n.children[0].nodeName===`FONT`,i=t.querySelectorAll(`br`);for(let e of i)e.replaceWith(` +`);let o=t.getAttribute(`gdg-raw-value`),s=t.getAttribute(`gdg-format`)??`string`;if(t.querySelector(`a`)!==null)a?.push({rawValue:t.querySelector(`a`)?.getAttribute(`href`)??``,formatted:t.textContent??``,format:s});else if(t.querySelector(`ol`)!==null){let e=t.querySelectorAll(`li`);a?.push({rawValue:[...e].map(e=>e.getAttribute(`gdg-raw-value`)??``),formatted:[...e].map(e=>e.textContent??``),format:`string-array`})}else if(o!==null)a?.push({rawValue:Gu(o),formatted:t.textContent??``,format:s});else{let e=t.textContent??``;r&&(e=e.replace(/\n(?!\n)/g,``)),a?.push({rawValue:e??``,formatted:e??``,format:s})}}}return a!==void 0&&i.push(a),i}function Yu(e,t,n,r,i){let a=e;if(r===`allowPartial`||e.current===void 0||t===void 0)return e;let o=!1;do{if(e?.current===void 0)break;let r=e.current?.range,s=[];if(r.width>2){let e=t({x:r.x,y:r.y,width:1,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e);let n=t({x:r.x+r.width-1,y:r.y,width:1,height:r.height},i.signal);if(typeof n==`function`)return a;s.push(...n)}else{let e=t({x:r.x,y:r.y,width:r.width,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e)}let c=r.x-n,l=r.x+r.width-1-n;for(let e of s)for(let t of e)t.span!==void 0&&(c=Math.min(t.span[0],c),l=Math.max(t.span[1],l));c===r.x-n&&l===r.x+r.width-1-n?o=!0:e={current:{cell:e.current.cell??[0,0],range:{x:c+n,y:r.y,width:l-c+1,height:r.height},rangeStack:e.current.rangeStack},columns:e.columns,rows:e.rows}}while(!o);return e}function Xu(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&(e=e.slice(1,-1).replace(/""/g,`"`)),e}function Zu(e){let t;(function(e){e[e.None=0]=`None`,e[e.inString=1]=`inString`,e[e.inStringPostQuote=2]=`inStringPostQuote`})(t||={});let n=[],r=[],i=0,a=t.None;e=e.replace(/\r\n/g,` +`);let o=0;for(let s of e){switch(a){case t.None:s===` `||s===` +`?(r.push(e.slice(i,o)),i=o+1,s===` +`&&(n.push(r),r=[])):s===`"`&&(a=t.inString);break;case t.inString:s===`"`&&(a=t.inStringPostQuote);break;case t.inStringPostQuote:s===`"`?a=t.inString:((s===` `||s===` +`)&&(r.push(Xu(e.slice(i,o))),i=o+1,s===` +`&&(n.push(r),r=[])),a=t.None)}o++}return ie.map(e=>({rawValue:e,formatted:e,format:`string`})))}function Qu(e,t,n){let r=qu(e,t),i=e=>{window.navigator.clipboard?.writeText(e)},a=(e,t)=>window.navigator.clipboard?.write!==void 0&&(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([t],{type:`text/html`})})]),!0);window.navigator.clipboard?.write!==void 0||n?.clipboardData!==void 0?((e,t)=>{try{if(n===void 0||n.clipboardData===null)throw Error(`No clipboard data`);n?.clipboardData?.setData(`text/plain`,e),n?.clipboardData?.setData(`text/html`,t)}catch{a(e,t)||i(e)}})(r.textPlain,r.textHtml):i(r.textPlain),n?.preventDefault()}function $u(e){return e!==!0}function ed(e){return typeof e==`string`?e:`${e}px`}var td=Si(`div`)({name:`Wrapper`,class:`gdg-wmyidgi`,propsAsIs:!1,vars:{"wmyidgi-0":[e=>e.innerWidth],"wmyidgi-1":[e=>e.innerHeight]}}),nd=e=>{let{inWidth:t,inHeight:n,children:r,...i}=e;return g.createElement(td,{innerHeight:ed(n),innerWidth:ed(t),...i},r)},rd=2,id=1300;function ad(e,t,n){let r=g.useRef(0),[i,a]=e??[0,0];g.useEffect(()=>{if(i===0&&a===0){r.current=0;return}let e=!1,o=0,s=c=>{if(!e){if(o===0)o=c;else{let e=c-o;r.current=Math.min(1,r.current+e/id);let s=r.current**1.618*e*rd;t.current?.scrollBy(i*s,a*s),o=c,n?.()}window.requestAnimationFrame(s)}};return window.requestAnimationFrame(s),()=>{e=!0}},[t,i,a,n])}function od({rowHeight:e,headerHeight:t,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:a,scaleToRem:o,remSize:s}){let[c,l,u,d,f,p]=g.useMemo(()=>{if(!o||s===16)return[e,t,n,r,i,a];let c=s/16,l=e,u=bs();return[typeof l==`number`?l*c:e=>Math.ceil(l(e)*c),Math.ceil(t*c),Math.ceil(n*c),{...r,headerIconSize:(r?.headerIconSize??u.headerIconSize)*c,cellHorizontalPadding:(r?.cellHorizontalPadding??u.cellHorizontalPadding)*c,cellVerticalPadding:(r?.cellVerticalPadding??u.cellVerticalPadding)*c},Math.ceil((i??0)*c),Math.ceil((a??0)*c)]},[n,t,i,a,s,e,o,r]);return{rowHeight:c,headerHeight:l,groupHeaderHeight:u,theme:d,overscrollX:f,overscrollY:p}}var sd={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 cd(e,t){return e===!0?t:e===!1?``:e}function ld(e){let t=ou.value;return{activateCell:cd(e.activateCell,` |Enter|shift+Enter`),clear:cd(e.clear,`any+Escape`),closeOverlay:cd(e.closeOverlay,`any+Escape`),acceptOverlayDown:cd(e.acceptOverlayDown,`Enter`),acceptOverlayUp:cd(e.acceptOverlayUp,`shift+Enter`),acceptOverlayLeft:cd(e.acceptOverlayLeft,`shift+Tab`),acceptOverlayRight:cd(e.acceptOverlayRight,`Tab`),copy:e.copy,cut:e.cut,delete:cd(e.delete,t?`Backspace|Delete`:`Delete`),downFill:cd(e.downFill,`primary+_68`),scrollToSelectedCell:cd(e.scrollToSelectedCell,`primary+Enter`),goDownCell:cd(e.goDownCell,`ArrowDown`),goDownCellRetainSelection:cd(e.goDownCellRetainSelection,`alt+ArrowDown`),goLeftCell:cd(e.goLeftCell,`ArrowLeft|shift+Tab`),goLeftCellRetainSelection:cd(e.goLeftCellRetainSelection,`alt+ArrowLeft`),goRightCell:cd(e.goRightCell,`ArrowRight|Tab`),goRightCellRetainSelection:cd(e.goRightCellRetainSelection,`alt+ArrowRight`),goUpCell:cd(e.goUpCell,`ArrowUp`),goUpCellRetainSelection:cd(e.goUpCellRetainSelection,`alt+ArrowUp`),goToFirstCell:cd(e.goToFirstCell,`primary+Home`),goToFirstColumn:cd(e.goToFirstColumn,`Home|primary+ArrowLeft`),goToFirstRow:cd(e.goToFirstRow,`primary+ArrowUp`),goToLastCell:cd(e.goToLastCell,`primary+End`),goToLastColumn:cd(e.goToLastColumn,`End|primary+ArrowRight`),goToLastRow:cd(e.goToLastRow,`primary+ArrowDown`),goToNextPage:cd(e.goToNextPage,`PageDown`),goToPreviousPage:cd(e.goToPreviousPage,`PageUp`),paste:e.paste,rightFill:cd(e.rightFill,`primary+_82`),search:cd(e.search,`primary+f`),selectAll:cd(e.selectAll,`primary+a`),selectColumn:cd(e.selectColumn,`ctrl+ `),selectGrowDown:cd(e.selectGrowDown,`shift+ArrowDown`),selectGrowLeft:cd(e.selectGrowLeft,`shift+ArrowLeft`),selectGrowRight:cd(e.selectGrowRight,`shift+ArrowRight`),selectGrowUp:cd(e.selectGrowUp,`shift+ArrowUp`),selectRow:cd(e.selectRow,`shift+ `),selectToFirstCell:cd(e.selectToFirstCell,`primary+shift+Home`),selectToFirstColumn:cd(e.selectToFirstColumn,`primary+shift+ArrowLeft`),selectToFirstRow:cd(e.selectToFirstRow,`primary+shift+ArrowUp`),selectToLastCell:cd(e.selectToLastCell,`primary+shift+End`),selectToLastColumn:cd(e.selectToLastColumn,`primary+shift+ArrowRight`),selectToLastRow:cd(e.selectToLastRow,`primary+shift+ArrowDown`)}}function ud(e){let t=da(e);return g.useMemo(()=>{if(t===void 0)return ld(sd);let e={...t,goToNextPage:t?.goToNextPage??t?.pageDown??sd.goToNextPage,goToPreviousPage:t?.goToPreviousPage??t?.pageUp??sd.goToPreviousPage,goToFirstCell:t?.goToFirstCell??t?.first??sd.goToFirstCell,goToLastCell:t?.goToLastCell??t?.last??sd.goToLastCell,selectToFirstCell:t?.selectToFirstCell??t?.first??sd.selectToFirstCell,selectToLastCell:t?.selectToLastCell??t?.last??sd.selectToLastCell};return ld({...sd,...e})},[t])}var dd=`modulepreload`,fd=function(e){return`/`+e},pd={},md=function(e){return e.pathname.endsWith(`.css`)},hd=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},gd=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=fd(t,n);let r=s(t),i=md(r);return hd(pd,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:dd,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},_d=c(Ws(),1),vd=c(Js(),1),yd=g.lazy(async()=>await gd(()=>import(`./data-grid-overlay-editor-BCyLLTrp.js`),[])),bd=0;function xd(e){return(0,_d.default)((0,vd.default)((0,vd.default)(e).filter(e=>e.span!==void 0).map(e=>(0,pu.default)((e.span?.[0]??0)+1,(e.span?.[1]??0)+1))))}function Sd(e,t){return e===void 0||t===0||e.columns.length===0&&e.current===void 0?e:{current:e.current===void 0?void 0:{cell:[e.current.cell[0]+t,e.current.cell[1]],range:{...e.current.range,x:e.current.range.x+t},rangeStack:e.current.rangeStack.map(e=>({...e,x:e.x+t}))},rows:e.rows,columns:e.columns.offset(t)}}var Cd={kind:K.Loading,allowOverlay:!1},wd={columns:fi.empty(),rows:fi.empty(),current:void 0},Td=g.forwardRef((e,t)=>{let[n,r]=g.useState(wd),[i,a]=g.useState(),o=g.useRef(null),s=g.useRef(null),[c,l]=g.useState(),u=g.useRef(null),d=g.useRef(),f=typeof window>`u`?null:window,{imageEditorOverride:p,getRowThemeOverride:m,markdownDivCreateNode:h,width:_,height:v,columns:y,rows:b,getCellContent:x,onCellClicked:S,onCellActivated:C,onFillPattern:w,onFinishedEditing:T,coercePasteValue:E,drawHeader:D,drawCell:O,editorBloom:k,onHeaderClicked:A,onColumnProposeMove:ee,spanRangeBehavior:te=`default`,onGroupHeaderClicked:ne,onCellContextMenu:re,className:j,onHeaderContextMenu:M,getCellsForSelection:ie,onGroupHeaderContextMenu:ae,onGroupHeaderRenamed:N,onCellEdited:oe,onCellsEdited:P,onSearchResultsChanged:F,searchResults:se,onSearchValueChange:I,searchValue:ce,onKeyDown:le,onKeyUp:ue,keybindings:de,editOnType:fe=!0,onRowAppended:pe,onColumnMoved:me,validateCell:L,highlightRegions:he,rangeSelect:R=`rect`,columnSelect:ge=`multi`,rowSelect:z=`multi`,rangeSelectionBlending:_e=`exclusive`,columnSelectionBlending:ve=`exclusive`,rowSelectionBlending:ye=`exclusive`,onDelete:be,onDragStart:xe,onMouseMove:Se,onPaste:Ce,copyHeaders:we=!1,freezeColumns:B=0,cellActivationBehavior:Te=`second-click`,rowSelectionMode:Ee=`auto`,onHeaderMenuClick:De,getGroupDetails:Oe,onSearchClose:ke,onItemHovered:Ae,onSelectionCleared:je,showSearch:Me,onVisibleRegionChanged:Ne,gridSelection:Pe,onGridSelectionChange:Fe,minColumnWidth:Ie=50,maxColumnWidth:Le=500,maxColumnAutoWidth:Re,provideEditor:ze,trailingRowOptions:Be,freezeTrailingRows:Ve=0,allowedFillDirections:He=`orthogonal`,scrollOffsetX:Ue,scrollOffsetY:We,verticalBorder:Ge,onDragOverCell:Ke,onDrop:qe,onColumnResize:Je,onColumnResizeEnd:Ye,onColumnResizeStart:Xe,customRenderers:Ze,fillHandle:Qe,drawFocusRing:$e=!0,experimental:et,fixedShadowX:tt,fixedShadowY:nt,headerIcons:rt,imageWindowLoader:it,initialSize:at,isDraggable:ot,onDragLeave:st,onRowMoved:ct,overscrollX:lt,overscrollY:ut,preventDiagonalScrolling:dt,rightElement:ft,rightElementProps:pt,trapFocus:mt=!1,smoothScrollX:ht,smoothScrollY:gt,scaleToRem:_t=!1,rowHeight:vt=34,headerHeight:yt=36,groupHeaderHeight:bt=yt,theme:xt,isOutsideClick:St,renderers:Ct}=e,wt=typeof e.rowMarkers==`string`?void 0:e.rowMarkers,Tt=wt?.kind??e.rowMarkers??`none`,Et=wt?.width??e.rowMarkerWidth,Dt=wt?.startIndex??e.rowMarkerStartIndex??1,Ot=wt?.theme??e.rowMarkerTheme,kt=wt?.checkboxStyle??`square`,At=Math.max(Ie,20),jt=Math.max(Le,At),Mt=Math.max(Re??jt,At),Nt=g.useMemo(()=>typeof window>`u`?{fontSize:`16px`}:window.getComputedStyle(document.documentElement),[]),{rowHeight:Pt,headerHeight:Ft,groupHeaderHeight:It,theme:Lt,overscrollX:Rt,overscrollY:zt}=od({groupHeaderHeight:bt,headerHeight:yt,overscrollX:lt,overscrollY:ut,remSize:g.useMemo(()=>Number.parseFloat(Nt.fontSize),[Nt]),rowHeight:vt,scaleToRem:_t,theme:xt}),Bt=ud(de),Vt=Et??(b>1e4?48:b>1e3?44:b>100?36:32),Ht=Tt!==`none`,V=+!!Ht,Ut=pe!==void 0,Wt=Be?.sticky===!0,[Gt,Kt]=g.useState(!1),qt=Me??Gt,Jt=g.useCallback(()=>{ke===void 0?Kt(!1):ke()},[ke]),H=g.useMemo(()=>Pe===void 0?void 0:Sd(Pe,V),[Pe,V])??n,Yt=g.useRef();Yt.current===void 0&&(Yt.current=new AbortController),g.useEffect(()=>()=>Yt?.current.abort(),[]);let[Xt,Zt]=Ru(ie,x,V,Yt.current,b),Qt=g.useCallback((e,t,n)=>{if(L===void 0)return!0;let r=[e[0]-V,e[1]];return L?.(r,t,n)},[V,L]),U=g.useRef(Pe),$t=g.useCallback((e,t)=>{t&&(e=Yu(e,Xt,V,te,Yt.current)),Fe===void 0?r(e):(U.current=Sd(e,-V),Fe(U.current))},[Fe,Xt,V,te]),en=Ji(Je,g.useCallback((e,t,n,r)=>{Je?.(y[n-V],t,n-V,r)},[Je,V,y])),tn=Ji(Ye,g.useCallback((e,t,n,r)=>{Ye?.(y[n-V],t,n-V,r)},[Ye,V,y])),nn=Ji(Xe,g.useCallback((e,t,n,r)=>{Xe?.(y[n-V],t,n-V,r)},[Xe,V,y])),rn=Ji(D,g.useCallback((e,t)=>D?.({...e,columnIndex:e.columnIndex-V},t)??!1,[D,V])),an=Ji(O,g.useCallback((e,t)=>O?.({...e,col:e.col-V},t)??!1,[O,V])),on=g.useCallback(e=>{if(be!==void 0){let t=be(Sd(e,-V));return typeof t==`boolean`?t:Sd(t,V)}return!0},[be,V]),[W,sn,cn]=Lu(H,$t,_e,ve,ye,R),ln=g.useMemo(()=>Ss(bs(),Lt),[Lt]),[un,dn]=g.useState([0,0,0]),fn=g.useMemo(()=>{if(Ct===void 0)return{};let e={};for(let t of Ct)e[t.kind]=t;return e},[Ct]),pn=g.useCallback(e=>e.kind===K.Custom?Ze?.find(t=>t.isMatch(e)):fn[e.kind],[Ze,fn]),{sizedColumns:mn,nonGrowWidth:hn}=Es(y,b,Zt,un[0]-(V===0?0:Vt)-un[2],At,Mt,ln,pn,Yt.current);Tt!==`none`&&(hn+=Vt);let gn=g.useMemo(()=>mn.some(e=>e.group!==void 0),[mn]),_n=gn?Ft+It:Ft,vn=H.rows.length,yn=Tt===`none`?void 0:vn===0?!1:vn===b||void 0,bn=g.useMemo(()=>Tt===`none`?mn:[{title:``,width:Vt,icon:void 0,hasMenu:!1,style:`normal`,themeOverride:Ot,rowMarker:kt,rowMarkerChecked:yn},...mn],[Tt,mn,Vt,Ot,kt,yn]),[xn,Sn]=g.useMemo(()=>[We!==void 0&&typeof Pt==`number`?Math.floor(We/Pt):0,We!==void 0&&typeof Pt==`number`?-(We%Pt):0],[We,Pt]),Cn=g.useRef({height:1,width:1,x:0,y:0}),wn=g.useMemo(()=>({x:Cn.current.x,y:xn,width:Cn.current.width??1,height:Cn.current.height??1,ty:Sn}),[Sn,xn]),Tn=g.useRef(!1),[En,G,Dn]=la(wn);Cn.current=En;let On=(En.height??1)>1;g.useLayoutEffect(()=>{if(We!==void 0&&u.current!==null&&On){if(u.current.scrollTop===We)return;u.current.scrollTop=We,u.current.scrollTop!==We&&Dn(),Tn.current=!0}},[We,On,Dn]);let kn=(En.width??1)>1;g.useLayoutEffect(()=>{if(Ue!==void 0&&u.current!==null&&kn){if(u.current.scrollLeft===Ue)return;u.current.scrollLeft=Ue,u.current.scrollLeft!==Ue&&Dn(),Tn.current=!0}},[Ue,kn,Dn]);let An=En.x+V,jn=En.y,Mn=g.useRef(null),Nn=g.useCallback(e=>{e===!0?Mn.current?.focus():window.requestAnimationFrame(()=>{Mn.current?.focus()})},[]),Pn=Ut?b+1:b,Fn=g.useCallback(e=>{let t=V===0?e:e.map(e=>({...e,location:[e.location[0]-V,e.location[1]]})),n=P?.(t);if(n!==!0)for(let e of t)oe?.(e.location,e.value);return n},[oe,P,V]),[In,Ln]=g.useState(),Rn=H.current!==void 0&&H.current.range.width*H.current.range.height>1?H.current.range:void 0,zn=$e?H.current?.cell:void 0,Bn=zn?.[0],Vn=zn?.[1],Hn=g.useMemo(()=>{if((he===void 0||he.length===0)&&(Rn??Bn??Vn??In)===void 0)return;let e=[];if(he!==void 0)for(let t of he){let n=bn.length-t.range.x-V;n>0&&e.push({color:t.color,range:{...t.range,x:t.range.x+V,width:Math.min(n,t.range.width)},style:t.style})}return In!==void 0&&e.push({color:mo(ln.accentColor,0),range:In,style:`dashed`}),Rn!==void 0&&e.push({color:mo(ln.accentColor,.5),range:Rn,style:`solid-outline`}),Bn!==void 0&&Vn!==void 0&&e.push({color:ln.accentColor,range:{x:Bn,y:Vn,width:1,height:1},style:`solid-outline`}),e.length>0?e:void 0},[In,Rn,Bn,Vn,he,bn.length,ln.accentColor,V]),Un=g.useRef(bn);Un.current=bn;let Wn=g.useCallback(([e,t],n=!1)=>{let r=Ut&&t===Pn-1;if(e===0&&Ht)return r?Cd:{kind:li.Marker,allowOverlay:!1,checkboxStyle:kt,checked:H?.rows.hasIndex(t)===!0,markerKind:Tt===`clickable-number`?`number`:Tt,row:Dt+t,drawHandle:ct!==void 0,cursor:Tt===`clickable-number`?`pointer`:void 0};if(r){let t=e===V?Be?.hint??``:``,n=Un.current[e];if(n?.trailingRowOptions?.disabled===!0)return Cd;{let e=n?.trailingRowOptions?.hint??t,r=n?.trailingRowOptions?.addIcon??Be?.addIcon;return{kind:li.NewRow,hint:e,allowOverlay:!1,icon:r}}}{let r=e-V;if(n||et?.strict===!0){let e=Cn.current,n=e.x>r||r>e.x+e.width||e.y>t||t>e.y+e.height||t>=tr.current,i=r===e.extras?.selected?.[0]&&t===e.extras?.selected[1],a=!1;if(e.extras?.freezeRegions!==void 0){for(let n of e.extras.freezeRegions)if(uc(n,r,t)){a=!0;break}}if(n&&!i&&!a)return Cd}let i=x([r,t]);return V!==0&&i.span!==void 0&&(i={...i,span:[i.span[0]+V,i.span[1]+V]}),i}},[Ut,Pn,Ht,kt,H?.rows,Tt,Dt,ct,V,Be?.hint,Be?.addIcon,et?.strict,x]),Gn=g.useCallback(e=>{let t=Oe?.(e)??{name:e};return N!==void 0&&e!==``&&(t={icon:t.icon,name:t.name,overrideTheme:t.overrideTheme,actions:[...t.actions??[],{title:`Rename`,icon:`renameIcon`,onClick:e=>mr({group:t.name,bounds:e.bounds})}]}),t},[Oe,N]),Yn=g.useCallback(e=>{let[t,n]=e.cell,r=bn[t],i=r?.group===void 0?void 0:Gn(r.group)?.overrideTheme,o=r?.themeOverride,s=m?.(n);a({...e,theme:Ss(ln,i,o,s,e.content.themeOverride)})},[m,bn,Gn,ln]),Xn=g.useCallback((e,t,n)=>{if(H.current===void 0)return;let[r,i]=H.current.cell,a=Wn([r,i]);if(a.kind!==K.Boolean&&a.allowOverlay){let t=a;if(n!==void 0)switch(t.kind){case K.Number:{let e=Jn(()=>n===`-`?-0:Number.parseFloat(n),0);t={...t,data:Number.isNaN(e)?0:e};break}case K.Text:case K.Markdown:case K.Uri:t={...t,data:n}}Yn({target:e,content:t,initialValue:n,cell:[r,i],highlight:n===void 0,forceEditMode:n!==void 0})}else a.kind===K.Boolean&&t&&a.readonly!==!0&&(Fn([{location:H.current.cell,value:{...a,data:$u(a.data)}}]),Mn.current?.damage([{cell:H.current.cell}]))},[Wn,H,Fn,Yn]),Zn=g.useCallback((e,t)=>{let n=Mn.current?.getBounds(e,t);if(n===void 0||u.current===null)return;let r=Wn([e,t]);r.allowOverlay&&Yn({target:n,content:r,initialValue:void 0,highlight:!0,cell:[e,t],forceEditMode:!0})},[Wn,Yn]),Qn=g.useCallback((e,t,n=`both`,r=0,i=0,a=void 0)=>{if(u.current!==null){let o=Mn.current,c=s.current,l=typeof e==`number`?e:e.unit===`cell`?e.amount:void 0,d=typeof t==`number`?t:t.unit===`cell`?t.amount:void 0,f=typeof e!=`number`&&e.unit===`px`?e.amount:void 0,p=typeof t!=`number`&&t.unit===`px`?t.amount:void 0;if(o!==null&&c!==null){let s={x:0,y:0,width:0,height:0},m=0,h=0;if((l!==void 0||d!==void 0)&&(s=o.getBounds((l??0)+V,d??0)??s,s.width===0||s.height===0))return;let g=c.getBoundingClientRect(),_=g.width/c.offsetWidth;if(f!==void 0&&(s={...s,x:f-g.left-u.current.scrollLeft,width:1}),p!==void 0&&(s={...s,y:p+g.top-u.current.scrollTop,height:1}),s!==void 0){let o={x:s.x-r,y:s.y-i,width:s.width+2*r,height:s.height+2*i},c=0;for(let e=0;e0&&(l=Ro(Pn,d,Pt));let f=c*_+g.left+V*Vt*_,p=g.right,v=g.top+_n*_,y=g.bottom-l*_,b=s.width+r*2;switch(a?.hAlign){case`start`:p=f+b;break;case`end`:f=p-b;break;case`center`:f=Math.floor((f+p)/2)-b/2,p=f+b}let x=s.height+i*2;switch(a?.vAlign){case`start`:y=v+x;break;case`end`:v=y-x;break;case`center`:v=Math.floor((v+y)/2)-x/2,y=v+x}f>o.x?m=o.x-f:po.y?h=o.y-v:y=Pn-d)&&(h=0),(m!==0||h!==0)&&(_!==1&&(m/=_,h/=_),u.current.scrollTo(m+u.current.scrollLeft,h+u.current.scrollTop))}}}},[V,Ve,Vt,_n,B,mn,Pn,Wt,Pt]),$n=g.useRef(Zn),er=g.useRef(x),tr=g.useRef(b);$n.current=Zn,er.current=x,tr.current=b;let nr=g.useCallback(async(e,t=!0)=>{if(bn[e]?.trailingRowOptions?.disabled===!0)return;let n=pe?.(),r,i=!0;n!==void 0&&(r=await n,r===`top`&&(i=!1),typeof r==`number`&&(i=!1));let a=0,o=()=>{if(tr.current<=b){a<500&&window.setTimeout(o,a),a=50+a*2;return}let n=typeof r==`number`?r:i?b:0;Jr.current(e-V,n),W({cell:[e,n],range:{x:e,y:n,width:1,height:1}},!1,!1,`edit`);let s=er.current([e-V,n]);s.allowOverlay&&oi(s)&&s.readonly!==!0&&t&&window.setTimeout(()=>{$n.current(e,n)},0)};o()},[bn,pe,V,b,W]),rr=g.useCallback(e=>{let t=mn[e]?.trailingRowOptions?.targetColumn??Be?.targetColumn;if(typeof t==`number`)return t+ +!!Ht;if(typeof t==`object`){let e=y.indexOf(t);if(e>=0)return e+ +!!Ht}},[mn,y,Ht,Be?.targetColumn]),ir=g.useRef(),ar=g.useRef(),or=g.useCallback((e,t)=>{let[n,r]=t;return Ss(ln,bn[n]?.themeOverride,m?.(r),e.themeOverride)},[m,bn,ln]),sr=g.useCallback(e=>{let t=ou.value?e.metaKey:e.ctrlKey,n=t&&z===`multi`,r=t&&ge===`multi`,[i,o]=e.location,s=H.columns,c=H.rows,[l,u]=H.current?.cell??[];if(e.kind===`cell`){if(ar.current=void 0,lr.current=[i,o],i===0&&Ht){if(Ut===!0&&o===b||Tt===`number`||z===`none`)return;let r=Wn(e.location);if(r.kind!==li.Marker)return;if(ct!==void 0){let t=pn(r);Kn(t?.kind===li.Marker);let n=t?.onClick?.({...e,cell:r,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,theme:or(r,e.location),preventDefault:()=>void 0});if(n===void 0||n.checked===r.checked)return}a(void 0),Nn();let i=c.hasIndex(o),s=ir.current;if(z===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&s!==void 0&&c.hasIndex(s)){let e=[Math.min(s,o),Math.max(s,o)+1];n||Ee===`multi`?sn(void 0,e,!0):sn(fi.fromSingleSelection(e),void 0,n)}else n||e.isTouch||Ee===`multi`?i?sn(c.remove(o),void 0,!0):(sn(void 0,o,!0),ir.current=o):i&&c.length===1?sn(fi.empty(),void 0,t):(sn(fi.fromSingleSelection(o),void 0,t),ir.current=o)}else if(i>=V&&Ut&&o===b){let e=rr(i);nr(e??i)}else if(l!==i||u!==o){let n=Wn(e.location),r=pn(n);if(r?.onSelect!==void 0){let t=!1;if(r.onSelect({...e,cell:n,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,preventDefault:()=>t=!0,theme:or(n,e.location)}),t)return}let s=Wt&&o===b,c=Wt&&H!==void 0&&H.current?.cell[1]===b;if((e.shiftKey||e.isLongTouch===!0)&&l!==void 0&&u!==void 0&&H.current!==void 0&&!c){if(s)return;let e=Math.min(i,l),n=Math.max(i,l),r=Math.min(o,u),a=Math.max(o,u);W({...H.current,range:{x:e,y:r,width:n-e+1,height:a-r+1}},!0,t,`click`),ir.current=void 0,Nn()}else W({cell:[i,o],range:{x:i,y:o,width:1,height:1}},!0,t,`click`),ir.current=void 0,a(void 0),Nn()}}else if(e.kind===`header`){if(lr.current=[i,o],a(void 0),Ht&&i===0)ir.current=void 0,ar.current=void 0,z===`multi`&&(c.length===b?sn(fi.empty(),void 0,t):sn(fi.fromSingleSelection([0,b]),void 0,t),Nn());else{let n=ar.current;if(ge===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&n!==void 0&&s.hasIndex(n)){let e=[Math.min(n,i),Math.max(n,i)+1];r?cn(void 0,e,t):cn(fi.fromSingleSelection(e),void 0,t)}else r?(s.hasIndex(i)?cn(s.remove(i),void 0,t):cn(void 0,i,t),ar.current=i):ge!==`none`&&(cn(fi.fromSingleSelection(i),void 0,t),ar.current=i);ir.current=void 0,Nn()}}else e.kind===`group-header`?lr.current=[i,o]:e.kind===`out-of-bounds`&&!e.isMaybeScrollbar&&($t(wd,!1),a(void 0),Nn(),je?.(),ir.current=void 0,ar.current=void 0)},[nr,ge,Nn,pn,rr,Wn,H,Ht,Wt,je,ct,V,Tt,z,Ee,b,W,$t,cn,sn,Ut,or]),cr=g.useRef(!1),lr=g.useRef(),ur=g.useRef(En),dr=g.useRef(),fr=g.useCallback(e=>{if(gr.current=!1,ur.current=Cn.current,e.button!==0&&e.button!==1){dr.current=void 0;return}let t=performance.now();dr.current={button:e.button,time:t,location:e.location},e?.kind===`header`&&(cr.current=!0);let n=e.kind===`cell`&&e.isFillHandle;(n||e.kind===`cell`||!e.isEdge)&&(l({previousSelection:H,fillHandle:n}),lr.current=void 0,!e.isTouch&&e.button===0&&!n?sr(e):!e.isTouch&&e.button===1&&(lr.current=e.location))},[H,sr]),[pr,mr]=g.useState(),hr=g.useCallback(e=>{if(e.kind!==`group-header`||ge!==`multi`)return;let t=ou.value?e.metaKey:e.ctrlKey,[n]=e.location,r=H.columns;if(n=V&&ko(i.group,bn[e].group);e--)a--;for(let e=n+1;e{if(Xt!==void 0&&en!==void 0){let t=Cn.current.y,n=Cn.current.height,r=Xt({x:e,y:t,width:1,height:Math.min(n,b-t)},Yt.current.signal);typeof r!=`object`&&(r=await r());let i=mn[e-V],a=document.createElement(`canvas`).getContext(`2d`,{alpha:!1});if(a!==null){a.font=ln.baseFontFull;let t=Ts(a,ln,i,0,r,At,jt,!1,pn);en?.(i,t.width,e,t.width)}}},[mn,Xt,jt,ln,At,en,V,b,pn]),[vr,yr]=g.useState(),br=g.useCallback(async(e,t)=>{let n=e.current?.range;if(n===void 0||Xt===void 0||t.current===void 0)return;let r=t.current.range;if(w!==void 0){let e=!1;if(w({fillDestination:{...r,x:r.x-V},patternSource:{...n,x:n.x-V},preventDefault:()=>e=!0}),e)return}let i=Xt(n,Yt.current.signal);typeof i!=`object`&&(i=await i());let a=i,o=[];for(let e=0;e({cell:e.location})))},[Xt,Fn,w,V]),xr=g.useCallback(()=>{if(H.current===void 0||H.current.range.width<=1)return;let e={...H,current:{...H.current,range:{...H.current.range,width:1}}};br(e,H)},[br,H]),Sr=g.useCallback(()=>{if(H.current===void 0||H.current.range.height<=1)return;let e={...H,current:{...H.current,range:{...H.current.range,height:1}}};br(e,H)},[br,H]),Cr=g.useCallback((e,t)=>{let n=c;if(l(void 0),Ln(void 0),yr(void 0),cr.current=!1,t)return;if(n?.fillHandle===!0&&H.current!==void 0&&n.previousSelection?.current!==void 0){if(In===void 0)return;let e={...H,current:{...H.current,range:dc(n.previousSelection.current.range,In)}};br(n.previousSelection,e),$t(e,!0);return}let[r,i]=e.location,[a,o]=lr.current??[],s=()=>{gr.current=!0},u=t=>{let c=t.isTouch||a===r&&o===i;if(c&&S?.([r-V,i],{...t,preventDefault:s}),t.button===1)return!gr.current;if(!gr.current){let a=Wn(e.location),o=pn(a);if(o!==void 0&&o.onClick!==void 0&&c){let n=o.onClick({...t,cell:a,posX:t.localEventX,posY:t.localEventY,bounds:t.bounds,theme:or(a,e.location),preventDefault:s});n!==void 0&&!ai(n)&&ii(n)&&(Fn([{location:t.location,value:n}]),Mn.current?.damage([{cell:t.location}]))}if(gr.current||H.current===void 0)return!1;let l=!1;switch(a.activationBehaviorOverride??Te){case`double-click`:case`second-click`:{if(n?.previousSelection?.current?.cell===void 0)break;let[e,a]=H.current.cell,[o,s]=n.previousSelection.current.cell;l=r===e&&r===o&&i===a&&i===s&&(t.isDoubleClick===!0||Te===`second-click`);break}case`single-click`:l=!0}if(l)return C?.([r-V,i]),Xn(t.bounds,!1),!0}return!1},d=e.location[0]-V;if(e.isTouch){let t=Cn.current,n=ur.current;if(t.x!==n.x||t.y!==n.y)return;if(e.isLongTouch===!0){if(e.kind===`cell`&&Mo(H.current?.cell,e.location)){re?.([d,e.location[1]],{...e,preventDefault:s});return}if(e.kind===`header`&&H.columns.hasIndex(r)){M?.(d,{...e,preventDefault:s});return}if(e.kind===`group-header`){if(d<0)return;ae?.(d,{...e,preventDefault:s});return}}e.kind===`cell`?u(e)||sr(e):e.kind===`group-header`?ne?.(d,{...e,preventDefault:s}):(e.kind===`header`&&A?.(d,{...e,preventDefault:s}),sr(e))}else{if(e.kind===`header`){if(d<0)return;e.isEdge?e.isDoubleClick===!0&&_r(r):e.button===0&&r===a&&i===o&&A?.(d,{...e,preventDefault:s})}if(e.kind===`group-header`){if(d<0)return;e.button===0&&r===a&&i===o&&(ne?.(d,{...e,preventDefault:s}),gr.current||hr(e))}e.kind===`cell`&&(e.button===0||e.button===1)&&u(e),lr.current=void 0}},[c,H,V,In,br,$t,S,Wn,pn,Te,or,Fn,C,Xn,re,M,ae,sr,ne,A,_r,hr]),wr=g.useCallback(e=>{let t={...e,location:[e.location[0]-V,e.location[1]]};Se?.(t),c!==void 0&&e.buttons===0&&(l(void 0),Ln(void 0),yr(void 0),cr.current=!1),yr(t=>cr.current?[e.scrollEdge[0],0]:e.scrollEdge[0]===t?.[0]&&e.scrollEdge[1]===t[1]?t:c===void 0||(dr.current?.location[0]??0){De?.(e-V,t)},[De,V]),Er=H?.current?.cell,Dr=g.useCallback((e,t,n,r,i,a)=>{Tn.current=!1;let o=Er;o!==void 0&&(o=[o[0]-V,o[1]]);let s=B===0?void 0:{x:0,y:e.y,width:B,height:e.height},c=[];s!==void 0&&c.push(s),Ve>0&&(c.push({x:e.x-V,y:b-Ve,width:e.width,height:Ve}),B>0&&c.push({x:0,y:b-Ve,width:B,height:Ve}));let l={x:e.x-V,y:e.y,width:e.width,height:Ut&&e.y+e.height>=b?e.height-1:e.height,tx:i,ty:a,extras:{selected:o,freezeRegion:s,freezeRegions:c}};Cn.current=l,G(l),dn([t,n,r]),Ne?.(l,l.tx,l.ty,l.extras)},[Er,V,Ut,b,B,Ve,G,Ne]),Or=Ji(me,g.useCallback((e,t)=>{me?.(e-V,t-V),ge!==`none`&&cn(fi.fromSingleSelection(t),void 0,!0)},[ge,me,V,cn])),kr=g.useRef(!1),Ar=g.useCallback(e=>{e.location[0]===0&&V>0?e.preventDefault():(xe?.({...e,location:[e.location[0]-V,e.location[1]]}),e.defaultPrevented()||(kr.current=!0),l(void 0))},[xe,V]),jr=g.useCallback(()=>{kr.current=!1},[]),Mr=g.useRef(),Nr=g.useCallback(e=>{if(!fu(e,Mr.current)&&(Mr.current=e,!(dr?.current?.button!==void 0&&dr.current.button>=1))){if(e.buttons!==0&&c!==void 0&&dr.current?.location[0]===0&&e.location[0]===0&&V===1&&z===`multi`&&c.previousSelection&&!c.previousSelection.rows.hasIndex(dr.current.location[1])&&H.rows.hasIndex(dr.current.location[1])){let t=Math.min(dr.current.location[1],e.location[1]),n=Math.max(dr.current.location[1],e.location[1])+1;sn(fi.fromSingleSelection([t,n]),void 0,!1)}if(e.buttons!==0&&c!==void 0&&H.current!==void 0&&!kr.current&&!cr.current&&(R===`rect`||R===`multi-rect`)){let[t,n]=H.current.cell,[r,i]=e.location;if(i<0&&(i=Cn.current.y),c.fillHandle===!0&&c.previousSelection?.current!==void 0){let e=c.previousSelection.current.range;i=Math.min(i,Ut?b-1:b);let t=cc(e,r,i,He);Ln(t)}else{if(Ut&&n===b)return;if(Ut&&i===b){if(e.kind===`out-of-bounds`)i--;else return}r=Math.max(r,V);let a=r-t,o=i-n,s={x:a>=0?t:r,y:o>=0?n:i,width:Math.abs(a)+1,height:Math.abs(o)+1};W({...H.current,range:s},!0,!1,`drag`)}}Ae?.({...e,location:[e.location[0]-V,e.location[1]]})}},[He,c,V,z,H,R,Ae,sn,Ut,b,W]);ad(vr,u,g.useCallback(()=>{let e=Mr.current;if(e===void 0)return;let[t,n]=e.scrollEdge,[r,i]=e.location,a=Cn.current;t===-1?r=a.extras?.freezeRegion?.x??a.x:t===1&&(r=a.x+a.width),n===-1?i=Math.max(0,a.y):n===1&&(i=Math.min(b-1,a.y+a.height)),r=(0,Ql.default)(r,0,bn.length-1),i=(0,Ql.default)(i,0,b-1),Nr({...e,location:[r,i]})},[bn.length,Nr,b]));let Pr=g.useCallback(e=>{if(H.current===void 0)return;let[t,n]=e,[r,i]=H.current.cell,a=H.current.range,o=a.x,s=a.x+a.width,c=a.y,l=a.y+a.height;if(n!==0)switch(n){case 2:l=b,c=i,Qn(0,l,`vertical`);break;case-2:c=0,l=i+1,Qn(0,c,`vertical`);break;case 1:ci+1?(l--,Qn(0,l,`vertical`)):(c=Math.max(0,c-1),Qn(0,c,`vertical`));break;default:qn(n)}if(t!==0){if(t===2)s=bn.length,o=r,Qn(s-1-V,0,`horizontal`);else if(t===-2)o=V,s=r+1,Qn(o-V,0,`horizontal`);else{let e=[];if(Xt!==void 0){let t=Xt({x:o,y:c,width:s-o-V,height:l-c},Yt.current.signal);typeof t==`object`&&(e=xd(t))}if(t===1){let t=!1;if(o0){let n=(0,pu.default)(o+1,r+1).find(t=>!e.includes(t-V));n!==void 0&&(o=n,t=!0)}else o++,t=!0;t&&Qn(o,0,`horizontal`)}t||(s=Math.min(bn.length,s+1),Qn(s-1-V,0,`horizontal`))}else if(t===-1){let t=!1;if(s>r+1){if(e.length>0){let n=(0,pu.default)(s-1,r,-1).find(t=>!e.includes(t-V));n!==void 0&&(s=n,t=!0)}else s--,t=!0;t&&Qn(s-V,0,`horizontal`)}t||(o=Math.max(V,o-1),Qn(o-V,0,`horizontal`))}else qn(t)}}W({cell:H.current.cell,range:{x:o,y:c,width:s-o,height:l-c}},!0,!1,`keyboard-select`)},[Xt,H,bn.length,V,b,Qn,W]),Fr=g.useCallback((e,t,n,r)=>{let i=Pn-+!n;if(e=(0,Ql.default)(e,V,mn.length-1+V),t=(0,Ql.default)(t,0,i),e===Er?.[0]&&t===Er?.[1])return!1;if(r&&H.current!==void 0){let n=[...H.current.rangeStack];(H.current.range.width>1||H.current.range.height>1)&&n.push(H.current.range),$t({...H,current:{cell:[e,t],range:{x:e,y:t,width:1,height:1},rangeStack:n}},!0)}else W({cell:[e,t],range:{x:e,y:t,width:1,height:1}},!0,!1,`keyboard-nav`);return d.current!==void 0&&d.current[0]===e&&d.current[1]===t&&(d.current=void 0),Qn(e-V,t),!0},[Pn,V,mn.length,Er,H,Qn,$t,W]),Ir=g.useCallback((e,t)=>{i?.cell!==void 0&&e!==void 0&&ii(e)&&(Fn([{location:i.cell,value:e}]),window.requestAnimationFrame(()=>{Mn.current?.damage([{cell:i.cell}])})),Nn(!0),a(void 0);let[n,r]=t;if(H.current!==void 0&&(n!==0||r!==0)){let t=H.current.cell[1]===Pn-1&&e!==void 0;Fr((0,Ql.default)(H.current.cell[0]+n,0,bn.length-1),(0,Ql.default)(H.current.cell[1]+r,0,Pn-1),t,!1)}T?.(e,t)},[i?.cell,Nn,H,T,Fn,Pn,Fr,bn.length]),Lr=g.useMemo(()=>`gdg-overlay-${bd++}`,[]),Rr=g.useCallback(e=>{Nn();let t=[];for(let n=e.x;n({cell:e.location})))},[Nn,x,pn,Fn,V]),zr=i!==void 0,Br=g.useCallback(e=>{let t=()=>{e.stopPropagation(),e.preventDefault()},n={didMatch:!1},{bounds:r}=e,i=H.columns,s=H.rows,c=Bt;if(!zr&&Fu(c.clear,e,n))$t(wd,!1),je?.();else if(!zr&&Fu(c.selectAll,e,n))$t({columns:fi.empty(),rows:fi.empty(),current:{cell:H.current?.cell??[V,0],range:{x:V,y:0,width:y.length,height:b},rangeStack:[]}},!1);else if(Fu(c.search,e,n))o?.current?.focus({preventScroll:!0}),Kt(!0);else if(Fu(c.delete,e,n)){let e=on?.(H)??!0;if(e!==!1){let t=e===!0?H:e;if(t.current!==void 0){Rr(t.current.range);for(let e of t.current.rangeStack)Rr(e)}for(let e of t.rows)Rr({x:V,y:e,width:y.length,height:1});for(let e of t.columns)Rr({x:e,y:0,width:1,height:b})}}if(n.didMatch)return t(),!0;if(H.current===void 0)return!1;let[l,u]=H.current.cell,d=!1,f=!1;Fu(c.scrollToSelectedCell,e,n)?Jr.current(l-V,u):ge!==`none`&&Fu(c.selectColumn,e,n)?i.hasIndex(l)?cn(i.remove(l),void 0,!0):ge===`single`?cn(fi.fromSingleSelection(l),void 0,!0):cn(void 0,l,!0):z!==`none`&&Fu(c.selectRow,e,n)?s.hasIndex(u)?sn(s.remove(u),void 0,!0):z===`single`?sn(fi.fromSingleSelection(u),void 0,!0):sn(void 0,u,!0):!zr&&r!==void 0&&Fu(c.activateCell,e,n)?u===b&&Ut?window.setTimeout(()=>{let e=rr(l);nr(e??l)},0):(C?.([l-V,u]),Xn(r,!0)):H.current.range.height>1&&Fu(c.downFill,e,n)?Sr():H.current.range.width>1&&Fu(c.rightFill,e,n)?xr():Fu(c.goToNextPage,e,n)?u+=Math.max(1,Cn.current.height-4):Fu(c.goToPreviousPage,e,n)?u-=Math.max(1,Cn.current.height-4):Fu(c.goToFirstCell,e,n)?(a(void 0),u=0,l=0):Fu(c.goToLastCell,e,n)?(a(void 0),u=2**53-1,l=2**53-1):Fu(c.selectToFirstCell,e,n)?(a(void 0),Pr([-2,-2])):Fu(c.selectToLastCell,e,n)?(a(void 0),Pr([2,2])):zr?(Fu(c.closeOverlay,e,n)&&a(void 0),Fu(c.acceptOverlayDown,e,n)&&(a(void 0),u++),Fu(c.acceptOverlayUp,e,n)&&(a(void 0),u--),Fu(c.acceptOverlayLeft,e,n)&&(a(void 0),l--),Fu(c.acceptOverlayRight,e,n)&&(a(void 0),l++)):(Fu(c.goDownCell,e,n)?u+=1:Fu(c.goUpCell,e,n)?--u:Fu(c.goRightCell,e,n)?l+=1:Fu(c.goLeftCell,e,n)?--l:Fu(c.goDownCellRetainSelection,e,n)?(u+=1,d=!0):Fu(c.goUpCellRetainSelection,e,n)?(--u,d=!0):Fu(c.goRightCellRetainSelection,e,n)?(l+=1,d=!0):Fu(c.goLeftCellRetainSelection,e,n)?(--l,d=!0):Fu(c.goToLastRow,e,n)?u=b-1:Fu(c.goToFirstRow,e,n)?u=-(2**53-1):Fu(c.goToLastColumn,e,n)?l=2**53-1:Fu(c.goToFirstColumn,e,n)?l=-(2**53-1):(R===`rect`||R===`multi-rect`)&&(Fu(c.selectGrowDown,e,n)?Pr([0,1]):Fu(c.selectGrowUp,e,n)?Pr([0,-1]):Fu(c.selectGrowRight,e,n)?Pr([1,0]):Fu(c.selectGrowLeft,e,n)?Pr([-1,0]):Fu(c.selectToLastRow,e,n)?Pr([0,2]):Fu(c.selectToFirstRow,e,n)?Pr([0,-2]):Fu(c.selectToLastColumn,e,n)?Pr([2,0]):Fu(c.selectToFirstColumn,e,n)&&Pr([-2,0])),f=n.didMatch);let p=Fr(l,u,!1,d),m=n.didMatch;return m&&(p||!f||mt)&&t(),m},[zr,H,Bt,ge,z,R,V,b,Fr,$t,je,y.length,on,mt,Rr,cn,sn,Ut,rr,nr,C,Xn,Sr,xr,Pr]),Vr=g.useCallback(e=>{let t=!1;if(le!==void 0&&le({...e,cancel:()=>{t=!0}}),t||Br(e)||H.current===void 0)return;let[n,r]=H.current.cell,i=Cn.current;if(fe&&!e.metaKey&&!e.ctrlKey&&H.current!==void 0&&e.key.length===1&&/[ -~]/g.test(e.key)&&e.bounds!==void 0&&oi(x([n-V,Math.max(0,Math.min(r,b-1))]))){if((!Ut||r!==b)&&(i.y>r||r>i.y+i.height||i.x>n||n>i.x+i.width))return;Xn(e.bounds,!0,e.key),e.stopPropagation(),e.preventDefault()}},[fe,le,Br,H,x,V,b,Ut,Xn]),Hr=g.useCallback((e,t)=>{let n=e.location[0]-V;if(e.kind===`header`&&M?.(n,{...e,preventDefault:t}),e.kind===`group-header`){if(n<0)return;ae?.(n,{...e,preventDefault:t})}if(e.kind===`cell`){let[r,i]=e.location;re?.([n,i],{...e,preventDefault:t}),Oo(H,e.location)||Fr(r,i,!1,!1)}},[H,re,ae,M,V,Fr]),Ur=g.useCallback(async e=>{if(!Bt.paste)return;function t(e,t,n,r){let i=typeof n==`object`?n?.join(` +`)??``:n?.toString()??``;if(!ai(e)&&oi(e)&&e.readonly!==!0){let a=E?.(i,e);if(a!==void 0&&ii(a))return{location:t,value:a};let o=pn(e);if(o===void 0)return;if(o.kind===K.Custom){Kn(e.kind===K.Custom);let n=o.onPaste?.(i,e.data);return n===void 0?void 0:{location:t,value:{...e,data:n}}}{let a=o.onPaste?.(i,e,{formatted:r,formattedString:typeof r==`string`?r:r?.join(` +`),rawValue:n});return a===void 0?void 0:(Kn(a.kind===e.kind),{location:t,value:a})}}}let n=H.columns,r=H.rows,i=u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,a;if(H.current===void 0?n.length===1?a=[n.first()??0,0]:r.length===1&&(a=[V,r.first()??0]):a=[H.current.range.x,H.current.range.y],i&&a!==void 0){let n,r,i=`text/plain`,o=`text/html`;if(navigator.clipboard.read!==void 0){let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(o)){let e=Ju(await(await t.getType(o)).text());if(e!==void 0){n=e;break}}t.types.includes(i)&&(r=await(await t.getType(i)).text())}}else if(navigator.clipboard.readText!==void 0)r=await navigator.clipboard.readText();else if(e!==void 0&&e?.clipboardData!==null)e.clipboardData.types.includes(o)&&(n=Ju(e.clipboardData.getData(o))),n===void 0&&e.clipboardData.types.includes(i)&&(r=e.clipboardData.getData(i));else return;let[s,c]=a,l=[];do if(Ce===void 0){let e=Wn(a),i=r??n?.map(e=>e.map(e=>e.rawValue).join(` `)).join(` `)??``,o=t(e,a,i,void 0);o!==void 0&&l.push(o)}else{if(n===void 0){if(r===void 0)return;n=Zu(r)}if(Ce===!1||typeof Ce==`function`&&Ce?.([a[0]-V,a[1]],n.map(e=>e.map(e=>e.rawValue?.toString()??``)))!==!0)return;for(let[e,r]of n.entries()){if(e+c>=b)break;for(let[n,i]of r.entries()){let r=[n+s,e+c],[a,o]=r;if(a>=bn.length||o>=Pn)continue;let u=t(Wn(r),r,i.rawValue,i.formatted);u!==void 0&&l.push(u)}}}while(0);Fn(l),Mn.current?.damage(l.map(e=>({cell:e.location})))}},[E,pn,Wn,H,Bt.paste,bn.length,Fn,Pn,Ce,V,b]);qi(`paste`,Ur,f,!1,!0);let Wr=g.useCallback(async(e,t)=>{if(!Bt.copy)return;let n=t===!0||u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,r=H.columns,i=H.rows,a=(t,n)=>{Qu(we?[n.map(e=>({kind:K.Text,data:y[e].title,displayData:y[e].title,allowOverlay:!1})),...t]:t,n,e)};if(n&&Xt!==void 0){if(H.current!==void 0){let e=Xt(H.current.range,Yt.current.signal);typeof e!=`object`&&(e=await e()),a(e,(0,pu.default)(H.current.range.x-V,H.current.range.x+H.current.range.width-V))}else if(i!==void 0&&i.length>0){let e=[...i].map(e=>{let t=Xt({x:V,y:e,width:y.length,height:1},Yt.current.signal);return typeof t==`object`?t[0]:t().then(e=>e[0])});e.some(e=>e instanceof Promise)?a(await Promise.all(e),(0,pu.default)(y.length)):a(e,(0,pu.default)(y.length))}else if(r.length>0){let e=[],t=[];for(let n of r){let r=Xt({x:n,y:0,width:1,height:b},Yt.current.signal);typeof r!=`object`&&(r=await r()),e.push(r),t.push(n-V)}e.length===1?a(e[0],t):a(e.reduce((e,t)=>e.map((e,n)=>[...e,...t[n]])),t)}}},[y,Xt,H,Bt.copy,V,b,we]);qi(`copy`,Wr,f,!1,!1),qi(`cut`,g.useCallback(async e=>{if(Bt.cut&&(u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0)&&(await Wr(e),H.current!==void 0)){let e={current:{cell:H.current.cell,range:H.current.range,rangeStack:[]},rows:fi.empty(),columns:fi.empty()},t=on?.(e);if(t===!1||(e=t===!0?e:t,e.current===void 0))return;Rr(e.current.range)}},[Rr,H,Bt.cut,Wr,on]),f,!1,!1);let Gr=g.useCallback((e,t)=>{if(F!==void 0){V!==0&&(e=e.map(e=>[e[0]-V,e[1]])),F(e,t);return}if(e.length===0||t===-1)return;let[n,r]=e[t];(d.current===void 0||d.current[0]!==n||d.current[1]!==r)&&(d.current=[n,r],Fr(n,r,!1,!1))},[F,V,Fr]),[Kr,qr]=Pe?.current?.cell??[],Jr=g.useRef(Qn);Jr.current=Qn,g.useLayoutEffect(()=>{Tn.current||Kr===void 0||qr===void 0||Kr===U.current?.current?.cell[0]&&qr===U.current?.current?.cell[1]||Jr.current(Kr,qr),Tn.current=!1},[Kr,qr]);let Yr=H.current!==void 0&&(H.current.cell[0]>=bn.length||H.current.cell[1]>=Pn);g.useLayoutEffect(()=>{Yr&&$t(wd,!1)},[Yr,$t]);let Xr=g.useMemo(()=>Ut===!0&&Be?.tint===!0?fi.fromSingleSelection(Pn-1):fi.empty(),[Pn,Ut,Be?.tint]),Zr=g.useCallback(e=>typeof Ge==`boolean`?Ge:Ge?.(e-V)??!0,[V,Ge]),Qr=g.useMemo(()=>{if(pr===void 0||s.current===null)return null;let{bounds:e,group:t}=pr,n=s.current.getBoundingClientRect();return g.createElement(Nu,{bounds:e,group:t,canvasBounds:n,onClose:()=>mr(void 0),onFinish:e=>{mr(void 0),N?.(t,e)}})},[N,pr]),$r=Math.min(bn.length,B+ +!!Ht);g.useImperativeHandle(t,()=>({appendRow:(e,t)=>nr(e+V,t),updateCells:e=>(V!==0&&(e=e.map(e=>({cell:[e.cell[0]+V,e.cell[1]]}))),Mn.current?.damage(e)),getBounds:(e,t)=>{if(s?.current!==null&&u?.current!==null){if(e===void 0&&t===void 0){let e=s.current.getBoundingClientRect(),t=e.width/u.current.clientWidth;return{x:e.x-u.current.scrollLeft*t,y:e.y-u.current.scrollTop*t,width:u.current.scrollWidth*t,height:u.current.scrollHeight*t}}return Mn.current?.getBounds((e??0)+V,t)}},focus:()=>Mn.current?.focus(),emit:async e=>{switch(e){case`delete`:Vr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!1,key:`Delete`,keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-right`:Vr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`r`,keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-down`:Vr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`d`,keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`copy`:await Wr(void 0,!0);break;case`paste`:await Ur()}},scrollTo:Qn,remeasureColumns:e=>{for(let t of e)_r(t+V)}}),[nr,_r,Wr,Vr,Ur,V,Qn]);let[ei,ti]=Er??[],ni=g.useCallback(e=>{let[t,n]=e;n===-1?ge!==`none`&&(cn(fi.fromSingleSelection(t),void 0,!1),Nn()):(ei!==t||ti!==n)&&(W({cell:e,range:{x:t,y:n,width:1,height:1}},!0,!1,`keyboard-nav`),Qn(t,n))},[ge,Nn,Qn,ei,ti,W,cn]),[ri,ci]=g.useState(!1),ui=g.useRef((0,Ki.default)(e=>{ci(e)},5)),di=g.useCallback(()=>{ui.current(!0),H.current===void 0&&H.columns.length===0&&H.rows.length===0&&c===void 0&&W({cell:[V,jn],range:{x:V,y:jn,width:1,height:1}},!0,!1,`keyboard-select`)},[jn,H,c,V,W]),pi=g.useCallback(()=>{ui.current(!1)},[]),[mi,hi]=g.useMemo(()=>{let e,t=et?.scrollbarWidthOverride??sa(),n=b+ +!!Ut;if(typeof Pt==`number`)e=_n+n*Pt;else{let t=0,r=Math.min(n,10);for(let e=0;et.width+e,0)+t;return[`${Math.min(1e5,r)}px`,`${Math.min(1e5,e)}px`]},[bn,et?.scrollbarWidthOverride,Pt,b,Ut,_n]),gi=g.useMemo(()=>vs(ln),[ln]);return g.createElement(xs.Provider,{value:ln},g.createElement(nd,{style:gi,className:j,inWidth:_??mi,inHeight:v??hi},g.createElement(Au,{fillHandle:Qe,drawFocusRing:$e,experimental:et,fixedShadowX:tt,fixedShadowY:nt,getRowThemeOverride:m,headerIcons:rt,imageWindowLoader:it,initialSize:at,isDraggable:ot,onDragLeave:st,onRowMoved:ct,overscrollX:Rt,overscrollY:zt,preventDiagonalScrolling:dt,rightElement:ft,rightElementProps:pt,smoothScrollX:ht,smoothScrollY:gt,className:j,enableGroups:gn,onCanvasFocused:di,onCanvasBlur:pi,canvasRef:s,onContextMenu:Hr,theme:ln,cellXOffset:An,cellYOffset:jn,accessibilityHeight:En.height,onDragEnd:jr,columns:bn,nonGrowWidth:hn,drawHeader:rn,onColumnProposeMove:ee,drawCell:an,disabledRows:Xr,freezeColumns:$r,lockColumns:V,firstColAccessible:V===0,getCellContent:Wn,minColumnWidth:At,maxColumnWidth:jt,searchInputRef:o,showSearch:qt,onSearchClose:Jt,highlightRegions:Hn,getCellsForSelection:Xt,getGroupDetails:Gn,headerHeight:Ft,isFocused:ri,groupHeaderHeight:gn?It:0,freezeTrailingRows:Ve+(Ut&&Be?.sticky===!0?1:0),hasAppendRow:Ut,onColumnResize:en,onColumnResizeEnd:tn,onColumnResizeStart:nn,onCellFocused:ni,onColumnMoved:Or,onDragStart:Ar,onHeaderMenuClick:Tr,onItemHovered:Nr,isFilling:c?.fillHandle===!0,onMouseMove:wr,onKeyDown:Vr,onKeyUp:ue,onMouseDown:fr,onMouseUp:Cr,onDragOverCell:Ke,onDrop:qe,onSearchResultsChanged:Gr,onVisibleRegionChanged:Dr,clientSize:un,rowHeight:Pt,searchResults:se,searchValue:ce,onSearchValueChange:I,rows:Pn,scrollRef:u,selection:H,translateX:En.tx,translateY:En.ty,verticalBorder:Zr,gridRef:Mn,getCellRenderer:pn}),Qr,i!==void 0&&g.createElement(g.Suspense,{fallback:null},g.createElement(yd,{...i,validateCell:Qt,bloom:k,id:Lr,getCellRenderer:pn,className:et?.isSubGrid===!0?`click-outside-ignore`:void 0,provideEditor:ze,imageEditorOverride:p,onFinishEditing:Ir,markdownDivCreateNode:h,isOutsideClick:St}))))}),Ed=20,Dd={getAccessibilityString:e=>e.data?.toString()??`false`,kind:K.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>Od(e,e.cell.data,ci(e.cell),e.cell.maxSize??Ed),onDelete:e=>({...e,data:!1}),onClick:e=>{let{cell:t,posX:n,posY:r,bounds:i,theme:a}=e,{width:o,height:s,x:c,y:l}=i,u=t.maxSize??Ed,d=Math.floor(i.y+s/2),f=$i(u,s,a.cellVerticalPadding),p=Zi(Qi(t.contentAlign??`center`,c,o,a.cellHorizontalPadding,f),d,f),m=ea(c+n,l+r,p);if(ci(t)&&m)return{...t,data:$u(t.data)}},onPaste:(e,t)=>{let n=null;return e.toLowerCase()===`true`?n=!0:e.toLowerCase()===`false`?n=!1:e.toLowerCase()===`indeterminate`&&(n=void 0),n===t.data?void 0:{...t,data:n}}};function Od(e,t,n,r){if(!n&&t===null)return;let{ctx:i,hoverAmount:a,theme:o,rect:s,highlighted:c,hoverX:l,hoverY:u,cell:{contentAlign:d}}=e,{x:f,y:p,width:m,height:h}=s,g=n?.65+.35*a:.4;t===null&&(g*=a),g!==0&&(i.globalAlpha=g,Sc(i,o,t,f,p,m,h,c,l,u,r,d),i.globalAlpha=1)}var kd=Si(`div`)({name:`BubblesOverlayEditorStyle`,class:`gdg-b1ygi5by`,propsAsIs:!1}),Ad=e=>{let{bubbles:t}=e;return g.createElement(kd,null,t.map((e,t)=>g.createElement(`div`,{key:t,className:`boe-bubble`},e)),g.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))},jd={getAccessibilityString:e=>ua(e.data),kind:K.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n).width+t+20,0)+2*n.cellHorizontalPadding-4,draw:e=>Nd(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return g.createElement(Ad,{bubbles:t.data})},onPaste:()=>void 0},Md=4;function Nd(e,t){let{rect:n,theme:r,ctx:i,highlighted:a}=e,{x:o,y:s,width:c,height:l}=n,u=Md,d=o+r.cellHorizontalPadding,f=[];for(let e of t){if(d>o+c)break;let t=qo(e,i,r.baseFontFull).width;f.push({x:d,width:t}),d+=t+16+u}i.beginPath();for(let e of f)os(i,e.x,s+(l-20)/2,e.width+16,20,r.roundingRadius??10);i.fillStyle=a?r.bgBubbleSelected:r.bgBubble,i.fill();for(let[e,n]of f.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(t[e],n.x+8,s+l/2+Yo(i,r))}var Pd=Si(`div`)({name:`DrilldownOverlayEditorStyle`,class:`gdg-d4zsq0x`,propsAsIs:!1}),Fd=e=>{let{drilldowns:t}=e;return g.createElement(Pd,null,t.map((e,t)=>g.createElement(`div`,{key:t,className:`doe-bubble`},e.img!==void 0&&g.createElement(`img`,{src:e.img}),g.createElement(`div`,null,e.text))))},Id={getAccessibilityString:e=>ua(e.data.map(e=>e.text)),kind:K.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n.text).width+t+20+(n.img===void 0?0:18),0)+2*n.cellHorizontalPadding-4,draw:e=>Bd(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return g.createElement(Fd,{drilldowns:t.data})},onPaste:()=>void 0},Ld=4,Rd={};function zd(e,t,n,r){let i=Math.ceil(window.devicePixelRatio),a=n-10,o=n*i,s=r+5,c=r*3,l=(c+10)*i,u=`${e},${t},${i},${n}`;if(Rd[u]!==void 0)return{el:Rd[u],height:o,width:l,middleWidth:4*i,sideWidth:s*i,padding:5*i,dpr:i};let d=document.createElement(`canvas`),f=d.getContext(`2d`);return f===null?null:(d.width=l,d.height=o,f.scale(i,i),Rd[u]=d,f.beginPath(),os(f,5,5,c,a,r),f.shadowColor=`rgba(24, 25, 34, 0.4)`,f.shadowBlur=1,f.fillStyle=e,f.fill(),f.shadowColor=`rgba(24, 25, 34, 0.3)`,f.shadowOffsetY=1,f.shadowBlur=5,f.fillStyle=e,f.fill(),f.shadowOffsetY=0,f.shadowBlur=0,f.shadowBlur=0,f.beginPath(),os(f,5.5,5.5,c,a,r),f.strokeStyle=t,f.lineWidth=1,f.stroke(),{el:d,height:o,width:l,sideWidth:s*i,middleWidth:r*i,padding:5*i,dpr:i})}function Bd(e,t){let{rect:n,theme:r,ctx:i,imageLoader:a,col:o,row:s}=e,{x:c,width:l}=n,u=r.baseFontFull,d=ns(i,u),f=Math.min(n.height,Math.max(16,Math.ceil(d*r.lineHeight)*2)),p=Math.floor(n.y+(n.height-f)/2),m=f-10,h=Ld,g=c+r.cellHorizontalPadding,_=r.roundingRadius??6,v=zd(r.bgCell,r.drilldownBorder,f,_),y=[];for(let e of t){if(g>c+l)break;let t=qo(e.text,i,u).width,n=0;e.img!==void 0&&a.loadOrGetImage(e.img,o,s)!==void 0&&(n=m-8+4);let r=t+n+16;y.push({x:g,width:r}),g+=r+h}if(v!==null){let{el:e,height:t,middleWidth:n,sideWidth:r,width:a,dpr:o,padding:s}=v,c=r/o,l=s/o;for(let o of y){let s=Math.floor(o.x),u=Math.floor(o.width),d=u-(c-l)*2;i.imageSmoothingEnabled=!1,i.drawImage(e,0,0,r,t,s-l,p,c,f),d>0&&i.drawImage(e,r,0,n,t,s+(c-l),p,d,f),i.drawImage(e,a-r,0,r,t,s+u-(c-l),p,c,f),i.imageSmoothingEnabled=!0}}i.beginPath();for(let[e,n]of y.entries()){let c=t[e],l=n.x+8;if(c.img!==void 0){let e=a.loadOrGetImage(c.img,o,s);if(e!==void 0){let t=m-8,n=0,a=0,o=e.width,s=e.height;o>s?(n+=(o-s)/2,o=s):s>o&&(a+=(s-o)/2,s=o),i.beginPath(),os(i,l,p+f/2-t/2,t,t,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(e,n,a,o,s,l,p+f/2-t/2,t,t),i.restore(),l+=t+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(c.text,l,p+f/2+Yo(i,r))}}var Vd={getAccessibilityString:e=>e.data.join(`, `),kind:K.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:e=>Ud(e,e.cell.displayData??e.cell.data,e.cell.rounding??e.theme.roundingRadius??4,e.cell.contentAlign),measure:(e,t)=>t.data.length*50,onDelete:e=>({...e,data:[]}),provideEditor:()=>e=>{let{value:t,onFinishedEditing:n,imageEditorOverride:r}=e,i=r??pa;return g.createElement(i,{urls:t.data,canWrite:t.readonly!==!1,onCancel:n,onChange:e=>{n({...t,data:[e]})}})},onPaste:(e,t)=>{e=e.trim();let n=e.split(`,`).map(e=>{try{return new URL(e),e}catch{return}}).filter(e=>e!==void 0);if(!(n.length===t.data.length&&n.every((e,n)=>e===t.data[n])))return{...t,data:n}}},Hd=4;function Ud(e,t,n,r){let{rect:i,col:a,row:o,theme:s,ctx:c,imageLoader:l}=e,{x:u,y:d,height:f,width:p}=i,m=f-s.cellVerticalPadding*2,h=[],g=0;for(let e=0;e0&&(c.beginPath(),os(c,_,d+s.cellVerticalPadding,t,m,n),c.save(),c.clip()),c.drawImage(e,_,d+s.cellVerticalPadding,t,m),n>0&&c.restore(),_+=t+Hd}}function Wd(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}var Gd={getAccessibilityString:()=>``,kind:K.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:e=>{let{cell:t,col:n,row:r,ctx:i,rect:a,theme:o}=e;if(t.skeletonWidth===void 0||t.skeletonWidth===0)return;let s=t.skeletonWidth;t.skeletonWidthVariability!==void 0&&t.skeletonWidthVariability>0&&(s+=Math.round(Wd(n,r)*t.skeletonWidthVariability));let c=o.cellHorizontalPadding,l=t.skeletonHeight??Math.min(18,a.height-2*o.cellVerticalPadding);os(i,a.x+c,a.y+(a.height-l)/2,s,l,o.roundingRadius??3),i.fillStyle=mo(o.textDark,.1),i.fill()},onPaste:()=>void 0},Kd=Si(`div`)({name:`MarkdownOverlayEditorStyle`,class:`gdg-m1pnx84e`,propsAsIs:!1,vars:{"m1pnx84e-0":[e=>e.targetWidth,`px`]}}),qd=e=>{let{value:t,onChange:n,forceEditMode:r,createNode:i,targetRect:a,onFinish:o,validatedSelection:s}=e,c=t.data,l=t.readonly===!0,[u,d]=g.useState(c===``||r),f=g.useCallback(()=>{d(e=>!e)},[]),p=c?`gdg-ml-6`:``;return u?g.createElement(Kd,{targetWidth:a.width-20},g.createElement(co,{autoFocus:!0,highlight:!1,validatedSelection:s,value:c,onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},onChange:n}),g.createElement(`div`,{className:`gdg-edit-icon gdg-checkmark-hover ${p}`,onClick:()=>o(t)},g.createElement(na,null))):g.createElement(Kd,{targetWidth:a.width},g.createElement(ro,{contents:c,createNode:i}),!l&&g.createElement(g.Fragment,null,g.createElement(`div`,{className:`spacer`}),g.createElement(`div`,{className:`gdg-edit-icon gdg-edit-hover ${p}`,onClick:f},g.createElement(ta,null))),g.createElement(`textarea`,{className:`gdg-md-edit-textarea gdg-input`,autoFocus:!0}))},Jd={getAccessibilityString:e=>e.data?.toString()??``,kind:K.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:es,measure:(e,t,n)=>{let r=t.data.split(` +`)[0];return e.measureText(r).width+2*n.cellHorizontalPadding},draw:e=>as(e,e.cell.data,e.cell.contentAlign),onDelete:e=>({...e,data:``}),provideEditor:()=>e=>{let{onChange:t,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:a,forceEditMode:o,validatedSelection:s}=e;return g.createElement(qd,{onFinish:i,targetRect:r,value:n,validatedSelection:s,onChange:e=>t({...n,data:e.target.value}),forceEditMode:o,createNode:a})},onPaste:(e,t)=>e===t.data?void 0:{...t,data:e}},Yd={getAccessibilityString:e=>e.row.toString(),kind:li.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:Xd,measure:()=>44,draw:e=>Qd(e,e.cell.row,e.cell.checked,e.cell.markerKind,e.cell.drawHandle,e.cell.checkboxStyle),onClick:e=>{let{bounds:t,cell:n,posX:r,posY:i}=e,{width:a,height:o}=t,s=n.drawHandle?7+(a-7)/2:a/2,c=o/2;if(Math.abs(r-s)<=10&&Math.abs(i-c)<=10)return{...n,checked:!n.checked}},onPaste:()=>void 0};function Xd(e,t){let{ctx:n,theme:r}=e,i=r.markerFontFull,a=t??{};return a?.font!==i&&(n.font=i,a.font=i),a.deprep=Zd,n.textAlign=`center`,a}function Zd(e){let{ctx:t}=e;t.textAlign=`start`}function Qd(e,t,n,r,i,a){let{ctx:o,rect:s,hoverAmount:c,theme:l}=e,{x:u,y:d,width:f,height:p}=s,m=n?1:r===`checkbox-visible`?.6+.4*c:c;if(r!==`number`&&m>0){o.globalAlpha=m;let e=7*(n?c:1);if(Sc(o,l,n,i?u+e:u,d,i?f-e:f,p,!0,void 0,void 0,18,`center`,a),i){o.globalAlpha=c,o.beginPath();for(let e of[3,6])for(let t of[-5,-1,3])o.rect(u+e,d+p/2+t,2,2);o.fillStyle=l.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r===`number`||r===`both`&&!n){let e=t.toString(),n=l.markerFontFull,i=u+f/2;r===`both`&&c!==0&&(o.globalAlpha=1-c),o.fillStyle=l.textLight,o.font=n,o.fillText(e,i,d+p/2+Yo(o,n)),c!==0&&(o.globalAlpha=1)}}var $d={getAccessibilityString:()=>``,kind:li.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>ef(e,e.cell.hint,e.cell.icon),onPaste:()=>void 0};function ef(e,t,n){let{ctx:r,rect:i,hoverAmount:a,theme:o,spriteManager:s}=e,{x:c,y:l,width:u,height:d}=i;r.beginPath(),r.globalAlpha=a,r.rect(c+1,l+1,u,d-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();let f=t!==``,p=0;if(n!==void 0){let e=d-8,t=c+4,i=l+4;s.drawSprite(n,`normal`,r,t,i,e,o,f?1:a),p=e}else{p=24;let e=f?12:a*12,t=f?0:(1-a)*12*.5,n=o.cellHorizontalPadding+4;e>0&&(r.moveTo(c+n+t,l+d/2),r.lineTo(c+n+t+e,l+d/2),r.moveTo(c+n+t+e*.5,l+d/2-e*.5),r.lineTo(c+n+t+e*.5,l+d/2+e*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap=`round`,r.stroke())}r.fillStyle=o.textMedium,r.fillText(t,p+c+o.cellHorizontalPadding+.5,l+d/2+Yo(r,o)),r.beginPath()}var tf=g.lazy(async()=>await gd(()=>import(`./number-overlay-editor-Cch5pRMh.js`),[])),nf={getAccessibilityString:e=>e.data?.toString()??``,kind:K.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:es,draw:e=>as(e,e.cell.displayData,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.displayData).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:void 0}),provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return g.createElement(g.Suspense,{fallback:null},g.createElement(tf,{highlight:t,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:e=>n({...r,data:Number.isNaN(e.floatValue??0)?0:e.floatValue})}))},onPaste:(e,t,n)=>{let r=typeof n.rawValue==`number`?n.rawValue:Number.parseFloat(typeof n.rawValue==`string`?n.rawValue:e);if(!(Number.isNaN(r)||t.data===r))return{...t,data:r,displayData:n.formattedString??t.displayData}}},rf={getAccessibilityString:()=>``,measure:()=>108,kind:K.Protected,needsHover:!1,needsHoverPosition:!1,draw:af,onPaste:()=>void 0};function af(e){let{ctx:t,theme:n,rect:r}=e,{x:i,y:a,height:o}=r;t.beginPath();let s=2.5,c=i+n.cellHorizontalPadding+s,l=a+o/2,u=Math.cos(Xi(30))*s,d=Math.sin(Xi(30))*s;for(let e=0;e<12;e++)t.moveTo(c,l-s),t.lineTo(c,l+s),t.moveTo(c+u,l-d),t.lineTo(c-u,l+d),t.moveTo(c-u,l-d),t.lineTo(c+u,l+d),c+=8;t.lineWidth=1.1,t.lineCap=`square`,t.strokeStyle=n.textLight,t.stroke()}var of={getAccessibilityString:e=>e.data?.toString()??``,kind:K.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(e,t)=>es(e,t,e.theme.textLight),draw:e=>as(e,e.cell.data,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.data).width+n.cellHorizontalPadding*2,provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return g.createElement(co,{highlight:t,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:e=>n({...r,data:e.target.value})})},onPaste:()=>void 0},sf={getAccessibilityString:e=>e.data?.toString()??``,kind:K.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:es,useLabel:!0,draw:e=>{let{cell:t,hoverAmount:n,hyperWrapping:r,ctx:i,rect:a,theme:o,overrideCursor:s}=e,{displayData:c,contentAlign:l,hoverEffect:u,allowWrapping:d}=t;if(u===!0&&n>0){i.textBaseline=`alphabetic`;let e=o.cellHorizontalPadding,t=o.cellVerticalPadding,r=qo(c,i,o.baseFontFull,`alphabetic`),l=a.height-t,u=Math.min(l,r.actualBoundingBoxAscent*2.5);i.beginPath(),os(i,a.x+e/2,a.y+(a.height-u)/2+1,r.width+e*3,u-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=mo(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline=`middle`,s?.(`text`)}as(e,c,l,d,r)},measure:(e,t,n)=>{let r=t.displayData.split(` +`,t.allowWrapping===!0?void 0:1),i=0;for(let t of r)i=Math.max(i,e.measureText(t).width);return i+2*n.cellHorizontalPadding},onDelete:e=>({...e,data:``}),provideEditor:e=>({disablePadding:e.allowWrapping===!0,editor:t=>{let{isHighlighted:n,onChange:r,value:i,validatedSelection:a}=t;return g.createElement(co,{style:e.allowWrapping===!0?{padding:`3px 8.5px`}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:a,onChange:e=>r({...i,data:e.target.value})})}}),onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}},cf=Si(`div`)({name:`UriOverlayEditorStyle`,class:`gdg-u1rrojo`,propsAsIs:!1}),lf=e=>{let{uri:t,onChange:n,forceEditMode:r,readonly:i,validatedSelection:a,preview:o}=e,[s,c]=g.useState(!i&&(t===``||r)),l=g.useCallback(()=>{c(!0)},[]);return s?g.createElement(co,{validatedSelection:a,highlight:!0,autoFocus:!0,value:t,onChange:n}):g.createElement(cf,null,g.createElement(`a`,{className:`gdg-link-area`,href:t,target:`_blank`,rel:`noopener noreferrer`},o),!i&&g.createElement(`div`,{className:`gdg-edit-icon`,onClick:l},g.createElement(ta,null)),g.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};function uf(e,t,n,r){let i=n.cellHorizontalPadding,a=t.height/2-e.actualBoundingBoxAscent/2,o=e.width,s=e.actualBoundingBoxAscent;return r===`right`?i=t.width-o-n.cellHorizontalPadding:r===`center`&&(i=t.width/2-o/2),{x:i,y:a,width:o,height:s}}var df=[Yd,$d,Dd,jd,Id,Vd,Gd,Jd,nf,rf,of,sf,{getAccessibilityString:e=>e.data?.toString()??``,kind:K.Uri,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:es,draw:e=>{let{cell:t,theme:n,overrideCursor:r,hoverX:i,hoverY:a,rect:o,ctx:s}=e,c=t.displayData??t.data,l=t.hoverEffect===!0;if(r!==void 0&&l&&i!==void 0&&a!==void 0){let{x:l,y:u,width:d,height:f}=uf(qo(c,s,n.baseFontFull),o,n,t.contentAlign);if(i>=l-4&&i<=l-4+d+8&&a>=u-4&&a<=u-4+f+8){let i=Yo(s,n.baseFontFull);r(`pointer`);let a=u-i;s.beginPath(),s.moveTo(o.x+l,Math.floor(o.y+a+f+5)+.5),s.lineTo(o.x+l+d,Math.floor(o.y+a+f+5)+.5),s.strokeStyle=n.linkColor,s.stroke(),s.save(),s.fillStyle=e.cellFillColor,as({...e,rect:{...o,x:o.x-1}},c,t.contentAlign),as({...e,rect:{...o,x:o.x-2}},c,t.contentAlign),as({...e,rect:{...o,x:o.x+1}},c,t.contentAlign),as({...e,rect:{...o,x:o.x+2}},c,t.contentAlign),s.restore()}}s.fillStyle=l?n.linkColor:n.textDark,as(e,c,t.contentAlign)},onClick:e=>{let{cell:t,bounds:n,posX:r,posY:i,theme:a}=e,o=t.displayData??t.data;if(t.hoverEffect!==!0||t.onClickUri===void 0)return;let s=Jo(o,a.baseFontFull);if(s===void 0)return;let c=uf(s,n,a,t.contentAlign);uc({x:c.x-4,y:c.y-4,width:c.width+8,height:c.height+8},r,i)&&t.onClickUri(e)},measure:(e,t,n)=>e.measureText(t.displayData??t.data).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:``}),provideEditor:e=>t=>{let{onChange:n,value:r,forceEditMode:i,validatedSelection:a}=t;return g.createElement(lf,{forceEditMode:r.readonly!==!0&&(i||e.hoverEffect===!0&&e.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:a,readonly:r.readonly===!0,onChange:e=>n({...r,data:e.target.value})})},onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}}],ff=c(o(((e,t)=>{var n=Gi(),r=cr(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a}))(),1),pf=[],mf=class extends hs{imageLoaded=()=>void 0;loadedLocations=[];cache={};setCallback(e){this.imageLoaded=e}sendLoaded=(0,ff.default)(()=>{this.imageLoaded(new _s(this.loadedLocations)),this.loadedLocations=[]},20);clearOutOfWindow=()=>{let e=Object.keys(this.cache);for(let t of e){let e=this.cache[t],n=!1;for(let t=0;t{o||(o=!0,pf.length<12?pf.unshift(a):i||(a.src=``))}},c=new Promise(e=>a.addEventListener(`load`,()=>e(null)));requestAnimationFrame(async()=>{try{a.src=e,await c,await a.decode();let t=this.cache[r];if(t!==void 0&&!o){t.img=a;for(let e of t.cells)this.loadedLocations.push(ms(e));i=!0,this.sendLoaded()}}catch{s.cancel()}}),this.cache[r]=s}loadOrGetImage(e,t,n){let r=e,i=this.cache[r];if(i!==void 0){let e=ds(t,n);return i.cells.includes(e)||i.cells.push(e),i.img}this.loadImage(e,t,n,r)}},hf=``,gf=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\||\+[-=]+(?:\+[-=]+)*\+|[-=]+(?:\+[-=]+)+)\s*$/m,_f=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/,vf=/^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/,yf=/^\s*[-=]+(?:\+[-=]+)+\s*$/,bf=/^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i,xf=/^\s*(?:`{3,}|~{3,})/,Sf=/^\s*#{1,6}\s+(.+?)\s*#*\s*$/,Cf=/^\s*(?:\*\*([^*]+)\*\*|__([^_]+)__)\s*:?\s*$/,wf=/^\s*(?:={3,}|-{3,})\s*$/;function Tf(e){for(let t=0;t=0&&e[n]===`\\`;n--)t++;return t%2==0}function Df(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),Ef(t)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;ee.trim())}function kf(e){return vf.test(e)||yf.test(e)}var Af=32;function jf(e){let t=e.replace(/(\*\*|__|`)*/g,``).replace(/\s+/g,` `).replace(/\s*:\s*$/,``).trim();return t?t.length>Af?`${t.slice(0,31).trimEnd()}…`:t:null}function Mf(e,t,n){if(t)return t;let r=n.slice(0,3).map(e=>e.trim()).filter(Boolean).join(`, `);return r?`Table ${e+1} (${r})`:`Table ${e+1}`}function Nf(e,t){let n=Sf.exec(e);if(n){let e=jf(n[1]);if(e)return{title:e,consumedNextLine:!1}}let r=Cf.exec(e);if(r){let e=jf(r[1]??r[2]??``);if(e)return{title:e,consumedNextLine:!1}}if(t!==void 0&&wf.test(t)&&e.trim().length>0&&!Tf(e)&&!kf(e)&&!xf.test(e)){let t=jf(e);if(t)return{title:t,consumedNextLine:!0}}return null}function Pf(e){if(!e)return[];let t=e.startsWith(hf)?e.slice(1):e,n=t.slice(0,65536);if(!n.includes(`|`)||!gf.test(n))return[];let r=t.split(/\r?\n/),i=[],a=null,o=0;for(;o=2&&n.length>=1){let t=Of(n[0],!0);if(t.length>0&&!t.every(e=>e===``)){let r=n.slice(1).map(e=>Of(e,!0)),s=Vf(t,r,`,`),c=i.length,l=a;i.push({index:c,title:l,label:Mf(c,l,t),headers:t,cleanedCsv:s,rows:r.length,cols:t.length,kind:`box`}),a=null,o=e;continue}}o++;continue}if(Tf(e)&&!kf(e)&&!_f.test(e)&&!Sf.test(e)&&o+10&&!t.every(e=>e===``)){let e=[],n=o+2;for(;n0&&!l.every(e=>e===``)){let e=t.slice(1).map(e=>Of(e,c)),r=Vf(l,e,`,`),s=i.length,u=a;i.push({index:s,title:u,label:Mf(s,u,l),headers:l,cleanedCsv:r,rows:e.length,cols:l.length,kind:`box`}),a=null,o=n;continue}}let t=Nf(e,r[o+1]);t?(a=t.title,o+=t.consumedNextLine?2:1):o++}return i}function Ff(e,t=0){let n=Pf(e);if(n.length===0)return null;let r=n[Math.min(Math.max(0,Math.trunc(t)||0),n.length-1)];return{cleanedCsv:r.cleanedCsv,rows:r.rows,cols:r.cols,kind:r.kind}}var If=``;function Lf(e){let t={",":0,";":0," ":0},n=`,`,r=-1,i=0,a=!1;for(let n=0;nr&&(n=e,r=t[e]);return n}function Rf(e,t,n){if(e[t]===`"`){let r=``,i=t+1;for(;;){if(i>=e.length)return[r,i];let t=e[i];if(t===`"`){if(e[i+1]===`"`)r+=`"`,i+=2;else{for(i++;i=o.length)break;o[t]===c?(p=t+1,m=!0):(p=o[t]===`\r`&&o[t+1]===` +`?t+2:t+1,l.push(d),u.push({start:f+s,end:t+s}),d=[])}d.length>0?(l.push(d),u.push({start:f+s,end:o.length+s})):l.length===0&&d.length===0&&o.length>0&&(l.push([``]),u.push({start:0+s,end:o.length+s}));let h=l.length>0?l[0]:[],g=h.length,_=l.slice(1),v=_.map(e=>e.length);return{headers:h,rows:_.map(e=>e.length===g?e:e.length>g?e.slice(0,g):[...e,...Array(g-e.length).fill(``)]),delimiter:c,rowWidths:v,rowSpans:u.slice(1)}}function Bf(e,t=`,`){return e.map(e=>e.includes(`"`)?`"${e.replaceAll(`"`,`""`)}"`:e.includes(t)||e.includes(` +`)||e.includes(`\r`)?`"${e}"`:e).join(t)}function Vf(e,t,n=`,`){return[e,...t].map(e=>Bf(e,n)).join(` +`)}function Hf(e,t){return zf(e,t).headers}function Uf(e){let t=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:e.headers.length},()=>!0),r=Array.from({length:e.headers.length},()=>!1);for(let i of e.rows)for(let e=0;ee&&r[t])}function Wf(e,t){let n=``,r=0;for(let{start:i,end:a,replacement:o}of t)n+=e.slice(r,i)+o,r=a;return n+e.slice(r)}function Gf(e,t){return e[t]===`\r`?e[t+1]===` +`?2:1:+(e[t]===` +`)}function Kf(e,t){return e[t-2]===`\r`&&e[t-1]===` +`?2:+(e[t-1]===`\r`||e[t-1]===` +`)}var qf=``;function Jf(e,t){let n=+!!e.startsWith(qf),r=t.rowSpans[0];return r===void 0?{start:n,end:n+e.slice(n).length-Kf(e,e.length)}:{start:n,end:r.start-Kf(e,r.start)}}function Yf(e,t,n){let r=[...new Set(n)].flatMap(e=>{let n=t.rowSpans[e];return n===void 0?[]:[n]}).sort((e,t)=>e.start-t.start).map(t=>({start:t.start,end:t.end+Gf(e,t.end),replacement:``}));return r.length===0?e:Wf(e,r)}function Xf(e,t,n){let r=new Set([...n].filter(e=>e>=0&&ee!r.has(t));a.push({start:n.start,end:n.end,replacement:Bf(o,t.delimiter)})}return Wf(e,a)}function Zf(e,t,n,r){if(!e||n<0||n>=t.headers.length)return e;let i=Jf(e,t),a=Hf(e.slice(i.start,i.end),t.delimiter);if(n>=a.length||a[n]===r)return e;let o=Bf(a.map((e,t)=>t===n?r:e),t.delimiter);return e.slice(0,i.start)+o+e.slice(i.end)}function Qf(e=``){return{past:[],present:e,future:[]}}function $f(e,t,n=50){if(t===e.present)return e;if(e.present===``&&e.past.length===0&&e.future.length===0)return{past:[],present:t,future:[]};let r=[...e.past,e.present];return{past:r.length>n?r.slice(r.length-n):r,present:t,future:[]}}function ep(e){if(e.past.length===0)return e;let t=e.past[e.past.length-1];return{past:e.past.slice(0,e.past.length-1),present:t,future:[e.present,...e.future]}}function tp(e){if(e.future.length===0)return e;let[t,...n]=e.future,r=[...e.past,e.present];return{past:r.length>50?r.slice(r.length-50):r,present:t,future:n}}function np(e){if(e.altKey||!e.metaKey&&!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`z`?e.shiftKey?`redo`:`undo`:t===`y`&&!e.shiftKey?`redo`:null}var rp=/^[+-]?\d{16,}$/;function ip(e,t){let n=Array.from({length:e.length},(e,t)=>t);if(t===``)return n;let r=t.toLowerCase();return n.filter(t=>{let n=e[t];for(let e=0;e{let o=t[e]?.[n]??``,s=t[r]?.[n]??``;if(i){let e=o===``?NaN:Number(o),t=s===``?NaN:Number(s),n=Number.isNaN(e),r=Number.isNaN(t);if(n||r)return n&&r?0:n?1:-1;if(rp.test(o)&&rp.test(s)){let e=BigInt(o),t=BigInt(s);return a*(et))}return a*(e-t)}return a*o.localeCompare(s)})}function op(e,t,n){if(n.length===0||e.headers.length===0)return``;let r=e.delimiter||`,`;return[Bf(n.map(t=>e.headers[t]??``),r),...t.filter(t=>t>=0&&tBf(n.map(n=>e.rows[t]?.[n]??``),r))].join(` +`)}var sp=` + +`;function cp(e,t){return Math.max(0,Math.min(e,t))}function lp(e,t,n,r){let i=e.headers.length,a=[];for(let o of n.ranges){let n=cp(o.x,r+i),s=cp(o.x+o.width,r+i);if(s<=r)continue;let c=Math.max(0,n-r),l=s-r;if(l<=c)continue;let u=cp(o.y,t.length),d=cp(o.y+o.height,t.length);if(d<=u)continue;let f=e.headers.slice(c,l),p=[];for(let n=u;ni[c+t]??``))}p.length!==0&&a.push(Vf(f,p,e.delimiter))}if(a.length>0)return a.join(sp);let o=[...n.rows].filter(e=>e>=0&&et[e]).filter(e=>e!==void 0);if(o.length>0)return Vf(e.headers,o.map(t=>e.rows[t]??[]),e.delimiter);let s=[...n.columns].filter(e=>e>=r&&e0?Vf(s.map(t=>e.headers[t-r]),t.map(t=>{let n=e.rows[t]??[];return s.map(e=>n[e-r]??``)}),e.delimiter):null}var up=1e5,dp=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function fp(e,t,n,r){let i=e.headers.length,a=t.length;if(i===0||a===0)return null;let o=new Set;for(let e of n.ranges){if(o.size>=up)break;let t=Math.max(0,e.x-r),n=Math.min(i,e.x+e.width-r);if(n<=t)continue;let s=Math.max(0,e.y),c=Math.min(a,e.y+e.height);if(!(c<=s))for(let e=s;e=up);e++){let r=e*i;for(let e=t;e=up));e++);}}for(let e of n.rows){if(o.size>=up)break;if(e<0||e>=a)continue;let t=e*i;for(let e=0;e=up));e++);}for(let e of n.columns){if(o.size>=up)break;let t=e-r;if(!(t<0||t>=i))for(let e=0;e=up));e++);}let s=o.size;if(s===0||s<2&&n.rows.length===0&&n.columns.length===0)return null;let c=0,l=0,u=0,d=null,f=null,p=new Set;for(let n of o){let r=Math.floor(n/i),a=n%i,o=t[r],s=((o===void 0?void 0:e.rows[o]?.[a])??``).trim();if(s===``)c+=1;else if(p.add(s),dp.test(s)){let e=Number(s);Number.isFinite(e)&&(l+=1,u+=e,(d===null||ef)&&(f=e))}}return{cellCount:s,distinctCount:p.size,emptyCount:c,numericCount:l,sum:l>0?u:null,avg:l>0?u/l:null,min:l>0?d:null,max:l>0?f:null}}var pp=24,mp=26,hp=110,gp=40,_p=12,vp=1,yp=`ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace`,bp=`ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,xp=[{mode:`auto`,label:`Auto`},{mode:`string`,label:`String`},{mode:`number`,label:`Number`},{mode:`boolean`,label:`Boolean`}];function Sp(e){return e===`string`?`STR`:e===`number`?`NUM`:e===`boolean`?`BOOL`:null}function Cp(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.isContentEditable}var wp=`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`,Tp=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:4});function Ep(e){return Tp.format(Object.is(e,-0)?0:e)}function Dp(e){let t=[`Cells: ${Tp.format(e.cellCount)}`,`Distinct: ${Tp.format(e.distinctCount)}`];return e.emptyCount>0&&t.push(`Empty: ${Tp.format(e.emptyCount)}`),e.numericCount>0&&e.sum!==null&&e.avg!==null&&e.min!==null&&e.max!==null&&t.push(`Sum: ${Ep(e.sum)}`,`Avg: ${Ep(e.avg)}`,`Min: ${Ep(e.min)}`,`Max: ${Ep(e.max)}`),t.join(` · `)}function Op(e){return e?{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:bp,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:bp,lineHeight:1}}function kp(e){return e?`hsla(45, 96%, 65%, 0.3)`:`hsl(48 96% 89%)`}function Ap({text:e,delimiter:t,testId:n=`csv-table`,dark:r=!1,onCellCommit:i,onUndo:a,onRedo:o,onCopySelection:s,columnTypes:c,onChangeColumnTypes:l,onProjectedCsvChange:u}){let d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=(0,g.useRef)(null),m=(0,g.useRef)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(null),S=(0,g.useRef)(b);S.current=b;let C=(0,g.useRef)(null),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)(``),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>new Set),[ee,te]=(0,g.useState)(!1),[ne,re]=(0,g.useState)(!1),[j,M]=(0,g.useState)(void 0),[ie,ae]=(0,g.useState)(()=>new Set),N=(0,g.useRef)(ie),[oe,P]=(0,g.useState)(0),[F,se]=(0,g.useState)({}),I=i!==void 0,ce=c??F,le=(0,g.useCallback)(e=>{se(e),l?.(e)},[l]),ue=(0,g.useMemo)(()=>Op(r),[r]),de=kp(r),fe=r?`hsl(240 3.7% 15.9%)`:`hsl(240 4.8% 95.9%)`,pe=(0,g.useRef)();pe.current===void 0&&(pe.current=new mf);let me=(0,g.useMemo)(()=>t===void 0?Ff(e)?.cleanedCsv??e:e,[e,t]),L=(0,g.useMemo)(()=>zf(me,t),[me,t]),he=(0,g.useMemo)(()=>Uf(L),[L]),R=L.headers.length,ge=(0,g.useRef)(L.headers);if(ge.current!==L.headers){let e=ge.current,t=L.headers;ge.current=t;let n=e.length===t.length,r=n?t.reduce((t,n,r)=>n===e[r]?t:t+1,0):1/0;(!n||r>1||r===1&&t.length<=1)&&k.size>0&&A(new Set)}let z=(0,g.useMemo)(()=>{let e=Array.from({length:R},(e,t)=>t);if(k.size===0)return e;let t=e.filter(e=>!k.has(e));return t.length>0?t:e},[R,k]),_e=(0,g.useRef)(z);_e.current=z;let ve=(0,g.useMemo)(()=>z.length===L.headers.length?L:{...L,headers:z.map(e=>L.headers[e]??``),rows:L.rows.map(e=>z.map(t=>e[t]??``))},[L,z]),ye=(0,g.useRef)({text:me,table:L,visibleTable:ve});ye.current={text:me,table:L,visibleTable:ve};let xe=(0,g.useRef)(j);xe.current=j,(0,g.useEffect)(()=>{let e=window.setTimeout(()=>y(h),150);return()=>window.clearTimeout(e)},[h]);let Ce=(0,g.useMemo)(()=>{let e=ip(L.rows,v);return b?ap(e,L.rows,b.col,b.dir,he[b.col]??!1):e},[L,v,b,he]),we=(0,g.useRef)(Ce);we.current=Ce,(0,g.useEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>P(e.clientWidth));return t.observe(e),P(e.clientWidth),()=>t.disconnect()},[]);let B=Math.max(hp,Math.floor((oe-gp)/Math.max(1,z.length)));(0,g.useEffect)(()=>{if(!ee)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),te(!1))},t=e=>{let t=p.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||te(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[ee]);let Te=(0,g.useCallback)(e=>{A(t=>{let n=new Set(t);if(n.has(e))n.delete(e);else{if(R-(n.size+1)<1)return t;n.add(e)}return n}),M(e=>e&&e.columns.length>0?{...e,columns:fi.empty()}:e)},[R]),Ee=(0,g.useCallback)(()=>{A(new Set),M(e=>e&&e.columns.length>0?{...e,columns:fi.empty()}:e)},[]),De=z.length!ne||!Oe?null:op(L,Ce,z),[ne,Oe,L,Ce,z]),Ae=(0,g.useRef)(u);Ae.current=u,(0,g.useEffect)(()=>{Ae.current?.(ke)},[ke]),(0,g.useEffect)(()=>()=>{Ae.current?.(null)},[]),(0,g.useEffect)(()=>{ae(e=>{let t=!1,n=new Set;for(let r of e)r{M(e=>{if(!e||e.rows.length===0)return e;let t=[];for(let e of N.current){let n=Ce.indexOf(e);n!==-1&&t.push(n)}t.sort((e,t)=>e-t);let n=t.reduce((e,t)=>e.add(t),fi.empty());return n.equals(e.rows)?e:{...e,rows:n}})},[Ce]),(0,g.useEffect)(()=>{x(e=>e!==null&&e.col>=R?null:e),T(e=>e!==null&&e.col>=R?null:e)},[R]);let je=v!==``,Me=L.rows.length,Ne=mp+Math.min(Ce.length,_p)*pp,Pe=()=>{_(``),y(``)},Ie=(0,g.useCallback)((e,t)=>{if(e0||i.height>0)?{x:Math.max(0,a.x-i.left),y:Math.max(0,a.y-i.top),width:a.width,height:a.height}:a??{x:gp+n*B,y:0,width:B,height:mp};D(e),T({col:r,bounds:o})}else C.current=S.current,T(null),x(e=>!e||e.col!==r?{col:r,dir:`asc`}:e.dir===`asc`?{col:r,dir:`desc`}:null)}},[I,B]),Le=(0,g.useCallback)(()=>{if(!w)return;let{col:e}=w;if(T(null),!i)return;let{text:t,table:n}=ye.current,r=n.headers[e]??``,a=Zf(t,n,e,E);if(a!==t){if(r!==``&&r!==E&&ce[r]!==void 0){let e={...ce},t=e[r];delete e[r],E!==``&&t!==void 0&&(e[E]=t),le(e)}i(a)}},[w,E,i,ce,le]),Re=(0,g.useCallback)(()=>{T(null)},[]);(0,g.useEffect)(()=>{if(!w)return;let e=O.current;e&&(e.focus(),e.select())},[w]);let ze=(0,g.useCallback)((e,t)=>{let n=we.current,r=n[t];if(r===void 0)return;let i=N.current,a=m.current,o;if(e.shiftKey&&a!==null&&a!==r){let t=n.indexOf(a),s=n.indexOf(r),c=t===-1?s:t,[l,u]=c<=s?[c,s]:[s,c];o=e.metaKey||e.ctrlKey?new Set(i):new Set;for(let e=l;e<=u;e++){let t=n[e];t!==void 0&&o.add(t)}}else e.metaKey||e.ctrlKey?(o=new Set(i),o.has(r)?o.delete(r):o.add(r)):o=new Set([r]);m.current=r,N.current=o,ae(o);let s=[...o].map(e=>n.indexOf(e)).filter(e=>e!==-1).sort((e,t)=>e-t);M(e=>({current:e?.current,columns:e?.columns??fi.empty(),rows:s.reduce((e,t)=>e.add(t),fi.empty())}))},[]),Be=(0,g.useCallback)(()=>{m.current=null,N.current=new Set,ae(new Set),M(void 0)},[]),Ve=(0,g.useCallback)(e=>{let t=new Set;for(let n of e.rows){let e=we.current[n];e!==void 0&&t.add(e)}N.current=t,ae(t),M(e)},[]),He=(0,g.useCallback)(()=>{Be()},[Be]),Ue=(0,g.useMemo)(()=>Ce.filter(e=>ie.has(e)),[Ce,ie]),We=(0,g.useMemo)(()=>[...j?.columns??[]].filter(e=>e>=vp).map(e=>z[e-vp]).filter(e=>e!==void 0),[j,z]),Ge=We.length,Ke=(0,g.useMemo)(()=>We.map(e=>L.headers[e]).filter(e=>e!==void 0),[We,L.headers]),Je=(0,g.useMemo)(()=>{if(Ke.length===0)return null;let e=ce[Ke[0]]??`auto`;for(let t=1;t{if(!I||Ke.length===0)return;let t={...ce};for(let n of Ke)e===`auto`?delete t[n]:t[n]=e;le(t)},[I,Ke,ce,le]),Xe=(0,g.useMemo)(()=>I?L.headers.filter(e=>Sp(ce[e])!==null).length:0,[I,L.headers,ce]),Qe=(0,g.useMemo)(()=>({ranges:j?.current?[j.current.range,...j.current.rangeStack]:[],columns:j?[...j.columns]:[],rows:ie.size>0?Ce.reduce((e,t,n)=>(ie.has(t)&&e.push(n),e),[]):j?[...j.rows]:[]}),[j,ie,Ce]),$e=vp,et=(0,g.useMemo)(()=>fp(ve,Ce,Qe,$e),[ve,Ce,Qe,$e]),tt=Ue.length>0||Ge>0||et!==null,nt=(0,g.useRef)(s);nt.current=s;let rt=()=>{let e=xe.current,t=lp(ye.current.visibleTable,we.current,{ranges:e?.current?[e.current.range,...e.current.rangeStack]:[],columns:e?[...e.columns]:[],rows:e?[...e.rows]:[]},vp);t!==null&&(nt.current?.(),navigator.clipboard?.writeText(t).catch(()=>{}))};(0,g.useEffect)(()=>{let e=e=>{let t=d.current;if(!t||!t.contains(document.activeElement))return;let n=document.activeElement;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;let r=xe.current,i=lp(ye.current.visibleTable,we.current,{ranges:r?.current?[r.current.range,...r.current.rangeStack]:[],columns:r?[...r.columns]:[],rows:r?[...r.rows]:[]},vp);i!==null&&(e.preventDefault(),e.stopImmediatePropagation(),e.clipboardData?.setData(`text/plain`,i),nt.current?.())};return window.addEventListener(`copy`,e,{capture:!0}),()=>window.removeEventListener(`copy`,e,{capture:!0})},[]),(0,g.useEffect)(()=>{if(!a&&!o)return;let e=e=>{let t=d.current;if(!t)return;let n=e.target instanceof Node&&t.contains(e.target),r=document.activeElement instanceof Node&&t.contains(document.activeElement);if(!n&&!r||Cp(e.target)||Cp(document.activeElement))return;let i=np(e);i===`undo`&&a?(e.preventDefault(),a()):i===`redo`&&o&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,o]);let it=(0,g.useCallback)(e=>{let t=d.current!==null&&document.activeElement instanceof Node&&d.current.contains(document.activeElement);Be(),i?.(e),t&&f.current?.focus({preventScroll:!0})},[Be,i]),at=R>0&&We.length>=R,ot=()=>{I&&Ue.length!==0&&it(Yf(ye.current.text,ye.current.table,Ue))},st=()=>{I&&!at&&We.length!==0&&it(Xf(ye.current.text,ye.current.table,We))},ct=(0,g.useCallback)(e=>{if(!i)return!1;let{text:t,table:n}=ye.current,r=we.current;if(e.rows.length>0){let i=[...e.rows].map(e=>r[e]).filter(e=>e!==void 0);if(i.length>0)return it(Yf(t,n,i)),!1}if(e.columns.length>0){let r=[...e.columns].filter(e=>e>=vp).map(e=>_e.current[e-vp]).filter(e=>e!==void 0&&e>=0&&e0&&r.length0&&it(Yf(t,n,o)),!1},[it,i]),lt=(0,g.useCallback)(e=>{let t=i;if(!t)return!1;let{text:n,table:r}=ye.current,a=we.current,o=[...e].sort((e,t)=>e.location[1]-t.location[1]),s=n,c=0;for(let{location:e,value:t}of o){let n=e[0]-vp,i=n>=0?_e.current[n]:void 0,o=e[1];if(i===void 0||i<0||t.kind!==K.Text)continue;let l=a[o],u=l===void 0?void 0:r.rowSpans[l];if(!u)continue;let d=Hf(s.slice(u.start+c,u.end+c),r.delimiter);for(;d.length<=i;)d.push(``);let f=t.data??``;if(d[i]===f)continue;d[i]=f;let p=Bf(d,r.delimiter);s=s.slice(0,u.start+c)+p+s.slice(u.end+c),c+=p.length-(u.end-u.start)}return s!==n&&t(s),!0},[i]),ut=(0,g.useCallback)(e=>{let[t,n]=e,r=we.current[n];if(t{let t=[];for(let n=e.y;n{e[0]>=vp||ze(t,e[1])},[ze]),pt=(0,g.useMemo)(()=>[{title:`#`,id:`__gutter`,width:gp,themeOverride:{baseFontStyle:`11px ${yp}`,textDark:`hsla(240, 3.8%, 46.1%, 0.4)`}},...z.map(e=>{let t=L.headers[e]??``,n=I?Sp(ce[t]):null;return{title:n?`${t.toUpperCase()} [${n}]`:t.toUpperCase(),id:`c${e}`,width:B,themeOverride:he[e]?{baseFontStyle:`12px ${yp}`}:void 0}})],[L.headers,z,he,B,I,ce]),mt=(0,g.useCallback)((e,t)=>{let{ctx:n,columnIndex:r,rect:i,theme:a,isSelected:o}=e;n.save();try{if(n.letterSpacing=`0.5px`,o&&(n.fillStyle=a.bgHeaderHovered,n.fillRect(i.x,i.y,i.width,i.height),n.fillStyle=a.accentColor,n.fillRect(i.x,i.y+i.height-2,i.width,2)),r{let{ctx:n,cell:r,rect:i,col:a,theme:o}=e,s=a-vp;if(s>=0&&je&&r.kind===K.Text){let e=jp(r.data,v);if(e!==null){n.save();try{let t=`${o.baseFontStyle} ${o.fontFamily}`;n.font=t;let r=i.x+o.cellHorizontalPadding,a=i.y+i.height/2+Yo(n,t);for(let t of e){let e=n.measureText(t.text).width;t.hit&&e>0&&(n.fillStyle=de,n.fillRect(r-1,a-7,e+2,14)),r+=e}}finally{n.restore()}}}if(t(),s>=0&&r.kind===K.Text&&r.data===``){n.save();try{n.font=`${o.baseFontStyle} ${o.fontFamily}`,n.fillStyle=o.textLight,n.fillText(`—`,i.x+o.cellHorizontalPadding,i.y+i.height/2+.5)}finally{n.restore()}}},[je,v,de]),gt=(0,g.useCallback)(e=>{let t=we.current[e];return t!==void 0&&N.current.has(t)?{bgCell:fe,bgCellMedium:fe}:void 0},[fe]);return R===0?(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:`No columns detected.`}):(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,ref:d,children:[(0,G.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:[(0,G.jsxs)(`div`,{className:`relative min-w-32 flex-1 sm:max-w-64`,children:[(0,G.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60`}),(0,G.jsx)(`input`,{type:`text`,"data-testid":`${n}-search`,"aria-label":`Search rows`,value:h,onChange:e=>_(e.target.value),onKeyDown:e=>{e.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!==``&&(0,G.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:(0,G.jsx)(Ze,{"aria-hidden":`true`,className:`size-3`})})]}),(0,G.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:je?`${Ce.length.toLocaleString()} of ${Me.toLocaleString()}`:`${Me.toLocaleString()} rows`}),I&&Xe>0&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`input-table-column-types-reset`,onClick:()=>le({}),title:`Reset all pinned column types to Auto`,className:wp,children:[`${Xe} ${Xe===1?`column type`:`column types`} pinned`,(0,G.jsx)(Ze,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]}),(0,G.jsxs)(`div`,{ref:p,className:`relative`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`${n}-columns-button`,"aria-expanded":ee,"aria-haspopup":`dialog`,"aria-label":`Columns`,onClick:()=>te(e=>!e),className:Tn(wp,De&&`border-foreground/30 bg-muted font-semibold`),children:[(0,G.jsx)(be,{"aria-hidden":`true`,className:`size-3`}),(0,G.jsx)(`span`,{children:De?`Columns (${z.length}/${R})`:`Columns`})]}),ee&&(0,G.jsxs)(`div`,{"data-testid":`${n}-columns-popout`,role:`dialog`,"aria-label":`Visible columns`,className:`absolute left-0 top-7 z-30 min-w-44 max-w-64 rounded-md border border-border bg-panel p-1.5 shadow-md`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2 border-b border-border px-1.5 pb-1`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:[`Columns (`,z.length,`/`,R,`)`]}),De&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`${n}-columns-reset`,onClick:Ee,className:`cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Show all`})]}),(0,G.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:L.headers.map((e,t)=>{let r=!k.has(t),i=r&&z.length<=1,a=e===``?`Column ${t+1}`:e;return(0,G.jsxs)(`label`,{className:Tn(`flex items-center gap-2 rounded px-1.5 py-1 text-xs`,i?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-muted`),children:[(0,G.jsx)(`input`,{type:`checkbox`,"data-testid":`${n}-column-toggle-${t}`,checked:r,disabled:i,onChange:()=>Te(t),className:`size-3.5 accent-foreground`}),(0,G.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:a})]},t)})})]})]}),Oe&&(0,G.jsx)(`button`,{type:`button`,"data-testid":`${n}-apply-view`,"aria-pressed":ne,onClick:()=>re(e=>!e),className:Tn(`inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,ne?`border-foreground bg-foreground text-background hover:bg-foreground/90`:`border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:`Apply view to output`}),tt&&(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(`span`,{"data-testid":`${n}-selected-count`,className:`text-[11px] font-medium tabular-nums text-muted-foreground`,children:Ue.length>0?`${Ue.length.toLocaleString()} selected`:Ge>0?`${Ge.toLocaleString()} ${Ge===1?`column`:`columns`} selected`:`${(et?.cellCount??0).toLocaleString()} cells selected`}),et!==null&&(0,G.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:Dp(et)}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`${n}-copy`,onClick:rt,className:wp,children:[(0,G.jsx)(Se,{"aria-hidden":`true`,className:`size-3`}),`Copy as CSV`]}),I&&Ue.length>0&&(0,G.jsxs)(`button`,{type:`button`,"data-testid":`${n}-delete-rows`,onClick:ot,title:`Deletes the ${Ue.length} selected ${Ue.length===1?`row`:`rows`} from the source CSV`,className:wp,children:[(0,G.jsx)(qe,{"aria-hidden":`true`,className:`size-3`}),`Delete `,Ue.length.toLocaleString(),` `,Ue.length===1?`row`:`rows`]}),I&&Ge>0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.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:xp.map(({mode:e,label:t})=>{let n=Je===e;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`input-table-column-type-${e}`,"aria-pressed":n,onClick:()=>Ye(e),className:n?`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:t},e)})}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`${n}-delete-columns`,onClick:st,disabled:at,title:at?`At least one column must remain — the converter needs a column to detect`:`Deletes the ${Ge} selected ${Ge===1?`column`:`columns`} from the source CSV`,className:`${wp} disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,G.jsx)(qe,{"aria-hidden":`true`,className:`size-3`}),`Delete `,Ge.toLocaleString(),` `,Ge===1?`column`:`columns`]})]}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`${n}-clear-selection`,onClick:Be,className:wp,children:`Clear`})]})]}),(0,G.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:Ne},children:[(0,G.jsx)(`div`,{className:`absolute inset-0`,children:(0,G.jsx)(Td,{imageWindowLoader:pe.current,renderers:df,columns:pt,rows:Ce.length,getCellContent:ut,getCellsForSelection:dt,onCellsEdited:I?lt:void 0,onDelete:I?ct:void 0,onCellClicked:ft,onHeaderClicked:Ie,onGridSelectionChange:Ve,onSelectionCleared:He,gridSelection:j,rangeSelect:`multi-rect`,columnSelect:`multi`,rowSelect:`multi`,rowHeight:pp,headerHeight:mp,freezeColumns:vp,fillHandle:I,onPaste:I?()=>!0:!1,keybindings:{search:!1},theme:ue,drawHeader:mt,drawCell:ht,getRowThemeOverride:gt,minColumnWidth:hp,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),w!==null&&(0,G.jsx)(`input`,{ref:O,type:`text`,"data-testid":`csv-header-rename-input`,"aria-label":`Rename column ${L.headers[w.col]??``}`,value:E,onChange:e=>D(e.target.value),onBlur:Le,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),Le()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Re())},style:{left:w.bounds.x,top:w.bounds.y,width:Math.max(60,w.bounds.width),height:w.bounds.height},className:`absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50`}),je&&Ce.length===0&&(0,G.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:[(0,G.jsxs)(`span`,{children:[`No rows matching “`,v,`”.`]}),(0,G.jsx)(`button`,{type:`button`,onClick:Pe,className:wp,children:`Show all rows`})]}),I&&!je&&Ce.length===0&&(0,G.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:(0,G.jsx)(`span`,{children:`No rows. Paste or upload data to start over.`})})]})]})}function jp(e,t){if(t===``||e===``)return null;let n=t.toLowerCase();if(!e.toLowerCase().includes(n))return null;let r=[],i=e.toLowerCase(),a=0;for(;;){let t=i.indexOf(n,a);if(t===-1)break;t>a&&r.push({text:e.slice(a,t),hit:!1}),r.push({text:e.slice(t,t+n.length),hit:!0}),a=t+n.length}return a`u`?void 0:navigator),a=(0,g.useRef)(null);(0,g.useEffect)(()=>{a.current?.focus()},[]);let o=e===`CSV`;return(0,G.jsx)(`div`,{"data-testid":`dropzone`,className:`flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16`,children:(0,G.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3`,children:[(0,G.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:(0,G.jsx)(z,{className:`size-4 md:size-5`})}),(0,G.jsx)(`p`,{"data-testid":`dropzone-title`,className:`text-center text-sm font-medium text-foreground`,children:o?`Paste CSV, TSV, or Markdown table`:`Paste JSON or JSONL here`}),(0,G.jsx)(`p`,{"data-testid":`dropzone-formats`,className:`max-w-[36ch] text-center text-[11.5px] leading-relaxed text-muted-foreground`,children:o?`Supports CSV, TSV / spreadsheet cells, Markdown & ChatGPT docs (multi-table), and psql / MySQL box tables`:`Supports JSON arrays, nested objects, wrapped API payloads ({ data: […] }), and JSONL / NDJSON`}),(0,G.jsx)(`textarea`,{ref:a,"data-testid":`paste-field`,rows:1,"aria-label":`Paste ${o?`CSV, TSV, Markdown, or CLI table`:`JSON, JSONL, or API response`} data — or press ${i} to paste anywhere on this page`,placeholder:o?`Paste CSV, TSV, Markdown, or psql/MySQL table here`:`Paste JSON, JSONL / NDJSON, or API response here`,spellCheck:!1,onChange:e=>{let n=e.currentTarget;n.rows=Fp(n.value),t(n.value)},className:`min-h-11 w-full resize-none overflow-hidden rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:font-sans placeholder:text-xs placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400`}),(0,G.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 (`,(0,G.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}),`)`]}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,G.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:[(0,G.jsx)(Te,{"aria-hidden":`true`}),`Choose file`]}),(0,G.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:[(0,G.jsx)(Le,{"aria-hidden":`true`}),`Try an example`]})]})]})})}var Lp=[],Rp=[];(()=>{let e=`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 t=0,n=0;t>1;if(e=Rp[r])t=r+1;else return!0;if(t==n)return!1}}function Bp(e){return e>=127462&&e<=127487}var Vp=8205;function Hp(e,t,n=!0,r=!0){return(n?Up:Wp)(e,t,r)}function Up(e,t,n){if(t==e.length)return t;t&&Kp(e.charCodeAt(t))&&qp(e.charCodeAt(t-1))&&t--;let r=Gp(e,t);for(t+=Jp(r);t=0&&Bp(Gp(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Wp(e,t,n){for(;t>1;){let r=Up(e,t-2,n);if(r=56320&&e<57344}function qp(e){return e>=55296&&e<56320}function Jp(e){return e<65536?1:2}var Yp=class e{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=am(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Zp.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=am(this,e,t);let n=[];return this.decompose(e,t,n,0),Zp.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new tm(this),i=new tm(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new tm(this,e)}iterRange(e,t=this.length){return new nm(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new rm(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new Xp(t):Zp.from(Xp.split(t,[]))}},Xp=class e extends Yp{constructor(e,t=Qp(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new im(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(em(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=$p(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=am(this,t,n);let i=$p(this.text,$p(r.text,em(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Zp.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=` +`){[e,t]=am(this,e,t);let r=``;for(let i=0,a=0;i<=t&&ae&&a&&(r+=n),ei&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},Zp=class e extends Yp{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=am(this,t,n),r.lines=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=` +`){[e,t]=am(this,e,t);let r=``;for(let i=0,a=0;ie&&i&&(r+=n),ea&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new Xp(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof Xp&&c&&(n=u[u.length-1])instanceof Xp&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new Xp(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};Yp.empty=new Xp([``],0);function Qp(e){let t=-1;for(let n of e)t+=n.length+1;return t}function $p(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a=n&&(c>r&&(s=s.slice(0,r-i)),i0?1:(e instanceof Xp?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof Xp?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(r instanceof Xp){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof Xp?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},nm=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new tm(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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!=``}},rm=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(Yp.prototype[Symbol.iterator]=function(){return this.iter()},tm.prototype[Symbol.iterator]=nm.prototype[Symbol.iterator]=rm.prototype[Symbol.iterator]=function(){return this});var im=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function am(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function om(e,t,n=!0,r=!0){return Hp(e,t,n,r)}function sm(e){return e>=56320&&e<57344}function cm(e){return e>=55296&&e<56320}function lm(e,t){let n=e.charCodeAt(t);if(!cm(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return sm(r)?(n-55296<<10)+(r-56320)+65536:n}function um(e){return e<65536?1:2}var dm=/\r\n?|\n/,fm=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(fm||={}),pm=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return i+(e-r);i+=o}else{if(n!=fm.Simple&&c>=e&&(n==fm.TrackDel&&re||n==fm.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&o>=e)return rt?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},mm=class e extends pm{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return _m(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return vm(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length0&&gm(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;os||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?Yp.of(l.split(r||dm)):l:Yp.empty,d=u.length;if(e==s&&d==0)return;eo&&hm(i,e-o,-1),hm(i,s-e,d),gm(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;et&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function gm(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function vm(e,t,n,r=!1){let i=[],a=r?[]:null,o=new bm(e),s=new bm(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);hm(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len=0&&e=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.lent||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var bm=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Yp.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Yp.empty:t[n].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)}},xm=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}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(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return X.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return X.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!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 RangeError(`Invalid JSON representation for SelectionRange`);return X.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},X=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>xm.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;ie.from-t.from),n=t.indexOf(r);for(let r=1;ri.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Sm(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Cm=0,wm=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Cm++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Tm),!!t.static,t.enables)}of(e){return new Em([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Em(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Em(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Tm(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Em=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Cm++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Om(e,c)){let r=t(e);if(a?!Dm(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Vm(o,c);if(this.dependencies.every(t=>t instanceof wm?o.facet(t)===e.facet(t):t instanceof jm?o.field(t,!1)==e.field(t,!1):!0)||(a?Dm(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Dm(e,t,n){if(e.length!=t.length)return!1;for(let r=0;re[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;te===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Am).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Am),i=n.facet(Am),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Am.of({field:this,create:e})]}get extension(){return this}},Mm={lowest:4,low:3,default:2,high:1,highest:0};function Nm(e){return t=>new Fm(t,e)}var Pm={highest:Nm(Mm.highest),high:Nm(Mm.high),default:Nm(Mm.default),low:Nm(Mm.low),lowest:Nm(Mm.lowest)},Fm=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Im=class e{of(e){return new Lm(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Lm=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Rm=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of zm(t,n,o))e instanceof jm?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Tm(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>km(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function zm(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Lm&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Lm){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Fm)a(e.inner,e.prec);else if(e instanceof jm)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Em)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Mm.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Mm.default),r.reduce((e,t)=>e.concat(t))}function Bm(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Vm(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Hm=wm.define(),Um=wm.define({combine:e=>e.some(e=>e),static:!0}),Wm=wm.define({combine:e=>e.length?e[0]:void 0,static:!0}),Gm=wm.define(),Km=wm.define(),qm=wm.define(),Jm=wm.define({combine:e=>e.length?e[0]:!1}),Ym=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Xm}},Xm=class{of(e){return new Ym(this,e)}},Zm=class{constructor(e){this.map=e}of(e){return new Qm(this,e)}},Qm=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new Zm(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};Qm.reconfigure=Qm.define(),Qm.appendConfig=Qm.define();var $m=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Sm(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};$m.time=Ym.define(),$m.userEvent=Ym.define(),$m.addToHistory=Ym.define(),$m.remote=Ym.define();function eh(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r=e[r]))a=e[r++],o=e[r++];else if(i=0;n--){let i=r[n](e);e=i instanceof $m?i:Array.isArray(i)&&i.length==1&&i[0]instanceof $m?i[0]:rh(t,sh(i),!1)}return e}function ah(e){let t=e.startState,n=t.facet(qm),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=th(r,nh(t,a,e.changes.newLength),!0))}return r==e?e:$m.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var oh=[];function sh(e){return e==null?oh:Array.isArray(e)?e:[e]}var ch=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(ch||={}),lh=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,uh;try{uh=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function dh(e){if(uh)return uh.test(e);for(let t=0;t`€`&&(n.toUpperCase()!=n.toLowerCase()||lh.test(n)))return!0}return!1}function fh(e){return t=>{if(!/\S/.test(t))return ch.Space;if(dh(t))return ch.Word;for(let n=0;n-1)return ch.Word;return ch.Other}}var ph=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;ei.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(Qm.reconfigure)?(n=null,r=e.value):e.is(Qm.appendConfig)&&(n=null,r=sh(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Rm.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(Um)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:X.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=sh(n.effects);for(let n=1;nn.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:X.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Rm.resolve(t.extensions||[],new Map),r=t.doc instanceof Yp?t.doc:Yp.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||dm)),i=t.selection?t.selection instanceof X?t.selection:X.single(t.selection.anchor,t.selection.head):X.single(0);return Sm(i,r.length),n.staticFacet(Um)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||` +`}get readOnly(){return this.facet(Jm)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(Hm))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return fh(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=om(t,a,!1);if(i(t.slice(e,a))!=ch.Word)break;a=e}for(;oe.length?e[0]:4}),ph.lineSeparator=Wm,ph.readOnly=Jm,ph.phrases=wm.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),ph.languageData=Hm,ph.changeFilter=Gm,ph.transactionFilter=Km,ph.transactionExtender=qm,Im.reconfigure=Qm.define();function mh(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var hh=class{eq(e){return this==e}range(e,t=e){return _h.create(e,t,this)}};hh.prototype.startSide=hh.prototype.endSide=0,hh.prototype.point=!1,hh.prototype.mapMode=fm.TrackDel;function gh(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var _h=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function vh(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var yh=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return xh(this.to)}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);ih||m==h&&d.startSide>0&&d.endSide<=0)continue;if(!((h-m||d.endSide-d.startSide)<0)){if(l<0&&(l=m),d.point&&(u=Math.max(u,h-m)),(m-r||d.startSide-i)>=0)o.push(d),s.push(m-l),c.push(h-l),r=h,i=d.endSide;else{if(m==h)for(let e=o.length;e>0;e--){if((m-(c[e-1]+l)||d.startSide-o[e-1].endSide)>=0){o.splice(e,0,d),s.splice(e,0,m-l),c.splice(e,0,h-l);continue iter}if((m-(s[e-1]+l)||d.endSide-o[e-1].startSide)>0)break}a(m,h,d)}}}return{mapped:o.length?new e(s,c,o,u):null,pos:l}}},bh=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,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 t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(vh)),this.isEmpty)return n.length?e.of(n):this;let s=new Th(this,null,-1).goto(0),c=0,l=[],u=new Ch;for(;s.value||c=0){let e=n[c++];u.addInner(e.from,e.to,e.value,!1)||l.push(e)}else s.rangeIndex==1&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||as.to||a{a||=new Ch,a.addRange(e,t,n,!1)};for(let e=0;e=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Eh.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Eh.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=wh(a,o,n),c=new Oh(a,s,i),l=new Oh(o,s,i);n.iterGaps((e,t,n)=>kh(c,e,l,t,n,r)),n.empty&&n.length==0&&kh(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=wh(i,a),s=new Oh(i,o,0).goto(n),c=new Oh(a,o,0).goto(n);for(;;){if(s.to!=c.to||!Ah(s.active,c.active)||s.point&&(!c.point||!gh(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new Oh(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFromo&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new Ch;for(let r of e instanceof _h?[e]:t?Sh(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=xh(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};bh.empty=new bh([],[],null,-1);function xh(e){return e[e.length-1]}function Sh(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(vh);t=r}return e}bh.empty.nextLayer=bh.empty;var Ch=class e{finishChunk(e){this.chunks.push(new yh(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,t,n){this.addRange(e,t,n,!0)}addRange(t,n,r,i){this.addInner(t,n,r,i)||(this.nextLayer||=new e).addRange(t,n,r,i)}addInner(e,t,n,r){let i=e-this.lastTo||n.startSide-this.last.endSide;if(r&&i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw 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(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(bh.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=bh.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function wh(e,t,n){let r=new Map;for(let t of e)for(let e=0;e=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 Th(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dh(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Dh(this.heap,e);(this.to-e||this.value.endSide-t)<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(),Dh(this.heap,0)}}};function Dh(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var Oh=class{constructor(e,t,n){this.minPoint=n,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=Eh.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){jh(this.active,e),jh(this.activeTo,e),jh(this.activeRank,e),this.minActive=Nh(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t0;)t++;Mh(this.active,t,n),Mh(this.activeTo,t,r),Mh(this.activeRank,t,i),e&&Mh(e,t,this.cursor.from),this.minActive=Nh(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&jh(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function kh(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&gh(e.point,n.point)&&Ah(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&=(a.boundChange(s),!1),d>s&&!Ah(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&do)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function Ah(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;n--)e[n+1]=e[n];e[t]=n}function Nh(e,t){let n=-1,r=1e9;for(let i=0;i=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=om(e,r)}return r===!0?-1:e.length}for(var Ih=`ͼ`,Lh=typeof Symbol>`u`?`__ͼ`:Symbol.for(Ih),Rh=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),zh=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},Bh=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(` +`)}static newName(){let e=zh[Lh]||1;return zh[Lh]=e+1,Ih+e.toString(36)}static mount(e,t,n){let r=e[Rh],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Hh(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Vh=new Map,Hh=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Vh.get(n);if(t)return e[Rh]=t;this.sheet=new r.CSSStyleSheet,Vh.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[Rh]=this}mount(e,t){let n=this.sheet,r=0,i=0,a=!1;for(let t=0;t-1&&(this.modules.splice(s,1),a=!0,i--,s=-1),s==-1){if(this.modules.splice(i++,0,o),a=!0,n)for(let e=0;e`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Gh=typeof navigator<`u`&&/Mac/.test(navigator.platform),Kh=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),qh=0;qh<10;qh++)Uh[48+qh]=Uh[96+qh]=String(qh);for(var qh=1;qh<=24;qh++)Uh[qh+111]=`F`+qh;for(var qh=65;qh<=90;qh++)Uh[qh]=String.fromCharCode(qh+32),Wh[qh]=String.fromCharCode(qh);for(var Jh in Uh)Wh.hasOwnProperty(Jh)||(Wh[Jh]=Uh[Jh]);function Yh(e){var t=!(Gh&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Kh&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Wh:Uh)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function Xh(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=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`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t2),Z={mac:cg||/Mac/.test(Qh.platform),windows:/Win/.test(Qh.platform),linux:/Linux|X11/.test(Qh.platform),ie:rg,ie_version:tg?$h.documentMode||6:ng?+ng[1]:eg?+eg[1]:0,gecko:ig,gecko_version:ig?+(/Firefox\/(\d+)/.exec(Qh.userAgent)||[0,0])[1]:0,chrome:!!ag,chrome_version:ag?+ag[1]:0,ios:cg,android:/Android\b/.test(Qh.userAgent),webkit:og,webkit_version:og?+(/\bAppleWebKit\/(\d+)/.exec(Qh.userAgent)||[0,0])[1]:0,safari:sg,safari_version:sg?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Qh.userAgent)||[0,0])[1]:0,tabSize:$h.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function lg(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var ug=Object.create(null);function dg(e,t,n){if(e==t)return!0;e||=ug,t||=ug;let r=Object.keys(e),i=Object.keys(t);if(r.length-0!=i.length-0)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function fg(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function pg(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function mg(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new bg(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=xg(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new bg(e,n,r,t,e.widget||null,!0)}static line(e){return new yg(e)}static set(e,t=!1){return bh.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};_g.none=bh.empty;var vg=class e extends _g{constructor(e){let{start:t,end:n}=xg(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?lg(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ug}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&dg(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};vg.prototype.point=!1;var yg=class e extends _g{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&dg(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};yg.prototype.mapMode=fm.TrackBefore,yg.prototype.point=!0;var bg=class e extends _g{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?fm.TrackBefore:fm.TrackAfter:fm.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?gg.WidgetBefore:gg.WidgetAfter:gg.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&Sg(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};bg.prototype.point=!0;function xg(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function Sg(e,t){return e==t||!!(e&&t&&e.compare(t))}function Cg(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var wg=class e extends hh{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&dg(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||ug,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return bh.of(e,t)}};wg.prototype.startSide=wg.prototype.endSide=-1;var Tg=e=>e.nodeType==1,Eg=e=>e.nodeType==3;function Dg(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function Og(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function kg(e,t){if(!t.anchorNode)return!1;try{return Og(e,t.anchorNode)}catch{return!1}}function Ag(e){return Eg(e)?qg(e,0,e.nodeValue.length).getClientRects():Tg(e)?e.getClientRects():[]}function jg(e,t,n,r){return n?Pg(e,t,n,r,-1)||Pg(e,t,n,r,1):!1}function Mg(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function Ng(e){return Tg(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Pg(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:Fg(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!Tg(n))return!1;t=Mg(e)+(i<0?0:1),e=n}else if(Tg(e)){if(e=e.childNodes[t+(i<0?-1:0)],Tg(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?Fg(e):0}else return!1}}function Fg(e){return Eg(e)?e.nodeValue.length:e.childNodes.length}function Ig(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function Lg(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Rg(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function zg(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(Tg(u)){let e,f=u==c.body,p=1,m=1,h=!0,g=!0;if(f)e=Lg(l);else{let t=getComputedStyle(u);if(/^(fixed|sticky)$/.test(t.position)&&(d=!0),(u.scrollHeight<=u.clientHeight||!/auto|scroll/.test(t.overflowY))&&(g=!1),(u.scrollWidth<=u.clientWidth||!/auto|scroll/.test(t.overflowX))&&(h=!1),!h&&!g){u=u.assignedSlot||u.parentNode;continue}let n=u.getBoundingClientRect();({scaleX:p,scaleY:m}=Rg(u,n)),e={left:n.left,right:n.left+u.clientWidth*p,top:n.top,bottom:n.top+u.clientHeight*m}}let _=0,v=0;if(g){if(i==`nearest`)t.top0&&t.bottom>e.bottom+v&&(v=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(v=t.bottom-e.bottom+o,n<0&&t.top-v0&&t.right>e.right+_&&(_=t.right-e.right+a)):t.right>e.right-a&&(_=t.right-e.right+a,n<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Bg(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(Tg(a))!i&&a.scrollHeight>a.clientHeight&&/scroll|auto/.test(getComputedStyle(a).overflowY)&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&/scroll|auto/.test(getComputedStyle(a).overflowX)&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var Vg=class{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:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?Fg(t):0),n,Math.min(e.focusOffset,n?Fg(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Hg(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)Tg(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function Ug(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var Wg=null;Z.safari&&Z.safari_version>=26&&(Wg=!1);function Gg(e){if(e.setActive)return e.setActive();if(Wg)return e.focus(Wg);let t=Hg(e);e.focus(Wg==null?{get preventScroll(){return Wg={preventScroll:!0},!0}}:void 0),Wg||(Wg=!1,Ug(t))}var Kg;function qg(e,t,n=t){let r=Kg||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function Jg(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Yg(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Xg(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,Fg(n));;)if(r){if(!Tg(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=Fg(n))}else if(n==e)return!0;else r=Mg(n),n=n.parentNode}function Zg(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Qg(e,t){for(let n=e,r=t;;)if(Eg(n)&&r>0)return{node:n,offset:r};else if(Tg(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=Fg(n)}else if(n.parentNode&&!Ng(n))r=Mg(n),n=n.parentNode;else return null}function $g(e,t){for(let n=e,r=t;;)if(Eg(n)&&r=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.fromt))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function f_(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;e-=3)if(c_[e+1]==-r){let n=c_[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(p_[t]=p_[c_[e]]=r),s=e;break}}else if(c_.length==189)break;else c_[s++]=t,c_[s++]=n,c_[s++]=c}else if((o=p_[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=c_[t+2];if(n&2)break;if(e)c_[t+2]|=2;else{if(n&4)break;c_[t+2]|=4}}}}}function g_(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=ic;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),p_[--t]=u;c=o}else a=o,c++}}}function __(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;cc&&o.push(new d_(c,m.from,f)),v_(e,m.direction==n_==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?p_[p]!=s:p_[p]==s))break;else p++;d?__(e,c,p,r+1,i,d,o):ct;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=p_[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(p_[e-1]==s)break run;else break}d?d.push(m):(m.top_.length;)p_[p_.length]=256;let r=[],i=t==n_?0:1;return v_(e,i,i,n,0,e.length,r),r}function b_(e){return[new d_(0,e,0)]}var x_=``;function S_(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=d_.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=om(e.text,a,s.forward(i,n));(ls.to)&&(l=c),x_=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?X.cursor(e.to,1):X.cursor(e.from,-1);if(u.level+ +!ie.some(e=>e)}),P_=wm.define({combine:e=>e.some(e=>e)}),F_=wm.define(),I_=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(X.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},L_=Qm.define({map:(e,t)=>e.map(t)}),R_=Qm.define();function z_(e,t,n){let r=e.facet(D_);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var B_=wm.define({combine:e=>!e.length||e[0]}),V_=0,H_=wm.define({combine(e){return e.filter((t,n)=>{for(let r=0;r{let t=[];return o&&t.push(q_.of(t=>{let n=t.plugin(e);return n?o(n):_g.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},W_=class{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.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){z_(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(z_(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){z_(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},G_=wm.define(),K_=wm.define(),q_=wm.define(),J_=wm.define(),Y_=wm.define(),X_=wm.define(),Z_=wm.define();function Q_(e,t){let n=e.state.facet(Z_);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return bh.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let t=r[e].spec.bidiIsolate,n;if(a>0&&c.length&&(n=c[c.length-1]).to==o&&n.direction==t)n.to=s,c=n.inner;else{let e={from:o,to:s,direction:t,inner:[]};c.push(e),c=e.inner}}}}),$_(t.text,i)}function $_(e,t){for(let n of t){if(n.direction==null){for(let t=n.from,r=0;t0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAr.push(new rv(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,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}},av=[],ov=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return av}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 e=this.domAttrs;e&&fg(this.dom,e)}}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,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=Mg(this.dom),r=this.length?e>0:t>0;return new e_(this.parent.dom,n+ +!!r,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 lv)return e;return null}static get(e){return e.cmTile}},sv=class extends ov{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 t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=cv(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=cv(r);this.length=a}};function cv(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var lv=class extends sv{constructor(e,t){super(t),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 t=ov.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof uv)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(se||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},uv=class e extends sv{constructor(e,t){super(e),this.wrapper=t}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(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},dv=class e extends sv{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return n&&r||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&pv(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):fv(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new e_(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new e_(e.dom,0);e==n.tile&&(a=!0)}}return new e_(this.dom,0)}};function fv(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Ag(t);return n[n.length-1]||null}function pv(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.topr&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?Z.chrome||Z.gecko||(e?(i--,o=1):a=0)?0:s.length-1];return Z.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:Ig(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},gv=class e extends ov{constructor(e,t,n,r){super(e,t,r),this.widget=n}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,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Ig(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top0==n)}},vv=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i0?s.length<=e:s.length=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof mv&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(Av(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&ov.get(n.dom)&&(e=Av(n.dom));let t=mv.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=ov.get(e.text);i&&this.cache.reused.set(i,2);let a=new hv(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).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 t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=Dv;let n=dv.start(e,t||this.cache.find(dv)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}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,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof mv&&a.mark.eq(i))n=a,t--;else{let e=mv.of(i,this.cache.find(mv,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Tv(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(Z.ios&&Tv(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(Mv,0,32)||new gv(Mv.toDOM(),0,Mv,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 t=e.rank*102+e.value.rank,n=new yv(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.frome.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(_v,void 0,1);return n&&(n.flags=t),n||new _v(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},xv=class{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},Sv=[gv,dv,hv,mv,_v,uv,lv];for(let e=0;e[]),this.index=Sv.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=ar){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof mv&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof mv&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=bh.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof bg){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?jv.block:jv.inline),c=Ev(a),l=this.cache.findWidget(i,t-e,c)||gv.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=Ov(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=ov.get(r);if(r==this.view.contentDOM)break;e instanceof mv?t.push(e):e?.isLine()?n=e:e instanceof uv||(r.nodeName==`DIV`&&!n?n=new dv(r,Dv):n||t.push(mv.of(new vg({tagName:r.nodeName.toLowerCase(),attributes:mg(r)}),r)))}return n?{line:n,marks:t}:null}};function Tv(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function Ev(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var Dv={class:`cm-line`};function Ov(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&lg(n,e),r&&(e.class+=` `+r)),e}function kv(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof mv&&t.push(r.mark)}return t}function Av(e){let t=ov.get(e);return t&&t.setDOM(e.cloneNode()),e}var jv=class extends hg{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}};jv.inline=new jv(`span`),jv.block=new jv(`div`);var Mv=new class extends hg{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},Nv=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=_g.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 lv(e,e.contentDOM),this.updateInner([new rv(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.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 n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!Wv(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?Lv(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new rv(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Z.ie||Z.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=Bv(i,this.decorations,e.changes);o.length&&(t=rv.extendWithRanges(t,o));let s=Hv(a,this.blockWrappers,e.changes);return s.length&&(t=rv.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new wv(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&ov.get(t.text)&&r.cache.reused.set(ov.get(t.text),2),this.tile=r.run(e,t),Pv(n,r.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 r=Z.chrome||Z.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&kg(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Z.gecko&&s.empty&&!this.hasComposition&&Fv(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new e_(e,0),o=!0}let u=this.view.observer.selectionRange;!o&&u.focusNode&&(jg(c.node,c.offset,u.anchorNode,u.anchorOffset)&&jg(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,s))||(this.view.observer.ignore(()=>{Z.android&&Z.chrome&&n.contains(u.focusNode)&&Uv(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Dg(this.view.root);if(e){if(s.empty){if(Z.gecko){let e=Rv(c.node,c.offset);if(e&&e!=3){let t=(e==1?Qg:$g)(c.node,c.offset);t&&(c=new e_(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new e_(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new e_(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&jg(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Dg(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=Fg(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!ov.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof Gv?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==t_.LTR,c=0,l=(e,u,d)=>{for(let f=0;fr);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof uv)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?Ag(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?t_.RTL:t_.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Ag(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=Ag(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(_g.replace({widget:new Gv(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return _g.set(e)}updateDeco(){let e=1,t=this.view.state.facet(q_).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Y_).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(bh.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(F_))try{if(t(this.view,e.range,e))return!0}catch(e){z_(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=tv(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(zg(this.view.scrollDOM,a,t.head1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){Pv(this.tile)}};function Pv(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)Pv(n,t)}}function Fv(e){return Tg(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function Iv(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Qg(n.focusNode,n.focusOffset),i=$g(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=ov.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=ov.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function Lv(e,t,n){let r=Iv(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new rv(c.mapPos(a),c.mapPos(o),a,o),text:i}}function Rv(e,t){return Tg(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t{et.from&&(n=!0)}),n}var Gv=class extends hg{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 Kv(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return X.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=om(i.text,a,!1):s=om(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=om(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;se.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+Fh(o,a,e.state.tabSize)}function Jv(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.tot)return i;(!e||i.type==gg.Text&&(e.type!=i.type||(n<0?i.fromt)))&&(e=i)}}return e||r}return r}function Yv(e,t,n,r){let i=Jv(e,t.head,t.assoc||-1),a=!r||i.type!=gg.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAndSideAtCoords({x:n==(r==t_.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o)return X.cursor(o.pos,o.assoc)}return X.cursor(n?i.to:i.from,n?1:-1)}function Xv(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=S_(i,a,o,s,n),l=x_;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=` +`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?X.cursor(i.from,-1):X.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function Zv(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==ch.Space&&(i=t),i==t}}function Qv(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return X.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=ry(e,{x:d,y:r},!1,a);if(n?r>c.bottom:rs:u{if(t>e&&tt(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:X.cursor(r,re.viewState.docHeight)return new ny(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==gg.Text){if(r<0?l.toe.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==gg.Text){let t=qv(e,i,l,o,s);return new ny(t,t==l.from?1:-1)}}if(l.type!=gg.Text)return c<(l.top+l.bottom)/2?new ny(l.from,1):new ny(l.to,-1);let u=e.docView.lineAt(l.from,2);return u&&u.length==l.length||(u=e.docView.lineAt(l.from,-2)),new iy(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var iy=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from>1;adjust:if(a.has(f)){for(let e=1;e=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e1)){if(t.bottomthis.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==t_.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r{let i=n[r]-t,a=n[r+1]-t;return qg(e.dom,i,a).getClientRects()});return r.after?new ny(n[r.i+1],-1):new ny(n[r.i],1)}scanTile(e,t){if(!e.length)return new ny(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r{let n=e.children[t];return n.flags&48?null:(Tg(n.dom)?n.dom:qg(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new ny(n[r.i+1],-1):new ny(a,1)}},ay=`￿`,oy=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(ph.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=ay}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=ov.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=ov.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:Ng(r))||Ng(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!cy(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=ov.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else Eg(e)?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():Tg(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(Eg(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(sy(e,n.node,n.offset)?t:0))}};function sy(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=dy(e.docView.tile,t,n,0))){let t=i||a?[]:gy(e),n=new oy(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=_y(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!Og(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!Og(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Z.ios||Z.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(X.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=X.create([X.cursor(n,r)])}else this.newSel=X.single(r,n)}}};function dy(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;cn)return dy(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function fy(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||Z.android&&t.text.length=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:Yp.of(t.text.slice(a.from-e,u).split(ay))}:(d=hy(l,t.text,s-e,c))&&(Z.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:Yp.of(t.text.slice(d.from,d.toB).split(ay))})}else r&&(!e.hasFocus&&i.facet(B_)||vy(r,a))&&(r=null);if(!n&&!r)return!1;if((Z.mac||Z.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=X.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Yp.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:Z.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&e.lineWrapping&&(r&&=X.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:Yp.of([` `])}),n)return py(e,n,r,o);if(r&&!vy(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=ey(i.facet(X_).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function py(e,t,n,r=-1){if(Z.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(Z.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&Jg(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.lengthi.head)&&Jg(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Jg(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=my(e,t,n);return e.state.facet(k_).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function my(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.froma.to){let n=t.fromt(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:X.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.fromt.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&Iv(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?X.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function hy(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function gy(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new ly(n,r)),(i!=n||a!=r)&&t.push(new ly(i,a))),t}function _y(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?X.create([X.cursor(r+t,-1)]):X.single(n+t,r+t)}function vy(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var yy=class{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,Z.safari&&e.contentDOM.addEventListener(`input`,()=>null),Z.gecko&&nb(e.contentDOM.ownerDocument)}handleEvent(e){Ny(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=Sy(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}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&&Ty.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Z.android&&Z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Cy.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||wy.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&Z.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&by(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from0?!0:Z.safari&&!Z.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 by(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function xy(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){z_(n.state,e)}}}function Sy(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(xy(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(xy(t.value,r))}}for(let e in Py)n(e).handlers.push(Py[e]);for(let e in Fy)n(e).observers.push(Fy[e]);return t}var Cy=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],wy=`dthko`,Ty=[16,17,18,20,91,92,224,225],Ey=6;function Dy(e){return Math.max(0,e)*.7+8}function Oy(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var ky=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Bg(e.contentDOM),this.atoms=e.state.facet(X_).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(ph.allowMultipleSelections)&&Ay(e,t),this.dragging=My(e,t)&&Gy(t)==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&&Oy(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=tv(this.view);e.clientX-s.left<=r+Ey?t=-Dy(r-e.clientX):e.clientX+s.right>=a-Ey&&(t=Dy(e.clientX-a)),e.clientY-s.top<=i+Ey?n=-Dy(i-e.clientY):e.clientY+s.bottom>=o-Ey&&(n=Dy(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??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,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=ey(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Ay(e,t){let n=e.state.facet(w_);return n.length?n[0](t):Z.mac?t.metaKey:t.ctrlKey}function jy(e,t){let n=e.state.facet(T_);return n.length?n[0](t):Z.mac?!t.altKey:!t.ctrlKey}function My(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Dg(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function Ny(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=ov.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var Py=Object.create(null),Fy=Object.create(null),Iy=Z.ie&&Z.ie_version<15||Z.ios&&Z.webkit_version<604;function Ly(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),zy(e,n.value)},50)}function Ry(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function zy(e,t){t=Ry(e.state,j_,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(Zy!=null&&n.selection.ranges.every(e=>e.empty)&&Zy==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:X.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:X.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}Fy.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,Z.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},Fy.wheel=Fy.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Py.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),Fy.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},Fy.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},Fy.touchend=(e,t)=>{e.inputState.touchActive=!1},Py.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(E_))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=Ky(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new ky(e,t,n,r)),r&&e.observer.ignore(()=>{Gg(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function By(e,t,n,r){if(r==1)return X.cursor(t,n);if(r==2)return Kv(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(Uy+1)%3:1}function Ky(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Gy(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=By(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=By(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i1&&(c=qy(i,s.pos))?c:o?i.addRange(l):X.create([l])}}}function qy(e,t){for(let n=0;n=t)return X.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}Py.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=X.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,Ry(e.state,M_,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},Py.dragend=e=>(e.inputState.draggedContent=null,!1);function Jy(e,t,n,r){if(n=Ry(e.state,j_,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&jy(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}Py.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Jy(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Jy(e,t,n,!0),!0}return!1},Py.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Iy?null:t.clipboardData;return n?(zy(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(Ly(e),!1)};function Yy(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function Xy(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:Ry(e,M_,t.join(e.lineBreak)),ranges:n,linewise:r}}var Zy=null;Py.copy=Py.cut=(e,t)=>{if(!kg(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=Xy(e.state);if(!n&&!i)return!1;Zy=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=Iy?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Yy(e,n),!1)};var Qy=Ym.define();function $y(e,t){let n=[];for(let r of e.facet(A_)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Qy.of(!0)}):null}function eb(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=$y(e.state,t);n?e.dispatch(n):e.update([])}},10)}Fy.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),eb(e)},Fy.blur=e=>{e.observer.clearSelectionRange(),eb(e)},Fy.compositionstart=Fy.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},Fy.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Z.chrome&&Z.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},Fy.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Py.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return py(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(Z.chrome&&Z.android&&(n=Cy.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Z.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),Z.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>Fy.compositionend(e,t),20),!1};var tb=new Set;function nb(e){tb.has(e)||(tb.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var rb=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],ib=!1;function ab(){ib=!1}var ob=class{constructor(e){this.lineWrapping=e,this.doc=Yp.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}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 rb.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>ub&&(ib=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,lb.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,lb.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,sa*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i=i&&a(this.lineAt(0,lb.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},hb=class e extends mb{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new cb(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof gb&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof gb?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):db.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||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:``})`}},gb=class e extends db{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return db.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=ub&&(s=-2);let c=new hb(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=db.of(r);return(s<0||Math.abs(c.height-this.height)>=ub||Math.abs(s-this.heightMetrics(t,n).perLine)>=ub)&&(ib=!0),fb(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},_b=class extends db{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return eo))return c;let l=t==lb.ByPosNoHeight?lb.ByPosNoHeight:lb.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,lb.ByPos,n,r,i);e=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&vb(i,a-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?db.of(this.break?[e,null,t]:[e,t]):(this.left=fb(this.left,e),this.right=fb(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function vb(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof gb&&(r=e[t+1])instanceof gb&&e.splice(t-1,3,new gb(n.length+1+r.length))}var yb=5,bb=class e{constructor(e,t){this.pos=e,this.oracle=t,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,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof hb?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new hb(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=yb)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new hb(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new gb(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof hb)return e;let t=new hb(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof hb)&&!this.isCovered?this.nodes.push(new hb(0,-1,0)):(this.writtenTot.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function wb(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function Tb(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Eb=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new ob(n),this.stateDeco=Fb(t),this.heightMap=db.empty().applyChanges(this.stateDeco,Yp.empty,this.heightOracle.setDoc(t.doc),[new rv(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=_g.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new kb(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Pb:Ib.get(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(Lb(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=Fb(this.state);let r=e.changedRanges,i=rv.extendWithRanges(r,xb(n,this.stateDeco,e?e.changes:mm.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ab(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||ib)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heads.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!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),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(P_)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?t_.RTL:t_.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=Rg(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Bg(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=Zg(this.scrollParent||e.win);let m=(this.printing?Tb:Cb)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!wb(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),ab();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?db.empty().applyChanges(this.stateDeco,Yp.empty,this.heightOracle,[new rv(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new sb(n.from,i))}ib&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new kb(r.lineAt(a-n*1e3,lb.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,lb.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(es.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,lb.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i>1,a=r<<1;if(this.defaultTextDirection!=t_.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-rr&&ee.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)e.fromt));if(!f){if(ae.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(X.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new Eb(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length2e6)for(let n of e)n.from>=t.from&&n.fromt.from&&s(t.from,c,t,i),le.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];bh.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Lb(this.heightMap.lineAt(e,lb.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(t=>t.top<=e&&t.bottom>=e)||Lb(this.heightMap.lineAt(this.scaler.fromDOM(e),lb.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Lb(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}},kb=class{constructor(e,t){this.from=e,this.to=t}};function Ab(e,t,n){let r=[],i=e,a=0;return bh.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function Mb(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function Nb(e,t){for(let n of e)if(t(n))return n}var Pb={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function Fb(e){let t=e.facet(q_).filter(e=>typeof e!=`function`),n=e.facet(Y_).filter(e=>typeof e!=`function`);return n.length&&t.push(bh.join(n)),t}var Ib=class e{constructor(e,t){this.scale=e,this.viewports=t}static get(t,n,r){let i=0,a=0,o=0,s=r.map(({from:e,to:r})=>{let a=n.lineAt(e,lb.ByPos,t,0,0).top,o=n.lineAt(r,lb.ByPos,t,0,0).bottom;return i+=o-a,{from:e,to:r,top:a,bottom:o,domTop:0,domBottom:0}});if(n.height-i<10)return Pb;let c=(7e6-i)/(n.height-i);for(let e of s)e.domTop=o+(e.top-a)*c,o=e.domBottom=e.domTop+(e.bottom-e.top),a=e.bottom;return new e(c,s)}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=te.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function Lb(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new cb(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Lb(e,t)):e._content)}var Rb=wm.define({combine:e=>e.join(` `)}),zb=wm.define({combine:e=>e.indexOf(!0)>-1}),Bb=Bh.newName(),Vb=Bh.newName(),Hb=Bh.newName(),Ub={"&light":`.`+Vb,"&dark":`.`+Hb};function Wb(e,t,n){return new Bh(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Gb=Wb(`.`+Bb,{"&":{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:`baseline`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) 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`}},Ub),Kb={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},qb=Z.ie&&Z.ie_version<=11,Jb=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Vg,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(t=>{for(let e of t)this.queue.push(e);(Z.ie&&Z.ie_version<=11||Z.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Z.chrome&&Z.chrome_version<126)&&(this.editContext=new Qb(e),e.state.facet(B_)&&(e.contentDOM.editContext=this.editContext.editContext)),qb&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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(()=>{this.view.docView?.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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(this.pendingRecords().length>0),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((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(B_)?n.root.activeElement!=this.dom:!kg(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Z.ie&&Z.ie_version<=11||Z.android&&Z.chrome)&&!n.state.selection.main.empty&&r.focusNode&&jg(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Dg(e.root);if(!t)return!1;let n=Z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&Zb(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=kg(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Jg(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&e!=`Enter`||(this.delayedAndroidKey={key:e,keyCode:t,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 t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&kg(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new uy(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=fy(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Yb(t,e.previousSibling||e.target.previousSibling,-1),r=Yb(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.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(B_)!=e.state.facet(B_)&&(e.view.contentDOM.editContext=e.state.facet(B_)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.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 Yb(e,t,n){for(;t;){let r=ov.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function Xb(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return jg(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function Zb(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Xb(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?Xb(e,n):null}var Qb=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=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=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&ithis.to&&(s=i);let l=hy(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=X.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));vy(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:Yp.of(n.text.slice(l.from,l.toB).split(` +`))};if((Z.mac||Z.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:Yp.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);py(e,u,X.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i{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:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=Dg(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(ithis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.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||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+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 t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},$b=class e{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={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Yg(e.parent)||document,this.viewState=new Ob(this,e.state||ph.create(e)),e.scrollTo&&e.scrollTo.is(L_)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(H_).map(e=>new W_(e));for(let e of this.plugins)e.update(this);this.observer=new Jb(this),this.inputState=new yy(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Nv(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof $m?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Qy))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=$y(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(ph.phrases)!=this.state.facet(ph.phrases))return this.setState(a);i=iv.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new I_(t.empty?t:X.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(L_)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=nx.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(nv)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(Rb)!=i.state.facet(Rb)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(O_))try{e(i)}catch(e){z_(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!fy(this,u)&&l.force&&Jg(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw 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 t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new Ob(this,e),this.plugins=e.facet(H_).map(e=>new W_(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new Nv(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(H_),n=e.state.facet(H_);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new W_(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(Zg(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return z_(this.state,e),tx}}),u=iv.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e1||e<-1)&&!(Z.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(O_))e(t)}get themeClasses(){return Bb+` `+(this.state.facet(zb)?Hb:Vb)+` `+this.state.facet(Rb)}updateAttrs(){let e=rx(this,G_,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(B_)?`true`:`false`,class:`cm-content`,style:`${Z.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),rx(this,K_,t);let n=this.observer.ignore(()=>{let n=pg(this.contentDOM,this.contentAttrs,t),r=pg(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(nv);let t=this.state.facet(e.cspNonce);Bh.mount(this.root,this.styleModules.concat(Gb).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw 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 t=0;tt.plugin==e)||null),t&&t.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,t,n){return ty(this,e,Xv(this,e,t,n))}moveByGroup(e,t){return ty(this,e,Xv(this,e,t,t=>Zv(this,e.head,t)))}visualLineSide(e,t){return t?X.cursor(e.to,1):X.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return Yv(this,e,t,n)}moveVertically(e,t,n){return ty(this,e,Qv(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=ry(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),ry(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[d_.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==t_.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(N_)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>ex)return b_(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||f_(r.isolates,n=Q_(this,e))))return r.order;n||=Q_(this,e);let r=y_(e.text,t,n);return this.bidiCache.push(new nx(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||Z.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Gg(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.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return L_.of(new I_(typeof e==`number`?X.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return L_.of(new I_(X.cursor(n.from),`start`,`start`,n.top-e,t,!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 U_.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return U_.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Bh.newName(),r=[Rb.of(n),nv.of(Wb(`.${n}`,e))];return t&&t.dark&&r.push(zb.of(!0)),r}static baseTheme(e){return Pm.lowest(nv.of(Wb(`.`+Bb,e,Ub)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&ov.get(t)||ov.get(e))?.root?.view||null}};$b.styleModule=nv,$b.inputHandler=k_,$b.clipboardInputFilter=j_,$b.clipboardOutputFilter=M_,$b.scrollHandler=F_,$b.focusChangeEffect=A_,$b.perLineTextDirection=N_,$b.exceptionSink=D_,$b.updateListener=O_,$b.editable=B_,$b.mouseSelectionStyle=E_,$b.dragMovesSelection=T_,$b.clickAddsSelectionRange=w_,$b.decorations=q_,$b.blockWrappers=J_,$b.outerDecorations=Y_,$b.atomicRanges=X_,$b.bidiIsolatedRanges=Z_,$b.cursorScrollMargin=wm.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),$b.scrollMargins=ev,$b.darkTheme=zb,$b.cspNonce=wm.define({combine:e=>e.length?e[0]:``}),$b.contentAttributes=K_,$b.editorAttributes=G_,$b.lineWrapping=$b.contentAttributes.of({class:`cm-lineWrapping`}),$b.announce=Qm.define();var ex=4096,tx={},nx=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:t_.LTR;for(let a=Math.max(0,t.length-10);a=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&lg(a,n)}return n}var ix=Z.mac?`mac`:Z.windows?`win`:Z.linux?`linux`:`key`;function ax(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;ee.concat(t),[]))),n}var dx=null,fx=4e3;function px(e,t=ix){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>ax(e,t));for(let t=1;t{let r=dx={view:t,prefix:n,scope:e};return setTimeout(()=>{dx==r&&(dx=null)},fx),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,mx))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var mx=null;function hx(e,t,n,r){mx=t;let i=Yh(t),a=um(lm(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;dx&&dx.view==n&&dx.scope==r&&(o=dx.prefix+` `,Ty.indexOf(t.keyCode)<0&&(c=!0,dx=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+ox(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Z.windows&&t.ctrlKey&&t.altKey)&&!(Z.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=Uh[t.keyCode])&&p!=i?(d(f[o+ox(p,t,!0)])||t.shiftKey&&(m=Wh[t.keyCode])!=i&&m!=p&&d(f[o+ox(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+ox(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),mx=null,s}var gx=!Z.ios,_x=Z.gecko&&Z.gecko_version==153?`#ffffff01`:`transparent`;({...gx?{"& ::selection, &::selection":{backgroundColor:`${_x} !important`}}:{}}),{...gx?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}},/x/.unicode;var vx=class extends hg{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?Ag(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Ig(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function yx(e){let t=U_.fromClass(class{constructor(t){this.view=t,this.placeholder=e?_g.set([_g.widget({widget:new vx(e),side:1}).range(0)]):_g.none}get decorations(){return this.view.state.doc.length?_g.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,$b.contentAttributes.of({"aria-placeholder":e})]:t}var bx=`-10000px`,xx=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;nt[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function Sx(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function Cx(e){let{left:t,right:n}=Sx(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var wx=wm.define({combine:e=>({position:Z.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||Cx})}),Tx=new WeakMap,Ex=U_.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(wx);this.position=t.position,this.parent=t.parent,this.classes=e.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 xx(e,Ax,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(wx);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=bx,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 e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Z.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=Sx(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=tv(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(wx).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1)){l.style.top=bx;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=Tx.get(c)??d.bottom-d.top,g=c.offset||kx,_=this.view.textDirection==t_.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.yn.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(bv&&e.topx&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,Dx(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,Dx(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=bx}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Dx(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var Ox=$b.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:`14px`,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`}}}),kx={x:0,y:0},Ax=wm.define({enables:[Ex,Ox]}),jx=wm.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),Mx=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new xx(e,jx,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},Nx=Ax.compute([jx],e=>{let t=e.facet(jx);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:Mx.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Px=wm.define(),Fx=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,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;en.bottom||t.xn.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==t_.RTL?-1:1;i=t.x{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>z_(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Ex),t=e?e.manager.tooltips.findIndex(e=>e.create==Mx.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){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:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!Lx(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!Rx(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},Ix=4;function Lx(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-Ix&&t.clientX<=r+Ix&&t.clientY>=i-Ix&&t.clientY<=a+Ix}function Rx(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,s)=t&&c<=n}function zx(e,t={}){let n=Qm.define(),r=new WeakMap,i=jm.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,fm.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(Bx)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>jx.from(e)}),a=U_.define(a=>new Fx(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,Px.of(a),Nx]}}var Bx=Qm.define(),Vx=wm.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}}),Hx=U_.fromClass(class{constructor(e){this.input=e.state.facet(Gx),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Vx);this.top=new Ux(e,!0,t.topContainer),this.bottom=new Ux(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(Vx);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Ux(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Ux(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Gx);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>$b.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),Ux=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Wx(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Wx(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 Wx(e){let t=e.nextSibling;return e.remove(),t}var Gx=wm.define({enables:Hx}),Kx=class extends hh{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Kx.prototype.elementClass=``,Kx.prototype.toDOM=void 0,Kx.prototype.mapMode=fm.TrackBefore,Kx.prototype.startSide=Kx.prototype.endSide=-1,Kx.prototype.point=!0;var qx=1024,Jx=0,Yx=class{constructor(e,t){this.from=e,this.to=t}},Xx=class{constructor(e={}){this.id=Jx++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=$x.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Xx.closedBy=new Xx({deserialize:e=>e.split(` `)}),Xx.openedBy=new Xx({deserialize:e=>e.split(` `)}),Xx.group=new Xx({deserialize:e=>e.split(` `)}),Xx.isolate=new Xx({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Xx.contextHash=new Xx({perNode:!0}),Xx.lookAhead=new Xx({perNode:!0}),Xx.mounted=new Xx({perNode:!0});var Zx=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Xx.mounted.id]}},Qx=Object.create(null),$x=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Qx,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[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 t=this.prop(Xx.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Xx.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};$x.none=new $x(``,Object.create(null),0,8);var eS=class e{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(a|rS.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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 t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:CS($x.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e($x.none,t,n,r)))}static build(e){return bS(e)}};iS.empty=new iS($x.none,[],[],0);var aS=class e{constructor(e,t){this.buffer=e,this.index=t}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 e(this.buffer,this.index)}},oS=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return $x.none}toString(){let e=[];for(let t=0;t0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function cS(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&rS.EnterBracketed&&l instanceof iS&&(d=Zx.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||sS(i,r,u,u+l.length)){if(l instanceof oS){if(a&rS.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new mS(new pS(o,l,t,u),null,e)}else if(a&rS.IncludeAnonymous||!l.type.isAnonymous||yS(l)){let s;if(!(a&rS.IgnoreMounts)&&(s=Zx.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&rS.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&rS.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n: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(t,n,r=0){let i;if(!(r&rS.IgnoreOverlays)&&(i=Zx.get(this._tree))&&i.overlay){let a=t-this.from,o=r&rS.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,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 dS(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function fS(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var pS=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},mS=class e extends lS{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,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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(t,n,r=0){if(r&rS.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new iS(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function hS(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;rn.from||i.to=t){let o=new uS(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(cS(o,t,n,!1))}}return i?hS(i):r}var vS=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~rS.EnterBracketed,e instanceof uS)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof uS?(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,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,t,n=this.mode){return this.buffer?n&rS.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&rS.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&rS.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:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&rS.IncludeAnonymous||e instanceof oS||!e.type.isAnonymous||yS(e))return!1}return!0}move(e,t){if(t&&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,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e=0;i--){if(i<0)return fS(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function yS(e){return e.children.some(e=>e instanceof oS||!e.type.isAnonymous||yS(e))}function bS(e){let{buffer:t,nodeSet:n,maxBufferLength:r=qx,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new aS(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,A=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new oS(t,C-k.start,n),A=k.start-e}else{let e=o.pos-w;o.next();let t=[],s=[],c=x>=a?x:-1,h=0,g=C,_=T;for(;o.pos>e;)c>=0&&o.id==c&&o.size>=0?(o.end<=g-r&&(p(t,s,S,h,o.end,g,c,_,E),h=t.length,g=o.end,_=l),o.next()):b>2500?d(S,e,t,s):(c>=0&&o.size==-1&&i[o.id].type==n.types[c]&&(h=0&&h>0&&h-1&&h>0){let e=f(D,E);O=CS(D,t,s,0,t.length,0,C-S,e,e)}else O=m(D,t,s,C-S,T-C,E)}_.push(O),v.push(A)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new oS(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof iS){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Xx.lookAhead))&&(a=r[o]+s.length+c-i)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Xx.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Xx.lookAhead,i];o=o?[e].concat(o):[e]}return new iS(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new iS(s[e.topID],_.reverse(),v.reverse(),y)}var xS=new WeakMap;function SS(e,t){if(!e.isAnonymous||t instanceof oS||t.type!=e)return 1;let n=xS.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof iS)){n=1;break}n+=SS(e,r)}xS.set(t,n)}return n}function CS(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(CS(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var wS=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s=r)for(;o&&o.from=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=anew Yx(e.from,e.to)):[new Yx(0,0)]:[new Yx(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},ES=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new Xx({perNode:!0});var DS=0,OS=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=DS++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new AS(e);return e=>e.modified.indexOf(t)>-1?e:AS.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},kS=0,AS=class e{constructor(e){this.name=e,this.instances=[],this.id=kS++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&jS(n,e.modified));if(r)return r;let i=[],a=new OS(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=MS(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function jS(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function MS(e){let t=[[]];for(let n=0;nt.length-e.length)}function NS(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new FS(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return PS.add(t)}var PS=new Xx({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new FS(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),FS=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function LS(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function RS(e,t,n,r=0,i=e.length){let a=new zS(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var zS=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=BS(e)||FS.empty,u=LS(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(Xx.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function BS(e){let t=e.type.prop(PS);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var Q=OS.define,VS=Q(),HS=Q(),US=Q(HS),WS=Q(HS),GS=Q(),KS=Q(GS),qS=Q(GS),JS=Q(),YS=Q(JS),XS=Q(),ZS=Q(),QS=Q(),$S=Q(QS),eC=Q(),$={comment:VS,lineComment:Q(VS),blockComment:Q(VS),docComment:Q(VS),name:HS,variableName:Q(HS),typeName:US,tagName:Q(US),propertyName:WS,attributeName:Q(WS),className:Q(HS),labelName:Q(HS),namespace:Q(HS),macroName:Q(HS),literal:GS,string:KS,docString:Q(KS),character:Q(KS),attributeValue:Q(KS),number:qS,integer:Q(qS),float:Q(qS),bool:Q(GS),regexp:Q(GS),escape:Q(GS),color:Q(GS),url:Q(GS),keyword:XS,self:Q(XS),null:Q(XS),atom:Q(XS),unit:Q(XS),modifier:Q(XS),operatorKeyword:Q(XS),controlKeyword:Q(XS),definitionKeyword:Q(XS),moduleKeyword:Q(XS),operator:ZS,derefOperator:Q(ZS),arithmeticOperator:Q(ZS),logicOperator:Q(ZS),bitwiseOperator:Q(ZS),compareOperator:Q(ZS),updateOperator:Q(ZS),definitionOperator:Q(ZS),typeOperator:Q(ZS),controlOperator:Q(ZS),punctuation:QS,separator:Q(QS),bracket:$S,angleBracket:Q($S),squareBracket:Q($S),paren:Q($S),brace:Q($S),content:JS,heading:YS,heading1:Q(YS),heading2:Q(YS),heading3:Q(YS),heading4:Q(YS),heading5:Q(YS),heading6:Q(YS),contentSeparator:Q(JS),list:Q(JS),quote:Q(JS),emphasis:Q(JS),strong:Q(JS),link:Q(JS),monospace:Q(JS),strikethrough:Q(JS),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:eC,documentMeta:Q(eC),annotation:Q(eC),processingInstruction:Q(eC),definition:OS.defineModifier(`definition`),constant:OS.defineModifier(`constant`),function:OS.defineModifier(`function`),standard:OS.defineModifier(`standard`),local:OS.defineModifier(`local`),special:OS.defineModifier(`special`)};for(let e in $){let t=$[e];t instanceof OS&&(t.name=e)}IS([{tag:$.link,class:`tok-link`},{tag:$.heading,class:`tok-heading`},{tag:$.emphasis,class:`tok-emphasis`},{tag:$.strong,class:`tok-strong`},{tag:$.keyword,class:`tok-keyword`},{tag:$.atom,class:`tok-atom`},{tag:$.bool,class:`tok-bool`},{tag:$.url,class:`tok-url`},{tag:$.labelName,class:`tok-labelName`},{tag:$.inserted,class:`tok-inserted`},{tag:$.deleted,class:`tok-deleted`},{tag:$.literal,class:`tok-literal`},{tag:$.string,class:`tok-string`},{tag:$.number,class:`tok-number`},{tag:[$.regexp,$.escape,$.special($.string)],class:`tok-string2`},{tag:$.variableName,class:`tok-variableName`},{tag:$.local($.variableName),class:`tok-variableName tok-local`},{tag:$.definition($.variableName),class:`tok-variableName tok-definition`},{tag:$.special($.variableName),class:`tok-variableName2`},{tag:$.definition($.propertyName),class:`tok-propertyName tok-definition`},{tag:$.typeName,class:`tok-typeName`},{tag:$.namespace,class:`tok-namespace`},{tag:$.className,class:`tok-className`},{tag:$.macroName,class:`tok-macroName`},{tag:$.propertyName,class:`tok-propertyName`},{tag:$.operator,class:`tok-operator`},{tag:$.comment,class:`tok-comment`},{tag:$.meta,class:`tok-meta`},{tag:$.invalid,class:`tok-invalid`},{tag:$.punctuation,class:`tok-punctuation`}]);var tC=new Xx;function nC(e){return wm.define({combine:e?t=>t.concat(e):void 0})}var rC=new Xx,iC=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,ph.prototype.hasOwnProperty(`tree`)||Object.defineProperty(ph.prototype,"tree",{get(){return sC(this)}}),this.parser=t,this.extension=[gC.of(this),ph.languageData.of((e,t,n)=>{let r=aC(e,t,n),i=r.type.prop(tC);if(!i)return[];let a=e.facet(i),o=r.type.prop(rC);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return aC(e,t,n).type.prop(tC)==this.data}findRegions(e){let t=e.facet(gC);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(tC)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Xx.mounted);if(i){if(i.tree.prop(tC)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function sC(e){let t=e.field(iC.state,!1);return t?t.tree:iS.empty}var cC=class{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,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},lC=null,uC=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],iS.empty,0,r,[],null)}startParse(){return this.parser.startParse(new cC(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=iS.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(wS.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=lC;lC=this;try{return e()}finally{lC=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=dC(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=wS.applyChanges(r,e),i=iS.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);ne.from&&(this.fragments=dC(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends TS{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=lC;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new iS($x.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return lC}};function dC(e,t,n){return wS.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var fC=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=uC.create(t.facet(gC).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};iC.state=jm.define({create:fC.init,update(e,t){for(let e of t.effects)if(e.is(iC.setState))return e.value;return t.startState.facet(gC)==t.state.facet(gC)?e.apply(t):fC.init(t.state)}});var pC=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(pC=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var mC=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,hC=U_.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 t=this.view.state.field(iC.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(iC.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=pC(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,s=i.context.work(()=>mC&&mC()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:iC.setState.of(new fC(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>z_(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),gC=wm.define({combine(e){return e.length?e[0]:null},enables:e=>[iC.state,hC,$b.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),_C=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},vC=wm.define(),yC=wm.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function bC(e){let t=e.facet(yC);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function xC(e,t){let n=``,r=e.tabSize,i=e.facet(yC)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e=t?TC(e,n,t):null}var CC=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=bC(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Ph(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},wC=new Xx;function TC(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.fromr.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return EC(r,e,n)}function EC(e,t,n){for(let r=e;r;r=r.next){let e=OC(r.node);if(e)return e(AC.create(t,n,r))}return 0}function DC(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function OC(e){let t=e.type.prop(wC);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Xx.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>NC(e,!0,1,void 0,n&&!DC(e)?t.from:void 0)}return e.parent==null?kC:null}function kC(){return 0}var AC=class e extends CC{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(jC(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return EC(this.context.next,this.base,this.pos)}};function jC(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function MC(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function NC(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?MC(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function PC({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var FC=new Xx;function IC(e){let t=e.firstChild,n=e.lastChild;return t&&t.toe.prop(tC)==a.data:a?e=>e==a:void 0,this.style=IS(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Bh(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},RC=wm.define(),zC=wm.define({combine(e){return e.length?[e[0]]:null}});function BC(e){let t=e.facet(RC);return t.length?t:e.facet(zC)}function VC(e,t){let n=[UC],r;return e instanceof LC&&(e.module&&n.push($b.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(zC.of(e)):r?n.push(RC.computeN([$b.darkTheme],t=>t.facet($b.darkTheme)==(r==`dark`)?[e]:[])):n.push(RC.of(e)),n}var HC=class{constructor(e){this.markCache=Object.create(null),this.tree=sC(e.state),this.decorations=this.buildDeco(e,BC(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=sC(e.state),n=BC(e.state),r=n!=BC(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return _g.none;let n=new Ch;for(let{from:r,to:i}of e.visibleRanges)RS(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=_g.mark({class:r})))},r,i);return n.finish()}},UC=Pm.high(U_.fromClass(HC,{decorations:e=>e.decorations}));$.meta,$.link,$.heading,$.emphasis,$.strong,$.strikethrough,$.keyword,$.atom,$.bool,$.url,$.contentSeparator,$.labelName,$.literal,$.inserted,$.string,$.deleted,$.regexp,$.escape,$.string,$.variableName,$.variableName,$.typeName,$.namespace,$.className,$.variableName,$.macroName,$.propertyName,$.comment,$.invalid;var WC=1e4,GC=`()[]{}`,KC=new Xx;function qC(e,t,n){let r=e.prop(t<0?Xx.openedBy:Xx.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function JC(e){let t=e.type.prop(KC);return t?t(e.node):e}function YC(e,t,n,r={}){let i=r.maxScanDistance||WC,a=r.brackets||GC,o=sC(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=qC(r.type,n,a);if(i&&r.from0?t>=o.from&&to.from&&t<=o.to))return XC(e,t,n,r,o,i,a)}}return ZC(e,t,n,o,s.type,i,a)}function XC(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var QC=Object.create(null),$C=[$x.none],ew=[],tw=Object.create(null),nw=Object.create(null);for(let[e,t]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`]])nw[e]=iw(QC,t);function rw(e,t){ew.indexOf(e)>-1||(ew.push(e),console.warn(t))}function iw(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||$[n];r?typeof r==`function`?t.length?t=t.map(r):rw(n,`Modifier ${n} used at start of tag`):t.length?rw(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:rw(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=tw[i];if(a)return a.id;let o=tw[i]=$x.define({id:$C.length,name:r,props:[NS({[r]:n})]});return $C.push(o),o.id}t_.RTL,t_.LTR;var aw=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=uw(e.state,n.from);return r.line?sw(e):r.block?lw(e):!1};function ow(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var sw=ow(hw,0),cw=ow(mw,0),lw=ow((e,t)=>mw(e,t,pw(t)),0);function uw(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var dw=50;function fw(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-dw,r),o=e.sliceDoc(i,i+dw),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+dw),d=e.sliceDoc(i-dw,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function pw(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function mw(e,t,n=t.selection.ranges){let r=n.map(e=>uw(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>fw(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var gw=Ym.define(),_w=Ym.define(),vw=wm.define(),yw=wm.define({combine(e){return mh(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),bw=jm.define({create(){return zw.empty},update(e,t){let n=t.state.facet(yw),r=t.annotation(gw);if(r){let i=Dw.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?Ow(o,o.length,n.minDepth,i):Pw(o,t.startState.selection),new zw(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(_w);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation($m.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=Dw.fromTransaction(t),o=t.annotation($m.time),s=t.annotation($m.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new zw(e.done.map(Dw.fromJSON),e.undone.map(Dw.fromJSON))}});function xw(e={}){return[bw,yw.of(e),$b.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Cw:e.inputType==`historyRedo`?ww:null;return n?(e.preventDefault(),n(t)):!1}})]}function Sw(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(bw,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Cw=Sw(0,!1),ww=Sw(1,!1),Tw=Sw(0,!0),Ew=Sw(1,!0),Dw=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&mm.fromJSON(t.changes),[],t.mapped&&pm.fromJSON(t.mapped),t.startSelection&&X.fromJSON(t.startSelection),t.selectionsAfter.map(X.fromJSON))}static fromTransaction(t,n){let r=Mw;for(let e of t.startState.facet(vw)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,Mw)}static selection(t){return new e(void 0,Mw,void 0,void 0,t)}};function Ow(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function kw(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function Aw(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function jw(e,t){return e.length?t.length?e.concat(t):e:t}var Mw=[],Nw=200;function Pw(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Nw));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Ow(e,e.length-1,1e9,n.setSelAfter(r)))}return[Dw.selection([t])]}function Fw(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function Iw(e,t){if(!e.length)return e;let n=e.length,r=Mw;for(;n;){let i=Lw(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[Dw.selection(r)]:Mw}function Lw(e,t,n){let r=jw(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):Mw,n);if(!e.changes)return Dw.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new Dw(i,Qm.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var Rw=/^(input\.type|delete)($|\.)/,zw=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||Rw.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):Ww(n,t))}function Kw(e){return e.textDirectionAt(e.state.selection.main.head)==t_.LTR}var qw=e=>Gw(e,!Kw(e)),Jw=e=>Gw(e,Kw(e));function Yw(e,t){return Uw(e,n=>n.empty?e.moveByGroup(n,t):Ww(n,t))}var Xw=e=>Yw(e,!Kw(e)),Zw=e=>Yw(e,Kw(e));typeof Intl<`u`&&Intl.Segmenter;function Qw(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function $w(e,t,n){let r=sC(e).resolveInner(t.head),i=n?Xx.closedBy:Xx.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;Qw(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?YC(e,r.from,1):YC(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,X.cursor(s,n?-1:1)}var eT=e=>Uw(e,t=>$w(e.state,t,!Kw(e))),tT=e=>Uw(e,t=>$w(e.state,t,Kw(e)));function nT(e,t){return Uw(e,n=>{if(!n.empty)return Ww(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var rT=e=>nT(e,!1),iT=e=>nT(e,!0);function aT(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):Ww(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomoT(e,!1),cT=e=>oT(e,!0);function lT(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=X.cursor(r.from+n))}return i}var uT=e=>Uw(e,t=>lT(e,t,!0)),dT=e=>Uw(e,t=>lT(e,t,!1)),fT=e=>Uw(e,t=>lT(e,t,!Kw(e))),pT=e=>Uw(e,t=>lT(e,t,Kw(e))),mT=e=>Uw(e,t=>e.moveToLineBoundary(t,!1,!1)),hT=e=>Uw(e,t=>e.moveToLineBoundary(t,!0,!1));function gT(e,t,n){let r=!1,i=Vw(e.selection,t=>{let i=YC(e,t.head,-1)||YC(e,t.head,1)||t.head>0&&YC(e,t.head-1,1)||t.headgT(e,t,!1);function vT(e,t,n){let r=Vw(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=X.range(e.head,e.anchor));let r=n(e);return X.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(Hw(e.state,r)),!0)}function yT(e,t){return vT(e,t,n=>e.moveByChar(n,t))}var bT=e=>yT(e,!Kw(e)),xT=e=>yT(e,Kw(e));function ST(e,t){return vT(e,t,n=>e.moveByGroup(n,t))}var CT=e=>ST(e,!Kw(e)),wT=e=>ST(e,Kw(e)),TT=e=>{let t=!Kw(e);return vT(e,t,n=>$w(e.state,n,t))},ET=e=>{let t=Kw(e);return vT(e,t,n=>$w(e.state,n,t))};function DT(e,t){return vT(e,t,n=>e.moveVertically(n,t))}var OT=e=>DT(e,!1),kT=e=>DT(e,!0);function AT(e,t){return vT(e,t,n=>e.moveVertically(n,t,aT(e).height))}var jT=e=>AT(e,!1),MT=e=>AT(e,!0),NT=e=>vT(e,!0,t=>lT(e,t,!0)),PT=e=>vT(e,!1,t=>lT(e,t,!1)),FT=e=>{let t=!Kw(e);return vT(e,t,n=>lT(e,n,t))},IT=e=>{let t=Kw(e);return vT(e,t,n=>lT(e,n,t))},LT=e=>vT(e,!1,t=>X.cursor(e.lineBlockAt(t.head).from)),RT=e=>vT(e,!0,t=>X.cursor(e.lineBlockAt(t.head).to)),zT=({state:e,dispatch:t})=>(t(Hw(e,{anchor:0})),!0),BT=({state:e,dispatch:t})=>(t(Hw(e,{anchor:e.doc.length})),!0),VT=({state:e,dispatch:t})=>(t(Hw(e,{anchor:e.selection.main.anchor,head:0})),!0),HT=({state:e,dispatch:t})=>(t(Hw(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),UT=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),WT=({state:e,dispatch:t})=>{let n=lE(e).map(({from:t,to:n})=>X.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:X.create(n),userEvent:`select`})),!0},GT=({state:e,dispatch:t})=>{let n=Vw(e.selection,t=>{let n=sC(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return X.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(Hw(e,n)),!0)};function KT(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(Hw(n,X.create(i,i.length-1))),!0)}var qT=e=>KT(e,!1),JT=e=>KT(e,!0),YT=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=X.create([n.main]):n.main.empty||(r=X.create([X.cursor(n.main.head)])),r?(t(Hw(e,r)),!0):!1};function XT(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=ZT(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=ZT(e,i,!1),a=ZT(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:X.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}var QT=(e,t,n)=>XT(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iQT(e,!1,!0),eE=e=>QT(e,!0,!1),tE=(e,t)=>XT(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=om(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),nE=e=>tE(e,!1),rE=e=>tE(e,!0),iE=e=>XT(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headXT(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),oE=e=>XT(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Yp.of([``,``])},range:X.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},cE=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:om(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:om(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:X.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function lE(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function uE(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of lE(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(X.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(X.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:X.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var dE=({state:e,dispatch:t})=>uE(e,t,!1),fE=({state:e,dispatch:t})=>uE(e,t,!0);function pE(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of lE(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var mE=({state:e,dispatch:t})=>pE(e,t,!1),hE=({state:e,dispatch:t})=>pE(e,t,!0),gE=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(lE(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function _E(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=sC(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Xx.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var vE=bE(!1),yE=bE(!0);function bE(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&_E(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new CC(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=SC(s,r);for(c??=Ph(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:X.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var SE=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new CC(e,{overrideIndentation:e=>n[e]??-1}),i=xE(e,(t,i,a)=>{let o=SC(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=xC(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(xE(e,(t,n)=>{n.push({from:t.from,insert:e.facet(yC)})}),{userEvent:`input.indent`})),!0),wE=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(xE(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Ph(r,e.tabSize),a=0,o=xC(e,Math.max(0,i-bC(e)));for(;a(e.setTabFocusMode(),!0),EE=[{key:`Ctrl-b`,run:qw,shift:bT,preventDefault:!0},{key:`Ctrl-f`,run:Jw,shift:xT},{key:`Ctrl-p`,run:rT,shift:OT},{key:`Ctrl-n`,run:iT,shift:kT},{key:`Ctrl-a`,run:mT,shift:LT},{key:`Ctrl-e`,run:hT,shift:RT},{key:`Ctrl-d`,run:eE},{key:`Ctrl-h`,run:$T},{key:`Ctrl-k`,run:iE},{key:`Ctrl-Alt-h`,run:nE},{key:`Ctrl-o`,run:sE},{key:`Ctrl-t`,run:cE},{key:`Ctrl-v`,run:cT}],DE=[{key:`ArrowLeft`,run:qw,shift:bT,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:Xw,shift:CT,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:fT,shift:FT,preventDefault:!0},{key:`ArrowRight`,run:Jw,shift:xT,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:Zw,shift:wT,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:pT,shift:IT,preventDefault:!0},{key:`ArrowUp`,run:rT,shift:OT,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:zT,shift:VT},{mac:`Ctrl-ArrowUp`,run:sT,shift:jT},{key:`ArrowDown`,run:iT,shift:kT,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:BT,shift:HT},{mac:`Ctrl-ArrowDown`,run:cT,shift:MT},{key:`PageUp`,run:sT,shift:jT},{key:`PageDown`,run:cT,shift:MT},{key:`Home`,run:dT,shift:PT,preventDefault:!0},{key:`Mod-Home`,run:zT,shift:VT},{key:`End`,run:uT,shift:NT,preventDefault:!0},{key:`Mod-End`,run:BT,shift:HT},{key:`Enter`,run:vE,shift:vE},{key:`Mod-a`,run:UT},{key:`Backspace`,run:$T,shift:$T,preventDefault:!0},{key:`Delete`,run:eE,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:nE,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:rE,preventDefault:!0},{mac:`Mod-Backspace`,run:aE,preventDefault:!0},{mac:`Mod-Delete`,run:oE,preventDefault:!0}].concat(EE.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),OE=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:eT,shift:TT},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:tT,shift:ET},{key:`Alt-ArrowUp`,run:dE},{key:`Shift-Alt-ArrowUp`,run:mE},{key:`Alt-ArrowDown`,run:fE},{key:`Shift-Alt-ArrowDown`,run:hE},{key:`Mod-Alt-ArrowUp`,run:qT},{key:`Mod-Alt-ArrowDown`,run:JT},{key:`Escape`,run:YT},{key:`Mod-Enter`,run:yE},{key:`Alt-l`,mac:`Ctrl-l`,run:WT},{key:`Mod-i`,run:GT,preventDefault:!0},{key:`Mod-[`,run:wE},{key:`Mod-]`,run:CE},{key:`Mod-Alt-\\`,run:SE},{key:`Shift-Mod-k`,run:gE},{key:`Shift-Mod-\\`,run:_T},{key:`Mod-/`,run:aw},{key:`Alt-A`,mac:`Ctrl-A`,run:cw},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:TE}].concat(DE),kE={key:`Tab`,run:CE,shift:wE},AE=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new jE(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizeo;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new ME(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;rt&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(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 t=0;t0&&this.emitLookAhead()}},jE=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},ME=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},NE=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.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 e(this.stack,this.pos,this.index)}};function PE(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var FE=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},IE=new FE,LE=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=IE,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;in.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nt.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=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.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1: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,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=IE,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&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},RE=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;BE(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};RE.prototype.contextual=RE.prototype.fallback=RE.prototype.extend=!1;var zE=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?PE(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(BE(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};zE.prototype.contextual=RE.prototype.fallback=RE.prototype.extend=!1;function BE(e,t,n,r,i,a){let o=0,s=1<0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||HE(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function VE(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function HE(e,t,n,r){let i=VE(n,r,t);return i<0||VE(n,r,e)t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var KE=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?GE(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?GE(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=a,null;if(i instanceof iS){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(Xx.lookAhead))||t+r=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},qE=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new FE)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;rl.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new FE,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new FE,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;te.bufferLength*4?new KE(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&$E(r);if(e)return UE&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw UE&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return UE&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e-1&&n.length&&(!i||(n.prop(Xx.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof iS&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=UE?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos0)return e.reduce(o),UE&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;or?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return YE(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),UE&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(UE&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)UE&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))UE&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),UE&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),YE(o,n)):(!r||r.scoree.topRules[t][1]),r=[];for(let e=0;e=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new eS(t.map((t,i)=>$x.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=qx;let a=PE(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;etypeof e==`number`?new RE(a,e):e),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,t,n){let r=new JE(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=QE(this.data,n+2);else break}r=t(QE(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=QE(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=eD(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.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 t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;ee)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,r)<<1|t}return e.get}var tD=NS({String:$.string,Number:$.number,"True False":$.bool,PropertyName:$.propertyName,Null:$.null,", :":$.separator,"[ ]":$.squareBracket,"{ }":$.brace}),nD=ZE.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:[tD],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}),rD=()=>e=>{try{JSON.parse(e.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;let n=iD(t,e.state.doc);return[{from:n,message:t.message,severity:`error`,to:n}]}return[]};function iD(e,t){let n;return(n=e.message.match(/at position (\d+)/))?Math.min(+n[1],t.length):(n=e.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+n[1]).from+ +n[2]-1,t.length):0}var aD=oC.define({name:`json`,parser:nD.configure({props:[wC.add({Object:PC({except:/^\s*\}/}),Array:PC({except:/^\s*\]/})}),FC.add({"Object Array":IC})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function oD(){return new _C(aD)}var sD=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},cD=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(CD).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new Ch,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;et.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=FD(s);if(i)o.add(n,n,_g.widget({widget:new OD(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,_g.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new sD(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new sD(r.from,n,r.diagnostic)}}),r}function uD(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(CD).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(pD))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function dD(e,t){return e.field(gD,!1)?t:t.concat(Qm.appendConfig.of(LD))}function fD(e,t){return{effects:dD(e,[pD.of(t)])}}var pD=Qm.define(),mD=Qm.define(),hD=Qm.define(),gD=jm.define({create(){return new cD(_g.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=lD(n,e.selected.diagnostic,i)||lD(n,null,i)}!n.size&&i&&t.state.facet(CD).autoPanel&&(i=null),e=new cD(n,i,r)}for(let n of t.effects)if(n.is(pD)){let r=t.state.facet(CD).autoPanel?n.value.length?AD.open:null:e.panel;e=cD.init(n.value,r,t.state)}else n.is(mD)?e=new cD(e.diagnostics,n.value?AD.open:null,e.selected):n.is(hD)&&(e=new cD(e.diagnostics,e.panel,n.value));return e},provide:e=>[Gx.from(e,e=>e.panel),$b.decorations.from(e,e=>e.diagnostics)]}),_D=_g.mark({class:`cm-lintRange cm-lintRange-active`});function vD(e,t,n){let{diagnostics:r}=e.state.field(gD),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(tDD(e,t,!1)))}var bD=e=>{let t=e.state.field(gD,!1);return!t||!t.panel?!1:(e.dispatch({effects:mD.of(!1)}),!0)},xD=U_.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(CD);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(ePromise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(fD(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{z_(this.view.state,e)})}}update(e){let t=e.state.facet(CD);(e.docChanged||t!=e.startState.facet(CD)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function SD(e,t,n){let r=[],i=-1;for(let a of e)a.then(n=>{r.push(n),clearTimeout(i),r.length==e.length?t(r):i=setTimeout(()=>t(r),200)},n)}var CD=wm.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...mh(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:wD,tooltipFilter:wD,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function wD(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function TD(e,t={}){return[CD.of({source:e,config:t}),xD,LD]}function ED(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;ee.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function DD(e,t,n){let r=n?ED(t.actions):[];return Xh(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},Xh(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=lD(e.state.field(gD).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),Xh(`u`,s.slice(c,c+1)),s.slice(c+1)];return Xh(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&Xh(`div`,{class:`cm-diagnosticSource`},t.source))}var OD=class extends hg{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Xh(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},kD=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=DD(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},AD=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)bD(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=ED(n.actions);for(let i=0;i{for(let t=0;tbD(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(gD).selected;if(!e)return-1;for(let t=0;t{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;tn&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=lD(this.view.state.field(gD).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:hD.of(t)})}static open(t){return new e(t)}};function jD(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function MD(e){return jD(``,`width="6" height="3"`)}var ND=$b.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:MD(`#f11`)},".cm-lintRange-warning":{backgroundImage:MD(`orange`)},".cm-lintRange-info":{backgroundImage:MD(`#999`)},".cm-lintRange-hint":{backgroundImage:MD(`#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 PD(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function FD(e){let t=`hint`,n=1;for(let r of e){let e=PD(r.severity);e>n&&(n=e,t=r.severity)}return t}var ID=zx(vD,{hideOn:uD}),LD=[gD,$b.decorations.compute([gD],e=>{let{selected:t,panel:n}=e.field(gD);return!t||!n||t.from==t.to?_g.none:_g.set([_D.range(t.from,t.to)])}),ID,ND],RD=524288;function zD(e,t){if(e.length<=t)return e;let n=e.lastIndexOf(` +`,t);return n>t*.5?e.slice(0,n):e.slice(0,t)}var BD=e=>e.state.doc.length>524288?[]:rD()(e);function VD(e){return LC.define([{tag:$.propertyName,color:e?`#7dd3fc`:`#0369a1`},{tag:$.string,color:e?`#86efac`:`#15803d`},{tag:$.number,color:e?`#fcd34d`:`#b45309`},{tag:$.bool,color:e?`#d8b4fe`:`#7e22ce`},{tag:$.null,color:e?`#a1a1aa`:`#71717a`}])}var HD=$b.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 UD({value:e,onChange:t,editable:n,lintJson:r=!0,dark:i,placeholder:a,testId:o=`json-editor`,className:s,onReady:c}){let l=(0,g.useRef)(null),u=(0,g.useRef)(null),d=(0,g.useRef)(t);d.current=t;let f=(0,g.useRef)(i),p=(0,g.useRef)(null),m=(0,g.useRef)(null),h=(0,g.useRef)(null),_=n??t!==void 0,v=(0,g.useRef)(_),y=(0,g.useRef)(r),b=e.length>RD,x=(0,g.useRef)(b),S=!_&&e.length>2e6,C=S?zD(e,RD):e,w=(0,g.useRef)(!1),T=(0,g.useCallback)((e,t,n)=>e?[$b.updateListener.of(e=>{e.docChanged&&!w.current&&d.current?.(e.state.doc.toString())}),...t||!n?[]:[TD(BD,{delay:300})]]:[ph.readOnly.of(!0),$b.editable.of(!1)],[]);return(0,g.useEffect)(()=>{let e=l.current;if(!e)return;let t=new Im,n=new Im,o=new Im,s=new $b({state:ph.create({doc:C,extensions:[o.of(b||!r?[]:oD()),$b.lineWrapping,xw(),cx.of([...OE,...Bw,kE]),HD,t.of(VC(VD(i))),n.of(T(_,b,r)),...a?[yx(a)]:[]]}),parent:e});return p.current=t,m.current=n,h.current=o,c?.(s),u.current=s,()=>{s.destroy(),u.current=null}},[]),(0,g.useEffect)(()=>{let e=u.current;if(!e)return;let t=h.current,n=m.current,i=[];(b!==x.current||r!==y.current)&&(x.current=b,y.current=r,t&&i.push(t.reconfigure(b||!r?[]:oD())),n&&i.push(n.reconfigure(T(_,b,r))));let a=e.state.doc.toString();if(a!==C||i.length!==0){w.current=!0;try{e.dispatch({...a===C?{}:{changes:{from:0,to:e.state.doc.length,insert:C}},...i.length>0?{effects:i}:{}})}finally{w.current=!1}}},[C,b,r,_,T]),(0,g.useEffect)(()=>{let e=u.current,t=m.current;e&&t&&_!==v.current&&(v.current=_,e.dispatch({effects:t.reconfigure(T(_,b,r))}))},[_,b,r,T]),(0,g.useEffect)(()=>{let e=u.current;if(!e||i===f.current)return;f.current=i;let t=p.current;t&&e.dispatch({effects:t.reconfigure(VC(VD(i)))})},[i]),(0,G.jsxs)(`div`,{"data-testid":o,className:Tn(`flex min-h-0 flex-1 flex-col overflow-hidden font-mono`,s),children:[S?(0,G.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,(0,G.jsx)(`div`,{ref:l,className:`min-h-0 flex-1 overflow-hidden px-5 py-4`})]})}function WD({title:e,meta:t,actions:n,status:r,children:i}){return(0,G.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,G.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:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 lg:gap-3`,children:[(0,G.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground`,children:e}),t?(0,G.jsx)(`span`,{"data-testid":`pane-meta`,className:`text-xs tabular-nums text-muted-foreground/70`,children:t}):null]}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1`,children:n})]}),(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),r?(0,G.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]})}var GD=`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`,KD=o(((e,t,n)=>{(function(){var n=[`,`,`;`,` `],r=!0,i={",":`comma`,";":`semicolon`," ":`tab`,"|":`pipe`};function a(e){var t={},r;return n.forEach(function(n,i){var a=new RegExp(n,`g`);t[n]=(e.match(a)||[]).length,r=!r||t[n]>t[r]?n:r}),r}function o(e){for(var t={},n=0;n=0;n--){var r=e[n];t[r]>0&&(r=r+`__`+t[r]--),i.unshift(r)}return i}function s(e,t){if(t||={},e.length==0)throw`Empty CSV. Please provide something.`;var n=t.separator||a(e);if(!n)throw`We could not detect the separator.`;var s=[];try{r=t.trim!==!1;var s=c.parse(e,i[n])}catch(t){var l=e.lastIndexOf(` +`,t.offset),u=e.indexOf(` +`,t.offset),d=e.substring(l>=-1?l:0,u>-1?u:e.length);throw t.message+` On line `+t.line+` and column `+t.column+`. +`+d}if(t.transpose){for(var f=0,p=0;pf&&(f=s[p].length);for(var m=Array(f),h=0;hs&&(s=a,c=[]),c.push(e))}function u(){var e,t,n=a,r=a;return e=(function(e){return b=`,`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function d(){var e,t,n=a,r=a;return e=(function(e){return b=`;`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function f(){var e,t,n=a,r=a;return e=(function(e){return b=`|`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function p(){var e,t,n=a,r=a;return e=(function(e){return b=` `})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function m(){var e,n,r,i,s,c=a,u=a,d,f;for(e=[],/^[\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[\\n\\r]`));n!==null;)e.push(n),/^[\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[\\n\\r]`));if(e!==null){if(n=h(),n!==null){if(r=[],d=a,f=a,/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`)),s!==null)for(i=[];s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));else i=null;for(i===null?(i=null,a=f):(s=h(),s===null?(i=null,a=f):i=[i,s]),i!==null&&(i=(function(e,t){return t})(d,i[1])),i===null&&(a=d);i!==null;){if(r.push(i),d=a,f=a,/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`)),s!==null)for(i=[];s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));else i=null;i===null?(i=null,a=f):(s=h(),s===null?(i=null,a=f):i=[i,s]),i!==null&&(i=(function(e,t){return t})(d,i[1])),i===null&&(a=d)}if(r!==null){for(i=[],/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));i===null?(e=null,a=u):e=[e,n,r,i]}else e=null,a=u}else e=null,a=u}else e=null,a=u;return e!==null&&(e=(function(e,t,n){return n.unshift(t),n})(c,e[1],e[2])),e===null&&(a=c),e}function h(){var e,n,r,i,s,c=a,u=a,d,f;if(e=g(),e!==null){for(n=[],d=a,f=a,t.length>a?(r=t.charAt(a),a++):(r=null,o===0&&l(`any character`)),r===null?(r=null,a=f):(i=(function(e,t){return t==b})(a,r)?``:null,i===null?(r=null,a=f):(s=g(),s===null?(r=null,a=f):r=[r,i,s])),r!==null&&(r=(function(e,t,n){return n})(d,r[0],r[2])),r===null&&(a=d);r!==null;)n.push(r),d=a,f=a,t.length>a?(r=t.charAt(a),a++):(r=null,o===0&&l(`any character`)),r===null?(r=null,a=f):(i=(function(e,t){return t==b})(a,r)?``:null,i===null?(r=null,a=f):(s=g(),s===null?(r=null,a=f):r=[r,i,s])),r!==null&&(r=(function(e,t,n){return n})(d,r[0],r[2])),r===null&&(a=d);n===null?(e=null,a=u):(r=(function(e,t,n){return!!t||n.length})(a,e,n)?``:null,r===null?(e=null,a=u):e=[e,n,r])}else e=null,a=u;return e!==null&&(e=(function(e,t,n){return n.unshift(t),n})(c,e[0],e[1])),e===null&&(a=c),e}function g(){var e,n,i,s=a,c=a,u;if(t.charCodeAt(a)===34?(e=`"`,a++):(e=null,o===0&&l(`"\\""`)),e!==null){for(n=[],i=_();i!==null;)n.push(i),i=_();n===null?(e=null,a=c):(t.charCodeAt(a)===34?(i=`"`,a++):(i=null,o===0&&l(`"\\""`)),i===null?(e=null,a=c):e=[e,n,i])}else e=null,a=c;if(e!==null&&(e=(function(e,t){return t.join(``)})(s,e[1])),e===null&&(a=s),e===null){for(s=a,e=[],c=a,u=a,/^[^\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[^\\n\\r]`)),n===null?(n=null,a=u):(i=(function(e,t){return t!=b})(a,n)?``:null,i===null?(n=null,a=u):n=[n,i]),n!==null&&(n=(function(e,t){return t})(c,n[0])),n===null&&(a=c);n!==null;)e.push(n),c=a,u=a,/^[^\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[^\\n\\r]`)),n===null?(n=null,a=u):(i=(function(e,t){return t!=b})(a,n)?``:null,i===null?(n=null,a=u):n=[n,i]),n!==null&&(n=(function(e,t){return t})(c,n[0])),n===null&&(a=c);e!==null&&(e=(function(e,t){return(r?t.join(``).trim():t.join(``)).replace(/(^")|("$)/g,``)})(s,e)),e===null&&(a=s)}return e}function _(){var e,n,r=a,i=a;return t.charCodeAt(a)===34?(e=`"`,a++):(e=null,o===0&&l(`"\\""`)),e===null?(e=null,a=i):(t.charCodeAt(a)===34?(n=`"`,a++):(n=null,o===0&&l(`"\\""`)),n===null?(e=null,a=i):e=[e,n]),e!==null&&(e=(function(e){return`"`})(r)),e===null&&(a=r),e===null&&(/^[^"]/.test(t.charAt(a))?(e=t.charAt(a),a++):(e=null,o===0&&l(`[^"]`))),e}function v(e){e.sort();for(var t=null,n=[],r=0;r{(function(){var n=`Item in array is not an object: {0}`;function r(e,t){t||=[];function o(e,t){var n=e.slice(0);if(!Array.isArray(t))return n;for(var r=0;r=2)try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1}}return{ok:!1}}function iO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aO(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function oO(e){let t=(e,r,i)=>{for(let[a,o]of Object.entries(e)){let e=r?`${r}.${a}`:a;iO(o)&&Object.keys(o).length>0?t(o,e,i):i[e]=Array.isArray(o)?o.map(n):o}},n=e=>{if(!iO(e))return e;let n={};return t(e,``,n),n};return Array.isArray(e)?e.map(n):iO(e)?n(e):e}function sO(e){let t=e=>{if(!iO(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Array.isArray(i)&&i.length>0&&i.every(aO)?i.join(`, `):Array.isArray(i)?i.map(t):i;return n};return Array.isArray(e)?e.map(t):iO(e)?t(e):e}function cO(e){let t=e.trim().toLowerCase();return t===`true`||t===`1`||t===`yes`?!0:t===`false`||t===`0`||t===`no`?!1:e}function lO(e,t,n){if(n===`string`)return e;if(n===`number`)return nO(e);if(n===`boolean`)return cO(e);if(t.parseJSON){let t=rO(e);if(t.ok&&typeof t.value!=`number`)return t.value}return t.parseNumbers?nO(e):e}function uO(e,t){let n=e=>{let n={};for(let r of Object.keys(e)){let i=e[r];if(typeof i!=`string`){n[r]=i;continue}if(t.emptyFields===`skip`&&i===``)continue;if(t.nullLiterals===`null`&&i===`NULL`){n[r]=null;continue}let a=t.columnTypes?.[r];n[r]=lO(i,t,a)}return n};if(Array.isArray(e))return e.map(e=>iO(e)?n(e):e);let r={};for(let[t,i]of Object.entries(e))r[t]=iO(i)?n(i):i;return r}var dO=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function fO(e){let t=dO.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=t[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:e,prefix:n,index:o,notation:r===void 0?`bracket`:`dot`,...a===void 0?{}:{subKey:a}}:null}function pO(e){let t=new Set(e),n=new Map;for(let t of e){let e=fO(t);if(!e)continue;let r=n.get(e.prefix);r?r.push(e):n.set(e.prefix,[e])}let r=[];for(let[e,i]of n.entries()){if(t.has(e))continue;let n=i[0].subKey!==void 0,a=i[0].notation;if(i.some(e=>e.subKey!==void 0!==n||e.notation!==a))continue;let o=new Set,s=!1;for(let e of i){let t=`${e.index}:${e.subKey??``}`;if(o.has(t)){s=!0;break}o.add(t)}if(s)continue;let c=Array.from(new Set(i.map(e=>e.index))).sort((e,t)=>e-t);if(c.length<2)continue;let l=c[0];(l===0||l===1)&&c.every((e,t)=>e===l+t)&&r.push({prefix:e,indices:c,columns:i.map(e=>e.column)})}return r}function mO(e,t){return e===void 0||e===``||t===`skip`&&e===null}function hO(e,t,n,r){let i=new Map,a=new Set,o=new Map;for(let e of n)if(e.columns.length!==0){i.set(e.columns[0],e);for(let t of e.columns)a.add(t);o.set(e.prefix,e.columns.map(e=>fO(e)).filter(e=>e!==null))}let s={};for(let n of t){let t=i.get(n);if(t){let n=o.get(t.prefix)??[];if(n.some(e=>e.subKey!==void 0)){let i=new Map;for(let e of n){let t=i.get(e.index);t?t.push(e):i.set(e.index,[e])}let a=[];for(let n of t.indices){let t=i.get(n)??[],o={};for(let n of t){if(!n.subKey)continue;let t=e[n.column];mO(t,r)||(o[n.subKey]=t)}Object.keys(o).length>0&&a.push(o)}if(a.length===0&&r===`skip`)continue;s[t.prefix]=a}else{let i=new Map;for(let e of n)i.set(e.index,e.column);let a=[];for(let n of t.indices){let t=i.get(n);if(!t)continue;let o=e[t];mO(o,r)||a.push(o)}if(a.length===0&&r===`skip`)continue;s[t.prefix]=a}}else a.has(n)||Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s}function gO(e,t,n){if(Array.isArray(e)&&Array.isArray(t)){let r=e[0];if(!iO(r))return t;let i=Object.keys(r),a=pO(i);return a.length===0?t:t.map(e=>iO(e)?hO(e,i,a,n):e)}if(!Array.isArray(e)&&!Array.isArray(t)){let r=Object.values(e)[0];if(!iO(r))return t;let i=Object.keys(r),a=pO(i);if(a.length===0)return t;let o={};for(let[e,r]of Object.entries(t))o[e]=iO(r)?hO(r,i,a,n):r;return o}return t}function _O(e,t={}){let n={parseNumbers:t.parseNumbers??!0,parseJSON:t.parseJSON??!1,emptyFields:t.emptyFields??`keep`,nullLiterals:t.nullLiterals??`string`,columnTypes:t.columnTypes},r=e.startsWith(eO)?e.slice(1):e,i=t.separator===void 0?Ff(r,t.markdownTableIndex??0):null,a=i?i.cleanedCsv:r;try{let e=(0,JD.default)(a,{...t,parseNumbers:!1,parseJSON:!1,trim:!1}),r=uO(e,n);return t.collapseIndexedArrays!==!1&&!t.transpose?gO(e,r,n.emptyFields):r}catch(e){throw Error($D(e),{cause:e})}}function vO(e,t={}){try{let n=t.flatten?sO(oO(e)):e;return(0,YD.default)(n,t)}catch(e){let n=$D(e);throw QD.some(e=>n.startsWith(e))?new XD(ZD(n,t.flatten??!1)):Error(n,{cause:e})}}function yO(e,t={}){return JSON.stringify(e,null,t.minify?void 0:2)}var bO={separator:`auto`,parseNumbers:!0,parseJSON:!0,emptyFields:`keep`,nullLiterals:`string`,transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},xO=[`data`,`items`,`results`,`records`,`rows`];function SO(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function CO(e){let t=e.trim();if(t===``||!t.startsWith(`{`))return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!SO(n))return[];let r=Object.keys(n),i=new Set(xO),a=[...xO.filter(e=>r.includes(e)),...r.filter(e=>!i.has(e))],o=[];for(let e of a){let t=n[e];Array.isArray(t)&&t.length>0&&t.every(e=>SO(e))&&o.push({key:e,rowCount:t.length,unwrappedJson:JSON.stringify(t,null,2)})}return o}function wO(e){let t=e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);if(t.length<2)return null;let n=[];for(let e of t)try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;n.push(t)}catch{return null}return n}function TO(e){let t=e.trim();if(t===``)return null;let n;try{n=JSON.parse(t)}catch{let e=wO(t);if(e===null)return null;n=e}let r=JSON.stringify(n,null,2);return t===r?{label:`Minify`,nextInput:JSON.stringify(n)}:{label:`Format`,nextInput:r}}function EO(e){let t=e.trim();if(t===``)return[];let n;try{n=JSON.parse(t)}catch{let e=wO(t);if(e===null)return[];n=e}let r;if(Array.isArray(n)){if(n.length===0||!n.every(e=>SO(e)))return[];r=n}else if(SO(n)){if(CO(t).length>0)return[];r=[n]}else return[];let i=new Set,a=r.slice(0,50);for(let e of a)for(let[t,n]of Object.entries(e))(SO(n)||Array.isArray(n)&&n.length>0)&&i.add(t);return Array.from(i)}function DO(e){let t=e=>{let t=new Set;for(let n of e)n&&typeof n==`object`&&!Array.isArray(n)&&Object.keys(n).forEach(e=>t.add(e));return t};if(Array.isArray(e))return{rows:e.length,cols:t(e).size};if(e&&typeof e==`object`){let n=Object.values(e);return{rows:n.length,cols:t(n).size}}return{rows:0,cols:0}}var OO=e=>e===`auto`?void 0:e;function kO(e){let t=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((e,t)=>{if(a&&t===i.rowWidths.length-1)return;let r=i.rows[t];(e!==1||r[0]!==``)&&e!==i.headers.length&&n.push(e0?{warnings:o}:{}}}let r;try{r=JSON.parse(t)}catch(e){let n=wO(t);if(n!==null)r=n;else return{ok:!1,error:`Invalid JSON — ${e instanceof Error?e.message:String(e)}`}}let i=OO(n.separator),a=vO(r,{separator:i,flatten:n.flatten}),o=zf(a,i);return{ok:!0,text:a,rows:o.rows.length,cols:o.headers.length}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function NO(){return(0,G.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:(0,G.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.2-8.56`,strokeLinecap:`round`})})}function PO({label:e,testId:t,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:a=!1}){return(0,G.jsxs)(`button`,{type:`button`,"data-testid":t,"aria-label":e,disabled:r,onClick:n,title:e,className:GD,children:[i?(0,G.jsx)(i,{"aria-hidden":`true`}):null,i&&!a?(0,G.jsx)(`span`,{className:`hidden xl:inline`,children:e}):e]})}function FO(e){let t=Math.min(e.length,65536),n=!1,r=0;for(let i=0;i=3))return e.slice(0,i+1)}return e.slice(0,t)}function IO(e){let t=e.slice(0,3).map(e=>`.${e}`).join(`, `),n=e.length-3;return n>0?`${t}, +${n} more`:t}function LO({format:e,input:t,onInputChange:n,onFile:r,onTryExample:i,onClear:a,onCopy:o,onCopySelection:s,onDownload:c,filename:l,reading:u,meta:d,error:f,notice:p,dark:m,delimiter:h,onCellCommit:_,canUndo:v=!1,canRedo:y=!1,onUndo:b,onRedo:x,onProjectedCsvChange:S,collapseIndexedArrays:C=!0,onToggleCollapseIndexedArrays:w,columnTypes:T,onChangeColumnTypes:E,flatten:D=!1,onToggleFlatten:O,selectedMarkdownTableIndex:k,onSelectMarkdownTableIndex:A}){let[ee,te]=(0,g.useState)(!1),[ne,re]=(0,g.useState)(!1),[j,M]=(0,g.useState)({forInput:``,index:0}),ie=(0,g.useRef)(0),ae=(0,g.useRef)(null),N=t.trim()===``,oe=e===`CSV`,P=(0,g.useMemo)(()=>!oe||N||h!==void 0?[]:Pf(t),[oe,N,t,h]),F=k===void 0?j.forInput===t?j.index:0:k,se=P.length===0?0:Math.min(Math.max(0,F),P.length-1),I=P[se]??null,ce=e=>{M({forInput:t,index:e}),A?.(e)},le=(0,g.useMemo)(()=>!oe||N?[]:pO(zf(FO(I?I.cleanedCsv:t),h).headers.map(e=>e.trim())),[oe,N,t,h,I]),ue=(0,g.useMemo)(()=>oe||N?[]:CO(t),[oe,N,t]),de=(0,g.useMemo)(()=>oe||N?[]:EO(t),[oe,N,t]),fe=(0,g.useMemo)(()=>oe||N?null:TO(t),[oe,N,t]),pe=e=>{e.preventDefault(),Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(ie.current++,re(!0))},me=()=>{ie.current=Math.max(0,ie.current-1),ie.current===0&&re(!1)},he=e=>{e.preventDefault(),ie.current=0,re(!1);let t=e.dataTransfer?.files?.[0];t&&r(t,`drop`)},R=e=>{if(!N||e.defaultPrevented||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement)return;let t=e.clipboardData?.getData(`text/plain`);t&&(e.preventDefault(),n(t))},ge=oe?(0,G.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:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`view-table`,"aria-pressed":!ee,onClick:()=>te(!1),className:Tn(`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`,ee?`text-muted-foreground hover:text-foreground`:`bg-background text-foreground shadow-sm`),children:[(0,G.jsx)(Ve,{"aria-hidden":`true`,className:`size-3.5 md:hidden lg:inline`}),`Table`]}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`raw-toggle`,"aria-pressed":ee,onClick:()=>te(!0),className:Tn(`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`,ee?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[(0,G.jsx)(L,{"aria-hidden":`true`,className:`size-3.5 md:hidden lg:inline`}),`Raw`]})]}):null,z=u&&l?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,G.jsx)(NO,{}),` `,l]}):l?d?`${l} · ${d}`:l:d;return(0,G.jsx)(`div`,{"data-testid":`input-pane`,onDragEnter:pe,onDragOver:e=>e.preventDefault(),onDragLeave:me,onDrop:he,onPaste:R,"data-drag-over":ne||void 0,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,G.jsxs)(WD,{title:e,meta:z,actions:(0,G.jsxs)(G.Fragment,{children:[ge,oe&&(v||y)?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`csv-undo-button`,"aria-label":`Undo`,title:`Undo`,disabled:!v,onClick:()=>b?.(),className:GD,children:(0,G.jsx)(Ye,{"aria-hidden":`true`})}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`csv-redo-button`,"aria-label":`Redo`,title:`Redo`,disabled:!y,onClick:()=>x?.(),className:GD,children:(0,G.jsx)(ke,{"aria-hidden":`true`})})]}):null,fe?(0,G.jsx)(PO,{label:fe.label,testId:`json-format-toggle`,onClick:()=>n(fe.nextInput),Icon:L,keepLabelOnMobile:!0}):null,(0,G.jsx)(`input`,{ref:ae,type:`file`,"data-testid":`file-input`,accept:oe?`.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/markdown`:`.json,.jsonl,.ndjson,.txt,application/json,application/x-ndjson`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&r(t,`picker`),e.target.value=``}}),(0,G.jsx)(PO,{label:`Upload`,testId:`upload`,onClick:()=>ae.current?.click(),Icon:Te}),(0,G.jsx)(PO,{label:`Copy`,testId:`copy-input`,onClick:o,Icon:Se}),(0,G.jsx)(PO,{label:`Clear`,testId:`clear-input`,onClick:a,disabled:N,Icon:qe}),(0,G.jsx)(PO,{label:`Download`,testId:`download-input`,onClick:c,disabled:N,Icon:we})]}),status:f?{kind:`error`,message:f}:p?{kind:`notice`,message:p}:null,children:[N?(0,G.jsx)(Ip,{format:e,onIngest:n,onBrowse:()=>ae.current?.click(),onTryExample:i}):oe?(0,G.jsxs)(G.Fragment,{children:[I?(0,G.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:[P.length>=2?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`${P.length} tables detected:`}),P.map(e=>{let t=e.index===se,n=e.title??e.headers.slice(0,2).join(`, `);return(0,G.jsx)(`button`,{type:`button`,"data-testid":`csv-markdown-table-select-${e.index}`,"aria-pressed":t,onClick:()=>ce(e.index),className:Tn(`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`,t?`border-foreground/30 bg-background text-foreground ring-1 ring-foreground/15`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:`${e.index+1}. ${n} (${e.rows}×${e.cols})`},e.index)})]}):(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:I.kind===`box`?`ASCII CLI box table detected:`:`Markdown pipe table detected:`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`csv-clean-markdown-pill`,onClick:()=>n(I.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:P.length>=2?`Use only this table (${I.rows} ${I.rows===1?`row`:`rows`})`:I.kind===`box`?`Clean CLI table (${I.rows} ${I.rows===1?`row`:`rows`})`:`Clean Markdown table (${I.rows} ${I.rows===1?`row`:`rows`})`})]}):null,le.length>0?(0,G.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:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Indexed columns (${le.map(e=>`${e.prefix}[${e.indices.length}]`).join(`, `)}):`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`csv-indexed-array-pill`,"aria-pressed":C,onClick:()=>w?.(),className:Tn(`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`,C?`border-border bg-background text-foreground hover:bg-muted`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:C?`Arrays: .0, .1 → []`:`Keep flat keys (.0, .1)`})]}):null,ee?(0,G.jsx)(`textarea`,{"data-testid":`input-editor`,value:t,onChange:e=>n(e.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`}):(0,G.jsx)(Ap,{text:I?I.cleanedCsv:t,delimiter:h,testId:`input-table`,dark:m,onCellCommit:_,onUndo:b,onRedo:x,onCopySelection:s,columnTypes:T,onChangeColumnTypes:E,onProjectedCsvChange:S})]}):(0,G.jsxs)(G.Fragment,{children:[ue.length>0?(0,G.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:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Nested array detected:`}),ue.map(e=>(0,G.jsx)(`button`,{type:`button`,"data-testid":`json-unwrap-pill-${e.key}`,onClick:()=>n(e.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 .${e.key} (${e.rowCount} ${e.rowCount===1?`row`:`rows`})`},e.key))]}):null,de.length>0?(0,G.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:[(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Nested keys (${de.length}):`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`json-flatten-pill`,"aria-pressed":D,onClick:()=>O?.(),className:Tn(`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`,D?`border-border bg-background text-foreground hover:bg-muted`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:`${D?`Flattened`:`Flatten`} nested keys (${IO(de)})`})]}):null,(0,G.jsx)(UD,{value:t,onChange:n,dark:m,testId:`input-editor`})]}),ne?(0,G.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:(0,G.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Drop file to import`})}):null]})})}var RO=/\.(csv|tsv|txt|json|jsonl|ndjson|md|log)$/i;function zO(e){return e.type.startsWith(`text/`)||e.type===`application/json`?!0:RO.test(e.name)}var BO=[{value:`utf-8`,label:`UTF-8`},{value:`windows-1252`,label:`Windows-1252`}];async function VO(e,t){let n=e.stream().getReader(),r=``;try{let e=[],i=0;for(;i<2;){let{done:t,value:r}=await n.read();if(t)break;r&&r.byteLength>0&&(e.push(r),i+=r.byteLength)}let a=null;if(e.length===1)a=e[0];else if(e.length>1){a=new Uint8Array(i);let t=0;for(let n of e)a.set(n,t),t+=n.byteLength}let o=t;t===`utf-8`&&a&&a.byteLength>=2&&(a[0]===255&&a[1]===254?o=`utf-16le`:a[0]===254&&a[1]===255&&(o=`utf-16be`));let s=new TextDecoder(o,{fatal:!1});for(a&&(r+=s.decode(a,{stream:!0}));;){let{done:e,value:t}=await n.read();if(e)break;r+=s.decode(t,{stream:!0})}return r+s.decode()}finally{n.releaseLock()}}function HO(e){let t=typeof window<`u`&&typeof window.matchMedia==`function`,n=(0,g.useCallback)(n=>{if(!t)return()=>{};let r=window.matchMedia(e);return r.addEventListener(`change`,n),()=>r.removeEventListener(`change`,n)},[e,t]),r=(0,g.useCallback)(()=>t?window.matchMedia(e).matches:!1,[e,t]);return(0,g.useSyncExternalStore)(n,r,()=>!1)}var UO=[{value:`auto`,label:`Auto-detect`},{value:`,`,label:`Comma`},{value:`;`,label:`Semicolon`},{value:` `,label:`Tab`},{value:`|`,label:`Pipe`}];function WO(){return(0,G.jsx)(`div`,{className:`hidden h-5 w-px shrink-0 bg-border fit:block`,"aria-hidden":`true`})}function GO(e,t){let n=[t.separator===`auto`?`Auto`:UO.find(e=>e.value===t.separator)?.label??`Auto`];return e===`csv2json`?(t.parseNumbers&&n.push(`Parse numbers`),t.parseJSON&&n.push(`Parse JSON`),t.emptyFields===`skip`&&n.push(`Skip empty`),t.nullLiterals===`null`&&n.push(`NULL→null`),t.transpose&&n.push(`Transpose`),t.hash&&n.push(`Hash`),t.minify&&n.push(`Minify`)):t.flatten&&n.push(`Flatten`),n.join(` · `)}function KO(){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 qO(){return(0,G.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:(0,G.jsx)(`path`,{d:`m4 6 4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function JO({children:e}){return(0,G.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase`,children:e})}function YO({label:e,checked:t,onChange:n,hint:r}){return(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,G.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":e,onClick:()=>n(!t),className:`flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,G.jsx)(`span`,{className:Tn(`relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors`,t?`border-primary bg-primary`:`border-border bg-muted`),children:(0,G.jsx)(`span`,{className:Tn(`pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform`,t?`translate-x-[15px]`:`translate-x-[2px]`)})})}),(0,G.jsx)(`span`,{className:`select-none`,children:e})]}),r?(0,G.jsx)(XO,{text:r}):null]})}function XO({text:e}){let t=(0,g.useId)(),[n,r]=(0,g.useState)(!1);return(0,G.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,G.jsx)(`button`,{type:`button`,"aria-label":`What does this option do?`,"aria-expanded":n,"aria-describedby":t,title:`What does this option do?`,onClick:()=>r(e=>!e),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`}),(0,G.jsx)(`span`,{"data-hint":!0,id:t,hidden:!n,className:`ml-1 text-muted-foreground`,children:e})]})}function ZO({direction:e,options:t,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:a}){let[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null),l=(0,g.useRef)(null),u=HO(`(min-width: 98.5rem)`),d=e===`csv2json`,f=GO(e,t),p=(0,g.useCallback)(()=>{s(!1),c.current?.focus()},[]);(0,g.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&p()},t=e=>{let t=l.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||p())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[o,p]);let m=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(JO,{children:`Separator`}),(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(`select`,{"data-testid":`opt-separator`,value:t.separator,onChange:e=>n({separator:e.target.value}),className:KO(),children:UO.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(qO,{})]})]}),(0,G.jsx)(XO,{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&&a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WO,{}),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(JO,{children:`Encoding`}),(0,G.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,G.jsx)(`select`,{"data-testid":`opt-encoding`,value:i,onChange:e=>a(e.target.value),className:KO(),children:BO.map(e=>(0,G.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,G.jsx)(qO,{})]})]}),(0,G.jsx)(XO,{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,(0,G.jsx)(WO,{}),d?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(YO,{label:`Parse numbers`,checked:t.parseNumbers,onChange:e=>n({parseNumbers:e}),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.`}),(0,G.jsx)(YO,{label:`Parse JSON`,checked:t.parseJSON,onChange:e=>n({parseJSON:e}),hint:`Turns null, true, false, [] and {} into real JSON values instead of strings.`}),(0,G.jsx)(YO,{label:`Skip empty fields`,checked:t.emptyFields===`skip`,onChange:e=>n({emptyFields:e?`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.`}),(0,G.jsx)(YO,{label:`NULL as null`,checked:t.nullLiterals===`null`,onChange:e=>n({nullLiterals:e?`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.`}),(0,G.jsx)(YO,{label:`Transpose`,checked:t.transpose,onChange:e=>n({transpose:e}),hint:`Flip rows and columns — the first column becomes the header row.`}),(0,G.jsx)(YO,{label:`Hash output`,checked:t.hash,onChange:e=>n({hash:e}),hint:`The first column becomes the object key instead of a field.`}),(0,G.jsx)(YO,{label:`Minify`,checked:t.minify,onChange:e=>n({minify:e}),hint:`Remove indentation from the JSON output. Data is untouched.`})]}):(0,G.jsx)(YO,{label:`Flatten nested arrays`,checked:t.flatten,onChange:e=>n({flatten:e}),hint:`Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table.`})]});return u?(0,G.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:(0,G.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:[m,r?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`span`,{"data-testid":`options-notice`,children:r})]}):null]})}):(0,G.jsxs)(`div`,{"data-testid":`options-row`,ref:l,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:[(0,G.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,ref:c,"data-testid":`options-settings-toggle`,"aria-expanded":o,"aria-haspopup":`true`,onClick:()=>o?p():s(!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`,(0,G.jsx)(R,{"aria-hidden":`true`,className:Tn(`size-3.5 shrink-0 transition-transform`,o&&`rotate-180`)})]}),(0,G.jsx)(`span`,{"data-testid":`options-settings-summary`,className:`min-w-0 truncate`,children:f}),r?(0,G.jsx)(`span`,{"data-testid":`options-notice`,className:`ml-auto shrink-0 text-right`,children:r}):null]}),(0,G.jsx)(`div`,{"data-testid":`options-settings-menu`,role:`group`,"aria-label":`Parse settings`,hidden:!o,className:Tn(`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:m})]})}var QO=[{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`}],$O=new Set([`csv`,`tsv`,`txt`,`json`,`jsonl`,`sql`,`ts`]),ek=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function tk(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function nk(e){if(Array.isArray(e))return e.map(e=>tk(e)?e:{value:e});if(tk(e)){let t=Object.entries(e);return t.length===0?[]:t.every(([,e])=>tk(e))?t.map(([e,t])=>{let n=t;return`key`in n?n:{key:e,...n}}):[e]}return[]}function rk(e){let t=new Set,n=[];for(let r of e)for(let e of Object.keys(r))t.has(e)||(t.add(e),n.push(e));return n}function ik(e){if(!e)return`data`;let t=e.trim(),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));for(n>=0&&(t=t.slice(n+1));;){let e=t.lastIndexOf(`.`);if(e<=0)break;if(e===t.length-1){t=t.slice(0,e);continue}let n=t.slice(e+1).toLowerCase();if(!$O.has(n))break;t=t.slice(0,e)}let r=t.replace(/[^a-zA-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return r.length>0?r:`data`}function ak(e){return`"${e.replace(/"/g,`""`)}"`}function ok(e){let t=e.filter(e=>e!=null);return t.length===0?`TEXT`:t.every(e=>typeof e==`boolean`)?`BOOLEAN`:t.every(e=>typeof e==`number`&&Number.isFinite(e))?t.every(e=>Number.isInteger(e))?`INTEGER`:`NUMERIC`:`TEXT`}function sk(e){return e==null?`NULL`:typeof e==`boolean`?e?`TRUE`:`FALSE`:typeof e==`number`?Number.isFinite(e)?String(e):`NULL`:typeof e==`string`?`'${e.replace(/'/g,`''`)}'`:`'${JSON.stringify(e).replace(/'/g,`''`)}'`}function ck(e){let t=e.trim();if(t===``)return``;let n;try{n=JSON.parse(t)}catch{return e}return nk(n).map(e=>JSON.stringify(e)).join(` +`)}function lk(e,t){let n=e.trim();if(n===``)return``;let r;try{r=JSON.parse(n)}catch{return e}let i=nk(r),a=rk(i),o=ak(ik(t));if(a.length===0)return`CREATE TABLE ${o} ();`;let s=`CREATE TABLE ${o} (\n${a.map(e=>{let t=ok(i.map(t=>t[e]));return` ${ak(e)} ${t}`}).join(`, +`)}\n);`;return i.length===0?s:`${s}\n\n${`INSERT INTO ${o} (${a.map(ak).join(`, `)}) VALUES\n${i.map(e=>` (${a.map(t=>sk(e[t])).join(`, `)})`).join(`, +`)};`}`}function uk(e){if(e===null)return`null`;if(typeof e==`string`)return`string`;if(typeof e==`number`)return`number`;if(typeof e==`boolean`)return`boolean`;if(Array.isArray(e)){if(e.length===0)return`unknown[]`;let t=fk(Array.from(new Set(e.map(e=>uk(e)))));return t.length===1?`${t[0]}[]`:`(${t.join(` | `)})[]`}return tk(e)?`Record`:`unknown`}var dk={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function fk(e){return[...e].sort((e,t)=>{let n=dk[e]??50,r=dk[t]??50;return n===r?e.localeCompare(t):n-r})}function pk(e){return ek.test(e)?e:JSON.stringify(e)}function mk(e){let t=e.trim();if(t===``)return``;let n;try{n=JSON.parse(t)}catch{return e}let r=nk(n),i=rk(r).map(e=>{let t=!1,n=new Set;for(let i of r)!Object.prototype.hasOwnProperty.call(i,e)||i[e]===void 0?t=!0:n.add(uk(i[e]));let i=fk(Array.from(n)),a=i.length>0?i.join(` | `):`unknown`,o=t?`?`:``;return` ${pk(e)}${o}: ${a};`});return`${i.length>0?`export interface DataRow {\n${i.join(` +`)}\n}`:`export interface DataRow {}`}\n\nexport const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function hk(e,t,n,r){let i=typeof e==`string`?e:e.text,a=typeof n==`string`||n===null?n:r??null;switch(t){case`json`:return i;case`jsonl`:return ck(i);case`sql`:return lk(i,a);case`ts`:return mk(i)}}var gk=3;function _k(e){let t=e.slice(0,gk),n=e.length-t.length;return(n>0?[...t,`+${n} more`]:t).join(` +`)}function vk({format:e,inputEmpty:t,outputText:n,error:r,meta:i,staleNotice:a,warnings:o,edited:s,editable:c,egressFormat:l=`json`,delimiter:u,dark:d,onCopy:f,onCopySelection:p,onProjectedCsvChange:m,onNativeCopy:h,onDownload:g,onEgressFormatChange:_,onOutputChange:v,onRevert:y,onDiscardReconvert:b}){let x=e===`JSON`,S=l===`json`;return(0,G.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:(0,G.jsx)(WD,{title:e,meta:t?null:s?(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.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`}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`revert-output`,onClick:y,className:GD,children:[(0,G.jsx)(Ne,{"aria-hidden":`true`}),`Revert`]})]}):a?(0,G.jsx)(`span`,{"data-testid":`stale-notice`,className:`text-xs text-amber-600 dark:text-amber-400`,children:a}):i,actions:(0,G.jsxs)(G.Fragment,{children:[x?(0,G.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:QO.map(e=>{let t=l===e.format;return(0,G.jsx)(`button`,{type:`button`,"data-testid":`output-format-option-${e.format}`,"aria-pressed":t,onClick:()=>_?.(e.format),className:Tn(`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:e.label},e.format)})}):null,(0,G.jsxs)(`button`,{type:`button`,"data-testid":`copy-output`,"aria-label":`Copy`,title:`Copy`,onClick:f,disabled:!n,className:GD,children:[(0,G.jsx)(Se,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`hidden xl:inline`,children:`Copy`})]}),(0,G.jsxs)(`button`,{type:`button`,"data-testid":`download-output`,"aria-label":`Download`,title:`Download`,onClick:g,disabled:!n,className:GD,children:[(0,G.jsx)(we,{"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`hidden xl:inline`,children:`Download`})]})]}),status:s?{kind:`notice`,message:`Output edited — CSV and option changes aren't applied.`,action:b?(0,G.jsxs)(`button`,{type:`button`,"data-testid":`discard-reconvert`,onClick:b,className:GD+` ml-2`,children:[(0,G.jsx)(Ne,{"aria-hidden":`true`}),`Discard edits & reconvert`]}):void 0}:r?{kind:`error`,message:r}:o&&o.length>0?{kind:`notice`,message:_k(o)}:null,children:t?(0,G.jsxs)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:[`Your `,e,` appears here.`]}):n?x?(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onCopy:()=>h?.(),children:(0,G.jsx)(UD,{value:n,editable:c&&S&&n.length<=2e6,lintJson:S,onChange:v,dark:d,testId:`output-view`})}):(0,G.jsx)(Ap,{text:n,delimiter:u,testId:`output-table`,dark:d,onCopySelection:p,onProjectedCsvChange:m}):r?(0,G.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:`Resolve the error to see output.`}):(0,G.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 yk({phase:e,message:t,onRetry:n}){return e===`loading`?(0,G.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…`}):e===`not-found`?(0,G.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:[(0,G.jsx)(`span`,{children:`This data doesn't exist (or was deleted).`}),(0,G.jsx)(`a`,{href:`/`,className:`font-medium underline underline-offset-2`,children:`Go to the converter`})]}):e===`unsupported`?(0,G.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:[(0,G.jsx)(`span`,{children:`This link's saved data can't be shown in the new converter.`}),(0,G.jsx)(`a`,{href:`/`,className:`font-medium underline underline-offset-2`,children:`Go to the converter`})]}):(0,G.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:[(0,G.jsx)(`span`,{children:t||`Couldn't load this data.`}),(0,G.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`})]})}var bk=`csvjson:recent.v1`,xk=80;function Sk(e){return e===`csv2json`||e===`json2csv`}function Ck(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))(r===`string`||r===`number`||r===`boolean`||r===`auto`)&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function wk(e){if(typeof e!=`object`||!e)return{...bO};let t=e,n=t.separator,r=n===`auto`||n===`,`||n===`;`||n===` `||n===`|`?n:bO.separator,i=t.emptyFields===`keep`||t.emptyFields===`skip`?t.emptyFields:bO.emptyFields,a=t.nullLiterals===`string`||t.nullLiterals===`null`?t.nullLiterals:bO.nullLiterals,o=Ck(t.columnTypes);return{separator:r,parseNumbers:typeof t.parseNumbers==`boolean`?t.parseNumbers:bO.parseNumbers,parseJSON:typeof t.parseJSON==`boolean`?t.parseJSON:bO.parseJSON,emptyFields:i,nullLiterals:a,transpose:typeof t.transpose==`boolean`?t.transpose:bO.transpose,hash:typeof t.hash==`boolean`?t.hash:bO.hash,minify:typeof t.minify==`boolean`?t.minify:bO.minify,flatten:typeof t.flatten==`boolean`?t.flatten:bO.flatten,collapseIndexedArrays:typeof t.collapseIndexedArrays==`boolean`?t.collapseIndexedArrays:bO.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function Tk(e){let t=(e.split(/\r?\n/).map(e=>e.trim()).find(e=>e.length>0)??``).replace(/\s+/g,` `);return t.length<=xk?t:`${t.slice(0,79)}…`}function Ek(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(typeof t.id!=`string`||t.id.trim()===``||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||!Sk(t.direction)||typeof t.input!=`string`||t.input.trim()===``||t.input.length>1e5||t.filename!==null&&typeof t.filename!=`string`||typeof t.rows!=`number`||!Number.isInteger(t.rows)||t.rows<0||typeof t.cols!=`number`||!Number.isInteger(t.cols)||t.cols<0||typeof t.preview!=`string`)}function Dk(e){return{id:e.id,createdAt:e.createdAt,direction:e.direction,input:e.input,options:wk(e.options),filename:e.filename,rows:e.rows,cols:e.cols,preview:e.preview||Tk(e.input)}}function Ok(e){try{if(typeof window>`u`)return;window.localStorage.setItem(bk,JSON.stringify(e))}catch{}}function kk(e){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`snap-${e}-${Math.random().toString(36).slice(2,10)}`}function Ak(){try{if(typeof window>`u`)return[];let e=window.localStorage.getItem(bk);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(Ek).map(Dk).sort((e,t)=>t.createdAt-e.createdAt).slice(0,10):[]}catch{return[]}}function jk(e){let t=Ak(),n=e.input.trim();if(n===``||e.input.length>1e5||e.rows<=0&&e.cols<=0)return t;let r=e.createdAt??Date.now(),i=[{id:t.find(t=>t.direction===e.direction&&t.input.trim()===n)?.id??kk(r),createdAt:r,direction:e.direction,input:e.input,options:wk(e.options),filename:e.filename,rows:e.rows,cols:e.cols,preview:Tk(e.input)},...t.filter(t=>t.direction!==e.direction||t.input.trim()!==n)].slice(0,10);return Ok(i),i}function Mk(e){let t=Ak().filter(t=>t.id!==e);return Ok(t),t}function Nk(){try{if(typeof window>`u`)return;window.localStorage.removeItem(bk)}catch{}}function Pk(e,t=Date.now()){let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<45)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);return o===1?`yesterday`:o<7?`${o}d ago`:new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function Fk(e){return e===`csv2json`?`CSV→JSON`:`JSON→CSV`}function Ik(e,t){return e>0&&t>0?`${e} rows · ${t} cols`:e>0?`${e} rows`:t>0?`${t} cols`:`0 rows`}function Lk({snapshots:e,onSelect:t,onRemove:n,onClear:r}){let[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=(0,g.useCallback)(()=>{a(!1)},[]),l=(0,g.useRef)(!1);(0,g.useEffect)(()=>{l.current&&!i&&s.current?.focus(),l.current=i},[i]),(0,g.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&c()},t=e=>{let t=o.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||c())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[i,c]);let u=e.length;return(0,G.jsxs)(`div`,{"data-testid":`recent-history`,ref:o,className:`relative max-sm:static`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`recent-history-toggle`,ref:s,onClick:()=>a(e=>!e),"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:[(0,G.jsx)(ve,{size:14,strokeWidth:2,"aria-hidden":`true`}),(0,G.jsx)(`span`,{className:`hidden sm:inline`,children:`Recent`}),u>0&&(0,G.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:u})]}),i&&(0,G.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:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold tracking-tight text-foreground`,children:`Recent conversions`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u>0&&(0,G.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`}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`recent-history-close`,onClick:c,"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:(0,G.jsx)(Ze,{size:14,strokeWidth:2,"aria-hidden":`true`})})]})]}),u===0?(0,G.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.`}):(0,G.jsx)(`div`,{className:`max-h-96 divide-y divide-border overflow-y-auto`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`recent-history-item-${e.id}`,onClick:()=>{t(e),c()},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:[(0,G.jsxs)(`div`,{className:`mb-1 flex w-full items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:Fk(e.direction)}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:Ik(e.rows,e.cols)}),(0,G.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:Pk(e.createdAt)})]}),(0,G.jsx)(`span`,{className:`w-full truncate font-mono text-xs text-foreground`,children:e.filename??e.preview})]}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`recent-history-delete-${e.id}`,onClick:t=>{t.stopPropagation(),n(e.id)},"aria-label":`Delete recent snapshot ${e.filename??e.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:(0,G.jsx)(qe,{size:13,strokeWidth:2,"aria-hidden":`true`})})]},e.id))})]})]})}function Rk(e){return Math.min(80,Math.max(20,e))}function zk({layout:e,split:t,onSplitChange:n,left:r,right:i,children:a}){let o=(0,g.useRef)(null),[s,c]=(0,g.useState)(!1),l=e===`stacked`;return(0,g.useEffect)(()=>{if(!s)return;let e=e=>{let t=o.current?.getBoundingClientRect();t&&t.width!==0&&t.height!==0&&n(Rk((l?(e.clientY-t.top)/t.height:(e.clientX-t.left)/t.width)*100))},t=()=>c(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[s,l,n]),(0,G.jsxs)(`div`,{ref:o,className:Tn(`relative flex min-h-0 flex-1`,`flex-col md:flex-row`,s&&`select-none`),children:[(0,G.jsx)(`div`,{"data-testid":`pane-left`,style:{"--split":`${t}%`},className:Tn(`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}),(0,G.jsxs)(`div`,{"data-testid":`seam`,role:`separator`,tabIndex:0,"aria-orientation":l?`horizontal`:`vertical`,"aria-valuenow":Math.round(t),"aria-valuemin":20,"aria-valuemax":80,"aria-label":`Resize panes`,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.target instanceof Element&&e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),c(!0))},onPointerUp:()=>c(!1),onDoubleClick:()=>n(50),onKeyDown:e=>{let r=e.shiftKey?5:1;switch(e.key){case`ArrowLeft`:case`ArrowUp`:e.preventDefault(),n(Rk(t-r));break;case`ArrowRight`:case`ArrowDown`:e.preventDefault(),n(Rk(t+r));break;case`Home`:e.preventDefault(),n(20);break;case`End`:e.preventDefault(),n(80);break;case`Enter`:case` `:e.preventDefault(),n(50)}},style:{"--split":`${t}%`,touchAction:`none`},className:Tn(`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:[(0,G.jsx)(`div`,{className:Tn(`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`)}),a?(0,G.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:a}):null]}),(0,G.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 Bk({theme:e}){return e===`dark`?(0,G.jsx)(ze,{size:15,strokeWidth:2,"aria-hidden":`true`}):(0,G.jsx)(De,{size:15,strokeWidth:2,"aria-hidden":`true`})}function Vk({theme:e,onToggleTheme:t,slot:n}){return(0,G.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:[(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap`,children:`csvjson`}),(0,G.jsx)(`span`,{className:`hidden text-[13px] font-medium text-muted-foreground sm:inline`,children:`CSV → JSON converter`})]}),(0,G.jsx)(`div`,{className:`flex-1`}),(0,G.jsx)(`div`,{"data-testid":`topbar-slot`,children:n}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`theme-toggle`,onClick:t,"aria-label":e===`dark`?`Switch to light mode`:`Switch to dark mode`,title:e===`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:(0,G.jsx)(Bk,{theme:e})})]})}function Hk(e){return[...e].sort((e,t)=>t.id-e.id)}var Uk=[{id:24,date:`2026-10-20`,tag:`improvement`,title:`Clearer supported paste and upload formats in the input area`,summary:`The empty-state input area and file picker now explicitly list every accepted format in each mode — CSV, TSV / spreadsheet cells, Markdown & ChatGPT multi-table docs, and psql/MySQL box tables in CSV → JSON, plus JSON arrays, nested objects, wrapped API payloads, and JSONL / NDJSON in JSON → CSV.`},{id:23,date:`2026-10-20`,tag:`new`,title:`Extract and switch between multiple tables in pasted Markdown`,summary:`Paste an entire ChatGPT response or Markdown document containing prose and multiple Markdown or CLI box tables into CSV → JSON: every table is detected in order with interactive chooser pills to switch which table is previewed and converted, or keep only the selected table as clean CSV.`},{id:22,date:`2026-10-20`,tag:`new`,title:`Column visibility picker and Apply view to output`,summary:`Use the new Columns menu in any data table to hide or restore columns without touching your raw input. When a search filter, sort order, or column subset is active, toggle Apply view to output to project that exact table view into the converted output, Copy, and Download.`},{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.`}],Wk=864e5;function Gk(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function Kk(e,t=Date.now()){let n=new Date(`${e}T00:00:00Z`),r=new Date(t),i=Math.round((Gk(r)-Gk(n))/Wk);if(i<=0)return`today`;if(i===1)return`yesterday`;if(i<7)return`${i} days ago`;let a=n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`});return n.getUTCFullYear()===r.getUTCFullYear()?a:`${a}, ${n.getUTCFullYear()}`}var qk=`csvjson:changelog.v1`,Jk=Math.max(...Uk.map(e=>e.id),0),Yk=Hk(Uk);function Xk(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.lastSeenId!==null&&typeof t.lastSeenId!=`number`||typeof t.votes!=`object`||t.votes===null)return!1;for(let[e,n]of Object.entries(t.votes))if(!/^\d+$/.test(e)||n!==1&&n!==-1)return!1;return!(t.clientId!==void 0&&!Zk(t.clientId)||t.pendingIds!==void 0&&(!Array.isArray(t.pendingIds)||t.pendingIds.some(e=>typeof e!=`number`||!Number.isInteger(e)||e<1)))}function Zk(e){return typeof e==`string`&&/^[0-9a-fA-F-]{8,64}$/.test(e)}function Qk(e){return e===void 0?[]:[...new Set(e)].filter(e=>e>=1&&e<=Jk).sort((e,t)=>e-t)}function $k(e,t,n){let r=Qk(e.pendingIds),i=n?[...new Set([...r,t])].sort((e,t)=>e-t):r.filter(e=>e!==t);return{...e,pendingIds:i}}function eA(){try{let e=window.localStorage.getItem(qk);if(e===null)return{lastSeenId:null,votes:{}};let t=JSON.parse(e);return Xk(t)?{...t,pendingIds:Qk(t.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function tA(e){try{window.localStorage.setItem(qk,JSON.stringify(e))}catch{}}function nA(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=globalThis.crypto?.getRandomValues?.(new Uint8Array(16));if(e===void 0)throw Error(`no secure randomness available`);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}async function rA(e,t,n){try{return(await fetch(`/api/changelog-vote`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:e,entryId:t,vote:n})})).ok?`ok`:`failed`}catch{return`failed`}}function iA(e){return[`flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors`,e?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`].join(` `)}function aA({entry:e,vote:t,queued:n,inFlight:r,onVote:i}){return(0,G.jsxs)(`article`,{className:`px-3 py-2.5`,"data-testid":`changelog-entry-${e.id}`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[e.tag!==void 0&&(0,G.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.tag}),(0,G.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:Kk(e.date)})]}),(0,G.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:e.title}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-muted-foreground`,children:e.summary}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex gap-1`,children:[(0,G.jsx)(`button`,{type:`button`,"data-testid":`changelog-up-${e.id}`,onClick:()=>i(e.id,1),"aria-pressed":t===1,"aria-label":`Upvote: ${e.title}`,title:`Good change`,className:iA(t===1),children:(0,G.jsx)(Ge,{size:13,strokeWidth:2,"aria-hidden":`true`})}),(0,G.jsx)(`button`,{type:`button`,"data-testid":`changelog-down-${e.id}`,onClick:()=>i(e.id,-1),"aria-pressed":t===-1,"aria-label":`Downvote: ${e.title}`,title:`Not for me`,className:iA(t===-1),children:(0,G.jsx)(Ue,{size:13,strokeWidth:2,"aria-hidden":`true`})})]}),n&&!r&&(0,G.jsx)(`p`,{"data-testid":`changelog-queued-${e.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 oA(){let[e,t]=(0,g.useState)(eA),[n,r]=(0,g.useState)(!1),i=(0,g.useRef)(e),a=(0,g.useCallback)(e=>{tA(e),i.current=e,t(e)},[]),[o,s]=(0,g.useState)(()=>new Set),c=(0,g.useRef)(new Set),l=(0,g.useRef)(null),u=(0,g.useRef)(null),d=(0,g.useRef)(new Map),f=e.lastSeenId!==null&&Jk>e.lastSeenId,p=(0,g.useCallback)((e,t)=>{s(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),m=(0,g.useCallback)((e,t,n,r)=>{let o=(d.current.get(e)??0)+1;d.current.set(e,o),c.current.add(e),r&&p(e,!0),rA(n,e,t).then(n=>{d.current.get(e)===o&&(c.current.delete(e),n===`ok`&&(w({entry_id:e,vote:t}),a($k(i.current,e,!1))),r&&p(e,!1))})},[a,p]),h=(0,g.useCallback)(e=>{let{clientId:t,pendingIds:n,votes:r}=i.current,a=n??[];if(a.length!==0&&t!==void 0)for(let n of a){if(n===e||c.current.has(n))continue;let i=r[n];i!==void 0&&m(n,i,t,!1)}},[m]),_=(t,n)=>{if(e.votes[t]===n){h();return}let r=e.clientId??nA();a($k({...e,votes:{...e.votes,[t]:n},clientId:r},t,!0)),m(t,n,r,!0),h(t)},v=()=>{r(!0),C(),e.lastSeenId!==Jk&&a({...e,lastSeenId:Jk}),h()},y=(0,g.useCallback)(()=>{r(!1)},[]),b=(0,g.useRef)(!1);(0,g.useEffect)(()=>{b.current&&!n&&u.current?.focus(),b.current=n},[n]);let x=(0,g.useRef)(!1);return(0,g.useEffect)(()=>{x.current||(x.current=!0,h())},[h]),(0,g.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&y()},t=e=>{let t=l.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||y())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[n,y]),(0,G.jsxs)(`div`,{"data-testid":`changelog`,ref:l,className:`relative max-sm:static`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`changelog-toggle`,ref:u,onClick:()=>n?y():v(),"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:[(0,G.jsx)(je,{size:15,strokeWidth:2,"aria-hidden":`true`}),f&&(0,G.jsx)(`span`,{"data-testid":`changelog-dot`,"aria-hidden":`true`,className:`absolute right-1 top-1 size-1.5 rounded-full bg-foreground`})]}),n&&(0,G.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:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5`,children:[(0,G.jsx)(`span`,{className:`text-xs font-semibold tracking-tight text-foreground`,children:`What's new`}),(0,G.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:(0,G.jsx)(Ze,{size:14,strokeWidth:2,"aria-hidden":`true`})})]}),(0,G.jsx)(`div`,{className:`max-h-96 divide-y divide-border overflow-y-auto`,children:Yk.map(t=>(0,G.jsx)(aA,{entry:t,vote:e.votes[t.id],queued:e.pendingIds?.includes(t.id)??!1,inFlight:o.has(t.id),onVote:_},t.id))})]})]})}function sA(e,t){let[n,r]=(0,g.useState)(e);return(0,g.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var cA=[`csv2json`,`json2csv`,`json_validator`,`json_beautifier`,`sql2json`,`csvjson2json`,`datajanitor`],lA=[`csv2json`,`json2csv`,`csvjson2json`];function uA(e){return lA.includes(e)}var dA=/^[0-9a-f]{32}$/i,fA=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,pA=({BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_S3_DATA_URL??`https://csvjson.s3.us-east-2.amazonaws.com/data/`).replace(/\/*$/,`/`);function mA(e){let t=fA.exec(e);if(!t)return null;let n=t[1].toLowerCase();return cA.includes(n)?{tool:n,id:t[2].toLowerCase()}:null}var hA=class extends Error{constructor(){super(`This data doesn't exist (or was deleted)`),this.name=`PermalinkNotFoundError`}},gA=class extends Error{constructor(e,t){super(e,t),this.name=`PermalinkFetchError`}},_A={csv:(e,t)=>{e.direction=`csv2json`,e.input=vA(t)},json:(e,t)=>{e.input=vA(t),e.direction=`json2csv`},parseNumbers:(e,t)=>{let n=bA(t);n!==void 0&&(e.options.parseNumbers=n)},parseJSON:(e,t)=>{let n=bA(t);n!==void 0&&(e.options.parseJSON=n)},transpose:(e,t)=>{let n=bA(t);n!==void 0&&(e.options.transpose=n)},"output-array":(e,t)=>{let n=bA(t);n!==void 0&&(e.options.hash=!n)},"output-hash":(e,t)=>{let n=bA(t);n!==void 0&&(e.options.hash=n)},flatten:(e,t)=>{let n=bA(t);n!==void 0&&(e.options.flatten=n)},output_csvjson_variant:()=>{}};function vA(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}function yA(e){return typeof e==`string`&&e.trim()!==``}function bA(e){if(e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1}function xA(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:Object.values(e).every(e=>typeof e==`string`||typeof e==`boolean`)}function SA(e){if(!xA(e))return null;let t=yA(e.csv),n=yA(e.json);if(!t&&!n)return null;let r={direction:t?`csv2json`:`json2csv`,input:``,options:{}};for(let[t,n]of Object.entries(e))_A[t]?.(r,n);return r.input=vA(t?e.csv:e.json),r}async function CA(e){if(!dA.test(e))throw new hA;let t;try{t=await fetch(`${pA}${e}`,{mode:`cors`})}catch(e){throw new gA(`Network error while loading this data`,{cause:e})}if(t.status===403||t.status===404)throw new hA;if(!t.ok)throw new gA(`Unexpected response while loading this data (HTTP ${t.status})`);let n;try{let e=await t.text();if(e.trim()===``)throw Error(`empty body`);n=JSON.parse(e)}catch{throw new gA(`Stored data for this link is malformed`)}return n}function wA(e){let t=(0,g.useMemo)(()=>e&&uA(e.tool)?e.id:null,[e]),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(t?`loading`:`idle`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``);return(0,g.useEffect)(()=>{if(!t)return;let e=!1;return CA(t).then(t=>{if(e)return;let n=SA(t);n?(s(n),a(`hydrated`)):a(`unsupported`)}).catch(t=>{e||(t instanceof hA?a(`not-found`):(l(t instanceof Error?t.message:`Couldn't load this data`),a(`error`)))}),()=>{e=!0}},[t,n]),{phase:i,hydrated:o,message:c,retry:()=>{i===`error`&&(a(`loading`),r(e=>e+1))}}}async function TA(e){try{if(typeof navigator<`u`&&navigator.clipboard)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function EA(e,t){return t?``+e:e}function DA(e,t,n){let r=EA(e,n);return new Blob([r],{type:`${t};charset=utf-8`})}var OA=new Set([`csv`,`tsv`,`json`,`jsonl`,`sql`,`ts`,`txt`]);function kA(e){let t=e;for(;;){let e=t.lastIndexOf(`.`);if(e<=0)break;if(e===t.length-1)t=t.slice(0,e);else{if(!OA.has(t.slice(e+1).toLowerCase()))break;t=t.slice(0,e)}}return t}function AA(e,t,n=`json`){let r=t===`csv2json`?n:`csv`;return e?`${kA(e)}.${r}`:`data.${r}`}function jA(e,t=`json`){if(e===`json2csv`)return`text/csv`;switch(t){case`json`:return`application/json`;case`jsonl`:return`application/x-ndjson`;case`sql`:return`application/sql`;case`ts`:return`text/typescript`}}function MA(e,t,{mime:n=`text/plain`,bom:r=!1}={}){let i=DA(e,n,r),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(a),0),t}function NA(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.closest(`[contenteditable="true"]`)!==null}var PA=`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`,FA=`[ + { + "album": "Elephant", + "year": 2003, + "label": "XL Recordings" + }, + { + "album": "Icky Thump", + "year": 2007, + "label": "XL Recordings" + } +]`,IA=`csvjson-theme`;function LA(){try{let e=localStorage.getItem(IA);return e===`dark`||e===`light`?e:null}catch{return null}}function RA(){try{if(typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function zA(){return LA()??RA()}function BA(e){try{localStorage.setItem(IA,e)}catch{}}function VA(e){return new URLSearchParams(e).get(`direction`)===`json2csv`?`json2csv`:`csv2json`}var HA=2097152,UA=150,WA=1e3,GA=2e3,KA=2e3;function qA(e,t){return e===0?null:t>0?`${e} rows · ${t} cols`:`${e} rows`}function JA(e){try{return JSON.parse(e),!0}catch{return!1}}function YA(){let[e,t]=(0,g.useState)(zA);(0,g.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`)},[e]);let n=()=>t(e=>{let t=e===`dark`?`light`:`dark`;return BA(t),t}),[r,i]=(0,g.useState)(()=>typeof window>`u`?`csv2json`:VA(window.location.search)),[a,o]=(0,g.useState)(()=>Qf(``)),s=a.present,[c,l]=(0,g.useState)(bO),[u,d]=(0,g.useState)(`json`),[f,p]=(0,g.useState)(50),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,C]=(0,g.useState)(`utf-8`),[w,T]=(0,g.useState)(Ak),[E,D]=(0,g.useState)(null),[O,A]=(0,g.useState)(null),[ee,te]=(0,g.useState)({forInput:``,index:0}),ne=ee.forInput===s?ee.index:0,j=(0,g.useCallback)(e=>{te({forInput:s,index:e})},[s]),M=(0,g.useMemo)(()=>ne>0?{...c,markdownTableIndex:ne}:c,[c,ne]),ie=(0,g.useRef)({direction:r,options:c,input:s,resultOk:!0}),ae=(0,g.useRef)(null);ae.current||=re({settleMs:GA,minWindowMs:KA,isValid:(e,t)=>{let n=ie.current;return t===n.input?n.resultOk:MO(e===`csv_to_json`?`csv2json`:`json2csv`,t,n.options).ok}});let N=ae.current;(0,g.useEffect)(()=>()=>N.cancel(),[N]);let oe=HO(`(min-width: 48rem)`)?`side-by-side`:`stacked`,P=r===`csv2json`,F=P?`CSV`:`JSON`,se=P?`JSON`:`CSV`,I=s.trim()===``,ce=s.length>HA?WA:UA,le=sA(s,I?0:ce),ue=(0,g.useRef)(null),de=(0,g.useRef)(null),fe=s!==``&&ue.current?.text===s?s:le,pe=P&&E!==null&&fe.trim()!==``?E:fe,me=(0,g.useMemo)(()=>typeof window>`u`?null:mA(window.location.pathname),[]),L=wA(me),he=(0,g.useMemo)(()=>MO(r,pe,M),[r,pe,M]);ie.current={direction:r,options:M,input:fe,resultOk:he.ok},(0,g.useEffect)(()=>{let e=de.current;e&&e.text===fe&&(de.current=null,N.discrete(e.direction,e.via,e.text))},[fe,he,N]);let[R,ge]=(0,g.useState)(null);(0,g.useEffect)(()=>{fe.trim()!==``&&he.ok&&ge(he.text)},[he,fe]),(0,g.useEffect)(()=>{fe.trim()!==``&&(!he.ok||he.rows<=0&&he.cols<=0||T(jk({direction:r,input:fe,options:c,filename:m,rows:he.rows,cols:he.cols})))},[r,fe,m,c,he]);let z=fe.trim()!==``&&he.ok?he.text:R,[_e,ve]=(0,g.useState)(!1),[ye,be]=(0,g.useState)(null),xe=_e?ye:z,Se=(0,g.useMemo)(()=>{if(!P||xe===null||u===`json`)return xe;let e=_e&&ye!==null&&JA(ye)?ye:z;return e===null?null:hk(e,u,c,m)},[P,xe,u,_e,ye,z,c,m]),Ce=P&&u===`json`&&!I&&Se!==null&&(_e||he.ok),we=(0,g.useCallback)(e=>{e===z?(ve(!1),be(null)):(ve(!0),be(e))},[z]),B=(0,g.useCallback)(()=>{let e=P&&E!==null&&s.trim()!==``?E:s,t=MO(r,e,M);t.ok&&ge(t.text),ve(!1),be(null)},[P,r,M,s,E]),Te=(0,g.useCallback)(e=>{o(t=>P?$f(t,e):Qf(e))},[P]),Ee=P&&a.past.length>0,De=P&&a.future.length>0,Oe=(0,g.useCallback)(()=>{if(!P||a.past.length===0)return;let e=ep(a);b(null),o(e),N.edit(`csv_to_json`,e.present)},[P,a,N]),ke=(0,g.useCallback)(()=>{if(!P||a.future.length===0)return;let e=tp(a);b(null),o(e),N.edit(`csv_to_json`,e.present)},[P,a,N]),Ae=(0,g.useCallback)(e=>{b(null),ue.current=null,i(e.direction),l({...e.options}),h(e.filename),ve(!1),be(null),o(t=>e.direction===`csv2json`&&r===`csv2json`?$f(t,e.input):Qf(e.input)),T(jk({direction:e.direction,input:e.input,options:e.options,filename:e.filename,rows:e.rows,cols:e.cols}))},[r]),je=(0,g.useCallback)(e=>{T(Mk(e))},[]),Me=(0,g.useCallback)(()=>{Nk(),T([])},[]),Ne=()=>{let e=r===`csv2json`?`json2csv`:`csv2json`;if(_e){let t=ye??``,n=JA(t)?t:s;o(Qf(n)),i(e),ve(!1),be(null),n.trim()!==``&&(ie.current={direction:e,options:c,input:n,resultOk:MO(e,n,c).ok},N.discrete(e===`csv2json`?`csv_to_json`:`json_to_csv`,`flip`,n))}else if(i(e),I)o(Qf(``));else{let t=MO(r,s,M),n=t.ok?t.text:s;o(Qf(n)),n.trim()!==``&&(ie.current={direction:e,options:c,input:n,resultOk:MO(e,n,c).ok},N.discrete(e===`csv2json`?`csv_to_json`:`json_to_csv`,`flip`,n))}},Pe=L.hydrated;(0,g.useEffect)(()=>{if(Pe===null)return;let e={...ie.current.options,...Pe.options};ie.current={direction:Pe.direction,options:e,input:Pe.input,resultOk:MO(Pe.direction,Pe.input,e).ok},i(Pe.direction),o(Qf(Pe.input)),l(e=>({...e,...Pe.options})),ve(!1),be(null),S(),N.discrete(Pe.direction===`csv2json`?`csv_to_json`:`json_to_csv`,`permalink`,Pe.input)},[Pe,N]);let Fe=async(e,t)=>{if(!zO(e))b(`Can't read "${e.name}" as text — drop a ${P?`.csv / .tsv`:`.json`} file.`);else{b(null),v(!0);try{let n=await VO(e,x);ue.current={file:e,source:t,text:n},de.current={direction:P?`csv_to_json`:`json_to_csv`,via:t===`drop`?`drag`:`file`,text:n},Te(n),h(e.name),v(!1)}catch{v(!1),b(`Couldn't read "${e.name}".`)}}},Ie=async e=>{let t=x;C(e);let n=ue.current;if(n&&s===n.text){v(!0);try{let t=await VO(n.file,e);ue.current={...n,text:t},de.current={direction:P?`csv_to_json`:`json_to_csv`,via:n.source===`drop`?`drag`:`file`,text:t},o(e=>({...e,present:t})),v(!1)}catch{v(!1),C(t),b(`Couldn't read "${n.file.name}".`)}}},Le=(0,g.useCallback)(e=>{b(null),e.trim()===``&&l(e=>{if(!e.columnTypes)return e;let t={...e};return delete t.columnTypes,t}),Te(e),N.edit(P?`csv_to_json`:`json_to_csv`,e)},[Te,P,N]);(0,g.useEffect)(()=>{let e=e=>{let t=e.clipboardData?.getData(`text/plain`);t&&!NA(e.target)&&(e.preventDefault(),e.stopPropagation(),h(null),Le(t))};return document.addEventListener(`paste`,e,!0),()=>document.removeEventListener(`paste`,e,!0)},[Le]);let Re=he.ok?qA(he.rows,he.cols):null,ze=!he.ok&&R?`Last valid result — input has errors`:null,Be=he.ok&&he.warnings&&he.warnings.length>0?he.warnings:null,Ve=s.length>HA,He=P?`csv_to_json`:`json_to_csv`,Ue=P?u:`csv`,We=()=>{k({via:`copy`,format:P?`csv`:`json`,pane:`input`,direction:He}),TA(s)},Ge=!P&&O!==null?O:Se,Ke=()=>{k({via:`copy`,format:Ue,pane:`output`,direction:He}),Ge&&TA(Ge)},qe=()=>{k({via:`download`,format:P?`csv`:`json`,pane:`input`,direction:He}),MA(s,m??(P?`data.csv`:`data.json`),{mime:P?`text/csv`:`application/json`,bom:P})},Je=()=>{k({via:`download`,format:Ue,pane:`output`,direction:He}),MA(Ge??``,AA(m,P?`csv2json`:`json2csv`,u),{mime:jA(P?`csv2json`:`json2csv`,u),bom:!P})},Ye=(0,g.useCallback)(()=>{k({via:`copy`,format:`csv`,pane:`input`,direction:He})},[He]),Xe=(0,g.useCallback)(()=>{k({via:`copy`,format:`csv`,pane:`output`,direction:He})},[He]),Ze=(0,g.useCallback)(()=>{k({via:`copy`,format:Ue,pane:`output`,direction:He})},[Ue,He]),Qe=(0,G.jsx)(LO,{format:F,input:s,onInputChange:Le,onCellCommit:Le,onFile:Fe,onTryExample:()=>{b(null);let e=P?PA:FA;ie.current={direction:r,options:c,input:e,resultOk:MO(r,e,c).ok},Te(e),N.discrete(He,`example`,e)},onClear:()=>{Te(``),h(null),l(e=>{if(!e.columnTypes)return e;let t={...e};return delete t.columnTypes,t}),ve(!1),be(null),N.cancel()},onCopy:We,onCopySelection:Ye,onProjectedCsvChange:D,onDownload:qe,canUndo:Ee,canRedo:De,onUndo:Oe,onRedo:ke,collapseIndexedArrays:c.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>l(e=>({...e,collapseIndexedArrays:!(e.collapseIndexedArrays??!0)})),columnTypes:c.columnTypes??{},onChangeColumnTypes:e=>l(t=>{let n={...t};return Object.keys(e).length>0?n.columnTypes=e:delete n.columnTypes,n}),flatten:c.flatten,onToggleFlatten:()=>l(e=>({...e,flatten:!e.flatten})),selectedMarkdownTableIndex:ne,onSelectMarkdownTableIndex:j,filename:m,reading:_,meta:Re,error:null,notice:y,delimiter:c.separator===`auto`?void 0:c.separator,dark:e===`dark`}),$e=(0,G.jsx)(vk,{format:se,inputEmpty:I,outputText:Se,error:he.ok?null:he.error,meta:Re,staleNotice:ze,warnings:Be,edited:_e,editable:Ce,egressFormat:u,delimiter:c.separator===`auto`?void 0:c.separator,dark:e===`dark`,onCopy:Ke,onCopySelection:Xe,onProjectedCsvChange:A,onNativeCopy:Ze,onDownload:Je,onEgressFormatChange:d,onOutputChange:we,onRevert:B,onDiscardReconvert:B});return(0,G.jsxs)(`div`,{className:`flex min-h-svh flex-col bg-background text-foreground`,children:[(0,G.jsx)(`h1`,{className:`sr-only`,children:`CSV to JSON and JSON to CSV converter`}),(0,G.jsxs)(`div`,{className:`flex min-h-svh flex-col md:h-svh md:min-h-0`,children:[(0,G.jsx)(Pn,{}),(0,G.jsx)(Vk,{theme:e,onToggleTheme:n,slot:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Lk,{snapshots:w,onSelect:Ae,onRemove:je,onClear:Me}),(0,G.jsx)(oA,{}),(0,G.jsx)(Wn,{})]})}),me&&(L.phase===`loading`||L.phase===`not-found`||L.phase===`unsupported`||L.phase===`error`)?(0,G.jsx)(yk,{phase:L.phase,message:L.phase===`error`?L.message:void 0,onRetry:L.retry}):null,(0,G.jsx)(zk,{layout:oe,split:f,onSplitChange:p,left:Qe,right:$e,children:(0,G.jsx)(kn,{direction:r,onFlip:Ne})}),(0,G.jsx)(ZO,{direction:r,options:c,onChange:e=>l(t=>({...t,...e})),uploadEncoding:x,onUploadEncodingChange:Ie,notice:Ve?`Large file — converting on pause`:null})]}),(0,G.jsx)(Mn,{})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(g.StrictMode,{children:(0,G.jsx)(YA,{})})),document.getElementById(`root`).removeAttribute(`inert`),b(),x();export{ii as a,m as c,Si as i,u as l,xs as n,ai as o,vs as r,si as s,ju as t,c as u}; \ No newline at end of file diff --git a/app/dist/assets/index-Dw_RpILp.js b/app/dist/assets/index-Dw_RpILp.js deleted file mode 100644 index e2822d2..0000000 --- a/app/dist/assets/index-Dw_RpILp.js +++ /dev/null @@ -1,114 +0,0 @@ -var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=o((e=>{var t=Symbol.for(`react.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.provider`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.iterator;function p(e){return typeof e!=`object`||!e?null:(e=f&&e[f]||e[`@@iterator`],typeof e==`function`?e:null)}var m={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},h=Object.assign,g={};function _(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}_.prototype.isReactComponent={},_.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},_.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function v(){}v.prototype=_.prototype;function y(e,t,n){this.props=e,this.context=t,this.refs=g,this.updater=n||m}var b=y.prototype=new v;b.constructor=y,h(b,_.prototype),b.isPureReactComponent=!0;var x=Array.isArray,S=Object.prototype.hasOwnProperty,C={current:null},w={key:!0,ref:!0,__self:!0,__source:!0};function T(e,n,r){var i,a={},o=null,s=null;if(n!=null)for(i in n.ref!==void 0&&(s=n.ref),n.key!==void 0&&(o=``+n.key),n)S.call(n,i)&&!w.hasOwnProperty(i)&&(a[i]=n[i]);var c=arguments.length-2;if(c===1)a.children=r;else if(1{t.exports=l()})),d=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=typeof setTimeout==`function`?setTimeout:null,_=typeof clearTimeout==`function`?clearTimeout:null,v=typeof setImmediate<`u`?setImmediate:null;typeof navigator<`u`&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function b(e){if(h=!1,y(e),!m){if(n(c)!==null)m=!0,te(x);else{var t=n(l);t!==null&&ne(b,t.startTime-e)}}}function x(t,i){m=!1,h&&(h=!1,_(w),w=-1),p=!0;var a=f;try{for(y(i),d=n(c);d!==null&&(!(d.expirationTime>i)||t&&!D());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=i);i=e.unstable_now(),typeof s==`function`?d.callback=s:d===n(c)&&r(c),y(i)}else r(c);d=n(c)}if(d!==null)var u=!0;else{var g=n(l);g!==null&&ne(b,g.startTime-i),u=!1}return u}finally{d=null,f=a,p=!1}}var S=!1,C=null,w=-1,T=5,E=-1;function D(){return!(e.unstable_now()-Ee||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(_(w),w=-1):h=!0,ne(b,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,te(x))),r},e.unstable_shouldYield=D,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u(),n=f();function r(e){for(var t=`https://reactjs.org/docs/error-decoder.html?invariant=`+e,n=1;nt}return!1}function v(e,t,n,r,i,a,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=o}var y={};`children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style`.split(` `).forEach(function(e){y[e]=new v(e,0,!1,e,null,!1,!1)}),[[`acceptCharset`,`accept-charset`],[`className`,`class`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`]].forEach(function(e){var t=e[0];y[t]=new v(t,1,!1,e[1],null,!1,!1)}),[`contentEditable`,`draggable`,`spellCheck`,`value`].forEach(function(e){y[e]=new v(e,2,!1,e.toLowerCase(),null,!1,!1)}),[`autoReverse`,`externalResourcesRequired`,`focusable`,`preserveAlpha`].forEach(function(e){y[e]=new v(e,2,!1,e,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(e){y[e]=new v(e,3,!1,e.toLowerCase(),null,!1,!1)}),[`checked`,`multiple`,`muted`,`selected`].forEach(function(e){y[e]=new v(e,3,!0,e,null,!1,!1)}),[`capture`,`download`].forEach(function(e){y[e]=new v(e,4,!1,e,null,!1,!1)}),[`cols`,`rows`,`size`,`span`].forEach(function(e){y[e]=new v(e,6,!1,e,null,!1,!1)}),[`rowSpan`,`start`].forEach(function(e){y[e]=new v(e,5,!1,e.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function x(e){return e[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(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,null,!1,!1)}),`xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type`.split(` `).forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/1999/xlink`,!1,!1)}),[`xml:base`,`xml:lang`,`xml:space`].forEach(function(e){var t=e.replace(b,x);y[t]=new v(t,1,!1,e,`http://www.w3.org/XML/1998/namespace`,!1,!1)}),[`tabIndex`,`crossOrigin`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!1,!1)}),y.xlinkHref=new v(`xlinkHref`,1,!1,`xlink:href`,`http://www.w3.org/1999/xlink`,!0,!1),[`src`,`href`,`action`,`formAction`].forEach(function(e){y[e]=new v(e,1,!1,e.toLowerCase(),null,!0,!0)});function S(e,t,n,r){var i=y.hasOwnProperty(t)?y[t]:null;(i===null?r||!(2s||i[o]!==a[s]){var c=` -`+i[o].replace(` at new `,` at `);return e.displayName&&c.includes(``)&&(c=c.replace(``,e.displayName)),c}while(1<=o&&0<=s);break}}}finally{se=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:``)?P(e):``}function F(e){switch(e.tag){case 5:return P(e.type);case 16:return P(`Lazy`);case 13:return P(`Suspense`);case 19:return P(`SuspenseList`);case 0:case 2:case 15:return e=ce(e.type,!1),e;case 11:return e=ce(e.type.render,!1),e;case 1:return e=ce(e.type,!0),e;default:return``}}function le(e){if(e==null)return null;if(typeof e==`function`)return e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case E:return`Fragment`;case T:return`Portal`;case O:return`Profiler`;case D:return`StrictMode`;case te:return`Suspense`;case ne:return`SuspenseList`}if(typeof e==`object`)switch(e.$$typeof){case A:return(e.displayName||`Context`)+`.Consumer`;case k:return(e._context.displayName||`Context`)+`.Provider`;case ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case j:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}function ue(e){var t=e.type;switch(e.tag){case 24:return`Cache`;case 9:return(t.displayName||`Context`)+`.Consumer`;case 10:return(t._context.displayName||`Context`)+`.Provider`;case 18:return`DehydratedFragment`;case 11:return e=t.render,e=e.displayName||e.name||``,t.displayName||(e===``?`ForwardRef`:`ForwardRef(`+e+`)`);case 7:return`Fragment`;case 5:return t;case 4:return`Portal`;case 3:return`Root`;case 6:return`Text`;case 16:return le(t);case 8:return t===D?`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 t==`function`)return t.displayName||t.name||null;if(typeof t==`string`)return t}return null}function de(e){switch(typeof e){case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function fe(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function pe(e){var t=fe(e)?`checked`:`value`,n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=``+e[t];if(!e.hasOwnProperty(t)&&n!==void 0&&typeof n.get==`function`&&typeof n.set==`function`){var i=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){r=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function me(e){e._valueTracker||=pe(e)}function he(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=fe(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function ge(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function I(e,t){var n=t.checked;return N({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function L(e,t){var n=t.defaultValue==null?``:t.defaultValue,r=t.checked==null?t.defaultChecked:t.checked;n=de(t.value==null?n:t.value),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type===`checkbox`||t.type===`radio`?t.checked!=null:t.value!=null}}function _e(e,t){t=t.checked,t!=null&&S(e,`checked`,t,!1)}function R(e,t){_e(e,t);var n=de(t.value),r=t.type;if(n!=null)r===`number`?(n===0&&e.value===``||e.value!=n)&&(e.value=``+n):e.value!==``+n&&(e.value=``+n);else if(r===`submit`||r===`reset`){e.removeAttribute(`value`);return}t.hasOwnProperty(`value`)?ye(e,t.type,n):t.hasOwnProperty(`defaultValue`)&&ye(e,t.type,de(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ve(e,t,n){if(t.hasOwnProperty(`value`)||t.hasOwnProperty(`defaultValue`)){var r=t.type;if(!(r!==`submit`&&r!==`reset`||t.value!==void 0&&t.value!==null))return;t=``+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==``&&(e.name=``),e.defaultChecked=!!e._wrapperState.initialChecked,n!==``&&(e.name=n)}function ye(e,t,n){(t!==`number`||ge(e.ownerDocument)!==e)&&(n==null?e.defaultValue=``+e._wrapperState.initialValue:e.defaultValue!==``+n&&(e.defaultValue=``+n))}var be=Array.isArray;function xe(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i`+t.valueOf().toString()+``,t=Ee.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Oe(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ke={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},Ae=[`Webkit`,`ms`,`Moz`,`O`];Object.keys(ke).forEach(function(e){Ae.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ke[t]=ke[e]})});function je(e,t,n){return t==null||typeof t==`boolean`||t===``?``:n||typeof t!=`number`||t===0||ke.hasOwnProperty(e)&&ke[e]?(``+t).trim():t+`px`}function Me(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=n.indexOf(`--`)===0,i=je(n,t[n],r);n===`float`&&(n=`cssFloat`),r?e.setProperty(n,i):e[n]=i}}var Ne=N({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 Pe(e,t){if(t){if(Ne[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(r(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(r(60));if(typeof t.dangerouslySetInnerHTML!=`object`||!(`__html`in t.dangerouslySetInnerHTML))throw Error(r(61))}if(t.style!=null&&typeof t.style!=`object`)throw Error(r(62))}}function Fe(e,t){if(e.indexOf(`-`)===-1)return typeof t.is==`string`;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Ie=null;function Le(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Re=null,ze=null,Be=null;function Ve(e){if(e=Ri(e)){if(typeof Re!=`function`)throw Error(r(280));var t=e.stateNode;t&&(t=Bi(t),Re(e.stateNode,e.type,t))}}function He(e){ze?Be?Be.push(e):Be=[e]:ze=e}function Ue(){if(ze){var e=ze,t=Be;if(Be=ze=null,Ve(e),t)for(e=0;e>>=0,e===0?32:31-(V(e)/Et|0)|0}var Ot=64,kt=4194304;function At(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64: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 e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function jt(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,a=e.pingedLanes,o=n&268435455;if(o!==0){var s=o&~i;s===0?(a&=o,a!==0&&(r=At(a))):r=At(s)}else o=n&~i,o===0?a!==0&&(r=At(a)):r=At(o);if(r===0)return 0;if(t!==0&&t!==r&&(t&i)===0&&(i=r&-r,a=t&-t,i>=a||i===16&&a&4194240))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Lt(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Tt(t),e[t]=n}function Rt(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=W),er=` `,tr=!1;function nr(e,t){switch(e){case`keyup`:return Xn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function rr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ir=!1;function ar(e,t){switch(e){case`compositionend`:return rr(t);case`keypress`:return t.which===32?(tr=!0,er):null;case`textInput`:return e=t.data,e===er&&tr?null:e;default:return null}}function or(e,t){if(ir)return e===`compositionend`||!Zn&&nr(e,t)?(e=xn(),bn=yn=vn=null,ir=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Or(n)}}function Ar(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ar(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function jr(){for(var e=window,t=ge();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=ge(e.document)}return t}function Mr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}function Nr(e){var t=jr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ar(n.ownerDocument.documentElement,n)){if(r!==null&&Mr(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),`selectionStart`in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,a=Math.min(r.start,i);r=r.end===void 0?a:Math.min(r.end,i),!e.extend&&a>r&&(i=r,r=a,a=i),i=kr(n,a);var o=kr(n,r);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus==`function`&&n.focus(),n=0;n=document.documentMode,Fr=null,Ir=null,Lr=null,Rr=!1;function zr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Rr||Fr==null||Fr!==ge(r)||(r=Fr,`selectionStart`in r&&Mr(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}),Lr&&Dr(Lr,r)||(Lr=r,r=di(Ir,`onSelect`),0Hi||(e.current=Vi[Hi],Vi[Hi]=null,Hi--)}function Ui(e,t){Hi++,Vi[Hi]=e.current,e.current=t}var Wi={},Gi=G(Wi),Ki=G(!1),qi=Wi;function Ji(e,t){var n=e.type.contextTypes;if(!n)return Wi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},a;for(a in n)i[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Yi(e){return e=e.childContextTypes,e!=null}function Xi(){K(Ki),K(Gi)}function Zi(e,t,n){if(Gi.current!==Wi)throw Error(r(168));Ui(Gi,t),Ui(Ki,n)}function Qi(e,t,n){var i=e.stateNode;if(t=t.childContextTypes,typeof i.getChildContext!=`function`)return n;for(var a in i=i.getChildContext(),i)if(!(a in t))throw Error(r(108,ue(e)||`Unknown`,a));return N({},n,i)}function q(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Wi,qi=Gi.current,Ui(Gi,e),Ui(Ki,Ki.current),!0}function $i(e,t,n){var i=e.stateNode;if(!i)throw Error(r(169));n?(e=Qi(e,t,qi),i.__reactInternalMemoizedMergedChildContext=e,K(Ki),K(Gi),Ui(Gi,e)):K(Ki),Ui(Ki,n)}var ea=null,ta=!1,na=!1;function ra(e){ea===null?ea=[e]:ea.push(e)}function ia(e){ta=!0,ra(e)}function aa(){if(!na&&ea!==null){na=!0;var e=0,t=Bt;try{var n=ea;for(Bt=1;e>=o,i-=o,pa=1<<32-Tt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(r,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(r,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(r,d),xa&&ha(r,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),xa&&ha(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return xa&&ha(a,g),u}for(h=i(a,h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),xa&&ha(a,g),u}function _(e,r,i,o){if(typeof i==`object`&&i&&i.type===E&&i.key===null&&(i=i.props.children),typeof i==`object`&&i){switch(i.$$typeof){case w:a:{for(var c=i.key,l=r;l!==null;){if(l.key===c){if(c=i.type,c===E){if(l.tag===7){n(e,l.sibling),r=a(l,i.props.children),r.return=e,e=r;break a}}else if(l.elementType===c||typeof c==`object`&&c&&c.$$typeof===j&&Fa(c)===l.type){n(e,l.sibling),r=a(l,i.props),r.ref=Na(e,l,i),r.return=e,e=r;break a}n(e,l);break}t(e,l),l=l.sibling}i.type===E?(r=nu(i.props.children,e.mode,o,i.key),r.return=e,e=r):(o=tu(i.type,i.key,i.props,null,e.mode,o),o.ref=Na(e,r,i),o.return=e,e=o)}return s(e);case T:a:{for(l=i.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===i.containerInfo&&r.stateNode.implementation===i.implementation){n(e,r.sibling),r=a(r,i.children||[]),r.return=e,e=r;break a}n(e,r);break}t(e,r),r=r.sibling}r=au(i,e.mode,o),r.return=e,e=r}return s(e);case j:return l=i._init,_(e,r,l(i._payload),o)}if(be(i))return h(e,r,i,o);if(ae(i))return g(e,r,i,o);Pa(e,i)}return typeof i==`string`&&i!==``||typeof i==`number`?(i=``+i,r!==null&&r.tag===6?(n(e,r.sibling),r=a(r,i),r.return=e,e=r):(n(e,r),r=iu(i,e.mode,o),r.return=e,e=r),s(e)):n(e,r)}return _}var La=Ia(!0),Ra=Ia(!1),za=G(null),Ba=null,Va=null,Ha=null;function Ua(){Ha=Va=Ba=null}function Wa(e){var t=za.current;K(za),e._currentValue=t}function Ga(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ka(e,t){Ba=e,Ha=Va=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Is=!0),e.firstContext=null)}function qa(e){var t=e._currentValue;if(Ha!==e){if(e={context:e,memoizedValue:t,next:null},Va===null){if(Ba===null)throw Error(r(308));Va=e,Ba.dependencies={lanes:0,firstContext:e}}else Va=Va.next=e}return t}var Ja=null;function Ya(e){Ja===null?Ja=[e]:Ja.push(e)}function Xa(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Ya(t)):(n.next=i.next,i.next=n),t.interleaved=n,Za(e,r)}function Za(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Qa=!1;function $a(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function eo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function to(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function no(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Gc&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,Za(e,n)}return i=r.interleaved,i===null?(t.next=t,Ya(r)):(t.next=i.next,i.next=t),r.interleaved=t,Za(e,n)}function ro(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194240)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,zt(e,n)}}function io(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=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};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ao(e,t,n,r){var i=e.updateQueue;Qa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});a:{var m=e,h=s;switch(f=t,p=n,h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(p,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(p,d,f):m,f==null)break a;d=N({},d,f);break a;case 2:Qa=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=i.effects,f===null?i.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;f=s,s=f.next,f.next=null,i.lastBaseUpdate=f,i.shared.pending=null}}while(1);if(u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else a===null&&(i.shared.lanes=0);$c|=o,e.lanes=o,e.memoizedState=d}}function oo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=So.transition;So.transition={};try{e(!1),t()}finally{Bt=n,So.transition=r}}function ls(){return Io().memoizedState}function us(e,t,n){var r=vl(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},fs(e))ps(t,n);else if(n=Xa(e,t,n,r),n!==null){var i=_l();yl(n,e,r,i),ms(n,t,r)}}function ds(e,t,n){var r=vl(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(fs(e))ps(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Er(s,o)){var c=t.interleaved;c===null?(i.next=i,Ya(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}n=Xa(e,t,i,r),n!==null&&(i=_l(),yl(n,e,r,i),ms(n,t,r))}}function fs(e){var t=e.alternate;return e===wo||t!==null&&t===wo}function ps(e,t){Oo=Do=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ms(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,zt(e,n)}}var hs={readContext:qa,useCallback:jo,useContext:jo,useEffect:jo,useImperativeHandle:jo,useInsertionEffect:jo,useLayoutEffect:jo,useMemo:jo,useReducer:jo,useRef:jo,useState:jo,useDebugValue:jo,useDeferredValue:jo,useTransition:jo,useMutableSource:jo,useSyncExternalStore:jo,useId:jo,unstable_isNewReconciler:!1},gs={readContext:qa,useCallback:function(e,t){return Fo().memoizedState=[e,t===void 0?null:t],e},useContext:qa,useEffect:Qo,useImperativeHandle:function(e,t,n){return n=n==null?null:n.concat([e]),Xo(4194308,4,ns.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xo(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xo(4,2,e,t)},useMemo:function(e,t){var n=Fo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Fo();return t=n===void 0?t:n(t),r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=us.bind(null,wo,e),[r.memoizedState,e]},useRef:function(e){var t=Fo();return e={current:e},t.memoizedState=e},useState:qo,useDebugValue:is,useDeferredValue:function(e){return Fo().memoizedState=e},useTransition:function(){var e=qo(!1),t=e[0];return e=cs.bind(null,e[1]),Fo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var i=wo,a=Fo();if(xa){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Kc===null)throw Error(r(349));Co&30||Ho(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Qo(Wo.bind(null,i,o,e),[e]),i.flags|=2048,Jo(9,Uo.bind(null,i,o,n,t),void 0,null),n},useId:function(){var e=Fo(),t=Kc.identifierPrefix;if(xa){var n=ma,r=pa;n=(r&~(1<<32-Tt(r)-1)).toString(32)+n,t=`:`+t+`R`+n,n=ko++,0<\/script>`,e=e.removeChild(e.firstChild)):typeof i.is==`string`?e=c.createElement(n,{is:i.is}):(e=c.createElement(n),n===`select`&&(c=e,i.multiple?c.multiple=!0:i.size&&(c.size=i.size))):e=c.createElementNS(e,n),e[ji]=t,e[Mi]=i,oc(e,t,!1,!1),t.stateNode=e;a:{switch(c=Fe(n,i),n){case`dialog`:ii(`cancel`,e),ii(`close`,e),o=i;break;case`iframe`:case`object`:case`embed`:ii(`load`,e),o=i;break;case`video`:case`audio`:for(o=0;oal&&(t.flags|=128,i=!0,lc(s,!1),t.lanes=4194304)}}else{if(!i){if(e=vo(c),e!==null){if(t.flags|=128,i=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),lc(s,!0),s.tail===null&&s.tailMode===`hidden`&&!c.alternate&&!xa)return uc(t),null}else 2*ht()-s.renderingStartTime>al&&n!==1073741824&&(t.flags|=128,i=!0,lc(s,!1),t.lanes=4194304)}s.isBackwards?(c.sibling=t.child,t.child=c):(n=s.last,n===null?t.child=c:n.sibling=c,s.last=c)}return s.tail===null?(uc(t),null):(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=ht(),t.sibling=null,n=_o.current,Ui(_o,i?n&1|2:n&1),t);case 22:case 23:return kl(),i=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==i&&(t.flags|=8192),i&&t.mode&1?Yc&1073741824&&(uc(t),t.subtreeFlags&6&&(t.flags|=8192)):uc(t),null;case 24:return null;case 25:return null}throw Error(r(156,t.tag))}function fc(e,t){switch(va(t),t.tag){case 1:return Yi(t.type)&&Xi(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return mo(),K(Ki),K(Gi),bo(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return go(t),null;case 13:if(K(_o),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));Aa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return K(_o),null;case 4:return mo(),null;case 10:return Wa(t.type._context),null;case 22:case 23:return kl(),null;case 24:return null;default:return null}}var pc=!1,mc=!1,hc=typeof WeakSet==`function`?WeakSet:Set,J=null;function gc(e,t){var n=e.ref;if(n!==null){if(typeof n==`function`)try{n(null)}catch(n){Ul(e,t,n)}else n.current=null}}function _c(e,t,n){try{n()}catch(n){Ul(e,t,n)}}var vc=!1;function yc(e,t){if(yi=dn,e=jr(),Mr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var i=n.getSelection&&n.getSelection();if(i&&i.rangeCount!==0){n=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(bi={focusedElem:e,selectionRange:n},dn=!1,J=t;J!==null;)if(t=J,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,J=e;else for(;J!==null;){t=J;try{var h=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var g=h.memoizedProps,_=h.memoizedState,v=t.stateNode;v.__reactInternalSnapshotBeforeUpdate=v.getSnapshotBeforeUpdate(t.elementType===t.type?g:ys(t.type,g),_)}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent=``:y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(r(163))}}catch(e){Ul(t,t.return,e)}if(e=t.sibling,e!==null){e.return=t.return,J=e;break}J=t.return}return h=vc,vc=!1,h}function bc(e,t,n){var r=t.updateQueue;if(r=r===null?null:r.lastEffect,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var a=i.destroy;i.destroy=void 0,a!==void 0&&_c(t,n,a)}i=i.next}while(i!==r)}}function xc(e,t){if(t=t.updateQueue,t=t===null?null:t.lastEffect,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Sc(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t==`function`?t(e):t.current=e}}function Cc(e){var t=e.alternate;t!==null&&(e.alternate=null,Cc(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[ji],delete t[Mi],delete t[Pi],delete t[Fi],delete t[Ii])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function wc(e){return e.tag===5||e.tag===3||e.tag===4}function Tc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||wc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Ec(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=vi));else if(r!==4&&(e=e.child,e!==null))for(Ec(e,t,n),e=e.sibling;e!==null;)Ec(e,t,n),e=e.sibling}function Dc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Dc(e,t,n),e=e.sibling;e!==null;)Dc(e,t,n),e=e.sibling}var Oc=null,kc=!1;function Ac(e,t,n){for(n=n.child;n!==null;)jc(e,t,n),n=n.sibling}function jc(e,t,n){if(Ct&&typeof Ct.onCommitFiberUnmount==`function`)try{Ct.onCommitFiberUnmount(St,n)}catch{}switch(n.tag){case 5:mc||gc(n,t);case 6:var r=Oc,i=kc;Oc=null,Ac(e,t,n),Oc=r,kc=i,Oc!==null&&(kc?(e=Oc,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Oc.removeChild(n.stateNode));break;case 18:Oc!==null&&(kc?(e=Oc,n=n.stateNode,e.nodeType===8?Di(e.parentNode,n):e.nodeType===1&&Di(e,n),ln(e)):Di(Oc,n.stateNode));break;case 4:r=Oc,i=kc,Oc=n.stateNode.containerInfo,kc=!0,Ac(e,t,n),Oc=r,kc=i;break;case 0:case 11:case 14:case 15:if(!mc&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var a=i,o=a.destroy;a=a.tag,o!==void 0&&(a&2||a&4)&&_c(n,t,o),i=i.next}while(i!==r)}Ac(e,t,n);break;case 1:if(!mc&&(gc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(e){Ul(n,t,e)}Ac(e,t,n);break;case 21:Ac(e,t,n);break;case 22:n.mode&1?(mc=(r=mc)||n.memoizedState!==null,Ac(e,t,n),mc=r):Ac(e,t,n);break;default:Ac(e,t,n)}}function Mc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new hc),t.forEach(function(t){var r=ql.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))})}}function Nc(e,t){var n=t.deletions;if(n!==null)for(var i=0;ia&&(a=s),i&=~o}if(i=a,i=ht()-i,i=(120>i?120:480>i?480:1080>i?1080:1920>i?1920:3e3>i?3e3:4320>i?4320:1960*Vc(i/1960))-i,10e?16:e,dl===null)var i=!1;else{if(e=dl,dl=null,fl=0,Gc&6)throw Error(r(331));var a=Gc;for(Gc|=4,J=e.current;J!==null;){var o=J,s=o.child;if(J.flags&16){var c=o.deletions;if(c!==null){for(var l=0;lht()-il?Al(e,0):tl|=n),bl(e,t)}function Gl(e,t){t===0&&(e.mode&1?(t=kt,kt<<=1,!(kt&130023424)&&(kt=4194304)):t=1);var n=_l();e=Za(e,t),e!==null&&(Lt(e,t,n),bl(e,n))}function Kl(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gl(e,n)}function ql(e,t){var n=0;switch(e.tag){case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;default:throw Error(r(314))}i!==null&&i.delete(t),Gl(e,n)}var Jl=function(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps||Ki.current)Is=!0;else{if((e.lanes&n)===0&&!(t.flags&128))return Is=!1,ac(e,t,n);Is=!!(e.flags&131072)}}else Is=!1,xa&&t.flags&1048576&&ga(t,la,t.index);switch(t.lanes=0,t.tag){case 2:var i=t.type;rc(e,t),e=t.pendingProps;var a=Ji(t,Gi.current);Ka(t,n),a=No(null,t,i,e,a,n);var o=Po();return t.flags|=1,typeof a==`object`&&a&&typeof a.render==`function`&&a.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Yi(i)?(o=!0,q(t)):o=!1,t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,$a(t),a.updater=xs,t.stateNode=a,a._reactInternals=t,Ts(t,i,e,n),t=Gs(null,t,i,!0,o,n)):(t.tag=0,xa&&o&&_a(t),Ls(null,t,a,n),t=t.child),t;case 16:i=t.elementType;a:{switch(rc(e,t),e=t.pendingProps,a=i._init,i=a(i._payload),t.type=i,a=t.tag=$l(i),e=ys(i,e),a){case 0:t=Us(null,t,i,e,n);break a;case 1:t=Ws(null,t,i,e,n);break a;case 11:t=Rs(null,t,i,e,n);break a;case 14:t=zs(null,t,i,ys(i.type,e),n);break a}throw Error(r(306,i,``))}return t;case 0:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Us(e,t,i,a,n);case 1:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Ws(e,t,i,a,n);case 3:a:{if(Ks(t),e===null)throw Error(r(387));i=t.pendingProps,o=t.memoizedState,a=o.element,eo(e,t),ao(t,i,null,n);var s=t.memoizedState;if(i=s.element,o.isDehydrated){if(o={element:i,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){a=Es(Error(r(423)),t),t=qs(e,t,i,n,a);break a}if(i!==a){a=Es(Error(r(424)),t),t=qs(e,t,i,n,a);break a}for(ba=Oi(t.stateNode.containerInfo.firstChild),ya=t,xa=!0,Sa=null,n=Ra(t,null,i,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Aa(),i===a){t=ic(e,t,n);break a}Ls(e,t,i,n)}t=t.child}return t;case 5:return ho(t),e===null&&Ea(t),i=t.type,a=t.pendingProps,o=e===null?null:e.memoizedProps,s=a.children,xi(i,a)?s=null:o!==null&&xi(i,o)&&(t.flags|=32),Hs(e,t),Ls(e,t,s,n),t.child;case 6:return e===null&&Ea(t),null;case 13:return Xs(e,t,n);case 4:return po(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=La(t,null,i,n):Ls(e,t,i,n),t.child;case 11:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),Rs(e,t,i,a,n);case 7:return Ls(e,t,t.pendingProps,n),t.child;case 8:return Ls(e,t,t.pendingProps.children,n),t.child;case 12:return Ls(e,t,t.pendingProps.children,n),t.child;case 10:a:{if(i=t.type._context,a=t.pendingProps,o=t.memoizedProps,s=a.value,Ui(za,i._currentValue),i._currentValue=s,o!==null){if(Er(o.value,s)){if(o.children===a.children&&!Ki.current){t=ic(e,t,n);break a}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var c=o.dependencies;if(c!==null){s=o.child;for(var l=c.firstContext;l!==null;){if(l.context===i){if(o.tag===1){l=to(-1,n&-n),l.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?l.next=l:(l.next=d.next,d.next=l),u.pending=l}}o.lanes|=n,l=o.alternate,l!==null&&(l.lanes|=n),Ga(o.return,n,t),c.lanes|=n;break}l=l.next}}else if(o.tag===10)s=o.type===t.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(r(341));s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Ga(s,n,t),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===t){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}}Ls(e,t,a.children,n),t=t.child}return t;case 9:return a=t.type,i=t.pendingProps.children,Ka(t,n),a=qa(a),i=i(a),t.flags|=1,Ls(e,t,i,n),t.child;case 14:return i=t.type,a=ys(i,t.pendingProps),a=ys(i.type,a),zs(e,t,i,a,n);case 15:return Bs(e,t,t.type,t.pendingProps,n);case 17:return i=t.type,a=t.pendingProps,a=t.elementType===i?a:ys(i,a),rc(e,t),t.tag=1,Yi(i)?(e=!0,q(t)):e=!1,Ka(t,n),Cs(t,i,a),Ts(t,i,a,n),Gs(null,t,i,!0,e,n);case 19:return nc(e,t,n);case 22:return Vs(e,t,n)}throw Error(r(156,t.tag))};function Yl(e,t){return dt(e,t)}function Xl(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,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 Zl(e,t,n,r){return new Xl(e,t,n,r)}function Ql(e){return e=e.prototype,!(!e||!e.isReactComponent)}function $l(e){if(typeof e==`function`)return+!!Ql(e);if(e!=null){if(e=e.$$typeof,e===ee)return 11;if(e===re)return 14}return 2}function eu(e,t){var n=e.alternate;return n===null?(n=Zl(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function tu(e,t,n,i,a,o){var s=2;if(i=e,typeof e==`function`)Ql(e)&&(s=1);else if(typeof e==`string`)s=5;else a:switch(e){case E:return nu(n.children,a,o,t);case D:s=8,a|=8;break;case O:return e=Zl(12,n,t,a|2),e.elementType=O,e.lanes=o,e;case te:return e=Zl(13,n,t,a),e.elementType=te,e.lanes=o,e;case ne:return e=Zl(19,n,t,a),e.elementType=ne,e.lanes=o,e;case ie:return ru(n,a,o,t);default:if(typeof e==`object`&&e)switch(e.$$typeof){case k:s=10;break a;case A:s=9;break a;case ee:s=11;break a;case re:s=14;break a;case j:s=16,i=null;break a}throw Error(r(130,e==null?e:typeof e,``))}return t=Zl(s,n,t,a),t.elementType=e,t.type=i,t.lanes=o,t}function nu(e,t,n,r){return e=Zl(7,e,r,t),e.lanes=n,e}function ru(e,t,n,r){return e=Zl(22,e,r,t),e.elementType=ie,e.lanes=n,e.stateNode={isHidden:!1},e}function iu(e,t,n){return e=Zl(6,e,null,t),e.lanes=n,e}function au(e,t,n){return t=Zl(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function ou(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=It(0),this.expirationTimes=It(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=It(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function su(e,t,n,r,i,a,o,s,c){return e=new ou(e,t,n,s,c),t===1?(t=1,!0===a&&(t|=8)):t=0,a=Zl(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},$a(a),e}function cu(e,t,n){var r=3{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=p()})),h=o((e=>{var t=m();e.createRoot=t.createRoot,e.hydrateRoot=t.hydrateRoot})),g=c(u(),1),_=h();function v(){return``}function y(){return/^G-[A-Z0-9]+$/.test(v())}function b(){let e=window.gtag;typeof e==`function`&&y()&&e(`config`,v(),{send_page_view:!1})}function x(){window.gtag?.(`event`,`page_view`,{page_path:window.location.pathname,page_location:window.location.href}),window.plausible?.(`pageview`)}function S(){window.gtag?.(`event`,`permalink_view`),window.plausible?.(`Permalink View`)}function C(){window.gtag?.(`event`,`changelog_open`),window.plausible?.(`Changelog Open`)}function w(e){window.gtag?.(`event`,`changelog_vote`,{...e}),window.plausible?.(`Changelog Vote`,{props:{...e}})}function T(e){return e.charAt(0).toUpperCase()+e.slice(1)}function E(e,t){window.gtag?.(`event`,e,{...t}),window.plausible?.(T(e),{props:{...t}})}function D(e){E(`input`,e)}function O(e){E(`conversion`,e)}function k(e){E(`export`,{via:e.via,format:e.format,...e.pane===void 0?{}:{pane:e.pane},...e.direction===void 0?{}:{direction:e.direction}})}function A(e){E(`feedback`,e)}function ee(e){return new TextEncoder().encode(e).length}function te(e){return e<10240?`<10KB`:e<102400?`10-100KB`:e<1048576?`100KB-1MB`:`>1MB`}function ne(e){let t=2166136261;for(let n=0;n>>0).toString(36)}function re(e={}){let t=e.settleMs??2e3,n=e.minWindowMs??2e3,r=e.now??(()=>Date.now()),i=e.isValid??(()=>!0),a=null,o,s=null,c=0,l=null,u=0;function d(e){if(e.text.trim()===``)return!1;let t=ee(e.text),a=te(t),o=i(e.direction,e.text),d=`${e.direction}:${e.input}:${t}:${ne(e.text)}`,f=r();return d!==s&&(c===0||f-c>=n)&&(s=d,c=f,D({direction:e.direction,input:e.input,size:a,valid:o})),!o||d===l||u!==0&&f-u{o=void 0,a&&d(a)},t)}return{edit(e,t){a={direction:e,input:`paste`,text:t},f()},discrete(e,t,n){a={direction:e,input:t,text:n},f(),d(a)},cancel(){a=null,s=null,l=null,o&&=(clearTimeout(o),void 0)}}}var j=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),ie=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),M=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ae=e=>{let t=M(e);return t.charAt(0).toUpperCase()+t.slice(1)},N={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`},oe=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},P=(0,g.createContext)({}),se=()=>(0,g.useContext)(P),ce=(0,g.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=se()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,g.createElement)(`svg`,{ref:c,...N,width:t??l??N.width,height:t??l??N.height,stroke:e??f,strokeWidth:m,className:j(`lucide`,p,i),...!a&&!oe(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,g.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),F=(e,t)=>{let n=(0,g.forwardRef)(({className:n,...r},i)=>(0,g.createElement)(ce,{ref:i,iconNode:t,className:j(`lucide-${ie(ae(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ae(e),n},le=F(`arrow-left-right`,[[`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`}]]),ue=F(`braces`,[[`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`}]]),de=F(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),fe=F(`clipboard`,[[`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`}]]),pe=F(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),me=F(`columns-3`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),he=F(`copy`,[[`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`}]]),ge=F(`download`,[[`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`}]]),I=F(`file-up`,[[`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`}]]),L=F(`moon`,[[`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`}]]),_e=F(`redo-2`,[[`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`}]]),R=F(`rotate-ccw-clock`,[[`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`}]]),ve=F(`rotate-ccw`,[[`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`}]]),ye=F(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),be=F(`sparkles`,[[`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`}]]),xe=F(`sun`,[[`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`}]]),Se=F(`table`,[[`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`}]]),z=F(`thumbs-down`,[[`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`}]]),Ce=F(`thumbs-up`,[[`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`}]]),we=F(`trash`,[[`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`}]]),B=F(`undo-2`,[[`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`}]]),Te=F(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function Ee(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t{let t=Ne(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{let n=e.split(Oe);return n[0]===``&&n.length!==1&&n.shift(),Ae(n,t)||Me(e)},getConflictingClassGroupIds:(e,t)=>{let i=n[e]||[];return t&&r[e]?[...i,...r[e]]:i}}},Ae=(e,t)=>{if(e.length===0)return t.classGroupId;let n=e[0],r=t.nextPart.get(n),i=r?Ae(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;let a=e.join(Oe);return t.validators.find(({validator:e})=>e(a))?.classGroupId},je=/^\[(.+)\]$/,Me=e=>{if(je.test(e)){let t=je.exec(e)[1],n=t?.substring(0,t.indexOf(`:`));if(n)return`arbitrary..`+n}},Ne=e=>{let{theme:t,prefix:n}=e,r={nextPart:new Map,validators:[]};return Le(Object.entries(e.classGroups),n).forEach(([e,n])=>{Pe(n,r,e,t)}),r},Pe=(e,t,n,r)=>{e.forEach(e=>{if(typeof e==`string`){let r=e===``?t:Fe(t,e);r.classGroupId=n}else if(typeof e==`function`){if(Ie(e)){Pe(e(r),t,n,r);return}t.validators.push({validator:e,classGroupId:n})}else Object.entries(e).forEach(([e,i])=>{Pe(i,Fe(t,e),n,r)})})},Fe=(e,t)=>{let n=e;return t.split(Oe).forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},Ie=e=>e.isThemeGetter,Le=(e,t)=>t?e.map(([e,n])=>[e,n.map(e=>typeof e==`string`?t+e:typeof e==`object`?Object.fromEntries(Object.entries(e).map(([e,n])=>[t+e,n])):e)]):e,Re=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,r=new Map,i=(i,a)=>{n.set(i,a),t++,t>e&&(t=0,r=n,n=new Map)};return{get(e){let t=n.get(e);if(t!==void 0)return t;if((t=r.get(e))!==void 0)return i(e,t),t},set(e,t){n.has(e)?n.set(e,t):i(e,t)}}},ze=`!`,Be=e=>{let{separator:t,experimentalParseClassName:n}=e,r=t.length===1,i=t[0],a=t.length,o=e=>{let n=[],o=0,s=0,c;for(let l=0;ls?c-s:void 0}};return n?e=>n({className:e,parseClassName:o}):o},Ve=e=>{if(e.length<=1)return e;let t=[],n=[];return e.forEach(e=>{e[0]===`[`?(t.push(...n.sort(),e),n=[]):n.push(e)}),t.push(...n.sort()),t},He=e=>({cache:Re(e.cacheSize),parseClassName:Be(e),...ke(e)}),Ue=/\s+/,We=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i}=t,a=[],o=e.trim().split(Ue),s=``;for(let e=o.length-1;e>=0;--e){let t=o[e],{modifiers:c,hasImportantModifier:l,baseClassName:u,maybePostfixModifierPosition:d}=n(t),f=!!d,p=r(f?u.substring(0,d):u);if(!p){if(!f||(p=r(u),!p)){s=t+(s.length>0?` `+s:s);continue}f=!1}let m=Ve(c).join(`:`),h=l?m+ze:m,g=h+p;if(a.includes(g))continue;a.push(g);let _=i(p,f);for(let e=0;e<_.length;++e){let t=_[e];a.push(h+t)}s=t+(s.length>0?` `+s:s)}return s};function Ge(){let e=0,t,n,r=``;for(;e{if(typeof e==`string`)return e;let t,n=``;for(let r=0;rt(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)}function s(e){let t=r(e);if(t)return t;let a=We(e,n);return i(e,a),a}return function(){return a(Ge.apply(null,arguments))}}var Je=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},Ye=/^\[(?:([a-z-]+):)?(.+)\]$/i,Xe=/^\d+\/\d+$/,Ze=new Set([`px`,`full`,`screen`]),Qe=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,$e=/\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$/,et=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,tt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,rt=e=>at(e)||Ze.has(e)||Xe.test(e),it=e=>vt(e,`length`,yt),at=e=>!!e&&!Number.isNaN(Number(e)),ot=e=>vt(e,`number`,at),st=e=>!!e&&Number.isInteger(Number(e)),ct=e=>e.endsWith(`%`)&&at(e.slice(0,-1)),lt=e=>Ye.test(e),ut=e=>Qe.test(e),dt=new Set([`length`,`size`,`percentage`]),ft=e=>vt(e,dt,bt),pt=e=>vt(e,`position`,bt),mt=new Set([`image`,`url`]),ht=e=>vt(e,mt,St),gt=e=>vt(e,``,xt),_t=()=>!0,vt=(e,t,n)=>{let r=Ye.exec(e);return r?r[1]?typeof t==`string`?r[1]===t:t.has(r[1]):n(r[2]):!1},yt=e=>$e.test(e)&&!et.test(e),bt=()=>!1,xt=e=>tt.test(e),St=e=>nt.test(e),Ct=qe(()=>{let e=Je(`colors`),t=Je(`spacing`),n=Je(`blur`),r=Je(`brightness`),i=Je(`borderColor`),a=Je(`borderRadius`),o=Je(`borderSpacing`),s=Je(`borderWidth`),c=Je(`contrast`),l=Je(`grayscale`),u=Je(`hueRotate`),d=Je(`invert`),f=Je(`gap`),p=Je(`gradientColorStops`),m=Je(`gradientColorStopPositions`),h=Je(`inset`),g=Je(`margin`),_=Je(`opacity`),v=Je(`padding`),y=Je(`saturate`),b=Je(`scale`),x=Je(`sepia`),S=Je(`skew`),C=Je(`space`),w=Je(`translate`),T=()=>[`auto`,`contain`,`none`],E=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],D=()=>[`auto`,lt,t],O=()=>[lt,t],k=()=>[``,rt,it],A=()=>[`auto`,at,lt],ee=()=>[`bottom`,`center`,`left`,`left-bottom`,`left-top`,`right`,`right-bottom`,`right-top`,`top`],te=()=>[`solid`,`dashed`,`dotted`,`double`,`none`],ne=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],re=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`],j=()=>[``,`0`,lt],ie=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],M=()=>[at,lt];return{cacheSize:500,separator:`:`,theme:{colors:[_t],spacing:[rt,it],blur:[`none`,``,ut,lt],brightness:M(),borderColor:[e],borderRadius:[`none`,``,`full`,ut,lt],borderSpacing:O(),borderWidth:k(),contrast:M(),grayscale:j(),hueRotate:M(),invert:j(),gap:O(),gradientColorStops:[e],gradientColorStopPositions:[ct,it],inset:D(),margin:D(),opacity:M(),padding:O(),saturate:M(),scale:M(),sepia:j(),skew:M(),space:O(),translate:O()},classGroups:{aspect:[{aspect:[`auto`,`square`,`video`,lt]}],container:[`container`],columns:[{columns:[ut]}],"break-after":[{"break-after":ie()}],"break-before":[{"break-before":ie()}],"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(),lt]}],overflow:[{overflow:E()}],"overflow-x":[{"overflow-x":E()}],"overflow-y":[{"overflow-y":E()}],overscroll:[{overscroll:T()}],"overscroll-x":[{"overscroll-x":T()}],"overscroll-y":[{"overscroll-y":T()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:[h]}],"inset-x":[{"inset-x":[h]}],"inset-y":[{"inset-y":[h]}],start:[{start:[h]}],end:[{end:[h]}],top:[{top:[h]}],right:[{right:[h]}],bottom:[{bottom:[h]}],left:[{left:[h]}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[`auto`,st,lt]}],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`,lt]}],grow:[{grow:j()}],shrink:[{shrink:j()}],order:[{order:[`first`,`last`,`none`,st,lt]}],"grid-cols":[{"grid-cols":[_t]}],"col-start-end":[{col:[`auto`,{span:[`full`,st,lt]},lt]}],"col-start":[{"col-start":A()}],"col-end":[{"col-end":A()}],"grid-rows":[{"grid-rows":[_t]}],"row-start-end":[{row:[`auto`,{span:[st,lt]},lt]}],"row-start":[{"row-start":A()}],"row-end":[{"row-end":A()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":[`auto`,`min`,`max`,`fr`,lt]}],"auto-rows":[{"auto-rows":[`auto`,`min`,`max`,`fr`,lt]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:[`normal`,...re()]}],"justify-items":[{"justify-items":[`start`,`end`,`center`,`stretch`]}],"justify-self":[{"justify-self":[`auto`,`start`,`end`,`center`,`stretch`]}],"align-content":[{content:[`normal`,...re(),`baseline`]}],"align-items":[{items:[`start`,`end`,`center`,`baseline`,`stretch`]}],"align-self":[{self:[`auto`,`start`,`end`,`center`,`stretch`,`baseline`]}],"place-content":[{"place-content":[...re(),`baseline`]}],"place-items":[{"place-items":[`start`,`end`,`center`,`baseline`,`stretch`]}],"place-self":[{"place-self":[`auto`,`start`,`end`,`center`,`stretch`]}],p:[{p:[v]}],px:[{px:[v]}],py:[{py:[v]}],ps:[{ps:[v]}],pe:[{pe:[v]}],pt:[{pt:[v]}],pr:[{pr:[v]}],pb:[{pb:[v]}],pl:[{pl:[v]}],m:[{m:[g]}],mx:[{mx:[g]}],my:[{my:[g]}],ms:[{ms:[g]}],me:[{me:[g]}],mt:[{mt:[g]}],mr:[{mr:[g]}],mb:[{mb:[g]}],ml:[{ml:[g]}],"space-x":[{"space-x":[C]}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":[C]}],"space-y-reverse":[`space-y-reverse`],w:[{w:[`auto`,`min`,`max`,`fit`,`svw`,`lvw`,`dvw`,lt,t]}],"min-w":[{"min-w":[lt,t,`min`,`max`,`fit`]}],"max-w":[{"max-w":[lt,t,`none`,`full`,`min`,`max`,`fit`,`prose`,{screen:[ut]},ut]}],h:[{h:[lt,t,`auto`,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"min-h":[{"min-h":[lt,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],"max-h":[{"max-h":[lt,t,`min`,`max`,`fit`,`svh`,`lvh`,`dvh`]}],size:[{size:[lt,t,`auto`,`min`,`max`,`fit`]}],"font-size":[{text:[`base`,ut,it]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`,ot]}],"font-family":[{font:[_t]}],"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`,lt]}],"line-clamp":[{"line-clamp":[`none`,at,ot]}],leading:[{leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`,rt,lt]}],"list-image":[{"list-image":[`none`,lt]}],"list-style-type":[{list:[`none`,`disc`,`decimal`,lt]}],"list-style-position":[{list:[`inside`,`outside`]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[_]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[_]}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...te(),`wavy`]}],"text-decoration-thickness":[{decoration:[`auto`,`from-font`,rt,it]}],"underline-offset":[{"underline-offset":[`auto`,rt,lt]}],"text-decoration-color":[{decoration:[e]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:O()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,lt]}],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`,lt]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-opacity":[{"bg-opacity":[_]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:[...ee(),pt]}],"bg-repeat":[{bg:[`no-repeat`,{repeat:[``,`x`,`y`,`round`,`space`]}]}],"bg-size":[{bg:[`auto`,`cover`,`contain`,ft]}],"bg-image":[{bg:[`none`,{"gradient-to":[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},ht]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[m]}],"gradient-via-pos":[{via:[m]}],"gradient-to-pos":[{to:[m]}],"gradient-from":[{from:[p]}],"gradient-via":[{via:[p]}],"gradient-to":[{to:[p]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[s]}],"border-w-x":[{"border-x":[s]}],"border-w-y":[{"border-y":[s]}],"border-w-s":[{"border-s":[s]}],"border-w-e":[{"border-e":[s]}],"border-w-t":[{"border-t":[s]}],"border-w-r":[{"border-r":[s]}],"border-w-b":[{"border-b":[s]}],"border-w-l":[{"border-l":[s]}],"border-opacity":[{"border-opacity":[_]}],"border-style":[{border:[...te(),`hidden`]}],"divide-x":[{"divide-x":[s]}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":[s]}],"divide-y-reverse":[`divide-y-reverse`],"divide-opacity":[{"divide-opacity":[_]}],"divide-style":[{divide:te()}],"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:[``,...te()]}],"outline-offset":[{"outline-offset":[rt,lt]}],"outline-w":[{outline:[rt,it]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:k()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[_]}],"ring-offset-w":[{"ring-offset":[rt,it]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:[``,`inner`,`none`,ut,gt]}],"shadow-color":[{shadow:[_t]}],opacity:[{opacity:[_]}],"mix-blend":[{"mix-blend":[...ne(),`plus-lighter`,`plus-darker`]}],"bg-blend":[{"bg-blend":ne()}],filter:[{filter:[``,`none`]}],blur:[{blur:[n]}],brightness:[{brightness:[r]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":[``,`none`,ut,lt]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[u]}],invert:[{invert:[d]}],saturate:[{saturate:[y]}],sepia:[{sepia:[x]}],"backdrop-filter":[{"backdrop-filter":[``,`none`]}],"backdrop-blur":[{"backdrop-blur":[n]}],"backdrop-brightness":[{"backdrop-brightness":[r]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[u]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[_]}],"backdrop-saturate":[{"backdrop-saturate":[y]}],"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`,lt]}],duration:[{duration:M()}],ease:[{ease:[`linear`,`in`,`out`,`in-out`,lt]}],delay:[{delay:M()}],animate:[{animate:[`none`,`spin`,`ping`,`pulse`,`bounce`,lt]}],transform:[{transform:[``,`gpu`,`none`]}],scale:[{scale:[b]}],"scale-x":[{"scale-x":[b]}],"scale-y":[{"scale-y":[b]}],rotate:[{rotate:[st,lt]}],"translate-x":[{"translate-x":[w]}],"translate-y":[{"translate-y":[w]}],"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`,lt]}],accent:[{accent:[`auto`,e]}],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`,lt]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":[`none`,`auto`]}],resize:[{resize:[`none`,`y`,`x`,``]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"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`,lt]}],fill:[{fill:[e,`none`]}],"stroke-w":[{stroke:[rt,it,ot]}],stroke:[{stroke:[e,`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`]}}});function wt(...e){return Ct(De(e))}var Tt=o((e=>{var t=u(),n=Symbol.for(`react.element`),r=Symbol.for(`react.fragment`),i=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function s(e,t,r){var s,c={},l=null,u=null;for(s in r!==void 0&&(l=``+r),t.key!==void 0&&(l=``+t.key),t.ref!==void 0&&(u=t.ref),t)i.call(t,s)&&!o.hasOwnProperty(s)&&(c[s]=t[s]);if(e&&e.defaultProps)for(s in t=e.defaultProps,t)c[s]===void 0&&(c[s]=t[s]);return{$$typeof:n,type:e,key:l,ref:u,props:c,_owner:a.current}}e.Fragment=r,e.jsx=s,e.jsxs=s})),V=o(((e,t)=>{t.exports=Tt()}))();function Et(e){return e===`csv2json`?`CSV → JSON`:`JSON → CSV`}function Dt({flipped:e}){return(0,V.jsx)(le,{size:18,strokeWidth:2,"aria-hidden":`true`,className:wt(`transition-transform duration-300`,e&&`rotate-180`)})}function Ot({direction:e,onFlip:t}){return(0,V.jsxs)(`button`,{type:`button`,"data-testid":`divider-switch`,onClick:t,onMouseDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),title:`Switch direction (currently ${Et(e)})`,"aria-label":`Switch conversion direction (currently ${Et(e)})`,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:[(0,V.jsx)(Dt,{flipped:e===`json2csv`}),(0,V.jsx)(`span`,{"data-testid":`divider-switch-label`,children:Et(e)})]})}var kt=[{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.`}],At={"@context":`https://schema.org`,"@type":`FAQPage`,mainEntity:kt.map(e=>({"@type":`Question`,name:e.question,acceptedAnswer:{"@type":`Answer`,text:e.answer}}))};function jt(){let[e,t]=(0,g.useState)(!1),n=(0,g.useId)();return(0,V.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:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`faq-toggle`,"aria-expanded":e,"aria-controls":n,onClick:()=>t(e=>!e),className:`flex w-full cursor-pointer items-center gap-1.5 py-2 text-[12.5px] text-muted-foreground hover:text-foreground`,children:[(0,V.jsx)(`span`,{"aria-hidden":`true`,className:`w-3 text-center`,children:e?`▾`:`▸`}),`How it works & FAQ`]}),(0,V.jsx)(`div`,{id:n,"data-testid":`faq-content`,hidden:!e,className:`max-w-3xl pb-4 text-[13px] leading-relaxed text-muted-foreground`,children:kt.map(e=>(0,V.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,V.jsx)(`h2`,{className:`mb-0.5 text-[11px] font-semibold uppercase tracking-[0.1em] text-foreground`,children:e.question}),(0,V.jsx)(`p`,{children:e.answer})]},e.question))}),(0,V.jsx)(`script`,{type:`application/ld+json`,dangerouslySetInnerHTML:{__html:JSON.stringify(At)}})]})}var Mt=`https://github.com/FlatFilers/csvjson-app/discussions/163`;function Nt(){return(0,V.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:(0,V.jsxs)(`p`,{className:`text-center`,children:[`Enjoy a cleaner, simpler CSVJSON.`,` `,(0,V.jsx)(`a`,{"data-testid":`feedback-link`,href:Mt,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`}),`.`]})})}var Pt=`csvjson:feedback.v1`,Ft=[{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 It(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.clientId==`string`&&t.clientId.length<=64&&(t.vote===1||t.vote===-1)&&(typeof t.reasonCode==`string`||t.reasonCode===null)&&(typeof t.reasonText==`string`||t.reasonText===null)&&typeof t.pending==`boolean`}function Lt(){try{let e=window.localStorage.getItem(Pt);if(e===null)return null;let t=JSON.parse(e);return It(t)?t:null}catch{return null}}function Rt(e){try{window.localStorage.setItem(Pt,JSON.stringify(e))}catch{}}function zt(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=globalThis.crypto?.getRandomValues?.(new Uint8Array(16));if(e===void 0)throw Error(`no secure randomness available`);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}function Bt(e){let t=window.location.pathname;return e.vote===1?{clientId:e.clientId,vote:1,path:t}:{clientId:e.clientId,vote:-1,reasonCode:e.reasonCode,reasonText:e.reasonText,path:t}}async function Vt(e){try{return(await fetch(`/api/feedback`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Bt(e))})).ok?`ok`:`failed`}catch{return`failed`}}function H(e){return[`flex h-7 w-7 cursor-pointer items-center justify-center rounded-md transition-colors`,e?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`].join(` `)}function Ht(){let[e,t]=(0,g.useState)(Lt),[n,r]=(0,g.useState)(!1),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),f=(0,g.useRef)(null),p=(0,g.useRef)(0),m=(0,g.useCallback)((e,n)=>{let r={...e,pending:n===`failed`};Rt(r),t(r),n===`ok`?A({vote:e.vote,with_reason:e.reasonCode!==null}):l(!1)},[]),h=(0,g.useCallback)((e,t)=>{let n=++p.current;t&&d(!0),Vt(e).then(t=>{p.current===n&&(m(e,t),t===`ok`&&l(!0))}).finally(()=>{t&&p.current===n&&d(!1)})},[m]),_=e=>{let n={...e,pending:!0};Rt(n),t(n),h(n,!0)},v=(0,g.useRef)(!1);return(0,g.useEffect)(()=>{if(v.current)return;v.current=!0;let e=Lt();e?.pending&&h(e,!1)},[h]),(0,g.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>l(!1),3e3);return()=>clearTimeout(e)},[c]),(0,g.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r(!1)},t=e=>{let t=f.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||r(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[n]),(0,V.jsxs)(`div`,{"data-testid":`feedback-vote`,ref:f,className:`relative flex items-center gap-1 max-sm:static`,children:[(0,V.jsx)(`button`,{type:`button`,"data-testid":`feedback-up`,onClick:()=>{e?.vote===1&&!e.pending?l(!0):_({clientId:e?.clientId??zt(),vote:1,reasonCode:null,reasonText:null})},"aria-pressed":e?.vote===1,"aria-label":`Helpful — send an upvote`,title:`Helpful`,className:H(e?.vote===1),children:(0,V.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:[(0,V.jsx)(`path`,{d:`M7 10v12`}),(0,V.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`})]})}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`feedback-down`,onClick:()=>{n?r(!1):(a(null),s(``),r(!0))},"aria-pressed":e?.vote===-1,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-label":`Not helpful — send a downvote`,title:`Not helpful`,className:H(e?.vote===-1),children:(0,V.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:[(0,V.jsx)(`path`,{d:`M17 14V2`}),(0,V.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`})]})}),c&&(0,V.jsx)(`span`,{"data-testid":`feedback-thanks`,className:`text-xs text-muted-foreground`,children:`Thanks for the feedback!`}),e?.pending&&!u&&(0,V.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&&(0,V.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:[(0,V.jsx)(`p`,{className:`mb-2 text-xs font-medium text-foreground`,children:`What went wrong?`}),(0,V.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1.5`,children:Ft.map(e=>(0,V.jsx)(`button`,{type:`button`,"data-testid":`feedback-reason-${e.value}`,"aria-pressed":i===e.value,onClick:()=>a(e.value),className:[`cursor-pointer rounded-sm border px-2 py-0.5 text-xs transition-colors`,i===e.value?`border-foreground bg-foreground text-panel`:`border-border text-muted-foreground hover:border-foreground hover:text-foreground`].join(` `),children:e.label},e.value))}),(0,V.jsx)(`textarea`,{"data-testid":`feedback-text`,value:o,maxLength:500,rows:2,onChange:e=>s(e.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`}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:[o.length,`/500`]}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`feedback-submit`,onClick:()=>{if(i===null)return;let t=o.trim();_({clientId:e?.clientId??zt(),vote:-1,reasonCode:i,reasonText:t===``?null:t}),r(!1)},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 Ut(e=`This should not happen`){throw Error(e)}function Wt(e,t=`Assertion failed`){if(!e)return Ut(t)}function Gt(e,t){return Ut(t??`Hell froze over`)}function Kt(e,t){try{return e()}catch{return t}}var qt=Object.prototype.hasOwnProperty;function Jt(e,t){let n,r;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((r=e.length)===t.length)for(;r--&&Jt(e[r],t[r]););return r===-1}if(!n||typeof e==`object`){for(n in r=0,e)if(qt.call(e,n)&&++r&&!qt.call(t,n)||!(n in t)||!Jt(e[n],t[n]))return!1;return Object.keys(t).length===r}}return e!==e&&t!==t}var Yt=o(((e,t)=>{var n=Object.prototype.hasOwnProperty;function r(e,t){return e!=null&&n.call(e,t)}t.exports=r})),Xt=o(((e,t)=>{t.exports=Array.isArray})),U=o(((e,t)=>{t.exports=typeof global==`object`&&global&&global.Object===Object&&global})),Zt=o(((e,t)=>{var n=U(),r=typeof self==`object`&&self&&self.Object===Object&&self;t.exports=n||r||Function(`return this`)()})),Qt=o(((e,t)=>{t.exports=Zt().Symbol})),$t=o(((e,t)=>{var n=Qt(),r=Object.prototype,i=r.hasOwnProperty,a=r.toString,o=n?n.toStringTag:void 0;function s(e){var t=i.call(e,o),n=e[o];try{e[o]=void 0;var r=!0}catch{}var s=a.call(e);return r&&(t?e[o]=n:delete e[o]),s}t.exports=s})),en=o(((e,t)=>{var n=Object.prototype.toString;function r(e){return n.call(e)}t.exports=r})),tn=o(((e,t)=>{var n=Qt(),r=$t(),i=en(),a=`[object Null]`,o=`[object Undefined]`,s=n?n.toStringTag:void 0;function c(e){return e==null?e===void 0?o:a:s&&s in Object(e)?r(e):i(e)}t.exports=c})),nn=o(((e,t)=>{function n(e){return typeof e==`object`&&!!e}t.exports=n})),rn=o(((e,t)=>{var n=tn(),r=nn(),i=`[object Symbol]`;function a(e){return typeof e==`symbol`||r(e)&&n(e)==i}t.exports=a})),an=o(((e,t)=>{var n=Xt(),r=rn(),i=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;function o(e,t){if(n(e))return!1;var o=typeof e;return o==`number`||o==`symbol`||o==`boolean`||e==null||r(e)?!0:a.test(e)||!i.test(e)||t!=null&&e in Object(t)}t.exports=o})),on=o(((e,t)=>{function n(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}t.exports=n})),sn=o(((e,t)=>{var n=tn(),r=on(),i=`[object AsyncFunction]`,a=`[object Function]`,o=`[object GeneratorFunction]`,s=`[object Proxy]`;function c(e){if(!r(e))return!1;var t=n(e);return t==a||t==o||t==i||t==s}t.exports=c})),cn=o(((e,t)=>{t.exports=Zt()[`__core-js_shared__`]})),ln=o(((e,t)=>{var n=cn(),r=function(){var e=/[^.]+$/.exec(n&&n.keys&&n.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function i(e){return!!r&&r in e}t.exports=i})),un=o(((e,t)=>{var n=Function.prototype.toString;function r(e){if(e!=null){try{return n.call(e)}catch{}try{return e+``}catch{}}return``}t.exports=r})),dn=o(((e,t)=>{var n=sn(),r=ln(),i=on(),a=un(),o=/[\\^$.*+?()[\]{}|]/g,s=/^\[object .+?Constructor\]$/,c=Function.prototype,l=Object.prototype,u=c.toString,d=l.hasOwnProperty,f=RegExp(`^`+u.call(d).replace(o,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function p(e){return!i(e)||r(e)?!1:(n(e)?f:s).test(a(e))}t.exports=p})),fn=o(((e,t)=>{function n(e,t){return e?.[t]}t.exports=n})),pn=o(((e,t)=>{var n=dn(),r=fn();function i(e,t){var i=r(e,t);return n(i)?i:void 0}t.exports=i})),mn=o(((e,t)=>{t.exports=pn()(Object,`create`)})),hn=o(((e,t)=>{var n=mn();function r(){this.__data__=n?n(null):{},this.size=0}t.exports=r})),gn=o(((e,t)=>{function n(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}t.exports=n})),_n=o(((e,t)=>{var n=mn(),r=`__lodash_hash_undefined__`,i=Object.prototype.hasOwnProperty;function a(e){var t=this.__data__;if(n){var a=t[e];return a===r?void 0:a}return i.call(t,e)?t[e]:void 0}t.exports=a})),vn=o(((e,t)=>{var n=mn(),r=Object.prototype.hasOwnProperty;function i(e){var t=this.__data__;return n?t[e]!==void 0:r.call(t,e)}t.exports=i})),yn=o(((e,t)=>{var n=mn(),r=`__lodash_hash_undefined__`;function i(e,t){var i=this.__data__;return this.size+=+!this.has(e),i[e]=n&&t===void 0?r:t,this}t.exports=i})),bn=o(((e,t)=>{var n=hn(),r=gn(),i=_n(),a=vn(),o=yn();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{function n(){this.__data__=[],this.size=0}t.exports=n})),Sn=o(((e,t)=>{function n(e,t){return e===t||e!==e&&t!==t}t.exports=n})),Cn=o(((e,t)=>{var n=Sn();function r(e,t){for(var r=e.length;r--;)if(n(e[r][0],t))return r;return-1}t.exports=r})),wn=o(((e,t)=>{var n=Cn(),r=Array.prototype.splice;function i(e){var t=this.__data__,i=n(t,e);return i<0?!1:(i==t.length-1?t.pop():r.call(t,i,1),--this.size,!0)}t.exports=i})),Tn=o(((e,t)=>{var n=Cn();function r(e){var t=this.__data__,r=n(t,e);return r<0?void 0:t[r][1]}t.exports=r})),En=o(((e,t)=>{var n=Cn();function r(e){return n(this.__data__,e)>-1}t.exports=r})),Dn=o(((e,t)=>{var n=Cn();function r(e,t){var r=this.__data__,i=n(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this}t.exports=r})),On=o(((e,t)=>{var n=xn(),r=wn(),i=Tn(),a=En(),o=Dn();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{t.exports=pn()(Zt(),`Map`)})),An=o(((e,t)=>{var n=bn(),r=On(),i=kn();function a(){this.size=0,this.__data__={hash:new n,map:new(i||r),string:new n}}t.exports=a})),jn=o(((e,t)=>{function n(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}t.exports=n})),Mn=o(((e,t)=>{var n=jn();function r(e,t){var r=e.__data__;return n(t)?r[typeof t==`string`?`string`:`hash`]:r.map}t.exports=r})),Nn=o(((e,t)=>{var n=Mn();function r(e){var t=n(this,e).delete(e);return this.size-=+!!t,t}t.exports=r})),Pn=o(((e,t)=>{var n=Mn();function r(e){return n(this,e).get(e)}t.exports=r})),Fn=o(((e,t)=>{var n=Mn();function r(e){return n(this,e).has(e)}t.exports=r})),In=o(((e,t)=>{var n=Mn();function r(e,t){var r=n(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this}t.exports=r})),Ln=o(((e,t)=>{var n=An(),r=Nn(),i=Pn(),a=Fn(),o=In();function s(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t{var n=Ln(),r=`Expected a function`;function i(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(r);var a=function(){var n=arguments,r=t?t.apply(this,n):n[0],i=a.cache;if(i.has(r))return i.get(r);var o=e.apply(this,n);return a.cache=i.set(r,o)||i,o};return a.cache=new(i.Cache||n),a}i.Cache=n,t.exports=i})),zn=o(((e,t)=>{var n=Rn(),r=500;function i(e){var t=n(e,function(e){return i.size===r&&i.clear(),e}),i=t.cache;return t}t.exports=i})),Bn=o(((e,t)=>{var n=zn(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,i=/\\(\\)?/g;t.exports=n(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(r,function(e,n,r,a){t.push(r?a.replace(i,`$1`):n||e)}),t})})),Vn=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n{var n=Qt(),r=Vn(),i=Xt(),a=rn(),o=1/0,s=n?n.prototype:void 0,c=s?s.toString:void 0;function l(e){if(typeof e==`string`)return e;if(i(e))return r(e,l)+``;if(a(e))return c?c.call(e):``;var t=e+``;return t==`0`&&1/e==-o?`-0`:t}t.exports=l})),Un=o(((e,t)=>{var n=Hn();function r(e){return e==null?``:n(e)}t.exports=r})),Wn=o(((e,t)=>{var n=Xt(),r=an(),i=Bn(),a=Un();function o(e,t){return n(e)?e:r(e,t)?[e]:i(a(e))}t.exports=o})),Gn=o(((e,t)=>{var n=tn(),r=nn(),i=`[object Arguments]`;function a(e){return r(e)&&n(e)==i}t.exports=a})),Kn=o(((e,t)=>{var n=Gn(),r=nn(),i=Object.prototype,a=i.hasOwnProperty,o=i.propertyIsEnumerable;t.exports=n(function(){return arguments}())?n:function(e){return r(e)&&a.call(e,`callee`)&&!o.call(e,`callee`)}})),qn=o(((e,t)=>{var n=/^(?:0|[1-9]\d*)$/;function r(e,t){var r=typeof e;return t??=9007199254740991,!!t&&(r==`number`||r!=`symbol`&&n.test(e))&&e>-1&&e%1==0&&e{function n(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=9007199254740991}t.exports=n})),Yn=o(((e,t)=>{var n=rn(),r=1/0;function i(e){if(typeof e==`string`||n(e))return e;var t=e+``;return t==`0`&&1/e==-r?`-0`:t}t.exports=i})),Xn=o(((e,t)=>{var n=Wn(),r=Kn(),i=Xt(),a=qn(),o=Jn(),s=Yn();function c(e,t,c){t=n(t,e);for(var l=-1,u=t.length,d=!1;++l{var n=Yt(),r=Xn();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i}))(),1),W;(function(e){e.Uri=`uri`,e.Text=`text`,e.Image=`image`,e.RowID=`row-id`,e.Number=`number`,e.Bubble=`bubble`,e.Boolean=`boolean`,e.Loading=`loading`,e.Markdown=`markdown`,e.Drilldown=`drilldown`,e.Protected=`protected`,e.Custom=`custom`})(W||={});var Qn;(function(e){e.HeaderRowID=`headerRowID`,e.HeaderCode=`headerCode`,e.HeaderNumber=`headerNumber`,e.HeaderString=`headerString`,e.HeaderBoolean=`headerBoolean`,e.HeaderAudioUri=`headerAudioUri`,e.HeaderVideoUri=`headerVideoUri`,e.HeaderEmoji=`headerEmoji`,e.HeaderImage=`headerImage`,e.HeaderUri=`headerUri`,e.HeaderPhone=`headerPhone`,e.HeaderMarkdown=`headerMarkdown`,e.HeaderDate=`headerDate`,e.HeaderTime=`headerTime`,e.HeaderEmail=`headerEmail`,e.HeaderReference=`headerReference`,e.HeaderIfThenElse=`headerIfThenElse`,e.HeaderSingleValue=`headerSingleValue`,e.HeaderLookup=`headerLookup`,e.HeaderTextTemplate=`headerTextTemplate`,e.HeaderMath=`headerMath`,e.HeaderRollup=`headerRollup`,e.HeaderJoinStrings=`headerJoinStrings`,e.HeaderSplitString=`headerSplitString`,e.HeaderGeoDistance=`headerGeoDistance`,e.HeaderArray=`headerArray`,e.RowOwnerOverlay=`rowOwnerOverlay`,e.ProtectedColumnOverlay=`protectedColumnOverlay`})(Qn||={});var $n;(function(e){e.Triangle=`triangle`,e.Dots=`dots`})($n||={});function er(e){return`width`in e&&typeof e.width==`number`}async function tr(e){return typeof e==`object`?e:await e()}function nr(e){return e.kind!==W.Loading&&e.kind!==W.Bubble&&e.kind!==W.RowID&&e.kind!==W.Protected&&e.kind!==W.Drilldown}function rr(e){return e.kind===sr.Marker||e.kind===sr.NewRow}function ir(e){if(!nr(e)||e.kind===W.Image)return!1;if(e.kind===W.Text||e.kind===W.Number||e.kind===W.Markdown||e.kind===W.Uri||e.kind===W.Custom||e.kind===W.Boolean)return e.readonly!==!0;Gt(e,`A cell was passed with an invalid kind`)}function ar(e){return(0,Zn.default)(e,`editor`)}function or(e){return!(e.readonly??!1)}var sr;(function(e){e.NewRow=`new-row`,e.Marker=`marker`})(sr||={});function cr(e){if(e.length===0)return[];let t=[...e],n=[];t.sort(function(e,t){return e[0]-t[0]}),n.push([...t[0]]);for(let e of t.slice(1)){let t=n[n.length-1];t[1]lr??=new e([]);static fromSingleSelection=t=>e.empty().add(t);offset(t){if(t===0)return this;let n=this.items.map(e=>[e[0]+t,e[1]+t]);return new e(n)}add(t){let n=typeof t==`number`?[t,t+1]:t,r=cr([...this.items,n]);return new e(r)}remove(t){let n=[...this.items],r=typeof t==`number`?t:t[0],i=typeof t==`number`?t+1:t[1];for(let[e,t]of n.entries()){let[a,o]=t;if(a<=i&&r<=o){let t=[];a=n&&e{(e?e.split(` `):[]).forEach(e=>{if(e.startsWith(`atm_`)){let[,n]=e.split(`_`);t[n]=e}else n.push(e)})});let r=[];for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.push(t[e]);return r.push(...n),r.join(` `)},hr=e=>e.toUpperCase()===e,gr=e=>t=>e.indexOf(t)===-1,_r=(e,t)=>{let n={};return Object.keys(e).filter(gr(t)).forEach(t=>{n[t]=e[t]}),n};function vr(e,t,n){let r=_r(t,n);if(!e){let e=typeof pr==`function`?{default:pr}:pr;Object.keys(r).forEach(t=>{e.default(t)||delete r[t]})}return r}function yr(e){return t=>{let n=(n,r)=>{let{as:i=e,class:a=``}=n,o=vr(t.propsAsIs===void 0?!(typeof i==`string`&&i.indexOf(`-`)===-1&&!hr(i[0])):t.propsAsIs,n,[`as`,`class`]);o.ref=r,o.className=t.atomic?mr(t.class,o.className||a):mr(o.className||a,t.class);let{vars:s}=t;if(s){let e={};for(let r in s){let i=s[r],a=i[0],o=i[1]||``,c=typeof a==`function`?a(n):a;t.name,e[`--${r}`]=`${c}${o}`}let r=o.style||{},i=Object.keys(r);i.length>0&&i.forEach(t=>{e[t]=r[t]}),o.style=e}return e.__linaria&&e!==i?(o.as=i,g.createElement(e,o)):g.createElement(i,o)},r=g.forwardRef?g.forwardRef(n):e=>{let t=_r(e,[`innerRef`]);return n(t,e.innerRef)};return r.displayName=t.name,r.__linaria={className:t.class||``,extends:e},r}}var br=yr,xr=br(`div`)({name:`ImageOverlayEditorStyle`,class:`gdg-i2iowwq`,propsAsIs:!1}),Sr=o(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Cr=o(((e,t)=>{var n=Sr();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=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 s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),wr=o(((e,t)=>{t.exports=Cr()()})),Tr=o(((e,t,n)=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`react`,`prop-types`],n);else if(e!==void 0)n(e,u(),wr());else{var r={exports:{}};n(r.exports,t.react,t.propTypes),t.reactSwipe=r.exports}})(n,function(e,t,n){Object.defineProperty(e,"__esModule",{value:!0}),e.setHasSupportToCaptureOption=p;var r=a(t),i=a(n);function a(e){return e&&e.__esModule?e:{default:e}}var o=Object.assign||function(e){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function c(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var l=function(){function e(e,t){for(var n=0;n0&&arguments[0]!==void 0?arguments[0]:{capture:!0};return f?e:e.capture}function h(e){if(`touches`in e){var t=e.touches[0];return{x:t.pageX,y:t.pageY}}return{x:e.screenX,y:e.screenY}}var g=function(e){d(t,e);function t(){var e;c(this,t);var n=[...arguments],r=u(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(n)));return r._handleSwipeStart=r._handleSwipeStart.bind(r),r._handleSwipeMove=r._handleSwipeMove.bind(r),r._handleSwipeEnd=r._handleSwipeEnd.bind(r),r._onMouseDown=r._onMouseDown.bind(r),r._onMouseMove=r._onMouseMove.bind(r),r._onMouseUp=r._onMouseUp.bind(r),r._setSwiperRef=r._setSwiperRef.bind(r),r}return l(t,[{key:`componentDidMount`,value:function(){this.swiper&&this.swiper.addEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`componentWillUnmount`,value:function(){this.swiper&&this.swiper.removeEventListener(`touchmove`,this._handleSwipeMove,m({capture:!0,passive:!1}))}},{key:`_onMouseDown`,value:function(e){this.props.allowMouseEvents&&(this.mouseDown=!0,document.addEventListener(`mouseup`,this._onMouseUp),document.addEventListener(`mousemove`,this._onMouseMove),this._handleSwipeStart(e))}},{key:`_onMouseMove`,value:function(e){this.mouseDown&&this._handleSwipeMove(e)}},{key:`_onMouseUp`,value:function(e){this.mouseDown=!1,document.removeEventListener(`mouseup`,this._onMouseUp),document.removeEventListener(`mousemove`,this._onMouseMove),this._handleSwipeEnd(e)}},{key:`_handleSwipeStart`,value:function(e){var t=h(e),n=t.x,r=t.y;this.moveStart={x:n,y:r},this.props.onSwipeStart(e)}},{key:`_handleSwipeMove`,value:function(e){if(this.moveStart){var t=h(e),n=t.x,r=t.y,i=n-this.moveStart.x,a=r-this.moveStart.y;this.moving=!0,this.props.onSwipeMove({x:i,y:a},e)&&e.cancelable&&e.preventDefault(),this.movePosition={deltaX:i,deltaY:a}}}},{key:`_handleSwipeEnd`,value:function(e){this.props.onSwipeEnd(e);var t=this.props.tolerance;this.moving&&this.movePosition&&(this.movePosition.deltaX<-t?this.props.onSwipeLeft(1,e):this.movePosition.deltaX>t&&this.props.onSwipeRight(1,e),this.movePosition.deltaY<-t?this.props.onSwipeUp(1,e):this.movePosition.deltaY>t&&this.props.onSwipeDown(1,e)),this.moveStart=null,this.moving=!1,this.movePosition=null}},{key:`_setSwiperRef`,value:function(e){this.swiper=e,this.props.innerRef(e)}},{key:`render`,value:function(){var e=this.props;e.tagName;var t=e.className,n=e.style,i=e.children;e.allowMouseEvents,e.onSwipeUp,e.onSwipeDown,e.onSwipeLeft,e.onSwipeRight,e.onSwipeStart,e.onSwipeMove,e.onSwipeEnd,e.innerRef,e.tolerance;var a=s(e,[`tagName`,`className`,`style`,`children`,`allowMouseEvents`,`onSwipeUp`,`onSwipeDown`,`onSwipeLeft`,`onSwipeRight`,`onSwipeStart`,`onSwipeMove`,`onSwipeEnd`,`innerRef`,`tolerance`]);return r.default.createElement(this.props.tagName,o({ref:this._setSwiperRef,onMouseDown:this._onMouseDown,onTouchStart:this._handleSwipeStart,onTouchEnd:this._handleSwipeEnd,className:t,style:n},a),i)}}]),t}(t.Component);g.displayName=`ReactSwipe`,g.propTypes={tagName:i.default.string,className:i.default.string,style:i.default.object,children:i.default.node,allowMouseEvents:i.default.bool,onSwipeUp:i.default.func,onSwipeDown:i.default.func,onSwipeLeft:i.default.func,onSwipeRight:i.default.func,onSwipeStart:i.default.func,onSwipeMove:i.default.func,onSwipeEnd:i.default.func,innerRef:i.default.func,tolerance:i.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})})),Er=o(((e,t,n)=>{(function(t,n){if(typeof define==`function`&&define.amd)define([`exports`,`./react-swipe`],n);else if(e!==void 0)n(e,Tr());else{var r={exports:{}};n(r.exports,t.reactSwipe),t.index=r.exports}})(n,function(e,t){Object.defineProperty(e,"__esModule",{value:!0});var n=r(t);function r(e){return e&&e.__esModule?e:{default:e}}e.default=n.default})})),Dr=o(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=n(Dr());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}e.default={ROOT:function(e){return(0,t.default)(r({"carousel-root":!0},e||``,!!e))},CAROUSEL:function(e){return(0,t.default)({carousel:!0,"carousel-slider":e})},WRAPPER:function(e,n){return(0,t.default)({"thumbs-wrapper":!e,"slider-wrapper":e,"axis-horizontal":n===`horizontal`,"axis-vertical":n!==`horizontal`})},SLIDER:function(e,n){return(0,t.default)({thumbs:!e,slider:e,animated:!n})},ITEM:function(e,n,r){return(0,t.default)({thumb:!e,slide:e,selected:n,previous:r})},ARROW_PREV:function(e){return(0,t.default)({"control-arrow control-prev":!0,"control-disabled":e})},ARROW_NEXT:function(e){return(0,t.default)({"control-arrow control-next":!0,"control-disabled":e})},DOT:function(e){return(0,t.default)({dot:!0,selected:e})}}})),kr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.outerWidth=void 0,e.outerWidth=function(e){var t=e.offsetWidth,n=getComputedStyle(e);return t+=parseInt(n.marginLeft)+parseInt(n.marginRight),t}})),Ar=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(e,t,n){var r=e===0?e:e+t;return`translate3d`+(`(`+(n===`horizontal`?[r,0,0]:[0,r,0]).join(`,`)+`)`)}})),jr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return window}})),Mr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=l(u()),n=s(Or()),r=kr(),i=s(Ar()),a=s(Er()),o=s(jr());function s(e){return e&&e.__esModule?e:{default:e}}function c(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){if(e&&e.__esModule)return e;if(e===null||d(e)!==`object`&&typeof e!=`function`)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(){return f=Object.assign||function(e){for(var t=1;t`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 S(e){return S=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},S(e)}function C(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var w=function(e){return e.hasOwnProperty(`key`)},T=function(e){g(c,e);var s=v(c);function c(e){var n;return p(this,c),n=s.call(this,e),C(b(n),`itemsWrapperRef`,void 0),C(b(n),`itemsListRef`,void 0),C(b(n),`thumbsRef`,void 0),C(b(n),`setItemsWrapperRef`,function(e){n.itemsWrapperRef=e}),C(b(n),`setItemsListRef`,function(e){n.itemsListRef=e}),C(b(n),`setThumbsRef`,function(e,t){n.thumbsRef||(n.thumbsRef=[]),n.thumbsRef[t]=e}),C(b(n),`updateSizes`,function(){if(n.props.children&&n.itemsWrapperRef&&n.thumbsRef){var e=t.Children.count(n.props.children),i=n.itemsWrapperRef.clientWidth,a=n.props.thumbWidth?n.props.thumbWidth:(0,r.outerWidth)(n.thumbsRef[0]),o=Math.floor(i/a),s=o0&&(r=0),s===c&&r<0&&(r=0);var l=s+100/(n.itemsWrapperRef.clientWidth/r);return n.itemsListRef&&[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(e){n.itemsListRef.style[e]=(0,i.default)(l,`%`,n.props.axis)}),!0}),C(b(n),`slideRight`,function(e){n.moveTo(n.state.firstItem-(typeof e==`number`?e:1))}),C(b(n),`slideLeft`,function(e){n.moveTo(n.state.firstItem+(typeof e==`number`?e:1))}),C(b(n),`moveTo`,function(e){e=e<0?0:e,e=e>=n.state.lastPosition?n.state.lastPosition:e,n.setState({firstItem:e})}),n.state={selectedItem:e.selectedItem,swiping:!1,showArrows:!1,firstItem:0,visibleItems:0,lastPosition:0},n}return h(c,[{key:`componentDidMount`,value:function(){this.setupThumbs()}},{key:`componentDidUpdate`,value:function(e){this.props.selectedItem!==this.state.selectedItem&&this.setState({selectedItem:this.props.selectedItem,firstItem:this.getFirstItem(this.props.selectedItem)}),this.props.children!==e.children&&this.updateSizes()}},{key:`componentWillUnmount`,value:function(){this.destroyThumbs()}},{key:`setupThumbs`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.updateSizes()}},{key:`destroyThumbs`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes)}},{key:`getFirstItem`,value:function(e){var t=e;return e>=this.state.lastPosition&&(t=this.state.lastPosition),e1,o=this.state.showArrows&&this.state.firstItem>0,s=this.state.showArrows&&this.state.firstItem{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0,e.default=function(){return document}})),Pr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.setPosition=e.getPosition=e.isKeyboardEvent=e.defaultStatusFormatter=e.noop=void 0;var t=u(),n=r(Ar());function r(e){return e&&e.__esModule?e:{default:e}}e.noop=function(){},e.defaultStatusFormatter=function(e,t){return`${e} of ${t}`},e.isKeyboardEvent=function(e){return e?e.hasOwnProperty(`key`):!1},e.getPosition=function(e,n){if(n.infiniteLoop&&++e,e===0)return 0;var r=t.Children.count(n.children);if(n.centerMode&&n.axis===`horizontal`){var i=-e*n.centerSlidePercentage,a=r-1;return e&&(e!==a||n.infiniteLoop)?i+=(100-n.centerSlidePercentage)/2:e===a&&(i+=100-n.centerSlidePercentage),i}return-e*100},e.setPosition=function(e,t){var r={};return[`WebkitTransform`,`MozTransform`,`MsTransform`,`OTransform`,`transform`,`msTransform`].forEach(function(i){r[i]=(0,n.default)(e,`%`,t)}),r}})),Fr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.fadeAnimationHandler=e.slideStopSwipingHandler=e.slideSwipeAnimationHandler=e.slideAnimationHandler=void 0;var t=u(),n=i(Ar()),r=Pr();function i(e){return e&&e.__esModule?e:{default:e}}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function o(e){for(var t=1;tl))return c<0?a.itemListStyle=e.centerMode&&e.centerSlidePercentage&&e.axis===`horizontal`?(0,r.setPosition)(-(l+2)*e.centerSlidePercentage-(100-e.centerSlidePercentage)/2,e.axis):(0,r.setPosition)(-(l+2)*100,e.axis):c>l&&(a.itemListStyle=(0,r.setPosition)(0,e.axis)),a;var u=(0,r.getPosition)(s,e),d=(0,n.default)(u,`%`,e.axis),f=e.transitionTime+`ms`;return a.itemListStyle={WebkitTransform:d,msTransform:d,OTransform:d,transform:d},i.swiping||(a.itemListStyle=o(o({},a.itemListStyle),{},{WebkitTransitionDuration:f,MozTransitionDuration:f,OTransitionDuration:f,transitionDuration:f,msTransitionDuration:f})),a},e.slideSwipeAnimationHandler=function(e,n,i,a){var o={},s=n.axis===`horizontal`,c=t.Children.count(n.children),l=0,u=(0,r.getPosition)(i.selectedItem,n),d=n.infiniteLoop?(0,r.getPosition)(c-1,n)-100:(0,r.getPosition)(c-1,n),f=s?e.x:e.y,p=f;u===l&&f>0&&(p=0),u===d&&f<0&&(p=0);var m=u+100/(i.itemSize/p),h=Math.abs(f)>n.swipeScrollTolerance;return n.infiniteLoop&&h&&(i.selectedItem===0&&m>-100?m-=c*100:i.selectedItem===c-1&&m<-c*100&&(m+=c*100)),(!n.preventMovementUntilSwipeScrollTolerance||h||i.swipeMovementStarted)&&(i.swipeMovementStarted||a({swipeMovementStarted:!0}),o.itemListStyle=(0,r.setPosition)(m,n.axis)),h&&!i.cancelClick&&a({cancelClick:!0}),o},e.slideStopSwipingHandler=function(e,t){var n=(0,r.getPosition)(t.selectedItem,e);return{itemListStyle:(0,r.setPosition)(n,e.axis)}},e.fadeAnimationHandler=function(e,t){var n=e.transitionTime+`ms`,r=`ease-in-out`,i={position:`absolute`,display:`block`,zIndex:-2,minHeight:`100%`,opacity:0,top:0,right:0,left:0,bottom:0,transitionTimingFunction:r,msTransitionTimingFunction:r,MozTransitionTimingFunction:r,WebkitTransitionTimingFunction:r,OTransitionTimingFunction:r};return t.swiping||(i=o(o({},i),{},{WebkitTransitionDuration:n,MozTransitionDuration:n,OTransitionDuration:n,transitionDuration:n,msTransitionDuration:n})),{slideStyle:i,selectedStyle:o(o({},i),{},{opacity:1,position:`relative`}),prevStyle:o({},i)}}})),Ir=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=f(u()),n=l(Er()),r=l(Or()),i=l(Mr()),a=l(Nr()),o=l(jr()),s=Pr(),c=Fr();function l(e){return e&&e.__esModule?e:{default:e}}function d(){if(typeof WeakMap!=`function`)return null;var e=new WeakMap;return d=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(e===null||p(e)!==`object`&&typeof e!=`function`)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var a=r?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(n,i,a):n[i]=e[i]}return n.default=e,t&&t.set(e,n),n}function p(e){"@babel/helpers - typeof";return p=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},p(e)}function m(){return m=Object.assign||function(e){for(var t=1;t`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 E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function D(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var O=function(e){b(u,e);var l=S(u);function u(e){var n;_(this,u),n=l.call(this,e),D(w(n),`thumbsRef`,void 0),D(w(n),`carouselWrapperRef`,void 0),D(w(n),`listRef`,void 0),D(w(n),`itemsRef`,void 0),D(w(n),`timer`,void 0),D(w(n),`animationHandler`,void 0),D(w(n),`setThumbsRef`,function(e){n.thumbsRef=e}),D(w(n),`setCarouselWrapperRef`,function(e){n.carouselWrapperRef=e}),D(w(n),`setListRef`,function(e){n.listRef=e}),D(w(n),`setItemsRef`,function(e,t){n.itemsRef||(n.itemsRef=[]),n.itemsRef[t]=e}),D(w(n),`autoPlay`,function(){t.Children.count(n.props.children)<=1||(n.clearAutoPlay(),n.props.autoPlay&&(n.timer=setTimeout(function(){n.increment()},n.props.interval)))}),D(w(n),`clearAutoPlay`,function(){n.timer&&clearTimeout(n.timer)}),D(w(n),`resetAutoPlay`,function(){n.clearAutoPlay(),n.autoPlay()}),D(w(n),`stopOnHover`,function(){n.setState({isMouseEntered:!0},n.clearAutoPlay)}),D(w(n),`startOnLeave`,function(){n.setState({isMouseEntered:!1},n.autoPlay)}),D(w(n),`isFocusWithinTheCarousel`,function(){return n.carouselWrapperRef?!!((0,a.default)().activeElement===n.carouselWrapperRef||n.carouselWrapperRef.contains((0,a.default)().activeElement)):!1}),D(w(n),`navigateWithKeyboard`,function(e){if(n.isFocusWithinTheCarousel()){var t=n.props.axis===`horizontal`,r={ArrowUp:38,ArrowRight:39,ArrowDown:40,ArrowLeft:37},i=t?r.ArrowRight:r.ArrowDown,a=t?r.ArrowLeft:r.ArrowUp;i===e.keyCode?n.increment():a===e.keyCode&&n.decrement()}}),D(w(n),`updateSizes`,function(){if(n.state.initialized&&n.itemsRef&&n.itemsRef.length!==0){var e=n.props.axis===`horizontal`,t=n.itemsRef[0];if(t){var r=e?t.clientWidth:t.clientHeight;n.setState({itemSize:r}),n.thumbsRef&&n.thumbsRef.updateSizes()}}}),D(w(n),`setMountState`,function(){n.setState({hasMount:!0}),n.updateSizes()}),D(w(n),`handleClickItem`,function(e,r){t.Children.count(n.props.children)!==0&&(n.state.cancelClick?n.setState({cancelClick:!1}):(n.props.onClickItem(e,r),e!==n.state.selectedItem&&n.setState({selectedItem:e})))}),D(w(n),`handleOnChange`,function(e,r){t.Children.count(n.props.children)<=1||n.props.onChange(e,r)}),D(w(n),`handleClickThumb`,function(e,t){n.props.onClickThumb(e,t),n.moveTo(e)}),D(w(n),`onSwipeStart`,function(e){n.setState({swiping:!0}),n.props.onSwipeStart(e)}),D(w(n),`onSwipeEnd`,function(e){n.setState({swiping:!1,cancelClick:!1,swipeMovementStarted:!1}),n.props.onSwipeEnd(e),n.clearAutoPlay(),n.state.autoPlay&&n.autoPlay()}),D(w(n),`onSwipeMove`,function(e,t){n.props.onSwipeMove(t);var r=n.props.swipeAnimationHandler(e,n.props,n.state,n.setState.bind(w(n)));return n.setState(g({},r)),!!Object.keys(r).length}),D(w(n),`decrement`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem-(typeof e==`number`?e:1))}),D(w(n),`increment`,function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1;n.moveTo(n.state.selectedItem+(typeof e==`number`?e:1))}),D(w(n),`moveTo`,function(e){if(typeof e==`number`){var r=t.Children.count(n.props.children)-1;e<0&&(e=n.props.infiniteLoop?r:0),e>r&&(e=n.props.infiniteLoop?0:r),n.selectItem({selectedItem:e}),n.state.autoPlay&&n.state.isMouseEntered===!1&&n.resetAutoPlay()}}),D(w(n),`onClickNext`,function(){n.increment(1)}),D(w(n),`onClickPrev`,function(){n.decrement(1)}),D(w(n),`onSwipeForward`,function(){n.increment(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`onSwipeBackwards`,function(){n.decrement(1),n.props.emulateTouch&&n.setState({cancelClick:!0})}),D(w(n),`changeItem`,function(e){return function(t){(0,s.isKeyboardEvent)(t)&&t.key!==`Enter`||n.moveTo(e)}}),D(w(n),`selectItem`,function(e){n.setState(g({previousItem:n.state.selectedItem},e),function(){n.setState(n.animationHandler(n.props,n.state))}),n.handleOnChange(e.selectedItem,t.Children.toArray(n.props.children)[e.selectedItem])}),D(w(n),`getInitialImage`,function(){var e=n.props.selectedItem,t=n.itemsRef&&n.itemsRef[e];return(t&&t.getElementsByTagName(`img`)||[])[0]}),D(w(n),`getVariableItemHeight`,function(e){var t=n.itemsRef&&n.itemsRef[e];if(n.state.hasMount&&t&&t.children.length){var r=t.children[0].getElementsByTagName(`img`)||[];if(r.length>0){var i=r[0];i.complete||i.addEventListener(`load`,function e(){n.forceUpdate(),i.removeEventListener(`load`,e)})}var a=(r[0]||t.children[0]).clientHeight;return a>0?a:null}return null});var r={initialized:!1,previousItem:e.selectedItem,selectedItem:e.selectedItem,hasMount:!1,isMouseEntered:!1,autoPlay:e.autoPlay,swiping:!1,swipeMovementStarted:!1,cancelClick:!1,itemSize:1,itemListStyle:{},slideStyle:{},selectedStyle:{},prevStyle:{}};return n.animationHandler=typeof e.animationHandler==`function`&&e.animationHandler||e.animationHandler===`fade`&&c.fadeAnimationHandler||c.slideAnimationHandler,n.state=g(g({},r),n.animationHandler(e,r)),n}return y(u,[{key:`componentDidMount`,value:function(){this.props.children&&this.setupCarousel()}},{key:`componentDidUpdate`,value:function(e,t){!e.children&&this.props.children&&!this.state.initialized&&this.setupCarousel(),!e.autoFocus&&this.props.autoFocus&&this.forceFocus(),t.swiping&&!this.state.swiping&&this.setState(g({},this.props.stopSwipingHandler(this.props,this.state))),(e.selectedItem!==this.props.selectedItem||e.centerMode!==this.props.centerMode)&&(this.updateSizes(),this.moveTo(this.props.selectedItem)),e.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 e=this;this.bindEvents(),this.state.autoPlay&&t.Children.count(this.props.children)>1&&this.setupAutoPlay(),this.props.autoFocus&&this.forceFocus(),this.setState({initialized:!0},function(){var t=e.getInitialImage();t&&!t.complete?t.addEventListener(`load`,e.setMountState):e.setMountState()})}},{key:`destroyCarousel`,value:function(){this.state.initialized&&(this.unbindEvents(),this.destroyAutoPlay())}},{key:`setupAutoPlay`,value:function(){this.autoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.addEventListener(`mouseenter`,this.stopOnHover),e.addEventListener(`mouseleave`,this.startOnLeave))}},{key:`destroyAutoPlay`,value:function(){this.clearAutoPlay();var e=this.carouselWrapperRef;this.props.stopOnHover&&e&&(e.removeEventListener(`mouseenter`,this.stopOnHover),e.removeEventListener(`mouseleave`,this.startOnLeave))}},{key:`bindEvents`,value:function(){(0,o.default)().addEventListener(`resize`,this.updateSizes),(0,o.default)().addEventListener(`DOMContentLoaded`,this.updateSizes),this.props.useKeyboardArrows&&(0,a.default)().addEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`unbindEvents`,value:function(){(0,o.default)().removeEventListener(`resize`,this.updateSizes),(0,o.default)().removeEventListener(`DOMContentLoaded`,this.updateSizes);var e=this.getInitialImage();e&&e.removeEventListener(`load`,this.setMountState),this.props.useKeyboardArrows&&(0,a.default)().removeEventListener(`keydown`,this.navigateWithKeyboard)}},{key:`forceFocus`,value:function(){var e;(e=this.carouselWrapperRef)==null||e.focus()}},{key:`renderItems`,value:function(e){var n=this;return this.props.children?t.Children.map(this.props.children,function(i,a){var o=a===n.state.selectedItem,s=a===n.state.previousItem,c=o&&n.state.selectedStyle||s&&n.state.prevStyle||n.state.slideStyle||{};n.props.centerMode&&n.props.axis===`horizontal`&&(c=g(g({},c),{},{minWidth:n.props.centerSlidePercentage+`%`})),n.state.swiping&&n.state.swipeMovementStarted&&(c=g(g({},c),{},{pointerEvents:`none`}));var l={ref:function(e){return n.setItemsRef(e,a)},key:`itemKey`+a+(e?`clone`:``),className:r.default.ITEM(!0,a===n.state.selectedItem,a===n.state.previousItem),onClick:n.handleClickItem.bind(n,a,i),style:c};return t.default.createElement(`li`,l,n.props.renderItem(i,{isSelected:a===n.state.selectedItem,isPrevious:a===n.state.previousItem}))}):[]}},{key:`renderControls`,value:function(){var e=this,n=this.props,r=n.showIndicators,i=n.labels,a=n.renderIndicator,o=n.children;return r?t.default.createElement(`ul`,{className:`control-dots`},t.Children.map(o,function(t,n){return a&&a(e.changeItem(n),n===e.state.selectedItem,n,i.item)})):null}},{key:`renderStatus`,value:function(){return this.props.showStatus?t.default.createElement(`p`,{className:`carousel-status`},this.props.statusFormatter(this.state.selectedItem+1,t.Children.count(this.props.children))):null}},{key:`renderThumbs`,value:function(){return!this.props.showThumbs||!this.props.children||t.Children.count(this.props.children)===0?null:t.default.createElement(i.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 e=this;if(!this.props.children||t.Children.count(this.props.children)===0)return null;var i=this.props.swipeable&&t.Children.count(this.props.children)>1,a=this.props.axis===`horizontal`,o=this.props.showArrows&&t.Children.count(this.props.children)>1,s=o&&(this.state.selectedItem>0||this.props.infiniteLoop)||!1,c=o&&(this.state.selectedItem{})),Rr=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"Carousel",{enumerable:!0,get:function(){return t.default}}),Object.defineProperty(e,"CarouselProps",{enumerable:!0,get:function(){return n.CarouselProps}}),Object.defineProperty(e,"Thumbs",{enumerable:!0,get:function(){return r.default}});var t=i(Ir()),n=Lr(),r=i(Mr());function i(e){return e&&e.__esModule?e:{default:e}}})),zr=o(((e,t)=>{var n=Zt();t.exports=function(){return n.Date.now()}})),Br=o(((e,t)=>{var n=/\s/;function r(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}t.exports=r})),Vr=o(((e,t)=>{var n=Br(),r=/^\s+/;function i(e){return e&&e.slice(0,n(e)+1).replace(r,``)}t.exports=i})),Hr=o(((e,t)=>{var n=Vr(),r=on(),i=rn(),a=NaN,o=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,c=/^0o[0-7]+$/i,l=parseInt;function u(e){if(typeof e==`number`)return e;if(i(e))return a;if(r(e)){var t=typeof e.valueOf==`function`?e.valueOf():e;e=r(t)?t+``:t}if(typeof e!=`string`)return e===0?e:+e;e=n(e);var u=s.test(e);return u||c.test(e)?l(e.slice(2),u?2:8):o.test(e)?a:+e}t.exports=u})),Ur=o(((e,t)=>{var n=on(),r=zr(),i=Hr(),a=`Expected a function`,o=Math.max,s=Math.min;function c(e,t,c){var l,u,d,f,p,m,h=0,g=!1,_=!1,v=!0;if(typeof e!=`function`)throw TypeError(a);t=i(t)||0,n(c)&&(g=!!c.leading,_=`maxWait`in c,d=_?o(i(c.maxWait)||0,t):d,v=`trailing`in c?!!c.trailing:v);function y(t){var n=l,r=u;return l=u=void 0,h=t,f=e.apply(r,n),f}function b(e){return h=e,p=setTimeout(C,t),g?y(e):f}function x(e){var n=e-m,r=e-h,i=t-n;return _?s(i,d-r):i}function S(e){var n=e-m,r=e-h;return m===void 0||n>=t||n<0||_&&r>=d}function C(){var e=r();if(S(e))return w(e);p=setTimeout(C,x(e))}function w(e){return p=void 0,v&&l?y(e):(l=u=void 0,f)}function T(){p!==void 0&&clearTimeout(p),h=0,l=m=u=p=void 0}function E(){return p===void 0?f:w(r())}function D(){var e=r(),n=S(e);if(l=arguments,u=this,m=e,n){if(p===void 0)return b(m);if(_)return clearTimeout(p),p=setTimeout(C,t),y(m)}return p===void 0&&(p=setTimeout(C,t)),f}return D.cancel=T,D.flush=E,D}t.exports=c})),Wr=c(Ur(),1);function Gr(e,t,n,r,i=!1){let a=g.useRef();a.current=t,g.useEffect(()=>{if(n===null||n.addEventListener===void 0)return;let t=n,o=e=>{a.current?.call(t,e)};return t.addEventListener(e,o,{passive:r,capture:i}),()=>{t.removeEventListener(e,o,{capture:i})}},[e,n,r,i])}function Kr(e,t){return e===void 0?void 0:t}var qr=Math.PI;function Jr(e){return e*qr/180}var Yr=(e,t,n)=>({x1:e-n/2,y1:t-n/2,x2:e+n/2,y2:t+n/2}),Xr=(e,t,n,r,i)=>{switch(e){case`left`:return Math.floor(t)+r+i/2;case`center`:return Math.floor(t+n/2);case`right`:return Math.floor(t+n)-r-i/2}},Zr=(e,t,n)=>Math.min(e,t-n*2),Qr=(e,t,n)=>n.x1<=e&&e<=n.x2&&n.y1<=t&&t<=n.y2,$r=e=>{let t=e.fgColor??`currentColor`;return g.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},g.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:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}),g.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:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,fill:`none`,vectorEffect:`non-scaling-stroke`}))},ei=e=>{let t=e.fgColor??`currentColor`;return g.createElement(`svg`,{viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`},g.createElement(`path`,{d:`M19 6L10.3802 17L5.34071 11.8758`,vectorEffect:`non-scaling-stroke`,stroke:t,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}))};function ti(e,t,n){let[r,i]=g.useState(e),a=g.useRef(!0);g.useEffect(()=>()=>{a.current=!1},[]);let o=g.useRef((0,Wr.default)(e=>{a.current&&i(e)},n));return g.useLayoutEffect(()=>{a.current&&o.current(()=>e())},t),r}var ni=RegExp(`^[^A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿]*[֑-߿יִ-﷽ﹰ-ﻼ]`);function ri(e){return ni.test(e)?`rtl`:`not-rtl`}var ii=void 0;function ai(){if(typeof document>`u`)return 0;if(ii!==void 0)return ii;let e=document.createElement(`p`);e.style.width=`100%`,e.style.height=`200px`;let t=document.createElement(`div`);t.id=`testScrollbar`,t.style.position=`absolute`,t.style.top=`0px`,t.style.left=`0px`,t.style.visibility=`hidden`,t.style.width=`200px`,t.style.height=`150px`,t.style.overflow=`hidden`,t.append(e),document.body.append(t);let n=e.offsetWidth;t.style.overflow=`scroll`;let r=e.offsetWidth;return n===r&&(r=t.clientWidth),t.remove(),ii=n-r,ii}var oi=Symbol();function si(e){let t=g.useRef([oi,e]);t.current[1]!==e&&(t.current[0]=e),t.current[1]=e;let[n,r]=g.useState(e),[,i]=g.useState(),a=g.useCallback(e=>{let n=t.current[0];n!==oi&&(e=typeof e==`function`?e(n):e,e===n)||(n!==oi&&i({}),r(t=>typeof e==`function`?e(n===oi?t:n):e),t.current[0]=oi)},[]),o=g.useCallback(()=>{t.current[0]=oi,i({})},[]);return[t.current[0]===oi?n:t.current[0],a,o]}function ci(e){if(e.length===0)return``;let t=0,n=0;for(let r of e){if(n+=r.length,n>1e4)break;t++}return e.slice(0,t).join(`, `)}function li(e){let t=g.useRef(e);return Jt(e,t.current)||(t.current=e),t.current}var ui=Rr(),di=e=>{let{urls:t,canWrite:n,onEditClick:r,renderImage:i}=e,a=t.filter(e=>e!==``);if(a.length===0)return null;let o=a.length>1;return g.createElement(xr,{"data-testid":`GDG-default-image-overlay-editor`},g.createElement(ui.Carousel,{showArrows:o,showThumbs:!1,swipeable:o,emulateTouch:o,infiniteLoop:o},a.map(e=>{let t=i?.(e)??g.createElement(`img`,{draggable:!1,src:e});return g.createElement(`div`,{className:`gdg-centering-container`,key:e},t)})),n&&r&&g.createElement(`button`,{className:`gdg-edit-icon`,onClick:r},g.createElement($r,null)))};function fi(){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}}var pi=fi();function mi(e){pi=e}var hi=/[&<>"']/,gi=new RegExp(hi.source,`g`),_i=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,vi=new RegExp(_i.source,`g`),yi={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},bi=e=>yi[e];function xi(e,t){if(t){if(hi.test(e))return e.replace(gi,bi)}else if(_i.test(e))return e.replace(vi,bi);return e}var Si=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function Ci(e){return e.replace(Si,(e,t)=>(t=t.toLowerCase(),t===`colon`?`:`:t.charAt(0)===`#`?t.charAt(1)===`x`?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):``))}var wi=/(^|[^\[])\^/g;function Ti(e,t){e=typeof e==`string`?e:e.source,t||=``;let n={replace:(t,r)=>(r=r.source||r,r=r.replace(wi,`$1`),e=e.replace(t,r),n),getRegex:()=>new RegExp(e,t)};return n}var Ei=/[^\w:]/g,Di=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Oi(e,t,n){if(e){let e;try{e=decodeURIComponent(Ci(n)).replace(Ei,``).toLowerCase()}catch{return null}if(e.indexOf(`javascript:`)===0||e.indexOf(`vbscript:`)===0||e.indexOf(`data:`)===0)return null}t&&!Di.test(n)&&(n=Ni(t,n));try{n=encodeURI(n).replace(/%25/g,`%`)}catch{return null}return n}var ki={},Ai=/^[^:]+:\/*[^/]*$/,ji=/^([^:]+:)[\s\S]*$/,Mi=/^([^:]+:\/*[^/]*)[\s\S]*$/;function Ni(e,t){ki[` `+e]||(Ai.test(e)?ki[` `+e]=e+`/`:ki[` `+e]=Ii(e,`/`,!0)),e=ki[` `+e];let n=e.indexOf(`:`)===-1;return t.substring(0,2)===`//`?n?t:e.replace(ji,`$1`)+t:t.charAt(0)===`/`?n?t:e.replace(Mi,`$1`)+t:e+t}var Pi={exec:function(){}};function Fi(e,t){let n=e.replace(/\|/g,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(/ \|/),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n[n.length-1].trim()&&n.pop(),n.length>t)n.splice(t);else for(;n.length1;)t&1&&(n+=e),t>>=1,e+=e;return n+e}function Bi(e,t,n,r){let i=t.href,a=t.title?xi(t.title):null,o=e[1].replace(/\\([\[\]])/g,`$1`);if(e[0].charAt(0)!==`!`){r.state.inLink=!0;let e={type:`link`,raw:n,href:i,title:a,text:o,tokens:r.inlineTokens(o)};return r.state.inLink=!1,e}return{type:`image`,raw:n,href:i,title:a,text:xi(o)}}function Vi(e,t){let n=e.match(/^(\s+)(?:```)/);if(n===null)return t;let r=n[1];return t.split(` -`).map(e=>{let t=e.match(/^\s+/);if(t===null)return e;let[n]=t;return n.length>=r.length?e.slice(r.length):e}).join(` -`)}var Hi=class{constructor(e){this.options=e||pi}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(/^ {1,4}/gm,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:Ii(e,` -`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=Vi(e,t[3]||``);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(/#$/.test(e)){let t=Ii(e,`#`);(this.options.pedantic||!t||/ $/.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:t[0]}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=t[0].replace(/^ *>[ \t]?/gm,``),n=this.lexer.state.top;this.lexer.state.top=!0;let r=this.lexer.blockTokens(e);return this.lexer.state.top=n,{type:`blockquote`,raw:t[0],tokens:r,text:e}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n,r,i,a,o,s,c,l,u,d,f,p,m=t[1].trim(),h=m.length>1,g={type:`list`,raw:``,ordered:h,start:h?+m.slice(0,-1):``,loose:!1,items:[]};m=h?`\\d{1,9}\\${m.slice(-1)}`:`\\${m}`,this.options.pedantic&&(m=h?m:`[*+-]`);let _=RegExp(`^( {0,3}${m})((?:[\t ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,(t=_.exec(e))&&!this.rules.block.hr.test(e));){if(n=t[0],e=e.substring(n.length),l=t[2].split(` -`,1)[0].replace(/^\t+/,e=>` `.repeat(3*e.length)),u=e.split(` -`,1)[0],this.options.pedantic?(a=2,f=l.trimLeft()):(a=t[2].search(/[^ ]/),a=a>4?1:a,f=l.slice(a),a+=t[1].length),s=!1,!l&&/^ *$/.test(u)&&(n+=u+` -`,e=e.substring(u.length+1),p=!0),!p){let t=RegExp(`^ {0,${Math.min(3,a-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),r=RegExp(`^ {0,${Math.min(3,a-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),i=RegExp(`^ {0,${Math.min(3,a-1)}}(?:\`\`\`|~~~)`),o=RegExp(`^ {0,${Math.min(3,a-1)}}#`);for(;e&&(d=e.split(` -`,1)[0],u=d,this.options.pedantic&&(u=u.replace(/^ {1,4}(?=( {4})*[^ ])/g,` `)),!(i.test(u)||o.test(u)||t.test(u)||r.test(e)));){if(u.search(/[^ ]/)>=a||!u.trim())f+=` -`+u.slice(a);else{if(s||l.search(/[^ ]/)>=4||i.test(l)||o.test(l)||r.test(l))break;f+=` -`+u}!s&&!u.trim()&&(s=!0),n+=d+` -`,e=e.substring(d.length+1),l=u.slice(a)}}g.loose||(c?g.loose=!0:/\n *\n *$/.test(n)&&(c=!0)),this.options.gfm&&(r=/^\[[ xX]\] /.exec(f),r&&(i=r[0]!==`[ ] `,f=f.replace(/^\[[ xX]\] +/,``))),g.items.push({type:`list_item`,raw:n,task:!!r,checked:i,loose:!1,text:f}),g.raw+=n}g.items[g.items.length-1].raw=n.trimRight(),g.items[g.items.length-1].text=f.trimRight(),g.raw=g.raw.trimRight();let v=g.items.length;for(o=0;oe.type===`space`);g.loose=e.length>0&&e.some(e=>/\n.*\n/.test(e.raw))}if(g.loose)for(o=0;o$/,`$1`).replace(this.rules.inline._escapes,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(t){let e={type:`table`,header:Fi(t[1]).map(e=>({text:e})),align:t[2].replace(/^ *|\| *$/g,``).split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,``).split(` -`):[]};if(e.header.length===e.align.length){e.raw=t[0];let n=e.align.length,r,i,a,o;for(r=0;r({text:e}));for(n=e.header.length,i=0;i/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?`text`:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):xi(t[0]):t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&/^$/.test(e))return;let t=Ii(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=Li(t[2],`()`);if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),/^$/.test(e)?n.slice(1):n.slice(1,-1)),Bi(t,{href:n&&n.replace(this.rules.inline._escapes,`$1`),title:r&&r.replace(this.rules.inline._escapes,`$1`)},t[0],this.lexer)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=(n[2]||n[1]).replace(/\s+/g,` `);if(e=t[e.toLowerCase()],!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return Bi(n,e,n[0],this.lexer)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrong.lDelim.exec(e);if(!r||r[3]&&n.match(/[\p{L}\p{N}]/u))return;let i=r[1]||r[2]||``;if(!i||i&&(n===``||this.rules.inline.punctuation.exec(n))){let n=r[0].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=i.length,r[3]||r[4]){o+=a;continue}if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=e.slice(0,n+r.index+(r[0].length-i.length)+a);if(Math.min(n,a)%2){let e=t.slice(1,-1);return{type:`em`,raw:t,text:e,tokens:this.lexer.inlineTokens(e)}}let c=t.slice(2,-2);return{type:`strong`,raw:t,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(/\n/g,` `),n=/[^ ]/.test(e),r=/^ /.test(e)&&/ $/.test(e);return n&&r&&(e=e.substring(1,e.length-1)),e=xi(e,!0),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){let n=this.rules.inline.autolink.exec(e);if(n){let e,r;return n[2]===`@`?(e=xi(this.options.mangle?t(n[1]):n[1]),r=`mailto:`+e):(e=xi(n[1]),r=e),{type:`link`,raw:n[0],text:e,href:r,tokens:[{type:`text`,raw:e,text:e}]}}}url(e,t){let n;if(n=this.rules.inline.url.exec(e)){let e,r;if(n[2]===`@`)e=xi(this.options.mangle?t(n[0]):n[0]),r=`mailto:`+e;else{let t;do t=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0];while(t!==n[0]);e=xi(n[0]),r=n[1]===`www.`?`http://`+n[0]:n[0]}return{type:`link`,raw:n[0],text:e,href:r,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e,t){let n=this.rules.inline.text.exec(e);if(n){let e;return e=this.lexer.state.inRawBlock?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(n[0]):xi(n[0]):n[0]:xi(this.options.smartypants?t(n[0]):n[0]),{type:`text`,raw:n[0],text:e}}}},G={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:Pi,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};G._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/,G._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/,G.def=Ti(G.def).replace(`label`,G._label).replace(`title`,G._title).getRegex(),G.bullet=/(?:[*+-]|\d{1,9}[.)])/,G.listItemStart=Ti(/^( *)(bull) */).replace(`bull`,G.bullet).getRegex(),G.list=Ti(G.list).replace(/bull/g,G.bullet).replace(`hr`,`\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))`).replace(`def`,`\\n+(?=`+G.def.source+`)`).getRegex(),G._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`,G._comment=/|$)/,G.html=Ti(G.html,`i`).replace(`comment`,G._comment).replace(`tag`,G._tag).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),G.paragraph=Ti(G._paragraph).replace(`hr`,G.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`,G._tag).getRegex(),G.blockquote=Ti(G.blockquote).replace(`paragraph`,G.paragraph).getRegex(),G.normal={...G},G.gfm={...G.normal,table:`^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`},G.gfm.table=Ti(G.gfm.table).replace(`hr`,G.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`,G._tag).getRegex(),G.gfm.paragraph=Ti(G._paragraph).replace(`hr`,G.hr).replace(`heading`,` {0,3}#{1,6} `).replace(`|lheading`,``).replace(`table`,G.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`,G._tag).getRegex(),G.pedantic={...G.normal,html:Ti(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,G._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:Pi,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Ti(G.normal._paragraph).replace(`hr`,G.hr).replace(`heading`,` *#{1,6} *[^ -]`).replace(`lheading`,G.lheading).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).getRegex()};var K={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Pi,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:Pi,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]\`^{|}~`,K.punctuation=Ti(K.punctuation).replace(/punctuation/g,K._punctuation).getRegex(),K.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,K.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g,K._comment=Ti(G._comment).replace(`(?:-->|$)`,`-->`).getRegex(),K.emStrong.lDelim=Ti(K.emStrong.lDelim).replace(/punct/g,K._punctuation).getRegex(),K.emStrong.rDelimAst=Ti(K.emStrong.rDelimAst,`g`).replace(/punct/g,K._punctuation).getRegex(),K.emStrong.rDelimUnd=Ti(K.emStrong.rDelimUnd,`g`).replace(/punct/g,K._punctuation).getRegex(),K._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,K._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,K._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])?)+(?![-_])/,K.autolink=Ti(K.autolink).replace(`scheme`,K._scheme).replace(`email`,K._email).getRegex(),K._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,K.tag=Ti(K.tag).replace(`comment`,K._comment).replace(`attribute`,K._attribute).getRegex(),K._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,K._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,K._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,K.link=Ti(K.link).replace(`label`,K._label).replace(`href`,K._href).replace(`title`,K._title).getRegex(),K.reflink=Ti(K.reflink).replace(`label`,K._label).replace(`ref`,G._label).getRegex(),K.nolink=Ti(K.nolink).replace(`ref`,G._label).getRegex(),K.reflinkSearch=Ti(K.reflinkSearch,`g`).replace(`reflink`,K.reflink).replace(`nolink`,K.nolink).getRegex(),K.normal={...K},K.pedantic={...K.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:Ti(/^!?\[(label)\]\((.*?)\)/).replace(`label`,K._label).getRegex(),reflink:Ti(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,K._label).getRegex()},K.gfm={...K.normal,escape:Ti(K.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)),t+=`&#`+r+`;`;return t}var Gi=class e{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||pi,this.options.tokenizer=this.options.tokenizer||new Hi,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={block:G.normal,inline:K.normal};this.options.pedantic?(t.block=G.pedantic,t.inline=K.pedantic):this.options.gfm&&(t.block=G.gfm,t.inline=this.options.breaks?K.breaks:K.gfm),this.tokenizer.rules=t}static get rules(){return{block:G,inline:K}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(/\r\n|\r/g,` -`),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){e=this.options.pedantic?e.replace(/\t/g,` `).replace(/^ +$/gm,``):e.replace(/^( *)(\t+)/gm,(e,t,n)=>t+` `.repeat(n.length));let n,r,i,a;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.space(e))e=e.substring(n.raw.length),n.raw.length===1&&t.length>0?t[t.length-1].raw+=` -`:t.push(n);else if(n=this.tokenizer.code(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&(r.type===`paragraph`||r.type===`text`)?(r.raw+=` -`+n.raw,r.text+=` -`+n.text,this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(n=this.tokenizer.fences(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.heading(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.hr(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.blockquote(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.list(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.html(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.def(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&(r.type===`paragraph`||r.type===`text`)?(r.raw+=` -`+n.raw,r.text+=` -`+n.raw,this.inlineQueue[this.inlineQueue.length-1].src=r.text):this.tokens.links[n.tag]||(this.tokens.links[n.tag]={href:n.href,title:n.title});else if(n=this.tokenizer.table(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.lheading(e))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(function(e){r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(n=this.tokenizer.paragraph(i)))r=t[t.length-1],a&&r.type===`paragraph`?(r.raw+=` -`+n.raw,r.text+=` -`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n),a=i.length!==e.length,e=e.substring(n.raw.length);else if(n=this.tokenizer.text(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&r.type===`text`?(r.raw+=` -`+n.raw,r.text+=` -`+n.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=r.text):t.push(n);else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,r,i,a=e,o,s,c;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(o=this.tokenizer.rules.inline.reflinkSearch.exec(a))!=null;)e.includes(o[0].slice(o[0].lastIndexOf(`[`)+1,-1))&&(a=a.slice(0,o.index)+`[`+zi(`a`,o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(o=this.tokenizer.rules.inline.blockSkip.exec(a))!=null;)a=a.slice(0,o.index)+`[`+zi(`a`,o[0].length-2)+`]`+a.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(o=this.tokenizer.rules.inline.escapedEmSt.exec(a))!=null;)a=a.slice(0,o.index+o[0].length-2)+`++`+a.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(s||(c=``),s=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(r=>(n=r.call({lexer:this},e,t))?(e=e.substring(n.raw.length),t.push(n),!0):!1))){if(n=this.tokenizer.escape(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.tag(e))e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.link(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.reflink(e,this.tokens.links))e=e.substring(n.raw.length),r=t[t.length-1],r&&n.type===`text`&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(n=this.tokenizer.emStrong(e,a,c))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.codespan(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.br(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.del(e))e=e.substring(n.raw.length),t.push(n);else if(n=this.tokenizer.autolink(e,Wi))e=e.substring(n.raw.length),t.push(n);else if(!this.state.inLink&&(n=this.tokenizer.url(e,Wi)))e=e.substring(n.raw.length),t.push(n);else{if(i=e,this.options.extensions&&this.options.extensions.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(function(e){r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(n=this.tokenizer.inlineText(i,Ui))e=e.substring(n.raw.length),n.raw.slice(-1)!==`_`&&(c=n.raw.slice(-1)),s=!0,r=t[t.length-1],r&&r.type===`text`?(r.raw+=n.raw,r.text+=n.text):t.push(n);else if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw Error(t)}}}return t}},Ki=class{constructor(e){this.options=e||pi}code(e,t,n){let r=(t||``).match(/\S*/)[0];if(this.options.highlight){let t=this.options.highlight(e,r);t!=null&&t!==e&&(n=!0,e=t)}return e=e.replace(/\n$/,``)+` -`,r?`
    `+(n?e:xi(e,!0))+`
    -`:`
    `+(n?e:xi(e,!0))+`
    -`}blockquote(e){return`
    \n${e}
    \n`}html(e){return e}heading(e,t,n,r){return this.options.headerIds?`${e}\n`:`${e}\n`}hr(){return this.options.xhtml?`
    -`:`
    -`}list(e,t,n){let r=t?`ol`:`ul`,i=t&&n!==1?` start="`+n+`"`:``;return`<`+r+i+`> -`+e+` -`}listitem(e){return`
  • ${e}
  • \n`}checkbox(e){return` `}paragraph(e){return`

    ${e}

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

    An error occurred:

    `+xi(r.message+``,!0)+`
    `;if(t)return Promise.resolve(e);if(n){n(null,e);return}return e}if(t)return Promise.reject(r);if(n)n(r);else throw r}}function Qi(e,t){return(n,r,i)=>{typeof r==`function`&&(i=r,r=null);let a={...r};r={...q.defaults,...a};let o=Zi(r.silent,r.async,i);if(n==null)return o(Error(`marked(): input parameter is undefined or null`));if(typeof n!=`string`)return o(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(n)+`, string expected`));if(Ri(r),r.hooks&&(r.hooks.options=r),i){let a=r.highlight,s;try{r.hooks&&(n=r.hooks.preprocess(n)),s=e(n,r)}catch(e){return o(e)}let c=function(e){let n;if(!e)try{r.walkTokens&&q.walkTokens(s,r.walkTokens),n=t(s,r),r.hooks&&(n=r.hooks.postprocess(n))}catch(t){e=t}return r.highlight=a,e?o(e):i(null,n)};if(!a||a.length<3||(delete r.highlight,!s.length))return c();let l=0;q.walkTokens(s,function(e){e.type===`code`&&(l++,setTimeout(()=>{a(e.text,e.lang,function(t,n){if(t)return c(t);n!=null&&n!==e.text&&(e.text=n,e.escaped=!0),l--,l===0&&c()})},0))}),l===0&&c()}else{if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(t=>e(t,r)).then(e=>r.walkTokens?Promise.all(q.walkTokens(e,r.walkTokens)).then(()=>e):e).then(e=>t(e,r)).then(e=>r.hooks?r.hooks.postprocess(e):e).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let i=e(n,r);r.walkTokens&&q.walkTokens(i,r.walkTokens);let a=t(i,r);return r.hooks&&(a=r.hooks.postprocess(a)),a}catch(e){return o(e)}}}}function q(e,t,n){return Qi(Gi.lex,Yi.parse)(e,t,n)}q.options=q.setOptions=function(e){return q.defaults={...q.defaults,...e},mi(q.defaults),q},q.getDefaults=fi,q.defaults=pi,q.use=function(...e){let t=q.defaults.extensions||{renderers:{},childTokens:{}};e.forEach(e=>{let n={...e};if(n.async=q.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(e.renderer){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(e.tokenizer){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);t[e.level]?t[e.level].unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=q.defaults.renderer||new Ki;for(let n in e.renderer){let r=t[n];t[n]=(...i)=>{let a=e.renderer[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.renderer=t}if(e.tokenizer){let t=q.defaults.tokenizer||new Hi;for(let n in e.tokenizer){let r=t[n];t[n]=(...i)=>{let a=e.tokenizer[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.tokenizer=t}if(e.hooks){let t=q.defaults.hooks||new Xi;for(let n in e.hooks){let r=t[n];t[n]=Xi.passThroughHooks.has(n)?i=>{if(q.defaults.async)return Promise.resolve(e.hooks[n].call(t,i)).then(e=>r.call(t,e));let a=e.hooks[n].call(t,i);return r.call(t,a)}:(...i)=>{let a=e.hooks[n].apply(t,i);return a===!1&&(a=r.apply(t,i)),a}}n.hooks=t}if(e.walkTokens){let t=q.defaults.walkTokens;n.walkTokens=function(n){let r=[];return r.push(e.walkTokens.call(this,n)),t&&(r=r.concat(t.call(this,n))),r}}q.setOptions(n)})},q.walkTokens=function(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(q,r)),r.type){case`table`:for(let e of r.header)n=n.concat(q.walkTokens(e.tokens,t));for(let e of r.rows)for(let r of e)n=n.concat(q.walkTokens(r.tokens,t));break;case`list`:n=n.concat(q.walkTokens(r.items,t));break;default:q.defaults.extensions&&q.defaults.extensions.childTokens&&q.defaults.extensions.childTokens[r.type]?q.defaults.extensions.childTokens[r.type].forEach(function(e){n=n.concat(q.walkTokens(r[e],t))}):r.tokens&&(n=n.concat(q.walkTokens(r.tokens,t)))}return n},q.parseInline=Qi(Gi.lexInline,Yi.parseInline),q.Parser=Yi,q.parser=Yi.parse,q.Renderer=Ki,q.TextRenderer=qi,q.Lexer=Gi,q.lexer=Gi.lex,q.Tokenizer=Hi,q.Slugger=Ji,q.Hooks=Xi,q.parse=q,q.options,q.setOptions,q.use,q.walkTokens,q.parseInline,Yi.parse,Gi.lex;var $i=br(`div`)({name:`MarkdownContainer`,class:`gdg-mnuv029`,propsAsIs:!1}),ea=class extends g.PureComponent{targetElement=null;renderMarkdownIntoDiv(){let{targetElement:e,props:t}=this;if(e===null)return;let{contents:n,createNode:r}=t,i=q(n),a=document.createRange();a.selectNodeContents(e),a.deleteContents();let o=r?.(i);if(o===void 0){let e=document.createElement(`template`);e.innerHTML=i,o=e.content}e.append(o);let s=e.getElementsByTagName(`a`);for(let e of s)e.target=`_blank`,e.rel=`noreferrer noopener`}containerRefHook=e=>{this.targetElement=e,this.renderMarkdownIntoDiv()};render(){return this.renderMarkdownIntoDiv(),g.createElement($i,{ref:this.containerRefHook})}},ta=br(`textarea`)({name:`InputBox`,class:`gdg-izpuzkl`,propsAsIs:!1}),na=br(`div`)({name:`ShadowBox`,class:`gdg-s69h75o`,propsAsIs:!1}),ra=br(`div`)({name:`GrowingEntryStyle`,class:`gdg-g1y0xocz`,propsAsIs:!1}),ia=0,aa=e=>{let{placeholder:t,value:n,onKeyDown:r,highlight:i,altNewline:a,validatedSelection:o,...s}=e,{onChange:c,className:l}=s,u=g.useRef(null),d=n??``;Wt(c!==void 0,`GrowingEntry must be a controlled input area`);let[f]=g.useState(()=>`input-box-`+(ia=(ia+1)%1e7));g.useEffect(()=>{let e=u.current;if(e===null||e.disabled)return;let t=d.toString().length;e.focus(),e.setSelectionRange(i?0:t,t)},[]),g.useLayoutEffect(()=>{if(o!==void 0){let e=typeof o==`number`?[o,null]:o;u.current?.setSelectionRange(e[0],e[1])}},[o]);let p=g.useCallback(e=>{e.key===`Enter`&&e.shiftKey&&a===!0||r?.(e)},[a,r]);return g.createElement(ra,{className:`gdg-growing-entry`},g.createElement(na,{className:l},d+` -`),g.createElement(ta,{...s,className:(l??``)+` gdg-input`,id:f,ref:u,onKeyDown:p,value:d,placeholder:t,dir:`auto`}))},oa={},sa=null;function ca(){let e=document.createElement(`div`);return e.style.opacity=`0`,e.style.pointerEvents=`none`,e.style.position=`fixed`,document.body.append(e),e}function la(e){let t=e.toLowerCase().trim();if(oa[t]!==void 0)return oa[t];sa||=ca(),sa.style.color=`#000`,sa.style.color=t;let n=getComputedStyle(sa).color;sa.style.color=`#fff`,sa.style.color=t;let r=getComputedStyle(sa).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(e=>Number.isNaN(e)?0:e),oa[t]=i,i}function ua(e,t){let[n,r,i]=la(e);return`rgba(${n}, ${r}, ${i}, ${t})`}var da=new Map;function fa(e,t){let n=`${e}-${t}`,r=da.get(n);if(r!==void 0)return r;let i=pa(e,t);return da.set(n,i),i}function pa(e,t){if(t===void 0)return e;let[n,r,i,a]=la(e);if(a===1)return e;let[o,s,c,l]=la(t),u=a+l*(1-a);return`rgba(${(a*n+l*o*(1-a))/u}, ${(a*r+l*s*(1-a))/u}, ${(a*i+l*c*(1-a))/u}, ${u})`}var ma=new Map,ha=new Map,ga=new Map;function _a(){ma.clear(),ga.clear(),ha.clear()}function va(e,t,n,r,i){let a=0,o={};for(let t of e)a+=n.get(t)??i,o[t]=(o[t]??0)+1;let s=t-a;for(let e of Object.keys(o)){let t=o[e],c=n.get(e)??i,l=c+s*(c*t/a)*r/t;n.set(e,l)}}function ya(e,t){let n=new Map,r=0;for(let t of`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890,.-+=?`){let i=e.measureText(t).width;n.set(t,i),r+=i}let i=r/n.size,a=(t/i+3)/4,o=n.keys();for(let e of o)n.set(e,(n.get(e)??i)*a);return n}function ba(e,t,n,r){let i=ha.get(n);if(r&&i!==void 0&&i.count>2e4){let r=ga.get(n);if(r===void 0&&(r=ya(e,i.size),ga.set(n,r)),i.count>5e5){let e=0;for(let n of t)e+=r.get(n)??i.size;return e*1.01}let a=e.measureText(t);return va(t,a.width,r,Math.max(.05,1-i.count/2e5),i.size),ha.set(n,{count:i.count+t.length,size:i.size}),a.width}let a=e.measureText(t),o=a.width/t.length;if((i?.count??0)>2e4)return a.width;if(i===void 0)ha.set(n,{count:t.length,size:o});else{let e=o-i.size,r=t.length/(i.count+t.length),a=i.size+e*r;ha.set(n,{count:i.count+t.length,size:a})}return a.width}function xa(e,t,n,r,i,a,o,s){if(t.length<=1)return t.length;if(in;){let n=u===void 0?t.lastIndexOf(` `,c-1):0;n>0?c=n:c--,l=ba(e,t.slice(0,Math.max(0,c)),r,o)}}if(t[c]!==` `){let e=0;if(u===void 0)e=t.lastIndexOf(` `,c);else for(let t of u){if(t>c)break;e=t}e>0&&(c=e)}return c}function Sa(e,t,n,r,i,a){let o=`${t}_${n}_${r}px`,s=ma.get(o);if(s!==void 0)return s;if(r<=0)return[];let c=[],l=t.split(` -`),u=ha.get(n),d=u===void 0?t.length:r/u.size*1.5,f=i&&u!==void 0&&u.count>2e4;for(let t of l){let i=ba(e,t.slice(0,Math.max(0,d)),n,f),o=Math.min(t.length,d);if(i<=r)c.push(t);else{for(;i>r;){let s=xa(e,t,r,n,i,o,f,a),l=t.slice(0,Math.max(0,s));t=t.slice(l.length),c.push(l),i=ba(e,t.slice(0,Math.max(0,d)),n,f),o=Math.min(t.length,d)}i>0&&c.push(t)}}return c=c.map((e,t)=>t===0?e.trimEnd():e.trim()),ma.set(o,c),ma.size>500&&ma.delete(ma.keys().next().value),c}function Ca(e,t){return g.useMemo(()=>e.map((e,n)=>({group:e.group,grow:e.grow,hasMenu:e.hasMenu,icon:e.icon,id:e.id,menuIcon:e.menuIcon,overlayIcon:e.overlayIcon,sourceIndex:n,sticky:n=e.x&&n=e.y&&r=t.span[0]&&n.current.cell[0]<=t.span[1]}function Da(e,t){let[n,r]=e;return n>=t.x&&n=t.y&&ro)return!1;if(t.span===void 0)return s>=r&&s<=i;let[l,u]=t.span;return l>=r&&l<=i||u>=r&&l<=i||li}function ja(e,t,n,r){let i=0;if(n.current===void 0)return i;let a=n.current.range;(r||a.height*a.width>1)&&Aa(e,t,a)&&i++;for(let r of n.current.rangeStack)Aa(e,t,r)&&i++;return i}function Ma(e,t){let n=e;if(t!==void 0){let r=[...e],i=n[t.src];t.src>t.dest?(r.splice(t.src,1),r.splice(t.dest,0,i)):(r.splice(t.dest+1,0,i),r.splice(t.src,1)),r=r.map((t,n)=>({...t,sticky:e[n].sticky})),n=r}return n}function Na(e,t){let n=0,r=Ma(e,t);for(let e=0;e0)for(let e of o)n-=e.width;let s=t,c=i??0;for(;c<=n&&s=d)return n}let f=a-l,p=e-(c??0);if(typeof o==`number`){let e=Math.floor((p-u)/o)+s;return e>=f?void 0:e}{let e=u;for(let t=s;t`u`;async function Va(){Ba||document?.fonts?.ready===void 0||(await document.fonts.ready,Ra=0,za={},_a())}Va();function Ha(e,t,n,r){return`${e}_${r??t?.font}_${n}`}function Ua(e,t,n,r=`middle`){let i=Ha(e,t,r,n),a=za[i];return a===void 0&&(a=t.measureText(e),za[i]=a,Ra++),Ra>1e4&&(za={},Ra=0),a}function Wa(e,t){let n=Ha(e,void 0,`middle`,t);return za[n]}function Ga(e,t){return typeof t!=`string`&&(t=t.baseFontFull),Ja(e,t)}function Ka(e,t){e.save(),e.textBaseline=t;let n=e.measureText(`ABCDEFGHIJKLMNOPQRSTUVWXYZ`);return e.restore(),n}var qa=[];function Ja(e,t){for(let e of qa)if(e.key===t)return e.val;let n=Ka(e,`alphabetic`),r=-(Ka(e,`middle`).actualBoundingBoxDescent-n.actualBoundingBoxDescent)+n.actualBoundingBoxAscent/2;return qa.push({key:t,val:r}),r}function Ya(e,t,n,r,i,a){let{ctx:o,rect:s,theme:c}=e,l=2**53-1;return t!==void 0&&(l=n-t,l<500&&(o.globalAlpha=1-l/500,o.fillStyle=c.bgSearchResult,o.fillRect(s.x+1,s.y+1,s.width-(i?2:1),s.height-(a?2:1)),o.globalAlpha=1,r!==void 0&&(r.fillStyle=c.bgSearchResult))),l<500}function Xa(e,t,n){let{ctx:r,theme:i}=e,a=t??{},o=n??i.textDark;return o!==a.fillStyle&&(r.fillStyle=o,a.fillStyle=o),a}function Za(e,t,n,r,i,a,o,s,c){c===`right`?e.fillText(t,n+i-(s.cellHorizontalPadding+.5),r+a/2+o):c===`center`?e.fillText(t,n+i/2,r+a/2+o):e.fillText(t,n+s.cellHorizontalPadding+.5,r+a/2+o)}function Qa(e,t){let n=Ua(`ABCi09jgqpy`,e,t);return n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}function $a(e,t){e.includes(` -`)&&(e=e.split(/\r?\n/,1)[0]);let n=t/4;return e.length>n&&(e=e.slice(0,n)),e}function eo(e,t,n,r,i,a,o,s,c,l){let u=s.baseFontFull,d=Sa(e,t,u,i-s.cellHorizontalPadding*2,l??!1),f=Qa(e,u),p=s.lineHeight*f,m=f+p*(d.length-1),h=m+s.cellVerticalPadding>a;h&&(e.save(),e.rect(n,r,i,a),e.clip());let g=r+a/2-m/2,_=Math.max(r+s.cellVerticalPadding,g);for(let t of d)if(Za(e,t,n,_,i,f,o,s,c),_+=p,_>r+a)break;h&&e.restore()}function to(e,t,n,r,i){let{ctx:a,rect:o,theme:s}=e,{x:c,y:l,width:u,height:d}=o;r??=!1,r||(t=$a(t,u));let f=Ga(a,s),p=ri(t)===`rtl`;if(n===void 0&&p&&(n=`right`),p&&(a.direction=`rtl`),t.length>0){let e=!1;n===`right`?(a.textAlign=`right`,e=!0):n!==void 0&&n!==`left`&&(a.textAlign=n,e=!0),r?eo(a,t,c,l,u,d,f,s,n,i):Za(a,t,c,l,u,d,f,s,n),e&&(a.textAlign=`start`),p&&(a.direction=`inherit`)}}function no(e,t,n,r,i,a){typeof a==`number`&&(a={tl:a,tr:a,br:a,bl:a}),a={tl:Math.max(0,Math.min(a.tl,i/2,r/2)),tr:Math.max(0,Math.min(a.tr,i/2,r/2)),bl:Math.max(0,Math.min(a.bl,i/2,r/2)),br:Math.max(0,Math.min(a.br,i/2,r/2))},e.moveTo(t+a.tl,n),e.arcTo(t+r,n,t+r,n+a.tr,a.tr),e.arcTo(t+r,n+i,t+r-a.br,n+i,a.br),e.arcTo(t,n+i,t,n+i-a.bl,a.bl),e.arcTo(t,n,t+a.tl,n,a.tl)}function ro(e,t,n){let r=1.25;e.arc(t,n-r*3.5,r,0,2*Math.PI,!1),e.arc(t,n,r,0,2*Math.PI,!1),e.arc(t,n+r*3.5,r,0,2*Math.PI,!1)}function io(e,t,n){let r=function(e,t){let n=t.x-e.x,r=t.y-e.y,i=Math.sqrt(n*n+r*r),a=n/i,o=r/i;return{x:n,y:t.y-e.y,len:i,nx:a,ny:o,ang:Math.atan2(o,a)}},i,a=t.length,o=t[a-1];for(let s=0;s1?1:f),h=1,g=!1;p<0?m<0?m=Math.PI+m:(m=Math.PI-m,h=-1,g=!0):m>0&&(h=-1,g=!0),i=c.radius===void 0?n:c.radius;let _=m/2,v=Math.abs(Math.cos(_)*i/Math.sin(_)),y;v>Math.min(u.len/2,d.len/2)?(v=Math.min(u.len/2,d.len/2),y=Math.abs(v*Math.sin(_)/Math.cos(_))):y=i;let b=c.x+d.nx*v,x=c.y+d.ny*v;b+=-d.ny*y*h,x+=d.nx*y*h,e.arc(b,x,y,u.ang+Math.PI/2*h,d.ang-Math.PI/2*h,g),o=c,c=l}e.closePath()}function ao(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h={x:0,y:a+l,width:0,height:0};if(e>=p.length||t>=u||t<-2||e<0)return h;let g=a-i;if(e>=d){let t=o>e?-1:1,n=Na(p);h.x+=n+c;for(let n=o;n!==e;n+=t)h.x+=p[t===1?n:n-1].width*t}else for(let t=0;t0&&Ta(p[t-1].group,r)&&p[t-1].sticky===a;){let e=p[t-1];h.x-=e.width,h.width+=e.width,t--}let o=e;for(;o+1n&&(h.width=n-h.x)}}else if(t>=u-f){let e=u-t;for(h.y=r;e>0;){let n=t+e-1;h.height=typeof m==`number`?m:m(n),h.y-=h.height,e--}h.height+=1}else{let e=s>t?-1:1;if(typeof m==`number`){let e=t-s;h.y+=e*m}else for(let n=s;n!==t;n+=e)h.y+=m(n)*e;h.height=(typeof m==`number`?m:m(t))+1}return h}var oo=1<<21;function so(e,t){return(t+2)*oo+e}function co(e){return e%oo}function lo(e){return Math.floor(e/oo)-2}function uo(e){return[co(e),lo(e)]}var fo=class{visibleWindow={x:0,y:0,width:0,height:0};freezeCols=0;freezeRows=[];isInWindow=e=>{let t=co(e),n=lo(e),r=this.visibleWindow,i=t>=r.x&&t<=r.x+r.width||t=r.y&&n<=r.y+r.height||this.freezeRows.includes(n);return i&&a};setWindow(e,t,n){this.visibleWindow.x===e.x&&this.visibleWindow.y===e.y&&this.visibleWindow.width===e.width&&this.visibleWindow.height===e.height&&this.freezeCols===t&&Jt(this.freezeRows,n)||(this.visibleWindow=e,this.freezeCols=t,this.freezeRows=n,this.clearOutOfWindow())}},po=class extends fo{cache=new Map;setValue=(e,t)=>{this.cache.set(so(e[0],e[1]),t)};getValue=e=>this.cache.get(so(e[0],e[1]));clearOutOfWindow=()=>{for(let[e]of this.cache.entries())this.isInWindow(e)||this.cache.delete(e)}},mo=class{cells;constructor(e=[]){this.cells=new Set(e.map(e=>so(e[0],e[1])))}add(e){this.cells.add(so(e[0],e[1]))}has(e){return e!==void 0&&this.cells.has(so(e[0],e[1]))}remove(e){this.cells.delete(so(e[0],e[1]))}clear(){this.cells.clear()}get size(){return this.cells.size}hasHeader(){for(let e of this.cells)if(lo(e)<0)return!0;return!1}hasItemInRectangle(e){for(let t=e.y;t{let i=xo(e,n[r],t,c);return l=Math.max(l,i),i});if(u.length>5&&s){l=0;let e=0;for(let t of u)e+=t;let t=e/u.length;for(let e=0;e=t*2?u[e]=0:l=Math.max(l,u[e])}l=Math.max(l,e.measureText(n.title).width+16+(n.icon===void 0?0:28));let d=Math.max(Math.ceil(a),Math.min(Math.floor(o),Math.ceil(l)));return{...n,width:d}}function Co(e,t,n,r,i,a,o,s,c){let l=g.useRef(t),u=g.useRef(n),d=g.useRef(o);l.current=t,u.current=n,d.current=o;let[f,p]=g.useMemo(()=>{if(typeof window>`u`)return[null,null];let e=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,[e,e.getContext(`2d`,{alpha:!1})]},[]);g.useLayoutEffect(()=>(f&&document.documentElement.append(f),()=>{f?.remove()}),[f]);let m=g.useRef({}),h=g.useRef(),[_,v]=g.useState();return g.useLayoutEffect(()=>{let t=u.current;if(t===void 0||e.every(er))return;let n=Math.max(1,10-Math.floor(e.length/1e4)),r=0;n1&&(n--,r=1);let i={x:0,y:0,width:e.length,height:Math.min(l.current,n)},a={x:0,y:l.current-1,width:e.length,height:1};(async()=>{let n=t(i,c.signal),o=r>0?t(a,c.signal):void 0,s;s=typeof n==`object`?n:await tr(n),o!==void 0&&(s=typeof o==`object`?[...s,...o]:[...s,...await tr(o)]),h.current=e,v(s)})()},[c.signal,e]),g.useMemo(()=>{let t=e.every(er)?e:p===null?e.map(e=>er(e)?e:{...e,width:bo}):(p.font=d.current.baseFontFull,e.map((t,n)=>{if(er(t))return t;if(m.current[t.id]!==void 0)return{...t,width:m.current[t.id]};if(_===void 0||h.current!==e||t.id===void 0)return{...t,width:bo};let r=So(p,o,t,n,_,i,a,!0,s);return m.current[t.id]=r.width,r})),n=0,c=0,l=[];for(let[e,r]of t.entries())n+=r.width,r.grow!==void 0&&r.grow>0&&(c+=r.grow,l.push(e));if(n0){let e=[...t],i=r-n,a=i;for(let n=0;n{function n(e,t,n){return e===e&&(n!==void 0&&(e=e<=n?e:n),t!==void 0&&(e=e>=t?e:t)),e}t.exports=n})),To=o(((e,t)=>{var n=wo(),r=Hr();function i(e,t,i){return i===void 0&&(i=t,t=void 0),i!==void 0&&(i=r(i),i=i===i?i:0),t!==void 0&&(t=r(t),t=t===t?t:0),n(r(e),t,i)}t.exports=i})),Eo=o(((e,t)=>{function n(e){return this.__data__.set(e,`__lodash_hash_undefined__`),this}t.exports=n})),Do=o(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),Oo=o(((e,t)=>{var n=Ln(),r=Eo(),i=Do();function a(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new n;++t{function n(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a{function n(e){return e!==e}t.exports=n})),jo=o(((e,t)=>{function n(e,t,n){for(var r=n-1,i=e.length;++r{var n=ko(),r=Ao(),i=jo();function a(e,t,a){return t===t?i(e,t,a):n(e,r,a)}t.exports=a})),No=o(((e,t)=>{var n=Mo();function r(e,t){return!!(e!=null&&e.length)&&n(e,t,0)>-1}t.exports=r})),Po=o(((e,t)=>{function n(e,t,n){for(var r=-1,i=e==null?0:e.length;++r{function n(e,t){return e.has(t)}t.exports=n})),Io=o(((e,t)=>{t.exports=pn()(Zt(),`Set`)})),Lo=o(((e,t)=>{function n(){}t.exports=n})),Ro=o(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}t.exports=n})),zo=o(((e,t)=>{var n=Io(),r=Lo(),i=Ro();t.exports=n&&1/i(new n([,-0]))[1]==1/0?function(e){return new n(e)}:r})),Bo=o(((e,t)=>{var n=Oo(),r=No(),i=Po(),a=Fo(),o=zo(),s=Ro(),c=200;function l(e,t,l){var u=-1,d=r,f=e.length,p=!0,m=[],h=m;if(l)p=!1,d=i;else if(f>=c){var g=t?null:o(e);if(g)return s(g);p=!1,d=a,h=new n}else h=t?[]:m;outer:for(;++u{var n=Bo();function r(e){return e&&e.length?n(e):[]}t.exports=r})),Ho=o(((e,t)=>{function n(e,t){for(var n=-1,r=t.length,i=e.length;++n{var n=Qt(),r=Kn(),i=Xt(),a=n?n.isConcatSpreadable:void 0;function o(e){return i(e)||r(e)||!!(a&&e&&e[a])}t.exports=o})),Wo=o(((e,t)=>{var n=Ho(),r=Uo();function i(e,t,a,o,s){var c=-1,l=e.length;for(a||=r,s||=[];++c0&&a(u)?t>1?i(u,t-1,a,o,s):n(s,u):o||(s[s.length]=u)}return s}t.exports=i})),Go=o(((e,t)=>{var n=Wo();function r(e){return e!=null&&e.length?n(e,1):[]}t.exports=r})),Ko=o(((e,t)=>{var n=Math.ceil,r=Math.max;function i(e,t,i,a){for(var o=-1,s=r(n((t-e)/(i||1)),0),c=Array(s);s--;)c[a?s:++o]=e,e+=i;return c}t.exports=i})),qo=o(((e,t)=>{var n=sn(),r=Jn();function i(e){return e!=null&&r(e.length)&&!n(e)}t.exports=i})),Jo=o(((e,t)=>{var n=Sn(),r=qo(),i=qn(),a=on();function o(e,t,o){if(!a(o))return!1;var s=typeof t;return(s==`number`?r(o)&&i(t,o.length):s==`string`&&t in o)?n(o[t],e):!1}t.exports=o})),Yo=o(((e,t)=>{var n=Hr(),r=1/0,i=17976931348623157e292;function a(e){return e?(e=n(e),e===r||e===-r?(e<0?-1:1)*i:e===e?e:0):e===0?e:0}t.exports=a})),Xo=o(((e,t)=>{var n=Ko(),r=Jo(),i=Yo();function a(e){return function(t,a,o){return o&&typeof o!=`number`&&r(t,a,o)&&(a=o=void 0),t=i(t),a===void 0?(a=t,t=0):a=i(a),o=o===void 0?t{t.exports=Xo()()}));function Qo(e,t){return e===`normal`?[t.bgIconHeader,t.fgIconHeader]:e===`selected`?[`white`,t.accentColor]:[t.accentColor,t.bgHeader]}var $o=class{onSettled;spriteMap=new Map;headerIcons;inFlight=0;constructor(e,t){this.onSettled=t,this.headerIcons=e??{}}drawSprite(e,t,n,r,i,a,o,s=1){let[c,l]=Qo(t,o),u=a*Math.ceil(window.devicePixelRatio),d=`${c}_${l}_${u}_${e}`,f=this.spriteMap.get(d);if(f===void 0){let t=this.headerIcons[e];if(t===void 0)return;f=document.createElement(`canvas`);let n=f.getContext(`2d`);if(n===null)return;let r=new Image;r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t({fgColor:l,bgColor:c}))}`,this.spriteMap.set(d,f);let i=r.decode();if(i===void 0)return;this.inFlight++,i.then(()=>{n.drawImage(r,0,0,u,u)}).finally(()=>{this.inFlight--,this.inFlight===0&&this.onSettled()})}else s<1&&(n.globalAlpha=s),n.drawImage(f,0,0,u,u,r,i,a,a),s<1&&(n.globalAlpha=1)}};function es(e){if(e.length===0)return;let t;for(let n of e)t=Math.min(t??n.y,n.y)}function ts(e,t,n,r,i,a,o,s,c){s??=t;let l=t,u=e,d=r-a,f=!1;for(;ls&&c(l,u,e,!1,o&&u===r-1)===!0){f=!0;break}l+=e,u++}if(!f){l=n;for(let e=0;e!e.sticky)?.sourceIndex??0;if(c>d){let e=Math.max(s,d),l=t,f=r;for(let t=a.sourceIndex-1;t>=e;t--)l-=o[t].width,f+=o[t].width;for(let e=a.sourceIndex+1;e<=c;e++)f+=o[e].width;u={x:l,y:n,width:f,height:i}}if(d>s){let e=Math.min(c,d-1),u=t,f=r;for(let e=a.sourceIndex-1;e>=s;e--)u-=o[e].width,f+=o[e].width;for(let t=a.sourceIndex+1;t<=e;t++)f+=o[t].width;l={x:u,y:n,width:f,height:i}}return[l,u]}function as(e,t,n,r){if(r===`any`)return cs(e,{x:t,y:n,width:1,height:1});if(r===`vertical`&&(t=e.x),r===`horizontal`&&(n=e.y),Da([t,n],e))return;let i=t-e.x,a=e.x+e.width-t,o=n-e.y+1,s=e.y+e.height-n,c=Math.min(r===`vertical`?2**53-1:i,r===`vertical`?2**53-1:a,r===`horizontal`?2**53-1:o,r===`horizontal`?2**53-1:s);return c===s?{x:e.x,y:e.y+e.height,width:e.width,height:n-e.y-e.height+1}:c===o?{x:e.x,y:n,width:e.width,height:e.y-n}:c===a?{x:e.x+e.width,y:e.y,width:t-e.x-e.width+1,height:e.height}:{x:t,y:e.y,width:e.x-t,height:e.height}}function os(e,t,n,r,i,a,o,s){return e<=i+o&&i<=e+n&&t<=a+s&&a<=t+r}function ss(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function cs(e,t){let n=Math.min(e.x,t.x),r=Math.min(e.y,t.y);return{x:n,y:r,width:Math.max(e.x+e.width,t.x+t.width)-n,height:Math.max(e.y+e.height,t.y+t.height)-r}}function ls(e,t){return e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}function us(e,t,n,r){if(e.x>t||e.y>n||e.x<0&&e.y<0&&e.x+e.width>t&&e.y+e.height>n)return;if(e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n)return e;let i=t+4,a=n+4,o=-4-e.x,s=e.x+e.width-i,c=-4-e.y,l=e.y+e.height-a,u=o>0?e.x+Math.floor(o/r)*r:e.x,d=s>0?e.x+e.width-Math.floor(s/r)*r:e.x+e.width,f=c>0?e.y+Math.floor(c/r)*r:e.y,p=l>0?e.y+e.height-Math.floor(l/r)*r:e.y+e.height;return{x:u,y:f,width:d-u,height:p-f}}function ds(e,t,n,r,i){let[a,o,s,c]=t,[l,u,d,f]=i,{x:p,y:m,width:h,height:g}=e,_=[];if(h<=0||g<=0)return _;let v=p+h,y=m+g,b=ps,C=m+g>c,w=p>=a&&pa&&v<=s||ps,T=m>=o&&mo&&y<=c||mc;if(w&&T){let e=Math.max(p,a),t=Math.max(m,o),n=Math.min(v,s),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:u,width:d-l+1,height:f-u+1}})}if(b&&x){let e=p,t=m,n=Math.min(v,a),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:0,width:l+1,height:u+1}})}if(x&&w){let e=Math.max(p,a),t=m,n=Math.min(v,s),r=Math.min(y,o);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:l,y:0,width:d-l+1,height:u+1}})}if(x&&S){let e=Math.max(p,s),t=m,r=v,i=Math.min(y,o);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:0,width:n-d+1,height:u+1}})}if(b&&T){let e=p,t=Math.max(m,o),n=Math.min(v,a),r=Math.min(y,c);_.push({rect:{x:e,y:t,width:n-e,height:r-t},clip:{x:0,y:u,width:l+1,height:f-u+1}})}if(S&&T){let e=Math.max(p,s),t=Math.max(m,o),r=v,i=Math.min(y,c);_.push({rect:{x:e,y:t,width:r-e,height:i-t},clip:{x:d,y:u,width:n-d+1,height:f-u+1}})}if(b&&C){let e=p,t=Math.max(m,c),n=Math.min(v,a),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:0,y:f,width:l+1,height:r-f+1}})}if(C&&w){let e=Math.max(p,a),t=Math.max(m,c),n=Math.min(v,s),i=y;_.push({rect:{x:e,y:t,width:n-e,height:i-t},clip:{x:l,y:f,width:d-l+1,height:r-f+1}})}if(S&&C){let e=Math.max(p,s),t=Math.max(m,c),i=v,a=y;_.push({rect:{x:e,y:t,width:i-e,height:a-t},clip:{x:d,y:f,width:n-d+1,height:r-f+1}})}return _}var fs={kind:W.Loading,allowOverlay:!1};function ps(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,k,A,ee,te,ne,re){let j=y?.size??2**53-1,ie=performance.now(),M=k.baseFontFull;e.font=M;let ae={ctx:e},N=[0,0],oe=g>0?Pa(c,g,l):0,P,se,ce=es(v);return ns(t,s,a,o,i,(t,a,o,s,F)=>{let le=Math.max(0,s-a),ue=a+le,de=i+1,fe=t.width-le,pe=r-i-1;if(v.length>0){let e=!1;for(let t=0;t{e.save(),e.beginPath(),e.rect(ue,de,fe,pe),e.clip()},he=b.columns.hasIndex(t.sourceIndex),ge=d(t.group??``).overrideTheme,I=t.themeOverride===void 0&&ge===void 0?k:yo(k,ge,t.themeOverride),L=I.baseFontFull;L!==M&&(M=L,e.font=L),me();let _e;return ts(F,o,r,c,l,g,_,ce,(i,o,l,d,g)=>{if(o<0||(N[0]=t.sourceIndex,N[1]=o,y!==void 0&&!y.has(N)))return;if(v.length>0){let e=!1;for(let n=0;nF.span!==void 0&&e>=F.span[0]&&e<=F.span[1]);ve&&!m&&h?ye=0:ve&&h&&(ye=Math.max(ye,1)),be&&ye++,ve||(_&&ye++,he&&!g&&ye++);let xe=F.kind===W.Protected?R.bgCellMedium:R.bgCell,Se;if((d||xe!==k.bgCell)&&(Se=pa(xe,Se)),ye>0||ce){ce&&(Se=pa(R.bgHeader,Se));for(let e=0;ere&&!fe){let n=R.baseFontFull;n!==M&&(e.font=n,M=n),_e=ys(e,F,t.sourceIndex,o,Ce,we,le,i,ue,l,ye>0,R,Se??R.bgCell,C,w,B?.hoverAmount??0,E,O,ie,D,_e,A,ee,te,ne)}return z&&e.restore(),F.style===`faded`&&(e.globalAlpha=1),j--,de&&(e.restore(),_e?.deprep?.(ae),_e=void 0,me(),M=L,e.font=L),j<=0}),e.restore(),j<=0}),P}var ms=[0,0],hs={x:0,y:0,width:0,height:0},gs=[void 0,()=>void 0],_s=!1;function vs(){_s=!0}function ys(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w){let T,E;g!==void 0&&g[0][0]===n&&g[0][1]===r&&(T=g[1][0],E=g[1][1]);let D;ms[0]=n,ms[1]=r,hs.x=o,hs.y=s,hs.width=c,hs.height=l,gs[0]=S.getValue(ms),gs[1]=e=>S.setValue(ms,e),_s=!1;let O={ctx:e,theme:d,col:n,row:r,cell:t,rect:hs,highlighted:u,cellFillColor:f,hoverAmount:h,frameTime:v,hoverX:T,drawState:gs,hoverY:E,imageLoader:p,spriteManager:m,hyperWrapping:_,overrideCursor:T===void 0?void 0:w,requestAnimationFrame:vs},k=Ya(O,t.lastUpdated,v,b,i,a),A=C(t);if(A!==void 0){b?.renderer!==A&&(b?.deprep?.(O),b=void 0);let e=A.drawPrep?.(O,b);y!==void 0&&!rr(O.cell)?y(O,()=>A.draw(O,t)):A.draw(O,t),D=e===void 0?void 0:{deprep:e?.deprep,fillStyle:e?.fillStyle,font:e?.font,renderer:A}}return(k||_s)&&x?.(ms),D}function bs(e,t,n,r,i,a,o,s,c=-20,l=-20,u=32,d=`center`,f=`square`){let p=Math.floor(i+o/2),m=f===`circle`?1e4:t.roundingRadius??4,h=Zr(u,o,t.cellVerticalPadding),g=h/2,_=Xr(d,r,a,t.cellHorizontalPadding,h),v=Yr(_,p,h),y=Qr(r+c,i+l,v);switch(n){case!0:e.beginPath(),no(e,_-h/2,p-h/2,h,h,m),f===`circle`&&(g*=.8,h*=.8),e.fillStyle=s?t.accentColor:t.textMedium,e.fill(),e.beginPath(),e.moveTo(_-g+h/4.23,p-g+h/1.97),e.lineTo(_-g+h/2.42,p-g+h/1.44),e.lineTo(_-g+h/1.29,p-g+h/3.25),e.strokeStyle=t.bgCell,e.lineJoin=`round`,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;case null:case!1:e.beginPath(),no(e,_-h/2+.5,p-h/2+.5,h-1,h-1,m),e.lineWidth=1,e.strokeStyle=y?t.textDark:t.textMedium,e.stroke();break;case void 0:e.beginPath(),no(e,_-h/2,p-h/2,h,h,m),e.fillStyle=y?t.textMedium:t.textLight,e.fill(),f===`circle`&&(g*=.8,h*=.8),e.beginPath(),e.moveTo(_-h/3,p),e.lineTo(_+h/3,p),e.strokeStyle=t.bgCell,e.lineCap=`round`,e.lineWidth=1.9,e.stroke();break;default:Gt(n)}}function xs(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=o+s;if(y<=0)return;e.fillStyle=d.bgHeader,e.fillRect(0,0,i,y);let[b,x]=r?.[0]??[];e.font=d.headerFontFull,ns(t,0,a,0,y,(t,r,i,a)=>{if(g!==void 0&&!g.has([t.sourceIndex,-1]))return;let m=Math.max(0,a-r);e.save(),e.beginPath(),e.rect(r+m,s,t.width-m,o),e.clip();let y=h(t.group??``).overrideTheme,S=t.themeOverride===void 0&&y===void 0?d:yo(d,y,t.themeOverride);S.bgHeader!==d.bgHeader&&(e.fillStyle=S.bgHeader,e.fill()),S!==d&&(e.font=S.baseFontFull);let C=u.columns.hasIndex(t.sourceIndex),w=c!==void 0||l,T=!w&&x===-1&&b===t.sourceIndex,E=w?0:p.find(e=>e.item[0]===t.sourceIndex&&e.item[1]===-1)?.hoverAmount??0,D=u?.current!==void 0&&u.current.cell[0]===t.sourceIndex,O=C?S.accentColor:D?S.bgHeaderHasFocus:S.bgHeader,k=n?s:0,A=t.sourceIndex===0?0:1;C?(e.fillStyle=O,e.fillRect(r+A,k,t.width-A,o)):(D||E>0)&&(e.beginPath(),e.rect(r+A,k,t.width-A,o),D&&(e.fillStyle=S.bgHeaderHasFocus,e.fill()),E>0&&(e.globalAlpha=E,e.fillStyle=S.bgHeaderHovered,e.fill(),e.globalAlpha=1)),Ds(e,r,k,t.width,o,t,C,S,T,D,E,f,_,v),e.restore()}),n&&Ss(e,t,i,a,s,r,d,f,p,m,h,g)}function Ss(e,t,n,r,i,a,o,s,c,l,u,d){let[f,p]=a?.[0]??[],m=0;rs(t,n,r,i,(t,n,r,c,h,g)=>{if(d!==void 0&&!d.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1}))return;e.save(),e.beginPath(),e.rect(r,c,h,g),e.clip();let _=u(n),v=_?.overrideTheme===void 0?o:yo(o,_.overrideTheme),y=p===-2&&f!==void 0&&f>=t[0]&&f<=t[1],b=y?v.bgHeaderHovered:v.bgHeader;if(b!==o.bgHeader&&(e.fillStyle=b,e.fill()),e.fillStyle=v.textGroupHeader??v.textHeader,_!==void 0){let t=r;if(_.icon!==void 0&&(s.drawSprite(_.icon,`normal`,e,t+8,(i-20)/2,20,v),t+=26),e.fillText(_.name,t+8,i/2+Ga(e,o.headerFontFull)),_.actions!==void 0&&y){let t=Ts({x:r,y:c,width:h,height:g},_.actions);e.beginPath();let n=t[0].x-10,o=r+h-n;e.rect(n,0,o,i);let l=e.createLinearGradient(n,0,n+o,0),u=ua(b,0);l.addColorStop(0,u),l.addColorStop(10/o,b),l.addColorStop(1,b),e.fillStyle=l,e.fill(),e.globalAlpha=.6;let[d,f]=a?.[1]??[-1,-1];for(let n=0;n<_.actions.length;n++){let i=_.actions[n],a=t[n],o=ss(a,d+r,f);o&&(e.globalAlpha=1),s.drawSprite(i.icon,`normal`,e,a.x+a.width/2-10,a.y+a.height/2-10,20,v),o&&(e.globalAlpha=.6)}e.globalAlpha=1}}r!==0&&l(t[0])&&(e.beginPath(),e.moveTo(r+.5,0),e.lineTo(r+.5,i),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()),e.restore(),m=r+h}),e.beginPath(),e.moveTo(m+.5,0),e.lineTo(m+.5,i),e.moveTo(0,i+.5),e.lineTo(n,i+.5),e.strokeStyle=o.borderColor,e.lineWidth=1,e.stroke()}var Cs=30;function ws(e,t,n,r,i){return i?{x:e,y:t,width:Cs,height:Math.min(Cs,r)}:{x:e+n-Cs,y:Math.max(t,t+r/2-Cs/2),width:Cs,height:Math.min(Cs,r)}}function Ts(e,t){let n=[],r=e.x+e.width-26*t.length,i=e.y+e.height/2-13;for(let e=0;e35){let n=f?35:r-35,i=f?24.5:r-24.5,a=n/r,o=i/r,s=e.createLinearGradient(t,0,t+r,0),c=ua(h,0);s.addColorStop(+!!f,h),s.addColorStop(a,h),s.addColorStop(o,c),s.addColorStop(+!f,c),e.fillStyle=s}else e.fillStyle=h;if(f&&(e.textAlign=`right`),e.fillText(a.title,v,n+i/2+Ga(e,s.headerFontFull)),f&&(e.textAlign=`left`),g&&a.hasMenu===!0){if(a.menuIcon===void 0||a.menuIcon===$n.Triangle){e.beginPath();let t=p.x+p.width/2-5.5,n=p.y+p.height/2-3;io(e,[{x:t,y:n},{x:t+11,y:n},{x:t+5.5,y:n+6}],1),e.fillStyle=h,e.fill()}else if(a.menuIcon===$n.Dots)e.beginPath(),ro(e,p.x+p.width/2,p.y+p.height/2),e.fillStyle=h,e.fill();else{let t=p.x+(p.width-s.headerIconSize)/2,n=p.y+(p.height-s.headerIconSize)/2;u.drawSprite(a.menuIcon,`normal`,e,t,n,s.headerIconSize,s)}}}function Ds(e,t,n,r,i,a,o,s,c,l,u,d,f,p){let m=ri(a.title)===`rtl`,h=ws(t,n,r,i,m);f===void 0?Es(e,t,n,r,i,a,o,s,c,u,d,p,m,h):f({ctx:e,theme:s,rect:{x:t,y:n,width:r,height:i},column:a,columnIndex:a.sourceIndex,isSelected:o,hoverAmount:u,isHovered:c,hasSelectedCell:l,spriteManager:d,menuBounds:h},()=>Es(e,t,n,r,i,a,o,s,c,u,d,p,m,h))}var Os=o(((e,t)=>{var n=pn();t.exports=function(){try{var e=n(Object,`defineProperty`);return e({},``,{}),e}catch{}}()})),ks=o(((e,t)=>{var n=Os();function r(e,t,r){t==`__proto__`&&n?n(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}t.exports=r})),As=o(((e,t)=>{function n(e,t,n,r){for(var i=-1,a=e==null?0:e.length;++i{function n(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}t.exports=n})),Ms=o(((e,t)=>{t.exports=js()()})),Ns=o(((e,t)=>{function n(e,t){for(var n=-1,r=Array(e);++n{function n(){return!1}t.exports=n})),Fs=o(((e,t)=>{var n=Zt(),r=Ps(),i=typeof e==`object`&&e&&!e.nodeType&&e,a=i&&typeof t==`object`&&t&&!t.nodeType&&t,o=a&&a.exports===i?n.Buffer:void 0;t.exports=(o?o.isBuffer:void 0)||r})),Is=o(((e,t)=>{var n=tn(),r=Jn(),i=nn(),a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object RegExp]`,h=`[object Set]`,g=`[object String]`,_=`[object WeakMap]`,v=`[object ArrayBuffer]`,y=`[object DataView]`,b=`[object Float32Array]`,x=`[object Float64Array]`,S=`[object Int8Array]`,C=`[object Int16Array]`,w=`[object Int32Array]`,T=`[object Uint8Array]`,E=`[object Uint8ClampedArray]`,D=`[object Uint16Array]`,O=`[object Uint32Array]`,k={};k[b]=k[x]=k[S]=k[C]=k[w]=k[T]=k[E]=k[D]=k[O]=!0,k[a]=k[o]=k[v]=k[s]=k[y]=k[c]=k[l]=k[u]=k[d]=k[f]=k[p]=k[m]=k[h]=k[g]=k[_]=!1;function A(e){return i(e)&&r(e.length)&&!!k[n(e)]}t.exports=A})),Ls=o(((e,t)=>{function n(e){return function(t){return e(t)}}t.exports=n})),Rs=o(((e,t)=>{var n=U(),r=typeof e==`object`&&e&&!e.nodeType&&e,i=r&&typeof t==`object`&&t&&!t.nodeType&&t,a=i&&i.exports===r&&n.process;t.exports=function(){try{return i&&i.require&&i.require(`util`).types||a&&a.binding&&a.binding(`util`)}catch{}}()})),zs=o(((e,t)=>{var n=Is(),r=Ls(),i=Rs(),a=i&&i.isTypedArray;t.exports=a?r(a):n})),Bs=o(((e,t)=>{var n=Ns(),r=Kn(),i=Xt(),a=Fs(),o=qn(),s=zs(),c=Object.prototype.hasOwnProperty;function l(e,t){var l=i(e),u=!l&&r(e),d=!l&&!u&&a(e),f=!l&&!u&&!d&&s(e),p=l||u||d||f,m=p?n(e.length,String):[],h=m.length;for(var g in e)(t||c.call(e,g))&&!(p&&(g==`length`||d&&(g==`offset`||g==`parent`)||f&&(g==`buffer`||g==`byteLength`||g==`byteOffset`)||o(g,h)))&&m.push(g);return m}t.exports=l})),Vs=o(((e,t)=>{var n=Object.prototype;function r(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||n)}t.exports=r})),Hs=o(((e,t)=>{function n(e,t){return function(n){return e(t(n))}}t.exports=n})),Us=o(((e,t)=>{t.exports=Hs()(Object.keys,Object)})),Ws=o(((e,t)=>{var n=Vs(),r=Us(),i=Object.prototype.hasOwnProperty;function a(e){if(!n(e))return r(e);var t=[];for(var a in Object(e))i.call(e,a)&&a!=`constructor`&&t.push(a);return t}t.exports=a})),Gs=o(((e,t)=>{var n=Bs(),r=Ws(),i=qo();function a(e){return i(e)?n(e):r(e)}t.exports=a})),Ks=o(((e,t)=>{var n=Ms(),r=Gs();function i(e,t){return e&&n(e,t,r)}t.exports=i})),qs=o(((e,t)=>{var n=qo();function r(e,t){return function(r,i){if(r==null)return r;if(!n(r))return e(r,i);for(var a=r.length,o=t?a:-1,s=Object(r);(t?o--:++o{var n=Ks();t.exports=qs()(n)})),Ys=o(((e,t)=>{var n=Js();function r(e,t,r,i){return n(e,function(e,n,a){t(i,e,r(e),a)}),i}t.exports=r})),Xs=o(((e,t)=>{var n=On();function r(){this.__data__=new n,this.size=0}t.exports=r})),Zs=o(((e,t)=>{function n(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}t.exports=n})),Qs=o(((e,t)=>{function n(e){return this.__data__.get(e)}t.exports=n})),$s=o(((e,t)=>{function n(e){return this.__data__.has(e)}t.exports=n})),ec=o(((e,t)=>{var n=On(),r=kn(),i=Ln(),a=200;function o(e,t){var o=this.__data__;if(o instanceof n){var s=o.__data__;if(!r||s.length{var n=On(),r=Xs(),i=Zs(),a=Qs(),o=$s(),s=ec();function c(e){var t=this.__data__=new n(e);this.size=t.size}c.prototype.clear=r,c.prototype.delete=i,c.prototype.get=a,c.prototype.has=o,c.prototype.set=s,t.exports=c})),nc=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length;++n{var n=Oo(),r=nc(),i=Fo(),a=1,o=2;function s(e,t,s,c,l,u){var d=s&a,f=e.length,p=t.length;if(f!=p&&!(d&&p>f))return!1;var m=u.get(e),h=u.get(t);if(m&&h)return m==t&&h==e;var g=-1,_=!0,v=s&o?new n:void 0;for(u.set(e,t),u.set(t,e);++g{t.exports=Zt().Uint8Array})),ac=o(((e,t)=>{function n(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}t.exports=n})),oc=o(((e,t)=>{var n=Qt(),r=ic(),i=Sn(),a=rc(),o=ac(),s=Ro(),c=1,l=2,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Map]`,m=`[object Number]`,h=`[object RegExp]`,g=`[object Set]`,_=`[object String]`,v=`[object Symbol]`,y=`[object ArrayBuffer]`,b=`[object DataView]`,x=n?n.prototype:void 0,S=x?x.valueOf:void 0;function C(e,t,n,x,C,w,T){switch(n){case b:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case y:return!(e.byteLength!=t.byteLength||!w(new r(e),new r(t)));case u:case d:case m:return i(+e,+t);case f:return e.name==t.name&&e.message==t.message;case h:case _:return e==t+``;case p:var E=o;case g:var D=x&c;if(E||=s,e.size!=t.size&&!D)return!1;var O=T.get(e);if(O)return O==t;x|=l,T.set(e,t);var k=a(E(e),E(t),x,C,w,T);return T.delete(e),k;case v:if(S)return S.call(e)==S.call(t)}return!1}t.exports=C})),sc=o(((e,t)=>{var n=Ho(),r=Xt();function i(e,t,i){var a=t(e);return r(e)?a:n(a,i(e))}t.exports=i})),cc=o(((e,t)=>{function n(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n{function n(){return[]}t.exports=n})),uc=o(((e,t)=>{var n=cc(),r=lc(),i=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols;t.exports=a?function(e){return e==null?[]:(e=Object(e),n(a(e),function(t){return i.call(e,t)}))}:r})),dc=o(((e,t)=>{var n=sc(),r=uc(),i=Gs();function a(e){return n(e,i,r)}t.exports=a})),fc=o(((e,t)=>{var n=dc(),r=1,i=Object.prototype.hasOwnProperty;function a(e,t,a,o,s,c){var l=a&r,u=n(e),d=u.length;if(d!=n(t).length&&!l)return!1;for(var f=d;f--;){var p=u[f];if(!(l?p in t:i.call(t,p)))return!1}var m=c.get(e),h=c.get(t);if(m&&h)return m==t&&h==e;var g=!0;c.set(e,t),c.set(t,e);for(var _=l;++f{t.exports=pn()(Zt(),`DataView`)})),mc=o(((e,t)=>{t.exports=pn()(Zt(),`Promise`)})),hc=o(((e,t)=>{t.exports=pn()(Zt(),`WeakMap`)})),J=o(((e,t)=>{var n=pc(),r=kn(),i=mc(),a=Io(),o=hc(),s=tn(),c=un(),l=`[object Map]`,u=`[object Object]`,d=`[object Promise]`,f=`[object Set]`,p=`[object WeakMap]`,m=`[object DataView]`,h=c(n),g=c(r),_=c(i),v=c(a),y=c(o),b=s;(n&&b(new n(new ArrayBuffer(1)))!=m||r&&b(new r)!=l||i&&b(i.resolve())!=d||a&&b(new a)!=f||o&&b(new o)!=p)&&(b=function(e){var t=s(e),n=t==u?e.constructor:void 0,r=n?c(n):``;if(r)switch(r){case h:return m;case g:return l;case _:return d;case v:return f;case y:return p}return t}),t.exports=b})),gc=o(((e,t)=>{var n=tc(),r=rc(),i=oc(),a=fc(),o=J(),s=Xt(),c=Fs(),l=zs(),u=1,d=`[object Arguments]`,f=`[object Array]`,p=`[object Object]`,m=Object.prototype.hasOwnProperty;function h(e,t,h,g,_,v){var y=s(e),b=s(t),x=y?f:o(e),S=b?f:o(t);x=x==d?p:x,S=S==d?p:S;var C=x==p,w=S==p,T=x==S;if(T&&c(e)){if(!c(t))return!1;y=!0,C=!1}if(T&&!C)return v||=new n,y||l(e)?r(e,t,h,g,_,v):i(e,t,x,h,g,_,v);if(!(h&u)){var E=C&&m.call(e,`__wrapped__`),D=w&&m.call(t,`__wrapped__`);if(E||D){var O=E?e.value():e,k=D?t.value():t;return v||=new n,_(O,k,h,g,v)}}return T?(v||=new n,a(e,t,h,g,_,v)):!1}t.exports=h})),_c=o(((e,t)=>{var n=gc(),r=nn();function i(e,t,a,o,s){return e===t?!0:e==null||t==null||!r(e)&&!r(t)?e!==e&&t!==t:n(e,t,a,o,i,s)}t.exports=i})),vc=o(((e,t)=>{var n=tc(),r=_c(),i=1,a=2;function o(e,t,o,s){var c=o.length,l=c,u=!s;if(e==null)return!l;for(e=Object(e);c--;){var d=o[c];if(u&&d[2]?d[1]!==e[d[0]]:!(d[0]in e))return!1}for(;++c{var n=on();function r(e){return e===e&&!n(e)}t.exports=r})),bc=o(((e,t)=>{var n=yc(),r=Gs();function i(e){for(var t=r(e),i=t.length;i--;){var a=t[i],o=e[a];t[i]=[a,o,n(o)]}return t}t.exports=i})),xc=o(((e,t)=>{function n(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}t.exports=n})),Sc=o(((e,t)=>{var n=vc(),r=bc(),i=xc();function a(e){var t=r(e);return t.length==1&&t[0][2]?i(t[0][0],t[0][1]):function(r){return r===e||n(r,e,t)}}t.exports=a})),Cc=o(((e,t)=>{var n=Wn(),r=Yn();function i(e,t){t=n(t,e);for(var i=0,a=t.length;e!=null&&i{var n=Cc();function r(e,t,r){var i=e==null?void 0:n(e,t);return i===void 0?r:i}t.exports=r})),Tc=o(((e,t)=>{function n(e,t){return e!=null&&t in Object(e)}t.exports=n})),Ec=o(((e,t)=>{var n=Tc(),r=Xn();function i(e,t){return e!=null&&r(e,t,n)}t.exports=i})),Dc=o(((e,t)=>{var n=_c(),r=wc(),i=Ec(),a=an(),o=yc(),s=xc(),c=Yn(),l=1,u=2;function d(e,t){return a(e)&&o(t)?s(c(e),t):function(a){var o=r(a,e);return o===void 0&&o===t?i(a,e):n(t,o,l|u)}}t.exports=d})),Oc=o(((e,t)=>{function n(e){return e}t.exports=n})),kc=o(((e,t)=>{function n(e){return function(t){return t?.[e]}}t.exports=n})),Ac=o(((e,t)=>{var n=Cc();function r(e){return function(t){return n(t,e)}}t.exports=r})),jc=o(((e,t)=>{var n=kc(),r=Ac(),i=an(),a=Yn();function o(e){return i(e)?n(a(e)):r(e)}t.exports=o})),Mc=o(((e,t)=>{var n=Sc(),r=Dc(),i=Oc(),a=Xt(),o=jc();function s(e){return typeof e==`function`?e:e==null?i:typeof e==`object`?a(e)?r(e[0],e[1]):n(e):o(e)}t.exports=s})),Nc=o(((e,t)=>{var n=As(),r=Ys(),i=Mc(),a=Xt();function o(e,t){return function(o,s){var c=a(o)?n:r,l=t?t():{};return c(o,e,i(s,2),l)}}t.exports=o})),Pc=c(o(((e,t)=>{var n=ks(),r=Nc(),i=Object.prototype.hasOwnProperty;t.exports=r(function(e,t,r){i.call(e,r)?e[r].push(t):n(e,r,[t])})}))(),1);function Fc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){if(_!==void 0||t[t.length-1]!==n[t.length-1])return;let y=es(g);ns(t,c,o,s,a,(n,o,s,c,_)=>{if(n!==t[t.length-1])return;o+=n.width;let b=Math.max(o,c);b>r||(e.save(),e.beginPath(),e.rect(b,a+1,1e4,i-a-1),e.clip(),ts(_,s,i,l,u,m,h,y,(t,n,r,i)=>{if(!i&&g.length>0&&!g.some(e=>os(o,t,1e4,r,e.x,e.y,e.width,e.height)))return;let a=f.hasIndex(n),s=p.hasIndex(n);e.beginPath();let c=d?.(n),l=c===void 0?v:yo(v,c);l.bgCell!==v.bgCell&&(e.fillStyle=l.bgCell,e.fillRect(o,t,1e4,r)),s&&(e.fillStyle=l.bgHeader,e.fillRect(o,t,1e4,r)),a&&(e.fillStyle=l.accentLight,e.fillRect(o,t,1e4,r))}),e.restore())})}function Ic(e,t,n,r,i,a,o,s,c){let l=!1;for(let e of t)if(!e.sticky){l=o(e.sourceIndex);break}let u=c.horizontalBorderColor??c.borderColor,d=c.borderColor,f=l?Na(t):0,p;if(f!==0&&(p=fa(d,c.bgCell),e.beginPath(),e.moveTo(f+.5,0),e.lineTo(f+.5,r),e.strokeStyle=p,e.stroke()),i>0){let t=d===u&&p!==void 0?p:fa(u,c.bgCell),o=Pa(a,i,s);e.beginPath(),e.moveTo(0,r-o+.5),e.lineTo(n,r-o+.5),e.strokeStyle=t,e.stroke()}}var Lc=(e,t,n)=>{let r=0,i=t,a=0,o=n;if(e!==void 0&&e.length>0){r=2**53-1,a=2**53-1,i=-(2**53-1),o=-(2**53-1);for(let t of e)r=Math.min(r,t.x-1),i=Math.max(i,t.x+t.width+1),a=Math.min(a,t.y-1),o=Math.max(o,t.y+t.height+1)}return{minX:r,maxX:i,minY:a,maxY:o}};function Rc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){let h=m.bgCell,{minX:g,maxX:_,minY:v,maxY:y}=Lc(s,a,o),b=[],x=o-Pa(p,f,l),S=c,C=n,w=0;for(;S+i=v&&e<=y-1){let n=u?.(C)?.bgCell;n!==void 0&&n!==h&&C>=p-f&&b.push({x:g,y:e,w:_-g,h:t,color:n})}S+=t,C0)for(let e=0;e=g&&i<=_&&d(e+1)&&b.push({x:i,y:w,w:n.width,h:E,color:a}),T+=n.width}if(b.length===0)return;let D;e.beginPath();for(let t=b.length-1;t>=0;t--){let n=b[t];D===void 0?D=n.color:n.color!==D&&(e.fillStyle=D,e.fill(),e.beginPath(),D=n.color),e.rect(n.x,n.y,n.w,n.h)}D!==void 0&&(e.fillStyle=D,e.fill()),e.beginPath()}function zc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_=!1){if(c!==void 0){e.beginPath(),e.save(),e.rect(0,0,a,o);for(let t of c)e.rect(t.x+1,t.y+1,t.width-1,t.height-1);e.clip(`evenodd`)}let v=g.horizontalBorderColor??g.borderColor,y=g.borderColor,{minX:b,maxX:x,minY:S,maxY:C}=Lc(s,a,o),w=[];e.beginPath();let T=.5;for(let e=0;e=b&&i<=x&&p(e+1)&&w.push({x1:i,y1:Math.max(l,S),x2:i,y2:Math.min(o,C),color:y})}let E=o+.5;for(let e=h-m;e=S&&n<=C-1){let e=f?.(t);w.push({x1:b,y1:n,x2:x,y2:n,color:e?.horizontalBorderColor??e?.borderColor??v})}e+=d(t),t++}}let D=(0,Pc.default)(w,e=>e.color);for(let t of Object.keys(D)){e.strokeStyle=t;for(let n of D[t])e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2);e.stroke(),e.beginPath()}c!==void 0&&e.restore()}function Bc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let y=[];e.imageSmoothingEnabled=!1;let b=Math.min(i.cellYOffset,o),x=Math.max(i.cellYOffset,o),S=0;if(typeof _==`number`)S+=(x-b)*_;else for(let e=b;ei.cellYOffset&&(S=-S),S+=c-i.translateY;let C=Math.min(i.cellXOffset,a),w=Math.max(i.cellXOffset,a),T=0;for(let e=C;ei.cellXOffset&&(T=-T),T+=s-i.translateX;let E=Na(g);if(T!==0&&S!==0)return{regions:[]};let D=l>0?Pa(f,l,_):0,O=u-E-Math.abs(T),k=d-p-D-Math.abs(S)-1;if(O>150&&k>150){let i={sx:0,sy:0,sw:u*m,sh:d*m,dx:0,dy:0,dw:u*m,dh:d*m};if(S>0?(i.sy=(p+1)*m,i.sh=k*m,i.dy=(S+p+1)*m,i.dh=k*m,y.push({x:0,y:p,width:u,height:S+1})):S<0&&(i.sy=(-S+p+1)*m,i.sh=k*m,i.dy=(p+1)*m,i.dh=k*m,y.push({x:0,y:d+S-D,width:u,height:-S+D})),T>0?(i.sx=E*m,i.sw=O*m,i.dx=(T+E)*m,i.dw=O*m,y.push({x:E-1,y:0,width:T+2,height:d})):T<0&&(i.sx=(E-T)*m,i.sw=O*m,i.dx=E*m,i.dw=O*m,y.push({x:u+T,y:0,width:-T,height:d})),e.setTransform(1,0,0,1,0,0),v){if(E>0&&T!==0&&S===0&&(r===void 0||n?.[1]!==!1)){let n=E*m,r=d*m;e.drawImage(t,0,0,n,r,0,0,n,r)}if(D>0&&T===0&&S!==0&&(r===void 0||n?.[0]!==!1)){let n=(d-D)*m,r=u*m,i=D*m;e.drawImage(t,0,n,r,i,0,n,r,i)}}e.drawImage(t,i.sx,i.sy,i.sw,i.sh,i.dx,i.dy,i.dw,i.dh),e.scale(m,m)}return e.imageSmoothingEnabled=!0,{regions:y}}function Vc(e,t,n,r,i,a,o,s,c,l){let u=[];return t!==e.cellXOffset||n!==e.cellYOffset||r!==e.translateX||i!==e.translateY||ns(c,n,r,i,s,(e,t,n,r)=>{if(e.sourceIndex===l){let e=Math.max(t,r)+1;return u.push({x:e,y:0,width:a-e,height:o}),!0}}),u}function Hc(e,t){if(t===void 0||e.width!==t.width||e.height!==t.height||e.theme!==t.theme||e.headerHeight!==t.headerHeight||e.rowHeight!==t.rowHeight||e.rows!==t.rows||e.freezeColumns!==t.freezeColumns||e.getRowThemeOverride!==t.getRowThemeOverride||e.isFocused!==t.isFocused||e.isResizing!==t.isResizing||e.verticalBorder!==t.verticalBorder||e.getCellContent!==t.getCellContent||e.highlightRegions!==t.highlightRegions||e.selection!==t.selection||e.dragAndDropState!==t.dragAndDropState||e.prelightCells!==t.prelightCells||e.touchMode!==t.touchMode||e.maxScaleFactor!==t.maxScaleFactor)return!1;if(e.mappedColumns!==t.mappedColumns){if(e.mappedColumns.length>100||e.mappedColumns.length!==t.mappedColumns.length)return!1;let n;for(let r=0;re.style!==`no-outline`);if(g===void 0||g.length===0)return;let _=Na(s),v=Pa(p,f,d),y=[c,0,s.length,p-f],b=[_,0,t,n-v],x=g.map(e=>{let m=e.range,h=e.style??`dashed`;return ds(m,y,t,n,b).map(m=>{let g=m.rect,_=ao(g.x,g.y,t,n,u,l+u,r,i,a,o,p,c,f,s,d),v=g.width===1&&g.height===1?_:ao(g.x+g.width-1,g.y+g.height-1,t,n,u,l+u,r,i,a,o,p,c,f,s,d);return g.x+g.width>=s.length&&--v.width,g.y+g.height>=p&&--v.height,{color:e.color,style:h,clip:m.clip,rect:us({x:_.x,y:_.y,width:v.x+v.width-_.x,height:v.y+v.height-_.y},t,n,8)}})}),S=()=>{e.lineWidth=1;let r=!1;for(let i of x)for(let a of i)if(a?.rect!==void 0&&os(0,0,t,n,a.rect.x,a.rect.y,a.rect.width,a.rect.height)){let t=r,n=!ls(a.clip,a.rect);n&&(e.save(),e.rect(a.clip.x,a.clip.y,a.clip.width,a.clip.height),e.clip()),a.style===`dashed`&&!r?(e.setLineDash([5,3]),r=!0):(a.style===`solid`||a.style===`solid-outline`)&&r&&(e.setLineDash([]),r=!1),e.strokeStyle=a.style===`solid-outline`?pa(pa(a.color,h.borderColor),h.bgCell):ua(a.color,1),e.strokeRect(a.rect.x+.5,a.rect.y+.5,a.rect.width-1,a.rect.height-1),n&&(e.restore(),r=t)}r&&e.setLineDash([])};return S(),S}function Wc(e,t,n,r,i){e.beginPath(),e.moveTo(t,n),e.lineTo(t,r),e.lineWidth=2,e.strokeStyle=i,e.stroke(),e.globalAlpha=1}function Gc(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g){if(u.current===void 0)return;let _=u.current.range,v=u.current.cell,y=[_.x+_.width-1,_.y+_.height-1];if(v[1]>=g&&y[1]>=g||!o.some(e=>e.sourceIndex===v[0]||e.sourceIndex===y[0]))return;let[b,x]=u.current.cell,S=f(u.current.cell),C=S.span??[b,b],w=x>=g-p,T=p>0&&!w?Pa(g,p,d)-1:0,E=y[1],D;if(ns(o,r,i,a,l,(r,i,a,o,l)=>{if(r.sticky&&b>r.sourceIndex)return;let u=r.sourceIndexC[1],_=r.sourceIndex===y[0];if(_||!u&&!f)return ts(l,a,n,g,d,p,m,void 0,(a,l,u)=>{if(l!==x&&l!==E)return;let d=i,f=r.width;if(S.span!==void 0){let e=is(S.span,i,a,r.width,u,r,s),t=r.sticky?e[0]:e[1];t!==void 0&&(d=t.x,f=t.width)}return l===E&&_&&h&&(D=()=>{o>d&&!r.sticky&&(e.beginPath(),e.rect(o,0,t-o,n),e.clip()),e.beginPath(),e.rect(d+f-4,a+u-4,4,4),e.fillStyle=r.themeOverride?.accentColor??c.accentColor,e.fill()}),D!==void 0}),D!==void 0}),D===void 0)return;let O=()=>{e.save(),e.beginPath(),e.rect(0,l,t,n-l-T),e.clip(),D?.(),e.restore()};return O(),O}function Kc(e,t,n,r,i,a,o,s,c){c!==void 0&&c.size!==0&&(e.beginPath(),rs(t,n,a,r,(t,n,r,i,a,o)=>{c.hasItemInRectangle({x:t[0],y:-2,width:t[1]-t[0]+1,height:1})&&e.rect(r,i,a,o)}),ns(t,s,a,o,i,(t,n,a,o)=>{let s=Math.max(0,o-n),l=n+s+1,u=t.width-s-1;c.has([t.sourceIndex,-1])&&e.rect(l,r,u,i-r)}),e.clip())}function qc(e,t,n,r,i,a,o,s,c,l){let u=0;return ns(e,a,r,i,n,(e,n,r,i,a)=>(ts(a,r,t,o,s,c,l,void 0,(e,t,n,r)=>{r||(u=Math.max(t,u))}),!0)),u}function Jc(e,t){let{canvasCtx:n,headerCanvasCtx:r,width:i,height:a,cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mappedColumns:u,enableGroups:d,freezeColumns:f,dragAndDropState:p,theme:m,drawFocus:h,headerHeight:g,groupHeaderHeight:_,disabledRows:v,rowHeight:y,verticalBorder:b,overrideCursor:x,isResizing:S,selection:C,fillHandle:w,freezeTrailingRows:T,rows:E,getCellContent:D,getGroupDetails:O,getRowThemeOverride:k,isFocused:A,drawHeaderCallback:ee,prelightCells:te,drawCellCallback:ne,highlightRegions:re,resizeCol:j,imageLoader:ie,lastBlitData:M,hoverValues:ae,hyperWrapping:N,hoverInfo:oe,spriteManager:P,maxScaleFactor:se,hasAppendRow:ce,touchMode:F,enqueue:le,renderStateProvider:ue,getCellRenderer:de,renderStrategy:fe,bufferACtx:pe,bufferBCtx:me,damage:he,minimumCellWidth:ge}=e;if(i===0||a===0)return;let I=fe===`double-buffer`,L=Math.min(se,Math.ceil(window.devicePixelRatio??1)),_e=fe!==`direct`&&Hc(e,t),R=n.canvas;(R.width!==i*L||R.height!==a*L)&&(R.width=i*L,R.height=a*L,R.style.width=i+`px`,R.style.height=a+`px`);let ve=r.canvas,ye=d?_+g:g,be=ye+1;(ve.width!==i*L||ve.height!==be*L)&&(ve.width=i*L,ve.height=be*L,ve.style.width=i+`px`,ve.style.height=be+`px`);let xe=pe.canvas,Se=me.canvas;I&&(xe.width!==i*L||xe.height!==a*L)&&(xe.width=i*L,xe.height=a*L,M.current!==void 0&&(M.current.aBufferScroll=void 0)),I&&(Se.width!==i*L||Se.height!==a*L)&&(Se.width=i*L,Se.height=a*L,M.current!==void 0&&(M.current.bBufferScroll=void 0));let z=M.current;if(_e===!0&&o===z?.cellXOffset&&s===z?.cellYOffset&&c===z?.translateX&&l===z?.translateY)return;let Ce=null;I&&(Ce=n);let we=r,B;B=I?he===void 0?z?.lastBuffer===`b`?pe:me:z?.lastBuffer===`b`?me:pe:n;let Te=B.canvas,Ee=I?Te===xe?Se:xe:R,De=typeof y==`number`?()=>y:y;we.save(),B.save(),we.beginPath(),B.beginPath(),we.textBaseline=`middle`,B.textBaseline=`middle`,L!==1&&(we.scale(L,L),B.scale(L,L));let Oe=Fa(u,o,i,p,c),ke=[],Ae=h&&C.current?.cell[1]===s&&l===0,je=!1;if(re!==void 0){for(let e of re)if(e.style!==`no-outline`&&e.range.y===s&&l===0){je=!0;break}}let Me=()=>{xs(we,Oe,d,oe,i,c,g,_,p,S,C,m,P,ae,b,O,he,ee,F),zc(we,Oe,s,c,l,i,a,void 0,void 0,_,ye,De,k,b,T,E,m,!0),we.beginPath(),we.moveTo(0,be-.5),we.lineTo(i,be-.5),we.strokeStyle=pa(m.headerBottomBorderColor??m.horizontalBorderColor??m.borderColor,m.bgHeader),we.stroke(),je&&Uc(we,i,a,o,s,c,l,u,f,g,_,y,T,E,re,m),Ae&&Gc(we,i,a,s,c,l,Oe,u,m,ye,C,De,D,T,ce,w,E)};if(he!==void 0){let e=Oe[Oe.length-1].sourceIndex+1,t=he.hasItemInRegion([{x:o,y:-2,width:e,height:2},{x:o,y:s,width:e,height:300},{x:0,y:s,width:f,height:300},{x:0,y:-2,width:f,height:2},{x:o,y:E-T,width:e,height:T,when:T>0}]),n=e=>{ps(e,Oe,u,a,ye,c,l,s,E,De,D,O,k,v,A,h,T,ce,ke,he,C,te,re,ie,P,ae,oe,ne,N,m,le,ue,de,x,ge);let t=C.current;w&&h&&t!==void 0&&he.has(ka(t.range))&&Gc(e,i,a,s,c,l,Oe,u,m,ye,C,De,D,T,ce,w,E)};t&&(n(B),Ce!==null&&(Ce.save(),Ce.scale(L,L),Ce.textBaseline=`middle`,n(Ce),Ce.restore()),he.hasHeader()&&(Kc(we,Oe,i,_,ye,c,l,s,he),Me())),B.restore(),we.restore();return}if((_e!==!0||o!==z?.cellXOffset||c!==z?.translateX||Ae!==z?.mustDrawFocusOnHeader||je!==z?.mustDrawHighlightRingsOnHeader)&&Me(),_e===!0){Wt(Ee!==void 0&&z!==void 0);let{regions:e}=Bc(B,Ee,Ee===xe?z.aBufferScroll:z.bBufferScroll,Ee===xe?z.bBufferScroll:z.aBufferScroll,z,o,s,c,l,T,i,a,E,ye,L,u,Oe,y,I);ke=e}else _e!==!1&&(Wt(z!==void 0),ke=Vc(z,o,s,c,l,i,a,ye,Oe,_e));Ic(B,Oe,i,a,T,E,b,De,m);let Ne=Uc(B,i,a,o,s,c,l,u,f,g,_,y,T,E,re,m),Pe=h?Gc(B,i,a,s,c,l,Oe,u,m,ye,C,De,D,T,ce,w,E):void 0;if(B.fillStyle=m.bgCell,ke.length>0){B.beginPath();for(let e of ke)B.rect(e.x,e.y,e.width,e.height);B.clip(),B.fill(),B.beginPath()}else B.fillRect(0,0,i,a);let Fe=ps(B,Oe,u,a,ye,c,l,s,E,De,D,O,k,v,A,h,T,ce,ke,he,C,te,re,ie,P,ae,oe,ne,N,m,le,ue,de,x,ge);Fc(B,Oe,u,i,a,ye,c,l,s,E,De,k,C.rows,v,T,ce,ke,he,m),Rc(B,Oe,s,c,l,i,a,ke,ye,De,k,b,T,E,m),zc(B,Oe,s,c,l,i,a,ke,Fe,_,ye,De,k,b,T,E,m),Ne?.(),Pe?.(),S&&ns(Oe,0,c,0,ye,(e,t)=>e.sourceIndex===j&&(Wc(we,t+e.width,0,ye+1,pa(m.resizeIndicatorColor??m.accentLight,m.bgHeader)),Wc(B,t+e.width,ye,a,pa(m.resizeIndicatorColor??m.accentLight,m.bgCell)),!0)),Ce!==null&&(Ce.fillStyle=m.bgCell,Ce.fillRect(0,0,i,a),Ce.drawImage(B.canvas,0,0));let Ie=qc(Oe,a,ye,c,l,s,E,De,T,ce);ie?.setWindow({x:o,y:s,width:Oe.length,height:Ie-s},f,Array.from({length:T},(e,t)=>E-1-t));let Le=z!==void 0&&(o!==z.cellXOffset||c!==z.translateX),Re=z!==void 0&&(s!==z.cellYOffset||l!==z.translateY);M.current={cellXOffset:o,cellYOffset:s,translateX:c,translateY:l,mustDrawFocusOnHeader:Ae,mustDrawHighlightRingsOnHeader:je,lastBuffer:I?Te===xe?`a`:`b`:void 0,aBufferScroll:Te===xe?[Le,Re]:z?.aBufferScroll,bBufferScroll:Te===Se?[Le,Re]:z?.bBufferScroll},B.restore(),we.restore()}var Yc=c(To(),1),Xc=80;function Zc(e){let t=e-1;return t*t*t+1}var Qc=class{callback;constructor(e){this.callback=e}currentHoveredItem=void 0;leavingItems=[];lastAnimationTime;addToLeavingItems=e=>{this.leavingItems.some(t=>Oa(t.item,e.item))||this.leavingItems.push(e)};removeFromLeavingItems=e=>{let t=this.leavingItems.find(t=>Oa(t.item,e));return this.leavingItems=this.leavingItems.filter(e=>e!==t),t?.hoverAmount??0};cleanUpLeavingElements=()=>{this.leavingItems=this.leavingItems.filter(e=>e.hoverAmount>0)};shouldStep=()=>{let e=this.leavingItems.length>0,t=this.currentHoveredItem!==void 0&&this.currentHoveredItem.hoverAmount<1;return e||t};getAnimatingItems=()=>this.currentHoveredItem===void 0?this.leavingItems.map(e=>({...e,hoverAmount:Zc(e.hoverAmount)})):[...this.leavingItems,this.currentHoveredItem];step=e=>{if(this.lastAnimationTime===void 0)this.lastAnimationTime=e;else{let t=(e-this.lastAnimationTime)/Xc;for(let e of this.leavingItems)e.hoverAmount=(0,Yc.default)(e.hoverAmount-t,0,1);this.currentHoveredItem!==void 0&&(this.currentHoveredItem.hoverAmount=(0,Yc.default)(this.currentHoveredItem.hoverAmount+t,0,1));let n=this.getAnimatingItems();this.callback(n),this.cleanUpLeavingElements()}this.shouldStep()?(this.lastAnimationTime=e,window.requestAnimationFrame(this.step)):this.lastAnimationTime=void 0};setHovered=e=>{if(!Oa(this.currentHoveredItem?.item,e)){if(this.currentHoveredItem!==void 0&&this.addToLeavingItems(this.currentHoveredItem),e!==void 0){let t=this.removeFromLeavingItems(e);this.currentHoveredItem={item:e,hoverAmount:t}}else this.currentHoveredItem=void 0;this.lastAnimationTime===void 0&&window.requestAnimationFrame(this.step)}}},$c=class{fn;val;constructor(e){this.fn=e}get value(){return this.val??=this.fn()}};function el(e){return new $c(e)}var tl=el(()=>window.navigator.userAgent.includes(`Firefox`)),nl=el(()=>window.navigator.userAgent.includes(`Mac OS`)&&window.navigator.userAgent.includes(`Safari`)&&!window.navigator.userAgent.includes(`Chrome`)),rl=el(()=>window.navigator.platform.toLowerCase().startsWith(`mac`));function il(e){let t=g.useRef([]),n=g.useRef(0),r=g.useRef(e);r.current=e;let i=g.useCallback(()=>{let e=()=>window.requestAnimationFrame(i),i=()=>{let e=t.current.map(uo);t.current=[],r.current(new mo(e)),t.current.length>0?n.current++:n.current=0};window.requestAnimationFrame(n.current>600?e:i)},[]);return g.useCallback(e=>{t.current.length===0&&i();let n=so(e[0],e[1]);t.current.includes(n)||t.current.push(n)},[i])}var al=`header`,ol=`group-header`,sl=`out-of-bounds`,cl;(function(e){e[e.Start=-2]=`Start`,e[e.StartPadding=-1]=`StartPadding`,e[e.Center=0]=`Center`,e[e.EndPadding=1]=`EndPadding`,e[e.End=2]=`End`})(cl||={});function ll(e,t){return e===t?!0:e?.kind===`out-of-bounds`?e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]&&e?.region[0]===t?.region[0]&&e?.region[1]===t?.region[1]:e?.kind===t?.kind&&e?.location[0]===t?.location[0]&&e?.location[1]===t?.location[1]}var ul=c(Zo(),1),dl=6,fl=(e,t)=>e.kind===W.Custom?e.copyData:(t?.(e))?.getAccessibilityString(e)??``,pl=g.memo(g.forwardRef((e,t)=>{let{width:n,height:r,accessibilityHeight:i,columns:a,cellXOffset:o,cellYOffset:s,headerHeight:c,fillHandle:l=!1,groupHeaderHeight:u,rowHeight:d,rows:f,getCellContent:p,getRowThemeOverride:m,onHeaderMenuClick:h,enableGroups:_,isFilling:v,onCanvasFocused:y,onCanvasBlur:b,isFocused:x,selection:S,freezeColumns:C,onContextMenu:w,freezeTrailingRows:T,fixedShadowX:E=!0,fixedShadowY:D=!0,drawFocusRing:O,onMouseDown:k,onMouseUp:A,onMouseMoveRaw:ee,onMouseMove:te,onItemHovered:ne,dragAndDropState:re,firstColAccessible:j,onKeyDown:ie,onKeyUp:M,highlightRegions:ae,canvasRef:N,onDragStart:oe,onDragEnd:P,eventTargetRef:se,isResizing:ce,resizeColumn:F,isDragging:le,isDraggable:ue=!1,allowResize:de,disabledRows:fe,hasAppendRow:pe,getGroupDetails:me,theme:he,prelightCells:ge,headerIcons:I,verticalBorder:L,drawCell:_e,drawHeader:R,onCellFocused:ve,onDragOverCell:ye,onDrop:be,onDragLeave:xe,imageWindowLoader:Se,smoothScrollX:z=!1,smoothScrollY:Ce=!1,experimental:we,getCellRenderer:B}=e,Te=e.translateX??0,Ee=e.translateY??0,De=Math.max(C,Math.min(a.length-1,o)),Oe=g.useRef(null),ke=Se,Ae=g.useRef(),[je,Me]=g.useState(!1),Ne=g.useRef([]),Pe=g.useRef(),[Fe,Ie]=g.useState(),[Le,Re]=g.useState(),ze=g.useRef(null),[Be,Ve]=g.useState(),[He,Ue]=g.useState(!1),We=g.useRef(He);We.current=He;let Ge=g.useMemo(()=>new $o(I,()=>{ct.current=void 0,ft.current()}),[I]),Ke=_?u+c:c,qe=g.useRef(-1),Je=(we?.enableFirefoxRescaling??!1)&&tl.value,Ye=(we?.enableSafariRescaling??!1)&&nl.value;g.useLayoutEffect(()=>{window.devicePixelRatio!==1&&(Je||Ye)&&(qe.current!==-1&&Me(!0),window.clearTimeout(qe.current),qe.current=window.setTimeout(()=>{Me(!1),qe.current=-1},200))},[s,De,Te,Ee,Je,Ye]);let Xe=Ca(a,C),Ze=E?Na(Xe,re):0,Qe=g.useCallback((e,t,i)=>{let a=e.getBoundingClientRect();if(t>=Xe.length||i>=f)return;let o=a.width/n,c=ao(t,i,n,r,u,Ke,De,s,Te,Ee,f,C,T,Xe,d);return o!==1&&(c.x*=o,c.y*=o,c.width*=o,c.height*=o),c.x+=a.x,c.y+=a.y,c},[n,r,u,Ke,De,s,Te,Ee,f,C,T,Xe,d]),$e=g.useCallback((e,t,i,a)=>{let o=e.getBoundingClientRect(),p=o.width/n,m=(t-o.left)/p,h=(i-o.top)/p,g=Fa(Xe,De,n,void 0,Te),v=0,y=0;a instanceof MouseEvent&&(v=a.button,y=a.buttons);let b=Ia(m,g,Te),x=La(h,r,_,c,u,f,d,s,Ee,T),C=a?.shiftKey===!0,w=a?.ctrlKey===!0,E=a?.metaKey===!0,D=a!==void 0&&!(a instanceof MouseEvent)||a?.pointerType===`touch`,O=[m<0?-1:+(nn||h>r){let i=m>n?1:m<0?-1:0,a=h>r?1:h<0?-1:0,o=i*2,s=a*2;i===0&&(o=b===-1?cl.EndPadding:cl.Center),a===0&&(s=x===void 0?cl.EndPadding:cl.Center);let c=!1;if(b===-1&&x===-1){let n=Qe(e,Xe.length-1,-1);Wt(n!==void 0),c=tn&&mr&&h=0?(r=!0,n=Qe(e,a,x),Wt(n!==void 0),k={kind:_&&x===-2?ol:al,location:[a,x],bounds:n,group:Xe[a].group??``,isEdge:r,shiftKey:C,ctrlKey:w,metaKey:E,isTouch:D,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:O}):k={kind:_&&x===-2?ol:al,group:Xe[b].group??``,location:[b,x],bounds:n,isEdge:r,shiftKey:C,ctrlKey:w,metaKey:E,isTouch:D,localEventX:t-n.x,localEventY:i-n.y,button:v,buttons:y,scrollEdge:O}}else{let n=Qe(e,b,x);Wt(n!==void 0);let r=n!==void 0&&n.x+n.width-t<5,a=!1;if(l&&S.current!==void 0){let n=ka(S.current.range),r=Qe(e,n[0],n[1]);if(r!==void 0){let e=r.x+r.width-2,n=r.y+r.height-2;a=Math.abs(e-t){}),nt=g.useRef(Fe);nt.current=Fe;let[rt,it]=g.useMemo(()=>{let e=document.createElement(`canvas`),t=document.createElement(`canvas`);return e.style.display=`none`,e.style.opacity=`0`,e.style.position=`fixed`,t.style.display=`none`,t.style.opacity=`0`,t.style.position=`fixed`,[e.getContext(`2d`,{alpha:!1}),t.getContext(`2d`,{alpha:!1})]},[]);g.useLayoutEffect(()=>{if(rt!==null&&it!==null)return document.documentElement.append(rt.canvas),document.documentElement.append(it.canvas),()=>{rt.canvas.remove(),it.canvas.remove()}},[rt,it]);let at=g.useMemo(()=>new po,[]),ot=Je&&je?1:Ye&&je?2:5,st=we?.disableMinimumCellWidth===!0?1:10,ct=g.useRef(),lt=g.useRef(null),ut=g.useRef(null),dt=g.useCallback(()=>{let e=Oe.current,t=ze.current;if(e===null||t===null||(lt.current===null&&(lt.current=e.getContext(`2d`,{alpha:!1}),e.width=0,e.height=0),ut.current===null&&(ut.current=t.getContext(`2d`,{alpha:!1}),t.width=0,t.height=0),lt.current===null||ut.current===null||rt===null||it===null))return;let i=!1,a=e=>{i=!0,Ve(e)},o=ct.current,h={headerCanvasCtx:ut.current,canvasCtx:lt.current,bufferACtx:rt,bufferBCtx:it,width:n,height:r,cellXOffset:De,cellYOffset:s,translateX:Math.round(Te),translateY:Math.round(Ee),mappedColumns:Xe,enableGroups:_,freezeColumns:C,dragAndDropState:re,theme:he,headerHeight:c,groupHeaderHeight:u,disabledRows:fe??ur.empty(),rowHeight:d,verticalBorder:L,isResizing:ce,resizeCol:F,isFocused:x,selection:S,fillHandle:l,drawCellCallback:_e,hasAppendRow:pe,overrideCursor:a,maxScaleFactor:ot,freezeTrailingRows:T,rows:f,drawFocus:O,getCellContent:p,getGroupDetails:me??(e=>({name:e})),getRowThemeOverride:m,drawHeaderCallback:R,prelightCells:ge,highlightRegions:ae,imageLoader:ke,lastBlitData:Pe,damage:Ae.current,hoverValues:Ne.current,hoverInfo:nt.current,spriteManager:Ge,scrolling:je,hyperWrapping:we?.hyperWrapping??!1,touchMode:He,enqueue:tt.current,renderStateProvider:at,renderStrategy:we?.renderStrategy??(nl.value?`double-buffer`:`single-buffer`),getCellRenderer:B,minimumCellWidth:st};h.damage===void 0?(ct.current=h,Jc(h,o)):Jc(h,void 0),!i&&(h.damage===void 0||h.damage.has(nt?.current?.[0]))&&Ve(void 0)},[rt,it,n,r,De,s,Te,Ee,Xe,_,C,re,he,c,u,fe,d,L,ce,pe,F,x,S,l,T,f,O,ot,p,me,m,_e,R,ge,ae,ke,Ge,je,we?.hyperWrapping,we?.renderStrategy,He,at,B,st]),ft=g.useRef(dt);g.useLayoutEffect(()=>{dt(),ft.current=dt},[dt]),g.useLayoutEffect(()=>{(async()=>{document?.fonts?.ready!==void 0&&(await document.fonts.ready,ct.current=void 0,ft.current())})()},[]);let pt=g.useCallback(e=>{Ae.current=e,ft.current(),Ae.current=void 0},[]);tt.current=il(pt);let mt=g.useCallback(e=>{pt(new mo(e.map(e=>e.cell)))},[pt]);ke.setCallback(pt);let[ht,gt]=g.useState(!1),[_t,vt]=et??[],yt=_t!==void 0&&vt===-1,bt=_t!==void 0&&vt===-2,xt=!1,St=!1,Ct=Be;if(Ct===void 0&&_t!==void 0&&vt!==void 0&&vt>-1&&vt({contain:`strict`,display:`block`,cursor:wt}),[wt]),V=g.useRef(`default`),Et=se?.current;Et!=null&&V.current!==Tt.cursor&&(Et.style.cursor=V.current=Tt.cursor);let Dt=g.useCallback((e,t,n,r)=>{if(me===void 0)return;let i=me(e);if(i.actions!==void 0){let e=Ts(t,i.actions);for(let[a,o]of e.entries())if(ss(o,n+t.x,r+o.y))return i.actions[a]}},[me]),Ot=g.useCallback((e,t,n,r)=>{let i=a[t];if(!le&&!ce&&i.hasMenu===!0&&!(Le??!1)){let a=Qe(e,t,-1);Wt(a!==void 0);let o=ws(a.x,a.y,a.width,a.height,ri(i.title)===`rtl`);if(n>o.x&&no.y&&r{let t=Oe.current,n=se?.current;if(t===null||e.target!==t&&e.target!==n)return;jt.current=!0;let r,i;if(e instanceof MouseEvent?(r=e.clientX,i=e.clientY):(r=e.touches[0].clientX,i=e.touches[0].clientY),e.target===n&&n!==null){let e=n.getBoundingClientRect();if(r>e.right||i>e.bottom)return}let a=$e(t,r,i,e);At.current=a.location,a.isTouch&&(kt.current=Date.now()),We.current!==a.isTouch&&Ue(a.isTouch),a.kind===`header`&&Ot(t,a.location[0],r,i)!==void 0||a.kind===`group-header`&&Dt(a.group,a.bounds,a.localEventX,a.localEventY)!==void 0||(k?.(a),!a.isTouch&&ue!==!0&&ue!==a.kind&&a.button<3&&a.button!==1&&e.preventDefault())},[se,ue,$e,Dt,Ot,k]);Gr(`touchstart`,Mt,window,!1),Gr(`mousedown`,Mt,window,!1);let Nt=g.useRef(0),Pt=g.useCallback(e=>{let t=Nt.current;Nt.current=Date.now();let n=Oe.current;if(jt.current=!1,A===void 0||n===null)return;let r=se?.current,i=e.target!==n&&e.target!==r,a,o,s=!0;if(e instanceof MouseEvent){if(a=e.clientX,o=e.clientY,s=e.button<3,e.pointerType===`touch`)return}else a=e.changedTouches[0].clientX,o=e.changedTouches[0].clientY;let c=$e(n,a,o,e);c.isTouch&&kt.current!==0&&Date.now()-kt.current>500&&(c={...c,isLongTouch:!0}),t!==0&&Date.now()-t<(c.isTouch?1e3:500)&&(c={...c,isDoubleClick:!0}),We.current!==c.isTouch&&Ue(c.isTouch),!i&&e.cancelable&&s&&e.preventDefault();let[l]=c.location,u=Ot(n,l,a,o);if(c.kind===`header`&&u!==void 0)(c.button!==0||At.current?.[0]!==l||At.current?.[1]!==-1)&&A(c,!0);else{if(c.kind===`group-header`){let e=Dt(c.group,c.bounds,c.localEventX,c.localEventY);if(e!==void 0){c.button===0&&e.onClick(c);return}}A(c,i)}},[A,se,$e,Ot,Dt]);Gr(`mouseup`,Pt,window,!1),Gr(`touchend`,Pt,window,!1),Gr(`click`,g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n=se?.current,r=e.target!==t&&e.target!==n,i,a,o=!0;e instanceof MouseEvent?(i=e.clientX,a=e.clientY,o=e.button<3):(i=e.changedTouches[0].clientX,a=e.changedTouches[0].clientY);let s=$e(t,i,a,e);We.current!==s.isTouch&&Ue(s.isTouch),!r&&e.cancelable&&o&&e.preventDefault();let[c]=s.location,l=Ot(t,c,i,a);if(s.kind===`header`&&l!==void 0)s.button===0&&At.current?.[0]===c&&At.current?.[1]===-1&&h?.(c,l);else if(s.kind===`group-header`){let e=Dt(s.group,s.bounds,s.localEventX,s.localEventY);e!==void 0&&s.button===0&&e.onClick(s)}},[se,$e,Ot,h,Dt]),window,!1),Gr(`contextmenu`,g.useCallback(e=>{let t=Oe.current,n=se?.current;if(t===null||e.target!==t&&e.target!==n||w===void 0)return;let r=$e(t,e.clientX,e.clientY,e);w(r,()=>{e.cancelable&&e.preventDefault()})},[se,$e,w]),se?.current??null,!1);let Ft=g.useCallback(e=>{Ae.current=new mo(e.map(e=>e.item)),Ne.current=e,ft.current(),Ae.current=void 0},[]),It=g.useMemo(()=>new Qc(Ft),[Ft]),Lt=g.useRef(It);Lt.current=It,g.useLayoutEffect(()=>{let e=Lt.current;if(et===void 0||et[1]<0){e.setHovered(et);return}let t=p(et,!0),n=B(t),r=n===void 0&&t.kind===W.Custom||n?.needsHover!==void 0&&(typeof n.needsHover==`boolean`?n.needsHover:n.needsHover(t));e.setHovered(r?et:void 0)},[p,B,et]);let Rt=g.useRef();Gr(`mousemove`,g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n=se?.current,r=e.target!==t&&e.target!==n,i=$e(t,e.clientX,e.clientY,e);if(i.kind!==`out-of-bounds`&&r&&!jt.current&&!i.isTouch)return;let a=(e,t)=>{Ie(n=>n===e||n?.[0][0]===e?.[0][0]&&n?.[0][1]===e?.[0][1]&&(n?.[1][0]===e?.[1][0]&&n?.[1][1]===e?.[1][1]||!t)?n:e)};if(!ll(i,Rt.current))Ve(void 0),ne?.(i),a(i.kind===`out-of-bounds`?void 0:[i.location,[i.localEventX,i.localEventY]],!0),Rt.current=i;else if(i.kind===`cell`||i.kind===`header`||i.kind===`group-header`){let e=!1,t=!0;if(i.kind===`cell`){let n=p(i.location);t=B(n)?.needsHoverPosition??n.kind===W.Custom,e=t}else i.kind===`group-header`&&(e=!0);let n=[i.location,[i.localEventX,i.localEventY]];a(n,t),nt.current=n,e&&pt(new mo([i.location]))}let o=i.location[0]>=+!j;Re(i.kind===`header`&&i.isEdge&&o&&de===!0),gt(i.kind===`cell`&&i.isFillHandle),ee?.(e),te(i)},[se,$e,j,de,ee,te,ne,p,B,pt]),window,!0);let zt=g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n,r;S.current!==void 0&&(n=Qe(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),ie?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[ie,S,Qe]),Bt=g.useCallback(e=>{let t=Oe.current;if(t===null)return;let n,r;S.current!==void 0&&(n=Qe(t,S.current.cell[0],S.current.cell[1]),r=S.current.cell),M?.({bounds:n,stopPropagation:()=>e.stopPropagation(),preventDefault:()=>e.preventDefault(),cancel:()=>void 0,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,altKey:e.altKey,key:e.key,keyCode:e.keyCode,rawEvent:e,location:r})},[M,S,Qe]),Vt=g.useCallback(e=>{Oe.current=e,N!==void 0&&(N.current=e)},[N]);Gr(`dragstart`,g.useCallback(e=>{let t=Oe.current;if(t===null||ue===!1||ce){e.preventDefault();return}let n,r,i=$e(t,e.clientX,e.clientY);if(ue!==!0&&i.kind!==ue){e.preventDefault();return}let a=(e,t)=>{n=e,r=t},o,s,c,l=(e,t,n)=>{o=e,s=t,c=n},u=!1;if(oe?.({...i,setData:a,setDragImage:l,preventDefault:()=>u=!0,defaultPrevented:()=>u}),!u&&n!==void 0&&r!==void 0&&e.dataTransfer!==null){if(e.dataTransfer.setData(n,r),e.dataTransfer.effectAllowed=`copyLink`,o!==void 0&&s!==void 0&&c!==void 0)e.dataTransfer.setDragImage(o,s,c);else{let[n,r]=i.location;if(r!==void 0){let i=document.createElement(`canvas`),a=Qe(t,n,r);Wt(a!==void 0);let o=Math.ceil(window.devicePixelRatio??1);i.width=a.width*o,i.height=a.height*o;let s=i.getContext(`2d`);s!==null&&(s.scale(o,o),s.textBaseline=`middle`,r===-1?(s.font=he.headerFontFull,s.fillStyle=he.bgHeader,s.fillRect(0,0,i.width,i.height),Ds(s,0,0,a.width,a.height,Xe[n],!1,he,!1,!1,0,Ge,R,!1)):(s.font=he.baseFontFull,s.fillStyle=he.bgCell,s.fillRect(0,0,i.width,i.height),ys(s,p([n,r]),0,r,!1,!1,0,0,a.width,a.height,!1,he,he.bgCell,ke,Ge,1,void 0,!1,0,void 0,void 0,void 0,at,B,()=>void 0))),i.style.left=`-100%`,i.style.position=`absolute`,i.style.width=`${a.width}px`,i.style.height=`${a.height}px`,document.body.append(i),e.dataTransfer.setDragImage(i,a.width/2,a.height/2),window.setTimeout(()=>{i.remove()},0)}}}else e.preventDefault()},[ue,ce,$e,oe,Qe,he,Xe,Ge,R,p,ke,at,B]),se?.current??null,!1,!1);let H=g.useRef();Gr(`dragover`,g.useCallback(e=>{let t=Oe.current;if(be!==void 0&&e.preventDefault(),t===null||ye===void 0)return;let[n,r]=$e(t,e.clientX,e.clientY).location,i=n-+!j,[a,o]=H.current??[];(a!==i||o!==r)&&(H.current=[i,r],ye([i,r],e.dataTransfer))},[j,$e,ye,be]),se?.current??null,!1,!1),Gr(`dragend`,g.useCallback(()=>{H.current=void 0,P?.()},[P]),se?.current??null,!1,!1),Gr(`drop`,g.useCallback(e=>{let t=Oe.current;if(t===null||be===void 0)return;e.preventDefault();let[n,r]=$e(t,e.clientX,e.clientY).location,i=n-+!j;be([i,r],e.dataTransfer)},[j,$e,be]),se?.current??null,!1,!1),Gr(`dragleave`,g.useCallback(()=>{xe?.()},[xe]),se?.current??null,!1,!1);let Ht=g.useRef(S);Ht.current=S;let Ut=g.useRef(null),Gt=g.useCallback(e=>{Oe.current!==null&&Oe.current.contains(document.activeElement)&&(e===null&&Ht.current.current!==void 0?N?.current?.focus({preventScroll:!0}):e!==null&&e.focus({preventScroll:!0}),Ut.current=e)},[N]);g.useImperativeHandle(t,()=>({focus:()=>{let e=Ut.current;e===null||!document.contains(e)?N?.current?.focus({preventScroll:!0}):e.focus({preventScroll:!0})},getBounds:(e,t)=>{if(N!==void 0&&N.current!==null)return Qe(N.current,e??0,t??-1)},damage:mt}),[N,mt,Qe]);let Kt=g.useRef(),qt=ti(()=>{if(n<50||we?.disableAccessibilityTree===!0)return null;let e=Fa(Xe,De,n,re,Te),t=j?0:-1;!j&&e[0]?.sourceIndex===0&&(e=e.slice(1));let[r,a]=S.current?.cell??[],o=S.current?.range,c=e.map(e=>e.sourceIndex),l=(0,ul.default)(s,Math.min(f,s+i));return r!==void 0&&a!==void 0&&!(c.includes(r)&&l.includes(a))&&Gt(null),g.createElement(`table`,{key:`access-tree`,role:`grid`,"aria-rowcount":f+1,"aria-multiselectable":`true`,"aria-colcount":Xe.length+t},g.createElement(`thead`,{role:`rowgroup`},g.createElement(`tr`,{role:`row`,"aria-rowindex":1},e.map(e=>g.createElement(`th`,{role:`columnheader`,"aria-selected":S.columns.hasIndex(e.sourceIndex),"aria-colindex":e.sourceIndex+1+t,tabIndex:-1,onFocus:t=>{if(t.target!==Ut.current)return ve?.([e.sourceIndex,-1])},key:e.sourceIndex},e.title)))),g.createElement(`tbody`,{role:`rowgroup`},l.map(n=>g.createElement(`tr`,{role:`row`,"aria-selected":S.rows.hasIndex(n),key:n,"aria-rowindex":n+2},e.map(e=>{let i=e.sourceIndex,s=so(i,n),c=r===i&&a===n,l=o!==void 0&&i>=o.x&&i=o.y&&n{let e=N?.current;if(e!=null)return ie?.({bounds:Qe(e,i,n),cancel:()=>void 0,preventDefault:()=>void 0,stopPropagation:()=>void 0,ctrlKey:!1,key:`Enter`,keyCode:13,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:d})},onFocusCapture:e=>{if(!(e.target===Ut.current||Kt.current?.[0]===i&&Kt.current?.[1]===n))return Kt.current=d,ve?.(d)},ref:c?Gt:void 0,tabIndex:-1},fl(f,B))})))))},[n,Xe,De,re,Te,f,s,i,S,Gt,p,N,ie,Qe,ve],200),Jt=C===0||!E?0:De>C?1:(0,Yc.default)(-Te/100,0,1),Yt=-s*32+Ee,Xt=D?(0,Yc.default)(-Yt/100,0,1):0,U=g.useMemo(()=>{if(!Jt&&!Xt)return null;let e={position:`absolute`,top:0,left:Ze,width:n-Ze,height:r,opacity:Jt,pointerEvents:`none`,transition:z?void 0:`opacity 0.2s`,boxShadow:`inset 13px 0 10px -13px rgba(0, 0, 0, 0.2)`},t={position:`absolute`,top:Ke,left:0,width:n,height:r,opacity:Xt,pointerEvents:`none`,transition:Ce?void 0:`opacity 0.2s`,boxShadow:`inset 0 13px 10px -13px rgba(0, 0, 0, 0.2)`};return g.createElement(g.Fragment,null,Jt>0&&g.createElement(`div`,{id:`shadow-x`,style:e}),Xt>0&&g.createElement(`div`,{id:`shadow-y`,style:t}))},[Jt,Xt,Ze,n,z,Ke,r,Ce]),Zt=g.useMemo(()=>({position:`absolute`,top:0,left:0}),[]);return g.createElement(g.Fragment,null,g.createElement(`canvas`,{"data-testid":`data-grid-canvas`,tabIndex:0,onKeyDown:zt,onKeyUp:Bt,onFocus:y,onBlur:b,ref:Vt,style:Tt},qt),g.createElement(`canvas`,{ref:ze,style:Zt}),U)}));function ml(e,t,n,r){return(0,Yc.default)(Math.round(t-(e.growOffset??0)),Math.ceil(n),Math.floor(r))}var hl=e=>{let[t,n]=g.useState(),[r,i]=g.useState(),[a,o]=g.useState(),[s,c]=g.useState(),[l,u]=g.useState(!1),[d,f]=g.useState(),[p,m]=g.useState(),[h,_]=g.useState(),[v,y]=g.useState(!1),[b,x]=g.useState(),{onHeaderMenuClick:S,getCellContent:C,onColumnMoved:w,onColumnResize:T,onColumnResizeStart:E,onColumnResizeEnd:D,gridRef:O,maxColumnWidth:k,minColumnWidth:A,onRowMoved:ee,lockColumns:te,onColumnProposeMove:ne,onMouseDown:re,onMouseUp:j,onItemHovered:ie,onDragStart:M,canvasRef:ae}=e,N=(T??D??E)!==void 0,{columns:oe,selection:P}=e,se=P.columns,ce=g.useCallback(e=>{let[t,n]=e.location;a!==void 0&&s!==t&&t>=te?(u(!0),c(t)):p!==void 0&&n!==void 0?(y(!0),_(Math.max(0,n))):r===void 0&&!l&&!v&&ie?.(e)},[a,p,s,ie,te,r,l,v]),F=w!==void 0,le=g.useCallback(e=>{if(e.button===0){let[t,r]=e.location;if(e.kind===`out-of-bounds`&&e.isEdge&&N){let e=O?.current?.getBounds(oe.length-1,-1);e!==void 0&&(n(e.x),i(oe.length-1))}else if(e.kind===`header`&&t>=te){let r=ae?.current;if(e.isEdge&&N&&r){n(e.bounds.x),i(t);let a=r.getBoundingClientRect().width/r.offsetWidth,o=e.bounds.width/a;E?.(oe[t],o,t,o+(oe[t].growOffset??0))}else e.kind===`header`&&F&&(f(e.bounds.x),o(t))}else e.kind===`cell`&&te>0&&t===0&&r!==void 0&&ee!==void 0&&(x(e.bounds.y),m(r))}re?.(e)},[re,N,te,ee,O,oe,F,E,ae]),ue=g.useCallback((e,t)=>{l||v||S?.(e,t)},[l,v,S]),de=g.useRef(-1),fe=g.useCallback(()=>{de.current=-1,m(void 0),_(void 0),x(void 0),y(!1),o(void 0),c(void 0),f(void 0),u(!1),i(void 0),n(void 0)},[]),pe=g.useCallback((e,t)=>{if(e.button===0){if(r!==void 0){if(se?.hasIndex(r)===!0)for(let e of se){if(e===r)continue;let t=oe[e],n=ml(t,de.current,A,k);T?.(t,n,e,n+(t.growOffset??0))}let e=ml(oe[r],de.current,A,k);if(D?.(oe[r],e,r,e+(oe[r].growOffset??0)),se.hasIndex(r))for(let e of se){if(e===r)continue;let t=oe[e],n=ml(t,de.current,A,k);D?.(t,n,e,n+(t.growOffset??0))}}fe(),a!==void 0&&s!==void 0&&w?.(a,s),p!==void 0&&h!==void 0&&ee?.(p,h)}j?.(e,t)},[j,r,a,s,p,h,se,D,oe,A,k,T,w,ee,fe]),me=g.useMemo(()=>{if(a!==void 0&&s!==void 0&&a!==s&&ne?.(a,s)!==!1)return{src:a,dest:s}},[a,s,ne]),he=g.useCallback(e=>{let n=ae?.current;if(a!==void 0&&d!==void 0)Math.abs(e.clientX-d)>20&&u(!0);else if(p!==void 0&&b!==void 0)Math.abs(e.clientY-b)>20&&y(!0);else if(r!==void 0&&t!==void 0&&n){let i=n.getBoundingClientRect().width/n.offsetWidth,a=(e.clientX-t)/i,o=oe[r],s=ml(o,a,A,k);if(T?.(o,s,r,s+(o.growOffset??0)),de.current=a,se?.first()===r)for(let e of se){if(e===r)continue;let t=oe[e],n=ml(t,de.current,A,k);T?.(t,n,e,n+(t.growOffset??0))}}},[a,d,p,b,r,t,oe,A,k,T,se,ae]),ge=g.useCallback((e,t)=>{if(p===void 0||h===void 0)return C(e,t);let[n,r]=e;return r===h?r=p:(r>h&&--r,r>=p&&(r+=1)),C([n,r],t)},[p,h,C]),I=g.useCallback(e=>{M?.(e),e.defaultPrevented()||fe()},[fe,M]);return g.createElement(pl,{accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,enableGroups:e.enableGroups,eventTargetRef:e.eventTargetRef,experimental:e.experimental,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,headerIcons:e.headerIcons,height:e.height,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,resizeColumn:r,isDraggable:e.isDraggable,isFilling:e.isFilling,isFocused:e.isFocused,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDrop:e.onDrop,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,width:e.width,getCellContent:ge,isResizing:r!==void 0,onHeaderMenuClick:ue,isDragging:l,onItemHovered:ce,onDragStart:I,onMouseDown:le,allowResize:N,onMouseUp:pe,dragAndDropState:me,onMouseMoveRaw:he,ref:O})};function gl(e){let t=(0,g.useRef)(null),[n,r]=(0,g.useState)({width:e?.[0],height:e?.[1]});return(0,g.useLayoutEffect)(()=>{let e=new window.ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t&&t.contentRect||{};r(t=>t.width===e&&t.height===n?t:{width:e,height:n})}});return t.current&&e.observe(t.current,void 0),()=>{e.disconnect()}},[t.current]),{ref:t,...n}}var _l=(e,t,n)=>{let r=(0,g.useRef)(null),i=(0,g.useRef)(null),a=(0,g.useRef)(null),o=(0,g.useRef)(0),s=(0,g.useRef)(t);s.current=t;let c=n.current;(0,g.useEffect)(()=>{let t=()=>{if(i.current===!1&&c!==null){let e=[c.scrollLeft,c.scrollTop];if(a.current?.[0]===e[0]&&a.current?.[1]===e[1]){if(o.current>10){a.current=null,i.current=null;return}o.current++}else o.current=0,s.current(e[0],e[1]),a.current=e;r.current=window.setTimeout(t,1e3/120)}},n=()=>{i.current=!0,a.current=null,r.current!==null&&(window.clearTimeout(r.current),r.current=null)},l=e=>{e.touches.length===0&&(i.current=!1,o.current=0,r.current=window.setTimeout(t,1e3/120))};if(e&&c!==null){let e=c;return e.addEventListener(`touchstart`,n),e.addEventListener(`touchend`,l),()=>{e.removeEventListener(`touchstart`,n),e.removeEventListener(`touchend`,l),r.current!==null&&window.clearTimeout(r.current)}}},[e,c])},vl=br(`div`)({name:`ScrollRegionStyle`,class:`gdg-s1dgczr6`,propsAsIs:!1,vars:{"s1dgczr6-0":[e=>e.isSafari?`scroll`:`auto`]}});function yl(e){let[t,n]=g.useState(!1),r=typeof window>`u`?null:window,i=g.useRef(0);return Gr(`touchstart`,g.useCallback(()=>{window.clearTimeout(i.current),n(!0)},[]),r,!0,!1),Gr(`touchend`,g.useCallback(t=>{t.touches.length===0&&(i.current=window.setTimeout(()=>n(!1),e))},[e]),r,!0,!1),t}var bl=e=>{let{children:t,clientHeight:n,scrollHeight:r,scrollWidth:i,update:a,draggable:o,className:s,preventDiagonalScrolling:c=!1,paddingBottom:l=0,paddingRight:u=0,rightElement:d,rightElementProps:f,kineticScrollPerfHack:p=!1,scrollRef:m,initialSize:h}=e,_=[],v=f?.sticky??!1,y=f?.fill??!1,b=g.useRef(0),x=g.useRef(0),S=g.useRef(null),C=typeof window>`u`?1:window.devicePixelRatio,w=g.useRef({scrollLeft:0,scrollTop:0,lockDirection:void 0}),T=g.useRef(null),E=yl(200),[D,O]=g.useState(!0),k=g.useRef(0);g.useLayoutEffect(()=>{if(!D||E||w.current.lockDirection===void 0)return;let e=S.current;if(e===null)return;let[t,n]=w.current.lockDirection;t===void 0?n!==void 0&&(e.scrollTop=n):e.scrollLeft=t,w.current.lockDirection=void 0},[E,D]);let A=g.useCallback((e,t)=>{let n=S.current;if(n===null)return;t??=n.scrollTop,e??=n.scrollLeft;let i=w.current.scrollTop,o=w.current.scrollLeft,s=e-o,d=t-i;E&&s!==0&&d!==0&&(Math.abs(s)>3||Math.abs(d)>3)&&c&&w.current.lockDirection===void 0&&(w.current.lockDirection=Math.abs(s)0&&(Math.abs(g)>2e3||h===0||h===_)&&r>n.scrollHeight+5){let e=h/_,t=(r-m)*e;b.current=t-h}f!==void 0&&(window.clearTimeout(k.current),O(!1),k.current=window.setTimeout(()=>O(!0),200)),a({x:e,y:h+b.current,width:p-u,height:m-l,paddingRight:T.current?.clientWidth??0})},[l,u,r,a,c,E]);_l(p&&nl.value,A,S);let ee=g.useRef(A);ee.current=A;let te=g.useRef(),ne=g.useRef(!1);g.useLayoutEffect(()=>{ne.current?A():ne.current=!0},[A,l,u]);let re=g.useCallback(e=>{S.current=e,m!==void 0&&(m.current=e)},[m]),j=0,ie=0;for(_.push(g.createElement(`div`,{key:j++,style:{width:i,height:0}}));ieee.current(),0),te.current={width:ae,height:N}),(ae??0)===0||(N??0)===0?g.createElement(`div`,{ref:M}):g.createElement(`div`,{ref:M},g.createElement(vl,{isSafari:nl.value},g.createElement(`div`,{className:`dvn-underlay`},t),g.createElement(`div`,{ref:re,style:te.current,draggable:o,onDragStart:e=>{o||(e.stopPropagation(),e.preventDefault())},className:`dvn-scroller `+(s??``),onScroll:()=>A()},g.createElement(`div`,{className:`dvn-scroll-inner`+(d===void 0?` dvn-hidden`:``)},g.createElement(`div`,{className:`dvn-stack`},_),d!==void 0&&g.createElement(g.Fragment,null,!y&&g.createElement(`div`,{className:`dvn-spacer`}),g.createElement(`div`,{ref:T,style:{height:N,maxHeight:n-Math.ceil(C%1),position:`sticky`,top:0,paddingLeft:1,marginBottom:-40,marginRight:u,flexGrow:y?1:void 0,right:v?u??0:void 0,pointerEvents:`auto`}},d))))))},xl=e=>{let{columns:t,rows:n,rowHeight:r,headerHeight:i,groupHeaderHeight:a,enableGroups:o,freezeColumns:s,experimental:c,nonGrowWidth:l,clientSize:u,className:d,onVisibleRegionChanged:f,scrollRef:p,preventDiagonalScrolling:m,rightElement:h,rightElementProps:_,overscrollX:v,overscrollY:y,initialSize:b,smoothScrollX:x=!1,smoothScrollY:S=!1,isDraggable:C}=e,{paddingRight:w,paddingBottom:T}=c??{},[E,D]=u,O=g.useRef(),k=g.useRef(),A=g.useRef(),ee=g.useRef(),te=l+Math.max(0,v??0),ne=o?i+a:i;if(typeof r==`number`)ne+=n*r;else for(let e=0;e{if(re.current===void 0)return;let e={...re.current},i=0,a=e.x<0?-e.x:0,o=0,c=0;e.x=e.x<0?0:e.x;let l=0;for(let e=0;e=t+n.width)i+=n.width,c++,o++;else if(e.x>t)i+=n.width,x?a+=t-e.x:c++,o++;else if(e.x+e.width>t)i+=n.width,o++;else break}let u=0,d=0,p=0;if(typeof r==`number`)S?(d=Math.floor(e.y/r),u=d*r-e.y):d=Math.ceil(e.y/r),p=Math.ceil(e.height/r)+d,u<0&&p++;else{let t=0;for(let i=0;i=t+n)t+=n,d++,p++;else if(e.y>a)t+=n,S?u+=a-e.y:d++,p++;else if(e.y+e.height>n/2+t)t+=n,p++;else break}}let m={x:c,y:d,width:o-c,height:p-d},h=O.current;(h===void 0||h.y!==m.y||h.x!==m.x||h.height!==m.height||h.width!==m.width||k.current!==a||A.current!==u||e.width!==ee.current?.[0]||e.height!==ee.current?.[1])&&(f?.({x:c,y:d,width:o-c,height:p-d},e.width,e.height,e.paddingRight??0,a,u),O.current=m,k.current=a,A.current=u,ee.current=[e.width,e.height])},[t,r,n,f,s,x,S]),ie=g.useCallback(e=>{re.current=e,j()},[j]);return g.useEffect(()=>{j()},[j]),g.createElement(bl,{scrollRef:p,className:d,kineticScrollPerfHack:c?.kineticScrollPerfHack,preventDiagonalScrolling:m,draggable:C===!0||typeof C==`string`,scrollWidth:te+(w??0),scrollHeight:ne+(T??0),clientHeight:D,rightElement:h,paddingBottom:T,paddingRight:w,rightElementProps:_,update:ie,initialSize:b},g.createElement(hl,{eventTargetRef:p,width:E,height:D,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,prelightCells:e.prelightCells,rowHeight:e.rowHeight,rows:e.rows,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,onColumnProposeMove:e.onColumnProposeMove,verticalBorder:e.verticalBorder,drawFocusRing:e.drawFocusRing,drawHeader:e.drawHeader,drawCell:e.drawCell,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}))},Sl=br(`div`)({name:`SearchWrapper`,class:`gdg-seveqep`,propsAsIs:!1}),Cl=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 244l144-144 144 144M256 120v292`})),wl=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`48`,d:`M112 268l144 144 144-144M256 392V100`})),Tl=g.createElement(`svg`,{className:`button-icon`,viewBox:`0 0 512 512`},g.createElement(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:`32`,d:`M368 368L144 144M368 144L144 368`})),El=10,Dl=e=>{let{canvasRef:t,cellYOffset:n,rows:r,columns:i,searchInputRef:a,searchValue:o,searchResults:s,onSearchValueChange:c,getCellsForSelection:l,onSearchResultsChanged:u,showSearch:d=!1,onSearchClose:f}=e,[p]=g.useState(()=>`search-box-`+Math.round(Math.random()*1e3)),[m,h]=g.useState(``),_=o??m,v=g.useCallback(e=>{h(e),c?.(e)},[c]),[y,b]=g.useState(),x=g.useRef(y);x.current=y,g.useEffect(()=>{s!==void 0&&(s.length>0?b(e=>({rowsSearched:r,results:s.length,selectedIndex:e?.selectedIndex??-1})):b(void 0))},[r,s]);let S=g.useRef();S.current===void 0&&(S.current=new AbortController);let C=g.useRef(),[w,T]=g.useState([]),E=s??w,D=g.useCallback(()=>{C.current!==void 0&&(window.cancelAnimationFrame(C.current),C.current=void 0,S.current.abort())},[]),O=g.useRef(n);O.current=n;let k=g.useCallback(e=>{let t=new RegExp(e.replace(/([$()*+.?[\\\]^{|}-])/g,`\\$1`),`i`),n=O.current,a=Math.min(10,r),o=0;b(void 0),T([]);let s=[],c=async()=>{if(l===void 0)return;let e=performance.now(),d=r-o,f=l({x:0,y:n,width:i.length,height:Math.min(a,d,r-n)},S.current.signal);typeof f==`function`&&(f=await f());let p=!1;for(let[e,r]of f.entries())for(let[i,a]of r.entries()){let r;switch(a.kind){case W.Text:case W.Number:r=a.displayData;break;case W.Uri:case W.Markdown:r=a.data;break;case W.Boolean:r=typeof a.data==`boolean`?a.data.toString():void 0;break;case W.Image:case W.Bubble:r=a.data.join(`🐳`);break;case W.Custom:r=a.copyData}r!==void 0&&t.test(r)&&(s.push([i,e+n]),p=!0)}let m=performance.now();p&&T([...s]),o+=f.length,Wt(o<=r);let h=x.current?.selectedIndex??-1;b({results:s.length,rowsSearched:o,selectedIndex:h}),u?.(s,h),n+a>=r?n=0:n+=a;let g=m-e,_=El/Math.max(g,1);a=Math.ceil(a*_),o{f?.(),b(void 0),T([]),u?.([],-1),D(),t?.current?.focus()},[D,t,f,u]),ee=g.useCallback(e=>{v(e.target.value),s===void 0&&(e.target.value===``?(b(void 0),T([]),D()):k(e.target.value))},[k,D,v,s]);g.useEffect(()=>{d&&a.current!==null&&(v(``),a.current.focus({preventScroll:!0}))},[d,a,v]);let te=g.useCallback(e=>{if(e?.stopPropagation?.(),y===void 0)return;let t=(y.selectedIndex+1)%y.results;b({...y,selectedIndex:t}),u?.(E,t)},[y,u,E]),ne=g.useCallback(e=>{if(e?.stopPropagation?.(),y===void 0)return;let t=(y.selectedIndex-1)%y.results;t<0&&(t+=y.results),b({...y,selectedIndex:t}),u?.(E,t)},[u,E,y]),re=g.useCallback(e=>{(e.ctrlKey||e.metaKey)&&e.nativeEvent.code===`KeyF`||e.key===`Escape`?(A(),e.stopPropagation(),e.preventDefault()):e.key===`Enter`&&(e.shiftKey?ne():te())},[A,te,ne]);g.useEffect(()=>()=>{D()},[D]);let[j,ie]=g.useState(!1);g.useEffect(()=>{if(d)ie(!0);else{let e=setTimeout(()=>ie(!1),150);return()=>clearTimeout(e)}},[d]);let M=g.useMemo(()=>{if(!d&&!j)return null;let e;y!==void 0&&(e=y.results>=1e3?`over 1000`:`${y.results} result${y.results===1?``:`s`}`,y.selectedIndex>=0&&(e=`${y.selectedIndex+1} of ${e}`));let t=e=>{e.stopPropagation()},n={width:`${Math.floor((y?.rowsSearched??0)/r*100)}%`};return g.createElement(Sl,{className:d?``:`out`,onMouseDown:t,onMouseMove:t,onMouseUp:t,onClick:t},g.createElement(`div`,{className:`gdg-search-bar-inner`},g.createElement(`input`,{id:p,"aria-hidden":!d,"data-testid":`search-input`,ref:a,onChange:ee,value:_,tabIndex:d?void 0:-1,onKeyDownCapture:re}),g.createElement(`button`,{"aria-label":`Previous Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:ne,disabled:(y?.results??0)===0},Cl),g.createElement(`button`,{"aria-label":`Next Result`,"aria-hidden":!d,tabIndex:d?void 0:-1,onClick:te,disabled:(y?.results??0)===0},wl),f!==void 0&&g.createElement(`button`,{"aria-label":`Close Search`,"aria-hidden":!d,"data-testid":`search-close-button`,tabIndex:d?void 0:-1,onClick:A},Tl)),y===void 0?g.createElement(`div`,{className:`gdg-search-status`},g.createElement(`label`,{htmlFor:p},`Type to search`)):g.createElement(g.Fragment,null,g.createElement(`div`,{className:`gdg-search-status`},g.createElement(`div`,{"data-testid":`search-result-area`},e)),g.createElement(`div`,{className:`gdg-search-progress`,style:n})))},[d,j,y,r,p,a,ee,_,re,ne,te,f,A]);return g.createElement(g.Fragment,null,g.createElement(xl,{prelightCells:E,accessibilityHeight:e.accessibilityHeight,canvasRef:e.canvasRef,cellXOffset:e.cellXOffset,cellYOffset:e.cellYOffset,className:e.className,clientSize:e.clientSize,columns:e.columns,disabledRows:e.disabledRows,enableGroups:e.enableGroups,fillHandle:e.fillHandle,firstColAccessible:e.firstColAccessible,nonGrowWidth:e.nonGrowWidth,fixedShadowX:e.fixedShadowX,fixedShadowY:e.fixedShadowY,freezeColumns:e.freezeColumns,getCellContent:e.getCellContent,getCellRenderer:e.getCellRenderer,getGroupDetails:e.getGroupDetails,getRowThemeOverride:e.getRowThemeOverride,groupHeaderHeight:e.groupHeaderHeight,headerHeight:e.headerHeight,highlightRegions:e.highlightRegions,imageWindowLoader:e.imageWindowLoader,initialSize:e.initialSize,isFilling:e.isFilling,isFocused:e.isFocused,lockColumns:e.lockColumns,maxColumnWidth:e.maxColumnWidth,minColumnWidth:e.minColumnWidth,onHeaderMenuClick:e.onHeaderMenuClick,onMouseMove:e.onMouseMove,onVisibleRegionChanged:e.onVisibleRegionChanged,overscrollX:e.overscrollX,overscrollY:e.overscrollY,preventDiagonalScrolling:e.preventDiagonalScrolling,rightElement:e.rightElement,rightElementProps:e.rightElementProps,rowHeight:e.rowHeight,rows:e.rows,scrollRef:e.scrollRef,selection:e.selection,theme:e.theme,freezeTrailingRows:e.freezeTrailingRows,hasAppendRow:e.hasAppendRow,translateX:e.translateX,translateY:e.translateY,verticalBorder:e.verticalBorder,onColumnProposeMove:e.onColumnProposeMove,drawFocusRing:e.drawFocusRing,drawCell:e.drawCell,drawHeader:e.drawHeader,experimental:e.experimental,gridRef:e.gridRef,headerIcons:e.headerIcons,isDraggable:e.isDraggable,onCanvasBlur:e.onCanvasBlur,onCanvasFocused:e.onCanvasFocused,onCellFocused:e.onCellFocused,onColumnMoved:e.onColumnMoved,onColumnResize:e.onColumnResize,onColumnResizeEnd:e.onColumnResizeEnd,onColumnResizeStart:e.onColumnResizeStart,onContextMenu:e.onContextMenu,onDragEnd:e.onDragEnd,onDragLeave:e.onDragLeave,onDragOverCell:e.onDragOverCell,onDragStart:e.onDragStart,onDrop:e.onDrop,onItemHovered:e.onItemHovered,onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onRowMoved:e.onRowMoved,smoothScrollX:e.smoothScrollX,smoothScrollY:e.smoothScrollY}),M)},Ol=class extends g.PureComponent{wrapperRef=g.createRef();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)}clickOutside=e=>{if((!this.props.isOutsideClick||this.props.isOutsideClick(e))&&this.wrapperRef.current!==null&&!this.wrapperRef.current.contains(e.target)){let t=e.target;for(;t!==null;){if(t.classList.contains(`click-outside-ignore`))return;t=t.parentElement}this.props.onClickOutside()}};render(){let{onClickOutside:e,isOutsideClick:t,...n}=this.props;return g.createElement(`div`,{...n,ref:this.wrapperRef},this.props.children)}},kl=br(`input`)({name:`RenameInput`,class:`gdg-r17m35ur`,propsAsIs:!1,vars:{"r17m35ur-0":[e=>Math.max(16,e.targetHeight-10),`px`]}}),Al=e=>{let{bounds:t,group:n,onClose:r,canvasBounds:i,onFinish:a}=e,[o,s]=g.useState(n);return g.createElement(Ol,{style:{position:`absolute`,left:t.x-i.left+1,top:t.y-i.top,width:t.width-2,height:t.height},className:`gdg-c1tqibwd`,onClickOutside:r},g.createElement(kl,{targetHeight:t.height,"data-testid":`group-rename-input`,value:o,onBlur:r,onFocus:e=>e.target.setSelectionRange(0,o.length),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`?a(o):e.key===`Escape`&&r()},autoFocus:!0}))};function jl(e,t){return e===void 0?!1:e.length>1&&e.startsWith(`_`)?Number.parseInt(e.slice(1))===t.keyCode:e.length===1&&e>=`a`&&e<=`z`?e.toUpperCase().codePointAt(0)===t.keyCode:e===t.key}function Ml(e,t,n){let r=Nl(e,t);return r&&(n.didMatch=!0),r}function Nl(e,t){if(e.length===0)return!1;if(e.includes(`|`)){let n=e.split(`|`);for(let e of n)if(Nl(e,t))return!0;return!1}let n=!1,r=!1,i=!1,a=!1,o=e.split(`+`);if(!jl(o.pop(),t))return!1;if(o[0]===`any`)return!0;for(let e of o)switch(e){case`ctrl`:n=!0;break;case`shift`:r=!0;break;case`alt`:i=!0;break;case`meta`:a=!0;break;case`primary`:rl.value?a=!0:n=!0}return t.altKey===i&&t.ctrlKey===n&&t.shiftKey===r&&t.metaKey===a}function Pl(e,t,n,r,i,a){return[g.useCallback((o,s,c,l)=>{(a===`cell`||a===`multi-cell`)&&o!==void 0&&(o={...o,range:{x:o.cell[0],y:o.cell[1],width:1,height:1}});let u=n===`mixed`&&(c||l===`drag`),d=r===`mixed`&&u,f=i===`mixed`&&u,p={current:o===void 0?void 0:{...o,rangeStack:l===`drag`?e.current?.rangeStack??[]:[]},columns:d?e.columns:ur.empty(),rows:f?e.rows:ur.empty()};c&&(a===`multi-rect`||a===`multi-cell`)&&p.current!==void 0&&e.current!==void 0&&(p={...p,current:{...p.current,rangeStack:[...e.current.rangeStack,e.current.range]}}),t(p,s)},[r,e,n,a,i,t]),g.useCallback((a,o,s)=>{a??=e.rows,o!==void 0&&(a=a.add(o));let c;if(i===`exclusive`&&a.length>0)c={current:void 0,columns:ur.empty(),rows:a};else{let t=s&&n===`mixed`,i=s&&r===`mixed`;c={current:t?e.current:void 0,columns:i?e.columns:ur.empty(),rows:a}}t(c,!1)},[r,e,n,i,t]),g.useCallback((a,o,s)=>{a??=e.columns,o!==void 0&&(a=a.add(o));let c;if(r===`exclusive`&&a.length>0)c={current:void 0,rows:ur.empty(),columns:a};else{let t=s&&n===`mixed`,r=s&&i===`mixed`;c={current:t?e.current:void 0,rows:r?e.rows:ur.empty(),columns:a}}t(c,!1)},[r,e,n,i,t])]}function Fl(e,t,n,r,i){let a=g.useCallback(n=>{if(e===!0){let e=[];for(let r=n.y;r=i?a.push({kind:W.Loading,allowOverlay:!1}):a.push(t([e,r]));e.push(a)}return e}return e?.(n,r.signal)??[]},[r.signal,t,e,i]),o=e===void 0?void 0:a,s=g.useCallback(e=>{if(o===void 0)return[];let t={...e,x:e.x-n};if(t.x<0){t.x=0,t.width--;let e=o(t,r.signal);return typeof e==`function`?async()=>(await e()).map(e=>[{kind:W.Loading,allowOverlay:!1},...e]):e.map(e=>[{kind:W.Loading,allowOverlay:!1},...e])}return o(t,r.signal)},[r.signal,o,n]);return[e===void 0?void 0:s,o]}function Il(e){if(e.copyData!==void 0)return{formatted:e.copyData,rawValue:e.copyData,format:`string`};switch(e.kind){case W.Boolean:return{formatted:e.data===!0?`TRUE`:e.data===!1?`FALSE`:e.data===void 0?`INDETERMINATE`:``,rawValue:e.data,format:`boolean`};case W.Custom:return{formatted:e.copyData,rawValue:e.copyData,format:`string`};case W.Image:case W.Bubble:return{formatted:e.data,rawValue:e.data,format:`string-array`};case W.Drilldown:return{formatted:e.data.map(e=>e.text),rawValue:e.data.map(e=>e.text),format:`string-array`};case W.Text:return{formatted:e.displayData??e.data,rawValue:e.data,format:`string`};case W.Uri:return{formatted:e.displayData??e.data,rawValue:e.data,format:`url`};case W.Markdown:case W.RowID:return{formatted:e.data,rawValue:e.data,format:`string`};case W.Number:return{formatted:e.displayData,rawValue:e.data,format:`number`};case W.Loading:return{formatted:`#LOADING`,rawValue:``,format:`string`};case W.Protected:return{formatted:`************`,rawValue:``,format:`string`};default:Gt(e)}}function Ll(e,t){return e.map((e,n)=>{let r=t[n];return e.map(e=>e.span!==void 0&&e.span[0]!==r?{formatted:``,rawValue:``,format:`string`}:Il(e))})}function Rl(e,t){return(t?/[\t\n",]/:/[\t\n"]/).test(e)&&(e=`"${e.replace(/"/g,`""`)}"`),e}function zl(e){let t=[];for(let n of e){let e=[];for(let t of n)t.format===`url`?e.push(t.rawValue?.toString()??``):t.format===`string-array`?e.push(t.formatted.map(e=>Rl(e,!0)).join(`,`)):e.push(Rl(t.formatted,!1));t.push(e.join(` `))}return t.join(` -`)}function Bl(e){return e.replace(/\t/g,` `).replace(/ {2,}/g,e=>` `.repeat(e.length))}function Vl(e){return`"`+e.replace(/&/g,`&`).replace(/"/g,`"`).replace(//g,`>`)+`"`}function Hl(e){return e.replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`).replace(/&/g,`&`)}function Ul(e){let t=[];t.push(``,``);for(let n of e){t.push(``);for(let e of n){let n=`gdg-format="${e.format}"`;e.format===`url`?t.push(``):e.format===`string-array`?t.push(``):t.push(``)}t.push(``)}return t.push(`
    ${Bl(e.formatted)}
      ${e.formatted.map((t,n)=>`
    1. `+Bl(t)+`
    2. `).join(``)}
    ${Bl(e.formatted)}
    `),t.join(``)}function Wl(e,t){let n=Ll(e,t);return{textPlain:zl(n),textHtml:Ul(n)}}function Gl(e){let t=document.createElement(`html`);t.innerHTML=e.replace(/ /g,` `);let n=t.querySelector(`table`);if(n===null)return;let r=[n],i=[],a;for(;r.length>0;){let e=r.pop();if(e===void 0)break;if(e instanceof HTMLTableElement||e.nodeName===`TBODY`)r.push(...[...e.children].reverse());else if(e instanceof HTMLTableRowElement)a!==void 0&&i.push(a),a=[],r.push(...[...e.children].reverse());else if(e instanceof HTMLTableCellElement){let t=e.cloneNode(!0),n=t.children.length===1&&t.children[0].nodeName===`P`?t.children[0]:null,r=n?.children.length===1&&n.children[0].nodeName===`FONT`,i=t.querySelectorAll(`br`);for(let e of i)e.replaceWith(` -`);let o=t.getAttribute(`gdg-raw-value`),s=t.getAttribute(`gdg-format`)??`string`;if(t.querySelector(`a`)!==null)a?.push({rawValue:t.querySelector(`a`)?.getAttribute(`href`)??``,formatted:t.textContent??``,format:s});else if(t.querySelector(`ol`)!==null){let e=t.querySelectorAll(`li`);a?.push({rawValue:[...e].map(e=>e.getAttribute(`gdg-raw-value`)??``),formatted:[...e].map(e=>e.textContent??``),format:`string-array`})}else if(o!==null)a?.push({rawValue:Hl(o),formatted:t.textContent??``,format:s});else{let e=t.textContent??``;r&&(e=e.replace(/\n(?!\n)/g,``)),a?.push({rawValue:e??``,formatted:e??``,format:s})}}}return a!==void 0&&i.push(a),i}function Kl(e,t,n,r,i){let a=e;if(r===`allowPartial`||e.current===void 0||t===void 0)return e;let o=!1;do{if(e?.current===void 0)break;let r=e.current?.range,s=[];if(r.width>2){let e=t({x:r.x,y:r.y,width:1,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e);let n=t({x:r.x+r.width-1,y:r.y,width:1,height:r.height},i.signal);if(typeof n==`function`)return a;s.push(...n)}else{let e=t({x:r.x,y:r.y,width:r.width,height:r.height},i.signal);if(typeof e==`function`)return a;s.push(...e)}let c=r.x-n,l=r.x+r.width-1-n;for(let e of s)for(let t of e)t.span!==void 0&&(c=Math.min(t.span[0],c),l=Math.max(t.span[1],l));c===r.x-n&&l===r.x+r.width-1-n?o=!0:e={current:{cell:e.current.cell??[0,0],range:{x:c+n,y:r.y,width:l-c+1,height:r.height},rangeStack:e.current.rangeStack},columns:e.columns,rows:e.rows}}while(!o);return e}function ql(e){return e.startsWith(`"`)&&e.endsWith(`"`)&&(e=e.slice(1,-1).replace(/""/g,`"`)),e}function Jl(e){let t;(function(e){e[e.None=0]=`None`,e[e.inString=1]=`inString`,e[e.inStringPostQuote=2]=`inStringPostQuote`})(t||={});let n=[],r=[],i=0,a=t.None;e=e.replace(/\r\n/g,` -`);let o=0;for(let s of e){switch(a){case t.None:s===` `||s===` -`?(r.push(e.slice(i,o)),i=o+1,s===` -`&&(n.push(r),r=[])):s===`"`&&(a=t.inString);break;case t.inString:s===`"`&&(a=t.inStringPostQuote);break;case t.inStringPostQuote:s===`"`?a=t.inString:((s===` `||s===` -`)&&(r.push(ql(e.slice(i,o))),i=o+1,s===` -`&&(n.push(r),r=[])),a=t.None)}o++}return ie.map(e=>({rawValue:e,formatted:e,format:`string`})))}function Yl(e,t,n){let r=Wl(e,t),i=e=>{window.navigator.clipboard?.writeText(e)},a=(e,t)=>window.navigator.clipboard?.write!==void 0&&(window.navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:`text/plain`}),"text/html":new Blob([t],{type:`text/html`})})]),!0);window.navigator.clipboard?.write!==void 0||n?.clipboardData!==void 0?((e,t)=>{try{if(n===void 0||n.clipboardData===null)throw Error(`No clipboard data`);n?.clipboardData?.setData(`text/plain`,e),n?.clipboardData?.setData(`text/html`,t)}catch{a(e,t)||i(e)}})(r.textPlain,r.textHtml):i(r.textPlain),n?.preventDefault()}function Xl(e){return e!==!0}function Zl(e){return typeof e==`string`?e:`${e}px`}var Ql=br(`div`)({name:`Wrapper`,class:`gdg-wmyidgi`,propsAsIs:!1,vars:{"wmyidgi-0":[e=>e.innerWidth],"wmyidgi-1":[e=>e.innerHeight]}}),$l=e=>{let{inWidth:t,inHeight:n,children:r,...i}=e;return g.createElement(Ql,{innerHeight:Zl(n),innerWidth:Zl(t),...i},r)},eu=2,tu=1300;function nu(e,t,n){let r=g.useRef(0),[i,a]=e??[0,0];g.useEffect(()=>{if(i===0&&a===0){r.current=0;return}let e=!1,o=0,s=c=>{if(!e){if(o===0)o=c;else{let e=c-o;r.current=Math.min(1,r.current+e/tu);let s=r.current**1.618*e*eu;t.current?.scrollBy(i*s,a*s),o=c,n?.()}window.requestAnimationFrame(s)}};return window.requestAnimationFrame(s),()=>{e=!0}},[t,i,a,n])}function ru({rowHeight:e,headerHeight:t,groupHeaderHeight:n,theme:r,overscrollX:i,overscrollY:a,scaleToRem:o,remSize:s}){let[c,l,u,d,f,p]=g.useMemo(()=>{if(!o||s===16)return[e,t,n,r,i,a];let c=s/16,l=e,u=_o();return[typeof l==`number`?l*c:e=>Math.ceil(l(e)*c),Math.ceil(t*c),Math.ceil(n*c),{...r,headerIconSize:(r?.headerIconSize??u.headerIconSize)*c,cellHorizontalPadding:(r?.cellHorizontalPadding??u.cellHorizontalPadding)*c,cellVerticalPadding:(r?.cellVerticalPadding??u.cellVerticalPadding)*c},Math.ceil((i??0)*c),Math.ceil((a??0)*c)]},[n,t,i,a,s,e,o,r]);return{rowHeight:c,headerHeight:l,groupHeaderHeight:u,theme:d,overscrollX:f,overscrollY:p}}var iu={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 au(e,t){return e===!0?t:e===!1?``:e}function ou(e){let t=rl.value;return{activateCell:au(e.activateCell,` |Enter|shift+Enter`),clear:au(e.clear,`any+Escape`),closeOverlay:au(e.closeOverlay,`any+Escape`),acceptOverlayDown:au(e.acceptOverlayDown,`Enter`),acceptOverlayUp:au(e.acceptOverlayUp,`shift+Enter`),acceptOverlayLeft:au(e.acceptOverlayLeft,`shift+Tab`),acceptOverlayRight:au(e.acceptOverlayRight,`Tab`),copy:e.copy,cut:e.cut,delete:au(e.delete,t?`Backspace|Delete`:`Delete`),downFill:au(e.downFill,`primary+_68`),scrollToSelectedCell:au(e.scrollToSelectedCell,`primary+Enter`),goDownCell:au(e.goDownCell,`ArrowDown`),goDownCellRetainSelection:au(e.goDownCellRetainSelection,`alt+ArrowDown`),goLeftCell:au(e.goLeftCell,`ArrowLeft|shift+Tab`),goLeftCellRetainSelection:au(e.goLeftCellRetainSelection,`alt+ArrowLeft`),goRightCell:au(e.goRightCell,`ArrowRight|Tab`),goRightCellRetainSelection:au(e.goRightCellRetainSelection,`alt+ArrowRight`),goUpCell:au(e.goUpCell,`ArrowUp`),goUpCellRetainSelection:au(e.goUpCellRetainSelection,`alt+ArrowUp`),goToFirstCell:au(e.goToFirstCell,`primary+Home`),goToFirstColumn:au(e.goToFirstColumn,`Home|primary+ArrowLeft`),goToFirstRow:au(e.goToFirstRow,`primary+ArrowUp`),goToLastCell:au(e.goToLastCell,`primary+End`),goToLastColumn:au(e.goToLastColumn,`End|primary+ArrowRight`),goToLastRow:au(e.goToLastRow,`primary+ArrowDown`),goToNextPage:au(e.goToNextPage,`PageDown`),goToPreviousPage:au(e.goToPreviousPage,`PageUp`),paste:e.paste,rightFill:au(e.rightFill,`primary+_82`),search:au(e.search,`primary+f`),selectAll:au(e.selectAll,`primary+a`),selectColumn:au(e.selectColumn,`ctrl+ `),selectGrowDown:au(e.selectGrowDown,`shift+ArrowDown`),selectGrowLeft:au(e.selectGrowLeft,`shift+ArrowLeft`),selectGrowRight:au(e.selectGrowRight,`shift+ArrowRight`),selectGrowUp:au(e.selectGrowUp,`shift+ArrowUp`),selectRow:au(e.selectRow,`shift+ `),selectToFirstCell:au(e.selectToFirstCell,`primary+shift+Home`),selectToFirstColumn:au(e.selectToFirstColumn,`primary+shift+ArrowLeft`),selectToFirstRow:au(e.selectToFirstRow,`primary+shift+ArrowUp`),selectToLastCell:au(e.selectToLastCell,`primary+shift+End`),selectToLastColumn:au(e.selectToLastColumn,`primary+shift+ArrowRight`),selectToLastRow:au(e.selectToLastRow,`primary+shift+ArrowDown`)}}function su(e){let t=li(e);return g.useMemo(()=>{if(t===void 0)return ou(iu);let e={...t,goToNextPage:t?.goToNextPage??t?.pageDown??iu.goToNextPage,goToPreviousPage:t?.goToPreviousPage??t?.pageUp??iu.goToPreviousPage,goToFirstCell:t?.goToFirstCell??t?.first??iu.goToFirstCell,goToLastCell:t?.goToLastCell??t?.last??iu.goToLastCell,selectToFirstCell:t?.selectToFirstCell??t?.first??iu.selectToFirstCell,selectToLastCell:t?.selectToLastCell??t?.last??iu.selectToLastCell};return ou({...iu,...e})},[t])}var cu=`modulepreload`,lu=function(e){return`/`+e},uu={},du=function(e){return e.pathname.endsWith(`.css`)},fu=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},pu=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=lu(t,n);let r=s(t),i=du(r);return fu(uu,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:cu,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},mu=c(Vo(),1),hu=c(Go(),1),gu=g.lazy(async()=>await pu(()=>import(`./data-grid-overlay-editor-upJpLw4s.js`),[])),_u=0;function vu(e){return(0,mu.default)((0,hu.default)((0,hu.default)(e).filter(e=>e.span!==void 0).map(e=>(0,ul.default)((e.span?.[0]??0)+1,(e.span?.[1]??0)+1))))}function yu(e,t){return e===void 0||t===0||e.columns.length===0&&e.current===void 0?e:{current:e.current===void 0?void 0:{cell:[e.current.cell[0]+t,e.current.cell[1]],range:{...e.current.range,x:e.current.range.x+t},rangeStack:e.current.rangeStack.map(e=>({...e,x:e.x+t}))},rows:e.rows,columns:e.columns.offset(t)}}var bu={kind:W.Loading,allowOverlay:!1},xu={columns:ur.empty(),rows:ur.empty(),current:void 0},Su=g.forwardRef((e,t)=>{let[n,r]=g.useState(xu),[i,a]=g.useState(),o=g.useRef(null),s=g.useRef(null),[c,l]=g.useState(),u=g.useRef(null),d=g.useRef(),f=typeof window>`u`?null:window,{imageEditorOverride:p,getRowThemeOverride:m,markdownDivCreateNode:h,width:_,height:v,columns:y,rows:b,getCellContent:x,onCellClicked:S,onCellActivated:C,onFillPattern:w,onFinishedEditing:T,coercePasteValue:E,drawHeader:D,drawCell:O,editorBloom:k,onHeaderClicked:A,onColumnProposeMove:ee,spanRangeBehavior:te=`default`,onGroupHeaderClicked:ne,onCellContextMenu:re,className:j,onHeaderContextMenu:ie,getCellsForSelection:M,onGroupHeaderContextMenu:ae,onGroupHeaderRenamed:N,onCellEdited:oe,onCellsEdited:P,onSearchResultsChanged:se,searchResults:ce,onSearchValueChange:F,searchValue:le,onKeyDown:ue,onKeyUp:de,keybindings:fe,editOnType:pe=!0,onRowAppended:me,onColumnMoved:he,validateCell:ge,highlightRegions:I,rangeSelect:L=`rect`,columnSelect:_e=`multi`,rowSelect:R=`multi`,rangeSelectionBlending:ve=`exclusive`,columnSelectionBlending:ye=`exclusive`,rowSelectionBlending:be=`exclusive`,onDelete:xe,onDragStart:Se,onMouseMove:z,onPaste:Ce,copyHeaders:we=!1,freezeColumns:B=0,cellActivationBehavior:Te=`second-click`,rowSelectionMode:Ee=`auto`,onHeaderMenuClick:De,getGroupDetails:Oe,onSearchClose:ke,onItemHovered:Ae,onSelectionCleared:je,showSearch:Me,onVisibleRegionChanged:Ne,gridSelection:Pe,onGridSelectionChange:Fe,minColumnWidth:Ie=50,maxColumnWidth:Le=500,maxColumnAutoWidth:Re,provideEditor:ze,trailingRowOptions:Be,freezeTrailingRows:Ve=0,allowedFillDirections:He=`orthogonal`,scrollOffsetX:Ue,scrollOffsetY:We,verticalBorder:Ge,onDragOverCell:Ke,onDrop:qe,onColumnResize:Je,onColumnResizeEnd:Ye,onColumnResizeStart:Xe,customRenderers:Ze,fillHandle:Qe,drawFocusRing:$e=!0,experimental:et,fixedShadowX:tt,fixedShadowY:nt,headerIcons:rt,imageWindowLoader:it,initialSize:at,isDraggable:ot,onDragLeave:st,onRowMoved:ct,overscrollX:lt,overscrollY:ut,preventDiagonalScrolling:dt,rightElement:ft,rightElementProps:pt,trapFocus:mt=!1,smoothScrollX:ht,smoothScrollY:gt,scaleToRem:_t=!1,rowHeight:vt=34,headerHeight:yt=36,groupHeaderHeight:bt=yt,theme:xt,isOutsideClick:St,renderers:Ct}=e,wt=typeof e.rowMarkers==`string`?void 0:e.rowMarkers,Tt=wt?.kind??e.rowMarkers??`none`,V=wt?.width??e.rowMarkerWidth,Et=wt?.startIndex??e.rowMarkerStartIndex??1,Dt=wt?.theme??e.rowMarkerTheme,Ot=wt?.checkboxStyle??`square`,kt=Math.max(Ie,20),At=Math.max(Le,kt),jt=Math.max(Re??At,kt),Mt=g.useMemo(()=>typeof window>`u`?{fontSize:`16px`}:window.getComputedStyle(document.documentElement),[]),{rowHeight:Nt,headerHeight:Pt,groupHeaderHeight:Ft,theme:It,overscrollX:Lt,overscrollY:Rt}=ru({groupHeaderHeight:bt,headerHeight:yt,overscrollX:lt,overscrollY:ut,remSize:g.useMemo(()=>Number.parseFloat(Mt.fontSize),[Mt]),rowHeight:vt,scaleToRem:_t,theme:xt}),zt=su(fe),Bt=V??(b>1e4?48:b>1e3?44:b>100?36:32),Vt=Tt!==`none`,H=+!!Vt,Ht=me!==void 0,Ut=Be?.sticky===!0,[qt,Jt]=g.useState(!1),Yt=Me??qt,Xt=g.useCallback(()=>{ke===void 0?Jt(!1):ke()},[ke]),U=g.useMemo(()=>Pe===void 0?void 0:yu(Pe,H),[Pe,H])??n,Zt=g.useRef();Zt.current===void 0&&(Zt.current=new AbortController),g.useEffect(()=>()=>Zt?.current.abort(),[]);let[Qt,$t]=Fl(M,x,H,Zt.current,b),en=g.useCallback((e,t,n)=>{if(ge===void 0)return!0;let r=[e[0]-H,e[1]];return ge?.(r,t,n)},[H,ge]),tn=g.useRef(Pe),nn=g.useCallback((e,t)=>{t&&(e=Kl(e,Qt,H,te,Zt.current)),Fe===void 0?r(e):(tn.current=yu(e,-H),Fe(tn.current))},[Fe,Qt,H,te]),rn=Kr(Je,g.useCallback((e,t,n,r)=>{Je?.(y[n-H],t,n-H,r)},[Je,H,y])),an=Kr(Ye,g.useCallback((e,t,n,r)=>{Ye?.(y[n-H],t,n-H,r)},[Ye,H,y])),on=Kr(Xe,g.useCallback((e,t,n,r)=>{Xe?.(y[n-H],t,n-H,r)},[Xe,H,y])),sn=Kr(D,g.useCallback((e,t)=>D?.({...e,columnIndex:e.columnIndex-H},t)??!1,[D,H])),cn=Kr(O,g.useCallback((e,t)=>O?.({...e,col:e.col-H},t)??!1,[O,H])),ln=g.useCallback(e=>{if(xe!==void 0){let t=xe(yu(e,-H));return typeof t==`boolean`?t:yu(t,H)}return!0},[xe,H]),[un,dn,fn]=Pl(U,nn,ve,ye,be,L),pn=g.useMemo(()=>yo(_o(),It),[It]),[mn,hn]=g.useState([0,0,0]),gn=g.useMemo(()=>{if(Ct===void 0)return{};let e={};for(let t of Ct)e[t.kind]=t;return e},[Ct]),_n=g.useCallback(e=>e.kind===W.Custom?Ze?.find(t=>t.isMatch(e)):gn[e.kind],[Ze,gn]),{sizedColumns:vn,nonGrowWidth:yn}=Co(y,b,$t,mn[0]-(H===0?0:Bt)-mn[2],kt,jt,pn,_n,Zt.current);Tt!==`none`&&(yn+=Bt);let bn=g.useMemo(()=>vn.some(e=>e.group!==void 0),[vn]),xn=bn?Pt+Ft:Pt,Sn=U.rows.length,Cn=Tt===`none`?void 0:Sn===0?!1:Sn===b||void 0,wn=g.useMemo(()=>Tt===`none`?vn:[{title:``,width:Bt,icon:void 0,hasMenu:!1,style:`normal`,themeOverride:Dt,rowMarker:Ot,rowMarkerChecked:Cn},...vn],[Tt,vn,Bt,Dt,Ot,Cn]),[Tn,En]=g.useMemo(()=>[We!==void 0&&typeof Nt==`number`?Math.floor(We/Nt):0,We!==void 0&&typeof Nt==`number`?-(We%Nt):0],[We,Nt]),Dn=g.useRef({height:1,width:1,x:0,y:0}),On=g.useMemo(()=>({x:Dn.current.x,y:Tn,width:Dn.current.width??1,height:Dn.current.height??1,ty:En}),[En,Tn]),kn=g.useRef(!1),[An,jn,Mn]=si(On);Dn.current=An;let Nn=(An.height??1)>1;g.useLayoutEffect(()=>{if(We!==void 0&&u.current!==null&&Nn){if(u.current.scrollTop===We)return;u.current.scrollTop=We,u.current.scrollTop!==We&&Mn(),kn.current=!0}},[We,Nn,Mn]);let Pn=(An.width??1)>1;g.useLayoutEffect(()=>{if(Ue!==void 0&&u.current!==null&&Pn){if(u.current.scrollLeft===Ue)return;u.current.scrollLeft=Ue,u.current.scrollLeft!==Ue&&Mn(),kn.current=!0}},[Ue,Pn,Mn]);let Fn=An.x+H,In=An.y,Ln=g.useRef(null),Rn=g.useCallback(e=>{e===!0?Ln.current?.focus():window.requestAnimationFrame(()=>{Ln.current?.focus()})},[]),zn=Ht?b+1:b,Bn=g.useCallback(e=>{let t=H===0?e:e.map(e=>({...e,location:[e.location[0]-H,e.location[1]]})),n=P?.(t);if(n!==!0)for(let e of t)oe?.(e.location,e.value);return n},[oe,P,H]),[Vn,Hn]=g.useState(),Un=U.current!==void 0&&U.current.range.width*U.current.range.height>1?U.current.range:void 0,Wn=$e?U.current?.cell:void 0,Gn=Wn?.[0],Kn=Wn?.[1],qn=g.useMemo(()=>{if((I===void 0||I.length===0)&&(Un??Gn??Kn??Vn)===void 0)return;let e=[];if(I!==void 0)for(let t of I){let n=wn.length-t.range.x-H;n>0&&e.push({color:t.color,range:{...t.range,x:t.range.x+H,width:Math.min(n,t.range.width)},style:t.style})}return Vn!==void 0&&e.push({color:ua(pn.accentColor,0),range:Vn,style:`dashed`}),Un!==void 0&&e.push({color:ua(pn.accentColor,.5),range:Un,style:`solid-outline`}),Gn!==void 0&&Kn!==void 0&&e.push({color:pn.accentColor,range:{x:Gn,y:Kn,width:1,height:1},style:`solid-outline`}),e.length>0?e:void 0},[Vn,Un,Gn,Kn,I,wn.length,pn.accentColor,H]),Jn=g.useRef(wn);Jn.current=wn;let Yn=g.useCallback(([e,t],n=!1)=>{let r=Ht&&t===zn-1;if(e===0&&Vt)return r?bu:{kind:sr.Marker,allowOverlay:!1,checkboxStyle:Ot,checked:U?.rows.hasIndex(t)===!0,markerKind:Tt===`clickable-number`?`number`:Tt,row:Et+t,drawHandle:ct!==void 0,cursor:Tt===`clickable-number`?`pointer`:void 0};if(r){let t=e===H?Be?.hint??``:``,n=Jn.current[e];if(n?.trailingRowOptions?.disabled===!0)return bu;{let e=n?.trailingRowOptions?.hint??t,r=n?.trailingRowOptions?.addIcon??Be?.addIcon;return{kind:sr.NewRow,hint:e,allowOverlay:!1,icon:r}}}{let r=e-H;if(n||et?.strict===!0){let e=Dn.current,n=e.x>r||r>e.x+e.width||e.y>t||t>e.y+e.height||t>=cr.current,i=r===e.extras?.selected?.[0]&&t===e.extras?.selected[1],a=!1;if(e.extras?.freezeRegions!==void 0){for(let n of e.extras.freezeRegions)if(ss(n,r,t)){a=!0;break}}if(n&&!i&&!a)return bu}let i=x([r,t]);return H!==0&&i.span!==void 0&&(i={...i,span:[i.span[0]+H,i.span[1]+H]}),i}},[Ht,zn,Vt,Ot,U?.rows,Tt,Et,ct,H,Be?.hint,Be?.addIcon,et?.strict,x]),Xn=g.useCallback(e=>{let t=Oe?.(e)??{name:e};return N!==void 0&&e!==``&&(t={icon:t.icon,name:t.name,overrideTheme:t.overrideTheme,actions:[...t.actions??[],{title:`Rename`,icon:`renameIcon`,onClick:e=>Sr({group:t.name,bounds:e.bounds})}]}),t},[Oe,N]),Zn=g.useCallback(e=>{let[t,n]=e.cell,r=wn[t],i=r?.group===void 0?void 0:Xn(r.group)?.overrideTheme,o=r?.themeOverride,s=m?.(n);a({...e,theme:yo(pn,i,o,s,e.content.themeOverride)})},[m,wn,Xn,pn]),Qn=g.useCallback((e,t,n)=>{if(U.current===void 0)return;let[r,i]=U.current.cell,a=Yn([r,i]);if(a.kind!==W.Boolean&&a.allowOverlay){let t=a;if(n!==void 0)switch(t.kind){case W.Number:{let e=Kt(()=>n===`-`?-0:Number.parseFloat(n),0);t={...t,data:Number.isNaN(e)?0:e};break}case W.Text:case W.Markdown:case W.Uri:t={...t,data:n}}Zn({target:e,content:t,initialValue:n,cell:[r,i],highlight:n===void 0,forceEditMode:n!==void 0})}else a.kind===W.Boolean&&t&&a.readonly!==!0&&(Bn([{location:U.current.cell,value:{...a,data:Xl(a.data)}}]),Ln.current?.damage([{cell:U.current.cell}]))},[Yn,U,Bn,Zn]),$n=g.useCallback((e,t)=>{let n=Ln.current?.getBounds(e,t);if(n===void 0||u.current===null)return;let r=Yn([e,t]);r.allowOverlay&&Zn({target:n,content:r,initialValue:void 0,highlight:!0,cell:[e,t],forceEditMode:!0})},[Yn,Zn]),er=g.useCallback((e,t,n=`both`,r=0,i=0,a=void 0)=>{if(u.current!==null){let o=Ln.current,c=s.current,l=typeof e==`number`?e:e.unit===`cell`?e.amount:void 0,d=typeof t==`number`?t:t.unit===`cell`?t.amount:void 0,f=typeof e!=`number`&&e.unit===`px`?e.amount:void 0,p=typeof t!=`number`&&t.unit===`px`?t.amount:void 0;if(o!==null&&c!==null){let s={x:0,y:0,width:0,height:0},m=0,h=0;if((l!==void 0||d!==void 0)&&(s=o.getBounds((l??0)+H,d??0)??s,s.width===0||s.height===0))return;let g=c.getBoundingClientRect(),_=g.width/c.offsetWidth;if(f!==void 0&&(s={...s,x:f-g.left-u.current.scrollLeft,width:1}),p!==void 0&&(s={...s,y:p+g.top-u.current.scrollTop,height:1}),s!==void 0){let o={x:s.x-r,y:s.y-i,width:s.width+2*r,height:s.height+2*i},c=0;for(let e=0;e0&&(l=Pa(zn,d,Nt));let f=c*_+g.left+H*Bt*_,p=g.right,v=g.top+xn*_,y=g.bottom-l*_,b=s.width+r*2;switch(a?.hAlign){case`start`:p=f+b;break;case`end`:f=p-b;break;case`center`:f=Math.floor((f+p)/2)-b/2,p=f+b}let x=s.height+i*2;switch(a?.vAlign){case`start`:y=v+x;break;case`end`:v=y-x;break;case`center`:v=Math.floor((v+y)/2)-x/2,y=v+x}f>o.x?m=o.x-f:po.y?h=o.y-v:y=zn-d)&&(h=0),(m!==0||h!==0)&&(_!==1&&(m/=_,h/=_),u.current.scrollTo(m+u.current.scrollLeft,h+u.current.scrollTop))}}}},[H,Ve,Bt,xn,B,vn,zn,Ut,Nt]),tr=g.useRef($n),or=g.useRef(x),cr=g.useRef(b);tr.current=$n,or.current=x,cr.current=b;let lr=g.useCallback(async(e,t=!0)=>{if(wn[e]?.trailingRowOptions?.disabled===!0)return;let n=me?.(),r,i=!0;n!==void 0&&(r=await n,r===`top`&&(i=!1),typeof r==`number`&&(i=!1));let a=0,o=()=>{if(cr.current<=b){a<500&&window.setTimeout(o,a),a=50+a*2;return}let n=typeof r==`number`?r:i?b:0;oi.current(e-H,n),un({cell:[e,n],range:{x:e,y:n,width:1,height:1}},!1,!1,`edit`);let s=or.current([e-H,n]);s.allowOverlay&&ir(s)&&s.readonly!==!0&&t&&window.setTimeout(()=>{tr.current(e,n)},0)};o()},[wn,me,H,b,un]),dr=g.useCallback(e=>{let t=vn[e]?.trailingRowOptions?.targetColumn??Be?.targetColumn;if(typeof t==`number`)return t+ +!!Vt;if(typeof t==`object`){let e=y.indexOf(t);if(e>=0)return e+ +!!Vt}},[vn,y,Vt,Be?.targetColumn]),fr=g.useRef(),pr=g.useRef(),mr=g.useCallback((e,t)=>{let[n,r]=t;return yo(pn,wn[n]?.themeOverride,m?.(r),e.themeOverride)},[m,wn,pn]),hr=g.useCallback(e=>{let t=rl.value?e.metaKey:e.ctrlKey,n=t&&R===`multi`,r=t&&_e===`multi`,[i,o]=e.location,s=U.columns,c=U.rows,[l,u]=U.current?.cell??[];if(e.kind===`cell`){if(pr.current=void 0,_r.current=[i,o],i===0&&Vt){if(Ht===!0&&o===b||Tt===`number`||R===`none`)return;let r=Yn(e.location);if(r.kind!==sr.Marker)return;if(ct!==void 0){let t=_n(r);Wt(t?.kind===sr.Marker);let n=t?.onClick?.({...e,cell:r,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,theme:mr(r,e.location),preventDefault:()=>void 0});if(n===void 0||n.checked===r.checked)return}a(void 0),Rn();let i=c.hasIndex(o),s=fr.current;if(R===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&s!==void 0&&c.hasIndex(s)){let e=[Math.min(s,o),Math.max(s,o)+1];n||Ee===`multi`?dn(void 0,e,!0):dn(ur.fromSingleSelection(e),void 0,n)}else n||e.isTouch||Ee===`multi`?i?dn(c.remove(o),void 0,!0):(dn(void 0,o,!0),fr.current=o):i&&c.length===1?dn(ur.empty(),void 0,t):(dn(ur.fromSingleSelection(o),void 0,t),fr.current=o)}else if(i>=H&&Ht&&o===b){let e=dr(i);lr(e??i)}else if(l!==i||u!==o){let n=Yn(e.location),r=_n(n);if(r?.onSelect!==void 0){let t=!1;if(r.onSelect({...e,cell:n,posX:e.localEventX,posY:e.localEventY,bounds:e.bounds,preventDefault:()=>t=!0,theme:mr(n,e.location)}),t)return}let s=Ut&&o===b,c=Ut&&U!==void 0&&U.current?.cell[1]===b;if((e.shiftKey||e.isLongTouch===!0)&&l!==void 0&&u!==void 0&&U.current!==void 0&&!c){if(s)return;let e=Math.min(i,l),n=Math.max(i,l),r=Math.min(o,u),a=Math.max(o,u);un({...U.current,range:{x:e,y:r,width:n-e+1,height:a-r+1}},!0,t,`click`),fr.current=void 0,Rn()}else un({cell:[i,o],range:{x:i,y:o,width:1,height:1}},!0,t,`click`),fr.current=void 0,a(void 0),Rn()}}else if(e.kind===`header`){if(_r.current=[i,o],a(void 0),Vt&&i===0)fr.current=void 0,pr.current=void 0,R===`multi`&&(c.length===b?dn(ur.empty(),void 0,t):dn(ur.fromSingleSelection([0,b]),void 0,t),Rn());else{let n=pr.current;if(_e===`multi`&&(e.shiftKey||e.isLongTouch===!0)&&n!==void 0&&s.hasIndex(n)){let e=[Math.min(n,i),Math.max(n,i)+1];r?fn(void 0,e,t):fn(ur.fromSingleSelection(e),void 0,t)}else r?(s.hasIndex(i)?fn(s.remove(i),void 0,t):fn(void 0,i,t),pr.current=i):_e!==`none`&&(fn(ur.fromSingleSelection(i),void 0,t),pr.current=i);fr.current=void 0,Rn()}}else e.kind===`group-header`?_r.current=[i,o]:e.kind===`out-of-bounds`&&!e.isMaybeScrollbar&&(nn(xu,!1),a(void 0),Rn(),je?.(),fr.current=void 0,pr.current=void 0)},[lr,_e,Rn,_n,dr,Yn,U,Vt,Ut,je,ct,H,Tt,R,Ee,b,un,nn,fn,dn,Ht,mr]),gr=g.useRef(!1),_r=g.useRef(),vr=g.useRef(An),yr=g.useRef(),br=g.useCallback(e=>{if(wr.current=!1,vr.current=Dn.current,e.button!==0&&e.button!==1){yr.current=void 0;return}let t=performance.now();yr.current={button:e.button,time:t,location:e.location},e?.kind===`header`&&(gr.current=!0);let n=e.kind===`cell`&&e.isFillHandle;(n||e.kind===`cell`||!e.isEdge)&&(l({previousSelection:U,fillHandle:n}),_r.current=void 0,!e.isTouch&&e.button===0&&!n?hr(e):!e.isTouch&&e.button===1&&(_r.current=e.location))},[U,hr]),[xr,Sr]=g.useState(),Cr=g.useCallback(e=>{if(e.kind!==`group-header`||_e!==`multi`)return;let t=rl.value?e.metaKey:e.ctrlKey,[n]=e.location,r=U.columns;if(n=H&&Ta(i.group,wn[e].group);e--)a--;for(let e=n+1;e{if(Qt!==void 0&&rn!==void 0){let t=Dn.current.y,n=Dn.current.height,r=Qt({x:e,y:t,width:1,height:Math.min(n,b-t)},Zt.current.signal);typeof r!=`object`&&(r=await r());let i=vn[e-H],a=document.createElement(`canvas`).getContext(`2d`,{alpha:!1});if(a!==null){a.font=pn.baseFontFull;let t=So(a,pn,i,0,r,kt,At,!1,_n);rn?.(i,t.width,e,t.width)}}},[vn,Qt,At,pn,kt,rn,H,b,_n]),[Er,Dr]=g.useState(),Or=g.useCallback(async(e,t)=>{let n=e.current?.range;if(n===void 0||Qt===void 0||t.current===void 0)return;let r=t.current.range;if(w!==void 0){let e=!1;if(w({fillDestination:{...r,x:r.x-H},patternSource:{...n,x:n.x-H},preventDefault:()=>e=!0}),e)return}let i=Qt(n,Zt.current.signal);typeof i!=`object`&&(i=await i());let a=i,o=[];for(let e=0;e({cell:e.location})))},[Qt,Bn,w,H]),kr=g.useCallback(()=>{if(U.current===void 0||U.current.range.width<=1)return;let e={...U,current:{...U.current,range:{...U.current.range,width:1}}};Or(e,U)},[Or,U]),Ar=g.useCallback(()=>{if(U.current===void 0||U.current.range.height<=1)return;let e={...U,current:{...U.current,range:{...U.current.range,height:1}}};Or(e,U)},[Or,U]),jr=g.useCallback((e,t)=>{let n=c;if(l(void 0),Hn(void 0),Dr(void 0),gr.current=!1,t)return;if(n?.fillHandle===!0&&U.current!==void 0&&n.previousSelection?.current!==void 0){if(Vn===void 0)return;let e={...U,current:{...U.current,range:cs(n.previousSelection.current.range,Vn)}};Or(n.previousSelection,e),nn(e,!0);return}let[r,i]=e.location,[a,o]=_r.current??[],s=()=>{wr.current=!0},u=t=>{let c=t.isTouch||a===r&&o===i;if(c&&S?.([r-H,i],{...t,preventDefault:s}),t.button===1)return!wr.current;if(!wr.current){let a=Yn(e.location),o=_n(a);if(o!==void 0&&o.onClick!==void 0&&c){let n=o.onClick({...t,cell:a,posX:t.localEventX,posY:t.localEventY,bounds:t.bounds,theme:mr(a,e.location),preventDefault:s});n!==void 0&&!rr(n)&&nr(n)&&(Bn([{location:t.location,value:n}]),Ln.current?.damage([{cell:t.location}]))}if(wr.current||U.current===void 0)return!1;let l=!1;switch(a.activationBehaviorOverride??Te){case`double-click`:case`second-click`:{if(n?.previousSelection?.current?.cell===void 0)break;let[e,a]=U.current.cell,[o,s]=n.previousSelection.current.cell;l=r===e&&r===o&&i===a&&i===s&&(t.isDoubleClick===!0||Te===`second-click`);break}case`single-click`:l=!0}if(l)return C?.([r-H,i]),Qn(t.bounds,!1),!0}return!1},d=e.location[0]-H;if(e.isTouch){let t=Dn.current,n=vr.current;if(t.x!==n.x||t.y!==n.y)return;if(e.isLongTouch===!0){if(e.kind===`cell`&&Oa(U.current?.cell,e.location)){re?.([d,e.location[1]],{...e,preventDefault:s});return}if(e.kind===`header`&&U.columns.hasIndex(r)){ie?.(d,{...e,preventDefault:s});return}if(e.kind===`group-header`){if(d<0)return;ae?.(d,{...e,preventDefault:s});return}}e.kind===`cell`?u(e)||hr(e):e.kind===`group-header`?ne?.(d,{...e,preventDefault:s}):(e.kind===`header`&&A?.(d,{...e,preventDefault:s}),hr(e))}else{if(e.kind===`header`){if(d<0)return;e.isEdge?e.isDoubleClick===!0&&Tr(r):e.button===0&&r===a&&i===o&&A?.(d,{...e,preventDefault:s})}if(e.kind===`group-header`){if(d<0)return;e.button===0&&r===a&&i===o&&(ne?.(d,{...e,preventDefault:s}),wr.current||Cr(e))}e.kind===`cell`&&(e.button===0||e.button===1)&&u(e),_r.current=void 0}},[c,U,H,Vn,Or,nn,S,Yn,_n,Te,mr,Bn,C,Qn,re,ie,ae,hr,ne,A,Tr,Cr]),Mr=g.useCallback(e=>{let t={...e,location:[e.location[0]-H,e.location[1]]};z?.(t),c!==void 0&&e.buttons===0&&(l(void 0),Hn(void 0),Dr(void 0),gr.current=!1),Dr(t=>gr.current?[e.scrollEdge[0],0]:e.scrollEdge[0]===t?.[0]&&e.scrollEdge[1]===t[1]?t:c===void 0||(yr.current?.location[0]??0){De?.(e-H,t)},[De,H]),Pr=U?.current?.cell,Fr=g.useCallback((e,t,n,r,i,a)=>{kn.current=!1;let o=Pr;o!==void 0&&(o=[o[0]-H,o[1]]);let s=B===0?void 0:{x:0,y:e.y,width:B,height:e.height},c=[];s!==void 0&&c.push(s),Ve>0&&(c.push({x:e.x-H,y:b-Ve,width:e.width,height:Ve}),B>0&&c.push({x:0,y:b-Ve,width:B,height:Ve}));let l={x:e.x-H,y:e.y,width:e.width,height:Ht&&e.y+e.height>=b?e.height-1:e.height,tx:i,ty:a,extras:{selected:o,freezeRegion:s,freezeRegions:c}};Dn.current=l,jn(l),hn([t,n,r]),Ne?.(l,l.tx,l.ty,l.extras)},[Pr,H,Ht,b,B,Ve,jn,Ne]),Ir=Kr(he,g.useCallback((e,t)=>{he?.(e-H,t-H),_e!==`none`&&fn(ur.fromSingleSelection(t),void 0,!0)},[_e,he,H,fn])),Lr=g.useRef(!1),Rr=g.useCallback(e=>{e.location[0]===0&&H>0?e.preventDefault():(Se?.({...e,location:[e.location[0]-H,e.location[1]]}),e.defaultPrevented()||(Lr.current=!0),l(void 0))},[Se,H]),zr=g.useCallback(()=>{Lr.current=!1},[]),Br=g.useRef(),Vr=g.useCallback(e=>{if(!ll(e,Br.current)&&(Br.current=e,!(yr?.current?.button!==void 0&&yr.current.button>=1))){if(e.buttons!==0&&c!==void 0&&yr.current?.location[0]===0&&e.location[0]===0&&H===1&&R===`multi`&&c.previousSelection&&!c.previousSelection.rows.hasIndex(yr.current.location[1])&&U.rows.hasIndex(yr.current.location[1])){let t=Math.min(yr.current.location[1],e.location[1]),n=Math.max(yr.current.location[1],e.location[1])+1;dn(ur.fromSingleSelection([t,n]),void 0,!1)}if(e.buttons!==0&&c!==void 0&&U.current!==void 0&&!Lr.current&&!gr.current&&(L===`rect`||L===`multi-rect`)){let[t,n]=U.current.cell,[r,i]=e.location;if(i<0&&(i=Dn.current.y),c.fillHandle===!0&&c.previousSelection?.current!==void 0){let e=c.previousSelection.current.range;i=Math.min(i,Ht?b-1:b);let t=as(e,r,i,He);Hn(t)}else{if(Ht&&n===b)return;if(Ht&&i===b){if(e.kind===`out-of-bounds`)i--;else return}r=Math.max(r,H);let a=r-t,o=i-n,s={x:a>=0?t:r,y:o>=0?n:i,width:Math.abs(a)+1,height:Math.abs(o)+1};un({...U.current,range:s},!0,!1,`drag`)}}Ae?.({...e,location:[e.location[0]-H,e.location[1]]})}},[He,c,H,R,U,L,Ae,dn,Ht,b,un]);nu(Er,u,g.useCallback(()=>{let e=Br.current;if(e===void 0)return;let[t,n]=e.scrollEdge,[r,i]=e.location,a=Dn.current;t===-1?r=a.extras?.freezeRegion?.x??a.x:t===1&&(r=a.x+a.width),n===-1?i=Math.max(0,a.y):n===1&&(i=Math.min(b-1,a.y+a.height)),r=(0,Yc.default)(r,0,wn.length-1),i=(0,Yc.default)(i,0,b-1),Vr({...e,location:[r,i]})},[wn.length,Vr,b]));let Hr=g.useCallback(e=>{if(U.current===void 0)return;let[t,n]=e,[r,i]=U.current.cell,a=U.current.range,o=a.x,s=a.x+a.width,c=a.y,l=a.y+a.height;if(n!==0)switch(n){case 2:l=b,c=i,er(0,l,`vertical`);break;case-2:c=0,l=i+1,er(0,c,`vertical`);break;case 1:ci+1?(l--,er(0,l,`vertical`)):(c=Math.max(0,c-1),er(0,c,`vertical`));break;default:Gt(n)}if(t!==0){if(t===2)s=wn.length,o=r,er(s-1-H,0,`horizontal`);else if(t===-2)o=H,s=r+1,er(o-H,0,`horizontal`);else{let e=[];if(Qt!==void 0){let t=Qt({x:o,y:c,width:s-o-H,height:l-c},Zt.current.signal);typeof t==`object`&&(e=vu(t))}if(t===1){let t=!1;if(o0){let n=(0,ul.default)(o+1,r+1).find(t=>!e.includes(t-H));n!==void 0&&(o=n,t=!0)}else o++,t=!0;t&&er(o,0,`horizontal`)}t||(s=Math.min(wn.length,s+1),er(s-1-H,0,`horizontal`))}else if(t===-1){let t=!1;if(s>r+1){if(e.length>0){let n=(0,ul.default)(s-1,r,-1).find(t=>!e.includes(t-H));n!==void 0&&(s=n,t=!0)}else s--,t=!0;t&&er(s-H,0,`horizontal`)}t||(o=Math.max(H,o-1),er(o-H,0,`horizontal`))}else Gt(t)}}un({cell:U.current.cell,range:{x:o,y:c,width:s-o,height:l-c}},!0,!1,`keyboard-select`)},[Qt,U,wn.length,H,b,er,un]),Ur=g.useCallback((e,t,n,r)=>{let i=zn-+!n;if(e=(0,Yc.default)(e,H,vn.length-1+H),t=(0,Yc.default)(t,0,i),e===Pr?.[0]&&t===Pr?.[1])return!1;if(r&&U.current!==void 0){let n=[...U.current.rangeStack];(U.current.range.width>1||U.current.range.height>1)&&n.push(U.current.range),nn({...U,current:{cell:[e,t],range:{x:e,y:t,width:1,height:1},rangeStack:n}},!0)}else un({cell:[e,t],range:{x:e,y:t,width:1,height:1}},!0,!1,`keyboard-nav`);return d.current!==void 0&&d.current[0]===e&&d.current[1]===t&&(d.current=void 0),er(e-H,t),!0},[zn,H,vn.length,Pr,U,er,nn,un]),qr=g.useCallback((e,t)=>{i?.cell!==void 0&&e!==void 0&&nr(e)&&(Bn([{location:i.cell,value:e}]),window.requestAnimationFrame(()=>{Ln.current?.damage([{cell:i.cell}])})),Rn(!0),a(void 0);let[n,r]=t;if(U.current!==void 0&&(n!==0||r!==0)){let t=U.current.cell[1]===zn-1&&e!==void 0;Ur((0,Yc.default)(U.current.cell[0]+n,0,wn.length-1),(0,Yc.default)(U.current.cell[1]+r,0,zn-1),t,!1)}T?.(e,t)},[i?.cell,Rn,U,T,Bn,zn,Ur,wn.length]),Jr=g.useMemo(()=>`gdg-overlay-${_u++}`,[]),Yr=g.useCallback(e=>{Rn();let t=[];for(let n=e.x;n({cell:e.location})))},[Rn,x,_n,Bn,H]),Xr=i!==void 0,Zr=g.useCallback(e=>{let t=()=>{e.stopPropagation(),e.preventDefault()},n={didMatch:!1},{bounds:r}=e,i=U.columns,s=U.rows,c=zt;if(!Xr&&Ml(c.clear,e,n))nn(xu,!1),je?.();else if(!Xr&&Ml(c.selectAll,e,n))nn({columns:ur.empty(),rows:ur.empty(),current:{cell:U.current?.cell??[H,0],range:{x:H,y:0,width:y.length,height:b},rangeStack:[]}},!1);else if(Ml(c.search,e,n))o?.current?.focus({preventScroll:!0}),Jt(!0);else if(Ml(c.delete,e,n)){let e=ln?.(U)??!0;if(e!==!1){let t=e===!0?U:e;if(t.current!==void 0){Yr(t.current.range);for(let e of t.current.rangeStack)Yr(e)}for(let e of t.rows)Yr({x:H,y:e,width:y.length,height:1});for(let e of t.columns)Yr({x:e,y:0,width:1,height:b})}}if(n.didMatch)return t(),!0;if(U.current===void 0)return!1;let[l,u]=U.current.cell,d=!1,f=!1;Ml(c.scrollToSelectedCell,e,n)?oi.current(l-H,u):_e!==`none`&&Ml(c.selectColumn,e,n)?i.hasIndex(l)?fn(i.remove(l),void 0,!0):_e===`single`?fn(ur.fromSingleSelection(l),void 0,!0):fn(void 0,l,!0):R!==`none`&&Ml(c.selectRow,e,n)?s.hasIndex(u)?dn(s.remove(u),void 0,!0):R===`single`?dn(ur.fromSingleSelection(u),void 0,!0):dn(void 0,u,!0):!Xr&&r!==void 0&&Ml(c.activateCell,e,n)?u===b&&Ht?window.setTimeout(()=>{let e=dr(l);lr(e??l)},0):(C?.([l-H,u]),Qn(r,!0)):U.current.range.height>1&&Ml(c.downFill,e,n)?Ar():U.current.range.width>1&&Ml(c.rightFill,e,n)?kr():Ml(c.goToNextPage,e,n)?u+=Math.max(1,Dn.current.height-4):Ml(c.goToPreviousPage,e,n)?u-=Math.max(1,Dn.current.height-4):Ml(c.goToFirstCell,e,n)?(a(void 0),u=0,l=0):Ml(c.goToLastCell,e,n)?(a(void 0),u=2**53-1,l=2**53-1):Ml(c.selectToFirstCell,e,n)?(a(void 0),Hr([-2,-2])):Ml(c.selectToLastCell,e,n)?(a(void 0),Hr([2,2])):Xr?(Ml(c.closeOverlay,e,n)&&a(void 0),Ml(c.acceptOverlayDown,e,n)&&(a(void 0),u++),Ml(c.acceptOverlayUp,e,n)&&(a(void 0),u--),Ml(c.acceptOverlayLeft,e,n)&&(a(void 0),l--),Ml(c.acceptOverlayRight,e,n)&&(a(void 0),l++)):(Ml(c.goDownCell,e,n)?u+=1:Ml(c.goUpCell,e,n)?--u:Ml(c.goRightCell,e,n)?l+=1:Ml(c.goLeftCell,e,n)?--l:Ml(c.goDownCellRetainSelection,e,n)?(u+=1,d=!0):Ml(c.goUpCellRetainSelection,e,n)?(--u,d=!0):Ml(c.goRightCellRetainSelection,e,n)?(l+=1,d=!0):Ml(c.goLeftCellRetainSelection,e,n)?(--l,d=!0):Ml(c.goToLastRow,e,n)?u=b-1:Ml(c.goToFirstRow,e,n)?u=-(2**53-1):Ml(c.goToLastColumn,e,n)?l=2**53-1:Ml(c.goToFirstColumn,e,n)?l=-(2**53-1):(L===`rect`||L===`multi-rect`)&&(Ml(c.selectGrowDown,e,n)?Hr([0,1]):Ml(c.selectGrowUp,e,n)?Hr([0,-1]):Ml(c.selectGrowRight,e,n)?Hr([1,0]):Ml(c.selectGrowLeft,e,n)?Hr([-1,0]):Ml(c.selectToLastRow,e,n)?Hr([0,2]):Ml(c.selectToFirstRow,e,n)?Hr([0,-2]):Ml(c.selectToLastColumn,e,n)?Hr([2,0]):Ml(c.selectToFirstColumn,e,n)&&Hr([-2,0])),f=n.didMatch);let p=Ur(l,u,!1,d),m=n.didMatch;return m&&(p||!f||mt)&&t(),m},[Xr,U,zt,_e,R,L,H,b,Ur,nn,je,y.length,ln,mt,Yr,fn,dn,Ht,dr,lr,C,Qn,Ar,kr,Hr]),Qr=g.useCallback(e=>{let t=!1;if(ue!==void 0&&ue({...e,cancel:()=>{t=!0}}),t||Zr(e)||U.current===void 0)return;let[n,r]=U.current.cell,i=Dn.current;if(pe&&!e.metaKey&&!e.ctrlKey&&U.current!==void 0&&e.key.length===1&&/[ -~]/g.test(e.key)&&e.bounds!==void 0&&ir(x([n-H,Math.max(0,Math.min(r,b-1))]))){if((!Ht||r!==b)&&(i.y>r||r>i.y+i.height||i.x>n||n>i.x+i.width))return;Qn(e.bounds,!0,e.key),e.stopPropagation(),e.preventDefault()}},[pe,ue,Zr,U,x,H,b,Ht,Qn]),$r=g.useCallback((e,t)=>{let n=e.location[0]-H;if(e.kind===`header`&&ie?.(n,{...e,preventDefault:t}),e.kind===`group-header`){if(n<0)return;ae?.(n,{...e,preventDefault:t})}if(e.kind===`cell`){let[r,i]=e.location;re?.([n,i],{...e,preventDefault:t}),wa(U,e.location)||Ur(r,i,!1,!1)}},[U,re,ae,ie,H,Ur]),ei=g.useCallback(async e=>{if(!zt.paste)return;function t(e,t,n,r){let i=typeof n==`object`?n?.join(` -`)??``:n?.toString()??``;if(!rr(e)&&ir(e)&&e.readonly!==!0){let a=E?.(i,e);if(a!==void 0&&nr(a))return{location:t,value:a};let o=_n(e);if(o===void 0)return;if(o.kind===W.Custom){Wt(e.kind===W.Custom);let n=o.onPaste?.(i,e.data);return n===void 0?void 0:{location:t,value:{...e,data:n}}}{let a=o.onPaste?.(i,e,{formatted:r,formattedString:typeof r==`string`?r:r?.join(` -`),rawValue:n});return a===void 0?void 0:(Wt(a.kind===e.kind),{location:t,value:a})}}}let n=U.columns,r=U.rows,i=u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,a;if(U.current===void 0?n.length===1?a=[n.first()??0,0]:r.length===1&&(a=[H,r.first()??0]):a=[U.current.range.x,U.current.range.y],i&&a!==void 0){let n,r,i=`text/plain`,o=`text/html`;if(navigator.clipboard.read!==void 0){let e=await navigator.clipboard.read();for(let t of e){if(t.types.includes(o)){let e=Gl(await(await t.getType(o)).text());if(e!==void 0){n=e;break}}t.types.includes(i)&&(r=await(await t.getType(i)).text())}}else if(navigator.clipboard.readText!==void 0)r=await navigator.clipboard.readText();else if(e!==void 0&&e?.clipboardData!==null)e.clipboardData.types.includes(o)&&(n=Gl(e.clipboardData.getData(o))),n===void 0&&e.clipboardData.types.includes(i)&&(r=e.clipboardData.getData(i));else return;let[s,c]=a,l=[];do if(Ce===void 0){let e=Yn(a),i=r??n?.map(e=>e.map(e=>e.rawValue).join(` `)).join(` `)??``,o=t(e,a,i,void 0);o!==void 0&&l.push(o)}else{if(n===void 0){if(r===void 0)return;n=Jl(r)}if(Ce===!1||typeof Ce==`function`&&Ce?.([a[0]-H,a[1]],n.map(e=>e.map(e=>e.rawValue?.toString()??``)))!==!0)return;for(let[e,r]of n.entries()){if(e+c>=b)break;for(let[n,i]of r.entries()){let r=[n+s,e+c],[a,o]=r;if(a>=wn.length||o>=zn)continue;let u=t(Yn(r),r,i.rawValue,i.formatted);u!==void 0&&l.push(u)}}}while(0);Bn(l),Ln.current?.damage(l.map(e=>({cell:e.location})))}},[E,_n,Yn,U,zt.paste,wn.length,Bn,zn,Ce,H,b]);Gr(`paste`,ei,f,!1,!0);let ti=g.useCallback(async(e,t)=>{if(!zt.copy)return;let n=t===!0||u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0,r=U.columns,i=U.rows,a=(t,n)=>{Yl(we?[n.map(e=>({kind:W.Text,data:y[e].title,displayData:y[e].title,allowOverlay:!1})),...t]:t,n,e)};if(n&&Qt!==void 0){if(U.current!==void 0){let e=Qt(U.current.range,Zt.current.signal);typeof e!=`object`&&(e=await e()),a(e,(0,ul.default)(U.current.range.x-H,U.current.range.x+U.current.range.width-H))}else if(i!==void 0&&i.length>0){let e=[...i].map(e=>{let t=Qt({x:H,y:e,width:y.length,height:1},Zt.current.signal);return typeof t==`object`?t[0]:t().then(e=>e[0])});e.some(e=>e instanceof Promise)?a(await Promise.all(e),(0,ul.default)(y.length)):a(e,(0,ul.default)(y.length))}else if(r.length>0){let e=[],t=[];for(let n of r){let r=Qt({x:n,y:0,width:1,height:b},Zt.current.signal);typeof r!=`object`&&(r=await r()),e.push(r),t.push(n-H)}e.length===1?a(e[0],t):a(e.reduce((e,t)=>e.map((e,n)=>[...e,...t[n]])),t)}}},[y,Qt,U,zt.copy,H,b,we]);Gr(`copy`,ti,f,!1,!1),Gr(`cut`,g.useCallback(async e=>{if(zt.cut&&(u.current?.contains(document.activeElement)===!0||s.current?.contains(document.activeElement)===!0)&&(await ti(e),U.current!==void 0)){let e={current:{cell:U.current.cell,range:U.current.range,rangeStack:[]},rows:ur.empty(),columns:ur.empty()},t=ln?.(e);if(t===!1||(e=t===!0?e:t,e.current===void 0))return;Yr(e.current.range)}},[Yr,U,zt.cut,ti,ln]),f,!1,!1);let ni=g.useCallback((e,t)=>{if(se!==void 0){H!==0&&(e=e.map(e=>[e[0]-H,e[1]])),se(e,t);return}if(e.length===0||t===-1)return;let[n,r]=e[t];(d.current===void 0||d.current[0]!==n||d.current[1]!==r)&&(d.current=[n,r],Ur(n,r,!1,!1))},[se,H,Ur]),[ri,ii]=Pe?.current?.cell??[],oi=g.useRef(er);oi.current=er,g.useLayoutEffect(()=>{kn.current||ri===void 0||ii===void 0||ri===tn.current?.current?.cell[0]&&ii===tn.current?.current?.cell[1]||oi.current(ri,ii),kn.current=!1},[ri,ii]);let ci=U.current!==void 0&&(U.current.cell[0]>=wn.length||U.current.cell[1]>=zn);g.useLayoutEffect(()=>{ci&&nn(xu,!1)},[ci,nn]);let li=g.useMemo(()=>Ht===!0&&Be?.tint===!0?ur.fromSingleSelection(zn-1):ur.empty(),[zn,Ht,Be?.tint]),ui=g.useCallback(e=>typeof Ge==`boolean`?Ge:Ge?.(e-H)??!0,[H,Ge]),di=g.useMemo(()=>{if(xr===void 0||s.current===null)return null;let{bounds:e,group:t}=xr,n=s.current.getBoundingClientRect();return g.createElement(Al,{bounds:e,group:t,canvasBounds:n,onClose:()=>Sr(void 0),onFinish:e=>{Sr(void 0),N?.(t,e)}})},[N,xr]),fi=Math.min(wn.length,B+ +!!Vt);g.useImperativeHandle(t,()=>({appendRow:(e,t)=>lr(e+H,t),updateCells:e=>(H!==0&&(e=e.map(e=>({cell:[e.cell[0]+H,e.cell[1]]}))),Ln.current?.damage(e)),getBounds:(e,t)=>{if(s?.current!==null&&u?.current!==null){if(e===void 0&&t===void 0){let e=s.current.getBoundingClientRect(),t=e.width/u.current.clientWidth;return{x:e.x-u.current.scrollLeft*t,y:e.y-u.current.scrollTop*t,width:u.current.scrollWidth*t,height:u.current.scrollHeight*t}}return Ln.current?.getBounds((e??0)+H,t)}},focus:()=>Ln.current?.focus(),emit:async e=>{switch(e){case`delete`:Qr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!1,key:`Delete`,keyCode:46,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-right`:Qr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`r`,keyCode:82,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`fill-down`:Qr({bounds:void 0,cancel:()=>void 0,stopPropagation:()=>void 0,preventDefault:()=>void 0,ctrlKey:!0,key:`d`,keyCode:68,metaKey:!1,shiftKey:!1,altKey:!1,rawEvent:void 0,location:void 0});break;case`copy`:await ti(void 0,!0);break;case`paste`:await ei()}},scrollTo:er,remeasureColumns:e=>{for(let t of e)Tr(t+H)}}),[lr,Tr,ti,Qr,ei,H,er]);let[pi,mi]=Pr??[],hi=g.useCallback(e=>{let[t,n]=e;n===-1?_e!==`none`&&(fn(ur.fromSingleSelection(t),void 0,!1),Rn()):(pi!==t||mi!==n)&&(un({cell:e,range:{x:t,y:n,width:1,height:1}},!0,!1,`keyboard-nav`),er(t,n))},[_e,Rn,er,pi,mi,un,fn]),[gi,_i]=g.useState(!1),vi=g.useRef((0,Wr.default)(e=>{_i(e)},5)),yi=g.useCallback(()=>{vi.current(!0),U.current===void 0&&U.columns.length===0&&U.rows.length===0&&c===void 0&&un({cell:[H,In],range:{x:H,y:In,width:1,height:1}},!0,!1,`keyboard-select`)},[In,U,c,H,un]),bi=g.useCallback(()=>{vi.current(!1)},[]),[xi,Si]=g.useMemo(()=>{let e,t=et?.scrollbarWidthOverride??ai(),n=b+ +!!Ht;if(typeof Nt==`number`)e=xn+n*Nt;else{let t=0,r=Math.min(n,10);for(let e=0;et.width+e,0)+t;return[`${Math.min(1e5,r)}px`,`${Math.min(1e5,e)}px`]},[wn,et?.scrollbarWidthOverride,Nt,b,Ht,xn]),Ci=g.useMemo(()=>ho(pn),[pn]);return g.createElement(vo.Provider,{value:pn},g.createElement($l,{style:Ci,className:j,inWidth:_??xi,inHeight:v??Si},g.createElement(Dl,{fillHandle:Qe,drawFocusRing:$e,experimental:et,fixedShadowX:tt,fixedShadowY:nt,getRowThemeOverride:m,headerIcons:rt,imageWindowLoader:it,initialSize:at,isDraggable:ot,onDragLeave:st,onRowMoved:ct,overscrollX:Lt,overscrollY:Rt,preventDiagonalScrolling:dt,rightElement:ft,rightElementProps:pt,smoothScrollX:ht,smoothScrollY:gt,className:j,enableGroups:bn,onCanvasFocused:yi,onCanvasBlur:bi,canvasRef:s,onContextMenu:$r,theme:pn,cellXOffset:Fn,cellYOffset:In,accessibilityHeight:An.height,onDragEnd:zr,columns:wn,nonGrowWidth:yn,drawHeader:sn,onColumnProposeMove:ee,drawCell:cn,disabledRows:li,freezeColumns:fi,lockColumns:H,firstColAccessible:H===0,getCellContent:Yn,minColumnWidth:kt,maxColumnWidth:At,searchInputRef:o,showSearch:Yt,onSearchClose:Xt,highlightRegions:qn,getCellsForSelection:Qt,getGroupDetails:Xn,headerHeight:Pt,isFocused:gi,groupHeaderHeight:bn?Ft:0,freezeTrailingRows:Ve+(Ht&&Be?.sticky===!0?1:0),hasAppendRow:Ht,onColumnResize:rn,onColumnResizeEnd:an,onColumnResizeStart:on,onCellFocused:hi,onColumnMoved:Ir,onDragStart:Rr,onHeaderMenuClick:Nr,onItemHovered:Vr,isFilling:c?.fillHandle===!0,onMouseMove:Mr,onKeyDown:Qr,onKeyUp:de,onMouseDown:br,onMouseUp:jr,onDragOverCell:Ke,onDrop:qe,onSearchResultsChanged:ni,onVisibleRegionChanged:Fr,clientSize:mn,rowHeight:Nt,searchResults:ce,searchValue:le,onSearchValueChange:F,rows:zn,scrollRef:u,selection:U,translateX:An.tx,translateY:An.ty,verticalBorder:ui,gridRef:Ln,getCellRenderer:_n}),di,i!==void 0&&g.createElement(g.Suspense,{fallback:null},g.createElement(gu,{...i,validateCell:en,bloom:k,id:Jr,getCellRenderer:_n,className:et?.isSubGrid===!0?`click-outside-ignore`:void 0,provideEditor:ze,imageEditorOverride:p,onFinishEditing:qr,markdownDivCreateNode:h,isOutsideClick:St}))))}),Cu=20,wu={getAccessibilityString:e=>e.data?.toString()??`false`,kind:W.Boolean,needsHover:!0,useLabel:!1,needsHoverPosition:!0,measure:()=>50,draw:e=>Tu(e,e.cell.data,or(e.cell),e.cell.maxSize??Cu),onDelete:e=>({...e,data:!1}),onClick:e=>{let{cell:t,posX:n,posY:r,bounds:i,theme:a}=e,{width:o,height:s,x:c,y:l}=i,u=t.maxSize??Cu,d=Math.floor(i.y+s/2),f=Zr(u,s,a.cellVerticalPadding),p=Yr(Xr(t.contentAlign??`center`,c,o,a.cellHorizontalPadding,f),d,f),m=Qr(c+n,l+r,p);if(or(t)&&m)return{...t,data:Xl(t.data)}},onPaste:(e,t)=>{let n=null;return e.toLowerCase()===`true`?n=!0:e.toLowerCase()===`false`?n=!1:e.toLowerCase()===`indeterminate`&&(n=void 0),n===t.data?void 0:{...t,data:n}}};function Tu(e,t,n,r){if(!n&&t===null)return;let{ctx:i,hoverAmount:a,theme:o,rect:s,highlighted:c,hoverX:l,hoverY:u,cell:{contentAlign:d}}=e,{x:f,y:p,width:m,height:h}=s,g=n?.65+.35*a:.4;t===null&&(g*=a),g!==0&&(i.globalAlpha=g,bs(i,o,t,f,p,m,h,c,l,u,r,d),i.globalAlpha=1)}var Eu=br(`div`)({name:`BubblesOverlayEditorStyle`,class:`gdg-b1ygi5by`,propsAsIs:!1}),Du=e=>{let{bubbles:t}=e;return g.createElement(Eu,null,t.map((e,t)=>g.createElement(`div`,{key:t,className:`boe-bubble`},e)),g.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))},Ou={getAccessibilityString:e=>ci(e.data),kind:W.Bubble,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n).width+t+20,0)+2*n.cellHorizontalPadding-4,draw:e=>Au(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return g.createElement(Du,{bubbles:t.data})},onPaste:()=>void 0},ku=4;function Au(e,t){let{rect:n,theme:r,ctx:i,highlighted:a}=e,{x:o,y:s,width:c,height:l}=n,u=ku,d=o+r.cellHorizontalPadding,f=[];for(let e of t){if(d>o+c)break;let t=Ua(e,i,r.baseFontFull).width;f.push({x:d,width:t}),d+=t+16+u}i.beginPath();for(let e of f)no(i,e.x,s+(l-20)/2,e.width+16,20,r.roundingRadius??10);i.fillStyle=a?r.bgBubbleSelected:r.bgBubble,i.fill();for(let[e,n]of f.entries())i.beginPath(),i.fillStyle=r.textBubble,i.fillText(t[e],n.x+8,s+l/2+Ga(i,r))}var ju=br(`div`)({name:`DrilldownOverlayEditorStyle`,class:`gdg-d4zsq0x`,propsAsIs:!1}),Mu=e=>{let{drilldowns:t}=e;return g.createElement(ju,null,t.map((e,t)=>g.createElement(`div`,{key:t,className:`doe-bubble`},e.img!==void 0&&g.createElement(`img`,{src:e.img}),g.createElement(`div`,null,e.text))))},Nu={getAccessibilityString:e=>ci(e.data.map(e=>e.text)),kind:W.Drilldown,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:(e,t,n)=>t.data.reduce((t,n)=>e.measureText(n.text).width+t+20+(n.img===void 0?0:18),0)+2*n.cellHorizontalPadding-4,draw:e=>Lu(e,e.cell.data),provideEditor:()=>e=>{let{value:t}=e;return g.createElement(Mu,{drilldowns:t.data})},onPaste:()=>void 0},Pu=4,Fu={};function Iu(e,t,n,r){let i=Math.ceil(window.devicePixelRatio),a=n-10,o=n*i,s=r+5,c=r*3,l=(c+10)*i,u=`${e},${t},${i},${n}`;if(Fu[u]!==void 0)return{el:Fu[u],height:o,width:l,middleWidth:4*i,sideWidth:s*i,padding:5*i,dpr:i};let d=document.createElement(`canvas`),f=d.getContext(`2d`);return f===null?null:(d.width=l,d.height=o,f.scale(i,i),Fu[u]=d,f.beginPath(),no(f,5,5,c,a,r),f.shadowColor=`rgba(24, 25, 34, 0.4)`,f.shadowBlur=1,f.fillStyle=e,f.fill(),f.shadowColor=`rgba(24, 25, 34, 0.3)`,f.shadowOffsetY=1,f.shadowBlur=5,f.fillStyle=e,f.fill(),f.shadowOffsetY=0,f.shadowBlur=0,f.shadowBlur=0,f.beginPath(),no(f,5.5,5.5,c,a,r),f.strokeStyle=t,f.lineWidth=1,f.stroke(),{el:d,height:o,width:l,sideWidth:s*i,middleWidth:r*i,padding:5*i,dpr:i})}function Lu(e,t){let{rect:n,theme:r,ctx:i,imageLoader:a,col:o,row:s}=e,{x:c,width:l}=n,u=r.baseFontFull,d=Qa(i,u),f=Math.min(n.height,Math.max(16,Math.ceil(d*r.lineHeight)*2)),p=Math.floor(n.y+(n.height-f)/2),m=f-10,h=Pu,g=c+r.cellHorizontalPadding,_=r.roundingRadius??6,v=Iu(r.bgCell,r.drilldownBorder,f,_),y=[];for(let e of t){if(g>c+l)break;let t=Ua(e.text,i,u).width,n=0;e.img!==void 0&&a.loadOrGetImage(e.img,o,s)!==void 0&&(n=m-8+4);let r=t+n+16;y.push({x:g,width:r}),g+=r+h}if(v!==null){let{el:e,height:t,middleWidth:n,sideWidth:r,width:a,dpr:o,padding:s}=v,c=r/o,l=s/o;for(let o of y){let s=Math.floor(o.x),u=Math.floor(o.width),d=u-(c-l)*2;i.imageSmoothingEnabled=!1,i.drawImage(e,0,0,r,t,s-l,p,c,f),d>0&&i.drawImage(e,r,0,n,t,s+(c-l),p,d,f),i.drawImage(e,a-r,0,r,t,s+u-(c-l),p,c,f),i.imageSmoothingEnabled=!0}}i.beginPath();for(let[e,n]of y.entries()){let c=t[e],l=n.x+8;if(c.img!==void 0){let e=a.loadOrGetImage(c.img,o,s);if(e!==void 0){let t=m-8,n=0,a=0,o=e.width,s=e.height;o>s?(n+=(o-s)/2,o=s):s>o&&(a+=(s-o)/2,s=o),i.beginPath(),no(i,l,p+f/2-t/2,t,t,r.roundingRadius??3),i.save(),i.clip(),i.drawImage(e,n,a,o,s,l,p+f/2-t/2,t,t),i.restore(),l+=t+4}}i.beginPath(),i.fillStyle=r.textBubble,i.fillText(c.text,l,p+f/2+Ga(i,r))}}var Ru={getAccessibilityString:e=>e.data.join(`, `),kind:W.Image,needsHover:!1,useLabel:!1,needsHoverPosition:!1,draw:e=>Bu(e,e.cell.displayData??e.cell.data,e.cell.rounding??e.theme.roundingRadius??4,e.cell.contentAlign),measure:(e,t)=>t.data.length*50,onDelete:e=>({...e,data:[]}),provideEditor:()=>e=>{let{value:t,onFinishedEditing:n,imageEditorOverride:r}=e,i=r??di;return g.createElement(i,{urls:t.data,canWrite:t.readonly!==!1,onCancel:n,onChange:e=>{n({...t,data:[e]})}})},onPaste:(e,t)=>{e=e.trim();let n=e.split(`,`).map(e=>{try{return new URL(e),e}catch{return}}).filter(e=>e!==void 0);if(!(n.length===t.data.length&&n.every((e,n)=>e===t.data[n])))return{...t,data:n}}},zu=4;function Bu(e,t,n,r){let{rect:i,col:a,row:o,theme:s,ctx:c,imageLoader:l}=e,{x:u,y:d,height:f,width:p}=i,m=f-s.cellVerticalPadding*2,h=[],g=0;for(let e=0;e0&&(c.beginPath(),no(c,_,d+s.cellVerticalPadding,t,m,n),c.save(),c.clip()),c.drawImage(e,_,d+s.cellVerticalPadding,t,m),n>0&&c.restore(),_+=t+zu}}function Vu(e,t){let n=e*49632+t*325176;return n^=n<<13,n^=n>>17,n^=n<<5,n/4294967295*2}var Hu={getAccessibilityString:()=>``,kind:W.Loading,needsHover:!1,useLabel:!1,needsHoverPosition:!1,measure:()=>120,draw:e=>{let{cell:t,col:n,row:r,ctx:i,rect:a,theme:o}=e;if(t.skeletonWidth===void 0||t.skeletonWidth===0)return;let s=t.skeletonWidth;t.skeletonWidthVariability!==void 0&&t.skeletonWidthVariability>0&&(s+=Math.round(Vu(n,r)*t.skeletonWidthVariability));let c=o.cellHorizontalPadding,l=t.skeletonHeight??Math.min(18,a.height-2*o.cellVerticalPadding);no(i,a.x+c,a.y+(a.height-l)/2,s,l,o.roundingRadius??3),i.fillStyle=ua(o.textDark,.1),i.fill()},onPaste:()=>void 0},Uu=br(`div`)({name:`MarkdownOverlayEditorStyle`,class:`gdg-m1pnx84e`,propsAsIs:!1,vars:{"m1pnx84e-0":[e=>e.targetWidth,`px`]}}),Wu=e=>{let{value:t,onChange:n,forceEditMode:r,createNode:i,targetRect:a,onFinish:o,validatedSelection:s}=e,c=t.data,l=t.readonly===!0,[u,d]=g.useState(c===``||r),f=g.useCallback(()=>{d(e=>!e)},[]),p=c?`gdg-ml-6`:``;return u?g.createElement(Uu,{targetWidth:a.width-20},g.createElement(aa,{autoFocus:!0,highlight:!1,validatedSelection:s,value:c,onKeyDown:e=>{e.key===`Enter`&&e.stopPropagation()},onChange:n}),g.createElement(`div`,{className:`gdg-edit-icon gdg-checkmark-hover ${p}`,onClick:()=>o(t)},g.createElement(ei,null))):g.createElement(Uu,{targetWidth:a.width},g.createElement(ea,{contents:c,createNode:i}),!l&&g.createElement(g.Fragment,null,g.createElement(`div`,{className:`spacer`}),g.createElement(`div`,{className:`gdg-edit-icon gdg-edit-hover ${p}`,onClick:f},g.createElement($r,null))),g.createElement(`textarea`,{className:`gdg-md-edit-textarea gdg-input`,autoFocus:!0}))},Gu={getAccessibilityString:e=>e.data?.toString()??``,kind:W.Markdown,needsHover:!1,needsHoverPosition:!1,drawPrep:Xa,measure:(e,t,n)=>{let r=t.data.split(` -`)[0];return e.measureText(r).width+2*n.cellHorizontalPadding},draw:e=>to(e,e.cell.data,e.cell.contentAlign),onDelete:e=>({...e,data:``}),provideEditor:()=>e=>{let{onChange:t,value:n,target:r,onFinishedEditing:i,markdownDivCreateNode:a,forceEditMode:o,validatedSelection:s}=e;return g.createElement(Wu,{onFinish:i,targetRect:r,value:n,validatedSelection:s,onChange:e=>t({...n,data:e.target.value}),forceEditMode:o,createNode:a})},onPaste:(e,t)=>e===t.data?void 0:{...t,data:e}},Ku={getAccessibilityString:e=>e.row.toString(),kind:sr.Marker,needsHover:!0,needsHoverPosition:!1,drawPrep:qu,measure:()=>44,draw:e=>Yu(e,e.cell.row,e.cell.checked,e.cell.markerKind,e.cell.drawHandle,e.cell.checkboxStyle),onClick:e=>{let{bounds:t,cell:n,posX:r,posY:i}=e,{width:a,height:o}=t,s=n.drawHandle?7+(a-7)/2:a/2,c=o/2;if(Math.abs(r-s)<=10&&Math.abs(i-c)<=10)return{...n,checked:!n.checked}},onPaste:()=>void 0};function qu(e,t){let{ctx:n,theme:r}=e,i=r.markerFontFull,a=t??{};return a?.font!==i&&(n.font=i,a.font=i),a.deprep=Ju,n.textAlign=`center`,a}function Ju(e){let{ctx:t}=e;t.textAlign=`start`}function Yu(e,t,n,r,i,a){let{ctx:o,rect:s,hoverAmount:c,theme:l}=e,{x:u,y:d,width:f,height:p}=s,m=n?1:r===`checkbox-visible`?.6+.4*c:c;if(r!==`number`&&m>0){o.globalAlpha=m;let e=7*(n?c:1);if(bs(o,l,n,i?u+e:u,d,i?f-e:f,p,!0,void 0,void 0,18,`center`,a),i){o.globalAlpha=c,o.beginPath();for(let e of[3,6])for(let t of[-5,-1,3])o.rect(u+e,d+p/2+t,2,2);o.fillStyle=l.textLight,o.fill(),o.beginPath()}o.globalAlpha=1}if(r===`number`||r===`both`&&!n){let e=t.toString(),n=l.markerFontFull,i=u+f/2;r===`both`&&c!==0&&(o.globalAlpha=1-c),o.fillStyle=l.textLight,o.font=n,o.fillText(e,i,d+p/2+Ga(o,n)),c!==0&&(o.globalAlpha=1)}}var Xu={getAccessibilityString:()=>``,kind:sr.NewRow,needsHover:!0,needsHoverPosition:!1,measure:()=>200,draw:e=>Zu(e,e.cell.hint,e.cell.icon),onPaste:()=>void 0};function Zu(e,t,n){let{ctx:r,rect:i,hoverAmount:a,theme:o,spriteManager:s}=e,{x:c,y:l,width:u,height:d}=i;r.beginPath(),r.globalAlpha=a,r.rect(c+1,l+1,u,d-2),r.fillStyle=o.bgHeaderHovered,r.fill(),r.globalAlpha=1,r.beginPath();let f=t!==``,p=0;if(n!==void 0){let e=d-8,t=c+4,i=l+4;s.drawSprite(n,`normal`,r,t,i,e,o,f?1:a),p=e}else{p=24;let e=f?12:a*12,t=f?0:(1-a)*12*.5,n=o.cellHorizontalPadding+4;e>0&&(r.moveTo(c+n+t,l+d/2),r.lineTo(c+n+t+e,l+d/2),r.moveTo(c+n+t+e*.5,l+d/2-e*.5),r.lineTo(c+n+t+e*.5,l+d/2+e*.5),r.lineWidth=2,r.strokeStyle=o.bgIconHeader,r.lineCap=`round`,r.stroke())}r.fillStyle=o.textMedium,r.fillText(t,p+c+o.cellHorizontalPadding+.5,l+d/2+Ga(r,o)),r.beginPath()}var Qu=g.lazy(async()=>await pu(()=>import(`./number-overlay-editor-DAo7GPxB.js`),[])),$u={getAccessibilityString:e=>e.data?.toString()??``,kind:W.Number,needsHover:!1,needsHoverPosition:!1,useLabel:!0,drawPrep:Xa,draw:e=>to(e,e.cell.displayData,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.displayData).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:void 0}),provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return g.createElement(g.Suspense,{fallback:null},g.createElement(Qu,{highlight:t,disabled:r.readonly===!0,value:r.data,fixedDecimals:r.fixedDecimals,allowNegative:r.allowNegative,thousandSeparator:r.thousandSeparator,decimalSeparator:r.decimalSeparator,validatedSelection:i,onChange:e=>n({...r,data:Number.isNaN(e.floatValue??0)?0:e.floatValue})}))},onPaste:(e,t,n)=>{let r=typeof n.rawValue==`number`?n.rawValue:Number.parseFloat(typeof n.rawValue==`string`?n.rawValue:e);if(!(Number.isNaN(r)||t.data===r))return{...t,data:r,displayData:n.formattedString??t.displayData}}},ed={getAccessibilityString:()=>``,measure:()=>108,kind:W.Protected,needsHover:!1,needsHoverPosition:!1,draw:td,onPaste:()=>void 0};function td(e){let{ctx:t,theme:n,rect:r}=e,{x:i,y:a,height:o}=r;t.beginPath();let s=2.5,c=i+n.cellHorizontalPadding+s,l=a+o/2,u=Math.cos(Jr(30))*s,d=Math.sin(Jr(30))*s;for(let e=0;e<12;e++)t.moveTo(c,l-s),t.lineTo(c,l+s),t.moveTo(c+u,l-d),t.lineTo(c-u,l+d),t.moveTo(c-u,l-d),t.lineTo(c+u,l+d),c+=8;t.lineWidth=1.1,t.lineCap=`square`,t.strokeStyle=n.textLight,t.stroke()}var nd={getAccessibilityString:e=>e.data?.toString()??``,kind:W.RowID,needsHover:!1,needsHoverPosition:!1,drawPrep:(e,t)=>Xa(e,t,e.theme.textLight),draw:e=>to(e,e.cell.data,e.cell.contentAlign),measure:(e,t,n)=>e.measureText(t.data).width+n.cellHorizontalPadding*2,provideEditor:()=>e=>{let{isHighlighted:t,onChange:n,value:r,validatedSelection:i}=e;return g.createElement(aa,{highlight:t,autoFocus:r.readonly!==!0,disabled:r.readonly!==!1,value:r.data,validatedSelection:i,onChange:e=>n({...r,data:e.target.value})})},onPaste:()=>void 0},rd={getAccessibilityString:e=>e.data?.toString()??``,kind:W.Text,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!1,drawPrep:Xa,useLabel:!0,draw:e=>{let{cell:t,hoverAmount:n,hyperWrapping:r,ctx:i,rect:a,theme:o,overrideCursor:s}=e,{displayData:c,contentAlign:l,hoverEffect:u,allowWrapping:d}=t;if(u===!0&&n>0){i.textBaseline=`alphabetic`;let e=o.cellHorizontalPadding,t=o.cellVerticalPadding,r=Ua(c,i,o.baseFontFull,`alphabetic`),l=a.height-t,u=Math.min(l,r.actualBoundingBoxAscent*2.5);i.beginPath(),no(i,a.x+e/2,a.y+(a.height-u)/2+1,r.width+e*3,u-1,o.roundingRadius??4),i.globalAlpha=n,i.fillStyle=ua(o.textDark,.1),i.fill(),i.globalAlpha=1,i.fillStyle=o.textDark,i.textBaseline=`middle`,s?.(`text`)}to(e,c,l,d,r)},measure:(e,t,n)=>{let r=t.displayData.split(` -`,t.allowWrapping===!0?void 0:1),i=0;for(let t of r)i=Math.max(i,e.measureText(t).width);return i+2*n.cellHorizontalPadding},onDelete:e=>({...e,data:``}),provideEditor:e=>({disablePadding:e.allowWrapping===!0,editor:t=>{let{isHighlighted:n,onChange:r,value:i,validatedSelection:a}=t;return g.createElement(aa,{style:e.allowWrapping===!0?{padding:`3px 8.5px`}:void 0,highlight:n,autoFocus:i.readonly!==!0,disabled:i.readonly===!0,altNewline:!0,value:i.data,validatedSelection:a,onChange:e=>r({...i,data:e.target.value})})}}),onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}},id=br(`div`)({name:`UriOverlayEditorStyle`,class:`gdg-u1rrojo`,propsAsIs:!1}),ad=e=>{let{uri:t,onChange:n,forceEditMode:r,readonly:i,validatedSelection:a,preview:o}=e,[s,c]=g.useState(!i&&(t===``||r)),l=g.useCallback(()=>{c(!0)},[]);return s?g.createElement(aa,{validatedSelection:a,highlight:!0,autoFocus:!0,value:t,onChange:n}):g.createElement(id,null,g.createElement(`a`,{className:`gdg-link-area`,href:t,target:`_blank`,rel:`noopener noreferrer`},o),!i&&g.createElement(`div`,{className:`gdg-edit-icon`,onClick:l},g.createElement($r,null)),g.createElement(`textarea`,{className:`gdg-input`,autoFocus:!0}))};function od(e,t,n,r){let i=n.cellHorizontalPadding,a=t.height/2-e.actualBoundingBoxAscent/2,o=e.width,s=e.actualBoundingBoxAscent;return r===`right`?i=t.width-o-n.cellHorizontalPadding:r===`center`&&(i=t.width/2-o/2),{x:i,y:a,width:o,height:s}}var sd=[Ku,Xu,wu,Ou,Nu,Ru,Hu,Gu,$u,ed,nd,rd,{getAccessibilityString:e=>e.data?.toString()??``,kind:W.Uri,needsHover:e=>e.hoverEffect===!0,needsHoverPosition:!0,useLabel:!0,drawPrep:Xa,draw:e=>{let{cell:t,theme:n,overrideCursor:r,hoverX:i,hoverY:a,rect:o,ctx:s}=e,c=t.displayData??t.data,l=t.hoverEffect===!0;if(r!==void 0&&l&&i!==void 0&&a!==void 0){let{x:l,y:u,width:d,height:f}=od(Ua(c,s,n.baseFontFull),o,n,t.contentAlign);if(i>=l-4&&i<=l-4+d+8&&a>=u-4&&a<=u-4+f+8){let i=Ga(s,n.baseFontFull);r(`pointer`);let a=u-i;s.beginPath(),s.moveTo(o.x+l,Math.floor(o.y+a+f+5)+.5),s.lineTo(o.x+l+d,Math.floor(o.y+a+f+5)+.5),s.strokeStyle=n.linkColor,s.stroke(),s.save(),s.fillStyle=e.cellFillColor,to({...e,rect:{...o,x:o.x-1}},c,t.contentAlign),to({...e,rect:{...o,x:o.x-2}},c,t.contentAlign),to({...e,rect:{...o,x:o.x+1}},c,t.contentAlign),to({...e,rect:{...o,x:o.x+2}},c,t.contentAlign),s.restore()}}s.fillStyle=l?n.linkColor:n.textDark,to(e,c,t.contentAlign)},onClick:e=>{let{cell:t,bounds:n,posX:r,posY:i,theme:a}=e,o=t.displayData??t.data;if(t.hoverEffect!==!0||t.onClickUri===void 0)return;let s=Wa(o,a.baseFontFull);if(s===void 0)return;let c=od(s,n,a,t.contentAlign);ss({x:c.x-4,y:c.y-4,width:c.width+8,height:c.height+8},r,i)&&t.onClickUri(e)},measure:(e,t,n)=>e.measureText(t.displayData??t.data).width+n.cellHorizontalPadding*2,onDelete:e=>({...e,data:``}),provideEditor:e=>t=>{let{onChange:n,value:r,forceEditMode:i,validatedSelection:a}=t;return g.createElement(ad,{forceEditMode:r.readonly!==!0&&(i||e.hoverEffect===!0&&e.onClickUri!==void 0),uri:r.data,preview:r.displayData??r.data,validatedSelection:a,readonly:r.readonly===!0,onChange:e=>n({...r,data:e.target.value})})},onPaste:(e,t,n)=>e===t.data?void 0:{...t,data:e,displayData:n.formattedString??t.displayData}}],cd=c(o(((e,t)=>{var n=Ur(),r=on(),i=`Expected a function`;function a(e,t,a){var o=!0,s=!0;if(typeof e!=`function`)throw TypeError(i);return r(a)&&(o=`leading`in a?!!a.leading:o,s=`trailing`in a?!!a.trailing:s),n(e,t,{leading:o,maxWait:t,trailing:s})}t.exports=a}))(),1),ld=[],ud=class extends fo{imageLoaded=()=>void 0;loadedLocations=[];cache={};setCallback(e){this.imageLoaded=e}sendLoaded=(0,cd.default)(()=>{this.imageLoaded(new mo(this.loadedLocations)),this.loadedLocations=[]},20);clearOutOfWindow=()=>{let e=Object.keys(this.cache);for(let t of e){let e=this.cache[t],n=!1;for(let t=0;t{o||(o=!0,ld.length<12?ld.unshift(a):i||(a.src=``))}},c=new Promise(e=>a.addEventListener(`load`,()=>e(null)));requestAnimationFrame(async()=>{try{a.src=e,await c,await a.decode();let t=this.cache[r];if(t!==void 0&&!o){t.img=a;for(let e of t.cells)this.loadedLocations.push(uo(e));i=!0,this.sendLoaded()}}catch{s.cancel()}}),this.cache[r]=s}loadOrGetImage(e,t,n){let r=e,i=this.cache[r];if(i!==void 0){let e=so(t,n);return i.cells.includes(e)||i.cells.push(e),i.img}this.loadImage(e,t,n,r)}},dd=``,fd=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\||\+[-=]+(?:\+[-=]+)*\+|[-=]+(?:\+[-=]+)+)\s*$/m,pd=/^\s*(?:\|?\s*:?-{2,}:?\s*(?:\|\s*:?-{2,}:?\s*)+\|?|\|\s*:?-{2,}:?\s*\|)\s*$/,md=/^\s*\+[-=]+(?:\+[-=]+)*\+\s*$/,hd=/^\s*[-=]+(?:\+[-=]+)+\s*$/,gd=/^\s*(?:\(\d+\s+rows?\)|\d+\s+rows?\s+in\s+set(?:\s*\([^)]*\))?)\s*$/i,_d=/^\s*(?:`{3,}|~{3,})/,vd=/^\s*#{1,6}\s+(.+?)\s*#*\s*$/,yd=/^\s*(?:\*\*([^*]+)\*\*|__([^_]+)__)\s*:?\s*$/,bd=/^\s*(?:={3,}|-{3,})\s*$/;function xd(e){for(let t=0;t=0&&e[n]===`\\`;n--)t++;return t%2==0}function Cd(e){let t=e.trim();t.startsWith(`|`)&&(t=t.slice(1)),Sd(t)&&(t=t.slice(0,-1));let n=[],r=``;for(let e=0;ee.trim())}function Td(e){return md.test(e)||hd.test(e)}var Ed=32;function Dd(e){let t=e.replace(/(\*\*|__|`)*/g,``).replace(/\s+/g,` `).replace(/\s*:\s*$/,``).trim();return t?t.length>Ed?`${t.slice(0,31).trimEnd()}…`:t:null}function Od(e,t,n){if(t)return t;let r=n.slice(0,3).map(e=>e.trim()).filter(Boolean).join(`, `);return r?`Table ${e+1} (${r})`:`Table ${e+1}`}function kd(e,t){let n=vd.exec(e);if(n){let e=Dd(n[1]);if(e)return{title:e,consumedNextLine:!1}}let r=yd.exec(e);if(r){let e=Dd(r[1]??r[2]??``);if(e)return{title:e,consumedNextLine:!1}}if(t!==void 0&&bd.test(t)&&e.trim().length>0&&!xd(e)&&!Td(e)&&!_d.test(e)){let t=Dd(e);if(t)return{title:t,consumedNextLine:!0}}return null}function Ad(e){if(!e)return[];let t=e.startsWith(dd)?e.slice(1):e,n=t.slice(0,65536);if(!n.includes(`|`)||!fd.test(n))return[];let r=t.split(/\r?\n/),i=[],a=null,o=0;for(;o=2&&n.length>=1){let t=wd(n[0],!0);if(t.length>0&&!t.every(e=>e===``)){let r=n.slice(1).map(e=>wd(e,!0)),s=Ld(t,r,`,`),c=i.length,l=a;i.push({index:c,title:l,label:Od(c,l,t),headers:t,cleanedCsv:s,rows:r.length,cols:t.length,kind:`box`}),a=null,o=e;continue}}o++;continue}if(xd(e)&&!Td(e)&&!pd.test(e)&&!vd.test(e)&&o+10&&!t.every(e=>e===``)){let e=[],n=o+2;for(;n0&&!l.every(e=>e===``)){let e=t.slice(1).map(e=>wd(e,c)),r=Ld(l,e,`,`),s=i.length,u=a;i.push({index:s,title:u,label:Od(s,u,l),headers:l,cleanedCsv:r,rows:e.length,cols:l.length,kind:`box`}),a=null,o=n;continue}}let t=kd(e,r[o+1]);t?(a=t.title,o+=t.consumedNextLine?2:1):o++}return i}function jd(e,t=0){let n=Ad(e);if(n.length===0)return null;let r=n[Math.min(Math.max(0,Math.trunc(t)||0),n.length-1)];return{cleanedCsv:r.cleanedCsv,rows:r.rows,cols:r.cols,kind:r.kind}}var Md=``;function Nd(e){let t={",":0,";":0," ":0},n=`,`,r=-1,i=0,a=!1;for(let n=0;nr&&(n=e,r=t[e]);return n}function Pd(e,t,n){if(e[t]===`"`){let r=``,i=t+1;for(;;){if(i>=e.length)return[r,i];let t=e[i];if(t===`"`){if(e[i+1]===`"`)r+=`"`,i+=2;else{for(i++;i=o.length)break;o[t]===c?(p=t+1,m=!0):(p=o[t]===`\r`&&o[t+1]===` -`?t+2:t+1,l.push(d),u.push({start:f+s,end:t+s}),d=[])}d.length>0?(l.push(d),u.push({start:f+s,end:o.length+s})):l.length===0&&d.length===0&&o.length>0&&(l.push([``]),u.push({start:0+s,end:o.length+s}));let h=l.length>0?l[0]:[],g=h.length,_=l.slice(1),v=_.map(e=>e.length);return{headers:h,rows:_.map(e=>e.length===g?e:e.length>g?e.slice(0,g):[...e,...Array(g-e.length).fill(``)]),delimiter:c,rowWidths:v,rowSpans:u.slice(1)}}function Id(e,t=`,`){return e.map(e=>e.includes(`"`)?`"${e.replaceAll(`"`,`""`)}"`:e.includes(t)||e.includes(` -`)||e.includes(`\r`)?`"${e}"`:e).join(t)}function Ld(e,t,n=`,`){return[e,...t].map(e=>Id(e,n)).join(` -`)}function Rd(e,t){return Fd(e,t).headers}function zd(e){let t=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/,n=Array.from({length:e.headers.length},()=>!0),r=Array.from({length:e.headers.length},()=>!1);for(let i of e.rows)for(let e=0;ee&&r[t])}function Bd(e,t){let n=``,r=0;for(let{start:i,end:a,replacement:o}of t)n+=e.slice(r,i)+o,r=a;return n+e.slice(r)}function Vd(e,t){return e[t]===`\r`?e[t+1]===` -`?2:1:+(e[t]===` -`)}function Hd(e,t){return e[t-2]===`\r`&&e[t-1]===` -`?2:+(e[t-1]===`\r`||e[t-1]===` -`)}var Ud=``;function Wd(e,t){let n=+!!e.startsWith(Ud),r=t.rowSpans[0];return r===void 0?{start:n,end:n+e.slice(n).length-Hd(e,e.length)}:{start:n,end:r.start-Hd(e,r.start)}}function Gd(e,t,n){let r=[...new Set(n)].flatMap(e=>{let n=t.rowSpans[e];return n===void 0?[]:[n]}).sort((e,t)=>e.start-t.start).map(t=>({start:t.start,end:t.end+Vd(e,t.end),replacement:``}));return r.length===0?e:Bd(e,r)}function Kd(e,t,n){let r=new Set([...n].filter(e=>e>=0&&ee!r.has(t));a.push({start:n.start,end:n.end,replacement:Id(o,t.delimiter)})}return Bd(e,a)}function qd(e,t,n,r){if(!e||n<0||n>=t.headers.length)return e;let i=Wd(e,t),a=Rd(e.slice(i.start,i.end),t.delimiter);if(n>=a.length||a[n]===r)return e;let o=Id(a.map((e,t)=>t===n?r:e),t.delimiter);return e.slice(0,i.start)+o+e.slice(i.end)}function Jd(e=``){return{past:[],present:e,future:[]}}function Yd(e,t,n=50){if(t===e.present)return e;if(e.present===``&&e.past.length===0&&e.future.length===0)return{past:[],present:t,future:[]};let r=[...e.past,e.present];return{past:r.length>n?r.slice(r.length-n):r,present:t,future:[]}}function Xd(e){if(e.past.length===0)return e;let t=e.past[e.past.length-1];return{past:e.past.slice(0,e.past.length-1),present:t,future:[e.present,...e.future]}}function Zd(e){if(e.future.length===0)return e;let[t,...n]=e.future,r=[...e.past,e.present];return{past:r.length>50?r.slice(r.length-50):r,present:t,future:n}}function Qd(e){if(e.altKey||!e.metaKey&&!e.ctrlKey)return null;let t=e.key.toLowerCase();return t===`z`?e.shiftKey?`redo`:`undo`:t===`y`&&!e.shiftKey?`redo`:null}var $d=/^[+-]?\d{16,}$/;function ef(e,t){let n=Array.from({length:e.length},(e,t)=>t);if(t===``)return n;let r=t.toLowerCase();return n.filter(t=>{let n=e[t];for(let e=0;e{let o=t[e]?.[n]??``,s=t[r]?.[n]??``;if(i){let e=o===``?NaN:Number(o),t=s===``?NaN:Number(s),n=Number.isNaN(e),r=Number.isNaN(t);if(n||r)return n&&r?0:n?1:-1;if($d.test(o)&&$d.test(s)){let e=BigInt(o),t=BigInt(s);return a*(et))}return a*(e-t)}return a*o.localeCompare(s)})}function nf(e,t,n){if(n.length===0||e.headers.length===0)return``;let r=e.delimiter||`,`;return[Id(n.map(t=>e.headers[t]??``),r),...t.filter(t=>t>=0&&tId(n.map(n=>e.rows[t]?.[n]??``),r))].join(` -`)}var rf=` - -`;function af(e,t){return Math.max(0,Math.min(e,t))}function of(e,t,n,r){let i=e.headers.length,a=[];for(let o of n.ranges){let n=af(o.x,r+i),s=af(o.x+o.width,r+i);if(s<=r)continue;let c=Math.max(0,n-r),l=s-r;if(l<=c)continue;let u=af(o.y,t.length),d=af(o.y+o.height,t.length);if(d<=u)continue;let f=e.headers.slice(c,l),p=[];for(let n=u;ni[c+t]??``))}p.length!==0&&a.push(Ld(f,p,e.delimiter))}if(a.length>0)return a.join(rf);let o=[...n.rows].filter(e=>e>=0&&et[e]).filter(e=>e!==void 0);if(o.length>0)return Ld(e.headers,o.map(t=>e.rows[t]??[]),e.delimiter);let s=[...n.columns].filter(e=>e>=r&&e0?Ld(s.map(t=>e.headers[t-r]),t.map(t=>{let n=e.rows[t]??[];return s.map(e=>n[e-r]??``)}),e.delimiter):null}var sf=1e5,cf=/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/;function lf(e,t,n,r){let i=e.headers.length,a=t.length;if(i===0||a===0)return null;let o=new Set;for(let e of n.ranges){if(o.size>=sf)break;let t=Math.max(0,e.x-r),n=Math.min(i,e.x+e.width-r);if(n<=t)continue;let s=Math.max(0,e.y),c=Math.min(a,e.y+e.height);if(!(c<=s))for(let e=s;e=sf);e++){let r=e*i;for(let e=t;e=sf));e++);}}for(let e of n.rows){if(o.size>=sf)break;if(e<0||e>=a)continue;let t=e*i;for(let e=0;e=sf));e++);}for(let e of n.columns){if(o.size>=sf)break;let t=e-r;if(!(t<0||t>=i))for(let e=0;e=sf));e++);}let s=o.size;if(s===0||s<2&&n.rows.length===0&&n.columns.length===0)return null;let c=0,l=0,u=0,d=null,f=null,p=new Set;for(let n of o){let r=Math.floor(n/i),a=n%i,o=t[r],s=((o===void 0?void 0:e.rows[o]?.[a])??``).trim();if(s===``)c+=1;else if(p.add(s),cf.test(s)){let e=Number(s);Number.isFinite(e)&&(l+=1,u+=e,(d===null||ef)&&(f=e))}}return{cellCount:s,distinctCount:p.size,emptyCount:c,numericCount:l,sum:l>0?u:null,avg:l>0?u/l:null,min:l>0?d:null,max:l>0?f:null}}var uf=24,df=26,ff=110,pf=40,mf=12,hf=1,gf=`ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace`,_f=`ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif`,vf=[{mode:`auto`,label:`Auto`},{mode:`string`,label:`String`},{mode:`number`,label:`Number`},{mode:`boolean`,label:`Boolean`}];function yf(e){return e===`string`?`STR`:e===`number`?`NUM`:e===`boolean`?`BOOL`:null}function bf(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.isContentEditable}var xf=`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`,Sf=new Intl.NumberFormat(`en-US`,{maximumFractionDigits:4});function Cf(e){return Sf.format(Object.is(e,-0)?0:e)}function wf(e){let t=[`Cells: ${Sf.format(e.cellCount)}`,`Distinct: ${Sf.format(e.distinctCount)}`];return e.emptyCount>0&&t.push(`Empty: ${Sf.format(e.emptyCount)}`),e.numericCount>0&&e.sum!==null&&e.avg!==null&&e.min!==null&&e.max!==null&&t.push(`Sum: ${Cf(e.sum)}`,`Avg: ${Cf(e.avg)}`,`Min: ${Cf(e.min)}`,`Max: ${Cf(e.max)}`),t.join(` · `)}function Tf(e){return e?{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:_f,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:_f,lineHeight:1}}function Ef(e){return e?`hsla(45, 96%, 65%, 0.3)`:`hsl(48 96% 89%)`}function Df({text:e,delimiter:t,testId:n=`csv-table`,dark:r=!1,onCellCommit:i,onUndo:a,onRedo:o,onCopySelection:s,columnTypes:c,onChangeColumnTypes:l,onProjectedCsvChange:u}){let d=(0,g.useRef)(null),f=(0,g.useRef)(null),p=(0,g.useRef)(null),m=(0,g.useRef)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(null),S=(0,g.useRef)(b);S.current=b;let C=(0,g.useRef)(null),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)(``),O=(0,g.useRef)(null),[k,A]=(0,g.useState)(()=>new Set),[ee,te]=(0,g.useState)(!1),[ne,re]=(0,g.useState)(!1),[j,ie]=(0,g.useState)(void 0),[M,ae]=(0,g.useState)(()=>new Set),N=(0,g.useRef)(M),[oe,P]=(0,g.useState)(0),[se,ce]=(0,g.useState)({}),F=i!==void 0,le=c??se,ue=(0,g.useCallback)(e=>{ce(e),l?.(e)},[l]),de=(0,g.useMemo)(()=>Tf(r),[r]),fe=Ef(r),pe=r?`hsl(240 3.7% 15.9%)`:`hsl(240 4.8% 95.9%)`,ge=(0,g.useRef)();ge.current===void 0&&(ge.current=new ud);let I=(0,g.useMemo)(()=>t===void 0?jd(e)?.cleanedCsv??e:e,[e,t]),L=(0,g.useMemo)(()=>Fd(I,t),[I,t]),_e=(0,g.useMemo)(()=>zd(L),[L]),R=L.headers.length,ve=(0,g.useRef)(L.headers);if(ve.current!==L.headers){let e=ve.current,t=L.headers;ve.current=t;let n=e.length===t.length,r=n?t.reduce((t,n,r)=>n===e[r]?t:t+1,0):1/0;(!n||r>1||r===1&&t.length<=1)&&k.size>0&&A(new Set)}let be=(0,g.useMemo)(()=>{let e=Array.from({length:R},(e,t)=>t);if(k.size===0)return e;let t=e.filter(e=>!k.has(e));return t.length>0?t:e},[R,k]),xe=(0,g.useRef)(be);xe.current=be;let Se=(0,g.useMemo)(()=>be.length===L.headers.length?L:{...L,headers:be.map(e=>L.headers[e]??``),rows:L.rows.map(e=>be.map(t=>e[t]??``))},[L,be]),z=(0,g.useRef)({text:I,table:L,visibleTable:Se});z.current={text:I,table:L,visibleTable:Se};let Ce=(0,g.useRef)(j);Ce.current=j,(0,g.useEffect)(()=>{let e=window.setTimeout(()=>y(h),150);return()=>window.clearTimeout(e)},[h]);let B=(0,g.useMemo)(()=>{let e=ef(L.rows,v);return b?tf(e,L.rows,b.col,b.dir,_e[b.col]??!1):e},[L,v,b,_e]),Ee=(0,g.useRef)(B);Ee.current=B,(0,g.useEffect)(()=>{let e=f.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>P(e.clientWidth));return t.observe(e),P(e.clientWidth),()=>t.disconnect()},[]);let De=Math.max(ff,Math.floor((oe-pf)/Math.max(1,be.length)));(0,g.useEffect)(()=>{if(!ee)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),te(!1))},t=e=>{let t=p.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||te(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[ee]);let Oe=(0,g.useCallback)(e=>{A(t=>{let n=new Set(t);if(n.has(e))n.delete(e);else{if(R-(n.size+1)<1)return t;n.add(e)}return n}),ie(e=>e&&e.columns.length>0?{...e,columns:ur.empty()}:e)},[R]),ke=(0,g.useCallback)(()=>{A(new Set),ie(e=>e&&e.columns.length>0?{...e,columns:ur.empty()}:e)},[]),Ae=be.length!ne||!je?null:nf(L,B,be),[ne,je,L,B,be]),Ne=(0,g.useRef)(u);Ne.current=u,(0,g.useEffect)(()=>{Ne.current?.(Me)},[Me]),(0,g.useEffect)(()=>()=>{Ne.current?.(null)},[]),(0,g.useEffect)(()=>{ae(e=>{let t=!1,n=new Set;for(let r of e)r{ie(e=>{if(!e||e.rows.length===0)return e;let t=[];for(let e of N.current){let n=B.indexOf(e);n!==-1&&t.push(n)}t.sort((e,t)=>e-t);let n=t.reduce((e,t)=>e.add(t),ur.empty());return n.equals(e.rows)?e:{...e,rows:n}})},[B]),(0,g.useEffect)(()=>{x(e=>e!==null&&e.col>=R?null:e),T(e=>e!==null&&e.col>=R?null:e)},[R]);let Pe=v!==``,Fe=L.rows.length,Ie=df+Math.min(B.length,mf)*uf,Le=()=>{_(``),y(``)},Re=(0,g.useCallback)((e,t)=>{if(e0||i.height>0)?{x:Math.max(0,a.x-i.left),y:Math.max(0,a.y-i.top),width:a.width,height:a.height}:a??{x:pf+n*De,y:0,width:De,height:df};D(e),T({col:r,bounds:o})}else C.current=S.current,T(null),x(e=>!e||e.col!==r?{col:r,dir:`asc`}:e.dir===`asc`?{col:r,dir:`desc`}:null)}},[F,De]),ze=(0,g.useCallback)(()=>{if(!w)return;let{col:e}=w;if(T(null),!i)return;let{text:t,table:n}=z.current,r=n.headers[e]??``,a=qd(t,n,e,E);if(a!==t){if(r!==``&&r!==E&&le[r]!==void 0){let e={...le},t=e[r];delete e[r],E!==``&&t!==void 0&&(e[E]=t),ue(e)}i(a)}},[w,E,i,le,ue]),Be=(0,g.useCallback)(()=>{T(null)},[]);(0,g.useEffect)(()=>{if(!w)return;let e=O.current;e&&(e.focus(),e.select())},[w]);let Ve=(0,g.useCallback)((e,t)=>{let n=Ee.current,r=n[t];if(r===void 0)return;let i=N.current,a=m.current,o;if(e.shiftKey&&a!==null&&a!==r){let t=n.indexOf(a),s=n.indexOf(r),c=t===-1?s:t,[l,u]=c<=s?[c,s]:[s,c];o=e.metaKey||e.ctrlKey?new Set(i):new Set;for(let e=l;e<=u;e++){let t=n[e];t!==void 0&&o.add(t)}}else e.metaKey||e.ctrlKey?(o=new Set(i),o.has(r)?o.delete(r):o.add(r)):o=new Set([r]);m.current=r,N.current=o,ae(o);let s=[...o].map(e=>n.indexOf(e)).filter(e=>e!==-1).sort((e,t)=>e-t);ie(e=>({current:e?.current,columns:e?.columns??ur.empty(),rows:s.reduce((e,t)=>e.add(t),ur.empty())}))},[]),He=(0,g.useCallback)(()=>{m.current=null,N.current=new Set,ae(new Set),ie(void 0)},[]),Ue=(0,g.useCallback)(e=>{let t=new Set;for(let n of e.rows){let e=Ee.current[n];e!==void 0&&t.add(e)}N.current=t,ae(t),ie(e)},[]),We=(0,g.useCallback)(()=>{He()},[He]),Ge=(0,g.useMemo)(()=>B.filter(e=>M.has(e)),[B,M]),Ke=(0,g.useMemo)(()=>[...j?.columns??[]].filter(e=>e>=hf).map(e=>be[e-hf]).filter(e=>e!==void 0),[j,be]),qe=Ke.length,Je=(0,g.useMemo)(()=>Ke.map(e=>L.headers[e]).filter(e=>e!==void 0),[Ke,L.headers]),Ye=(0,g.useMemo)(()=>{if(Je.length===0)return null;let e=le[Je[0]]??`auto`;for(let t=1;t{if(!F||Je.length===0)return;let t={...le};for(let n of Je)e===`auto`?delete t[n]:t[n]=e;ue(t)},[F,Je,le,ue]),Ze=(0,g.useMemo)(()=>F?L.headers.filter(e=>yf(le[e])!==null).length:0,[F,L.headers,le]),Qe=(0,g.useMemo)(()=>({ranges:j?.current?[j.current.range,...j.current.rangeStack]:[],columns:j?[...j.columns]:[],rows:M.size>0?B.reduce((e,t,n)=>(M.has(t)&&e.push(n),e),[]):j?[...j.rows]:[]}),[j,M,B]),$e=hf,et=(0,g.useMemo)(()=>lf(Se,B,Qe,$e),[Se,B,Qe,$e]),tt=Ge.length>0||qe>0||et!==null,nt=(0,g.useRef)(s);nt.current=s;let rt=()=>{let e=Ce.current,t=of(z.current.visibleTable,Ee.current,{ranges:e?.current?[e.current.range,...e.current.rangeStack]:[],columns:e?[...e.columns]:[],rows:e?[...e.rows]:[]},hf);t!==null&&(nt.current?.(),navigator.clipboard?.writeText(t).catch(()=>{}))};(0,g.useEffect)(()=>{let e=e=>{let t=d.current;if(!t||!t.contains(document.activeElement))return;let n=document.activeElement;if(n&&(n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable))return;let r=Ce.current,i=of(z.current.visibleTable,Ee.current,{ranges:r?.current?[r.current.range,...r.current.rangeStack]:[],columns:r?[...r.columns]:[],rows:r?[...r.rows]:[]},hf);i!==null&&(e.preventDefault(),e.stopImmediatePropagation(),e.clipboardData?.setData(`text/plain`,i),nt.current?.())};return window.addEventListener(`copy`,e,{capture:!0}),()=>window.removeEventListener(`copy`,e,{capture:!0})},[]),(0,g.useEffect)(()=>{if(!a&&!o)return;let e=e=>{let t=d.current;if(!t)return;let n=e.target instanceof Node&&t.contains(e.target),r=document.activeElement instanceof Node&&t.contains(document.activeElement);if(!n&&!r||bf(e.target)||bf(document.activeElement))return;let i=Qd(e);i===`undo`&&a?(e.preventDefault(),a()):i===`redo`&&o&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a,o]);let it=(0,g.useCallback)(e=>{let t=d.current!==null&&document.activeElement instanceof Node&&d.current.contains(document.activeElement);He(),i?.(e),t&&f.current?.focus({preventScroll:!0})},[He,i]),at=R>0&&Ke.length>=R,ot=()=>{F&&Ge.length!==0&&it(Gd(z.current.text,z.current.table,Ge))},st=()=>{F&&!at&&Ke.length!==0&&it(Kd(z.current.text,z.current.table,Ke))},ct=(0,g.useCallback)(e=>{if(!i)return!1;let{text:t,table:n}=z.current,r=Ee.current;if(e.rows.length>0){let i=[...e.rows].map(e=>r[e]).filter(e=>e!==void 0);if(i.length>0)return it(Gd(t,n,i)),!1}if(e.columns.length>0){let r=[...e.columns].filter(e=>e>=hf).map(e=>xe.current[e-hf]).filter(e=>e!==void 0&&e>=0&&e0&&r.length0&&it(Gd(t,n,o)),!1},[it,i]),lt=(0,g.useCallback)(e=>{let t=i;if(!t)return!1;let{text:n,table:r}=z.current,a=Ee.current,o=[...e].sort((e,t)=>e.location[1]-t.location[1]),s=n,c=0;for(let{location:e,value:t}of o){let n=e[0]-hf,i=n>=0?xe.current[n]:void 0,o=e[1];if(i===void 0||i<0||t.kind!==W.Text)continue;let l=a[o],u=l===void 0?void 0:r.rowSpans[l];if(!u)continue;let d=Rd(s.slice(u.start+c,u.end+c),r.delimiter);for(;d.length<=i;)d.push(``);let f=t.data??``;if(d[i]===f)continue;d[i]=f;let p=Id(d,r.delimiter);s=s.slice(0,u.start+c)+p+s.slice(u.end+c),c+=p.length-(u.end-u.start)}return s!==n&&t(s),!0},[i]),ut=(0,g.useCallback)(e=>{let[t,n]=e,r=Ee.current[n];if(t{let t=[];for(let n=e.y;n{e[0]>=hf||Ve(t,e[1])},[Ve]),pt=(0,g.useMemo)(()=>[{title:`#`,id:`__gutter`,width:pf,themeOverride:{baseFontStyle:`11px ${gf}`,textDark:`hsla(240, 3.8%, 46.1%, 0.4)`}},...be.map(e=>{let t=L.headers[e]??``,n=F?yf(le[t]):null;return{title:n?`${t.toUpperCase()} [${n}]`:t.toUpperCase(),id:`c${e}`,width:De,themeOverride:_e[e]?{baseFontStyle:`12px ${gf}`}:void 0}})],[L.headers,be,_e,De,F,le]),mt=(0,g.useCallback)((e,t)=>{let{ctx:n,columnIndex:r,rect:i,theme:a,isSelected:o}=e;n.save();try{if(n.letterSpacing=`0.5px`,o&&(n.fillStyle=a.bgHeaderHovered,n.fillRect(i.x,i.y,i.width,i.height),n.fillStyle=a.accentColor,n.fillRect(i.x,i.y+i.height-2,i.width,2)),r{let{ctx:n,cell:r,rect:i,col:a,theme:o}=e,s=a-hf;if(s>=0&&Pe&&r.kind===W.Text){let e=Of(r.data,v);if(e!==null){n.save();try{let t=`${o.baseFontStyle} ${o.fontFamily}`;n.font=t;let r=i.x+o.cellHorizontalPadding,a=i.y+i.height/2+Ga(n,t);for(let t of e){let e=n.measureText(t.text).width;t.hit&&e>0&&(n.fillStyle=fe,n.fillRect(r-1,a-7,e+2,14)),r+=e}}finally{n.restore()}}}if(t(),s>=0&&r.kind===W.Text&&r.data===``){n.save();try{n.font=`${o.baseFontStyle} ${o.fontFamily}`,n.fillStyle=o.textLight,n.fillText(`—`,i.x+o.cellHorizontalPadding,i.y+i.height/2+.5)}finally{n.restore()}}},[Pe,v,fe]),gt=(0,g.useCallback)(e=>{let t=Ee.current[e];return t!==void 0&&N.current.has(t)?{bgCell:pe,bgCellMedium:pe}:void 0},[pe]);return R===0?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:`No columns detected.`}):(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,ref:d,children:[(0,V.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:[(0,V.jsxs)(`div`,{className:`relative min-w-32 flex-1 sm:max-w-64`,children:[(0,V.jsx)(ye,{"aria-hidden":`true`,className:`pointer-events-none absolute left-1.5 top-1/2 size-3 -translate-y-1/2 text-muted-foreground/60`}),(0,V.jsx)(`input`,{type:`text`,"data-testid":`${n}-search`,"aria-label":`Search rows`,value:h,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Escape`&&Le()},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!==``&&(0,V.jsx)(`button`,{type:`button`,"data-testid":`${n}-clear-search`,"aria-label":`Clear search`,onClick:Le,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:(0,V.jsx)(Te,{"aria-hidden":`true`,className:`size-3`})})]}),(0,V.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:Pe?`${B.length.toLocaleString()} of ${Fe.toLocaleString()}`:`${Fe.toLocaleString()} rows`}),F&&Ze>0&&(0,V.jsxs)(`button`,{type:`button`,"data-testid":`input-table-column-types-reset`,onClick:()=>ue({}),title:`Reset all pinned column types to Auto`,className:xf,children:[`${Ze} ${Ze===1?`column type`:`column types`} pinned`,(0,V.jsx)(Te,{"aria-hidden":`true`,className:`size-3 text-muted-foreground`})]}),(0,V.jsxs)(`div`,{ref:p,className:`relative`,children:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`${n}-columns-button`,"aria-expanded":ee,"aria-haspopup":`dialog`,"aria-label":`Columns`,onClick:()=>te(e=>!e),className:wt(xf,Ae&&`border-foreground/30 bg-muted font-semibold`),children:[(0,V.jsx)(me,{"aria-hidden":`true`,className:`size-3`}),(0,V.jsx)(`span`,{children:Ae?`Columns (${be.length}/${R})`:`Columns`})]}),ee&&(0,V.jsxs)(`div`,{"data-testid":`${n}-columns-popout`,role:`dialog`,"aria-label":`Visible columns`,className:`absolute left-0 top-7 z-30 min-w-44 max-w-64 rounded-md border border-border bg-panel p-1.5 shadow-md`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2 border-b border-border px-1.5 pb-1`,children:[(0,V.jsxs)(`span`,{className:`text-[11px] font-semibold text-foreground`,children:[`Columns (`,be.length,`/`,R,`)`]}),Ae&&(0,V.jsx)(`button`,{type:`button`,"data-testid":`${n}-columns-reset`,onClick:ke,className:`cursor-pointer rounded px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:`Show all`})]}),(0,V.jsx)(`div`,{className:`max-h-56 overflow-y-auto`,children:L.headers.map((e,t)=>{let r=!k.has(t),i=r&&be.length<=1,a=e===``?`Column ${t+1}`:e;return(0,V.jsxs)(`label`,{className:wt(`flex items-center gap-2 rounded px-1.5 py-1 text-xs`,i?`cursor-not-allowed opacity-60`:`cursor-pointer hover:bg-muted`),children:[(0,V.jsx)(`input`,{type:`checkbox`,"data-testid":`${n}-column-toggle-${t}`,checked:r,disabled:i,onChange:()=>Oe(t),className:`size-3.5 accent-foreground`}),(0,V.jsx)(`span`,{className:`truncate font-mono text-[11px] text-foreground`,children:a})]},t)})})]})]}),je&&(0,V.jsx)(`button`,{type:`button`,"data-testid":`${n}-apply-view`,"aria-pressed":ne,onClick:()=>re(e=>!e),className:wt(`inline-flex cursor-pointer items-center gap-1 rounded-md border px-2 py-0.5 text-[11px] font-medium transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,ne?`border-foreground bg-foreground text-background hover:bg-foreground/90`:`border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground`),children:`Apply view to output`}),tt&&(0,V.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,V.jsx)(`span`,{"data-testid":`${n}-selected-count`,className:`text-[11px] font-medium tabular-nums text-muted-foreground`,children:Ge.length>0?`${Ge.length.toLocaleString()} selected`:qe>0?`${qe.toLocaleString()} ${qe===1?`column`:`columns`} selected`:`${(et?.cellCount??0).toLocaleString()} cells selected`}),et!==null&&(0,V.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:wf(et)}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`${n}-copy`,onClick:rt,className:xf,children:[(0,V.jsx)(he,{"aria-hidden":`true`,className:`size-3`}),`Copy as CSV`]}),F&&Ge.length>0&&(0,V.jsxs)(`button`,{type:`button`,"data-testid":`${n}-delete-rows`,onClick:ot,title:`Deletes the ${Ge.length} selected ${Ge.length===1?`row`:`rows`} from the source CSV`,className:xf,children:[(0,V.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),`Delete `,Ge.length.toLocaleString(),` `,Ge.length===1?`row`:`rows`]}),F&&qe>0&&(0,V.jsxs)(V.Fragment,{children:[(0,V.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:vf.map(({mode:e,label:t})=>{let n=Ye===e;return(0,V.jsx)(`button`,{type:`button`,"data-testid":`input-table-column-type-${e}`,"aria-pressed":n,onClick:()=>Xe(e),className:n?`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:t},e)})}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`${n}-delete-columns`,onClick:st,disabled:at,title:at?`At least one column must remain — the converter needs a column to detect`:`Deletes the ${qe} selected ${qe===1?`column`:`columns`} from the source CSV`,className:`${xf} disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,V.jsx)(we,{"aria-hidden":`true`,className:`size-3`}),`Delete `,qe.toLocaleString(),` `,qe===1?`column`:`columns`]})]}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`${n}-clear-selection`,onClick:He,className:xf,children:`Clear`})]})]}),(0,V.jsxs)(`div`,{ref:f,"data-testid":n,role:`grid`,tabIndex:-1,"aria-rowcount":B.length+1,className:`relative min-h-0 flex-1 outline-none`,style:{minHeight:Ie},children:[(0,V.jsx)(`div`,{className:`absolute inset-0`,children:(0,V.jsx)(Su,{imageWindowLoader:ge.current,renderers:sd,columns:pt,rows:B.length,getCellContent:ut,getCellsForSelection:dt,onCellsEdited:F?lt:void 0,onDelete:F?ct:void 0,onCellClicked:ft,onHeaderClicked:Re,onGridSelectionChange:Ue,onSelectionCleared:We,gridSelection:j,rangeSelect:`multi-rect`,columnSelect:`multi`,rowSelect:`multi`,rowHeight:uf,headerHeight:df,freezeColumns:hf,fillHandle:F,onPaste:F?()=>!0:!1,keybindings:{search:!1},theme:de,drawHeader:mt,drawCell:ht,getRowThemeOverride:gt,minColumnWidth:ff,smoothScrollX:!0,smoothScrollY:!0,verticalBorder:!1})}),w!==null&&(0,V.jsx)(`input`,{ref:O,type:`text`,"data-testid":`csv-header-rename-input`,"aria-label":`Rename column ${L.headers[w.col]??``}`,value:E,onChange:e=>D(e.target.value),onBlur:ze,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),ze()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),Be())},style:{left:w.bounds.x,top:w.bounds.y,width:Math.max(60,w.bounds.width),height:w.bounds.height},className:`absolute z-20 border border-ring bg-background px-2 font-mono text-[11px] font-semibold tracking-wider text-foreground outline-none ring-2 ring-ring/50`}),Pe&&B.length===0&&(0,V.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:[(0,V.jsxs)(`span`,{children:[`No rows matching “`,v,`”.`]}),(0,V.jsx)(`button`,{type:`button`,onClick:Le,className:xf,children:`Show all rows`})]}),F&&!Pe&&B.length===0&&(0,V.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:(0,V.jsx)(`span`,{children:`No rows. Paste or upload data to start over.`})})]})]})}function Of(e,t){if(t===``||e===``)return null;let n=t.toLowerCase();if(!e.toLowerCase().includes(n))return null;let r=[],i=e.toLowerCase(),a=0;for(;;){let t=i.indexOf(n,a);if(t===-1)break;t>a&&r.push({text:e.slice(a,t),hit:!1}),r.push({text:e.slice(t,t+n.length),hit:!0}),a=t+n.length}return a`u`?void 0:navigator),a=(0,g.useRef)(null);(0,g.useEffect)(()=>{a.current?.focus()},[]);let o=e===`CSV`;return(0,V.jsx)(`div`,{"data-testid":`dropzone`,className:`flex flex-1 flex-col items-center justify-center p-3 md:p-6 md:px-16`,children:(0,V.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col items-center gap-2.5 md:gap-3`,children:[(0,V.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:(0,V.jsx)(fe,{className:`size-4 md:size-5`})}),(0,V.jsx)(`p`,{"data-testid":`dropzone-title`,className:`text-center text-sm font-medium text-foreground`,children:o?`Paste CSV, TSV, or Markdown table`:`Paste JSON or JSONL here`}),(0,V.jsx)(`p`,{"data-testid":`dropzone-formats`,className:`max-w-[36ch] text-center text-[11.5px] leading-relaxed text-muted-foreground`,children:o?`Supports CSV, TSV / spreadsheet cells, Markdown & ChatGPT docs (multi-table), and psql / MySQL box tables`:`Supports JSON arrays, nested objects, wrapped API payloads ({ data: […] }), and JSONL / NDJSON`}),(0,V.jsx)(`textarea`,{ref:a,"data-testid":`paste-field`,rows:1,"aria-label":`Paste ${o?`CSV, TSV, Markdown, or CLI table`:`JSON, JSONL, or API response`} data — or press ${i} to paste anywhere on this page`,placeholder:o?`Paste CSV, TSV, Markdown, or psql/MySQL table here`:`Paste JSON, JSONL / NDJSON, or API response here`,spellCheck:!1,onChange:e=>{let n=e.currentTarget;n.rows=Mf(n.value),t(n.value)},className:`min-h-11 w-full resize-none overflow-hidden rounded-md border border-border bg-background px-3 py-2.5 font-mono text-[12.5px] leading-relaxed text-foreground transition-colors placeholder:font-sans placeholder:text-xs placeholder:text-muted-foreground focus:outline-none focus-visible:border-sky-600 dark:focus-visible:border-sky-400`}),(0,V.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 (`,(0,V.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}),`)`]}),(0,V.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,V.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:[(0,V.jsx)(I,{"aria-hidden":`true`}),`Choose file`]}),(0,V.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:[(0,V.jsx)(be,{"aria-hidden":`true`}),`Try an example`]})]})]})})}var Pf=[],Ff=[];(()=>{let e=`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 t=0,n=0;t>1;if(e=Ff[r])t=r+1;else return!0;if(t==n)return!1}}function Lf(e){return e>=127462&&e<=127487}var Rf=8205;function zf(e,t,n=!0,r=!0){return(n?Bf:Vf)(e,t,r)}function Bf(e,t,n){if(t==e.length)return t;t&&Uf(e.charCodeAt(t))&&Wf(e.charCodeAt(t-1))&&t--;let r=Hf(e,t);for(t+=Gf(r);t=0&&Lf(Hf(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function Vf(e,t,n){for(;t>1;){let r=Bf(e,t-2,n);if(r=56320&&e<57344}function Wf(e){return e>=55296&&e<56320}function Gf(e){return e<65536?1:2}var Kf=class e{lineAt(e){if(e<0||e>this.length)throw 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 RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=np(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),Jf.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=np(this,e,t);let n=[];return this.decompose(e,t,n,0),Jf.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new Qf(this),i=new Qf(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new Qf(this,e)}iterRange(e,t=this.length){return new $f(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new ep(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new qf(t):Jf.from(qf.split(t,[]))}},qf=class e extends Kf{constructor(e,t=Yf(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new tp(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(Zf(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=Xf(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=np(this,t,n);let i=Xf(this.text,Xf(r.text,Zf(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):Jf.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=` -`){[e,t]=np(this,e,t);let r=``;for(let i=0,a=0;i<=t&&ae&&a&&(r+=n),ei&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},Jf=class e extends Kf{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=np(this,t,n),r.lines=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=` -`){[e,t]=np(this,e,t);let r=``;for(let i=0,a=0;ie&&i&&(r+=n),ea&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new qf(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof qf&&c&&(n=u[u.length-1])instanceof qf&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new qf(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};Kf.empty=new qf([``],0);function Yf(e){let t=-1;for(let n of e)t+=n.length+1;return t}function Xf(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a=n&&(c>r&&(s=s.slice(0,r-i)),i0?1:(e instanceof qf?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof qf?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(r instanceof qf){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof qf?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},$f=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new Qf(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),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!=``}},ep=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(Kf.prototype[Symbol.iterator]=function(){return this.iter()},Qf.prototype[Symbol.iterator]=$f.prototype[Symbol.iterator]=ep.prototype[Symbol.iterator]=function(){return this});var tp=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function np(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function rp(e,t,n=!0,r=!0){return zf(e,t,n,r)}function ip(e){return e>=56320&&e<57344}function ap(e){return e>=55296&&e<56320}function op(e,t){let n=e.charCodeAt(t);if(!ap(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ip(r)?(n-55296<<10)+(r-56320)+65536:n}function sp(e){return e<65536?1:2}var cp=/\r\n?|\n/,lp=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(lp||={}),up=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return i+(e-r);i+=o}else{if(n!=lp.Simple&&c>=e&&(n==lp.TrackDel&&re||n==lp.TrackBefore&&re))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n=0&&r<=t&&o>=e)return rt?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},dp=class e extends up{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return mp(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return hp(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length0&&pp(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;os||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?Kf.of(l.split(r||cp)):l:Kf.empty,d=u.length;if(e==s&&d==0)return;eo&&fp(i,e-o,-1),fp(i,s-e,d),pp(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;et&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function pp(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function hp(e,t,n,r=!1){let i=[],a=r?[]:null,o=new _p(e),s=new _p(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);fp(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len=0&&e=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.lent||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var _p=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?Kf.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?Kf.empty:t[n].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)}},vp=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}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(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return Y.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return Y.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!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 RangeError(`Invalid JSON representation for SelectionRange`);return Y.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},Y=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;ne.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>vp.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;ie.from-t.from),n=t.indexOf(r);for(let r=1;ri.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function yp(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var bp=0,X=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=bp++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:xp),!!t.static,t.enables)}of(e){return new Sp([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Sp(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new Sp(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function xp(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var Sp=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=bp++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||wp(e,c)){let r=t(e);if(a?!Cp(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=Lp(o,c);if(this.dependencies.every(t=>t instanceof X?o.facet(t)===e.facet(t):t instanceof Dp?o.field(t,!1)==e.field(t,!1):!0)||(a?Cp(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Cp(e,t,n){if(e.length!=t.length)return!1;for(let r=0;re[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;te===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Ep).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Ep),i=n.facet(Ep),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Ep.of({field:this,create:e})]}get extension(){return this}},Op={lowest:4,low:3,default:2,high:1,highest:0};function kp(e){return t=>new jp(t,e)}var Ap={highest:kp(Op.highest),high:kp(Op.high),default:kp(Op.default),low:kp(Op.low),lowest:kp(Op.lowest)},jp=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Mp=class e{of(e){return new Np(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Np=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Pp=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Fp(t,n,o))e instanceof Dp?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,xp(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Tp(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Fp(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Np&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Np){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof jp)a(e.inner,e.prec);else if(e instanceof Dp)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof Sp)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Op.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Op.default),r.reduce((e,t)=>e.concat(t))}function Ip(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function Lp(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var Rp=X.define(),zp=X.define({combine:e=>e.some(e=>e),static:!0}),Bp=X.define({combine:e=>e.length?e[0]:void 0,static:!0}),Vp=X.define(),Hp=X.define(),Up=X.define(),Wp=X.define({combine:e=>e.length?e[0]:!1}),Gp=class{constructor(e,t){this.type=e,this.value=t}static define(){return new Kp}},Kp=class{of(e){return new Gp(this,e)}},qp=class{constructor(e){this.map=e}of(e){return new Jp(this,e)}},Jp=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new qp(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};Jp.reconfigure=Jp.define(),Jp.appendConfig=Jp.define();var Yp=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&yp(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return 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 t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};Yp.time=Gp.define(),Yp.userEvent=Gp.define(),Yp.addToHistory=Gp.define(),Yp.remote=Gp.define();function Xp(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r=e[r]))a=e[r++],o=e[r++];else if(i=0;n--){let i=r[n](e);e=i instanceof Yp?i:Array.isArray(i)&&i.length==1&&i[0]instanceof Yp?i[0]:$p(t,rm(i),!1)}return e}function tm(e){let t=e.startState,n=t.facet(Up),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=Zp(r,Qp(t,a,e.changes.newLength),!0))}return r==e?e:Yp.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var nm=[];function rm(e){return e==null?nm:Array.isArray(e)?e:[e]}var im=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(im||={}),am=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,om;try{om=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function sm(e){if(om)return om.test(e);for(let t=0;t`€`&&(n.toUpperCase()!=n.toLowerCase()||am.test(n)))return!0}return!1}function cm(e){return t=>{if(!/\S/.test(t))return im.Space;if(sm(t))return im.Word;for(let n=0;n-1)return im.Word;return im.Other}}var lm=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;ei.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(Jp.reconfigure)?(n=null,r=e.value):e.is(Jp.appendConfig)&&(n=null,r=rm(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Pp.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(zp)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:Y.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=rm(n.effects);for(let n=1;nn.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:Y.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Pp.resolve(t.extensions||[],new Map),r=t.doc instanceof Kf?t.doc:Kf.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||cp)),i=t.selection?t.selection instanceof Y?t.selection:Y.single(t.selection.anchor,t.selection.head):Y.single(0);return yp(i,r.length),n.staticFacet(zp)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||` -`}get readOnly(){return this.facet(Wp)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(Rp))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return cm(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=rp(t,a,!1);if(i(t.slice(e,a))!=im.Word)break;a=e}for(;oe.length?e[0]:4}),lm.lineSeparator=Bp,lm.readOnly=Wp,lm.phrases=X.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),lm.languageData=Rp,lm.changeFilter=Vp,lm.transactionFilter=Hp,lm.transactionExtender=Up,Mp.reconfigure=Jp.define();function um(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var dm=class{eq(e){return this==e}range(e,t=e){return pm.create(e,t,this)}};dm.prototype.startSide=dm.prototype.endSide=0,dm.prototype.point=!1,dm.prototype.mapMode=lp.TrackDel;function fm(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var pm=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function mm(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var hm=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return _m(this.to)}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);ih||m==h&&d.startSide>0&&d.endSide<=0)continue;if(!((h-m||d.endSide-d.startSide)<0)){if(l<0&&(l=m),d.point&&(u=Math.max(u,h-m)),(m-r||d.startSide-i)>=0)o.push(d),s.push(m-l),c.push(h-l),r=h,i=d.endSide;else{if(m==h)for(let e=o.length;e>0;e--){if((m-(c[e-1]+l)||d.startSide-o[e-1].endSide)>=0){o.splice(e,0,d),s.splice(e,0,m-l),c.splice(e,0,h-l);continue iter}if((m-(s[e-1]+l)||d.endSide-o[e-1].startSide)>0)break}a(m,h,d)}}}return{mapped:o.length?new e(s,c,o,u):null,pos:l}}},gm=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,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 t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(mm)),this.isEmpty)return n.length?e.of(n):this;let s=new xm(this,null,-1).goto(0),c=0,l=[],u=new ym;for(;s.value||c=0){let e=n[c++];u.addInner(e.from,e.to,e.value,!1)||l.push(e)}else s.rangeIndex==1&&s.chunkIndexthis.chunkEnd(s.chunkIndex)||as.to||a{a||=new ym,a.addRange(e,t,n,!1)};for(let e=0;e=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return Sm.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Sm.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=bm(a,o,n),c=new wm(a,s,i),l=new wm(o,s,i);n.iterGaps((e,t,n)=>Tm(c,e,l,t,n,r)),n.empty&&n.length==0&&Tm(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=bm(i,a),s=new wm(i,o,0).goto(n),c=new wm(a,o,0).goto(n);for(;;){if(s.to!=c.to||!Em(s.active,c.active)||s.point&&(!c.point||!fm(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new wm(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFromo&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new ym;for(let r of e instanceof pm?[e]:t?vm(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=_m(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};gm.empty=new gm([],[],null,-1);function _m(e){return e[e.length-1]}function vm(e){if(e.length>1)for(let t=e[0],n=1;n0)return e.slice().sort(mm);t=r}return e}gm.empty.nextLayer=gm.empty;var ym=class e{finishChunk(e){this.chunks.push(new hm(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,t,n){this.addRange(e,t,n,!0)}addRange(t,n,r,i){this.addInner(t,n,r,i)||(this.nextLayer||=new e).addRange(t,n,r,i)}addInner(e,t,n,r){let i=e-this.lastTo||n.startSide-this.last.endSide;if(r&&i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw 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(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(gm.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=gm.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function bm(e,t,n){let r=new Map;for(let t of e)for(let e=0;e=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 xm(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)Cm(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)Cm(this.heap,e);(this.to-e||this.value.endSide-t)<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(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var wm=class{constructor(e,t,n){this.minPoint=n,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=Sm.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Dm(this.active,e),Dm(this.activeTo,e),Dm(this.activeRank,e),this.minActive=km(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t0;)t++;Om(this.active,t,n),Om(this.activeTo,t,r),Om(this.activeRank,t,i),e&&Om(e,t,this.cursor.from),this.minActive=km(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&Dm(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&n[t]=0&&!(this.activeRank[n]e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function Tm(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&fm(e.point,n.point)&&Em(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&=(a.boundChange(s),!1),d>s&&!Em(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&do)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function Em(e,t){if(e.length!=t.length)return!1;for(let n=0;n=t;n--)e[n+1]=e[n];e[t]=n}function km(e,t){let n=-1,r=1e9;for(let i=0;i=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=rp(e,r)}return r===!0?-1:e.length}for(var Mm=`ͼ`,Nm=typeof Symbol>`u`?`__ͼ`:Symbol.for(Mm),Pm=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),Fm=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},Im=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=Fm[Nm]||1;return Fm[Nm]=e+1,Mm+e.toString(36)}static mount(e,t,n){let r=e[Pm],i=n&&n.nonce;r?i&&r.setNonce(i):r=new Rm(e,i),r.mount(Array.isArray(t)?t:[t],e)}},Lm=new Map,Rm=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=Lm.get(n);if(t)return e[Pm]=t;this.sheet=new r.CSSStyleSheet,Lm.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[Pm]=this}mount(e,t){let n=this.sheet,r=0,i=0,a=!1;for(let t=0;t-1&&(this.modules.splice(s,1),a=!0,i--,s=-1),s==-1){if(this.modules.splice(i++,0,o),a=!0,n)for(let e=0;e`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Vm=typeof navigator<`u`&&/Mac/.test(navigator.platform),Hm=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Um=0;Um<10;Um++)zm[48+Um]=zm[96+Um]=String(Um);for(var Um=1;Um<=24;Um++)zm[Um+111]=`F`+Um;for(var Um=65;Um<=90;Um++)zm[Um]=String.fromCharCode(Um+32),Bm[Um]=String.fromCharCode(Um);for(var Wm in zm)Bm.hasOwnProperty(Wm)||(Bm[Wm]=zm[Wm]);function Gm(e){var t=!(Vm&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Hm&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Bm:zm)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function Km(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=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`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t2),Z={mac:ih||/Mac/.test(Jm.platform),windows:/Win/.test(Jm.platform),linux:/Linux|X11/.test(Jm.platform),ie:$m,ie_version:Zm?Ym.documentMode||6:Qm?+Qm[1]:Xm?+Xm[1]:0,gecko:eh,gecko_version:eh?+(/Firefox\/(\d+)/.exec(Jm.userAgent)||[0,0])[1]:0,chrome:!!th,chrome_version:th?+th[1]:0,ios:ih,android:/Android\b/.test(Jm.userAgent),webkit:nh,webkit_version:nh?+(/\bAppleWebKit\/(\d+)/.exec(Jm.userAgent)||[0,0])[1]:0,safari:rh,safari_version:rh?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Jm.userAgent)||[0,0])[1]:0,tabSize:Ym.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function ah(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var oh=Object.create(null);function sh(e,t,n){if(e==t)return!0;e||=oh,t||=oh;let r=Object.keys(e),i=Object.keys(t);if(r.length-0!=i.length-0)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function ch(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function lh(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function uh(e){let t=Object.create(null);for(let n=0;n0?3e8:-4e8:t>0?1e8:-1e8,new gh(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=_h(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new gh(e,n,r,t,e.widget||null,!0)}static line(e){return new hh(e)}static set(e,t=!1){return gm.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};ph.none=gm.empty;var mh=class e extends ph{constructor(e){let{start:t,end:n}=_h(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?ah(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||oh}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&sh(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};mh.prototype.point=!1;var hh=class e extends ph{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&sh(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};hh.prototype.mapMode=lp.TrackBefore,hh.prototype.point=!0;var gh=class e extends ph{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?lp.TrackBefore:lp.TrackAfter:lp.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?fh.WidgetBefore:fh.WidgetAfter:fh.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&vh(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};gh.prototype.point=!0;function _h(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function vh(e,t){return e==t||!!(e&&t&&e.compare(t))}function yh(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var bh=class e extends dm{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&sh(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||oh,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return gm.of(e,t)}};bh.prototype.startSide=bh.prototype.endSide=-1;var xh=e=>e.nodeType==1,Sh=e=>e.nodeType==3;function Ch(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function wh(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function Th(e,t){if(!t.anchorNode)return!1;try{return wh(e,t.anchorNode)}catch{return!1}}function Eh(e){return Sh(e)?Uh(e,0,e.nodeValue.length).getClientRects():xh(e)?e.getClientRects():[]}function Dh(e,t,n,r){return n?Ah(e,t,n,r,-1)||Ah(e,t,n,r,1):!1}function Oh(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function kh(e){return xh(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function Ah(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:jh(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!xh(n))return!1;t=Oh(e)+(i<0?0:1),e=n}else if(xh(e)){if(e=e.childNodes[t+(i<0?-1:0)],xh(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?jh(e):0}else return!1}}function jh(e){return Sh(e)?e.nodeValue.length:e.childNodes.length}function Mh(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function Nh(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function Ph(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function Fh(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(xh(u)){let e,f=u==c.body,p=1,m=1,h=!0,g=!0;if(f)e=Nh(l);else{let t=getComputedStyle(u);if(/^(fixed|sticky)$/.test(t.position)&&(d=!0),(u.scrollHeight<=u.clientHeight||!/auto|scroll/.test(t.overflowY))&&(g=!1),(u.scrollWidth<=u.clientWidth||!/auto|scroll/.test(t.overflowX))&&(h=!1),!h&&!g){u=u.assignedSlot||u.parentNode;continue}let n=u.getBoundingClientRect();({scaleX:p,scaleY:m}=Ph(u,n)),e={left:n.left,right:n.left+u.clientWidth*p,top:n.top,bottom:n.top+u.clientHeight*m}}let _=0,v=0;if(g){if(i==`nearest`)t.top0&&t.bottom>e.bottom+v&&(v=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(v=t.bottom-e.bottom+o,n<0&&t.top-v0&&t.right>e.right+_&&(_=t.right-e.right+a)):t.right>e.right-a&&(_=t.right-e.right+a,n<0&&t.lefte.bottom||t.lefte.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function Ih(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(xh(a))!i&&a.scrollHeight>a.clientHeight&&/scroll|auto/.test(getComputedStyle(a).overflowY)&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&/scroll|auto/.test(getComputedStyle(a).overflowX)&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var Lh=class{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:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?jh(t):0),n,Math.min(e.focusOffset,n?jh(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function Rh(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)xh(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function zh(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var Bh=null;Z.safari&&Z.safari_version>=26&&(Bh=!1);function Vh(e){if(e.setActive)return e.setActive();if(Bh)return e.focus(Bh);let t=Rh(e);e.focus(Bh==null?{get preventScroll(){return Bh={preventScroll:!0},!0}}:void 0),Bh||(Bh=!1,zh(t))}var Hh;function Uh(e,t,n=t){let r=Hh||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function Wh(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function Gh(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function Kh(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,jh(n));;)if(r){if(!xh(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=jh(n))}else if(n==e)return!0;else r=Oh(n),n=n.parentNode}function qh(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function Jh(e,t){for(let n=e,r=t;;)if(Sh(n)&&r>0)return{node:n,offset:r};else if(xh(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=jh(n)}else if(n.parentNode&&!kh(n))r=Oh(n),n=n.parentNode;else return null}function Yh(e,t){for(let n=e,r=t;;)if(Sh(n)&&r=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.fromt))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function cg(e,t){if(e.length!=t.length)return!1;for(let n=0;n=0;e-=3)if(ig[e+1]==-r){let n=ig[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(lg[t]=lg[ig[e]]=r),s=e;break}}else if(ig.length==189)break;else ig[s++]=t,ig[s++]=n,ig[s++]=c}else if((o=lg[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=ig[t+2];if(n&2)break;if(e)ig[t+2]|=2;else{if(n&4)break;ig[t+2]|=4}}}}}function fg(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=ic;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),lg[--t]=u;c=o}else a=o,c++}}}function pg(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;cc&&o.push(new sg(c,m.from,f)),mg(e,m.direction==Qh==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?lg[p]!=s:lg[p]==s))break;else p++;d?pg(e,c,p,r+1,i,d,o):ct;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=lg[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(lg[e-1]==s)break run;else break}d?d.push(m):(m.tolg.length;)lg[lg.length]=256;let r=[],i=t==Qh?0:1;return mg(e,i,i,n,0,e.length,r),r}function gg(e){return[new sg(0,e,0)]}var _g=``;function vg(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=sg.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=rp(e.text,a,s.forward(i,n));(ls.to)&&(l=c),_g=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?Y.cursor(e.to,1):Y.cursor(e.from,-1);if(u.level+ +!ie.some(e=>e)}),Ag=X.define({combine:e=>e.some(e=>e)}),jg=X.define(),Mg=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(Y.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},Ng=Jp.define({map:(e,t)=>e.map(t)}),Pg=Jp.define();function Fg(e,t,n){let r=e.facet(Cg);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var Ig=X.define({combine:e=>!e.length||e[0]}),Lg=0,Rg=X.define({combine(e){return e.filter((t,n)=>{for(let r=0;r{let t=[];return o&&t.push(Ug.of(t=>{let n=t.plugin(e);return n?o(n):ph.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},Bg=class{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.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){Fg(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(Fg(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){Fg(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},Vg=X.define(),Hg=X.define(),Ug=X.define(),Wg=X.define(),Gg=X.define(),Kg=X.define(),qg=X.define();function Jg(e,t){let n=e.state.facet(qg);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return gm.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let t=r[e].spec.bidiIsolate,n;if(a>0&&c.length&&(n=c[c.length-1]).to==o&&n.direction==t)n.to=s,c=n.inner;else{let e={from:o,to:s,direction:t,inner:[]};c.push(e),c=e.inner}}}}),Yg(t.text,i)}function Yg(e,t){for(let n of t){if(n.direction==null){for(let t=n.from,r=0;t0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toAr.push(new $g(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,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}},t_=[],n_=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return t_}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 e=this.domAttrs;e&&ch(this.dom,e)}}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,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=Oh(this.dom),r=this.length?e>0:t>0;return new Xh(this.parent.dom,n+ +!!r,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 a_)return e;return null}static get(e){return e.cmTile}},r_=class extends n_{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 t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=i_(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=i_(r);this.length=a}};function i_(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var a_=class extends r_{constructor(e,t){super(t),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 t=n_.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof o_)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(se||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},o_=class e extends r_{constructor(e,t){super(e),this.wrapper=t}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(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},s_=class e extends r_{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return n&&r||(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&l_(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):c_(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new Xh(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new Xh(e.dom,0);e==n.tile&&(a=!0)}}return new Xh(this.dom,0)}};function c_(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=Eh(t);return n[n.length-1]||null}function l_(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.topr&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?Z.chrome||Z.gecko||(e?(i--,o=1):a=0)?0:s.length-1];return Z.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:Mh(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},f_=class e extends n_{constructor(e,t,n,r){super(e,t,r),this.widget=n}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,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return Mh(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top0==n)}},m_=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i0?s.length<=e:s.length=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof u_&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(E_(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&n_.get(n.dom)&&(e=E_(n.dom));let t=u_.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=n_.get(e.text);i&&this.cache.reused.set(i,2);let a=new d_(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).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 t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=C_;let n=s_.start(e,t||this.cache.find(s_)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}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,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof u_&&a.mark.eq(i))n=a,t--;else{let e=u_.of(i,this.cache.find(u_,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!x_(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(Z.ios&&x_(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(O_,0,32)||new f_(O_.toDOM(),0,O_,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 t=e.rank*102+e.value.rank,n=new h_(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.frome.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(p_,void 0,1);return n&&(n.flags=t),n||new p_(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},__=class{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:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},v_=[f_,s_,d_,u_,p_,o_,a_];for(let e=0;e[]),this.index=v_.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=ar){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof u_&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof u_&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=gm.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof gh){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?D_.block:D_.inline),c=S_(a),l=this.cache.findWidget(i,t-e,c)||f_.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=w_(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=n_.get(r);if(r==this.view.contentDOM)break;e instanceof u_?t.push(e):e?.isLine()?n=e:e instanceof o_||(r.nodeName==`DIV`&&!n?n=new s_(r,C_):n||t.push(u_.of(new mh({tagName:r.nodeName.toLowerCase(),attributes:uh(r)}),r)))}return n?{line:n,marks:t}:null}};function x_(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function S_(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var C_={class:`cm-line`};function w_(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&ah(n,e),r&&(e.class+=` `+r)),e}function T_(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof u_&&t.push(r.mark)}return t}function E_(e){let t=n_.get(e);return t&&t.setDOM(e.cloneNode()),e}var D_=class extends dh{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}};D_.inline=new D_(`span`),D_.block=new D_(`div`);var O_=new class extends dh{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},k_=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ph.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 a_(e,e.contentDOM),this.updateInner([new $g(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>tthis.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 n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!B_(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?N_(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new $g(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(Z.ie||Z.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=I_(i,this.decorations,e.changes);o.length&&(t=$g.extendWithRanges(t,o));let s=R_(a,this.blockWrappers,e.changes);return s.length&&(t=$g.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new b_(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&n_.get(t.text)&&r.cache.reused.set(n_.get(t.text),2),this.tile=r.run(e,t),A_(n,r.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 r=Z.chrome||Z.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Th(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),Z.gecko&&s.empty&&!this.hasComposition&&j_(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new Xh(e,0),o=!0}let u=this.view.observer.selectionRange;!o&&u.focusNode&&(Dh(c.node,c.offset,u.anchorNode,u.anchorOffset)&&Dh(l.node,l.offset,u.focusNode,u.focusOffset)||this.suppressWidgetCursorChange(u,s))||(this.view.observer.ignore(()=>{Z.android&&Z.chrome&&n.contains(u.focusNode)&&z_(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=Ch(this.view.root);if(e){if(s.empty){if(Z.gecko){let e=P_(c.node,c.offset);if(e&&e!=3){let t=(e==1?Jh:Yh)(c.node,c.offset);t&&(c=new Xh(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new Xh(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new Xh(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&Dh(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=Ch(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=jh(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!n_.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof V_?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&tMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==Zh.LTR,c=0,l=(e,u,d)=>{for(let f=0;fr);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof o_)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?Eh(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?Zh.RTL:Zh.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=Eh(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=Eh(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(ph.replace({widget:new V_(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return ph.set(e)}updateDeco(){let e=1,t=this.view.state.facet(Ug).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(Gg).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(gm.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(jg))try{if(t(this.view,e.range,e))return!0}catch(e){Fg(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=Zg(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(Fh(this.view.scrollDOM,a,t.head1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottome.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){A_(this.tile)}};function A_(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)A_(n,t)}}function j_(e){return xh(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function M_(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=Jh(n.focusNode,n.focusOffset),i=Yh(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=n_.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=n_.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function N_(e,t,n){let r=M_(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new $g(c.mapPos(a),c.mapPos(o),a,o),text:i}}function P_(e,t){return xh(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t{et.from&&(n=!0)}),n}var V_=class extends dh{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 H_(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return Y.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=rp(i.text,a,!1):s=rp(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=rp(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;se.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+jm(o,a,e.state.tabSize)}function W_(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.tot)return i;(!e||i.type==fh.Text&&(e.type!=i.type||(n<0?i.fromt)))&&(e=i)}}return e||r}return r}function G_(e,t,n,r){let i=W_(e,t.head,t.assoc||-1),a=!r||i.type!=fh.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAndSideAtCoords({x:n==(r==Zh.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o)return Y.cursor(o.pos,o.assoc)}return Y.cursor(n?i.to:i.from,n?1:-1)}function K_(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=vg(i,a,o,s,n),l=_g;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=` -`,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?Y.cursor(i.from,-1):Y.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function q_(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==im.Space&&(i=t),i==t}}function J_(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return Y.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=$_(e,{x:d,y:r},!1,a);if(n?r>c.bottom:rs:u{if(t>e&&tt(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:Y.cursor(r,re.viewState.docHeight)return new Q_(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==fh.Text){if(r<0?l.toe.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==fh.Text){let t=U_(e,i,l,o,s);return new Q_(t,t==l.from?1:-1)}}if(l.type!=fh.Text)return c<(l.top+l.bottom)/2?new Q_(l.from,1):new Q_(l.to,-1);let u=e.docView.lineAt(l.from,2);return u&&u.length==l.length||(u=e.docView.lineAt(l.from,-2)),new ev(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var ev=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from>1;adjust:if(a.has(f)){for(let e=1;e=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e1)){if(t.bottomthis.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==Zh.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r{let i=n[r]-t,a=n[r+1]-t;return Uh(e.dom,i,a).getClientRects()});return r.after?new Q_(n[r.i+1],-1):new Q_(n[r.i],1)}scanTile(e,t){if(!e.length)return new Q_(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r{let n=e.children[t];return n.flags&48?null:(xh(n.dom)?n.dom:Uh(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new Q_(n[r.i+1],-1):new Q_(a,1)}},tv=`￿`,nv=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(lm.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=tv}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=n_.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=n_.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:kh(r))||kh(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!iv(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=n_.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else Sh(e)?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():xh(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(Sh(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(rv(e,n.node,n.offset)?t:0))}};function rv(e,t,n){for(;;){if(!t||n-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=sv(e.docView.tile,t,n,0))){let t=i||a?[]:fv(e),n=new nv(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=pv(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!wh(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!wh(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((Z.ios||Z.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to-1&&o.ranges.length>1)this.newSel=o.replaceRange(Y.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=Y.create([Y.cursor(n,r)])}else this.newSel=Y.single(r,n)}}};function sv(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;cn)return sv(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function cv(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||Z.android&&t.text.length=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:Kf.of(t.text.slice(a.from-e,u).split(tv))}:(d=dv(l,t.text,s-e,c))&&(Z.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:Kf.of(t.text.slice(d.from,d.toB).split(tv))})}else r&&(!e.hasFocus&&i.facet(Ig)||mv(r,a))&&(r=null);if(!n&&!r)return!1;if((Z.mac||Z.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=Y.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:Kf.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:Z.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&e.lineWrapping&&(r&&=Y.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:Kf.of([` `])}),n)return lv(e,n,r,o);if(r&&!mv(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=X_(i.facet(Kg).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function lv(e,t,n,r=-1){if(Z.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(Z.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&Wh(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.lengthi.head)&&Wh(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&Wh(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=uv(e,t,n);return e.state.facet(Tg).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function uv(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.froma.to){let n=t.fromt(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:Y.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.fromt.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&M_(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?Y.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function dv(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function fv(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new av(n,r)),(i!=n||a!=r)&&t.push(new av(i,a))),t}function pv(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?Y.create([Y.cursor(r+t,-1)]):Y.single(n+t,r+t)}function mv(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var hv=class{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,Z.safari&&e.contentDOM.addEventListener(`input`,()=>null),Z.gecko&&Qv(e.contentDOM.ownerDocument)}handleEvent(e){kv(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=vv(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}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&&xv.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Z.android&&Z.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Z.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(yv.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||bv.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&Z.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&gv(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from0?!0:Z.safari&&!Z.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 gv(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function _v(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){Fg(n.state,e)}}}function vv(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(_v(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(_v(t.value,r))}}for(let e in Av)n(e).handlers.push(Av[e]);for(let e in jv)n(e).observers.push(jv[e]);return t}var yv=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],bv=`dthko`,xv=[16,17,18,20,91,92,224,225],Sv=6;function Cv(e){return Math.max(0,e)*.7+8}function wv(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var Tv=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=Ih(e.contentDOM),this.atoms=e.state.facet(Kg).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(lm.allowMultipleSelections)&&Ev(e,t),this.dragging=Ov(e,t)&&Vv(t)==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&&wv(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=Zg(this.view);e.clientX-s.left<=r+Sv?t=-Cv(r-e.clientX):e.clientX+s.right>=a-Sv&&(t=Cv(e.clientX-a)),e.clientY-s.top<=i+Sv?n=-Cv(i-e.clientY):e.clientY+s.bottom>=o-Sv&&(n=Cv(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??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,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=X_(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function Ev(e,t){let n=e.state.facet(bg);return n.length?n[0](t):Z.mac?t.metaKey:t.ctrlKey}function Dv(e,t){let n=e.state.facet(xg);return n.length?n[0](t):Z.mac?!t.altKey:!t.ctrlKey}function Ov(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=Ch(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function kv(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=n_.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var Av=Object.create(null),jv=Object.create(null),Mv=Z.ie&&Z.ie_version<15||Z.ios&&Z.webkit_version<604;function Nv(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),Fv(e,n.value)},50)}function Pv(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function Fv(e,t){t=Pv(e.state,Dg,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(qv!=null&&n.selection.ranges.every(e=>e.empty)&&qv==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:Y.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:Y.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}jv.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,Z.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},jv.wheel=jv.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},Av.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),jv.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},jv.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},jv.touchend=(e,t)=>{e.inputState.touchActive=!1},Av.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(Sg))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=Hv(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new Tv(e,t,n,r)),r&&e.observer.ignore(()=>{Vh(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function Iv(e,t,n,r){if(r==1)return Y.cursor(t,n);if(r==2)return H_(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return oDate.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(zv+1)%3:1}function Hv(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=Vv(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=Iv(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=Iv(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i1&&(c=Uv(i,s.pos))?c:o?i.addRange(l):Y.create([l])}}}function Uv(e,t){for(let n=0;n=t)return Y.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}Av.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=Y.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,Pv(e.state,Og,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},Av.dragend=e=>(e.inputState.draggedContent=null,!1);function Wv(e,t,n,r){if(n=Pv(e.state,Dg,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&Dv(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}Av.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&Wv(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return Wv(e,t,n,!0),!0}return!1},Av.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=Mv?null:t.clipboardData;return n?(Fv(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(Nv(e),!1)};function Gv(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function Kv(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:Pv(e,Og,t.join(e.lineBreak)),ranges:n,linewise:r}}var qv=null;Av.copy=Av.cut=(e,t)=>{if(!Th(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=Kv(e.state);if(!n&&!i)return!1;qv=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=Mv?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(Gv(e,n),!1)};var Jv=Gp.define();function Yv(e,t){let n=[];for(let r of e.facet(Eg)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:Jv.of(!0)}):null}function Xv(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=Yv(e.state,t);n?e.dispatch(n):e.update([])}},10)}jv.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),Xv(e)},jv.blur=e=>{e.observer.clearSelectionRange(),Xv(e)},jv.compositionstart=jv.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},jv.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,Z.chrome&&Z.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},jv.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},Av.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return lv(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(Z.chrome&&Z.android&&(n=yv.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return Z.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),Z.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>jv.compositionend(e,t),20),!1};var Zv=new Set;function Qv(e){Zv.has(e)||(Zv.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var $v=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],ey=!1;function ty(){ey=!1}var ny=class{constructor(e){this.lineWrapping=e,this.doc=Kf.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}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 $v.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>oy&&(ey=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,ay.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,ay.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,sa*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i=i&&a(this.lineAt(0,ay.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},dy=class e extends uy{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new iy(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof fy&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof fy?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):sy.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||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:``})`}},fy=class e extends sy{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return sy.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=oy&&(s=-2);let c=new dy(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=sy.of(r);return(s<0||Math.abs(c.height-this.height)>=oy||Math.abs(s-this.heightMetrics(t,n).perLine)>=oy)&&(ey=!0),cy(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},py=class extends sy{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return eo))return c;let l=t==ay.ByPosNoHeight?ay.ByPosNoHeight:ay.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,ay.ByPos,n,r,i);e=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&my(i,a-1),t=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e2*t.size||t.size>2*e.size?sy.of(this.break?[e,null,t]:[e,t]):(this.left=cy(this.left,e),this.right=cy(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function my(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof fy&&(r=e[t+1])instanceof fy&&e.splice(t-1,3,new fy(n.length+1+r.length))}var hy=5,gy=class e{constructor(e,t){this.pos=e,this.oracle=t,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,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof dy?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new dy(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e=hy)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new dy(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new fy(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof dy)return e;let t=new dy(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof dy)&&!this.isCovered?this.nodes.push(new dy(0,-1,0)):(this.writtenTot.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function by(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left0&&t.top0}function xy(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var Sy=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;ntypeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new ny(n),this.stateDeco=jy(t),this.heightMap=sy.empty().applyChanges(this.stateDeco,Kf.empty,this.heightOracle.setDoc(t.doc),[new $g(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ph.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new Ty(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?Ay:My.get(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(Ny(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=jy(this.state);let r=e.changedRanges,i=$g.extendWithRanges(r,_y(n,this.stateDeco,e?e.changes:dp.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ty(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||ey)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heads.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!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),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Ag)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?Zh.RTL:Zh.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=Ph(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=Ih(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=qh(this.scrollParent||e.win);let m=(this.printing?xy:yy)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!by(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),ty();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?sy.empty().applyChanges(this.stateDeco,Kf.empty,this.heightOracle,[new $g(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new ry(n.from,i))}ey&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new Ty(r.lineAt(a-n*1e3,ay.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,ay.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(es.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,ay.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i>1,a=r<<1;if(this.defaultTextDirection!=Zh.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-rr&&ee.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)e.fromt));if(!f){if(ae.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(Y.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new Sy(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length2e6)for(let n of e)n.from>=t.from&&n.fromt.from&&s(t.from,c,t,i),le.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];gm.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Ny(this.heightMap.lineAt(e,ay.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(t=>t.top<=e&&t.bottom>=e)||Ny(this.heightMap.lineAt(this.scaler.fromDOM(e),ay.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+12-this.paddingTop);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return Ny(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}},Ty=class{constructor(e,t){this.from=e,this.to=t}};function Ey(e,t,n){let r=[],i=e,a=0;return gm.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function Oy(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function ky(e,t){for(let n of e)if(t(n))return n}var Ay={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function jy(e){let t=e.facet(Ug).filter(e=>typeof e!=`function`),n=e.facet(Gg).filter(e=>typeof e!=`function`);return n.length&&t.push(gm.join(n)),t}var My=class e{constructor(e,t){this.scale=e,this.viewports=t}static get(t,n,r){let i=0,a=0,o=0,s=r.map(({from:e,to:r})=>{let a=n.lineAt(e,ay.ByPos,t,0,0).top,o=n.lineAt(r,ay.ByPos,t,0,0).bottom;return i+=o-a,{from:e,to:r,top:a,bottom:o,domTop:0,domBottom:0}});if(n.height-i<10)return Ay;let c=(7e6-i)/(n.height-i);for(let e of s)e.domTop=o+(e.top-a)*c,o=e.domBottom=e.domTop+(e.bottom-e.top),a=e.bottom;return new e(c,s)}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=te.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function Ny(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new iy(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>Ny(e,t)):e._content)}var Py=X.define({combine:e=>e.join(` `)}),Fy=X.define({combine:e=>e.indexOf(!0)>-1}),Iy=Im.newName(),Ly=Im.newName(),Ry=Im.newName(),zy={"&light":`.`+Ly,"&dark":`.`+Ry};function By(e,t,n){return new Im(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var Vy=By(`.`+Iy,{"&":{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:`baseline`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) 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`}},zy),Hy={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Uy=Z.ie&&Z.ie_version<=11,Wy=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new Lh,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(t=>{for(let e of t)this.queue.push(e);(Z.ie&&Z.ie_version<=11||Z.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Z.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Z.chrome&&Z.chrome_version<126)&&(this.editContext=new Jy(e),e.state.facet(Ig)&&(e.contentDOM.editContext=this.editContext.editContext)),Uy&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.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(()=>{this.view.docView?.lastUpdate{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.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(e=>{e.length>0&&e[e.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(this.pendingRecords().length>0),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((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet(Ig)?n.root.activeElement!=this.dom:!Th(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(Z.ie&&Z.ie_version<=11||Z.android&&Z.chrome)&&!n.state.selection.main.empty&&r.focusNode&&Dh(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Ch(e.root);if(!t)return!1;let n=Z.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&qy(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=Th(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&Wh(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&e!=`Enter`||(this.delayedAndroidKey={key:e,keyCode:t,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 t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&Th(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new ov(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=cv(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=Gy(t,e.previousSibling||e.target.previousSibling,-1),r=Gy(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.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(Ig)!=e.state.facet(Ig)&&(e.view.contentDOM.editContext=e.state.facet(Ig)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.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 Gy(e,t,n){for(;t;){let r=n_.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function Ky(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return Dh(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function qy(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Ky(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?Ky(e,n):null}var Jy=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=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=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&ithis.to&&(s=i);let l=dv(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=Y.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));mv(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:Kf.of(n.text.slice(l.from,l.toB).split(` -`))};if((Z.mac||Z.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:Kf.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);lv(e,u,Y.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i{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:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=Ch(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(ithis.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.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||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+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 t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Yy=class e{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={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,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:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||Gh(e.parent)||document,this.viewState=new wy(this,e.state||lm.create(e)),e.scrollTo&&e.scrollTo.is(Ng)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Rg).map(e=>new Bg(e));for(let e of this.plugins)e.update(this);this.observer=new Wy(this),this.inputState=new hv(this),this.inputState.ensureHandlers(this.plugins),this.docView=new k_(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Yp?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(Jv))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=Yv(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(lm.phrases)!=this.state.facet(lm.phrases))return this.setState(a);i=e_.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new Mg(t.empty?t:Y.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(Ng)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=Qy.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(Qg)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(Py)!=i.state.facet(Py)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(wg))try{e(i)}catch(e){Fg(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!cv(this,u)&&l.force&&Wh(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw 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 t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new wy(this,e),this.plugins=e.facet(Rg).map(e=>new Bg(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new k_(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Rg),n=e.state.facet(Rg);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new Bg(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(qh(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return Fg(this.state,e),Zy}}),u=e_.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e1||e<-1)&&!(Z.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(wg))e(t)}get themeClasses(){return Iy+` `+(this.state.facet(Fy)?Ry:Ly)+` `+this.state.facet(Py)}updateAttrs(){let e=$y(this,Vg,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet(Ig)?`true`:`false`,class:`cm-content`,style:`${Z.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),$y(this,Hg,t);let n=this.observer.ignore(()=>{let n=lh(this.contentDOM,this.contentAttrs,t),r=lh(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(Qg);let t=this.state.facet(e.cspNonce);Im.mount(this.root,this.styleModules.concat(Vy).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw 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 t=0;tt.plugin==e)||null),t&&t.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,t,n){return Z_(this,e,K_(this,e,t,n))}moveByGroup(e,t){return Z_(this,e,K_(this,e,t,t=>q_(this,e.head,t)))}visualLineSide(e,t){return t?Y.cursor(e.to,1):Y.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return G_(this,e,t,n)}moveVertically(e,t,n){return Z_(this,e,J_(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=$_(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),$_(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[sg.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==Zh.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(kg)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Xy)return gg(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||cg(r.isolates,n=Jg(this,e))))return r.order;n||=Jg(this,e);let r=hg(e.text,t,n);return this.bidiCache.push(new Qy(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||Z.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Vh(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.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Ng.of(new Mg(typeof e==`number`?Y.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Ng.of(new Mg(Y.cursor(n.from),`start`,`start`,n.top-e,t,!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 zg.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return zg.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Im.newName(),r=[Py.of(n),Qg.of(By(`.${n}`,e))];return t&&t.dark&&r.push(Fy.of(!0)),r}static baseTheme(e){return Ap.lowest(Qg.of(By(`.`+Iy,e,zy)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&n_.get(t)||n_.get(e))?.root?.view||null}};Yy.styleModule=Qg,Yy.inputHandler=Tg,Yy.clipboardInputFilter=Dg,Yy.clipboardOutputFilter=Og,Yy.scrollHandler=jg,Yy.focusChangeEffect=Eg,Yy.perLineTextDirection=kg,Yy.exceptionSink=Cg,Yy.updateListener=wg,Yy.editable=Ig,Yy.mouseSelectionStyle=Sg,Yy.dragMovesSelection=xg,Yy.clickAddsSelectionRange=bg,Yy.decorations=Ug,Yy.blockWrappers=Wg,Yy.outerDecorations=Gg,Yy.atomicRanges=Kg,Yy.bidiIsolatedRanges=qg,Yy.cursorScrollMargin=X.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Yy.scrollMargins=Xg,Yy.darkTheme=Fy,Yy.cspNonce=X.define({combine:e=>e.length?e[0]:``}),Yy.contentAttributes=Hg,Yy.editorAttributes=Vg,Yy.lineWrapping=Yy.contentAttributes.of({class:`cm-lineWrapping`}),Yy.announce=Jp.define();var Xy=4096,Zy={},Qy=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Zh.LTR;for(let a=Math.max(0,t.length-10);a=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&ah(a,n)}return n}var eb=Z.mac?`mac`:Z.windows?`win`:Z.linux?`linux`:`key`;function tb(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;ee.concat(t),[]))),n}var sb=null,cb=4e3;function lb(e,t=eb){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>tb(e,t));for(let t=1;t{let r=sb={view:t,prefix:n,scope:e};return setTimeout(()=>{sb==r&&(sb=null)},cb),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,ub))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var ub=null;function db(e,t,n,r){ub=t;let i=Gm(t),a=sp(op(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;sb&&sb.view==n&&sb.scope==r&&(o=sb.prefix+` `,xv.indexOf(t.keyCode)<0&&(c=!0,sb=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+nb(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(Z.windows&&t.ctrlKey&&t.altKey)&&!(Z.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=zm[t.keyCode])&&p!=i?(d(f[o+nb(p,t,!0)])||t.shiftKey&&(m=Bm[t.keyCode])!=i&&m!=p&&d(f[o+nb(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+nb(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),ub=null,s}var fb=!Z.ios,pb=Z.gecko&&Z.gecko_version==153?`#ffffff01`:`transparent`;({...fb?{"& ::selection, &::selection":{backgroundColor:`${pb} !important`}}:{}}),{...fb?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}},/x/.unicode;var mb=class extends dh{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?Eh(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=Mh(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function hb(e){let t=zg.fromClass(class{constructor(t){this.view=t,this.placeholder=e?ph.set([ph.widget({widget:new mb(e),side:1}).range(0)]):ph.none}get decorations(){return this.view.state.doc.length?ph.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,Yy.contentAttributes.of({"aria-placeholder":e})]:t}var gb=`-10000px`,_b=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;nt[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function vb(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function yb(e){let{left:t,right:n}=vb(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var bb=X.define({combine:e=>({position:Z.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||yb})}),xb=new WeakMap,Sb=zg.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(bb);this.position=t.position,this.parent=t.parent,this.classes=e.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 _b(e,Eb,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.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 e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(bb);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.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 e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=gb,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 e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(Z.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=vb(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=Zg(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(bb).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||u.rightMath.min(t.right,n.right)+.1)){l.style.top=gb;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=xb.get(c)??d.bottom-d.top,g=c.offset||Tb,_=this.view.textDirection==Zh.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.yn.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(bv&&e.topx&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,Cb(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,Cb(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.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 e of this.manager.tooltipViews)e.dom.style.top=gb}},{eventObservers:{scroll(){this.maybeMeasure()}}});function Cb(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var wb=Yy.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:`14px`,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`}}}),Tb={x:0,y:0},Eb=X.define({enables:[Sb,wb]}),Db=X.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])}),Ob=class e{static create(t){return new e(t)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement(`div`),this.dom.classList.add(`cm-tooltip-hover`),this.manager=new _b(e,Db,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add(`cm-tooltip-section`),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)==null||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let r=n[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp(`offset`)}get getCoords(){return this.passProp(`getCoords`)}get overlap(){return this.passProp(`overlap`)}get resize(){return this.passProp(`resize`)}},kb=Eb.compute([Db],e=>{let t=e.facet(Db);return t.length===0?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>e.end??e.pos)),create:Ob.create,above:t[0].above,arrow:t.some(e=>e.arrow)}}),Ab=X.define(),jb=class{constructor(e,t,n,r,i,a){this.view=e,this.source=t,this.field=n,this.locked=r,this.setHover=i,this.hoverTime=a,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;en.bottom||t.xn.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(e=>e.from<=r&&e.to>=r),o=a&&a.dir==Zh.RTL?-1:1;i=t.x{if(t&&(!Array.isArray(t)||t.length)){let n=Array.isArray(t)?t:[t];r&&this.locked.set(n,r),e.dispatch({effects:this.setHover.of(n)})}};if(i&&`then`in i){let n=this.pending={pos:t};i.then(e=>{this.pending==n&&(this.pending=null,a(e))},t=>Fg(e.state,t,`hover tooltip`))}else a(i)}get tooltip(){let e=this.view.plugin(Sb),t=e?e.manager.tooltips.findIndex(e=>e.create==Ob.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){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:t,tooltip:n}=this;if(t.length&&!this.locked.has(t)&&n&&!Nb(n.dom,e)||this.pending){let{pos:n}=t[0]||this.pending,r=t[0]?.end??n;(n==r?this.view.posAtCoords(this.lastMove)!=n:!Pb(this.view,n,r,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:t}=this;t&&t.dom.contains(e.relatedTarget)?this.watchTooltipLeave(t.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener(`mouseleave`,t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener(`mouseleave`,t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener(`mouseleave`,this.mouseleave),this.view.dom.removeEventListener(`mousemove`,this.mousemove)}},Mb=4;function Nb(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),o;if(o=e.querySelector(`.cm-tooltip-arrow`)){let e=o.getBoundingClientRect();i=Math.min(e.top,i),a=Math.max(e.bottom,a)}return t.clientX>=n-Mb&&t.clientX<=r+Mb&&t.clientY>=i-Mb&&t.clientY<=a+Mb}function Pb(e,t,n,r,i,a){let o=e.scrollDOM.getBoundingClientRect(),s=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>r||o.righti||Math.min(o.bottom,s)=t&&c<=n}function Fb(e,t={}){let n=Jp.define(),r=new WeakMap,i=Dp.define({create(){return[]},update(e,a){let o=r.get(e);if(e.length&&(t.hideOnChange&&(a.docChanged||a.selection)||o&&o(a)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(a,e)))),a.docChanged&&e.length){let t=[];for(let n of e){let e=a.changes.mapPos(n.pos,-1,lp.TrackDel);if(e!=null){let r=Object.assign(Object.create(null),n);r.pos=e,r.end!=null&&(r.end=a.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of a.effects)t.is(n)&&(e=t.value,o=void 0),(t.is(Ib)&&!t.value||t.value==i)&&(e=[]);return e.length&&o&&r.set(e,o),e},provide:e=>Db.from(e)}),a=zg.define(a=>new jb(a,e,i,r,n,t.hoverTime||300));return{active:i,extension:[i,a,Ab.of(a),kb]}}var Ib=Jp.define(),Lb=X.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}}),Rb=zg.fromClass(class{constructor(e){this.input=e.state.facet(Vb),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(Lb);this.top=new zb(e,!0,t.topContainer),this.bottom=new zb(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(Lb);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new zb(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new zb(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(Vb);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Yy.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),zb=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),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 e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=Bb(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=Bb(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 Bb(e){let t=e.nextSibling;return e.remove(),t}var Vb=X.define({enables:Rb}),Hb=class extends dm{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};Hb.prototype.elementClass=``,Hb.prototype.toDOM=void 0,Hb.prototype.mapMode=lp.TrackBefore,Hb.prototype.startSide=Hb.prototype.endSide=-1,Hb.prototype.point=!0;var Ub=1024,Wb=0,Gb=class{constructor(e,t){this.from=e,this.to=t}},Kb=class{constructor(e={}){this.id=Wb++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=Yb.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};Kb.closedBy=new Kb({deserialize:e=>e.split(` `)}),Kb.openedBy=new Kb({deserialize:e=>e.split(` `)}),Kb.group=new Kb({deserialize:e=>e.split(` `)}),Kb.isolate=new Kb({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),Kb.contextHash=new Kb({perNode:!0}),Kb.lookAhead=new Kb({perNode:!0}),Kb.mounted=new Kb({perNode:!0});var qb=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[Kb.mounted.id]}},Jb=Object.create(null),Yb=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):Jb,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[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 t=this.prop(Kb.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(Kb.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};Yb.none=new Yb(``,Object.create(null),0,8);var Xb=class e{constructor(e){this.types=e;for(let t=0;t0;for(let e=this.cursor(a|$b.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!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 t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:yx(Yb.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(Yb.none,t,n,r)))}static build(e){return gx(e)}};ex.empty=new ex(Yb.none,[],[],0);var tx=class e{constructor(e,t){this.buffer=e,this.index=t}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 e(this.buffer,this.index)}},nx=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Yb.none}toString(){let e=[];for(let t=0;t0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e=t&&nt;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function ix(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&$b.EnterBracketed&&l instanceof ex&&(d=qb.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||rx(i,r,u,u+l.length)){if(l instanceof nx){if(a&$b.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new ux(new lx(o,l,t,u),null,e)}else if(a&$b.IncludeAnonymous||!l.type.isAnonymous||hx(l)){let s;if(!(a&$b.IgnoreMounts)&&(s=qb.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&$b.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&$b.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n: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(t,n,r=0){let i;if(!(r&$b.IgnoreOverlays)&&(i=qb.get(this._tree))&&i.overlay){let a=t-this.from,o=r&$b.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,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 sx(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function cx(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var lx=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},ux=class e extends ax{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,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}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(t,n,r=0){if(r&$b.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}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:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new ex(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function dx(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;rn.from||i.to=t){let o=new ox(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(ix(o,t,n,!1))}}return i?dx(i):r}var mx=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~$b.EnterBracketed,e instanceof ox)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.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,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof ox?(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,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}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,t,n=this.mode){return this.buffer?n&$b.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&$b.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&$b.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:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&$b.IncludeAnonymous||e instanceof nx||!e.type.isAnonymous||hx(e))return!1}return!0}move(e,t){if(t&&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,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e=0;i--){if(i<0)return cx(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function hx(e){return e.children.some(e=>e instanceof nx||!e.type.isAnonymous||hx(e))}function gx(e){let{buffer:t,nodeSet:n,maxBufferLength:r=Ub,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new tx(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,A=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new nx(t,C-k.start,n),A=k.start-e}else{let e=o.pos-w;o.next();let t=[],s=[],c=x>=a?x:-1,h=0,g=C,_=T;for(;o.pos>e;)c>=0&&o.id==c&&o.size>=0?(o.end<=g-r&&(p(t,s,S,h,o.end,g,c,_,E),h=t.length,g=o.end,_=l),o.next()):b>2500?d(S,e,t,s):(c>=0&&o.size==-1&&i[o.id].type==n.types[c]&&(h=0&&h>0&&h-1&&h>0){let e=f(D,E);O=yx(D,t,s,0,t.length,0,C-S,e,e)}else O=m(D,t,s,C-S,T-C,E)}_.push(O),v.push(A)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new nx(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof ex){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(Kb.lookAhead))&&(a=r[o]+s.length+c-i)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[Kb.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[Kb.lookAhead,i];o=o?[e].concat(o):[e]}return new ex(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new ex(s[e.topID],_.reverse(),v.reverse(),y)}var _x=new WeakMap;function vx(e,t){if(!e.isAnonymous||t instanceof nx||t.type!=e)return 1;let n=_x.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof ex)){n=1;break}n+=vx(e,r)}_x.set(t,n)}return n}function yx(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(yx(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var bx=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s=r)for(;o&&o.from=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=anew Gb(e.from,e.to)):[new Gb(0,0)]:[new Gb(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},Sx=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new Kb({perNode:!0});var Cx=0,wx=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Cx++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new Ex(e);return e=>e.modified.indexOf(t)>-1?e:Ex.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Tx=0,Ex=class e{constructor(e){this.name=e,this.instances=[],this.id=Tx++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Dx(n,e.modified));if(r)return r;let i=[],a=new wx(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Ox(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Dx(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Ox(e){let t=[[]];for(let n=0;nt.length-e.length)}function kx(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new jx(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Ax.add(t)}var Ax=new Kb({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new jx(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),jx=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Nx(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function Px(e,t,n,r=0,i=e.length){let a=new Fx(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Fx=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Ix(e)||jx.empty,u=Nx(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(Kb.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Ix(e){let t=e.type.prop(Ax);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var Q=wx.define,Lx=Q(),Rx=Q(),zx=Q(Rx),Bx=Q(Rx),Vx=Q(),Hx=Q(Vx),Ux=Q(Vx),Wx=Q(),Gx=Q(Wx),Kx=Q(),qx=Q(),Jx=Q(),Yx=Q(Jx),Xx=Q(),$={comment:Lx,lineComment:Q(Lx),blockComment:Q(Lx),docComment:Q(Lx),name:Rx,variableName:Q(Rx),typeName:zx,tagName:Q(zx),propertyName:Bx,attributeName:Q(Bx),className:Q(Rx),labelName:Q(Rx),namespace:Q(Rx),macroName:Q(Rx),literal:Vx,string:Hx,docString:Q(Hx),character:Q(Hx),attributeValue:Q(Hx),number:Ux,integer:Q(Ux),float:Q(Ux),bool:Q(Vx),regexp:Q(Vx),escape:Q(Vx),color:Q(Vx),url:Q(Vx),keyword:Kx,self:Q(Kx),null:Q(Kx),atom:Q(Kx),unit:Q(Kx),modifier:Q(Kx),operatorKeyword:Q(Kx),controlKeyword:Q(Kx),definitionKeyword:Q(Kx),moduleKeyword:Q(Kx),operator:qx,derefOperator:Q(qx),arithmeticOperator:Q(qx),logicOperator:Q(qx),bitwiseOperator:Q(qx),compareOperator:Q(qx),updateOperator:Q(qx),definitionOperator:Q(qx),typeOperator:Q(qx),controlOperator:Q(qx),punctuation:Jx,separator:Q(Jx),bracket:Yx,angleBracket:Q(Yx),squareBracket:Q(Yx),paren:Q(Yx),brace:Q(Yx),content:Wx,heading:Gx,heading1:Q(Gx),heading2:Q(Gx),heading3:Q(Gx),heading4:Q(Gx),heading5:Q(Gx),heading6:Q(Gx),contentSeparator:Q(Wx),list:Q(Wx),quote:Q(Wx),emphasis:Q(Wx),strong:Q(Wx),link:Q(Wx),monospace:Q(Wx),strikethrough:Q(Wx),inserted:Q(),deleted:Q(),changed:Q(),invalid:Q(),meta:Xx,documentMeta:Q(Xx),annotation:Q(Xx),processingInstruction:Q(Xx),definition:wx.defineModifier(`definition`),constant:wx.defineModifier(`constant`),function:wx.defineModifier(`function`),standard:wx.defineModifier(`standard`),local:wx.defineModifier(`local`),special:wx.defineModifier(`special`)};for(let e in $){let t=$[e];t instanceof wx&&(t.name=e)}Mx([{tag:$.link,class:`tok-link`},{tag:$.heading,class:`tok-heading`},{tag:$.emphasis,class:`tok-emphasis`},{tag:$.strong,class:`tok-strong`},{tag:$.keyword,class:`tok-keyword`},{tag:$.atom,class:`tok-atom`},{tag:$.bool,class:`tok-bool`},{tag:$.url,class:`tok-url`},{tag:$.labelName,class:`tok-labelName`},{tag:$.inserted,class:`tok-inserted`},{tag:$.deleted,class:`tok-deleted`},{tag:$.literal,class:`tok-literal`},{tag:$.string,class:`tok-string`},{tag:$.number,class:`tok-number`},{tag:[$.regexp,$.escape,$.special($.string)],class:`tok-string2`},{tag:$.variableName,class:`tok-variableName`},{tag:$.local($.variableName),class:`tok-variableName tok-local`},{tag:$.definition($.variableName),class:`tok-variableName tok-definition`},{tag:$.special($.variableName),class:`tok-variableName2`},{tag:$.definition($.propertyName),class:`tok-propertyName tok-definition`},{tag:$.typeName,class:`tok-typeName`},{tag:$.namespace,class:`tok-namespace`},{tag:$.className,class:`tok-className`},{tag:$.macroName,class:`tok-macroName`},{tag:$.propertyName,class:`tok-propertyName`},{tag:$.operator,class:`tok-operator`},{tag:$.comment,class:`tok-comment`},{tag:$.meta,class:`tok-meta`},{tag:$.invalid,class:`tok-invalid`},{tag:$.punctuation,class:`tok-punctuation`}]);var Zx=new Kb;function Qx(e){return X.define({combine:e?t=>t.concat(e):void 0})}var $x=new Kb,eS=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,lm.prototype.hasOwnProperty(`tree`)||Object.defineProperty(lm.prototype,"tree",{get(){return rS(this)}}),this.parser=t,this.extension=[fS.of(this),lm.languageData.of((e,t,n)=>{let r=tS(e,t,n),i=r.type.prop(Zx);if(!i)return[];let a=e.facet(i),o=r.type.prop($x);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return tS(e,t,n).type.prop(Zx)==this.data}findRegions(e){let t=e.facet(fS);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(Zx)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(Kb.mounted);if(i){if(i.tree.prop(Zx)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;ne.isTop?n:void 0)]}),t.name)}configure(t,n){return new e(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function rS(e){let t=e.field(eS.state,!1);return t?t.tree:ex.empty}var iS=class{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,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},aS=null,oS=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],ex.empty,0,r,[],null)}startParse(){return this.parser.startParse(new iS(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ex.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(bx.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=aS;aS=this;try{return e()}finally{aS=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=sS(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=bx.applyChanges(r,e),i=ex.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);ne.from&&(this.fragments=sS(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends xx{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=aS;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new ex(Yb.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return aS}};function sS(e,t,n){return bx.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var cS=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=oS.create(t.facet(fS).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};eS.state=Dp.define({create:cS.init,update(e,t){for(let e of t.effects)if(e.is(eS.setState))return e.value;return t.startState.facet(fS)==t.state.facet(fS)?e.apply(t):cS.init(t.state)}});var lS=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(lS=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var uS=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,dS=zg.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 t=this.view.state.field(eS.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(eS.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=lS(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEndr+1e3,s=i.context.work(()=>uS&&uS()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:eS.setState.of(new cS(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>Fg(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),fS=X.define({combine(e){return e.length?e[0]:null},enables:e=>[eS.state,dS,Yy.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),pS=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}},mS=X.define(),hS=X.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function gS(e){let t=e.facet(hS);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function _S(e,t){let n=``,r=e.tabSize,i=e.facet(hS)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e=t?xS(e,n,t):null}var yS=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=gS(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return Am(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},bS=new Kb;function xS(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.fromr.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return SS(r,e,n)}function SS(e,t,n){for(let r=e;r;r=r.next){let e=wS(r.node);if(e)return e(ES.create(t,n,r))}return 0}function CS(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function wS(e){let t=e.type.prop(bS);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Kb.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>kS(e,!0,1,void 0,n&&!CS(e)?t.from:void 0)}return e.parent==null?TS:null}function TS(){return 0}var ES=class e extends yS{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(DS(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return SS(this.context.next,this.base,this.pos)}};function DS(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function OS(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function kS(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?OS(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}function AS({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}var jS=new Kb;function MS(e){let t=e.firstChild,n=e.lastChild;return t&&t.toe.prop(Zx)==a.data:a?e=>e==a:void 0,this.style=Mx(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new Im(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},PS=X.define(),FS=X.define({combine(e){return e.length?[e[0]]:null}});function IS(e){let t=e.facet(PS);return t.length?t:e.facet(FS)}function LS(e,t){let n=[zS],r;return e instanceof NS&&(e.module&&n.push(Yy.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(FS.of(e)):r?n.push(PS.computeN([Yy.darkTheme],t=>t.facet(Yy.darkTheme)==(r==`dark`)?[e]:[])):n.push(PS.of(e)),n}var RS=class{constructor(e){this.markCache=Object.create(null),this.tree=rS(e.state),this.decorations=this.buildDeco(e,IS(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=rS(e.state),n=IS(e.state),r=n!=IS(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return ph.none;let n=new ym;for(let{from:r,to:i}of e.visibleRanges)Px(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=ph.mark({class:r})))},r,i);return n.finish()}},zS=Ap.high(zg.fromClass(RS,{decorations:e=>e.decorations}));$.meta,$.link,$.heading,$.emphasis,$.strong,$.strikethrough,$.keyword,$.atom,$.bool,$.url,$.contentSeparator,$.labelName,$.literal,$.inserted,$.string,$.deleted,$.regexp,$.escape,$.string,$.variableName,$.variableName,$.typeName,$.namespace,$.className,$.variableName,$.macroName,$.propertyName,$.comment,$.invalid;var BS=1e4,VS=`()[]{}`,HS=new Kb;function US(e,t,n){let r=e.prop(t<0?Kb.openedBy:Kb.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function WS(e){let t=e.type.prop(HS);return t?t(e.node):e}function GS(e,t,n,r={}){let i=r.maxScanDistance||BS,a=r.brackets||VS,o=rS(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=US(r.type,n,a);if(i&&r.from0?t>=o.from&&to.from&&t<=o.to))return KS(e,t,n,r,o,i,a)}}return qS(e,t,n,o,s.type,i,a)}function KS(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var JS=Object.create(null),YS=[Yb.none],XS=[],ZS=Object.create(null),QS=Object.create(null);for(let[e,t]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`]])QS[e]=eC(JS,t);function $S(e,t){XS.indexOf(e)>-1||(XS.push(e),console.warn(t))}function eC(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||$[n];r?typeof r==`function`?t.length?t=t.map(r):$S(n,`Modifier ${n} used at start of tag`):t.length?$S(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:$S(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=ZS[i];if(a)return a.id;let o=ZS[i]=Yb.define({id:YS.length,name:r,props:[kx({[r]:n})]});return YS.push(o),o.id}Zh.RTL,Zh.LTR;var tC=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=oC(e.state,n.from);return r.line?rC(e):r.block?aC(e):!1};function nC(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var rC=nC(dC,0),iC=nC(uC,0),aC=nC((e,t)=>uC(e,t,lC(t)),0);function oC(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var sC=50;function cC(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-sC,r),o=e.sliceDoc(i,i+sC),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+sC),d=e.sliceDoc(i-sC,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function lC(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function uC(e,t,n=t.selection.ranges){let r=n.map(e=>oC(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>cC(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;ti&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;ee.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var fC=Gp.define(),pC=Gp.define(),mC=X.define(),hC=X.define({combine(e){return um(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),gC=Dp.define({create(){return FC.empty},update(e,t){let n=t.state.facet(hC),r=t.annotation(fC);if(r){let i=CC.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?wC(o,o.length,n.minDepth,i):AC(o,t.startState.selection),new FC(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(pC);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Yp.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=CC.fromTransaction(t),o=t.annotation(Yp.time),s=t.annotation(Yp.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new FC(e.done.map(CC.fromJSON),e.undone.map(CC.fromJSON))}});function _C(e={}){return[gC,hC.of(e),Yy.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?yC:e.inputType==`historyRedo`?bC:null;return n?(e.preventDefault(),n(t)):!1}})]}function vC(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(gC,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var yC=vC(0,!1),bC=vC(1,!1),xC=vC(0,!0),SC=vC(1,!0),CC=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&dp.fromJSON(t.changes),[],t.mapped&&up.fromJSON(t.mapped),t.startSelection&&Y.fromJSON(t.startSelection),t.selectionsAfter.map(Y.fromJSON))}static fromTransaction(t,n){let r=OC;for(let e of t.startState.facet(mC)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,OC)}static selection(t){return new e(void 0,OC,void 0,void 0,t)}};function wC(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function TC(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e=t&&i<=o&&(r=!0)}}),r}function EC(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function DC(e,t){return e.length?t.length?e.concat(t):e:t}var OC=[],kC=200;function AC(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-kC));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),wC(e,e.length-1,1e9,n.setSelAfter(r)))}return[CC.selection([t])]}function jC(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function MC(e,t){if(!e.length)return e;let n=e.length,r=OC;for(;n;){let i=NC(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[CC.selection(r)]:OC}function NC(e,t,n){let r=DC(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):OC,n);if(!e.changes)return CC.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new CC(i,Jp.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var PC=/^(input\.type|delete)($|\.)/,FC=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||PC.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?e.moveByChar(n,t):BC(n,t))}function HC(e){return e.textDirectionAt(e.state.selection.main.head)==Zh.LTR}var UC=e=>VC(e,!HC(e)),WC=e=>VC(e,HC(e));function GC(e,t){return zC(e,n=>n.empty?e.moveByGroup(n,t):BC(n,t))}var KC=e=>GC(e,!HC(e)),qC=e=>GC(e,HC(e));typeof Intl<`u`&&Intl.Segmenter;function JC(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function YC(e,t,n){let r=rS(e).resolveInner(t.head),i=n?Kb.closedBy:Kb.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;JC(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?GS(e,r.from,1):GS(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,Y.cursor(s,n?-1:1)}var XC=e=>zC(e,t=>YC(e.state,t,!HC(e))),ZC=e=>zC(e,t=>YC(e.state,t,HC(e)));function QC(e,t){return zC(e,n=>{if(!n.empty)return BC(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var $C=e=>QC(e,!1),ew=e=>QC(e,!0);function tw(e){let t=e.scrollDOM.clientHeightr.empty?e.moveVertically(r,t,n.height):BC(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottomnw(e,!1),iw=e=>nw(e,!0);function aw(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=Y.cursor(r.from+n))}return i}var ow=e=>zC(e,t=>aw(e,t,!0)),sw=e=>zC(e,t=>aw(e,t,!1)),cw=e=>zC(e,t=>aw(e,t,!HC(e))),lw=e=>zC(e,t=>aw(e,t,HC(e))),uw=e=>zC(e,t=>e.moveToLineBoundary(t,!1,!1)),dw=e=>zC(e,t=>e.moveToLineBoundary(t,!0,!1));function fw(e,t,n){let r=!1,i=LC(e.selection,t=>{let i=GS(e,t.head,-1)||GS(e,t.head,1)||t.head>0&&GS(e,t.head-1,1)||t.headfw(e,t,!1);function mw(e,t,n){let r=LC(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=Y.range(e.head,e.anchor));let r=n(e);return Y.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(RC(e.state,r)),!0)}function hw(e,t){return mw(e,t,n=>e.moveByChar(n,t))}var gw=e=>hw(e,!HC(e)),_w=e=>hw(e,HC(e));function vw(e,t){return mw(e,t,n=>e.moveByGroup(n,t))}var yw=e=>vw(e,!HC(e)),bw=e=>vw(e,HC(e)),xw=e=>{let t=!HC(e);return mw(e,t,n=>YC(e.state,n,t))},Sw=e=>{let t=HC(e);return mw(e,t,n=>YC(e.state,n,t))};function Cw(e,t){return mw(e,t,n=>e.moveVertically(n,t))}var ww=e=>Cw(e,!1),Tw=e=>Cw(e,!0);function Ew(e,t){return mw(e,t,n=>e.moveVertically(n,t,tw(e).height))}var Dw=e=>Ew(e,!1),Ow=e=>Ew(e,!0),kw=e=>mw(e,!0,t=>aw(e,t,!0)),Aw=e=>mw(e,!1,t=>aw(e,t,!1)),jw=e=>{let t=!HC(e);return mw(e,t,n=>aw(e,n,t))},Mw=e=>{let t=HC(e);return mw(e,t,n=>aw(e,n,t))},Nw=e=>mw(e,!1,t=>Y.cursor(e.lineBlockAt(t.head).from)),Pw=e=>mw(e,!0,t=>Y.cursor(e.lineBlockAt(t.head).to)),Fw=({state:e,dispatch:t})=>(t(RC(e,{anchor:0})),!0),Iw=({state:e,dispatch:t})=>(t(RC(e,{anchor:e.doc.length})),!0),Lw=({state:e,dispatch:t})=>(t(RC(e,{anchor:e.selection.main.anchor,head:0})),!0),Rw=({state:e,dispatch:t})=>(t(RC(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),zw=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),Bw=({state:e,dispatch:t})=>{let n=aT(e).map(({from:t,to:n})=>Y.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:Y.create(n),userEvent:`select`})),!0},Vw=({state:e,dispatch:t})=>{let n=LC(e.selection,t=>{let n=rS(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return Y.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(RC(e,n)),!0)};function Hw(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.heada.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(RC(n,Y.create(i,i.length-1))),!0)}var Uw=e=>Hw(e,!1),Ww=e=>Hw(e,!0),Gw=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=Y.create([n.main]):n.main.empty||(r=Y.create([Y.cursor(n.main.head)])),r?(t(RC(e,r)),!0):!1};function Kw(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);oi&&(n=`delete.forward`,o=qw(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=qw(e,i,!1),a=qw(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:Y.cursor(i,it(e)))r.between(t,t,(e,r)=>{et&&(t=n?r:e)});return t}var Jw=(e,t,n)=>Kw(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&iJw(e,!1,!0),Xw=e=>Jw(e,!0,!1),Zw=(e,t)=>Kw(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=rp(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),Qw=e=>Zw(e,!1),$w=e=>Zw(e,!0),eT=e=>Kw(e,t=>{let n=e.lineBlockAt(t.head).to;return t.headKw(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),nT=e=>Kw(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Kf.of([``,``])},range:Y.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},iT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:rp(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:rp(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:Y.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function aT(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function oT(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of aT(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(Y.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(Y.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:Y.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var sT=({state:e,dispatch:t})=>oT(e,t,!1),cT=({state:e,dispatch:t})=>oT(e,t,!0);function lT(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of aT(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var uT=({state:e,dispatch:t})=>lT(e,t,!1),dT=({state:e,dispatch:t})=>lT(e,t,!0),fT=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(aT(t).map(({from:e,to:n})=>(e>0?e--:n{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function pT(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=rS(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(Kb.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var mT=gT(!1),hT=gT(!0);function gT(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&pT(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new yS(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=vS(s,r);for(c??=Am(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);ia.from&&r{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:Y.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var vT=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new yS(e,{overrideIndentation:e=>n[e]??-1}),i=_T(e,(t,i,a)=>{let o=vS(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=_S(e,o);(s!=c||a.from!e.readOnly&&(t(e.update(_T(e,(t,n)=>{n.push({from:t.from,insert:e.facet(hS)})}),{userEvent:`input.indent`})),!0),bT=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(_T(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=Am(r,e.tabSize),a=0,o=_S(e,Math.max(0,i-gS(e)));for(;a(e.setTabFocusMode(),!0),ST=[{key:`Ctrl-b`,run:UC,shift:gw,preventDefault:!0},{key:`Ctrl-f`,run:WC,shift:_w},{key:`Ctrl-p`,run:$C,shift:ww},{key:`Ctrl-n`,run:ew,shift:Tw},{key:`Ctrl-a`,run:uw,shift:Nw},{key:`Ctrl-e`,run:dw,shift:Pw},{key:`Ctrl-d`,run:Xw},{key:`Ctrl-h`,run:Yw},{key:`Ctrl-k`,run:eT},{key:`Ctrl-Alt-h`,run:Qw},{key:`Ctrl-o`,run:rT},{key:`Ctrl-t`,run:iT},{key:`Ctrl-v`,run:iw}],CT=[{key:`ArrowLeft`,run:UC,shift:gw,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:KC,shift:yw,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:cw,shift:jw,preventDefault:!0},{key:`ArrowRight`,run:WC,shift:_w,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:qC,shift:bw,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:lw,shift:Mw,preventDefault:!0},{key:`ArrowUp`,run:$C,shift:ww,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Fw,shift:Lw},{mac:`Ctrl-ArrowUp`,run:rw,shift:Dw},{key:`ArrowDown`,run:ew,shift:Tw,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Iw,shift:Rw},{mac:`Ctrl-ArrowDown`,run:iw,shift:Ow},{key:`PageUp`,run:rw,shift:Dw},{key:`PageDown`,run:iw,shift:Ow},{key:`Home`,run:sw,shift:Aw,preventDefault:!0},{key:`Mod-Home`,run:Fw,shift:Lw},{key:`End`,run:ow,shift:kw,preventDefault:!0},{key:`Mod-End`,run:Iw,shift:Rw},{key:`Enter`,run:mT,shift:mT},{key:`Mod-a`,run:zw},{key:`Backspace`,run:Yw,shift:Yw,preventDefault:!0},{key:`Delete`,run:Xw,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:Qw,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:$w,preventDefault:!0},{mac:`Mod-Backspace`,run:tT,preventDefault:!0},{mac:`Mod-Delete`,run:nT,preventDefault:!0}].concat(ST.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),wT=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:XC,shift:xw},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:ZC,shift:Sw},{key:`Alt-ArrowUp`,run:sT},{key:`Shift-Alt-ArrowUp`,run:uT},{key:`Alt-ArrowDown`,run:cT},{key:`Shift-Alt-ArrowDown`,run:dT},{key:`Mod-Alt-ArrowUp`,run:Uw},{key:`Mod-Alt-ArrowDown`,run:Ww},{key:`Escape`,run:Gw},{key:`Mod-Enter`,run:hT},{key:`Alt-l`,mac:`Ctrl-l`,run:Bw},{key:`Mod-i`,run:Vw,preventDefault:!0},{key:`Mod-[`,run:bT},{key:`Mod-]`,run:yT},{key:`Mod-Alt-\\`,run:vT},{key:`Shift-Mod-k`,run:fT},{key:`Shift-Mod-\\`,run:pw},{key:`Mod-/`,run:tC},{key:`Alt-A`,mac:`Ctrl-A`,run:iC},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:xT}].concat(CT),TT={key:`Tab`,run:yT,shift:bT},ET=class e{constructor(e,t,n,r,i,a,o,s,c,l=0,u){this.p=e,this.stack=t,this.state=n,this.reducePos=r,this.pos=i,this.score=a,this.buffer=o,this.bufferBase=s,this.curContext=c,this.lookAhead=l,this.parent=u}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?`!`+this.score:``}`}static start(t,n,r=0){let i=t.parser.context;return new e(t,[],n,r,r,0,[],0,i?new DT(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){let t=e>>19,n=e&65535,{parser:r}=this.p,i=this.reducePos=2e3&&!this.p.parser.nodeSet.types[n]?.isAnonymous&&(s==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=c):this.p.lastBigReductionSizeo;)this.stack.pop();this.reduceContext(n,s)}storeNode(e,t,n,r=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&this.buffer[e-4]==0&&this.buffer[e-1]>-1){if(t==n)return;if(this.buffer[e-2]>=t){this.buffer[e-2]=n;return}}}if(!i||this.pos==n)this.buffer.push(e,t,n,r);else{let i=this.buffer.length;if(i>0&&(this.buffer[i-4]!=0||this.buffer[i-1]<0)){let e=!1;for(let t=i;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;i>0&&this.buffer[i-2]>n;)this.buffer[i]=this.buffer[i-4],this.buffer[i+1]=this.buffer[i-3],this.buffer[i+2]=this.buffer[i-2],this.buffer[i+3]=this.buffer[i-1],i-=4,r>4&&(r-=4)}this.buffer[i]=e,this.buffer[i+1]=t,this.buffer[i+2]=n,this.buffer[i+3]=r}}shift(e,t,n,r){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=r,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,r,4);else{let i=e,{parser:a}=this.p;this.pos=r;let o=a.stateFlag(i,1);!o&&(r>n||t<=a.maxNode)&&(this.reducePos=r),this.pushState(i,o?n:Math.min(n,this.reducePos)),this.shiftContext(t,n),t<=a.maxNode&&this.buffer.push(t,n,r,4)}}apply(e,t,n,r){e&65536?this.reduce(e):this.shift(e,t,n,r)}useNode(e,t,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.reducePos=this.pos=n+e.length;this.pushState(t,n),this.buffer.push(r,n,i,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let t=this,n=t.buffer.length;for(n&&t.buffer[n-4]==0&&(n-=4);n>0&&t.buffer[n-2]>t.reducePos;)n-=4;let r=t.buffer.slice(n),i=t.bufferBase+n;for(;t&&i==t.bufferBase;)t=t.parent;return new e(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,t)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new OT(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if(!(n&65536))return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let n=[];for(let r=0,i;rt&1&&e==r)||n.push(t[e],r)}t=n}let n=[];for(let e=0;e>19,r=t&65535,i=this.stack.length-n*3;if(i<0||e.getGoto(this.stack[i],r,!1)<0){let e=this.findForcedReduction();if(e==null)return!1;t=e}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(r,i)=>{if(!t.includes(r))return t.push(r),e.allActions(r,t=>{if(!(t&393216)){if(t&65536){let n=(t>>19)-i;if(n>1){let r=t&65535,i=this.stack.length-n*3;if(i>=0&&e.getGoto(this.stack[i],r,!1)>=0)return n<<19|65536|r}}else{let e=n(t,i+1);if(e!=null)return e}}})};return n(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 t=0;t0&&this.emitLookAhead()}},DT=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},OT=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},kT=class e{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(t,n=t.bufferBase+t.buffer.length){return new e(t,n,n-t.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 e(this.stack,this.pos,this.index)}};function AT(e,t=Uint16Array){if(typeof e!=`string`)return e;let n=null;for(let r=0,i=0;r=92&&t--,t>=34&&t--;let i=t-32;if(i>=46&&(i-=46,n=!0),a+=i,n)break;a*=46}n?n[i++]=a:n=new t(a)}return n}var jT=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},MT=new jT,NT=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk=``,this.chunkOff=0,this.chunk2=``,this.chunk2Pos=0,this.next=-1,this.token=MT,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,r=this.rangeIndex,i=this.pos+e;for(;in.to:i>=n.to;){if(r==this.ranges.length-1)return null;let e=this.ranges[++r];i+=e.from-n.to,n=e}return i}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,r;if(t>=0&&t=this.chunk2Pos&&nt.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),r=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),r}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=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.next=this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?-1: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,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=MT,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&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n=``;for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(n+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return n}},PT=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;IT(this.data,e,t,this.id,n.data,n.tokenPrecTable)}};PT.prototype.contextual=PT.prototype.fallback=PT.prototype.extend=!1;var FT=class{constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data=typeof e==`string`?AT(e):e}token(e,t){let n=e.pos,r=0;for(;;){let n=e.next<0,i=e.resolveOffset(1,1);if(IT(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(n||r++,i==null)break;e.reset(i,e.token)}r&&(e.reset(n,e.token),e.acceptToken(this.elseToken,r))}};FT.prototype.contextual=PT.prototype.fallback=PT.prototype.extend=!1;function IT(e,t,n,r,i,a){let o=0,s=1<0){let n=e[r];if(c.allows(n)&&(t.token.value==-1||t.token.value==n||RT(n,t.token.value,i,a))){t.acceptToken(n);break}}let r=t.next,l=0,u=e[o+2];if(t.next<0&&u>l&&e[n+u*3-3]==65535){o=e[n+u*3-1];continue scan}for(;l>1,a=n+i+(i<<1),s=e[a],c=e[a+1]||65536;if(r=c)l=i+1;else{o=e[a+2],t.advance();continue scan}}break}}function LT(e,t,n){for(let r=t,i;(i=e[r])!=65535;r++)if(i==n)return r-t;return-1}function RT(e,t,n,r){let i=LT(n,r,t);return i<0||LT(n,r,e)t)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,t-25)):Math.min(e.length,Math.max(r.from+1,t+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:e.length}}var HT=class{constructor(e,t){this.fragments=e,this.minRepeat=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.lastRepeat=null,this.lastRepeatPos=-1,this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?VT(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?VT(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=a,null;if(i instanceof ex){let n=a>this.lastRepeatPos&&i.type.id>=this.minRepeat;if(a==e||n){let t=a+i.length,r;if(a>=this.safeFrom&&t<=this.safeTo&&(!(r=i.prop(Kb.lookAhead))||t+r=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(a),this.index.push(0))}else this.index[t]++,this.nextStart=a+i.length}}},UT=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new jT)}getActions(e){let t=0,n=null,{parser:r}=e.p,{tokenizers:i}=r,a=r.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,s=0;for(let r=0;rl.end+25&&(s=Math.max(l.lookAhead,s)),l.value!=0)){let r=t;if(l.extended>-1&&(t=this.addActions(e,l.extended,l.end,t)),t=this.addActions(e,l.value,l.end,t),!c.extend&&(n=l,t>r))break}}for(;this.actions.length>t;)this.actions.pop();return s&&e.setLookAhead(s),!n&&e.pos==this.stream.end&&(n=new jT,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new jT,{pos:n,p:r}=e;return t.start=n,t.end=Math.min(n+1,r.stream.end),t.value=n==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,n){let r=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(r,e),n),e.value>-1){let{parser:t}=n.p;for(let r=0;r=0&&n.p.parser.dialect.allows(i>>1)){i&1?e.extended=i>>1:e.value=i>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,n,r){for(let t=0;te.bufferLength*4?new HT(n,e.minRepeatTerm):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],r,i;if(this.bigReductionCount>300&&e.length==1){let[t]=e;for(;t.forceReduce()&&t.stack.length&&t.stack[t.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let a=0;at)n.push(o);else if(this.advanceStack(o,n,e))continue;else{r||(r=[],i=[]),r.push(o);let e=this.tokens.getMainToken(o);i.push(e.value,e.end)}break}}if(!n.length){let e=r&&YT(r);if(e)return zT&&console.log(`Finish with `+this.stackID(e)),this.stackToTree(e);if(this.parser.strict)throw zT&&r&&console.log(`Stuck with token `+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):`none`)),SyntaxError(`No parse at `+t);this.recovering||=5}if(this.recovering&&r){let e=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,i,n);if(e)return zT&&console.log(`Force-finish `+this.stackID(e)),this.stackToTree(e.forceAll())}if(this.recovering){let e=this.recovering==1?1:this.recovering*3;if(n.length>e)for(n.sort((e,t)=>t.score-e.score);n.length>e;)n.pop();n.some(e=>e.reducePos>t)&&this.recovering--}else if(n.length>1){outer:for(let e=0;e500&&i.buffer.length>500){if((t.score-i.score||t.buffer.length-i.buffer.length)>0)n.splice(r--,1);else{n.splice(e--,1);continue outer}}}}n.length>12&&(n.sort((e,t)=>t.score-e.score),n.splice(12,n.length-12))}this.minStackPos=n[0].pos;for(let e=1;e-1&&n.length&&(!i||(n.prop(Kb.contextHash)||0)==a))return e.useNode(n,o,t),n;if(n.children.length==0||n.positions[0]>0)break;let s=n.children[0];if(s instanceof ex&&(!r||s.type.id>=this.parser.minRepeatTerm))n=s;else break}return null}advanceStack(e,t,n){let r=e.pos,{parser:i}=this,a=zT?this.stackID(e)+` -> `:``;if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.reducePos0)return e.reduce(o),zT&&console.log(a+this.stackID(e)+` (via always-reduce ${i.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let s=this.tokens.getActions(e);for(let o=0;or?t.push(f):n.push(f)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return GT(e,t),!0}}runRecovery(e,t,n){let r=null,i=!1;for(let a=0;a `:``;if(o.deadEnd&&(i||(i=!0,o.restart(),zT&&console.log(l+this.stackID(o)+` (restarted)`),this.advanceFully(o,n))))continue;let u=o.split(),d=l;for(let e=0;e<10&&u.forceReduce()&&(zT&&console.log(d+this.stackID(u)+` (via force-reduce)`),!this.advanceFully(u,n));e++)zT&&(d=this.stackID(u)+` -> `);for(let e of o.recoverByInsert(s))zT&&console.log(l+this.stackID(e)+` (via recover-insert)`),this.advanceFully(e,n);this.stream.end>o.pos?(c==o.pos&&(c++,s=0),o.recoverByDelete(s,c),zT&&console.log(l+this.stackID(o)+` (via recover-delete ${this.parser.getName(s)})`),GT(o,n)):(!r||r.scoree.topRules[t][1]),r=[];for(let e=0;e=0)i(r,e,t[n++]);else{let a=t[n+-r];for(let o=-r;o>0;o--)i(t[n++],e,a);n++}}}this.nodeSet=new Xb(t.map((t,i)=>Yb.define({name:i>=this.minRepeatTerm?void 0:t,id:i,props:r[i],top:n.indexOf(i)>-1,error:i==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(i)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=Ub;let a=AT(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;etypeof e==`number`?new PT(a,e):e),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,t,n){let r=new WT(this,e,t,n);for(let i of this.wrappers)r=i(r,e,t,n);return r}getGoto(e,t,n=!1){let r=this.goto;if(t>=r[0])return-1;for(let i=r[t+1];;){let t=r[i++],a=t&1,o=r[i++];if(a&&n)return o;for(let n=i+(t>>1);i0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),r=n?t(n):void 0;for(let n=this.stateSlot(e,1);r==null;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=JT(this.data,n+2);else break}r=t(JT(this.data,n+1))}return r}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535){if(this.data[n+1]==1)n=JT(this.data,n+2);else break}if(!(this.data[n+2]&1)){let e=this.data[n+1];t.some((t,n)=>n&1&&t==e)||t.push(this.data[n],e)}}return t}configure(t){let n=Object.assign(Object.create(e.prototype),this);if(t.props&&(n.nodeSet=this.nodeSet.extend(...t.props)),t.top){let e=this.topRules[t.top];if(!e)throw RangeError(`Invalid top rule name ${t.top}`);n.top=e}return t.tokenizers&&(n.tokenizers=this.tokenizers.map(e=>{let n=t.tokenizers.find(t=>t.from==e);return n?n.to:e})),t.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((e,r)=>{let i=t.specializers.find(t=>t.from==e.external);if(!i)return e;let a=Object.assign(Object.assign({},e),{external:i.to});return n.specializers[r]=XT(a),a})),t.contextTracker&&(n.context=t.contextTracker),t.dialect&&(n.dialect=this.parseDialect(t.dialect)),t.strict!=null&&(n.strict=t.strict),t.wrap&&(n.wrappers=n.wrappers.concat(t.wrap)),t.bufferLength!=null&&(n.bufferLength=t.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 t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let r of e.split(` `)){let e=t.indexOf(r);e>=0&&(n[e]=!0)}let r=null;for(let e=0;ee)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.scoree.external(n,r)<<1|t}return e.get}var ZT=kx({String:$.string,Number:$.number,"True False":$.bool,PropertyName:$.propertyName,Null:$.null,", :":$.separator,"[ ]":$.squareBracket,"{ }":$.brace}),QT=qT.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:[ZT],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}),$T=()=>e=>{try{JSON.parse(e.state.doc.toString())}catch(t){if(!(t instanceof SyntaxError))throw t;let n=eE(t,e.state.doc);return[{from:n,message:t.message,severity:`error`,to:n}]}return[]};function eE(e,t){let n;return(n=e.message.match(/at position (\d+)/))?Math.min(+n[1],t.length):(n=e.message.match(/at line (\d+) column (\d+)/))?Math.min(t.line(+n[1]).from+ +n[2]-1,t.length):0}var tE=nS.define({name:`json`,parser:QT.configure({props:[bS.add({Object:AS({except:/^\s*\}/}),Array:AS({except:/^\s*\]/})}),jS.add({"Object Array":MS})]}),languageData:{closeBrackets:{brackets:[`[`,`{`,`"`]},indentOnInput:/^\s*[\}\]]$/}});function nE(){return new pS(tE)}var rE=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},iE=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(yE).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new ym,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;et.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=jE(s);if(i)o.add(n,n,ph.widget({widget:new wE(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,ph.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new rE(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new rE(r.from,n,r.diagnostic)}}),r}function oE(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(yE).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(lE))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function sE(e,t){return e.field(fE,!1)?t:t.concat(Jp.appendConfig.of(NE))}function cE(e,t){return{effects:sE(e,[lE.of(t)])}}var lE=Jp.define(),uE=Jp.define(),dE=Jp.define(),fE=Dp.define({create(){return new iE(ph.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=aE(n,e.selected.diagnostic,i)||aE(n,null,i)}!n.size&&i&&t.state.facet(yE).autoPanel&&(i=null),e=new iE(n,i,r)}for(let n of t.effects)if(n.is(lE)){let r=t.state.facet(yE).autoPanel?n.value.length?EE.open:null:e.panel;e=iE.init(n.value,r,t.state)}else n.is(uE)?e=new iE(e.diagnostics,n.value?EE.open:null,e.selected):n.is(dE)&&(e=new iE(e.diagnostics,e.panel,n.value));return e},provide:e=>[Vb.from(e,e=>e.panel),Yy.decorations.from(e,e=>e.diagnostics)]}),pE=ph.mark({class:`cm-lintRange cm-lintRange-active`});function mE(e,t,n){let{diagnostics:r}=e.state.field(fE),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(tCE(e,t,!1)))}var gE=e=>{let t=e.state.field(fE,!1);return!t||!t.panel?!1:(e.dispatch({effects:uE.of(!1)}),!0)},_E=zg.fromClass(class{constructor(e){this.view=e,this.timeout=-1,this.set=!0;let{delay:t}=e.state.facet(yE);this.lintTime=Date.now()+t,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,t)}run(){clearTimeout(this.timeout);let e=Date.now();if(ePromise.resolve(e(this.view))),t=>{this.view.state.doc==e.doc&&this.view.dispatch(cE(this.view.state,t.reduce((e,t)=>e.concat(t))))},e=>{Fg(this.view.state,e)})}}update(e){let t=e.state.facet(yE);(e.docChanged||t!=e.startState.facet(yE)||t.needsRefresh&&t.needsRefresh(e))&&(this.lintTime=Date.now()+t.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,t.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function vE(e,t,n){let r=[],i=-1;for(let a of e)a.then(n=>{r.push(n),clearTimeout(i),r.length==e.length?t(r):i=setTimeout(()=>t(r),200)},n)}var yE=X.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...um(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:bE,tooltipFilter:bE,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function bE(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function xE(e,t={}){return[yE.of({source:e,config:t}),_E,NE]}function SE(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;ee.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function CE(e,t,n){let r=n?SE(t.actions):[];return Km(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},Km(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=aE(e.state.field(fE).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),Km(`u`,s.slice(c,c+1)),s.slice(c+1)];return Km(`button`,{type:`button`,class:`cm-diagnosticAction`+(n.markClass?` `+n.markClass:``),onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&Km(`div`,{class:`cm-diagnosticSource`},t.source))}var wE=class extends dh{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Km(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},TE=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=CE(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},EE=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)gE(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=SE(n.actions);for(let i=0;i{for(let t=0;tgE(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(fE).selected;if(!e)return-1;for(let t=0;t{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;tn&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.topt.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=aE(this.view.state.field(fE).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:dE.of(t)})}static open(t){return new e(t)}};function DE(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,${encodeURIComponent(e)}')`}function OE(e){return DE(``,`width="6" height="3"`)}var kE=Yy.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:OE(`#f11`)},".cm-lintRange-warning":{backgroundImage:OE(`orange`)},".cm-lintRange-info":{backgroundImage:OE(`#999`)},".cm-lintRange-hint":{backgroundImage:OE(`#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 AE(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function jE(e){let t=`hint`,n=1;for(let r of e){let e=AE(r.severity);e>n&&(n=e,t=r.severity)}return t}var ME=Fb(mE,{hideOn:oE}),NE=[fE,Yy.decorations.compute([fE],e=>{let{selected:t,panel:n}=e.field(fE);return!t||!n||t.from==t.to?ph.none:ph.set([pE.range(t.from,t.to)])}),ME,kE],PE=524288;function FE(e,t){if(e.length<=t)return e;let n=e.lastIndexOf(` -`,t);return n>t*.5?e.slice(0,n):e.slice(0,t)}var IE=e=>e.state.doc.length>524288?[]:$T()(e);function LE(e){return NS.define([{tag:$.propertyName,color:e?`#7dd3fc`:`#0369a1`},{tag:$.string,color:e?`#86efac`:`#15803d`},{tag:$.number,color:e?`#fcd34d`:`#b45309`},{tag:$.bool,color:e?`#d8b4fe`:`#7e22ce`},{tag:$.null,color:e?`#a1a1aa`:`#71717a`}])}var RE=Yy.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 zE({value:e,onChange:t,editable:n,lintJson:r=!0,dark:i,placeholder:a,testId:o=`json-editor`,className:s,onReady:c}){let l=(0,g.useRef)(null),u=(0,g.useRef)(null),d=(0,g.useRef)(t);d.current=t;let f=(0,g.useRef)(i),p=(0,g.useRef)(null),m=(0,g.useRef)(null),h=(0,g.useRef)(null),_=n??t!==void 0,v=(0,g.useRef)(_),y=(0,g.useRef)(r),b=e.length>PE,x=(0,g.useRef)(b),S=!_&&e.length>2e6,C=S?FE(e,PE):e,w=(0,g.useRef)(!1),T=(0,g.useCallback)((e,t,n)=>e?[Yy.updateListener.of(e=>{e.docChanged&&!w.current&&d.current?.(e.state.doc.toString())}),...t||!n?[]:[xE(IE,{delay:300})]]:[lm.readOnly.of(!0),Yy.editable.of(!1)],[]);return(0,g.useEffect)(()=>{let e=l.current;if(!e)return;let t=new Mp,n=new Mp,o=new Mp,s=new Yy({state:lm.create({doc:C,extensions:[o.of(b||!r?[]:nE()),Yy.lineWrapping,_C(),ib.of([...wT,...IC,TT]),RE,t.of(LS(LE(i))),n.of(T(_,b,r)),...a?[hb(a)]:[]]}),parent:e});return p.current=t,m.current=n,h.current=o,c?.(s),u.current=s,()=>{s.destroy(),u.current=null}},[]),(0,g.useEffect)(()=>{let e=u.current;if(!e)return;let t=h.current,n=m.current,i=[];(b!==x.current||r!==y.current)&&(x.current=b,y.current=r,t&&i.push(t.reconfigure(b||!r?[]:nE())),n&&i.push(n.reconfigure(T(_,b,r))));let a=e.state.doc.toString();if(a!==C||i.length!==0){w.current=!0;try{e.dispatch({...a===C?{}:{changes:{from:0,to:e.state.doc.length,insert:C}},...i.length>0?{effects:i}:{}})}finally{w.current=!1}}},[C,b,r,_,T]),(0,g.useEffect)(()=>{let e=u.current,t=m.current;e&&t&&_!==v.current&&(v.current=_,e.dispatch({effects:t.reconfigure(T(_,b,r))}))},[_,b,r,T]),(0,g.useEffect)(()=>{let e=u.current;if(!e||i===f.current)return;f.current=i;let t=p.current;t&&e.dispatch({effects:t.reconfigure(LS(LE(i)))})},[i]),(0,V.jsxs)(`div`,{"data-testid":o,className:wt(`flex min-h-0 flex-1 flex-col overflow-hidden font-mono`,s),children:[S?(0,V.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,(0,V.jsx)(`div`,{ref:l,className:`min-h-0 flex-1 overflow-hidden px-5 py-4`})]})}function BE({title:e,meta:t,actions:n,status:r,children:i}){return(0,V.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 lg:gap-3`,children:[(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[0.18em] text-muted-foreground`,children:e}),t?(0,V.jsx)(`span`,{"data-testid":`pane-meta`,className:`text-xs tabular-nums text-muted-foreground/70`,children:t}):null]}),(0,V.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-0.5 max-md:gap-1`,children:n})]}),(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:i}),r?(0,V.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]})}var VE=`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`,HE=o(((e,t,n)=>{(function(){var n=[`,`,`;`,` `],r=!0,i={",":`comma`,";":`semicolon`," ":`tab`,"|":`pipe`};function a(e){var t={},r;return n.forEach(function(n,i){var a=new RegExp(n,`g`);t[n]=(e.match(a)||[]).length,r=!r||t[n]>t[r]?n:r}),r}function o(e){for(var t={},n=0;n=0;n--){var r=e[n];t[r]>0&&(r=r+`__`+t[r]--),i.unshift(r)}return i}function s(e,t){if(t||={},e.length==0)throw`Empty CSV. Please provide something.`;var n=t.separator||a(e);if(!n)throw`We could not detect the separator.`;var s=[];try{r=t.trim!==!1;var s=c.parse(e,i[n])}catch(t){var l=e.lastIndexOf(` -`,t.offset),u=e.indexOf(` -`,t.offset),d=e.substring(l>=-1?l:0,u>-1?u:e.length);throw t.message+` On line `+t.line+` and column `+t.column+`. -`+d}if(t.transpose){for(var f=0,p=0;pf&&(f=s[p].length);for(var m=Array(f),h=0;hs&&(s=a,c=[]),c.push(e))}function u(){var e,t,n=a,r=a;return e=(function(e){return b=`,`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function d(){var e,t,n=a,r=a;return e=(function(e){return b=`;`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function f(){var e,t,n=a,r=a;return e=(function(e){return b=`|`})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function p(){var e,t,n=a,r=a;return e=(function(e){return b=` `})(a)?``:null,e===null?(e=null,a=r):(t=m(),t===null?(e=null,a=r):e=[e,t]),e!==null&&(e=(function(e,t){return t})(n,e[1])),e===null&&(a=n),e}function m(){var e,n,r,i,s,c=a,u=a,d,f;for(e=[],/^[\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[\\n\\r]`));n!==null;)e.push(n),/^[\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[\\n\\r]`));if(e!==null){if(n=h(),n!==null){if(r=[],d=a,f=a,/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`)),s!==null)for(i=[];s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));else i=null;for(i===null?(i=null,a=f):(s=h(),s===null?(i=null,a=f):i=[i,s]),i!==null&&(i=(function(e,t){return t})(d,i[1])),i===null&&(a=d);i!==null;){if(r.push(i),d=a,f=a,/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`)),s!==null)for(i=[];s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));else i=null;i===null?(i=null,a=f):(s=h(),s===null?(i=null,a=f):i=[i,s]),i!==null&&(i=(function(e,t){return t})(d,i[1])),i===null&&(a=d)}if(r!==null){for(i=[],/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));s!==null;)i.push(s),/^[\n\r]/.test(t.charAt(a))?(s=t.charAt(a),a++):(s=null,o===0&&l(`[\\n\\r]`));i===null?(e=null,a=u):e=[e,n,r,i]}else e=null,a=u}else e=null,a=u}else e=null,a=u;return e!==null&&(e=(function(e,t,n){return n.unshift(t),n})(c,e[1],e[2])),e===null&&(a=c),e}function h(){var e,n,r,i,s,c=a,u=a,d,f;if(e=g(),e!==null){for(n=[],d=a,f=a,t.length>a?(r=t.charAt(a),a++):(r=null,o===0&&l(`any character`)),r===null?(r=null,a=f):(i=(function(e,t){return t==b})(a,r)?``:null,i===null?(r=null,a=f):(s=g(),s===null?(r=null,a=f):r=[r,i,s])),r!==null&&(r=(function(e,t,n){return n})(d,r[0],r[2])),r===null&&(a=d);r!==null;)n.push(r),d=a,f=a,t.length>a?(r=t.charAt(a),a++):(r=null,o===0&&l(`any character`)),r===null?(r=null,a=f):(i=(function(e,t){return t==b})(a,r)?``:null,i===null?(r=null,a=f):(s=g(),s===null?(r=null,a=f):r=[r,i,s])),r!==null&&(r=(function(e,t,n){return n})(d,r[0],r[2])),r===null&&(a=d);n===null?(e=null,a=u):(r=(function(e,t,n){return!!t||n.length})(a,e,n)?``:null,r===null?(e=null,a=u):e=[e,n,r])}else e=null,a=u;return e!==null&&(e=(function(e,t,n){return n.unshift(t),n})(c,e[0],e[1])),e===null&&(a=c),e}function g(){var e,n,i,s=a,c=a,u;if(t.charCodeAt(a)===34?(e=`"`,a++):(e=null,o===0&&l(`"\\""`)),e!==null){for(n=[],i=_();i!==null;)n.push(i),i=_();n===null?(e=null,a=c):(t.charCodeAt(a)===34?(i=`"`,a++):(i=null,o===0&&l(`"\\""`)),i===null?(e=null,a=c):e=[e,n,i])}else e=null,a=c;if(e!==null&&(e=(function(e,t){return t.join(``)})(s,e[1])),e===null&&(a=s),e===null){for(s=a,e=[],c=a,u=a,/^[^\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[^\\n\\r]`)),n===null?(n=null,a=u):(i=(function(e,t){return t!=b})(a,n)?``:null,i===null?(n=null,a=u):n=[n,i]),n!==null&&(n=(function(e,t){return t})(c,n[0])),n===null&&(a=c);n!==null;)e.push(n),c=a,u=a,/^[^\n\r]/.test(t.charAt(a))?(n=t.charAt(a),a++):(n=null,o===0&&l(`[^\\n\\r]`)),n===null?(n=null,a=u):(i=(function(e,t){return t!=b})(a,n)?``:null,i===null?(n=null,a=u):n=[n,i]),n!==null&&(n=(function(e,t){return t})(c,n[0])),n===null&&(a=c);e!==null&&(e=(function(e,t){return(r?t.join(``).trim():t.join(``)).replace(/(^")|("$)/g,``)})(s,e)),e===null&&(a=s)}return e}function _(){var e,n,r=a,i=a;return t.charCodeAt(a)===34?(e=`"`,a++):(e=null,o===0&&l(`"\\""`)),e===null?(e=null,a=i):(t.charCodeAt(a)===34?(n=`"`,a++):(n=null,o===0&&l(`"\\""`)),n===null?(e=null,a=i):e=[e,n]),e!==null&&(e=(function(e){return`"`})(r)),e===null&&(a=r),e===null&&(/^[^"]/.test(t.charAt(a))?(e=t.charAt(a),a++):(e=null,o===0&&l(`[^"]`))),e}function v(e){e.sort();for(var t=null,n=[],r=0;r{(function(){var n=`Item in array is not an object: {0}`;function r(e,t){t||=[];function o(e,t){var n=e.slice(0);if(!Array.isArray(t))return n;for(var r=0;r=2)try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1}}return{ok:!1}}function eD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function tD(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function nD(e){let t=(e,r,i)=>{for(let[a,o]of Object.entries(e)){let e=r?`${r}.${a}`:a;eD(o)&&Object.keys(o).length>0?t(o,e,i):i[e]=Array.isArray(o)?o.map(n):o}},n=e=>{if(!eD(e))return e;let n={};return t(e,``,n),n};return Array.isArray(e)?e.map(n):eD(e)?n(e):e}function rD(e){let t=e=>{if(!eD(e))return e;let n={};for(let[r,i]of Object.entries(e))n[r]=Array.isArray(i)&&i.length>0&&i.every(tD)?i.join(`, `):Array.isArray(i)?i.map(t):i;return n};return Array.isArray(e)?e.map(t):eD(e)?t(e):e}function iD(e){let t=e.trim().toLowerCase();return t===`true`||t===`1`||t===`yes`?!0:t===`false`||t===`0`||t===`no`?!1:e}function aD(e,t,n){if(n===`string`)return e;if(n===`number`)return QE(e);if(n===`boolean`)return iD(e);if(t.parseJSON){let t=$E(e);if(t.ok&&typeof t.value!=`number`)return t.value}return t.parseNumbers?QE(e):e}function oD(e,t){let n=e=>{let n={};for(let r of Object.keys(e)){let i=e[r];if(typeof i!=`string`){n[r]=i;continue}if(t.emptyFields===`skip`&&i===``)continue;if(t.nullLiterals===`null`&&i===`NULL`){n[r]=null;continue}let a=t.columnTypes?.[r];n[r]=aD(i,t,a)}return n};if(Array.isArray(e))return e.map(e=>eD(e)?n(e):e);let r={};for(let[t,i]of Object.entries(e))r[t]=eD(i)?n(i):i;return r}var sD=/^([^.[\]]+)(?:\.(0|[1-9]\d*)|\[(0|[1-9]\d*)\])(?:\.(.+))?$/;function cD(e){let t=sD.exec(e);if(!t)return null;let n=t[1],r=t[2],i=t[3],a=t[4],o=Number(r??i);return Number.isSafeInteger(o)?{column:e,prefix:n,index:o,notation:r===void 0?`bracket`:`dot`,...a===void 0?{}:{subKey:a}}:null}function lD(e){let t=new Set(e),n=new Map;for(let t of e){let e=cD(t);if(!e)continue;let r=n.get(e.prefix);r?r.push(e):n.set(e.prefix,[e])}let r=[];for(let[e,i]of n.entries()){if(t.has(e))continue;let n=i[0].subKey!==void 0,a=i[0].notation;if(i.some(e=>e.subKey!==void 0!==n||e.notation!==a))continue;let o=new Set,s=!1;for(let e of i){let t=`${e.index}:${e.subKey??``}`;if(o.has(t)){s=!0;break}o.add(t)}if(s)continue;let c=Array.from(new Set(i.map(e=>e.index))).sort((e,t)=>e-t);if(c.length<2)continue;let l=c[0];(l===0||l===1)&&c.every((e,t)=>e===l+t)&&r.push({prefix:e,indices:c,columns:i.map(e=>e.column)})}return r}function uD(e,t){return e===void 0||e===``||t===`skip`&&e===null}function dD(e,t,n,r){let i=new Map,a=new Set,o=new Map;for(let e of n)if(e.columns.length!==0){i.set(e.columns[0],e);for(let t of e.columns)a.add(t);o.set(e.prefix,e.columns.map(e=>cD(e)).filter(e=>e!==null))}let s={};for(let n of t){let t=i.get(n);if(t){let n=o.get(t.prefix)??[];if(n.some(e=>e.subKey!==void 0)){let i=new Map;for(let e of n){let t=i.get(e.index);t?t.push(e):i.set(e.index,[e])}let a=[];for(let n of t.indices){let t=i.get(n)??[],o={};for(let n of t){if(!n.subKey)continue;let t=e[n.column];uD(t,r)||(o[n.subKey]=t)}Object.keys(o).length>0&&a.push(o)}if(a.length===0&&r===`skip`)continue;s[t.prefix]=a}else{let i=new Map;for(let e of n)i.set(e.index,e.column);let a=[];for(let n of t.indices){let t=i.get(n);if(!t)continue;let o=e[t];uD(o,r)||a.push(o)}if(a.length===0&&r===`skip`)continue;s[t.prefix]=a}}else a.has(n)||Object.prototype.hasOwnProperty.call(e,n)&&(s[n]=e[n])}return s}function fD(e,t,n){if(Array.isArray(e)&&Array.isArray(t)){let r=e[0];if(!eD(r))return t;let i=Object.keys(r),a=lD(i);return a.length===0?t:t.map(e=>eD(e)?dD(e,i,a,n):e)}if(!Array.isArray(e)&&!Array.isArray(t)){let r=Object.values(e)[0];if(!eD(r))return t;let i=Object.keys(r),a=lD(i);if(a.length===0)return t;let o={};for(let[e,r]of Object.entries(t))o[e]=eD(r)?dD(r,i,a,n):r;return o}return t}function pD(e,t={}){let n={parseNumbers:t.parseNumbers??!0,parseJSON:t.parseJSON??!1,emptyFields:t.emptyFields??`keep`,nullLiterals:t.nullLiterals??`string`,columnTypes:t.columnTypes},r=e.startsWith(XE)?e.slice(1):e,i=t.separator===void 0?jd(r,t.markdownTableIndex??0):null,a=i?i.cleanedCsv:r;try{let e=(0,WE.default)(a,{...t,parseNumbers:!1,parseJSON:!1,trim:!1}),r=oD(e,n);return t.collapseIndexedArrays!==!1&&!t.transpose?fD(e,r,n.emptyFields):r}catch(e){throw Error(YE(e),{cause:e})}}function mD(e,t={}){try{let n=t.flatten?rD(nD(e)):e;return(0,GE.default)(n,t)}catch(e){let n=YE(e);throw JE.some(e=>n.startsWith(e))?new KE(qE(n,t.flatten??!1)):Error(n,{cause:e})}}function hD(e,t={}){return JSON.stringify(e,null,t.minify?void 0:2)}var gD={separator:`auto`,parseNumbers:!0,parseJSON:!0,emptyFields:`keep`,nullLiterals:`string`,transpose:!1,hash:!1,minify:!1,flatten:!1,collapseIndexedArrays:!0},_D=[`data`,`items`,`results`,`records`,`rows`];function vD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yD(e){let t=e.trim();if(t===``||!t.startsWith(`{`))return[];let n;try{n=JSON.parse(t)}catch{return[]}if(!vD(n))return[];let r=Object.keys(n),i=new Set(_D),a=[..._D.filter(e=>r.includes(e)),...r.filter(e=>!i.has(e))],o=[];for(let e of a){let t=n[e];Array.isArray(t)&&t.length>0&&t.every(e=>vD(e))&&o.push({key:e,rowCount:t.length,unwrappedJson:JSON.stringify(t,null,2)})}return o}function bD(e){let t=e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0);if(t.length<2)return null;let n=[];for(let e of t)try{let t=JSON.parse(e);if(typeof t!=`object`||!t)return null;n.push(t)}catch{return null}return n}function xD(e){let t=e.trim();if(t===``)return null;let n;try{n=JSON.parse(t)}catch{let e=bD(t);if(e===null)return null;n=e}let r=JSON.stringify(n,null,2);return t===r?{label:`Minify`,nextInput:JSON.stringify(n)}:{label:`Format`,nextInput:r}}function SD(e){let t=e.trim();if(t===``)return[];let n;try{n=JSON.parse(t)}catch{let e=bD(t);if(e===null)return[];n=e}let r;if(Array.isArray(n)){if(n.length===0||!n.every(e=>vD(e)))return[];r=n}else if(vD(n)){if(yD(t).length>0)return[];r=[n]}else return[];let i=new Set,a=r.slice(0,50);for(let e of a)for(let[t,n]of Object.entries(e))(vD(n)||Array.isArray(n)&&n.length>0)&&i.add(t);return Array.from(i)}function CD(e){let t=e=>{let t=new Set;for(let n of e)n&&typeof n==`object`&&!Array.isArray(n)&&Object.keys(n).forEach(e=>t.add(e));return t};if(Array.isArray(e))return{rows:e.length,cols:t(e).size};if(e&&typeof e==`object`){let n=Object.values(e);return{rows:n.length,cols:t(n).size}}return{rows:0,cols:0}}var wD=e=>e===`auto`?void 0:e;function TD(e){let t=!1,n=1;for(let r=0;r0;return i.rowWidths.forEach((e,t)=>{if(a&&t===i.rowWidths.length-1)return;let r=i.rows[t];(e!==1||r[0]!==``)&&e!==i.headers.length&&n.push(e0?{warnings:o}:{}}}let r;try{r=JSON.parse(t)}catch(e){let n=bD(t);if(n!==null)r=n;else return{ok:!1,error:`Invalid JSON — ${e instanceof Error?e.message:String(e)}`}}let i=wD(n.separator),a=mD(r,{separator:i,flatten:n.flatten}),o=Fd(a,i);return{ok:!0,text:a,rows:o.rows.length,cols:o.headers.length}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}function kD(){return(0,V.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:(0,V.jsx)(`path`,{d:`M21 12a9 9 0 1 1-6.2-8.56`,strokeLinecap:`round`})})}function AD({label:e,testId:t,onClick:n,disabled:r,Icon:i,keepLabelOnMobile:a=!1}){return(0,V.jsxs)(`button`,{type:`button`,"data-testid":t,"aria-label":e,disabled:r,onClick:n,title:e,className:VE,children:[i?(0,V.jsx)(i,{"aria-hidden":`true`}):null,i&&!a?(0,V.jsx)(`span`,{className:`hidden xl:inline`,children:e}):e]})}function jD(e){let t=Math.min(e.length,65536),n=!1,r=0;for(let i=0;i=3))return e.slice(0,i+1)}return e.slice(0,t)}function MD(e){let t=e.slice(0,3).map(e=>`.${e}`).join(`, `),n=e.length-3;return n>0?`${t}, +${n} more`:t}function ND({format:e,input:t,onInputChange:n,onFile:r,onTryExample:i,onClear:a,onCopy:o,onCopySelection:s,onDownload:c,filename:l,reading:u,meta:d,error:f,notice:p,dark:m,delimiter:h,onCellCommit:_,canUndo:v=!1,canRedo:y=!1,onUndo:b,onRedo:x,onProjectedCsvChange:S,collapseIndexedArrays:C=!0,onToggleCollapseIndexedArrays:w,columnTypes:T,onChangeColumnTypes:E,flatten:D=!1,onToggleFlatten:O,selectedMarkdownTableIndex:k,onSelectMarkdownTableIndex:A}){let[ee,te]=(0,g.useState)(!1),[ne,re]=(0,g.useState)(!1),[j,ie]=(0,g.useState)({forInput:``,index:0}),M=(0,g.useRef)(0),ae=(0,g.useRef)(null),N=t.trim()===``,oe=e===`CSV`,P=(0,g.useMemo)(()=>!oe||N||h!==void 0?[]:Ad(t),[oe,N,t,h]),se=k===void 0?j.forInput===t?j.index:0:k,ce=P.length===0?0:Math.min(Math.max(0,se),P.length-1),F=P[ce]??null,le=e=>{ie({forInput:t,index:e}),A?.(e)},de=(0,g.useMemo)(()=>!oe||N?[]:lD(Fd(jD(F?F.cleanedCsv:t),h).headers.map(e=>e.trim())),[oe,N,t,h,F]),fe=(0,g.useMemo)(()=>oe||N?[]:yD(t),[oe,N,t]),pe=(0,g.useMemo)(()=>oe||N?[]:SD(t),[oe,N,t]),me=(0,g.useMemo)(()=>oe||N?null:xD(t),[oe,N,t]),L=e=>{e.preventDefault(),Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(M.current++,re(!0))},R=()=>{M.current=Math.max(0,M.current-1),M.current===0&&re(!1)},ve=e=>{e.preventDefault(),M.current=0,re(!1);let t=e.dataTransfer?.files?.[0];t&&r(t,`drop`)},ye=e=>{if(!N||e.defaultPrevented||e.target instanceof HTMLTextAreaElement||e.target instanceof HTMLInputElement)return;let t=e.clipboardData?.getData(`text/plain`);t&&(e.preventDefault(),n(t))},be=oe?(0,V.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:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`view-table`,"aria-pressed":!ee,onClick:()=>te(!1),className:wt(`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`,ee?`text-muted-foreground hover:text-foreground`:`bg-background text-foreground shadow-sm`),children:[(0,V.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5 md:hidden lg:inline`}),`Table`]}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`raw-toggle`,"aria-pressed":ee,onClick:()=>te(!0),className:wt(`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`,ee?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:[(0,V.jsx)(ue,{"aria-hidden":`true`,className:`size-3.5 md:hidden lg:inline`}),`Raw`]})]}):null,xe=u&&l?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,V.jsx)(kD,{}),` `,l]}):l?d?`${l} · ${d}`:l:d;return(0,V.jsx)(`div`,{"data-testid":`input-pane`,onDragEnter:L,onDragOver:e=>e.preventDefault(),onDragLeave:R,onDrop:ve,onPaste:ye,"data-drag-over":ne||void 0,className:`relative flex min-h-0 min-w-0 flex-1 flex-col`,children:(0,V.jsxs)(BE,{title:e,meta:xe,actions:(0,V.jsxs)(V.Fragment,{children:[be,oe&&(v||y)?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`button`,{type:`button`,"data-testid":`csv-undo-button`,"aria-label":`Undo`,title:`Undo`,disabled:!v,onClick:()=>b?.(),className:VE,children:(0,V.jsx)(B,{"aria-hidden":`true`})}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`csv-redo-button`,"aria-label":`Redo`,title:`Redo`,disabled:!y,onClick:()=>x?.(),className:VE,children:(0,V.jsx)(_e,{"aria-hidden":`true`})})]}):null,me?(0,V.jsx)(AD,{label:me.label,testId:`json-format-toggle`,onClick:()=>n(me.nextInput),Icon:ue,keepLabelOnMobile:!0}):null,(0,V.jsx)(`input`,{ref:ae,type:`file`,"data-testid":`file-input`,accept:oe?`.csv,.tsv,.txt,.md,text/csv,text/tab-separated-values,text/markdown`:`.json,.jsonl,.ndjson,.txt,application/json,application/x-ndjson`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&r(t,`picker`),e.target.value=``}}),(0,V.jsx)(AD,{label:`Upload`,testId:`upload`,onClick:()=>ae.current?.click(),Icon:I}),(0,V.jsx)(AD,{label:`Copy`,testId:`copy-input`,onClick:o,Icon:he}),(0,V.jsx)(AD,{label:`Clear`,testId:`clear-input`,onClick:a,disabled:N,Icon:we}),(0,V.jsx)(AD,{label:`Download`,testId:`download-input`,onClick:c,disabled:N,Icon:ge})]}),status:f?{kind:`error`,message:f}:p?{kind:`notice`,message:p}:null,children:[N?(0,V.jsx)(Nf,{format:e,onIngest:n,onBrowse:()=>ae.current?.click(),onTryExample:i}):oe?(0,V.jsxs)(V.Fragment,{children:[F?(0,V.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:[P.length>=2?(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`${P.length} tables detected:`}),P.map(e=>{let t=e.index===ce,n=e.title??e.headers.slice(0,2).join(`, `);return(0,V.jsx)(`button`,{type:`button`,"data-testid":`csv-markdown-table-select-${e.index}`,"aria-pressed":t,onClick:()=>le(e.index),className:wt(`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`,t?`border-foreground/30 bg-background text-foreground ring-1 ring-foreground/15`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:`${e.index+1}. ${n} (${e.rows}×${e.cols})`},e.index)})]}):(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:F.kind===`box`?`ASCII CLI box table detected:`:`Markdown pipe table detected:`}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`csv-clean-markdown-pill`,onClick:()=>n(F.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:P.length>=2?`Use only this table (${F.rows} ${F.rows===1?`row`:`rows`})`:F.kind===`box`?`Clean CLI table (${F.rows} ${F.rows===1?`row`:`rows`})`:`Clean Markdown table (${F.rows} ${F.rows===1?`row`:`rows`})`})]}):null,de.length>0?(0,V.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:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Indexed columns (${de.map(e=>`${e.prefix}[${e.indices.length}]`).join(`, `)}):`}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`csv-indexed-array-pill`,"aria-pressed":C,onClick:()=>w?.(),className:wt(`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`,C?`border-border bg-background text-foreground hover:bg-muted`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:C?`Arrays: .0, .1 → []`:`Keep flat keys (.0, .1)`})]}):null,ee?(0,V.jsx)(`textarea`,{"data-testid":`input-editor`,value:t,onChange:e=>n(e.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`}):(0,V.jsx)(Df,{text:F?F.cleanedCsv:t,delimiter:h,testId:`input-table`,dark:m,onCellCommit:_,onUndo:b,onRedo:x,onCopySelection:s,columnTypes:T,onChangeColumnTypes:E,onProjectedCsvChange:S})]}):(0,V.jsxs)(V.Fragment,{children:[fe.length>0?(0,V.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:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Nested array detected:`}),fe.map(e=>(0,V.jsx)(`button`,{type:`button`,"data-testid":`json-unwrap-pill-${e.key}`,onClick:()=>n(e.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 .${e.key} (${e.rowCount} ${e.rowCount===1?`row`:`rows`})`},e.key))]}):null,pe.length>0?(0,V.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:[(0,V.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Nested keys (${pe.length}):`}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`json-flatten-pill`,"aria-pressed":D,onClick:()=>O?.(),className:wt(`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`,D?`border-border bg-background text-foreground hover:bg-muted`:`border-border bg-muted/60 text-muted-foreground hover:bg-muted hover:text-foreground`),children:`${D?`Flattened`:`Flatten`} nested keys (${MD(pe)})`})]}):null,(0,V.jsx)(zE,{value:t,onChange:n,dark:m,testId:`input-editor`})]}),ne?(0,V.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:(0,V.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Drop file to import`})}):null]})})}var PD=/\.(csv|tsv|txt|json|jsonl|ndjson|md|log)$/i;function FD(e){return e.type.startsWith(`text/`)||e.type===`application/json`?!0:PD.test(e.name)}var ID=[{value:`utf-8`,label:`UTF-8`},{value:`windows-1252`,label:`Windows-1252`}];async function LD(e,t){let n=e.stream().getReader(),r=``;try{let e=[],i=0;for(;i<2;){let{done:t,value:r}=await n.read();if(t)break;r&&r.byteLength>0&&(e.push(r),i+=r.byteLength)}let a=null;if(e.length===1)a=e[0];else if(e.length>1){a=new Uint8Array(i);let t=0;for(let n of e)a.set(n,t),t+=n.byteLength}let o=t;t===`utf-8`&&a&&a.byteLength>=2&&(a[0]===255&&a[1]===254?o=`utf-16le`:a[0]===254&&a[1]===255&&(o=`utf-16be`));let s=new TextDecoder(o,{fatal:!1});for(a&&(r+=s.decode(a,{stream:!0}));;){let{done:e,value:t}=await n.read();if(e)break;r+=s.decode(t,{stream:!0})}return r+s.decode()}finally{n.releaseLock()}}function RD(e){let t=typeof window<`u`&&typeof window.matchMedia==`function`,n=(0,g.useCallback)(n=>{if(!t)return()=>{};let r=window.matchMedia(e);return r.addEventListener(`change`,n),()=>r.removeEventListener(`change`,n)},[e,t]),r=(0,g.useCallback)(()=>t?window.matchMedia(e).matches:!1,[e,t]);return(0,g.useSyncExternalStore)(n,r,()=>!1)}var zD=[{value:`auto`,label:`Auto-detect`},{value:`,`,label:`Comma`},{value:`;`,label:`Semicolon`},{value:` `,label:`Tab`},{value:`|`,label:`Pipe`}];function BD(){return(0,V.jsx)(`div`,{className:`hidden h-5 w-px shrink-0 bg-border fit:block`,"aria-hidden":`true`})}function VD(e,t){let n=[t.separator===`auto`?`Auto`:zD.find(e=>e.value===t.separator)?.label??`Auto`];return e===`csv2json`?(t.parseNumbers&&n.push(`Parse numbers`),t.parseJSON&&n.push(`Parse JSON`),t.emptyFields===`skip`&&n.push(`Skip empty`),t.nullLiterals===`null`&&n.push(`NULL→null`),t.transpose&&n.push(`Transpose`),t.hash&&n.push(`Hash`),t.minify&&n.push(`Minify`)):t.flatten&&n.push(`Flatten`),n.join(` · `)}function HD(){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 UD(){return(0,V.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:(0,V.jsx)(`path`,{d:`m4 6 4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function WD({children:e}){return(0,V.jsx)(`span`,{className:`font-mono text-[11px] font-semibold tracking-[0.14em] whitespace-nowrap text-muted-foreground/70 uppercase`,children:e})}function GD({label:e,checked:t,onChange:n,hint:r}){return(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,V.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 whitespace-nowrap text-[13px] text-muted-foreground transition-colors hover:text-foreground`,children:[(0,V.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":t,"aria-label":e,onClick:()=>n(!t),className:`flex h-6 shrink-0 cursor-pointer items-center rounded-full outline-none focus-visible:ring-3 focus-visible:ring-ring/50`,children:(0,V.jsx)(`span`,{className:wt(`relative inline-flex h-[18px] w-8 items-center rounded-full border transition-colors`,t?`border-primary bg-primary`:`border-border bg-muted`),children:(0,V.jsx)(`span`,{className:wt(`pointer-events-none inline-block size-3 rounded-full bg-background shadow-sm transition-transform`,t?`translate-x-[15px]`:`translate-x-[2px]`)})})}),(0,V.jsx)(`span`,{className:`select-none`,children:e})]}),r?(0,V.jsx)(KD,{text:r}):null]})}function KD({text:e}){let t=(0,g.useId)(),[n,r]=(0,g.useState)(!1);return(0,V.jsxs)(`span`,{className:`relative inline-flex items-center`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`What does this option do?`,"aria-expanded":n,"aria-describedby":t,title:`What does this option do?`,onClick:()=>r(e=>!e),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`}),(0,V.jsx)(`span`,{"data-hint":!0,id:t,hidden:!n,className:`ml-1 text-muted-foreground`,children:e})]})}function qD({direction:e,options:t,onChange:n,notice:r,uploadEncoding:i,onUploadEncodingChange:a}){let[o,s]=(0,g.useState)(!1),c=(0,g.useRef)(null),l=(0,g.useRef)(null),u=RD(`(min-width: 98.5rem)`),d=e===`csv2json`,f=VD(e,t),p=(0,g.useCallback)(()=>{s(!1),c.current?.focus()},[]);(0,g.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&p()},t=e=>{let t=l.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||p())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[o,p]);let m=(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(WD,{children:`Separator`}),(0,V.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,V.jsx)(`select`,{"data-testid":`opt-separator`,value:t.separator,onChange:e=>n({separator:e.target.value}),className:HD(),children:zD.map(e=>(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,V.jsx)(UD,{})]})]}),(0,V.jsx)(KD,{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&&a?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(BD,{}),(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,V.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(WD,{children:`Encoding`}),(0,V.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,V.jsx)(`select`,{"data-testid":`opt-encoding`,value:i,onChange:e=>a(e.target.value),className:HD(),children:ID.map(e=>(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,V.jsx)(UD,{})]})]}),(0,V.jsx)(KD,{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,(0,V.jsx)(BD,{}),d?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(GD,{label:`Parse numbers`,checked:t.parseNumbers,onChange:e=>n({parseNumbers:e}),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.`}),(0,V.jsx)(GD,{label:`Parse JSON`,checked:t.parseJSON,onChange:e=>n({parseJSON:e}),hint:`Turns null, true, false, [] and {} into real JSON values instead of strings.`}),(0,V.jsx)(GD,{label:`Skip empty fields`,checked:t.emptyFields===`skip`,onChange:e=>n({emptyFields:e?`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.`}),(0,V.jsx)(GD,{label:`NULL as null`,checked:t.nullLiterals===`null`,onChange:e=>n({nullLiterals:e?`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.`}),(0,V.jsx)(GD,{label:`Transpose`,checked:t.transpose,onChange:e=>n({transpose:e}),hint:`Flip rows and columns — the first column becomes the header row.`}),(0,V.jsx)(GD,{label:`Hash output`,checked:t.hash,onChange:e=>n({hash:e}),hint:`The first column becomes the object key instead of a field.`}),(0,V.jsx)(GD,{label:`Minify`,checked:t.minify,onChange:e=>n({minify:e}),hint:`Remove indentation from the JSON output. Data is untouched.`})]}):(0,V.jsx)(GD,{label:`Flatten nested arrays`,checked:t.flatten,onChange:e=>n({flatten:e}),hint:`Explode nested arrays into extra rows with dotted keys — needed when the JSON isn't a flat table.`})]});return u?(0,V.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:(0,V.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:[m,r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`flex-1`}),(0,V.jsx)(`span`,{"data-testid":`options-notice`,children:r})]}):null]})}):(0,V.jsxs)(`div`,{"data-testid":`options-row`,ref:l,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:[(0,V.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,ref:c,"data-testid":`options-settings-toggle`,"aria-expanded":o,"aria-haspopup":`true`,onClick:()=>o?p():s(!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`,(0,V.jsx)(de,{"aria-hidden":`true`,className:wt(`size-3.5 shrink-0 transition-transform`,o&&`rotate-180`)})]}),(0,V.jsx)(`span`,{"data-testid":`options-settings-summary`,className:`min-w-0 truncate`,children:f}),r?(0,V.jsx)(`span`,{"data-testid":`options-notice`,className:`ml-auto shrink-0 text-right`,children:r}):null]}),(0,V.jsx)(`div`,{"data-testid":`options-settings-menu`,role:`group`,"aria-label":`Parse settings`,hidden:!o,className:wt(`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:m})]})}var JD=[{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`}],YD=new Set([`csv`,`tsv`,`txt`,`json`,`jsonl`,`sql`,`ts`]),XD=/^[A-Za-z_$][A-Za-z0-9_$]*$/;function ZD(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function QD(e){if(Array.isArray(e))return e.map(e=>ZD(e)?e:{value:e});if(ZD(e)){let t=Object.entries(e);return t.length===0?[]:t.every(([,e])=>ZD(e))?t.map(([e,t])=>{let n=t;return`key`in n?n:{key:e,...n}}):[e]}return[]}function $D(e){let t=new Set,n=[];for(let r of e)for(let e of Object.keys(r))t.has(e)||(t.add(e),n.push(e));return n}function eO(e){if(!e)return`data`;let t=e.trim(),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));for(n>=0&&(t=t.slice(n+1));;){let e=t.lastIndexOf(`.`);if(e<=0)break;if(e===t.length-1){t=t.slice(0,e);continue}let n=t.slice(e+1).toLowerCase();if(!YD.has(n))break;t=t.slice(0,e)}let r=t.replace(/[^a-zA-Z0-9]+/g,`_`).replace(/^_+|_+$/g,``);return r.length>0?r:`data`}function tO(e){return`"${e.replace(/"/g,`""`)}"`}function nO(e){let t=e.filter(e=>e!=null);return t.length===0?`TEXT`:t.every(e=>typeof e==`boolean`)?`BOOLEAN`:t.every(e=>typeof e==`number`&&Number.isFinite(e))?t.every(e=>Number.isInteger(e))?`INTEGER`:`NUMERIC`:`TEXT`}function rO(e){return e==null?`NULL`:typeof e==`boolean`?e?`TRUE`:`FALSE`:typeof e==`number`?Number.isFinite(e)?String(e):`NULL`:typeof e==`string`?`'${e.replace(/'/g,`''`)}'`:`'${JSON.stringify(e).replace(/'/g,`''`)}'`}function iO(e){let t=e.trim();if(t===``)return``;let n;try{n=JSON.parse(t)}catch{return e}return QD(n).map(e=>JSON.stringify(e)).join(` -`)}function aO(e,t){let n=e.trim();if(n===``)return``;let r;try{r=JSON.parse(n)}catch{return e}let i=QD(r),a=$D(i),o=tO(eO(t));if(a.length===0)return`CREATE TABLE ${o} ();`;let s=`CREATE TABLE ${o} (\n${a.map(e=>{let t=nO(i.map(t=>t[e]));return` ${tO(e)} ${t}`}).join(`, -`)}\n);`;return i.length===0?s:`${s}\n\n${`INSERT INTO ${o} (${a.map(tO).join(`, `)}) VALUES\n${i.map(e=>` (${a.map(t=>rO(e[t])).join(`, `)})`).join(`, -`)};`}`}function oO(e){if(e===null)return`null`;if(typeof e==`string`)return`string`;if(typeof e==`number`)return`number`;if(typeof e==`boolean`)return`boolean`;if(Array.isArray(e)){if(e.length===0)return`unknown[]`;let t=cO(Array.from(new Set(e.map(e=>oO(e)))));return t.length===1?`${t[0]}[]`:`(${t.join(` | `)})[]`}return ZD(e)?`Record`:`unknown`}var sO={string:1,number:2,boolean:3,"Record":4,unknown:90,null:100};function cO(e){return[...e].sort((e,t)=>{let n=sO[e]??50,r=sO[t]??50;return n===r?e.localeCompare(t):n-r})}function lO(e){return XD.test(e)?e:JSON.stringify(e)}function uO(e){let t=e.trim();if(t===``)return``;let n;try{n=JSON.parse(t)}catch{return e}let r=QD(n),i=$D(r).map(e=>{let t=!1,n=new Set;for(let i of r)!Object.prototype.hasOwnProperty.call(i,e)||i[e]===void 0?t=!0:n.add(oO(i[e]));let i=cO(Array.from(n)),a=i.length>0?i.join(` | `):`unknown`,o=t?`?`:``;return` ${lO(e)}${o}: ${a};`});return`${i.length>0?`export interface DataRow {\n${i.join(` -`)}\n}`:`export interface DataRow {}`}\n\nexport const data: DataRow[] = ${JSON.stringify(r,null,2)};`}function dO(e,t,n,r){let i=typeof e==`string`?e:e.text,a=typeof n==`string`||n===null?n:r??null;switch(t){case`json`:return i;case`jsonl`:return iO(i);case`sql`:return aO(i,a);case`ts`:return uO(i)}}var fO=3;function pO(e){let t=e.slice(0,fO),n=e.length-t.length;return(n>0?[...t,`+${n} more`]:t).join(` -`)}function mO({format:e,inputEmpty:t,outputText:n,error:r,meta:i,staleNotice:a,warnings:o,edited:s,editable:c,egressFormat:l=`json`,delimiter:u,dark:d,onCopy:f,onCopySelection:p,onProjectedCsvChange:m,onNativeCopy:h,onDownload:g,onEgressFormatChange:_,onOutputChange:v,onRevert:y,onDiscardReconvert:b}){let x=e===`JSON`,S=l===`json`;return(0,V.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:(0,V.jsx)(BE,{title:e,meta:t?null:s?(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.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`}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`revert-output`,onClick:y,className:VE,children:[(0,V.jsx)(ve,{"aria-hidden":`true`}),`Revert`]})]}):a?(0,V.jsx)(`span`,{"data-testid":`stale-notice`,className:`text-xs text-amber-600 dark:text-amber-400`,children:a}):i,actions:(0,V.jsxs)(V.Fragment,{children:[x?(0,V.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:JD.map(e=>{let t=l===e.format;return(0,V.jsx)(`button`,{type:`button`,"data-testid":`output-format-option-${e.format}`,"aria-pressed":t,onClick:()=>_?.(e.format),className:wt(`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:e.label},e.format)})}):null,(0,V.jsxs)(`button`,{type:`button`,"data-testid":`copy-output`,"aria-label":`Copy`,title:`Copy`,onClick:f,disabled:!n,className:VE,children:[(0,V.jsx)(he,{"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`hidden xl:inline`,children:`Copy`})]}),(0,V.jsxs)(`button`,{type:`button`,"data-testid":`download-output`,"aria-label":`Download`,title:`Download`,onClick:g,disabled:!n,className:VE,children:[(0,V.jsx)(ge,{"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`hidden xl:inline`,children:`Download`})]})]}),status:s?{kind:`notice`,message:`Output edited — CSV and option changes aren't applied.`,action:b?(0,V.jsxs)(`button`,{type:`button`,"data-testid":`discard-reconvert`,onClick:b,className:VE+` ml-2`,children:[(0,V.jsx)(ve,{"aria-hidden":`true`}),`Discard edits & reconvert`]}):void 0}:r?{kind:`error`,message:r}:o&&o.length>0?{kind:`notice`,message:pO(o)}:null,children:t?(0,V.jsxs)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:[`Your `,e,` appears here.`]}):n?x?(0,V.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onCopy:()=>h?.(),children:(0,V.jsx)(zE,{value:n,editable:c&&S&&n.length<=2e6,lintJson:S,onChange:v,dark:d,testId:`output-view`})}):(0,V.jsx)(Df,{text:n,delimiter:u,testId:`output-table`,dark:d,onCopySelection:p,onProjectedCsvChange:m}):r?(0,V.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-sm text-muted-foreground`,children:`Resolve the error to see output.`}):(0,V.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 hO({phase:e,message:t,onRetry:n}){return e===`loading`?(0,V.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…`}):e===`not-found`?(0,V.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:[(0,V.jsx)(`span`,{children:`This data doesn't exist (or was deleted).`}),(0,V.jsx)(`a`,{href:`/`,className:`font-medium underline underline-offset-2`,children:`Go to the converter`})]}):e===`unsupported`?(0,V.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:[(0,V.jsx)(`span`,{children:`This link's saved data can't be shown in the new converter.`}),(0,V.jsx)(`a`,{href:`/`,className:`font-medium underline underline-offset-2`,children:`Go to the converter`})]}):(0,V.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:[(0,V.jsx)(`span`,{children:t||`Couldn't load this data.`}),(0,V.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`})]})}var gO=`csvjson:recent.v1`,_O=80;function vO(e){return e===`csv2json`||e===`json2csv`}function yO(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t={};for(let[n,r]of Object.entries(e))(r===`string`||r===`number`||r===`boolean`||r===`auto`)&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function bO(e){if(typeof e!=`object`||!e)return{...gD};let t=e,n=t.separator,r=n===`auto`||n===`,`||n===`;`||n===` `||n===`|`?n:gD.separator,i=t.emptyFields===`keep`||t.emptyFields===`skip`?t.emptyFields:gD.emptyFields,a=t.nullLiterals===`string`||t.nullLiterals===`null`?t.nullLiterals:gD.nullLiterals,o=yO(t.columnTypes);return{separator:r,parseNumbers:typeof t.parseNumbers==`boolean`?t.parseNumbers:gD.parseNumbers,parseJSON:typeof t.parseJSON==`boolean`?t.parseJSON:gD.parseJSON,emptyFields:i,nullLiterals:a,transpose:typeof t.transpose==`boolean`?t.transpose:gD.transpose,hash:typeof t.hash==`boolean`?t.hash:gD.hash,minify:typeof t.minify==`boolean`?t.minify:gD.minify,flatten:typeof t.flatten==`boolean`?t.flatten:gD.flatten,collapseIndexedArrays:typeof t.collapseIndexedArrays==`boolean`?t.collapseIndexedArrays:gD.collapseIndexedArrays,...o?{columnTypes:o}:{}}}function xO(e){let t=(e.split(/\r?\n/).map(e=>e.trim()).find(e=>e.length>0)??``).replace(/\s+/g,` `);return t.length<=_O?t:`${t.slice(0,79)}…`}function SO(e){if(typeof e!=`object`||!e)return!1;let t=e;return!(typeof t.id!=`string`||t.id.trim()===``||typeof t.createdAt!=`number`||!Number.isFinite(t.createdAt)||!vO(t.direction)||typeof t.input!=`string`||t.input.trim()===``||t.input.length>1e5||t.filename!==null&&typeof t.filename!=`string`||typeof t.rows!=`number`||!Number.isInteger(t.rows)||t.rows<0||typeof t.cols!=`number`||!Number.isInteger(t.cols)||t.cols<0||typeof t.preview!=`string`)}function CO(e){return{id:e.id,createdAt:e.createdAt,direction:e.direction,input:e.input,options:bO(e.options),filename:e.filename,rows:e.rows,cols:e.cols,preview:e.preview||xO(e.input)}}function wO(e){try{if(typeof window>`u`)return;window.localStorage.setItem(gO,JSON.stringify(e))}catch{}}function TO(e){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`snap-${e}-${Math.random().toString(36).slice(2,10)}`}function EO(){try{if(typeof window>`u`)return[];let e=window.localStorage.getItem(gO);if(e===null)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(SO).map(CO).sort((e,t)=>t.createdAt-e.createdAt).slice(0,10):[]}catch{return[]}}function DO(e){let t=EO(),n=e.input.trim();if(n===``||e.input.length>1e5||e.rows<=0&&e.cols<=0)return t;let r=e.createdAt??Date.now(),i=[{id:t.find(t=>t.direction===e.direction&&t.input.trim()===n)?.id??TO(r),createdAt:r,direction:e.direction,input:e.input,options:bO(e.options),filename:e.filename,rows:e.rows,cols:e.cols,preview:xO(e.input)},...t.filter(t=>t.direction!==e.direction||t.input.trim()!==n)].slice(0,10);return wO(i),i}function OO(e){let t=EO().filter(t=>t.id!==e);return wO(t),t}function kO(){try{if(typeof window>`u`)return;window.localStorage.removeItem(gO)}catch{}}function AO(e,t=Date.now()){let n=Math.max(0,t-e),r=Math.floor(n/1e3);if(r<45)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i}m ago`;let a=Math.floor(i/60);if(a<24)return`${a}h ago`;let o=Math.floor(a/24);return o===1?`yesterday`:o<7?`${o}d ago`:new Date(e).toLocaleDateString(`en-US`,{month:`short`,day:`numeric`})}function jO(e){return e===`csv2json`?`CSV→JSON`:`JSON→CSV`}function MO(e,t){return e>0&&t>0?`${e} rows · ${t} cols`:e>0?`${e} rows`:t>0?`${t} cols`:`0 rows`}function NO({snapshots:e,onSelect:t,onRemove:n,onClear:r}){let[i,a]=(0,g.useState)(!1),o=(0,g.useRef)(null),s=(0,g.useRef)(null),c=(0,g.useCallback)(()=>{a(!1)},[]),l=(0,g.useRef)(!1);(0,g.useEffect)(()=>{l.current&&!i&&s.current?.focus(),l.current=i},[i]),(0,g.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`Escape`&&c()},t=e=>{let t=o.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||c())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[i,c]);let u=e.length;return(0,V.jsxs)(`div`,{"data-testid":`recent-history`,ref:o,className:`relative max-sm:static`,children:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`recent-history-toggle`,ref:s,onClick:()=>a(e=>!e),"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:[(0,V.jsx)(pe,{size:14,strokeWidth:2,"aria-hidden":`true`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:`Recent`}),u>0&&(0,V.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:u})]}),i&&(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5`,children:[(0,V.jsx)(`span`,{className:`text-xs font-semibold tracking-tight text-foreground`,children:`Recent conversions`}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u>0&&(0,V.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`}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`recent-history-close`,onClick:c,"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:(0,V.jsx)(Te,{size:14,strokeWidth:2,"aria-hidden":`true`})})]})]}),u===0?(0,V.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.`}):(0,V.jsx)(`div`,{className:`max-h-96 divide-y divide-border overflow-y-auto`,children:e.map(e=>(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-1 px-2 py-2 transition-colors hover:bg-muted/50`,children:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`recent-history-item-${e.id}`,onClick:()=>{t(e),c()},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:[(0,V.jsxs)(`div`,{className:`mb-1 flex w-full items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:jO(e.direction)}),(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:MO(e.rows,e.cols)}),(0,V.jsx)(`span`,{className:`ml-auto text-[11px] text-muted-foreground`,children:AO(e.createdAt)})]}),(0,V.jsx)(`span`,{className:`w-full truncate font-mono text-xs text-foreground`,children:e.filename??e.preview})]}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`recent-history-delete-${e.id}`,onClick:t=>{t.stopPropagation(),n(e.id)},"aria-label":`Delete recent snapshot ${e.filename??e.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:(0,V.jsx)(we,{size:13,strokeWidth:2,"aria-hidden":`true`})})]},e.id))})]})]})}function PO(e){return Math.min(80,Math.max(20,e))}function FO({layout:e,split:t,onSplitChange:n,left:r,right:i,children:a}){let o=(0,g.useRef)(null),[s,c]=(0,g.useState)(!1),l=e===`stacked`;return(0,g.useEffect)(()=>{if(!s)return;let e=e=>{let t=o.current?.getBoundingClientRect();t&&t.width!==0&&t.height!==0&&n(PO((l?(e.clientY-t.top)/t.height:(e.clientX-t.left)/t.width)*100))},t=()=>c(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[s,l,n]),(0,V.jsxs)(`div`,{ref:o,className:wt(`relative flex min-h-0 flex-1`,`flex-col md:flex-row`,s&&`select-none`),children:[(0,V.jsx)(`div`,{"data-testid":`pane-left`,style:{"--split":`${t}%`},className:wt(`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}),(0,V.jsxs)(`div`,{"data-testid":`seam`,role:`separator`,tabIndex:0,"aria-orientation":l?`horizontal`:`vertical`,"aria-valuenow":Math.round(t),"aria-valuemin":20,"aria-valuemax":80,"aria-label":`Resize panes`,title:`Drag to resize · double-click to reset`,onPointerDown:e=>{e.target instanceof Element&&e.target.closest(`button`)||(e.preventDefault(),e.currentTarget.setPointerCapture?.(e.pointerId),c(!0))},onPointerUp:()=>c(!1),onDoubleClick:()=>n(50),onKeyDown:e=>{let r=e.shiftKey?5:1;switch(e.key){case`ArrowLeft`:case`ArrowUp`:e.preventDefault(),n(PO(t-r));break;case`ArrowRight`:case`ArrowDown`:e.preventDefault(),n(PO(t+r));break;case`Home`:e.preventDefault(),n(20);break;case`End`:e.preventDefault(),n(80);break;case`Enter`:case` `:e.preventDefault(),n(50)}},style:{"--split":`${t}%`,touchAction:`none`},className:wt(`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:[(0,V.jsx)(`div`,{className:wt(`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`)}),a?(0,V.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:a}):null]}),(0,V.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 IO({theme:e}){return e===`dark`?(0,V.jsx)(xe,{size:15,strokeWidth:2,"aria-hidden":`true`}):(0,V.jsx)(L,{size:15,strokeWidth:2,"aria-hidden":`true`})}function LO({theme:e,onToggleTheme:t,slot:n}){return(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,V.jsx)(`span`,{className:`text-[15px] font-semibold tracking-tight text-foreground whitespace-nowrap`,children:`csvjson`}),(0,V.jsx)(`span`,{className:`hidden text-[13px] font-medium text-muted-foreground sm:inline`,children:`CSV → JSON converter`})]}),(0,V.jsx)(`div`,{className:`flex-1`}),(0,V.jsx)(`div`,{"data-testid":`topbar-slot`,children:n}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`theme-toggle`,onClick:t,"aria-label":e===`dark`?`Switch to light mode`:`Switch to dark mode`,title:e===`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:(0,V.jsx)(IO,{theme:e})})]})}function RO(e){return[...e].sort((e,t)=>t.id-e.id)}var zO=[{id:24,date:`2026-10-20`,tag:`improvement`,title:`Clearer supported paste and upload formats in the input area`,summary:`The empty-state input area and file picker now explicitly list every accepted format in each mode — CSV, TSV / spreadsheet cells, Markdown & ChatGPT multi-table docs, and psql/MySQL box tables in CSV → JSON, plus JSON arrays, nested objects, wrapped API payloads, and JSONL / NDJSON in JSON → CSV.`},{id:23,date:`2026-10-20`,tag:`new`,title:`Extract and switch between multiple tables in pasted Markdown`,summary:`Paste an entire ChatGPT response or Markdown document containing prose and multiple Markdown or CLI box tables into CSV → JSON: every table is detected in order with interactive chooser pills to switch which table is previewed and converted, or keep only the selected table as clean CSV.`},{id:22,date:`2026-10-20`,tag:`new`,title:`Column visibility picker and Apply view to output`,summary:`Use the new Columns menu in any data table to hide or restore columns without touching your raw input. When a search filter, sort order, or column subset is active, toggle Apply view to output to project that exact table view into the converted output, Copy, and Download.`},{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.`}],BO=864e5;function VO(e){return Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())}function HO(e,t=Date.now()){let n=new Date(`${e}T00:00:00Z`),r=new Date(t),i=Math.round((VO(r)-VO(n))/BO);if(i<=0)return`today`;if(i===1)return`yesterday`;if(i<7)return`${i} days ago`;let a=n.toLocaleDateString(`en-US`,{month:`short`,day:`numeric`,timeZone:`UTC`});return n.getUTCFullYear()===r.getUTCFullYear()?a:`${a}, ${n.getUTCFullYear()}`}var UO=`csvjson:changelog.v1`,WO=Math.max(...zO.map(e=>e.id),0),GO=RO(zO);function KO(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.lastSeenId!==null&&typeof t.lastSeenId!=`number`||typeof t.votes!=`object`||t.votes===null)return!1;for(let[e,n]of Object.entries(t.votes))if(!/^\d+$/.test(e)||n!==1&&n!==-1)return!1;return!(t.clientId!==void 0&&!qO(t.clientId)||t.pendingIds!==void 0&&(!Array.isArray(t.pendingIds)||t.pendingIds.some(e=>typeof e!=`number`||!Number.isInteger(e)||e<1)))}function qO(e){return typeof e==`string`&&/^[0-9a-fA-F-]{8,64}$/.test(e)}function JO(e){return e===void 0?[]:[...new Set(e)].filter(e=>e>=1&&e<=WO).sort((e,t)=>e-t)}function YO(e,t,n){let r=JO(e.pendingIds),i=n?[...new Set([...r,t])].sort((e,t)=>e-t):r.filter(e=>e!==t);return{...e,pendingIds:i}}function XO(){try{let e=window.localStorage.getItem(UO);if(e===null)return{lastSeenId:null,votes:{}};let t=JSON.parse(e);return KO(t)?{...t,pendingIds:JO(t.pendingIds)}:{lastSeenId:null,votes:{}}}catch{return{lastSeenId:null,votes:{}}}}function ZO(e){try{window.localStorage.setItem(UO,JSON.stringify(e))}catch{}}function QO(){if(typeof globalThis.crypto?.randomUUID==`function`)return globalThis.crypto.randomUUID();let e=globalThis.crypto?.getRandomValues?.(new Uint8Array(16));if(e===void 0)throw Error(`no secure randomness available`);e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}async function $O(e,t,n){try{return(await fetch(`/api/changelog-vote`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({clientId:e,entryId:t,vote:n})})).ok?`ok`:`failed`}catch{return`failed`}}function ek(e){return[`flex h-6 w-7 cursor-pointer items-center justify-center rounded-md transition-colors`,e?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`].join(` `)}function tk({entry:e,vote:t,queued:n,inFlight:r,onVote:i}){return(0,V.jsxs)(`article`,{className:`px-3 py-2.5`,"data-testid":`changelog-entry-${e.id}`,children:[(0,V.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5`,children:[e.tag!==void 0&&(0,V.jsx)(`span`,{className:`rounded-full border border-border px-1.5 py-px text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:e.tag}),(0,V.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:HO(e.date)})]}),(0,V.jsx)(`h3`,{className:`text-xs font-semibold text-foreground`,children:e.title}),(0,V.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-muted-foreground`,children:e.summary}),(0,V.jsxs)(`div`,{className:`mt-1.5 flex gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,"data-testid":`changelog-up-${e.id}`,onClick:()=>i(e.id,1),"aria-pressed":t===1,"aria-label":`Upvote: ${e.title}`,title:`Good change`,className:ek(t===1),children:(0,V.jsx)(Ce,{size:13,strokeWidth:2,"aria-hidden":`true`})}),(0,V.jsx)(`button`,{type:`button`,"data-testid":`changelog-down-${e.id}`,onClick:()=>i(e.id,-1),"aria-pressed":t===-1,"aria-label":`Downvote: ${e.title}`,title:`Not for me`,className:ek(t===-1),children:(0,V.jsx)(z,{size:13,strokeWidth:2,"aria-hidden":`true`})})]}),n&&!r&&(0,V.jsx)(`p`,{"data-testid":`changelog-queued-${e.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 nk(){let[e,t]=(0,g.useState)(XO),[n,r]=(0,g.useState)(!1),i=(0,g.useRef)(e),a=(0,g.useCallback)(e=>{ZO(e),i.current=e,t(e)},[]),[o,s]=(0,g.useState)(()=>new Set),c=(0,g.useRef)(new Set),l=(0,g.useRef)(null),u=(0,g.useRef)(null),d=(0,g.useRef)(new Map),f=e.lastSeenId!==null&&WO>e.lastSeenId,p=(0,g.useCallback)((e,t)=>{s(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),m=(0,g.useCallback)((e,t,n,r)=>{let o=(d.current.get(e)??0)+1;d.current.set(e,o),c.current.add(e),r&&p(e,!0),$O(n,e,t).then(n=>{d.current.get(e)===o&&(c.current.delete(e),n===`ok`&&(w({entry_id:e,vote:t}),a(YO(i.current,e,!1))),r&&p(e,!1))})},[a,p]),h=(0,g.useCallback)(e=>{let{clientId:t,pendingIds:n,votes:r}=i.current,a=n??[];if(a.length!==0&&t!==void 0)for(let n of a){if(n===e||c.current.has(n))continue;let i=r[n];i!==void 0&&m(n,i,t,!1)}},[m]),_=(t,n)=>{if(e.votes[t]===n){h();return}let r=e.clientId??QO();a(YO({...e,votes:{...e.votes,[t]:n},clientId:r},t,!0)),m(t,n,r,!0),h(t)},v=()=>{r(!0),C(),e.lastSeenId!==WO&&a({...e,lastSeenId:WO}),h()},y=(0,g.useCallback)(()=>{r(!1)},[]),b=(0,g.useRef)(!1);(0,g.useEffect)(()=>{b.current&&!n&&u.current?.focus(),b.current=n},[n]);let x=(0,g.useRef)(!1);return(0,g.useEffect)(()=>{x.current||(x.current=!0,h())},[h]),(0,g.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&y()},t=e=>{let t=l.current;t!==null&&e.target instanceof Node&&(t.contains(e.target)||y())};return document.addEventListener(`keydown`,e),document.addEventListener(`click`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`click`,t)}},[n,y]),(0,V.jsxs)(`div`,{"data-testid":`changelog`,ref:l,className:`relative max-sm:static`,children:[(0,V.jsxs)(`button`,{type:`button`,"data-testid":`changelog-toggle`,ref:u,onClick:()=>n?y():v(),"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:[(0,V.jsx)(R,{size:15,strokeWidth:2,"aria-hidden":`true`}),f&&(0,V.jsx)(`span`,{"data-testid":`changelog-dot`,"aria-hidden":`true`,className:`absolute right-1 top-1 size-1.5 rounded-full bg-foreground`})]}),n&&(0,V.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:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border py-1.5 pl-3 pr-1.5`,children:[(0,V.jsx)(`span`,{className:`text-xs font-semibold tracking-tight text-foreground`,children:`What's new`}),(0,V.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:(0,V.jsx)(Te,{size:14,strokeWidth:2,"aria-hidden":`true`})})]}),(0,V.jsx)(`div`,{className:`max-h-96 divide-y divide-border overflow-y-auto`,children:GO.map(t=>(0,V.jsx)(tk,{entry:t,vote:e.votes[t.id],queued:e.pendingIds?.includes(t.id)??!1,inFlight:o.has(t.id),onVote:_},t.id))})]})]})}function rk(e,t){let[n,r]=(0,g.useState)(e);return(0,g.useEffect)(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}var ik=[`csv2json`,`json2csv`,`json_validator`,`json_beautifier`,`sql2json`,`csvjson2json`,`datajanitor`],ak=[`csv2json`,`json2csv`,`csvjson2json`];function ok(e){return ak.includes(e)}var sk=/^[0-9a-f]{32}$/i,ck=/^\/([a-z0-9_]+)\/([0-9a-f]{32})\/?$/i,lk=({BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_S3_DATA_URL??`https://csvjson.s3.us-east-2.amazonaws.com/data/`).replace(/\/*$/,`/`);function uk(e){let t=ck.exec(e);if(!t)return null;let n=t[1].toLowerCase();return ik.includes(n)?{tool:n,id:t[2].toLowerCase()}:null}var dk=class extends Error{constructor(){super(`This data doesn't exist (or was deleted)`),this.name=`PermalinkNotFoundError`}},fk=class extends Error{constructor(e,t){super(e,t),this.name=`PermalinkFetchError`}},pk={csv:(e,t)=>{e.direction=`csv2json`,e.input=mk(t)},json:(e,t)=>{e.input=mk(t),e.direction=`json2csv`},parseNumbers:(e,t)=>{let n=gk(t);n!==void 0&&(e.options.parseNumbers=n)},parseJSON:(e,t)=>{let n=gk(t);n!==void 0&&(e.options.parseJSON=n)},transpose:(e,t)=>{let n=gk(t);n!==void 0&&(e.options.transpose=n)},"output-array":(e,t)=>{let n=gk(t);n!==void 0&&(e.options.hash=!n)},"output-hash":(e,t)=>{let n=gk(t);n!==void 0&&(e.options.hash=n)},flatten:(e,t)=>{let n=gk(t);n!==void 0&&(e.options.flatten=n)},output_csvjson_variant:()=>{}};function mk(e){return typeof e==`string`?e:typeof e==`number`?String(e):``}function hk(e){return typeof e==`string`&&e.trim()!==``}function gk(e){if(e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1}function _k(e){return typeof e!=`object`||!e||Array.isArray(e)?!1:Object.values(e).every(e=>typeof e==`string`||typeof e==`boolean`)}function vk(e){if(!_k(e))return null;let t=hk(e.csv),n=hk(e.json);if(!t&&!n)return null;let r={direction:t?`csv2json`:`json2csv`,input:``,options:{}};for(let[t,n]of Object.entries(e))pk[t]?.(r,n);return r.input=mk(t?e.csv:e.json),r}async function yk(e){if(!sk.test(e))throw new dk;let t;try{t=await fetch(`${lk}${e}`,{mode:`cors`})}catch(e){throw new fk(`Network error while loading this data`,{cause:e})}if(t.status===403||t.status===404)throw new dk;if(!t.ok)throw new fk(`Unexpected response while loading this data (HTTP ${t.status})`);let n;try{let e=await t.text();if(e.trim()===``)throw Error(`empty body`);n=JSON.parse(e)}catch{throw new fk(`Stored data for this link is malformed`)}return n}function bk(e){let t=(0,g.useMemo)(()=>e&&ok(e.tool)?e.id:null,[e]),[n,r]=(0,g.useState)(0),[i,a]=(0,g.useState)(t?`loading`:`idle`),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``);return(0,g.useEffect)(()=>{if(!t)return;let e=!1;return yk(t).then(t=>{if(e)return;let n=vk(t);n?(s(n),a(`hydrated`)):a(`unsupported`)}).catch(t=>{e||(t instanceof dk?a(`not-found`):(l(t instanceof Error?t.message:`Couldn't load this data`),a(`error`)))}),()=>{e=!0}},[t,n]),{phase:i,hydrated:o,message:c,retry:()=>{i===`error`&&(a(`loading`),r(e=>e+1))}}}async function xk(e){try{if(typeof navigator<`u`&&navigator.clipboard)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return t.remove(),n}catch{return!1}}function Sk(e,t){return t?``+e:e}function Ck(e,t,n){let r=Sk(e,n);return new Blob([r],{type:`${t};charset=utf-8`})}var wk=new Set([`csv`,`tsv`,`json`,`jsonl`,`sql`,`ts`,`txt`]);function Tk(e){let t=e;for(;;){let e=t.lastIndexOf(`.`);if(e<=0)break;if(e===t.length-1)t=t.slice(0,e);else{if(!wk.has(t.slice(e+1).toLowerCase()))break;t=t.slice(0,e)}}return t}function Ek(e,t,n=`json`){let r=t===`csv2json`?n:`csv`;return e?`${Tk(e)}.${r}`:`data.${r}`}function Dk(e,t=`json`){if(e===`json2csv`)return`text/csv`;switch(t){case`json`:return`application/json`;case`jsonl`:return`application/x-ndjson`;case`sql`:return`application/sql`;case`ts`:return`text/typescript`}}function Ok(e,t,{mime:n=`text/plain`,bom:r=!1}={}){let i=Ck(e,n,r),a=URL.createObjectURL(i),o=document.createElement(`a`);return o.href=a,o.download=t,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(a),0),t}function kk(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||e.closest(`[contenteditable="true"]`)!==null}var Ak=`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`,jk=`[ - { - "album": "Elephant", - "year": 2003, - "label": "XL Recordings" - }, - { - "album": "Icky Thump", - "year": 2007, - "label": "XL Recordings" - } -]`,Mk=`csvjson-theme`;function Nk(){try{let e=localStorage.getItem(Mk);return e===`dark`||e===`light`?e:null}catch{return null}}function Pk(){try{if(typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches)return`dark`}catch{}return`light`}function Fk(){return Nk()??Pk()}function Ik(e){try{localStorage.setItem(Mk,e)}catch{}}function Lk(e){return new URLSearchParams(e).get(`direction`)===`json2csv`?`json2csv`:`csv2json`}var Rk=2097152,zk=150,Bk=1e3,Vk=2e3,Hk=2e3;function Uk(e,t){return e===0?null:t>0?`${e} rows · ${t} cols`:`${e} rows`}function Wk(e){try{return JSON.parse(e),!0}catch{return!1}}function Gk(){let[e,t]=(0,g.useState)(Fk);(0,g.useEffect)(()=>{document.documentElement.classList.toggle(`dark`,e===`dark`)},[e]);let n=()=>t(e=>{let t=e===`dark`?`light`:`dark`;return Ik(t),t}),[r,i]=(0,g.useState)(()=>typeof window>`u`?`csv2json`:Lk(window.location.search)),[a,o]=(0,g.useState)(()=>Jd(``)),s=a.present,[c,l]=(0,g.useState)(gD),[u,d]=(0,g.useState)(`json`),[f,p]=(0,g.useState)(50),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(null),[x,C]=(0,g.useState)(`utf-8`),[w,T]=(0,g.useState)(EO),[E,D]=(0,g.useState)(null),[O,A]=(0,g.useState)(null),[ee,te]=(0,g.useState)({forInput:``,index:0}),ne=ee.forInput===s?ee.index:0,j=(0,g.useCallback)(e=>{te({forInput:s,index:e})},[s]),ie=(0,g.useMemo)(()=>ne>0?{...c,markdownTableIndex:ne}:c,[c,ne]),M=(0,g.useRef)({direction:r,options:c,input:s,resultOk:!0}),ae=(0,g.useRef)(null);ae.current||=re({settleMs:Vk,minWindowMs:Hk,isValid:(e,t)=>{let n=M.current;return t===n.input?n.resultOk:OD(e===`csv_to_json`?`csv2json`:`json2csv`,t,n.options).ok}});let N=ae.current;(0,g.useEffect)(()=>()=>N.cancel(),[N]);let oe=RD(`(min-width: 48rem)`)?`side-by-side`:`stacked`,P=r===`csv2json`,se=P?`CSV`:`JSON`,ce=P?`JSON`:`CSV`,F=s.trim()===``,le=s.length>Rk?Bk:zk,ue=rk(s,F?0:le),de=(0,g.useRef)(null),fe=(0,g.useRef)(null),pe=s!==``&&de.current?.text===s?s:ue,me=P&&E!==null&&pe.trim()!==``?E:pe,he=(0,g.useMemo)(()=>typeof window>`u`?null:uk(window.location.pathname),[]),ge=bk(he),I=(0,g.useMemo)(()=>OD(r,me,ie),[r,me,ie]);M.current={direction:r,options:ie,input:pe,resultOk:I.ok},(0,g.useEffect)(()=>{let e=fe.current;e&&e.text===pe&&(fe.current=null,N.discrete(e.direction,e.via,e.text))},[pe,I,N]);let[L,_e]=(0,g.useState)(null);(0,g.useEffect)(()=>{pe.trim()!==``&&I.ok&&_e(I.text)},[I,pe]),(0,g.useEffect)(()=>{pe.trim()!==``&&(!I.ok||I.rows<=0&&I.cols<=0||T(DO({direction:r,input:pe,options:c,filename:m,rows:I.rows,cols:I.cols})))},[r,pe,m,c,I]);let R=pe.trim()!==``&&I.ok?I.text:L,[ve,ye]=(0,g.useState)(!1),[be,xe]=(0,g.useState)(null),Se=ve?be:R,z=(0,g.useMemo)(()=>{if(!P||Se===null||u===`json`)return Se;let e=ve&&be!==null&&Wk(be)?be:R;return e===null?null:dO(e,u,c,m)},[P,Se,u,ve,be,R,c,m]),Ce=P&&u===`json`&&!F&&z!==null&&(ve||I.ok),we=(0,g.useCallback)(e=>{e===R?(ye(!1),xe(null)):(ye(!0),xe(e))},[R]),B=(0,g.useCallback)(()=>{let e=P&&E!==null&&s.trim()!==``?E:s,t=OD(r,e,ie);t.ok&&_e(t.text),ye(!1),xe(null)},[P,r,ie,s,E]),Te=(0,g.useCallback)(e=>{o(t=>P?Yd(t,e):Jd(e))},[P]),Ee=P&&a.past.length>0,De=P&&a.future.length>0,Oe=(0,g.useCallback)(()=>{if(!P||a.past.length===0)return;let e=Xd(a);b(null),o(e),N.edit(`csv_to_json`,e.present)},[P,a,N]),ke=(0,g.useCallback)(()=>{if(!P||a.future.length===0)return;let e=Zd(a);b(null),o(e),N.edit(`csv_to_json`,e.present)},[P,a,N]),Ae=(0,g.useCallback)(e=>{b(null),de.current=null,i(e.direction),l({...e.options}),h(e.filename),ye(!1),xe(null),o(t=>e.direction===`csv2json`&&r===`csv2json`?Yd(t,e.input):Jd(e.input)),T(DO({direction:e.direction,input:e.input,options:e.options,filename:e.filename,rows:e.rows,cols:e.cols}))},[r]),je=(0,g.useCallback)(e=>{T(OO(e))},[]),Me=(0,g.useCallback)(()=>{kO(),T([])},[]),Ne=()=>{let e=r===`csv2json`?`json2csv`:`csv2json`;if(ve){let t=be??``,n=Wk(t)?t:s;o(Jd(n)),i(e),ye(!1),xe(null),n.trim()!==``&&(M.current={direction:e,options:c,input:n,resultOk:OD(e,n,c).ok},N.discrete(e===`csv2json`?`csv_to_json`:`json_to_csv`,`flip`,n))}else if(i(e),F)o(Jd(``));else{let t=OD(r,s,ie),n=t.ok?t.text:s;o(Jd(n)),n.trim()!==``&&(M.current={direction:e,options:c,input:n,resultOk:OD(e,n,c).ok},N.discrete(e===`csv2json`?`csv_to_json`:`json_to_csv`,`flip`,n))}},Pe=ge.hydrated;(0,g.useEffect)(()=>{if(Pe===null)return;let e={...M.current.options,...Pe.options};M.current={direction:Pe.direction,options:e,input:Pe.input,resultOk:OD(Pe.direction,Pe.input,e).ok},i(Pe.direction),o(Jd(Pe.input)),l(e=>({...e,...Pe.options})),ye(!1),xe(null),S(),N.discrete(Pe.direction===`csv2json`?`csv_to_json`:`json_to_csv`,`permalink`,Pe.input)},[Pe,N]);let Fe=async(e,t)=>{if(!FD(e))b(`Can't read "${e.name}" as text — drop a ${P?`.csv / .tsv`:`.json`} file.`);else{b(null),v(!0);try{let n=await LD(e,x);de.current={file:e,source:t,text:n},fe.current={direction:P?`csv_to_json`:`json_to_csv`,via:t===`drop`?`drag`:`file`,text:n},Te(n),h(e.name),v(!1)}catch{v(!1),b(`Couldn't read "${e.name}".`)}}},Ie=async e=>{let t=x;C(e);let n=de.current;if(n&&s===n.text){v(!0);try{let t=await LD(n.file,e);de.current={...n,text:t},fe.current={direction:P?`csv_to_json`:`json_to_csv`,via:n.source===`drop`?`drag`:`file`,text:t},o(e=>({...e,present:t})),v(!1)}catch{v(!1),C(t),b(`Couldn't read "${n.file.name}".`)}}},Le=(0,g.useCallback)(e=>{b(null),e.trim()===``&&l(e=>{if(!e.columnTypes)return e;let t={...e};return delete t.columnTypes,t}),Te(e),N.edit(P?`csv_to_json`:`json_to_csv`,e)},[Te,P,N]);(0,g.useEffect)(()=>{let e=e=>{let t=e.clipboardData?.getData(`text/plain`);t&&!kk(e.target)&&(e.preventDefault(),e.stopPropagation(),h(null),Le(t))};return document.addEventListener(`paste`,e,!0),()=>document.removeEventListener(`paste`,e,!0)},[Le]);let Re=I.ok?Uk(I.rows,I.cols):null,ze=!I.ok&&L?`Last valid result — input has errors`:null,Be=I.ok&&I.warnings&&I.warnings.length>0?I.warnings:null,Ve=s.length>Rk,He=P?`csv_to_json`:`json_to_csv`,Ue=P?u:`csv`,We=()=>{k({via:`copy`,format:P?`csv`:`json`,pane:`input`,direction:He}),xk(s)},Ge=!P&&O!==null?O:z,Ke=()=>{k({via:`copy`,format:Ue,pane:`output`,direction:He}),Ge&&xk(Ge)},qe=()=>{k({via:`download`,format:P?`csv`:`json`,pane:`input`,direction:He}),Ok(s,m??(P?`data.csv`:`data.json`),{mime:P?`text/csv`:`application/json`,bom:P})},Je=()=>{k({via:`download`,format:Ue,pane:`output`,direction:He}),Ok(Ge??``,Ek(m,P?`csv2json`:`json2csv`,u),{mime:Dk(P?`csv2json`:`json2csv`,u),bom:!P})},Ye=(0,g.useCallback)(()=>{k({via:`copy`,format:`csv`,pane:`input`,direction:He})},[He]),Xe=(0,g.useCallback)(()=>{k({via:`copy`,format:`csv`,pane:`output`,direction:He})},[He]),Ze=(0,g.useCallback)(()=>{k({via:`copy`,format:Ue,pane:`output`,direction:He})},[Ue,He]),Qe=(0,V.jsx)(ND,{format:se,input:s,onInputChange:Le,onCellCommit:Le,onFile:Fe,onTryExample:()=>{b(null);let e=P?Ak:jk;M.current={direction:r,options:c,input:e,resultOk:OD(r,e,c).ok},Te(e),N.discrete(He,`example`,e)},onClear:()=>{Te(``),h(null),l(e=>{if(!e.columnTypes)return e;let t={...e};return delete t.columnTypes,t}),ye(!1),xe(null),N.cancel()},onCopy:We,onCopySelection:Ye,onProjectedCsvChange:D,onDownload:qe,canUndo:Ee,canRedo:De,onUndo:Oe,onRedo:ke,collapseIndexedArrays:c.collapseIndexedArrays??!0,onToggleCollapseIndexedArrays:()=>l(e=>({...e,collapseIndexedArrays:!(e.collapseIndexedArrays??!0)})),columnTypes:c.columnTypes??{},onChangeColumnTypes:e=>l(t=>{let n={...t};return Object.keys(e).length>0?n.columnTypes=e:delete n.columnTypes,n}),flatten:c.flatten,onToggleFlatten:()=>l(e=>({...e,flatten:!e.flatten})),selectedMarkdownTableIndex:ne,onSelectMarkdownTableIndex:j,filename:m,reading:_,meta:Re,error:null,notice:y,delimiter:c.separator===`auto`?void 0:c.separator,dark:e===`dark`}),$e=(0,V.jsx)(mO,{format:ce,inputEmpty:F,outputText:z,error:I.ok?null:I.error,meta:Re,staleNotice:ze,warnings:Be,edited:ve,editable:Ce,egressFormat:u,delimiter:c.separator===`auto`?void 0:c.separator,dark:e===`dark`,onCopy:Ke,onCopySelection:Xe,onProjectedCsvChange:A,onNativeCopy:Ze,onDownload:Je,onEgressFormatChange:d,onOutputChange:we,onRevert:B,onDiscardReconvert:B});return(0,V.jsxs)(`div`,{className:`flex min-h-svh flex-col bg-background text-foreground`,children:[(0,V.jsx)(`h1`,{className:`sr-only`,children:`CSV to JSON and JSON to CSV converter`}),(0,V.jsxs)(`div`,{className:`flex min-h-svh flex-col md:h-svh md:min-h-0`,children:[(0,V.jsx)(Nt,{}),(0,V.jsx)(LO,{theme:e,onToggleTheme:n,slot:(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(NO,{snapshots:w,onSelect:Ae,onRemove:je,onClear:Me}),(0,V.jsx)(nk,{}),(0,V.jsx)(Ht,{})]})}),he&&(ge.phase===`loading`||ge.phase===`not-found`||ge.phase===`unsupported`||ge.phase===`error`)?(0,V.jsx)(hO,{phase:ge.phase,message:ge.phase===`error`?ge.message:void 0,onRetry:ge.retry}):null,(0,V.jsx)(FO,{layout:oe,split:f,onSplitChange:p,left:Qe,right:$e,children:(0,V.jsx)(Ot,{direction:r,onFlip:Ne})}),(0,V.jsx)(qD,{direction:r,options:c,onChange:e=>l(t=>({...t,...e})),uploadEncoding:x,onUploadEncodingChange:Ie,notice:Ve?`Large file — converting on pause`:null})]}),(0,V.jsx)(jt,{})]})}(0,_.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(g.StrictMode,{children:(0,V.jsx)(Gk,{})})),document.getElementById(`root`).removeAttribute(`inert`),b(),x();export{nr as a,m as c,br as i,u as l,vo as n,rr as o,ho as r,ar as s,Ol as t,c as u}; \ No newline at end of file diff --git a/app/dist/assets/number-overlay-editor-DAo7GPxB.js b/app/dist/assets/number-overlay-editor-Cch5pRMh.js similarity index 99% rename from app/dist/assets/number-overlay-editor-DAo7GPxB.js rename to app/dist/assets/number-overlay-editor-Cch5pRMh.js index 24ed60b..d0b4bd7 100644 --- a/app/dist/assets/number-overlay-editor-DAo7GPxB.js +++ b/app/dist/assets/number-overlay-editor-Cch5pRMh.js @@ -1,4 +1,4 @@ -import{i as e,l as t,u as n}from"./index-Dw_RpILp.js";var r=n(t()),i=e(`div`)({name:`NumberOverlayEditorStyle`,class:`gdg-n15fjm3e`,propsAsIs:!1});function a(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i=s?i+=b(`0`,o-s):i=(i.substring(0,o)||`0`)+`.`+i.substring(o),n+i}function S(e,t,n){if([``,`-`].indexOf(e)!==-1)return e;var r=(e.indexOf(`.`)!==-1||n)&&t,i=_(e),a=i.beforeDecimal,o=i.afterDecimal,s=i.hasNegation,c=parseFloat(`0.`+(o||`0`)),l=(o.length<=t?`0.`+o:c.toFixed(t)).split(`.`),u=a;a&&Number(l[0])&&(u=a.split(``).reverse().reduce(function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e},l[0]));var d=y(l[1]||``,t,n),f=s?`-`:``,p=r?`.`:``;return``+f+u+p+d}function C(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move(`character`,t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var w=c(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&nn&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),T=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}};function E(e,t,n){return Math.min(Math.max(e,t),n)}function D(e){return Math.max(e.selectionStart,e.selectionEnd)}function O(){return typeof navigator<`u`&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function k(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:``}}function A(e){var t=e.currentValue,n=e.formattedValue,r=e.currentValueIndex,i=e.formattedValueIndex;return t[r]===n[i]}function j(e,t,n,r,i,a,o){o===void 0&&(o=A);var s=i.findIndex(function(e){return e}),c=e.slice(0,s);!t&&!n.startsWith(c)&&(t=c,n=c+n,r+=c.length);for(var l=n.length,u=e.length,d={},f=Array(l),p=0;p0&&f[g]===-1;)g--;var v=g===-1||f[g]===-1?0:f[g]+1;return v>_?_:r-v<_-r?v:_}function M(e,t,n,r){var i=e.length;if(t=E(t,0,i),r===`left`){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}return t===-1&&(t=i),t}function N(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,r=t.length;nE.length-o.length||Tj||f>e.length-o.length)&&(A=f),e=e.substring(0,A),e=B(S?`-`+e:e,i),e=(e.match(V(g,!0))||[]).join(``);var M=e.indexOf(g);e=e.replace(new RegExp(p(g),`g`),function(e,t){return t===M?`.`:``});var N=_(e,i),P=N.beforeDecimal,F=N.afterDecimal,I=N.addNegation;return u.end-u.start=s?i+=b(`0`,o-s):i=(i.substring(0,o)||`0`)+`.`+i.substring(o),n+i}function S(e,t,n){if([``,`-`].indexOf(e)!==-1)return e;var r=(e.indexOf(`.`)!==-1||n)&&t,i=_(e),a=i.beforeDecimal,o=i.afterDecimal,s=i.hasNegation,c=parseFloat(`0.`+(o||`0`)),l=(o.length<=t?`0.`+o:c.toFixed(t)).split(`.`),u=a;a&&Number(l[0])&&(u=a.split(``).reverse().reduce(function(e,t,n){return e.length>n?(Number(e[0])+Number(t)).toString()+e.substring(1,e.length):t+e},l[0]));var d=y(l[1]||``,t,n),f=s?`-`:``,p=r?`.`:``;return``+f+u+p+d}function C(e,t){if(e.value=e.value,e!==null){if(e.createTextRange){var n=e.createTextRange();return n.move(`character`,t),n.select(),!0}return e.selectionStart||e.selectionStart===0?(e.focus(),e.setSelectionRange(t,t),!0):(e.focus(),!1)}}var w=c(function(e,t){for(var n=0,r=0,i=e.length,a=t.length;e[n]===t[n]&&nn&&i-r>n;)r++;return{from:{start:n,end:i-r},to:{start:n,end:a-r}}}),T=function(e,t){var n=Math.min(e.selectionStart,t);return{from:{start:n,end:e.selectionEnd},to:{start:n,end:t}}};function E(e,t,n){return Math.min(Math.max(e,t),n)}function D(e){return Math.max(e.selectionStart,e.selectionEnd)}function O(){return typeof navigator<`u`&&!(navigator.platform&&/iPhone|iPod/.test(navigator.platform))}function k(e){return{from:{start:0,end:0},to:{start:0,end:e.length},lastValue:``}}function A(e){var t=e.currentValue,n=e.formattedValue,r=e.currentValueIndex,i=e.formattedValueIndex;return t[r]===n[i]}function j(e,t,n,r,i,a,o){o===void 0&&(o=A);var s=i.findIndex(function(e){return e}),c=e.slice(0,s);!t&&!n.startsWith(c)&&(t=c,n=c+n,r+=c.length);for(var l=n.length,u=e.length,d={},f=Array(l),p=0;p0&&f[g]===-1;)g--;var v=g===-1||f[g]===-1?0:f[g]+1;return v>_?_:r-v<_-r?v:_}function M(e,t,n,r){var i=e.length;if(t=E(t,0,i),r===`left`){for(;t>=0&&!n[t];)t--;t===-1&&(t=n.indexOf(!0))}else{for(;t<=i&&!n[t];)t++;t>i&&(t=n.lastIndexOf(!0))}return t===-1&&(t=i),t}function N(e){for(var t=Array.from({length:e.length+1}).map(function(){return!0}),n=0,r=t.length;nE.length-o.length||Tj||f>e.length-o.length)&&(A=f),e=e.substring(0,A),e=B(S?`-`+e:e,i),e=(e.match(V(g,!0))||[]).join(``);var M=e.indexOf(g);e=e.replace(new RegExp(p(g),`g`),function(e,t){return t===M?`.`:``});var N=_(e,i),P=N.beforeDecimal,F=N.afterDecimal,I=N.addNegation;return u.end-u.start - + -

    CSV to JSON and JSON to CSV converter

    Enjoy a cleaner, simpler CSVJSON. Leave feedback or ask for features here.

    csvjson
    CSV

    Paste CSV, TSV, or Markdown table

    Supports CSV, TSV / spreadsheet cells, Markdown & ChatGPT docs (multi-table), and psql / MySQL box tables

    or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (Ctrl+V)

    JSON
    Your JSON appears here.
    Auto · Parse numbers · Parse JSON
    +

    CSV to JSON and JSON to CSV converter

    Enjoy a cleaner, simpler CSVJSON. Leave feedback or ask for features here.

    csvjson
    CSV

    Paste CSV, TSV, or Markdown table

    Supports CSV, TSV / spreadsheet cells, Markdown & ChatGPT docs (multi-table), and psql / MySQL box tables

    or drag & drop a file anywhere in this pane — you can also paste anywhere on the page (Ctrl+V)

    JSON
    Your JSON appears here.
    Auto · Parse numbers · Parse JSON