aiexecode 1.0.92 → 1.0.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of aiexecode might be problematic. Click here for more details.
- package/README.md +210 -87
- package/index.js +33 -1
- package/package.json +3 -3
- package/payload_viewer/out/404/index.html +1 -1
- package/payload_viewer/out/404.html +1 -1
- package/payload_viewer/out/_next/static/chunks/{37d0cd2587a38f79.js → b6c0459f3789d25c.js} +1 -1
- package/payload_viewer/out/_next/static/chunks/b75131b58f8ca46a.css +3 -0
- package/payload_viewer/out/index.html +1 -1
- package/payload_viewer/out/index.txt +3 -3
- package/payload_viewer/web_server.js +361 -0
- package/src/LLMClient/client.js +392 -16
- package/src/LLMClient/converters/responses-to-claude.js +67 -18
- package/src/LLMClient/converters/responses-to-zai.js +608 -0
- package/src/LLMClient/errors.js +18 -4
- package/src/LLMClient/index.js +5 -0
- package/src/ai_based/completion_judge.js +35 -4
- package/src/ai_based/orchestrator.js +146 -35
- package/src/commands/agents.js +70 -0
- package/src/commands/commands.js +51 -0
- package/src/commands/debug.js +52 -0
- package/src/commands/help.js +11 -1
- package/src/commands/model.js +43 -7
- package/src/commands/skills.js +46 -0
- package/src/config/ai_models.js +96 -5
- package/src/config/constants.js +71 -0
- package/src/frontend/App.js +4 -5
- package/src/frontend/components/ConversationItem.js +25 -24
- package/src/frontend/components/HelpView.js +106 -2
- package/src/frontend/components/SetupWizard.js +53 -8
- package/src/frontend/utils/syntaxHighlighter.js +4 -4
- package/src/frontend/utils/toolUIFormatter.js +261 -0
- package/src/system/agents_loader.js +289 -0
- package/src/system/ai_request.js +147 -9
- package/src/system/command_parser.js +33 -3
- package/src/system/conversation_state.js +265 -0
- package/src/system/custom_command_loader.js +386 -0
- package/src/system/session.js +59 -35
- package/src/system/skill_loader.js +318 -0
- package/src/system/tool_approval.js +10 -0
- package/src/tools/file_reader.js +49 -9
- package/src/tools/glob.js +0 -3
- package/src/tools/ripgrep.js +5 -7
- package/src/tools/skill_tool.js +122 -0
- package/src/tools/web_downloader.js +0 -3
- package/src/util/clone.js +174 -0
- package/src/util/config.js +38 -2
- package/src/util/config_migration.js +174 -0
- package/src/util/path_validator.js +178 -0
- package/src/util/prompt_loader.js +68 -1
- package/src/util/safe_fs.js +43 -3
- package/payload_viewer/out/_next/static/chunks/ecd2072ebf41611f.css +0 -3
- /package/payload_viewer/out/_next/static/{d0-fu2rgYnshgGFPxr1CR → lHmNygVpv4N1VR0LdnwkJ}/_buildManifest.js +0 -0
- /package/payload_viewer/out/_next/static/{d0-fu2rgYnshgGFPxr1CR → lHmNygVpv4N1VR0LdnwkJ}/_clientMiddlewareManifest.json +0 -0
- /package/payload_viewer/out/_next/static/{d0-fu2rgYnshgGFPxr1CR → lHmNygVpv4N1VR0LdnwkJ}/_ssgManifest.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67585,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return r}});let i=e.r(32061);function r(e){let{reason:t,children:n}=e;if("undefined"==typeof window)throw Object.defineProperty(new i.BailoutToCSRError(t),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}},9885,(e,t,n)=>{"use strict";function i(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return i}})},52157,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return l}});let i=e.r(43476),r=e.r(74080),s=e.r(63599),o=e.r(9885);function l(e){let{moduleIds:t}=e;if("undefined"!=typeof window)return null;let n=s.workAsyncStorage.getStore();if(void 0===n)return null;let l=[];if(n.reactLoadableManifest&&t){let e=n.reactLoadableManifest;for(let n of t){if(!e[n])continue;let t=e[n].files;l.push(...t)}}return 0===l.length?null:(0,i.jsx)(i.Fragment,{children:l.map(e=>{let t=n.assetPrefix+"/_next/"+(0,o.encodeURIPath)(e);return e.endsWith(".css")?(0,i.jsx)("link",{precedence:"dynamic",href:t,rel:"stylesheet",as:"style"},e):((0,r.preload)(t,{as:"script",fetchPriority:"low"}),null)})})}},69093,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return h}});let i=e.r(43476),r=e.r(71645),s=e.r(67585),o=e.r(52157);function l(e){return{default:e&&"default"in e?e.default:e}}let a={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},h=function(e){let t={...a,...e},n=(0,r.lazy)(()=>t.loader().then(l)),h=t.loading;function c(e){let l=h?(0,i.jsx)(h,{isLoading:!0,pastDelay:!0,error:null}):null,a=!t.ssr||!!t.loading,c=a?r.Suspense:r.Fragment,d=t.ssr?(0,i.jsxs)(i.Fragment,{children:["undefined"==typeof window?(0,i.jsx)(o.PreloadChunks,{moduleIds:t.modules}):null,(0,i.jsx)(n,{...e})]}):(0,i.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,i.jsx)(n,{...e})});return(0,i.jsx)(c,{...a?{fallback:l}:{},children:d})}return c.displayName="LoadableComponent",c}},70703,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}});let i=e.r(55682)._(e.r(69093));function r(e,t){var n;let r={};"function"==typeof e&&(r.loader=e);let s={...r,...t};return(0,i.default)({...s,modules:null==(n=s.loadableGenerated)?void 0:n.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},31713,e=>{"use strict";let t,n;e.s(["default",()=>vC],31713);var i,r,s,o,l,a,h,c=e.i(43476),d=e.i(71645),u=e.i(74080);function f(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{let n=!1,i=t.map(t=>{let i=f(t,e);return n||"function"!=typeof i||(n=!0),i});if(n)return()=>{for(let e=0;e<i.length;e++){let n=i[e];"function"==typeof n?n():f(t[e],null)}}}}function m(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.useCallback(p(...t),t)}function g(e){let t=function(e){let t=d.forwardRef((e,t)=>{let{children:n,...i}=e;if(d.isValidElement(n)){var r,s,o;let e,l,a=(l=(e=null==(s=Object.getOwnPropertyDescriptor((r=n).props,"ref"))?void 0:s.get)&&"isReactWarning"in e&&e.isReactWarning)?r.ref:(l=(e=null==(o=Object.getOwnPropertyDescriptor(r,"ref"))?void 0:o.get)&&"isReactWarning"in e&&e.isReactWarning)?r.props.ref:r.props.ref||r.ref,h=function(e,t){let n={...t};for(let i in t){let r=e[i],s=t[i];/^on[A-Z]/.test(i)?r&&s?n[i]=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=s(...t);return r(...t),i}:r&&(n[i]=r):"style"===i?n[i]={...r,...s}:"className"===i&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}(i,n.props);return n.type!==d.Fragment&&(h.ref=t?p(t,a):a),d.cloneElement(n,h)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}(e),n=d.forwardRef((e,n)=>{let{children:i,...r}=e,s=d.Children.toArray(i),o=s.find(b);if(o){let e=o.props.children,i=s.map(t=>t!==o?t:d.Children.count(e)>1?d.Children.only(null):d.isValidElement(e)?e.props.children:null);return(0,c.jsx)(t,{...r,ref:n,children:d.isValidElement(e)?d.cloneElement(e,void 0,i):null})}return(0,c.jsx)(t,{...r,ref:n,children:i})});return n.displayName="".concat(e,".Slot"),n}var v=g("Slot"),x=Symbol("radix.slottable");function b(e){return d.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===x}var y=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=g("Primitive.".concat(t)),i=d.forwardRef((e,i)=>{let{asChild:r,...s}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,c.jsx)(r?n:t,{...s,ref:i})});return i.displayName="Primitive.".concat(t),{...e,[t]:i}},{}),w=(null==(r=globalThis)?void 0:r.document)?d.useLayoutEffect:()=>{},k=e=>{let{present:t,children:n}=e,i=function(e){var t,n;let[i,r]=d.useState(),s=d.useRef(null),o=d.useRef(e),l=d.useRef("none"),[a,h]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},d.useReducer((e,t)=>{let i=n[e][t];return null!=i?i:e},t));return d.useEffect(()=>{let e=S(s.current);l.current="mounted"===a?e:"none"},[a]),w(()=>{let t=s.current,n=o.current;if(n!==e){let i=l.current,r=S(t);e?h("MOUNT"):"none"===r||(null==t?void 0:t.display)==="none"?h("UNMOUNT"):n&&i!==r?h("ANIMATION_OUT"):h("UNMOUNT"),o.current=e}},[e,h]),w(()=>{if(i){var e;let t,n=null!=(e=i.ownerDocument.defaultView)?e:window,r=e=>{let r=S(s.current).includes(CSS.escape(e.animationName));if(e.target===i&&r&&(h("ANIMATION_END"),!o.current)){let e=i.style.animationFillMode;i.style.animationFillMode="forwards",t=n.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=e)})}},a=e=>{e.target===i&&(l.current=S(s.current))};return i.addEventListener("animationstart",a),i.addEventListener("animationcancel",r),i.addEventListener("animationend",r),()=>{n.clearTimeout(t),i.removeEventListener("animationstart",a),i.removeEventListener("animationcancel",r),i.removeEventListener("animationend",r)}}h("ANIMATION_END")},[i,h]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(e=>{s.current=e?getComputedStyle(e):null,r(e)},[])}}(t),r="function"==typeof n?n({present:i.isPresent}):d.Children.only(n),s=m(i.ref,function(e){var t,n;let i=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=i&&"isReactWarning"in i&&i.isReactWarning;return r?e.ref:(r=(i=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get)&&"isReactWarning"in i&&i.isReactWarning)?e.props.ref:e.props.ref||e.ref}(r));return"function"==typeof n||i.isPresent?d.cloneElement(r,{ref:s}):null};function S(e){return(null==e?void 0:e.animationName)||"none"}function C(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[],i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let i=(null==n?void 0:n[e])||t;return d.useMemo(()=>({["__scope".concat(e)]:{...n,[e]:i}}),[n,i])}};return i.scopeName=e,[function(t,i){let r=d.createContext(i),s=n.length;n=[...n,i];let o=t=>{var n;let{scope:i,children:o,...l}=t,a=(null==i||null==(n=i[e])?void 0:n[s])||r,h=d.useMemo(()=>l,Object.values(l));return(0,c.jsx)(a.Provider,{value:h,children:o})};return o.displayName=t+"Provider",[o,function(n,o){var l;let a=(null==o||null==(l=o[e])?void 0:l[s])||r,h=d.useContext(a);if(h)return h;if(void 0!==i)return i;throw Error("`".concat(n,"` must be used within `").concat(t,"`"))}]},function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=t[0];if(1===t.length)return i;let r=()=>{let e=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){let n=e.reduce((e,n)=>{let{useScope:i,scopeName:r}=n,s=i(t)["__scope".concat(r)];return{...e,...s}},{});return d.useMemo(()=>({["__scope".concat(i.scopeName)]:n}),[n])}};return r.scopeName=i.scopeName,r}(i,...t)]}function A(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>function(){for(var e,n=arguments.length,i=Array(n),r=0;r<n;r++)i[r]=arguments[r];return null==(e=t.current)?void 0:e.call(t,...i)},[])}k.displayName="Presence";var N=d.createContext(void 0);function M(e){let t=d.useContext(N);return e||t||"ltr"}function O(e,t){let{checkForDefaultPrevented:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){if(null==e||e(i),!1===n||!i.defaultPrevented)return null==t?void 0:t(i)}}"undefined"!=typeof window&&window.document&&window.document.createElement;var j="ScrollArea",[E,T]=C(j),[D,R]=E(j),P=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:i="hover",dir:r,scrollHideDelay:s=600,...o}=e,[l,a]=d.useState(null),[h,u]=d.useState(null),[f,p]=d.useState(null),[g,v]=d.useState(null),[x,b]=d.useState(null),[w,k]=d.useState(0),[S,C]=d.useState(0),[A,N]=d.useState(!1),[O,j]=d.useState(!1),E=m(t,e=>a(e)),T=M(r);return(0,c.jsx)(D,{scope:n,type:i,dir:T,scrollHideDelay:s,scrollArea:l,viewport:h,onViewportChange:u,content:f,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:A,onScrollbarXEnabledChange:N,scrollbarY:x,onScrollbarYChange:b,scrollbarYEnabled:O,onScrollbarYEnabledChange:j,onCornerWidthChange:k,onCornerHeightChange:C,children:(0,c.jsx)(y.div,{dir:T,...o,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});P.displayName=j;var L="ScrollAreaViewport",I=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:i,nonce:r,...s}=e,o=R(L,n),l=m(t,d.useRef(null),o.onViewportChange);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,c.jsx)(y.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,c.jsx)("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});I.displayName=L;var B="ScrollAreaScrollbar",z=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=R(B,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:o}=r,l="horizontal"===e.orientation;return d.useEffect(()=>(l?s(!0):o(!0),()=>{l?s(!1):o(!1)}),[l,s,o]),"hover"===r.type?(0,c.jsx)(F,{...i,ref:t,forceMount:n}):"scroll"===r.type?(0,c.jsx)(_,{...i,ref:t,forceMount:n}):"auto"===r.type?(0,c.jsx)(W,{...i,ref:t,forceMount:n}):"always"===r.type?(0,c.jsx)(V,{...i,ref:t}):null});z.displayName=B;var F=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=R(B,e.__scopeScrollArea),[s,o]=d.useState(!1);return d.useEffect(()=>{let e=r.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},i=()=>{t=window.setTimeout(()=>o(!1),r.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",i),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",i)}}},[r.scrollArea,r.scrollHideDelay]),(0,c.jsx)(k,{present:n||s,children:(0,c.jsx)(W,{"data-state":s?"visible":"hidden",...i,ref:t})})}),_=d.forwardRef((e,t)=>{var n;let{forceMount:i,...r}=e,s=R(B,e.__scopeScrollArea),o="horizontal"===e.orientation,l=eo(()=>h("SCROLL_END"),100),[a,h]=(n={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},d.useReducer((e,t)=>{let i=n[e][t];return null!=i?i:e},"hidden"));return d.useEffect(()=>{if("idle"===a){let e=window.setTimeout(()=>h("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(e)}},[a,s.scrollHideDelay,h]),d.useEffect(()=>{let e=s.viewport,t=o?"scrollLeft":"scrollTop";if(e){let n=e[t],i=()=>{let i=e[t];n!==i&&(h("SCROLL"),l()),n=i};return e.addEventListener("scroll",i),()=>e.removeEventListener("scroll",i)}},[s.viewport,o,h,l]),(0,c.jsx)(k,{present:i||"hidden"!==a,children:(0,c.jsx)(V,{"data-state":"hidden"===a?"hidden":"visible",...r,ref:t,onPointerEnter:O(e.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:O(e.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),W=d.forwardRef((e,t)=>{let n=R(B,e.__scopeScrollArea),{forceMount:i,...r}=e,[s,o]=d.useState(!1),l="horizontal"===e.orientation,a=eo(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(l?e:t)}},10);return el(n.viewport,a),el(n.content,a),(0,c.jsx)(k,{present:i||s,children:(0,c.jsx)(V,{"data-state":s?"visible":"hidden",...r,ref:t})})}),V=d.forwardRef((e,t)=>{let{orientation:n="vertical",...i}=e,r=R(B,e.__scopeScrollArea),s=d.useRef(null),o=d.useRef(0),[l,a]=d.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=et(l.viewport,l.content),u={...i,sizes:l,onSizesChange:a,hasThumb:!!(h>0&&h<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function f(e,t){return function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"ltr",r=en(n),s=t||r/2,o=n.scrollbar.paddingStart+s,l=n.scrollbar.size-n.scrollbar.paddingEnd-(r-s),a=n.content-n.viewport;return er([o,l],"ltr"===i?[0,a]:[-1*a,0])(e)}(e,o.current,l,t)}return"horizontal"===n?(0,c.jsx)(H,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&s.current){let e=ei(r.viewport.scrollLeft,l,r.dir);s.current.style.transform="translate3d(".concat(e,"px, 0, 0)")}},onWheelScroll:e=>{r.viewport&&(r.viewport.scrollLeft=e)},onDragScroll:e=>{r.viewport&&(r.viewport.scrollLeft=f(e,r.dir))}}):"vertical"===n?(0,c.jsx)(q,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&s.current){let e=ei(r.viewport.scrollTop,l);s.current.style.transform="translate3d(0, ".concat(e,"px, 0)")}},onWheelScroll:e=>{r.viewport&&(r.viewport.scrollTop=e)},onDragScroll:e=>{r.viewport&&(r.viewport.scrollTop=f(e))}}):null}),H=d.forwardRef((e,t)=>{let{sizes:n,onSizesChange:i,...r}=e,s=R(B,e.__scopeScrollArea),[o,l]=d.useState(),a=d.useRef(null),h=m(t,a,s.onScrollbarXChange);return d.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),(0,c.jsx)(J,{"data-orientation":"horizontal",...r,ref:h,sizes:n,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":en(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(s.viewport){let i=s.viewport.scrollLeft+t.deltaX;e.onWheelScroll(i),function(e,t){return e>0&&e<t}(i,n)&&t.preventDefault()}},onResize:()=>{a.current&&s.viewport&&o&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:ee(o.paddingLeft),paddingEnd:ee(o.paddingRight)}})}})}),q=d.forwardRef((e,t)=>{let{sizes:n,onSizesChange:i,...r}=e,s=R(B,e.__scopeScrollArea),[o,l]=d.useState(),a=d.useRef(null),h=m(t,a,s.onScrollbarYChange);return d.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),(0,c.jsx)(J,{"data-orientation":"vertical",...r,ref:h,sizes:n,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":en(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(s.viewport){let i=s.viewport.scrollTop+t.deltaY;e.onWheelScroll(i),function(e,t){return e>0&&e<t}(i,n)&&t.preventDefault()}},onResize:()=>{a.current&&s.viewport&&o&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:ee(o.paddingTop),paddingEnd:ee(o.paddingBottom)}})}})}),[K,U]=E(B),J=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:i,hasThumb:r,onThumbChange:s,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:h,onWheelScroll:u,onResize:f,...p}=e,g=R(B,n),[v,x]=d.useState(null),b=m(t,e=>x(e)),w=d.useRef(null),k=d.useRef(""),S=g.viewport,C=i.content-i.viewport,N=A(u),M=A(a),j=eo(f,10);function E(e){w.current&&h({x:e.clientX-w.current.left,y:e.clientY-w.current.top})}return d.useEffect(()=>{let e=e=>{let t=e.target;(null==v?void 0:v.contains(t))&&N(e,C)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[S,v,C,N]),d.useEffect(M,[i,M]),el(v,j),el(g.content,j),(0,c.jsx)(K,{scope:n,scrollbar:v,hasThumb:r,onThumbChange:A(s),onThumbPointerUp:A(o),onThumbPositionChange:M,onThumbPointerDown:A(l),children:(0,c.jsx)(y.div,{...p,ref:b,style:{position:"absolute",...p.style},onPointerDown:O(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),w.current=v.getBoundingClientRect(),k.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),E(e))}),onPointerMove:O(e.onPointerMove,E),onPointerUp:O(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=k.current,g.viewport&&(g.viewport.style.scrollBehavior=""),w.current=null})})})}),G="ScrollAreaThumb",Y=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=U(G,e.__scopeScrollArea);return(0,c.jsx)(k,{present:n||r.hasThumb,children:(0,c.jsx)(Q,{ref:t,...i})})}),Q=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:i,...r}=e,s=R(G,n),o=U(G,n),{onThumbPositionChange:l}=o,a=m(t,e=>o.onThumbChange(e)),h=d.useRef(void 0),u=eo(()=>{h.current&&(h.current(),h.current=void 0)},100);return d.useEffect(()=>{let e=s.viewport;if(e){let t=()=>{u(),h.current||(h.current=es(e,l),l())};return l(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[s.viewport,u,l]),(0,c.jsx)(y.div,{"data-state":o.hasThumb?"visible":"hidden",...r,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:O(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;o.onThumbPointerDown({x:n,y:i})}),onPointerUp:O(e.onPointerUp,o.onThumbPointerUp)})});Y.displayName=G;var X="ScrollAreaCorner",$=d.forwardRef((e,t)=>{let n=R(X,e.__scopeScrollArea),i=!!(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&i?(0,c.jsx)(Z,{...e,ref:t}):null});$.displayName=X;var Z=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,...i}=e,r=R(X,n),[s,o]=d.useState(0),[l,a]=d.useState(0),h=!!(s&&l);return el(r.scrollbarX,()=>{var e;let t=(null==(e=r.scrollbarX)?void 0:e.offsetHeight)||0;r.onCornerHeightChange(t),a(t)}),el(r.scrollbarY,()=>{var e;let t=(null==(e=r.scrollbarY)?void 0:e.offsetWidth)||0;r.onCornerWidthChange(t),o(t)}),h?(0,c.jsx)(y.div,{...i,ref:t,style:{width:s,height:l,position:"absolute",right:"ltr"===r.dir?0:void 0,left:"rtl"===r.dir?0:void 0,bottom:0,...e.style}}):null});function ee(e){return e?parseInt(e,10):0}function et(e,t){let n=e/t;return isNaN(n)?0:n}function en(e){let t=et(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-n)*t,18)}function ei(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"ltr",i=en(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-r,o=t.content-t.viewport,l=function(e,t){let[n,i]=t;return Math.min(i,Math.max(n,e))}(e,"ltr"===n?[0,o]:[-1*o,0]);return er([0,o],[0,s-i])(l)}function er(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}var es=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n={left:e.scrollLeft,top:e.scrollTop},i=0;return!function r(){let s={left:e.scrollLeft,top:e.scrollTop},o=n.left!==s.left,l=n.top!==s.top;(o||l)&&t(),n=s,i=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(i)};function eo(e,t){let n=A(e),i=d.useRef(0);return d.useEffect(()=>()=>window.clearTimeout(i.current),[]),d.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(n,t)},[n,t])}function el(e,t){let n=A(t);w(()=>{let t=0;if(e){let i=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(t),i.unobserve(e)}}},[e,n])}function ea(){for(var e,t,n=0,i="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=function e(t){var n,i,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t)){var s=t.length;for(n=0;n<s;n++)t[n]&&(i=e(t[n]))&&(r&&(r+=" "),r+=i)}else for(i in t)t[i]&&(r&&(r+=" "),r+=i);return r}(e))&&(i&&(i+=" "),i+=t);return i}let eh=(e,t)=>{var n;if(0===e.length)return t.classGroupId;let i=e[0],r=t.nextPart.get(i),s=r?eh(e.slice(1),r):void 0;if(s)return s;if(0===t.validators.length)return;let o=e.join("-");return null==(n=t.validators.find(e=>{let{validator:t}=e;return t(o)}))?void 0:n.classGroupId},ec=/^\[(.+)\]$/,ed=(e,t,n,i)=>{e.forEach(e=>{if("string"==typeof e){(""===e?t:eu(t,e)).classGroupId=n;return}if("function"==typeof e)return ef(e)?void ed(e(i),t,n,i):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(e=>{let[r,s]=e;ed(s,eu(t,r),n,i)})})},eu=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},ef=e=>e.isThemeGetter,ep=/\s+/;function em(){let e,t,n=0,i="";for(;n<arguments.length;)(e=arguments[n++])&&(t=eg(e))&&(i&&(i+=" "),i+=t);return i}let eg=e=>{let t;if("string"==typeof e)return e;let n="";for(let i=0;i<e.length;i++)e[i]&&(t=eg(e[i]))&&(n&&(n+=" "),n+=t);return n},ev=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},ex=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,eb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ey=/^\d+\/\d+$/,ew=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ek=/\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$/,eS=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,eC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,eA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,eN=e=>ey.test(e),eM=e=>!!e&&!Number.isNaN(Number(e)),eO=e=>!!e&&Number.isInteger(Number(e)),ej=e=>e.endsWith("%")&&eM(e.slice(0,-1)),eE=e=>ew.test(e),eT=()=>!0,eD=e=>ek.test(e)&&!eS.test(e),eR=()=>!1,eP=e=>eC.test(e),eL=e=>eA.test(e),eI=e=>!ez(e)&&!eq(e),eB=e=>eX(e,e1,eR),ez=e=>ex.test(e),eF=e=>eX(e,e2,eD),e_=e=>eX(e,e3,eM),eW=e=>eX(e,eZ,eR),eV=e=>eX(e,e0,eL),eH=e=>eX(e,e5,eP),eq=e=>eb.test(e),eK=e=>e$(e,e2),eU=e=>e$(e,e4),eJ=e=>e$(e,eZ),eG=e=>e$(e,e1),eY=e=>e$(e,e0),eQ=e=>e$(e,e5,!0),eX=(e,t,n)=>{let i=ex.exec(e);return!!i&&(i[1]?t(i[1]):n(i[2]))},e$=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=eb.exec(e);return!!i&&(i[1]?t(i[1]):n)},eZ=e=>"position"===e||"percentage"===e,e0=e=>"image"===e||"url"===e,e1=e=>"length"===e||"size"===e||"bg-size"===e,e2=e=>"length"===e,e3=e=>"number"===e,e4=e=>"family-name"===e,e5=e=>"shadow"===e;Symbol.toStringTag;let e8=function(e){let t,n,i;for(var r=arguments.length,s=Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];let l=function(r){let o;return n=(t={cache:(e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,i=new Map,r=(r,s)=>{n.set(r,s),++t>e&&(t=0,i=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=i.get(e))?(r(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):r(e,t)}}})((o=s.reduce((e,t)=>t(e),e())).cacheSize),parseClassName:(e=>{let{prefix:t,experimentalParseClassName:n}=e,i=e=>{let t,n,i=[],r=0,s=0,o=0;for(let n=0;n<e.length;n++){let l=e[n];if(0===r&&0===s){if(":"===l){i.push(e.slice(o,n)),o=n+1;continue}if("/"===l){t=n;continue}}"["===l?r++:"]"===l?r--:"("===l?s++:")"===l&&s--}let l=0===i.length?e:e.substring(o),a=(n=l).endsWith("!")?n.substring(0,n.length-1):n.startsWith("!")?n.substring(1):n;return{modifiers:i,hasImportantModifier:a!==l,baseClassName:a,maybePostfixModifierPosition:t&&t>o?t-o:void 0}};if(t){let e=t+":",n=i;i=t=>t.startsWith(e)?n(t.substring(e.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:t,maybePostfixModifierPosition:void 0}}if(n){let e=i;i=t=>n({className:t,parseClassName:e})}return i})(o),sortModifiers:(e=>{let t=Object.fromEntries(e.orderSensitiveModifiers.map(e=>[e,!0]));return e=>{if(e.length<=1)return e;let n=[],i=[];return e.forEach(e=>{"["===e[0]||t[e]?(n.push(...i.sort(),e),i=[]):i.push(e)}),n.push(...i.sort()),n}})(o),...(e=>{let t=(e=>{let{theme:t,classGroups:n}=e,i={nextPart:new Map,validators:[]};for(let e in n)ed(n[e],i,e,t);return i})(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=e;return{getClassGroupId:e=>{let n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),eh(n,t)||(e=>{if(ec.test(e)){let t=ec.exec(e)[1],n=null==t?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}})(e)},getConflictingClassGroupIds:(e,t)=>{let r=n[e]||[];return t&&i[e]?[...r,...i[e]]:r}}})(o)}).cache.get,i=t.cache.set,l=a,a(r)};function a(e){let r=n(e);if(r)return r;let s=((e,t)=>{let{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=t,o=[],l=e.trim().split(ep),a="";for(let e=l.length-1;e>=0;e-=1){let t=l[e],{isExternal:h,modifiers:c,hasImportantModifier:d,baseClassName:u,maybePostfixModifierPosition:f}=n(t);if(h){a=t+(a.length>0?" "+a:a);continue}let p=!!f,m=i(p?u.substring(0,f):u);if(!m){if(!p||!(m=i(u))){a=t+(a.length>0?" "+a:a);continue}p=!1}let g=s(c).join(":"),v=d?g+"!":g,x=v+m;if(o.includes(x))continue;o.push(x);let b=r(m,p);for(let e=0;e<b.length;++e){let t=b[e];o.push(v+t)}a=t+(a.length>0?" "+a:a)}return a})(e,t);return i(e,s),s}return function(){return l(em.apply(null,arguments))}}(()=>{let e=ev("color"),t=ev("font"),n=ev("text"),i=ev("font-weight"),r=ev("tracking"),s=ev("leading"),o=ev("breakpoint"),l=ev("container"),a=ev("spacing"),h=ev("radius"),c=ev("shadow"),d=ev("inset-shadow"),u=ev("text-shadow"),f=ev("drop-shadow"),p=ev("blur"),m=ev("perspective"),g=ev("aspect"),v=ev("ease"),x=ev("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...y(),eq,ez],k=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],C=()=>[eq,ez,a],A=()=>[eN,"full","auto",...C()],N=()=>[eO,"none","subgrid",eq,ez],M=()=>["auto",{span:["full",eO,eq,ez]},eO,eq,ez],O=()=>[eO,"auto",eq,ez],j=()=>["auto","min","max","fr",eq,ez],E=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],T=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...C()],R=()=>[eN,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],P=()=>[e,eq,ez],L=()=>[...y(),eJ,eW,{position:[eq,ez]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],B=()=>["auto","cover","contain",eG,eB,{size:[eq,ez]}],z=()=>[ej,eK,eF],F=()=>["","none","full",h,eq,ez],_=()=>["",eM,eK,eF],W=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[eM,ej,eJ,eW],q=()=>["","none",p,eq,ez],K=()=>["none",eM,eq,ez],U=()=>["none",eM,eq,ez],J=()=>[eM,eq,ez],G=()=>[eN,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[eE],breakpoint:[eE],color:[eT],container:[eE],"drop-shadow":[eE],ease:["in","out","in-out"],font:[eI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[eE],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[eE],shadow:[eE],spacing:["px",eM],text:[eE],"text-shadow":[eE],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",eN,ez,eq,g]}],container:["container"],columns:[{columns:[eM,ez,eq,l]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"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:w()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[eO,"auto",eq,ez]}],basis:[{basis:[eN,"full","auto",l,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[eM,eN,"auto","initial","none",ez]}],grow:[{grow:["",eM,eq,ez]}],shrink:[{shrink:["",eM,eq,ez]}],order:[{order:[eO,"first","last","none",eq,ez]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:M()}],"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":j()}],"auto-rows":[{"auto-rows":j()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...E(),"normal"]}],"justify-items":[{"justify-items":[...T(),"normal"]}],"justify-self":[{"justify-self":["auto",...T()]}],"align-content":[{content:["normal",...E()]}],"align-items":[{items:[...T(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...T(),{baseline:["","last"]}]}],"place-content":[{"place-content":E()}],"place-items":[{"place-items":[...T(),"baseline"]}],"place-self":[{"place-self":["auto",...T()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:R()}],w:[{w:[l,"screen",...R()]}],"min-w":[{"min-w":[l,"screen","none",...R()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...R()]}],h:[{h:["screen","lh",...R()]}],"min-h":[{"min-h":["screen","lh","none",...R()]}],"max-h":[{"max-h":["screen","lh",...R()]}],"font-size":[{text:["base",n,eK,eF]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,eq,e_]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ej,ez]}],"font-family":[{font:[eU,ez,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:[r,eq,ez]}],"line-clamp":[{"line-clamp":[eM,"none",eq,e_]}],leading:[{leading:[s,...C()]}],"list-image":[{"list-image":["none",eq,ez]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",eq,ez]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...W(),"wavy"]}],"text-decoration-thickness":[{decoration:[eM,"from-font","auto",eq,eF]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[eM,"auto",eq,ez]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",eq,ez]}],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",eq,ez]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:B()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},eO,eq,ez],radial:["",eq,ez],conic:[eO,eq,ez]},eY,eV]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...W(),"hidden","none"]}],"divide-style":[{divide:[...W(),"hidden","none"]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...W(),"none","hidden"]}],"outline-offset":[{"outline-offset":[eM,eq,ez]}],"outline-w":[{outline:["",eM,eK,eF]}],"outline-color":[{outline:P()}],shadow:[{shadow:["","none",c,eQ,eH]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":["none",d,eQ,eH]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[eM,eF]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":["none",u,eQ,eH]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[eM,eq,ez]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"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":[eM]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[eq,ez]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"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":y()}],"mask-image-conic-pos":[{"mask-conic":[eM]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:B()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",eq,ez]}],filter:[{filter:["","none",eq,ez]}],blur:[{blur:q()}],brightness:[{brightness:[eM,eq,ez]}],contrast:[{contrast:[eM,eq,ez]}],"drop-shadow":[{"drop-shadow":["","none",f,eQ,eH]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:["",eM,eq,ez]}],"hue-rotate":[{"hue-rotate":[eM,eq,ez]}],invert:[{invert:["",eM,eq,ez]}],saturate:[{saturate:[eM,eq,ez]}],sepia:[{sepia:["",eM,eq,ez]}],"backdrop-filter":[{"backdrop-filter":["","none",eq,ez]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[eM,eq,ez]}],"backdrop-contrast":[{"backdrop-contrast":[eM,eq,ez]}],"backdrop-grayscale":[{"backdrop-grayscale":["",eM,eq,ez]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[eM,eq,ez]}],"backdrop-invert":[{"backdrop-invert":["",eM,eq,ez]}],"backdrop-opacity":[{"backdrop-opacity":[eM,eq,ez]}],"backdrop-saturate":[{"backdrop-saturate":[eM,eq,ez]}],"backdrop-sepia":[{"backdrop-sepia":["",eM,eq,ez]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",eq,ez]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[eM,"initial",eq,ez]}],ease:[{ease:["linear","initial",v,eq,ez]}],delay:[{delay:[eM,eq,ez]}],animate:[{animate:["none",x,eq,ez]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,eq,ez]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":["scale-3d"],skew:[{skew:J()}],"skew-x":[{"skew-x":J()}],"skew-y":[{"skew-y":J()}],transform:[{transform:[eq,ez,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:G()}],"translate-x":[{"translate-x":G()}],"translate-y":[{"translate-y":G()}],"translate-z":[{"translate-z":G()}],"translate-none":["translate-none"],accent:[{accent:P()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:P()}],"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",eq,ez]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",eq,ez]}],fill:[{fill:["none",...P()]}],"stroke-w":[{stroke:[eM,eK,eF,e_]}],stroke:[{stroke:["none",...P()]}],"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-x","border-w-y","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-x","border-color-y","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"],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-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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function e6(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return e8(ea(t))}function e9(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}let e7=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsxs)(P,{ref:t,className:e6("relative overflow-hidden",n),...r,children:[(0,c.jsx)(I,{className:"h-full w-full rounded-[inherit]",children:i}),(0,c.jsx)(te,{}),(0,c.jsx)($,{})]})});e7.displayName=P.displayName;let te=d.forwardRef((e,t)=>{let{className:n,orientation:i="vertical",...r}=e;return(0,c.jsx)(z,{ref:t,orientation:i,className:e6("flex touch-none select-none transition-colors","vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...r,children:(0,c.jsx)(Y,{className:"relative flex-1 rounded-full bg-border"})})});te.displayName=z.displayName;let tt=e=>"boolean"==typeof e?"".concat(e):0===e?"0":e,tn=(e,t)=>n=>{var i;if((null==t?void 0:t.variants)==null)return ea(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:r,defaultVariants:s}=t,o=Object.keys(r).map(e=>{let t=null==n?void 0:n[e],i=null==s?void 0:s[e];if(null===t)return null;let o=tt(t)||tt(i);return r[e][o]}),l=n&&Object.entries(n).reduce((e,t)=>{let[n,i]=t;return void 0===i||(e[n]=i),e},{});return ea(e,o,null==t||null==(i=t.compoundVariants)?void 0:i.reduce((e,t)=>{let{class:n,className:i,...r}=t;return Object.entries(r).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...s,...l}[t]):({...s,...l})[t]===n})?[...e,n,i]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)},ti=tn("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),tr=d.forwardRef((e,t)=>{let{className:n,variant:i,size:r,asChild:s=!1,...o}=e;return(0,c.jsx)(s?v:"button",{className:e6(ti({variant:i,size:r,className:n})),ref:t,...o})});tr.displayName="Button";let ts=tn("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function to(e){let{className:t,variant:n,...i}=e;return(0,c.jsx)("div",{className:e6(ts({variant:n}),t),...i})}let tl=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},ta=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim()};var th={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"};let tc=(0,d.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:o="",children:l,iconNode:a,...h}=e;return(0,d.createElement)("svg",{ref:t,...th,width:i,height:i,stroke:n,strokeWidth:s?24*Number(r)/Number(i):r,className:ta("lucide",o),...!l&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(h)&&{"aria-hidden":"true"},...h},[...a.map(e=>{let[t,n]=e;return(0,d.createElement)(t,n)}),...Array.isArray(l)?l:[l]])}),td=(e,t)=>{let n=(0,d.forwardRef)((n,i)=>{let{className:r,...s}=n;return(0,d.createElement)(tc,{ref:i,iconNode:t,className:ta("lucide-".concat(tl(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),r),...s})});return n.displayName=tl(e),n},tu=td("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),tf=td("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),tp=td("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),tm=td("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),tg=td("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"}]]),tv=td("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),tx=td("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),tb=td("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function ty(e){let{files:t,selectedFile:n,onFileSelect:i,loading:r,error:s,onRefresh:o}=e;if(r)return(0,c.jsxs)("div",{className:"p-4 text-center text-muted-foreground",children:[(0,c.jsx)(tu,{className:"h-6 w-6 animate-spin mx-auto mb-2"}),"로딩 중..."]});if(s)return(0,c.jsxs)("div",{className:"p-4 text-center",children:[(0,c.jsx)(tf,{className:"h-6 w-6 text-destructive mx-auto mb-2"}),(0,c.jsx)("p",{className:"text-sm text-destructive mb-2",children:s}),(0,c.jsx)(tr,{onClick:o,size:"sm",children:"다시 시도"})]});let l=(()=>{let e=[],n=t.filter(e=>{var t;return(null==(t=e.parsedInfo)?void 0:t.type)==="REQ"}),i=t.filter(e=>{var t;return(null==(t=e.parsedInfo)?void 0:t.type)==="RES"});return n.forEach(t=>{let n;if(!t.parsedInfo)return;let r=t.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/);if(!r)return;let s=r[1],o=1/0;i.filter(e=>{var n,i;return(null==(n=e.parsedInfo)?void 0:n.component)===(null==(i=t.parsedInfo)?void 0:i.component)}).forEach(e=>{if(!e.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/))return;let i=new Date(t.parsedInfo.datetime).getTime(),r=new Date(e.parsedInfo.datetime).getTime(),s=Math.abs(r-i);r>=i&&s<o&&(o=s,n=e)}),e.push({id:"".concat(t.parsedInfo.component,"-").concat(s),component:t.parsedInfo.component,timestamp:t.parsedInfo.datetime,request:t,response:n})}),i.forEach(t=>{if(t.parsedInfo&&!e.some(e=>{var n;return(null==(n=e.response)?void 0:n.name)===t.name})){let n=t.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/),i=n?n[1]:Date.now().toString();e.push({id:"".concat(t.parsedInfo.component,"-").concat(i,"-res-only"),component:t.parsedInfo.component,timestamp:t.parsedInfo.datetime,response:t})}}),e.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())})().map((e,t)=>({...e,round:t+1}));return(0,c.jsxs)("div",{className:"p-4 space-y-4",children:[(0,c.jsxs)(tr,{onClick:o,variant:"outline",size:"sm",className:"w-full",children:[(0,c.jsx)(tu,{className:"h-4 w-4 mr-2"}),"새로고침"]}),(0,c.jsx)("div",{className:"space-y-3",children:l.map(e=>{var t,r;let s=(null==n?void 0:n.name)===(null==(t=e.request)?void 0:t.name),o=(null==n?void 0:n.name)===(null==(r=e.response)?void 0:r.name);return(0,c.jsxs)("div",{className:"border rounded-lg overflow-hidden",children:[(0,c.jsx)("div",{className:"bg-muted/30 px-4 py-2 border-b",children:(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(e=>{switch(null==e?void 0:e.toLowerCase()){case"orchestrator":return(0,c.jsx)(tv,{className:"h-4 w-4"});case"verifier":return(0,c.jsx)(tx,{className:"h-4 w-4"});default:return(0,c.jsx)(tb,{className:"h-4 w-4"})}})(e.component),(0,c.jsx)("span",{className:"text-sm font-medium",children:"orchestrator"===e.component?"오케스트레이터":"verifier"===e.component?"검증기":e.component})]}),(0,c.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,c.jsxs)(to,{variant:"outline",className:"text-xs",children:["#",e.round,"회차"]})})]})}),(0,c.jsxs)("div",{className:"p-3 space-y-2",children:[e.request&&(0,c.jsxs)("div",{className:e6("p-3 rounded-md border cursor-pointer transition-all duration-200 flex items-center justify-between",s?"bg-primary text-primary-foreground border-primary shadow-sm":"hover:bg-muted/50 border-border hover:border-border/80"),onClick:()=>i(e.request),children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 text-xs font-medium flex items-center gap-1",children:[(0,c.jsx)(tm,{className:"h-3 w-3"}),"요청"]})}),(0,c.jsx)("div",{className:"text-xs opacity-60",children:e9(e.request.size)})]}),e.response?(0,c.jsxs)("div",{className:e6("p-3 rounded-md border cursor-pointer transition-all duration-200 flex items-center justify-between",o?"bg-primary text-primary-foreground border-primary shadow-sm":"hover:bg-muted/50 border-border hover:border-border/80"),onClick:()=>i(e.response),children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{className:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 text-xs font-medium flex items-center gap-1",children:[(0,c.jsx)(tg,{className:"h-3 w-3"}),"응답"]})}),(0,c.jsx)("div",{className:"text-xs opacity-60",children:e9(e.response.size)})]}):e.request&&(0,c.jsx)("div",{className:"p-3 rounded-md border border-dashed border-muted-foreground/30 text-center text-muted-foreground",children:(0,c.jsx)("div",{className:"text-xs",children:"응답 대기 중..."})})]})]},e.id)})}),0===t.length&&(0,c.jsxs)("div",{className:"text-center text-muted-foreground p-8",children:[(0,c.jsx)(tp,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),(0,c.jsx)("h4",{className:"font-medium text-sm mb-1",children:"로그 파일 없음"}),(0,c.jsx)("p",{className:"text-xs opacity-70",children:"AI Agent가 실행되면 로그가 생성됩니다"})]})]})}let tw=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("rounded-lg border bg-card text-card-foreground shadow-sm",n),...i})});tw.displayName="Card";let tk=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("flex flex-col space-y-1.5 p-6",n),...i})});tk.displayName="CardHeader";let tS=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("h3",{ref:t,className:e6("text-2xl font-semibold leading-none tracking-tight",n),...i})});tS.displayName="CardTitle";let tC=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("p",{ref:t,className:e6("text-sm text-muted-foreground",n),...i})});tC.displayName="CardDescription";let tA=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("p-6 pt-0",n),...i})});tA.displayName="CardContent",d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("flex items-center p-6 pt-0",n),...i})}).displayName="CardFooter";var tN=d[" useId ".trim().toString()]||(()=>void 0),tM=0;function tO(e){let[t,n]=d.useState(tN());return w(()=>{e||n(e=>null!=e?e:String(tM++))},[e]),e||(t?"radix-".concat(t):"")}d[" useEffectEvent ".trim().toString()],d[" useInsertionEffect ".trim().toString()];var tj=d[" useInsertionEffect ".trim().toString()]||w;function tE(e){let{prop:t,defaultProp:n,onChange:i=()=>{},caller:r}=e,[s,o,l]=function(e){let{defaultProp:t,onChange:n}=e,[i,r]=d.useState(t),s=d.useRef(i),o=d.useRef(n);return tj(()=>{o.current=n},[n]),d.useEffect(()=>{if(s.current!==i){var e;null==(e=o.current)||e.call(o,i),s.current=i}},[i,s]),[i,r,o]}({defaultProp:n,onChange:i}),a=void 0!==t,h=a?t:s;{let e=d.useRef(void 0!==t);d.useEffect(()=>{let t=e.current;if(t!==a){let e=a?"controlled":"uncontrolled";console.warn("".concat(r," is changing from ").concat(t?"controlled":"uncontrolled"," to ").concat(e,". Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component."))}e.current=a},[a,r])}return[h,d.useCallback(e=>{if(a){let i="function"==typeof e?e(t):e;if(i!==t){var n;null==(n=l.current)||n.call(l,i)}}else o(e)},[a,t,o,l])]}Symbol("RADIX:SYNC_STATE");var tT="dismissableLayer.update",tD=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tR=d.forwardRef((e,t)=>{var n,i;let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:a,onInteractOutside:h,onDismiss:u,...f}=e,p=d.useContext(tD),[g,v]=d.useState(null),x=null!=(i=null==g?void 0:g.ownerDocument)?i:null==(n=globalThis)?void 0:n.document,[,b]=d.useState({}),w=m(t,e=>v(e)),k=Array.from(p.layers),[S]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),C=k.indexOf(S),N=g?k.indexOf(g):-1,M=p.layersWithOutsidePointerEventsDisabled.size>0,j=N>=C,E=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e),r=d.useRef(!1),s=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let t=function(){tL("dismissableLayer.pointerDownOutside",i,r,{discrete:!0})},r={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",s.current),s.current=t,n.addEventListener("click",s.current,{once:!0})):t()}else n.removeEventListener("click",s.current);r.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",s.current)}},[n,i]),{onPointerDownCapture:()=>r.current=!0}}(e=>{let t=e.target,n=[...p.branches].some(e=>e.contains(t));j&&!n&&(null==l||l(e),null==h||h(e),e.defaultPrevented||null==u||u())},x),T=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&tL("dismissableLayer.focusOutside",i,{originalEvent:e},{discrete:!1})};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,i]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{let t=e.target;![...p.branches].some(e=>e.contains(t))&&(null==a||a(e),null==h||h(e),e.defaultPrevented||null==u||u())},x);return!function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e);d.useEffect(()=>{let e=e=>{"Escape"===e.key&&i(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[i,n])}(e=>{N===p.layers.size-1&&(null==o||o(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))},x),d.useEffect(()=>{if(g)return r&&(0===p.layersWithOutsidePointerEventsDisabled.size&&(s=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(g)),p.layers.add(g),tP(),()=>{r&&1===p.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=s)}},[g,x,r,p]),d.useEffect(()=>()=>{g&&(p.layers.delete(g),p.layersWithOutsidePointerEventsDisabled.delete(g),tP())},[g,p]),d.useEffect(()=>{let e=()=>b({});return document.addEventListener(tT,e),()=>document.removeEventListener(tT,e)},[]),(0,c.jsx)(y.div,{...f,ref:w,style:{pointerEvents:M?j?"auto":"none":void 0,...e.style},onFocusCapture:O(e.onFocusCapture,T.onFocusCapture),onBlurCapture:O(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:O(e.onPointerDownCapture,E.onPointerDownCapture)})});function tP(){let e=new CustomEvent(tT);document.dispatchEvent(e)}function tL(e,t,n,i){let{discrete:r}=i,s=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});if(t&&s.addEventListener(e,t,{once:!0}),r)s&&u.flushSync(()=>s.dispatchEvent(o));else s.dispatchEvent(o)}tR.displayName="DismissableLayer",d.forwardRef((e,t)=>{let n=d.useContext(tD),i=d.useRef(null),r=m(t,i);return d.useEffect(()=>{let e=i.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,c.jsx)(y.div,{...e,ref:r})}).displayName="DismissableLayerBranch";var tI="focusScope.autoFocusOnMount",tB="focusScope.autoFocusOnUnmount",tz={bubbles:!1,cancelable:!0},tF=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:s,...o}=e,[l,a]=d.useState(null),h=A(r),u=A(s),f=d.useRef(null),p=m(t,e=>a(e)),g=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let e=function(e){if(g.paused||!l)return;let t=e.target;l.contains(t)?f.current=t:tV(f.current,{select:!0})},t=function(e){if(g.paused||!l)return;let t=e.relatedTarget;null!==t&&(l.contains(t)||tV(f.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&tV(l)});return l&&n.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[i,l,g.paused]),d.useEffect(()=>{if(l){tH.add(g);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(tI,tz);l.addEventListener(tI,h),l.dispatchEvent(t),t.defaultPrevented||(function(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=document.activeElement;for(let i of e)if(tV(i,{select:t}),document.activeElement!==n)return}(t_(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&tV(l))}return()=>{l.removeEventListener(tI,h),setTimeout(()=>{let t=new CustomEvent(tB,tz);l.addEventListener(tB,u),l.dispatchEvent(t),t.defaultPrevented||tV(null!=e?e:document.body,{select:!0}),l.removeEventListener(tB,u),tH.remove(g)},0)}}},[l,h,u,g]);let v=d.useCallback(e=>{if(!n&&!i||g.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){let t=e.currentTarget,[i,s]=function(e){let t=t_(e);return[tW(t,e),tW(t.reverse(),e)]}(t);i&&s?e.shiftKey||r!==s?e.shiftKey&&r===i&&(e.preventDefault(),n&&tV(s,{select:!0})):(e.preventDefault(),n&&tV(i,{select:!0})):r===t&&e.preventDefault()}},[n,i,g.paused]);return(0,c.jsx)(y.div,{tabIndex:-1,...o,ref:p,onKeyDown:v})});function t_(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function tW(e,t){for(let n of e)if(!function(e,t){let{upTo:n}=t;if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===n||e!==n);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function tV(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.focus){var n;let i=document.activeElement;e.focus({preventScroll:!0}),e!==i&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}tF.displayName="FocusScope";var tH=function(){let e=[];return{add(t){let n=e[0];t!==n&&(null==n||n.pause()),(e=tq(e,t)).unshift(t)},remove(t){var n;null==(n=(e=tq(e,t))[0])||n.resume()}}}();function tq(e,t){let n=[...e],i=n.indexOf(t);return -1!==i&&n.splice(i,1),n}var tK=d.forwardRef((e,t)=>{var n,i;let{container:r,...s}=e,[o,l]=d.useState(!1);w(()=>l(!0),[]);let a=r||o&&(null==(i=globalThis)||null==(n=i.document)?void 0:n.body);return a?u.default.createPortal((0,c.jsx)(y.div,{...s,ref:t}),a):null});tK.displayName="Portal";var tU=0;function tJ(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tG=function(){return(tG=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function tY(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}Object.create;Object.create;var tQ=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),tX="width-before-scroll-bar";function t$(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var tZ="undefined"!=typeof window?d.useLayoutEffect:d.useEffect,t0=new WeakMap;function t1(e){return e}var t2=function(e){void 0===e&&(e={});var t,n,i,r=(void 0===t&&(t=t1),n=[],i=!1,{read:function(){if(i)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:null},useMedium:function(e){var r=t(e,i);return n.push(r),function(){n=n.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(i=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){i=!0;var t=[];if(n.length){var r=n;n=[],r.forEach(e),t=n}var s=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(s)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}});return r.options=tG({async:!0,ssr:!1},e),r}(),t3=function(){},t4=d.forwardRef(function(e,t){var n,i,r,s,o=d.useRef(null),l=d.useState({onScrollCapture:t3,onWheelCapture:t3,onTouchMoveCapture:t3}),a=l[0],h=l[1],c=e.forwardProps,u=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,v=e.sideCar,x=e.noRelative,b=e.noIsolation,y=e.inert,w=e.allowPinchZoom,k=e.as,S=e.gapMode,C=tY(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=(n=[o,t],i=function(e){return n.forEach(function(t){return t$(t,e)})},(r=(0,d.useState)(function(){return{value:null,callback:i,facade:{get current(){return r.value},set current(value){var e=r.value;e!==value&&(r.value=value,r.callback(value,e))}}}})[0]).callback=i,s=r.facade,tZ(function(){var e=t0.get(s);if(e){var t=new Set(e),i=new Set(n),r=s.current;t.forEach(function(e){i.has(e)||t$(e,null)}),i.forEach(function(e){t.has(e)||t$(e,r)})}t0.set(s,n)},[n]),s),N=tG(tG({},C),a);return d.createElement(d.Fragment,null,m&&d.createElement(v,{sideCar:t2,removeScrollBar:p,shards:g,noRelative:x,noIsolation:b,inert:y,setCallbacks:h,allowPinchZoom:!!w,lockRef:o,gapMode:S}),c?d.cloneElement(d.Children.only(u),tG(tG({},N),{ref:A})):d.createElement(void 0===k?"div":k,tG({},N,{className:f,ref:A}),u))});t4.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},t4.classNames={fullWidth:tX,zeroRight:tQ};var t5=function(e){var t=e.sideCar,n=tY(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=t.read();if(!i)throw Error("Sidecar medium not found");return d.createElement(i,tG({},n))};t5.isSideCarExport=!0;var t8=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=o||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var i,r;(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),r=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(r)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t6=function(){var e=t8();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},t9=function(){var e=t6();return function(t){return e(t.styles,t.dynamic),null}},t7={left:0,top:0,right:0,gap:0},ne=function(e){return parseInt(e||"",10)||0},nt=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],r=t["padding"===e?"paddingRight":"marginRight"];return[ne(n),ne(i),ne(r)]},nn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return t7;var t=nt(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},ni=t9(),nr="data-scroll-locked",ns=function(e,t,n,i){var r=e.left,s=e.top,o=e.right,l=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(nr,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===n&&"\n padding-left: ".concat(r,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===n&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(tQ," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(tX," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(tQ," .").concat(tQ," {\n right: 0 ").concat(i,";\n }\n \n .").concat(tX," .").concat(tX," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(nr,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},no=function(){var e=parseInt(document.body.getAttribute(nr)||"0",10);return isFinite(e)?e:0},nl=function(){d.useEffect(function(){return document.body.setAttribute(nr,(no()+1).toString()),function(){var e=no()-1;e<=0?document.body.removeAttribute(nr):document.body.setAttribute(nr,e.toString())}},[])},na=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,r=void 0===i?"margin":i;nl();var s=d.useMemo(function(){return nn(r)},[r]);return d.createElement(ni,{styles:ns(s,!t,r,n?"":"!important")})},nh=!1;if("undefined"!=typeof window)try{var nc=Object.defineProperty({},"passive",{get:function(){return nh=!0,!0}});window.addEventListener("test",nc,nc),window.removeEventListener("test",nc,nc)}catch(e){nh=!1}var nd=!!nh&&{passive:!1},nu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},nf=function(e,t){var n=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),np(e,i)){var r=nm(e,i);if(r[1]>r[2])return!0}i=i.parentNode}while(i&&i!==n.body)return!1},np=function(e,t){return"v"===e?nu(t,"overflowY"):nu(t,"overflowX")},nm=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},ng=function(e,t,n,i,r){var s,o=(s=window.getComputedStyle(t).direction,"h"===e&&"rtl"===s?-1:1),l=o*i,a=n.target,h=t.contains(a),c=!1,d=l>0,u=0,f=0;do{if(!a)break;var p=nm(e,a),m=p[0],g=p[1]-p[2]-o*m;(m||g)&&np(e,a)&&(u+=g,f+=m);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!h&&a!==document.body||h&&(t.contains(a)||t===a))return d&&(r&&1>Math.abs(u)||!r&&l>u)?c=!0:!d&&(r&&1>Math.abs(f)||!r&&-l>f)&&(c=!0),c},nv=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nx=function(e){return[e.deltaX,e.deltaY]},nb=function(e){return e&&"current"in e?e.current:e},ny=0,nw=[];let nk=(i=function(e){var t=d.useRef([]),n=d.useRef([0,0]),i=d.useRef(),r=d.useState(ny++)[0],s=d.useState(t9)[0],o=d.useRef(e);d.useEffect(function(){o.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var t=(function(e,t,n){if(n||2==arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(nb),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,s=nv(e),l=n.current,a="deltaX"in e?e.deltaX:l[0]-s[0],h="deltaY"in e?e.deltaY:l[1]-s[1],c=e.target,d=Math.abs(a)>Math.abs(h)?"h":"v";if("touches"in e&&"h"===d&&"range"===c.type)return!1;var u=nf(d,c);if(!u)return!0;if(u?r=d:(r="v"===d?"h":"v",u=nf(d,c)),!u)return!1;if(!i.current&&"changedTouches"in e&&(a||h)&&(i.current=r),!r)return!0;var f=i.current||r;return ng(f,t,e,"h"===f?a:h,!0)},[]),a=d.useCallback(function(e){if(nw.length&&nw[nw.length-1]===s){var n="deltaY"in e?nx(e):nv(e),i=t.current.filter(function(t){var i;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(i=t.delta,i[0]===n[0]&&i[1]===n[1])})[0];if(i&&i.should){e.cancelable&&e.preventDefault();return}if(!i){var r=(o.current.shards||[]).map(nb).filter(Boolean).filter(function(t){return t.contains(e.target)});(r.length>0?l(e,r[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),h=d.useCallback(function(e,n,i,r){var s={name:e,delta:n,target:i,should:r,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(i)};t.current.push(s),setTimeout(function(){t.current=t.current.filter(function(e){return e!==s})},1)},[]),c=d.useCallback(function(e){n.current=nv(e),i.current=void 0},[]),u=d.useCallback(function(t){h(t.type,nx(t),t.target,l(t,e.lockRef.current))},[]),f=d.useCallback(function(t){h(t.type,nv(t),t.target,l(t,e.lockRef.current))},[]);d.useEffect(function(){return nw.push(s),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",a,nd),document.addEventListener("touchmove",a,nd),document.addEventListener("touchstart",c,nd),function(){nw=nw.filter(function(e){return e!==s}),document.removeEventListener("wheel",a,nd),document.removeEventListener("touchmove",a,nd),document.removeEventListener("touchstart",c,nd)}},[]);var p=e.removeScrollBar,m=e.inert;return d.createElement(d.Fragment,null,m?d.createElement(s,{styles:"\n .block-interactivity-".concat(r," {pointer-events: none;}\n .allow-interactivity-").concat(r," {pointer-events: all;}\n")}):null,p?d.createElement(na,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},t2.useMedium(i),t5);var nS=d.forwardRef(function(e,t){return d.createElement(t4,tG({},e,{ref:t,sideCar:nk}))});nS.classNames=t4.classNames;var nC=new WeakMap,nA=new WeakMap,nN={},nM=0,nO=function(e){return e&&(e.host||nO(e.parentNode))},nj=function(e,t,n,i){var r=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=nO(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});nN[n]||(nN[n]=new WeakMap);var s=nN[n],o=[],l=new Set,a=new Set(r),h=function(e){!e||l.has(e)||(l.add(e),h(e.parentNode))};r.forEach(h);var c=function(e){!e||a.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))c(e);else try{var t=e.getAttribute(i),r=null!==t&&"false"!==t,a=(nC.get(e)||0)+1,h=(s.get(e)||0)+1;nC.set(e,a),s.set(e,h),o.push(e),1===a&&r&&nA.set(e,!0),1===h&&e.setAttribute(n,"true"),r||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),l.clear(),nM++,function(){o.forEach(function(e){var t=nC.get(e)-1,r=s.get(e)-1;nC.set(e,t),s.set(e,r),t||(nA.has(e)||e.removeAttribute(i),nA.delete(e)),r||e.removeAttribute(n)}),--nM||(nC=new WeakMap,nC=new WeakMap,nA=new WeakMap,nN={})}},nE=function(e,t,n){void 0===n&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=t||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),nj(i,r,n,"aria-hidden")):function(){return null}},nT="Dialog",[nD,nR]=C(nT),[nP,nL]=nD(nT),nI=e=>{let{__scopeDialog:t,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:o=!0}=e,l=d.useRef(null),a=d.useRef(null),[h,u]=tE({prop:i,defaultProp:null!=r&&r,onChange:s,caller:nT});return(0,c.jsx)(nP,{scope:t,triggerRef:l,contentRef:a,contentId:tO(),titleId:tO(),descriptionId:tO(),open:h,onOpenChange:u,onOpenToggle:d.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};nI.displayName=nT;var nB="DialogTrigger",nz=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(nB,n),s=m(t,r.triggerRef);return(0,c.jsx)(y.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":n4(r.open),...i,ref:s,onClick:O(e.onClick,r.onOpenToggle)})});nz.displayName=nB;var nF="DialogPortal",[n_,nW]=nD(nF,{forceMount:void 0}),nV=e=>{let{__scopeDialog:t,forceMount:n,children:i,container:r}=e,s=nL(nF,t);return(0,c.jsx)(n_,{scope:t,forceMount:n,children:d.Children.map(i,e=>(0,c.jsx)(k,{present:n||s.open,children:(0,c.jsx)(tK,{asChild:!0,container:r,children:e})}))})};nV.displayName=nF;var nH="DialogOverlay",nq=d.forwardRef((e,t)=>{let n=nW(nH,e.__scopeDialog),{forceMount:i=n.forceMount,...r}=e,s=nL(nH,e.__scopeDialog);return s.modal?(0,c.jsx)(k,{present:i||s.open,children:(0,c.jsx)(nU,{...r,ref:t})}):null});nq.displayName=nH;var nK=g("DialogOverlay.RemoveScroll"),nU=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(nH,n);return(0,c.jsx)(nS,{as:nK,allowPinchZoom:!0,shards:[r.contentRef],children:(0,c.jsx)(y.div,{"data-state":n4(r.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),nJ="DialogContent",nG=d.forwardRef((e,t)=>{let n=nW(nJ,e.__scopeDialog),{forceMount:i=n.forceMount,...r}=e,s=nL(nJ,e.__scopeDialog);return(0,c.jsx)(k,{present:i||s.open,children:s.modal?(0,c.jsx)(nY,{...r,ref:t}):(0,c.jsx)(nQ,{...r,ref:t})})});nG.displayName=nJ;var nY=d.forwardRef((e,t)=>{let n=nL(nJ,e.__scopeDialog),i=d.useRef(null),r=m(t,n.contentRef,i);return d.useEffect(()=>{let e=i.current;if(e)return nE(e)},[]),(0,c.jsx)(nX,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault())})}),nQ=d.forwardRef((e,t)=>{let n=nL(nJ,e.__scopeDialog),i=d.useRef(!1),r=d.useRef(!1);return(0,c.jsx)(nX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var s,o;null==(s=e.onCloseAutoFocus)||s.call(e,t),t.defaultPrevented||(i.current||null==(o=n.triggerRef.current)||o.focus(),t.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:t=>{var s,o;null==(s=e.onInteractOutside)||s.call(e,t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(r.current=!0));let l=t.target;(null==(o=n.triggerRef.current)?void 0:o.contains(l))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&r.current&&t.preventDefault()}})}),nX=d.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...o}=e,l=nL(nJ,n),a=d.useRef(null),h=m(t,a);return d.useEffect(()=>{var e,t;let n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",null!=(e=n[0])?e:tJ()),document.body.insertAdjacentElement("beforeend",null!=(t=n[1])?t:tJ()),tU++,()=>{1===tU&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),tU--}},[]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(tF,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:(0,c.jsx)(tR,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":n4(l.open),...o,ref:h,onDismiss:()=>l.onOpenChange(!1)})}),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n9,{titleId:l.titleId}),(0,c.jsx)(n7,{contentRef:a,descriptionId:l.descriptionId})]})]})}),n$="DialogTitle",nZ=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n$,n);return(0,c.jsx)(y.h2,{id:r.titleId,...i,ref:t})});nZ.displayName=n$;var n0="DialogDescription",n1=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n0,n);return(0,c.jsx)(y.p,{id:r.descriptionId,...i,ref:t})});n1.displayName=n0;var n2="DialogClose",n3=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n2,n);return(0,c.jsx)(y.button,{type:"button",...i,ref:t,onClick:O(e.onClick,()=>r.onOpenChange(!1))})});function n4(e){return e?"open":"closed"}n3.displayName=n2;var n5="DialogTitleWarning",[n8,n6]=function(e,t){let n=d.createContext(t),i=e=>{let{children:t,...i}=e,r=d.useMemo(()=>i,Object.values(i));return(0,c.jsx)(n.Provider,{value:r,children:t})};return i.displayName=e+"Provider",[i,function(i){let r=d.useContext(n);if(r)return r;if(void 0!==t)return t;throw Error("`".concat(i,"` must be used within `").concat(e,"`"))}]}(n5,{contentName:nJ,titleName:n$,docsSlug:"dialog"}),n9=e=>{let{titleId:t}=e,n=n6(n5),i="`".concat(n.contentName,"` requires a `").concat(n.titleName,"` for the component to be accessible for screen reader users.\n\nIf you want to hide the `").concat(n.titleName,"`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/").concat(n.docsSlug);return d.useEffect(()=>{t&&(document.getElementById(t)||console.error(i))},[i,t]),null},n7=e=>{let{contentRef:t,descriptionId:n}=e,i=n6("DialogDescriptionWarning"),r="Warning: Missing `Description` or `aria-describedby={undefined}` for {".concat(i.contentName,"}.");return d.useEffect(()=>{var e;let i=null==(e=t.current)?void 0:e.getAttribute("aria-describedby");n&&i&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null};let ie=td("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),it=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(nq,{ref:t,className:e6("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i})});it.displayName=nq.displayName;let ii=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsxs)(nV,{children:[(0,c.jsx)(it,{}),(0,c.jsxs)(nG,{ref:t,className:e6("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...r,children:[i,(0,c.jsxs)(n3,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,c.jsx)(ie,{className:"h-4 w-4"}),(0,c.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});ii.displayName=nG.displayName;let ir=e=>{let{className:t,...n}=e;return(0,c.jsx)("div",{className:e6("flex flex-col space-y-1.5 text-center sm:text-left",t),...n})};ir.displayName="DialogHeader";let is=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(nZ,{ref:t,className:e6("text-lg font-semibold leading-none tracking-tight",n),...i})});is.displayName=nZ.displayName;let io=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(n1,{ref:t,className:e6("text-sm text-muted-foreground",n),...i})});io.displayName=n1.displayName;let il=async(e,t)=>fetch("".concat(window.location.origin).concat(e),t),ia=td("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),ih=td("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),ic=td("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),id=td("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),iu=td("tree-pine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]),ip=td("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),im=td("rectangle-ellipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);var ig=e.i(70703),iv=e.i(5766);let ix=td("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),ib=td("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),iy=td("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),iw=td("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),ik=td("trash-2",[["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"}]]),iS=td("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"}]]),iC=d.forwardRef((e,t)=>{let{className:n,type:i,...r}=e;return(0,c.jsx)("input",{type:i,className:e6("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n),ref:t,...r})});function iA(e){let{data:t,onChange:n,className:i,expandedNodes:r,onExpandedNodesChange:s,expandAllByDefault:o=!1}=e,[l,a]=d.useState(new Set),[h,u]=d.useState(null),f=r||l,p=s||a,[m,g]=d.useState(""),v=d.useCallback(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return null==e?[]:Object.entries(e).map(e=>{let[n,i]=e,r=[...t,n],s="string",o=[];return null===i?s="null":Array.isArray(i)?(s="array",o=i.map((e,t)=>{let n=[...r,t.toString()];return{key:t.toString(),value:e,type:"object"==typeof e&&null!==e?Array.isArray(e)?"array":"object":typeof e,path:n,children:"object"==typeof e&&null!==e?v(e,n):void 0}})):"object"==typeof i?(s="object",o=v(i,r)):s=typeof i,{key:n,value:i,type:s,path:r,children:o.length>0?o:void 0}})},[]),x=d.useMemo(()=>v(t),[t,v]);d.useEffect(()=>{if(o&&t&&x.length>0){let e=new Set,t=n=>{n.forEach(n=>{n.children&&n.children.length>0&&(e.add(n.path.join(".")),t(n.children))})};t(x),p(e)}},[o,t,x,p]);let b=e=>{try{let i=JSON.parse(JSON.stringify(t)),r=i;for(let t=0;t<e.length-1;t++)r=r[e[t]];let s=m;try{s=JSON.parse(m)}catch(e){s=m}r[e[e.length-1]]=s,n(i),u(null),g("")}catch(e){console.log("Failed to save edit:",e)}},y=()=>{u(null),g("")},w=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.path.join("."),s=f.has(r),o=h===r,l=e.children&&e.children.length>0;return(0,c.jsxs)("div",{className:"select-none",children:[(0,c.jsxs)("div",{className:e6("flex items-center gap-2 py-1 px-2 rounded hover:bg-muted/50 group","min-h-[32px]"),style:{paddingLeft:"".concat(20*i+8,"px")},children:[l?(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0",onClick:()=>(e=>{let t=new Set(f);t.has(e)?t.delete(e):t.add(e),p(t)})(r),children:s?(0,c.jsx)(ix,{className:"h-3 w-3"}):(0,c.jsx)(ib,{className:"h-3 w-3"})}):(0,c.jsx)("div",{className:"w-4"}),(0,c.jsxs)("span",{className:"font-medium text-sm min-w-0 flex-shrink-0",children:[e.key,":"]}),o?(0,c.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[(0,c.jsx)(iC,{value:m,onChange:e=>g(e.target.value),className:"h-6 text-xs",onKeyDown:t=>{"Enter"===t.key?b(e.path):"Escape"===t.key&&y()}}),(0,c.jsx)(tr,{size:"sm",className:"h-6 px-2",onClick:()=>b(e.path),children:"✓"}),(0,c.jsx)(tr,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:y,children:"✕"})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("span",{className:e6("text-sm font-mono flex-1",(e=>{switch(e){case"string":return"text-green-600 dark:text-green-400";case"number":return"text-blue-600 dark:text-blue-400";case"boolean":return"text-purple-600 dark:text-purple-400";case"null":return"text-gray-500 dark:text-gray-400";case"object":return"text-orange-600 dark:text-orange-400";case"array":return"text-indigo-600 dark:text-indigo-400";default:return"text-gray-600 dark:text-gray-300"}})(e.type)),children:((e,t)=>{if("string"===t)return'"'.concat(e,'"');if("null"===t)return"null";if("object"===t||"array"===t){let n=Array.isArray(e)?e.length:Object.keys(e||{}).length;return"".concat("array"===t?"[":"{").concat(n," item").concat(1!==n?"s":"").concat("array"===t?"]":"}")}return String(e)})(e.value,e.type)}),(0,c.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-1",children:[(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{var t;return t=e.value,void(u(r),g("string"==typeof t?t:JSON.stringify(t)))},title:"Edit",children:(0,c.jsx)(iy,{className:"h-3 w-3"})}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{var t;return t=e.path,void navigator.clipboard.writeText(t.join("."))},title:"Copy path",children:(0,c.jsx)(iS,{className:"h-3 w-3"})}),("object"===e.type||"array"===e.type)&&(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{let i="array"===e.type?"new_item":"new_key";((e,i,r)=>{let s=JSON.parse(JSON.stringify(t)),o=s;for(let t of e)o=o[t];Array.isArray(o)?o.push(r):o[i]=r,n(s)})(e.path,i,(e.type,""))},title:"Add item",children:(0,c.jsx)(iw,{className:"h-3 w-3"})}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>(e=>{let i=JSON.parse(JSON.stringify(t)),r=i;for(let t=0;t<e.length-1;t++)r=r[e[t]];Array.isArray(r)?r.splice(parseInt(e[e.length-1]),1):delete r[e[e.length-1]],n(i)})(e.path),title:"Delete",children:(0,c.jsx)(ik,{className:"h-3 w-3"})})]})]})]}),l&&s&&(0,c.jsx)("div",{children:e.children.map(e=>w(e,i+1))})]},r)};return(0,c.jsxs)("div",{className:e6("border rounded-lg overflow-hidden flex flex-col h-full",i),children:[(0,c.jsx)("div",{className:"bg-muted/30 px-3 py-2 border-b flex-shrink-0",children:(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsx)("span",{className:"text-sm font-medium",children:"JSON Tree Editor"}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>p(new Set),children:"Collapse All"}),(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{let e=new Set,t=n=>{n.forEach(n=>{n.children&&n.children.length>0&&(e.add(n.path.join(".")),t(n.children))})};t(x),p(e)},children:"Expand All"})]})]})}),(0,c.jsx)("div",{className:"flex-1 min-h-0 overflow-auto p-2 pb-8",children:x.map(e=>w(e))})]})}iC.displayName="Input";var iN=d.forwardRef((e,t)=>(0,c.jsx)(y.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null==(n=e.onMouseDown)||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));iN.displayName="Label";let iM=tn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),iO=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(iN,{ref:t,className:e6(iM(),n),...i})});function ij(){return(ij=Object.assign.bind()).apply(null,arguments)}iO.displayName=iN.displayName;let iE=[],iT=[];function iD(e){return e>=127462&&e<=127487}function iR(e,t,n){if(t==e.length)return t;t&&iL(e.charCodeAt(t))&&iI(e.charCodeAt(t-1))&&t--;let i=iP(e,t);for(t+=iB(i);t<e.length;){let r=iP(e,t);if(8205==i||8205==r||n&&function(e){if(e<768)return!1;for(let t=0,n=iE.length;;){let i=t+n>>1;if(e<iE[i])n=i;else{if(!(e>=iT[i]))return!0;t=i+1}if(t==n)return!1}}(r))t+=iB(r),i=r;else if(iD(r)){let n=0,i=t-2;for(;i>=0&&iD(iP(e,i));)n++,i-=2;if(n%2==0)break;t+=2}else break}return t}function iP(e,t){let n=e.charCodeAt(t);if(!iI(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return iL(i)?(n-55296<<10)+(i-56320)+65536:n}function iL(e){return e>=56320&&e<57344}function iI(e){return e>=55296&&e<56320}function iB(e){return e<65536?1:2}(()=>{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,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?iT:iE).push(n+=e[t])})();class iz{lineAt(e){if(e<0||e>this.length)throw RangeError("Invalid position ".concat(e," in document of length ").concat(this.length));return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError("Invalid line number ".concat(e," in ").concat(this.lines,"-line document"));return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=iU(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),i_.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;[e,t]=iU(this,e,t);let n=[];return this.decompose(e,t,n,0),i_.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),i=new iV(this),r=new iV(e);for(let e=t,s=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(s+=i.value.length,i.done||s>=n)return!0}}iter(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new iV(this,e)}iterRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new iH(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new iq(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new iF(e):i_.from(iF.split(e,[])):iz.empty}constructor(){}}class iF extends iz{get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let s=this.text[r],o=i+s.length;if((t?n:o)>=e)return new iK(i,o,n,s);i=o+1,n++}}decompose(e,t,n,i){var r;let s=e<=0&&t>=this.length?this:new iF((r=this.text,iW(r,[""],e,t)),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=iW(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new iF(t,e.length+s.length));else{let e=t.length>>1;n.push(new iF(t.slice(0,e)),new iF(t.slice(e)))}}else n.push(s)}replace(e,t,n){var i;if(!(n instanceof iF))return super.replace(e,t,n);[e,t]=iU(this,e,t);let r=iW(this.text,iW(n.text,(i=this.text,iW(i,[""],0,e))),t),s=this.length+n.length-(t-e);return r.length<=32?new iF(r,s):i_.from(iF.split(r,[]),s)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n";[e,t]=iU(this,e,t);let i="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>e&&s&&(i+=n),e<l&&t>r&&(i+=o.slice(Math.max(0,e-r),t-r)),r=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new iF(n,i)),n=[],i=-1);return i>-1&&t.push(new iF(n,i)),t}constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}}class i_ extends iz{lineInner(e,t,n,i){for(let r=0;;r++){let s=this.children[r],o=i+s.length,l=n+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,n,i);i=o+1,n=l+1}}decompose(e,t,n,i){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let r=i&(s<=e|2*(l>=t));s>=e&&l<=t&&!r?n.push(o):o.decompose(e-s,t-s,n,r)}s=l+1}}replace(e,t,n){if([e,t]=iU(this,e,t),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let s=this.children[i],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[i]=l,new i_(r,this.length-(t-e)+n.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,n)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n";[e,t]=iU(this,e,t);let i="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;s>e&&r&&(i+=n),e<l&&t>s&&(i+=o.sliceString(e-s,t-s,n)),s=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i_))return 0;let n=0,[i,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==s||r==o)return n;let l=this.children[i],a=e.children[r];if(l!=a)return n+l.scanIdentical(a,t);n+=l.length+1}}static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.reduce((e,t)=>e+t.length+1,-1),n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new iF(n,t)}let i=Math.max(32,n>>5),r=i<<1,s=i>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:i_.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let n;if(t.lines>r&&t instanceof i_)for(let n of t.children)e(n);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof iF&&l&&(n=h[h.length-1])instanceof iF&&t.lines+n.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new iF(n.text.concat(t.text),n.length+1+t.length)):(l+t.lines>i&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new i_(o,t)}constructor(e,t){for(let n of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=n.lines}}function iW(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9;for(let r=0,s=0,o=!0;s<e.length&&r<=i;s++){let l=e[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(t[t.length-1]+=l,o=!1):t.push(l)),r=a+1}return t}iz.empty=new iF([""],0);class iV{nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],s=r>>1,o=i instanceof iF?i.text.length:i.children.length;if(s==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof iF){let r=i.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof iF?r.text.length:r.children.length)<<1))}}}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof iF?e.text.length:e.children.length)<<1]}}class iH{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:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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}constructor(e,t,n){this.value="",this.done=!1,this.cursor=new iV(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}}class iq{next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,{done:t,lineBreak:n,value:i}=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=i,this.afterBreak=!1),this}get lineBreak(){return!1}constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}}"undefined"!=typeof Symbol&&(iz.prototype[Symbol.iterator]=function(){return this.iter()},iV.prototype[Symbol.iterator]=iH.prototype[Symbol.iterator]=iq.prototype[Symbol.iterator]=function(){return this});class iK{get length(){return this.to-this.from}constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}}function iU(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function iJ(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=!(arguments.length>3)||void 0===arguments[3]||arguments[3];return function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=!(arguments.length>3)||void 0===arguments[3]||arguments[3];return(n?iR:function(e,t,n){for(;t>0;){let i=iR(e,t-2,n);if(i<t)return i;t--}return 0})(e,t,i)}(e,t,n,i)}function iG(e,t){let n=e.charCodeAt(t);if(!(n>=55296&&n<56320)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return i>=56320&&i<57344?(n-55296<<10)+(i-56320)+65536:n}function iY(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(((e-=65536)>>10)+55296,(1023&e)+56320)}function iQ(e){return e<65536?1:2}let iX=/\r\n?|\n/;var i$=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(i$||(i$={}));class iZ{get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let r=this.sections[t++],s=this.sections[t++];s<0?(e(n,i,r),i+=r):i+=s,n+=r}}iterChangedRanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i3(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new iZ(e)}composeDesc(e){return this.empty?e:e.empty?this:i5(this,e)}mapDesc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:i4(this,e,t)}mapPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i$.Simple,i=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=i+o;if(l<0){if(a>e)return r+(e-i);r+=o}else{if(n!=i$.Simple&&a>=e&&(n==i$.TrackDel&&i<e&&a>e||n==i$.TrackBefore&&i<e||n==i$.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==i||t<0?r:r+l;r+=l}i=a}if(e>i)throw RangeError("Position ".concat(e," is out of range for changeset of length ").concat(i));return r}touchesRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;for(let n=0,i=0;n<this.sections.length&&i<=t;){let r=this.sections[n++],s=this.sections[n++],o=i+r;if(s>=0&&i<=t&&o>=e)return!(i<e)||!(o>t)||"cover";i=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new iZ(e)}static create(e){return new iZ(e)}constructor(e){this.sections=e}}class i0 extends iZ{apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return i3(this,(t,n,i,r,s)=>e=e.replace(i,i+(n-t),s),!1),e}mapDesc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i4(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,r=0;i<t.length;i+=2){let s=t[i],o=t[i+1];if(o>=0){t[i]=o,t[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(iz.empty);n.push(s?e.slice(r,r+s):iz.empty)}r+=s}return new i0(t,n)}compose(e){return this.empty?e:e.empty?this:i5(this,e,!0)}map(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:i4(this,e,t,!0)}iterChanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i3(this,e,t)}get desc(){return iZ.create(this.sections)}filter(e){let t=[],n=[],i=[],r=new i8(this);e:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,l-o);i1(i,e,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;i1(t,e,s),s>0&&i2(n,t,r.text),r.forward(e),o+=e}let a=e[s++];for(;o<a;){if(r.done)break e;let e=Math.min(r.len,a-o);i1(t,e,-1),i1(i,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),o+=e}}return{changes:new i0(t,n),filtered:iZ.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],r=[],s=0,o=null;function l(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e&&!i.length)return;s<t&&i1(i,t-s,-1);let n=new i0(i,r);o=o?o.compose(n.map(o)):n,i=[],r=[],s=0}return!function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof i0){if(a.length!=t)throw RangeError("Mismatched change set length (got ".concat(a.length,", expected ").concat(t,")"));l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError("Invalid change range ".concat(e," to ").concat(o," (in doc of length ").concat(t,")"));let c=h?"string"==typeof h?iz.of(h.split(n||iX)):h:iz.empty,d=c.length;if(e==o&&0==d)return;e<s&&l(),e>s&&i1(i,e-s,-1),i1(i,o-e,d),i2(r,i,c),s=o}}(e),l(!o),o}static empty(e){return new i0(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let r=e[i];if("number"==typeof r)t.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)t.push(r[0],0);else{for(;n.length<i;)n.push(iz.empty);n[i]=iz.of(r.slice(1)),t.push(r[0],n[i].length)}}return new i0(t,n)}static createSet(e,t){return new i0(e,t)}constructor(e,t){super(e),this.inserted=t}}function i1(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(0==t&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function i2(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(iz.empty);e.push(n)}}function i3(e,t,n){let i=e.inserted;for(let r=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,d=iz.empty;for(;h+=l,c+=a,a&&i&&(d=d.append(i[o-2>>1])),!n&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(r,h,s,c,d),r=h,s=c}}}function i4(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=[],s=i?[]:null,o=new i8(e),l=new i8(t);for(let e=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);i1(r,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let t=l.len;for(i1(r,l.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(i1(r,0,o.ins),s&&i2(s,r,o.text),e=o.i),o.forward(n),t-=n}l.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(-1==l.ins){let e=Math.min(n,l.len);t+=e,n-=e,l.forward(e)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;i1(r,t,e<o.i?o.ins:0),s&&e<o.i&&i2(s,r,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?i0.createSet(r,s):iZ.create(r);else throw Error("Mismatched change set lengths")}function i5(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],r=n?[]:null,s=new i8(e),o=new i8(t);for(let e=!1;;)if(s.done&&o.done)return r?i0.createSet(i,r):iZ.create(i);else if(0==s.ins)i1(i,s.len,0,e),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let t=Math.min(s.len2,o.len),n=i.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;i1(i,t,n,e),r&&n&&i2(r,i,o.text)}else -1==o.ins?(i1(i,s.off?0:s.len,t,e),r&&i2(r,i,s.textBit(t))):(i1(i,s.off?0:s.len,o.off?0:o.ins,e),r&&!o.off&&i2(r,i,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||i.length>n),s.forward2(t),o.forward(t)}else i1(i,0,o.ins,e),r&&i2(r,i,o.text),o.next()}class i8{next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?iz.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?iz.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}constructor(e){this.set=e,this.i=0,this.next()}}class i6{get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 0xffffff==e?void 0:e}map(e){let t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return this.empty?t=n=e.mapPos(this.from,i):(t=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),t==this.from&&n==this.to?this:new i6(t,n,this.flags)}extend(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e<=this.anchor&&t>=this.anchor)return i9.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return i9.range(this.anchor,n)}eq(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return i9.range(e.anchor,e.head)}static create(e,t,n){return new i6(e,t,n)}constructor(e,t,n){this.from=e,this.to=t,this.flags=n}}class i9{map(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return e.empty?this:i9.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new i9([this.main],0)}addRange(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return i9.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.mainIndex,n=this.ranges.slice();return n[t]=e,i9.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new i9(e.ranges.map(e=>i6.fromJSON(e)),e.main)}static single(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return new i9([i9.range(e,t)],0)}static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0==e.length)throw RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let r=e[i];if(r.empty?r.from<=n:r.from<n)return i9.normalized(e.slice(),t);n=r.to}return new i9(e,t)}static cursor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return i6.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:0xffffff)<<6)}static range(e,t,n,i){let r=(null!=n?n:0xffffff)<<6|(null==i?7:Math.min(6,i));return t<e?i6.create(t,e,48|r):i6.create(e,t,8*(t>e)|r)}static normalized(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],r=e[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let s=r.from,o=Math.max(i.to,r.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?i9.range(o,s):i9.range(s,o))}}return new i9(e,t)}constructor(e,t){this.ranges=e,this.mainIndex=t}}function i7(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError("Selection points outside of document")}let re=0;class rt{get reader(){return this}static define(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rt(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(!e.combine?rn:(e,t)=>e===t),!!e.static,e.enables)}of(e){return new ri([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ri(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ri(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=re++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}}function rn(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class ri{dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,s=e[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(t=e[n.id])?t:1)&1)==0&&h.push(e[n.id]);return{create:e=>(e.values[s]=n(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||rs(e,h)){let t=n(e);if(o?!rr(t,e.values[s],i):!i(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[r];if(null!=a){let r=rg(t,a);if(this.dependencies.every(n=>n instanceof rt?t.facet(n)===e.facet(n):!(n instanceof rl)||t.field(n,!1)==e.field(n,!1))||(o?rr(l=n(e),r,i):i(l=n(e),r)))return e.values[s]=r,0}else l=n(e);return e.values[s]=l,1}}}constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=re++}}function rr(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function rs(e,t){let n=!1;for(let i of t)1&rm(e,i)&&(n=!0);return n}let ro=rt.define({static:!0});class rl{static define(e){let t=new rl(re++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ro).find(e=>e.field==this);return((null==t?void 0:t.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 i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>{let i=e.facet(ro),r=n.facet(ro),s;return(s=i.find(e=>e.field==this))&&s!=r.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,ro.of({field:this,create:e})]}get extension(){return this}constructor(e,t,n,i,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}}let ra={lowest:4,low:3,default:2,high:1,highest:0};function rh(e){return t=>new rd(t,e)}let rc={highest:rh(ra.highest),high:rh(ra.high),default:rh(ra.default),low:rh(ra.low),lowest:rh(ra.lowest)};class rd{constructor(e,t){this.inner=e,this.prec=t}}class ru{of(e){return new rf(this,e)}reconfigure(e){return ru.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class rf{constructor(e,t){this.compartment=e,this.inner=t}}class rp{staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){var i,r,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(i=e,r=t,s=c,o=[[],[],[],[],[]],l=new Map,!function e(t,n){let i=l.get(t);if(null!=i){if(i<=n)return;let e=o[i].indexOf(t);e>-1&&o[i].splice(e,1),t instanceof rf&&s.delete(t.compartment)}if(l.set(t,n),Array.isArray(t))for(let i of t)e(i,n);else if(t instanceof rf){if(s.has(t.compartment))throw RangeError("Duplicate use of compartment in extensions");let i=r.get(t.compartment)||t.inner;s.set(t.compartment,i),e(i,n)}else if(t instanceof rd)e(t.inner,t.prec);else if(t instanceof rl)o[n].push(t),t.provides&&e(t.provides,n);else if(t instanceof ri)o[n].push(t),t.facet.extensions&&e(t.facet.extensions,ra.default);else{let i=t.extension;if(!i)throw Error("Unrecognized extension value in extension set (".concat(t,"). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks."));e(i,n)}}(i,ra.default),o.reduce((e,t)=>e.concat(t))))n instanceof rl?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let d=Object.create(null),u=[],f=[];for(let e of a)d[e.id]=f.length<<1,f.push(t=>e.slot(t));let p=null==n?void 0:n.config.facets;for(let e in h){let t=h[e],i=t[0].facet,r=p&&p[e]||[];if(t.every(e=>0==e.type))if(d[i.id]=u.length<<1|1,rn(r,t))u.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));u.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(d[e.id]=u.length<<1|1,u.push(e.value)):(d[e.id]=f.length<<1,f.push(t=>e.dynamicSlot(t)));d[i.id]=f.length<<1,f.push(e=>(function(e,t,n){let i=n.map(t=>e[t.id]),r=n.map(e=>e.type),s=i.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let n=[];for(let t=0;t<i.length;t++){let s=rg(e,i[t]);if(2==r[t])for(let e of s)n.push(e);else n.push(s)}return t.combine(n)}return{create(e){for(let t of i)rm(e,t);return e.values[o]=l(e),1},update(e,n){if(!rs(e,s))return 0;let i=l(e);return t.compare(i,e.values[o])?0:(e.values[o]=i,1)},reconfigure(e,r){let s=rs(e,i),a=r.config.facets[t.id],h=r.facet(t);if(a&&!s&&rn(n,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,i,t))}}return new rp(e,c,f.map(e=>e(d)),d,u,h)}constructor(e,t,n,i,r,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}}function rm(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function rg(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let rv=rt.define(),rx=rt.define({combine:e=>e.some(e=>e),static:!0}),rb=rt.define({combine:e=>e.length?e[0]:void 0,static:!0}),ry=rt.define(),rw=rt.define(),rk=rt.define(),rS=rt.define({combine:e=>!!e.length&&e[0]});class rC{static define(){return new rA}constructor(e,t){this.type=e,this.value=t}}class rA{of(e){return new rC(this,e)}}class rN{of(e){return new rM(this,e)}constructor(e){this.map=e}}class rM{map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new rM(this.type,t)}is(e){return this.type==e}static define(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rN(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}constructor(e,t){this.type=e,this.value=t}}rM.reconfigure=rM.define(),rM.appendConfig=rM.define();class rO{static create(e,t,n,i,r,s){return new rO(e,t,n,i,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let 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(e){let t=this.annotation(rO.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}constructor(e,t,n,i,r,s){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,n&&i7(n,t.newLength),r.some(e=>e.type==rO.time)||(this.annotations=r.concat(rO.time.of(Date.now())))}}function rj(e,t,n){var i;let r,s,o;return n?(r=t.changes,s=i0.empty(t.changes.length),o=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):null==(i=e.selection)?void 0:i.map(r),effects:rM.mapEffects(e.effects,r).concat(rM.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function rE(e,t,n){let i=t.selection,r=rD(t.annotations);return t.userEvent&&(r=r.concat(rO.userEvent.of(t.userEvent))),{changes:t.changes instanceof i0?t.changes:i0.of(t.changes||[],n,e.facet(rb)),selection:i&&(i instanceof i9?i:i9.single(i.anchor,i.head)),effects:rD(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}rO.time=rC.define(),rO.userEvent=rC.define(),rO.addToHistory=rC.define(),rO.remote=rC.define();let rT=[];function rD(e){return null==e?rT:Array.isArray(e)?e:[e]}var rR=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(rR||(rR={}));let rP=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{t=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class rL{field(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this.config.address[e.id];if(null==n){if(t)throw RangeError("Field is not present in this state");return}return rm(this,n),rg(this,n)}update(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function e(t,n,i){let r=rE(t,n.length?n[0]:{},t.doc.length);n.length&&!1===n[0].filter&&(i=!1);for(let e=1;e<n.length;e++){!1===n[e].filter&&(i=!1);let s=!!n[e].sequential;r=rj(r,rE(t,n[e],s?r.changes.newLength:t.doc.length),s)}let s=rO.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(rk),i=e;for(let r=n.length-1;r>=0;r--){let s=n[r](e);s&&Object.keys(s).length&&(i=rj(i,rE(t,s,e.changes.newLength),!0))}return i==e?e:rO.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(i?function(t){let n=t.startState,i=!0;for(let e of n.facet(ry)){let n=e(t);if(!1===n){i=!1;break}Array.isArray(n)&&(i=!0===i?n:function(e,t){let n=[];for(let i=0,r=0;;){let s,o;if(i<e.length&&(r==t.length||t[r]>=e[i]))s=e[i++],o=e[i++];else{if(!(r<t.length))return n;s=t[r++],o=t[r++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(i,n))}if(!0!==i){let e,r;if(!1===i)r=t.changes.invertedDesc,e=i0.empty(n.doc.length);else{let n=t.changes.filter(i);e=n.changes,r=n.filtered.mapDesc(n.changes).invertedDesc}t=rO.create(n,e,t.selection&&t.selection.map(r),rM.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let r=n.facet(rw);for(let i=r.length-1;i>=0;i--){let s=r[i](t);t=s instanceof rO?s:Array.isArray(s)&&1==s.length&&s[0]instanceof rO?s[0]:e(n,rD(s),!1)}return t}(s):s)}(this,t,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:r}=n;for(let t of e.effects)t.is(ru.reconfigure)?(n&&(r=new Map,n.compartments.forEach((e,t)=>r.set(t,e)),n=null),r.set(t.value.compartment,t.value.extension)):t.is(rM.reconfigure)?(n=null,i=t.value):t.is(rM.appendConfig)&&(n=null,i=rD(i).concat(t.value));t=n?e.startState.values.slice():new rL(n=rp.resolve(i,r,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(rx)?e.newSelection:e.newSelection.asSingle();new rL(n,e.newDoc,s,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:i9.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],s=rD(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),l=this.changes(o.changes),a=l.map(i);for(let e=0;e<n;e++)r[e]=r[e].map(a);let h=i.mapDesc(l,!0);r.push(o.range.map(h)),i=i.compose(a),s=rM.mapEffects(s,a).concat(rM.mapEffects(rD(o.effects),h))}return{changes:i,selection:i9.create(r,t.mainIndex),effects:s}}changes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e instanceof i0?e:i0.of(e,this.doc.length,this.facet(rL.lineSeparator))}toText(e){return iz.of(e.split(this.facet(rL.lineSeparator)||iX))}sliceDoc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.doc.length;return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(rm(this,t),rg(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof rl&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],s=e[t];i.push(r.init(e=>r.spec.fromJSON(s,e)))}}return rL.create({doc:e.doc,selection:i9.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=rp.resolve(e.extensions||[],new Map),n=e.doc instanceof iz?e.doc:iz.of((e.doc||"").split(t.staticFacet(rL.lineSeparator)||iX)),i=e.selection?e.selection instanceof i9?e.selection:i9.single(e.selection.anchor,e.selection.head):i9.single(0);return i7(i,n.length),t.staticFacet(rx)||(i=i.asSingle()),new rL(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(rL.tabSize)}get lineBreak(){return this.facet(rL.lineSeparator)||"\n"}get readOnly(){return this.facet(rS)}phrase(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(let t of this.facet(rL.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(e,t)=>{if("$"==t)return"$";let i=+(t||1);return!i||i>n.length?e:n[i-1]})),e}languageDataAt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[];for(let r of this.facet(rv))for(let s of r(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&i.push(s[e]);return i}charCategorizer(e){var n;return n=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return rR.Space;if(function(e){if(t)return t.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||rP.test(n)))return!0}return!1}(e))return rR.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return rR.Word;return rR.Other}}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-n,o=e-n;for(;s>0;){let e=iJ(t,s,!1);if(r(t.slice(e,s))!=rR.Word)break;s=e}for(;o<i;){let e=iJ(t,o);if(r(t.slice(o,e))!=rR.Word)break;o=e}return s==o?null:i9.range(s+n,o+n)}constructor(e,t,n,i,r,s){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)rm(this,e<<1);this.computeSlot=null}}function rI(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],s=i[e];if(void 0===s)i[e]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(n,e))i[e]=n[e](s,r);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}rL.allowMultipleSelections=rx,rL.tabSize=rt.define({combine:e=>e.length?e[0]:4}),rL.lineSeparator=rb,rL.readOnly=rS,rL.phrases=rt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),rL.languageData=rv,rL.changeFilter=ry,rL.transactionFilter=rw,rL.transactionExtender=rk,ru.reconfigure=rM.define();class rB{eq(e){return this==e}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return rz.create(e,t,this)}}rB.prototype.startSide=rB.prototype.endSide=0,rB.prototype.point=!1,rB.prototype.mapMode=i$.TrackDel;class rz{static create(e,t,n){return new rz(e,t,n)}constructor(e,t,n){this.from=e,this.to=t,this.value=n}}function rF(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class r_{get length(){return this.to[this.to.length-1]}findIndex(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n?this.to:this.from;for(let s=i,o=r.length;;){if(s==o)return s;let i=s+o>>1,l=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==s)return l>=0?s:o;l>=0?o=i:s=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,r);r<s;r++)if(!1===i(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let n=[],i=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,d,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(d=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<d))continue}else if((d=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||d==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-d||a.endSide-a.startSide)||(s<0&&(s=d),a.point&&(o=Math.max(o,u-d)),n.push(a),i.push(d-s),r.push(u-s))}return{mapped:n.length?new r_(i,r,n,o):null,pos:s}}constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}}class rW{static create(e,t,n,i){return new rW(e,t,n,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(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(n&&(t=t.slice().sort(rF)),this.isEmpty)return t.length?rW.of(t):this;let o=new rq(this,null,-1).goto(0),l=0,a=[],h=new rV;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||i>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||i>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(rz.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?rW.empty:this.nextLayer.update({add:a,filter:s,filterFrom:i,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=e.touchesRange(s,s+o.length);if(!1===l)i=Math.max(i,o.maxPoint),t.push(o),n.push(e.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,e);r&&(i=Math.max(i,r.maxPoint),t.push(r),n.push(l))}}let r=this.nextLayer.map(e);return 0==t.length?r:new rW(n,t,r||rW.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],s=this.chunk[i];if(t>=r&&e<=r+s.length&&!1===s.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return rK.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return rK.from(e).goto(t)}static compare(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),l=rH(s,o,n),a=new rJ(s,l,r),h=new rJ(o,l,r);n.iterGaps((e,t,n)=>rG(a,e,h,t,n,i)),n.empty&&0==n.length&&rG(a,0,h,0,0,i)}static eq(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null==i&&(i=0x3b9ac9ff);let r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=rH(r,s),l=new rJ(r,o,0).goto(n),a=new rJ(s,o,0).goto(n);for(;;){if(l.to!=a.to||!rY(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>i)return!0;l.next(),a.next()}}static spans(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=new rJ(e,null,r).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),r=s.pointFrom<t?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);i.point(o,e,s.point,n,r,s.pointRank),l=Math.min(s.openEnd(e),n.length)}else e>o&&(i.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new rV;for(let i of e instanceof rz?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(rF(t,i)>0)return e.slice().sort(rF);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return rW.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=rW.empty;i=i.nextLayer)t=new rW(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}}rW.empty=new rW([],[],null,-1),rW.empty.nextLayer=rW.empty;class rV{finishChunk(e){this.chunks.push(new r_(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=[])}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new rV)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&0>(e-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&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(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))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(rW.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=rW.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}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}}function rH(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=i.get(e.chunk[t]);null==s||(n?n.mapPos(s):s)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(s,s+e.chunk[t].length))||r.add(e.chunk[t])}return r}class rq{get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}}class rK{static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[];for(let r=0;r<e.length;r++)for(let s=e[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&i.push(new rq(s,t,n,r));return 1==i.length?i[0]:new rK(i)}get startSide(){return this.value?this.value.startSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rU(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--)rU(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)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(),rU(this.heap,0)}}constructor(e){this.heap=e}}function rU(e,t){for(let n=e[t];;){let i=(t<<1)+1;if(i>=e.length)break;let r=e[i];if(i+1<e.length&&r.compare(e[i+1])>=0&&(r=e[i+1],i++),0>n.compare(r))break;e[i]=n,e[t]=r,t=i}}class rJ{goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-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&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){rQ(this.active,e),rQ(this.activeTo,e),rQ(this.activeRank,e),this.minActive=r$(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||i-this.activeTo[t])>0;)t++;rX(this.active,t,n),rX(this.activeTo,t,i),rX(this.activeRank,t,r),e&&rX(e,t,this.cursor.from),this.minActive=r$(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&0>(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&rQ(n,i)}else if(this.cursor.value)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)if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[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}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=rK.from(e,t,n)}}function rG(e,t,n,i,r,s){e.goto(t),n.goto(i);let o=i+r,l=i,a=i-t;for(;;){let t=e.to+a-n.to,i=t||e.endSide-n.endSide,r=i<0?e.to+a:n.to,h=Math.min(r,o);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&rY(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(l,h,e.point,n.point):h>l&&!rY(e.active,n.active)&&s.compareRange(l,h,e.active,n.active),r>o)break;(t||e.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(r),l=r,i<=0&&e.next(),i>=0&&n.next()}}function rY(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function rQ(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function rX(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function r$(e,t){let n=-1,i=1e9;for(let r=0;r<t.length;r++)0>(t[r]-i||e[r].endSide-e[n].endSide)&&(n=r,i=t[r]);return n}function rZ(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=0;for(let r=0;r<n&&r<e.length;)9==e.charCodeAt(r)?(i+=t-i%t,r++):(i++,r=iJ(e,r));return i}function r0(e,t,n,i){for(let i=0,r=0;;){if(r>=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=iJ(e,i)}return!0===i?-1:e.length}let r1="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),r2="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r3="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class r4{getRules(){return this.rules.join("\n")}static newName(){let e=r3[r1]||1;return r3[r1]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[r2],r=n&&n.nonce;i?r&&i.setNonce(r):i=new r8(e,r),i.mount(Array.isArray(t)?t:[t],e)}constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}for(let t in e)!function e(t,r,s,o){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(t[0]+";");for(let n in r){let o=r[n];if(/&/.test(n))e(n.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((e,t)=>e.concat(t)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+n+") should be a primitive value.");e(i(n),o,l,h)}else null!=o&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((n&&!a&&!o?t.map(n):t).join(", ")+" {"+l.join(" ")+"}")}(i(t),e[t],this.rules)}}let r5=new Map;class r8{mount(e,t){let n=this.sheet,i=0,r=0;for(let t=0;t<e.length;t++){let s=e[t],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),n)for(let e=0;e<s.rules.length;e++)n.insertRule(s.rules[e],i++)}else{for(;r<o;)i+=this.modules[r++].rules.length;i+=s.rules.length,r++}}if(n)0>t.adoptedStyleSheets.indexOf(this.sheet)&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=r5.get(n);if(t)return e[r2]=t;this.sheet=new i.CSSStyleSheet,r5.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[r2]=this}}for(var r6={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},r9={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},r7="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),se="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),st=0;st<10;st++)r6[48+st]=r6[96+st]=String(st);for(var st=1;st<=24;st++)r6[st+111]="F"+st;for(var st=65;st<=90;st++)r6[st]=String.fromCharCode(st+32),r9[st]=String.fromCharCode(st);for(var sn in r6)r9.hasOwnProperty(sn)||(r9[sn]=r6[sn]);function si(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?e.setAttribute(i,r):null!=r&&(e[i]=r)}t++}for(;t<arguments.length;t++)!function e(t,n){if("string"==typeof n)t.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)t.appendChild(n);else if(Array.isArray(n))for(var i=0;i<n.length;i++)e(t,n[i]);else throw RangeError("Unsupported child node: "+n)}(e,arguments[t]);return e}function sr(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function ss(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function so(e,t){if(!t.anchorNode)return!1;try{return ss(e,t.anchorNode)}catch(e){return!1}}function sl(e){return 3==e.nodeType?sx(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function sa(e,t,n,i){return!!n&&(sd(e,t,n,i,-1)||sd(e,t,n,i,1))}function sh(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function sc(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function sd(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:su(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=sh(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType||1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?su(e):0}}}function su(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function sf(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function sp(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(t.width-e.offsetWidth))&&(n=1),(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(t.height-e.offsetHeight))&&(i=1),{scaleX:n,scaleY:i}}class sm{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?su(t):0),n,Math.min(e.focusOffset,n?su(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}}let sg=null;function sv(e){if(e.setActive)return e.setActive();if(sg)return e.focus(sg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==sg?{get preventScroll(){return sg={preventScroll:!0},!0}}:void 0),!sg){sg=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],r=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function sx(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=n||(n=document.createRange());return r.setEnd(e,i),r.setStart(e,t),r}function sb(e,t,n,i){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,e.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function sy(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function sw(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function sk(e,t){for(let n=e,i=t;;)if(3==n.nodeType&&i>0)return{node:n,offset:i};else if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;i=su(n=n.childNodes[i-1])}else{if(!n.parentNode||sc(n))return null;i=sh(n),n=n.parentNode}}function sS(e,t){for(let n=e,i=t;;)if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};else if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||sc(n))return null;i=sh(n)+1,n=n.parentNode}}class sC{static before(e,t){return new sC(e.parentNode,sh(e),t)}static after(e,t){return new sC(e.parentNode,sh(e)+1,t)}constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}}let sA=[];class sN{get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n=this.dom,i=null,r;for(let s of this.children){if(7&s.flags){if(!s.dom&&(r=i?i.nextSibling:n.firstChild)){let e=sN.get(r);(!e||!e.parent&&e.canReuseDOM(s))&&s.reuseDOM(r)}s.sync(e,t),s.flags&=-8}if(r=i?i.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&r!=s.dom&&(t.written=!0),s.dom.parentNode==n)for(;r&&r!=s.dom;)r=sM(r);else n.insertBefore(s.dom,r);i=s.dom}for((r=i?i.nextSibling:n.firstChild)&&t&&t.node==n&&(t.written=!0);r;)r=sM(r)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let i=0==su(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}n=i<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!sN.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let i=this.children[e];if(i.dom==n)return t;t+=i.length+i.breakAfter}}domBoundsAround(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=-1,r=-1,s=-1,o=-1;for(let l=0,a=n,h=n;l<this.children.length;l++){let n=this.children[l],c=a+n.length;if(a<e&&c>t)return n.domBoundsAround(e,t,a);if(c>=e&&-1==i&&(i=l,r=a),a>t&&n.dom.parentNode==this.dom){s=l,o=h;break}h=c,a=c+n.breakAfter}return{from:r,to:o<0?n+this.length:o,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sA;this.markDirty();for(let i=e;i<t;i++){let e=this.children[i];e.parent==this&&0>n.indexOf(e)&&e.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let e=0;e<n.length;e++)n[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length;return new sO(this.children,e,this.children.length)}childPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,i,r,s){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}constructor(){this.parent=null,this.dom=null,this.flags=2}}function sM(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}sN.prototype.breakAfter=0;class sO{findPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}}function sj(e,t,n,i,r,s,o,l,a){let{children:h}=e,c=h.length?h[t]:null,d=s.length?s[s.length-1]:null,u=d?d.breakAfter:o;if(!(t==i&&c&&!o&&!u&&s.length<2&&c.merge(n,r,s.length?d:null,0==n,l,a))){if(i<h.length){let e=h[i];e&&(r<e.length||e.breakAfter&&(null==d?void 0:d.breakAfter))?(t==i&&(e=e.split(r),r=0),!u&&d&&e.merge(0,r,d,!0,0,a)?s[s.length-1]=e:((r||e.children.length&&!e.children[0].length)&&e.merge(0,r,null,!1,0,a),s.push(e))):(null==e?void 0:e.breakAfter)&&(d?d.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,n>0&&(!o&&s.length&&c.merge(n,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(n<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(n,c.length,null,!1,l,0),t++));t<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[t].become(s[0]))t++,s.shift(),l=s.length?0:a;else break;!s.length&&t&&i<h.length&&!h[t-1].breakAfter&&h[i].merge(0,0,h[t-1],!1,l,a)&&t--,(t<i||s.length)&&e.replaceChildren(t,i,s)}}function sE(e,t,n,i,r,s){let o=e.childCursor(),{i:l,off:a}=o.findPos(n,1),{i:h,off:c}=o.findPos(t,-1),d=t-n;for(let e of i)d+=e.length;e.length+=d,sj(e,h,c,l,a,i,0,r,s)}let sT="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},sD="undefined"!=typeof document?document:{documentElement:{style:{}}},sR=/Edge\/(\d+)/.exec(sT.userAgent),sP=/MSIE \d/.test(sT.userAgent),sL=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sT.userAgent),sI=!!(sP||sL||sR),sB=!sI&&/gecko\/(\d+)/i.test(sT.userAgent),sz=!sI&&/Chrome\/(\d+)/.exec(sT.userAgent),sF="webkitFontSmoothing"in sD.documentElement.style,s_=!sI&&/Apple Computer/.test(sT.vendor),sW=s_&&(/Mobile\/\w+/.test(sT.userAgent)||sT.maxTouchPoints>2);var sV={mac:sW||/Mac/.test(sT.platform),windows:/Win/.test(sT.platform),linux:/Linux|X11/.test(sT.platform),ie:sI,ie_version:sP?sD.documentMode||6:sL?+sL[1]:sR?+sR[1]:0,gecko:sB,gecko_version:sB?+(/Firefox\/(\d+)/.exec(sT.userAgent)||[0,0])[1]:0,chrome:!!sz,chrome_version:sz?+sz[1]:0,ios:sW,android:/Android\b/.test(sT.userAgent),webkit:sF,safari:s_,webkit_version:sF?+(/\bAppleWebKit\/(\d+)/.exec(sT.userAgent)||[0,0])[1]:0,tabSize:null!=sD.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class sH extends sN{get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags)&&(!n||n instanceof sH&&!(this.length-(t-e)+n.length>256)&&!(8&n.flags))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new sH(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new sC(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let i=e.nodeValue.length;t>i&&(t=i);let r=t,s=t,o=0;0==t&&n<0||t==i&&n>=0?!(sV.chrome||sV.gecko)&&(t?(r--,o=1):s<i&&(s++,o=-1)):n<0?r--:s<i&&s++;let l=sx(e,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:n>=0)?0:l.length-1];return sV.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(l,e=>e.width)||a),o?sf(a,o<0):a||null}(this.dom,e,t)}constructor(e){super(),this.text=e}}class sq extends sN{setAttrs(e){if(sy(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,i,r,s){return(!n||!!(n instanceof sq&&n.mark.eq(this.mark))&&(!e||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(sE(this,e,t,n?n.children.slice():[],r-1,s-1),this.markDirty(),!0)}split(e){let t=[],n=0,i=-1,r=0;for(let s of this.children){let o=n+s.length;o>e&&t.push(n<e?s.split(e-n):s),i<0&&n>=e&&(i=r),n=o,r++}let s=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new sq(this.mark,t,s)}domAtPos(e){return sJ(this,e)}coordsAt(e,t){return sG(this,e,t)}constructor(e,t=[],n=0){for(let i of(super(),this.mark=e,this.children=t,this.length=n,t))i.setParent(this)}}class sK extends sN{static create(e,t,n){return new sK(e,t,n)}split(e){let t=sK.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,i,r,s){return(!n||n instanceof sK&&!!this.widget.compare(n.widget)&&(!(e>0)||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof sK&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return iz.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):iz.empty}domAtPos(e){return(this.length?0==e:this.side>0)?sC.before(this.dom):sC.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let s=this.side?this.side<0:e>0;for(let t=s?i.length-1:0;r=i[t],e>0?0!=t:t!=i.length-1&&!(r.top<r.bottom);t+=s?-1:1);return sf(r,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}}class sU extends sN{get length(){return 0}merge(){return!1}become(e){return e instanceof sU&&e.side==this.side}split(){return new sU(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?sC.before(this.dom):sC.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return iz.empty}get isHidden(){return!0}constructor(e){super(),this.side=e}}function sJ(e,t){let n=e.dom,{children:i}=e,r=0;for(let e=0;r<i.length;r++){let s=i[r],o=e+s.length;if(!(o==e&&0>=s.getSide())){if(t>e&&t<o&&s.dom.parentNode==n)return s.domAtPos(t-e);if(t<=e)break;e=o}}for(let e=r;e>0;e--){let t=i[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=r;e<i.length;e++){let t=i[e];if(t.dom.parentNode==n)return t.domAtPos(0)}return new sC(n,0)}function sG(e,t,n){let i=null,r=-1,s=null,o=-1;!function e(t,l){for(let a=0,h=0;a<t.children.length&&h<=l;a++){let c=t.children[a],d=h+c.length;d>=l&&(c.children.length?e(c,l-h):(!s||s.isHidden&&(n>0||function(e,t){let n=e.coordsAt(0,1),i=t.coordsAt(0,1);return n&&i&&i.top<n.bottom}(s,c)))&&(d>l||h==d&&c.getSide()>0)?(s=c,o=l-h):(h<l||h==d&&0>c.getSide()&&!c.isHidden)&&(i=c,r=l-h)),h=d}}(e,t);let l=(n<0?i:s)||i||s;return l?l.coordsAt(Math.max(0,l==i?r:o),n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=sl(t);return n[n.length-1]||null}(e)}function sY(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}sH.prototype.children=sK.prototype.children=sU.prototype.children=sA;let sQ=Object.create(null);function sX(e,t,n){if(e==t)return!0;e||(e=sQ),t||(t=sQ);let i=Object.keys(e),r=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let s of i)if(s!=n&&(-1==r.indexOf(s)||e[s]!==t[s]))return!1;return!0}function s$(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}class sZ{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var s0=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(s0||(s0={}));class s1 extends rB{get heightRelevant(){return!1}static mark(e){return new s2(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new s4(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,i;if(e.isBlockGap)n=-5e8,i=4e8;else{let{start:r,end:s}=s5(e,t);n=(r?t?-3e8:-1:5e8)-1,i=(s?t?2e8:1:-6e8)+1}return new s4(e,n,i,t,e.widget||null,!0)}static line(e){return new s3(e)}static set(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return rW.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}}s1.none=rW.empty;class s2 extends s1{eq(e){var t,n;return this==e||e instanceof s2&&this.tagName==e.tagName&&(this.class||(null==(t=this.attrs)?void 0:t.class))==(e.class||(null==(n=e.attrs)?void 0:n.class))&&sX(this.attrs,e.attrs,"class")}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e>=t)throw RangeError("Mark decorations may not be empty");return super.range(e,t)}constructor(e){let{start:t,end:n}=s5(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}}s2.prototype.point=!1;class s3 extends s1{eq(e){return e instanceof s3&&this.spec.class==e.spec.class&&sX(this.spec.attributes,e.spec.attributes)}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(t!=e)throw RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}constructor(e){super(-2e8,-2e8,null,e)}}s3.prototype.mapMode=i$.TrackBefore,s3.prototype.point=!0;class s4 extends s1{get type(){return this.startSide!=this.endSide?s0.WidgetRange:this.startSide<=0?s0.WidgetBefore:s0.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){var t,n;return e instanceof s4&&(t=this.widget,t==(n=e.widget)||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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)}constructor(e,t,n,i,r,s){super(t,n,r,e),this.block=i,this.isReplace=s,this.mapMode=i?t<=0?i$.TrackBefore:i$.TrackAfter:i$.TrackDel}}function s5(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function s8(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}s4.prototype.point=!0;class s6 extends sN{merge(e,t,n,i,r,s){if(n){if(!(n instanceof s6))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),sE(this,e,t,n?n.children.slice():[],r,s),!0}split(e){let t=new s6;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:i}=this.childPos(e);i&&(t.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let e=n;e<this.children.length;e++)t.append(this.children[e],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){sX(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){!function e(t,n,i){let r,{children:s}=t;i>0&&n instanceof sq&&s.length&&(r=s[s.length-1])instanceof sq&&r.mark.eq(n.mark)?e(r,n.children[0],i-1):(s.push(n),n.setParent(t)),t.length+=n.length}(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=sY(t,this.attrs||{})),n&&(this.attrs=sY({class:n},this.attrs||{}))}domAtPos(e){return sJ(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(sy(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(s$(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let i=this.dom.lastChild;for(;i&&sN.get(i)instanceof sq;)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&(null==(n=sN.get(i))?void 0:n.isEditable)==!1&&(!sV.ios||!this.children.some(e=>e instanceof sH))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof sH)||/[^ -~]/.test(n.text))return null;let i=sl(n.dom);if(1!=i.length)return null;e+=i[0].width,t=i[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=sG(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(2>Math.abs(t-e.lineHeight)&&e.textHeight<t){let i=(t-e.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return e instanceof s6&&0==this.children.length&&0==e.children.length&&sX(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,i=0;n<e.children.length;n++){let r=e.children[n],s=i+r.length;if(s>=t){if(r instanceof s6)return r;if(s>t)break}i=s+r.breakAfter}return null}constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}}class s9 extends sN{merge(e,t,n,i,r,s){return(!n||n instanceof s9&&!!this.widget.compare(n.widget)&&(!(e>0)||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?sC.before(this.dom):sC.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new s9(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return sA}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):iz.empty}domBoundsAround(){return null}become(e){return e instanceof s9&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof s7?null:sf(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t!=n&&(e<0?t<0:n>0)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}}class s7 extends sZ{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}constructor(e){super(),this.height=e}}class oe{posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof s9&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new s6),this.atCursorPos=!0),this.curLine}flushBuffer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.bufferMarks;this.pendingBuffer&&(this.curLine.append(ot(new sU(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof s9||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e),r=Math.min(i,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(ot(new sH(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=i<=r?0:t.length}}span(e,t,n,i){this.buildText(t-e,n,i),this.pos=t,this.openStart<0&&(this.openStart=i)}point(e,t,n,i,r,s){if(this.disallowBlockEffectsFor[s]&&n instanceof s4){if(n.block)throw RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=t-e;if(n instanceof s4)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new s9(n.widget||on.block,o,n));else{let s=sK.create(n.widget||on.inline,o,o?0:n.startSide),l=this.atCursorPos&&!s.isEditable&&r<=i.length&&(e<t||n.startSide>0),a=!s.isEditable&&(e<t||r>i.length||n.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),l&&(h.append(ot(new sU(1),i),r),r=i.length+Math.max(0,r-i.length)),h.append(ot(s,i),r),this.atCursorPos=a,this.pendingBuffer=a?e<t||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,i,r){let s=new oe(e,t,n,r);return s.openEnd=rW.spans(i,t,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}constructor(e,t,n,i){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}}function ot(e,t){for(let n of t)e=new sq(n,[e],e.length);return e}class on extends sZ{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}constructor(e){super(),this.tag=e}}on.inline=new on("span"),on.block=new on("div");var oi=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(oi||(oi={}));let or=oi.LTR,os=oi.RTL;function oo(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}let ol=oo("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),oa=oo("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),oh=Object.create(null),oc=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);oh[t]=n,oh[n]=-t}function od(e){return e<=247?ol[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?oa[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}let ou=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class of{get dir(){return this.level%2?os:or}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let r=-1;for(let s=0;s<e.length;s++){let o=e[s];if(o.from<=t&&o.to>=t){if(o.level==n)return s;(r<0||(0!=i?i<0?o.from<t:o.to>t:e[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}constructor(e,t,n){this.from=e,this.to=t,this.level=n}}let op=[];function om(e){return[new of(0,e,0)]}let og="",ov=rt.define(),ox=rt.define(),ob=rt.define(),oy=rt.define(),ow=rt.define(),ok=rt.define(),oS=rt.define(),oC=rt.define(),oA=rt.define(),oN=rt.define({combine:e=>e.some(e=>e)}),oM=rt.define({combine:e=>e.some(e=>e)}),oO=rt.define();class oj{map(e){return e.empty?this:new oj(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new oj(i9.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}constructor(e,t="nearest",n="nearest",i=5,r=5,s=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=s}}let oE=rM.define({map:(e,t)=>e.map(t)}),oT=rM.define();function oD(e,t,n){let i=e.facet(oy);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}let oR=rt.define({combine:e=>!e.length||e[0]}),oP=0,oL=rt.define({combine:e=>e.filter((t,n)=>{for(let i=0;i<n;i++)if(e[i].plugin==t.plugin)return!1;return!0})});class oI{of(e){return this.baseExtensions.concat(oL.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:n,eventObservers:i,provide:r,decorations:s}=t||{};return new oI(oP++,e,n,i,e=>{let t=[];return s&&t.push(o_.of(t=>{let n=t.plugin(e);return n?s(n):s1.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return oI.define((t,n)=>new e(t,n),t)}constructor(e,t,n,i,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(oL.of({plugin:this,arg:void 0}))}}class oB{get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(oD(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){oD(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null==(t=this.value)?void 0:t.destroy)try{this.value.destroy()}catch(t){oD(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}}let oz=rt.define(),oF=rt.define(),o_=rt.define(),oW=rt.define(),oV=rt.define(),oH=rt.define();function oq(e,t){let n=e.state.facet(oH);if(!n.length)return n;let i=n.map(t=>t instanceof Function?t(e):t),r=[];return rW.spans(i,t.from,t.to,{point(){},span(e,n,i,s){let o=e-t.from,l=n-t.from,a=r;for(let e=i.length-1;e>=0;e--,s--){let n=i[e].spec.bidiIsolate,r;if(null==n&&(n=function(e,t,n){for(let i=t;i<n;i++){let t=od(e.charCodeAt(i));if(1==t)break;if(2==t||4==t)return os}return or}(t.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==n)r.to=l,a=r.inner;else{let e={from:o,to:l,direction:n,inner:[]};a.push(e),a=e.inner}}}}),r}let oK=rt.define();function oU(e){let t=0,n=0,i=0,r=0;for(let s of e.state.facet(oK)){let o=s(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:t,right:n,top:i,bottom:r}}let oJ=rt.define();class oG{join(e){return new oG(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,r=0,s=0,o=0;;i++){let l=i==e.length?null:e[i],a=s-o,h=l?l.fromB:1e9;for(;r<t.length&&t[r]<h;){let e=t[r],i=t[r+1],s=Math.max(o,e),l=Math.min(h,i);if(s<=l&&new oG(s+a,l+a,s,l).addToSet(n),i>h)break;r+=2}if(!l)return n;new oG(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,o=l.toB}}constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}}class oY{static create(e,t,n){return new oY(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}constructor(e,t,n){for(let i of(this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=i0.empty(this.startState.doc.length),n))this.changes=this.changes.compose(i.changes);let i=[];this.changes.iterChangedRanges((e,t,n,r)=>i.push(new oG(e,t,n,r))),this.changedRanges=i}}class oQ extends sN{get length(){return this.view.state.doc.length}update(e){var t,n,i,r,s,o;let l,a,h=e.changedRanges;this.minWidth>0&&h.length&&(h.every(e=>{let{fromA:t,toA:n}=e;return n<this.minWidthFrom||t>this.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 c=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(t=this.domChanged)?void 0:t.newSel)?c=this.domChanged.newSel.head:(n=e.changes,i=this.hasComposition,l=!1,i&&n.iterChangedRanges((e,t)=>{e<i.to&&t>i.from&&(l=!0)}),l||e.selectionSet||(c=e.state.selection.main.head)));let d=c>-1?function(e,t,n){let i=oX(e,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||e.state.doc.sliceString(i.from,i.to)!=l)return null;let a=t.invertedDesc,h=new oG(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let t=r.parentNode;;t=t.parentNode){let n=sN.get(t);if(n instanceof sq)c.push({node:t,deco:n.mark});else{if(n instanceof s6||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:h,text:r,marks:c,line:t};if(t==e.contentDOM)return null;c.push({node:t,deco:new s2({inclusive:!0,attributes:function(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,c):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:n}=this.hasComposition;h=new oG(t,n,e.changes.mapPos(t,-1),e.changes.mapPos(n,1)).addToSet(h.slice())}this.hasComposition=d?{from:d.range.fromB,to:d.range.toB}:null,(sV.ie||sV.chrome)&&!d&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let u=(r=this.decorations,s=this.updateDeco(),o=e.changes,a=new o$,rW.compare(r,s,o,a),a.changes);return h=oG.extendWithRanges(h,u),(!!(7&this.flags)||0!=h.length)&&(this.updateInner(h,e.startState.doc.length,d),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=sV.chrome||sV.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(e=>e.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof s9&&e.widget instanceof s7&&r.push(e.dom);i.updateGaps(r)}updateChildren(e,t,n){let i=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let e=i.length-1;;e--){let t=e>=0?i[e]:null;if(!t)break;let{fromA:s,toA:o,fromB:l,toB:a}=t,h,c,d,u;if(n&&n.range.fromB<a&&n.range.toB>l){let e=oe.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=oe.build(this.view.state.doc,n.range.toB,a,this.decorations,this.dynamicDecorationMap);c=e.breakAtStart,d=e.openStart,u=t.openEnd;let i=this.compositionView(n);t.breakAtStart?i.breakAfter=1:t.content.length&&i.merge(i.length,i.length,t.content[0],!1,t.openStart,0)&&(i.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&i.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),h=e.content.concat(i).concat(t.content)}else({content:h,breakAtStart:c,openStart:d,openEnd:u}=oe.build(this.view.state.doc,l,a,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=r.findPos(o,1),{i:m,off:g}=r.findPos(s,-1);sj(this,m,g,f,p,h,c,d,u)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){for(let t of(this.editContextFormatting=this.editContextFormatting.map(e.changes),e.transactions))for(let e of t.effects)e.is(oT)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new sH(e.text.nodeValue);for(let{deco:n}of(t.flags|=8,e.marks))t=new sq(n,[t],t.length);let n=new s6;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|!!t.children.some(e=>7&e.flags),this.markedForComposition.add(t);let n=sN.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),i=this.children[n.i];t(e.line,i);for(let r=e.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],t(r>=0?e.marks[r].node:e.text,i)}updateSelection(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&!(this.view.state.facet(oR)||this.dom.tabIndex>-1)&&so(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||n||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(sV.gecko&&l.empty&&!this.hasComposition&&1==(e=a).node.nodeType&&e.node.firstChild&&(0==e.offset||"false"==e.node.childNodes[e.offset-1].contentEditable)&&(e.offset==e.node.childNodes.length||"false"==e.node.childNodes[e.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=h=new sC(e,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(sa(a.node,a.offset,c.anchorNode,c.anchorOffset)&&sa(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,l))||(this.view.observer.ignore(()=>{sV.android&&sV.chrome&&this.dom.contains(c.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=sr(this.view.root);if(e)if(l.empty){if(sV.gecko){var t,n;let e=(t=a.node,n=a.offset,1!=t.nodeType?0:(n&&"false"==t.childNodes[n-1].contentEditable?1:0)|2*(n<t.childNodes.length&&"false"==t.childNodes[n].contentEditable));if(e&&3!=e){let t=(1==e?sk:sS)(a.node,a.offset);t&&(a=new sC(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=l.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=l.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(h.node,h.offset)}catch(e){}}else{let t=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),t.setEnd(h.node,h.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new sC(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new sC(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&sa(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=sr(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=s6.find(this,t.head);if(!s)return;let o=s.posAtStart;if(t.head==o||t.head==o+s.length)return;let l=this.coordsAt(t.head,-1),a=this.coordsAt(t.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(t.head+t.assoc);n.collapse(h.node,h.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(i,r)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let i=e.offset;!n&&i<t.childNodes.length;i++){let e=sN.get(t.childNodes[i]);e instanceof s6&&(n=e.domAtPos(0))}for(let i=e.offset-1;!n&&i>=0;i--){let e=sN.get(t.childNodes[i]);e instanceof s6&&(n=e.domAtPos(e.length))}return n?new sC(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let e=sN.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(n<e.length||e instanceof s6)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,i=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],l=r-o.breakAfter,a=l-o.length;if(l<e)break;if(a<=e&&(a<e||o.covers(-1))&&(l>e||o.covers(1))&&(!n||o instanceof s6&&!(n instanceof s6&&t>=0)))n=o,i=a;else if(n&&a==e&&l==e&&o instanceof s9&&2>Math.abs(t))if(o.deco.startSide<0)break;else s&&(n=null);r=a}return n?n.coordsAt(e-i,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),i=this.children[t];if(!(i instanceof s6))return null;for(;i.children.length;){let{i:e,off:t}=i.childPos(n,1);for(;;e++){if(e==i.children.length)return null;if((i=i.children[e]).length)break}n=t}if(!(i instanceof sH))return null;let r=iJ(i.text,n);if(r==n)return null;let s=sx(i.dom,n,r).getClientRects();for(let e=0;e<s.length;e++){let t=s[e];if(e==s.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==oi.LTR;for(let e=0,a=0;a<this.children.length;a++){let h=this.children[a],c=e+h.length;if(c>i)break;if(e>=n){let n=h.dom.getBoundingClientRect();if(t.push(n.height),s){let t=h.dom.lastChild,i=t?sl(t):[];if(i.length){let t=i[i.length-1],s=l?t.right-n.left:n.right-t.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=c)}}}e=c+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?oi.RTL:oi.LTR}measureTextSize(){for(let e of this.children)if(e instanceof s6){let t=e.measureTextSize();if(t)return t}let e=document.createElement("div"),t,n,i;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=sl(e.firstChild)[0];t=e.getBoundingClientRect().height,n=r?r.width/27:7,i=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}childCursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length,t=this.children.length;return t&&(e-=this.children[--t].length),new sO(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],s=r?r.from-1:this.length;if(s>n){let i=(t.lineBlockAt(s).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(s1.replace({widget:new s7(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!r)break;n=r.to+1}return s1.set(e)}updateDeco(){let e=1,t=this.view.state.facet(o_).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,i=this.view.state.facet(oW).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(rW.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}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(oO))try{if(t(this.view,e.range,e))return!0}catch(e){oD(this.view.state,e,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),i;if(!n)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let r=oU(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(e,t,n,i,r,s,o,l){let a=e.ownerDocument,h=a.defaultView||window;for(let c=e,d=!1;c&&!d;)if(1==c.nodeType){let e,u=c==a.body,f=1,p=1;if(u)e=function(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}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=sp(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)t.top<e.top?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let i=t.bottom-t.top,s=e.bottom-e.top;g=("center"==r&&i<=s?t.top+i/2-s/2:"start"==r||"center"==r&&n<0?t.top-o:t.bottom-s+o)-e.top}if("nearest"==i?t.left<e.left?(m=t.left-(e.left+s),n>0&&t.right>e.right+m&&(m=t.right-e.right+s)):t.right>e.right&&(m=t.right-e.right+s,n<0&&t.left<e.left+m&&(m=t.left-(e.left+s))):m=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==l?t.left-s:t.right-(e.right-e.left)+s)-e.left,m||g)if(u)h.scrollBy(m,g);else{let e=0,n=0;if(g){let e=c.scrollTop;c.scrollTop+=g/p,n=(c.scrollTop-e)*p}if(m){let t=c.scrollLeft;c.scrollLeft+=m/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&1>Math.abs(e-m)&&(i="nearest"),n&&1>Math.abs(n-g)&&(r="nearest")}if(u)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.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)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==oi.LTR)}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=s1.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.setDOM(e.contentDOM),this.children=[new s6],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new oG(0,0,0,e.state.doc.length)],0,null)}}function oX(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=sk(n.focusNode,n.focusOffset),r=sS(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let t=sN.get(r.node);if(!t||t instanceof sH&&t.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let e=sN.get(i.node);!e||e instanceof sH&&e.text!=i.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let o$=class{compareRange(e,t){s8(e,t,this.changes)}comparePoint(e,t){s8(e,t,this.changes)}boundChange(e){s8(e,e,this.changes)}constructor(){this.changes=[]}};function oZ(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function o0(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function o1(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function o2(e,t,n){let i=e.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let i=sx(e,l,l+1).getClientRects();for(let a=0;a<i.length;a++){let h=i[a];if(h.top==h.bottom)continue;o||(o=t-h.left);let c=(h.top>n?h.top-n:n-h.bottom)-1;if(h.left-1<=t&&h.right+1>=t&&c<s){let n=t>=(h.left+h.right)/2,i=n;if((sV.chrome||sV.gecko)&&sx(e,l).getBoundingClientRect().left==h.right&&(i=!n),c<=0)return{node:e,offset:l+ +!!i};r=l+ +!!i,s=c}}}return{node:e,offset:r>-1?r:o>0?e.nodeValue.length:0}}function o3(e,t,n){var i,r;let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=e.contentDOM.getBoundingClientRect(),l=o.top+e.viewState.paddingTop,a,{docHeight:h}=e.viewState,{x:c,y:d}=t,u=d-l;if(u<0)return 0;if(u>h)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,i=!1;(a=e.elementAtHeight(u)).type!=s0.Text;)for(;!((u=s>0?a.bottom+t:a.top-t)>=0)||!(u<=h);){if(i)return n?null:0;i=!0,s=-s}d=l+u;let f=a.from;if(f<e.viewport.from)return 0==e.viewport.from?0:n?null:o4(e,o,a,c,d);if(f>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:o4(e,o,a,c,d);let p=e.dom.ownerDocument,m=e.root.elementFromPoint?e.root:p,g=m.elementFromPoint(c,d);g&&!e.contentDOM.contains(g)&&(g=null),!g&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(g=m.elementFromPoint(c,d))&&!e.contentDOM.contains(g)&&(g=null));let v,x=-1;if(g&&(null==(i=e.docView.nearest(g))?void 0:i.isEditable)!=!1){if(p.caretPositionFromPoint){let e=p.caretPositionFromPoint(c,d);e&&({offsetNode:v,offset:x}=e)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,d);e&&({startContainer:v,startOffset:x}=e)}v&&(!e.contentDOM.contains(v)||sV.safari&&o5(v,x,c)||sV.chrome&&function(e,t,n){if(0!=t)return o5(e,t,n);for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}return n-(1==e.nodeType?e.getBoundingClientRect():sx(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,x,c))&&(v=void 0),v&&(x=Math.min(su(v),x))}if(!v||!e.docView.dom.contains(v)){let t=s6.find(e.docView,f);if(!t)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:x}=function e(t,n,i){let r,s,o,l,a,h,c,d,u=!1;for(let m=t.firstChild;m;m=m.nextSibling){let t=sl(m);for(let g=0;g<t.length;g++){var f,p;let v=t[g];h&&oZ(h,v)&&(v=o0(o1(v,h.bottom),h.top));let x=(f=v).left>n?f.left-n:Math.max(0,n-f.right),b=(p=v).top>i?p.top-i:Math.max(0,i-p.bottom);if(0==x&&0==b)return 3==m.nodeType?o2(m,n,i):e(m,n,i);(!a||d>b||d==b&&c>x)&&(a=m,h=v,c=x,d=b,u=!x||(n<v.left?g>0:g<t.length-1)),0==x?i>v.bottom&&(!o||o.bottom<v.bottom)?(r=m,o=v):i<v.top&&(!l||l.top>v.top)&&(s=m,l=v):o&&oZ(o,v)?o=o1(o,v.bottom):l&&oZ(l,v)&&(l=o0(l,v.top))}}if(o&&o.bottom>=i?(a=r,h=o):l&&l.top<=i&&(a=s,h=l),!a)return{node:t,offset:0};let m=Math.max(h.left,Math.min(h.right,n));if(3==a.nodeType)return o2(a,m,i);if(u&&"false"!=a.contentEditable)return e(a,m,i);let g=Array.prototype.indexOf.call(t.childNodes,a)+ +(n>=(h.left+h.right)/2);return{node:t,offset:g}}(t.dom,c,d))}let b=e.docView.nearest(v);if(!b)return null;if(!b.isWidget||(null==(r=b.dom)?void 0:r.nodeType)!=1)return b.localPosFromDOM(v,x)+b.posAtStart;{let e=b.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?b.posAtStart:b.posAtEnd}}function o4(e,t,n,i,r){let s=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((r-n.top-(e.defaultLineHeight-t)*.5)/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+r0(o,s,e.state.tabSize)}function o5(e,t,n){let i,r=e;if(3!=e.nodeType||t!=(i=e.nodeValue.length))return!1;for(;;){let e=r.nextSibling;if(e){if("BR"==e.nodeName)break;return!1}{let e=r.parentNode;if(!e||"DIV"==e.nodeName)break;r=e}}return sx(e,i-1,i).getBoundingClientRect().right>n}function o8(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let r of i.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!e||r.type==s0.Text&&(e.type!=r.type||(n<0?r.from<t:r.to>t)))&&(e=r)}}return e||i}return i}function o6(e,t,n,i){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let l=t,a=null;;){let t=function(e,t,n,i,r){var s;let o=i.head-e.from,l=of.find(t,o,null!=(s=i.bidiLevel)?s:-1,i.assoc),a=t[l],h=a.side(r,n);if(o==h){let e=l+=r?1:-1;if(e<0||e>=t.length)return null;o=(a=t[l=e]).side(!r,n),h=a.side(r,n)}let c=iJ(e.text,o,a.forward(r,n));(c<a.from||c>a.to)&&(c=h),og=e.text.slice(Math.min(o,c),Math.max(o,c));let d=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return d&&c==h&&d.level+ +!r<a.level?i9.cursor(d.side(!r,n)+e.from,d.forward(r,n)?1:-1,d.level):i9.cursor(c+e.from,a.forward(r,n)?-1:1,a.level)}(r,s,o,l,n),h=og;if(!t){if(r.number==(n?e.state.doc.lines:1))return l;h="\n",r=e.state.doc.line(r.number+(n?1:-1)),s=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(a){if(!a(h))return l}else{if(!i)return t;a=i(h)}l=t}}function o9(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,(e,r,s)=>{if(t>e&&t<r){let s=i||n||(t-e<r-t?-1:1);t=s<0?e:r,i=s}});if(!i)return t}}function o7(e,t){let n=null;for(let i=0;i<t.ranges.length;i++){let r=t.ranges[i],s=null;if(r.empty){let t=o9(e,r.from,0);t!=r.from&&(s=i9.cursor(t,-1))}else{let t=o9(e,r.from,-1),n=o9(e,r.to,1);(t!=r.from||n!=r.to)&&(s=i9.range(r.from==r.anchor?t:n,r.from==r.head?t:n))}s&&(n||(n=t.ranges.slice()),n[i]=s)}return n?i9.create(n,t.mainIndex):t}function le(e,t,n){let i=o9(e.state.facet(oV).map(t=>t(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:i9.cursor(i,i<n.from?1:-1)}class lt{append(e){this.text+=e}lineBreak(){this.text+=""}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==t)break;let s=sN.get(i),o=sN.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:sc(i))||sc(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>e)&&this.lineBreak(),i=r}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,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=i.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=r+s}}readNode(e){if(e.cmIgnore)return;let t=sN.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&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)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(!function(e,t,n){for(;;){if(!t||n<su(t))return!1;if(t==e)return!0;n=sh(t)+1,t=t.parentNode}}(e,n.node,n.offset)?0:t))}constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(rL.lineSeparator)}}class ln{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class li{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=r||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new ln(n,i)),(r!=n||s!=i)&&t.push(new ln(r,s))),t}(e),n=new lt(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?i9.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!ss(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!ss(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),o=e.viewport;if((sV.ios||sV.chrome)&&e.state.selection.main.empty&&n!=i&&(o.from>0||o.to<e.state.doc.length)){let t=Math.min(n,i),r=Math.max(n,i),s=o.from-t,l=o.to-r;(0==s||1==s||0==t)&&(0==l||-1==l||r==e.state.doc.length)&&(n=0,i=e.state.doc.length)}this.newSel=i9.single(i,n)}}}function lr(e,t){let n,{newSel:i}=t,r=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:i,to:o}=t.bounds,l=r.from,a=null;(8===s||sV.android&&t.text.length<o-i)&&(l=r.to,a="end");let h=function(e,t,n,i){let r=Math.min(e.length,t.length),s=0;for(;s<r&&e.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&e.length==t.length)return null;let o=e.length,l=t.length;for(;o>0&&l>0&&e.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if("end"==i){let e=Math.max(0,s-Math.min(o,l));n-=o+e-s}if(o<s&&e.length<t.length){let e=n<=s&&n>=o?s-n:0;s-=e,l=s+(l-o),o=s}else if(l<s){let e=n<=s&&n>=l?s-n:0;s-=e,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}(e.state.doc.sliceString(i,o,""),t.text,l-i,a);h&&(sV.chrome&&13==s&&h.toB==h.from+2&&""==t.text.slice(h.from,h.toB)&&h.toB--,n={from:i+h.from,to:i+h.toA,insert:iz.of(t.text.slice(h.from,h.toB).split(""))})}else i&&(!e.hasFocus&&e.state.facet(oR)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&t.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(sV.mac||sV.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=i9.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:iz.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:sV.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=i9.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:iz.of([" "])}),n)return ls(e,n,i,s);if(!i||i.main.eq(r))return!1;{let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),"select.pointer"==(n=e.inputState.lastSelectionOrigin)&&(i=o7(e.state.facet(oV).map(t=>t(e)),i))),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}}function ls(e,t,n){let i,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1;if(sV.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(sV.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&sb(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>s.head)&&sb(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&sb(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>i||(i=function(e,t,n){let i,r=e.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let n=t.from<s.from?-1:1,i=n<0?s.from:s.to,l=o9(r.facet(oV).map(t=>t(e)),i,n);t.from==l&&(o=l)}if(o>-1)i={changes:t,selection:i9.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=s.from<t.from?r.sliceDoc(s.from,t.from):"",o=s.to>t.to?r.sliceDoc(t.to,s.to):"";i=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=r.changes(t),l=n&&n.main.to<=o.newLength?n.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let a=e.state.sliceDoc(t.from,t.to),h,c=n&&oX(e,n.main.head);if(c){let e=t.insert.length-(t.to-t.from);h={from:c.from,to:c.to-e}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to,u=s.to-s.from;i=r.changeByRange(n=>{if(n.from==s.from&&n.to==s.to)return{changes:o,range:l||n.map(o)};let i=n.to-d,c=i-a.length;if(n.to-n.from!=u||e.state.sliceDoc(c,i)!=a||n.to>=h.from&&n.from<=h.to)return{range:n};let f=r.changes({from:c,to:i,insert:t.insert}),p=n.to-s.to;return{changes:f,range:l?i9.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):n.map(f)}})}else i={changes:o,selection:l&&r.selection.replaceRange(l)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}(e,t,n));return e.state.facet(ok).some(n=>n(e,t.from,t.to,o,l))||e.dispatch(l()),!0}class lo{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}handleEvent(e){!(!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,i;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=sN.get(n))&&i.ignoreEvent(t))return!1;return!0}(this.view,e)||this.ignoreDuringComposition(e))&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):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=function(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,i=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(i)for(let e in i){let r=i[e];r&&n(e).handlers.push(ll(t.value,r))}if(r)for(let e in r){let i=r[e];i&&n(e).observers.push(ll(t.value,i))}}for(let e in lf)n(e).handlers.push(lf[e]);for(let e in lp)n(e).observers.push(lp[e]);return t}(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,s=n[e];s&&!s.handlers.length!=r&&(i.removeEventListener(e,this.handleEvent),s=null),s||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){let t;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=e.keyCode&&0>lc.indexOf(e.keyCode)&&(this.tabFocusMode=-1),sV.android&&sV.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0):sV.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=la.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||lh.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=e.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(e){let t=this.pendingIOSKey;return!(!t||"Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,sb(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(sV.safari&&!sV.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 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.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,sV.safari&&e.contentDOM.addEventListener("input",()=>null),sV.gecko&&function(e){lT.has(e)||(lT.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}}function ll(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){oD(n.state,e)}}}let la=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lh="dthko",lc=[16,17,18,20,91,92,224,225];function ld(e){return .7*Math.max(0,e)+8}class lu{start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(t=this.startEvent,Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))))return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=oU(this.view);e.clientX-a.left<=r+6?n=-ld(r-e.clientX):e.clientX+a.right>=o-6&&(n=ld(e.clientX-o)),e.clientY-a.top<=s+6?i=-ld(s-e.clientY):e.clientY+a.bottom>=l-6&&(i=ld(e.clientY-l)),this.setScrollSpeed(n,i)}up(e){null==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),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=o7(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,!1===this.dragging))&&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)}constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t=e.ownerDocument,n,i;for(let r=e.parentNode;r;)if(r==t.body||n&&i)break;else if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:n,y:i}}(e.contentDOM),this.atoms=e.state.facet(oV).map(t=>t(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(rL.allowMultipleSelections)&&function(e,t){let n=e.state.facet(ov);return n.length?n[0](t):sV.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=sr(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let n=r[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)&&1==lA(t)&&null}}let lf=Object.create(null),lp=Object.create(null),lm=sV.ie&&sV.ie_version<15||sV.ios&&sV.webkit_version<604;function lg(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function lv(e,t){t=lg(e.state,oC,t);let{state:n}=e,i,r=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(null!=lM&&n.selection.ranges.every(e=>e.empty)&&lM==s.toString()){let e=-1;i=n.changeByRange(i=>{let l=n.doc.lineAt(i.from);if(l.from==e)return{range:i};e=l.from;let a=n.toText((o?s.line(r++).text:t)+n.lineBreak);return{changes:{from:l.from,insert:a},range:i9.cursor(i.from+a.length)}})}else i=o?n.changeByRange(e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:i9.cursor(e.from+t.length)}}):n.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function lx(e,t,n,i){if(1==i)return i9.cursor(t,n);{if(2==i)return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return i9.cursor(t);0==s?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=iJ(r.text,s,!1):l=iJ(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let e=iJ(r.text,o,!1);if(i(r.text.slice(e,o))!=a)break;o=e}for(;l<r.length;){let e=iJ(r.text,l);if(i(r.text.slice(l,e))!=a)break;l=e}return i9.range(o+r.from,l+r.from)}(e.state,t,n);let r=s6.find(e.docView,t),s=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<e.state.doc.length&&l==s.to&&l++,i9.range(o,l)}}lp.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},lf.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),lp.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},lp.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},lf.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(ob))if(n=i(e,t))break;if(n||0!=t.button||(n=function(e,t){let n=ly(e,t),i=lA(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,s,o){let l=ly(e,t),a,h=lx(e,l.pos,l.bias,i);if(n.pos!=l.pos&&!s){let t=lx(e,n.pos,n.bias,i),r=Math.min(t.from,h.from),s=Math.max(t.to,h.to);h=r<h.from?i9.range(r,s):i9.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==i&&r.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:r}=e.ranges[n];if(i<=t&&r>=t)return i9.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n))}return null}(r,l.pos))?a:o?r.addRange(h):i9.create([h])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new lu(e,t,n,i)),i&&e.observer.ignore(()=>{sv(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};let lb=(e,t,n)=>t>=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right;function ly(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:function(e,t,n,i){let r=s6.find(e.docView,t);if(!r)return 1;let s=t-r.posAtStart;if(0==s)return 1;if(s==r.length)return -1;let o=r.coordsAt(s,-1);if(o&&lb(n,i,o))return -1;let l=r.coordsAt(s,1);return l&&lb(n,i,l)?1:o&&o.bottom>=i?-1:1}(e,n,t.clientX,t.clientY)}}let lw=sV.ie&&sV.ie_version<=11,lk=null,lS=0,lC=0;function lA(e){if(!lw)return e.detail;let t=lk,n=lC;return lk=e,lC=Date.now(),lS=!t||n>Date.now()-400&&2>Math.abs(t.clientX-e.clientX)&&2>Math.abs(t.clientY-e.clientY)?(lS+1)%3:1}function lN(e,t,n,i){let r;if(!(n=lg(e.state,oC,n)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,l=i&&o&&((r=e.state.facet(ox)).length?r[0](t):sV.mac?!t.altKey:!t.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:n},h=e.state.changes(l?[l,a]:a);e.focus(),e.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),e.inputState.draggedContent=null}lf.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.nearest(t.target);if(i&&i.isWidget){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=i9.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",lg(e.state,oA,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},lf.dragend=e=>(e.inputState.draggedContent=null,!1),lf.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&lN(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=s,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),s()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return lN(e,t,n,!0),!0}return!1},lf.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=lm?null:t.clipboardData;return n?(lv(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(!function(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(),lv(e,n.value)},50)}(e),!1)};let lM=null;lf.copy=lf.cut=(e,t)=>{let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let s=e.doc.lineAt(i);s.number>r&&(t.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),r=s.number}i=!0}return{text:lg(e,oA,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;lM=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=lm?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(!function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};let lO=rC.define();function lj(e,t){let n=[];for(let i of e.facet(oS)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:lO.of(!0)}):null}function lE(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=lj(e.state,t);n?e.dispatch(n):e.update([])}},10)}lp.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),lE(e)},lp.blur=e=>{e.observer.clearSelectionRange(),lE(e)},lp.compositionstart=lp.compositionupdate=e=>{!e.observer.editContext&&(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},lp.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,sV.chrome&&sV.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},lp.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},lf.beforeinput=(e,t)=>{var n,i;let r;if("insertReplacementText"==t.inputType&&e.observer.editContext){let i=null==(n=t.dataTransfer)?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),s=e.posAtDOM(t.endContainer,t.endOffset);return ls(e,{from:n,to:s,insert:e.state.toText(i)},null),!0}}if(sV.chrome&&sV.android&&(r=la.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null==(i=window.visualViewport)?void 0:i.height)||0;setTimeout(()=>{var n;((null==(n=window.visualViewport)?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return sV.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),sV.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>lp.compositionend(e,t),20),!1};let lT=new Set,lD=["pre-wrap","normal","pre-line","break-spaces"],lR=!1;class lP{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 lD.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,r,s){let o=lD.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let e=0;e<s.length;e++){let t=s[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return l}constructor(e){this.lineWrapping=e,this.doc=iz.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}}class lL{get more(){return this.index<this.heights.length}constructor(e,t){this.from=e,this.heights=t,this.index=0}}class lI{get type(){return"number"==typeof this._content?s0.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof s4?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new lI(this.from,this.length+e.length,this.top,this.height+e.height,t)}constructor(e,t,n,i,r){this.from=e,this.length=t,this.top=n,this.height=i,this._content=r}}var lB=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(lB||(lB={}));class lz{get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=2*!!e|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>.001&&(lR=!0),this.height=e)}replace(e,t,n){return lz.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,s=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=i[o],d=r.lineAt(l,lB.ByPosNoHeight,n.setDoc(t),0,0),u=d.to>=a?d:r.lineAt(a,lB.ByPosNoHeight,n,0,0);for(c+=u.to-a,a=u.to;o>0&&d.from<=i[o-1].toA;)l=i[o-1].fromA,h=i[o-1].fromB,o--,l<d.from&&(d=r.lineAt(l,lB.ByPosNoHeight,n,0,0));h+=d.from-l,l=d.from;let f=lK.build(n.setDoc(s),e,h,c);r=lF(r,r.replace(l,a,f))}return r.updateHeight(n,0)}static empty(){return new lW(0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,r=0;for(;;)if(t==n)if(i>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else if(r>2*i){let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}else break;else if(i<r){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(r+=t.size)}let s=0;return null==e[t-1]?(s=1,t--):null==e[t]&&(s=1,n++),new lH(lz.of(e.slice(0,t)),s,lz.of(e.slice(n)))}constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}}function lF(e,t){return e==t?e:(e.constructor!=t.constructor&&(lR=!0),t)}lz.prototype.size=1;class l_ extends lz{blockAt(e,t,n,i){return new lI(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(e,t,n,i,r,s){e<=r+this.length&&t>=r&&s(this.blockAt(0,n,i,r))}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3?arguments[3]:void 0);return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return"block(".concat(this.length,")")}constructor(e,t,n){super(e,t),this.deco=n}}class lW extends l_{blockAt(e,t,n,i){return new lI(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof lW||i instanceof lV&&4&i.flags)&&10>Math.abs(this.length-i.length)?(i instanceof lV?i=new lW(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):lz.of(n)}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")")}constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}}class lV extends lz{heightMetrics(e,t){let n=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,r=i-n+1,s,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);s=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else s=this.height/r;return{firstLine:n,lastLine:i,perLine:s,perChar:o}}blockAt(e,t,n,i){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),s=t.doc.lineAt(r),a=o+s.length*l,h=Math.max(n,e-a/2);return new lI(s.from,s.length,h,a,0)}{let i=Math.max(0,Math.min(s-r,Math.floor((e-n)/o))),{from:l,length:a}=t.doc.line(r+i);return new lI(l,a,n+o*i,o,0)}}lineAt(e,t,n,i,r){if(t==lB.ByHeight)return this.blockAt(e,n,i,r);if(t==lB.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new lI(t,i-t,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(n,r),a=n.doc.lineAt(e),h=o+a.length*l,c=a.number-s,d=i+o*c+l*(a.from-r-c);return new lI(a.from,a.length,Math.max(i,Math.min(d,i+this.height-h)),h,0)}forEachLine(e,t,n,i,r,s){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);for(let h=e,c=i;h<=t;){let t=n.doc.lineAt(h);if(h==e){let n=t.number-o;c+=l*n+a*(e-r-n)}let i=l+a*t.length;s(new lI(t.from,t.length,c,i,0)),c+=i,h=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof lV?n[n.length-1]=new lV(e.length+i):n.push(null,new lV(i-1))}if(e>0){let t=n[0];t instanceof lV?n[0]=new lV(e+t.length):n.unshift(new lV(e-1),null)}return lz.of(n)}decomposeLeft(e,t){t.push(new lV(e-1),null)}decomposeRight(e,t){t.push(null,new lV(this.length-e-1))}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],s=Math.max(t,i.from),o=-1;for(i.from>t&&n.push(new lV(i.from-t-1).updateHeight(e,t));s<=r&&i.more;){let t=e.doc.lineAt(s).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let l=new lW(t,r);l.outdated=!1,n.push(l),s+=t+1}s<=r&&n.push(null,new lV(r-s).updateHeight(e,s));let l=lz.of(n);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(e,t).perLine)>=.001)&&(lR=!0),lF(this,l)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return"gap(".concat(this.length,")")}constructor(e){super(e,0)}}class lH extends lz{get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,r,i+this.left.length+this.break)}lineAt(e,t,n,i,r){let s=i+this.left.height,o=r+this.left.length+this.break,l=t==lB.ByHeight?e<s:e<o,a=l?this.left.lineAt(e,t,n,i,r):this.right.lineAt(e,t,n,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=t==lB.ByPosNoHeight?lB.ByPosNoHeight:lB.ByPos;return l?a.join(this.right.lineAt(o,h,n,s,o)):this.left.lineAt(o,h,n,i,r).join(a)}forEachLine(e,t,n,i,r,s){let o=i+this.left.height,l=r+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,n,i,r,s),t>=l&&this.right.forEachLine(e,t,n,o,l,s);else{let a=this.lineAt(l,lB.ByPos,n,i,r);e<a.from&&this.left.forEachLine(e,a.from-1,n,i,r,s),a.to>=e&&a.from<=t&&s(a),t>a.to&&this.right.forEachLine(a.to+1,t,n,o,l,s)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let s=r.length;for(let e of n)r.push(e);if(e>0&&lq(r,s-1),t<this.length){let e=r.length;this.decomposeRight(t,r),lq(r,e)}return lz.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++n&&t.push(null),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?lz.of(this.break?[e,null,t]:[e,t]):(this.left=lF(this.left,e),this.right=lF(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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,{left:r,right:s}=this,o=t+r.length+this.break,l=null;return(i&&i.from<=t+r.length&&i.more?l=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=o+s.length&&i.more?l=s=s.updateHeight(e,o,n,i):s.updateHeight(e,o,n),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}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}}function lq(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof lV&&(i=e[t+1])instanceof lV&&e.splice(t-1,3,new lV(n.length+1+i.length))}class lK{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 lW?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new lW(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=t-e;n.block?this.addBlock(new l_(s,i,n)):(s||r||i>=5)&&this.addLineDeco(i,r,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new lW(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new lV(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 lW)return e;let t=new lW(0,-1);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=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof lW||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new lW(0,-1));let n=e;for(let e of this.nodes)e instanceof lW&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let r=new lK(n,e);return rW.spans(t,n,i,r,0),r.finish(n)}constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}}class lU{compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&s8(e,t,this.changes,5)}constructor(){this.changes=[]}}class lJ{static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(e,t){return s1.replace({widget:new lG(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}}class lG extends sZ{eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}constructor(e,t){super(),this.size=e,this.vertical=t}}class lY{updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(e=>{let{from:t,to:n}=e;return i>=t&&i<=n})){let{from:t,to:n}=this.lineBlockAt(i);e.push(new lQ(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?lZ:new l0(this.heightOracle,this.heightMap,this.viewports),2*!e.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(l1(e,this.scaler))})}update(e){var t,n;let i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.state=e.state;let s=this.stateDeco;this.stateDeco=this.state.facet(o_).filter(e=>"function"!=typeof e);let o=e.changedRanges,l=oG.extendWithRanges(o,(t=this.stateDeco,n=e?e.changes:i0.empty(this.state.doc.length),i=new lU,rW.compare(s,t,n,i,0),i.changes)),a=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);lR=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=a||lR)&&(e.flags|=2),h?(this.scrollAnchorPos=e.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(r&&(r.range.head<c.from||r.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,r));let d=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,e.flags|=this.updateForViewport(),(d||!e.changes.empty||2&e.flags)&&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),r&&(this.scrollTarget=r),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(oM)&&(this.mustEnforceCursorAssoc=!0)}measure(e){var t;let n,i,r=e.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?oi.RTL:oi.LTR;let a=this.heightOracle.mustRefreshForWrapping(l),h=r.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let d=0,u=0;if(h.width&&h.height){let{scaleX:e,scaleY:t}=sp(r,h);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,d|=16,a=c=!0)}let f=(parseInt(s.paddingTop)||0)*this.scaleY,p=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=p)&&(this.paddingTop=f,this.paddingBottom=p,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(c=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=sw(e.scrollDOM);let g=(this.printing?function(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}:function(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();s=Math.max(s,i.left),o=Math.min(o,i.right),l=Math.max(l,i.top),a=Math.min(t==e.parentNode?r.innerHeight:a,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else if(11==t.nodeType)t=t.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+t),bottom:Math.max(l,a)-(n.top+t)}})(r,this.paddingTop),v=g.top-this.pixelViewport.top,x=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(c=!0)),!this.inView&&!this.scrollTarget&&(n=(t=e.dom).getBoundingClientRect(),i=t.ownerDocument.defaultView||window,!(n.left<i.innerWidth)||!(n.right>0)||!(n.top<i.innerHeight)||!(n.bottom>0)))return 0;let y=h.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=h.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),c){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(a=!0),a||o.lineWrapping&&Math.abs(y-this.contentDOMWidth)>o.charWidth){let{lineHeight:n,charWidth:i,textHeight:r}=e.docView.measureTextSize();(a=n>0&&o.refresh(l,n,i,r,Math.max(5,y/i),t))&&(e.docView.minWidth=0,d|=16)}for(let n of(v>0&&x>0?u=Math.max(v,x):v<0&&x<0&&(u=Math.min(v,x)),lR=!1,this.viewports)){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?lz.empty().applyChanges(this.stateDeco,iz.empty,this.heightOracle,[new oG(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new lL(n.from,i))}lR&&(d|=2)}let w=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(2&d&&(d|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),d|=this.updateForViewport()),(2&d||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}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)),i=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new lQ(i.lineAt(s-1e3*n,lB.ByHeight,r,0,0).from,i.lineAt(o+(1-n)*1e3,lB.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<l.from||e>l.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,lB.ByPos,r,0,0),o;o="center"==t.y?(s.top+s.bottom)/2-n/2:"start"==t.y||"nearest"==t.y&&e<l.from?s.top:s.bottom-n,l=new lQ(i.lineAt(o-500,lB.ByHeight,r,0,0).from,i.lineAt(o+n+500,lB.ByHeight,r,0,0).to)}}return l}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new lQ(this.heightMap.lineAt(n,lB.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,lB.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate(e){let{from:t,to:n}=e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(t,lB.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,lB.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(0==t||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2e3&&s<l+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new lJ(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,s=i<<1;if(this.defaultTextDirection!=oi.LTR&&!n)return[];let o=[],l=(i,s,a,h)=>{if(s-i<r)return;let c=this.state.selection.main,d=[c.from];for(let e of(c.empty||d.push(c.to),d))if(e>i&&e<s){l(i,e-10,a,h),l(e+10,s,a,h);return}let u=function(e,t){for(let n of e)if(t(n))return n}(e,e=>e.from>=a.from&&e.to<=a.to&&Math.abs(e.from-i)<r&&Math.abs(e.to-s)<r&&!d.some(t=>e.from<t&&e.to>t));if(!u){if(s<a.to&&t&&n&&t.visibleRanges.some(e=>e.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(i9.cursor(s),!1,!0).head;e>i&&(s=e)}let e=this.gapSize(a,i,s,h),r=n||e<2e6?e:2e6;u=new lJ(i,s,e,r)}o.push(u)},a=t=>{var r,o,a;let h,c,d,u,f;if(t.length<s||t.type!=s0.Text)return;let p=(r=t.from,o=t.to,a=this.stateDeco,d=[],u=r,f=0,rW.spans(a,r,o,{span(){},point(e,t){e>u&&(d.push({from:u,to:e}),f+=e-u),u=t}},20),u<o&&(d.push({from:u,to:o}),f+=o-u),{total:f,ranges:d});if(p.total<s)return;let m=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=m){let i=l$(p,m),s=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-r)/t.height,n=(this.visibleBottom-t.top+r)/t.height;h=lX(p,e),c=lX(p,n)}else{let n,r,s=p.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,l=0;if(s>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=n.size-n.displaySize);let a=this.pixelViewport.left+l,d=this.pixelViewport.right+l;if(null!=m){let e=l$(p,m),t=((d-a)/2+o)/s;n=e-t,r=e+t}else n=(a-o)/s,r=(d+o)/s;h=lX(p,n),c=lX(p,r)}h>t.from&&l(t.from,h,t,p),c<t.to&&l(c,t.to,t,p)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(a):a(e);return o}gapSize(e,t,n,i){let r=l$(i,n)-l$(i,t);return this.heightOracle.lineWrapping?e.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(e){lJ.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=s1.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];rW.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let r=this.visibleRanges[t],s=n[t];(r.from!=s.from||r.to!=s.to)&&(i|=4,e&&e.mapPos(r.from,-1)==s.from&&e.mapPos(r.to,1)==s.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||l1(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)||l1(this.heightMap.lineAt(this.scaler.fromDOM(e),lB.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return l1(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}constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=lZ,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=oi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(oF).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new lP(t),this.stateDeco=e.facet(o_).filter(e=>"function"!=typeof e),this.heightMap=lz.empty().applyChanges(this.stateDeco,iz.empty,this.heightOracle.setDoc(e.doc),[new oG(0,0,0,e.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=s1.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}}class lQ{constructor(e,t){this.from=e,this.to=t}}function lX(e,t){let{total:n,ranges:i}=e;if(t<=0)return i[0].from;if(t>=1)return i[i.length-1].to;let r=Math.floor(n*t);for(let e=0;;e++){let{from:t,to:n}=i[e],s=n-t;if(r<=s)return t+r;r-=s}}function l$(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}let lZ={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class l0{toDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return i+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,i=r.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-i)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,i=r.domBottom}}eq(e){return e instanceof l0&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)}constructor(e,t,n){let i=0,r=0,s=0;for(let o of(this.viewports=n.map(n=>{let{from:r,to:s}=n,o=t.lineAt(r,lB.ByPos,e,0,0).top,l=t.lineAt(s,lB.ByPos,e,0,0).bottom;return i+=l-o,{from:r,to:s,top:o,bottom:l,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}}function l1(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new lI(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>l1(e,t)):e._content)}let l2=rt.define({combine:e=>e.join(" ")}),l3=rt.define({combine:e=>e.indexOf(!0)>-1}),l4=r4.newName(),l5=r4.newName(),l8=r4.newName(),l6={"&light":"."+l5,"&dark":"."+l8};function l9(e,t,n){return new r4(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw RangeError("Unsupported selector: ".concat(t));return n[t]}):e+" "+t})}let l7=l9("."+l4,{"&":{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":{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-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"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',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"}},l6),ae={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},at=sV.ie&&sV.ie_version<=11;class an{onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&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]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(oR)?n.root.activeElement!=this.dom:!so(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(sV.ie&&sV.ie_version<=11||sV.android&&sV.chrome)&&!n.state.selection.main.empty&&i.focusNode&&sa(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=sr(e.root);if(!t)return!1;let n=sV.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ar(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?ar(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=so(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,su(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:i=su(n=e)}else{if(n==e)return!0;i=sh(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ae),at&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),at&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&sb(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null==(n=this.delayedAndroidKey)?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&so(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new li(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=lr(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let n=ai(t,e.previousSibling||e.target.previousSibling,-1),i=ai(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{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(oR)!=e.state.facet(oR)&&(e.view.contentDOM.editContext=e.state.facet(oR)?this.editContext.editContext:null))}destroy(){var e,t,n;for(let i of(this.stop(),null==(e=this.intersection)||e.disconnect(),null==(t=this.gapIntersection)||t.disconnect(),null==(n=this.resizeScroll)||n.disconnect(),this.scrollTargets))i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new sm,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);(sV.ie&&sV.ie_version<=11||sV.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&sV.android&&!1!==e.constructor.EDIT_CONTEXT&&!(sV.chrome&&sV.chrome_version<126)&&(this.editContext=new as(e),e.state.facet(oR)&&(e.contentDOM.editContext=this.editContext.editContext)),at&&(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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null==(e=this.view.docView)?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{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()}}function ai(e,t,n){for(;t;){let i=sN.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function ar(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return sa(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}class as{applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,s,o,l,a)=>{if(n)return;let h=a.length-(s-r);if(i&&s>=i.to)if(i.from==r&&i.to==s&&i.insert.eq(a)){i=this.pendingContextChange=null,t+=h,this.to+=h;return}else i=null,this.revertPending(e.state);if(r+=t,(s+=t)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}t+=h}),i&&!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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(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))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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])}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)});for(let n in this.handlers.textupdate=t=>{let n=e.state.selection.main,{anchor:i,head:r}=n,s=this.toEditorPos(t.updateRangeStart),o=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:s,drifted:!1});let l={from:s,to:o,insert:iz.of(t.text.split("\n"))};if(l.from==this.from&&i<this.from?l.from=i:l.to==this.to&&i>this.to&&(l.to=i),l.from==l.to&&!l.insert.length){let i=i9.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));i.main.eq(n)||e.dispatch({selection:i,userEvent:"select"});return}if((sV.mac||sV.android)&&l.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(l={from:s,to:o,insert:iz.of([t.text.replace("."," ")])}),this.pendingContextChange=l,!e.state.readOnly){let n=this.to-this.from+(l.to-l.from+l.insert.length);ls(e,l,i9.single(this.toEditorPos(t.selectionStart,n),this.toEditorPos(t.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),s=this.toEditorPos(n.rangeEnd);t<s;t++){let n=e.coordsForChar(t);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if("None"!=t&&"None"!=i){let r=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(r<s){let e="text-decoration: underline ".concat("Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":"").concat("Thin"==i?1:2,"px");n.push(s1.mark({attributes:{style:e}}).range(r,s))}}}e.dispatch({effects:oT.of(s1.set(n))})},this.handlers.compositionstart=()=>{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)}},this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=sr(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}}class ao{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}dispatch(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=1==t.length&&t[0]instanceof rO?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(i,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,i,r=this.state;for(let t of e){if(t.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,l=null;e.some(e=>e.annotation(lO))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,(l=lj(r,s))||(o=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(rL.phrases)!=this.state.facet(rL.phrases))return this.setState(r);i=oY.create(this,r,e),i.flags|=o;let c=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new oj(e.empty?e:i9.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(oE)&&(c=e.value.clip(this.state))}this.viewState.update(i,c),this.bidiCache=ah.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(oJ)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(l2)!=i.state.facet(l2)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(ow))try{e(i)}catch(e){oD(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!lr(this,h)&&a.force&&sb(this.contentDOM,a.key,a.keyCode)})}setState(e){if(0!=this.updateState)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);for(let t of(this.viewState=new lY(e),this.plugins=e.facet(oL).map(e=>new oB(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new oQ(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(oL),n=e.state.facet(oL);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new oB(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){oD(this.state,e,"doc view update listener")}}}measure(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(this.destroyed)return;if(this.measureScheduled>-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.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0)if(sw(n))r=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,s=e.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(e=>{try{return e.read(this)}catch(e){return oD(this.state,e),aa}}),h=oY.create(this,this.state,[]),c=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e<l.length;e++)if(a[e]!=aa)try{let t=l[e];t.write&&t.write(a[e],this)}catch(e){oD(this.state,e)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(e>1||e<-1){n.scrollTop=(i+=e)/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ow))e(t)}get themeClasses(){return l4+" "+(this.state.facet(l3)?l8:l5)+" "+this.state.facet(l2)}updateAttrs(){let e=ac(this,oz,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(oR)?"true":"false",class:"cm-content",style:"".concat(sV.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),ac(this,oF,t);let n=this.observer.ignore(()=>{let n=s$(this.contentDOM,this.contentAttrs,t),i=s$(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)e.is(ao.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(oJ);let e=this.state.facet(ao.cspNonce);r4.mount(this.root,this.styleModules.concat(l7).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e)&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.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 le(this,e,o6(this,e,t,n))}moveByGroup(e,t){return le(this,e,o6(this,e,t,t=>{var n;let i,r;return n=e.head,r=(i=this.state.charCategorizer(n))(t),e=>{let t=i(e);return r==rR.Space&&(r=t),r==t}}))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return i9.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return function(e,t,n,i){let r=o8(e,t.head,t.assoc||-1),s=i&&r.type==s0.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(r.from),o=e.posAtCoords({x:n==(i==oi.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return i9.cursor(o,n?-1:1)}return i9.cursor(n?r.to:r.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return le(this,e,function(e,t,n,i){let r=t.head,s=n?1:-1;if(r==(n?e.state.doc.length:0))return i9.cursor(r,t.assoc);let o=t.goalColumn,l,a=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r,t.assoc||-1),c=e.documentTop;if(h)null==o&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(r-t.from))),l=(s<0?t.top:t.bottom)+c}let d=a.left+o,u=null!=i?i:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let n=l+(u+t)*s,i=o3(e,{x:d,y:n},!1,s);if(n<a.top||n>a.bottom||(s<0?i<r:i>r)){let t=e.docView.coordsForChar(i),r=!t||n<t.top?-1:1;return i9.cursor(i,r,void 0,o)}}}(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.posFromDOM(e,t)}posAtCoords(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return this.readMeasured(),o3(this,e,t)}coordsAtPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),r=this.bidiSpans(i);return sf(n,r[of.find(r,e-i.from,-1,t)].dir==oi.LTR==t>0)}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(oN)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>al)return om(e.length);let t=this.textDirectionAt(e.from),n;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==t&&(i.fresh||function e(t,n){if(t.length!=n.length)return!1;for(let i=0;i<t.length;i++){let r=t[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!e(r.inner,s.inner))return!1}return!0}(i.isolates,n=oq(this,e))))return i.order;n||(n=oq(this,e));let i=function(e,t,n){if(!e)return[new of(0,0,+(t==os))];if(t==or&&!n.length&&!ou.test(e))return om(e.length);if(n.length)for(;e.length>op.length;)op[op.length]=256;let i=[],r=+(t!=or);return function e(t,n,i,r,s,o,l){let a=n%2?2:1;!function(e,t,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:t,l=s<i.length?i[s].from:n,a=s?256:r;for(let t=o,n=a,i=a;t<l;t++){let r=od(e.charCodeAt(t));512==r?r=n:8==r&&4==i&&(r=16),op[t]=4==r?2:r,7&r&&(i=r),n=r}for(let e=o,t=a,i=a;e<l;e++){let r=op[e];if(128==r)e<l-1&&t==op[e+1]&&24&t?r=op[e]=t:op[e]=256;else if(64==r){let r=e+1;for(;r<l&&64==op[r];)r++;let s=e&&8==t||r<n&&8==op[r]?1==i?1:8:256;for(let t=e;t<r;t++)op[t]=s;e=r-1}else 8==r&&1==i&&(op[e]=1);t=r,7&r&&(i=r)}}}(t,s,o,r,a),function(e,t,n,i,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:t,c=o<i.length?i[o].from:n;for(let t=h,n,i,o;t<c;t++)if(i=oh[n=e.charCodeAt(t)])if(i<0){for(let e=l-3;e>=0;e-=3)if(oc[e+1]==-i){let n=oc[e+2],i=2&n?r:4&n?1&n?s:r:0;i&&(op[t]=op[oc[e]]=i),l=e;break}}else if(189==oc.length)break;else oc[l++]=t,oc[l++]=n,oc[l++]=a;else if(2==(o=op[t])||1==o){let e=o==r;a=+!e;for(let t=l-3;t>=0;t-=3){let n=oc[t+2];if(2&n)break;if(e)oc[t+2]|=2;else{if(4&n)break;oc[t+2]|=4}}}}}(t,s,o,r,a),function(e,t,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t;for(let a=o;a<l;){let o=op[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==n.length)break;o=n[r++].to,l=r<n.length?n[r].from:t}else if(256==op[o])o++;else break;let h=1==s,c=h==((o<t?op[o]:i)==1)?h?1:2:i;for(let t=o,i=r,s=i?n[i-1].to:e;t>a;)t==s&&(t=n[--i].from,s=i?n[i-1].to:e),op[--t]=c;a=o}else s=o,a++}}}(s,o,r,a),function t(n,i,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=i,d=0;c<r;){let i=!0,u=!1;if(d==l.length||c<l[d].from){let e=op[c];e!=h&&(i=!1,u=16==e)}let f=i||1!=h?null:[],p=i?s:s+1,m=c;t:for(;;)if(d<l.length&&m==l[d].from){if(u)break;let t=l[d];if(!i)for(let e=t.to,n=d+1;;){if(e==r)break t;if(n<l.length&&l[n].from==e)e=l[n++].to;else if(op[e]==h)break t;else break}d++,f?f.push(t):(t.from>c&&a.push(new of(c,t.from,p)),e(n,t.direction==or!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.to),m=t.to}else if(m==r||(i?op[m]!=h:op[m]==h))break;else m++;f?t(n,c,m,s+1,o,f,a):c<m&&a.push(new of(c,m,p)),c=m}else for(let c=r,d=l.length;c>i;){let r=!0,u=!1;if(!d||c>l[d-1].to){let e=op[c-1];e!=h&&(r=!1,u=16==e)}let f=r||1!=h?null:[],p=r?s:s+1,m=c;t:for(;;)if(d&&m==l[d-1].to){if(u)break;let t=l[--d];if(!r)for(let e=t.from,n=d;;){if(e==i)break t;if(n&&l[n-1].to==e)e=l[--n].from;else if(op[e-1]==h)break t;else break}f?f.push(t):(t.to<c&&a.push(new of(t.to,c,p)),e(n,t.direction==or!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.from),m=t.from}else if(m==i||(r?op[m-1]!=h:op[m-1]==h))break;else m--;f?t(n,m,c,s+1,o,f,a):m<c&&a.push(new of(m,c,p)),c=m}}(t,s,o,n,i,r,l)}(e,r,r,n,0,e.length,i),i}(e.text,t,n);return this.bidiCache.push(new ah(e.from,e.to,t,n,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||sV.safari&&(null==(e=this.inputState)?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sv(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return oE.of(new oj("number"==typeof e?i9.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return oE.of(new oj(i9.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return oI.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return oI.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=r4.newName(),i=[l2.of(n),oJ.of(l9(".".concat(n),e))];return t&&t.dark&&i.push(l3.of(!0)),i}static baseTheme(e){return rc.lowest(oJ.of(l9("."+l4,e,l6)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&sN.get(n)||sN.get(e);return(null==(t=null==i?void 0:i.rootView)?void 0:t.view)||null}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new lY(e.state||rL.create(e)),e.scrollTo&&e.scrollTo.is(oE)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(oL).map(e=>new oB(e)),this.plugins))t.update(this);this.observer=new an(this),this.inputState=new lo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new oQ(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(t=document.fonts)?void 0:t.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}}ao.styleModule=oJ,ao.inputHandler=ok,ao.clipboardInputFilter=oC,ao.clipboardOutputFilter=oA,ao.scrollHandler=oO,ao.focusChangeEffect=oS,ao.perLineTextDirection=oN,ao.exceptionSink=oy,ao.updateListener=ow,ao.editable=oR,ao.mouseSelectionStyle=ob,ao.dragMovesSelection=ox,ao.clickAddsSelectionRange=ov,ao.decorations=o_,ao.outerDecorations=oW,ao.atomicRanges=oV,ao.bidiIsolatedRanges=oH,ao.scrollMargins=oK,ao.darkTheme=l3,ao.cspNonce=rt.define({combine:e=>e.length?e[0]:""}),ao.contentAttributes=oF,ao.editorAttributes=oz,ao.lineWrapping=ao.contentAttributes.of({class:"cm-lineWrapping"}),ao.announce=rM.define();let al=4096,aa={};class ah{static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:oi.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let s=e[r];s.dir!=i||t.touchesRange(s.from,s.to)||n.push(new ah(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return n}constructor(e,t,n,i,r,s){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=s}}function ac(e,t,n){for(let i=e.state.facet(t),r=i.length-1;r>=0;r--){let t=i[r],s="function"==typeof t?t(e):t;s&&sY(s,n)}return n}let ad=sV.mac?"mac":sV.windows?"win":sV.linux?"linux":"key";function au(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}let af=rc.default(ao.domEventHandlers({keydown:(e,t)=>ab(ag(t.state),e,t,"editor")})),ap=rt.define({enables:af}),am=new WeakMap;function ag(e){let t=e.facet(ap),n=am.get(t);return n||am.set(t,n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ad,n=Object.create(null),i=Object.create(null),r=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,i,s,o,l)=>{var a,h;let c=n[e]||(n[e]=Object.create(null)),d=i.split(/ (?!$)/).map(e=>(function(e,t){let n,i,r,s,o=e.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let e=0;e<o.length-1;++e){let l=o[e];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==t?s=!0:i=!0;else throw Error("Unrecognized modifier name: "+l)}return n&&(l="Alt-"+l),i&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(e,t));for(let t=1;t<d.length;t++){let n=d.slice(0,t).join(" ");r(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let i=av={view:t,prefix:n,scope:e};return setTimeout(()=>{av==i&&(av=null)},4e3),!0}]})}let u=d.join(" ");r(u,!1);let f=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null==(h=null==(a=c._any)?void 0:a.run)?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=i;for(let t in e)e[t].run.push(e=>r(e,ax))}let r=i[t]||i.key;if(r)for(let t of e)s(t,r,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(t,"Shift-"+r,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let av=null,ax=null;function ab(e,t,n,i){var r;ax=t;let s=("Esc"==(r=!(r7&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||se&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?r9:r6)[t.keyCode]||t.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=iQ(iG(s,0))==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;av&&av.view==n&&av.scope==i&&(l=av.prefix+" ",0>lc.indexOf(t.keyCode)&&(h=!0,av=null));let d=new Set,u=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),h=!0)}return!1},f=e[i],p,m;return f&&(u(f[l+au(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(sV.windows&&t.ctrlKey&&t.altKey)&&!(sV.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=r6[t.keyCode])&&p!=s?u(f[l+au(p,t,!0)])?a=!0:t.shiftKey&&(m=r9[t.keyCode])!=s&&m!=p&&u(f[l+au(m,t,!1)])&&(a=!0):o&&t.shiftKey&&u(f[l+au(s,t,!0)])&&(a=!0),!a&&u(f._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),ax=null,a}class ay{draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(!n.empty)return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),s=e.textDirection==oi.LTR,o=e.contentDOM,l=o.getBoundingClientRect(),a=aw(e),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=o8(e,i,1),p=o8(e,r,-1),m=f.type==s0.Text?f:null,g=p.type==s0.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=ak(e,i,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=ak(e,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return x(b(n.from,n.to,m));{let t=m?b(n.from,null,m):y(f,!1),i=g?b(null,n.to,g):y(p,!0),r=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<i.top?r.push(v(d,t.bottom,u,i.top)):t.bottom<i.top&&e.elementAtHeight((t.bottom+i.top)/2).type==s0.Text&&(t.bottom=i.top=(t.bottom+i.top)/2),x(t).concat(r).concat(x(i))}function v(e,n,i,r){return new ay(t,e-a.left,n-a.top,i-e,r-n)}function x(e){let{top:t,bottom:n,horizontal:i}=e,r=[];for(let e=0;e<i.length;e+=2)r.push(v(i[e],t,i[e+1],n));return r}function b(t,n,i){let r=1e9,o=-1e9,l=[];function a(t,n,a,h,c){let f=e.coordsAtPos(t,t==i.to?-2:2),p=e.coordsAtPos(a,a==i.from?2:-2);f&&p&&(r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),c==oi.LTR?l.push(s&&n?d:f.left,s&&h?u:p.right):l.push(!s&&h?d:p.left,!s&&n?u:f.right))}let h=null!=t?t:i.from,c=null!=n?n:i.to;for(let i of e.visibleRanges)if(i.to>h&&i.from<c)for(let r=Math.max(i.from,h),s=Math.min(i.to,c);;){let i=e.state.doc.lineAt(r);for(let o of e.bidiSpans(i)){let e=o.from+i.from,l=o.to+i.from;if(e>=s)break;l>r&&a(Math.max(e,r),null==t&&e<=h,Math.min(l,s),null==n&&l>=c,o.dir)}if((r=i.to+1)>=s)break}return 0==l.length&&a(h,null==t,c,null==n,e.textDirection),{top:r,bottom:o,horizontal:l}}function y(e,t){let n=l.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n);{let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let r=aw(e);return[new ay(t,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}}constructor(e,t,n,i,r){this.className=e,this.left=t,this.top=n,this.width=i,this.height=r}}function aw(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==oi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function ak(e,t,n,i){let r=e.coordsAtPos(t,2*n);if(!r)return i;let s=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=e.posAtCoords({x:s.left+1,y:o}),a=e.posAtCoords({x:s.right-1,y:o});return null==l||null==a?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}class aS{update(e){e.startState.facet(aC)!=e.state.facet(aC)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(aC);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform="scale(".concat(1/e,", ").concat(1/t,")"))}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{var n;return n=this.drawn[t],!(e.constructor==n.constructor&&e.eq(n))})){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,sV.ios&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}}let aC=rt.define();function aA(e){return[oI.define(t=>new aS(t,e)),aC.of(e)]}let aN=rt.define({combine:e=>rI(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function aM(e){return e.startState.facet(aN)!=e.state.facet(aN)}let aO=aA({above:!0,markers(e){let{state:t}=e,n=t.facet(aN),i=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||n.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=r.empty?r:i9.cursor(r.head,r.head>r.anchor?-1:1);for(let r of ay.forRange(e,t,n))i.push(r)}}return i},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=aM(e);return n&&aj(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){aj(t.state,e)},class:"cm-cursorLayer"});function aj(e,t){t.style.animationDuration=e.facet(aN).cursorBlinkRate+"ms"}let aE=aA({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:ay.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||aM(e),class:"cm-selectionLayer"}),aT=rc.highest(ao.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),aD=rM.define({map:(e,t)=>null==e?null:t.mapPos(e)}),aR=rl.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(aD)?t.value:e,e))}),aP=oI.fromClass(class{update(e){var t;let n=e.state.field(aR);null==n?null!=this.cursor&&(null==(t=this.cursor)||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(aR)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(aR),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(aR)!=e&&this.view.dispatch({effects:aD.of(e)})}constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function aL(e,t,n,i,r){t.lastIndex=0;for(let s=e.iterRange(n,i),o=n,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)r(o+l.index,l)}class aI{createDeco(e){let t=new rV,n=t.add.bind(t);for(let{from:t,to:i}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}(e,this.maxLength))aL(e.state.doc,this.regexp,t,i,(t,i)=>this.addMatch(i,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return(e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>=e.view.viewport.from&&s<=e.view.viewport.to&&(n=Math.min(s,n),i=Math.max(o,i))}),e.viewportMoved||i-n>1e3)?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let r of e.visibleRanges){let s=Math.max(r.from,n),o=Math.min(r.to,i);if(o>=s){let n=e.state.doc.lineAt(s),i=n.to<o?e.state.doc.lineAt(o):n,l=Math.max(r.from,n.from),a=Math.min(r.to,i.to);if(this.boundary){for(;s>n.from;s--)if(this.boundary.test(n.text[s-1-n.from])){l=s;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){a=o;break}}let h=[],c,d=(e,t,n)=>h.push(n.range(e,t));if(n==i)for(this.regexp.lastIndex=l-n.from;(c=this.regexp.exec(n.text))&&c.index<a-n.from;)this.addMatch(c,e,c.index+n.from,d);else aL(e.state.doc,this.regexp,l,a,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>e<l||t>a,add:h})}}return t}constructor(e){let{regexp:t,decoration:n,decorate:i,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(e,t,n,r)=>i(r,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,i,r)=>{let s=n(e,t,i);s&&r(i,i+e[0].length,s)};else if(n)this.addMatch=(e,t,i,r)=>r(i,i+e[0].length,n);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}}let aB=null!=/x/.unicode?"gu":"g",az=RegExp("[\0-\b\n-\x1f-\u2028\u2029\uFEFF-]",aB),aF={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},a_=null,aW=rt.define({combine(e){let t=rI(e,{render:null,specialChars:az,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==a_&&"undefined"!=typeof document&&document.body){let t=document.body.style;a_=(null!=(e=t.tabSize)?e:t.MozTabSize)!=null}return a_||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,aB)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,aB)),t}}),aV=null;class aH extends sZ{eq(e){return e.code==this.code}toDOM(e){var t;let n=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),i=e.state.phrase("Control character")+" "+(aF[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}constructor(e,t){super(),this.options=e,this.code=t}}class aq extends sZ{eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}constructor(e){super(),this.width=e}}let aK=s1.line({class:"cm-activeLine"}),aU=oI.fromClass(class{update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let r=e.lineBlockAt(i.head);r.from>t&&(n.push(aK.range(r.from)),t=r.from)}return s1.set(n)}constructor(e){this.decorations=this.getDeco(e)}},{decorations:e=>e.decorations});class aJ extends sZ{toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?sl(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),i=sf(t[0],"rtl"!=n.direction),r=parseInt(n.lineHeight);return i.bottom-i.top>1.5*r?{left:i.left,right:i.right,top:i.top,bottom:i.top+r}:i}ignoreEvent(){return!1}constructor(e){super(),this.content=e}}function aG(e,t){var n;let i,r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(r),o=r-s.from,l=o>2e3?-1:o==s.length?(n=t.clientX,(i=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((i.left-n)/e.defaultCharacterWidth)):-1):rZ(s.text,e.state.tabSize,r-s.from);return{line:s.number,col:l,off:o}}let aY={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},aQ={style:"cursor: crosshair"},aX="-10000px";class a${update(e,t){var n;let i=e.state.facet(this.facet),r=i.filter(e=>e);if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let s=[],o=t?[]:null;for(let n=0;n<r.length;n++){let i=r[n],l=-1;if(i){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==i.create&&(l=e)}if(l<0)s[n]=this.createTooltipView(i,n?s[n-1]:null),o&&(o[n]=!!i.above);else{let i=s[n]=this.tooltipViews[l];o&&(o[n]=t[l]),i.update&&i.update(e)}}}for(let e of this.tooltipViews)0>s.indexOf(e)&&(this.removeTooltipView(e),null==(n=e.destroy)||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=i,this.tooltips=r,this.tooltipViews=s,!0}constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=n(e,r))}}function aZ(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}let a0=rt.define({combine:e=>{var t,n,i;return{position:sV.ios?"absolute":(null==(t=e.find(e=>e.position))?void 0:t.position)||"fixed",parent:(null==(n=e.find(e=>e.parent))?void 0:n.parent)||null,tooltipSpace:(null==(i=e.find(e=>e.tooltipSpace))?void 0:i.tooltipSpace)||aZ}}}),a1=new WeakMap,a2=oI.fromClass(class{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)for(let e of(this.intersectionObserver.disconnect(),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,i=e.state.facet(a0);if(i.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=i.position,this.manager.tooltipViews))e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer(),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),i=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=aX,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null==(e=t.destroy)||e.call(t);this.parent&&this.container.remove(),null==(t=this.resizeObserver)||t.disconnect(),null==(n=this.intersectionObserver)||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(sV.gecko)n=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==aX&&"0px"==e.style.left){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}}if(n||"absolute"==this.position)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);let i=this.view.scrollDOM.getBoundingClientRect(),r=oU(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.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(e=>{let{dom:t}=e;return t.getBoundingClientRect()}),space:this.view.state.facet(a0).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:n,space:i,scaleX:r,scaleY:s}=e,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,d=e.pos[l],u=e.size[l];if(!d||!1!==a.clip&&(d.bottom<=Math.max(n.top,i.top)||d.top>=Math.min(n.bottom,i.bottom)||d.right<Math.max(n.left,i.left)-.1||d.left>Math.min(n.right,i.right)+.1)){c.style.top=aX;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!f,m=u.right-u.left,g=null!=(t=a1.get(h))?t:u.bottom-u.top,v=h.offset||a5,x=this.view.textDirection==oi.LTR,b=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(d.left-14*!!f+v.x,i.right-m)):Math.min(Math.max(i.left,d.left-m+14*!!f-v.x),i.right-m),y=this.above[l];!a.strictSide&&(y?d.top-g-p-v.y<i.top:d.bottom+g+p+v.y>i.bottom)&&y==i.bottom-d.bottom>d.top-i.top&&(y=this.above[l]=!y);let w=(y?d.top-i.top:i.bottom-d.bottom)-p;if(w<g&&!1!==h.resize){if(w<this.view.defaultLineHeight){c.style.top=aX;continue}a1.set(h,g),c.style.height=(g=w)/s+"px"}else c.style.height&&(c.style.height="");let k=y?d.top-g-p-v.y:d.bottom+p+v.y,S=b+m;if(!0!==h.overlap)for(let e of o)e.left<S&&e.right>b&&e.top<k+g&&e.bottom>k&&(k=y?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-e.parent.top)/s+"px",a3(c,(b-e.parent.left)/r)):(c.style.top=k/s+"px",a3(c,b/r)),f){let e=d.left+(x?v.x:-v.x)-(b+14-7);f.style.left=e/r+"px"}!0!==h.overlap&&o.push({left:b,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.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=aX}constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(a0);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="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new a$(e,a8,(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="function"==typeof IntersectionObserver?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()}},{eventObservers:{scroll(){this.maybeMeasure()}}});function a3(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}let a4=ao.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:"".concat(7,"px"),width:"".concat(14,"px"),position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"".concat(7,"px solid transparent"),borderRight:"".concat(7,"px solid transparent")},".cm-tooltip-above &":{bottom:"-".concat(7,"px"),"&:before":{borderTop:"".concat(7,"px solid #bbb")},"&:after":{borderTop:"".concat(7,"px solid #f5f5f5"),bottom:"1px"}},".cm-tooltip-below &":{top:"-".concat(7,"px"),"&:before":{borderBottom:"".concat(7,"px solid #bbb")},"&:after":{borderBottom:"".concat(7,"px solid #f5f5f5"),top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),a5={x:0,y:0},a8=rt.define({enables:[a2,a4]}),a6=rt.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class a9{static create(e){return new a9(e)}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)null==(e=t.destroy)||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i){if(void 0===t)t=i;else if(t!==i)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")}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new a$(e,a6,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}}let a7=a8.compute([a6],e=>{let t=e.facet(a6);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!=(t=e.end)?t:e.pos})),create:a9.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class he{update(){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;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let i,r=1;if(n instanceof sK)i=n.posAtStart;else{if(null==(i=e.posAtCoords(t)))return;let n=e.coordsAtPos(i);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let s=e.bidiSpans(e.state.doc.lineAt(i)).find(e=>e.from<=i&&e.to>=i),o=s&&s.dir==oi.RTL?-1:1;r=t.x<n.left?-o:o}let s=this.source(e,i,r);if(null==s?void 0:s.then){let t=this.pending={pos:i};s.then(n=>{this.pending==t&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>oD(e.state,t,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(a2),t=e?e.manager.tooltips.findIndex(e=>e.create==a9.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i.length&&r&&!function(e,t){let{left:n,right:i,top:r,bottom:s}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let e=o.getBoundingClientRect();r=Math.min(e.top,r),s=Math.max(e.bottom,s)}return t.clientX>=n-4&&t.clientX<=i+4&&t.clientY>=r-4&&t.clientY<=s+4}(r.dom,e)||this.pending){let{pos:r}=i[0]||this.pending,s=null!=(n=null==(t=i[0])?void 0:t.end)?n:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!function(e,t,n,i,r,s){let o=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=e.posAtCoords({x:i,y:r},!1);return a>=t&&a<=n}(this.view,r,s,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){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),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}constructor(e,t,n,i,r){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=r,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))}}function ht(e,t){let n=e.plugin(a2);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}let hn=rM.define(),hi=rt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function hr(e,t){let n=e.plugin(hs),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}let hs=oI.fromClass(class{update(e){let t=e.state.facet(hi);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ho(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ho(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ha);if(n!=this.input){let t=n.filter(e=>e),i=[],r=[],s=[],o=[];for(let n of t){let t=this.specs.indexOf(n),l;t<0?(l=n(e.view),o.push(l)):(l=this.panels[t]).update&&l.update(e),i.push(l),(l.top?r:s).push(l)}for(let e of(this.specs=t,this.panels=i,this.top.sync(r),this.bottom.sync(s),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([])}constructor(e){this.input=e.state.facet(ha),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(hi);for(let n of(this.top=new ho(e,!0,t.topContainer),this.bottom=new ho(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))n.dom.classList.add("cm-panel"),n.mount&&n.mount()}},{provide:e=>ao.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ho{sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";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=hl(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=hl(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)}}constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}}function hl(e){let t=e.nextSibling;return e.remove(),t}let ha=rt.define({enables:hs});class hh extends rB{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}hh.prototype.elementClass="",hh.prototype.toDOM=void 0,hh.prototype.mapMode=i$.TrackBefore,hh.prototype.startSide=hh.prototype.endSide=-1,hh.prototype.point=!0;let hc=rt.define(),hd=rt.define(),hu={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>rW.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},hf=rt.define(),hp=rt.define({combine:e=>e.some(e=>e)});function hm(e){let t=[hg];return e&&!1===e.fixed&&t.push(hp.of(!0)),t}let hg=oI.fromClass(class{getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(hp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=rW.iter(this.view.state.facet(hc),this.view.viewport.from),i=[],r=this.gutters.map(e=>new hb(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(e.type)){let t=!0;for(let s of e.type)if(s.type==s0.Text&&t){for(let e of(hx(n,i,s.from),r))e.line(this.view,s,i);t=!1}else if(s.widget)for(let e of r)e.widget(this.view,s)}else if(e.type==s0.Text)for(let t of(hx(n,i,e.from),r))t.line(this.view,e,i);else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(hf),n=e.state.facet(hf),i=e.docChanged||e.heightChanged||e.viewportChanged||!rW.eq(e.startState.facet(hc),e.state.facet(hc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(i=!0);else{i=!0;let r=[];for(let i of n){let n=t.indexOf(i);n<0?r.push(new hy(this.view,i)):(this.gutters[n].update(e),r.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),0>r.indexOf(e)&&e.destroy();for(let e of r)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=r}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}constructor(e){for(let t of(this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(hf).map(t=>new hy(e,t)),this.fixed=!e.state.facet(hp),this.gutters))"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}},{provide:e=>ao.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,r=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==oi.LTR?{left:i,right:r}:{right:i,left:r}})});function hv(e){return Array.isArray(e)?e:[e]}function hx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class hb{addElement(e,t,n){let{gutter:i}=this,r=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==i.elements.length){let t=new hw(e,s,r,n);i.elements.push(t),i.dom.appendChild(t.dom)}else i.elements[this.i].update(e,s,r,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];hx(this.cursor,i,t.from),n.length&&(i=i.concat(n));let r=this.gutter.config.lineMarker(e,t,i);r&&i.unshift(r);let s=this.gutter;(0!=i.length||s.config.renderEmptyElements)&&this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let n of e.state.facet(hd)){let r=n(e,t.widget,t);r&&(i||(i=[])).push(r)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=rW.iter(e.markers,t.from)}}class hy{update(e){let t=this.markers;if(this.markers=hv(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!rW.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}constructor(e,t){for(let n in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(n,i=>{let r=i.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=i.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=hv(t.markers(e)),t.initialSpacer&&(this.spacer=new hw(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}}class hw{update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,i)&&this.setMarkers(e,i)}setMarkers(e,t){let n="cm-gutterElement",i=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<t.length?t[r++]:null,a=!1;if(l){let e=l.elementClass;e&&(n+=" "+e);for(let e=s;e<this.markers.length;e++)if(this.markers[e].compare(l)){o=e,a=!0;break}}else o=this.markers.length;for(;s<o;){let e=this.markers[s++];if(e.toDOM){e.destroy(i);let t=i.nextSibling;i.remove(),i=t}}if(!l)break;l.toDOM&&(a?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),a&&s++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}}let hk=rt.define(),hS=rt.define(),hC=rt.define({combine:e=>rI(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let i=n[e],r=t[e];n[e]=i?(e,t,n)=>i(e,t,n)||r(e,t,n):r}return n}})});class hA extends hh{eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}constructor(e){super(),this.number=e}}function hN(e,t){return e.state.facet(hC).formatNumber(t,e.state)}let hM=hf.compute([hC],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(hk),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new hA(hN(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let i of e.state.facet(hS)){let r=i(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(hC)!=e.state.facet(hC),initialSpacer:e=>new hA(hN(e,hO(e.state.doc.lines))),updateSpacer(e,t){let n=hN(t.view,hO(t.view.state.doc.lines));return n==e.number?e:new hA(n)},domEventHandlers:e.facet(hC).domEventHandlers,side:"before"}));function hO(e){let t=9;for(;t<e;)t=10*t+9;return t}let hj=new class extends hh{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},hE=hc.compute(["selection"],e=>{let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.head).from;r>n&&(n=r,t.push(hj.range(r)))}return rW.of(t)}),hT=0;class hD{constructor(e,t){this.from=e,this.to=t}}class hR{add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=hI.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}constructor(e={}){this.id=hT++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}}hR.closedBy=new hR({deserialize:e=>e.split(" ")}),hR.openedBy=new hR({deserialize:e=>e.split(" ")}),hR.group=new hR({deserialize:e=>e.split(" ")}),hR.isolate=new hR({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),hR.contextHash=new hR({perNode:!0}),hR.lookAhead=new hR({perNode:!0}),hR.mounted=new hR({perNode:!0});class hP{static get(e){return e&&e.props&&e.props[hR.mounted.id]}constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}}let hL=Object.create(null);class hI{static define(e){let t=e.props&&e.props.length?Object.create(null):hL,n=!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),i=new hI(e.name||"",t,e.id,n);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(hR.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(hR.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}}hI.none=new hI("",Object.create(null),0,8);class hB{extend(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=[];for(let e of this.types){let n=null;for(let i of t){let t=i(e);t&&(n||(n=Object.assign({},e.props)),n[t[0].id]=t[1])}i.push(n?new hI(e.name,n,e.id,e.flags):e)}return new hB(i)}constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}}let hz=new WeakMap,hF=new WeakMap;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(l||(l={}));class h_{toString(){let e=hP.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new hZ(this.topNode,e)}cursorAt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;arguments.length>2&&void 0!==arguments[2]&&arguments[2];let n=new hZ(hz.get(this)||this.topNode);return n.moveTo(e,t),hz.set(this,n._tree),n}get topNode(){return new hU(this,0,0,null)}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hq(hz.get(this)||this.topNode,e,t,!1);return hz.set(this,n),n}resolveInner(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hq(hF.get(this)||this.topNode,e,t,!0);return hF.set(this,n),n}resolveStack(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let e=i instanceof hU?i:i.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(r||(r=[i])).push(s.resolve(t,n)),e=s}else{let s=hP.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new hU(s.tree,s.overlay[0].from+e.from,-1,e);(r||(r=[i])).push(hq(o,t,n,!1))}}return r?hX(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,s=e.mode||0,o=(s&l.IncludeAnonymous)>0;for(let e=this.cursor(s|l.IncludeAnonymous);;){let s=!1;if(e.from<=r&&e.to>=i&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;s=!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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:h3(hI.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new h_(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new h_(hI.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=e,l=Array.isArray(n)?new hW(n,n.length):n,a=i.types,h=0,c=0;function d(e,t,n,r,s,o,l,a,h){let c=[],d=[];for(;e.length>r;)c.push(e.pop()),d.push(t.pop()+n-s);e.push(u(i.types[l],c,d,o-s,a-o,h)),t.push(s-n)}function u(e,t,n,i,r,s,o){if(s){let e=[hR.contextHash,s];o=o?[e].concat(o):[e]}if(r>25){let e=[hR.lookAhead,r];o=o?[e].concat(o):[e]}return new h_(e,t,n,i,o)}let f=[],p=[];for(;l.pos>0;)!function e(t,n,f,p,m,g){let{id:v,start:x,end:b,size:y}=l,w=c,k=h;for(;y<0;){if(l.next(),-1==y){let e=s[v];f.push(e),p.push(x-t);return}if(-3==y){h=v;return}if(-4==y){c=v;return}else throw RangeError("Unrecognized record size: ".concat(y))}let S=a[v],C,A,N=x-t;if(b-x<=r&&(A=function(e,t){let n=l.fork(),i=0,s=0,a=0,h=n.end-r,c={size:0,start:0,skip:0};n:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){c.size=i,c.start=s,c.skip=a,a+=4,i+=4,n.next();continue}let l=n.pos-e;if(e<0||l<r||n.start<h)break;let d=4*(n.id>=o),u=n.start;for(n.next();n.pos>l;){if(n.size<0)if(-3==n.size)d+=4;else break n;else n.id>=o&&(d+=4);n.next()}s=u,i+=e,a+=d}return(t<0||i==e)&&(c.size=i,c.start=s,c.skip=a),c.size>4?c:void 0}(l.pos-n,m))){let e=new Uint16Array(A.size-A.skip),n=l.pos-A.size,r=e.length;for(;l.pos>n;)r=function e(t,n,i){let{id:r,start:s,end:a,size:d}=l;if(l.next(),d>=0&&r<o){let o=i;if(d>4){let r=l.pos-(d-4);for(;l.pos>r;)i=e(t,n,i)}n[--i]=o,n[--i]=a-t,n[--i]=s-t,n[--i]=r}else -3==d?h=r:-4==d&&(c=r);return i}(A.start,e,r);C=new hV(e,b-A.start,i),N=A.start-t}else{let t=l.pos-y;l.next();let n=[],s=[],a=v>=o?v:-1,h=0,c=b;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-r&&(d(n,s,x,h,l.end,c,a,w,k),h=n.length,c=l.end),l.next()):g>2500?function(e,t,n,s){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:n,size:i}=l;if(i>4)l.next();else if(h>-1&&t<h)break;else h<0&&(h=n-r),o.push(e,t,n),a++,l.next()}if(a){let t=new Uint16Array(4*a),r=o[o.length-2];for(let e=o.length-3,n=0;e>=0;e-=3)t[n++]=o[e],t[n++]=o[e+1]-r,t[n++]=o[e+2]-r,t[n++]=n;n.push(new hV(t,o[2]-r,i)),s.push(r-e)}}(x,t,n,s):e(x,t,n,s,a,g+1);if(a>=0&&h>0&&h<n.length&&d(n,s,x,h,x,c,a,w,k),n.reverse(),s.reverse(),a>-1&&h>0){let e=function(e,t){return(n,i,r)=>{let s=0,o=n.length-1,l,a;if(o>=0&&(l=n[o])instanceof h_){if(!o&&l.type==e&&l.length==r)return l;(a=l.prop(hR.lookAhead))&&(s=i[o]+l.length+a)}return u(e,n,i,r,s,t)}}(S,k);C=h3(S,n,s,0,n.length,0,b-x,e,e)}else C=u(S,n,s,b-x,w-b,k)}f.push(C),p.push(N)}(e.start||0,e.bufferStart||0,f,p,-1,0);let m=null!=(t=e.length)?t:f.length?p[0]+f[0].length:0;return new h_(a[e.topID],f.reverse(),p.reverse(),m)}(e)}constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[e,t]of(this.props=Object.create(null),r))this.props["number"==typeof e?e:e.id]=t}}h_.empty=new h_(hI.none,[],[],0);class hW{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 hW(this.buffer,this.index)}constructor(e,t){this.buffer=e,this.index=t}}class hV{get type(){return hI.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return r+"("+s.join(",")+")"}findChild(e,t,n,i,r){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&(!hH(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){r[l++]=i[o++],r[l++]=i[o++]-n;let t=r[l++]=i[o++]-n;r[l++]=i[o++]-e,s=Math.max(s,t)}return new hV(r,s,this.set)}constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}}function hH(e,t,n,i){switch(e){case -2:return n<t;case -1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function hq(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof hU&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=i?0:l.IgnoreOverlays;if(i)for(let i=e,o=i.parent;o;o=(i=o).parent)i instanceof hU&&i.index<0&&(null==(r=o.enter(t,n,s))?void 0:r.from)!=i.from&&(e=o);for(;;){let i=e.enter(t,n,s);if(!i)return e;e=i}}class hK{cursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new hZ(this,e)}getChild(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=hJ(this,e,t,n);return i.length?i[0]:null}getChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return hJ(this,e,t,n)}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return hq(this,e,t,!1)}resolveInner(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return hq(this,e,t,!0)}matchContext(e){return hG(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class hU extends hK{get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;for(let s=this;;){for(let{children:o,positions:a}=s._tree,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],c=a[e]+s.from;if(hH(i,n,c,c+h.length)){if(h instanceof hV){if(r&l.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,n-c,i);if(o>-1)return new hQ(new hY(s,h,e,c),null,o)}else if(r&l.IncludeAnonymous||!h.type.isAnonymous||h0(h)){let o;if(!(r&l.IgnoreMounts)&&(o=hP.get(h))&&!o.overlay)return new hU(o.tree,c,e,s);let a=new hU(h,c,e,s);return r&l.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?h.children.length-1:0,t,n,i)}}}if(r&l.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))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)}enter(e,t){let n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(i&l.IgnoreOverlays)&&(n=hP.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:e,to:r}of n.overlay)if((t>0?e<=i:e<i)&&(t<0?r>=i:r>i))return new hU(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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()}constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}}function hJ(e,t,n,i){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function hG(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-1;for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class hY{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class hQ extends hK{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]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new hQ(this.context,this,r)}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)}enter(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(n&l.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new hQ(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new hQ(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new hQ(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];e.push(n.slice(i,r,s)),t.push(0)}return new h_(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}}function hX(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let r=e[i];(r.from>n.from||r.to<n.to)&&(n=r,t=i)}let i=n instanceof hU&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new h$(r,n)}class h${get next(){return hX(this.heads)}constructor(e,t){this.heads=e,this.node=t}}class hZ{get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof hU?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}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:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}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){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.mode;return this.buffer?!(n&l.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&l.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&l.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));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:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&l.IncludeAnonymous||e instanceof hV||!e.type.isAnonymous||h0(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(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.move(1,e)}prev(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.move(-1,e)}moveTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)n:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;t=s,n=r+1;break n}i=this.stack[--r]}for(let e=n;e<this.stack.length;e++)t=new hQ(this.buffer,t,this.stack[e]);return this.bufferNode=new hQ(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return hG(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return hG(this._tree,e,i);let s=n[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof hU)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)}}}function h0(e){return e.children.some(e=>e instanceof hV||!e.type.isAnonymous||h0(e))}let h1=new WeakMap;function h2(e,t){if(!e.isAnonymous||t instanceof hV||t.type!=e)return 1;let n=h1.get(t);if(null==n){for(let i of(n=1,t.children)){if(i.type!=e||!(i instanceof h_)){n=1;break}n+=h2(e,i)}h1.set(t,n)}return n}function h3(e,t,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=h2(e,t[n]);let c=Math.ceil(1.5*h/8),d=[],u=[];return!function t(n,i,r,o,l){for(let h=r;h<o;){let r=h,f=i[h],p=h2(e,n[h]);for(h++;h<o;h++){let t=h2(e,n[h]);if(p+t>=c)break;p+=t}if(h==r+1){if(p>c){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+l);continue}d.push(n[r])}else{let t=i[h-1]+n[h-1].length-f;d.push(h3(e,n,i,r,h,f,t,null,a))}u.push(f+l-s)}}(t,n,i,r,0),(l||a)(d,u,o)}class h4{get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[new h4(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!t.length)return e;let i=[],r=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let t=s;if(l>=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,c)-a;t=e>=n?null:new h4(e,n,t.tree,t.offset+a,o>0,!!h)}if(t&&i.push(t),s.to>c)break;s=r<e.length?e[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}constructor(e,t,n,i,r=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=!!r|2*!!s}}class h5{startParse(e,t,n){return"string"==typeof e&&(e=new h8(e)),n=n?n.length?n.map(e=>new hD(e.from,e.to)):[new hD(0,0)]:[new hD(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class h8{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)}constructor(e){this.string=e}}new hR({perNode:!0});let h6=0;class h9{toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e="".concat(t.name,"(").concat(e,")"));return e}static define(e,t){if(e instanceof h9&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let n=new h9("string"==typeof e?e:"?",[],null,[]);if(n.set.push(n),t)for(let e of t.set)n.set.push(e);return n}static defineModifier(e){let t=new ce(e);return e=>e.modified.indexOf(t)>-1?e:ce.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=h6++}}let h7=0;class ce{static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{var i,r;return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every((e,t)=>e==r[t]))});if(n)return n;let i=[],r=new h9(e.name,i,e,t);for(let e of t)e.instances.push(r);let s=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)i.push(ce.get(t,e));return r}constructor(e){this.name=e,this.instances=[],this.id=h7++}}function ct(e){let t=Object.create(null);for(let n in e){let i=e[n];for(let e of(Array.isArray(i)||(i=[i]),n.split(" ")))if(e){let n=[],r=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!i)throw RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),(t+=i[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);s=e.slice(t)}let o=n.length-1,l=n[o];if(!l)throw RangeError("Invalid path: "+e);let a=new ci(i,r,o>0?n.slice(0,o):null);t[l]=a.sort(t[l])}}return cn.add(t)}let cn=new hR;class ci{get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}}function cr(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}ci.empty=new ci([],2,null);class cs{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,i,r){let{type:s,from:o,to:l}=e;if(o>=n||l<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let a=i,h=function(e){let t=e.type.prop(cn);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||ci.empty,c=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,h.tags);if(c&&(a&&(a+=" "),a+=c,1==h.mode&&(i+=(i?" ":"")+c)),this.startSpan(Math.max(t,o),a),h.opaque)return;let d=e.tree&&e.tree.prop(hR.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),c=e.firstChild();for(let u=0,f=o;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+o:l,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&c)for(;e.from<v&&(this.highlightRange(e,g,v,i,r),this.startSpan(Math.min(v,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;(f=p.to+o)>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(n,f),"",h),this.startSpan(Math.min(n,f),a))}c&&e.parent()}else if(e.firstChild()){d&&(i="");do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),a)}while(e.nextSibling())e.parent()}}constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}}let co=h9.define,cl=co(),ca=co(),ch=co(ca),cc=co(ca),cd=co(),cu=co(cd),cf=co(cd),cp=co(),cm=co(cp),cg=co(),cv=co(),cx=co(),cb=co(cx),cy=co(),cw={comment:cl,lineComment:co(cl),blockComment:co(cl),docComment:co(cl),name:ca,variableName:co(ca),typeName:ch,tagName:co(ch),propertyName:cc,attributeName:co(cc),className:co(ca),labelName:co(ca),namespace:co(ca),macroName:co(ca),literal:cd,string:cu,docString:co(cu),character:co(cu),attributeValue:co(cu),number:cf,integer:co(cf),float:co(cf),bool:co(cd),regexp:co(cd),escape:co(cd),color:co(cd),url:co(cd),keyword:cg,self:co(cg),null:co(cg),atom:co(cg),unit:co(cg),modifier:co(cg),operatorKeyword:co(cg),controlKeyword:co(cg),definitionKeyword:co(cg),moduleKeyword:co(cg),operator:cv,derefOperator:co(cv),arithmeticOperator:co(cv),logicOperator:co(cv),bitwiseOperator:co(cv),compareOperator:co(cv),updateOperator:co(cv),definitionOperator:co(cv),typeOperator:co(cv),controlOperator:co(cv),punctuation:cx,separator:co(cx),bracket:cb,angleBracket:co(cb),squareBracket:co(cb),paren:co(cb),brace:co(cb),content:cp,heading:cm,heading1:co(cm),heading2:co(cm),heading3:co(cm),heading4:co(cm),heading5:co(cm),heading6:co(cm),contentSeparator:co(cp),list:co(cp),quote:co(cp),emphasis:co(cp),strong:co(cp),link:co(cp),monospace:co(cp),strikethrough:co(cp),inserted:co(),deleted:co(),changed:co(),invalid:co(),meta:cy,documentMeta:co(cy),annotation:co(cy),processingInstruction:co(cy),definition:h9.defineModifier("definition"),constant:h9.defineModifier("constant"),function:h9.defineModifier("function"),standard:h9.defineModifier("standard"),local:h9.defineModifier("local"),special:h9.defineModifier("special")};for(let e in cw){let t=cw[e];t instanceof h9&&(t.name=e)}cr([{tag:cw.link,class:"tok-link"},{tag:cw.heading,class:"tok-heading"},{tag:cw.emphasis,class:"tok-emphasis"},{tag:cw.strong,class:"tok-strong"},{tag:cw.keyword,class:"tok-keyword"},{tag:cw.atom,class:"tok-atom"},{tag:cw.bool,class:"tok-bool"},{tag:cw.url,class:"tok-url"},{tag:cw.labelName,class:"tok-labelName"},{tag:cw.inserted,class:"tok-inserted"},{tag:cw.deleted,class:"tok-deleted"},{tag:cw.literal,class:"tok-literal"},{tag:cw.string,class:"tok-string"},{tag:cw.number,class:"tok-number"},{tag:[cw.regexp,cw.escape,cw.special(cw.string)],class:"tok-string2"},{tag:cw.variableName,class:"tok-variableName"},{tag:cw.local(cw.variableName),class:"tok-variableName tok-local"},{tag:cw.definition(cw.variableName),class:"tok-variableName tok-definition"},{tag:cw.special(cw.variableName),class:"tok-variableName2"},{tag:cw.definition(cw.propertyName),class:"tok-propertyName tok-definition"},{tag:cw.typeName,class:"tok-typeName"},{tag:cw.namespace,class:"tok-namespace"},{tag:cw.className,class:"tok-className"},{tag:cw.macroName,class:"tok-macroName"},{tag:cw.propertyName,class:"tok-propertyName"},{tag:cw.operator,class:"tok-operator"},{tag:cw.comment,class:"tok-comment"},{tag:cw.meta,class:"tok-meta"},{tag:cw.invalid,class:"tok-invalid"},{tag:cw.punctuation,class:"tok-punctuation"}]);let ck=new hR,cS=new hR;class cC{isActiveAt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return cA(e,t,n).type.prop(ck)==this.data}findRegions(e){let t=e.facet(cI);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(ck)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(hR.mounted);if(r){if(r.tree.prop(ck)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof h_&&i(r,e.positions[n]+t)}};return i(cM(e),0),n}get allowsNesting(){return!0}constructor(e,t,n=[],i=""){this.data=e,this.name=i,rL.prototype.hasOwnProperty("tree")||Object.defineProperty(rL.prototype,"tree",{get(){return cM(this)}}),this.parser=t,this.extension=[cI.of(this),rL.languageData.of((e,t,n)=>{let i=cA(e,t,n),r=i.type.prop(ck);if(!r)return[];let s=e.facet(r),o=i.type.prop(cS);if(o){let r=i.resolve(t-i.from,n);for(let t of o)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(s)}}return s})].concat(n)}}function cA(e,t,n){let i=e.facet(cI),r=cM(e).topNode;if(!i||i.allowsNesting)for(let e=r;e;e=e.enter(t,n,l.ExcludeBuffers))e.type.isTop&&(r=e);return r}cC.setState=rM.define();class cN extends cC{static define(e){var t;let n=(t=e.languageData,rt.define({combine:t?e=>e.concat(t):void 0}));return new cN(n,e.parser.configure({props:[ck.add(e=>e.isTop?n:void 0)]}),e.name)}configure(e,t){return new cN(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}constructor(e,t,n){super(e,t,[],n),this.parser=t}}function cM(e){let t=e.field(cC.state,!1);return t?t.tree:h_.empty}class cO{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<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}}let cj=null;class cE{static create(e,t,n){return new cE(e,t,[],h_.empty,0,n,[],null)}startParse(){return this.parser.startParse(new cO(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=h_.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(h4.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(h4.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=cj;cj=this;try{return e()}finally{cj=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=cT(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r})),n=h4.applyChanges(n,t),i=h_.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&o.push({from:n,to:i})}}return new cE(this.parser,t,n,i,r,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=cT(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends h5{createParse(t,n,i){let r=i[0].from,s=i[i.length-1].to;return{parsedPos:r,advance(){let t=cj;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new h_(hI.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return cj}constructor(e,t,n=[],i,r,s,o,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}}function cT(e,t,n){return h4.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class cD{apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new cD(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=cE.create(e.facet(cI).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new cD(n)}constructor(e){this.context=e,this.tree=e.tree}}cC.state=rl.define({create:cD.init,update(e,t){for(let e of t.effects)if(e.is(cC.setState))return e.value;return t.startState.facet(cI)!=t.state.facet(cI)?cD.init(t.state):e.apply(t)}});let cR=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(cR=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});let cP="undefined"!=typeof navigator&&(null==(a=navigator.scheduling)?void 0:a.isInputPending)?()=>navigator.scheduling.isInputPending():null,cL=oI.fromClass(class{update(e){let t=this.view.state.field(cC.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(cC.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=cR(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(cC.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!cP?Math.max(25,e.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>cP&&cP()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:cC.setState.of(new cD(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>oD(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}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()}},{eventHandlers:{focus(){this.scheduleWork()}}}),cI=rt.define({combine:e=>e.length?e[0]:null,enables:e=>[cC.state,cL,ao.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class cB{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}let cz=rt.define(),cF=rt.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 c_(e){let t=e.facet(cF);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function cW(e,t){let n="",i=e.tabSize,r=e.facet(cF)[0];if(" "==r){for(;t>=i;)n+=" ",t-=i;r=" "}for(let e=0;e<t;e++)n+=r;return n}function cV(e,t){for(let n of(e instanceof rL&&(e=new cH(e)),e.state.facet(cz))){let i=n(e,t);if(void 0!==i)return i}let n=cM(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let e=[];for(let t=r;t&&!(t.from<i.node.from||t.to>i.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return cK(i,e,n)}(e,n,t):null}class cH{lineAt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==e)return{text:"",from:e};else if(t<0?i<e:i<=e)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,{text:n,from:i}=this.lineAt(e,t),r=this.countColumn(n,e-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length;return rZ(e,this.state.tabSize,t)}lineIndent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,{text:n,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}constructor(e,t={}){this.state=e,this.options=t,this.unit=c_(e)}}let cq=new hR;function cK(e,t,n){for(let i=e;i;i=i.next){let e=function(e){let t=e.type.prop(cq);if(t)return t;let n=e.firstChild,i;if(n&&(i=n.type.prop(hR.closedBy))){let t=e.lastChild,n=t&&i.indexOf(t.name)>-1;return e=>(function(e,t,n,i,r){let s=e.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==e.pos+o,a=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=n.to;;){let r=t.childAfter(e);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+e}}e=r.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:+e.unit)})(e,!0,1,void 0,n&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?cU:null}(i.node);if(e)return e(cJ.create(t,n,i))}return 0}function cU(){return 0}class cJ extends cH{get node(){return this.context.node}static create(e,t,n){return new cJ(e,t,n)}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(function(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return cK(this.context.next,this.base,this.pos)}constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}}function cG(){let{except:e,units:t=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}let cY=rt.define(),cQ=new hR;function cX(e,t,n){for(let i of e.facet(cY)){let r=i(e,t,n);if(r)return r}return function(e,t,n){let i=cM(e);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<t)break;let l=r.type.prop(cQ);if(l&&(r.to<i.length-50||i.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(r))){let i=l(r,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(s=i)}}return s}(e,t,n)}function c$(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}let cZ=rM.define({map:c$}),c0=rM.define({map:c$});function c1(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}let c2=rl.define({create:()=>s1.none,update(e,t){for(let n of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=c3(e,t,n)),e=e.map(t.changes),t.effects))if(n.is(cZ)&&!function(e,t,n){let i=!1;return e.between(t,t,(e,r)=>{e==t&&r==n&&(i=!0)}),i}(e,n.value.from,n.value.to)){let{preparePlaceholder:i}=t.state.facet(c7),r=i?s1.replace({widget:new di(i(t.state,n.value))}):dn;e=e.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(c0)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=c3(e,t.selection.main.head)),e},provide:e=>ao.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],r=e[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");t.push(dn.range(i,r))}return s1.set(t,!0)}});function c3(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=!1;return e.between(t,n,(e,r)=>{e<n&&r>t&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(e,i)=>e>=n||i<=t}):e}function c4(e,t,n){var i;let r=null;return null==(i=e.field(c2,!1))||i.between(t,n,(e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})}),r}function c5(e,t){return e.field(c2,!1)?t:t.concat(rM.appendConfig.of(de()))}function c8(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return ao.announce.of("".concat(e.state.phrase(n?"Folded lines":"Unfolded lines")," ").concat(i," ").concat(e.state.phrase("to")," ").concat(r,"."))}let c6=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of c1(e)){let n=cX(e.state,t.from,t.to);if(n)return e.dispatch({effects:c5(e.state,[cZ.of(n),c8(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(c2,!1))return!1;let t=[];for(let n of c1(e)){let i=c4(e.state,n.from,n.to);i&&t.push(c0.of(i),c8(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let r=e.lineBlockAt(i),s=cX(t,r.from,r.to);s&&n.push(cZ.of(s)),i=(s?e.lineBlockAt(s.to):r).to+1}return n.length&&e.dispatch({effects:c5(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(c2,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(c0.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],c9={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},c7=rt.define({combine:e=>rI(e,c9)});function de(e){let t=[c2,dl];return e&&t.push(c7.of(e)),t}function dt(e,t){let{state:n}=e,i=n.facet(c7),r=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=c4(e.state,n.from,n.to);i&&e.dispatch({effects:c0.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let dn=s1.replace({widget:new class extends sZ{toDOM(e){return dt(e,null)}}});class di extends sZ{eq(e){return this.value==e.value}toDOM(e){return dt(e,this.value)}constructor(e){super(),this.value=e}}let dr={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ds extends hh{eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}constructor(e,t){super(),this.config=e,this.open=t}}let dl=ao.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class da{static define(e,t){return new da(e,t||{})}constructor(e,t){let n;function i(e){let t=r4.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;let r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,s=t.scope;this.scope=s instanceof cC?e=>e.prop(ck)==s.data:s?e=>e==s:void 0,this.style=cr(e.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=n?new r4(n):null,this.themeType=t.themeType}}let dh=rt.define(),dc=rt.define({combine:e=>e.length?[e[0]]:null});function dd(e){let t=e.facet(dh);return t.length?t:e.facet(dc)}function du(e,t){let n=[df],i;return e instanceof da&&(e.module&&n.push(ao.styleModule.of(e.module)),i=e.themeType),(null==t?void 0:t.fallback)?n.push(dc.of(e)):i?n.push(dh.computeN([ao.darkTheme],t=>t.facet(ao.darkTheme)==("dark"==i)?[e]:[])):n.push(dh.of(e)),n}let df=rc.high(oI.fromClass(class{update(e){let t=cM(e.state),n=dd(e.state),i=n!=dd(e.startState),{viewport:r}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!i&&t.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return s1.none;let n=new rV;for(let{from:i,to:r}of e.visibleRanges)!function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.length,s=new cs(i,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),i,r,"",s.highlighters),s.flush(r)}(this.tree,t,(e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=s1.mark({class:i})))},i,r);return n.finish()}constructor(e){this.markCache=Object.create(null),this.tree=cM(e.state),this.decorations=this.buildDeco(e,dd(e.state)),this.decoratedTo=e.viewport.to}},{decorations:e=>e.decorations})),dp=da.define([{tag:cw.meta,color:"#404740"},{tag:cw.link,textDecoration:"underline"},{tag:cw.heading,textDecoration:"underline",fontWeight:"bold"},{tag:cw.emphasis,fontStyle:"italic"},{tag:cw.strong,fontWeight:"bold"},{tag:cw.strikethrough,textDecoration:"line-through"},{tag:cw.keyword,color:"#708"},{tag:[cw.atom,cw.bool,cw.url,cw.contentSeparator,cw.labelName],color:"#219"},{tag:[cw.literal,cw.inserted],color:"#164"},{tag:[cw.string,cw.deleted],color:"#a11"},{tag:[cw.regexp,cw.escape,cw.special(cw.string)],color:"#e40"},{tag:cw.definition(cw.variableName),color:"#00f"},{tag:cw.local(cw.variableName),color:"#30a"},{tag:[cw.typeName,cw.namespace],color:"#085"},{tag:cw.className,color:"#167"},{tag:[cw.special(cw.variableName),cw.macroName],color:"#256"},{tag:cw.definition(cw.propertyName),color:"#00c"},{tag:cw.comment,color:"#940"},{tag:cw.invalid,color:"#f00"}]),dm=ao.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),dg="()[]{}",dv=rt.define({combine:e=>rI(e,{afterCursor:!0,brackets:dg,maxScanDistance:1e4,renderMatch:dy})}),dx=s1.mark({class:"cm-matchingBracket"}),db=s1.mark({class:"cm-nonmatchingBracket"});function dy(e){let t=[],n=e.matched?dx:db;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}let dw=[rl.define({create:()=>s1.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(dv);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=dA(t.state,e.head,-1,i)||e.head>0&&dA(t.state,e.head-1,1,i)||i.afterCursor&&(dA(t.state,e.head,1,i)||e.head<t.state.doc.length&&dA(t.state,e.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,t.state)))}return s1.set(n,!0)},provide:e=>ao.decorations.from(e)}),dm],dk=new hR;function dS(e,t,n){let i=e.prop(t<0?hR.openedBy:hR.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==+(t<0))return[n[i+t]]}return null}function dC(e){let t=e.type.prop(dk);return t?t(e.node):e}function dA(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=i.maxScanDistance||1e4,s=i.brackets||dg,o=cM(e),l=o.resolveInner(t,n);for(let e=l;e;e=e.parent){let i=dS(e.type,n,s);if(i&&e.from<e.to){let r=dC(e);if(r&&(n>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return function(e,t,n,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=null==l?void 0:l.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do if(n<0?c.to<=i.from:c.from>=i.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let e=dC(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(dS(c.type,n,o))h++;else if(dS(c.type,-n,o)){if(0==h){let e=dC(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}while(n<0?c.prevSibling():c.nextSibling())return{start:a,matched:!1}}(0,0,n,e,r,i,s)}}return function(e,t,n,i,r,s,o){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?t-1:t,to:n>0?t+1:t},c=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;n<0&&(e+=s.length);let l=t+e*n;for(let e=n>0?0:s.length-1,t=n>0?s.length:-1;e!=t;e+=n){let t=o.indexOf(s[e]);if(!(t<0)&&i.resolveInner(l+e,1).type==r)if(t%2==0==n>0)d++;else{if(1==d)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};d--}}n>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,n,o,l.type,r,s)}let dN=Object.create(null),dM=[hI.none],dO=[],dj=Object.create(null),dE=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"]])dE[e]=function(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||cw[n];i?"function"==typeof i?t.length?t=t.map(i):dT(n,"Modifier ".concat(n," used at start of tag")):t.length?dT(n,"Tag ".concat(n," used as modifier")):t=Array.isArray(i)?i:[i]:dT(n,"Unknown highlighting tag ".concat(n))}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map(e=>e.id),s=dj[r];if(s)return s.id;let o=dj[r]=hI.define({id:dM.length,name:i,props:[ct({[i]:n})]});return dM.push(o),o.id}(dN,t);function dT(e,t){dO.indexOf(e)>-1||(dO.push(e),console.warn(t))}function dD(e,t){return n=>{let{state:i,dispatch:r}=n;if(i.readOnly)return!1;let s=e(t,i);return!!s&&(r(i.update(s)),!0)}}oi.RTL,oi.LTR;let dR=dD(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,i=[],r=-1;for(let{from:e,to:s}of n){let n=i.length,o=1e9,l=dI(t,e).line;if(l){for(let n=e;n<=s;){let a=t.doc.lineAt(n);if(a.from>r&&(e==s||s>a.from)){r=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,n=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),i.push({line:a,comment:n,token:l,indent:e,empty:t,single:!1})}n=a.to+1}if(o<1e9)for(let e=n;e<i.length;e++)i[e].indent<i[e].line.text.length&&(i[e].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=e&&i.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:r,empty:s,single:o}of i)(o||!s)&&e.push({from:t.from+r,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:r}of i)if(n>=0){let i=t.from+n,s=i+r.length;" "==t.text[s-t.from]&&s++,e.push({from:i,to:s})}return{changes:e}}return null},0),dP=dD(dB,0),dL=dD((e,t)=>dB(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}(t)),0);function dI(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function dB(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,i=n.map(e=>dI(t,e.from).block);if(!i.every(e=>e))return null;let r=n.map((e,n)=>(function(e,t,n,i){let r,s,{open:o,close:l}=t,a=e.sliceDoc(n-50,n),h=e.sliceDoc(i,i+50),c=/\s*$/.exec(a)[0].length,d=/^\s*/.exec(h)[0].length,u=a.length-c;if(a.slice(u-o.length,u)==o&&h.slice(d,d+l.length)==l)return{open:{pos:n-c,margin:c&&1},close:{pos:i+d,margin:d&&1}};i-n<=100?r=s=e.sliceDoc(n,i):(r=e.sliceDoc(n,n+50),s=e.sliceDoc(i-50,i));let f=/^\s*/.exec(r)[0].length,p=/\s*$/.exec(s)[0].length,m=s.length-p-l.length;return r.slice(f,f+o.length)==o&&s.slice(m,m+l.length)==l?{open:{pos:n+f+o.length,margin:+!!/\s/.test(r.charAt(f+o.length))},close:{pos:i-p-l.length,margin:+!!/\s/.test(s.charAt(m-1))}}:null})(t,i[n],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(n.map((e,t)=>r[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t=0,n;t<r.length;t++)if(n=r[t]){let r=i[t],{open:s,close:o}=n;e.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:e}}return null}let dz=rC.define(),dF=rC.define(),d_=rt.define(),dW=rt.define({combine:e=>rI(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}),dV=rl.define({create:()=>d1.empty,update(e,t){let n=t.state.facet(dW),i=t.annotation(dz);if(i){let r=dG.fromTransaction(t,i.selection),s=i.side,o=0==s?e.undone:e.done;return o=r?dY(o,o.length,n.minDepth,r):d$(o,t.startState.selection),new d1(0==s?i.rest:o,0==s?o:i.rest)}let r=t.annotation(dF);if(("full"==r||"before"==r)&&(e=e.isolate()),!1===t.annotation(rO.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=dG.fromTransaction(t),o=t.annotation(rO.time),l=t.annotation(rO.userEvent);return s?e=e.addChanges(s,o,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,n.newGroupDelay)),("full"==r||"after"==r)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new d1(e.done.map(dG.fromJSON),e.undone.map(dG.fromJSON))});function dH(e,t){return function(n){let{state:i,dispatch:r}=n;if(!t&&i.readOnly)return!1;let s=i.field(dV,!1);if(!s)return!1;let o=s.pop(e,i,t);return!!o&&(r(o),!0)}}let dq=dH(0,!1),dK=dH(1,!1),dU=dH(0,!0),dJ=dH(1,!0);class dG{setSelAfter(e){return new dG(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new dG(e.changes&&i0.fromJSON(e.changes),[],e.mapped&&iZ.fromJSON(e.mapped),e.startSelection&&i9.fromJSON(e.startSelection),e.selectionsAfter.map(i9.fromJSON))}static fromTransaction(e,t){let n=dX;for(let t of e.startState.facet(d_)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new dG(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,dX)}static selection(e){return new dG(void 0,dX,void 0,void 0,e)}constructor(e,t,n,i,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}}function dY(e,t,n,i){let r=e.slice(t+1>n+20?t-n-1:0,t);return r.push(i),r}function dQ(e,t){return e.length?t.length?e.concat(t):e:t}let dX=[];function d$(e,t){if(!e.length)return[dG.selection([t])];{let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),dY(e,e.length-1,1e9,n.setSelAfter(i)))}}function dZ(e,t){if(!e.length)return e;let n=e.length,i=dX;for(;n;){let r=function(e,t,n){let i=dQ(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):dX,n);if(!e.changes)return dG.selection(i);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new dG(r,rM.mapEffects(e.effects,t),o,e.startSelection.map(s),i)}(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,n);return t[n-1]=r,t}t=r.mapped,n--,i=r.selectionsAfter}return i.length?[dG.selection(i)]:dX}let d0=/^(input\.type|delete)($|\.)/;class d1{isolate(){return this.prevTime?new d1(this.done,this.undone):this}addChanges(e,t,n,i,r){var s,o;let l,a,h=this.done,c=h[h.length-1];return new d1(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!n||d0.test(n))&&(!c.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=c.changes,o=e.changes,l=[],a=!1,s.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,n,i)=>{for(let e=0;e<l.length;){let t=l[e++],r=l[e++];i>=t&&n<=r&&(a=!0)}}),a))||"input.type.compose"==n)?dY(h,h.length-1,i.minDepth,new dG(e.changes.compose(c.changes),dQ(rM.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,dX)):dY(h,h.length,i.minDepth,e),dX,t,n)}addSelection(e,t,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:dX;return s.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==e.ranges.length&&0===r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new d1(d$(this.done,e),this.undone,t,n)}addMapping(e){return new d1(dZ(this.done,e),dZ(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||t.selection;if(n&&r.selectionsAfter.length){let n,o;return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:dz.of({side:e,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?dX:i.slice(0,i.length-1);return r.mapped&&(n=dZ(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:dz.of({side:e,rest:n,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}constructor(e,t,n=0,i){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}}d1.empty=new d1(dX,dX);let d2=[{key:"Mod-z",run:dq,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:dK,preventDefault:!0},{linux:"Ctrl-Shift-z",run:dK,preventDefault:!0},{key:"Mod-u",run:dU,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dJ,preventDefault:!0}];function d3(e,t){return i9.create(e.ranges.map(t),e.mainIndex)}function d4(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function d5(e,t){let{state:n,dispatch:i}=e,r=d3(n.selection,t);return!r.eq(n.selection,!0)&&(i(d4(n,r)),!0)}function d8(e,t){return i9.cursor(t?e.to:e.from)}function d6(e,t){return d5(e,n=>n.empty?e.moveByChar(n,t):d8(n,t))}function d9(e){return e.textDirectionAt(e.state.selection.main.head)==oi.LTR}let d7=e=>d6(e,!d9(e)),ue=e=>d6(e,d9(e));function ut(e,t){return d5(e,n=>n.empty?e.moveByGroup(n,t):d8(n,t))}function un(e,t,n){let i,r,s=cM(e).resolveInner(t.head),o=n?hR.closedBy:hR.openedBy;for(let i=t.head;;){let t=n?s.childAfter(i):s.childBefore(i);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?i=n?t.to:t.from:s=t}return r=s.type.prop(o)&&(i=n?dA(e,s.from,1):dA(e,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,i9.cursor(r,n?-1:1)}function ui(e,t){return d5(e,n=>{if(!n.empty)return d8(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let ur=e=>ui(e,!1),us=e=>ui(e,!0);function uo(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,i=0,r;if(t){for(let t of e.state.facet(ao.scrollMargins)){let r=t(e);(null==r?void 0:r.top)&&(n=Math.max(null==r?void 0:r.top,n)),(null==r?void 0:r.bottom)&&(i=Math.max(null==r?void 0:r.bottom,i))}r=e.scrollDOM.clientHeight-n-i}else r=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:t,height:Math.max(e.defaultLineHeight,r-5)}}function ul(e,t){let n,i=uo(e),{state:r}=e,s=d3(r.selection,n=>n.empty?e.moveVertically(n,t,i.height):d8(n,t));if(s.eq(r.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+i.marginTop,a=o.bottom-i.marginBottom;t&&t.top>l&&t.bottom<a&&(n=ao.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(d4(r,s),{effects:n}),!0}let ua=e=>ul(e,!1),uh=e=>ul(e,!0);function uc(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=i9.cursor(i.from+n))}return r}function ud(e,t){let n=d3(e.state.selection,e=>{let n=t(e);return i9.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(d4(e.state,n)),!0)}function uu(e,t){return ud(e,n=>e.moveByChar(n,t))}let uf=e=>uu(e,!d9(e)),up=e=>uu(e,d9(e));function um(e,t){return ud(e,n=>e.moveByGroup(n,t))}function ug(e,t){return ud(e,n=>e.moveVertically(n,t))}let uv=e=>ug(e,!1),ux=e=>ug(e,!0);function ub(e,t){return ud(e,n=>e.moveVertically(n,t,uo(e).height))}let uy=e=>ub(e,!1),uw=e=>ub(e,!0),uk=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:0})),!0},uS=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.doc.length})),!0},uC=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.selection.main.anchor,head:0})),!0},uA=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0};function uN(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange(i=>{let{from:r,to:s}=i;if(r==s){let o=t(i);o<r?(n="delete.backward",o=uM(e,o,!1)):o>r&&(n="delete.forward",o=uM(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=uM(e,r,!1),s=uM(e,s,!0);return r==s?{range:i}:{changes:{from:r,to:s},range:i9.cursor(r,r<i.head?-1:1)}});return!r.changes.empty&&(e.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?ao.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function uM(e,t,n){if(e instanceof ao)for(let i of e.state.facet(ao.atomicRanges).map(t=>t(e)))i.between(t,t,(e,i)=>{e<t&&i>t&&(t=n?i:e)});return t}let uO=(e,t,n)=>uN(e,i=>{let r=i.from,{state:s}=e,o=s.doc.lineAt(r),l,a;if(n&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let e=rZ(l,s.tabSize)%c_(s)||c_(s);for(let t=0;t<e&&" "==l[l.length-1-t];t++)r--;a=r}else(a=iJ(o.text,r-o.from,t,t)+o.from)==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=iJ(o.text,a-o.from,!1,!1)+o.from);return a}),uj=e=>uO(e,!1,!0),uE=e=>uO(e,!0,!1),uT=(e,t)=>uN(e,n=>{let i=n.head,{state:r}=e,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let e=null;;){if(i==(t?s.to:s.from)){i==n.head&&s.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let l=iJ(s.text,i-s.from,t)+s.from,a=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||i!=n.head)&&(e=h),i=l}return i}),uD=e=>uT(e,!1);function uR(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),s=e.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=e.doc.lineAt(i.to-1)),n>=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(i)}else t.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return t}function uP(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let t of uR(e)){if(n?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1),o=s.length+1;if(n)for(let n of(i.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))r.push(i9.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(i.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))r.push(i9.range(n.anchor-o,n.head-o))}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:i9.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function uL(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of uR(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let uI=uz(!1),uB=uz(!0);function uz(e){return t=>{let{state:n,dispatch:i}=t;if(n.readOnly)return!1;let r=n.changeByRange(t=>{let{from:i,to:r}=t,s=n.doc.lineAt(i),o=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=cM(e).resolveInner(t),i=n.childBefore(t),r=n.childAfter(t),s;return i&&r&&i.to<=t&&r.from>=t&&(s=i.type.prop(hR.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}(n,i);e&&(i=r=(r<=s.to?s:n.doc.lineAt(r)).to);let l=new cH(n,{simulateBreak:i,simulateDoubleBreak:!!o}),a=cV(l,i);for(null==a&&(a=rZ(/^\s*/.exec(n.doc.lineAt(i).text)[0],n.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:i,to:r}=o:i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let h=["",cW(n,a)];return o&&h.push(cW(n,l.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:iz.of(h)},range:i9.cursor(i+1+h[1].length)}});return i(n.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function uF(e,t){let n=-1;return e.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let o=e.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:i9.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}let u_=e=>{let{state:t,dispatch:n}=e;return!t.readOnly&&(n(t.update(uF(t,(e,n)=>{n.push({from:e.from,insert:t.facet(cF)})}),{userEvent:"input.indent"})),!0)},uW=e=>{let{state:t,dispatch:n}=e;return!t.readOnly&&(n(t.update(uF(t,(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=rZ(i,t.tabSize),s=0,o=cW(t,Math.max(0,r-c_(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0)},uV=[{key:"Ctrl-b",run:d7,shift:uf,preventDefault:!0},{key:"Ctrl-f",run:ue,shift:up},{key:"Ctrl-p",run:ur,shift:uv},{key:"Ctrl-n",run:us,shift:ux},{key:"Ctrl-a",run:e=>d5(e,t=>i9.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>ud(e,t=>i9.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>d5(e,t=>i9.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>ud(e,t=>i9.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:uE},{key:"Ctrl-h",run:uj},{key:"Ctrl-k",run:e=>uN(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:uD},{key:"Ctrl-o",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=t.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:iz.of(["",""])},range:i9.cursor(e.from)}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:iJ(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:iJ(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:i9.cursor(s)}});return!i.changes.empty&&(n(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:uh}],uH=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>d5(e,t=>un(e.state,t,!d9(e))),shift:e=>ud(e,t=>un(e.state,t,!d9(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>d5(e,t=>un(e.state,t,d9(e))),shift:e=>ud(e,t=>un(e.state,t,d9(e)))},{key:"Alt-ArrowUp",run:e=>{let{state:t,dispatch:n}=e;return uP(t,n,!1)}},{key:"Shift-Alt-ArrowUp",run:e=>{let{state:t,dispatch:n}=e;return uL(t,n,!1)}},{key:"Alt-ArrowDown",run:e=>{let{state:t,dispatch:n}=e;return uP(t,n,!0)}},{key:"Shift-Alt-ArrowDown",run:e=>{let{state:t,dispatch:n}=e;return uL(t,n,!0)}},{key:"Escape",run:e=>{let{state:t,dispatch:n}=e,i=t.selection,r=null;return i.ranges.length>1?r=i9.create([i.main]):i.main.empty||(r=i9.create([i9.cursor(i.main.head)])),!!r&&(n(d4(t,r)),!0)}},{key:"Mod-Enter",run:uB},{key:"Alt-l",mac:"Ctrl-l",run:e=>{let{state:t,dispatch:n}=e,i=uR(t).map(e=>{let{from:n,to:i}=e;return i9.range(n,Math.min(i+1,t.doc.length))});return n(t.update({selection:i9.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:e=>{let{state:t,dispatch:n}=e,i=d3(t.selection,e=>{let n=cM(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return i9.range(n.to,n.from)}return e});return!i.eq(t.selection)&&(n(d4(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:uW},{key:"Mod-]",run:u_},{key:"Mod-Alt-\\",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=Object.create(null),r=new cH(t,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),s=uF(t,(e,n,s)=>{let o=cV(r,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],a=cW(t,o);(l!=a||s.from<e.from+l.length)&&(i[e.from]=o,n.push({from:e.from,to:e.from+l.length,insert:a}))});return s.changes.empty||n(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(uR(t).map(e=>{let{from:n,to:i}=e;return n>0?n--:i<t.doc.length&&i++,{from:n,to:i}})),i=d3(t.selection,t=>{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(n=i.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:e=>{let{state:t,dispatch:n}=e;return function(e,t,n){let i=!1,r=d3(e.selection,t=>{let r=dA(e,t.head,-1)||dA(e,t.head,1)||t.head>0&&dA(e,t.head-1,1)||t.head<e.doc.length&&dA(e,t.head+1,-1);if(!r||!r.end)return t;i=!0;let s=r.start.from==t.head?r.end.to:r.end.from;return n?i9.range(t.anchor,s):i9.cursor(s)});return!!i&&(t(d4(e,r)),!0)}(t,n,!1)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=dI(e.state,n.from);return i.line?dR(e):!!i.block&&dL(e)}},{key:"Alt-A",run:dP},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:d7,shift:uf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>ut(e,!d9(e)),shift:e=>um(e,!d9(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>d5(e,t=>uc(e,t,!d9(e))),shift:e=>ud(e,t=>uc(e,t,!d9(e))),preventDefault:!0},{key:"ArrowRight",run:ue,shift:up,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>ut(e,d9(e)),shift:e=>um(e,d9(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>d5(e,t=>uc(e,t,d9(e))),shift:e=>ud(e,t=>uc(e,t,d9(e))),preventDefault:!0},{key:"ArrowUp",run:ur,shift:uv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:uk,shift:uC},{mac:"Ctrl-ArrowUp",run:ua,shift:uy},{key:"ArrowDown",run:us,shift:ux,preventDefault:!0},{mac:"Cmd-ArrowDown",run:uS,shift:uA},{mac:"Ctrl-ArrowDown",run:uh,shift:uw},{key:"PageUp",run:ua,shift:uy},{key:"PageDown",run:uh,shift:uw},{key:"Home",run:e=>d5(e,t=>uc(e,t,!1)),shift:e=>ud(e,t=>uc(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:uk,shift:uC},{key:"End",run:e=>d5(e,t=>uc(e,t,!0)),shift:e=>ud(e,t=>uc(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:uS,shift:uA},{key:"Enter",run:uI,shift:uI},{key:"Mod-a",run:e=>{let{state:t,dispatch:n}=e;return n(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0}},{key:"Backspace",run:uj,shift:uj},{key:"Delete",run:uE},{key:"Mod-Backspace",mac:"Alt-Backspace",run:uD},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>uT(e,!0)},{mac:"Mod-Backspace",run:e=>uN(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})},{mac:"Mod-Delete",run:e=>uN(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})}].concat(uV.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),uq={key:"Tab",run:u_,shift:uW},uK="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class uU{peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return iG(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=iY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=iQ(e);let i=this.normalize(t);if(i.length)for(let e=0,r=n;;e++){let s=i.charCodeAt(e),o=this.match(s,r,this.bufferPos+this.bufferStart);if(e==i.length-1){if(o)return this.value=o,this;break}r==n&&e<t.length&&t.charCodeAt(e)==s&&r++}}}match(e,t,n){let i=null;for(let t=0;t<this.matches.length;t+=2){let r=this.matches[t],s=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?i={from:this.matches[t+1],to:n}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:n}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}constructor(e,t,n=0,i=e.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(uK(e)):uK,this.query=this.normalize(t)}}"undefined"!=typeof Symbol&&(uU.prototype[Symbol.iterator]=function(){return this});let uJ={from:-1,to:-1,match:/.*/.exec("")},uG="gm"+(null==/x/.unicode?"":"u");class uY{getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=uZ(this.text,i+ +(n==i)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}constructor(e,t,n,i=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=uJ,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new u$(e,t,n,i,r);this.re=new RegExp(t,uG+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=uZ(e,i),this.getLine(this.curLineStart)}}let uQ=new WeakMap;class uX{get to(){return this.from+this.text.length}static get(e,t,n){let i=uQ.get(e);if(!i||i.from>=n||i.to<=t){let i=new uX(t,e.sliceString(t,n));return uQ.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:r,from:s}=i;return s>t&&(r=e.sliceString(t,s)+r,s=t),i.to<n&&(r+=e.sliceString(i.to,n)),uQ.set(e,new uX(s,r)),new uX(t,r.slice(t-s,n-s))}constructor(e,t){this.from=e,this.text=t}}class u${chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=uZ(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=uX.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}constructor(e,t,n,i,r){this.text=e,this.to=r,this.done=!1,this.value=uJ,this.matchPos=uZ(e,i),this.re=new RegExp(t,uG+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=uX.get(e,i,this.chunkEnd(i+5e3))}}function uZ(e,t){if(t>=e.length)return t;let n=e.lineAt(t),i;for(;t<n.to&&(i=n.text.charCodeAt(t-n.from))>=56320&&i<57344;)t++;return t}function u0(e){let t=si("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:i}=e,r=i.doc.lineAt(i.selection.main.head),[,s,o,l,a]=n,h=l?+l.slice(1):0,c=o?+o:r.number;if(o&&a){let e=c/100;s&&(e=e*("-"==s?-1:1)+r.number/i.doc.lines),c=Math.round(i.doc.lines*e)}else o&&s&&(c=c*("-"==s?-1:1)+r.number);let d=i.doc.line(Math.max(1,Math.min(i.doc.lines,c))),u=i9.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[u1.of(!1),ao.scrollIntoView(u.from,{y:"center"})],selection:u}),e.focus()}return{dom:si("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:u1.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},si("label",e.state.phrase("Go to line"),": ",t)," ",si("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),si("button",{name:"close",onclick:()=>{e.dispatch({effects:u1.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(uY.prototype[Symbol.iterator]=u$.prototype[Symbol.iterator]=function(){return this});let u1=rM.define(),u2=rl.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(u1)&&(e=n.value);return e},provide:e=>ha.from(e,e=>e?u0:null)}),u3=ao.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),u4={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},u5=rt.define({combine:e=>rI(e,u4,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),u8=s1.mark({class:"cm-selectionMatch"}),u6=s1.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function u9(e,t,n,i){return(0==n||e(t.sliceDoc(n-1,n))!=rR.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=rR.Word)}let u7=oI.fromClass(class{update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(u5),{state:n}=e,i=n.selection;if(i.ranges.length>1)return s1.none;let r=i.main,s,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return s1.none;let e=n.wordAt(r.head);if(!e)return s1.none;o=n.charCategorizer(r.head),s=n.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return s1.none;if(t.wholeWords){var l,a,h;if(s=n.sliceDoc(r.from,r.to),!(u9(o=n.charCategorizer(r.head),n,r.from,r.to)&&(l=o,a=r.from,h=r.to,l(n.sliceDoc(a,a+1))==rR.Word&&l(n.sliceDoc(h-1,h))==rR.Word)))return s1.none}else if(!(s=n.sliceDoc(r.from,r.to)))return s1.none}let c=[];for(let i of e.visibleRanges){let e=new uU(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!o||u9(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?c.push(u6.range(i,s)):(i>=r.to||s<=r.from)&&c.push(u8.range(i,s)),c.length>t.maxMatches))return s1.none}}return s1.set(c)}constructor(e){this.decorations=this.getDeco(e)}},{decorations:e=>e.decorations}),fe=ao.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ft=rt.define({combine:e=>rI(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new fE(e),scrollToMatch:e=>ao.scrollIntoView(e)})});class fn{unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new fh(this):new fs(this)}getCursor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=e.doc?e:rL.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?fo(this,i,t,n):fr(this,i,t,n)}constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,uG),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}}class fi{constructor(e){this.spec=e}}function fr(e,t,n,i){var r,s;return new uU(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,n,i)=>((i>e||i+n.length<t)&&(i=Math.max(0,e-2),n=r.sliceString(i,Math.min(r.length,t+2))),(s(fl(n,e-i))!=rR.Word||s(fa(n,e-i))!=rR.Word)&&(s(fa(n,t-i))!=rR.Word||s(fl(n,t-i))!=rR.Word))):void 0)}class fs extends fi{nextMatch(e,t,n){let i=fr(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=fr(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),r=fr(this.spec,e,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=fr(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=fr(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}constructor(e){super(e)}}function fo(e,t,n,i){var r;return new uY(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(r(fl(n.input,n.index))!=rR.Word||r(fa(n.input,n.index))!=rR.Word)&&(r(fa(n.input,n.index+n[0].length))!=rR.Word||r(fl(n.input,n.index+n[0].length))!=rR.Word)):void 0},n,i)}function fl(e,t){return e.slice(iJ(e,t,!1),t)}function fa(e,t){return e.slice(t,iJ(e,t))}class fh extends fi{nextMatch(e,t,n){let i=fo(this.spec,e,n,e.doc.length).next();return i.done&&(i=fo(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let r=Math.max(t,n-1e4*i),s=fo(this.spec,e,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let i=+n.slice(0,t);if(i>0&&i<e.match.length)return e.match[i]+n.slice(t)}return t})}matchAll(e,t){let n=fo(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=fo(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}let fc=rM.define(),fd=rM.define(),fu=rl.define({create:e=>new ff(fC(e).create(),null),update(e,t){for(let n of t.effects)n.is(fc)?e=new ff(n.value.create(),e.panel):n.is(fd)&&(e=new ff(e.query,n.value?fS:null));return e},provide:e=>ha.from(e,e=>e.panel)});class ff{constructor(e,t){this.query=e,this.panel=t}}let fp=s1.mark({class:"cm-searchMatch"}),fm=s1.mark({class:"cm-searchMatch cm-searchMatch-selected"}),fg=oI.fromClass(class{update(e){let t=e.state.field(fu);(t!=e.startState.field(fu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){let{query:t,panel:n}=e;if(!n||!t.spec.valid)return s1.none;let{view:i}=this,r=new rV;for(let e=0,n=i.visibleRanges,s=n.length;e<s;e++){let{from:o,to:l}=n[e];for(;e<s-1&&l>n[e+1].from-500;)l=n[++e].to;t.highlight(i.state,o,l,(e,t)=>{let n=i.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,n?fm:fp)})}return r.finish()}constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(fu))}},{decorations:e=>e.decorations});function fv(e){return t=>{let n=t.state.field(fu,!1);return n&&n.query.spec.valid?e(t,n):fM(t)}}let fx=fv((e,t)=>{let{query:n}=t,{to:i}=e.state.selection.main,r=n.nextMatch(e.state,i,i);if(!r)return!1;let s=i9.single(r.from,r.to),o=e.state.facet(ft);return e.dispatch({selection:s,effects:[fR(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),fN(e),!0}),fb=fv((e,t)=>{let{query:n}=t,{state:i}=e,{from:r}=i.selection.main,s=n.prevMatch(i,r,r);if(!s)return!1;let o=i9.single(s.from,s.to),l=e.state.facet(ft);return e.dispatch({selection:o,effects:[fR(e,s),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),fN(e),!0}),fy=fv((e,t)=>{let{query:n}=t,i=n.matchAll(e.state,1e3);return!!i&&!!i.length&&(e.dispatch({selection:i9.create(i.map(e=>i9.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),fw=fv((e,t)=>{let{query:n}=t,{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let o=n.nextMatch(i,r,r);if(!o)return!1;let l=o,a=[],h,c,d=[];l.from==r&&l.to==s&&(c=i.toText(n.getReplacement(l)),a.push({from:l.from,to:l.to,insert:c}),l=n.nextMatch(i,l.from,l.to),d.push(ao.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+".")));let u=e.state.changes(a);return l&&(h=i9.single(l.from,l.to).map(u),d.push(fR(e,l)),d.push(i.facet(ft).scrollToMatch(h.main,e))),e.dispatch({changes:u,selection:h,effects:d,userEvent:"input.replace"}),!0}),fk=fv((e,t)=>{let{query:n}=t;if(e.state.readOnly)return!1;let i=n.matchAll(e.state,1e9).map(e=>{let{from:t,to:i}=e;return{from:t,to:i,insert:n.getReplacement(e)}});if(!i.length)return!1;let r=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:ao.announce.of(r),userEvent:"input.replace.all"}),!0});function fS(e){return e.state.facet(ft).createPanel(e)}function fC(e,t){var n,i,r,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(ft);return new fn({search:(null!=(n=null==t?void 0:t.literal)?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!=(i=null==t?void 0:t.caseSensitive)?i:h.caseSensitive,literal:null!=(r=null==t?void 0:t.literal)?r:h.literal,regexp:null!=(s=null==t?void 0:t.regexp)?s:h.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:h.wholeWord})}function fA(e){let t=hr(e,fS);return t&&t.dom.querySelector("[main-field]")}function fN(e){let t=fA(e);t&&t==e.root.activeElement&&t.select()}let fM=e=>{let t=e.state.field(fu,!1);if(t&&t.panel){let n=fA(e);if(n&&n!=e.root.activeElement){let i=fC(e.state,t.query.spec);i.valid&&e.dispatch({effects:fc.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[fd.of(!0),t?fc.of(fC(e.state,t.query.spec)):rM.appendConfig.of(fL)]});return!0},fO=e=>{let t=e.state.field(fu,!1);if(!t||!t.panel)return!1;let n=hr(e,fS);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:fd.of(!1)}),!0},fj=[{key:"Mod-f",run:fM,scope:"editor search-panel"},{key:"F3",run:fx,shift:fb,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:fx,shift:fb,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:fO,scope:"editor search-panel"},{key:"Mod-Shift-l",run:e=>{let{state:t,dispatch:n}=e,i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:r,to:s}=i.main,o=[],l=0;for(let e=new uU(t.doc,t.sliceDoc(r,s));!e.next().done;){if(o.length>1e3)return!1;e.value.from==r&&(l=o.length),o.push(i9.range(e.value.from,e.value.to))}return n(t.update({selection:i9.create(o,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=hr(e,u0);if(!t){let n=[u1.of(!0)];null==e.state.field(u2,!1)&&n.push(rM.appendConfig.of([u2,u3])),e.dispatch({effects:n}),t=hr(e,u0)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:e=>{let{state:t,dispatch:n}=e,{ranges:i}=t.selection;if(i.some(e=>e.from===e.to))return(e=>{let{state:t,dispatch:n}=e,{selection:i}=t,r=i9.create(i.ranges.map(e=>t.wordAt(e.head)||i9.cursor(e.head)),i.mainIndex);return!r.eq(i)&&(n(t.update({selection:r})),!0)})({state:t,dispatch:n});let r=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=r))return!1;let s=function(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new uU(e.doc,t,i[i.length-1].to);;)if(r.next(),r.done){if(n)return null;r=new uU(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}else{if(n&&i.some(e=>e.from==r.value.from))continue;if(s){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}}(t,r);return!!s&&(n(t.update({selection:t.selection.addRange(i9.range(s.from,s.to),!1),effects:ao.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class fE{commit(){let e=new fn({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:fc.of(e)}))}keydown(e){var t;(t=this.view,ab(ag(t.state),e,t,"search-panel"))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?fb:fx)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),fw(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(fc)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ft).top}constructor(e){this.view=e;let t=this.query=e.state.field(fu).query.spec;function n(e,t,n){return si("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=si("input",{value:t.search,placeholder:fT(e,"Find"),"aria-label":fT(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=si("input",{value:t.replace,placeholder:fT(e,"Replace"),"aria-label":fT(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=si("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=si("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=si("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=si("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>fx(e),[fT(e,"next")]),n("prev",()=>fb(e),[fT(e,"previous")]),n("select",()=>fy(e),[fT(e,"all")]),si("label",null,[this.caseField,fT(e,"match case")]),si("label",null,[this.reField,fT(e,"regexp")]),si("label",null,[this.wordField,fT(e,"by word")]),...e.state.readOnly?[]:[si("br"),this.replaceField,n("replace",()=>fw(e),[fT(e,"replace")]),n("replaceAll",()=>fk(e),[fT(e,"replace all")])],si("button",{name:"close",onclick:()=>fO(e),"aria-label":fT(e,"close"),type:"button"},["×"])])}}function fT(e,t){return e.state.phrase(t)}let fD=/[\s\.,:;?!]/;function fR(e,t){let{from:n,to:i}=t,r=e.state.doc.lineAt(n),s=e.state.doc.lineAt(i).to,o=Math.max(r.from,n-30),l=Math.min(s,i+30),a=e.state.sliceDoc(o,l);if(o!=r.from){for(let e=0;e<30;e++)if(!fD.test(a[e+1])&&fD.test(a[e])){a=a.slice(e);break}}if(l!=s){for(let e=a.length-1;e>a.length-30;e--)if(!fD.test(a[e-1])&&fD.test(a[e])){a=a.slice(0,e);break}}return ao.announce.of("".concat(e.state.phrase("current match"),". ").concat(a," ").concat(e.state.phrase("on line")," ").concat(r.number,"."))}let fP=ao.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),fL=[fu,rc.low(fg),fP];class fI{tokenBefore(e){let t=cM(this.state).resolveInner(this.pos,-1);for(;t&&0>e.indexOf(t.name);)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),r=i.search(f_(e,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}}function fB(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),"[".concat(n?"\\w":"").concat(t.replace(/[^\w\s]/g,"\\$&"),"]")}class fz{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function fF(e){return e.selection.main.from}function f_(e,t){var n;let{source:i}=e,r=t&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?new RegExp("".concat(r?"^":"","(?:").concat(i,")").concat(s?"$":""),null!=(n=e.flags)?n:e.ignoreCase?"i":""):e}let fW=rC.define(),fV=new WeakMap;function fH(e){if(!Array.isArray(e))return e;let t=fV.get(e);return t||fV.set(e,t=function(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,i]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let i=fB(t)+fB(n)+"*$";return[RegExp("^"+i),new RegExp(i)]}(t);return e=>{let r=e.matchBefore(i);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:n}:null}}(e)),t}let fq=rM.define(),fK=rM.define();class fU{ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:r,byWord:s}=this;if(1==t.length){let i=iG(e,0),r=iQ(i),s=r==e.length?0:-100;if(i==t[0]);else{if(i!=n[0])return null;s+=-200}return this.ret(s,[0,r])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,a=0;if(o<0){for(let r=0,s=Math.min(e.length,200);r<s&&a<l;){let s=iG(e,r);(s==t[a]||s==n[a])&&(i[a++]=r),r+=iQ(s)}if(a<l)return null}let h=0,c=0,d=!1,u=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let i=0,a=Math.min(e.length,200),v=0;i<a&&c<l;){let a=iG(e,i);o<0&&(h<l&&a==t[h]&&(r[h++]=i),u<l&&(a==t[u]||a==n[u]?(0==u&&(f=i),p=i+1,u++):u=0));let x,b=a<255?a>=48&&a<=57||a>=97&&a<=122?2:+(a>=65&&a<=90):(x=iY(a))!=x.toLowerCase()?1:2*(x!=x.toUpperCase());(!i||1==b&&m||0==v&&0!=b)&&(t[c]==a||n[c]==a&&(d=!0)?s[c++]=i:s.length&&(g=!1)),v=b,i+=iQ(a)}return c==l&&0==s[0]&&g?this.result(-100+(d?-200:0),s,e):u==l&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):u==l?this.ret(-900-e.length,[f,p]):c==l?this.result(-100+(d?-200:0)+-700+(g?0:-1100),s,e):2==t.length?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,n){let i=[],r=0;for(let e of t){let t=e+(this.astral?iQ(iG(n,e)):1);r&&i[r-1]==e?i[r-1]=t:(i[r++]=e,i[r++]=t)}return this.ret(e-n.length,i)}constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=iG(e,t),i=iQ(n);this.chars.push(n);let r=e.slice(t,t+i),s=r.toUpperCase();this.folded.push(iG(s==r?r.toLowerCase():s,0)),t+=i}this.astral=e.length!=this.chars.length}}class fJ{match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}}let fG=rt.define({combine:e=>rI(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:fQ,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>fY(e(n),t(n)),optionClass:(e,t)=>n=>fY(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function fY(e,t){return e?t?e+" "+t:e:t}function fQ(e,t,n,i,r,s){let o=e.textDirection==oi.RTL,l=o,a=!1,h="top",c,d,u=t.left-r.left,f=r.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,f)?l=!1:!l&&f<Math.min(p,u)&&(l=!0),p<=(l?u:f))c=Math.max(r.top,Math.min(n.top,r.bottom-m))-t.top,d=Math.min(400,l?u:f);else{a=!0,d=Math.min(400,(o?t.right:r.right-t.left)-30);let e=r.bottom-t.bottom;e>=m||e>t.top?c=n.bottom-t.top:(h="bottom",c=t.bottom-n.top)}let g=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:"".concat(h,": ").concat(c/g,"px; max-width: ").concat(d/v,"px"),class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function fX(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class f${mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=fX(r.length,s,e.state.facet(fG).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null==(t=i.open)?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fX(t.options.length,t.selected,this.view.state.facet(fG).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)}).catch(e=>oD(this.view.state,e,"completion info")):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){var t,n;let i,r,s,o=null;for(let t=this.list.firstChild,n=this.range.from;t;t=t.nextSibling,n++)"LI"==t.nodeName&&t.id?n==e?t.hasAttribute("aria-selected")||(t.setAttribute("aria-selected","true"),o=t):t.hasAttribute("aria-selected")&&t.removeAttribute("aria-selected"):n--;return o&&(t=this.list,n=o,i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.height/t.offsetHeight,r.top<i.top?t.scrollTop-=(i.top-r.top)/s:r.bottom>i.bottom&&(t.scrollTop+=(r.bottom-i.bottom)/s)),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(r.bottom,t.bottom)-10||i.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(fG).positionInfo(this.view,t,i,n,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){let i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",e=>{e.target==i&&e.preventDefault()});let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=e[s],{section:a}=o;if(a){let e="string"==typeof a?a:a.name;e!=r&&(s>n.from||0==n.from)&&(r=e,"string"!=typeof a&&a.header?i.appendChild(a.header(a)):i.appendChild(document.createElement("completion-section")).textContent=e)}let h=i.appendChild(document.createElement("li"));h.id=t+"-"+s,h.setAttribute("role","option");let c=this.optionClass(o);for(let e of(c&&(h.className=c),this.optionContent)){let t=e(o,this.view.state,this.view,l);t&&h.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:r,selected:s}=i.open,o=e.state.facet(fG);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=e.displayLabel||e.label,o=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>o&&r.appendChild(document.createTextNode(s.slice(o,t)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(t,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fX(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=e.state.field(t).open;for(let t=n.target,r;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(r=/-(\d+)$/.exec(t.id))&&+r[1]<i.length){this.applyCompletion(e,i[+r[1]]),n.preventDefault();return}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(fG).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:fK.of(null)})}),this.showOptions(r,i.id)}}function fZ(e){return 100*(e.boost||0)+10*!!e.apply+5*!!e.info+ +!!e.type}class f0{setSelected(e,t){return e==this.selected||e>=this.options.length?this:new f0(this.options,f4(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,r,s){if(i&&!s&&e.some(e=>e.isPending))return i.setDisabled();let o=function(e,t){let n=[],i=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some(t=>t.name==e)||i.push("string"==typeof t?{name:e}:t)}},s=t.facet(fG);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)r(new fz(t,i.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(i.from,i.to),o,l=s.filterStrict?new fJ(n):new fU(n);for(let t of i.result.options)if(o=l.match(t.label)){let n=t.displayLabel?e?e(t,o.matched):[]:o.matched;r(new fz(t,i.source,n,o.score+(t.boost||0)))}}}if(i){let e=Object.create(null),t=0;for(let n of i.sort((e,t)=>{var n,i;return(null!=(n=e.rank)?n:1e9)-(null!=(i=t.rank)?i:1e9)||(e.name<t.name?-1:1)}))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let o=[],l=null,a=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||a(e.completion,t.completion))){let t=e.completion;l&&l.label==t.label&&l.detail==t.detail&&(null==l.type||null==t.type||l.type==t.type)&&l.apply==t.apply&&l.boost==t.boost?fZ(e.completion)>fZ(l)&&(o[o.length-1]=e):o.push(e),l=e.completion}return o}(e,t);if(!o.length)return i&&e.some(e=>e.isPending)?i.setDisabled():null;let l=t.facet(fG).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){l=t;break}}return new f0(o,f4(n,l),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:pi,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new f0(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new f0(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}constructor(e,t,n,i,r,s){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}}class f1{static start(){return new f1(f5,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(fG),i=(n.override||t.languageDataAt("autocomplete",fF(t)).map(fH)).map(t=>(this.active.find(e=>e.source==t)||new f6(t,+!!this.active.some(e=>0!=e.state))).update(e,n));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let r=this.open,s=e.effects.some(e=>e.is(f7));for(let o of(r&&e.docChanged&&(r=r.map(e.changes)),e.selection||i.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;i<t.length&&!t[i].hasResult();)i++;let r=n==e.length,s=i==t.length;if(r||s)return r==s;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)||s?r=f0.build(i,t,this.id,r,n,s):r&&r.disabled&&!i.some(e=>e.isPending)&&(r=null),!r&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new f6(e.source,0):e)),e.effects))o.is(pe)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new f1(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?f2:f3}constructor(e,t,n){this.active=e,this.id=t,this.open=n}}let f2={"aria-autocomplete":"list"},f3={};function f4(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}let f5=[];function f8(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(fW);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:16*!!e.docChanged}class f6{hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=f8(e,t),i=this;for(let t of((8&n||16&n&&this.touches(e))&&(i=new f6(i.source,0)),4&n&&0==i.state&&(i=new f6(this.source,1)),i=i.updateFor(e,n),e.effects))if(t.is(fq))i=new f6(i.source,1,t.value);else if(t.is(fK))i=new f6(i.source,0);else if(t.is(f7))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fF(e.state))}constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}}class f9 extends f6{hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let r=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),o=fF(e.state);if(o>s||!i||2&t&&(fF(e.startState)==this.from||o<this.limit))return new f6(this.source,4&t?1:0);let l=e.changes.mapPos(this.limit);return!function(e,t,n,i){if(!e)return!1;let r=t.sliceDoc(n,i);return"function"==typeof e?e(r,n,i,t):f_(e,!0).test(r)}(i.validFor,e.state,r,s)?i.update&&(i=i.update(i,r,s,new fI(e.state,o,!1)))?new f9(this.source,this.explicit,l,i,i.from,null!=(n=i.to)?n:fF(e.state)):new f6(this.source,1,this.explicit):new f9(this.source,this.explicit,l,i,r,s)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new f9(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new f6(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}constructor(e,t,n,i,r,s){super(e,3,t),this.limit=n,this.result=i,this.from=r,this.to=s}}let f7=rM.define({map:(e,t)=>e.map(e=>e.map(t))}),pe=rM.define(),pt=rl.define({create:()=>f1.start(),update:(e,t)=>e.update(t),provide:e=>[a8.from(e,e=>e.tooltip),ao.contentAttributes.from(e,e=>e.attrs)]});function pn(e,t){let n=t.completion.apply||t.completion.label,i=e.state.field(pt).active.find(e=>e.source==t.source);return i instanceof f9&&("string"==typeof n?e.dispatch({...function(e,t,n,i){let{main:r}=e.selection,s=n-r.from,o=i-r.from;return{...e.changeByRange(l=>{if(l!=r&&n!=i&&e.sliceDoc(l.from+s,l.from+o)!=e.sliceDoc(n,i))return{range:l};let a=e.toText(t);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:i9.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}(e.state,n,i.from,i.to),annotations:fW.of(t.completion)}):n(e,t.completion,i.from,i.to),!0)}let pi=e=>new f$(e,pt,pn);function pr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"option";return n=>{let i=n.state.field(pt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(fG).interactionDelay)return!1;let r=1,s;"page"==t&&(s=ht(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(e?1:-1):e?0:o-1;return l<0?l="page"==t?0:o-1:l>=o&&(l="page"==t?o-1:0),n.dispatch({effects:pe.of(l)}),!0}}let ps=e=>!!e.state.field(pt,!1)&&(e.dispatch({effects:fq.of(!0)}),!0);class po{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}let pl=oI.fromClass(class{update(e){let t=e.state.field(pt),n=e.state.facet(fG);if(!e.selectionSet&&!e.docChanged&&e.startState.field(pt)==t)return;let i=e.transactions.some(e=>{let t=f8(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){oD(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(fq)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),r):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(pt);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fG).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=fF(t),i=new fI(t,n,e.explicit,this.view),r=new po(e,i);this.running.push(r),Promise.resolve(e.source(i)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:fK.of(null)}),oD(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fG).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(fG),i=this.view.state.field(pt);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=fF(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+ +!s.active.explicit),o=new f9(s.active.source,s.active.explicit,r,s.done,s.done.from,null!=(e=s.done.to)?e:i);for(let e of s.updates)o=o.update(e,n);if(o.hasResult()){t.push(o);continue}}let o=i.active.find(e=>e.source==s.active.source);if(o&&o.isPending)if(null==s.done){let e=new f6(s.active.source,0);for(let t of s.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:f7.of(t)})}constructor(e){for(let t of(this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,e.state.field(pt).active))t.isPending&&this.startQuery(t)}},{eventHandlers:{blur(e){let t=this.view.state.field(pt,!1);if(t&&t.tooltip&&this.view.state.facet(fG).closeOnBlur){let n=t.open&&ht(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:fK.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:fq.of(!1)}),20),this.composing=0}}}),pa="object"==typeof navigator&&/Win/.test(navigator.platform),ph=rc.highest(ao.domEventHandlers({keydown(e,t){let n=t.state.field(pt,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(pa&&e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(e=>e.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&pn(t,i),!1}})),pc=ao.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"".concat(400,"px"),boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"".concat(30,"px")},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"".concat(30,"px")},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),pd=s1.widget({widget:new class extends sZ{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),pu=s1.mark({class:"cm-snippetField"});class pf{map(e){let t=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;t.push(i)}return new pf(t,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}constructor(e,t){this.ranges=e,this.active=t,this.deco=s1.set(e.map(e=>(e.from==e.to?pd:pu).range(e.from,e.to)),!0)}}let pp=rM.define({map:(e,t)=>e&&e.map(t)}),pm=rM.define(),pg=rl.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(pp))return n.value;if(n.is(pm)&&e)return new pf(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ao.decorations.from(e,e=>e?e.deco:s1.none)});function pv(e){return t=>{var n;let{state:i,dispatch:r}=t,s=i.field(pg,!1);if(!s||e<0&&0==s.active)return!1;let o=s.active+e,l=e>0&&!s.ranges.some(t=>t.field==o+e);return r(i.update({selection:(n=s.ranges,i9.create(n.filter(e=>e.field==o).map(e=>i9.range(e.from,e.to)))),effects:pp.of(l?null:new pf(s.ranges,o)),scrollIntoView:!0})),!0}}let px=[{key:"Tab",run:pv(1),shift:pv(-1)},{key:"Escape",run:e=>{let{state:t,dispatch:n}=e;return!!t.field(pg,!1)&&(n(t.update({effects:pp.of(null)})),!0)}}],pb={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},py=rM.define({map(e,t){let n=t.mapPos(e,-1,i$.TrackAfter);return null==n?void 0:n}}),pw=new class extends rB{};pw.startSide=1,pw.endSide=-1;let pk=rl.define({create:()=>rW.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(py)&&(e=e.update({add:[pw.range(n.value,n.value+1)]}));return e}}),pS="()[]{}<>«»»«[]{}";function pC(e){for(let t=0;t<pS.length;t+=2)if(pS.charCodeAt(t)==e)return pS.charAt(t+1);return iY(e<128?e:e+1)}function pA(e,t){return e.languageDataAt("closeBrackets",t)[0]||pb}let pN="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),pM=ao.inputHandler.of((e,t,n,i)=>{if((pN?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||2==i.length&&1==iQ(iG(i,0))||t!=r.from||n!=r.to)return!1;let s=function(e,t){let n=pA(e,e.selection.main.head),i=n.brackets||pb.brackets;for(let r of i){let s=pC(iG(r,0));if(t==r)return s==r?function(e,t,n,i){let r=i.stringPrefixes||pb.stringPrefixes,s=null,o=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:py.of(i.to+t.length),range:i9.range(i.anchor+t.length,i.head+t.length)};let o=i.head,l=pE(e.doc,o),a;if(l==t){if(pT(e,o))return{changes:{insert:t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};else if(pj(e,o)){let i=n&&e.sliceDoc(o,o+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+i.length,insert:i},range:i9.cursor(o+i.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(a=pD(e,o-2*t.length,r))>-1&&pT(e,a))return{changes:{insert:t+t+t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};else if(e.charCategorizer(o)(l)!=rR.Word&&pD(e,o,r)>-1&&!function(e,t,n,i){let r=cM(e).resolveInner(t,-1),s=i.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=r.to==t&&r.parent;if(!a)break;r=a}return!1}(e,o,t,r))return{changes:{insert:t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};return{range:s=i}});return s?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,i.indexOf(r+r+r)>-1,n):function(e,t,n,i){let r=null,s=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:py.of(s.to+t.length),range:i9.range(s.anchor+t.length,s.head+t.length)};let o=pE(e.doc,s.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:s.head},effects:py.of(s.head+t.length),range:i9.cursor(s.head+t.length)}:{range:r=s}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,s,n.before||pb.before);if(t==s&&pj(e,e.selection.main.from))return function(e,t,n){let i=null,r=e.changeByRange(t=>t.empty&&pE(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:i9.cursor(t.head+n.length)}:i={range:t});return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(e,0,s)}return null}(e.state,i);return!!s&&(e.dispatch(s),!0)}),pO=[{key:"Backspace",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=pA(t,t.selection.main.head).brackets||pb.brackets,r=null,s=t.changeByRange(e=>{if(e.empty){let n=function(e,t){let n=e.sliceString(t-2,t);return iQ(iG(n,0))==n.length?n:n.slice(1)}(t.doc,e.head);for(let r of i)if(r==n&&pE(t.doc,e.head)==pC(iG(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:i9.cursor(e.head-r.length)}}return{range:r=e}});return r||n(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function pj(e,t){let n=!1;return e.field(pk).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function pE(e,t){let n=e.sliceString(t,t+2);return n.slice(0,iQ(iG(n,0)))}function pT(e,t){let n=cM(e).resolveInner(t+1);return n.parent&&n.from==t}function pD(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=rR.Word)return t;for(let r of n){let n=t-r.length;if(e.sliceDoc(n,t)==r&&i(e.sliceDoc(n-1,n))!=rR.Word)return n}return -1}let pR=[{key:"Ctrl-Space",run:ps},{mac:"Alt-`",run:ps},{mac:"Alt-i",run:ps},{key:"Escape",run:e=>{let t=e.state.field(pt,!1);return!!t&&!!t.active.some(e=>0!=e.state)&&(e.dispatch({effects:fK.of(null)}),!0)}},{key:"ArrowDown",run:pr(!0)},{key:"ArrowUp",run:pr(!1)},{key:"PageDown",run:pr(!0,"page")},{key:"PageUp",run:pr(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(pt,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(fG).interactionDelay)&&pn(e,t.open.options[t.open.selected])}}],pP=rc.highest(ap.computeN([fG],e=>e.facet(fG).defaultKeymap?[pR]:[]));class pL{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class pI{static init(e,t,n){let i=n.facet(pJ).markerFilter;i&&(e=i(e,n));let r=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),s=new rV,o=[],l=0;for(let e=0;;){let t,i,a=e==r.length?null:r[e];if(!a&&!o.length)break;for(o.length?(t=l,i=o.reduce((e,t)=>Math.min(e,t.to),a&&a.from>t?a.from:1e8)):(t=a.from,i=a.to,o.push(a),e++);e<r.length;){let n=r[e];if(n.from==t&&(n.to>n.from||n.to==t))o.push(n),e++,i=Math.min(n.to,i);else{i=Math.min(n.from,i);break}}let h=p1(o);if(o.some(e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from))s.add(t,t,s1.widget({widget:new pQ(h),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");s.add(t,i,s1.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>i)}))}l=i;for(let e=0;e<o.length;e++)o[e].to<=l&&o.splice(e--,1)}let a=s.finish();return new pI(a,t,pB(a))}constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}}function pB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=null;return e.between(n,1e9,(e,n,r)=>{let{spec:s}=r;if(!(t&&0>s.diagnostics.indexOf(t)))if(i){if(0>s.diagnostics.indexOf(i.diagnostic))return!1;i=new pL(i.from,n,i.diagnostic)}else i=new pL(e,n,t||s.diagnostics[0])}),i}function pz(e,t){let n=t.pos,i=t.end||n,r=e.state.facet(pJ).hideOn(e,n,i);if(null!=r)return r;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(pF))||e.changes.touchesRange(s.from,Math.max(s.to,i)))}let pF=rM.define(),p_=rM.define(),pW=rM.define(),pV=rl.define({create:()=>new pI(s1.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,r=e.panel;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=pB(n,e.selected.diagnostic,r)||pB(n,null,r)}!n.size&&r&&t.state.facet(pJ).autoPanel&&(r=null),e=new pI(n,r,i)}for(let n of t.effects)if(n.is(pF)){let i=t.state.facet(pJ).autoPanel?n.value.length?p$.open:null:e.panel;e=pI.init(n.value,i,t.state)}else n.is(p_)?e=new pI(e.diagnostics,n.value?p$.open:null,e.selected):n.is(pW)&&(e=new pI(e.diagnostics,e.panel,n.value));return e},provide:e=>[ha.from(e,e=>e.panel),ao.decorations.from(e,e=>e.diagnostics)]}),pH=s1.mark({class:"cm-lintRange cm-lintRange-active"});function pq(e,t){return si("ul",{class:"cm-tooltip-lint"},t.map(t=>pY(e,t,!1)))}let pK=e=>{let t=e.state.field(pV,!1);return!!t&&!!t.panel&&(e.dispatch({effects:p_.of(!1)}),!0)},pU=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(pV,!1);t&&t.panel||e.dispatch({effects:function(e,t){return e.field(pV,!1)?t:t.concat(rM.appendConfig.of(p4))}(e.state,[p_.of(!0)])});let n=hr(e,p$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(pV,!1);if(!t)return!1;let n=e.state.selection.main,i=t.diagnostics.iter(n.to+1);return(!!i.value||!!(i=t.diagnostics.iter(0)).value&&(i.from!=n.from||i.to!=n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],pJ=rt.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},rI(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function pG(e){let t=[];if(e)i:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some(e=>e.toLowerCase()==i.toLowerCase())){t.push(i);continue i}}t.push("")}return t}function pY(e,t,n){var i;let r=n?pG(t.actions):[];return si("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},si("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(i=t.actions)?void 0:i.map((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=pB(e.state.field(pV).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:l}=n,a=r[i]?l.indexOf(r[i]):-1,h=a<0?l:[l.slice(0,a),si("u",l.slice(a,a+1)),l.slice(a+1)];return si("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":" Action: ".concat(l).concat(a<0?"":' (access key "'.concat(r[i],')"'),".")},h)}),t.source&&si("div",{class:"cm-diagnosticSource"},t.source))}class pQ extends sZ{eq(e){return e.sev==this.sev}toDOM(){return si("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}constructor(e){super(),this.sev=e}}class pX{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=pY(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class p${get selectedIndex(){let e=this.view.state.field(pV).selected;if(!e)return -1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return -1}update(){let{diagnostics:e,selected:t}=this.view.state.field(pV),n=0,i=!1,r=null,s=new Set;for(e.between(0,this.view.state.doc.length,(e,o,l)=>{let{spec:a}=l;for(let e of a.diagnostics){if(s.has(e))continue;s.add(e);let o=-1,l;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(l=new pX(this.view,e),this.items.splice(n,0,l),i=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),i=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new pX(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:e=>{let{sel:t,panel:n}=e,i=n.height/this.list.offsetHeight;t.top<n.top?this.list.scrollTop-=(n.top-t.top)/i:t.bottom>n.bottom&&(this.list.scrollTop+=(t.bottom-n.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&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=pB(this.view.state.field(pV).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:pW.of(t)})}static open(e){return new p$(e)}constructor(e){this.view=e,this.items=[];let t=t=>{if(27==t.keyCode)pK(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],i=pG(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==t.keyCode){let t=pB(this.view.state.field(pV).diagnostics,n);t&&n.actions[r].apply(e,t.from,t.to)}}t.preventDefault()},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=si("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=si("div",{class:"cm-panel-lint"},this.list,si("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>pK(this.view)},"×")),this.update()}}function pZ(e){return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'viewBox="0 0 40 40"';return'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" '.concat(t,">").concat(encodeURIComponent(e),"</svg>')")}('<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="'.concat(e,'" fill="none" stroke-width=".7"/>'),'width="6" height="3"')}let p0=ao.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:pZ("#d11")},".cm-lintRange-warning":{backgroundImage:pZ("orange")},".cm-lintRange-info":{backgroundImage:pZ("#999")},".cm-lintRange-hint":{backgroundImage:pZ("#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}}});function p1(e){let t="hint",n=1;for(let r of e){var i;let e="error"==(i=r.severity)?4:"warning"==i?3:"info"==i?2:1;e>n&&(n=e,t=r.severity)}return t}let p2=rM.define(),p3=rl.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=pz(t,e)?null:Object.assign(Object.assign({},e),{pos:t.changes.mapPos(e.pos)})),t.effects.reduce((e,t)=>t.is(p2)?t.value:e,e)),provide:e=>a8.from(e)}),p4=[pV,ao.decorations.compute([pV],e=>{let{selected:t,panel:n}=e.field(pV);return t&&n&&t.from!=t.to?s1.set([pH.range(t.from,t.to)]):s1.none}),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=rM.define(),i=rl.define({create:()=>[],update(e,i){if(e.length&&(t.hideOnChange&&(i.docChanged||i.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(i,e))),i.docChanged)){let t=[];for(let n of e){let e=i.changes.mapPos(n.pos,-1,i$.TrackDel);if(null!=e){let r=Object.assign(Object.create(null),n);r.pos=e,null!=r.end&&(r.end=i.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(hn)&&(e=[]);return e},provide:e=>a6.from(e)});return{active:i,extension:[i,oI.define(r=>new he(r,e,i,n,t.hoverTime||300)),a7]}}(function(e,t,n){let{diagnostics:i}=e.state.field(pV),r,s=-1,o=-1;i.between(t-(n<0),t+ +(n>0),(e,i,l)=>{let{spec:a}=l;if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,s=e,o=i,!1});let l=e.state.facet(pJ).tooltipFilter;return(r&&l&&(r=l(r,e.state)),r)?{pos:s,end:o,above:e.state.doc.lineAt(s).to<o,create:()=>({dom:pq(e,r)})}:null},{hideOn:pz}),p0],p5=rt.define({combine:e=>rI(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});var p8=function(e){let t;void 0===e&&(e={});var{crosshairCursor:n=!1}=e,i=[];!1!==e.closeBracketsKeymap&&(i=i.concat(pO)),!1!==e.defaultKeymap&&(i=i.concat(uH)),!1!==e.searchKeymap&&(i=i.concat(fj)),!1!==e.historyKeymap&&(i=i.concat(d2)),!1!==e.foldKeymap&&(i=i.concat(c6)),!1!==e.completionKeymap&&(i=i.concat(pR)),!1!==e.lintKeymap&&(i=i.concat(pU));var r=[];return!1!==e.lineNumbers&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[hC.of(e),hm(),hM]}()),!1!==e.highlightActiveLineGutter&&r.push(hE),!1!==e.highlightSpecialChars&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[aW.of(e),aV||(aV=oI.fromClass(class{makeDecorator(e){return new aI({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:r}=n.state,s=iG(t[0],0);if(9==s){let e=r.lineAt(i),t=n.state.tabSize,s=rZ(e.text,t,i-e.from);return s1.replace({widget:new aq((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=s1.replace({widget:new aH(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(aW);e.startState.facet(aW)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}constructor(e){this.view=e,this.decorations=s1.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(aW)),this.decorations=this.decorator.createDeco(e)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[dV,dW.of(e),ao.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?dq:"historyRedo"==e.inputType?dK:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n={...dr,...t},i=new ds(n,!0),r=new ds(n,!1),s=oI.fromClass(class{update(e){(e.docChanged||e.viewportChanged||e.startState.facet(cI)!=e.state.facet(cI)||e.startState.field(c2,!1)!=e.state.field(c2,!1)||cM(e.startState)!=cM(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new rV;for(let n of e.viewportLineBlocks){let s=c4(e.state,n.from,n.to)?r:cX(e.state,n.from,n.to)?i:null;s&&t.add(n.from,n.from,s)}return t.finish()}constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}}),{domEventHandlers:o}=n;return[s,(e={class:"cm-foldGutter",markers(e){var t;return(null==(t=e.plugin(s))?void 0:t.markers)||rW.empty},initialSpacer:()=>new ds(n,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let i=c4(e.state,t.from,t.to);if(i)return e.dispatch({effects:c0.of(i)}),!0;let r=cX(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:cZ.of(r)}),!0)}}},[hm(),hf.of({...hu,...e})]),de()]}()),!1!==e.drawSelection&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[aN.of(e),aO,aE,aT,oM.of(!0)]}()),!1!==e.dropCursor&&r.push([aR,aP]),!1!==e.allowMultipleSelections&&r.push(rL.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(rL.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return e;let s=n.sliceString(r.from,i);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let n=cV(o,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],r=cW(o,n);i!=r&&a.push({from:t.from,to:t.from+i.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(du(dp,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[dv.of(e),dw]}()),!1!==e.closeBrackets&&r.push([pM,pk]),!1!==e.autocompletion&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[ph,pt,fG.of(e),pl,pP,pc]}()),!1!==e.rectangularSelection&&r.push((t=e=>e.altKey&&0==e.button,ao.mouseSelectionStyle.of((e,n)=>{let i,r;return t(n)?(i=aG(e,n),r=e.state.selection,{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(i.line).from),n=e.state.doc.lineAt(t);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},r=r.map(e.changes)}},get(t,n,s){let o=aG(e,t),l=function(e,t,n){let i=Math.min(t.line,n.line),r=Math.max(t.line,n.line),s=[];if(t.off>2e3||n.off>2e3||t.col<0||n.col<0){let o=Math.min(t.off,n.off),l=Math.max(t.off,n.off);for(let t=i;t<=r;t++){let n=e.doc.line(t);n.length<=l&&s.push(i9.range(n.from+o,n.to+l))}}else{let o=Math.min(t.col,n.col),l=Math.max(t.col,n.col);for(let t=i;t<=r;t++){let n=e.doc.line(t),i=r0(n.text,o,e.tabSize,!0);if(i<0)s.push(i9.cursor(n.to));else{let t=r0(n.text,l,e.tabSize);s.push(i9.range(n.from+i,n.from+t))}}}return s}(e.state,i,o);return l.length?s?i9.create(l.concat(r.ranges)):i9.create(l):r}}):null}))),!1!==n&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,n]=aY[e.key||"Alt"],i=oI.fromClass(class{set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}constructor(e){this.view=e,this.isDown=!1}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[i,ao.contentAttributes.of(e=>{var t;return(null==(t=e.plugin(i))?void 0:t.isDown)?aQ:null})]}()),!1!==e.highlightActiveLine&&r.push(aU),!1!==e.highlightSelectionMatches&&r.push([fe,u7]),e.tabSize&&"number"==typeof e.tabSize&&r.push(cF.of(" ".repeat(e.tabSize))),r.concat([ap.of(i.flat())]).filter(Boolean)};let p6="#e06c75",p9="#abb2bf",p7="#7d8799",me="#d19a66",mt="#2c313a",mn="#282c34",mi="#353a42",mr="#528bff",ms=[ao.theme({"&":{color:p9,backgroundColor:mn},".cm-content":{caretColor:mr},".cm-cursor, .cm-dropCursor":{borderLeftColor:mr},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:p9},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:mn,color:p7,border:"none"},".cm-activeLineGutter":{backgroundColor:mt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:mi},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:mi,borderBottomColor:mi},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:mt,color:p9}}},{dark:!0}),du(da.define([{tag:cw.keyword,color:"#c678dd"},{tag:[cw.name,cw.deleted,cw.character,cw.propertyName,cw.macroName],color:p6},{tag:[cw.function(cw.variableName),cw.labelName],color:"#61afef"},{tag:[cw.color,cw.constant(cw.name),cw.standard(cw.name)],color:me},{tag:[cw.definition(cw.name),cw.separator],color:p9},{tag:[cw.typeName,cw.className,cw.number,cw.changed,cw.annotation,cw.modifier,cw.self,cw.namespace],color:"#e5c07b"},{tag:[cw.operator,cw.operatorKeyword,cw.url,cw.escape,cw.regexp,cw.link,cw.special(cw.string)],color:"#56b6c2"},{tag:[cw.meta,cw.comment],color:p7},{tag:cw.strong,fontWeight:"bold"},{tag:cw.emphasis,fontStyle:"italic"},{tag:cw.strikethrough,textDecoration:"line-through"},{tag:cw.link,color:p7,textDecoration:"underline"},{tag:cw.heading,fontWeight:"bold",color:p6},{tag:[cw.atom,cw.bool,cw.special(cw.variableName)],color:me},{tag:[cw.processingInstruction,cw.string,cw.inserted],color:"#98c379"},{tag:cw.invalid,color:"#ffffff"}]))];var mo=ao.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ml=function(e){let t;void 0===e&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(n&&a.unshift(ap.of([uq])),l&&("boolean"==typeof l?a.unshift(p8()):a.unshift(p8(l))),o&&a.unshift((t=oI.fromClass(class{get decorations(){return this.view.state.doc.length?s1.none:this.placeholder}constructor(e){this.view=e,this.placeholder=o?s1.set([s1.widget({widget:new aJ(o),side:1}).range(0)]):s1.none}},{decorations:e=>e.decorations}),"string"==typeof o?[t,ao.contentAttributes.of({"aria-placeholder":o})]:t)),s){case"light":a.push(mo);break;case"dark":a.push(ms);break;case"none":break;default:a.push(s)}return!1===i&&a.push(ao.editable.of(!1)),r&&a.push(rL.readOnly.of(!0)),[...a]};class ma{tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error("TimeoutLatch callback error:",e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}}class mh{add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}constructor(){this.interval=null,this.latches=new Set}}var mc=null,md=rC.define(),mu=[],mf=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],mp=(0,d.forwardRef)((e,t)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:u,theme:f="light",height:p,minHeight:m,maxHeight:g,width:v,minWidth:x,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:S,readOnly:C,root:A,initialState:N}=e,M=function(e,t){if(null==e)return{};var n={};for(var i in e)if(({}).hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}(e,mf),O=(0,d.useRef)(null),{state:j,view:E,container:T,setContainer:D}=function(e){var{value:t,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:l=mu,autoFocus:a,theme:h="light",height:c=null,minHeight:u=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:x=!0,readOnly:b=!1,indentWithTab:y=!0,basicSetup:w=!0,root:k,initialState:S}=e,[C,A]=(0,d.useState)(),[N,M]=(0,d.useState)(),[O,j]=(0,d.useState)(),E=(0,d.useState)(()=>({current:null}))[0],T=(0,d.useState)(()=>({current:null}))[0],D=ao.theme({"&":{height:c,minHeight:u,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),R=[ao.updateListener.of(e=>{e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(md))&&(E.current?E.current.reset():(E.current=new ma(()=>{if(T.current){var e=T.current;T.current=null,e()}E.current=null},200),("undefined"==typeof window?new mh:(!mc&&(mc=new mh),mc)).add(E.current)),i(e.state.doc.toString(),e)),r&&r({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)})}),D,...ml({theme:h,editable:x,readOnly:b,placeholder:v,indentWithTab:y,basicSetup:w})];return o&&"function"==typeof o&&R.push(ao.updateListener.of(o)),R=R.concat(l),(0,d.useLayoutEffect)(()=>{if(C&&!O){var e={doc:t,selection:n,extensions:R},i=S?rL.fromJSON(S.json,e,S.fields):rL.create(e);if(j(i),!N){var r=new ao({state:i,parent:C,root:k});M(r),s&&s(r,i)}}return()=>{N&&(j(void 0),M(void 0))}},[C,O]),(0,d.useEffect)(()=>{e.container&&A(e.container)},[e.container]),(0,d.useEffect)(()=>()=>{N&&(N.destroy(),M(void 0)),E.current&&(E.current.cancel(),E.current=null)},[N]),(0,d.useEffect)(()=>{a&&N&&N.focus()},[a,N]),(0,d.useEffect)(()=>{N&&N.dispatch({effects:rM.reconfigure.of(R)})},[h,l,c,u,f,p,m,g,v,x,b,y,w,i,o]),(0,d.useEffect)(()=>{if(void 0!==t){var e=N?N.state.doc.toString():"";if(N&&t!==e){var n=E.current&&!E.current.isDone,i=()=>{N&&t!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:t||""},annotations:[md.of(!0)]})};n?T.current=i:i()}}},[t,N]),{state:O,setState:j,view:N,setView:M,container:C,setContainer:A}}({root:A,value:i,autoFocus:u,theme:f,height:p,minHeight:m,maxHeight:g,width:v,minWidth:x,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:S,readOnly:C,selection:r,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:s,initialState:N});(0,d.useImperativeHandle)(t,()=>({editor:O.current,state:j,view:E}),[O,T,j,E]);var R=(0,d.useCallback)(e=>{O.current=e,D(e)},[D]);if("string"!=typeof i)throw Error("value must be typeof string but got "+typeof i);var P="string"==typeof f?"cm-theme-"+f:"cm-theme";return(0,c.jsx)("div",ij({ref:R,className:""+P+(n?" "+n:"")},M))});mp.displayName="CodeMirror";var mm=e.i(47167);class mg{toString(){return"[".concat(this.stack.filter((e,t)=>t%3==0).concat(this.state),"]@").concat(this.pos).concat(this.score?"!"+this.score:"")}static start(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=e.parser.context;return new mg(e,[],t,n,n,0,[],0,i?new mv(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){var t;let n=e>>19,i=65535&e,{parser:r}=this.p,s=this.reducePos<this.pos-25;s&&this.setLookAhead(this.pos);let o=r.dynamicPrecedence(i);if(o&&(this.score+=o),0==n){this.pushState(r.getGoto(this.state,i,!0),this.reducePos),i<r.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(n-1)*3-(262144&e?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,h=this.reducePos-a;h>=2e3&&!(null==(t=this.p.parser.nodeSet.types[i])?void 0:t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=h));let c=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-c;if(i<r.minRepeatTerm||131072&e){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,e,d+4,!0)}if(262144&e)this.state=this.stack[l];else{let e=this.stack[l-3];this.state=r.getGoto(e,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4,r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,i=this.buffer.length;if(0==i&&e.parent&&(i=e.bufferBase-e.parent.bufferBase,e=e.parent),i>0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t){e.buffer[i-2]=n;return}}}if(r&&this.pos!=n){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4]){let e=!1;for(let t=r;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;r>0&&this.buffer[r-2]>n;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=n,this.buffer[r+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n,i){if(131072&e)this.pushState(65535&e,this.pos);else if((262144&e)==0){let{parser:r}=this.p;(i>this.pos||t<=r.maxNode)&&(this.pos=i,r.stateFlag(e,1)||(this.reducePos=i)),this.pushState(e,n),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,i,4)}else this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4)}apply(e,t,n,i){65536&e?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new mg(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}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 mx(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if((65536&n)==0)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 i=0,r;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let i=t[e+1];n.some((e,t)=>1&t&&e==i)||n.push(t[e],i)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let i=t[e+1];if(i==this.state)continue;let r=this.split();r.pushState(i,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(t[e],this.pos),r.reducePos=this.pos,r.score-=200,n.push(r)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((65536&t)==0)return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=65535&t,r=this.stack.length-3*n;if(r<0||0>e.getGoto(this.stack[r],i,!1)){let e=this.findForcedReduction();if(null==e)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=(i,r)=>{if(!t.includes(i))return t.push(i),e.allActions(i,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-r;if(n>1){let i=65535&t,r=this.stack.length-3*n;if(r>=0&&e.getGoto(this.stack[r],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,r+1);if(null!=e)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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!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;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new mv(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}constructor(e,t,n,i,r,s,o,l,a,h=0,c){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=r,this.score=s,this.buffer=o,this.bufferBase=l,this.curContext=a,this.lookAhead=h,this.parent=c}}class mv{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class mx{reduce(e){let t=e>>19;0==t?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],65535&e,!0);this.state=n}constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}}class mb{static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.bufferBase+e.buffer.length;return new mb(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new mb(this.stack,this.pos,this.index)}constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}}function my(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Uint16Array;if("string"!=typeof e)return e;let n=null;for(let i=0,r=0;i<e.length;){let s=0;for(;;){let t=e.charCodeAt(i++),n=!1;if(126==t){s=65535;break}t>=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,n=!0),s+=r,n)break;s*=46}n?n[r++]=s:n=new t(s)}return n}class mw{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}let mk=new mw;class mS{resolveOffset(e,t){let n=this.range,i=this.rangeIndex,r=this.pos+e;for(;r<n.from;){if(!i)return null;let e=this.ranges[--i];r-=n.from-e.to,n=e}for(;t<0?r>n.to:r>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];r+=e.from-n.to,n=e}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,i;if(t>=0&&t<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(null==t)return -1;if((n=t)>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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=mk,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(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 i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mk,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}}class mC{token(e,t){let{parser:n}=t.p;mA(this.data,e,t,this.id,n.data,n.tokenPrecTable)}constructor(e,t){this.data=e,this.id=t}}function mA(e,t,n,i,r,s){let o=0,l=1<<i,{dialect:a}=n.p.parser;n:for(;(l&e[o])!=0;){let n=e[o+1];for(let i=o+3;i<n;i+=2)if((e[i+1]&l)>0){let n=e[i];if(a.allows(n)&&(-1==t.token.value||t.token.value==n||function(e,t,n,i){let r=mN(n,i,t);return r<0||mN(n,i,e)<r}(n,t.token.value,r,s))){t.acceptToken(n);break}}let i=t.next,h=0,c=e[o+2];if(t.next<0&&c>h&&65535==e[n+3*c-3]){o=e[n+3*c-1];continue}for(;h<c;){let r=h+c>>1,s=n+r+(r<<1),l=e[s],a=e[s+1]||65536;if(i<l)c=r;else if(i>=a)h=r+1;else{o=e[s+2],t.advance();continue n}}break}}function mN(e,t,n){for(let i=t,r;65535!=(r=e[i]);i++)if(r==n)return i-t;return -1}mC.prototype.contextual=mC.prototype.fallback=mC.prototype.extend=!1,(class{token(e,t){let n=e.pos,i=0;for(;;){let n=e.next<0,r=e.resolveOffset(1,1);if(mA(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(!n&&i++,null==r)break;e.reset(r,e.token)}i&&(e.reset(n,e.token),e.acceptToken(this.elseToken,i))}constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data="string"==typeof e?my(e):e}}).prototype.contextual=mC.prototype.fallback=mC.prototype.extend=!1;let mM=void 0!==mm.default&&mm.default.env&&/\bparse\b/.test(mm.default.env.LOG),mO=null;function mj(e,t,n){let i=e.cursor(l.IncludeAnonymous);for(i.moveTo(t);;)if(!(n<0?i.childBefore(t):i.childAfter(t)))for(;;){if((n<0?i.to<t:i.from>t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}class mE{nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?mj(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?mj(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(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[i],s=this.start[t]+n.positions[i];if(s>e)return this.nextStart=s,null;if(r instanceof h_){if(s==e){if(s<this.safeFrom)return null;let e=s+r.length;if(e<=this.safeTo){let t=r.prop(hR.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,s+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+r.length}}constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}}class mT{getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:r}=i,s=i.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,l=0;for(let i=0;i<r.length;i++){if((1<<i&s)==0)continue;let a=r[i],h=this.tokens[i];if((!n||a.fallback)&&((a.contextual||h.start!=e.pos||h.mask!=s||h.context!=o)&&(this.updateCachedToken(h,a,e),h.mask=s,h.context=o),h.lookAhead>h.end+25&&(l=Math.max(h.lookAhead,l)),0!=h.value)){let i=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!a.extend&&(n=h,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),n||e.pos!=this.stream.end||((n=new mw).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 mw,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i<t.specialized.length;i++)if(t.specialized[i]==e.value){let r=t.specializers[i](this.stream.read(e.start,e.end),n);if(r>=0&&n.p.parser.dialect.allows(r>>1)){(1&r)==0?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t<i;t+=3)if(this.actions[t]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:r}=e,{parser:s}=e.p,{data:o}=s;for(let e=0;e<2;e++)for(let l=s.stateSlot(r,e?2:1);;l+=3){if(65535==o[l])if(1==o[l+1])l=mI(o,l+2);else{0==i&&2==o[l+1]&&(i=this.putAction(mI(o,l+2),t,n,i));break}o[l]==t&&(i=this.putAction(mI(o,l+1),t,n,i))}return i}constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new mw)}}class mD{get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<n.length;s++){let o=n[s];for(;;){if(this.tokens.mainToken=null,o.pos>i)r.push(o);else{if(this.advanceStack(o,r,n))continue;e||(e=[],t=[]),e.push(o);let i=this.tokens.getMainToken(o);t.push(i.value,i.end)}break}}if(!r.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return mM&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw mM&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,r);if(n)return mM&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort((e,t)=>t.score-e.score);r.length>e;)r.pop();r.some(e=>e.reducePos>i)&&this.recovering--}else if(r.length>1){r:for(let e=0;e<r.length-1;e++){let t=r[e];for(let n=e+1;n<r.length;n++){let i=r[n];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)r.splice(n--,1);else{r.splice(e--,1);continue r}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e<r.length;e++)r[e].pos<this.minStackPos&&(this.minStackPos=r[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:r}=this,s=mM?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(i);o;){let i=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(i>-1&&o.length&&(!t||(o.prop(hR.contextHash)||0)==n))return e.useNode(o,i),mM&&console.log(s+this.stackID(e)+" (via reuse of ".concat(r.getName(o.type.id),")")),!0;if(!(o instanceof h_)||0==o.children.length||o.positions[0]>0)break;let l=o.children[0];if(l instanceof h_&&0==o.positions[0])o=l;else break}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),mM&&console.log(s+this.stackID(e)+" (via always-reduce ".concat(r.getName(65535&o),")")),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let o=0;o<l.length;){let a=l[o++],h=l[o++],c=l[o++],d=o==l.length||!n,u=d?e:e.split(),f=this.tokens.mainToken;if(u.apply(a,h,f?f.start:u.pos,c),mM&&console.log(s+this.stackID(u)+" (via ".concat((65536&a)==0?"shift":"reduce of ".concat(r.getName(65535&a))," for ").concat(r.getName(h)," @ ").concat(i).concat(u==e?"":", split",")")),d)return!0;u.pos>i?t.push(u):n.push(u)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return mR(e,t),!0}}runRecovery(e,t,n){let i=null,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=t[s<<1],a=t[(s<<1)+1],h=mM?this.stackID(o)+" -> ":"";if(o.deadEnd&&(r||(r=!0,o.restart(),mM&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let c=o.split(),d=h;for(let e=0;c.forceReduce()&&e<10&&(mM&&console.log(d+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,n));e++)mM&&(d=this.stackID(c)+" -> ");for(let e of o.recoverByInsert(l))mM&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>o.pos?(a==o.pos&&(a++,l=0),o.recoverByDelete(l,a),mM&&console.log(h+this.stackID(o)+" (via recover-delete ".concat(this.parser.getName(l),")")),mR(o,n)):(!i||i.score<o.score)&&(i=o)}return i}stackToTree(e){return e.close(),h_.build({buffer:mb.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(mO||(mO=new WeakMap)).get(e);return t||mO.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new mS(t,i),this.tokens=new mT(e,this.stream),this.topTerm=e.top[1];let{from:r}=i[0];this.stacks=[mg.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>4*e.bufferLength?new mE(n,e.nodeSet):null}}function mR(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(i.pos==e.pos&&i.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}class mP{allows(e){return!this.disabled||0==this.disabled[e]}constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}}class mL extends h5{createParse(e,t,n){let i=new mD(this,e,t,n);for(let r of this.wrappers)i=r(i,e,t,n);return i}getGoto(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.goto;if(t>=i[0])return -1;for(let r=i[t+1];;){let t=i[r++],s=1&t,o=i[r++];if(s&&n)return o;for(let n=r+(t>>1);r<n;r++)if(i[r]==e)return o;if(s)return -1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let r=this.stateSlot(e,i?2:1),s;;r+=3){if(65535==(s=n[r]))if(1==n[r+1])s=n[r=mI(n,r+2)];else if(2==n[r+1])return mI(n,r+2);else break;if(s==t||0==s)return mI(n,r+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=mI(this.data,n+2);else break;i=t(mI(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=mI(this.data,n+2);else break;if((1&this.data[n+2])==0){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(mL.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw RangeError("Invalid top rule name ".concat(e.top));t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let r=e.specializers.find(e=>e.from==n.external);if(!r)return n;let s=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[i]=mB(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}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 null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],r;65535!=(r=this.data[n++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[r]=1;return new mP(e,n,i)}static deserialize(e){return new mL(e)}constructor(e){if(super(),this.wrappers=[],14!=e.version)throw RangeError("Parser version (".concat(e.version,") doesn't match runtime version (",14,")"));let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),i=[];for(let e=0;e<t.length;e++)i.push([]);function r(e,t,n){i[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=hR[e]);for(let n=1;n<t.length;){let i=t[n++];if(i>=0)r(i,e,t[n++]);else{let s=t[n+-i];for(let o=-i;o>0;o--)r(t[n++],e,s);n++}}}this.nodeSet=new hB(t.map((t,r)=>hI.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:i[r],top:n.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=my(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(mB),this.states=my(e.states,Uint32Array),this.data=my(e.stateData),this.goto=my(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new mC(s,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]]}}function mI(e,t){return e[t]|e[t+1]<<16}function mB(e){if(e.external){let t=+!!e.extend;return(n,i)=>e.external(n,i)<<1|t}return e.get}let mz=ct({String:cw.string,Number:cw.number,"True False":cw.bool,PropertyName:cw.propertyName,Null:cw.null,", :":cw.separator,"[ ]":cw.squareBracket,"{ }":cw.brace}),mF=mL.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:[mz],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}),m_=cN.define({name:"json",parser:mF.configure({props:[cq.add({Object:cG({except:/^\s*\}/}),Array:cG({except:/^\s*\]/})}),cQ.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mW(e){let{value:t,onChange:n,language:i="json",className:r="",id:s,readOnly:o=!1}=e,l=(0,d.useMemo)(()=>{if("json"!==i||!t.trim())return t;try{let e=JSON.parse(t);return JSON.stringify(e,null,2)}catch(e){return t}},[t,i]),a=(0,d.useMemo)(()=>{let e=[];return"json"===i&&e.push(new cB(m_)),e.push(ao.lineWrapping),e.push(ao.theme({"&":{height:"auto !important"},".cm-scroller":{overflow:"visible !important"},".cm-editor":{height:"auto !important"},".cm-content":{padding:"8px",minHeight:"fit-content"}})),e},[i]);return(0,c.jsx)("div",{id:s,className:"border rounded-lg overflow-hidden ".concat(r),children:(0,c.jsx)(mp,{value:l,extensions:a,onChange:o?void 0:e=>n(e),theme:"dark",basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!o,bracketMatching:!0,closeBrackets:!o,autocompletion:!o,highlightSelectionMatches:!1,searchKeymap:!o},editable:!o})})}var mV="horizontal",mH=["horizontal","vertical"],mq=d.forwardRef((e,t)=>{var n;let{decorative:i,orientation:r=mV,...s}=e,o=(n=r,mH.includes(n))?r:mV;return(0,c.jsx)(y.div,{"data-orientation":o,...i?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...s,ref:t})});mq.displayName="Separator";let mK=d.forwardRef((e,t)=>{let{className:n,orientation:i="horizontal",decorative:r=!0,...s}=e;return(0,c.jsx)(mq,{ref:t,decorative:r,orientation:i,className:e6("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n),...s})});function mU(e,t,n){if(!t.has(e))throw TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function mJ(e,t){var n=mU(e,t,"get");return n.get?n.get.call(e):n.value}function mG(e,t,n){var i=mU(e,t,"set");if(i.set)i.set.call(e,n);else{if(!i.writable)throw TypeError("attempted to set read only private field");i.value=n}return n}function mY(e){let t=e+"CollectionProvider",[n,i]=C(t),[r,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,i=d.default.useRef(null),s=d.default.useRef(new Map).current;return(0,c.jsx)(r,{scope:t,itemMap:s,collectionRef:i,children:n})};o.displayName=t;let l=e+"CollectionSlot",a=g(l),h=d.default.forwardRef((e,t)=>{let{scope:n,children:i}=e,r=m(t,s(l,n).collectionRef);return(0,c.jsx)(a,{ref:r,children:i})});h.displayName=l;let u=e+"CollectionItemSlot",f="data-radix-collection-item",p=g(u),v=d.default.forwardRef((e,t)=>{let{scope:n,children:i,...r}=e,o=d.default.useRef(null),l=m(t,o),a=s(u,n);return d.default.useEffect(()=>(a.itemMap.set(o,{ref:o,...r}),()=>void a.itemMap.delete(o))),(0,c.jsx)(p,{...{[f]:""},ref:l,children:i})});return v.displayName=u,[{Provider:o,Slot:h,ItemSlot:v},function(t){let n=s(e+"CollectionConsumer",t);return d.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll("[".concat(f,"]")));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},i]}mK.displayName=mq.displayName;var mQ=new WeakMap;function mX(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);let n=function(e,t){let n=e.length,i=m$(t),r=i>=0?i:n+i;return r<0||r>=n?-1:r}(e,t);return -1===n?void 0:e[n]}function m$(e){return e!=e||0===e?0:Math.trunc(e)}h=new WeakMap,class e extends Map{set(e,t){return mQ.get(this)&&(this.has(e)?mJ(this,h)[mJ(this,h).indexOf(e)]=e:mJ(this,h).push(e)),super.set(e,t),this}insert(e,t,n){let i,r=this.has(t),s=mJ(this,h).length,o=m$(e),l=o>=0?o:s+o,a=l<0||l>=s?-1:l;if(a===this.size||r&&a===this.size-1||-1===a)return this.set(t,n),this;let c=this.size+ +!r;o<0&&l++;let d=[...mJ(this,h)],u=!1;for(let e=l;e<c;e++)if(l===e){let s=d[e];d[e]===t&&(s=d[e+1]),r&&this.delete(t),i=this.get(s),this.set(t,n)}else{u||d[e-1]!==t||(u=!0);let n=d[u?e:e-1],r=i;i=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,i){let r=new e(this);return r.insert(t,n,i),r}before(e){let t=mJ(this,h).indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let i=mJ(this,h).indexOf(e);return -1===i?this:this.insert(i,t,n)}after(e){let t=mJ(this,h).indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let i=mJ(this,h).indexOf(e);return -1===i?this:this.insert(i+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return mG(this,h,[]),super.clear()}delete(e){let t=super.delete(e);return t&&mJ(this,h).splice(mJ(this,h).indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=mX(mJ(this,h),e);if(void 0!==t)return this.get(t)}entryAt(e){let t=mX(mJ(this,h),e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return mJ(this,h).indexOf(e)}keyAt(e){return mX(mJ(this,h),e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let i=n+t;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let i=n+t;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return i;n++}}findIndex(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return n;n++}return -1}filter(t,n){let i=[],r=0;for(let e of this)Reflect.apply(t,n,[e,r,this])&&i.push(e),r++;return new e(i)}map(t,n){let i=[],r=0;for(let e of this)i.push([e[0],Reflect.apply(t,n,[e,r,this])]),r++;return new e(i)}reduce(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let[i,r]=t,s=0,o=null!=r?r:this.at(0);for(let e of this)o=0===s&&1===t.length?e:Reflect.apply(i,this,[o,e,s,this]),s++;return o}reduceRight(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let[i,r]=t,s=null!=r?r:this.at(-1);for(let e=this.size-1;e>=0;e--){let n=this.at(e);s=e===this.size-1&&1===t.length?n:Reflect.apply(i,this,[s,n,e,this])}return s}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),i=this.get(n);t.set(n,i)}return t}toSpliced(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];let r=[...this.entries()];return r.splice(...n),new e(r)}slice(t,n){let i=new e,r=this.size-1;if(void 0===t)return i;t<0&&(t+=this.size),void 0!==n&&n>0&&(r=n-1);for(let e=t;e<=r;e++){let t=this.keyAt(e),n=this.get(t);i.set(t,n)}return i}every(e,t){let n=0;for(let i of this){if(!Reflect.apply(e,t,[i,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return!0;n++}return!1}constructor(e){super(e),function(e,t,n){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,n)}(this,h,{writable:!0,value:void 0}),mG(this,h,[...super.keys()]),mQ.set(this,!0)}};var mZ="Collapsible",[m0,m1]=C(mZ),[m2,m3]=m0(mZ),m4=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:i,defaultOpen:r,disabled:s,onOpenChange:o,...l}=e,[a,h]=tE({prop:i,defaultProp:null!=r&&r,onChange:o,caller:mZ});return(0,c.jsx)(m2,{scope:n,disabled:s,contentId:tO(),open:a,onOpenToggle:d.useCallback(()=>h(e=>!e),[h]),children:(0,c.jsx)(y.div,{"data-state":ge(a),"data-disabled":s?"":void 0,...l,ref:t})})});m4.displayName=mZ;var m5="CollapsibleTrigger",m8=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,...i}=e,r=m3(m5,n);return(0,c.jsx)(y.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":ge(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...i,ref:t,onClick:O(e.onClick,r.onOpenToggle)})});m8.displayName=m5;var m6="CollapsibleContent",m9=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=m3(m6,e.__scopeCollapsible);return(0,c.jsx)(k,{present:n||r.open,children:e=>{let{present:n}=e;return(0,c.jsx)(m7,{...i,ref:t,present:n})}})});m9.displayName=m6;var m7=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:i,children:r,...s}=e,o=m3(m6,n),[l,a]=d.useState(i),h=d.useRef(null),u=m(t,h),f=d.useRef(0),p=f.current,g=d.useRef(0),v=g.current,x=o.open||l,b=d.useRef(x),k=d.useRef(void 0);return d.useEffect(()=>{let e=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(e)},[]),w(()=>{let e=h.current;if(e){k.current=k.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();f.current=t.height,g.current=t.width,b.current||(e.style.transitionDuration=k.current.transitionDuration,e.style.animationName=k.current.animationName),a(i)}},[o.open,i]),(0,c.jsx)(y.div,{"data-state":ge(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!x,...s,ref:u,style:{"--radix-collapsible-content-height":p?"".concat(p,"px"):void 0,"--radix-collapsible-content-width":v?"".concat(v,"px"):void 0,...e.style},children:x&&r})});function ge(e){return e?"open":"closed"}var gt="Accordion",gn=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[gi,gr,gs]=mY(gt),[go,gl]=C(gt,[gs,m1]),ga=m1(),gh=d.default.forwardRef((e,t)=>{let{type:n,...i}=e;return(0,c.jsx)(gi.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,c.jsx)(gm,{...i,ref:t}):(0,c.jsx)(gp,{...i,ref:t})})});gh.displayName=gt;var[gc,gd]=go(gt),[gu,gf]=go(gt,{collapsible:!1}),gp=d.default.forwardRef((e,t)=>{let{value:n,defaultValue:i,onValueChange:r=()=>{},collapsible:s=!1,...o}=e,[l,a]=tE({prop:n,defaultProp:null!=i?i:"",onChange:r,caller:gt});return(0,c.jsx)(gc,{scope:e.__scopeAccordion,value:d.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:d.default.useCallback(()=>s&&a(""),[s,a]),children:(0,c.jsx)(gu,{scope:e.__scopeAccordion,collapsible:s,children:(0,c.jsx)(gx,{...o,ref:t})})})}),gm=d.default.forwardRef((e,t)=>{let{value:n,defaultValue:i,onValueChange:r=()=>{},...s}=e,[o,l]=tE({prop:n,defaultProp:null!=i?i:[],onChange:r,caller:gt}),a=d.default.useCallback(e=>l(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[...t,e]}),[l]),h=d.default.useCallback(e=>l(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.filter(t=>t!==e)}),[l]);return(0,c.jsx)(gc,{scope:e.__scopeAccordion,value:o,onItemOpen:a,onItemClose:h,children:(0,c.jsx)(gu,{scope:e.__scopeAccordion,collapsible:!0,children:(0,c.jsx)(gx,{...s,ref:t})})})}),[gg,gv]=go(gt),gx=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:i,dir:r,orientation:s="vertical",...o}=e,l=m(d.default.useRef(null),t),a=gr(n),h="ltr"===M(r),u=O(e.onKeyDown,e=>{var t;if(!gn.includes(e.key))return;let n=e.target,i=a().filter(e=>{var t;return!(null==(t=e.ref.current)?void 0:t.disabled)}),r=i.findIndex(e=>e.ref.current===n),o=i.length;if(-1===r)return;e.preventDefault();let l=r,c=o-1,d=()=>{(l=r+1)>c&&(l=0)},u=()=>{(l=r-1)<0&&(l=c)};switch(e.key){case"Home":l=0;break;case"End":l=c;break;case"ArrowRight":"horizontal"===s&&(h?d():u());break;case"ArrowDown":"vertical"===s&&d();break;case"ArrowLeft":"horizontal"===s&&(h?u():d());break;case"ArrowUp":"vertical"===s&&u()}null==(t=i[l%o].ref.current)||t.focus()});return(0,c.jsx)(gg,{scope:n,disabled:i,direction:r,orientation:s,children:(0,c.jsx)(gi.Slot,{scope:n,children:(0,c.jsx)(y.div,{...o,"data-orientation":s,ref:l,onKeyDown:i?void 0:u})})})}),gb="AccordionItem",[gy,gw]=go(gb),gk=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:i,...r}=e,s=gv(gb,n),o=gd(gb,n),l=ga(n),a=tO(),h=i&&o.value.includes(i)||!1,d=s.disabled||e.disabled;return(0,c.jsx)(gy,{scope:n,open:h,disabled:d,triggerId:a,children:(0,c.jsx)(m4,{"data-orientation":s.orientation,"data-state":gj(h),...l,...r,ref:t,disabled:d,open:h,onOpenChange:e=>{e?o.onItemOpen(i):o.onItemClose(i)}})})});gk.displayName=gb;var gS="AccordionHeader",gC=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gS,n);return(0,c.jsx)(y.h3,{"data-orientation":r.orientation,"data-state":gj(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});gC.displayName=gS;var gA="AccordionTrigger",gN=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gA,n),o=gf(gA,n),l=ga(n);return(0,c.jsx)(gi.ItemSlot,{scope:n,children:(0,c.jsx)(m8,{"aria-disabled":s.open&&!o.collapsible||void 0,"data-orientation":r.orientation,id:s.triggerId,...l,...i,ref:t})})});gN.displayName=gA;var gM="AccordionContent",gO=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gM,n),o=ga(n);return(0,c.jsx)(m9,{role:"region","aria-labelledby":s.triggerId,"data-orientation":r.orientation,...o,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function gj(e){return e?"open":"closed"}gO.displayName=gM;let gE=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(gk,{ref:t,className:e6("border-b",n),...i})});gE.displayName="AccordionItem";let gT=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsx)(gC,{className:"flex",children:(0,c.jsxs)(gN,{ref:t,className:e6("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",n),...r,children:[i,(0,c.jsx)(ix,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})})});gT.displayName=gN.displayName;let gD=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsx)(gO,{ref:t,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:(0,c.jsx)("div",{className:e6("pb-4 pt-0",n),children:i})})});gD.displayName=gO.displayName;let gR=td("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]),gP=td("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),gL=td("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),gI=td("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);function gB(e){return null===e?"null":Array.isArray(e)?"array":"object"==typeof e?"object":typeof e}function gz(e){let{data:t,onChange:n,className:i=""}=e,[r,s]=(0,d.useState)({});(0,d.useEffect)(()=>{if(t){let e=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=[];return null===t?[{key:n.join(".")||"root",value:null,type:"null",path:n}]:(Array.isArray(t)?t.forEach((t,r)=>{let s=[...n,r.toString()];i.push(...e(t,s))}):"object"==typeof t?Object.entries(t).forEach(t=>{let[r,s]=t,o=[...n,r];"object"!=typeof s||null===s||Array.isArray(s)?i.push({key:o.join("."),value:s,type:gB(s),path:o}):i.push(...e(s,o))}):i.push({key:n.join(".")||"root",value:t,type:gB(t),path:n}),i)}(t),n={};e.forEach(e=>{let t=e.path.slice(0,-1).join(".")||"root";n[t]||(n[t]=[]),n[t].push(e)}),s(n)}},[t]);let o=(e,i)=>{n(function e(t,n,i){if(0===n.length)return i;if(Array.isArray(t)){let r=[...t],[s,...o]=n,l=parseInt(s);return 0===o.length?r[l]=i:r[l]=e(r[l]||{},o,i),r}if("object"==typeof t&&null!==t){let r={...t},[s,...o]=n;return 0===o.length?r[s]=i:r[s]=e(r[s]||{},o,i),r}return i}(t,e.path,i))},l=(e,t)=>{let n;switch(t){case"string":n=String(e.value||"");break;case"number":n=Number(e.value)||0;break;case"boolean":n=!!e.value;break;case"null":n=null;break;case"array":n=Array.isArray(e.value)?e.value:[];break;case"object":n="object"!=typeof e.value||Array.isArray(e.value)?{}:e.value;break;default:n=e.value}o(e,n)};if(!t)return(0,c.jsx)(tw,{className:"h-full ".concat(i),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(tp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"No data to edit"})]})})});let a=Object.keys(r).sort();return(0,c.jsxs)(tw,{className:"h-full ".concat(i),children:[(0,c.jsxs)(tk,{children:[(0,c.jsxs)(tS,{className:"flex items-center gap-2",children:[(0,c.jsx)(tp,{className:"h-5 w-5"}),"JSON Form Editor"]}),(0,c.jsx)(tC,{children:"Edit JSON values using form controls"})]}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-6",children:a.map(e=>(0,c.jsx)(gh,{type:"single",collapsible:!0,children:(0,c.jsxs)(gE,{value:e,className:"border-2 rounded-lg bg-card/50 shadow-sm",children:[(0,c.jsx)(gT,{className:"text-sm font-medium px-4 py-3 bg-muted/30 rounded-t-lg",children:(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(to,{variant:"outline",className:"font-mono text-xs",children:"root"===e?"Root Level":e}),(0,c.jsxs)("span",{className:"text-muted-foreground",children:["(",r[e].length," fields)"]})]})}),(0,c.jsx)(gD,{children:(0,c.jsx)("div",{className:"space-y-4 pt-2 px-4 pb-4 bg-background/50 rounded-b-lg",children:r[e].map(e=>(0,c.jsxs)("div",{className:"space-y-3 border border-muted-foreground/20 rounded-lg p-3 bg-muted/10",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)(iO,{htmlFor:"field-".concat(e.key),className:"flex items-center gap-2 font-medium",children:[(0,c.jsx)("span",{className:"font-mono text-sm bg-muted px-2 py-1 rounded",children:e.path[e.path.length-1]}),(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat((e=>{switch(e){case"string":return"bg-green-50 text-green-700 dark:bg-green-800 dark:text-green-100";case"number":return"bg-blue-50 text-blue-700 dark:bg-blue-800 dark:text-blue-100";case"boolean":return"bg-purple-50 text-purple-700 dark:bg-purple-800 dark:text-purple-100";case"array":return"bg-orange-50 text-orange-700 dark:bg-orange-800 dark:text-orange-100";case"object":return"bg-red-50 text-red-700 dark:bg-red-800 dark:text-red-100";default:return"bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-100"}})(e.type)),children:[(e=>{switch(e){case"string":return(0,c.jsx)(gR,{className:"h-4 w-4"});case"number":return(0,c.jsx)(gP,{className:"h-4 w-4"});case"boolean":return(0,c.jsx)(gL,{className:"h-4 w-4"});case"array":return(0,c.jsx)(gI,{className:"h-4 w-4"});default:return(0,c.jsx)(tp,{className:"h-4 w-4"})}})(e.type),e.type]})]}),"root"!==e.key&&e.path.length>0&&(0,c.jsx)(iC,{value:e.type,onChange:t=>{let n=t.target.value;["string","number","boolean","array","object","null"].includes(n)&&l(e,n)},className:"w-32 h-8 font-mono text-xs",placeholder:"string, number, boolean..."})]}),(e=>{let t="field-".concat(e.key);switch(e.type){case"string":return(0,c.jsx)("div",{className:"space-y-2",children:String(e.value).length>100?(0,c.jsx)(mW,{id:t,value:String(e.value),onChange:t=>o(e,t),language:"text"}):(0,c.jsx)(iC,{id:t,type:"text",value:String(e.value),onChange:t=>o(e,t.target.value),className:"font-mono",placeholder:"Enter text..."})});case"number":return(0,c.jsx)(iC,{id:t,type:"number",value:Number(e.value),onChange:t=>o(e,parseFloat(t.target.value)||0),className:"font-mono",placeholder:"0"});case"boolean":return(0,c.jsx)(iC,{id:t,value:String(e.value),onChange:t=>{let n=t.target.value.toLowerCase();"true"===n||"false"===n?o(e,"true"===n):o(e,t.target.value)},className:"font-mono",placeholder:"true or false"});case"null":return(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(to,{variant:"secondary",className:"font-mono",children:"null"}),(0,c.jsx)(tr,{size:"sm",variant:"outline",onClick:()=>l(e,"string"),children:"Convert to String"})]});case"array":return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{variant:"outline",className:"font-mono",children:["Array (",Array.isArray(e.value)?e.value.length:0," items)"]})}),(0,c.jsx)(mW,{id:t,value:JSON.stringify(e.value,null,2),onChange:t=>{try{let n=JSON.parse(t);Array.isArray(n)&&o(e,n)}catch(e){}},language:"json"})]});case"object":return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{variant:"outline",className:"font-mono",children:["Object (","object"==typeof e.value&&e.value?Object.keys(e.value).length:0," keys)"]})}),(0,c.jsx)(mW,{id:t,value:JSON.stringify(e.value,null,2),onChange:t=>{try{let n=JSON.parse(t);"object"!=typeof n||Array.isArray(n)||o(e,n)}catch(e){}},language:"json"})]});default:return(0,c.jsxs)("div",{className:"text-muted-foreground italic",children:["Unsupported type: ",e.type]})}})(e),(0,c.jsx)(mK,{className:"my-4"})]},e.key))})})]})},e))})})})]})}var gF="rovingFocusGroup.onEntryFocus",g_={bubbles:!1,cancelable:!0},gW="RovingFocusGroup",[gV,gH,gq]=mY(gW),[gK,gU]=C(gW,[gq]),[gJ,gG]=gK(gW),gY=d.forwardRef((e,t)=>(0,c.jsx)(gV.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(gV.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(gQ,{...e,ref:t})})}));gY.displayName=gW;var gQ=d.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:a,onEntryFocus:h,preventScrollOnEntryFocus:u=!1,...f}=e,p=d.useRef(null),g=m(t,p),v=M(s),[x,b]=tE({prop:o,defaultProp:null!=l?l:null,onChange:a,caller:gW}),[w,k]=d.useState(!1),S=A(h),C=gH(n),N=d.useRef(!1),[j,E]=d.useState(0);return d.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(gF,S),()=>e.removeEventListener(gF,S)},[S]),(0,c.jsx)(gJ,{scope:n,orientation:i,dir:v,loop:r,currentTabStopId:x,onItemFocus:d.useCallback(e=>b(e),[b]),onItemShiftTab:d.useCallback(()=>k(!0),[]),onFocusableItemAdd:d.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:d.useCallback(()=>E(e=>e-1),[]),children:(0,c.jsx)(y.div,{tabIndex:w||0===j?-1:0,"data-orientation":i,...f,ref:g,style:{outline:"none",...e.style},onMouseDown:O(e.onMouseDown,()=>{N.current=!0}),onFocus:O(e.onFocus,e=>{let t=!N.current;if(e.target===e.currentTarget&&t&&!w){let t=new CustomEvent(gF,g_);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=C().filter(e=>e.focusable);g0([e.find(e=>e.active),e.find(e=>e.id===x),...e].filter(Boolean).map(e=>e.ref.current),u)}}N.current=!1}),onBlur:O(e.onBlur,()=>k(!1))})})}),gX="RovingFocusGroupItem",g$=d.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...l}=e,a=tO(),h=s||a,u=gG(gX,n),f=u.currentTabStopId===h,p=gH(n),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=u;return d.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),(0,c.jsx)(gV.ItemSlot,{scope:n,id:h,focusable:i,active:r,children:(0,c.jsx)(y.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:O(e.onMouseDown,e=>{i?u.onItemFocus(h):e.preventDefault()}),onFocus:O(e.onFocus,()=>u.onItemFocus(h)),onKeyDown:O(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var i;let r=(i=e.key,"rtl"!==n?i:"ArrowLeft"===i?"ArrowRight":"ArrowRight"===i?"ArrowLeft":i);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(r))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)))return gZ[r]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)n.reverse();else if("prev"===t||"next"===t){"prev"===t&&n.reverse();let i=n.indexOf(e.currentTarget);n=u.loop?function(e,t){return e.map((n,i)=>e[(t+i)%e.length])}(n,i+1):n.slice(i+1)}setTimeout(()=>g0(n))}}),children:"function"==typeof o?o({isCurrentTabStop:f,hasTabStop:null!=v}):o})})});g$.displayName=gX;var gZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function g0(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.activeElement;for(let i of e)if(i===n||(i.focus({preventScroll:t}),document.activeElement!==n))return}var g1="Tabs",[g2,g3]=C(g1,[gU]),g4=gU(),[g5,g8]=g2(g1),g6=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,onValueChange:r,defaultValue:s,orientation:o="horizontal",dir:l,activationMode:a="automatic",...h}=e,d=M(l),[u,f]=tE({prop:i,onChange:r,defaultProp:null!=s?s:"",caller:g1});return(0,c.jsx)(g5,{scope:n,baseId:tO(),value:u,onValueChange:f,orientation:o,dir:d,activationMode:a,children:(0,c.jsx)(y.div,{dir:d,"data-orientation":o,...h,ref:t})})});g6.displayName=g1;var g9="TabsList",g7=d.forwardRef((e,t)=>{let{__scopeTabs:n,loop:i=!0,...r}=e,s=g8(g9,n),o=g4(n);return(0,c.jsx)(gY,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:i,children:(0,c.jsx)(y.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:t})})});g7.displayName=g9;var ve="TabsTrigger",vt=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,disabled:r=!1,...s}=e,o=g8(ve,n),l=g4(n),a=vr(o.baseId,i),h=vs(o.baseId,i),d=i===o.value;return(0,c.jsx)(g$,{asChild:!0,...l,focusable:!r,active:d,children:(0,c.jsx)(y.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":h,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:a,...s,ref:t,onMouseDown:O(e.onMouseDown,e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(i)}),onKeyDown:O(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(i)}),onFocus:O(e.onFocus,()=>{let e="manual"!==o.activationMode;d||r||!e||o.onValueChange(i)})})})});vt.displayName=ve;var vn="TabsContent",vi=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,forceMount:r,children:s,...o}=e,l=g8(vn,n),a=vr(l.baseId,i),h=vs(l.baseId,i),u=i===l.value,f=d.useRef(u);return d.useEffect(()=>{let e=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,c.jsx)(k,{present:r||u,children:n=>{let{present:i}=n;return(0,c.jsx)(y.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":a,hidden:!i,id:h,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:i&&s})}})});function vr(e,t){return"".concat(e,"-trigger-").concat(t)}function vs(e,t){return"".concat(e,"-content-").concat(t)}vi.displayName=vn;let vo=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(g7,{ref:t,className:e6("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",n),...i})});vo.displayName=g7.displayName;let vl=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(vt,{ref:t,className:e6("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",n),...i})});vl.displayName=vt.displayName;let va=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(vi,{ref:t,className:e6("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...i})});va.displayName=vi.displayName;let vh=td("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),vc=td("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function vd(e){return null===e?"null":Array.isArray(e)?"array":"object"==typeof e?"object":typeof e}function vu(e){let{field:t,expanded:n,onToggle:i,searchTerm:r}=e,s="object"===t.type||"array"===t.type,o=r&&(t.key.toLowerCase().includes(r.toLowerCase())||String(t.value).toLowerCase().includes(r.toLowerCase()));return(0,c.jsxs)("div",{className:"flex items-center gap-2 py-1 px-2 rounded ".concat(o?"bg-yellow-100 dark:bg-yellow-900/30":""),style:{marginLeft:"".concat(16*t.level,"px")},children:[s?(0,c.jsx)(tr,{variant:"ghost",size:"sm",onClick:i,className:"h-6 w-6 p-0",children:n?(0,c.jsx)(ix,{className:"h-3 w-3"}):(0,c.jsx)(ib,{className:"h-3 w-3"})}):(0,c.jsx)("div",{className:"w-6"}),(0,c.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat((e=>{switch(e){case"string":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"number":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"boolean":return"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200";case"array":return"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200";case"object":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200"}})(t.type)," flex items-center gap-1"),children:[(e=>{switch(e){case"string":return(0,c.jsx)(gR,{className:"h-3 w-3"});case"number":return(0,c.jsx)(gP,{className:"h-3 w-3"});case"boolean":return(0,c.jsx)(gL,{className:"h-3 w-3"});case"array":return(0,c.jsx)(gI,{className:"h-3 w-3"});default:return(0,c.jsx)(tp,{className:"h-3 w-3"})}})(t.type),t.type]}),(0,c.jsxs)("span",{className:"font-mono text-sm text-muted-foreground",children:[t.path[t.path.length-1]||"root",":"]}),(0,c.jsx)("div",{className:"flex-1 min-w-0",children:((e,t)=>{switch(t){case"string":return(0,c.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-mono",children:['"',String(e),'"']});case"number":return(0,c.jsx)("span",{className:"text-blue-600 dark:text-blue-400 font-mono",children:Number(e)});case"boolean":return(0,c.jsx)("span",{className:"text-purple-600 dark:text-purple-400 font-mono",children:String(e)});case"null":return(0,c.jsx)("span",{className:"text-gray-500 dark:text-gray-400 font-mono italic",children:"null"});case"array":let n=Array.isArray(e)?e.length:0;return(0,c.jsxs)("span",{className:"text-orange-600 dark:text-orange-400 font-mono",children:["Array(",n,")"]});case"object":let i="object"==typeof e&&null!==e?Object.keys(e).length:0;return(0,c.jsxs)("span",{className:"text-red-600 dark:text-red-400 font-mono",children:["Object(",i,")"]});default:return(0,c.jsx)("span",{children:String(e)})}})(t.value,t.type)}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t.value,null,2)),iv.default.success("필드가 클립보드에 복사되었습니다")}catch(n){console.log("Failed to copy field to clipboard:",n);let e=document.createElement("textarea");e.value=JSON.stringify(t.value,null,2),document.body.appendChild(e),e.select();try{document.execCommand("copy"),iv.default.success("필드가 클립보드에 복사되었습니다")}catch(e){console.log("Field fallback copy failed:",e),iv.default.error("클립보드 복사에 실패했습니다")}document.body.removeChild(e)}},className:"h-6 w-6 p-0 opacity-50 hover:opacity-100",children:(0,c.jsx)(iS,{className:"h-3 w-3"})})]})]})}function vf(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(!!Array.isArray(e.output)||!!(e.data&&"object"==typeof e.data&&null!==e.data&&Array.isArray(e.data.output)))}function vp(e){let{data:t}=e,n=Array.isArray(t.output)?t:t.data||t,i=n.output&&Array.isArray(n.output)?n.output:[],[r,s]=(0,d.useState)(new Set(i.map((e,t)=>t)));return(0,c.jsxs)("div",{className:"space-y-4",children:[n.usage&&"object"==typeof n.usage?(0,c.jsxs)("div",{className:"p-4 bg-muted/30 rounded-lg space-y-4",children:[(0,c.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-blue-600",children:Number(n.usage.input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"입력 토큰"})]}),(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-green-600",children:Number(n.usage.output_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"출력 토큰"})]}),(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-gray-600",children:Number(n.usage.total_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"총 토큰"})]})]}),(n.usage.cache_creation_input_tokens||n.usage.cache_read_input_tokens)&&("anthropic"===n.provider||"anthropic"===t.provider)?(0,c.jsxs)("div",{className:"grid grid-cols-2 gap-4 pt-4 border-t",children:[(0,c.jsxs)("div",{className:"text-center p-3 bg-purple-50 dark:bg-purple-950/20 rounded-lg border border-purple-200 dark:border-purple-800",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-purple-600 dark:text-purple-400",children:Number(n.usage.cache_creation_input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-purple-700 dark:text-purple-300",children:"캐시 생성 토큰"}),(0,c.jsx)("div",{className:"text-xs text-purple-600 dark:text-purple-400 mt-1",children:"Cache Write"})]}),(0,c.jsxs)("div",{className:"text-center p-3 bg-orange-50 dark:bg-orange-950/20 rounded-lg border border-orange-200 dark:border-orange-800",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:Number(n.usage.cache_read_input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-orange-700 dark:text-orange-300",children:"캐시 읽기 토큰"}),(0,c.jsx)("div",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:"Cache Hit (90% 절약)"})]})]}):null]}):null,n.output&&Array.isArray(n.output)&&n.output.length>0?(0,c.jsxs)("div",{className:"bg-gradient-to-r from-blue-50 to-purple-50 dark:from-blue-950/20 dark:to-purple-950/20 p-4 rounded-lg border border-blue-200 dark:border-blue-800",children:[(0,c.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-10 h-10 bg-gradient-to-r from-blue-500 to-purple-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white font-bold",children:"🚀"})}),(0,c.jsxs)("div",{children:[(0,c.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:"AI 실행 과정"}),(0,c.jsxs)("p",{className:"text-xs text-muted-foreground",children:["총 ",n.output.length,"단계의 처리 과정을 확인할 수 있습니다"]})]})]}),(0,c.jsx)("div",{className:"space-y-3",children:n.output.map((e,t)=>((e,t)=>{let n=r.has(t),i=String(e.type||"unknown");return(0,c.jsxs)("div",{className:"border rounded-lg overflow-hidden ".concat((e=>{switch(e){case"reasoning":return"bg-purple-50 dark:bg-purple-950/20 border-purple-200 dark:border-purple-800";case"function_call":return"bg-blue-50 dark:bg-blue-950/20 border-blue-200 dark:border-blue-800";case"function_call_output":return"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800";case"message":return"bg-gray-50 dark:bg-gray-950/20 border-gray-200 dark:border-gray-800";default:return"bg-muted/30 border-muted"}})(i)),children:[(0,c.jsxs)("div",{className:"flex items-center justify-between p-4 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>(e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),s(t)})(t),children:[(0,c.jsxs)("div",{className:"flex items-center gap-3",children:[(0,c.jsx)("span",{className:"text-lg",children:(e=>{switch(e){case"reasoning":return"🧠";case"function_call":return"🔧";case"function_call_output":return"✅";case"message":return"💬";default:return"📄"}})(i)}),(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"font-medium text-sm",children:(e=>{switch(e){case"reasoning":return"사고 과정";case"function_call":return"도구 사용";case"function_call_output":return"실행 결과";case"message":return"응답";default:return"기타"}})(i)}),e.name?(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:String(e.name)}):null]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[e.status?(0,c.jsx)(to,{variant:"completed"===e.status?"default":"destructive",className:"text-xs",children:String(e.status)}):null,n?(0,c.jsx)(ix,{className:"h-4 w-4"}):(0,c.jsx)(ib,{className:"h-4 w-4"})]})]}),n&&(0,c.jsxs)("div",{className:"px-4 pb-4",children:["reasoning"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,c.jsx)("div",{className:"w-2 h-2 bg-purple-500 rounded-full"}),(0,c.jsx)("span",{className:"text-sm font-medium text-purple-900 dark:text-purple-100",children:"AI 추론 과정"})]}),(0,c.jsx)("div",{className:"text-sm text-purple-800 dark:text-purple-200 leading-relaxed",children:(()=>{if(e.summary)if(Array.isArray(e.summary))return e.summary.map(e=>"object"==typeof e&&null!==e?e.text||JSON.stringify(e):String(e)).join(" ");else if("object"==typeof e.summary)return JSON.stringify(e.summary,null,2);else return String(e.summary);if(e.content)if(Array.isArray(e.content))return e.content.map(e=>"object"==typeof e&&null!==e?e.text||JSON.stringify(e):String(e)).join(" ");else if("object"==typeof e.content)return JSON.stringify(e.content,null,2);else return String(e.content);return e.text?String(e.text):JSON.stringify(e,null,2)})()})]}),"function_call"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-blue-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"🔧"})}),(0,c.jsxs)("div",{className:"flex-1",children:[(0,c.jsxs)("div",{className:"font-medium text-blue-900 dark:text-blue-100",children:[String(e.name||"unknown")," 도구 호출"]}),(0,c.jsxs)("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[(0,c.jsx)("span",{children:"도구 호출됨"}),e.call_id?(0,c.jsxs)("span",{className:"bg-blue-100 dark:bg-blue-900 px-2 py-0.5 rounded text-xs font-mono",children:[String(e.call_id).substring(0,12),"..."]}):null]})]}),e.status?(0,c.jsx)("span",{className:"px-2 py-1 text-xs rounded ".concat("completed"===e.status?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:String(e.status)}):null]}),e.arguments?(0,c.jsxs)("div",{className:"bg-blue-50/50 dark:bg-blue-950/30 p-2 rounded border border-blue-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-blue-800 dark:text-blue-200 mb-1",children:"📋 입력 매개변수:"}),(0,c.jsx)("pre",{className:"text-xs text-blue-700 dark:text-blue-300 overflow-auto max-h-32 bg-white/50 dark:bg-gray-800/50 p-2 rounded",children:(()=>{try{return JSON.stringify(JSON.parse(String(e.arguments)),null,2)}catch(t){return String(e.arguments)}})()})]}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"매개변수 없음"})]}),"function_call_output"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-green-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"✅"})}),(0,c.jsxs)("div",{className:"flex-1",children:[(0,c.jsx)("div",{className:"font-medium text-green-900 dark:text-green-100",children:"도구 실행 완료"}),(0,c.jsxs)("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[(0,c.jsx)("span",{children:"실행 결과 반환됨"}),e.call_id?(0,c.jsxs)("span",{className:"bg-green-100 dark:bg-green-900 px-2 py-0.5 rounded text-xs font-mono",children:[String(e.call_id).substring(0,12),"..."]}):null]})]})]}),e.output?(0,c.jsxs)("div",{className:"bg-green-50/50 dark:bg-green-950/30 p-2 rounded border border-green-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-green-800 dark:text-green-200 mb-1",children:"📊 실행 결과:"}),(0,c.jsx)("div",{className:"bg-white/70 dark:bg-gray-800/70 p-2 rounded border",children:(()=>{try{let t=JSON.parse(String(e.output));if(t.tool&&t.stdout)return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)("span",{className:"text-xs font-medium text-green-700 dark:text-green-300",children:"도구:"}),(0,c.jsx)("code",{className:"text-xs bg-green-100 dark:bg-green-900 px-1 py-0.5 rounded",children:t.tool}),(0,c.jsx)("span",{className:"text-xs font-medium text-green-700 dark:text-green-300",children:"상태:"}),(0,c.jsx)("span",{className:"text-xs px-1 py-0.5 rounded ".concat(0===t.exit_code?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"),children:0===t.exit_code?"성공":"실패"})]}),t.stdout&&(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"text-xs font-medium text-green-700 dark:text-green-300 mb-1",children:"출력:"}),(0,c.jsx)("pre",{className:"text-xs text-green-600 dark:text-green-400 whitespace-pre-wrap bg-gray-50 dark:bg-gray-800 p-2 rounded",children:t.stdout})]}),t.stderr&&(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"text-xs font-medium text-red-700 dark:text-red-300 mb-1",children:"오류:"}),(0,c.jsx)("pre",{className:"text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap bg-red-50 dark:bg-red-900/20 p-2 rounded",children:t.stderr})]})]});return(0,c.jsx)("pre",{className:"text-xs text-green-700 dark:text-green-300 overflow-auto max-h-40 leading-relaxed",children:JSON.stringify(t,null,2)})}catch(t){return(0,c.jsx)("pre",{className:"text-xs text-green-700 dark:text-green-300 overflow-auto max-h-40 leading-relaxed whitespace-pre-wrap",children:String(e.output)})}})()})]}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"결과 없음"})]}),"message"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-indigo-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"💬"})}),(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"font-medium text-indigo-900 dark:text-indigo-100",children:"최종 응답"}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"assistant"===e.role?"AI 어시스턴트 응답":"".concat(String(e.role)," 메시지")})]})]}),e.content&&Array.isArray(e.content)?(0,c.jsx)("div",{className:"space-y-2",children:e.content.map((e,t)=>(0,c.jsx)("div",{children:"output_text"===e.type&&(0,c.jsxs)("div",{className:"bg-indigo-50/50 dark:bg-indigo-950/30 p-3 rounded border border-indigo-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-indigo-800 dark:text-indigo-200 mb-2",children:"💭 응답 내용:"}),(()=>{let t=String(e.text||"");try{let e=JSON.parse(t);return(0,c.jsx)("div",{className:"bg-white/70 dark:bg-gray-800/70 rounded border",children:(0,c.jsx)(iA,{data:e,onChange:()=>{},expandAllByDefault:!0,className:"text-sm"})})}catch(e){return(0,c.jsx)("div",{className:"text-sm text-indigo-900 dark:text-indigo-100 whitespace-pre-wrap leading-relaxed",children:t})}})()]})},t))}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"메시지 내용 없음"})]}),!["reasoning","function_call","function_call_output","message"].includes(String(e.type))&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,c.jsx)("span",{className:"text-lg",children:"📄"}),(0,c.jsxs)("div",{className:"font-medium text-sm",children:["알 수 없는 타입: ",String(e.type)]})]}),(0,c.jsx)("div",{className:"bg-gray-50/50 dark:bg-gray-950/30 p-2 rounded border",children:(0,c.jsx)("pre",{className:"text-xs text-gray-700 dark:text-gray-300 overflow-auto max-h-40",children:JSON.stringify(e,null,2)})})]})]})]},t)})(e,t))})]}):null]})}function vm(e){let{data:t,className:n=""}=e,[i,r]=(0,d.useState)([]),[s,o]=(0,d.useState)(new Set),[l,a]=(0,d.useState)(""),[h,u]=(0,d.useState)([]);(0,d.useEffect)(()=>{if(t){let e=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[];return null===t?[{key:n.join(".")||"root",value:null,type:"null",path:n,level:i}]:(Array.isArray(t)?t.forEach((t,s)=>{let o=[...n,"[".concat(s,"]")];r.push({key:o.join("."),value:t,type:vd(t),path:o,level:i}),"object"==typeof t&&null!==t&&r.push(...e(t,o,i+1))}):"object"==typeof t?Object.entries(t).forEach(t=>{let[s,o]=t,l=[...n,s];r.push({key:l.join("."),value:o,type:vd(o),path:l,level:i}),"object"==typeof o&&null!==o&&r.push(...e(o,l,i+1))}):r.push({key:n.join(".")||"root",value:t,type:vd(t),path:n,level:i}),r)}(t);r(e),o(new Set(e.filter(e=>"object"===e.type||"array"===e.type).map(e=>e.key)))}},[t]),(0,d.useEffect)(()=>{l?u(i.filter(e=>e.key.toLowerCase().includes(l.toLowerCase())||String(e.value).toLowerCase().includes(l.toLowerCase()))):u(i)},[i,l]);let f=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),iv.default.success("JSON이 클립보드에 복사되었습니다")}catch(n){console.log("Failed to copy to clipboard:",n);let e=document.createElement("textarea");e.value=JSON.stringify(t,null,2),document.body.appendChild(e),e.select();try{document.execCommand("copy"),iv.default.success("JSON이 클립보드에 복사되었습니다")}catch(e){console.log("Fallback copy failed:",e),iv.default.error("클립보드 복사에 실패했습니다")}document.body.removeChild(e)}},p=()=>{let e=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download="response.json",i.click(),URL.revokeObjectURL(n)};if(!t)return(0,c.jsx)(tw,{className:"h-full ".concat(n),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(vh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"No response data to display"})]})})});let m=vf(t)||t&&"object"==typeof t&&!Array.isArray(t)&&t.data&&"object"==typeof t.data&&Array.isArray(t.data.output);return(console.log("Final decision:",{isAIAgent:vf(t),shouldShow:m,hasDataOutput:!!((null==t?void 0:t.data)&&"object"==typeof t.data&&t.data.output)}),m)?(0,c.jsx)("div",{className:"h-full flex flex-col ".concat(n),children:(0,c.jsxs)("div",{className:"h-full p-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsx)("div",{children:(0,c.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-5 w-5"}),"AI Agent Response"]})}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:f,children:[(0,c.jsx)(iS,{className:"h-4 w-4 mr-1"}),"Copy"]}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:p,children:[(0,c.jsx)(tg,{className:"h-4 w-4 mr-1"}),"Download"]})]})]}),(0,c.jsxs)(g6,{defaultValue:"structured",className:"h-full flex flex-col",children:[(0,c.jsxs)(vo,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[(0,c.jsxs)(vl,{value:"structured",className:"flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-4 w-4"}),"구조화된 뷰"]}),(0,c.jsxs)(vl,{value:"tree",className:"flex items-center gap-2",children:[(0,c.jsx)(gI,{className:"h-4 w-4"}),"트리 뷰"]})]}),(0,c.jsx)(va,{value:"structured",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"pr-4",children:(0,c.jsx)(vp,{data:t})})})}),(0,c.jsx)(va,{value:"tree",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(iA,{data:t,onChange:()=>{},expandAllByDefault:!0})})]})]})}):(0,c.jsx)("div",{className:"h-full flex flex-col ".concat(n),children:(0,c.jsxs)("div",{className:"h-full p-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsx)("div",{children:(0,c.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-5 w-5"}),"Response Viewer"]})}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{o(new Set(i.filter(e=>"object"===e.type||"array"===e.type).map(e=>e.key)))},children:"Expand All"}),(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{o(new Set)},children:"Collapse All"}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:f,children:[(0,c.jsx)(iS,{className:"h-4 w-4 mr-1"}),"Copy"]}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:p,children:[(0,c.jsx)(tg,{className:"h-4 w-4 mr-1"}),"Download"]})]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,c.jsx)(vc,{className:"h-4 w-4 text-muted-foreground"}),(0,c.jsx)(iC,{placeholder:"Search fields and values...",value:l,onChange:e=>a(e.target.value),className:"flex-1"})]}),(0,c.jsxs)(g6,{defaultValue:"tree",className:"h-full flex flex-col",children:[(0,c.jsxs)(vo,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[(0,c.jsxs)(vl,{value:"tree",className:"flex items-center gap-2",children:[(0,c.jsx)(gI,{className:"h-4 w-4"}),"Tree View"]}),(0,c.jsxs)(vl,{value:"raw",className:"flex items-center gap-2",children:[(0,c.jsx)(ip,{className:"h-4 w-4"}),"Raw JSON"]})]}),(0,c.jsx)(va,{value:"tree",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-1 pr-4",children:h.filter(e=>{if(0===e.level)return!0;let t=e.path.slice(0,-1).join(".");return s.has(t)}).map(e=>(0,c.jsx)(vu,{field:e,expanded:s.has(e.key),onToggle:()=>(e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),o(t)})(e.key),searchTerm:l},e.key))})})}),(0,c.jsx)(va,{value:"raw",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"bg-muted p-4 rounded-lg mr-4",children:(0,c.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:JSON.stringify(t,null,2)})})})})]})]})})}let vg=td("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),vv=td("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),vx=td("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),vb=td("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);function vy(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&("role"in e[0]&&"content"in e[0]||"type"in e[0]&&("function_call"===e[0].type||"function_call_output"===e[0].type||"reasoning"===e[0].type))}function vw(e){let{data:t,onChange:n,className:i=""}=e,[r,s]=(0,d.useState)([]),o=e=>"function_call"===e.type||"reasoning"===e.type||"function_call_output"===e.type;(0,d.useEffect)(()=>{vy(t)?s(t.map(e=>"content"in e?{...e,content:Array.isArray(e.content)?e.content:[]}:e)):s([])},[t]);let l=(e,t,i,o)=>{let l=[...r];Array.isArray(l[e].content)||(l[e].content=[]);let a=l[e].content[t];a&&("type"===i?a.type=o:"text"===i&&(a.text=o)),s(l),n(l)},a=(e,t,i)=>{let o=[...r];o[e][t]=i,s(o),n(o)};return vy(t)?(0,c.jsxs)(tw,{className:"h-full ".concat(i),children:[(0,c.jsxs)(tk,{children:[(0,c.jsxs)(tS,{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(vv,{className:"h-5 w-5"}),"Input 메시지 편집기"]}),(0,c.jsxs)(tr,{size:"sm",onClick:()=>{let e=[...r,{role:"user",content:[{type:"input_text",text:""}]}];s(e),n(e)},children:[(0,c.jsx)(iw,{className:"h-4 w-4 mr-2"}),"메시지 추가"]})]}),(0,c.jsxs)(tC,{children:["대화 메시지와 함수 호출을 편집합니다 (",r.length,"개 메시지)"]})]}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-6",children:r.map((e,t)=>(0,c.jsx)(gh,{type:"single",collapsible:!0,defaultValue:"system"===e.role?void 0:"message-".concat(t),children:(0,c.jsxs)(gE,{value:"message-".concat(t),className:"border-2 rounded-lg bg-card/50 shadow-sm",children:[(0,c.jsx)(gT,{className:"text-sm font-medium hover:no-underline px-4 py-3 bg-muted/30 rounded-t-lg",children:(0,c.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat(function(e){switch(e.role){case"system":return"bg-purple-50 text-purple-700 dark:bg-purple-800 dark:text-purple-100";case"user":return"bg-blue-50 text-blue-700 dark:bg-blue-800 dark:text-blue-100";case"assistant":return"bg-green-50 text-green-700 dark:bg-green-800 dark:text-green-100";default:if("reasoning"===e.type)return"bg-orange-50 text-orange-700 dark:bg-orange-800 dark:text-orange-100";if("function_call"===e.type)return"bg-red-50 text-red-700 dark:bg-red-800 dark:text-red-100";return e.type,"bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-100"}}(e)),children:[function(e){switch(e.role){case"system":return(0,c.jsx)(tv,{className:"h-4 w-4"});case"user":return(0,c.jsx)(vx,{className:"h-4 w-4"});case"assistant":return(0,c.jsx)(vb,{className:"h-4 w-4"});default:if("reasoning"===e.type)return(0,c.jsx)(gP,{className:"h-4 w-4"});if("function_call"===e.type)return(0,c.jsx)(tv,{className:"h-4 w-4"});if("function_call_output"===e.type)return(0,c.jsx)(tp,{className:"h-4 w-4"});return(0,c.jsx)(vv,{className:"h-4 w-4"})}}(e),String(e.role||e.type||"Unknown")]}),(0,c.jsx)("span",{className:"text-muted-foreground text-xs flex-1 text-left",children:"system"===e.role||"user"===e.role||"assistant"===e.role?"".concat(Array.isArray(e.content)?e.content.length:0," content items"):"function_call_output"===e.type?String(e.call_id||"Function Call Output"):String(e.name||e.id||"Message ".concat(t+1))}),(0,c.jsx)(tr,{size:"sm",variant:"ghost",onClick:e=>{e.stopPropagation();let i=r.filter((e,n)=>n!==t);s(i),n(i)},className:"h-6 w-6 p-0",disabled:o(e),children:(0,c.jsx)(vg,{className:"h-3 w-3"})})]})}),(0,c.jsx)(gD,{children:(0,c.jsxs)("div",{className:"space-y-4 pt-2 px-4 pb-4 bg-background/50 rounded-b-lg",children:[(0,c.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[void 0!==e.role&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"role-".concat(t),children:"Role"}),(0,c.jsx)(iC,{id:"role-".concat(t),value:String(e.role||""),onChange:e=>a(t,"role",e.target.value),className:"font-mono text-xs",placeholder:"system, user, assistant",readOnly:o(e)})]}),void 0!==e.id&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"id-".concat(t),children:"ID"}),(0,c.jsx)(iC,{id:"id-".concat(t),value:String(e.id||""),onChange:e=>a(t,"id",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.type&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"type-".concat(t),children:"Type"}),(0,c.jsx)(iC,{id:"type-".concat(t),value:String(e.type||""),onChange:e=>a(t,"type",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.status&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"status-".concat(t),children:"Status"}),(0,c.jsx)(iC,{id:"status-".concat(t),value:String(e.status||""),onChange:e=>a(t,"status",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.arguments&&(0,c.jsxs)("div",{className:"space-y-2 col-span-2",children:[(0,c.jsx)(iO,{htmlFor:"args-".concat(t),children:"Arguments"}),(0,c.jsx)(mW,{id:"args-".concat(t),value:String(e.arguments||""),onChange:e=>a(t,"arguments",e),language:"json",readOnly:o(e)})]}),void 0!==e.call_id&&"function_call_output"!==e.type&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"call_id-".concat(t),children:"Call ID"}),(0,c.jsx)(iC,{id:"call_id-".concat(t),value:String(e.call_id||""),onChange:e=>a(t,"call_id",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.name&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"name-".concat(t),children:"Name"}),(0,c.jsx)(iC,{id:"name-".concat(t),value:String(e.name||""),onChange:e=>a(t,"name",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.output&&(0,c.jsxs)("div",{className:"space-y-2 col-span-2",children:[(0,c.jsx)(iO,{htmlFor:"output-".concat(t),children:"Output"}),(0,c.jsx)(mW,{id:"output-".concat(t),value:String(e.output||""),onChange:e=>a(t,"output",e),language:"json",readOnly:o(e)})]})]}),(0,c.jsx)(mK,{}),e.role&&("system"===e.role||"user"===e.role||"assistant"===e.role)&&(0,c.jsxs)("div",{className:"space-y-3",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)(iO,{children:["Content (",Array.isArray(e.content)?e.content.length:0," items)"]}),(0,c.jsxs)(tr,{size:"sm",variant:"outline",onClick:()=>(e=>{let t=[...r];Array.isArray(t[e].content)||(t[e].content=[]),t[e].content.push({type:"input_text",text:""}),s(t),n(t)})(t),disabled:o(e),children:[(0,c.jsx)(iw,{className:"h-3 w-3 mr-1"}),"Add Content"]})]}),Array.isArray(e.content)?e.content.map((i,a)=>(0,c.jsxs)("div",{className:"border-2 border-dashed border-muted-foreground/30 rounded-lg p-4 space-y-3 bg-muted/20",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)(to,{variant:"outline",className:"text-xs font-medium bg-primary/10 text-primary border-primary/20",children:["Content ",a+1]}),(0,c.jsx)(iC,{value:String(i.type||""),onChange:e=>l(t,a,"type",e.target.value),className:"w-40 h-8 font-mono text-xs",placeholder:"input_text, text, image",readOnly:o(e)})]}),(0,c.jsx)(tr,{size:"sm",variant:"ghost",onClick:()=>((e,t)=>{let i=[...r];Array.isArray(i[e].content)&&(i[e].content=i[e].content.filter((e,n)=>n!==t)),s(i),n(i)})(t,a),className:"h-6 w-6 p-0",disabled:o(e),children:(0,c.jsx)(vg,{className:"h-3 w-3"})})]}),void 0!==i.text&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{children:"Text Content"}),(i.text||"").length>100?(0,c.jsx)(mW,{value:String(i.text||""),onChange:e=>l(t,a,"text",e),language:"text",readOnly:o(e)}):(0,c.jsx)(iC,{value:String(i.text||""),onChange:e=>l(t,a,"text",e.target.value),placeholder:"Enter text content...",readOnly:o(e)})]})]},a)):null]}),void 0!==e.summary&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{children:"Summary"}),(0,c.jsx)(mW,{value:JSON.stringify(e.summary,null,2),onChange:e=>{try{let i=JSON.parse(e),o=[...r];o[t].summary=i,s(o),n(o)}catch(e){}},language:"json",readOnly:o(e)})]}),(0,c.jsx)(mK,{className:"my-4"})]})})]})},t))})})})]}):(0,c.jsx)(tw,{className:"h-full ".concat(i),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(vv,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"Input 배열 형식이 아닙니다"})]})})})}let vk=(0,ig.default)(()=>e.A(53096),{loadableGenerated:{modules:[67211]},ssr:!1});function vS(e){var t,n;let{selectedFile:i,onFileUpdate:r}=e,[s,o]=(0,d.useState)(""),[l,a]=(0,d.useState)(null),[h,u]=(0,d.useState)("form"),[f,p]=(0,d.useState)({}),[m,g]=(0,d.useState)(new Set),v=d.useRef({}),[x,b]=(0,d.useState)(!1),[y,w]=(0,d.useState)(!1),[k,S]=(0,d.useState)(null),[C,A]=(0,d.useState)(!1),[N,M]=(0,d.useState)("editor"),[O,j]=(0,d.useState)("openai"),E=(0,d.useRef)(null),T=(0,d.useRef)(null),[D,R]=(0,d.useState)(0),P=d.useCallback(e=>{let t=Math.max(e+10,100);Math.abs(t-D)>1&&(R(t),E.current&&(E.current.style.height="".concat(t,"px")),T.current&&requestAnimationFrame(()=>{var e;null==(e=T.current)||e.layout()}))},[D]),L=d.useCallback(e=>{if(T.current&&T.current!==e){let e=T.current._heightSubscription;e&&e.dispose()}T.current=e;let t=e.onDidContentSizeChange(e=>{P(e.contentHeight)}),n=T.current;n&&(n._heightSubscription=t),setTimeout(()=>{let t=e.getDomNode();t&&t.addEventListener("wheel",e=>{var t;let n=null==(t=E.current)?void 0:t.parentElement;for(;n;){if(n.hasAttribute("data-radix-scroll-area-viewport")||n.querySelector("[data-radix-scroll-area-viewport]")){let t=n.hasAttribute("data-radix-scroll-area-viewport")?n:n.querySelector("[data-radix-scroll-area-viewport]");if(t){t.scrollTop+=e.deltaY,e.preventDefault(),e.stopPropagation();break}}n=n.parentElement}},{passive:!1,capture:!0}),P(e.getContentHeight()),e.layout()},100)},[P]),I=d.useCallback(e=>{let t=e.currentTarget.parentElement;for(;t;){if(t.hasAttribute("data-radix-scroll-area-viewport")||t.classList.contains("scroll-area")||t.querySelector("[data-radix-scroll-area-viewport]")){let n=t.hasAttribute("data-radix-scroll-area-viewport")?t:t.querySelector("[data-radix-scroll-area-viewport]");if(n){let t=n.scrollTop,i=e.deltaY;n.scrollTo({top:t+i,behavior:"auto"}),e.preventDefault();break}}t=t.parentElement}},[]);(0,d.useEffect)(()=>()=>{if(T.current){let e=T.current._heightSubscription;e&&e.dispose()}},[]);let B=d.useCallback(e=>{let t=v.current[e];if(t){let n=t.querySelector("[data-radix-scroll-area-viewport]");n&&p(t=>({...t,[e]:n.scrollTop}))}},[]),z=d.useCallback(e=>{let t=v.current[e],n=f[e];if(t&&"number"==typeof n){let e=t.querySelector("[data-radix-scroll-area-viewport]");e&&setTimeout(()=>{e.scrollTop=n},10)}},[f]),F=d.useCallback(e=>{"result"===N&&M("editor"),B(h),u(e),setTimeout(()=>{z(e),"code"===e&&T.current&&setTimeout(()=>{var e;null==(e=T.current)||e.layout()},50)},50)},[h,N,B,z]),_=d.useCallback(async()=>{if(i)try{b(!0);let e=await il("/api/logs/".concat(encodeURIComponent(i.name)));if(!e.ok)throw Error("Failed to load file");let t=await e.json(),n=t.data||t;o(JSON.stringify(n,null,2)),a(n);let r="openai";if(t.provider)r=t.provider;else if(n.provider)r=n.provider;else{let e="messages"in n&&Array.isArray(n.messages),t="input"in n&&Array.isArray(n.input),i="output"in n&&Array.isArray(n.output),s="max_tokens"in n,o="content"in n&&Array.isArray(n.content),l=n.model||"";e||s||o||l.startsWith("claude-")?r="anthropic":(t||i||l.startsWith("gpt-")||l.startsWith("o1-"))&&(r="openai")}j(r)}catch(e){iv.default.error("파일 로드 실패")}finally{b(!1)}},[i]);(0,d.useEffect)(()=>{var e,t;i&&((null==(e=i.parsedInfo)?void 0:e.type)==="REQ"||(null==(t=i.parsedInfo)?void 0:t.type)==="RES")?(R(100),E.current&&(E.current.style.height="100px"),S(null),M("editor"),_()):(o(""),a(null),R(100),E.current&&(E.current.style.height="100px"),S(null),M("editor"))},[i,_]);let W=e=>{try{return JSON.parse(e),!0}catch(e){return!1}},V=e=>{a(e),o(JSON.stringify(e,null,2))},H=async()=>{if(!i||!W(s))return void iv.default.error("유효하지 않은 JSON 형식입니다");try{(await il("/api/logs/".concat(encodeURIComponent(i.name)),{method:"PUT",headers:{"Content-Type":"application/json"},body:s})).ok?(iv.default.success("파일이 저장되었습니다"),r()):iv.default.error("저장 실패")}catch(e){iv.default.error("저장 중 오류가 발생했습니다")}},q=async()=>{if(!W(s))return void iv.default.error("유효하지 않은 JSON 형식입니다");try{w(!0);let e=Date.now(),t=await il("anthropic"===O?"/api/test-anthropic":"/api/test-openai",{method:"POST",headers:{"Content-Type":"application/json"},body:s}),n=await t.json(),i=Date.now()-e;S({success:t.ok,response:n,error:t.ok?void 0:n.error,executionTime:i}),M("result"),t.ok?(iv.default.success("".concat("anthropic"===O?"Anthropic":"OpenAI"," 요청이 성공적으로 실행되었습니다")),r()):iv.default.error("요청 실행 실패")}catch(e){S({success:!1,error:e instanceof Error?e.message:"알 수 없는 오류"}),M("result"),iv.default.error("실행 중 오류가 발생했습니다")}finally{w(!1),A(!1)}};return i?(null==(t=i.parsedInfo)?void 0:t.type)==="RES"?(0,c.jsx)("div",{className:"h-full flex flex-col",children:x?(0,c.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,c.jsx)(id,{className:"h-6 w-6 animate-spin"})}):(0,c.jsx)(vm,{data:l,className:"h-full"})}):(null==(n=i.parsedInfo)?void 0:n.type)!=="REQ"?(0,c.jsx)(tw,{className:"h-full",children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(tf,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{className:"text-lg",children:"지원하지 않는 파일 타입입니다"}),(0,c.jsx)("p",{className:"text-sm",children:"REQ 또는 RES 파일만 지원됩니다"})]})})}):(0,c.jsxs)(tw,{className:"h-full flex flex-col !border-none !rounded-none",children:[(0,c.jsx)(tk,{className:"flex-shrink-0",children:(0,c.jsxs)(tS,{className:"flex items-center justify-between",children:[(0,c.jsxs)("span",{className:"flex items-center gap-2",children:[(0,c.jsx)(ia,{className:"h-5 w-5"}),"요청 편집기: ",i.name]}),(0,c.jsxs)("div",{className:"flex items-center gap-4",children:[(0,c.jsxs)("div",{className:"flex items-center bg-muted rounded-lg p-1",children:[(0,c.jsxs)(tr,{variant:"form"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("form"),className:"h-8",children:[(0,c.jsx)(im,{className:"h-4 w-4 mr-1"}),"폼"]}),(0,c.jsxs)(tr,{variant:"code"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("code"),className:"h-8",children:[(0,c.jsx)(ip,{className:"h-4 w-4 mr-1"}),"코드"]}),(0,c.jsxs)(tr,{variant:"tree"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("tree"),className:"h-8",children:[(0,c.jsx)(iu,{className:"h-4 w-4 mr-1"}),"트리"]}),k&&(0,c.jsxs)(tr,{variant:"result"===N?"default":"ghost",size:"sm",onClick:()=>M("result"),className:"h-8",children:[(0,c.jsx)(tx,{className:"h-4 w-4 mr-1"}),"실행결과"]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)("div",{className:"hidden flex items-center gap-1 mr-2 px-2 py-1 border rounded-md bg-muted/30",children:[(0,c.jsx)(tr,{size:"sm",variant:"openai"===O?"default":"ghost",onClick:()=>j("openai"),className:"h-6 px-2",children:"OpenAI"}),(0,c.jsx)(tr,{size:"sm",variant:"anthropic"===O?"default":"ghost",onClick:()=>j("anthropic"),className:"h-6 px-2",children:"Anthropic"})]}),(0,c.jsxs)(tr,{onClick:H,variant:"outline",size:"sm",disabled:x||!W(s),children:[(0,c.jsx)(ic,{className:"h-4 w-4 mr-2"}),"저장"]}),(0,c.jsxs)(nI,{open:C,onOpenChange:A,children:[(0,c.jsx)(nz,{asChild:!0,children:(0,c.jsxs)(tr,{size:"sm",disabled:x||y||!W(s),children:[y?(0,c.jsx)(id,{className:"h-4 w-4 mr-2 animate-spin"}):(0,c.jsx)(ih,{className:"h-4 w-4 mr-2"}),"실행"]})}),(0,c.jsxs)(ii,{children:[(0,c.jsxs)(ir,{children:[(0,c.jsx)(is,{children:"요청 실행 확인"}),(0,c.jsxs)(io,{children:["anthropic"===O?"Anthropic Claude":"OpenAI"," API 요청을 실행하시겠습니까?",(0,c.jsx)("br",{}),"이 작업은 실제 AI 모델을 호출합니다."]})]}),(0,c.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,c.jsx)(tr,{variant:"outline",onClick:()=>A(!1),children:"취소"}),(0,c.jsxs)(tr,{onClick:q,disabled:y,children:[y?(0,c.jsx)(id,{className:"h-4 w-4 mr-2 animate-spin"}):(0,c.jsx)(ih,{className:"h-4 w-4 mr-2"}),"실행"]})]})]})]})]})]})]})}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:x?(0,c.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,c.jsx)(id,{className:"h-6 w-6 animate-spin"})}):"result"===N&&k?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.result=e},children:k.success?(0,c.jsx)("div",{className:"h-full",children:(0,c.jsx)(vm,{data:k.response,className:"h-full"})}):(0,c.jsx)("div",{className:"bg-red-50 border border-red-200 p-4 rounded-lg",children:(0,c.jsx)("p",{className:"text-red-800",children:k.error})})},"result-scroll"):"form"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.form=e},children:(0,c.jsx)("div",{className:"space-y-4",children:l?l&&"object"==typeof l&&null!==l&&"input"in l&&Array.isArray(l.input)?(0,c.jsxs)("div",{className:"space-y-4",children:[(0,c.jsx)(vw,{data:l.input,onChange:e=>{V({...l,input:e})},className:"h-full"}),(0,c.jsx)(gz,{data:Object.fromEntries(Object.entries(l).filter(e=>{let[t]=e;return"input"!==t})),onChange:e=>{V({...e,input:l.input})},className:"h-full"})]}):(0,c.jsx)(gz,{data:l,onChange:V,className:"h-full"}):(0,c.jsxs)("div",{className:"border rounded-lg p-8 text-center text-muted-foreground",children:[(0,c.jsx)(im,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"JSON 데이터를 파싱할 수 없습니다"}),(0,c.jsx)("p",{className:"text-sm",children:"코드 편집기에서 유효한 JSON을 입력하세요"})]})})},"form-scroll"):"code"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.code=e},children:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{ref:E,className:"border rounded-lg overflow-hidden mb-4",style:{height:"".concat(D,"px")},onWheel:I,children:(0,c.jsx)(vk,{height:"100%",defaultLanguage:"json",theme:"vs-dark",value:s,onChange:e=>{let t=e||"";if(o(t),W(t))try{a(JSON.parse(t))}catch(e){}},onMount:L,options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,lineNumbers:"on",renderWhitespace:"selection",folding:!0,wordWrap:"on",formatOnType:!0,formatOnPaste:!0,automaticLayout:!1,scrollbar:{vertical:"hidden",verticalScrollbarSize:0,horizontal:"auto",horizontalScrollbarSize:10},overviewRulerLanes:0,hideCursorInOverviewRuler:!0,overviewRulerBorder:!1,mouseWheelScrollSensitivity:0}})}),(0,c.jsx)("div",{className:"flex items-center gap-2",children:W(s)?(0,c.jsxs)("div",{className:"flex items-center text-sm text-green-600",children:[(0,c.jsx)(tx,{className:"h-4 w-4 mr-1"}),"유효한 JSON"]}):(0,c.jsxs)("div",{className:"flex items-center text-sm text-red-600",children:[(0,c.jsx)(tf,{className:"h-4 w-4 mr-1"}),"유효하지 않은 JSON"]})})]})},"code-scroll"):"tree"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.tree=e},children:(0,c.jsx)("div",{className:"space-y-4",children:l?(0,c.jsx)(iA,{data:l,onChange:V,className:"h-full",expandedNodes:m,onExpandedNodesChange:g,expandAllByDefault:!0}):(0,c.jsxs)("div",{className:"border rounded-lg p-8 text-center text-muted-foreground",children:[(0,c.jsx)(iu,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"JSON 데이터를 파싱할 수 없습니다"}),(0,c.jsx)("p",{className:"text-sm",children:"코드 편집기에서 유효한 JSON을 입력하세요"})]})})},"tree-scroll"):null})]}):(0,c.jsx)(tw,{className:"h-full",children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(ia,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{className:"text-lg",children:"REQ 파일을 선택하세요"}),(0,c.jsx)("p",{className:"text-sm",children:"요청 파일을 선택하면 내용을 편집하고 재실행할 수 있습니다"})]})})})}function vC(){let[e,t]=(0,d.useState)([]),[n,i]=(0,d.useState)(null),[r,s]=(0,d.useState)(!0),[o,l]=(0,d.useState)(null);(0,d.useEffect)(()=>{a()},[]);let a=async()=>{try{s(!0);let e=await il("/api/logs"),n=await e.json();e.ok?(t(n.files||[]),l(null)):l(n.message||"Failed to load log files")}catch(e){l("Failed to connect to server")}finally{s(!1)}};return(0,c.jsxs)("div",{className:"h-screen bg-background flex",children:[(0,c.jsxs)("div",{className:"flex-shrink-0 w-80 border-r border-border bg-background flex flex-col",children:[(0,c.jsxs)("div",{className:"flex-shrink-0 border-b border-border p-4",children:[(0,c.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(tp,{className:"h-5 w-5"}),"로그 파일"]}),(0,c.jsx)("p",{className:"text-sm text-muted-foreground",children:r?"로딩 중...":"".concat(e.length,"개 파일")})]}),(0,c.jsx)("div",{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)(ty,{files:e,selectedFile:n,onFileSelect:e=>{i(e)},loading:r,error:o,onRefresh:a})})})]}),(0,c.jsx)("div",{className:"flex-1 min-w-0",children:(0,c.jsx)(vS,{selectedFile:n,onFileUpdate:a})})]})}}]);
|
|
1
|
+
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,67585,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return r}});let i=e.r(32061);function r(e){let{reason:t,children:n}=e;if("undefined"==typeof window)throw Object.defineProperty(new i.BailoutToCSRError(t),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return n}},9885,(e,t,n)=>{"use strict";function i(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return i}})},52157,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return l}});let i=e.r(43476),r=e.r(74080),s=e.r(63599),o=e.r(9885);function l(e){let{moduleIds:t}=e;if("undefined"!=typeof window)return null;let n=s.workAsyncStorage.getStore();if(void 0===n)return null;let l=[];if(n.reactLoadableManifest&&t){let e=n.reactLoadableManifest;for(let n of t){if(!e[n])continue;let t=e[n].files;l.push(...t)}}return 0===l.length?null:(0,i.jsx)(i.Fragment,{children:l.map(e=>{let t=n.assetPrefix+"/_next/"+(0,o.encodeURIPath)(e);return e.endsWith(".css")?(0,i.jsx)("link",{precedence:"dynamic",href:t,rel:"stylesheet",as:"style"},e):((0,r.preload)(t,{as:"script",fetchPriority:"low"}),null)})})}},69093,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return h}});let i=e.r(43476),r=e.r(71645),s=e.r(67585),o=e.r(52157);function l(e){return{default:e&&"default"in e?e.default:e}}let a={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},h=function(e){let t={...a,...e},n=(0,r.lazy)(()=>t.loader().then(l)),h=t.loading;function c(e){let l=h?(0,i.jsx)(h,{isLoading:!0,pastDelay:!0,error:null}):null,a=!t.ssr||!!t.loading,c=a?r.Suspense:r.Fragment,d=t.ssr?(0,i.jsxs)(i.Fragment,{children:["undefined"==typeof window?(0,i.jsx)(o.PreloadChunks,{moduleIds:t.modules}):null,(0,i.jsx)(n,{...e})]}):(0,i.jsx)(s.BailoutToCSR,{reason:"next/dynamic",children:(0,i.jsx)(n,{...e})});return(0,i.jsx)(c,{...a?{fallback:l}:{},children:d})}return c.displayName="LoadableComponent",c}},70703,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return r}});let i=e.r(55682)._(e.r(69093));function r(e,t){var n;let r={};"function"==typeof e&&(r.loader=e);let s={...r,...t};return(0,i.default)({...s,modules:null==(n=s.loadableGenerated)?void 0:n.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},31713,e=>{"use strict";let t,n;e.s(["default",()=>vC],31713);var i,r,s,o,l,a,h,c=e.i(43476),d=e.i(71645),u=e.i(74080);function f(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function p(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return e=>{let n=!1,i=t.map(t=>{let i=f(t,e);return n||"function"!=typeof i||(n=!0),i});if(n)return()=>{for(let e=0;e<i.length;e++){let n=i[e];"function"==typeof n?n():f(t[e],null)}}}}function m(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return d.useCallback(p(...t),t)}function g(e){let t=function(e){let t=d.forwardRef((e,t)=>{let{children:n,...i}=e;if(d.isValidElement(n)){var r,s,o;let e,l,a=(l=(e=null==(s=Object.getOwnPropertyDescriptor((r=n).props,"ref"))?void 0:s.get)&&"isReactWarning"in e&&e.isReactWarning)?r.ref:(l=(e=null==(o=Object.getOwnPropertyDescriptor(r,"ref"))?void 0:o.get)&&"isReactWarning"in e&&e.isReactWarning)?r.props.ref:r.props.ref||r.ref,h=function(e,t){let n={...t};for(let i in t){let r=e[i],s=t[i];/^on[A-Z]/.test(i)?r&&s?n[i]=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=s(...t);return r(...t),i}:r&&(n[i]=r):"style"===i?n[i]={...r,...s}:"className"===i&&(n[i]=[r,s].filter(Boolean).join(" "))}return{...e,...n}}(i,n.props);return n.type!==d.Fragment&&(h.ref=t?p(t,a):a),d.cloneElement(n,h)}return d.Children.count(n)>1?d.Children.only(null):null});return t.displayName="".concat(e,".SlotClone"),t}(e),n=d.forwardRef((e,n)=>{let{children:i,...r}=e,s=d.Children.toArray(i),o=s.find(b);if(o){let e=o.props.children,i=s.map(t=>t!==o?t:d.Children.count(e)>1?d.Children.only(null):d.isValidElement(e)?e.props.children:null);return(0,c.jsx)(t,{...r,ref:n,children:d.isValidElement(e)?d.cloneElement(e,void 0,i):null})}return(0,c.jsx)(t,{...r,ref:n,children:i})});return n.displayName="".concat(e,".Slot"),n}var v=g("Slot"),x=Symbol("radix.slottable");function b(e){return d.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===x}var y=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,t)=>{let n=g("Primitive.".concat(t)),i=d.forwardRef((e,i)=>{let{asChild:r,...s}=e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,c.jsx)(r?n:t,{...s,ref:i})});return i.displayName="Primitive.".concat(t),{...e,[t]:i}},{}),w=(null==(r=globalThis)?void 0:r.document)?d.useLayoutEffect:()=>{},k=e=>{let{present:t,children:n}=e,i=function(e){var t,n;let[i,r]=d.useState(),s=d.useRef(null),o=d.useRef(e),l=d.useRef("none"),[a,h]=(t=e?"mounted":"unmounted",n={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},d.useReducer((e,t)=>{let i=n[e][t];return null!=i?i:e},t));return d.useEffect(()=>{let e=S(s.current);l.current="mounted"===a?e:"none"},[a]),w(()=>{let t=s.current,n=o.current;if(n!==e){let i=l.current,r=S(t);e?h("MOUNT"):"none"===r||(null==t?void 0:t.display)==="none"?h("UNMOUNT"):n&&i!==r?h("ANIMATION_OUT"):h("UNMOUNT"),o.current=e}},[e,h]),w(()=>{if(i){var e;let t,n=null!=(e=i.ownerDocument.defaultView)?e:window,r=e=>{let r=S(s.current).includes(CSS.escape(e.animationName));if(e.target===i&&r&&(h("ANIMATION_END"),!o.current)){let e=i.style.animationFillMode;i.style.animationFillMode="forwards",t=n.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=e)})}},a=e=>{e.target===i&&(l.current=S(s.current))};return i.addEventListener("animationstart",a),i.addEventListener("animationcancel",r),i.addEventListener("animationend",r),()=>{n.clearTimeout(t),i.removeEventListener("animationstart",a),i.removeEventListener("animationcancel",r),i.removeEventListener("animationend",r)}}h("ANIMATION_END")},[i,h]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:d.useCallback(e=>{s.current=e?getComputedStyle(e):null,r(e)},[])}}(t),r="function"==typeof n?n({present:i.isPresent}):d.Children.only(n),s=m(i.ref,function(e){var t,n;let i=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=i&&"isReactWarning"in i&&i.isReactWarning;return r?e.ref:(r=(i=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get)&&"isReactWarning"in i&&i.isReactWarning)?e.props.ref:e.props.ref||e.ref}(r));return"function"==typeof n||i.isPresent?d.cloneElement(r,{ref:s}):null};function S(e){return(null==e?void 0:e.animationName)||"none"}function C(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=[],i=()=>{let t=n.map(e=>d.createContext(e));return function(n){let i=(null==n?void 0:n[e])||t;return d.useMemo(()=>({["__scope".concat(e)]:{...n,[e]:i}}),[n,i])}};return i.scopeName=e,[function(t,i){let r=d.createContext(i),s=n.length;n=[...n,i];let o=t=>{var n;let{scope:i,children:o,...l}=t,a=(null==i||null==(n=i[e])?void 0:n[s])||r,h=d.useMemo(()=>l,Object.values(l));return(0,c.jsx)(a.Provider,{value:h,children:o})};return o.displayName=t+"Provider",[o,function(n,o){var l;let a=(null==o||null==(l=o[e])?void 0:l[s])||r,h=d.useContext(a);if(h)return h;if(void 0!==i)return i;throw Error("`".concat(n,"` must be used within `").concat(t,"`"))}]},function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=t[0];if(1===t.length)return i;let r=()=>{let e=t.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(t){let n=e.reduce((e,n)=>{let{useScope:i,scopeName:r}=n,s=i(t)["__scope".concat(r)];return{...e,...s}},{});return d.useMemo(()=>({["__scope".concat(i.scopeName)]:n}),[n])}};return r.scopeName=i.scopeName,r}(i,...t)]}function A(e){let t=d.useRef(e);return d.useEffect(()=>{t.current=e}),d.useMemo(()=>function(){for(var e,n=arguments.length,i=Array(n),r=0;r<n;r++)i[r]=arguments[r];return null==(e=t.current)?void 0:e.call(t,...i)},[])}k.displayName="Presence";var N=d.createContext(void 0);function M(e){let t=d.useContext(N);return e||t||"ltr"}function O(e,t){let{checkForDefaultPrevented:n=!0}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(i){if(null==e||e(i),!1===n||!i.defaultPrevented)return null==t?void 0:t(i)}}"undefined"!=typeof window&&window.document&&window.document.createElement;var j="ScrollArea",[E,T]=C(j),[D,R]=E(j),P=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,type:i="hover",dir:r,scrollHideDelay:s=600,...o}=e,[l,a]=d.useState(null),[h,u]=d.useState(null),[f,p]=d.useState(null),[g,v]=d.useState(null),[x,b]=d.useState(null),[w,k]=d.useState(0),[S,C]=d.useState(0),[A,N]=d.useState(!1),[O,j]=d.useState(!1),E=m(t,e=>a(e)),T=M(r);return(0,c.jsx)(D,{scope:n,type:i,dir:T,scrollHideDelay:s,scrollArea:l,viewport:h,onViewportChange:u,content:f,onContentChange:p,scrollbarX:g,onScrollbarXChange:v,scrollbarXEnabled:A,onScrollbarXEnabledChange:N,scrollbarY:x,onScrollbarYChange:b,scrollbarYEnabled:O,onScrollbarYEnabledChange:j,onCornerWidthChange:k,onCornerHeightChange:C,children:(0,c.jsx)(y.div,{dir:T,...o,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":w+"px","--radix-scroll-area-corner-height":S+"px",...e.style}})})});P.displayName=j;var L="ScrollAreaViewport",I=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,children:i,nonce:r,...s}=e,o=R(L,n),l=m(t,d.useRef(null),o.onViewportChange);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),(0,c.jsx)(y.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:(0,c.jsx)("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})});I.displayName=L;var B="ScrollAreaScrollbar",z=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=R(B,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:o}=r,l="horizontal"===e.orientation;return d.useEffect(()=>(l?s(!0):o(!0),()=>{l?s(!1):o(!1)}),[l,s,o]),"hover"===r.type?(0,c.jsx)(F,{...i,ref:t,forceMount:n}):"scroll"===r.type?(0,c.jsx)(_,{...i,ref:t,forceMount:n}):"auto"===r.type?(0,c.jsx)(W,{...i,ref:t,forceMount:n}):"always"===r.type?(0,c.jsx)(V,{...i,ref:t}):null});z.displayName=B;var F=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=R(B,e.__scopeScrollArea),[s,o]=d.useState(!1);return d.useEffect(()=>{let e=r.scrollArea,t=0;if(e){let n=()=>{window.clearTimeout(t),o(!0)},i=()=>{t=window.setTimeout(()=>o(!1),r.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",i),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",i)}}},[r.scrollArea,r.scrollHideDelay]),(0,c.jsx)(k,{present:n||s,children:(0,c.jsx)(W,{"data-state":s?"visible":"hidden",...i,ref:t})})}),_=d.forwardRef((e,t)=>{var n;let{forceMount:i,...r}=e,s=R(B,e.__scopeScrollArea),o="horizontal"===e.orientation,l=eo(()=>h("SCROLL_END"),100),[a,h]=(n={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},d.useReducer((e,t)=>{let i=n[e][t];return null!=i?i:e},"hidden"));return d.useEffect(()=>{if("idle"===a){let e=window.setTimeout(()=>h("HIDE"),s.scrollHideDelay);return()=>window.clearTimeout(e)}},[a,s.scrollHideDelay,h]),d.useEffect(()=>{let e=s.viewport,t=o?"scrollLeft":"scrollTop";if(e){let n=e[t],i=()=>{let i=e[t];n!==i&&(h("SCROLL"),l()),n=i};return e.addEventListener("scroll",i),()=>e.removeEventListener("scroll",i)}},[s.viewport,o,h,l]),(0,c.jsx)(k,{present:i||"hidden"!==a,children:(0,c.jsx)(V,{"data-state":"hidden"===a?"hidden":"visible",...r,ref:t,onPointerEnter:O(e.onPointerEnter,()=>h("POINTER_ENTER")),onPointerLeave:O(e.onPointerLeave,()=>h("POINTER_LEAVE"))})})}),W=d.forwardRef((e,t)=>{let n=R(B,e.__scopeScrollArea),{forceMount:i,...r}=e,[s,o]=d.useState(!1),l="horizontal"===e.orientation,a=eo(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(l?e:t)}},10);return el(n.viewport,a),el(n.content,a),(0,c.jsx)(k,{present:i||s,children:(0,c.jsx)(V,{"data-state":s?"visible":"hidden",...r,ref:t})})}),V=d.forwardRef((e,t)=>{let{orientation:n="vertical",...i}=e,r=R(B,e.__scopeScrollArea),s=d.useRef(null),o=d.useRef(0),[l,a]=d.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),h=et(l.viewport,l.content),u={...i,sizes:l,onSizesChange:a,hasThumb:!!(h>0&&h<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:e=>o.current=e};function f(e,t){return function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"ltr",r=en(n),s=t||r/2,o=n.scrollbar.paddingStart+s,l=n.scrollbar.size-n.scrollbar.paddingEnd-(r-s),a=n.content-n.viewport;return er([o,l],"ltr"===i?[0,a]:[-1*a,0])(e)}(e,o.current,l,t)}return"horizontal"===n?(0,c.jsx)(H,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&s.current){let e=ei(r.viewport.scrollLeft,l,r.dir);s.current.style.transform="translate3d(".concat(e,"px, 0, 0)")}},onWheelScroll:e=>{r.viewport&&(r.viewport.scrollLeft=e)},onDragScroll:e=>{r.viewport&&(r.viewport.scrollLeft=f(e,r.dir))}}):"vertical"===n?(0,c.jsx)(q,{...u,ref:t,onThumbPositionChange:()=>{if(r.viewport&&s.current){let e=ei(r.viewport.scrollTop,l);s.current.style.transform="translate3d(0, ".concat(e,"px, 0)")}},onWheelScroll:e=>{r.viewport&&(r.viewport.scrollTop=e)},onDragScroll:e=>{r.viewport&&(r.viewport.scrollTop=f(e))}}):null}),H=d.forwardRef((e,t)=>{let{sizes:n,onSizesChange:i,...r}=e,s=R(B,e.__scopeScrollArea),[o,l]=d.useState(),a=d.useRef(null),h=m(t,a,s.onScrollbarXChange);return d.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),(0,c.jsx)(J,{"data-orientation":"horizontal",...r,ref:h,sizes:n,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":en(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(s.viewport){let i=s.viewport.scrollLeft+t.deltaX;e.onWheelScroll(i),function(e,t){return e>0&&e<t}(i,n)&&t.preventDefault()}},onResize:()=>{a.current&&s.viewport&&o&&i({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:a.current.clientWidth,paddingStart:ee(o.paddingLeft),paddingEnd:ee(o.paddingRight)}})}})}),q=d.forwardRef((e,t)=>{let{sizes:n,onSizesChange:i,...r}=e,s=R(B,e.__scopeScrollArea),[o,l]=d.useState(),a=d.useRef(null),h=m(t,a,s.onScrollbarYChange);return d.useEffect(()=>{a.current&&l(getComputedStyle(a.current))},[a]),(0,c.jsx)(J,{"data-orientation":"vertical",...r,ref:h,sizes:n,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":en(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(s.viewport){let i=s.viewport.scrollTop+t.deltaY;e.onWheelScroll(i),function(e,t){return e>0&&e<t}(i,n)&&t.preventDefault()}},onResize:()=>{a.current&&s.viewport&&o&&i({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:a.current.clientHeight,paddingStart:ee(o.paddingTop),paddingEnd:ee(o.paddingBottom)}})}})}),[K,U]=E(B),J=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,sizes:i,hasThumb:r,onThumbChange:s,onThumbPointerUp:o,onThumbPointerDown:l,onThumbPositionChange:a,onDragScroll:h,onWheelScroll:u,onResize:f,...p}=e,g=R(B,n),[v,x]=d.useState(null),b=m(t,e=>x(e)),w=d.useRef(null),k=d.useRef(""),S=g.viewport,C=i.content-i.viewport,N=A(u),M=A(a),j=eo(f,10);function E(e){w.current&&h({x:e.clientX-w.current.left,y:e.clientY-w.current.top})}return d.useEffect(()=>{let e=e=>{let t=e.target;(null==v?void 0:v.contains(t))&&N(e,C)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[S,v,C,N]),d.useEffect(M,[i,M]),el(v,j),el(g.content,j),(0,c.jsx)(K,{scope:n,scrollbar:v,hasThumb:r,onThumbChange:A(s),onThumbPointerUp:A(o),onThumbPositionChange:M,onThumbPointerDown:A(l),children:(0,c.jsx)(y.div,{...p,ref:b,style:{position:"absolute",...p.style},onPointerDown:O(e.onPointerDown,e=>{0===e.button&&(e.target.setPointerCapture(e.pointerId),w.current=v.getBoundingClientRect(),k.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),E(e))}),onPointerMove:O(e.onPointerMove,E),onPointerUp:O(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=k.current,g.viewport&&(g.viewport.style.scrollBehavior=""),w.current=null})})})}),G="ScrollAreaThumb",Y=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=U(G,e.__scopeScrollArea);return(0,c.jsx)(k,{present:n||r.hasThumb,children:(0,c.jsx)(Q,{ref:t,...i})})}),Q=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,style:i,...r}=e,s=R(G,n),o=U(G,n),{onThumbPositionChange:l}=o,a=m(t,e=>o.onThumbChange(e)),h=d.useRef(void 0),u=eo(()=>{h.current&&(h.current(),h.current=void 0)},100);return d.useEffect(()=>{let e=s.viewport;if(e){let t=()=>{u(),h.current||(h.current=es(e,l),l())};return l(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}},[s.viewport,u,l]),(0,c.jsx)(y.div,{"data-state":o.hasThumb?"visible":"hidden",...r,ref:a,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:O(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;o.onThumbPointerDown({x:n,y:i})}),onPointerUp:O(e.onPointerUp,o.onThumbPointerUp)})});Y.displayName=G;var X="ScrollAreaCorner",$=d.forwardRef((e,t)=>{let n=R(X,e.__scopeScrollArea),i=!!(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&i?(0,c.jsx)(Z,{...e,ref:t}):null});$.displayName=X;var Z=d.forwardRef((e,t)=>{let{__scopeScrollArea:n,...i}=e,r=R(X,n),[s,o]=d.useState(0),[l,a]=d.useState(0),h=!!(s&&l);return el(r.scrollbarX,()=>{var e;let t=(null==(e=r.scrollbarX)?void 0:e.offsetHeight)||0;r.onCornerHeightChange(t),a(t)}),el(r.scrollbarY,()=>{var e;let t=(null==(e=r.scrollbarY)?void 0:e.offsetWidth)||0;r.onCornerWidthChange(t),o(t)}),h?(0,c.jsx)(y.div,{...i,ref:t,style:{width:s,height:l,position:"absolute",right:"ltr"===r.dir?0:void 0,left:"rtl"===r.dir?0:void 0,bottom:0,...e.style}}):null});function ee(e){return e?parseInt(e,10):0}function et(e,t){let n=e/t;return isNaN(n)?0:n}function en(e){let t=et(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd;return Math.max((e.scrollbar.size-n)*t,18)}function ei(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"ltr",i=en(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-r,o=t.content-t.viewport,l=function(e,t){let[n,i]=t;return Math.min(i,Math.max(n,e))}(e,"ltr"===n?[0,o]:[-1*o,0]);return er([0,o],[0,s-i])(l)}function er(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let i=(t[1]-t[0])/(e[1]-e[0]);return t[0]+i*(n-e[0])}}var es=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:()=>{},n={left:e.scrollLeft,top:e.scrollTop},i=0;return!function r(){let s={left:e.scrollLeft,top:e.scrollTop},o=n.left!==s.left,l=n.top!==s.top;(o||l)&&t(),n=s,i=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(i)};function eo(e,t){let n=A(e),i=d.useRef(0);return d.useEffect(()=>()=>window.clearTimeout(i.current),[]),d.useCallback(()=>{window.clearTimeout(i.current),i.current=window.setTimeout(n,t)},[n,t])}function el(e,t){let n=A(t);w(()=>{let t=0;if(e){let i=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return i.observe(e),()=>{window.cancelAnimationFrame(t),i.unobserve(e)}}},[e,n])}function ea(){for(var e,t,n=0,i="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=function e(t){var n,i,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t)){var s=t.length;for(n=0;n<s;n++)t[n]&&(i=e(t[n]))&&(r&&(r+=" "),r+=i)}else for(i in t)t[i]&&(r&&(r+=" "),r+=i);return r}(e))&&(i&&(i+=" "),i+=t);return i}let eh=(e,t)=>{var n;if(0===e.length)return t.classGroupId;let i=e[0],r=t.nextPart.get(i),s=r?eh(e.slice(1),r):void 0;if(s)return s;if(0===t.validators.length)return;let o=e.join("-");return null==(n=t.validators.find(e=>{let{validator:t}=e;return t(o)}))?void 0:n.classGroupId},ec=/^\[(.+)\]$/,ed=(e,t,n,i)=>{e.forEach(e=>{if("string"==typeof e){(""===e?t:eu(t,e)).classGroupId=n;return}if("function"==typeof e)return ef(e)?void ed(e(i),t,n,i):void t.validators.push({validator:e,classGroupId:n});Object.entries(e).forEach(e=>{let[r,s]=e;ed(s,eu(t,r),n,i)})})},eu=(e,t)=>{let n=e;return t.split("-").forEach(e=>{n.nextPart.has(e)||n.nextPart.set(e,{nextPart:new Map,validators:[]}),n=n.nextPart.get(e)}),n},ef=e=>e.isThemeGetter,ep=/\s+/;function em(){let e,t,n=0,i="";for(;n<arguments.length;)(e=arguments[n++])&&(t=eg(e))&&(i&&(i+=" "),i+=t);return i}let eg=e=>{let t;if("string"==typeof e)return e;let n="";for(let i=0;i<e.length;i++)e[i]&&(t=eg(e[i]))&&(n&&(n+=" "),n+=t);return n},ev=e=>{let t=t=>t[e]||[];return t.isThemeGetter=!0,t},ex=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,eb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ey=/^\d+\/\d+$/,ew=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,ek=/\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$/,eS=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,eC=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,eA=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,eN=e=>ey.test(e),eM=e=>!!e&&!Number.isNaN(Number(e)),eO=e=>!!e&&Number.isInteger(Number(e)),ej=e=>e.endsWith("%")&&eM(e.slice(0,-1)),eE=e=>ew.test(e),eT=()=>!0,eD=e=>ek.test(e)&&!eS.test(e),eR=()=>!1,eP=e=>eC.test(e),eL=e=>eA.test(e),eI=e=>!ez(e)&&!eq(e),eB=e=>eX(e,e1,eR),ez=e=>ex.test(e),eF=e=>eX(e,e2,eD),e_=e=>eX(e,e3,eM),eW=e=>eX(e,eZ,eR),eV=e=>eX(e,e0,eL),eH=e=>eX(e,e5,eP),eq=e=>eb.test(e),eK=e=>e$(e,e2),eU=e=>e$(e,e4),eJ=e=>e$(e,eZ),eG=e=>e$(e,e1),eY=e=>e$(e,e0),eQ=e=>e$(e,e5,!0),eX=(e,t,n)=>{let i=ex.exec(e);return!!i&&(i[1]?t(i[1]):n(i[2]))},e$=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=eb.exec(e);return!!i&&(i[1]?t(i[1]):n)},eZ=e=>"position"===e||"percentage"===e,e0=e=>"image"===e||"url"===e,e1=e=>"length"===e||"size"===e||"bg-size"===e,e2=e=>"length"===e,e3=e=>"number"===e,e4=e=>"family-name"===e,e5=e=>"shadow"===e;Symbol.toStringTag;let e8=function(e){let t,n,i;for(var r=arguments.length,s=Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];let l=function(r){let o;return n=(t={cache:(e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=new Map,i=new Map,r=(r,s)=>{n.set(r,s),++t>e&&(t=0,i=n,n=new Map)};return{get(e){let t=n.get(e);return void 0!==t?t:void 0!==(t=i.get(e))?(r(e,t),t):void 0},set(e,t){n.has(e)?n.set(e,t):r(e,t)}}})((o=s.reduce((e,t)=>t(e),e())).cacheSize),parseClassName:(e=>{let{prefix:t,experimentalParseClassName:n}=e,i=e=>{let t,n,i=[],r=0,s=0,o=0;for(let n=0;n<e.length;n++){let l=e[n];if(0===r&&0===s){if(":"===l){i.push(e.slice(o,n)),o=n+1;continue}if("/"===l){t=n;continue}}"["===l?r++:"]"===l?r--:"("===l?s++:")"===l&&s--}let l=0===i.length?e:e.substring(o),a=(n=l).endsWith("!")?n.substring(0,n.length-1):n.startsWith("!")?n.substring(1):n;return{modifiers:i,hasImportantModifier:a!==l,baseClassName:a,maybePostfixModifierPosition:t&&t>o?t-o:void 0}};if(t){let e=t+":",n=i;i=t=>t.startsWith(e)?n(t.substring(e.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:t,maybePostfixModifierPosition:void 0}}if(n){let e=i;i=t=>n({className:t,parseClassName:e})}return i})(o),sortModifiers:(e=>{let t=Object.fromEntries(e.orderSensitiveModifiers.map(e=>[e,!0]));return e=>{if(e.length<=1)return e;let n=[],i=[];return e.forEach(e=>{"["===e[0]||t[e]?(n.push(...i.sort(),e),i=[]):i.push(e)}),n.push(...i.sort()),n}})(o),...(e=>{let t=(e=>{let{theme:t,classGroups:n}=e,i={nextPart:new Map,validators:[]};for(let e in n)ed(n[e],i,e,t);return i})(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:i}=e;return{getClassGroupId:e=>{let n=e.split("-");return""===n[0]&&1!==n.length&&n.shift(),eh(n,t)||(e=>{if(ec.test(e)){let t=ec.exec(e)[1],n=null==t?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}})(e)},getConflictingClassGroupIds:(e,t)=>{let r=n[e]||[];return t&&i[e]?[...r,...i[e]]:r}}})(o)}).cache.get,i=t.cache.set,l=a,a(r)};function a(e){let r=n(e);if(r)return r;let s=((e,t)=>{let{parseClassName:n,getClassGroupId:i,getConflictingClassGroupIds:r,sortModifiers:s}=t,o=[],l=e.trim().split(ep),a="";for(let e=l.length-1;e>=0;e-=1){let t=l[e],{isExternal:h,modifiers:c,hasImportantModifier:d,baseClassName:u,maybePostfixModifierPosition:f}=n(t);if(h){a=t+(a.length>0?" "+a:a);continue}let p=!!f,m=i(p?u.substring(0,f):u);if(!m){if(!p||!(m=i(u))){a=t+(a.length>0?" "+a:a);continue}p=!1}let g=s(c).join(":"),v=d?g+"!":g,x=v+m;if(o.includes(x))continue;o.push(x);let b=r(m,p);for(let e=0;e<b.length;++e){let t=b[e];o.push(v+t)}a=t+(a.length>0?" "+a:a)}return a})(e,t);return i(e,s),s}return function(){return l(em.apply(null,arguments))}}(()=>{let e=ev("color"),t=ev("font"),n=ev("text"),i=ev("font-weight"),r=ev("tracking"),s=ev("leading"),o=ev("breakpoint"),l=ev("container"),a=ev("spacing"),h=ev("radius"),c=ev("shadow"),d=ev("inset-shadow"),u=ev("text-shadow"),f=ev("drop-shadow"),p=ev("blur"),m=ev("perspective"),g=ev("aspect"),v=ev("ease"),x=ev("animate"),b=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],w=()=>[...y(),eq,ez],k=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],C=()=>[eq,ez,a],A=()=>[eN,"full","auto",...C()],N=()=>[eO,"none","subgrid",eq,ez],M=()=>["auto",{span:["full",eO,eq,ez]},eO,eq,ez],O=()=>[eO,"auto",eq,ez],j=()=>["auto","min","max","fr",eq,ez],E=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],T=()=>["start","end","center","stretch","center-safe","end-safe"],D=()=>["auto",...C()],R=()=>[eN,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...C()],P=()=>[e,eq,ez],L=()=>[...y(),eJ,eW,{position:[eq,ez]}],I=()=>["no-repeat",{repeat:["","x","y","space","round"]}],B=()=>["auto","cover","contain",eG,eB,{size:[eq,ez]}],z=()=>[ej,eK,eF],F=()=>["","none","full",h,eq,ez],_=()=>["",eM,eK,eF],W=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[eM,ej,eJ,eW],q=()=>["","none",p,eq,ez],K=()=>["none",eM,eq,ez],U=()=>["none",eM,eq,ez],J=()=>[eM,eq,ez],G=()=>[eN,"full",...C()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[eE],breakpoint:[eE],color:[eT],container:[eE],"drop-shadow":[eE],ease:["in","out","in-out"],font:[eI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[eE],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[eE],shadow:[eE],spacing:["px",eM],text:[eE],"text-shadow":[eE],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",eN,ez,eq,g]}],container:["container"],columns:[{columns:[eM,ez,eq,l]}],"break-after":[{"break-after":b()}],"break-before":[{"break-before":b()}],"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:w()}],overflow:[{overflow:k()}],"overflow-x":[{"overflow-x":k()}],"overflow-y":[{"overflow-y":k()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:A()}],"inset-x":[{"inset-x":A()}],"inset-y":[{"inset-y":A()}],start:[{start:A()}],end:[{end:A()}],top:[{top:A()}],right:[{right:A()}],bottom:[{bottom:A()}],left:[{left:A()}],visibility:["visible","invisible","collapse"],z:[{z:[eO,"auto",eq,ez]}],basis:[{basis:[eN,"full","auto",l,...C()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[eM,eN,"auto","initial","none",ez]}],grow:[{grow:["",eM,eq,ez]}],shrink:[{shrink:["",eM,eq,ez]}],order:[{order:[eO,"first","last","none",eq,ez]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:M()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:M()}],"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":j()}],"auto-rows":[{"auto-rows":j()}],gap:[{gap:C()}],"gap-x":[{"gap-x":C()}],"gap-y":[{"gap-y":C()}],"justify-content":[{justify:[...E(),"normal"]}],"justify-items":[{"justify-items":[...T(),"normal"]}],"justify-self":[{"justify-self":["auto",...T()]}],"align-content":[{content:["normal",...E()]}],"align-items":[{items:[...T(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...T(),{baseline:["","last"]}]}],"place-content":[{"place-content":E()}],"place-items":[{"place-items":[...T(),"baseline"]}],"place-self":[{"place-self":["auto",...T()]}],p:[{p:C()}],px:[{px:C()}],py:[{py:C()}],ps:[{ps:C()}],pe:[{pe:C()}],pt:[{pt:C()}],pr:[{pr:C()}],pb:[{pb:C()}],pl:[{pl:C()}],m:[{m:D()}],mx:[{mx:D()}],my:[{my:D()}],ms:[{ms:D()}],me:[{me:D()}],mt:[{mt:D()}],mr:[{mr:D()}],mb:[{mb:D()}],ml:[{ml:D()}],"space-x":[{"space-x":C()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":C()}],"space-y-reverse":["space-y-reverse"],size:[{size:R()}],w:[{w:[l,"screen",...R()]}],"min-w":[{"min-w":[l,"screen","none",...R()]}],"max-w":[{"max-w":[l,"screen","none","prose",{screen:[o]},...R()]}],h:[{h:["screen","lh",...R()]}],"min-h":[{"min-h":["screen","lh","none",...R()]}],"max-h":[{"max-h":["screen","lh",...R()]}],"font-size":[{text:["base",n,eK,eF]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[i,eq,e_]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ej,ez]}],"font-family":[{font:[eU,ez,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:[r,eq,ez]}],"line-clamp":[{"line-clamp":[eM,"none",eq,e_]}],leading:[{leading:[s,...C()]}],"list-image":[{"list-image":["none",eq,ez]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",eq,ez]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...W(),"wavy"]}],"text-decoration-thickness":[{decoration:[eM,"from-font","auto",eq,eF]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[eM,"auto",eq,ez]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:C()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",eq,ez]}],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",eq,ez]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:B()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},eO,eq,ez],radial:["",eq,ez],conic:[eO,eq,ez]},eY,eV]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:z()}],"gradient-via-pos":[{via:z()}],"gradient-to-pos":[{to:z()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:F()}],"rounded-s":[{"rounded-s":F()}],"rounded-e":[{"rounded-e":F()}],"rounded-t":[{"rounded-t":F()}],"rounded-r":[{"rounded-r":F()}],"rounded-b":[{"rounded-b":F()}],"rounded-l":[{"rounded-l":F()}],"rounded-ss":[{"rounded-ss":F()}],"rounded-se":[{"rounded-se":F()}],"rounded-ee":[{"rounded-ee":F()}],"rounded-es":[{"rounded-es":F()}],"rounded-tl":[{"rounded-tl":F()}],"rounded-tr":[{"rounded-tr":F()}],"rounded-br":[{"rounded-br":F()}],"rounded-bl":[{"rounded-bl":F()}],"border-w":[{border:_()}],"border-w-x":[{"border-x":_()}],"border-w-y":[{"border-y":_()}],"border-w-s":[{"border-s":_()}],"border-w-e":[{"border-e":_()}],"border-w-t":[{"border-t":_()}],"border-w-r":[{"border-r":_()}],"border-w-b":[{"border-b":_()}],"border-w-l":[{"border-l":_()}],"divide-x":[{"divide-x":_()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":_()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...W(),"hidden","none"]}],"divide-style":[{divide:[...W(),"hidden","none"]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...W(),"none","hidden"]}],"outline-offset":[{"outline-offset":[eM,eq,ez]}],"outline-w":[{outline:["",eM,eK,eF]}],"outline-color":[{outline:P()}],shadow:[{shadow:["","none",c,eQ,eH]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":["none",d,eQ,eH]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:_()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[eM,eF]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":_()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":["none",u,eQ,eH]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[eM,eq,ez]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"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":[eM]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[eq,ez]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"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":y()}],"mask-image-conic-pos":[{"mask-conic":[eM]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:B()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",eq,ez]}],filter:[{filter:["","none",eq,ez]}],blur:[{blur:q()}],brightness:[{brightness:[eM,eq,ez]}],contrast:[{contrast:[eM,eq,ez]}],"drop-shadow":[{"drop-shadow":["","none",f,eQ,eH]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:["",eM,eq,ez]}],"hue-rotate":[{"hue-rotate":[eM,eq,ez]}],invert:[{invert:["",eM,eq,ez]}],saturate:[{saturate:[eM,eq,ez]}],sepia:[{sepia:["",eM,eq,ez]}],"backdrop-filter":[{"backdrop-filter":["","none",eq,ez]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[eM,eq,ez]}],"backdrop-contrast":[{"backdrop-contrast":[eM,eq,ez]}],"backdrop-grayscale":[{"backdrop-grayscale":["",eM,eq,ez]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[eM,eq,ez]}],"backdrop-invert":[{"backdrop-invert":["",eM,eq,ez]}],"backdrop-opacity":[{"backdrop-opacity":[eM,eq,ez]}],"backdrop-saturate":[{"backdrop-saturate":[eM,eq,ez]}],"backdrop-sepia":[{"backdrop-sepia":["",eM,eq,ez]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":C()}],"border-spacing-x":[{"border-spacing-x":C()}],"border-spacing-y":[{"border-spacing-y":C()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",eq,ez]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[eM,"initial",eq,ez]}],ease:[{ease:["linear","initial",v,eq,ez]}],delay:[{delay:[eM,eq,ez]}],animate:[{animate:["none",x,eq,ez]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,eq,ez]}],"perspective-origin":[{"perspective-origin":w()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":["scale-3d"],skew:[{skew:J()}],"skew-x":[{"skew-x":J()}],"skew-y":[{"skew-y":J()}],transform:[{transform:[eq,ez,"","none","gpu","cpu"]}],"transform-origin":[{origin:w()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:G()}],"translate-x":[{"translate-x":G()}],"translate-y":[{"translate-y":G()}],"translate-z":[{"translate-z":G()}],"translate-none":["translate-none"],accent:[{accent:P()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:P()}],"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",eq,ez]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":C()}],"scroll-mx":[{"scroll-mx":C()}],"scroll-my":[{"scroll-my":C()}],"scroll-ms":[{"scroll-ms":C()}],"scroll-me":[{"scroll-me":C()}],"scroll-mt":[{"scroll-mt":C()}],"scroll-mr":[{"scroll-mr":C()}],"scroll-mb":[{"scroll-mb":C()}],"scroll-ml":[{"scroll-ml":C()}],"scroll-p":[{"scroll-p":C()}],"scroll-px":[{"scroll-px":C()}],"scroll-py":[{"scroll-py":C()}],"scroll-ps":[{"scroll-ps":C()}],"scroll-pe":[{"scroll-pe":C()}],"scroll-pt":[{"scroll-pt":C()}],"scroll-pr":[{"scroll-pr":C()}],"scroll-pb":[{"scroll-pb":C()}],"scroll-pl":[{"scroll-pl":C()}],"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",eq,ez]}],fill:[{fill:["none",...P()]}],"stroke-w":[{stroke:[eM,eK,eF,e_]}],stroke:[{stroke:["none",...P()]}],"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-x","border-w-y","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-x","border-color-y","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"],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-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"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}});function e6(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return e8(ea(t))}function e9(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB"][t]}let e7=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsxs)(P,{ref:t,className:e6("relative overflow-hidden",n),...r,children:[(0,c.jsx)(I,{className:"h-full w-full rounded-[inherit]",children:i}),(0,c.jsx)(te,{}),(0,c.jsx)($,{})]})});e7.displayName=P.displayName;let te=d.forwardRef((e,t)=>{let{className:n,orientation:i="vertical",...r}=e;return(0,c.jsx)(z,{ref:t,orientation:i,className:e6("flex touch-none select-none transition-colors","vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",n),...r,children:(0,c.jsx)(Y,{className:"relative flex-1 rounded-full bg-border"})})});te.displayName=z.displayName;let tt=e=>"boolean"==typeof e?"".concat(e):0===e?"0":e,tn=(e,t)=>n=>{var i;if((null==t?void 0:t.variants)==null)return ea(e,null==n?void 0:n.class,null==n?void 0:n.className);let{variants:r,defaultVariants:s}=t,o=Object.keys(r).map(e=>{let t=null==n?void 0:n[e],i=null==s?void 0:s[e];if(null===t)return null;let o=tt(t)||tt(i);return r[e][o]}),l=n&&Object.entries(n).reduce((e,t)=>{let[n,i]=t;return void 0===i||(e[n]=i),e},{});return ea(e,o,null==t||null==(i=t.compoundVariants)?void 0:i.reduce((e,t)=>{let{class:n,className:i,...r}=t;return Object.entries(r).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...s,...l}[t]):({...s,...l})[t]===n})?[...e,n,i]:e},[]),null==n?void 0:n.class,null==n?void 0:n.className)},ti=tn("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),tr=d.forwardRef((e,t)=>{let{className:n,variant:i,size:r,asChild:s=!1,...o}=e;return(0,c.jsx)(s?v:"button",{className:e6(ti({variant:i,size:r,className:n})),ref:t,...o})});tr.displayName="Button";let ts=tn("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function to(e){let{className:t,variant:n,...i}=e;return(0,c.jsx)("div",{className:e6(ts({variant:n}),t),...i})}let tl=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)},ta=function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter((e,t,n)=>!!e&&""!==e.trim()&&n.indexOf(e)===t).join(" ").trim()};var th={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"};let tc=(0,d.forwardRef)((e,t)=>{let{color:n="currentColor",size:i=24,strokeWidth:r=2,absoluteStrokeWidth:s,className:o="",children:l,iconNode:a,...h}=e;return(0,d.createElement)("svg",{ref:t,...th,width:i,height:i,stroke:n,strokeWidth:s?24*Number(r)/Number(i):r,className:ta("lucide",o),...!l&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0})(h)&&{"aria-hidden":"true"},...h},[...a.map(e=>{let[t,n]=e;return(0,d.createElement)(t,n)}),...Array.isArray(l)?l:[l]])}),td=(e,t)=>{let n=(0,d.forwardRef)((n,i)=>{let{className:r,...s}=n;return(0,d.createElement)(tc,{ref:i,iconNode:t,className:ta("lucide-".concat(tl(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),r),...s})});return n.displayName=tl(e),n},tu=td("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),tf=td("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]),tp=td("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]),tm=td("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),tg=td("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"}]]),tv=td("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),tx=td("circle-check-big",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]),tb=td("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function ty(e){let{files:t,selectedFile:n,onFileSelect:i,loading:r,error:s,onRefresh:o}=e;if(r)return(0,c.jsxs)("div",{className:"p-4 text-center text-muted-foreground",children:[(0,c.jsx)(tu,{className:"h-6 w-6 animate-spin mx-auto mb-2"}),"로딩 중..."]});if(s)return(0,c.jsxs)("div",{className:"p-4 text-center",children:[(0,c.jsx)(tf,{className:"h-6 w-6 text-destructive mx-auto mb-2"}),(0,c.jsx)("p",{className:"text-sm text-destructive mb-2",children:s}),(0,c.jsx)(tr,{onClick:o,size:"sm",children:"다시 시도"})]});let l=(()=>{let e=[],n=t.filter(e=>{var t;return(null==(t=e.parsedInfo)?void 0:t.type)==="REQ"}),i=t.filter(e=>{var t;return(null==(t=e.parsedInfo)?void 0:t.type)==="RES"});return n.forEach(t=>{let n;if(!t.parsedInfo)return;let r=t.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/);if(!r)return;let s=r[1],o=1/0;i.filter(e=>{var n,i;return(null==(n=e.parsedInfo)?void 0:n.component)===(null==(i=t.parsedInfo)?void 0:i.component)}).forEach(e=>{if(!e.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/))return;let i=new Date(t.parsedInfo.datetime).getTime(),r=new Date(e.parsedInfo.datetime).getTime(),s=Math.abs(r-i);r>=i&&s<o&&(o=s,n=e)}),e.push({id:"".concat(t.parsedInfo.component,"-").concat(s),component:t.parsedInfo.component,timestamp:t.parsedInfo.datetime,request:t,response:n})}),i.forEach(t=>{if(t.parsedInfo&&!e.some(e=>{var n;return(null==(n=e.response)?void 0:n.name)===t.name})){let n=t.name.match(/(\d{4}-\d{2}-\d{2}_\d{9})/),i=n?n[1]:Date.now().toString();e.push({id:"".concat(t.parsedInfo.component,"-").concat(i,"-res-only"),component:t.parsedInfo.component,timestamp:t.parsedInfo.datetime,response:t})}}),e.sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())})().map((e,t)=>({...e,round:t+1}));return(0,c.jsxs)("div",{className:"p-4 space-y-4",children:[(0,c.jsxs)(tr,{onClick:o,variant:"outline",size:"sm",className:"w-full",children:[(0,c.jsx)(tu,{className:"h-4 w-4 mr-2"}),"새로고침"]}),(0,c.jsx)("div",{className:"space-y-3",children:l.map(e=>{var t,r;let s=(null==n?void 0:n.name)===(null==(t=e.request)?void 0:t.name),o=(null==n?void 0:n.name)===(null==(r=e.response)?void 0:r.name);return(0,c.jsxs)("div",{className:"border rounded-lg overflow-hidden",children:[(0,c.jsx)("div",{className:"bg-muted/30 px-4 py-2 border-b",children:(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(e=>{switch(null==e?void 0:e.toLowerCase()){case"orchestrator":return(0,c.jsx)(tv,{className:"h-4 w-4"});case"verifier":return(0,c.jsx)(tx,{className:"h-4 w-4"});default:return(0,c.jsx)(tb,{className:"h-4 w-4"})}})(e.component),(0,c.jsx)("span",{className:"text-sm font-medium",children:"orchestrator"===e.component?"오케스트레이터":"verifier"===e.component?"검증기":e.component})]}),(0,c.jsx)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:(0,c.jsxs)(to,{variant:"outline",className:"text-xs",children:["#",e.round,"회차"]})})]})}),(0,c.jsxs)("div",{className:"p-3 space-y-2",children:[e.request&&(0,c.jsxs)("div",{className:e6("p-3 rounded-md border cursor-pointer transition-all duration-200 flex items-center justify-between",s?"bg-primary text-primary-foreground border-primary shadow-sm":"hover:bg-muted/50 border-border hover:border-border/80"),onClick:()=>i(e.request),children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{className:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200 text-xs font-medium flex items-center gap-1",children:[(0,c.jsx)(tm,{className:"h-3 w-3"}),"요청"]})}),(0,c.jsx)("div",{className:"text-xs opacity-60",children:e9(e.request.size)})]}),e.response?(0,c.jsxs)("div",{className:e6("p-3 rounded-md border cursor-pointer transition-all duration-200 flex items-center justify-between",o?"bg-primary text-primary-foreground border-primary shadow-sm":"hover:bg-muted/50 border-border hover:border-border/80"),onClick:()=>i(e.response),children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{className:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 text-xs font-medium flex items-center gap-1",children:[(0,c.jsx)(tg,{className:"h-3 w-3"}),"응답"]})}),(0,c.jsx)("div",{className:"text-xs opacity-60",children:e9(e.response.size)})]}):e.request&&(0,c.jsx)("div",{className:"p-3 rounded-md border border-dashed border-muted-foreground/30 text-center text-muted-foreground",children:(0,c.jsx)("div",{className:"text-xs",children:"응답 대기 중..."})})]})]},e.id)})}),0===t.length&&(0,c.jsxs)("div",{className:"text-center text-muted-foreground p-8",children:[(0,c.jsx)(tp,{className:"h-12 w-12 mx-auto mb-3 opacity-30"}),(0,c.jsx)("h4",{className:"font-medium text-sm mb-1",children:"로그 파일 없음"}),(0,c.jsx)("p",{className:"text-xs opacity-70",children:"AI Agent가 실행되면 로그가 생성됩니다"})]})]})}let tw=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("rounded-lg border bg-card text-card-foreground shadow-sm",n),...i})});tw.displayName="Card";let tk=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("flex flex-col space-y-1.5 p-6",n),...i})});tk.displayName="CardHeader";let tS=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("h3",{ref:t,className:e6("text-2xl font-semibold leading-none tracking-tight",n),...i})});tS.displayName="CardTitle";let tC=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("p",{ref:t,className:e6("text-sm text-muted-foreground",n),...i})});tC.displayName="CardDescription";let tA=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("p-6 pt-0",n),...i})});tA.displayName="CardContent",d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)("div",{ref:t,className:e6("flex items-center p-6 pt-0",n),...i})}).displayName="CardFooter";var tN=d[" useId ".trim().toString()]||(()=>void 0),tM=0;function tO(e){let[t,n]=d.useState(tN());return w(()=>{e||n(e=>null!=e?e:String(tM++))},[e]),e||(t?"radix-".concat(t):"")}d[" useEffectEvent ".trim().toString()],d[" useInsertionEffect ".trim().toString()];var tj=d[" useInsertionEffect ".trim().toString()]||w;function tE(e){let{prop:t,defaultProp:n,onChange:i=()=>{},caller:r}=e,[s,o,l]=function(e){let{defaultProp:t,onChange:n}=e,[i,r]=d.useState(t),s=d.useRef(i),o=d.useRef(n);return tj(()=>{o.current=n},[n]),d.useEffect(()=>{if(s.current!==i){var e;null==(e=o.current)||e.call(o,i),s.current=i}},[i,s]),[i,r,o]}({defaultProp:n,onChange:i}),a=void 0!==t,h=a?t:s;{let e=d.useRef(void 0!==t);d.useEffect(()=>{let t=e.current;if(t!==a){let e=a?"controlled":"uncontrolled";console.warn("".concat(r," is changing from ").concat(t?"controlled":"uncontrolled"," to ").concat(e,". Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component."))}e.current=a},[a,r])}return[h,d.useCallback(e=>{if(a){let i="function"==typeof e?e(t):e;if(i!==t){var n;null==(n=l.current)||n.call(l,i)}}else o(e)},[a,t,o,l])]}Symbol("RADIX:SYNC_STATE");var tT="dismissableLayer.update",tD=d.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),tR=d.forwardRef((e,t)=>{var n,i;let{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:a,onInteractOutside:h,onDismiss:u,...f}=e,p=d.useContext(tD),[g,v]=d.useState(null),x=null!=(i=null==g?void 0:g.ownerDocument)?i:null==(n=globalThis)?void 0:n.document,[,b]=d.useState({}),w=m(t,e=>v(e)),k=Array.from(p.layers),[S]=[...p.layersWithOutsidePointerEventsDisabled].slice(-1),C=k.indexOf(S),N=g?k.indexOf(g):-1,M=p.layersWithOutsidePointerEventsDisabled.size>0,j=N>=C,E=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e),r=d.useRef(!1),s=d.useRef(()=>{});return d.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let t=function(){tL("dismissableLayer.pointerDownOutside",i,r,{discrete:!0})},r={originalEvent:e};"touch"===e.pointerType?(n.removeEventListener("click",s.current),s.current=t,n.addEventListener("click",s.current,{once:!0})):t()}else n.removeEventListener("click",s.current);r.current=!1},t=window.setTimeout(()=>{n.addEventListener("pointerdown",e)},0);return()=>{window.clearTimeout(t),n.removeEventListener("pointerdown",e),n.removeEventListener("click",s.current)}},[n,i]),{onPointerDownCapture:()=>r.current=!0}}(e=>{let t=e.target,n=[...p.branches].some(e=>e.contains(t));j&&!n&&(null==l||l(e),null==h||h(e),e.defaultPrevented||null==u||u())},x),T=function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e),r=d.useRef(!1);return d.useEffect(()=>{let e=e=>{e.target&&!r.current&&tL("dismissableLayer.focusOutside",i,{originalEvent:e},{discrete:!1})};return n.addEventListener("focusin",e),()=>n.removeEventListener("focusin",e)},[n,i]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}(e=>{let t=e.target;![...p.branches].some(e=>e.contains(t))&&(null==a||a(e),null==h||h(e),e.defaultPrevented||null==u||u())},x);return!function(e){var t;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null==(t=globalThis)?void 0:t.document,i=A(e);d.useEffect(()=>{let e=e=>{"Escape"===e.key&&i(e)};return n.addEventListener("keydown",e,{capture:!0}),()=>n.removeEventListener("keydown",e,{capture:!0})},[i,n])}(e=>{N===p.layers.size-1&&(null==o||o(e),!e.defaultPrevented&&u&&(e.preventDefault(),u()))},x),d.useEffect(()=>{if(g)return r&&(0===p.layersWithOutsidePointerEventsDisabled.size&&(s=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),p.layersWithOutsidePointerEventsDisabled.add(g)),p.layers.add(g),tP(),()=>{r&&1===p.layersWithOutsidePointerEventsDisabled.size&&(x.body.style.pointerEvents=s)}},[g,x,r,p]),d.useEffect(()=>()=>{g&&(p.layers.delete(g),p.layersWithOutsidePointerEventsDisabled.delete(g),tP())},[g,p]),d.useEffect(()=>{let e=()=>b({});return document.addEventListener(tT,e),()=>document.removeEventListener(tT,e)},[]),(0,c.jsx)(y.div,{...f,ref:w,style:{pointerEvents:M?j?"auto":"none":void 0,...e.style},onFocusCapture:O(e.onFocusCapture,T.onFocusCapture),onBlurCapture:O(e.onBlurCapture,T.onBlurCapture),onPointerDownCapture:O(e.onPointerDownCapture,E.onPointerDownCapture)})});function tP(){let e=new CustomEvent(tT);document.dispatchEvent(e)}function tL(e,t,n,i){let{discrete:r}=i,s=n.originalEvent.target,o=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});if(t&&s.addEventListener(e,t,{once:!0}),r)s&&u.flushSync(()=>s.dispatchEvent(o));else s.dispatchEvent(o)}tR.displayName="DismissableLayer",d.forwardRef((e,t)=>{let n=d.useContext(tD),i=d.useRef(null),r=m(t,i);return d.useEffect(()=>{let e=i.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,c.jsx)(y.div,{...e,ref:r})}).displayName="DismissableLayerBranch";var tI="focusScope.autoFocusOnMount",tB="focusScope.autoFocusOnUnmount",tz={bubbles:!1,cancelable:!0},tF=d.forwardRef((e,t)=>{let{loop:n=!1,trapped:i=!1,onMountAutoFocus:r,onUnmountAutoFocus:s,...o}=e,[l,a]=d.useState(null),h=A(r),u=A(s),f=d.useRef(null),p=m(t,e=>a(e)),g=d.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;d.useEffect(()=>{if(i){let e=function(e){if(g.paused||!l)return;let t=e.target;l.contains(t)?f.current=t:tV(f.current,{select:!0})},t=function(e){if(g.paused||!l)return;let t=e.relatedTarget;null!==t&&(l.contains(t)||tV(f.current,{select:!0}))};document.addEventListener("focusin",e),document.addEventListener("focusout",t);let n=new MutationObserver(function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&tV(l)});return l&&n.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",e),document.removeEventListener("focusout",t),n.disconnect()}}},[i,l,g.paused]),d.useEffect(()=>{if(l){tH.add(g);let e=document.activeElement;if(!l.contains(e)){let t=new CustomEvent(tI,tz);l.addEventListener(tI,h),l.dispatchEvent(t),t.defaultPrevented||(function(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=document.activeElement;for(let i of e)if(tV(i,{select:t}),document.activeElement!==n)return}(t_(l).filter(e=>"A"!==e.tagName),{select:!0}),document.activeElement===e&&tV(l))}return()=>{l.removeEventListener(tI,h),setTimeout(()=>{let t=new CustomEvent(tB,tz);l.addEventListener(tB,u),l.dispatchEvent(t),t.defaultPrevented||tV(null!=e?e:document.body,{select:!0}),l.removeEventListener(tB,u),tH.remove(g)},0)}}},[l,h,u,g]);let v=d.useCallback(e=>{if(!n&&!i||g.paused)return;let t="Tab"===e.key&&!e.altKey&&!e.ctrlKey&&!e.metaKey,r=document.activeElement;if(t&&r){let t=e.currentTarget,[i,s]=function(e){let t=t_(e);return[tW(t,e),tW(t.reverse(),e)]}(t);i&&s?e.shiftKey||r!==s?e.shiftKey&&r===i&&(e.preventDefault(),n&&tV(s,{select:!0})):(e.preventDefault(),n&&tV(i,{select:!0})):r===t&&e.preventDefault()}},[n,i,g.paused]);return(0,c.jsx)(y.div,{tabIndex:-1,...o,ref:p,onKeyDown:v})});function t_(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t="INPUT"===e.tagName&&"hidden"===e.type;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function tW(e,t){for(let n of e)if(!function(e,t){let{upTo:n}=t;if("hidden"===getComputedStyle(e).visibility)return!0;for(;e&&(void 0===n||e!==n);){if("none"===getComputedStyle(e).display)return!0;e=e.parentElement}return!1}(n,{upTo:t}))return n}function tV(e){let{select:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e&&e.focus){var n;let i=document.activeElement;e.focus({preventScroll:!0}),e!==i&&(n=e)instanceof HTMLInputElement&&"select"in n&&t&&e.select()}}tF.displayName="FocusScope";var tH=function(){let e=[];return{add(t){let n=e[0];t!==n&&(null==n||n.pause()),(e=tq(e,t)).unshift(t)},remove(t){var n;null==(n=(e=tq(e,t))[0])||n.resume()}}}();function tq(e,t){let n=[...e],i=n.indexOf(t);return -1!==i&&n.splice(i,1),n}var tK=d.forwardRef((e,t)=>{var n,i;let{container:r,...s}=e,[o,l]=d.useState(!1);w(()=>l(!0),[]);let a=r||o&&(null==(i=globalThis)||null==(n=i.document)?void 0:n.body);return a?u.default.createPortal((0,c.jsx)(y.div,{...s,ref:t}),a):null});tK.displayName="Portal";var tU=0;function tJ(){let e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var tG=function(){return(tG=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function tY(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);r<i.length;r++)0>t.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n}Object.create;Object.create;var tQ=("function"==typeof SuppressedError&&SuppressedError,"right-scroll-bar-position"),tX="width-before-scroll-bar";function t$(e,t){return"function"==typeof e?e(t):e&&(e.current=t),e}var tZ="undefined"!=typeof window?d.useLayoutEffect:d.useEffect,t0=new WeakMap;function t1(e){return e}var t2=function(e){void 0===e&&(e={});var t,n,i,r=(void 0===t&&(t=t1),n=[],i=!1,{read:function(){if(i)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:null},useMedium:function(e){var r=t(e,i);return n.push(r),function(){n=n.filter(function(e){return e!==r})}},assignSyncMedium:function(e){for(i=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){i=!0;var t=[];if(n.length){var r=n;n=[],r.forEach(e),t=n}var s=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(s)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}});return r.options=tG({async:!0,ssr:!1},e),r}(),t3=function(){},t4=d.forwardRef(function(e,t){var n,i,r,s,o=d.useRef(null),l=d.useState({onScrollCapture:t3,onWheelCapture:t3,onTouchMoveCapture:t3}),a=l[0],h=l[1],c=e.forwardProps,u=e.children,f=e.className,p=e.removeScrollBar,m=e.enabled,g=e.shards,v=e.sideCar,x=e.noRelative,b=e.noIsolation,y=e.inert,w=e.allowPinchZoom,k=e.as,S=e.gapMode,C=tY(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),A=(n=[o,t],i=function(e){return n.forEach(function(t){return t$(t,e)})},(r=(0,d.useState)(function(){return{value:null,callback:i,facade:{get current(){return r.value},set current(value){var e=r.value;e!==value&&(r.value=value,r.callback(value,e))}}}})[0]).callback=i,s=r.facade,tZ(function(){var e=t0.get(s);if(e){var t=new Set(e),i=new Set(n),r=s.current;t.forEach(function(e){i.has(e)||t$(e,null)}),i.forEach(function(e){t.has(e)||t$(e,r)})}t0.set(s,n)},[n]),s),N=tG(tG({},C),a);return d.createElement(d.Fragment,null,m&&d.createElement(v,{sideCar:t2,removeScrollBar:p,shards:g,noRelative:x,noIsolation:b,inert:y,setCallbacks:h,allowPinchZoom:!!w,lockRef:o,gapMode:S}),c?d.cloneElement(d.Children.only(u),tG(tG({},N),{ref:A})):d.createElement(void 0===k?"div":k,tG({},N,{className:f,ref:A}),u))});t4.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},t4.classNames={fullWidth:tX,zeroRight:tQ};var t5=function(e){var t=e.sideCar,n=tY(e,["sideCar"]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var i=t.read();if(!i)throw Error("Sidecar medium not found");return d.createElement(i,tG({},n))};t5.isSideCarExport=!0;var t8=function(){var e=0,t=null;return{add:function(n){if(0==e&&(t=function(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=o||("undefined"!=typeof __webpack_nonce__?__webpack_nonce__:void 0);return t&&e.setAttribute("nonce",t),e}())){var i,r;(i=t).styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n)),r=t,(document.head||document.getElementsByTagName("head")[0]).appendChild(r)}e++},remove:function(){--e||!t||(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},t6=function(){var e=t8();return function(t,n){d.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},t9=function(){var e=t6();return function(t){return e(t.styles,t.dynamic),null}},t7={left:0,top:0,right:0,gap:0},ne=function(e){return parseInt(e||"",10)||0},nt=function(e){var t=window.getComputedStyle(document.body),n=t["padding"===e?"paddingLeft":"marginLeft"],i=t["padding"===e?"paddingTop":"marginTop"],r=t["padding"===e?"paddingRight":"marginRight"];return[ne(n),ne(i),ne(r)]},nn=function(e){if(void 0===e&&(e="margin"),"undefined"==typeof window)return t7;var t=nt(e),n=document.documentElement.clientWidth,i=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,i-n+t[2]-t[0])}},ni=t9(),nr="data-scroll-locked",ns=function(e,t,n,i){var r=e.left,s=e.top,o=e.right,l=e.gap;return void 0===n&&(n="margin"),"\n .".concat("with-scroll-bars-hidden"," {\n overflow: hidden ").concat(i,";\n padding-right: ").concat(l,"px ").concat(i,";\n }\n body[").concat(nr,"] {\n overflow: hidden ").concat(i,";\n overscroll-behavior: contain;\n ").concat([t&&"position: relative ".concat(i,";"),"margin"===n&&"\n padding-left: ".concat(r,"px;\n padding-top: ").concat(s,"px;\n padding-right: ").concat(o,"px;\n margin-left:0;\n margin-top:0;\n margin-right: ").concat(l,"px ").concat(i,";\n "),"padding"===n&&"padding-right: ".concat(l,"px ").concat(i,";")].filter(Boolean).join(""),"\n }\n \n .").concat(tQ," {\n right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(tX," {\n margin-right: ").concat(l,"px ").concat(i,";\n }\n \n .").concat(tQ," .").concat(tQ," {\n right: 0 ").concat(i,";\n }\n \n .").concat(tX," .").concat(tX," {\n margin-right: 0 ").concat(i,";\n }\n \n body[").concat(nr,"] {\n ").concat("--removed-body-scroll-bar-size",": ").concat(l,"px;\n }\n")},no=function(){var e=parseInt(document.body.getAttribute(nr)||"0",10);return isFinite(e)?e:0},nl=function(){d.useEffect(function(){return document.body.setAttribute(nr,(no()+1).toString()),function(){var e=no()-1;e<=0?document.body.removeAttribute(nr):document.body.setAttribute(nr,e.toString())}},[])},na=function(e){var t=e.noRelative,n=e.noImportant,i=e.gapMode,r=void 0===i?"margin":i;nl();var s=d.useMemo(function(){return nn(r)},[r]);return d.createElement(ni,{styles:ns(s,!t,r,n?"":"!important")})},nh=!1;if("undefined"!=typeof window)try{var nc=Object.defineProperty({},"passive",{get:function(){return nh=!0,!0}});window.addEventListener("test",nc,nc),window.removeEventListener("test",nc,nc)}catch(e){nh=!1}var nd=!!nh&&{passive:!1},nu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return"hidden"!==n[t]&&(n.overflowY!==n.overflowX||"TEXTAREA"===e.tagName||"visible"!==n[t])},nf=function(e,t){var n=t.ownerDocument,i=t;do{if("undefined"!=typeof ShadowRoot&&i instanceof ShadowRoot&&(i=i.host),np(e,i)){var r=nm(e,i);if(r[1]>r[2])return!0}i=i.parentNode}while(i&&i!==n.body)return!1},np=function(e,t){return"v"===e?nu(t,"overflowY"):nu(t,"overflowX")},nm=function(e,t){return"v"===e?[t.scrollTop,t.scrollHeight,t.clientHeight]:[t.scrollLeft,t.scrollWidth,t.clientWidth]},ng=function(e,t,n,i,r){var s,o=(s=window.getComputedStyle(t).direction,"h"===e&&"rtl"===s?-1:1),l=o*i,a=n.target,h=t.contains(a),c=!1,d=l>0,u=0,f=0;do{if(!a)break;var p=nm(e,a),m=p[0],g=p[1]-p[2]-o*m;(m||g)&&np(e,a)&&(u+=g,f+=m);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!h&&a!==document.body||h&&(t.contains(a)||t===a))return d&&(r&&1>Math.abs(u)||!r&&l>u)?c=!0:!d&&(r&&1>Math.abs(f)||!r&&-l>f)&&(c=!0),c},nv=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nx=function(e){return[e.deltaX,e.deltaY]},nb=function(e){return e&&"current"in e?e.current:e},ny=0,nw=[];let nk=(i=function(e){var t=d.useRef([]),n=d.useRef([0,0]),i=d.useRef(),r=d.useState(ny++)[0],s=d.useState(t9)[0],o=d.useRef(e);d.useEffect(function(){o.current=e},[e]),d.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(r));var t=(function(e,t,n){if(n||2==arguments.length)for(var i,r=0,s=t.length;r<s;r++)!i&&r in t||(i||(i=Array.prototype.slice.call(t,0,r)),i[r]=t[r]);return e.concat(i||Array.prototype.slice.call(t))})([e.lockRef.current],(e.shards||[]).map(nb),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add("allow-interactivity-".concat(r))}),function(){document.body.classList.remove("block-interactivity-".concat(r)),t.forEach(function(e){return e.classList.remove("allow-interactivity-".concat(r))})}}},[e.inert,e.lockRef.current,e.shards]);var l=d.useCallback(function(e,t){if("touches"in e&&2===e.touches.length||"wheel"===e.type&&e.ctrlKey)return!o.current.allowPinchZoom;var r,s=nv(e),l=n.current,a="deltaX"in e?e.deltaX:l[0]-s[0],h="deltaY"in e?e.deltaY:l[1]-s[1],c=e.target,d=Math.abs(a)>Math.abs(h)?"h":"v";if("touches"in e&&"h"===d&&"range"===c.type)return!1;var u=nf(d,c);if(!u)return!0;if(u?r=d:(r="v"===d?"h":"v",u=nf(d,c)),!u)return!1;if(!i.current&&"changedTouches"in e&&(a||h)&&(i.current=r),!r)return!0;var f=i.current||r;return ng(f,t,e,"h"===f?a:h,!0)},[]),a=d.useCallback(function(e){if(nw.length&&nw[nw.length-1]===s){var n="deltaY"in e?nx(e):nv(e),i=t.current.filter(function(t){var i;return t.name===e.type&&(t.target===e.target||e.target===t.shadowParent)&&(i=t.delta,i[0]===n[0]&&i[1]===n[1])})[0];if(i&&i.should){e.cancelable&&e.preventDefault();return}if(!i){var r=(o.current.shards||[]).map(nb).filter(Boolean).filter(function(t){return t.contains(e.target)});(r.length>0?l(e,r[0]):!o.current.noIsolation)&&e.cancelable&&e.preventDefault()}}},[]),h=d.useCallback(function(e,n,i,r){var s={name:e,delta:n,target:i,should:r,shadowParent:function(e){for(var t=null;null!==e;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}(i)};t.current.push(s),setTimeout(function(){t.current=t.current.filter(function(e){return e!==s})},1)},[]),c=d.useCallback(function(e){n.current=nv(e),i.current=void 0},[]),u=d.useCallback(function(t){h(t.type,nx(t),t.target,l(t,e.lockRef.current))},[]),f=d.useCallback(function(t){h(t.type,nv(t),t.target,l(t,e.lockRef.current))},[]);d.useEffect(function(){return nw.push(s),e.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:f}),document.addEventListener("wheel",a,nd),document.addEventListener("touchmove",a,nd),document.addEventListener("touchstart",c,nd),function(){nw=nw.filter(function(e){return e!==s}),document.removeEventListener("wheel",a,nd),document.removeEventListener("touchmove",a,nd),document.removeEventListener("touchstart",c,nd)}},[]);var p=e.removeScrollBar,m=e.inert;return d.createElement(d.Fragment,null,m?d.createElement(s,{styles:"\n .block-interactivity-".concat(r," {pointer-events: none;}\n .allow-interactivity-").concat(r," {pointer-events: all;}\n")}):null,p?d.createElement(na,{noRelative:e.noRelative,gapMode:e.gapMode}):null)},t2.useMedium(i),t5);var nS=d.forwardRef(function(e,t){return d.createElement(t4,tG({},e,{ref:t,sideCar:nk}))});nS.classNames=t4.classNames;var nC=new WeakMap,nA=new WeakMap,nN={},nM=0,nO=function(e){return e&&(e.host||nO(e.parentNode))},nj=function(e,t,n,i){var r=(Array.isArray(e)?e:[e]).map(function(e){if(t.contains(e))return e;var n=nO(e);return n&&t.contains(n)?n:(console.error("aria-hidden",e,"in not contained inside",t,". Doing nothing"),null)}).filter(function(e){return!!e});nN[n]||(nN[n]=new WeakMap);var s=nN[n],o=[],l=new Set,a=new Set(r),h=function(e){!e||l.has(e)||(l.add(e),h(e.parentNode))};r.forEach(h);var c=function(e){!e||a.has(e)||Array.prototype.forEach.call(e.children,function(e){if(l.has(e))c(e);else try{var t=e.getAttribute(i),r=null!==t&&"false"!==t,a=(nC.get(e)||0)+1,h=(s.get(e)||0)+1;nC.set(e,a),s.set(e,h),o.push(e),1===a&&r&&nA.set(e,!0),1===h&&e.setAttribute(n,"true"),r||e.setAttribute(i,"true")}catch(t){console.error("aria-hidden: cannot operate on ",e,t)}})};return c(t),l.clear(),nM++,function(){o.forEach(function(e){var t=nC.get(e)-1,r=s.get(e)-1;nC.set(e,t),s.set(e,r),t||(nA.has(e)||e.removeAttribute(i),nA.delete(e)),r||e.removeAttribute(n)}),--nM||(nC=new WeakMap,nC=new WeakMap,nA=new WeakMap,nN={})}},nE=function(e,t,n){void 0===n&&(n="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),r=t||("undefined"==typeof document?null:(Array.isArray(e)?e[0]:e).ownerDocument.body);return r?(i.push.apply(i,Array.from(r.querySelectorAll("[aria-live], script"))),nj(i,r,n,"aria-hidden")):function(){return null}},nT="Dialog",[nD,nR]=C(nT),[nP,nL]=nD(nT),nI=e=>{let{__scopeDialog:t,children:n,open:i,defaultOpen:r,onOpenChange:s,modal:o=!0}=e,l=d.useRef(null),a=d.useRef(null),[h,u]=tE({prop:i,defaultProp:null!=r&&r,onChange:s,caller:nT});return(0,c.jsx)(nP,{scope:t,triggerRef:l,contentRef:a,contentId:tO(),titleId:tO(),descriptionId:tO(),open:h,onOpenChange:u,onOpenToggle:d.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};nI.displayName=nT;var nB="DialogTrigger",nz=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(nB,n),s=m(t,r.triggerRef);return(0,c.jsx)(y.button,{type:"button","aria-haspopup":"dialog","aria-expanded":r.open,"aria-controls":r.contentId,"data-state":n4(r.open),...i,ref:s,onClick:O(e.onClick,r.onOpenToggle)})});nz.displayName=nB;var nF="DialogPortal",[n_,nW]=nD(nF,{forceMount:void 0}),nV=e=>{let{__scopeDialog:t,forceMount:n,children:i,container:r}=e,s=nL(nF,t);return(0,c.jsx)(n_,{scope:t,forceMount:n,children:d.Children.map(i,e=>(0,c.jsx)(k,{present:n||s.open,children:(0,c.jsx)(tK,{asChild:!0,container:r,children:e})}))})};nV.displayName=nF;var nH="DialogOverlay",nq=d.forwardRef((e,t)=>{let n=nW(nH,e.__scopeDialog),{forceMount:i=n.forceMount,...r}=e,s=nL(nH,e.__scopeDialog);return s.modal?(0,c.jsx)(k,{present:i||s.open,children:(0,c.jsx)(nU,{...r,ref:t})}):null});nq.displayName=nH;var nK=g("DialogOverlay.RemoveScroll"),nU=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(nH,n);return(0,c.jsx)(nS,{as:nK,allowPinchZoom:!0,shards:[r.contentRef],children:(0,c.jsx)(y.div,{"data-state":n4(r.open),...i,ref:t,style:{pointerEvents:"auto",...i.style}})})}),nJ="DialogContent",nG=d.forwardRef((e,t)=>{let n=nW(nJ,e.__scopeDialog),{forceMount:i=n.forceMount,...r}=e,s=nL(nJ,e.__scopeDialog);return(0,c.jsx)(k,{present:i||s.open,children:s.modal?(0,c.jsx)(nY,{...r,ref:t}):(0,c.jsx)(nQ,{...r,ref:t})})});nG.displayName=nJ;var nY=d.forwardRef((e,t)=>{let n=nL(nJ,e.__scopeDialog),i=d.useRef(null),r=m(t,n.contentRef,i);return d.useEffect(()=>{let e=i.current;if(e)return nE(e)},[]),(0,c.jsx)(nX,{...e,ref:r,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:O(e.onCloseAutoFocus,e=>{var t;e.preventDefault(),null==(t=n.triggerRef.current)||t.focus()}),onPointerDownOutside:O(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=0===t.button&&!0===t.ctrlKey;(2===t.button||n)&&e.preventDefault()}),onFocusOutside:O(e.onFocusOutside,e=>e.preventDefault())})}),nQ=d.forwardRef((e,t)=>{let n=nL(nJ,e.__scopeDialog),i=d.useRef(!1),r=d.useRef(!1);return(0,c.jsx)(nX,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{var s,o;null==(s=e.onCloseAutoFocus)||s.call(e,t),t.defaultPrevented||(i.current||null==(o=n.triggerRef.current)||o.focus(),t.preventDefault()),i.current=!1,r.current=!1},onInteractOutside:t=>{var s,o;null==(s=e.onInteractOutside)||s.call(e,t),t.defaultPrevented||(i.current=!0,"pointerdown"===t.detail.originalEvent.type&&(r.current=!0));let l=t.target;(null==(o=n.triggerRef.current)?void 0:o.contains(l))&&t.preventDefault(),"focusin"===t.detail.originalEvent.type&&r.current&&t.preventDefault()}})}),nX=d.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:i,onOpenAutoFocus:r,onCloseAutoFocus:s,...o}=e,l=nL(nJ,n),a=d.useRef(null),h=m(t,a);return d.useEffect(()=>{var e,t;let n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",null!=(e=n[0])?e:tJ()),document.body.insertAdjacentElement("beforeend",null!=(t=n[1])?t:tJ()),tU++,()=>{1===tU&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),tU--}},[]),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(tF,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:r,onUnmountAutoFocus:s,children:(0,c.jsx)(tR,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":n4(l.open),...o,ref:h,onDismiss:()=>l.onOpenChange(!1)})}),(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n9,{titleId:l.titleId}),(0,c.jsx)(n7,{contentRef:a,descriptionId:l.descriptionId})]})]})}),n$="DialogTitle",nZ=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n$,n);return(0,c.jsx)(y.h2,{id:r.titleId,...i,ref:t})});nZ.displayName=n$;var n0="DialogDescription",n1=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n0,n);return(0,c.jsx)(y.p,{id:r.descriptionId,...i,ref:t})});n1.displayName=n0;var n2="DialogClose",n3=d.forwardRef((e,t)=>{let{__scopeDialog:n,...i}=e,r=nL(n2,n);return(0,c.jsx)(y.button,{type:"button",...i,ref:t,onClick:O(e.onClick,()=>r.onOpenChange(!1))})});function n4(e){return e?"open":"closed"}n3.displayName=n2;var n5="DialogTitleWarning",[n8,n6]=function(e,t){let n=d.createContext(t),i=e=>{let{children:t,...i}=e,r=d.useMemo(()=>i,Object.values(i));return(0,c.jsx)(n.Provider,{value:r,children:t})};return i.displayName=e+"Provider",[i,function(i){let r=d.useContext(n);if(r)return r;if(void 0!==t)return t;throw Error("`".concat(i,"` must be used within `").concat(e,"`"))}]}(n5,{contentName:nJ,titleName:n$,docsSlug:"dialog"}),n9=e=>{let{titleId:t}=e,n=n6(n5),i="`".concat(n.contentName,"` requires a `").concat(n.titleName,"` for the component to be accessible for screen reader users.\n\nIf you want to hide the `").concat(n.titleName,"`, you can wrap it with our VisuallyHidden component.\n\nFor more information, see https://radix-ui.com/primitives/docs/components/").concat(n.docsSlug);return d.useEffect(()=>{t&&(document.getElementById(t)||console.error(i))},[i,t]),null},n7=e=>{let{contentRef:t,descriptionId:n}=e,i=n6("DialogDescriptionWarning"),r="Warning: Missing `Description` or `aria-describedby={undefined}` for {".concat(i.contentName,"}.");return d.useEffect(()=>{var e;let i=null==(e=t.current)?void 0:e.getAttribute("aria-describedby");n&&i&&(document.getElementById(n)||console.warn(r))},[r,t,n]),null};let ie=td("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),it=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(nq,{ref:t,className:e6("fixed inset-0 z-50 bg-background/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",n),...i})});it.displayName=nq.displayName;let ii=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsxs)(nV,{children:[(0,c.jsx)(it,{}),(0,c.jsxs)(nG,{ref:t,className:e6("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",n),...r,children:[i,(0,c.jsxs)(n3,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,c.jsx)(ie,{className:"h-4 w-4"}),(0,c.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});ii.displayName=nG.displayName;let ir=e=>{let{className:t,...n}=e;return(0,c.jsx)("div",{className:e6("flex flex-col space-y-1.5 text-center sm:text-left",t),...n})};ir.displayName="DialogHeader";let is=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(nZ,{ref:t,className:e6("text-lg font-semibold leading-none tracking-tight",n),...i})});is.displayName=nZ.displayName;let io=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(n1,{ref:t,className:e6("text-sm text-muted-foreground",n),...i})});io.displayName=n1.displayName;let il=async(e,t)=>fetch("".concat(window.location.origin).concat(e),t),ia=td("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]),ih=td("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]),ic=td("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),id=td("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]),iu=td("tree-pine",[["path",{d:"m17 14 3 3.3a1 1 0 0 1-.7 1.7H4.7a1 1 0 0 1-.7-1.7L7 14h-.3a1 1 0 0 1-.7-1.7L9 9h-.2A1 1 0 0 1 8 7.3L12 3l4 4.3a1 1 0 0 1-.8 1.7H15l3 3.3a1 1 0 0 1-.7 1.7H17Z",key:"cpyugq"}],["path",{d:"M12 22v-3",key:"kmzjlo"}]]),ip=td("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]),im=td("rectangle-ellipsis",[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"2",key:"9lu3g6"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M17 12h.01",key:"1m0b6t"}],["path",{d:"M7 12h.01",key:"eqddd0"}]]);var ig=e.i(70703),iv=e.i(5766);let ix=td("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]),ib=td("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]),iy=td("pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]),iw=td("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]),ik=td("trash-2",[["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"}]]),iS=td("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"}]]),iC=d.forwardRef((e,t)=>{let{className:n,type:i,...r}=e;return(0,c.jsx)("input",{type:i,className:e6("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",n),ref:t,...r})});function iA(e){let{data:t,onChange:n,className:i,expandedNodes:r,onExpandedNodesChange:s,expandAllByDefault:o=!1}=e,[l,a]=d.useState(new Set),[h,u]=d.useState(null),f=r||l,p=s||a,[m,g]=d.useState(""),v=d.useCallback(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return null==e?[]:Object.entries(e).map(e=>{let[n,i]=e,r=[...t,n],s="string",o=[];return null===i?s="null":Array.isArray(i)?(s="array",o=i.map((e,t)=>{let n=[...r,t.toString()];return{key:t.toString(),value:e,type:"object"==typeof e&&null!==e?Array.isArray(e)?"array":"object":typeof e,path:n,children:"object"==typeof e&&null!==e?v(e,n):void 0}})):"object"==typeof i?(s="object",o=v(i,r)):s=typeof i,{key:n,value:i,type:s,path:r,children:o.length>0?o:void 0}})},[]),x=d.useMemo(()=>v(t),[t,v]);d.useEffect(()=>{if(o&&t&&x.length>0){let e=new Set,t=n=>{n.forEach(n=>{n.children&&n.children.length>0&&(e.add(n.path.join(".")),t(n.children))})};t(x),p(e)}},[o,t,x,p]);let b=e=>{try{let i=JSON.parse(JSON.stringify(t)),r=i;for(let t=0;t<e.length-1;t++)r=r[e[t]];let s=m;try{s=JSON.parse(m)}catch(e){s=m}r[e[e.length-1]]=s,n(i),u(null),g("")}catch(e){console.log("Failed to save edit:",e)}},y=()=>{u(null),g("")},w=function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=e.path.join("."),s=f.has(r),o=h===r,l=e.children&&e.children.length>0;return(0,c.jsxs)("div",{className:"select-none",children:[(0,c.jsxs)("div",{className:e6("flex items-center gap-2 py-1 px-2 rounded hover:bg-muted/50 group","min-h-[32px]"),style:{paddingLeft:"".concat(20*i+8,"px")},children:[l?(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-4 w-4 p-0",onClick:()=>(e=>{let t=new Set(f);t.has(e)?t.delete(e):t.add(e),p(t)})(r),children:s?(0,c.jsx)(ix,{className:"h-3 w-3"}):(0,c.jsx)(ib,{className:"h-3 w-3"})}):(0,c.jsx)("div",{className:"w-4"}),(0,c.jsxs)("span",{className:"font-medium text-sm min-w-0 flex-shrink-0",children:[e.key,":"]}),o?(0,c.jsxs)("div",{className:"flex items-center gap-2 flex-1",children:[(0,c.jsx)(iC,{value:m,onChange:e=>g(e.target.value),className:"h-6 text-xs",onKeyDown:t=>{"Enter"===t.key?b(e.path):"Escape"===t.key&&y()}}),(0,c.jsx)(tr,{size:"sm",className:"h-6 px-2",onClick:()=>b(e.path),children:"✓"}),(0,c.jsx)(tr,{size:"sm",variant:"outline",className:"h-6 px-2",onClick:y,children:"✕"})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("span",{className:e6("text-sm font-mono flex-1",(e=>{switch(e){case"string":return"text-green-600 dark:text-green-400";case"number":return"text-blue-600 dark:text-blue-400";case"boolean":return"text-purple-600 dark:text-purple-400";case"null":return"text-gray-500 dark:text-gray-400";case"object":return"text-orange-600 dark:text-orange-400";case"array":return"text-indigo-600 dark:text-indigo-400";default:return"text-gray-600 dark:text-gray-300"}})(e.type)),children:((e,t)=>{if("string"===t)return'"'.concat(e,'"');if("null"===t)return"null";if("object"===t||"array"===t){let n=Array.isArray(e)?e.length:Object.keys(e||{}).length;return"".concat("array"===t?"[":"{").concat(n," item").concat(1!==n?"s":"").concat("array"===t?"]":"}")}return String(e)})(e.value,e.type)}),(0,c.jsxs)("div",{className:"opacity-0 group-hover:opacity-100 flex items-center gap-1",children:[(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{var t;return t=e.value,void(u(r),g("string"==typeof t?t:JSON.stringify(t)))},title:"Edit",children:(0,c.jsx)(iy,{className:"h-3 w-3"})}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{var t;return t=e.path,void navigator.clipboard.writeText(t.join("."))},title:"Copy path",children:(0,c.jsx)(iS,{className:"h-3 w-3"})}),("object"===e.type||"array"===e.type)&&(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",onClick:()=>{let i="array"===e.type?"new_item":"new_key";((e,i,r)=>{let s=JSON.parse(JSON.stringify(t)),o=s;for(let t of e)o=o[t];Array.isArray(o)?o.push(r):o[i]=r,n(s)})(e.path,i,(e.type,""))},title:"Add item",children:(0,c.jsx)(iw,{className:"h-3 w-3"})}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-destructive hover:text-destructive",onClick:()=>(e=>{let i=JSON.parse(JSON.stringify(t)),r=i;for(let t=0;t<e.length-1;t++)r=r[e[t]];Array.isArray(r)?r.splice(parseInt(e[e.length-1]),1):delete r[e[e.length-1]],n(i)})(e.path),title:"Delete",children:(0,c.jsx)(ik,{className:"h-3 w-3"})})]})]})]}),l&&s&&(0,c.jsx)("div",{children:e.children.map(e=>w(e,i+1))})]},r)};return(0,c.jsxs)("div",{className:e6("border rounded-lg overflow-hidden flex flex-col h-full",i),children:[(0,c.jsx)("div",{className:"bg-muted/30 px-3 py-2 border-b flex-shrink-0",children:(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsx)("span",{className:"text-sm font-medium",children:"JSON Tree Editor"}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>p(new Set),children:"Collapse All"}),(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{let e=new Set,t=n=>{n.forEach(n=>{n.children&&n.children.length>0&&(e.add(n.path.join(".")),t(n.children))})};t(x),p(e)},children:"Expand All"})]})]})}),(0,c.jsx)("div",{className:"flex-1 min-h-0 overflow-auto p-2 pb-8",children:x.map(e=>w(e))})]})}iC.displayName="Input";var iN=d.forwardRef((e,t)=>(0,c.jsx)(y.label,{...e,ref:t,onMouseDown:t=>{var n;t.target.closest("button, input, select, textarea")||(null==(n=e.onMouseDown)||n.call(e,t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));iN.displayName="Label";let iM=tn("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),iO=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(iN,{ref:t,className:e6(iM(),n),...i})});function ij(){return(ij=Object.assign.bind()).apply(null,arguments)}iO.displayName=iN.displayName;let iE=[],iT=[];function iD(e){return e>=127462&&e<=127487}function iR(e,t,n){if(t==e.length)return t;t&&iL(e.charCodeAt(t))&&iI(e.charCodeAt(t-1))&&t--;let i=iP(e,t);for(t+=iB(i);t<e.length;){let r=iP(e,t);if(8205==i||8205==r||n&&function(e){if(e<768)return!1;for(let t=0,n=iE.length;;){let i=t+n>>1;if(e<iE[i])n=i;else{if(!(e>=iT[i]))return!0;t=i+1}if(t==n)return!1}}(r))t+=iB(r),i=r;else if(iD(r)){let n=0,i=t-2;for(;i>=0&&iD(iP(e,i));)n++,i-=2;if(n%2==0)break;t+=2}else break}return t}function iP(e,t){let n=e.charCodeAt(t);if(!iI(n)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return iL(i)?(n-55296<<10)+(i-56320)+65536:n}function iL(e){return e>=56320&&e<57344}function iI(e){return e>=55296&&e<56320}function iB(e){return e<65536?1:2}(()=>{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,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?iT:iE).push(n+=e[t])})();class iz{lineAt(e){if(e<0||e>this.length)throw RangeError("Invalid position ".concat(e," in document of length ").concat(this.length));return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError("Invalid line number ".concat(e," in ").concat(this.lines,"-line document"));return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=iU(this,e,t);let i=[];return this.decompose(0,e,i,2),n.length&&n.decompose(0,n.length,i,3),this.decompose(t,this.length,i,1),i_.from(i,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;[e,t]=iU(this,e,t);let n=[];return this.decompose(e,t,n,0),i_.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),i=new iV(this),r=new iV(e);for(let e=t,s=t;;){if(i.next(e),r.next(e),e=0,i.lineBreak!=r.lineBreak||i.done!=r.done||i.value!=r.value)return!1;if(s+=i.value.length,i.done||s>=n)return!0}}iter(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;return new iV(this,e)}iterRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return new iH(this,e,t)}iterLines(e,t){let n;if(null==e)n=this.iter();else{null==t&&(t=this.lines+1);let i=this.line(e).from;n=this.iterRange(i,Math.max(i,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new iq(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}static of(e){if(0==e.length)throw RangeError("A document must have at least one line");return 1!=e.length||e[0]?e.length<=32?new iF(e):i_.from(iF.split(e,[])):iz.empty}constructor(){}}class iF extends iz{get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,i){for(let r=0;;r++){let s=this.text[r],o=i+s.length;if((t?n:o)>=e)return new iK(i,o,n,s);i=o+1,n++}}decompose(e,t,n,i){var r;let s=e<=0&&t>=this.length?this:new iF((r=this.text,iW(r,[""],e,t)),Math.min(t,this.length)-Math.max(0,e));if(1&i){let e=n.pop(),t=iW(s.text,e.text.slice(),0,s.length);if(t.length<=32)n.push(new iF(t,e.length+s.length));else{let e=t.length>>1;n.push(new iF(t.slice(0,e)),new iF(t.slice(e)))}}else n.push(s)}replace(e,t,n){var i;if(!(n instanceof iF))return super.replace(e,t,n);[e,t]=iU(this,e,t);let r=iW(this.text,iW(n.text,(i=this.text,iW(i,[""],0,e))),t),s=this.length+n.length-(t-e);return r.length<=32?new iF(r,s):i_.from(iF.split(r,[]),s)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n";[e,t]=iU(this,e,t);let i="";for(let r=0,s=0;r<=t&&s<this.text.length;s++){let o=this.text[s],l=r+o.length;r>e&&s&&(i+=n),e<l&&t>r&&(i+=o.slice(Math.max(0,e-r),t-r)),r=l+1}return i}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let n=[],i=-1;for(let r of e)n.push(r),i+=r.length+1,32==n.length&&(t.push(new iF(n,i)),n=[],i=-1);return i>-1&&t.push(new iF(n,i)),t}constructor(e,t=function(e){let t=-1;for(let n of e)t+=n.length+1;return t}(e)){super(),this.text=e,this.length=t}}class i_ extends iz{lineInner(e,t,n,i){for(let r=0;;r++){let s=this.children[r],o=i+s.length,l=n+s.lines-1;if((t?l:o)>=e)return s.lineInner(e,t,n,i);i=o+1,n=l+1}}decompose(e,t,n,i){for(let r=0,s=0;s<=t&&r<this.children.length;r++){let o=this.children[r],l=s+o.length;if(e<=l&&t>=s){let r=i&(s<=e|2*(l>=t));s>=e&&l<=t&&!r?n.push(o):o.decompose(e-s,t-s,n,r)}s=l+1}}replace(e,t,n){if([e,t]=iU(this,e,t),n.lines<this.lines)for(let i=0,r=0;i<this.children.length;i++){let s=this.children[i],o=r+s.length;if(e>=r&&t<=o){let l=s.replace(e-r,t-r,n),a=this.lines-s.lines+l.lines;if(l.lines<a>>4&&l.lines>a>>6){let r=this.children.slice();return r[i]=l,new i_(r,this.length-(t-e)+n.length)}return super.replace(r,o,l)}r=o+1}return super.replace(e,t,n)}sliceString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"\n";[e,t]=iU(this,e,t);let i="";for(let r=0,s=0;r<this.children.length&&s<=t;r++){let o=this.children[r],l=s+o.length;s>e&&r&&(i+=n),e<l&&t>s&&(i+=o.sliceString(e-s,t-s,n)),s=l+1}return i}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof i_))return 0;let n=0,[i,r,s,o]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=t,r+=t){if(i==s||r==o)return n;let l=this.children[i],a=e.children[r];if(l!=a)return n+l.scanIdentical(a,t);n+=l.length+1}}static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.reduce((e,t)=>e+t.length+1,-1),n=0;for(let t of e)n+=t.lines;if(n<32){let n=[];for(let t of e)t.flatten(n);return new iF(n,t)}let i=Math.max(32,n>>5),r=i<<1,s=i>>1,o=[],l=0,a=-1,h=[];function c(){0!=l&&(o.push(1==h.length?h[0]:i_.from(h,a)),a=-1,l=h.length=0)}for(let t of e)!function e(t){let n;if(t.lines>r&&t instanceof i_)for(let n of t.children)e(n);else t.lines>s&&(l>s||!l)?(c(),o.push(t)):t instanceof iF&&l&&(n=h[h.length-1])instanceof iF&&t.lines+n.lines<=32?(l+=t.lines,a+=t.length+1,h[h.length-1]=new iF(n.text.concat(t.text),n.length+1+t.length)):(l+t.lines>i&&c(),l+=t.lines,a+=t.length+1,h.push(t))}(t);return c(),1==o.length?o[0]:new i_(o,t)}constructor(e,t){for(let n of(super(),this.children=e,this.length=t,this.lines=0,e))this.lines+=n.lines}}function iW(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e9;for(let r=0,s=0,o=!0;s<e.length&&r<=i;s++){let l=e[s],a=r+l.length;a>=n&&(a>i&&(l=l.slice(0,i-r)),r<n&&(l=l.slice(n-r)),o?(t[t.length-1]+=l,o=!1):t.push(l)),r=a+1}return t}iz.empty=new iF([""],0);class iV{nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,i=this.nodes[n],r=this.offsets[n],s=r>>1,o=i instanceof iF?i.text.length:i.children.length;if(s==(t>0?o:0)){if(0==n)return this.done=!0,this.value="",this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((1&r)==(t>0?0:1)){if(this.offsets[n]+=t,0==e)return this.lineBreak=!0,this.value="\n",this;e--}else if(i instanceof iF){let r=i.text[s+(t<0?-1:0)];if(this.offsets[n]+=t,r.length>Math.max(0,e))return this.value=0==e?r:t>0?r.slice(e):r.slice(0,r.length-e),this;e-=r.length}else{let r=i.children[s+(t<0?-1:0)];e>r.length?(e-=r.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(r),this.offsets.push(t>0?1:(r instanceof iF?r.text.length:r.children.length)<<1))}}}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[t>0?1:(e instanceof iF?e.text.length:e.children.length)<<1]}}class iH{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:i}=this.cursor.next(e);return this.pos+=(i.length+e)*t,this.value=i.length<=n?i:t<0?i.slice(i.length-n):i.slice(0,n),this.done=!this.value,this}next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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}constructor(e,t,n){this.value="",this.done=!1,this.cursor=new iV(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}}class iq{next(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,{done:t,lineBreak:n,value:i}=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=i,this.afterBreak=!1),this}get lineBreak(){return!1}constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}}"undefined"!=typeof Symbol&&(iz.prototype[Symbol.iterator]=function(){return this.iter()},iV.prototype[Symbol.iterator]=iH.prototype[Symbol.iterator]=iq.prototype[Symbol.iterator]=function(){return this});class iK{get length(){return this.to-this.from}constructor(e,t,n,i){this.from=e,this.to=t,this.number=n,this.text=i}}function iU(e,t,n){return[t=Math.max(0,Math.min(e.length,t)),Math.max(t,Math.min(e.length,n))]}function iJ(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=!(arguments.length>3)||void 0===arguments[3]||arguments[3];return function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=!(arguments.length>3)||void 0===arguments[3]||arguments[3];return(n?iR:function(e,t,n){for(;t>0;){let i=iR(e,t-2,n);if(i<t)return i;t--}return 0})(e,t,i)}(e,t,n,i)}function iG(e,t){let n=e.charCodeAt(t);if(!(n>=55296&&n<56320)||t+1==e.length)return n;let i=e.charCodeAt(t+1);return i>=56320&&i<57344?(n-55296<<10)+(i-56320)+65536:n}function iY(e){return e<=65535?String.fromCharCode(e):String.fromCharCode(((e-=65536)>>10)+55296,(1023&e)+56320)}function iQ(e){return e<65536?1:2}let iX=/\r\n?|\n/;var i$=function(e){return e[e.Simple=0]="Simple",e[e.TrackDel=1]="TrackDel",e[e.TrackBefore=2]="TrackBefore",e[e.TrackAfter=3]="TrackAfter",e}(i$||(i$={}));class iZ{get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return 0==this.sections.length||2==this.sections.length&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,i=0;t<this.sections.length;){let r=this.sections[t++],s=this.sections[t++];s<0?(e(n,i,r),i+=r):i+=s,n+=r}}iterChangedRanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i3(this,e,t)}get invertedDesc(){let e=[];for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];i<0?e.push(n,i):e.push(i,n)}return new iZ(e)}composeDesc(e){return this.empty?e:e.empty?this:i5(this,e)}mapDesc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:i4(this,e,t)}mapPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:i$.Simple,i=0,r=0;for(let s=0;s<this.sections.length;){let o=this.sections[s++],l=this.sections[s++],a=i+o;if(l<0){if(a>e)return r+(e-i);r+=o}else{if(n!=i$.Simple&&a>=e&&(n==i$.TrackDel&&i<e&&a>e||n==i$.TrackBefore&&i<e||n==i$.TrackAfter&&a>e))return null;if(a>e||a==e&&t<0&&!o)return e==i||t<0?r:r+l;r+=l}i=a}if(e>i)throw RangeError("Position ".concat(e," is out of range for changeset of length ").concat(i));return r}touchesRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;for(let n=0,i=0;n<this.sections.length&&i<=t;){let r=this.sections[n++],s=this.sections[n++],o=i+r;if(s>=0&&i<=t&&o>=e)return!(i<e)||!(o>t)||"cover";i=o}return!1}toString(){let e="";for(let t=0;t<this.sections.length;){let n=this.sections[t++],i=this.sections[t++];e+=(e?" ":"")+n+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(e=>"number"!=typeof e))throw RangeError("Invalid JSON representation of ChangeDesc");return new iZ(e)}static create(e){return new iZ(e)}constructor(e){this.sections=e}}class i0 extends iZ{apply(e){if(this.length!=e.length)throw RangeError("Applying change set to a document with the wrong length");return i3(this,(t,n,i,r,s)=>e=e.replace(i,i+(n-t),s),!1),e}mapDesc(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return i4(this,e,t,!0)}invert(e){let t=this.sections.slice(),n=[];for(let i=0,r=0;i<t.length;i+=2){let s=t[i],o=t[i+1];if(o>=0){t[i]=o,t[i+1]=s;let l=i>>1;for(;n.length<l;)n.push(iz.empty);n.push(s?e.slice(r,r+s):iz.empty)}r+=s}return new i0(t,n)}compose(e){return this.empty?e:e.empty?this:i5(this,e,!0)}map(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.empty?this:i4(this,e,t,!0)}iterChanges(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];i3(this,e,t)}get desc(){return iZ.create(this.sections)}filter(e){let t=[],n=[],i=[],r=new i8(this);e:for(let s=0,o=0;;){let l=s==e.length?1e9:e[s++];for(;o<l||o==l&&0==r.len;){if(r.done)break e;let e=Math.min(r.len,l-o);i1(i,e,-1);let s=-1==r.ins?-1:0==r.off?r.ins:0;i1(t,e,s),s>0&&i2(n,t,r.text),r.forward(e),o+=e}let a=e[s++];for(;o<a;){if(r.done)break e;let e=Math.min(r.len,a-o);i1(t,e,-1),i1(i,e,-1==r.ins?-1:0==r.off?r.ins:0),r.forward(e),o+=e}}return{changes:new i0(t,n),filtered:iZ.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],i=this.sections[t+1];i<0?e.push(n):0==i?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(e,t,n){let i=[],r=[],s=0,o=null;function l(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(!e&&!i.length)return;s<t&&i1(i,t-s,-1);let n=new i0(i,r);o=o?o.compose(n.map(o)):n,i=[],r=[],s=0}return!function e(a){if(Array.isArray(a))for(let t of a)e(t);else if(a instanceof i0){if(a.length!=t)throw RangeError("Mismatched change set length (got ".concat(a.length,", expected ").concat(t,")"));l(),o=o?o.compose(a.map(o)):a}else{let{from:e,to:o=e,insert:h}=a;if(e>o||e<0||o>t)throw RangeError("Invalid change range ".concat(e," to ").concat(o," (in doc of length ").concat(t,")"));let c=h?"string"==typeof h?iz.of(h.split(n||iX)):h:iz.empty,d=c.length;if(e==o&&0==d)return;e<s&&l(),e>s&&i1(i,e-s,-1),i1(i,o-e,d),i2(r,i,c),s=o}}(e),l(!o),o}static empty(e){return new i0(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw RangeError("Invalid JSON representation of ChangeSet");let t=[],n=[];for(let i=0;i<e.length;i++){let r=e[i];if("number"==typeof r)t.push(r,-1);else if(!Array.isArray(r)||"number"!=typeof r[0]||r.some((e,t)=>t&&"string"!=typeof e))throw RangeError("Invalid JSON representation of ChangeSet");else if(1==r.length)t.push(r[0],0);else{for(;n.length<i;)n.push(iz.empty);n[i]=iz.of(r.slice(1)),t.push(r[0],n[i].length)}}return new i0(t,n)}static createSet(e,t){return new i0(e,t)}constructor(e,t){super(e),this.inserted=t}}function i1(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(0==t&&n<=0)return;let r=e.length-2;r>=0&&n<=0&&n==e[r+1]?e[r]+=t:r>=0&&0==t&&0==e[r]?e[r+1]+=n:i?(e[r]+=t,e[r+1]+=n):e.push(t,n)}function i2(e,t,n){if(0==n.length)return;let i=t.length-2>>1;if(i<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<i;)e.push(iz.empty);e.push(n)}}function i3(e,t,n){let i=e.inserted;for(let r=0,s=0,o=0;o<e.sections.length;){let l=e.sections[o++],a=e.sections[o++];if(a<0)r+=l,s+=l;else{let h=r,c=s,d=iz.empty;for(;h+=l,c+=a,a&&i&&(d=d.append(i[o-2>>1])),!n&&o!=e.sections.length&&!(e.sections[o+1]<0);)l=e.sections[o++],a=e.sections[o++];t(r,h,s,c,d),r=h,s=c}}}function i4(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=[],s=i?[]:null,o=new i8(e),l=new i8(t);for(let e=-1;;)if(o.done&&l.len||l.done&&o.len)throw Error("Mismatched change set lengths");else if(-1==o.ins&&-1==l.ins){let e=Math.min(o.len,l.len);i1(r,e,-1),o.forward(e),l.forward(e)}else if(l.ins>=0&&(o.ins<0||e==o.i||0==o.off&&(l.len<o.len||l.len==o.len&&!n))){let t=l.len;for(i1(r,l.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(i1(r,0,o.ins),s&&i2(s,r,o.text),e=o.i),o.forward(n),t-=n}l.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(-1==l.ins){let e=Math.min(n,l.len);t+=e,n-=e,l.forward(e)}else if(0==l.ins&&l.len<n)n-=l.len,l.next();else break;i1(r,t,e<o.i?o.ins:0),s&&e<o.i&&i2(s,r,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&l.done)return s?i0.createSet(r,s):iZ.create(r);else throw Error("Mismatched change set lengths")}function i5(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[],r=n?[]:null,s=new i8(e),o=new i8(t);for(let e=!1;;)if(s.done&&o.done)return r?i0.createSet(i,r):iZ.create(i);else if(0==s.ins)i1(i,s.len,0,e),s.next();else if(0!=o.len||o.done)if(s.done||o.done)throw Error("Mismatched change set lengths");else{let t=Math.min(s.len2,o.len),n=i.length;if(-1==s.ins){let n=-1==o.ins?-1:o.off?0:o.ins;i1(i,t,n,e),r&&n&&i2(r,i,o.text)}else -1==o.ins?(i1(i,s.off?0:s.len,t,e),r&&i2(r,i,s.textBit(t))):(i1(i,s.off?0:s.len,o.off?0:o.ins,e),r&&!o.off&&i2(r,i,o.text));e=(s.ins>t||o.ins>=0&&o.len>t)&&(e||i.length>n),s.forward2(t),o.forward(t)}else i1(i,0,o.ins,e),r&&i2(r,i,o.text),o.next()}class i8{next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return -2==this.ins}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?iz.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?iz.empty:t[n].slice(this.off,null==e?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){-1==this.ins?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}constructor(e){this.set=e,this.i=0,this.next()}}class i6{get anchor(){return 32&this.flags?this.to:this.from}get head(){return 32&this.flags?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return 8&this.flags?-1:16&this.flags?1:0}get bidiLevel(){let e=7&this.flags;return 7==e?null:e}get goalColumn(){let e=this.flags>>6;return 0xffffff==e?void 0:e}map(e){let t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return this.empty?t=n=e.mapPos(this.from,i):(t=e.mapPos(this.from,1),n=e.mapPos(this.to,-1)),t==this.from&&n==this.to?this:new i6(t,n,this.flags)}extend(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e<=this.anchor&&t>=this.anchor)return i9.range(e,t);let n=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return i9.range(this.anchor,n)}eq(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.anchor==e.anchor&&this.head==e.head&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||"number"!=typeof e.anchor||"number"!=typeof e.head)throw RangeError("Invalid JSON representation for SelectionRange");return i9.range(e.anchor,e.head)}static create(e,t,n){return new i6(e,t,n)}constructor(e,t,n){this.from=e,this.to=t,this.flags=n}}class i9{map(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1;return e.empty?this:i9.create(this.ranges.map(n=>n.map(e,t)),this.mainIndex)}eq(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return 1==this.ranges.length?this:new i9([this.main],0)}addRange(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return i9.create([e].concat(this.ranges),t?0:this.mainIndex+1)}replaceRange(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.mainIndex,n=this.ranges.slice();return n[t]=e,i9.create(n,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||"number"!=typeof e.main||e.main>=e.ranges.length)throw RangeError("Invalid JSON representation for EditorSelection");return new i9(e.ranges.map(e=>i6.fromJSON(e)),e.main)}static single(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return new i9([i9.range(e,t)],0)}static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(0==e.length)throw RangeError("A selection needs at least one range");for(let n=0,i=0;i<e.length;i++){let r=e[i];if(r.empty?r.from<=n:r.from<n)return i9.normalized(e.slice(),t);n=r.to}return new i9(e,t)}static cursor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return i6.create(e,e,(0==t?0:t<0?8:16)|(null==n?7:Math.min(6,n))|(null!=i?i:0xffffff)<<6)}static range(e,t,n,i){let r=(null!=n?n:0xffffff)<<6|(null==i?7:Math.min(6,i));return t<e?i6.create(t,e,48|r):i6.create(e,t,8*(t>e)|r)}static normalized(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=e[t];e.sort((e,t)=>e.from-t.from),t=e.indexOf(n);for(let n=1;n<e.length;n++){let i=e[n],r=e[n-1];if(i.empty?i.from<=r.to:i.from<r.to){let s=r.from,o=Math.max(i.to,r.to);n<=t&&t--,e.splice(--n,2,i.anchor>i.head?i9.range(o,s):i9.range(s,o))}}return new i9(e,t)}constructor(e,t){this.ranges=e,this.mainIndex=t}}function i7(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError("Selection points outside of document")}let re=0;class rt{get reader(){return this}static define(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rt(e.combine||(e=>e),e.compareInput||((e,t)=>e===t),e.compare||(!e.combine?rn:(e,t)=>e===t),!!e.static,e.enables)}of(e){return new ri([],this,0,e)}compute(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ri(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error("Can't compute a static facet");return new ri(e,this,2,t)}from(e,t){return t||(t=e=>e),this.compute([e],n=>t(n.field(e)))}constructor(e,t,n,i,r){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=i,this.id=re++,this.default=e([]),this.extensions="function"==typeof r?r(this):r}}function rn(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}class ri{dynamicSlot(e){var t;let n=this.value,i=this.facet.compareInput,r=this.id,s=e[r]>>1,o=2==this.type,l=!1,a=!1,h=[];for(let n of this.dependencies)"doc"==n?l=!0:"selection"==n?a=!0:((null!=(t=e[n.id])?t:1)&1)==0&&h.push(e[n.id]);return{create:e=>(e.values[s]=n(e),1),update(e,t){if(l&&t.docChanged||a&&(t.docChanged||t.selection)||rs(e,h)){let t=n(e);if(o?!rr(t,e.values[s],i):!i(t,e.values[s]))return e.values[s]=t,1}return 0},reconfigure:(e,t)=>{let l,a=t.config.address[r];if(null!=a){let r=rg(t,a);if(this.dependencies.every(n=>n instanceof rt?t.facet(n)===e.facet(n):!(n instanceof rl)||t.field(n,!1)==e.field(n,!1))||(o?rr(l=n(e),r,i):i(l=n(e),r)))return e.values[s]=r,0}else l=n(e);return e.values[s]=l,1}}}constructor(e,t,n,i){this.dependencies=e,this.facet=t,this.type=n,this.value=i,this.id=re++}}function rr(e,t,n){if(e.length!=t.length)return!1;for(let i=0;i<e.length;i++)if(!n(e[i],t[i]))return!1;return!0}function rs(e,t){let n=!1;for(let i of t)1&rm(e,i)&&(n=!0);return n}let ro=rt.define({static:!0});class rl{static define(e){let t=new rl(re++,e.create,e.update,e.compare||((e,t)=>e===t),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(ro).find(e=>e.field==this);return((null==t?void 0:t.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 i=e.values[t],r=this.updateF(i,n);return this.compareF(i,r)?0:(e.values[t]=r,1)},reconfigure:(e,n)=>{let i=e.facet(ro),r=n.facet(ro),s;return(s=i.find(e=>e.field==this))&&s!=r.find(e=>e.field==this)?(e.values[t]=s.create(e),1):null!=n.config.address[this.id]?(e.values[t]=n.field(this),0):(e.values[t]=this.create(e),1)}}}init(e){return[this,ro.of({field:this,create:e})]}get extension(){return this}constructor(e,t,n,i,r){this.id=e,this.createF=t,this.updateF=n,this.compareF=i,this.spec=r,this.provides=void 0}}let ra={lowest:4,low:3,default:2,high:1,highest:0};function rh(e){return t=>new rd(t,e)}let rc={highest:rh(ra.highest),high:rh(ra.high),default:rh(ra.default),low:rh(ra.low),lowest:rh(ra.lowest)};class rd{constructor(e,t){this.inner=e,this.prec=t}}class ru{of(e){return new rf(this,e)}reconfigure(e){return ru.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class rf{constructor(e,t){this.compartment=e,this.inner=t}}class rp{staticFacet(e){let t=this.address[e.id];return null==t?e.default:this.staticValues[t>>1]}static resolve(e,t,n){var i,r,s;let o,l,a=[],h=Object.create(null),c=new Map;for(let n of(i=e,r=t,s=c,o=[[],[],[],[],[]],l=new Map,!function e(t,n){let i=l.get(t);if(null!=i){if(i<=n)return;let e=o[i].indexOf(t);e>-1&&o[i].splice(e,1),t instanceof rf&&s.delete(t.compartment)}if(l.set(t,n),Array.isArray(t))for(let i of t)e(i,n);else if(t instanceof rf){if(s.has(t.compartment))throw RangeError("Duplicate use of compartment in extensions");let i=r.get(t.compartment)||t.inner;s.set(t.compartment,i),e(i,n)}else if(t instanceof rd)e(t.inner,t.prec);else if(t instanceof rl)o[n].push(t),t.provides&&e(t.provides,n);else if(t instanceof ri)o[n].push(t),t.facet.extensions&&e(t.facet.extensions,ra.default);else{let i=t.extension;if(!i)throw Error("Unrecognized extension value in extension set (".concat(t,"). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks."));e(i,n)}}(i,ra.default),o.reduce((e,t)=>e.concat(t))))n instanceof rl?a.push(n):(h[n.facet.id]||(h[n.facet.id]=[])).push(n);let d=Object.create(null),u=[],f=[];for(let e of a)d[e.id]=f.length<<1,f.push(t=>e.slot(t));let p=null==n?void 0:n.config.facets;for(let e in h){let t=h[e],i=t[0].facet,r=p&&p[e]||[];if(t.every(e=>0==e.type))if(d[i.id]=u.length<<1|1,rn(r,t))u.push(n.facet(i));else{let e=i.combine(t.map(e=>e.value));u.push(n&&i.compare(e,n.facet(i))?n.facet(i):e)}else{for(let e of t)0==e.type?(d[e.id]=u.length<<1|1,u.push(e.value)):(d[e.id]=f.length<<1,f.push(t=>e.dynamicSlot(t)));d[i.id]=f.length<<1,f.push(e=>(function(e,t,n){let i=n.map(t=>e[t.id]),r=n.map(e=>e.type),s=i.filter(e=>!(1&e)),o=e[t.id]>>1;function l(e){let n=[];for(let t=0;t<i.length;t++){let s=rg(e,i[t]);if(2==r[t])for(let e of s)n.push(e);else n.push(s)}return t.combine(n)}return{create(e){for(let t of i)rm(e,t);return e.values[o]=l(e),1},update(e,n){if(!rs(e,s))return 0;let i=l(e);return t.compare(i,e.values[o])?0:(e.values[o]=i,1)},reconfigure(e,r){let s=rs(e,i),a=r.config.facets[t.id],h=r.facet(t);if(a&&!s&&rn(n,a))return e.values[o]=h,0;let c=l(e);return t.compare(c,h)?(e.values[o]=h,0):(e.values[o]=c,1)}}})(e,i,t))}}return new rp(e,c,f.map(e=>e(d)),d,u,h)}constructor(e,t,n,i,r,s){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=i,this.staticValues=r,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}}function rm(e,t){if(1&t)return 2;let n=t>>1,i=e.status[n];if(4==i)throw Error("Cyclic dependency between fields and/or facets");if(2&i)return i;e.status[n]=4;let r=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|r}function rg(e,t){return 1&t?e.config.staticValues[t>>1]:e.values[t>>1]}let rv=rt.define(),rx=rt.define({combine:e=>e.some(e=>e),static:!0}),rb=rt.define({combine:e=>e.length?e[0]:void 0,static:!0}),ry=rt.define(),rw=rt.define(),rk=rt.define(),rS=rt.define({combine:e=>!!e.length&&e[0]});class rC{static define(){return new rA}constructor(e,t){this.type=e,this.value=t}}class rA{of(e){return new rC(this,e)}}class rN{of(e){return new rM(this,e)}constructor(e){this.map=e}}class rM{map(e){let t=this.type.map(this.value,e);return void 0===t?void 0:t==this.value?this:new rM(this.type,t)}is(e){return this.type==e}static define(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new rN(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let i of e){let e=i.map(t);e&&n.push(e)}return n}constructor(e,t){this.type=e,this.value=t}}rM.reconfigure=rM.define(),rM.appendConfig=rM.define();class rO{static create(e,t,n,i,r,s){return new rO(e,t,n,i,r,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let 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(e){let t=this.annotation(rO.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&"."==t[e.length]))}constructor(e,t,n,i,r,s){this.startState=e,this.changes=t,this.selection=n,this.effects=i,this.annotations=r,this.scrollIntoView=s,this._doc=null,this._state=null,n&&i7(n,t.newLength),r.some(e=>e.type==rO.time)||(this.annotations=r.concat(rO.time.of(Date.now())))}}function rj(e,t,n){var i;let r,s,o;return n?(r=t.changes,s=i0.empty(t.changes.length),o=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),s=e.changes.mapDesc(t.changes,!0),o=e.changes.compose(r)),{changes:o,selection:t.selection?t.selection.map(s):null==(i=e.selection)?void 0:i.map(r),effects:rM.mapEffects(e.effects,r).concat(rM.mapEffects(t.effects,s)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function rE(e,t,n){let i=t.selection,r=rD(t.annotations);return t.userEvent&&(r=r.concat(rO.userEvent.of(t.userEvent))),{changes:t.changes instanceof i0?t.changes:i0.of(t.changes||[],n,e.facet(rb)),selection:i&&(i instanceof i9?i:i9.single(i.anchor,i.head)),effects:rD(t.effects),annotations:r,scrollIntoView:!!t.scrollIntoView}}rO.time=rC.define(),rO.userEvent=rC.define(),rO.addToHistory=rC.define(),rO.remote=rC.define();let rT=[];function rD(e){return null==e?rT:Array.isArray(e)?e:[e]}var rR=function(e){return e[e.Word=0]="Word",e[e.Space=1]="Space",e[e.Other=2]="Other",e}(rR||(rR={}));let rP=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;try{t=RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch(e){}class rL{field(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=this.config.address[e.id];if(null==n){if(t)throw RangeError("Field is not present in this state");return}return rm(this,n),rg(this,n)}update(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function e(t,n,i){let r=rE(t,n.length?n[0]:{},t.doc.length);n.length&&!1===n[0].filter&&(i=!1);for(let e=1;e<n.length;e++){!1===n[e].filter&&(i=!1);let s=!!n[e].sequential;r=rj(r,rE(t,n[e],s?r.changes.newLength:t.doc.length),s)}let s=rO.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return function(e){let t=e.startState,n=t.facet(rk),i=e;for(let r=n.length-1;r>=0;r--){let s=n[r](e);s&&Object.keys(s).length&&(i=rj(i,rE(t,s,e.changes.newLength),!0))}return i==e?e:rO.create(t,e.changes,e.selection,i.effects,i.annotations,i.scrollIntoView)}(i?function(t){let n=t.startState,i=!0;for(let e of n.facet(ry)){let n=e(t);if(!1===n){i=!1;break}Array.isArray(n)&&(i=!0===i?n:function(e,t){let n=[];for(let i=0,r=0;;){let s,o;if(i<e.length&&(r==t.length||t[r]>=e[i]))s=e[i++],o=e[i++];else{if(!(r<t.length))return n;s=t[r++],o=t[r++]}!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}(i,n))}if(!0!==i){let e,r;if(!1===i)r=t.changes.invertedDesc,e=i0.empty(n.doc.length);else{let n=t.changes.filter(i);e=n.changes,r=n.filtered.mapDesc(n.changes).invertedDesc}t=rO.create(n,e,t.selection&&t.selection.map(r),rM.mapEffects(t.effects,r),t.annotations,t.scrollIntoView)}let r=n.facet(rw);for(let i=r.length-1;i>=0;i--){let s=r[i](t);t=s instanceof rO?s:Array.isArray(s)&&1==s.length&&s[0]instanceof rO?s[0]:e(n,rD(s),!1)}return t}(s):s)}(this,t,!0)}applyTransaction(e){let t,n=this.config,{base:i,compartments:r}=n;for(let t of e.effects)t.is(ru.reconfigure)?(n&&(r=new Map,n.compartments.forEach((e,t)=>r.set(t,e)),n=null),r.set(t.value.compartment,t.value.extension)):t.is(rM.reconfigure)?(n=null,i=t.value):t.is(rM.appendConfig)&&(n=null,i=rD(i).concat(t.value));t=n?e.startState.values.slice():new rL(n=rp.resolve(i,r,this),this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values;let s=e.startState.facet(rx)?e.newSelection:e.newSelection.asSingle();new rL(n,e.newDoc,s,t,(t,n)=>n.update(t,e),e)}replaceSelection(e){return"string"==typeof e&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:i9.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),i=this.changes(n.changes),r=[n.range],s=rD(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),l=this.changes(o.changes),a=l.map(i);for(let e=0;e<n;e++)r[e]=r[e].map(a);let h=i.mapDesc(l,!0);r.push(o.range.map(h)),i=i.compose(a),s=rM.mapEffects(s,a).concat(rM.mapEffects(rD(o.effects),h))}return{changes:i,selection:i9.create(r,t.mainIndex),effects:s}}changes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return e instanceof i0?e:i0.of(e,this.doc.length,this.facet(rL.lineSeparator))}toText(e){return iz.of(e.split(this.facet(rL.lineSeparator)||iX))}sliceDoc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.doc.length;return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return null==t?e.default:(rm(this,t),rg(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let i=e[n];i instanceof rl&&null!=this.config.address[i.id]&&(t[n]=i.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(!e||"string"!=typeof e.doc)throw RangeError("Invalid JSON representation for EditorState");let i=[];if(n){for(let t in n)if(Object.prototype.hasOwnProperty.call(e,t)){let r=n[t],s=e[t];i.push(r.init(e=>r.spec.fromJSON(s,e)))}}return rL.create({doc:e.doc,selection:i9.fromJSON(e.selection),extensions:t.extensions?i.concat([t.extensions]):i})}static create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=rp.resolve(e.extensions||[],new Map),n=e.doc instanceof iz?e.doc:iz.of((e.doc||"").split(t.staticFacet(rL.lineSeparator)||iX)),i=e.selection?e.selection instanceof i9?e.selection:i9.single(e.selection.anchor,e.selection.head):i9.single(0);return i7(i,n.length),t.staticFacet(rx)||(i=i.asSingle()),new rL(t,n,i,t.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(rL.tabSize)}get lineBreak(){return this.facet(rL.lineSeparator)||"\n"}get readOnly(){return this.facet(rS)}phrase(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];for(let t of this.facet(rL.phrases))if(Object.prototype.hasOwnProperty.call(t,e)){e=t[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(e,t)=>{if("$"==t)return"$";let i=+(t||1);return!i||i>n.length?e:n[i-1]})),e}languageDataAt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[];for(let r of this.facet(rv))for(let s of r(this,t,n))Object.prototype.hasOwnProperty.call(s,e)&&i.push(s[e]);return i}charCategorizer(e){var n;return n=this.languageDataAt("wordChars",e).join(""),e=>{if(!/\S/.test(e))return rR.Space;if(function(e){if(t)return t.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||rP.test(n)))return!0}return!1}(e))return rR.Word;for(let t=0;t<n.length;t++)if(e.indexOf(n[t])>-1)return rR.Word;return rR.Other}}wordAt(e){let{text:t,from:n,length:i}=this.doc.lineAt(e),r=this.charCategorizer(e),s=e-n,o=e-n;for(;s>0;){let e=iJ(t,s,!1);if(r(t.slice(e,s))!=rR.Word)break;s=e}for(;o<i;){let e=iJ(t,o);if(r(t.slice(o,e))!=rR.Word)break;o=e}return s==o?null:i9.range(s+n,o+n)}constructor(e,t,n,i,r,s){this.config=e,this.doc=t,this.selection=n,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=r,s&&(s._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)rm(this,e<<1);this.computeSlot=null}}function rI(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={};for(let t of e)for(let e of Object.keys(t)){let r=t[e],s=i[e];if(void 0===s)i[e]=r;else if(s===r||void 0===r);else if(Object.hasOwnProperty.call(n,e))i[e]=n[e](s,r);else throw Error("Config merge conflict for field "+e)}for(let e in t)void 0===i[e]&&(i[e]=t[e]);return i}rL.allowMultipleSelections=rx,rL.tabSize=rt.define({combine:e=>e.length?e[0]:4}),rL.lineSeparator=rb,rL.readOnly=rS,rL.phrases=rt.define({compare(e,t){let n=Object.keys(e),i=Object.keys(t);return n.length==i.length&&n.every(n=>e[n]==t[n])}}),rL.languageData=rv,rL.changeFilter=ry,rL.transactionFilter=rw,rL.transactionExtender=rk,ru.reconfigure=rM.define();class rB{eq(e){return this==e}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return rz.create(e,t,this)}}rB.prototype.startSide=rB.prototype.endSide=0,rB.prototype.point=!1,rB.prototype.mapMode=i$.TrackDel;class rz{static create(e,t,n){return new rz(e,t,n)}constructor(e,t,n){this.from=e,this.to=t,this.value=n}}function rF(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}class r_{get length(){return this.to[this.to.length-1]}findIndex(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n?this.to:this.from;for(let s=i,o=r.length;;){if(s==o)return s;let i=s+o>>1,l=r[i]-e||(n?this.value[i].endSide:this.value[i].startSide)-t;if(i==s)return l>=0?s:o;l>=0?o=i:s=i+1}}between(e,t,n,i){for(let r=this.findIndex(t,-1e9,!0),s=this.findIndex(n,1e9,!1,r);r<s;r++)if(!1===i(this.from[r]+e,this.to[r]+e,this.value[r]))return!1}map(e,t){let n=[],i=[],r=[],s=-1,o=-1;for(let l=0;l<this.value.length;l++){let a=this.value[l],h=this.from[l]+e,c=this.to[l]+e,d,u;if(h==c){let e=t.mapPos(h,a.startSide,a.mapMode);if(null==e||(d=u=e,a.startSide!=a.endSide&&(u=t.mapPos(h,a.endSide))<d))continue}else if((d=t.mapPos(h,a.startSide))>(u=t.mapPos(c,a.endSide))||d==u&&a.startSide>0&&a.endSide<=0)continue;0>(u-d||a.endSide-a.startSide)||(s<0&&(s=d),a.point&&(o=Math.max(o,u-d)),n.push(a),i.push(d-s),r.push(u-s))}return{mapped:n.length?new r_(i,r,n,o):null,pos:s}}constructor(e,t,n,i){this.from=e,this.to=t,this.value=n,this.maxPoint=i}}class rW{static create(e,t,n,i){return new rW(e,t,n,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(e){let{add:t=[],sort:n=!1,filterFrom:i=0,filterTo:r=this.length}=e,s=e.filter;if(0==t.length&&!s)return this;if(n&&(t=t.slice().sort(rF)),this.isEmpty)return t.length?rW.of(t):this;let o=new rq(this,null,-1).goto(0),l=0,a=[],h=new rV;for(;o.value||l<t.length;)if(l<t.length&&(o.from-t[l].from||o.startSide-t[l].value.startSide)>=0){let e=t[l++];h.addInner(e.from,e.to,e.value)||a.push(e)}else 1==o.rangeIndex&&o.chunkIndex<this.chunk.length&&(l==t.length||this.chunkEnd(o.chunkIndex)<t[l].from)&&(!s||i>this.chunkEnd(o.chunkIndex)||r<this.chunkPos[o.chunkIndex])&&h.addChunk(this.chunkPos[o.chunkIndex],this.chunk[o.chunkIndex])?o.nextChunk():((!s||i>o.to||r<o.from||s(o.from,o.to,o.value))&&!h.addInner(o.from,o.to,o.value)&&a.push(rz.create(o.from,o.to,o.value)),o.next());return h.finishInner(this.nextLayer.isEmpty&&!a.length?rW.empty:this.nextLayer.update({add:a,filter:s,filterFrom:i,filterTo:r}))}map(e){if(e.empty||this.isEmpty)return this;let t=[],n=[],i=-1;for(let r=0;r<this.chunk.length;r++){let s=this.chunkPos[r],o=this.chunk[r],l=e.touchesRange(s,s+o.length);if(!1===l)i=Math.max(i,o.maxPoint),t.push(o),n.push(e.mapPos(s));else if(!0===l){let{mapped:r,pos:l}=o.map(s,e);r&&(i=Math.max(i,r.maxPoint),t.push(r),n.push(l))}}let r=this.nextLayer.map(e);return 0==t.length?r:new rW(n,t,r||rW.empty,i)}between(e,t,n){if(!this.isEmpty){for(let i=0;i<this.chunk.length;i++){let r=this.chunkPos[i],s=this.chunk[i];if(t>=r&&e<=r+s.length&&!1===s.between(r,e-r,t-r,n))return}this.nextLayer.between(e,t,n)}}iter(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return rK.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return rK.from(e).goto(t)}static compare(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=r),l=rH(s,o,n),a=new rJ(s,l,r),h=new rJ(o,l,r);n.iterGaps((e,t,n)=>rG(a,e,h,t,n,i)),n.empty&&0==n.length&&rG(a,0,h,0,0,i)}static eq(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3?arguments[3]:void 0;null==i&&(i=0x3b9ac9ff);let r=e.filter(e=>!e.isEmpty&&0>t.indexOf(e)),s=t.filter(t=>!t.isEmpty&&0>e.indexOf(t));if(r.length!=s.length)return!1;if(!r.length)return!0;let o=rH(r,s),l=new rJ(r,o,0).goto(n),a=new rJ(s,o,0).goto(n);for(;;){if(l.to!=a.to||!rY(l.active,a.active)||l.point&&(!a.point||!l.point.eq(a.point)))return!1;if(l.to>i)return!0;l.next(),a.next()}}static spans(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:-1,s=new rJ(e,null,r).goto(t),o=t,l=s.openStart;for(;;){let e=Math.min(s.to,n);if(s.point){let n=s.activeForPoint(s.to),r=s.pointFrom<t?n.length+1:s.point.startSide<0?n.length:Math.min(n.length,l);i.point(o,e,s.point,n,r,s.pointRank),l=Math.min(s.openEnd(e),n.length)}else e>o&&(i.span(o,e,s.active,l),l=s.openEnd(e));if(s.to>n)return l+(s.point&&s.to>n?1:0);o=s.to,s.next()}}static of(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new rV;for(let i of e instanceof rz?[e]:t?function(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let i=e[n];if(rF(t,i)>0)return e.slice().sort(rF);t=i}return e}(e):e)n.add(i.from,i.to,i.value);return n.finish()}static join(e){if(!e.length)return rW.empty;let t=e[e.length-1];for(let n=e.length-2;n>=0;n--)for(let i=e[n];i!=rW.empty;i=i.nextLayer)t=new rW(i.chunkPos,i.chunk,t,Math.max(i.maxPoint,t.maxPoint));return t}constructor(e,t,n,i){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=i}}rW.empty=new rW([],[],null,-1),rW.empty.nextLayer=rW.empty;class rV{finishChunk(e){this.chunks.push(new r_(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=[])}add(e,t,n){this.addInner(e,t,n)||(this.nextLayer||(this.nextLayer=new rV)).add(e,t,n)}addInner(e,t,n){let i=e-this.lastTo||n.startSide-this.last.endSide;if(i<=0&&0>(e-this.lastFrom||n.startSide-this.last.startSide))throw Error("Ranges must be added sorted by `from` position and `startSide`");return!(i<0)&&(250==this.from.length&&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(0>(e-this.lastTo||t.value[0].startSide-this.last.endSide))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(rW.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),0==this.chunks.length)return e;let t=rW.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}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}}function rH(e,t,n){let i=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&i.set(t.chunk[e],t.chunkPos[e]);let r=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let s=i.get(e.chunk[t]);null==s||(n?n.mapPos(s):s)!=e.chunkPos[t]||(null==n?void 0:n.touchesRange(s,s+e.chunk[t].length))||r.add(e.chunk[t])}return r}class rq{get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let i=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<i)&&this.setRangeIndex(i)}this.next()}forward(e,t){0>(this.to-e||this.endSide-t)&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}constructor(e,t,n,i=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=i}}class rK{static from(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,i=[];for(let r=0;r<e.length;r++)for(let s=e[r];!s.isEmpty;s=s.nextLayer)s.maxPoint>=n&&i.push(new rq(s,t,n,r));return 1==i.length?i[0]:new rK(i)}get startSide(){return this.value?this.value.startSide:0}goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-1e9;for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)rU(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--)rU(this.heap,e);0>(this.to-e||this.value.endSide-t)&&this.next()}next(){if(0==this.heap.length)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(),rU(this.heap,0)}}constructor(e){this.heap=e}}function rU(e,t){for(let n=e[t];;){let i=(t<<1)+1;if(i>=e.length)break;let r=e[i];if(i+1<e.length&&r.compare(e[i+1])>=0&&(r=e[i+1],i++),0>n.compare(r))break;e[i]=n,e[t]=r,t=i}}class rJ{goto(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:-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&&0>(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t);)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){rQ(this.active,e),rQ(this.activeTo,e),rQ(this.activeRank,e),this.minActive=r$(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:i,rank:r}=this.cursor;for(;t<this.activeRank.length&&(r-this.activeRank[t]||i-this.activeTo[t])>0;)t++;rX(this.active,t,n),rX(this.activeTo,t,i),rX(this.activeRank,t,r),e&&rX(e,t,this.cursor.from),this.minActive=r$(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let i=this.minActive;if(i>-1&&0>(this.activeTo[i]-this.cursor.from||this.active[i].endSide-this.cursor.startSide)){if(this.activeTo[i]>e){this.to=this.activeTo[i],this.endSide=this.active[i].endSide;break}this.removeActive(i),n&&rQ(n,i)}else if(this.cursor.value)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)if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}else this.addActive(n),this.cursor.next()}else{this.to=this.endSide=1e9;break}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[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}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=rK.from(e,t,n)}}function rG(e,t,n,i,r,s){e.goto(t),n.goto(i);let o=i+r,l=i,a=i-t;for(;;){let t=e.to+a-n.to,i=t||e.endSide-n.endSide,r=i<0?e.to+a:n.to,h=Math.min(r,o);if(e.point||n.point?e.point&&n.point&&(e.point==n.point||e.point.eq(n.point))&&rY(e.activeForPoint(e.to),n.activeForPoint(n.to))||s.comparePoint(l,h,e.point,n.point):h>l&&!rY(e.active,n.active)&&s.compareRange(l,h,e.active,n.active),r>o)break;(t||e.openEnd!=n.openEnd)&&s.boundChange&&s.boundChange(r),l=r,i<=0&&e.next(),i>=0&&n.next()}}function rY(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!e[n].eq(t[n]))return!1;return!0}function rQ(e,t){for(let n=t,i=e.length-1;n<i;n++)e[n]=e[n+1];e.pop()}function rX(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function r$(e,t){let n=-1,i=1e9;for(let r=0;r<t.length;r++)0>(t[r]-i||e[r].endSide-e[n].endSide)&&(n=r,i=t[r]);return n}function rZ(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length,i=0;for(let r=0;r<n&&r<e.length;)9==e.charCodeAt(r)?(i+=t-i%t,r++):(i++,r=iJ(e,r));return i}function r0(e,t,n,i){for(let i=0,r=0;;){if(r>=t)return i;if(i==e.length)break;r+=9==e.charCodeAt(i)?n-r%n:1,i=iJ(e,i)}return!0===i?-1:e.length}let r1="undefined"==typeof Symbol?"__ͼ":Symbol.for("ͼ"),r2="undefined"==typeof Symbol?"__styleSet"+Math.floor(1e8*Math.random()):Symbol("styleSet"),r3="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{};class r4{getRules(){return this.rules.join("\n")}static newName(){let e=r3[r1]||1;return r3[r1]=e+1,"ͼ"+e.toString(36)}static mount(e,t,n){let i=e[r2],r=n&&n.nonce;i?r&&i.setNonce(r):i=new r8(e,r),i.mount(Array.isArray(t)?t:[t],e)}constructor(e,t){this.rules=[];let{finish:n}=t||{};function i(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}for(let t in e)!function e(t,r,s,o){let l=[],a=/^@(\w+)\b/.exec(t[0]),h=a&&"keyframes"==a[1];if(a&&null==r)return s.push(t[0]+";");for(let n in r){let o=r[n];if(/&/.test(n))e(n.split(/,\s*/).map(e=>t.map(t=>e.replace(/&/,t))).reduce((e,t)=>e.concat(t)),o,s);else if(o&&"object"==typeof o){if(!a)throw RangeError("The value of a property ("+n+") should be a primitive value.");e(i(n),o,l,h)}else null!=o&&l.push(n.replace(/_.*/,"").replace(/[A-Z]/g,e=>"-"+e.toLowerCase())+": "+o+";")}(l.length||h)&&s.push((n&&!a&&!o?t.map(n):t).join(", ")+" {"+l.join(" ")+"}")}(i(t),e[t],this.rules)}}let r5=new Map;class r8{mount(e,t){let n=this.sheet,i=0,r=0;for(let t=0;t<e.length;t++){let s=e[t],o=this.modules.indexOf(s);if(o<r&&o>-1&&(this.modules.splice(o,1),r--,o=-1),-1==o){if(this.modules.splice(r++,0,s),n)for(let e=0;e<s.rules.length;e++)n.insertRule(s.rules[e],i++)}else{for(;r<o;)i+=this.modules[r++].rules.length;i+=s.rules.length,r++}}if(n)0>t.adoptedStyleSheets.indexOf(this.sheet)&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{let e="";for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+"\n";this.styleTag.textContent=e;let n=t.head||t;this.styleTag.parentNode!=n&&n.insertBefore(this.styleTag,n.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}constructor(e,t){let n=e.ownerDocument||e,i=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let t=r5.get(n);if(t)return e[r2]=t;this.sheet=new i.CSSStyleSheet,r5.set(n,this)}else this.styleTag=n.createElement("style"),t&&this.styleTag.setAttribute("nonce",t);this.modules=[],e[r2]=this}}for(var r6={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},r9={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},r7="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),se="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),st=0;st<10;st++)r6[48+st]=r6[96+st]=String(st);for(var st=1;st<=24;st++)r6[st+111]="F"+st;for(var st=65;st<=90;st++)r6[st]=String.fromCharCode(st+32),r9[st]=String.fromCharCode(st);for(var sn in r6)r9.hasOwnProperty(sn)||(r9[sn]=r6[sn]);function si(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var r=n[i];"string"==typeof r?e.setAttribute(i,r):null!=r&&(e[i]=r)}t++}for(;t<arguments.length;t++)!function e(t,n){if("string"==typeof n)t.appendChild(document.createTextNode(n));else if(null==n);else if(null!=n.nodeType)t.appendChild(n);else if(Array.isArray(n))for(var i=0;i<n.length;i++)e(t,n[i]);else throw RangeError("Unsupported child node: "+n)}(e,arguments[t]);return e}function sr(e){return(11==e.nodeType?e.getSelection?e:e.ownerDocument:e).getSelection()}function ss(e,t){return!!t&&(e==t||e.contains(1!=t.nodeType?t.parentNode:t))}function so(e,t){if(!t.anchorNode)return!1;try{return ss(e,t.anchorNode)}catch(e){return!1}}function sl(e){return 3==e.nodeType?sx(e,0,e.nodeValue.length).getClientRects():1==e.nodeType?e.getClientRects():[]}function sa(e,t,n,i){return!!n&&(sd(e,t,n,i,-1)||sd(e,t,n,i,1))}function sh(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t}function sc(e){return 1==e.nodeType&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function sd(e,t,n,i,r){for(;;){if(e==n&&t==i)return!0;if(t==(r<0?0:su(e))){if("DIV"==e.nodeName)return!1;let n=e.parentNode;if(!n||1!=n.nodeType)return!1;t=sh(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType||1==(e=e.childNodes[t+(r<0?-1:0)]).nodeType&&"false"==e.contentEditable)return!1;t=r<0?su(e):0}}}function su(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function sf(e,t){let n=t?e.left:e.right;return{left:n,right:n,top:e.top,bottom:e.bottom}}function sp(e,t){let n=t.width/e.offsetWidth,i=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||1>Math.abs(t.width-e.offsetWidth))&&(n=1),(i>.995&&i<1.005||!isFinite(i)||1>Math.abs(t.height-e.offsetHeight))&&(i=1),{scaleX:n,scaleY:i}}class sm{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?su(t):0),n,Math.min(e.focusOffset,n?su(n):0))}set(e,t,n,i){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=i}constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}}let sg=null;function sv(e){if(e.setActive)return e.setActive();if(sg)return e.focus(sg);let t=[];for(let n=e;n&&(t.push(n,n.scrollTop,n.scrollLeft),n!=n.ownerDocument);n=n.parentNode);if(e.focus(null==sg?{get preventScroll(){return sg={preventScroll:!0},!0}}:void 0),!sg){sg=!1;for(let e=0;e<t.length;){let n=t[e++],i=t[e++],r=t[e++];n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}}}function sx(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,r=n||(n=document.createRange());return r.setEnd(e,i),r.setStart(e,t),r}function sb(e,t,n,i){let r={key:t,code:t,keyCode:n,which:n,cancelable:!0};i&&({altKey:r.altKey,ctrlKey:r.ctrlKey,shiftKey:r.shiftKey,metaKey:r.metaKey}=i);let s=new KeyboardEvent("keydown",r);s.synthetic=!0,e.dispatchEvent(s);let o=new KeyboardEvent("keyup",r);return o.synthetic=!0,e.dispatchEvent(o),s.defaultPrevented||o.defaultPrevented}function sy(e){for(;e.attributes.length;)e.removeAttributeNode(e.attributes[0])}function sw(e){return e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function sk(e,t){for(let n=e,i=t;;)if(3==n.nodeType&&i>0)return{node:n,offset:i};else if(1==n.nodeType&&i>0){if("false"==n.contentEditable)return null;i=su(n=n.childNodes[i-1])}else{if(!n.parentNode||sc(n))return null;i=sh(n),n=n.parentNode}}function sS(e,t){for(let n=e,i=t;;)if(3==n.nodeType&&i<n.nodeValue.length)return{node:n,offset:i};else if(1==n.nodeType&&i<n.childNodes.length){if("false"==n.contentEditable)return null;n=n.childNodes[i],i=0}else{if(!n.parentNode||sc(n))return null;i=sh(n)+1,n=n.parentNode}}class sC{static before(e,t){return new sC(e.parentNode,sh(e),t)}static after(e,t){return new sC(e.parentNode,sh(e)+1,t)}constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}}let sA=[];class sN{get overrideDOMText(){return null}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e){let t=this.posAtStart;for(let n of this.children){if(n==e)return t;t+=n.length+n.breakAfter}throw RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}sync(e,t){if(2&this.flags){let n=this.dom,i=null,r;for(let s of this.children){if(7&s.flags){if(!s.dom&&(r=i?i.nextSibling:n.firstChild)){let e=sN.get(r);(!e||!e.parent&&e.canReuseDOM(s))&&s.reuseDOM(r)}s.sync(e,t),s.flags&=-8}if(r=i?i.nextSibling:n.firstChild,t&&!t.written&&t.node==n&&r!=s.dom&&(t.written=!0),s.dom.parentNode==n)for(;r&&r!=s.dom;)r=sM(r);else n.insertBefore(s.dom,r);i=s.dom}for((r=i?i.nextSibling:n.firstChild)&&t&&t.node==n&&(t.written=!0);r;)r=sM(r)}else if(1&this.flags)for(let n of this.children)7&n.flags&&(n.sync(e,t),n.flags&=-8)}reuseDOM(e){}localPosFromDOM(e,t){let n;if(e==this.dom)n=this.dom.childNodes[t];else{let i=0==su(e)?0:0==t?-1:1;for(;;){let t=e.parentNode;if(t==this.dom)break;0==i&&t.firstChild!=t.lastChild&&(i=e==t.firstChild?-1:1),e=t}n=i<0?e:e.nextSibling}if(n==this.dom.firstChild)return 0;for(;n&&!sN.get(n);)n=n.nextSibling;if(!n)return this.length;for(let e=0,t=0;;e++){let i=this.children[e];if(i.dom==n)return t;t+=i.length+i.breakAfter}}domBoundsAround(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=-1,r=-1,s=-1,o=-1;for(let l=0,a=n,h=n;l<this.children.length;l++){let n=this.children[l],c=a+n.length;if(a<e&&c>t)return n.domBoundsAround(e,t,a);if(c>=e&&-1==i&&(i=l,r=a),a>t&&n.dom.parentNode==this.dom){s=l,o=h;break}h=c,a=c+n.breakAfter}return{from:r,to:o<0?n+this.length:o,startDOM:(i?this.children[i-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:s<this.children.length&&s>=0?this.children[s].dom:null}}markDirty(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.flags|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.flags|=2),1&t.flags)return;t.flags|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,7&this.flags&&this.markParentsDirty(!0))}setDOM(e){this.dom!=e&&(this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this)}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:sA;this.markDirty();for(let i=e;i<t;i++){let e=this.children[i];e.parent==this&&0>n.indexOf(e)&&e.destroy()}n.length<250?this.children.splice(e,t-e,...n):this.children=[].concat(this.children.slice(0,e),n,this.children.slice(t));for(let e=0;e<n.length;e++)n[e].setParent(this)}ignoreMutation(e){return!1}ignoreEvent(e){return!1}childCursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length;return new sO(this.children,e,this.children.length)}childPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return this.childCursor().findPos(e,t)}toString(){let e=this.constructor.name.replace("View","");return e+(this.children.length?"("+this.children.join()+")":this.length?"["+("Text"==e?this.text:this.length)+"]":"")+(this.breakAfter?"#":"")}static get(e){return e.cmView}get isEditable(){return!0}get isWidget(){return!1}get isHidden(){return!1}merge(e,t,n,i,r,s){return!1}become(e){return!1}canReuseDOM(e){return e.constructor==this.constructor&&!((this.flags|e.flags)&8)}getSide(){return 0}destroy(){for(let e of this.children)e.parent==this&&e.destroy();this.parent=null}constructor(){this.parent=null,this.dom=null,this.flags=2}}function sM(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}sN.prototype.breakAfter=0;class sO{findPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;for(;;){if(e>this.pos||e==this.pos&&(t>0||0==this.i||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let n=this.children[--this.i];this.pos-=n.length+n.breakAfter}}constructor(e,t,n){this.children=e,this.pos=t,this.i=n,this.off=0}}function sj(e,t,n,i,r,s,o,l,a){let{children:h}=e,c=h.length?h[t]:null,d=s.length?s[s.length-1]:null,u=d?d.breakAfter:o;if(!(t==i&&c&&!o&&!u&&s.length<2&&c.merge(n,r,s.length?d:null,0==n,l,a))){if(i<h.length){let e=h[i];e&&(r<e.length||e.breakAfter&&(null==d?void 0:d.breakAfter))?(t==i&&(e=e.split(r),r=0),!u&&d&&e.merge(0,r,d,!0,0,a)?s[s.length-1]=e:((r||e.children.length&&!e.children[0].length)&&e.merge(0,r,null,!1,0,a),s.push(e))):(null==e?void 0:e.breakAfter)&&(d?d.breakAfter=1:o=1),i++}for(c&&(c.breakAfter=o,n>0&&(!o&&s.length&&c.merge(n,c.length,s[0],!1,l,0)?c.breakAfter=s.shift().breakAfter:(n<c.length||c.children.length&&0==c.children[c.children.length-1].length)&&c.merge(n,c.length,null,!1,l,0),t++));t<i&&s.length;)if(h[i-1].become(s[s.length-1]))i--,s.pop(),a=s.length?0:l;else if(h[t].become(s[0]))t++,s.shift(),l=s.length?0:a;else break;!s.length&&t&&i<h.length&&!h[t-1].breakAfter&&h[i].merge(0,0,h[t-1],!1,l,a)&&t--,(t<i||s.length)&&e.replaceChildren(t,i,s)}}function sE(e,t,n,i,r,s){let o=e.childCursor(),{i:l,off:a}=o.findPos(n,1),{i:h,off:c}=o.findPos(t,-1),d=t-n;for(let e of i)d+=e.length;e.length+=d,sj(e,h,c,l,a,i,0,r,s)}let sT="undefined"!=typeof navigator?navigator:{userAgent:"",vendor:"",platform:""},sD="undefined"!=typeof document?document:{documentElement:{style:{}}},sR=/Edge\/(\d+)/.exec(sT.userAgent),sP=/MSIE \d/.test(sT.userAgent),sL=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(sT.userAgent),sI=!!(sP||sL||sR),sB=!sI&&/gecko\/(\d+)/i.test(sT.userAgent),sz=!sI&&/Chrome\/(\d+)/.exec(sT.userAgent),sF="webkitFontSmoothing"in sD.documentElement.style,s_=!sI&&/Apple Computer/.test(sT.vendor),sW=s_&&(/Mobile\/\w+/.test(sT.userAgent)||sT.maxTouchPoints>2);var sV={mac:sW||/Mac/.test(sT.platform),windows:/Win/.test(sT.platform),linux:/Linux|X11/.test(sT.platform),ie:sI,ie_version:sP?sD.documentMode||6:sL?+sL[1]:sR?+sR[1]:0,gecko:sB,gecko_version:sB?+(/Firefox\/(\d+)/.exec(sT.userAgent)||[0,0])[1]:0,chrome:!!sz,chrome_version:sz?+sz[1]:0,ios:sW,android:/Android\b/.test(sT.userAgent),webkit:sF,safari:s_,webkit_version:sF?+(/\bAppleWebKit\/(\d+)/.exec(sT.userAgent)||[0,0])[1]:0,tabSize:null!=sD.documentElement.style.tabSize?"tab-size":"-moz-tab-size"};class sH extends sN{get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){3==e.nodeType&&this.createDOM(e)}merge(e,t,n){return!(8&this.flags)&&(!n||n instanceof sH&&!(this.length-(t-e)+n.length>256)&&!(8&n.flags))&&(this.text=this.text.slice(0,e)+(n?n.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new sH(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t.flags|=8&this.flags,t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new sC(this.dom,e)}domBoundsAround(e,t,n){return{from:n,to:n+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return function(e,t,n){let i=e.nodeValue.length;t>i&&(t=i);let r=t,s=t,o=0;0==t&&n<0||t==i&&n>=0?!(sV.chrome||sV.gecko)&&(t?(r--,o=1):s<i&&(s++,o=-1)):n<0?r--:s<i&&s++;let l=sx(e,r,s).getClientRects();if(!l.length)return null;let a=l[(o?o<0:n>=0)?0:l.length-1];return sV.safari&&!o&&0==a.width&&(a=Array.prototype.find.call(l,e=>e.width)||a),o?sf(a,o<0):a||null}(this.dom,e,t)}constructor(e){super(),this.text=e}}class sq extends sN{setAttrs(e){if(sy(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}canReuseDOM(e){return super.canReuseDOM(e)&&!((this.flags|e.flags)&8)}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.flags|=6)}sync(e,t){this.dom?4&this.flags&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,n,i,r,s){return(!n||!!(n instanceof sq&&n.mark.eq(this.mark))&&(!e||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(sE(this,e,t,n?n.children.slice():[],r-1,s-1),this.markDirty(),!0)}split(e){let t=[],n=0,i=-1,r=0;for(let s of this.children){let o=n+s.length;o>e&&t.push(n<e?s.split(e-n):s),i<0&&n>=e&&(i=r),n=o,r++}let s=this.length-e;return this.length=e,i>-1&&(this.children.length=i,this.markDirty()),new sq(this.mark,t,s)}domAtPos(e){return sJ(this,e)}coordsAt(e,t){return sG(this,e,t)}constructor(e,t=[],n=0){for(let i of(super(),this.mark=e,this.children=t,this.length=n,t))i.setParent(this)}}class sK extends sN{static create(e,t,n){return new sK(e,t,n)}split(e){let t=sK.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}getSide(){return this.side}merge(e,t,n,i,r,s){return(!n||n instanceof sK&&!!this.widget.compare(n.widget)&&(!(e>0)||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}become(e){return e instanceof sK&&e.side==this.side&&this.widget.constructor==e.widget.constructor&&(this.widget.compare(e.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get overrideDOMText(){if(0==this.length)return iz.empty;let e=this;for(;e.parent;)e=e.parent;let{view:t}=e,n=t&&t.state.doc,i=this.posAtStart;return n?n.slice(i,i+this.length):iz.empty}domAtPos(e){return(this.length?0==e:this.side>0)?sC.before(this.dom):sC.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);if(n)return n;let i=this.dom.getClientRects(),r=null;if(!i.length)return null;let s=this.side?this.side<0:e>0;for(let t=s?i.length-1:0;r=i[t],e>0?0!=t:t!=i.length-1&&!(r.top<r.bottom);t+=s?-1:1);return sf(r,!s)}get isEditable(){return!1}get isWidget(){return!0}get isHidden(){return this.widget.isHidden}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.side=n,this.prevWidget=null}}class sU extends sN{get length(){return 0}merge(){return!1}become(e){return e instanceof sU&&e.side==this.side}split(){return new sU(this.side)}sync(){if(!this.dom){let e=document.createElement("img");e.className="cm-widgetBuffer",e.setAttribute("aria-hidden","true"),this.setDOM(e)}}getSide(){return this.side}domAtPos(e){return this.side>0?sC.before(this.dom):sC.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return iz.empty}get isHidden(){return!0}constructor(e){super(),this.side=e}}function sJ(e,t){let n=e.dom,{children:i}=e,r=0;for(let e=0;r<i.length;r++){let s=i[r],o=e+s.length;if(!(o==e&&0>=s.getSide())){if(t>e&&t<o&&s.dom.parentNode==n)return s.domAtPos(t-e);if(t<=e)break;e=o}}for(let e=r;e>0;e--){let t=i[e-1];if(t.dom.parentNode==n)return t.domAtPos(t.length)}for(let e=r;e<i.length;e++){let t=i[e];if(t.dom.parentNode==n)return t.domAtPos(0)}return new sC(n,0)}function sG(e,t,n){let i=null,r=-1,s=null,o=-1;!function e(t,l){for(let a=0,h=0;a<t.children.length&&h<=l;a++){let c=t.children[a],d=h+c.length;d>=l&&(c.children.length?e(c,l-h):(!s||s.isHidden&&(n>0||function(e,t){let n=e.coordsAt(0,1),i=t.coordsAt(0,1);return n&&i&&i.top<n.bottom}(s,c)))&&(d>l||h==d&&c.getSide()>0)?(s=c,o=l-h):(h<l||h==d&&0>c.getSide()&&!c.isHidden)&&(i=c,r=l-h)),h=d}}(e,t);let l=(n<0?i:s)||i||s;return l?l.coordsAt(Math.max(0,l==i?r:o),n):function(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=sl(t);return n[n.length-1]||null}(e)}function sY(e,t){for(let n in e)"class"==n&&t.class?t.class+=" "+e.class:"style"==n&&t.style?t.style+=";"+e.style:t[n]=e[n];return t}sH.prototype.children=sK.prototype.children=sU.prototype.children=sA;let sQ=Object.create(null);function sX(e,t,n){if(e==t)return!0;e||(e=sQ),t||(t=sQ);let i=Object.keys(e),r=Object.keys(t);if(i.length-(n&&i.indexOf(n)>-1?1:0)!=r.length-(n&&r.indexOf(n)>-1?1:0))return!1;for(let s of i)if(s!=n&&(-1==r.indexOf(s)||e[s]!==t[s]))return!1;return!0}function s$(e,t,n){let i=!1;if(t)for(let r in t)n&&r in n||(i=!0,"style"==r?e.style.cssText="":e.removeAttribute(r));if(n)for(let r in n)t&&t[r]==n[r]||(i=!0,"style"==r?e.style.cssText=n[r]:e.setAttribute(r,n[r]));return i}class sZ{eq(e){return!1}updateDOM(e,t){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return -1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}}var s0=function(e){return e[e.Text=0]="Text",e[e.WidgetBefore=1]="WidgetBefore",e[e.WidgetAfter=2]="WidgetAfter",e[e.WidgetRange=3]="WidgetRange",e}(s0||(s0={}));class s1 extends rB{get heightRelevant(){return!1}static mark(e){return new s2(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new s4(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,i;if(e.isBlockGap)n=-5e8,i=4e8;else{let{start:r,end:s}=s5(e,t);n=(r?t?-3e8:-1:5e8)-1,i=(s?t?2e8:1:-6e8)+1}return new s4(e,n,i,t,e.widget||null,!0)}static line(e){return new s3(e)}static set(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return rW.of(e,t)}hasHeight(){return!!this.widget&&this.widget.estimatedHeight>-1}constructor(e,t,n,i){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=i}}s1.none=rW.empty;class s2 extends s1{eq(e){var t,n;return this==e||e instanceof s2&&this.tagName==e.tagName&&(this.class||(null==(t=this.attrs)?void 0:t.class))==(e.class||(null==(n=e.attrs)?void 0:n.class))&&sX(this.attrs,e.attrs,"class")}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(e>=t)throw RangeError("Mark decorations may not be empty");return super.range(e,t)}constructor(e){let{start:t,end:n}=s5(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}}s2.prototype.point=!1;class s3 extends s1{eq(e){return e instanceof s3&&this.spec.class==e.spec.class&&sX(this.spec.attributes,e.spec.attributes)}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;if(t!=e)throw RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}constructor(e){super(-2e8,-2e8,null,e)}}s3.prototype.mapMode=i$.TrackBefore,s3.prototype.point=!0;class s4 extends s1{get type(){return this.startSide!=this.endSide?s0.WidgetRange:this.startSide<=0?s0.WidgetBefore:s0.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){var t,n;return e instanceof s4&&(t=this.widget,t==(n=e.widget)||!!(t&&n&&t.compare(n)))&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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)}constructor(e,t,n,i,r,s){super(t,n,r,e),this.block=i,this.isReplace=s,this.mapMode=i?t<=0?i$.TrackBefore:i$.TrackAfter:i$.TrackDel}}function s5(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{inclusiveStart:n,inclusiveEnd:i}=e;return null==n&&(n=e.inclusive),null==i&&(i=e.inclusive),{start:null!=n?n:t,end:null!=i?i:t}}function s8(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=n.length-1;r>=0&&n[r]+i>=e?n[r]=Math.max(n[r],t):n.push(e,t)}s4.prototype.point=!0;class s6 extends sN{merge(e,t,n,i,r,s){if(n){if(!(n instanceof s6))return!1;this.dom||n.transferDOM(this)}return i&&this.setDeco(n?n.attrs:null),sE(this,e,t,n?n.children.slice():[],r,s),!0}split(e){let t=new s6;if(t.breakAfter=this.breakAfter,0==this.length)return t;let{i:n,off:i}=this.childPos(e);i&&(t.append(this.children[n].split(i),0),this.children[n].merge(i,this.children[n].length,null,!1,0,0),n++);for(let e=n;e<this.children.length;e++)t.append(this.children[e],0);for(;n>0&&0==this.children[n-1].length;)this.children[--n].destroy();return this.children.length=n,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=void 0===this.prevAttrs?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){sX(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){!function e(t,n,i){let r,{children:s}=t;i>0&&n instanceof sq&&s.length&&(r=s[s.length-1])instanceof sq&&r.mark.eq(n.mark)?e(r,n.children[0],i-1):(s.push(n),n.setParent(t)),t.length+=n.length}(this,e,t)}addLineDeco(e){let t=e.spec.attributes,n=e.spec.class;t&&(this.attrs=sY(t,this.attrs||{})),n&&(this.attrs=sY({class:n},this.attrs||{}))}domAtPos(e){return sJ(this,e)}reuseDOM(e){"DIV"==e.nodeName&&(this.setDOM(e),this.flags|=6)}sync(e,t){var n;this.dom?4&this.flags&&(sy(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),void 0!==this.prevAttrs&&(s$(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let i=this.dom.lastChild;for(;i&&sN.get(i)instanceof sq;)i=i.lastChild;if(!i||!this.length||"BR"!=i.nodeName&&(null==(n=sN.get(i))?void 0:n.isEditable)==!1&&(!sV.ios||!this.children.some(e=>e instanceof sH))){let e=document.createElement("BR");e.cmIgnore=!0,this.dom.appendChild(e)}}measureTextSize(){if(0==this.children.length||this.length>20)return null;let e=0,t;for(let n of this.children){if(!(n instanceof sH)||/[^ -~]/.test(n.text))return null;let i=sl(n.dom);if(1!=i.length)return null;e+=i[0].width,t=i[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let n=sG(this,e,t);if(!this.children.length&&n&&this.parent){let{heightOracle:e}=this.parent.view.viewState,t=n.bottom-n.top;if(2>Math.abs(t-e.lineHeight)&&e.textHeight<t){let i=(t-e.textHeight)/2;return{top:n.top+i,bottom:n.bottom-i,left:n.left,right:n.left}}}return n}become(e){return e instanceof s6&&0==this.children.length&&0==e.children.length&&sX(this.attrs,e.attrs)&&this.breakAfter==e.breakAfter}covers(){return!0}static find(e,t){for(let n=0,i=0;n<e.children.length;n++){let r=e.children[n],s=i+r.length;if(s>=t){if(r instanceof s6)return r;if(s>t)break}i=s+r.breakAfter}return null}constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}}class s9 extends sN{merge(e,t,n,i,r,s){return(!n||n instanceof s9&&!!this.widget.compare(n.widget)&&(!(e>0)||!(r<=0))&&(!(t<this.length)||!(s<=0)))&&(this.length=e+(n?n.length:0)+(this.length-t),!0)}domAtPos(e){return 0==e?sC.before(this.dom):sC.after(this.dom,e==this.length)}split(e){let t=this.length-e;this.length=e;let n=new s9(this.widget,t,this.deco);return n.breakAfter=this.breakAfter,n}get children(){return sA}sync(e){this.dom&&this.widget.updateDOM(this.dom,e)||(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.widget.editable||(this.dom.contentEditable="false"))}get overrideDOMText(){return this.parent?this.parent.view.state.doc.slice(this.posAtStart,this.posAtEnd):iz.empty}domBoundsAround(){return null}become(e){return e instanceof s9&&e.widget.constructor==this.widget.constructor&&(e.widget.compare(this.widget)||this.markDirty(!0),this.dom&&!this.prevWidget&&(this.prevWidget=this.widget),this.widget=e.widget,this.length=e.length,this.deco=e.deco,this.breakAfter=e.breakAfter,!0)}ignoreMutation(){return!0}ignoreEvent(e){return this.widget.ignoreEvent(e)}get isEditable(){return!1}get isWidget(){return!0}coordsAt(e,t){let n=this.widget.coordsAt(this.dom,e,t);return n||(this.widget instanceof s7?null:sf(this.dom.getBoundingClientRect(),this.length?0==e:t<=0))}destroy(){super.destroy(),this.dom&&this.widget.destroy(this.dom)}covers(e){let{startSide:t,endSide:n}=this.deco;return t!=n&&(e<0?t<0:n>0)}constructor(e,t,n){super(),this.widget=e,this.length=t,this.deco=n,this.breakAfter=0,this.prevWidget=null}}class s7 extends sZ{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}constructor(e){super(),this.height=e}}class oe{posCovered(){if(0==this.content.length)return!this.breakAtStart&&this.doc.lineAt(this.pos).from!=this.pos;let e=this.content[this.content.length-1];return!(e.breakAfter||e instanceof s9&&e.deco.endSide<0)}getLine(){return this.curLine||(this.content.push(this.curLine=new s6),this.atCursorPos=!0),this.curLine}flushBuffer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.bufferMarks;this.pendingBuffer&&(this.curLine.append(ot(new sU(-1),e),e.length),this.pendingBuffer=0)}addBlockWidget(e){this.flushBuffer(),this.curLine=null,this.content.push(e)}finish(e){this.pendingBuffer&&e<=this.bufferMarks.length?this.flushBuffer():this.pendingBuffer=0,this.posCovered()||e&&this.content.length&&this.content[this.content.length-1]instanceof s9||this.getLine()}buildText(e,t,n){for(;e>0;){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:i}=this.cursor.next(this.skip);if(this.skip=0,i)throw Error("Ran out of text content when drawing inline views");if(n){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}this.text=t,this.textOff=0}let i=Math.min(this.text.length-this.textOff,e),r=Math.min(i,512);this.flushBuffer(t.slice(t.length-n)),this.getLine().append(ot(new sH(this.text.slice(this.textOff,this.textOff+r)),t),n),this.atCursorPos=!0,this.textOff+=r,e-=r,n=i<=r?0:t.length}}span(e,t,n,i){this.buildText(t-e,n,i),this.pos=t,this.openStart<0&&(this.openStart=i)}point(e,t,n,i,r,s){if(this.disallowBlockEffectsFor[s]&&n instanceof s4){if(n.block)throw RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw RangeError("Decorations that replace line breaks may not be specified via plugins")}let o=t-e;if(n instanceof s4)if(n.block)n.startSide>0&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new s9(n.widget||on.block,o,n));else{let s=sK.create(n.widget||on.inline,o,o?0:n.startSide),l=this.atCursorPos&&!s.isEditable&&r<=i.length&&(e<t||n.startSide>0),a=!s.isEditable&&(e<t||r>i.length||n.startSide<=0),h=this.getLine();2!=this.pendingBuffer||l||s.isEditable||(this.pendingBuffer=0),this.flushBuffer(i),l&&(h.append(ot(new sU(1),i),r),r=i.length+Math.max(0,r-i.length)),h.append(ot(s,i),r),this.atCursorPos=a,this.pendingBuffer=a?e<t||r>i.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=i.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(n);o&&(this.textOff+o<=this.text.length?this.textOff+=o:(this.skip+=o-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,n,i,r){let s=new oe(e,t,n,r);return s.openEnd=rW.spans(i,t,n,s),s.openStart<0&&(s.openStart=s.openEnd),s.finish(s.openEnd),s}constructor(e,t,n,i){this.doc=e,this.pos=t,this.end=n,this.disallowBlockEffectsFor=i,this.content=[],this.curLine=null,this.breakAtStart=0,this.pendingBuffer=0,this.bufferMarks=[],this.atCursorPos=!0,this.openStart=-1,this.openEnd=-1,this.text="",this.textOff=0,this.cursor=e.iter(),this.skip=t}}function ot(e,t){for(let n of t)e=new sq(n,[e],e.length);return e}class on extends sZ{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}constructor(e){super(),this.tag=e}}on.inline=new on("span"),on.block=new on("div");var oi=function(e){return e[e.LTR=0]="LTR",e[e.RTL=1]="RTL",e}(oi||(oi={}));let or=oi.LTR,os=oi.RTL;function oo(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}let ol=oo("88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008"),oa=oo("4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333"),oh=Object.create(null),oc=[];for(let e of["()","[]","{}"]){let t=e.charCodeAt(0),n=e.charCodeAt(1);oh[t]=n,oh[n]=-t}function od(e){return e<=247?ol[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?oa[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}let ou=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/;class of{get dir(){return this.level%2?os:or}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,i){let r=-1;for(let s=0;s<e.length;s++){let o=e[s];if(o.from<=t&&o.to>=t){if(o.level==n)return s;(r<0||(0!=i?i<0?o.from<t:o.to>t:e[r].level>o.level))&&(r=s)}}if(r<0)throw RangeError("Index out of range");return r}constructor(e,t,n){this.from=e,this.to=t,this.level=n}}let op=[];function om(e){return[new of(0,e,0)]}let og="",ov=rt.define(),ox=rt.define(),ob=rt.define(),oy=rt.define(),ow=rt.define(),ok=rt.define(),oS=rt.define(),oC=rt.define(),oA=rt.define(),oN=rt.define({combine:e=>e.some(e=>e)}),oM=rt.define({combine:e=>e.some(e=>e)}),oO=rt.define();class oj{map(e){return e.empty?this:new oj(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new oj(i9.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}constructor(e,t="nearest",n="nearest",i=5,r=5,s=!1){this.range=e,this.y=t,this.x=n,this.yMargin=i,this.xMargin=r,this.isSnapshot=s}}let oE=rM.define({map:(e,t)=>e.map(t)}),oT=rM.define();function oD(e,t,n){let i=e.facet(oy);i.length?i[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+":",t):console.error(t))}let oR=rt.define({combine:e=>!e.length||e[0]}),oP=0,oL=rt.define({combine:e=>e.filter((t,n)=>{for(let i=0;i<n;i++)if(e[i].plugin==t.plugin)return!1;return!0})});class oI{of(e){return this.baseExtensions.concat(oL.of({plugin:this,arg:e}))}static define(e,t){let{eventHandlers:n,eventObservers:i,provide:r,decorations:s}=t||{};return new oI(oP++,e,n,i,e=>{let t=[];return s&&t.push(o_.of(t=>{let n=t.plugin(e);return n?s(n):s1.none})),r&&t.push(r(e)),t})}static fromClass(e,t){return oI.define((t,n)=>new e(t,n),t)}constructor(e,t,n,i,r){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=i,this.baseExtensions=r(this),this.extension=this.baseExtensions.concat(oL.of({plugin:this,arg:void 0}))}}class oB{get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(oD(e.state,t,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch(e){}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){oD(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(null==(t=this.value)?void 0:t.destroy)try{this.value.destroy()}catch(t){oD(e.state,t,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}}let oz=rt.define(),oF=rt.define(),o_=rt.define(),oW=rt.define(),oV=rt.define(),oH=rt.define();function oq(e,t){let n=e.state.facet(oH);if(!n.length)return n;let i=n.map(t=>t instanceof Function?t(e):t),r=[];return rW.spans(i,t.from,t.to,{point(){},span(e,n,i,s){let o=e-t.from,l=n-t.from,a=r;for(let e=i.length-1;e>=0;e--,s--){let n=i[e].spec.bidiIsolate,r;if(null==n&&(n=function(e,t,n){for(let i=t;i<n;i++){let t=od(e.charCodeAt(i));if(1==t)break;if(2==t||4==t)return os}return or}(t.text,o,l)),s>0&&a.length&&(r=a[a.length-1]).to==o&&r.direction==n)r.to=l,a=r.inner;else{let e={from:o,to:l,direction:n,inner:[]};a.push(e),a=e.inner}}}}),r}let oK=rt.define();function oU(e){let t=0,n=0,i=0,r=0;for(let s of e.state.facet(oK)){let o=s(e);o&&(null!=o.left&&(t=Math.max(t,o.left)),null!=o.right&&(n=Math.max(n,o.right)),null!=o.top&&(i=Math.max(i,o.top)),null!=o.bottom&&(r=Math.max(r,o.bottom)))}return{left:t,right:n,top:i,bottom:r}}let oJ=rt.define();class oG{join(e){return new oG(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let i=e[t-1];if(!(i.fromA>n.toA)){if(i.toA<n.fromA)break;n=n.join(i),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(e,t){if(0==t.length)return e;let n=[];for(let i=0,r=0,s=0,o=0;;i++){let l=i==e.length?null:e[i],a=s-o,h=l?l.fromB:1e9;for(;r<t.length&&t[r]<h;){let e=t[r],i=t[r+1],s=Math.max(o,e),l=Math.min(h,i);if(s<=l&&new oG(s+a,l+a,s,l).addToSet(n),i>h)break;r+=2}if(!l)return n;new oG(l.fromA,l.toA,l.fromB,l.toB).addToSet(n),s=l.toA,o=l.toB}}constructor(e,t,n,i){this.fromA=e,this.toA=t,this.fromB=n,this.toB=i}}class oY{static create(e,t,n){return new oY(e,t,n)}get viewportChanged(){return(4&this.flags)>0}get viewportMoved(){return(8&this.flags)>0}get heightChanged(){return(2&this.flags)>0}get geometryChanged(){return this.docChanged||(18&this.flags)>0}get focusChanged(){return(1&this.flags)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return 0==this.flags&&0==this.transactions.length}constructor(e,t,n){for(let i of(this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=i0.empty(this.startState.doc.length),n))this.changes=this.changes.compose(i.changes);let i=[];this.changes.iterChangedRanges((e,t,n,r)=>i.push(new oG(e,t,n,r))),this.changedRanges=i}}class oQ extends sN{get length(){return this.view.state.doc.length}update(e){var t,n,i,r,s,o;let l,a,h=e.changedRanges;this.minWidth>0&&h.length&&(h.every(e=>{let{fromA:t,toA:n}=e;return n<this.minWidthFrom||t>this.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 c=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&((null==(t=this.domChanged)?void 0:t.newSel)?c=this.domChanged.newSel.head:(n=e.changes,i=this.hasComposition,l=!1,i&&n.iterChangedRanges((e,t)=>{e<i.to&&t>i.from&&(l=!0)}),l||e.selectionSet||(c=e.state.selection.main.head)));let d=c>-1?function(e,t,n){let i=oX(e,n);if(!i)return null;let{node:r,from:s,to:o}=i,l=r.nodeValue;if(/[\n\r]/.test(l)||e.state.doc.sliceString(i.from,i.to)!=l)return null;let a=t.invertedDesc,h=new oG(a.mapPos(s),a.mapPos(o),s,o),c=[];for(let t=r.parentNode;;t=t.parentNode){let n=sN.get(t);if(n instanceof sq)c.push({node:t,deco:n.mark});else{if(n instanceof s6||"DIV"==t.nodeName&&t.parentNode==e.contentDOM)return{range:h,text:r,marks:c,line:t};if(t==e.contentDOM)return null;c.push({node:t,deco:new s2({inclusive:!0,attributes:function(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let i=e.attributes[n];t[i.name]=i.value}return t}(t),tagName:t.tagName.toLowerCase()})})}}}(this.view,e.changes,c):null;if(this.domChanged=null,this.hasComposition){this.markedForComposition.clear();let{from:t,to:n}=this.hasComposition;h=new oG(t,n,e.changes.mapPos(t,-1),e.changes.mapPos(n,1)).addToSet(h.slice())}this.hasComposition=d?{from:d.range.fromB,to:d.range.toB}:null,(sV.ie||sV.chrome)&&!d&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let u=(r=this.decorations,s=this.updateDeco(),o=e.changes,a=new o$,rW.compare(r,s,o,a),a.changes);return h=oG.extendWithRanges(h,u),(!!(7&this.flags)||0!=h.length)&&(this.updateInner(h,e.startState.doc.length,d),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t,n){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t,n);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let e=sV.chrome||sV.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,e),this.flags&=-8,e&&(e.written||i.selectionRange.focusNode!=e.node)&&(this.forceSelection=!0),this.dom.style.height=""}),this.markedForComposition.forEach(e=>e.flags&=-9);let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.children)e instanceof s9&&e.widget instanceof s7&&r.push(e.dom);i.updateGaps(r)}updateChildren(e,t,n){let i=n?n.range.addToSet(e.slice()):e,r=this.childCursor(t);for(let e=i.length-1;;e--){let t=e>=0?i[e]:null;if(!t)break;let{fromA:s,toA:o,fromB:l,toB:a}=t,h,c,d,u;if(n&&n.range.fromB<a&&n.range.toB>l){let e=oe.build(this.view.state.doc,l,n.range.fromB,this.decorations,this.dynamicDecorationMap),t=oe.build(this.view.state.doc,n.range.toB,a,this.decorations,this.dynamicDecorationMap);c=e.breakAtStart,d=e.openStart,u=t.openEnd;let i=this.compositionView(n);t.breakAtStart?i.breakAfter=1:t.content.length&&i.merge(i.length,i.length,t.content[0],!1,t.openStart,0)&&(i.breakAfter=t.content[0].breakAfter,t.content.shift()),e.content.length&&i.merge(0,0,e.content[e.content.length-1],!0,0,e.openEnd)&&e.content.pop(),h=e.content.concat(i).concat(t.content)}else({content:h,breakAtStart:c,openStart:d,openEnd:u}=oe.build(this.view.state.doc,l,a,this.decorations,this.dynamicDecorationMap));let{i:f,off:p}=r.findPos(o,1),{i:m,off:g}=r.findPos(s,-1);sj(this,m,g,f,p,h,c,d,u)}n&&this.fixCompositionDOM(n)}updateEditContextFormatting(e){for(let t of(this.editContextFormatting=this.editContextFormatting.map(e.changes),e.transactions))for(let e of t.effects)e.is(oT)&&(this.editContextFormatting=e.value)}compositionView(e){let t=new sH(e.text.nodeValue);for(let{deco:n}of(t.flags|=8,e.marks))t=new sq(n,[t],t.length);let n=new s6;return n.append(t,0),n}fixCompositionDOM(e){let t=(e,t)=>{t.flags|=8|!!t.children.some(e=>7&e.flags),this.markedForComposition.add(t);let n=sN.get(e);n&&n!=t&&(n.dom=null),t.setDOM(e)},n=this.childPos(e.range.fromB,1),i=this.children[n.i];t(e.line,i);for(let r=e.marks.length-1;r>=-1;r--)n=i.childPos(n.off,1),i=i.children[n.i],t(r>=0?e.marks[r].node:e.text,i)}updateSelection(){var e;let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(t||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,r=i==this.dom,s=!r&&!(this.view.state.facet(oR)||this.dom.tabIndex>-1)&&so(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(r||n||s))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.moveToLine(this.domAtPos(l.anchor)),h=l.empty?a:this.moveToLine(this.domAtPos(l.head));if(sV.gecko&&l.empty&&!this.hasComposition&&1==(e=a).node.nodeType&&e.node.firstChild&&(0==e.offset||"false"==e.node.childNodes[e.offset-1].contentEditable)&&(e.offset==e.node.childNodes.length||"false"==e.node.childNodes[e.offset].contentEditable)){let e=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(e,a.node.childNodes[a.offset]||null)),a=h=new sC(e,0),o=!0}let c=this.view.observer.selectionRange;!o&&c.focusNode&&(sa(a.node,a.offset,c.anchorNode,c.anchorOffset)&&sa(h.node,h.offset,c.focusNode,c.focusOffset)||this.suppressWidgetCursorChange(c,l))||(this.view.observer.ignore(()=>{sV.android&&sV.chrome&&this.dom.contains(c.focusNode)&&function(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(1==n.nodeType&&"false"==n.contentEditable)return!0;return!1}(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let e=sr(this.view.root);if(e)if(l.empty){if(sV.gecko){var t,n;let e=(t=a.node,n=a.offset,1!=t.nodeType?0:(n&&"false"==t.childNodes[n-1].contentEditable?1:0)|2*(n<t.childNodes.length&&"false"==t.childNodes[n].contentEditable));if(e&&3!=e){let t=(1==e?sk:sS)(a.node,a.offset);t&&(a=new sC(t.node,t.offset))}}e.collapse(a.node,a.offset),null!=l.bidiLevel&&void 0!==e.caretBidiLevel&&(e.caretBidiLevel=l.bidiLevel)}else if(e.extend){e.collapse(a.node,a.offset);try{e.extend(h.node,h.offset)}catch(e){}}else{let t=document.createRange();l.anchor>l.head&&([a,h]=[h,a]),t.setEnd(h.node,h.offset),t.setStart(a.node,a.offset),e.removeAllRanges(),e.addRange(t)}s&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,h)),this.impreciseAnchor=a.precise?null:new sC(c.anchorNode,c.anchorOffset),this.impreciseHead=h.precise?null:new sC(c.focusNode,c.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&sa(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=sr(e.root),{anchorNode:i,anchorOffset:r}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let s=s6.find(this,t.head);if(!s)return;let o=s.posAtStart;if(t.head==o||t.head==o+s.length)return;let l=this.coordsAt(t.head,-1),a=this.coordsAt(t.head,1);if(!l||!a||l.bottom>a.top)return;let h=this.domAtPos(t.head+t.assoc);n.collapse(h.node,h.offset),n.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let c=e.observer.selectionRange;e.docView.posFromDOM(c.anchorNode,c.anchorOffset)!=t.from&&n.collapse(i,r)}moveToLine(e){let t=this.dom,n;if(e.node!=t)return e;for(let i=e.offset;!n&&i<t.childNodes.length;i++){let e=sN.get(t.childNodes[i]);e instanceof s6&&(n=e.domAtPos(0))}for(let i=e.offset-1;!n&&i>=0;i--){let e=sN.get(t.childNodes[i]);e instanceof s6&&(n=e.domAtPos(e.length))}return n?new sC(n.node,n.offset,!0):e}nearest(e){for(let t=e;t;){let e=sN.get(t);if(e&&e.rootView==this)return e;t=t.parentNode}return null}posFromDOM(e,t){let n=this.nearest(e);if(!n)throw RangeError("Trying to find position for a DOM position outside of the document");return n.localPosFromDOM(e,t)+n.posAtStart}domAtPos(e){let{i:t,off:n}=this.childCursor().findPos(e,-1);for(;t<this.children.length-1;){let e=this.children[t];if(n<e.length||e instanceof s6)break;t++,n=0}return this.children[t].domAtPos(n)}coordsAt(e,t){let n=null,i=0;for(let r=this.length,s=this.children.length-1;s>=0;s--){let o=this.children[s],l=r-o.breakAfter,a=l-o.length;if(l<e)break;if(a<=e&&(a<e||o.covers(-1))&&(l>e||o.covers(1))&&(!n||o instanceof s6&&!(n instanceof s6&&t>=0)))n=o,i=a;else if(n&&a==e&&l==e&&o instanceof s9&&2>Math.abs(t))if(o.deco.startSide<0)break;else s&&(n=null);r=a}return n?n.coordsAt(e-i,t):null}coordsForChar(e){let{i:t,off:n}=this.childPos(e,1),i=this.children[t];if(!(i instanceof s6))return null;for(;i.children.length;){let{i:e,off:t}=i.childPos(n,1);for(;;e++){if(e==i.children.length)return null;if((i=i.children[e]).length)break}n=t}if(!(i instanceof sH))return null;let r=iJ(i.text,n);if(r==n)return null;let s=sx(i.dom,n,r).getClientRects();for(let e=0;e<s.length;e++){let t=s[e];if(e==s.length-1||t.top<t.bottom&&t.left<t.right)return t}return null}measureVisibleLineHeights(e){let t=[],{from:n,to:i}=e,r=this.view.contentDOM.clientWidth,s=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,l=this.view.textDirection==oi.LTR;for(let e=0,a=0;a<this.children.length;a++){let h=this.children[a],c=e+h.length;if(c>i)break;if(e>=n){let n=h.dom.getBoundingClientRect();if(t.push(n.height),s){let t=h.dom.lastChild,i=t?sl(t):[];if(i.length){let t=i[i.length-1],s=l?t.right-n.left:n.right-t.left;s>o&&(o=s,this.minWidth=r,this.minWidthFrom=e,this.minWidthTo=c)}}}e=c+h.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return"rtl"==getComputedStyle(this.children[t].dom).direction?oi.RTL:oi.LTR}measureTextSize(){for(let e of this.children)if(e instanceof s6){let t=e.measureTextSize();if(t)return t}let e=document.createElement("div"),t,n,i;return e.className="cm-line",e.style.width="99999px",e.style.position="absolute",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=sl(e.firstChild)[0];t=e.getBoundingClientRect().height,n=r?r.width/27:7,i=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:n,textHeight:i}}childCursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.length,t=this.children.length;return t&&(e-=this.children[--t].length),new sO(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,i=0;;i++){let r=i==t.viewports.length?null:t.viewports[i],s=r?r.from-1:this.length;if(s>n){let i=(t.lineBlockAt(s).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(s1.replace({widget:new s7(i),block:!0,inclusive:!0,isBlockGap:!0}).range(n,s))}if(!r)break;n=r.to+1}return s1.set(e)}updateDeco(){let e=1,t=this.view.state.facet(o_).map(t=>(this.dynamicDecorationMap[e++]="function"==typeof t)?t(this.view):t),n=!1,i=this.view.state.facet(oW).map((e,t)=>{let i="function"==typeof e;return i&&(n=!0),i?e(this.view):e});for(i.length&&(this.dynamicDecorationMap[e++]=n,t.push(rW.join(i))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;return this.decorations}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(oO))try{if(t(this.view,e.range,e))return!0}catch(e){oD(this.view.state,e,"scroll handler")}let{range:t}=e,n=this.coordsAt(t.head,t.empty?t.assoc:t.head>t.anchor?-1:1),i;if(!n)return;!t.empty&&(i=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,i.left),top:Math.min(n.top,i.top),right:Math.max(n.right,i.right),bottom:Math.max(n.bottom,i.bottom)});let r=oU(this.view),s={left:n.left-r.left,top:n.top-r.top,right:n.right+r.right,bottom:n.bottom+r.bottom},{offsetWidth:o,offsetHeight:l}=this.view.scrollDOM;!function(e,t,n,i,r,s,o,l){let a=e.ownerDocument,h=a.defaultView||window;for(let c=e,d=!1;c&&!d;)if(1==c.nodeType){let e,u=c==a.body,f=1,p=1;if(u)e=function(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}}(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(c).position)&&(d=!0),c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let t=c.getBoundingClientRect();({scaleX:f,scaleY:p}=sp(c,t)),e={left:t.left,right:t.left+c.clientWidth*f,top:t.top,bottom:t.top+c.clientHeight*p}}let m=0,g=0;if("nearest"==r)t.top<e.top?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let i=t.bottom-t.top,s=e.bottom-e.top;g=("center"==r&&i<=s?t.top+i/2-s/2:"start"==r||"center"==r&&n<0?t.top-o:t.bottom-s+o)-e.top}if("nearest"==i?t.left<e.left?(m=t.left-(e.left+s),n>0&&t.right>e.right+m&&(m=t.right-e.right+s)):t.right>e.right&&(m=t.right-e.right+s,n<0&&t.left<e.left+m&&(m=t.left-(e.left+s))):m=("center"==i?t.left+(t.right-t.left)/2-(e.right-e.left)/2:"start"==i==l?t.left-s:t.right-(e.right-e.left)+s)-e.left,m||g)if(u)h.scrollBy(m,g);else{let e=0,n=0;if(g){let e=c.scrollTop;c.scrollTop+=g/p,n=(c.scrollTop-e)*p}if(m){let t=c.scrollLeft;c.scrollLeft+=m/f,e=(c.scrollLeft-t)*f}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&1>Math.abs(e-m)&&(i="nearest"),n&&1>Math.abs(n-g)&&(r="nearest")}if(u)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.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)}),c=c.assignedSlot||c.parentNode}else if(11==c.nodeType)c=c.host;else break}(this.view.scrollDOM,s,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,l),-l),this.view.textDirection==oi.LTR)}constructor(e){super(),this.view=e,this.decorations=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.markedForComposition=new Set,this.editContextFormatting=s1.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.setDOM(e.contentDOM),this.children=[new s6],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new oG(0,0,0,e.state.doc.length)],0,null)}}function oX(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let i=sk(n.focusNode,n.focusOffset),r=sS(n.focusNode,n.focusOffset),s=i||r;if(r&&i&&r.node!=i.node){let t=sN.get(r.node);if(!t||t instanceof sH&&t.text!=r.node.nodeValue)s=r;else if(e.docView.lastCompositionAfterCursor){let e=sN.get(i.node);!e||e instanceof sH&&e.text!=i.node.nodeValue||(s=r)}}if(e.docView.lastCompositionAfterCursor=s!=i,!s)return null;let o=t-s.offset;return{from:o,to:o+s.node.nodeValue.length,node:s.node}}let o$=class{compareRange(e,t){s8(e,t,this.changes)}comparePoint(e,t){s8(e,t,this.changes)}boundChange(e){s8(e,e,this.changes)}constructor(){this.changes=[]}};function oZ(e,t){return e.top<t.bottom-1&&e.bottom>t.top+1}function o0(e,t){return t<e.top?{top:t,left:e.left,right:e.right,bottom:e.bottom}:e}function o1(e,t){return t>e.bottom?{top:e.top,left:e.left,right:e.right,bottom:t}:e}function o2(e,t,n){let i=e.nodeValue.length,r=-1,s=1e9,o=0;for(let l=0;l<i;l++){let i=sx(e,l,l+1).getClientRects();for(let a=0;a<i.length;a++){let h=i[a];if(h.top==h.bottom)continue;o||(o=t-h.left);let c=(h.top>n?h.top-n:n-h.bottom)-1;if(h.left-1<=t&&h.right+1>=t&&c<s){let n=t>=(h.left+h.right)/2,i=n;if((sV.chrome||sV.gecko)&&sx(e,l).getBoundingClientRect().left==h.right&&(i=!n),c<=0)return{node:e,offset:l+ +!!i};r=l+ +!!i,s=c}}}return{node:e,offset:r>-1?r:o>0?e.nodeValue.length:0}}function o3(e,t,n){var i,r;let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1,o=e.contentDOM.getBoundingClientRect(),l=o.top+e.viewState.paddingTop,a,{docHeight:h}=e.viewState,{x:c,y:d}=t,u=d-l;if(u<0)return 0;if(u>h)return e.state.doc.length;for(let t=e.viewState.heightOracle.textHeight/2,i=!1;(a=e.elementAtHeight(u)).type!=s0.Text;)for(;!((u=s>0?a.bottom+t:a.top-t)>=0)||!(u<=h);){if(i)return n?null:0;i=!0,s=-s}d=l+u;let f=a.from;if(f<e.viewport.from)return 0==e.viewport.from?0:n?null:o4(e,o,a,c,d);if(f>e.viewport.to)return e.viewport.to==e.state.doc.length?e.state.doc.length:n?null:o4(e,o,a,c,d);let p=e.dom.ownerDocument,m=e.root.elementFromPoint?e.root:p,g=m.elementFromPoint(c,d);g&&!e.contentDOM.contains(g)&&(g=null),!g&&(c=Math.max(o.left+1,Math.min(o.right-1,c)),(g=m.elementFromPoint(c,d))&&!e.contentDOM.contains(g)&&(g=null));let v,x=-1;if(g&&(null==(i=e.docView.nearest(g))?void 0:i.isEditable)!=!1){if(p.caretPositionFromPoint){let e=p.caretPositionFromPoint(c,d);e&&({offsetNode:v,offset:x}=e)}else if(p.caretRangeFromPoint){let e=p.caretRangeFromPoint(c,d);e&&({startContainer:v,startOffset:x}=e)}v&&(!e.contentDOM.contains(v)||sV.safari&&o5(v,x,c)||sV.chrome&&function(e,t,n){if(0!=t)return o5(e,t,n);for(let t=e;;){let e=t.parentNode;if(!e||1!=e.nodeType||e.firstChild!=t)return!1;if(e.classList.contains("cm-line"))break;t=e}return n-(1==e.nodeType?e.getBoundingClientRect():sx(e,0,Math.max(e.nodeValue.length,1)).getBoundingClientRect()).left>5}(v,x,c))&&(v=void 0),v&&(x=Math.min(su(v),x))}if(!v||!e.docView.dom.contains(v)){let t=s6.find(e.docView,f);if(!t)return u>a.top+a.height/2?a.to:a.from;({node:v,offset:x}=function e(t,n,i){let r,s,o,l,a,h,c,d,u=!1;for(let m=t.firstChild;m;m=m.nextSibling){let t=sl(m);for(let g=0;g<t.length;g++){var f,p;let v=t[g];h&&oZ(h,v)&&(v=o0(o1(v,h.bottom),h.top));let x=(f=v).left>n?f.left-n:Math.max(0,n-f.right),b=(p=v).top>i?p.top-i:Math.max(0,i-p.bottom);if(0==x&&0==b)return 3==m.nodeType?o2(m,n,i):e(m,n,i);(!a||d>b||d==b&&c>x)&&(a=m,h=v,c=x,d=b,u=!x||(n<v.left?g>0:g<t.length-1)),0==x?i>v.bottom&&(!o||o.bottom<v.bottom)?(r=m,o=v):i<v.top&&(!l||l.top>v.top)&&(s=m,l=v):o&&oZ(o,v)?o=o1(o,v.bottom):l&&oZ(l,v)&&(l=o0(l,v.top))}}if(o&&o.bottom>=i?(a=r,h=o):l&&l.top<=i&&(a=s,h=l),!a)return{node:t,offset:0};let m=Math.max(h.left,Math.min(h.right,n));if(3==a.nodeType)return o2(a,m,i);if(u&&"false"!=a.contentEditable)return e(a,m,i);let g=Array.prototype.indexOf.call(t.childNodes,a)+ +(n>=(h.left+h.right)/2);return{node:t,offset:g}}(t.dom,c,d))}let b=e.docView.nearest(v);if(!b)return null;if(!b.isWidget||(null==(r=b.dom)?void 0:r.nodeType)!=1)return b.localPosFromDOM(v,x)+b.posAtStart;{let e=b.dom.getBoundingClientRect();return t.y<e.top||t.y<=e.bottom&&t.x<=(e.left+e.right)/2?b.posAtStart:b.posAtEnd}}function o4(e,t,n,i,r){let s=Math.round((i-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>1.5*e.defaultLineHeight){let t=e.viewState.heightOracle.textHeight;s+=Math.floor((r-n.top-(e.defaultLineHeight-t)*.5)/t)*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+r0(o,s,e.state.tabSize)}function o5(e,t,n){let i,r=e;if(3!=e.nodeType||t!=(i=e.nodeValue.length))return!1;for(;;){let e=r.nextSibling;if(e){if("BR"==e.nodeName)break;return!1}{let e=r.parentNode;if(!e||"DIV"==e.nodeName)break;r=e}}return sx(e,i-1,i).getBoundingClientRect().right>n}function o8(e,t,n){let i=e.lineBlockAt(t);if(Array.isArray(i.type)){let e;for(let r of i.type){if(r.from>t)break;if(!(r.to<t)){if(r.from<t&&r.to>t)return r;(!e||r.type==s0.Text&&(e.type!=r.type||(n<0?r.from<t:r.to>t)))&&(e=r)}}return e||i}return i}function o6(e,t,n,i){let r=e.state.doc.lineAt(t.head),s=e.bidiSpans(r),o=e.textDirectionAt(r.from);for(let l=t,a=null;;){let t=function(e,t,n,i,r){var s;let o=i.head-e.from,l=of.find(t,o,null!=(s=i.bidiLevel)?s:-1,i.assoc),a=t[l],h=a.side(r,n);if(o==h){let e=l+=r?1:-1;if(e<0||e>=t.length)return null;o=(a=t[l=e]).side(!r,n),h=a.side(r,n)}let c=iJ(e.text,o,a.forward(r,n));(c<a.from||c>a.to)&&(c=h),og=e.text.slice(Math.min(o,c),Math.max(o,c));let d=l==(r?t.length-1:0)?null:t[l+(r?1:-1)];return d&&c==h&&d.level+ +!r<a.level?i9.cursor(d.side(!r,n)+e.from,d.forward(r,n)?1:-1,d.level):i9.cursor(c+e.from,a.forward(r,n)?-1:1,a.level)}(r,s,o,l,n),h=og;if(!t){if(r.number==(n?e.state.doc.lines:1))return l;h="\n",r=e.state.doc.line(r.number+(n?1:-1)),s=e.bidiSpans(r),t=e.visualLineSide(r,!n)}if(a){if(!a(h))return l}else{if(!i)return t;a=i(h)}l=t}}function o9(e,t,n){for(;;){let i=0;for(let r of e)r.between(t-1,t+1,(e,r,s)=>{if(t>e&&t<r){let s=i||n||(t-e<r-t?-1:1);t=s<0?e:r,i=s}});if(!i)return t}}function o7(e,t){let n=null;for(let i=0;i<t.ranges.length;i++){let r=t.ranges[i],s=null;if(r.empty){let t=o9(e,r.from,0);t!=r.from&&(s=i9.cursor(t,-1))}else{let t=o9(e,r.from,-1),n=o9(e,r.to,1);(t!=r.from||n!=r.to)&&(s=i9.range(r.from==r.anchor?t:n,r.from==r.head?t:n))}s&&(n||(n=t.ranges.slice()),n[i]=s)}return n?i9.create(n,t.mainIndex):t}function le(e,t,n){let i=o9(e.state.facet(oV).map(t=>t(e)),n.from,t.head>n.from?-1:1);return i==n.from?n:i9.cursor(i,i<n.from?1:-1)}class lt{append(e){this.text+=e}lineBreak(){this.text+=""}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let i=e;;){this.findPointBefore(n,i);let e=this.text.length;this.readNode(i);let r=i.nextSibling;if(r==t)break;let s=sN.get(i),o=sN.get(r);(s&&o?s.breakAfter:(s?s.breakAfter:sc(i))||sc(r)&&("BR"!=i.nodeName||i.cmIgnore)&&this.text.length>e)&&this.lineBreak(),i=r}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,i=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,s=1,o;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,n),s=this.lineSeparator.length):(o=i.exec(t))&&(r=o.index,s=o[0].length),this.append(t.slice(n,r<0?t.length:r)),r<0)break;if(this.lineBreak(),s>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=s-1);n=r+s}}readNode(e){if(e.cmIgnore)return;let t=sN.get(e),n=t&&t.overrideDOMText;if(null!=n){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else 3==e.nodeType?this.readTextNode(e):"BR"==e.nodeName?e.nextSibling&&this.lineBreak():1==e.nodeType&&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)(3==e.nodeType?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(!function(e,t,n){for(;;){if(!t||n<su(t))return!1;if(t==e)return!0;n=sh(t)+1,t=t.parentNode}}(e,n.node,n.offset)?0:t))}constructor(e,t){this.points=e,this.text="",this.lineSeparator=t.facet(rL.lineSeparator)}}class ln{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class li{constructor(e,t,n,i){this.typeOver=i,this.bounds=null,this.text="",this.domChanged=t>-1;let{impreciseHead:r,impreciseAnchor:s}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,n,0))){let t=r||s?[]:function(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}=e.observer.selectionRange;return n&&(t.push(new ln(n,i)),(r!=n||s!=i)&&t.push(new ln(r,s))),t}(e),n=new lt(t,e.state);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=function(e,t){if(0==e.length)return null;let n=e[0].pos,i=2==e.length?e[1].pos:n;return n>-1&&i>-1?i9.single(n+t,i+t):null}(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=r&&r.node==t.focusNode&&r.offset==t.focusOffset||!ss(e.contentDOM,t.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),i=s&&s.node==t.anchorNode&&s.offset==t.anchorOffset||!ss(e.contentDOM,t.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),o=e.viewport;if((sV.ios||sV.chrome)&&e.state.selection.main.empty&&n!=i&&(o.from>0||o.to<e.state.doc.length)){let t=Math.min(n,i),r=Math.max(n,i),s=o.from-t,l=o.to-r;(0==s||1==s||0==t)&&(0==l||-1==l||r==e.state.doc.length)&&(n=0,i=e.state.doc.length)}this.newSel=i9.single(i,n)}}}function lr(e,t){let n,{newSel:i}=t,r=e.state.selection.main,s=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:i,to:o}=t.bounds,l=r.from,a=null;(8===s||sV.android&&t.text.length<o-i)&&(l=r.to,a="end");let h=function(e,t,n,i){let r=Math.min(e.length,t.length),s=0;for(;s<r&&e.charCodeAt(s)==t.charCodeAt(s);)s++;if(s==r&&e.length==t.length)return null;let o=e.length,l=t.length;for(;o>0&&l>0&&e.charCodeAt(o-1)==t.charCodeAt(l-1);)o--,l--;if("end"==i){let e=Math.max(0,s-Math.min(o,l));n-=o+e-s}if(o<s&&e.length<t.length){let e=n<=s&&n>=o?s-n:0;s-=e,l=s+(l-o),o=s}else if(l<s){let e=n<=s&&n>=l?s-n:0;s-=e,o=s+(o-l),l=s}return{from:s,toA:o,toB:l}}(e.state.doc.sliceString(i,o,""),t.text,l-i,a);h&&(sV.chrome&&13==s&&h.toB==h.from+2&&""==t.text.slice(h.from,h.toB)&&h.toB--,n={from:i+h.from,to:i+h.toA,insert:iz.of(t.text.slice(h.from,h.toB).split(""))})}else i&&(!e.hasFocus&&e.state.facet(oR)||i.main.eq(r))&&(i=null);if(!n&&!i)return!1;if(!n&&t.typeOver&&!r.empty&&i&&i.main.empty?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,r.to)}:(sV.mac||sV.android)&&n&&n.from==n.to&&n.from==r.head-1&&/^\. ?$/.test(n.insert.toString())&&"off"==e.contentDOM.getAttribute("autocorrect")?(i&&2==n.insert.length&&(i=i9.single(i.main.anchor-1,i.main.head-1)),n={from:n.from,to:n.to,insert:iz.of([n.insert.toString().replace("."," ")])}):n&&n.from>=r.from&&n.to<=r.to&&(n.from!=r.from||n.to!=r.to)&&r.to-r.from-(n.to-n.from)<=4?n={from:r.from,to:r.to,insert:e.state.doc.slice(r.from,n.from).append(n.insert).append(e.state.doc.slice(n.to,r.to))}:sV.chrome&&n&&n.from==n.to&&n.from==r.head&&"\n "==n.insert.toString()&&e.lineWrapping&&(i&&(i=i9.single(i.main.anchor-1,i.main.head-1)),n={from:r.from,to:r.to,insert:iz.of([" "])}),n)return ls(e,n,i,s);if(!i||i.main.eq(r))return!1;{let t=!1,n="select";return e.inputState.lastSelectionTime>Date.now()-50&&("select"==e.inputState.lastSelectionOrigin&&(t=!0),"select.pointer"==(n=e.inputState.lastSelectionOrigin)&&(i=o7(e.state.facet(oV).map(t=>t(e)),i))),e.dispatch({selection:i,scrollIntoView:t,userEvent:n}),!0}}function ls(e,t,n){let i,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:-1;if(sV.ios&&e.inputState.flushIOSKey(t))return!0;let s=e.state.selection.main;if(sV.android&&(t.to==s.to&&(t.from==s.from||t.from==s.from-1&&" "==e.state.sliceDoc(t.from,s.from))&&1==t.insert.length&&2==t.insert.lines&&sb(e.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&0==t.insert.length||8==r&&t.insert.length<t.to-t.from&&t.to>s.head)&&sb(e.contentDOM,"Backspace",8)||t.from==s.from&&t.to==s.to+1&&0==t.insert.length&&sb(e.contentDOM,"Delete",46)))return!0;let o=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let l=()=>i||(i=function(e,t,n){let i,r=e.state,s=r.selection.main,o=-1;if(t.from==t.to&&t.from<s.from||t.from>s.to){let n=t.from<s.from?-1:1,i=n<0?s.from:s.to,l=o9(r.facet(oV).map(t=>t(e)),i,n);t.from==l&&(o=l)}if(o>-1)i={changes:t,selection:i9.cursor(t.from+t.insert.length,-1)};else if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=s.from<t.from?r.sliceDoc(s.from,t.from):"",o=s.to>t.to?r.sliceDoc(t.to,s.to):"";i=r.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=r.changes(t),l=n&&n.main.to<=o.newLength?n.main:void 0;if(r.selection.ranges.length>1&&e.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let a=e.state.sliceDoc(t.from,t.to),h,c=n&&oX(e,n.main.head);if(c){let e=t.insert.length-(t.to-t.from);h={from:c.from,to:c.to-e}}else h=e.state.doc.lineAt(s.head);let d=s.to-t.to,u=s.to-s.from;i=r.changeByRange(n=>{if(n.from==s.from&&n.to==s.to)return{changes:o,range:l||n.map(o)};let i=n.to-d,c=i-a.length;if(n.to-n.from!=u||e.state.sliceDoc(c,i)!=a||n.to>=h.from&&n.from<=h.to)return{range:n};let f=r.changes({from:c,to:i,insert:t.insert}),p=n.to-s.to;return{changes:f,range:l?i9.range(Math.max(0,l.anchor+p),Math.max(0,l.head+p)):n.map(f)}})}else i={changes:o,selection:l&&r.selection.replaceRange(l)}}let l="input.type";return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,l+=".compose",e.inputState.compositionFirstChange&&(l+=".start",e.inputState.compositionFirstChange=!1)),r.update(i,{userEvent:l,scrollIntoView:!0})}(e,t,n));return e.state.facet(ok).some(n=>n(e,t.from,t.to,o,l))||e.dispatch(l()),!0}class lo{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}handleEvent(e){!(!function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,i;n!=e.contentDOM;n=n.parentNode)if(!n||11==n.nodeType||(i=sN.get(n))&&i.ignoreEvent(t))return!1;return!0}(this.view,e)||this.ignoreDuringComposition(e))&&("keydown"==e.type&&this.keydown(e)||(0!=this.view.updateState?Promise.resolve().then(()=>this.runHandlers(e.type,e)):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=function(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,i=e&&e.plugin.domEventHandlers,r=e&&e.plugin.domEventObservers;if(i)for(let e in i){let r=i[e];r&&n(e).handlers.push(ll(t.value,r))}if(r)for(let e in r){let i=r[e];i&&n(e).observers.push(ll(t.value,i))}}for(let e in lf)n(e).handlers.push(lf[e]);for(let e in lp)n(e).observers.push(lp[e]);return t}(e),n=this.handlers,i=this.view.contentDOM;for(let e in t)if("scroll"!=e){let r=!t[e].handlers.length,s=n[e];s&&!s.handlers.length!=r&&(i.removeEventListener(e,this.handleEvent),s=null),s||i.addEventListener(e,this.handleEvent,{passive:r})}for(let e in n)"scroll"==e||t[e]||i.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){let t;return this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),!!(9==e.keyCode&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))||((this.tabFocusMode>0&&27!=e.keyCode&&0>lc.indexOf(e.keyCode)&&(this.tabFocusMode=-1),sV.android&&sV.chrome&&!e.synthetic&&(13==e.keyCode||8==e.keyCode))?(this.view.observer.delayAndroidKey(e.key,e.keyCode),!0):sV.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&((t=la.find(t=>t.keyCode==e.keyCode))&&!e.ctrlKey||lh.indexOf(e.key)>-1&&e.ctrlKey&&!e.shiftKey)?(this.pendingIOSKey=t||e,setTimeout(()=>this.flushIOSKey(),250),!0):(229!=e.keyCode&&this.view.observer.forceFlush(),!1))}flushIOSKey(e){let t=this.pendingIOSKey;return!(!t||"Enter"==t.key&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString()))&&(this.pendingIOSKey=void 0,sb(this.view.contentDOM,t.key,t.keyCode,t instanceof KeyboardEvent?t:void 0))}ignoreDuringComposition(e){return!!/^key/.test(e.type)&&(this.composing>0||!!(sV.safari&&!sV.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100)&&(this.compositionPendingKey=!1,!0))}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()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.lastTouchTime=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.pendingIOSKey=void 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.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,sV.safari&&e.contentDOM.addEventListener("input",()=>null),sV.gecko&&function(e){lT.has(e)||(lT.add(e),e.addEventListener("copy",()=>{}),e.addEventListener("cut",()=>{}))}(e.contentDOM.ownerDocument)}}function ll(e,t){return(n,i)=>{try{return t.call(e,i,n)}catch(e){oD(n.state,e)}}}let la=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],lh="dthko",lc=[16,17,18,20,91,92,224,225];function ld(e){return .7*Math.max(0,e)+8}class lu{start(e){!1===this.dragging&&this.select(e)}move(e){var t;if(0==e.buttons)return this.destroy();if(this.dragging||null==this.dragging&&10>(t=this.startEvent,Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))))return;this.select(this.lastEvent=e);let n=0,i=0,r=0,s=0,o=this.view.win.innerWidth,l=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:o}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:s,bottom:l}=this.scrollParents.y.getBoundingClientRect());let a=oU(this.view);e.clientX-a.left<=r+6?n=-ld(r-e.clientX):e.clientX+a.right>=o-6&&(n=ld(e.clientX-o)),e.clientY-a.top<=s+6?i=-ld(s-e.clientY):e.clientY+a.bottom>=l-6&&(i=ld(e.clientY-l)),this.setScrollSpeed(n,i)}up(e){null==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),!1===this.dragging&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=o7(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,!1===this.dragging))&&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)}constructor(e,t,n,i){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=i,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=function(e){let t=e.ownerDocument,n,i;for(let r=e.parentNode;r;)if(r==t.body||n&&i)break;else if(1==r.nodeType)!i&&r.scrollHeight>r.clientHeight&&(i=r),!n&&r.scrollWidth>r.clientWidth&&(n=r),r=r.assignedSlot||r.parentNode;else if(11==r.nodeType)r=r.host;else break;return{x:n,y:i}}(e.contentDOM),this.atoms=e.state.facet(oV).map(t=>t(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(rL.allowMultipleSelections)&&function(e,t){let n=e.state.facet(ov);return n.length?n[0](t):sV.mac?t.metaKey:t.ctrlKey}(e,t),this.dragging=!!function(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let i=sr(e.root);if(!i||0==i.rangeCount)return!0;let r=i.getRangeAt(0).getClientRects();for(let e=0;e<r.length;e++){let n=r[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}(e,t)&&1==lA(t)&&null}}let lf=Object.create(null),lp=Object.create(null),lm=sV.ie&&sV.ie_version<15||sV.ios&&sV.webkit_version<604;function lg(e,t,n){for(let i of e.facet(t))n=i(n,e);return n}function lv(e,t){t=lg(e.state,oC,t);let{state:n}=e,i,r=1,s=n.toText(t),o=s.lines==n.selection.ranges.length;if(null!=lM&&n.selection.ranges.every(e=>e.empty)&&lM==s.toString()){let e=-1;i=n.changeByRange(i=>{let l=n.doc.lineAt(i.from);if(l.from==e)return{range:i};e=l.from;let a=n.toText((o?s.line(r++).text:t)+n.lineBreak);return{changes:{from:l.from,insert:a},range:i9.cursor(i.from+a.length)}})}else i=o?n.changeByRange(e=>{let t=s.line(r++);return{changes:{from:e.from,to:e.to,insert:t.text},range:i9.cursor(e.from+t.length)}}):n.replaceSelection(s);e.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}function lx(e,t,n,i){if(1==i)return i9.cursor(t,n);{if(2==i)return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,i=e.charCategorizer(t),r=e.doc.lineAt(t),s=t-r.from;if(0==r.length)return i9.cursor(t);0==s?n=1:s==r.length&&(n=-1);let o=s,l=s;n<0?o=iJ(r.text,s,!1):l=iJ(r.text,s);let a=i(r.text.slice(o,l));for(;o>0;){let e=iJ(r.text,o,!1);if(i(r.text.slice(e,o))!=a)break;o=e}for(;l<r.length;){let e=iJ(r.text,l);if(i(r.text.slice(l,e))!=a)break;l=e}return i9.range(o+r.from,l+r.from)}(e.state,t,n);let r=s6.find(e.docView,t),s=e.state.doc.lineAt(r?r.posAtEnd:t),o=r?r.posAtStart:s.from,l=r?r.posAtEnd:s.to;return l<e.state.doc.length&&l==s.to&&l++,i9.range(o,l)}}lp.scroll=e=>{e.inputState.lastScrollTop=e.scrollDOM.scrollTop,e.inputState.lastScrollLeft=e.scrollDOM.scrollLeft},lf.keydown=(e,t)=>(e.inputState.setSelectionOrigin("select"),27==t.keyCode&&0!=e.inputState.tabFocusMode&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),lp.touchstart=(e,t)=>{e.inputState.lastTouchTime=Date.now(),e.inputState.setSelectionOrigin("select.pointer")},lp.touchmove=e=>{e.inputState.setSelectionOrigin("select.pointer")},lf.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let i of e.state.facet(ob))if(n=i(e,t))break;if(n||0!=t.button||(n=function(e,t){let n=ly(e,t),i=lA(t),r=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),r=r.map(e.changes))},get(t,s,o){let l=ly(e,t),a,h=lx(e,l.pos,l.bias,i);if(n.pos!=l.pos&&!s){let t=lx(e,n.pos,n.bias,i),r=Math.min(t.from,h.from),s=Math.max(t.to,h.to);h=r<h.from?i9.range(r,s):i9.range(s,r)}return s?r.replaceRange(r.main.extend(h.from,h.to)):o&&1==i&&r.ranges.length>1&&(a=function(e,t){for(let n=0;n<e.ranges.length;n++){let{from:i,to:r}=e.ranges[n];if(i<=t&&r>=t)return i9.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-(e.mainIndex>n))}return null}(r,l.pos))?a:o?r.addRange(h):i9.create([h])}}}(e,t)),n){let i=!e.hasFocus;e.inputState.startMouseSelection(new lu(e,t,n,i)),i&&e.observer.ignore(()=>{sv(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let r=e.inputState.mouseSelection;if(r)return r.start(t),!1===r.dragging}else e.inputState.setSelectionOrigin("select.pointer");return!1};let lb=(e,t,n)=>t>=n.top&&t<=n.bottom&&e>=n.left&&e<=n.right;function ly(e,t){let n=e.posAtCoords({x:t.clientX,y:t.clientY},!1);return{pos:n,bias:function(e,t,n,i){let r=s6.find(e.docView,t);if(!r)return 1;let s=t-r.posAtStart;if(0==s)return 1;if(s==r.length)return -1;let o=r.coordsAt(s,-1);if(o&&lb(n,i,o))return -1;let l=r.coordsAt(s,1);return l&&lb(n,i,l)?1:o&&o.bottom>=i?-1:1}(e,n,t.clientX,t.clientY)}}let lw=sV.ie&&sV.ie_version<=11,lk=null,lS=0,lC=0;function lA(e){if(!lw)return e.detail;let t=lk,n=lC;return lk=e,lC=Date.now(),lS=!t||n>Date.now()-400&&2>Math.abs(t.clientX-e.clientX)&&2>Math.abs(t.clientY-e.clientY)?(lS+1)%3:1}function lN(e,t,n,i){let r;if(!(n=lg(e.state,oC,n)))return;let s=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:o}=e.inputState,l=i&&o&&((r=e.state.facet(ox)).length?r[0](t):sV.mac?!t.altKey:!t.ctrlKey)?{from:o.from,to:o.to}:null,a={from:s,insert:n},h=e.state.changes(l?[l,a]:a);e.focus(),e.dispatch({changes:h,selection:{anchor:h.mapPos(s,-1),head:h.mapPos(s,1)},userEvent:l?"move.drop":"input.drop"}),e.inputState.draggedContent=null}lf.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let i=e.docView.nearest(t.target);if(i&&i.isWidget){let e=i.posAtStart,t=e+i.length;(e>=n.to||t<=n.from)&&(n=i9.range(e,t))}}let{inputState:i}=e;return i.mouseSelection&&(i.mouseSelection.dragging=!0),i.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData("Text",lg(e.state,oA,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed="copyMove"),!1},lf.dragend=e=>(e.inputState.draggedContent=null,!1),lf.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let i=Array(n.length),r=0,s=()=>{++r==n.length&&lN(e,t,i.filter(e=>null!=e).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=s,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(i[e]=t.result),s()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData("Text");if(n)return lN(e,t,n,!0),!0}return!1},lf.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=lm?null:t.clipboardData;return n?(lv(e,n.getData("text/plain")||n.getData("text/uri-list")),!0):(!function(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(),lv(e,n.value)},50)}(e),!1)};let lM=null;lf.copy=lf.cut=(e,t)=>{let{text:n,ranges:i,linewise:r}=function(e){let t=[],n=[],i=!1;for(let i of e.selection.ranges)i.empty||(t.push(e.sliceDoc(i.from,i.to)),n.push(i));if(!t.length){let r=-1;for(let{from:i}of e.selection.ranges){let s=e.doc.lineAt(i);s.number>r&&(t.push(s.text),n.push({from:s.from,to:Math.min(e.doc.length,s.to+1)})),r=s.number}i=!0}return{text:lg(e,oA,t.join(e.lineBreak)),ranges:n,linewise:i}}(e.state);if(!n&&!r)return!1;lM=r?n:null,"cut"!=t.type||e.state.readOnly||e.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"});let s=lm?null:t.clipboardData;return s?(s.clearData(),s.setData("text/plain",n),!0):(!function(e,t){let n=e.dom.parentNode;if(!n)return;let i=n.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=t,i.focus(),i.selectionEnd=t.length,i.selectionStart=0,setTimeout(()=>{i.remove(),e.focus()},50)}(e,n),!1)};let lO=rC.define();function lj(e,t){let n=[];for(let i of e.facet(oS)){let r=i(e,t);r&&n.push(r)}return n.length?e.update({effects:n,annotations:lO.of(!0)}):null}function lE(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=lj(e.state,t);n?e.dispatch(n):e.update([])}},10)}lp.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),lE(e)},lp.blur=e=>{e.observer.clearSelectionRange(),lE(e)},lp.compositionstart=lp.compositionupdate=e=>{!e.observer.editContext&&(null==e.inputState.compositionFirstChange&&(e.inputState.compositionFirstChange=!0),e.inputState.composing<0&&(e.inputState.composing=0))},lp.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,sV.chrome&&sV.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},lp.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},lf.beforeinput=(e,t)=>{var n,i;let r;if("insertReplacementText"==t.inputType&&e.observer.editContext){let i=null==(n=t.dataTransfer)?void 0:n.getData("text/plain"),r=t.getTargetRanges();if(i&&r.length){let t=r[0],n=e.posAtDOM(t.startContainer,t.startOffset),s=e.posAtDOM(t.endContainer,t.endOffset);return ls(e,{from:n,to:s,insert:e.state.toText(i)},null),!0}}if(sV.chrome&&sV.android&&(r=la.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(r.key,r.keyCode),"Backspace"==r.key||"Delete"==r.key)){let t=(null==(i=window.visualViewport)?void 0:i.height)||0;setTimeout(()=>{var n;((null==(n=window.visualViewport)?void 0:n.height)||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return sV.ios&&"deleteContentForward"==t.inputType&&e.observer.flushSoon(),sV.safari&&"insertText"==t.inputType&&e.inputState.composing>=0&&setTimeout(()=>lp.compositionend(e,t),20),!1};let lT=new Set,lD=["pre-wrap","normal","pre-line","break-spaces"],lR=!1;class lP{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 lD.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];i<0?n++:this.heightSamples[Math.floor(10*i)]||(t=!0,this.heightSamples[Math.floor(10*i)]=!0)}return t}refresh(e,t,n,i,r,s){let o=lD.indexOf(e)>-1,l=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=i,this.lineLength=r,l){this.heightSamples={};for(let e=0;e<s.length;e++){let t=s[e];t<0?e++:this.heightSamples[Math.floor(10*t)]=!0}}return l}constructor(e){this.lineWrapping=e,this.doc=iz.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}}class lL{get more(){return this.index<this.heights.length}constructor(e,t){this.from=e,this.heights=t,this.index=0}}class lI{get type(){return"number"==typeof this._content?s0.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof s4?this._content.widget:null}get widgetLineBreaks(){return"number"==typeof this._content?this._content:0}join(e){let t=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(e._content)?e._content:[e]);return new lI(this.from,this.length+e.length,this.top,this.height+e.height,t)}constructor(e,t,n,i,r){this.from=e,this.length=t,this.top=n,this.height=i,this._content=r}}var lB=function(e){return e[e.ByPos=0]="ByPos",e[e.ByHeight=1]="ByHeight",e[e.ByPosNoHeight=2]="ByPosNoHeight",e}(lB||(lB={}));class lz{get outdated(){return(2&this.flags)>0}set outdated(e){this.flags=2*!!e|-3&this.flags}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>.001&&(lR=!0),this.height=e)}replace(e,t,n){return lz.of(n)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,i){let r=this,s=n.doc;for(let o=i.length-1;o>=0;o--){let{fromA:l,toA:a,fromB:h,toB:c}=i[o],d=r.lineAt(l,lB.ByPosNoHeight,n.setDoc(t),0,0),u=d.to>=a?d:r.lineAt(a,lB.ByPosNoHeight,n,0,0);for(c+=u.to-a,a=u.to;o>0&&d.from<=i[o-1].toA;)l=i[o-1].fromA,h=i[o-1].fromB,o--,l<d.from&&(d=r.lineAt(l,lB.ByPosNoHeight,n,0,0));h+=d.from-l,l=d.from;let f=lK.build(n.setDoc(s),e,h,c);r=lF(r,r.replace(l,a,f))}return r.updateHeight(n,0)}static empty(){return new lW(0,0)}static of(e){if(1==e.length)return e[0];let t=0,n=e.length,i=0,r=0;for(;;)if(t==n)if(i>2*r){let r=e[t-1];r.break?e.splice(--t,1,r.left,null,r.right):e.splice(--t,1,r.left,r.right),n+=1+r.break,i-=r.size}else if(r>2*i){let t=e[n];t.break?e.splice(n,1,t.left,null,t.right):e.splice(n,1,t.left,t.right),n+=2+t.break,r-=t.size}else break;else if(i<r){let n=e[t++];n&&(i+=n.size)}else{let t=e[--n];t&&(r+=t.size)}let s=0;return null==e[t-1]?(s=1,t--):null==e[t]&&(s=1,n++),new lH(lz.of(e.slice(0,t)),s,lz.of(e.slice(n)))}constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}}function lF(e,t){return e==t?e:(e.constructor!=t.constructor&&(lR=!0),t)}lz.prototype.size=1;class l_ extends lz{blockAt(e,t,n,i){return new lI(i,this.length,n,this.height,this.deco||0)}lineAt(e,t,n,i,r){return this.blockAt(0,n,i,r)}forEachLine(e,t,n,i,r,s){e<=r+this.length&&t>=r&&s(this.blockAt(0,n,i,r))}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(arguments.length>2&&void 0!==arguments[2]&&arguments[2],arguments.length>3?arguments[3]:void 0);return n&&n.from<=t&&n.more&&this.setHeight(n.heights[n.index++]),this.outdated=!1,this}toString(){return"block(".concat(this.length,")")}constructor(e,t,n){super(e,t),this.deco=n}}class lW extends l_{blockAt(e,t,n,i){return new lI(i,this.length,n,this.height,this.breaks)}replace(e,t,n){let i=n[0];return 1==n.length&&(i instanceof lW||i instanceof lV&&4&i.flags)&&10>Math.abs(this.length-i.length)?(i instanceof lV?i=new lW(i.length,this.height):i.height=this.height,this.outdated||(i.outdated=!1),i):lz.of(n)}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0;return i&&i.from<=t&&i.more?this.setHeight(i.heights[i.index++]):(n||this.outdated)&&this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return"line(".concat(this.length).concat(this.collapsed?-this.collapsed:"").concat(this.widgetHeight?":"+this.widgetHeight:"",")")}constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}}class lV extends lz{heightMetrics(e,t){let n=e.doc.lineAt(t).number,i=e.doc.lineAt(t+this.length).number,r=i-n+1,s,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*r);s=t/r,this.length>r+1&&(o=(this.height-t)/(this.length-r-1))}else s=this.height/r;return{firstLine:n,lastLine:i,perLine:s,perChar:o}}blockAt(e,t,n,i){let{firstLine:r,lastLine:s,perLine:o,perChar:l}=this.heightMetrics(t,i);if(t.lineWrapping){let r=i+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),s=t.doc.lineAt(r),a=o+s.length*l,h=Math.max(n,e-a/2);return new lI(s.from,s.length,h,a,0)}{let i=Math.max(0,Math.min(s-r,Math.floor((e-n)/o))),{from:l,length:a}=t.doc.line(r+i);return new lI(l,a,n+o*i,o,0)}}lineAt(e,t,n,i,r){if(t==lB.ByHeight)return this.blockAt(e,n,i,r);if(t==lB.ByPosNoHeight){let{from:t,to:i}=n.doc.lineAt(e);return new lI(t,i-t,0,0,0)}let{firstLine:s,perLine:o,perChar:l}=this.heightMetrics(n,r),a=n.doc.lineAt(e),h=o+a.length*l,c=a.number-s,d=i+o*c+l*(a.from-r-c);return new lI(a.from,a.length,Math.max(i,Math.min(d,i+this.height-h)),h,0)}forEachLine(e,t,n,i,r,s){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(n,r);for(let h=e,c=i;h<=t;){let t=n.doc.lineAt(h);if(h==e){let n=t.number-o;c+=l*n+a*(e-r-n)}let i=l+a*t.length;s(new lI(t.from,t.length,c,i,0)),c+=i,h=t.to+1}}replace(e,t,n){let i=this.length-t;if(i>0){let e=n[n.length-1];e instanceof lV?n[n.length-1]=new lV(e.length+i):n.push(null,new lV(i-1))}if(e>0){let t=n[0];t instanceof lV?n[0]=new lV(e+t.length):n.unshift(new lV(e-1),null)}return lz.of(n)}decomposeLeft(e,t){t.push(new lV(e-1),null)}decomposeRight(e,t){t.push(null,new lV(this.length-e-1))}updateHeight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,r=t+this.length;if(i&&i.from<=t+this.length&&i.more){let n=[],s=Math.max(t,i.from),o=-1;for(i.from>t&&n.push(new lV(i.from-t-1).updateHeight(e,t));s<=r&&i.more;){let t=e.doc.lineAt(s).length;n.length&&n.push(null);let r=i.heights[i.index++];-1==o?o=r:Math.abs(r-o)>=.001&&(o=-2);let l=new lW(t,r);l.outdated=!1,n.push(l),s+=t+1}s<=r&&n.push(null,new lV(r-s).updateHeight(e,s));let l=lz.of(n);return(o<0||Math.abs(l.height-this.height)>=.001||Math.abs(o-this.heightMetrics(e,t).perLine)>=.001)&&(lR=!0),lF(this,l)}return(n||this.outdated)&&(this.setHeight(e.heightForGap(t,t+this.length)),this.outdated=!1),this}toString(){return"gap(".concat(this.length,")")}constructor(e){super(e,0)}}class lH extends lz{get break(){return 1&this.flags}blockAt(e,t,n,i){let r=n+this.left.height;return e<r?this.left.blockAt(e,t,n,i):this.right.blockAt(e,t,r,i+this.left.length+this.break)}lineAt(e,t,n,i,r){let s=i+this.left.height,o=r+this.left.length+this.break,l=t==lB.ByHeight?e<s:e<o,a=l?this.left.lineAt(e,t,n,i,r):this.right.lineAt(e,t,n,s,o);if(this.break||(l?a.to<o:a.from>o))return a;let h=t==lB.ByPosNoHeight?lB.ByPosNoHeight:lB.ByPos;return l?a.join(this.right.lineAt(o,h,n,s,o)):this.left.lineAt(o,h,n,i,r).join(a)}forEachLine(e,t,n,i,r,s){let o=i+this.left.height,l=r+this.left.length+this.break;if(this.break)e<l&&this.left.forEachLine(e,t,n,i,r,s),t>=l&&this.right.forEachLine(e,t,n,o,l,s);else{let a=this.lineAt(l,lB.ByPos,n,i,r);e<a.from&&this.left.forEachLine(e,a.from-1,n,i,r,s),a.to>=e&&a.from<=t&&s(a),t>a.to&&this.right.forEachLine(a.to+1,t,n,o,l,s)}}replace(e,t,n){let i=this.left.length+this.break;if(t<i)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-i,t-i,n));let r=[];e>0&&this.decomposeLeft(e,r);let s=r.length;for(let e of n)r.push(e);if(e>0&&lq(r,s-1),t<this.length){let e=r.length;this.decomposeRight(t,r),lq(r,e)}return lz.of(r)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&e>=++n&&t.push(null),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,i=n+this.break;if(e>=i)return this.right.decomposeRight(e-i,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<i&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?lz.of(this.break?[e,null,t]:[e,t]):(this.left=lF(this.left,e),this.right=lF(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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3?arguments[3]:void 0,{left:r,right:s}=this,o=t+r.length+this.break,l=null;return(i&&i.from<=t+r.length&&i.more?l=r=r.updateHeight(e,t,n,i):r.updateHeight(e,t,n),i&&i.from<=o+s.length&&i.more?l=s=s.updateHeight(e,o,n,i):s.updateHeight(e,o,n),l)?this.balanced(r,s):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}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}}function lq(e,t){let n,i;null==e[t]&&(n=e[t-1])instanceof lV&&(i=e[t+1])instanceof lV&&e.splice(t-1,3,new lV(n.length+1+i.length))}class lK{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 lW?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new lW(e-this.pos,-1)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let i=n.widget?n.widget.estimatedHeight:0,r=n.widget?n.widget.lineBreaks:0;i<0&&(i=this.oracle.lineHeight);let s=t-e;n.block?this.addBlock(new l_(s,i,n)):(s||r||i>=5)&&this.addLineDeco(i,r,s)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||null==this.nodes[this.nodes.length-1])&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new lW(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let n=new lV(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 lW)return e;let t=new lW(0,-1);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=this.pos+e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let i=this.ensureLine();i.length+=n,i.collapsed+=n,i.widgetHeight=Math.max(i.widgetHeight,e),i.breaks+=t,this.writtenTo=this.pos=this.pos+n}finish(e){let t=0==this.nodes.length?null:this.nodes[this.nodes.length-1];!(this.lineStart>-1)||t instanceof lW||this.isCovered?(this.writtenTo<this.pos||null==t)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos)):this.nodes.push(new lW(0,-1));let n=e;for(let e of this.nodes)e instanceof lW&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(e,t,n,i){let r=new lK(n,e);return rW.spans(t,n,i,r,0),r.finish(n)}constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}}class lU{compareRange(){}comparePoint(e,t,n,i){(e<t||n&&n.heightRelevant||i&&i.heightRelevant)&&s8(e,t,this.changes,5)}constructor(){this.changes=[]}}class lJ{static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let i=e[n],r=t[n];if(i.from!=r.from||i.to!=r.to||i.size!=r.size)return!1}return!0}draw(e,t){return s1.replace({widget:new lG(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}constructor(e,t,n,i){this.from=e,this.to=t,this.size=n,this.displaySize=i}}class lG extends sZ{eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement("div");return this.vertical?e.style.height=this.size+"px":(e.style.width=this.size+"px",e.style.height="2px",e.style.display="inline-block"),e}get estimatedHeight(){return this.vertical?this.size:-1}constructor(e,t){super(),this.size=e,this.vertical=t}}class lY{updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let i=n?t.head:t.anchor;if(!e.some(e=>{let{from:t,to:n}=e;return i>=t&&i<=n})){let{from:t,to:n}=this.lineBlockAt(i);e.push(new lQ(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?lZ:new l0(this.heightOracle,this.heightMap,this.viewports),2*!e.eq(this.scaler)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(l1(e,this.scaler))})}update(e){var t,n;let i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;this.state=e.state;let s=this.stateDeco;this.stateDeco=this.state.facet(o_).filter(e=>"function"!=typeof e);let o=e.changedRanges,l=oG.extendWithRanges(o,(t=this.stateDeco,n=e?e.changes:i0.empty(this.state.doc.length),i=new lU,rW.compare(s,t,n,i,0),i.changes)),a=this.heightMap.height,h=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollTop);lR=!1,this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),l),(this.heightMap.height!=a||lR)&&(e.flags|=2),h?(this.scrollAnchorPos=e.changes.mapPos(h.from,-1),this.scrollAnchorHeight=h.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let c=l.length?this.mapViewport(this.viewport,e.changes):this.viewport;(r&&(r.range.head<c.from||r.range.head>c.to)||!this.viewportIsAppropriate(c))&&(c=this.getViewport(0,r));let d=c.from!=this.viewport.from||c.to!=this.viewport.to;this.viewport=c,e.flags|=this.updateForViewport(),(d||!e.changes.empty||2&e.flags)&&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),r&&(this.scrollTarget=r),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(oM)&&(this.mustEnforceCursorAssoc=!0)}measure(e){var t;let n,i,r=e.contentDOM,s=window.getComputedStyle(r),o=this.heightOracle,l=s.whiteSpace;this.defaultTextDirection="rtl"==s.direction?oi.RTL:oi.LTR;let a=this.heightOracle.mustRefreshForWrapping(l),h=r.getBoundingClientRect(),c=a||this.mustMeasureContent||this.contentDOMHeight!=h.height;this.contentDOMHeight=h.height,this.mustMeasureContent=!1;let d=0,u=0;if(h.width&&h.height){let{scaleX:e,scaleY:t}=sp(r,h);(e>.005&&Math.abs(this.scaleX-e)>.005||t>.005&&Math.abs(this.scaleY-t)>.005)&&(this.scaleX=e,this.scaleY=t,d|=16,a=c=!0)}let f=(parseInt(s.paddingTop)||0)*this.scaleY,p=(parseInt(s.paddingBottom)||0)*this.scaleY;(this.paddingTop!=f||this.paddingBottom!=p)&&(this.paddingTop=f,this.paddingBottom=p,d|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(o.lineWrapping&&(c=!0),this.editorWidth=e.scrollDOM.clientWidth,d|=16);let m=e.scrollDOM.scrollTop*this.scaleY;this.scrollTop!=m&&(this.scrollAnchorHeight=-1,this.scrollTop=m),this.scrolledToBottom=sw(e.scrollDOM);let g=(this.printing?function(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}:function(e,t){let n=e.getBoundingClientRect(),i=e.ownerDocument,r=i.defaultView||window,s=Math.max(0,n.left),o=Math.min(r.innerWidth,n.right),l=Math.max(0,n.top),a=Math.min(r.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=i.body;)if(1==t.nodeType){let n=t,i=window.getComputedStyle(n);if((n.scrollHeight>n.clientHeight||n.scrollWidth>n.clientWidth)&&"visible"!=i.overflow){let i=n.getBoundingClientRect();s=Math.max(s,i.left),o=Math.min(o,i.right),l=Math.max(l,i.top),a=Math.min(t==e.parentNode?r.innerHeight:a,i.bottom)}t="absolute"==i.position||"fixed"==i.position?n.offsetParent:n.parentNode}else if(11==t.nodeType)t=t.host;else break;return{left:s-n.left,right:Math.max(s,o)-n.left,top:l-(n.top+t),bottom:Math.max(l,a)-(n.top+t)}})(r,this.paddingTop),v=g.top-this.pixelViewport.top,x=g.bottom-this.pixelViewport.bottom;this.pixelViewport=g;let b=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(b!=this.inView&&(this.inView=b,b&&(c=!0)),!this.inView&&!this.scrollTarget&&(n=(t=e.dom).getBoundingClientRect(),i=t.ownerDocument.defaultView||window,!(n.left<i.innerWidth)||!(n.right>0)||!(n.top<i.innerHeight)||!(n.bottom>0)))return 0;let y=h.width;if((this.contentDOMWidth!=y||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=h.width,this.editorHeight=e.scrollDOM.clientHeight,d|=16),c){let t=e.docView.measureVisibleLineHeights(this.viewport);if(o.mustRefreshForHeights(t)&&(a=!0),a||o.lineWrapping&&Math.abs(y-this.contentDOMWidth)>o.charWidth){let{lineHeight:n,charWidth:i,textHeight:r}=e.docView.measureTextSize();(a=n>0&&o.refresh(l,n,i,r,Math.max(5,y/i),t))&&(e.docView.minWidth=0,d|=16)}for(let n of(v>0&&x>0?u=Math.max(v,x):v<0&&x<0&&(u=Math.min(v,x)),lR=!1,this.viewports)){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?lz.empty().applyChanges(this.stateDeco,iz.empty,this.heightOracle,[new oG(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(o,0,a,new lL(n.from,i))}lR&&(d|=2)}let w=!this.viewportIsAppropriate(this.viewport,u)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return w&&(2&d&&(d|=this.updateScaler()),this.viewport=this.getViewport(u,this.scrollTarget),d|=this.updateForViewport()),(2&d||w)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),d|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),d}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)),i=this.heightMap,r=this.heightOracle,{visibleTop:s,visibleBottom:o}=this,l=new lQ(i.lineAt(s-1e3*n,lB.ByHeight,r,0,0).from,i.lineAt(o+(1-n)*1e3,lB.ByHeight,r,0,0).to);if(t){let{head:e}=t.range;if(e<l.from||e>l.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),s=i.lineAt(e,lB.ByPos,r,0,0),o;o="center"==t.y?(s.top+s.bottom)/2-n/2:"start"==t.y||"nearest"==t.y&&e<l.from?s.top:s.bottom-n,l=new lQ(i.lineAt(o-500,lB.ByHeight,r,0,0).from,i.lineAt(o+n+500,lB.ByHeight,r,0,0).to)}}return l}mapViewport(e,t){let n=t.mapPos(e.from,-1),i=t.mapPos(e.to,1);return new lQ(this.heightMap.lineAt(n,lB.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(i,lB.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate(e){let{from:t,to:n}=e,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(t,lB.ByPos,this.heightOracle,0,0),{bottom:s}=this.heightMap.lineAt(n,lB.ByPos,this.heightOracle,0,0),{visibleTop:o,visibleBottom:l}=this;return(0==t||r<=o-Math.max(10,Math.min(-i,250)))&&(n==this.state.doc.length||s>=l+Math.max(10,Math.min(i,250)))&&r>o-2e3&&s<l+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let i of e)t.touchesRange(i.from,i.to)||n.push(new lJ(t.mapPos(i.from),t.mapPos(i.to),i.size,i.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,i=n?1e4:2e3,r=i>>1,s=i<<1;if(this.defaultTextDirection!=oi.LTR&&!n)return[];let o=[],l=(i,s,a,h)=>{if(s-i<r)return;let c=this.state.selection.main,d=[c.from];for(let e of(c.empty||d.push(c.to),d))if(e>i&&e<s){l(i,e-10,a,h),l(e+10,s,a,h);return}let u=function(e,t){for(let n of e)if(t(n))return n}(e,e=>e.from>=a.from&&e.to<=a.to&&Math.abs(e.from-i)<r&&Math.abs(e.to-s)<r&&!d.some(t=>e.from<t&&e.to>t));if(!u){if(s<a.to&&t&&n&&t.visibleRanges.some(e=>e.from<=s&&e.to>=s)){let e=t.moveToLineBoundary(i9.cursor(s),!1,!0).head;e>i&&(s=e)}let e=this.gapSize(a,i,s,h),r=n||e<2e6?e:2e6;u=new lJ(i,s,e,r)}o.push(u)},a=t=>{var r,o,a;let h,c,d,u,f;if(t.length<s||t.type!=s0.Text)return;let p=(r=t.from,o=t.to,a=this.stateDeco,d=[],u=r,f=0,rW.spans(a,r,o,{span(){},point(e,t){e>u&&(d.push({from:u,to:e}),f+=e-u),u=t}},20),u<o&&(d.push({from:u,to:o}),f+=o-u),{total:f,ranges:d});if(p.total<s)return;let m=this.scrollTarget?this.scrollTarget.range.head:null;if(n){let e,n,r=i/this.heightOracle.lineLength*this.heightOracle.lineHeight;if(null!=m){let i=l$(p,m),s=((this.visibleBottom-this.visibleTop)/2+r)/t.height;e=i-s,n=i+s}else e=(this.visibleTop-t.top-r)/t.height,n=(this.visibleBottom-t.top+r)/t.height;h=lX(p,e),c=lX(p,n)}else{let n,r,s=p.total*this.heightOracle.charWidth,o=i*this.heightOracle.charWidth,l=0;if(s>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+l<this.pixelViewport.left&&(l=n.size-n.displaySize);let a=this.pixelViewport.left+l,d=this.pixelViewport.right+l;if(null!=m){let e=l$(p,m),t=((d-a)/2+o)/s;n=e-t,r=e+t}else n=(a-o)/s,r=(d+o)/s;h=lX(p,n),c=lX(p,r)}h>t.from&&l(t.from,h,t,p),c<t.to&&l(c,t.to,t,p)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(a):a(e);return o}gapSize(e,t,n,i){let r=l$(i,n)-l$(i,t);return this.heightOracle.lineWrapping?e.height*r:i.total*this.heightOracle.charWidth*r}updateLineGaps(e){lJ.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=s1.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];rW.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let i=0;if(n.length!=this.visibleRanges.length)i=12;else for(let t=0;t<n.length&&!(8&i);t++){let r=this.visibleRanges[t],s=n[t];(r.from!=s.from||r.to!=s.to)&&(i|=4,e&&e.mapPos(r.from,-1)==s.from&&e.mapPos(r.to,1)==s.to||(i|=8))}return this.visibleRanges=n,i}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||l1(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)||l1(this.heightMap.lineAt(this.scaler.fromDOM(e),lB.ByHeight,this.heightOracle,0,0),this.scaler)}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return l1(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}constructor(e){this.state=e,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scrollTop=0,this.scrolledToBottom=!1,this.scaleX=1,this.scaleY=1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=lZ,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=oi.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let t=e.facet(oF).some(e=>"function"!=typeof e&&"cm-lineWrapping"==e.class);this.heightOracle=new lP(t),this.stateDeco=e.facet(o_).filter(e=>"function"!=typeof e),this.heightMap=lz.empty().applyChanges(this.stateDeco,iz.empty,this.heightOracle.setDoc(e.doc),[new oG(0,0,0,e.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=s1.set(this.lineGaps.map(e=>e.draw(this,!1))),this.computeVisibleRanges()}}class lQ{constructor(e,t){this.from=e,this.to=t}}function lX(e,t){let{total:n,ranges:i}=e;if(t<=0)return i[0].from;if(t>=1)return i[i.length-1].to;let r=Math.floor(n*t);for(let e=0;;e++){let{from:t,to:n}=i[e],s=n-t;if(r<=s)return t+r;r-=s}}function l$(e,t){let n=0;for(let{from:i,to:r}of e.ranges){if(t<=r){n+=t-i;break}n+=r-i}return n/e.total}let lZ={toDOM:e=>e,fromDOM:e=>e,scale:1,eq(e){return e==this}};class l0{toDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.top)return i+(e-n)*this.scale;if(e<=r.bottom)return r.domTop+(e-r.top);n=r.bottom,i=r.domBottom}}fromDOM(e){for(let t=0,n=0,i=0;;t++){let r=t<this.viewports.length?this.viewports[t]:null;if(!r||e<r.domTop)return n+(e-i)/this.scale;if(e<=r.domBottom)return r.top+(e-r.domTop);n=r.bottom,i=r.domBottom}}eq(e){return e instanceof l0&&this.scale==e.scale&&this.viewports.length==e.viewports.length&&this.viewports.every((t,n)=>t.from==e.viewports[n].from&&t.to==e.viewports[n].to)}constructor(e,t,n){let i=0,r=0,s=0;for(let o of(this.viewports=n.map(n=>{let{from:r,to:s}=n,o=t.lineAt(r,lB.ByPos,e,0,0).top,l=t.lineAt(s,lB.ByPos,e,0,0).bottom;return i+=l-o,{from:r,to:s,top:o,bottom:l,domTop:0,domBottom:0}}),this.scale=(7e6-i)/(t.height-i),this.viewports))o.domTop=s+(o.top-r)*this.scale,s=o.domBottom=o.domTop+(o.bottom-o.top),r=o.bottom}}function l1(e,t){if(1==t.scale)return e;let n=t.toDOM(e.top),i=t.toDOM(e.bottom);return new lI(e.from,e.length,n,i-n,Array.isArray(e._content)?e._content.map(e=>l1(e,t)):e._content)}let l2=rt.define({combine:e=>e.join(" ")}),l3=rt.define({combine:e=>e.indexOf(!0)>-1}),l4=r4.newName(),l5=r4.newName(),l8=r4.newName(),l6={"&light":"."+l5,"&dark":"."+l8};function l9(e,t,n){return new r4(t,{finish:t=>/&/.test(t)?t.replace(/&\w*/,t=>{if("&"==t)return e;if(!n||!n[t])throw RangeError("Unsupported selector: ".concat(t));return n[t]}):e+" "+t})}let l7=l9("."+l4,{"&":{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":{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-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"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{backgroundImage:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 5%)",backgroundPosition:"center"},".cm-highlightTab":{backgroundImage:'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>\')',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"}},l6),ae={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},at=sV.ie&&sV.ie_version<=11;class an{onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){("change"!=e.type&&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]))){for(let t of(this.gapIntersection.disconnect(),e))this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,i=this.selectionRange;if(n.state.facet(oR)?n.root.activeElement!=this.dom:!so(this.dom,i))return;let r=i.anchorNode&&n.docView.nearest(i.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(sV.ie&&sV.ie_version<=11||sV.android&&sV.chrome)&&!n.state.selection.main.empty&&i.focusNode&&sa(i.focusNode,i.focusOffset,i.anchorNode,i.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=sr(e.root);if(!t)return!1;let n=sV.safari&&11==e.root.nodeType&&e.root.activeElement==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ar(e,n)}let n=null;function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener("beforeinput",i,!0),e.dom.ownerDocument.execCommand("indent"),e.contentDOM.removeEventListener("beforeinput",i,!0),n?ar(e,n):null}(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let i=so(this.dom,n);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&function(e,t){let n=t.focusNode,i=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=i)return!1;for(i=Math.min(i,su(n));;)if(i){if(1!=n.nodeType)return!1;let e=n.childNodes[i-1];"false"==e.contentEditable?i--:i=su(n=e)}else{if(n==e)return!0;i=sh(n),n=n.parentNode}}(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),i&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(1==n.nodeType)!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||(t=this.scrollTargets.slice(0,e)),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(11==n.nodeType)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener("scroll",this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener("scroll",this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||(this.observer.observe(this.dom,ae),at&&this.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.active=!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),at&&this.dom.removeEventListener("DOMCharacterDataModified",this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){var n;if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&sb(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}this.delayedAndroidKey&&"Enter"!=e||(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!(null==(n=this.delayedAndroidKey)?void 0:n.force)})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{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,i=!1;for(let r of e){let e=this.readMutation(r);e&&(e.typeOver&&(i=!0),-1==t?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:i}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),i=this.selectionChanged&&so(this.dom,this.selectionRange);if(e<0&&!i)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let r=new li(this.view,e,t,n);return this.view.docView.domChanged={newSel:r.newSel?r.newSel.main:null},r}flush(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return this.view.requestMeasure(),!1;let n=this.view.state,i=lr(this.view,t);return this.view.state==n&&(t.domChanged||t.newSel&&!t.newSel.main.eq(this.view.state.selection.main))&&this.view.update([]),i}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty("attributes"==e.type),"attributes"==e.type&&(t.flags|=4),"childList"==e.type){let n=ai(t,e.previousSibling||e.target.previousSibling,-1),i=ai(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:i?t.posBefore(i):t.posAtEnd,typeOver:!1}}return"characterData"==e.type?{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(oR)!=e.state.facet(oR)&&(e.view.contentDOM.editContext=e.state.facet(oR)?this.editContext.editContext:null))}destroy(){var e,t,n;for(let i of(this.stop(),null==(e=this.intersection)||e.disconnect(),null==(t=this.gapIntersection)||t.disconnect(),null==(n=this.resizeScroll)||n.disconnect(),this.scrollTargets))i.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new sm,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);(sV.ie&&sV.ie_version<=11||sV.ios&&e.composing)&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&sV.android&&!1!==e.constructor.EDIT_CONTEXT&&!(sV.chrome&&sV.chrome_version<126)&&(this.editContext=new as(e),e.state.facet(oR)&&(e.contentDOM.editContext=this.editContext.editContext)),at&&(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")),"function"==typeof ResizeObserver&&(this.resizeScroll=new ResizeObserver(()=>{var e;(null==(e=this.view.docView)?void 0:e.lastUpdate)<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),"function"==typeof IntersectionObserver&&(this.intersection=new IntersectionObserver(e=>{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()}}function ai(e,t,n){for(;t;){let i=sN.get(t);if(i&&i.parent==e)return i;let r=t.parentNode;t=r!=e.dom?r:n>0?t.nextSibling:t.previousSibling}return null}function ar(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,s=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor);return sa(o.node,o.offset,r,s)&&([n,i,r,s]=[r,s,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:s}}class as{applyEdits(e){let t=0,n=!1,i=this.pendingContextChange;return e.changes.iterChanges((r,s,o,l,a)=>{if(n)return;let h=a.length-(s-r);if(i&&s>=i.to)if(i.from==r&&i.to==s&&i.insert.eq(a)){i=this.pendingContextChange=null,t+=h,this.to+=h;return}else i=null,this.revertPending(e.state);if(r+=t,(s+=t)<=this.from)this.from+=h,this.to+=h;else if(r<this.to){if(r<this.from||s>this.to||this.to-this.from+a.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(r),this.toContextPos(s),a.toString()),this.to+=h}t+=h}),i&&!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)?(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state):(this.pendingContextChange=null,this.reset(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))),i=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=i)&&this.editContext.updateSelection(n,i)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]: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])}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)});for(let n in this.handlers.textupdate=t=>{let n=e.state.selection.main,{anchor:i,head:r}=n,s=this.toEditorPos(t.updateRangeStart),o=this.toEditorPos(t.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:t.updateRangeStart,editorBase:s,drifted:!1});let l={from:s,to:o,insert:iz.of(t.text.split("\n"))};if(l.from==this.from&&i<this.from?l.from=i:l.to==this.to&&i>this.to&&(l.to=i),l.from==l.to&&!l.insert.length){let i=i9.single(this.toEditorPos(t.selectionStart),this.toEditorPos(t.selectionEnd));i.main.eq(n)||e.dispatch({selection:i,userEvent:"select"});return}if((sV.mac||sV.android)&&l.from==r-1&&/^\. ?$/.test(t.text)&&"off"==e.contentDOM.getAttribute("autocorrect")&&(l={from:s,to:o,insert:iz.of([t.text.replace("."," ")])}),this.pendingContextChange=l,!e.state.readOnly){let n=this.to-this.from+(l.to-l.from+l.insert.length);ls(e,l,i9.single(this.toEditorPos(t.selectionStart,n),this.toEditorPos(t.selectionEnd,n)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state))},this.handlers.characterboundsupdate=n=>{let i=[],r=null;for(let t=this.toEditorPos(n.rangeStart),s=this.toEditorPos(n.rangeEnd);t<s;t++){let n=e.coordsForChar(t);r=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||r||new DOMRect,i.push(r)}t.updateCharacterBounds(n.rangeStart,i)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,i=e.underlineThickness;if("None"!=t&&"None"!=i){let r=this.toEditorPos(e.rangeStart),s=this.toEditorPos(e.rangeEnd);if(r<s){let e="text-decoration: underline ".concat("Dashed"==t?"dashed ":"Squiggle"==t?"wavy ":"").concat("Thin"==i?1:2,"px");n.push(s1.mark({attributes:{style:e}}).range(r,s))}}}e.dispatch({effects:oT.of(s1.set(n))})},this.handlers.compositionstart=()=>{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)}},this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:e=>{this.editContext.updateControlBounds(e.contentDOM.getBoundingClientRect());let t=sr(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}}class ao{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}dispatch(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=1==t.length&&t[0]instanceof rO?t:1==t.length&&Array.isArray(t[0])?t[0]:[this.state.update(...t)];this.dispatchTransactions(i,this)}update(e){if(0!=this.updateState)throw Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,i,r=this.state;for(let t of e){if(t.startState!=r)throw RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=t.state}if(this.destroyed){this.viewState.state=r;return}let s=this.hasFocus,o=0,l=null;e.some(e=>e.annotation(lO))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,(l=lj(r,s))||(o=1));let a=this.observer.delayedAndroidKey,h=null;if(a?(this.observer.clearDelayedAndroidKey(),((h=this.observer.readChange())&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(h=null)):this.observer.clear(),r.facet(rL.phrases)!=this.state.facet(rL.phrases))return this.setState(r);i=oY.create(this,r,e),i.flags|=o;let c=this.viewState.scrollTarget;try{for(let t of(this.updateState=2,e)){if(c&&(c=c.map(t.changes)),t.scrollIntoView){let{main:e}=t.state.selection;c=new oj(e.empty?e:i9.cursor(e.head,e.head>e.anchor?-1:1))}for(let e of t.effects)e.is(oE)&&(c=e.value.clip(this.state))}this.viewState.update(i,c),this.bidiCache=ah.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),t=this.docView.update(i),this.state.facet(oJ)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(e=>e.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(l2)!=i.state.facet(l2)&&(this.viewState.mustMeasureContent=!0),(t||n||c||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(ow))try{e(i)}catch(e){oD(this.state,e,"update listener")}(l||h)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),h&&!lr(this,h)&&a.force&&sb(this.contentDOM,a.key,a.keyCode)})}setState(e){if(0!=this.updateState)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);for(let t of(this.viewState=new lY(e),this.plugins=e.facet(oL).map(e=>new oB(e)),this.pluginMap.clear(),this.plugins))t.update(this);this.docView.destroy(),this.docView=new oQ(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(oL),n=e.state.facet(oL);if(t!=n){let i=[];for(let r of n){let n=t.indexOf(r);if(n<0)i.push(new oB(r));else{let t=this.plugins[n];t.mustUpdate=e,i.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=i,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){oD(this.state,e,"doc view update listener")}}}measure(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];if(this.destroyed)return;if(this.measureScheduled>-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.scrollDOM,i=n.scrollTop*this.scaleY,{scrollAnchorPos:r,scrollAnchorHeight:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(s<0)if(sw(n))r=-1,s=this.viewState.heightMap.height;else{let e=this.viewState.scrollAnchorAt(i);r=e.from,s=e.top}this.updateState=1;let o=this.viewState.measure(this);if(!o&&!this.measureRequests.length&&null==this.viewState.scrollTarget)break;if(e>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let l=[];4&o||([this.measureRequests,l]=[l,this.measureRequests]);let a=l.map(e=>{try{return e.read(this)}catch(e){return oD(this.state,e),aa}}),h=oY.create(this,this.state,[]),c=!1;h.flags|=o,t?t.flags|=o:t=h,this.updateState=2,!h.empty&&(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),(c=this.docView.update(h))&&this.docViewUpdate());for(let e=0;e<l.length;e++)if(a[e]!=aa)try{let t=l[e];t.write&&t.write(a[e],this)}catch(e){oD(this.state,e)}if(c&&this.docView.updateSelection(!0),!h.viewportChanged&&0==this.measureRequests.length){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let e=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-s;if(e>1||e<-1){n.scrollTop=(i+=e)/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(ow))e(t)}get themeClasses(){return l4+" "+(this.state.facet(l3)?l8:l5)+" "+this.state.facet(l2)}updateAttrs(){let e=ac(this,oz,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(oR)?"true":"false",class:"cm-content",style:"".concat(sV.tabSize,": ").concat(this.state.tabSize),role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),ac(this,oF,t);let n=this.observer.ignore(()=>{let n=s$(this.contentDOM,this.contentAttrs,t),i=s$(this.dom,this.editorAttrs,e);return n||i});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let e of n.effects)e.is(ao.announce)&&(t&&(this.announceDOM.textContent=""),t=!1,this.announceDOM.appendChild(document.createElement("div")).textContent=e.value)}mountStyles(){this.styleModules=this.state.facet(oJ);let e=this.state.facet(ao.cspNonce);r4.mount(this.root,this.styleModules.concat(l7).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(2==this.updateState)throw Error("Reading the editor layout isn't allowed during an update");0==this.updateState&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if((this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e)&&!(this.measureRequests.indexOf(e)>-1)){if(null!=e.key){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(void 0===t||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.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 le(this,e,o6(this,e,t,n))}moveByGroup(e,t){return le(this,e,o6(this,e,t,t=>{var n;let i,r;return n=e.head,r=(i=this.state.charCategorizer(n))(t),e=>{let t=i(e);return r==rR.Space&&(r=t),r==t}}))}visualLineSide(e,t){let n=this.bidiSpans(e),i=this.textDirectionAt(e.from),r=n[t?n.length-1:0];return i9.cursor(r.side(t,i)+e.from,r.forward(!t,i)?1:-1)}moveToLineBoundary(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return function(e,t,n,i){let r=o8(e,t.head,t.assoc||-1),s=i&&r.type==s0.Text&&(e.lineWrapping||r.widgetLineBreaks)?e.coordsAtPos(t.assoc<0&&t.head>r.from?t.head-1:t.head):null;if(s){let t=e.dom.getBoundingClientRect(),i=e.textDirectionAt(r.from),o=e.posAtCoords({x:n==(i==oi.LTR)?t.right-1:t.left+1,y:(s.top+s.bottom)/2});if(null!=o)return i9.cursor(o,n?-1:1)}return i9.cursor(n?r.to:r.from,n?-1:1)}(this,e,t,n)}moveVertically(e,t,n){return le(this,e,function(e,t,n,i){let r=t.head,s=n?1:-1;if(r==(n?e.state.doc.length:0))return i9.cursor(r,t.assoc);let o=t.goalColumn,l,a=e.contentDOM.getBoundingClientRect(),h=e.coordsAtPos(r,t.assoc||-1),c=e.documentTop;if(h)null==o&&(o=h.left-a.left),l=s<0?h.top:h.bottom;else{let t=e.viewState.lineBlockAt(r);null==o&&(o=Math.min(a.right-a.left,e.defaultCharacterWidth*(r-t.from))),l=(s<0?t.top:t.bottom)+c}let d=a.left+o,u=null!=i?i:e.viewState.heightOracle.textHeight>>1;for(let t=0;;t+=10){let n=l+(u+t)*s,i=o3(e,{x:d,y:n},!1,s);if(n<a.top||n>a.bottom||(s<0?i<r:i>r)){let t=e.docView.coordsForChar(i),r=!t||n<t.top?-1:1;return i9.cursor(i,r,void 0,o)}}}(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.docView.posFromDOM(e,t)}posAtCoords(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];return this.readMeasured(),o3(this,e,t)}coordsAtPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let i=this.state.doc.lineAt(e),r=this.bidiSpans(i);return sf(n,r[of.find(r,e-i.from,-1,t)].dir==oi.LTR==t>0)}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(oN)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>al)return om(e.length);let t=this.textDirectionAt(e.from),n;for(let i of this.bidiCache)if(i.from==e.from&&i.dir==t&&(i.fresh||function e(t,n){if(t.length!=n.length)return!1;for(let i=0;i<t.length;i++){let r=t[i],s=n[i];if(r.from!=s.from||r.to!=s.to||r.direction!=s.direction||!e(r.inner,s.inner))return!1}return!0}(i.isolates,n=oq(this,e))))return i.order;n||(n=oq(this,e));let i=function(e,t,n){if(!e)return[new of(0,0,+(t==os))];if(t==or&&!n.length&&!ou.test(e))return om(e.length);if(n.length)for(;e.length>op.length;)op[op.length]=256;let i=[],r=+(t!=or);return function e(t,n,i,r,s,o,l){let a=n%2?2:1;!function(e,t,n,i,r){for(let s=0;s<=i.length;s++){let o=s?i[s-1].to:t,l=s<i.length?i[s].from:n,a=s?256:r;for(let t=o,n=a,i=a;t<l;t++){let r=od(e.charCodeAt(t));512==r?r=n:8==r&&4==i&&(r=16),op[t]=4==r?2:r,7&r&&(i=r),n=r}for(let e=o,t=a,i=a;e<l;e++){let r=op[e];if(128==r)e<l-1&&t==op[e+1]&&24&t?r=op[e]=t:op[e]=256;else if(64==r){let r=e+1;for(;r<l&&64==op[r];)r++;let s=e&&8==t||r<n&&8==op[r]?1==i?1:8:256;for(let t=e;t<r;t++)op[t]=s;e=r-1}else 8==r&&1==i&&(op[e]=1);t=r,7&r&&(i=r)}}}(t,s,o,r,a),function(e,t,n,i,r){let s=1==r?2:1;for(let o=0,l=0,a=0;o<=i.length;o++){let h=o?i[o-1].to:t,c=o<i.length?i[o].from:n;for(let t=h,n,i,o;t<c;t++)if(i=oh[n=e.charCodeAt(t)])if(i<0){for(let e=l-3;e>=0;e-=3)if(oc[e+1]==-i){let n=oc[e+2],i=2&n?r:4&n?1&n?s:r:0;i&&(op[t]=op[oc[e]]=i),l=e;break}}else if(189==oc.length)break;else oc[l++]=t,oc[l++]=n,oc[l++]=a;else if(2==(o=op[t])||1==o){let e=o==r;a=+!e;for(let t=l-3;t>=0;t-=3){let n=oc[t+2];if(2&n)break;if(e)oc[t+2]|=2;else{if(4&n)break;oc[t+2]|=4}}}}}(t,s,o,r,a),function(e,t,n,i){for(let r=0,s=i;r<=n.length;r++){let o=r?n[r-1].to:e,l=r<n.length?n[r].from:t;for(let a=o;a<l;){let o=op[a];if(256==o){let o=a+1;for(;;)if(o==l){if(r==n.length)break;o=n[r++].to,l=r<n.length?n[r].from:t}else if(256==op[o])o++;else break;let h=1==s,c=h==((o<t?op[o]:i)==1)?h?1:2:i;for(let t=o,i=r,s=i?n[i-1].to:e;t>a;)t==s&&(t=n[--i].from,s=i?n[i-1].to:e),op[--t]=c;a=o}else s=o,a++}}}(s,o,r,a),function t(n,i,r,s,o,l,a){let h=s%2?2:1;if(s%2==o%2)for(let c=i,d=0;c<r;){let i=!0,u=!1;if(d==l.length||c<l[d].from){let e=op[c];e!=h&&(i=!1,u=16==e)}let f=i||1!=h?null:[],p=i?s:s+1,m=c;t:for(;;)if(d<l.length&&m==l[d].from){if(u)break;let t=l[d];if(!i)for(let e=t.to,n=d+1;;){if(e==r)break t;if(n<l.length&&l[n].from==e)e=l[n++].to;else if(op[e]==h)break t;else break}d++,f?f.push(t):(t.from>c&&a.push(new of(c,t.from,p)),e(n,t.direction==or!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.to),m=t.to}else if(m==r||(i?op[m]!=h:op[m]==h))break;else m++;f?t(n,c,m,s+1,o,f,a):c<m&&a.push(new of(c,m,p)),c=m}else for(let c=r,d=l.length;c>i;){let r=!0,u=!1;if(!d||c>l[d-1].to){let e=op[c-1];e!=h&&(r=!1,u=16==e)}let f=r||1!=h?null:[],p=r?s:s+1,m=c;t:for(;;)if(d&&m==l[d-1].to){if(u)break;let t=l[--d];if(!r)for(let e=t.from,n=d;;){if(e==i)break t;if(n&&l[n-1].to==e)e=l[--n].from;else if(op[e-1]==h)break t;else break}f?f.push(t):(t.to<c&&a.push(new of(t.to,c,p)),e(n,t.direction==or!=!(p%2)?s+1:s,o,t.inner,t.from,t.to,a),c=t.from),m=t.from}else if(m==i||(r?op[m-1]!=h:op[m-1]==h))break;else m--;f?t(n,m,c,s+1,o,f,a):m<c&&a.push(new of(m,c,p)),c=m}}(t,s,o,n,i,r,l)}(e,r,r,n,0,e.length,i),i}(e.text,t,n);return this.bidiCache.push(new ah(e.from,e.to,t,n,!0,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||sV.safari&&(null==(e=this.inputState)?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{sv(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((9==e.nodeType?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of(this.root.activeElement==this.contentDOM&&this.contentDOM.blur(),this.plugins))e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return oE.of(new oj("number"==typeof e?i9.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return oE.of(new oj(i9.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){null==e?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:"boolean"==typeof e?this.inputState.tabFocusMode=e?0:-1:0!=this.inputState.tabFocusMode&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return oI.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return oI.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=r4.newName(),i=[l2.of(n),oJ.of(l9(".".concat(n),e))];return t&&t.dark&&i.push(l3.of(!0)),i}static baseTheme(e){return rc.lowest(oJ.of(l9("."+l4,e,l6)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),i=n&&sN.get(n)||sN.get(e);return(null==(t=null==i?void 0:i.rootView)?void 0:t.view)||null}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;for(let t of(this.dispatchTransactions=e.dispatchTransactions||n&&(e=>e.forEach(e=>n(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||function(e){for(;e;){if(e&&(9==e.nodeType||11==e.nodeType&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}(e.parent)||document,this.viewState=new lY(e.state||rL.create(e)),e.scrollTo&&e.scrollTo.is(oE)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(oL).map(e=>new oB(e)),this.plugins))t.update(this);this.observer=new an(this),this.inputState=new lo(this),this.inputState.ensureHandlers(this.plugins),this.docView=new oQ(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),(null==(t=document.fonts)?void 0:t.ready)&&document.fonts.ready.then(()=>this.requestMeasure())}}ao.styleModule=oJ,ao.inputHandler=ok,ao.clipboardInputFilter=oC,ao.clipboardOutputFilter=oA,ao.scrollHandler=oO,ao.focusChangeEffect=oS,ao.perLineTextDirection=oN,ao.exceptionSink=oy,ao.updateListener=ow,ao.editable=oR,ao.mouseSelectionStyle=ob,ao.dragMovesSelection=ox,ao.clickAddsSelectionRange=ov,ao.decorations=o_,ao.outerDecorations=oW,ao.atomicRanges=oV,ao.bidiIsolatedRanges=oH,ao.scrollMargins=oK,ao.darkTheme=l3,ao.cspNonce=rt.define({combine:e=>e.length?e[0]:""}),ao.contentAttributes=oF,ao.editorAttributes=oz,ao.lineWrapping=ao.contentAttributes.of({class:"cm-lineWrapping"}),ao.announce=rM.define();let al=4096,aa={};class ah{static update(e,t){if(t.empty&&!e.some(e=>e.fresh))return e;let n=[],i=e.length?e[e.length-1].dir:oi.LTR;for(let r=Math.max(0,e.length-10);r<e.length;r++){let s=e[r];s.dir!=i||t.touchesRange(s.from,s.to)||n.push(new ah(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return n}constructor(e,t,n,i,r,s){this.from=e,this.to=t,this.dir=n,this.isolates=i,this.fresh=r,this.order=s}}function ac(e,t,n){for(let i=e.state.facet(t),r=i.length-1;r>=0;r--){let t=i[r],s="function"==typeof t?t(e):t;s&&sY(s,n)}return n}let ad=sV.mac?"mac":sV.windows?"win":sV.linux?"linux":"key";function au(e,t,n){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),!1!==n&&t.shiftKey&&(e="Shift-"+e),e}let af=rc.default(ao.domEventHandlers({keydown:(e,t)=>ab(ag(t.state),e,t,"editor")})),ap=rt.define({enables:af}),am=new WeakMap;function ag(e){let t=e.facet(ap),n=am.get(t);return n||am.set(t,n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ad,n=Object.create(null),i=Object.create(null),r=(e,t)=>{let n=i[e];if(null==n)i[e]=t;else if(n!=t)throw Error("Key binding "+e+" is used both as a regular binding and as a multi-stroke prefix")},s=(e,i,s,o,l)=>{var a,h;let c=n[e]||(n[e]=Object.create(null)),d=i.split(/ (?!$)/).map(e=>(function(e,t){let n,i,r,s,o=e.split(/-(?!$)/),l=o[o.length-1];"Space"==l&&(l=" ");for(let e=0;e<o.length-1;++e){let l=o[e];if(/^(cmd|meta|m)$/i.test(l))s=!0;else if(/^a(lt)?$/i.test(l))n=!0;else if(/^(c|ctrl|control)$/i.test(l))i=!0;else if(/^s(hift)?$/i.test(l))r=!0;else if(/^mod$/i.test(l))"mac"==t?s=!0:i=!0;else throw Error("Unrecognized modifier name: "+l)}return n&&(l="Alt-"+l),i&&(l="Ctrl-"+l),s&&(l="Meta-"+l),r&&(l="Shift-"+l),l})(e,t));for(let t=1;t<d.length;t++){let n=d.slice(0,t).join(" ");r(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let i=av={view:t,prefix:n,scope:e};return setTimeout(()=>{av==i&&(av=null)},4e3),!0}]})}let u=d.join(" ");r(u,!1);let f=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(null==(h=null==(a=c._any)?void 0:a.run)?void 0:h.slice())||[]});s&&f.run.push(s),o&&(f.preventDefault=!0),l&&(f.stopPropagation=!0)};for(let i of e){let e=i.scope?i.scope.split(" "):["editor"];if(i.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||(e._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:r}=i;for(let t in e)e[t].run.push(e=>r(e,ax))}let r=i[t]||i.key;if(r)for(let t of e)s(t,r,i.run,i.preventDefault,i.stopPropagation),i.shift&&s(t,"Shift-"+r,i.shift,i.preventDefault,i.stopPropagation)}return n}(t.reduce((e,t)=>e.concat(t),[]))),n}let av=null,ax=null;function ab(e,t,n,i){var r;ax=t;let s=("Esc"==(r=!(r7&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||se&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?r9:r6)[t.keyCode]||t.key||"Unidentified")&&(r="Escape"),"Del"==r&&(r="Delete"),"Left"==r&&(r="ArrowLeft"),"Up"==r&&(r="ArrowUp"),"Right"==r&&(r="ArrowRight"),"Down"==r&&(r="ArrowDown"),r),o=iQ(iG(s,0))==s.length&&" "!=s,l="",a=!1,h=!1,c=!1;av&&av.view==n&&av.scope==i&&(l=av.prefix+" ",0>lc.indexOf(t.keyCode)&&(h=!0,av=null));let d=new Set,u=e=>{if(e){for(let t of e.run)if(!d.has(t)&&(d.add(t),t(n)))return e.stopPropagation&&(c=!0),!0;e.preventDefault&&(e.stopPropagation&&(c=!0),h=!0)}return!1},f=e[i],p,m;return f&&(u(f[l+au(s,t,!o)])?a=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(sV.windows&&t.ctrlKey&&t.altKey)&&!(sV.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=r6[t.keyCode])&&p!=s?u(f[l+au(p,t,!0)])?a=!0:t.shiftKey&&(m=r9[t.keyCode])!=s&&m!=p&&u(f[l+au(m,t,!1)])&&(a=!0):o&&t.shiftKey&&u(f[l+au(s,t,!0)])&&(a=!0),!a&&u(f._any)&&(a=!0)),h&&(a=!0),a&&c&&t.stopPropagation(),ax=null,a}class ay{draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className==this.className&&(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",null!=this.width&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(!n.empty)return function(e,t,n){if(n.to<=e.viewport.from||n.from>=e.viewport.to)return[];let i=Math.max(n.from,e.viewport.from),r=Math.min(n.to,e.viewport.to),s=e.textDirection==oi.LTR,o=e.contentDOM,l=o.getBoundingClientRect(),a=aw(e),h=o.querySelector(".cm-line"),c=h&&window.getComputedStyle(h),d=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),u=l.right-(c?parseInt(c.paddingRight):0),f=o8(e,i,1),p=o8(e,r,-1),m=f.type==s0.Text?f:null,g=p.type==s0.Text?p:null;if(m&&(e.lineWrapping||f.widgetLineBreaks)&&(m=ak(e,i,1,m)),g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=ak(e,r,-1,g)),m&&g&&m.from==g.from&&m.to==g.to)return x(b(n.from,n.to,m));{let t=m?b(n.from,null,m):y(f,!1),i=g?b(null,n.to,g):y(p,!0),r=[];return(m||f).to<(g||p).from-(m&&g?1:0)||f.widgetLineBreaks>1&&t.bottom+e.defaultLineHeight/2<i.top?r.push(v(d,t.bottom,u,i.top)):t.bottom<i.top&&e.elementAtHeight((t.bottom+i.top)/2).type==s0.Text&&(t.bottom=i.top=(t.bottom+i.top)/2),x(t).concat(r).concat(x(i))}function v(e,n,i,r){return new ay(t,e-a.left,n-a.top,i-e,r-n)}function x(e){let{top:t,bottom:n,horizontal:i}=e,r=[];for(let e=0;e<i.length;e+=2)r.push(v(i[e],t,i[e+1],n));return r}function b(t,n,i){let r=1e9,o=-1e9,l=[];function a(t,n,a,h,c){let f=e.coordsAtPos(t,t==i.to?-2:2),p=e.coordsAtPos(a,a==i.from?2:-2);f&&p&&(r=Math.min(f.top,p.top,r),o=Math.max(f.bottom,p.bottom,o),c==oi.LTR?l.push(s&&n?d:f.left,s&&h?u:p.right):l.push(!s&&h?d:p.left,!s&&n?u:f.right))}let h=null!=t?t:i.from,c=null!=n?n:i.to;for(let i of e.visibleRanges)if(i.to>h&&i.from<c)for(let r=Math.max(i.from,h),s=Math.min(i.to,c);;){let i=e.state.doc.lineAt(r);for(let o of e.bidiSpans(i)){let e=o.from+i.from,l=o.to+i.from;if(e>=s)break;l>r&&a(Math.max(e,r),null==t&&e<=h,Math.min(l,s),null==n&&l>=c,o.dir)}if((r=i.to+1)>=s)break}return 0==l.length&&a(h,null==t,c,null==n,e.textDirection),{top:r,bottom:o,horizontal:l}}function y(e,t){let n=l.top+(t?e.top:e.bottom);return{top:n,bottom:n,horizontal:[]}}}(e,t,n);{let i=e.coordsAtPos(n.head,n.assoc||1);if(!i)return[];let r=aw(e);return[new ay(t,i.left-r.left,i.top-r.top,null,i.bottom-i.top)]}}constructor(e,t,n,i,r){this.className=e,this.left=t,this.top=n,this.width=i,this.height=r}}function aw(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==oi.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function ak(e,t,n,i){let r=e.coordsAtPos(t,2*n);if(!r)return i;let s=e.dom.getBoundingClientRect(),o=(r.top+r.bottom)/2,l=e.posAtCoords({x:s.left+1,y:o}),a=e.posAtCoords({x:s.right-1,y:o});return null==l||null==a?i:{from:Math.max(i.from,Math.min(l,a)),to:Math.min(i.to,Math.max(l,a))}}class aS{update(e){e.startState.facet(aC)!=e.state.facet(aC)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){!1!==this.layer.updateOnDocViewUpdate&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(aC);for(;t<n.length&&n[t]!=this.layer;)t++;this.dom.style.zIndex=String((this.layer.above?150:-1)-t)}measure(){return this.layer.markers(this.view)}scale(){let{scaleX:e,scaleY:t}=this.view;(e!=this.scaleX||t!=this.scaleY)&&(this.scaleX=e,this.scaleY=t,this.dom.style.transform="scale(".concat(1/e,", ").concat(1/t,")"))}draw(e){if(e.length!=this.drawn.length||e.some((e,t)=>{var n;return n=this.drawn[t],!(e.constructor==n.constructor&&e.eq(n))})){let t=this.dom.firstChild,n=0;for(let i of e)i.update&&t&&i.constructor&&this.drawn[n].constructor&&i.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(i.draw(),t);for(;t;){let e=t.nextSibling;t.remove(),t=e}this.drawn=e,sV.ios&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}}let aC=rt.define();function aA(e){return[oI.define(t=>new aS(t,e)),aC.of(e)]}let aN=rt.define({combine:e=>rI(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})});function aM(e){return e.startState.facet(aN)!=e.state.facet(aN)}let aO=aA({above:!0,markers(e){let{state:t}=e,n=t.facet(aN),i=[];for(let r of t.selection.ranges){let s=r==t.selection.main;if(r.empty||n.drawRangeCursor){let t=s?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",n=r.empty?r:i9.cursor(r.head,r.head>r.anchor?-1:1);for(let r of ay.forRange(e,t,n))i.push(r)}}return i},update(e,t){e.transactions.some(e=>e.selection)&&(t.style.animationName="cm-blink"==t.style.animationName?"cm-blink2":"cm-blink");let n=aM(e);return n&&aj(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){aj(t.state,e)},class:"cm-cursorLayer"});function aj(e,t){t.style.animationDuration=e.facet(aN).cursorBlinkRate+"ms"}let aE=aA({above:!1,markers:e=>e.state.selection.ranges.map(t=>t.empty?[]:ay.forRange(e,"cm-selectionBackground",t)).reduce((e,t)=>e.concat(t)),update:(e,t)=>e.docChanged||e.selectionSet||e.viewportChanged||aM(e),class:"cm-selectionLayer"}),aT=rc.highest(ao.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),aD=rM.define({map:(e,t)=>null==e?null:t.mapPos(e)}),aR=rl.define({create:()=>null,update:(e,t)=>(null!=e&&(e=t.changes.mapPos(e)),t.effects.reduce((e,t)=>t.is(aD)?t.value:e,e))}),aP=oI.fromClass(class{update(e){var t;let n=e.state.field(aR);null==n?null!=this.cursor&&(null==(t=this.cursor)||t.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(e.startState.field(aR)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(aR),n=null!=t&&e.coordsAtPos(t);if(!n)return null;let i=e.scrollDOM.getBoundingClientRect();return{left:n.left-i.left+e.scrollDOM.scrollLeft*e.scaleX,top:n.top-i.top+e.scrollDOM.scrollTop*e.scaleY,height:n.bottom-n.top}}drawCursor(e){if(this.cursor){let{scaleX:t,scaleY:n}=this.view;e?(this.cursor.style.left=e.left/t+"px",this.cursor.style.top=e.top/n+"px",this.cursor.style.height=e.height/n+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(e){this.view.state.field(aR)!=e&&this.view.dispatch({effects:aD.of(e)})}constructor(e){this.view=e,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}},{eventObservers:{dragover(e){this.setDropPos(this.view.posAtCoords({x:e.clientX,y:e.clientY}))},dragleave(e){e.target!=this.view.contentDOM&&this.view.contentDOM.contains(e.relatedTarget)||this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function aL(e,t,n,i,r){t.lastIndex=0;for(let s=e.iterRange(n,i),o=n,l;!s.next().done;o+=s.value.length)if(!s.lineBreak)for(;l=t.exec(s.value);)r(o+l.index,l)}class aI{createDeco(e){let t=new rV,n=t.add.bind(t);for(let{from:t,to:i}of function(e,t){let n=e.visibleRanges;if(1==n.length&&n[0].from==e.viewport.from&&n[0].to==e.viewport.to)return n;let i=[];for(let{from:r,to:s}of n)r=Math.max(e.state.doc.lineAt(r).from,r-t),s=Math.min(e.state.doc.lineAt(s).to,s+t),i.length&&i[i.length-1].to>=r?i[i.length-1].to=s:i.push({from:r,to:s});return i}(e,this.maxLength))aL(e.state.doc,this.regexp,t,i,(t,i)=>this.addMatch(i,e,t,n));return t.finish()}updateDeco(e,t){let n=1e9,i=-1;return(e.docChanged&&e.changes.iterChanges((t,r,s,o)=>{o>=e.view.viewport.from&&s<=e.view.viewport.to&&(n=Math.min(s,n),i=Math.max(o,i))}),e.viewportMoved||i-n>1e3)?this.createDeco(e.view):i>-1?this.updateRange(e.view,t.map(e.changes),n,i):t}updateRange(e,t,n,i){for(let r of e.visibleRanges){let s=Math.max(r.from,n),o=Math.min(r.to,i);if(o>=s){let n=e.state.doc.lineAt(s),i=n.to<o?e.state.doc.lineAt(o):n,l=Math.max(r.from,n.from),a=Math.min(r.to,i.to);if(this.boundary){for(;s>n.from;s--)if(this.boundary.test(n.text[s-1-n.from])){l=s;break}for(;o<i.to;o++)if(this.boundary.test(i.text[o-i.from])){a=o;break}}let h=[],c,d=(e,t,n)=>h.push(n.range(e,t));if(n==i)for(this.regexp.lastIndex=l-n.from;(c=this.regexp.exec(n.text))&&c.index<a-n.from;)this.addMatch(c,e,c.index+n.from,d);else aL(e.state.doc,this.regexp,l,a,(t,n)=>this.addMatch(n,e,t,d));t=t.update({filterFrom:l,filterTo:a,filter:(e,t)=>e<l||t>a,add:h})}}return t}constructor(e){let{regexp:t,decoration:n,decorate:i,boundary:r,maxLength:s=1e3}=e;if(!t.global)throw RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,i)this.addMatch=(e,t,n,r)=>i(r,n,n+e[0].length,e,t);else if("function"==typeof n)this.addMatch=(e,t,i,r)=>{let s=n(e,t,i);s&&r(i,i+e[0].length,s)};else if(n)this.addMatch=(e,t,i,r)=>r(i,i+e[0].length,n);else throw RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=s}}let aB=null!=/x/.unicode?"gu":"g",az=RegExp("[\0-\b\n-\x1f-\u2028\u2029\uFEFF-]",aB),aF={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"},a_=null,aW=rt.define({combine(e){let t=rI(e,{render:null,specialChars:az,addSpecialChars:null});return(t.replaceTabs=!function(){var e;if(null==a_&&"undefined"!=typeof document&&document.body){let t=document.body.style;a_=(null!=(e=t.tabSize)?e:t.MozTabSize)!=null}return a_||!1}())&&(t.specialChars=RegExp(" |"+t.specialChars.source,aB)),t.addSpecialChars&&(t.specialChars=RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,aB)),t}}),aV=null;class aH extends sZ{eq(e){return e.code==this.code}toDOM(e){var t;let n=(t=this.code)>=32?"•":10==t?"":String.fromCharCode(9216+t),i=e.state.phrase("Control character")+" "+(aF[this.code]||"0x"+this.code.toString(16)),r=this.options.render&&this.options.render(this.code,i,n);if(r)return r;let s=document.createElement("span");return s.textContent=n,s.title=i,s.setAttribute("aria-label",i),s.className="cm-specialChar",s}ignoreEvent(){return!1}constructor(e,t){super(),this.options=e,this.code=t}}class aq extends sZ{eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}constructor(e){super(),this.width=e}}let aK=s1.line({class:"cm-activeLine"}),aU=oI.fromClass(class{update(e){(e.docChanged||e.selectionSet)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=-1,n=[];for(let i of e.state.selection.ranges){let r=e.lineBlockAt(i.head);r.from>t&&(n.push(aK.range(r.from)),t=r.from)}return s1.set(n)}constructor(e){this.decorations=this.getDeco(e)}},{decorations:e=>e.decorations});class aJ extends sZ{toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild("string"==typeof this.content?document.createTextNode(this.content):"function"==typeof this.content?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?sl(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),i=sf(t[0],"rtl"!=n.direction),r=parseInt(n.lineHeight);return i.bottom-i.top>1.5*r?{left:i.left,right:i.right,top:i.top,bottom:i.top+r}:i}ignoreEvent(){return!1}constructor(e){super(),this.content=e}}function aG(e,t){var n;let i,r=e.posAtCoords({x:t.clientX,y:t.clientY},!1),s=e.state.doc.lineAt(r),o=r-s.from,l=o>2e3?-1:o==s.length?(n=t.clientX,(i=e.coordsAtPos(e.viewport.from))?Math.round(Math.abs((i.left-n)/e.defaultCharacterWidth)):-1):rZ(s.text,e.state.tabSize,r-s.from);return{line:s.number,col:l,off:o}}let aY={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},aQ={style:"cursor: crosshair"},aX="-10000px";class a${update(e,t){var n;let i=e.state.facet(this.facet),r=i.filter(e=>e);if(i===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let s=[],o=t?[]:null;for(let n=0;n<r.length;n++){let i=r[n],l=-1;if(i){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==i.create&&(l=e)}if(l<0)s[n]=this.createTooltipView(i,n?s[n-1]:null),o&&(o[n]=!!i.above);else{let i=s[n]=this.tooltipViews[l];o&&(o[n]=t[l]),i.update&&i.update(e)}}}for(let e of this.tooltipViews)0>s.indexOf(e)&&(this.removeTooltipView(e),null==(n=e.destroy)||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=i,this.tooltips=r,this.tooltipViews=s,!0}constructor(e,t,n,i){this.facet=t,this.createTooltipView=n,this.removeTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let r=null;this.tooltipViews=this.tooltips.map(e=>r=n(e,r))}}function aZ(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}let a0=rt.define({combine:e=>{var t,n,i;return{position:sV.ios?"absolute":(null==(t=e.find(e=>e.position))?void 0:t.position)||"fixed",parent:(null==(n=e.find(e=>e.parent))?void 0:n.parent)||null,tooltipSpace:(null==(i=e.find(e=>e.tooltipSpace))?void 0:i.tooltipSpace)||aZ}}}),a1=new WeakMap,a2=oI.fromClass(class{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)for(let e of(this.intersectionObserver.disconnect(),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,i=e.state.facet(a0);if(i.position!=this.position&&!this.madeAbsolute){for(let e of(this.position=i.position,this.manager.tooltipViews))e.dom.style.position=this.position;n=!0}if(i.parent!=this.parent){for(let e of(this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer(),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),i=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=aX,n.dom.style.left="0px",this.container.insertBefore(n.dom,i),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;for(let t of(this.view.win.removeEventListener("resize",this.measureSoon),this.manager.tooltipViews))t.dom.remove(),null==(e=t.destroy)||e.call(t);this.parent&&this.container.remove(),null==(t=this.resizeObserver)||t.disconnect(),null==(n=this.intersectionObserver)||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1;if("fixed"==this.position&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(sV.gecko)n=e.offsetParent!=this.container.ownerDocument.body;else if(e.style.top==aX&&"0px"==e.style.left){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}}if(n||"absolute"==this.position)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);let i=this.view.scrollDOM.getBoundingClientRect(),r=oU(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.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(e=>{let{dom:t}=e;return t.getBoundingClientRect()}),space:this.view.state.facet(a0).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute)for(let e of(this.madeAbsolute=!0,this.position="absolute",this.manager.tooltipViews))e.dom.style.position="absolute";let{visible:n,space:i,scaleX:r,scaleY:s}=e,o=[];for(let l=0;l<this.manager.tooltips.length;l++){let a=this.manager.tooltips[l],h=this.manager.tooltipViews[l],{dom:c}=h,d=e.pos[l],u=e.size[l];if(!d||!1!==a.clip&&(d.bottom<=Math.max(n.top,i.top)||d.top>=Math.min(n.bottom,i.bottom)||d.right<Math.max(n.left,i.left)-.1||d.left>Math.min(n.right,i.right)+.1)){c.style.top=aX;continue}let f=a.arrow?h.dom.querySelector(".cm-tooltip-arrow"):null,p=7*!!f,m=u.right-u.left,g=null!=(t=a1.get(h))?t:u.bottom-u.top,v=h.offset||a5,x=this.view.textDirection==oi.LTR,b=u.width>i.right-i.left?x?i.left:i.right-u.width:x?Math.max(i.left,Math.min(d.left-14*!!f+v.x,i.right-m)):Math.min(Math.max(i.left,d.left-m+14*!!f-v.x),i.right-m),y=this.above[l];!a.strictSide&&(y?d.top-g-p-v.y<i.top:d.bottom+g+p+v.y>i.bottom)&&y==i.bottom-d.bottom>d.top-i.top&&(y=this.above[l]=!y);let w=(y?d.top-i.top:i.bottom-d.bottom)-p;if(w<g&&!1!==h.resize){if(w<this.view.defaultLineHeight){c.style.top=aX;continue}a1.set(h,g),c.style.height=(g=w)/s+"px"}else c.style.height&&(c.style.height="");let k=y?d.top-g-p-v.y:d.bottom+p+v.y,S=b+m;if(!0!==h.overlap)for(let e of o)e.left<S&&e.right>b&&e.top<k+g&&e.bottom>k&&(k=y?e.top-g-2-p:e.bottom+p+2);if("absolute"==this.position?(c.style.top=(k-e.parent.top)/s+"px",a3(c,(b-e.parent.left)/r)):(c.style.top=k/s+"px",a3(c,b/r)),f){let e=d.left+(x?v.x:-v.x)-(b+14-7);f.style.left=e/r+"px"}!0!==h.overlap&&o.push({left:b,top:k,right:S,bottom:k+g}),c.classList.toggle("cm-tooltip-above",y),c.classList.toggle("cm-tooltip-below",!y),h.positioned&&h.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=aX}constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(a0);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="function"==typeof ResizeObserver?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new a$(e,a8,(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="function"==typeof IntersectionObserver?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()}},{eventObservers:{scroll(){this.maybeMeasure()}}});function a3(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}let a4=ao.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:"".concat(7,"px"),width:"".concat(14,"px"),position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"".concat(7,"px solid transparent"),borderRight:"".concat(7,"px solid transparent")},".cm-tooltip-above &":{bottom:"-".concat(7,"px"),"&:before":{borderTop:"".concat(7,"px solid #bbb")},"&:after":{borderTop:"".concat(7,"px solid #f5f5f5"),bottom:"1px"}},".cm-tooltip-below &":{top:"-".concat(7,"px"),"&:before":{borderBottom:"".concat(7,"px solid #bbb")},"&:after":{borderBottom:"".concat(7,"px solid #f5f5f5"),top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),a5={x:0,y:0},a8=rt.define({enables:[a2,a4]}),a6=rt.define({combine:e=>e.reduce((e,t)=>e.concat(t),[])});class a9{static create(e){return new a9(e)}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)null==(e=t.destroy)||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let i=n[e];if(void 0!==i){if(void 0===t)t=i;else if(t!==i)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")}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new a$(e,a6,(e,t)=>this.createHostedView(e,t),e=>e.dom.remove())}}let a7=a8.compute([a6],e=>{let t=e.facet(a6);return 0===t.length?null:{pos:Math.min(...t.map(e=>e.pos)),end:Math.max(...t.map(e=>{var t;return null!=(t=e.end)?t:e.pos})),create:a9.create,above:t[0].above,arrow:t.some(e=>e.arrow)}});class he{update(){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;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,n=e.docView.nearest(t.target);if(!n)return;let i,r=1;if(n instanceof sK)i=n.posAtStart;else{if(null==(i=e.posAtCoords(t)))return;let n=e.coordsAtPos(i);if(!n||t.y<n.top||t.y>n.bottom||t.x<n.left-e.defaultCharacterWidth||t.x>n.right+e.defaultCharacterWidth)return;let s=e.bidiSpans(e.state.doc.lineAt(i)).find(e=>e.from<=i&&e.to>=i),o=s&&s.dir==oi.RTL?-1:1;r=t.x<n.left?-o:o}let s=this.source(e,i,r);if(null==s?void 0:s.then){let t=this.pending={pos:i};s.then(n=>{this.pending==t&&(this.pending=null,n&&!(Array.isArray(n)&&!n.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(n)?n:[n])}))},t=>oD(e.state,t,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let e=this.view.plugin(a2),t=e?e.manager.tooltips.findIndex(e=>e.create==a9.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:i,tooltip:r}=this;if(i.length&&r&&!function(e,t){let{left:n,right:i,top:r,bottom:s}=e.getBoundingClientRect(),o;if(o=e.querySelector(".cm-tooltip-arrow")){let e=o.getBoundingClientRect();r=Math.min(e.top,r),s=Math.max(e.bottom,s)}return t.clientX>=n-4&&t.clientX<=i+4&&t.clientY>=r-4&&t.clientY<=s+4}(r.dom,e)||this.pending){let{pos:r}=i[0]||this.pending,s=null!=(n=null==(t=i[0])?void 0:t.end)?n:r;(r==s?this.view.posAtCoords(this.lastMove)!=r:!function(e,t,n,i,r,s){let o=e.scrollDOM.getBoundingClientRect(),l=e.documentTop+e.documentPadding.top+e.contentHeight;if(o.left>i||o.right<i||o.top>r||Math.min(o.bottom,l)<r)return!1;let a=e.posAtCoords({x:i,y:r},!1);return a>=t&&a<=n}(this.view,r,s,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){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),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}constructor(e,t,n,i,r){this.view=e,this.source=t,this.field=n,this.setHover=i,this.hoverTime=r,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))}}function ht(e,t){let n=e.plugin(a2);if(!n)return null;let i=n.manager.tooltips.indexOf(t);return i<0?null:n.manager.tooltipViews[i]}let hn=rM.define(),hi=rt.define({combine(e){let t,n;for(let i of e)t=t||i.topContainer,n=n||i.bottomContainer;return{topContainer:t,bottomContainer:n}}});function hr(e,t){let n=e.plugin(hs),i=n?n.specs.indexOf(t):-1;return i>-1?n.panels[i]:null}let hs=oI.fromClass(class{update(e){let t=e.state.facet(hi);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new ho(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new ho(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(ha);if(n!=this.input){let t=n.filter(e=>e),i=[],r=[],s=[],o=[];for(let n of t){let t=this.specs.indexOf(n),l;t<0?(l=n(e.view),o.push(l)):(l=this.panels[t]).update&&l.update(e),i.push(l),(l.top?r:s).push(l)}for(let e of(this.specs=t,this.panels=i,this.top.sync(r),this.bottom.sync(s),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([])}constructor(e){this.input=e.state.facet(ha),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(hi);for(let n of(this.top=new ho(e,!0,t.topContainer),this.bottom=new ho(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top)),this.panels))n.dom.classList.add("cm-panel"),n.mount&&n.mount()}},{provide:e=>ao.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class ho{sync(e){for(let t of this.panels)t.destroy&&0>e.indexOf(t)&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(0==this.panels.length){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";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=hl(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=hl(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)}}constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}}function hl(e){let t=e.nextSibling;return e.remove(),t}let ha=rt.define({enables:hs});class hh extends rB{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}hh.prototype.elementClass="",hh.prototype.toDOM=void 0,hh.prototype.mapMode=i$.TrackBefore,hh.prototype.startSide=hh.prototype.endSide=-1,hh.prototype.point=!0;let hc=rt.define(),hd=rt.define(),hu={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>rW.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},hf=rt.define(),hp=rt.define({combine:e=>e.some(e=>e)});function hm(e){let t=[hg];return e&&!1===e.fixed&&t.push(hp.of(!0)),t}let hg=oI.fromClass(class{getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(e){if(this.updateGutters(e)){let t=this.prevViewport,n=e.view.viewport,i=Math.min(t.to,n.to)-Math.max(t.from,n.from);this.syncGutters(i<(n.to-n.from)*.8)}if(e.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(hp)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=e.view.viewport}syncGutters(e){let t=this.dom.nextSibling;e&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=rW.iter(this.view.state.facet(hc),this.view.viewport.from),i=[],r=this.gutters.map(e=>new hb(e,this.view.viewport,-this.view.documentPadding.top));for(let e of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(e.type)){let t=!0;for(let s of e.type)if(s.type==s0.Text&&t){for(let e of(hx(n,i,s.from),r))e.line(this.view,s,i);t=!1}else if(s.widget)for(let e of r)e.widget(this.view,s)}else if(e.type==s0.Text)for(let t of(hx(n,i,e.from),r))t.line(this.view,e,i);else if(e.widget)for(let t of r)t.widget(this.view,e);for(let e of r)e.finish();e&&(this.view.scrollDOM.insertBefore(this.dom,t),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(e){let t=e.startState.facet(hf),n=e.state.facet(hf),i=e.docChanged||e.heightChanged||e.viewportChanged||!rW.eq(e.startState.facet(hc),e.state.facet(hc),e.view.viewport.from,e.view.viewport.to);if(t==n)for(let t of this.gutters)t.update(e)&&(i=!0);else{i=!0;let r=[];for(let i of n){let n=t.indexOf(i);n<0?r.push(new hy(this.view,i)):(this.gutters[n].update(e),r.push(this.gutters[n]))}for(let e of this.gutters)e.dom.remove(),0>r.indexOf(e)&&e.destroy();for(let e of r)"after"==e.config.side?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.gutters=r}return i}destroy(){for(let e of this.gutters)e.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}constructor(e){for(let t of(this.view=e,this.domAfter=null,this.prevViewport=e.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=e.state.facet(hf).map(t=>new hy(e,t)),this.fixed=!e.state.facet(hp),this.gutters))"after"==t.config.side?this.getDOMAfter().appendChild(t.dom):this.dom.appendChild(t.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),e.scrollDOM.insertBefore(this.dom,e.contentDOM)}},{provide:e=>ao.scrollMargins.of(t=>{let n=t.plugin(e);if(!n||0==n.gutters.length||!n.fixed)return null;let i=n.dom.offsetWidth*t.scaleX,r=n.domAfter?n.domAfter.offsetWidth*t.scaleX:0;return t.textDirection==oi.LTR?{left:i,right:r}:{right:i,left:r}})});function hv(e){return Array.isArray(e)?e:[e]}function hx(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class hb{addElement(e,t,n){let{gutter:i}=this,r=(t.top-this.height)/e.scaleY,s=t.height/e.scaleY;if(this.i==i.elements.length){let t=new hw(e,s,r,n);i.elements.push(t),i.dom.appendChild(t.dom)}else i.elements[this.i].update(e,s,r,n);this.height=t.bottom,this.i++}line(e,t,n){let i=[];hx(this.cursor,i,t.from),n.length&&(i=i.concat(n));let r=this.gutter.config.lineMarker(e,t,i);r&&i.unshift(r);let s=this.gutter;(0!=i.length||s.config.renderEmptyElements)&&this.addElement(e,t,i)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),i=n?[n]:null;for(let n of e.state.facet(hd)){let r=n(e,t.widget,t);r&&(i||(i=[])).push(r)}i&&this.addElement(e,t,i)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=rW.iter(e.markers,t.from)}}class hy{update(e){let t=this.markers;if(this.markers=hv(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let t=this.config.updateSpacer(this.spacer.markers[0],e);t!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[t])}let n=e.view.viewport;return!rW.eq(this.markers,t,n.from,n.to)||!!this.config.lineMarkerChange&&this.config.lineMarkerChange(e)}destroy(){for(let e of this.elements)e.destroy()}constructor(e,t){for(let n in this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:""),t.domEventHandlers)this.dom.addEventListener(n,i=>{let r=i.target,s;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let e=r.getBoundingClientRect();s=(e.top+e.bottom)/2}else s=i.clientY;let o=e.lineBlockAtHeight(s-e.documentTop);t.domEventHandlers[n](e,o,i)&&i.preventDefault()});this.markers=hv(t.markers(e)),t.initialSpacer&&(this.spacer=new hw(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}}class hw{update(e,t,n,i){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),!function(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].compare(t[n]))return!1;return!0}(this.markers,i)&&this.setMarkers(e,i)}setMarkers(e,t){let n="cm-gutterElement",i=this.dom.firstChild;for(let r=0,s=0;;){let o=s,l=r<t.length?t[r++]:null,a=!1;if(l){let e=l.elementClass;e&&(n+=" "+e);for(let e=s;e<this.markers.length;e++)if(this.markers[e].compare(l)){o=e,a=!0;break}}else o=this.markers.length;for(;s<o;){let e=this.markers[s++];if(e.toDOM){e.destroy(i);let t=i.nextSibling;i.remove(),i=t}}if(!l)break;l.toDOM&&(a?i=i.nextSibling:this.dom.insertBefore(l.toDOM(e),i)),a&&s++}this.dom.className=n,this.markers=t}destroy(){this.setMarkers(null,[])}constructor(e,t,n,i){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,i)}}let hk=rt.define(),hS=rt.define(),hC=rt.define({combine:e=>rI(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(e,t){let n=Object.assign({},e);for(let e in t){let i=n[e],r=t[e];n[e]=i?(e,t,n)=>i(e,t,n)||r(e,t,n):r}return n}})});class hA extends hh{eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}constructor(e){super(),this.number=e}}function hN(e,t){return e.state.facet(hC).formatNumber(t,e.state)}let hM=hf.compute([hC],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers:e=>e.state.facet(hk),lineMarker:(e,t,n)=>n.some(e=>e.toDOM)?null:new hA(hN(e,e.state.doc.lineAt(t.from).number)),widgetMarker:(e,t,n)=>{for(let i of e.state.facet(hS)){let r=i(e,t,n);if(r)return r}return null},lineMarkerChange:e=>e.startState.facet(hC)!=e.state.facet(hC),initialSpacer:e=>new hA(hN(e,hO(e.state.doc.lines))),updateSpacer(e,t){let n=hN(t.view,hO(t.view.state.doc.lines));return n==e.number?e:new hA(n)},domEventHandlers:e.facet(hC).domEventHandlers,side:"before"}));function hO(e){let t=9;for(;t<e;)t=10*t+9;return t}let hj=new class extends hh{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},hE=hc.compute(["selection"],e=>{let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.head).from;r>n&&(n=r,t.push(hj.range(r)))}return rW.of(t)}),hT=0;class hD{constructor(e,t){this.from=e,this.to=t}}class hR{add(e){if(this.perNode)throw RangeError("Can't add per-node props to node types");return"function"!=typeof e&&(e=hI.match(e)),t=>{let n=e(t);return void 0===n?null:[this,n]}}constructor(e={}){this.id=hT++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error("This node type doesn't define a deserialize function")})}}hR.closedBy=new hR({deserialize:e=>e.split(" ")}),hR.openedBy=new hR({deserialize:e=>e.split(" ")}),hR.group=new hR({deserialize:e=>e.split(" ")}),hR.isolate=new hR({deserialize:e=>{if(e&&"rtl"!=e&&"ltr"!=e&&"auto"!=e)throw RangeError("Invalid value for isolate: "+e);return e||"auto"}}),hR.contextHash=new hR({perNode:!0}),hR.lookAhead=new hR({perNode:!0}),hR.mounted=new hR({perNode:!0});class hP{static get(e){return e&&e.props&&e.props[hR.mounted.id]}constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}}let hL=Object.create(null);class hI{static define(e){let t=e.props&&e.props.length?Object.create(null):hL,n=!!e.top|2*!!e.skipped|4*!!e.error|8*(null==e.name),i=new hI(e.name||"",t,e.id,n);if(e.props){for(let n of e.props)if(Array.isArray(n)||(n=n(i)),n){if(n[0].perNode)throw RangeError("Can't store a per-node prop on a node type");t[n[0].id]=n[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(1&this.flags)>0}get isSkipped(){return(2&this.flags)>0}get isError(){return(4&this.flags)>0}get isAnonymous(){return(8&this.flags)>0}is(e){if("string"==typeof e){if(this.name==e)return!0;let t=this.prop(hR.group);return!!t&&t.indexOf(e)>-1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let i of n.split(" "))t[i]=e[n];return e=>{for(let n=e.prop(hR.group),i=-1;i<(n?n.length:0);i++){let r=t[i<0?e.name:n[i]];if(r)return r}}}constructor(e,t,n,i=0){this.name=e,this.props=t,this.id=n,this.flags=i}}hI.none=new hI("",Object.create(null),0,8);class hB{extend(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let i=[];for(let e of this.types){let n=null;for(let i of t){let t=i(e);t&&(n||(n=Object.assign({},e.props)),n[t[0].id]=t[1])}i.push(n?new hI(e.name,n,e.id,e.flags):e)}return new hB(i)}constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw RangeError("Node type ids should correspond to array positions when creating a node set")}}let hz=new WeakMap,hF=new WeakMap;!function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"}(l||(l={}));class h_{toString(){let e=hP.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let e of this.children){let n=e.toString();n&&(t&&(t+=","),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new hZ(this.topNode,e)}cursorAt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;arguments.length>2&&void 0!==arguments[2]&&arguments[2];let n=new hZ(hz.get(this)||this.topNode);return n.moveTo(e,t),hz.set(this,n._tree),n}get topNode(){return new hU(this,0,0,null)}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hq(hz.get(this)||this.topNode,e,t,!1);return hz.set(this,n),n}resolveInner(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=hq(hF.get(this)||this.topNode,e,t,!0);return hF.set(this,n),n}resolveStack(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return function(e,t,n){let i=e.resolveInner(t,n),r=null;for(let e=i instanceof hU?i:i.context.parent;e;e=e.parent)if(e.index<0){let s=e.parent;(r||(r=[i])).push(s.resolve(t,n)),e=s}else{let s=hP.get(e.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new hU(s.tree,s.overlay[0].from+e.from,-1,e);(r||(r=[i])).push(hq(o,t,n,!1))}}return r?hX(r):i}(this,e,t)}iterate(e){let{enter:t,leave:n,from:i=0,to:r=this.length}=e,s=e.mode||0,o=(s&l.IncludeAnonymous)>0;for(let e=this.cursor(s|l.IncludeAnonymous);;){let s=!1;if(e.from<=r&&e.to>=i&&(!o&&e.type.isAnonymous||!1!==t(e))){if(e.firstChild())continue;s=!0}for(;s&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;s=!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(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.children.length<=8?this:h3(hI.none,this.children,this.positions,0,this.children.length,0,this.length,(e,t,n)=>new h_(this.type,e,t,n,this.propValues),e.makeTree||((e,t,n)=>new h_(hI.none,e,t,n)))}static build(e){return function(e){var t;let{buffer:n,nodeSet:i,maxBufferLength:r=1024,reused:s=[],minRepeatType:o=i.types.length}=e,l=Array.isArray(n)?new hW(n,n.length):n,a=i.types,h=0,c=0;function d(e,t,n,r,s,o,l,a,h){let c=[],d=[];for(;e.length>r;)c.push(e.pop()),d.push(t.pop()+n-s);e.push(u(i.types[l],c,d,o-s,a-o,h)),t.push(s-n)}function u(e,t,n,i,r,s,o){if(s){let e=[hR.contextHash,s];o=o?[e].concat(o):[e]}if(r>25){let e=[hR.lookAhead,r];o=o?[e].concat(o):[e]}return new h_(e,t,n,i,o)}let f=[],p=[];for(;l.pos>0;)!function e(t,n,f,p,m,g){let{id:v,start:x,end:b,size:y}=l,w=c,k=h;for(;y<0;){if(l.next(),-1==y){let e=s[v];f.push(e),p.push(x-t);return}if(-3==y){h=v;return}if(-4==y){c=v;return}else throw RangeError("Unrecognized record size: ".concat(y))}let S=a[v],C,A,N=x-t;if(b-x<=r&&(A=function(e,t){let n=l.fork(),i=0,s=0,a=0,h=n.end-r,c={size:0,start:0,skip:0};n:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){c.size=i,c.start=s,c.skip=a,a+=4,i+=4,n.next();continue}let l=n.pos-e;if(e<0||l<r||n.start<h)break;let d=4*(n.id>=o),u=n.start;for(n.next();n.pos>l;){if(n.size<0)if(-3==n.size)d+=4;else break n;else n.id>=o&&(d+=4);n.next()}s=u,i+=e,a+=d}return(t<0||i==e)&&(c.size=i,c.start=s,c.skip=a),c.size>4?c:void 0}(l.pos-n,m))){let e=new Uint16Array(A.size-A.skip),n=l.pos-A.size,r=e.length;for(;l.pos>n;)r=function e(t,n,i){let{id:r,start:s,end:a,size:d}=l;if(l.next(),d>=0&&r<o){let o=i;if(d>4){let r=l.pos-(d-4);for(;l.pos>r;)i=e(t,n,i)}n[--i]=o,n[--i]=a-t,n[--i]=s-t,n[--i]=r}else -3==d?h=r:-4==d&&(c=r);return i}(A.start,e,r);C=new hV(e,b-A.start,i),N=A.start-t}else{let t=l.pos-y;l.next();let n=[],s=[],a=v>=o?v:-1,h=0,c=b;for(;l.pos>t;)a>=0&&l.id==a&&l.size>=0?(l.end<=c-r&&(d(n,s,x,h,l.end,c,a,w,k),h=n.length,c=l.end),l.next()):g>2500?function(e,t,n,s){let o=[],a=0,h=-1;for(;l.pos>t;){let{id:e,start:t,end:n,size:i}=l;if(i>4)l.next();else if(h>-1&&t<h)break;else h<0&&(h=n-r),o.push(e,t,n),a++,l.next()}if(a){let t=new Uint16Array(4*a),r=o[o.length-2];for(let e=o.length-3,n=0;e>=0;e-=3)t[n++]=o[e],t[n++]=o[e+1]-r,t[n++]=o[e+2]-r,t[n++]=n;n.push(new hV(t,o[2]-r,i)),s.push(r-e)}}(x,t,n,s):e(x,t,n,s,a,g+1);if(a>=0&&h>0&&h<n.length&&d(n,s,x,h,x,c,a,w,k),n.reverse(),s.reverse(),a>-1&&h>0){let e=function(e,t){return(n,i,r)=>{let s=0,o=n.length-1,l,a;if(o>=0&&(l=n[o])instanceof h_){if(!o&&l.type==e&&l.length==r)return l;(a=l.prop(hR.lookAhead))&&(s=i[o]+l.length+a)}return u(e,n,i,r,s,t)}}(S,k);C=h3(S,n,s,0,n.length,0,b-x,e,e)}else C=u(S,n,s,b-x,w-b,k)}f.push(C),p.push(N)}(e.start||0,e.bufferStart||0,f,p,-1,0);let m=null!=(t=e.length)?t:f.length?p[0]+f[0].length:0;return new h_(a[e.topID],f.reverse(),p.reverse(),m)}(e)}constructor(e,t,n,i,r){if(this.type=e,this.children=t,this.positions=n,this.length=i,this.props=null,r&&r.length)for(let[e,t]of(this.props=Object.create(null),r))this.props["number"==typeof e?e:e.id]=t}}h_.empty=new h_(hI.none,[],[],0);class hW{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 hW(this.buffer,this.index)}constructor(e,t){this.buffer=e,this.index=t}}class hV{get type(){return hI.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],n=this.buffer[e+3],i=this.set.types[t],r=i.name;if(/\W/.test(r)&&!i.isError&&(r=JSON.stringify(r)),n==(e+=4))return r;let s=[];for(;e<n;)s.push(this.childString(e)),e=this.buffer[e+3];return r+"("+s.join(",")+")"}findChild(e,t,n,i,r){let{buffer:s}=this,o=-1;for(let l=e;l!=t&&(!hH(r,i,s[l+1],s[l+2])||(o=l,!(n>0)));l=s[l+3]);return o}slice(e,t,n){let i=this.buffer,r=new Uint16Array(t-e),s=0;for(let o=e,l=0;o<t;){r[l++]=i[o++],r[l++]=i[o++]-n;let t=r[l++]=i[o++]-n;r[l++]=i[o++]-e,s=Math.max(s,t)}return new hV(r,s,this.set)}constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}}function hH(e,t,n,i){switch(e){case -2:return n<t;case -1:return i>=t&&n<t;case 0:return n<t&&i>t;case 1:return n<=t&&i>t;case 2:return i>t;case 4:return!0}}function hq(e,t,n,i){for(var r;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!i&&e instanceof hU&&e.index<0?null:e.parent;if(!t)return e;e=t}let s=i?0:l.IgnoreOverlays;if(i)for(let i=e,o=i.parent;o;o=(i=o).parent)i instanceof hU&&i.index<0&&(null==(r=o.enter(t,n,s))?void 0:r.from)!=i.from&&(e=o);for(;;){let i=e.enter(t,n,s);if(!i)return e;e=i}}class hK{cursor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return new hZ(this,e)}getChild(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=hJ(this,e,t,n);return i.length?i[0]:null}getChildren(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return hJ(this,e,t,n)}resolve(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return hq(this,e,t,!1)}resolveInner(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return hq(this,e,t,!0)}matchContext(e){return hG(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}}class hU extends hK{get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;for(let s=this;;){for(let{children:o,positions:a}=s._tree,h=t>0?o.length:-1;e!=h;e+=t){let h=o[e],c=a[e]+s.from;if(hH(i,n,c,c+h.length)){if(h instanceof hV){if(r&l.ExcludeBuffers)continue;let o=h.findChild(0,h.buffer.length,t,n-c,i);if(o>-1)return new hQ(new hY(s,h,e,c),null,o)}else if(r&l.IncludeAnonymous||!h.type.isAnonymous||h0(h)){let o;if(!(r&l.IgnoreMounts)&&(o=hP.get(h))&&!o.overlay)return new hU(o.tree,c,e,s);let a=new hU(h,c,e,s);return r&l.IncludeAnonymous||!a.type.isAnonymous?a:a.nextChild(t<0?h.children.length-1:0,t,n,i)}}}if(r&l.IncludeAnonymous||!s.type.isAnonymous||(e=s.index>=0?s.index+t:t<0?-1:s._parent._tree.children.length,!(s=s._parent)))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)}enter(e,t){let n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!(i&l.IgnoreOverlays)&&(n=hP.get(this._tree))&&n.overlay){let i=e-this.from;for(let{from:e,to:r}of n.overlay)if((t>0?e<=i:e<i)&&(t<0?r>=i:r>i))return new hU(n.tree,n.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}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()}constructor(e,t,n,i){super(),this._tree=e,this.from=t,this.index=n,this._parent=i}}function hJ(e,t,n,i){let r=e.cursor(),s=[];if(!r.firstChild())return s;if(null!=n){for(let e=!1;!e;)if(e=r.type.is(n),!r.nextSibling())return s}for(;;){if(null!=i&&r.type.is(i))return s;if(r.type.is(t)&&s.push(r.node),!r.nextSibling())return null==i?s:[]}}function hG(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.length-1;for(let i=e;n>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(t[n]&&t[n]!=i.name)return!1;n--}}return!0}class hY{constructor(e,t,n,i){this.parent=e,this.buffer=t,this.index=n,this.start=i}}class hQ extends hK{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]}child(e,t,n){let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.context.start,n);return r<0?null:new hQ(this.context,this,r)}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)}enter(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(n&l.ExcludeBuffers)return null;let{buffer:i}=this.context,r=i.findChild(this.index+4,i.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new hQ(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new hQ(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new hQ(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,i=this.index+4,r=n.buffer[this.index+3];if(r>i){let s=n.buffer[this.index+1];e.push(n.slice(i,r,s)),t.push(0)}return new h_(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}}function hX(e){if(!e.length)return null;let t=0,n=e[0];for(let i=1;i<e.length;i++){let r=e[i];(r.from>n.from||r.to<n.to)&&(n=r,t=i)}let i=n instanceof hU&&n.index<0?null:n.parent,r=e.slice();return i?r[t]=i:r.splice(t,1),new h$(r,n)}class h${get next(){return hX(this.heads)}constructor(e,t){this.heads=e,this.node=t}}class hZ{get name(){return this.type.name}yieldNode(e){return!!e&&(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0)}yieldBuf(e,t){this.index=e;let{start:n,buffer:i}=this.buffer;return this.type=t||i.set.types[i.buffer[e]],this.from=n+i.buffer[e+1],this.to=n+i.buffer[e+2],!0}yield(e){return!!e&&(e instanceof hU?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)))}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:i}=this.buffer,r=i.findChild(this.index+4,i.buffer[this.index+3],e,t-this.buffer.start,n);return!(r<0)&&(this.stack.push(this.index),this.yieldBuf(r))}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){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.mode;return this.buffer?!(n&l.ExcludeBuffers)&&this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&l.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&l.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));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:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(i.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=i)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let i=t+e,r=e<0?-1:n._tree.children.length;i!=r;i+=e){let e=n._tree.children[i];if(this.mode&l.IncludeAnonymous||e instanceof hV||!e.type.isAnonymous||h0(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(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.move(1,e)}prev(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return this.move(-1,e)}moveTo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)n:for(let i=this.index,r=this.stack.length;r>=0;){for(let s=e;s;s=s._parent)if(s.index==i){if(i==this.index)return s;t=s,n=r+1;break n}i=this.stack[--r]}for(let e=n;e<this.stack.length;e++)t=new hQ(this.buffer,t,this.stack[e]);return this.bufferNode=new hQ(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let i=!1;if(this.type.isAnonymous||!1!==e(this)){if(this.firstChild()){n++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&t&&t(this),i=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,i=!0}}}matchContext(e){if(!this.buffer)return hG(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let i=e.length-1,r=this.stack.length-1;i>=0;r--){if(r<0)return hG(this._tree,e,i);let s=n[t.buffer[this.stack[r]]];if(!s.isAnonymous){if(e[i]&&e[i]!=s.name)return!1;i--}}return!0}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof hU)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)}}}function h0(e){return e.children.some(e=>e instanceof hV||!e.type.isAnonymous||h0(e))}let h1=new WeakMap;function h2(e,t){if(!e.isAnonymous||t instanceof hV||t.type!=e)return 1;let n=h1.get(t);if(null==n){for(let i of(n=1,t.children)){if(i.type!=e||!(i instanceof h_)){n=1;break}n+=h2(e,i)}h1.set(t,n)}return n}function h3(e,t,n,i,r,s,o,l,a){let h=0;for(let n=i;n<r;n++)h+=h2(e,t[n]);let c=Math.ceil(1.5*h/8),d=[],u=[];return!function t(n,i,r,o,l){for(let h=r;h<o;){let r=h,f=i[h],p=h2(e,n[h]);for(h++;h<o;h++){let t=h2(e,n[h]);if(p+t>=c)break;p+=t}if(h==r+1){if(p>c){let e=n[r];t(e.children,e.positions,0,e.children.length,i[r]+l);continue}d.push(n[r])}else{let t=i[h-1]+n[h-1].length-f;d.push(h3(e,n,i,r,h,f,t,null,a))}u.push(f+l-s)}}(t,n,i,r,0),(l||a)(d,u,o)}class h4{get openStart(){return(1&this.open)>0}get openEnd(){return(2&this.open)>0}static addTree(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=[new h4(0,e.length,e,0,!1,n)];for(let n of t)n.to>e.length&&i.push(n);return i}static applyChanges(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:128;if(!t.length)return e;let i=[],r=1,s=e.length?e[0]:null;for(let o=0,l=0,a=0;;o++){let h=o<t.length?t[o]:null,c=h?h.fromA:1e9;if(c-l>=n)for(;s&&s.from<c;){let t=s;if(l>=t.from||c<=t.to||a){let e=Math.max(t.from,l)-a,n=Math.min(t.to,c)-a;t=e>=n?null:new h4(e,n,t.tree,t.offset+a,o>0,!!h)}if(t&&i.push(t),s.to>c)break;s=r<e.length?e[r++]:null}if(!h)break;l=h.toA,a=h.toA-h.toB}return i}constructor(e,t,n,i,r=!1,s=!1){this.from=e,this.to=t,this.tree=n,this.offset=i,this.open=!!r|2*!!s}}class h5{startParse(e,t,n){return"string"==typeof e&&(e=new h8(e)),n=n?n.length?n.map(e=>new hD(e.from,e.to)):[new hD(0,0)]:[new hD(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let i=this.startParse(e,t,n);for(;;){let e=i.advance();if(e)return e}}}class h8{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)}constructor(e){this.string=e}}new hR({perNode:!0});let h6=0;class h9{toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e="".concat(t.name,"(").concat(e,")"));return e}static define(e,t){if(e instanceof h9&&(t=e),null==t?void 0:t.base)throw Error("Can not derive from a modified tag");let n=new h9("string"==typeof e?e:"?",[],null,[]);if(n.set.push(n),t)for(let e of t.set)n.set.push(e);return n}static defineModifier(e){let t=new ce(e);return e=>e.modified.indexOf(t)>-1?e:ce.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}constructor(e,t,n,i){this.name=e,this.set=t,this.base=n,this.modified=i,this.id=h6++}}let h7=0;class ce{static get(e,t){if(!t.length)return e;let n=t[0].instances.find(n=>{var i,r;return n.base==e&&(i=t,r=n.modified,i.length==r.length&&i.every((e,t)=>e==r[t]))});if(n)return n;let i=[],r=new h9(e.name,i,e,t);for(let e of t)e.instances.push(r);let s=function(e){let t=[[]];for(let n=0;n<e.length;n++)for(let i=0,r=t.length;i<r;i++)t.push(t[i].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}(t);for(let t of e.set)if(!t.modified.length)for(let e of s)i.push(ce.get(t,e));return r}constructor(e){this.name=e,this.instances=[],this.id=h7++}}function ct(e){let t=Object.create(null);for(let n in e){let i=e[n];for(let e of(Array.isArray(i)||(i=[i]),n.split(" ")))if(e){let n=[],r=2,s=e;for(let t=0;;){if("..."==s&&t>0&&t+3==e.length){r=1;break}let i=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!i)throw RangeError("Invalid path: "+e);if(n.push("*"==i[0]?"":'"'==i[0][0]?JSON.parse(i[0]):i[0]),(t+=i[0].length)==e.length)break;let o=e[t++];if(t==e.length&&"!"==o){r=0;break}if("/"!=o)throw RangeError("Invalid path: "+e);s=e.slice(t)}let o=n.length-1,l=n[o];if(!l)throw RangeError("Invalid path: "+e);let a=new ci(i,r,o>0?n.slice(0,o):null);t[l]=a.sort(t[l])}}return cn.add(t)}let cn=new hR;class ci{get opaque(){return 0==this.mode}get inherit(){return 1==this.mode}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}constructor(e,t,n,i){this.tags=e,this.mode=t,this.context=n,this.next=i}}function cr(e,t){let n=Object.create(null);for(let t of e)if(Array.isArray(t.tag))for(let e of t.tag)n[e.id]=t.class;else n[t.tag.id]=t.class;let{scope:i,all:r=null}=t||{};return{style:e=>{let t=r;for(let i of e)for(let e of i.set){let i=n[e.id];if(i){t=t?t+" "+i:i;break}}return t},scope:i}}ci.empty=new ci([],2,null);class cs{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,i,r){let{type:s,from:o,to:l}=e;if(o>=n||l<=t)return;s.isTop&&(r=this.highlighters.filter(e=>!e.scope||e.scope(s)));let a=i,h=function(e){let t=e.type.prop(cn);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}(e)||ci.empty,c=function(e,t){let n=null;for(let i of e){let e=i.style(t);e&&(n=n?n+" "+e:e)}return n}(r,h.tags);if(c&&(a&&(a+=" "),a+=c,1==h.mode&&(i+=(i?" ":"")+c)),this.startSpan(Math.max(t,o),a),h.opaque)return;let d=e.tree&&e.tree.prop(hR.mounted);if(d&&d.overlay){let s=e.node.enter(d.overlay[0].from+o,1),h=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),c=e.firstChild();for(let u=0,f=o;;u++){let p=u<d.overlay.length?d.overlay[u]:null,m=p?p.from+o:l,g=Math.max(t,f),v=Math.min(n,m);if(g<v&&c)for(;e.from<v&&(this.highlightRange(e,g,v,i,r),this.startSpan(Math.min(v,e.to),a),!(e.to>=m)&&e.nextSibling()););if(!p||m>n)break;(f=p.to+o)>t&&(this.highlightRange(s.cursor(),Math.max(t,p.from+o),Math.min(n,f),"",h),this.startSpan(Math.min(n,f),a))}c&&e.parent()}else if(e.firstChild()){d&&(i="");do{if(e.to<=t)continue;if(e.from>=n)break;this.highlightRange(e,t,n,i,r),this.startSpan(Math.min(n,e.to),a)}while(e.nextSibling())e.parent()}}constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}}let co=h9.define,cl=co(),ca=co(),ch=co(ca),cc=co(ca),cd=co(),cu=co(cd),cf=co(cd),cp=co(),cm=co(cp),cg=co(),cv=co(),cx=co(),cb=co(cx),cy=co(),cw={comment:cl,lineComment:co(cl),blockComment:co(cl),docComment:co(cl),name:ca,variableName:co(ca),typeName:ch,tagName:co(ch),propertyName:cc,attributeName:co(cc),className:co(ca),labelName:co(ca),namespace:co(ca),macroName:co(ca),literal:cd,string:cu,docString:co(cu),character:co(cu),attributeValue:co(cu),number:cf,integer:co(cf),float:co(cf),bool:co(cd),regexp:co(cd),escape:co(cd),color:co(cd),url:co(cd),keyword:cg,self:co(cg),null:co(cg),atom:co(cg),unit:co(cg),modifier:co(cg),operatorKeyword:co(cg),controlKeyword:co(cg),definitionKeyword:co(cg),moduleKeyword:co(cg),operator:cv,derefOperator:co(cv),arithmeticOperator:co(cv),logicOperator:co(cv),bitwiseOperator:co(cv),compareOperator:co(cv),updateOperator:co(cv),definitionOperator:co(cv),typeOperator:co(cv),controlOperator:co(cv),punctuation:cx,separator:co(cx),bracket:cb,angleBracket:co(cb),squareBracket:co(cb),paren:co(cb),brace:co(cb),content:cp,heading:cm,heading1:co(cm),heading2:co(cm),heading3:co(cm),heading4:co(cm),heading5:co(cm),heading6:co(cm),contentSeparator:co(cp),list:co(cp),quote:co(cp),emphasis:co(cp),strong:co(cp),link:co(cp),monospace:co(cp),strikethrough:co(cp),inserted:co(),deleted:co(),changed:co(),invalid:co(),meta:cy,documentMeta:co(cy),annotation:co(cy),processingInstruction:co(cy),definition:h9.defineModifier("definition"),constant:h9.defineModifier("constant"),function:h9.defineModifier("function"),standard:h9.defineModifier("standard"),local:h9.defineModifier("local"),special:h9.defineModifier("special")};for(let e in cw){let t=cw[e];t instanceof h9&&(t.name=e)}cr([{tag:cw.link,class:"tok-link"},{tag:cw.heading,class:"tok-heading"},{tag:cw.emphasis,class:"tok-emphasis"},{tag:cw.strong,class:"tok-strong"},{tag:cw.keyword,class:"tok-keyword"},{tag:cw.atom,class:"tok-atom"},{tag:cw.bool,class:"tok-bool"},{tag:cw.url,class:"tok-url"},{tag:cw.labelName,class:"tok-labelName"},{tag:cw.inserted,class:"tok-inserted"},{tag:cw.deleted,class:"tok-deleted"},{tag:cw.literal,class:"tok-literal"},{tag:cw.string,class:"tok-string"},{tag:cw.number,class:"tok-number"},{tag:[cw.regexp,cw.escape,cw.special(cw.string)],class:"tok-string2"},{tag:cw.variableName,class:"tok-variableName"},{tag:cw.local(cw.variableName),class:"tok-variableName tok-local"},{tag:cw.definition(cw.variableName),class:"tok-variableName tok-definition"},{tag:cw.special(cw.variableName),class:"tok-variableName2"},{tag:cw.definition(cw.propertyName),class:"tok-propertyName tok-definition"},{tag:cw.typeName,class:"tok-typeName"},{tag:cw.namespace,class:"tok-namespace"},{tag:cw.className,class:"tok-className"},{tag:cw.macroName,class:"tok-macroName"},{tag:cw.propertyName,class:"tok-propertyName"},{tag:cw.operator,class:"tok-operator"},{tag:cw.comment,class:"tok-comment"},{tag:cw.meta,class:"tok-meta"},{tag:cw.invalid,class:"tok-invalid"},{tag:cw.punctuation,class:"tok-punctuation"}]);let ck=new hR,cS=new hR;class cC{isActiveAt(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;return cA(e,t,n).type.prop(ck)==this.data}findRegions(e){let t=e.facet(cI);if((null==t?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],i=(e,t)=>{if(e.prop(ck)==this.data)return void n.push({from:t,to:t+e.length});let r=e.prop(hR.mounted);if(r){if(r.tree.prop(ck)==this.data){if(r.overlay)for(let e of r.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}else if(r.overlay){let e=n.length;if(i(r.tree,r.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let r=e.children[n];r instanceof h_&&i(r,e.positions[n]+t)}};return i(cM(e),0),n}get allowsNesting(){return!0}constructor(e,t,n=[],i=""){this.data=e,this.name=i,rL.prototype.hasOwnProperty("tree")||Object.defineProperty(rL.prototype,"tree",{get(){return cM(this)}}),this.parser=t,this.extension=[cI.of(this),rL.languageData.of((e,t,n)=>{let i=cA(e,t,n),r=i.type.prop(ck);if(!r)return[];let s=e.facet(r),o=i.type.prop(cS);if(o){let r=i.resolve(t-i.from,n);for(let t of o)if(t.test(r,e)){let n=e.facet(t.facet);return"replace"==t.type?n:n.concat(s)}}return s})].concat(n)}}function cA(e,t,n){let i=e.facet(cI),r=cM(e).topNode;if(!i||i.allowsNesting)for(let e=r;e;e=e.enter(t,n,l.ExcludeBuffers))e.type.isTop&&(r=e);return r}cC.setState=rM.define();class cN extends cC{static define(e){var t;let n=(t=e.languageData,rt.define({combine:t?e=>e.concat(t):void 0}));return new cN(n,e.parser.configure({props:[ck.add(e=>e.isTop?n:void 0)]}),e.name)}configure(e,t){return new cN(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}constructor(e,t,n){super(e,t,[],n),this.parser=t}}function cM(e){let t=e.field(cC.state,!1);return t?t.tree:h_.empty}class cO{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<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}}let cj=null;class cE{static create(e,t,n){return new cE(e,t,[],h_.empty,0,n,[],null)}startParse(){return this.parser.startParse(new cO(this.state.doc),this.fragments)}work(e,t){return(null!=t&&t>=this.state.doc.length&&(t=void 0),this.tree!=h_.empty&&this.isDone(null!=t?t:this.state.doc.length))?(this.takeTree(),!0):this.withContext(()=>{var n;if("number"==typeof e){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||(this.parse=this.startParse()),null!=t&&(null==this.parse.stoppedAt||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let i=this.parse.advance();if(i){if(this.fragments=this.withoutTempSkipped(h4.addTree(i,this.fragments,null!=this.parse.stoppedAt)),this.treeLen=null!=(n=this.parse.stoppedAt)?n:this.state.doc.length,this.tree=i,this.parse=null,!(this.treeLen<(null!=t?t:this.state.doc.length)))return!0;this.parse=this.startParse()}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((null==this.parse.stoppedAt||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(h4.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=cj;cj=this;try{return e()}finally{cj=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=cT(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:i,treeLen:r,viewport:s,skipped:o}=this;if(this.takeTree(),!e.empty){let t=[];if(e.iterChangedRanges((e,n,i,r)=>t.push({fromA:e,toA:n,fromB:i,toB:r})),n=h4.applyChanges(n,t),i=h_.empty,r=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length)for(let t of(o=[],this.skipped)){let n=e.mapPos(t.from,1),i=e.mapPos(t.to,-1);n<i&&o.push({from:n,to:i})}}return new cE(this.parser,t,n,i,r,s,o,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:i}=this.skipped[t];n<e.to&&i>e.from&&(this.fragments=cT(this.fragments,n,i),this.skipped.splice(t--,1))}return!(this.skipped.length>=t)&&(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends h5{createParse(t,n,i){let r=i[0].from,s=i[i.length-1].to;return{parsedPos:r,advance(){let t=cj;if(t){for(let e of i)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=s,new h_(hI.none,[],[],s-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&0==t[0].from&&t[0].to>=e}static get(){return cj}constructor(e,t,n=[],i,r,s,o,l){this.parser=e,this.state=t,this.fragments=n,this.tree=i,this.treeLen=r,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}}function cT(e,t,n){return h4.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class cD{apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new cD(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=cE.create(e.facet(cI).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new cD(n)}constructor(e){this.context=e,this.tree=e.tree}}cC.state=rl.define({create:cD.init,update(e,t){for(let e of t.effects)if(e.is(cC.setState))return e.value;return t.startState.facet(cI)!=t.state.facet(cI)?cD.init(t.state):e.apply(t)}});let cR=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};"undefined"!=typeof requestIdleCallback&&(cR=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});let cP="undefined"!=typeof navigator&&(null==(a=navigator.scheduling)?void 0:a.isInputPending)?()=>navigator.scheduling.isInputPending():null,cL=oI.fromClass(class{update(e){let t=this.view.state.field(cC.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(cC.state);t.tree==t.context.tree&&t.context.isDone(e.doc.length)||(this.working=cR(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:i}}=this.view,r=n.field(cC.state);if(r.tree==r.context.tree&&r.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!cP?Math.max(25,e.timeRemaining()-5):1e9),o=r.context.treeLen<i&&n.doc.length>i+1e3,l=r.context.work(()=>cP&&cP()||Date.now()>s,i+1e5*!o);this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:cC.setState.of(new cD(r.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>oD(this.view.state,e)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}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()}},{eventHandlers:{focus(){this.scheduleWork()}}}),cI=rt.define({combine:e=>e.length?e[0]:null,enables:e=>[cC.state,cL,ao.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class cB{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}let cz=rt.define(),cF=rt.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 c_(e){let t=e.facet(cF);return 9==t.charCodeAt(0)?e.tabSize*t.length:t.length}function cW(e,t){let n="",i=e.tabSize,r=e.facet(cF)[0];if(" "==r){for(;t>=i;)n+=" ",t-=i;r=" "}for(let e=0;e<t;e++)n+=r;return n}function cV(e,t){for(let n of(e instanceof rL&&(e=new cH(e)),e.state.facet(cz))){let i=n(e,t);if(void 0!==i)return i}let n=cM(e.state);return n.length>=t?function(e,t,n){let i=t.resolveStack(n),r=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(r!=i.node){let e=[];for(let t=r;t&&!(t.from<i.node.from||t.to>i.node.to||t.from==i.node.from&&t.type==i.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)i={node:e[t],next:i}}return cK(i,e,n)}(e,n,t):null}class cH{lineAt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=this.state.doc.lineAt(e),{simulateBreak:i,simulateDoubleBreak:r}=this.options;if(null!=i&&i>=n.from&&i<=n.to)if(r&&i==e)return{text:"",from:e};else if(t<0?i<e:i<=e)return{text:n.text.slice(i-n.from),from:i};else return{text:n.text.slice(0,i-n.from),from:n.from};return n}textAfterPos(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:n,from:i}=this.lineAt(e,t);return n.slice(e-i,Math.min(n.length,e+100-i))}column(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,{text:n,from:i}=this.lineAt(e,t),r=this.countColumn(n,e-i),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(r+=s-this.countColumn(n,n.search(/\S|$/))),r}countColumn(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.length;return rZ(e,this.state.tabSize,t)}lineIndent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,{text:n,from:i}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let e=r(i);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}constructor(e,t={}){this.state=e,this.options=t,this.unit=c_(e)}}let cq=new hR;function cK(e,t,n){for(let i=e;i;i=i.next){let e=function(e){let t=e.type.prop(cq);if(t)return t;let n=e.firstChild,i;if(n&&(i=n.type.prop(hR.closedBy))){let t=e.lastChild,n=t&&i.indexOf(t.name)>-1;return e=>(function(e,t,n,i,r){let s=e.textAfter,o=s.match(/^\s*/)[0].length,l=i&&s.slice(o,o+i.length)==i||r==e.pos+o,a=t?function(e){let t=e.node,n=t.childAfter(t.from),i=t.lastChild;if(!n)return null;let r=e.options.simulateBreak,s=e.state.doc.lineAt(n.from),o=null==r||r<=s.from?s.to:Math.min(s.to,r);for(let e=n.to;;){let r=t.childAfter(e);if(!r||r==i)return null;if(!r.type.isSkipped){if(r.from>=o)return null;let e=/^ */.exec(s.text.slice(n.to-s.from))[0].length;return{from:n.from,to:n.to+e}}e=r.to}}(e):null;return a?l?e.column(a.from):e.column(a.to):e.baseIndent+(l?0:+e.unit)})(e,!0,1,void 0,n&&!(e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak)?t.from:void 0)}return null==e.parent?cU:null}(i.node);if(e)return e(cJ.create(t,n,i))}return 0}function cU(){return 0}class cJ extends cH{get node(){return this.context.node}static create(e,t,n){return new cJ(e,t,n)}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(function(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return cK(this.context.next,this.base,this.pos)}constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}}function cG(){let{except:e,units:t=1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return n=>{let i=e&&e.test(n.textAfter);return n.baseIndent+(i?0:t*n.unit)}}let cY=rt.define(),cQ=new hR;function cX(e,t,n){for(let i of e.facet(cY)){let r=i(e,t,n);if(r)return r}return function(e,t,n){let i=cM(e);if(i.length<n)return null;let r=i.resolveStack(n,1),s=null;for(let o=r;o;o=o.next){let r=o.node;if(r.to<=n||r.from>n)continue;if(s&&r.from<t)break;let l=r.type.prop(cQ);if(l&&(r.to<i.length-50||i.length==e.doc.length||!function(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}(r))){let i=l(r,e);i&&i.from<=n&&i.from>=t&&i.to>n&&(s=i)}}return s}(e,t,n)}function c$(e,t){let n=t.mapPos(e.from,1),i=t.mapPos(e.to,-1);return n>=i?void 0:{from:n,to:i}}let cZ=rM.define({map:c$}),c0=rM.define({map:c$});function c1(e){let t=[];for(let{head:n}of e.state.selection.ranges)t.some(e=>e.from<=n&&e.to>=n)||t.push(e.lineBlockAt(n));return t}let c2=rl.define({create:()=>s1.none,update(e,t){for(let n of(t.isUserEvent("delete")&&t.changes.iterChangedRanges((t,n)=>e=c3(e,t,n)),e=e.map(t.changes),t.effects))if(n.is(cZ)&&!function(e,t,n){let i=!1;return e.between(t,t,(e,r)=>{e==t&&r==n&&(i=!0)}),i}(e,n.value.from,n.value.to)){let{preparePlaceholder:i}=t.state.facet(c7),r=i?s1.replace({widget:new di(i(t.state,n.value))}):dn;e=e.update({add:[r.range(n.value.from,n.value.to)]})}else n.is(c0)&&(e=e.update({filter:(e,t)=>n.value.from!=e||n.value.to!=t,filterFrom:n.value.from,filterTo:n.value.to}));return t.selection&&(e=c3(e,t.selection.main.head)),e},provide:e=>ao.decorations.from(e),toJSON(e,t){let n=[];return e.between(0,t.doc.length,(e,t)=>{n.push(e,t)}),n},fromJSON(e){if(!Array.isArray(e)||e.length%2)throw RangeError("Invalid JSON for fold state");let t=[];for(let n=0;n<e.length;){let i=e[n++],r=e[n++];if("number"!=typeof i||"number"!=typeof r)throw RangeError("Invalid JSON for fold state");t.push(dn.range(i,r))}return s1.set(t,!0)}});function c3(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i=!1;return e.between(t,n,(e,r)=>{e<n&&r>t&&(i=!0)}),i?e.update({filterFrom:t,filterTo:n,filter:(e,i)=>e>=n||i<=t}):e}function c4(e,t,n){var i;let r=null;return null==(i=e.field(c2,!1))||i.between(t,n,(e,t)=>{(!r||r.from>e)&&(r={from:e,to:t})}),r}function c5(e,t){return e.field(c2,!1)?t:t.concat(rM.appendConfig.of(de()))}function c8(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=e.state.doc.lineAt(t.from).number,r=e.state.doc.lineAt(t.to).number;return ao.announce.of("".concat(e.state.phrase(n?"Folded lines":"Unfolded lines")," ").concat(i," ").concat(e.state.phrase("to")," ").concat(r,"."))}let c6=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:e=>{for(let t of c1(e)){let n=cX(e.state,t.from,t.to);if(n)return e.dispatch({effects:c5(e.state,[cZ.of(n),c8(e,n)])}),!0}return!1}},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:e=>{if(!e.state.field(c2,!1))return!1;let t=[];for(let n of c1(e)){let i=c4(e.state,n.from,n.to);i&&t.push(c0.of(i),c8(e,i,!1))}return t.length&&e.dispatch({effects:t}),t.length>0}},{key:"Ctrl-Alt-[",run:e=>{let{state:t}=e,n=[];for(let i=0;i<t.doc.length;){let r=e.lineBlockAt(i),s=cX(t,r.from,r.to);s&&n.push(cZ.of(s)),i=(s?e.lineBlockAt(s.to):r).to+1}return n.length&&e.dispatch({effects:c5(e.state,n)}),!!n.length}},{key:"Ctrl-Alt-]",run:e=>{let t=e.state.field(c2,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(e,t)=>{n.push(c0.of({from:e,to:t}))}),e.dispatch({effects:n}),!0}}],c9={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},c7=rt.define({combine:e=>rI(e,c9)});function de(e){let t=[c2,dl];return e&&t.push(c7.of(e)),t}function dt(e,t){let{state:n}=e,i=n.facet(c7),r=t=>{let n=e.lineBlockAt(e.posAtDOM(t.target)),i=c4(e.state,n.from,n.to);i&&e.dispatch({effects:c0.of(i)}),t.preventDefault()};if(i.placeholderDOM)return i.placeholderDOM(e,r,t);let s=document.createElement("span");return s.textContent=i.placeholderText,s.setAttribute("aria-label",n.phrase("folded code")),s.title=n.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=r,s}let dn=s1.replace({widget:new class extends sZ{toDOM(e){return dt(e,null)}}});class di extends sZ{eq(e){return this.value==e.value}toDOM(e){return dt(e,this.value)}constructor(e){super(),this.value=e}}let dr={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class ds extends hh{eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}constructor(e,t){super(),this.config=e,this.open=t}}let dl=ao.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class da{static define(e,t){return new da(e,t||{})}constructor(e,t){let n;function i(e){let t=r4.newName();return(n||(n=Object.create(null)))["."+t]=e,t}this.specs=e;let r="string"==typeof t.all?t.all:t.all?i(t.all):void 0,s=t.scope;this.scope=s instanceof cC?e=>e.prop(ck)==s.data:s?e=>e==s:void 0,this.style=cr(e.map(e=>({tag:e.tag,class:e.class||i(Object.assign({},e,{tag:null}))})),{all:r}).style,this.module=n?new r4(n):null,this.themeType=t.themeType}}let dh=rt.define(),dc=rt.define({combine:e=>e.length?[e[0]]:null});function dd(e){let t=e.facet(dh);return t.length?t:e.facet(dc)}function du(e,t){let n=[df],i;return e instanceof da&&(e.module&&n.push(ao.styleModule.of(e.module)),i=e.themeType),(null==t?void 0:t.fallback)?n.push(dc.of(e)):i?n.push(dh.computeN([ao.darkTheme],t=>t.facet(ao.darkTheme)==("dark"==i)?[e]:[])):n.push(dh.of(e)),n}let df=rc.high(oI.fromClass(class{update(e){let t=cM(e.state),n=dd(e.state),i=n!=dd(e.startState),{viewport:r}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<r.to&&!i&&t.type==this.tree.type&&s>=r.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||i)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=r.to)}buildDeco(e,t){if(!t||!this.tree.length)return s1.none;let n=new rV;for(let{from:i,to:r}of e.visibleRanges)!function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:e.length,s=new cs(i,Array.isArray(t)?t:[t],n);s.highlightRange(e.cursor(),i,r,"",s.highlighters),s.flush(r)}(this.tree,t,(e,t,i)=>{n.add(e,t,this.markCache[i]||(this.markCache[i]=s1.mark({class:i})))},i,r);return n.finish()}constructor(e){this.markCache=Object.create(null),this.tree=cM(e.state),this.decorations=this.buildDeco(e,dd(e.state)),this.decoratedTo=e.viewport.to}},{decorations:e=>e.decorations})),dp=da.define([{tag:cw.meta,color:"#404740"},{tag:cw.link,textDecoration:"underline"},{tag:cw.heading,textDecoration:"underline",fontWeight:"bold"},{tag:cw.emphasis,fontStyle:"italic"},{tag:cw.strong,fontWeight:"bold"},{tag:cw.strikethrough,textDecoration:"line-through"},{tag:cw.keyword,color:"#708"},{tag:[cw.atom,cw.bool,cw.url,cw.contentSeparator,cw.labelName],color:"#219"},{tag:[cw.literal,cw.inserted],color:"#164"},{tag:[cw.string,cw.deleted],color:"#a11"},{tag:[cw.regexp,cw.escape,cw.special(cw.string)],color:"#e40"},{tag:cw.definition(cw.variableName),color:"#00f"},{tag:cw.local(cw.variableName),color:"#30a"},{tag:[cw.typeName,cw.namespace],color:"#085"},{tag:cw.className,color:"#167"},{tag:[cw.special(cw.variableName),cw.macroName],color:"#256"},{tag:cw.definition(cw.propertyName),color:"#00c"},{tag:cw.comment,color:"#940"},{tag:cw.invalid,color:"#f00"}]),dm=ao.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),dg="()[]{}",dv=rt.define({combine:e=>rI(e,{afterCursor:!0,brackets:dg,maxScanDistance:1e4,renderMatch:dy})}),dx=s1.mark({class:"cm-matchingBracket"}),db=s1.mark({class:"cm-nonmatchingBracket"});function dy(e){let t=[],n=e.matched?dx:db;return t.push(n.range(e.start.from,e.start.to)),e.end&&t.push(n.range(e.end.from,e.end.to)),t}let dw=[rl.define({create:()=>s1.none,update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],i=t.state.facet(dv);for(let e of t.state.selection.ranges){if(!e.empty)continue;let r=dA(t.state,e.head,-1,i)||e.head>0&&dA(t.state,e.head-1,1,i)||i.afterCursor&&(dA(t.state,e.head,1,i)||e.head<t.state.doc.length&&dA(t.state,e.head+1,-1,i));r&&(n=n.concat(i.renderMatch(r,t.state)))}return s1.set(n,!0)},provide:e=>ao.decorations.from(e)}),dm],dk=new hR;function dS(e,t,n){let i=e.prop(t<0?hR.openedBy:hR.closedBy);if(i)return i;if(1==e.name.length){let i=n.indexOf(e.name);if(i>-1&&i%2==+(t<0))return[n[i+t]]}return null}function dC(e){let t=e.type.prop(dk);return t?t(e.node):e}function dA(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=i.maxScanDistance||1e4,s=i.brackets||dg,o=cM(e),l=o.resolveInner(t,n);for(let e=l;e;e=e.parent){let i=dS(e.type,n,s);if(i&&e.from<e.to){let r=dC(e);if(r&&(n>0?t>=r.from&&t<r.to:t>r.from&&t<=r.to))return function(e,t,n,i,r,s,o){let l=i.parent,a={from:r.from,to:r.to},h=0,c=null==l?void 0:l.cursor();if(c&&(n<0?c.childBefore(i.from):c.childAfter(i.to)))do if(n<0?c.to<=i.from:c.from>=i.to){if(0==h&&s.indexOf(c.type.name)>-1&&c.from<c.to){let e=dC(c);return{start:a,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}else if(dS(c.type,n,o))h++;else if(dS(c.type,-n,o)){if(0==h){let e=dC(c);return{start:a,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}h--}}while(n<0?c.prevSibling():c.nextSibling())return{start:a,matched:!1}}(0,0,n,e,r,i,s)}}return function(e,t,n,i,r,s,o){let l=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),a=o.indexOf(l);if(a<0||a%2==0!=n>0)return null;let h={from:n<0?t-1:t,to:n>0?t+1:t},c=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!c.next().done&&e<=s;){let s=c.value;n<0&&(e+=s.length);let l=t+e*n;for(let e=n>0?0:s.length-1,t=n>0?s.length:-1;e!=t;e+=n){let t=o.indexOf(s[e]);if(!(t<0)&&i.resolveInner(l+e,1).type==r)if(t%2==0==n>0)d++;else{if(1==d)return{start:h,end:{from:l+e,to:l+e+1},matched:t>>1==a>>1};d--}}n>0&&(e+=s.length)}return c.done?{start:h,matched:!1}:null}(e,t,n,o,l.type,r,s)}let dN=Object.create(null),dM=[hI.none],dO=[],dj=Object.create(null),dE=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"]])dE[e]=function(e,t){let n=[];for(let i of t.split(" ")){let t=[];for(let n of i.split(".")){let i=e[n]||cw[n];i?"function"==typeof i?t.length?t=t.map(i):dT(n,"Modifier ".concat(n," used at start of tag")):t.length?dT(n,"Tag ".concat(n," used as modifier")):t=Array.isArray(i)?i:[i]:dT(n,"Unknown highlighting tag ".concat(n))}for(let e of t)n.push(e)}if(!n.length)return 0;let i=t.replace(/ /g,"_"),r=i+" "+n.map(e=>e.id),s=dj[r];if(s)return s.id;let o=dj[r]=hI.define({id:dM.length,name:i,props:[ct({[i]:n})]});return dM.push(o),o.id}(dN,t);function dT(e,t){dO.indexOf(e)>-1||(dO.push(e),console.warn(t))}function dD(e,t){return n=>{let{state:i,dispatch:r}=n;if(i.readOnly)return!1;let s=e(t,i);return!!s&&(r(i.update(s)),!0)}}oi.RTL,oi.LTR;let dR=dD(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,i=[],r=-1;for(let{from:e,to:s}of n){let n=i.length,o=1e9,l=dI(t,e).line;if(l){for(let n=e;n<=s;){let a=t.doc.lineAt(n);if(a.from>r&&(e==s||s>a.from)){r=a.from;let e=/^\s*/.exec(a.text)[0].length,t=e==a.length,n=a.text.slice(e,e+l.length)==l?e:-1;e<a.text.length&&e<o&&(o=e),i.push({line:a,comment:n,token:l,indent:e,empty:t,single:!1})}n=a.to+1}if(o<1e9)for(let e=n;e<i.length;e++)i[e].indent<i[e].line.text.length&&(i[e].indent=o);i.length==n+1&&(i[n].single=!0)}}if(2!=e&&i.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:r,empty:s,single:o}of i)(o||!s)&&e.push({from:t.from+r,insert:n+" "});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(1!=e&&i.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:r}of i)if(n>=0){let i=t.from+n,s=i+r.length;" "==t.text[s-t.from]&&s++,e.push({from:i,to:s})}return{changes:e}}return null},0),dP=dD(dB,0),dL=dD((e,t)=>dB(e,t,function(e){let t=[];for(let n of e.selection.ranges){let i=e.doc.lineAt(n.from),r=n.to<=i.to?i:e.doc.lineAt(n.to);r.from>i.from&&r.from==n.to&&(r=n.to==i.to+1?i:e.doc.lineAt(n.to-1));let s=t.length-1;s>=0&&t[s].to>i.from?t[s].to=r.to:t.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return t}(t)),0);function dI(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}function dB(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.selection.ranges,i=n.map(e=>dI(t,e.from).block);if(!i.every(e=>e))return null;let r=n.map((e,n)=>(function(e,t,n,i){let r,s,{open:o,close:l}=t,a=e.sliceDoc(n-50,n),h=e.sliceDoc(i,i+50),c=/\s*$/.exec(a)[0].length,d=/^\s*/.exec(h)[0].length,u=a.length-c;if(a.slice(u-o.length,u)==o&&h.slice(d,d+l.length)==l)return{open:{pos:n-c,margin:c&&1},close:{pos:i+d,margin:d&&1}};i-n<=100?r=s=e.sliceDoc(n,i):(r=e.sliceDoc(n,n+50),s=e.sliceDoc(i-50,i));let f=/^\s*/.exec(r)[0].length,p=/\s*$/.exec(s)[0].length,m=s.length-p-l.length;return r.slice(f,f+o.length)==o&&s.slice(m,m+l.length)==l?{open:{pos:n+f+o.length,margin:+!!/\s/.test(r.charAt(f+o.length))},close:{pos:i-p-l.length,margin:+!!/\s/.test(s.charAt(m-1))}}:null})(t,i[n],e.from,e.to));if(2!=e&&!r.every(e=>e))return{changes:t.changes(n.map((e,t)=>r[t]?[]:[{from:e.from,insert:i[t].open+" "},{from:e.to,insert:" "+i[t].close}]))};if(1!=e&&r.some(e=>e)){let e=[];for(let t=0,n;t<r.length;t++)if(n=r[t]){let r=i[t],{open:s,close:o}=n;e.push({from:s.pos-r.open.length,to:s.pos+s.margin},{from:o.pos-o.margin,to:o.pos+r.close.length})}return{changes:e}}return null}let dz=rC.define(),dF=rC.define(),d_=rt.define(),dW=rt.define({combine:e=>rI(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,i)=>e(n,i)||t(n,i)})}),dV=rl.define({create:()=>d1.empty,update(e,t){let n=t.state.facet(dW),i=t.annotation(dz);if(i){let r=dG.fromTransaction(t,i.selection),s=i.side,o=0==s?e.undone:e.done;return o=r?dY(o,o.length,n.minDepth,r):d$(o,t.startState.selection),new d1(0==s?i.rest:o,0==s?o:i.rest)}let r=t.annotation(dF);if(("full"==r||"before"==r)&&(e=e.isolate()),!1===t.annotation(rO.addToHistory))return t.changes.empty?e:e.addMapping(t.changes.desc);let s=dG.fromTransaction(t),o=t.annotation(rO.time),l=t.annotation(rO.userEvent);return s?e=e.addChanges(s,o,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,l,n.newGroupDelay)),("full"==r||"after"==r)&&(e=e.isolate()),e},toJSON:e=>({done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}),fromJSON:e=>new d1(e.done.map(dG.fromJSON),e.undone.map(dG.fromJSON))});function dH(e,t){return function(n){let{state:i,dispatch:r}=n;if(!t&&i.readOnly)return!1;let s=i.field(dV,!1);if(!s)return!1;let o=s.pop(e,i,t);return!!o&&(r(o),!0)}}let dq=dH(0,!1),dK=dH(1,!1),dU=dH(0,!0),dJ=dH(1,!0);class dG{setSelAfter(e){return new dG(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:null==(e=this.changes)?void 0:e.toJSON(),mapped:null==(t=this.mapped)?void 0:t.toJSON(),startSelection:null==(n=this.startSelection)?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(e){return new dG(e.changes&&i0.fromJSON(e.changes),[],e.mapped&&iZ.fromJSON(e.mapped),e.startSelection&&i9.fromJSON(e.startSelection),e.selectionsAfter.map(i9.fromJSON))}static fromTransaction(e,t){let n=dX;for(let t of e.startState.facet(d_)){let i=t(e);i.length&&(n=n.concat(i))}return!n.length&&e.changes.empty?null:new dG(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,dX)}static selection(e){return new dG(void 0,dX,void 0,void 0,e)}constructor(e,t,n,i,r){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=i,this.selectionsAfter=r}}function dY(e,t,n,i){let r=e.slice(t+1>n+20?t-n-1:0,t);return r.push(i),r}function dQ(e,t){return e.length?t.length?e.concat(t):e:t}let dX=[];function d$(e,t){if(!e.length)return[dG.selection([t])];{let n=e[e.length-1],i=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-200));return i.length&&i[i.length-1].eq(t)?e:(i.push(t),dY(e,e.length-1,1e9,n.setSelAfter(i)))}}function dZ(e,t){if(!e.length)return e;let n=e.length,i=dX;for(;n;){let r=function(e,t,n){let i=dQ(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):dX,n);if(!e.changes)return dG.selection(i);let r=e.changes.map(t),s=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(s):s;return new dG(r,rM.mapEffects(e.effects,t),o,e.startSelection.map(s),i)}(e[n-1],t,i);if(r.changes&&!r.changes.empty||r.effects.length){let t=e.slice(0,n);return t[n-1]=r,t}t=r.mapped,n--,i=r.selectionsAfter}return i.length?[dG.selection(i)]:dX}let d0=/^(input\.type|delete)($|\.)/;class d1{isolate(){return this.prevTime?new d1(this.done,this.undone):this}addChanges(e,t,n,i,r){var s,o;let l,a,h=this.done,c=h[h.length-1];return new d1(h=c&&c.changes&&!c.changes.empty&&e.changes&&(!n||d0.test(n))&&(!c.selectionsAfter.length&&t-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,(s=c.changes,o=e.changes,l=[],a=!1,s.iterChangedRanges((e,t)=>l.push(e,t)),o.iterChangedRanges((e,t,n,i)=>{for(let e=0;e<l.length;){let t=l[e++],r=l[e++];i>=t&&n<=r&&(a=!0)}}),a))||"input.type.compose"==n)?dY(h,h.length-1,i.minDepth,new dG(e.changes.compose(c.changes),dQ(rM.mapEffects(e.effects,c.changes),c.effects),c.mapped,c.startSelection,dX)):dY(h,h.length,i.minDepth,e),dX,t,n)}addSelection(e,t,n,i){var r;let s=this.done.length?this.done[this.done.length-1].selectionsAfter:dX;return s.length>0&&t-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&(r=s[s.length-1],r.ranges.length==e.ranges.length&&0===r.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length)?this:new d1(d$(this.done,e),this.undone,t,n)}addMapping(e){return new d1(dZ(this.done,e),dZ(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,n){let i=0==e?this.done:this.undone;if(0==i.length)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||t.selection;if(n&&r.selectionsAfter.length){let n,o;return t.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:dz.of({side:e,rest:(n=i[i.length-1],(o=i.slice())[i.length-1]=n.setSelAfter(n.selectionsAfter.slice(0,n.selectionsAfter.length-1)),o),selection:s}),userEvent:0==e?"select.undo":"select.redo",scrollIntoView:!0})}{if(!r.changes)return null;let n=1==i.length?dX:i.slice(0,i.length-1);return r.mapped&&(n=dZ(n,r.mapped)),t.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:dz.of({side:e,rest:n,selection:s}),filter:!1,userEvent:0==e?"undo":"redo",scrollIntoView:!0})}}constructor(e,t,n=0,i){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=i}}d1.empty=new d1(dX,dX);let d2=[{key:"Mod-z",run:dq,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:dK,preventDefault:!0},{linux:"Ctrl-Shift-z",run:dK,preventDefault:!0},{key:"Mod-u",run:dU,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:dJ,preventDefault:!0}];function d3(e,t){return i9.create(e.ranges.map(t),e.mainIndex)}function d4(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function d5(e,t){let{state:n,dispatch:i}=e,r=d3(n.selection,t);return!r.eq(n.selection,!0)&&(i(d4(n,r)),!0)}function d8(e,t){return i9.cursor(t?e.to:e.from)}function d6(e,t){return d5(e,n=>n.empty?e.moveByChar(n,t):d8(n,t))}function d9(e){return e.textDirectionAt(e.state.selection.main.head)==oi.LTR}let d7=e=>d6(e,!d9(e)),ue=e=>d6(e,d9(e));function ut(e,t){return d5(e,n=>n.empty?e.moveByGroup(n,t):d8(n,t))}function un(e,t,n){let i,r,s=cM(e).resolveInner(t.head),o=n?hR.closedBy:hR.openedBy;for(let i=t.head;;){let t=n?s.childAfter(i):s.childBefore(i);if(!t)break;!function(e,t,n){if(t.type.prop(n))return!0;let i=t.to-t.from;return i&&(i>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}(e,t,o)?i=n?t.to:t.from:s=t}return r=s.type.prop(o)&&(i=n?dA(e,s.from,1):dA(e,s.to,-1))&&i.matched?n?i.end.to:i.end.from:n?s.to:s.from,i9.cursor(r,n?-1:1)}function ui(e,t){return d5(e,n=>{if(!n.empty)return d8(n,t);let i=e.moveVertically(n,t);return i.head!=n.head?i:e.moveToLineBoundary(n,t)})}"undefined"!=typeof Intl&&Intl.Segmenter;let ur=e=>ui(e,!1),us=e=>ui(e,!0);function uo(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,i=0,r;if(t){for(let t of e.state.facet(ao.scrollMargins)){let r=t(e);(null==r?void 0:r.top)&&(n=Math.max(null==r?void 0:r.top,n)),(null==r?void 0:r.bottom)&&(i=Math.max(null==r?void 0:r.bottom,i))}r=e.scrollDOM.clientHeight-n-i}else r=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:i,selfScroll:t,height:Math.max(e.defaultLineHeight,r-5)}}function ul(e,t){let n,i=uo(e),{state:r}=e,s=d3(r.selection,n=>n.empty?e.moveVertically(n,t,i.height):d8(n,t));if(s.eq(r.selection))return!1;if(i.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),l=o.top+i.marginTop,a=o.bottom-i.marginBottom;t&&t.top>l&&t.bottom<a&&(n=ao.scrollIntoView(s.main.head,{y:"start",yMargin:t.top-l}))}return e.dispatch(d4(r,s),{effects:n}),!0}let ua=e=>ul(e,!1),uh=e=>ul(e,!0);function uc(e,t,n){let i=e.lineBlockAt(t.head),r=e.moveToLineBoundary(t,n);if(r.head==t.head&&r.head!=(n?i.to:i.from)&&(r=e.moveToLineBoundary(t,n,!1)),!n&&r.head==i.from&&i.length){let n=/^\s*/.exec(e.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;n&&t.head!=i.from+n&&(r=i9.cursor(i.from+n))}return r}function ud(e,t){let n=d3(e.state.selection,e=>{let n=t(e);return i9.range(e.anchor,n.head,n.goalColumn,n.bidiLevel||void 0)});return!n.eq(e.state.selection)&&(e.dispatch(d4(e.state,n)),!0)}function uu(e,t){return ud(e,n=>e.moveByChar(n,t))}let uf=e=>uu(e,!d9(e)),up=e=>uu(e,d9(e));function um(e,t){return ud(e,n=>e.moveByGroup(n,t))}function ug(e,t){return ud(e,n=>e.moveVertically(n,t))}let uv=e=>ug(e,!1),ux=e=>ug(e,!0);function ub(e,t){return ud(e,n=>e.moveVertically(n,t,uo(e).height))}let uy=e=>ub(e,!1),uw=e=>ub(e,!0),uk=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:0})),!0},uS=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.doc.length})),!0},uC=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.selection.main.anchor,head:0})),!0},uA=e=>{let{state:t,dispatch:n}=e;return n(d4(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0};function uN(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:i}=e,r=i.changeByRange(i=>{let{from:r,to:s}=i;if(r==s){let o=t(i);o<r?(n="delete.backward",o=uM(e,o,!1)):o>r&&(n="delete.forward",o=uM(e,o,!0)),r=Math.min(r,o),s=Math.max(s,o)}else r=uM(e,r,!1),s=uM(e,s,!0);return r==s?{range:i}:{changes:{from:r,to:s},range:i9.cursor(r,r<i.head?-1:1)}});return!r.changes.empty&&(e.dispatch(i.update(r,{scrollIntoView:!0,userEvent:n,effects:"delete.selection"==n?ao.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function uM(e,t,n){if(e instanceof ao)for(let i of e.state.facet(ao.atomicRanges).map(t=>t(e)))i.between(t,t,(e,i)=>{e<t&&i>t&&(t=n?i:e)});return t}let uO=(e,t,n)=>uN(e,i=>{let r=i.from,{state:s}=e,o=s.doc.lineAt(r),l,a;if(n&&!t&&r>o.from&&r<o.from+200&&!/[^ \t]/.test(l=o.text.slice(0,r-o.from))){if(" "==l[l.length-1])return r-1;let e=rZ(l,s.tabSize)%c_(s)||c_(s);for(let t=0;t<e&&" "==l[l.length-1-t];t++)r--;a=r}else(a=iJ(o.text,r-o.from,t,t)+o.from)==r&&o.number!=(t?s.doc.lines:1)?a+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(a-o.from,r-o.from))&&(a=iJ(o.text,a-o.from,!1,!1)+o.from);return a}),uj=e=>uO(e,!1,!0),uE=e=>uO(e,!0,!1),uT=(e,t)=>uN(e,n=>{let i=n.head,{state:r}=e,s=r.doc.lineAt(i),o=r.charCategorizer(i);for(let e=null;;){if(i==(t?s.to:s.from)){i==n.head&&s.number!=(t?r.doc.lines:1)&&(i+=t?1:-1);break}let l=iJ(s.text,i-s.from,t)+s.from,a=s.text.slice(Math.min(i,l)-s.from,Math.max(i,l)-s.from),h=o(a);if(null!=e&&h!=e)break;(" "!=a||i!=n.head)&&(e=h),i=l}return i}),uD=e=>uT(e,!1);function uR(e){let t=[],n=-1;for(let i of e.selection.ranges){let r=e.doc.lineAt(i.from),s=e.doc.lineAt(i.to);if(i.empty||i.to!=s.from||(s=e.doc.lineAt(i.to-1)),n>=r.number){let e=t[t.length-1];e.to=s.to,e.ranges.push(i)}else t.push({from:r.from,to:s.to,ranges:[i]});n=s.number+1}return t}function uP(e,t,n){if(e.readOnly)return!1;let i=[],r=[];for(let t of uR(e)){if(n?t.to==e.doc.length:0==t.from)continue;let s=e.doc.lineAt(n?t.to+1:t.from-1),o=s.length+1;if(n)for(let n of(i.push({from:t.to,to:s.to},{from:t.from,insert:s.text+e.lineBreak}),t.ranges))r.push(i9.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)));else for(let n of(i.push({from:s.from,to:t.from},{from:t.to,insert:e.lineBreak+s.text}),t.ranges))r.push(i9.range(n.anchor-o,n.head-o))}return!!i.length&&(t(e.update({changes:i,scrollIntoView:!0,selection:i9.create(r,e.selection.mainIndex),userEvent:"move.line"})),!0)}function uL(e,t,n){if(e.readOnly)return!1;let i=[];for(let t of uR(e))n?i.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):i.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});return t(e.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}let uI=uz(!1),uB=uz(!0);function uz(e){return t=>{let{state:n,dispatch:i}=t;if(n.readOnly)return!1;let r=n.changeByRange(t=>{let{from:i,to:r}=t,s=n.doc.lineAt(i),o=!e&&i==r&&function(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=cM(e).resolveInner(t),i=n.childBefore(t),r=n.childAfter(t),s;return i&&r&&i.to<=t&&r.from>=t&&(s=i.type.prop(hR.closedBy))&&s.indexOf(r.name)>-1&&e.doc.lineAt(i.to).from==e.doc.lineAt(r.from).from&&!/\S/.test(e.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}(n,i);e&&(i=r=(r<=s.to?s:n.doc.lineAt(r)).to);let l=new cH(n,{simulateBreak:i,simulateDoubleBreak:!!o}),a=cV(l,i);for(null==a&&(a=rZ(/^\s*/.exec(n.doc.lineAt(i).text)[0],n.tabSize));r<s.to&&/\s/.test(s.text[r-s.from]);)r++;o?{from:i,to:r}=o:i>s.from&&i<s.from+100&&!/\S/.test(s.text.slice(0,i))&&(i=s.from);let h=["",cW(n,a)];return o&&h.push(cW(n,l.lineIndent(s.from,-1))),{changes:{from:i,to:r,insert:iz.of(h)},range:i9.cursor(i+1+h[1].length)}});return i(n.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function uF(e,t){let n=-1;return e.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let o=e.doc.lineAt(s);o.number>n&&(i.empty||i.to>o.from)&&(t(o,r,i),n=o.number),s=o.to+1}let s=e.changes(r);return{changes:r,range:i9.range(s.mapPos(i.anchor,1),s.mapPos(i.head,1))}})}let u_=e=>{let{state:t,dispatch:n}=e;return!t.readOnly&&(n(t.update(uF(t,(e,n)=>{n.push({from:e.from,insert:t.facet(cF)})}),{userEvent:"input.indent"})),!0)},uW=e=>{let{state:t,dispatch:n}=e;return!t.readOnly&&(n(t.update(uF(t,(e,n)=>{let i=/^\s*/.exec(e.text)[0];if(!i)return;let r=rZ(i,t.tabSize),s=0,o=cW(t,Math.max(0,r-c_(t)));for(;s<i.length&&s<o.length&&i.charCodeAt(s)==o.charCodeAt(s);)s++;n.push({from:e.from+s,to:e.from+i.length,insert:o.slice(s)})}),{userEvent:"delete.dedent"})),!0)},uV=[{key:"Ctrl-b",run:d7,shift:uf,preventDefault:!0},{key:"Ctrl-f",run:ue,shift:up},{key:"Ctrl-p",run:ur,shift:uv},{key:"Ctrl-n",run:us,shift:ux},{key:"Ctrl-a",run:e=>d5(e,t=>i9.cursor(e.lineBlockAt(t.head).from,1)),shift:e=>ud(e,t=>i9.cursor(e.lineBlockAt(t.head).from))},{key:"Ctrl-e",run:e=>d5(e,t=>i9.cursor(e.lineBlockAt(t.head).to,-1)),shift:e=>ud(e,t=>i9.cursor(e.lineBlockAt(t.head).to))},{key:"Ctrl-d",run:uE},{key:"Ctrl-h",run:uj},{key:"Ctrl-k",run:e=>uN(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})},{key:"Ctrl-Alt-h",run:uD},{key:"Ctrl-o",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=t.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:iz.of(["",""])},range:i9.cursor(e.from)}));return n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}},{key:"Ctrl-t",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=t.changeByRange(e=>{if(!e.empty||0==e.from||e.from==t.doc.length)return{range:e};let n=e.from,i=t.doc.lineAt(n),r=n==i.from?n-1:iJ(i.text,n-i.from,!1)+i.from,s=n==i.to?n+1:iJ(i.text,n-i.from,!0)+i.from;return{changes:{from:r,to:s,insert:t.doc.slice(n,s).append(t.doc.slice(r,n))},range:i9.cursor(s)}});return!i.changes.empty&&(n(t.update(i,{scrollIntoView:!0,userEvent:"move.character"})),!0)}},{key:"Ctrl-v",run:uh}],uH=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:e=>d5(e,t=>un(e.state,t,!d9(e))),shift:e=>ud(e,t=>un(e.state,t,!d9(e)))},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:e=>d5(e,t=>un(e.state,t,d9(e))),shift:e=>ud(e,t=>un(e.state,t,d9(e)))},{key:"Alt-ArrowUp",run:e=>{let{state:t,dispatch:n}=e;return uP(t,n,!1)}},{key:"Shift-Alt-ArrowUp",run:e=>{let{state:t,dispatch:n}=e;return uL(t,n,!1)}},{key:"Alt-ArrowDown",run:e=>{let{state:t,dispatch:n}=e;return uP(t,n,!0)}},{key:"Shift-Alt-ArrowDown",run:e=>{let{state:t,dispatch:n}=e;return uL(t,n,!0)}},{key:"Escape",run:e=>{let{state:t,dispatch:n}=e,i=t.selection,r=null;return i.ranges.length>1?r=i9.create([i.main]):i.main.empty||(r=i9.create([i9.cursor(i.main.head)])),!!r&&(n(d4(t,r)),!0)}},{key:"Mod-Enter",run:uB},{key:"Alt-l",mac:"Ctrl-l",run:e=>{let{state:t,dispatch:n}=e,i=uR(t).map(e=>{let{from:n,to:i}=e;return i9.range(n,Math.min(i+1,t.doc.length))});return n(t.update({selection:i9.create(i),userEvent:"select"})),!0}},{key:"Mod-i",run:e=>{let{state:t,dispatch:n}=e,i=d3(t.selection,e=>{let n=cM(t),i=n.resolveStack(e.from,1);if(e.empty){let t=n.resolveStack(e.from,-1);t.node.from>=i.node.from&&t.node.to<=i.node.to&&(i=t)}for(let t=i;t;t=t.next){let{node:n}=t;if((n.from<e.from&&n.to>=e.to||n.to>e.to&&n.from<=e.from)&&t.next)return i9.range(n.to,n.from)}return e});return!i.eq(t.selection)&&(n(d4(t,i)),!0)},preventDefault:!0},{key:"Mod-[",run:uW},{key:"Mod-]",run:u_},{key:"Mod-Alt-\\",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=Object.create(null),r=new cH(t,{overrideIndentation:e=>{let t=i[e];return null==t?-1:t}}),s=uF(t,(e,n,s)=>{let o=cV(r,e.from);if(null==o)return;/\S/.test(e.text)||(o=0);let l=/^\s*/.exec(e.text)[0],a=cW(t,o);(l!=a||s.from<e.from+l.length)&&(i[e.from]=o,n.push({from:e.from,to:e.from+l.length,insert:a}))});return s.changes.empty||n(t.update(s,{userEvent:"indent"})),!0}},{key:"Shift-Mod-k",run:e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(uR(t).map(e=>{let{from:n,to:i}=e;return n>0?n--:i<t.doc.length&&i++,{from:n,to:i}})),i=d3(t.selection,t=>{let n;if(e.lineWrapping){let i=e.lineBlockAt(t.head),r=e.coordsAtPos(t.head,t.assoc||1);r&&(n=i.bottom+e.documentTop-r.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0}},{key:"Shift-Mod-\\",run:e=>{let{state:t,dispatch:n}=e;return function(e,t,n){let i=!1,r=d3(e.selection,t=>{let r=dA(e,t.head,-1)||dA(e,t.head,1)||t.head>0&&dA(e,t.head-1,1)||t.head<e.doc.length&&dA(e,t.head+1,-1);if(!r||!r.end)return t;i=!0;let s=r.start.from==t.head?r.end.to:r.end.from;return n?i9.range(t.anchor,s):i9.cursor(s)});return!!i&&(t(d4(e,r)),!0)}(t,n,!1)}},{key:"Mod-/",run:e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),i=dI(e.state,n.from);return i.line?dR(e):!!i.block&&dL(e)}},{key:"Alt-A",run:dP},{key:"Ctrl-m",mac:"Shift-Alt-m",run:e=>(e.setTabFocusMode(),!0)}].concat([{key:"ArrowLeft",run:d7,shift:uf,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:e=>ut(e,!d9(e)),shift:e=>um(e,!d9(e)),preventDefault:!0},{mac:"Cmd-ArrowLeft",run:e=>d5(e,t=>uc(e,t,!d9(e))),shift:e=>ud(e,t=>uc(e,t,!d9(e))),preventDefault:!0},{key:"ArrowRight",run:ue,shift:up,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:e=>ut(e,d9(e)),shift:e=>um(e,d9(e)),preventDefault:!0},{mac:"Cmd-ArrowRight",run:e=>d5(e,t=>uc(e,t,d9(e))),shift:e=>ud(e,t=>uc(e,t,d9(e))),preventDefault:!0},{key:"ArrowUp",run:ur,shift:uv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:uk,shift:uC},{mac:"Ctrl-ArrowUp",run:ua,shift:uy},{key:"ArrowDown",run:us,shift:ux,preventDefault:!0},{mac:"Cmd-ArrowDown",run:uS,shift:uA},{mac:"Ctrl-ArrowDown",run:uh,shift:uw},{key:"PageUp",run:ua,shift:uy},{key:"PageDown",run:uh,shift:uw},{key:"Home",run:e=>d5(e,t=>uc(e,t,!1)),shift:e=>ud(e,t=>uc(e,t,!1)),preventDefault:!0},{key:"Mod-Home",run:uk,shift:uC},{key:"End",run:e=>d5(e,t=>uc(e,t,!0)),shift:e=>ud(e,t=>uc(e,t,!0)),preventDefault:!0},{key:"Mod-End",run:uS,shift:uA},{key:"Enter",run:uI,shift:uI},{key:"Mod-a",run:e=>{let{state:t,dispatch:n}=e;return n(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0}},{key:"Backspace",run:uj,shift:uj},{key:"Delete",run:uE},{key:"Mod-Backspace",mac:"Alt-Backspace",run:uD},{key:"Mod-Delete",mac:"Alt-Delete",run:e=>uT(e,!0)},{mac:"Mod-Backspace",run:e=>uN(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)})},{mac:"Mod-Delete",run:e=>uN(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)})}].concat(uV.map(e=>({mac:e.key,run:e.run,shift:e.shift})))),uq={key:"Tab",run:u_,shift:uW},uK="function"==typeof String.prototype.normalize?e=>e.normalize("NFKD"):e=>e;class uU{peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return -1;this.bufferPos=0,this.buffer=this.iter.value}return iG(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=iY(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=iQ(e);let i=this.normalize(t);if(i.length)for(let e=0,r=n;;e++){let s=i.charCodeAt(e),o=this.match(s,r,this.bufferPos+this.bufferStart);if(e==i.length-1){if(o)return this.value=o,this;break}r==n&&e<t.length&&t.charCodeAt(e)==s&&r++}}}match(e,t,n){let i=null;for(let t=0;t<this.matches.length;t+=2){let r=this.matches[t],s=!1;this.query.charCodeAt(r)==e&&(r==this.query.length-1?i={from:this.matches[t+1],to:n}:(this.matches[t]++,s=!0)),s||(this.matches.splice(t,2),t-=2)}return this.query.charCodeAt(0)==e&&(1==this.query.length?i={from:t,to:n}:this.matches.push(1,t)),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}constructor(e,t,n=0,i=e.length,r,s){this.test=s,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,i),this.bufferStart=n,this.normalize=r?e=>r(uK(e)):uK,this.query=this.normalize(t)}}"undefined"!=typeof Symbol&&(uU.prototype[Symbol.iterator]=function(){return this});let uJ={from:-1,to:-1,match:/.*/.exec("")},uG="gm"+(null==/x/.unicode?"":"u");class uY{getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,i=n+t[0].length;if(this.matchPos=uZ(this.text,i+ +(n==i)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<i||n>this.value.to)&&(!this.test||this.test(n,i,t)))return this.value={from:n,to:i,match:t},this;e=this.matchPos-this.curLineStart}else{if(!(this.curLineStart+this.curLine.length<this.to))return this.done=!0,this;this.nextLine(),e=0}}}constructor(e,t,n,i=0,r=e.length){if(this.text=e,this.to=r,this.curLine="",this.done=!1,this.value=uJ,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new u$(e,t,n,i,r);this.re=new RegExp(t,uG+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.iter=e.iter();let s=e.lineAt(i);this.curLineStart=s.from,this.matchPos=uZ(e,i),this.getLine(this.curLineStart)}}let uQ=new WeakMap;class uX{get to(){return this.from+this.text.length}static get(e,t,n){let i=uQ.get(e);if(!i||i.from>=n||i.to<=t){let i=new uX(t,e.sliceString(t,n));return uQ.set(e,i),i}if(i.from==t&&i.to==n)return i;let{text:r,from:s}=i;return s>t&&(r=e.sliceString(t,s)+r,s=t),i.to<n&&(r+=e.sliceString(i.to,n)),uQ.set(e,new uX(s,r)),new uX(t,r.slice(t-s,n-s))}constructor(e,t){this.from=e,this.text=t}}class u${chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,match:t},this.matchPos=uZ(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=uX.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+2*this.flat.text.length))}}constructor(e,t,n,i,r){this.text=e,this.to=r,this.done=!1,this.value=uJ,this.matchPos=uZ(e,i),this.re=new RegExp(t,uG+((null==n?void 0:n.ignoreCase)?"i":"")),this.test=null==n?void 0:n.test,this.flat=uX.get(e,i,this.chunkEnd(i+5e3))}}function uZ(e,t){if(t>=e.length)return t;let n=e.lineAt(t),i;for(;t<n.to&&(i=n.text.charCodeAt(t-n.from))>=56320&&i<57344;)t++;return t}function u0(e){let t=si("input",{class:"cm-textfield",name:"line",value:String(e.state.doc.lineAt(e.state.selection.main.head).number)});function n(){let n=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!n)return;let{state:i}=e,r=i.doc.lineAt(i.selection.main.head),[,s,o,l,a]=n,h=l?+l.slice(1):0,c=o?+o:r.number;if(o&&a){let e=c/100;s&&(e=e*("-"==s?-1:1)+r.number/i.doc.lines),c=Math.round(i.doc.lines*e)}else o&&s&&(c=c*("-"==s?-1:1)+r.number);let d=i.doc.line(Math.max(1,Math.min(i.doc.lines,c))),u=i9.cursor(d.from+Math.max(0,Math.min(h,d.length)));e.dispatch({effects:[u1.of(!1),ao.scrollIntoView(u.from,{y:"center"})],selection:u}),e.focus()}return{dom:si("form",{class:"cm-gotoLine",onkeydown:t=>{27==t.keyCode?(t.preventDefault(),e.dispatch({effects:u1.of(!1)}),e.focus()):13==t.keyCode&&(t.preventDefault(),n())},onsubmit:e=>{e.preventDefault(),n()}},si("label",e.state.phrase("Go to line"),": ",t)," ",si("button",{class:"cm-button",type:"submit"},e.state.phrase("go")),si("button",{name:"close",onclick:()=>{e.dispatch({effects:u1.of(!1)}),e.focus()},"aria-label":e.state.phrase("close"),type:"button"},["×"]))}}"undefined"!=typeof Symbol&&(uY.prototype[Symbol.iterator]=u$.prototype[Symbol.iterator]=function(){return this});let u1=rM.define(),u2=rl.define({create:()=>!0,update(e,t){for(let n of t.effects)n.is(u1)&&(e=n.value);return e},provide:e=>ha.from(e,e=>e?u0:null)}),u3=ao.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),u4={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},u5=rt.define({combine:e=>rI(e,u4,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}),u8=s1.mark({class:"cm-selectionMatch"}),u6=s1.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function u9(e,t,n,i){return(0==n||e(t.sliceDoc(n-1,n))!=rR.Word)&&(i==t.doc.length||e(t.sliceDoc(i,i+1))!=rR.Word)}let u7=oI.fromClass(class{update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(u5),{state:n}=e,i=n.selection;if(i.ranges.length>1)return s1.none;let r=i.main,s,o=null;if(r.empty){if(!t.highlightWordAroundCursor)return s1.none;let e=n.wordAt(r.head);if(!e)return s1.none;o=n.charCategorizer(r.head),s=n.sliceDoc(e.from,e.to)}else{let e=r.to-r.from;if(e<t.minSelectionLength||e>200)return s1.none;if(t.wholeWords){var l,a,h;if(s=n.sliceDoc(r.from,r.to),!(u9(o=n.charCategorizer(r.head),n,r.from,r.to)&&(l=o,a=r.from,h=r.to,l(n.sliceDoc(a,a+1))==rR.Word&&l(n.sliceDoc(h-1,h))==rR.Word)))return s1.none}else if(!(s=n.sliceDoc(r.from,r.to)))return s1.none}let c=[];for(let i of e.visibleRanges){let e=new uU(n.doc,s,i.from,i.to);for(;!e.next().done;){let{from:i,to:s}=e.value;if((!o||u9(o,n,i,s))&&(r.empty&&i<=r.from&&s>=r.to?c.push(u6.range(i,s)):(i>=r.to||s<=r.from)&&c.push(u8.range(i,s)),c.length>t.maxMatches))return s1.none}}return s1.set(c)}constructor(e){this.decorations=this.getDeco(e)}},{decorations:e=>e.decorations}),fe=ao.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),ft=rt.define({combine:e=>rI(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new fE(e),scrollToMatch:e=>ao.scrollIntoView(e)})});class fn{unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>"n"==t?"\n":"r"==t?"\r":"t"==t?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new fh(this):new fs(this)}getCursor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,i=e.doc?e:rL.create({doc:e});return null==n&&(n=i.doc.length),this.regexp?fo(this,i,t,n):fr(this,i,t,n)}constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||function(e){try{return new RegExp(e,uG),!0}catch(e){return!1}}(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}}class fi{constructor(e){this.spec=e}}function fr(e,t,n,i){var r,s;return new uU(t.doc,e.unquoted,n,i,e.caseSensitive?void 0:e=>e.toLowerCase(),e.wholeWord?(r=t.doc,s=t.charCategorizer(t.selection.main.head),(e,t,n,i)=>((i>e||i+n.length<t)&&(i=Math.max(0,e-2),n=r.sliceString(i,Math.min(r.length,t+2))),(s(fl(n,e-i))!=rR.Word||s(fa(n,e-i))!=rR.Word)&&(s(fa(n,t-i))!=rR.Word||s(fl(n,t-i))!=rR.Word))):void 0)}class fs extends fi{nextMatch(e,t,n){let i=fr(this.spec,e,n,e.doc.length).nextOverlapping();if(i.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);i=fr(this.spec,e,0,n).nextOverlapping()}return i.done||i.value.from==t&&i.value.to==n?null:i.value}prevMatchInRange(e,t,n){for(let i=n;;){let n=Math.max(t,i-1e4-this.spec.unquoted.length),r=fr(this.spec,e,n,i),s=null;for(;!r.nextOverlapping().done;)s=r.value;if(s)return s;if(n==t)return null;i-=1e4}}prevMatch(e,t,n){let i=this.prevMatchInRange(e,0,t);return i||(i=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length)),i&&(i.from!=t||i.to!=n)?i:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=fr(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=fr(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}constructor(e){super(e)}}function fo(e,t,n,i){var r;return new uY(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:e.wholeWord?(r=t.charCategorizer(t.selection.main.head),(e,t,n)=>!n[0].length||(r(fl(n.input,n.index))!=rR.Word||r(fa(n.input,n.index))!=rR.Word)&&(r(fa(n.input,n.index+n[0].length))!=rR.Word||r(fl(n.input,n.index+n[0].length))!=rR.Word)):void 0},n,i)}function fl(e,t){return e.slice(iJ(e,t,!1),t)}function fa(e,t){return e.slice(t,iJ(e,t))}class fh extends fi{nextMatch(e,t,n){let i=fo(this.spec,e,n,e.doc.length).next();return i.done&&(i=fo(this.spec,e,0,t).next()),i.done?null:i.value}prevMatchInRange(e,t,n){for(let i=1;;i++){let r=Math.max(t,n-1e4*i),s=fo(this.spec,e,r,n),o=null;for(;!s.next().done;)o=s.value;if(o&&(r==t||o.from>r+10))return o;if(r==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if("&"==n)return e.match[0];if("$"==n)return"$";for(let t=n.length;t>0;t--){let i=+n.slice(0,t);if(i>0&&i<e.match.length)return e.match[i]+n.slice(t)}return t})}matchAll(e,t){let n=fo(this.spec,e,0,e.doc.length),i=[];for(;!n.next().done;){if(i.length>=t)return null;i.push(n.value)}return i}highlight(e,t,n,i){let r=fo(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!r.next().done;)i(r.value.from,r.value.to)}}let fc=rM.define(),fd=rM.define(),fu=rl.define({create:e=>new ff(fC(e).create(),null),update(e,t){for(let n of t.effects)n.is(fc)?e=new ff(n.value.create(),e.panel):n.is(fd)&&(e=new ff(e.query,n.value?fS:null));return e},provide:e=>ha.from(e,e=>e.panel)});class ff{constructor(e,t){this.query=e,this.panel=t}}let fp=s1.mark({class:"cm-searchMatch"}),fm=s1.mark({class:"cm-searchMatch cm-searchMatch-selected"}),fg=oI.fromClass(class{update(e){let t=e.state.field(fu);(t!=e.startState.field(fu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){let{query:t,panel:n}=e;if(!n||!t.spec.valid)return s1.none;let{view:i}=this,r=new rV;for(let e=0,n=i.visibleRanges,s=n.length;e<s;e++){let{from:o,to:l}=n[e];for(;e<s-1&&l>n[e+1].from-500;)l=n[++e].to;t.highlight(i.state,o,l,(e,t)=>{let n=i.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,n?fm:fp)})}return r.finish()}constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(fu))}},{decorations:e=>e.decorations});function fv(e){return t=>{let n=t.state.field(fu,!1);return n&&n.query.spec.valid?e(t,n):fM(t)}}let fx=fv((e,t)=>{let{query:n}=t,{to:i}=e.state.selection.main,r=n.nextMatch(e.state,i,i);if(!r)return!1;let s=i9.single(r.from,r.to),o=e.state.facet(ft);return e.dispatch({selection:s,effects:[fR(e,r),o.scrollToMatch(s.main,e)],userEvent:"select.search"}),fN(e),!0}),fb=fv((e,t)=>{let{query:n}=t,{state:i}=e,{from:r}=i.selection.main,s=n.prevMatch(i,r,r);if(!s)return!1;let o=i9.single(s.from,s.to),l=e.state.facet(ft);return e.dispatch({selection:o,effects:[fR(e,s),l.scrollToMatch(o.main,e)],userEvent:"select.search"}),fN(e),!0}),fy=fv((e,t)=>{let{query:n}=t,i=n.matchAll(e.state,1e3);return!!i&&!!i.length&&(e.dispatch({selection:i9.create(i.map(e=>i9.range(e.from,e.to))),userEvent:"select.search.matches"}),!0)}),fw=fv((e,t)=>{let{query:n}=t,{state:i}=e,{from:r,to:s}=i.selection.main;if(i.readOnly)return!1;let o=n.nextMatch(i,r,r);if(!o)return!1;let l=o,a=[],h,c,d=[];l.from==r&&l.to==s&&(c=i.toText(n.getReplacement(l)),a.push({from:l.from,to:l.to,insert:c}),l=n.nextMatch(i,l.from,l.to),d.push(ao.announce.of(i.phrase("replaced match on line $",i.doc.lineAt(r).number)+".")));let u=e.state.changes(a);return l&&(h=i9.single(l.from,l.to).map(u),d.push(fR(e,l)),d.push(i.facet(ft).scrollToMatch(h.main,e))),e.dispatch({changes:u,selection:h,effects:d,userEvent:"input.replace"}),!0}),fk=fv((e,t)=>{let{query:n}=t;if(e.state.readOnly)return!1;let i=n.matchAll(e.state,1e9).map(e=>{let{from:t,to:i}=e;return{from:t,to:i,insert:n.getReplacement(e)}});if(!i.length)return!1;let r=e.state.phrase("replaced $ matches",i.length)+".";return e.dispatch({changes:i,effects:ao.announce.of(r),userEvent:"input.replace.all"}),!0});function fS(e){return e.state.facet(ft).createPanel(e)}function fC(e,t){var n,i,r,s,o;let l=e.selection.main,a=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!a)return t;let h=e.facet(ft);return new fn({search:(null!=(n=null==t?void 0:t.literal)?n:h.literal)?a:a.replace(/\n/g,"\\n"),caseSensitive:null!=(i=null==t?void 0:t.caseSensitive)?i:h.caseSensitive,literal:null!=(r=null==t?void 0:t.literal)?r:h.literal,regexp:null!=(s=null==t?void 0:t.regexp)?s:h.regexp,wholeWord:null!=(o=null==t?void 0:t.wholeWord)?o:h.wholeWord})}function fA(e){let t=hr(e,fS);return t&&t.dom.querySelector("[main-field]")}function fN(e){let t=fA(e);t&&t==e.root.activeElement&&t.select()}let fM=e=>{let t=e.state.field(fu,!1);if(t&&t.panel){let n=fA(e);if(n&&n!=e.root.activeElement){let i=fC(e.state,t.query.spec);i.valid&&e.dispatch({effects:fc.of(i)}),n.focus(),n.select()}}else e.dispatch({effects:[fd.of(!0),t?fc.of(fC(e.state,t.query.spec)):rM.appendConfig.of(fL)]});return!0},fO=e=>{let t=e.state.field(fu,!1);if(!t||!t.panel)return!1;let n=hr(e,fS);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:fd.of(!1)}),!0},fj=[{key:"Mod-f",run:fM,scope:"editor search-panel"},{key:"F3",run:fx,shift:fb,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:fx,shift:fb,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:fO,scope:"editor search-panel"},{key:"Mod-Shift-l",run:e=>{let{state:t,dispatch:n}=e,i=t.selection;if(i.ranges.length>1||i.main.empty)return!1;let{from:r,to:s}=i.main,o=[],l=0;for(let e=new uU(t.doc,t.sliceDoc(r,s));!e.next().done;){if(o.length>1e3)return!1;e.value.from==r&&(l=o.length),o.push(i9.range(e.value.from,e.value.to))}return n(t.update({selection:i9.create(o,l),userEvent:"select.search.matches"})),!0}},{key:"Mod-Alt-g",run:e=>{let t=hr(e,u0);if(!t){let n=[u1.of(!0)];null==e.state.field(u2,!1)&&n.push(rM.appendConfig.of([u2,u3])),e.dispatch({effects:n}),t=hr(e,u0)}return t&&t.dom.querySelector("input").select(),!0}},{key:"Mod-d",run:e=>{let{state:t,dispatch:n}=e,{ranges:i}=t.selection;if(i.some(e=>e.from===e.to))return(e=>{let{state:t,dispatch:n}=e,{selection:i}=t,r=i9.create(i.ranges.map(e=>t.wordAt(e.head)||i9.cursor(e.head)),i.mainIndex);return!r.eq(i)&&(n(t.update({selection:r})),!0)})({state:t,dispatch:n});let r=t.sliceDoc(i[0].from,i[0].to);if(t.selection.ranges.some(e=>t.sliceDoc(e.from,e.to)!=r))return!1;let s=function(e,t){let{main:n,ranges:i}=e.selection,r=e.wordAt(n.head),s=r&&r.from==n.from&&r.to==n.to;for(let n=!1,r=new uU(e.doc,t,i[i.length-1].to);;)if(r.next(),r.done){if(n)return null;r=new uU(e.doc,t,0,Math.max(0,i[i.length-1].from-1)),n=!0}else{if(n&&i.some(e=>e.from==r.value.from))continue;if(s){let t=e.wordAt(r.value.from);if(!t||t.from!=r.value.from||t.to!=r.value.to)continue}return r.value}}(t,r);return!!s&&(n(t.update({selection:t.selection.addRange(i9.range(s.from,s.to),!1),effects:ao.scrollIntoView(s.to)})),!0)},preventDefault:!0}];class fE{commit(){let e=new fn({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:fc.of(e)}))}keydown(e){var t;(t=this.view,ab(ag(t.state),e,t,"search-panel"))?e.preventDefault():13==e.keyCode&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?fb:fx)(this.view)):13==e.keyCode&&e.target==this.replaceField&&(e.preventDefault(),fw(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(fc)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(ft).top}constructor(e){this.view=e;let t=this.query=e.state.field(fu).query.spec;function n(e,t,n){return si("button",{class:"cm-button",name:e,onclick:t,type:"button"},n)}this.commit=this.commit.bind(this),this.searchField=si("input",{value:t.search,placeholder:fT(e,"Find"),"aria-label":fT(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=si("input",{value:t.replace,placeholder:fT(e,"Replace"),"aria-label":fT(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=si("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=si("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=si("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit}),this.dom=si("div",{onkeydown:e=>this.keydown(e),class:"cm-search"},[this.searchField,n("next",()=>fx(e),[fT(e,"next")]),n("prev",()=>fb(e),[fT(e,"previous")]),n("select",()=>fy(e),[fT(e,"all")]),si("label",null,[this.caseField,fT(e,"match case")]),si("label",null,[this.reField,fT(e,"regexp")]),si("label",null,[this.wordField,fT(e,"by word")]),...e.state.readOnly?[]:[si("br"),this.replaceField,n("replace",()=>fw(e),[fT(e,"replace")]),n("replaceAll",()=>fk(e),[fT(e,"replace all")])],si("button",{name:"close",onclick:()=>fO(e),"aria-label":fT(e,"close"),type:"button"},["×"])])}}function fT(e,t){return e.state.phrase(t)}let fD=/[\s\.,:;?!]/;function fR(e,t){let{from:n,to:i}=t,r=e.state.doc.lineAt(n),s=e.state.doc.lineAt(i).to,o=Math.max(r.from,n-30),l=Math.min(s,i+30),a=e.state.sliceDoc(o,l);if(o!=r.from){for(let e=0;e<30;e++)if(!fD.test(a[e+1])&&fD.test(a[e])){a=a.slice(e);break}}if(l!=s){for(let e=a.length-1;e>a.length-30;e--)if(!fD.test(a[e-1])&&fD.test(a[e])){a=a.slice(0,e);break}}return ao.announce.of("".concat(e.state.phrase("current match"),". ").concat(a," ").concat(e.state.phrase("on line")," ").concat(r.number,"."))}let fP=ao.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),fL=[fu,rc.low(fg),fP];class fI{tokenBefore(e){let t=cM(this.state).resolveInner(this.pos,-1);for(;t&&0>e.indexOf(t.name);)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),i=t.text.slice(n-t.from,this.pos-t.from),r=i.search(f_(e,!1));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return null==this.abortListeners}addEventListener(e,t,n){"abort"==e&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}constructor(e,t,n,i){this.state=e,this.pos=t,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=!1}}function fB(e){let t=Object.keys(e).join(""),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,"")),"[".concat(n?"\\w":"").concat(t.replace(/[^\w\s]/g,"\\$&"),"]")}class fz{constructor(e,t,n,i){this.completion=e,this.source=t,this.match=n,this.score=i}}function fF(e){return e.selection.main.from}function f_(e,t){var n;let{source:i}=e,r=t&&"^"!=i[0],s="$"!=i[i.length-1];return r||s?new RegExp("".concat(r?"^":"","(?:").concat(i,")").concat(s?"$":""),null!=(n=e.flags)?n:e.ignoreCase?"i":""):e}let fW=rC.define(),fV=new WeakMap;function fH(e){if(!Array.isArray(e))return e;let t=fV.get(e);return t||fV.set(e,t=function(e){let t=e.map(e=>"string"==typeof e?{label:e}:e),[n,i]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:function(e){let t=Object.create(null),n=Object.create(null);for(let{label:i}of e){t[i[0]]=!0;for(let e=1;e<i.length;e++)n[i[e]]=!0}let i=fB(t)+fB(n)+"*$";return[RegExp("^"+i),new RegExp(i)]}(t);return e=>{let r=e.matchBefore(i);return r||e.explicit?{from:r?r.from:e.pos,options:t,validFor:n}:null}}(e)),t}let fq=rM.define(),fK=rM.define();class fU{ret(e,t){return this.score=e,this.matched=t,this}match(e){if(0==this.pattern.length)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:i,precise:r,byWord:s}=this;if(1==t.length){let i=iG(e,0),r=iQ(i),s=r==e.length?0:-100;if(i==t[0]);else{if(i!=n[0])return null;s+=-200}return this.ret(s,[0,r])}let o=e.indexOf(this.pattern);if(0==o)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,a=0;if(o<0){for(let r=0,s=Math.min(e.length,200);r<s&&a<l;){let s=iG(e,r);(s==t[a]||s==n[a])&&(i[a++]=r),r+=iQ(s)}if(a<l)return null}let h=0,c=0,d=!1,u=0,f=-1,p=-1,m=/[a-z]/.test(e),g=!0;for(let i=0,a=Math.min(e.length,200),v=0;i<a&&c<l;){let a=iG(e,i);o<0&&(h<l&&a==t[h]&&(r[h++]=i),u<l&&(a==t[u]||a==n[u]?(0==u&&(f=i),p=i+1,u++):u=0));let x,b=a<255?a>=48&&a<=57||a>=97&&a<=122?2:+(a>=65&&a<=90):(x=iY(a))!=x.toLowerCase()?1:2*(x!=x.toUpperCase());(!i||1==b&&m||0==v&&0!=b)&&(t[c]==a||n[c]==a&&(d=!0)?s[c++]=i:s.length&&(g=!1)),v=b,i+=iQ(a)}return c==l&&0==s[0]&&g?this.result(-100+(d?-200:0),s,e):u==l&&0==f?this.ret(-200-e.length+(p==e.length?0:-100),[0,p]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):u==l?this.ret(-900-e.length,[f,p]):c==l?this.result(-100+(d?-200:0)+-700+(g?0:-1100),s,e):2==t.length?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,t,n){let i=[],r=0;for(let e of t){let t=e+(this.astral?iQ(iG(n,e)):1);r&&i[r-1]==e?i[r-1]=t:(i[r++]=e,i[r++]=t)}return this.ret(e-n.length,i)}constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=iG(e,t),i=iQ(n);this.chars.push(n);let r=e.slice(t,t+i),s=r.toUpperCase();this.folded.push(iG(s==r?r.toLowerCase():s,0)),t+=i}this.astral=e.length!=this.chars.length}}class fJ{match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return null==n?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}}let fG=rt.define({combine:e=>rI(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:fQ,filterStrict:!1,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>fY(e(n),t(n)),optionClass:(e,t)=>n=>fY(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})});function fY(e,t){return e?t?e+" "+t:e:t}function fQ(e,t,n,i,r,s){let o=e.textDirection==oi.RTL,l=o,a=!1,h="top",c,d,u=t.left-r.left,f=r.right-t.right,p=i.right-i.left,m=i.bottom-i.top;if(l&&u<Math.min(p,f)?l=!1:!l&&f<Math.min(p,u)&&(l=!0),p<=(l?u:f))c=Math.max(r.top,Math.min(n.top,r.bottom-m))-t.top,d=Math.min(400,l?u:f);else{a=!0,d=Math.min(400,(o?t.right:r.right-t.left)-30);let e=r.bottom-t.bottom;e>=m||e>t.top?c=n.bottom-t.top:(h="bottom",c=t.bottom-n.top)}let g=(t.bottom-t.top)/s.offsetHeight,v=(t.right-t.left)/s.offsetWidth;return{style:"".concat(h,": ").concat(c/g,"px; max-width: ").concat(d/v,"px"),class:"cm-completionInfo-"+(a?o?"left-narrow":"right-narrow":l?"left":"right")}}function fX(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let i=Math.floor((e-t)/n);return{from:e-(i+1)*n,to:e-i*n}}class f${mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),i=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=i){let{options:r,selected:s,disabled:o}=n.open;i.open&&i.open.options==r||(this.range=fX(r.length,s,e.state.facet(fG).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),o!=(null==(t=i.open)?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(" "))e&&this.dom.classList.remove(e);for(let e of t.split(" "))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=fX(t.options.length,t.selected,this.view.state.facet(fG).maxRenderedOptions),this.showOptions(t.options,e.id)),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:n}=t.options[t.selected],{info:i}=n;if(!i)return;let r="string"==typeof i?document.createTextNode(i):i(n);if(!r)return;"then"in r?r.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,n)}).catch(e=>oD(this.view.state,e,"completion info")):this.addInfoPane(r,n)}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",null!=e.nodeType)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:i}=e;n.appendChild(t),this.infoDestroy=i||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){var t,n;let i,r,s,o=null;for(let t=this.list.firstChild,n=this.range.from;t;t=t.nextSibling,n++)"LI"==t.nodeName&&t.id?n==e?t.hasAttribute("aria-selected")||(t.setAttribute("aria-selected","true"),o=t):t.hasAttribute("aria-selected")&&t.removeAttribute("aria-selected"):n--;return o&&(t=this.list,n=o,i=t.getBoundingClientRect(),r=n.getBoundingClientRect(),s=i.height/t.offsetHeight,r.top<i.top?t.scrollTop-=(i.top-r.top)/s:r.bottom>i.bottom&&(t.scrollTop+=(r.bottom-i.bottom)/s)),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),r=this.space;if(!r){let e=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return i.top>Math.min(r.bottom,t.bottom)-10||i.bottom<Math.max(r.top,t.top)+10?null:this.view.state.facet(fG).positionInfo(this.view,t,i,n,r,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,n){let i=document.createElement("ul");i.id=t,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",e=>{e.target==i&&e.preventDefault()});let r=null;for(let s=n.from;s<n.to;s++){let{completion:o,match:l}=e[s],{section:a}=o;if(a){let e="string"==typeof a?a:a.name;e!=r&&(s>n.from||0==n.from)&&(r=e,"string"!=typeof a&&a.header?i.appendChild(a.header(a)):i.appendChild(document.createElement("completion-section")).textContent=e)}let h=i.appendChild(document.createElement("li"));h.id=t+"-"+s,h.setAttribute("role","option");let c=this.optionClass(o);for(let e of(c&&(h.className=c),this.optionContent)){let t=e(o,this.view.state,this.view,l);t&&h.appendChild(t)}}return n.from&&i.classList.add("cm-completionListIncompleteTop"),n.to<e.length&&i.classList.add("cm-completionListIncompleteBottom"),i}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass="";let i=e.state.field(t),{options:r,selected:s}=i.open,o=e.state.facet(fG);this.optionContent=function(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement("div");return t.classList.add("cm-completionIcon"),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>"cm-completionIcon-"+e)),t.setAttribute("aria-hidden","true"),t},position:20}),t.push({render(e,t,n,i){let r=document.createElement("span");r.className="cm-completionLabel";let s=e.displayLabel||e.label,o=0;for(let e=0;e<i.length;){let t=i[e++],n=i[e++];t>o&&r.appendChild(document.createTextNode(s.slice(o,t)));let l=r.appendChild(document.createElement("span"));l.appendChild(document.createTextNode(s.slice(t,n))),l.className="cm-completionMatchedText",o=n}return o<s.length&&r.appendChild(document.createTextNode(s.slice(o))),r},position:50},{render(e){if(!e.detail)return null;let t=document.createElement("span");return t.className="cm-completionDetail",t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fX(r.length,s,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",n=>{let{options:i}=e.state.field(t).open;for(let t=n.target,r;t&&t!=this.dom;t=t.parentNode)if("LI"==t.nodeName&&(r=/-(\d+)$/.exec(t.id))&&+r[1]<i.length){this.applyCompletion(e,i[+r[1]]),n.preventDefault();return}}),this.dom.addEventListener("focusout",t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(fG).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:fK.of(null)})}),this.showOptions(r,i.id)}}function fZ(e){return 100*(e.boost||0)+10*!!e.apply+5*!!e.info+ +!!e.type}class f0{setSelected(e,t){return e==this.selected||e>=this.options.length?this:new f0(this.options,f4(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,i,r,s){if(i&&!s&&e.some(e=>e.isPending))return i.setDisabled();let o=function(e,t){let n=[],i=null,r=e=>{n.push(e);let{section:t}=e.completion;if(t){i||(i=[]);let e="string"==typeof t?t:t.name;i.some(t=>t.name==e)||i.push("string"==typeof t?{name:e}:t)}},s=t.facet(fG);for(let i of e)if(i.hasResult()){let e=i.result.getMatch;if(!1===i.result.filter)for(let t of i.result.options)r(new fz(t,i.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(i.from,i.to),o,l=s.filterStrict?new fJ(n):new fU(n);for(let t of i.result.options)if(o=l.match(t.label)){let n=t.displayLabel?e?e(t,o.matched):[]:o.matched;r(new fz(t,i.source,n,o.score+(t.boost||0)))}}}if(i){let e=Object.create(null),t=0;for(let n of i.sort((e,t)=>{var n,i;return(null!=(n=e.rank)?n:1e9)-(null!=(i=t.rank)?i:1e9)||(e.name<t.name?-1:1)}))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e["string"==typeof n?n:n.name])}}let o=[],l=null,a=s.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||a(e.completion,t.completion))){let t=e.completion;l&&l.label==t.label&&l.detail==t.detail&&(null==l.type||null==t.type||l.type==t.type)&&l.apply==t.apply&&l.boost==t.boost?fZ(e.completion)>fZ(l)&&(o[o.length-1]=e):o.push(e),l=e.completion}return o}(e,t);if(!o.length)return i&&e.some(e=>e.isPending)?i.setDisabled():null;let l=t.facet(fG).selectOnOpen?0:-1;if(i&&i.selected!=l&&-1!=i.selected){let e=i.options[i.selected].completion;for(let t=0;t<o.length;t++)if(o[t].completion==e){l=t;break}}return new f0(o,f4(n,l),{pos:e.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:pi,above:r.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(e){return new f0(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new f0(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}constructor(e,t,n,i,r,s){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s}}class f1{static start(){return new f1(f5,"cm-ac-"+Math.floor(2e6*Math.random()).toString(36),null)}update(e){let{state:t}=e,n=t.facet(fG),i=(n.override||t.languageDataAt("autocomplete",fF(t)).map(fH)).map(t=>(this.active.find(e=>e.source==t)||new f6(t,+!!this.active.some(e=>0!=e.state))).update(e,n));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let r=this.open,s=e.effects.some(e=>e.is(f7));for(let o of(r&&e.docChanged&&(r=r.map(e.changes)),e.selection||i.some(t=>t.hasResult()&&e.changes.touchesRange(t.from,t.to))||!function(e,t){if(e==t)return!0;for(let n=0,i=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;i<t.length&&!t[i].hasResult();)i++;let r=n==e.length,s=i==t.length;if(r||s)return r==s;if(e[n++].result!=t[i++].result)return!1}}(i,this.active)||s?r=f0.build(i,t,this.id,r,n,s):r&&r.disabled&&!i.some(e=>e.isPending)&&(r=null),!r&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new f6(e.source,0):e)),e.effects))o.is(pe)&&(r=r&&r.setSelected(o.value,this.id));return i==this.active&&r==this.open?this:new f1(i,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?f2:f3}constructor(e,t,n){this.active=e,this.id=t,this.open=n}}let f2={"aria-autocomplete":"list"},f3={};function f4(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}let f5=[];function f8(e,t){if(e.isUserEvent("input.complete")){let n=e.annotation(fW);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent("input.type");return n&&t.activateOnTyping?5:n?1:e.isUserEvent("delete.backward")?2:e.selection?8:16*!!e.docChanged}class f6{hasResult(){return!1}get isPending(){return 1==this.state}update(e,t){let n=f8(e,t),i=this;for(let t of((8&n||16&n&&this.touches(e))&&(i=new f6(i.source,0)),4&n&&0==i.state&&(i=new f6(this.source,1)),i=i.updateFor(e,n),e.effects))if(t.is(fq))i=new f6(i.source,1,t.value);else if(t.is(fK))i=new f6(i.source,0);else if(t.is(f7))for(let e of t.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(fF(e.state))}constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}}class f9 extends f6{hasResult(){return!0}updateFor(e,t){var n;if(!(3&t))return this.map(e.changes);let i=this.result;i.map&&!e.changes.empty&&(i=i.map(i,e.changes));let r=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),o=fF(e.state);if(o>s||!i||2&t&&(fF(e.startState)==this.from||o<this.limit))return new f6(this.source,4&t?1:0);let l=e.changes.mapPos(this.limit);return!function(e,t,n,i){if(!e)return!1;let r=t.sliceDoc(n,i);return"function"==typeof e?e(r,n,i,t):f_(e,!0).test(r)}(i.validFor,e.state,r,s)?i.update&&(i=i.update(i,r,s,new fI(e.state,o,!1)))?new f9(this.source,this.explicit,l,i,i.from,null!=(n=i.to)?n:fF(e.state)):new f6(this.source,1,this.explicit):new f9(this.source,this.explicit,l,i,r,s)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new f9(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new f6(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}constructor(e,t,n,i,r,s){super(e,3,t),this.limit=n,this.result=i,this.from=r,this.to=s}}let f7=rM.define({map:(e,t)=>e.map(e=>e.map(t))}),pe=rM.define(),pt=rl.define({create:()=>f1.start(),update:(e,t)=>e.update(t),provide:e=>[a8.from(e,e=>e.tooltip),ao.contentAttributes.from(e,e=>e.attrs)]});function pn(e,t){let n=t.completion.apply||t.completion.label,i=e.state.field(pt).active.find(e=>e.source==t.source);return i instanceof f9&&("string"==typeof n?e.dispatch({...function(e,t,n,i){let{main:r}=e.selection,s=n-r.from,o=i-r.from;return{...e.changeByRange(l=>{if(l!=r&&n!=i&&e.sliceDoc(l.from+s,l.from+o)!=e.sliceDoc(n,i))return{range:l};let a=e.toText(t);return{changes:{from:l.from+s,to:i==r.from?l.to:l.from+o,insert:a},range:i9.cursor(l.from+s+a.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}(e.state,n,i.from,i.to),annotations:fW.of(t.completion)}):n(e,t.completion,i.from,i.to),!0)}let pi=e=>new f$(e,pt,pn);function pr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"option";return n=>{let i=n.state.field(pt,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<n.state.facet(fG).interactionDelay)return!1;let r=1,s;"page"==t&&(s=ht(n,i.open.tooltip))&&(r=Math.max(2,Math.floor(s.dom.offsetHeight/s.dom.querySelector("li").offsetHeight)-1));let{length:o}=i.open.options,l=i.open.selected>-1?i.open.selected+r*(e?1:-1):e?0:o-1;return l<0?l="page"==t?0:o-1:l>=o&&(l="page"==t?o-1:0),n.dispatch({effects:pe.of(l)}),!0}}let ps=e=>!!e.state.field(pt,!1)&&(e.dispatch({effects:fq.of(!0)}),!0);class po{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}let pl=oI.fromClass(class{update(e){let t=e.state.field(pt),n=e.state.facet(fG);if(!e.selectionSet&&!e.docChanged&&e.startState.field(pt)==t)return;let i=e.transactions.some(e=>{let t=f8(e,n);return 8&t||(e.selection||e.docChanged)&&!(3&t)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(i||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>50&&Date.now()-n.time>1e3){for(let e of n.context.abortListeners)try{e()}catch(e){oD(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(fq)))&&(this.pendingStart=!0);let r=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),r):-1,0!=this.composing)for(let t of e.transactions)t.isUserEvent("input.type")?this.composing=2:2==this.composing&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(pt);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fG).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=fF(t),i=new fI(t,n,e.explicit,this.view),r=new po(e,i);this.running.push(r),Promise.resolve(e.source(i)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:fK.of(null)}),oD(this.view.state,e)})}scheduleAccept(){this.running.every(e=>void 0!==e.done)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(fG).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(fG),i=this.view.state.field(pt);for(let r=0;r<this.running.length;r++){let s=this.running[r];if(void 0===s.done)continue;if(this.running.splice(r--,1),s.done){let i=fF(s.updates.length?s.updates[0].startState:this.view.state),r=Math.min(i,s.done.from+ +!s.active.explicit),o=new f9(s.active.source,s.active.explicit,r,s.done,s.done.from,null!=(e=s.done.to)?e:i);for(let e of s.updates)o=o.update(e,n);if(o.hasResult()){t.push(o);continue}}let o=i.active.find(e=>e.source==s.active.source);if(o&&o.isPending)if(null==s.done){let e=new f6(s.active.source,0);for(let t of s.updates)e=e.update(t,n);e.isPending||t.push(e)}else this.startQuery(o)}(t.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:f7.of(t)})}constructor(e){for(let t of(this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0,e.state.field(pt).active))t.isPending&&this.startQuery(t)}},{eventHandlers:{blur(e){let t=this.view.state.field(pt,!1);if(t&&t.tooltip&&this.view.state.facet(fG).closeOnBlur){let n=t.open&&ht(this.view,t.open.tooltip);n&&n.dom.contains(e.relatedTarget)||setTimeout(()=>this.view.dispatch({effects:fK.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){3==this.composing&&setTimeout(()=>this.view.dispatch({effects:fq.of(!1)}),20),this.composing=0}}}),pa="object"==typeof navigator&&/Win/.test(navigator.platform),ph=rc.highest(ao.domEventHandlers({keydown(e,t){let n=t.state.field(pt,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(pa&&e.altKey)||e.metaKey)return!1;let i=n.open.options[n.open.selected],r=n.active.find(e=>e.source==i.source),s=i.completion.commitCharacters||r.result.commitCharacters;return s&&s.indexOf(e.key)>-1&&pn(t,i),!1}})),pc=ao.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"".concat(400,"px"),boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"".concat(30,"px")},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"".concat(30,"px")},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),pd=s1.widget({widget:new class extends sZ{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),pu=s1.mark({class:"cm-snippetField"});class pf{map(e){let t=[];for(let n of this.ranges){let i=n.map(e);if(!i)return null;t.push(i)}return new pf(t,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}constructor(e,t){this.ranges=e,this.active=t,this.deco=s1.set(e.map(e=>(e.from==e.to?pd:pu).range(e.from,e.to)),!0)}}let pp=rM.define({map:(e,t)=>e&&e.map(t)}),pm=rM.define(),pg=rl.define({create:()=>null,update(e,t){for(let n of t.effects){if(n.is(pp))return n.value;if(n.is(pm)&&e)return new pf(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>ao.decorations.from(e,e=>e?e.deco:s1.none)});function pv(e){return t=>{var n;let{state:i,dispatch:r}=t,s=i.field(pg,!1);if(!s||e<0&&0==s.active)return!1;let o=s.active+e,l=e>0&&!s.ranges.some(t=>t.field==o+e);return r(i.update({selection:(n=s.ranges,i9.create(n.filter(e=>e.field==o).map(e=>i9.range(e.from,e.to)))),effects:pp.of(l?null:new pf(s.ranges,o)),scrollIntoView:!0})),!0}}let px=[{key:"Tab",run:pv(1),shift:pv(-1)},{key:"Escape",run:e=>{let{state:t,dispatch:n}=e;return!!t.field(pg,!1)&&(n(t.update({effects:pp.of(null)})),!0)}}],pb={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},py=rM.define({map(e,t){let n=t.mapPos(e,-1,i$.TrackAfter);return null==n?void 0:n}}),pw=new class extends rB{};pw.startSide=1,pw.endSide=-1;let pk=rl.define({create:()=>rW.empty,update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(py)&&(e=e.update({add:[pw.range(n.value,n.value+1)]}));return e}}),pS="()[]{}<>«»»«[]{}";function pC(e){for(let t=0;t<pS.length;t+=2)if(pS.charCodeAt(t)==e)return pS.charAt(t+1);return iY(e<128?e:e+1)}function pA(e,t){return e.languageDataAt("closeBrackets",t)[0]||pb}let pN="object"==typeof navigator&&/Android\b/.test(navigator.userAgent),pM=ao.inputHandler.of((e,t,n,i)=>{if((pN?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let r=e.state.selection.main;if(i.length>2||2==i.length&&1==iQ(iG(i,0))||t!=r.from||n!=r.to)return!1;let s=function(e,t){let n=pA(e,e.selection.main.head),i=n.brackets||pb.brackets;for(let r of i){let s=pC(iG(r,0));if(t==r)return s==r?function(e,t,n,i){let r=i.stringPrefixes||pb.stringPrefixes,s=null,o=e.changeByRange(i=>{if(!i.empty)return{changes:[{insert:t,from:i.from},{insert:t,from:i.to}],effects:py.of(i.to+t.length),range:i9.range(i.anchor+t.length,i.head+t.length)};let o=i.head,l=pE(e.doc,o),a;if(l==t){if(pT(e,o))return{changes:{insert:t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};else if(pj(e,o)){let i=n&&e.sliceDoc(o,o+3*t.length)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+i.length,insert:i},range:i9.cursor(o+i.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(a=pD(e,o-2*t.length,r))>-1&&pT(e,a))return{changes:{insert:t+t+t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};else if(e.charCategorizer(o)(l)!=rR.Word&&pD(e,o,r)>-1&&!function(e,t,n,i){let r=cM(e).resolveInner(t,-1),s=i.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(r.from,Math.min(r.to,r.from+n.length+s)),l=o.indexOf(n);if(!l||l>-1&&i.indexOf(o.slice(0,l))>-1){let t=r.firstChild;for(;t&&t.from==r.from&&t.to-t.from>n.length+l;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let a=r.to==t&&r.parent;if(!a)break;r=a}return!1}(e,o,t,r))return{changes:{insert:t+t,from:o},effects:py.of(o+t.length),range:i9.cursor(o+t.length)};return{range:s=i}});return s?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,i.indexOf(r+r+r)>-1,n):function(e,t,n,i){let r=null,s=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:py.of(s.to+t.length),range:i9.range(s.anchor+t.length,s.head+t.length)};let o=pE(e.doc,s.head);return!o||/\s/.test(o)||i.indexOf(o)>-1?{changes:{insert:t+n,from:s.head},effects:py.of(s.head+t.length),range:i9.cursor(s.head+t.length)}:{range:r=s}});return r?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}(e,r,s,n.before||pb.before);if(t==s&&pj(e,e.selection.main.from))return function(e,t,n){let i=null,r=e.changeByRange(t=>t.empty&&pE(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:i9.cursor(t.head+n.length)}:i={range:t});return i?null:e.update(r,{scrollIntoView:!0,userEvent:"input.type"})}(e,0,s)}return null}(e.state,i);return!!s&&(e.dispatch(s),!0)}),pO=[{key:"Backspace",run:e=>{let{state:t,dispatch:n}=e;if(t.readOnly)return!1;let i=pA(t,t.selection.main.head).brackets||pb.brackets,r=null,s=t.changeByRange(e=>{if(e.empty){let n=function(e,t){let n=e.sliceString(t-2,t);return iQ(iG(n,0))==n.length?n:n.slice(1)}(t.doc,e.head);for(let r of i)if(r==n&&pE(t.doc,e.head)==pC(iG(r,0)))return{changes:{from:e.head-r.length,to:e.head+r.length},range:i9.cursor(e.head-r.length)}}return{range:r=e}});return r||n(t.update(s,{scrollIntoView:!0,userEvent:"delete.backward"})),!r}}];function pj(e,t){let n=!1;return e.field(pk).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function pE(e,t){let n=e.sliceString(t,t+2);return n.slice(0,iQ(iG(n,0)))}function pT(e,t){let n=cM(e).resolveInner(t+1);return n.parent&&n.from==t}function pD(e,t,n){let i=e.charCategorizer(t);if(i(e.sliceDoc(t-1,t))!=rR.Word)return t;for(let r of n){let n=t-r.length;if(e.sliceDoc(n,t)==r&&i(e.sliceDoc(n-1,n))!=rR.Word)return n}return -1}let pR=[{key:"Ctrl-Space",run:ps},{mac:"Alt-`",run:ps},{mac:"Alt-i",run:ps},{key:"Escape",run:e=>{let t=e.state.field(pt,!1);return!!t&&!!t.active.some(e=>0!=e.state)&&(e.dispatch({effects:fK.of(null)}),!0)}},{key:"ArrowDown",run:pr(!0)},{key:"ArrowUp",run:pr(!1)},{key:"PageDown",run:pr(!0,"page")},{key:"PageUp",run:pr(!1,"page")},{key:"Enter",run:e=>{let t=e.state.field(pt,!1);return!(e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(fG).interactionDelay)&&pn(e,t.open.options[t.open.selected])}}],pP=rc.highest(ap.computeN([fG],e=>e.facet(fG).defaultKeymap?[pR]:[]));class pL{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class pI{static init(e,t,n){let i=n.facet(pJ).markerFilter;i&&(e=i(e,n));let r=e.slice().sort((e,t)=>e.from-t.from||e.to-t.to),s=new rV,o=[],l=0;for(let e=0;;){let t,i,a=e==r.length?null:r[e];if(!a&&!o.length)break;for(o.length?(t=l,i=o.reduce((e,t)=>Math.min(e,t.to),a&&a.from>t?a.from:1e8)):(t=a.from,i=a.to,o.push(a),e++);e<r.length;){let n=r[e];if(n.from==t&&(n.to>n.from||n.to==t))o.push(n),e++,i=Math.min(n.to,i);else{i=Math.min(n.from,i);break}}let h=p1(o);if(o.some(e=>e.from==e.to||e.from==e.to-1&&n.doc.lineAt(e.from).to==e.from))s.add(t,t,s1.widget({widget:new pQ(h),diagnostics:o.slice()}));else{let e=o.reduce((e,t)=>t.markClass?e+" "+t.markClass:e,"");s.add(t,i,s1.mark({class:"cm-lintRange cm-lintRange-"+h+e,diagnostics:o.slice(),inclusiveEnd:o.some(e=>e.to>i)}))}l=i;for(let e=0;e<o.length;e++)o[e].to<=l&&o.splice(e--,1)}let a=s.finish();return new pI(a,t,pB(a))}constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}}function pB(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=null;return e.between(n,1e9,(e,n,r)=>{let{spec:s}=r;if(!(t&&0>s.diagnostics.indexOf(t)))if(i){if(0>s.diagnostics.indexOf(i.diagnostic))return!1;i=new pL(i.from,n,i.diagnostic)}else i=new pL(e,n,t||s.diagnostics[0])}),i}function pz(e,t){let n=t.pos,i=t.end||n,r=e.state.facet(pJ).hideOn(e,n,i);if(null!=r)return r;let s=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(pF))||e.changes.touchesRange(s.from,Math.max(s.to,i)))}let pF=rM.define(),p_=rM.define(),pW=rM.define(),pV=rl.define({create:()=>new pI(s1.none,null,null),update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),i=null,r=e.panel;if(e.selected){let r=t.changes.mapPos(e.selected.from,1);i=pB(n,e.selected.diagnostic,r)||pB(n,null,r)}!n.size&&r&&t.state.facet(pJ).autoPanel&&(r=null),e=new pI(n,r,i)}for(let n of t.effects)if(n.is(pF)){let i=t.state.facet(pJ).autoPanel?n.value.length?p$.open:null:e.panel;e=pI.init(n.value,i,t.state)}else n.is(p_)?e=new pI(e.diagnostics,n.value?p$.open:null,e.selected):n.is(pW)&&(e=new pI(e.diagnostics,e.panel,n.value));return e},provide:e=>[ha.from(e,e=>e.panel),ao.decorations.from(e,e=>e.diagnostics)]}),pH=s1.mark({class:"cm-lintRange cm-lintRange-active"});function pq(e,t){return si("ul",{class:"cm-tooltip-lint"},t.map(t=>pY(e,t,!1)))}let pK=e=>{let t=e.state.field(pV,!1);return!!t&&!!t.panel&&(e.dispatch({effects:p_.of(!1)}),!0)},pU=[{key:"Mod-Shift-m",run:e=>{let t=e.state.field(pV,!1);t&&t.panel||e.dispatch({effects:function(e,t){return e.field(pV,!1)?t:t.concat(rM.appendConfig.of(p4))}(e.state,[p_.of(!0)])});let n=hr(e,p$.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},preventDefault:!0},{key:"F8",run:e=>{let t=e.state.field(pV,!1);if(!t)return!1;let n=e.state.selection.main,i=t.diagnostics.iter(n.to+1);return(!!i.value||!!(i=t.diagnostics.iter(0)).value&&(i.from!=n.from||i.to!=n.to))&&(e.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)}}],pJ=rt.define({combine:e=>Object.assign({sources:e.map(e=>e.source).filter(e=>null!=e)},rI(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t}))});function pG(e){let t=[];if(e)i:for(let{name:n}of e){for(let e=0;e<n.length;e++){let i=n[e];if(/[a-zA-Z]/.test(i)&&!t.some(e=>e.toLowerCase()==i.toLowerCase())){t.push(i);continue i}}t.push("")}return t}function pY(e,t,n){var i;let r=n?pG(t.actions):[];return si("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},si("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),null==(i=t.actions)?void 0:i.map((n,i)=>{let s=!1,o=i=>{if(i.preventDefault(),s)return;s=!0;let r=pB(e.state.field(pV).diagnostics,t);r&&n.apply(e,r.from,r.to)},{name:l}=n,a=r[i]?l.indexOf(r[i]):-1,h=a<0?l:[l.slice(0,a),si("u",l.slice(a,a+1)),l.slice(a+1)];return si("button",{type:"button",class:"cm-diagnosticAction",onclick:o,onmousedown:o,"aria-label":" Action: ".concat(l).concat(a<0?"":' (access key "'.concat(r[i],')"'),".")},h)}),t.source&&si("div",{class:"cm-diagnosticSource"},t.source))}class pQ extends sZ{eq(e){return e.sev==this.sev}toDOM(){return si("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}constructor(e){super(),this.sev=e}}class pX{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(0xffffffff*Math.random()).toString(16),this.dom=pY(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class p${get selectedIndex(){let e=this.view.state.field(pV).selected;if(!e)return -1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return -1}update(){let{diagnostics:e,selected:t}=this.view.state.field(pV),n=0,i=!1,r=null,s=new Set;for(e.between(0,this.view.state.doc.length,(e,o,l)=>{let{spec:a}=l;for(let e of a.diagnostics){if(s.has(e))continue;s.add(e);let o=-1,l;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(l=new pX(this.view,e),this.items.splice(n,0,l),i=!0):(l=this.items[o],o>n&&(this.items.splice(n,o-n),i=!0)),t&&l.diagnostic==t.diagnostic?l.dom.hasAttribute("aria-selected")||(l.dom.setAttribute("aria-selected","true"),r=l):l.dom.hasAttribute("aria-selected")&&l.dom.removeAttribute("aria-selected"),n++}});n<this.items.length&&!(1==this.items.length&&this.items[0].diagnostic.from<0);)i=!0,this.items.pop();0==this.items.length&&(this.items.push(new pX(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=!0),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:e=>{let{sel:t,panel:n}=e,i=n.height/this.list.offsetHeight;t.top<n.top?this.list.scrollTop-=(n.top-t.top)/i:t.bottom>n.bottom&&(this.list.scrollTop+=(t.bottom-n.bottom)/i)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&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=pB(this.view.state.field(pV).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:pW.of(t)})}static open(e){return new p$(e)}constructor(e){this.view=e,this.items=[];let t=t=>{if(27==t.keyCode)pK(this.view),this.view.focus();else if(38==t.keyCode||33==t.keyCode)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(40==t.keyCode||34==t.keyCode)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(36==t.keyCode)this.moveSelection(0);else if(35==t.keyCode)this.moveSelection(this.items.length-1);else if(13==t.keyCode)this.view.focus();else{if(!(t.keyCode>=65)||!(t.keyCode<=90)||!(this.selectedIndex>=0))return;let{diagnostic:n}=this.items[this.selectedIndex],i=pG(n.actions);for(let r=0;r<i.length;r++)if(i[r].toUpperCase().charCodeAt(0)==t.keyCode){let t=pB(this.view.state.field(pV).diagnostics,n);t&&n.actions[r].apply(e,t.from,t.to)}}t.preventDefault()},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=si("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:n}),this.dom=si("div",{class:"cm-panel-lint"},this.list,si("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>pK(this.view)},"×")),this.update()}}function pZ(e){return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:'viewBox="0 0 40 40"';return'url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" '.concat(t,">").concat(encodeURIComponent(e),"</svg>')")}('<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="'.concat(e,'" fill="none" stroke-width=".7"/>'),'width="6" height="3"')}let p0=ao.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:pZ("#d11")},".cm-lintRange-warning":{backgroundImage:pZ("orange")},".cm-lintRange-info":{backgroundImage:pZ("#999")},".cm-lintRange-hint":{backgroundImage:pZ("#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}}});function p1(e){let t="hint",n=1;for(let r of e){var i;let e="error"==(i=r.severity)?4:"warning"==i?3:"info"==i?2:1;e>n&&(n=e,t=r.severity)}return t}let p2=rM.define(),p3=rl.define({create:()=>null,update:(e,t)=>(e&&t.docChanged&&(e=pz(t,e)?null:Object.assign(Object.assign({},e),{pos:t.changes.mapPos(e.pos)})),t.effects.reduce((e,t)=>t.is(p2)?t.value:e,e)),provide:e=>a8.from(e)}),p4=[pV,ao.decorations.compute([pV],e=>{let{selected:t,panel:n}=e.field(pV);return t&&n&&t.from!=t.to?s1.set([pH.range(t.from,t.to)]):s1.none}),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=rM.define(),i=rl.define({create:()=>[],update(e,i){if(e.length&&(t.hideOnChange&&(i.docChanged||i.selection)?e=[]:t.hideOn&&(e=e.filter(e=>!t.hideOn(i,e))),i.docChanged)){let t=[];for(let n of e){let e=i.changes.mapPos(n.pos,-1,i$.TrackDel);if(null!=e){let r=Object.assign(Object.create(null),n);r.pos=e,null!=r.end&&(r.end=i.changes.mapPos(r.end)),t.push(r)}}e=t}for(let t of i.effects)t.is(n)&&(e=t.value),t.is(hn)&&(e=[]);return e},provide:e=>a6.from(e)});return{active:i,extension:[i,oI.define(r=>new he(r,e,i,n,t.hoverTime||300)),a7]}}(function(e,t,n){let{diagnostics:i}=e.state.field(pV),r,s=-1,o=-1;i.between(t-(n<0),t+ +(n>0),(e,i,l)=>{let{spec:a}=l;if(t>=e&&t<=i&&(e==i||(t>e||n>0)&&(t<i||n<0)))return r=a.diagnostics,s=e,o=i,!1});let l=e.state.facet(pJ).tooltipFilter;return(r&&l&&(r=l(r,e.state)),r)?{pos:s,end:o,above:e.state.doc.lineAt(s).to<o,create:()=>({dom:pq(e,r)})}:null},{hideOn:pz}),p0],p5=rt.define({combine:e=>rI(e,{hoverTime:300,markerFilter:null,tooltipFilter:null})});var p8=function(e){let t;void 0===e&&(e={});var{crosshairCursor:n=!1}=e,i=[];!1!==e.closeBracketsKeymap&&(i=i.concat(pO)),!1!==e.defaultKeymap&&(i=i.concat(uH)),!1!==e.searchKeymap&&(i=i.concat(fj)),!1!==e.historyKeymap&&(i=i.concat(d2)),!1!==e.foldKeymap&&(i=i.concat(c6)),!1!==e.completionKeymap&&(i=i.concat(pR)),!1!==e.lintKeymap&&(i=i.concat(pU));var r=[];return!1!==e.lineNumbers&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[hC.of(e),hm(),hM]}()),!1!==e.highlightActiveLineGutter&&r.push(hE),!1!==e.highlightSpecialChars&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[aW.of(e),aV||(aV=oI.fromClass(class{makeDecorator(e){return new aI({regexp:e.specialChars,decoration:(t,n,i)=>{let{doc:r}=n.state,s=iG(t[0],0);if(9==s){let e=r.lineAt(i),t=n.state.tabSize,s=rZ(e.text,t,i-e.from);return s1.replace({widget:new aq((t-s%t)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[s]||(this.decorationCache[s]=s1.replace({widget:new aH(e,s)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(aW);e.startState.facet(aW)!=t?(this.decorator=this.makeDecorator(t),this.decorations=this.decorator.createDeco(e.view)):this.decorations=this.decorator.updateDeco(e,this.decorations)}constructor(e){this.view=e,this.decorations=s1.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(aW)),this.decorations=this.decorator.createDeco(e)}},{decorations:e=>e.decorations}))]}()),!1!==e.history&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[dV,dW.of(e),ao.domEventHandlers({beforeinput(e,t){let n="historyUndo"==e.inputType?dq:"historyRedo"==e.inputType?dK:null;return!!n&&(e.preventDefault(),n(t))}})]}()),!1!==e.foldGutter&&r.push(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n={...dr,...t},i=new ds(n,!0),r=new ds(n,!1),s=oI.fromClass(class{update(e){(e.docChanged||e.viewportChanged||e.startState.facet(cI)!=e.state.facet(cI)||e.startState.field(c2,!1)!=e.state.field(c2,!1)||cM(e.startState)!=cM(e.state)||n.foldingChanged(e))&&(this.markers=this.buildMarkers(e.view))}buildMarkers(e){let t=new rV;for(let n of e.viewportLineBlocks){let s=c4(e.state,n.from,n.to)?r:cX(e.state,n.from,n.to)?i:null;s&&t.add(n.from,n.from,s)}return t.finish()}constructor(e){this.from=e.viewport.from,this.markers=this.buildMarkers(e)}}),{domEventHandlers:o}=n;return[s,(e={class:"cm-foldGutter",markers(e){var t;return(null==(t=e.plugin(s))?void 0:t.markers)||rW.empty},initialSpacer:()=>new ds(n,!1),domEventHandlers:{...o,click:(e,t,n)=>{if(o.click&&o.click(e,t,n))return!0;let i=c4(e.state,t.from,t.to);if(i)return e.dispatch({effects:c0.of(i)}),!0;let r=cX(e.state,t.from,t.to);return!!r&&(e.dispatch({effects:cZ.of(r)}),!0)}}},[hm(),hf.of({...hu,...e})]),de()]}()),!1!==e.drawSelection&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[aN.of(e),aO,aE,aT,oM.of(!0)]}()),!1!==e.dropCursor&&r.push([aR,aP]),!1!==e.allowMultipleSelections&&r.push(rL.allowMultipleSelections.of(!0)),!1!==e.indentOnInput&&r.push(rL.transactionFilter.of(e=>{if(!e.docChanged||!e.isUserEvent("input.type")&&!e.isUserEvent("input.complete"))return e;let t=e.startState.languageDataAt("indentOnInput",e.startState.selection.main.head);if(!t.length)return e;let n=e.newDoc,{head:i}=e.newSelection.main,r=n.lineAt(i);if(i>r.from+200)return e;let s=n.sliceString(r.from,i);if(!t.some(e=>e.test(s)))return e;let{state:o}=e,l=-1,a=[];for(let{head:e}of o.selection.ranges){let t=o.doc.lineAt(e);if(t.from==l)continue;l=t.from;let n=cV(o,t.from);if(null==n)continue;let i=/^\s*/.exec(t.text)[0],r=cW(o,n);i!=r&&a.push({from:t.from,to:t.from+i.length,insert:r})}return a.length?[e,{changes:a,sequential:!0}]:e})),!1!==e.syntaxHighlighting&&r.push(du(dp,{fallback:!0})),!1!==e.bracketMatching&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[dv.of(e),dw]}()),!1!==e.closeBrackets&&r.push([pM,pk]),!1!==e.autocompletion&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return[ph,pt,fG.of(e),pl,pP,pc]}()),!1!==e.rectangularSelection&&r.push((t=e=>e.altKey&&0==e.button,ao.mouseSelectionStyle.of((e,n)=>{let i,r;return t(n)?(i=aG(e,n),r=e.state.selection,{update(e){if(e.docChanged){let t=e.changes.mapPos(e.startState.doc.line(i.line).from),n=e.state.doc.lineAt(t);i={line:n.number,col:i.col,off:Math.min(i.off,n.length)},r=r.map(e.changes)}},get(t,n,s){let o=aG(e,t),l=function(e,t,n){let i=Math.min(t.line,n.line),r=Math.max(t.line,n.line),s=[];if(t.off>2e3||n.off>2e3||t.col<0||n.col<0){let o=Math.min(t.off,n.off),l=Math.max(t.off,n.off);for(let t=i;t<=r;t++){let n=e.doc.line(t);n.length<=l&&s.push(i9.range(n.from+o,n.to+l))}}else{let o=Math.min(t.col,n.col),l=Math.max(t.col,n.col);for(let t=i;t<=r;t++){let n=e.doc.line(t),i=r0(n.text,o,e.tabSize,!0);if(i<0)s.push(i9.cursor(n.to));else{let t=r0(n.text,l,e.tabSize);s.push(i9.range(n.from+i,n.from+t))}}}return s}(e.state,i,o);return l.length?s?i9.create(l.concat(r.ranges)):i9.create(l):r}}):null}))),!1!==n&&r.push(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[t,n]=aY[e.key||"Alt"],i=oI.fromClass(class{set(e){this.isDown!=e&&(this.isDown=e,this.view.update([]))}constructor(e){this.view=e,this.isDown=!1}},{eventObservers:{keydown(e){this.set(e.keyCode==t||n(e))},keyup(e){e.keyCode!=t&&n(e)||this.set(!1)},mousemove(e){this.set(n(e))}}});return[i,ao.contentAttributes.of(e=>{var t;return(null==(t=e.plugin(i))?void 0:t.isDown)?aQ:null})]}()),!1!==e.highlightActiveLine&&r.push(aU),!1!==e.highlightSelectionMatches&&r.push([fe,u7]),e.tabSize&&"number"==typeof e.tabSize&&r.push(cF.of(" ".repeat(e.tabSize))),r.concat([ap.of(i.flat())]).filter(Boolean)};let p6="#e06c75",p9="#abb2bf",p7="#7d8799",me="#d19a66",mt="#2c313a",mn="#282c34",mi="#353a42",mr="#528bff",ms=[ao.theme({"&":{color:p9,backgroundColor:mn},".cm-content":{caretColor:mr},".cm-cursor, .cm-dropCursor":{borderLeftColor:mr},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:"#3E4451"},".cm-panels":{backgroundColor:"#21252b",color:p9},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:mn,color:p7,border:"none"},".cm-activeLineGutter":{backgroundColor:mt},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:mi},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:mi,borderBottomColor:mi},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:mt,color:p9}}},{dark:!0}),du(da.define([{tag:cw.keyword,color:"#c678dd"},{tag:[cw.name,cw.deleted,cw.character,cw.propertyName,cw.macroName],color:p6},{tag:[cw.function(cw.variableName),cw.labelName],color:"#61afef"},{tag:[cw.color,cw.constant(cw.name),cw.standard(cw.name)],color:me},{tag:[cw.definition(cw.name),cw.separator],color:p9},{tag:[cw.typeName,cw.className,cw.number,cw.changed,cw.annotation,cw.modifier,cw.self,cw.namespace],color:"#e5c07b"},{tag:[cw.operator,cw.operatorKeyword,cw.url,cw.escape,cw.regexp,cw.link,cw.special(cw.string)],color:"#56b6c2"},{tag:[cw.meta,cw.comment],color:p7},{tag:cw.strong,fontWeight:"bold"},{tag:cw.emphasis,fontStyle:"italic"},{tag:cw.strikethrough,textDecoration:"line-through"},{tag:cw.link,color:p7,textDecoration:"underline"},{tag:cw.heading,fontWeight:"bold",color:p6},{tag:[cw.atom,cw.bool,cw.special(cw.variableName)],color:me},{tag:[cw.processingInstruction,cw.string,cw.inserted],color:"#98c379"},{tag:cw.invalid,color:"#ffffff"}]))];var mo=ao.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ml=function(e){let t;void 0===e&&(e={});var{indentWithTab:n=!0,editable:i=!0,readOnly:r=!1,theme:s="light",placeholder:o="",basicSetup:l=!0}=e,a=[];switch(n&&a.unshift(ap.of([uq])),l&&("boolean"==typeof l?a.unshift(p8()):a.unshift(p8(l))),o&&a.unshift((t=oI.fromClass(class{get decorations(){return this.view.state.doc.length?s1.none:this.placeholder}constructor(e){this.view=e,this.placeholder=o?s1.set([s1.widget({widget:new aJ(o),side:1}).range(0)]):s1.none}},{decorations:e=>e.decorations}),"string"==typeof o?[t,ao.contentAttributes.of({"aria-placeholder":o})]:t)),s){case"light":a.push(mo);break;case"dark":a.push(ms);break;case"none":break;default:a.push(s)}return!1===i&&a.push(ao.editable.of(!1)),r&&a.push(rL.readOnly.of(!0)),[...a]};class ma{tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error("TimeoutLatch callback error:",e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}}class mh{add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),0===this.latches.size&&this.stop()}start(){null===this.interval&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){null!==this.interval&&(clearInterval(this.interval),this.interval=null)}constructor(){this.interval=null,this.latches=new Set}}var mc=null,md=rC.define(),mu=[],mf=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],mp=(0,d.forwardRef)((e,t)=>{var{className:n,value:i="",selection:r,extensions:s=[],onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,autoFocus:u,theme:f="light",height:p,minHeight:m,maxHeight:g,width:v,minWidth:x,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:S,readOnly:C,root:A,initialState:N}=e,M=function(e,t){if(null==e)return{};var n={};for(var i in e)if(({}).hasOwnProperty.call(e,i)){if(-1!==t.indexOf(i))continue;n[i]=e[i]}return n}(e,mf),O=(0,d.useRef)(null),{state:j,view:E,container:T,setContainer:D}=function(e){var{value:t,selection:n,onChange:i,onStatistics:r,onCreateEditor:s,onUpdate:o,extensions:l=mu,autoFocus:a,theme:h="light",height:c=null,minHeight:u=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:g=null,placeholder:v="",editable:x=!0,readOnly:b=!1,indentWithTab:y=!0,basicSetup:w=!0,root:k,initialState:S}=e,[C,A]=(0,d.useState)(),[N,M]=(0,d.useState)(),[O,j]=(0,d.useState)(),E=(0,d.useState)(()=>({current:null}))[0],T=(0,d.useState)(()=>({current:null}))[0],D=ao.theme({"&":{height:c,minHeight:u,maxHeight:f,width:p,minWidth:m,maxWidth:g},"& .cm-scroller":{height:"100% !important"}}),R=[ao.updateListener.of(e=>{e.docChanged&&"function"==typeof i&&!e.transactions.some(e=>e.annotation(md))&&(E.current?E.current.reset():(E.current=new ma(()=>{if(T.current){var e=T.current;T.current=null,e()}E.current=null},200),("undefined"==typeof window?new mh:(!mc&&(mc=new mh),mc)).add(E.current)),i(e.state.doc.toString(),e)),r&&r({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)})}),D,...ml({theme:h,editable:x,readOnly:b,placeholder:v,indentWithTab:y,basicSetup:w})];return o&&"function"==typeof o&&R.push(ao.updateListener.of(o)),R=R.concat(l),(0,d.useLayoutEffect)(()=>{if(C&&!O){var e={doc:t,selection:n,extensions:R},i=S?rL.fromJSON(S.json,e,S.fields):rL.create(e);if(j(i),!N){var r=new ao({state:i,parent:C,root:k});M(r),s&&s(r,i)}}return()=>{N&&(j(void 0),M(void 0))}},[C,O]),(0,d.useEffect)(()=>{e.container&&A(e.container)},[e.container]),(0,d.useEffect)(()=>()=>{N&&(N.destroy(),M(void 0)),E.current&&(E.current.cancel(),E.current=null)},[N]),(0,d.useEffect)(()=>{a&&N&&N.focus()},[a,N]),(0,d.useEffect)(()=>{N&&N.dispatch({effects:rM.reconfigure.of(R)})},[h,l,c,u,f,p,m,g,v,x,b,y,w,i,o]),(0,d.useEffect)(()=>{if(void 0!==t){var e=N?N.state.doc.toString():"";if(N&&t!==e){var n=E.current&&!E.current.isDone,i=()=>{N&&t!==N.state.doc.toString()&&N.dispatch({changes:{from:0,to:N.state.doc.toString().length,insert:t||""},annotations:[md.of(!0)]})};n?T.current=i:i()}}},[t,N]),{state:O,setState:j,view:N,setView:M,container:C,setContainer:A}}({root:A,value:i,autoFocus:u,theme:f,height:p,minHeight:m,maxHeight:g,width:v,minWidth:x,maxWidth:b,basicSetup:y,placeholder:w,indentWithTab:k,editable:S,readOnly:C,selection:r,onChange:o,onStatistics:l,onCreateEditor:a,onUpdate:h,extensions:s,initialState:N});(0,d.useImperativeHandle)(t,()=>({editor:O.current,state:j,view:E}),[O,T,j,E]);var R=(0,d.useCallback)(e=>{O.current=e,D(e)},[D]);if("string"!=typeof i)throw Error("value must be typeof string but got "+typeof i);var P="string"==typeof f?"cm-theme-"+f:"cm-theme";return(0,c.jsx)("div",ij({ref:R,className:""+P+(n?" "+n:"")},M))});mp.displayName="CodeMirror";var mm=e.i(47167);class mg{toString(){return"[".concat(this.stack.filter((e,t)=>t%3==0).concat(this.state),"]@").concat(this.pos).concat(this.score?"!"+this.score:"")}static start(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=e.parser.context;return new mg(e,[],t,n,n,0,[],0,i?new mv(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){var t;let n=e>>19,i=65535&e,{parser:r}=this.p,s=this.reducePos<this.pos-25;s&&this.setLookAhead(this.pos);let o=r.dynamicPrecedence(i);if(o&&(this.score+=o),0==n){this.pushState(r.getGoto(this.state,i,!0),this.reducePos),i<r.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(n-1)*3-(262144&e?6:0),a=l?this.stack[l-2]:this.p.ranges[0].from,h=this.reducePos-a;h>=2e3&&!(null==(t=this.p.parser.nodeSet.types[i])?void 0:t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSize<h&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=a,this.p.lastBigReductionSize=h));let c=l?this.stack[l-1]:0,d=this.bufferBase+this.buffer.length-c;if(i<r.minRepeatTerm||131072&e){let e=r.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,a,e,d+4,!0)}if(262144&e)this.state=this.stack[l];else{let e=this.stack[l-3];this.state=r.getGoto(e,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,a)}storeNode(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:4,r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if(0==e&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let e=this,i=this.buffer.length;if(0==i&&e.parent&&(i=e.bufferBase-e.parent.bufferBase,e=e.parent),i>0&&0==e.buffer[i-4]&&e.buffer[i-1]>-1){if(t==n)return;if(e.buffer[i-2]>=t){e.buffer[i-2]=n;return}}}if(r&&this.pos!=n){let r=this.buffer.length;if(r>0&&0!=this.buffer[r-4]){let e=!1;for(let t=r;t>0&&this.buffer[t-2]>n;t-=4)if(this.buffer[t-1]>=0){e=!0;break}if(e)for(;r>0&&this.buffer[r-2]>n;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,i>4&&(i-=4)}this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=n,this.buffer[r+3]=i}else this.buffer.push(e,t,n,i)}shift(e,t,n,i){if(131072&e)this.pushState(65535&e,this.pos);else if((262144&e)==0){let{parser:r}=this.p;(i>this.pos||t<=r.maxNode)&&(this.pos=i,r.stateFlag(e,1)||(this.reducePos=i)),this.pushState(e,n),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,i,4)}else this.pos=i,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,i,4)}apply(e,t,n,i){65536&e?this.reduce(e):this.shift(e,t,n,i)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(t,i),this.buffer.push(n,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),i=e.bufferBase+t;for(;e&&i==e.bufferBase;)e=e.parent;return new mg(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,i,this.curContext,this.lookAhead,e)}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 mx(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(0==n)return!1;if((65536&n)==0)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 i=0,r;i<t.length;i+=2)(r=t[i+1])!=this.state&&this.p.parser.hasAction(r,e)&&n.push(t[i],r);if(this.stack.length<120)for(let e=0;n.length<8&&e<t.length;e+=2){let i=t[e+1];n.some((e,t)=>1&t&&e==i)||n.push(t[e],i)}t=n}let n=[];for(let e=0;e<t.length&&n.length<4;e+=2){let i=t[e+1];if(i==this.state)continue;let r=this.split();r.pushState(i,this.pos),r.storeNode(0,r.pos,r.pos,4,!0),r.shiftContext(t[e],this.pos),r.reducePos=this.pos,r.score-=200,n.push(r)}return n}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((65536&t)==0)return!1;if(!e.validAction(this.state,t)){let n=t>>19,i=65535&t,r=this.stack.length-3*n;if(r<0||0>e.getGoto(this.stack[r],i,!1)){let e=this.findForcedReduction();if(null==e)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=(i,r)=>{if(!t.includes(i))return t.push(i),e.allActions(i,t=>{if(393216&t);else if(65536&t){let n=(t>>19)-r;if(n>1){let i=65535&t,r=this.stack.length-3*n;if(r>=0&&e.getGoto(this.stack[r],i,!1)>=0)return n<<19|65536|i}}else{let e=n(t,r+1);if(null!=e)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(3!=this.stack.length)return!1;let{parser:e}=this.p;return 65535==e.data[e.stateSlot(this.state,1)]&&!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;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||-3!=this.buffer[e])&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||-4!=this.buffer[e])&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new mv(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}constructor(e,t,n,i,r,s,o,l,a,h=0,c){this.p=e,this.stack=t,this.state=n,this.reducePos=i,this.pos=r,this.score=s,this.buffer=o,this.bufferBase=l,this.curContext=a,this.lookAhead=h,this.parent=c}}class mv{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class mx{reduce(e){let t=e>>19;0==t?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(t-1)*3;let n=this.start.p.parser.getGoto(this.stack[this.base-3],65535&e,!0);this.state=n}constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}}class mb{static create(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.bufferBase+e.buffer.length;return new mb(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;null!=e&&(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,0==this.index&&this.maybeNext()}fork(){return new mb(this.stack,this.pos,this.index)}constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,0==this.index&&this.maybeNext()}}function my(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Uint16Array;if("string"!=typeof e)return e;let n=null;for(let i=0,r=0;i<e.length;){let s=0;for(;;){let t=e.charCodeAt(i++),n=!1;if(126==t){s=65535;break}t>=92&&t--,t>=34&&t--;let r=t-32;if(r>=46&&(r-=46,n=!0),s+=r,n)break;s*=46}n?n[r++]=s:n=new t(s)}return n}class mw{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}let mk=new mw;class mS{resolveOffset(e,t){let n=this.range,i=this.rangeIndex,r=this.pos+e;for(;r<n.from;){if(!i)return null;let e=this.ranges[--i];r-=n.from-e.to,n=e}for(;t<0?r>n.to:r>=n.to;){if(i==this.ranges.length-1)return null;let e=this.ranges[++i];r+=e.from-n.to,n=e}return r}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,i;if(t>=0&&t<this.chunk.length)n=this.pos+e,i=this.chunk.charCodeAt(t);else{let t=this.resolveOffset(e,1);if(null==t)return -1;if((n=t)>=this.chunk2Pos&&n<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(n-this.chunk2Pos);else{let e=this.rangeIndex,t=this.range;for(;t.to<=n;)t=this.ranges[++e];this.chunk2=this.input.chunk(this.chunk2Pos=n),n+this.chunk2.length>t.to&&(this.chunk2=this.chunk2.slice(0,t.to-n)),i=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),i}acceptToken(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=t?this.resolveOffset(t,-1):this.pos;if(null==n||n<this.token.start)throw RangeError("Token end out of bounds");this.token.value=e,this.token.end=n}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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=mk,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(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 i of this.ranges){if(i.from>=t)break;i.to>e&&(n+=this.input.read(Math.max(i.from,e),Math.min(i.to,t)))}return n}constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mk,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}}class mC{token(e,t){let{parser:n}=t.p;mA(this.data,e,t,this.id,n.data,n.tokenPrecTable)}constructor(e,t){this.data=e,this.id=t}}function mA(e,t,n,i,r,s){let o=0,l=1<<i,{dialect:a}=n.p.parser;n:for(;(l&e[o])!=0;){let n=e[o+1];for(let i=o+3;i<n;i+=2)if((e[i+1]&l)>0){let n=e[i];if(a.allows(n)&&(-1==t.token.value||t.token.value==n||function(e,t,n,i){let r=mN(n,i,t);return r<0||mN(n,i,e)<r}(n,t.token.value,r,s))){t.acceptToken(n);break}}let i=t.next,h=0,c=e[o+2];if(t.next<0&&c>h&&65535==e[n+3*c-3]){o=e[n+3*c-1];continue}for(;h<c;){let r=h+c>>1,s=n+r+(r<<1),l=e[s],a=e[s+1]||65536;if(i<l)c=r;else if(i>=a)h=r+1;else{o=e[s+2],t.advance();continue n}}break}}function mN(e,t,n){for(let i=t,r;65535!=(r=e[i]);i++)if(r==n)return i-t;return -1}mC.prototype.contextual=mC.prototype.fallback=mC.prototype.extend=!1,(class{token(e,t){let n=e.pos,i=0;for(;;){let n=e.next<0,r=e.resolveOffset(1,1);if(mA(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(null==this.elseToken)return;if(!n&&i++,null==r)break;e.reset(r,e.token)}i&&(e.reset(n,e.token),e.acceptToken(this.elseToken,i))}constructor(e,t,n){this.precTable=t,this.elseToken=n,this.data="string"==typeof e?my(e):e}}).prototype.contextual=mC.prototype.fallback=mC.prototype.extend=!1;let mM=void 0!==mm.default&&mm.default.env&&/\bparse\b/.test(mm.default.env.LOG),mO=null;function mj(e,t,n){let i=e.cursor(l.IncludeAnonymous);for(i.moveTo(t);;)if(!(n<0?i.childBefore(t):i.childAfter(t)))for(;;){if((n<0?i.to<t:i.from>t)&&!i.type.isError)return n<0?Math.max(0,Math.min(i.to-1,t-25)):Math.min(e.length,Math.max(i.from+1,t+25));if(n<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return n<0?0:e.length}}class mE{nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?mj(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?mj(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(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let n=this.trees[t],i=this.index[t];if(i==n.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let r=n.children[i],s=this.start[t]+n.positions[i];if(s>e)return this.nextStart=s,null;if(r instanceof h_){if(s==e){if(s<this.safeFrom)return null;let e=s+r.length;if(e<=this.safeTo){let t=r.prop(hR.lookAhead);if(!t||e+t<this.fragment.to)return r}}this.index[t]++,s+r.length>=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+r.length}}constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}}class mT{getActions(e){let t=0,n=null,{parser:i}=e.p,{tokenizers:r}=i,s=i.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,l=0;for(let i=0;i<r.length;i++){if((1<<i&s)==0)continue;let a=r[i],h=this.tokens[i];if((!n||a.fallback)&&((a.contextual||h.start!=e.pos||h.mask!=s||h.context!=o)&&(this.updateCachedToken(h,a,e),h.mask=s,h.context=o),h.lookAhead>h.end+25&&(l=Math.max(h.lookAhead,l)),0!=h.value)){let i=t;if(h.extended>-1&&(t=this.addActions(e,h.extended,h.end,t)),t=this.addActions(e,h.value,h.end,t),!a.extend&&(n=h,t>i))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),n||e.pos!=this.stream.end||((n=new mw).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 mw,{pos:n,p:i}=e;return t.start=n,t.end=Math.min(n+1,i.stream.end),t.value=n==i.stream.end?i.parser.eofTerm:0,t}updateCachedToken(e,t,n){let i=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(i,e),n),e.value>-1){let{parser:t}=n.p;for(let i=0;i<t.specialized.length;i++)if(t.specialized[i]==e.value){let r=t.specializers[i](this.stream.read(e.start,e.end),n);if(r>=0&&n.p.parser.dialect.allows(r>>1)){(1&r)==0?e.value=r>>1:e.extended=r>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,t,n,i){for(let t=0;t<i;t+=3)if(this.actions[t]==e)return i;return this.actions[i++]=e,this.actions[i++]=t,this.actions[i++]=n,i}addActions(e,t,n,i){let{state:r}=e,{parser:s}=e.p,{data:o}=s;for(let e=0;e<2;e++)for(let l=s.stateSlot(r,e?2:1);;l+=3){if(65535==o[l])if(1==o[l+1])l=mI(o,l+2);else{0==i&&2==o[l+1]&&(i=this.putAction(mI(o,l+2),t,n,i));break}o[l]==t&&(i=this.putAction(mI(o,l+1),t,n,i))}return i}constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(e=>new mw)}}class mD{get parsedPos(){return this.minStackPos}advance(){let e,t,n=this.stacks,i=this.minStackPos,r=this.stacks=[];if(this.bigReductionCount>300&&1==n.length){let[e]=n;for(;e.forceReduce()&&e.stack.length&&e.stack[e.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<n.length;s++){let o=n[s];for(;;){if(this.tokens.mainToken=null,o.pos>i)r.push(o);else{if(this.advanceStack(o,r,n))continue;e||(e=[],t=[]),e.push(o);let i=this.tokens.getMainToken(o);t.push(i.value,i.end)}break}}if(!r.length){let t=e&&function(e){let t=null;for(let n of e){let e=n.p.stoppedAt;(n.pos==n.p.stream.end||null!=e&&n.pos>e)&&n.p.parser.stateFlag(n.state,2)&&(!t||t.score<n.score)&&(t=n)}return t}(e);if(t)return mM&&console.log("Finish with "+this.stackID(t)),this.stackToTree(t);if(this.parser.strict)throw mM&&e&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),SyntaxError("No parse at "+i);this.recovering||(this.recovering=5)}if(this.recovering&&e){let n=null!=this.stoppedAt&&e[0].pos>this.stoppedAt?e[0]:this.runRecovery(e,t,r);if(n)return mM&&console.log("Force-finish "+this.stackID(n)),this.stackToTree(n.forceAll())}if(this.recovering){let e=1==this.recovering?1:3*this.recovering;if(r.length>e)for(r.sort((e,t)=>t.score-e.score);r.length>e;)r.pop();r.some(e=>e.reducePos>i)&&this.recovering--}else if(r.length>1){r:for(let e=0;e<r.length-1;e++){let t=r[e];for(let n=e+1;n<r.length;n++){let i=r[n];if(t.sameState(i)||t.buffer.length>500&&i.buffer.length>500)if((t.score-i.score||t.buffer.length-i.buffer.length)>0)r.splice(n--,1);else{r.splice(e--,1);continue r}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let e=1;e<r.length;e++)r[e].pos<this.minStackPos&&(this.minStackPos=r[e].pos);return null}stopAt(e){if(null!=this.stoppedAt&&this.stoppedAt<e)throw RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,n){let i=e.pos,{parser:r}=this,s=mM?this.stackID(e)+" -> ":"";if(null!=this.stoppedAt&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let t=e.curContext&&e.curContext.tracker.strict,n=t?e.curContext.hash:0;for(let o=this.fragments.nodeAt(i);o;){let i=this.parser.nodeSet.types[o.type.id]==o.type?r.getGoto(e.state,o.type.id):-1;if(i>-1&&o.length&&(!t||(o.prop(hR.contextHash)||0)==n))return e.useNode(o,i),mM&&console.log(s+this.stackID(e)+" (via reuse of ".concat(r.getName(o.type.id),")")),!0;if(!(o instanceof h_)||0==o.children.length||o.positions[0]>0)break;let l=o.children[0];if(l instanceof h_&&0==o.positions[0])o=l;else break}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),mM&&console.log(s+this.stackID(e)+" (via always-reduce ".concat(r.getName(65535&o),")")),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let o=0;o<l.length;){let a=l[o++],h=l[o++],c=l[o++],d=o==l.length||!n,u=d?e:e.split(),f=this.tokens.mainToken;if(u.apply(a,h,f?f.start:u.pos,c),mM&&console.log(s+this.stackID(u)+" (via ".concat((65536&a)==0?"shift":"reduce of ".concat(r.getName(65535&a))," for ").concat(r.getName(h)," @ ").concat(i).concat(u==e?"":", split",")")),d)return!0;u.pos>i?t.push(u):n.push(u)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return mR(e,t),!0}}runRecovery(e,t,n){let i=null,r=!1;for(let s=0;s<e.length;s++){let o=e[s],l=t[s<<1],a=t[(s<<1)+1],h=mM?this.stackID(o)+" -> ":"";if(o.deadEnd&&(r||(r=!0,o.restart(),mM&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let c=o.split(),d=h;for(let e=0;c.forceReduce()&&e<10&&(mM&&console.log(d+this.stackID(c)+" (via force-reduce)"),!this.advanceFully(c,n));e++)mM&&(d=this.stackID(c)+" -> ");for(let e of o.recoverByInsert(l))mM&&console.log(h+this.stackID(e)+" (via recover-insert)"),this.advanceFully(e,n);this.stream.end>o.pos?(a==o.pos&&(a++,l=0),o.recoverByDelete(l,a),mM&&console.log(h+this.stackID(o)+" (via recover-delete ".concat(this.parser.getName(l),")")),mR(o,n)):(!i||i.score<o.score)&&(i=o)}return i}stackToTree(e){return e.close(),h_.build({buffer:mb.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(mO||(mO=new WeakMap)).get(e);return t||mO.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}constructor(e,t,n,i){this.parser=e,this.input=t,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new mS(t,i),this.tokens=new mT(e,this.stream),this.topTerm=e.top[1];let{from:r}=i[0];this.stacks=[mg.start(this,e.top[0],r)],this.fragments=n.length&&this.stream.end-r>4*e.bufferLength?new mE(n,e.nodeSet):null}}function mR(e,t){for(let n=0;n<t.length;n++){let i=t[n];if(i.pos==e.pos&&i.sameState(e)){t[n].score<e.score&&(t[n]=e);return}}t.push(e)}class mP{allows(e){return!this.disabled||0==this.disabled[e]}constructor(e,t,n){this.source=e,this.flags=t,this.disabled=n}}class mL extends h5{createParse(e,t,n){let i=new mD(this,e,t,n);for(let r of this.wrappers)i=r(i,e,t,n);return i}getGoto(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=this.goto;if(t>=i[0])return -1;for(let r=i[t+1];;){let t=i[r++],s=1&t,o=i[r++];if(s&&n)return o;for(let n=r+(t>>1);r<n;r++)if(i[r]==e)return o;if(s)return -1}}hasAction(e,t){let n=this.data;for(let i=0;i<2;i++)for(let r=this.stateSlot(e,i?2:1),s;;r+=3){if(65535==(s=n[r]))if(1==n[r+1])s=n[r=mI(n,r+2)];else if(2==n[r+1])return mI(n,r+2);else break;if(s==t||0==s)return mI(n,r+1)}return 0}stateSlot(e,t){return this.states[6*e+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,e=>e==t||null)}allActions(e,t){let n=this.stateSlot(e,4),i=n?t(n):void 0;for(let n=this.stateSlot(e,1);null==i;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=mI(this.data,n+2);else break;i=t(mI(this.data,n+1))}return i}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(65535==this.data[n])if(1==this.data[n+1])n=mI(this.data,n+2);else break;if((1&this.data[n+2])==0){let e=this.data[n+1];t.some((t,n)=>1&n&&t==e)||t.push(this.data[n],e)}}return t}configure(e){let t=Object.assign(Object.create(mL.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw RangeError("Invalid top rule name ".concat(e.top));t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(t=>{let n=e.tokenizers.find(e=>e.from==t);return n?n.to:t})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,i)=>{let r=e.specializers.find(e=>e.from==n.external);if(!r)return n;let s=Object.assign(Object.assign({},n),{external:r.to});return t.specializers[i]=mB(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),null!=e.strict&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),null!=e.bufferLength&&(t.bufferLength=e.bufferLength),t}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 null==t?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let i of e.split(" ")){let e=t.indexOf(i);e>=0&&(n[e]=!0)}let i=null;for(let e=0;e<t.length;e++)if(!n[e])for(let n=this.dialects[t[e]],r;65535!=(r=this.data[n++]);)(i||(i=new Uint8Array(this.maxTerm+1)))[r]=1;return new mP(e,n,i)}static deserialize(e){return new mL(e)}constructor(e){if(super(),this.wrappers=[],14!=e.version)throw RangeError("Parser version (".concat(e.version,") doesn't match runtime version (",14,")"));let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let n=0;n<e.repeatNodeCount;n++)t.push("");let n=Object.keys(e.topRules).map(t=>e.topRules[t][1]),i=[];for(let e=0;e<t.length;e++)i.push([]);function r(e,t,n){i[e].push([t,t.deserialize(String(n))])}if(e.nodeProps)for(let t of e.nodeProps){let e=t[0];"string"==typeof e&&(e=hR[e]);for(let n=1;n<t.length;){let i=t[n++];if(i>=0)r(i,e,t[n++]);else{let s=t[n+-i];for(let o=-i;o>0;o--)r(t[n++],e,s);n++}}}this.nodeSet=new hB(t.map((t,r)=>hI.define({name:r>=this.minRepeatTerm?void 0:t,id:r,props:i[r],top:n.indexOf(r)>-1,error:0==r,skipped:e.skippedNodes&&e.skippedNodes.indexOf(r)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=my(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let e=0;e<this.specializerSpecs.length;e++)this.specialized[e]=this.specializerSpecs[e].term;this.specializers=this.specializerSpecs.map(mB),this.states=my(e.states,Uint32Array),this.data=my(e.stateData),this.goto=my(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(e=>"number"==typeof e?new mC(s,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]]}}function mI(e,t){return e[t]|e[t+1]<<16}function mB(e){if(e.external){let t=+!!e.extend;return(n,i)=>e.external(n,i)<<1|t}return e.get}let mz=ct({String:cw.string,Number:cw.number,"True False":cw.bool,PropertyName:cw.propertyName,Null:cw.null,", :":cw.separator,"[ ]":cw.squareBracket,"{ }":cw.brace}),mF=mL.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:[mz],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}),m_=cN.define({name:"json",parser:mF.configure({props:[cq.add({Object:cG({except:/^\s*\}/}),Array:cG({except:/^\s*\]/})}),cQ.add({"Object Array":function(e){let t=e.firstChild,n=e.lastChild;return t&&t.to<n.from?{from:t.to,to:n.type.isError?e.to:n.from}:null}})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function mW(e){let{value:t,onChange:n,language:i="json",className:r="",id:s,readOnly:o=!1}=e,l=(0,d.useMemo)(()=>{if("json"!==i||!t.trim())return t;try{let e=JSON.parse(t);return JSON.stringify(e,null,2)}catch(e){return t}},[t,i]),a=(0,d.useMemo)(()=>{let e=[];return"json"===i&&e.push(new cB(m_)),e.push(ao.lineWrapping),e.push(ao.theme({"&":{height:"auto !important"},".cm-scroller":{overflow:"visible !important"},".cm-editor":{height:"auto !important"},".cm-content":{padding:"8px",minHeight:"fit-content"}})),e},[i]);return(0,c.jsx)("div",{id:s,className:"border rounded-lg overflow-hidden ".concat(r),children:(0,c.jsx)(mp,{value:l,extensions:a,onChange:o?void 0:e=>n(e),theme:"dark",basicSetup:{lineNumbers:!0,foldGutter:!0,dropCursor:!1,allowMultipleSelections:!1,indentOnInput:!o,bracketMatching:!0,closeBrackets:!o,autocompletion:!o,highlightSelectionMatches:!1,searchKeymap:!o},editable:!o})})}var mV="horizontal",mH=["horizontal","vertical"],mq=d.forwardRef((e,t)=>{var n;let{decorative:i,orientation:r=mV,...s}=e,o=(n=r,mH.includes(n))?r:mV;return(0,c.jsx)(y.div,{"data-orientation":o,...i?{role:"none"}:{"aria-orientation":"vertical"===o?o:void 0,role:"separator"},...s,ref:t})});mq.displayName="Separator";let mK=d.forwardRef((e,t)=>{let{className:n,orientation:i="horizontal",decorative:r=!0,...s}=e;return(0,c.jsx)(mq,{ref:t,decorative:r,orientation:i,className:e6("shrink-0 bg-border","horizontal"===i?"h-[1px] w-full":"h-full w-[1px]",n),...s})});function mU(e,t,n){if(!t.has(e))throw TypeError("attempted to "+n+" private field on non-instance");return t.get(e)}function mJ(e,t){var n=mU(e,t,"get");return n.get?n.get.call(e):n.value}function mG(e,t,n){var i=mU(e,t,"set");if(i.set)i.set.call(e,n);else{if(!i.writable)throw TypeError("attempted to set read only private field");i.value=n}return n}function mY(e){let t=e+"CollectionProvider",[n,i]=C(t),[r,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,i=d.default.useRef(null),s=d.default.useRef(new Map).current;return(0,c.jsx)(r,{scope:t,itemMap:s,collectionRef:i,children:n})};o.displayName=t;let l=e+"CollectionSlot",a=g(l),h=d.default.forwardRef((e,t)=>{let{scope:n,children:i}=e,r=m(t,s(l,n).collectionRef);return(0,c.jsx)(a,{ref:r,children:i})});h.displayName=l;let u=e+"CollectionItemSlot",f="data-radix-collection-item",p=g(u),v=d.default.forwardRef((e,t)=>{let{scope:n,children:i,...r}=e,o=d.default.useRef(null),l=m(t,o),a=s(u,n);return d.default.useEffect(()=>(a.itemMap.set(o,{ref:o,...r}),()=>void a.itemMap.delete(o))),(0,c.jsx)(p,{...{[f]:""},ref:l,children:i})});return v.displayName=u,[{Provider:o,Slot:h,ItemSlot:v},function(t){let n=s(e+"CollectionConsumer",t);return d.default.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll("[".concat(f,"]")));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])},i]}mK.displayName=mq.displayName;var mQ=new WeakMap;function mX(e,t){if("at"in Array.prototype)return Array.prototype.at.call(e,t);let n=function(e,t){let n=e.length,i=m$(t),r=i>=0?i:n+i;return r<0||r>=n?-1:r}(e,t);return -1===n?void 0:e[n]}function m$(e){return e!=e||0===e?0:Math.trunc(e)}h=new WeakMap,class e extends Map{set(e,t){return mQ.get(this)&&(this.has(e)?mJ(this,h)[mJ(this,h).indexOf(e)]=e:mJ(this,h).push(e)),super.set(e,t),this}insert(e,t,n){let i,r=this.has(t),s=mJ(this,h).length,o=m$(e),l=o>=0?o:s+o,a=l<0||l>=s?-1:l;if(a===this.size||r&&a===this.size-1||-1===a)return this.set(t,n),this;let c=this.size+ +!r;o<0&&l++;let d=[...mJ(this,h)],u=!1;for(let e=l;e<c;e++)if(l===e){let s=d[e];d[e]===t&&(s=d[e+1]),r&&this.delete(t),i=this.get(s),this.set(t,n)}else{u||d[e-1]!==t||(u=!0);let n=d[u?e:e-1],r=i;i=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,i){let r=new e(this);return r.insert(t,n,i),r}before(e){let t=mJ(this,h).indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let i=mJ(this,h).indexOf(e);return -1===i?this:this.insert(i,t,n)}after(e){let t=mJ(this,h).indexOf(e);if(-1!==(t=-1===t||t===this.size-1?-1:t+1))return this.entryAt(t)}setAfter(e,t,n){let i=mJ(this,h).indexOf(e);return -1===i?this:this.insert(i+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return mG(this,h,[]),super.clear()}delete(e){let t=super.delete(e);return t&&mJ(this,h).splice(mJ(this,h).indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return void 0!==t&&this.delete(t)}at(e){let t=mX(mJ(this,h),e);if(void 0!==t)return this.get(t)}entryAt(e){let t=mX(mJ(this,h),e);if(void 0!==t)return[t,this.get(t)]}indexOf(e){return mJ(this,h).indexOf(e)}keyAt(e){return mX(mJ(this,h),e)}from(e,t){let n=this.indexOf(e);if(-1===n)return;let i=n+t;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.at(i)}keyFrom(e,t){let n=this.indexOf(e);if(-1===n)return;let i=n+t;return i<0&&(i=0),i>=this.size&&(i=this.size-1),this.keyAt(i)}find(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return i;n++}}findIndex(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return n;n++}return -1}filter(t,n){let i=[],r=0;for(let e of this)Reflect.apply(t,n,[e,r,this])&&i.push(e),r++;return new e(i)}map(t,n){let i=[],r=0;for(let e of this)i.push([e[0],Reflect.apply(t,n,[e,r,this])]),r++;return new e(i)}reduce(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let[i,r]=t,s=0,o=null!=r?r:this.at(0);for(let e of this)o=0===s&&1===t.length?e:Reflect.apply(i,this,[o,e,s,this]),s++;return o}reduceRight(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];let[i,r]=t,s=null!=r?r:this.at(-1);for(let e=this.size-1;e>=0;e--){let n=this.at(e);s=e===this.size-1&&1===t.length?n:Reflect.apply(i,this,[s,n,e,this])}return s}toSorted(t){return new e([...this.entries()].sort(t))}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),i=this.get(n);t.set(n,i)}return t}toSpliced(){for(var t=arguments.length,n=Array(t),i=0;i<t;i++)n[i]=arguments[i];let r=[...this.entries()];return r.splice(...n),new e(r)}slice(t,n){let i=new e,r=this.size-1;if(void 0===t)return i;t<0&&(t+=this.size),void 0!==n&&n>0&&(r=n-1);for(let e=t;e<=r;e++){let t=this.keyAt(e),n=this.get(t);i.set(t,n)}return i}every(e,t){let n=0;for(let i of this){if(!Reflect.apply(e,t,[i,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let i of this){if(Reflect.apply(e,t,[i,n,this]))return!0;n++}return!1}constructor(e){super(e),function(e,t,n){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object");t.set(e,n)}(this,h,{writable:!0,value:void 0}),mG(this,h,[...super.keys()]),mQ.set(this,!0)}};var mZ="Collapsible",[m0,m1]=C(mZ),[m2,m3]=m0(mZ),m4=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:i,defaultOpen:r,disabled:s,onOpenChange:o,...l}=e,[a,h]=tE({prop:i,defaultProp:null!=r&&r,onChange:o,caller:mZ});return(0,c.jsx)(m2,{scope:n,disabled:s,contentId:tO(),open:a,onOpenToggle:d.useCallback(()=>h(e=>!e),[h]),children:(0,c.jsx)(y.div,{"data-state":ge(a),"data-disabled":s?"":void 0,...l,ref:t})})});m4.displayName=mZ;var m5="CollapsibleTrigger",m8=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,...i}=e,r=m3(m5,n);return(0,c.jsx)(y.button,{type:"button","aria-controls":r.contentId,"aria-expanded":r.open||!1,"data-state":ge(r.open),"data-disabled":r.disabled?"":void 0,disabled:r.disabled,...i,ref:t,onClick:O(e.onClick,r.onOpenToggle)})});m8.displayName=m5;var m6="CollapsibleContent",m9=d.forwardRef((e,t)=>{let{forceMount:n,...i}=e,r=m3(m6,e.__scopeCollapsible);return(0,c.jsx)(k,{present:n||r.open,children:e=>{let{present:n}=e;return(0,c.jsx)(m7,{...i,ref:t,present:n})}})});m9.displayName=m6;var m7=d.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:i,children:r,...s}=e,o=m3(m6,n),[l,a]=d.useState(i),h=d.useRef(null),u=m(t,h),f=d.useRef(0),p=f.current,g=d.useRef(0),v=g.current,x=o.open||l,b=d.useRef(x),k=d.useRef(void 0);return d.useEffect(()=>{let e=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(e)},[]),w(()=>{let e=h.current;if(e){k.current=k.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();f.current=t.height,g.current=t.width,b.current||(e.style.transitionDuration=k.current.transitionDuration,e.style.animationName=k.current.animationName),a(i)}},[o.open,i]),(0,c.jsx)(y.div,{"data-state":ge(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!x,...s,ref:u,style:{"--radix-collapsible-content-height":p?"".concat(p,"px"):void 0,"--radix-collapsible-content-width":v?"".concat(v,"px"):void 0,...e.style},children:x&&r})});function ge(e){return e?"open":"closed"}var gt="Accordion",gn=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[gi,gr,gs]=mY(gt),[go,gl]=C(gt,[gs,m1]),ga=m1(),gh=d.default.forwardRef((e,t)=>{let{type:n,...i}=e;return(0,c.jsx)(gi.Provider,{scope:e.__scopeAccordion,children:"multiple"===n?(0,c.jsx)(gm,{...i,ref:t}):(0,c.jsx)(gp,{...i,ref:t})})});gh.displayName=gt;var[gc,gd]=go(gt),[gu,gf]=go(gt,{collapsible:!1}),gp=d.default.forwardRef((e,t)=>{let{value:n,defaultValue:i,onValueChange:r=()=>{},collapsible:s=!1,...o}=e,[l,a]=tE({prop:n,defaultProp:null!=i?i:"",onChange:r,caller:gt});return(0,c.jsx)(gc,{scope:e.__scopeAccordion,value:d.default.useMemo(()=>l?[l]:[],[l]),onItemOpen:a,onItemClose:d.default.useCallback(()=>s&&a(""),[s,a]),children:(0,c.jsx)(gu,{scope:e.__scopeAccordion,collapsible:s,children:(0,c.jsx)(gx,{...o,ref:t})})})}),gm=d.default.forwardRef((e,t)=>{let{value:n,defaultValue:i,onValueChange:r=()=>{},...s}=e,[o,l]=tE({prop:n,defaultProp:null!=i?i:[],onChange:r,caller:gt}),a=d.default.useCallback(e=>l(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return[...t,e]}),[l]),h=d.default.useCallback(e=>l(function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return t.filter(t=>t!==e)}),[l]);return(0,c.jsx)(gc,{scope:e.__scopeAccordion,value:o,onItemOpen:a,onItemClose:h,children:(0,c.jsx)(gu,{scope:e.__scopeAccordion,collapsible:!0,children:(0,c.jsx)(gx,{...s,ref:t})})})}),[gg,gv]=go(gt),gx=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,disabled:i,dir:r,orientation:s="vertical",...o}=e,l=m(d.default.useRef(null),t),a=gr(n),h="ltr"===M(r),u=O(e.onKeyDown,e=>{var t;if(!gn.includes(e.key))return;let n=e.target,i=a().filter(e=>{var t;return!(null==(t=e.ref.current)?void 0:t.disabled)}),r=i.findIndex(e=>e.ref.current===n),o=i.length;if(-1===r)return;e.preventDefault();let l=r,c=o-1,d=()=>{(l=r+1)>c&&(l=0)},u=()=>{(l=r-1)<0&&(l=c)};switch(e.key){case"Home":l=0;break;case"End":l=c;break;case"ArrowRight":"horizontal"===s&&(h?d():u());break;case"ArrowDown":"vertical"===s&&d();break;case"ArrowLeft":"horizontal"===s&&(h?u():d());break;case"ArrowUp":"vertical"===s&&u()}null==(t=i[l%o].ref.current)||t.focus()});return(0,c.jsx)(gg,{scope:n,disabled:i,direction:r,orientation:s,children:(0,c.jsx)(gi.Slot,{scope:n,children:(0,c.jsx)(y.div,{...o,"data-orientation":s,ref:l,onKeyDown:i?void 0:u})})})}),gb="AccordionItem",[gy,gw]=go(gb),gk=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,value:i,...r}=e,s=gv(gb,n),o=gd(gb,n),l=ga(n),a=tO(),h=i&&o.value.includes(i)||!1,d=s.disabled||e.disabled;return(0,c.jsx)(gy,{scope:n,open:h,disabled:d,triggerId:a,children:(0,c.jsx)(m4,{"data-orientation":s.orientation,"data-state":gj(h),...l,...r,ref:t,disabled:d,open:h,onOpenChange:e=>{e?o.onItemOpen(i):o.onItemClose(i)}})})});gk.displayName=gb;var gS="AccordionHeader",gC=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gS,n);return(0,c.jsx)(y.h3,{"data-orientation":r.orientation,"data-state":gj(s.open),"data-disabled":s.disabled?"":void 0,...i,ref:t})});gC.displayName=gS;var gA="AccordionTrigger",gN=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gA,n),o=gf(gA,n),l=ga(n);return(0,c.jsx)(gi.ItemSlot,{scope:n,children:(0,c.jsx)(m8,{"aria-disabled":s.open&&!o.collapsible||void 0,"data-orientation":r.orientation,id:s.triggerId,...l,...i,ref:t})})});gN.displayName=gA;var gM="AccordionContent",gO=d.default.forwardRef((e,t)=>{let{__scopeAccordion:n,...i}=e,r=gv(gt,n),s=gw(gM,n),o=ga(n);return(0,c.jsx)(m9,{role:"region","aria-labelledby":s.triggerId,"data-orientation":r.orientation,...o,...i,ref:t,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...e.style}})});function gj(e){return e?"open":"closed"}gO.displayName=gM;let gE=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(gk,{ref:t,className:e6("border-b",n),...i})});gE.displayName="AccordionItem";let gT=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsx)(gC,{className:"flex",children:(0,c.jsxs)(gN,{ref:t,className:e6("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",n),...r,children:[i,(0,c.jsx)(ix,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})})});gT.displayName=gN.displayName;let gD=d.forwardRef((e,t)=>{let{className:n,children:i,...r}=e;return(0,c.jsx)(gO,{ref:t,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...r,children:(0,c.jsx)("div",{className:e6("pb-4 pt-0",n),children:i})})});gD.displayName=gO.displayName;let gR=td("type",[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]]),gP=td("hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),gL=td("toggle-left",[["circle",{cx:"9",cy:"12",r:"3",key:"u3jwor"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]]),gI=td("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);function gB(e){return null===e?"null":Array.isArray(e)?"array":"object"==typeof e?"object":typeof e}function gz(e){let{data:t,onChange:n,className:i=""}=e,[r,s]=(0,d.useState)({});(0,d.useEffect)(()=>{if(t){let e=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=[];return null===t?[{key:n.join(".")||"root",value:null,type:"null",path:n}]:(Array.isArray(t)?t.forEach((t,r)=>{let s=[...n,r.toString()];i.push(...e(t,s))}):"object"==typeof t?Object.entries(t).forEach(t=>{let[r,s]=t,o=[...n,r];"object"!=typeof s||null===s||Array.isArray(s)?i.push({key:o.join("."),value:s,type:gB(s),path:o}):i.push(...e(s,o))}):i.push({key:n.join(".")||"root",value:t,type:gB(t),path:n}),i)}(t),n={};e.forEach(e=>{let t=e.path.slice(0,-1).join(".")||"root";n[t]||(n[t]=[]),n[t].push(e)}),s(n)}},[t]);let o=(e,i)=>{n(function e(t,n,i){if(0===n.length)return i;if(Array.isArray(t)){let r=[...t],[s,...o]=n,l=parseInt(s);return 0===o.length?r[l]=i:r[l]=e(r[l]||{},o,i),r}if("object"==typeof t&&null!==t){let r={...t},[s,...o]=n;return 0===o.length?r[s]=i:r[s]=e(r[s]||{},o,i),r}return i}(t,e.path,i))},l=(e,t)=>{let n;switch(t){case"string":n=String(e.value||"");break;case"number":n=Number(e.value)||0;break;case"boolean":n=!!e.value;break;case"null":n=null;break;case"array":n=Array.isArray(e.value)?e.value:[];break;case"object":n="object"!=typeof e.value||Array.isArray(e.value)?{}:e.value;break;default:n=e.value}o(e,n)};if(!t)return(0,c.jsx)(tw,{className:"h-full ".concat(i),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(tp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"No data to edit"})]})})});let a=Object.keys(r).sort();return(0,c.jsxs)(tw,{className:"h-full ".concat(i),children:[(0,c.jsxs)(tk,{children:[(0,c.jsxs)(tS,{className:"flex items-center gap-2",children:[(0,c.jsx)(tp,{className:"h-5 w-5"}),"JSON Form Editor"]}),(0,c.jsx)(tC,{children:"Edit JSON values using form controls"})]}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-6",children:a.map(e=>(0,c.jsx)(gh,{type:"single",collapsible:!0,children:(0,c.jsxs)(gE,{value:e,className:"border-2 rounded-lg bg-card/50 shadow-sm",children:[(0,c.jsx)(gT,{className:"text-sm font-medium px-4 py-3 bg-muted/30 rounded-t-lg",children:(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(to,{variant:"outline",className:"font-mono text-xs",children:"root"===e?"Root Level":e}),(0,c.jsxs)("span",{className:"text-muted-foreground",children:["(",r[e].length," fields)"]})]})}),(0,c.jsx)(gD,{children:(0,c.jsx)("div",{className:"space-y-4 pt-2 px-4 pb-4 bg-background/50 rounded-b-lg",children:r[e].map(e=>(0,c.jsxs)("div",{className:"space-y-3 border border-muted-foreground/20 rounded-lg p-3 bg-muted/10",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)(iO,{htmlFor:"field-".concat(e.key),className:"flex items-center gap-2 font-medium",children:[(0,c.jsx)("span",{className:"font-mono text-sm bg-muted px-2 py-1 rounded",children:e.path[e.path.length-1]}),(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat((e=>{switch(e){case"string":return"bg-green-50 text-green-700 dark:bg-green-800 dark:text-green-100";case"number":return"bg-blue-50 text-blue-700 dark:bg-blue-800 dark:text-blue-100";case"boolean":return"bg-purple-50 text-purple-700 dark:bg-purple-800 dark:text-purple-100";case"array":return"bg-orange-50 text-orange-700 dark:bg-orange-800 dark:text-orange-100";case"object":return"bg-red-50 text-red-700 dark:bg-red-800 dark:text-red-100";default:return"bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-100"}})(e.type)),children:[(e=>{switch(e){case"string":return(0,c.jsx)(gR,{className:"h-4 w-4"});case"number":return(0,c.jsx)(gP,{className:"h-4 w-4"});case"boolean":return(0,c.jsx)(gL,{className:"h-4 w-4"});case"array":return(0,c.jsx)(gI,{className:"h-4 w-4"});default:return(0,c.jsx)(tp,{className:"h-4 w-4"})}})(e.type),e.type]})]}),"root"!==e.key&&e.path.length>0&&(0,c.jsx)(iC,{value:e.type,onChange:t=>{let n=t.target.value;["string","number","boolean","array","object","null"].includes(n)&&l(e,n)},className:"w-32 h-8 font-mono text-xs",placeholder:"string, number, boolean..."})]}),(e=>{let t="field-".concat(e.key);switch(e.type){case"string":return(0,c.jsx)("div",{className:"space-y-2",children:String(e.value).length>100?(0,c.jsx)(mW,{id:t,value:String(e.value),onChange:t=>o(e,t),language:"text"}):(0,c.jsx)(iC,{id:t,type:"text",value:String(e.value),onChange:t=>o(e,t.target.value),className:"font-mono",placeholder:"Enter text..."})});case"number":return(0,c.jsx)(iC,{id:t,type:"number",value:Number(e.value),onChange:t=>o(e,parseFloat(t.target.value)||0),className:"font-mono",placeholder:"0"});case"boolean":return(0,c.jsx)(iC,{id:t,value:String(e.value),onChange:t=>{let n=t.target.value.toLowerCase();"true"===n||"false"===n?o(e,"true"===n):o(e,t.target.value)},className:"font-mono",placeholder:"true or false"});case"null":return(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(to,{variant:"secondary",className:"font-mono",children:"null"}),(0,c.jsx)(tr,{size:"sm",variant:"outline",onClick:()=>l(e,"string"),children:"Convert to String"})]});case"array":return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{variant:"outline",className:"font-mono",children:["Array (",Array.isArray(e.value)?e.value.length:0," items)"]})}),(0,c.jsx)(mW,{id:t,value:JSON.stringify(e.value,null,2),onChange:t=>{try{let n=JSON.parse(t);Array.isArray(n)&&o(e,n)}catch(e){}},language:"json"})]});case"object":return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)("div",{className:"flex items-center gap-2",children:(0,c.jsxs)(to,{variant:"outline",className:"font-mono",children:["Object (","object"==typeof e.value&&e.value?Object.keys(e.value).length:0," keys)"]})}),(0,c.jsx)(mW,{id:t,value:JSON.stringify(e.value,null,2),onChange:t=>{try{let n=JSON.parse(t);"object"!=typeof n||Array.isArray(n)||o(e,n)}catch(e){}},language:"json"})]});default:return(0,c.jsxs)("div",{className:"text-muted-foreground italic",children:["Unsupported type: ",e.type]})}})(e),(0,c.jsx)(mK,{className:"my-4"})]},e.key))})})]})},e))})})})]})}var gF="rovingFocusGroup.onEntryFocus",g_={bubbles:!1,cancelable:!0},gW="RovingFocusGroup",[gV,gH,gq]=mY(gW),[gK,gU]=C(gW,[gq]),[gJ,gG]=gK(gW),gY=d.forwardRef((e,t)=>(0,c.jsx)(gV.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(gV.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,c.jsx)(gQ,{...e,ref:t})})}));gY.displayName=gW;var gQ=d.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:i,loop:r=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:a,onEntryFocus:h,preventScrollOnEntryFocus:u=!1,...f}=e,p=d.useRef(null),g=m(t,p),v=M(s),[x,b]=tE({prop:o,defaultProp:null!=l?l:null,onChange:a,caller:gW}),[w,k]=d.useState(!1),S=A(h),C=gH(n),N=d.useRef(!1),[j,E]=d.useState(0);return d.useEffect(()=>{let e=p.current;if(e)return e.addEventListener(gF,S),()=>e.removeEventListener(gF,S)},[S]),(0,c.jsx)(gJ,{scope:n,orientation:i,dir:v,loop:r,currentTabStopId:x,onItemFocus:d.useCallback(e=>b(e),[b]),onItemShiftTab:d.useCallback(()=>k(!0),[]),onFocusableItemAdd:d.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:d.useCallback(()=>E(e=>e-1),[]),children:(0,c.jsx)(y.div,{tabIndex:w||0===j?-1:0,"data-orientation":i,...f,ref:g,style:{outline:"none",...e.style},onMouseDown:O(e.onMouseDown,()=>{N.current=!0}),onFocus:O(e.onFocus,e=>{let t=!N.current;if(e.target===e.currentTarget&&t&&!w){let t=new CustomEvent(gF,g_);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=C().filter(e=>e.focusable);g0([e.find(e=>e.active),e.find(e=>e.id===x),...e].filter(Boolean).map(e=>e.ref.current),u)}}N.current=!1}),onBlur:O(e.onBlur,()=>k(!1))})})}),gX="RovingFocusGroupItem",g$=d.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:i=!0,active:r=!1,tabStopId:s,children:o,...l}=e,a=tO(),h=s||a,u=gG(gX,n),f=u.currentTabStopId===h,p=gH(n),{onFocusableItemAdd:m,onFocusableItemRemove:g,currentTabStopId:v}=u;return d.useEffect(()=>{if(i)return m(),()=>g()},[i,m,g]),(0,c.jsx)(gV.ItemSlot,{scope:n,id:h,focusable:i,active:r,children:(0,c.jsx)(y.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:O(e.onMouseDown,e=>{i?u.onItemFocus(h):e.preventDefault()}),onFocus:O(e.onFocus,()=>u.onItemFocus(h)),onKeyDown:O(e.onKeyDown,e=>{if("Tab"===e.key&&e.shiftKey)return void u.onItemShiftTab();if(e.target!==e.currentTarget)return;let t=function(e,t,n){var i;let r=(i=e.key,"rtl"!==n?i:"ArrowLeft"===i?"ArrowRight":"ArrowRight"===i?"ArrowLeft":i);if(!("vertical"===t&&["ArrowLeft","ArrowRight"].includes(r))&&!("horizontal"===t&&["ArrowUp","ArrowDown"].includes(r)))return gZ[r]}(e,u.orientation,u.dir);if(void 0!==t){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if("last"===t)n.reverse();else if("prev"===t||"next"===t){"prev"===t&&n.reverse();let i=n.indexOf(e.currentTarget);n=u.loop?function(e,t){return e.map((n,i)=>e[(t+i)%e.length])}(n,i+1):n.slice(i+1)}setTimeout(()=>g0(n))}}),children:"function"==typeof o?o({isCurrentTabStop:f,hasTabStop:null!=v}):o})})});g$.displayName=gX;var gZ={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function g0(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=document.activeElement;for(let i of e)if(i===n||(i.focus({preventScroll:t}),document.activeElement!==n))return}var g1="Tabs",[g2,g3]=C(g1,[gU]),g4=gU(),[g5,g8]=g2(g1),g6=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,onValueChange:r,defaultValue:s,orientation:o="horizontal",dir:l,activationMode:a="automatic",...h}=e,d=M(l),[u,f]=tE({prop:i,onChange:r,defaultProp:null!=s?s:"",caller:g1});return(0,c.jsx)(g5,{scope:n,baseId:tO(),value:u,onValueChange:f,orientation:o,dir:d,activationMode:a,children:(0,c.jsx)(y.div,{dir:d,"data-orientation":o,...h,ref:t})})});g6.displayName=g1;var g9="TabsList",g7=d.forwardRef((e,t)=>{let{__scopeTabs:n,loop:i=!0,...r}=e,s=g8(g9,n),o=g4(n);return(0,c.jsx)(gY,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:i,children:(0,c.jsx)(y.div,{role:"tablist","aria-orientation":s.orientation,...r,ref:t})})});g7.displayName=g9;var ve="TabsTrigger",vt=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,disabled:r=!1,...s}=e,o=g8(ve,n),l=g4(n),a=vr(o.baseId,i),h=vs(o.baseId,i),d=i===o.value;return(0,c.jsx)(g$,{asChild:!0,...l,focusable:!r,active:d,children:(0,c.jsx)(y.button,{type:"button",role:"tab","aria-selected":d,"aria-controls":h,"data-state":d?"active":"inactive","data-disabled":r?"":void 0,disabled:r,id:a,...s,ref:t,onMouseDown:O(e.onMouseDown,e=>{r||0!==e.button||!1!==e.ctrlKey?e.preventDefault():o.onValueChange(i)}),onKeyDown:O(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&o.onValueChange(i)}),onFocus:O(e.onFocus,()=>{let e="manual"!==o.activationMode;d||r||!e||o.onValueChange(i)})})})});vt.displayName=ve;var vn="TabsContent",vi=d.forwardRef((e,t)=>{let{__scopeTabs:n,value:i,forceMount:r,children:s,...o}=e,l=g8(vn,n),a=vr(l.baseId,i),h=vs(l.baseId,i),u=i===l.value,f=d.useRef(u);return d.useEffect(()=>{let e=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,c.jsx)(k,{present:r||u,children:n=>{let{present:i}=n;return(0,c.jsx)(y.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":a,hidden:!i,id:h,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:i&&s})}})});function vr(e,t){return"".concat(e,"-trigger-").concat(t)}function vs(e,t){return"".concat(e,"-content-").concat(t)}vi.displayName=vn;let vo=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(g7,{ref:t,className:e6("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",n),...i})});vo.displayName=g7.displayName;let vl=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(vt,{ref:t,className:e6("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",n),...i})});vl.displayName=vt.displayName;let va=d.forwardRef((e,t)=>{let{className:n,...i}=e;return(0,c.jsx)(vi,{ref:t,className:e6("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...i})});va.displayName=vi.displayName;let vh=td("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]),vc=td("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);function vd(e){return null===e?"null":Array.isArray(e)?"array":"object"==typeof e?"object":typeof e}function vu(e){let{field:t,expanded:n,onToggle:i,searchTerm:r}=e,s="object"===t.type||"array"===t.type,o=r&&(t.key.toLowerCase().includes(r.toLowerCase())||String(t.value).toLowerCase().includes(r.toLowerCase()));return(0,c.jsxs)("div",{className:"flex items-center gap-2 py-1 px-2 rounded ".concat(o?"bg-yellow-100 dark:bg-yellow-900/30":""),style:{marginLeft:"".concat(16*t.level,"px")},children:[s?(0,c.jsx)(tr,{variant:"ghost",size:"sm",onClick:i,className:"h-6 w-6 p-0",children:n?(0,c.jsx)(ix,{className:"h-3 w-3"}):(0,c.jsx)(ib,{className:"h-3 w-3"})}):(0,c.jsx)("div",{className:"w-6"}),(0,c.jsxs)("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat((e=>{switch(e){case"string":return"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200";case"number":return"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200";case"boolean":return"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200";case"array":return"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200";case"object":return"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200";default:return"bg-gray-100 text-gray-800 dark:bg-gray-900 dark:text-gray-200"}})(t.type)," flex items-center gap-1"),children:[(e=>{switch(e){case"string":return(0,c.jsx)(gR,{className:"h-3 w-3"});case"number":return(0,c.jsx)(gP,{className:"h-3 w-3"});case"boolean":return(0,c.jsx)(gL,{className:"h-3 w-3"});case"array":return(0,c.jsx)(gI,{className:"h-3 w-3"});default:return(0,c.jsx)(tp,{className:"h-3 w-3"})}})(t.type),t.type]}),(0,c.jsxs)("span",{className:"font-mono text-sm text-muted-foreground",children:[t.path[t.path.length-1]||"root",":"]}),(0,c.jsx)("div",{className:"flex-1 min-w-0",children:((e,t)=>{switch(t){case"string":return(0,c.jsxs)("span",{className:"text-green-600 dark:text-green-400 font-mono",children:['"',String(e),'"']});case"number":return(0,c.jsx)("span",{className:"text-blue-600 dark:text-blue-400 font-mono",children:Number(e)});case"boolean":return(0,c.jsx)("span",{className:"text-purple-600 dark:text-purple-400 font-mono",children:String(e)});case"null":return(0,c.jsx)("span",{className:"text-gray-500 dark:text-gray-400 font-mono italic",children:"null"});case"array":let n=Array.isArray(e)?e.length:0;return(0,c.jsxs)("span",{className:"text-orange-600 dark:text-orange-400 font-mono",children:["Array(",n,")"]});case"object":let i="object"==typeof e&&null!==e?Object.keys(e).length:0;return(0,c.jsxs)("span",{className:"text-red-600 dark:text-red-400 font-mono",children:["Object(",i,")"]});default:return(0,c.jsx)("span",{children:String(e)})}})(t.value,t.type)}),(0,c.jsx)(tr,{variant:"ghost",size:"sm",onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t.value,null,2)),iv.default.success("필드가 클립보드에 복사되었습니다")}catch(n){console.log("Failed to copy field to clipboard:",n);let e=document.createElement("textarea");e.value=JSON.stringify(t.value,null,2),document.body.appendChild(e),e.select();try{document.execCommand("copy"),iv.default.success("필드가 클립보드에 복사되었습니다")}catch(e){console.log("Field fallback copy failed:",e),iv.default.error("클립보드 복사에 실패했습니다")}document.body.removeChild(e)}},className:"h-6 w-6 p-0 opacity-50 hover:opacity-100",children:(0,c.jsx)(iS,{className:"h-3 w-3"})})]})]})}function vf(e){return!(!e||"object"!=typeof e||Array.isArray(e))&&(!!Array.isArray(e.output)||!!(e.data&&"object"==typeof e.data&&null!==e.data&&Array.isArray(e.data.output)))}function vp(e){let{data:t}=e,n=Array.isArray(t.output)?t:t.data||t,i=n.output&&Array.isArray(n.output)?n.output:[],[r,s]=(0,d.useState)(new Set(i.map((e,t)=>t)));return(0,c.jsxs)("div",{className:"space-y-4",children:[n.usage&&"object"==typeof n.usage?(0,c.jsxs)("div",{className:"p-4 bg-muted/30 rounded-lg space-y-4",children:[(0,c.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-blue-600",children:Number(n.usage.input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"입력 토큰"})]}),(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-green-600",children:Number(n.usage.output_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"출력 토큰"})]}),(0,c.jsxs)("div",{className:"text-center",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-gray-600",children:Number(n.usage.total_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"총 토큰"})]})]}),(n.usage.cache_creation_input_tokens||n.usage.cache_read_input_tokens)&&("anthropic"===n.provider||"anthropic"===t.provider||"zai"===n.provider||"zai"===t.provider)?(0,c.jsxs)("div",{className:"grid grid-cols-2 gap-4 pt-4 border-t",children:[(0,c.jsxs)("div",{className:"text-center p-3 bg-purple-50 dark:bg-purple-950/20 rounded-lg border border-purple-200 dark:border-purple-800",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-purple-600 dark:text-purple-400",children:Number(n.usage.cache_creation_input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-purple-700 dark:text-purple-300",children:"캐시 생성 토큰"}),(0,c.jsx)("div",{className:"text-xs text-purple-600 dark:text-purple-400 mt-1",children:"Cache Write"})]}),(0,c.jsxs)("div",{className:"text-center p-3 bg-orange-50 dark:bg-orange-950/20 rounded-lg border border-orange-200 dark:border-orange-800",children:[(0,c.jsx)("div",{className:"text-lg font-bold text-orange-600 dark:text-orange-400",children:Number(n.usage.cache_read_input_tokens||0).toLocaleString()}),(0,c.jsx)("div",{className:"text-xs text-orange-700 dark:text-orange-300",children:"캐시 읽기 토큰"}),(0,c.jsx)("div",{className:"text-xs text-orange-600 dark:text-orange-400 mt-1",children:"Cache Hit (90% 절약)"})]})]}):null]}):null,n.output&&Array.isArray(n.output)&&n.output.length>0?(0,c.jsxs)("div",{className:"bg-gradient-to-r from-blue-50 to-purple-50 dark:from-blue-950/20 dark:to-purple-950/20 p-4 rounded-lg border border-blue-200 dark:border-blue-800",children:[(0,c.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-10 h-10 bg-gradient-to-r from-blue-500 to-purple-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white font-bold",children:"🚀"})}),(0,c.jsxs)("div",{children:[(0,c.jsx)("h4",{className:"font-semibold text-gray-900 dark:text-gray-100",children:"AI 실행 과정"}),(0,c.jsxs)("p",{className:"text-xs text-muted-foreground",children:["총 ",n.output.length,"단계의 처리 과정을 확인할 수 있습니다"]})]})]}),(0,c.jsx)("div",{className:"space-y-3",children:n.output.map((e,t)=>((e,t)=>{let n=r.has(t),i=String(e.type||"unknown");return(0,c.jsxs)("div",{className:"border rounded-lg overflow-hidden ".concat((e=>{switch(e){case"reasoning":return"bg-purple-50 dark:bg-purple-950/20 border-purple-200 dark:border-purple-800";case"function_call":return"bg-blue-50 dark:bg-blue-950/20 border-blue-200 dark:border-blue-800";case"function_call_output":return"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800";case"message":return"bg-gray-50 dark:bg-gray-950/20 border-gray-200 dark:border-gray-800";default:return"bg-muted/30 border-muted"}})(i)),children:[(0,c.jsxs)("div",{className:"flex items-center justify-between p-4 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>(e=>{let t=new Set(r);t.has(e)?t.delete(e):t.add(e),s(t)})(t),children:[(0,c.jsxs)("div",{className:"flex items-center gap-3",children:[(0,c.jsx)("span",{className:"text-lg",children:(e=>{switch(e){case"reasoning":return"🧠";case"function_call":return"🔧";case"function_call_output":return"✅";case"message":return"💬";default:return"📄"}})(i)}),(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"font-medium text-sm",children:(e=>{switch(e){case"reasoning":return"사고 과정";case"function_call":return"도구 사용";case"function_call_output":return"실행 결과";case"message":return"응답";default:return"기타"}})(i)}),e.name?(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:String(e.name)}):null]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[e.status?(0,c.jsx)(to,{variant:"completed"===e.status?"default":"destructive",className:"text-xs",children:String(e.status)}):null,n?(0,c.jsx)(ix,{className:"h-4 w-4"}):(0,c.jsx)(ib,{className:"h-4 w-4"})]})]}),n&&(0,c.jsxs)("div",{className:"px-4 pb-4",children:["reasoning"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,c.jsx)("div",{className:"w-2 h-2 bg-purple-500 rounded-full"}),(0,c.jsx)("span",{className:"text-sm font-medium text-purple-900 dark:text-purple-100",children:"AI 추론 과정"})]}),(0,c.jsx)("div",{className:"text-sm text-purple-800 dark:text-purple-200 leading-relaxed",children:(()=>{if(e.summary)if(Array.isArray(e.summary))return e.summary.map(e=>"object"==typeof e&&null!==e?e.text||JSON.stringify(e):String(e)).join(" ");else if("object"==typeof e.summary)return JSON.stringify(e.summary,null,2);else return String(e.summary);if(e.content)if(Array.isArray(e.content))return e.content.map(e=>"object"==typeof e&&null!==e?e.text||JSON.stringify(e):String(e)).join(" ");else if("object"==typeof e.content)return JSON.stringify(e.content,null,2);else return String(e.content);return e.text?String(e.text):JSON.stringify(e,null,2)})()})]}),"function_call"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-blue-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"🔧"})}),(0,c.jsxs)("div",{className:"flex-1",children:[(0,c.jsxs)("div",{className:"font-medium text-blue-900 dark:text-blue-100",children:[String(e.name||"unknown")," 도구 호출"]}),(0,c.jsxs)("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[(0,c.jsx)("span",{children:"도구 호출됨"}),e.call_id?(0,c.jsxs)("span",{className:"bg-blue-100 dark:bg-blue-900 px-2 py-0.5 rounded text-xs font-mono",children:[String(e.call_id).substring(0,12),"..."]}):null]})]}),e.status?(0,c.jsx)("span",{className:"px-2 py-1 text-xs rounded ".concat("completed"===e.status?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"),children:String(e.status)}):null]}),e.arguments?(0,c.jsxs)("div",{className:"bg-blue-50/50 dark:bg-blue-950/30 p-2 rounded border border-blue-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-blue-800 dark:text-blue-200 mb-1",children:"📋 입력 매개변수:"}),(0,c.jsx)("pre",{className:"text-xs text-blue-700 dark:text-blue-300 overflow-auto max-h-32 bg-white/50 dark:bg-gray-800/50 p-2 rounded",children:(()=>{try{return JSON.stringify(JSON.parse(String(e.arguments)),null,2)}catch(t){return String(e.arguments)}})()})]}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"매개변수 없음"})]}),"function_call_output"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-green-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"✅"})}),(0,c.jsxs)("div",{className:"flex-1",children:[(0,c.jsx)("div",{className:"font-medium text-green-900 dark:text-green-100",children:"도구 실행 완료"}),(0,c.jsxs)("div",{className:"text-xs text-muted-foreground flex items-center gap-2",children:[(0,c.jsx)("span",{children:"실행 결과 반환됨"}),e.call_id?(0,c.jsxs)("span",{className:"bg-green-100 dark:bg-green-900 px-2 py-0.5 rounded text-xs font-mono",children:[String(e.call_id).substring(0,12),"..."]}):null]})]})]}),e.output?(0,c.jsxs)("div",{className:"bg-green-50/50 dark:bg-green-950/30 p-2 rounded border border-green-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-green-800 dark:text-green-200 mb-1",children:"📊 실행 결과:"}),(0,c.jsx)("div",{className:"bg-white/70 dark:bg-gray-800/70 p-2 rounded border",children:(()=>{try{let t=JSON.parse(String(e.output));if(t.tool&&t.stdout)return(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)("span",{className:"text-xs font-medium text-green-700 dark:text-green-300",children:"도구:"}),(0,c.jsx)("code",{className:"text-xs bg-green-100 dark:bg-green-900 px-1 py-0.5 rounded",children:t.tool}),(0,c.jsx)("span",{className:"text-xs font-medium text-green-700 dark:text-green-300",children:"상태:"}),(0,c.jsx)("span",{className:"text-xs px-1 py-0.5 rounded ".concat(0===t.exit_code?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"),children:0===t.exit_code?"성공":"실패"})]}),t.stdout&&(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"text-xs font-medium text-green-700 dark:text-green-300 mb-1",children:"출력:"}),(0,c.jsx)("pre",{className:"text-xs text-green-600 dark:text-green-400 whitespace-pre-wrap bg-gray-50 dark:bg-gray-800 p-2 rounded",children:t.stdout})]}),t.stderr&&(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"text-xs font-medium text-red-700 dark:text-red-300 mb-1",children:"오류:"}),(0,c.jsx)("pre",{className:"text-xs text-red-600 dark:text-red-400 whitespace-pre-wrap bg-red-50 dark:bg-red-900/20 p-2 rounded",children:t.stderr})]})]});return(0,c.jsx)("pre",{className:"text-xs text-green-700 dark:text-green-300 overflow-auto max-h-40 leading-relaxed",children:JSON.stringify(t,null,2)})}catch(t){return(0,c.jsx)("pre",{className:"text-xs text-green-700 dark:text-green-300 overflow-auto max-h-40 leading-relaxed whitespace-pre-wrap",children:String(e.output)})}})()})]}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"결과 없음"})]}),"message"===e.type&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,c.jsx)("div",{className:"flex items-center justify-center w-8 h-8 bg-indigo-500 rounded-full",children:(0,c.jsx)("span",{className:"text-white text-sm",children:"💬"})}),(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"font-medium text-indigo-900 dark:text-indigo-100",children:"최종 응답"}),(0,c.jsx)("div",{className:"text-xs text-muted-foreground",children:"assistant"===e.role?"AI 어시스턴트 응답":"".concat(String(e.role)," 메시지")})]})]}),e.content&&Array.isArray(e.content)?(0,c.jsx)("div",{className:"space-y-2",children:e.content.map((e,t)=>(0,c.jsx)("div",{children:"output_text"===e.type&&(0,c.jsxs)("div",{className:"bg-indigo-50/50 dark:bg-indigo-950/30 p-3 rounded border border-indigo-200/50",children:[(0,c.jsx)("div",{className:"text-xs font-medium text-indigo-800 dark:text-indigo-200 mb-2",children:"💭 응답 내용:"}),(()=>{let t=String(e.text||"");try{let e=JSON.parse(t);return(0,c.jsx)("div",{className:"bg-white/70 dark:bg-gray-800/70 rounded border",children:(0,c.jsx)(iA,{data:e,onChange:()=>{},expandAllByDefault:!0,className:"text-sm"})})}catch(e){return(0,c.jsx)("div",{className:"text-sm text-indigo-900 dark:text-indigo-100 whitespace-pre-wrap leading-relaxed",children:t})}})()]})},t))}):(0,c.jsx)("div",{className:"text-xs text-muted-foreground italic",children:"메시지 내용 없음"})]}),!["reasoning","function_call","function_call_output","message"].includes(String(e.type))&&(0,c.jsxs)("div",{className:"bg-white/60 dark:bg-gray-900/60 p-3 rounded border",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,c.jsx)("span",{className:"text-lg",children:"📄"}),(0,c.jsxs)("div",{className:"font-medium text-sm",children:["알 수 없는 타입: ",String(e.type)]})]}),(0,c.jsx)("div",{className:"bg-gray-50/50 dark:bg-gray-950/30 p-2 rounded border",children:(0,c.jsx)("pre",{className:"text-xs text-gray-700 dark:text-gray-300 overflow-auto max-h-40",children:JSON.stringify(e,null,2)})})]})]})]},t)})(e,t))})]}):null]})}function vm(e){let{data:t,className:n=""}=e,[i,r]=(0,d.useState)([]),[s,o]=(0,d.useState)(new Set),[l,a]=(0,d.useState)(""),[h,u]=(0,d.useState)([]);(0,d.useEffect)(()=>{if(t){let e=function e(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=[];return null===t?[{key:n.join(".")||"root",value:null,type:"null",path:n,level:i}]:(Array.isArray(t)?t.forEach((t,s)=>{let o=[...n,"[".concat(s,"]")];r.push({key:o.join("."),value:t,type:vd(t),path:o,level:i}),"object"==typeof t&&null!==t&&r.push(...e(t,o,i+1))}):"object"==typeof t?Object.entries(t).forEach(t=>{let[s,o]=t,l=[...n,s];r.push({key:l.join("."),value:o,type:vd(o),path:l,level:i}),"object"==typeof o&&null!==o&&r.push(...e(o,l,i+1))}):r.push({key:n.join(".")||"root",value:t,type:vd(t),path:n,level:i}),r)}(t);r(e),o(new Set(e.filter(e=>"object"===e.type||"array"===e.type).map(e=>e.key)))}},[t]),(0,d.useEffect)(()=>{l?u(i.filter(e=>e.key.toLowerCase().includes(l.toLowerCase())||String(e.value).toLowerCase().includes(l.toLowerCase()))):u(i)},[i,l]);let f=async()=>{try{await navigator.clipboard.writeText(JSON.stringify(t,null,2)),iv.default.success("JSON이 클립보드에 복사되었습니다")}catch(n){console.log("Failed to copy to clipboard:",n);let e=document.createElement("textarea");e.value=JSON.stringify(t,null,2),document.body.appendChild(e),e.select();try{document.execCommand("copy"),iv.default.success("JSON이 클립보드에 복사되었습니다")}catch(e){console.log("Fallback copy failed:",e),iv.default.error("클립보드 복사에 실패했습니다")}document.body.removeChild(e)}},p=()=>{let e=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download="response.json",i.click(),URL.revokeObjectURL(n)};if(!t)return(0,c.jsx)(tw,{className:"h-full ".concat(n),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(vh,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"No response data to display"})]})})});let m=vf(t)||t&&"object"==typeof t&&!Array.isArray(t)&&t.data&&"object"==typeof t.data&&Array.isArray(t.data.output);return(console.log("Final decision:",{isAIAgent:vf(t),shouldShow:m,hasDataOutput:!!((null==t?void 0:t.data)&&"object"==typeof t.data&&t.data.output)}),m)?(0,c.jsx)("div",{className:"h-full flex flex-col ".concat(n),children:(0,c.jsxs)("div",{className:"h-full p-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsx)("div",{children:(0,c.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-5 w-5"}),"AI Agent Response"]})}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:f,children:[(0,c.jsx)(iS,{className:"h-4 w-4 mr-1"}),"Copy"]}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:p,children:[(0,c.jsx)(tg,{className:"h-4 w-4 mr-1"}),"Download"]})]})]}),(0,c.jsxs)(g6,{defaultValue:"structured",className:"h-full flex flex-col",children:[(0,c.jsxs)(vo,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[(0,c.jsxs)(vl,{value:"structured",className:"flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-4 w-4"}),"구조화된 뷰"]}),(0,c.jsxs)(vl,{value:"tree",className:"flex items-center gap-2",children:[(0,c.jsx)(gI,{className:"h-4 w-4"}),"트리 뷰"]})]}),(0,c.jsx)(va,{value:"structured",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"pr-4",children:(0,c.jsx)(vp,{data:t})})})}),(0,c.jsx)(va,{value:"tree",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(iA,{data:t,onChange:()=>{},expandAllByDefault:!0})})]})]})}):(0,c.jsx)("div",{className:"h-full flex flex-col ".concat(n),children:(0,c.jsxs)("div",{className:"h-full p-6",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,c.jsx)("div",{children:(0,c.jsxs)("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(vh,{className:"h-5 w-5"}),"Response Viewer"]})}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{o(new Set(i.filter(e=>"object"===e.type||"array"===e.type).map(e=>e.key)))},children:"Expand All"}),(0,c.jsx)(tr,{variant:"outline",size:"sm",onClick:()=>{o(new Set)},children:"Collapse All"}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:f,children:[(0,c.jsx)(iS,{className:"h-4 w-4 mr-1"}),"Copy"]}),(0,c.jsxs)(tr,{variant:"outline",size:"sm",onClick:p,children:[(0,c.jsx)(tg,{className:"h-4 w-4 mr-1"}),"Download"]})]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,c.jsx)(vc,{className:"h-4 w-4 text-muted-foreground"}),(0,c.jsx)(iC,{placeholder:"Search fields and values...",value:l,onChange:e=>a(e.target.value),className:"flex-1"})]}),(0,c.jsxs)(g6,{defaultValue:"tree",className:"h-full flex flex-col",children:[(0,c.jsxs)(vo,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[(0,c.jsxs)(vl,{value:"tree",className:"flex items-center gap-2",children:[(0,c.jsx)(gI,{className:"h-4 w-4"}),"Tree View"]}),(0,c.jsxs)(vl,{value:"raw",className:"flex items-center gap-2",children:[(0,c.jsx)(ip,{className:"h-4 w-4"}),"Raw JSON"]})]}),(0,c.jsx)(va,{value:"tree",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-1 pr-4",children:h.filter(e=>{if(0===e.level)return!0;let t=e.path.slice(0,-1).join(".");return s.has(t)}).map(e=>(0,c.jsx)(vu,{field:e,expanded:s.has(e.key),onToggle:()=>(e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),o(t)})(e.key),searchTerm:l},e.key))})})}),(0,c.jsx)(va,{value:"raw",className:"flex-1 min-h-0 mt-4",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"bg-muted p-4 rounded-lg mr-4",children:(0,c.jsx)("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:JSON.stringify(t,null,2)})})})})]})]})})}let vg=td("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]),vv=td("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]),vx=td("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]),vb=td("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);function vy(e){return Array.isArray(e)&&e.length>0&&"object"==typeof e[0]&&null!==e[0]&&("role"in e[0]&&"content"in e[0]||"type"in e[0]&&("function_call"===e[0].type||"function_call_output"===e[0].type||"reasoning"===e[0].type))}function vw(e){let{data:t,onChange:n,className:i=""}=e,[r,s]=(0,d.useState)([]),o=e=>"function_call"===e.type||"reasoning"===e.type||"function_call_output"===e.type;(0,d.useEffect)(()=>{vy(t)?s(t.map(e=>"content"in e?{...e,content:Array.isArray(e.content)?e.content:[]}:e)):s([])},[t]);let l=(e,t,i,o)=>{let l=[...r];Array.isArray(l[e].content)||(l[e].content=[]);let a=l[e].content[t];a&&("type"===i?a.type=o:"text"===i&&(a.text=o)),s(l),n(l)},a=(e,t,i)=>{let o=[...r];o[e][t]=i,s(o),n(o)};return vy(t)?(0,c.jsxs)(tw,{className:"h-full ".concat(i),children:[(0,c.jsxs)(tk,{children:[(0,c.jsxs)(tS,{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsx)(vv,{className:"h-5 w-5"}),"Input 메시지 편집기"]}),(0,c.jsxs)(tr,{size:"sm",onClick:()=>{let e=[...r,{role:"user",content:[{type:"input_text",text:""}]}];s(e),n(e)},children:[(0,c.jsx)(iw,{className:"h-4 w-4 mr-2"}),"메시지 추가"]})]}),(0,c.jsxs)(tC,{children:["대화 메시지와 함수 호출을 편집합니다 (",r.length,"개 메시지)"]})]}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)("div",{className:"space-y-6",children:r.map((e,t)=>(0,c.jsx)(gh,{type:"single",collapsible:!0,defaultValue:"system"===e.role?void 0:"message-".concat(t),children:(0,c.jsxs)(gE,{value:"message-".concat(t),className:"border-2 rounded-lg bg-card/50 shadow-sm",children:[(0,c.jsx)(gT,{className:"text-sm font-medium hover:no-underline px-4 py-3 bg-muted/30 rounded-t-lg",children:(0,c.jsxs)("div",{className:"flex items-center gap-2 w-full",children:[(0,c.jsxs)(to,{variant:"secondary",className:"text-xs ".concat(function(e){switch(e.role){case"system":return"bg-purple-50 text-purple-700 dark:bg-purple-800 dark:text-purple-100";case"user":return"bg-blue-50 text-blue-700 dark:bg-blue-800 dark:text-blue-100";case"assistant":return"bg-green-50 text-green-700 dark:bg-green-800 dark:text-green-100";default:if("reasoning"===e.type)return"bg-orange-50 text-orange-700 dark:bg-orange-800 dark:text-orange-100";if("function_call"===e.type)return"bg-red-50 text-red-700 dark:bg-red-800 dark:text-red-100";return e.type,"bg-gray-50 text-gray-700 dark:bg-gray-800 dark:text-gray-100"}}(e)),children:[function(e){switch(e.role){case"system":return(0,c.jsx)(tv,{className:"h-4 w-4"});case"user":return(0,c.jsx)(vx,{className:"h-4 w-4"});case"assistant":return(0,c.jsx)(vb,{className:"h-4 w-4"});default:if("reasoning"===e.type)return(0,c.jsx)(gP,{className:"h-4 w-4"});if("function_call"===e.type)return(0,c.jsx)(tv,{className:"h-4 w-4"});if("function_call_output"===e.type)return(0,c.jsx)(tp,{className:"h-4 w-4"});return(0,c.jsx)(vv,{className:"h-4 w-4"})}}(e),String(e.role||e.type||"Unknown")]}),(0,c.jsx)("span",{className:"text-muted-foreground text-xs flex-1 text-left",children:"system"===e.role||"user"===e.role||"assistant"===e.role?"".concat(Array.isArray(e.content)?e.content.length:0," content items"):"function_call_output"===e.type?String(e.call_id||"Function Call Output"):String(e.name||e.id||"Message ".concat(t+1))}),(0,c.jsx)(tr,{size:"sm",variant:"ghost",onClick:e=>{e.stopPropagation();let i=r.filter((e,n)=>n!==t);s(i),n(i)},className:"h-6 w-6 p-0",disabled:o(e),children:(0,c.jsx)(vg,{className:"h-3 w-3"})})]})}),(0,c.jsx)(gD,{children:(0,c.jsxs)("div",{className:"space-y-4 pt-2 px-4 pb-4 bg-background/50 rounded-b-lg",children:[(0,c.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[void 0!==e.role&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"role-".concat(t),children:"Role"}),(0,c.jsx)(iC,{id:"role-".concat(t),value:String(e.role||""),onChange:e=>a(t,"role",e.target.value),className:"font-mono text-xs",placeholder:"system, user, assistant",readOnly:o(e)})]}),void 0!==e.id&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"id-".concat(t),children:"ID"}),(0,c.jsx)(iC,{id:"id-".concat(t),value:String(e.id||""),onChange:e=>a(t,"id",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.type&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"type-".concat(t),children:"Type"}),(0,c.jsx)(iC,{id:"type-".concat(t),value:String(e.type||""),onChange:e=>a(t,"type",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.status&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"status-".concat(t),children:"Status"}),(0,c.jsx)(iC,{id:"status-".concat(t),value:String(e.status||""),onChange:e=>a(t,"status",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.arguments&&(0,c.jsxs)("div",{className:"space-y-2 col-span-2",children:[(0,c.jsx)(iO,{htmlFor:"args-".concat(t),children:"Arguments"}),(0,c.jsx)(mW,{id:"args-".concat(t),value:String(e.arguments||""),onChange:e=>a(t,"arguments",e),language:"json",readOnly:o(e)})]}),void 0!==e.call_id&&"function_call_output"!==e.type&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"call_id-".concat(t),children:"Call ID"}),(0,c.jsx)(iC,{id:"call_id-".concat(t),value:String(e.call_id||""),onChange:e=>a(t,"call_id",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.name&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{htmlFor:"name-".concat(t),children:"Name"}),(0,c.jsx)(iC,{id:"name-".concat(t),value:String(e.name||""),onChange:e=>a(t,"name",e.target.value),className:"font-mono text-xs",readOnly:o(e)})]}),void 0!==e.output&&(0,c.jsxs)("div",{className:"space-y-2 col-span-2",children:[(0,c.jsx)(iO,{htmlFor:"output-".concat(t),children:"Output"}),(0,c.jsx)(mW,{id:"output-".concat(t),value:String(e.output||""),onChange:e=>a(t,"output",e),language:"json",readOnly:o(e)})]})]}),(0,c.jsx)(mK,{}),e.role&&("system"===e.role||"user"===e.role||"assistant"===e.role)&&(0,c.jsxs)("div",{className:"space-y-3",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)(iO,{children:["Content (",Array.isArray(e.content)?e.content.length:0," items)"]}),(0,c.jsxs)(tr,{size:"sm",variant:"outline",onClick:()=>(e=>{let t=[...r];Array.isArray(t[e].content)||(t[e].content=[]),t[e].content.push({type:"input_text",text:""}),s(t),n(t)})(t),disabled:o(e),children:[(0,c.jsx)(iw,{className:"h-3 w-3 mr-1"}),"Add Content"]})]}),Array.isArray(e.content)?e.content.map((i,a)=>(0,c.jsxs)("div",{className:"border-2 border-dashed border-muted-foreground/30 rounded-lg p-4 space-y-3 bg-muted/20",children:[(0,c.jsxs)("div",{className:"flex items-center justify-between",children:[(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)(to,{variant:"outline",className:"text-xs font-medium bg-primary/10 text-primary border-primary/20",children:["Content ",a+1]}),(0,c.jsx)(iC,{value:String(i.type||""),onChange:e=>l(t,a,"type",e.target.value),className:"w-40 h-8 font-mono text-xs",placeholder:"input_text, text, image",readOnly:o(e)})]}),(0,c.jsx)(tr,{size:"sm",variant:"ghost",onClick:()=>((e,t)=>{let i=[...r];Array.isArray(i[e].content)&&(i[e].content=i[e].content.filter((e,n)=>n!==t)),s(i),n(i)})(t,a),className:"h-6 w-6 p-0",disabled:o(e),children:(0,c.jsx)(vg,{className:"h-3 w-3"})})]}),void 0!==i.text&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{children:"Text Content"}),(i.text||"").length>100?(0,c.jsx)(mW,{value:String(i.text||""),onChange:e=>l(t,a,"text",e),language:"text",readOnly:o(e)}):(0,c.jsx)(iC,{value:String(i.text||""),onChange:e=>l(t,a,"text",e.target.value),placeholder:"Enter text content...",readOnly:o(e)})]})]},a)):null]}),void 0!==e.summary&&(0,c.jsxs)("div",{className:"space-y-2",children:[(0,c.jsx)(iO,{children:"Summary"}),(0,c.jsx)(mW,{value:JSON.stringify(e.summary,null,2),onChange:e=>{try{let i=JSON.parse(e),o=[...r];o[t].summary=i,s(o),n(o)}catch(e){}},language:"json",readOnly:o(e)})]}),(0,c.jsx)(mK,{className:"my-4"})]})})]})},t))})})})]}):(0,c.jsx)(tw,{className:"h-full ".concat(i),children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(vv,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"Input 배열 형식이 아닙니다"})]})})})}let vk=(0,ig.default)(()=>e.A(53096),{loadableGenerated:{modules:[67211]},ssr:!1});function vS(e){var t,n;let{selectedFile:i,onFileUpdate:r}=e,[s,o]=(0,d.useState)(""),[l,a]=(0,d.useState)(null),[h,u]=(0,d.useState)("form"),[f,p]=(0,d.useState)({}),[m,g]=(0,d.useState)(new Set),v=d.useRef({}),[x,b]=(0,d.useState)(!1),[y,w]=(0,d.useState)(!1),[k,S]=(0,d.useState)(null),[C,A]=(0,d.useState)(!1),[N,M]=(0,d.useState)("editor"),[O,j]=(0,d.useState)("openai"),E=(0,d.useRef)(null),T=(0,d.useRef)(null),[D,R]=(0,d.useState)(0),P=d.useCallback(e=>{let t=Math.max(e+10,100);Math.abs(t-D)>1&&(R(t),E.current&&(E.current.style.height="".concat(t,"px")),T.current&&requestAnimationFrame(()=>{var e;null==(e=T.current)||e.layout()}))},[D]),L=d.useCallback(e=>{if(T.current&&T.current!==e){let e=T.current._heightSubscription;e&&e.dispose()}T.current=e;let t=e.onDidContentSizeChange(e=>{P(e.contentHeight)}),n=T.current;n&&(n._heightSubscription=t),setTimeout(()=>{let t=e.getDomNode();t&&t.addEventListener("wheel",e=>{var t;let n=null==(t=E.current)?void 0:t.parentElement;for(;n;){if(n.hasAttribute("data-radix-scroll-area-viewport")||n.querySelector("[data-radix-scroll-area-viewport]")){let t=n.hasAttribute("data-radix-scroll-area-viewport")?n:n.querySelector("[data-radix-scroll-area-viewport]");if(t){t.scrollTop+=e.deltaY,e.preventDefault(),e.stopPropagation();break}}n=n.parentElement}},{passive:!1,capture:!0}),P(e.getContentHeight()),e.layout()},100)},[P]),I=d.useCallback(e=>{let t=e.currentTarget.parentElement;for(;t;){if(t.hasAttribute("data-radix-scroll-area-viewport")||t.classList.contains("scroll-area")||t.querySelector("[data-radix-scroll-area-viewport]")){let n=t.hasAttribute("data-radix-scroll-area-viewport")?t:t.querySelector("[data-radix-scroll-area-viewport]");if(n){let t=n.scrollTop,i=e.deltaY;n.scrollTo({top:t+i,behavior:"auto"}),e.preventDefault();break}}t=t.parentElement}},[]);(0,d.useEffect)(()=>()=>{if(T.current){let e=T.current._heightSubscription;e&&e.dispose()}},[]);let B=d.useCallback(e=>{let t=v.current[e];if(t){let n=t.querySelector("[data-radix-scroll-area-viewport]");n&&p(t=>({...t,[e]:n.scrollTop}))}},[]),z=d.useCallback(e=>{let t=v.current[e],n=f[e];if(t&&"number"==typeof n){let e=t.querySelector("[data-radix-scroll-area-viewport]");e&&setTimeout(()=>{e.scrollTop=n},10)}},[f]),F=d.useCallback(e=>{"result"===N&&M("editor"),B(h),u(e),setTimeout(()=>{z(e),"code"===e&&T.current&&setTimeout(()=>{var e;null==(e=T.current)||e.layout()},50)},50)},[h,N,B,z]),_=d.useCallback(async()=>{if(i)try{b(!0);let e=await il("/api/logs/".concat(encodeURIComponent(i.name)));if(!e.ok)throw Error("Failed to load file");let t=await e.json(),n=t.data||t;o(JSON.stringify(n,null,2)),a(n);let r="openai";if(t.provider)r=t.provider;else if(n.provider)r=n.provider;else{let e="messages"in n&&Array.isArray(n.messages),t="input"in n&&Array.isArray(n.input),i="output"in n&&Array.isArray(n.output),s="max_tokens"in n,o="content"in n&&Array.isArray(n.content),l=n.model||"";l.startsWith("glm-")?r="zai":e||s||o||l.startsWith("claude-")?r="anthropic":(t||i||l.startsWith("gpt-")||l.startsWith("o1-"))&&(r="openai")}j(r)}catch(e){iv.default.error("파일 로드 실패")}finally{b(!1)}},[i]);(0,d.useEffect)(()=>{var e,t;i&&((null==(e=i.parsedInfo)?void 0:e.type)==="REQ"||(null==(t=i.parsedInfo)?void 0:t.type)==="RES")?(R(100),E.current&&(E.current.style.height="100px"),S(null),M("editor"),_()):(o(""),a(null),R(100),E.current&&(E.current.style.height="100px"),S(null),M("editor"))},[i,_]);let W=e=>{try{return JSON.parse(e),!0}catch(e){return!1}},V=e=>{a(e),o(JSON.stringify(e,null,2))},H=async()=>{if(!i||!W(s))return void iv.default.error("유효하지 않은 JSON 형식입니다");try{(await il("/api/logs/".concat(encodeURIComponent(i.name)),{method:"PUT",headers:{"Content-Type":"application/json"},body:s})).ok?(iv.default.success("파일이 저장되었습니다"),r()):iv.default.error("저장 실패")}catch(e){iv.default.error("저장 중 오류가 발생했습니다")}},q=async()=>{if(!W(s))return void iv.default.error("유효하지 않은 JSON 형식입니다");try{w(!0);let e=Date.now(),t=await il("anthropic"===O?"/api/test-anthropic":"zai"===O?"/api/test-zai":"/api/test-openai",{method:"POST",headers:{"Content-Type":"application/json"},body:s}),n=await t.json(),i=Date.now()-e;S({success:t.ok,response:n,error:t.ok?void 0:n.error,executionTime:i}),M("result"),t.ok?(iv.default.success("".concat("anthropic"===O?"Anthropic":"zai"===O?"Z.AI (GLM)":"OpenAI"," 요청이 성공적으로 실행되었습니다")),r()):iv.default.error("요청 실행 실패")}catch(e){S({success:!1,error:e instanceof Error?e.message:"알 수 없는 오류"}),M("result"),iv.default.error("실행 중 오류가 발생했습니다")}finally{w(!1),A(!1)}};return i?(null==(t=i.parsedInfo)?void 0:t.type)==="RES"?(0,c.jsx)("div",{className:"h-full flex flex-col",children:x?(0,c.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,c.jsx)(id,{className:"h-6 w-6 animate-spin"})}):(0,c.jsx)(vm,{data:l,className:"h-full"})}):(null==(n=i.parsedInfo)?void 0:n.type)!=="REQ"?(0,c.jsx)(tw,{className:"h-full",children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(tf,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{className:"text-lg",children:"지원하지 않는 파일 타입입니다"}),(0,c.jsx)("p",{className:"text-sm",children:"REQ 또는 RES 파일만 지원됩니다"})]})})}):(0,c.jsxs)(tw,{className:"h-full flex flex-col !border-none !rounded-none",children:[(0,c.jsx)(tk,{className:"flex-shrink-0",children:(0,c.jsxs)(tS,{className:"flex items-center justify-between",children:[(0,c.jsxs)("span",{className:"flex items-center gap-2",children:[(0,c.jsx)(ia,{className:"h-5 w-5"}),"요청 편집기: ",i.name]}),(0,c.jsxs)("div",{className:"flex items-center gap-4",children:[(0,c.jsxs)("div",{className:"flex items-center bg-muted rounded-lg p-1",children:[(0,c.jsxs)(tr,{variant:"form"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("form"),className:"h-8",children:[(0,c.jsx)(im,{className:"h-4 w-4 mr-1"}),"폼"]}),(0,c.jsxs)(tr,{variant:"code"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("code"),className:"h-8",children:[(0,c.jsx)(ip,{className:"h-4 w-4 mr-1"}),"코드"]}),(0,c.jsxs)(tr,{variant:"tree"===h&&"editor"===N?"default":"ghost",size:"sm",onClick:()=>F("tree"),className:"h-8",children:[(0,c.jsx)(iu,{className:"h-4 w-4 mr-1"}),"트리"]}),k&&(0,c.jsxs)(tr,{variant:"result"===N?"default":"ghost",size:"sm",onClick:()=>M("result"),className:"h-8",children:[(0,c.jsx)(tx,{className:"h-4 w-4 mr-1"}),"실행결과"]})]}),(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[(0,c.jsxs)("div",{className:"hidden flex items-center gap-1 mr-2 px-2 py-1 border rounded-md bg-muted/30",children:[(0,c.jsx)(tr,{size:"sm",variant:"openai"===O?"default":"ghost",onClick:()=>j("openai"),className:"h-6 px-2",children:"OpenAI"}),(0,c.jsx)(tr,{size:"sm",variant:"anthropic"===O?"default":"ghost",onClick:()=>j("anthropic"),className:"h-6 px-2",children:"Anthropic"}),(0,c.jsx)(tr,{size:"sm",variant:"zai"===O?"default":"ghost",onClick:()=>j("zai"),className:"h-6 px-2",children:"Z.AI"})]}),(0,c.jsxs)(tr,{onClick:H,variant:"outline",size:"sm",disabled:x||!W(s),children:[(0,c.jsx)(ic,{className:"h-4 w-4 mr-2"}),"저장"]}),(0,c.jsxs)(nI,{open:C,onOpenChange:A,children:[(0,c.jsx)(nz,{asChild:!0,children:(0,c.jsxs)(tr,{size:"sm",disabled:x||y||!W(s),children:[y?(0,c.jsx)(id,{className:"h-4 w-4 mr-2 animate-spin"}):(0,c.jsx)(ih,{className:"h-4 w-4 mr-2"}),"실행"]})}),(0,c.jsxs)(ii,{children:[(0,c.jsxs)(ir,{children:[(0,c.jsx)(is,{children:"요청 실행 확인"}),(0,c.jsxs)(io,{children:["anthropic"===O?"Anthropic Claude":"zai"===O?"Z.AI (GLM)":"OpenAI"," API 요청을 실행하시겠습니까?",(0,c.jsx)("br",{}),"이 작업은 실제 AI 모델을 호출합니다."]})]}),(0,c.jsxs)("div",{className:"flex justify-end gap-2 mt-4",children:[(0,c.jsx)(tr,{variant:"outline",onClick:()=>A(!1),children:"취소"}),(0,c.jsxs)(tr,{onClick:q,disabled:y,children:[y?(0,c.jsx)(id,{className:"h-4 w-4 mr-2 animate-spin"}):(0,c.jsx)(ih,{className:"h-4 w-4 mr-2"}),"실행"]})]})]})]})]})]})]})}),(0,c.jsx)(tA,{className:"flex-1 min-h-0",children:x?(0,c.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,c.jsx)(id,{className:"h-6 w-6 animate-spin"})}):"result"===N&&k?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.result=e},children:k.success?(0,c.jsx)("div",{className:"h-full",children:(0,c.jsx)(vm,{data:k.response,className:"h-full"})}):(0,c.jsx)("div",{className:"bg-red-50 border border-red-200 p-4 rounded-lg",children:(0,c.jsx)("p",{className:"text-red-800",children:k.error})})},"result-scroll"):"form"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.form=e},children:(0,c.jsx)("div",{className:"space-y-4",children:l?l&&"object"==typeof l&&null!==l&&"input"in l&&Array.isArray(l.input)?(0,c.jsxs)("div",{className:"space-y-4",children:[(0,c.jsx)(vw,{data:l.input,onChange:e=>{V({...l,input:e})},className:"h-full"}),(0,c.jsx)(gz,{data:Object.fromEntries(Object.entries(l).filter(e=>{let[t]=e;return"input"!==t})),onChange:e=>{V({...e,input:l.input})},className:"h-full"})]}):(0,c.jsx)(gz,{data:l,onChange:V,className:"h-full"}):(0,c.jsxs)("div",{className:"border rounded-lg p-8 text-center text-muted-foreground",children:[(0,c.jsx)(im,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"JSON 데이터를 파싱할 수 없습니다"}),(0,c.jsx)("p",{className:"text-sm",children:"코드 편집기에서 유효한 JSON을 입력하세요"})]})})},"form-scroll"):"code"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.code=e},children:(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{ref:E,className:"border rounded-lg overflow-hidden mb-4",style:{height:"".concat(D,"px")},onWheel:I,children:(0,c.jsx)(vk,{height:"100%",defaultLanguage:"json",theme:"vs-dark",value:s,onChange:e=>{let t=e||"";if(o(t),W(t))try{a(JSON.parse(t))}catch(e){}},onMount:L,options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:14,lineNumbers:"on",renderWhitespace:"selection",folding:!0,wordWrap:"on",formatOnType:!0,formatOnPaste:!0,automaticLayout:!1,scrollbar:{vertical:"hidden",verticalScrollbarSize:0,horizontal:"auto",horizontalScrollbarSize:10},overviewRulerLanes:0,hideCursorInOverviewRuler:!0,overviewRulerBorder:!1,mouseWheelScrollSensitivity:0}})}),(0,c.jsx)("div",{className:"flex items-center gap-2",children:W(s)?(0,c.jsxs)("div",{className:"flex items-center text-sm text-green-600",children:[(0,c.jsx)(tx,{className:"h-4 w-4 mr-1"}),"유효한 JSON"]}):(0,c.jsxs)("div",{className:"flex items-center text-sm text-red-600",children:[(0,c.jsx)(tf,{className:"h-4 w-4 mr-1"}),"유효하지 않은 JSON"]})})]})},"code-scroll"):"tree"===h?(0,c.jsx)(e7,{className:"h-full",ref:e=>{v.current.tree=e},children:(0,c.jsx)("div",{className:"space-y-4",children:l?(0,c.jsx)(iA,{data:l,onChange:V,className:"h-full",expandedNodes:m,onExpandedNodesChange:g,expandAllByDefault:!0}):(0,c.jsxs)("div",{className:"border rounded-lg p-8 text-center text-muted-foreground",children:[(0,c.jsx)(iu,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{children:"JSON 데이터를 파싱할 수 없습니다"}),(0,c.jsx)("p",{className:"text-sm",children:"코드 편집기에서 유효한 JSON을 입력하세요"})]})})},"tree-scroll"):null})]}):(0,c.jsx)(tw,{className:"h-full",children:(0,c.jsx)(tA,{className:"flex items-center justify-center h-full",children:(0,c.jsxs)("div",{className:"text-center text-muted-foreground",children:[(0,c.jsx)(ia,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),(0,c.jsx)("p",{className:"text-lg",children:"REQ 파일을 선택하세요"}),(0,c.jsx)("p",{className:"text-sm",children:"요청 파일을 선택하면 내용을 편집하고 재실행할 수 있습니다"})]})})})}function vC(){let[e,t]=(0,d.useState)([]),[n,i]=(0,d.useState)(null),[r,s]=(0,d.useState)(!0),[o,l]=(0,d.useState)(null);(0,d.useEffect)(()=>{a()},[]);let a=async()=>{try{s(!0);let e=await il("/api/logs"),n=await e.json();e.ok?(t(n.files||[]),l(null)):l(n.message||"Failed to load log files")}catch(e){l("Failed to connect to server")}finally{s(!1)}};return(0,c.jsxs)("div",{className:"h-screen bg-background flex",children:[(0,c.jsxs)("div",{className:"flex-shrink-0 w-80 border-r border-border bg-background flex flex-col",children:[(0,c.jsxs)("div",{className:"flex-shrink-0 border-b border-border p-4",children:[(0,c.jsxs)("h2",{className:"text-lg font-semibold flex items-center gap-2",children:[(0,c.jsx)(tp,{className:"h-5 w-5"}),"로그 파일"]}),(0,c.jsx)("p",{className:"text-sm text-muted-foreground",children:r?"로딩 중...":"".concat(e.length,"개 파일")})]}),(0,c.jsx)("div",{className:"flex-1 min-h-0",children:(0,c.jsx)(e7,{className:"h-full",children:(0,c.jsx)(ty,{files:e,selectedFile:n,onFileSelect:e=>{i(e)},loading:r,error:o,onRefresh:a})})})]}),(0,c.jsx)("div",{className:"flex-1 min-w-0",children:(0,c.jsx)(vS,{selectedFile:n,onFileUpdate:a})})]})}}]);
|