import './async-D55cHugf.js';
import { f as attr_class, i as stringify, d as bind_props, c as spread_props } from './index-u8mz_F03.js';
import './2-BLdXJizP.js';
import { $ as $$1 } from './utils.svelte-B2py64Fz.js';
import { W as W$1 } from './index3-Df92vI-L.js';
import { i } from './Code-CrFuQ3ob.js';
import { o as onDestroy } from './index-server-CQz6EZl_.js';
import { B, A as A$1, _ as _i$1, F as Ft$1, O as Oe$1, s as st, J as J$1, W as Wt$1, C, U, $ as $$2, g as gl, n as nt$1, v as vt$1, a as su, b as $i$1, c as at, L, d as Jl, r as ro, N as Nt$1, R as Rt$1, e as Jh, f as es$1, k as k$1, h as fu, I as Ir$1, i as F$1, j as iu, Q as Qc, l as hu, m as Jc, H as H$1, o as lu, t as tu, p as eu, q as au, T as Tl, u as cc, w as bn, x as fc, y as W$2, z as mt$1, D as le$1, Y as Yc, E as ae$1, G as nu, K as I$1, M as zt$1, P as uu, S as qi$1, V as Ml, X as cu } from './Code.svelte_svelte_type_style_lang-C72WHBwk.js';
import { e } from './Check-C7_ZsXgh.js';
import { h } from './Copy-B8YOhH7c.js';
import { w } from './IconButton-BRnu7KaR.js';
import { l } from './Download-DcU5dONL.js';
import { u } from './DownloadLink-nj1p0krE.js';
import { y } from './IconButtonWrapper-CjFRPb3y.js';
import { G as G$1 } from './Block-DZmzQwnI.js';
import { k } from './BlockLabel-bKYWnOzQ.js';
import { p } from './Empty-DGRbZO0a.js';
export { default as BaseExample } from './Example-DMvLoGhj.js';
import './escaping-CBnpiEl5.js';
import './context-CBkBucIx.js';
import './index5-BoOEKc6P.js';
import './dev-fallback-Bc5Ork7Y.js';
import './index-Cg-Pg6j3.js';
import './clone-Yk88IHKV.js';
import './Clear-D7Yjckqz.js';

