UNPKG

code-server

Version:

Run VS Code on a remote server.

149 lines • 514 kB
import{n as vo}from"./chunk-YNKYB66X.js";import{a as Im,b as Mm,c as Nm}from"./chunk-OOJM4CTU.js";var Ld=Im((rI,Jo)=>{(function(){var t;typeof Jo<"u"?t=Jo.exports=i:t=(function(){return this||(0,eval)("this")})(),t.format=i,t.vsprintf=n,typeof console<"u"&&typeof console.log=="function"&&(t.printf=e);function e(){console.log(i.apply(null,arguments))}function n(r,s){return i.apply(null,[r].concat(s))}function i(r){for(var s=1,o=[].slice.call(arguments),a=0,l=r.length,c="",d,h=!1,u,f,m=!1,p,v=function(){return o[s++]},g=function(){for(var w="";/\d/.test(r[a]);)w+=r[a++],d=r[a];return w.length>0?parseInt(w):null};a<l;++a)if(d=r[a],h)switch(h=!1,d=="."?(m=!1,d=r[++a]):d=="0"&&r[a+1]=="."?(m=!0,a+=2,d=r[a]):m=!0,p=g(),d){case"b":c+=parseInt(v(),10).toString(2);break;case"c":u=v(),typeof u=="string"||u instanceof String?c+=u:c+=String.fromCharCode(parseInt(u,10));break;case"d":c+=parseInt(v(),10);break;case"f":f=String(parseFloat(v()).toFixed(p||6)),c+=m?f:f.replace(/^0/,"");break;case"j":c+=JSON.stringify(v());break;case"o":c+="0"+parseInt(v(),10).toString(8);break;case"s":c+=v();break;case"x":c+="0x"+parseInt(v(),10).toString(16);break;case"X":c+="0x"+parseInt(v(),10).toString(16).toUpperCase();break;default:c+=d;break}else d==="%"?h=!0:c+=d;return c}})()});var Z=["macos"],Ve=["windows","linux"],de=(t,e=!1)=>({kind:"cursor",command:t,extend:e}),zn=t=>({kind:"edit",command:t}),Mc=t=>({kind:"history",command:t}),Nc=t=>({kind:"tab",command:t}),bo=t=>({kind:"enter",command:t}),R=(t,e,n)=>({key:t,modifiers:e,platforms:n}),j=(t,e,n,i,r="host")=>({id:t,title:e,action:n,keybindings:i,routing:r}),En=[j("markdown.editor.cursorLeft","Move Cursor Left",de("left"),[R("b",{ctrl:!0},Z),R("ArrowLeft")]),j("markdown.editor.cursorRight","Move Cursor Right",de("right"),[R("f",{ctrl:!0},Z),R("ArrowRight")]),j("markdown.editor.cursorUp","Move Cursor Up",de("up"),[R("p",{ctrl:!0},Z),R("ArrowUp")]),j("markdown.editor.cursorDown","Move Cursor Down",de("down"),[R("n",{ctrl:!0},Z),R("ArrowDown")]),j("markdown.editor.cursorLeftSelect","Select Left",de("left",!0),[R("ArrowLeft",{shift:!0})]),j("markdown.editor.cursorRightSelect","Select Right",de("right",!0),[R("ArrowRight",{shift:!0})]),j("markdown.editor.cursorUpSelect","Select Up",de("up",!0),[R("ArrowUp",{shift:!0})]),j("markdown.editor.cursorDownSelect","Select Down",de("down",!0),[R("ArrowDown",{shift:!0})]),j("markdown.editor.cursorWordLeft","Move Cursor Word Left",de("wordLeft"),[R("ArrowLeft",{alt:!0},Z),R("ArrowLeft",{ctrl:!0},Ve)]),j("markdown.editor.cursorWordRight","Move Cursor Word Right",de("wordRight"),[R("ArrowRight",{alt:!0},Z),R("ArrowRight",{ctrl:!0},Ve)]),j("markdown.editor.cursorWordLeftSelect","Select Word Left",de("wordLeft",!0),[R("ArrowLeft",{alt:!0,shift:!0},Z),R("ArrowLeft",{ctrl:!0,shift:!0},Ve)]),j("markdown.editor.cursorWordRightSelect","Select Word Right",de("wordRight",!0),[R("ArrowRight",{alt:!0,shift:!0},Z),R("ArrowRight",{ctrl:!0,shift:!0},Ve)]),j("markdown.editor.cursorVisualLineStart","Move Cursor to Visual Line Start",de("visualLineStart"),[R("ArrowLeft",{meta:!0},Z),R("Home")]),j("markdown.editor.cursorVisualLineEnd","Move Cursor to Visual Line End",de("visualLineEnd"),[R("ArrowRight",{meta:!0},Z),R("End")]),j("markdown.editor.cursorVisualLineStartSelect","Select to Visual Line Start",de("visualLineStart",!0),[R("ArrowLeft",{meta:!0,shift:!0},Z),R("Home",{shift:!0})]),j("markdown.editor.cursorVisualLineEndSelect","Select to Visual Line End",de("visualLineEnd",!0),[R("ArrowRight",{meta:!0,shift:!0},Z),R("End",{shift:!0})]),j("markdown.editor.cursorLogicalLineStart","Move Cursor to Logical Line Start",de("logicalLineStart"),[R("a",{ctrl:!0},Z)]),j("markdown.editor.cursorLogicalLineEnd","Move Cursor to Logical Line End",de("logicalLineEnd"),[R("e",{ctrl:!0},Z)]),j("markdown.editor.cursorLogicalLineStartSelect","Select to Logical Line Start",de("logicalLineStart",!0),[R("a",{ctrl:!0,shift:!0},Z)]),j("markdown.editor.cursorLogicalLineEndSelect","Select to Logical Line End",de("logicalLineEnd",!0),[R("e",{ctrl:!0,shift:!0},Z)]),j("markdown.editor.cursorDocumentStart","Move Cursor to Document Start",de("documentStart"),[R("ArrowUp",{meta:!0},Z),R("Home",{ctrl:!0},Ve)]),j("markdown.editor.cursorDocumentEnd","Move Cursor to Document End",de("documentEnd"),[R("ArrowDown",{meta:!0},Z),R("End",{ctrl:!0},Ve)]),j("markdown.editor.cursorDocumentStartSelect","Select to Document Start",de("documentStart",!0),[R("ArrowUp",{meta:!0,shift:!0},Z),R("Home",{ctrl:!0,shift:!0},Ve)]),j("markdown.editor.cursorDocumentEndSelect","Select to Document End",de("documentEnd",!0),[R("ArrowDown",{meta:!0,shift:!0},Z),R("End",{ctrl:!0,shift:!0},Ve)]),j("markdown.editor.selectAll","Select All",{kind:"selectAll"},[R("a",{meta:!0},Z),R("a",{ctrl:!0},Ve)]),j("markdown.editor.deleteLeft","Delete Left",zn("deleteLeft"),[R("h",{ctrl:!0},Z),R("Backspace",{ctrl:!0},Z),R("Backspace"),R("Backspace",{shift:!0})]),j("markdown.editor.deleteRight","Delete Right",zn("deleteRight"),[R("d",{ctrl:!0},Z),R("Delete",{ctrl:!0},Z),R("Delete")]),j("markdown.editor.deleteWordLeft","Delete Word Left",zn("deleteWordLeft"),[R("Backspace",{alt:!0},Z),R("Backspace",{ctrl:!0},Ve)]),j("markdown.editor.deleteWordRight","Delete Word Right",zn("deleteWordRight"),[R("Delete",{alt:!0},Z),R("Delete",{ctrl:!0},Ve)]),j("markdown.editor.deleteLineLeft","Delete All Left",zn("deleteLineLeft"),[R("Backspace",{meta:!0},Z)]),j("markdown.editor.deleteLineRight","Delete All Right",zn("deleteLineRight"),[R("Delete",{meta:!0},Z),R("k",{ctrl:!0},Z)]),j("markdown.editor.undo","Undo",Mc("undo"),[R("z",{meta:!0},Z),R("z",{ctrl:!0},Ve)]),j("markdown.editor.redo","Redo",Mc("redo"),[R("z",{meta:!0,shift:!0},Z),R("z",{ctrl:!0,shift:!0},Ve),R("y",{ctrl:!0},Ve)]),j("markdown.editor.insertTab","Insert Tab",Nc("insert"),[R("Tab")],"local"),j("markdown.editor.outdent","Outdent",Nc("outdent"),[R("Tab",{shift:!0})],"local"),j("markdown.editor.toggleTabFocus","Toggle Tab Key Moves Focus",{kind:"toggleTabFocus"},[R("m",{ctrl:!0})],"local"),j("markdown.editor.smartEnter","Insert Paragraph",bo("smartEnter"),[R("Enter")]),j("markdown.editor.insertHardLineBreak","Insert Hard Line Break",bo("insertHardLineBreak"),[R("Enter",{shift:!0})]),j("markdown.editor.insertParagraph","Insert Paragraph Without Continuing Markup",bo("insertParagraph"),[R("Enter",{meta:!0},Z),R("Enter",{ctrl:!0})])];var O=class t{constructor(e,n){if(this.start=e,this.endExclusive=n,e>n)throw new Error(`Invalid range: [${e}, ${n})`)}static fromTo(e,n){return new t(e,n)}static ofLength(e){return new t(0,e)}static ofStartAndLength(e,n){return new t(e,e+n)}static emptyAt(e){return new t(e,e)}get isEmpty(){return this.start===this.endExclusive}get length(){return this.endExclusive-this.start}delta(e){return new t(this.start+e,this.endExclusive+e)}deltaStart(e){return new t(this.start+e,this.endExclusive)}deltaEnd(e){return new t(this.start,this.endExclusive+e)}contains(e){return this.start<=e&&e<this.endExclusive}containsRange(e){return this.start<=e.start&&e.endExclusive<=this.endExclusive}intersects(e){return Math.max(this.start,e.start)<Math.min(this.endExclusive,e.endExclusive)}intersectsOrTouches(e){return Math.max(this.start,e.start)<=Math.min(this.endExclusive,e.endExclusive)}intersect(e){let n=Math.max(this.start,e.start),i=Math.min(this.endExclusive,e.endExclusive);if(n<=i)return new t(n,i)}join(e){return new t(Math.min(this.start,e.start),Math.max(this.endExclusive,e.endExclusive))}isBefore(e){return this.endExclusive<=e.start}isAfter(e){return this.start>=e.endExclusive}substring(e){return e.substring(this.start,this.endExclusive)}slice(e){return e.slice(this.start,this.endExclusive)}equals(e){return this.start===e.start&&this.endExclusive===e.endExclusive}toString(){return`[${this.start}, ${this.endExclusive})`}},ze=class t{constructor(e,n){this.replaceRange=e,this.newText=n}static insert(e,n){return new t(O.emptyAt(e),n)}static replace(e,n){return new t(e,n)}static delete(e){return new t(e,"")}get isEmpty(){return this.replaceRange.isEmpty&&this.newText.length===0}equals(e){return this.replaceRange.equals(e.replaceRange)&&this.newText===e.newText}removeCommonSuffixPrefix(e){let n=this.replaceRange.substring(e),i=Am(n,this.newText),r=Math.min(n.length-i,this.newText.length-i,Pm(n,this.newText));return new t(new O(this.replaceRange.start+i,this.replaceRange.endExclusive-r),this.newText.substring(i,this.newText.length-r))}toString(){return`${this.replaceRange} -> ${JSON.stringify(this.newText)}`}};function Am(t,e){let n=Math.min(t.length,e.length),i=0;for(;i<n&&t.charCodeAt(i)===e.charCodeAt(i);)i++;return i}function Pm(t,e){let n=Math.min(t.length,e.length),i=0;for(;i<n&&t.charCodeAt(t.length-i-1)===e.charCodeAt(e.length-i-1);)i++;return i}var H=class t{static empty=new t([]);static single(e){return new t([e])}static replace(e,n){return new t([ze.replace(e,n)])}static insert(e,n){return new t([ze.insert(e,n)])}static delete(e){return new t([ze.delete(e)])}replacements;constructor(e){let n=-1;for(let i of e){if(i.replaceRange.start<n)throw new Error(`Edits must be disjoint and sorted. Found ${i} after ${n}`);n=i.replaceRange.endExclusive}this.replacements=e}get isEmpty(){return this.replacements.length===0}apply(e){let n=[],i=0;for(let r of this.replacements)n.push(e.substring(i,r.replaceRange.start)),n.push(r.newText),i=r.replaceRange.endExclusive;return n.push(e.substring(i)),n.join("")}inverse(e){let n=[],i=0;for(let r of this.replacements){let s=e.substring(r.replaceRange.start,r.replaceRange.endExclusive);n.push(ze.replace(O.ofStartAndLength(r.replaceRange.start+i,r.newText.length),s)),i+=r.newText.length-r.replaceRange.length}return new t(n)}equals(e){if(this.replacements.length!==e.replacements.length)return!1;for(let n=0;n<this.replacements.length;n++)if(!this.replacements[n].equals(e.replacements[n]))return!1;return!0}mapOffset(e){let n=0;for(let i of this.replacements){if(i.replaceRange.start>e)break;if(i.replaceRange.endExclusive<=e)n+=i.newText.length-i.replaceRange.length;else return i.replaceRange.start+n+i.newText.length}return e+n}toString(){return`[${this.replacements.map(e=>e.toString()).join(", ")}]`}};function Ac(t,e){return t===e?H.empty:H.single(ze.replace(new O(0,t.length),e).removeCommonSuffixPrefix(t))}var tn;function Pc(t){tn?tn instanceof ir?tn.loggers.push(t):tn=new ir([tn,t]):tn=t}function ie(){return tn}var _o;function Fc(t){_o=t}function $c(t){_o&&_o(t)}var ir=class{constructor(e){this.loggers=e}handleObservableCreated(e,n){for(let i of this.loggers)i.handleObservableCreated(e,n)}handleOnListenerCountChanged(e,n){for(let i of this.loggers)i.handleOnListenerCountChanged(e,n)}handleObservableUpdated(e,n){for(let i of this.loggers)i.handleObservableUpdated(e,n)}handleAutorunCreated(e,n){for(let i of this.loggers)i.handleAutorunCreated(e,n)}handleAutorunDisposed(e){for(let n of this.loggers)n.handleAutorunDisposed(e)}handleAutorunDependencyChanged(e,n,i){for(let r of this.loggers)r.handleAutorunDependencyChanged(e,n,i)}handleAutorunStarted(e){for(let n of this.loggers)n.handleAutorunStarted(e)}handleAutorunFinished(e){for(let n of this.loggers)n.handleAutorunFinished(e)}handleDerivedDependencyChanged(e,n,i){for(let r of this.loggers)r.handleDerivedDependencyChanged(e,n,i)}handleDerivedCleared(e){for(let n of this.loggers)n.handleDerivedCleared(e)}handleBeginTransaction(e){for(let n of this.loggers)n.handleBeginTransaction(e)}handleEndTransaction(e){for(let n of this.loggers)n.handleEndTransaction(e)}};var _e;(function(t){let e=!1;function n(){e=!0}t.enable=n;function i(){return r(1)}t.ofCaller=i;function r(s){if(!e)return;let o=Error,a=o.stackTraceLimit;o.stackTraceLimit=3;let l=new Error().stack;return o.stackTraceLimit=a,wo.fromStack(l,s+1)}t.ofNthCaller=r})(_e||(_e={}));var wo=class t{static fromStack(e,n){let i=e.split(`
`),r=Fm(i[n+1]);if(r)return new t(r.fileName,r.line,r.column,r.id)}constructor(e,n,i,r){this.fileName=e,this.line=n,this.column=i,this.id=r}};function Fm(t){if(!t)return;let e=t.match(/\((.*):(\d+):(\d+)\)/);if(e)return{fileName:e[1],line:parseInt(e[2]),column:parseInt(e[3]),id:t};let n=t.match(/at ([^\(\)]*):(\d+):(\d+)/);if(n)return{fileName:n[1],line:parseInt(n[2]),column:parseInt(n[3]),id:t}}var Ee=class{constructor(e,n,i){this.owner=e,this.debugNameSource=n,this.referenceFn=i}getDebugName(e){return qc(e,this)}},Bc=new Map,yo=new WeakMap;function qc(t,e){let n=yo.get(t);if(n)return n;let i=$m(t,e);if(i){let r=Bc.get(i)??0;r++,Bc.set(i,r);let s=r===1?i:`${i}#${r}`;return yo.set(t,s),s}}function $m(t,e){let n=yo.get(t);if(n)return n;let i=e.owner?Dm(e.owner)+".":"",r,s=e.debugNameSource;if(s!==void 0)if(typeof s=="function"){if(r=s(),r!==void 0)return i+r}else return i+s;let o=e.referenceFn;if(o!==void 0&&(r=ri(o),r!==void 0))return i+r;if(e.owner!==void 0){let a=Bm(e.owner,t);if(a!==void 0)return i+a}}function Bm(t,e){for(let n in t)if(t[n]===e)return n}var Dc=new Map,Vc=new WeakMap;function Dm(t){let e=Vc.get(t);if(e)return e;let n=ko(t)??"Object",i=Dc.get(n)??0;i++,Dc.set(n,i);let r=i===1?n:`${n}#${i}`;return Vc.set(t,r),r}function ko(t){let e=t.constructor;if(e)return e.name==="Object"?void 0:e.name}function ri(t){let e=t.toString(),i=/\/\*\*\s*@description\s*([^*]*)\*\//.exec(e);return(i?i[1]:void 0)?.trim()}var xo;function jc(t){xo=t}var Wc;function Hc(t){Wc=t}var Kc;function Uc(t){Kc=t}var Zc;function Xc(t){Zc=t}var si=class{get TChange(){return null}reportChanges(){this.get()}read(e){return e?e.readObservable(this):this.get()}map(e,n,i=_e.ofCaller()){let r=n===void 0?void 0:e,s=n===void 0?e:n;return xo({owner:r,debugName:()=>{let o=ri(s);if(o!==void 0)return o;let l=/^\s*\(?\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\)?\s*=>\s*\1(?:\??)\.([a-zA-Z_$][a-zA-Z_$0-9]*)\s*$/.exec(s.toString());if(l)return`${this.debugName}.${l[2]}`;if(!r)return`${this.debugName} (mapped)`},debugReferenceFn:s},o=>s(this.read(o),o),i)}flatten(){return xo({owner:void 0,debugName:()=>`${this.debugName} (flattened)`},e=>this.read(e).read(e))}recomputeInitiallyAndOnChange(e,n){return e.add(Wc(this,n)),this}keepObserved(e){return e.add(Kc(this)),this}get debugValue(){return this.get()}debugGetDependencyGraph(){return Zc(this)}},ht=class extends si{constructor(e){super(),this._observers=new Set,ie()?.handleObservableCreated(this,e)}addObserver(e){let n=this._observers.size;this._observers.add(e),n===0&&this.onFirstObserverAdded(),n!==this._observers.size&&ie()?.handleOnListenerCountChanged(this,this._observers.size)}removeObserver(e){let n=this._observers.delete(e);n&&this._observers.size===0&&this.onLastObserverRemoved(),n&&ie()?.handleOnListenerCountChanged(this,this._observers.size)}onFirstObserverAdded(){}onLastObserverRemoved(){}log(){let e=!!ie();return $c(this),e||ie()?.handleObservableCreated(this,_e.ofCaller()),this}debugGetObservers(){return this._observers}};function oi(t){return{dispose:t}}var nt=class t extends Error{constructor(e){super(e||"An unexpected bug occurred."),Object.setPrototypeOf(this,t.prototype)}};function Cn(t){throw t}function Jc(t){console.error("Unexpected error:",t)}var pt=(t,e)=>t===e;var Le=class{constructor(){this.disposables=[],this._isDisposed=!1}get isDisposed(){return this._isDisposed}dispose(){this.clear(),this._isDisposed=!0}add(e){return e&&this.disposables.push(e),e}remove(e){if(!e)return e;let n=this.disposables.indexOf(e);return n!==-1&&this.disposables.splice(n,1),e}clear(){for(let e of this.disposables)e.dispose();this.disposables=[]}leakItems(){this.disposables=[]}},pe=class{constructor(){this._store=new Le}dispose(){this._store.dispose()}_register(e){return this._store.add(e),e}_registerOrDispose(e){return e&&(this._store.isDisposed?e.dispose():this._store.add(e)),e}};function Vm(t){switch(t){case 0:return"initial";case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var it=class extends ht{get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}constructor(e,n,i,r=void 0,s,o){super(o),this._debugNameData=e,this._computeFn=n,this._changeTracker=i,this._handleLastObserverRemoved=r,this._equalityComparator=s,this._state=0,this._value=void 0,this._updateCount=0,this._dependencies=new Set,this._dependenciesToBeRemoved=new Set,this._changeSummary=void 0,this._isUpdating=!1,this._isComputing=!1,this._didReportChange=!1,this._isInBeforeUpdate=!1,this._isReaderValid=!1,this._store=void 0,this._delayedStore=void 0,this._removedObserverToCallEndUpdateOn=null,this._changeSummary=this._changeTracker?.createChangeSummary(void 0)}onLastObserverRemoved(){this._state=0,this._value=void 0,ie()?.handleDerivedCleared(this);for(let e of this._dependencies)e.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._delayedStore!==void 0&&(this._delayedStore.dispose(),this._delayedStore=void 0),this._handleLastObserverRemoved?.()}get(){if(this._isComputing,this._observers.size===0){let n;try{this._isReaderValid=!0;let i;this._changeTracker&&(i=this._changeTracker.createChangeSummary(void 0),this._changeTracker.beforeUpdate?.(this,i)),n=this._computeFn(this,i)}finally{this._isReaderValid=!1}return this.onLastObserverRemoved(),n}else{do{if(this._state===1){for(let n of this._dependencies)if(n.reportChanges(),this._state===2)break}this._state===1&&(this._state=3),this._state!==3&&this._recompute()}while(this._state!==3);return this._value}}_recompute(){let e=!1;this._isComputing=!0,this._didReportChange=!1;let n=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=n;try{let i=this._changeSummary;this._isReaderValid=!0,this._changeTracker&&(this._isInBeforeUpdate=!0,this._changeTracker.beforeUpdate?.(this,i),this._isInBeforeUpdate=!1,this._changeSummary=this._changeTracker?.createChangeSummary(i));let r=this._state!==0,s=this._value;this._state=3;let o=this._delayedStore;o!==void 0&&(this._delayedStore=void 0);try{this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._value=this._computeFn(this,i)}finally{this._isReaderValid=!1;for(let a of this._dependenciesToBeRemoved)a.removeObserver(this);this._dependenciesToBeRemoved.clear(),o!==void 0&&o.dispose()}e=this._didReportChange||r&&!this._equalityComparator(s,this._value),ie()?.handleObservableUpdated(this,{oldValue:s,newValue:this._value,change:void 0,didChange:e,hadValue:r})}catch(i){Cn(i)}if(this._isComputing=!1,!this._didReportChange&&e)for(let i of this._observers)i.handleChange(this,void 0);else this._didReportChange=!1}toString(){return`LazyDerived<${this.debugName}>`}beginUpdate(e){if(this._isUpdating)throw new nt("Cyclic deriveds are not supported yet!");this._updateCount++,this._isUpdating=!0;try{let n=this._updateCount===1;if(this._state===3&&(this._state=1,!n))for(let i of this._observers)i.handlePossibleChange(this);if(n)for(let i of this._observers)i.beginUpdate(this)}finally{this._isUpdating=!1}}endUpdate(e){if(this._updateCount--,this._updateCount===0){let n=[...this._observers];for(let i of n)i.endUpdate(this);if(this._removedObserverToCallEndUpdateOn){let i=[...this._removedObserverToCallEndUpdateOn];this._removedObserverToCallEndUpdateOn=null;for(let r of i)r.endUpdate(this)}}}handlePossibleChange(e){if(this._state===3&&this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)){this._state=1;for(let n of this._observers)n.handlePossibleChange(this)}}handleChange(e,n){if(this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)||this._isInBeforeUpdate){ie()?.handleDerivedDependencyChanged(this,e,n);let i=!1;try{i=this._changeTracker?this._changeTracker.handleChange({changedObservable:e,change:n,didChange:s=>s===e},this._changeSummary):!0}catch(s){Cn(s)}let r=this._state===3;if(i&&(this._state===1||r)&&(this._state=2,r))for(let s of this._observers)s.handlePossibleChange(this)}}_ensureReaderValid(){if(!this._isReaderValid)throw new nt("The reader object cannot be used outside its compute function!")}readObservable(e){this._ensureReaderValid(),e.addObserver(this);let n=e.get();return this._dependencies.add(e),this._dependenciesToBeRemoved.delete(e),n}reportChange(e){this._ensureReaderValid(),this._didReportChange=!0;for(let n of this._observers)n.handleChange(this,e)}get store(){return this._ensureReaderValid(),this._store===void 0&&(this._store=new Le),this._store}get delayedStore(){return this._ensureReaderValid(),this._delayedStore===void 0&&(this._delayedStore=new Le),this._delayedStore}addObserver(e){let n=!this._observers.has(e)&&this._updateCount>0;super.addObserver(e),n&&(this._removedObserverToCallEndUpdateOn&&this._removedObserverToCallEndUpdateOn.has(e)?this._removedObserverToCallEndUpdateOn.delete(e):e.beginUpdate(this))}removeObserver(e){this._observers.has(e)&&this._updateCount>0&&(this._removedObserverToCallEndUpdateOn||(this._removedObserverToCallEndUpdateOn=new Set),this._removedObserverToCallEndUpdateOn.add(e)),super.removeObserver(e)}debugGetState(){return{state:this._state,stateStr:Vm(this._state),updateCount:this._updateCount,isComputing:this._isComputing,dependencies:this._dependencies,value:this._value}}debugSetValue(e){this._value=e}debugRecompute(){this._isComputing?this._state=2:this._recompute()}setValue(e,n,i){this._value=e;let r=this._observers;n.updateObserver(this,this);for(let s of r)s.handleChange(this,i)}};function re(t,e,n=_e.ofCaller()){return e!==void 0?new it(new Ee(t,void 0,e),e,void 0,void 0,pt,n):new it(new Ee(void 0,void 0,t),t,void 0,void 0,pt,n)}function rr(t,e,n=_e.ofCaller()){return new it(new Ee(t.owner,t.debugName,t.debugReferenceFn),e,void 0,t.onLastObserverRemoved,t.equalsFn??pt,n)}jc(rr);function qm(t){switch(t){case 1:return"dependenciesMightHaveChanged";case 2:return"stale";case 3:return"upToDate";default:return"<unknown>"}}var nn=class{get debugName(){return this._debugNameData.getDebugName(this)??"(anonymous)"}constructor(e,n,i,r){this._debugNameData=e,this._runFn=n,this._changeTracker=i,this._state=2,this._updateCount=0,this._disposed=!1,this._dependencies=new Set,this._dependenciesToBeRemoved=new Set,this._isRunning=!1,this._store=void 0,this._delayedStore=void 0,this._changeSummary=this._changeTracker?.createChangeSummary(void 0),ie()?.handleAutorunCreated(this,r),this._run()}dispose(){if(!this._disposed){this._disposed=!0;for(let e of this._dependencies)e.removeObserver(this);this._dependencies.clear(),this._store!==void 0&&this._store.dispose(),this._delayedStore!==void 0&&this._delayedStore.dispose(),ie()?.handleAutorunDisposed(this)}}_run(){let e=this._dependenciesToBeRemoved;this._dependenciesToBeRemoved=this._dependencies,this._dependencies=e,this._state=3;try{if(!this._disposed){ie()?.handleAutorunStarted(this);let n=this._changeSummary,i=this._delayedStore;i!==void 0&&(this._delayedStore=void 0);try{this._isRunning=!0,this._changeTracker&&(this._changeTracker.beforeUpdate?.(this,n),this._changeSummary=this._changeTracker.createChangeSummary(n)),this._store!==void 0&&(this._store.dispose(),this._store=void 0),this._runFn(this,n)}catch(r){Cn(r)}finally{this._isRunning=!1,i!==void 0&&i.dispose()}}}finally{this._disposed||ie()?.handleAutorunFinished(this);for(let n of this._dependenciesToBeRemoved)n.removeObserver(this);this._dependenciesToBeRemoved.clear()}}toString(){return`Autorun<${this.debugName}>`}beginUpdate(e){this._state===3&&(this._state=1),this._updateCount++}endUpdate(e){try{if(this._updateCount===1)do{if(this._state===1){this._state=3;for(let n of this._dependencies)if(n.reportChanges(),this._state===2)break}this._state!==3&&this._run()}while(this._state!==3)}finally{this._updateCount--}}handlePossibleChange(e){this._state===3&&this._isDependency(e)&&(this._state=1)}handleChange(e,n){if(this._isDependency(e)){ie()?.handleAutorunDependencyChanged(this,e,n);try{(!this._changeTracker||this._changeTracker.handleChange({changedObservable:e,change:n,didChange:r=>r===e},this._changeSummary))&&(this._state=2)}catch(i){Cn(i)}}}_isDependency(e){return this._dependencies.has(e)&&!this._dependenciesToBeRemoved.has(e)}_ensureNoRunning(){if(!this._isRunning)throw new nt("The reader object cannot be used outside its compute function!")}readObservable(e){if(this._ensureNoRunning(),this._disposed)return e.get();e.addObserver(this);let n=e.get();return this._dependencies.add(e),this._dependenciesToBeRemoved.delete(e),n}get store(){if(this._ensureNoRunning(),this._disposed)throw new nt("Cannot access store after dispose");return this._store===void 0&&(this._store=new Le),this._store}get delayedStore(){if(this._ensureNoRunning(),this._disposed)throw new nt("Cannot access store after dispose");return this._delayedStore===void 0&&(this._delayedStore=new Le),this._delayedStore}debugGetState(){return{isRunning:this._isRunning,updateCount:this._updateCount,dependencies:this._dependencies,state:this._state,stateStr:qm(this._state)}}debugRerun(){this._isRunning?this._state=2:this._run()}};function ai(t,e=_e.ofCaller()){return new nn(new Ee(void 0,void 0,t),t,void 0,e)}var ee=ai;function Gc(t,e,n=_e.ofCaller()){return new nn(new Ee(t.owner,t.debugName,t.debugReferenceFn??e),e,t.changeTracker,n)}function So(t,e){let n=new Le,i=Gc({owner:t.owner,debugName:t.debugName,debugReferenceFn:t.debugReferenceFn??e,changeTracker:t.changeTracker},(r,s)=>{n.clear(),e(r,s,n)});return oi(()=>{i.dispose(),n.dispose()})}function zo(t){let e=new Error("BugIndicatingErrorRecovery: "+t);Jc(e),console.error("recovered from an error that indicates a bug",e)}function Ce(t,e){let n=new rn(t,e);try{t(n)}finally{n.finish()}}function Eo(t,e,n){t?e(t):Ce(e,n)}var rn=class{constructor(e,n){this._fn=e,this._getDebugName=n,this._updatingObservers=[],ie()?.handleBeginTransaction(this)}getDebugName(){return this._getDebugName?this._getDebugName():ri(this._fn)}updateObserver(e,n){if(!this._updatingObservers){zo("Transaction already finished!"),Ce(i=>{i.updateObserver(e,n)});return}this._updatingObservers.push({observer:e,observable:n}),e.beginUpdate(n)}finish(){let e=this._updatingObservers;if(!e){zo("transaction.finish() has already been called!");return}for(let n=0;n<e.length;n++){let{observer:i,observable:r}=e[n];i.endUpdate(r)}this._updatingObservers=null,ie()?.handleEndTransaction(this)}debugGetUpdatingObservers(){return this._updatingObservers}};function V(t,e,n=_e.ofCaller()){let i;return typeof t=="string"?i=new Ee(void 0,t,void 0):i=new Ee(t,void 0,void 0),new Tn(i,e,pt,n)}var Tn=class extends ht{get debugName(){return this._debugNameData.getDebugName(this)??"ObservableValue"}constructor(e,n,i,r){super(r),this._debugNameData=e,this._equalityComparator=i,this._value=n,ie()?.handleObservableUpdated(this,{hadValue:!1,newValue:n,change:void 0,didChange:!0,oldValue:void 0})}get(){return this._value}set(e,n,i){if(i===void 0&&this._equalityComparator(this._value,e))return;let r;n||(n=r=new rn(()=>{},()=>`Setting ${this.debugName}`));try{let s=this._value;this._setValue(e),ie()?.handleObservableUpdated(this,{oldValue:s,newValue:e,change:i,didChange:!0,hadValue:!0});for(let o of this._observers)n.updateObserver(o,this),o.handleChange(this,i)}finally{r&&r.finish()}}toString(){return`${this.debugName}: ${this._value}`}_setValue(e){this._value=e}debugGetState(){return{value:this._value}}debugSetValue(e){this._value=e}};function sn(...t){let e,n,i,r;return t.length===2?[n,i]=t:[e,n,i,r]=t,new gt(new Ee(e,void 0,i),n,i,()=>gt.globalTransaction,pt,r??_e.ofCaller())}var gt=class extends ht{constructor(e,n,i,r,s,o){super(o),this._debugNameData=e,this.event=n,this._getValue=i,this._getTransaction=r,this._equalityComparator=s,this._hasValue=!1,this.handleEvent=a=>{let l=this._getValue(a),c=this._value,d=!this._hasValue||!this._equalityComparator(c,l),h=!1;d&&(this._value=l,this._hasValue&&(h=!0,Eo(this._getTransaction(),u=>{ie()?.handleObservableUpdated(this,{oldValue:c,newValue:l,change:void 0,didChange:d,hadValue:this._hasValue});for(let f of this._observers)u.updateObserver(f,this),f.handleChange(this,void 0)},()=>{let u=this.getDebugName();return"Event fired"+(u?`: ${u}`:"")})),this._hasValue=!0),h||ie()?.handleObservableUpdated(this,{oldValue:c,newValue:l,change:void 0,didChange:d,hadValue:this._hasValue})}}getDebugName(){return this._debugNameData.getDebugName(this)}get debugName(){let e=this.getDebugName();return"From Event"+(e?`: ${e}`:"")}onFirstObserverAdded(){this._subscription=this.event(this.handleEvent)}onLastObserverRemoved(){this._subscription.dispose(),this._subscription=void 0,this._hasValue=!1,this._value=void 0}get(){return this._subscription?(this._hasValue||this.handleEvent(void 0),this._value):this._getValue(void 0)}debugSetValue(e){this._value=e}debugGetState(){return{value:this._value,hasValue:this._hasValue}}};(function(t){t.Observer=gt;function e(n,i){let r=!1;gt.globalTransaction===void 0&&(gt.globalTransaction=n,r=!0);try{i()}finally{r&&(gt.globalTransaction=void 0)}}t.batchEventsGlobally=e})(sn||(sn={}));function or(t){let e=new sr(!1,void 0);return t.addObserver(e),oi(()=>{t.removeObserver(e)})}Uc(or);function Co(t,e){let n=new sr(!0,e);t.addObserver(n);try{n.beginUpdate(t)}finally{n.endUpdate(t)}return oi(()=>{t.removeObserver(n)})}Hc(Co);var sr=class{constructor(e,n){this._forceRecompute=e,this._handleValue=n,this._counter=0}beginUpdate(e){this._counter++}endUpdate(e){this._counter===1&&this._forceRecompute&&(this._handleValue?this._handleValue(e.get()):e.reportChanges()),this._counter--}handlePossibleChange(e){}handleChange(e,n){}};var ar;function Yc(t){ar||(ar=new To,Pc(ar)),ar.addFilteredObj(t)}var To=class{constructor(){this.indentation=0,this.changedObservablesSets=new WeakMap}addFilteredObj(e){this._filteredObjects||(this._filteredObjects=new Set),this._filteredObjects.add(e)}_isIncluded(e){return this._filteredObjects?.has(e)??!0}textToConsoleArgs(e){return Wm([On(Zm("|  ",this.indentation)),e])}formatInfo(e){return e.hadValue?e.didChange?[On(" "),rt(on(e.oldValue,70),{color:"red",strikeThrough:!0}),On(" "),rt(on(e.newValue,60),{color:"green"})]:[On(" (unchanged)")]:[On(" "),rt(on(e.newValue,60),{color:"green"}),On(" (initial)")]}handleObservableCreated(e){if(e instanceof it){let n=e;this.changedObservablesSets.set(n,new Set)}}handleOnListenerCountChanged(e,n){}handleObservableUpdated(e,n){if(this._isIncluded(e)){if(e instanceof it){this._handleDerivedRecomputed(e,n);return}console.log(...this.textToConsoleArgs([Rn("observable value changed"),rt(e.debugName,{color:"BlueViolet"}),...this.formatInfo(n)]))}}formatChanges(e){if(e.size!==0)return rt(" (changed deps: "+[...e].map(n=>n.debugName).join(", ")+")",{color:"gray"})}handleDerivedDependencyChanged(e,n,i){this._isIncluded(e)&&this.changedObservablesSets.get(e)?.add(n)}_handleDerivedRecomputed(e,n){if(!this._isIncluded(e))return;let i=this.changedObservablesSets.get(e);i&&(console.log(...this.textToConsoleArgs([Rn("derived recomputed"),rt(e.debugName,{color:"BlueViolet"}),...this.formatInfo(n),this.formatChanges(i),{data:[{fn:e._debugNameData.referenceFn??e._computeFn}]}])),i.clear())}handleDerivedCleared(e){this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Rn("derived cleared"),rt(e.debugName,{color:"BlueViolet"})]))}handleFromEventObservableTriggered(e,n){this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Rn("observable from event triggered"),rt(e.debugName,{color:"BlueViolet"}),...this.formatInfo(n),{data:[{fn:e._getValue}]}]))}handleAutorunCreated(e){this._isIncluded(e)&&this.changedObservablesSets.set(e,new Set)}handleAutorunDisposed(e){}handleAutorunDependencyChanged(e,n,i){this._isIncluded(e)&&this.changedObservablesSets.get(e).add(n)}handleAutorunStarted(e){let n=this.changedObservablesSets.get(e);n&&(this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Rn("autorun"),rt(e.debugName,{color:"BlueViolet"}),this.formatChanges(n),{data:[{fn:e._debugNameData.referenceFn??e._runFn}]}])),n.clear(),this.indentation++)}handleAutorunFinished(e){this.indentation--}handleBeginTransaction(e){let n=e.getDebugName();n===void 0&&(n=""),this._isIncluded(e)&&console.log(...this.textToConsoleArgs([Rn("transaction"),rt(n,{color:"BlueViolet"}),{data:[{fn:e._fn}]}])),this.indentation++}handleEndTransaction(){this.indentation--}};function Wm(t){let e=new Array,n=[],i="";function r(o){if("length"in o)for(let a of o)a&&r(a);else"text"in o?(i+=`%c${o.text}`,e.push(o.style),o.data&&n.push(...o.data)):"data"in o&&n.push(...o.data)}r(t);let s=[i,...e];return s.push(...n),s}function On(t){return rt(t,{color:"black"})}function Rn(t){return rt(Xm(`${t}: `,10),{color:"black",bold:!0})}function rt(t,e={color:"black"}){function n(r){return Object.entries(r).reduce((s,[o,a])=>`${s}${o}:${a};`,"")}let i={color:e.color};return e.strikeThrough&&(i["text-decoration"]="line-through"),e.bold&&(i["font-weight"]="bold"),{text:t,style:n(i)}}function on(t,e){try{return Hm(t,e)}catch{return"[[???]]"}}function Hm(t,e){switch(typeof t){case"number":return""+t;case"string":return t.length+2<=e?`"${t}"`:`"${t.substr(0,e-7)}"+...`;case"boolean":return t?"true":"false";case"undefined":return"undefined";case"object":return t===null?"null":Array.isArray(t)?Km(t,e):Um(t,e);case"symbol":return t.toString();case"function":return`[[Function${t.name?" "+t.name:""}]]`;default:return""+t}}function Km(t,e){let n="[ ",i=!0;for(let r of t){if(i||(n+=", "),n.length-5>e){n+="...";break}i=!1,n+=`${on(r,e-n.length)}`}return n+=" ]",n}function Um(t,e){try{if(typeof t.toString=="function"&&t.toString!==Object.prototype.toString){let o=t.toString();return o.length<=e?o:o.substring(0,e-3)+"..."}}catch{return"[[Object]]"}let n=ko(t),i=n?n+"(":"{ ",r=!0,s;try{s=Object.entries(t)}catch{return n?`${n}(...)`:"[[Object]]"}for(let[o,a]of s){if(r||(i+=", "),i.length-5>e){i+="...";break}r=!1,i+=`${o}: ${on(a,e-i.length)}`}return i+=n?")":" }",i}function Zm(t,e){let n="";for(let i=1;i<=e;i++)n+=t;return n}function Xm(t,e){for(;t.length<e;)t+=" ";return t}function Qc(t,e){let n=e?.debugNamePostProcessor??(s=>s),i=Oo.from(t,n);return i?ed(i,0,new Set).trim():""}function ed(t,e,n){let i="		".repeat(e),r=[];if(n.has(t.sourceObj))return r.push(`${i}* ${t.type} ${t.name} (already listed)`),r.join(`
`);if(n.add(t.sourceObj),r.push(`${i}* ${t.type} ${t.name}:`),r.push(`${i}  value: ${on(t.value,50)}`),r.push(`${i}  state: ${t.state}`),t.dependencies.length>0){r.push(`${i}  dependencies:`);for(let o of t.dependencies)r.push(ed(o,e+1,n))}return r.join(`
`)}var Oo=class t{static from(e,n){if(e instanceof nn){let i=e.debugGetState();return new t(e,n(e.debugName),"autorun",void 0,i.stateStr,Array.from(i.dependencies).map(r=>t.from(r,n)||t.unknown(r)))}else if(e instanceof it){let i=e.debugGetState();return new t(e,n(e.debugName),"derived",i.value,i.stateStr,Array.from(i.dependencies).map(r=>t.from(r,n)||t.unknown(r)))}else if(e instanceof Tn){let i=e.debugGetState();return new t(e,n(e.debugName),"observableValue",i.value,"upToDate",[])}else if(e instanceof gt){let i=e.debugGetState();return new t(e,n(e.debugName),"fromEvent",i.value,i.hasValue?"upToDate":"initial",[])}}static unknown(e){return new t(e,"(unknown)","unknown",void 0,"unknown",[])}constructor(e,n,i,r,s,o){this.sourceObj=e,this.name=n,this.type=i,this.value=r,this.state=s,this.dependencies=o}};Xc(Qc);Fc(Yc);function Lo(t){return new Ro(t)}var Ro=class extends si{constructor(e){super(),this.value=e}get debugName(){return this.toString()}get(){return this.value}addObserver(e){}removeObserver(e){}log(){return this}toString(){return`Const: ${this.value}`}};function li(t,e){let n,i=!0;return So({changeTracker:{createChangeSummary:()=>({deltas:[],didChange:!1}),handleChange:(r,s)=>{if(r.didChange(t)){let o=r.change;o!==void 0&&s.deltas.push(o),s.didChange=!0}return!0}}},(r,s)=>{let o=t.read(r),a=n;s.didChange&&(n=o,e(o,a,s.deltas)),i&&(i=!1,n=o)})}var dp="`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?",an={wordSeparators:dp,wordSegmenterLocales:[]};function ci(t,e){return t!==void 0&&!/\s/u.test(t)&&!e.includes(t)}var Io=class{_separators;_segmenter;_cachedLine;_cachedWords=[];constructor(e){this._separators=new Set(e.wordSeparators),this._segmenter=up(e.wordSegmenterLocales)}classify(e){return e===void 0||e===" "||e==="	"?1:this._separators.has(e)?2:0}previousIntlWord(e,n){let i;for(let r of this._intlWords(e)){if(r.index>n)break;i=r}return i}nextIntlWord(e,n){return this._intlWords(e).find(i=>i.index>=n)}_intlWords(e){if(!this._segmenter)return[];if(this._cachedLine===e)return this._cachedWords;let n=[];for(let i of this._segmenter.segment(e))i.isWordLike&&n.push({index:i.index,segment:i.segment});return this._cachedLine=e,this._cachedWords=n,n}};function up(t){if(t.length===0)return;let e=[];for(let n of t){if(typeof n!="string"||n.length===0){console.warn("Ignoring invalid editor.wordSegmenterLocales entry",n);continue}try{e.push(...Intl.Segmenter.supportedLocalesOf(n))}catch(i){console.warn(`Ignoring invalid editor.wordSegmenterLocales entry: ${n}`,i)}}if(e.length!==0)try{return new Intl.Segmenter(e,{granularity:"word"})}catch(n){console.warn(`Unable to initialize editor.wordSegmenterLocales: ${e.join(", ")}`,n);return}}var id=new Map;function di(t){let e=`${t.wordSeparators}/${t.wordSegmenterLocales.join(",")}`,n=id.get(e);return n||(n=new Io(t),id.set(e,n)),n}function rd(t,e,n=an){if(e=ui(e,0,t.length),e===0)return 0;let i=t.lastIndexOf(`
`,e-1)+1,r=t.indexOf(`
`,e);r===-1&&(r=t.length);let s=e-i;if(s===0){let c=i-1;i=c<=0?0:t.lastIndexOf(`
`,c-1)+1,r=c,s=Math.max(0,c-i)}let o=t.slice(i,r),a=di(n),l=Mo(o,a,s);return l?.type===1&&l.end-l.start===1&&l.nextClass===0&&(l=Mo(o,a,l.start)),i+(l?.start??0)}function sd(t,e,n=an){if(e=ui(e,0,t.length),e===t.length)return t.length;let i=t.lastIndexOf(`
`,e-1)+1,r=t.indexOf(`
`,e);r===-1&&(r=t.length);let s=e-i;e===r&&r<t.length&&(i=r+1,r=t.indexOf(`
`,i),r===-1&&(r=t.length),s=0);let o=t.slice(i,r),a=di(n),l=dr(o,a,s);return l?.type===1&&l.end-l.start===1&&l.nextClass===0&&(l=dr(o,a,l.end)),i+(l?.end??o.length)}function od(t,e,n=an){if(e=ui(e,0,t.length),e===0)return 0;let i=e===0?0:t.lastIndexOf(`
`,e-1)+1,r=e-i;if(r===0)return e-1;let s=r-1;for(;s>=0&&(t[i+s]===" "||t[i+s]==="	");)s--;if(s+1<r-1)return i+s+1;let o=t.indexOf(`
`,e);o===-1&&(o=t.length);let a=t.slice(i,o),l=Mo(a,di(n),r);return i+(l?.start??0)}function ad(t,e,n=an){if(e=ui(e,0,t.length),e===t.length)return t.length;let i=t.lastIndexOf(`
`,e-1)+1,r=t.indexOf(`
`,e);r===-1&&(r=t.length);let s=e-i,o=t.slice(i,r),a=s;for(;a<o.length&&(o[a]===" "||o[a]==="	");)a++;if(s<a)return i+a;let l=di(n),c=dr(o,l,s);if(c)return i+c.end;if(e<r||r===t.length)return r;let d=r+1,h=t.indexOf(`
`,d);h===-1&&(h=t.length);let u=t.slice(d,h),f=dr(u,l,0);return d+(f?.start??u.length)}function No(t,e,n=an){if(e=ui(e,0,t.length),e===t.length)return{start:e,end:e};let i=t[e];if(/\s/u.test(i)){let f=e,m=e+1;for(;f>0&&/\s/u.test(t[f-1]);)f--;for(;m<t.length&&/\s/u.test(t[m]);)m++;return{start:f,end:m}}let r=t.lastIndexOf(`
`,e-1)+1,s=t.indexOf(`
`,e);s===-1&&(s=t.length);let o=t.slice(r,s),a=e-r,l=di(n),c=l.previousIntlWord(o,a);if(c&&a<c.index+c.segment.length)return{start:r+c.index,end:r+c.index+c.segment.length};let d=l.classify(i),h=a,u=a+1;for(;h>0&&l.classify(o[h-1])===d;)h--;for(;u<o.length&&l.classify(o[u])===d;)u++;return{start:r+h,end:r+u}}function Mo(t,e,n){let i,r=e.previousIntlWord(t,n-1);for(let s=n-1;s>=0;s--){let o=e.classify(t[s]);if(r&&s===r.index)return{start:r.index,end:r.index+r.segment.length,type:0,nextClass:o};if(o===0){if(i===1){let a=s+1;return{start:a,end:lr(t,e,i,a),type:i,nextClass:o}}i=0}else if(o===2){if(i===0){let a=s+1;return{start:a,end:lr(t,e,i,a),type:i,nextClass:o}}i=1}else if(i!==void 0){let a=s+1;return{start:a,end:lr(t,e,i,a),type:i,nextClass:o}}}return i===void 0?void 0:{start:0,end:lr(t,e,i,0),type:i,nextClass:1}}function dr(t,e,n){let i,r=e.nextIntlWord(t,n);for(let s=n;s<t.length;s++){let o=e.classify(t[s]);if(r&&s===r.index)return{start:r.index,end:r.index+r.segment.length,type:0,nextClass:o};if(o===0){if(i===1){let a=s;return{start:cr(t,e,i,a-1),end:a,type:i,nextClass:o}}i=0}else if(o===2){if(i===0){let a=s;return{start:cr(t,e,i,a-1),end:a,type:i,nextClass:o}}i=1}else if(i!==void 0){let a=s;return{start:cr(t,e,i,a-1),end:a,type:i,nextClass:o}}}return i===void 0?void 0:{start:cr(t,e,i,t.length-1),end:t.length,type:i,nextClass:1}}function lr(t,e,n,i){let r=e.nextIntlWord(t,i);for(let s=i;s<t.length;s++){if(r&&s===r.index+r.segment.length)return s;let o=e.classify(t[s]);if(o===1||n===0&&o===2||n===1&&o===0)return s}return t.length}function cr(t,e,n,i){let r=e.previousIntlWord(t,i);for(let s=i;s>=0;s--){if(r&&s===r.index)return s;let o=e.classify(t[s]);if(o===1||n===0&&o===2||n===1&&o===0)return s+1}return 0}function ui(t,e,n){return Math.min(Math.max(t,e),n)}var ld=document.createElement("i");function cd(t){let e="&"+t+";";ld.innerHTML=e;let n=ld.textContent;return n.charCodeAt(n.length-1)===59&&t!=="semi"||n===e?!1:n}function we(t,e,n,i){let r=t.length,s=0,o;if(e<0?e=-e>r?0:r+e:e=e>r?r:e,n=n>0?n:0,i.length<1e4)o=Array.from(i),o.unshift(e,n),t.splice(...o);else for(n&&t.splice(e,n);s<i.length;)o=i.slice(s,s+1e4),o.unshift(e,0),t.splice(...o),s+=1e4,e+=1e4}function Ae(t,e){return t.length>0?(we(t,t.length,0,e),t):e}var dd={}.hasOwnProperty;function ud(t){let e={},n=-1;for(;++n<t.length;)hp(e,t[n]);return e}function hp(t,e){let n;for(n in e){let r=(dd.call(t,n)?t[n]:void 0)||(t[n]={}),s=e[n],o;if(s)for(o in s){dd.call(r,o)||(r[o]=[]);let a=s[o];fp(r[o],Array.isArray(a)?a:a?[a]:[])}}}function fp(t,e){let n=-1,i=[];for(;++n<e.length;)(e[n].add==="after"?t:i).push(e[n]);we(t,0,0,i)}function hi(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}var Ze=Dt(/[A-Za-z]/),Pe=Dt(/[\dA-Za-z]/),hd=Dt(/[#-'*+\--9=?A-Z^-~]/);function fi(t){return t!==null&&(t<32||t===127)}var mi=Dt(/\d/),fd=Dt(/[\dA-Fa-f]/),md=Dt(/[!-/:-@[-`{-~]/);function T(t){return t!==null&&t<-2}function se(t){return t!==null&&(t<0||t===32)}function M(t){return t===-2||t===-1||t===32}var pd=Dt(/\p{P}|\p{S}/u),gd=Dt(/\s/);function Dt(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function N(t,e,n,i){let r=i?i-1:Number.POSITIVE_INFINITY,s=0;return o;function o(l){return M(l)?(t.enter(n),a(l)):e(l)}function a(l){return M(l)&&s++<r?(t.consume(l),a):(t.exit(n),e(l))}}var vd={tokenize:mp};function mp(t){let e=t.attempt(this.parser.constructs.contentInitial,i,r),n;return e;function i(a){if(a===null){t.consume(a);return}return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),N(t,e,"linePrefix")}function r(a){return t.enter("paragraph"),s(a)}function s(a){let l=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(a);return}return T(a)?(t.consume(a),t.exit("chunkText"),s):(t.consume(a),o)}}var _d={tokenize:pp},bd={tokenize:gp};function pp(t){let e=this,n=[],i=0,r,s,o;return a;function a(y){if(i<n.length){let x=n[i];return e.containerState=x[1],t.attempt(x[0].continuation,l,c)(y)}return c(y)}function l(y){if(i++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,r&&w();let x=e.events.length,C=x,k;for(;C--;)if(e.events[C][0]==="exit"&&e.events[C][1].type==="chunkFlow"){k=e.events[C][1].end;break}g(i);let E=x;for(;E<e.events.length;)e.events[E][1].end={...k},E++;return we(e.events,C+1,0,e.events.slice(x)),e.events.length=E,c(y)}return a(y)}function c(y){if(i===n.length){if(!r)return u(y);if(r.currentConstruct&&r.currentConstruct.concrete)return m(y);e.interrupt=!!(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(bd,d,h)(y)}function d(y){return r&&w(),g(i),u(y)}function h(y){return e.parser.lazy[e.now().line]=i!==n.length,o=e.now().offset,m(y)}function u(y){return e.containerState={},t.attempt(bd,f,m)(y)}function f(y){return i++,n.push([e.currentConstruct,e.containerState]),u(y)}function m(y){if(y===null){r&&w(),g(0),t.consume(y);return}return r=r||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:s}),p(y)}function p(y){if(y===null){v(t.exit("chunkFlow"),!0),g(0),t.consume(y);return}return T(y)?(t.consume(y),v(t.exit("chunkFlow")),i=0,e.interrupt=void 0,a):(t.consume(y),p)}function v(y,x){let C=e.sliceStream(y);if(x&&C.push(null),y.previous=s,s&&(s.next=y),s=y,r.defineSkip(y.start),r.write(C),e.parser.lazy[y.start.line]){let k=r.events.length;for(;k--;)if(r.events[k][1].start.offset<o&&(!r.events[k][1].end||r.events[k][1].end.offset>o))return;let E=e.events.length,L=E,D,S;for(;L--;)if(e.events[L][0]==="exit"&&e.events[L][1].type==="chunkFlow"){if(D){S=e.events[L][1].end;break}D=!0}for(g(i),k=E;k<e.events.length;)e.events[k][1].end={...S},k++;we(e.events,L+1,0,e.events.slice(E)),e.events.length=k}}function g(y){let x=n.length;for(;x-- >y;){let C=n[x];e.containerState=C[1],C[0].exit.call(e,t)}n.length=y}function w(){r.write([null]),s=void 0,r=void 0,e.containerState._closeFlow=void 0}}function gp(t,e,n){return N(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ln(t){if(t===null||se(t)||gd(t))return 1;if(pd(t))return 2}function Vt(t,e,n){let i=[],r=-1;for(;++r<t.length;){let s=t[r].resolveAll;s&&!i.includes(s)&&(e=s(e,n),i.push(s))}return e}var pi={name:"attention",resolveAll:vp,tokenize:bp};function vp(t,e){let n=-1,i,r,s,o,a,l,c,d;for(;++n<t.length;)if(t[n][0]==="enter"&&t[n][1].type==="attentionSequence"&&t[n][1]._close){for(i=n;i--;)if(t[i][0]==="exit"&&t[i][1].type==="attentionSequence"&&t[i][1]._open&&e.sliceSerialize(t[i][1]).charCodeAt(0)===e.sliceSerialize(t[n][1]).charCodeAt(0)){if((t[i][1]._close||t[n][1]._open)&&(t[n][1].end.offset-t[n][1].start.offset)%3&&!((t[i][1].end.offset-t[i][1].start.offset+t[n][1].end.offset-t[n][1].start.offset)%3))continue;l=t[i][1].end.offset-t[i][1].start.offset>1&&t[n][1].end.offset-t[n][1].start.offset>1?2:1;let h={...t[i][1].end},u={...t[n][1].start};wd(h,-l),wd(u,l),o={type:l>1?"strongSequence":"emphasisSequence",start:h,end:{...t[i][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...t[n][1].start},end:u},s={type:l>1?"strongText":"emphasisText",start:{...t[i][1].end},end:{...t[n][1].start}},r={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},t[i][1].end={...o.start},t[n][1].start={...a.end},c=[],t[i][1].end.offset-t[i][1].start.offset&&(c=Ae(c,[["enter",t[i][1],e],["exit",t[i][1],e]])),c=Ae(c,[["enter",r,e],["enter",o,e],["exit",o,e],["enter",s,e]]),c=Ae(c,Vt(e.parser.constructs.insideSpan.null,t.slice(i+1,n),e)),c=Ae(c,[["exit",s,e],["enter",a,e],["exit",a,e],["exit",r,e]]),t[n][1].end.offset-t[n][1].start.offset?(d=2,c=Ae(c,[["enter",t[n][1],e],["exit",t[n][1],e]])):d=0,we(t,i-1,n-i+3,c),n=i+c.length-d-2;break}}for(n=-1;++n<t.length;)t[n][1].type==="attentionSequence"&&(t[n][1].type="data");return t}function bp(t,e){let n=this.parser.constructs.attentionMarkers.null,i=this.previous,r=Ln(i),s;return o;function o(l){return s=l,t.enter("attentionSequence"),a(l)}function a(l){if(l===s)return t.consume(l),a;let c=t.exit("attentionSequence"),d=Ln(l),h=!d||d===2&&r||n.includes(l),u=!r||r===2&&d||n.includes(i);return c._open=!!(s===42?h:h&&(r||!u)),c._close=!!(s===42?u:u&&(d||!h)),e(l)}}function wd(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}var Ao={name:"autolink",tokenize:_p};function _p(t,e,n){let i=0;return r;function r(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),s}function s(f){return Ze(f)?(t.consume(f),o):f===64?n(f):c(f)}function o(f){return f===43||f===45||f===46||Pe(f)?(i=1,a(f)):c(f)}function a(f){return f===58?(t.consume(f),i=0,l):(f===43||f===45||f===46||Pe(f))&&i++<32?(t.consume(f),a):(i=0,c(f))}function l(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||fi(f)?n(f):(t.consume(f),l)}function c(f){return f===64?(t.consume(f),d):hd(f)?(t.consume(f),c):n(f)}function d(f){return Pe(f)?h(f):n(f)}function h(f){return f===46?(t.consume(f),i=0,d):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):u(f)}function u(f){if((f===45||Pe(f))&&i++<63){let m=f===45?u:h;return t.consume(f),m}return n(f)}}var qt={partial:!0,tokenize:wp};function wp(t,e,n){return i;function i(s){return M(s)?N(t,r,"linePrefix")(s):r(s)}function r(s){return s===null||T(s)?e(s):n(s)}}var ur={continuation:{tokenize:kp},exit:xp,name:"blockQuote",tokenize:yp};function yp(t,e,n){let i=this;return r;function r(o){if(o===62){let a=i.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(o),t.exit("blockQuoteMarker"),s}return n(o)}function s(o){return M(o)?(t.enter("blockQuotePrefixWhitespace"),t.consume(o),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(o))}}function kp(t,e,n){let i=this;return r;function r(o){return M(o)?N(t,s,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return t.attempt(ur,e,n)(o)}}function xp(t){t.exit("blockQuote")}var hr={name:"characterEscape",tokenize:Sp};function Sp(t,e,n){return i;function i(s){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(s),t.exit("escapeMarker"),r}function r(s){return md(s)?(t.enter("characterEscapeValue"),t.consume(s),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(s)}}var fr={name:"characterReference",tokenize:zp};function zp(t,e,n){let i=this,r=0,s,o;return a;function a(h){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),l}function l(h){return h===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(h),t.exit("characterReferenceMarkerNumeric"),c):(t.enter("characterReferenceValue"),s=31,o=Pe,d(h))}function c(h){return h===88||h===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(h),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),s=6,o=fd,d):(t.enter("characterReferenceValue"),s=7,o=mi,d(h))}function d(h){if(h===59&&r){let u=t.exit("characterReferenceValue");return o===Pe&&!cd(i.sliceSerialize(u))?n(h):(t.enter("characterReferenceMarker"),t.consume(h),t.exit("characterReferenceMarker"),t.exit("characterReference"),e)}return o(h)&&r++<s?(t.consume(h),d):n(h)}}var yd={partial:!0,tokenize:Cp},mr={concrete:!0,name:"codeFenced",tokenize:Ep};function Ep(t,e,n){let i=this,r={partial:!0,tokenize:C},s=0,o=0,a;return l;function l(k){return c(k)}function c(k){let E=i.events[i.events.length-1];return s=E&&E[1].type==="linePrefix"?E[2].sliceSerialize(E[1],!0).length:0,a=k,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),d(k)}function d(k){return k===a?(o++,t.consume(k),d):o<3?n(k):(t.exit("codeFencedFenceSequence"),M(k)?N(t,h,"whitespace")(k):h(k))}function h(k){return k===null||T(k)?(t.exit("codeFencedFence"),i.interrupt?e(k):t.check(yd,p,x)(k)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),u(k))}function u(k){return k===null||T(k)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),h(k)):M(k)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),N(t,f,"whitespace")(k)):k===96&&k===a?n(k):(t.consume(k),u)}function f(k){return k===null||T(k)?h(k):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||T(k)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),h(k)):k===96&&k===a?n(k):(t.consume(k),m)}function p(k){return t.attempt(r,x,v)(k)}function v(k){return t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),g}function g(k){return s>0&&M(k)?N(t,w,"linePrefix",s+1)(k):w(k)}function w(k){return k===null||T(k)?t.check(yd,p,x)(k):(t.enter("codeFlowValue"),y(k))}function y(k){return k===null||T(k)?(t.exit("codeFlowValue"),w(k)):(t.consume(k),y)}function x(k){return t.exit("codeFenced"),e(k)}function C(k,E,L){let D=0;return S;function S(K){return k.enter("lineEnding"),k.consume(K),k.exit("lineEnding"),ce}function ce(K){return k.enter("codeFencedFence"),M(K)?N(k,G,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):G(K)}function G(K){return K===a?(k.enter("codeFencedFenceSequence"),F(K)):L(K)}function F(K){return K===a?(D++,k.consume(K),F):D>=o?(k.exit("codeFencedFenceSequence"),M(K)?N(k,W,"whitespace")(K):W(K)):L(K)}function W(K){return K===null||T(K)?(k.exit("codeFencedFence"),E(K)):L(K)}}}function Cp(t,e,n){let i=this;return r;function r(o){return o===null?n(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return i.parser.lazy[i.now().line]?n(o):e(o)}}var gi={name:"codeIndented",tokenize:Op},Tp={partial:!0,tokenize:Rp};function Op(t,e,n){let i=this;return r;function r(c){return t.enter("codeIndented"),N(t,s,"linePrefix",5)(c)}function s(c){let d=i.events[i.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):T(c)?t.attempt(Tp,o,l)(c):(t.enter("codeFlowValue"),a(c))}function a(c){return c===null||T(c)?(t.exit("codeFlowValue"),o(c)):(t.consume(c),a)}function l(c){return t.exit("codeIndented"),e(c)}}function Rp(t,e,n){let i=this;return r;function r(o){return i.parser.lazy[i.now().line]?n(o):T(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),r):N(t,s,"linePrefix",5)(o)}function s(o){let a=i.events[i.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):T(o)?r(o):n(o)}}var Po={name:"codeText",previous:Ip,resolve:Lp,tokenize:Mp};function Lp(t){let e=t.length-4,n=3,i,r;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(i=n;++i<e;)if(t[i][1].type==="codeTextData"){t[n][1].type="codeTextPadding",t[e][1].type="codeTextPadding",n+=2,e-=2;break}}for(i=n-1,e++;++i<=e;)r===void 0?i!==e&&t[i][1].type!=="lineEnding"&&(r=i):(i===e||t[i][1].type==="lineEnding")&&(t[r][1].type="codeTextData",i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),e-=i-r-2,i=r+2),r=void 0);return t}function Ip(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Mp(t,e,n){let i=this,r=0,s,o;return a;function a(u){return t.enter("codeText"),t.enter("codeTextSequence"),l(u)}function l(u){return u===96?(t.consume(u),r++,l):(t.exit("codeTextSequence"),c(u))}function c(u){return u===null?n(u):u===32?(t.enter("space"),t.consume(u),t.exit("space"),c):u===96?(o=t.enter("codeTextSequence"),s=0,h(u)):T(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),c):(t.enter("codeTextData"),d(u))}function d(u){return u===null||u===32||u===96||T(u)?(t.exit("codeTextData"),c(u)):(t.consume(u),d)}function h(u){return u===96?(t.consume(u),s++,h):s===r?(t.exit("codeTextSequence"),t.exit("codeText"),e(u)):(o.type="codeTextData",d(u))}}var pr=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,n){let i=n??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(e,i):e>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(e,n,i){let r=n||0;this.setCursor(Math.trunc(e));let s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return i&&vi(this.left,i),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),vi(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),vi(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){let n=this.left.splice(e,Number.POSITIVE_INFINITY);vi(this.right,n.reverse())}else{let n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);vi(this.left,n.reverse())}}};function vi(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function gr(t){let e={},n=-1,i,r,s,o,a,l,c,d=new pr(t);for(;++n<d.length;){for(;n in e;)n=e[n];if(i=d.get(n),n&&i[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=i[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(i[0]==="enter")i[1].contentType&&(Object.assign(e,Np(d,n)),n=e[n],c=!0);else if(i[1]._container){for(s=n,r=void 0;s--;)if(o=d.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(r&&(d.get(r)[1].type="lineEndingBlank"),o[1].type="lineEnding",r=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;r&&(i[1].end={...d.get(r)[1].start},a=d.slice(r,n),a.unshift(i),d.splice(r,n-r+1,a))}}return we(t,0,Number.POSITIVE_INFINITY,d.slice(0)),!c}function Np(t,e){let n=t.get(e)[1],i=t.get(e)[2],r=e-1,s=[],o=n._tokenizer;o||(o=i.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let a=o.events,l=[],c={},d,h,u=-1,f=n,m=0,p=0,v=[p];for(;f;){for(;t.get(++r)[1]!==f;);s.push(r),f._tokenizer||(d=i.sliceStream(f),f.next||d.push(null),h&&o.defineSkip(f.start),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),f._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=f,f=f.next}for(f=n;++u<a.length;)a[u][0]==="exit"&&a[u-1][0]==="enter"&&a[u][1].type===a[u-1][1].type&&a[u][1].start.line!==a[u][1].end.line&&(p=u+1,v.push(p),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(o.events=[],f?(f._tokenizer=void 0,f.previous=void 0):v.pop(),u=v.length;u--;){let g=a.slice(v[u],v[u+1]),w=s.pop();l.push([w,w+g.length-1]),t.splice(w,2,g)}for(l.reverse(),u=-1;++u<l.length;)c[m+l[u][0]]=m+l[u][1],m+=l[u][1]-l[u][0]-1;return c}var Fo={resolve:Pp,tokenize:Fp},Ap={partial:!0,tokenize:$p};function Pp(t){return gr(t),t}function Fp(t,e){let n;return i;function i(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),r(a)}function r(a){return a===null?s(a):T(a)?t.check(Ap,o,s)(a):(t.consume(a),r)}function s(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function o(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}function $p(t,e,n){let i=this;return r;function r(o){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),N(t,s,"linePrefix")}function s(o){if(o===null||T(o))return n(o);let a=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(o):t.interrupt(i.parser.constructs.flow,n,e)(o)}}function vr(t,e,n,i,r,s,o,a,l){let c=l||Number.POSITIVE_INFINITY,d=0;return h;function h(g){return g===60?(t.enter(i),t.enter(r),t.enter(s),t.consume(g),t.exit(s),u):g===null||g===32||g===41||fi(g)?n(g):(t.enter(i),t.enter(o),t.enter(a),t.enter("chunkString",{contentType:"string"}),p(g))}function u(g){return g===62?(t.enter(s),t.consume(g),t.exit(s),t.exit(r),t.exit(i),e):(t.enter(a),t.enter("chunkString",{contentType:"string"}),f(g))}function f(g){return g===62?(t.exit("chunkString"),t.exit(a),u(g)):g===null||g===60||T(g)?n(g):(t.consume(g),g===92?m:f)}function m(g){return g===60||g===62||g===92?(t.consume(g),f):f(g)}function p(g){return!d&&(g===null||g===41||se(g))?(t.exit("chunkString"),t.exit(a),t.exit(o),t.exit(i),e(g)):d<c&&g===40?(t.consume(g),d++,p):g===41?(t.consume(g),d--,p):g===null||g===32||g===40||fi(g)?n(g):(t.consume(g),g===92?v:p)}function v(g){return g===40||g===41||g===92?(t.consume(g),p):p(g)}}function br(t,e,n,i,r,s){let o=this,a=0,l;return c;function c(f){return t.enter(i),t.enter(r),t.consume(f),t.exit(r),t.enter(s),d}function d(f){return a>999||f===null||f===91||f===93&&!l||f===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(f):f===93?(t.exit(s),t.enter(r),t.consume(f),t.exit(r),t.exit(i),e):T(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),h(f))}function h(f){return f===null||f===91||f===93||T(f)||a++>999?(t.exit("chunkString"),d(f)):(t.consume(f),l||(l=!M(f)),f===92?u:h)}function u(f){return f===91||f===92||f===93?(t.consume(f),a++,h):h(f)}}function _r(t,e,n,i,r,s){let o;return a;function a(u){return u===34||u===39||u===40?(t.enter(i),t.enter(r),t.consume(u),t.exit(r),o=u===40?41:u,l):n(u)}function l(u){return u===o?(t.enter(r),t.consume(u),t.exit(r),t.exit(i),e):(t.enter(s),c(u))}function c(u){return u===o?(t.exit(s),l(o)):u===null?n(u):T(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),N(t,c,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(u))}function d(u){return u===o||u===null||T(u)?(t.exit("chunkString"),c(u)):(t.consume(u),u===92?h:d)}function h(u){return u===o||u===92?(t.consume(u),d):d(u)}}function ln(t,e){let n;return i;function i(r){return T(r)?(t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),n=!0,i):M(r)?N(t,i,n?"linePrefix":"lineSuffix")(r):e(r)}}var $o={name:"definition",tokenize:Dp},Bp={partial:!0,tokenize:Vp};function Dp(t,e,n){let i=this,r;return s;function s(f){return t.enter("definition"),o(f)}function o(f){return br.call(i,t,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}function a(f){return r=hi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),f===58?(t.enter("definitionMarker"),t.consume(f),t.exit("definitionMarker"),l):n(f)}function l(f){return se(f)?ln(t,c)(f):c(f)}function c(f){return vr(t,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(f)}function d(f){return t.attempt(Bp,h,h)(f)}function h(f){return M(f)?N(t,u,"whitespace")(f):u(f)}function u(f){return f===null||T(f)?(t.exit("definition"),i.parser.defined.push(r),e(f)):n(f)}}function Vp(t,e,n){return i;function i(a){return se(a)?ln(t,r)(a):n(a)}function r(a){return _r(t,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return M(a)?N(t,o,"whitespace")(a):o(a)}function o(a){return a===null||T(a)?e(a):n(a)}}var Bo={name:"hardBreakEscape",tokenize:qp};function qp(t,e,n){return i;function i(s){return t.enter("hardBreakEscape"),t.consume(s),r}function r(s){return T(s)?(t.exit("hardBreakEscape"),e(s)):n(s)}}var Do={name:"headingAtx",resolve:jp,tokenize:Wp};function jp(t,e){let n=t.length-2,i=3,r,s;return t[i][1].type==="whitespace"&&(i+=2),n-2>i&&t[n][1].type==="whitespace"&&(n-=2),t[n][1].type==="atxHeadingSequence"&&(i===n-1||n-4>i&&t[n-2][1].type==="whitespace")&&(n-=i+1===n?2:4),n>i&&(r={type:"atxHeadingText",start:t[i][1].start,end:t[n][1].end},s={type:"chunkText",start:t[i][1].start,end:t[n][1].end,contentType:"text"},we(t,i,n-i+1,[["enter",r,e],["enter",s,e],["exit",s,e],["exit",r,e]])),t}function Wp(t,e,n){let i=0;return r;function r(d){return t.enter("atxHeading"),s(d)}function s(d){return t.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&i++<6?(t.consume(d),o):d===null||se(d)?(t.exit("atxHeadingSequence"),a(d)):n(d)}function a(d){return d===35?(t.enter("atxHeadingSequence"),l(d)):d===null||T(d)?(t.exit("atxHeading"),e(d)):M(d)?N(t,a,"whitespace")(d):(t.enter("atxHeadingText"),c(d))}function l(d){return d===35?(t.consume(d),l):(t.exit("atxHeadingSequence"),a(d))}function c(d){return d===null||d===35||se(d)?(t.exit("atxHeadingText"),a(d)):(t.consume(d),c)}}var kd=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Vo=["pre","script","style","textarea"];var qo={concrete:!0,name:"htmlFlow",resolveTo:Up,tokenize:Zp},Hp={partial:!0,tokenize:Jp},Kp={partial:!0,tokenize:Xp};function Up(t){let e=t.length;for(;e--&&!(t[e][0]==="enter"&&t[e][1].type==="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t}function Zp(t,e,n){let i=this,r,s,o,a,l;return c;function c(_){return d(_)}function d(_){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(_),h}function h(_){return _===33?(t.consume(_),u):_===47?(t.consume(_),s=!0,p):_===63?(t.consume(_),r=3,i.interrupt?e:b):Ze(_)?(t.consume(_),o=String.fromCharCode(_),v):n(_)}function u(_){return _===45?(t.consume(_),r=2,f):_===91?(t.consume(_),r=5,a=0,m):Ze(_)?(t.consume(_),r=4,i.interrupt?e:b):n(_)}function f(_){return _===45?(t.consume(_),i.interrupt?e:b):n(_)}function m(_){let ut="CDATA[";return _===ut.charCodeAt(a++)?(t.consume(_),a===ut.length?i.interrupt?e:G:m):n(_)}function p(_){return Ze(_)?(t.consume(_),o=String.fromCharCode(_),v):n(_)}function v(_){if(_===null||_===47||_===62||se(_)){let ut=_===47,er=o.toLowerCase();return!ut&&!s&&Vo.includes(er)?(r=1,i.interrupt?e(_):G(_)):kd.includes(o.toLowerCase())?(r=6,ut?(t.consume(_),g):i.interrupt?e(_):G(_)):(r=7,i.interrupt&&!i.parser.lazy[i.now().line]?n(_):s?w(_):y(_))}return _===45||Pe(_)?(t.consume(_),o+=String.fromCharCode(_),v):n(_)}function g(_){return _===62?(t.consume(_),i.interrupt?e:G):n(_)}function w(_){return M(_)?(t.consume(_),w):S(_)}function y(_){return _===47?(t.consume(_),S):_===58||_===95||Ze(_)?(t.consume(_),x):M(_)?(t.consume(_),y):S(_)}function x(_){return _===45||_===46||_===58||_===95||Pe(_)?(t.consume(_),x):C(_)}function C(_){return _===61?(t.consume(_),k):M(_)?(t.consume(_),C):y(_)}function k(_){return _===null||_===60||_===61||_===62||_===96?n(_):_===34||_===39?(t.consume(_),l=_,E):M(_)?(t.consume(_),k):L(_)}function E(_){return _===l?(t.consume(_),l=null,D):_===null||T(_)?n(_):(t.consume(_),E)}function L(_){return _===null||_===34||_===39||_===47||_===60||_===61||_===62||_===96||se(_)?C(_):(t.consume(_),L)}function D(_){return _===47||_===62||M(_)?y(_):n(_)}function S(_){return _===62?(t.consume(_),ce):n(_)}function ce(_){return _===null||T(_)?G(_):M(_)?(t.consume(_),ce):n(_)}function G(_){return _===45&&r===2?(t.consume(_),ke):_===60&&r===1?(t.consume(_),Te):_===62&&r===4?(t.consume(_),mt):_===63&&r===3?(t.consume(_),b):_===93&&r===5?(t.consume(_),Bt):T(_)&&(r===6||r===7)?(t.exit("htmlFlowData"),t.check(Hp,Qt,F)(_)):_===null||T(_)?(t.exit("htmlFlowData"),F(_)):(t.consume(_),G)}function F(_){return t.check(Kp,W,Qt)(_)}function W(_){return t.enter("lineEnding"),t.consume(_),t.exit("lineEnding"),K}function K(_){return _===null||T(_)?F(_):(t.enter("htmlFlowData"),G(_))}function ke(_){return _===45?(t.consume(_),b):G(_)}function Te(_){return _===47?(t.consume(_),o="",Tt):G(_)}function Tt(_){if(_===62){let ut=o.toLowerCase();return Vo.includes(ut)?(t.consume(_),mt):G(_)}return Ze(_)&&o.length<8?(t.consume(_),o+=String.fromCharCode(_),Tt):G(_)}function Bt(_){return _===93?(t.consume(_),b):G(_)}function b(_){return _===62?(t.consume(_),mt):_===45&&r===2?(t.consume(_),b):G(_)}function mt(_){return _===null||T(_)?(t.exit("htmlFlowData"),Qt(_)):(t.consume(_),mt)}function Qt(_){return t.exit("htmlFlow"),e(_)}}function Xp(t,e,n){let i=this;return r;function r(o){return T(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s):n(o)}function s(o){return i.parser.lazy[i.now().line]?n(o):e(o)}}function Jp(t,e,n){return i;function i(r){return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),t.attempt(qt,e,n)}}var jo={name:"htmlText",tokenize:Gp};function Gp(t,e,n){let i=this,r,s,o;return a;function a(b){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(b),l}function l(b){return b===33?(t.consume(b),c):b===47?(t.consume(b),C):b===63?(t.consume(b),y):Ze(b)?(t.consume(b),L):n(b)}function c(b){return b===45?(t.consume(b),d):b===91?(t.consume(b),s=0,m):Ze(b)?(t.consume(b),w):n(b)}function d(b){return b===45?(t.consume(b),f):n(b)}function h(b){return b===null?n(b):b===45?(t.consume(b),u):T(b)?(o=h,Te(b)):(t.consume(b),h)}function u(b){return b===45?(t.consume(b),f):h(b)}function f(b){return b===62?ke(b):b===45?u(b):h(b)}function m(b){let mt="CDATA[";return b===mt.charCodeAt(s++)?(t.consume(b),s===mt.length?p:m):n(b)}function p(b){return b===null?n(b):b===93?(t.consume(b),v):T(b)?(o=p,Te(b)):(t.consume(b),p)}function v(b){return b===93?(t.consume(b),g):p(b)}function g(b){return b===62?ke(b):b===93?(t.consume(b),g):p(b)}function w(b){return b===null||b===62?ke(b):T(b)?(o=w,Te(b)):(t.consume(b),w)}function y(b){return b===null?n(b):b===63?(t.consume(b),x):T(b)?(o=y,Te(b)):(t.consume(b),y)}function x(b){return b===62?ke(b):y(b)}function C(b){return Ze(b)?(t.consume(b),k):n(b)}function k(b){return b===45||Pe(b)?(t.consume(b),k):E(b)}function E(b){return T(b)?(o=E,Te(b)):M(b)?(t.consume(b),E):ke(b)}function L(b){return b===45||Pe(b)?(t.consume(b),L):b===47||b===62||se(b)?D(b):n(b)}function D(b){return b===47?(t.consume(b),ke):b===58||b===95||Ze(b)?(t.consume(b),S):T(b)?(o=D,Te(b)):M(b)?(t.consume(b),D):ke(b)}function S(b){return b===45||b===46||b===58||b===95||Pe(b)?(t.consume(b),S):ce(b)}function ce(b){return b===61?(t.consume(b),G):T(b)?(o=ce,Te(b)):M(b)?(t.consume(b),ce):D(b)}function G(b){return b===null||b===60||b===61||b===62||b===96?n(b):b===34||b===39?(t.consume(b),r=b,F):T(b)?(o=G,Te(b)):M(b)?(t.consume(b),G):(t.consume(b),W)}function F(b){return b===r?(t.consume(b),r=void 0,K):b===null?n(b):T(b)?(o=F,Te(b)):(t.consume(b),F)}function W(b){return b===null||b===34||b===39||b===60||b===61||b===96?n(b):b===47||b===62||se(b)?D(b):(t.consume(b),W)}function K(b){return b===47||b===62||se(b)?D(b):n(b)}function ke(b){return b===62?(t.consume(b),t.exit("htmlTextData"),t.exit("htmlText"),e):n(b)}function Te(b){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),Tt}function Tt(b){return M(b)?N(t,Bt,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(b):Bt(b)}function Bt(b){return t.enter("htmlTextData"),o(b)}}var cn={name:"labelEnd",resolveAll:tg,resolveTo:ng,tokenize:ig},Yp={tokenize:rg},Qp={tokenize:sg},eg={tokenize:og};function tg(t){let e=-1,n=[];for(;++e<t.length;){let i=t[e][1];if(n.push(t[e]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){let r=i.type==="labelImage"?4:2;i.type="data",e+=r}}return t.length!==n.length&&we(t,0,t.length,n),t}function ng(t,e){let n=t.length,i=0,r,s,o,a;for(;n--;)if(r=t[n][1],s){if(r.type==="link"||r.type==="labelLink"&&r._inactive)break;t[n][0]==="enter"&&r.type==="labelLink"&&(r._inactive=!0)}else if(o){if(t[n][0]==="enter"&&(r.type==="labelImage"||r.type==="labelLink")&&!r._balanced&&(s=n,r.type!=="labelLink")){i=2;break}}else r.type==="labelEnd"&&(o=n);let l={type:t[s][1].type==="labelLink"?"link":"image",start:{...t[s][1].start},end:{...t[t.length-1][1].end}},c={type:"label",start:{...t[s][1].start},end:{...t[o][1].end}},d={type:"labelText",start:{...t[s+i+2][1].end},end:{...t[o-2][1].start}};return a=[["enter",l,e],["enter",c,e]],a=Ae(a,t.slice(s+1,s+i+3)),a=Ae(a,[["enter",d,e]]),a=Ae(a,Vt(e.parser.constructs.insideSpan.null,t.slice(s+i+4,o-3),e)),a=Ae(a,[["exit",d,e],t[o-2],t[o-1],["exit",c,e]]),a=Ae(a,t.slice(o+1)),a=Ae(a,[["exit",l,e]]),we(t,s,t.length,a),t}function ig(t,e,n){let i=this,r=i.events.length,s,o;for(;r--;)if((i.events[r][1].type==="labelImage"||i.events[r][1].type==="labelLink")&&!i.events[r][1]._balanced){s=i.events[r][1];break}return a;function a(u){return s?s._inactive?h(u):(o=i.parser.defined.includes(hi(i.sliceSerialize({start:s.end,end:i.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(u),t.exit("labelMarker"),t.exit("labelEnd"),l):n(u)}function l(u){return u===40?t.attempt(Yp,d,o?d:h)(u):u===91?t.attempt(Qp,d,o?c:h)(u):o?d(u):h(u)}function c(u){return t.attempt(eg,d,h)(u)}function d(u){return e(u)}function h(u){return s._balanced=!0,n(u)}}function rg(t,e,n){return i;function i(h){return t.enter("resource"),t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),r}function r(h){return se(h)?ln(t,s)(h):s(h)}function s(h){return h===41?d(h):vr(t,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return se(h)?ln(t,l)(h):d(h)}function a(h){return n(h)}function l(h){return h===34||h===39||h===40?_r(t,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):d(h)}function c(h){return se(h)?ln(t,d)(h):d(h)}function d(h){return h===41?(t.enter("resourceMarker"),t.consume(h),t.exit("resourceMarker"),t.exit("resource"),e):n(h)}}function sg(t,e,n){let i=this;return r;function r(a){return br.call(i,t,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return i.parser.defined.includes(hi(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function o(a){return n(a)}}function og(t,e,n){return i;function i(s){return t.enter("reference"),t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),r}function r(s){return s===93?(t.enter("referenceMarker"),t.consume(s),t.exit("referenceMarker"),t.exit("reference"),e):n(s)}}var Wo={name:"labelStartImage",resolveAll:cn.resolveAll,tokenize:ag};function ag(t,e,n){let i=this;return r;function r(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),s}function s(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(a):e(a)}}var Ho={name:"labelStartLink",resolveAll:cn.resolveAll,tokenize:lg};function lg(t,e,n){let i=this;return r;function r(o){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(o),t.exit("labelMarker"),t.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in i.parser.constructs?n(o):e(o)}}var bi={name:"lineEnding",tokenize:cg};function cg(t,e){return n;function n(i){return t.enter("lineEnding"),t.consume(i),t.exit("lineEnding"),N(t,e,"linePrefix")}}var dn={name:"thematicBreak",tokenize:dg};function dg(t,e,n){let i=0,r;return s;function s(c){return t.enter("thematicBreak"),o(c)}function o(c){return r=c,a(c)}function a(c){return c===r?(t.enter("thematicBreakSequence"),l(c)):i>=3&&(c===null||T(c))?(t.exit("thematicBreak"),e(c)):n(c)}function l(c){return c===r?(t.consume(c),i++,l):(t.exit("thematicBreakSequence"),M(c)?N(t,a,"whitespace")(c):a(c))}}var Ie={continuation:{tokenize:mg},exit:gg,name:"list",tokenize:fg},ug={partial:!0,tokenize:vg},hg={partial:!0,tokenize:pg};function fg(t,e,n){let i=this,r=i.events[i.events.length-1],s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,o=0;return a;function a(f){let m=i.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!i.containerState.marker||f===i.containerState.marker:mi(f)){if(i.containerState.type||(i.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(dn,n,c)(f):c(f);if(!i.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),l(f)}return n(f)}function l(f){return mi(f)&&++o<10?(t.consume(f),l):(!i.interrupt||o<2)&&(i.containerState.marker?f===i.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),c(f)):n(f)}function c(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||f,t.check(qt,i.interrupt?n:d,t.attempt(ug,u,h))}function d(f){return i.containerState.initialBlankLine=!0,s++,u(f)}function h(f){return M(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),u):n(f)}function u(f){return i.containerState.size=s+i.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}function mg(t,e,n){let i=this;return i.containerState._closeFlow=void 0,t.check(qt,r,s);function r(a){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,N(t,e,"listItemIndent",i.containerState.size+1)(a)}function s(a){return i.containerState.furtherBlankLines||!M(a)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,o(a)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,t.attempt(hg,e,o)(a))}function o(a){return i.containerState._closeFlow=!0,i.interrupt=void 0,N(t,t.attempt(Ie,e,n),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function pg(t,e,n){let i=this;return N(t,r,"listItemIndent",i.containerState.size+1);function r(s){let o=i.events[i.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===i.containerState.size?e(s):n(s)}}function gg(t){t.exit(this.containerState.type)}function vg(t,e,n){let i=this;return N(t,r,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function r(s){let o=i.events[i.events.length-1];return!M(s)&&o&&o[1].type==="listItemPrefixWhitespace"?e(s):n(s)}}var wr={name:"setextUnderline",resolveTo:bg,tokenize:_g};function bg(t,e){let n=t.length,i,r,s;for(;n--;)if(t[n][0]==="enter"){if(t[n][1].type==="content"){i=n;break}t[n][1].type==="paragraph"&&(r=n)}else t[n][1].type==="content"&&t.splice(n,1),!s&&t[n][1].type==="definition"&&(s=n);let o={type:"setextHeading",start:{...t[i][1].start},end:{...t[t.length-1][1].end}};return t[r][1].type="setextHeadingText",s?(t.splice(r,0,["enter",o,e]),t.splice(s+1,0,["exit",t[i][1],e]),t[i][1].end={...t[s][1].end}):t[i][1]=o,t.push(["exit",o,e]),t}function _g(t,e,n){let i=this,r;return s;function s(c){let d=i.events.length,h;for(;d--;)if(i.events[d][1].type!=="lineEnding"&&i.events[d][1].type!=="linePrefix"&&i.events[d][1].type!=="content"){h=i.events[d][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||h)?(t.enter("setextHeadingLine"),r=c,o(c)):n(c)}function o(c){return t.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===r?(t.consume(c),a):(t.exit("setextHeadingLineSequence"),M(c)?N(t,l,"lineSuffix")(c):l(c))}function l(c){return c===null||T(c)?(t.exit("setextHeadingLine"),e(c)):n(c)}}var xd={tokenize:wg};function wg(t){let e=this,n=t.attempt(qt,i,t.attempt(this.parser.constructs.flowInitial,r,N(t,t.attempt(this.parser.constructs.flow,r,t.attempt(Fo,r)),"linePrefix")));return n;function i(s){if(s===null){t.consume(s);return}return t.enter("lineEndingBlank"),t.consume(s),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n}function r(s){if(s===null){t.consume(s);return}return t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),e.currentConstruct=void 0,n}}var Sd={resolveAll:Td()},zd=Cd("string"),Ed=Cd("text");function Cd(t){return{resolveAll:Td(t==="text"?yg:void 0),tokenize:e};function e(n){let i=this,r=this.parser.constructs[t],s=n.attempt(r,o,a);return o;function o(d){return c(d)?s(d):a(d)}function a(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return c(d)?(n.exit("data"),s(d)):(n.consume(d),l)}function c(d){if(d===null)return!0;let h=r[d],u=-1;if(h)for(;++u<h.length;){let f=h[u];if(!f.previous||f.previous.call(i,i.previous))return!0}return!1}}}function Td(t){return e;function e(n,i){let r=-1,s;for(;++r<=n.length;)s===void 0?n[r]&&n[r][1].type==="data"&&(s=r,r++):(!n[r]||n[r][1].type!=="data")&&(r!==s+2&&(n[s][1].end=n[r-1][1].end,n.splice(s+2,r-s-2),r=s+2),s=void 0);return t?t(n,i):n}}function yg(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){let i=t[n-1][1],r=e.sliceStream(i),s=r.length,o=-1,a=0,l;for(;s--;){let c=r[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(a=0),a){let c={type:n===t.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:i.start._bufferIndex+o,_index:i.start._index+s,line:i.end.line,column:i.end.column-a,offset:i.end.offset-a},end:{...i.end}};i.end={...c.start},i.start.offset===i.end.offset?Object.assign(i,c):(t.splice(n,0,["enter",c,e],["exit",c,e]),n+=2)}n++}return t}var Ko={};Mm(Ko,{attentionMarkers:()=>Og,contentInitial:()=>xg,disable:()=>Rg,document:()=>kg,flow:()=>zg,flowInitial:()=>Sg,insideSpan:()=>Tg,string:()=>Eg,text:()=>Cg});var kg={42:Ie,43:Ie,45:Ie,48:Ie,49:Ie,50:Ie,51:Ie,52:Ie,53:Ie,54:Ie,55:Ie,56:Ie,57:Ie,62:ur},xg={91:$o},Sg={[-2]:gi,[-1]:gi,32:gi},zg={35:Do,42:dn,45:[wr,dn],60:qo,61:wr,95:dn,96:mr,126:mr},Eg={38:fr,92:hr},Cg={[-5]:bi,[-4]:bi,[-3]:bi,33:Wo,38:fr,42:pi,60:[Ao,jo],91:Ho,92:[Bo,hr],93:cn,95:pi,96:Po},Tg={null:[pi,Sd]},Og={null:[42,95]},Rg={null:[]};function Od(t,e,n){let i={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},r={},s=[],o=[],a=[],l=!0,c={attempt:D(E),check:D(L),consume:x,enter:C,exit:k,interrupt:D(L,{interrupt:!0})},d={code:null,containerState:{},defineSkip:g,events:[],now:v,parser:t,previous:null,sliceSerialize:m,sliceStream:p,write:f},h=e.tokenize.call(d,c),u;return e.resolveAll&&s.push(e),d;function f(F){return o=Ae(o,F),w(),o[o.length-1]!==null?[]:(S(e,0),d.events=Vt(s,d.events,d),d.events)}function m(F,W){return Ig(p(F),W)}function p(F){return Lg(o,F)}function v(){let{_bufferIndex:F,_index:W,line:K,column:ke,offset:Te}=i;return{_bufferIndex:F,_index:W,line:K,column:ke,offset:Te}}function g(F){r[F.line]=F.column,G()}function w(){let F;for(;i._index<o.length;){let W=o[i._index];if(typeof W=="string")for(F=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===F&&i._bufferIndex<W.length;)y(W.charCodeAt(i._bufferIndex));else y(W)}}function y(F){l=void 0,u=F,h=h(F)}function x(F){T(F)?(i.line++,i.column=1,i.offset+=F===-3?2:1,G()):F!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===o[i._index].length&&(i._bufferIndex=-1,i._index++)),d.previous=F,l=!0}function C(F,W){let K=W||{};return K.type=F,K.start=v(),d.events.push(["enter",K,d]),a.push(K),K}function k(F){let W=a.pop();return W.end=v(),d.events.push(["exit",W,d]),W}function E(F,W){S(F,W.from)}function L(F,W){W.restore()}function D(F,W){return K;function K(ke,Te,Tt){let Bt,b,mt,Qt;return Array.isArray(ke)?ut(ke):"tokenize"in ke?ut([ke]):_(ke);function _(Ne){return go;function go(en){let tr=en!==null&&Ne[en],nr=en!==null&&Ne.null,Lm=[...Array.isArray(tr)?tr:tr?[tr]:[],...Array.isArray(nr)?nr:nr?[nr]:[]];return ut(Lm)(en)}}function ut(Ne){return Bt=Ne,b=0,Ne.length===0?Tt:er(Ne[b])}function er(Ne){return go;function go(en){return Qt=ce(),mt=Ne,Ne.partial||(d.currentConstruct=Ne),Ne.name&&d.parser.constructs.disable.null.includes(Ne.name)?Ic(en):Ne.tokenize.call(W?Object.assign(Object.create(d),W):d,c,Rm,Ic)(en)}}function Rm(Ne){return l=!0,F(mt,Qt),Te}function Ic(Ne){return l=!0,Qt.restore(),++b<Bt.length?er(Bt[b]):Tt}}}function S(F,W){F.resolveAll&&!s.includes(F)&&s.push(F),F.resolve&&we(d.events,W,d.events.length-W,F.resolve(d.events.slice(W),d)),F.resolveTo&&(d.events=F.resolveTo(d.events,d))}function ce(){let F=v(),W=d.previous,K=d.currentConstruct,ke=d.events.length,Te=Array.from(a);return{from:ke,restore:Tt};function Tt(){i=F,d.previous=W,d.currentConstruct=K,d.events.length=ke,a=Te,G()}}function G(){i.line in r&&i.column<2&&(i.column=r[i.line],i.offset+=r[i.line]-1)}}function Lg(t,e){let n=e.start._index,i=e.start._bufferIndex,r=e.end._index,s=e.end._bufferIndex,o;if(n===r)o=[t[n].slice(i,s)];else{if(o=t.slice(n,r),i>-1){let a=o[0];typeof a=="string"?o[0]=a.slice(i):o.shift()}s>0&&o.push(t[r].slice(0,s))}return o}function Ig(t,e){let n=-1,i=[],r;for(;++n<t.length;){let s=t[n],o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
`;break}case-3:{o=`\r
`;break}case-2:{o=e?" ":"	";break}case-1:{if(!e&&r)continue;o=" ";break}default:o=String.fromCharCode(s)}r=s===-2,i.push(o)}return i.join("")}function Uo(t){let i={constructs:ud([Ko,...(t||{}).extensions||[]]),content:r(vd),defined:[],document:r(_d),flow:r(xd),lazy:{},string:r(zd),text:r(Ed)};return i;function r(s){return o;function o(a){return Od(i,s,a)}}}function Zo(t){for(;!gr(t););return t}var Rd=/[\0\t\n\r]/g;function Xo(){let t=1,e="",n=!0,i;return r;function r(s,o,a){let l=[],c,d,h,u,f;for(s=e+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,e="",n&&(s.charCodeAt(0)===65279&&h++,n=void 0);h<s.length;){if(Rd.lastIndex=h,c=Rd.exec(s),u=c&&c.index!==void 0?c.index:s.length,f=s.charCodeAt(u),!c){e=s.slice(h);break}if(f===10&&h===u&&i)l.push(-3),i=void 0;else switch(i&&(l.push(-5),i=void 0),h<u&&(l.push(s.slice(h,u)),t+=u-h),f){case 0:{l.push(65533),t++;break}case 9:{for(d=Math.ceil(t/4)*4,l.push(-2);t++<d;)l.push(-1);break}case 10:{l.push(-4),t=1;break}default:i=!0,t=1}h=u+1}return a&&(i&&l.push(-5),e&&l.push(e),l.push(null)),l}}var Id=Nm(Ld(),1),_i=Object.assign(un(Error),{eval:un(EvalError),range:un(RangeError),reference:un(ReferenceError),syntax:un(SyntaxError),type:un(TypeError),uri:un(URIError)});function un(t){return e.displayName=t.displayName||t.name,e;function e(n,...i){let r=n&&(0,Id.default)(n,...i);return new t(r)}}var yr={}.hasOwnProperty,Md={yaml:"-",toml:"+"};function Nd(t){let e=[],n=-1,i=Array.isArray(t)?t:t?[t]:["yaml"];for(;++n<i.length;)e[n]=Mg(i[n]);return e}function Mg(t){let e=t;if(typeof e=="string"){if(!yr.call(Md,e))throw _i("Missing matter definition for `%s`",e);e={type:e,marker:Md[e]}}else if(typeof e!="object")throw _i("Expected matter to be an object, not `%j`",e);if(!yr.call(e,"type"))throw _i("Missing `type` in matter `%j`",e);if(!yr.call(e,"fence")&&!yr.call(e,"marker"))throw _i("Missing `marker` or `fence` in matter `%j`",e);return e}function Yo(t){let e=Nd(t),n={},i=-1;for(;++i<e.length;){let r=e[i],s=Go(r,"open").charCodeAt(0),o=Ng(r),a=n[s];Array.isArray(a)?a.push(o):n[s]=[o]}return{flow:n}}function Ng(t){let e=t.anywhere,n=t.type,i=n+"Fence",r=i+"Sequence",s=n+"Value",o={tokenize:d,partial:!0},a,l=0;return{tokenize:c,concrete:!0};function c(h,u,f){let m=this;return p;function p(E){let L=m.now();return L.column===1&&(L.line===1||e)&&(a=Go(t,"open"),l=0,E===a.charCodeAt(l))?(h.enter(n),h.enter(i),h.enter(r),v(E)):f(E)}function v(E){return l===a.length?(h.exit(r),M(E)?(h.enter("whitespace"),g(E)):w(E)):E===a.charCodeAt(l++)?(h.consume(E),v):f(E)}function g(E){return M(E)?(h.consume(E),g):(h.exit("whitespace"),w(E))}function w(E){return T(E)?(h.exit(i),h.enter("lineEnding"),h.consume(E),h.exit("lineEnding"),a=Go(t,"close"),l=0,h.attempt(o,k,y)):f(E)}function y(E){return E===null||T(E)?C(E):(h.enter(s),x(E))}function x(E){return E===null||T(E)?(h.exit(s),C(E)):(h.consume(E),x)}function C(E){return E===null?f(E):(h.enter("lineEnding"),h.consume(E),h.exit("lineEnding"),h.attempt(o,k,y))}function k(E){return h.exit(n),u(E)}}function d(h,u,f){let m=0;return p;function p(y){return y===a.charCodeAt(m)?(h.enter(i),h.enter(r),v(y)):f(y)}function v(y){return m===a.length?(h.exit(r),M(y)?(h.enter("whitespace"),g(y)):w(y)):y===a.charCodeAt(m++)?(h.consume(y),v):f(y)}function g(y){return M(y)?(h.consume(y),g):(h.exit("whitespace"),w(y))}function w(y){return y===null||T(y)?(h.exit(i),u(y)):f(y)}}}function Go(t,e){return t.marker?Ad(t.marker,e).repeat(3):Ad(t.fence,e)}function Ad(t,e){return typeof t=="string"?t:t[e]}var Fd={tokenize:Ag,concrete:!0,name:"mathFlow"},Pd={tokenize:Pg,partial:!0};function Ag(t,e,n){let i=this,r=i.events[i.events.length-1],s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,o=0;return a;function a(w){return t.enter("mathFlow"),t.enter("mathFlowFence"),t.enter("mathFlowFenceSequence"),l(w)}function l(w){return w===36?(t.consume(w),o++,l):o<2?n(w):(t.exit("mathFlowFenceSequence"),N(t,c,"whitespace")(w))}function c(w){return w===null||T(w)?h(w):(t.enter("mathFlowFenceMeta"),t.enter("chunkString",{contentType:"string"}),d(w))}function d(w){return w===null||T(w)?(t.exit("chunkString"),t.exit("mathFlowFenceMeta"),h(w)):w===36?n(w):(t.consume(w),d)}function h(w){return t.exit("mathFlowFence"),i.interrupt?e(w):t.attempt(Pd,u,v)(w)}function u(w){return t.attempt({tokenize:g,partial:!0},v,f)(w)}function f(w){return(s?N(t,m,"linePrefix",s+1):m)(w)}function m(w){return w===null?v(w):T(w)?t.attempt(Pd,u,v)(w):(t.enter("mathFlowValue"),p(w))}function p(w){return w===null||T(w)?(t.exit("mathFlowValue"),m(w)):(t.consume(w),p)}function v(w){return t.exit("mathFlow"),e(w)}function g(w,y,x){let C=0;return N(w,k,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function k(D){return w.enter("mathFlowFence"),w.enter("mathFlowFenceSequence"),E(D)}function E(D){return D===36?(C++,w.consume(D),E):C<o?x(D):(w.exit("mathFlowFenceSequence"),N(w,L,"whitespace")(D))}function L(D){return D===null||T(D)?(w.exit("mathFlowFence"),y(D)):x(D)}}}function Pg(t,e,n){let i=this;return r;function r(o){return o===null?e(o):(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),s)}function s(o){return i.parser.lazy[i.now().line]?n(o):e(o)}}function $d(t){let n=(t||{}).singleDollarTextMath;return n==null&&(n=!0),{tokenize:i,resolve:Fg,previous:$g,name:"mathText"};function i(r,s,o){let a=this,l=0,c,d;return h;function h(v){return r.enter("mathText"),r.enter("mathTextSequence"),u(v)}function u(v){return v===36?(r.consume(v),l++,u):l<2&&!n?o(v):(r.exit("mathTextSequence"),f(v))}function f(v){return v===null?o(v):v===36?(d=r.enter("mathTextSequence"),c=0,p(v)):v===32?(r.enter("space"),r.consume(v),r.exit("space"),f):T(v)?(r.enter("lineEnding"),r.consume(v),r.exit("lineEnding"),f):(r.enter("mathTextData"),m(v))}function m(v){return v===null||v===32||v===36||T(v)?(r.exit("mathTextData"),f(v)):(r.consume(v),m)}function p(v){return v===36?(r.consume(v),c++,p):c===l?(r.exit("mathTextSequence"),r.exit("mathText"),s(v)):(d.type="mathTextData",m(v))}}}function Fg(t){let e=t.length-4,n=3,i,r;if((t[n][1].type==="lineEnding"||t[n][1].type==="space")&&(t[e][1].type==="lineEnding"||t[e][1].type==="space")){for(i=n;++i<e;)if(t[i][1].type==="mathTextData"){t[e][1].type="mathTextPadding",t[n][1].type="mathTextPadding",n+=2,e-=2;break}}for(i=n-1,e++;++i<=e;)r===void 0?i!==e&&t[i][1].type!=="lineEnding"&&(r=i):(i===e||t[i][1].type==="lineEnding")&&(t[r][1].type="mathTextData",i!==r+2&&(t[r][1].end=t[i-1][1].end,t.splice(r+2,i-r-2),e-=i-r-2,i=r+2),r=void 0);return t}function $g(t){return t!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Qo(t){return{flow:{36:Fd},text:{36:$d(t)}}}var kr=class{constructor(){this.map=[]}add(e,n,i){Bg(this,e,n,i)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length,i=[];for(;n>0;)n-=1,i.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];i.push(e.slice()),e.length=0;let r=i.pop();for(;r;){for(let s of r)e.push(s);r=i.pop()}this.map.length=0}};function Bg(t,e,n,i){let r=0;if(!(n===0&&i.length===0)){for(;r<t.map.length;){if(t.map[r][0]===e){t.map[r][1]+=n,t.map[r][2].push(...i);return}r+=1}t.map.push([e,n,i])}}function Bd(t,e){let n=!1,i=[];for(;e<t.length;){let r=t[e];if(n){if(r[0]==="enter")r[1].type==="tableContent"&&i.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(r[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){let s=i.length-1;i[s]=i[s]==="left"?"center":"right"}}else if(r[1].type==="tableDelimiterRow")break}else r[0]==="enter"&&r[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return i}function ea(){return{flow:{null:{name:"table",tokenize:Dg,resolveAll:Vg}}}}function Dg(t,e,n){let i=this,r=0,s=0,o;return a;function a(S){let ce=i.events.length-1;for(;ce>-1;){let W=i.events[ce][1].type;if(W==="lineEnding"||W==="linePrefix")ce--;else break}let G=ce>-1?i.events[ce][1].type:null,F=G==="tableHead"||G==="tableRow"?k:l;return F===k&&i.parser.lazy[i.now().line]?n(S):F(S)}function l(S){return t.enter("tableHead"),t.enter("tableRow"),c(S)}function c(S){return S===124||(o=!0,s+=1),d(S)}function d(S){return S===null?n(S):T(S)?s>1?(s=0,i.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(S),t.exit("lineEnding"),f):n(S):M(S)?N(t,d,"whitespace")(S):(s+=1,o&&(o=!1,r+=1),S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),o=!0,d):(t.enter("data"),h(S)))}function h(S){return S===null||S===124||se(S)?(t.exit("data"),d(S)):(t.consume(S),S===92?u:h)}function u(S){return S===92||S===124?(t.consume(S),h):h(S)}function f(S){return i.interrupt=!1,i.parser.lazy[i.now().line]?n(S):(t.enter("tableDelimiterRow"),o=!1,M(S)?N(t,m,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(S):m(S))}function m(S){return S===45||S===58?v(S):S===124?(o=!0,t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),p):C(S)}function p(S){return M(S)?N(t,v,"whitespace")(S):v(S)}function v(S){return S===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),g):S===45?(s+=1,g(S)):S===null||T(S)?x(S):C(S)}function g(S){return S===45?(t.enter("tableDelimiterFiller"),w(S)):C(S)}function w(S){return S===45?(t.consume(S),w):S===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(S),t.exit("tableDelimiterMarker"),y):(t.exit("tableDelimiterFiller"),y(S))}function y(S){return M(S)?N(t,x,"whitespace")(S):x(S)}function x(S){return S===124?m(S):S===null||T(S)?!o||r!==s?C(S):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(S)):C(S)}function C(S){return n(S)}function k(S){return t.enter("tableRow"),E(S)}function E(S){return S===124?(t.enter("tableCellDivider"),t.consume(S),t.exit("tableCellDivider"),E):S===null||T(S)?(t.exit("tableRow"),e(S)):M(S)?N(t,E,"whitespace")(S):(t.enter("data"),L(S))}function L(S){return S===null||S===124||se(S)?(t.exit("data"),E(S)):(t.consume(S),S===92?D:L)}function D(S){return S===92||S===124?(t.consume(S),L):L(S)}}function Vg(t,e){let n=-1,i=!0,r=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,d,h,u=new kr;for(;++n<t.length;){let f=t[n],m=f[1];f[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(Dd(u,e,l,c,d),d=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},u.add(n,0,[["enter",c,e]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(i=!0,h=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,d={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},u.add(n,0,[["enter",d,e]])),r=m.type==="tableDelimiterRow"?2:d?3:1):r&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(i=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],h=xr(u,e,s,r,void 0,h),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(i?i=!1:(s[1]!==0&&(o[0]=o[1],h=xr(u,e,s,r,void 0,h)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],h=xr(u,e,s,r,n,h)):o[1]!==0&&(h=xr(u,e,o,r,n,h)),r=0):r&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Dd(u,e,l,c,d),u.consume(e.events),n=-1;++n<e.events.length;){let f=e.events[n];f[0]==="enter"&&f[1].type==="table"&&(f[1]._align=Bd(e.events,n))}return t}function xr(t,e,n,i,r,s){let o=i===1?"tableHeader":i===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},In(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));let l=In(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){let c=In(e.events,n[2]),d=In(e.events,n[3]),h={type:a,start:Object.assign({},c),end:Object.assign({},d)};if(t.add(n[2],0,[["enter",h,e]]),i!==2){let u=e.events[n[2]],f=e.events[n[3]];if(u[1].end=Object.assign({},f[1].end),u[1].type="chunkText",u[1].contentType="text",n[3]>n[2]+1){let m=n[2]+1,p=n[3]-n[2]-1;t.add(m,p,[])}}t.add(n[3]+1,0,[["exit",h,e]])}return r!==void 0&&(s.end=Object.assign({},In(e.events,r)),t.add(r,0,[["exit",s,e]]),s=void 0),s}function Dd(t,e,n,i,r){let s=[],o=In(e.events,n);r&&(r.end=Object.assign({},o),s.push(["exit",r,e])),i.end=Object.assign({},o),s.push(["exit",i,e]),t.add(n+1,0,s)}function In(t,e){let n=t[e],i=n[0]==="enter"?"start":"end";return n[1][i]}var qg={name:"tasklistCheck",tokenize:jg};function ta(){return{text:{91:qg}}}function jg(t,e,n){let i=this;return r;function r(l){return i.previous!==null||!i._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return se(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return T(l)?e(l):M(l)?t.check({tokenize:Wg},e,n)(l):n(l)}}function Wg(t,e,n){return N(t,i,"whitespace");function i(r){return r===null?n(r):e(r)}}function na(t){let n=(t||{}).singleTilde,i={name:"strikethrough",tokenize:s,resolveAll:r};return n==null&&(n=!0),{text:{126:i},insideSpan:{null:[i]},attentionMarkers:{null:[126]}};function r(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";let d={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},h={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},u=[["enter",d,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",h,a]],f=a.parser.constructs.insideSpan.null;f&&we(u,u.length,0,Vt(f,o.slice(c+1,l),a)),we(u,u.length,0,[["exit",h,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",d,a]]),we(o,c-1,l-c+3,u),l=c+u.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){let c=this.previous,d=this.events,h=0;return u;function u(m){return c===126&&d[d.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),f(m))}function f(m){let p=Ln(c);if(m===126)return h>1?l(m):(o.consume(m),h++,f);if(h<2&&!n)return l(m);let v=o.exit("strikethroughSequenceTemporary"),g=Ln(m);return v._open=!g||g===2&&!!p,v._close=!p||p===2&&!!g,a(m)}}}var U=class t{start;endExclusive;static ofLength(e){return new t(0,e)}static ofStartAndLength(e,n){return new t(e,e+n)}constructor(e,n){if(this.start=e,this.endExclusive=n,e>n)throw new Error(`Invalid range: [${e}, ${n})`)}get isEmpty(){return this.start===this.endExclusive}get length(){return this.endExclusive-this.start}delta(e){return new t(this.start+e,this.endExclusive+e)}deltaStart(e){return new t(this.start+e,this.endExclusive)}deltaEnd(e){return new t(this.start,this.endExclusive+e)}equals(e){return this.start===e.start&&this.endExclusive===e.endExclusive}containsRange(e){return this.start<=e.start&&e.endExclusive<=this.endExclusive}contains(e){return this.start<=e&&e<this.endExclusive}join(e){return new t(Math.min(this.start,e.start),Math.max(this.endExclusive,e.endExclusive))}intersect(e){let n=Math.max(this.start,e.start),i=Math.min(this.endExclusive,e.endExclusive);if(n<=i)return new t(n,i)}intersects(e){let n=Math.max(this.start,e.start),i=Math.min(this.endExclusive,e.endExclusive);return n<i}intersectsOrTouches(e){let n=Math.max(this.start,e.start),i=Math.min(this.endExclusive,e.endExclusive);return n<=i}slice(e){return e.slice(this.start,this.endExclusive)}toString(){return`[${this.start}, ${this.endExclusive})`}},sa=class{original;modified;constructor(e,n){this.original=e,this.modified=n}toString(){return`${this.original} <-> ${this.modified}`}},mn=class{range;newText;constructor(e,n){this.range=e,this.newText=n}get isEmpty(){return this.range.isEmpty&&this.newText.length===0}toString(){return`${this.range}->${JSON.stringify(this.newText)}`}},Cr=class t{replacements;static empty=new t([]);static single(e){return new t([e])}static of(e){for(let n=1;n<e.length;n++){let i=e[n-1],r=e[n];if(i.range.endExclusive>r.range.start)throw new Error(`StringEdit.of: replacements must be sorted and non-overlapping (${i.range} vs ${r.range})`)}return new t(e)}constructor(e){this.replacements=e}get isEmpty(){return this.replacements.length===0}apply(e){if(this.replacements.length===0)return e;let n=[],i=0;for(let r of this.replacements)n.push(e.substring(i,r.range.start)),n.push(r.newText),i=r.range.endExclusive;return n.push(e.substring(i)),n.join("")}inverse(e){let n=[],i=0;for(let r of this.replacements){let s=r.range.start+i,o=s+r.newText.length,a=e.substring(r.range.start,r.range.endExclusive);n.push(new mn(new U(s,o),a)),i+=r.newText.length-r.range.length}return new t(n)}normalize(){let e=[];for(let n of this.replacements){if(n.isEmpty)continue;let i=e[e.length-1];i&&i.range.endExclusive===n.range.start?e[e.length-1]=new mn(new U(i.range.start,n.range.endExclusive),i.newText+n.newText):e.push(n)}return new t(e)}toString(){return`StringEdit[${this.replacements.map(e=>e.toString()).join(", ")}]`}},fn=class{range;newText;data;constructor(e,n,i){this.range=e,this.newText=n,this.data=i}get isEmpty(){return this.range.isEmpty&&this.newText.length===0}toString(){return`${this.range}->${JSON.stringify(this.newText)}#${this.data}`}},oa=class t{replacements;static empty(){return new t([])}static single(e){return new t([e])}static of(e){for(let n=1;n<e.length;n++){let i=e[n-1],r=e[n];if(i.range.endExclusive>r.range.start)throw new Error(`AnnotatedStringEdit.of: replacements must be sorted and non-overlapping (${i.range} vs ${r.range})`)}return new t(e)}constructor(e){this.replacements=e}get isEmpty(){return this.replacements.length===0}apply(e){if(this.replacements.length===0)return e;let n=[],i=0;for(let r of this.replacements)n.push(e.substring(i,r.range.start)),n.push(r.newText),i=r.range.endExclusive;return n.push(e.substring(i)),n.join("")}inverse(e,n){let i=[],r=0;for(let s of this.replacements){let o=s.range.start+r,a=o+s.newText.length,l=e.substring(s.range.start,s.range.endExclusive);i.push(new fn(new U(o,a),l,n(s.data))),r+=s.newText.length-s.range.length}return new t(i)}normalize(){let e=[];for(let n of this.replacements){if(n.isEmpty)continue;let i=e[e.length-1];if(i&&i.range.endExclusive===n.range.start){let r=i.data.join(n.data);if(r!==void 0){e[e.length-1]=new fn(new U(i.range.start,n.range.endExclusive),i.newText+n.newText,r);continue}}e.push(n)}return new t(e)}mapData(e){return new t(this.replacements.map(n=>new fn(n.range,n.newText,e(n.data))))}stripData(){return Cr.of(this.replacements.map(e=>new mn(e.range,e.newText)))}toString(){return`AnnotatedStringEdit[${this.replacements.map(e=>e.toString()).join(", ")}]`}},Tr=class t{isFormattingChange;static change=new t(!1);static formatting=new t(!0);constructor(e){this.isFormattingChange=e}join(e){if(this.isFormattingChange===e.isFormattingChange)return this}toString(){return this.isFormattingChange?"formatting":"change"}},aa=class{range;innerEdit;constructor(e,n){this.range=e,this.innerEdit=n}toString(){return`Move ${this.range}`+(this.innerEdit.isEmpty?"":` (${this.innerEdit})`)}},la=class{edits;moves;hitTimeout;constructor(e,n,i){this.edits=e,this.moves=n,this.hitTimeout=i}},Si=class t{static instance=new t;isValid(){return!0}},ca=class{timeout;startTime=Date.now();valid=!0;constructor(e){if(this.timeout=e,e<=0)throw new Error("timeout must be positive")}isValid(){return!(Date.now()-this.startTime<this.timeout)&&this.valid&&(this.valid=!1),this.valid}},Rt=class t{offset1;offset2;static zero=new t(0,0);static max=new t(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);constructor(e,n){this.offset1=e,this.offset2=n}toString(){return`${this.offset1} <-> ${this.offset2}`}delta(e){return e===0?this:new t(this.offset1+e,this.offset2+e)}equals(e){return this.offset1===e.offset1&&this.offset2===e.offset2}},je=class t{seq1Range;seq2Range;static invert(e,n){let i=[];return Hg(e,(r,s)=>{i.push(t.fromOffsetPairs(r?r.getEndExclusives():Rt.zero,s?s.getStarts():new Rt(n,(r?r.seq2Range.endExclusive-r.seq1Range.endExclusive:0)+n)))}),i}static fromOffsetPairs(e,n){return new t(new U(e.offset1,n.offset1),new U(e.offset2,n.offset2))}static assertSorted(e){let n;for(let i of e){if(n&&!(n.seq1Range.endExclusive<=i.seq1Range.start&&n.seq2Range.endExclusive<=i.seq2Range.start))throw new Error("Sequence diffs must be sorted");n=i}}constructor(e,n){this.seq1Range=e,this.seq2Range=n}swap(){return new t(this.seq2Range,this.seq1Range)}toString(){return`${this.seq1Range} <-> ${this.seq2Range}`}join(e){return new t(this.seq1Range.join(e.seq1Range),this.seq2Range.join(e.seq2Range))}delta(e){return e===0?this:new t(this.seq1Range.delta(e),this.seq2Range.delta(e))}deltaStart(e){return e===0?this:new t(this.seq1Range.deltaStart(e),this.seq2Range.deltaStart(e))}deltaEnd(e){return e===0?this:new t(this.seq1Range.deltaEnd(e),this.seq2Range.deltaEnd(e))}intersectsOrTouches(e){return this.seq1Range.intersectsOrTouches(e.seq1Range)||this.seq2Range.intersectsOrTouches(e.seq2Range)}intersect(e){let n=this.seq1Range.intersect(e.seq1Range),i=this.seq2Range.intersect(e.seq2Range);if(!(!n||!i))return new t(n,i)}getStarts(){return new Rt(this.seq1Range.start,this.seq2Range.start)}getEndExclusives(){return new Rt(this.seq1Range.endExclusive,this.seq2Range.endExclusive)}},Wt=class t{diffs;hitTimeout;static trivial(e,n){return new t([new je(U.ofLength(e.length),U.ofLength(n.length))],!1)}static trivialTimedOut(e,n){return new t([new je(U.ofLength(e.length),U.ofLength(n.length))],!0)}constructor(e,n){this.diffs=e,this.hitTimeout=n}};function Hg(t,e){let n;for(let i of t)e(n,i),n=i;e(n,void 0)}var yi=class{width;height;array=[];constructor(e,n){this.width=e,this.height=n,this.array=new Array(e*n)}get(e,n){return this.array[e+n*this.width]}set(e,n,i){this.array[e+n*this.width]=i}},da=class{compute(e,n,i=Si.instance,r){if(e.length===0||n.length===0)return Wt.trivial(e,n);let s=new yi(e.length,n.length),o=new yi(e.length,n.length),a=new yi(e.length,n.length);for(let m=0;m<e.length;m++)for(let p=0;p<n.length;p++){if(!i.isValid())return Wt.trivialTimedOut(e,n);let v=m===0?0:s.get(m-1,p),g=p===0?0:s.get(m,p-1),w;e.getElement(m)===n.getElement(p)?(m===0||p===0?w=0:w=s.get(m-1,p-1),m>0&&p>0&&o.get(m-1,p-1)===3&&(w+=a.get(m-1,p-1)),w+=r?r(m,p):1):w=-1;let y=Math.max(v,g,w);if(y===w){let x=m>0&&p>0?a.get(m-1,p-1):0;a.set(m,p,x+1),o.set(m,p,3)}else y===v?(a.set(m,p,0),o.set(m,p,1)):y===g&&(a.set(m,p,0),o.set(m,p,2));s.set(m,p,y)}let l=[],c=e.length,d=n.length;function h(m,p){(m+1!==c||p+1!==d)&&l.push(new je(new U(m+1,c),new U(p+1,d))),c=m,d=p}let u=e.length-1,f=n.length-1;for(;u>=0&&f>=0;)o.get(u,f)===3?(h(u,f),u--,f--):o.get(u,f)===1?u--:f--;return h(-1,-1),l.reverse(),new Wt(l,!1)}},ua=class{compute(e,n,i=Si.instance){if(e.length===0||n.length===0)return Wt.trivial(e,n);let r=e,s=n;function o(p,v){for(;p<r.length&&v<s.length&&r.getElement(p)===s.getElement(v);)p++,v++;return p}let a=0,l=new ha;l.set(0,o(0,0));let c=new fa;c.set(0,l.get(0)===0?null:new Or(null,0,0,l.get(0)));let d=0;e:for(;;){if(a++,!i.isValid())return Wt.trivialTimedOut(r,s);let p=-Math.min(a,s.length+a%2),v=Math.min(a,r.length+a%2);for(d=p;d<=v;d+=2){let g=d===v?-1:l.get(d+1),w=d===p?-1:l.get(d-1)+1,y=Math.min(Math.max(g,w),r.length),x=y-d;if(y>r.length||x>s.length)continue;let C=o(y,x);l.set(d,C);let k=y===g?c.get(d+1):c.get(d-1);if(c.set(d,C!==y?new Or(k,y,x,C-y):k),l.get(d)===r.length&&l.get(d)-d===s.length)break e}}let h=c.get(d),u=[],f=r.length,m=s.length;for(;;){let p=h?h.x+h.length:0,v=h?h.y+h.length:0;if((p!==f||v!==m)&&u.push(new je(new U(p,f),new U(v,m))),!h)break;f=h.x,m=h.y,h=h.prev}return u.reverse(),new Wt(u,!1)}},Or=class{prev;x;y;length;constructor(e,n,i,r){this.prev=e,this.x=n,this.y=i,this.length=r}},ha=class{positiveArr=new Int32Array(10);negativeArr=new Int32Array(10);get(e){return e<0?(e=-e-1,this.negativeArr[e]):this.positiveArr[e]}set(e,n){if(e<0){if(e=-e-1,e>=this.negativeArr.length){let i=this.negativeArr;this.negativeArr=new Int32Array(i.length*2),this.negativeArr.set(i)}this.negativeArr[e]=n}else{if(e>=this.positiveArr.length){let i=this.positiveArr;this.positiveArr=new Int32Array(i.length*2),this.positiveArr.set(i)}this.positiveArr[e]=n}}},fa=class{positiveArr=[];negativeArr=[];get(e){return e<0?(e=-e-1,this.negativeArr[e]):this.positiveArr[e]}set(e,n){e<0?(e=-e-1,this.negativeArr[e]=n):this.positiveArr[e]=n}};function Vd(t,e,n){let i=n;return i=qd(t,e,i),i=qd(t,e,i),i=Kg(t,e,i),i}function qd(t,e,n){if(n.length===0)return n;let i=[];i.push(n[0]);for(let s=1;s<n.length;s++){let o=i[i.length-1],a=n[s];if(a.seq1Range.isEmpty||a.seq2Range.isEmpty){let l=a.seq1Range.start-o.seq1Range.endExclusive,c;for(c=1;c<=l&&!(t.getElement(a.seq1Range.start-c)!==t.getElement(a.seq1Range.endExclusive-c)||e.getElement(a.seq2Range.start-c)!==e.getElement(a.seq2Range.endExclusive-c));c++);if(c--,c===l){i[i.length-1]=new je(new U(o.seq1Range.start,a.seq1Range.endExclusive-l),new U(o.seq2Range.start,a.seq2Range.endExclusive-l));continue}a=a.delta(-c)}i.push(a)}let r=[];for(let s=0;s<i.length-1;s++){let o=i[s+1],a=i[s];if(a.seq1Range.isEmpty||a.seq2Range.isEmpty){let l=o.seq1Range.start-a.seq1Range.endExclusive,c;for(c=0;c<l&&!(!t.isStronglyEqual(a.seq1Range.start+c,a.seq1Range.endExclusive+c)||!e.isStronglyEqual(a.seq2Range.start+c,a.seq2Range.endExclusive+c));c++);if(c===l){i[s+1]=new je(new U(a.seq1Range.start+l,o.seq1Range.endExclusive),new U(a.seq2Range.start+l,o.seq2Range.endExclusive));continue}c>0&&(a=a.delta(c))}r.push(a)}return i.length>0&&r.push(i[i.length-1]),r}function Kg(t,e,n){if(!t.getBoundaryScore||!e.getBoundaryScore)return n;for(let i=0;i<n.length;i++){let r=i>0?n[i-1]:void 0,s=n[i],o=i+1<n.length?n[i+1]:void 0,a=new U(r?r.seq1Range.endExclusive+1:0,o?o.seq1Range.start-1:t.length),l=new U(r?r.seq2Range.endExclusive+1:0,o?o.seq2Range.start-1:e.length);s.seq1Range.isEmpty?n[i]=jd(s,t,e,a,l):s.seq2Range.isEmpty&&(n[i]=jd(s.swap(),e,t,l,a).swap())}return n}function jd(t,e,n,i,r){let o=1;for(;t.seq1Range.start-o>=i.start&&t.seq2Range.start-o>=r.start&&n.isStronglyEqual(t.seq2Range.start-o,t.seq2Range.endExclusive-o)&&o<100;)o++;o--;let a=0;for(;t.seq1Range.start+a<i.endExclusive&&t.seq2Range.endExclusive+a<r.endExclusive&&n.isStronglyEqual(t.seq2Range.start+a,t.seq2Range.endExclusive+a)&&a<100;)a++;if(o===0&&a===0)return t;let l=0,c=-1;for(let d=-o;d<=a;d++){let h=t.seq2Range.start+d,u=t.seq2Range.endExclusive+d,f=t.seq1Range.start+d,m=e.getBoundaryScore(f)+n.getBoundaryScore(h)+n.getBoundaryScore(u);m>c&&(c=m,l=d)}return t.delta(l)}function Ug(t,e,n){let i=[];for(let r of n){let s=i[i.length-1];if(!s){i.push(r);continue}r.seq1Range.start-s.seq1Range.endExclusive<=2||r.seq2Range.start-s.seq2Range.endExclusive<=2?i[i.length-1]=new je(s.seq1Range.join(r.seq1Range),s.seq2Range.join(r.seq2Range)):i.push(r)}return i}function Wd(t,e,n,i,r=!1){let s=je.invert(n,t.length),o=[],a=new Rt(0,0);function l(d,h){if(d.offset1<a.offset1||d.offset2<a.offset2)return;let u=i(t,d.offset1),f=i(e,d.offset2);if(!u||!f)return;let m=new je(u,f),p=m.intersect(h),v=p.seq1Range.length,g=p.seq2Range.length;for(;s.length>0;){let w=s[0];if(!(w.seq1Range.intersects(m.seq1Range)||w.seq2Range.intersects(m.seq2Range)))break;let x=i(t,w.seq1Range.start),C=i(e,w.seq2Range.start),k=new je(x,C),E=k.intersect(w);if(v+=E.seq1Range.length,g+=E.seq2Range.length,m=m.join(k),m.seq1Range.endExclusive>=w.seq1Range.endExclusive)s.shift();else break}(r&&v+g<m.seq1Range.length+m.seq2Range.length||v+g<(m.seq1Range.length+m.seq2Range.length)*2/3)&&o.push(m),a=m.getEndExclusives()}for(;s.length>0;){let d=s.shift();d.seq1Range.isEmpty||(l(d.getStarts(),d),l(d.getEndExclusives().delta(-1),d))}return Zg(n,o)}function Zg(t,e){let n=[];for(;t.length>0||e.length>0;){let i=t[0],r=e[0],s;i&&(!r||i.seq1Range.start<r.seq1Range.start)?s=t.shift():s=e.shift(),n.length>0&&n[n.length-1].seq1Range.endExclusive>=s.seq1Range.start?n[n.length-1]=n[n.length-1].join(s):n.push(s)}return n}function Xg(t,e,n){let i=n;if(i.length===0)return i;let r=0,s;do{s=!1;let o=[i[0]];for(let a=1;a<i.length;a++){let d=function(u,f){let m=new U(c.seq1Range.endExclusive,l.seq1Range.start);return t.getText(m).replace(/\s/g,"").length<=4&&(u.seq1Range.length+u.seq2Range.length>5||f.seq1Range.length+f.seq2Range.length>5)},l=i[a],c=o[o.length-1];d(c,l)?(s=!0,o[o.length-1]=o[o.length-1].join(l)):o.push(l)}i=o}while(r++<10&&s);return i}function Jg(t,e,n){`${JSON.stringify(n.map(a=>a.toString()))}`;let i=n;if(i.length===0)return i;let r=0,s;do{s=!1;let a=[i[0]];for(let l=1;l<i.length;l++){let h=function(f,m){let p=new U(d.seq1Range.endExclusive,c.seq1Range.start);if(t.countLinesIn(p)>5||p.length>500)return!1;let g=t.getText(p).trim();if(g.length>20||g.split(/\r\n|\r|\n/).length>1)return!1;let w=t.countLinesIn(f.seq1Range),y=f.seq1Range.length,x=e.countLinesIn(f.seq2Range),C=f.seq2Range.length,k=t.countLinesIn(m.seq1Range),E=m.seq1Range.length,L=e.countLinesIn(m.seq2Range),D=m.seq2Range.length,S=130;function ce(G){return Math.min(G,S)}return Math.pow(Math.pow(ce(w*40+y),1.5)+Math.pow(ce(x*40+C),1.5),1.5)+Math.pow(Math.pow(ce(k*40+E),1.5)+Math.pow(ce(L*40+D),1.5),1.5)>(S**1.5)**1.5*1.3},c=i[l],d=a[a.length-1];h(d,c)?(s=!0,a[a.length-1]=a[a.length-1].join(c)):a.push(c)}i=a}while(r++<10&&s);`${JSON.stringify(i.map(a=>a.toString()))}`;let o=[];return Gg(i,(a,l,c)=>{`${l.toString()}${a?.toString()}${c?.toString()}`;let d=l;function h(g){return g.length>0&&g.trim().length<=3&&l.seq1Range.length+l.seq2Range.length>100}let u=t.extendToFullLines(l.seq1Range);`${u.toString()}${l.seq1Range.toString()}`;let f=t.getText(new U(u.start,l.seq1Range.start));`${f}${f.length}`,f.length>0&&f.trim().length<=3&&l.seq1Range.length+l.seq2Range.length>100,h(f)&&(`${d.toString()}`,-f.length,d=d.deltaStart(-f.length),`${d.toString()}`,void 0);let m=t.getText(new U(l.seq1Range.endExclusive,u.endExclusive));`${m}${m.length}`,m.length>0&&m.trim().length<=3&&l.seq1Range.length+l.seq2Range.length>100,h(m)&&(`${d.toString()}${m.length}`,d=d.deltaEnd(m.length),`${d.toString()}`,void 0);let p=je.fromOffsetPairs(a?a.getEndExclusives():Rt.zero,c?c.getStarts():Rt.max);`${p.toString()}${d.toString()}`;let v=d.intersect(p);`${v?.toString()}`,o.length>0&&v.getStarts().equals(o[o.length-1].getEndExclusives())?o[o.length-1]=o[o.length-1].join(v):o.push(v)}),o}function Gg(t,e){for(let n=0;n<t.length;n++)e(t[n-1],t[n],t[n+1])}var Hd={Space:32,Tab:9},Rr=class{trimmedHash;lines;constructor(e,n){this.trimmedHash=e,this.lines=n}getElement(e){return this.trimmedHash[e]}get length(){return this.trimmedHash.length}getBoundaryScore(e){let n=e===0?0:Kd(this.lines[e-1]),i=e===this.lines.length?0:Kd(this.lines[e]);return 1e3-(n+i)}getText(e){return this.lines.slice(e.start,e.endExclusive).join(`
`)}isStronglyEqual(e,n){return this.lines[e]===this.lines[n]}};function Kd(t){let e=0;for(;e<t.length&&(t.charCodeAt(e)===Hd.Space||t.charCodeAt(e)===Hd.Tab);)e++;return e}var xe={LineFeed:10,CarriageReturn:13,Space:32,Tab:9,a:97,z:122,A:65,Z:90,Digit0:48,Digit9:57,Comma:44,Semicolon:59};function Yg(t){return t===xe.Space||t===xe.Tab}var qe=class t{startLineNumber;startColumn;endLineNumber;endColumn;constructor(e,n,i,r){this.startLineNumber=e,this.startColumn=n,this.endLineNumber=i,this.endColumn=r}static fromPositions(e,n){return new t(e.lineNumber,e.column,n.lineNumber,n.column)}},Ot=class{lineNumber;column;constructor(e,n){this.lineNumber=e,this.column=n}isBefore(e){return this.lineNumber<e.lineNumber?!0:e.lineNumber<this.lineNumber?!1:this.column<e.column}},Lr=class{lines;considerWhitespaceChanges;elements=[];firstElementOffsetByLineIdx=[];lineStartOffsets=[];trimmedWsLengthsByLineIdx=[];_range;constructor(e,n,i){this.lines=e,this.considerWhitespaceChanges=i,this._range=n,this.firstElementOffsetByLineIdx.push(0);for(let r=this._range.startLineNumber;r<=this._range.endLineNumber;r++){let s=e[r-1],o=0;r===this._range.startLineNumber&&this._range.startColumn>1&&(o=this._range.startColumn-1,s=s.substring(o)),this.lineStartOffsets.push(o);let a=0;if(!i){let c=s.trimStart();a=s.length-c.length,s=c.trimEnd()}this.trimmedWsLengthsByLineIdx.push(a);let l=r===this._range.endLineNumber?Math.min(this._range.endColumn-1-o-a,s.length):s.length;for(let c=0;c<l;c++)this.elements.push(s.charCodeAt(c));r<this._range.endLineNumber&&(this.elements.push(10),this.firstElementOffsetByLineIdx.push(this.elements.length))}}toString(){return`Slice: "${this.text}"`}get text(){return this.getText(new U(0,this.length))}getText(e){return this.elements.slice(e.start,e.endExclusive).map(n=>String.fromCharCode(n)).join("")}getElement(e){return this.elements[e]}get length(){return this.elements.length}getBoundaryScore(e){let n=Xd(e>0?this.elements[e-1]:-1),i=Xd(e<this.elements.length?this.elements[e]:-1);if(n===7&&i===8)return 0;if(n===8)return 150;let r=0;return n!==i&&(r+=10,n===0&&i===1&&(r+=1)),r+=Zd(n),r+=Zd(i),r}translateOffset(e,n="right"){let i=Yd(this.firstElementOffsetByLineIdx,s=>s<=e),r=e-this.firstElementOffsetByLineIdx[i];return new Ot(this._range.startLineNumber+i,1+this.lineStartOffsets[i]+r+(r===0&&n==="left"?0:this.trimmedWsLengthsByLineIdx[i]))}translateRange(e){let n=this.translateOffset(e.start,"right"),i=this.translateOffset(e.endExclusive,"left");return i.isBefore(n)?qe.fromPositions(i,i):qe.fromPositions(n,i)}findWordContaining(e){if(e<0||e>=this.elements.length||!Mn(this.elements[e]))return;let n=e;for(;n>0&&Mn(this.elements[n-1]);)n--;let i=e;for(;i<this.elements.length&&Mn(this.elements[i]);)i++;return new U(n,i)}findSubWordContaining(e){if(e<0||e>=this.elements.length||!Mn(this.elements[e]))return;let n=e;for(;n>0&&Mn(this.elements[n-1])&&!Ud(this.elements[n]);)n--;let i=e;for(;i<this.elements.length&&Mn(this.elements[i])&&!Ud(this.elements[i]);)i++;return new U(n,i)}countLinesIn(e){return this.translateOffset(e.endExclusive).lineNumber-this.translateOffset(e.start).lineNumber}isStronglyEqual(e,n){return this.elements[e]===this.elements[n]}extendToFullLines(e){let n=ev(this.firstElementOffsetByLineIdx,r=>r<=e.start)??0,i=tv(this.firstElementOffsetByLineIdx,r=>e.endExclusive<=r)??this.elements.length;return new U(n,i)}};function Mn(t){return t>=xe.a&&t<=xe.z||t>=xe.A&&t<=xe.Z||t>=xe.Digit0&&t<=xe.Digit9}function Ud(t){return t>=xe.A&&t<=xe.Z}var Qg={0:0,1:0,2:0,3:10,4:2,5:30,6:3,7:10,8:10};function Zd(t){return Qg[t]}function Xd(t){return t===xe.LineFeed?8:t===xe.CarriageReturn?7:Yg(t)?6:t>=xe.a&&t<=xe.z?0:t>=xe.A&&t<=xe.Z?1:t>=xe.Digit0&&t<=xe.Digit9?2:t===-1?3:t===xe.Comma||t===xe.Semicolon?5:4}function Yd(t,e){let n=0,i=t.length-1;for(;n<=i;){let r=Math.floor((n+i)/2);e(t[r])?n=r+1:i=r-1}return i}function ev(t,e){let n=Yd(t,e);return n>=0?t[n]:void 0}function tv(t,e){let n=0,i=t.length-1;for(;n<=i;){let r=Math.floor((n+i)/2);e(t[r])?i=r-1:n=r+1}return n<t.length?t[n]:void 0}var vt=class t{startLineNumber;endLineNumberExclusive;constructor(e,n){if(this.startLineNumber=e,this.endLineNumberExclusive=n,e>n)throw new Error(`Invalid range: ${e} > ${n}`)}get isEmpty(){return this.startLineNumber===this.endLineNumberExclusive}get length(){return this.endLineNumberExclusive-this.startLineNumber}join(e){return new t(Math.min(this.startLineNumber,e.startLineNumber),Math.max(this.endLineNumberExclusive,e.endLineNumberExclusive))}intersectsOrTouches(e){return this.startLineNumber<=e.endLineNumberExclusive&&e.startLineNumber<=this.endLineNumberExclusive}toOffsetRange(){return new U(this.startLineNumber-1,this.endLineNumberExclusive-1)}toString(){return`[${this.startLineNumber}, ${this.endLineNumberExclusive})`}},Ht=class{originalRange;modifiedRange;constructor(e,n){this.originalRange=e,this.modifiedRange=n}toString(){return`${Jd(this.originalRange)} <-> ${Jd(this.modifiedRange)}`}static assertSorted(e){for(let n=1;n<e.length;n++){let i=e[n-1],r=e[n];if(!(i.originalRange.endLineNumber<=r.originalRange.startLineNumber||i.originalRange.endLineNumber===r.originalRange.startLineNumber&&i.originalRange.endColumn<=r.originalRange.startColumn))throw new Error("RangeMappings must be sorted")}}};function Jd(t){return`(${t.startLineNumber}:${t.startColumn})-(${t.endLineNumber}:${t.endColumn})`}var Ir=class{original;modified;constructor(e,n){this.original=e,this.modified=n}toString(){return`${this.original} <-> ${this.modified}`}toRangeMapping2(e,n){let i=(s,o)=>s>=1&&s<=o.length,r=(s,o,a)=>{if(s<1)return new Ot(1,1);if(s>a.length)return new Ot(a.length,a[a.length-1].length+1);let l=a[s-1];return o>l.length+1?new Ot(s,l.length+1):new Ot(s,o)};if(i(this.original.endLineNumberExclusive,e)&&i(this.modified.endLineNumberExclusive,n))return new Ht(new qe(this.original.startLineNumber,1,this.original.endLineNumberExclusive,1),new qe(this.modified.startLineNumber,1,this.modified.endLineNumberExclusive,1));if(!this.original.isEmpty&&!this.modified.isEmpty)return new Ht(qe.fromPositions(new Ot(this.original.startLineNumber,1),r(this.original.endLineNumberExclusive-1,Number.MAX_SAFE_INTEGER,e)),qe.fromPositions(new Ot(this.modified.startLineNumber,1),r(this.modified.endLineNumberExclusive-1,Number.MAX_SAFE_INTEGER,n)));if(this.original.startLineNumber>1&&this.modified.startLineNumber>1)return new Ht(qe.fromPositions(r(this.original.startLineNumber-1,Number.MAX_SAFE_INTEGER,e),r(this.original.endLineNumberExclusive-1,Number.MAX_SAFE_INTEGER,e)),qe.fromPositions(r(this.modified.startLineNumber-1,Number.MAX_SAFE_INTEGER,n),r(this.modified.endLineNumberExclusive-1,Number.MAX_SAFE_INTEGER,n)));throw new Error("Invalid diff: cannot convert to range mapping")}},Bn=class extends Ir{innerChanges;constructor(e,n,i){super(e,n),this.innerChanges=i}},$n=class{changes;moves;hitTimeout;constructor(e,n,i){this.changes=e,this.moves=n,this.hitTimeout=i}};function nv(t,e,n,i=!1){let r=[];for(let s of rv(t.map(o=>iv(o,e,n)),(o,a)=>o.original.intersectsOrTouches(a.original)||o.modified.intersectsOrTouches(a.modified))){let o=s[0],a=s[s.length-1];r.push(new Bn(o.original.join(a.original),o.modified.join(a.modified),s.map(l=>l.innerChanges[0])))}if(!i)for(let s=1;s<r.length;s++){let o=r[s-1],a=r[s];if(o.original.endLineNumberExclusive>a.original.startLineNumber||o.modified.endLineNumberExclusive>a.modified.startLineNumber)break}return r}function iv(t,e,n){let i=0,r=0;t.modifiedRange.endColumn===1&&t.originalRange.endColumn===1&&t.originalRange.startLineNumber+i<=t.originalRange.endLineNumber&&t.modifiedRange.startLineNumber+i<=t.modifiedRange.endLineNumber&&(r=-1),t.modifiedRange.startColumn-1>=(n[t.modifiedRange.startLineNumber-1]?.length??0)&&t.originalRange.startColumn-1>=(e[t.originalRange.startLineNumber-1]?.length??0)&&t.originalRange.startLineNumber<=t.originalRange.endLineNumber+r&&t.modifiedRange.startLineNumber<=t.modifiedRange.endLineNumber+r&&(i=1);let s=new vt(t.originalRange.startLineNumber+i,t.originalRange.endLineNumber+1+r),o=new vt(t.modifiedRange.startLineNumber+i,t.modifiedRange.endLineNumber+1+r);return new Bn(s,o,[t])}function*rv(t,e){let n,i;for(let r of t)i!==void 0&&e(i,r)?n.push(r):(n&&(yield n),n=[r]),i=r;n&&(yield n)}var Mr=class{lines;constructor(e){this.lines=e}get lineCount(){return this.lines.length}getLineContent(e){return this.lines[e-1]}},ma=class{_dynamicProgrammingDiffing=new da;_myersDiffingAlgorithm=new ua;computeDiff(e,n,i){if(e.length<=1&&ov(e,n))return new $n([],[],!1);if(e.length===1&&e[0].length===0||n.length===1&&n[0].length===0)return new $n([new Bn(new vt(1,e.length+1),new vt(1,n.length+1),[new Ht(new qe(1,1,e.length,e[e.length-1].length+1),new qe(1,1,n.length,n[n.length-1].length+1))])],[],!1);let r=i.maxComputationTimeMs===0?Si.instance:new ca(i.maxComputationTimeMs),s=!i.ignoreTrimWhitespace,o=new Map;function a(E){let L=o.get(E);return L===void 0&&(L=o.size,o.set(E,L)),L}let l=e.map(E=>a(E.trim())),c=n.map(E=>a(E.trim())),d=new Rr(l,e),h=new Rr(c,n),u=d.length+h.length<1700?this._dynamicProgrammingDiffing.compute(d,h,r,(E,L)=>e[E]===n[L]?n[L].length===0?.1:1+Math.log(1+n[L].length):.99):this._myersDiffingAlgorithm.compute(d,h,r),f=u.diffs,m=u.hitTimeout;f=Vd(d,h,f),f=Xg(d,h,f);let p=[],v=E=>{if(s)for(let L=0;L<E;L++){let D=g+L,S=w+L;if(e[D]!==n[S]){let ce=this._refineDiff(e,n,new je(new U(D,D+1),new U(S,S+1)),r,s,i);for(let G of ce.mappings)p.push(G);ce.hitTimeout&&(m=!0)}}},g=0,w=0;for(let E of f){let L=E.seq1Range.start-g;v(L),g=E.seq1Range.endExclusive,w=E.seq2Range.endExclusive;let D=this._refineDiff(e,n,E,r,s,i);D.hitTimeout&&(m=!0);for(let S of D.mappings)p.push(S)}v(e.length-g);let y=new Mr(e),x=new Mr(n),C=nv(p,y.lines,x.lines),k=[];return new $n(C,k,m)}_refineDiff(e,n,i,r,s,o){let l=sv(i).toRangeMapping2(e,n),c=new Lr(e,l.originalRange,s),d=new Lr(n,l.modifiedRange,s),h=c.length+d.length<500?this._dynamicProgrammingDiffing.compute(c,d,r):this._myersDiffingAlgorithm.compute(c,d,r),u=h.diffs;return u=Vd(c,d,u),u=Wd(c,d,u,(m,p)=>m.findWordContaining(p)),o.extendToSubwords&&(u=Wd(c,d,u,(m,p)=>m.findSubWordContaining(p),!0)),u=Ug(c,d,u),u=Jg(c,d,u),{mappings:u.map(m=>new Ht(c.translateRange(m.seq1Range),d.translateRange(m.seq2Range))),hitTimeout:h.hitTimeout}}};function sv(t){return new Ir(new vt(t.seq1Range.start+1,t.seq1Range.endExclusive+1),new vt(t.seq2Range.start+1,t.seq2Range.endExclusive+1))}function ov(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function av(t,e,n){let i=An(t,J.__wbindgen_malloc,J.__wbindgen_realloc),r=jt,s=An(e,J.__wbindgen_malloc,J.__wbindgen_realloc),o=jt,a=J.computeDiff(i,r,s,o,n);if(a[2])throw Nr(a[1]);return Nr(a[0])}function lv(t,e,n){let i=J.computeDiffLines(t,e,n);if(i[2])throw Nr(i[1]);return Nr(i[0])}function Qd(){J.init()}function eu(){return{__proto__:null,"./diff_wasm_bg.js":{__proto__:null,__wbg_Error_bce6d499ff0a4aff:function(e,n){return Error(Sr(e,n))},__wbg_Number_b7972a139bfbfdf0:function(e){return Number(e)},__wbg_String_8564e559799eccda:function(e,n){let i=String(n),r=An(i,J.__wbindgen_malloc,J.__wbindgen_realloc),s=jt;st().setInt32(e+4,s,!0),st().setInt32(e+0,r,!0)},__wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83:function(e,n){let i=n,r=typeof i=="bigint"?i:void 0;st().setBigInt64(e+8,Nn(r)?BigInt(0):r,!0),st().setInt32(e+0,!Nn(r),!0)},__wbg___wbindgen_boolean_get_2304fb8c853028c8:function(e){let n=e,i=typeof n=="boolean"?n:void 0;return Nn(i)?16777215:i?1:0},__wbg___wbindgen_debug_string_edece8177ad01481:function(e,n){let i=pa(n),r=An(i,J.__wbindgen_malloc,J.__wbindgen_realloc),s=jt;st().setInt32(e+4,s,!0),st().setInt32(e+0,r,!0)},__wbg___wbindgen_in_07056af4f902c445:function(e,n){return e in n},__wbg___wbindgen_is_bigint_aeae3893f30ed54e:function(e){return typeof e=="bigint"},__wbg___wbindgen_is_function_5cd60d5cf78b4eef:function(e){return typeof e=="function"},__wbg___wbindgen_is_null_2042690d351e14f0:function(e){return e===null},__wbg___wbindgen_is_object_b4593df85baada48:function(e){let n=e;return typeof n=="object"&&n!==null},__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5:function(e){return e===void 0},__wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9:function(e,n){return e===n},__wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c:function(e,n){return e==n},__wbg___wbindgen_number_get_f73a1244370fcc2c:function(e,n){let i=n,r=typeof i=="number"?i:void 0;st().setFloat64(e+8,Nn(r)?0:r,!0),st().setInt32(e+0,!Nn(r),!0)},__wbg___wbindgen_string_get_d109740c0d18f4d7:function(e,n){let i=n,r=typeof i=="string"?i:void 0;var s=Nn(r)?0:An(r,J.__wbindgen_malloc,J.__wbindgen_realloc),o=jt;st().setInt32(e+4,o,!0),st().setInt32(e+0,s,!0)},__wbg___wbindgen_throw_9c31b086c2b26051:function(e,n){throw new Error(Sr(e,n))},__wbg_call_13665d9f14390edc:function(){return ia(function(e,n){return e.call(n)},arguments)},__wbg_done_54b8da57023b7ed2:function(e){return e.done},__wbg_error_a6fa202b58aa1cd3:function(e,n){let i,r;try{i=e,r=n,console.error(Sr(e,n))}finally{J.__wbindgen_free(i,r,1)}},__wbg_get_3e9a707ab7d352eb:function(){return ia(function(e,n){return Reflect.get(e,n)},arguments)},__wbg_get_unchecked_1dfe6d05ad91d9b7:function(e,n){return e[n>>>0]},__wbg_get_with_ref_key_6412cf3094599694:function(e,n){return e[n]},__wbg_instanceof_ArrayBuffer_53db37b06f6b9afe:function(e){let n;try{n=e instanceof ArrayBuffer}catch{n=!1}return n},__wbg_instanceof_Uint8Array_abd07d4bd221d50b:function(e){let n;try{n=e instanceof Uint8Array}catch{n=!1}return n},__wbg_isArray_94898ed3aad6947b:function(e){return Array.isArray(e)},__wbg_isSafeInteger_01e964d144ad3a55:function(e){return Number.isSafeInteger(e)},__wbg_iterator_1441b47f341dc34f:function(){return Symbol.iterator},__wbg_length_2591a0f4f659a55c:function(e){return e.length},__wbg_length_56fcd3e2b7e0299d:function(e){return e.length},__wbg_new_02d162bc6cf02f60:function(){return new Object},__wbg_new_227d7c05414eb861:function(){return new Error},__wbg_new_310879b66b6e95e1:function(){return new Array},__wbg_new_7ddec6de44ff8f5d:function(e){return new Uint8Array(e)},__wbg_next_2a4e19f4f5083b0f:function(e){return e.next},__wbg_next_6429a146bf756f93:function(){return ia(function(e){return e.next()},arguments)},__wbg_prototypesetcall_5f9bdc8d75e07276:function(e,n,i){Uint8Array.prototype.set.call(dv(e,n),i)},__wbg_set_6be42768c690e380:function(e,n,i){e[n]=i},__wbg_set_78ea6a19f4818587:function(e,n,i){e[n>>>0]=i},__wbg_stack_3b0d974bbf31e44f:function(e,n){let i=n.stack,r=An(i,J.__wbindgen_malloc,J.__wbindgen_realloc),s=jt;st().setInt32(e+4,s,!0),st().setInt32(e+0,r,!0)},__wbg_value_9cc0518af87a489c:function(e){return e.value},__wbindgen_cast_0000000000000001:function(e){return e},__wbindgen_cast_0000000000000002:function(e,n){return Sr(e,n)},__wbindgen_cast_0000000000000003:function(e){return BigInt.asUintN(64,e)},__wbindgen_init_externref_table:function(){let e=J.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)}}}}function cv(t){let e=J.__externref_table_alloc();return J.__wbindgen_externrefs.set(e,t),e}function pa(t){let e=typeof t;if(e=="number"||e=="boolean"||t==null)return`${t}`;if(e=="string")return`"${t}"`;if(e=="symbol"){let r=t.description;return r==null?"Symbol":`Symbol(${r})`}if(e=="function"){let r=t.name;return typeof r=="string"&&r.length>0?`Function(${r})`:"Function"}if(Array.isArray(t)){let r=t.length,s="[";r>0&&(s+=pa(t[0]));for(let o=1;o<r;o++)s+=", "+pa(t[o]);return s+="]",s}let n=/\[object ([^\]]+)\]/.exec(toString.call(t)),i;if(n&&n.length>1)i=n[1];else return toString.call(t);if(i=="Object")try{return"Object("+JSON.stringify(t)+")"}catch{return"Object"}return t instanceof Error?`${t.name}: ${t.message}
${t.stack}`:i}function dv(t,e){return t=t>>>0,ki().subarray(t/1,t/1+e)}var hn=null;function st(){return(hn===null||hn.buffer.detached===!0||hn.buffer.detached===void 0&&hn.buffer!==J.memory.buffer)&&(hn=new DataView(J.memory.buffer)),hn}function Sr(t,e){return hv(t>>>0,e)}var wi=null;function ki(){return(wi===null||wi.byteLength===0)&&(wi=new Uint8Array(J.memory.buffer)),wi}function ia(t,e){try{return t.apply(this,e)}catch(n){let i=cv(n);J.__wbindgen_exn_store(i)}}function Nn(t){return t==null}function An(t,e,n){if(n===void 0){let a=xi.encode(t),l=e(a.length,1)>>>0;return ki().subarray(l,l+a.length).set(a),jt=a.length,l}let i=t.length,r=e(i,1)>>>0,s=ki(),o=0;for(;o<i;o++){let a=t.charCodeAt(o);if(a>127)break;s[r+o]=a}if(o!==i){o!==0&&(t=t.slice(o)),r=n(r,i,i=o+t.length*3,1)>>>0;let a=ki().subarray(r+o,r+i),l=xi.encodeInto(t,a);o+=l.written,r=n(r,i,o,1)>>>0}return jt=o,r}function Nr(t){let e=J.__wbindgen_externrefs.get(t);return J.__externref_table_dealloc(t),e}var Er=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});Er.decode();var uv=2146435072,ra=0;function hv(t,e){return ra+=e,ra>=uv&&(Er=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),Er.decode(),ra=e),Er.decode(ki().subarray(t,t+e))}var xi=new TextEncoder;"encodeInto"in xi||(xi.encodeInto=function(t,e){let n=xi.encode(t);return e.set(n),{read:t.length,written:n.length}});var jt=0,J;function tu(t,e){return J=t.exports,hn=null,wi=null,J.__wbindgen_start(),J}async function fv(t,e){if(typeof Response=="function"&&t instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(t,e)}catch(r){if(t.ok&&n(t.type)&&t.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",r);else throw r}let i=await t.arrayBuffer();return await WebAssembly.instantiate(i,e)}else{let i=await WebAssembly.instantiate(t,e);return i instanceof WebAssembly.Instance?{instance:i,module:t}:i}function n(i){switch(i){case"basic":case"cors":case"default":return!0}return!1}}function mv(t){if(J!==void 0)return J;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module:t}=t:console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));let e=eu();t instanceof WebAssembly.Module||(t=new WebAssembly.Module(t));let n=new WebAssembly.Instance(t,e);return tu(n)}async function nu(t){if(J!==void 0)return J;t!==void 0&&(Object.getPrototypeOf(t)===Object.prototype?{module_or_path:t}=t:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),t===void 0&&(t=new URL(new URL("diff_wasm_bg-BNcsPO7p.wasm",import.meta.url).href));let e=eu();(typeof t=="string"||typeof Request=="function"&&t instanceof Request||typeof URL=="function"&&t instanceof URL)&&(t=fetch(t));let{instance:n,module:i}=await fv(await t,e);return tu(n)}var pv=Object.freeze({__proto__:null,computeDiff:av,computeDiffLines:lv,default:nu,init:Qd,initSync:mv}),Pn=null,zr=null;async function gv(){return Pn||zr||(zr=(async()=>{let t=new URL(new URL("diff_wasm_bg-BNcsPO7p.wasm",import.meta.url).href),e=t;if(typeof process<"u"&&process.versions?.node){let{readFile:n}=await import("node:fs/promises");e=await n(t)}return await nu({module_or_path:e}),Qd(),Pn=pv,Pn})(),zr)}function vv(){if(!Pn)throw new Error("WASM not initialized. Call initWasm() first and await it.");return Pn}async function iu(t={}){return t.useWasm?(await gv(),new va(t.algorithm)):new ga(t.algorithm)}var ga=class{_algorithm;_impl=new ma;constructor(e){this._algorithm=e}computeDiff(e,n,i){let r=e.split(`
`),s=n.split(`
`),o={maxComputationTimeMs:i?.maxComputationTimeMs??0,ignoreTrimWhitespace:i?.ignoreTrimWhitespace??!1,computeMoves:i?.computeMoves??!1,extendToSubwords:i?.extendToSubwords??!1},a=this._impl.computeDiff(r,s,o);return this._algorithm,ru(a,e,n,r,s)}},va=class{_algorithm;constructor(e){this._algorithm=e}computeDiff(e,n,i){let r=e.split(`
`),s=n.split(`
`),o={};i?.maxComputationTimeMs!==void 0&&(o.maxComputationTimeMs=i.maxComputationTimeMs),i?.ignoreTrimWhitespace!==void 0&&(o.ignoreTrimWhitespace=i.ignoreTrimWhitespace),i?.computeMoves!==void 0&&(o.computeMoves=i.computeMoves),i?.extendToSubwords!==void 0&&(o.extendToSubwords=i.extendToSubwords);let l=vv().computeDiffLines(r,s,o);this._algorithm;let c=bv(l);return ru(c,e,n,r,s)}};function bv(t){let e=t.changes.map(n=>{let i=n.innerChanges?.map(r=>new Ht(new qe(r.originalStartLine,r.originalStartColumn,r.originalEndLine,r.originalEndColumn),new qe(r.modifiedStartLine,r.modifiedStartColumn,r.modifiedEndLine,r.modifiedEndColumn)));return new Bn(new vt(n.original.startLineNumber,n.original.endLineNumberExclusive),new vt(n.modified.startLineNumber,n.modified.endLineNumberExclusive),i)});return new $n(e,[],t.hitTimeout)}function ru(t,e,n,i,r){let s=Gd(i),o=Gd(r),a=[];for(let d of t.changes)_v(d,e,n,i,r,s,o,a);let l=oa.of(a),c=t.moves.map(d=>wv(d,e,n,i,r,s,o));return new la(l,c,t.hitTimeout)}function _v(t,e,n,i,r,s,o,a){if(t.innerChanges&&t.innerChanges.length>0){for(let h of t.innerChanges){let u=Ar(h.originalRange,e,i,s),f=Ar(h.modifiedRange,n,r,o),m=n.substring(f.start,f.endExclusive);a.push(new fn(u,m,Tr.change))}return}let l=Fn(t.original.startLineNumber,t.original.endLineNumberExclusive,e,s),c=Fn(t.modified.startLineNumber,t.modified.endLineNumberExclusive,n,o),d=n.substring(c.start,c.endExclusive);a.push(new fn(l,d,Tr.change))}function wv(t,e,n,i,r,s,o){let a=Fn(t.lineRangeMapping.original.startLineNumber,t.lineRangeMapping.original.endLineNumberExclusive,e,s),l=Fn(t.lineRangeMapping.modified.startLineNumber,t.lineRangeMapping.modified.endLineNumberExclusive,n,o),c=[];for(let d of t.changes)if(d.innerChanges&&d.innerChanges.length>0)for(let h of d.innerChanges){let u=Ar(h.originalRange,e,i,s),f=Ar(h.modifiedRange,n,r,o);c.push(new mn(new U(u.start-a.start,u.endExclusive-a.start),n.substring(f.start,f.endExclusive)))}else{let h=Fn(d.original.startLineNumber,d.original.endLineNumberExclusive,e,s),u=Fn(d.modified.startLineNumber,d.modified.endLineNumberExclusive,n,o);c.push(new mn(new U(h.start-a.start,h.endExclusive-a.start),n.substring(u.start,u.endExclusive)))}return new aa(new sa(a,l),Cr.of(c))}function Gd(t){let e=new Array(t.length+1);e[0]=0;for(let n=0;n<t.length;n++)e[n+1]=e[n]+t[n].length+1;return e}function Fn(t,e,n,i){let r=Pr(t,1,n,i),s=Pr(e,1,n,i);return new U(r,s)}function Ar(t,e,n,i){let r=Pr(t.startLineNumber,t.startColumn,e,i),s=Pr(t.endLineNumber,t.endColumn,e,i);return new U(r,s)}function Pr(t,e,n,i){if(t<=0)return 0;if(t>i.length)return n.length;let s=i[t-1]+(e-1);return Math.min(Math.max(s,0),n.length)}var Ra=class t{constructor(e,n){if(this.replaceRange=e,this.newLength=n,n<0)throw new Error(`newLength must be non-negative, got ${n}`)}static replace(e,n){return new t(e,n)}get lengthDelta(){return this.newLength-this.replaceRange.length}equals(e){return this.replaceRange.equals(e.replaceRange)&&this.newLength===e.newLength}toString(){return`${this.replaceRange} -> +${this.newLength}`}},Ei=class t{static empty=new t([]);static single(e){return new t([e])}static replace(e,n){return new t([Ra.replace(e,n)])}replacements;constructor(e){let n=-1;for(let i of e){if(i.replaceRange.start<n)throw new Error(`Edits must be disjoint and sorted. Found ${i} after end ${n}`);n=i.replaceRange.endExclusive}this.replacements=e}get isEmpty(){return this.replacements.length===0}equals(e){if(this.replacements.length!==e.replacements.length)return!1;for(let n=0;n<this.replacements.length;n++)if(!this.replacements[n].equals(e.replacements[n]))return!1;return!0}toString(){return this.isEmpty?"LengthEdit.empty":this.replacements.join(", ")}},gn=class{constructor(e){this.value=e}get length(){return this.value.length}substring(e){return e.substring(this.value)}toString(){return this.value}},$=class t{constructor(e,n){this.anchor=e,this.active=n}static collapsed(e){return new t(e,e)}get isCollapsed(){return this.anchor===this.active}get isForward(){return this.active>=this.anchor}get range(){return this.isForward?new O(this.anchor,this.active):new O(this.active,this.anchor)}collapseToActive(){return t.collapsed(this.active)}withActive(e){return new t(this.anchor,e)}},La=class{constructor(e,n){this.sourceOffsetBefore=e,this.sourceOffsetAfter=n}},ue;(t=>{function e(i){return{kind:"source",offset:i}}t.source=e;function n(i){return{kind:"virtual",line:i}}t.virtual=n})(ue||(ue={}));var vn=class t{constructor(e,n){this.x=e,this.y=n}static ZERO=new t(0,0);translate(e,n){return new t(this.x+e,this.y+n)}},ne=class t{constructor(e,n,i,r){this.x=e,this.y=n,this.width=i,this.height=r}static EMPTY=new t(0,0,0,0);static fromPointPoint(e,n,i,r){return new t(e,n,i-e,r-n)}static fromPointSize(e,n,i,r){return new t(e,n,i,r)}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get topLeft(){return new vn(this.x,this.y)}containsX(e){return e>=this.left&&e<this.right}containsY(e){return e>=this.top&&e<this.bottom}containsPoint(e){return this.containsX(e.x)&&this.containsY(e.y)}withZeroWidthAt(e){return new t(e,this.y,0,this.height)}translate(e,n){return new t(this.x+e,this.y+n,this.width,this.height)}},yv=1,$e=class{id=yv++;_length=-1;get length(){if(this._length<0){let e=0;for(let n of this.children)e+=n.length;this._length=e}return this._length}equalsShallow(e){if(this===e)return!0;if(this.kind!==e.kind||this.length!==e.length||!this._localEquals(e))return!1;let n=this.children,i=e.children;if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}_localEquals(e){return!0}cloneWithId(e){let n=Object.create(Object.getPrototypeOf(this));return Object.assign(n,this),n.id=e,n}},kv=[];function ye(t,e){let n;for(let i=0;i<e.length;i++){let r=t.get(e[i]);r&&r!==e[i]&&((n??=e.slice())[i]=r)}return n??e}function kt(t,e){let n=t.get(e);return n&&n!==e?n:e}function St(t,e){return e?kt(t,e):void 0}var Hn=class extends $e{get children(){return kv}get length(){return this.content.length}mapChildren(){return this}},Ci=class extends Hn{constructor(e){super(),this.content=e}kind="text";_localEquals(e){return this.content===e.content}},q=class extends Hn{constructor(e,n){super(),this.markerKind=e,this.content=n}kind="marker";_localEquals(e){return this.markerKind===e.markerKind&&this.content===e.content}},Fe=class extends Hn{constructor(e,n){super(),this.content=e,this.glueKind=n}kind="glue";_localEquals(e){return this.content===e.content&&this.glueKind===e.glueKind}},Je=class extends $e{_withLeading(e){return this.leadingTrivia?[this.leadingTrivia,...e]:e}},Ti=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="thematicBreak";get children(){return this._withLeading(this.content)}get marker(){return It(this.content,"content")}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}};function It(t,e){return t.find(n=>n instanceof q&&n.markerKind===e)}var Ia=class t extends $e{constructor(e,n,i){super(),this.openMarker=e,this.content=n,this.closeMarker=i}kind="strong";get children(){return[this.openMarker,...this.content,this.closeMarker]}mapChildren(e){return new t(kt(e,this.openMarker),ye(e,this.content),kt(e,this.closeMarker))}},Ma=class t extends $e{constructor(e,n,i){super(),this.openMarker=e,this.content=n,this.closeMarker=i}kind="emphasis";get children(){return[this.openMarker,...this.content,this.closeMarker]}mapChildren(e){return new t(kt(e,this.openMarker),ye(e,this.content),kt(e,this.closeMarker))}},Na=class t extends $e{constructor(e,n,i){super(),this.openMarker=e,this.content=n,this.closeMarker=i}kind="strikethrough";get children(){return[this.openMarker,...this.content,this.closeMarker]}mapChildren(e){return new t(kt(e,this.openMarker),ye(e,this.content),kt(e,this.closeMarker))}},Aa=class t extends $e{constructor(e){super(),this.content=e}kind="inlineCode";get children(){return this.content}mapChildren(e){return new t(ye(e,this.content))}},Pa=class t extends $e{constructor(e){super(),this.content=e}kind="inlineMath";get children(){return this.content}mapChildren(e){return new t(ye(e,this.content))}},Fa=class t extends $e{constructor(e,n){super(),this.url=e,this.content=n}kind="link";get children(){return this.content}mapChildren(e){return new t(this.url,ye(e,this.content))}_localEquals(e){return this.url===e.url}},$a=class t extends $e{constructor(e,n,i){super(),this.alt=e,this.url=n,this.content=i}kind="image";get children(){return this.content}mapChildren(e){return new t(this.alt,this.url,ye(e,this.content))}_localEquals(e){return this.alt===e.alt&&this.url===e.url}},Kn=class t extends Je{constructor(e,n,i){super(),this.tokenType=e,this.content=n,this.leadingTrivia=i}kind="unhandledBlock";get children(){return this._withLeading(this.content)}get code(){return It(this.content,"content")}get htmlComment(){let e=this.code?.content;if(this.tokenType!=="htmlFlow"||e===void 0)return;let n="<!--",i="-->",r=e.indexOf(n);if(r<0)return;let s=e.slice(0,r);if(s.trim().length>0)return;let o=r+n.length,a=e.indexOf(i,o);if(a<0)return{kind:"open",leadingWhitespace:s,opening:n,body:e.slice(o)};let l=e.slice(a+i.length);if(!(l.trim().length>0))return{kind:"complete",leadingWhitespace:s,opening:n,body:e.slice(o,a),closing:i,trailingWhitespace:l}}mapChildren(e){return new t(this.tokenType,ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.tokenType,this.content,e)}_localEquals(e){return this.tokenType===e.tokenType}},Oi=class t extends Je{constructor(e,n,i,r){super(),this.level=e,this.marker=n,this.content=i,this.leadingTrivia=r}kind="heading";get children(){return this._withLeading([this.marker,...this.content])}mapChildren(e){return new t(this.level,kt(e,this.marker),ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.level,this.marker,this.content,e)}_localEquals(e){return this.level===e.level}},Nt=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="paragraph";get children(){return this._withLeading(this.content)}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}},Ri=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="frontMatter";get children(){return this._withLeading(this.content)}get openFence(){return It(this.content,"openFence")}get closeFence(){return It(this.content,"closeFence")}get value(){return It(this.content,"content")}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}},Kt=class t extends Je{constructor(e,n,i,r){super(),this.language=e,this.infoString=n,this.content=i,this.leadingTrivia=r}kind="codeBlock";_previous;_contentEdit;get children(){return this._withLeading(this.content)}get openFence(){return It(this.content,"openFence")}get closeFence(){return It(this.content,"closeFence")}get code(){return It(this.content,"content")}get codeOffset(){let e=this.leadingTrivia?.length??0;for(let n of this.content){if(n.kind==="marker"&&n.markerKind==="content")return e;e+=n.length}return e}mapChildren(e){return new t(this.language,this.infoString,ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.language,this.infoString,this.content,e)}_localEquals(e){return this.language===e.language&&this.infoString===e.infoString}withCodeDiff(e,n){let i=this.cloneWithId(this.id);return i._previous=new WeakRef(e),i._contentEdit=n,i}getDiff(e){if(this._contentEdit&&this._previous?.deref()===e)return{stringEdit:this._contentEdit}}},Li=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="mathBlock";get children(){return this._withLeading(this.content)}get code(){return It(this.content,"content")}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}},Ii=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="blockQuote";get children(){return this._withLeading(this.content)}get blocks(){return this.content.filter(ql)}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}},wt=class t extends Je{constructor(e,n,i){super(),this.ordered=e,this.content=n,this.leadingTrivia=i}kind="list";get children(){return this._withLeading(this.content)}get items(){return this.content.filter(e=>e instanceof yt)}mapChildren(e){return new t(this.ordered,ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.ordered,this.content,e)}_localEquals(e){return this.ordered===e.ordered}},yt=class t extends $e{constructor(e,n,i,r){super(),this.marker=e,this.content=n,this.checked=i,this.leadingTrivia=r}kind="listItem";get children(){return this.leadingTrivia?[this.leadingTrivia,this.marker,...this.content]:[this.marker,...this.content]}get blocks(){return this.content.filter(ql)}mapChildren(e){return new t(kt(e,this.marker),ye(e,this.content),this.checked,this.leadingTrivia?kt(e,this.leadingTrivia):void 0)}withLeadingTrivia(e){return new t(this.marker,this.content,this.checked,e)}_localEquals(e){return this.checked===e.checked}},Mi=class t extends Je{constructor(e,n){super(),this.content=e,this.leadingTrivia=n}kind="table";get children(){return this._withLeading(this.content)}get _rows(){return this.content.filter(e=>e instanceof Ni)}get headerRow(){return this._rows[0]}get delimiterRow(){return this._rows[1]}get bodyRows(){return this._rows.slice(2)}mapChildren(e){return new t(ye(e,this.content),St(e,this.leadingTrivia))}withLeadingTrivia(e){return new t(this.content,e)}},Ni=class t extends $e{constructor(e){super(),this.content=e}kind="tableRow";get children(){return this.content}get cells(){return this.content.filter(e=>e instanceof Ai)}mapChildren(e){return new t(ye(e,this.content))}},Ai=class t extends $e{constructor(e){super(),this.content=e}kind="tableCell";get children(){return this.content}mapChildren(e){return new t(ye(e,this.content))}},Ba=class t extends $e{constructor(e){super(),this.content=e}kind="document";get children(){return this.content}get blocks(){return this.content.filter(ql)}mapChildren(e){return new t(ye(e,this.content))}};function ql(t){return t instanceof Oi||t instanceof Nt||t instanceof Ri||t instanceof Kt||t instanceof Li||t instanceof Ti||t instanceof Ii||t instanceof wt||t instanceof Mi||t instanceof Kn}function ot(t,e){if(t.id===e.id)return 0;let n=0;for(let i of t.children){let r=ot(i,e);if(r!==void 0)return n+r;n+=i.length}}var xv=/\[[ xX]\]/;function Sv(t){if(t.checked===void 0)return;let e=xv.exec(qu(t));if(e)return O.ofStartAndLength(e.index,e[0].length)}function qu(t){if(t instanceof Hn)return t.content;let e="";for(let n of t.children)e+=qu(n);return e}function zv(t){let e=Uo({extensions:[Yo(),Qo(),ea(),ta(),na()]}),n=Xo()(t,void 0,!0);return Zo(e.document().write(n)).map(([i,r])=>({type:i,tokenType:r.type,startOffset:r.start.offset,endOffset:r.end.offset}))}function Ev(t){return new Da(zv(t),t).build()}var Cv=new Set(["htmlFlow","setextHeading","definition"]);function Fr(t){let e=[];for(let n=0;n<t.length;n++){let i=t[n],r=t[n+1];if(i instanceof Fe&&i.glueKind==="indent"){let s=r!==void 0?Tv(r,i):void 0;if(s){e.push(s),n++;continue}let o=e[e.length-1];if(o instanceof Fe&&o.glueKind===void 0){e[e.length-1]=new Fe(o.content+i.content);continue}e.push(i);continue}e.push(i)}return e}function Tv(t,e){if(t instanceof wt){let n=t.content.findIndex(r=>r instanceof yt);if(n<0)return;let i=t.content.map((r,s)=>s===n?r.withLeadingTrivia(e):r);return new wt(t.ordered,i,t.leadingTrivia)}if(t instanceof yt||t instanceof Je)return t.withLeadingTrivia(e)}function $r(t){let e=[];for(let n=0;n<t.length;n++){let i=t[n];if(i instanceof Fe&&i.glueKind===void 0){let r=e[e.length-1],s=t[n+1],o=r instanceof Nt&&s instanceof Nt,a=new Fe(i.content,o?"blockBreak":"blockGap"),l=r!==void 0?ju(r,a):void 0;l?e[e.length-1]=l:e.push(a);continue}e.push(i)}return e}function ju(t,e){switch(t.kind){case"paragraph":{let n=t;return new Nt([...n.content,e],n.leadingTrivia)}case"heading":{let n=t;return new Oi(n.level,n.marker,[...n.content,e],n.leadingTrivia)}case"codeBlock":{let n=t;return new Kt(n.language,n.infoString,[...n.content,e],n.leadingTrivia)}case"frontMatter":{let n=t;return new Ri([...n.content,e],n.leadingTrivia)}case"mathBlock":{let n=t;return new Li([...n.content,e],n.leadingTrivia)}case"thematicBreak":{let n=t;return new Ti([...n.content,e],n.leadingTrivia)}case"unhandledBlock":{let n=t;return new Kn(n.tokenType,[...n.content,e],n.leadingTrivia)}case"table":{let n=t;return new Mi([...n.content,e],n.leadingTrivia)}case"blockQuote":{let n=t;return new Ii(ba(n.content,e),n.leadingTrivia)}case"list":{let n=t;return new wt(n.ordered,ba(n.content,e),n.leadingTrivia)}case"listItem":{let n=t;return new yt(n.marker,ba(n.content,e),n.checked,n.leadingTrivia)}default:return}}function ba(t,e){let n=t[t.length-1],i=n!==void 0?ju(n,e):void 0;if(i){let r=t.slice();return r[r.length-1]=i,r}return[...t,e]}function Ov(t){return t.some(e=>!(e instanceof Fe))?t:[new Nt(t)]}var fe=class{constructor(e,n){this._parentStart=e,this._source=n}_entries=[];add(e,n){this._entries.push({node:e,start:n})}build(e,n){this._entries.sort((a,l)=>a.start-l.start);let i=[],r=this._parentStart,s=this._parentStart+e,o=(a,l)=>{let c=this._source.substring(a,l),d=n?null:/\n[^\S\n]+$/.exec(c);if(!d){i.push(new Fe(c,n));return}let h=c.slice(d.index+1);i.push(new Fe(c.slice(0,c.length-h.length))),i.push(new Fe(h,"indent"))};for(let{node:a,start:l}of this._entries)a.length!==0&&(l>r&&o(r,l),i.push(a),r=l+a.length);return r<s&&o(r,s),i}},Da=class{constructor(e,n){this._events=e,this._source=n}_idx=0;_checkChecked;build(){let e=new fe(0,this._source),n=0;for(;this._idx<this._events.length;){let i=this._events[this._idx];if(i.type==="enter"){let r=i.startOffset,s=this._tryParseBlock();if(s)e.add(s,r),n=Math.max(n,r+s.length);else{let o=this._tryParseUnhandled(n);o&&(e.add(o.node,o.start),n=Math.max(n,o.start+o.node.length))}}else this._idx++}return new Ba(Ov($r(Fr(e.build(this._source.length)))))}_tryParseBlock(){switch(this._events[this._idx].tokenType){case"yaml":return this._parseFrontMatter();case"atxHeading":return this._parseHeading();case"paragraph":return this._parseParagraph();case"codeFenced":return this._parseCodeFenced();case"codeIndented":return this._parseCodeIndented();case"mathFlow":return this._parseMathFlow();case"thematicBreak":return this._parseThematicBreak();case"blockQuote":return this._parseBlockQuote();case"listUnordered":case"listOrdered":return this._parseList();case"table":return this._parseTable();default:return}}_parseUnhandledBlock(){let e=this._events[this._idx],n=e.tokenType;this._idx++;let i=1,r=e;for(;this._idx<this._events.length&&i>0;){let o=this._events[this._idx];o.tokenType===n&&(i+=o.type==="enter"?1:-1),i===0&&(r=o),this._idx++}let s=this._source.substring(e.startOffset,r.endOffset);return new Kn(n,[new q("content",s)])}_tryParseUnhandled(e){let n=this._events[this._idx],i=n.startOffset;if(i>=e&&Cv.has(n.tokenType))return{node:this._parseUnhandledBlock(),start:i};this._idx++}_parseHeading(){let e=this._consume("enter","atxHeading"),n=1,i=e.startOffset,r=e.startOffset,s=[];for(;this._notExit("atxHeading");){let d=this._events[this._idx];if(d.type==="enter"&&d.tokenType==="atxHeadingSequence"){let h=this._consume("enter","atxHeadingSequence"),u=this._consume("exit","atxHeadingSequence");r===e.startOffset&&(n=Math.min(6,Math.max(1,u.endOffset-h.startOffset)),i=h.startOffset,r=u.endOffset)}else d.type==="enter"&&d.tokenType==="atxHeadingText"?(this._consume("enter","atxHeadingText"),this._parseInlines(s,"atxHeadingText"),this._consume("exit","atxHeadingText")):this._idx++}let o=this._consume("exit","atxHeading");r>i&&s.length>0&&(r=s[0].start);let a=new q("headingMarker",this._source.substring(e.startOffset,r)),l=new fe(r,this._source);for(let d of s)l.add(d.node,d.start);let c=l.build(o.endOffset-r);return new Oi(n,a,c)}_parseParagraph(){let e=this._consume("enter","paragraph"),n=[];for(;this._notExit("paragraph");)this._parseInlineEvent(n);let i=this._consume("exit","paragraph"),r=new fe(e.startOffset,this._source);for(let s of n)r.add(s.node,s.start);return new Nt(r.build(i.endOffset-e.startOffset))}_parseFrontMatter(){let e=this._consume("enter","yaml"),n=new fe(e.startOffset,this._source),i=!1,r,s;for(;this._notExit("yaml");){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType==="yamlFence"){let l=this._consume("enter","yamlFence");for(;this._notExit("yamlFence");)this._idx++;let c=this._consume("exit","yamlFence");n.add(new q(i?"closeFence":"openFence",this._source.substring(l.startOffset,c.endOffset)),l.startOffset),i=!0}else a.tokenType==="yamlValue"||a.tokenType==="lineEnding"?(r===void 0&&(r=a.startOffset),s=a.endOffset,this._idx++):this._idx++}let o=this._consume("exit","yaml");return r!==void 0&&n.add(new q("content",this._source.substring(r,s)),r),new Ri(n.build(o.endOffset-e.startOffset))}_parseCodeFenced(){let e=this._consume("enter","codeFenced"),n="",i,r,s=new fe(e.startOffset,this._source),o=!1,a,l;for(;this._notExit("codeFenced");){let h=this._events[this._idx];if(h.type==="enter"&&h.tokenType==="codeFencedFence"){let u=this._consume("enter","codeFencedFence");for(;this._notExit("codeFencedFence");){let m=this._events[this._idx];if(m.type==="enter"&&(m.tokenType==="codeFencedFenceInfo"||m.tokenType==="codeFencedFenceMeta")){let p=m.tokenType,v=this._consume("enter",p);for(i??=v.startOffset;this._notExit(p);){let g=this._events[this._idx];p==="codeFencedFenceInfo"&&g.type==="enter"&&g.tokenType==="data"&&(n+=this._source.substring(g.startOffset,g.endOffset)),this._idx++}r=this._consume("exit",p).endOffset}else this._idx++}let f=this._consume("exit","codeFencedFence");s.add(new q(o?"closeFence":"openFence",this._source.substring(u.startOffset,f.endOffset)),u.startOffset),o=!0}else h.tokenType==="codeFlowValue"||h.tokenType==="lineEnding"?(a===void 0&&(a=h.startOffset),l=h.endOffset,this._idx++):this._idx++}let c=this._consume("exit","codeFenced");a!==void 0&&s.add(new q("content",this._source.substring(a,l)),a);let d=i===void 0?"":this._source.substring(i,r);return new Kt(n,d,s.build(c.endOffset-e.startOffset))}_parseCodeIndented(){let e=this._consume("enter","codeIndented"),n=new fe(e.startOffset,this._source),i,r,s=()=>{i!==void 0&&(n.add(new q("content",this._source.substring(i,r)),i),i=void 0)};for(;this._notExit("codeIndented");){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType==="linePrefix"){s();let l=this._consume("enter","linePrefix"),c=this._consume("exit","linePrefix");n.add(new q("codeIndent",this._source.substring(l.startOffset,c.endOffset)),l.startOffset)}else a.tokenType==="codeFlowValue"||a.tokenType==="lineEnding"?(i===void 0&&(i=a.startOffset),r=a.endOffset,this._idx++):this._idx++}s();let o=this._consume("exit","codeIndented");return new Kt("","",n.build(o.endOffset-e.startOffset))}_parseMathFlow(){let e=this._consume("enter","mathFlow"),n=new fe(e.startOffset,this._source),i=!1,r,s;for(;this._notExit("mathFlow");){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType==="mathFlowFence"){let l=this._consume("enter","mathFlowFence");for(;this._notExit("mathFlowFence");)this._idx++;let c=this._consume("exit","mathFlowFence");n.add(new q(i?"closeFence":"openFence",this._source.substring(l.startOffset,c.endOffset)),l.startOffset),i=!0}else a.tokenType==="mathFlowValue"||a.tokenType==="lineEnding"?(r===void 0&&(r=a.startOffset),s=a.endOffset,this._idx++):this._idx++}let o=this._consume("exit","mathFlow");return r!==void 0&&n.add(new q("content",this._source.substring(r,s)),r),new Li(n.build(o.endOffset-e.startOffset))}_parseThematicBreak(){let e=this._consume("enter","thematicBreak");for(;this._notExit("thematicBreak");)this._idx++;let n=this._consume("exit","thematicBreak"),i=new q("content",this._source.substring(e.startOffset,n.endOffset));return new Ti([i])}_parseBlockQuote(){let e=this._consume("enter","blockQuote"),n=new fe(e.startOffset,this._source),i=!1,r=[],s=e.startOffset;for(;this._notExit("blockQuote");){let l=this._events[this._idx];if(l.type==="enter"&&l.tokenType==="blockQuotePrefix"){let c=this._consume("enter","blockQuotePrefix");for(;this._notExit("blockQuotePrefix");)this._idx++;let d=this._consume("exit","blockQuotePrefix");if(!i)n.add(new q("blockQuoteMarker",this._source.substring(c.startOffset,d.endOffset)),c.startOffset);else{let h=r[r.length-1];h&&!/^[\r\n]*$/.test(this._source.substring(h.endOffset,c.startOffset))&&(r=[]),r.push({startOffset:c.startOffset,endOffset:d.endOffset})}s=Math.max(s,d.endOffset)}else if(l.type==="enter"){let c=l.startOffset,d=this._tryParseBlock();if(d)n.add(d,c),i=!0,r=[],s=Math.max(s,c+d.length);else{let h=this._tryParseUnhandled(s);h&&(n.add(h.node,h.start),i=!0,r=[],s=Math.max(s,h.start+h.node.length))}}else this._idx++}let o=this._consume("exit","blockQuote"),a=r[r.length-1];if(a&&/^[\r\n]*$/.test(this._source.substring(a.endOffset,o.endOffset)))for(let l of r)n.add(new q("blockQuoteMarker",this._source.substring(l.startOffset,l.endOffset)),l.startOffset);return new Ii($r(Fr(n.build(o.endOffset-e.startOffset))))}_parseList(){let e=this._events[this._idx].tokenType,n=e==="listOrdered",i=this._consume("enter",e),r=new fe(i.startOffset,this._source),s,o,a,l,c,d,h=()=>{if(s===void 0||o===void 0||l===void 0)return;let f=new q("listItemMarker",this._source.substring(o,a)),m=d??a,p=l.build(m-a);r.add(new yt(f,$r(Fr(p)),c),s)};for(;this._notExit(e);){let f=this._events[this._idx];if(f.type==="enter"&&f.tokenType==="listItemPrefix"){for(h(),this._consume("enter","listItemPrefix"),s=f.startOffset,o=f.startOffset,c=void 0,d=void 0,this._checkChecked=void 0;this._notExit("listItemPrefix");)this._idx++;a=this._events[this._idx].endOffset,this._consume("exit","listItemPrefix"),l=new fe(a,this._source)}else if(f.type==="enter"){let m=f.startOffset,p=this._tryParseBlock();if(p&&l)l.add(p,m),d=m+p.length,c===void 0&&this._checkChecked!==void 0&&(c=this._checkChecked);else if(!p){let v=this._tryParseUnhandled(d??a??m);v&&l&&(l.add(v.node,v.start),d=v.start+v.node.length)}}else this._idx++}h();let u=this._consume("exit",e);return new wt(n,$r(Fr(r.build(u.endOffset-i.startOffset))))}_parseTable(){let e=this._consume("enter","table"),n=new fe(e.startOffset,this._source),i=0;for(;this._notExit("table");){let s=this._events[this._idx];if(s.type==="enter"&&s.tokenType==="tableHead"){for(this._consume("enter","tableHead");this._notExit("tableHead");){let o=this._events[this._idx];if(o.type==="enter"&&o.tokenType==="tableRow"){let a=this._parseTableRow("tableHeader");i=a.cells.length,n.add(a,o.startOffset)}else if(o.type==="enter"&&o.tokenType==="tableDelimiterRow"){let a=o.startOffset;for(;this._notExit("tableDelimiterRow");)this._idx++;let l=this._events[this._idx].endOffset;this._idx++,n.add(this._buildDelimiterRow(a,l,i),a)}else this._idx++}this._consume("exit","tableHead")}else if(s.type==="enter"&&s.tokenType==="tableBody"){for(this._consume("enter","tableBody");this._notExit("tableBody");){let o=this._events[this._idx];o.type==="enter"&&o.tokenType==="tableRow"?n.add(this._parseTableRow("tableData"),o.startOffset):this._idx++}this._consume("exit","tableBody")}else this._idx++}let r=this._consume("exit","table");return new Mi(n.build(r.endOffset-e.startOffset))}_buildDelimiterRow(e,n,i){let r=this._source.substring(e,n),s=[];for(let c=0;c<r.length;c++)r[c]==="|"&&s.push(c);let o=[],a=Math.max(1,i);if(r[0]==="|")for(let c=0;c<a&&c<s.length;c++)o.push(s[c]);else{o.push(0);for(let c=0;c<a-1&&c<s.length;c++)o.push(s[c])}let l=new fe(e,this._source);for(let c=0;c<o.length;c++){let d=o[c],h=c+1<o.length?o[c+1]:r.length,u=new fe(e+d,this._source),f=r.substring(d,h);c===o.length-1&&f.length>1&&f.endsWith("|")?(u.add(new q("tableDelimiter",f.slice(0,-1)),e+d),u.add(new q("tableDelimiterClose","|"),e+d+f.length-1)):u.add(new q("tableDelimiter",f),e+d),l.add(new Ai(u.build(h-d)),e+d)}return new Ni(l.build(n-e))}_parseTableRow(e){let n=this._consume("enter","tableRow"),i=new fe(n.startOffset,this._source);for(;this._notExit("tableRow");){let s=this._events[this._idx];if(s.type==="enter"&&s.tokenType===e){let o=this._consume("enter",e),a=[];for(;this._notExit(e);){let d=this._events[this._idx];if(d.type==="enter"&&d.tokenType==="tableContent"){for(this._consume("enter","tableContent");this._notExit("tableContent");)this._parseInlineEvent(a);this._consume("exit","tableContent")}else this._idx++}let l=this._consume("exit",e),c=new fe(o.startOffset,this._source);for(let d of a)c.add(d.node,d.start);i.add(new Ai(c.build(l.endOffset-o.startOffset,"tableCellGlue")),o.startOffset)}else this._idx++}let r=this._consume("exit","tableRow");return new Ni(i.build(r.endOffset-n.startOffset))}_parseInlines(e,n){for(;this._idx<this._events.length;){let i=this._events[this._idx];if(i.type==="exit"&&i.tokenType===n)return;this._parseInlineEvent(e)}}_parseInlineEvent(e){let n=this._events[this._idx];if(n.type==="enter")switch(n.tokenType){case"strongSequence":case"emphasisSequence":this._parseEmphasisOrStrong(e);return;case"codeText":e.push(this._parseInlineCode());return;case"mathText":e.push(this._parseInlineMath());return;case"link":e.push(this._parseLink());return;case"image":e.push(this._parseImage());return;case"strikethrough":e.push(this._parseStrikethrough());return;case"hardBreakTrailing":case"hardBreakEscape":e.push(this._parseHardBreak());return}n.type==="exit"&&(n.tokenType==="data"||n.tokenType==="codeTextData")&&e.push({node:new Ci(this._source.substring(n.startOffset,n.endOffset)),start:n.startOffset}),n.type==="exit"&&n.tokenType==="taskListCheckValueChecked"?this._checkChecked=!0:n.type==="exit"&&n.tokenType==="taskListCheckValueUnchecked"&&(this._checkChecked=!1),this._idx++}_parseHardBreak(){let e=this._events[this._idx],n=e.tokenType;for(this._consume("enter",n);this._notExit(n);)this._idx++;let i=this._consume("exit",n).endOffset,r=this._events[this._idx];return r&&r.type==="enter"&&r.tokenType==="lineEnding"&&(this._consume("enter","lineEnding"),i=this._consume("exit","lineEnding").endOffset),{node:new q("hardBreak",this._source.substring(e.startOffset,i)),start:e.startOffset}}_parseEmphasisOrStrong(e){let n=this._events[this._idx].tokenType,i=n==="strongSequence",r=this._consume("enter",n),s=this._consume("exit",n),o=[];for(;this._idx<this._events.length;){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType===n){let l=this._consume("enter",n),c=this._consume("exit",n),d=new q("openMarker",this._source.substring(r.startOffset,s.endOffset)),h=new q("closeMarker",this._source.substring(l.startOffset,c.endOffset)),u=new fe(s.endOffset,this._source);for(let p of o)u.add(p.node,p.start);let f=u.build(l.startOffset-s.endOffset),m=i?new Ia(d,f,h):new Ma(d,f,h);e.push({node:m,start:r.startOffset});return}this._parseInlineEvent(o)}e.push({node:new Ci(this._source.substring(r.startOffset,s.endOffset)),start:r.startOffset})}_parseInlineCode(){let e=this._consume("enter","codeText"),n=new fe(e.startOffset,this._source),i=!1,r,s;for(;this._notExit("codeText");){let a=this._events[this._idx];a.type==="enter"&&a.tokenType==="codeTextSequence"?(n.add(new q(i?"closeMarker":"openMarker",this._source.substring(a.startOffset,a.endOffset)),a.startOffset),i=!0):a.type==="enter"&&a.tokenType==="codeTextData"&&(r===void 0&&(r=a.startOffset),s=a.endOffset),this._idx++}let o=this._consume("exit","codeText");return r!==void 0&&n.add(new q("content",this._source.substring(r,s)),r),{node:new Aa(n.build(o.endOffset-e.startOffset)),start:e.startOffset}}_parseInlineMath(){let e=this._consume("enter","mathText"),n=new fe(e.startOffset,this._source),i=!1,r,s;for(;this._notExit("mathText");){let a=this._events[this._idx];a.type==="enter"&&a.tokenType==="mathTextSequence"?(n.add(new q(i?"closeMarker":"openMarker",this._source.substring(a.startOffset,a.endOffset)),a.startOffset),i=!0):a.type==="enter"&&a.tokenType==="mathTextData"&&(r===void 0&&(r=a.startOffset),s=a.endOffset),this._idx++}let o=this._consume("exit","mathText");return r!==void 0&&n.add(new q("content",this._source.substring(r,s)),r),{node:new Pa(n.build(o.endOffset-e.startOffset)),start:e.startOffset}}_parseStrikethrough(){let e=this._consume("enter","strikethrough"),n,i,r=e.startOffset,s=e.startOffset,o=[];for(;this._notExit("strikethrough");){let c=this._events[this._idx];if(c.type==="enter"&&c.tokenType==="strikethroughSequence"){let d=this._source.substring(c.startOffset,c.endOffset);n?(i=new q("closeMarker",d),s=c.startOffset):(n=new q("openMarker",d),r=c.endOffset),this._idx++}else c.type==="enter"&&c.tokenType==="strikethroughText"?(this._consume("enter","strikethroughText"),this._parseInlines(o,"strikethroughText"),this._consume("exit","strikethroughText")):this._idx++}this._consume("exit","strikethrough");let a=new fe(r,this._source);for(let c of o)a.add(c.node,c.start);let l=a.build(s-r);return{node:new Na(n,l,i),start:e.startOffset}}_parseLink(){let e=this._consume("enter","link"),n=new fe(e.startOffset,this._source),i=[],r="",s=!1;for(;this._notExit("link");){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType==="label"){for(this._consume("enter","label");this._notExit("label");){let l=this._events[this._idx];if(l.type==="enter"&&l.tokenType==="labelMarker")n.add(new q(s?"closeBracket":"openBracket",this._source.substring(l.startOffset,l.endOffset)),l.startOffset),s=!0;else if(l.type==="enter"&&l.tokenType==="labelText"){this._consume("enter","labelText"),this._parseInlines(i,"labelText"),this._consume("exit","labelText");continue}this._idx++}this._consume("exit","label")}else if(a.type==="enter"&&a.tokenType==="resource"){this._consume("enter","resource");let l=!1;for(;this._notExit("resource");){let c=this._events[this._idx];c.type==="enter"&&c.tokenType==="resourceMarker"?(n.add(new q(l?"closeParen":"openParen",this._source.substring(c.startOffset,c.endOffset)),c.startOffset),l=!0):c.type==="enter"&&c.tokenType==="resourceDestinationString"&&(r=this._source.substring(c.startOffset,c.endOffset),n.add(new q("url",r),c.startOffset)),this._idx++}this._consume("exit","resource")}else this._idx++}let o=this._consume("exit","link");for(let a of i)n.add(a.node,a.start);return{node:new Fa(r,n.build(o.endOffset-e.startOffset)),start:e.startOffset}}_parseImage(){let e=this._consume("enter","image"),n=new fe(e.startOffset,this._source),i="",r="",s=!1;for(;this._notExit("image");){let a=this._events[this._idx];if(a.type==="enter"&&a.tokenType==="label"){for(this._consume("enter","label");this._notExit("label");){let l=this._events[this._idx];l.type==="enter"&&l.tokenType==="labelImageMarker"?n.add(new q("bangBracket",this._source.substring(l.startOffset,l.endOffset)),l.startOffset):l.type==="enter"&&l.tokenType==="labelMarker"?(n.add(new q(s?"closeBracket":"openBracket",this._source.substring(l.startOffset,l.endOffset)),l.startOffset),s=!0):l.type==="enter"&&l.tokenType==="labelText"&&(i=this._source.substring(l.startOffset,l.endOffset)),this._idx++}this._consume("exit","label")}else if(a.type==="enter"&&a.tokenType==="resource"){this._consume("enter","resource");let l=!1;for(;this._notExit("resource");){let c=this._events[this._idx];c.type==="enter"&&c.tokenType==="resourceMarker"?(n.add(new q(l?"closeParen":"openParen",this._source.substring(c.startOffset,c.endOffset)),c.startOffset),l=!0):c.type==="enter"&&c.tokenType==="resourceDestinationString"&&(r=this._source.substring(c.startOffset,c.endOffset)),this._idx++}this._consume("exit","resource")}else this._idx++}let o=this._consume("exit","image");return{node:new $a(i,r,n.build(o.endOffset-e.startOffset)),start:e.startOffset}}_notExit(e){if(this._idx>=this._events.length)return!1;let n=this._events[this._idx];return!(n.type==="exit"&&n.tokenType===e)}_consume(e,n){let i=this._events[this._idx];if(!i||i.type!==e||i.tokenType!==n)throw new Error(`Expected ${e}:${n} at ${this._idx}, got ${i?.type}:${i?.tokenType}`);return this._idx++,i}},Kr=class{constructor(e){this._edit=e}getOriginalRange(e){let n=0;for(let i of this._edit.replacements){let r=i.replaceRange.start+n;if(r>=e.endExclusive)break;let s=r+i.newText.length;if(Math.max(r,e.start)<Math.min(s,e.endExclusive))return;n+=i.newText.length-i.replaceRange.length}return e.delta(-n)}getOriginalOffset(e){let n=0;for(let i of this._edit.replacements){let r=i.replaceRange.start+n;if(e<r)break;if(e<r+i.newText.length)return;n+=i.newText.length-i.replaceRange.length}return e-n}},Va=class{_byRange=new Map;_byId=new Map;constructor(e){this._walk(e,0)}_walk(e,n){let i=`${n}:${n+e.length}`,r=this._byRange.get(i);r||(r=[],this._byRange.set(i,r)),r.push(e),this._byId.set(`${n}:${e.kind}`,e);let s=n;for(let o of e.children)this._walk(o,s),s+=o.length}lookupExact(e,n){return this._byRange.get(`${e.start}:${e.endExclusive}`)?.find(i=>i.kind===n)}lookupId(e,n){return this._byId.get(`${e}:${n}`)}};function Wu(t,e,n,i,r){let s,o=e;for(let h of t.children){let u=Wu(h,o,n,i,r);u!==h&&(s??=new Map).set(h,u),o+=h.length}let a=s?t.mapChildren(s):t,l=n.getOriginalRange(O.ofStartAndLength(e,t.length));if(l){let h=i.lookupExact(l,a.kind);if(h&&a.equalsShallow(h))return h}let c=n.getOriginalOffset(e),d=c!==void 0?i.lookupId(c,a.kind):void 0;if(d&&d.id!==a.id&&(a=a.cloneWithId(d.id)),a instanceof Kt&&d instanceof Kt&&c!==void 0){let h=Rv(a,d,c,r);if(h)return h}return a}function Rv(t,e,n,i){let r=e.code,s=t.code;if(!r||!s||t.infoString!==e.infoString||t.openFence?.content!==e.openFence?.content||t.closeFence?.content!==e.closeFence?.content)return;let o=n+e.codeOffset,a=o+r.length;if(!Lv(i,o,a))return;let l=Iv(i,-o);if(l.apply(r.content)===s.content)return t.withCodeDiff(e,l)}function Lv(t,e,n){for(let i of t.replacements)if(i.replaceRange.start<e||i.replaceRange.endExclusive>n)return!1;return!0}function Iv(t,e){return new H(t.replacements.map(n=>ze.replace(n.replaceRange.delta(e),n.newText)))}function Mv(t,e,n){return Wu(t,0,new Kr(n),new Va(e),n)}function Nv(t,e,n){let i=Ev(t);return!e||!n?i:Mv(i,e,n)}var qa=class{parse(e,n,i){return Nv(e.value,n,i)}};function Av(t){let e=0,n=[];for(let i of t.replacements){let r=i.replaceRange.start+e;n.push({original:i.replaceRange,modified:O.ofStartAndLength(r,i.newText.length)}),e+=i.newText.length-i.replaceRange.length}return n}var Pv={},Hu=V(Pv,!1),Fv=Hu,ja,_a;function $v(){return _a||(_a=iu({useWasm:!1}).then(t=>{ja=t,Hu.set(!0,void 0)}).catch(()=>{})),_a}$v();function Bv(t,e){if(!ja)throw new Error("Diff computer not loaded yet \u2014 await ensureDiffComputer() / observe diffComputerReady first.");let n=ja.computeDiff(t,e,{extendToSubwords:!0});return Dv(n.edits.stripData())}function Dv(t){return new H(t.replacements.map(e=>ze.replace(new O(e.range.start,e.range.endExclusive),e.newText)))}var Vv=new Set(["document","list","blockQuote","table","tableRow"]),qv=new Set(["glue","marker"]);function jv(t,e,n){let i=new Kr(n),r=Av(n);return Ku(t,0,e,0,i,r)}function Ku(t,e,n,i,r,s){let o=su(t,e),a=su(n,i),l=[],c=0;for(let d of a){let h=O.ofStartAndLength(d.start,d.node.length),u=r.getOriginalOffset(d.start);for(;c<o.length&&u!==void 0&&o[c].start+o[c].node.length<=u;)l.push(ou(o[c],s)),c++;let f=c<o.length?o[c]:void 0,m=f?O.ofStartAndLength(f.start,f.node.length):void 0,p=r.getOriginalRange(h);p&&m&&p.equals(m)?(l.push({kind:"unchanged",node:d.node,modifiedStart:d.start}),c++):f&&m&&f.node.kind===d.node.kind&&u!==void 0&&m.contains(u)?(c++,Vv.has(d.node.kind)?l.push({kind:"nested",original:f.node,originalStart:f.start,modified:d.node,modifiedStart:d.start,children:Ku(f.node,f.start,d.node,d.start,r,s)}):l.push({kind:"replaced",original:f.node,originalStart:f.start,modified:d.node,modifiedStart:d.start,insertedLocal:Ur(h,d.start,s,"modified","inserted"),deletedLocal:Ur(m,f.start,s,"original","deleted")})):l.push(Wv(d,s))}for(;c<o.length;)l.push(ou(o[c],s)),c++;return l}function su(t,e){let n=[],i=e;for(let r of t.children)qv.has(r.kind)||n.push({node:r,start:i}),i+=r.length;return n}function Wv(t,e){let n=O.ofStartAndLength(t.start,t.node.length),i=Ur(n,t.start,e,"modified","inserted");return i.length===0&&(i=[{range:O.ofLength(t.node.length),kind:"inserted"}]),{kind:"added",node:t.node,modifiedStart:t.start,insertedLocal:i}}function ou(t,e){let n=O.ofStartAndLength(t.start,t.node.length),i=Ur(n,t.start,e,"original","deleted");return i.length===0&&(i=[{range:O.ofLength(t.node.length),kind:"deleted"}]),{kind:"removed",node:t.node,originalStart:t.start,deletedLocal:i}}function Ur(t,e,n,i,r){let s=[];for(let o of n){let a=(i==="original"?o.original:o.modified).intersect(t);a&&!a.isEmpty&&s.push({range:a.delta(-e),kind:r})}return s}var Hv=Symbol("NO_ACTIVE_BLOCKS"),Zr=class{_parser=new qa;_sourceEditListeners=new Set;_sourceTextIds=new WeakMap;_lastSourceTextId=0;_pendingEdit;sourceText=V(this,new gn(""));wordNavigationConfig=V(this,an);readonlyMode=V(this,!1);selection=V(this,void 0);selectionSource=V(this,"user");ctrlOrMetaDown=V(this,!1);isSelecting=V(this,!1);gutterMarkers=V(this,[]);activeBlocksOverride=V(this,void 0);pendingParagraph=V(this,void 0);cursorOffset=re(this,e=>e.readObservable(this.selection)?.active);cursorPosition=re(this,e=>{let n=e.readObservable(this.pendingParagraph);if(n)return ue.virtual(n.cursorLine);let i=e.readObservable(this.selection)?.active;return i===void 0?void 0:ue.source(i)});document=(()=>{let e,n;return re(this,i=>{let r=i.readObservable(this.sourceText);if(e&&n===r.value)return e;let s=this._pendingEdit,o=s&&s.baseText===n&&s.newText===r.value?s.edit:void 0,a=this._parser.parse(r,e,o);return e=a,n=r.value,a})})();activeBlock=re(this,e=>{let n=e.readObservable(this.document),i=e.readObservable(this.cursorOffset);if(i!==void 0)return Uu(n,i)});activeBlocks=re(this,e=>{if(this.readonlyMode.read(e))return new Set;if(e.readObservable(this.pendingParagraph)!==void 0)return new Set;let n=e.readObservable(this.activeBlocksOverride);if(n===Hv)return new Set;if(n!==void 0)return new Set(n);let i=e.readObservable(this.document),r=e.readObservable(this.selection);return r===void 0?new Set:new Set(Wa(i,r.range.start,r.range.endExclusive))});baseline=V(this,void 0);_baselineDocument=re(this,e=>{let n=e.readObservable(this.baseline);return n?this._parser.parse(n):void 0});diff=re(this,e=>{let n=e.readObservable(this._baselineDocument),i=e.readObservable(this.baseline);if(!n||!i||!e.readObservable(Fv))return;let r=e.readObservable(this.document),s=e.readObservable(this.sourceText),o=Bv(i.value,s.value),a=jv(n,r,o),l=[],c=(h,u)=>{for(let f of h)if(f.kind==="replaced")for(let m of f.insertedLocal)l.push(m.range.delta(f.modifiedStart));else if(f.kind==="added"&&!u)for(let m of f.insertedLocal)l.push(m.range.delta(f.modifiedStart));else f.kind==="nested"&&c(f.children,!1)};c(a,!0);let d=new Set;for(let h of a)h.kind==="replaced"&&d.add(h.modified);return{items:a,insertedRanges:l,changedBlocks:d}});markerVisibleBlocks=re(this,e=>{let n=e.readObservable(this.activeBlocks),i=e.readObservable(this.diff);return i?new Set([...n,...i.changedBlocks]):n});onWillApplySourceEdit(e){return this._sourceEditListeners.add(e),{dispose:()=>this._sourceEditListeners.delete(e)}}getSourceTextId(e){let n=this._sourceTextIds.get(e);return n===void 0&&(n=++this._lastSourceTextId,this._sourceTextIds.set(e,n)),n}armPendingParagraph(e){Ce(n=>{this.pendingParagraph.set({...e,text:"",cursorLine:new La(e.replaceRange.start,e.replaceRange.endExclusive),syntheticAst:new Nt([])},n),this.selectionSource.set("user",n),this.selection.set($.collapsed(e.replaceRange.start),n)})}cancelPendingParagraph(){this.pendingParagraph.get()!==void 0&&this.pendingParagraph.set(void 0,void 0)}replaceSourceText(e){let n=this.sourceText.get(),i=Ac(n.value,e.value),r=this.selection.get(),s=r?new $(Br(i.mapOffset(Br(r.anchor,n.value.length)),e.value.length),Br(i.mapOffset(Br(r.active,n.value.length)),e.value.length)):void 0;i.isEmpty||(this._pendingEdit={baseText:n.value,newText:e.value,edit:i}),Ce(o=>{this.pendingParagraph.set(void 0,o),i.isEmpty||this.sourceText.set(e,o),s!==r&&this.selection.set(s,o)})}setPendingParagraphText(e){if(this.readonlyMode.get())return;if(!/^[ \t]*$/.test(e))throw new TypeError("Pending paragraph text must contain only spaces and tabs");let n=this.pendingParagraph.get();!n||n.text===e||this.pendingParagraph.set({...n,text:e},void 0)}materializePendingParagraph(e){if(this.readonlyMode.get())return;let n=this.pendingParagraph.get();if(!n)return;let i=n.text+e,r=n.separateFromPreviousBlock?`

`:"",s=r+i+(n.atEof?"":`

`),o=n.replaceRange.start+r.length+i.length,a=H.replace(n.replaceRange,s);this._applySourceEdit(a,$.collapsed(o))}setTaskCheckboxChecked(e,n){if(e.checked===n)return;let i=ot(this.document.get(),e),r=Sv(e);if(i===void 0||r===void 0)return;let s=H.replace(r.delta(i),n?"[x]":"[ ]");this._applySourceEdit(s,this.selection.get()??$.collapsed(0))}applyEdit(e,n){if(this.readonlyMode.get())return;let i=this.selection.get()??$.collapsed(0),r=e.mapOffset(i.active);this._applySourceEdit(e,n??$.collapsed(r))}applyEditForSelection(e){if(this.readonlyMode.get())return;let n=this.selection.get()??$.collapsed(0),i=e.mapOffset(n.range.endExclusive);this._applySourceEdit(e,$.collapsed(i))}_applySourceEdit(e,n){let i=this.sourceText.get(),r=new gn(e.apply(i.value));this._pendingEdit={baseText:i.value,newText:r.value,edit:e};let s=this._identifySourceEdit(i,r);Ce(o=>{this._emitWillApplySourceEdit({...s,edit:e,transaction:o}),this.pendingParagraph.set(void 0,o),this.sourceText.set(r,o),this.selectionSource.set("user",o),this.selection.set(n,o)})}_identifySourceEdit(e,n){return{baseSourceTextId:this.getSourceTextId(e),resultSourceTextId:this.getSourceTextId(n)}}_emitWillApplySourceEdit(e){for(let n of this._sourceEditListeners)n(e)}};function Br(t,e){return Math.max(0,Math.min(t,e))}function Uu(t,e){let n=new Set(t.blocks),i=0,r;for(let s of t.children){let o=i+s.length;if(n.has(s)){if(i<=e&&e<o)return s;o===e&&(r=s)}i=o}return r}function Wa(t,e,n){if(e===n){let o=Uu(t,e);return o?[o]:[]}let i=[],r=new Set(t.blocks),s=0;for(let o of t.children){let a=s+o.length;r.has(o)&&s<n&&a>e&&i.push(o),s=a}return i}var Pi=class t{constructor(e){this.lines=e,this.sourceLines=e.filter(n=>!n.virtualCursorLine)}static EMPTY=new t([]);static measure(e,n,i=n.capture()){return Zv(e,n,i)}sourceLines;get lineCount(){return this.lines.length}get isEmpty(){return this.lines.length===0}lineRect(e){return this.lines[e].rect}lineIndexOfOffset(e){let n=-1;for(let s=0;s<this.lines.length;s++){if(this.lines[s].virtualCursorLine)continue;let o=this.lines[s].offsetMembership(e);if(o==="covers")return s;o==="end"&&n<0&&(n=s)}if(n>=0)return n;let i=0,r=1/0;for(let s=0;s<this.lines.length;s++){if(this.lines[s].virtualCursorLine)continue;let o=this.lines[s].sourceDistanceTo(e);o<r&&(r=o,i=s)}return i}xAtOffset(e){return this.lines.length===0?0:this.lines[this.lineIndexOfOffset(e)].xAtOffset(e)}lineIndexOfPosition(e){if(e.kind==="source")return this.lineIndexOfOffset(e.offset);let n=this.lines.findIndex(i=>i.virtualCursorLine===e.line);return n<0?void 0:n}xAtPosition(e){if(e.kind==="source")return this.xAtOffset(e.offset);let n=this.lineIndexOfPosition(e);return n===void 0?0:this.lines[n].rect.left}lineIndexAtY(e){if(this.lines.length===0)return 0;for(let n=0;n<this.lines.length;n++)if(!this.lines[n].virtualCursorLine&&e<this.lines[n].rect.bottom)return n;for(let n=this.lines.length-1;n>=0;n--)if(!this.lines[n].virtualCursorLine)return n;return 0}offsetAtPoint(e){return this.offsetInLineAtX(this.lineIndexAtY(e.y),e.x)}offsetInLineAtX(e,n){if(e<0||e>=this.lines.length)return 0;let i=this.lines[e].virtualCursorLine;return i?i.sourceOffsetBefore:this.lines[e].offsetAtX(n)}positionInLineAtX(e,n){if(e<0||e>=this.lines.length)return ue.source(0);let i=this.lines[e].virtualCursorLine;return i?ue.virtual(i):ue.source(this.lines[e].offsetAtX(n))}lineStartOffset(e){if(e<0||e>=this.lines.length)return;let n=this.lines[e];if(!n.virtualCursorLine)return n.offsetAtX(n.rect.left)}lineEndOffset(e){if(e<0||e>=this.lines.length)return;let n=this.lines[e];if(!n.virtualCursorLine)return n.offsetAtX(n.rect.right)}},Xr=class t{constructor(e,n,i){this.rect=e,this.runs=n,this.virtualCursorLine=i}static virtual(e,n){return new t(n,[pn.visualLineAnchor(e.sourceOffsetBefore,n.withZeroWidthAt(n.left))],e)}containsOffset(e){for(let n of this.runs)if(n.containsOffset(e))return!0;return!1}offsetMembership(e){let n=!1;for(let i of this.runs){if(i.isVisualLineAnchor&&e===i.sourceStart||e>=i.sourceStart&&e<i.sourceEndExclusive)return"covers";e===i.sourceEndExclusive&&(n=!0)}return n?"end":"none"}sourceDistanceTo(e){let n=1/0;for(let i of this.runs){let r=i.sourceDistanceTo(e);r<n&&(n=r)}return n}xAtOffset(e){for(let o of this.runs)if(o.isVisualLineAnchor&&o.sourceStart===e)return o.rect.left;for(let o of this.runs)if(o.sourceStart===e)return o.xAtOffset(e);for(let o of this.runs)if(o.containsOffset(e))return o.xAtOffset(e);let n,i=-1/0,r,s=1/0;for(let o of this.runs)o.sourceEndExclusive<=e&&o.sourceEndExclusive>i&&(i=o.sourceEndExclusive,n=o.rect.right),o.sourceStart>=e&&o.sourceStart<s&&(s=o.sourceStart,r=o.rect.left);return n!==void 0?n:r!==void 0?r:this.runs[0].rect.left}offsetAtX(e){if(this.runs.length===0)return 0;let n=this.runs[0],i=1/0;for(let s of this.runs){if(s.rect.containsX(e)||e===s.rect.right)return s.offsetAtX(e);let o=Math.min(Math.abs(e-s.rect.left),Math.abs(e-s.rect.right));o<i&&(i=o,n=s)}let r=Math.min(Math.max(e,n.rect.left),n.rect.right);return n.offsetAtX(r)}},pn=class t{constructor(e,n,i,r=!1){this.sourceRange=e,this.rect=n,this.source=i,this.isVisualLineAnchor=r}static visualLineAnchor(e,n){return new t(O.emptyAt(e),n,void 0,!0)}get sourceStart(){return this.sourceRange.start}get sourceEndExclusive(){return this.sourceRange.endExclusive}get sourceLength(){return this.sourceRange.length}containsOffset(e){return e>=this.sourceStart&&e<=this.sourceEndExclusive}sourceDistanceTo(e){return e<this.sourceStart?this.sourceStart-e:e>this.sourceEndExclusive?e-this.sourceEndExclusive:0}xAtOffset(e){return this.sourceLength===0||e<=this.sourceStart?this.rect.left:this.source?Kv(this.source.textNode,this.source.textNodeStart+(e-this.sourceStart),this.rect.left,this.source.coordinateSpace):(e-this.sourceStart)/this.sourceLength<=.5?this.rect.left:this.rect.right}offsetAtX(e){if(this.rect.width<=0)return this.sourceStart;if(this.source){let i=Uv(this.source.textNode,this.source.textNodeStart,this.source.textNodeStart+this.sourceLength,e,this.source.coordinateSpace);return this.sourceStart+(i-this.source.textNodeStart)}let n=(this.rect.left+this.rect.right)/2;return e<n?this.sourceStart:this.sourceEndExclusive}};function Kv(t,e,n,i){if(e<=0)return n;let r=document.createRange();r.setStart(t,e-1),r.setEnd(t,e);let s=r.getBoundingClientRect();return s.width===0&&s.height===0?n:i.capture().toLocalRect(s).right}function Uv(t,e,n,i,r){let s=document.createRange(),o=r.capture(),a=e,l=1/0;for(let c=e;c<n;c++){s.setStart(t,c),s.setEnd(t,c+1);let d=s.getBoundingClientRect();if(d.width===0&&d.height===0)continue;let h=o.toLocalRect(d),u=(h.left+h.right)/2,f=Math.abs(i-h.left),m=Math.abs(i-h.right);if(f<l&&(l=f,a=c),m<l&&(l=m,a=c+1),i>=h.left&&i<=h.right)return i<u?c:c+1}return a}function Zv(t,e,n){let i=[];for(let h of t){let u=i.length;h.viewNode.forEachTextLeaf(h.absoluteStart,(f,m)=>{let p=f.dom;if(p.length===0)return;let v=document.createRange();v.selectNodeContents(p);let g=v.getClientRects();if(g.length===0)return;let w=Xv(Array.from(g,x=>n.toLocalRect(x))),y=Gv(p.parentElement);if(f.sourceLength===0){i.push(pn.visualLineAnchor(m,wa(w[0],y)));return}if(w.length===1)i.push(new pn(O.fromTo(m,m+p.length),wa(w[0],y),{textNode:p,textNodeStart:0,coordinateSpace:e}));else{let x=Jv(p,w,n);for(let C=0;C<w.length;C++){let k=C===0?0:x[C-1],E=C<x.length?x[C]:p.length;i.push(new pn(O.fromTo(m+k,m+E),wa(w[C],y),{textNode:p,textNodeStart:k,coordinateSpace:e}))}}}),i.length===u&&Yv(i,h.viewNode,h.absoluteStart,n)}i.sort((h,u)=>h.rect.y-u.rect.y||h.rect.x-u.rect.x);let r=[],s=[],o=-1/0,a=0,l=1/0,c=-1/0,d=()=>{s.length!==0&&r.push(new Xr(ne.fromPointPoint(l,o,c,o+a),s))};for(let h of i){let u=h.rect;s.length>0&&Zu(ne.fromPointSize(l,o,c-l,a),u)?(s.push(h),a=Math.max(a,u.y+u.height-o),l=Math.min(l,u.left),c=Math.max(c,u.right)):(d(),s=[h],o=u.y,a=u.height,l=u.left,c=u.right)}return d(),new Pi(r)}function Xv(t){let e=[];for(let n of t){let i=e[e.length-1];if(!i||!Zu(i,n)){e.push(n);continue}e[e.length-1]=ne.fromPointPoint(Math.min(i.left,n.left),Math.min(i.top,n.top),Math.max(i.right,n.right),Math.max(i.bottom,n.bottom))}return e}function Zu(t,e){return Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top)>Math.min(t.height,e.height)/2}function Jv(t,e,n){let i=[],r=document.createRange();for(let s=0;s<e.length-1;s++){let o=e[s+1].y,a=s===0?0:i[s-1],l=t.length;for(;a<l;){let c=a+l>>>1;r.setStart(t,c),r.setEnd(t,Math.min(c+1,t.length)),n.toLocalRect(r.getBoundingClientRect()).y<o-1?a=c+1:l=c}i.push(a)}return i}function Gv(t){if(!t)return 0;let e=getComputedStyle(t),n=parseFloat(e.lineHeight);return isFinite(n)||(n=parseFloat(e.fontSize)*1.2),n}function wa(t,e){if(e<=t.height)return ne.fromPointSize(t.x,t.y,t.width,t.height);let n=(e-t.height)/2;return ne.fromPointSize(t.x,t.y-n,t.width,e)}function Yv(t,e,n,i){let r=e.dom;if(r.nodeType!==1)return;let s=r.getBoundingClientRect();if(s.width===0&&s.height===0)return;let o=i.toLocalRect(s);t.push(new pn(O.fromTo(n,n+e.sourceLength),ne.fromPointSize(o.x,o.y,o.width,o.height)))}var Ha=class{_measurements=V(this,[]);measurements=this._measurements;_virtualLines=V(this,[]);visualLineMap=re(this,e=>{let n=e.readObservable(this._measurements),i=e.readObservable(this._virtualLines),r=new Map;for(let o of i){let a=r.get(o.afterBlock);a?a.push(o.line):r.set(o.afterBlock,[o.line])}let s=n.flatMap(o=>[...o.visualLineMap?.lines??[],...r.get(o.block)??[]]);return new Pi(s)});setMeasurements(e,n){Ce(i=>{this._measurements.set(e,i),this._virtualLines.set(n,i)})}},au=new WeakMap,Qv=64;function Un(t,e,n,i){let r=i==="right"?n+1:n-1;return zt(t,e,n,r,i)}function zt(t,e,n,i,r,s=!0){i=Math.min(Math.max(i,0),t.length);let o=Xu(t,e,n);if(r==="right")for(let a=nb(o,i);a<o.length;a++){let l=o[a];if(l.start>i)break;(l.contains(i)||s&&l.start===i)&&(i=l.endExclusive)}else for(let a=ib(o,i);a>=0;a--){let l=o[a];if(l.endExclusive<i)break;(l.contains(i)||s&&l.endExclusive===i)&&(i=l.start)}return i}function Xu(t,e,n){let i=eb(t),r=tb(i,e,n),s=i.rangesByVisibilityKey.get(r);if(s)return i.rangesByVisibilityKey.delete(r),i.rangesByVisibilityKey.set(r,s),s;let o=[];for(let a of i.entries)if(!e.has(a.block))o.push(...a.hiddenRanges);else if(a.block.kind==="list")for(let l of rb(a.block,Ps(a.block,n-a.start)))o.push(l.delta(a.start));return i.rangesByVisibilityKey.set(r,o),i.rangesByVisibilityKey.size>Qv&&i.rangesByVisibilityKey.delete(i.rangesByVisibilityKey.keys().next().value),o}function eb(t){let e=au.get(t);if(e)return e;let n=new Set(t.blocks),i=[],r=new Map,s=0;for(let o of t.children){if(n.has(o)){let a=o,l={block:a,index:i.length,start:s,hiddenRanges:sb(a).map(c=>c.delta(s))};i.push(l),r.set(a,l)}s+=o.length}return e={entries:i,entryByBlock:r,rangesByVisibilityKey:new Map},au.set(t,e),e}function tb(t,e,n){let i=[];for(let r of e){let s=t.entryByBlock.get(r);if(!s)continue;let o=r.kind==="list"?Ps(r,n-s.start)??"":"";i.push(`${s.index}:${o}`)}return i.sort(),i.join(",")}function nb(t,e){let n=0,i=t.length;for(;n<i;){let r=n+i>>>1;t[r].endExclusive<e?n=r+1:i=r}return n}function ib(t,e){let n=0,i=t.length;for(;n<i;){let r=n+i>>>1;t[r].start<=e?n=r+1:i=r}return n-1}function Ps(t,e){let n=0,i;for(let r=0;r<t.children.length;r++){let s=t.children[r],o=n+s.length,a=t.items.indexOf(s);if(a>=0){if(n<=e&&e<o)return a;o===e&&(i=a)}n=o}return i}function rb(t,e){let n=[],i=0;for(let r of t.children){let s=t.items.indexOf(r);if(s>=0&&s!==e){let o=t.items[s];jl(o,i,n)}i+=r.length}return n.sort((r,s)=>r.start-s.start),n}function sb(t){let e=[];return jl(t,0,e),e.sort((n,i)=>n.start-i.start),e}function jl(t,e,n){if(t.children.length===0){t instanceof q&&n.push(O.ofStartAndLength(e,t.length));return}switch(t.kind){case"frontMatter":case"codeBlock":case"mathBlock":{let r=e;for(let s of t.children)s instanceof q&&(s.markerKind==="openFence"||s.markerKind==="closeFence")&&n.push(O.ofStartAndLength(r,s.length)),r+=s.length;return}case"inlineCode":case"inlineMath":{let r=e;for(let s of t.children)s instanceof q&&(s.markerKind==="openMarker"||s.markerKind==="closeMarker")&&n.push(O.ofStartAndLength(r,s.length)),r+=s.length;return}case"thematicBreak":return;case"unhandledBlock":return;case"image":{n.push(O.ofStartAndLength(e,t.length));return}}let i=e;for(let r of t.children)jl(r,i,n),i+=r.length}var ob=t=>t.cursorPosition.kind==="virtual"?Fs(t,t.cursorPosition.line,"after","right"):t.selection.isCollapsed?ue.source(Un(t.document,t.markerVisibleBlocks,t.selection.active,"right")):ue.source(t.selection.range.endExclusive),ab=t=>t.cursorPosition.kind==="virtual"?Fs(t,t.cursorPosition.line,"before","left"):t.selection.isCollapsed?ue.source(Un(t.document,t.markerVisibleBlocks,t.selection.active,"left")):ue.source(t.selection.range.start),lb=t=>t.cursorPosition.kind==="virtual"?Fs(t,t.cursorPosition.line,"after","right"):ue.source(Un(t.document,t.markerVisibleBlocks,t.selection.active,"right")),cb=t=>t.cursorPosition.kind==="virtual"?Fs(t,t.cursorPosition.line,"before","left"):ue.source(Un(t.document,t.markerVisibleBlocks,t.selection.active,"left")),db=t=>{let e=t.cursorPosition.kind==="virtual"?t.cursorPosition.line.sourceOffsetAfter:t.selection.active;return ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,sd(t.text,e,t.wordNavigationConfig),"right",!1))},ub=t=>{let e=t.cursorPosition.kind==="virtual"?t.cursorPosition.line.sourceOffsetBefore:t.selection.active;return ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,rd(t.text,e,t.wordNavigationConfig),"left",!1))},Ka=t=>t.cursorPosition.kind==="virtual"?t.cursorPosition:ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,t.selection.active===0?0:t.text.lastIndexOf(`
`,t.selection.active-1)+1,"right")),Ua=t=>{if(t.cursorPosition.kind==="virtual")return t.cursorPosition;let e=t.text.indexOf(`
`,t.selection.active);return ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,e===-1?t.text.length:e,"left"))},hb=t=>ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,0,"right")),fb=t=>ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,t.text.length,"left")),mb=t=>{if(t.cursorPosition.kind==="virtual")return{position:t.cursorPosition,desiredColumn:void 0};let e=t.lineMap.lineIndexOfPosition(t.cursorPosition);if(e===void 0)return{position:Ka(t),desiredColumn:void 0};let n=t.lineMap.lineStartOffset(e),i=t.lineMap.lineEndOffset(e);if(n===void 0||i===void 0)return{position:Ka(t),desiredColumn:void 0};let r=n===0?0:t.text.lastIndexOf(`
`,n-1)+1,s=n;if(n===r){for(;s<i&&(t.text[s]===" "||t.text[s]==="	");)s++;s===i&&(s=n)}let o=s!==n&&t.selection.active!==s?s:n;return{position:ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,o,"right")),desiredColumn:void 0}},pb=t=>{if(t.cursorPosition.kind==="virtual")return{position:t.cursorPosition,desiredColumn:void 0};let e=t.lineMap.lineIndexOfPosition(t.cursorPosition);if(e===void 0)return{position:Ua(t),desiredColumn:void 0};let n=t.lineMap.lineEndOffset(e);return n===void 0?{position:Ua(t),desiredColumn:void 0}:{position:ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,n,"left")),desiredColumn:void 0}},gb=t=>{let e=t.lineMap.lineIndexOfPosition(t.cursorPosition);if(e===void 0)return bb(t);let n=t.desiredColumn??t.lineMap.xAtPosition(t.cursorPosition);return e>=t.lineMap.lineCount-1?{position:t.cursorPosition,desiredColumn:n}:{position:t.lineMap.positionInLineAtX(e+1,n),desiredColumn:n}},lu=t=>{let e=t.lineMap.lineIndexOfPosition(t.cursorPosition);if(e===void 0)return vb(t);if(t.cursorPosition.kind==="virtual"&&e>0)return Ju(t,e-1);let n=t.desiredColumn??t.lineMap.xAtPosition(t.cursorPosition);return e<=0?{position:t.cursorPosition,desiredColumn:n}:{position:t.lineMap.positionInLineAtX(e-1,n),desiredColumn:n}};function Fs(t,e,n,i){let r=n==="before"?e.sourceOffsetBefore:e.sourceOffsetAfter;return ue.source(zt(t.document,t.markerVisibleBlocks,t.selection.active,r,i))}function vb(t){if(t.cursorPosition.kind!=="virtual"||t.lineMap.isEmpty)return{position:t.cursorPosition,desiredColumn:t.desiredColumn};let e=t.lineMap.lineIndexOfOffset(t.cursorPosition.line.sourceOffsetBefore);return Ju(t,e)}function bb(t){if(t.cursorPosition.kind!=="virtual"||t.lineMap.isEmpty)return{position:t.cursorPosition,desiredColumn:t.desiredColumn};let e=t.lineMap.lineIndexOfOffset(t.cursorPosition.line.sourceOffsetBefore),n=t.desiredColumn??t.lineMap.lineRect(e).left;return e>=t.lineMap.lineCount-1?{position:t.cursorPosition,desiredColumn:n}:{position:t.lineMap.positionInLineAtX(e+1,n),desiredColumn:n}}function Ju(t,e){let n=t.lineMap.lineRect(e).right;return{position:t.lineMap.positionInLineAtX(e,n),desiredColumn:n}}var Di={tabSize:4,insertSpaces:!0},zi="  ",cu=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};if(e.active===0)return;let n=new O(Un(t.document,t.markerVisibleBlocks,e.active,"left"),e.active);return{edit:H.delete(n),selection:$.collapsed(n.start)}},_b=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};if(e.active>=t.text.length)return;let n=new O(e.active,Un(t.document,t.markerVisibleBlocks,e.active,"right"));return{edit:H.delete(n),selection:$.collapsed(n.start)}},wb=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};if(e.active===0)return;let n=od(t.text,e.active,t.wordNavigationConfig),i=new O(n,e.active),r=$s(t,i);if(!r.isEmpty)return{edit:r,selection:$.collapsed(r.mapOffset(n))}},yb=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};if(e.active>=t.text.length)return;let n=ad(t.text,e.active,t.wordNavigationConfig),i=new O(e.active,n),r=$s(t,i);if(!r.isEmpty)return{edit:r,selection:$.collapsed(r.mapOffset(e.active))}},kb=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};if(e.active===0)return;let n=t.text.lastIndexOf(`
`,e.active-1)+1;if(n===e.active&&n>0&&n--,n===e.active)return;let i=$s(t,new O(n,e.active));if(!i.isEmpty)return{edit:i,selection:$.collapsed(i.mapOffset(n))}},xb=t=>{let e=t.selection;if(!e.isCollapsed)return{edit:H.delete(e.range),selection:$.collapsed(e.range.start)};let n=t.text.indexOf(`
`,e.active),i=n===-1?t.text.length:n===e.active?n+1:n;if(i===e.active)return;let r=$s(t,new O(e.active,i));if(!r.isEmpty)return{edit:r,selection:$.collapsed(r.mapOffset(e.active))}};function $s(t,e){let n=[],i=e.start;for(let r of Xu(t.document,t.markerVisibleBlocks,t.selection.active))if(!(r.endExclusive<=i)){if(r.start>=e.endExclusive)break;i<r.start&&n.push(ze.delete(new O(i,Math.min(r.start,e.endExclusive)))),i=Math.max(i,r.endExclusive)}return i<e.endExclusive&&n.push(ze.delete(new O(i,e.endExclusive))),n.length===0?H.empty:new H(n)}function Sb(t){return e=>{let n=H.replace(e.selection.range,t),i=e.selection.range.start+t.length;return{edit:n,selection:$.collapsed(i)}}}function zb(t=Di){return Bs(t),e=>{let n=e.selection,i=n.range,r=Xe(e.text,i.start),s=du(e.text,i.start),o=i.endExclusive<=s&&(i.start!==r||i.endExclusive!==s),a=n.isCollapsed?ih(e.document,e.text,n.active):void 0,l=a?ot(e.document,a.item):void 0,c=a?ot(e.document,a.item.marker):void 0;if(a&&l!==void 0&&c!==void 0&&Xe(e.text,c)===r){let f=rh(e.text,l,l+a.item.length,sh(e.text,Xe(e.text,c),c)),m=f[0];if(a.index===0&&c-m>=zi.length)return;let p=f.filter(g=>g<du(e.text,g)).map(g=>ze.insert(g,zi)),v=new H(p);return{edit:v,selection:$.collapsed(v.mapOffset(n.active))}}if(n.isCollapsed||o){let f=eh(e.text.slice(Xe(e.text,i.start),i.start),t);return{edit:H.replace(i,f),selection:$.collapsed(i.start+f.length)}}let d=Qu(e.text,i),h=d.map(f=>ze.insert(f,Bb(t))),u=new H(h);return{edit:u,selection:Wb(u,n,new Set(d))}}}function Eb(t=Di){return Bs(t),e=>{if(e.selection.isCollapsed){let r=ih(e.document,e.text,e.selection.active),s=r?ot(e.document,r.item):void 0,o=r?ot(e.document,r.item.marker):void 0;if(r&&s!==void 0&&o!==void 0&&Xe(e.text,o)===Xe(e.text,e.selection.active)){let a=rh(e.text,s,s+r.item.length,sh(e.text,Xe(e.text,o),o)).flatMap(c=>e.text.slice(c,c+zi.length)===zi?[ze.delete(new O(c,c+zi.length))]:[]);if(a.length===0)return;let l=new H(a);return{edit:l,selection:$.collapsed(l.mapOffset(e.selection.active))}}}let n=[];for(let r of Qu(e.text,e.selection.range)){let s=Vb(e.text,r),o=e.text.slice(r,s),a=th(o,t);a!==o&&n.push(ze.replace(new O(r,s),a))}if(n.length===0)return;let i=new H(n);return{edit:i,selection:jb(i,e.selection)}}}var Cb=t=>{let e=H.replace(t.selection.range,`

`),n=t.selection.range.start+2;return{edit:e,selection:$.collapsed(n)}},Tb=t=>{let e=H.replace(t.selection.range,`
`),n=t.selection.range.start+1;return{edit:e,selection:$.collapsed(n)}},Ob=t=>{let e=t.selection.range.start,n=0;for(;n<2&&t.text[e-1-n]===" ";)n++;let i=" ".repeat(2-n)+`
`,r=H.replace(t.selection.range,i),s=e+i.length;return{edit:r,selection:$.collapsed(s)}};function Vi(t){let e=t.activeBlock;if(!t.selection.isCollapsed||!e)return;let n=Ds(t.document,e);if(n!==void 0)switch(e.kind){case"paragraph":case"heading":case"thematicBreak":return t.selection.active>=Jr(e,n)?ya(t,e,n):void 0;case"frontMatter":case"codeBlock":return e.closeFence&&t.selection.active>=Jr(e,n)?ya(t,e,n):void 0;case"blockQuote":return Ab(t);case"unhandledBlock":{let i=e.htmlComment;if(i?.kind!=="complete")return;let r=n+i.leadingWhitespace.length+i.opening.length+i.body.length+i.closing.length;return t.selection.active>=r?ya(t,e,n):void 0}default:return}}var Rb=t=>{let e=t.selection,n=t.activeBlock;if(!e.isCollapsed||!n)return Mt(t);switch(n.kind){case"paragraph":case"heading":case"thematicBreak":return Lb(t,n);case"frontMatter":case"codeBlock":return Ib(t);case"blockQuote":return Nb(t);case"list":return Pb(t,n);case"unhandledBlock":return Mb(t,n);default:return Mt(t)}};function Lb(t,e){let n=t.selection,i=Ds(t.document,e);if(i===void 0)return Mt(t);let r=Jr(e,i);return n.active<r?{kind:"edit",edit:H.replace(n.range,`

`),selection:$.collapsed(n.range.start+2)}:Vi(t)??Mt(t)}function Ib(t,e){let n=t.selection,i=Vi(t);if(i)return i;let r=t.text.lastIndexOf(`
`,n.active-1)+1,s=r;for(;s<n.active&&(t.text[s]===" "||t.text[s]==="	");)s++;let o=`
`+t.text.slice(r,s);return Wl(n,o)}function ya(t,e,n){let i=Jr(e,n),r=n+e.length;return{kind:"pending",anchorBlock:e,replaceRange:new O(i,r),separateFromPreviousBlock:!0,atEof:r>=t.text.length}}function Mb(t,e){return e.htmlComment?.kind!=="complete"?Mt(t):Vi(t)??Mt(t)}function Jr(t,e){return e+t.length-Hb(t)}function Nb(t){let e=t.selection,n=Gu(t.text,e.active),i=n.prefix??"> ";if(n.content.slice(i.length).trim()==="")return Vi(t)??Yu(t,n.start,n.endExclusive);let r=`
`+i.replace(/\s*$/," ");return Wl(e,r)}function Ab(t){let e=t.activeBlock;if(!t.selection.isCollapsed||e?.kind!=="blockQuote")return;let n=Gu(t.text,t.selection.active);if(!n.prefix||n.content.slice(n.prefix.length).trim()!==""||t.selection.active<n.start+n.prefix.length)return;let i=Ds(t.document,e);if(i===void 0)return;let r=i+e.length;if(!/^[\r\n]*$/.test(t.text.slice(n.endExclusive,r)))return;let s=n.start>i?t.text.lastIndexOf(`
`,n.start-1):-1,o=s>=i;return{kind:"pending",anchorBlock:e,replaceRange:new O(o?s:i,r),separateFromPreviousBlock:o,atEof:r>=t.text.length}}function Gu(t,e){let n=t.lastIndexOf(`
`,e-1)+1,i=$b(t,e),r=t.slice(n,i);return{start:n,endExclusive:i,content:r,prefix:/^(\s*(?:>\s*)+)/.exec(r)?.[1]}}function Pb(t,e){let n=t.selection,i=Ds(t.document,e);if(i===void 0)return Mt(t);let r=Ps(e,n.active-i);if(r===void 0)return Mt(t);let s=e.items[r],o=ot(t.document,s);if(o===void 0)return Mt(t);if(!oh(s))return Yu(t,o,o+s.length);let a=`
`+Fb(e,s);return Wl(n,a)}function Yu(t,e,n){let i=e>0?t.text.lastIndexOf(`
`,e-1):-1;return i>=0?{kind:"edit",edit:H.replace(new O(i,n),`

`),selection:$.collapsed(i+2)}:{kind:"edit",edit:H.replace(new O(e,n),""),selection:$.collapsed(e)}}function Fb(t,e){let n=e.marker.content.trim(),i=n.charAt(0)||"-";if(e.checked!==void 0)return`${i} [ ] `;if(t.ordered){let r=/^(\d+)([.)])/.exec(n);if(r)return`${Number(r[1])+1}${r[2]} `}return`${i} `}function Wl(t,e){return{kind:"edit",edit:H.replace(t.range,e),selection:$.collapsed(t.range.start+e.length)}}function $b(t,e){let n=t.indexOf(`
`,e);return n===-1?t.length:n}function Xe(t,e){return t.lastIndexOf(`
`,Math.max(0,e-1))+1}function du(t,e){let n=t.indexOf(`
`,e);return n===-1?t.length:n}function Qu(t,e){let n=[Xe(t,e.start)],i=e.endExclusive>e.start&&t[e.endExclusive-1]===`
`?e.endExclusive-1:e.endExclusive,r=t.indexOf(`
`,n[0])+1;for(;r>0&&r<=i;)n.push(r),r=t.indexOf(`
`,r)+1;return n}function eh(t,e=Di){if(Bs(e),!e.insertSpaces)return"	";let n=nh(t,e.tabSize);return" ".repeat(e.tabSize-n%e.tabSize)}function Bb(t){return t.insertSpaces?" ".repeat(t.tabSize):"	"}function th(t,e=Di){Bs(e);let n=nh(t,e.tabSize);if(n===0)return t;let i=n-(n%e.tabSize||e.tabSize);return Db(i,e)}function Db(t,e){return e.insertSpaces?" ".repeat(t):"	".repeat(Math.floor(t/e.tabSize))+" ".repeat(t%e.tabSize)}function nh(t,e){let n=0;for(let i of t)n=i==="	"?n+e-n%e:n+1;return n}function Vb(t,e){let n=e;for(;t[n]===" "||t[n]==="	";)n++;return n}function ih(t,e,n){let i=(a,l,c,d)=>{let h=a instanceof yt&&c!==void 0&&d!==void 0?{item:a,index:d}:void 0,u=l,f;for(let m of a.children){let p=u+m.length,v=a instanceof wt&&m instanceof yt?a:c,g=a instanceof wt&&m instanceof yt?a.items.indexOf(m):d;if(u<=n&&n<p)return i(m,u,v,g)??h;p===n&&(f=i(m,u,v,g)??h),u=p}return f??h},r=i(t,0,void 0,void 0);if(r){let a=ot(t,r.item.marker);if(a!==void 0&&Xe(e,a)===Xe(e,n))return r}let s,o=a=>{if(a instanceof wt)for(let l=0;l<a.items.length;l++){let c=a.items[l],d=ot(t,c.marker);d!==void 0&&Xe(e,d)===Xe(e,n)&&(s={item:c,index:l})}for(let l of a.children)o(l)};return o(t),s??r}function rh(t,e,n,i){let r=[],s=Xe(t,e);for(;s<n;){r.push(qb(t,s,i));let o=t.indexOf(`
`,s);if(o===-1)break;s=o+1}return r}function sh(t,e,n){let i=e,r=0;for(;i<n;){let s=i;for(let o=0;o<3&&s<n&&(t[s]===" "||t[s]==="	");o++)s++;if(s>=n||t[s]!==">")break;r++,i=s+1,(t[i]===" "||t[i]==="	")&&i++}return r}function qb(t,e,n){let i=e;for(let r=0;r<n;r++){let s=i;for(let o=0;o<3&&(t[s]===" "||t[s]==="	");o++)s++;if(t[s]!==">")return e;i=s+1,(t[i]===" "||t[i]==="	")&&i++}return i}function jb(t,e){return new $(t.mapOffset(e.anchor),t.mapOffset(e.active))}function Wb(t,e,n){let i=r=>{if(!n.has(r))return t.mapOffset(r);let s=0;for(let o of t.replacements){if(o.replaceRange.start>=r)break;s+=o.newText.length-o.replaceRange.length}return r+s};return new $(i(e.anchor),i(e.active))}function Bs(t){if(!Number.isInteger(t.tabSize)||t.tabSize<=0)throw new RangeError(`tabSize must be a positive integer, got ${t.tabSize}`)}function oh(t){return t instanceof Ci?t.content.trim().length>0:t instanceof Kn?(t.code?.content.trim().length??0)>0:t.children.some(oh)}function Mt(t){let e=Tb(t);return{kind:"edit",edit:e.edit,selection:e.selection}}function Ds(t,e){let n=0;for(let i of t.children){if(i===e)return n;n+=i.length}}function Hb(t){let e=t.children,n=0;for(let i=e.length-1;i>=0&&e[i]instanceof Fe;i--)n+=e[i].length;return n}var Kb=t=>new $(0,t.text.length),Ub=(t,e)=>{let n=No(t.text,e,t.wordNavigationConfig);return new $(n.start,n.end)};function Zb(t,e){return new $(e.start,e.endExclusive)}var uu=new WeakMap,ka=new WeakMap,xt=class t extends pe{constructor(e,n,i=Xb){super(),this.ast=e,this.dom=n,this._children=i,uu.set(n,this);for(let r of i)ka.set(r,this)}_children;get children(){return this._children}_replaceChildren(e){for(let n of this._children)n.dispose();this._children=e;for(let n of e)ka.set(n,this)}dispose(){for(let e of this._children)e.dispose()}get sourceLength(){return this.ast.length}get mountNode(){return this.dom}get parent(){return ka.get(this)}static forDom(e){for(let n=e;n;n=n.parentNode){let i=uu.get(n);if(i)return i}}localOffsetInParent(){let e=this.parent;return e?e._localOffsetOfChild(this):0}_localOffsetOfChild(e){let n=0;for(let i of this.children){if(i===e)return n;n+=i.sourceLength}return n}getLocalSourceRange(e){return this.dom===e.node&&this.dom.nodeType===3?O.emptyAt(Math.max(0,Math.min(e.offset,this.sourceLength))):O.emptyAt(e.offset>=1?this.sourceLength:0)}resolveSource(e){let n=t.forDom(e.node);if(!n)return;let i=n.getLocalSourceRange(e);for(;n!==this;){let r=n.parent;if(!r)return;i=i.delta(n.localOffsetInParent()),n=r}return i.start}sourceToDom(e,n=0){if(e<n||e>n+this.sourceLength)return;if(this.children.length===0)return this.dom.nodeType===3?{node:this.dom,offset:e-n}:void 0;let i=n;for(let r of this.children){let s=i+r.sourceLength;if(e>=i&&e<=s){let o=r.sourceToDom(e,i);if(o)return o}i=s}}forEachTextLeaf(e,n){if(this.children.length===0){this.dom.nodeType===3&&n(this,e);return}let i=e;for(let r of this.children)r.forEachTextLeaf(i,n),i+=r.sourceLength}},Xb=[];function Jb(t){let e=document;if(e.caretPositionFromPoint){let i=e.caretPositionFromPoint(t.x,t.y);return i?{node:i.offsetNode,offset:i.offset}:void 0}let n=e.caretRangeFromPoint?.(t.x,t.y);if(n)return{node:n.startContainer,offset:n.startOffset}}function Za(t,e){let n=t.firstChild,i=0;for(;i<e.length&&n===e[i];i++)n=n.nextSibling;if(!(i===e.length&&n===null)){for(;i<e.length;i++){let r=e[i];n===r?n=r.nextSibling:t.insertBefore(r,n)}for(;n;){let r=n;n=n.nextSibling,t.removeChild(r)}}}function Gb(t){let e=Yb(t),n=Qb(t),i=Math.max(e,t.length-n);return{text:t.slice(e,i),sourceOffset:e}}function Yb(t){return t.startsWith(`\r
`)?2:t.startsWith("\r")||t.startsWith(`
`)?1:0}function Qb(t){return t.endsWith(`\r
`)?2:t.endsWith("\r")||t.endsWith(`
`)?1:0}var Gr=class t{static create(e){let n=document.createElement("span");n.dataset.mdUrl=e.href,n.setAttribute("role","link"),n.tabIndex=0;let i=document.createElement("span");i.textContent=e.authoredLabel;let r=new t(n,i);return r.update(e.presentation),r}static mount(e,n){return new t(e,n)}static clear(e){e.classList.remove("md-rich-link","md-rich-link-unavailable"),delete e.dataset.mdRichLinkKind,delete e.dataset.mdRichLinkStatus,delete e.dataset.mdRichLinkSecondaryStatus,e.removeAttribute("aria-label"),e.removeAttribute("title")}element;authoredLabel;_icon;_title;_detail;_reference;_status;_secondaryStatus;constructor(e,n){this.element=e,this.authoredLabel=n,this._icon=document.createElement("span"),this._icon.className="md-rich-link-icon codicon",this._icon.setAttribute("aria-hidden","true"),this._title=document.createElement("span"),this._title.className="md-rich-link-title",this._detail=document.createElement("span"),this._detail.className="md-rich-link-detail",this._reference=document.createElement("span"),this._reference.className="md-rich-link-reference",this._status=hu("md-rich-link-primary-status"),this._secondaryStatus=hu("md-rich-link-secondary-status"),this.authoredLabel.className="md-rich-link-label",this.element.classList.add("md-rich-link"),this._setDefaultOrder()}update(e){if(!e){this._renderUnavailable();return}this.element.classList.remove("md-rich-link-unavailable"),this.element.dataset.mdRichLinkKind=e.kind,this._icon.className=`md-rich-link-icon codicon codicon-${e_[e.kind]}`,this.authoredLabel.hidden=!!e.title,this._title.textContent=e.title??"",this._title.hidden=!e.title,this._detail.textContent=e.detail??"",this._detail.hidden=!e.detail,this._reference.textContent=e.reference??"",this._reference.hidden=!e.reference,fu(this.element,e.kind,this._status,e.status,"mdRichLinkStatus"),fu(this.element,e.kind,this._secondaryStatus,e.secondaryStatus,"mdRichLinkSecondaryStatus"),Za(this.element,i_(e)?[this._status.root,this.authoredLabel,this._title,this._detail,this._reference,this._secondaryStatus.root]:[this._icon,this.authoredLabel,this._title,this._detail,this._reference,this._status.root,this._secondaryStatus.root]),e.ariaLabel?this.element.setAttribute("aria-label",e.ariaLabel):this.element.removeAttribute("aria-label"),e.tooltip?this.element.title=e.tooltip:this.element.removeAttribute("title")}_renderUnavailable(){this.element.classList.add("md-rich-link-unavailable"),delete this.element.dataset.mdRichLinkKind,delete this.element.dataset.mdRichLinkStatus,delete this.element.dataset.mdRichLinkSecondaryStatus,this._setDefaultOrder(),this._icon.className="md-rich-link-icon codicon codicon-link",this.authoredLabel.hidden=!1,this._title.hidden=!0,this._detail.hidden=!0,this._reference.hidden=!0,Xa(this._status),Xa(this._secondaryStatus),this.element.removeAttribute("aria-label"),this.element.removeAttribute("title")}_setDefaultOrder(){Za(this.element,[this._icon,this.authoredLabel,this._title,this._detail,this._reference,this._status.root,this._secondaryStatus.root])}},e_={resource:"link",issue:"issues",pullRequest:"git-pull-request",commit:"git-commit",file:"file",folder:"folder",session:"comment-discussion",repository:"repo",branch:"git-branch"};function hu(t){let e=document.createElement("span");e.className=`md-rich-link-status ${t}`;let n=document.createElement("span");n.className="md-rich-link-status-icon codicon",n.setAttribute("aria-hidden","true");let i=document.createElement("span");return i.className="md-rich-link-status-label",e.append(n,i),{root:e,icon:n,label:i}}function fu(t,e,n,i,r){if(!i){delete t.dataset[r],Xa(n);return}t.dataset[r]=i.kind;let s=n_(e,i.kind);n.icon.className=`md-rich-link-status-icon codicon codicon-${r_(e,i.kind)}`,n.icon.hidden=s!==void 0,s?(n.pixelSpinner??=t_(n.label),n.pixelSpinner.classList.toggle("monaco-pixel-spinner-ring",s==="ring")):(n.pixelSpinner?.remove(),n.pixelSpinner=void 0),n.label.textContent=i.label,n.root.hidden=!1}function Xa(t){t.icon.hidden=!1,t.pixelSpinner?.remove(),t.pixelSpinner=void 0,t.label.textContent="",t.root.hidden=!0}function t_(t){let e=document.createElement("span");e.className="md-rich-link-status-icon monaco-pixel-spinner",e.setAttribute("aria-hidden","true");for(let n=0;n<6;n++){let i=document.createElement("span");i.className="monaco-pixel-spinner-dot",e.appendChild(i)}return t.before(e),e}function n_(t,e){if(t==="session")switch(e){case"pending":return"grid";case"warning":return"ring";default:return}}function i_(t){let e=t.status?.kind;switch(t.kind){case"issue":return e==="open"||e==="closed"||e==="notPlanned";case"pullRequest":return e==="open"||e==="closed"||e==="merged"||e==="draft";case"session":return e!==void 0;default:return!1}}function r_(t,e){if(t==="session")switch(e){case"pending":case"warning":case"success":case"neutral":return"comment-discussion";case"error":return"error"}switch(e){case"open":return t==="pullRequest"?"git-pull-request":"issue-opened";case"closed":return t==="pullRequest"?"git-pull-request-closed":"issue-closed";case"merged":return"git-merge";case"draft":return"git-pull-request-draft";case"notPlanned":return"circle-slash";case"pending":return"circle-filled";case"success":return"pass-filled";case"warning":return"warning";case"error":return"error";case"neutral":return"circle-outline"}}var te=class extends xt{constructor(e,n,i){super(e.ast,n,i),this.data=e}get block(){return this.data.ast}get element(){return this.dom}get scrollElement(){return this.element}canReuse(e,n){return this.data===e}recordMeasuredHeight(e){}};function at(t,e,n){if(n instanceof te){if(n.canReuse(t,e))return n}else if(n?.ast===t.ast)return n;switch(t.kind){case"text":return a_(t,ge(n,Bi));case"marker":return t.ast.markerKind==="hardBreak"?new ts(t,ge(n,ts)):new Qr(t,ge(n,Qr));case"glue":return new es(t,ge(n,es));case"heading":return new is(t,e,ge(n,is));case"paragraph":return new Lt(t,"p","md-block md-paragraph",e,Dn(n));case"frontMatter":return new cs(t,e,ge(n,cs));case"codeBlock":return new Ja(t,e,n);case"mathBlock":return new us(t,e,ge(n,us));case"thematicBreak":return new rs(t,e,ge(n,rs));case"unhandledBlock":{let i=t.ast.htmlComment;return i?new os(t,i,e,ge(n,os)):new ss(t,e,ge(n,ss))}case"blockQuote":return new ns(t,e,ge(n,ns));case"list":return new hs(t,e,ge(n,hs));case"listItem":return new fs(t,e,ge(n,fs));case"table":return new ms(t,e,ge(n,ms));case"tableRow":return new ps(t,e,ge(n,ps));case"tableCell":return new Lt(t,"td","",e,Dn(n));case"strong":return new Lt(t,"strong","",e,Dn(n));case"emphasis":return new Lt(t,"em","",e,Dn(n));case"strikethrough":return new Lt(t,"del","",e,Dn(n));case"inlineCode":return new gs(t,e,ge(n,gs));case"inlineMath":return new vs(t,e,ge(n,vs));case"link":return new bs(t,e,ge(n,bs));case"image":return new _s(t,e,ge(n,_s));case"document":return new Lt(t,"div","",e,Dn(n));case"diffHunk":return new Fi(t,e,ge(n,Fi));case"diffDecoration":return new $i(t,e,ge(n,$i))}}function ge(t,e){return t instanceof e?t:void 0}function Dn(t){return t instanceof Lt?t:void 0}function Ge(t,e,n,i){let{paired:r,unused:s}=Hl(e,n??Se),o=e.map(a=>i(a,r.get(a)));for(let a of s)a.dispose();return s_(t,o),o}function s_(t,e){ft(t,e.map(n=>n.mountNode))}var ft=Za;function At(t){return(e,n)=>at(e,t,n)}function ah(t){return(e,n)=>e.kind==="marker"&&e.ast.markerKind==="content"?new Bi(e,document.createTextNode(e.ast.content)):at(e,t,n)}var Se=[],Fi=class extends te{_originalNode;_modifiedNode;constructor(e,n,i){let r=i?.dom??document.createElement("div");r.className="md-block md-diff-hunk";let s=[],o=[],a=e.original?mu(e.original,"md-diff-original",n,i?._originalNode):void 0,l=e.modified?mu(e.modified,"md-diff-modified",n,i?._modifiedNode):void 0;a&&(s.push(a),o.push(a.mountNode)),l&&(s.push(l),o.push(l.mountNode)),ft(r,o),super(e,r,s),this._originalNode=a,this._modifiedNode=l}get sides(){let e=[];return this._originalNode&&this.data.original&&e.push({node:this._originalNode,ranges:this.data.original.ranges}),this._modifiedNode&&this.data.modified&&e.push({node:this._modifiedNode,ranges:this.data.modified.ranges}),e}};function mu(t,e,n,i){let r=at(t.view,n,i),s=r.element;return s.classList.add(e),s.classList.toggle("md-block-active",t.active),s.classList.toggle("md-markers-hidden",!t.active),r}var $i=class extends te{sideNode;constructor(e,n,i){let r=i?.dom??document.createElement("div");r.className="md-block md-diff-decoration",r.style.pointerEvents="none";let s=at(e.side,n,i?.sideNode),o=s.element,a=!e.whole;o.classList.add(e.whole?"md-diff-removed":"md-diff-original"),o.classList.toggle("md-block-active",a),o.classList.toggle("md-markers-hidden",!a),ft(r,[s.mountNode]),super(e,r,[s]),this.sideNode=s}get sourceLength(){return 0}get whole(){return this.data.whole}get originalStart(){return this.data.originalStart}get deletedRanges(){return this.data.deletedRanges}};function lh(t){return"content"in t?t.content:o_}var o_=[];function a_(t,e){let n=t.ast.content;if(t.hiddenPrefixLength>0)return l_(t,n,t.hiddenPrefixLength);let i={leftBoundary:t.leftWordBoundary,rightBoundary:t.rightWordBoundary,decorateNewline:!0};if(t.showWhitespace&&dh(n,i)){let o=document.createElement("span");o.className="md-text";let a=Vs(o,n,i,t.ast);return new te(t,o,a)}let r=e?.dom,s=r instanceof globalThis.Text&&r.data===n?r:document.createTextNode(n);return new Bi(t,s)}function l_(t,e,n){let i=document.createElement("span");i.className="md-text";let r=document.createElement("span");r.className="md-runner-marker",r.setAttribute("aria-hidden","true");let s=document.createTextNode(e.slice(0,n));r.appendChild(s),i.appendChild(r);let o=document.createTextNode(e.slice(n));return i.appendChild(o),new te(t,i,[new Oe(t.ast,s,Se,n),new Oe(t.ast,o,Se,e.length-n)])}function pu(t){return t===" "||t==="	"||t===`
`||t==="\r"}var c_={leftBoundary:!1,rightBoundary:!1,decorateNewline:!1},d_={leftBoundary:!1,rightBoundary:!1,decorateNewline:!1};function u_(t,e,n){let i=e>0?!pu(t[e-1]):n.leftBoundary,r=e<t.length-1?!pu(t[e+1]):n.rightBoundary;return i&&r}function ch(t,e,n){let i=t[e];if(i==="	")return"md-ws-tab";if(i===`
`||i==="\r")return n.decorateNewline?"md-ws-newline":void 0;if(i===" "&&!u_(t,e,n))return"md-ws-space"}function dh(t,e){for(let n=0;n<t.length;n++){let i=t[n];if(e.newlineGlyph&&(i===`
`||i==="\r")||ch(t,n,e)!==void 0)return!0}return!1}function h_(t,e){let n=[],i=-1,r=a=>{i>=0&&(n.push({text:t.slice(i,a),cls:void 0}),i=-1)},s=e.breakGlyphClass?t.indexOf(`
`):-1,o=e.newlineGlyph?t.lastIndexOf(`
`):-1;for(let a=0;a<t.length;a++){let l=t[a];if(e.newlineGlyph&&(l===`
`||l==="\r")){let d=a===s;if(a!==o||d){r(a),n.push({text:l,cls:d?e.breakGlyphClass:"md-ws-newline-glyph",display:"\u21B5"});continue}}let c=e.newlineGlyph&&(l===`
`||l==="\r")?void 0:ch(t,a,e);if(c===void 0){i<0&&(i=a);continue}r(a),n.push({text:l,cls:c})}return r(t.length),n}function Vs(t,e,n,i){let r=[];for(let s of h_(e,n)){let o=document.createTextNode(s.display??s.text);if(s.cls){let a=document.createElement("span");a.className=s.cls,a.appendChild(o),t.appendChild(a)}else t.appendChild(o);r.push(new Oe(i,o,Se,s.text.length))}return r}var Bi=class extends te{constructor(e,n){super(e,n,Se)}},Oe=class extends xt{_sourceLength;constructor(e,n,i=Se,r=e.length){super(e,n,i),this._sourceLength=r}get sourceLength(){return this._sourceLength}},Yr=class extends Oe{_span;constructor(e,n){let i=document.createElement("span");n&&(i.className=n),i.setAttribute("aria-hidden","true"),i.style.userSelect="none";let r=document.createTextNode("\u200B");i.appendChild(r),super(e,r,Se,0),this._span=i}get mountNode(){return this._span}},Qr=class extends te{_span;constructor(e,n){let i=e.ast,r=`md-marker md-marker-${i.markerKind}`,s=n&&n.dom instanceof globalThis.Text&&n.dom.data===i.content,o=s?n._span:document.createElement("span");o.className=e.visible?r:`${r} md-marker-hidden`;let a=s?n.dom:document.createTextNode(i.content);s||o.appendChild(a),super(e,a,Se),this._span=o}get mountNode(){return this._span}},es=class t extends te{_span;constructor(e,n){let i=t._build(e,n);super(e,i.dom,i.children),this._span=i.span}get mountNode(){return this._span}static _build(e,n){let i=e.ast,r=i.glueKind?`md-glue md-glue-${i.glueKind}`:"md-glue",s=i.glueKind==="blockBreak",o={leftBoundary:!1,rightBoundary:!1,decorateNewline:e.decorateNewline,newlineGlyph:i.glueKind==="blockGap"||s,breakGlyphClass:s?"md-ws-blockbreak-glyph":void 0};if(e.visible&&dh(i.content,o)){let d=document.createElement("span");d.className=r;let h=Vs(d,i.content,o,i);return{span:d,dom:d,children:h}}let a=n&&n.dom instanceof globalThis.Text&&n.dom.data===i.content&&n.children.length===0,l=a?n._span:document.createElement("span");l.className=e.visible?r:`${r} md-glue-hidden`;let c=a?n.dom:document.createTextNode(i.content);return a||l.appendChild(c),{span:l,dom:c,children:Se}}},ts=class extends te{_span;constructor(e,n){let i=e.ast.content,r=document.createElement("span");r.className="md-hardbreak";let s=document.createElement("span");s.className=e.visible?"md-hardbreak-src":"md-hardbreak-src md-hardbreak-src-hidden";let o=e.visible?Vs(s,i,c_,e.ast):f_(s,i,e.ast);r.appendChild(s),r.appendChild(document.createElement("br")),super(e,r,o),this._span=r}get mountNode(){return this._span}};function f_(t,e,n){let i=document.createTextNode(e);return t.appendChild(i),[new Oe(n,i)]}var Lt=class extends te{constructor(e,n,i,r,s){let o=s?.element??document.createElement(n);!s&&i&&(o.className=i);let a=Ge(o,lh(e),s?.children,At(r));super(e,o,a)}},ns=class extends te{_sourceChildren;_anchors;constructor(e,n,i){let r=i?.element??document.createElement("blockquote");i||(r.className="md-block md-blockquote");let s=Ge(r,e.content,i?._sourceChildren,At(n)),o=m_(e.ast),a=e.showFinalMarkerOnlyLine?o:o.slice(0,-1);r.classList.toggle("md-blockquote-marker-only-line",a.length>0);let l=new Map(i?._anchors.map(u=>[u.ast.id,u])),c=a.map(({marker:u})=>{let f=l.get(u.id)??new Yr(u,"md-blockquote-line-anchor");return l.delete(u.id),f});for(let u of l.values())u.dispose();let d=new Map(a.map(({index:u},f)=>[u,c[f]])),h=[];for(let u=0;u<s.length;u++){h.push(s[u]);let f=d.get(u);f&&h.push(f)}ft(r,h.map(u=>u.mountNode)),super(e,r,h),this._sourceChildren=s,this._anchors=c}};function m_(t){let e=[];for(let n=t.children.length-1;n>=0;n--){let i=t.children[n];if(!(i instanceof Fe)){if(i instanceof q&&i.markerKind==="blockQuoteMarker"){e.push({index:n,marker:i});continue}break}}return e.reverse()}var is=class extends te{constructor(e,n,i){let r=i&&i.element.tagName===`H${e.ast.level}`,s=r?i.element:document.createElement(`h${e.ast.level}`);r||(s.className="md-block md-heading");let o=Ge(s,e.content,i?.children,At(n));super(e,s,o)}},rs=class extends te{_contentEl;constructor(e,n,i){if(e.showMarkup){let o=i?.data.showMarkup?i:void 0,a=o?.dom??document.createElement("div");o||(a.className="md-block md-thematic-break-source");let l=Ge(a,e.content,o?.children,At(n));super(e,a,l),this._contentEl=a;return}let r=document.createElement("div");r.className="md-block md-thematic-break-wrapper";let s=document.createElement("hr");s.className="md-block md-thematic-break",r.appendChild(s),super(e,r,Se),this._contentEl=s}get element(){return this._contentEl}},ss=class extends te{_scroller;constructor(e,n,i){let r=i&&i.dom instanceof HTMLDivElement?i:void 0,s=r?.dom??document.createElement("div");r||(s.className="md-block md-unhandled-block");let o=r?._scroller??document.createElement("pre");r||(o.className="md-code-block md-unhandled-scroll",s.appendChild(o));let a=(r?o.querySelector("code"):null)??document.createElement("code");r||o.appendChild(a);let l=Ge(a,e.content,r?.children,(c,d)=>{let h=c.ast;if(c.kind==="marker"&&h.markerKind==="content"){let u=(d instanceof Oe&&d.dom.nodeType===globalThis.Node.TEXT_NODE&&d.dom.data===h.content?d.dom:void 0)??document.createTextNode(h.content);return new Oe(h,u)}return at(c,n,d)});super(e,s,l),this._scroller=o}get element(){return this._scroller}},os=class extends te{constructor(e,n,i,r){let s=r?.dom instanceof HTMLDivElement?r.dom:document.createElement("div");s.className=`md-block md-html-comment md-html-comment-${n.kind}${e.showMarkup?" md-html-comment-source":""}`;let o=Ge(s,e.content,r?.children,(a,l)=>{let c=a.ast;return a.kind==="marker"&&c.markerKind==="content"?new as(c,n,ge(l,as)):at(a,i,l)});super(e,s,o)}},as=class extends xt{constructor(e,n,i){let r=i?.dom instanceof HTMLSpanElement?i.dom:document.createElement("span");r.className="md-html-comment-content";let s=[{className:"md-html-comment-syntax",content:n.leadingWhitespace},{className:"md-html-comment-syntax",content:n.opening},{className:"md-html-comment-body",content:n.body}];n.kind==="complete"&&s.push({className:"md-html-comment-syntax",content:n.closing},{className:"md-html-comment-syntax",content:n.trailingWhitespace});let o=s.filter(a=>a.content.length>0).map((a,l)=>{let c=i?.children[l]instanceof ls?i.children[l]:void 0,d=c?.mountNode instanceof HTMLSpanElement?c.mountNode:document.createElement("span");d.className=a.className;let h=c?.dom instanceof Text?c.dom:void 0,u=h?.data===a.content?h:document.createTextNode(a.content);return ft(d,[u]),new ls(e,u,d,a.content.length)});ft(r,o.map(a=>a.mountNode)),super(e,r,o)}},ls=class extends Oe{constructor(e,n,i,r){super(e,n,Se,r),this._span=i}get mountNode(){return this._span}},cs=class extends te{_session;_snapshotSub;constructor(e,n,i){let r=e.ast,s=r.value,o=s?.content??"",a=n?.syntaxHighlighter,l;s&&a&&(i?._session&&r===i.ast?(l=i._session,i._session=void 0):l=a.create("yaml",o)),i?._session?.dispose(),i&&(i._session=void 0),i?._snapshotSub?.dispose(),i&&(i._snapshotSub=void 0);let c=l?l.snapshot.get().getTokens(O.ofLength(o.length)).tokens:void 0,d=uh(e.content,s,o,n,"md-block md-code-block md-front-matter","yaml",c);if(super(e,d.dom,d.children),this._session=l,l&&d.contentNode){let h=d.contentNode;this._snapshotSub=li(l.snapshot,()=>{let u=l.snapshot.get();h.refresh(o,u.getTokens(O.ofLength(o.length)).tokens)})}}dispose(){this._snapshotSub?.dispose(),this._snapshotSub=void 0,this._session?.dispose(),this._session=void 0,super.dispose()}},Ja=class t extends te{_session;_snapshotSub;_embeddedEditor;_embeddedEditorFactoryVersion;_embeddedEditorReadOnly;canReuse(e,n){return super.canReuse(e,n)&&Object.is(n?.embeddedCodeEditorFactoryVersion,this._embeddedEditorFactoryVersion)&&(!this._embeddedEditor||(n?.embeddedCodeEditorReadOnly??!1)===this._embeddedEditorReadOnly)}constructor(e,n,i){let r=e.ast,s=r.code?.content??"",o=i instanceof t?i:void 0,a=n?.embeddedCodeEditorReadOnly??!1,l=Gb(s),c;!e.showMarkup&&r.language&&r.code&&l.sourceOffset>0&&n?.embeddedCodeEditorFactory&&(o?._embeddedEditor&&Object.is(n.embeddedCodeEditorFactoryVersion,o._embeddedEditorFactoryVersion)&&(r===o.ast||r.getDiff(o.ast))?(c=o._embeddedEditor,o._embeddedEditor=void 0):c=n.embeddedCodeEditorFactory.create(r.language,r.infoString,l.text)??void 0),o?._embeddedEditor&&(o._embeddedEditor.dispose(),o._embeddedEditor=void 0);let d=!c&&!e.showMarkup&&r.language&&n?.renderCustomCodeBlock?n.renderCustomCodeBlock(r.language,s)??void 0:void 0,h=n?.syntaxHighlighter,u;if(!c&&!d&&h&&r.language){if(o?._session&&r===o.ast)u=o._session,o._session=void 0;else if(o?._session){let g=r.getDiff(o.ast);g&&(u=o._session,o._session=void 0,Ce(w=>u.update(g.stringEdit,w)))}u||(u=h.create(r.language,s))}o?._session&&(o._session.dispose(),o._session=void 0),o?._snapshotSub?.dispose(),o&&(o._snapshotSub=void 0);let f=u?u.snapshot.get().getTokens(O.ofLength(s.length)).tokens:void 0,m,p,v;if(c){c.element.classList.add("md-block","md-code-block");let g=c.estimateHeight?.(l.text);g!==void 0&&(c.element.style.boxSizing="border-box",c.element.style.minHeight=`${g}px`),c.onEdit=w=>{let y=l.sourceOffset===0?w:new H(w.replacements.map(x=>ze.replace(x.replaceRange.delta(l.sourceOffset),x.newText)));n?.onEmbeddedCodeEditorEdit?.(r,y)},c.setReadOnly?.(n?.embeddedCodeEditorReadOnly??!1),c.setContent(l.text),m=c.element,p=Se}else if(d)d.classList.add("md-block","md-code-block"),m=d,p=Se;else if(r.openFence){let g=uh(e.content,r.code,s,n,"md-block md-code-block",r.language||void 0,f),w=g.dom,y=g.children;if(v=g.contentNode,!r.closeFence&&r.code&&s.endsWith(`
`)){let x=new Yr(r.code);w.appendChild(x.mountNode),y.push(x)}m=w,p=y}else{let g=document.createElement("pre");g.className="md-block md-code-block";let w=document.createElement("code");g.appendChild(w);let y=[];for(let x of e.content){let C=x.ast;if(x.kind==="marker"&&C.markerKind==="content"){let k=document.createTextNode(C.content);w.appendChild(k),y.push(new Oe(C,k))}else if(x.kind==="marker"&&C.markerKind==="codeIndent"){let k=C;if(x.visible){let E=document.createElement("span");E.className="md-marker md-marker-codeIndent";let L=Vs(E,k.content,d_,k);w.appendChild(E),y.push(new Oe(k,E,L))}else{let E=at(x,n,void 0);w.appendChild(E.mountNode),y.push(E)}}else{let k=at(x,n,void 0);g.appendChild(k.mountNode),y.push(k)}}m=g,p=y}super(e,m,p),this._session=u,this._embeddedEditor=c,this._embeddedEditorFactoryVersion=n?.embeddedCodeEditorFactoryVersion,this._embeddedEditorReadOnly=a,u&&v&&(this._snapshotSub=li(u.snapshot,()=>{let g=u.snapshot.get();v.refresh(s,g.getTokens(O.ofLength(s.length)).tokens)}))}dispose(){this._snapshotSub?.dispose(),this._snapshotSub=void 0,this._session?.dispose(),this._session=void 0,this._embeddedEditor?.dispose(),this._embeddedEditor=void 0,super.dispose()}};function uh(t,e,n,i,r,s,o){let a=document.createElement("pre");a.className=r;let l=[],c;for(let d of t)if(e&&d.ast===e){let h=document.createElement("code");s&&(h.className=`language-${CSS.escape(s)}`);let u=p_(e,n,h,o);u instanceof ds&&(c=u),l.push(u),a.appendChild(h)}else{let h=at(d,i,void 0);a.appendChild(h.mountNode),l.push(h)}return{dom:a,children:l,contentNode:c}}function p_(t,e,n,i){if(!i){let r=document.createTextNode(e);return n.appendChild(r),new Oe(t,r)}return new ds(t,n,e,i)}var ds=class extends xt{constructor(e,n,i,r){super(e,n,gu(e,n,i,r))}refresh(e,n){let i=this.dom;i.replaceChildren(),this._replaceChildren(gu(this.ast,i,e,n))}};function gu(t,e,n,i){let r=[],s=0;for(let o of i){let a=n.slice(s,s+o.length);s+=o.length;let l=document.createTextNode(a);if(o.className){let c=document.createElement("span");for(let d of o.className.split("."))d&&c.classList.add(`tok-${d}`);c.appendChild(l),e.appendChild(c)}else e.appendChild(l);r.push(new Oe(t,l,Se,a.length))}return r}function hh(t){let e=0;for(let n of t){if(n.kind==="marker"&&n.markerKind==="content")return e;e+=n.length}return e}function fh(t,e,n){let i=e.filter(a=>a.length>0&&a.start>=0&&a.start+a.length<=n).slice().sort((a,l)=>a.start-l.start),r=[],s=0,o=a=>{a>0&&r.push(new Oe(t,document.createTextNode(""),Se,a))};for(let a of i)a.start<s||(o(a.start-s),r.push(new Oe(t,a.dom,Se,a.length)),s=a.start+a.length);return o(n-s),r}var us=class extends te{_renderedHeight;constructor(e,n,i){let r=e.ast,s=i?._renderedHeight;if(e.showMarkup){let c=document.createElement("pre");c.className="md-block md-math-block",s!==void 0&&(c.style.boxSizing="border-box",c.style.minHeight=`${s}px`);let d=[];for(let h of e.content)if(h.ast===r.code){let u=document.createElement("code"),f=document.createTextNode(r.code.content);u.appendChild(f),c.appendChild(u),d.push(new Oe(r.code,f))}else{let u=at(h,n,void 0);c.appendChild(u.mountNode),d.push(u)}super(e,c,d),this._renderedHeight=s;return}let o=r.code?.content??"",a=n?.renderMath?.({latex:o,displayMode:!0,className:"md-block md-math-block",nodeLength:r.length,contentStart:hh(r.content)});if(a){super(e,a.dom,fh(r,a.segments,r.length)),this._renderedHeight=s;return}let l=document.createElement("div");l.className="md-block md-math-block";try{vo.render(o,l,{displayMode:!0,throwOnError:!1})}catch{l.textContent=o}super(e,l,Se),this._renderedHeight=s}recordMeasuredHeight(e){this.data.showMarkup||(this._renderedHeight=e)}},hs=class extends te{constructor(e,n,i){let r=e.ast.ordered?"ol":"ul",s=i&&i.element.tagName===r.toUpperCase(),o=s?i.element:document.createElement(r);s||(o.className="md-block md-list");let a=Ge(o,e.content,i?.children,At(n));super(e,o,a)}},fs=class extends te{constructor(e,n,i){let r=e.ast,s=document.createElement("li");e.isActive&&s.classList.add("md-list-item-active"),r.checked!==void 0&&s.classList.add("md-task-list-item"),e.isActive||s.classList.add("md-markers-hidden"),e.isRunning&&s.classList.add("md-task-list-item-running"),s.style.setProperty("--md-list-level",String(e.level));let o=g_(s,e.content,i,n);if(!e.isActive&&r.checked!==void 0){let a=document.createElement("input");a.type="checkbox",a.checked=r.checked,a.className="md-checkbox",e.isRunning&&(a.classList.add("md-checkbox-running"),a.indeterminate=!0,a.setAttribute("aria-busy","true"),a.setAttribute("aria-label","In progress"));let l=n?.onToggleCheckbox;if(l){let c=r.checked;a.addEventListener("pointerdown",d=>{d.stopPropagation()}),a.addEventListener("click",d=>{d.stopPropagation(),d.preventDefault(),l(r,!c)})}else a.disabled=!0;s.insertBefore(a,s.firstChild)}super(e,s,o)}};function g_(t,e,n,i){let{paired:r,unused:s}=Hl(e,n?.children??Se),o=e.map(c=>at(c,i,r.get(c)));for(let c of s)c.dispose();if(!(e.length>=2&&e[0].kind==="glue"&&e[0].ast.glueKind==="indent"&&e[1].kind==="marker"&&e[1].ast.markerKind==="listItemMarker"))return ft(t,o.map(c=>c.mountNode)),o;let a=t.firstElementChild,l=a&&a.classList.contains("md-list-gutter")?a:document.createElement("span");return l.className="md-list-gutter",ft(l,[o[0].mountNode,o[1].mountNode]),ft(t,[l,...o.slice(2).map(c=>c.mountNode)]),o}var ms=class extends te{_table;constructor(e,n,i){let r=i?.dom??document.createElement("div"),s=i?._table??document.createElement("table");i||(r.className="md-block md-table-wrapper",s.className="md-block md-table",r.appendChild(s));let o=Ge(s,lh(e),i?.children,At(n));super(e,r,o),this._table=s}get element(){return this._table}get scrollElement(){return this.dom}},ps=class extends te{constructor(e,n,i){let r=i?.element??document.createElement("tr");e.isDelimiter&&r.classList.add("md-table-delimiter-row");let s=Ge(r,e.content,i?.children,At(n));e.isDelimiter||e.content.forEach((o,a)=>{o.kind==="tableCell"&&s[a].element.classList.toggle("md-table-cell-active",o.isActive)}),super(e,r,s)}},gs=class extends te{constructor(e,n,i){let r=i?.element??document.createElement("code"),s=Ge(r,e.content,i?.children,ah(n));super(e,r,s)}},vs=class extends te{constructor(e,n,i){if(e.showMarkup){let a=document.createElement("span");a.className="md-inline-math";let l=Ge(a,e.content,i?.children,ah(n));super(e,a,l);return}let r=e.content.find(a=>a.kind==="marker"&&a.ast.markerKind==="content")?.ast.content??"",s=n?.renderMath?.({latex:r,displayMode:!1,className:"md-inline-math",nodeLength:e.ast.length,contentStart:hh(e.ast.content)});if(s){super(e,s.dom,fh(e.ast,s.segments,e.ast.length));return}let o=document.createElement("span");o.className="md-inline-math";try{vo.render(r,o,{throwOnError:!1})}catch{o.textContent=r}super(e,o,Se)}},bs=class extends te{_presentation;_presentationSubscription;constructor(e,n,i){i?._presentationSubscription?.dispose(),i&&(i._presentationSubscription=void 0),i?._presentation?.dispose(),i&&(i._presentation=void 0);let r=!e.showMarkup&&Ga(e.ast.url)?n?.linkPresentationProvider?.createLinkPresentation(e.ast.url):void 0,s=r?"SPAN":"A",o=i?.element.tagName===s?i.element:document.createElement(s.toLowerCase());if(Ga(e.ast.url)?(o.dataset.mdUrl=e.ast.url,o instanceof HTMLAnchorElement&&(o.href=e.ast.url)):(o.removeAttribute("href"),delete o.dataset.mdUrl),r?(o.setAttribute("role","link"),o.tabIndex=0):(o.removeAttribute("role"),o.removeAttribute("tabindex")),o!==i?.element){let d=m=>!o.dataset.mdUrl||m.button!==0&&m.button!==1?!1:m.button===1?!0:o.closest(".md-block-active")===null||m.ctrlKey||m.metaKey,h=m=>{let p=o.dataset.mdUrl;if(!p)return!0;let v=n?.onOpenLink;return v?v(p,m)!==!1:(window.open(p,"_blank","noopener"),!0)},u=!1;o.addEventListener("pointerdown",m=>{u=!1,d(m)&&(m.stopPropagation(),u=!0)});let f=m=>{let p=u||d(m);u=!1,p&&h(m)&&(m.preventDefault(),m.stopPropagation())};o.addEventListener("click",f),o.addEventListener("auxclick",f),o.addEventListener("keydown",m=>{o.getAttribute("role")!=="link"||m.key!=="Enter"&&m.key!==" "||(m.preventDefault(),o.click())})}let a,l=r?o.querySelector(":scope > .md-rich-link-label")??document.createElement("span"):o,c=Ge(l,e.content,i?.children,At(n));if(r?a=Gr.mount(o,l):(Gr.clear(o),ft(o,c.map(d=>d.mountNode))),super(e,o,c),r&&a){this._presentation=r;let d=()=>a.update(r.presentation.get());d(),this._presentationSubscription=li(r.presentation,d)}}dispose(){this._presentationSubscription?.dispose(),this._presentationSubscription=void 0,this._presentation?.dispose(),this._presentation=void 0,super.dispose()}},_s=class extends te{constructor(e,n,i){let r=e.ast;if(e.showMarkup){let o=document.createElement("span");o.className="md-image-source";let a=Ge(o,e.content,i?.children,At(n));super(e,o,a);return}let s=document.createElement("img");Ga(r.url)&&(s.src=r.url),s.alt=r.alt,super(e,s,Se)}};function Hl(t,e){let n=new Map;for(let r of e)n.set(r.ast.id,r);let i=new Map;for(let r of t){let s=n.get(r.ast.id);s&&(i.set(r,s),n.delete(r.ast.id))}return{paired:i,unused:[...n.values()]}}function Ga(t){return!t.trim().toLowerCase().startsWith("javascript:")}var Ya=class t extends xt{constructor(e,n,i,r,s){super(e,n,r),this.blocks=i,this.pendingParagraph=s}static create(e,n,i){let r=i?.contentDomNode??document.createElement("div");r.classList.add("md-document");let s=new Map(e.children.filter(f=>f.kind==="block").map(f=>[f.view,f.isActive])),o=i?.children,a=e.children.map(f=>f.view),{paired:l,unused:c}=Hl(a,o??v_),d,h=a.map((f,m)=>{let p=l.get(f);if(e.children[m].kind==="pendingParagraph"){let g=f,w=p instanceof ws?p:new ws(g);return w.update(g.text),d=w,w}let v=at(f,n,p);if(e.children[m].kind==="block"){let g=s.get(f);g!==void 0&&(v.element.classList.toggle("md-block-active",g),v.element.classList.toggle("md-markers-hidden",!g));let w=e.children[m].diffKind;v.element.classList.toggle("md-diff-added",w==="added"),v.element.classList.toggle("md-diff-modified",w==="modified")}return v});for(let f of c)f.dispose();ft(r,h.map(f=>f.mountNode));let u=[];return e.children.forEach((f,m)=>{f.kind==="block"&&u.push({node:h[m],absoluteStart:f.absoluteStart})}),new t(e.ast,r,u,h,d)}get contentDomNode(){return this.dom}},ws=class extends xt{element;anchorBlock;cursorLine;_text="";constructor(e){let n=document.createElement("p");n.className="md-block md-paragraph md-pending-paragraph",super(e.ast,n),this.element=n,this.anchorBlock=e.anchorBlock,this.cursorLine=e.cursorLine,this.update(e.text)}update(e){if(!(e===this._text&&this.element.childNodes.length>0)){if(this._text=e,e.length===0){this.element.replaceChildren(document.createElement("br"));return}this.element.replaceChildren(...[...e].map(n=>{let i=document.createElement("span");return i.className=n===" "?"md-ws-space":"md-ws-tab",i.textContent=n,i}))}}getCaretClientRect(){let e=this.element.getBoundingClientRect();if(this._text.length===0)return new DOMRect(e.left,e.top,0,e.height);let n=this.element.ownerDocument.createRange();n.selectNodeContents(this.element),n.collapse(!1);let i=n.getBoundingClientRect();if(i.height>0)return i;let r=this.element.lastElementChild?.getBoundingClientRect();return new DOMRect(r?.right??e.left,e.top,0,e.height)}},v_=[],Dr=1e-7,ys=class t{constructor(e){this._getLocalToClientMatrix=e}static forSvgOverlay(e){return new t(()=>{if(!e.isConnected)return new DOMMatrix;let n=e.getScreenCTM();if(!n)throw new Error("Cannot resolve editor coordinates before the overlay is mounted");return n})}capture(){let e=this._getLocalToClientMatrix();if(e.is2D===!1||Math.abs(e.b)>Dr||Math.abs(e.c)>Dr||e.a<=Dr||e.d<=Dr)throw new Error("Markdown editor geometry supports positive axis-aligned scale and translation only");return new Qa(e)}},Qa=class{constructor(e){this._localToClient=e,this._clientToLocal=e.inverse()}_clientToLocal;toLocalPoint(e){let n=new DOMPoint(e.x,e.y).matrixTransform(this._clientToLocal);return new vn(n.x,n.y)}toClientPoint(e){let n=new DOMPoint(e.x,e.y).matrixTransform(this._localToClient);return new vn(n.x,n.y)}toLocalRect(e){return this._convertRect(e,this._clientToLocal)}toClientRect(e){return this._convertRect(e,this._localToClient)}_convertRect(e,n){let i=new DOMPoint(e.left,e.top).matrixTransform(n),r=new DOMPoint(e.left+e.width,e.top+e.height).matrixTransform(n);return ne.fromPointPoint(i.x,i.y,r.x,r.y)}},ks=class{constructor(e,n,i){this.ast=e,this.blocks=n,this.children=i}kind="document"},el=class{constructor(e,n){this.ast=e,this.content=n}kind="heading"},tl=class{constructor(e,n){this.ast=e,this.content=n}kind="paragraph"},nl=class{constructor(e,n,i,r){this.ast=e,this.anchorBlock=n,this.cursorLine=i,this.text=r}kind="pendingParagraph"},il=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="frontMatter"},rl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="codeBlock"},sl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="mathBlock"},ol=class{constructor(e,n,i){this.ast=e,this.content=n,this.showFinalMarkerOnlyLine=i}kind="blockQuote"},al=class{constructor(e,n){this.ast=e,this.content=n}kind="list"},ll=class{constructor(e,n){this.ast=e,this.content=n}kind="table"},cl=class{constructor(e,n){this.ast=e,this.content=n}kind="strong"},dl=class{constructor(e,n){this.ast=e,this.content=n}kind="emphasis"},ul=class{constructor(e,n){this.ast=e,this.content=n}kind="strikethrough"},hl=class{constructor(e,n){this.ast=e,this.content=n}kind="inlineCode"},fl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="inlineMath"},ml=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="link"},pl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="image"},gl=class{constructor(e,n,i,r,s=!1){this.ast=e,this.isActive=n,this.content=i,this.level=r,this.isRunning=s}kind="listItem"},vl=class{constructor(e,n,i){this.ast=e,this.isDelimiter=n,this.content=i}kind="tableRow"},bl=class{constructor(e,n,i,r){this.ast=e,this.isActive=n,this.showTableGlue=i,this.content=r}kind="tableCell"},_l=class{constructor(e,n,i=!1,r=!1,s=0){this.ast=e,this.showWhitespace=n,this.leftWordBoundary=i,this.rightWordBoundary=r,this.hiddenPrefixLength=s}kind="text"},wl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="thematicBreak"},yl=class{constructor(e,n,i){this.ast=e,this.showMarkup=n,this.content=i}kind="unhandledBlock"},kl=class{constructor(e,n){this.ast=e,this.visible=n}kind="marker"},xs=class{constructor(e,n,i){this.ast=e,this.visible=n,this.decorateNewline=i}kind="glue"},xl=class{constructor(e,n,i,r,s){this.ast=e,this.side=n,this.deletedRanges=i,this.whole=r,this.originalStart=s}kind="diffDecoration"},mh={showMarkup:!1,showTableGlue:!1,selectionInNode:void 0};function _t(t){return t.inlineFlow?t:{...t,inlineFlow:!0}}function ph(t,e,n,i,r){let s=new Map;if(i)for(let h of i.children)s.set(h.view.ast,h);let o=t.content,a=new Set(t.blocks),l=[],c=[],d=0;for(let h=0;h<o.length;h++){let u=o[h];if(a.has(u)){let f=u,m=e.has(f),p=s.get(f),v=r?.anchorBlock===f?r.replaceRange.delta(-d):void 0,g;if(!m)g=p&&!p.isActive&&!v?p.view:Sl(f,{...mh,pendingAnchorBlock:v?f:void 0,pendingReplacementInBlock:v},p?.view);else{let w=n&&n.endExclusive>=d&&n.start<=d+f.length?new O(Math.max(0,n.start-d),Math.min(f.length,n.endExclusive-d)):void 0;g=Sl(f,{showMarkup:!0,showTableGlue:!1,selectionInNode:w,pendingAnchorBlock:v?f:void 0,pendingReplacementInBlock:v},p?.view)}l.push({ast:f,absoluteStart:d,isActive:m,view:g}),c.push({absoluteStart:d,isActive:m,view:g,kind:"block"}),r&&r.anchorBlock===f&&c.push({absoluteStart:d+f.length,isActive:!0,view:new nl(r.ast,r.anchorBlock,r.cursorLine,r.text),kind:"pendingParagraph"})}else if(u instanceof Fe){let f=s.get(u),m=oe(f?.view,new xs(u,!1,!1));c.push({absoluteStart:d,isActive:!1,view:m,kind:"glue"})}d+=u.length}return new ks(t,l,c)}function Sl(t,e,n){return Zn(t,e,n)}function b_(t,e,n){return Sl(t,e?{showMarkup:!0,showTableGlue:!1,selectionInNode:void 0}:mh,n)}function __(t,e,n=!1){let i=new Map,r=new Map,s=[];for(let c of e){if(c.kind==="removed"){s.push(c);continue}let d=vh(c);d&&(s.length&&(r.set(d,s),s=[]),i.set(d,c))}let o=s,a=[],l=[];for(let c of t.children){if(c.kind!=="block"){a.push(c);continue}let d=c.view;for(let p of r.get(d.ast)??[])a.push(xa(p.node,p.deletedLocal,c.absoluteStart,!0,p.originalStart,n));let h=i.get(d.ast);h&&h.kind==="replaced"&&h.deletedLocal.length>0&&a.push(xa(h.original,h.deletedLocal,c.absoluteStart,!1,h.originalStart,n));let u=h&&h.kind==="nested"?gh(d,h,n):d,f=h?.kind==="added"?"added":h?.kind==="replaced"?"modified":void 0,m=f?{...c,diffKind:f}:u!==d?{...c,view:u}:c;a.push(m),l.push({ast:d.ast,absoluteStart:c.absoluteStart,isActive:c.isActive,view:u})}for(let c of o)a.push(xa(c.node,c.deletedLocal,t.ast.length,!0,c.originalStart,n));return new ks(t.ast,l,a)}function xa(t,e,n,i,r,s){return{absoluteStart:n,isActive:!1,view:Wr(t,e,i,r,s),kind:"diffDecoration"}}function Wr(t,e,n,i,r){return new xl(t,b_(t,r||!n),e,n,i)}function gh(t,e,n){let i=new Map,r=new Map,s=[];for(let l of e.children){if(l.kind==="removed"){s.push(l);continue}let c=vh(l);c&&(s.length&&(r.set(c,s),s=[]),i.set(c,l))}let o=t.content??[],a=[];for(let l of o){for(let d of r.get(l.ast)??[])a.push(Wr(d.node,d.deletedLocal,!0,d.originalStart,n));let c=i.get(l.ast);c&&c.kind==="replaced"&&c.deletedLocal.length>0?(a.push(Wr(c.original,c.deletedLocal,!1,c.originalStart,n)),a.push(l)):c&&c.kind==="nested"?a.push(gh(l,c,n)):a.push(l)}for(let l of s)a.push(Wr(l.node,l.deletedLocal,!0,l.originalStart,n));return w_(t,a)}function w_(t,e){return Object.assign(Object.create(Object.getPrototypeOf(t)),t,{content:e})}function vh(t){switch(t.kind){case"unchanged":return t.node;case"added":return t.node;case"replaced":return t.modified;case"nested":return t.modified;case"removed":return}}function Zn(t,e,n,i){let r=t;switch(r.kind){case"text":return oe(n,new _l(r,e.showMarkup,i?.left??!1,i?.right??!1,r===e.hideRunnerMarkerNode?e.hideRunnerMarkerLength??0:0));case"thematicBreak":return oe(n,new wl(r,e.showMarkup,Me(r.children,e,n)));case"unhandledBlock":return oe(n,new yl(r,e.showMarkup,Me(r.children,e,n)));case"marker":return oe(n,new kl(r,S_(r.markerKind,e)));case"glue":return oe(n,new xs(r,z_(r.glueKind,e),e.inlineFlow??!1));case"heading":return oe(n,new el(r,Me(r.children,_t(e),n)));case"paragraph":return oe(n,new tl(r,Me(r.children,_t(e),n)));case"frontMatter":return oe(n,new il(r,e.showMarkup,Me(r.children,e,n)));case"codeBlock":return oe(n,new rl(r,e.showMarkup,Me(r.children,e,n)));case"mathBlock":return oe(n,new sl(r,e.showMarkup,Me(r.children,e,n)));case"blockQuote":{let s=x_(r),o=e.pendingAnchorBlock?ot(e.pendingAnchorBlock,r):void 0,a=s&&o!==void 0?s.delta(o):void 0,l=!a||!e.pendingReplacementInBlock?.containsRange(a);return oe(n,new ol(r,Me(r.children,e,n),l))}case"list":return oe(n,C_(r,e,n));case"listItem":return oe(n,bh(r,e,n));case"table":return oe(n,T_(r,e,n));case"tableRow":return oe(n,_h(r,e,!1,n));case"tableCell":return oe(n,wh(r,e.showMarkup,e.showTableGlue,e.selectionInNode,n));case"strong":return oe(n,new cl(r,Me(r.children,_t(e),n)));case"emphasis":return oe(n,new dl(r,Me(r.children,_t(e),n)));case"strikethrough":return oe(n,new ul(r,Me(r.children,_t(e),n)));case"inlineCode":return oe(n,new hl(r,Me(r.children,_t(e),n)));case"inlineMath":return oe(n,new fl(r,e.showMarkup,Me(r.children,_t(e),n)));case"link":return oe(n,new ml(r,e.showMarkup,Me(r.children,_t(e),n)));case"image":return oe(n,new pl(r,e.showMarkup,Me(r.children,_t(e),n)));case"document":return ph(r,new Set,O.ofLength(0),void 0)}}function zl(t){return t.kind==="document"?t.blocks.map(e=>e.view):"content"in t?t.content:y_}var y_=[];function qi(t){if(!t)return;let e=new Map;for(let n of zl(t))e.set(n.ast,n);return e}function oe(t,e){if(t&&t.kind===e.kind&&t.ast===e.ast&&k_(t,e)){let n=zl(t),i=zl(e);if(n.length===i.length&&n.every((r,s)=>r===i[s]))return t}return e}function k_(t,e){switch(t.kind){case"text":return t.showWhitespace===e.showWhitespace&&t.leftWordBoundary===e.leftWordBoundary&&t.rightWordBoundary===e.rightWordBoundary&&t.hiddenPrefixLength===e.hiddenPrefixLength;case"marker":return t.visible===e.visible;case"glue":return t.visible===e.visible&&t.decorateNewline===e.decorateNewline;case"thematicBreak":return t.showMarkup===e.showMarkup;case"frontMatter":return t.showMarkup===e.showMarkup;case"codeBlock":return t.showMarkup===e.showMarkup;case"mathBlock":return t.showMarkup===e.showMarkup;case"inlineMath":return t.showMarkup===e.showMarkup;case"image":return t.showMarkup===e.showMarkup;case"unhandledBlock":return t.showMarkup===e.showMarkup;case"listItem":return t.isActive===e.isActive&&t.isRunning===e.isRunning;case"tableCell":{let n=e;return t.isActive===n.isActive&&t.showTableGlue===n.showTableGlue}case"tableRow":return t.isDelimiter===e.isDelimiter;case"blockQuote":return t.showFinalMarkerOnlyLine===e.showFinalMarkerOnlyLine;default:return!0}}function x_(t){let e=0,n;for(let i of t.children)i instanceof Fe||(n=i instanceof q&&i.markerKind==="blockQuoteMarker"?O.ofStartAndLength(e,i.length):void 0),e+=i.length;return n}function Me(t,e,n){let i=qi(n);return t.map((r,s)=>{let o=r.kind==="text"?{left:s>0&&vu(t[s-1],"end"),right:s<t.length-1&&vu(t[s+1],"start")}:void 0;return Zn(r,e,i?.get(r),o)})}function vu(t,e){switch(t.kind){case"text":{let n=t.content,i=e==="end"?n[n.length-1]:n[0];return i!==void 0&&i!==" "&&i!=="	"&&i!==`
`&&i!=="\r"}case"inlineCode":case"inlineMath":case"link":case"image":case"strong":case"emphasis":case"strikethrough":return!0;default:return!1}}function S_(t,e){return e.showMarkup||t==="tableCellGlue"&&e.showTableGlue}function z_(t,e){return e.showMarkup||t==="tableCellGlue"&&e.showTableGlue}var bu=":running:";function E_(t){if(t.checked===void 0)return;let e=t.blocks[0];if(!e||e.kind!=="paragraph")return;let n=e.content[1];if(!n||n.kind!=="text")return;let i=n.content,r=0;for(;r<i.length&&(i[r]===" "||i[r]==="	");)r++;if(i.startsWith(bu,r))return{text:n,hiddenLength:r+bu.length}}function C_(t,e,n){let i=qi(n),r=O_(t,e),s=new Set(t.items),o=(e.listLevel??0)+1,a=[],l=0;for(let c of t.children){if(s.has(c)){let d=c,h=r.has(t.items.indexOf(d)),u={showMarkup:h,showTableGlue:!1,selectionInNode:h&&e.selectionInNode?e.selectionInNode.delta(-l):void 0,listLevel:o};a.push(oe(i?.get(d),bh(d,u,i?.get(d))))}else a.push(Zn(c,e,i?.get(c)));l+=c.length}return new al(t,a)}function bh(t,e,n){let i=qi(n),r=e.showMarkup?void 0:E_(t),s=r!==void 0,o=s?{...e,hideRunnerMarkerNode:r.text,hideRunnerMarkerLength:r.hiddenLength}:e,a=[],l=0;for(let c of t.children){let d=o.selectionInNode?{...o,selectionInNode:o.selectionInNode.delta(-l)}:o;a.push(Zn(c,d,i?.get(c))),l+=c.length}return new gl(t,e.showMarkup,a,e.listLevel??1,s)}function T_(t,e,n){let i=qi(n),r=e.showMarkup,s=t.delimiterRow,o=new Set([t.headerRow,t.delimiterRow,...t.bodyRows].filter(c=>c!==void 0)),a=[],l=0;for(let c of t.children){if(o.has(c)){let d=c,h=d===s,u={showMarkup:r,showTableGlue:r,selectionInNode:!h&&r&&e.selectionInNode?e.selectionInNode.delta(-l):void 0};a.push(oe(i?.get(d),_h(d,u,h,i?.get(d))))}else a.push(Zn(c,e,i?.get(c)));l+=c.length}return new ll(t,a)}function _h(t,e,n,i){let r=qi(i),s=e.showMarkup,o=n?void 0:R_(t,e),a=new Set(t.cells),l=[],c=0;for(let d of t.children){if(a.has(d)){let h=d,u=n?s:o.has(t.cells.indexOf(h)),f=u&&e.selectionInNode?e.selectionInNode.delta(-c):void 0;l.push(wh(h,u,s,f,r?.get(h)))}else l.push(Zn(d,e,r?.get(d)));c+=d.length}return new vl(t,n,l)}function wh(t,e,n,i,r){let s={showMarkup:e,showTableGlue:n,selectionInNode:i};return new bl(t,e,n,Me(t.children,_t(s),r))}var Ss=new Set;function O_(t,e){if(!e.showMarkup||!e.selectionInNode)return Ss;let n=e.selectionInNode;if(n.isEmpty){let s=Ps(t,n.start);return s===void 0?Ss:new Set([s])}let i=new Set,r=0;for(let s of t.children){let o=t.items.indexOf(s);o>=0&&r<n.endExclusive&&r+s.length>n.start&&i.add(o),r+=s.length}return i}function R_(t,e){if(!e.showMarkup||!e.selectionInNode)return Ss;let n=e.selectionInNode;if(n.isEmpty){let s=L_(t,n.start);return s===void 0?Ss:new Set([s])}let i=new Set,r=0;for(let s of t.children){let o=t.cells.indexOf(s);o>=0&&r<n.endExclusive&&r+s.length>n.start&&i.add(o),r+=s.length}return i}function L_(t,e){let n=0;for(let i of t.children){let r=n+i.length,s=t.cells.indexOf(i);if(s>=0&&(n<=e&&e<r||r===e))return s;n=r}}function I_(t){let e=[],n=(i,r)=>{let s=i.children;if(s.length===0){if(i.dom.nodeType===3){let a=i.dom,l=Math.min(a.data.length,i.sourceLength);l>0&&e.push({text:a,start:r,len:l})}return}let o=r;for(let a of s)a.sourceLength!==0&&(n(a,o),o+=a.sourceLength)};return n(t,0),e}function _u(t,e){let n=document.createRange();return n.setStart(t.text,e.start-t.start),n.setEnd(t.text,e.endExclusive-t.start),n}function qs(t,e,n=Number.POSITIVE_INFINITY){if(n<=0)return[];let i=I_(t),r=e.slice().sort((a,l)=>a.start-l.start||a.endExclusive-l.endExclusive),s=[],o=0;for(let a of r){if(a.isEmpty){let l=M_(i,a.start);if(l&&(s.push({range:_u(l,a),sourceRange:a}),s.length>=n))return s;continue}for(;o<i.length&&i[o].start+i[o].len<=a.start;)o++;for(let l=o;l<i.length;l++){let c=i[l];if(c.start>=a.endExclusive)break;let d=a.intersect(O.ofStartAndLength(c.start,c.len));if(!(!d||d.isEmpty)&&(s.push({range:_u(c,d),sourceRange:d}),s.length>=n))return s}}return s}function Sa(t,e){return qs(t,e).map(n=>n.range)}function M_(t,e){return t.find(n=>n.start<=e&&e<=n.start+n.len)}var El=class extends pe{constructor(e,n){super(),this._parent=e,this.element=document.createElement("div"),this.element.className="md-diff-highlight-layer",n?(this._coordinateSpace=n,this._coordinateProbe=void 0):(this._coordinateProbe=document.createElementNS("http://www.w3.org/2000/svg","svg"),this._coordinateProbe.setAttribute("aria-hidden","true"),this._coordinateProbe.style.position="absolute",this._coordinateProbe.style.inset="0",this._coordinateProbe.style.width="100%",this._coordinateProbe.style.height="100%",this._coordinateProbe.style.visibility="hidden",this._coordinateProbe.style.pointerEvents="none",this.element.appendChild(this._coordinateProbe),this._coordinateSpace=ys.forSvgOverlay(this._coordinateProbe)),this._resizeObserver=new ResizeObserver(()=>{this._last&&this._repaint(this._last)}),this._resizeObserver.observe(this._parent),this._register({dispose:()=>{this._resizeObserver.disconnect(),this.element.remove()}})}element;_last;_resizeObserver;_coordinateSpace;_coordinateProbe;clear(){this._last=void 0,this._replaceHighlights()}render(e,n){this._last={node:e,inserted:n},this._repaint(this._last)}_repaint(e){let n=[],i=[];e.inserted&&n.push(...Sa(e.node,e.inserted));let r=s=>{if(s instanceof $i)s.whole||i.push(...Sa(s.sideNode,s.deletedRanges.map(o=>o.range)));else if(s instanceof Fi)for(let o of s.sides)for(let a of o.ranges){let l=Sa(o.node,[a.range]);(a.kind==="inserted"?n:i).push(...l)}for(let o of s.children)r(o)};r(e.node),this._paint(n,i)}_paint(e,n){let i=this._coordinateSpace.capture(),r=document.createDocumentFragment(),s=(o,a)=>{for(let l of o)for(let c of l.getClientRects()){if(c.width===0||c.height===0)continue;let d=i.toLocalRect(c),h=document.createElement("div");h.className=a,h.style.left=`${d.left}px`,h.style.top=`${d.top}px`,h.style.width=`${d.width}px`,h.style.height=`${d.height}px`,r.appendChild(h)}};s(e,"md-diff-ins-rect"),s(n,"md-diff-del-rect"),this._replaceHighlights(r)}_replaceHighlights(...e){let n=this._coordinateProbe?[this._coordinateProbe,...e]:e;this.element.replaceChildren(...n)}},Cl=class extends pe{element;rendering;_path;constructor(e){super(),this.element=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.element.setAttribute("class","md-selection-layer"),this._path=document.createElementNS("http://www.w3.org/2000/svg","path"),this._path.setAttribute("class","md-selection-path"),this.element.appendChild(this._path),this.rendering=re(this,n=>{let i=n.readObservable(e.selection),r=n.readObservable(e.visualLineMap),s=n.readObservable(e.blocks);return N_(this._path,i,r,s)}),this._register(ee(n=>{n.readObservable(this.rendering)}))}},zs=class{constructor(e){this.rects=e}};function N_(t,e,n,i){if(!e||e.isCollapsed)return t.setAttribute("d",""),new zs([]);let r=yh(e.range,n,i);return t.setAttribute("d",$_(r,4)),new zs(r)}var A_=.4;function yh(t,e,n){if(t.isEmpty)return[];let i=t,r=(u,f,m,p)=>ne.fromPointPoint(u,f,Math.max(u,m),Math.max(f,p)),s=e.sourceLines,o=[];for(let u=0;u<s.length;u++){let f=s[u],m=Es(f);if(!m)continue;let p=u+1<s.length?Es(s[u+1]):void 0,v=!p||p.start>m.endExclusive,g=i.intersects(m),w=v&&i.start<=m.endExclusive&&i.endExclusive>m.endExclusive;if(!g&&!w)continue;let y=n.find(x=>O.ofStartAndLength(x.absoluteStart,x.block.length).containsRange(m));o.push({line:f,lineRange:m,block:y,hardBreak:v})}let a=[],l=[];for(let{line:u,lineRange:f,hardBreak:m,block:p}of o){let v=f.start,g=f.endExclusive,w=i.start<=v?u.rect.left:u.xAtOffset(i.start),y;if(i.endExclusive<g)y=u.xAtOffset(i.endExclusive);else{let C=i.endExclusive>g;y=u.rect.right+(C&&m?u.rect.height*A_:0)}let x=kh(p);x&&(w=Math.max(w,x.left),y=Math.min(y,x.right)),a.push(r(w,u.rect.top,y,u.rect.bottom)),l.push({left:w,right:y,top:u.rect.top,bottom:u.rect.top+u.rect.height})}for(let u=0;u<l.length-1;u++){let f=l[u],m=l[u+1];if(m.top<=f.bottom)continue;let p=Math.max(f.left,m.left),v=Math.min(f.right,m.right);v<=p||a.push(r(p,f.bottom,v,m.top))}let c=new Map,d=new Map;for(let u=0;u<o.length;u++){let f=o[u].block;f&&(c.has(f)||c.set(f,u),d.set(f,u))}let h=n.map(u=>i.intersects(O.ofStartAndLength(u.absoluteStart,u.block.length)));for(let u=0;u<n.length-1;u++){let f=n[u],m=n[u+1],p=f.absoluteStart+f.block.length,v=m.absoluteStart;if(p<v&&!i.containsRange(O.fromTo(p,v))||p>=v&&!(h[u]&&h[u+1]))continue;let g=f.rect,w=m.rect,y=F_(e,m,w.top),x=g.bottom;if(y<=x)continue;let C=d.get(f),k=c.get(m);if(C===void 0&&za(e,f)||k===void 0&&za(e,m))continue;let E=C!==void 0?l[C]:{left:g.left,right:g.right},L=k!==void 0?l[k]:{left:w.left,right:w.right},D=Math.max(E.left,L.left),S=Math.min(E.right,L.right);S<=D||a.push(r(D,x,S,y))}for(let u of n){let f=O.ofStartAndLength(u.absoluteStart,u.block.length);i.intersects(f)&&(za(e,u)||a.push(u.rect))}return a}function Es(t){if(t.runs.length===0)return;let e=1/0,n=-1/0;for(let i of t.runs)i.sourceStart<e&&(e=i.sourceStart),i.sourceEndExclusive>n&&(n=i.sourceEndExclusive);return O.fromTo(e,n)}function za(t,e){let n=O.ofStartAndLength(e.absoluteStart,e.block.length);for(let i of t.sourceLines){let r=Es(i);if(r&&n.containsRange(r))return!0}return!1}function kh(t){return t?.viewportClip}function P_(t,e){return t.find(n=>e>=n.absoluteStart&&e<=n.absoluteStart+n.block.length)}function F_(t,e,n){let i=O.ofStartAndLength(e.absoluteStart,e.block.length);for(let r of t.sourceLines){let s=Es(r);if(s&&i.containsRange(s))return r.rect.top}return n}function $_(t,e){if(t.length===0)return"";let n=t.slice().sort((s,o)=>s.y-o.y||s.x-o.x),i=[],r=[];for(let s of n){let o=r[r.length-1],a=o!==void 0&&s.y<=o.y+o.height+.5,l=o!==void 0&&Math.max(o.x,s.x)<Math.min(o.x+o.width,s.x+s.width);a&&l?r.push(s):(r.length>0&&i.push(r),r=[s])}return r.length>0&&i.push(r),i.map(s=>B_(s,e)).filter(Boolean).join(" ")}function B_(t,e){let n=[];n.push({x:t[0].x+t[0].width,y:t[0].y,convex:!0});for(let r=0;r<t.length-1;r++){let s=t[r],o=t[r+1],a=s.x+s.width,l=o.x+o.width;if(Math.abs(a-l)>.5){let c=s.y+s.height,d=a>l;n.push({x:a,y:c,convex:d}),n.push({x:l,y:c,convex:!d})}}let i=t[t.length-1];n.push({x:i.x+i.width,y:i.y+i.height,convex:!0}),n.push({x:i.x,y:i.y+i.height,convex:!0});for(let r=t.length-1;r>0;r--){let s=t[r],o=t[r-1];if(Math.abs(s.x-o.x)>.5){let a=s.y,l=s.x<o.x;n.push({x:s.x,y:a,convex:l}),n.push({x:o.x,y:a,convex:!l})}}return n.push({x:t[0].x,y:t[0].y,convex:!0}),D_(n,e)}function D_(t,e){let n=t.length;if(n<3)return"";let i=new Array(n);for(let o=0;o<n;o++){let a=t[(o+n-1)%n],l=t[(o+1)%n],c=Vr(t[o],a),d=Vr(t[o],l);i[o]=Math.min(e,c/2,d/2)}let r=Ea(t[n-1],t[0],Vr(t[n-1],t[0])-i[0]),s=[`M${bt(r.x)},${bt(r.y)}`];for(let o=0;o<n;o++){let a=t[o],l=t[(o+1)%n],c=i[o],d=Ea(a,l,c);c>0?s.push(`A${bt(c)},${bt(c)} 0 0 ${a.convex?1:0} ${bt(d.x)},${bt(d.y)}`):s.push(`L${bt(d.x)},${bt(d.y)}`);let h=i[(o+1)%n],u=Ea(a,l,Vr(a,l)-h);s.push(`L${bt(u.x)},${bt(u.y)}`)}return s.push("Z"),s.join(" ")}function Vr(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}function Ea(t,e,n){let i=e.x-t.x,r=e.y-t.y,s=Math.hypot(i,r);if(s===0)return{x:t.x,y:t.y};let o=n/s;return{x:t.x+i*o,y:t.y+r*o}}function bt(t){return t.toFixed(2)}var Tl=class extends pe{element;rendering;constructor(e){super(),this.element=document.createElement("div"),this.element.className="md-cursor",this.rendering=re(this,n=>{let i=n.readObservable(e.position),r=n.readObservable(e.visualLineMap);if(i===void 0||r.isEmpty)return this.element.style.display="none",new Wn(i??ue.source(0),!1,ne.EMPTY);let s=r.lineIndexOfPosition(i);if(s===void 0)return this.element.style.display="none",new Wn(i,!1,ne.EMPTY);let o=r.lineRect(s).withZeroWidthAt(r.xAtPosition(i)),a=e.blocks?n.readObservable(e.blocks):void 0,l=a&&i.kind==="source"?kh(P_(a,i.offset)):void 0;return l&&(o.x<l.left-.5||o.x>l.right+.5)?(this.element.style.display="none",new Wn(i,!1,ne.EMPTY)):(this.element.style.left=`${o.x}px`,this.element.style.top=`${o.y}px`,this.element.style.height=`${o.height}px`,this.element.style.display="",new Wn(i,!0,o))}),this._register(ee(n=>{n.readObservable(this.rendering)})),this._register(ee(n=>{n.readObservable(e.position),this.element.style.animation="none",this.element.offsetWidth,this.element.style.animation=""}))}},Wn=class{constructor(e,n,i){this.position=e,this.visible=n,this.rect=i}},Ol=class extends pe{element;rendering;constructor(e){super(),this.element=document.createElement("div"),this.element.className="md-gutter-layer",this.rendering=re(this,n=>{let i=n.readObservable(e.markers),r=n.readObservable(e.visualLineMap);return this._render(i,r)}),this._register(ee(n=>{n.readObservable(this.rendering)}))}_render(e,n){if(this.element.replaceChildren(),n.isEmpty)return new Cs([]);let i=[];for(let r of e){let s=r.type==="deleted"||r.range.isEmpty?q_(r,n):V_(r,n);if(!s)continue;let o=document.createElement("div");o.className=`md-gutter-marker md-gutter-marker-${s.type}`,o.style.top=`${s.y}px`,s.height>0&&(o.style.height=`${s.height}px`),this.element.appendChild(o),i.push(s)}return new Cs(i)}},Cs=class{constructor(e){this.rects=e}};function V_(t,e){let n=1/0,i=-1/0;for(let r of e.sourceLines){let s=j_(r);!s||!t.range.intersects(s)||(n=Math.min(n,r.rect.top),i=Math.max(i,r.rect.top+r.rect.height))}if(!(i<=n))return{type:t.type,y:n,height:i-n}}function q_(t,e){let n=e.lineIndexOfOffset(t.range.start);return{type:"deleted",y:e.lineRect(n).top,height:0}}function j_(t){if(t.runs.length===0)return;let e=1/0,n=-1/0;for(let i of t.runs)i.sourceStart<e&&(e=i.sourceStart),i.sourceEndExclusive>n&&(n=i.sourceEndExclusive);return O.fromTo(e,n)}function wu(t){return t.windowHasFocus&&t.focusIsUnclaimed}function W_(t){return!t.windowHasFocus}function xh(t){let e=t.ownerDocument,n=e.defaultView??window,i=ne.fromPointSize(0,0,e.documentElement.clientWidth||n.innerWidth,e.documentElement.clientHeight||n.innerHeight);for(let r=t.parentElement;r;r=r.parentElement){let s=n.getComputedStyle(r),o=ku(s.overflowX),a=ku(s.overflowY);if(!o&&!a)continue;let l=Sh(r),c=o?Math.max(i.left,l.left):i.left,d=o?Math.min(i.right,l.right):i.right,h=a?Math.max(i.top,l.top):i.top,u=a?Math.min(i.bottom,l.bottom):i.bottom;if(d<=c||u<=h)return ne.fromPointSize(c,h,0,0);i=ne.fromPointPoint(c,h,d,u)}return i}function Sh(t){let e=t.getBoundingClientRect(),n=t.offsetWidth>0?e.width/t.offsetWidth:1,i=t.offsetHeight>0?e.height/t.offsetHeight:1;return ne.fromPointSize(e.left+t.clientLeft*n,e.top+t.clientTop*i,t.clientWidth*n,t.clientHeight*i)}function H_(t,e,n){let i=t.getBoundingClientRect(),r=t.offsetWidth>0?i.width/t.offsetWidth:1,s=t.offsetHeight>0?i.height/t.offsetHeight:1;return{x:e/r,y:n/s}}function K_(t){let e=t.ownerDocument.defaultView??window,n=[];for(let i=t.parentElement;i;i=i.parentElement){let r=e.getComputedStyle(i),s=xu(r.overflowX)&&i.scrollWidth>i.clientWidth,o=xu(r.overflowY)&&i.scrollHeight>i.clientHeight;(s||o)&&n.push(i)}return n}function yu(t,e){return t.left<=e.left&&e.right<=t.right&&t.top<=e.top&&e.bottom<=t.bottom}function ku(t){return t==="auto"||t==="scroll"||t==="hidden"||t==="clip"}function xu(t){return t==="auto"||t==="scroll"||t==="hidden"}var U_=900,Ts=class extends pe{constructor(e,n){super(),this._model=e,this._options=n,this.element=document.createElement("div"),this.element.className="md-editor",this._options?.classNames&&this.element.classList.add(...this._options.classNames),this.element.tabIndex=0,this._contentContainer=document.createElement("div"),this._contentContainer.className="md-editor-content",this.element.appendChild(this._contentContainer);let i=this._options?.limitedWidth??Lo(U_);this._register(ee(c=>{let d=i.read(c);this._contentContainer.style.maxWidth=d===void 0?"":`${d}px`})),this.measuredLayout=new Ha;let r=-1,s=-1,o=-1;this._resizeObserver=new ResizeObserver(()=>{this.element.classList.toggle("md-editor-narrow",this.element.clientWidth<=320);let c=getComputedStyle(this._contentContainer),d=this._contentContainer.clientWidth-parseFloat(c.paddingLeft)-parseFloat(c.paddingRight);this.element.classList.toggle("md-find-compact",d<=400);let h=this._document.get();if(!h)return;let u=this._contentContainer.clientWidth,f=this._contentContainer.clientHeight,m=h.contentDomNode.getBoundingClientRect().height;Math.abs(u-r)<.5&&Math.abs(f-s)<.5&&Math.abs(m-o)<.5||(r=u,s=f,o=m,this._publishMeasurements(h))}),this._resizeObserver.observe(this.element),this._resizeObserver.observe(this._contentContainer),this._register({dispose:()=>this._resizeObserver.disconnect()});let a=0,l=()=>{a||(a=requestAnimationFrame(()=>{a=0;let c=this._document.get();c&&this._publishMeasurements(c)}))};this._contentContainer.addEventListener("scroll",l,{capture:!0,passive:!0}),this._register({dispose:()=>{this._contentContainer.removeEventListener("scroll",l,{capture:!0}),a&&cancelAnimationFrame(a)}}),this._selectionView=this._register(new Cl({selection:this._model.selection,visualLineMap:this.measuredLayout.visualLineMap,blocks:this._selectionBlocksObs})),this._contentContainer.appendChild(this._selectionView.element),this.coordinateSpace=ys.forSvgOverlay(this._selectionView.element),this._cursorView=this._register(new Tl({position:this._model.cursorPosition,visualLineMap:this.measuredLayout.visualLineMap,blocks:this._selectionBlocksObs})),this._contentContainer.appendChild(this._cursorView.element),this._gutterMarkersView=this._register(new Ol({markers:this._model.gutterMarkers,visualLineMap:this.measuredLayout.visualLineMap})),this._contentContainer.appendChild(this._gutterMarkersView.element),this._diffHighlightsView=this._register(new El(this._contentContainer,this.coordinateSpace)),this._contentContainer.appendChild(this._diffHighlightsView.element),this._register(ee(c=>{let d=this._model.readonlyMode.read(c);this.element.classList.toggle("md-readonly",d),d||this.element.classList.remove("md-readonly-editing-attempt")})),this._options?.showReadonlyToggle!==!1&&this._setupReadonlyToggle(),this.editContext=new EditContext({text:this._model.sourceText.get().value,selectionStart:0,selectionEnd:0}),this.element.editContext=this.editContext,this._register(ee(this._renderAutorun)),this._setupModifierTracking(),this._setupFocusTracking(),this._register(ee(c=>{let d=c.readObservable(this._model.selection)?.range;this.editContext.updateSelection(d?.start??0,d?.endExclusive??0)})),this._register({dispose:()=>{this._document.get()?.dispose(),this._clearDiff()}})}element;editContext;measuredLayout;coordinateSpace;forcedMarkerVisibleBlocks=V(this,new Set);_contentContainer;_resizeObserver;_cursorView;_selectionView;_gutterMarkersView;_diffHighlightsView;_readonlyToggleButton;_editContextSuspensions=new Set;_revealOcclusions=new Set;_document=V(this,void 0);_embeddedCodeEditorFactoryVersion=V(this,0);get documentViewNode(){return this._document}refreshEmbeddedCodeEditors(){this._embeddedCodeEditorFactoryVersion.set(this._embeddedCodeEditorFactoryVersion.get()+1,void 0)}_previousViewData;_viewData=V(this,void 0);get viewData(){return this._viewData}_focused=V(this,!1);get focused(){return this._focused}_selectionBlocksObs=re(this,e=>this.measuredLayout.measurements.read(e).flatMap(n=>!n.rect||!n.viewNode?[]:[{block:n.block,absoluteStart:n.absoluteStart,rect:n.rect,viewportClip:n.viewportClip}]));_caretRect=re(this,e=>{let n=this._cursorView.rendering.read(e);return n.visible?n.rect:void 0});get caretRect(){return this._caretRect}get overlayContainer(){return this._contentContainer}rangeRects(e){return re(this,n=>{let i=this.measuredLayout.visualLineMap.read(n),r=this._selectionBlocksObs.read(n);return yh(e,i,r)})}_setupModifierTracking(){this._register(ee(e=>{this.element.classList.toggle("md-mod-down",this._model.ctrlOrMetaDown.read(e))}))}_setupFocusTracking(){let e=this.element,n=e.ownerDocument.defaultView??window,i=()=>{let c=e.ownerDocument.activeElement;return c!==null&&e.contains(c)},r=c=>this._focused.set(c,void 0),s=()=>r(!0),o=c=>{let d=c.relatedTarget;r(d instanceof Node&&e.contains(d))},a=()=>r(!1),l=()=>r(i());e.addEventListener("focusin",s),e.addEventListener("focusout",o),n.addEventListener("blur",a),n.addEventListener("focus",l),this._register({dispose:()=>{e.removeEventListener("focusin",s),e.removeEventListener("focusout",o),n.removeEventListener("blur",a),n.removeEventListener("focus",l)}}),this._register(ee(c=>{this.element.classList.toggle("md-focused",this._focused.read(c))}))}_setupReadonlyToggle(){let e=document.createElement("div");e.className="md-readonly-toggle-host",this._contentContainer.classList.add("md-editor-content-with-readonly-toggle");let n=document.createElement("button");n.type="button",n.className="md-readonly-toggle",this._readonlyToggleButton=n;let i=document.createElement("span");i.className="md-readonly-toggle-indicator",i.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.classList.add("md-readonly-toggle-icon","md-readonly-toggle-icon-locked"),r.setAttribute("viewBox","0 0 16 16"),r.setAttribute("fill","currentColor"),r.setAttribute("aria-hidden","true");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M8 9C8.55228 9 9 9.44771 9 10C9 10.5523 8.55228 11 8 11C7.44772 11 7 10.5523 7 10C7 9.44771 7.44772 9 8 9Z");let o=document.createElementNS("http://www.w3.org/2000/svg","path");o.setAttribute("fill-rule","evenodd"),o.setAttribute("clip-rule","evenodd"),o.setAttribute("d","M8 1C9.654 1 11 2.346 11 4V6H12C13.103 6 14 6.897 14 8V13C14 14.103 13.103 15 12 15H4C2.897 15 2 14.103 2 13V8C2 6.897 2.897 6 4 6H5V4C5 2.346 6.346 1 8 1ZM4 7C3.449 7 3 7.449 3 8V13C3 13.551 3.449 14 4 14H12C12.551 14 13 13.551 13 13V8C13 7.449 12.551 7 12 7H4ZM8 2C6.897 2 6 2.897 6 4V6H10V4C10 2.897 9.103 2 8 2Z"),r.append(s,o);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.classList.add("md-readonly-toggle-icon","md-readonly-toggle-icon-editing"),a.setAttribute("viewBox","0 0 16 16"),a.setAttribute("fill","currentColor"),a.setAttribute("aria-hidden","true");let l=document.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d","M14.236 1.76386C13.2123 0.740172 11.5525 0.740171 10.5289 1.76386L2.65722 9.63549C2.28304 10.0097 2.01623 10.4775 1.88467 10.99L1.01571 14.3755C0.971767 14.5467 1.02148 14.7284 1.14646 14.8534C1.27144 14.9783 1.45312 15.028 1.62432 14.9841L5.00978 14.1151C5.52234 13.9836 5.99015 13.7168 6.36433 13.3426L14.236 5.47097C15.2596 4.44728 15.2596 2.78755 14.236 1.76386ZM11.236 2.47097C11.8691 1.8378 12.8957 1.8378 13.5288 2.47097C14.162 3.10413 14.162 4.1307 13.5288 4.76386L12.75 5.54269L10.4571 3.24979L11.236 2.47097ZM9.75002 3.9569L12.0429 6.24979L5.65722 12.6355C5.40969 12.883 5.10023 13.0595 4.76117 13.1465L2.19447 13.8053L2.85327 11.2386C2.9403 10.8996 3.1168 10.5901 3.36433 10.3426L9.75002 3.9569Z"),a.appendChild(l),n.append(i,r,a),e.appendChild(n);let c=()=>{this._model.readonlyMode.set(!this._model.readonlyMode.get(),void 0)},d=f=>{f.button===0&&(f.preventDefault(),f.stopPropagation(),this.focus())},h=f=>{f.stopPropagation()},u=f=>{f.animationName==="md-readonly-toggle-shine"&&n.classList.remove("md-readonly-toggle-shine")};n.addEventListener("pointerdown",d),n.addEventListener("keydown",h),n.addEventListener("animationend",u),n.addEventListener("click",c),this._register(this.suspendEditContextWhileFocused(n)),this._register({dispose:()=>{n.removeEventListener("pointerdown",d),n.removeEventListener("keydown",h),n.removeEventListener("animationend",u),n.removeEventListener("click",c),this._readonlyToggleButton===n&&(this._readonlyToggleButton=void 0)}}),this._register(ee(f=>{let m=this._model.readonlyMode.read(f);n.classList.toggle("md-readonly-toggle-locked",m),n.setAttribute("aria-pressed",String(m)),n.setAttribute("aria-label",m?"Locked; switch to editing":"Editing; switch to locked mode"),n.title=m?"Read-only: markers hidden, editing disabled. Click to edit.":"Editing: click to lock (hide markers, disable editing).",m||n.classList.remove("md-readonly-toggle-shine")})),this._contentContainer.insertBefore(e,this._contentContainer.firstChild)}showReadonlyEditingAttempt(){let e=this._readonlyToggleButton;if(e){e.classList.contains("md-readonly-toggle-shine")||e.classList.add("md-readonly-toggle-shine");return}this.element.classList.remove("md-readonly-editing-attempt"),requestAnimationFrame(()=>{this._model.readonlyMode.get()&&this.element.classList.add("md-readonly-editing-attempt")})}focus(){this.element.focus({preventScroll:!0})}mountOverlay(e,n){return n==="top-chrome"?this._contentContainer.insertBefore(e,this._contentContainer.firstChild):n==="below-selection"?this._contentContainer.insertBefore(e,this._selectionView.element):this._contentContainer.appendChild(e),{dispose:()=>e.remove()}}registerRevealOcclusion(e){return this._revealOcclusions.add(e),{dispose:()=>this._revealOcclusions.delete(e)}}suspendEditContextWhileFocused(e){let n=()=>{this._editContextSuspensions.add(e),this._syncEditContextAttachment()},i=r=>{let s=r.relatedTarget;s instanceof Node&&e.contains(s)||(this._editContextSuspensions.delete(e),this._syncEditContextAttachment())};return e.addEventListener("focusin",n),e.addEventListener("focusout",i),{dispose:()=>{e.removeEventListener("focusin",n),e.removeEventListener("focusout",i),this._editContextSuspensions.delete(e),this._syncEditContextAttachment()}}}revealRangeInCenterIfOutsideViewport(e,n="smooth"){let i=!1,r=requestAnimationFrame(()=>{i||this._revealRange(e,n)}),s={dispose:()=>{i||(i=!0,cancelAnimationFrame(r))}};return this._register(s)}_sampleAutoFocusEnvironment(){let e=this.element.ownerDocument,n=e.activeElement;return{windowHasFocus:e.hasFocus(),focusIsUnclaimed:n===null||n===e.body}}tryAutoFocus(){return wu(this._sampleAutoFocusEnvironment())?(this.focus(),!0):!1}autoFocusOnOpen(){let e=this._sampleAutoFocusEnvironment();if(wu(e)){this.focus();return}if(!W_(e))return;let n=this.element.ownerDocument.defaultView??window,i=()=>{n.removeEventListener("focus",i),this.tryAutoFocus()};n.addEventListener("focus",i),this._register({dispose:()=>n.removeEventListener("focus",i)})}geometricHitTest=V(this,!0);resolveOffsetFromPoint(e){let n=this._resolveTableCellOffset(e);if(n!==void 0)return n;if(this.geometricHitTest.get()){let r=this.measuredLayout.visualLineMap.get();return r.isEmpty?void 0:r.offsetAtPoint(this.coordinateSpace.capture().toLocalPoint(e))}let i=Jb(e);if(i)return this._document.get()?.resolveSource(i)}_resolveTableCellOffset(e){let n=document.elementFromPoint(e.x,e.y),i=n?.closest("td");if(!(i instanceof HTMLTableCellElement)||!this._contentContainer.contains(i))return;let r=this._document.get();if(!r)return;let s=xt.forDom(i);if(s?.ast.kind!=="tableCell"||s.dom!==i)return;let o=r.resolveSource({node:i,offset:0}),a=r.resolveSource({node:i,offset:1});if(o===void 0||a===void 0)return;let l=h=>{let u=h.getBoundingClientRect();return(getComputedStyle(h).direction==="rtl"?e.x>=u.left+u.width/2:e.x<u.left+u.width/2)?0:1},c=(h,u)=>this.measuredLayout.visualLineMap.get().lines.some(f=>f.runs.some(m=>m.source!==void 0&&m.sourceStart<u&&m.sourceEndExclusive>h)),d=n?xt.forDom(n):void 0;if(d&&d!==s&&d.dom instanceof Element){let h=r.resolveSource({node:d.dom,offset:0}),u=r.resolveSource({node:d.dom,offset:1});if(h!==void 0&&u!==void 0&&!c(h,u))return u-h<=1?u:l(d.dom)===0?h+1:u-1}if(!c(o,a))return a-o<=1?a:l(i)===0?o+1:a-1}isPointInContent(e){let n=this._document.get()?.contentDomNode;if(!n)return!1;let i=document.elementFromPoint(e.x,e.y);return i!==null&&n.contains(i)}intersectsRenderedContent(e){let n=this._document.get()?.contentDomNode;return!!n&&e.intersectsNode(n)}_renderAutorun=e=>{let n=e.readObservable(this._model.document),i=e.readObservable(this._model.sourceText).value,r=e.readObservable(this._model.markerVisibleBlocks),s=e.readObservable(this.forcedMarkerVisibleBlocks),o=s.size===0?r:new Set([...r,...s]),a=e.readObservable(this._model.selection),l=e.readObservable(this._model.pendingParagraph),c=e.readObservable(this._model.diff),d=e.readObservable(this._model.readonlyMode),h=e.readObservable(this._embeddedCodeEditorFactoryVersion);this.editContext.text!==i&&this.editContext.updateText(0,this.editContext.text.length,i);let u=a?.range;this.editContext.updateSelection(u?.start??0,u?.endExclusive??0);let f=this._document.get(),m=ph(n,o,a?.range,this._previousViewData,l?{anchorBlock:l.anchorBlock,ast:l.syntheticAst,replaceRange:l.replaceRange,cursorLine:l.cursorLine,text:l.text}:void 0);this._previousViewData=m;let p=c?__(m,c.items,this._options?.diffDecorationsActive):m;this._viewData.set(p,void 0);let v=this._options?.embeddedCodeEditorFactory?{...this._options,embeddedCodeEditorReadOnly:d,embeddedCodeEditorFactoryVersion:h}:this._options,g=Ya.create(p,v,f);if(f){if(g.contentDomNode!==f.contentDomNode)throw new Error("DocumentViewNode.contentDomNode must be stable across rebuilds")}else this._contentContainer.insertBefore(g.contentDomNode,this._selectionView.element),this._resizeObserver.observe(g.contentDomNode);this._document.set(g,void 0),this._publishMeasurements(g),c?this._paintDiff(g,c.insertedRanges):this._clearDiff()};get _blocks(){return this._document.get()?.blocks??[]}_publishMeasurements(e){let n=this.coordinateSpace.capture(),i=[];for(let o of e.blocks){let a=n.toLocalRect(o.node.element.getBoundingClientRect());o.node.recordMeasuredHeight(a.height);let l=o.node.scrollElement,c,d=getComputedStyle(l).overflowX;if((d==="auto"||d==="scroll"||d==="hidden"||d==="clip")&&l.scrollWidth>l.clientWidth+1){let u=n.toLocalRect(l.getBoundingClientRect()).left+l.clientLeft;c={left:u,right:u+l.clientWidth}}let h=Pi.measure([{absoluteStart:o.absoluteStart,viewNode:o.node}],this.coordinateSpace,n);i.push({block:o.node.block,absoluteStart:o.absoluteStart,height:a.height,rect:a,viewportClip:c,isMeasured:!0,visualLineMap:h,viewNode:o.node})}let r=e.pendingParagraph,s=[];if(r){let o=n.toLocalRect(r.element.getBoundingClientRect()),a=n.toLocalRect(r.getCaretClientRect());s.push({afterBlock:r.anchorBlock,line:Xr.virtual(r.cursorLine,ne.fromPointSize(a.left,o.top,0,o.height))})}this.measuredLayout.setMeasurements(i,s)}_paintDiff(e,n){this._diffHighlightsView.render(e,n)}_clearDiff(){this._diffHighlightsView.clear()}_syncEditContextAttachment(){this.element.editContext=this._editContextSuspensions.size>0?null:this.editContext}_revealRange(e,n){let i=this._document.get();if(!i)return;let r=qs(i,[e]);if(r.length===0&&!e.isEmpty)return;let s=this.measuredLayout.measurements.get().find(v=>v.absoluteStart<=e.start&&e.start<=v.absoluteStart+v.block.length),o=r[0]?.range.startContainer??s?.viewNode?.dom,a=o instanceof Element?o:o?.parentElement;if(!a)return;let l=()=>{let v=X_(r.flatMap(w=>Array.from(w.range.getClientRects())));if(v||!e.isEmpty)return v;let g=this.measuredLayout.visualLineMap.get();if(!g.isEmpty){let w=g.lineIndexOfOffset(e.start),y=g.lineRect(w),x=ne.fromPointSize(g.xAtOffset(e.start),y.top,2,y.height);return this.coordinateSpace.capture().toClientRect(x)}if(s?.rect)return this.coordinateSpace.capture().toClientRect(ne.fromPointSize(s.rect.left,s.rect.top,2,s.rect.height))},c=l();if(!c)return;let d=xh(a),h=this._isRevealOccluded(c);if(yu(d,c)&&!h)return;let u=K_(a);for(let v=0;v<u.length;v++){let g=u[v];c=l()??c,h=this._isRevealOccluded(c);let w=Sh(g),y=g.scrollWidth>g.clientWidth,x=g.scrollHeight>g.clientHeight,C=H_(g,c.left+c.width/2-(w.left+w.width/2),c.top+c.height/2-(w.top+w.height/2)),k=y&&(c.left<w.left||c.right>w.right)?g.scrollLeft+C.x:g.scrollLeft,E=x&&(c.top<w.top||c.bottom>w.bottom||h)?g.scrollTop+C.y:g.scrollTop,L=E!==g.scrollTop;(k!==g.scrollLeft||L)&&g.scrollTo({left:k,top:E,behavior:"auto"})}c=l()??c,h=this._isRevealOccluded(c);let f=this.element.ownerDocument,m=f.defaultView??window,p=ne.fromPointSize(0,0,f.documentElement.clientWidth||m.innerWidth,f.documentElement.clientHeight||m.innerHeight);(!yu(p,c)||h)&&m.scrollBy({left:c.left<p.left||c.right>p.right?c.left+c.width/2-p.width/2:0,top:c.top+c.height/2-p.height/2,behavior:n})}_isRevealOccluded(e){for(let n of this._revealOcclusions){let i=n.ownerDocument.defaultView?.getComputedStyle(n).visibility;if(n.isConnected&&n.getClientRects().length>0&&i!=="hidden"&&i!=="collapse"&&Z_(e,J_(n.getBoundingClientRect())))return!0}return!1}};function Z_(t,e){let n=t.width===0?e.containsX(t.left):Math.max(t.left,e.left)<Math.min(t.right,e.right),i=t.height===0?e.containsY(t.top):Math.max(t.top,e.top)<Math.min(t.bottom,e.bottom);return n&&i}function X_(t){if(t.length===0)return;let e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(let s of t)e=Math.min(e,s.left),n=Math.min(n,s.top),i=Math.max(i,s.right),r=Math.max(r,s.bottom);return ne.fromPointPoint(e,n,i,r)}function J_(t){return ne.fromPointPoint(t.left,t.top,t.right,t.bottom)}var G_=1e3,Y_="md-editor-find-match",Q_="md-editor-find-current",Su=new WeakMap,Rl=class{constructor(e){this._registry=e}_entries=new Set;add(){let e={matches:[],current:[]};return this._entries.add(e),this._refresh(),{update:(n,i)=>{e.matches=n,e.current=i,this._refresh()},dispose:()=>{this._entries.delete(e),this._refresh()}}}_refresh(){let e=[...this._entries].flatMap(i=>i.matches),n=[...this._entries].flatMap(i=>i.current);this._set(Y_,e),this._set(Q_,n)}_set(e,n){n.length===0?this._registry.delete(e):this._registry.set(e,new Highlight(...n))}};function ew(t){let e=t.defaultView?.CSS.highlights;if(!e)return{update:()=>{},dispose:()=>{}};let n=Su.get(t);return n||(n=new Rl(e),Su.set(t,n)),n.add()}var Ll=class extends pe{constructor(e,n){super(),this._view=e,this._matchesLayer=Eu("md-find-matches-layer"),this._currentLayer=Eu("md-find-current-layer"),this._highlightRegistration=this._register(ew(this._view.element.ownerDocument)),this._register(this._view.mountOverlay(this._matchesLayer,"below-selection")),this._register(this._view.mountOverlay(this._currentLayer,"above-decorations")),this._register(ee(o=>{let a=n.isRevealed.read(o);if(!a){this._snapshot=void 0,this._schedulePaint();return}this._snapshot={isRevealed:a,result:n.searchResult.read(o),currentMatch:n.currentMatch.read(o),document:this._view.documentViewNode.read(o),measurements:this._view.measuredLayout.measurements.read(o)},this._schedulePaint()}));let i=()=>this._schedulePaint(),r=this._view.element.ownerDocument,s=r.defaultView??window;r.addEventListener("scroll",i,!0),s.addEventListener("scroll",i),this._register({dispose:()=>{r.removeEventListener("scroll",i,!0),s.removeEventListener("scroll",i)}}),this._resizeObserver=new ResizeObserver(()=>this._schedulePaint()),this._observeResizeAncestors(),s.addEventListener("resize",i),this._register({dispose:()=>{s.removeEventListener("resize",i),this._resizeObserver.disconnect()}}),this._register({dispose:()=>{this._paintRaf&&cancelAnimationFrame(this._paintRaf)}})}_matchesLayer;_currentLayer;_highlightRegistration;_resizeObserver;_resizeObservedElements=new Set;_snapshot;_paintRaf=0;_schedulePaint(){this._paintRaf||(this._paintRaf=requestAnimationFrame(()=>{this._paintRaf=0,this._paint()}))}_paint(){this._observeResizeAncestors();let e=this._snapshot;if(!e||!e.isRevealed||e.result.kind==="invalid"||!e.document){this._matchesLayer.replaceChildren(),this._currentLayer.replaceChildren(),this._highlightRegistration.update([],[]);return}let n=this._view.coordinateSpace.capture(),i=xh(this._view.overlayContainer),r=n.toLocalRect(i),s=tw(this._view.measuredLayout.visualLineMap.get().sourceLines.flatMap(h=>Math.max(h.rect.top,r.top)>=Math.min(h.rect.bottom,r.bottom)?[]:h.runs.flatMap(u=>{let f=nw(u,h.rect,r);return f?[f]:[]}))),o=Cu(e.result.matches.filter(h=>!e.currentMatch?.equals(h)),s),a=e.currentMatch?[e.currentMatch]:[],l=Cu(a,s),c=this._paintRanges(this._matchesLayer,e.document,o,e.measurements,r,"md-find-match-rect",G_),d=this._paintRanges(this._currentLayer,e.document,l,e.measurements,r,"md-find-current-rect",Number.POSITIVE_INFINITY);this._highlightRegistration.update(c,d)}_observeResizeAncestors(){for(let e=this._view.element;e;e=e.parentElement)this._resizeObservedElements.has(e)||(this._resizeObservedElements.add(e),this._resizeObserver.observe(e))}_paintRanges(e,n,i,r,s,o,a){let l=this._view.coordinateSpace.capture(),c=document.createDocumentFragment(),d=[],h=0;for(let f of i.filter(m=>m.isEmpty)){let m=this._view.measuredLayout.visualLineMap.get();if(m.isEmpty)continue;let p=m.lineIndexOfOffset(f.start),v=m.lineRect(p),g=Ru(ne.fromPointSize(m.xAtOffset(f.start),v.top,2,v.height),s,Tu(r,f.start)?.viewportClip);if(g&&(c.appendChild(zu(`${o} md-find-zero-width-rect`,g)),h++,h>=a))return e.replaceChildren(c),d}let u=Number.isFinite(a)?Math.max(0,a-h):Number.POSITIVE_INFINITY;for(let f of qs(n,i.filter(m=>!m.isEmpty),u)){let m=Tu(r,f.sourceRange.start),p=!1;for(let v of f.range.getClientRects()){let g=Ru(l.toLocalRect(v),s,m?.viewportClip);if(!(!g||g.width===0||g.height===0)&&(p=!0,c.appendChild(zu(o,g)),h++,h>=a))return p&&d.push(f.range),e.replaceChildren(c),d}p&&d.push(f.range)}return e.replaceChildren(c),d}};function zu(t,e){let n=document.createElement("div");return n.className=t,n.style.left=`${e.left}px`,n.style.top=`${e.top}px`,n.style.width=`${e.width}px`,n.style.height=`${e.height}px`,n}function Eu(t){let e=document.createElement("div");return e.className=`md-find-highlight-layer ${t}`,e.setAttribute("aria-hidden","true"),e}function Cu(t,e){if(e.length===0)return[];let n=[],i=0;for(let r of t){if(r.isEmpty){for(;i<e.length&&e[i].endExclusive<r.start;)i++;let s=e[i];s&&s.start<=r.start&&r.start<=s.endExclusive&&n.push(r);continue}for(;i<e.length&&e[i].endExclusive<=r.start;)i++;for(let s=i;s<e.length;s++){let o=e[s];if(o.start>=r.endExclusive)break;let a=o.intersect(r);a&&!a.isEmpty&&n.push(a)}}return n}function Tu(t,e){let n=0,i=t.length;for(;n<i;){let r=n+i>>>1,s=t[r];if(e<s.absoluteStart)i=r;else if(e>=s.absoluteStart+s.block.length)n=r+1;else return s}}function tw(t){let e=t.slice().sort((i,r)=>i.start-r.start||i.endExclusive-r.endExclusive),n=[];for(let i of e){let r=n[n.length-1];r?.intersectsOrTouches(i)?n[n.length-1]=r.join(i):n.push(i)}return n}function nw(t,e,n){if(t.sourceRange.isEmpty)return n.left<=t.rect.left&&t.rect.left<=n.right?t.sourceRange:void 0;let i=t.sourceStart,r=t.sourceEndExclusive;if(i>=r)return;let s=t.xAtOffset(r),o=t.xAtOffset(i+1),a=s>=o,l=t.rect.width>0?t.rect:e,c=a?l.left:l.right,d=v=>v===i?c:t.xAtOffset(v),h=v=>a?v:-v,u=h(a?n.left:n.right),f=h(a?n.right:n.left);if(h(s)<u||h(c)>f)return;let m=Ou(i,r,v=>h(d(v))>=u);if(m>r)return;let p=Math.min(r,Ou(m,r,v=>h(d(v))>f));if(!(m>=p))return new O(m,p)}function Ou(t,e,n){let i=t,r=e+1;for(;i<r;){let s=i+r>>>1;s<=e&&n(s)?r=s:i=s+1}return i}function Ru(t,e,n){let i=Math.max(t.left,e.left,n?.left??Number.NEGATIVE_INFINITY),r=Math.min(t.right,e.right,n?.right??Number.POSITIVE_INFINITY),s=Math.max(t.top,e.top),o=Math.min(t.bottom,e.bottom);return i<r&&s<o?ne.fromPointPoint(i,s,r,o):void 0}var iw=19999,Il=class t{constructor(e,n,i,r,s){this._source=e,this._flags=n,this._wholeWord=i,this._wordSeparators=r,this.isEmpty=s}static create(e){if(e.searchString.length===0)return{kind:"valid",pattern:new t("","gmu",e.wholeWord,e.wordSeparators,!0)};let n=e.isRegex?e.searchString:rw(e.searchString),i=`gmu${e.matchCase?"":"i"}`;try{new RegExp(n,i)}catch(r){return{kind:"invalid",error:r instanceof Error?r:new Error(String(r))}}return{kind:"valid",pattern:new t(n,i,e.wholeWord,e.wordSeparators,!1)}}findMatches(e,n,i=iw){if(this.isEmpty||i<=0)return{matches:[],isCapped:!1};let r=[],s=!1;return this._forEachMatch(e,n,o=>r.length===i?(s=!0,!1):(r.push(o),!0)),{matches:r,isCapped:s}}findNextMatch(e,n,i,r=!0,s){if(this.isEmpty)return;let o=Os(n,0,e.length),a,l,c=!1;return this._forEachMatch(e,i,d=>s?.equals(d)?(c=!0,!0):(a??=d,d.start>=o?(l=d,!1):!0)),l??(r?a:void 0)??(c?s:void 0)}findPreviousMatch(e,n,i,r=!0,s){if(this.isEmpty)return;let o=Os(n,0,e.length),a,l,c=!1;return this._forEachMatch(e,i,d=>s?.equals(d)?(c=!0,!0):(l=d,d.endExclusive<=o&&(a=d),!0)),a??(r?l:void 0)??(c?s:void 0)}_forEachMatch(e,n,i){let r=sw(n,e.length);if(r?.isEmpty)return;let s=new RegExp(this._source,this._flags);for(;;){let o=s.exec(e);if(!o)return;let a=O.ofStartAndLength(o.index,o[0].length);if((!r||r.containsRange(a))&&(!this._wholeWord||ow(e,a,this._wordSeparators))&&!i(a))return;o[0].length===0&&(s.lastIndex=aw(e,s.lastIndex))}}};function zh(t){return t.replace(/[\\{}()[\]^$+*?.|]/g,"\\$&")}function rw(t){return t.split(/\r\n|\r|\n/).map(zh).join("(?:\\r\\n|[\\r\\n])")}function sw(t,e){if(!t)return;let n=Os(t.start,0,e),i=Os(t.endExclusive,0,e);return n<=i?new O(n,i):O.emptyAt(n)}function ow(t,e,n){let i=t[e.start-1],r=t[e.start],s=t[e.endExclusive-1],o=t[e.endExclusive],a=e.start===0||!ci(i,n)||e.length>0&&!ci(r,n),l=e.endExclusive===t.length||!ci(o,n)||e.length>0&&!ci(s,n);return a&&l}function aw(t,e){if(e>=t.length)return t.length+1;let n=t.charCodeAt(e);if(n<55296||n>56319||e+1>=t.length)return e+1;let i=t.charCodeAt(e+1);return i>=56320&&i<=57343?e+2:e+1}function Os(t,e,n){return Math.min(Math.max(t,e),n)}var Rs=class{constructor(e){this._editorModel=e,this._observedSourceTextId=this._editorModel.getSourceTextId(this._editorModel.sourceText.get())}_observedSourceTextId;_pending;record(e){let n=this._pending;this._pending=n?{baseSourceTextId:n.baseSourceTextId,resultSourceTextId:e.resultSourceTextId,isContinuous:n.isContinuous&&n.resultSourceTextId===e.baseSourceTextId}:{baseSourceTextId:e.baseSourceTextId,resultSourceTextId:e.resultSourceTextId,isContinuous:!0}}consume(e){let n=this._editorModel.getSourceTextId(e),i=this._pending;this._pending=void 0;let r=n!==this._observedSourceTextId,s=i!==void 0&&i.isContinuous&&i.baseSourceTextId===this._observedSourceTextId&&i.resultSourceTextId===n;return this._observedSourceTextId=n,{sourceIdentityChanged:r,isExpected:s}}},Ml=class extends pe{constructor(e){super(),this._editorModel=e,this._sourceEditTracker=new Rs(this._editorModel);let n=this._inputSnapshot();this._register(this._editorModel.onWillApplySourceEdit(i=>{this._mapStateThroughEdit(i),this._sourceEditTracker.record(i)})),this._register(ee(i=>{let r=this._editorModel.sourceText.read(i),s=r.value,o=this._readInputSnapshot(i),a=this._sourceEditTracker.consume(r),l=a.sourceIdentityChanged,c=l&&a.isExpected;if(l&&!c){this._searchOrigin=Ca(this._searchOrigin,0,s.length),n={...o,scope:void 0},Ce(f=>{this.searchScope.set(void 0,f),this.currentMatch.set(void 0,f)});return}let d=o.isRevealed&&!n.isRevealed,h=!cw(o,n),u=!dw(o.scope,n.scope)&&!l;if(!o.isRevealed)n.isRevealed&&this.currentMatch.set(void 0,void 0);else{let f=this.searchResult.read(i);if(f.kind==="invalid"||f.pattern.isEmpty||f.matches.length===0)this.currentMatch.set(void 0,void 0);else if(d||h||u)this._selectFromOrigin(f,this._pendingInitialDirection??"next");else if(l){let m=this.currentMatch.get();m&&!lw(f,s,o.scope,m)&&this.currentMatch.set(void 0,void 0)}}this._pendingInitialDirection=void 0,this._pendingInitialDirection=void 0,n=o}))}isRevealed=V(this,!1);searchString=V(this,"");isRegex=V(this,!1);matchCase=V(this,!1);wholeWord=V(this,!1);searchScope=V(this,void 0);currentMatch=V(this,void 0);loop=V(this,!0);searchResult=re(this,e=>{let n=this._editorModel.sourceText.read(e).value,i=Il.create({searchString:this.searchString.read(e),isRegex:this.isRegex.read(e),matchCase:this.matchCase.read(e),wholeWord:this.wholeWord.read(e),wordSeparators:this._editorModel.wordNavigationConfig.read(e).wordSeparators});if(i.kind==="invalid")return{kind:"invalid",error:i.error};let r=i.pattern.findMatches(n,this.searchScope.read(e));return{kind:"valid",pattern:i.pattern,matches:r.matches,isCapped:r.isCapped}});matchesCount=re(this,e=>{let n=this.searchResult.read(e);return n.kind==="valid"?n.matches.length:0});isCapped=re(this,e=>{let n=this.searchResult.read(e);return n.kind==="valid"&&n.isCapped});currentMatchPosition=re(this,e=>{let n=this.currentMatch.read(e);if(!n)return 0;let i=this.searchResult.read(e);if(i.kind==="invalid")return 0;let r=i.matches.findIndex(s=>s.equals(n));return r<0?0:r+1});_searchOrigin=0;_sourceEditTracker;_pendingInitialDirection;reveal(e){this._searchOrigin=Ca(e.origin,0,this._editorModel.sourceText.get().value.length),this._pendingInitialDirection=e.direction??"next",Ce(n=>{e.searchString!==void 0&&this.searchString.set(e.searchString,n),this.isRevealed.set(!0,n)})}hide(){Ce(e=>{this.isRevealed.set(!1,e),this.searchScope.set(void 0,e),this.currentMatch.set(void 0,e)})}setSearchOrigin(e){this._searchOrigin=Ca(e,0,this._editorModel.sourceText.get().value.length)}setSearchScope(e){this.searchScope.set(e,void 0)}moveToNextMatch(){return this._move("next")}moveToPreviousMatch(){return this._move("previous")}_move(e){let n=this.searchResult.get();if(n.kind==="invalid"||n.pattern.isEmpty){this.currentMatch.set(void 0,void 0);return}let i=this._editorModel.sourceText.get().value,r=this.currentMatch.get(),s=this.searchScope.get(),o=e==="next"?n.pattern.findNextMatch(i,r?.endExclusive??this._searchOrigin,s,this.loop.get(),r):n.pattern.findPreviousMatch(i,r?.start??this._searchOrigin,s,this.loop.get(),r);return this.currentMatch.set(o,void 0),o}_selectFromOrigin(e,n){let i=this._editorModel.sourceText.get().value,r=this.searchScope.get(),s=n==="next"?e.pattern.findNextMatch(i,this._searchOrigin,r,this.loop.get()):e.pattern.findPreviousMatch(i,this._searchOrigin,r,this.loop.get());this.currentMatch.set(s,void 0)}_mapStateThroughEdit(e){this._searchOrigin=Nl(e.edit,this._searchOrigin,"after");let n=this.searchScope.get();n&&this.searchScope.set(Lu(e.edit,n),e.transaction);let i=this.currentMatch.get();i&&this.currentMatch.set(uw(e.edit,i)?void 0:Lu(e.edit,i),e.transaction)}_inputSnapshot(){return{isRevealed:this.isRevealed.get(),searchString:this.searchString.get(),isRegex:this.isRegex.get(),matchCase:this.matchCase.get(),wholeWord:this.wholeWord.get(),scope:this.searchScope.get()}}_readInputSnapshot(e){return{isRevealed:this.isRevealed.read(e),searchString:this.searchString.read(e),isRegex:this.isRegex.read(e),matchCase:this.matchCase.read(e),wholeWord:this.wholeWord.read(e),scope:this.searchScope.read(e)}}};function lw(t,e,n,i){return t.pattern.findNextMatch(e,i.start,n,!1)?.equals(i)??!1}function cw(t,e){return t.searchString===e.searchString&&t.isRegex===e.isRegex&&t.matchCase===e.matchCase&&t.wholeWord===e.wholeWord}function dw(t,e){return t===e||!!t&&!!e&&t.equals(e)}function Lu(t,e){let n=Nl(t,e.start,"after"),i=Nl(t,e.endExclusive,"before");return new O(Math.min(n,i),Math.max(n,i))}function Nl(t,e,n){let i=0;for(let r of t.replacements){let s=r.replaceRange;if(e<s.start)break;if(e>s.endExclusive){i+=r.newText.length-s.length;continue}return s.isEmpty?s.start+i+(n==="after"?r.newText.length:0):e===s.start&&n==="before"?s.start+i:s.start+i+r.newText.length}return e+i}function uw(t,e){return t.replacements.some(n=>{let i=n.replaceRange;return i.isEmpty?e.start<i.start&&i.start<e.endExclusive:e.isEmpty?i.contains(e.start):i.intersects(e)})}function Ca(t,e,n){return Math.min(Math.max(t,e),n)}var Al=class extends pe{constructor(e,n){super(),this._view=e,this._options=n,this.element=document.createElement("div"),this.element.className="md-find-widget-host",this.element.hidden=!0,this.panelElement=document.createElement("div"),this.panelElement.className="md-find-widget",this.panelElement.setAttribute("role","dialog"),this.panelElement.setAttribute("aria-label","Find"),this.element.appendChild(this.panelElement);let i=document.createElement("div");i.className="md-find-row",this.panelElement.appendChild(i),this._inputShell=document.createElement("div"),this._inputShell.className="md-find-input-shell",i.appendChild(this._inputShell),this._input=document.createElement("textarea"),this._input.className="md-find-input",this._input.rows=1,this._input.spellcheck=!1,this._input.setAttribute("aria-label","Find"),this._input.placeholder="Find",this._inputShell.appendChild(this._input);let r=document.createElement("div");r.className="md-find-options",this._inputShell.appendChild(r),this._caseButton=Ta("Aa","Match Case"),this._wholeWordButton=Ta("ab","Match Whole Word","md-find-option-whole-word"),this._regexButton=Ta(".*","Use Regular Expression"),r.append(this._caseButton,this._wholeWordButton,this._regexButton),this._matchesCount=document.createElement("div"),this._matchesCount.className="md-find-count",this._matchesCount.setAttribute("role","status"),this._matchesCount.setAttribute("aria-live","polite"),i.appendChild(this._matchesCount),this._previousButton=qr("arrow-up","Previous Match"),this._nextButton=qr("arrow-down","Next Match"),this._selectionButton=qr("selection","Find in Selection");let s=qr("close","Close");i.append(this._previousButton,this._nextButton,this._selectionButton,s),this._error=document.createElement("div"),this._error.className="md-find-error",this._error.setAttribute("role","alert"),this.panelElement.appendChild(this._error);let o=()=>this._options.findModel.searchString.set(this._input.value,void 0),a=u=>{u.isComposing||u.key==="Enter"&&!u.ctrlKey&&!u.metaKey&&!u.altKey&&(u.preventDefault(),u.stopPropagation(),u.shiftKey?this._options.onPrevious():this._options.onNext())},l=u=>{u.key==="Escape"&&!u.isComposing&&(u.preventDefault(),u.stopPropagation(),this._options.onClose())},c=u=>u.stopPropagation(),d=()=>this.focused.set(!0,void 0),h=u=>{let f=u.relatedTarget;f instanceof Node&&this.panelElement.contains(f)||this.focused.set(!1,void 0)};this._input.addEventListener("input",o),this._input.addEventListener("keydown",a),this.panelElement.addEventListener("keydown",l),this.panelElement.addEventListener("pointerdown",c),this.panelElement.addEventListener("focusin",d),this.panelElement.addEventListener("focusout",h),this._register({dispose:()=>{this._input.removeEventListener("input",o),this._input.removeEventListener("keydown",a),this.panelElement.removeEventListener("keydown",l),this.panelElement.removeEventListener("pointerdown",c),this.panelElement.removeEventListener("focusin",d),this.panelElement.removeEventListener("focusout",h)}}),this._registerButton(this._caseButton,()=>this._options.findModel.matchCase.set(!this._options.findModel.matchCase.get(),void 0)),this._registerButton(this._wholeWordButton,()=>this._options.findModel.wholeWord.set(!this._options.findModel.wholeWord.get(),void 0)),this._registerButton(this._regexButton,()=>this._options.findModel.isRegex.set(!this._options.findModel.isRegex.get(),void 0)),this._registerButton(this._previousButton,this._options.onPrevious),this._registerButton(this._nextButton,this._options.onNext),this._registerButton(this._selectionButton,this._options.onToggleFindInSelection),this._registerButton(s,this._options.onClose),this._register(this._view.mountOverlay(this.element,"top-chrome")),this._register(this._view.registerRevealOcclusion(this.panelElement)),this._register(this._view.suspendEditContextWhileFocused(this.panelElement)),this._register(ee(u=>this._render(u)))}element;panelElement;focused=V(this,!1);_inputShell;_input;_matchesCount;_previousButton;_nextButton;_selectionButton;_caseButton;_wholeWordButton;_regexButton;_error;focusAndSelect(){this._input.focus({preventScroll:!0}),this._input.select()}_registerButton(e,n){e.addEventListener("click",n),this._register({dispose:()=>e.removeEventListener("click",n)})}_render(e){let n=this._options.findModel,i=n.isRevealed.read(e);if(!i&&this.panelElement.contains(this.panelElement.ownerDocument.activeElement)&&this._view.focus(),this.element.hidden=!i,this._view.element.classList.toggle("md-find-visible",i),!i)return;let r=n.searchString.read(e),s=n.matchCase.read(e),o=n.wholeWord.read(e),a=n.isRegex.read(e),l=n.searchScope.read(e),c=n.searchResult.read(e),d=n.currentMatchPosition.read(e),h=this._options.canFindInSelection.read(e)||l!==void 0;this._input.value!==r&&(this._input.value=r),jr(this._caseButton,s),jr(this._wholeWordButton,o),jr(this._regexButton,a),jr(this._selectionButton,l!==void 0),this._selectionButton.disabled=!i||!h;let u=c.kind==="valid"?c.matches.length:0,f=u>0,m=r.length>0;if(this._previousButton.disabled=!i||!f,this._nextButton.disabled=!i||!f,this.panelElement.classList.toggle("md-find-no-results",m&&!f&&c.kind==="valid"),!f)this._matchesCount.textContent="No results";else{let v=c.kind==="valid"&&c.isCapped?`${u}+`:String(u);this._matchesCount.textContent=`${d||"?"} of ${v}`}let p=c.kind==="invalid"?c.error.message:"";this._input.setAttribute("aria-invalid",String(p.length>0)),this._inputShell.classList.toggle("md-find-input-invalid",p.length>0),this._input.title=p,this._error.textContent=p,this._error.hidden=p.length===0}};function Ta(t,e,n){let i=document.createElement("button");return i.type="button",i.className="md-find-button md-find-option",n&&i.classList.add(n),i.textContent=t,i.setAttribute("aria-label",e),i.title=e,i.setAttribute("aria-pressed","false"),i}function qr(t,e){let n=document.createElement("button");n.type="button",n.className="md-find-button",n.setAttribute("aria-label",e),n.title=e;let i=document.createElement("span");return i.className=`codicon codicon-${t}`,i.setAttribute("aria-hidden","true"),n.appendChild(i),n}function jr(t,e){t.setAttribute("aria-pressed",String(e)),t.classList.toggle("md-find-option-active",e)}var Pl=class extends pe{constructor(e,n,i){super(),this._editorModel=e,this._view=n,this._options=i,this._observedSourceTextId=this._editorModel.getSourceTextId(this._editorModel.sourceText.get()),this._sourceEditTracker=new Rs(this._editorModel),this.model=this._register(new Ml(this._editorModel)),this._register(this._editorModel.onWillApplySourceEdit(a=>{this._sourceEditTracker.record(a)}));let r=re(this,a=>{let l=this._selectionForScope.read(a);return!!l&&!l.isCollapsed});this.widget=this._register(new Al(this._view,{findModel:this.model,canFindInSelection:r,onNext:()=>{this.model.moveToNextMatch()},onPrevious:()=>{this.model.moveToPreviousMatch()},onToggleFindInSelection:()=>this._toggleFindInSelection(),onClose:()=>this.close()})),this._register(new Ll(this._view,this.model));let s=a=>this._handleKeyDown(a);this._view.element.addEventListener("keydown",s,!0),this._register({dispose:()=>this._view.element.removeEventListener("keydown",s,!0)}),this._register(ee(a=>{let l=this.widget.focused.read(a);this._view.element.classList.toggle("md-find-widget-focused",l)}));let o=this._editorModel.selection.get();this._register(ee(a=>{let l=this._editorModel.sourceText.read(a),c=this._editorModel.selection.read(a),d=this._sourceEditTracker.consume(l),h=c!==o;if(o=c,!h)return;let u=this.model.currentMatch.get();!c||u&&c.range.equals(u)||(this._selectionForScope.set(c,void 0),this.model.setSearchOrigin(c.active),d.isExpected||this.model.currentMatch.set(void 0,void 0))})),this._register(ee(a=>{let l=this._editorModel.sourceText.read(a),c=this._editorModel.getSourceTextId(l),d=c!==this._observedSourceTextId,h=this.model.isRevealed.read(a),u=this.model.currentMatch.read(a);this._view.element.classList.toggle("md-find-has-current-match",h&&u!==void 0);let f=this._editorModel.document.read(a),m=this._view.documentViewNode.read(a);if(!h||!u){this._forcedMatch=void 0,this._selectedMatch=void 0,this._observedSourceTextId=c,this._cancelRevealRequest(),this._setForcedMarkerVisibleBlocks(new Set);return}let p=!this._selectedMatch?.equals(u),v=new Set;this._forcedMatch?.equals(u)?v=new Set(Wa(f,u.start,u.endExclusive)):m&&fw(m,u)?this._forcedMatch=void 0:(v=new Set(Wa(f,u.start,u.endExclusive)),this._forcedMatch=u),Ce(g=>{Iu(this._view.forcedMarkerVisibleBlocks.get(),v)||this._view.forcedMarkerVisibleBlocks.set(v,g);let w=this._editorModel.selection.get();p&&!d&&(!w||!w.range.equals(u))&&(this._editorModel.pendingParagraph.set(void 0,g),this._editorModel.selectionSource.set("find",g),this._editorModel.selection.set(new $(u.start,u.endExclusive),g))}),this._selectedMatch=u,this._observedSourceTextId=c,p&&!d&&(this._cancelRevealRequest(),this._revealRequest=this._view.revealRangeInCenterIfOutsideViewport(u,"auto"))})),this._register({dispose:()=>{this._cancelRevealRequest(),this._view.element.classList.remove("md-find-visible","md-find-widget-focused","md-find-has-current-match"),this._view.forcedMarkerVisibleBlocks.set(new Set,void 0)}})}model;widget;_selectionForScope=V(this,void 0);_forcedMatch;_selectedMatch;_observedSourceTextId;_sourceEditTracker;_revealRequest;_setForcedMarkerVisibleBlocks(e){Iu(this._view.forcedMarkerVisibleBlocks.get(),e)||this._view.forcedMarkerVisibleBlocks.set(e,void 0)}openAndFocus(){if(this.model.isRevealed.get()){this.widget.focusAndSelect();return}let e=this._editorModel.selection.get()??$.collapsed(0);this._selectionForScope.set(e,void 0);let{searchString:n,origin:i}=this._querySeed(e,this.model.searchString.get());this.model.reveal({origin:i,searchString:n,direction:"next"}),this.widget.focusAndSelect()}close(){this.model.isRevealed.get()&&(this._cancelRevealRequest(),this.model.hide(),this._view.focus())}_handleKeyDown(e){if(e.isComposing||e.getModifierState("AltGraph"))return;let n=e.target,i=n instanceof Node&&this.widget.panelElement.contains(n);if(!(n!==this._view.element&&!i)){if(hw(e,this._options.keyboardPlatform)){Oa(e),this.openAndFocus();return}if(e.key==="F3"&&!e.altKey&&!e.ctrlKey&&!e.metaKey){Oa(e),this._findByKeyboard(e.shiftKey?"previous":"next");return}e.key==="Escape"&&this.model.isRevealed.get()&&(Oa(e),this.close())}}_cancelRevealRequest(){this._revealRequest?.dispose(),this._revealRequest=void 0}_findByKeyboard(e){if(this.model.isRevealed.get()){e==="next"?this.model.moveToNextMatch():this.model.moveToPreviousMatch();return}let n=this._editorModel.selection.get()??$.collapsed(0);this._selectionForScope.set(n,void 0);let i=this.model.searchString.get()||this._querySeed(n).searchString,r=e==="next"?n.range.endExclusive:n.range.start;this.model.reveal({origin:r,searchString:i,direction:e})}_querySeed(e,n){let i=this._selectedSingleLineText(e);if(i)return{searchString:this._prepareSeed(i),origin:e.range.start};if(n)return{searchString:n,origin:e.active};let r=this._editorModel.sourceText.get().value,s=No(r,e.active,this._editorModel.wordNavigationConfig.get()),o=r.slice(s.start,s.end);return{searchString:/\S/u.test(o)?this._prepareSeed(o):"",origin:s.start}}_prepareSeed(e){return this.model.isRegex.get()?zh(e):e}_selectedSingleLineText(e){if(e.isCollapsed)return;let n=e.range.substring(this._editorModel.sourceText.get().value);return n.includes(`
`)||n.length===0?void 0:n}_toggleFindInSelection(){if(this.model.searchScope.get()){this.model.setSearchScope(void 0);return}let e=this._selectionForScope.get();!e||e.isCollapsed||(this.model.setSearchOrigin(e.range.start),this.model.setSearchScope(e.range))}};function hw(t,e){return t.key.toLowerCase()==="f"&&!t.shiftKey&&!t.altKey&&(e==="macos"?t.metaKey&&!t.ctrlKey:t.ctrlKey&&!t.metaKey)}function Oa(t){t.preventDefault(),t.stopPropagation()}function Iu(t,e){return t.size===e.size&&Array.from(t).every(n=>e.has(n))}function fw(t,e){let n=qs(t,[e]);return e.isEmpty?n.some(i=>Mu(i.range)):n.reduce((i,r)=>{let s=Array.from(r.range.getClientRects()).some(o=>o.width>0&&o.height>0)&&Mu(r.range);return i+(s?r.sourceRange.length:0)},0)===e.length}function Mu(t){let e=t.startContainer.ownerDocument;if(!e)return!1;let n=e.defaultView??window;for(let i=t.startContainer instanceof Element?t.startContainer:t.startContainer.parentElement;i;i=i.parentElement){let r=n.getComputedStyle(i);if(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse")return!1}return!0}var Fl=class{connect(e){let n=o=>{if(Hr(o.target,e.element))return;let a=e.getSelectedText();a!==void 0&&(o.preventDefault(),o.clipboardData?.setData("text/plain",a))},i=o=>{if(Hr(o.target,e.element))return;let a=e.getSelectedText();a!==void 0&&(o.preventDefault(),o.clipboardData?.setData("text/plain",a),e.deleteSelection())},r=o=>{if(Hr(o.target,e.element))return;o.preventDefault();let a=o.clipboardData?.getData("text/plain");a&&e.insertText(a)},s=e.element;return s.addEventListener("copy",n),s.addEventListener("cut",i),s.addEventListener("paste",r),{dispose:()=>{s.removeEventListener("copy",n),s.removeEventListener("cut",i),s.removeEventListener("paste",r)}}}},Ls=class{constructor(e=navigator.clipboard){this._clipboard=e}connect(e){let n=r=>{if(!(r.ctrlKey||r.metaKey)||r.altKey)return;let s=Hr(r.target,e.element);if(s){mw(r,s,this._clipboard);return}switch(r.key.toLowerCase()){case"c":{let o=e.getSelectedText();if(o===void 0)return;r.preventDefault(),this._clipboard.writeText(o);break}case"x":{let o=e.getSelectedText();if(o===void 0)return;r.preventDefault(),this._clipboard.writeText(o),e.deleteSelection();break}case"v":{r.preventDefault(),this._clipboard.readText().then(o=>{o&&e.insertText(o)});break}}},i=e.element;return i.addEventListener("keydown",n),{dispose:()=>i.removeEventListener("keydown",n)}}};function Hr(t,e){if(!(t instanceof Node)||t===e)return;let n=(t instanceof Element?t:t.parentElement)?.closest('input, textarea, [contenteditable]:not([contenteditable="false"]), [role="textbox"]');return n instanceof HTMLElement&&e.contains(n)?n:void 0}function mw(t,e,n){switch(t.key.toLowerCase()){case"c":{let i=Nu(e);if(i===void 0)return;t.preventDefault(),n.writeText(i);return}case"x":{let i=Nu(e);if(i===void 0)return;t.preventDefault(),n.writeText(i),Au(e,"");return}case"v":t.preventDefault(),n.readText().then(i=>{i.length>0&&Au(e,i)})}}function Nu(t){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let n=t.selectionStart,i=t.selectionEnd;return n===null||i===null||n===i?void 0:t.value.slice(n,i)}let e=t.ownerDocument.getSelection();if(!(!e||e.isCollapsed||e.rangeCount===0||!t.contains(e.getRangeAt(0).commonAncestorContainer)))return e.toString()}function Au(t,e){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let s=t.selectionStart??t.value.length,o=t.selectionEnd??s;t.setRangeText(e,s,o,"end"),t.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:e.length===0?"deleteByCut":"insertFromPaste",data:e}));return}let n=t.ownerDocument.getSelection();if(!n||n.rangeCount===0||!t.contains(n.getRangeAt(0).commonAncestorContainer))return;let i=n.getRangeAt(0);i.deleteContents();let r=t.ownerDocument.createTextNode(e);i.insertNode(r),i.setStartAfter(r),i.collapse(!0),n.removeAllRanges(),n.addRange(i),t.dispatchEvent(new InputEvent("input",{bubbles:!0,inputType:e.length===0?"deleteByCut":"insertFromPaste",data:e}))}var $l={bindings:En.flatMap(t=>t.keybindings.map(e=>({...e,action:t.action})))},Eh={bindings:En.filter(t=>t.routing==="local").flatMap(t=>t.keybindings.map(e=>({...e,action:t.action})))},Ch={bindings:En.filter(t=>t.routing!=="local").flatMap(t=>t.keybindings.map(e=>({...e,action:t.action})))},pw=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End"]);function gw(t){return pw.has(t)}function vw(t){return t.includes("Macintosh")||t.includes("Mac OS X")?"macos":t.includes("Windows")?"windows":"linux"}function Pu(t){return{key:t.key,code:t.code,shiftKey:t.shiftKey,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altGraphKey:t.getModifierState("AltGraph")}}function Fu(t,e,n=$l){if(t.altGraphKey)return;let i=t.key.length===1?t.key.toLowerCase():t.key,r=/^[a-z]$/.test(i)?void 0:bw(t.code);for(let s of n.bindings)if((s.key===i||s.key===r)&&(!s.platforms||s.platforms.includes(e))&&_w(t,s.modifiers))return s.action}function bw(t){return/^Key([A-Z])$/.exec(t)?.[1].toLowerCase()}function _w(t,e={}){return t.shiftKey===!!e.shift&&t.altKey===!!e.alt&&t.ctrlKey===!!e.ctrl&&t.metaKey===!!e.meta}var ww=500,$u=5,Is=class extends pe{constructor(e,n,i){super(),this._model=e,this._view=n;let r=this._view.element,s=r.ownerDocument.defaultView??window;this._keyboardPlatform=i?.keyboardPlatform??vw(s.navigator.userAgent),this._keyboardProfile=i?.keyboardProfile??$l,this._forwardedKeyboardProfile=i?.forwardedKeyboardProfile,this._historyStrategy=i?.historyStrategy,this._indentation=i?.indentation??Di,this._tabFocusStatus=this._keyboardProfile===$l?this._registerTabFocusAccessibility(r):void 0,r.addEventListener("pointerdown",this._handlePointerDown),r.addEventListener("keydown",this._handleKeyDown),this._register({dispose:()=>{r.removeEventListener("pointerdown",this._handlePointerDown),r.removeEventListener("keydown",this._handleKeyDown)}}),s.addEventListener("keydown",this._updateModifierState),s.addEventListener("keyup",this._updateModifierState),s.addEventListener("blur",this._clearModifierState),r.ownerDocument.addEventListener("selectionchange",this._discardNativeSelection),this._register({dispose:()=>{s.removeEventListener("keydown",this._updateModifierState),s.removeEventListener("keyup",this._updateModifierState),s.removeEventListener("blur",this._clearModifierState),r.ownerDocument.removeEventListener("selectionchange",this._discardNativeSelection)}});let o=i?.clipboardStrategy??new Fl;this._register(o.connect({element:r,getSelectedText:()=>this._selectedText(),deleteSelection:()=>this._executeEditCommand(cu),insertText:l=>{this._handlePendingInput(l)||this._executeEditCommand(Sb(l))}}));let a=this._view.editContext;a.addEventListener("textupdate",this._handleTextUpdate),this._register({dispose:()=>a.removeEventListener("textupdate",this._handleTextUpdate)}),this.findController=i?.find===!1?void 0:this._register(new Pl(this._model,this._view,{keyboardPlatform:this._keyboardPlatform}))}findController;_desiredColumn;_keyboardPlatform;_keyboardProfile;_forwardedKeyboardProfile;_historyStrategy;_indentation;_tabFocusStatus;_tabMovesFocus=!1;_clickCount=0;_lastPointerDown;_handleTextUpdate=e=>{if(this._model.readonlyMode.get()){e.text.length>0&&this._view.showReadonlyEditingAttempt();return}if(this._model.pendingParagraph.get()!==void 0){e.text.length>0?this._handlePendingInput(e.text):this._model.cancelPendingParagraph();return}let n=H.replace(new O(e.updateRangeStart,e.updateRangeEnd),e.text);this._runUndoableEdit(()=>this._model.applyEdit(n),n)};_handlePendingInput(e){let n=this._model.pendingParagraph.get();return n?(e.length===0||(/^[ \t]+$/.test(e)?this._model.setPendingParagraphText(n.text+e):this._runUndoableEdit(()=>this._model.materializePendingParagraph(e))),!0):!1}_deletePendingText(e){let n=this._model.pendingParagraph.get();if(n){if(n.text.length===0){this._model.cancelPendingParagraph();return}this._model.setPendingParagraphText(e==="deleteLeft"?n.text.slice(0,-1):"")}}_handlePointerDown=e=>{if(e.button!==0)return;e.preventDefault(),this._model.cancelPendingParagraph(),this._view.focus(),this._desiredColumn=void 0;let n=new vn(e.clientX,e.clientY),i=this._lastPointerDown,r=i!==void 0&&e.timeStamp-i.time<ww&&Math.abs(n.x-i.point.x)<$u&&Math.abs(n.y-i.point.y)<$u;if(this._clickCount=r?this._clickCount+1:1,this._lastPointerDown={time:e.timeStamp,point:n},!this._view.isPointInContent(n)){this._setUserSelection(void 0);return}let s=this._view.resolveOffsetFromPoint(n)??this._model.sourceText.get().value.length;if(this._clickCount===2){let h=this._makeCursorContext();this._setUserSelection(Ub(h,s));return}if(this._clickCount===3){let h=kw(this._model.document.get(),s);h&&this._setUserSelection(Zb(this._makeCursorContext(),h));return}let o=this._clickCount===1&&!e.shiftKey&&this._model.readonlyMode.get();if(e.shiftKey){let h=this._model.selection.get()??$.collapsed(s);this._setUserSelection(h.withActive(s))}else this._setUserSelection($.collapsed(s));let a=this._view.element,l=e.pointerId;a.setPointerCapture(l),this._model.isSelecting.set(!0,void 0);let c=h=>{let u=this._model.selection.get()??$.collapsed(s),f=this._view.resolveOffsetFromPoint(new vn(h.clientX,h.clientY))??u.active;this._setUserSelection(new $(u.anchor,f))},d=()=>{this._model.isSelecting.set(!1,void 0),o&&(this._model.selection.get()?.isCollapsed??!0)&&this._view.showReadonlyEditingAttempt(),a.removeEventListener("pointermove",c),a.removeEventListener("pointerup",d),a.removeEventListener("pointercancel",d),a.removeEventListener("lostpointercapture",d)};a.addEventListener("pointermove",c),a.addEventListener("pointerup",d),a.addEventListener("pointercancel",d),a.addEventListener("lostpointercapture",d)};_makeCursorContext(){let e=this._model.activeBlock.get(),n=this._model.selection.get()??$.collapsed(0);return{text:this._model.sourceText.get().value,selection:n,document:this._model.document.get(),activeBlock:e,markerVisibleBlocks:this._model.markerVisibleBlocks.get(),wordNavigationConfig:this._model.wordNavigationConfig.get(),cursorPosition:this._model.cursorPosition.get()??ue.source(n.active)}}_makeVisualCursorContext(){return{...this._makeCursorContext(),desiredColumn:this._desiredColumn,lineMap:this._view.measuredLayout.visualLineMap.get()}}_executeCursorCommand(e,n){let i=this._makeCursorContext();this._applyCursorPosition(i.selection,e(i),n),this._desiredColumn=void 0}_executeEditCommand(e){if(this._model.readonlyMode.get()){this._view.showReadonlyEditingAttempt();return}let n=this._makeCursorContext(),i=e(n);i&&(this._runUndoableEdit(()=>this._model.applyEdit(i.edit,i.selection),i.edit),this._desiredColumn=void 0)}_runUndoableEdit(e,n){let i=this._historyStrategy;i?.record?i.record(e,n):e()}_executeVisualCursorCommand(e,n){let i=this._makeVisualCursorContext(),r=e(i);this._applyCursorPosition(i.selection,r.position,n),this._desiredColumn=r.desiredColumn}_cursorDown(e){let n=this._makeVisualCursorContext(),i=gb(n);if(!e&&!this._model.readonlyMode.get()&&!n.lineMap.isEmpty&&n.cursorPosition.kind==="source"&&i.position.kind==="source"&&i.position.offset===n.selection.active){let r=Vi(n);if(r){this._model.armPendingParagraph(r),this._desiredColumn=void 0;return}}this._applyCursorPosition(n.selection,i.position,e),this._desiredColumn=i.desiredColumn}_setUserSelection(e){Ce(n=>{this._model.pendingParagraph.set(void 0,n),this._model.selectionSource.set("user",n),this._model.selection.set(e,n)})}_applyCursorPosition(e,n,i){if(n.kind==="virtual"){if(this._model.pendingParagraph.get()?.cursorLine!==n.line){let r=n.line.sourceOffsetBefore;this._setUserSelection(i?e.withActive(r):$.collapsed(r))}return}this._setUserSelection(i?e.withActive(n.offset):$.collapsed(n.offset))}cursorDown(e=!1){this._cursorDown(e)}cursorUp(e=!1){this._executeVisualCursorCommand(lu,e)}_selectedText(){let e=this._model.selection.get();if(!(!e||e.isCollapsed))return this._model.sourceText.get().value.slice(e.range.start,e.range.endExclusive)}_updateModifierState=e=>{this._model.ctrlOrMetaDown.set(e.ctrlKey||e.metaKey,void 0)};_clearModifierState=()=>{this._model.ctrlOrMetaDown.set(!1,void 0)};_discardNativeSelection=()=>{let e=this._view.element.ownerDocument;if(!this._view.element.contains(e.activeElement))return;let n=e.getSelection();if(!(!n||n.rangeCount===0||n.isCollapsed)){for(let i=0;i<n.rangeCount;i++)if(this._view.intersectsRenderedContent(n.getRangeAt(i))){n.removeAllRanges();return}}};_handleKeyDown=e=>{if(e.isComposing||yw(e,this._view.element)||(this._updateModifierState(e),e.key==="Tab"&&(this._model.readonlyMode.get()||this._tabMovesFocus)))return;if(this._model.pendingParagraph.get()!==void 0&&e.key==="Escape"){Bu(e),this._model.cancelPendingParagraph();return}let n=Fu(Pu(e),this._keyboardPlatform,this._keyboardProfile);if(!n){if(this._forwardedKeyboardProfile&&Fu(Pu(e),this._keyboardPlatform,this._forwardedKeyboardProfile)){e.preventDefault();return}gw(e.key)&&e.preventDefault();return}let i=this._model.pendingParagraph.get()!==void 0;n.kind==="history"&&!i&&!this._historyStrategy||(Bu(e),this._executeKeyboardAction(n))};executeCommand(e){this._executeKeyboardAction(e.action)}_executeKeyboardAction(e){switch(e.kind){case"cursor":{let n=e.command;switch(n){case"left":this._executeCursorCommand(e.extend?cb:ab,e.extend);return;case"right":this._executeCursorCommand(e.extend?lb:ob,e.extend);return;case"up":this._executeVisualCursorCommand(lu,e.extend);return;case"down":this._cursorDown(e.extend);return;case"wordLeft":this._executeCursorCommand(ub,e.extend);return;case"wordRight":this._executeCursorCommand(db,e.extend);return;case"visualLineStart":this._executeVisualCursorCommand(mb,e.extend);return;case"visualLineEnd":this._executeVisualCursorCommand(pb,e.extend);return;case"logicalLineStart":this._executeCursorCommand(Ka,e.extend);return;case"logicalLineEnd":this._executeCursorCommand(Ua,e.extend);return;case"documentStart":this._executeCursorCommand(hb,e.extend);return;case"documentEnd":this._executeCursorCommand(fb,e.extend);return;default:return Vn(n)}}case"edit":{let n=e.command;if(this._model.pendingParagraph.get()!==void 0){if(n==="deleteLeft"||n==="deleteWordLeft"||n==="deleteLineLeft"){this._deletePendingText(n);return}this._model.cancelPendingParagraph();return}switch(n){case"deleteLeft":this._executeEditCommand(cu);return;case"deleteRight":this._executeEditCommand(_b);return;case"deleteWordLeft":this._executeEditCommand(wb);return;case"deleteWordRight":this._executeEditCommand(yb);return;case"deleteLineLeft":this._executeEditCommand(kb);return;case"deleteLineRight":this._executeEditCommand(xb);return;default:return Vn(n)}}case"selectAll":{let n=this._makeCursorContext();this._setUserSelection(Kb(n));return}case"history":{if(this._model.pendingParagraph.get()!==void 0){e.command==="undo"&&this._model.cancelPendingParagraph();return}if(this._model.readonlyMode.get())return;let n=this._historyStrategy;if(!n)return;let i=e.command;switch(i){case"undo":n.undo();return;case"redo":n.redo();return;default:return Vn(i)}}case"tab":{let n=this._model.pendingParagraph.get();if(n!==void 0){e.command==="insert"?this._model.setPendingParagraphText(n.text+eh(n.text,this._indentation)):this._model.setPendingParagraphText(th(n.text,this._indentation));return}let i=e.command;switch(i){case"insert":this._executeEditCommand(zb(this._indentation));return;case"outdent":this._executeEditCommand(Eb(this._indentation));return;default:return Vn(i)}}case"toggleTabFocus":{if(this._model.cancelPendingParagraph(),this._model.readonlyMode.get()){this._tabFocusStatus&&(this._tabFocusStatus.textContent="Tab always moves focus while the document is locked.");return}this._tabMovesFocus=!this._tabMovesFocus,this._tabFocusStatus&&(this._tabFocusStatus.textContent=this._tabMovesFocus?"Tab now moves focus. Press Control+M to make Tab insert indentation.":"Tab now inserts indentation. Press Control+M to make Tab move focus.");return}case"enter":{if(this._model.pendingParagraph.get()!==void 0){this._model.readonlyMode.get()&&this._view.showReadonlyEditingAttempt(),this._desiredColumn=void 0;return}let n=e.command;switch(n){case"smartEnter":this._smartEnter();return;case"insertParagraph":this._executeEditCommand(Cb);return;case"insertHardLineBreak":this._executeEditCommand(Ob);return;default:return Vn(n)}}default:return Vn(e)}}_smartEnter(){if(this._model.readonlyMode.get()){this._view.showReadonlyEditingAttempt();return}let e=this._makeCursorContext(),n=Rb(e);n.kind==="edit"?this._runUndoableEdit(()=>this._model.applyEdit(n.edit,n.selection),n.edit):this._model.armPendingParagraph({anchorBlock:n.anchorBlock,replaceRange:n.replaceRange,separateFromPreviousBlock:n.separateFromPreviousBlock,atEof:n.atEof}),this._desiredColumn=void 0}_registerTabFocusAccessibility(e){let n=e.getAttribute("aria-description"),i=e.getAttribute("aria-keyshortcuts");e.setAttribute("aria-description","Press Control+M to toggle whether Tab inserts indentation or moves focus. While locked, Tab always moves focus."),e.setAttribute("aria-keyshortcuts","Control+M");let r=e.ownerDocument.createElement("span");return r.className="md-editor-a11y-status",r.setAttribute("aria-live","polite"),e.ownerDocument.body.appendChild(r),this._register({dispose:()=>{r.remove(),Du(e,"aria-description",n),Du(e,"aria-keyshortcuts",i)}}),r}};function Vn(t){throw new Error(`Unhandled keyboard action: ${JSON.stringify(t)}`)}function Bu(t){t.preventDefault(),t.stopPropagation()}function yw(t,e){return t.target!==e}function kw(t,e){let n=new Set(t.blocks),i=0;for(let r of t.children){if(n.has(r)){let s=O.ofStartAndLength(i,r.length);if(s.contains(e)||s.endExclusive===e)return s}i+=r.length}}function Du(t,e,n){n===null?t.removeAttribute(e):t.setAttribute(e,n)}var xw='<svg viewBox="0 0 16 16" width="16" height="16" fill="currentColor" aria-hidden="true"><path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"></path></svg>',Bl=class extends pe{constructor(e){super(),this._options=e,this.element=document.createElement("div"),this.element.className="md-comment-input",this._textarea=document.createElement("textarea"),this._textarea.className="md-comment-input-textarea",this._textarea.rows=1,this._textarea.placeholder=e?.placeholder??"Add Comment",this.element.appendChild(this._textarea),this._measure=document.createElement("span"),this._measure.className="md-comment-input-measure",this._measure.setAttribute("aria-hidden","true"),this.element.appendChild(this._measure);let n=document.createElement("div");n.className="md-comment-input-actions",this.element.appendChild(n),this._submitButton=document.createElement("button"),this._submitButton.type="button",this._submitButton.className="md-comment-input-submit",this._submitButton.innerHTML=xw,this._submitButton.title="Comment",n.appendChild(this._submitButton);let i=a=>{a.stopPropagation(),!(a.target===this._textarea||this._submitButton.contains(a.target))&&(a.preventDefault(),this._textarea.focus())};this.element.addEventListener("pointerdown",i),this._register({dispose:()=>this.element.removeEventListener("pointerdown",i)});let r=()=>{this._value.set(this._textarea.value,void 0),this._autoSize()};this._textarea.addEventListener("input",r),this._register({dispose:()=>this._textarea.removeEventListener("input",r)});let s=a=>{if(a.stopPropagation(),a.key==="Escape"){a.preventDefault(),this._options?.onCancel?.();return}a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),this._submit())};this._textarea.addEventListener("keydown",s),this._register({dispose:()=>this._textarea.removeEventListener("keydown",s)});let o=()=>this._submit();this._submitButton.addEventListener("click",o),this._register({dispose:()=>this._submitButton.removeEventListener("click",o)}),this._register(ee(a=>{let l=this._value.read(a).trim().length>0;this._submitButton.disabled=!l,this.element.classList.toggle("md-comment-input-empty",!l)})),this._autoSize()}element;_textarea;_measure;_submitButton;_value=V(this,"");get value(){return this._value}get inputElement(){return this._textarea}focus(){this._textarea.focus();let e=this._textarea.value.length;this._textarea.setSelectionRange(e,e)}setText(e){this._textarea.value=e,this._value.set(e,void 0),this._autoSize()}clear(){this.setText("")}_submit(){let e=this._textarea.value.trim();e&&this._options?.onSubmit?.(e)}_autoSize(){let e=this._textarea.value||this._textarea.placeholder;this._measure.textContent=e;let n=this._measure.scrollWidth,i=Math.min(Math.max(150,n+10),400);this._textarea.style.width=`${i}px`,this._textarea.style.height="auto";let r=this._textarea.scrollHeight;r>0&&(this._textarea.style.height=`${r}px`),this._options?.onDidChangeSize?.()}},Ms=class t extends pe{constructor(e,n,i){super(),this._model=e,this._view=n,this._options=i,this._gap=i?.gap??8,this._widget=this._register(new Bl({onDidChangeSize:()=>{this._visible&&this._layoutHorizontally()},onSubmit:d=>this._submit(d),onCancel:()=>this._hideAndRefocus()}));let r=this._widget.element;r.style.position="absolute",r.style.zIndex="20",r.style.display="none",this._view.overlayContainer.appendChild(r),this._register({dispose:()=>r.remove()}),this._register({dispose:()=>this._view.element.classList.remove("md-comment-active")});let s=new ResizeObserver(()=>{this._visible&&this._layoutHorizontally()});s.observe(r),s.observe(this._view.overlayContainer),this._register({dispose:()=>s.disconnect()}),this._register(ee(d=>this._update(d)));let o=this._view.element.ownerDocument,a=()=>{this._view.element.classList.add("md-comment-active")};this._widget.inputElement.addEventListener("focus",a),this._register({dispose:()=>this._widget.inputElement.removeEventListener("focus",a)});let l=()=>{this._view.element.classList.remove("md-comment-active"),o.defaultView?.setTimeout(()=>this._autoHide(),0)};this._widget.inputElement.addEventListener("blur",l),this._register({dispose:()=>this._widget.inputElement.removeEventListener("blur",l)});let c=d=>{d.key!=="Tab"||d.shiftKey||d.ctrlKey||d.metaKey||d.altKey||!this._visible||this._widgetHasFocus()||(d.preventDefault(),this._widget.focus())};this._view.element.addEventListener("keydown",c),this._register({dispose:()=>this._view.element.removeEventListener("keydown",c)})}static _isCommentableSelectionSource(e){switch(e){case"user":return!0;case"find":return!1;default:return Sw(e)}}_widget;_gap;_visible=!1;_anchorX=0;_pinnedRange;_submittedRange;_update(e){let n=this._model.readonlyMode.read(e),i=this._model.selection.read(e),r=this._model.selectionSource.read(e),s=this._view.caretRect.read(e),o=this._model.isSelecting.read(e),a=this._widget.value.read(e).trim().length>0;if(!n){this._hide();return}if(!t._isCommentableSelectionSource(r)){this._autoHide();return}if(!(this._visible&&(a||this._widgetHasFocus()))){if(o){this._autoHide();return}if(!i||i.isCollapsed||!s){this._autoHide();return}if(this._submittedRange?.equals(i.range)){this._autoHide();return}this._submittedRange=void 0,this._pinnedRange=i.range,this._show(s,!i.isForward)}}_show(e,n){let i=this._widget.element;i.style.display="",this._visible=!0;let r=i.offsetHeight,s=this._getViewportRect(),o=this._view.coordinateSpace.capture(),a=o.toClientRect(e),l=o.toClientRect(ne.fromPointSize(0,0,0,r)).height,c=o.toClientRect(ne.fromPointSize(0,0,0,this._gap)).height,d=a.top,h=a.bottom+c+l<=s.bottom,u=d-c-l>=s.top,f=(n?u||!h:!h&&u)?e.y-this._gap-r:e.y+e.height+this._gap;this._anchorX=e.x,this._layoutHorizontally(),i.style.top=`${f}px`}_layoutHorizontally(){let e=this._widget.element,n=this._view.overlayContainer.clientWidth;e.style.maxWidth=`${Math.max(0,n-this._gap)}px`;let i=Math.max(0,n-e.offsetWidth-this._gap);e.style.left=`${Math.min(Math.max(0,this._anchorX),i)}px`}_hide(){this._visible&&(this._visible=!1,this._pinnedRange=void 0,this._widget.clear(),this._widget.element.style.display="none",this._view.element.classList.remove("md-comment-active"))}_autoHide(){this._widgetHasFocus()||this._widget.value.get().trim().length>0||this._hide()}_widgetHasFocus(){let e=this._view.element.ownerDocument.activeElement;return e!==null&&this._widget.element.contains(e)}_getViewportRect(){let e=this._view.element.ownerDocument.defaultView,n=this._view.element;for(;n;){let i=e?.getComputedStyle(n).overflowY;if((i==="auto"||i==="scroll")&&n.scrollHeight>n.clientHeight){let r=n.getBoundingClientRect();return{top:r.top,bottom:r.bottom}}n=n.parentElement}return{top:0,bottom:e?.innerHeight??0}}_hideAndRefocus(){this._hide(),this._view.focus()}_submit(e){let n=this._pinnedRange;this._submittedRange=n,this._hideAndRefocus(),n&&this._options?.onSubmit?.({text:e,range:n})}};function Sw(t){throw new Error(`Unhandled selection source: ${JSON.stringify(t)}`)}var Ns=class{_comments=V(this,[]);_sequence=0;get comments(){return this._comments}hoveredId=V(this,void 0);set(e){this._comments.set(e,void 0)}create(e){let n={id:`comment-${++this._sequence}`,range:e.range,body:e.body,author:e.author,createdAt:Date.now()};return this.add(n),n}add(e){this._comments.set([...this._comments.get(),e],void 0)}remove(e){this._comments.set(this._comments.get().filter(n=>n.id!==e),void 0)}};var zw=12,Ew=8;function Cw(t,e){let n=t.element,i=t.overlayContainer,r=n.clientWidth-Ew-i.offsetLeft,s=[];for(let a of e){if(a.rects.length===0){a.element.style.visibility="hidden";continue}a.element.style.visibility="",s.push({element:a.element,y:Math.min(...a.rects.map(l=>l.y))})}s.sort((a,l)=>a.y-l.y);let o=-1/0;for(let a of s){let l=Math.max(a.y,o+zw),c=r-a.element.offsetWidth;a.element.style.left=`${c}px`,a.element.style.top=`${l}px`,o=l+a.element.offsetHeight}}var Dl=class extends pe{constructor(e,n,i){super(),this.model=e,this.view=n,this.context=i,this._layer=document.createElement("div"),this._layer.className=i?.theme==="light"?"vscode-comments-light":"vscode-comments-dark",this._layer.style.position="absolute",this._layer.style.inset="0",this._layer.style.pointerEvents="none",this._layer.style.overflow="visible",this._layer.style.background="transparent",this.view.overlayContainer.appendChild(this._layer),this._register({dispose:()=>{for(let s of this._entries.values())s.widget.dispose();this._entries.clear(),this._layer.remove()}}),this._register(ee(s=>{let o=this.model.comments.read(s);this._reconcile(o);for(let a of o)this._entries.get(a.id).rects.read(s);this._relayout()}));let r=new ResizeObserver(()=>this._relayout());r.observe(this.view.element),this._register({dispose:()=>r.disconnect()})}_layer;_entries=new Map;_order=[];_pendingRevealCommentId;revealComment(e){this._pendingRevealCommentId=e,this._revealPendingComment()}_reconcile(e){this._order=e.map(i=>i.id);let n=new Set(this._order);for(let i of e){if(this._entries.has(i.id))continue;let r=this.createWidget(i);r.element.style.position="absolute",r.element.style.pointerEvents="auto",this._layer.appendChild(r.element),this._entries.set(i.id,{widget:r,rects:this.view.rangeRects(i.range)})}for(let[i,r]of this._entries)n.has(i)||(r.widget.dispose(),this._entries.delete(i))}_relayout(){let e=this._order.map(n=>this._entries.get(n)).filter(n=>n!==void 0).map(n=>({element:n.widget.element,rects:n.rects.get()}));Cw(this.view,e),this._revealPendingComment()}_revealPendingComment(){let e=this._pendingRevealCommentId;if(!e)return;let n=this._entries.get(e)?.widget.element;!n||n.style.visibility==="hidden"||(this._pendingRevealCommentId=void 0,n.scrollIntoView({block:"center",inline:"nearest"}))}};function qn(t){return`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var nM={comment:qn('<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>'),"comment-discussion":qn('<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"></path>'),"chevron-down":qn('<polyline points="6 9 12 15 18 9"></polyline>'),"chevron-up":qn('<polyline points="18 15 12 9 6 15"></polyline>'),edit:qn('<path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>'),close:qn('<line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>')};var Tw=/^([a-z0-9]+)/i;function jn(t){let e=Tw.exec(t)?.[1]??"div",n=document.createElement(e),i=t.slice(e.length).split(".").filter(Boolean);return i.length&&(n.className=i.join(" ")),n}function Vu(t){return`<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${t}</svg>`}var Ow={edit:Vu('<path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>'),trash:Vu('<polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line>')};function Rw(t,e){let n=document.createElement("button");return n.type="button",n.className="vscode-comment-widget-v2-action",n.setAttribute("aria-label",e),n.title=e,n.innerHTML=Ow[t]??"",n}var Vl=class{_domNode;_textNode;_toggleNode;_onToggle;_state;_disposables=[];_onToggleClick=e=>{e.preventDefault(),this.toggle()};get element(){return this._domNode}get expanded(){return this._state==="expanded"}constructor(e){this._state=e.state??"short",this._onToggle=e.onToggle,this._domNode=jn("div.vscode-comment-widget-v2");let n=jn("div.vscode-comment-widget-v2-header"),i=jn("div.vscode-comment-widget-v2-title-group"),r=jn("span.vscode-comment-widget-v2-username");r.textContent=e.username,i.appendChild(r),n.appendChild(i);let s=jn("div.vscode-comment-widget-v2-actions");e.onEdit&&s.appendChild(this._actionButton("edit","Edit",e.onEdit)),e.onDelete&&s.appendChild(this._actionButton("trash","Delete",e.onDelete)),n.appendChild(s),this._domNode.appendChild(n);let o=jn("div.vscode-comment-widget-v2-body");if(this._textNode=document.createElement("p"),this._textNode.className="vscode-comment-widget-v2-text",this._textNode.textContent=e.body,o.appendChild(this._textNode),this._state!=="short"){let a=document.createElement("button");a.type="button",a.className="vscode-comment-widget-v2-toggle",a.addEventListener("click",this._onToggleClick),this._toggleNode=a,o.appendChild(a)}this._domNode.appendChild(o),this._applyState()}toggle(){this._state!=="short"&&(this._state=this._state==="expanded"?"collapsed":"expanded",this._applyState(),this._onToggle?.(this._state==="expanded"))}_applyState(){this._domNode.classList.toggle("vscode-comment-widget-v2--collapsed",this._state==="collapsed"),this._domNode.classList.toggle("vscode-comment-widget-v2--expanded",this._state==="expanded"),this._toggleNode&&(this._toggleNode.textContent=this._state==="expanded"?"See less":"See more")}_actionButton(e,n,i){let r=Rw(e,n),s=o=>{o.preventDefault(),o.stopPropagation(),i()};return r.addEventListener("click",s),this._disposables.push(()=>r.removeEventListener("click",s)),r}dispose(){this._toggleNode?.removeEventListener("click",this._onToggleClick);for(let e of this._disposables)e();this._domNode.remove()}},Lw=80,As=class extends Dl{createWidget(e){return new Vl({username:e.author??"You",body:e.body,state:e.body.length>Lw?"collapsed":"short",onDelete:()=>this.model.remove(e.id)})}};var Th;function X(t,e,n){function i(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);let c=o.prototype,d=Object.keys(c);for(let h=0;h<d.length;h++){let u=d[h];u in a||(a[u]=c[u].bind(a))}}let r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:t});function o(a){var l;let c=n?.Parent?new s:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(let d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}var Ui=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};(Th=globalThis).__zod_globalConfig??(Th.__zod_globalConfig={});var Iw=globalThis.__zod_globalConfig;function wn(t){return Iw}function xf(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,i])=>e.indexOf(+n)===-1).map(([n,i])=>i)}function Mw(t,e){return typeof e=="bigint"?e.toString():e}function Nw(t){return{get value(){{let e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function Sf(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}var Oh=Symbol("evaluating");function Ft(t,e,n){let i;Object.defineProperty(t,e,{get(){if(i!==Oh)return i===void 0&&(i=Oh,i=n()),i},set(r){Object.defineProperty(t,e,{value:r})},configurable:!0})}var zf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function tc(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Aw(t){if(tc(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(tc(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}var Pw=new Set(["string","number","symbol"]);function nc(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fw(t,e,n){let i=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(i._zod.parent=t),i}function Ke(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function $w(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Bw={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Wi(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function Dw(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue===!1)return!0;return!1}function Jn(t,e){return e.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(t),n})}function js(t){return typeof t=="string"?t:t?.message}function yn(t,e,n){let i=t.message?t.message:js(t.inst?._zod.def?.error?.(t))??js(e?.error?.(t))??js(n.customError?.(t))??js(n.localeError?.(t))??"Invalid input",{inst:r,continue:s,input:o,...a}=t;return a.path??(a.path=[]),a.message=i,e?.reportInput&&(a.input=o),a}var Ef=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,Mw,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Vw=X("$ZodError",Ef),oo=X("$ZodError",Ef,{Parent:Error}),qw=t=>(e,n,i,r)=>{let s=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Ui;if(o.issues.length){let a=new(r?.Err??t)(o.issues.map(l=>yn(l,s,wn())));throw zf(a,r?.callee),a}return o.value},jw=qw(oo),Ww=t=>async(e,n,i,r)=>{let s=i?{...i,async:!0}:{async:!0},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(r?.Err??t)(o.issues.map(l=>yn(l,s,wn())));throw zf(a,r?.callee),a}return o.value},Hw=Ww(oo),Kw=t=>(e,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Ui;return s.issues.length?{success:!1,error:new(t??Vw)(s.issues.map(o=>yn(o,r,wn())))}:{success:!0,data:s.value}},Ct=Kw(oo),Uw=t=>async(e,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=e._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>yn(o,r,wn())))}:{success:!0,data:s.value}},Cf=Uw(oo),Zw=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Xw=/^-?\d+$/,Tf=/^-?\d+(?:\.\d+)?$/,Jw=/^(?:true|false)$/i,Of=X("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),Gw={number:"number",bigint:"bigint",object:"date"},Rf=X("$ZodCheckGreaterThan",(t,e)=>{Of.init(t,e);let n=Gw[typeof e.value];t._zod.onattach.push(i=>{let r=i._zod.bag,s=(e.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?r.minimum=e.value:r.exclusiveMinimum=e.value)}),t._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Yw=X("$ZodCheckNumberFormat",(t,e)=>{Of.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),i=n?"int":"number",[r,s]=Bw[e.format];t._zod.onattach.push(o=>{let a=o._zod.bag;a.format=e.format,a.minimum=r,a.maximum=s,n&&(a.pattern=Xw)}),t._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort});return}}a<r&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:t,continue:!e.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),Qw={major:4,minor:4,patch:3},et=X("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Qw;let i=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&i.unshift(t);for(let r of i)for(let s of r._zod.onattach)s(t);if(i.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(o,a,l)=>{let c=Wi(o),d;for(let h of a){if(h._zod.def.when){if(Dw(o)||!h._zod.def.when(o))continue}else if(c)continue;let u=o.issues.length,f=h._zod.check(o);if(f instanceof Promise&&l?.async===!1)throw new Ui;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,o.issues.length!==u&&(c||(c=Wi(o,u)))});else{if(o.issues.length===u)continue;c||(c=Wi(o,u))}}return d?d.then(()=>o):o},s=(o,a,l)=>{if(Wi(o))return o.aborted=!0,o;let c=r(a,i,l);if(c instanceof Promise){if(l.async===!1)throw new Ui;return c.then(d=>t._zod.parse(d,l))}return t._zod.parse(c,l)};t._zod.run=(o,a)=>{if(a.skipChecks)return t._zod.parse(o,a);if(a.direction==="backward"){let c=t._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return c instanceof Promise?c.then(d=>s(d,o,a)):s(c,o,a)}let l=t._zod.parse(o,a);if(l instanceof Promise){if(a.async===!1)throw new Ui;return l.then(c=>r(c,i,a))}return r(l,i,a)}}Ft(t,"~standard",()=>({validate:r=>{try{let s=Ct(t,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Cf(t,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),ey=X("$ZodString",(t,e)=>{et.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Zw(t._zod.bag),t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),Lf=X("$ZodNumber",(t,e)=>{et.init(t,e),t._zod.pattern=t._zod.bag.pattern??Tf,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:t,...s?{received:s}:{}}),n}}),ty=X("$ZodNumberFormat",(t,e)=>{Yw.init(t,e),Lf.init(t,e)}),ny=X("$ZodBoolean",(t,e)=>{et.init(t,e),t._zod.pattern=Jw,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n}}),iy=X("$ZodUnknown",(t,e)=>{et.init(t,e),t._zod.parse=n=>n}),ry=X("$ZodVoid",(t,e)=>{et.init(t,e),t._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:t}),n}});function Rh(t,e,n){t.issues.length&&e.issues.push(...Jn(n,t.issues)),e.value[n]=t.value}var sy=X("$ZodArray",(t,e)=>{et.init(t,e),t._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);let s=[];for(let o=0;o<r.length;o++){let a=r[o],l=e.element._zod.run({value:a,issues:[]},i);l instanceof Promise?s.push(l.then(c=>Rh(c,n,o))):Rh(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function Ys(t,e,n,i,r,s){let o=n in i;if(t.issues.length){if(r&&s&&!o)return;e.issues.push(...Jn(n,t.issues))}if(!o&&!r){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}t.value===void 0?o&&(e.value[n]=void 0):e.value[n]=t.value}function oy(t){let e=Object.keys(t.shape);for(let i of e)if(!t.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=$w(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function ay(t,e,n,i,r,s){let o=[],a=r.keySet,l=r.catchall._zod,c=l.def.type,d=l.optin==="optional",h=l.optout==="optional";for(let u in e){if(u==="__proto__"||a.has(u))continue;if(c==="never"){o.push(u);continue}let f=l.run({value:e[u],issues:[]},i);f instanceof Promise?t.push(f.then(m=>Ys(m,n,u,e,d,h))):Ys(f,n,u,e,d,h)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}var ly=X("$ZodObject",(t,e)=>{if(et.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let o=e.shape;Object.defineProperty(e,"shape",{get:()=>{let a={...o};return Object.defineProperty(e,"shape",{value:a}),a}})}let n=Nw(()=>oy(e));Ft(t._zod,"propValues",()=>{let o=e.shape,a={};for(let l in o){let c=o[l]._zod;if(c.values){a[l]??(a[l]=new Set);for(let d of c.values)a[l].add(d)}}return a});let i=tc,r=e.catchall,s;t._zod.parse=(o,a)=>{s??(s=n.value);let l=o.value;if(!i(l))return o.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),o;o.value={};let c=[],d=s.shape;for(let h of s.keys){let u=d[h],f=u._zod.optin==="optional",m=u._zod.optout==="optional",p=u._zod.run({value:l[h],issues:[]},a);p instanceof Promise?c.push(p.then(v=>Ys(v,o,h,l,f,m))):Ys(p,o,h,l,f,m)}return r?ay(c,l,o,a,n.value,t):c.length?Promise.all(c).then(()=>o):o}});function Lh(t,e,n,i){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let r=t.filter(s=>!Wi(s));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>yn(o,i,wn())))}),e)}var cy=X("$ZodUnion",(t,e)=>{et.init(t,e),Ft(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Ft(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Ft(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Ft(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){let i=e.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>Sf(r.source)).join("|")})$`)}});let n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of e.options){let l=a._zod.run({value:i.value,issues:[]},r);if(l instanceof Promise)o.push(l),s=!0;else{if(l.issues.length===0)return l;o.push(l)}}return s?Promise.all(o).then(a=>Lh(a,i,t,r)):Lh(o,i,t,r)}}),dy=X("$ZodRecord",(t,e)=>{et.init(t,e),t._zod.parse=(n,i)=>{let r=n.value;if(!Aw(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:t}),n;let s=[],o=e.keyType._zod.values;if(o){n.value={};let a=new Set;for(let c of o)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){a.add(typeof c=="number"?c.toString():c);let d=e.keyType._zod.run({value:c,issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(f=>yn(f,i,wn())),input:c,path:[c],inst:t});continue}let h=d.value,u=e.valueType._zod.run({value:r[c],issues:[]},i);u instanceof Promise?s.push(u.then(f=>{f.issues.length&&n.issues.push(...Jn(c,f.issues)),n.value[h]=f.value})):(u.issues.length&&n.issues.push(...Jn(c,u.issues)),n.value[h]=u.value)}let l;for(let c in r)a.has(c)||(l=l??[],l.push(c));l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:t,keys:l})}else{n.value={};for(let a of Reflect.ownKeys(r)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,a))continue;let l=e.keyType._zod.run({value:a,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Tf.test(a)&&l.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},i);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(l=d)}if(l.issues.length){e.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(d=>yn(d,i,wn())),input:a,path:[a],inst:t});continue}let c=e.valueType._zod.run({value:r[a],issues:[]},i);c instanceof Promise?s.push(c.then(d=>{d.issues.length&&n.issues.push(...Jn(a,d.issues)),n.value[l.value]=d.value})):(c.issues.length&&n.issues.push(...Jn(a,c.issues)),n.value[l.value]=c.value)}}return s.length?Promise.all(s).then(()=>n):n}}),uy=X("$ZodEnum",(t,e)=>{et.init(t,e);let n=xf(e.entries),i=new Set(n);t._zod.values=i,t._zod.pattern=new RegExp(`^(${n.filter(r=>Pw.has(typeof r)).map(r=>typeof r=="string"?nc(r):r.toString()).join("|")})$`),t._zod.parse=(r,s)=>{let o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:t}),r}}),hy=X("$ZodLiteral",(t,e)=>{if(et.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(i=>typeof i=="string"?nc(i):i?nc(i.toString()):String(i)).join("|")})$`),t._zod.parse=(i,r)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),i}});function Ih(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var fy=X("$ZodOptional",(t,e)=>{et.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Ft(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Ft(t._zod,"pattern",()=>{let n=e.innerType._zod.pattern;return n?new RegExp(`^(${Sf(n.source)})?$`):void 0}),t._zod.parse=(n,i)=>{if(e.innerType._zod.optin==="optional"){let r=n.value,s=e.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>Ih(o,r)):Ih(s,r)}return n.value===void 0?n:e.innerType._zod.run(n,i)}}),Mh,my=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){let n=e[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){let e=t._zod.parent;if(e){let n={...this.get(e)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function py(){return new my}(Mh=globalThis).__zod_globalRegistry??(Mh.__zod_globalRegistry=py());var gy=globalThis.__zod_globalRegistry;function vy(t,e){return new t({type:"string",...Ke(e)})}function by(t,e){return new t({type:"number",checks:[],...Ke(e)})}function _y(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Ke(e)})}function wy(t,e){return new t({type:"boolean",...Ke(e)})}function yy(t){return new t({type:"unknown"})}function ky(t,e){return new t({type:"void",...Ke(e)})}function xy(t,e){return new Rf({check:"greater_than",...Ke(e),value:t,inclusive:!1})}function Sy(t,e){return new Rf({check:"greater_than",...Ke(e),value:t,inclusive:!0})}function zy(t){return xy(0,t)}function Zi(t){return Sy(0,t)}function ic(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??gy,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function le(t,e,n={path:[],schemaPath:[]}){var i;let r=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);let a=t._zod.toJSONSchema?.();if(a)o.schema=a;else{let c={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,c);else{let h=o.schema,u=e.processors[r.type];if(!u)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);u(t,e,h,c)}let d=t._zod.parent;d&&(o.ref||(o.ref=d),le(d,e,c),e.seen.get(d).isParent=!0)}let l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&Be(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function rc(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of t.seen.entries()){let a=t.metadataRegistry.get(o[0])?.id;if(a){let l=i.get(a);if(l&&l!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=o=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(o[0])?.id,h=t.external.uri??(f=>f);if(d)return{ref:h(d)};let u=o[1].defId??o[1].schema.id??`schema${t.counter++}`;return o[1].defId=u,{defId:u,ref:`${h("__shared")}#/${a}/${u}`}}if(o[1]===n)return{ref:"#"};let l=`#/${a}/`,c=o[1].schema.id??`__schema${t.counter++}`;return{defId:c,ref:l+c}},s=o=>{if(o[1].schema.$ref)return;let a=o[1],{ref:l,defId:c}=r(o);a.def={...a.schema},c&&(a.defId=c);let d=a.schema;for(let h in d)delete d[h];d.$ref=l};if(t.cycles==="throw")for(let o of t.seen.entries()){let a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>

Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of t.seen.entries()){let a=o[1];if(e===o[0]){s(o);continue}if(t.external){let l=t.external.registry.get(o[0])?.id;if(e!==o[0]&&l){s(o);continue}}if(t.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&t.reused==="ref"){s(o);continue}}}function sc(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=a=>{let l=t.seen.get(a);if(l.ref===null)return;let c=l.def??l.schema,d={...c},h=l.ref;if(l.ref=null,h){i(h);let f=t.seen.get(h),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,d),a._zod.parent===h)for(let p in c)p==="$ref"||p==="allOf"||p in d||delete c[p];if(m.$ref&&f.def)for(let p in c)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(c[p])===JSON.stringify(f.def[p])&&delete c[p]}let u=a._zod.parent;if(u&&u!==h){i(u);let f=t.seen.get(u);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(let m in c)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(c[m])===JSON.stringify(f.def[m])&&delete c[m]}t.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};for(let a of[...t.seen.entries()].reverse())i(a[0]);let r={};if(t.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(a)}Object.assign(r,n.def??n.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&r.id===s&&delete r.id;let o=t.external?.defs??{};for(let a of t.seen.entries()){let l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,o[l.defId]=l.def)}t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Nh(e,"input",t.processors),output:Nh(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Be(t,e){let n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return Be(i.element,n);if(i.type==="set")return Be(i.valueType,n);if(i.type==="lazy")return Be(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return Be(i.innerType,n);if(i.type==="intersection")return Be(i.left,n)||Be(i.right,n);if(i.type==="record"||i.type==="map")return Be(i.keyType,n)||Be(i.valueType,n);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:Be(i.in,n)||Be(i.out,n);if(i.type==="object"){for(let r in i.shape)if(Be(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(Be(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(Be(r,n))return!0;return!!(i.rest&&Be(i.rest,n))}return!1}var Nh=(t,e,n={})=>i=>{let{libraryOptions:r,target:s}=i??{},o=ic({...r??{},target:s,io:e,processors:n});return le(t,o),rc(o,t),sc(o,t)},Ey={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cy=(t,e,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),a&&(r.format=Ey[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),c&&(r.contentEncoding=c),l&&l.size>0){let d=[...l];d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(h=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Ty=(t,e,n,i)=>{let r=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number";let h=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),u=typeof c=="number"&&c<=(o??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";h?f?(r.minimum=d,r.exclusiveMinimum=!0):r.exclusiveMinimum=d:typeof s=="number"&&(r.minimum=s),u?f?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof o=="number"&&(r.maximum=o),typeof l=="number"&&(r.multipleOf=l)},Oy=(t,e,n,i)=>{n.type="boolean"},Ry=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},Ly=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},Iy=(t,e,n,i)=>{e.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},My=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Ny=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},Ay=(t,e,n,i)=>{n.not={}},Py=(t,e,n,i)=>{},Fy=(t,e,n,i)=>{},$y=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},By=(t,e,n,i)=>{let r=t._zod.def,s=xf(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},Dy=(t,e,n,i)=>{let r=t._zod.def,s=[];for(let o of r.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},Vy=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},qy=(t,e,n,i)=>{let r=n,s=t._zod.pattern;if(!s)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=s.source},jy=(t,e,n,i)=>{let r=n,s={type:"string",format:"binary",contentEncoding:"binary"},{minimum:o,maximum:a,mime:l}=t._zod.bag;o!==void 0&&(s.minLength=o),a!==void 0&&(s.maxLength=a),l?l.length===1?(s.contentMediaType=l[0],Object.assign(r,s)):(Object.assign(r,s),r.anyOf=l.map(c=>({contentMediaType:c}))):Object.assign(r,s)},Wy=(t,e,n,i)=>{n.type="boolean"},Hy=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ky=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Uy=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Zy=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Xy=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Jy=(t,e,n,i)=>{let r=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(r.minItems=o),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=le(s.element,e,{...i,path:[...i.path,"items"]})},Gy=(t,e,n,i)=>{let r=n,s=t._zod.def;r.type="object",r.properties={};let o=s.shape;for(let c in o)r.properties[c]=le(o[c],e,{...i,path:[...i.path,"properties",c]});let a=new Set(Object.keys(o)),l=new Set([...a].filter(c=>{let d=s.shape[c]._zod;return e.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(r.required=Array.from(l)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=le(s.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},Yy=(t,e,n,i)=>{let r=t._zod.def,s=r.inclusive===!1,o=r.options.map((a,l)=>le(a,e,{...i,path:[...i.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},Qy=(t,e,n,i)=>{let r=t._zod.def,s=le(r.left,e,{...i,path:[...i.path,"allOf",0]}),o=le(r.right,e,{...i,path:[...i.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,l=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]];n.allOf=l},ek=(t,e,n,i)=>{let r=n,s=t._zod.def;r.type="array";let o=e.target==="draft-2020-12"?"prefixItems":"items",a=e.target==="draft-2020-12"||e.target==="openapi-3.0"?"items":"additionalItems",l=s.items.map((u,f)=>le(u,e,{...i,path:[...i.path,o,f]})),c=s.rest?le(s.rest,e,{...i,path:[...i.path,a,...e.target==="openapi-3.0"?[s.items.length]:[]]}):null;e.target==="draft-2020-12"?(r.prefixItems=l,c&&(r.items=c)):e.target==="openapi-3.0"?(r.items={anyOf:l},c&&r.items.anyOf.push(c),r.minItems=l.length,c||(r.maxItems=l.length)):(r.items=l,c&&(r.additionalItems=c));let{minimum:d,maximum:h}=t._zod.bag;typeof d=="number"&&(r.minItems=d),typeof h=="number"&&(r.maxItems=h)},tk=(t,e,n,i)=>{let r=n,s=t._zod.def;r.type="object";let o=s.keyType,a=o._zod.bag?.patterns;if(s.mode==="loose"&&a&&a.size>0){let c=le(s.valueType,e,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let d of a)r.patternProperties[d.source]=c}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(r.propertyNames=le(s.keyType,e,{...i,path:[...i.path,"propertyNames"]})),r.additionalProperties=le(s.valueType,e,{...i,path:[...i.path,"additionalProperties"]});let l=o._zod.values;if(l){let c=[...l].filter(d=>typeof d=="string"||typeof d=="number");c.length>0&&(r.required=c)}},nk=(t,e,n,i)=>{let r=t._zod.def,s=le(r.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},ik=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType},rk=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},sk=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},ok=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},ak=(t,e,n,i)=>{let r=t._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?s?r.out:r.in:r.out;le(o,e,i);let a=e.seen.get(t);a.ref=o},lk=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,n.readOnly=!0},ck=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType},dk=(t,e,n,i)=>{let r=t._zod.def;le(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType},uk=(t,e,n,i)=>{let r=t._zod.innerType;le(r,e,i);let s=e.seen.get(t);s.ref=r},Ah={string:Cy,number:Ty,boolean:Oy,bigint:Ry,symbol:Ly,null:Iy,undefined:My,void:Ny,never:Ay,any:Py,unknown:Fy,date:$y,enum:By,literal:Dy,nan:Vy,template_literal:qy,file:jy,success:Wy,custom:Hy,function:Ky,transform:Uy,map:Zy,set:Xy,array:Jy,object:Gy,union:Yy,intersection:Qy,tuple:ek,record:tk,nullable:nk,nonoptional:ik,default:rk,prefault:sk,catch:ok,pipe:ak,readonly:lk,promise:ck,optional:dk,lazy:uk};function hk(t,e){if("_idmap"in t){let i=t,r=ic({...e,processors:Ah}),s={};for(let l of i._idmap.entries()){let[c,d]=l;le(d,r)}let o={},a={registry:i,uri:e?.uri,defs:s};r.external=a;for(let l of i._idmap.entries()){let[c,d]=l;rc(r,d),o[c]=sc(r,d)}if(Object.keys(s).length>0){let l=r.target==="draft-2020-12"?"$defs":"definitions";o.__shared={[l]:s}}return{schemas:o}}let n=ic({...e,processors:Ah});return le(t,n),rc(n,t),sc(n,t)}var ct=X("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");et.init(t,e),t.def=e,t.type=e.type,t.parse=(n,i)=>jw(t,n,i,{callee:t.parse}),t.safeParse=(n,i)=>Ct(t,n,i),t.parseAsync=async(n,i)=>Hw(t,n,i,{callee:t.parseAsync}),t.safeParseAsync=async(n,i)=>Cf(t,n,i),t.check=(...n)=>t.clone({...e,checks:[...e.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]},{parent:!0}),t.with=t.check,t.clone=(n,i)=>Fw(t,n,i),t.brand=()=>t,t.register=((n,i)=>(n.add(t,i),t)),t.apply=n=>n(t)}),fk=X("ZodMiniString",(t,e)=>{ey.init(t,e),ct.init(t,e)});function I(t){return vy(fk,t)}var If=X("ZodMiniNumber",(t,e)=>{Lf.init(t,e),ct.init(t,e)});function lt(t){return by(If,t)}var mk=X("ZodMiniNumberFormat",(t,e)=>{ty.init(t,e),If.init(t,e)});function ti(t){return _y(mk,t)}var pk=X("ZodMiniBoolean",(t,e)=>{ny.init(t,e),ct.init(t,e)});function ao(t){return wy(pk,t)}var gk=X("ZodMiniUnknown",(t,e)=>{iy.init(t,e),ct.init(t,e)});function _n(){return yy(gk)}var vk=X("ZodMiniVoid",(t,e)=>{ry.init(t,e),ct.init(t,e)});function Ph(t){return ky(vk,t)}var bk=X("ZodMiniArray",(t,e)=>{sy.init(t,e),ct.init(t,e)});function Qe(t,e){return new bk({type:"array",element:t,...Ke(e)})}var _k=X("ZodMiniObject",(t,e)=>{ly.init(t,e),ct.init(t,e),Ft(t,"shape",()=>e.shape)});function P(t,e){let n={type:"object",shape:t??{},...Ke(e)};return new _k(n)}var wk=X("ZodMiniUnion",(t,e)=>{cy.init(t,e),ct.init(t,e)});function Yi(t,e){return new wk({type:"union",options:t,...Ke(e)})}var Fh=X("ZodMiniRecord",(t,e)=>{dy.init(t,e),ct.init(t,e)});function yk(t,e,n){return!e||!e._zod?new Fh({type:"record",keyType:I(),valueType:t,...Ke(e)}):new Fh({type:"record",keyType:t,valueType:e,...Ke(n)})}var kk=X("ZodMiniEnum",(t,e)=>{uy.init(t,e),ct.init(t,e),t.options=Object.values(e.entries)});function Xt(t,e){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new kk({type:"enum",entries:n,...Ke(e)})}var xk=X("ZodMiniLiteral",(t,e)=>{hy.init(t,e),ct.init(t,e)});function Mf(t,e){return new xk({type:"literal",values:Array.isArray(t)?t:[t],...Ke(e)})}var Sk=X("ZodMiniOptional",(t,e)=>{fy.init(t,e),ct.init(t,e)});function B(t){return new Sk({type:"optional",innerType:t})}var zk=new Set(["type","format","properties","required","additionalProperties","items","prefixItems","const","enum","anyOf","oneOf","discriminator","$ref","title","description"]);function Xs(t){if(t===!0||t===!1)return t;if(t===null||typeof t!="object")throw new Error(`normalizeJsonSchema: expected object, got ${typeof t}`);if(Array.isArray(t))throw new Error("normalizeJsonSchema: expected object, got array");let e=t;if("not"in e&&Ck(e.not))return!1;let n={};for(let[i,r]of Object.entries(e)){if(!zk.has(i))continue;let s=Ek(i,r);s!==void 0&&(n[i]=s)}if(n.type==="object"&&!("additionalProperties"in n)&&(n.additionalProperties=!1),Array.isArray(n.oneOf)&&!("discriminator"in n)){let i=Tk(n.oneOf);i!==void 0&&(n.discriminator=i)}return"discriminator"in n&&!Array.isArray(n.oneOf)&&delete n.discriminator,Object.keys(n).length===0?!0:n}function Ek(t,e){switch(t){case"properties":{if(!oc(e))return{};let n={};for(let[i,r]of Object.entries(e))n[i]=Xs(r);return n}case"items":case"additionalProperties":return e===!1?!1:Xs(e);case"prefixItems":case"anyOf":case"oneOf":return Array.isArray(e)?e.map(n=>Xs(n)):[];case"discriminator":{if(!oc(e))return;let n=e.propertyName;return typeof n!="string"||n.length===0?void 0:{propertyName:n}}case"enum":return Array.isArray(e)?e.slice():[];case"required":return Array.isArray(e)?e.slice().sort():[];default:return e}}function Ck(t){return oc(t)&&Object.keys(t).length===0}function oc(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Tk(t){if(t.length<2)return;let e=[];for(let i of t){if(i===!0||i===!1||i.type!=="object")return;let r=i.properties;if(!r)return;e.push(r)}let n=$h(e[0]);for(let i=1;i<e.length;i++)if(n=n.filter(r=>$h(e[i]).includes(r)),n.length===0)return;for(let i of n){let r=new Set,s=!0;for(let o of e){let a=o[i],l=JSON.stringify(a.const);if(r.has(l)){s=!1;break}r.add(l)}if(s)return{propertyName:i}}}function $h(t){let e=[];for(let[n,i]of Object.entries(t))i===!0||i===!1||"const"in i&&e.push(n);return e}var Nf=class Af{paramsSchema;resultSchema;errorSchema;docs;clientStreamSchema;serverStreamSchema;kind="request";constructor(e,n,i,r={},s,o){this.paramsSchema=e,this.resultSchema=n,this.errorSchema=i,this.docs=r,this.clientStreamSchema=s,this.serverStreamSchema=o}withStream(e){return new Af(this.paramsSchema,this.resultSchema,this.errorSchema,this.docs,e.client,e.server)}},Pf=class{paramsSchema;docs;kind="notification";constructor(t,e={}){this.paramsSchema=t,this.docs=e}};function ae(t,e,n,i){let r={};return new Nf(t,e??Ph(),Ph(),r)}function Jt(t,e={}){return new Pf(t,e)}function ji(t){let e=t._zod?.def?.type;return e==="void"||e==="undefined"?!0:Xs(hk(t))}function Ok(t){let e=Js(t);if(e===void 0)throw new Error("jcsCanonicalize: value is not JSON-representable");return e}new TextEncoder;function Js(t,e=new Set){if(typeof t=="number"&&Number.isNaN(t))throw new Error("NaN is not allowed");if(typeof t=="number"&&!Number.isFinite(t))throw new Error("Infinity is not allowed");if(t===null||typeof t!="object")return JSON.stringify(t);let n=t;if(typeof n.toJSON=="function"){if(e.has(n))throw new Error("Circular reference detected");e.add(n);let r=Js(n.toJSON(),e);return e.delete(n),r}if(e.has(n))throw new Error("Circular reference detected");e.add(n);let i;if(Array.isArray(n))i=`[${n.map(r=>Js(r===void 0||typeof r=="symbol"?null:r,e)).join(",")}]`;else{let r=[];for(let s of Object.keys(n).sort()){let o=n[s];o===void 0||typeof o=="symbol"||r.push(`${JSON.stringify(s)}:${Js(o,e)}`)}i=`{${r.join(",")}}`}return e.delete(n),i}var Rk=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Et(t,e){return t>>>e|t<<32-e}function Lk(t){let e=t.length,n=e*8,i=e+9+63&-64,r=new Uint8Array(i);r.set(t),r[e]=128;let s=new DataView(r.buffer);s.setUint32(i-8,Math.floor(n/4294967296),!1),s.setUint32(i-4,n>>>0,!1);let o=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);for(let d=0;d<i;d+=64){for(let y=0;y<16;y++)a[y]=s.getUint32(d+y*4,!1);for(let y=16;y<64;y++){let x=a[y-15],C=a[y-2],k=Et(x,7)^Et(x,18)^x>>>3,E=Et(C,17)^Et(C,19)^C>>>10;a[y]=a[y-16]+k+a[y-7]+E>>>0}let h=o[0],u=o[1],f=o[2],m=o[3],p=o[4],v=o[5],g=o[6],w=o[7];for(let y=0;y<64;y++){let x=Et(p,6)^Et(p,11)^Et(p,25),C=p&v^~p&g,k=w+x+C+Rk[y]+a[y]>>>0,E=(Et(h,2)^Et(h,13)^Et(h,22))+(h&u^h&f^u&f)>>>0;w=g,g=v,v=p,p=m+k>>>0,m=f,f=u,u=h,h=k+E>>>0}o[0]=o[0]+h>>>0,o[1]=o[1]+u>>>0,o[2]=o[2]+f>>>0,o[3]=o[3]+m>>>0,o[4]=o[4]+p>>>0,o[5]=o[5]+v>>>0,o[6]=o[6]+g>>>0,o[7]=o[7]+w>>>0}let l=new Uint8Array(32),c=new DataView(l.buffer);for(let d=0;d<8;d++)c.setUint32(d*4,o[d],!1);return l}function Ik(t){let e=Ok(ac(t,!0)),n=Lk(new TextEncoder().encode(e));return Array.from(n.subarray(0,8),i=>i.toString(16).padStart(2,"0")).join("")}function ac(t,e=!1){if(t===null||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>ac(i));let n={};for(let i of Object.keys(t)){if(i==="comment"||e&&i==="hash")continue;let r=t[i];r!==void 0&&(n[i]=ac(r))}return n}var Kl=new WeakMap,Mk=class{info;members;constructor(t,e,n={}){if(this.info=t,this.members=e,Kl.set(this,{frozenSchema:n.frozenSchema,schemaCache:void 0,hashCache:void 0}),t.hash!==void 0&&this.schemaHash!==t.hash)throw new Error(`Interface hash mismatch for "${t.id}": expected "${t.hash}", got "${this.schemaHash}". The interface's wire contract changed \u2014 update the pinned hash to "${this.schemaHash}" after reviewing the change.`)}get schemaHash(){let t=Kl.get(this);return t.hashCache===void 0&&(t.hashCache=Ik(t.frozenSchema??Bh(this.info,this.members,""))),t.hashCache}toSchema(){let t=Kl.get(this);return t.schemaCache===void 0&&(t.schemaCache=t.frozenSchema!==void 0?{...t.frozenSchema,hash:this.schemaHash}:Bh(this.info,this.members,this.schemaHash)),t.schemaCache}};function Bh(t,e,n){let i={};for(let[s,o]of Object.entries(e))i[s]=Nk(o);let r={id:t.id,hash:n,methods:i};return t.description!==void 0&&(r.description=t.description),t.comment!==void 0&&(r.comment=t.comment),r}function Nk(t){let e=t.docs;if(t.kind==="request"){let i={params:ji(t.paramsSchema),result:ji(t.resultSchema)};return t.clientStreamSchema!==void 0&&(i.clientStream=ji(t.clientStreamSchema)),t.serverStreamSchema!==void 0&&(i.serverStream=ji(t.serverStreamSchema)),e.description!==void 0&&(i.description=e.description),e.comment!==void 0&&(i.comment=e.comment),e.annotations!==void 0&&(i.annotations=e.annotations),i}let n={params:ji(t.paramsSchema)};return e.description!==void 0&&(n.description=e.description),e.comment!==void 0&&(n.comment=e.comment),e.annotations!==void 0&&(n.annotations=e.annotations),n}function tt(t,e){return new Mk(t,e)}var Dh=tt({id:"hubrpc.defaults",description:"Reflection: preset default service / interface on this connection."},{get:ae(P({}),P({serviceId:B(I()),interfaceId:B(I()),interfaceHash:B(I())}))}),Ak=Qe(P({principal:I(),transitive:B(ao())})),lc=Yi([P({exact:I()}),P({prefix:I()})]),Pk=P({serviceId:I(),interfaceId:I(),interfaceHash:I(),serviceDescription:B(I()),rootPrincipalSets:B(Qe(Ak)),reachableServiceIds:B(Qe(lc))}),Vh=tt({id:"hubrpc.directory",description:"Reflection: list services exposed by this endpoint. Can also list other directory services that can be explored."},{list:ae(P({interfaceId:B(I()),interfaceIdPrefix:B(I()),serviceId:B(I()),serviceIdScopes:B(Qe(lc)),cursor:B(I()),limit:B(lt().check(ti(),zy())),timeoutMs:B(lt().check(ti(),Zi()))}),P({items:Qe(Pk),nextCursor:B(I()),truncated:B(ao())})),watch:ae(P({interfaceId:B(I()),interfaceIdPrefix:B(I()),serviceId:B(I()),serviceIdScopes:B(Qe(lc))}),P({})).withStream({server:P({})})}),qh=tt({id:"hubrpc.schemas",description:"Reflection: fetch interface schemas by id (+ optional hash). Must serve the interfaces advertised in this endpoint's directory."},{get:ae(P({interfaceId:I(),hash:B(I())}),P({schema:_n()}))}),Fk=P({portId:I(),label:B(I())}),$k=P({type:B(I()),label:B(I()),processId:B(lt()),processType:B(I()),nodeStatusServiceId:B(I()),metadata:B(yk(I(),Yi([I(),lt(),ao()])))}),Ff=P({source:Xt(["self","attacher"]),descriptor:$k}),Bk=P({nodeId:I(),kind:B(Xt(["endpoint","hub"])),label:B(I()),descriptors:B(Qe(Ff)),ports:Qe(Fk)}),jh=P({nodeId:I(),portId:I()}),Dk=P({from:jh,to:jh,label:B(I()),peerState:B(Xt(["identified","pending","unsupported","error"]))}),Vk=P({serviceId:I(),nodeId:I(),portId:I(),match:Xt(["exact","prefix"])}),qk=P({observerServiceId:I(),entryNodeId:I(),nodes:Qe(Bk),links:Qe(Dk),routes:Qe(Vk)}),$f=tt({id:"hubrpc.topology",description:"Inspect the transport graph visible from a service. A watch emits invalidation ticks; consumers re-fetch getGraph after each tick."},{getGraph:ae(P({}),qk),watchGraph:ae(P({}),P({})).withStream({server:P({})})}),Wh=P({edgeId:I(),portId:I(),requestId:B(Yi([lt(),I()]))}),jk=P({type:Mf("transit"),ts:lt(),nodeId:I(),in:B(Wh),out:B(Wh),disposition:Xt(["forwarded","consumed","dropped","unroutable"]),kind:Xt(["request","notification","response","stream"]),method:B(I()),params:B(_n()),result:B(_n()),error:B(P({code:lt(),message:I(),data:B(_n())}))}),Wk=P({type:Mf("overflow"),dropped:lt().check(ti(),Zi())}),Hh=Yi([jk,Wk]),Kh=P({delivered:lt().check(ti(),Zi()),dropped:lt().check(ti(),Zi())}),Hk=P({methodPrefix:B(I())}),Kk=P({methodPrefix:B(I()),maxPayloadBytes:lt().check(ti(),Zi())}),Bf=tt({id:"hubrpc.traffic",description:"Stream raw message transits for the entire node hosting the addressed service. Payload-free and explicitly payload-bearing variants keep disclosure opt-in."},{watch:ae(Hk,Kh).withStream({server:Hh}),watchWithPayloads:ae(Kk,Kh).withStream({server:Hh})}),Uk=P({nodeId:I(),portId:I(),descriptors:B(Qe(Ff))}),cc=tt({id:"hubrpc.node",description:"Topology bootstrap: identify the node and port at this end of the direct connection."},{getNodeId:ae(P({}),Uk)}),Xn={toCaller:"toCaller",toCallee:"toCallee"},Ut={cancel:"cancel",ping:"ping",pong:"pong"},Zk=tt({id:"$stream",description:"Reserved sub-protocol for in-flight stream messages correlated to a request by `requestId`."},{send:Jt(P({requestId:Yi([lt(),I()]),dir:Xt(["toCaller","toCallee"]),control:B(P({type:Xt(["cancel","ping","pong"]),reason:B(I()),nonce:B(I())})),payload:B(_n())}),{description:"Emit a stream message tied to the request `requestId`."})}),Gn=`${Zk.info.id}::send`,Ye={parseError:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internalError:-32603,permissionRequired:-32401,peerDisconnected:-32402,requestTimeout:-32403,cancelled:-32800};function Hi(t){return typeof t.method=="string"&&t.id!==void 0}function Df(t){return typeof t.method=="string"&&t.id===void 0}function Gs(t){return typeof t.method!="string"}var Pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function Xk(t){let e="",n=0;for(;n+3<=t.length;n+=3){let r=t[n]<<16|t[n+1]<<8|t[n+2];e+=Pt[r>>18&63]+Pt[r>>12&63]+Pt[r>>6&63]+Pt[r&63]}let i=t.length-n;if(i===1){let r=t[n]<<16;e+=Pt[r>>18&63]+Pt[r>>12&63]}else if(i===2){let r=t[n]<<16|t[n+1]<<8;e+=Pt[r>>18&63]+Pt[r>>12&63]+Pt[r>>6&63]}return e}function Jk(t){let e=t.split("::");if(e.length===3&&e[0].length===0&&e[1].length>0&&e[2].length>0)return{kind:"interface",interfaceId:e[1],member:e[2]};if(!e.some(n=>n.length===0)){if(e.length===1)return{kind:"bare",member:e[0]};if(e.length===2)return{kind:"interface",interfaceId:e[0],member:e[1]};if(e.length===3)return{kind:"full",serviceId:e[0],interfaceId:e[1],member:e[2]}}}var Vf=Symbol.for("@vscode/hubrpc.localMessageContext");function Gk(t,e){return Object.defineProperties(t,{context:{configurable:!0,enumerable:!1,value:e},[Vf]:{configurable:!0,enumerable:!1,value:!0}}),t}function Yk(t){let e=t;return t[Vf]===!0?e.context:void 0}var Qk=class qf{sender;_setHandler;_setWireObserver;constructor(e,n,i){this.sender=e,this._setHandler=n,this._setWireObserver=i}setRequestHandler(e){this._setHandler(e)}setWireMessageObserver(e,n){this._setWireObserver?.(e,n)}withSender(e){return new qf(e(this.sender),this._setHandler,this._setWireObserver)}},jf=Symbol("hubrpc.inspectionCall");function Ul(t){return Object.defineProperty(t,jf,{value:!0}),t}function Zl(t){return t?.[jf]===!0}var Zt=class extends Error{code;data;constructor(t,e,n){super(t),this.code=e,this.data=n,this.name="RpcError"}};function ex(t,e){return"exact"in e?t===e.exact:e.prefix===""||t===e.prefix||t.startsWith(`${e.prefix}/`)}function Wf(t,e){return e===void 0||e.some(n=>ex(t,n))}var tx=10*6e4,Hf=class Kf{_transport;static create(e){return this.createWithClose(e).channel}static createWithClose(e){let n=new Kf(e);return{channel:new Qk(n,i=>n.setRequestHandler(i),(i,r)=>n.setWireMessageObserver(i,r)),close:()=>n.close()}}_nextId=1;_pending=new Map;_streamListeners=new Map;_streamControl=new Map;_incomingAborts=new Map;_handler;_wireObserver;_isInspectionMethod;_outboundInspectionRequests=new Set;_inboundInspectionRequests=new Set;_closeError;setRequestHandler(e){this._handler=e}setWireMessageObserver(e,n){this._wireObserver=e,this._isInspectionMethod=e===void 0?void 0:n,e===void 0&&(this._outboundInspectionRequests.clear(),this._inboundInspectionRequests.clear())}constructor(e){this._transport=e,this._transport.setListener(n=>this._onMessage(n))}async sendRequest(e,n,i){this._throwIfClosed();let r=this._nextId++,s={jsonrpc:"2.0",id:r,method:e};n!==void 0&&(s.params=n);let o=new Promise((a,l)=>{this._pending.set(String(r),{resolve:a,reject:l})});this._observeOutbound(s,i);try{await this._transport.send(s)}catch(a){throw this._pending.delete(String(r)),this._observeSendFailure(r,a),a}return o}async sendNotification(e,n,i){this._throwIfClosed();let r={jsonrpc:"2.0",method:e};n!==void 0&&(r.params=n),this._observeOutbound(r,i),await this._transport.send(r)}sendRequestWithStream(e,n,i){this._throwIfClosed();let r=this._nextId++,s=String(r),o,a,l=new Promise((u,f)=>{o=u,a=f});this._pending.set(s,{resolve:o,reject:a}),i?.onStreamMessage&&this._streamListeners.set(s,i.onStreamMessage);let c=this._makePinger(r,Xn.toCallee);this._streamControl.set(s,c.onControl);let d=setInterval(()=>{this._sendStream(r,Xn.toCallee,{control:{type:Ut.ping}})},tx);d.unref?.();let h=()=>{clearInterval(d),c.dispose(),this._streamControl.delete(s)};return l.then(h,h),(async()=>{let u={jsonrpc:"2.0",id:r,method:e};n!==void 0&&(u.params=n),this._observeOutbound(u,i),await this._transport.send(u)})().catch(u=>{this._pending.delete(s),this._streamListeners.delete(s),this._observeSendFailure(r,u),h(),a(u instanceof Error?u:new Error(String(u)))}),{result:l,send:u=>this._sendStream(r,Xn.toCallee,{payload:u}),cancel:u=>this._sendStream(r,Xn.toCallee,{control:u!==void 0?{type:Ut.cancel,reason:u}:{type:Ut.cancel}}),ping:c.ping}}_makePinger(e,n){let i=new Map,r=1;return{ping:()=>{let s=`${e}:${r++}`,o=new Promise((a,l)=>i.set(s,{resolve:a,reject:l}));return this._sendStream(e,n,{control:{type:Ut.ping,nonce:s}}),o},onControl:s=>{if(s.type===Ut.ping)this._sendStream(e,n,{control:{type:Ut.pong,nonce:s.nonce}});else if(s.type===Ut.pong&&s.nonce!==void 0){let o=i.get(s.nonce);o&&(i.delete(s.nonce),o.resolve())}},dispose:()=>{let s=new Zt("Request settled before pong",Ye.cancelled);for(let o of i.values())o.reject(s);i.clear()}}}async _sendStream(e,n,i){this._throwIfClosed();let r={jsonrpc:"2.0",method:Gn,params:{requestId:e,dir:n,...i}};this._observeOutbound(r),await this._transport.send(r)}close(){if(this._closeError)return;let e=new Zt("Connection closed",Ye.peerDisconnected);this._closeError=e;for(let n of this._incomingAborts.values())n.abort(e);this._incomingAborts.clear(),this._transport.dispose();for(let n of this._pending.values())n.reject(e);this._pending.clear(),this._streamListeners.clear(),this._streamControl.clear()}_throwIfClosed(){if(this._closeError)throw this._closeError}_onMessage(e){let n=e.context;if(this._observeInbound(e),Gs(e)){if(e.id===null)return;let i=String(e.id),r=this._pending.get(i);if(!r)return;if(this._pending.delete(i),this._streamListeners.delete(i),"error"in e){let s=e.error,o=new Zt(s.message,s.code,s.data);r.reject(o)}else r.resolve(e.result);return}if(Hi(e)){this._handleRequest(e,n).catch(()=>{});return}if(Df(e)){if(e.method===Gn){this._handleStreamNotification(e);return}this._handleNotification(e,n);return}}_handleStreamNotification(e){let n=e.params;if(!n)return;let i=n.requestId;if(i===void 0)return;let r=String(i);if(n.control){this._streamControl.get(r)?.(n.control);return}let s=this._streamListeners.get(r);s&&s(n.payload)}async _handleRequest(e,n){let i=String(e.id),r=this._makePinger(e.id,Xn.toCaller),s={send:l=>this._sendStream(e.id,Xn.toCaller,{payload:l}),onMessage:l=>{l?this._streamListeners.set(i,l):this._streamListeners.delete(i)},ping:r.ping,markInspectionLifecycle:()=>{this._wireObserver!==void 0&&this._inboundInspectionRequests.add(i)}},o=new AbortController;this._incomingAborts.set(i,o),this._streamControl.set(i,l=>{l.type===Ut.cancel?o.abort(new Zt(l.reason??"cancelled",Ye.cancelled)):r.onControl(l)});let a;try{if(!this._handler)a={error:{code:Ye.methodNotFound,message:`No handler registered on this endpoint (method: ${e.method}).`}};else try{a=await this._handler.handleRequest({method:e.method,params:e.params,context:n,stream:s,signal:o.signal})}catch(l){a={error:{code:Ye.internalError,message:l instanceof Error?l.message:String(l)}}}}finally{this._streamListeners.delete(i),this._streamControl.delete(i),this._incomingAborts.delete(i),r.dispose()}if("result"in a){let l={jsonrpc:"2.0",id:e.id,result:a.result};this._observeOutbound(l),await this._transport.send(l)}else{let l={jsonrpc:"2.0",id:e.id,error:a.error};this._observeOutbound(l),await this._transport.send(l)}}_handleNotification(e,n){if(this._handler)try{this._handler.handleNotification({method:e.method,params:e.params,context:n,stream:nx,signal:ix})}catch{}}_observeInbound(e){let n=this._wireObserver;if(n===void 0)return;let i=!1;if(Hi(e))i=this._isInspectionMethod?.(e.method)===!0,i&&this._inboundInspectionRequests.add(String(e.id));else if(Gs(e)){if(e.id!==null){let r=String(e.id);i=this._outboundInspectionRequests.delete(r)}}else e.method===Gn?i=this._isInspectionStream(e):i=this._isInspectionMethod?.(e.method)===!0;i||n("inbound",e)}_observeOutbound(e,n){Hi(e)&&Zl(n)&&Gk(e,{...Yk(e),inspection:!0});let i=this._wireObserver;if(i===void 0)return;let r=!1;if(Hi(e))r=Zl(n),r&&this._outboundInspectionRequests.add(String(e.id));else if(Gs(e)){if(e.id!==null){let s=String(e.id);r=this._inboundInspectionRequests.delete(s)}}else e.method===Gn?r=this._isInspectionStream(e):r=Zl(n);r||i("outbound",e)}_observeSendFailure(e,n){if(this._wireObserver===void 0){this._outboundInspectionRequests.delete(String(e));return}this._observeInbound({jsonrpc:"2.0",id:e,error:{code:Ye.peerDisconnected,message:n instanceof Error?n.message:String(n)}})}_isInspectionStream(e){let n=e.params;if(n?.requestId===void 0)return!1;let i=String(n.requestId);return this._outboundInspectionRequests.has(i)||this._inboundInspectionRequests.has(i)}},nx={send:()=>Promise.resolve(),onMessage:()=>{},ping:()=>Promise.resolve(),markInspectionLifecycle:()=>{}},ix=new AbortController().signal,rx=256,sx=class{_options;_send;_onDispose;_queueLimit;_queue=[];_active=!0;_pumping=!1;_overflowPending=0;_delivered=0;_dropped=0;_resolveClosed;closed;constructor(t,e,n,i=rx){this._options=t,this._send=e,this._onDispose=n,this._queueLimit=i;let r;this.closed=new Promise(s=>r=s),this._resolveClosed=r}enqueue(t){if(!this._active||this._options.methodPrefix!==void 0&&!t.method?.startsWith(this._options.methodPrefix))return;let e=this._options.maxPayloadBytes===void 0?ox(t):ax(t,this._options.maxPayloadBytes);this._queue.length>=this._queueLimit&&(this._queue.shift(),this._dropped++,this._overflowPending++),this._queue.push(e),this._pumping||(this._pumping=!0,queueMicrotask(()=>{this._pump()}))}dispose(){this._active&&(this._active=!1,this._dropped+=this._queue.length,this._queue.length=0,this._overflowPending=0,this._onDispose(),this._pumping||this._complete())}async _pump(){try{for(;this._active;){if(this._overflowPending>0){let e=this._overflowPending;this._overflowPending=0,await this._send({type:"overflow",dropped:e});continue}let t=this._queue.shift();if(t===void 0)break;await this._send(t),this._delivered++}}catch{this.dispose()}finally{this._pumping=!1,this._active?(this._queue.length>0||this._overflowPending>0)&&(this._pumping=!0,queueMicrotask(()=>{this._pump()})):this._complete()}}_complete(){this._resolveClosed({delivered:this._delivered,dropped:this._dropped})}};function ox(t){let{params:e,result:n,error:i,...r}=t;return i===void 0?r:{...r,error:{code:i.code,message:i.message}}}function ax(t,e){return{...t,params:Xl(t.params,e),result:Xl(t.result,e),error:t.error===void 0?void 0:{...t.error,data:Xl(t.error.data,e)}}}function Xl(t,e){if(t===void 0)return;if(e===Number.POSITIVE_INFINITY)return t;let n=JSON.stringify(t);if(n===void 0)return;let i=new TextEncoder().encode(n);if(i.byteLength<=e)return t;let r=new TextEncoder,s=new TextDecoder().decode(i.slice(0,e));for(;r.encode(s).byteLength>e;)s=s.slice(0,-1);return s}var lx=class{_nodeId;_portId;_setActive;_subscribers=new Set;_observers=new Set;_outboundRequests=new Map;_inboundRequests=new Map;observe=(t,e)=>{this._onMessage(t,e)};constructor(t,e,n){this._nodeId=t,this._portId=e,this._setActive=n}get observerCount(){return this._subscribers.size+this._observers.size}subscribe(t,e){let n=new sx(t,e,()=>{this._subscribers.delete(n),this._deactivateIfUnused()});return this._activateIfUnused(),this._subscribers.add(n),n}observeTransits(t){this._activateIfUnused(),this._observers.add(t);let e=!1;return{dispose:()=>{e||(e=!0,this._observers.delete(t),this._deactivateIfUnused())}}}dispose(){for(let t of[...this._subscribers])t.dispose();this._subscribers.clear(),this._observers.clear(),this._outboundRequests.clear(),this._inboundRequests.clear(),this._setActive(!1)}_onMessage(t,e){if(this._subscribers.size===0&&this._observers.size===0)return;let n=Date.now(),i,r=this._endpoint("id"in e?e.id??void 0:void 0),s={type:"transit",ts:n,nodeId:this._nodeId,...t==="inbound"?{in:r}:{out:r},disposition:t==="inbound"?"consumed":"forwarded"};if(Hi(e)){let o={method:e.method};this._requestMap(t).set(String(e.id),o),i={...s,kind:"request",method:e.method,params:e.params}}else if(Gs(e)){let o=t==="inbound"?this._outboundRequests:this._inboundRequests,a=String(e.id),l=o.get(a);o.delete(a),i={...s,kind:"response",method:l?.method,result:"result"in e?e.result:void 0,error:"error"in e?e.error:void 0}}else if(Df(e)&&e.method===Gn){let o=e.params,a=this._endpoint(o?.requestId);i={...s,...t==="inbound"?{in:a}:{out:a},kind:"stream",method:Gn,params:e.params}}else i={...s,kind:"notification",method:e.method,params:e.params};for(let o of[...this._observers])try{o(i)}catch{}for(let o of this._subscribers)o.enqueue(i)}_requestMap(t){return t==="outbound"?this._outboundRequests:this._inboundRequests}_endpoint(t){return{edgeId:this._portId,portId:this._portId,...t!==void 0?{requestId:t}:{}}}_activateIfUnused(){this._subscribers.size===0&&this._observers.size===0&&this._setActive(!0)}_deactivateIfUnused(){this._subscribers.size!==0||this._observers.size!==0||(this._outboundRequests.clear(),this._inboundRequests.clear(),this._setActive(!1))}},cx=class Uf{static fromTransport(e){return new Uf(Hf.create(e))}channel;_registry=new Map;_serviceDescriptions=new Map;_serviceRootPrincipalSets=new Map;_directoryWatchers=new Set;_directoryListeners=new Set;_inspection;_trafficInspector;_serviceInspectionRegistrations=new Map;_wireChannel;_preset;constructor(e){"sender"in e?(this._wireChannel=e,this.channel=e.sender,e.setRequestHandler({handleRequest:n=>this._handleRequest(n),handleNotification:n=>this._handleNotification(n)})):(this._wireChannel=void 0,this.channel=e)}get(e,n={}){return this._buildClient(e,n)}service(e){return new ux(this,e)}register(e,n,i={}){return this._register(e,n,i,!1)}_register(e,n,i,r){let s=i.serviceId,o=`${s??""}::${e.info.id}`;if(this._registry.has(o))throw new Error(`Interface "${e.info.id}" already registered${s?` under service "${s}"`:""}.`);let a=!1;if(i.serviceDescription!==void 0){if(s===void 0)throw new Error("register: `serviceDescription` requires `serviceId`.");let d=this._serviceDescriptions.get(s);if(d!==void 0&&d!==i.serviceDescription)throw new Error(`register: conflicting descriptions for service "${s}".`);this._serviceDescriptions.set(s,i.serviceDescription),a=d===void 0}if(i.rootPrincipalSets!==void 0){if(s===void 0)throw new Error("register: `rootPrincipalSets` requires `serviceId`.");let d=this._serviceRootPrincipalSets.get(s);if(d!==void 0&&!dx(d,i.rootPrincipalSets))throw new Error(`register: conflicting rootPrincipalSets for service "${s}".`);this._serviceRootPrincipalSets.set(s,i.rootPrincipalSets),a||=d===void 0}let l={iface:e,handlers:n,serviceId:s,internalInspection:r};if(this._registry.set(o,l),this._notifyDirectoryWatchers(l,a),!r&&s!==void 0&&this._inspection!==void 0&&!this._serviceInspectionRegistrations.has(s))try{this._installServiceInspection(s)}catch(d){throw this._registry.delete(o),this._notifyDirectoryWatchers(l),d}let c=!1;return{dispose:()=>{c||(c=!0,this._registry.get(o)===l&&(this._registry.delete(o),this._notifyDirectoryWatchers(l),s===void 0&&this._preset?.interfaceId===e.info.id&&(this._preset=void 0),s!==void 0&&!this._hasBusinessServiceRegistration(s)&&(this._removeServiceInspection(s),this._serviceDescriptions.delete(s),this._serviceRootPrincipalSets.delete(s))))}}}setPreset(e){let n=`::${e.info.id}`;if(!this._registry.has(n))throw new Error(`setPreset: interface "${e.info.id}" is not registered under the root service.`);this._preset={serviceId:void 0,interfaceId:e.info.id,hash:e.schemaHash}}listRegisteredInterfaces(){return Array.from(this._registry.values()).map(e=>{let n=e.serviceId??"",i={serviceId:n,interfaceId:e.iface.info.id,interfaceHash:e.iface.schemaHash},r=n===""?void 0:this._serviceDescriptions.get(n);r!==void 0&&(i.serviceDescription=r);let s=n===""?void 0:this._serviceRootPrincipalSets.get(n);return s!==void 0&&(i.rootPrincipalSets=s),i})}onDidChangeDirectory(e){return this._directoryListeners.add(e),()=>this._directoryListeners.delete(e)}findRegisteredInterface(e,n){for(let i of this._registry.values())if(i.iface.info.id===e&&!(n!==void 0&&i.iface.schemaHash!==n))return i.iface}enableReflection(e={}){let n=`${e.serviceId??""}::${Dh.info.id}`;if(this._registry.has(n))return{dispose(){}};let i=`${e.serviceId??""}::`;for(let a of[Vh,qh])if(this._registry.has(`${i}${a.info.id}`))throw new Error(`enableReflection: partial reflection registration for service "${e.serviceId??""}".`);let r=e.serviceId!==void 0?{serviceId:e.serviceId}:{},s=[];if(s.push(this.register(Dh,{get:()=>this._preset?{serviceId:this._preset.serviceId,interfaceId:this._preset.interfaceId,interfaceHash:this._preset.hash}:{}},r)),s.push(this.register(Vh,{list:({interfaceId:a,interfaceIdPrefix:l,serviceId:c,serviceIdScopes:d,cursor:h,limit:u})=>{let f=this.listRegisteredInterfaces().filter(g=>e.serviceId===void 0||g.serviceId===e.serviceId).filter(g=>a===void 0||g.interfaceId===a).filter(g=>l===void 0||g.interfaceId.startsWith(l)).filter(g=>c===void 0||g.serviceId===c).filter(g=>Wf(g.serviceId,d)),m=h===void 0?0:Number.parseInt(h,10)||0,p=u===void 0?f.length:Math.min(f.length,m+u),v=f.slice(m,p).map(g=>({serviceId:g.serviceId,interfaceId:g.interfaceId,interfaceHash:g.interfaceHash,serviceDescription:g.serviceDescription,rootPrincipalSets:g.rootPrincipalSets?.map(w=>w.map(y=>({...y})))}));return p<f.length?{items:v,nextCursor:String(p)}:{items:v}},watch:(a,l,c)=>new Promise(d=>{let h={interfaceId:a.interfaceId,interfaceIdPrefix:a.interfaceIdPrefix,serviceId:a.serviceId,serviceIdScopes:a.serviceIdScopes,send:()=>c.send({})};this._directoryWatchers.add(h);let u=()=>{this._directoryWatchers.delete(h),d({})};if(c.signal.aborted){u();return}c.signal.addEventListener("abort",u,{once:!0})})},r)),s.push(this.register(qh,{get:({interfaceId:a,hash:l})=>{let c=this.findRegisteredInterface(a,l);if(!c)throw new Zt("Interface not found",Ye.methodNotFound,{reason:"unknown-interface",interfaceId:a,hash:l});return{schema:c.toSchema()}}},r)),e.serviceId!==void 0)try{this.enableReflection()}catch(a){for(let l of s.reverse())l.dispose();throw a}let o=!1;return{dispose:()=>{if(!o){o=!0;for(let a of s.reverse())a.dispose()}}}}_notifyDirectoryWatchers(e,n=!1){for(let i of this._directoryListeners)try{i()}catch{}for(let i of this._directoryWatchers){if(i.pending)continue;let r=Zh(i,e),s=n&&e.serviceId!==void 0&&[...this._registry.values()].some(o=>o.serviceId===e.serviceId&&Zh(i,o));!r&&!s||(i.pending=!0,queueMicrotask(()=>{i.pending=!1,this._directoryWatchers.has(i)&&i.send()}))}}enableInspection(e){if(this._inspection!==void 0)return this._inspection;let n={nodeId:Uh("node"),portId:Uh("port"),...e!==void 0?{descriptors:[...e]}:{}},i=this._register(cc,{getNodeId:()=>n},{},!0),r=new lx(n.nodeId,n.portId,a=>this._wireChannel?.setWireMessageObserver(a?r.observe:void 0,a?l=>this._isInspectionMethod(l):void 0));this._trafficInspector=r;let s=!1,o={...n,observeTraffic:a=>r.observeTransits(a),dispose:()=>{if(!s){s=!0;for(let a of[...this._serviceInspectionRegistrations.keys()])this._removeServiceInspection(a);r.dispose(),this._trafficInspector===r&&(this._trafficInspector=void 0),i.dispose(),this._inspection===o&&(this._inspection=void 0)}}};this._inspection=o;try{let a=new Set(Array.from(this._registry.values()).filter(l=>l.serviceId!==void 0&&!l.internalInspection).map(l=>l.serviceId));for(let l of a)this._installServiceInspection(l)}catch(a){throw o.dispose(),a}return o}get trafficObserverCount(){return this._trafficInspector?.observerCount??0}close(){this.channel.close()}_buildClient(e,n){let{serviceId:i,...r}=n,s=r,o=e.schemaHash,a=Jl(e),l={};for(let[c,d]of Object.entries(e.members)){let h=i?`${i}::${e.info.id}::${c}`:`${e.info.id}::${c}`;if(d.kind==="request")if(d.clientStreamSchema!==void 0||d.serverStreamSchema!==void 0){let u=d.serverStreamSchema;l[c]=(f,m)=>{let p=m?.onMessage,v=p!==void 0?x=>{if(u!==void 0){let C=Ct(u,x);if(!C.success)return;p(C.data);return}p(x)}:void 0,g=v!==void 0?{ctx:s,interfaceHash:o,onStreamMessage:v}:{ctx:s,interfaceHash:o};a&&Ul(g);let w=this.channel.sendRequestWithStream(h,f,g),y=w.result.then(x=>{let C=Ct(d.resultSchema,x===null?void 0:x);if(!C.success)throw new Zt(Ye.internalError,`Invalid result for ${h}`,{issues:C.error.issues});return x});return Object.assign(y,{send:x=>w.send(x),cancel:x=>w.cancel(x),ping:()=>w.ping()})}}else{let u=d.resultSchema;l[c]=async f=>{let m={ctx:s,interfaceHash:o};a&&Ul(m);let p=await this.channel.sendRequest(h,f,m),v=Ct(u,p===null?void 0:p);if(!v.success)throw new Zt(Ye.internalError,`Invalid result for ${h}`,{issues:v.error.issues});return p}}else l[c]=async u=>{let f={ctx:s,interfaceHash:o};a&&Ul(f),this.channel.sendNotification(h,u,f)}}return l}async _handleRequest(e){let n=this._parseRouted(e.method);if(!n.ok)return Ws(n.reason,e.method);let{entry:i,memberName:r}=n,s=i.iface.members[r];if(!s)return Ws("unknown-method",e.method);let o=i.handlers[r];if(!o)return Ws("unknown-method",e.method);let a=Ct(s.paramsSchema,e.params);if(!a.success)return{error:{code:Ye.invalidParams,message:"Invalid params",data:{issues:a.error.issues}}};if(!(s instanceof Nf))return Ws("unknown-method",e.method);let l=this._buildStreamApi(e.stream,e.signal,s);try{let c=o(a.data,e.context,l);Jl(i.iface)&&e.stream.markInspectionLifecycle();let d=await c,h=Ct(s.resultSchema,d);return h.success?{result:d===void 0?null:d}:{error:{code:Ye.internalError,message:`Invalid result for ${e.method}`,data:{issues:h.error.issues}}}}catch(c){return c instanceof Zt?{error:{code:c.code,message:c.message,data:c.data}}:{error:{code:Ye.internalError,message:c instanceof Error?c.message:String(c)}}}}_buildStreamApi(e,n,i){return{send:r=>{if(i.serverStreamSchema){let s=Ct(i.serverStreamSchema,r);if(!s.success)throw new Error(`Server stream payload failed schema validation: ${s.error.message}`)}return e.send(r)},onMessage:r=>{e.onMessage(s=>{if(i.clientStreamSchema){let o=Ct(i.clientStreamSchema,s);if(!o.success)return;r(o.data);return}})},ping:()=>e.ping(),signal:n}}_handleNotification(e){let n=this._parseRouted(e.method);if(!n.ok)return;let{entry:i,memberName:r}=n,s=i.iface.members[r];if(!(s instanceof Pf))return;let o=i.handlers[r];if(!o)return;let a=Ct(s.paramsSchema,e.params);a.success&&o(a.data,e.context)}_parseRouted(e){let n=Jk(e);if(!n)return{ok:!1,reason:"bad-method-grammar"};if(n.kind==="bare"){if(!this._preset)return{ok:!1,reason:"no-preset"};let o=this._registry.get(`::${this._preset.interfaceId}`);return o?{ok:!0,entry:o,memberName:n.member}:{ok:!1,reason:"no-preset"}}let i=n.kind==="full"?n.serviceId:void 0,r=`${i??""}::${n.interfaceId}`,s=this._registry.get(r);return s?{ok:!0,entry:s,memberName:n.member}:{ok:!1,reason:i?"unknown-service":"unknown-interface"}}_installServiceInspection(e){if(this._serviceInspectionRegistrations.has(e))return;let n=this._inspection,i=this._trafficInspector;if(n===void 0||i===void 0)return;let r=[],s={serviceId:e};try{r.push(this._register(cc,{getNodeId:()=>({nodeId:n.nodeId,portId:n.portId})},s,!0)),r.push(this._register($f,{getGraph:()=>this._endpointGraph(e,n),watchGraph:async(o,a,l)=>(await hx(l.signal),{})},s,!0)),r.push(this._register(Bf,{watch:({methodPrefix:o},a,l)=>this._watchTraffic(i,{methodPrefix:o},l),watchWithPayloads:({methodPrefix:o,maxPayloadBytes:a},l,c)=>this._watchTraffic(i,{methodPrefix:o,maxPayloadBytes:a},c)},s,!0))}catch(o){for(let a of r.reverse())a.dispose();throw o}this._serviceInspectionRegistrations.set(e,r)}_removeServiceInspection(e){let n=this._serviceInspectionRegistrations.get(e);if(n!==void 0){this._serviceInspectionRegistrations.delete(e);for(let i of n.reverse())i.dispose()}}_hasBusinessServiceRegistration(e){return Array.from(this._registry.values()).some(n=>n.serviceId===e&&!n.internalInspection)}_isInspectionMethod(e){let n=this._parseRouted(e);return n.ok&&Jl(n.entry.iface)}_endpointGraph(e,n){return{observerServiceId:e,entryNodeId:n.nodeId,nodes:[{nodeId:n.nodeId,kind:"endpoint",...n.descriptors!==void 0?{descriptors:n.descriptors}:{},ports:[{portId:n.portId}]}],links:[],routes:[{serviceId:e,nodeId:n.nodeId,portId:n.portId,match:"exact"}]}}async _watchTraffic(e,n,i){let r=e.subscribe(n,o=>i.send(o)),s=()=>r.dispose();i.signal.aborted?s():i.signal.addEventListener("abort",s,{once:!0});try{return await r.closed}finally{i.signal.removeEventListener("abort",s),r.dispose()}}};function Uh(t){let e=new Uint8Array(16);return globalThis.crypto.getRandomValues(e),`${t}:${Xk(e)}`}function dx(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++){let i=t[n],r=e[n];if(i.length!==r.length)return!1;for(let s=0;s<i.length;s++)if(i[s].principal!==r[s].principal||i[s].transitive===!0!=(r[s].transitive===!0))return!1}return!0}function Zh(t,e){let n=e.serviceId??"";return(t.interfaceId===void 0||t.interfaceId===e.iface.info.id)&&(t.interfaceIdPrefix===void 0||e.iface.info.id.startsWith(t.interfaceIdPrefix))&&(t.serviceId===void 0||t.serviceId===n)&&Wf(n,t.serviceIdScopes)}var ux=class{_connection;_serviceId;constructor(t,e){this._connection=t,this._serviceId=e}get(t,e={}){return this._connection.get(t,{...e,serviceId:this._serviceId})}register(t,e,n={}){return this._connection.register(t,e,{...n,serviceId:this._serviceId})}};function Ws(t,e){return{error:{code:Ye.methodNotFound,message:`Method not found: ${e}`,data:{reason:t,method:e}}}}function Jl(t){return t===cc||t===$f||t===Bf}function hx(t){return t.aborted?Promise.resolve():new Promise(e=>{t.addEventListener("abort",()=>e(),{once:!0})})}fx(globalThis,{});function fx(t,e){return new Proxy(t,{get(n,i,r){return i in e?e[i]:t[i]},set(n,i,r){return i in e&&delete e[i],t[i]=r,!0},deleteProperty(n,i){let r=!1;return i in e&&(delete e[i],r=!0),i in t&&(delete t[i],r=!0),r},ownKeys(n){let i=Reflect.ownKeys(t),r=Reflect.ownKeys(e),s=new Set(r);return[...i.filter(o=>!s.has(o)),...r]},defineProperty(n,i,r){return i in e&&delete e[i],Reflect.defineProperty(t,i,r),!0},getOwnPropertyDescriptor(n,i){return i in e?Reflect.getOwnPropertyDescriptor(e,i):Reflect.getOwnPropertyDescriptor(t,i)},has(n,i){return i in e||i in t}})}var bn=I();tt({id:"identity",description:"Per-participant key oracle: exposes signing and HPKE-based wrap/unwrap for the identity the executor has attached to this participant's root overlay. Private keys never leave the executor."},{getPrincipal:ae(P({}),P({principal:I()})),getWrapPublicKey:ae(P({}),P({wrapPublicKey:bn})),sign:ae(P({bytes:bn}),P({signature:bn})),wrap:ae(P({domain:I(),bytes:bn}),P({blob:bn})),unwrap:ae(P({domain:I(),blob:bn}),P({bytes:bn}))});tt({id:"identity.storage",description:"Per-identity persistent key/value store. Scope is the executor's managed-identity slot; lifecycle is tied to the identity itself. Backed by an at-rest-encrypted file in the executor."},{get:ae(P({key:I()}),P({value:B(_n())})),set:ae(P({key:I(),value:_n()}),P({})),delete:ae(P({key:I()}),P({existed:ao()})),list:ae(P({prefix:B(I())}),P({keys:Qe(I())}))});var mx=class{_our;_their;_filterSource;_listener;_buffer=[];_closed=!1;_handler=t=>{if(this._filterSource&&t.source!==this._their)return;let e=t.data;px(e)&&(this._listener?this._listener(e):this._buffer.push(e))};constructor(t,e,n=!0){if(this._our=t,this._their=e,this._filterSource=n,t===e)throw new Error("WindowMessageTransport: cannot connect to self");t.addEventListener("message",this._handler)}send(t){this._closed||this._their.postMessage(t,"*")}setListener(t){if(this._listener=t,t)for(;this._buffer.length>0&&this._listener;)t(this._buffer.shift())}dispose(){this._closed||(this._closed=!0,this._our.removeEventListener("message",this._handler))}};function px(t){return typeof t=="object"&&t!==null&&t.jsonrpc==="2.0"}var Xh;function z(t,e,n){function i(a,l){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:l,constr:o,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,l);let c=o.prototype,d=Object.keys(c);for(let h=0;h<d.length;h++){let u=d[h];u in a||(a[u]=c[u].bind(a))}}let r=n?.Parent??Object;class s extends r{}Object.defineProperty(s,"name",{value:t});function o(a){var l;let c=n?.Parent?new s:this;i(c,a),(l=c._zod).deferred??(l.deferred=[]);for(let d of c._zod.deferred)d();return c}return Object.defineProperty(o,"init",{value:i}),Object.defineProperty(o,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(o,"name",{value:t}),o}var Qn=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Zf=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Xh=globalThis).__zod_globalConfig??(Xh.__zod_globalConfig={});var bc=globalThis.__zod_globalConfig;function kn(t){return bc}function Xf(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,i])=>e.indexOf(+n)===-1).map(([n,i])=>i)}function dc(t,e){return typeof e=="bigint"?e.toString():e}function lo(t){return{get value(){{let e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function _c(t){return t==null}function wc(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function gx(t,e){let n=t/e,i=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}var Jh=Symbol("evaluating");function Q(t,e,n){let i;Object.defineProperty(t,e,{get(){if(i!==Jh)return i===void 0&&(i=Jh,i=n()),i},set(r){Object.defineProperty(t,e,{value:r})},configurable:!0})}function Sn(t,e,n){Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Gt(...t){let e={};for(let n of t){let i=Object.getOwnPropertyDescriptors(n);Object.assign(e,i)}return Object.defineProperties({},e)}function Gh(t){return JSON.stringify(t)}function vx(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Jf="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Xi(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var bx=lo(()=>{if(bc.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch{return!1}});function Ji(t){if(Xi(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let n=e.prototype;return!(Xi(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Gf(t){return Ji(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}var _x=new Set(["string","number","symbol"]);function ni(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Yt(t,e,n){let i=new t._zod.constr(e??t._zod.def);return(!e||n?.parent)&&(i._zod.parent=t),i}function A(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function wx(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var yx={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function kx(t,e){let n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return Yt(t,Gt(t._zod.def,{get shape(){let r={};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(r[s]=n.shape[s])}return Sn(this,"shape",r),r},checks:[]}))}function xx(t,e){let n=t._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");return Yt(t,Gt(t._zod.def,{get shape(){let r={...t._zod.def.shape};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete r[s]}return Sn(this,"shape",r),r},checks:[]}))}function Sx(t,e){if(!Ji(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let i=t._zod.def.shape;for(let r in e)if(Object.getOwnPropertyDescriptor(i,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Yt(t,Gt(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return Sn(this,"shape",i),i}}))}function zx(t,e){if(!Ji(e))throw new Error("Invalid input to safeExtend: expected a plain object");return Yt(t,Gt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return Sn(this,"shape",n),n}}))}function Ex(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");return Yt(t,Gt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return Sn(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]}))}function Cx(t,e,n){let i=e._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");return Yt(e,Gt(e._zod.def,{get shape(){let r=e._zod.def.shape,s={...r};if(n)for(let o in n){if(!(o in r))throw new Error(`Unrecognized key: "${o}"`);n[o]&&(s[o]=t?new t({type:"optional",innerType:r[o]}):r[o])}else for(let o in r)s[o]=t?new t({type:"optional",innerType:r[o]}):r[o];return Sn(this,"shape",s),s},checks:[]}))}function Tx(t,e,n){return Yt(e,Gt(e._zod.def,{get shape(){let i=e._zod.def.shape,r={...i};if(n)for(let s in n){if(!(s in r))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(r[s]=new t({type:"nonoptional",innerType:i[s]}))}else for(let s in i)r[s]=new t({type:"nonoptional",innerType:i[s]});return Sn(this,"shape",r),r}}))}function Yn(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==!0)return!0;return!1}function Ox(t,e=0){if(t.aborted===!0)return!0;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue===!1)return!0;return!1}function Yf(t,e){return e.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(t),n})}function Hs(t){return typeof t=="string"?t:t?.message}function xn(t,e,n){let i=t.message?t.message:Hs(t.inst?._zod.def?.error?.(t))??Hs(e?.error?.(t))??Hs(n.customError?.(t))??Hs(n.localeError?.(t))??"Invalid input",{inst:r,continue:s,input:o,...a}=t;return a.path??(a.path=[]),a.message=i,e?.reportInput&&(a.input=o),a}function yc(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Gi(...t){let[e,n,i]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:i}:{...e}}var Qf=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,dc,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},em=z("$ZodError",Qf),tm=z("$ZodError",Qf,{Parent:Error});function Rx(t,e=n=>n.message){let n={},i=[];for(let r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):i.push(e(r));return{formErrors:i,fieldErrors:n}}function Lx(t,e=n=>n.message){let n={_errors:[]},i=(r,s=[])=>{for(let o of r.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(a=>i({issues:a},[...s,...o.path]));else if(o.code==="invalid_key")i({issues:o.issues},[...s,...o.path]);else if(o.code==="invalid_element")i({issues:o.issues},[...s,...o.path]);else{let a=[...s,...o.path];if(a.length===0)n._errors.push(e(o));else{let l=n,c=0;for(;c<a.length;){let d=a[c];c!==a.length-1?l[d]=l[d]||{_errors:[]}:(l[d]=l[d]||{_errors:[]},l[d]._errors.push(e(o))),l=l[d],c++}}}};return i(t),n}var kc=t=>(e,n,i,r)=>{let s=i?{...i,async:!1}:{async:!1},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new Qn;if(o.issues.length){let a=new(r?.Err??t)(o.issues.map(l=>xn(l,s,kn())));throw Jf(a,r?.callee),a}return o.value},xc=t=>async(e,n,i,r)=>{let s=i?{...i,async:!0}:{async:!0},o=e._zod.run({value:n,issues:[]},s);if(o instanceof Promise&&(o=await o),o.issues.length){let a=new(r?.Err??t)(o.issues.map(l=>xn(l,s,kn())));throw Jf(a,r?.callee),a}return o.value},co=t=>(e,n,i)=>{let r=i?{...i,async:!1}:{async:!1},s=e._zod.run({value:n,issues:[]},r);if(s instanceof Promise)throw new Qn;return s.issues.length?{success:!1,error:new(t??em)(s.issues.map(o=>xn(o,r,kn())))}:{success:!0,data:s.value}},Ix=co(tm),uo=t=>async(e,n,i)=>{let r=i?{...i,async:!0}:{async:!0},s=e._zod.run({value:n,issues:[]},r);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(o=>xn(o,r,kn())))}:{success:!0,data:s.value}},Mx=uo(tm),Nx=t=>(e,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return kc(t)(e,n,r)},Ax=t=>(e,n,i)=>kc(t)(e,n,i),Px=t=>async(e,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return xc(t)(e,n,r)},Fx=t=>async(e,n,i)=>xc(t)(e,n,i),$x=t=>(e,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return co(t)(e,n,r)},Bx=t=>(e,n,i)=>co(t)(e,n,i),Dx=t=>async(e,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return uo(t)(e,n,r)},Vx=t=>async(e,n,i)=>uo(t)(e,n,i),qx=/^[cC][0-9a-z]{6,}$/,jx=/^[0-9a-z]+$/,Wx=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hx=/^[0-9a-vA-V]{20}$/,Kx=/^[A-Za-z0-9]{27}$/,Ux=/^[a-zA-Z0-9_-]{21}$/,Zx=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xx=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Yh=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Jx=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gx="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Yx(){return new RegExp(Gx,"u")}var Qx=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,e0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,t0=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,n0=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,i0=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,nm=/^[A-Za-z0-9_-]*$/,r0=/^https?$/,s0=/^\+[1-9]\d{6,14}$/,im="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",o0=new RegExp(`^${im}$`);function rm(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function a0(t){return new RegExp(`^${rm(t)}$`)}function l0(t){let e=rm({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let i=`${e}(?:${n.join("|")})`;return new RegExp(`^${im}T(?:${i})$`)}var c0=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},d0=/^-?\d+$/,u0=/^-?\d+(?:\.\d+)?$/,h0=/^(?:true|false)$/i,f0=/^[^A-Z]*$/,m0=/^[^a-z]*$/,Ue=z("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[])}),sm={number:"number",bigint:"bigint",object:"date"},om=z("$ZodCheckLessThan",(t,e)=>{Ue.init(t,e);let n=sm[typeof e.value];t._zod.onattach.push(i=>{let r=i._zod.bag,s=(e.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?r.maximum=e.value:r.exclusiveMaximum=e.value)}),t._zod.check=i=>{(e.inclusive?i.value<=e.value:i.value<e.value)||i.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),am=z("$ZodCheckGreaterThan",(t,e)=>{Ue.init(t,e);let n=sm[typeof e.value];t._zod.onattach.push(i=>{let r=i._zod.bag,s=(e.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?r.minimum=e.value:r.exclusiveMinimum=e.value)}),t._zod.check=i=>{(e.inclusive?i.value>=e.value:i.value>e.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:i.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),p0=z("$ZodCheckMultipleOf",(t,e)=>{Ue.init(t,e),t._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.multipleOf=e.value)}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):gx(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort})}}),g0=z("$ZodCheckNumberFormat",(t,e)=>{Ue.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),i=n?"int":"number",[r,s]=yx[e.format];t._zod.onattach.push(o=>{let a=o._zod.bag;a.format=e.format,a.minimum=r,a.maximum=s,n&&(a.pattern=d0)}),t._zod.check=o=>{let a=o.value;if(n){if(!Number.isInteger(a)){o.issues.push({expected:i,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?o.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort}):o.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:i,inclusive:!0,continue:!e.abort});return}}a<r&&o.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:t,continue:!e.abort}),a>s&&o.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}}),v0=z("$ZodCheckMaxLength",(t,e)=>{var n;Ue.init(t,e),(n=t._zod.def).when??(n.when=i=>{let r=i.value;return!_c(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{let r=i._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<r&&(i._zod.bag.maximum=e.maximum)}),t._zod.check=i=>{let r=i.value;if(r.length<=e.maximum)return;let s=yc(r);i.issues.push({origin:s,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),b0=z("$ZodCheckMinLength",(t,e)=>{var n;Ue.init(t,e),(n=t._zod.def).when??(n.when=i=>{let r=i.value;return!_c(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{let r=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(i._zod.bag.minimum=e.minimum)}),t._zod.check=i=>{let r=i.value;if(r.length>=e.minimum)return;let s=yc(r);i.issues.push({origin:s,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:t,continue:!e.abort})}}),_0=z("$ZodCheckLengthEquals",(t,e)=>{var n;Ue.init(t,e),(n=t._zod.def).when??(n.when=i=>{let r=i.value;return!_c(r)&&r.length!==void 0}),t._zod.onattach.push(i=>{let r=i._zod.bag;r.minimum=e.length,r.maximum=e.length,r.length=e.length}),t._zod.check=i=>{let r=i.value,s=r.length;if(s===e.length)return;let o=yc(r),a=s>e.length;i.issues.push({origin:o,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:i.value,inst:t,continue:!e.abort})}}),ho=z("$ZodCheckStringFormat",(t,e)=>{var n,i;Ue.init(t,e),t._zod.onattach.push(r=>{let s=r._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(n=t._zod).check??(n.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(i=t._zod).check??(i.check=()=>{})}),w0=z("$ZodCheckRegex",(t,e)=>{ho.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),y0=z("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=f0),ho.init(t,e)}),k0=z("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=m0),ho.init(t,e)}),x0=z("$ZodCheckIncludes",(t,e)=>{Ue.init(t,e);let n=ni(e.includes),i=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=i,t._zod.onattach.push(r=>{let s=r._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(i)}),t._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:t,continue:!e.abort})}}),S0=z("$ZodCheckStartsWith",(t,e)=>{Ue.init(t,e);let n=new RegExp(`^${ni(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.startsWith(e.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:i.value,inst:t,continue:!e.abort})}}),z0=z("$ZodCheckEndsWith",(t,e)=>{Ue.init(t,e);let n=new RegExp(`.*${ni(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(i=>{let r=i._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),t._zod.check=i=>{i.value.endsWith(e.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:i.value,inst:t,continue:!e.abort})}}),E0=z("$ZodCheckOverwrite",(t,e)=>{Ue.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value)}}),C0=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let e=t.split(`
`).filter(r=>r),n=Math.min(...e.map(r=>r.length-r.trimStart().length)),i=e.map(r=>r.slice(n)).map(r=>" ".repeat(this.indent*2)+r);for(let r of i)this.content.push(r)}compile(){let t=Function,e=this?.args,n=[...(this?.content??[""]).map(i=>`  ${i}`)];return new t(...e,n.join(`
`))}},T0={major:4,minor:4,patch:3},ve=z("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=T0;let i=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&i.unshift(t);for(let r of i)for(let s of r._zod.onattach)s(t);if(i.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let r=(o,a,l)=>{let c=Yn(o),d;for(let h of a){if(h._zod.def.when){if(Ox(o)||!h._zod.def.when(o))continue}else if(c)continue;let u=o.issues.length,f=h._zod.check(o);if(f instanceof Promise&&l?.async===!1)throw new Qn;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,o.issues.length!==u&&(c||(c=Yn(o,u)))});else{if(o.issues.length===u)continue;c||(c=Yn(o,u))}}return d?d.then(()=>o):o},s=(o,a,l)=>{if(Yn(o))return o.aborted=!0,o;let c=r(a,i,l);if(c instanceof Promise){if(l.async===!1)throw new Qn;return c.then(d=>t._zod.parse(d,l))}return t._zod.parse(c,l)};t._zod.run=(o,a)=>{if(a.skipChecks)return t._zod.parse(o,a);if(a.direction==="backward"){let c=t._zod.parse({value:o.value,issues:[]},{...a,skipChecks:!0});return c instanceof Promise?c.then(d=>s(d,o,a)):s(c,o,a)}let l=t._zod.parse(o,a);if(l instanceof Promise){if(a.async===!1)throw new Qn;return l.then(c=>r(c,i,a))}return r(l,i,a)}}Q(t,"~standard",()=>({validate:r=>{try{let s=Ix(t,r);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Mx(t,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),Sc=z("$ZodString",(t,e)=>{ve.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??c0(t._zod.bag),t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:t}),n}}),he=z("$ZodStringFormat",(t,e)=>{ho.init(t,e),Sc.init(t,e)}),O0=z("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Xx),he.init(t,e)}),R0=z("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=Yh(n))}else e.pattern??(e.pattern=Yh());he.init(t,e)}),L0=z("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Jx),he.init(t,e)}),I0=z("$ZodURL",(t,e)=>{he.init(t,e),t._zod.check=n=>{try{let i=n.value.trim();if(!e.normalize&&e.protocol?.source===r0.source&&!/^https?:\/\//i.test(i)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:t,continue:!e.abort});return}let r=new URL(i);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=r.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort})}}}),M0=z("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Yx()),he.init(t,e)}),N0=z("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Ux),he.init(t,e)}),A0=z("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=qx),he.init(t,e)}),P0=z("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=jx),he.init(t,e)}),F0=z("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Wx),he.init(t,e)}),$0=z("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Hx),he.init(t,e)}),B0=z("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Kx),he.init(t,e)}),D0=z("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=l0(e)),he.init(t,e)}),V0=z("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=o0),he.init(t,e)}),q0=z("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=a0(e)),he.init(t,e)}),j0=z("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Zx),he.init(t,e)}),W0=z("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Qx),he.init(t,e),t._zod.bag.format="ipv4"}),H0=z("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=e0),he.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort})}}}),K0=z("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=t0),he.init(t,e)}),U0=z("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=n0),he.init(t,e),t._zod.check=n=>{let i=n.value.split("/");try{if(i.length!==2)throw new Error;let[r,s]=i;if(!s)throw new Error;let o=Number(s);if(`${o}`!==s)throw new Error;if(o<0||o>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort})}}});function lm(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Z0=z("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=i0),he.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{lm(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort})}});function X0(t){if(!nm.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/");return lm(e.padEnd(Math.ceil(e.length/4)*4,"="))}var J0=z("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=nm),he.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{X0(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort})}}),G0=z("$ZodE164",(t,e)=>{e.pattern??(e.pattern=s0),he.init(t,e)});function Y0(t,e=null){try{let n=t.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return!1}}var Q0=z("$ZodJWT",(t,e)=>{he.init(t,e),t._zod.check=n=>{Y0(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort})}}),cm=z("$ZodNumber",(t,e)=>{ve.init(t,e),t._zod.pattern=t._zod.bag.pattern??u0,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let s=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:t,...s?{received:s}:{}}),n}}),e1=z("$ZodNumberFormat",(t,e)=>{g0.init(t,e),cm.init(t,e)}),t1=z("$ZodBoolean",(t,e)=>{ve.init(t,e),t._zod.pattern=h0,t._zod.parse=(n,i)=>{if(e.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n}}),n1=z("$ZodUnknown",(t,e)=>{ve.init(t,e),t._zod.parse=n=>n}),i1=z("$ZodNever",(t,e)=>{ve.init(t,e),t._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n)});function Qh(t,e,n){t.issues.length&&e.issues.push(...Yf(n,t.issues)),e.value[n]=t.value}var r1=z("$ZodArray",(t,e)=>{ve.init(t,e),t._zod.parse=(n,i)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);let s=[];for(let o=0;o<r.length;o++){let a=r[o],l=e.element._zod.run({value:a,issues:[]},i);l instanceof Promise?s.push(l.then(c=>Qh(c,n,o))):Qh(l,n,o)}return s.length?Promise.all(s).then(()=>n):n}});function Qs(t,e,n,i,r,s){let o=n in i;if(t.issues.length){if(r&&s&&!o)return;e.issues.push(...Yf(n,t.issues))}if(!o&&!r){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}t.value===void 0?o&&(e.value[n]=void 0):e.value[n]=t.value}function dm(t){let e=Object.keys(t.shape);for(let i of e)if(!t.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);let n=wx(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function um(t,e,n,i,r,s){let o=[],a=r.keySet,l=r.catchall._zod,c=l.def.type,d=l.optin==="optional",h=l.optout==="optional";for(let u in e){if(u==="__proto__"||a.has(u))continue;if(c==="never"){o.push(u);continue}let f=l.run({value:e[u],issues:[]},i);f instanceof Promise?t.push(f.then(m=>Qs(m,n,u,e,d,h))):Qs(f,n,u,e,d,h)}return o.length&&n.issues.push({code:"unrecognized_keys",keys:o,input:e,inst:s}),t.length?Promise.all(t).then(()=>n):n}var s1=z("$ZodObject",(t,e)=>{if(ve.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let o=e.shape;Object.defineProperty(e,"shape",{get:()=>{let a={...o};return Object.defineProperty(e,"shape",{value:a}),a}})}let n=lo(()=>dm(e));Q(t._zod,"propValues",()=>{let o=e.shape,a={};for(let l in o){let c=o[l]._zod;if(c.values){a[l]??(a[l]=new Set);for(let d of c.values)a[l].add(d)}}return a});let i=Xi,r=e.catchall,s;t._zod.parse=(o,a)=>{s??(s=n.value);let l=o.value;if(!i(l))return o.issues.push({expected:"object",code:"invalid_type",input:l,inst:t}),o;o.value={};let c=[],d=s.shape;for(let h of s.keys){let u=d[h],f=u._zod.optin==="optional",m=u._zod.optout==="optional",p=u._zod.run({value:l[h],issues:[]},a);p instanceof Promise?c.push(p.then(v=>Qs(v,o,h,l,f,m))):Qs(p,o,h,l,f,m)}return r?um(c,l,o,a,n.value,t):c.length?Promise.all(c).then(()=>o):o}}),o1=z("$ZodObjectJIT",(t,e)=>{s1.init(t,e);let n=t._zod.parse,i=lo(()=>dm(e)),r=h=>{let u=new C0(["shape","payload","ctx"]),f=i.value,m=w=>{let y=Gh(w);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};u.write("const input = payload.value;");let p=Object.create(null),v=0;for(let w of f.keys)p[w]=`key_${v++}`;u.write("const newResult = {};");for(let w of f.keys){let y=p[w],x=Gh(w),C=h[w],k=C?._zod?.optin==="optional",E=C?._zod?.optout==="optional";u.write(`const ${y} = ${m(w)};`),k&&E?u.write(`
        if (${y}.issues.length) {
          if (${x} in input) {
            payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
              ...iss,
              path: iss.path ? [${x}, ...iss.path] : [${x}]
            })));
          }
        }
        
        if (${y}.value === undefined) {
          if (${x} in input) {
            newResult[${x}] = undefined;
          }
        } else {
          newResult[${x}] = ${y}.value;
        }
        
      `):k?u.write(`
        if (${y}.issues.length) {
          payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
            ...iss,
            path: iss.path ? [${x}, ...iss.path] : [${x}]
          })));
        }
        
        if (${y}.value === undefined) {
          if (${x} in input) {
            newResult[${x}] = undefined;
          }
        } else {
          newResult[${x}] = ${y}.value;
        }
        
      `):u.write(`
        const ${y}_present = ${x} in input;
        if (${y}.issues.length) {
          payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
            ...iss,
            path: iss.path ? [${x}, ...iss.path] : [${x}]
          })));
        }
        if (!${y}_present && !${y}.issues.length) {
          payload.issues.push({
            code: "invalid_type",
            expected: "nonoptional",
            input: undefined,
            path: [${x}]
          });
        }

        if (${y}_present) {
          if (${y}.value === undefined) {
            newResult[${x}] = undefined;
          } else {
            newResult[${x}] = ${y}.value;
          }
        }

      `)}u.write("payload.value = newResult;"),u.write("return payload;");let g=u.compile();return(w,y)=>g(h,w,y)},s,o=Xi,a=!bc.jitless,l=a&&bx.value,c=e.catchall,d;t._zod.parse=(h,u)=>{d??(d=i.value);let f=h.value;return o(f)?a&&l&&u?.async===!1&&u.jitless!==!0?(s||(s=r(e.shape)),h=s(h,u),c?um([],f,h,u,d,t):h):n(h,u):(h.issues.push({expected:"object",code:"invalid_type",input:f,inst:t}),h)}});function ef(t,e,n,i){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let r=t.filter(s=>!Yn(s));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(s=>s.issues.map(o=>xn(o,i,kn())))}),e)}var hm=z("$ZodUnion",(t,e)=>{ve.init(t,e),Q(t._zod,"optin",()=>e.options.some(i=>i._zod.optin==="optional")?"optional":void 0),Q(t._zod,"optout",()=>e.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Q(t._zod,"values",()=>{if(e.options.every(i=>i._zod.values))return new Set(e.options.flatMap(i=>Array.from(i._zod.values)))}),Q(t._zod,"pattern",()=>{if(e.options.every(i=>i._zod.pattern)){let i=e.options.map(r=>r._zod.pattern);return new RegExp(`^(${i.map(r=>wc(r.source)).join("|")})$`)}});let n=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(i,r)=>{if(n)return n(i,r);let s=!1,o=[];for(let a of e.options){let l=a._zod.run({value:i.value,issues:[]},r);if(l instanceof Promise)o.push(l),s=!0;else{if(l.issues.length===0)return l;o.push(l)}}return s?Promise.all(o).then(a=>ef(a,i,t,r)):ef(o,i,t,r)}}),a1=z("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,hm.init(t,e);let n=t._zod.parse;Q(t._zod,"propValues",()=>{let r={};for(let s of e.options){let o=s._zod.propValues;if(!o||Object.keys(o).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,l]of Object.entries(o)){r[a]||(r[a]=new Set);for(let c of l)r[a].add(c)}}return r});let i=lo(()=>{let r=e.options,s=new Map;for(let o of r){let a=o._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(o)}"`);for(let l of a){if(s.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);s.set(l,o)}}return s});t._zod.parse=(r,s)=>{let o=r.value;if(!Xi(o))return r.issues.push({code:"invalid_type",expected:"object",input:o,inst:t}),r;let a=i.value.get(o?.[e.discriminator]);return a?a._zod.run(r,s):e.unionFallback||s.direction==="backward"?n(r,s):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(i.value.keys()),input:o,path:[e.discriminator],inst:t}),r)}}),l1=z("$ZodIntersection",(t,e)=>{ve.init(t,e),t._zod.parse=(n,i)=>{let r=n.value,s=e.left._zod.run({value:r,issues:[]},i),o=e.right._zod.run({value:r,issues:[]},i);return s instanceof Promise||o instanceof Promise?Promise.all([s,o]).then(([a,l])=>tf(n,a,l)):tf(n,s,o)}});function uc(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Ji(t)&&Ji(e)){let n=Object.keys(e),i=Object.keys(t).filter(s=>n.indexOf(s)!==-1),r={...t,...e};for(let s of i){let o=uc(t[s],e[s]);if(!o.valid)return{valid:!1,mergeErrorPath:[s,...o.mergeErrorPath]};r[s]=o.data}return{valid:!0,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<t.length;i++){let r=t[i],s=e[i],o=uc(r,s);if(!o.valid)return{valid:!1,mergeErrorPath:[i,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function tf(t,e,n){let i=new Map,r;for(let a of e.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).l=!0}else t.issues.push(a);for(let a of n.issues)if(a.code==="unrecognized_keys")for(let l of a.keys)i.has(l)||i.set(l,{}),i.get(l).r=!0;else t.issues.push(a);let s=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&r&&t.issues.push({...r,keys:s}),Yn(t))return t;let o=uc(e.value,n.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return t.value=o.data,t}var c1=z("$ZodEnum",(t,e)=>{ve.init(t,e);let n=Xf(e.entries),i=new Set(n);t._zod.values=i,t._zod.pattern=new RegExp(`^(${n.filter(r=>_x.has(typeof r)).map(r=>typeof r=="string"?ni(r):r.toString()).join("|")})$`),t._zod.parse=(r,s)=>{let o=r.value;return i.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:t}),r}}),d1=z("$ZodLiteral",(t,e)=>{if(ve.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let n=new Set(e.values);t._zod.values=n,t._zod.pattern=new RegExp(`^(${e.values.map(i=>typeof i=="string"?ni(i):i?ni(i.toString()):String(i)).join("|")})$`),t._zod.parse=(i,r)=>{let s=i.value;return n.has(s)||i.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),i}}),u1=z("$ZodTransform",(t,e)=>{ve.init(t,e),t._zod.optin="optional",t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zf(t.constructor.name);let r=e.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(n.value=s,n.fallback=!0,n));if(r instanceof Promise)throw new Qn;return n.value=r,n.fallback=!0,n}});function nf(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var fm=z("$ZodOptional",(t,e)=>{ve.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Q(t._zod,"pattern",()=>{let n=e.innerType._zod.pattern;return n?new RegExp(`^(${wc(n.source)})?$`):void 0}),t._zod.parse=(n,i)=>{if(e.innerType._zod.optin==="optional"){let r=n.value,s=e.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>nf(o,r)):nf(s,r)}return n.value===void 0?n:e.innerType._zod.run(n,i)}}),h1=z("$ZodExactOptional",(t,e)=>{fm.init(t,e),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(n,i)=>e.innerType._zod.run(n,i)}),f1=z("$ZodNullable",(t,e)=>{ve.init(t,e),Q(t._zod,"optin",()=>e.innerType._zod.optin),Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"pattern",()=>{let n=e.innerType._zod.pattern;return n?new RegExp(`^(${wc(n.source)}|null)$`):void 0}),Q(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(n,i)=>n.value===null?n:e.innerType._zod.run(n,i)}),m1=z("$ZodDefault",(t,e)=>{ve.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);if(n.value===void 0)return n.value=e.defaultValue,n;let r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>rf(s,e)):rf(r,e)}});function rf(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var p1=z("$ZodPrefault",(t,e)=>{ve.init(t,e),t._zod.optin="optional",Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=e.defaultValue),e.innerType._zod.run(n,i))}),g1=z("$ZodNonOptional",(t,e)=>{ve.init(t,e),Q(t._zod,"values",()=>{let n=e.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),t._zod.parse=(n,i)=>{let r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>sf(s,t)):sf(r,t)}});function sf(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var v1=z("$ZodCatch",(t,e)=>{ve.init(t,e),t._zod.optin="optional",Q(t._zod,"optout",()=>e.innerType._zod.optout),Q(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);let r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(s=>(n.value=s.value,s.issues.length&&(n.value=e.catchValue({...n,error:{issues:s.issues.map(o=>xn(o,i,kn()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=e.catchValue({...n,error:{issues:r.issues.map(s=>xn(s,i,kn()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),b1=z("$ZodPipe",(t,e)=>{ve.init(t,e),Q(t._zod,"values",()=>e.in._zod.values),Q(t._zod,"optin",()=>e.in._zod.optin),Q(t._zod,"optout",()=>e.out._zod.optout),Q(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(n,i)=>{if(i.direction==="backward"){let s=e.out._zod.run(n,i);return s instanceof Promise?s.then(o=>Ks(o,e.in,i)):Ks(s,e.in,i)}let r=e.in._zod.run(n,i);return r instanceof Promise?r.then(s=>Ks(s,e.out,i)):Ks(r,e.out,i)}});function Ks(t,e,n){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},n)}var _1=z("$ZodReadonly",(t,e)=>{ve.init(t,e),Q(t._zod,"propValues",()=>e.innerType._zod.propValues),Q(t._zod,"values",()=>e.innerType._zod.values),Q(t._zod,"optin",()=>e.innerType?._zod?.optin),Q(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(n,i)=>{if(i.direction==="backward")return e.innerType._zod.run(n,i);let r=e.innerType._zod.run(n,i);return r instanceof Promise?r.then(of):of(r)}});function of(t){return t.value=Object.freeze(t.value),t}var w1=z("$ZodCustom",(t,e)=>{Ue.init(t,e),ve.init(t,e),t._zod.parse=(n,i)=>n,t._zod.check=n=>{let i=n.value,r=e.fn(i);if(r instanceof Promise)return r.then(s=>af(s,n,i,t));af(r,n,i,t)}});function af(t,e,n,i){if(!t){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),e.issues.push(Gi(r))}}var lf,y1=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...e){let n=e[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let e=this._map.get(t);return e&&typeof e=="object"&&"id"in e&&this._idmap.delete(e.id),this._map.delete(t),this}get(t){let e=t._zod.parent;if(e){let n={...this.get(e)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function k1(){return new y1}(lf=globalThis).__zod_globalRegistry??(lf.__zod_globalRegistry=k1());var Ki=globalThis.__zod_globalRegistry;function x1(t,e){return new t({type:"string",...A(e)})}function S1(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...A(e)})}function cf(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...A(e)})}function z1(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...A(e)})}function E1(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(e)})}function C1(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(e)})}function T1(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(e)})}function O1(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...A(e)})}function R1(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...A(e)})}function L1(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(e)})}function I1(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...A(e)})}function M1(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(e)})}function N1(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...A(e)})}function A1(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...A(e)})}function P1(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(e)})}function F1(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(e)})}function $1(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(e)})}function B1(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(e)})}function D1(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(e)})}function V1(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...A(e)})}function q1(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...A(e)})}function j1(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...A(e)})}function W1(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...A(e)})}function H1(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(e)})}function K1(t,e){return new t({type:"string",format:"date",check:"string_format",...A(e)})}function U1(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...A(e)})}function Z1(t,e){return new t({type:"string",format:"duration",check:"string_format",...A(e)})}function X1(t,e){return new t({type:"number",checks:[],...A(e)})}function J1(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...A(e)})}function G1(t,e){return new t({type:"boolean",...A(e)})}function Y1(t){return new t({type:"unknown"})}function Q1(t,e){return new t({type:"never",...A(e)})}function df(t,e){return new om({check:"less_than",...A(e),value:t,inclusive:!1})}function Gl(t,e){return new om({check:"less_than",...A(e),value:t,inclusive:!0})}function uf(t,e){return new am({check:"greater_than",...A(e),value:t,inclusive:!1})}function Yl(t,e){return new am({check:"greater_than",...A(e),value:t,inclusive:!0})}function hf(t,e){return new p0({check:"multiple_of",...A(e),value:t})}function mm(t,e){return new v0({check:"max_length",...A(e),maximum:t})}function eo(t,e){return new b0({check:"min_length",...A(e),minimum:t})}function pm(t,e){return new _0({check:"length_equals",...A(e),length:t})}function eS(t,e){return new w0({check:"string_format",format:"regex",...A(e),pattern:t})}function tS(t){return new y0({check:"string_format",format:"lowercase",...A(t)})}function nS(t){return new k0({check:"string_format",format:"uppercase",...A(t)})}function iS(t,e){return new x0({check:"string_format",format:"includes",...A(e),includes:t})}function rS(t,e){return new S0({check:"string_format",format:"starts_with",...A(e),prefix:t})}function sS(t,e){return new z0({check:"string_format",format:"ends_with",...A(e),suffix:t})}function ii(t){return new E0({check:"overwrite",tx:t})}function oS(t){return ii(e=>e.normalize(t))}function aS(){return ii(t=>t.trim())}function lS(){return ii(t=>t.toLowerCase())}function cS(){return ii(t=>t.toUpperCase())}function dS(){return ii(t=>vx(t))}function uS(t,e,n){return new t({type:"array",element:e,...A(n)})}function hS(t,e,n){return new t({type:"custom",check:"custom",fn:e,...A(n)})}function fS(t,e){let n=mS(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(Gi(r,i.value,n._zod.def));else{let s=r;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=i.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),i.issues.push(Gi(s))}},t(i.value,i)),e);return n}function mS(t,e){let n=new Ue({check:"custom",...A(e)});return n._zod.check=t,n}function gm(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Ki,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function Re(t,e,n={path:[],schemaPath:[]}){var i;let r=t._zod.def,s=e.seen.get(t);if(s)return s.count++,n.schemaPath.includes(t)&&(s.cycle=n.path),s.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};e.seen.set(t,o);let a=t._zod.toJSONSchema?.();if(a)o.schema=a;else{let c={...n,schemaPath:[...n.schemaPath,t],path:n.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,o.schema,c);else{let h=o.schema,u=e.processors[r.type];if(!u)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);u(t,e,h,c)}let d=t._zod.parent;d&&(o.ref||(o.ref=d),Re(d,e,c),e.seen.get(d).isParent=!0)}let l=e.metadataRegistry.get(t);return l&&Object.assign(o.schema,l),e.io==="input"&&De(t)&&(delete o.schema.examples,delete o.schema.default),e.io==="input"&&"_prefault"in o.schema&&((i=o.schema).default??(i.default=o.schema._prefault)),delete o.schema._prefault,e.seen.get(t).schema}function vm(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=new Map;for(let o of t.seen.entries()){let a=t.metadataRegistry.get(o[0])?.id;if(a){let l=i.get(a);if(l&&l!==o[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,o[0])}}let r=o=>{let a=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(o[0])?.id,h=t.external.uri??(f=>f);if(d)return{ref:h(d)};let u=o[1].defId??o[1].schema.id??`schema${t.counter++}`;return o[1].defId=u,{defId:u,ref:`${h("__shared")}#/${a}/${u}`}}if(o[1]===n)return{ref:"#"};let l=`#/${a}/`,c=o[1].schema.id??`__schema${t.counter++}`;return{defId:c,ref:l+c}},s=o=>{if(o[1].schema.$ref)return;let a=o[1],{ref:l,defId:c}=r(o);a.def={...a.schema},c&&(a.defId=c);let d=a.schema;for(let h in d)delete d[h];d.$ref=l};if(t.cycles==="throw")for(let o of t.seen.entries()){let a=o[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>

Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let o of t.seen.entries()){let a=o[1];if(e===o[0]){s(o);continue}if(t.external){let l=t.external.registry.get(o[0])?.id;if(e!==o[0]&&l){s(o);continue}}if(t.metadataRegistry.get(o[0])?.id){s(o);continue}if(a.cycle){s(o);continue}if(a.count>1&&t.reused==="ref"){s(o);continue}}}function bm(t,e){let n=t.seen.get(e);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=a=>{let l=t.seen.get(a);if(l.ref===null)return;let c=l.def??l.schema,d={...c},h=l.ref;if(l.ref=null,h){i(h);let f=t.seen.get(h),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(m)):Object.assign(c,m),Object.assign(c,d),a._zod.parent===h)for(let p in c)p==="$ref"||p==="allOf"||p in d||delete c[p];if(m.$ref&&f.def)for(let p in c)p==="$ref"||p==="allOf"||p in f.def&&JSON.stringify(c[p])===JSON.stringify(f.def[p])&&delete c[p]}let u=a._zod.parent;if(u&&u!==h){i(u);let f=t.seen.get(u);if(f?.schema.$ref&&(c.$ref=f.schema.$ref,f.def))for(let m in c)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(c[m])===JSON.stringify(f.def[m])&&delete c[m]}t.override({zodSchema:a,jsonSchema:c,path:l.path??[]})};for(let a of[...t.seen.entries()].reverse())i(a[0]);let r={};if(t.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=t.external.uri(a)}Object.assign(r,n.def??n.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&r.id===s&&delete r.id;let o=t.external?.defs??{};for(let a of t.seen.entries()){let l=a[1];l.def&&l.defId&&(l.def.id===l.defId&&delete l.def.id,o[l.defId]=l.def)}t.external||Object.keys(o).length>0&&(t.target==="draft-2020-12"?r.$defs=o:r.definitions=o);try{let a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:to(e,"input",t.processors),output:to(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function De(t,e){let n=e??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let i=t._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return De(i.element,n);if(i.type==="set")return De(i.valueType,n);if(i.type==="lazy")return De(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return De(i.innerType,n);if(i.type==="intersection")return De(i.left,n)||De(i.right,n);if(i.type==="record"||i.type==="map")return De(i.keyType,n)||De(i.valueType,n);if(i.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:De(i.in,n)||De(i.out,n);if(i.type==="object"){for(let r in i.shape)if(De(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(De(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(De(r,n))return!0;return!!(i.rest&&De(i.rest,n))}return!1}var pS=(t,e={})=>n=>{let i=gm({...n,processors:e});return Re(t,i),vm(i,t),bm(i,t)},to=(t,e,n={})=>i=>{let{libraryOptions:r,target:s}=i??{},o=gm({...r??{},target:s,io:e,processors:n});return Re(t,o),vm(o,t),bm(o,t)},gS={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},vS=(t,e,n,i)=>{let r=n;r.type="string";let{minimum:s,maximum:o,format:a,patterns:l,contentEncoding:c}=t._zod.bag;if(typeof s=="number"&&(r.minLength=s),typeof o=="number"&&(r.maxLength=o),a&&(r.format=gS[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),c&&(r.contentEncoding=c),l&&l.size>0){let d=[...l];d.length===1?r.pattern=d[0].source:d.length>1&&(r.allOf=[...d.map(h=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},bS=(t,e,n,i)=>{let r=n,{minimum:s,maximum:o,format:a,multipleOf:l,exclusiveMaximum:c,exclusiveMinimum:d}=t._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number";let h=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),u=typeof c=="number"&&c<=(o??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";h?f?(r.minimum=d,r.exclusiveMinimum=!0):r.exclusiveMinimum=d:typeof s=="number"&&(r.minimum=s),u?f?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof o=="number"&&(r.maximum=o),typeof l=="number"&&(r.multipleOf=l)},_S=(t,e,n,i)=>{n.type="boolean"},wS=(t,e,n,i)=>{n.not={}},yS=(t,e,n,i)=>{let r=t._zod.def,s=Xf(r.entries);s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),n.enum=s},kS=(t,e,n,i)=>{let r=t._zod.def,s=[];for(let o of r.values)if(o===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof o=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");s.push(Number(o))}else s.push(o);if(s.length!==0)if(s.length===1){let o=s[0];n.type=o===null?"null":typeof o,e.target==="draft-04"||e.target==="openapi-3.0"?n.enum=[o]:n.const=o}else s.every(o=>typeof o=="number")&&(n.type="number"),s.every(o=>typeof o=="string")&&(n.type="string"),s.every(o=>typeof o=="boolean")&&(n.type="boolean"),s.every(o=>o===null)&&(n.type="null"),n.enum=s},xS=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},SS=(t,e,n,i)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},zS=(t,e,n,i)=>{let r=n,s=t._zod.def,{minimum:o,maximum:a}=t._zod.bag;typeof o=="number"&&(r.minItems=o),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=Re(s.element,e,{...i,path:[...i.path,"items"]})},ES=(t,e,n,i)=>{let r=n,s=t._zod.def;r.type="object",r.properties={};let o=s.shape;for(let c in o)r.properties[c]=Re(o[c],e,{...i,path:[...i.path,"properties",c]});let a=new Set(Object.keys(o)),l=new Set([...a].filter(c=>{let d=s.shape[c]._zod;return e.io==="input"?d.optin===void 0:d.optout===void 0}));l.size>0&&(r.required=Array.from(l)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=Re(s.catchall,e,{...i,path:[...i.path,"additionalProperties"]})):e.io==="output"&&(r.additionalProperties=!1)},CS=(t,e,n,i)=>{let r=t._zod.def,s=r.inclusive===!1,o=r.options.map((a,l)=>Re(a,e,{...i,path:[...i.path,s?"oneOf":"anyOf",l]}));s?n.oneOf=o:n.anyOf=o},TS=(t,e,n,i)=>{let r=t._zod.def,s=Re(r.left,e,{...i,path:[...i.path,"allOf",0]}),o=Re(r.right,e,{...i,path:[...i.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1;n.allOf=[...a(s)?s.allOf:[s],...a(o)?o.allOf:[o]]},OS=(t,e,n,i)=>{let r=t._zod.def,s=Re(r.innerType,e,i),o=e.seen.get(t);e.target==="openapi-3.0"?(o.ref=r.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},RS=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType},LS=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},IS=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,e.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},MS=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType;let o;try{o=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=o},NS=(t,e,n,i)=>{let r=t._zod.def,s=r.in._zod.traits.has("$ZodTransform"),o=e.io==="input"?s?r.out:r.in:r.out;Re(o,e,i);let a=e.seen.get(t);a.ref=o},AS=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType,n.readOnly=!0},_m=(t,e,n,i)=>{let r=t._zod.def;Re(r.innerType,e,i);let s=e.seen.get(t);s.ref=r.innerType},PS=z("ZodISODateTime",(t,e)=>{D0.init(t,e),me.init(t,e)});function FS(t){return H1(PS,t)}var $S=z("ZodISODate",(t,e)=>{V0.init(t,e),me.init(t,e)});function BS(t){return K1($S,t)}var DS=z("ZodISOTime",(t,e)=>{q0.init(t,e),me.init(t,e)});function VS(t){return U1(DS,t)}var qS=z("ZodISODuration",(t,e)=>{j0.init(t,e),me.init(t,e)});function jS(t){return Z1(qS,t)}var WS=(t,e)=>{em.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:n=>Lx(t,n)},flatten:{value:n=>Rx(t,n)},addIssue:{value:n=>{t.issues.push(n),t.message=JSON.stringify(t.issues,dc,2)}},addIssues:{value:n=>{t.issues.push(...n),t.message=JSON.stringify(t.issues,dc,2)}},isEmpty:{get(){return t.issues.length===0}}})},dt=z("ZodError",WS,{Parent:Error}),HS=kc(dt),KS=xc(dt),US=co(dt),ZS=uo(dt),XS=Nx(dt),JS=Ax(dt),GS=Px(dt),YS=Fx(dt),QS=$x(dt),ez=Bx(dt),tz=Dx(dt),nz=Vx(dt),ff=new WeakMap;function Qi(t,e,n){let i=Object.getPrototypeOf(t),r=ff.get(i);if(r||(r=new Set,ff.set(i,r)),!r.has(e)){r.add(e);for(let s in n){let o=n[s];Object.defineProperty(i,s,{configurable:!0,enumerable:!1,get(){let a=o.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var be=z("ZodType",(t,e)=>(ve.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:to(t,"input"),output:to(t,"output")}}),t.toJSONSchema=pS(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(n,i)=>HS(t,n,i,{callee:t.parse}),t.safeParse=(n,i)=>US(t,n,i),t.parseAsync=async(n,i)=>KS(t,n,i,{callee:t.parseAsync}),t.safeParseAsync=async(n,i)=>ZS(t,n,i),t.spa=t.safeParseAsync,t.encode=(n,i)=>XS(t,n,i),t.decode=(n,i)=>JS(t,n,i),t.encodeAsync=async(n,i)=>GS(t,n,i),t.decodeAsync=async(n,i)=>YS(t,n,i),t.safeEncode=(n,i)=>QS(t,n,i),t.safeDecode=(n,i)=>ez(t,n,i),t.safeEncodeAsync=async(n,i)=>tz(t,n,i),t.safeDecodeAsync=async(n,i)=>nz(t,n,i),Qi(t,"ZodType",{check(...n){let i=this.def;return this.clone(Gt(i,{checks:[...i.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,i){return Yt(this,n,i)},brand(){return this},register(n,i){return n.add(this,i),this},refine(n,i){return this.check(Jz(n,i))},superRefine(n,i){return this.check(Gz(n,i))},overwrite(n){return this.check(ii(n))},optional(){return gf(this)},exactOptional(){return Fz(this)},nullable(){return vf(this)},nullish(){return gf(vf(this))},nonoptional(n){return jz(this,n)},array(){return ei(this)},or(n){return Tz([this,n])},and(n){return Iz(this,n)},transform(n){return bf(this,Az(n))},default(n){return Dz(this,n)},prefault(n){return qz(this,n)},catch(n){return Hz(this,n)},pipe(n){return bf(this,n)},readonly(){return Zz(this)},describe(n){let i=this.clone();return Ki.add(i,{description:n}),i},meta(...n){if(n.length===0)return Ki.get(this);let i=this.clone();return Ki.add(i,n[0]),i},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(t,"description",{get(){return Ki.get(t)?.description},configurable:!0}),t)),wm=z("_ZodString",(t,e)=>{Sc.init(t,e),be.init(t,e),t._zod.processJSONSchema=(i,r,s)=>vS(t,i,r);let n=t._zod.bag;t.format=n.format??null,t.minLength=n.minimum??null,t.maxLength=n.maximum??null,Qi(t,"_ZodString",{regex(...i){return this.check(eS(...i))},includes(...i){return this.check(iS(...i))},startsWith(...i){return this.check(rS(...i))},endsWith(...i){return this.check(sS(...i))},min(...i){return this.check(eo(...i))},max(...i){return this.check(mm(...i))},length(...i){return this.check(pm(...i))},nonempty(...i){return this.check(eo(1,...i))},lowercase(i){return this.check(tS(i))},uppercase(i){return this.check(nS(i))},trim(){return this.check(aS())},normalize(...i){return this.check(oS(...i))},toLowerCase(){return this.check(lS())},toUpperCase(){return this.check(cS())},slugify(){return this.check(dS())}})}),iz=z("ZodString",(t,e)=>{Sc.init(t,e),wm.init(t,e),t.email=n=>t.check(S1(rz,n)),t.url=n=>t.check(O1(sz,n)),t.jwt=n=>t.check(W1(wz,n)),t.emoji=n=>t.check(R1(oz,n)),t.guid=n=>t.check(cf(mf,n)),t.uuid=n=>t.check(z1(Us,n)),t.uuidv4=n=>t.check(E1(Us,n)),t.uuidv6=n=>t.check(C1(Us,n)),t.uuidv7=n=>t.check(T1(Us,n)),t.nanoid=n=>t.check(L1(az,n)),t.guid=n=>t.check(cf(mf,n)),t.cuid=n=>t.check(I1(lz,n)),t.cuid2=n=>t.check(M1(cz,n)),t.ulid=n=>t.check(N1(dz,n)),t.base64=n=>t.check(V1(vz,n)),t.base64url=n=>t.check(q1(bz,n)),t.xid=n=>t.check(A1(uz,n)),t.ksuid=n=>t.check(P1(hz,n)),t.ipv4=n=>t.check(F1(fz,n)),t.ipv6=n=>t.check($1(mz,n)),t.cidrv4=n=>t.check(B1(pz,n)),t.cidrv6=n=>t.check(D1(gz,n)),t.e164=n=>t.check(j1(_z,n)),t.datetime=n=>t.check(FS(n)),t.date=n=>t.check(BS(n)),t.time=n=>t.check(VS(n)),t.duration=n=>t.check(jS(n))});function We(t){return x1(iz,t)}var me=z("ZodStringFormat",(t,e)=>{he.init(t,e),wm.init(t,e)}),rz=z("ZodEmail",(t,e)=>{L0.init(t,e),me.init(t,e)}),mf=z("ZodGUID",(t,e)=>{O0.init(t,e),me.init(t,e)}),Us=z("ZodUUID",(t,e)=>{R0.init(t,e),me.init(t,e)}),sz=z("ZodURL",(t,e)=>{I0.init(t,e),me.init(t,e)}),oz=z("ZodEmoji",(t,e)=>{M0.init(t,e),me.init(t,e)}),az=z("ZodNanoID",(t,e)=>{N0.init(t,e),me.init(t,e)}),lz=z("ZodCUID",(t,e)=>{A0.init(t,e),me.init(t,e)}),cz=z("ZodCUID2",(t,e)=>{P0.init(t,e),me.init(t,e)}),dz=z("ZodULID",(t,e)=>{F0.init(t,e),me.init(t,e)}),uz=z("ZodXID",(t,e)=>{$0.init(t,e),me.init(t,e)}),hz=z("ZodKSUID",(t,e)=>{B0.init(t,e),me.init(t,e)}),fz=z("ZodIPv4",(t,e)=>{W0.init(t,e),me.init(t,e)}),mz=z("ZodIPv6",(t,e)=>{H0.init(t,e),me.init(t,e)}),pz=z("ZodCIDRv4",(t,e)=>{K0.init(t,e),me.init(t,e)}),gz=z("ZodCIDRv6",(t,e)=>{U0.init(t,e),me.init(t,e)}),vz=z("ZodBase64",(t,e)=>{Z0.init(t,e),me.init(t,e)}),bz=z("ZodBase64URL",(t,e)=>{J0.init(t,e),me.init(t,e)}),_z=z("ZodE164",(t,e)=>{G0.init(t,e),me.init(t,e)}),wz=z("ZodJWT",(t,e)=>{Q0.init(t,e),me.init(t,e)}),ym=z("ZodNumber",(t,e)=>{cm.init(t,e),be.init(t,e),t._zod.processJSONSchema=(i,r,s)=>bS(t,i,r),Qi(t,"ZodNumber",{gt(i,r){return this.check(uf(i,r))},gte(i,r){return this.check(Yl(i,r))},min(i,r){return this.check(Yl(i,r))},lt(i,r){return this.check(df(i,r))},lte(i,r){return this.check(Gl(i,r))},max(i,r){return this.check(Gl(i,r))},int(i){return this.check(pf(i))},safe(i){return this.check(pf(i))},positive(i){return this.check(uf(0,i))},nonnegative(i){return this.check(Yl(0,i))},negative(i){return this.check(df(0,i))},nonpositive(i){return this.check(Gl(0,i))},multipleOf(i,r){return this.check(hf(i,r))},step(i,r){return this.check(hf(i,r))},finite(){return this}});let n=t._zod.bag;t.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),t.isFinite=!0,t.format=n.format??null});function $t(t){return X1(ym,t)}var yz=z("ZodNumberFormat",(t,e)=>{e1.init(t,e),ym.init(t,e)});function pf(t){return J1(yz,t)}var kz=z("ZodBoolean",(t,e)=>{t1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>_S(t,n,i)});function He(t){return G1(kz,t)}var xz=z("ZodUnknown",(t,e)=>{n1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>{}});function hc(){return Y1(xz)}var Sz=z("ZodNever",(t,e)=>{i1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>wS(t,n,i)});function zz(t){return Q1(Sz,t)}var Ez=z("ZodArray",(t,e)=>{r1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>zS(t,n,i,r),t.element=e.element,Qi(t,"ZodArray",{min(n,i){return this.check(eo(n,i))},nonempty(n){return this.check(eo(1,n))},max(n,i){return this.check(mm(n,i))},length(n,i){return this.check(pm(n,i))},unwrap(){return this.element}})});function ei(t,e){return uS(Ez,t,e)}var Cz=z("ZodObject",(t,e)=>{o1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>ES(t,n,i,r),Q(t,"shape",()=>e.shape),Qi(t,"ZodObject",{keyof(){return zc(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:hc()})},loose(){return this.clone({...this._zod.def,catchall:hc()})},strict(){return this.clone({...this._zod.def,catchall:zz()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Sx(this,n)},safeExtend(n){return zx(this,n)},merge(n){return Ex(this,n)},pick(n){return kx(this,n)},omit(n){return xx(this,n)},partial(...n){return Cx(xm,this,n[0])},required(...n){return Tx(Sm,this,n[0])}})});function Y(t,e){let n={type:"object",shape:t??{},...A(e)};return new Cz(n)}var km=z("ZodUnion",(t,e)=>{hm.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>CS(t,n,i,r),t.options=e.options});function Tz(t,e){return new km({type:"union",options:t,...A(e)})}var Oz=z("ZodDiscriminatedUnion",(t,e)=>{km.init(t,e),a1.init(t,e)});function Rz(t,e,n){return new Oz({type:"union",options:e,discriminator:t,...A(n)})}var Lz=z("ZodIntersection",(t,e)=>{l1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>TS(t,n,i,r)});function Iz(t,e){return new Lz({type:"intersection",left:t,right:e})}var fc=z("ZodEnum",(t,e)=>{c1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(i,r,s)=>yS(t,i,r),t.enum=e.entries,t.options=Object.values(e.entries);let n=new Set(Object.keys(e.entries));t.extract=(i,r)=>{let s={};for(let o of i)if(n.has(o))s[o]=e.entries[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...e,checks:[],...A(r),entries:s})},t.exclude=(i,r)=>{let s={...e.entries};for(let o of i)if(n.has(o))delete s[o];else throw new Error(`Key ${o} not found in enum`);return new fc({...e,checks:[],...A(r),entries:s})}});function zc(t,e){let n=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new fc({type:"enum",entries:n,...A(e)})}var Mz=z("ZodLiteral",(t,e)=>{d1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>kS(t,n,i),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function no(t,e){return new Mz({type:"literal",values:Array.isArray(t)?t:[t],...A(e)})}var Nz=z("ZodTransform",(t,e)=>{u1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>SS(t,n),t._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Zf(t.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(Gi(s,n.value,e));else{let o=s;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=n.value),o.inst??(o.inst=t),n.issues.push(Gi(o))}};let r=e.transform(n.value,n);return r instanceof Promise?r.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function Az(t){return new Nz({type:"transform",transform:t})}var xm=z("ZodOptional",(t,e)=>{fm.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>_m(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function gf(t){return new xm({type:"optional",innerType:t})}var Pz=z("ZodExactOptional",(t,e)=>{h1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>_m(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function Fz(t){return new Pz({type:"optional",innerType:t})}var $z=z("ZodNullable",(t,e)=>{f1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>OS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function vf(t){return new $z({type:"nullable",innerType:t})}var Bz=z("ZodDefault",(t,e)=>{m1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>LS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Dz(t,e){return new Bz({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():Gf(e)}})}var Vz=z("ZodPrefault",(t,e)=>{p1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>IS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function qz(t,e){return new Vz({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():Gf(e)}})}var Sm=z("ZodNonOptional",(t,e)=>{g1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>RS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function jz(t,e){return new Sm({type:"nonoptional",innerType:t,...A(e)})}var Wz=z("ZodCatch",(t,e)=>{v1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>MS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Hz(t,e){return new Wz({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Kz=z("ZodPipe",(t,e)=>{b1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>NS(t,n,i,r),t.in=e.in,t.out=e.out});function bf(t,e){return new Kz({type:"pipe",in:t,out:e})}var Uz=z("ZodReadonly",(t,e)=>{_1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>AS(t,n,i,r),t.unwrap=()=>t._zod.def.innerType});function Zz(t){return new Uz({type:"readonly",innerType:t})}var Xz=z("ZodCustom",(t,e)=>{w1.init(t,e),be.init(t,e),t._zod.processJSONSchema=(n,i,r)=>xS(t,n)});function Jz(t,e={}){return hS(Xz,t,e)}function Gz(t,e){return fS(t,e)}var io=hc(),Yz=Y({supportsContentEdits:He().optional(),supportsOptions:He().optional()}),Qz=Y({supportsContentEdits:He().optional(),supportsOptions:He().optional(),supportsForceUpdate:He().optional()}),eE=Y({offset:$t().int().nonnegative(),length:$t().int().nonnegative(),newText:We()}),zm=Rz("kind",[Y({kind:no("replace"),path:ei(We()),newValue:io}),Y({kind:no("stringEdits"),path:ei(We()),stringEdits:ei(eE)})]),tE=Y({content:io.optional(),options:io.optional(),readOnly:He().optional(),serverRevision:$t().int().nonnegative().optional(),acknowledgedClientRevision:$t().int().nonnegative().optional(),force:He().optional()}),nE=tt({id:"web-editor-host",description:"Methods the host exposes to the editor (web-editor/0.12)."},{initialized:ae(Y({protocolVersion:no("web-editor/0.12"),contentType:zc(["text","json"]),capabilities:Yz.optional()}),Y({protocolVersion:no("web-editor-host/0.12"),capabilities:Qz.optional()})),applyContentEdit:Jt(Y({edits:ei(zm),clientRevision:$t().int().nonnegative(),basedOnServerRevision:$t().int().nonnegative()})),reportSize:Jt(Y({height:$t().nonnegative()}))}),iE=tt({id:"web-editor",description:"Methods the editor exposes to the host (web-editor/0.12)."},{update:Jt(tE),applyContentEdits:Jt(Y({edits:ei(zm),serverRevision:$t().int().nonnegative(),acknowledgedClientRevision:$t().int().nonnegative()})),getContentSchema:ae(Y({}),Y({schema:io}))}),Zs=Y({registered:He(),isDefault:He()}),Ec=Y({handleId:We(),appId:We(),serviceId:We(),serviceIdPrefix:We()}),rE=Ec.extend({parentAppId:We()});tt({id:"vscode-app-host",description:"Methods an app `.vscode-app.html` exposes to the host (vscode-app-host/0.1)."},{getContext:ae(Y({}),Y({dataDocument:Y({contentType:zc(["text","json"])}).nullable(),embedding:rE.nullable()})),loadApp:ae(Y({path:We()}),Ec).withStream({server:Y({})}),unloadApp:ae(Y({handleId:We()}),Y({})),embeddedReady:Jt(Y({})),setModalVisibility:ae(Y({visible:He(),presentation:Y({title:We().optional()}).optional()}),Y({})),getEditorRegistration:ae(Y({extension:We()}),Y({global:Zs,workspace:Zs,hasWorkspace:He()})),configureEditorAssociation:ae(Y({extension:We(),dismissable:He().optional()}),Y({global:Zs,workspace:Zs,hasWorkspace:He(),changed:He()}))});tt({id:"vscode-app-embedding-events",description:"Lifecycle notifications for child apps loaded by a VS Code app."},{changed:Jt(Ec),removed:Jt(Y({handleId:We()}))});function _f(t,e){let n=t;for(let i of e)if(i.kind==="replace")n=wf(n,i.path,i.newValue);else{let r=oE(n,i.path);if(typeof r!="string")throw new Error(`applyContentEdits: stringEdits at path [${i.path.join(", ")}] requires a string, got ${typeof r}`);n=wf(n,i.path,sE(r,i.stringEdits))}return n}function sE(t,e){let n=t;for(let i of e)n=n.slice(0,i.offset)+i.newText+n.slice(i.offset+i.length);return n}function oE(t,e){let n=t;for(let i of e){if(n==null)return;n=n[i]}return n}function wf(t,e,n){if(e.length===0)return n;let i=t===null||typeof t!="object"?{}:t,r=i;for(let s=0;s<e.length-1;s++){let o=e[s],a=r[o];(a===null||typeof a!="object")&&(r[o]={}),r=r[o]}return r[e[e.length-1]]=n,i}function Ql(t,e){return e==="text"?t:t===""?null:JSON.parse(t)}function yf(t,e,n={}){if(e==="text"){if(typeof t!="string")throw new Error(`decodeFromEditor: expected string for text content, got ${typeof t}`);return t}let i=n.indentation;if(t!==null&&typeof t=="object"&&!Array.isArray(t)){let r=t["$web-editor.format-json"];typeof r=="number"||r==="	"?i=r:r!==void 0&&(i=4)}return JSON.stringify(t,void 0,i)}var ec=class{_listeners=new Set;event=t=>(this._listeners.add(t),{dispose:()=>this._listeners.delete(t)});fire(t){for(let e of this._listeners)try{e(t)}catch(n){console.error("Emitter listener threw:",n)}}dispose(){this._listeners.clear()}},aE=class{_connection;_editor;_contentType;_jsonFormat;_onError;_capabilities;_text;_readOnly;_serverRevision=0;_acknowledgedClientRevision=0;_editorInitialized=!1;_editorCapabilities;_onDidChangeText=new ec;onDidChangeText=this._onDidChangeText.event;_onDidInitialize=new ec;onDidInitialize=this._onDidInitialize.event;_onDidReportSize=new ec;onDidReportSize=this._onDidReportSize.event;constructor(t){this._connection=t.connection,this._contentType=t.contentType??"text",this._text=t.initialText??"",this._readOnly=t.readOnly??!1,this._jsonFormat=t.jsonFormat??{},this._onError=t.onError??((e,n)=>console.error("WebEditorHost:",e,n)),this._capabilities=t.capabilities??{supportsForceUpdate:!0},this._editor=this._connection.get(iE),this._connection.register(nE,{initialized:e=>(e.contentType!==this._contentType&&this._onError(`Editor contentType "${e.contentType}" does not match host "${this._contentType}"`),this._editorCapabilities=e.capabilities,this._editorInitialized=!0,this._serverRevision=0,this._acknowledgedClientRevision=0,this._pushFullUpdate(),this._onDidInitialize.fire({capabilities:e.capabilities}),{protocolVersion:"web-editor-host/0.12",capabilities:this._capabilities}),applyContentEdit:e=>{if(this._readOnly){this._onError("Editor sent applyContentEdit while readOnly"),this._acknowledgeAndRestore(e.clientRevision);return}if(e.basedOnServerRevision!==this._serverRevision){this._onError(`Editor edit is based on stale server revision ${e.basedOnServerRevision}; current revision is ${this._serverRevision}`),this._acknowledgeAndRestore(e.clientRevision);return}let n;try{n=_f(Ql(this._text,this._contentType),e.edits)}catch(r){this._onError("Failed to apply content edits from editor",r),this._acknowledgeAndRestore(e.clientRevision);return}let i;try{i=yf(n,this._contentType,this._jsonFormat)}catch(r){this._onError("Failed to decode editor content",r),this._acknowledgeAndRestore(e.clientRevision);return}this._acknowledgedClientRevision=Math.max(this._acknowledgedClientRevision,e.clientRevision),i!==this._text&&(this._text=i,this._onDidChangeText.fire({text:i})),this._pushAcknowledgement()},reportSize:e=>{this._onDidReportSize.fire({height:e.height})}})}getText(){return this._text}setText(t,e={}){t===this._text&&!e.force||(this._text=t,this._pushFullUpdate(e.force))}reuse(t,e){this._readOnly=e,this._text=t,this._pushFullUpdate(!0)}getReadOnly(){return this._readOnly}setReadOnly(t){this._readOnly!==t&&(this._readOnly=t,this._editorInitialized&&this._editor.update({readOnly:t,acknowledgedClientRevision:this._acknowledgedClientRevision}))}applyEdits(t){if(t.length===0||!this._editorInitialized)return;let e;try{e=_f(Ql(this._text,this._contentType),t),this._text=yf(e,this._contentType,this._jsonFormat)}catch(n){this._onError("Failed to apply outgoing edits to local text",n);return}this._serverRevision++,this._editor.applyContentEdits({edits:t,serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision})}dispose(){this._onDidChangeText.dispose(),this._onDidInitialize.dispose(),this._onDidReportSize.dispose(),this._connection.close()}_pushFullUpdate(t){if(!this._editorInitialized)return;this._serverRevision++;let e;try{e=Ql(this._text,this._contentType)}catch(n){this._onError("Failed to encode text for editor",n);return}this._editor.update({content:e,readOnly:this._readOnly,serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision,force:t})}_pushAcknowledgement(){this._editorInitialized&&this._editor.update({serverRevision:this._serverRevision,acknowledgedClientRevision:this._acknowledgedClientRevision})}_acknowledgeAndRestore(t){this._acknowledgedClientRevision=Math.max(this._acknowledgedClientRevision,t),this._pushFullUpdate(!0)}};function lE(t,e){let n=t.filter(s=>"language"in s.selector&&s.selector.language===e);if(n.length>0)return n.length===1?{kind:"match",provider:n[0]}:{kind:"ambiguous",providers:n};let i=-1,r=[];for(let s of t){if(!("languagePrefix"in s.selector)||!e.startsWith(s.selector.languagePrefix))continue;let o=s.selector.languagePrefix.length;o>i?(i=o,r=[s]):o===i&&r.push(s)}if(r.length!==0)return r.length===1?{kind:"match",provider:r[0]}:{kind:"ambiguous",providers:r}}var cE=`
	:root { color-scheme: light dark; }
	html, body { margin: 0; padding: 0; background: transparent; }
	body {
		font-family: var(--vscode-font-family, system-ui, sans-serif);
		font-size: var(--vscode-font-size, 13px);
		color: var(--vscode-foreground, #1e1e1e);
		box-sizing: border-box;
	}
`,ro="vscode-markdown-editor::control",dE=1e4;function uE(t,e,n){let i=cE.replace(/<\/style/gi,"<\\/style"),r=(e??"").replace(/<\/style/gi,"<\\/style"),s=n?` nonce="${hE(n)}"`:"",o=`<style data-vscode-markdown-editor-base>${i}</style><style data-vscode-markdown-editor-theme>${r}</style><script${s}>(function(){var t=document.currentScript.previousElementSibling;var sendSize=function(){parent.postMessage({type:${JSON.stringify(ro)},height:Math.max(document.documentElement.scrollHeight,document.body?document.body.scrollHeight:0)},"*");};addEventListener("message",function(e){if(e.source!==parent)return;var d=e.data;if(d&&d.type===${JSON.stringify(ro)}&&typeof d.themeCss==="string")t.textContent=d.themeCss;});addEventListener("load",sendSize);new ResizeObserver(sendSize).observe(document.documentElement);})();<\/script>`,a=n?t.replace(/<script\b(?![^>]*\bnonce\s*=)/gi,`<script${s}`):t,l=a.search(/<\/head\s*>/i);if(l!==-1)return a.slice(0,l)+o+a.slice(l);let c=a.match(/<html[^>]*>/i);if(c?.index!==void 0){let d=c.index+c[0].length;return a.slice(0,d)+`<head>${o}</head>`+a.slice(d)}return`<!doctype html><html><head>${o}</head><body>${a}</body></html>`}function hE(t){return t.replaceAll("&","&amp;").replaceAll('"',"&quot;")}var so=class{constructor(e){this._options=e,this._providers=e.providers,this._frameLayer=document.createElement("div"),this._frameLayer.style.position="absolute",this._frameLayer.style.inset="0",this._frameLayer.style.height="0",this._frameLayer.style.pointerEvents="none",this._frameLayer.style.zIndex="1",e.frameRoot&&this._setFrameRoot(e.frameRoot),this._observer=typeof IntersectionObserver>"u"?void 0:new IntersectionObserver(n=>{for(let i of n)Array.from(this._logicalEditors).find(r=>r.element===i.target)?.setVisible(i.isIntersecting)},{root:e.root??null})}_frameLayer;_frameRoot;_restoreFrameRootPosition;_layoutObserver;_layoutFrame=0;_observer;_logicalEditors=new Set;_pools=new Map;_descriptorCache=new Map;_rejectedProviders=new Set;_providers;_generation=0;_descriptorCacheHits=0;_disposed=!1;updateProviders(e){this._providers=e,this._generation++,this._descriptorCache.clear(),this._rejectedProviders.clear(),this._descriptorCacheHits=0,this._disposePools();for(let n of this._logicalEditors)n.invalidate();this._options.onDidChange?.()}get diagnostics(){let e=0,n=0;for(let i of this._pools.values())e+=i.leasedFrames,n+=i.idleFrames;return{logicalEditors:this._logicalEditors.size,leasedFrames:e,idleFrames:n,descriptorCacheEntries:this._descriptorCache.size,descriptorCacheHits:this._descriptorCacheHits}}create(e,n,i){let r=lE(this._providers,e);if(!r)return;if(r.kind==="ambiguous"){this._options.onAmbiguous?.(e,r.providers);return}let s=kf(r.provider.id,n);if(this._rejectedProviders.has(s))return;let o=new mc(this,r.provider,n,i,this._options.defaultHeight??120,this._generation);return this._logicalEditors.add(o),this._observer?.observe(o.element),this._layoutObserver&&o.observeLayout(this._layoutObserver),this._observer||o.setVisible(!0),o}dispose(){if(!this._disposed){this._disposed=!0,this._observer?.disconnect(),this._layoutObserver?.disconnect(),cancelAnimationFrame(this._layoutFrame),window.removeEventListener("resize",this._scheduleLayout);for(let e of Array.from(this._logicalEditors))e.dispose();this._disposePools(),this._frameLayer.remove(),this._frameRoot&&this._restoreFrameRootPosition!==void 0&&(this._frameRoot.style.position=this._restoreFrameRootPosition)}}remove(e){this._observer?.unobserve(e.element),this._layoutObserver?.unobserve(e.element),this._logicalEditors.delete(e),e.frame?.unbind()}async resolve(e,n){let i=kf(e.provider.id,e.infoString),r=this._descriptorCache.get(i),s;try{r?this._descriptorCacheHits++:(r=e.provider.resolve(e.infoString),this._descriptorCache.set(i,r)),s=await r}catch{r&&this._descriptorCache.get(i)===r&&this._descriptorCache.delete(i),this._rejectEditor(e,n,i);return}if(this._disposed||e.disposed||n!==this._generation||!s){this._rejectEditor(e,n,i);return}let o=fE(e.provider.id,e.infoString,s),a=this._pools.get(o);if(!a){let l=this._ensureFrameRoot(e);a=new pc(s,this._frameLayer,l,this._options.scriptNonce,this._options.themeCss),this._pools.set(o,a)}e.resolve(a)}_rejectEditor(e,n,i){e.resolve(void 0),!this._disposed&&!e.disposed&&n===this._generation&&(this._rejectedProviders.add(i),this._options.onDidChange?.())}_ensureFrameRoot(e){return this._frameRoot??this._setFrameRoot(e.element.closest(".md-editor")??(this._options.root instanceof HTMLElement?this._options.root:document.body))}_setFrameRoot(e){if(this._frameRoot=e,e!==document.body&&getComputedStyle(e).position==="static"&&(this._restoreFrameRootPosition=e.style.position,e.style.position="relative"),e.appendChild(this._frameLayer),typeof ResizeObserver<"u"){this._layoutObserver=new ResizeObserver(()=>this._scheduleLayout()),this._layoutObserver.observe(e);for(let n of this._logicalEditors)n.observeLayout(this._layoutObserver)}return window.addEventListener("resize",this._scheduleLayout),e}_scheduleLayout=()=>{this._layoutFrame||(this._layoutFrame=requestAnimationFrame(()=>{this._layoutFrame=0;for(let e of this._pools.values())e.layout()}))};_disposePools(){for(let e of this._pools.values())e.dispose();this._pools.clear()}},mc=class{constructor(e,n,i,r,s,o){this._factory=e,this.provider=n,this.infoString=i,this._content=r,this.element=document.createElement("div"),this.element.style.width="100%",this.element.style.minHeight=`${s}px`,this._frameHost=document.createElement("div"),this._frameHost.style.width="100%",this.element.appendChild(this._frameHost),this.estimateHeight=()=>parseFloat(this.element.style.minHeight)||s,this._factory.resolve(this,o)}element;onEdit;estimateHeight;frame;disposed=!1;visible=!1;infoString;_frameHost;_content;_readOnly=!1;_pool;_resolved=!1;setContent(e){e!==this._content&&(this._content=e,this.frame?.bind(this))}setReadOnly(e){this._readOnly!==e&&(this._readOnly=e,this.frame?.bind(this))}setVisible(e){this.visible=e,this._resolved&&(e?this._pool?.acquire(this):this.hasFocus()||this._pool?.release(this))}resolve(e){this.disposed||(this._resolved=!0,this._pool=e,e?e.descriptor.initialHeight!==void 0&&(this.element.style.minHeight=`${e.descriptor.initialHeight}px`):this._renderFallback(),this.visible&&e?.acquire(this))}invalidate(){this.frame?.unbind(),this._pool=void 0,this._resolved=!1,this._renderFallback()}bindFrame(e){this.frame=e,e.layout(this)}unbindFrame(e){this.frame&&(this.element.style.minHeight=`${e}px`,this.frame=void 0)}applyGuestText(e){if(e===this._content)return;let n=H.replace(O.ofLength(this._content.length),e);this._content=e,this.onEdit?.(n)}applyHeight(e){let n=vc(e);this.element.style.minHeight=`${n}px`,this.frame&&(this.frame.iframe.style.height=`${n}px`,this.frame.layout(this))}observeLayout(e){e.observe(this.element)}hasFocus(){return this.frame!==void 0&&document.activeElement===this.frame.iframe}get content(){return this._content}get readOnly(){return this._readOnly}get frameHost(){return this._frameHost}dispose(){this.disposed||(this.disposed=!0,this._factory.remove(this),this.element.remove())}_renderFallback(){let e=document.createElement("pre"),n=document.createElement("code");n.textContent=this._content,e.appendChild(n),this._frameHost.replaceChildren(e)}},pc=class{constructor(e,n,i,r,s){this._frameLayer=n,this._frameRoot=i,this._scriptNonce=r,this._themeCss=s,this.descriptor=e}descriptor;_frames=new Set;get leasedFrames(){return Array.from(this._frames).filter(e=>e.editor!==void 0).length}get idleFrames(){return this._frames.size-this.leasedFrames}acquire(e){if(e.frame){e.frame.bind(e);return}(Array.from(this._frames).find(n=>n.editor===void 0)??this._createFrame()).bind(e)}release(e){let n=e.frame;!n||n.editor!==e||e.hasFocus()||n.unbind()}park(e){e.style.top="-100000px",e.style.left="0"}dispose(){for(let e of this._frames)e.dispose();this._frames.clear()}layout(){for(let e of this._frames)e.editor&&e.layout(e.editor)}_createFrame(){let e=new gc(this,this.descriptor,this._frameLayer,this._frameRoot,this._scriptNonce,this._themeCss);return this._frames.add(e),e}},gc=class{constructor(e,n,i,r,s,o){this._descriptor=n,this._frameRoot=r,this._scriptNonce=s,this._themeCss=o,this.pool=e;let a=document.createElement("iframe");a.setAttribute("sandbox",Em(n.sandbox)),a.setAttribute("allow",n.sandbox?.clipboardWrite?"clipboard-write":""),a.style.width="100%",a.style.border="none",a.style.display="block",a.style.position="absolute",a.style.pointerEvents="auto",a.style.background="transparent",a.style.height=`${n.initialHeight??120}px`,e.park(a),a.addEventListener("blur",()=>{let l=this.editor;l&&!l.visible&&this.pool.release(l)}),this.iframe=a,this._onWindowMessage=l=>{if(l.source!==a.contentWindow)return;let c=l.data;c?.type!==ro||typeof c.height!="number"||!Number.isFinite(c.height)||this.editor?.applyHeight(c.height)},window.addEventListener("message",this._onWindowMessage),i.appendChild(a),queueMicrotask(()=>this._setup())}iframe;editor;pool;_host;_transport;_pendingEditor;_disposed=!1;_onWindowMessage;bind(e){if(this.editor===e){this._host?.setText(e.content),this._host?.setReadOnly(e.readOnly),this.iframe.style.height=`${vc(e.estimateHeight())}px`,this.layout(e);return}this.editor&&this.editor!==e&&this.unbind(),this._pendingEditor=e,this._host&&this._host.reuse(e.content,e.readOnly),this.editor=e,this._pendingEditor=void 0,e.bindFrame(this),this.iframe.style.height=`${vc(e.estimateHeight())}px`}unbind(){let e=this.editor;if(!e)return;let n=parseFloat(this.iframe.style.height)||this._descriptor.initialHeight||120;this.editor=void 0,e.unbindFrame(n),this.pool.park(this.iframe)}layout(e){if(this.editor!==e)return;let n=e.element.getBoundingClientRect(),i=this._frameRoot.getBoundingClientRect(),r=this._frameRoot===document.body,s=r?n.top+window.scrollY:n.top-i.top+this._frameRoot.scrollTop,o=r?n.left+window.scrollX:n.left-i.left+this._frameRoot.scrollLeft;this.iframe.style.top=`${s}px`,this.iframe.style.left=`${o}px`,this.iframe.style.width=`${n.width}px`}dispose(){this._disposed||(this._disposed=!0,this.unbind(),window.removeEventListener("message",this._onWindowMessage),this._host?.dispose(),this._transport?.dispose(),this.iframe.remove())}_setup(){if(this._disposed)return;let e=this.iframe.contentWindow;if(!e){requestAnimationFrame(()=>this._setup());return}this._transport=new mx(window,e);let n=new cx(Hf.create(this._transport)),i=this._pendingEditor??this.editor;this._host=new aE({connection:n,contentType:this._descriptor.contentType??"text",initialText:i?.content??"",readOnly:i?.readOnly??!1}),this._host.onDidChangeText(({text:r})=>this.editor?.applyGuestText(r)),this._host.onDidReportSize(({height:r})=>this.editor?.applyHeight(r)),this.iframe.addEventListener("load",()=>this._postTheme(),{once:!0}),this.iframe.srcdoc=uE(this._descriptor.html,this._getThemeCss(),this._scriptNonce)}_getThemeCss(){return typeof this._themeCss=="function"?this._themeCss():this._themeCss}_postTheme(){let e=this._getThemeCss();e!==void 0&&this.iframe.contentWindow?.postMessage({type:ro,themeCss:e},"*")}};function Em(t){let e=["allow-scripts"];return t?.forms&&e.push("allow-forms"),t?.downloads&&e.push("allow-downloads"),t?.pointerLock&&e.push("allow-pointer-lock"),e.join(" ")}function vc(t){return Math.max(1,Math.min(dE,Math.ceil(t)))}function kf(t,e){return`${t}\0${e}`}function fE(t,e,n){return[t,e,n.contentType??"text",Em(n.sandbox),n.sandbox?.clipboardWrite===!0?"clipboard-write":""].join("\0")}function Cm(){let t=[];for(let e=1;e<=15;e++){let n=[];e&1&&n.push("font-style: italic;"),e&2&&n.push("font-weight: bold;");let i=[];e&4&&i.push("underline"),e&8&&i.push("line-through"),i.length&&n.push(`text-decoration: ${i.join(" ")};`),t.push(`.tok-mdhl-fs-${e} { ${n.join(" ")} }`)}return t.join(`
`)}function mE(t){return t.map((e,n)=>`.tok-mdhl-fg-${n} { color: ${e}; }`).join(`
`)}function pE(t,e){let n=[];return t>0&&n.push(`mdhl-fg-${t}`),e>0&&n.push(`mdhl-fs-${e}`),n.length?n.join("."):void 0}function Cc(t){let e=0;for(let i of t)e+=i.length;let n=O.ofLength(e);return{getTokens:()=>({range:n,tokens:t})}}function Tc(t){return t>0?[{length:t,className:void 0}]:[]}function gE(t,e,n){let i=n-e;if(i===0)return t;if(t.length===0)return Tc(n);let r=t[t.length-1],s=r.length+i;return s<=0?Tc(n):[...t.slice(0,-1),{length:s,className:r.className}]}var Oc=class{#e;#t;snapshot;#r;#s;constructor(e,n,i){this.#r=e,this.#s=n,this.#e=i,this.#t=Tc(i.length),this.snapshot=V("mdSyntaxHighlight",Cc(this.#t)),this.#i(i)}update(e,n){let i=e.apply(this.#e),r=this.#e.length;this.#t=gE(this.#t,r,i.length),this.#e=i,this.snapshot.set(Cc(this.#t),n,Ei.replace(O.ofLength(r),i.length)),this.#i(i)}refresh(){this.#i(this.#e)}dispose(){this.#r._remove(this)}async#i(e){let n=await this.#r.request(e,this.#s);e===this.#e&&(this.#t=n.tokens.map(i=>({length:i.length,className:pE(i.foreground,i.fontStyle)})),this.snapshot.set(Cc(this.#t),void 0,Ei.replace(O.ofLength(e.length),e.length)))}},fo=class{#e=0;#t=new Map;#r=new Set;#s;#i;constructor(e){this.#i=e,this.#s=document.createElement("style"),this.#s.textContent=Cm(),document.head.appendChild(this.#s)}create(e,n){let i=new Oc(this,e,n);return this.#r.add(i),i}request(e,n){let i=this.#e++;return new Promise(r=>{this.#t.set(i,r),this.#i({type:"highlight",requestId:i,source:e,languageId:n})})}handleMessage(e){switch(e.type){case"highlightResult":{let n=this.#t.get(e.requestId);return n&&(this.#t.delete(e.requestId),this.#o(e.colorMap),n({tokens:e.tokens,colorMap:e.colorMap})),!0}case"highlightThemeChanged":{for(let n of this.#r)n.refresh();return!0}default:return!1}}_remove(e){this.#r.delete(e)}#o(e){this.#s.textContent=`${Cm()}
${mE(e)}`}};var mo=class extends pe{#e=new Map;#t;#r;#s=!1;constructor(e,n){super(),this.#t=e.map(i=>({id:i.id,uriPattern:new RegExp(i.source,i.flags),initialKind:i.initialKind})),this.#r=n}createLinkPresentation(e){let n=this.#t.find(s=>vE(s.uriPattern,e));if(!n)return;let i=this.#e.get(e);i||(i={presentation:V(`linkPresentation:${e}`,{kind:n.initialKind,isLoading:!0}),references:0},this.#e.set(e,i)),i.references++,this.#o();let r=!1;return{presentation:i.presentation,dispose:()=>{r||(r=!0,this.#i(e,i))}}}handleMessage(e){if(!po(e)||e.type!=="richLinkPresentations"||!Array.isArray(e.presentations))return!1;for(let n of e.presentations){if(!po(n)||typeof n.href!="string")continue;let i=this.#e.get(n.href);i&&i.presentation.set(bE(n.presentation),void 0)}return!0}dispose(){this.#e.clear(),super.dispose()}#i(e,n){n.references--,n.references===0&&this.#e.get(e)===n&&(this.#e.delete(e),this.#o())}#o(){this.#s||(this.#s=!0,queueMicrotask(()=>{this.#s=!1,this.#r({type:"richLinkTargets",hrefs:[...this.#e.keys()]})}))}};function vE(t,e){return t.lastIndex=0,t.test(e)}function bE(t){if(!po(t)||!_E(t.kind))return;let e=typeof t.title=="string"?t.title:void 0,n=typeof t.detail=="string"?t.detail:void 0,i=typeof t.reference=="string"?t.reference:void 0,r=typeof t.tooltip=="string"?t.tooltip:void 0,s=typeof t.ariaLabel=="string"?t.ariaLabel:void 0,o=Tm(t.status),a=Tm(t.secondaryStatus),l=t.isLoading===!0;return{kind:t.kind,...e?{title:e}:{},...n?{detail:n}:{},...i?{reference:i}:{},...o?{status:o}:{},...a?{secondaryStatus:a}:{},...r?{tooltip:r}:{},...s?{ariaLabel:s}:{},...l?{isLoading:!0}:{}}}function Tm(t){return po(t)&&wE(t.kind)&&typeof t.label=="string"?{kind:t.kind,label:t.label}:void 0}function _E(t){return t==="resource"||t==="issue"||t==="pullRequest"||t==="commit"||t==="file"||t==="folder"||t==="session"||t==="repository"||t==="branch"}function wE(t){return t==="neutral"||t==="pending"||t==="success"||t==="warning"||t==="error"||t==="open"||t==="closed"||t==="merged"||t==="draft"||t==="notPlanned"}function po(t){return typeof t=="object"&&t!==null}var Lc=class extends pe{model=new Zr;isUpdatingFromExtension=!1;#e=!1;#t=0;#r=[];#s=1;#i=new Map;#o;#d;#u;#a=new Ns;#h;#f=V("acceptsComments",!1);#m;#n=acquireVsCodeApi();#p=new fo(e=>this.#n.postMessage(e));#l;constructor(e,n){super();let i=document.querySelector('meta[name="vscode-markdown-editor-message-secret"]')?.content;if(!i)throw new Error("Missing Markdown editor message secret");this.#m=i,this.#l=n.richLinksEnabled?this._register(new mo(n.linkPresentationRules,r=>this.#n.postMessage(r))):void 0,this.model.sourceText.set(new gn(n.content),void 0),this.model.readonlyMode.set(n.readonly,void 0),window.addEventListener("message",r=>{let s=r.data;if(!(!s||typeof s!="object"||s.messageSecret!==this.#m)&&!this.#p.handleMessage(s)&&!this.#l?.handleMessage(s))switch(s.type){case"update":{this.isUpdatingFromExtension=!0,this.model.replaceSourceText(new gn(s.content)),this.isUpdatingFromExtension=!1;break}case"codeBlockEditorProviders":{let o=SE(s.codeBlockEditorProviders);this.#r=o,this.#u?.updateProviders(this.#g(o));break}case"resolvedCodeBlockEditor":{if(typeof s.requestId!="number")break;let o=this.#i.get(s.requestId);o&&(this.#i.delete(s.requestId),o(Om(s.descriptor)));break}case"gutterMarkers":{let o=s.markers.map(a=>({range:O.fromTo(a.start,a.endExclusive),type:a.type}));this.model.gutterMarkers.set(o,void 0);break}case"comments":{this.#e=!0,this.#a.set(s.comments.map(o=>({id:o.id,range:O.fromTo(o.start,o.endExclusive),body:o.body,author:o.author}))),this.#e=!1,this.#f.set(!!s.acceptsComments,void 0);break}case"revealComment":{this.#h?.revealComment(s.id);break}case"command":{let o=En.find(a=>a.id===s.command);o&&this.#o?.executeCommand(o);break}}}),this.#b(e,n.content),this.#n.postMessage({type:"ready",documentVersion:n.documentVersion}),this._register({dispose:()=>{for(let r of this.#i.values())r(void 0);this.#i.clear()}})}#b(e,n){let i=this.model,r=document.querySelector('meta[name="vscode-markdown-editor-script-nonce"]')?.content,s=this._register(new so({providers:this.#g(this.#r),scriptNonce:r,themeCss:()=>`:root { ${document.documentElement.getAttribute("style")??""} }`,onAmbiguous:(x,C)=>this.#n.postMessage({type:"codeBlockEditorDiagnostic",message:`Ambiguous providers for ${x}: ${C.map(k=>k.id).join(", ")}`}),onDidChange:()=>this.#d?.refreshEmbeddedCodeEditors()}));this.#u=s;let o=this.#v(),a=this._register(new Ts(i,{classNames:["md-theme-vscode-default"],syntaxHighlighter:this.#p,linkPresentationProvider:this.#l,embeddedCodeEditorFactory:s,onEmbeddedCodeEditorEdit:(x,C)=>{let k=i.document.get(),E=ot(k,x);if(E===void 0)return;let L=E+x.codeOffset;i.applyEdit(new H(C.replacements.map(D=>ze.replace(D.replaceRange.delta(L),D.newText))))},onOpenLink:x=>{this.#n.postMessage({type:"openLink",href:x})},onToggleCheckbox:(x,C)=>{i.setTaskCheckboxChecked(x,C)},renderCustomCodeBlock:(x,C)=>{if(x!=="mermaid")return;let k=document.createElement("div");k.className="md-mermaid",k.textContent=C,k.setAttribute("aria-busy","true");let E=`mermaid-${this.#t++}`;return yE().then(L=>L.render(E,C)).then(({svg:L})=>{k.innerHTML=L,k.setAttribute("aria-busy","false")}).catch(L=>{k.textContent=C,k.setAttribute("aria-busy","false"),this.#n.postMessage({type:"codeBlockEditorDiagnostic",message:`Failed to render Mermaid diagram: ${L instanceof Error?L.message:String(L)}`})}),k}}));this.#d=a,this.#o=this._register(new Is(i,a,{clipboardStrategy:new Ls,keyboardProfile:Eh,forwardedKeyboardProfile:Ch,historyStrategy:{undo:()=>this.#n.postMessage({type:"history",command:"undo"}),redo:()=>this.#n.postMessage({type:"history",command:"redo"})}}));let l,c=()=>{let x=document.hasFocus()&&document.activeElement===a.element;x!==l&&(l=x,this.#n.postMessage({type:"editorFocusChanged",focused:x}))},d=()=>queueMicrotask(c);document.addEventListener("focusin",c),document.addEventListener("focusout",d),window.addEventListener("focus",c),window.addEventListener("blur",c),this._register({dispose:()=>{document.removeEventListener("focusin",c),document.removeEventListener("focusout",d),window.removeEventListener("focus",c),window.removeEventListener("blur",c)}}),e.appendChild(a.element),c();let h=document.body.classList.contains("vscode-light");this.#h=this._register(new As(this.#a,a,{theme:h?"light":"dark",resolveLine:x=>i.sourceText.get().value.slice(0,x).split(`
`).length}));let u;this._register(ee(x=>{let C=x.readObservable(this.#f);C&&!u?u=new Ms(i,a,{onSubmit:({text:k,range:E})=>{this.#n.postMessage({type:"addComment",start:E.start,endExclusive:E.endExclusive,text:k})}}):!C&&u&&(u.dispose(),u=void 0)})),this._register({dispose:()=>u?.dispose()});let f=new Set(this.#a.comments.get().map(x=>x.id));if(this._register(ee(x=>{let C=new Set(x.readObservable(this.#a.comments).map(k=>k.id));if(!this.#e)for(let k of f)C.has(k)||this.#n.postMessage({type:"deleteComment",id:k});f=C})),o.selection){let x=n.length,C=Math.min(o.selection.anchor,x),k=Math.min(o.selection.active,x);i.selection.set(new $(C,k),void 0)}let m=!1,p=()=>{m=!1,this.#c({scrollTop:e.scrollTop})},v=()=>{m||(m=!0,requestAnimationFrame(p))};e.addEventListener("scroll",v,{passive:!0}),this._register({dispose:()=>e.removeEventListener("scroll",v)});let g=()=>{document.visibilityState==="hidden"&&this.#c({scrollTop:e.scrollTop})};document.addEventListener("visibilitychange",g),window.addEventListener("pagehide",p),this._register({dispose:()=>{document.removeEventListener("visibilitychange",g),window.removeEventListener("pagehide",p)}}),this._register(ee(x=>{let C=x.readObservable(this.model.selection);this.#c({selection:C?{anchor:C.anchor,active:C.active}:void 0})}));let w=!0;this._register(ee(x=>{let C=x.readObservable(this.model.readonlyMode);w||this.#n.postMessage({type:"setReadonly",readonly:C}),w=!1}));let y=this.model.sourceText.get().value;this._register(ee(x=>{let C=x.readObservable(this.model.sourceText).value;!this.isUpdatingFromExtension&&C!==y&&this.#n.postMessage({type:"edit",...OE(y,C)}),y=C})),this.#w(e,o.scrollTop)}#g(e){return e.map(n=>({id:n.id,selector:n.selector,resolve:n.source.kind==="static"?async()=>n.source.kind==="static"?n.source.descriptor:void 0:i=>this.#_(n.id,i)}))}#_(e,n){let i=this.#s++;return new Promise(r=>{this.#i.set(i,r),this.#n.postMessage({type:"resolveCodeBlockEditor",requestId:i,providerId:e,language:n})})}#v(){return this.#n.getState()??{}}#c(e){this.#n.setState({...this.#v(),...e})}#w(e,n){if(typeof n!="number"||n<=0)return;let i=0,r=()=>{e.scrollTop=n,++i<6&&Math.abs(e.scrollTop-n)>1&&requestAnimationFrame(r)};requestAnimationFrame(r)}},Rc;function yE(){return Rc||(Rc=import("./mermaid.core-VZVANW2P.js").then(t=>(t.default.initialize({startOnLoad:!1,theme:"default"}),t.default))),Rc}function kE(){let t=document.getElementById("vscode-markdown-editor-initial-state");if(!(t instanceof HTMLMetaElement))throw new Error("Markdown editor initial state was not found.");t.remove();let e=JSON.parse(decodeURIComponent(t.content));if(!xE(e))throw new Error("Markdown editor initial state is invalid.");return e}function xE(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.content=="string"&&typeof e.documentVersion=="number"&&typeof e.readonly=="boolean"&&typeof e.richLinksEnabled=="boolean"&&Array.isArray(e.linkPresentationRules)}function SE(t){return Array.isArray(t)?t.filter(zE):[]}function zE(t){if(typeof t!="object"||t===null)return!1;let e=t;return typeof e.id=="string"&&EE(e.selector)&&CE(e.source)}function EE(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.language=="string"&&e.languagePrefix===void 0||e.language===void 0&&typeof e.languagePrefix=="string"}function CE(t){if(!t||typeof t!="object")return!1;let e=t;return e.kind==="exportApi"||e.kind==="static"&&Om(e.descriptor)!==void 0}function Om(t){if(!t||typeof t!="object")return;let e=t;if(!(typeof e.html!="string"||e.contentType!=="text"&&e.contentType!=="json"||e.cacheKey!==void 0&&typeof e.cacheKey!="string"||e.initialHeight!==void 0&&(typeof e.initialHeight!="number"||!Number.isFinite(e.initialHeight)||e.initialHeight<=0)||!TE(e.sandbox)))return e}function TE(t){if(t===void 0)return!0;if(!t||typeof t!="object")return!1;let e=t;return["forms","downloads","pointerLock","clipboardWrite"].every(n=>e[n]===void 0||typeof e[n]=="boolean")}function OE(t,e){let n=0;for(;n<t.length&&n<e.length&&t.charCodeAt(n)===e.charCodeAt(n);)n++;let i=t.length,r=e.length;for(;i>n&&r>n&&t.charCodeAt(i-1)===e.charCodeAt(r-1);)i--,r--;return{start:n,endExclusive:i,text:e.slice(n,r)}}new Lc(document.getElementById("editor"),kE());