function H(){var t=arguments[0];typeof t=="string"&&(t=document.createElement(t));var e=1,o=arguments[1];if(o&&typeof o=="object"&&o.nodeType==null&&!Array.isArray(o)){for(var n in o)if(Object.prototype.hasOwnProperty.call(o,n)){var i=o[n];typeof i=="string"?t.setAttribute(n,i):i!=null&&(t[n]=i);}e++;}for(;e<arguments.length;e++)co(t,arguments[e]);return t}function co(t,e){if(typeof e=="string")t.appendChild(document.createTextNode(e));else if(e!=null)if(e.nodeType!=null)t.appendChild(e);else if(Array.isArray(e))for(var o=0;o<e.length;o++)co(t,e[o]);else throw new RangeError("Unsupported child node: "+e)}const ti=t=>{let{state:e}=t,o=e.doc.lineAt(e.selection.main.from),n=ut(t.state,o.from);return n.line?oi(t):n.block?ii(t):false};function ft(t,e){return ({state:o,dispatch:n})=>{if(o.readOnly)return  false;let i=t(e,o);return i?(n(o.update(i)),true):false}}const oi=ft(li,0),ni=ft(fo,0),ii=ft((t,e)=>fo(t,e,si(e)),0);function ut(t,e){let o=t.languageDataAt("commentTokens",e,1);return o.length?o[0]:{}}const ae=50;function ri(t,{open:e,close:o},n,i){let r=t.sliceDoc(n-ae,n),s=t.sliceDoc(i,i+ae),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(s)[0].length,f=r.length-l;if(r.slice(f-e.length,f)==e&&s.slice(a,a+o.length)==o)return {open:{pos:n-l,margin:l&&1},close:{pos:i+a,margin:a&&1}};let c,d;i-n<=2*ae?c=d=t.sliceDoc(n,i):(c=t.sliceDoc(n,n+ae),d=t.sliceDoc(i-ae,i));let m=/^\s*/.exec(c)[0].length,h=/\s*$/.exec(d)[0].length,p=d.length-h-o.length;return c.slice(m,m+e.length)==e&&d.slice(p,p+o.length)==o?{open:{pos:n+m+e.length,margin:/\s/.test(c.charAt(m+e.length))?1:0},close:{pos:i-h-o.length,margin:/\s/.test(d.charAt(p-1))?1:0}}:null}function si(t){let e=[];for(let o of t.selection.ranges){let n=t.doc.lineAt(o.from),i=o.to<=n.to?n:t.doc.lineAt(o.to);i.from>n.from&&i.from==o.to&&(i=o.to==n.to+1?n:t.doc.lineAt(o.to-1));let r=e.length-1;r>=0&&e[r].to>n.from?e[r].to=i.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:i.to});}return e}function fo(t,e,o=e.selection.ranges){let n=o.map(r=>ut(e,r.from).block);if(!n.every(r=>r))return null;let i=o.map((r,s)=>ri(e,n[s],r.from,r.to));if(t!=2&&!i.every(r=>r))return {changes:e.changes(o.map((r,s)=>i[s]?[]:[{from:r.from,insert:n[s].open+" "},{from:r.to,insert:" "+n[s].close}]))};if(t!=1&&i.some(r=>r)){let r=[];for(let s=0,l;s<i.length;s++)if(l=i[s]){let a=n[s],{open:f,close:c}=l;r.push({from:f.pos-a.open.length,to:f.pos+f.margin},{from:c.pos-c.margin,to:c.pos+a.close.length});}return {changes:r}}return null}function li(t,e,o=e.selection.ranges){let n=[],i=-1;for(let{from:r,to:s}of o){let l=n.length,a=1e9,f=ut(e,r).line;if(f){for(let c=r;c<=s;){let d=e.doc.lineAt(c);if(d.from>i&&(r==s||s>d.from)){i=d.from;let m=/^\s*/.exec(d.text)[0].length,h=m==d.length,p=d.text.slice(m,m+f.length)==f?m:-1;m<d.text.length&&m<a&&(a=m),n.push({line:d,comment:p,token:f,indent:m,empty:h,single:false});}c=d.to+1;}if(a<1e9)for(let c=l;c<n.length;c++)n[c].indent<n[c].line.text.length&&(n[c].indent=a);n.length==l+1&&(n[l].single=true);}}if(t!=2&&n.some(r=>r.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:f,empty:c,single:d}of n)(d||!c)&&r.push({from:l.from+f,insert:a+" "});let s=e.changes(r);return {changes:s,selection:e.selection.map(s,1)}}else if(t!=1&&n.some(r=>r.comment>=0)){let r=[];for(let{line:s,comment:l,token:a}of n)if(l>=0){let f=s.from+l,c=f+a.length;s.text[c-s.from]==" "&&c++,r.push({from:f,to:c});}return {changes:r}}return null}const et=Oe$1.define(),ai=Oe$1.define(),ci=A$1.define(),uo=A$1.define({combine(t){return _i$1(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,o)=>o},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,o)=>(n,i)=>e(n,i)||o(n,i)})}}),ho=Ft$1.define({create(){return V.empty},update(t,e){let o=e.state.facet(uo),n=e.annotation(et);if(n){let a=T.fromTransaction(e,n.selection),f=n.side,c=f==0?t.undone:t.done;return a?c=De(c,c.length,o.minDepth,a):c=go(c,e.startState.selection),new V(f==0?n.rest:c,f==0?c:n.rest)}let i=e.annotation(ai);if((i=="full"||i=="before")&&(t=t.isolate()),e.annotation(st.addToHistory)===false)return e.changes.empty?t:t.addMapping(e.changes.desc);let r=T.fromTransaction(e),s=e.annotation(st.time),l=e.annotation(st.userEvent);return r?t=t.addChanges(r,s,l,o,e):e.selection&&(t=t.addSelection(e.startState.selection,s,l,o.newGroupDelay)),(i=="full"||i=="after")&&(t=t.isolate()),t},toJSON(t){return {done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new V(t.done.map(T.fromJSON),t.undone.map(T.fromJSON))}});function fi(t={}){return [ho,uo.of(t),B.domEventHandlers({beforeinput(e,o){let n=e.inputType=="historyUndo"?mo:e.inputType=="historyRedo"?tt:null;return n?(e.preventDefault(),n(o)):false}})]}function Oe(t,e){return function({state:o,dispatch:n}){if(!e&&o.readOnly)return  false;let i=o.field(ho,false);if(!i)return  false;let r=i.pop(t,o,e);return r?(n(r),true):false}}const mo=Oe(0,false),tt=Oe(1,false),ui=Oe(0,true),di=Oe(1,true);class T{constructor(e,o,n,i,r){this.changes=e,this.effects=o,this.mapped=n,this.startSelection=i,this.selectionsAfter=r;}setSelAfter(e){return new T(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,o,n;return {changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(o=this.mapped)===null||o===void 0?void 0:o.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(i=>i.toJSON())}}static fromJSON(e){return new T(e.changes&&J$1.fromJSON(e.changes),[],e.mapped&&Wt$1.fromJSON(e.mapped),e.startSelection&&C.fromJSON(e.startSelection),e.selectionsAfter.map(C.fromJSON))}static fromTransaction(e,o){let n=E;for(let i of e.startState.facet(ci)){let r=i(e);r.length&&(n=n.concat(r));}return !n.length&&e.changes.empty?null:new T(e.changes.invert(e.startState.doc),n,void 0,o||e.startState.selection,E)}static selection(e){return new T(void 0,E,void 0,void 0,e)}}function De(t,e,o,n){let i=e+1>o+20?e-o-1:0,r=t.slice(i,e);return r.push(n),r}function hi(t,e){let o=[],n=false;return t.iterChangedRanges((i,r)=>o.push(i,r)),e.iterChangedRanges((i,r,s,l)=>{for(let a=0;a<o.length;){let f=o[a++],c=o[a++];l>=f&&s<=c&&(n=true);}}),n}function mi(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((o,n)=>o.empty!=e.ranges[n].empty).length===0}function po(t,e){return t.length?e.length?t.concat(e):t:e}const E=[],pi=200;function go(t,e){if(t.length){let o=t[t.length-1],n=o.selectionsAfter.slice(Math.max(0,o.selectionsAfter.length-pi));return n.length&&n[n.length-1].eq(e)?t:(n.push(e),De(t,t.length-1,1e9,o.setSelAfter(n)))}else return [T.selection([e])]}function gi(t){let e=t[t.length-1],o=t.slice();return o[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),o}function Ue(t,e){if(!t.length)return t;let o=t.length,n=E;for(;o;){let i=yi(t[o-1],e,n);if(i.changes&&!i.changes.empty||i.effects.length){let r=t.slice(0,o);return r[o-1]=i,r}else e=i.mapped,o--,n=i.selectionsAfter;}return n.length?[T.selection(n)]:E}function yi(t,e,o){let n=po(t.selectionsAfter.length?t.selectionsAfter.map(l=>l.map(e)):E,o);if(!t.changes)return T.selection(n);let i=t.changes.map(e),r=e.mapDesc(t.changes,true),s=t.mapped?t.mapped.composeDesc(r):r;return new T(i,U.mapEffects(t.effects,e),s,t.startSelection.map(r),n)}const bi=/^(input\.type|delete)($|\.)/;class V{constructor(e,o,n=0,i=void 0){this.done=e,this.undone=o,this.prevTime=n,this.prevUserEvent=i;}isolate(){return this.prevTime?new V(this.done,this.undone):this}addChanges(e,o,n,i,r){let s=this.done,l=s[s.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!n||bi.test(n))&&(!l.selectionsAfter.length&&o-this.prevTime<i.newGroupDelay&&i.joinToEvent(r,hi(l.changes,e.changes))||n=="input.type.compose")?s=De(s,s.length-1,i.minDepth,new T(e.changes.compose(l.changes),po(U.mapEffects(e.effects,l.changes),l.effects),l.mapped,l.startSelection,E)):s=De(s,s.length,i.minDepth,e),new V(s,E,o,n)}addSelection(e,o,n,i){let r=this.done.length?this.done[this.done.length-1].selectionsAfter:E;return r.length>0&&o-this.prevTime<i&&n==this.prevUserEvent&&n&&/^select($|\.)/.test(n)&&mi(r[r.length-1],e)?this:new V(go(this.done,e),this.undone,o,n)}addMapping(e){return new V(Ue(this.done,e),Ue(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,o,n){let i=e==0?this.done:this.undone;if(i.length==0)return null;let r=i[i.length-1],s=r.selectionsAfter[0]||o.selection;if(n&&r.selectionsAfter.length)return o.update({selection:r.selectionsAfter[r.selectionsAfter.length-1],annotations:et.of({side:e,rest:gi(i),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:true});if(r.changes){let l=i.length==1?E:i.slice(0,i.length-1);return r.mapped&&(l=Ue(l,r.mapped)),o.update({changes:r.changes,selection:r.startSelection,effects:r.effects,annotations:et.of({side:e,rest:l,selection:s}),filter:false,userEvent:e==0?"undo":"redo",scrollIntoView:true})}else return null}}V.empty=new V(E,E);const ki=[{key:"Mod-z",run:mo,preventDefault:true},{key:"Mod-y",mac:"Mod-Shift-z",run:tt,preventDefault:true},{linux:"Ctrl-Shift-z",run:tt,preventDefault:true},{key:"Mod-u",run:ui,preventDefault:true},{key:"Alt-u",mac:"Mod-Shift-u",run:di,preventDefault:true}];function le(t,e){return C.create(t.ranges.map(e),t.mainIndex)}function F(t,e){return t.update({selection:e,scrollIntoView:true,userEvent:"select"})}function $({state:t,dispatch:e},o){let n=le(t.selection,o);return n.eq(t.selection,true)?false:(e(F(t,n)),true)}function Ee(t,e){return C.cursor(e?t.to:t.from)}function yo(t,e){return $(t,o=>o.empty?t.moveByChar(o,e):Ee(o,e))}function D(t){return t.textDirectionAt(t.state.selection.main.head)==$$2.LTR}const bo=t=>yo(t,!D(t)),ko=t=>yo(t,D(t));function xo(t,e){return $(t,o=>o.empty?t.moveByGroup(o,e):Ee(o,e))}const xi=t=>xo(t,!D(t)),Ci=t=>xo(t,D(t));function vi(t,e,o){if(e.type.prop(o))return  true;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Re(t,e,o){let n=Rt$1(t).resolveInner(e.head),i=o?I$1.closedBy:I$1.openedBy;for(let a=e.head;;){let f=o?n.childAfter(a):n.childBefore(a);if(!f)break;vi(t,f,i)?n=f:a=o?f.to:f.from;}let r=n.type.prop(i),s,l;return r&&(s=o?uu(t,n.from,1):uu(t,n.to,-1))&&s.matched?l=o?s.end.to:s.end.from:l=o?n.to:n.from,C.cursor(l,o?-1:1)}const Si=t=>$(t,e=>Re(t.state,e,!D(t))),wi=t=>$(t,e=>Re(t.state,e,D(t)));function Co(t,e){return $(t,o=>{if(!o.empty)return Ee(o,e);let n=t.moveVertically(o,e);return n.head!=o.head?n:t.moveToLineBoundary(o,e)})}const vo=t=>Co(t,false),So=t=>Co(t,true);function wo(t){let e=t.scrollDOM.clientHeight<t.scrollDOM.scrollHeight-2,o=0,n=0,i;if(e){for(let r of t.state.facet(B.scrollMargins)){let s=r(t);s?.top&&(o=Math.max(s?.top,o)),s?.bottom&&(n=Math.max(s?.bottom,n));}i=t.scrollDOM.clientHeight-o-n;}else i=(t.dom.ownerDocument.defaultView||window).innerHeight;return {marginTop:o,marginBottom:n,selfScroll:e,height:Math.max(t.defaultLineHeight,i-5)}}function Ao(t,e){let o=wo(t),{state:n}=t,i=le(n.selection,s=>s.empty?t.moveVertically(s,e,o.height):Ee(s,e));if(i.eq(n.selection))return  false;let r;if(o.selfScroll){let s=t.coordsAtPos(n.selection.main.head),l=t.scrollDOM.getBoundingClientRect(),a=l.top+o.marginTop,f=l.bottom-o.marginBottom;s&&s.top>a&&s.bottom<f&&(r=B.scrollIntoView(i.main.head,{y:"start",yMargin:s.top-a}));}return t.dispatch(F(n,i),{effects:r}),true}const Ct=t=>Ao(t,false),ot=t=>Ao(t,true);function G(t,e,o){let n=t.lineBlockAt(e.head),i=t.moveToLineBoundary(e,o);if(i.head==e.head&&i.head!=(o?n.to:n.from)&&(i=t.moveToLineBoundary(e,o,false)),!o&&i.head==n.from&&n.length){let r=/^\s*/.exec(t.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;r&&e.head!=n.from+r&&(i=C.cursor(n.from+r));}return i}const Ai=t=>$(t,e=>G(t,e,true)),Bi=t=>$(t,e=>G(t,e,false)),Di=t=>$(t,e=>G(t,e,!D(t))),Li=t=>$(t,e=>G(t,e,D(t))),Mi=t=>$(t,e=>C.cursor(t.lineBlockAt(e.head).from,1)),Ti=t=>$(t,e=>C.cursor(t.lineBlockAt(e.head).to,-1));function Ii(t,e,o){let n=false,i=le(t.selection,r=>{let s=uu(t,r.head,-1)||uu(t,r.head,1)||r.head>0&&uu(t,r.head-1,1)||r.head<t.doc.length&&uu(t,r.head+1,-1);if(!s||!s.end)return r;n=true;let l=s.start.from==r.head?s.end.to:s.end.from;return C.cursor(l)});return n?(e(F(t,i)),true):false}const Oi=({state:t,dispatch:e})=>Ii(t,e);function P(t,e){let o=le(t.state.selection,n=>{let i=e(n);return C.range(n.anchor,i.head,i.goalColumn,i.bidiLevel||void 0)});return o.eq(t.state.selection)?false:(t.dispatch(F(t.state,o)),true)}function Bo(t,e){return P(t,o=>t.moveByChar(o,e))}const Do=t=>Bo(t,!D(t)),Lo=t=>Bo(t,D(t));function Mo(t,e){return P(t,o=>t.moveByGroup(o,e))}const Ei=t=>Mo(t,!D(t)),Ri=t=>Mo(t,D(t)),Pi=t=>P(t,e=>Re(t.state,e,!D(t))),_i=t=>P(t,e=>Re(t.state,e,D(t)));function To(t,e){return P(t,o=>t.moveVertically(o,e))}const Io=t=>To(t,false),Oo=t=>To(t,true);function Eo(t,e){return P(t,o=>t.moveVertically(o,e,wo(t).height))}const vt=t=>Eo(t,false),St=t=>Eo(t,true),Ni=t=>P(t,e=>G(t,e,true)),Ui=t=>P(t,e=>G(t,e,false)),Fi=t=>P(t,e=>G(t,e,!D(t))),$i=t=>P(t,e=>G(t,e,D(t))),Wi=t=>P(t,e=>C.cursor(t.lineBlockAt(e.head).from)),Hi=t=>P(t,e=>C.cursor(t.lineBlockAt(e.head).to)),wt=({state:t,dispatch:e})=>(e(F(t,{anchor:0})),true),At=({state:t,dispatch:e})=>(e(F(t,{anchor:t.doc.length})),true),Bt=({state:t,dispatch:e})=>(e(F(t,{anchor:t.selection.main.anchor,head:0})),true),Dt=({state:t,dispatch:e})=>(e(F(t,{anchor:t.selection.main.anchor,head:t.doc.length})),true),Vi=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),true),zi=({state:t,dispatch:e})=>{let o=Pe(t).map(({from:n,to:i})=>C.range(n,Math.min(i+1,t.doc.length)));return e(t.update({selection:C.create(o),userEvent:"select"})),true},qi=({state:t,dispatch:e})=>{let o=le(t.selection,n=>{let i=Rt$1(t),r=i.resolveStack(n.from,1);if(n.empty){let s=i.resolveStack(n.from,-1);s.node.from>=r.node.from&&s.node.to<=r.node.to&&(r=s);}for(let s=r;s;s=s.next){let{node:l}=s;if((l.from<n.from&&l.to>=n.to||l.to>n.to&&l.from<=n.from)&&s.next)return C.range(l.to,l.from)}return n});return o.eq(t.selection)?false:(e(F(t,o)),true)};function Ro(t,e){let{state:o}=t,n=o.selection,i=o.selection.ranges.slice();for(let r of o.selection.ranges){let s=o.doc.lineAt(r.head);if(e?s.to<t.state.doc.length:s.from>0)for(let l=r;;){let a=t.moveVertically(l,e);if(a.head<s.from||a.head>s.to){i.some(f=>f.head==a.head)||i.push(a);break}else {if(a.head==l.head)break;l=a;}}}return i.length==n.ranges.length?false:(t.dispatch(F(o,C.create(i,i.length-1))),true)}const ji=t=>Ro(t,false),Gi=t=>Ro(t,true),Ki=({state:t,dispatch:e})=>{let o=t.selection,n=null;return o.ranges.length>1?n=C.create([o.main]):o.main.empty||(n=C.create([C.cursor(o.main.head)])),n?(e(F(t,n)),true):false};function be(t,e){if(t.state.readOnly)return  false;let o="delete.selection",{state:n}=t,i=n.changeByRange(r=>{let{from:s,to:l}=r;if(s==l){let a=e(r);a<s?(o="delete.backward",a=ke(t,a,false)):a>s&&(o="delete.forward",a=ke(t,a,true)),s=Math.min(s,a),l=Math.max(l,a);}else s=ke(t,s,false),l=ke(t,l,true);return s==l?{range:r}:{changes:{from:s,to:l},range:C.cursor(s,s<r.head?-1:1)}});return i.changes.empty?false:(t.dispatch(n.update(i,{scrollIntoView:true,userEvent:o,effects:o=="delete.selection"?B.announce.of(n.phrase("Selection deleted")):void 0})),true)}function ke(t,e,o){if(t instanceof B)for(let n of t.state.facet(B.atomicRanges).map(i=>i(t)))n.between(e,e,(i,r)=>{i<e&&r>e&&(e=o?r:i);});return e}const Po=(t,e,o)=>be(t,n=>{let i=n.from,{state:r}=t,s=r.doc.lineAt(i),l,a;if(o&&!e&&i>s.from&&i<s.from+200&&!/[^ \t]/.test(l=s.text.slice(0,i-s.from))){if(l[l.length-1]=="	")return i-1;let f=bn(l,r.tabSize),c=f%qi$1(r)||qi$1(r);for(let d=0;d<c&&l[l.length-1-d]==" ";d++)i--;a=i;}else a=mt$1(s.text,i-s.from,e,e)+s.from,a==i&&s.number!=(e?r.doc.lines:1)?a+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(a-s.from,i-s.from))&&(a=mt$1(s.text,a-s.from,false,false)+s.from);return a}),nt=t=>Po(t,false,true),_o=t=>Po(t,true,false),No=(t,e)=>be(t,o=>{let n=o.head,{state:i}=t,r=i.doc.lineAt(n),s=i.charCategorizer(n);for(let l=null;;){if(n==(e?r.to:r.from)){n==o.head&&r.number!=(e?i.doc.lines:1)&&(n+=e?1:-1);break}let a=mt$1(r.text,n-r.from,e)+r.from,f=r.text.slice(Math.min(n,a)-r.from,Math.max(n,a)-r.from),c=s(f);if(l!=null&&c!=l)break;(f!=" "||n!=o.head)&&(l=c),n=a;}return n}),Uo=t=>No(t,false),Ji=t=>No(t,true),Qi=t=>be(t,e=>{let o=t.lineBlockAt(e.head).to;return e.head<o?o:Math.min(t.state.doc.length,e.head+1)}),Yi=t=>be(t,e=>{let o=t.moveToLineBoundary(e,false).head;return e.head>o?o:Math.max(0,e.head-1)}),Xi=t=>be(t,e=>{let o=t.moveToLineBoundary(e,true).head;return e.head<o?o:Math.min(t.state.doc.length,e.head+1)}),Zi=({state:t,dispatch:e})=>{if(t.readOnly)return  false;let o=t.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:W$2.of(["",""])},range:C.cursor(n.from)}));return e(t.update(o,{scrollIntoView:true,userEvent:"input"})),true},er=({state:t,dispatch:e})=>{if(t.readOnly)return  false;let o=t.changeByRange(n=>{if(!n.empty||n.from==0||n.from==t.doc.length)return {range:n};let i=n.from,r=t.doc.lineAt(i),s=i==r.from?i-1:mt$1(r.text,i-r.from,false)+r.from,l=i==r.to?i+1:mt$1(r.text,i-r.from,true)+r.from;return {changes:{from:s,to:l,insert:t.doc.slice(i,l).append(t.doc.slice(s,i))},range:C.cursor(l)}});return o.changes.empty?false:(e(t.update(o,{scrollIntoView:true,userEvent:"move.character"})),true)};function Pe(t){let e=[],o=-1;for(let n of t.selection.ranges){let i=t.doc.lineAt(n.from),r=t.doc.lineAt(n.to);if(!n.empty&&n.to==r.from&&(r=t.doc.lineAt(n.to-1)),o>=i.number){let s=e[e.length-1];s.to=r.to,s.ranges.push(n);}else e.push({from:i.from,to:r.to,ranges:[n]});o=r.number+1;}return e}function Fo(t,e,o){if(t.readOnly)return  false;let n=[],i=[];for(let r of Pe(t)){if(o?r.to==t.doc.length:r.from==0)continue;let s=t.doc.lineAt(o?r.to+1:r.from-1),l=s.length+1;if(o){n.push({from:r.to,to:s.to},{from:r.from,insert:s.text+t.lineBreak});for(let a of r.ranges)i.push(C.range(Math.min(t.doc.length,a.anchor+l),Math.min(t.doc.length,a.head+l)));}else {n.push({from:s.from,to:r.from},{from:r.to,insert:t.lineBreak+s.text});for(let a of r.ranges)i.push(C.range(a.anchor-l,a.head-l));}}return n.length?(e(t.update({changes:n,scrollIntoView:true,selection:C.create(i,t.selection.mainIndex),userEvent:"move.line"})),true):false}const tr=({state:t,dispatch:e})=>Fo(t,e,false),or=({state:t,dispatch:e})=>Fo(t,e,true);function $o(t,e,o){if(t.readOnly)return  false;let n=[];for(let r of Pe(t))o?n.push({from:r.from,insert:t.doc.slice(r.from,r.to)+t.lineBreak}):n.push({from:r.to,insert:t.lineBreak+t.doc.slice(r.from,r.to)});let i=t.changes(n);return e(t.update({changes:i,selection:t.selection.map(i,o?1:-1),scrollIntoView:true,userEvent:"input.copyline"})),true}const nr=({state:t,dispatch:e})=>$o(t,e,false),ir=({state:t,dispatch:e})=>$o(t,e,true),rr=t=>{if(t.state.readOnly)return  false;let{state:e}=t,o=e.changes(Pe(e).map(({from:i,to:r})=>(i>0?i--:r<e.doc.length&&r++,{from:i,to:r}))),n=le(e.selection,i=>{let r;if(t.lineWrapping){let s=t.lineBlockAt(i.head),l=t.coordsAtPos(i.head,i.assoc||1);l&&(r=s.bottom+t.documentTop-l.bottom+t.defaultLineHeight/2);}return t.moveVertically(i,true,r)}).map(o);return t.dispatch({changes:o,selection:n,scrollIntoView:true,userEvent:"delete.line"}),true};function sr(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return {from:e,to:e};let o=Rt$1(t).resolveInner(e),n=o.childBefore(e),i=o.childAfter(e),r;return n&&i&&n.to<=e&&i.from>=e&&(r=n.type.prop(I$1.closedBy))&&r.indexOf(i.name)>-1&&t.doc.lineAt(n.to).from==t.doc.lineAt(i.from).from&&!/\S/.test(t.sliceDoc(n.to,i.from))?{from:n.to,to:i.from}:null}const Lt=Wo(false),lr=Wo(true);function Wo(t){return ({state:e,dispatch:o})=>{if(e.readOnly)return  false;let n=e.changeByRange(i=>{let{from:r,to:s}=i,l=e.doc.lineAt(r),a=!t&&r==s&&sr(e,r);t&&(r=s=(s<=l.to?l:e.doc.lineAt(s)).to);let f=new Tl(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=cc(f,r);for(c==null&&(c=bn(/^\s*/.exec(e.doc.lineAt(r).text)[0],e.tabSize));s<l.to&&/\s/.test(l.text[s-l.from]);)s++;a?{from:r,to:s}=a:r>l.from&&r<l.from+100&&!/\S/.test(l.text.slice(0,r))&&(r=l.from);let d=["",fc(e,c)];return a&&d.push(fc(e,f.lineIndent(l.from,-1))),{changes:{from:r,to:s,insert:W$2.of(d)},range:C.cursor(r+1+d[1].length)}});return o(e.update(n,{scrollIntoView:true,userEvent:"input"})),true}}function dt(t,e){let o=-1;return t.changeByRange(n=>{let i=[];for(let s=n.from;s<=n.to;){let l=t.doc.lineAt(s);l.number>o&&(n.empty||n.to>l.from)&&(e(l,i,n),o=l.number),s=l.to+1;}let r=t.changes(i);return {changes:i,range:C.range(r.mapPos(n.anchor,1),r.mapPos(n.head,1))}})}const ar=({state:t,dispatch:e})=>{if(t.readOnly)return  false;let o=Object.create(null),n=new Tl(t,{overrideIndentation:r=>{let s=o[r];return s??-1}}),i=dt(t,(r,s,l)=>{let a=cc(n,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let f=/^\s*/.exec(r.text)[0],c=fc(t,a);(f!=c||l.from<r.from+f.length)&&(o[r.from]=a,s.push({from:r.from,to:r.from+f.length,insert:c}));});return i.changes.empty||e(t.update(i,{userEvent:"indent"})),true},Ho=({state:t,dispatch:e})=>t.readOnly?false:(e(t.update(dt(t,(o,n)=>{n.push({from:o.from,insert:t.facet(Ml)});}),{userEvent:"input.indent"})),true),Vo=({state:t,dispatch:e})=>t.readOnly?false:(e(t.update(dt(t,(o,n)=>{let i=/^\s*/.exec(o.text)[0];if(!i)return;let r=bn(i,t.tabSize),s=0,l=fc(t,Math.max(0,r-qi$1(t)));for(;s<i.length&&s<l.length&&i.charCodeAt(s)==l.charCodeAt(s);)s++;n.push({from:o.from+s,to:o.from+i.length,insert:l.slice(s)});}),{userEvent:"delete.dedent"})),true),cr=t=>(t.setTabFocusMode(),true),fr=[{key:"Ctrl-b",run:bo,shift:Do,preventDefault:true},{key:"Ctrl-f",run:ko,shift:Lo},{key:"Ctrl-p",run:vo,shift:Io},{key:"Ctrl-n",run:So,shift:Oo},{key:"Ctrl-a",run:Mi,shift:Wi},{key:"Ctrl-e",run:Ti,shift:Hi},{key:"Ctrl-d",run:_o},{key:"Ctrl-h",run:nt},{key:"Ctrl-k",run:Qi},{key:"Ctrl-Alt-h",run:Uo},{key:"Ctrl-o",run:Zi},{key:"Ctrl-t",run:er},{key:"Ctrl-v",run:ot}],ur=[{key:"ArrowLeft",run:bo,shift:Do,preventDefault:true},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:xi,shift:Ei,preventDefault:true},{mac:"Cmd-ArrowLeft",run:Di,shift:Fi,preventDefault:true},{key:"ArrowRight",run:ko,shift:Lo,preventDefault:true},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ci,shift:Ri,preventDefault:true},{mac:"Cmd-ArrowRight",run:Li,shift:$i,preventDefault:true},{key:"ArrowUp",run:vo,shift:Io,preventDefault:true},{mac:"Cmd-ArrowUp",run:wt,shift:Bt},{mac:"Ctrl-ArrowUp",run:Ct,shift:vt},{key:"ArrowDown",run:So,shift:Oo,preventDefault:true},{mac:"Cmd-ArrowDown",run:At,shift:Dt},{mac:"Ctrl-ArrowDown",run:ot,shift:St},{key:"PageUp",run:Ct,shift:vt},{key:"PageDown",run:ot,shift:St},{key:"Home",run:Bi,shift:Ui,preventDefault:true},{key:"Mod-Home",run:wt,shift:Bt},{key:"End",run:Ai,shift:Ni,preventDefault:true},{key:"Mod-End",run:At,shift:Dt},{key:"Enter",run:Lt,shift:Lt},{key:"Mod-a",run:Vi},{key:"Backspace",run:nt,shift:nt,preventDefault:true},{key:"Delete",run:_o,preventDefault:true},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Uo,preventDefault:true},{key:"Mod-Delete",mac:"Alt-Delete",run:Ji,preventDefault:true},{mac:"Mod-Backspace",run:Yi,preventDefault:true},{mac:"Mod-Delete",run:Xi,preventDefault:true}].concat(fr.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),dr=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:Si,shift:Pi},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:wi,shift:_i},{key:"Alt-ArrowUp",run:tr},{key:"Shift-Alt-ArrowUp",run:nr},{key:"Alt-ArrowDown",run:or},{key:"Shift-Alt-ArrowDown",run:ir},{key:"Mod-Alt-ArrowUp",run:ji},{key:"Mod-Alt-ArrowDown",run:Gi},{key:"Escape",run:Ki},{key:"Mod-Enter",run:lr},{key:"Alt-l",mac:"Ctrl-l",run:zi},{key:"Mod-i",run:qi,preventDefault:true},{key:"Mod-[",run:Vo},{key:"Mod-]",run:Ho},{key:"Mod-Alt-\\",run:ar},{key:"Shift-Mod-k",run:rr},{key:"Shift-Mod-\\",run:Oi},{key:"Mod-/",run:ti},{key:"Alt-A",run:ni},{key:"Ctrl-m",mac:"Shift-Alt-m",run:cr}].concat(ur);class zo{constructor(e,o,n,i){this.state=e,this.pos=o,this.explicit=n,this.view=i,this.abortListeners=[],this.abortOnDocChange=false;}tokenBefore(e){let o=Rt$1(this.state).resolveInner(this.pos,-1);for(;o&&e.indexOf(o.name)<0;)o=o.parent;return o?{from:o.from,to:this.pos,text:this.state.sliceDoc(o.from,this.pos),type:o.type}:null}matchBefore(e){let o=this.state.doc.lineAt(this.pos),n=Math.max(o.from,this.pos-250),i=o.text.slice(n-o.from,this.pos-o.from),r=i.search(qo(e,false));return r<0?null:{from:n+r,to:this.pos,text:i.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,o,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(o),n&&n.onDocChange&&(this.abortOnDocChange=true));}}function Mt(t){let e=Object.keys(t).join(""),o=/\w/.test(e);return o&&(e=e.replace(/\w/g,"")),`[${o?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function mr(t){let e=Object.create(null),o=Object.create(null);for(let{label:i}of t){e[i[0]]=true;for(let r=1;r<i.length;r++)o[i[r]]=true;}let n=Mt(e)+Mt(o)+"*$";return [new RegExp("^"+n),new RegExp(n)]}function pr(t){let e=t.map(i=>typeof i=="string"?{label:i}:i),[o,n]=e.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:mr(e);return i=>{let r=i.matchBefore(n);return r||i.explicit?{from:r?r.from:i.pos,options:e,validFor:o}:null}}class Tt{constructor(e,o,n,i){this.completion=e,this.source=o,this.match=n,this.score=i;}}function X(t){return t.selection.main.from}function qo(t,e){var o;let{source:n}=t,i=e&&n[0]!="^",r=n[n.length-1]!="$";return !i&&!r?t:new RegExp(`${i?"^":""}(?:${n})${r?"$":""}`,(o=t.flags)!==null&&o!==void 0?o:t.ignoreCase?"i":"")}const jo=Oe$1.define();function gr(t,e,o,n){let{main:i}=t.selection,r=o-i.from,s=n-i.from;return {...t.changeByRange(l=>{if(l!=i&&o!=n&&t.sliceDoc(l.from+r,l.from+s)!=t.sliceDoc(o,n))return {range:l};let a=t.toText(e);return {changes:{from:l.from+r,to:n==i.from?l.to:l.from+s,insert:a},range:C.cursor(l.from+r+a.length)}}),scrollIntoView:true,userEvent:"input.complete"}}const It=new WeakMap;function yr(t){if(!Array.isArray(t))return t;let e=It.get(t);return e||It.set(t,e=pr(t)),e}const Le=U.define(),me=U.define();class br{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let o=0;o<e.length;){let n=ro(e,o),i=Jl(n);this.chars.push(n);let r=e.slice(o,o+i),s=r.toUpperCase();this.folded.push(ro(s==r?r.toLowerCase():s,0)),o+=i;}this.astral=e.length!=this.chars.length;}ret(e,o){return this.score=e,this.matched=o,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:o,folded:n,any:i,precise:r,byWord:s}=this;if(o.length==1){let k=ro(e,0),b=Jl(k),v=b==e.length?0:-100;if(k!=o[0])if(k==n[0])v+=-200;else return null;return this.ret(v,[0,b])}let l=e.indexOf(this.pattern);if(l==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let a=o.length,f=0;if(l<0){for(let k=0,b=Math.min(e.length,200);k<b&&f<a;){let v=ro(e,k);(v==o[f]||v==n[f])&&(i[f++]=k),k+=Jl(v);}if(f<a)return null}let c=0,d=0,m=false,h=0,p=-1,y=-1,x=/[a-z]/.test(e),B=true;for(let k=0,b=Math.min(e.length,200),v=0;k<b&&d<a;){let w=ro(e,k);l<0&&(c<a&&w==o[c]&&(r[c++]=k),h<a&&(w==o[h]||w==n[h]?(h==0&&(p=k),y=k+1,h++):h=0));let Z,z=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(Z=Yc(w))!=Z.toLowerCase()?1:Z!=Z.toUpperCase()?2:0;(!k||z==1&&x||v==0&&z!=0)&&(o[d]==w||n[d]==w&&(m=true)?s[d++]=k:s.length&&(B=false)),v=z,k+=Jl(w);}return d==a&&s[0]==0&&B?this.result(-100+(m?-200:0),s,e):h==a&&p==0?this.ret(-200-e.length+(y==e.length?0:-100),[0,y]):l>-1?this.ret(-700-e.length,[l,l+this.pattern.length]):h==a?this.ret(-900-e.length,[p,y]):d==a?this.result(-100+(m?-200:0)+-700+(B?0:-1100),s,e):o.length==2?null:this.result((i[0]?-700:0)+-200+-1100,i,e)}result(e,o,n){let i=[],r=0;for(let s of o){let l=s+(this.astral?Jl(ro(n,s)):1);r&&i[r-1]==s?i[r-1]=l:(i[r++]=s,i[r++]=l);}return this.ret(e-n.length,i)}}class kr{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase();}match(e){if(e.length<this.pattern.length)return null;let o=e.slice(0,this.pattern.length),n=o==this.pattern?0:o.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,o.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}}const A=A$1.define({combine(t){return _i$1(t,{activateOnTyping:true,activateOnCompletion:()=>false,activateOnTypingDelay:100,selectOnOpen:true,override:null,closeOnBlur:true,maxRenderedOptions:100,defaultKeymap:true,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:false,icons:true,addToOptions:[],positionInfo:xr,filterStrict:false,compareCompletions:(e,o)=>(e.sortText||e.label).localeCompare(o.sortText||o.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,o)=>e&&o,closeOnBlur:(e,o)=>e&&o,icons:(e,o)=>e&&o,tooltipClass:(e,o)=>n=>Ot(e(n),o(n)),optionClass:(e,o)=>n=>Ot(e(n),o(n)),addToOptions:(e,o)=>e.concat(o),filterStrict:(e,o)=>e||o})}});function Ot(t,e){return t?e?t+" "+e:t:e}function xr(t,e,o,n,i,r){let s=t.textDirection==$$2.RTL,l=s,a=false,f="top",c,d,m=e.left-i.left,h=i.right-e.right,p=n.right-n.left,y=n.bottom-n.top;if(l&&m<Math.min(p,h)?l=false:!l&&h<Math.min(p,m)&&(l=true),p<=(l?m:h))c=Math.max(i.top,Math.min(o.top,i.bottom-y))-e.top,d=Math.min(400,l?m:h);else {a=true,d=Math.min(400,(s?e.right:i.right-e.left)-30);let k=i.bottom-e.bottom;k>=y||k>e.top?c=o.bottom-e.top:(f="bottom",c=e.bottom-o.top);}let x=(e.bottom-e.top)/r.offsetHeight,B=(e.right-e.left)/r.offsetWidth;return {style:`${f}: ${c/x}px; max-width: ${d/B}px`,class:"cm-completionInfo-"+(a?s?"left-narrow":"right-narrow":l?"left":"right")}}function Cr(t){let e=t.addToOptions.slice();return t.icons&&e.push({render(o){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),o.type&&n.classList.add(...o.type.split(/\s+/g).map(i=>"cm-completionIcon-"+i)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(o,n,i,r){let s=document.createElement("span");s.className="cm-completionLabel";let l=o.displayLabel||o.label,a=0;for(let f=0;f<r.length;){let c=r[f++],d=r[f++];c>a&&s.appendChild(document.createTextNode(l.slice(a,c)));let m=s.appendChild(document.createElement("span"));m.appendChild(document.createTextNode(l.slice(c,d))),m.className="cm-completionMatchedText",a=d;}return a<l.length&&s.appendChild(document.createTextNode(l.slice(a))),s},position:50},{render(o){if(!o.detail)return null;let n=document.createElement("span");return n.className="cm-completionDetail",n.textContent=o.detail,n},position:80}),e.sort((o,n)=>o.position-n.position).map(o=>o.render)}function Fe(t,e,o){if(t<=o)return {from:0,to:t};if(e<0&&(e=0),e<=t>>1){let i=Math.floor(e/o);return {from:i*o,to:(i+1)*o}}let n=Math.floor((t-e)/o);return {from:t-(n+1)*o,to:t-n*o}}class vr{constructor(e,o,n){this.view=e,this.stateField=o,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let i=e.state.field(o),{options:r,selected:s}=i.open,l=e.state.facet(A);this.optionContent=Cr(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=Fe(r.length,s,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{let{options:f}=e.state.field(o).open;for(let c=a.target,d;c&&c!=this.dom;c=c.parentNode)if(c.nodeName=="LI"&&(d=/-(\d+)$/.exec(c.id))&&+d[1]<f.length){this.applyCompletion(e,f[+d[1]]),a.preventDefault();return}}),this.dom.addEventListener("focusout",a=>{let f=e.state.field(this.stateField,false);f&&f.tooltip&&e.state.facet(A).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:me.of(null)});}),this.showOptions(r,i.id);}mount(){this.updateSel();}showOptions(e,o){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,o,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq);});}update(e){var o;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:l}=n.open;(!i.open||i.open.options!=r)&&(this.range=Fe(r.length,s,e.state.facet(A).maxRenderedOptions),this.showOptions(r,n.id)),this.updateSel(),l!=((o=i.open)===null||o===void 0?void 0:o.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!l);}}updateTooltipClass(e){let o=this.tooltipClass(e);if(o!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of o.split(" "))n&&this.dom.classList.add(n);this.currentClass=o;}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq);}updateSel(){let e=this.view.state.field(this.stateField),o=e.open;(o.selected>-1&&o.selected<this.range.from||o.selected>=this.range.to)&&(this.range=Fe(o.options.length,o.selected,this.view.state.facet(A).maxRenderedOptions),this.showOptions(o.options,e.id));let n=this.updateSelectedOption(o.selected);if(n){this.destroyInfo();let{completion:i}=o.options[o.selected],{info:r}=i;if(!r)return;let s=typeof r=="string"?document.createTextNode(r):r(i);if(!s)return;"then"in s?s.then(l=>{l&&this.view.state.field(this.stateField,false)==e&&this.addInfoPane(l,i);}).catch(l=>vt$1(this.view.state,l,"completion info")):(this.addInfoPane(s,i),n.setAttribute("aria-describedby",this.info.id));}}addInfoPane(e,o){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else {let{dom:i,destroy:r}=e;n.appendChild(i),this.infoDestroy=r||null;}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq);}updateSelectedOption(e){let o=null;for(let n=this.list.firstChild,i=this.range.from;n;n=n.nextSibling,i++)n.nodeName!="LI"||!n.id?i--:i==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),o=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return o&&wr(this.list,o),o}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let o=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),i=e.getBoundingClientRect(),r=this.space;if(!r){let s=this.dom.ownerDocument.documentElement;r={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight};}return i.top>Math.min(r.bottom,o.bottom)-10||i.bottom<Math.max(r.top,o.top)+10?null:this.view.state.facet(A).positionInfo(this.view,o,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,o,n){const i=document.createElement("ul");i.id=o,i.setAttribute("role","listbox"),i.setAttribute("aria-expanded","true"),i.setAttribute("aria-label",this.view.state.phrase("Completions")),i.addEventListener("mousedown",s=>{s.target==i&&s.preventDefault();});let r=null;for(let s=n.from;s<n.to;s++){let{completion:l,match:a}=e[s],{section:f}=l;if(f){let m=typeof f=="string"?f:f.name;if(m!=r&&(s>n.from||n.from==0))if(r=m,typeof f!="string"&&f.header)i.appendChild(f.header(f));else {let h=i.appendChild(document.createElement("completion-section"));h.textContent=m;}}const c=i.appendChild(document.createElement("li"));c.id=o+"-"+s,c.setAttribute("role","option");let d=this.optionClass(l);d&&(c.className=d);for(let m of this.optionContent){let h=m(l,this.view.state,this.view,a);h&&c.appendChild(h);}}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();}}function Sr(t,e){return o=>new vr(o,t,e)}function wr(t,e){let o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),i=o.height/t.offsetHeight;n.top<o.top?t.scrollTop-=(o.top-n.top)/i:n.bottom>o.bottom&&(t.scrollTop+=(n.bottom-o.bottom)/i);}function Et(t){return (t.boost||0)*100+(t.apply?10:0)+(t.info?5:0)+(t.type?1:0)}function Ar(t,e){let o=[],n=null,i=null,r=c=>{o.push(c);let{section:d}=c.completion;if(d){n||(n=[]);let m=typeof d=="string"?d:d.name;n.some(h=>h.name==m)||n.push(typeof d=="string"?{name:m}:d);}},s=e.facet(A);for(let c of t)if(c.hasResult()){let d=c.result.getMatch;if(c.result.filter===false)for(let m of c.result.options)r(new Tt(m,c.source,d?d(m):[],1e9-o.length));else {let m=e.sliceDoc(c.from,c.to),h,p=s.filterStrict?new kr(m):new br(m);for(let y of c.result.options)if(h=p.match(y.label)){let x=y.displayLabel?d?d(y,h.matched):[]:h.matched,B=h.score+(y.boost||0);if(r(new Tt(y,c.source,x,B)),typeof y.section=="object"&&y.section.rank==="dynamic"){let{name:k}=y.section;i||(i=Object.create(null)),i[k]=Math.max(B,i[k]||-1e9);}}}}if(n){let c=Object.create(null),d=0,m=(h,p)=>(h.rank==="dynamic"&&p.rank==="dynamic"?i[p.name]-i[h.name]:0)||(typeof h.rank=="number"?h.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(h.name<p.name?-1:1);for(let h of n.sort(m))d-=1e5,c[h.name]=d;for(let h of o){let{section:p}=h.completion;p&&(h.score+=c[typeof p=="string"?p:p.name]);}}let l=[],a=null,f=s.compareCompletions;for(let c of o.sort((d,m)=>m.score-d.score||f(d.completion,m.completion))){let d=c.completion;!a||a.label!=d.label||a.detail!=d.detail||a.type!=null&&d.type!=null&&a.type!=d.type||a.apply!=d.apply||a.boost!=d.boost?l.push(c):Et(c.completion)>Et(a)&&(l[l.length-1]=c),a=c.completion;}return l}class oe{constructor(e,o,n,i,r,s){this.options=e,this.attrs=o,this.tooltip=n,this.timestamp=i,this.selected=r,this.disabled=s;}setSelected(e,o){return e==this.selected||e>=this.options.length?this:new oe(this.options,Rt(o,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,o,n,i,r,s){if(i&&!s&&e.some(f=>f.isPending))return i.setDisabled();let l=Ar(e,o);if(!l.length)return i&&e.some(f=>f.isPending)?i.setDisabled():null;let a=o.facet(A).selectOnOpen?0:-1;if(i&&i.selected!=a&&i.selected!=-1){let f=i.options[i.selected].completion;for(let c=0;c<l.length;c++)if(l[c].completion==f){a=c;break}}return new oe(l,Rt(n,a),{pos:e.reduce((f,c)=>c.hasResult()?Math.min(f,c.from):f,1e8),create:Ir,above:r.aboveCursor},i?i.timestamp:Date.now(),a,false)}map(e){return new oe(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new oe(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,true)}}class Me{constructor(e,o,n){this.active=e,this.id=o,this.open=n;}static start(){return new Me(Mr,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:o}=e,n=o.facet(A),r=(n.override||o.languageDataAt("autocomplete",X(o)).map(yr)).map(a=>(this.active.find(c=>c.source==a)||new R(a,this.active.some(c=>c.state!=0)?1:0)).update(e,n));r.length==this.active.length&&r.every((a,f)=>a==this.active[f])&&(r=this.active);let s=this.open,l=e.effects.some(a=>a.is(ht));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||r.some(a=>a.hasResult()&&e.changes.touchesRange(a.from,a.to))||!Br(r,this.active)||l?s=oe.build(r,o,this.id,s,n,l):s&&s.disabled&&!r.some(a=>a.isPending)&&(s=null),!s&&r.every(a=>!a.isPending)&&r.some(a=>a.hasResult())&&(r=r.map(a=>a.hasResult()?new R(a.source,0):a));for(let a of e.effects)a.is(Ko)&&(s=s&&s.setSelected(a.value,this.id));return r==this.active&&s==this.open?this:new Me(r,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Dr:Lr}}function Br(t,e){if(t==e)return  true;for(let o=0,n=0;;){for(;o<t.length&&!t[o].hasResult();)o++;for(;n<e.length&&!e[n].hasResult();)n++;let i=o==t.length,r=n==e.length;if(i||r)return i==r;if(t[o++].result!=e[n++].result)return  false}}const Dr={"aria-autocomplete":"list"},Lr={};function Rt(t,e){let o={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":t};return e>-1&&(o["aria-activedescendant"]=t+"-"+e),o}const Mr=[];function Go(t,e){if(t.isUserEvent("input.complete")){let n=t.annotation(jo);if(n&&e.activateOnCompletion(n))return 12}let o=t.isUserEvent("input.type");return o&&e.activateOnTyping?5:o?1:t.isUserEvent("delete.backward")?2:t.selection?8:t.docChanged?16:0}class R{constructor(e,o,n=false){this.source=e,this.state=o,this.explicit=n;}hasResult(){return  false}get isPending(){return this.state==1}update(e,o){let n=Go(e,o),i=this;(n&8||n&16&&this.touches(e))&&(i=new R(i.source,0)),n&4&&i.state==0&&(i=new R(this.source,1)),i=i.updateFor(e,n);for(let r of e.effects)if(r.is(Le))i=new R(i.source,1,r.value);else if(r.is(me))i=new R(i.source,0);else if(r.is(ht))for(let s of r.value)s.source==i.source&&(i=s);return i}updateFor(e,o){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(X(e.state))}}class ne extends R{constructor(e,o,n,i,r,s){super(e,3,o),this.limit=n,this.result=i,this.from=r,this.to=s;}hasResult(){return  true}updateFor(e,o){var n;if(!(o&3))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),l=X(e.state);if(l>s||!i||o&2&&(X(e.startState)==this.from||l<this.limit))return new R(this.source,o&4?1:0);let a=e.changes.mapPos(this.limit);return Tr(i.validFor,e.state,r,s)?new ne(this.source,this.explicit,a,i,r,s):i.update&&(i=i.update(i,r,s,new zo(e.state,l,false)))?new ne(this.source,this.explicit,a,i,i.from,(n=i.to)!==null&&n!==void 0?n:X(e.state)):new R(this.source,1,this.explicit)}map(e){return e.empty?this:(this.result.map?this.result.map(this.result,e):this.result)?new ne(this.source,this.explicit,e.mapPos(this.limit),this.result,e.mapPos(this.from),e.mapPos(this.to,1)):new R(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}}function Tr(t,e,o,n){if(!t)return  false;let i=e.sliceDoc(o,n);return typeof t=="function"?t(i,o,n,e):qo(t,true).test(i)}const ht=U.define({map(t,e){return t.map(o=>o.map(e))}}),Ko=U.define(),M=Ft$1.define({create(){return Me.start()},update(t,e){return t.update(e)},provide:t=>[gl.from(t,e=>e.tooltip),B.contentAttributes.from(t,e=>e.attrs)]});function mt(t,e){const o=e.completion.apply||e.completion.label;let n=t.state.field(M).active.find(i=>i.source==e.source);return n instanceof ne?(typeof o=="string"?t.dispatch({...gr(t.state,o,n.from,n.to),annotations:jo.of(e.completion)}):o(t,e.completion,n.from,n.to),true):false}const Ir=Sr(M,mt);function xe(t,e="option"){return o=>{let n=o.state.field(M,false);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp<o.state.facet(A).interactionDelay)return  false;let i=1,r;e=="page"&&(r=su(o,n.open.tooltip))&&(i=Math.max(2,Math.floor(r.dom.offsetHeight/r.dom.querySelector("li").offsetHeight)-1));let{length:s}=n.open.options,l=n.open.selected>-1?n.open.selected+i*(t?1:-1):t?0:s-1;return l<0?l=e=="page"?0:s-1:l>=s&&(l=e=="page"?s-1:0),o.dispatch({effects:Ko.of(l)}),true}}const Jo=t=>{let e=t.state.field(M,false);return t.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<t.state.facet(A).interactionDelay?false:mt(t,e.open.options[e.open.selected])},$e=t=>t.state.field(M,false)?(t.dispatch({effects:Le.of(true)}),true):false,Or=t=>{let e=t.state.field(M,false);return !e||!e.active.some(o=>o.state!=0)?false:(t.dispatch({effects:me.of(null)}),true)};class Er{constructor(e,o){this.active=e,this.context=o,this.time=Date.now(),this.updates=[],this.done=void 0;}}const Rr=50,Pr=1e3;nt$1.fromClass(class{constructor(t){this.view=t,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=false,this.composing=0;for(let e of t.state.field(M).active)e.isPending&&this.startQuery(e);}update(t){let e=t.state.field(M),o=t.state.facet(A);if(!t.selectionSet&&!t.docChanged&&t.startState.field(M)==e)return;let n=t.transactions.some(r=>{let s=Go(r,o);return s&8||(r.selection||r.docChanged)&&!(s&3)});for(let r=0;r<this.running.length;r++){let s=this.running[r];if(n||s.context.abortOnDocChange&&t.docChanged||s.updates.length+t.transactions.length>Rr&&Date.now()-s.time>Pr){for(let l of s.context.abortListeners)try{l();}catch(a){vt$1(this.view.state,a);}s.context.abortListeners=null,this.running.splice(r--,1);}else s.updates.push(...t.transactions);}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),t.transactions.some(r=>r.effects.some(s=>s.is(Le)))&&(this.pendingStart=true);let i=this.pendingStart?50:o.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(r=>r.isPending&&!this.running.some(s=>s.active.source==r.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let r of t.transactions)r.isUserEvent("input.type")?this.composing=2:this.composing==2&&r.selection&&(this.composing=3);}startUpdate(){this.debounceUpdate=-1,this.pendingStart=false;let{state:t}=this.view,e=t.field(M);for(let o of e.active)o.isPending&&!this.running.some(n=>n.active.source==o.source)&&this.startQuery(o);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(A).updateSyncTime));}startQuery(t){let{state:e}=this.view,o=X(e),n=new zo(e,o,t.explicit,this.view),i=new Er(t,n);this.running.push(i),Promise.resolve(t.source(n)).then(r=>{i.context.aborted||(i.done=r||null,this.scheduleAccept());},r=>{this.view.dispatch({effects:me.of(null)}),vt$1(this.view.state,r);});}scheduleAccept(){this.running.every(t=>t.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(A).updateSyncTime));}accept(){var t;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],o=this.view.state.facet(A),n=this.view.state.field(M);for(let i=0;i<this.running.length;i++){let r=this.running[i];if(r.done===void 0)continue;if(this.running.splice(i--,1),r.done){let l=X(r.updates.length?r.updates[0].startState:this.view.state),a=Math.min(l,r.done.from+(r.active.explicit?0:1)),f=new ne(r.active.source,r.active.explicit,a,r.done,r.done.from,(t=r.done.to)!==null&&t!==void 0?t:l);for(let c of r.updates)f=f.update(c,o);if(f.hasResult()){e.push(f);continue}}let s=n.active.find(l=>l.source==r.active.source);if(s&&s.isPending)if(r.done==null){let l=new R(r.active.source,0);for(let a of r.updates)l=l.update(a,o);l.isPending||e.push(l);}else this.startQuery(s);}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:ht.of(e)});}},{eventHandlers:{blur(t){let e=this.view.state.field(M,false);if(e&&e.tooltip&&this.view.state.facet(A).closeOnBlur){let o=e.open&&su(this.view,e.open.tooltip);(!o||!o.dom.contains(t.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:me.of(null)}),10);}},compositionstart(){this.composing=1;},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:Le.of(false)}),20),this.composing=0;}}});const Nr=typeof navigator=="object"&&/Win/.test(navigator.platform);$i$1.highest(B.domEventHandlers({keydown(t,e){let o=e.state.field(M,false);if(!o||!o.open||o.open.disabled||o.open.selected<0||t.key.length>1||t.ctrlKey&&!(Nr&&t.altKey)||t.metaKey)return  false;let n=o.open.options[o.open.selected],i=o.active.find(s=>s.source==n.source),r=n.completion.commitCharacters||i.result.commitCharacters;return r&&r.indexOf(t.key)>-1&&mt(e,n),false}}));B.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:"400px",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:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&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"}}});const pe={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Y=U.define({map(t,e){let o=e.mapPos(t,-1,at.TrackAfter);return o??void 0}}),pt=new class extends le$1{};pt.startSide=1;pt.endSide=-1;const Qo=Ft$1.define({create(){return L.empty},update(t,e){if(t=t.map(e.changes),e.selection){let o=e.state.doc.lineAt(e.selection.main.head);t=t.update({filter:n=>n>=o.from&&n<=o.to});}for(let o of e.effects)o.is(Y)&&(t=t.update({add:[pt.range(o.value,o.value+1)]}));return t}});function $r(){return [Hr,Qo]}const We="()[]{}<>«»»«［］｛｝";function Yo(t){for(let e=0;e<We.length;e+=2)if(We.charCodeAt(e)==t)return We.charAt(e+1);return Yc(t<128?t:t+1)}function Xo(t,e){return t.languageDataAt("closeBrackets",e)[0]||pe}const Wr=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Hr=B.inputHandler.of((t,e,o,n)=>{if((Wr?t.composing:t.compositionStarted)||t.state.readOnly)return  false;let i=t.state.selection.main;if(n.length>2||n.length==2&&Jl(ro(n,0))==1||e!=i.from||o!=i.to)return  false;let r=qr(t.state,n);return r?(t.dispatch(r),true):false}),Vr=({state:t,dispatch:e})=>{if(t.readOnly)return  false;let n=Xo(t,t.selection.main.head).brackets||pe.brackets,i=null,r=t.changeByRange(s=>{if(s.empty){let l=jr(t.doc,s.head);for(let a of n)if(a==l&&_e(t.doc,s.head)==Yo(ro(a,0)))return {changes:{from:s.head-a.length,to:s.head+a.length},range:C.cursor(s.head-a.length)}}return {range:i=s}});return i||e(t.update(r,{scrollIntoView:true,userEvent:"delete.backward"})),!i},zr=[{key:"Backspace",run:Vr}];function qr(t,e){let o=Xo(t,t.selection.main.head),n=o.brackets||pe.brackets;for(let i of n){let r=Yo(ro(i,0));if(e==i)return r==i?Jr(t,i,n.indexOf(i+i+i)>-1,o):Gr(t,i,r,o.before||pe.before);if(e==r&&Zo(t,t.selection.main.from))return Kr(t,i,r)}return null}function Zo(t,e){let o=false;return t.field(Qo).between(0,t.doc.length,n=>{n==e&&(o=true);}),o}function _e(t,e){let o=t.sliceString(e,e+2);return o.slice(0,Jl(ro(o,0)))}function jr(t,e){let o=t.sliceString(e-2,e);return Jl(ro(o,0))==o.length?o:o.slice(1)}function Gr(t,e,o,n){let i=null,r=t.changeByRange(s=>{if(!s.empty)return {changes:[{insert:e,from:s.from},{insert:o,from:s.to}],effects:Y.of(s.to+e.length),range:C.range(s.anchor+e.length,s.head+e.length)};let l=_e(t.doc,s.head);return !l||/\s/.test(l)||n.indexOf(l)>-1?{changes:{insert:e+o,from:s.head},effects:Y.of(s.head+e.length),range:C.cursor(s.head+e.length)}:{range:i=s}});return i?null:t.update(r,{scrollIntoView:true,userEvent:"input.type"})}function Kr(t,e,o){let n=null,i=t.changeByRange(r=>r.empty&&_e(t.doc,r.head)==o?{changes:{from:r.head,to:r.head+o.length,insert:o},range:C.cursor(r.head+o.length)}:n={range:r});return n?null:t.update(i,{scrollIntoView:true,userEvent:"input.type"})}function Jr(t,e,o,n){let i=n.stringPrefixes||pe.stringPrefixes,r=null,s=t.changeByRange(l=>{if(!l.empty)return {changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Y.of(l.to+e.length),range:C.range(l.anchor+e.length,l.head+e.length)};let a=l.head,f=_e(t.doc,a),c;if(f==e){if(Pt(t,a))return {changes:{insert:e+e,from:a},effects:Y.of(a+e.length),range:C.cursor(a+e.length)};if(Zo(t,a)){let m=o&&t.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return {changes:{from:a,to:a+m.length,insert:m},range:C.cursor(a+m.length)}}}else {if(o&&t.sliceDoc(a-2*e.length,a)==e+e&&(c=_t(t,a-2*e.length,i))>-1&&Pt(t,c))return {changes:{insert:e+e+e+e,from:a},effects:Y.of(a+e.length),range:C.cursor(a+e.length)};if(t.charCategorizer(a)(f)!=Nt$1.Word&&_t(t,a,i)>-1&&!Qr(t,a,e,i))return {changes:{insert:e+e,from:a},effects:Y.of(a+e.length),range:C.cursor(a+e.length)}}return {range:r=l}});return r?null:t.update(s,{scrollIntoView:true,userEvent:"input.type"})}function Pt(t,e){let o=Rt$1(t).resolveInner(e+1);return o.parent&&o.from==e}function Qr(t,e,o,n){let i=Rt$1(t).resolveInner(e,-1),r=n.reduce((s,l)=>Math.max(s,l.length),0);for(let s=0;s<5;s++){let l=t.sliceDoc(i.from,Math.min(i.to,i.from+o.length+r)),a=l.indexOf(o);if(!a||a>-1&&n.indexOf(l.slice(0,a))>-1){let c=i.firstChild;for(;c&&c.from==i.from&&c.to-c.from>o.length+a;){if(t.sliceDoc(c.to-o.length,c.to)==o)return  false;c=c.firstChild;}return  true}let f=i.to==e&&i.parent;if(!f)break;i=f;}return  false}function _t(t,e,o){let n=t.charCategorizer(e);if(n(t.sliceDoc(e-1,e))!=Nt$1.Word)return e;for(let i of o){let r=e-i.length;if(t.sliceDoc(r,e)==i&&n(t.sliceDoc(r-1,r))!=Nt$1.Word)return r}return  -1}const en=[{key:"Ctrl-Space",run:$e},{mac:"Alt-`",run:$e},{mac:"Alt-i",run:$e},{key:"Escape",run:Or},{key:"ArrowDown",run:xe(true)},{key:"ArrowUp",run:xe(false)},{key:"PageDown",run:xe(true,"page")},{key:"PageUp",run:xe(false,"page")},{key:"Enter",run:Jo}];$i$1.highest(Jh.computeN([A],t=>t.facet(A).defaultKeymap?[en]:[]));const Zr="#2E3235",W="#DDDDDD",de="#B9D2FF",Ce="#b0b0b0",es="#e0e0e0",tn="#808080",He="#000000",ts="#A54543",on="#fc6d24",J="#fda331",Ve="#8abeb7",Nt="#b5bd68",ce="#6fb3d2",fe="#cc99cc",os="#6987AF",Ut=on,Ft="#292d30",ve=de+"30",ns=Zr,ze=W,is="#202325",$t=W,rs=B.theme({"&":{color:W,backgroundColor:ns},".cm-content":{caretColor:$t},".cm-cursor, .cm-dropCursor":{borderLeftColor:$t},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:is},".cm-panels":{backgroundColor:Ft,color:Ce},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:de,outline:`1px solid ${Ce}`,color:He},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:es,color:He},".cm-activeLine":{backgroundColor:ve},".cm-selectionMatch":{backgroundColor:ve},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Ce}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:de,color:He},".cm-gutters":{borderRight:"1px solid #ffffff10",color:tn,backgroundColor:Ft},".cm-activeLineGutter":{backgroundColor:ve},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:de},".cm-tooltip":{border:"none",backgroundColor:ze},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:ze,borderBottomColor:ze},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ve,color:Ce}}},{dark:true}),ss=es$1.define([{tag:k$1.keyword,color:J},{tag:[k$1.name,k$1.deleted,k$1.character,k$1.propertyName,k$1.macroName],color:Nt},{tag:[k$1.variableName],color:ce},{tag:[k$1.function(k$1.variableName)],color:J},{tag:[k$1.labelName],color:on},{tag:[k$1.color,k$1.constant(k$1.name),k$1.standard(k$1.name)],color:J},{tag:[k$1.definition(k$1.name),k$1.separator],color:fe},{tag:[k$1.brace],color:fe},{tag:[k$1.annotation],color:Ut},{tag:[k$1.number,k$1.changed,k$1.annotation,k$1.modifier,k$1.self,k$1.namespace],color:J},{tag:[k$1.typeName,k$1.className],color:ce},{tag:[k$1.operator,k$1.operatorKeyword],color:fe},{tag:[k$1.tagName],color:J},{tag:[k$1.squareBracket],color:fe},{tag:[k$1.angleBracket],color:fe},{tag:[k$1.attributeName],color:ce},{tag:[k$1.regexp],color:J},{tag:[k$1.quote],color:W},{tag:[k$1.string],color:Nt},{tag:k$1.link,color:os,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[k$1.url,k$1.escape,k$1.special(k$1.string)],color:Ve},{tag:[k$1.meta],color:ts},{tag:[k$1.comment],color:tn,fontStyle:"italic"},{tag:k$1.monospace,color:W},{tag:k$1.strong,fontWeight:"bold",color:J},{tag:k$1.emphasis,fontStyle:"italic",color:ce},{tag:k$1.strikethrough,textDecoration:"line-through"},{tag:k$1.heading,fontWeight:"bold",color:W},{tag:k$1.special(k$1.heading1),fontWeight:"bold",color:W},{tag:k$1.heading1,fontWeight:"bold",color:W},{tag:[k$1.heading2,k$1.heading3,k$1.heading4],fontWeight:"bold",color:W},{tag:[k$1.heading5,k$1.heading6],color:W},{tag:[k$1.atom,k$1.bool,k$1.special(k$1.variableName)],color:Ve},{tag:[k$1.processingInstruction,k$1.inserted],color:Ve},{tag:[k$1.contentSeparator],color:ce},{tag:k$1.invalid,color:de,borderBottom:`1px dotted ${Ut}`}]);[rs,fu(ss)];const Wt="#2e3440",gt="#3b4252",Ht="#434c5e",Se="#4c566a",Vt="#e5e9f0",it="#eceff4",qe="#8fbcbb",zt="#88c0d0",as="#81a1c1",_="#5e81ac",cs="#bf616a",ee="#d08770",je="#ebcb8b",qt="#a3be8c",fs="#b48ead",jt="#d30102",yt=it,Ge=yt,us="#ffffff",Ke=gt,ds=yt,Gt=gt,hs=B.theme({"&":{color:Wt,backgroundColor:us},".cm-content":{caretColor:Gt},".cm-cursor, .cm-dropCursor":{borderLeftColor:Gt},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:ds},".cm-panels":{backgroundColor:yt,color:Se},".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 ${Se}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:Vt},".cm-activeLine":{backgroundColor:Ge},".cm-selectionMatch":{backgroundColor:Vt},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Se}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:it},".cm-gutters":{backgroundColor:it,color:Wt,border:"none"},".cm-activeLineGutter":{backgroundColor:Ge},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:Ke},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Ke,borderBottomColor:Ke},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ge,color:Se}}},{dark:false}),ms=es$1.define([{tag:k$1.keyword,color:_},{tag:[k$1.name,k$1.deleted,k$1.character,k$1.propertyName,k$1.macroName],color:ee},{tag:[k$1.variableName],color:ee},{tag:[k$1.function(k$1.variableName)],color:_},{tag:[k$1.labelName],color:as},{tag:[k$1.color,k$1.constant(k$1.name),k$1.standard(k$1.name)],color:_},{tag:[k$1.definition(k$1.name),k$1.separator],color:qt},{tag:[k$1.brace],color:qe},{tag:[k$1.annotation],color:jt},{tag:[k$1.number,k$1.changed,k$1.annotation,k$1.modifier,k$1.self,k$1.namespace],color:zt},{tag:[k$1.typeName,k$1.className],color:je},{tag:[k$1.operator,k$1.operatorKeyword],color:qt},{tag:[k$1.tagName],color:fs},{tag:[k$1.squareBracket],color:cs},{tag:[k$1.angleBracket],color:ee},{tag:[k$1.attributeName],color:je},{tag:[k$1.regexp],color:_},{tag:[k$1.quote],color:gt},{tag:[k$1.string],color:ee},{tag:k$1.link,color:qe,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[k$1.url,k$1.escape,k$1.special(k$1.string)],color:ee},{tag:[k$1.meta],color:zt},{tag:[k$1.comment],color:Ht,fontStyle:"italic"},{tag:k$1.strong,fontWeight:"bold",color:_},{tag:k$1.emphasis,fontStyle:"italic",color:_},{tag:k$1.strikethrough,textDecoration:"line-through"},{tag:k$1.heading,fontWeight:"bold",color:_},{tag:k$1.special(k$1.heading1),fontWeight:"bold",color:_},{tag:k$1.heading1,fontWeight:"bold",color:_},{tag:[k$1.heading2,k$1.heading3,k$1.heading4],fontWeight:"bold",color:_},{tag:[k$1.heading5,k$1.heading6],color:_},{tag:[k$1.atom,k$1.bool,k$1.special(k$1.variableName)],color:ee},{tag:[k$1.processingInstruction,k$1.inserted],color:qe},{tag:[k$1.contentSeparator],color:je},{tag:k$1.invalid,color:Ht,borderBottom:`1px dotted ${jt}`}]);[hs,fu(ms)];class Kt{constructor(e,o,n){this.from=e,this.to=o,this.diagnostic=n;}}class Q{constructor(e,o,n){this.diagnostics=e,this.panel=o,this.selected=n;}static init(e,o,n){let i=n.facet(ge).markerFilter;i&&(e=i(e,n));let r=e.slice().sort((h,p)=>h.from-p.from||h.to-p.to),s=new ae$1,l=[],a=0,f=n.doc.iter(),c=0,d=n.doc.length;for(let h=0;;){let p=h==r.length?null:r[h];if(!p&&!l.length)break;let y,x;if(l.length)y=a,x=l.reduce((b,v)=>Math.min(b,v.to),p&&p.from>y?p.from:1e8);else {if(y=p.from,y>d)break;x=p.to,l.push(p),h++;}for(;h<r.length;){let b=r[h];if(b.from==y&&(b.to>b.from||b.to==y))l.push(b),h++,x=Math.min(b.to,x);else {x=Math.min(b.from,x);break}}x=Math.min(x,d);let B=false;if(l.some(b=>b.from==y&&(b.to==x||x==d))&&(B=y==x,!B&&x-y<10)){let b=y-(c+f.value.length);b>0&&(f.next(b),c=y);for(let v=y;;){if(v>=x){B=true;break}if(!f.lineBreak&&c+f.value.length>v)break;v=c+f.value.length,c+=f.value.length,f.next();}}let k=Ls(l);if(B)s.add(y,y,F$1.widget({widget:new ws(k),diagnostics:l.slice()}));else {let b=l.reduce((v,w)=>w.markClass?v+" "+w.markClass:v,"");s.add(y,x,F$1.mark({class:"cm-lintRange cm-lintRange-"+k+b,diagnostics:l.slice(),inclusiveEnd:l.some(v=>v.to>x)}));}if(a=x,a==d)break;for(let b=0;b<l.length;b++)l[b].to<=a&&l.splice(b--,1);}let m=s.finish();return new Q(m,o,re(m))}}function re(t,e=null,o=0){let n=null;return t.between(o,1e9,(i,r,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!n)n=new Kt(i,r,e||s.diagnostics[0]);else {if(s.diagnostics.indexOf(n.diagnostic)<0)return  false;n=new Kt(n.from,r,n.diagnostic);}}),n}function gs(t,e){let o=e.pos,n=e.end||o,i=t.state.facet(ge).hideOn(t,o,n);if(i!=null)return i;let r=t.startState.doc.lineAt(e.pos);return !!(t.effects.some(s=>s.is(nn))||t.changes.touchesRange(r.from,Math.max(r.to,n)))}function ys(t,e){return t.field(I,false)?e:e.concat(U.appendConfig.of(Ms))}const nn=U.define(),bt=U.define(),rn=U.define(),I=Ft$1.define({create(){return new Q(F$1.none,null,null)},update(t,e){if(e.docChanged&&t.diagnostics.size){let o=t.diagnostics.map(e.changes),n=null,i=t.panel;if(t.selected){let r=e.changes.mapPos(t.selected.from,1);n=re(o,t.selected.diagnostic,r)||re(o,null,r);}!o.size&&i&&e.state.facet(ge).autoPanel&&(i=null),t=new Q(o,i,n);}for(let o of e.effects)if(o.is(nn)){let n=e.state.facet(ge).autoPanel?o.value.length?ye.open:null:t.panel;t=Q.init(o.value,n,e.state);}else o.is(bt)?t=new Q(t.diagnostics,o.value?ye.open:null,t.selected):o.is(rn)&&(t=new Q(t.diagnostics,t.panel,o.value));return t},provide:t=>[Ir$1.from(t,e=>e.panel),B.decorations.from(t,e=>e.diagnostics)]}),bs=F$1.mark({class:"cm-lintRange cm-lintRange-active"});function ks(t,e,o){let{diagnostics:n}=t.state.field(I),i,r=-1,s=-1;n.between(e-(o<0?1:0),e+(o>0?1:0),(a,f,{spec:c})=>{if(e>=a&&e<=f&&(a==f||(e>a||o>0)&&(e<f||o<0)))return i=c.diagnostics,r=a,s=f,false});let l=t.state.facet(ge).tooltipFilter;return i&&l&&(i=l(i,t.state)),i?{pos:r,end:s,above:t.state.doc.lineAt(r).to<s,create(){return {dom:xs(t,i)}}}:null}function xs(t,e){return H("ul",{class:"cm-tooltip-lint"},e.map(o=>ln(t,o,false)))}const Cs=t=>{let e=t.state.field(I,false);(!e||!e.panel)&&t.dispatch({effects:ys(t.state,[bt.of(true)])});let o=nu(t,ye.open);return o&&o.dom.querySelector(".cm-panel-lint ul").focus(),true},Jt=t=>{let e=t.state.field(I,false);return !e||!e.panel?false:(t.dispatch({effects:bt.of(false)}),true)},vs=t=>{let e=t.state.field(I,false);if(!e)return  false;let o=t.state.selection.main,n=e.diagnostics.iter(o.to+1);return !n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==o.from&&n.to==o.to)?false:(t.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:true}),true)},Ss=[{key:"Mod-Shift-m",run:Cs,preventDefault:true},{key:"F8",run:vs}],ge=A$1.define({combine(t){return {sources:t.map(e=>e.source).filter(e=>e!=null),..._i$1(t.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Qt,tooltipFilter:Qt,needsRefresh:(e,o)=>e?o?n=>e(n)||o(n):e:o,hideOn:(e,o)=>e?o?(n,i,r)=>e(n,i,r)||o(n,i,r):e:o,autoPanel:(e,o)=>e||o})}}});function Qt(t,e){return t?e?(o,n)=>e(t(o,n),n):t:e}function sn(t){let e=[];if(t)e:for(let{name:o}of t){for(let n=0;n<o.length;n++){let i=o[n];if(/[a-zA-Z]/.test(i)&&!e.some(r=>r.toLowerCase()==i.toLowerCase())){e.push(i);continue e}}e.push("");}return e}function ln(t,e,o){var n;let i=o?sn(e.actions):[];return H("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},H("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(t):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((r,s)=>{let l=false,a=h=>{if(h.preventDefault(),l)return;l=true;let p=re(t.state.field(I).diagnostics,e);p&&r.apply(t,p.from,p.to);},{name:f}=r,c=i[s]?f.indexOf(i[s]):-1,d=c<0?f:[f.slice(0,c),H("u",f.slice(c,c+1)),f.slice(c+1)],m=r.markClass?" "+r.markClass:"";return H("button",{type:"button",class:"cm-diagnosticAction"+m,onclick:a,onmousedown:a,"aria-label":` Action: ${f}${c<0?"":` (access key "${i[s]})"`}.`},d)}),e.source&&H("div",{class:"cm-diagnosticSource"},e.source))}class ws extends zt$1{constructor(e){super(),this.sev=e;}eq(e){return e.sev==this.sev}toDOM(){return H("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Yt{constructor(e,o){this.diagnostic=o,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=ln(e,o,true),this.dom.id=this.id,this.dom.setAttribute("role","option");}}class ye{constructor(e){this.view=e,this.items=[];let o=i=>{if(i.keyCode==27)Jt(this.view),this.view.focus();else if(i.keyCode==38||i.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(i.keyCode==40||i.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(i.keyCode==36)this.moveSelection(0);else if(i.keyCode==35)this.moveSelection(this.items.length-1);else if(i.keyCode==13)this.view.focus();else if(i.keyCode>=65&&i.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],s=sn(r.actions);for(let l=0;l<s.length;l++)if(s[l].toUpperCase().charCodeAt(0)==i.keyCode){let a=re(this.view.state.field(I).diagnostics,r);a&&r.actions[l].apply(e,a.from,a.to);}}else return;i.preventDefault();},n=i=>{for(let r=0;r<this.items.length;r++)this.items[r].dom.contains(i.target)&&this.moveSelection(r);};this.list=H("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:o,onclick:n}),this.dom=H("div",{class:"cm-panel-lint"},this.list,H("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>Jt(this.view)},"×")),this.update();}get selectedIndex(){let e=this.view.state.field(I).selected;if(!e)return  -1;for(let o=0;o<this.items.length;o++)if(this.items[o].diagnostic==e.diagnostic)return o;return  -1}update(){let{diagnostics:e,selected:o}=this.view.state.field(I),n=0,i=false,r=null,s=new Set;for(e.between(0,this.view.state.doc.length,(l,a,{spec:f})=>{for(let c of f.diagnostics){if(s.has(c))continue;s.add(c);let d=-1,m;for(let h=n;h<this.items.length;h++)if(this.items[h].diagnostic==c){d=h;break}d<0?(m=new Yt(this.view,c),this.items.splice(n,0,m),i=true):(m=this.items[d],d>n&&(this.items.splice(n,d-n),i=true)),o&&m.diagnostic==o.diagnostic?m.dom.hasAttribute("aria-selected")||(m.dom.setAttribute("aria-selected","true"),r=m):m.dom.hasAttribute("aria-selected")&&m.dom.removeAttribute("aria-selected"),n++;}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)i=true,this.items.pop();this.items.length==0&&(this.items.push(new Yt(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),i=true),r?(this.list.setAttribute("aria-activedescendant",r.id),this.view.requestMeasure({key:this,read:()=>({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:a})=>{let f=a.height/this.list.offsetHeight;l.top<a.top?this.list.scrollTop-=(a.top-l.top)/f:l.bottom>a.bottom&&(this.list.scrollTop+=(l.bottom-a.bottom)/f);}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),i&&this.sync();}sync(){let e=this.list.firstChild;function o(){let n=e;e=n.nextSibling,n.remove();}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)o();e=n.dom.nextSibling;}else this.list.insertBefore(n.dom,e);for(;e;)o();}moveSelection(e){if(this.selectedIndex<0)return;let o=this.view.state.field(I),n=re(o.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:true,effects:rn.of(n)});}static open(e){return new ye(e)}}function As(t,e='viewBox="0 0 40 40"'){return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(t)}</svg>')`}function we(t){return As(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${t}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const Bs=B.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:we("#d11")},".cm-lintRange-warning":{backgroundImage:we("orange")},".cm-lintRange-info":{backgroundImage:we("#999")},".cm-lintRange-hint":{backgroundImage:we("#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 Ds(t){return t=="error"?4:t=="warning"?3:t=="info"?2:1}function Ls(t){let e="hint",o=1;for(let n of t){let i=Ds(n.severity);i>o&&(o=i,e=n.severity);}return e}const Ms=[I,B.decorations.compute([I],t=>{let{selected:e,panel:o}=t.field(I);return !e||!o||e.from==e.to?F$1.none:F$1.set([bs.range(e.from,e.to)])}),iu(ks,{hideOn:gs}),Bs];[Qc(),fi(),hu(),Jc(),H$1.allowMultipleSelections.of(true),lu(),fu(cu,{fallback:true}),$r(),tu(),eu(),Jh.of([...zr,...dr,...ki,...au,...en,...Ss])];function Is(t,e){t.component(o=>{let {class_names:n="",value:i=void 0,dark_mode:r,basic:s=true,language:l,lines:a=5,max_lines:f=null,extensions:c=[],use_tab:d=true,readonly:m=false,placeholder:h=void 0,wrap_lines:p=false,show_line_numbers:y=true,autocomplete:x=false,onchange:B$1,onblur:k,onfocus:b,oninput:v}=e;B.theme({"&":{fontSize:"var(--text-sm)",backgroundColor:"var(--border-color-secondary)"},".cm-content":{paddingTop:"5px",paddingBottom:"5px",color:"var(--body-text-color)",fontFamily:"var(--font-mono)",minHeight:"100%"},".cm-gutterElement":{marginRight:"var(--spacing-xs)"},".cm-gutters":{marginRight:"1px",borderRight:"1px solid var(--border-color-primary)",backgroundColor:"var(--block-background-fill);",color:"var(--body-text-color-subdued)"},".cm-focused":{outline:"none"},".cm-scroller":{height:"auto"},".cm-cursor":{borderLeftColor:"var(--body-text-color)"}});B.theme({".cm-tooltip-autocomplete":{"& > ul":{backgroundColor:"var(--background-fill-primary)",color:"var(--body-text-color)"},"& > ul > li[aria-selected]":{backgroundColor:"var(--color-accent-soft)",color:"var(--body-text-color)"}}});o.push(`<div class="wrap svelte-pndh99"><div${attr_class(`codemirror-wrapper ${stringify(n)}`,"svelte-pndh99")}></div></div>`),bind_props(e,{value:i});});}function Os(t,e$1){t.component(o=>{let{value:n}=e$1,i=false,r;function s(){i=true,r&&clearTimeout(r),r=setTimeout(()=>{i=false;},2e3);}async function l(){"clipboard"in navigator&&(await navigator.clipboard.writeText(n),s());}onDestroy(()=>{r&&clearTimeout(r);}),w(o,{Icon:i?e:h,label:"Copy",onclick:l});});}function Es(t,e$1){t.component(o=>{let{value:n,language:i}=e$1,r=s(i);function s(d){return {py:"py",python:"py",md:"md",markdown:"md",json:"json",html:"html",css:"css",js:"js",javascript:"js",ts:"ts",typescript:"ts",yaml:"yaml",yml:"yml",dockerfile:"dockerfile",sh:"sh",shell:"sh",r:"r",c:"c",cpp:"cpp",latex:"tex"}[d]||"txt"}let l$1=false,a;function f(){l$1=true,a&&clearTimeout(a),a=setTimeout(()=>{l$1=false;},2e3);}let c=URL.createObjectURL(new Blob([n]));onDestroy(()=>{a&&clearTimeout(a);}),u(o,{download:`file.${stringify(r)}`,href:c,onclick:f,children:d=>{w(d,{Icon:l$1?e:l,label:"Download"});},$$slots:{default:true}});});}function Rs(t,e){t.component(o=>{let{value:n,language:i,buttons:r=null,on_custom_button_click:s=null}=e;y(o,{buttons:r,on_custom_button_click:s,children:l=>{r?.some(a=>typeof a=="string"&&a==="download")?(l.push("<!--[-->"),Es(l,{value:n,language:i})):l.push("<!--[!-->"),l.push("<!--]--> "),r?.some(a=>typeof a=="string"&&a==="copy")?(l.push("<!--[-->"),Os(l,{value:n})):l.push("<!--[!-->"),l.push("<!--]-->");}});});}function tl(t,e){t.component(o=>{const{$$slots:n,$$events:i$1,...r}=e,s=new $$1(r);let l=s.shared.theme==="dark",a=s.shared.label||s.i18n("code.code");s.props.value;let f=true,c;function d(m){G$1(m,{height:s.props.max_lines&&"fit-content",variant:"solid",padding:false,elem_id:s.shared.elem_id,elem_classes:s.shared.elem_classes,visible:s.shared.visible,scale:s.shared.scale,min_width:s.shared.min_width,children:h=>{W$1(h,spread_props([{autoscroll:s.shared.autoscroll,i18n:s.i18n},s.shared.loading_status,{on_clear_status:()=>s.dispatch("clear_status",s.shared.loading_status)}])),h.push("<!----> "),s.shared.show_label?(h.push("<!--[-->"),k(h,{Icon:i,show_label:s.shared.show_label,label:a,float:false})):h.push("<!--[!-->"),h.push("<!--]--> "),!s.props.value&&!s.shared.interactive?(h.push("<!--[-->"),p(h,{unpadded_box:true,size:"large",children:p=>{i(p);},$$slots:{default:true}})):(h.push("<!--[!-->"),Rs(h,{language:s.props.language,value:s.props.value,buttons:s.props.buttons??["copy","download"],on_custom_button_click:p=>{s.dispatch("custom_button_click",{id:p});}}),h.push("<!----> "),Is(h,{language:s.props.language,lines:s.props.lines,max_lines:s.props.max_lines,dark_mode:l,wrap_lines:s.props.wrap_lines,show_line_numbers:s.props.show_line_numbers,autocomplete:s.props.autocomplete,readonly:!s.shared.interactive,onblur:()=>s.dispatch("blur"),onfocus:()=>s.dispatch("focus"),oninput:()=>s.dispatch("input"),get value(){return s.props.value},set value(p){s.props.value=p,f=false;}}),h.push("<!---->")),h.push("<!--]-->");},$$slots:{default:true}});}do f=true,c=o.copy(),d(c);while(!f);o.subsume(c);});}

export { Is as BaseCode, Os as BaseCopy, Es as BaseDownload, Rs as BaseWidget, tl as default };
//# sourceMappingURL=Index52-Ct2COUi7.js.map
